-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
app/testpmd: add recycle mbufs engine
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 <jerinjacobk@gmail.com> Signed-off-by: Feifei Wang <feifei.wang2@arm.com> Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com> Signed-off-by: 0-day Robot <robot@bytheb.org>
- Loading branch information
Showing
6 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* SPDX-License-Identifier: BSD-3-Clause | ||
* Copyright (c) 2023 Arm Limited. | ||
*/ | ||
|
||
#include "testpmd.h" | ||
|
||
/* | ||
* Forwarding of packets in I/O mode. | ||
* Enable mbufs recycle mode to recycle txq used mbufs | ||
* for rxq mbuf ring. This can bypass mempool path and | ||
* save CPU cycles. | ||
*/ | ||
static bool | ||
pkt_burst_recycle_mbufs(struct fwd_stream *fs) | ||
{ | ||
struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; | ||
uint16_t nb_rx; | ||
|
||
/* Recycle used mbufs from the txq, and move these mbufs into | ||
* the rxq mbuf ring. | ||
*/ | ||
rte_eth_recycle_mbufs(fs->rx_port, fs->rx_queue, | ||
fs->tx_port, fs->tx_queue, &(fs->recycle_rxq_info)); | ||
|
||
/* | ||
* Receive a burst of packets and forward them. | ||
*/ | ||
nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst); | ||
if (unlikely(nb_rx == 0)) | ||
return false; | ||
|
||
common_fwd_stream_transmit(fs, pkts_burst, nb_rx); | ||
|
||
return true; | ||
} | ||
|
||
static void | ||
recycle_mbufs_stream_init(struct fwd_stream *fs) | ||
{ | ||
int rc; | ||
|
||
/* Retrieve information about given ports's Rx queue | ||
* for recycling mbufs. | ||
*/ | ||
rc = rte_eth_recycle_rx_queue_info_get(fs->rx_port, | ||
fs->rx_queue, &(fs->recycle_rxq_info)); | ||
if (rc != 0) | ||
TESTPMD_LOG(WARNING, | ||
"Failed to get rx queue mbufs recycle info\n"); | ||
|
||
common_fwd_stream_init(fs); | ||
} | ||
|
||
struct fwd_engine recycle_mbufs_engine = { | ||
.fwd_mode_name = "recycle_mbufs", | ||
.stream_init = recycle_mbufs_stream_init, | ||
.packet_fwd = pkt_burst_recycle_mbufs, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -232,6 +232,7 @@ The command line options are: | |
noisy | ||
5tswap | ||
shared-rxq | ||
recycle_mbufs | ||
|
||
* ``--rss-ip`` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters