mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Edward Srouji <edwards@nvidia.com>
To: Leon Romanovsky <leon@kernel.org>,
	Saeed Mahameed <saeedm@nvidia.com>,
	Tariq Toukan <tariqt@nvidia.com>, Mark Bloch <mbloch@nvidia.com>,
	"Jason Gunthorpe" <jgg@ziepe.ca>,
	Selvin Xavier <selvin.xavier@broadcom.com>,
	"Kalesh AP" <kalesh-anakkur.purayil@broadcom.com>,
	Abhijit Gangurde <abhijit.gangurde@amd.com>,
	Allen Hubbe <allen.hubbe@amd.com>
Cc: <linux-rdma@vger.kernel.org>, <netdev@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	Edward Srouji <edwards@nvidia.com>,
	"Maher Sanalla" <msanalla@nvidia.com>,
	Michael Guralnik <michaelgur@nvidia.com>
Subject: [PATCH rdma-next 4/8] RDMA/mlx5: Support deferred rate limit configuration
Date: Sun, 24 May 2026 18:38:05 +0300	[thread overview]
Message-ID: <20260524-packet-pacing-v1-4-3d79439f8d08@nvidia.com> (raw)
In-Reply-To: <20260524-packet-pacing-v1-0-3d79439f8d08@nvidia.com>

From: Maher Sanalla <msanalla@nvidia.com>

Allow passing a rate limit attribute in modify QP flows even when the
QP is in a state that does not support packet pacing programming in
the lower layers.

When the user sets a rate limit during a QP transition that is not to
RTS, store the value in the mlx5 QP struct and program it to FW when
the QP later transitions to RTS, which is the state that allows
configuring the rate limit index in the QP context.

Signed-off-by: Maher Sanalla <msanalla@nvidia.com>
Reviewed-by: Michael Guralnik <michaelgur@nvidia.com>
Signed-off-by: Edward Srouji <edwards@nvidia.com>
---
 drivers/infiniband/hw/mlx5/mlx5_ib.h |  1 +
 drivers/infiniband/hw/mlx5/qp.c      | 14 +++++++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/mlx5/mlx5_ib.h b/drivers/infiniband/hw/mlx5/mlx5_ib.h
index e156dc4d752996cc4ae465bb567b0c1305d07fed..c74a53da99393cf4d4c0823cd12f9eccaa28f212 100644
--- a/drivers/infiniband/hw/mlx5/mlx5_ib.h
+++ b/drivers/infiniband/hw/mlx5/mlx5_ib.h
@@ -536,6 +536,7 @@ struct mlx5_ib_qp {
 	struct list_head	cq_recv_list;
 	struct list_head	cq_send_list;
 	struct mlx5_rate_limit	rl;
+	struct mlx5_rate_limit	rl_desired;
 	u32                     underlay_qpn;
 	u32			flags_en;
 	/*
diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
index e96d26253e3b1fabee23947b1a61ab26e7c7067f..66ab16b017c8311d44b521c023cfaf23ac42190a 100644
--- a/drivers/infiniband/hw/mlx5/qp.c
+++ b/drivers/infiniband/hw/mlx5/qp.c
@@ -3946,7 +3946,11 @@ static void qp_rl_commit(struct mlx5_core_dev *dev,
 		if (qp->rl.rate)
 			mlx5_rl_remove_rate(dev, &qp->rl);
 		memset(&qp->rl, 0, sizeof(qp->rl));
+		memset(&qp->rl_desired, 0, sizeof(qp->rl_desired));
+		return;
 	}
+
+	qp->rl_desired = ctx->rl_desired;
 }
 
 static int modify_raw_packet_qp_sq(
@@ -3990,6 +3994,7 @@ static int modify_raw_packet_qp_sq(
 	if (new_state != MLX5_SQC_STATE_RDY) {
 		mlx5_rl_remove_rate(dev, &ibqp->rl);
 		memset(&ibqp->rl, 0, sizeof(ibqp->rl));
+		memset(&ibqp->rl_desired, 0, sizeof(ibqp->rl_desired));
 	}
 
 	sq->state = new_state;
@@ -4449,7 +4454,7 @@ static int __mlx5_ib_modify_qp(struct ib_qp *ibqp,
 		if (err)
 			goto out;
 	} else {
-		rl_ctx.rl_desired = qp->rl;
+		rl_ctx.rl_desired = qp->rl_desired;
 	}
 
 	op = optab[mlx5_cur][mlx5_new];
@@ -4833,6 +4838,13 @@ int mlx5_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
 				    attr_mask);
 			goto out;
 		}
+	} else if (attr_mask == IB_QP_RATE_LIMIT && cur_state != IB_QPS_RTS) {
+		struct mlx5_rate_limit rl_desired = {};
+
+		err = qp_rl_parse(dev, qp, attr, &ucmd, &rl_desired);
+		if (!err)
+			qp->rl_desired = rl_desired;
+		goto out;
 	} else if (qp_type != MLX5_IB_QPT_REG_UMR &&
 		   qp_type != MLX5_IB_QPT_DCI &&
 		   !ib_modify_qp_is_ok(cur_state, new_state, qp_type,

-- 
2.49.0


  parent reply	other threads:[~2026-05-24 15:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-24 15:38 [PATCH rdma-next 0/8] RDMA: Extend packet pacing support to UD and UC QPs Edward Srouji
2026-05-24 15:38 ` [PATCH rdma-next 1/8] net/mlx5: Add UD and UC packet pacing caps Edward Srouji
2026-05-24 15:38 ` [PATCH rdma-next 2/8] RDMA/mlx5: Refactor raw packet QP rate limit handling Edward Srouji
2026-05-24 15:38 ` [PATCH rdma-next 3/8] RDMA/mlx5: Add support for rate limit in UD and UC QPs Edward Srouji
2026-05-24 15:38 ` Edward Srouji [this message]
2026-05-24 15:38 ` [PATCH rdma-next 5/8] RDMA/mlx5: Report packet pacing capabilities when querying device Edward Srouji
2026-05-24 15:38 ` [PATCH rdma-next 6/8] RDMA/bnxt_re: Validate rate limit attribute in modify QP Edward Srouji
2026-05-24 15:38 ` [PATCH rdma-next 7/8] RDMA/ionic: " Edward Srouji
2026-05-24 15:38 ` [PATCH rdma-next 8/8] IB/core: Delegate IB_QP_RATE_LIMIT validation to drivers Edward Srouji
2026-06-11 11:06 ` [PATCH rdma-next 0/8] RDMA: Extend packet pacing support to UD and UC QPs Leon Romanovsky

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=20260524-packet-pacing-v1-4-3d79439f8d08@nvidia.com \
    --to=edwards@nvidia.com \
    --cc=abhijit.gangurde@amd.com \
    --cc=allen.hubbe@amd.com \
    --cc=jgg@ziepe.ca \
    --cc=kalesh-anakkur.purayil@broadcom.com \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=mbloch@nvidia.com \
    --cc=michaelgur@nvidia.com \
    --cc=msanalla@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@nvidia.com \
    --cc=selvin.xavier@broadcom.com \
    --cc=tariqt@nvidia.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

all inboxes | Powered by JetHome®