Skip to content

Commit 3f9d0f9

Browse files
authored
Merge pull request #1638 from selvintxavier/flow_steering
bnxt_re/lib: Add Flow steering support
2 parents 1f9a5e3 + 0f09871 commit 3f9d0f9

File tree

3 files changed

+66
-24
lines changed

3 files changed

+66
-24
lines changed

providers/bnxt_re/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ static const struct verbs_context_ops bnxt_re_cntx_ops = {
121121
.free_context = bnxt_re_free_context,
122122

123123
.create_qp_ex = bnxt_re_create_qp_ex,
124+
.create_flow = bnxt_re_create_flow,
125+
.destroy_flow = bnxt_re_destroy_flow,
124126
};
125127

126128
static inline bool bnxt_re_is_chip_gen_p7(struct bnxt_re_chip_ctx *cctx)

providers/bnxt_re/verbs.c

Lines changed: 61 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,7 @@ static void bnxt_re_poll_success_rcqe(struct bnxt_re_qp *qp,
719719
{
720720
uint8_t flags, is_imm, is_rdma;
721721
struct bnxt_re_rc_cqe *rcqe;
722+
uint8_t qp_type = qp->qptyp;
722723
struct bnxt_re_wrid *swque;
723724
struct bnxt_re_queue *rq;
724725
uint32_t rcqe_len;
@@ -747,31 +748,34 @@ static void bnxt_re_poll_success_rcqe(struct bnxt_re_qp *qp,
747748
ibvwc->status = IBV_WC_SUCCESS;
748749
ibvwc->qp_num = qp->qpid;
749750
rcqe_len = le32toh(rcqe->length);
750-
ibvwc->byte_len = (qp->qptyp == IBV_QPT_UD) ?
751-
rcqe_len & BNXT_RE_UD_CQE_LEN_MASK: rcqe_len ;
751+
ibvwc->byte_len = (qp_type == IBV_QPT_UD ||
752+
qp_type == IBV_QPT_RAW_PACKET) ?
753+
rcqe_len & BNXT_RE_UD_CQE_LEN_MASK : rcqe_len;
752754
ibvwc->opcode = IBV_WC_RECV;
753755

754-
flags = (le32toh(hdr->flg_st_typ_ph) >> BNXT_RE_BCQE_FLAGS_SHIFT) &
755-
BNXT_RE_BCQE_FLAGS_MASK;
756-
is_imm = (flags & BNXT_RE_RC_FLAGS_IMM_MASK) >>
757-
BNXT_RE_RC_FLAGS_IMM_SHIFT;
758-
is_rdma = (flags & BNXT_RE_RC_FLAGS_RDMA_MASK) >>
759-
BNXT_RE_RC_FLAGS_RDMA_SHIFT;
760-
ibvwc->wc_flags = 0;
761-
if (is_imm) {
762-
ibvwc->wc_flags |= IBV_WC_WITH_IMM;
763-
/* Completion reports the raw-data in LE format, While
764-
* user expects it in BE format. Thus, swapping on outgoing
765-
* data is needed. On a BE platform le32toh will do the swap
766-
* while on LE platform htobe32 will do the job.
767-
*/
768-
ibvwc->imm_data = htobe32(le32toh(rcqe->imm_key));
769-
if (is_rdma)
770-
ibvwc->opcode = IBV_WC_RECV_RDMA_WITH_IMM;
771-
}
756+
if (qp_type == IBV_QPT_UD || qp_type == IBV_QPT_RC) {
757+
flags = (le32toh(hdr->flg_st_typ_ph) >> BNXT_RE_BCQE_FLAGS_SHIFT) &
758+
BNXT_RE_BCQE_FLAGS_MASK;
759+
is_imm = (flags & BNXT_RE_RC_FLAGS_IMM_MASK) >>
760+
BNXT_RE_RC_FLAGS_IMM_SHIFT;
761+
is_rdma = (flags & BNXT_RE_RC_FLAGS_RDMA_MASK) >>
762+
BNXT_RE_RC_FLAGS_RDMA_SHIFT;
763+
ibvwc->wc_flags = 0;
764+
if (is_imm) {
765+
ibvwc->wc_flags |= IBV_WC_WITH_IMM;
766+
/* Completion reports the raw-data in LE format, While
767+
* user expects it in BE format. Thus, swapping on outgoing
768+
* data is needed. On a BE platform le32toh will do the swap
769+
* while on LE platform htobe32 will do the job.
770+
*/
771+
ibvwc->imm_data = htobe32(le32toh(rcqe->imm_key));
772+
if (is_rdma)
773+
ibvwc->opcode = IBV_WC_RECV_RDMA_WITH_IMM;
774+
}
772775

773-
if (qp->qptyp == IBV_QPT_UD)
774-
bnxt_re_fill_ud_cqe(ibvwc, hdr, cqe, flags);
776+
if (qp_type == IBV_QPT_UD)
777+
bnxt_re_fill_ud_cqe(ibvwc, hdr, cqe, flags);
778+
}
775779

776780
if (!qp->srq)
777781
bnxt_re_jqq_mod_last(qp->jrqq, head);
@@ -872,6 +876,7 @@ static int bnxt_re_poll_one(struct bnxt_re_cq *cq, int nwc, struct ibv_wc *wc,
872876
break;
873877
case BNXT_RE_WC_TYPE_RECV_RC:
874878
case BNXT_RE_WC_TYPE_RECV_UD:
879+
case BNXT_RE_WC_TYPE_RECV_RAW:
875880
rcqe = cqe;
876881
qp_handle = (uint64_t *)&rcqe->qp_handle;
877882
qp = (struct bnxt_re_qp *)
@@ -880,8 +885,6 @@ static int bnxt_re_poll_one(struct bnxt_re_cq *cq, int nwc, struct ibv_wc *wc,
880885
break; /*stale cqe. should be rung.*/
881886
pcqe = bnxt_re_poll_rcqe(qp, wc, cqe, &cnt);
882887
break;
883-
case BNXT_RE_WC_TYPE_RECV_RAW:
884-
break;
885888
case BNXT_RE_WC_TYPE_TERM:
886889
scqe = cqe;
887890
qp_handle = (uint64_t *)&scqe->qp_handle;
@@ -1135,6 +1138,11 @@ static int bnxt_re_check_qp_limits(struct bnxt_re_context *cntx,
11351138
rdev = cntx->rdev;
11361139
devattr = &rdev->devattr;
11371140

1141+
if (attr->qp_type != IBV_QPT_RC &&
1142+
attr->qp_type != IBV_QPT_UD &&
1143+
attr->qp_type != IBV_QPT_RAW_PACKET)
1144+
return EINVAL;
1145+
11381146
if (attr->cap.max_send_sge > devattr->max_sge)
11391147
return EINVAL;
11401148
if (attr->cap.max_recv_sge > devattr->max_sge)
@@ -2956,3 +2964,32 @@ int bnxt_re_destroy_ah(struct ibv_ah *ibvah)
29562964

29572965
return 0;
29582966
}
2967+
2968+
struct ibv_flow *bnxt_re_create_flow(struct ibv_qp *qp,
2969+
struct ibv_flow_attr *attr)
2970+
{
2971+
struct ibv_flow *flow;
2972+
int ret;
2973+
2974+
flow = calloc(1, sizeof(*flow));
2975+
if (!flow)
2976+
return NULL;
2977+
2978+
ret = ibv_cmd_create_flow(qp, flow, attr, NULL, 0);
2979+
if (ret) {
2980+
free(flow);
2981+
flow = NULL;
2982+
}
2983+
2984+
return flow;
2985+
}
2986+
2987+
int bnxt_re_destroy_flow(struct ibv_flow *flow)
2988+
{
2989+
int ret;
2990+
2991+
ret = ibv_cmd_destroy_flow(flow);
2992+
2993+
free(flow);
2994+
return ret;
2995+
}

providers/bnxt_re/verbs.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ int bnxt_re_post_srq_recv(struct ibv_srq *ibvsrq, struct ibv_recv_wr *wr,
120120
struct ibv_ah *bnxt_re_create_ah(struct ibv_pd *ibvpd,
121121
struct ibv_ah_attr *attr);
122122
int bnxt_re_destroy_ah(struct ibv_ah *ibvah);
123+
struct ibv_flow *bnxt_re_create_flow(struct ibv_qp *qp,
124+
struct ibv_flow_attr *flow);
125+
int bnxt_re_destroy_flow(struct ibv_flow *flow);
123126
void bnxt_re_async_event(struct ibv_context *context,
124127
struct ibv_async_event *event);
125128

0 commit comments

Comments
 (0)