mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Edward Srouji <edwards@nvidia.com>
To: Leon Romanovsky <leon@kernel.org>, Jason Gunthorpe <jgg@ziepe.ca>,
	"Sabrina Dubroca" <sd@queasysnail.net>
Cc: <linux-rdma@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<netdev@vger.kernel.org>, Edward Srouji <edwards@nvidia.com>,
	"Akiva Goldberger" <agoldberger@nvidia.com>,
	Michael Gur <michaelgur@nvidia.com>
Subject: [PATCH rdma-next 06/11] RDMA/mlx5: Select the AH core device through their PD
Date: Tue, 17 Nov 2026 16:01:17 +0200	[thread overview]
Message-ID: <20261117-mlx5-sd-prep-v1-6-8efd124c7895@nvidia.com> (raw)
In-Reply-To: <20261117-mlx5-sd-prep-v1-0-8efd124c7895@nvidia.com>

From: Akiva Goldberger <agoldberger@nvidia.com>

An AH retains its PD through ib_ah->pd. Use this PD to access the core
device instead of accessing it through dev->mdev.

No functional change.

Signed-off-by: Akiva Goldberger <agoldberger@nvidia.com>
Reviewed-by: Michael Gur <michaelgur@nvidia.com>
Signed-off-by: Edward Srouji <edwards@nvidia.com>
---
 drivers/infiniband/hw/mlx5/ah.c      | 20 ++++++++++----------
 drivers/infiniband/hw/mlx5/main.c    |  4 ++--
 drivers/infiniband/hw/mlx5/mlx5_ib.h |  2 +-
 drivers/infiniband/hw/mlx5/qp.c      |  7 ++++---
 drivers/infiniband/hw/mlx5/qp.h      |  2 +-
 5 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/drivers/infiniband/hw/mlx5/ah.c b/drivers/infiniband/hw/mlx5/ah.c
index 643d0ce3452696352f7edac5bbf83012b8689033..758c41312c16f4a46d683539ffdc0a857c40ad48 100644
--- a/drivers/infiniband/hw/mlx5/ah.c
+++ b/drivers/infiniband/hw/mlx5/ah.c
@@ -32,8 +32,8 @@
 
 #include "mlx5_ib.h"
 
