All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Cc: jgg@ziepe.ca, linux-rdma@vger.kernel.org,
	andrew.gospodarek@broadcom.com, selvin.xavier@broadcom.com,
	Damodharam Ammepalli <damodharam.ammepalli@broadcom.com>,
	Hongguang Gao <hongguang.gao@broadcom.com>
Subject: Re: [PATCH rdma-rext V2 2/5] RDMA/bnxt_re: Add support for QP rate limiting
Date: Sun, 1 Feb 2026 14:55:23 +0200	[thread overview]
Message-ID: <20260201125523.GC34749@unreal> (raw)
In-Reply-To: <20260129102133.2878811-3-kalesh-anakkur.purayil@broadcom.com>

On Thu, Jan 29, 2026 at 03:51:30PM +0530, Kalesh AP wrote:
> Broadcom P7 chips supports applying rate limit to RC QPs.
> It allows adjust shaper rate values during the INIT -> RTR,
> RTR -> RTS, RTS -> RTS state changes or after QP transitions
> to RTR or RTS.
> 
> Signed-off-by: Damodharam Ammepalli <damodharam.ammepalli@broadcom.com>
> Reviewed-by: Hongguang Gao <hongguang.gao@broadcom.com>
> Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
> ---
>  drivers/infiniband/hw/bnxt_re/ib_verbs.c  | 17 ++++++++++++++++-
>  drivers/infiniband/hw/bnxt_re/qplib_fp.c  | 12 +++++++++++-
>  drivers/infiniband/hw/bnxt_re/qplib_fp.h  |  3 +++
>  drivers/infiniband/hw/bnxt_re/qplib_res.h |  6 ++++++
>  drivers/infiniband/hw/bnxt_re/qplib_sp.c  |  5 +++++
>  drivers/infiniband/hw/bnxt_re/qplib_sp.h  |  2 ++
>  drivers/infiniband/hw/bnxt_re/roce_hsi.h  | 13 +++++++++----
>  7 files changed, 52 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
> index f19b55c13d58..859e5b4e0d85 100644
> --- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c
> +++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
> @@ -2089,7 +2089,7 @@ int bnxt_re_modify_qp(struct ib_qp *ib_qp, struct ib_qp_attr *qp_attr,
>  	unsigned int flags;
>  	u8 nw_type;
>  
> -	if (qp_attr_mask & ~IB_QP_ATTR_STANDARD_BITS)
> +	if (qp_attr_mask & ~(IB_QP_ATTR_STANDARD_BITS | IB_QP_RATE_LIMIT))
>  		return -EOPNOTSUPP;
>  
>  	qp->qplib_qp.modify_flags = 0;
> @@ -2129,6 +2129,21 @@ int bnxt_re_modify_qp(struct ib_qp *ib_qp, struct ib_qp_attr *qp_attr,
>  			bnxt_re_unlock_cqs(qp, flags);
>  		}
>  	}
> +
> +	if (qp_attr_mask & IB_QP_RATE_LIMIT) {
> +		if (qp->qplib_qp.type != IB_QPT_RC ||
> +		    !_is_modify_qp_rate_limit_supported(dev_attr->dev_cap_flags2))
> +			return -EOPNOTSUPP;
> +		/* check rate limit within device limits */
> +		if (qp_attr->rate_limit > dev_attr->rate_limit_max ||
> +		    qp_attr->rate_limit < dev_attr->rate_limit_min) {
> +			ibdev_err(&rdev->ibdev, "Invalid rate_limit value\n");

Kernel rarely needs to check this. Or userspace, or FW should check it.

> +			return -EINVAL;
> +		}
> +		qp->qplib_qp.ext_modify_flags |=
> +			CMDQ_MODIFY_QP_EXT_MODIFY_MASK_RATE_LIMIT_VALID;
> +		qp->qplib_qp.rate_limit = qp_attr->rate_limit;
> +	}
>  	if (qp_attr_mask & IB_QP_EN_SQD_ASYNC_NOTIFY) {
>  		qp->qplib_qp.modify_flags |=
>  				CMDQ_MODIFY_QP_MODIFY_MASK_EN_SQD_ASYNC_NOTIFY;
> diff --git a/drivers/infiniband/hw/bnxt_re/qplib_fp.c b/drivers/infiniband/hw/bnxt_re/qplib_fp.c
> index c88f049136fc..3e44311bf939 100644
> --- a/drivers/infiniband/hw/bnxt_re/qplib_fp.c
> +++ b/drivers/infiniband/hw/bnxt_re/qplib_fp.c
> @@ -1313,8 +1313,8 @@ int bnxt_qplib_modify_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp)
>  	struct bnxt_qplib_cmdqmsg msg = {};
>  	struct cmdq_modify_qp req = {};
>  	u16 vlan_pcp_vlan_dei_vlan_id;
> +	u32 bmask, bmask_ext;
>  	u32 temp32[4];
> -	u32 bmask;
>  	int rc;
>  
>  	bnxt_qplib_rcfw_cmd_prep((struct cmdq_base *)&req,
> @@ -1329,9 +1329,16 @@ int bnxt_qplib_modify_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp)
>  		    is_optimized_state_transition(qp))
>  			bnxt_set_mandatory_attributes(res, qp, &req);
>  	}
> +
>  	bmask = qp->modify_flags;
>  	req.modify_mask = cpu_to_le32(qp->modify_flags);
> +	bmask_ext = qp->ext_modify_flags;
> +	req.ext_modify_mask = cpu_to_le32(qp->ext_modify_flags);
>  	req.qp_cid = cpu_to_le32(qp->id);
> +
> +	if (bmask_ext & CMDQ_MODIFY_QP_EXT_MODIFY_MASK_RATE_LIMIT_VALID)
> +		req.rate_limit = cpu_to_le32(qp->rate_limit);
> +
>  	if (bmask & CMDQ_MODIFY_QP_MODIFY_MASK_STATE) {
>  		req.network_type_en_sqd_async_notify_new_state =
>  				(qp->state & CMDQ_MODIFY_QP_NEW_STATE_MASK) |
> @@ -1429,6 +1436,9 @@ int bnxt_qplib_modify_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp)
>  	rc = bnxt_qplib_rcfw_send_message(rcfw, &msg);
>  	if (rc)
>  		return rc;
> +
> +	if (bmask_ext & CMDQ_MODIFY_QP_EXT_MODIFY_MASK_RATE_LIMIT_VALID)
> +		qp->shaper_allocation_status = resp.shaper_allocation_status;
>  	qp->cur_qp_state = qp->state;
>  	return 0;
>  }
> diff --git a/drivers/infiniband/hw/bnxt_re/qplib_fp.h b/drivers/infiniband/hw/bnxt_re/qplib_fp.h
> index 1b414a73b46d..30c3f99be07b 100644
> --- a/drivers/infiniband/hw/bnxt_re/qplib_fp.h
> +++ b/drivers/infiniband/hw/bnxt_re/qplib_fp.h
> @@ -280,6 +280,7 @@ struct bnxt_qplib_qp {
>  	u8				state;
>  	u8				cur_qp_state;
>  	u64				modify_flags;
> +	u32				ext_modify_flags;
>  	u32				max_inline_data;
>  	u32				mtu;
>  	u8				path_mtu;
> @@ -346,6 +347,8 @@ struct bnxt_qplib_qp {
>  	bool				is_host_msn_tbl;
>  	u8				tos_dscp;
>  	u32				ugid_index;
> +	u32				rate_limit;
> +	u8				shaper_allocation_status;
>  };
>  
>  #define BNXT_RE_MAX_MSG_SIZE	0x80000000
> diff --git a/drivers/infiniband/hw/bnxt_re/qplib_res.h b/drivers/infiniband/hw/bnxt_re/qplib_res.h
> index 2ea3b7f232a3..43f9c564e97c 100644
> --- a/drivers/infiniband/hw/bnxt_re/qplib_res.h
> +++ b/drivers/infiniband/hw/bnxt_re/qplib_res.h
> @@ -623,4 +623,10 @@ 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);
>  }
>  
> +static inline bool _is_modify_qp_rate_limit_supported(u16 dev_cap_ext_flags2)
> +{
> +	return !!(dev_cap_ext_flags2 &
> +		  CREQ_QUERY_FUNC_RESP_SB_MODIFY_QP_RATE_LIMIT_SUPPORTED);

There is no need in !! for boolean check of one bit.

Thanks

  reply	other threads:[~2026-02-01 12:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-29 10:21 [PATCH rdma-rext V2 0/5] RDMA/bnxt_re: Add QP rate limit support Kalesh AP
2026-01-29 10:21 ` [PATCH rdma-rext V2 1/5] IB/core: Extend rate limit support for RC QPs Kalesh AP
2026-02-01 12:51   ` Leon Romanovsky
2026-02-02  3:22     ` Kalesh Anakkur Purayil
2026-01-29 10:21 ` [PATCH rdma-rext V2 2/5] RDMA/bnxt_re: Add support for QP rate limiting Kalesh AP
2026-02-01 12:55   ` Leon Romanovsky [this message]
2026-01-29 10:21 ` [PATCH rdma-rext V2 3/5] RDMA/bnxt_re: Report packet pacing capabilities when querying device Kalesh AP
2026-01-29 10:21 ` [PATCH rdma-rext V2 4/5] RDMA/bnxt_re: Report QP rate limit in debugfs Kalesh AP
2026-01-29 10:21 ` [PATCH rdma-rext V2 5/5] RDMA/mlx5: Support rate limit only for Raw Packet QP Kalesh AP

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=20260201125523.GC34749@unreal \
    --to=leon@kernel.org \
    --cc=andrew.gospodarek@broadcom.com \
    --cc=damodharam.ammepalli@broadcom.com \
    --cc=hongguang.gao@broadcom.com \
    --cc=jgg@ziepe.ca \
    --cc=kalesh-anakkur.purayil@broadcom.com \
    --cc=linux-rdma@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.