]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
RDMA/bnxt_re: Update msn table size for app allocated QPs
authorSriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
Tue, 19 May 2026 15:00:36 +0000 (20:30 +0530)
committerJason Gunthorpe <jgg@nvidia.com>
Sun, 24 May 2026 15:32:21 +0000 (12:32 -0300)
For app allocated QPs, the driver shouldn't use slots/round-up logic
to compute the msn table size. The application handles this logic
and computes 'sq_npsn' and passes it to the driver using a new uapi
parameter.

Link: https://patch.msgid.link/r/20260519150041.7251-5-sriharsha.basavapatna@broadcom.com
Signed-off-by: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
Reviewed-by: Selvin Xavier <selvin.xavier@broadcom.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/hw/bnxt_re/ib_verbs.c
include/uapi/rdma/bnxt_re-abi.h

index e5a8d3972a4201a7f4307a8838aeffa61876f0ff..942148c2d9f07337ea887aa1d8062fe2074ff775 100644 (file)
@@ -1159,29 +1159,39 @@ static int bnxt_re_setup_sginfo(struct bnxt_re_dev *rdev,
 static int bnxt_re_get_psn_bytes(struct bnxt_re_dev *rdev,
                                 struct bnxt_re_ucontext *cntx,
                                 struct bnxt_qplib_qp *qplib_qp,
-                                struct bnxt_re_qp_req *ureq)
+                                struct bnxt_re_qp_req *ureq,
+                                bool fixed_que_attr)
 {
        int psn_sz, psn_nume;
 
-       psn_sz = bnxt_qplib_is_chip_gen_p5_p7(rdev->chip_ctx) ?
-                               sizeof(struct sq_psn_search_ext) :
-                               sizeof(struct sq_psn_search);
-       if (cntx && bnxt_re_is_var_size_supported(rdev, cntx)) {
-               psn_nume = ureq->sq_slots;
+       if (rdev->dev_attr &&
+           _is_host_msn_table(rdev->dev_attr->dev_cap_flags2))
+               psn_sz = sizeof(struct sq_msn_search);
+       else
+               psn_sz = bnxt_qplib_is_chip_gen_p5_p7(rdev->chip_ctx) ?
+                                       sizeof(struct sq_psn_search_ext) :
+                                       sizeof(struct sq_psn_search);
+       if (!fixed_que_attr) {
+               if (cntx && bnxt_re_is_var_size_supported(rdev, cntx)) {
+                       psn_nume = ureq->sq_slots;
+               } else {
+                       psn_nume = (qplib_qp->wqe_mode == BNXT_QPLIB_WQE_MODE_STATIC) ?
+                       qplib_qp->sq.max_wqe : ((qplib_qp->sq.max_wqe * qplib_qp->sq.wqe_size) /
+                                sizeof(struct bnxt_qplib_sge));
+               }
+               if (_is_host_msn_table(rdev->qplib_res.dattr->dev_cap_flags2))
+                       psn_nume = roundup_pow_of_two(psn_nume);
        } else {
-               psn_nume = (qplib_qp->wqe_mode == BNXT_QPLIB_WQE_MODE_STATIC) ?
-               qplib_qp->sq.max_wqe : ((qplib_qp->sq.max_wqe * qplib_qp->sq.wqe_size) /
-                        sizeof(struct bnxt_qplib_sge));
+               psn_nume = ureq->sq_npsn;
        }
-       if (_is_host_msn_table(rdev->qplib_res.dattr->dev_cap_flags2))
-               psn_nume = roundup_pow_of_two(psn_nume);
 
        return psn_nume * psn_sz;
 }
 
 static int bnxt_re_init_user_qp(struct bnxt_re_dev *rdev, struct bnxt_re_pd *pd,
                                struct bnxt_re_qp *qp, struct bnxt_re_ucontext *cntx,
-                               struct bnxt_re_qp_req *ureq)
+                               struct bnxt_re_qp_req *ureq,
+                               bool fixed_que_attr)
 {
        struct bnxt_qplib_qp *qplib_qp;
        struct ib_umem *umem;
@@ -1193,7 +1203,7 @@ static int bnxt_re_init_user_qp(struct bnxt_re_dev *rdev, struct bnxt_re_pd *pd,
        bytes = (qplib_qp->sq.max_wqe * qplib_qp->sq.wqe_size);
        /* Consider mapping PSN search memory only for RC QPs. */
        if (qplib_qp->type == CMDQ_CREATE_QP_TYPE_RC)
-               bytes += bnxt_re_get_psn_bytes(rdev, cntx, qplib_qp, ureq);
+               bytes += bnxt_re_get_psn_bytes(rdev, cntx, qplib_qp, ureq, fixed_que_attr);
 
        bytes = PAGE_ALIGN(bytes);
        umem = ib_umem_get(&rdev->ibdev, ureq->qpsva, bytes,
@@ -1647,7 +1657,9 @@ out:
        return qptype;
 }
 
-static void bnxt_re_qp_calculate_msn_psn_size(struct bnxt_re_qp *qp)
+static void bnxt_re_qp_calculate_msn_psn_size(struct bnxt_re_qp *qp,
+                                             bool fixed_que_attr,
+                                             struct bnxt_re_qp_req *req)
 {
        struct bnxt_qplib_qp *qplib_qp = &qp->qplib_qp;
        struct bnxt_qplib_q *sq = &qplib_qp->sq;
@@ -1670,12 +1682,17 @@ static void bnxt_re_qp_calculate_msn_psn_size(struct bnxt_re_qp *qp)
 
        /* Update msn tbl size */
        if (qplib_qp->is_host_msn_tbl && qplib_qp->psn_sz) {
-               if (wqe_mode == BNXT_QPLIB_WQE_MODE_STATIC)
-                       qplib_qp->msn_tbl_sz =
-                               roundup_pow_of_two(bnxt_qplib_set_sq_size(sq, wqe_mode));
-               else
-                       qplib_qp->msn_tbl_sz =
-                               roundup_pow_of_two(bnxt_qplib_set_sq_size(sq, wqe_mode)) / 2;
+               if (!fixed_que_attr) {
+                       if (wqe_mode == BNXT_QPLIB_WQE_MODE_STATIC)
+                               qplib_qp->msn_tbl_sz =
+                                       roundup_pow_of_two(bnxt_qplib_set_sq_size(sq, wqe_mode));
+                       else
+                               qplib_qp->msn_tbl_sz =
+                                       roundup_pow_of_two(bnxt_qplib_set_sq_size(sq, wqe_mode))
+                                               / 2;
+               } else {
+                       qplib_qp->msn_tbl_sz = req->sq_npsn;
+               }
                qplib_qp->msn = 0;
        }
 }
@@ -1750,12 +1767,12 @@ static int bnxt_re_init_qp_attr(struct bnxt_re_qp *qp, struct bnxt_re_pd *pd,
                bnxt_re_adjust_gsi_sq_attr(qp, init_attr, uctx);
 
        if (uctx) { /* This will update DPI and qp_handle */
-               rc = bnxt_re_init_user_qp(rdev, pd, qp, uctx, ureq);
+               rc = bnxt_re_init_user_qp(rdev, pd, qp, uctx, ureq, fixed_que_attr);
                if (rc)
                        return rc;
        }
 
-       bnxt_re_qp_calculate_msn_psn_size(qp);
+       bnxt_re_qp_calculate_msn_psn_size(qp, fixed_que_attr, ureq);
 
        rc = bnxt_re_setup_qp_hwqs(qp);
        if (rc)
index 40955eaba32e60ee0598452065ef0d5ea69af05e..db8400f2ce3bc542df8dd9008164e9bb384aabe4 100644 (file)
@@ -135,6 +135,7 @@ struct bnxt_re_qp_req {
        __aligned_u64 qp_handle;
        __aligned_u64 comp_mask;
        __u32 sq_slots;
+       __u32 sq_npsn;
 };
 
 struct bnxt_re_qp_resp {