-static __be16 mlx5_ah_get_udp_sport(const struct mlx5_ib_dev *dev,
-				  const struct rdma_ah_attr *ah_attr)
+static __be16 mlx5_ah_get_udp_sport(struct mlx5_core_dev *mdev,
+				    const struct rdma_ah_attr *ah_attr)
 {
 	enum ib_gid_type gid_type = ah_attr->grh.sgid_attr->gid_type;
 	__be16 sport;
@@ -44,15 +44,16 @@ static __be16 mlx5_ah_get_udp_sport(const struct mlx5_ib_dev *dev,
 		sport = cpu_to_be16(
 			rdma_flow_label_to_udp_sport(ah_attr->grh.flow_label));
 	else
-		sport = mlx5_get_roce_udp_sport_min(dev,
+		sport = mlx5_get_roce_udp_sport_min(mdev,
 						    ah_attr->grh.sgid_attr);
 
 	return sport;
 }
 
-static int create_ib_ah(struct mlx5_ib_dev *dev, struct mlx5_ib_ah *ah,
-			 struct rdma_ah_init_attr *init_attr)
+static int create_ib_ah(struct mlx5_ib_ah *ah,
+			struct rdma_ah_init_attr *init_attr)
 {
+	struct mlx5_core_dev *mdev = pd_to_mdev(ah->ibah.pd);
 	struct rdma_ah_attr *ah_attr = init_attr->ah_attr;
 	enum ib_gid_type gid_type;
 	int rate_val;
@@ -68,7 +69,7 @@ static int create_ib_ah(struct mlx5_ib_dev *dev, struct mlx5_ib_ah *ah,
 		ah->av.tclass = grh->traffic_class;
 	}
 
-	rate_val = mlx5r_ib_rate(dev, rdma_ah_get_static_rate(ah_attr));
+	rate_val = mlx5r_ib_rate(mdev, rdma_ah_get_static_rate(ah_attr));
 	if (rate_val < 0)
 		return rate_val;
 	ah->av.stat_rate_sl = rate_val << 4;
@@ -76,13 +77,13 @@ static int create_ib_ah(struct mlx5_ib_dev *dev, struct mlx5_ib_ah *ah,
 	if (ah_attr->type == RDMA_AH_ATTR_TYPE_ROCE) {
 		if (init_attr->xmit_slave)
 			ah->xmit_port =
-				mlx5_lag_get_slave_port(dev->mdev,
+				mlx5_lag_get_slave_port(mdev,
 							init_attr->xmit_slave);
 		gid_type = ah_attr->grh.sgid_attr->gid_type;
 
 		memcpy(ah->av.rmac, ah_attr->roce.dmac,
 		       sizeof(ah_attr->roce.dmac));
-		ah->av.udp_sport = mlx5_ah_get_udp_sport(dev, ah_attr);
+		ah->av.udp_sport = mlx5_ah_get_udp_sport(mdev, ah_attr);
 		ah->av.stat_rate_sl |= (rdma_ah_get_sl(ah_attr) & 0x7) << 1;
 		if (gid_type == IB_GID_TYPE_ROCE_UDP_ENCAP)
 #define MLX5_ECN_ENABLED BIT(1)
@@ -102,7 +103,6 @@ int mlx5_ib_create_ah(struct ib_ah *ibah, struct rdma_ah_init_attr *init_attr,
 {
 	struct rdma_ah_attr *ah_attr = init_attr->ah_attr;
 	struct mlx5_ib_ah *ah = to_mah(ibah);
-	struct mlx5_ib_dev *dev = to_dev(ibah->device);
 	enum rdma_ah_attr_type ah_type = ah_attr->type;
 
 	if ((ah_type == RDMA_AH_ATTR_TYPE_ROCE) &&
@@ -126,7 +126,7 @@ int mlx5_ib_create_ah(struct ib_ah *ibah, struct rdma_ah_init_attr *init_attr,
 			return err;
 	}
 
-	return create_ib_ah(dev, ah, init_attr);
+	return create_ib_ah(ah, init_attr);
 }
 
 int mlx5_ib_query_ah(struct ib_ah *ibah, struct rdma_ah_attr *ah_attr)
diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
index 4ec9b56afef7d9fb52ebcd22e0858eb741d010be..f7ea8aa4ad210c51c2dfd82bbe16043af667b7d9 100644
--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -705,13 +705,13 @@ static int mlx5_ib_del_gid(const struct ib_gid_attr *attr,
 	return 0;
 }
 
-__be16 mlx5_get_roce_udp_sport_min(const struct mlx5_ib_dev *dev,
+__be16 mlx5_get_roce_udp_sport_min(const struct mlx5_core_dev *mdev,
 				   const struct ib_gid_attr *attr)
 {
 	if (attr->gid_type != IB_GID_TYPE_ROCE_UDP_ENCAP)
 		return 0;
 
-	return cpu_to_be16(MLX5_CAP_ROCE(dev->mdev, r_roce_min_src_udp_port));
+	return cpu_to_be16(MLX5_CAP_ROCE(mdev, r_roce_min_src_udp_port));
 }
 
 static int mlx5_use_mad_ifc(struct mlx5_ib_dev *dev)
diff --git a/drivers/infiniband/hw/mlx5/mlx5_ib.h b/drivers/infiniband/hw/mlx5/mlx5_ib.h
index f110803cd30694f05ce7d5bf9fdd35e6b5c003fd..8b878b33fcdff72ecfa37a860585193ab0ea9c13 100644
--- a/drivers/infiniband/hw/mlx5/mlx5_ib.h
+++ b/drivers/infiniband/hw/mlx5/mlx5_ib.h
@@ -1534,7 +1534,7 @@ int mlx5_ib_get_vf_guid(struct ib_device *device, int vf, u32 port,
 int mlx5_ib_set_vf_guid(struct ib_device *device, int vf, u32 port,
 			u64 guid, int type);
 
-__be16 mlx5_get_roce_udp_sport_min(const struct mlx5_ib_dev *dev,
+__be16 mlx5_get_roce_udp_sport_min(const struct mlx5_core_dev *mdev,
 				   const struct ib_gid_attr *attr);
 
 void mlx5_ib_cleanup_cong_debugfs(struct mlx5_ib_dev *dev, u32 port_num);
diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
index 2196e06f593e16693f682fc0e9eb7a3b18131f60..2709e5465d3316eb08f25663a248fba62ebfe8c9 100644
--- a/drivers/infiniband/hw/mlx5/qp.c
+++ b/drivers/infiniband/hw/mlx5/qp.c
@@ -3497,7 +3497,7 @@ static int ib_to_mlx5_rate_map(u8 rate)
 	return 0;
 }
 
-int mlx5r_ib_rate(struct mlx5_ib_dev *dev, u8 rate)
+int mlx5r_ib_rate(struct mlx5_core_dev *mdev, u8 rate)
 {
 	u32 stat_rate_support;
 
@@ -3508,7 +3508,7 @@ int mlx5r_ib_rate(struct mlx5_ib_dev *dev, u8 rate)
 	if (rate < IB_RATE_2_5_GBPS || rate > IB_RATE_1600_GBPS)
 		return -EINVAL;
 
-	stat_rate_support = MLX5_CAP_GEN(dev->mdev, stat_rate_support);
+	stat_rate_support = MLX5_CAP_GEN(mdev, stat_rate_support);
 	while (rate != IB_RATE_PORT_CURRENT &&
 	       !(1 << ib_to_mlx5_rate_map(rate) & stat_rate_support))
 		--rate;
@@ -3587,6 +3587,7 @@ static int mlx5_set_path(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
 			 int attr_mask, u32 path_flags,
 			 const struct ib_qp_attr *attr, bool alt)
 {
+	struct mlx5_core_dev *mdev = qp_to_mdev(qp);
 	const struct ib_global_route *grh = rdma_ah_read_grh(ah);
 	int err;
 	enum ib_gid_type gid_type;
@@ -3647,7 +3648,7 @@ static int mlx5_set_path(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
 		       sizeof(grh->dgid.raw));
 	}
 
-	err = mlx5r_ib_rate(dev, rdma_ah_get_static_rate(ah));
+	err = mlx5r_ib_rate(mdev, rdma_ah_get_static_rate(ah));
 	if (err < 0)
 		return err;
 	MLX5_SET(ads, path, stat_rate, err);
diff --git a/drivers/infiniband/hw/mlx5/qp.h b/drivers/infiniband/hw/mlx5/qp.h
index 9dabf0326071814eb44c47637ef95e6088ba35d8..e3be8077a481bb3ea1eb974938e2b55234790ff3 100644
--- a/drivers/infiniband/hw/mlx5/qp.h
+++ b/drivers/infiniband/hw/mlx5/qp.h
@@ -56,5 +56,5 @@ int mlx5_core_xrcd_dealloc(struct mlx5_core_dev *mdev, u32 xrcdn);
 int mlx5_ib_qp_set_counter(struct ib_qp *qp, struct rdma_counter *counter);
 int mlx5_ib_qp_event_init(void);
 void mlx5_ib_qp_event_cleanup(void);
-int mlx5r_ib_rate(struct mlx5_ib_dev *dev, u8 rate);
+int mlx5r_ib_rate(struct mlx5_core_dev *mdev, u8 rate);
 #endif /* _MLX5_IB_QP_H */

-- 
2.49.0


  parent reply	other threads:[~2026-11-17 14:02 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 14:01 [PATCH rdma-next 00/11] RDMA/mlx5: Preparation for SD support Edward Srouji
2026-11-17 14:01 ` [PATCH rdma-next 01/11] RDMA/mlx5: Enforce dev/mdev naming for device pointers Edward Srouji
2026-11-17 14:01 ` [PATCH rdma-next 02/11] RDMA/mlx5: Rename to_mdev() helpers that return an IB device Edward Srouji
2026-11-17 14:01 ` [PATCH rdma-next 03/11] RDMA/mlx5: Select the PD and SRQ core device through the PD Edward Srouji
2026-11-17 14:01 ` [PATCH rdma-next 04/11] RDMA/mlx5: Select the core device through PD for QP commands Edward Srouji
2026-11-17 14:01 ` [PATCH rdma-next 05/11] RDMA/mlx5: Cache the MR core device and resolve the MW's via its PD Edward Srouji
2026-11-17 14:01 ` Edward Srouji [this message]
2026-11-17 14:01 ` [PATCH rdma-next 07/11] RDMA/mlx5: Select the QP core device through " Edward Srouji
2026-11-17 14:01 ` [PATCH rdma-next 08/11] RDMA/mlx5: Resolve core device from ucontext for DEVX resources Edward Srouji
2026-11-17 14:01 ` [PATCH rdma-next 09/11] RDMA/mlx5: Cache the CQ core device and resolve it via cq_to_mdev() Edward Srouji
2026-11-17 14:01 ` [PATCH rdma-next 10/11] RDMA/mlx5: Resolve the bfreg UAR-index core device from the ucontext Edward Srouji
2026-11-17 14:01 ` [PATCH rdma-next 11/11] RDMA/mlx5: Resolve UAR and mmap core devices via " Edward Srouji

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=20261117-mlx5-sd-prep-v1-6-8efd124c7895@nvidia.com \
    --to=edwards@nvidia.com \
    --cc=agoldberger@nvidia.com \
    --cc=jgg@ziepe.ca \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=michaelgur@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=sd@queasysnail.net \
    /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®