Skip to content

Commit 0d74db1

Browse files
MarkZhang81gregkh
authored andcommitted
RDMA/mlx5: Fix mlx5 rates to IB rates map
[ Upstream commit 6fe6e56 ] Correct the map between mlx5 rates and corresponding ib rates, as they don't always have a fixed offset between them. Fixes: e126ba9 ("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 4ebb3b7 commit 0d74db1

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

  • drivers/infiniband/hw/mlx5

drivers/infiniband/hw/mlx5/qp.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3079,6 +3079,19 @@ enum {
30793079
MLX5_PATH_FLAG_COUNTER = 1 << 2,
30803080
};
30813081

3082+
static int mlx5_to_ib_rate_map(u8 rate)
3083+
{
3084+
static const int rates[] = { IB_RATE_PORT_CURRENT, IB_RATE_56_GBPS,
3085+
IB_RATE_25_GBPS, IB_RATE_100_GBPS,
3086+
IB_RATE_200_GBPS, IB_RATE_50_GBPS,
3087+
IB_RATE_400_GBPS };
3088+
3089+
if (rate < ARRAY_SIZE(rates))
3090+
return rates[rate];
3091+
3092+
return rate - MLX5_STAT_RATE_OFFSET;
3093+
}
3094+
30823095
static int ib_to_mlx5_rate_map(u8 rate)
30833096
{
30843097
switch (rate) {
@@ -4420,7 +4433,7 @@ static void to_rdma_ah_attr(struct mlx5_ib_dev *ibdev,
44204433
rdma_ah_set_path_bits(ah_attr, MLX5_GET(ads, path, mlid));
44214434

44224435
static_rate = MLX5_GET(ads, path, stat_rate);
4423-
rdma_ah_set_static_rate(ah_attr, static_rate ? static_rate - 5 : 0);
4436+
rdma_ah_set_static_rate(ah_attr, mlx5_to_ib_rate_map(static_rate));
44244437
if (MLX5_GET(ads, path, grh) ||
44254438
ah_attr->type == RDMA_AH_ATTR_TYPE_ROCE) {
44264439
rdma_ah_set_grh(ah_attr, NULL, MLX5_GET(ads, path, flow_label),

0 commit comments

Comments
 (0)