Skip to contentSkip to conversation

Batch of mlx5_ib fixes

PATCH Applied Leon Romanovsky 1 participant 5 messages Jun 16, 2025 – Jun 25, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Batch of mlx5_ib fixes

The batch of different mlx5_ib fixes from Patrisious.

Patrisious Haddad (3):
RDMA/mlx5: Fix HW counters query for non-representor devices RDMA/mlx5: Fix CC counters query for MPV RDMA/mlx5: Fix vport loopback for MPV device

 drivers/infiniband/hw/mlx5/counters.c |  4 ++--
 drivers/infiniband/hw/mlx5/main.c     | 33 +++++++++++++++++++++++++++
 2 files changed, 35 insertions(+), 2 deletions(-)
Signature · 1 line
2.49.0
#1 lore raw

PATCH 1/3 RDMA/mlx5: Fix HW counters query for non-representor devices

From: Patrisious Haddad <[email protected]>

To get the device HW counters, a non-representor switchdev device should use the mlx5_ib_query_q_counters() function and query all of the available counters. While a representor device in switchdev mode should use the mlx5_ib_query_q_counters_vport() function and query only the Q_Counters without the PPCNT counters and congestion control counters, since they aren't relevant for a representor device.

Currently a non-representor switchdev device skips querying the PPCNT counters and congestion control counters, leaving them unupdated. Fix that by properly querying those counters for non-representor devices.

Fixes d22467a71ebe ("RDMA/mlx5: Expand switchdev Q-counters to expose representor statistics")
---
 drivers/infiniband/hw/mlx5/counters.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/counters.c +1 -1
index b847084dcd99..943e9eb2ad20 100644
@@ -398,7 +398,7 @@ static int do_get_hw_stats(struct ib_device *ibdev,
 		return ret;
 
 	/* We don't expose device counters over Vports */
-	if (is_mdev_switchdev_mode(dev->mdev) && port_num != 0)
+	if (is_mdev_switchdev_mode(dev->mdev) && dev->is_rep && port_num != 0)
 		goto done;
 
 	if (MLX5_CAP_PCAM_FEATURE(dev->mdev, rx_icrc_encapsulated_counter)) {
Signature · 1 line
2.49.0
#3 lore raw

PATCH 3/3 RDMA/mlx5: Fix vport loopback for MPV device

In reply to Leon Romanovsky

From: Patrisious Haddad <[email protected]>

Always enable vport loopback for both MPV devices on driver start.

Previously in some cases related to MPV RoCE, packets weren't correctly executing loopback check at vport in FW, since it was disabled. Due to complexity of identifying such cases for MPV always enable vport loopback for both GVMIs when binding the slave to the master port.

Fixes 0042f9e458a5 ("RDMA/mlx5: Enable vport loopback when user context or QP mandate")
---
 drivers/infiniband/hw/mlx5/main.c | 33 +++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
drivers/infiniband/hw/mlx5/main.c +33 -0
index ce7610740412..df6557ddbdfc 100644
@@ -1791,6 +1791,33 @@ static void deallocate_uars(struct mlx5_ib_dev *dev,
 					     context->devx_uid);
 }
 
+static int mlx5_ib_enable_lb_mp(struct mlx5_core_dev *master,
+				struct mlx5_core_dev *slave)
+{
+	int err;
+
+	err = mlx5_nic_vport_update_local_lb(master, true);
+	if (err)
+		return err;
+
+	err = mlx5_nic_vport_update_local_lb(slave, true);
+	if (err)
+		goto out;
+
+	return 0;
+
+out:
+	mlx5_nic_vport_update_local_lb(master, false);
+	return err;
+}
+
+static void mlx5_ib_disable_lb_mp(struct mlx5_core_dev *master,
+				  struct mlx5_core_dev *slave)
+{
+	mlx5_nic_vport_update_local_lb(slave, false);
+	mlx5_nic_vport_update_local_lb(master, false);
+}
+
 int mlx5_ib_enable_lb(struct mlx5_ib_dev *dev, bool td, bool qp)
 {
 	int err = 0;
@@ -3495,6 +3522,8 @@ static void mlx5_ib_unbind_slave_port(struct mlx5_ib_dev *ibdev,
 
 	lockdep_assert_held(&mlx5_ib_multiport_mutex);
 
+	mlx5_ib_disable_lb_mp(ibdev->mdev, mpi->mdev);
+
 	mlx5_core_mp_event_replay(ibdev->mdev,
 				  MLX5_DRIVER_EVENT_AFFILIATION_REMOVED,
 				  NULL);
@@ -3590,6 +3619,10 @@ static bool mlx5_ib_bind_slave_port(struct mlx5_ib_dev *ibdev,
 				  MLX5_DRIVER_EVENT_AFFILIATION_DONE,
 				  &key);
 
+	err = mlx5_ib_enable_lb_mp(ibdev->mdev, mpi->mdev);
+	if (err)
+		goto unbind;
+
 	return true;
 
 unbind:
Signature · 1 line
2.49.0
#2 lore raw

PATCH 2/3 RDMA/mlx5: Fix CC counters query for MPV

In reply to Leon Romanovsky

From: Patrisious Haddad <[email protected]>

In case, CC counters are querying for the second port use the correct core device for the query instead of always using the master core device.

Fixes aac4492ef23a ("IB/mlx5: Update counter implementation for dual port RoCE")
---
 drivers/infiniband/hw/mlx5/counters.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/counters.c +1 -1
index 943e9eb2ad20..a506fafd2b15 100644
@@ -418,7 +418,7 @@ static int do_get_hw_stats(struct ib_device *ibdev,
 			 */
 			goto done;
 		}
-		ret = mlx5_lag_query_cong_counters(dev->mdev,
+		ret = mlx5_lag_query_cong_counters(mdev,
 						   stats->value +
 						   cnts->num_q_counters,
 						   cnts->num_cong_counters,
Signature · 1 line
2.49.0
author Applied
#4 lore raw
In reply to Leon Romanovsky
Quoted 8 lines · Leon Romanovsky

The batch of different mlx5_ib fixes from Patrisious.

Patrisious Haddad (3):
RDMA/mlx5: Fix HW counters query for non-representor devices RDMA/mlx5: Fix CC counters query for MPV RDMA/mlx5: Fix vport loopback for MPV device

[...]

Applied, thanks!

[1/3] RDMA/mlx5: Fix HW counters query for non-representor devices

      https://git.kernel.org/rdma/rdma/c/3cc1dbfddf88dc
[2/3] RDMA/mlx5: Fix CC counters query for MPV
      https://git.kernel.org/rdma/rdma/c/acd245b1e33fc4
[3/3] RDMA/mlx5: Fix vport loopback for MPV device
      https://git.kernel.org/rdma/rdma/c/a9a9e68954f29b

Best regards,

Signature · 1 line
Leon Romanovsky <[email protected]>