Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp1848110rwb; Wed, 26 Jul 2023 20:59:05 -0700 (PDT) X-Google-Smtp-Source: APBJJlHMSvfmZeQHKvL0RxAHfZdM4gj10SQO5mrQHFu71en57f87QAKlXLZVkeXsayeB94UkuPCr X-Received: by 2002:a05:6808:1a88:b0:3a0:5723:e649 with SMTP id bm8-20020a0568081a8800b003a05723e649mr1653272oib.9.1690430345101; Wed, 26 Jul 2023 20:59:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690430345; cv=none; d=google.com; s=arc-20160816; b=pY0O8Jwq8374UY46pzlTdcOWZeH1eZ3ehwJq/0PBUN+A1Cf/1RgZEcOGBcJjt6QwHT 4ZUZZMIlhUR+Jvfe5CqXy12+tS6eVFFqZRdkDEk/HHb+5uZP1jT+4BDV5NJKww8dkrpm BCY0LKaUU+xnvmPb8RrYLNCar5A8fMPXEMVr+t6IjlHhTPzG0hNhGWfpcAMSHCA1i9Yf KT9uNapREWY3arSwDNCAJriB5x85adxZobO9CyPvColJmzrMqI4YsUXma0g02ZMAOVSW eJMwufA1sx9ysBztLrmS5TB0DF0lj7qsV5pR5Y/XLOWXQR2cjqoTrMs2HX3rqR2kqSLl Sw9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id; bh=mvgVG7KKz4I4WxjpOls9KbH7YKwZUWodZbs/wnyMuRE=; fh=lwuYK8a7egGMx+R2FtRpG71kRpIpHiJ0VDZBopZor6o=; b=b3i57C+F85X7L1+pAZkoyQKKvbhx9D3XU7QRKBYFGNipMXEy8PQExceCkpnhP4wKm6 f98cFUV4eOdMFdaZwg1kQaeFrrZeX8HdtqMAJFcZtpaf0qlQY/LsEAnjbHBJqgO0h0uS kskQnk6isDG0Ln3QZib5XItsE+PTp5Y9Q4f0GMOLVXM62dw1E9ZuAmMxa0iSnb/jxuK7 2VobkA4NUnIhSrK904btdCwZ+N1usUjochaPaPN00Ydo1YJKXGu82VF8vfTRla4OQ+ax Z7gn2yKOQCk8DDj9Xl/q/iTGe49r5ocM5UOLsY5KxIrbAm2hXiDBJljjBxQ7f9Hmgdi/ TUdA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b3-20020a63e703000000b00563e23a5524si439337pgi.336.2023.07.26.20.58.52; Wed, 26 Jul 2023 20:59:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231340AbjG0Do5 (ORCPT + 99 others); Wed, 26 Jul 2023 23:44:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230083AbjG0Doz (ORCPT ); Wed, 26 Jul 2023 23:44:55 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D30310FC; Wed, 26 Jul 2023 20:44:54 -0700 (PDT) Received: from kwepemi500006.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4RBGmR6Sl4zLntV; Thu, 27 Jul 2023 11:42:15 +0800 (CST) Received: from [10.67.102.17] (10.67.102.17) by kwepemi500006.china.huawei.com (7.221.188.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 27 Jul 2023 11:44:51 +0800 Message-ID: <01d762f7-6388-9539-68ee-5425b4d56e58@hisilicon.com> Date: Thu, 27 Jul 2023 11:44:50 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.1.0 Subject: Re: [PATCH v4 for-next] RDMA/core: Get IB width and speed from netdev To: Leon Romanovsky CC: , , , References: <20230721092052.2090449-1-huangjunxian6@hisilicon.com> <20230724111938.GB9776@unreal> Content-Language: en-US From: Junxian Huang In-Reply-To: <20230724111938.GB9776@unreal> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.102.17] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500006.china.huawei.com (7.221.188.68) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023/7/24 19:19, Leon Romanovsky wrote: > On Fri, Jul 21, 2023 at 05:20:52PM +0800, Junxian Huang wrote: >> From: Haoyue Xu >> >> Previously, there was no way to query the number of lanes for a network >> card, so the same netdev_speed would result in a fixed pair of width and >> speed. As network card specifications become more diverse, such fixed >> mode is no longer suitable, so a method is needed to obtain the correct >> width and speed based on the number of lanes. >> >> This patch retrieves netdev lanes and speed from net_device and >> translates them to IB width and speed. >> >> Signed-off-by: Haoyue Xu >> Signed-off-by: Luoyouming >> Signed-off-by: Junxian Huang >> --- >> drivers/infiniband/core/verbs.c | 100 +++++++++++++++++++++++++------- >> 1 file changed, 79 insertions(+), 21 deletions(-) >> >> diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c >> index b99b3cc283b6..25367bd6dd97 100644 >> --- a/drivers/infiniband/core/verbs.c >> +++ b/drivers/infiniband/core/verbs.c >> @@ -1880,6 +1880,80 @@ int ib_modify_qp_with_udata(struct ib_qp *ib_qp, struct ib_qp_attr *attr, >> } >> EXPORT_SYMBOL(ib_modify_qp_with_udata); >> >> +static void ib_get_width_and_speed(u32 netdev_speed, u32 lanes, >> + u16 *speed, u8 *width) > > <...> > >> + switch (netdev_speed / lanes) { >> + case SPEED_2500: >> + *speed = IB_SPEED_SDR; >> + break; >> + case SPEED_5000: >> + *speed = IB_SPEED_DDR; >> + break; >> + case SPEED_10000: >> + *speed = IB_SPEED_FDR10; >> + break; >> + case SPEED_14000: >> + *speed = IB_SPEED_FDR; >> + break; >> + case SPEED_25000: >> + *speed = IB_SPEED_EDR; >> + break; >> + case SPEED_50000: >> + *speed = IB_SPEED_HDR; >> + break; >> + case SPEED_100000: >> + *speed = IB_SPEED_NDR; >> + break; >> + default: >> + *speed = IB_SPEED_SDR; >> + } > > How did you come to these translation values? > > Thanks The IB spec defines the mapping relationship between IB speed and transfer rate. For example, if the transfer rate of is 2.5Gbps(SPEED_2500), the IB speed will be set to IB_SPEED_SDR. Junxian