Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp2058884rwb; Thu, 27 Jul 2023 01:04:28 -0700 (PDT) X-Google-Smtp-Source: APBJJlEgkUUWKoyi8300h/cvuZJEX3H81Kep8RoL996TctkRax6n+2hLyNfeFCG049EG4EMwFti6 X-Received: by 2002:a17:902:ecc8:b0:1b8:936f:c346 with SMTP id a8-20020a170902ecc800b001b8936fc346mr2730091plh.30.1690445068587; Thu, 27 Jul 2023 01:04:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690445068; cv=none; d=google.com; s=arc-20160816; b=Mrw4kQSjDJdbIA2V57G86UNkFRAiCsGaTKoq9bF3EDRIeJMqEb9kciHxElCTnyrjux 2PuLxZO+ZFYKW3suLJIeXxMjjFn5Yse0AwivDGUHgtYfpIkcHs497NzcTl2BeVZ0ObtV GgvmwC+tOXap6dBAvyXAGeh2dQcWj/5tJkXwNsK52p1/wPRpU9D/FMBb8zQuLe0qBqUs ItI3BcC0O8dLzuOw1jjfp5Z3xyZ6PD0s6O1kAT4sM729ByiPdd7CzbBYNWG5Bj5kz15k FYSip/prP59Y103CUBOotmJQLQXLAA4RDFZIHYZjICOxr4vakqbQKt2/fiOzpezDH7Zw Yhtg== 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=3oxGj94hB07BWgCdSNwbyKpY/SzATptXDnS7/S8Pvw8=; fh=lwuYK8a7egGMx+R2FtRpG71kRpIpHiJ0VDZBopZor6o=; b=u0Wrfiy0iVRD7EsaXpDRxJpGFiFCzvAyfZSHQ6pNt4T50bZhHJL7KdHMaT5fkCXWbR DocN0IlvkiBJJBssaNn/XoWhZ96tBS1Qfqu4x4WiuaFbM69VdLWAQAz1CSCupsLIK6zG AOvQmsvdIFprYcKS2THk2Oenov5B/usuIctIaD9h6rjwCSZ1zC0VYxMIEJJP9hCIbLBw Nz6cbLN8VVX6j+nlKnJEiNTrGw5Qe27VjHtb9grY0LM35ODQm4ocWAX4ATXwG+2DGQjZ KblmdRBqghAe6NAyGdEcmNh/ogZ/ri5m76LOVhpPHaT0nP6lYexdGKb8Ry4tllgNb903 Hvsw== 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 l16-20020a170903121000b001b8b4330585si986263plh.510.2023.07.27.01.04.16; Thu, 27 Jul 2023 01:04:28 -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 S233534AbjG0H46 (ORCPT + 99 others); Thu, 27 Jul 2023 03:56:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232432AbjG0H4X (ORCPT ); Thu, 27 Jul 2023 03:56:23 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4190122; Thu, 27 Jul 2023 00:53:56 -0700 (PDT) Received: from kwepemi500006.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RBNGv5Hd1zNmXN; Thu, 27 Jul 2023 15:50:31 +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 15:53:54 +0800 Message-ID: Date: Thu, 27 Jul 2023 15:53:54 +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> <01d762f7-6388-9539-68ee-5425b4d56e58@hisilicon.com> <20230727065820.GZ11388@unreal> Content-Language: en-US From: Junxian Huang In-Reply-To: <20230727065820.GZ11388@unreal> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.102.17] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) 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_H5,RCVD_IN_MSPIKE_WL,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/27 14:58, Leon Romanovsky wrote: > On Thu, Jul 27, 2023 at 11:44:50AM +0800, Junxian Huang wrote: >> >> >> 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. > > Are you referring to "Table 250 - Enumeration of the Rate"? > > Thanks > >> >> Junxian Yes. Junxian