Skip to content

Commit 0c4dcd6

Browse files
Devesh Sharmajgunthorpe
Devesh Sharma
authored andcommitted
RDMA/bnxt_re: Refactor hardware queue memory allocation
At top level there are three major data structure addition. viz bnxt_qplib_hwq_attr, bnxt_qplib_sg_info and bnxt_qplib_tqm_ctx Intorduction of first data structure reduces the arguments list to bnxt_re_alloc_init_hwq() function. There are changes all over the driver code to incorporate this new structure. The caller needs to fill the attribute data structure and pass to this function. The second data structure is to pass memory region description viz. sghead, page_size and page_shift. There are changes all over the driver code to initialize bnxt_re_sg_info data structure. The new data structure helps to reduce the argument list of __alloc_pbl() function call. Till now the TQM rings related members were not collected under any specific data-structure making it hard to manage. The third data sctructure bnxt_qplib_tqm_ctx is added to refactor the TQM queue allocation and initialization. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Naresh Kumar PBS <[email protected]> Signed-off-by: Selvin Xavier <[email protected]> Signed-off-by: Devesh Sharma <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 0cfb329 commit 0c4dcd6

File tree

9 files changed

+525
-332
lines changed

9 files changed

+525
-332
lines changed

drivers/infiniband/hw/bnxt_re/ib_verbs.c

