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 8423FA0526; Fri, 10 Jul 2020 09:03:10 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 39B831DB93; Fri, 10 Jul 2020 09:02:48 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 222F51DB90 for ; Fri, 10 Jul 2020 09:02:46 +0200 (CEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20200710070245euoutp011a457295bd9c72a99c7d2904b55c0063~gUiAWULnE2059620596euoutp01M; Fri, 10 Jul 2020 07:02:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20200710070245euoutp011a457295bd9c72a99c7d2904b55c0063~gUiAWULnE2059620596euoutp01M DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1594364565; bh=xmD2mOfSPYEySXTKCkIqMp30Ohht0MjEUFipNVMWweQ=; h=From:To:Subject:Date:In-Reply-To:Reply-To:References:From; b=l8WdLhc7Ou68f+sXo077AVLzZCIkKZRY0RyPAyukERaelTlM7MiTiZ7gRce8AdOzK TkSKNkM/xsu5PXwRfXkqrDEE+r8Q0EYWPD5h9nFTEoyIWvVbM7aH2KEg4L3qcRlfBH IiUjzlBNyNYMHuwAypV57m2AUTiPaUpTTNc8QWvw= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20200710070245eucas1p1176823fa684f17a1361a4f0c8762ff14~gUiABolML1572415724eucas1p1-; Fri, 10 Jul 2020 07:02:45 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 1E.21.06318.592180F5; Fri, 10 Jul 2020 08:02:45 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20200710070245eucas1p1f291014b205a97bf72822e820d7b2c8c~gUh-qZ7xY2360623606eucas1p1M; Fri, 10 Jul 2020 07:02:45 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200710070245eusmtrp29540ec3263421678aed6f8f4004e21c6~gUh-pmqp-2959329593eusmtrp2r; Fri, 10 Jul 2020 07:02:45 +0000 (GMT) X-AuditID: cbfec7f5-38bff700000018ae-78-5f081295af71 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id C8.74.06314.492180F5; Fri, 10 Jul 2020 08:02:44 +0100 (BST) Received: from idyukov.rnd.samsung.ru (unknown [106.109.129.29]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200710070243eusmtip1b79b292a939683a3e6230d8c341f3999~gUh91lb3k1340413404eusmtip1w; Fri, 10 Jul 2020 07:02:43 +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:01 +0300 Message-Id: <20200710070226.6045-4-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: H4sIAAAAAAAAA0WSfUwTdxjH89xd747OLkcx8dERzBqJc3HF+ZI8JETcsmX3zzKzOBOXTOz0 hkaopLVqmX8gEwZV2SjMKZqCZYoUDUPOFkw1rIkgFmH4RhtfxhwbQSZVlDEczFEOs/8+v+/L 8zx//ETWWM4vELdZdyo2qyXHxOs5f/tEz1vfGcWsZTeGk6mxywP04H4tS/2V93g68Hg/QxFf JgUDx3Xk/qWAoTL3E4YCp108/dlfyNHIaIChuxfDAlVdLxRoNDQo0KGeY0CDkw9ZOlrzFKjH c15HEz9d4Ck26eWo7PktoG/UK0AdB59wVNnaAlTskuhxfZ1AtXdTaLT/CkfhaLNAZ8Z6WTrf NQVU3tEIdK34hW7N6/LzmpM6uTY4xMgVJ3pZuT16WJAPdnoYuWmkhZFjl27xcpnqA/nqgwOs 3DDwN79W/6k+Y4uSs22XYktbvUm/tfnyMJtXad4zFKmHAvhrkQsSRJRWYkl7WHCBXjRKpwGD pQNc3DBKzwD3jy/V+ClghXvNy8LRI+2zhTrAiLcVtMcYYMz/uy6e4qU3MFziYeLGXKmJx8Bk HxM3kqTVWNVSKMSZk1Kxs8I9oxskwvI/VEZbsRAbfmxj45wgpWORyytoZ6RgX/WzmaEodYlY H5nQaYX38MadQ6zGSfiwQxU0TsYXrdWzQ7/E8XN9glYuAbzvLZoNZaI63D3NoshKS7DxQpom v4PHPOMzMkqvYuRRYlxmp9Ht/57VZAOWFBu1tAnbOq/PyohT/8zRUMbGarN2fBBQPfPxt7Cw 6v9NNQA+mKc47LnZin2FVdlttlty7Q5rtnnzjtxzMP1Rw/92jLXApcnPQyCJYJpj2DTFZxl1 ll12Z24IUGRNcw3vXgtvNBq2WJz5im1Hls2Ro9hD8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FxRutYpIoHhAt/+sI1kOdiqz5jVNJA6+DPK+OLvb3OdpbcPHB dGLwC9+PPVtv6aO6Vcf7FmV4qR+FNf/y828+JKNtAdXrSPWW/IA1U9ExP8bNgQWV5+UPhjur koqns2odq1882fKLmeq6T1mGK9I7R3S2Ip+dK/aywuehY6UX4iKvV+xIDwxyTZyaWcvvL/Qd P6ahpAQjv5a0SMa/bSjZcQkDAAA= X-CMS-MailID: 20200710070245eucas1p1f291014b205a97bf72822e820d7b2c8c X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200710070245eucas1p1f291014b205a97bf72822e820d7b2c8c X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200710070245eucas1p1f291014b205a97bf72822e820d7b2c8c References: <20200427095737.11082-1-i.dyukov@samsung.com> <20200710070226.6045-1-i.dyukov@samsung.com> Subject: [dpdk-dev] [PATCH v7 03/25] app: UNKNOWN link speed 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 Signed-off-by: Ivan Dyukov --- app/proc-info/main.c | 9 +++------ app/test-pipeline/init.c | 11 +++++------ app/test-pmd/config.c | 20 ++++++++++++-------- app/test-pmd/testpmd.c | 9 +-------- app/test/test_pmd_perf.c | 17 +++++++---------- 5 files changed, 28 insertions(+), 38 deletions(-) diff --git a/app/proc-info/main.c b/app/proc-info/main.c index abeca4aab..4a4c572c3 100644 --- a/app/proc-info/main.c +++ b/app/proc-info/main.c @@ -685,12 +685,9 @@ show_port(void) printf("Link get failed (port %u): %s\n", i, rte_strerror(-ret)); } else { - printf("\t -- link speed %d duplex %d," - " auto neg %d status %d\n", - link.link_speed, - link.link_duplex, - link.link_autoneg, - link.link_status); + rte_eth_link_printf("\t -- link speed: %M, duplex: %D," + " auto neg: %A, status: %S\n", + &link); } printf("\t -- promiscuous (%d)\n", rte_eth_promiscuous_get(i)); diff --git a/app/test-pipeline/init.c b/app/test-pipeline/init.c index 67d54ae05..b59064672 100644 --- a/app/test-pipeline/init.c +++ b/app/test-pipeline/init.c @@ -155,7 +155,7 @@ static void app_ports_check_link(void) { uint32_t all_ports_up, i; - + char link_status_text[50]; all_ports_up = 1; for (i = 0; i < app.n_ports; i++) { @@ -173,12 +173,11 @@ app_ports_check_link(void) all_ports_up = 0; continue; } - - RTE_LOG(INFO, USER1, "Port %u (%u Gbps) %s\n", + rte_eth_link_strf(link_status_text, 50, "(%G Gbps) %S", + &link); + RTE_LOG(INFO, USER1, "Port %u %s\n", port, - link.link_speed / 1000, - link.link_status ? "UP" : "DOWN"); - + link_status_text); if (link.link_status == ETH_LINK_DOWN) all_ports_up = 0; } diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index a7112c998..cb2795a94 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -604,10 +604,9 @@ port_infos_display(portid_t port_id) } else printf("\nmemory allocation on the socket: %u",port->socket_id); - printf("\nLink status: %s\n", (link.link_status) ? ("up") : ("down")); - printf("Link speed: %u Mbps\n", (unsigned) link.link_speed); - printf("Link duplex: %s\n", (link.link_duplex == ETH_LINK_FULL_DUPLEX) ? - ("full-duplex") : ("half-duplex")); + rte_eth_link_printf("\nLink status: %S\n" + "Link speed: %M Mbps\n" + "Link duplex: %D\n", &link); if (!rte_eth_dev_get_mtu(port_id, &mtu)) printf("MTU: %u\n", mtu); @@ -730,6 +729,8 @@ port_summary_display(portid_t port_id) struct rte_eth_link link; struct rte_eth_dev_info dev_info; char name[RTE_ETH_NAME_MAX_LEN]; + char status_text[6]; + char speed_text[12]; int ret; if (port_id_is_invalid(port_id, ENABLED_WARN)) { @@ -750,12 +751,14 @@ port_summary_display(portid_t port_id) if (ret != 0) return; - printf("%-4d %02X:%02X:%02X:%02X:%02X:%02X %-12s %-14s %-8s %uMbps\n", + rte_eth_link_strf(status_text, 6, "%S", &link); + rte_eth_link_strf(speed_text, 12, "%M", &link); + printf("%-4d %02X:%02X:%02X:%02X:%02X:%02X %-12s %-14s %-8s %sMbps\n", port_id, mac_addr.addr_bytes[0], mac_addr.addr_bytes[1], mac_addr.addr_bytes[2], mac_addr.addr_bytes[3], mac_addr.addr_bytes[4], mac_addr.addr_bytes[5], name, - dev_info.driver_name, (link.link_status) ? ("up") : ("down"), - (unsigned int) link.link_speed); + dev_info.driver_name, status_text, + speed_text); } void @@ -3899,7 +3902,8 @@ set_queue_rate_limit(portid_t port_id, uint16_t queue_idx, uint16_t rate) ret = eth_link_get_nowait_print_err(port_id, &link); if (ret < 0) return 1; - if (rate > link.link_speed) { + if (link.link_speed != ETH_SPEED_NUM_UNKNOWN && + rate > link.link_speed) { printf("Invalid rate value:%u bigger than link speed: %u\n", rate, link.link_speed); return 1; diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 4989d22ca..a1b9c1c1c 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -3010,14 +3010,7 @@ 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_printf(NULL, &link); continue; } /* clear all_ports_up flag if any link down */ diff --git a/app/test/test_pmd_perf.c b/app/test/test_pmd_perf.c index 352cd4715..7ebe4efae 100644 --- a/app/test/test_pmd_perf.c +++ b/app/test/test_pmd_perf.c @@ -126,6 +126,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask) uint8_t count, all_ports_up, print_flag = 0; struct rte_eth_link link; int ret; + char link_status[50]; printf("Checking link statuses...\n"); fflush(stdout); @@ -146,16 +147,12 @@ 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")); - if (link_mbps == 0) - link_mbps = link.link_speed; - } else - printf("Port %d Link Down\n", portid); + if (link.link_status && link_mbps == 0) + link_mbps = link.link_speed; + + rte_eth_link_strf(link_status, 50, NULL, + &link); + printf("Port %d %s\n", portid, link_status); continue; } /* clear all_ports_up flag if any link down */ -- 2.17.1