From patchwork Tue Sep 10 16:33:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Haiyue" X-Patchwork-Id: 59103 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 969231EF42; Tue, 10 Sep 2019 18:39:14 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 52A451EDB4 for ; Tue, 10 Sep 2019 18:39:10 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Sep 2019 09:39:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,490,1559545200"; d="scan'208";a="178732643" Received: from npg-dpdk-haiyue-1.sh.intel.com ([10.67.119.115]) by orsmga008.jf.intel.com with ESMTP; 10 Sep 2019 09:39:08 -0700 From: Haiyue Wang To: dev@dpdk.org, ferruh.yigit@intel.com, mdr@ashroe.eu, chenmin.sun@intel.com Cc: Haiyue Wang Date: Wed, 11 Sep 2019 00:33:34 +0800 Message-Id: <20190910163337.4843-2-haiyue.wang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190910163337.4843-1-haiyue.wang@intel.com> References: <20190910163337.4843-1-haiyue.wang@intel.com> Subject: [dpdk-dev] [RFC v3 1/4] ethdev: add 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" Some PMDs have more than one RX/TX burst paths, add the ethdev API that allows an application to retrieve the mode information about Rx/Tx packet burst such as Scalar or Vector, and Vector technology like AVX2. Signed-off-by: Haiyue Wang --- doc/guides/rel_notes/release_19_11.rst | 8 +++ lib/librte_ethdev/rte_ethdev.c | 75 ++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 82 ++++++++++++++++++++++++ lib/librte_ethdev/rte_ethdev_core.h | 5 ++ lib/librte_ethdev/rte_ethdev_version.map | 5 ++ 5 files changed, 175 insertions(+) diff --git a/doc/guides/rel_notes/release_19_11.rst b/doc/guides/rel_notes/release_19_11.rst index 27cfbd9e3..1d80e50fb 100644 --- a/doc/guides/rel_notes/release_19_11.rst +++ b/doc/guides/rel_notes/release_19_11.rst @@ -56,6 +56,14 @@ New Features Also, make sure to start the actual text at the margin. ========================================================= +* **Added RX/TX packet burst mode get API.** + + Added two new functions ``rte_eth_rx_burst_mode_get`` and + ``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. Removed Items ------------- diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 17d183e1f..aac0a81e9 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -4082,6 +4082,81 @@ rte_eth_tx_queue_info_get(uint16_t port_id, uint16_t queue_id, 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; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + + if (mode == NULL) + return -EINVAL; + + dev = &rte_eth_devices[port_id]; + + if (queue_id >= dev->data->nb_rx_queues) { + RTE_ETHDEV_LOG(ERR, "Invalid RX queue_id=%u\n", queue_id); + return -EINVAL; + } + + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_burst_mode_get, -ENOTSUP); + + memset(mode, 0, sizeof(*mode)); + dev->dev_ops->rx_burst_mode_get(dev, queue_id, mode); + + return 0; +} + +int +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; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + + if (mode == NULL) + return -EINVAL; + + dev = &rte_eth_devices[port_id]; + + if (queue_id >= dev->data->nb_tx_queues) { + RTE_ETHDEV_LOG(ERR, "Invalid TX queue_id=%u\n", queue_id); + return -EINVAL; + } + + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_burst_mode_get, -ENOTSUP); + + memset(mode, 0, sizeof(*mode)); + dev->dev_ops->tx_burst_mode_get(dev, queue_id, mode); + + return 0; +} + +const char * +rte_eth_burst_mode_option_name(uint64_t option) +{ + switch (option) { + case RTE_ETH_BURST_SCALAR: return "Scalar"; + case RTE_ETH_BURST_VECTOR: return "Vector"; + + case RTE_ETH_BURST_ALTIVEC: return "AltiVec"; + case RTE_ETH_BURST_NEON: return "Neon"; + case RTE_ETH_BURST_SSE: return "SSE"; + case RTE_ETH_BURST_AVX2: return "AVX2"; + case RTE_ETH_BURST_AVX512: return "AVX512"; + + case RTE_ETH_BURST_SCATTERED: return "Scattered"; + case RTE_ETH_BURST_BULK_ALLOC: return "Bulk Alloc"; + case RTE_ETH_BURST_SIMPLE: return "Simple"; + + case RTE_ETH_BURST_PER_QUEUE: return "Per Queue"; + } + + return ""; +} + int rte_eth_dev_set_mc_addr_list(uint16_t port_id, struct rte_ether_addr *mc_addr_set, diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h index d9871782e..1c5c23160 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -1212,6 +1212,32 @@ struct rte_eth_txq_info { uint16_t nb_desc; /**< configured number of TXDs. */ } __rte_cache_min_aligned; +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 */ +}; + +/** + * Ethernet device RX/TX queue packet burst mode information structure. + * Used to retrieve information about packet burst mode setting. + */ +struct rte_eth_burst_mode { + uint64_t options; +}; + /** Maximum name length for extended statistics counters */ #define RTE_ETH_XSTATS_NAME_SIZE 64 @@ -3556,6 +3582,62 @@ int rte_eth_rx_queue_info_get(uint16_t port_id, uint16_t queue_id, int rte_eth_tx_queue_info_get(uint16_t port_id, uint16_t queue_id, struct rte_eth_txq_info *qinfo); +/** + * Retrieve information about the Rx packet burst mode. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param queue_id + * The Rx queue on the Ethernet device for which information + * will be retrieved. + * @param mode + * A pointer to a structure of type *rte_eth_burst_mode* to be filled + * with the information of the packet burst mode. + * + * @return + * - 0: Success + * - -ENOTSUP: routine is not supported by the device PMD. + * - -EINVAL: The port_id or the queue_id is out of range. + */ +__rte_experimental +int rte_eth_rx_burst_mode_get(uint16_t port_id, uint16_t queue_id, + struct rte_eth_burst_mode *mode); + +/** + * Retrieve information about the Tx packet burst mode. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param queue_id + * The Tx queue on the Ethernet device for which information + * will be retrieved. + * @param mode + * A pointer to a structure of type *rte_eth_burst_mode* to be filled + * with the information of the packet burst mode. + * + * @return + * - 0: Success + * - -ENOTSUP: routine is not supported by the device PMD. + * - -EINVAL: The port_id or the queue_id is out of range. + */ +__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 mode + * 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_core.h b/lib/librte_ethdev/rte_ethdev_core.h index 2922d5b7c..f28c3da8e 100644 --- a/lib/librte_ethdev/rte_ethdev_core.h +++ b/lib/librte_ethdev/rte_ethdev_core.h @@ -170,6 +170,9 @@ typedef void (*eth_rxq_info_get_t)(struct rte_eth_dev *dev, typedef void (*eth_txq_info_get_t)(struct rte_eth_dev *dev, uint16_t tx_queue_id, struct rte_eth_txq_info *qinfo); +typedef void (*eth_burst_mode_get_t)(struct rte_eth_dev *dev, + uint16_t queue_id, struct rte_eth_burst_mode *mode); + typedef int (*mtu_set_t)(struct rte_eth_dev *dev, uint16_t mtu); /**< @internal Set MTU. */ @@ -418,6 +421,8 @@ struct eth_dev_ops { eth_dev_infos_get_t dev_infos_get; /**< Get device info. */ eth_rxq_info_get_t rxq_info_get; /**< retrieve RX queue information. */ eth_txq_info_get_t txq_info_get; /**< retrieve TX queue information. */ + eth_burst_mode_get_t rx_burst_mode_get; /**< Get RX burst mode */ + eth_burst_mode_get_t tx_burst_mode_get; /**< Get TX burst mode */ eth_fw_version_get_t fw_version_get; /**< Get firmware version. */ eth_dev_supported_ptypes_get_t dev_supported_ptypes_get; /**< Get packet types supported and identified by device. */ diff --git a/lib/librte_ethdev/rte_ethdev_version.map b/lib/librte_ethdev/rte_ethdev_version.map index 6df42a47b..e59d51648 100644 --- a/lib/librte_ethdev/rte_ethdev_version.map +++ b/lib/librte_ethdev/rte_ethdev_version.map @@ -283,4 +283,9 @@ EXPERIMENTAL { # added in 19.08 rte_eth_read_clock; + + # added in 19.11 + rte_eth_rx_burst_mode_get; + rte_eth_tx_burst_mode_get; + rte_eth_burst_mode_option_name; };