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 74A1AA00C5; Mon, 6 Jul 2020 22:28:03 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D98AD1DCB7; Mon, 6 Jul 2020 22:27:04 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 1EA331DCB7 for ; Mon, 6 Jul 2020 22:27:03 +0200 (CEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20200706202702euoutp01b9e52ad275f338a81d1afbb66cb052b1~fQ7GJqdYn2593425934euoutp01f; Mon, 6 Jul 2020 20:27:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20200706202702euoutp01b9e52ad275f338a81d1afbb66cb052b1~fQ7GJqdYn2593425934euoutp01f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1594067222; bh=fNqGGGujtZQoaCNUifIZpoVDm0FLT/KHJy8jVKrEsB4=; h=From:To:Subject:Date:In-Reply-To:Reply-To:References:From; b=kGoyOk9GV9E127XvmJLkUwee4qTHOINg4oUuXVlPa2howwp6PH4NvjRBKaWvs17A8 sTvPFAKgWl1Qr+4VnFWGFyO/QNAI7+OKONK8nIdmdPferbODFB9k8GR6Gvmi8qkXxa zpbCcTZNZvOxtScapGbm09wIj/4nkkIuFtxRvuYk= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20200706202701eucas1p2ab9b897f7381aff634f274917fa955cf~fQ7FS8P4T0115501155eucas1p2l; Mon, 6 Jul 2020 20:27:01 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id F3.96.06318.519830F5; Mon, 6 Jul 2020 21:27:01 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200706202701eucas1p2e1edbd116f7bb5b3cf3d9a5432ad6ff9~fQ7E9_glI2938529385eucas1p2B; Mon, 6 Jul 2020 20:27:01 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200706202701eusmtrp122f0a72dcdfd01de7001ee59747cd651~fQ7E9JtvN2178321783eusmtrp1p; Mon, 6 Jul 2020 20:27:01 +0000 (GMT) X-AuditID: cbfec7f5-371ff700000018ae-20-5f0389159ce7 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id C4.AF.06314.519830F5; Mon, 6 Jul 2020 21:27:01 +0100 (BST) Received: from idyukov.rnd.samsung.ru (unknown [106.109.129.29]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200706202659eusmtip1dfeddb4c84ceb9a5bbb7e07e5c9fa265~fQ7DI-dtC1560515605eusmtip1V; Mon, 6 Jul 2020 20:26:59 +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:25:58 +0300 Message-Id: <20200706202626.28628-9-i.dyukov@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200706202626.28628-1-i.dyukov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA0WSfUxTZxTG89739t5LtXhXMJzgIlvjkmkUXdTlaHQwQ5abxRgTncmWTCx6 +YgUSSvOj3/4smKpqMiccwtUmLGABEEEBCWFYIsWYWBMYQNpiIaAfAk0Gwi6lovZf7/zPM85 533fvALVFnDhQlLKcdmYok/WcWq21jnbuWHleRq7yTqEWNleSHDwRQlFb0E/h7mT2Qz2lEXh g7rfVZg/kM5gXv4bBuvsFg5HvZksjk/VMdj30M3j9e5MHqdahni80PkbwaH5EYq/2qYJdhbe U+FscwOHE/PFLObNPSd4saaNoMv6hsWC+/UEzRYRJ0tv8VjStxqnvG0sunvv8njb10XxXvsC wcuuSoJPze9V0Z9Kc7abKqnkwTAjXbnRRSVn71Vesj4uZKSq8XpGmmh6zkl5NWVEejKYS6Xy l/9ye9U/qHcckZOTTsjGjV8dUidmuwaZVNvOk++a/ybpJGeThQQJIG6B0qZxVYC1op1ARvZ+ C1H7eYbAeLmdKsU0gRdXq7kPHX/Yr/GKcYtAr6OKUQofgamMVzSQ4sTPwZ1TuGiEilUc1M17 mIARIkZDqbWKDTArfgZnJ58tskbcBoM+L1FWRED5HcfioCBxO7RO3OWUA64GT9HM4lAQ2wUw mytZpSEGRr0DjMIhMOKq4RX+GNxXrEuZM/BPtYdXmnP8Fyo+uxSKgprXHX4WBCquhcqGjYr8 Ndz+uZ8JyCAGQ8/YRwGZ+jG/9heqyBrIMWuVtA4cj7uXZICFt8sVWYKRS++XXvEhAYetl1wi Edf/32UjpIyEyWkmQ4Js2pwi/xRp0htMaSkJkYePGaqJ/6+637l89aRpPq6FiALRLdd4BRqr VelPmE4ZWggIVBeq2fXU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gmaeysy2JatYgWqU9kpQmWf7XEUxQWBbaF05W5c3cWJ4gvo1YRxaPbcyZ 632dJwYemPYWRMbGJ4w2jJSUerfw2bdd3i/KM6u0RXXzF/W16zl5c/egmfoWqYvxcPdu/jlQ XuAtt3X1Dfze7TwYkqgNrHnW0186d+cGvyHwduZmsIeu9TNpsS7Vo/VuW0b0wO/bz9Kqwn0f NJScLPJLSIss/gMi2+nyCQMAAA== X-CMS-MailID: 20200706202701eucas1p2e1edbd116f7bb5b3cf3d9a5432ad6ff9 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200706202701eucas1p2e1edbd116f7bb5b3cf3d9a5432ad6ff9 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200706202701eucas1p2e1edbd116f7bb5b3cf3d9a5432ad6ff9 References: <20200427095737.11082-1-i.dyukov@samsung.com> <20200706202626.28628-1-i.dyukov@samsung.com> Subject: [dpdk-dev] [PATCH v5 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