Direct re-arming of buffers on receive side
Subsystems (2)
v13 cover Recycle mbufs from Tx queue into Rx queue
In reply to Feifei WangCurrently, the transmit side frees the buffers into the lcore cache and the receive side allocates buffers from the lcore cache. The transmit side typically frees 32 buffers resulting in 32*8=256B of stores to lcore cache. The receive side allocates 32 buffers and stores them in the receive side software ring, resulting in 32*8=256B of stores and 256B of load from the lcore cache.
This patch proposes a mechanism to avoid freeing to/allocating from the lcore cache. i.e. the receive side will free the buffers from transmit side directly into its software ring. This will avoid the 256B of loads and stores introduced by the lcore cache. It also frees up the cache lines used by the lcore cache. And we can call this mode as mbufs recycle mode.
In the latest version, mbufs recycle mode is packaged as a separate API.
This allows for the users to change rxq/txq pairing in real time in data plane, according to the analysis of the packet flow by the application, for example:
-----------------------------------------------------------------------
Step 1: upper application analyse the flow direction
Step 2: recycle_rxq_info = rte_eth_recycle_rx_queue_info_get(rx_portid, rx_queueid) Step 3: rte_eth_recycle_mbufs(rx_portid, rx_queueid, tx_portid, tx_queueid, recycle_rxq_info); Step 4: rte_eth_rx_burst(rx_portid,rx_queueid);
Step 5: rte_eth_tx_burst(tx_portid,tx_queueid);
-----------------------------------------------------------------------
Above can support user to change rxq/txq pairing at run-time and user does not need to know the direction of flow in advance. This can effectively expand mbufs recycle mode's use scenarios.
Furthermore, mbufs recycle mode is no longer limited to the same pmd,
it can support moving mbufs between different vendor pmds, even can put the mbufs anywhere into your Rx mbuf ring as long as the address of the mbuf ring can be provided. In the latest version, we enable mbufs recycle mode in i40e pmd and ixgbe pmd, and also try to use i40e driver in Rx, ixgbe driver in Tx, and then achieve 7-9% performance improvement by mbufs recycle mode.
Difference between mbuf recycle, ZC API used in mempool and general path
For general path:
Rx: 32 pkts memcpy from mempool cache to rx_sw_ring
Tx: 32 pkts memcpy from tx_sw_ring to temporary variable + 32 pkts memcpy from temporary variable to mempool cache
For ZC API used in mempool:
Rx: 32 pkts memcpy from mempool cache to rx_sw_ring
Tx: 32 pkts memcpy from tx_sw_ring to zero-copy mempool cache
Refer link: http://patches.dpdk.org/project/dpdk/patch/[email protected]/
For mbufs recycle:
Rx/Tx: 32 pkts memcpy from tx_sw_ring to rx_sw_ring
Thus we can see in the one loop, compared to general path, mbufs recycle mode reduces 32+32=64 pkts memcpy; Compared to ZC API used in mempool, we can see mbufs recycle mode reduce 32 pkts memcpy in each loop.
So, mbufs recycle has its own benefits.
Testing status:
(1) dpdk l3fwd test with multiple drivers:
port 0: 82599 NIC port 1: XL710 NIC
-------------------------------------------------------------
Without fast free With fast free
Thunderx2: +7.53% +13.54%
-------------------------------------------------------------
(2) dpdk l3fwd test with same driver:
port 0 && 1: XL710 NIC
-------------------------------------------------------------
Without fast free With fast free
Ampere altra: +12.61% +11.42%
n1sdp: +8.30% +3.85%
x86-sse: +8.43% +3.72%
-------------------------------------------------------------
(3) Performance comparison with ZC_mempool used
port 0 && 1: XL710 NIC
with fast free
-------------------------------------------------------------
With recycle buffer With zc_mempool
Ampere altra: 11.42% 3.54%
-------------------------------------------------------------
Furthermore, we add recycle_mbuf engine in testpmd. Due to XL710 NIC has I/O bottleneck in testpmd in ampere altra, we can not see throughput change compared with I/O fwd engine. However, using record cmd in testpmd:
'$set record-burst-stats on'
we can see the ratio of 'Rx/Tx burst size of 32' is reduced. This indicate mbufs recycle can save CPU cycles.
V2:
1. Use data-plane API to enable direct-rearm (Konstantin, Honnappa)
2. Add 'txq_data_get' API to get txq info for Rx (Konstantin)
3. Use input parameter to enable direct rearm in l3fwd (Konstantin)
4. Add condition detection for direct rearm API (Morten, Andrew Rybchenko)
V3:
1. Seperate Rx and Tx operation with two APIs in direct-rearm (Konstantin)
2. Delete L3fwd change for direct rearm (Jerin)
3. enable direct rearm in ixgbe driver in Arm
v4:
1. Rename direct-rearm as buffer recycle. Based on this, function name and variable name are changed to let this mode more general for all drivers. (Konstantin, Morten)
2. Add ring wrapping check (Konstantin)
v5:
1. some change for ethdev API (Morten)
2. add support for avx2, sse, altivec path
v6:
1. fix ixgbe build issue in ppc
2. remove 'recycle_tx_mbufs_reuse' and 'recycle_rx_descriptors_refill' API wrapper (Tech Board meeting)
3. add recycle_mbufs engine in testpmd (Tech Board meeting)
4. add namespace in the functions related to mbufs recycle(Ferruh)
v7:
1. move 'rxq/txq data' pointers to the beginning of eth_dev structure, in order to keep them in the same cache line as rx/tx_burst function pointers (Morten)
2. add the extra description for 'rte_eth_recycle_mbufs' to show it can support feeding 1 Rx queue from 2 Tx queues in the same thread (Konstantin)
3. For i40e/ixgbe driver, make the previous copied buffers as invalid if there are Tx buffers refcnt > 1 or from unexpected mempool (Konstantin)
4. add check for the return value of 'rte_eth_recycle_rx_queue_info_get' in testpmd fwd engine (Morten)
v8:
1. add arm/x86 build option to fix ixgbe build issue in ppc
v9:
1. delete duplicate file name for ixgbe
v10:
1. fix compile issue on windows
v11:
1. fix doc warning
v12:
1. replace rx queue check code with eth_dev_validate_rx_queue function (Stephen)
2. put port and queue check before function call (Konstantin)
v13:
1. for i40e and ixgbe drivers, reset nb_recycle_mbufs to zero when rxep[i] == NULL, no matter what value refill_requirement is (Konstantin)
Feifei Wang (4):
ethdev: add API for mbufs recycle mode
net/i40e: implement mbufs recycle mode
net/ixgbe: implement mbufs recycle mode
app/testpmd: add recycle mbufs engine
app/test-pmd/meson.build | 1 + app/test-pmd/recycle_mbufs.c | 58 ++++++ app/test-pmd/testpmd.c | 1 + app/test-pmd/testpmd.h | 3 + doc/guides/rel_notes/release_23_11.rst | 15 ++ doc/guides/testpmd_app_ug/run_app.rst | 1 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 5 +- drivers/net/i40e/i40e_ethdev.c | 1 + drivers/net/i40e/i40e_ethdev.h | 2 + .../net/i40e/i40e_recycle_mbufs_vec_common.c | 147 ++++++++++++++ drivers/net/i40e/i40e_rxtx.c | 32 ++++ drivers/net/i40e/i40e_rxtx.h | 4 + drivers/net/i40e/meson.build | 1 + drivers/net/ixgbe/ixgbe_ethdev.c | 1 + drivers/net/ixgbe/ixgbe_ethdev.h | 3 + .../ixgbe/ixgbe_recycle_mbufs_vec_common.c | 143 ++++++++++++++ drivers/net/ixgbe/ixgbe_rxtx.c | 37 +++- drivers/net/ixgbe/ixgbe_rxtx.h | 4 + drivers/net/ixgbe/meson.build | 2 + lib/ethdev/ethdev_driver.h | 10 + lib/ethdev/ethdev_private.c | 2 + lib/ethdev/rte_ethdev.c | 22 +++ lib/ethdev/rte_ethdev.h | 180 ++++++++++++++++++ lib/ethdev/rte_ethdev_core.h | 23 ++- lib/ethdev/version.map | 3 + 25 files changed, 692 insertions(+), 9 deletions(-) create mode 100644 app/test-pmd/recycle_mbufs.c create mode 100644 drivers/net/i40e/i40e_recycle_mbufs_vec_common.c create mode 100644 drivers/net/ixgbe/ixgbe_recycle_mbufs_vec_common.c
Signature · 1 line
2.25.1
PATCH v13 1/4 ethdev: add API for mbufs recycle mode
Add 'rte_eth_recycle_rx_queue_info_get' and 'rte_eth_recycle_mbufs' APIs to recycle used mbufs from a transmit queue of an Ethernet device, and move these mbufs into a mbuf ring for a receive queue of an Ethernet device. This can bypass mempool 'put/get' operations hence saving CPU cycles.
For each recycling mbufs, the rte_eth_recycle_mbufs() function performs the following operations:
- Copy used *rte_mbuf* buffer pointers from Tx mbuf ring into Rx mbuf ring.
- Replenish the Rx descriptors with the recycling *rte_mbuf* mbufs freed from the Tx mbuf ring.
--- doc/guides/rel_notes/release_23_11.rst | 15 +++ lib/ethdev/ethdev_driver.h | 10 ++ lib/ethdev/ethdev_private.c | 2 + lib/ethdev/rte_ethdev.c | 22 +++ lib/ethdev/rte_ethdev.h | 180 +++++++++++++++++++++++++ lib/ethdev/rte_ethdev_core.h | 23 +++- lib/ethdev/version.map | 3 + 7 files changed, 249 insertions(+), 6 deletions(-)
doc/guides/rel_notes/release_23_11.rst +15 -0
@@ -78,6 +78,13 @@ New Features * build: Optional libraries can now be selected with the new ``enable_libs`` build option similarly to the existing ``enable_drivers`` build option. +* **Add mbufs recycling support.** + + Added ``rte_eth_recycle_rx_queue_info_get`` and ``rte_eth_recycle_mbufs`` + APIs which allow the user to copy used mbufs from the Tx mbuf ring + into the Rx mbuf ring. This feature supports the case that the Rx Ethernet + device is different from the Tx Ethernet device with respective driver + callback functions in ``rte_eth_recycle_mbufs``. Removed Items -------------
@@ -135,6 +142,14 @@ ABI Changes Also, make sure to start the actual text at the margin. ======================================================= +* ethdev: Added ``recycle_tx_mbufs_reuse`` and ``recycle_rx_descriptors_refill`` + fields to ``rte_eth_dev`` structure. + +* ethdev: Structure ``rte_eth_fp_ops`` was affected to add + ``recycle_tx_mbufs_reuse`` and ``recycle_rx_descriptors_refill`` + fields, to move ``rxq`` and ``txq`` fields, to change the size of + ``reserved1`` and ``reserved2`` fields. + Known Issues ------------
lib/ethdev/ethdev_driver.h +10 -0
@@ -60,6 +60,10 @@ struct rte_eth_dev {eth_rx_descriptor_status_t rx_descriptor_status;/** Check the status of a Tx descriptor */ eth_tx_descriptor_status_t tx_descriptor_status; +/** Pointer to PMD transmit mbufs reuse function */ +eth_recycle_tx_mbufs_reuse_t recycle_tx_mbufs_reuse; +/** Pointer to PMD receive descriptors refill function */ +eth_recycle_rx_descriptors_refill_t recycle_rx_descriptors_refill;/** * Device data that is shared between primary and secondary processes
@@ -509,6 +513,10 @@ 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_recycle_rxq_info_get_t )(struct rte_eth_dev *dev, +uint16_t rx_queue_id, +struct rte_eth_recycle_rxq_info *recycle_rxq_info); +typedef int (*eth_burst_mode_get_t )(struct rte_eth_dev *dev,uint16_t queue_id,struct rte_eth_burst_mode *mode);
@@ -1252,6 +1260,8 @@ struct eth_dev_ops {eth_rxq_info_get_t rxq_info_get;/** Retrieve Tx queue information */ eth_txq_info_get_t txq_info_get; +/** Retrieve mbufs recycle Rx queue information */ +eth_recycle_rxq_info_get_t recycle_rxq_info_get;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 */
lib/ethdev/ethdev_private.c +2 -0
@@ -277,6 +277,8 @@ eth_dev_fp_ops_setup(struct rte_eth_fp_ops *fpo, fpo->rx_queue_count = dev->rx_queue_count; fpo->rx_descriptor_status = dev->rx_descriptor_status; fpo->tx_descriptor_status = dev->tx_descriptor_status; + fpo->recycle_tx_mbufs_reuse = dev->recycle_tx_mbufs_reuse; + fpo->recycle_rx_descriptors_refill = dev->recycle_rx_descriptors_refill; fpo->rxq.data = dev->data->rx_queues; fpo->rxq.clbk = (void **)(uintptr_t )dev->post_rx_burst_cbs;
lib/ethdev/rte_ethdev.c +22 -0
@@ -5876,6 +5876,28 @@ rte_eth_tx_queue_info_get(uint16_t port_id, uint16_t queue_id,return 0 ; } +int +rte_eth_recycle_rx_queue_info_get (uint16_t port_id,uint16_t queue_id, +struct rte_eth_recycle_rxq_info *recycle_rxq_info) +{ +struct rte_eth_dev *dev; +int ret; + +RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id, -ENODEV ); + dev = &rte_eth_devices[port_id]; + + ret =eth_dev_validate_rx_queue (dev, queue_id); +if (unlikely (ret !=0 )) +return ret; + +if (*dev->dev_ops->recycle_rxq_info_get ==NULL ) +return -ENOTSUP ; + + dev->dev_ops->recycle_rxq_info_get (dev, queue_id, recycle_rxq_info); + +return 0 ; +} +int rte_eth_rx_burst_mode_get (uint16_t port_id,uint16_t queue_id,struct rte_eth_burst_mode *mode)
lib/ethdev/rte_ethdev.h +180 -0
198 lines not on this page · raw message
lib/ethdev/rte_ethdev_core.h +17 -6
@@ -53,6 +53,13 @@ typedef int (*eth_rx_descriptor_status_t)(void *rxq, uint16_t offset);/** @internal Check the status of a Tx descriptor */ typedef int (*eth_tx_descriptor_status_t )(void *txq,uint16_t offset); +/** @internal Copy used mbufs from Tx mbuf ring into Rx mbuf ring */ +typedef uint16_t (*eth_recycle_tx_mbufs_reuse_t )(void *txq, +struct rte_eth_recycle_rxq_info *recycle_rxq_info); + +/** @internal Refill Rx descriptors with the recycling mbufs */ +typedef void (*eth_recycle_rx_descriptors_refill_t )(void *rxq,uint16_t nb); +/** * @internal * Structure used to hold opaque pointers to internal ethdev Rx/Tx
@@ -81,15 +88,17 @@ struct rte_eth_fp_ops {* Rx fast-path functions and related data. * 64-bit systems: occupies first 64B line */ +/** Rx queues data. */ +struct rte_ethdev_qdata rxq;/** PMD receive function. */ eth_rx_burst_t rx_pkt_burst;/** Get the number of used Rx descriptors. */ eth_rx_queue_count_t rx_queue_count;/** Check the status of a Rx descriptor. */ eth_rx_descriptor_status_t rx_descriptor_status; -/** Rx queues data. */ -struct rte_ethdev_qdata rxq; -uintptr_t reserved1[3 ]; +/** Refill Rx descriptors with the recycling mbufs. */ +eth_recycle_rx_descriptors_refill_t recycle_rx_descriptors_refill; +uintptr_t reserved1[2 ];/**@}*/ /**@{*/
@@ -97,15 +106,17 @@ struct rte_eth_fp_ops {* Tx fast-path functions and related data. * 64-bit systems: occupies second 64B line */ +/** Tx queues data. */ +struct rte_ethdev_qdata txq;/** PMD transmit function. */ eth_tx_burst_t tx_pkt_burst;/** PMD transmit prepare function. */ eth_tx_prep_t tx_pkt_prepare;/** Check the status of a Tx descriptor. */ eth_tx_descriptor_status_t tx_descriptor_status; -/** Tx queues data. */ -struct rte_ethdev_qdata txq; -uintptr_t reserved2[3 ]; +/** Copy used mbufs from Tx mbuf ring into Rx. */ +eth_recycle_tx_mbufs_reuse_t recycle_tx_mbufs_reuse; +uintptr_t reserved2[2 ];/**@}*/ } __rte_cache_aligned;
lib/ethdev/version.map +3 -0
@@ -312,6 +312,9 @@ EXPERIMENTAL { rte_flow_async_action_list_handle_query_update; rte_flow_async_actions_update; rte_flow_restore_info_dynflag; + + # added in 23.11 + rte_eth_recycle_rx_queue_info_get; }; INTERNAL {
Signature · 1 line
2.25.1
Re: [PATCH v13 1/4] ethdev: add API for mbufs recycle mode
Quoted 14 lines · Feifei Wang
Add '
rte_eth_recycle_rx_queue_info_get' and 'rte_eth_recycle_mbufs' APIs to recycle used mbufs from a transmit queue of an Ethernet device, and move these mbufs into a mbuf ring for a receive queue of an Ethernet device. This can bypass mempool 'put/get' operations hence saving CPU cycles.For each recycling mbufs, the
rte_eth_recycle_mbufs()function performs the following operations:
- Copy used *rte_mbuf* buffer pointers from Tx mbuf ring into Rx mbuf ring.
- Replenish the Rx descriptors with the recycling *rte_mbuf* mbufs freed from the Tx mbuf ring.
Quoted 8 lines
Suggested-by Honnappa Nagarahalli <[email protected]>Suggested-by Ruifeng Wang <[email protected]>Signed-off-by Feifei Wang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>Reviewed-by Honnappa Nagarahalli <[email protected]>Acked-by Morten Brørup <[email protected]>Acked-by Ferruh Yigit <[email protected]>
Quoted 10 lines
--- doc/guides/rel_notes/release_23_11.rst | 15 +++ lib/ethdev/ethdev_driver.h | 10 ++ lib/ethdev/ethdev_private.c | 2 + lib/ethdev/rte_ethdev.c | 22 +++ lib/ethdev/rte_ethdev.h | 180 +++++++++++++++++++++++++ lib/ethdev/rte_ethdev_core.h | 23 +++- lib/ethdev/version.map | 3 + 7 files changed, 249 insertions(+), 6 deletions(-)
PATCH v13 2/4 net/i40e: implement mbufs recycle mode
In reply to Feifei WangDefine specific function implementation for i40e driver. Currently, mbufs recycle mode can support 128bit vector path and avx2 path. And can be enabled both in fast free and no fast free mode.
--- drivers/net/i40e/i40e_ethdev.c | 1 + drivers/net/i40e/i40e_ethdev.h | 2 + .../net/i40e/i40e_recycle_mbufs_vec_common.c | 147 ++++++++++++++++++ drivers/net/i40e/i40e_rxtx.c | 32 ++++ drivers/net/i40e/i40e_rxtx.h | 4 + drivers/net/i40e/meson.build | 1 + 6 files changed, 187 insertions(+) create mode 100644 drivers/net/i40e/i40e_recycle_mbufs_vec_common.c
drivers/net/i40e/i40e_ethdev.c +1 -0
@@ -496,6 +496,7 @@ static const struct eth_dev_ops i40e_eth_dev_ops = { .flow_ops_get = i40e_dev_flow_ops_get, .rxq_info_get = i40e_rxq_info_get, .txq_info_get = i40e_txq_info_get, + .recycle_rxq_info_get = i40e_recycle_rxq_info_get, .rx_burst_mode_get = i40e_rx_burst_mode_get, .tx_burst_mode_get = i40e_tx_burst_mode_get, .timesync_enable = i40e_timesync_enable,
drivers/net/i40e/i40e_ethdev.h +2 -0
@@ -1355,6 +1355,8 @@ void i40e_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id, struct rte_eth_rxq_info *qinfo);void i40e_txq_info_get (struct rte_eth_dev *dev,uint16_t queue_id,struct rte_eth_txq_info *qinfo); +void i40e_recycle_rxq_info_get (struct rte_eth_dev *dev,uint16_t queue_id, +struct rte_eth_recycle_rxq_info *recycle_rxq_info);int i40e_rx_burst_mode_get (struct rte_eth_dev *dev,uint16_t queue_id,struct rte_eth_burst_mode *mode); int i40e_tx_burst_mode_get(struct rte_eth_dev *dev, uint16_t queue_id,
drivers/net/i40e/i40e_recycle_mbufs_vec_common.c new file +147 -0
147 lines not on this page · raw message
drivers/net/i40e/i40e_rxtx.c +32 -0
@@ -3199,6 +3199,30 @@ i40e_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id, qinfo->conf.offloads = txq->offloads; } +void +i40e_recycle_rxq_info_get (struct rte_eth_dev *dev,uint16_t queue_id, +struct rte_eth_recycle_rxq_info *recycle_rxq_info) +{ +struct i40e_rx_queue *rxq; +struct i40e_adapter *ad = +I40E_DEV_PRIVATE_TO_ADAPTER (dev->data->dev_private); + + rxq = dev->data->rx_queues[queue_id]; + + recycle_rxq_info->mbuf_ring = (void *)rxq->sw_ring; + recycle_rxq_info->mp = rxq->mp; + recycle_rxq_info->mbuf_ring_size = rxq->nb_rx_desc; + recycle_rxq_info->receive_tail = &rxq->rx_tail; + +if (ad->rx_vec_allowed) { + recycle_rxq_info->refill_requirement =RTE_I40E_RXQ_REARM_THRESH ; + recycle_rxq_info->refill_head = &rxq->rxrearm_start; + }else { + recycle_rxq_info->refill_requirement = rxq->rx_free_thresh; + recycle_rxq_info->refill_head = &rxq->rx_free_trigger; + } +} +#ifdef RTE_ARCH_X86 static inline bool get_avx_supported (bool request_avx512)
@@ -3293,6 +3317,8 @@ i40e_set_rx_function(struct rte_eth_dev *dev) dev->rx_pkt_burst = ad->rx_use_avx2 ? i40e_recv_scattered_pkts_vec_avx2 : i40e_recv_scattered_pkts_vec; + dev->recycle_rx_descriptors_refill = + i40e_recycle_rx_descriptors_refill_vec; } }else {if (ad->rx_use_avx512) {
@@ -3311,9 +3337,12 @@ i40e_set_rx_function(struct rte_eth_dev *dev) dev->rx_pkt_burst = ad->rx_use_avx2 ? i40e_recv_pkts_vec_avx2 : i40e_recv_pkts_vec; + dev->recycle_rx_descriptors_refill = + i40e_recycle_rx_descriptors_refill_vec; } }#else /* RTE_ARCH_X86 */ + dev->recycle_rx_descriptors_refill = i40e_recycle_rx_descriptors_refill_vec;if (dev->data->scattered_rx) { PMD_INIT_LOG(DEBUG, "Using Vector Scattered Rx (port %d).",
@@ -3481,15 +3510,18 @@ i40e_set_tx_function(struct rte_eth_dev *dev) dev->tx_pkt_burst = ad->tx_use_avx2 ? i40e_xmit_pkts_vec_avx2 : i40e_xmit_pkts_vec; + dev->recycle_tx_mbufs_reuse = i40e_recycle_tx_mbufs_reuse_vec; }#else /* RTE_ARCH_X86 */ PMD_INIT_LOG (DEBUG ,"Using Vector Tx (port %d)." , dev->data->port_id); dev->tx_pkt_burst = i40e_xmit_pkts_vec; + dev->recycle_tx_mbufs_reuse = i40e_recycle_tx_mbufs_reuse_vec;#endif /* RTE_ARCH_X86 */ }else {PMD_INIT_LOG (DEBUG ,"Simple tx finally be used." ); dev->tx_pkt_burst = i40e_xmit_pkts_simple; + dev->recycle_tx_mbufs_reuse = i40e_recycle_tx_mbufs_reuse_vec; } dev->tx_pkt_prepare = i40e_simple_prep_pkts; }else {
drivers/net/i40e/i40e_rxtx.h +4 -0
@@ -236,6 +236,10 @@ uint32_t i40e_dev_rx_queue_count(void *rx_queue);int i40e_dev_rx_descriptor_status (void *rx_queue,uint16_t offset);int i40e_dev_tx_descriptor_status (void *tx_queue,uint16_t offset); +uint16_t i40e_recycle_tx_mbufs_reuse_vec (void *tx_queue, +struct rte_eth_recycle_rxq_info *recycle_rxq_info); +void i40e_recycle_rx_descriptors_refill_vec (void *rx_queue,uint16_t nb_mbufs); +uint16_t i40e_recv_pkts_vec (void *rx_queue,struct rte_mbuf **rx_pkts,uint16_t nb_pkts); uint16_t i40e_recv_scattered_pkts_vec(void *rx_queue,
drivers/net/i40e/meson.build +1 -0
@@ -34,6 +34,7 @@ sources = files( 'i40e_tm.c', 'i40e_hash.c', 'i40e_vf_representor.c', + 'i40e_recycle_mbufs_vec_common.c', 'rte_pmd_i40e.c', )
Signature · 1 line
2.25.1
Re: [PATCH v13 2/4] net/i40e: implement mbufs recycle mode
Quoted 10 lines · Feifei Wang
Define specific function implementation for i40e driver. Currently, mbufs recycle mode can support 128bit vector path and avx2 path. And can be enabled both in fast free and no fast free mode.
Suggested-by Honnappa Nagarahalli <[email protected]>Signed-off-by Feifei Wang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>Reviewed-by Honnappa Nagarahalli <[email protected]>
Hi Konstantin,
I guess this patch was under discussion, can you please check the latest version?
Hi Yuying, Beilei, Qiming, Wenjun,
This set includes i40e & ixgbe recycle_mbufs implementations, patch will be merged if there is no objection.
RE: [PATCH v13 2/4] net/i40e: implement mbufs recycle mode
Quoted 13 lines · Feifei Wang
Quoted 10 lines
Define specific function implementation for i40e driver. Currently, mbufs recycle mode can support 128bit vector path and avx2 path. And can be enabled both in fast free and no fast free mode.
Suggested-by Honnappa Nagarahalli <[email protected]>Signed-off-by Feifei Wang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>Reviewed-by Honnappa Nagarahalli <[email protected]>
Quoted 4 lines
Hi Konstantin,
I guess this patch was under discussion, can you please check the latest version?
Hi Ferruh,
Yes, I saw the new version, but didn't have time yet, to review/ack it. Will try to do it by today's COB.
Konstantin
Quoted 7 lines
Hi Yuying, Beilei, Qiming, Wenjun,
This set includes i40e & ixgbe
recycle_mbufsimplementations, patch will be merged if there is no objection.
Re: [PATCH v13 2/4] net/i40e: implement mbufs recycle mode
In reply to Feifei Wang25.09.2023 04:19, Feifei Wang пишет:
Quoted 10 lines
Define specific function implementation for i40e driver. Currently, mbufs recycle mode can support 128bit vector path and avx2 path. And can be enabled both in fast free and no fast free mode.
Suggested-by Honnappa Nagarahalli <[email protected]>Signed-off-by Feifei Wang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>Reviewed-by Honnappa Nagarahalli <[email protected]>---
PATCH v13 3/4 net/ixgbe: implement mbufs recycle mode
In reply to Feifei WangDefine specific function implementation for ixgbe driver. Currently, recycle buffer mode can support 128bit vector path. And can be enabled both in fast free and no fast free mode.
--- drivers/net/ixgbe/ixgbe_ethdev.c | 1 + drivers/net/ixgbe/ixgbe_ethdev.h | 3 + .../ixgbe/ixgbe_recycle_mbufs_vec_common.c | 143 ++++++++++++++++++ drivers/net/ixgbe/ixgbe_rxtx.c | 37 ++++- drivers/net/ixgbe/ixgbe_rxtx.h | 4 + drivers/net/ixgbe/meson.build | 2 + 6 files changed, 188 insertions(+), 2 deletions(-) create mode 100644 drivers/net/ixgbe/ixgbe_recycle_mbufs_vec_common.c
drivers/net/ixgbe/ixgbe_ethdev.c +1 -0
@@ -543,6 +543,7 @@ static const struct eth_dev_ops ixgbe_eth_dev_ops = { .set_mc_addr_list = ixgbe_dev_set_mc_addr_list, .rxq_info_get = ixgbe_rxq_info_get, .txq_info_get = ixgbe_txq_info_get, + .recycle_rxq_info_get = ixgbe_recycle_rxq_info_get, .timesync_enable = ixgbe_timesync_enable, .timesync_disable = ixgbe_timesync_disable, .timesync_read_rx_timestamp = ixgbe_timesync_read_rx_timestamp,
drivers/net/ixgbe/ixgbe_ethdev.h +3 -0
@@ -626,6 +626,9 @@ void ixgbe_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,void ixgbe_txq_info_get (struct rte_eth_dev *dev,uint16_t queue_id,struct rte_eth_txq_info *qinfo); +void ixgbe_recycle_rxq_info_get (struct rte_eth_dev *dev,uint16_t queue_id, +struct rte_eth_recycle_rxq_info *recycle_rxq_info); +int ixgbevf_dev_rx_init (struct rte_eth_dev *dev);void ixgbevf_dev_tx_init (struct rte_eth_dev *dev);
drivers/net/ixgbe/ixgbe_recycle_mbufs_vec_common.c new file +143 -0
143 lines not on this page · raw message
drivers/net/ixgbe/ixgbe_rxtx.c +35 -2
@@ -2552,6 +2552,9 @@ ixgbe_set_tx_function(struct rte_eth_dev *dev, struct ixgbe_tx_queue *txq) (rte_eal_process_type() != RTE_PROC_PRIMARY || ixgbe_txq_vec_setup(txq) == 0)) {PMD_INIT_LOG (DEBUG ,"Vector tx enabled." ); +#if defined(RTE_ARCH_X86 ) || defined(RTE_ARCH_ARM ) + dev->recycle_tx_mbufs_reuse = ixgbe_recycle_tx_mbufs_reuse_vec; +#endif dev->tx_pkt_burst = ixgbe_xmit_pkts_vec; } else dev->tx_pkt_burst = ixgbe_xmit_pkts_simple;
@@ -4890,7 +4893,10 @@ ixgbe_set_rx_function(struct rte_eth_dev *dev)PMD_INIT_LOG (DEBUG ,"Using Vector Scattered Rx " "callback (port=%d)." , dev->data->port_id); - +#if defined(RTE_ARCH_X86 ) || defined(RTE_ARCH_ARM ) + dev->recycle_rx_descriptors_refill = + ixgbe_recycle_rx_descriptors_refill_vec; +#endif dev->rx_pkt_burst = ixgbe_recv_scattered_pkts_vec; }else if (adapter->rx_bulk_alloc_allowed) { PMD_INIT_LOG(DEBUG, "Using a Scattered with bulk "
@@ -4919,7 +4925,9 @@ ixgbe_set_rx_function(struct rte_eth_dev *dev)"burst size no less than %d (port=%d)." ,RTE_IXGBE_DESCS_PER_LOOP , dev->data->port_id); - +#if defined(RTE_ARCH_X86 ) || defined(RTE_ARCH_ARM ) + dev->recycle_rx_descriptors_refill = ixgbe_recycle_rx_descriptors_refill_vec; +#endif dev->rx_pkt_burst = ixgbe_recv_pkts_vec; }else if (adapter->rx_bulk_alloc_allowed) { PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions are "
@@ -5691,6 +5699,31 @@ ixgbe_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id, qinfo->conf.tx_deferred_start = txq->tx_deferred_start; } +void +ixgbe_recycle_rxq_info_get (struct rte_eth_dev *dev,uint16_t queue_id, +struct rte_eth_recycle_rxq_info *recycle_rxq_info) +{ +struct ixgbe_rx_queue *rxq; +struct ixgbe_adapter *adapter = dev->data->dev_private; + + rxq = dev->data->rx_queues[queue_id]; + + recycle_rxq_info->mbuf_ring = (void *)rxq->sw_ring; + recycle_rxq_info->mp = rxq->mb_pool; + recycle_rxq_info->mbuf_ring_size = rxq->nb_rx_desc; + recycle_rxq_info->receive_tail = &rxq->rx_tail; + +if (adapter->rx_vec_allowed) { +#if defined(RTE_ARCH_X86 ) || defined(RTE_ARCH_ARM ) + recycle_rxq_info->refill_requirement =RTE_IXGBE_RXQ_REARM_THRESH ; + recycle_rxq_info->refill_head = &rxq->rxrearm_start; +#endif + }else { + recycle_rxq_info->refill_requirement = rxq->rx_free_thresh; + recycle_rxq_info->refill_head = &rxq->rx_free_trigger; + } +} +/* * [VF] Initializes Receive Unit. */
drivers/net/ixgbe/ixgbe_rxtx.h +4 -0
@@ -295,6 +295,10 @@ int ixgbe_dev_tx_done_cleanup(void *tx_queue, uint32_t free_cnt);extern const uint32_t ptype_table[IXGBE_PACKET_TYPE_MAX ];extern const uint32_t ptype_table_tn[IXGBE_PACKET_TYPE_TN_MAX ]; +uint16_t ixgbe_recycle_tx_mbufs_reuse_vec (void *tx_queue, +struct rte_eth_recycle_rxq_info *recycle_rxq_info); +void ixgbe_recycle_rx_descriptors_refill_vec (void *rx_queue,uint16_t nb_mbufs); +uint16_t ixgbe_xmit_fixed_burst_vec (void *tx_queue,struct rte_mbuf **tx_pkts,uint16_t nb_pkts);int ixgbe_txq_vec_setup (struct ixgbe_tx_queue *txq);
drivers/net/ixgbe/meson.build +2 -0
@@ -26,11 +26,13 @@ deps += ['hash', 'security'] if arch_subdir == 'x86' sources += files('ixgbe_rxtx_vec_sse.c') + sources += files('ixgbe_recycle_mbufs_vec_common.c') if is_windows and cc.get_id() != 'clang' cflags += ['-fno-asynchronous-unwind-tables'] endif elif arch_subdir == 'arm' sources += files('ixgbe_rxtx_vec_neon.c') + sources += files('ixgbe_recycle_mbufs_vec_common.c') endif includes += include_directories('base')
Signature · 1 line
2.25.1
Re: [PATCH v13 3/4] net/ixgbe: implement mbufs recycle mode
25.09.2023 04:19, Feifei Wang пишет:
Quoted 10 lines
Define specific function implementation for ixgbe driver. Currently, recycle buffer mode can support 128bit vector path. And can be enabled both in fast free and no fast free mode.
Suggested-by Honnappa Nagarahalli <[email protected]>Signed-off-by Feifei Wang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>Reviewed-by Honnappa Nagarahalli <[email protected]>---
PATCH v13 4/4 app/testpmd: add recycle mbufs engine
In reply to Feifei WangAdd recycle mbufs engine for testpmd. This engine forward pkts with I/O forward mode. But enable mbufs recycle feature to recycle used txq mbufs for rxq mbuf ring, which can bypass mempool path and save CPU cycles.
--- app/test-pmd/meson.build | 1 + app/test-pmd/recycle_mbufs.c | 58 +++++++++++++++++++++ app/test-pmd/testpmd.c | 1 + app/test-pmd/testpmd.h | 3 ++ doc/guides/testpmd_app_ug/run_app.rst | 1 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 5 +- 6 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 app/test-pmd/recycle_mbufs.c
app/test-pmd/meson.build +1 -0
@@ -22,6 +22,7 @@ sources = files( 'macswap.c', 'noisy_vnf.c', 'parameters.c', + 'recycle_mbufs.c', 'rxonly.c', 'shared_rxq_fwd.c', 'testpmd.c',
app/test-pmd/recycle_mbufs.c new file +58 -0
58 lines not on this page · raw message
app/test-pmd/testpmd.c +1 -0
@@ -199,6 +199,7 @@ struct fwd_engine * fwd_engines[] = { &icmp_echo_engine, &noisy_vnf_engine, &five_tuple_swap_fwd_engine, + &recycle_mbufs_engine, #ifdef RTE_LIBRTE_IEEE1588 &ieee1588_fwd_engine, #endif
app/test-pmd/testpmd.h +3 -0
@@ -188,6 +188,8 @@ struct fwd_stream {struct pkt_burst_stats rx_burst_stats;struct pkt_burst_stats tx_burst_stats;struct fwd_lcore *lcore;/**< Lcore being scheduled. */ +/**< Rx queue information for recycling mbufs */ +struct rte_eth_recycle_rxq_info recycle_rxq_info; };/**
@@ -449,6 +451,7 @@ extern struct fwd_engine csum_fwd_engine;extern struct fwd_engine icmp_echo_engine;extern struct fwd_engine noisy_vnf_engine;extern struct fwd_engine five_tuple_swap_fwd_engine; +extern struct fwd_engine recycle_mbufs_engine;#ifdef RTE_LIBRTE_IEEE1588 extern struct fwd_engine ieee1588_fwd_engine;#endif
doc/guides/testpmd_app_ug/run_app.rst +1 -0
@@ -232,6 +232,7 @@ The command line options are: noisy 5tswap shared-rxq + recycle_mbufs * ``--rss-ip``
doc/guides/testpmd_app_ug/testpmd_funcs.rst +4 -1
@@ -318,7 +318,7 @@ set fwd Set the packet forwarding mode:: testpmd> set fwd (io|mac|macswap|flowgen| \ - rxonly|txonly|csum|icmpecho|noisy|5tswap|shared-rxq) (""|retry) + rxonly|txonly|csum|icmpecho|noisy|5tswap|shared-rxq|recycle_mbufs) (""|retry) ``retry`` can be specified for forwarding engines except ``rx_only``.
@@ -364,6 +364,9 @@ The available information categories are: * ``shared-rxq``: Receive only for shared Rx queue. Resolve packet source port from mbuf and update stream statistics accordingly. +* ``recycle_mbufs``: Recycle Tx queue used mbufs for Rx queue mbuf ring. + This mode uses fast path mbuf recycle feature and forwards packets in I/O mode. + Example:: testpmd> set fwd rxonly
Signature · 1 line
2.25.1
Re: [PATCH v13 4/4] app/testpmd: add recycle mbufs engine
25.09.2023 04:19, Feifei Wang пишет:
Quoted 9 lines
Add recycle mbufs engine for testpmd. This engine forward pkts with I/O forward mode. But enable mbufs recycle feature to recycle used txq mbufs for rxq mbuf ring, which can bypass mempool path and save CPU cycles.
Suggested-by Jerin Jacob <[email protected]>Signed-off-by Feifei Wang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>---
Ajit Khaparde
Acked-byRe: [PATCH v13 4/4] app/testpmd: add recycle mbufs engine
Quoted 7 lines · Konstantin Ananyev
25.09.2023 04:19, Feifei Wang пишет:
Quoted 5 lines
Add recycle mbufs engine for testpmd. This engine forward pkts with I/O forward mode. But enable mbufs recycle feature to recycle used txq mbufs for rxq mbuf ring, which can bypass mempool path and save CPU cycles.
Quoted 7 lines
Quoted 4 lines
Suggested-by Jerin Jacob <[email protected]>Signed-off-by Feifei Wang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>---
Quoted 1 line
Re: [PATCH v13 0/4] Recycle mbufs from Tx queue into Rx queue
In reply to Feifei WangQuoted 143 lines · Feifei Wang
Currently, the transmit side frees the buffers into the lcore cache and the receive side allocates buffers from the lcore cache. The transmit side typically frees 32 buffers resulting in 32*8=256B of stores to lcore cache. The receive side allocates 32 buffers and stores them in the receive side software ring, resulting in 32*8=256B of stores and 256B of load from the lcore cache.
This patch proposes a mechanism to avoid freeing to/allocating from the lcore cache. i.e. the receive side will free the buffers from transmit side directly into its software ring. This will avoid the 256B of loads and stores introduced by the lcore cache. It also frees up the cache lines used by the lcore cache. And we can call this mode as mbufs recycle mode.
In the latest version, mbufs recycle mode is packaged as a separate API.
This allows for the users to change rxq/txq pairing in real time in data plane, according to the analysis of the packet flow by the application, for example:
-----------------------------------------------------------------------
Step 1: upper application analyse the flow direction
Step 2:recycle_rxq_info=rte_eth_recycle_rx_queue_info_get(rx_portid, rx_queueid)Step 3:rte_eth_recycle_mbufs(rx_portid, rx_queueid, tx_portid, tx_queueid, recycle_rxq_info); Step 4:rte_eth_rx_burst(rx_portid,rx_queueid);
Step 5:rte_eth_tx_burst(tx_portid,tx_queueid);
-----------------------------------------------------------------------
Above can support user to change rxq/txq pairing at run-time and user does not need to know the direction of flow in advance. This can effectively expand mbufs recycle mode's use scenarios.Furthermore, mbufs recycle mode is no longer limited to the same pmd,
it can support moving mbufs between different vendor pmds, even can put the mbufs anywhere into your Rx mbuf ring as long as the address of the mbuf ring can be provided. In the latest version, we enable mbufs recycle mode in i40e pmd and ixgbe pmd, and also try to use i40e driver in Rx, ixgbe driver in Tx, and then achieve 7-9% performance improvement by mbufs recycle mode.Difference between mbuf recycle, ZC API used in mempool and general path
For general path:
Rx: 32 pkts memcpy from mempool cache torx_sw_ring
Tx: 32 pkts memcpy fromtx_sw_ringto temporary variable + 32 pkts memcpy from temporary variable to mempool cache
For ZC API used in mempool:
Rx: 32 pkts memcpy from mempool cache torx_sw_ring
Tx: 32 pkts memcpy fromtx_sw_ringto zero-copy mempool cache
Refer link: http://patches.dpdk.org/project/dpdk/patch/[email protected]/
For mbufs recycle:
Rx/Tx: 32 pkts memcpy fromtx_sw_ringtorx_sw_ring
Thus we can see in the one loop, compared to general path, mbufs recycle mode reduces 32+32=64 pkts memcpy; Compared to ZC API used in mempool, we can see mbufs recycle mode reduce 32 pkts memcpy in each loop.
So, mbufs recycle has its own benefits.Testing status:
(1) dpdk l3fwd test with multiple drivers:port 0: 82599 NIC port 1: XL710 NIC-------------------------------------------------------------
Without fast free With fast free
Thunderx2: +7.53% +13.54%
-------------------------------------------------------------(2) dpdk l3fwd test with same driver:
port 0 && 1: XL710 NIC-------------------------------------------------------------
Without fast free With fast free
Ampere altra: +12.61% +11.42%
n1sdp: +8.30% +3.85%
x86-sse: +8.43% +3.72%
-------------------------------------------------------------(3) Performance comparison with
ZC_mempoolused
port 0 && 1: XL710 NIC
with fast free
-------------------------------------------------------------
With recycle buffer Withzc_mempool
Ampere altra: 11.42% 3.54%
-------------------------------------------------------------Furthermore, we add
recycle_mbufengine in testpmd. Due to XL710 NIC has I/O bottleneck in testpmd in ampere altra, we can not see throughput change compared with I/O fwd engine. However, using record cmd in testpmd:
'$set record-burst-stats on'
we can see the ratio of 'Rx/Tx burst size of 32' is reduced. This indicate mbufs recycle can save CPU cycles.V2:
1. Use data-plane API to enable direct-rearm (Konstantin, Honnappa)
2. Add 'txq_data_get' API to get txq info for Rx (Konstantin)
3. Use input parameter to enable direct rearm in l3fwd (Konstantin)
4. Add condition detection for direct rearm API (Morten, Andrew Rybchenko)V3:
1. Seperate Rx and Tx operation with two APIs in direct-rearm (Konstantin)
2. Delete L3fwd change for direct rearm (Jerin)
3. enable direct rearm in ixgbe driver in Armv4:
1. Rename direct-rearm as buffer recycle. Based on this, function name and variable name are changed to let this mode more general for all drivers. (Konstantin, Morten)
2. Add ring wrapping check (Konstantin)v5:
1. some change for ethdev API (Morten)
2. add support for avx2, sse, altivec pathv6:
1. fix ixgbe build issue in ppc
2. remove 'recycle_tx_mbufs_reuse' and 'recycle_rx_descriptors_refill' API wrapper (Tech Board meeting)
3. addrecycle_mbufsengine in testpmd (Tech Board meeting)
4. add namespace in the functions related to mbufs recycle(Ferruh)v7:
1. move 'rxq/txq data' pointers to the beginning ofeth_devstructure, in order to keep them in the same cache line as rx/tx_burst function pointers (Morten)
2. add the extra description for 'rte_eth_recycle_mbufs' to show it can support feeding 1 Rx queue from 2 Tx queues in the same thread (Konstantin)
3. For i40e/ixgbe driver, make the previous copied buffers as invalid if there are Tx buffers refcnt > 1 or from unexpected mempool (Konstantin)
4. add check for the return value of 'rte_eth_recycle_rx_queue_info_get' in testpmd fwd engine (Morten)v8:
1. add arm/x86 build option to fix ixgbe build issue in ppcv9:
1. delete duplicate file name for ixgbev10:
1. fix compile issue on windowsv11:
1. fix doc warningv12:
1. replace rx queue check code witheth_dev_validate_rx_queuefunction (Stephen)
2. put port and queue check before function call (Konstantin)v13:
1. for i40e and ixgbe drivers, resetnb_recycle_mbufsto zero when rxep[i] == NULL, no matter what valuerefill_requirementis (Konstantin)
Quoted 6 lines
Feifei Wang (4):
ethdev: add API for mbufs recycle mode
net/i40e: implement mbufs recycle mode
net/ixgbe: implement mbufs recycle mode
app/testpmd: add recycle mbufs engine
Series applied to dpdk-next-net/main, thanks.