+21-5
Original file line numberDiff line numberDiff line change
@@ -871,9 +871,11 @@ static int bnxt_re_init_user_qp(struct bnxt_re_dev *rdev, struct bnxt_re_pd *pd,
871871
return PTR_ERR(umem);
872872

873873
qp->sumem = umem;
874-
qplib_qp->sq.sg_info.sglist = umem->sg_head.sgl;
874+
qplib_qp->sq.sg_info.sghead = umem->sg_head.sgl;
875875
qplib_qp->sq.sg_info.npages = ib_umem_num_pages(umem);
876876
qplib_qp->sq.sg_info.nmap = umem->nmap;
877+
qplib_qp->sq.sg_info.pgsize = PAGE_SIZE;
878+
qplib_qp->sq.sg_info.pgshft = PAGE_SHIFT;
877879
qplib_qp->qp_handle = ureq.qp_handle;
878880

879881
if (!qp->qplib_qp.srq) {
@@ -884,9 +886,11 @@ static int bnxt_re_init_user_qp(struct bnxt_re_dev *rdev, struct bnxt_re_pd *pd,
884886
if (IS_ERR(umem))
885887
goto rqfail;
886888
qp->rumem = umem;
887-
qplib_qp->rq.sg_info.sglist = umem->sg_head.sgl;
889+
qplib_qp->rq.sg_info.sghead = umem->sg_head.sgl;
888890
qplib_qp->rq.sg_info.npages = ib_umem_num_pages(umem);
889891
qplib_qp->rq.sg_info.nmap = umem->nmap;
892+
qplib_qp->rq.sg_info.pgsize = PAGE_SIZE;
893+
qplib_qp->rq.sg_info.pgshft = PAGE_SHIFT;
890894
}
891895

892896
qplib_qp->dpi = &cntx->dpi;
@@ -976,6 +980,8 @@ static struct bnxt_re_qp *bnxt_re_create_shadow_qp
976980
qp->qplib_qp.sq.max_sge = 2;
977981
/* Q full delta can be 1 since it is internal QP */
978982
qp->qplib_qp.sq.q_full_delta = 1;
983+
qp->qplib_qp.sq.sg_info.pgsize = PAGE_SIZE;
984+
qp->qplib_qp.sq.sg_info.pgshft = PAGE_SHIFT;
979985

980986
qp->qplib_qp.scq = qp1_qp->scq;
981987
qp->qplib_qp.rcq = qp1_qp->rcq;
@@ -984,6 +990,8 @@ static struct bnxt_re_qp *bnxt_re_create_shadow_qp
984990
qp->qplib_qp.rq.max_sge = qp1_qp->rq.max_sge;
985991
/* Q full delta can be 1 since it is internal QP */
986992
qp->qplib_qp.rq.q_full_delta = 1;
993+
qp->qplib_qp.rq.sg_info.pgsize = PAGE_SIZE;
994+
qp->qplib_qp.rq.sg_info.pgshft = PAGE_SHIFT;
987995

988996
qp->qplib_qp.mtu = qp1_qp->mtu;
989997

@@ -1043,6 +1051,8 @@ static int bnxt_re_init_rq_attr(struct bnxt_re_qp *qp,
10431051
if (qplqp->rq.max_sge > dev_attr->max_qp_sges)
10441052
qplqp->rq.max_sge = dev_attr->max_qp_sges;
10451053
}
1054+
qplqp->rq.sg_info.pgsize = PAGE_SIZE;
1055+
qplqp->rq.sg_info.pgshft = PAGE_SHIFT;
10461056

10471057
return 0;
10481058
}
@@ -1095,6 +1105,8 @@ static void bnxt_re_init_sq_attr(struct bnxt_re_qp *qp,
10951105
* unexpected Queue full condition
10961106
*/
10971107
qplqp->sq.q_full_delta -= 1;
1108+
qplqp->sq.sg_info.pgsize = PAGE_SIZE;
1109+
qplqp->sq.sg_info.pgshft = PAGE_SHIFT;
10981110
}
10991111

11001112
static void bnxt_re_adjust_gsi_sq_attr(struct bnxt_re_qp *qp,
@@ -1511,9 +1523,11 @@ static int bnxt_re_init_user_srq(struct bnxt_re_dev *rdev,
15111523
return PTR_ERR(umem);
15121524

15131525
srq->umem = umem;
1514-
qplib_srq->sg_info.sglist = umem->sg_head.sgl;
1526+
qplib_srq->sg_info.sghead = umem->sg_head.sgl;
15151527
qplib_srq->sg_info.npages = ib_umem_num_pages(umem);
15161528
qplib_srq->sg_info.nmap = umem->nmap;
1529+
qplib_srq->sg_info.pgsize = PAGE_SIZE;
1530+
qplib_srq->sg_info.pgshft = PAGE_SHIFT;
15171531
qplib_srq->srq_handle = ureq.srq_handle;
15181532
qplib_srq->dpi = &cntx->dpi;
15191533

@@ -2368,7 +2382,7 @@ static int bnxt_re_build_reg_wqe(const struct ib_reg_wr *wr,
23682382
wqe->frmr.pbl_dma_ptr = qplib_frpl->hwq.pbl_dma_ptr[0];
23692383
wqe->frmr.page_list = mr->pages;
23702384
wqe->frmr.page_list_len = mr->npages;
2371-
wqe->frmr.levels = qplib_frpl->hwq.level + 1;
2385+
wqe->frmr.levels = qplib_frpl->hwq.level;
23722386
wqe->type = BNXT_QPLIB_SWQE_TYPE_REG_MR;
23732387

23742388
/* Need unconditional fence for reg_mr
@@ -2742,6 +2756,8 @@ int bnxt_re_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
27422756
if (entries > dev_attr->max_cq_wqes + 1)
27432757
entries = dev_attr->max_cq_wqes + 1;
27442758

2759+
cq->qplib_cq.sg_info.pgsize = PAGE_SIZE;
2760+
cq->qplib_cq.sg_info.pgshft = PAGE_SHIFT;
27452761
if (udata) {
27462762
struct bnxt_re_cq_req req;
27472763
struct bnxt_re_ucontext *uctx = rdma_udata_to_drv_context(
@@ -2758,7 +2774,7 @@ int bnxt_re_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
27582774
rc = PTR_ERR(cq->umem);
27592775
goto fail;
27602776
}
2761-
cq->qplib_cq.sg_info.sglist = cq->umem->sg_head.sgl;
2777+
cq->qplib_cq.sg_info.sghead = cq->umem->sg_head.sgl;
27622778
cq->qplib_cq.sg_info.npages = ib_umem_num_pages(cq->umem);
27632779
cq->qplib_cq.sg_info.nmap = cq->umem->nmap;
27642780
cq->qplib_cq.dpi = &uctx->dpi;

drivers/infiniband/hw/bnxt_re/main.c

+11-9
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ static void bnxt_re_destroy_chip_ctx(struct bnxt_re_dev *rdev)
9090
rdev->chip_ctx = NULL;
9191
rdev->rcfw.res = NULL;
9292
rdev->qplib_res.cctx = NULL;
93+
rdev->qplib_res.pdev = NULL;
94+
rdev->qplib_res.netdev = NULL;
9395
kfree(chip_ctx);
9496
}
9597

@@ -151,7 +153,7 @@ static void bnxt_re_limit_pf_res(struct bnxt_re_dev *rdev)
151153
ctx->cq_count = min_t(u32, BNXT_RE_MAX_CQ_COUNT, attr->max_cq);
152154
if (!bnxt_qplib_is_chip_gen_p5(rdev->chip_ctx))
153155
for (i = 0; i < MAX_TQM_ALLOC_REQ; i++)
154-
rdev->qplib_ctx.tqm_count[i] =
156+
rdev->qplib_ctx.tqm_ctx.qcount[i] =
155157
rdev->dev_attr.tqm_alloc_reqs[i];
156158
}
157159

@@ -982,8 +984,8 @@ static void bnxt_re_free_nq_res(struct bnxt_re_dev *rdev)
982984
for (i = 0; i < rdev->num_msix - 1; i++) {
983985
type = bnxt_qplib_get_ring_type(rdev->chip_ctx);
984986
bnxt_re_net_ring_free(rdev, rdev->nq[i].ring_id, type);
985-
rdev->nq[i].res = NULL;
986987
bnxt_qplib_free_nq(&rdev->nq[i]);
988+
rdev->nq[i].res = NULL;
987989
}
988990
}
989991

@@ -1032,7 +1034,7 @@ static int bnxt_re_alloc_res(struct bnxt_re_dev *rdev)
10321034
rdev->nq[i].res = &rdev->qplib_res;
10331035
rdev->nq[i].hwq.max_elements = BNXT_RE_MAX_CQ_COUNT +
10341036
BNXT_RE_MAX_SRQC_COUNT + 2;
1035-
rc = bnxt_qplib_alloc_nq(rdev->en_dev->pdev, &rdev->nq[i]);
1037+
rc = bnxt_qplib_alloc_nq(&rdev->qplib_res, &rdev->nq[i]);
10361038
if (rc) {
10371039
dev_err(rdev_to_dev(rdev), "Alloc Failed NQ%d rc:%#x",
10381040
i, rc);
@@ -1056,7 +1058,7 @@ static int bnxt_re_alloc_res(struct bnxt_re_dev *rdev)
10561058
}
10571059
return 0;
10581060
free_nq:
1059-
for (i = num_vec_created; i >= 0; i--) {
1061+
for (i = num_vec_created - 1; i >= 0; i--) {
10601062
type = bnxt_qplib_get_ring_type(rdev->chip_ctx);
10611063
bnxt_re_net_ring_free(rdev, rdev->nq[i].ring_id, type);
10621064
bnxt_qplib_free_nq(&rdev->nq[i]);
@@ -1335,7 +1337,7 @@ static void bnxt_re_ib_unreg(struct bnxt_re_dev *rdev)
13351337
dev_warn(rdev_to_dev(rdev),
13361338
"Failed to deinitialize RCFW: %#x", rc);
13371339
bnxt_re_net_stats_ctx_free(rdev, rdev->qplib_ctx.stats.fw_id);
1338-
bnxt_qplib_free_ctx(rdev->en_dev->pdev, &rdev->qplib_ctx);
1340+
bnxt_qplib_free_ctx(&rdev->qplib_res, &rdev->qplib_ctx);
13391341
bnxt_qplib_disable_rcfw_channel(&rdev->rcfw);
13401342
type = bnxt_qplib_get_ring_type(rdev->chip_ctx);
13411343
bnxt_re_net_ring_free(rdev, rdev->rcfw.creq_ring_id, type);
@@ -1411,7 +1413,7 @@ static int bnxt_re_ib_reg(struct bnxt_re_dev *rdev)
14111413
/* Establish RCFW Communication Channel to initialize the context
14121414
* memory for the function and all child VFs
14131415
*/
1414-
rc = bnxt_qplib_alloc_rcfw_channel(rdev->en_dev->pdev, &rdev->rcfw,
1416+
rc = bnxt_qplib_alloc_rcfw_channel(&rdev->qplib_res, &rdev->rcfw,
14151417
&rdev->qplib_ctx,
14161418
BNXT_RE_MAX_QPC_COUNT);
14171419
if (rc) {
@@ -1432,7 +1434,7 @@ static int bnxt_re_ib_reg(struct bnxt_re_dev *rdev)
14321434
}
14331435
db_offt = bnxt_re_get_nqdb_offset(rdev, BNXT_RE_AEQ_IDX);
14341436
vid = rdev->msix_entries[BNXT_RE_AEQ_IDX].vector;
1435-
rc = bnxt_qplib_enable_rcfw_channel(rdev->en_dev->pdev, &rdev->rcfw,
1437+
rc = bnxt_qplib_enable_rcfw_channel(&rdev->rcfw,
14361438
vid, db_offt, rdev->is_virtfn,
14371439
&bnxt_re_aeq_handler);
14381440
if (rc) {
@@ -1447,7 +1449,7 @@ static int bnxt_re_ib_reg(struct bnxt_re_dev *rdev)
14471449

14481450
bnxt_re_set_resource_limits(rdev);
14491451

1450-
rc = bnxt_qplib_alloc_ctx(rdev->en_dev->pdev, &rdev->qplib_ctx, 0,
1452+
rc = bnxt_qplib_alloc_ctx(&rdev->qplib_res, &rdev->qplib_ctx, 0,
14511453
bnxt_qplib_is_chip_gen_p5(rdev->chip_ctx));
14521454
if (rc) {
14531455
pr_err("Failed to allocate QPLIB context: %#x\n", rc);
@@ -1514,7 +1516,7 @@ static int bnxt_re_ib_reg(struct bnxt_re_dev *rdev)
15141516
free_sctx:
15151517
bnxt_re_net_stats_ctx_free(rdev, rdev->qplib_ctx.stats.fw_id);
15161518
free_ctx:
1517-
bnxt_qplib_free_ctx(rdev->en_dev->pdev, &rdev->qplib_ctx);
1519+
bnxt_qplib_free_ctx(&rdev->qplib_res, &rdev->qplib_ctx);
15181520
disable_rcfw:
15191521
bnxt_qplib_disable_rcfw_channel(&rdev->rcfw);
15201522
free_ring:

0 commit comments

Comments
 (0)