From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9FF49A04C3; Tue, 11 Aug 2020 15:00:36 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DA5771C022; Tue, 11 Aug 2020 15:00:35 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 15F251C01F for ; Tue, 11 Aug 2020 15:00:33 +0200 (CEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20200811130032euoutp011c296d1bfe63c9448a5d150752dc9c3f~qODhw1OCZ2696726967euoutp01G for ; Tue, 11 Aug 2020 13:00:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20200811130032euoutp011c296d1bfe63c9448a5d150752dc9c3f~qODhw1OCZ2696726967euoutp01G DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1597150832; bh=Vq0qf9N4vqMzL82B90YC6I2UolNURpe0qFXgxbvidZI=; h=Subject:To:Cc:From:Date:In-Reply-To:References:From; b=KmNLqLwOFf0SQe5eLRkMhhOfvNHUd7nDSeJbXQd7vWX3BbsxCt2y/D5upjkQq0hU0 YMO+LwCqsynMgohZvB1DQ5zYbuybrajJ4xIwo5Z9CtYCh6H/HMZAJqX6nyqkJ6OSEE 08W97cGO2ARYyyjNRuJVB7fK2BJsHqIQMemTWt6w= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20200811130032eucas1p17625d781fdd2c0839419cf5d6b323a08~qODhqqmWv0645506455eucas1p1c; Tue, 11 Aug 2020 13:00:32 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 10.F2.05997.076923F5; Tue, 11 Aug 2020 14:00:32 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20200811130032eucas1p1158393590e18a9ad18427e71b5412e61~qODhaRw1r0645506455eucas1p1b; Tue, 11 Aug 2020 13:00:32 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200811130032eusmtrp16f4d90fbdaa49dea580531e746f3805a~qODhZp__Q1710517105eusmtrp1z; Tue, 11 Aug 2020 13:00:32 +0000 (GMT) X-AuditID: cbfec7f4-65dff7000000176d-d2-5f3296704431 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id AA.6E.06314.076923F5; Tue, 11 Aug 2020 14:00:32 +0100 (BST) Received: from [106.109.129.29] (unknown [106.109.129.29]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200811130031eusmtip1de4ac980650bd0c2e220883faec24d52~qODg5FWlM0961509615eusmtip14; Tue, 11 Aug 2020 13:00:31 +0000 (GMT) To: =?UTF-8?Q?Ga=c3=abtan_Rivet?= Cc: dev@dpdk.org, thomas@monjalon.net, ferruh.yigit@intel.com, stephen@networkplumber.org, =?UTF-8?Q?Morten_Br=c3=b8rup?= From: Ivan Dyukov Message-ID: Date: Tue, 11 Aug 2020 16:00:31 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200811125311.x6aqxraobb42tcib@u256.net> Content-Transfer-Encoding: 8bit Content-Language: ru-RU X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrFKsWRmVeSWpSXmKPExsWy7djPc7oF04ziDbZdNbB492k7k8WdvafZ LfZfOs5m0ffrKqPF4jtyFp8enGBxYPP4tWApq8fiPS+ZPI7dn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YNS8EW6Yqft9IaGDtEuhg5OSQETCTe/Gxn6WLk4hASWMoocWrFLqYuRg6ghITE6yfMEDXC En+udbFB1LxllPiyahUbSI2wQITEmW2uIDUiAkYSt7/9YgSpYRaYwShx8Nt0doiGP0wSuz/f ZAWpYhPQkDjdMY8JxOYVsJM4P3cCO4jNIqAq8f3ydzBbFGjo54NH2CBqBCVOznzCAmJzCphL LF2xCsxmFjCTmLf5ITOELS/RvHU2lC0u8WH7QbYJjEKzkLTPQtIyC0nLLCQtCxhZVjGKpJYW 56bnFhvqFSfmFpfmpesl5+duYgTG3LZjPzfvYLy0MfgQowAHoxIP74KJRvFCrIllxZW5hxgl OJiVRHidzp6OE+JNSaysSi3Kjy8qzUktPsRoCvTcRGYp0eR8YDrIK4k3NDU0t7A0NDc2Nzaz UBLn7RA4GCMkkJ5YkpqdmlqQWgTTx8TBKdXA2MU1qb91V/NTW/1s7R8r2sJ1LR65hczcJ8fx cIL4blGTaI1tLW5Fx0NuJQREtszYPmG6jMy75xskd5RuWv3gz88a+8IwrQkXts6xcYrtFWQ6 v/ve56j9ZpZhJzOk8kQmC67uv5DSXlNnKMPZV+dXsdXIJ3qFdinj/A9H5i7xfbllw4v4hHmL lViKMxINtZiLihMB0ADIQs8CAAA= X-CMS-MailID: 20200811130032eucas1p1158393590e18a9ad18427e71b5412e61 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200811085304eucas1p150bf23b6f183a28fbceca06b0bced5af X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200811085304eucas1p150bf23b6f183a28fbceca06b0bced5af References: <20200427095737.11082-1-i.dyukov@samsung.com> <20200811085246.28735-1-i.dyukov@samsung.com> <20200811085246.28735-3-i.dyukov@samsung.com> <20200811110241.tfucvkcgn7yhlvoo@u256.net> <60cb10d2-a8e9-d4ac-b0d6-ab9c26970990@samsung.com> <20200811125311.x6aqxraobb42tcib@u256.net> Subject: Re: [dpdk-dev] [PATCH v9 02/24] ethdev: add a link status text representation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 11.08.2020 15:53, Gaëtan Rivet пишет: > On 11/08/20 15:48 +0300, Ivan Dyukov wrote: >> 11.08.2020 14:02, Gaëtan Rivet пишет: >>> On 11/08/20 11:52 +0300, Ivan Dyukov wrote: >>>> Link status structure keeps complicated values which are hard to >>>> represent to end user. e.g. link_speed has INT_MAX value which >>>> means that speed is unknown, link_duplex equal to 0 means >>>> 'half-duplex' etc. To simplify processing of the values >>>> in application, new dpdk function is introduced. >>>> >>>> This commit adds function which treat link status structure >>>> and format it to text representation. User may create custom >>>> link status string using format string. If format string is NULL, >>>> the function construct standard link status string. >>>> >>>> Signed-off-by: Ivan Dyukov >>> Hello Ivan, >>> >>> I don't see much difference for this patch, from what I read in previous >>> thread on the principle it does not seem motivated enough? >>> >>> I'd have a few nits on the implementation, but on the principle: I think >>> this can be an incentive to get properly formatted port status strings. >>> >>> The API is a little awkward however, and it is definitely complex to >>> maintain a format-based function. I think we could do without. >>> >>> I've tried a smaller alternative. >>> >>> + simpler to use. >>> + simpler to maintain. >>> + safer in general. >>> + no need to declare local string to store intermediate output. >>> >>> - one ugly macro. >> It would be good for all values except link_speed because link speed >> should be formated using sprintf e.g. >> >> char str[15]; >> >> ... >> >> char *rte_eth_link_speed_str(uint32_t link_speed) { >> >> if (link_speed == UINT32_MAX) >> >> return "Unknown"; >> >> else >> >> snprintf(str,sizeof(str),"%d",link_speed); >> >> return str; >> >> } >> >> so rte_eth_link_speed_str will require some global string, not local. > Sorry I don't understand your point, the implementation below works? Oh. Sorry I missed it. Thanks for clarification. It should work. Let's wait Thomas and Stephen comments. >>> +/** >>> + * Missing: doc. >>> + */ >>> +static inline const char * >>> +rte_eth_link_speed_str(uint32_t speed) >>> +{ >>> + struct { >>> + const char *str; >>> + uint32_t speed; >>> + } speed_str_map[] = { >>> + { "Unknown", ETH_SPEED_NUM_NONE }, >>> + { "10 Mbps", ETH_SPEED_NUM_10M }, >>> + { "100 Mbps", ETH_SPEED_NUM_100M }, >>> + { "1 Gbps", ETH_SPEED_NUM_1G }, >>> + { "2.5 Gbps", ETH_SPEED_NUM_2_5G }, >>> + { "5 Gbps", ETH_SPEED_NUM_5G }, >>> + { "10 Gbps", ETH_SPEED_NUM_10G }, >>> + { "20 Gbps", ETH_SPEED_NUM_20G }, >>> + { "25 Gbps", ETH_SPEED_NUM_25G }, >>> + { "40 Gbps", ETH_SPEED_NUM_40G }, >>> + { "50 Gbps", ETH_SPEED_NUM_50G }, >>> + { "56 Gbps", ETH_SPEED_NUM_56G }, >>> + { "100 Gbps", ETH_SPEED_NUM_100G }, >>> + { "200 Gbps", ETH_SPEED_NUM_200G }, >>> + }; >>> + size_t i; >>> + >>> + for (i = 0; i < RTE_DIM(speed_str_map); i++) { >>> + if (speed == speed_str_map[i].speed) >>> + return speed_str_map[i].str; >>> + } >>> + >>> + return speed_str_map[0].str; >>> +}