From patchwork Tue Jun 5 09:18:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 10447931 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AE9526024A for ; Tue, 5 Jun 2018 09:29:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A462928D40 for ; Tue, 5 Jun 2018 09:29:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 990DF28DE4; Tue, 5 Jun 2018 09:29:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1DA8A28D40 for ; Tue, 5 Jun 2018 09:29:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751451AbeFEJ3z (ORCPT ); Tue, 5 Jun 2018 05:29:55 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:38122 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751590AbeFEJ3y (ORCPT ); Tue, 5 Jun 2018 05:29:54 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from yishaih@mellanox.com) with ESMTPS (AES256-SHA encrypted); 5 Jun 2018 12:21:17 +0300 Received: from vnc17.mtl.labs.mlnx (vnc17.mtl.labs.mlnx [10.7.2.17]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id w559J3w4007520; Tue, 5 Jun 2018 12:19:03 +0300 Received: from vnc17.mtl.labs.mlnx (vnc17.mtl.labs.mlnx [127.0.0.1]) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8) with ESMTP id w559J32N018699; Tue, 5 Jun 2018 12:19:03 +0300 Received: (from yishaih@localhost) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8/Submit) id w559J31t018698; Tue, 5 Jun 2018 12:19:03 +0300 From: Yishai Hadas To: linux-rdma@vger.kernel.org Cc: yishaih@mellanox.com, parav@mellanox.com, majd@mellanox.com Subject: [PATCH rdma-core 2/2] mlx5: Convert ah_attr static rate to mlx5 static rate Date: Tue, 5 Jun 2018 12:18:38 +0300 Message-Id: <1528190318-18563-3-git-send-email-yishaih@mellanox.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1528190318-18563-1-git-send-email-yishaih@mellanox.com> References: <1528190318-18563-1-git-send-email-yishaih@mellanox.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Parav Pandit 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 Signed-off-by: Yishai Hadas --- 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 #include #include +#include #include #include @@ -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;