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 E226CA0520; Thu, 2 Jul 2020 15:22:32 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4D62E1D9FE; Thu, 2 Jul 2020 15:22:14 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id CE7251D9F6 for ; Thu, 2 Jul 2020 15:22:12 +0200 (CEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20200702132212euoutp0181f3ab5d3853ef218aa69f3b7c777008~d8jBIEaf52089820898euoutp01D for ; Thu, 2 Jul 2020 13:22:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20200702132212euoutp0181f3ab5d3853ef218aa69f3b7c777008~d8jBIEaf52089820898euoutp01D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1593696132; bh=yH4wqf+9CvJZ6kIX7HBs2k+QR9BiafgDjJMHMyZgdQ8=; h=From:To:Subject:Date:In-Reply-To:Reply-To:References:From; b=CZ44xdolHiVr+Kr3yK4xIVwgy7at94vKZngBDChQ3n8SO0+0Glmgb0WbD8f8BecWu VgCl34xusLm1p5XrC8uCyJ9eQSo6IBIyZMxRKPIeEwDZzUotCweg7zd24t2W2vqAS2 eOi88Ry3ZnumIDtJxXz/a5YM5QtF+Xh3P39xtprM= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20200702132212eucas1p12680d91d89509e206578f7bbda88ae3a~d8jA8gI1S2053720537eucas1p1G; Thu, 2 Jul 2020 13:22:12 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id B6.00.06456.38FDDFE5; Thu, 2 Jul 2020 14:22:12 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20200702132211eucas1p1e49daea80551730a4fb4736691f3edac~d8jAhoTCp2043520435eucas1p1S; Thu, 2 Jul 2020 13:22:11 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200702132211eusmtrp258f3bad862d533611a4a326c7b8093c3~d8jAg-CGM2416424164eusmtrp2W; Thu, 2 Jul 2020 13:22:11 +0000 (GMT) X-AuditID: cbfec7f2-7efff70000001938-05-5efddf834cc4 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id B5.E2.06314.38FDDFE5; Thu, 2 Jul 2020 14:22:11 +0100 (BST) Received: from idyukov.rnd.samsung.ru (unknown [106.109.129.29]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200702132210eusmtip2ee956a365525d66cc22dfdca84c01bb1~d8i-oiJRf0577205772eusmtip2b; Thu, 2 Jul 2020 13:22:10 +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 Date: Thu, 2 Jul 2020 16:21:30 +0300 Message-Id: <20200702132139.28078-4-i.dyukov@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200702132139.28078-1-i.dyukov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA0WSe0hTcRTH+917t3sdTm5T8uBCaRRlIzUKupaYScKNosd/Yajd8qamW7X5 yOoPGVY6xcRES0ql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vF6Zub2S3W fL3IbLH1zF9GBz6PXwuWsnos3vOSyePYzWnsHj0n5zF5vN93lc2jb8sqRo9Tj7qZPVY/+cEW wBGlZ1OUX1qSqpCRX1xiqxRtaGGkZ2hpoWdkYqlnaGwea2VkqqRvZ5OSmpNZllqkb5egl3Ft z3z2gn69iqZDixkbGD+rdDFyckgImEgc/X2brYuRi0NIYCmjxLcZB5m7GDmAEhISr58wQ9QI S/y51gVV85lR4vPlfYwgCTYBDYnTHfOYQGwRgXtMEltWqoLYwgI2EtN6joPVsAioStw9+5QV xOYVsJSYPmkeI8RQeYnVGw6A7eIUsJLYcoIPJCwkkClx+fUVNghbTuL6/C9MExj5FjAyrGIU SS0tzk3PLTbUK07MLS7NS9dLzs/dxAiMim3Hfm7ewXhpY/AhRgEORiUe3gnH/8YJsSaWFVfm HmKU4GBWEuF1Ons6Tog3JbGyKrUoP76oNCe1+BCjKdB9E5mlRJPzgRGbVxJvaGpobmFpaG5s bmxmoSTO2yFwMEZIID2xJDU7NbUgtQimj4mDU6qBMdzNTmu3mFGoSYJzc/q1rYUxt5l2fg2R /PejwnWyUKy88i5GZtfN6Rsm8tkbGW5+bHyr9fGCfUc31se9Zj0hPcX306aA7i9b202LpZN/ JqbfYLg0UYL3rJ7sheYQEzPPreJz1C+9uhioVtua/+DUmogs95XyZS2isRH+aU1r5N6xzaqz bRRXYinOSDTUYi4qTgQANZONz6ACAAA= X-CMS-MailID: 20200702132211eucas1p1e49daea80551730a4fb4736691f3edac X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200702132211eucas1p1e49daea80551730a4fb4736691f3edac X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200702132211eucas1p1e49daea80551730a4fb4736691f3edac References: <20200427095737.11082-1-i.dyukov@samsung.com> <20200702132139.28078-1-i.dyukov@samsung.com> Subject: [dpdk-dev] [PATCH v4 3/7] 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_format 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 | 19 +++++++++++-------- app/test-pmd/testpmd.c | 9 +-------- app/test/test_pmd_perf.c | 17 +++++++---------- 5 files changed, 27 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..dfeeec943 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_format(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 5381207cc..77fa9a0e9 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -600,10 +600,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); @@ -726,6 +725,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)) { @@ -746,12 +747,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_format(status_text, 6, "%S", &link); + rte_eth_link_format(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 @@ -3897,7 +3900,7 @@ 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 != UINT32_MAX && 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 9cbe6e9f6..621a1055c 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -3007,14 +3007,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..8ce464b56 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_format(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