Skip to content

Commit 0a01623

Browse files
selvintxavierjgunthorpe
authored andcommitted
RDMA/bnxt_re: Use rdma_read_gid_hw_context to retrieve HW gid index
bnxt_re HW maintains a GID table with only a single entry for the two duplicate GID entries (v1 and v2). Driver needs to map stack gid index to the HW table gid index. Use the new API rdma_read_gid_hw_context () to retrieve the HW GID context to get the HW table index. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Selvin Xavier <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 779820c commit 0a01623

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

drivers/infiniband/hw/bnxt_re/ib_verbs.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,7 @@ int bnxt_re_create_ah(struct ib_ah *ib_ah, struct rdma_ah_attr *ah_attr,
639639
const struct ib_global_route *grh = rdma_ah_read_grh(ah_attr);
640640
struct bnxt_re_dev *rdev = pd->rdev;
641641
const struct ib_gid_attr *sgid_attr;
642+
struct bnxt_re_gid_ctx *ctx;
642643
struct bnxt_re_ah *ah = container_of(ib_ah, struct bnxt_re_ah, ib_ah);
643644
u8 nw_type;
644645
int rc;
@@ -654,19 +655,18 @@ int bnxt_re_create_ah(struct ib_ah *ib_ah, struct rdma_ah_attr *ah_attr,
654655
/* Supply the configuration for the HW */
655656
memcpy(ah->qplib_ah.dgid.data, grh->dgid.raw,
656657
sizeof(union ib_gid));
657-
/*
658-
* If RoCE V2 is enabled, stack will have two entries for
659-
* each GID entry. Avoiding this duplicte entry in HW. Dividing
660-
* the GID index by 2 for RoCE V2
658+
sgid_attr = grh->sgid_attr;
659+
/* Get the HW context of the GID. The reference
660+
* of GID table entry is already taken by the caller.
661661
*/
662-
ah->qplib_ah.sgid_index = grh->sgid_index / 2;
662+
ctx = rdma_read_gid_hw_context(sgid_attr);
663+
ah->qplib_ah.sgid_index = ctx->idx;
663664
ah->qplib_ah.host_sgid_index = grh->sgid_index;
664665
ah->qplib_ah.traffic_class = grh->traffic_class;
665666
ah->qplib_ah.flow_label = grh->flow_label;
666667
ah->qplib_ah.hop_limit = grh->hop_limit;
667668
ah->qplib_ah.sl = rdma_ah_get_sl(ah_attr);
668669

669-
sgid_attr = grh->sgid_attr;
670670
/* Get network header type for this GID */
671671
nw_type = rdma_gid_attr_network_type(sgid_attr);
672672
ah->qplib_ah.nw_type = bnxt_re_stack_to_dev_nw_type(nw_type);
@@ -1593,6 +1593,7 @@ int bnxt_re_modify_qp(struct ib_qp *ib_qp, struct ib_qp_attr *qp_attr,
15931593
const struct ib_global_route *grh =
15941594
rdma_ah_read_grh(&qp_attr->ah_attr);
15951595
const struct ib_gid_attr *sgid_attr;
1596+
struct bnxt_re_gid_ctx *ctx;
15961597

15971598
qp->qplib_qp.modify_flags |= CMDQ_MODIFY_QP_MODIFY_MASK_DGID |
15981599
CMDQ_MODIFY_QP_MODIFY_MASK_FLOW_LABEL |
@@ -1604,19 +1605,19 @@ int bnxt_re_modify_qp(struct ib_qp *ib_qp, struct ib_qp_attr *qp_attr,
16041605
memcpy(qp->qplib_qp.ah.dgid.data, grh->dgid.raw,
16051606
sizeof(qp->qplib_qp.ah.dgid.data));
16061607
qp->qplib_qp.ah.flow_label = grh->flow_label;
1607-
/* If RoCE V2 is enabled, stack will have two entries for
1608-
* each GID entry. Avoiding this duplicte entry in HW. Dividing
1609-
* the GID index by 2 for RoCE V2
1608+
sgid_attr = grh->sgid_attr;
1609+
/* Get the HW context of the GID. The reference
1610+
* of GID table entry is already taken by the caller.
16101611
*/
1611-
qp->qplib_qp.ah.sgid_index = grh->sgid_index / 2;
1612+
ctx = rdma_read_gid_hw_context(sgid_attr);
1613+
qp->qplib_qp.ah.sgid_index = ctx->idx;
16121614
qp->qplib_qp.ah.host_sgid_index = grh->sgid_index;
16131615
qp->qplib_qp.ah.hop_limit = grh->hop_limit;
16141616
qp->qplib_qp.ah.traffic_class = grh->traffic_class;
16151617
qp->qplib_qp.ah.sl = rdma_ah_get_sl(&qp_attr->ah_attr);
16161618
ether_addr_copy(qp->qplib_qp.ah.dmac,
16171619
qp_attr->ah_attr.roce.dmac);
16181620

1619-
sgid_attr = qp_attr->ah_attr.grh.sgid_attr;
16201621
rc = rdma_read_gid_l2_fields(sgid_attr, NULL,
16211622
&qp->qplib_qp.smac[0]);
16221623
if (rc)

0 commit comments

Comments
 (0)