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 A2F98A0526; Fri, 10 Jul 2020 09:04:14 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 570601DCA0; Fri, 10 Jul 2020 09:03:01 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 6C1EC1DC77 for ; Fri, 10 Jul 2020 09:02:59 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20200710070259euoutp01c017097eb42bc92fe50c8a74828bfd0d~gUiMw2q3a2059620596euoutp01S; Fri, 10 Jul 2020 07:02:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20200710070259euoutp01c017097eb42bc92fe50c8a74828bfd0d~gUiMw2q3a2059620596euoutp01S DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1594364579; bh=fNqGGGujtZQoaCNUifIZpoVDm0FLT/KHJy8jVKrEsB4=; h=From:To:Subject:Date:In-Reply-To:Reply-To:References:From; b=bkuDHHIE8RDwXH7Tr9f7Tk/+TplmrNl1sBIBSBMW4IuXjm75ymGkGGCbQ4oP/MTtc ztAcmE2/h2+8PVSn328RUsauEHqe9l5C9bI6wFhQPAiFy88/QnVnQy9LSQ3ttjJi3k RX2fKuxXyt4n4GlnFwWznWubpQW9ac3KH0T1pWk8= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20200710070258eucas1p1b7e6b8dd126dfd6c01dd5d20c187907f~gUiMdJ-Wz1630516305eucas1p1C; Fri, 10 Jul 2020 07:02:58 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id A8.38.05997.2A2180F5; Fri, 10 Jul 2020 08:02:58 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200710070258eucas1p2a648deb28145bf9041f6b1d6b43f5412~gUiL3ArP52518925189eucas1p2B; Fri, 10 Jul 2020 07:02:58 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200710070258eusmtrp163a7b3e6162a1aaf5d02889752862c4f~gUiLrx5951176811768eusmtrp1E; Fri, 10 Jul 2020 07:02:58 +0000 (GMT) X-AuditID: cbfec7f4-65dff7000000176d-25-5f0812a28a69 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 16.04.06017.1A2180F5; Fri, 10 Jul 2020 08:02:57 +0100 (BST) Received: from idyukov.rnd.samsung.ru (unknown [106.109.129.29]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200710070256eusmtip1aff2fb83fbb560a2bcc940022f75408c~gUiJ7hFeF1465514655eusmtip1F; Fri, 10 Jul 2020 07:02:56 +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: Fri, 10 Jul 2020 10:02:06 +0300 Message-Id: <20200710070226.6045-9-i.dyukov@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200710070226.6045-1-i.dyukov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA0WSbUxbZRTHc+69vfdSV73rFjlBhazKIiYWpn44BpVhTLyLM/pNM3Wsuptu ERhpYXO+hSBg05WOlapxuq4Wt9UyZHQdIMEJ/UDBsheGCGQDSaMuvAiMFyejoJTL4rffc57f /5yTJ4/I6o/xKeL+wmLFUmjKN/Barqlz8fLjPr2Yl9VxzkgNPR6g2EgtS6PuYZ6OzJQzNBjI obbmrzXk+q2UIafrFkPNfjtPk6NlHE3NNjN048eoQMevlQk0G74pUNWVr4BuxsdZ+tI7B3TF c0FDix2tPE3HfRw57/QDHQ11AUUctzhy/9ACVGmXaOa7MwLV3kil2dEujqJD5wU6u9DL0oWe ZaBjkQagS5X/arZvke94T2nk2rYxRq75ppeVO4c+F2RHt4eRG6daGHn6Yj8vO0MBkH+OHWHl ut//4V/V7tI+s1fJ339QsWQ+t0e7rzwSY4q8z7630nEdSsGWZYckEaWncCY6JdhBK+olP2DY f5VVD/OA9d+PswlLL80BloW23E2sBM+vJ84AfloVZFRpAbArlJFgXnoUozYPk5A2S408NscH 1qRN0nb0XvRzCeakdAx0j66yKOokwusjW9UBaVh3rn1tcJL0NFbYfYLaPxUHTs6v9UTpqogn a8KcGngB63+t4lXehOORkKDygxitcaw7H+Dt4ICghm2AI76KdSkHQxOXhcQSrJSBDa2ZCUQp F8v6d6p4Lw7+tTEhs6voavqCVcs6tFXq1R4GbO++tl5GXF7aoJZlHHbEePWl2gA9nk+Eakg7 /v8oL0AAkpUSa4FZsT5RqBwyWk0F1pJCs/GdAwVBWP2o0ZXIfAu0xt8OgySCYYNuzzKfp9eY DloPF4QBRdawWff8pehuvW6v6fD7iuVAnqUkX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FgFXeLYoYo/Z8j2KDwbJRTuS1mMGTrmraUiuJCsjwm o27W5rWRWZE5LY2exvYDV6SuhMPOzs+1q5tSW12VUw5N3d21pzyx4s8q2mEejpK2aNMG5tb6 kg6GvcynGOFNVELMraIX7uj3M403axI38BFJZZsUj/zrw3MtzvZDRP9sS4y8Y8TktzZfSFoR wa/tV1OyycBHk5Js+AdjuHXICAMAAA== X-CMS-MailID: 20200710070258eucas1p2a648deb28145bf9041f6b1d6b43f5412 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200710070258eucas1p2a648deb28145bf9041f6b1d6b43f5412 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200710070258eucas1p2a648deb28145bf9041f6b1d6b43f5412 References: <20200427095737.11082-1-i.dyukov@samsung.com> <20200710070226.6045-1-i.dyukov@samsung.com> Subject: [dpdk-dev] [PATCH v7 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