Skip to contentSkip to conversation

RDMA/mlx5: Fix AH static rate parsing

PATCH Applied Leon Romanovsky 1 participant 2 messages Feb 10, 2025 – Feb 20, 2025

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

PATCH 1/1 RDMA/mlx5: Fix AH static rate parsing

From: Patrisious Haddad <[email protected]>

Previously static rate wasn't translated according to our PRM but simply used the 4 lower bytes.

Correctly translate static rate value passed in AH creation attribute according to our PRM expected values.

In addition change 800GB mapping to zero, which is the PRM specified value.

Fixes e126ba97dba9 ("mlx5: Add driver for Mellanox Connect-IB adapters")
---
 drivers/infiniband/hw/mlx5/ah.c | 3 ++-
 drivers/infiniband/hw/mlx5/qp.c | 6 +++---
 drivers/infiniband/hw/mlx5/qp.h | 1 +
 3 files changed, 6 insertions(+), 4 deletions(-)
drivers/infiniband/hw/mlx5/ah.c +2 -1
index 505bc47fd575..99036afb3aef 100644
@@ -67,7 +67,8 @@ static void create_ib_ah(struct mlx5_ib_dev *dev, struct mlx5_ib_ah *ah,
 		ah->av.tclass = grh->traffic_class;
 	}
 
-	ah->av.stat_rate_sl = (rdma_ah_get_static_rate(ah_attr) << 4);
+	ah->av.stat_rate_sl =
+		(mlx5r_ib_rate(dev, rdma_ah_get_static_rate(ah_attr)) << 4);
 
 	if (ah_attr->type == RDMA_AH_ATTR_TYPE_ROCE) {
 		if (init_attr->xmit_slave)
drivers/infiniband/hw/mlx5/qp.c +3 -3
index d0d877e1b499..1356f8fcd507 100644
@@ -3449,11 +3449,11 @@ static int ib_to_mlx5_rate_map(u8 rate)
 	return 0;
 }
 
-static int ib_rate_to_mlx5(struct mlx5_ib_dev *dev, u8 rate)
+int mlx5r_ib_rate(struct mlx5_ib_dev *dev, u8 rate)
 {
 	u32 stat_rate_support;
 
-	if (rate == IB_RATE_PORT_CURRENT)
+	if (rate == IB_RATE_PORT_CURRENT || rate == IB_RATE_800_GBPS)
 		return 0;
 
 	if (rate < IB_RATE_2_5_GBPS || rate > IB_RATE_800_GBPS)
@@ -3598,7 +3598,7 @@ static int mlx5_set_path(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
 		       sizeof(grh->dgid.raw));
 	}
 
-	err = ib_rate_to_mlx5(dev, rdma_ah_get_static_rate(ah));
+	err = mlx5r_ib_rate(dev, rdma_ah_get_static_rate(ah));
 	if (err < 0)
 		return err;
 	MLX5_SET(ads, path, stat_rate, err);
drivers/infiniband/hw/mlx5/qp.h +1 -0
index b6ee7c3ee1ca..2530e7730635 100644
@@ -56,4 +56,5 @@ int mlx5_core_xrcd_dealloc(struct mlx5_ib_dev *dev, 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);
 #endif /* _MLX5_IB_QP_H */
Signature · 1 line
2.48.1
author Applied
#1 lore raw
Quoted 10 lines · Leon Romanovsky

Previously static rate wasn't translated according to our PRM but simply used the 4 lower bytes.

Correctly translate static rate value passed in AH creation attribute according to our PRM expected values.

In addition change 800GB mapping to zero, which is the PRM specified value.

[...]

Applied, thanks!

[1/1] RDMA/mlx5: Fix AH static rate parsing

      https://git.kernel.org/rdma/rdma/c/a91d5a250bd78e

Best regards,

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