aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorMaher Sanalla <msanalla@nvidia.com>2026-05-24 18:38:07 +0300
committerLeon Romanovsky <leon@kernel.org>2026-06-11 07:02:05 -0400
commit8cca27313636c3e2cfc5f8071abfbbfdcf3138f8 (patch)
tree9234b28554589b9814929c88a167f1a9d26de7cb /drivers
parent1f307090e9575005ae3fc5cbb9d9520dcaf5086d (diff)
RDMA/bnxt_re: Validate rate limit attribute in modify QP
Rate limit transition validation for RC QPs currently relies on the IB core qp_state_table. Add a driver-level helper to validate the rate limit attribute directly during QP modify, ensuring it is only accepted for RC QPs in INIT->RTR, RTR->RTS and RTS->RTS transitions. This makes the driver responsible for rate limit validation and prepares for a follow-up IB core change that delegates IB_QP_RATE_LIMIT and all future non-standard modify attributes handling to individual vendor drivers. Signed-off-by: Maher Sanalla <msanalla@nvidia.com> Reviewed-by: Michael Guralnik <michaelgur@nvidia.com> Signed-off-by: Edward Srouji <edwards@nvidia.com> Link: https://patch.msgid.link/20260524-packet-pacing-v1-6-3d79439f8d08@nvidia.com Signed-off-by: Leon Romanovsky <leon@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/infiniband/hw/bnxt_re/ib_verbs.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
index b1c489867fc7..13e765f10db1 100644
--- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c
+++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
@@ -2406,6 +2406,23 @@ static int bnxt_re_modify_shadow_qp(struct bnxt_re_dev *rdev,
return rc;
}
+static bool bnxt_re_is_modify_ok(enum ib_qp_attr_mask ext_mask,
+ enum ib_qp_type type, enum ib_qp_state cur,
+ enum ib_qp_state next)
+{
+ if (!ext_mask)
+ return true;
+
+ if (ext_mask & ~IB_QP_RATE_LIMIT)
+ return false;
+
+ /* Rate limit is only supported for RC QPs during specific transitions */
+ return type == IB_QPT_RC &&
+ ((cur == IB_QPS_INIT && next == IB_QPS_RTR) ||
+ (cur == IB_QPS_RTR && next == IB_QPS_RTS) ||
+ (cur == IB_QPS_RTS && next == IB_QPS_RTS));
+}
+
int bnxt_re_modify_qp(struct ib_qp *ib_qp, struct ib_qp_attr *qp_attr,
int qp_attr_mask, struct ib_udata *udata)
{
@@ -2430,7 +2447,10 @@ int bnxt_re_modify_qp(struct ib_qp *ib_qp, struct ib_qp_attr *qp_attr,
curr_qp_state = __to_ib_qp_state(qp->qplib_qp.cur_qp_state);
new_qp_state = qp_attr->qp_state;
if (!ib_modify_qp_is_ok(curr_qp_state, new_qp_state,
- ib_qp->qp_type, qp_attr_mask)) {
+ ib_qp->qp_type, qp_attr_mask) ||
+ !bnxt_re_is_modify_ok(qp_attr_mask & ~IB_QP_ATTR_STANDARD_BITS,
+ ib_qp->qp_type, curr_qp_state,
+ new_qp_state)) {
ibdev_err(&rdev->ibdev,
"Invalid attribute mask: %#x specified ",
qp_attr_mask);