Skip to content

Commit

Permalink
mlx5: Convert ah_attr static rate to mlx5 static rate
Browse files Browse the repository at this point in the history
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: 8c4791a ("libmlx5: First version of libmlx5")
Signed-off-by: Parav Pandit <[email protected]>
Signed-off-by: Yishai Hadas <[email protected]>
(cherry picked from commit 08f5e0a)

# Conflicts:
#	providers/mlx5/verbs.c
  • Loading branch information
paravmellanox authored and nmorey committed Jun 6, 2018
1 parent 23c472c commit 2721fdb
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion providers/mlx5/verbs.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
#include <ccan/array_size.h>

#include <util/compiler.h>
#include <util/mmio.h>
Expand Down Expand Up @@ -1741,13 +1742,47 @@ int mlx5_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
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)
{
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;
Expand Down Expand Up @@ -1793,7 +1828,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;
Expand Down

0 comments on commit 2721fdb

Please sign in to comment.