diff mbox series

[rdma-next] RDMA/mlx5: Expose vhca id for all ports in multiport mode

Message ID 41dea83aa51843aa4c067b4f73f28d64e51bd53c.1722331101.git.leon@kernel.org (mailing list archive)
State Accepted
Headers show
Series [rdma-next] RDMA/mlx5: Expose vhca id for all ports in multiport mode | expand

Commit Message

Leon Romanovsky July 30, 2024, 9:18 a.m. UTC
From: Mark Bloch <mbloch@nvidia.com>

In multiport mode, RDMA devices make it impossible for userspace to use
DEVX to discover vhca id values for ports beyond port 1. This patch
addresses the issue by exposing the vhca id of all ports.

Signed-off-by: Mark Bloch <mbloch@nvidia.com>
Reviewed-by: Maor Gottlieb <maorg@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
 drivers/infiniband/hw/mlx5/std_types.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

Comments

Leon Romanovsky Aug. 5, 2024, 11 a.m. UTC | #1
On Tue, 30 Jul 2024 12:18:45 +0300, Leon Romanovsky wrote:
> In multiport mode, RDMA devices make it impossible for userspace to use
> DEVX to discover vhca id values for ports beyond port 1. This patch
> addresses the issue by exposing the vhca id of all ports.
> 
> 

Applied, thanks!

[1/1] RDMA/mlx5: Expose vhca id for all ports in multiport mode
      https://git.kernel.org/rdma/rdma/c/d29d64e8d65960

Best regards,
diff mbox series

Patch

diff --git a/drivers/infiniband/hw/mlx5/std_types.c b/drivers/infiniband/hw/mlx5/std_types.c
index ffeb1e1a1538..bdb568411091 100644
--- a/drivers/infiniband/hw/mlx5/std_types.c
+++ b/drivers/infiniband/hw/mlx5/std_types.c
@@ -112,6 +112,23 @@  static int fill_vport_vhca_id(struct mlx5_core_dev *mdev, u16 vport,
 	return err;
 }
 
+static int fill_multiport_info(struct mlx5_ib_dev *dev, u32 port_num,
+			       struct mlx5_ib_uapi_query_port *info)
+{
+	struct mlx5_core_dev *mdev;
+
+	mdev = mlx5_ib_get_native_port_mdev(dev, port_num, NULL);
+	if (!mdev)
+		return -EINVAL;
+
+	info->vport_vhca_id = MLX5_CAP_GEN(mdev, vhca_id);
+	info->flags |= MLX5_IB_UAPI_QUERY_PORT_VPORT_VHCA_ID;
+
+	mlx5_ib_put_native_port_mdev(dev, port_num);
+
+	return 0;
+}
+
 static int fill_switchdev_info(struct mlx5_ib_dev *dev, u32 port_num,
 			       struct mlx5_ib_uapi_query_port *info)
 {
@@ -178,6 +195,10 @@  static int UVERBS_HANDLER(MLX5_IB_METHOD_QUERY_PORT)(
 		ret = fill_switchdev_info(dev, port_num, &info);
 		if (ret)
 			return ret;
+	} else if (mlx5_core_mp_enabled(dev->mdev)) {
+		ret = fill_multiport_info(dev, port_num, &info);
+		if (ret)
+			return ret;
 	}
 
 	return uverbs_copy_to_struct_or_zero(attrs, MLX5_IB_ATTR_QUERY_PORT, &info,