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 4C76AA0528; Sat, 11 Jul 2020 12:44:58 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AB9D81D9B7; Sat, 11 Jul 2020 12:44:36 +0200 (CEST) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id 1B02B1D9AC for ; Sat, 11 Jul 2020 12:44:35 +0200 (CEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200711104434euoutp02afe1f7e92785cdf0af1d187675ea0ab5~grM9mb8_K2273222732euoutp02q; Sat, 11 Jul 2020 10:44:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200711104434euoutp02afe1f7e92785cdf0af1d187675ea0ab5~grM9mb8_K2273222732euoutp02q DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1594464274; bh=RFy0yPNPCG/l5HzYILZl0igxrZPOmUjRrnAYrQUbFJM=; h=From:To:Subject:Date:In-Reply-To:Reply-To:References:From; b=Ih9q8fZKLqREkD1VvfKoq8sXLHJFumQmnvViMEtHEwCND7Nr5hKTRANogouGMXqgV 0Xr7GpYqi+MxjlE8+QarCsXFzcsxmAgZT+kUh+7f2q2QaWVT/r+asyErhPvQh5Mret iz3hcTTFNV3+bviCe795Ib2lJ4zUPPv1VsCdcDJM= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20200711104433eucas1p256e48d9023764f9eb1c0a6b31fa54c1e~grM8tAVoR2332923329eucas1p2S; Sat, 11 Jul 2020 10:44:33 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id DD.77.06318.118990F5; Sat, 11 Jul 2020 11:44:33 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20200711104433eucas1p1dab66feada324094b4e223d57e66594f~grM755Uum1558215582eucas1p1f; Sat, 11 Jul 2020 10:44:33 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200711104433eusmtrp13a5c6c5dec6802abf91539f793d75deb~grM748mjD2954729547eusmtrp12; Sat, 11 Jul 2020 10:44:33 +0000 (GMT) X-AuditID: cbfec7f5-38bff700000018ae-3d-5f0998119466 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 7F.76.06017.018990F5; Sat, 11 Jul 2020 11:44:32 +0100 (BST) Received: from idyukov.rnd.samsung.ru (unknown [106.109.129.29]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200711104431eusmtip1f05ba0e4e7ef9065ad5c6cff90a99ee5~grM6JFali1304313043eusmtip1g; Sat, 11 Jul 2020 10:44:31 +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: Sat, 11 Jul 2020 13:43:50 +0300 Message-Id: <20200711104414.15422-4-i.dyukov@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200711104414.15422-1-i.dyukov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA0WSfUxTZxTGc+5XL9WSSzHxxBmIzbYwo7DNZR4XM9xYlhuXRf42Kla9ASOt plf83DIUQVZYHYVg1a0ghKBghjCkyIAxzFqwfEnCgKlIDLPRjQ8pOFGQUS5m/z3v73nO+5y8 eUXWWCCsEvdbDys2qznVJOi5Ou9M1/oIV1jSu6N336eqDjfQw6FSloYL7guUM3GGoYGKeGr0 /MCT80E6Qw7nU4Y8V+wC/TN8mqOxSQ9D95r8OrrYe1pHk60BHX3XfQkoMPuEpQvFQaBu9w2e Zn5rEGh8toQjx4s+oHO1bUC+3KccFdysB8qySzRxtVxHpfeiaHK4jSP/4M86ujZ9h6UbHXNA eb4qoM6seX7LGvlFcRkvlzY+ZuT8y3dY2TtYqJNz292MXD1Wz8jjzX2C7KitAPn2wxxWrhx5 LiTqt+s371NS9x9RbHEf79anODqCcKh707HLjQNMOgTW2SFMROkDPOXM4e2gF43SFcDBjiYu ZBilKcCiX77UjCDgSLqXfz3xKFAmaEY54OitXE47TAPam89BKCVIMejPdjMhY4VULaBntp8J GZHSRpy+2bioOektfDbVtdhnkDah98KPoFVEY+X1Fjakw6SPcG68h9V2isL+oqnFS1HqETHP e2pp4DO8VVjOaToSn/hqdZpejf783CV+Ev+t6ddpw9mAQyWZS6F4rP27a0GLIiu9g1UNcRr+ BM+PFEAIoxSOA6MRIcwuSGfdeVbDBszOMmppE7a09y5hxLmXyzUsY1l7Hmjv0wTY+8e33PcQ ffH/rmKAClippKmWZEXdYFWOxqpmi5pmTY7de9BSAwt/1f/KN10PzbN7WkESwbTcUGwWk4y8 +Yh63NIKKLKmFYZPO/27jIZ95uMnFNvBJFtaqqK2whsiZ1pp2FD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QzT87yMYD98c1FVXGrHdvTYn1RWWJaiGAqL6 Pj9/G98UdqBnNmbluk5n9ON6y0Tlar/DV/Nzx19Yy6sjp23G6o1bTf5lr8Ob8dWLNs+H8XH8 8oPckUiOKrZ1+/XeruryNlYfWvVuptC1XxMz6Q7en3GlqjtuLik7NqJ/k0+0M+/abPT6wDWh xyIrVJSUIqi3kQZJ+AuFx+gNCQMAAA== X-CMS-MailID: 20200711104433eucas1p1dab66feada324094b4e223d57e66594f X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200711104433eucas1p1dab66feada324094b4e223d57e66594f X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200711104433eucas1p1dab66feada324094b4e223d57e66594f References: <20200427095737.11082-1-i.dyukov@samsung.com> <20200711104414.15422-1-i.dyukov@samsung.com> Subject: [dpdk-dev] [PATCH v8 03/24] app: UNKNOWN link speed print 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_to_str function to example applications and docs 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 +++++++--------- doc/guides/sample_app_ug/link_status_intr.rst | 10 +++++----- 6 files changed, 33 insertions(+), 43 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..7abc62544 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_to_str(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..7ee8c4c4d 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_to_str(status_text, 6, "%S", &link); + rte_eth_link_to_str(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..892fb419d 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_to_str(link_status, 50, NULL, + &link); + printf("Port %d %s\n", portid, link_status); continue; } /* clear all_ports_up flag if any link down */ diff --git a/doc/guides/sample_app_ug/link_status_intr.rst b/doc/guides/sample_app_ug/link_status_intr.rst index 04c40f285..11733ded1 100644 --- a/doc/guides/sample_app_ug/link_status_intr.rst +++ b/doc/guides/sample_app_ug/link_status_intr.rst @@ -158,6 +158,7 @@ An example callback function that has been written as indicated below. { struct rte_eth_link link; int ret; + char link_status[200]; RTE_SET_USED(param); @@ -169,11 +170,10 @@ An example callback function that has been written as indicated below. if (ret < 0) { printf("Failed to get port %d link status: %s\n\n", port_id, rte_strerror(-ret)); - } else 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); + } else { + rte_eth_link_to_str(link_status, 200, NULL, &link); + printf("Port %d %s\n\n", port_id, link_status); + } } This function is called when a link status interrupt is present for the right port. -- 2.17.1