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 791C1A04BA; Wed, 7 Oct 2020 17:30:35 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C3B7D1BCC5; Wed, 7 Oct 2020 17:30:33 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 00B4E1BCAA for ; Wed, 7 Oct 2020 17:30:30 +0200 (CEST) IronPort-SDR: z5ctT1yUBSInxqNG8fC0wWOuIPiKzXMt2GgaeD7nyZLi91HENE8LcrBOFAscxQwWFnGv8ywFvW Gfu1bGZrpYJg== X-IronPort-AV: E=McAfee;i="6000,8403,9767"; a="161587857" X-IronPort-AV: E=Sophos;i="5.77,347,1596524400"; d="scan'208";a="161587857" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Oct 2020 08:30:29 -0700 IronPort-SDR: bmVs1rmKvy71bQ0JBavkO0+U+XWAA2ArzDjalpjWQy1+SW6dFeeMLKkSb+EAMxErusS+ZPlV1n 87nFRevlHtbA== X-IronPort-AV: E=Sophos;i="5.77,347,1596524400"; d="scan'208";a="316256560" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.213.226.27]) ([10.213.226.27]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Oct 2020 08:30:27 -0700 To: Asaf Penso , Sarosh Arif Cc: "dev@dpdk.org" , NBU-Contact-Thomas Monjalon References: <20200904062339.77430-1-sarosh.arif@emumba.com> <20200928100121.3332768-1-sarosh.arif@emumba.com> From: Ferruh Yigit Message-ID: <27726e10-fd7d-afe6-4f7f-f5bf9c16985c@intel.com> Date: Wed, 7 Oct 2020 16:30:23 +0100 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH v2] testpmd: add speed capability in device info 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" On 10/4/2020 9:51 AM, Asaf Penso wrote: >> -----Original Message----- >> From: dev On Behalf Of Sarosh Arif >> Sent: Monday, September 28, 2020 1:01 PM >> To: ferruh.yigit@intel.com >> Cc: dev@dpdk.org; Sarosh Arif >> Subject: [dpdk-dev] [PATCH v2] testpmd: add speed capability in device info >> >> Called rte_eth_dev_info_get() in testpmd, to get device info so that speed >> capabilities can be printed under "show device info" >> ​ >> Bugzilla ID: 496 >> Signed-off-by: Sarosh Arif >> --- >> app/test-pmd/config.c | 38 ++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 38 insertions(+) >> >> diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index >> 30bee3324..e2b3975a3 100644 >> --- a/app/test-pmd/config.c >> +++ b/app/test-pmd/config.c >> @@ -518,7 +518,9 @@ device_infos_display(const char *identifier) >> struct rte_device *dev; >> struct rte_devargs da; >> portid_t port_id; >> + struct rte_eth_dev_info dev_info; >> char devstr[128]; >> + uint32_t speed_capa; >> >> memset(&da, 0, sizeof(da)); >> if (!identifier) >> @@ -569,6 +571,42 @@ device_infos_display(const char *identifier) >> &mac_addr); >> rte_eth_dev_get_name_by_port(port_id, >> name); >> printf("\n\tDevice name: %s", name); > > How about extracting the below to a dedicated helper function to make the code more readable? > Something like: void device_infos_display_speeds(uint32_t speed_capa) > >> + rte_eth_dev_info_get(port_id, &dev_info); >> + speed_capa = dev_info.speed_capa; >> + >> + printf("\n\tDevice speed capability:"); >> + if (speed_capa == >> ETH_LINK_SPEED_AUTONEG) >> + printf(" Autonegotiate (all speeds)"); >> + if (speed_capa & ETH_LINK_SPEED_FIXED) >> + printf(" Disable autonegotiate (fixed >> speed) "); >> + if (speed_capa & ETH_LINK_SPEED_10M_HD) >> + printf(" 10 Mbps half-duplex "); >> + if (speed_capa & ETH_LINK_SPEED_10M) >> + printf(" 10 Mbps full-duplex "); >> + if (speed_capa & ETH_LINK_SPEED_100M_HD) >> + printf(" 100 Mbps half-duplex "); >> + if (speed_capa & ETH_LINK_SPEED_100M) >> + printf(" 100 Mbps full-duplex "); >> + if (speed_capa & ETH_LINK_SPEED_1G) >> + printf(" 1 Gbps "); >> + if (speed_capa & ETH_LINK_SPEED_2_5G) >> + printf(" 2.5 Gbps "); >> + if (speed_capa & ETH_LINK_SPEED_5G) >> + printf(" 5 Gbps "); >> + if (speed_capa & ETH_LINK_SPEED_10G) >> + printf(" 10 Gbps "); >> + if (speed_capa & ETH_LINK_SPEED_20G) >> + printf(" 20 Gbps "); >> + if (speed_capa & ETH_LINK_SPEED_25G) >> + printf(" 25 Gbps "); >> + if (speed_capa & ETH_LINK_SPEED_50G) >> + printf(" 50 Gbps "); >> + if (speed_capa & ETH_LINK_SPEED_56G) >> + printf(" 56 Gbps "); >> + if (speed_capa & ETH_LINK_SPEED_100G) >> + printf(" 100 Gbps "); >> + if (speed_capa & ETH_LINK_SPEED_200G) >> + printf(" 200 Gbps "); >> printf("\n"); Some speeds are missing, please add all. And +1 to Asaf's comment to extract it into its own function. >> } >> } >> -- >> 2.25.1 > > I'm ok also to leave is as-is. > Reviewed-By: Asaf Penso >