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 C2AD3A04AF; Tue, 11 Aug 2020 10:54:59 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0D0A41C113; Tue, 11 Aug 2020 10:53:17 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id E6A381C0DA for ; Tue, 11 Aug 2020 10:53:15 +0200 (CEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20200811085315euoutp015c4277bde14b2a2f605164f3c417bae2~qKrnixvZG0826508265euoutp01o; Tue, 11 Aug 2020 08:53:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20200811085315euoutp015c4277bde14b2a2f605164f3c417bae2~qKrnixvZG0826508265euoutp01o DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1597135995; bh=fgiYd6i2vA5tgF+67PLgyOKYf0isxQoJ4Cnk9IPoyJU=; h=From:To:Subject:Date:In-Reply-To:Reply-To:References:From; b=XpX0kr27uh49x9/7sgOr09QHNpLaTzZ8CizyT9AOgpEqnX0k/NLnYZIaVDmoSE9eX s/fpjEy7/59o4Vt6twpfFb2I1z+JD6JUM6kXriU8xnlSlQPuVOPScNurW2cxFyan2M 46NgWKxO9KpWXDSgTXT71v7k3QJsDlNnMlLwPUpM= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20200811085315eucas1p1fb5b7cd34dcce0b78be2e7edfe8d49b4~qKrnA3qEX2534225342eucas1p1A; Tue, 11 Aug 2020 08:53:15 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 2B.1C.05997.B7C523F5; Tue, 11 Aug 2020 09:53:15 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200811085314eucas1p267b60944d8b8b480521723275cd99415~qKrmfLl-S0122701227eucas1p2v; Tue, 11 Aug 2020 08:53:14 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200811085314eusmtrp1c157a4bab8c023773050c2b7c22d0076~qKrmePZUl1606216062eusmtrp1R; Tue, 11 Aug 2020 08:53:14 +0000 (GMT) X-AuditID: cbfec7f4-677ff7000000176d-ab-5f325c7bfdce Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id AA.4D.06017.A7C523F5; Tue, 11 Aug 2020 09:53:14 +0100 (BST) Received: from idyukov.rnd.samsung.ru (unknown [106.109.129.29]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200811085312eusmtip1ab70307f21661feaafc51c2d9a1d28c8~qKrkpCqfg1725317253eusmtip1i; Tue, 11 Aug 2020 08:53:12 +0000 (GMT) From: Ivan Dyukov To: dev@dpdk.org, i.dyukov@samsung.com, v.kuramshin@samsung.com, thomas@monjalon.net, david.marchand@redhat.com, ferruh.yigit@intel.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 Date: Tue, 11 Aug 2020 11:52:26 +0300 Message-Id: <20200811085246.28735-8-i.dyukov@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200811085246.28735-1-i.dyukov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA0WSfUxTZxTGc+43jZ131cQTZ2TULNtMlIEmO/sSXTZzl+hmsn8Wsw27eQdO qKQFNlmygRAkBZlQp9K6ijK/AFNBviRIAJ0XLMI0c7SLCiFmCCoi0KisiNxdzP77ned5zntO Tl6JtfwiLJa22dNVh92WYhVMXMOlJz0rfvg8PvGNCz0s+bt9QIO3Klga2HdToMKxPIaClQnU 0niIp9L+bIaKSx8y1HjSJdC9gV0cjY43MnTjfEAkz7VdIo13DIm0p9cLNBQZYamsfAKo11fP 05P2ZoEeRI5yVDx1Hejnuk4greghR/vONQHlu2QaO3VCpIobS2l8oJOjQOisSNXhqyzVd08D lWh+oCv5M/zaGGWq/BivVLQMM4r7yFVWuRTaLypFXT5GqRltYpQHrdcFpbiuEpTLg4WsUnX7 sbDJtNn07lY1ZVum6ohds8WUnFf9N5c2mPB9XpdfzIZf410QJaG8GkuqfuN0tsgnAUcKWBeY ZnkS8EB2A2cUE4BFo2Xc846yYfdc6gTgQX89GEUYMHL5d15PCfJrGCjwMbqxUK4RsDHSx+jG AnktuqeCos6c/AoOB0Ogs1l+C4/neHhjRDRWnWljdY6S38Yqbz9rLLgU+w5P/vcoyn9IeGbG M7fTB1h60C0YvABHtDrR4CUYcBdxRsNuwJKGs6JR7AXM9d6fSyVg3d2eWZYkVn4d/c2xhrwO zz16yusyyi9g8P6LuszOYmnDAdaQzViQbzHSVmzrujYnI07/O8+QFTzSWi0aBzoP6O11MXsh 2vP/rHKASlikZjhTk1RnvF39bqXTlurMsCet/HpHai3MftbAU22yCZojX3WALIF1njntnbhE C2/LdO5M7QCUWOtC8/tXAl9azFttO7NUx45ER0aK6uyAlyTOus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EaybVxoK4G0NXO5y7TWfiaUfojfL t5w36Zzl62LjQlozfrCzKw3RTXtOMYqrzSeLW0rqtYGzoo9UrC1vDyrrStiUrfV+4T2+KCvy u6xzl2Gfx6H1a3g/ZZ3v8btEr8fi3XkZUTvttsq2j8qOjWtJ5cWnmY8MF53g077ksPEogcIj fBsnV6koKV7PLyPNkv4f32WPugkDAAA= X-CMS-MailID: 20200811085314eucas1p267b60944d8b8b480521723275cd99415 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200811085314eucas1p267b60944d8b8b480521723275cd99415 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200811085314eucas1p267b60944d8b8b480521723275cd99415 References: <20200427095737.11082-1-i.dyukov@samsung.com> <20200811085246.28735-1-i.dyukov@samsung.com> Subject: [dpdk-dev] [PATCH v9 07/24] examples: new link status print format X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: i.dyukov@samsung.com List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add usage of rte_eth_link_to_str function to example applications: * ipv4_multicast * l2fwd-jobstats * l2fwd-keepalive * l3fwd * link_status_interrupt Signed-off-by: Ivan Dyukov --- examples/ipv4_multicast/main.c | 14 ++++++------ examples/l2fwd-jobstats/main.c | 13 +++++------ examples/l2fwd-keepalive/main.c | 13 +++++------ examples/l3fwd/main.c | 13 +++++------ examples/link_status_interrupt/main.c | 31 +++++++++++---------------- 5 files changed, 34 insertions(+), 50 deletions(-) diff --git a/examples/ipv4_multicast/main.c b/examples/ipv4_multicast/main.c index 7e255c35a..92bc13047 100644 --- a/examples/ipv4_multicast/main.c +++ b/examples/ipv4_multicast/main.c @@ -572,6 +572,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[ETH_LINK_MAX_STR_LEN]; printf("\nChecking link status"); fflush(stdout); @@ -591,14 +592,11 @@ 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 %u Mbps - %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), NULL, + &link); + printf("Port %d %s\n", portid, + link_status_text); continue; } /* clear all_ports_up flag if any link down */ diff --git a/examples/l2fwd-jobstats/main.c b/examples/l2fwd-jobstats/main.c index 47a3b0976..62ff2d9d5 100644 --- a/examples/l2fwd-jobstats/main.c +++ b/examples/l2fwd-jobstats/main.c @@ -689,6 +689,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[ETH_LINK_MAX_STR_LEN]; printf("\nChecking link status"); fflush(stdout); @@ -708,14 +709,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 %u Mbps - %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), NULL, &link); + printf("Port %d %s\n", portid, + link_status_text); continue; } /* clear all_ports_up flag if any link down */ diff --git a/examples/l2fwd-keepalive/main.c b/examples/l2fwd-keepalive/main.c index b2742633b..cf4db2820 100644 --- a/examples/l2fwd-keepalive/main.c +++ b/examples/l2fwd-keepalive/main.c @@ -453,6 +453,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[ETH_LINK_MAX_STR_LEN]; printf("\nChecking link status"); fflush(stdout); @@ -472,14 +473,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 %u Mbps - %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), NULL, &link); + printf("Port %d %s\n", portid, + link_status_text); continue; } /* clear all_ports_up flag if any link down */ diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c index 24ede4290..0e3b75c97 100644 --- a/examples/l3fwd/main.c +++ b/examples/l3fwd/main.c @@ -810,6 +810,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[ETH_LINK_MAX_STR_LEN]; printf("\nChecking link status"); fflush(stdout); @@ -833,14 +834,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 %u Mbps -%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), NULL, &link); + printf("Port %d %s\n", portid, + link_status_text); continue; } /* clear all_ports_up flag if any link down */ diff --git a/examples/link_status_interrupt/main.c b/examples/link_status_interrupt/main.c index 9bbcadfcf..3dcef4921 100644 --- a/examples/link_status_interrupt/main.c +++ b/examples/link_status_interrupt/main.c @@ -118,6 +118,7 @@ print_stats(void) const char clr[] = { 27, '[', '2', 'J', '\0' }; const char topLeft[] = { 27, '[', '1', ';', '1', 'H','\0' }; int link_get_err; + char link_speed_text[16]; /* Clear screen and move to top left */ printf("%s%s", clr, topLeft); @@ -131,9 +132,10 @@ print_stats(void) memset(&link, 0, sizeof(link)); link_get_err = rte_eth_link_get_nowait(portid, &link); + rte_eth_link_to_str(link_speed_text, 16, "%M", &link); printf("\nStatistics for port %u ------------------------------" "\nLink status: %25s" - "\nLink speed: %26u" + "\nLink speed: %26s" "\nLink duplex: %25s" "\nPackets sent: %24"PRIu64 "\nPackets received: %20"PRIu64 @@ -141,8 +143,7 @@ print_stats(void) portid, link_get_err < 0 ? "Link get failed" : (link.link_status ? "Link up" : "Link down"), - link_get_err < 0 ? 0 : - (unsigned int)link.link_speed, + link_get_err < 0 ? "0" : link_speed_text, link_get_err < 0 ? "Link get failed" : (link.link_duplex == ETH_LINK_FULL_DUPLEX ? \ "full-duplex" : "half-duplex"), @@ -445,6 +446,7 @@ lsi_event_callback(uint16_t port_id, enum rte_eth_event_type type, void *param, { struct rte_eth_link link; int ret; + char link_status_text[ETH_LINK_MAX_STR_LEN]; RTE_SET_USED(param); RTE_SET_USED(ret_param); @@ -457,13 +459,9 @@ lsi_event_callback(uint16_t port_id, enum rte_eth_event_type type, void *param, port_id, rte_strerror(-ret)); return ret; } - if (link.link_status) { - printf("Port %d Link Up - speed %u Mbps - %s\n\n", - port_id, (unsigned)link.link_speed, - (link.link_duplex == ETH_LINK_FULL_DUPLEX) ? - ("full-duplex") : ("half-duplex")); - } else - printf("Port %d Link Down\n\n", port_id); + rte_eth_link_to_str(link_status_text, sizeof(link_status_text), + NULL, &link); + printf("Port %d %s\n\n", port_id, link_status_text); return 0; } @@ -478,6 +476,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask) uint16_t portid; struct rte_eth_link link; int ret; + char link_status_text[ETH_LINK_MAX_STR_LEN]; printf("\nChecking link status"); fflush(stdout); @@ -497,14 +496,10 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask) } /* print link status if flag set */ if (print_flag == 1) { - if (link.link_status) - printf( - "Port%d Link Up. Speed %u Mbps - %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), NULL, &link); + printf("Port %d %s", portid, + link_status_text); continue; } /* clear all_ports_up flag if any link down */ -- 2.17.1