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 DFF78A00D7; Thu, 31 Oct 2019 18:18:43 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BA5491D16A; Thu, 31 Oct 2019 18:18:33 +0100 (CET) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id 34A6A1D161 for ; Thu, 31 Oct 2019 18:18:29 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 Oct 2019 10:18:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,252,1569308400"; d="scan'208";a="199586023" Received: from npg-dpdk-haiyue-1.sh.intel.com ([10.67.119.213]) by fmsmga007.fm.intel.com with ESMTP; 31 Oct 2019 10:18:27 -0700 From: Haiyue Wang To: dev@dpdk.org, thomas@monjalon.net, arybchenko@solarflare.com, ferruh.yigit@intel.com, jerinjacobk@gmail.com, xiaolong.ye@intel.com, ray.kinsella@intel.com, chenmin.sun@intel.com Cc: Haiyue Wang Date: Fri, 1 Nov 2019 01:11:39 +0800 Message-Id: <20191031171139.105110-3-haiyue.wang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191031171139.105110-1-haiyue.wang@intel.com> References: <20191031171139.105110-1-haiyue.wang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v1 3/3] ethdev: enhance the API for getting burst mode information X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 1. Change the rte_eth_rx/tx_burst_mode_get ethdev APIs to convert the 'uint64_t options' to string and append it to 'alternate_options', so that application access the string directly. 2. Change the 'enum rte_eth_burst_mode_option' to macro definition, since ISO C restricts enumerator values to range of ‘int’, but it needs 64bit. 3. Remove the 'rte_eth_burst_mode_option_name()' API. Signed-off-by: Haiyue Wang --- app/test-pmd/config.c | 27 ++------- doc/guides/nics/features.rst | 3 +- doc/guides/rel_notes/release_19_11.rst | 2 - lib/librte_ethdev/rte_ethdev.c | 76 +++++++++++++++++------- lib/librte_ethdev/rte_ethdev.h | 47 +++++---------- lib/librte_ethdev/rte_ethdev_version.map | 1 - 6 files changed, 76 insertions(+), 80 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index efe2812a8..0d04e4657 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -350,21 +350,6 @@ nic_stats_mapping_display(portid_t port_id) nic_stats_mapping_border, nic_stats_mapping_border); } -static void -burst_mode_options_display(uint64_t options) -{ - int offset; - - while (options != 0) { - offset = rte_bsf64(options); - - printf(" %s", - rte_eth_burst_mode_option_name(1ULL << offset)); - - options &= ~(1ULL << offset); - } -} - void rx_queue_infos_display(portid_t port_id, uint16_t queue_id) { @@ -397,10 +382,8 @@ rx_queue_infos_display(portid_t port_id, uint16_t queue_id) (qinfo.scattered_rx != 0) ? "on" : "off"); printf("\nNumber of RXDs: %hu", qinfo.nb_desc); - if (rte_eth_rx_burst_mode_get(port_id, queue_id, &mode) == 0) { - printf("\nBurst mode:"); - burst_mode_options_display(mode.options); - } + if (rte_eth_rx_burst_mode_get(port_id, queue_id, &mode) == 0) + printf("\nBurst mode: %s", mode.alternate_options); printf("\n"); } @@ -433,10 +416,8 @@ tx_queue_infos_display(portid_t port_id, uint16_t queue_id) (qinfo.conf.tx_deferred_start != 0) ? "on" : "off"); printf("\nNumber of TXDs: %hu", qinfo.nb_desc); - if (rte_eth_tx_burst_mode_get(port_id, queue_id, &mode) == 0) { - printf("\nBurst mode:"); - burst_mode_options_display(mode.options); - } + if (rte_eth_tx_burst_mode_get(port_id, queue_id, &mode) == 0) + printf("\nBurst mode: %s", mode.alternate_options); printf("\n"); } diff --git a/doc/guides/nics/features.rst b/doc/guides/nics/features.rst index d96696801..7a31cf7c8 100644 --- a/doc/guides/nics/features.rst +++ b/doc/guides/nics/features.rst @@ -879,8 +879,7 @@ Burst mode info Supports to get Rx/Tx packet burst mode information. * **[implements] eth_dev_ops**: ``rx_burst_mode_get``, ``tx_burst_mode_get``. -* **[related] API**: ``rte_eth_rx_burst_mode_get()``, ``rte_eth_tx_burst_mode_get()``, - ``rte_eth_burst_mode_option_name()``. +* **[related] API**: ``rte_eth_rx_burst_mode_get()``, ``rte_eth_tx_burst_mode_get()``. .. _nic_features_other: diff --git a/doc/guides/rel_notes/release_19_11.rst b/doc/guides/rel_notes/release_19_11.rst index ae8e7b2f0..8fd1e7e62 100644 --- a/doc/guides/rel_notes/release_19_11.rst +++ b/doc/guides/rel_notes/release_19_11.rst @@ -114,8 +114,6 @@ New Features ``rte_eth_tx_burst_mode_get`` that allow an application to retrieve the mode information about RX/TX packet burst such as Scalar or Vector, and Vector technology like AVX2. - Another new function ``rte_eth_burst_mode_option_name`` is - provided for burst mode options stringification. * **Updated the Intel ice driver.** diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 7743205d3..1ff4c302d 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -179,9 +179,6 @@ static const struct { { RTE_ETH_BURST_AVX2, "AVX2" }, { RTE_ETH_BURST_AVX512, "AVX512" }, - { RTE_ETH_BURST_SCATTERED, "Scattered" }, - { RTE_ETH_BURST_BULK_ALLOC, "Bulk Alloc" }, - { RTE_ETH_BURST_SIMPLE, "Simple" }, { RTE_ETH_BURST_PER_QUEUE, "Per Queue" }, }; @@ -4236,11 +4233,55 @@ rte_eth_tx_queue_info_get(uint16_t port_id, uint16_t queue_id, return 0; } +static inline const char * +burst_mode_option_name(uint64_t option) +{ + const char *name = ""; + unsigned int i; + + for (i = 0; i < RTE_DIM(rte_burst_option_names); ++i) { + if (option == rte_burst_option_names[i].option) { + name = rte_burst_option_names[i].name; + break; + } + } + + return name; +} + +static int +burst_mode_options_append(struct rte_eth_burst_mode *mode) +{ + int optlen, len = strlen(mode->alternate_options); + const char *sep = len > 0 ? ", " : ""; + uint64_t options = mode->options; + int offset; + + while (options != 0) { + offset = rte_bsf64(options); + + optlen = snprintf(&mode->alternate_options[len], + RTE_ETH_BURST_MODE_ALT_OPT_SIZE - len, + "%s%s", + sep, burst_mode_option_name(1ULL << offset)); + if (optlen < 0 || + optlen >= (RTE_ETH_BURST_MODE_ALT_OPT_SIZE - len)) + return -ENOSPC; /* An error or output was truncated */ + + len += optlen; + options &= ~(1ULL << offset); + sep = " "; + } + + return 0; +} + int rte_eth_rx_burst_mode_get(uint16_t port_id, uint16_t queue_id, struct rte_eth_burst_mode *mode) { struct rte_eth_dev *dev; + int ret; RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); @@ -4256,8 +4297,12 @@ rte_eth_rx_burst_mode_get(uint16_t port_id, uint16_t queue_id, RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_burst_mode_get, -ENOTSUP); memset(mode, 0, sizeof(*mode)); - return eth_err(port_id, - dev->dev_ops->rx_burst_mode_get(dev, queue_id, mode)); + + ret = dev->dev_ops->rx_burst_mode_get(dev, queue_id, mode); + if (ret == 0) + ret = burst_mode_options_append(mode); + + return eth_err(port_id, ret); } int @@ -4265,6 +4310,7 @@ rte_eth_tx_burst_mode_get(uint16_t port_id, uint16_t queue_id, struct rte_eth_burst_mode *mode) { struct rte_eth_dev *dev; + int ret; RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); @@ -4280,24 +4326,12 @@ rte_eth_tx_burst_mode_get(uint16_t port_id, uint16_t queue_id, RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_burst_mode_get, -ENOTSUP); memset(mode, 0, sizeof(*mode)); - return eth_err(port_id, - dev->dev_ops->tx_burst_mode_get(dev, queue_id, mode)); -} - -const char * -rte_eth_burst_mode_option_name(uint64_t option) -{ - const char *name = ""; - unsigned int i; - for (i = 0; i < RTE_DIM(rte_burst_option_names); ++i) { - if (option == rte_burst_option_names[i].option) { - name = rte_burst_option_names[i].name; - break; - } - } + ret = dev->dev_ops->tx_burst_mode_get(dev, queue_id, mode); + if (ret == 0) + ret = burst_mode_options_append(mode); - return name; + return eth_err(port_id, ret); } int diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h index c36c1b631..7471d4471 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -1250,30 +1250,29 @@ struct rte_eth_txq_info { /** * Burst mode types, values can be ORed to define the burst mode of a driver. */ -enum rte_eth_burst_mode_option { - RTE_ETH_BURST_SCALAR = (1 << 0), - RTE_ETH_BURST_VECTOR = (1 << 1), - - /**< bits[15:2] are reserved for each vector type */ - RTE_ETH_BURST_ALTIVEC = (1 << 2), - RTE_ETH_BURST_NEON = (1 << 3), - RTE_ETH_BURST_SSE = (1 << 4), - RTE_ETH_BURST_AVX2 = (1 << 5), - RTE_ETH_BURST_AVX512 = (1 << 6), - - RTE_ETH_BURST_SCATTERED = (1 << 16), /**< Support scattered packets */ - RTE_ETH_BURST_BULK_ALLOC = (1 << 17), /**< Support mbuf bulk alloc */ - RTE_ETH_BURST_SIMPLE = (1 << 18), - - RTE_ETH_BURST_PER_QUEUE = (1 << 19), /**< Support per queue burst */ -}; +#define RTE_ETH_BURST_SCALAR (1ULL << 0) +#define RTE_ETH_BURST_VECTOR (1ULL << 1) +/**< bits[15:2] are reserved for each vector type */ +#define RTE_ETH_BURST_ALTIVEC (1ULL << 2) +#define RTE_ETH_BURST_NEON (1ULL << 3) +#define RTE_ETH_BURST_SSE (1ULL << 4) +#define RTE_ETH_BURST_AVX2 (1ULL << 5) +#define RTE_ETH_BURST_AVX512 (1ULL << 6) +/**< Support per queue burst */ +#define RTE_ETH_BURST_PER_QUEUE (1ULL << 63) /** * Ethernet device RX/TX queue packet burst mode information structure. * Used to retrieve information about packet burst mode setting. */ +#define RTE_ETH_BURST_MODE_ALT_OPT_SIZE 1024 struct rte_eth_burst_mode { uint64_t options; + + /**< Each PMD can fill specific burst mode information into this, and + * ethdev APIs will append the 'options' string format at its end. + */ + char alternate_options[RTE_ETH_BURST_MODE_ALT_OPT_SIZE]; }; /** Maximum name length for extended statistics counters */ @@ -3706,20 +3705,6 @@ __rte_experimental int rte_eth_tx_burst_mode_get(uint16_t port_id, uint16_t queue_id, struct rte_eth_burst_mode *mode); -/** - * Retrieve name about burst mode option. - * - * @param option - * The burst mode option of type *rte_eth_burst_mode_option*. - * - * @return - * - "": Not found - * - "xxx": name of the mode option. - */ -__rte_experimental -const char * -rte_eth_burst_mode_option_name(uint64_t option); - /** * Retrieve device registers and register attributes (number of registers and * register size) diff --git a/lib/librte_ethdev/rte_ethdev_version.map b/lib/librte_ethdev/rte_ethdev_version.map index e59d51648..5b00b9a40 100644 --- a/lib/librte_ethdev/rte_ethdev_version.map +++ b/lib/librte_ethdev/rte_ethdev_version.map @@ -287,5 +287,4 @@ EXPERIMENTAL { # added in 19.11 rte_eth_rx_burst_mode_get; rte_eth_tx_burst_mode_get; - rte_eth_burst_mode_option_name; }; -- 2.17.1