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 BB488A04AF; Tue, 11 Aug 2020 10:53:47 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DB3C31C0B8; Tue, 11 Aug 2020 10:53:10 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 9C34C1C07D for ; Tue, 11 Aug 2020 10:53:07 +0200 (CEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20200811085307euoutp01ea190603586ad734e478421b5bf76b4a~qKrfynGT-0892608926euoutp01E; Tue, 11 Aug 2020 08:53:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20200811085307euoutp01ea190603586ad734e478421b5bf76b4a~qKrfynGT-0892608926euoutp01E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1597135987; bh=dI+oiTsEKRnvivBB04vQNjKvj/2HACon7g1KeTDyHHI=; h=From:To:Subject:Date:In-Reply-To:Reply-To:References:From; b=Pz4RrXKPbN4/M2c9tr05Yk8NtguSaSbUzo6xA+d9R3uRziZZBlCKis3pRKlXmTEHZ JmOJ8UlF0U4tObriumalQ3KzAljE0ZXjaVcDmJ1DIs4KptrKHRr4o7Q3vbXKKcFO98 SVriL8E6sZbXbchVUL7+nYitMQpTGtXMiAXD2Aag= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20200811085307eucas1p134aece58dc4de4db87cd497976b86cc5~qKrfmcV_01584815848eucas1p1i; Tue, 11 Aug 2020 08:53:07 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 21.1C.05997.37C523F5; Tue, 11 Aug 2020 09:53:07 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200811085306eucas1p2028e8b747d3a1b5d659e1e554a4aca84~qKrfKk7_v3145931459eucas1p20; Tue, 11 Aug 2020 08:53:06 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200811085306eusmtrp16c5bc19c51767d6fe2b1bb3c525fc0c3~qKrfJp3TC1606216062eusmtrp1B; Tue, 11 Aug 2020 08:53:06 +0000 (GMT) X-AuditID: cbfec7f4-65dff7000000176d-8e-5f325c733453 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 21.4D.06017.27C523F5; Tue, 11 Aug 2020 09:53:06 +0100 (BST) Received: from idyukov.rnd.samsung.ru (unknown [106.109.129.29]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200811085304eusmtip14073110d4a3a4567c33d352a704d85f8~qKrdY9lq-1792217922eusmtip1I; Tue, 11 Aug 2020 08:53:04 +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: Tue, 11 Aug 2020 11:52:22 +0300 Message-Id: <20200811085246.28735-4-i.dyukov@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200811085246.28735-1-i.dyukov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA0WSf0yUdRzH93me557n4fLs8XTjM3OyzunKFMFqfjSLdK6eP2w526o5la54 htRxsHtAo7XJriI9LkIkKmmIUEl31Gked4SacCWnHUiyDDEQxmqXdAjiMeI6KI4H13+v94/v 9/PZd1+RNX7ELxVzrAWKzWq2mHg952ufurJW3b0+M63PpyNPRw3Q0M16lgYr+3kqHXuXoeuu DDrn/0xHFQPFDJVV3GHI3+DgKTJo5+j2uJ+hvvMhgY512wUaD4QF+qCrGigcH2bp09q7QF01 TTqaamvhaTRex1FZ7BrQh95LQEHnHY4qv2sGKnFINPbVSYHq+5bT+OAljkK9ZwRqnLjKUlPH NNCRoAeos+Rf3dMPyrHaL3Ry/blbjHz0xFVWbu+tEmTn5RpGPn27mZFHv7/Gy2VeF8g/DZWy svv3v/kd+l36zVmKJWe/Ylv31Cv6fd1DQ0J+ZPubEz0n2GKIbXZAkojSY9jY+BvvAL1olBoA wz8EGE1EAZurugRN3AWMzAR09460ButAC04C2iva51sTgG7XJ1yixUsPYehQzdxdS6TTPPrj PUwiWCxtwLjrwhxz0kp8b7gXEmyQNuLU+NesNiIF3ada5zhJ2oTu6oE5NkrLsed4lNE6HSJG 4laNt+GvtR7QeDEOB72CxsswdNTJJZZA6X3AI74zgibKAd+pHplvZaD3ryuzLIqs9DB6WtZp 9hYMNHVyCRulhXh9ZFHCZmexwvcxq9kGPFRi1NombL3cPW8jTv+zQLNl9Pa3zr/PecBB+yko h5Rj/8+qBXBBslKo5mYr6nqrciBVNeeqhdbs1Nfycr+F2c8amglGm6El/moAJBFMCwz5T6Rn GnXm/WpRbgBQZE1LDFs7Q3uNhixz0VuKLS/TVmhR1AA8IHKmZMO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BF/73CJncMwVZ16+zn195iSlp+WZL2PJJztaq 7neHrzI4jzq9l0VvL/ud5Eq6tzr14fCanDhlT8DcpPfpxsaZg3mTmW8Vrl+dHaNCX2lY0mxH pFfMlDO4t8f6ajZX4vQ44kb5WFd2Ra7bfIA5Efo6SNFcPKeZtNVmpsqN2TWv8e5jyeckJXHe n9SUGKNnt5GCqP8LOHBGfAkDAAA= X-CMS-MailID: 20200811085306eucas1p2028e8b747d3a1b5d659e1e554a4aca84 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200811085306eucas1p2028e8b747d3a1b5d659e1e554a4aca84 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200811085306eucas1p2028e8b747d3a1b5d659e1e554a4aca84 References: <20200427095737.11082-1-i.dyukov@samsung.com> <20200811085246.28735-1-i.dyukov@samsung.com> Subject: [dpdk-dev] [PATCH v9 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 | 13 ++++++----- app/test-pipeline/init.c | 11 ++++----- app/test-pmd/config.c | 23 ++++++++++++------- app/test-pmd/testpmd.c | 12 ++++------ app/test/test_ethdev_link.c | 6 ++--- app/test/test_pmd_perf.c | 17 ++++++-------- doc/guides/sample_app_ug/link_status_intr.rst | 10 ++++---- 7 files changed, 46 insertions(+), 46 deletions(-) diff --git a/app/proc-info/main.c b/app/proc-info/main.c index abeca4aab..a315f22ce 100644 --- a/app/proc-info/main.c +++ b/app/proc-info/main.c @@ -672,6 +672,7 @@ show_port(void) struct rte_eth_dev_info dev_info; struct rte_eth_rxq_info queue_info; struct rte_eth_rss_conf rss_conf; + char link_status_text[100]; memset(&rss_conf, 0, sizeof(rss_conf)); @@ -685,12 +686,12 @@ 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_to_str(link_status_text, + sizeof(link_status_text), + "\t -- link speed: %M, duplex: %D," + " auto neg: %A, status: %S\n", + &link); + printf("%s", link_status_text); } 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..b85db3826 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, sizeof(link_status_text), + "(%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..a34aed123 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -564,6 +564,7 @@ port_infos_display(portid_t port_id) char name[RTE_ETH_NAME_MAX_LEN]; int ret; char fw_version[ETHDEV_FWVERS_LEN]; + char link_status[70]; if (port_id_is_invalid(port_id, ENABLED_WARN)) { print_valid_ports(); @@ -604,10 +605,11 @@ 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_to_str(link_status, sizeof(link_status), + "\nLink status: %S\n" + "Link speed: %M Mbps\n" + "Link duplex: %D\n", &link); + printf("%s", link_status); if (!rte_eth_dev_get_mtu(port_id, &mtu)) printf("MTU: %u\n", mtu); @@ -730,6 +732,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 +754,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 +3905,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..1d294641b 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -2991,6 +2991,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[ETH_LINK_MAX_STR_LEN]; printf("Checking link statuses...\n"); fflush(stdout); @@ -3010,14 +3011,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_to_str(link_status, + sizeof(link_status), NULL, &link); + printf("Port %d %s\n", portid, link_status); continue; } /* clear all_ports_up flag if any link down */ diff --git a/app/test/test_ethdev_link.c b/app/test/test_ethdev_link.c index b501deefe..8e2a8be13 100644 --- a/app/test/test_ethdev_link.c +++ b/app/test/test_ethdev_link.c @@ -19,7 +19,7 @@ test_link_status_up_default(void) .link_autoneg = ETH_LINK_AUTONEG, .link_duplex = ETH_LINK_FULL_DUPLEX }; - char text[RTE_ETH_LINK_MAX_STR_LEN + 1]; + char text[ETH_LINK_MAX_STR_LEN + 1]; ret = rte_eth_link_to_str(text, sizeof(text), NULL, &link_status); RTE_TEST_ASSERT(ret > 0, "Failed to format default string\n"); @@ -51,7 +51,7 @@ test_link_status_up_default(void) link_status.link_autoneg = ETH_LINK_AUTONEG; ret = rte_eth_link_to_str(text, sizeof(text), NULL, &link_status); printf("Default link up #4:len = %d, %s\n", ret, text); - RTE_TEST_ASSERT(ret > RTE_ETH_LINK_MAX_STR_LEN, + RTE_TEST_ASSERT(ret < ETH_LINK_MAX_STR_LEN, "String length exceeds max allowed value\n"); return TEST_SUCCESS; } @@ -66,7 +66,7 @@ test_link_status_down_default(void) .link_autoneg = ETH_LINK_AUTONEG, .link_duplex = ETH_LINK_FULL_DUPLEX }; - char text[RTE_ETH_LINK_MAX_STR_LEN]; + char text[ETH_LINK_MAX_STR_LEN]; ret = rte_eth_link_to_str(text, sizeof(text), NULL, &link_status); RTE_TEST_ASSERT(ret > 0, "Failed to format default string\n"); diff --git a/app/test/test_pmd_perf.c b/app/test/test_pmd_perf.c index 352cd4715..9d38382c2 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[ETH_LINK_MAX_STR_LEN]; 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, + sizeof(link_status), 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..2f7eb61c2 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[RTE_ETH_LINK_MAX_STR_LEN]; 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, sizeof(link_status), 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