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 6A1C9A0093; Mon, 15 Jun 2020 11:02:43 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 68955AAB7; Mon, 15 Jun 2020 11:02:16 +0200 (CEST) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id 24E225B3A for ; Mon, 15 Jun 2020 11:02:14 +0200 (CEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200615090213euoutp026b59e1d6f54238c041f457a0d72bb444~YrCLYS9ca3227332273euoutp02b for ; Mon, 15 Jun 2020 09:02:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200615090213euoutp026b59e1d6f54238c041f457a0d72bb444~YrCLYS9ca3227332273euoutp02b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1592211733; bh=oFT9jgZ3r9AckjfyWwBFLX0QNBigfrKWe4c5z6a7wCU=; h=From:To:Subject:Date:In-Reply-To:Reply-To:References:From; b=s7oJ6ne69comHUWkytB9+tI29ahItu0ZdjayPvbU+AGRYtX6rIV1vEdxwMo+2ztP5 5PnMFVnlgnpW6xcEp0dFWhZC6jA30a//Mk9e3CLc2nvzKnMsyz1SlE3P+iOC9gGJsy f/CC8Mogml9ENg5I9t5bFzEDu85OF8SdhNtz683Q= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20200615090213eucas1p202a66756f631346df6df1cff3a41a687~YrCLE_L0u0261002610eucas1p2s; Mon, 15 Jun 2020 09:02:13 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id BE.FE.61286.51937EE5; Mon, 15 Jun 2020 10:02:13 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20200615090213eucas1p15932ac08c443956186734940fcd03e28~YrCKx47Km1085310853eucas1p1j; Mon, 15 Jun 2020 09:02:13 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200615090213eusmtrp169bd8ec901b52c11a60d4d01fe9b3bb8~YrCKxKUxG1019610196eusmtrp1M; Mon, 15 Jun 2020 09:02:13 +0000 (GMT) X-AuditID: cbfec7f2-ef1ff7000001ef66-a1-5ee73915d773 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 00.D3.07950.51937EE5; Mon, 15 Jun 2020 10:02:13 +0100 (BST) Received: from idyukov.rnd.samsung.ru (unknown [106.109.129.29]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200615090212eusmtip10c0e6d23f66f79e17d2b7876690bc5a8~YrCKDIhsQ2966229662eusmtip11; Mon, 15 Jun 2020 09:02:12 +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 Date: Mon, 15 Jun 2020 12:01:51 +0300 Message-Id: <20200615090158.18912-4-i.dyukov@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200615090158.18912-1-i.dyukov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA0VSfSyUcRz3u+e5ex5yPI7mOxW6spUNWdkejUL9ca21rK1sRK48w3LoDoX+ QE4iZUhok9eRl5H31BWXt3apedthkV7moq7My4ROOQ/rv8/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vi2rGD1WP/nBFsAWpWdTlF9akqqQkV9cYqsUbWhh pGdoaaFnZGKpZ2hsHmtlZKqkb2eTkpqTWZZapG+XoJcxY+FPloKvuhXXL+9lb2B8pNLFyMkh IWAiseTiEhYQW0hgKaPEmabaLkYOoLiExOsnzBAlwhJ/rnWxdTFyAZV8ZpQ4feUAI0iCTUBD 4nTHPCaQhIjAEiaJvavOgSWEBWwkrrcsBetmEVCVmH2vlQlkKK+ApcSRN/oQQ+UlVm84AFbC KWAlcfHgDHaIGzIlXs2/wwphy0lcn/+FaQIj3wJGhlWMIqmlxbnpucVGesWJucWleel6yfm5 mxiB4b7t2M8tOxi73gUfYhTgYFTi4bUIfRYnxJpYVlyZe4hRgoNZSYTX6ezpOCHelMTKqtSi /Pii0pzU4kOMpkD3TWSWEk3OB8ZiXkm8oamhuYWlobmxubGZhZI4b4fAwRghgfTEktTs1NSC 1CKYPiYOTqkGxnpjW/5TChMkGY2MttwVVmGYknIxeCZHnPqNUN25fdvP/pj1UeJ3e+ezwKoj pqWsJW8f/p7n+zJ4zp+Vxr9j02dMdHhoWG6a4MrveyJuZ1f0Lv71X089vJz8pIRl6fwKsw3/ e763bOTOfPXx9DGRsFXNf0VT+yU91E7qcjjeN9op/JX30NO/C5RYijMSDbWYi4oTAQZd+6KN AgAA X-CMS-MailID: 20200615090213eucas1p15932ac08c443956186734940fcd03e28 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200615090213eucas1p15932ac08c443956186734940fcd03e28 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200615090213eucas1p15932ac08c443956186734940fcd03e28 References: <20200427095737.11082-1-i.dyukov@samsung.com> <20200615090158.18912-1-i.dyukov@samsung.com> Subject: [dpdk-dev] [PATCH v3 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 | 10 ++++------ app/test-pmd/config.c | 19 +++++++++++-------- app/test-pmd/testpmd.c | 9 +-------- app/test/test_pmd_perf.c | 17 +++++++---------- 5 files changed, 26 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..9d5d209ea 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 status_text[50]; all_ports_up = 1; for (i = 0; i < app.n_ports; i++) { @@ -173,12 +173,10 @@ app_ports_check_link(void) all_ports_up = 0; continue; } - - RTE_LOG(INFO, USER1, "Port %u (%u Gbps) %s\n", + rte_eth_link_format(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"); - + 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