From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Cc: Bruce Richardson <bruce.richardson@intel.com>,
Ian Stokes <ian.stokes@intel.com>,
Vladimir Medvedkin <vladimir.medvedkin@intel.com>,
Konstantin Ananyev <konstantin.v.ananyev@yandex.ru>,
Anatoly Burakov <anatoly.burakov@intel.com>
Subject: [RFC PATCH 17/21] net/iavf: use common Tx queue mbuf cleanup fn
Date: Fri, 22 Nov 2024 12:54:10 +0000 [thread overview]
Message-ID: <20241122125418.2857301-18-bruce.richardson@intel.com> (raw)
In-Reply-To: <20241122125418.2857301-1-bruce.richardson@intel.com>
Adjust iavf driver to also use the common mbuf freeing functions on Tx
queue release/cleanup. The implementation is complicated a little by the
need to integrate the additional "has_ctx" parameter for the iavf code,
but changes in other drivers are minimal - just a constant "false"
parameter.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
drivers/common/intel_eth/ieth_rxtx.h | 19 +++++++------
drivers/net/i40e/i40e_rxtx.c | 6 ++--
drivers/net/iavf/iavf_rxtx.c | 37 ++-----------------------
drivers/net/iavf/iavf_rxtx_vec_avx512.c | 24 ++--------------
drivers/net/iavf/iavf_rxtx_vec_common.h | 18 ------------
drivers/net/iavf/iavf_rxtx_vec_sse.c | 9 ++----
drivers/net/ice/ice_dcf_ethdev.c | 4 +--
drivers/net/ice/ice_rxtx.c | 6 ++--
drivers/net/ixgbe/ixgbe_rxtx.c | 6 ++--
9 files changed, 28 insertions(+), 101 deletions(-)
diff --git a/drivers/common/intel_eth/ieth_rxtx.h b/drivers/common/intel_eth/ieth_rxtx.h
index c8e5e1ad76..dad1ba4ae1 100644
--- a/drivers/common/intel_eth/ieth_rxtx.h
+++ b/drivers/common/intel_eth/ieth_rxtx.h
@@ -83,7 +83,6 @@ struct ieth_tx_queue {
};
struct { /* iavf driver specific values */
uint16_t ipsec_crypto_pkt_md_offset;
- uint8_t rel_mbufs_type;
#define IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG1 BIT(0)
#define IAVF_TX_FLAGS_VLAN_TAG_LOC_L2TAG2 BIT(1)
uint8_t vlan_flag;
@@ -103,23 +102,23 @@ struct ieth_tx_queue {
};
};
-#define IETH_FREE_BUFS_LOOP(txq, swr, start) do { \
+#define IETH_FREE_BUFS_LOOP(swr, nb_desc, start, end) do { \
uint16_t i = start; \
- if (txq->tx_tail < i) { \
- for (; i < txq->nb_tx_desc; i++) { \
+ if (end < i) { \
+ for (; i < nb_desc; i++) { \
rte_pktmbuf_free_seg(swr[i].mbuf); \
swr[i].mbuf = NULL; \
} \
i = 0; \
} \
- for (; i < txq->tx_tail; i++) { \
+ for (; i < end; i++) { \
rte_pktmbuf_free_seg(swr[i].mbuf); \
swr[i].mbuf = NULL; \
} \
} while(0)
static inline void
-ieth_txq_release_all_mbufs(struct ieth_tx_queue *txq)
+ieth_txq_release_all_mbufs(struct ieth_tx_queue *txq, bool use_ctx)
{
if (unlikely(!txq || !txq->sw_ring))
return;
@@ -138,14 +137,16 @@ ieth_txq_release_all_mbufs(struct ieth_tx_queue *txq)
* vPMD tx will not set sw_ring's mbuf to NULL after free,
* so need to free remains more carefully.
*/
- const uint16_t start = txq->tx_next_dd - txq->tx_rs_thresh + 1;
+ const uint16_t start = (txq->tx_next_dd - txq->tx_rs_thresh + 1) >> use_ctx;
+ const uint16_t nb_desc = txq->nb_tx_desc >> use_ctx;
+ const uint16_t end = txq->tx_tail >> use_ctx;
if (txq->vector_sw_ring) {
struct ieth_vec_tx_entry *swr = txq->sw_ring_v;
- IETH_FREE_BUFS_LOOP(txq, swr, start);
+ IETH_FREE_BUFS_LOOP(swr, nb_desc, start, end);
} else {
struct ieth_tx_entry *swr = txq->sw_ring;
- IETH_FREE_BUFS_LOOP(txq, swr, start);
+ IETH_FREE_BUFS_LOOP(swr, nb_desc, start, end);
}
}
diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index 362a71c8b2..4878b9b8aa 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -1934,7 +1934,7 @@ i40e_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
return err;
}
- ieth_txq_release_all_mbufs(txq);
+ ieth_txq_release_all_mbufs(txq, false);
i40e_reset_tx_queue(txq);
dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
@@ -2609,7 +2609,7 @@ i40e_tx_queue_release(void *txq)
return;
}
- ieth_txq_release_all_mbufs(q);
+ ieth_txq_release_all_mbufs(q, false);
rte_free(q->sw_ring);
rte_memzone_free(q->mz);
rte_free(q);
@@ -3072,7 +3072,7 @@ i40e_dev_clear_queues(struct rte_eth_dev *dev)
for (i = 0; i < dev->data->nb_tx_queues; i++) {
if (!dev->data->tx_queues[i])
continue;
- ieth_txq_release_all_mbufs(dev->data->tx_queues[i]);
+ ieth_txq_release_all_mbufs(dev->data->tx_queues[i], false);
i40e_reset_tx_queue(dev->data->tx_queues[i]);
}
diff --git a/drivers/net/iavf/iavf_rxtx.c b/drivers/net/iavf/iavf_rxtx.c
index c0f7d12804..c574b23f34 100644
--- a/drivers/net/iavf/iavf_rxtx.c
+++ b/drivers/net/iavf/iavf_rxtx.c
@@ -387,24 +387,6 @@ release_rxq_mbufs(struct iavf_rx_queue *rxq)
rxq->rx_nb_avail = 0;
}
-static inline void
-release_txq_mbufs(struct ieth_tx_queue *txq)
-{
- uint16_t i;
-
- if (!txq || !txq->sw_ring) {
- PMD_DRV_LOG(DEBUG, "Pointer to rxq or sw_ring is NULL");
- return;
- }
-
- for (i = 0; i < txq->nb_tx_desc; i++) {
- if (txq->sw_ring[i].mbuf) {
- rte_pktmbuf_free_seg(txq->sw_ring[i].mbuf);
- txq->sw_ring[i].mbuf = NULL;
- }
- }
-}
-
static const
struct iavf_rxq_ops iavf_rxq_release_mbufs_ops[] = {
[IAVF_REL_MBUFS_DEFAULT].release_mbufs = release_rxq_mbufs,
@@ -413,18 +395,6 @@ struct iavf_rxq_ops iavf_rxq_release_mbufs_ops[] = {
#endif
};
-static const
-struct iavf_txq_ops iavf_txq_release_mbufs_ops[] = {
- [IAVF_REL_MBUFS_DEFAULT].release_mbufs = release_txq_mbufs,
-#ifdef RTE_ARCH_X86
- [IAVF_REL_MBUFS_SSE_VEC].release_mbufs = iavf_tx_queue_release_mbufs_sse,
-#ifdef CC_AVX512_SUPPORT
- [IAVF_REL_MBUFS_AVX512_VEC].release_mbufs = iavf_tx_queue_release_mbufs_avx512,
-#endif
-#endif
-
-};
-
static inline void
iavf_rxd_to_pkt_fields_by_comms_ovs(__rte_unused struct iavf_rx_queue *rxq,
struct rte_mbuf *mb,
@@ -889,7 +859,6 @@ iavf_dev_tx_queue_setup(struct rte_eth_dev *dev,
txq->q_set = true;
dev->data->tx_queues[queue_idx] = txq;
txq->qtx_tail = hw->hw_addr + IAVF_QTX_TAIL1(queue_idx);
- txq->rel_mbufs_type = IAVF_REL_MBUFS_DEFAULT;
if (check_tx_vec_allow(txq) == false) {
struct iavf_adapter *ad =
@@ -1068,7 +1037,7 @@ iavf_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
}
txq = dev->data->tx_queues[tx_queue_id];
- iavf_txq_release_mbufs_ops[txq->rel_mbufs_type].release_mbufs(txq);
+ ieth_txq_release_all_mbufs(txq, txq->use_ctx);
reset_tx_queue(txq);
dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
@@ -1097,7 +1066,7 @@ iavf_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
if (!q)
return;
- iavf_txq_release_mbufs_ops[q->rel_mbufs_type].release_mbufs(q);
+ ieth_txq_release_all_mbufs(q, q->use_ctx);
rte_free(q->sw_ring);
rte_memzone_free(q->mz);
rte_free(q);
@@ -1114,7 +1083,7 @@ iavf_reset_queues(struct rte_eth_dev *dev)
txq = dev->data->tx_queues[i];
if (!txq)
continue;
- iavf_txq_release_mbufs_ops[txq->rel_mbufs_type].release_mbufs(txq);
+ ieth_txq_release_all_mbufs(txq, txq->use_ctx);
reset_tx_queue(txq);
dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED;
}
diff --git a/drivers/net/iavf/iavf_rxtx_vec_avx512.c b/drivers/net/iavf/iavf_rxtx_vec_avx512.c
index 391fbfcd4d..16cfd6a5b3 100644
--- a/drivers/net/iavf/iavf_rxtx_vec_avx512.c
+++ b/drivers/net/iavf/iavf_rxtx_vec_avx512.c
@@ -2356,31 +2356,11 @@ iavf_xmit_pkts_vec_avx512(void *tx_queue, struct rte_mbuf **tx_pkts,
return iavf_xmit_pkts_vec_avx512_cmn(tx_queue, tx_pkts, nb_pkts, false);
}
-void __rte_cold
-iavf_tx_queue_release_mbufs_avx512(struct ieth_tx_queue *txq)
-{
- unsigned int i;
- const uint16_t max_desc = (uint16_t)(txq->nb_tx_desc - 1);
- const uint16_t end_desc = txq->tx_tail >> txq->use_ctx; /* next empty slot */
- const uint16_t wrap_point = txq->nb_tx_desc >> txq->use_ctx; /* end of SW ring */
- struct ieth_vec_tx_entry *swr = (void *)txq->sw_ring;
-
- if (!txq->sw_ring || txq->nb_tx_free == max_desc)
- return;
-
- i = (txq->tx_next_dd - txq->tx_rs_thresh + 1) >> txq->use_ctx;
- while (i != end_desc) {
- rte_pktmbuf_free_seg(swr[i].mbuf);
- swr[i].mbuf = NULL;
- if (++i == wrap_point)
- i = 0;
- }
-}
-
int __rte_cold
iavf_txq_vec_setup_avx512(struct ieth_tx_queue *txq)
{
- txq->rel_mbufs_type = IAVF_REL_MBUFS_AVX512_VEC;
+ txq->vector_tx = true;
+ txq->vector_sw_ring = true;
return 0;
}
diff --git a/drivers/net/iavf/iavf_rxtx_vec_common.h b/drivers/net/iavf/iavf_rxtx_vec_common.h
index ccc447e28d..20d8262e7f 100644
--- a/drivers/net/iavf/iavf_rxtx_vec_common.h
+++ b/drivers/net/iavf/iavf_rxtx_vec_common.h
@@ -60,24 +60,6 @@ _iavf_rx_queue_release_mbufs_vec(struct iavf_rx_queue *rxq)
memset(rxq->sw_ring, 0, sizeof(rxq->sw_ring[0]) * rxq->nb_rx_desc);
}
-static inline void
-_iavf_tx_queue_release_mbufs_vec(struct ieth_tx_queue *txq)
-{
- unsigned i;
- const uint16_t max_desc = (uint16_t)(txq->nb_tx_desc - 1);
-
- if (!txq->sw_ring || txq->nb_tx_free == max_desc)
- return;
-
- i = txq->tx_next_dd - txq->tx_rs_thresh + 1;
- while (i != txq->tx_tail) {
- rte_pktmbuf_free_seg(txq->sw_ring[i].mbuf);
- txq->sw_ring[i].mbuf = NULL;
- if (++i == txq->nb_tx_desc)
- i = 0;
- }
-}
-
static inline int
iavf_rxq_vec_setup_default(struct iavf_rx_queue *rxq)
{
diff --git a/drivers/net/iavf/iavf_rxtx_vec_sse.c b/drivers/net/iavf/iavf_rxtx_vec_sse.c
index de632c6de8..21ad685ff1 100644
--- a/drivers/net/iavf/iavf_rxtx_vec_sse.c
+++ b/drivers/net/iavf/iavf_rxtx_vec_sse.c
@@ -1458,16 +1458,11 @@ iavf_rx_queue_release_mbufs_sse(struct iavf_rx_queue *rxq)
_iavf_rx_queue_release_mbufs_vec(rxq);
}
-void __rte_cold
-iavf_tx_queue_release_mbufs_sse(struct ieth_tx_queue *txq)
-{
- _iavf_tx_queue_release_mbufs_vec(txq);
-}
-
int __rte_cold
iavf_txq_vec_setup(struct ieth_tx_queue *txq)
{
- txq->rel_mbufs_type = IAVF_REL_MBUFS_SSE_VEC;
+ txq->vector_tx = true;
+ txq->vector_sw_ring = false;
return 0;
}
diff --git a/drivers/net/ice/ice_dcf_ethdev.c b/drivers/net/ice/ice_dcf_ethdev.c
index 54d17875bb..959215117f 100644
--- a/drivers/net/ice/ice_dcf_ethdev.c
+++ b/drivers/net/ice/ice_dcf_ethdev.c
@@ -501,7 +501,7 @@ ice_dcf_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
}
txq = dev->data->tx_queues[tx_queue_id];
- ieth_txq_release_all_mbufs(txq);
+ ieth_txq_release_all_mbufs(txq, false);
reset_tx_queue(txq);
dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
@@ -651,7 +651,7 @@ ice_dcf_stop_queues(struct rte_eth_dev *dev)
txq = dev->data->tx_queues[i];
if (!txq)
continue;
- ieth_txq_release_all_mbufs(txq);
+ ieth_txq_release_all_mbufs(txq, false);
reset_tx_queue(txq);
dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED;
}
diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c
index 51f82738d5..5e58314b57 100644
--- a/drivers/net/ice/ice_rxtx.c
+++ b/drivers/net/ice/ice_rxtx.c
@@ -1089,7 +1089,7 @@ ice_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
return -EINVAL;
}
- ieth_txq_release_all_mbufs(txq);
+ ieth_txq_release_all_mbufs(txq, false);
ice_reset_tx_queue(txq);
dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
@@ -1152,7 +1152,7 @@ ice_fdir_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
return -EINVAL;
}
- ieth_txq_release_all_mbufs(txq);
+ ieth_txq_release_all_mbufs(txq, false);
txq->qtx_tail = NULL;
return 0;
@@ -1531,7 +1531,7 @@ ice_tx_queue_release(void *txq)
return;
}
- ieth_txq_release_all_mbufs(q);
+ ieth_txq_release_all_mbufs(q, false);
rte_free(q->sw_ring);
rte_memzone_free(q->mz);
rte_free(q);
diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c
index 0d5f4803e5..9299171db0 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.c
+++ b/drivers/net/ixgbe/ixgbe_rxtx.c
@@ -2457,7 +2457,7 @@ static void __rte_cold
ixgbe_tx_queue_release(struct ieth_tx_queue *txq)
{
if (txq != NULL && txq->ops != NULL) {
- ieth_txq_release_all_mbufs(txq);
+ ieth_txq_release_all_mbufs(txq, false);
txq->ops->free_swring(txq);
rte_memzone_free(txq->mz);
rte_free(txq);
@@ -3364,7 +3364,7 @@ ixgbe_dev_clear_queues(struct rte_eth_dev *dev)
struct ieth_tx_queue *txq = dev->data->tx_queues[i];
if (txq != NULL) {
- ieth_txq_release_all_mbufs(txq);
+ ieth_txq_release_all_mbufs(txq, false);
txq->ops->reset(txq);
dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED;
}
@@ -5638,7 +5638,7 @@ ixgbe_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
}
if (txq->ops != NULL) {
- ieth_txq_release_all_mbufs(txq);
+ ieth_txq_release_all_mbufs(txq, false);
txq->ops->reset(txq);
}
dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
--
2.43.0
next prev parent reply other threads:[~2024-11-22 12:57 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-22 12:53 [RFC PATCH 00/21] Reduce code duplication across Intel NIC drivers Bruce Richardson
2024-11-22 12:53 ` [RFC PATCH 01/21] common/intel_eth: add pkt reassembly fn for intel drivers Bruce Richardson
2024-11-22 12:53 ` [RFC PATCH 02/21] common/intel_eth: provide common Tx entry structures Bruce Richardson
2024-11-22 12:53 ` [RFC PATCH 03/21] common/intel_eth: add Tx mbuf ring replenish fn Bruce Richardson
2024-11-22 12:53 ` [RFC PATCH 04/21] drivers/net: align Tx queue struct field names Bruce Richardson
2024-11-22 12:53 ` [RFC PATCH 05/21] drivers/net: add prefix for driver-specific structs Bruce Richardson
2024-11-22 12:53 ` [RFC PATCH 06/21] common/intel_eth: merge ice and i40e Tx queue struct Bruce Richardson
2024-11-22 12:54 ` [RFC PATCH 07/21] net/iavf: use common Tx queue structure Bruce Richardson
2024-11-22 12:54 ` [RFC PATCH 08/21] net/ixgbe: convert Tx queue context cache field to ptr Bruce Richardson
2024-11-22 12:54 ` [RFC PATCH 09/21] net/ixgbe: use common Tx queue structure Bruce Richardson
2024-11-22 12:54 ` [RFC PATCH 10/21] common/intel_eth: pack " Bruce Richardson
2024-11-22 12:54 ` [RFC PATCH 11/21] common/intel_eth: add post-Tx buffer free function Bruce Richardson
2024-11-22 12:54 ` [RFC PATCH 12/21] common/intel_eth: add Tx buffer free fn for AVX-512 Bruce Richardson
2024-11-22 12:54 ` [RFC PATCH 13/21] net/iavf: use common Tx " Bruce Richardson
2024-11-22 12:54 ` [RFC PATCH 14/21] net/ice: move Tx queue mbuf cleanup fn to common Bruce Richardson
2024-11-22 12:54 ` [RFC PATCH 15/21] net/i40e: use common Tx queue mbuf cleanup fn Bruce Richardson
2024-11-22 12:54 ` [RFC PATCH 16/21] net/ixgbe: " Bruce Richardson
2024-11-22 12:54 ` Bruce Richardson [this message]
2024-11-22 12:54 ` [RFC PATCH 18/21] net/ice: use vector SW ring for all vector paths Bruce Richardson
2024-11-22 12:54 ` [RFC PATCH 19/21] net/i40e: " Bruce Richardson
2024-11-22 12:54 ` [RFC PATCH 20/21] net/iavf: " Bruce Richardson
2024-11-22 12:54 ` [RFC PATCH 21/21] net/ixgbe: use common Tx backlog entry fn Bruce Richardson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241122125418.2857301-18-bruce.richardson@intel.com \
--to=bruce.richardson@intel.com \
--cc=anatoly.burakov@intel.com \
--cc=dev@dpdk.org \
--cc=ian.stokes@intel.com \
--cc=konstantin.v.ananyev@yandex.ru \
--cc=vladimir.medvedkin@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).