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 6EF51A04C8; Fri, 18 Sep 2020 20:07:36 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A8E981DB11; Fri, 18 Sep 2020 20:07:35 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 001F61DB0F for ; Fri, 18 Sep 2020 20:07:33 +0200 (CEST) IronPort-SDR: LZY76KcaMpG0zTmPxKhlNZX7PRN5Mr/JLWGcO5fSneyJqYRnhh8OExb5e80dALJ4791Gqa5598 syYrjaoxKWaA== X-IronPort-AV: E=McAfee;i="6000,8403,9748"; a="159315781" X-IronPort-AV: E=Sophos;i="5.77,274,1596524400"; d="scan'208";a="159315781" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2020 11:07:33 -0700 IronPort-SDR: PAMn+nK9WYSRgKR4/qC54VaPS3HvdUk5zqqQ/jUHtBkh8Py22tjlKKl0c0N47kmQszsoePvO5X 6zH/WUXnsu/g== X-IronPort-AV: E=Sophos;i="5.77,274,1596524400"; d="scan'208";a="484303970" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.213.227.248]) ([10.213.227.248]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2020 11:07:26 -0700 To: i.dyukov@samsung.com, dev@dpdk.org, v.kuramshin@samsung.com, thomas@monjalon.net, david.marchand@redhat.com, arybchenko@solarflare.com, wei.zhao1@intel.com, jia.guo@intel.com, beilei.xing@intel.com, qiming.yang@intel.com, wenzhuo.lu@intel.com, mb@smartsharesystems.com, stephen@networkplumber.org, nicolas.chautru@intel.com, bruce.richardson@intel.com, konstantin.ananyev@intel.com, cristian.dumitrescu@intel.com, radu.nicolau@intel.com, akhil.goyal@nxp.com, declan.doherty@intel.com, skori@marvell.com, pbhagavatula@marvell.com, jerinj@marvell.com, kirankumark@marvell.com, david.hunt@intel.com, anatoly.burakov@intel.com, xiaoyun.li@intel.com, jingjing.wu@intel.com, john.mcnamara@intel.com, jasvinder.singh@intel.com, byron.marohn@intel.com, yipeng1.wang@intel.com References: <20200427095737.11082-1-i.dyukov@samsung.com> <20200915190728.18143-1-i.dyukov@samsung.com> <20200915190728.18143-14-i.dyukov@samsung.com> From: Ferruh Yigit Message-ID: Date: Fri, 18 Sep 2020 19:07:23 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.2.2 MIME-Version: 1.0 In-Reply-To: <20200915190728.18143-14-i.dyukov@samsung.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH v11 13/24] examples/kni: new link status print format 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 9/15/2020 8:07 PM, Ivan Dyukov wrote: > Add usage of rte_eth_link_to_str function to example > applications > > Signed-off-by: Ivan Dyukov > --- > examples/kni/main.c | 27 ++++++++++----------------- > 1 file changed, 10 insertions(+), 17 deletions(-) > > diff --git a/examples/kni/main.c b/examples/kni/main.c > index f5d12a5b8..49d888064 100644 > --- a/examples/kni/main.c > +++ b/examples/kni/main.c > @@ -661,6 +661,7 @@ check_all_ports_link_status(uint32_t port_mask) > uint8_t count, all_ports_up, print_flag = 0; > struct rte_eth_link link; > int ret; > + char link_status_text[RTE_ETH_LINK_MAX_STR_LEN]; > > printf("\nChecking link status\n"); > fflush(stdout); > @@ -680,14 +681,10 @@ check_all_ports_link_status(uint32_t port_mask) > } > /* print link status if flag set */ > if (print_flag == 1) { > - if (link.link_status) > - printf( > - "Port%d Link Up - speed %uMbps - %s\n", > - portid, link.link_speed, > - (link.link_duplex == ETH_LINK_FULL_DUPLEX) ? > - ("full-duplex") : ("half-duplex")); > - else > - printf("Port %d Link Down\n", portid); > + rte_eth_link_to_str(link_status_text, > + sizeof(link_status_text), &link); > + printf("Port %d %s\n", portid, > + link_status_text); > continue; > } > /* clear all_ports_up flag if any link down */ > @@ -717,19 +714,15 @@ check_all_ports_link_status(uint32_t port_mask) > static void > log_link_state(struct rte_kni *kni, int prev, struct rte_eth_link *link) > { > + char link_status_text[60]; '60' seems forgotten, it also can be replaced with 'RTE_ETH_LINK_MAX_STR_LEN' Also good to have an empty line between variables declarations and code. > if (kni == NULL || link == NULL) > return; > > - if (prev == ETH_LINK_DOWN && link->link_status == ETH_LINK_UP) { > - RTE_LOG(INFO, APP, "%s NIC Link is Up %d Mbps %s %s.\n", > + rte_eth_link_to_str(link_status_text, 60, NULL, link); > + if (prev != link->link_status) > + RTE_LOG(INFO, APP, "%s NIC %s", > rte_kni_get_name(kni), > - link->link_speed, > - link->link_autoneg ? "(AutoNeg)" : "(Fixed)", > - link->link_duplex ? "Full Duplex" : "Half Duplex"); > - } else if (prev == ETH_LINK_UP && link->link_status == ETH_LINK_DOWN) { > - RTE_LOG(INFO, APP, "%s NIC Link is Down.\n", > - rte_kni_get_name(kni)); > - } > + link_status_text); > } > > /* >