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 6C895A04C7; Tue, 15 Sep 2020 21:08:13 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C395F1C10F; Tue, 15 Sep 2020 21:07:51 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 20FF51C10E for ; Tue, 15 Sep 2020 21:07:50 +0200 (CEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20200915190749euoutp012c8dab6b7292f37a52ec1b80688a6a8a~1CpMdaFM10530105301euoutp01T; Tue, 15 Sep 2020 19:07:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20200915190749euoutp012c8dab6b7292f37a52ec1b80688a6a8a~1CpMdaFM10530105301euoutp01T DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1600196869; bh=A2PTzi/6QAPdj31SukY6WaSzyjFhYitbEDWVAQoenkE=; h=From:To:Subject:Date:In-Reply-To:Reply-To:References:From; b=c/2kyi4XN4QnQvB+zlgCVcZTvlm/zwGI34kVWI7sVCMQfkC114D47nwJ1OJXbZp08 5Y1imXjANQ6mibRTfYcKtYVC9MUQNAUwL6HQz3hHirCOSVQCms5Z8xKLJmuxCz7BTY 7i8hCQW5Iw8y57uEDZtZO9jylTz/zb7/RexQ9SaQ= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20200915190749eucas1p10acec7e593034d8cf8b33d2d74148a61~1CpMJCRt33097130971eucas1p1S; Tue, 15 Sep 2020 19:07:49 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id F7.46.06318.501116F5; Tue, 15 Sep 2020 20:07:49 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20200915190748eucas1p171de0997902ef5c415bdd60e391ae631~1CpLxTG0r3097030970eucas1p1Y; Tue, 15 Sep 2020 19:07:48 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200915190748eusmtrp19aaa08952e5aa4e16f034ec1e56eadba~1CpLwUOdK3148631486eusmtrp1C; Tue, 15 Sep 2020 19:07:48 +0000 (GMT) X-AuditID: cbfec7f5-38bff700000018ae-57-5f61110519e2 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 11.EB.06017.401116F5; Tue, 15 Sep 2020 20:07:48 +0100 (BST) Received: from idyukov.rnd.samsung.ru (unknown [106.109.129.29]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200915190746eusmtip253380944e2c80083e28f465370995825~1CpJ-yzwn1712017120eusmtip2F; Tue, 15 Sep 2020 19:07: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: Tue, 15 Sep 2020 22:06:58 +0300 Message-Id: <20200915190728.18143-4-i.dyukov@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200915190728.18143-1-i.dyukov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA0WSf0yUdRzH+z6/uXHu8byNz7Agb7VlDSi1+CQN1LX52Jq6NjfXVnjFM6C4 w90jmLrVpYBwIOiJlODokpoEBhoHBw4dUuOgQxH0Bg5QJJ2hcPyWoPMHx3PO/97v1+f9/n62 z74CrSvhwoVU8x7ZYjamGTgN09A23xXFLjcmvp1XpMHaznKCw7cqaBwqHuQwfyKLwr6qBGx2 nWLRfttKYaF9kkJXpY3D0aGDDPqmXBQOXPTwWNpzkMep1vs8HukqI3jf/4DGk45pgl3l9SzO X77A4bj/NIOFC16CRc52gu6CSQaLmxoJ5thEnPjtDI8VAxE4NdTOoOdmHY9nZ7tprO98TPCY u5bglZyn7IZV0oLjV1aqaB6hpOM/d9NS280SXiroKKek875GShq/5OWkQmcVkf4ezqel6rv/ cds1n2o+SJLTUjNlS0z8Lk1KVs/v7O7iuG9qmltoK3FG20iIAOI6qO4/x9qIRtCJlQQapsc5 1cwQcJT6KNVMEzjx8A7zvDK1cJ1XB2cIdAzU0KqZJTDzKHspxYlvgCe3fKmuF89z4PL3UoHB CvFjuN1/iw9oRnwdrJ3/sgGtFd8H14+ngisiofpcCx3QIeJ66GnyLuV1YgT0/jSz9CiInQLk PSli1cKHcORPX7C8Ah64nbyqXwbP8QJGLRwmcKyhjlfNUQKHysaCqQRwPry6qAWBFldD7YUY FW+EYe8vdACDuAz6xpYHML0o7Q0/BLEWcnN0atoALR09QQzw+P9QFUtw5/u84LUuEqic/Ic5 SiJLX+xyEFJFwuQMxZQsK2vN8t5oxWhSMszJ0V+mm/4gi7/V88Q920gu+b9oJaJADKFaR/+u RB1rzFT2mVoJCLRBr910xfO5Tptk3LdftqQnWjLSZKWVrBQ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Ku0Q5IKJMt/H8Eq44vR5YRSOegfN8KYz+EOU3ls j7LSJp2N25Ktr615PrM+++sU9WfWTd8Mq3wFnq+OtbYmb6S/OndZTEZy0Q+978oFZRr1OH20 e6SPH1q146k/9QAOxm/w59t/GkRu+GP2YVvjvvsL1guBx66SW5rW2A7jnovVvmMrf53eG6q5 nKWl5FxRt5C0yOIfxU0rKQgDAAA= X-CMS-MailID: 20200915190748eucas1p171de0997902ef5c415bdd60e391ae631 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200915190748eucas1p171de0997902ef5c415bdd60e391ae631 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200915190748eucas1p171de0997902ef5c415bdd60e391ae631 References: <20200427095737.11082-1-i.dyukov@samsung.com> <20200915190728.18143-1-i.dyukov@samsung.com> Subject: [dpdk-dev] [PATCH v11 03/24] app: update apps&docs with new UNKNOWN link speed 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 | 11 +++++------ app/test-pipeline/init.c | 11 +++++------ app/test-pmd/config.c | 9 +++++---- app/test-pmd/testpmd.c | 12 ++++-------- app/test/test_pmd_perf.c | 17 +++++++---------- doc/guides/sample_app_ug/link_status_intr.rst | 10 +++++----- 6 files changed, 31 insertions(+), 39 deletions(-) diff --git a/app/proc-info/main.c b/app/proc-info/main.c index abeca4aab..0b030d326 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[RTE_ETH_LINK_MAX_STR_LEN]; memset(&rss_conf, 0, sizeof(rss_conf)); @@ -685,12 +686,10 @@ 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), + &link); + printf("\t%s\n", 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..fe37d6373 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[RTE_ETH_LINK_MAX_STR_LEN]; 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), + &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..f814de29c 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -605,7 +605,7 @@ port_infos_display(portid_t port_id) 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 speed: %s\n", rte_eth_link_speed_to_str(link.link_speed)); printf("Link duplex: %s\n", (link.link_duplex == ETH_LINK_FULL_DUPLEX) ? ("full-duplex") : ("half-duplex")); @@ -750,12 +750,12 @@ port_summary_display(portid_t port_id) if (ret != 0) return; - printf("%-4d %02X:%02X:%02X:%02X:%02X:%02X %-12s %-14s %-8s %uMbps\n", + printf("%-4d %02X:%02X:%02X:%02X:%02X:%02X %-12s %-14s %-8s %s\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); + rte_eth_link_speed_to_str(link.link_speed)); } void @@ -3899,7 +3899,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..e996e2b75 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[RTE_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), &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_pmd_perf.c b/app/test/test_pmd_perf.c index 352cd4715..d1240b76f 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[RTE_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), &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..1057c7584 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), &link); + printf("Port %d %s\n", port_id, link_status); + } } This function is called when a link status interrupt is present for the right port. -- 2.17.1