From: Parav Pandit <parav@xxxxxxxxxxxx> While creating AV for an AH for IB link layer, IB static rate is programmed in an AV. However it needs conversion from the IB defined static rate of Table 224 of IB spec 1.3 to HCA's internal static rate. Due to this incorrect programming, wrong static rate is used that leads to lower bandwidth when static rate is enabled in the HCA. Therefore, translate IB static rate to mlx5 internal static rate through a conversion table. Fixes: 8c4791ae2395 ("libmlx5: First version of libmlx5") Signed-off-by: Parav Pandit <parav@xxxxxxxxxxxx> Signed-off-by: Yishai Hadas <yishaih@xxxxxxxxxxxx> --- providers/mlx5/verbs.c | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/providers/mlx5/verbs.c b/providers/mlx5/verbs.c index 7853b17..d4ca842 100644 --- a/providers/mlx5/verbs.c +++ b/providers/mlx5/verbs.c @@ -44,6 +44,7 @@ #include <fcntl.h> #include <unistd.h> #include <sys/mman.h> +#include <ccan/array_size.h> #include <util/compiler.h> #include <util/mmio.h> @@ -2201,6 +2202,39 @@ int mlx5_modify_qp_rate_limit(struct ibv_qp *qp, return ret; } +/* + * IB spec version 1.3. Table 224 Rate to mlx5 rate + * conversion table on best effort basis. + */ +static const uint8_t ib_to_mlx5_rate_table[] = { + 0, /* Invalid to unlimited */ + 0, /* Invalid to unlimited */ + 7, /* 2.5 Gbps */ + 8, /* 10Gbps */ + 9, /* 30Gbps */ + 10, /* 5 Gbps */ + 11, /* 20 Gbps */ + 12, /* 40 Gbps */ + 13, /* 60 Gbps */ + 14, /* 80 Gbps */ + 15, /* 120 Gbps */ + 11, /* 14 Gbps to 20 Gbps */ + 13, /* 56 Gbps to 60 Gbps */ + 15, /* 112 Gbps to 120 Gbps */ + 0, /* 168 Gbps to unlimited */ + 9, /* 25 Gbps to 30 Gbps */ + 15, /* 100 Gbps to 120 Gbps */ + 0, /* 200 Gbps to unlimited */ + 0, /* 300 Gbps to unlimited */ +}; + +static uint8_t ah_attr_to_mlx5_rate(enum ibv_rate ah_static_rate) +{ + if (ah_static_rate >= ARRAY_SIZE(ib_to_mlx5_rate_table)) + return 0; + return ib_to_mlx5_rate_table[ah_static_rate]; +} + #define RROCE_UDP_SPORT_MIN 0xC000 #define RROCE_UDP_SPORT_MAX 0xFFFF struct ibv_ah *mlx5_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr) @@ -2208,6 +2242,7 @@ struct ibv_ah *mlx5_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr) struct mlx5_context *ctx = to_mctx(pd->context); struct ibv_port_attr port_attr; struct mlx5_ah *ah; + uint8_t static_rate; uint32_t gid_type; __be32 tmp; uint8_t grh; @@ -2253,7 +2288,8 @@ struct ibv_ah *mlx5_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr) ah->av.rlid = htobe16(attr->dlid); grh = 1; } - ah->av.stat_rate_sl = (attr->static_rate << 4) | attr->sl; + static_rate = ah_attr_to_mlx5_rate(attr->static_rate); + ah->av.stat_rate_sl = (static_rate << 4) | attr->sl; if (attr->is_global) { ah->av.tclass = attr->grh.traffic_class; ah->av.hop_limit = attr->grh.hop_limit; -- 1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html