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 5B796A00C5; Mon, 6 Jul 2020 22:39:19 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 58B8C1DD71; Mon, 6 Jul 2020 22:38:15 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 448561DD70 for ; Mon, 6 Jul 2020 22:38:14 +0200 (CEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20200706203814euoutp01d7f3e96fd3be68cb9a6b7a2a516c9975~fRE3Mtix73113131131euoutp01W; Mon, 6 Jul 2020 20:38:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20200706203814euoutp01d7f3e96fd3be68cb9a6b7a2a516c9975~fRE3Mtix73113131131euoutp01W DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1594067894; bh=fNqGGGujtZQoaCNUifIZpoVDm0FLT/KHJy8jVKrEsB4=; h=From:To:Subject:Date:In-Reply-To:Reply-To:References:From; b=S4mk3ynTRAmW3nvFcHAGicDvez5pDUyBGRZaLoaFPUP1IEnQJgsRk4+5dbZuwfP7w eNImdooCSZSne9ua89ZHeFlS/G+v2xemd6JgVgUxix1tRLS9+HyMjnmOciL+vGepEQ 5ymzSyBss9pQ9TmaRcIo4Fyg66nkWkMktXOBIfZM= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20200706203813eucas1p1d70e92506c352a77373ec0fa27fad5bd~fRE3A_H_62654826548eucas1p11; Mon, 6 Jul 2020 20:38:13 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 1A.D4.06456.5BB830F5; Mon, 6 Jul 2020 21:38:13 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20200706203813eucas1p1fd1cf5ef5ae7ac290dcc2e4de11c6224~fRE2bmbmv2656026560eucas1p15; Mon, 6 Jul 2020 20:38:13 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200706203813eusmtrp27905e50db7bbc13e1fceef1ca6f215b8~fRE2axy120640206402eusmtrp2t; Mon, 6 Jul 2020 20:38:13 +0000 (GMT) X-AuditID: cbfec7f2-7efff70000001938-f9-5f038bb5ed9f Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 16.7E.06017.5BB830F5; Mon, 6 Jul 2020 21:38:13 +0100 (BST) Received: from idyukov.rnd.samsung.ru (unknown [106.109.129.29]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200706203811eusmtip16f809c480876bc91be86e59ca33e85f2~fRE0ru4ia1500415004eusmtip1y; Mon, 6 Jul 2020 20:38:11 +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: Mon, 6 Jul 2020 23:37:22 +0300 Message-Id: <20200706203743.29416-9-i.dyukov@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200706203743.29416-1-i.dyukov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA0VSbUwTWRT1zUxnhoaa2UL0BonGGtfVoMi6iddvNJpMopLV7A+XZMGqE1Sg uq3g12ZDELCCIgKKsmupbQxYdREBQYIGmkgrRbsSK6ioBLXEqghFgh+AUgbjv3PPOfee+24e T6sL2DB+h26PpNdpkzSskrnW9NE9tzqHjp/vuxyB5S0mgl1PrTR2Fj5hMac3g8J22wqsr/lX gfnP0ijMze+jsKYsm8U3nekM9vhrKOy44eKwuDWdQ7+9m8Nj7n8Idg/5aDxj7ifoNlUr8GNj HYvvhiwM5n7yEDxe5SToONrHYOH1WoJZ2QL2Xijl0NoxFf2dTgZdDys5vDRwj8bqlmGCJxzl BO9kfVFETxc/mc8rRGv9K0osOHePFpsenuLEo7dNlFjRU0uJ7256WDG3ykbE5q4cWrz44gP7 qzJWuXSblLQjVdJHLt+s3J7h6KJ2m5ftG2l8TNKIcX42CeJB+AWGbV4umyh5tVBG4EnpIC0X 7wmYL2Qo5KKfwGuvcVThx1rMzlSZLyWQ11U4bhog0F7aQwfmssJP4DKaqIAQKlSwUDPURgWE ECEa+vz1XAAzwkxwp5lJAKuERXCu1snKS02Di1caxtKChMVw9lZYgFYLU6Gt5P3YTBD+56Gp wKeQ/ashL7+VkXEI+BxVnIzD4cv1EkrGB2HwahsnNxsJPLVkjptWQNXru1wgjBZmQ3ldpEyv hNPP/Zz84onQ/vaHAE2PwvxrReOHUIExSy27NdBwu3WcBhj+HCzTIljdXkY+zw0Ch+6epfPI tOLvWWZCbGSylGJITpAMUTpp7zyDNtmQokuYt3VX8lUy+lVdIw5/LRlo3WInAk80wapOno5X K7Sphv3JdgI8rQlVrbrjilOrtmn3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gyJAamFb98jYRJ2JP8zzabzxv49gfOTZqDaAcl8eK4HFidPiXEnWD1GW X7M58PPG6u58HFv5ZLtcdvugzaOdLF1SX7Vq24dYV15kePmK3ibf1ml1rv3hvDjz1R7f4UUl N3rCDFzOsR4NGbFVvWJL2f1DRkvX6mtBGwODjg6kDS0IuGIbj0xhMo4v+ujcsdi8OU4ydObp ZPWwghKSdKo1pFHQ/QN+tFV9BgMAAA== X-CMS-MailID: 20200706203813eucas1p1fd1cf5ef5ae7ac290dcc2e4de11c6224 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200706203813eucas1p1fd1cf5ef5ae7ac290dcc2e4de11c6224 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200706203813eucas1p1fd1cf5ef5ae7ac290dcc2e4de11c6224 References: <20200427095737.11082-1-i.dyukov@samsung.com> <20200706203743.29416-1-i.dyukov@samsung.com> Subject: [dpdk-dev] [PATCH v6 08/25] 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_strf function to example applications: * ipv4_multicast * l2fwd-jobstats * l2fwd-keepalive * l3fwd * link_status_interrupt Signed-off-by: Ivan Dyukov --- examples/ipv4_multicast/main.c | 12 ++++------- examples/l2fwd-jobstats/main.c | 12 ++++------- examples/l2fwd-keepalive/main.c | 12 ++++------- examples/l3fwd/main.c | 12 ++++------- examples/link_status_interrupt/main.c | 30 +++++++++++---------------- 5 files changed, 28 insertions(+), 50 deletions(-) diff --git a/examples/ipv4_multicast/main.c b/examples/ipv4_multicast/main.c index 7e255c35a..0d4957658 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[60]; printf("\nChecking link status"); fflush(stdout); @@ -591,14 +592,9 @@ 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_strf(link_status_text, 60, NULL, + &link); + printf("Port %d %s", 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..740f1c80f 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[60]; printf("\nChecking link status"); fflush(stdout); @@ -708,14 +709,9 @@ 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_strf(link_status_text, 60, NULL, + &link); + printf("Port %d %s", 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..d8be0a727 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[60]; printf("\nChecking link status"); fflush(stdout); @@ -472,14 +473,9 @@ 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_strf(link_status_text, 60, NULL, + &link); + printf("Port %d %s", 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..ef0f19a39 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[60]; printf("\nChecking link status"); fflush(stdout); @@ -833,14 +834,9 @@ 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_strf(link_status_text, 60, NULL, + &link); + printf("Port %d %s", 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..5e286060d 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_strf(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[60]; RTE_SET_USED(param); RTE_SET_USED(ret_param); @@ -457,13 +459,8 @@ 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_strf(link_status_text, 60, NULL, &link); + printf("Port %d %s\n", port_id, link_status_text); return 0; } @@ -478,6 +475,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[60]; printf("\nChecking link status"); fflush(stdout); @@ -497,14 +495,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_strf(link_status_text, 60, NULL, + &link); + printf("Port %d %s", portid, + link_status_text); continue; } /* clear all_ports_up flag if any link down */ -- 2.17.1