Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Selvin Xavier" <selvin.xavier@broadcom.com>
Cc: linux-rdma@vger.kernel.org
Subject: Re: [PATCH for-next 4/4] RDMA/bnxt_re: Allow user library to request STATIC WQE mode per-QP
Date: Sun, 29 Nov 2026 18:21:56 +0000	[thread overview]
Message-ID: <sashiko-outbox-239898@kernel.org> (raw)
In-Reply-To: <20261129232105.358484-5-selvin.xavier@broadcom.com>

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

      reply	other threads:[~2026-11-29 18:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-239898@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=selvin.xavier@broadcom.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox