From patchwork Fri Aug 20 16:28:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ananyev, Konstantin" X-Patchwork-Id: 97172 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B5915A0C4D; Fri, 20 Aug 2021 18:29:58 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9738241250; Fri, 20 Aug 2021 18:29:44 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id 7820E4121F; Fri, 20 Aug 2021 18:29:42 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10082"; a="203946828" X-IronPort-AV: E=Sophos;i="5.84,338,1620716400"; d="scan'208";a="203946828" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2021 09:29:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,338,1620716400"; d="scan'208";a="490551977" Received: from sivswdev08.ir.intel.com ([10.237.217.47]) by fmsmga008.fm.intel.com with ESMTP; 20 Aug 2021 09:29:39 -0700 From: Konstantin Ananyev To: dev@dpdk.org Cc: thomas@monjalon.net, ferruh.yigit@intel.com, andrew.rybchenko@oktetlabs.ru, qiming.yang@intel.com, qi.z.zhang@intel.com, beilei.xing@intel.com, techboard@dpdk.org, Konstantin Ananyev Date: Fri, 20 Aug 2021 17:28:33 +0100 Message-Id: <20210820162834.12544-7-konstantin.ananyev@intel.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210820162834.12544-1-konstantin.ananyev@intel.com> References: <20210820162834.12544-1-konstantin.ananyev@intel.com> Subject: [dpdk-dev] [RFC 6/7] eth: make drivers to use new API for Rx queue count X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" ethdev: - make changes so drivers can start using new API for rx_queue_count(). - provide helper functions/macros. - remove rx_queue_count() from 'struct rte_eth_dev'. drivers/net: - adjust to new rx_queue_count() API. Signed-off-by: Konstantin Ananyev --- drivers/net/i40e/i40e_ethdev.c | 3 +- drivers/net/i40e/i40e_ethdev_vf.c | 3 +- drivers/net/i40e/i40e_rxtx.c | 4 ++- drivers/net/i40e/i40e_rxtx.h | 3 +- drivers/net/ice/ice_ethdev.c | 3 +- drivers/net/ice/ice_rxtx.c | 4 ++- drivers/net/ice/ice_rxtx.h | 2 +- lib/ethdev/ethdev_driver.h | 58 +++++++++++++++++++++++++++++++ lib/ethdev/rte_ethdev.c | 24 ++++++++++++- lib/ethdev/rte_ethdev.h | 13 ++++--- lib/ethdev/rte_ethdev_core.h | 1 - lib/ethdev/version.map | 6 ++-- 12 files changed, 105 insertions(+), 19 deletions(-) diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index da5a7ec168..a99363659a 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -1433,7 +1433,8 @@ eth_i40e_dev_init(struct rte_eth_dev *dev, void *init_params __rte_unused) PMD_INIT_FUNC_TRACE(); dev->dev_ops = &i40e_eth_dev_ops; - dev->rx_queue_count = i40e_dev_rx_queue_count; + rte_eth_set_rx_qcnt(dev->data->port_id, + _RTE_ETH_FUNC(i40e_dev_rx_queue_count)); dev->rx_descriptor_done = i40e_dev_rx_descriptor_done; rte_eth_set_rx_desc_st(dev->data->port_id, _RTE_ETH_FUNC(i40e_dev_rx_descriptor_status)); diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c index f1bd6d4e1b..0da30f6784 100644 --- a/drivers/net/i40e/i40e_ethdev_vf.c +++ b/drivers/net/i40e/i40e_ethdev_vf.c @@ -1572,7 +1572,8 @@ i40evf_dev_init(struct rte_eth_dev *eth_dev) /* assign ops func pointer */ eth_dev->dev_ops = &i40evf_eth_dev_ops; - eth_dev->rx_queue_count = i40e_dev_rx_queue_count; + rte_eth_set_rx_qcnt(eth_dev->data->port_id, + _RTE_ETH_FUNC(i40e_dev_rx_queue_count)); eth_dev->rx_descriptor_done = i40e_dev_rx_descriptor_done; rte_eth_set_rx_desc_st(eth_dev->data->port_id, _RTE_ETH_FUNC(i40e_dev_rx_descriptor_status)); diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c index 310bb3f496..f0f42c41b2 100644 --- a/drivers/net/i40e/i40e_rxtx.c +++ b/drivers/net/i40e/i40e_rxtx.c @@ -2134,7 +2134,7 @@ i40e_dev_rx_queue_release(void *rxq) rte_free(q); } -uint32_t +static uint32_t i40e_dev_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id) { #define I40E_RXQ_SCAN_INTERVAL 4 @@ -2163,6 +2163,8 @@ i40e_dev_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id) return desc; } +_RTE_ETH_RX_QCNT_DEF(i40e_dev_rx_queue_count) + int i40e_dev_rx_descriptor_done(void *rx_queue, uint16_t offset) { diff --git a/drivers/net/i40e/i40e_rxtx.h b/drivers/net/i40e/i40e_rxtx.h index 42b3407fe2..3d98b1f9fb 100644 --- a/drivers/net/i40e/i40e_rxtx.h +++ b/drivers/net/i40e/i40e_rxtx.h @@ -220,8 +220,7 @@ int i40e_tx_done_cleanup(void *txq, uint32_t free_cnt); int i40e_alloc_rx_queue_mbufs(struct i40e_rx_queue *rxq); void i40e_rx_queue_release_mbufs(struct i40e_rx_queue *rxq); -uint32_t i40e_dev_rx_queue_count(struct rte_eth_dev *dev, - uint16_t rx_queue_id); +_RTE_ETH_RX_QCNT_PROTO(i40e_dev_rx_queue_count); int i40e_dev_rx_descriptor_done(void *rx_queue, uint16_t offset); _RTE_ETH_RX_DESC_PROTO(i40e_dev_rx_descriptor_status); _RTE_ETH_TX_DESC_PROTO(i40e_dev_tx_descriptor_status); diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index 8907737ba3..cb27f2f501 100644 --- a/drivers/net/ice/ice_ethdev.c +++ b/drivers/net/ice/ice_ethdev.c @@ -1993,7 +1993,8 @@ ice_dev_init(struct rte_eth_dev *dev) #endif dev->dev_ops = &ice_eth_dev_ops; - dev->rx_queue_count = ice_rx_queue_count; + rte_eth_set_rx_qcnt(dev->data->port_id, + _RTE_ETH_FUNC(ice_rx_queue_count)); rte_eth_set_rx_desc_st(dev->data->port_id, _RTE_ETH_FUNC(ice_rx_descriptor_status)); rte_eth_set_tx_desc_st(dev->data->port_id, diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c index 461135b4b4..e7af0a649b 100644 --- a/drivers/net/ice/ice_rxtx.c +++ b/drivers/net/ice/ice_rxtx.c @@ -1426,7 +1426,7 @@ ice_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id, qinfo->conf.tx_deferred_start = txq->tx_deferred_start; } -uint32_t +static uint32_t ice_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id) { #define ICE_RXQ_SCAN_INTERVAL 4 @@ -1454,6 +1454,8 @@ ice_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id) return desc; } +_RTE_ETH_RX_QCNT_DEF(ice_rx_queue_count) + #define ICE_RX_FLEX_ERR0_BITS \ ((1 << ICE_RX_FLEX_DESC_STATUS0_HBO_S) | \ (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_IPE_S) | \ diff --git a/drivers/net/ice/ice_rxtx.h b/drivers/net/ice/ice_rxtx.h index 49418442eb..d1e0a8b011 100644 --- a/drivers/net/ice/ice_rxtx.h +++ b/drivers/net/ice/ice_rxtx.h @@ -219,7 +219,7 @@ _RTE_ETH_TX_PROTO(ice_prep_pkts); void ice_set_tx_function_flag(struct rte_eth_dev *dev, struct ice_tx_queue *txq); void ice_set_tx_function(struct rte_eth_dev *dev); -uint32_t ice_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id); +_RTE_ETH_RX_QCNT_PROTO(ice_rx_queue_count); void ice_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id, struct rte_eth_rxq_info *qinfo); void ice_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id, diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h index eec56189a0..accaf1aab2 100644 --- a/lib/ethdev/ethdev_driver.h +++ b/lib/ethdev/ethdev_driver.h @@ -1921,6 +1921,64 @@ rte_eth_tx_descriptor_status_t rte_eth_get_tx_desc_st(uint16_t port_id); __rte_experimental int rte_eth_set_tx_desc_st(uint16_t port_id, rte_eth_tx_descriptor_status_t rf); +/** + * @internal + * Helper routine for eth driver rx_queue_count API. + * Should be called as first thing on entrance to the PMD's + * rx_queue_count implementation. + * Does necessary checks for input parameters. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param queue_id + * The index of the receive queue. + * + * @return + * Zero on success or negative error code otherwise. + */ +__rte_internal +static inline int +_rte_eth_rx_qcnt_prolog(uint16_t port_id, uint16_t queue_id) +{ + struct rte_eth_dev *dev; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + dev = &rte_eth_devices[port_id]; + if (queue_id >= dev->data->nb_rx_queues || + dev->data->rx_queues[queue_id] == NULL) + return -EINVAL; + return 0; +} + +/** + * @internal + * Helper macro to create new API wrappers for existing PMD rx_queue_count + * functions. + */ +#define _RTE_ETH_RX_QCNT_PROTO(fn) \ + int _RTE_ETH_FUNC(fn)(uint16_t port_id, uint16_t queue_id) + +/** + * @internal + * Helper macro to create new API wrappers for existing PMD rx_queue_count + * functions. + */ +#define _RTE_ETH_RX_QCNT_DEF(fn) \ +_RTE_ETH_RX_QCNT_PROTO(fn) \ +{ \ + int rc; \ + rc = _rte_eth_rx_qcnt_prolog(port_id, queue_id); \ + if (rc != 0) \ + return rc; \ + return fn(&rte_eth_devices[port_id], queue_id); \ +} + +__rte_experimental +rte_eth_rx_queue_count_t rte_eth_get_rx_qcnt(uint16_t port_id); + +__rte_experimental +int rte_eth_set_rx_qcnt(uint16_t port_id, rte_eth_rx_queue_count_t rf); + #ifdef __cplusplus } #endif diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index e48d1ec281..0cc9f40e95 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -588,7 +588,6 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev) eth_dev->device = NULL; eth_dev->process_private = NULL; eth_dev->intr_handle = NULL; - eth_dev->rx_queue_count = NULL; eth_dev->rx_descriptor_done = NULL; eth_dev->dev_ops = NULL; @@ -6421,6 +6420,7 @@ rte_eth_set_rx_desc_st(uint16_t port_id, rte_eth_rx_descriptor_status_t rf) return 0; } +__rte_experimental rte_eth_tx_descriptor_status_t rte_eth_get_tx_desc_st(uint16_t port_id) { @@ -6441,3 +6441,25 @@ rte_eth_set_tx_desc_st(uint16_t port_id, rte_eth_tx_descriptor_status_t tf) rte_eth_burst_api[port_id].tx_descriptor_status = tf; return 0; } + +__rte_experimental +rte_eth_rx_queue_count_t +rte_eth_get_rx_qcnt(uint16_t port_id) +{ + if (port_id >= RTE_DIM(rte_eth_burst_api)) { + rte_errno = EINVAL; + return NULL; + } + return rte_eth_burst_api[port_id].rx_queue_count; +} + +__rte_experimental +int +rte_eth_set_rx_qcnt(uint16_t port_id, rte_eth_rx_queue_count_t rf) +{ + if (port_id >= RTE_DIM(rte_eth_burst_api)) + return -EINVAL; + + rte_eth_burst_api[port_id].rx_queue_count = rf; + return 0; +} diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h index 073b532b7b..73aeef8c36 100644 --- a/lib/ethdev/rte_ethdev.h +++ b/lib/ethdev/rte_ethdev.h @@ -5004,16 +5004,15 @@ rte_eth_rx_burst(uint16_t port_id, uint16_t queue_id, static inline int rte_eth_rx_queue_count(uint16_t port_id, uint16_t queue_id) { - struct rte_eth_dev *dev; + rte_eth_rx_queue_count_t rqc; - RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); - dev = &rte_eth_devices[port_id]; - RTE_FUNC_PTR_OR_ERR_RET(*dev->rx_queue_count, -ENOTSUP); - if (queue_id >= dev->data->nb_rx_queues || - dev->data->rx_queues[queue_id] == NULL) + if (port_id >= RTE_MAX_ETHPORTS) return -EINVAL; - return (int)(*dev->rx_queue_count)(dev, queue_id); + rqc = rte_eth_burst_api[port_id].rx_queue_count; + RTE_FUNC_PTR_OR_ERR_RET(rqc, -ENOTSUP); + + return (rqc)(port_id, queue_id); } /** diff --git a/lib/ethdev/rte_ethdev_core.h b/lib/ethdev/rte_ethdev_core.h index 1e42bacfce..53dd5c2114 100644 --- a/lib/ethdev/rte_ethdev_core.h +++ b/lib/ethdev/rte_ethdev_core.h @@ -115,7 +115,6 @@ struct rte_eth_rxtx_callback { * process, while the actual configuration data for the device is shared. */ struct rte_eth_dev { - eth_rx_queue_count_t rx_queue_count; /**< Get the number of used RX descriptors. */ eth_rx_descriptor_done_t rx_descriptor_done; /**< Check rxd DD bit. */ /** * Next two fields are per-device data but *data is shared between diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map index 802d9c3c11..ff838fef53 100644 --- a/lib/ethdev/version.map +++ b/lib/ethdev/version.map @@ -254,13 +254,15 @@ EXPERIMENTAL { rte_eth_burst_api; rte_eth_get_rx_burst; rte_eth_get_rx_desc_st; - rte_eth_get_tx_desc_st; + rte_eth_get_rx_qcnt; rte_eth_get_tx_burst; + rte_eth_get_tx_desc_st; rte_eth_get_tx_prep; rte_eth_set_rx_burst; rte_eth_set_rx_desc_st; - rte_eth_set_tx_desc_st; + rte_eth_set_rx_qcnt; rte_eth_set_tx_burst; + rte_eth_set_tx_desc_st; rte_eth_set_tx_prep; };