* Re: [PATCH for-next v2 4/4] RDMA/bnxt_re: Allow user library to request STATIC WQE mode per-QP
2026-11-30 14:53 ` [PATCH for-next v2 4/4] RDMA/bnxt_re: Allow user library to request STATIC WQE mode per-QP Selvin Xavier
@ 2026-11-30 9:51 ` sashiko-bot
0 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-11-30 9:51 UTC (permalink / raw)
To: Selvin Xavier; +Cc: linux-rdma
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] RDMA/bnxt_re: wrong sq->max_wqe upper bound in
bnxt_re_init_sq_attr()
--
commit f833eaacd18642dcd75e27a7ef54dc8560c17fce
Author: Abhishek Mohapatra <abhishek.mohapatra@broadcom.com>
RDMA/bnxt_re: Allow user library to request STATIC WQE mode per-QP
This commit adds a wqe_mode field and BNXT_RE_QP_REQ_MASK_WQE_MODE flag to
struct bnxt_re_qp_req so userspace can explicitly request static WQE mode
per QP and size the SQ from sq_slots.
> diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
> index 92d8995b58952..ac7db219bfc1f 100644
> --- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c
> +++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
[ ... ]
> @@ -1598,17 +1611,24 @@ static int bnxt_re_init_sq_attr(struct bnxt_re_qp *qp,
> if (rc)
> return rc;
>
> - /* Allocate 128 + 1 more than what's provided */
> - if (qplqp->wqe_mode != BNXT_QPLIB_WQE_MODE_VARIABLE)
> - diff = BNXT_QPLIB_RESERVED_QP_WRS;
> - sq->max_wqe = bnxt_re_init_depth(
> - init_attr->cap.max_send_wr + diff + 1,
> - dev_attr->max_qp_wqes + diff + 1, uctx);
> - if (qplqp->wqe_mode == BNXT_QPLIB_WQE_MODE_VARIABLE)
> - sq->max_sw_wqe = bnxt_qplib_get_depth(sq, qplqp->wqe_mode, true);
> - else
> + if (uctx && fixed_que_attr) {
> + sq->max_wqe = ((u64)ureq->sq_slots * bnxt_qplib_get_stride()) /
> + sq->wqe_size;
> + /* Bound the depth by the device limit */
> + if (!sq->max_wqe || sq->max_wqe > dev_attr->max_qp_wqes + 1)
> + return -EINVAL;
> sq->max_sw_wqe = sq->max_wqe;
> -
> + } else {
> + /* Allocate 128 + 1 more than what's provided */
> + if (qplqp->wqe_mode != BNXT_QPLIB_WQE_MODE_VARIABLE)
> + diff = BNXT_QPLIB_RESERVED_QP_WRS;
> + sq->max_wqe = bnxt_re_init_depth(init_attr->cap.max_send_wr + diff + 1,
> + dev_attr->max_qp_wqes + diff + 1, uctx);
> + if (qplqp->wqe_mode == BNXT_QPLIB_WQE_MODE_VARIABLE)
> + sq->max_sw_wqe = bnxt_qplib_get_depth(sq, qplqp->wqe_mode, true);
> + else
> + sq->max_sw_wqe = sq->max_wqe;
> + }
> }
> if (!fixed_que_attr) {
> sq->q_full_delta = diff + 1;
> @@ -1618,6 +1638,12 @@ static int bnxt_re_init_sq_attr(struct bnxt_re_qp *qp,
> * unexpected Queue full condition
> */
> qplqp->sq.q_full_delta -= 1;
> + } else if (qplqp->wqe_mode == BNXT_QPLIB_WQE_MODE_STATIC &&
> + !bnxt_qplib_is_chip_gen_p5_p7(rdev->chip_ctx)) {
> + /* Legacy chips need 128 WQEs reserved for HW (8916) */
> + if (sq->max_wqe <= BNXT_QPLIB_RESERVED_QP_WRS)
> + return -EINVAL;
> + sq->q_full_delta = BNXT_QPLIB_RESERVED_QP_WRS;
> } else {
> sq->q_full_delta = 0;
> }
[Severity: Medium]
Does capping sq->max_wqe at dev_attr->max_qp_wqes + 1 reject valid static
WQE SQ sizes when fixed_que_attr is set?
In bnxt_qplib_get_dev_attr(), dev_attr->max_qp_wqes has already been
reduced for legacy chips or overwritten for variable-WQE chips:
drivers/infiniband/hw/bnxt_re/qplib_sp.c:bnxt_qplib_get_dev_attr() {
...
attr->max_qp_wqes = le16_to_cpu(sb->max_qp_wr) - 1;
if (!bnxt_qplib_is_chip_gen_p5_p7(rcfw->res->cctx)) {
/*
* 128 WQEs needs to be reserved for the HW (8916). Prevent
* reporting the max number on legacy devices
*/
attr->max_qp_wqes -= BNXT_QPLIB_RESERVED_QP_WRS + 1;
}
/* Adjust for max_qp_wqes for variable wqe */
if (cctx->modes.wqe_mode == BNXT_QPLIB_WQE_MODE_VARIABLE)
attr->max_qp_wqes = BNXT_VAR_MAX_WQE - 1;
...
}
On non-P5/P7 chips, fixed_que_attr static QPs still reserve
BNXT_QPLIB_RESERVED_QP_WRS (128) WQEs out of sq->max_wqe via
sq->q_full_delta, so checking sq->max_wqe against dev_attr->max_qp_wqes + 1
without adding BNXT_QPLIB_RESERVED_QP_WRS (unlike the else branch) rejects
QPs sized near the reported max_qp_wr limit with -EINVAL. On chips where
cctx->modes.wqe_mode is BNXT_QPLIB_WQE_MODE_VARIABLE, dev_attr->max_qp_wqes
is 4351, so the check caps static WQE SQs at 4352 WQEs (34816 slots) even
though bnxt_re_init_qp_attr() allows ureq->sq_slots up to
BNXT_RE_MAX_SQ_SLOTS (65536 slots, or 8192 static WQEs).
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261130145344.322857-1-selvin.xavier@broadcom.com?part=4
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH for-next v2 0/4] RDMA/bnxt_re: CQ and QP updates for app allocated queues
2026-11-30 14:53 [PATCH for-next v2 0/4] RDMA/bnxt_re: CQ and QP updates for app allocated queues Selvin Xavier
@ 2026-11-30 9:51 ` sashiko-bot
2026-11-30 14:53 ` [PATCH for-next v2 1/4] RDMA/bnxt_re: Disable CQ overflow detection on P7 adapters based on FW support Selvin Xavier
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-11-30 9:51 UTC (permalink / raw)
To: Selvin Xavier; +Cc: linux-rdma
Sashiko has finished reviewing this 4-patch series:
- Patches 1-3: no issues found.
- Patch 4 ("RDMA/bnxt_re: Allow user library to request STATIC W..."): 1
potential issue (1 Medium)
A detailed review has been sent as a separate reply to patch 4.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261130145344.322857-1-selvin.xavier@broadcom.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH for-next v2 0/4] RDMA/bnxt_re: CQ and QP updates for app allocated queues
@ 2026-11-30 14:53 Selvin Xavier
2026-11-30 9:51 ` sashiko-bot
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: Selvin Xavier @ 2026-11-30 14:53 UTC (permalink / raw)
To: leon, jgg
Cc: linux-rdma, andrew.gospodarek, kalesh-anakkur.purayil,
Selvin Xavier
This series has two CQ updates (CQ overflow detection on P7, CQ
coalescing for depth-1 CQs), a cleanup of the PSN size and QP HWQ setup
paths, and support for requesting STATIC WQE mode per QP from user space.
Please review and apply
Thanks,
Selvin Xavier
v1 -> v2:
- Patches 1-3: no changes.
- Patch 4: tighten validation of the STATIC WQE request (device SGE
limit, sq_slots alignment), keep the HW reserved WQEs on legacy
chips, and drop the power-of-two requirement on SQ/RQ depth.
Abhishek Mohapatra (4):
RDMA/bnxt_re: Disable CQ overflow detection on P7 adapters based on FW
support
RDMA/bnxt_re: Set CQ coalescing max buffers to 1 for CQs with depth 1
RDMA/bnxt_re: Simplify PSN size and QP HWQ setup paths
RDMA/bnxt_re: Allow user library to request STATIC WQE mode per-QP
drivers/infiniband/hw/bnxt_re/ib_verbs.c | 206 ++++++++++++++--------
drivers/infiniband/hw/bnxt_re/qplib_fp.c | 14 +-
drivers/infiniband/hw/bnxt_re/qplib_res.h | 5 +
drivers/infiniband/hw/bnxt_re/roce_hsi.h | 1 +
include/uapi/rdma/bnxt_re-abi.h | 9 +
5 files changed, 162 insertions(+), 73 deletions(-)
--
2.39.3
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH for-next v2 1/4] RDMA/bnxt_re: Disable CQ overflow detection on P7 adapters based on FW support
2026-11-30 14:53 [PATCH for-next v2 0/4] RDMA/bnxt_re: CQ and QP updates for app allocated queues Selvin Xavier
2026-11-30 9:51 ` sashiko-bot
@ 2026-11-30 14:53 ` Selvin Xavier
2026-11-30 14:53 ` [PATCH for-next v2 2/4] RDMA/bnxt_re: Set CQ coalescing max buffers to 1 for CQs with depth 1 Selvin Xavier
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Selvin Xavier @ 2026-11-30 14:53 UTC (permalink / raw)
To: leon, jgg
Cc: linux-rdma, andrew.gospodarek, kalesh-anakkur.purayil,
Abhishek Mohapatra, Selvin Xavier
From: Abhishek Mohapatra <abhishek.mohapatra@broadcom.com>
Firmware reports that CQ overflow detection is enabled through a new
capability bit in QUERY_FUNC's second extended capability word
(CREQ_QUERY_FUNC_RESP_SB_CQ_OVERFLOW_DETECTION_ENABLED).
Older firmware does not set this bit and has CQ overflow detection
disabled by default, so requesting DISABLE_CQ_OVERFLOW_DETECTION in
CREATE_CQ does not change its behavior. When the bit is set, the driver
does not request the disable.
Add the bit and a _is_cq_overflow_detection_enabled() helper, and have
CREATE_CQ set the DISABLE_CQ_OVERFLOW_DETECTION flag on P7 chips only
when the bit is clear.
Signed-off-by: Abhishek Mohapatra <abhishek.mohapatra@broadcom.com>
Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com>
---
drivers/infiniband/hw/bnxt_re/qplib_fp.c | 4 ++++
drivers/infiniband/hw/bnxt_re/qplib_res.h | 5 +++++
drivers/infiniband/hw/bnxt_re/roce_hsi.h | 1 +
3 files changed, 10 insertions(+)
diff --git a/drivers/infiniband/hw/bnxt_re/qplib_fp.c b/drivers/infiniband/hw/bnxt_re/qplib_fp.c
index 8151f9d5c568..41bde91432cb 100644
--- a/drivers/infiniband/hw/bnxt_re/qplib_fp.c
+++ b/drivers/infiniband/hw/bnxt_re/qplib_fp.c
@@ -2111,6 +2111,10 @@ int bnxt_qplib_create_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq)
req.cq_handle = cpu_to_le64(cq->cq_handle);
req.cq_size = cpu_to_le32(cq->max_wqe);
+ if (bnxt_qplib_is_chip_gen_p7(res->cctx) &&
+ !_is_cq_overflow_detection_enabled(res->dattr->dev_cap_flags2))
+ req.flags |= cpu_to_le16(CMDQ_CREATE_CQ_FLAGS_DISABLE_CQ_OVERFLOW_DETECTION);
+
if (_is_cq_coalescing_supported(res->dattr->dev_cap_flags2) &&
cq->coalescing->enable) {
req.flags |= cpu_to_le16(CMDQ_CREATE_CQ_FLAGS_COALESCING_VALID);
diff --git a/drivers/infiniband/hw/bnxt_re/qplib_res.h b/drivers/infiniband/hw/bnxt_re/qplib_res.h
index b925db796729..9b9c870dd341 100644
--- a/drivers/infiniband/hw/bnxt_re/qplib_res.h
+++ b/drivers/infiniband/hw/bnxt_re/qplib_res.h
@@ -628,6 +628,11 @@ static inline bool _is_cq_coalescing_supported(u16 dev_cap_ext_flags2)
return dev_cap_ext_flags2 & CREQ_QUERY_FUNC_RESP_SB_CQ_COALESCING_SUPPORTED;
}
+static inline bool _is_cq_overflow_detection_enabled(u16 dev_cap_ext_flags2)
+{
+ return !!(dev_cap_ext_flags2 & CREQ_QUERY_FUNC_RESP_SB_CQ_OVERFLOW_DETECTION_ENABLED);
+}
+
static inline bool _is_max_srq_ext_supported(u16 dev_cap_ext_flags_2)
{
return !!(dev_cap_ext_flags_2 & CREQ_QUERY_FUNC_RESP_SB_MAX_SRQ_EXTENDED);
diff --git a/drivers/infiniband/hw/bnxt_re/roce_hsi.h b/drivers/infiniband/hw/bnxt_re/roce_hsi.h
index aac338f2afd8..3185e1028385 100644
--- a/drivers/infiniband/hw/bnxt_re/roce_hsi.h
+++ b/drivers/infiniband/hw/bnxt_re/roce_hsi.h
@@ -2260,6 +2260,7 @@ struct creq_query_func_resp_sb {
#define CREQ_QUERY_FUNC_RESP_SB_MAX_SRQ_EXTENDED 0x40UL
#define CREQ_QUERY_FUNC_RESP_SB_MODIFY_QP_RATE_LIMIT_SUPPORTED 0x400UL
#define CREQ_QUERY_FUNC_RESP_SB_MIN_RNR_RTR_RTS_OPT_SUPPORTED 0x1000UL
+ #define CREQ_QUERY_FUNC_RESP_SB_CQ_OVERFLOW_DETECTION_ENABLED 0x2000UL
__le16 max_xp_qp_size;
__le16 create_qp_batch_size;
__le16 destroy_qp_batch_size;
--
2.39.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH for-next v2 2/4] RDMA/bnxt_re: Set CQ coalescing max buffers to 1 for CQs with depth 1
2026-11-30 14:53 [PATCH for-next v2 0/4] RDMA/bnxt_re: CQ and QP updates for app allocated queues Selvin Xavier
2026-11-30 9:51 ` sashiko-bot
2026-11-30 14:53 ` [PATCH for-next v2 1/4] RDMA/bnxt_re: Disable CQ overflow detection on P7 adapters based on FW support Selvin Xavier
@ 2026-11-30 14:53 ` Selvin Xavier
2026-11-30 14:53 ` [PATCH for-next v2 3/4] RDMA/bnxt_re: Simplify PSN size and QP HWQ setup paths Selvin Xavier
2026-11-30 14:53 ` [PATCH for-next v2 4/4] RDMA/bnxt_re: Allow user library to request STATIC WQE mode per-QP Selvin Xavier
4 siblings, 0 replies; 7+ messages in thread
From: Selvin Xavier @ 2026-11-30 14:53 UTC (permalink / raw)
To: leon, jgg
Cc: linux-rdma, andrew.gospodarek, kalesh-anakkur.purayil,
Abhishek Mohapatra, Selvin Xavier
From: Abhishek Mohapatra <abhishek.mohapatra@broadcom.com>
When the CQ depth is 1, program NORMAL_MAXBUF and DURING_MAXBUF to 1
in bnxt_qplib_create_cq(). A single-entry CQ has at most one
outstanding completion, so firmware flushes it as soon as it is
buffered instead of waiting for more.
Signed-off-by: Abhishek Mohapatra <abhishek.mohapatra@broadcom.com>
Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com>
---
drivers/infiniband/hw/bnxt_re/qplib_fp.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/infiniband/hw/bnxt_re/qplib_fp.c b/drivers/infiniband/hw/bnxt_re/qplib_fp.c
index 41bde91432cb..0ab3fedd03f0 100644
--- a/drivers/infiniband/hw/bnxt_re/qplib_fp.c
+++ b/drivers/infiniband/hw/bnxt_re/qplib_fp.c
@@ -2077,6 +2077,8 @@ int bnxt_qplib_post_recv(struct bnxt_qplib_qp *qp,
/* CQ */
int bnxt_qplib_create_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq)
{
+ u8 normal_maxbuf = cq->coalescing->normal_maxbuf;
+ u8 during_maxbuf = cq->coalescing->during_maxbuf;
struct bnxt_qplib_rcfw *rcfw = res->rcfw;
struct bnxt_qplib_hwq_attr hwq_attr = {};
struct creq_create_cq_resp resp = {};
@@ -2118,13 +2120,17 @@ int bnxt_qplib_create_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq)
if (_is_cq_coalescing_supported(res->dattr->dev_cap_flags2) &&
cq->coalescing->enable) {
req.flags |= cpu_to_le16(CMDQ_CREATE_CQ_FLAGS_COALESCING_VALID);
+ if (cq->max_wqe == 1) {
+ normal_maxbuf = 0x1;
+ during_maxbuf = 0x1;
+ }
coalescing |= ((cq->coalescing->buf_maxtime <<
CMDQ_CREATE_CQ_BUF_MAXTIME_SFT) &
CMDQ_CREATE_CQ_BUF_MAXTIME_MASK);
- coalescing |= ((cq->coalescing->normal_maxbuf <<
+ coalescing |= ((normal_maxbuf <<
CMDQ_CREATE_CQ_NORMAL_MAXBUF_SFT) &
CMDQ_CREATE_CQ_NORMAL_MAXBUF_MASK);
- coalescing |= ((cq->coalescing->during_maxbuf <<
+ coalescing |= ((during_maxbuf <<
CMDQ_CREATE_CQ_DURING_MAXBUF_SFT) &
CMDQ_CREATE_CQ_DURING_MAXBUF_MASK);
if (cq->coalescing->en_ring_idle_mode)
--
2.39.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH for-next v2 3/4] RDMA/bnxt_re: Simplify PSN size and QP HWQ setup paths
2026-11-30 14:53 [PATCH for-next v2 0/4] RDMA/bnxt_re: CQ and QP updates for app allocated queues Selvin Xavier
` (2 preceding siblings ...)
2026-11-30 14:53 ` [PATCH for-next v2 2/4] RDMA/bnxt_re: Set CQ coalescing max buffers to 1 for CQs with depth 1 Selvin Xavier
@ 2026-11-30 14:53 ` Selvin Xavier
2026-11-30 14:53 ` [PATCH for-next v2 4/4] RDMA/bnxt_re: Allow user library to request STATIC WQE mode per-QP Selvin Xavier
4 siblings, 0 replies; 7+ messages in thread
From: Selvin Xavier @ 2026-11-30 14:53 UTC (permalink / raw)
To: leon, jgg
Cc: linux-rdma, andrew.gospodarek, kalesh-anakkur.purayil,
Abhishek Mohapatra, Kashyap Desai, Selvin Xavier
From: Abhishek Mohapatra <abhishek.mohapatra@broadcom.com>
Factor out the SQ/RQ page size and level encoding into a helper,
flatten the RQ allocation in bnxt_re_setup_qp_hwqs(), fix the error
path to not free the RQ HWQ when an SRQ is used, and simplify
bnxt_re_get_psn_bytes(). No functional change intended.
Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Abhishek Mohapatra <abhishek.mohapatra@broadcom.com>
Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com>
---
drivers/infiniband/hw/bnxt_re/ib_verbs.c | 96 ++++++++++++------------
1 file changed, 48 insertions(+), 48 deletions(-)
diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
index c67f263c759f..92d8995b5895 100644
--- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c
+++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
@@ -1163,28 +1163,30 @@ static int bnxt_re_get_psn_bytes(struct bnxt_re_dev *rdev,
struct bnxt_re_qp_req *ureq,
bool fixed_que_attr)
{
+ bool msn_tbl = rdev->dev_attr &&
+ _is_host_msn_table(rdev->dev_attr->dev_cap_flags2);
int psn_sz, psn_nume;
- if (rdev->dev_attr &&
- _is_host_msn_table(rdev->dev_attr->dev_cap_flags2))
+ if (msn_tbl)
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 = ureq->sq_npsn;
- }
+
+ if (fixed_que_attr)
+ return ureq->sq_npsn * psn_sz;
+
+ if (cntx && bnxt_re_is_var_size_supported(rdev, cntx))
+ psn_nume = ureq->sq_slots;
+ else if (qplib_qp->wqe_mode == BNXT_QPLIB_WQE_MODE_STATIC)
+ psn_nume = qplib_qp->sq.max_wqe;
+ else
+ psn_nume = (qplib_qp->sq.max_wqe * qplib_qp->sq.wqe_size) /
+ sizeof(struct bnxt_qplib_sge);
+
+ if (msn_tbl)
+ psn_nume = roundup_pow_of_two(psn_nume);
return psn_nume * psn_sz;
}
@@ -1354,61 +1356,58 @@ static int bnxt_re_qp_alloc_init_xrrq(struct bnxt_re_qp *qp)
return rc;
}
+static void bnxt_re_set_hwq_pg_sz_lvl(struct bnxt_qplib_hwq *hwq, u8 pg_sz_sft,
+ u8 lvl_mask, u8 lvl_sft)
+{
+ hwq->pg_sz_lvl = (bnxt_qplib_base_pg_size(hwq) << pg_sz_sft) |
+ ((hwq->level & lvl_mask) << lvl_sft);
+}
+
static int bnxt_re_setup_qp_hwqs(struct bnxt_re_qp *qp, bool fixed_que_attr)
{
struct bnxt_qplib_res *res = &qp->rdev->qplib_res;
- struct bnxt_qplib_qp *qplib_qp = &qp->qplib_qp;
struct bnxt_qplib_hwq_attr hwq_attr = {};
+ struct bnxt_qplib_qp *qplib_qp = &qp->qplib_qp;
struct bnxt_qplib_q *sq = &qplib_qp->sq;
struct bnxt_qplib_q *rq = &qplib_qp->rq;
u8 wqe_mode = qplib_qp->wqe_mode;
- u8 pg_sz_lvl;
int rc;
hwq_attr.res = res;
hwq_attr.sginfo = &sq->sg_info;
hwq_attr.stride = bnxt_qplib_get_stride();
hwq_attr.aux_stride = qplib_qp->psn_sz;
+ hwq_attr.type = HWQ_TYPE_QUEUE;
if (!fixed_que_attr) {
hwq_attr.depth = bnxt_qplib_get_depth(sq, wqe_mode, true);
- hwq_attr.aux_depth = (qplib_qp->psn_sz) ?
- bnxt_qplib_set_sq_size(sq, wqe_mode) : 0;
- if (qplib_qp->is_host_msn_tbl && qplib_qp->psn_sz)
- hwq_attr.aux_depth = qplib_qp->msn_tbl_sz;
+ if (qplib_qp->psn_sz)
+ hwq_attr.aux_depth = qplib_qp->is_host_msn_tbl ?
+ qplib_qp->msn_tbl_sz :
+ bnxt_qplib_set_sq_size(sq, wqe_mode);
} else {
hwq_attr.depth = sq->max_wqe;
hwq_attr.aux_depth = qplib_qp->msn_tbl_sz;
}
- hwq_attr.type = HWQ_TYPE_QUEUE;
rc = bnxt_qplib_alloc_init_hwq(&sq->hwq, &hwq_attr);
if (rc)
return rc;
+ bnxt_re_set_hwq_pg_sz_lvl(&sq->hwq, CMDQ_CREATE_QP_SQ_PG_SIZE_SFT,
+ CMDQ_CREATE_QP_SQ_LVL_MASK,
+ CMDQ_CREATE_QP_SQ_LVL_SFT);
+
+ if (!qplib_qp->srq) {
+ hwq_attr.sginfo = &rq->sg_info;
+ hwq_attr.depth = bnxt_qplib_get_depth(rq, wqe_mode, false);
+ hwq_attr.aux_stride = 0;
+ hwq_attr.aux_depth = 0;
+ rc = bnxt_qplib_alloc_init_hwq(&rq->hwq, &hwq_attr);
+ if (rc)
+ goto free_sq_hwq;
+ bnxt_re_set_hwq_pg_sz_lvl(&rq->hwq, CMDQ_CREATE_QP_RQ_PG_SIZE_SFT,
+ CMDQ_CREATE_QP_RQ_LVL_MASK,
+ CMDQ_CREATE_QP_RQ_LVL_SFT);
+ }
- pg_sz_lvl = bnxt_qplib_base_pg_size(&sq->hwq) << CMDQ_CREATE_QP_SQ_PG_SIZE_SFT;
- pg_sz_lvl |= ((sq->hwq.level & CMDQ_CREATE_QP_SQ_LVL_MASK) <<
- CMDQ_CREATE_QP_SQ_LVL_SFT);
- sq->hwq.pg_sz_lvl = pg_sz_lvl;
-
- if (qplib_qp->srq)
- goto done;
-
- hwq_attr.res = res;
- hwq_attr.sginfo = &rq->sg_info;
- hwq_attr.stride = bnxt_qplib_get_stride();
- hwq_attr.depth = bnxt_qplib_get_depth(rq, qplib_qp->wqe_mode, false);
- hwq_attr.aux_stride = 0;
- hwq_attr.aux_depth = 0;
- hwq_attr.type = HWQ_TYPE_QUEUE;
- rc = bnxt_qplib_alloc_init_hwq(&rq->hwq, &hwq_attr);
- if (rc)
- goto free_sq_hwq;
- pg_sz_lvl = bnxt_qplib_base_pg_size(&rq->hwq) <<
- CMDQ_CREATE_QP_RQ_PG_SIZE_SFT;
- pg_sz_lvl |= ((rq->hwq.level & CMDQ_CREATE_QP_RQ_LVL_MASK) <<
- CMDQ_CREATE_QP_RQ_LVL_SFT);
- rq->hwq.pg_sz_lvl = pg_sz_lvl;
-
-done:
if (qplib_qp->psn_sz) {
rc = bnxt_re_qp_alloc_init_xrrq(qp);
if (rc)
@@ -1417,7 +1416,8 @@ static int bnxt_re_setup_qp_hwqs(struct bnxt_re_qp *qp, bool fixed_que_attr)
return 0;
free_rq_hwq:
- bnxt_qplib_free_hwq(res, &rq->hwq);
+ if (!qplib_qp->srq)
+ bnxt_qplib_free_hwq(res, &rq->hwq);
free_sq_hwq:
bnxt_qplib_free_hwq(res, &sq->hwq);
return rc;
--
2.39.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH for-next v2 4/4] RDMA/bnxt_re: Allow user library to request STATIC WQE mode per-QP
2026-11-30 14:53 [PATCH for-next v2 0/4] RDMA/bnxt_re: CQ and QP updates for app allocated queues Selvin Xavier
` (3 preceding siblings ...)
2026-11-30 14:53 ` [PATCH for-next v2 3/4] RDMA/bnxt_re: Simplify PSN size and QP HWQ setup paths Selvin Xavier
@ 2026-11-30 14:53 ` Selvin Xavier
2026-11-30 9:51 ` sashiko-bot
4 siblings, 1 reply; 7+ messages in thread
From: Selvin Xavier @ 2026-11-30 14:53 UTC (permalink / raw)
To: leon, jgg
Cc: linux-rdma, andrew.gospodarek, kalesh-anakkur.purayil,
Abhishek Mohapatra, Kashyap Desai, Selvin Xavier
From: Abhishek Mohapatra <abhishek.mohapatra@broadcom.com>
Allow the provider library to explicitly request STATIC WQE mode at
creation through a new wqe_mode field in the create-QP request,
gated by a comp_mask flag. This lets applications that create QP
directly to use fixed-size WQEs. The SQ is sized from the application
provided slot count and PSN/MSN sizing follows the
selected mode.
STATIC mode is rejected if the device reports fewer SGEs than the
fixed STATIC WQE size. On non-P5/P7 chips the 128 WQEs reserved for HW
are kept. In variable WQE mode, sq_slots must be a multiple of 256.
Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Abhishek Mohapatra <abhishek.mohapatra@broadcom.com>
Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com>
---
drivers/infiniband/hw/bnxt_re/ib_verbs.c | 122 +++++++++++++++++------
include/uapi/rdma/bnxt_re-abi.h | 9 ++
2 files changed, 102 insertions(+), 29 deletions(-)
diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
index 92d8995b5895..ac7db219bfc1 100644
--- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c
+++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
@@ -1163,6 +1163,7 @@ static int bnxt_re_get_psn_bytes(struct bnxt_re_dev *rdev,
struct bnxt_re_qp_req *ureq,
bool fixed_que_attr)
{
+ bool is_static = qplib_qp->wqe_mode == BNXT_QPLIB_WQE_MODE_STATIC;
bool msn_tbl = rdev->dev_attr &&
_is_host_msn_table(rdev->dev_attr->dev_cap_flags2);
int psn_sz, psn_nume;
@@ -1174,13 +1175,15 @@ static int bnxt_re_get_psn_bytes(struct bnxt_re_dev *rdev,
sizeof(struct sq_psn_search_ext) :
sizeof(struct sq_psn_search);
- if (fixed_que_attr)
+ /* Fixed-attribute variable-WQE QPs get the PSN count from userspace */
+ if (fixed_que_attr && !is_static)
return ureq->sq_npsn * psn_sz;
- if (cntx && bnxt_re_is_var_size_supported(rdev, cntx))
- psn_nume = ureq->sq_slots;
- else if (qplib_qp->wqe_mode == BNXT_QPLIB_WQE_MODE_STATIC)
+ /* STATIC mode matches msn_tbl_sz in bnxt_re_qp_calculate_msn_psn_size() */
+ if (is_static)
psn_nume = qplib_qp->sq.max_wqe;
+ else if (cntx && bnxt_re_is_var_size_supported(rdev, cntx))
+ psn_nume = ureq->sq_slots;
else
psn_nume = (qplib_qp->sq.max_wqe * qplib_qp->sq.wqe_size) /
sizeof(struct bnxt_qplib_sge);
@@ -1366,8 +1369,8 @@ static void bnxt_re_set_hwq_pg_sz_lvl(struct bnxt_qplib_hwq *hwq, u8 pg_sz_sft,
static int bnxt_re_setup_qp_hwqs(struct bnxt_re_qp *qp, bool fixed_que_attr)
{
struct bnxt_qplib_res *res = &qp->rdev->qplib_res;
- struct bnxt_qplib_hwq_attr hwq_attr = {};
struct bnxt_qplib_qp *qplib_qp = &qp->qplib_qp;
+ struct bnxt_qplib_hwq_attr hwq_attr = {};
struct bnxt_qplib_q *sq = &qplib_qp->sq;
struct bnxt_qplib_q *rq = &qplib_qp->rq;
u8 wqe_mode = qplib_qp->wqe_mode;
@@ -1378,7 +1381,8 @@ static int bnxt_re_setup_qp_hwqs(struct bnxt_re_qp *qp, bool fixed_que_attr)
hwq_attr.stride = bnxt_qplib_get_stride();
hwq_attr.aux_stride = qplib_qp->psn_sz;
hwq_attr.type = HWQ_TYPE_QUEUE;
- if (!fixed_que_attr) {
+ /* STATIC mode (also for fixed-attribute QPs) is sized from max_wqe */
+ if (!fixed_que_attr || wqe_mode == BNXT_QPLIB_WQE_MODE_STATIC) {
hwq_attr.depth = bnxt_qplib_get_depth(sq, wqe_mode, true);
if (qplib_qp->psn_sz)
hwq_attr.aux_depth = qplib_qp->is_host_msn_tbl ?
@@ -1509,6 +1513,7 @@ static int bnxt_re_init_rq_attr(struct bnxt_re_qp *qp,
struct bnxt_qplib_qp *qplqp;
struct bnxt_re_dev *rdev;
struct bnxt_qplib_q *rq;
+ u32 max_sge;
rdev = qp->rdev;
qplqp = &qp->qplib_qp;
@@ -1522,12 +1527,16 @@ static int bnxt_re_init_rq_attr(struct bnxt_re_qp *qp,
qplqp->srq = &srq->qplib_srq;
rq->max_wqe = 0;
} else {
- rq->max_sge = init_attr->cap.max_recv_sge;
- if (rq->max_sge > dev_attr->max_qp_sges)
- rq->max_sge = dev_attr->max_qp_sges;
+ /* Explicitly requested STATIC mode WQEs are fixed at
+ * BNXT_STATIC_MAX_SGE SGEs. Legacy QPs keep their geometry.
+ */
+ max_sge = dev_attr->max_qp_sges;
+ if (fixed_que_attr && qplqp->wqe_mode == BNXT_QPLIB_WQE_MODE_STATIC)
+ max_sge = min_t(u32, max_sge, BNXT_STATIC_MAX_SGE);
+ rq->max_sge = min_t(u32, init_attr->cap.max_recv_sge, max_sge);
init_attr->cap.max_recv_sge = rq->max_sge;
rq->wqe_size = bnxt_re_setup_rwqe_size(qplqp, rq->max_sge,
- dev_attr->max_qp_sges);
+ max_sge);
if (!fixed_que_attr) {
/* Allocate 1 more than what's provided so posting max doesn't
* mean empty.
@@ -1576,6 +1585,7 @@ static int bnxt_re_init_sq_attr(struct bnxt_re_qp *qp,
struct bnxt_re_dev *rdev;
struct bnxt_qplib_q *sq;
int diff = 0;
+ u32 max_sge;
int rc;
rdev = qp->rdev;
@@ -1589,8 +1599,11 @@ static int bnxt_re_init_sq_attr(struct bnxt_re_qp *qp,
sq->max_sw_wqe = ureq->sq_slots;
sq->wqe_size = sizeof(struct sq_sge);
} else {
- if (sq->max_sge > dev_attr->max_qp_sges) {
- sq->max_sge = dev_attr->max_qp_sges;
+ max_sge = dev_attr->max_qp_sges;
+ if (fixed_que_attr && qplqp->wqe_mode == BNXT_QPLIB_WQE_MODE_STATIC)
+ max_sge = min_t(u32, max_sge, BNXT_STATIC_MAX_SGE);
+ if (sq->max_sge > max_sge) {
+ sq->max_sge = max_sge;
init_attr->cap.max_send_sge = sq->max_sge;
}
@@ -1598,17 +1611,24 @@ static int bnxt_re_init_sq_attr(struct bnxt_re_qp *qp,
if (rc)
return rc;
- /* Allocate 128 + 1 more than what's provided */
- if (qplqp->wqe_mode != BNXT_QPLIB_WQE_MODE_VARIABLE)
- diff = BNXT_QPLIB_RESERVED_QP_WRS;
- sq->max_wqe = bnxt_re_init_depth(
- init_attr->cap.max_send_wr + diff + 1,
- dev_attr->max_qp_wqes + diff + 1, uctx);
- if (qplqp->wqe_mode == BNXT_QPLIB_WQE_MODE_VARIABLE)
- sq->max_sw_wqe = bnxt_qplib_get_depth(sq, qplqp->wqe_mode, true);
- else
+ if (uctx && fixed_que_attr) {
+ sq->max_wqe = ((u64)ureq->sq_slots * bnxt_qplib_get_stride()) /
+ sq->wqe_size;
+ /* Bound the depth by the device limit */
+ if (!sq->max_wqe || sq->max_wqe > dev_attr->max_qp_wqes + 1)
+ return -EINVAL;
sq->max_sw_wqe = sq->max_wqe;
-
+ } else {
+ /* Allocate 128 + 1 more than what's provided */
+ if (qplqp->wqe_mode != BNXT_QPLIB_WQE_MODE_VARIABLE)
+ diff = BNXT_QPLIB_RESERVED_QP_WRS;
+ sq->max_wqe = bnxt_re_init_depth(init_attr->cap.max_send_wr + diff + 1,
+ dev_attr->max_qp_wqes + diff + 1, uctx);
+ if (qplqp->wqe_mode == BNXT_QPLIB_WQE_MODE_VARIABLE)
+ sq->max_sw_wqe = bnxt_qplib_get_depth(sq, qplqp->wqe_mode, true);
+ else
+ sq->max_sw_wqe = sq->max_wqe;
+ }
}
if (!fixed_que_attr) {
sq->q_full_delta = diff + 1;
@@ -1618,6 +1638,12 @@ static int bnxt_re_init_sq_attr(struct bnxt_re_qp *qp,
* unexpected Queue full condition
*/
qplqp->sq.q_full_delta -= 1;
+ } else if (qplqp->wqe_mode == BNXT_QPLIB_WQE_MODE_STATIC &&
+ !bnxt_qplib_is_chip_gen_p5_p7(rdev->chip_ctx)) {
+ /* Legacy chips need 128 WQEs reserved for HW (8916) */
+ if (sq->max_wqe <= BNXT_QPLIB_RESERVED_QP_WRS)
+ return -EINVAL;
+ sq->q_full_delta = BNXT_QPLIB_RESERVED_QP_WRS;
} else {
sq->q_full_delta = 0;
}
@@ -1699,7 +1725,7 @@ 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 (!fixed_que_attr) {
+ if (!fixed_que_attr || wqe_mode == BNXT_QPLIB_WQE_MODE_STATIC) {
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));
@@ -1726,6 +1752,7 @@ static int bnxt_re_init_qp_attr(struct bnxt_re_qp *qp, struct bnxt_re_pd *pd,
struct bnxt_qplib_qp *qplqp;
struct bnxt_re_dev *rdev;
struct bnxt_re_cq *cq;
+ bool static_req = false;
int rc = 0, qptype;
rdev = qp->rdev;
@@ -1743,15 +1770,51 @@ static int bnxt_re_init_qp_attr(struct bnxt_re_qp *qp, struct bnxt_re_pd *pd,
return qptype;
qplqp->type = (u8)qptype;
qplqp->wqe_mode = bnxt_re_is_var_size_supported(rdev, uctx);
+
+ if (uctx && (ureq->comp_mask & BNXT_RE_QP_REQ_MASK_WQE_MODE)) {
+ switch (ureq->wqe_mode) {
+ case BNXT_RE_QP_REQ_WQE_MODE_DEFAULT:
+ break;
+ case BNXT_RE_QP_REQ_WQE_MODE_VARIABLE:
+ if (!bnxt_re_is_var_size_supported(rdev, uctx))
+ return -EOPNOTSUPP;
+ qplqp->wqe_mode = BNXT_QPLIB_WQE_MODE_VARIABLE;
+ break;
+ case BNXT_RE_QP_REQ_WQE_MODE_STATIC:
+ if (!fixed_que_attr)
+ return -EINVAL;
+ /* STATIC WQEs always use BNXT_STATIC_MAX_SGE SGEs */
+ if (dev_attr->max_qp_sges < BNXT_STATIC_MAX_SGE)
+ return -EOPNOTSUPP;
+ qplqp->wqe_mode = BNXT_QPLIB_WQE_MODE_STATIC;
+ static_req = true;
+ break;
+ default:
+ return -EINVAL;
+ }
+ }
if (uctx && qplqp->wqe_mode == BNXT_QPLIB_WQE_MODE_VARIABLE &&
- (!ureq->sq_slots || ureq->sq_slots > BNXT_RE_MAX_SQ_SLOTS))
+ (!ureq->sq_slots || ureq->sq_slots > BNXT_RE_MAX_SQ_SLOTS ||
+ !IS_ALIGNED(ureq->sq_slots, BNXT_VAR_MAX_SLOT_ALIGN)))
return -EINVAL;
if (fixed_que_attr) {
- if (qplqp->wqe_mode != BNXT_QPLIB_WQE_MODE_VARIABLE)
+ if (qplqp->wqe_mode == BNXT_QPLIB_WQE_MODE_VARIABLE) {
+ if (!ureq->sq_npsn ||
+ ureq->sq_npsn > roundup_pow_of_two(ureq->sq_slots / 2))
+ return -EINVAL;
+ } else if (!static_req) {
+ /* STATIC must be requested explicitly, not implied */
return -EOPNOTSUPP;
- if (!ureq->sq_npsn ||
- ureq->sq_npsn > roundup_pow_of_two(ureq->sq_slots / 2))
- return -EINVAL;
+ } else {
+ /* sq_slots must hold a whole number of static WQEs */
+ u32 slots_per_wqe = bnxt_re_get_swqe_size(BNXT_STATIC_MAX_SGE) /
+ bnxt_qplib_get_stride();
+
+ if (!ureq->sq_slots ||
+ ureq->sq_slots > BNXT_RE_MAX_SQ_SLOTS ||
+ ureq->sq_slots % slots_per_wqe)
+ return -EINVAL;
+ }
}
qplqp->dev_cap_flags = dev_attr->dev_cap_flags;
qplqp->cctx = rdev->chip_ctx;
@@ -1955,7 +2018,8 @@ int bnxt_re_create_qp(struct ib_qp *ib_qp, struct ib_qp_init_attr *qp_init_attr,
uctx = rdma_udata_to_drv_context(udata, struct bnxt_re_ucontext, ib_uctx);
if (udata) {
rc = ib_copy_validate_udata_in_cm(udata, ureq, qp_handle,
- BNXT_RE_QP_REQ_MASK_FIXED_QUE_ATTR);
+ BNXT_RE_QP_REQ_MASK_FIXED_QUE_ATTR |
+ BNXT_RE_QP_REQ_MASK_WQE_MODE);
if (rc)
return rc;
diff --git a/include/uapi/rdma/bnxt_re-abi.h b/include/uapi/rdma/bnxt_re-abi.h
index 15ed2a51f8f1..79d458ed3af5 100644
--- a/include/uapi/rdma/bnxt_re-abi.h
+++ b/include/uapi/rdma/bnxt_re-abi.h
@@ -128,6 +128,13 @@ struct bnxt_re_resize_cq_req {
enum bnxt_re_qp_mask {
BNXT_RE_QP_REQ_MASK_FIXED_QUE_ATTR = 0x1,
+ BNXT_RE_QP_REQ_MASK_WQE_MODE = 0x2,
+};
+
+enum bnxt_re_qp_req_wqe_mode {
+ BNXT_RE_QP_REQ_WQE_MODE_DEFAULT = 0x0,
+ BNXT_RE_QP_REQ_WQE_MODE_VARIABLE = 0x1,
+ BNXT_RE_QP_REQ_WQE_MODE_STATIC = 0x2,
};
struct bnxt_re_qp_req {
@@ -137,6 +144,8 @@ struct bnxt_re_qp_req {
__aligned_u64 comp_mask;
__u32 sq_slots;
__u32 sq_npsn;
+ __u32 wqe_mode;
+ __u32 rsvd0;
};
enum bnxt_re_create_qp_attrs {
--
2.39.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-11-30 9:51 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 14:53 [PATCH for-next v2 0/4] RDMA/bnxt_re: CQ and QP updates for app allocated queues Selvin Xavier
2026-11-30 9:51 ` sashiko-bot
2026-11-30 14:53 ` [PATCH for-next v2 1/4] RDMA/bnxt_re: Disable CQ overflow detection on P7 adapters based on FW support Selvin Xavier
2026-11-30 14:53 ` [PATCH for-next v2 2/4] RDMA/bnxt_re: Set CQ coalescing max buffers to 1 for CQs with depth 1 Selvin Xavier
2026-11-30 14:53 ` [PATCH for-next v2 3/4] RDMA/bnxt_re: Simplify PSN size and QP HWQ setup paths Selvin Xavier
2026-11-30 14:53 ` [PATCH for-next v2 4/4] RDMA/bnxt_re: Allow user library to request STATIC WQE mode per-QP Selvin Xavier
2026-11-30 9:51 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox