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 903FFA04C7; Tue, 15 Sep 2020 21:08:03 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8B2231C119; Tue, 15 Sep 2020 21:07:48 +0200 (CEST) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id 801801C10D for ; Tue, 15 Sep 2020 21:07:47 +0200 (CEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200915190747euoutp0264a92e300717e5b5a34e74e4b8ba69bd~1CpKEcXXK0661606616euoutp02c; Tue, 15 Sep 2020 19:07:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200915190747euoutp0264a92e300717e5b5a34e74e4b8ba69bd~1CpKEcXXK0661606616euoutp02c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1600196867; bh=RQ3/kkDLle8kNv2ZAm9r/hPz4wWBq8W0Dvtw/mrDJa0=; h=From:To:Subject:Date:In-Reply-To:Reply-To:References:From; b=iT8BFjxlaO4kJVqjD64ouMSmh2LJsV59gqoR24SMDa6wD1yHi6XCtV9MZxmZrsg6F zoAsQN6SqSPhqcAzBF/TEePX0epVi7S6hBCW23DumKf+GH91difMdYqGC7nrOqXLGV A4YpyMbMLB0yOl3ybxd6n4C4b2sLtI7NkB2VlK7w= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20200915190746eucas1p1f4e83098f40528fa6999c304098f8cce~1CpJsAELo3097030970eucas1p1T; Tue, 15 Sep 2020 19:07:46 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 35.46.06318.201116F5; Tue, 15 Sep 2020 20:07:46 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200915190746eucas1p2c80920f3eaff2844faf836eaea4c1d42~1CpJLp8n02574925749eucas1p2j; Tue, 15 Sep 2020 19:07:46 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200915190746eusmtrp10cda18771e6791514153607ab0a91a52~1CpJK6CiJ2872428724eusmtrp1G; Tue, 15 Sep 2020 19:07:45 +0000 (GMT) X-AuditID: cbfec7f5-38bff700000018ae-53-5f611102ada5 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 38.DB.06314.101116F5; Tue, 15 Sep 2020 20:07:45 +0100 (BST) Received: from idyukov.rnd.samsung.ru (unknown [106.109.129.29]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200915190743eusmtip2e08a44b03f82f69e2adc48b30ec97f6a~1CpHP0t961759817598eusmtip2J; Tue, 15 Sep 2020 19:07:43 +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:57 +0300 Message-Id: <20200915190728.18143-3-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: H4sIAAAAAAAAA0WSfUwTdxjH99xd747GmqOY+ZtTiU1MNjNejIt7QOMrLmeyRc32z5ZspZML mkLBlrK5uKSzpEpFxMJ0CqlVZCLdhiK0YJBok4muMLCTYLVoYzYNMhQK3QYWlXo1/vf5vvzy PHny42m1g13A7zSUSEaDrkDDKhnP1am+NCpZp80cL9dgc48T8P7dehrDNUMsHhgro/BW01rs 9NYp0HHPQmGlY5xCb6OdxX/Cexl8HPFSGLrk5/B4YC+HEd9DDg/21QI+jD2i8ZhrArDP2abA qSsXWXwSO8Vg5fQA4KHWa4DdFeMM1nS0A9rsAo6dPcNhfWgxRsLXGPQHL3D4c/QGjW09M4CH u5sBe23PFeuWiNOuBoVY3zlMidUnb9Di1eARTqy47qTE84/bKfFJ1wArVrY2gfj7/QO06P7r f3ar8nPl6jypYGepZMxYk6vc4fg3Qhdbc7/xnnzTAj9usUMST4T3yeivLWAHJa8WGoHMBM6x spgEcsfydyKZANLpH2ZePbGNNTJycAZIsCNIySIKpNbay8ZbrPAO8e93vgzmCedZ4o0Nzgqe TxFWk+jR7HiHEZaSrrJ7ijirhCzSYamh5AmpxH3uMh3nJCGbBDoGuDirhcVk8MRkotPPk3bP JzLnkMH/yjiZU8ij7tYELyT+6oqXmxJhH5DDngucLKqAWGtHE621pHXkDy6+HC28S5ovZsj2 elJ783uI20SYS26NJsdtehYdnqO0bKvIfptabmvI5euBhE3IzNM5MoqkM7JSvs4lILdbPEwV pB5/PcoF0ATzJbOpMF8yrTBIX6ebdIUmsyE/fXtRYQvM/lT/s+5oO3TFvvKBwINmjsp1J1er VuhKTbsLfUB4WjNPtaHX/6Valafb/a1kLNIazQWSyQdv84xmvmrFqeEv1EK+rkTSS1KxZHyV UnzSAguE9lg3r5nIyX5j491Yv76ntDxlqEx/ZDjV1rAraP2lSn/z7MJNmQa3jZ38OC1j5Ifi Enc0bF3221xX1rEPt7Fmz64HqrZPQysD0+l54UVM3e0tp5e73xN8/X9yaaHPppZ+d/rBW+Ww anuOGasdzpGhnxo/eNZn36jNKhrVX1FqMz/SMKYduuXLaKNJ9wJ0No/8pQMAAA== X-Brightmail-Tracker: H4sIAAAAAAAAAzWSbUhTcRTG+997dzdXi9vU+idkNQgqcG6aelxqIYG3TxViH3qbo25TdFvs zl4pbNqUaZYm2ZtrJpJZYWU5Vxa6wJnTRMMyTJNYVPamU/MFrVzStx88z3POgeeISOkYFSJK 15s4o16TKaPFlOe3eyAMLdGoFV+qFFDbbkPwYaCShMHSfhoKhnMJ6K3ZBI2OawIoeZ9NQFHJ CAGOaisN3wbNFPzwOQh499QjhCvdZiH4XJ+EcLbzKoJPM0MkXLaPIui0PRLAVPNjGn7O3KCg aLoHwbmHrQjchSMUlDobEFisDAzfuimEyneh4BtspcDztk4Id8a7SHjUPoug2F2LoMPyR7B5 NTttrxKwlY1fCPZCRRfJtry9KGQLX9gI9v6PBoL9+ayHZose1iC27UMByd72TtLbxbvkcUZD lolblWbgTfGy3UqIkCtjQR6xIVaujIzZq4qIkoUnxB3gMtMPc8bwhFR5WskvH3koJ/Woo2Jp Nrq0zYoCRJjZgC3D1ZQViUVSpgrh4ielpBWJ5gSMv3rJeU8gnnltpec9owgPvKyl/QLNrMWe fBvhF4KYPhq/yjtN+cOBTBweL1P5PRSzBj/LfS/ws4SJxc7sUmJ+6Ep8+17TvwUBjAp3O3uE fpYy6fh63it6nkPxm+tjxHm02I4W1KAgLovXaXW8Us5rdHyWXivfb9A9QHON17dM1TWg7vvJ LsSIkGyRxN6XqpYKNIf5YzoXwiJSFiRJ7PDsk0oOaI4d54wGtTErk+NdKGruwGIyJHi/Ye5/ 9Ca1MkoZA7HKmMiYyGiQLZPkM817pIxWY+IyOO4QZ/yfI0QBIdlIpyiLnqDrA30Fnyf6Tyxf IW7d8v1jb8bQkoVcZG1LsC/c7M1Iid+adGTKZZk0O9nnB3O8cb7RXtvs2fKUhOaLU+xsyZ2N xsKqzuYdivL8j2XDqurcU4u0vL0p9MzJNkgOK07qb+zzrruk0l5panDXrVXsiP5qOZgYzMX3 7lTdlVF8mka5njTymr8sCG57BwMAAA== X-CMS-MailID: 20200915190746eucas1p2c80920f3eaff2844faf836eaea4c1d42 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200915190746eucas1p2c80920f3eaff2844faf836eaea4c1d42 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200915190746eucas1p2c80920f3eaff2844faf836eaea4c1d42 References: <20200427095737.11082-1-i.dyukov@samsung.com> <20200915190728.18143-1-i.dyukov@samsung.com> Subject: [dpdk-dev] [PATCH v11 02/24] ethdev: format a link status text 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" There is new link_speed value introduced. It's INT_MAX value which means that speed is unknown. To simplify processing of the value in application, new function is added which convert link_speed to string. Also dpdk examples have many duplicated code which format entire link status structure to text. This commit adds two functions: * rte_eth_link_speed_to_str - format link_speed to string * rte_eth_link_to_str - convert link status structure to string Signed-off-by: Ivan Dyukov --- MAINTAINERS | 1 + app/test/Makefile | 3 + app/test/meson.build | 2 + app/test/test_ethdev_link.c | 169 +++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.c | 37 +++++ lib/librte_ethdev/rte_ethdev.h | 32 +++++ lib/librte_ethdev/rte_ethdev_version.map | 4 + 7 files changed, 248 insertions(+) create mode 100644 app/test/test_ethdev_link.c diff --git a/MAINTAINERS b/MAINTAINERS index 5e706cd7e..f4fb31ea2 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -393,6 +393,7 @@ T: git://dpdk.org/next/dpdk-next-net F: lib/librte_ethdev/ F: devtools/test-null.sh F: doc/guides/prog_guide/switch_representation.rst +F: app/test/test_ethdev* Flow API M: Ori Kam diff --git a/app/test/Makefile b/app/test/Makefile index e5440774b..9f43b8c3c 100644 --- a/app/test/Makefile +++ b/app/test/Makefile @@ -251,6 +251,9 @@ SRCS-$(CONFIG_RTE_LIBRTE_SECURITY) += test_security.c SRCS-$(CONFIG_RTE_LIBRTE_IPSEC) += test_ipsec.c test_ipsec_perf.c SRCS-$(CONFIG_RTE_LIBRTE_IPSEC) += test_ipsec_sad.c + +SRCS-$(CONFIG_RTE_LIBRTE_ETHER) += test_ethdev_link.c + ifeq ($(CONFIG_RTE_LIBRTE_IPSEC),y) LDLIBS += -lrte_ipsec endif diff --git a/app/test/meson.build b/app/test/meson.build index 56591db4e..1e6acf701 100644 --- a/app/test/meson.build +++ b/app/test/meson.build @@ -39,6 +39,7 @@ test_sources = files('commands.c', 'test_efd.c', 'test_efd_perf.c', 'test_errno.c', + 'test_ethdev_link.c', 'test_event_crypto_adapter.c', 'test_event_eth_rx_adapter.c', 'test_event_ring.c', @@ -199,6 +200,7 @@ fast_tests = [ ['eal_flags_misc_autotest', false], ['eal_fs_autotest', true], ['errno_autotest', true], + ['ethdev_link_status', true], ['event_ring_autotest', true], ['fib_autotest', true], ['fib6_autotest', true], diff --git a/app/test/test_ethdev_link.c b/app/test/test_ethdev_link.c new file mode 100644 index 000000000..ee11987ba --- /dev/null +++ b/app/test/test_ethdev_link.c @@ -0,0 +1,169 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved + */ + +#include +#include + +#include +#include "test.h" + + +static int32_t +test_link_status_up_default(void) +{ + int ret = 0; + struct rte_eth_link link_status = { + .link_speed = ETH_SPEED_NUM_2_5G, + .link_status = ETH_LINK_UP, + .link_autoneg = ETH_LINK_AUTONEG, + .link_duplex = ETH_LINK_FULL_DUPLEX + }; + char text[RTE_ETH_LINK_MAX_STR_LEN]; + + ret = rte_eth_link_to_str(text, sizeof(text), &link_status); + RTE_TEST_ASSERT(ret > 0, "Failed to format default string\n"); + printf("Default link up #1: %s\n", text); + TEST_ASSERT_BUFFERS_ARE_EQUAL("Link up at 2.5 Gbps FDX Autoneg", + text, strlen(text), "Invalid default link status string"); + + link_status.link_duplex = ETH_LINK_HALF_DUPLEX; + link_status.link_autoneg = ETH_LINK_FIXED; + link_status.link_speed = ETH_SPEED_NUM_10M, + ret = rte_eth_link_to_str(text, sizeof(text), &link_status); + printf("Default link up #2: %s\n", text); + RTE_TEST_ASSERT(ret > 0, "Failed to format default string\n"); + TEST_ASSERT_BUFFERS_ARE_EQUAL("Link up at 10 Mbps HDX Fixed", + text, strlen(text), "Invalid default link status " + "string with HDX"); + + link_status.link_speed = ETH_SPEED_NUM_UNKNOWN; + ret = rte_eth_link_to_str(text, sizeof(text), &link_status); + printf("Default link up #3: %s\n", text); + RTE_TEST_ASSERT(ret > 0, "Failed to format default string\n"); + TEST_ASSERT_BUFFERS_ARE_EQUAL("Link up at Unknown HDX Fixed", + text, strlen(text), "Invalid default link status " + "string with HDX"); + + link_status.link_speed = ETH_SPEED_NUM_NONE; + ret = rte_eth_link_to_str(text, sizeof(text), &link_status); + printf("Default link up #3: %s\n", text); + RTE_TEST_ASSERT(ret > 0, "Failed to format default string\n"); + TEST_ASSERT_BUFFERS_ARE_EQUAL("Link up at None HDX Fixed", + text, strlen(text), "Invalid default link status " + "string with HDX"); + + /* test max str len */ + link_status.link_speed = ETH_SPEED_NUM_200G; + link_status.link_duplex = ETH_LINK_HALF_DUPLEX; + link_status.link_autoneg = ETH_LINK_AUTONEG; + ret = rte_eth_link_to_str(text, sizeof(text), &link_status); + printf("Default link up #4:len = %d, %s\n", ret, text); + RTE_TEST_ASSERT(ret < RTE_ETH_LINK_MAX_STR_LEN, + "String length exceeds max allowed value\n"); + return TEST_SUCCESS; +} + +static int32_t +test_link_status_down_default(void) +{ + int ret = 0; + struct rte_eth_link link_status = { + .link_speed = ETH_SPEED_NUM_2_5G, + .link_status = ETH_LINK_DOWN, + .link_autoneg = ETH_LINK_AUTONEG, + .link_duplex = ETH_LINK_FULL_DUPLEX + }; + char text[RTE_ETH_LINK_MAX_STR_LEN]; + + ret = rte_eth_link_to_str(text, sizeof(text), &link_status); + RTE_TEST_ASSERT(ret > 0, "Failed to format default string\n"); + TEST_ASSERT_BUFFERS_ARE_EQUAL("Link down", + text, strlen(text), "Invalid default link status string"); + + return TEST_SUCCESS; +} + +static int32_t +test_link_status_invalid(void) +{ + int ret = 0; + struct rte_eth_link link_status = { + .link_speed = 55555, + .link_status = ETH_LINK_UP, + .link_autoneg = ETH_LINK_AUTONEG, + .link_duplex = ETH_LINK_FULL_DUPLEX + }; + char text[RTE_ETH_LINK_MAX_STR_LEN]; + + ret = rte_eth_link_to_str(text, sizeof(text), &link_status); + RTE_TEST_ASSERT(ret < RTE_ETH_LINK_MAX_STR_LEN, + "Failed to format invalid string\n"); + printf("invalid link up #1: len=%d %s\n", ret, text); + TEST_ASSERT_BUFFERS_ARE_EQUAL("Link up at Invalid FDX Autoneg", + text, strlen(text), "Incorrect invalid link status string"); + + return TEST_SUCCESS; +} + + +static int32_t +test_link_speed_all_values(void) +{ + const char *speed; + uint32_t i; + struct link_speed_t { + const char *value; + uint32_t link_speed; + } speed_str_map[] = { + { "None", ETH_SPEED_NUM_NONE }, + { "10 Mbps", ETH_SPEED_NUM_10M }, + { "100 Mbps", ETH_SPEED_NUM_100M }, + { "1 Gbps", ETH_SPEED_NUM_1G }, + { "2.5 Gbps", ETH_SPEED_NUM_2_5G }, + { "5 Gbps", ETH_SPEED_NUM_5G }, + { "10 Gbps", ETH_SPEED_NUM_10G }, + { "20 Gbps", ETH_SPEED_NUM_20G }, + { "25 Gbps", ETH_SPEED_NUM_25G }, + { "40 Gbps", ETH_SPEED_NUM_40G }, + { "50 Gbps", ETH_SPEED_NUM_50G }, + { "56 Gbps", ETH_SPEED_NUM_56G }, + { "100 Gbps", ETH_SPEED_NUM_100G }, + { "200 Gbps", ETH_SPEED_NUM_200G }, + { "Unknown", ETH_SPEED_NUM_UNKNOWN }, + { "Invalid", 50505 } + }; + + for (i = 0; i < sizeof(speed_str_map) / sizeof(struct link_speed_t); + i++) { + speed = rte_eth_link_speed_to_str(speed_str_map[i].link_speed); + TEST_ASSERT_BUFFERS_ARE_EQUAL(speed_str_map[i].value, + speed, strlen(speed_str_map[i].value), + "Invalid link speed string"); + } + return TEST_SUCCESS; +} + +static struct unit_test_suite link_status_testsuite = { + .suite_name = "link status formatting", + .setup = NULL, + .teardown = NULL, + .unit_test_cases = { + TEST_CASE(test_link_status_up_default), + TEST_CASE(test_link_status_down_default), + TEST_CASE(test_link_speed_all_values), + TEST_CASE(test_link_status_invalid), + TEST_CASES_END() /**< NULL terminate unit test array */ + } +}; + +static int +test_link_status(void) +{ + rte_log_set_global_level(RTE_LOG_DEBUG); + rte_log_set_level(RTE_LOGTYPE_EAL, RTE_LOG_DEBUG); + + return unit_test_suite_runner(&link_status_testsuite); +} + +REGISTER_TEST_COMMAND(ethdev_link_status, test_link_status); diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index d06b7f9b1..438cece72 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -2383,6 +2383,43 @@ rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link) return 0; } +const char * +rte_eth_link_speed_to_str(uint32_t link_speed) +{ + switch (link_speed) { + case ETH_SPEED_NUM_NONE: return "None"; + case ETH_SPEED_NUM_10M: return "10 Mbps"; + case ETH_SPEED_NUM_100M: return "100 Mbps"; + case ETH_SPEED_NUM_1G: return "1 Gbps"; + case ETH_SPEED_NUM_2_5G: return "2.5 Gbps"; + case ETH_SPEED_NUM_5G: return "5 Gbps"; + case ETH_SPEED_NUM_10G: return "10 Gbps"; + case ETH_SPEED_NUM_20G: return "20 Gbps"; + case ETH_SPEED_NUM_25G: return "25 Gbps"; + case ETH_SPEED_NUM_40G: return "40 Gbps"; + case ETH_SPEED_NUM_50G: return "50 Gbps"; + case ETH_SPEED_NUM_56G: return "56 Gbps"; + case ETH_SPEED_NUM_100G: return "100 Gbps"; + case ETH_SPEED_NUM_200G: return "200 Gbps"; + case ETH_SPEED_NUM_UNKNOWN: return "Unknown"; + default: return "Invalid"; + } +} + +int +rte_eth_link_to_str(char *str, size_t len, const struct rte_eth_link *eth_link) +{ + if (eth_link->link_status == ETH_LINK_DOWN) + return snprintf(str, len, "Link down"); + else + return snprintf(str, len, "Link up at %s %s %s", + rte_eth_link_speed_to_str(eth_link->link_speed), + (eth_link->link_duplex == ETH_LINK_FULL_DUPLEX) ? + "FDX" : "HDX", + (eth_link->link_autoneg == ETH_LINK_AUTONEG) ? + "Autoneg" : "Fixed"); +} + int rte_eth_stats_get(uint16_t port_id, struct rte_eth_stats *stats) { diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h index 2090af501..a86f8f916 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -323,6 +323,7 @@ struct rte_eth_link { #define ETH_LINK_UP 1 /**< Link is up (see link_status). */ #define ETH_LINK_FIXED 0 /**< No autonegotiation (see link_autoneg). */ #define ETH_LINK_AUTONEG 1 /**< Autonegotiated (see link_autoneg). */ +#define RTE_ETH_LINK_MAX_STR_LEN 40 /**< Max length of default link string. */ /** * A structure used to configure the ring threshold registers of an RX/TX @@ -2295,6 +2296,37 @@ int rte_eth_link_get(uint16_t port_id, struct rte_eth_link *link); */ int rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *link); +/** + * The function converts a link_speed to a string. It handles all special + * values like unknown or none speed. + * @param link_speed + * link_speed of rte_eth_link struct + * @return + * Link speed in textual format. It's pointer to immutable memory. + * No free is required. + */ +__rte_experimental +const char *rte_eth_link_speed_to_str(uint32_t speed_link); + +/** + * The function converts a rte_eth_link struct representing a link status to + * a string. + * @param str + * A pointer to a string to be filled with textual representation of + * device status. At least ETH_LINK_MAX_STR_LEN bytes should be allocated to + * store default link status text. + * @param len + * Length of available memory at 'str' string. + * @param eth_link + * Link status returned by rte_eth_link_get function + * @return + * - Number of bytes written to str array. + * + */ +__rte_experimental +int rte_eth_link_to_str(char *str, size_t len, + const struct rte_eth_link *eth_link); + /** * Retrieve the general I/O statistics of an Ethernet device. * diff --git a/lib/librte_ethdev/rte_ethdev_version.map b/lib/librte_ethdev/rte_ethdev_version.map index 715505604..69a763d4b 100644 --- a/lib/librte_ethdev/rte_ethdev_version.map +++ b/lib/librte_ethdev/rte_ethdev_version.map @@ -241,4 +241,8 @@ EXPERIMENTAL { __rte_ethdev_trace_rx_burst; __rte_ethdev_trace_tx_burst; rte_flow_get_aged_flows; + + # added in 20.11 + rte_eth_link_to_str; + rte_eth_link_speed_to_str; }; -- 2.17.1