Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4617511pxj; Wed, 12 May 2021 09:20:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxd3fPhg+ZkBS0s92JUWDyQ5Td8aDTlJ3Bv5raJFBhW+5i8t4BDjqpAi31kfxvH/aKX2uyY X-Received: by 2002:a2e:161a:: with SMTP id w26mr29725252ljd.436.1620836405401; Wed, 12 May 2021 09:20:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620836405; cv=none; d=google.com; s=arc-20160816; b=luj2yqVbxQ+lECqk5WXSffdzX7wC6gi6/oXUPlvXFQ0EivqqMzVf0BhTK1+wFYgQSP fO0++u7+Zt+kuCYIKI9hysdWLGBMknYg2ZRXyoTLsopwleYDy2KBv2lFLHaujJQSSP1c q6h8mxfVSLTzM/gj9i1OuUXPNWYIz61AZ96NW6m1rd+Trv/ElMvkgCeWf6h09EnHgNp+ O3T6Vna9wyNsu6VeNS7mmnLex5EDf5DAc0xwwC9qFLCzAVWITyIUcPLunnGDbJNxR+gd sV/oTOQmGfYbcvDzzLVLrgh9YH1MdEnWQZRUhXVOr+OlANtkx4Fl547nUcl/DOS7bSlL yRLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xzQCmSG6qdGkZUKTXfpPJk0u3XviXqYkOoo+wjssNoQ=; b=DLeZJcqO9L78L16TVf0fD49h2/rr8LdFvhGlj4XjND2cVniUCfkBbg0IrHJEeCVzVK vKGbbCBgTMFUMlH+CUC5nhxTQF2vu+7YI3JNkfIxzHrZqWg/deFWrM9krAaat4wU4/GY IlNrZ0ZhoUd8KF5p6iZ0Z/b5RoqfxQwhJrMw61m5fmicT78Xm8fqP2caukLisEemOsSJ GZs8ur8Qti1Eu3zTT71bm7PDgvPQ4QAl7+ftNtujrmGNbK5mSrYzP5ZTbGH7CZeRCcB2 mwx+/k7RNo/E4ID3AJCc4P7zqCtkmW1ix9sD+a3aCJ07QPBwgzu4bkeVxvMdtaYB5KuZ 47Qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rBmXzfw2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s11si317073ljp.184.2021.05.12.09.19.35; Wed, 12 May 2021 09:20:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rBmXzfw2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239875AbhELQQP (ORCPT + 99 others); Wed, 12 May 2021 12:16:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:48856 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234528AbhELPdH (ORCPT ); Wed, 12 May 2021 11:33:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BFBBD6194A; Wed, 12 May 2021 15:16:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832615; bh=g8v2ohjAqoDVPLQOw2syeDJ0Nzts78tm8hm/jN+xeMk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rBmXzfw2WjKkmtl+LYgG6uAnQWR7t0zXrQl9xmyvd+Mhn0rt65cvTEieHXPTK2o7F cjoHCMWefzePXlH6mXjGYseeVOY4JEyMsVPeagumw3oTxtGA61rXjKOYhSaIjv95LV A/urG6g/BT+nrEwgkulChZIddDCk5sMZVcgH5o4o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Zhang , Maor Gottlieb , Leon Romanovsky , Jason Gunthorpe , Sasha Levin Subject: [PATCH 5.10 352/530] RDMA/mlx5: Fix mlx5 rates to IB rates map Date: Wed, 12 May 2021 16:47:42 +0200 Message-Id: <20210512144831.350724048@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mark Zhang [ Upstream commit 6fe6e568639859db960c8fcef19a2ece1c2d7eae ] 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 Reviewed-by: Maor Gottlieb Signed-off-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/hw/mlx5/qp.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c index 75caeec378bd..6d2715f65d78 100644 --- a/drivers/infiniband/hw/mlx5/qp.c +++ b/drivers/infiniband/hw/mlx5/qp.c @@ -3079,6 +3079,19 @@ enum { MLX5_PATH_FLAG_COUNTER = 1 << 2, }; +static int mlx5_to_ib_rate_map(u8 rate) +{ + static const int rates[] = { IB_RATE_PORT_CURRENT, IB_RATE_56_GBPS, + IB_RATE_25_GBPS, IB_RATE_100_GBPS, + IB_RATE_200_GBPS, IB_RATE_50_GBPS, + IB_RATE_400_GBPS }; + + if (rate < ARRAY_SIZE(rates)) + return rates[rate]; + + return rate - MLX5_STAT_RATE_OFFSET; +} + static int ib_to_mlx5_rate_map(u8 rate) { switch (rate) { @@ -4420,7 +4433,7 @@ static void to_rdma_ah_attr(struct mlx5_ib_dev *ibdev, rdma_ah_set_path_bits(ah_attr, MLX5_GET(ads, path, mlid)); static_rate = MLX5_GET(ads, path, stat_rate); - rdma_ah_set_static_rate(ah_attr, static_rate ? static_rate - 5 : 0); + rdma_ah_set_static_rate(ah_attr, mlx5_to_ib_rate_map(static_rate)); if (MLX5_GET(ads, path, grh) || ah_attr->type == RDMA_AH_ATTR_TYPE_ROCE) { rdma_ah_set_grh(ah_attr, NULL, MLX5_GET(ads, path, flow_label), -- 2.30.2