From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5AD6842417; Thu, 19 Jan 2023 12:41:22 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1166B410DD; Thu, 19 Jan 2023 12:41:22 +0100 (CET) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2068.outbound.protection.outlook.com [40.107.244.68]) by mails.dpdk.org (Postfix) with ESMTP id 517234068E for ; Thu, 19 Jan 2023 12:41:20 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aeT8idN3I0lDGsHx9uECY7h6ky8ruRx1M7wzeijIxua6ZryfriL8zeUOctcS0XosH6stq9yr5Lt4oQ67gp2kYB30BpCGhcXUJ2ujrS31QPsP6VlvYd05QD2Qyk4/FLP4YaKoLh1Q890lLVlhHLxZ7INwYAWBSeiGYHeYmzZgPcHoi14nDlzRId7wd8TKzhfmB8IhRmYlFYn22m1vI2DC+pSJxp5WhsTZ92/dtrhbonZ3nGTM4IrWiGcJjAVEHwmPKOz9HQG2gBeJgoLiQStGEDfSyE92lrWW7vUz76ZJt00aDIhD2Vf+bw85sg8xzBAEwG427WrPMFlRFftPE63riw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JxQtnvR6n7uCdQrOM4oIHShpLWrWWT4gGKLCXN0iMmI=; b=FtTztNKCDnW15q4TFvlpSiPHT4ygXhk4xKRMQO5WD7qWnCVkOQ8aJcTfcHigFii7UYbQOLvaqx08jxF/aCw4Fm0UODVkgVhQtqnJyr5T/aU8dEV4BNk3ToI7oNzw4sqjfeDw/6I+hsPCWOkvjMIQ3Cz9ORti2KWGt/Zww+vvwyfHAWEHbIgobs3mCo+d1nBFWjpKA0gLVsL+2o2QVqKW07+LFeAM/Fv3jwewebQtdEbCfaFfEVCTr5F+oICmbVQDMXpiCIDiQG4b0TWPNdde99l3VTD6fQBxoqgt8v0ixq2g5zJ2+DtadPG4LDHHYK1HYPEpSOvclxdQficJsCsu2w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JxQtnvR6n7uCdQrOM4oIHShpLWrWWT4gGKLCXN0iMmI=; b=JpGoo9CundE0/iOTylyCc7eTsTU+2JQCRUeK81tIblU/GPSdVsznvW8me+oK7o/2RqJx7QHOHm7nSW++54P8jO0o+gTrfjXOpVyKPoKlF9BZfR0j0MB9RxmXxVxdxfdl1UDqPuF7KSfYTulNsvBPJ2rHBmcQSxMsGhrmsjOEjzQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from CH2PR12MB4294.namprd12.prod.outlook.com (2603:10b6:610:a9::11) by SA1PR12MB5637.namprd12.prod.outlook.com (2603:10b6:806:228::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.26; Thu, 19 Jan 2023 11:41:17 +0000 Received: from CH2PR12MB4294.namprd12.prod.outlook.com ([fe80::4807:1f44:5e04:e05a]) by CH2PR12MB4294.namprd12.prod.outlook.com ([fe80::4807:1f44:5e04:e05a%8]) with mapi id 15.20.6002.024; Thu, 19 Jan 2023 11:41:17 +0000 Message-ID: Date: Thu, 19 Jan 2023 11:41:12 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: [dpdk-dev] [RFC] ethdev: improve link speed to string Content-Language: en-US To: "Min Hu (Connor)" , Andrew Rybchenko Cc: thomas@monjalon.net, dev@dpdk.org References: <29b75903-d212-c6e6-eedf-e3bc92ab816a@huawei.com> <20210916025636.48024-1-humin29@huawei.com> <080fa0c3-c518-0e7f-f6d5-146dc9430d27@oktetlabs.ru> <7de60ca1-b652-e102-01c6-ec069ac00baa@huawei.com> <4c7d3345-1957-c85a-bf82-4c3df19f2ca8@oktetlabs.ru> From: Ferruh Yigit In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: PR2P264CA0016.FRAP264.PROD.OUTLOOK.COM (2603:10a6:101::28) To CH2PR12MB4294.namprd12.prod.outlook.com (2603:10b6:610:a9::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR12MB4294:EE_|SA1PR12MB5637:EE_ X-MS-Office365-Filtering-Correlation-Id: 3161d25e-e471-45bc-08ea-08dafa1213b6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Mja16IFvlfBRNFPt4w5qAkv5ejzYxwvsVWMBxv4BNagFZoilP3AG6zrJ9eVkA2IQMbw2ahXv8kMfQq9kwp1WsEebGbEfWwNRT9bVySksSR1FuYn2Pcfn3l+GPN0peMSZpqxO3DYuuoo91tFOqvFLW4dDZ+cmtuAWw7MrrMADZH6hB+Y5eXIsnfo5zQAELZw6PG7EeR45CxpiTfemosQROl7ROJQCLBu81eDaPn8R7BA5Jhwkg/WtH51uekG+yieNpLHZo8+sY81RyZW8EtnUrktQnCD4wJi87vV1kSqBJwk79jY8rSwGZCyGJGOtUHSlg8UCoQqPPX0CEZvatVxa8n4MLPawT4CUMXZUUF2/7szSfrJQfj3y2FFzjB21VnrudE8Bp27C4W13C7kBk4Z1UOCV8wQDxLcnLt8RRYU1YXQt4/CV6kH6SgMtfs250LGnT/aP8uMLz9xreHJt0GmBQcv5uXTfjsgxO/Nyb0/Q+bS2XuNpeaZGqRW8lj3ZERwdr2OEzUrwv5w4P3luJMwKsCW4RND4+08f/CP4cpamcWBIhn+CiSGq7VVTiQBbEiHO6XiwIq6yVi9BldCMNZL3CBXN767KizFRAs6ir7di9vtBYNJBsXWidqXl8iDmJ3Fl0h7QZ04o4Cbub5BBzDBfDNJ4HmTKTumuHcF68cy9fut5TwhPPayc9gQ6pgtZGIj2nl3vrf8UaA0JO2Y2nD3K8TnllGE+va9g9X2+rtxnvc8= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR12MB4294.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(39860400002)(366004)(376002)(346002)(136003)(396003)(451199015)(110136005)(316002)(2616005)(4326008)(5660300002)(8936002)(38100700002)(41300700001)(186003)(6512007)(8676002)(36756003)(26005)(83380400001)(66946007)(66556008)(66476007)(44832011)(31686004)(6666004)(31696002)(86362001)(2906002)(6486002)(6506007)(478600001)(53546011)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?dEtEZEgyNVN2UzZ1RnZyMUk4QmNPOUlqd1hRd25BVnFuSWdBaXI4NzVLdGpj?= =?utf-8?B?QVF4TEUzUVRCQnBpZXYwMURORnBwc0QvYm95RFgzMUpwNnB3a01NV1ZuVDZD?= =?utf-8?B?WXVoVWdhS1dDQjBFUHArOWFPanJBdWF1ZzdwNVBWV0o5UXBVREwxS1ZuMUJn?= =?utf-8?B?a3dJQWwvZWpsZE5WVGJTZkJKdGRac2lmNnIvY09QZ2FRZnNmR1BJR0JnWTRz?= =?utf-8?B?VTRaR29QVmN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RGb2lOeWN6L0puM3RJVzNvZHVn?= =?utf-8?B?aGQzS254OEZlQzgvTTd1dkw1TG9PWDU2TUhMcFQrVk9TZHhiUU5rNFgyUExQ?= =?utf-8?Q?+yDCc/3sHDAwQOw4i8KHofvQT?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3161d25e-e471-45bc-08ea-08dafa1213b6 X-MS-Exchange-CrossTenant-AuthSource: CH2PR12MB4294.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2023 11:41:17.6054 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: PPMg+qR3PXCr1KPEfzCZ+Y5qQmcaSJNXJSuxDotZnKQsiDKXXhNGRb3kBhyYBxgE X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB5637 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On 9/17/2021 1:43 AM, Min Hu (Connor) wrote: > 在 2021/9/16 16:21, Andrew Rybchenko 写道: >> On 9/16/21 11:16 AM, Min Hu (Connor) wrote: >>> Hi, Andrew, >>> >>> 在 2021/9/16 14:22, Andrew Rybchenko 写道: >>>> On 9/16/21 5:56 AM, Min Hu (Connor) wrote: >>>>> Currently, link speed to string only supports specific speeds, like >>>>> 10M, >>>>> 100M, 1G etc. >>>>> >>>>> This patch expands support for any link speed which is over 1M and one >>>>> decimal place will kept for display at most. >>>>> >>>>> Signed-off-by: Min Hu (Connor) >>>>> --- >>>>>    lib/ethdev/rte_ethdev.c | 34 +++++++++++++++++----------------- >>>>>    1 file changed, 17 insertions(+), 17 deletions(-) >>>>> >>>>> diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c >>>>> index daf5ca9242..1d3b960305 100644 >>>>> --- a/lib/ethdev/rte_ethdev.c >>>>> +++ b/lib/ethdev/rte_ethdev.c >>>>> @@ -2750,24 +2750,24 @@ rte_eth_link_get_nowait(uint16_t port_id, >>>>> struct rte_eth_link *eth_link) >>>>>    const char * >>>>>    rte_eth_link_speed_to_str(uint32_t link_speed) >>>>>    { >>>>> -    switch (link_speed) { >>>>> -    case ETH_SPEED_NUM_NONE: return "None"; >>>>> -    case ETH_SPEED_NUM_10M:  return "10 Mbps"; >>>>> -    case ETH_SPEED_NUM_100M: return "100 Mbps"; >>>>> -    case ETH_SPEED_NUM_1G:   return "1 Gbps"; >>>>> -    case ETH_SPEED_NUM_2_5G: return "2.5 Gbps"; >>>>> -    case ETH_SPEED_NUM_5G:   return "5 Gbps"; >>>>> -    case ETH_SPEED_NUM_10G:  return "10 Gbps"; >>>>> -    case ETH_SPEED_NUM_20G:  return "20 Gbps"; >>>>> -    case ETH_SPEED_NUM_25G:  return "25 Gbps"; >>>>> -    case ETH_SPEED_NUM_40G:  return "40 Gbps"; >>>>> -    case ETH_SPEED_NUM_50G:  return "50 Gbps"; >>>>> -    case ETH_SPEED_NUM_56G:  return "56 Gbps"; >>>>> -    case ETH_SPEED_NUM_100G: return "100 Gbps"; >>>>> -    case ETH_SPEED_NUM_200G: return "200 Gbps"; >>>>> -    case ETH_SPEED_NUM_UNKNOWN: return "Unknown"; >>>>> -    default: return "Invalid"; >>>>> +#define SPEED_STRING_LEN 16 >>>>> +    static char name[SPEED_STRING_LEN]; >>>> >>>> NACK >>>> >>>> Nothing good will happen if you try to use the function to >>>> print two different link speeds in one log message. >>> You are right. >>> And use malloc for "name" will result in memory leakage, which is also >>> not a good option. >>> >>> BTW, do you think if we need to modify the function >>> "rte_eth_link_speed_to_str"? >> >> IMHO it would be more pain than gain in this case. >> >> . >> > Agree with you. Thanks Andrew > It can be option to update the API as following in next ABI break release: const char * rte_eth_link_speed_to_str(uint32_t link_speed, char *buf, size_t buf_size); For this a deprecation notice needs to be sent and approved, not sure though if it worth. Meanwhile, what do you think to update string 'Invalid' to something like 'Irregular' or 'Erratic', does this help to convey the right message?