* Re: [PATCH for-next 4/4] RDMA/bnxt_re: Allow user library to request STATIC WQE mode per-QP
2026-11-29 23:21 ` [PATCH for-next 4/4] RDMA/bnxt_re: Allow user library to request STATIC WQE mode per-QP Selvin Xavier
@ 2026-11-29 18:21 ` sashiko-bot
0 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-11-29 18:21 UTC (permalink / raw)
To: Selvin Xavier; +Cc: linux-rdma
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] RDMA/bnxt_re: wrong RQ WQE size in bnxt_re_init_rq_attr() for
static mode
- [Medium] RDMA/bnxt_re: invalid max_qp_wqes check in
bnxt_re_init_sq_attr()
--
commit bbcf0cf8e78f812d2c2f6e6894a2f9c446265041
Author: Abhishek Mohapatra <abhishek.mohapatra@broadcom.com>
RDMA/bnxt_re: Allow user library to request STATIC WQE mode per-QP
This commit adds a BNXT_RE_QP_REQ_MASK_WQE_MODE flag and wqe_mode field to
struct bnxt_re_qp_req so userspace can explicitly request static WQE mode
per QP and size the SQ and PSN/MSN table accordingly.
> diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
> index 92d8995b58952..6905da9c8f1d6 100644
> --- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c
> +++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
[ ... ]
> @@ -1598,16 +1602,23 @@ 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;
> + if (!sq->max_wqe || sq->max_wqe > dev_attr->max_qp_wqes)
> + return -EINVAL;
> sq->max_sw_wqe = sq->max_wqe;
[Severity: Medium]
Does checking sq->max_wqe > dev_attr->max_qp_wqes reject valid power-of-two
static SQ depths?
In bnxt_re_init_qp_attr(), static fixed_que_attr QPs require sq->max_wqe
(ureq->sq_slots / slots_per_wqe) to be a power of two and allow
ureq->sq_slots up to BNXT_RE_MAX_SQ_SLOTS (65536 slots, or 8192 static
WQEs). However, bnxt_qplib_get_dev_attr() sets dev_attr->max_qp_wqes to
BNXT_VAR_MAX_WQE - 1 (4351) on variable-WQE devices (Gen P7) and to
sb->max_qp_wr - 1 (one less than a power of two) on static-WQE devices:
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(cctx))
attr->max_qp_wqes -= BNXT_QPLIB_RESERVED_QP_WRS;
/* 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;
...
}
As a result, creating a static-WQE QP with sq->max_wqe == 8192 on Gen P7
(or sq->max_wqe == sb->max_qp_wr on Gen P5) fails with -EINVAL here even
though it passes the BNXT_RE_MAX_SQ_SLOTS check in bnxt_re_init_qp_attr().
[ ... ]
> @@ -1743,15 +1755,52 @@ 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)) {
> + if (ureq->rsvd0)
> + return -EINVAL;
> + 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;
> + qplqp->wqe_mode = BNXT_QPLIB_WQE_MODE_STATIC;
> + static_req = true;
> + break;
[Severity: High]
When BNXT_RE_QP_REQ_WQE_MODE_STATIC is requested on a variable-WQE device
(Gen P7), does bnxt_re_init_rq_attr() compute a 240-byte rq->wqe_size
instead of the 128-byte static RQ WQE size expected by hardware and
userspace?
On Gen P7, dev_attr->max_qp_sges is up to BNXT_VAR_MAX_SGE (13). While
bnxt_re_setup_swqe_size() explicitly uses BNXT_STATIC_MAX_SGE (6) for the
SQ when qplqp->wqe_mode is BNXT_QPLIB_WQE_MODE_STATIC,
bnxt_re_init_rq_attr() passes dev_attr->max_qp_sges as max to
bnxt_re_setup_rwqe_size(), which forces rsge = max in static mode:
drivers/infiniband/hw/bnxt_re/ib_verbs.c:bnxt_re_setup_rwqe_size() {
if (qplqp->wqe_mode == BNXT_QPLIB_WQE_MODE_STATIC)
rsge = max;
return bnxt_re_get_rwqe_size(rsge);
}
This sets rq->wqe_size to 240 bytes (15 slots) instead of 128 bytes (8
slots), whereas bnxt_qplib_create_qp() programs firmware with nsge = 6
whenever qp->wqe_mode == BNXT_QPLIB_WQE_MODE_STATIC. bnxt_re_init_user_qp()
then calls ib_umem_get_attr_or_va() for PAGE_ALIGN(rq.max_wqe * 240) bytes,
failing QP creation with -EFAULT when userspace allocated 128-byte RQ WQEs
or sizing rq->hwq.depth at 15 slots per WQE while hardware uses 8. In
addition, cap.max_send_sge, cap.max_recv_sge, and cap.max_inline_data are
still validated only against the variable-WQE device limits rather than
BNXT_STATIC_MAX_SGE (6 SGEs / 96 bytes).
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261129232105.358484-1-selvin.xavier@broadcom.com?part=4
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH for-next 0/4] RDMA/bnxt_re: CQ and QP updates for app allocated queues
2026-11-29 23:21 [PATCH for-next 0/4] RDMA/bnxt_re: CQ and QP updates for app allocated queues Selvin Xavier
@ 2026-11-29 18:21 ` sashiko-bot
2026-11-29 23:21 ` [PATCH for-next 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-29 18:21 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..."): 2
potential issues (1 High, 1 Medium)
A detailed review has been sent as a separate reply to patch 4.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261129232105.358484-1-selvin.xavier@broadcom.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH for-next 0/4] RDMA/bnxt_re: CQ and QP updates for app allocated queues
@ 2026-11-29 23:21 Selvin Xavier
2026-11-29 18:21 ` sashiko-bot
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: Selvin Xavier @ 2026-11-29 23:21 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
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 | 176 ++++++++++++++--------
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, 140 insertions(+), 65 deletions(-)
--
2.39.3
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH for-next 1/4] RDMA/bnxt_re: Disable CQ overflow detection on P7 adapters based on FW support
2026-11-29 23:21 [PATCH for-next 0/4] RDMA/bnxt_re: CQ and QP updates for app allocated queues Selvin Xavier
2026-11-29 18:21 ` sashiko-bot
@ 2026-11-29 23:21 ` Selvin Xavier
2026-11-29 23:21 ` [PATCH for-next 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-29 23:21 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 5301e4f21ade..57c773521feb 100644
--- a/drivers/infiniband/hw/bnxt_re/qplib_fp.c
+++ b/drivers/infiniband/hw/bnxt_re/qplib_fp.c
@@ -2122,6 +2122,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 2/4] RDMA/bnxt_re: Set CQ coalescing max buffers to 1 for CQs with depth 1
2026-11-29 23:21 [PATCH for-next 0/4] RDMA/bnxt_re: CQ and QP updates for app allocated queues Selvin Xavier
2026-11-29 18:21 ` sashiko-bot
2026-11-29 23:21 ` [PATCH for-next 1/4] RDMA/bnxt_re: Disable CQ overflow detection on P7 adapters based on FW support Selvin Xavier
@ 2026-11-29 23:21 ` Selvin Xavier
2026-11-29 23:21 ` [PATCH for-next 3/4] RDMA/bnxt_re: Simplify PSN size and QP HWQ setup paths Selvin Xavier
2026-11-29 23:21 ` [PATCH for-next 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-29 23:21 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 57c773521feb..c03624b02570 100644
--- a/drivers/infiniband/hw/bnxt_re/qplib_fp.c
+++ b/drivers/infiniband/hw/bnxt_re/qplib_fp.c
@@ -2088,6 +2088,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 = {};
@@ -2129,13 +2131,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 3/4] RDMA/bnxt_re: Simplify PSN size and QP HWQ setup paths
2026-11-29 23:21 [PATCH for-next 0/4] RDMA/bnxt_re: CQ and QP updates for app allocated queues Selvin Xavier
` (2 preceding siblings ...)
2026-11-29 23:21 ` [PATCH for-next 2/4] RDMA/bnxt_re: Set CQ coalescing max buffers to 1 for CQs with depth 1 Selvin Xavier
@ 2026-11-29 23:21 ` Selvin Xavier
2026-11-29 23:21 ` [PATCH for-next 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-29 23:21 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 ac15372376a2..7d26d94ae8ea 100644
--- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c
+++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
@@ -1168,28 +1168,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;
}
@@ -1359,61 +1361,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)
@@ -1422,7 +1421,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 4/4] RDMA/bnxt_re: Allow user library to request STATIC WQE mode per-QP
2026-11-29 23:21 [PATCH for-next 0/4] RDMA/bnxt_re: CQ and QP updates for app allocated queues Selvin Xavier
` (3 preceding siblings ...)
2026-11-29 23:21 ` [PATCH for-next 3/4] RDMA/bnxt_re: Simplify PSN size and QP HWQ setup paths Selvin Xavier
@ 2026-11-29 23:21 ` Selvin Xavier
2026-11-29 18:21 ` sashiko-bot
4 siblings, 1 reply; 7+ messages in thread
From: Selvin Xavier @ 2026-11-29 23:21 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.
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 | 92 ++++++++++++++++++------
include/uapi/rdma/bnxt_re-abi.h | 9 +++
2 files changed, 80 insertions(+), 21 deletions(-)
diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
index 7d26d94ae8ea..cd4064682574 100644
--- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c
+++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
@@ -1168,6 +1168,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;
@@ -1179,13 +1180,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)
+ psn_nume = ureq->sq_slots;
else
psn_nume = (qplib_qp->sq.max_wqe * qplib_qp->sq.wqe_size) /
sizeof(struct bnxt_qplib_sge);
@@ -1371,8 +1374,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;
@@ -1383,7 +1386,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 ?
@@ -1603,16 +1607,23 @@ 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;
+ if (!sq->max_wqe || sq->max_wqe > dev_attr->max_qp_wqes)
+ 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) {
@@ -1704,7 +1715,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));
@@ -1731,6 +1742,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;
@@ -1748,15 +1760,52 @@ 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)) {
+ if (ureq->rsvd0)
+ return -EINVAL;
+ 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;
+ 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))
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 power-of-two number of static
+ * WQEs, since the SQ depth is used as an index mask.
+ */
+ 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 ||
+ !is_power_of_2(ureq->sq_slots / slots_per_wqe))
+ return -EINVAL;
+ }
}
qplqp->dev_cap_flags = dev_attr->dev_cap_flags;
qplqp->cctx = rdev->chip_ctx;
@@ -1960,7 +2009,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 856a1b3036e9..719799ecd0e6 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-29 18:21 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-29 23:21 [PATCH for-next 0/4] RDMA/bnxt_re: CQ and QP updates for app allocated queues Selvin Xavier
2026-11-29 18:21 ` sashiko-bot
2026-11-29 23:21 ` [PATCH for-next 1/4] RDMA/bnxt_re: Disable CQ overflow detection on P7 adapters based on FW support Selvin Xavier
2026-11-29 23:21 ` [PATCH for-next 2/4] RDMA/bnxt_re: Set CQ coalescing max buffers to 1 for CQs with depth 1 Selvin Xavier
2026-11-29 23:21 ` [PATCH for-next 3/4] RDMA/bnxt_re: Simplify PSN size and QP HWQ setup paths Selvin Xavier
2026-11-29 23:21 ` [PATCH for-next 4/4] RDMA/bnxt_re: Allow user library to request STATIC WQE mode per-QP Selvin Xavier
2026-11-29 18:21 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox