Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

RDMA/mlx5: Fix mlx5 rates to IB rates map

Correct the map between mlx5 rates and corresponding ib rates, as they
don't always have a fixed offset between them.

Fixes: e126ba97dba9 ("mlx5: Add driver for Mellanox Connect-IB adapters")
Link: https://lore.kernel.org/r/20210304124517.1100608-4-leon@kernel.org
Signed-off-by: Mark Zhang <markzhang@nvidia.com>
Reviewed-by: Maor Gottlieb <maorg@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>

authored by

Mark Zhang and committed by
Jason Gunthorpe
6fe6e568 7852546f

+14 -1
+14 -1
drivers/infiniband/hw/mlx5/qp.c
··· 3142 3142 MLX5_PATH_FLAG_COUNTER = 1 << 2, 3143 3143 }; 3144 3144 3145 + static int mlx5_to_ib_rate_map(u8 rate) 3146 + { 3147 + static const int rates[] = { IB_RATE_PORT_CURRENT, IB_RATE_56_GBPS, 3148 + IB_RATE_25_GBPS, IB_RATE_100_GBPS, 3149 + IB_RATE_200_GBPS, IB_RATE_50_GBPS, 3150 + IB_RATE_400_GBPS }; 3151 + 3152 + if (rate < ARRAY_SIZE(rates)) 3153 + return rates[rate]; 3154 + 3155 + return rate - MLX5_STAT_RATE_OFFSET; 3156 + } 3157 + 3145 3158 static int ib_to_mlx5_rate_map(u8 rate) 3146 3159 { 3147 3160 switch (rate) { ··· 4494 4481 rdma_ah_set_path_bits(ah_attr, MLX5_GET(ads, path, mlid)); 4495 4482 4496 4483 static_rate = MLX5_GET(ads, path, stat_rate); 4497 - rdma_ah_set_static_rate(ah_attr, static_rate ? static_rate - 5 : 0); 4484 + rdma_ah_set_static_rate(ah_attr, mlx5_to_ib_rate_map(static_rate)); 4498 4485 if (MLX5_GET(ads, path, grh) || 4499 4486 ah_attr->type == RDMA_AH_ATTR_TYPE_ROCE) { 4500 4487 rdma_ah_set_grh(ah_attr, NULL, MLX5_GET(ads, path, flow_label),