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 E9443A00C5; Mon, 6 Jul 2020 22:27:12 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4A1491DC80; Mon, 6 Jul 2020 22:26:51 +0200 (CEST) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id AD94D1DC30 for ; Mon, 6 Jul 2020 22:26:49 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200706202649euoutp0293e42927a463f9315b3419a1100e3c03~fQ65iaPoV1760817608euoutp021; Mon, 6 Jul 2020 20:26:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200706202649euoutp0293e42927a463f9315b3419a1100e3c03~fQ65iaPoV1760817608euoutp021 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1594067209; bh=xmD2mOfSPYEySXTKCkIqMp30Ohht0MjEUFipNVMWweQ=; h=From:To:Subject:Date:In-Reply-To:Reply-To:References:From; b=vhgqpzoZvNsu+CnnonJof/duJ98+HYzl0uNP0XQOmx9T05fnRFg3Dykb28TxAXJN+ akFaH7nwfPkcOzOH750zO8XTpe2Qf3FcO0nHnCGXjCN3P7fp7rPECuTh+3jW/wB9Om n2QIOCb/iY+cHVyb30ZmZ8t8JaJS7FdSFnsGtMLA= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20200706202648eucas1p1442491ef0fcb4b06233029e4fecef5cc~fQ65BGOuG1288412884eucas1p1h; Mon, 6 Jul 2020 20:26:48 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id AC.89.05997.809830F5; Mon, 6 Jul 2020 21:26:48 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20200706202648eucas1p17baebff6b2420c5b1c9e53a5dd51998c~fQ64fWGyO1287412874eucas1p1l; Mon, 6 Jul 2020 20:26:48 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200706202648eusmtrp110ed84e8df31f80e1cbddcd265cd8783~fQ64eQjmE2178321783eusmtrp1k; Mon, 6 Jul 2020 20:26:48 +0000 (GMT) X-AuditID: cbfec7f4-65dff7000000176d-95-5f03890887b0 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 10.AF.06314.809830F5; Mon, 6 Jul 2020 21:26:48 +0100 (BST) Received: from idyukov.rnd.samsung.ru (unknown [106.109.129.29]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200706202646eusmtip15870affda4678ca6e50552535cabf46d~fQ62qQaWH1560515605eusmtip1T; Mon, 6 Jul 2020 20:26:46 +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:53 +0300 Message-Id: <20200706202626.28628-4-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: H4sIAAAAAAAAA0WSfUwTdxjH89xd747Gmlsh8YlbNGtm9hKBqTifmUWdW5bbyx9z2R/GBFmH NzQCsp64odlCGCtYATfEEWSp2GYTUMekhSKILwUtWIqR2YDGMeiMDFBQXpxi2Ua5mv33+X1f nueXX34iazzMLxZ3ZO5WLJnmdBOv5xovP+6OF/ezKa9O9S+nui47UKjfydJA2e88Hbifz1Bf 7Xo66/lRR6V/5DJUUvqAIU+1jae7A3kcjU14GLrV6hfoSE+eQBPeIYGKr1YCDYVHWKqomgS6 am/Q0eOLzTyNhx0clcwEgQ66O4B8RQ84KjvTBGS1SXS/5rhAzltLaGKggyP/DZdAJ6evsdTQ NQv0va8OKGD9V7fheXmm6ied7Dw7zMiHjl1j5cs3fhDkok47I58ea2Lk8XNBXi5x14J8JXSA lU/cfsR/qN+if2Obkr5jj2JJXPeJfrvr0iibVZbw5XBfDeTCwxdsECOilISjoUrGBnrRKFUD /nXwMKcdpgBdt71RZxLwidspPK38Eu6Jpo4D3ryTH01NA5ZXWCGS4qWX0F9onzfipNM8esK9 TMSIldZh+ahjnjlpGRbf9c2PNUivY32LH7QVS/HErxfYCMdIa7F93MVH2Cgtwd6jU/NDUeoS 8efrAV4rvI22/fZoORZHfO7oXZ9D/6EiTuN9+Hd9r6CVCwH7Hd9GQ+vRPdo9x6LISi9jXXOi Jr+JwWonE5FRWoh9956JyOwcljaWs5pswEKrUUub8EJnT1RGnH2yQJNlLBloi75PK2B7S4Hu O1h65P9dVQC1sEjJVjPSFHVlpvJFgmrOULMz0xJSd2XUw9xn9f/jm2qC5vCnXpBEMC0wFPJs ilFn3qPmZHgBRdYUZ9gY8G81GraZc/Yqll0plux0RfXCsyJnWm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kx8Vwuv97hMjOJREtT3DtUgRdt3aG1PJD5ojb9+yW GWc1Y4XtTfr3e+OfHrLm7J9uyI932JcVyj7rtxrWhLmkzQxExcWCW33xrcnSCu23nvVBSLX9 jNWxwRqUrTKayxRfnQKd9py3NzsEwdeEpGRJCHP4TuCslg+Ii4xOntjlGMweCG4513Fq7bUj UoqPUsrdSB2v/AeKgybBCAMAAA== X-CMS-MailID: 20200706202648eucas1p17baebff6b2420c5b1c9e53a5dd51998c X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200706202648eucas1p17baebff6b2420c5b1c9e53a5dd51998c X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200706202648eucas1p17baebff6b2420c5b1c9e53a5dd51998c References: <20200427095737.11082-1-i.dyukov@samsung.com> <20200706202626.28628-1-i.dyukov@samsung.com> Subject: [dpdk-dev] [PATCH v5 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