[PATCH] examples/l2fwd: add check of Rx packets count

Rahul Bhansali rbhansali at marvell.com
Wed May 25 11:13:27 CEST 2022


An additional check is added to avoid extra processing if
receive packets are 0.

Performance impact: with Marvell OCTEON TX2 platform, observed an
improvement by ~14%.

Signed-off-by: Rahul Bhansali <rbhansali at marvell.com>
---
 examples/l2fwd/main.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/examples/l2fwd/main.c b/examples/l2fwd/main.c
index 281c6b7a3f..28c498712e 100644
--- a/examples/l2fwd/main.c
+++ b/examples/l2fwd/main.c
@@ -286,6 +286,9 @@ l2fwd_main_loop(void)
 			nb_rx = rte_eth_rx_burst(portid, 0,
 						 pkts_burst, MAX_PKT_BURST);
 
+			if (unlikely(nb_rx == 0))
+				continue;
+
 			port_statistics[portid].rx += nb_rx;
 
 			for (j = 0; j < nb_rx; j++) {
-- 
2.25.1



More information about the dev mailing list