From patchwork Fri Aug 20 16:28:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ananyev, Konstantin" X-Patchwork-Id: 97171 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 3EB25A0C4D; Fri, 20 Aug 2021 18:29:49 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0535841226; Fri, 20 Aug 2021 18:29:40 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id 2034941226; Fri, 20 Aug 2021 18:29:37 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10082"; a="203946824" X-IronPort-AV: E=Sophos;i="5.84,338,1620716400"; d="scan'208";a="203946824" 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:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,338,1620716400"; d="scan'208";a="490551967" Received: from sivswdev08.ir.intel.com ([10.237.217.47]) by fmsmga008.fm.intel.com with ESMTP; 20 Aug 2021 09:29:35 -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:32 +0100 Message-Id: <20210820162834.12544-6-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 5/7] eth: make drivers to use new API to obtain descriptor status 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_descriptor_status() and tx_descriptor_status(). remove related function pointers from 'struct rte_eth_dev'. drivers/net: adjust to new API. Signed-off-by: Konstantin Ananyev --- drivers/net/i40e/i40e_ethdev.c | 6 +- drivers/net/i40e/i40e_ethdev_vf.c | 6 +- drivers/net/i40e/i40e_rxtx.c | 8 +- drivers/net/i40e/i40e_rxtx.h | 4 +- drivers/net/ice/ice_ethdev.c | 6 +- drivers/net/ice/ice_rxtx.c | 8 +- drivers/net/ice/ice_rxtx.h | 4 +- lib/ethdev/ethdev_driver.h | 132 ++++++++++++++++++++++++++++++ lib/ethdev/rte_ethdev.c | 45 +++++++++- lib/ethdev/rte_ethdev.h | 40 ++++----- lib/ethdev/rte_ethdev_core.h | 3 - lib/ethdev/version.map | 4 + 12 files changed, 221 insertions(+), 45 deletions(-) diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index bd6408da90..da5a7ec168 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -1435,8 +1435,10 @@ eth_i40e_dev_init(struct rte_eth_dev *dev, void *init_params __rte_unused) dev->dev_ops = &i40e_eth_dev_ops; dev->rx_queue_count = i40e_dev_rx_queue_count; dev->rx_descriptor_done = i40e_dev_rx_descriptor_done; - dev->rx_descriptor_status = i40e_dev_rx_descriptor_status; - dev->tx_descriptor_status = i40e_dev_tx_descriptor_status; + rte_eth_set_rx_desc_st(dev->data->port_id, + _RTE_ETH_FUNC(i40e_dev_rx_descriptor_status)); + rte_eth_set_tx_desc_st(dev->data->port_id, + _RTE_ETH_FUNC(i40e_dev_tx_descriptor_status)); rte_eth_set_rx_burst(dev->data->port_id, _RTE_ETH_FUNC(i40e_recv_pkts)); rte_eth_set_tx_burst(dev->data->port_id, _RTE_ETH_FUNC(i40e_xmit_pkts)); rte_eth_set_tx_prep(dev->data->port_id, _RTE_ETH_FUNC(i40e_prep_pkts)); diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c index 3755bdb66a..f1bd6d4e1b 100644 --- a/drivers/net/i40e/i40e_ethdev_vf.c +++ b/drivers/net/i40e/i40e_ethdev_vf.c @@ -1574,8 +1574,10 @@ i40evf_dev_init(struct rte_eth_dev *eth_dev) eth_dev->dev_ops = &i40evf_eth_dev_ops; eth_dev->rx_queue_count = i40e_dev_rx_queue_count; eth_dev->rx_descriptor_done = i40e_dev_rx_descriptor_done; - eth_dev->rx_descriptor_status = i40e_dev_rx_descriptor_status; - eth_dev->tx_descriptor_status = i40e_dev_tx_descriptor_status; + rte_eth_set_rx_desc_st(eth_dev->data->port_id, + _RTE_ETH_FUNC(i40e_dev_rx_descriptor_status)); + rte_eth_set_tx_desc_st(eth_dev->data->port_id, + _RTE_ETH_FUNC(i40e_dev_tx_descriptor_status)); rte_eth_set_rx_burst(eth_dev->data->port_id, _RTE_ETH_FUNC(i40e_recv_pkts)); rte_eth_set_tx_burst(eth_dev->data->port_id, diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c index 44c4d33879..310bb3f496 100644 --- a/drivers/net/i40e/i40e_rxtx.c +++ b/drivers/net/i40e/i40e_rxtx.c @@ -2189,7 +2189,7 @@ i40e_dev_rx_descriptor_done(void *rx_queue, uint16_t offset) return ret; } -int +static int i40e_dev_rx_descriptor_status(void *rx_queue, uint16_t offset) { struct i40e_rx_queue *rxq = rx_queue; @@ -2216,7 +2216,9 @@ i40e_dev_rx_descriptor_status(void *rx_queue, uint16_t offset) return RTE_ETH_RX_DESC_AVAIL; } -int +_RTE_ETH_RX_DESC_DEF(i40e_dev_rx_descriptor_status) + +static int i40e_dev_tx_descriptor_status(void *tx_queue, uint16_t offset) { struct i40e_tx_queue *txq = tx_queue; @@ -2247,6 +2249,8 @@ i40e_dev_tx_descriptor_status(void *tx_queue, uint16_t offset) return RTE_ETH_TX_DESC_FULL; } +_RTE_ETH_TX_DESC_DEF(i40e_dev_tx_descriptor_status) + static int i40e_dev_tx_queue_setup_runtime(struct rte_eth_dev *dev, struct i40e_tx_queue *txq) diff --git a/drivers/net/i40e/i40e_rxtx.h b/drivers/net/i40e/i40e_rxtx.h index 85bc29b23a..42b3407fe2 100644 --- a/drivers/net/i40e/i40e_rxtx.h +++ b/drivers/net/i40e/i40e_rxtx.h @@ -223,8 +223,8 @@ 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); int i40e_dev_rx_descriptor_done(void *rx_queue, uint16_t offset); -int i40e_dev_rx_descriptor_status(void *rx_queue, uint16_t offset); -int i40e_dev_tx_descriptor_status(void *tx_queue, uint16_t offset); +_RTE_ETH_RX_DESC_PROTO(i40e_dev_rx_descriptor_status); +_RTE_ETH_TX_DESC_PROTO(i40e_dev_tx_descriptor_status); _RTE_ETH_RX_PROTO(i40e_recv_pkts_vec); _RTE_ETH_RX_PROTO(i40e_recv_scattered_pkts_vec); diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index 42b6f5928d..8907737ba3 100644 --- a/drivers/net/ice/ice_ethdev.c +++ b/drivers/net/ice/ice_ethdev.c @@ -1994,8 +1994,10 @@ ice_dev_init(struct rte_eth_dev *dev) dev->dev_ops = &ice_eth_dev_ops; dev->rx_queue_count = ice_rx_queue_count; - dev->rx_descriptor_status = ice_rx_descriptor_status; - dev->tx_descriptor_status = ice_tx_descriptor_status; + 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, + _RTE_ETH_FUNC(ice_tx_descriptor_status)); rte_eth_set_rx_burst(dev->data->port_id, _RTE_ETH_FUNC(ice_recv_pkts)); rte_eth_set_tx_burst(dev->data->port_id, _RTE_ETH_FUNC(ice_xmit_pkts)); rte_eth_set_tx_prep(dev->data->port_id, _RTE_ETH_FUNC(ice_prep_pkts)); diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c index 2ddcbbb721..461135b4b4 100644 --- a/drivers/net/ice/ice_rxtx.c +++ b/drivers/net/ice/ice_rxtx.c @@ -2021,7 +2021,7 @@ ice_dev_supported_ptypes_get(struct rte_eth_dev *dev) return NULL; } -int +static int ice_rx_descriptor_status(void *rx_queue, uint16_t offset) { volatile union ice_rx_flex_desc *rxdp; @@ -2046,7 +2046,9 @@ ice_rx_descriptor_status(void *rx_queue, uint16_t offset) return RTE_ETH_RX_DESC_AVAIL; } -int +_RTE_ETH_RX_DESC_DEF(ice_rx_descriptor_status) + +static int ice_tx_descriptor_status(void *tx_queue, uint16_t offset) { struct ice_tx_queue *txq = tx_queue; @@ -2077,6 +2079,8 @@ ice_tx_descriptor_status(void *tx_queue, uint16_t offset) return RTE_ETH_TX_DESC_FULL; } +_RTE_ETH_TX_DESC_DEF(ice_tx_descriptor_status) + void ice_free_queues(struct rte_eth_dev *dev) { diff --git a/drivers/net/ice/ice_rxtx.h b/drivers/net/ice/ice_rxtx.h index 53f6080cc9..49418442eb 100644 --- a/drivers/net/ice/ice_rxtx.h +++ b/drivers/net/ice/ice_rxtx.h @@ -228,8 +228,8 @@ int ice_rx_burst_mode_get(struct rte_eth_dev *dev, uint16_t queue_id, struct rte_eth_burst_mode *mode); int ice_tx_burst_mode_get(struct rte_eth_dev *dev, uint16_t queue_id, struct rte_eth_burst_mode *mode); -int ice_rx_descriptor_status(void *rx_queue, uint16_t offset); -int ice_tx_descriptor_status(void *tx_queue, uint16_t offset); +_RTE_ETH_RX_DESC_PROTO(ice_rx_descriptor_status); +_RTE_ETH_TX_DESC_PROTO(ice_tx_descriptor_status); void ice_set_default_ptype_table(struct rte_eth_dev *dev); const uint32_t *ice_dev_supported_ptypes_get(struct rte_eth_dev *dev); void ice_select_rxd_to_pkt_fields_handler(struct ice_rx_queue *rxq, diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h index fe1b4fc349..eec56189a0 100644 --- a/lib/ethdev/ethdev_driver.h +++ b/lib/ethdev/ethdev_driver.h @@ -1789,6 +1789,138 @@ rte_eth_tx_prep_t rte_eth_get_tx_prep(uint16_t port_id); __rte_experimental int rte_eth_set_tx_prep(uint16_t port_id, rte_eth_tx_prep_t txf); +/** + * @internal + * Helper routine for eth driver rx_descriptor_status API. + * Should be called as first thing on entrance to the PMD's + * rx_descriptor_status implementation. + * Does necessary checks and retrieves pointer to device RX queue. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param queue_id + * The index of the receive queue. + * @param rxq + * The output pointer to the RX queue structure. + * + * @return + * Zero on success or negative error code otherwise. + */ +__rte_internal +static inline int +_rte_eth_rx_desc_prolog(uint16_t port_id, uint16_t queue_id, void **rxq) +{ + struct rte_eth_dev *dev; + +#ifdef RTE_ETHDEV_DEBUG_RX + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); +#endif + dev = &rte_eth_devices[port_id]; +#ifdef RTE_ETHDEV_DEBUG_RX + if (queue_id >= dev->data->nb_rx_queues) + return -ENODEV; +#endif + *rxq = dev->data->rx_queues[queue_id]; + return 0; +} + +/** + * @internal + * Helper macro to create new API wrappers for existing PMD rx_descriptor_status + * functions. + */ +#define _RTE_ETH_RX_DESC_PROTO(fn) \ + int _RTE_ETH_FUNC(fn)(uint16_t port_id, uint16_t queue_id, \ + uint16_t offset) + +/** + * @internal + * Helper macro to create new API wrappers for existing PMD rx_descriptor_status + * functions. + */ +#define _RTE_ETH_RX_DESC_DEF(fn) \ +_RTE_ETH_RX_DESC_PROTO(fn) \ +{ \ + int rc; \ + void *rxq; \ + rc = _rte_eth_rx_desc_prolog(port_id, queue_id, &rxq); \ + if (rc != 0) \ + return rc; \ + return fn(rxq, offset); \ +} + +__rte_experimental +rte_eth_rx_descriptor_status_t rte_eth_get_rx_desc_st(uint16_t port_id); + +__rte_experimental +int rte_eth_set_rx_desc_st(uint16_t port_id, rte_eth_rx_descriptor_status_t rf); + +/** + * @internal + * Helper routine for eth driver tx_descriptor_status API. + * Should be called as first thing on entrance to the PMD's + * tx_descriptor_status implementation. + * Does necessary checks and retrieves pointer to device TX queue. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param queue_id + * The index of the transmit queue. + * @param txq + * The output pointer to the TX queue structure. + * + * @return + * Zero on success or negative error code otherwise. + */ +__rte_internal +static inline int +_rte_eth_tx_desc_prolog(uint16_t port_id, uint16_t queue_id, void **txq) +{ + struct rte_eth_dev *dev; + +#ifdef RTE_ETHDEV_DEBUG_TX + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); +#endif + dev = &rte_eth_devices[port_id]; +#ifdef RTE_ETHDEV_DEBUG_TX + if (queue_id >= dev->data->nb_tx_queues) + return -ENODEV; +#endif + *txq = dev->data->tx_queues[queue_id]; + return 0; +} + +/** + * @internal + * Helper macro to create new API wrappers for existing PMD tx_descriptor_status + * functions. + */ +#define _RTE_ETH_TX_DESC_PROTO(fn) \ + int _RTE_ETH_FUNC(fn)(uint16_t port_id, uint16_t queue_id, \ + uint16_t offset) + +/** + * @internal + * Helper macro to create new API wrappers for existing PMD tx_descriptor_status + * functions. + */ +#define _RTE_ETH_TX_DESC_DEF(fn) \ +_RTE_ETH_TX_DESC_PROTO(fn) \ +{ \ + int rc; \ + void *txq; \ + rc = _rte_eth_tx_desc_prolog(port_id, queue_id, &txq); \ + if (rc != 0) \ + return rc; \ + return fn(txq, offset); \ +} + +__rte_experimental +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); + #ifdef __cplusplus } #endif diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index 6b1d9c5f83..e48d1ec281 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -590,8 +590,6 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev) eth_dev->intr_handle = NULL; eth_dev->rx_queue_count = NULL; eth_dev->rx_descriptor_done = NULL; - eth_dev->rx_descriptor_status = NULL; - eth_dev->tx_descriptor_status = NULL; eth_dev->dev_ops = NULL; if (rte_eal_process_type() == RTE_PROC_PRIMARY) { @@ -6400,3 +6398,46 @@ rte_eth_set_tx_prep(uint16_t port_id, rte_eth_tx_prep_t tpf) rte_eth_burst_api[port_id].tx_pkt_prepare = tpf; return 0; } + +__rte_experimental +rte_eth_rx_descriptor_status_t +rte_eth_get_rx_desc_st(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_descriptor_status; +} + +__rte_experimental +int +rte_eth_set_rx_desc_st(uint16_t port_id, rte_eth_rx_descriptor_status_t rf) +{ + if (port_id >= RTE_DIM(rte_eth_burst_api)) + return -EINVAL; + + rte_eth_burst_api[port_id].rx_descriptor_status = rf; + return 0; +} + +rte_eth_tx_descriptor_status_t +rte_eth_get_tx_desc_st(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].tx_descriptor_status; +} + +__rte_experimental +int +rte_eth_set_tx_desc_st(uint16_t port_id, rte_eth_tx_descriptor_status_t tf) +{ + if (port_id >= RTE_DIM(rte_eth_burst_api)) + return -EINVAL; + + rte_eth_burst_api[port_id].tx_descriptor_status = tf; + return 0; +} diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h index 01fd1c99c3..073b532b7b 100644 --- a/lib/ethdev/rte_ethdev.h +++ b/lib/ethdev/rte_ethdev.h @@ -5082,21 +5082,15 @@ static inline int rte_eth_rx_descriptor_status(uint16_t port_id, uint16_t queue_id, uint16_t offset) { - struct rte_eth_dev *dev; - void *rxq; + rte_eth_rx_descriptor_status_t rds; -#ifdef RTE_ETHDEV_DEBUG_RX - RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); -#endif - dev = &rte_eth_devices[port_id]; -#ifdef RTE_ETHDEV_DEBUG_RX - if (queue_id >= dev->data->nb_rx_queues) - return -ENODEV; -#endif - RTE_FUNC_PTR_OR_ERR_RET(*dev->rx_descriptor_status, -ENOTSUP); - rxq = dev->data->rx_queues[queue_id]; + if (port_id >= RTE_MAX_ETHPORTS) + return -EINVAL; + + rds = rte_eth_burst_api[port_id].rx_descriptor_status; + RTE_FUNC_PTR_OR_ERR_RET(rds, -ENOTSUP); - return (*dev->rx_descriptor_status)(rxq, offset); + return (rds)(port_id, queue_id, offset); } #define RTE_ETH_TX_DESC_FULL 0 /**< Desc filled for hw, waiting xmit. */ @@ -5139,21 +5133,15 @@ rte_eth_rx_descriptor_status(uint16_t port_id, uint16_t queue_id, static inline int rte_eth_tx_descriptor_status(uint16_t port_id, uint16_t queue_id, uint16_t offset) { - struct rte_eth_dev *dev; - void *txq; + rte_eth_tx_descriptor_status_t tds; -#ifdef RTE_ETHDEV_DEBUG_TX - RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); -#endif - dev = &rte_eth_devices[port_id]; -#ifdef RTE_ETHDEV_DEBUG_TX - if (queue_id >= dev->data->nb_tx_queues) - return -ENODEV; -#endif - RTE_FUNC_PTR_OR_ERR_RET(*dev->tx_descriptor_status, -ENOTSUP); - txq = dev->data->tx_queues[queue_id]; + if (port_id >= RTE_MAX_ETHPORTS) + return -EINVAL; + + tds = rte_eth_burst_api[port_id].tx_descriptor_status; + RTE_FUNC_PTR_OR_ERR_RET(tds, -ENOTSUP); - return (*dev->tx_descriptor_status)(txq, offset); + return (tds)(port_id, queue_id, offset); } /** diff --git a/lib/ethdev/rte_ethdev_core.h b/lib/ethdev/rte_ethdev_core.h index 2d4600af4d..1e42bacfce 100644 --- a/lib/ethdev/rte_ethdev_core.h +++ b/lib/ethdev/rte_ethdev_core.h @@ -117,9 +117,6 @@ struct rte_eth_rxtx_callback { 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. */ - eth_rx_descriptor_status_t rx_descriptor_status; /**< Check the status of a Rx descriptor. */ - eth_tx_descriptor_status_t tx_descriptor_status; /**< Check the status of a Tx descriptor. */ - /** * Next two fields are per-device data but *data is shared between * primary and secondary processes and *process_private is per-process diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map index b26fd478aa..802d9c3c11 100644 --- a/lib/ethdev/version.map +++ b/lib/ethdev/version.map @@ -253,9 +253,13 @@ EXPERIMENTAL { # added in 21.11 rte_eth_burst_api; rte_eth_get_rx_burst; + rte_eth_get_rx_desc_st; + rte_eth_get_tx_desc_st; rte_eth_get_tx_burst; 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_tx_burst; rte_eth_set_tx_prep; };