Tested-by: Dengdui Huang <huangdeng...@huawei.com> The issue addressed by this patch is the same as the one fixed by the patch [1] pushed by Haijie. However, this patch is better, and I have already tested it on the Kunpeng platform. Please make the changes based on Konstantin's review comments and push the next version.
[1] https://patchwork.dpdk.org/project/dpdk/patch/20241204020622.977156-1-haij...@huawei.com/ On 2025/2/12 12:54, Sivaprasad Tummala wrote: > Previously, the TX burst size was fixed at 256, leading to performance > degradation in certain scenarios. > > This patch introduces logic to set the TX burst size to match the > configured RX burst size (--burst option, default 32, max 512) > for better efficiency. > > Fixes: d5c4897ecfb2 ("examples/l3fwd: add option to set Rx burst size") > Cc: haij...@huawei.com > Cc: sta...@dpdk.org > > Signed-off-by: Sivaprasad Tummala <sivaprasad.tumm...@amd.com> > --- > examples/l3fwd/l3fwd.h | 6 +++--- > examples/l3fwd/l3fwd_common.h | 11 +++++++---- > examples/l3fwd/main.c | 2 ++ > 3 files changed, 12 insertions(+), 7 deletions(-) > > diff --git a/examples/l3fwd/l3fwd.h b/examples/l3fwd/l3fwd.h > index 0cce3406ee..9d7c73504b 100644 > --- a/examples/l3fwd/l3fwd.h > +++ b/examples/l3fwd/l3fwd.h > @@ -35,7 +35,7 @@ > /* > * Try to avoid TX buffering if we have at least MAX_TX_BURST packets to > send. > */ > -#define MAX_TX_BURST (MAX_PKT_BURST / 2) > +#define MAX_TX_BURST (DEFAULT_PKT_BURST / 2) > > #define NB_SOCKETS 8 > > @@ -152,8 +152,8 @@ send_single_packet(struct lcore_conf *qconf, > len++; > > /* enough pkts to be sent */ > - if (unlikely(len == MAX_PKT_BURST)) { > - send_burst(qconf, MAX_PKT_BURST, port); > + if (unlikely(len == nb_pkt_per_burst)) { > + send_burst(qconf, nb_pkt_per_burst, port); > len = 0; > } > > diff --git a/examples/l3fwd/l3fwd_common.h b/examples/l3fwd/l3fwd_common.h > index d94e5f1357..6cb7de5144 100644 > --- a/examples/l3fwd/l3fwd_common.h > +++ b/examples/l3fwd/l3fwd_common.h > @@ -25,6 +25,9 @@ > */ > #define SENDM_PORT_OVERHEAD(x) (x) > > +extern uint32_t nb_pkt_per_burst; > +extern uint32_t max_tx_burst; > + > /* > * From http://www.rfc-editor.org/rfc/rfc1812.txt section 5.2.2: > * - The IP version number must be 4. > @@ -71,7 +74,7 @@ send_packetsx4(struct lcore_conf *qconf, uint16_t port, > struct rte_mbuf *m[], > * If TX buffer for that queue is empty, and we have enough packets, > * then send them straightway. > */ > - if (num >= MAX_TX_BURST && len == 0) { > + if (num >= max_tx_burst && len == 0) { > n = rte_eth_tx_burst(port, qconf->tx_queue_id[port], m, num); > if (unlikely(n < num)) { > do { > @@ -86,7 +89,7 @@ send_packetsx4(struct lcore_conf *qconf, uint16_t port, > struct rte_mbuf *m[], > */ > > n = len + num; > - n = (n > MAX_PKT_BURST) ? MAX_PKT_BURST - len : num; > + n = (n > nb_pkt_per_burst) ? nb_pkt_per_burst - len : num; > > j = 0; > switch (n % FWDSTEP) { > @@ -112,9 +115,9 @@ send_packetsx4(struct lcore_conf *qconf, uint16_t port, > struct rte_mbuf *m[], > len += n; > > /* enough pkts to be sent */ > - if (unlikely(len == MAX_PKT_BURST)) { > + if (unlikely(len == nb_pkt_per_burst)) { > > - send_burst(qconf, MAX_PKT_BURST, port); > + send_burst(qconf, nb_pkt_per_burst, port); > > /* copy rest of the packets into the TX buffer. */ > len = num - n; > diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c > index 994b7dd8e5..4cabd05be2 100644 > --- a/examples/l3fwd/main.c > +++ b/examples/l3fwd/main.c > @@ -59,6 +59,7 @@ uint16_t nb_rxd = RX_DESC_DEFAULT; > uint16_t nb_txd = TX_DESC_DEFAULT; > uint32_t nb_pkt_per_burst = DEFAULT_PKT_BURST; > uint32_t mb_mempool_cache_size = MEMPOOL_CACHE_SIZE; > +uint32_t max_tx_burst = MAX_TX_BURST; > > /**< Ports set in promiscuous mode off by default. */ > static int promiscuous_on; > @@ -733,6 +734,7 @@ parse_pkt_burst(const char *optarg) > return; > } > nb_pkt_per_burst = burst_size; > + max_tx_burst = burst_size / 2; > RTE_LOG(INFO, L3FWD, "Using PMD-provided burst value %d\n", burst_size); > } >