* [PATCH] examples/l3fwd: adjust Tx burst size based on Rx burst
@ 2025-02-12 4:54 Sivaprasad Tummala
2025-02-12 9:17 ` Ande, Venkat Kumar
` (3 more replies)
0 siblings, 4 replies; 11+ messages in thread
From: Sivaprasad Tummala @ 2025-02-12 4:54 UTC (permalink / raw)
To: david.hunt, anatoly.burakov, jerinj, radu.nicolau, gakhil,
cristian.dumitrescu, ferruh.yigit, konstantin.ananyev, mb
Cc: dev, haijie1, stable
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: haijie1@huawei.com
Cc: stable@dpdk.org
Signed-off-by: Sivaprasad Tummala <sivaprasad.tummala@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);
}
--
2.34.1
^ permalink raw reply [flat|nested] 11+ messages in thread* RE: [PATCH] examples/l3fwd: adjust Tx burst size based on Rx burst 2025-02-12 4:54 [PATCH] examples/l3fwd: adjust Tx burst size based on Rx burst Sivaprasad Tummala @ 2025-02-12 9:17 ` Ande, Venkat Kumar 2025-02-12 9:46 ` Ande, Venkat Kumar ` (2 subsequent siblings) 3 siblings, 0 replies; 11+ messages in thread From: Ande, Venkat Kumar @ 2025-02-12 9:17 UTC (permalink / raw) To: Tummala, Sivaprasad, david.hunt, anatoly.burakov, jerinj, radu.nicolau, gakhil, cristian.dumitrescu, Yigit, Ferruh, konstantin.ananyev, mb Cc: dev, haijie1, stable [AMD Official Use Only - AMD Internal Distribution Only] -----Original Message----- From: Sivaprasad Tummala <sivaprasad.tummala@amd.com> Sent: Wednesday, February 12, 2025 10:24 AM To: david.hunt@intel.com; anatoly.burakov@intel.com; jerinj@marvell.com; radu.nicolau@intel.com; gakhil@marvell.com; cristian.dumitrescu@intel.com; Yigit, Ferruh <Ferruh.Yigit@amd.com>; konstantin.ananyev@huawei.com; mb@smartsharesystems.com Cc: dev@dpdk.org; haijie1@huawei.com; stable@dpdk.org Subject: [PATCH] examples/l3fwd: adjust Tx burst size based on Rx burst Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding. 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: haijie1@huawei.com Cc: stable@dpdk.org Signed-off-by: Sivaprasad Tummala <sivaprasad.tummala@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); } -- 2.34.1 Tested-by: Venkat Kumar Ande <VenkatKumar.Ande@amd.com> ^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: [PATCH] examples/l3fwd: adjust Tx burst size based on Rx burst 2025-02-12 4:54 [PATCH] examples/l3fwd: adjust Tx burst size based on Rx burst Sivaprasad Tummala 2025-02-12 9:17 ` Ande, Venkat Kumar @ 2025-02-12 9:46 ` Ande, Venkat Kumar 2025-02-19 16:59 ` Konstantin Ananyev 2025-06-09 9:58 ` [PATCH v2] " Sivaprasad Tummala 3 siblings, 0 replies; 11+ messages in thread From: Ande, Venkat Kumar @ 2025-02-12 9:46 UTC (permalink / raw) To: Tummala, Sivaprasad, david.hunt, anatoly.burakov, jerinj, radu.nicolau, gakhil, cristian.dumitrescu, Yigit, Ferruh, konstantin.ananyev, mb Cc: dev, haijie1, stable [AMD Official Use Only - AMD Internal Distribution Only] Tested-by: Venkat Kumar Ande <VenkatKumar.Ande@amd.com> -----Original Message----- From: Sivaprasad Tummala <sivaprasad.tummala@amd.com> Sent: Wednesday, February 12, 2025 10:24 AM To: david.hunt@intel.com; anatoly.burakov@intel.com; jerinj@marvell.com; radu.nicolau@intel.com; gakhil@marvell.com; cristian.dumitrescu@intel.com; Yigit, Ferruh <Ferruh.Yigit@amd.com>; konstantin.ananyev@huawei.com; mb@smartsharesystems.com Cc: dev@dpdk.org; haijie1@huawei.com; stable@dpdk.org Subject: [PATCH] examples/l3fwd: adjust Tx burst size based on Rx burst Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding. 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: haijie1@huawei.com Cc: stable@dpdk.org Signed-off-by: Sivaprasad Tummala <sivaprasad.tummala@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); } -- 2.34.1 ^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: [PATCH] examples/l3fwd: adjust Tx burst size based on Rx burst 2025-02-12 4:54 [PATCH] examples/l3fwd: adjust Tx burst size based on Rx burst Sivaprasad Tummala 2025-02-12 9:17 ` Ande, Venkat Kumar 2025-02-12 9:46 ` Ande, Venkat Kumar @ 2025-02-19 16:59 ` Konstantin Ananyev 2025-06-09 9:58 ` [PATCH v2] " Sivaprasad Tummala 3 siblings, 0 replies; 11+ messages in thread From: Konstantin Ananyev @ 2025-02-19 16:59 UTC (permalink / raw) To: Sivaprasad Tummala, david.hunt, anatoly.burakov, jerinj, radu.nicolau, gakhil, cristian.dumitrescu, ferruh.yigit, mb Cc: dev, haijie, stable > 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: haijie1@huawei.com > Cc: stable@dpdk.org > > Signed-off-by: Sivaprasad Tummala <sivaprasad.tummala@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; Might be a bit better then to completely remove MAX_TX_BURST, and just always set: max_tx_burst = nb_pkt_per_burst / 2; > RTE_LOG(INFO, L3FWD, "Using PMD-provided burst value %d\n", burst_size); > } > > -- > 2.34.1 ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2] examples/l3fwd: adjust Tx burst size based on Rx burst 2025-02-12 4:54 [PATCH] examples/l3fwd: adjust Tx burst size based on Rx burst Sivaprasad Tummala ` (2 preceding siblings ...) 2025-02-19 16:59 ` Konstantin Ananyev @ 2025-06-09 9:58 ` Sivaprasad Tummala 2025-06-09 15:21 ` Stephen Hemminger ` (2 more replies) 3 siblings, 3 replies; 11+ messages in thread From: Sivaprasad Tummala @ 2025-06-09 9:58 UTC (permalink / raw) To: david.hunt, anatoly.burakov, jerinj, radu.nicolau, gakhil, cristian.dumitrescu, Ferruh.Yigit, konstantin.ananyev, mb Cc: dev, haijie1, stable, Venkat Kumar Ande, Dengdui Huang 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: haijie1@huawei.com Cc: stable@dpdk.org Signed-off-by: Sivaprasad Tummala <sivaprasad.tummala@amd.com> Tested-by: Venkat Kumar Ande <VenkatKumar.Ande@amd.com> Tested-by: Dengdui Huang <huangdengdui@huawei.com> --- examples/l3fwd/l3fwd.h | 8 ++------ examples/l3fwd/l3fwd_common.h | 11 +++++++---- examples/l3fwd/main.c | 2 ++ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/examples/l3fwd/l3fwd.h b/examples/l3fwd/l3fwd.h index 0cce3406ee..bbc54bcfae 100644 --- a/examples/l3fwd/l3fwd.h +++ b/examples/l3fwd/l3fwd.h @@ -32,10 +32,6 @@ #define VECTOR_SIZE_DEFAULT MAX_PKT_BURST #define VECTOR_TMO_NS_DEFAULT 1E6 /* 1ms */ -/* - * 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 NB_SOCKETS 8 @@ -152,8 +148,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 ae3b4f6439..8353e8e16f 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 = DEFAULT_PKT_BURST / 2; /**< Ports set in promiscuous mode off by default. */ static int promiscuous_on; @@ -734,6 +735,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); } -- 2.34.1 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2] examples/l3fwd: adjust Tx burst size based on Rx burst 2025-06-09 9:58 ` [PATCH v2] " Sivaprasad Tummala @ 2025-06-09 15:21 ` Stephen Hemminger 2025-06-10 14:29 ` [EXTERNAL] " Pavan Nikhilesh Bhagavatula 2025-11-06 14:16 ` [PATCH v3] examples/l3fwd: add Tx burst size configuration option Sivaprasad Tummala 2 siblings, 0 replies; 11+ messages in thread From: Stephen Hemminger @ 2025-06-09 15:21 UTC (permalink / raw) To: Sivaprasad Tummala Cc: david.hunt, anatoly.burakov, jerinj, radu.nicolau, gakhil, cristian.dumitrescu, Ferruh.Yigit, konstantin.ananyev, mb, dev, haijie1, stable, Venkat Kumar Ande, Dengdui Huang On Mon, 9 Jun 2025 09:58:27 +0000 Sivaprasad Tummala <sivaprasad.tummala@amd.com> 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: haijie1@huawei.com > Cc: stable@dpdk.org > > Signed-off-by: Sivaprasad Tummala <sivaprasad.tummala@amd.com> > Tested-by: Venkat Kumar Ande <VenkatKumar.Ande@amd.com> > Tested-by: Dengdui Huang <huangdengdui@huawei.com> What driver? Why not fix the driver. If RX burst is small, there should be no way to get TX burst larger than that to happen. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [EXTERNAL] [PATCH v2] examples/l3fwd: adjust Tx burst size based on Rx burst 2025-06-09 9:58 ` [PATCH v2] " Sivaprasad Tummala 2025-06-09 15:21 ` Stephen Hemminger @ 2025-06-10 14:29 ` Pavan Nikhilesh Bhagavatula 2025-10-09 2:32 ` Tummala, Sivaprasad 2025-11-06 14:16 ` [PATCH v3] examples/l3fwd: add Tx burst size configuration option Sivaprasad Tummala 2 siblings, 1 reply; 11+ messages in thread From: Pavan Nikhilesh Bhagavatula @ 2025-06-10 14:29 UTC (permalink / raw) To: Sivaprasad Tummala, david.hunt, anatoly.burakov, Jerin Jacob, radu.nicolau, Akhil Goyal, cristian.dumitrescu, Ferruh.Yigit, konstantin.ananyev, mb Cc: dev, haijie1, stable, Venkat Kumar Ande, Dengdui Huang >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: haijie1@huawei.com >Cc: stable@dpdk.org > >Signed-off-by: Sivaprasad Tummala <sivaprasad.tummala@amd.com> >Tested-by: Venkat Kumar Ande <VenkatKumar.Ande@amd.com> >Tested-by: Dengdui Huang <huangdengdui@huawei.com> It would be good if the selected burst sizes of Rx and Tx are logged. On CN10K platform we see upto 5% improvement, and upto 30% improvement on CN9K. Tested-by: Pavan Nikhilesh <pbhagavatula@marvell.com> >--- > examples/l3fwd/l3fwd.h | 8 ++------ > examples/l3fwd/l3fwd_common.h | 11 +++++++---- > examples/l3fwd/main.c | 2 ++ > 3 files changed, 11 insertions(+), 10 deletions(-) ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [EXTERNAL] [PATCH v2] examples/l3fwd: adjust Tx burst size based on Rx burst 2025-06-10 14:29 ` [EXTERNAL] " Pavan Nikhilesh Bhagavatula @ 2025-10-09 2:32 ` Tummala, Sivaprasad 2025-10-31 9:18 ` fengchengwen 0 siblings, 1 reply; 11+ messages in thread From: Tummala, Sivaprasad @ 2025-10-09 2:32 UTC (permalink / raw) To: Pavan Nikhilesh Bhagavatula, david.hunt, anatoly.burakov, Jerin Jacob, radu.nicolau, Akhil Goyal, cristian.dumitrescu, Yigit, Ferruh, konstantin.ananyev, mb Cc: dev, haijie1, stable, Ande, Venkat Kumar, Dengdui Huang [-- Attachment #1: Type: text/plain, Size: 2169 bytes --] [AMD Official Use Only - AMD Internal Distribution Only] Hi Pavan, Please find my response inline. ________________________________ From: Pavan Nikhilesh Bhagavatula <pbhagavatula@marvell.com> Sent: Tuesday, June 10, 2025 7:59 PM To: Tummala, Sivaprasad <Sivaprasad.Tummala@amd.com>; david.hunt@intel.com <david.hunt@intel.com>; anatoly.burakov@intel.com <anatoly.burakov@intel.com>; Jerin Jacob <jerinj@marvell.com>; radu.nicolau@intel.com <radu.nicolau@intel.com>; Akhil Goyal <gakhil@marvell.com>; cristian.dumitrescu@intel.com <cristian.dumitrescu@intel.com>; Yigit, Ferruh <Ferruh.Yigit@amd.com>; konstantin.ananyev@huawei.com <konstantin.ananyev@huawei.com>; mb@smartsharesystems.com <mb@smartsharesystems.com> Cc: dev@dpdk.org <dev@dpdk.org>; haijie1@huawei.com <haijie1@huawei.com>; stable@dpdk.org <stable@dpdk.org>; Ande, Venkat Kumar <VenkatKumar.Ande@amd.com>; Dengdui Huang <huangdengdui@huawei.com> Subject: Re: [EXTERNAL] [PATCH v2] examples/l3fwd: adjust Tx burst size based on Rx burst Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding. >>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: haijie1@huawei.com >>Cc: stable@dpdk.org >> >>Signed-off-by: Sivaprasad Tummala <sivaprasad.tummala@amd.com> >>Tested-by: Venkat Kumar Ande <VenkatKumar.Ande@amd.com> >>Tested-by: Dengdui Huang <huangdengdui@huawei.com> >It would be good if the selected burst sizes of Rx and Tx are logged. ACK >On CN10K platform we see upto 5% improvement, and upto 30% improvement on CN9K. >Tested-by: Pavan Nikhilesh <pbhagavatula@marvell.com> >--- > examples/l3fwd/l3fwd.h | 8 ++------ > examples/l3fwd/l3fwd_common.h | 11 +++++++---- > examples/l3fwd/main.c | 2 ++ > 3 files changed, 11 insertions(+), 10 deletions(-) [-- Attachment #2: Type: text/html, Size: 4085 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [EXTERNAL] [PATCH v2] examples/l3fwd: adjust Tx burst size based on Rx burst 2025-10-09 2:32 ` Tummala, Sivaprasad @ 2025-10-31 9:18 ` fengchengwen 2025-11-01 12:53 ` Tummala, Sivaprasad 0 siblings, 1 reply; 11+ messages in thread From: fengchengwen @ 2025-10-31 9:18 UTC (permalink / raw) To: Tummala, Sivaprasad, Pavan Nikhilesh Bhagavatula, david.hunt, anatoly.burakov, Jerin Jacob, radu.nicolau, Akhil Goyal, cristian.dumitrescu, Yigit, Ferruh, konstantin.ananyev, mb Cc: dev, haijie1, stable, Ande, Venkat Kumar, Dengdui Huang Hi Sivaprasad, Are you going to send v3 (add log) version? There is another patch about adjust burst size [1], if this patch don't continue, maybe we should restart that one. [1] https://patchwork.dpdk.org/project/dpdk/patch/20241204020622.977156-1-haijie1@huawei.com/ Thanks On 10/9/2025 10:32 AM, Tummala, Sivaprasad wrote: > [AMD Official Use Only - AMD Internal Distribution Only] > > Hi Pavan, > > Please find my response inline. > > ________________________________ > From: Pavan Nikhilesh Bhagavatula <pbhagavatula@marvell.com> > Sent: Tuesday, June 10, 2025 7:59 PM > To: Tummala, Sivaprasad <Sivaprasad.Tummala@amd.com>; david.hunt@intel.com <david.hunt@intel.com>; anatoly.burakov@intel.com <anatoly.burakov@intel.com>; Jerin Jacob <jerinj@marvell.com>; radu.nicolau@intel.com <radu.nicolau@intel.com>; Akhil Goyal <gakhil@marvell.com>; cristian.dumitrescu@intel.com <cristian.dumitrescu@intel.com>; Yigit, Ferruh <Ferruh.Yigit@amd.com>; konstantin.ananyev@huawei.com <konstantin.ananyev@huawei.com>; mb@smartsharesystems.com <mb@smartsharesystems.com> > Cc: dev@dpdk.org <dev@dpdk.org>; haijie1@huawei.com <haijie1@huawei.com>; stable@dpdk.org <stable@dpdk.org>; Ande, Venkat Kumar <VenkatKumar.Ande@amd.com>; Dengdui Huang <huangdengdui@huawei.com> > Subject: Re: [EXTERNAL] [PATCH v2] examples/l3fwd: adjust Tx burst size based on Rx burst > > Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding. > > >>> 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: haijie1@huawei.com >>> Cc: stable@dpdk.org >>> >>> Signed-off-by: Sivaprasad Tummala <sivaprasad.tummala@amd.com> >>> Tested-by: Venkat Kumar Ande <VenkatKumar.Ande@amd.com> >>> Tested-by: Dengdui Huang <huangdengdui@huawei.com> > >> It would be good if the selected burst sizes of Rx and Tx are logged. > ACK > >> On CN10K platform we see upto 5% improvement, and upto 30% improvement on CN9K. > >> Tested-by: Pavan Nikhilesh <pbhagavatula@marvell.com> > >> --- >> examples/l3fwd/l3fwd.h | 8 ++------ >> examples/l3fwd/l3fwd_common.h | 11 +++++++---- >> examples/l3fwd/main.c | 2 ++ >> 3 files changed, 11 insertions(+), 10 deletions(-) > > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [EXTERNAL] [PATCH v2] examples/l3fwd: adjust Tx burst size based on Rx burst 2025-10-31 9:18 ` fengchengwen @ 2025-11-01 12:53 ` Tummala, Sivaprasad 0 siblings, 0 replies; 11+ messages in thread From: Tummala, Sivaprasad @ 2025-11-01 12:53 UTC (permalink / raw) To: fengchengwen, Pavan Nikhilesh Bhagavatula, david.hunt, anatoly.burakov, Jerin Jacob, radu.nicolau, Akhil Goyal, cristian.dumitrescu, Yigit, Ferruh, konstantin.ananyev, mb Cc: dev, haijie1, stable, Ande, Venkat Kumar, Dengdui Huang [-- Attachment #1: Type: text/plain, Size: 3838 bytes --] [AMD Official Use Only - AMD Internal Distribution Only] Hi Fengchengwen, I will send the v3 patch early next week. Thanks & Regards, Sivaprasad ________________________________ From: fengchengwen <fengchengwen@huawei.com> Sent: Friday, October 31, 2025 2:48 PM To: Tummala, Sivaprasad <Sivaprasad.Tummala@amd.com>; Pavan Nikhilesh Bhagavatula <pbhagavatula@marvell.com>; david.hunt@intel.com <david.hunt@intel.com>; anatoly.burakov@intel.com <anatoly.burakov@intel.com>; Jerin Jacob <jerinj@marvell.com>; radu.nicolau@intel.com <radu.nicolau@intel.com>; Akhil Goyal <gakhil@marvell.com>; cristian.dumitrescu@intel.com <cristian.dumitrescu@intel.com>; Yigit, Ferruh <Ferruh.Yigit@amd.com>; konstantin.ananyev@huawei.com <konstantin.ananyev@huawei.com>; mb@smartsharesystems.com <mb@smartsharesystems.com> Cc: dev@dpdk.org <dev@dpdk.org>; haijie1@huawei.com <haijie1@huawei.com>; stable@dpdk.org <stable@dpdk.org>; Ande, Venkat Kumar <VenkatKumar.Ande@amd.com>; Dengdui Huang <huangdengdui@huawei.com> Subject: Re: [EXTERNAL] [PATCH v2] examples/l3fwd: adjust Tx burst size based on Rx burst Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding. Hi Sivaprasad, Are you going to send v3 (add log) version? There is another patch about adjust burst size [1], if this patch don't continue, maybe we should restart that one. [1] https://patchwork.dpdk.org/project/dpdk/patch/20241204020622.977156-1-haijie1@huawei.com/ Thanks On 10/9/2025 10:32 AM, Tummala, Sivaprasad wrote: > [AMD Official Use Only - AMD Internal Distribution Only] > > Hi Pavan, > > Please find my response inline. > > ________________________________ > From: Pavan Nikhilesh Bhagavatula <pbhagavatula@marvell.com> > Sent: Tuesday, June 10, 2025 7:59 PM > To: Tummala, Sivaprasad <Sivaprasad.Tummala@amd.com>; david.hunt@intel.com <david.hunt@intel.com>; anatoly.burakov@intel.com <anatoly.burakov@intel.com>; Jerin Jacob <jerinj@marvell.com>; radu.nicolau@intel.com <radu.nicolau@intel.com>; Akhil Goyal <gakhil@marvell.com>; cristian.dumitrescu@intel.com <cristian.dumitrescu@intel.com>; Yigit, Ferruh <Ferruh.Yigit@amd.com>; konstantin.ananyev@huawei.com <konstantin.ananyev@huawei.com>; mb@smartsharesystems.com <mb@smartsharesystems.com> > Cc: dev@dpdk.org <dev@dpdk.org>; haijie1@huawei.com <haijie1@huawei.com>; stable@dpdk.org <stable@dpdk.org>; Ande, Venkat Kumar <VenkatKumar.Ande@amd.com>; Dengdui Huang <huangdengdui@huawei.com> > Subject: Re: [EXTERNAL] [PATCH v2] examples/l3fwd: adjust Tx burst size based on Rx burst > > Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding. > > >>> 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: haijie1@huawei.com >>> Cc: stable@dpdk.org >>> >>> Signed-off-by: Sivaprasad Tummala <sivaprasad.tummala@amd.com> >>> Tested-by: Venkat Kumar Ande <VenkatKumar.Ande@amd.com> >>> Tested-by: Dengdui Huang <huangdengdui@huawei.com> > >> It would be good if the selected burst sizes of Rx and Tx are logged. > ACK > >> On CN10K platform we see upto 5% improvement, and upto 30% improvement on CN9K. > >> Tested-by: Pavan Nikhilesh <pbhagavatula@marvell.com> > >> --- >> examples/l3fwd/l3fwd.h | 8 ++------ >> examples/l3fwd/l3fwd_common.h | 11 +++++++---- >> examples/l3fwd/main.c | 2 ++ >> 3 files changed, 11 insertions(+), 10 deletions(-) > > [-- Attachment #2: Type: text/html, Size: 6448 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v3] examples/l3fwd: add Tx burst size configuration option 2025-06-09 9:58 ` [PATCH v2] " Sivaprasad Tummala 2025-06-09 15:21 ` Stephen Hemminger 2025-06-10 14:29 ` [EXTERNAL] " Pavan Nikhilesh Bhagavatula @ 2025-11-06 14:16 ` Sivaprasad Tummala 2 siblings, 0 replies; 11+ messages in thread From: Sivaprasad Tummala @ 2025-11-06 14:16 UTC (permalink / raw) To: Morten Brørup, Huisong Li, Chengwen Feng, Jie Hai Cc: dev, stable, Venkat Kumar Ande, Dengdui Huang, Pavan Nikhilesh Previously, the TX burst size in l3fwd was fixed at 256, which could lead to suboptimal performance in certain scenarios. This patch introduces separate --rx-burst and --tx-burst options to explicitly configure RX and TX burst sizes. By default, the TX burst size now matches the RX burst size for better efficiency and pipeline balance. Fixes: d5c4897ecfb2 ("examples/l3fwd: add option to set Rx burst size") Cc: haijie1@huawei.com Cc: stable@dpdk.org Signed-off-by: Sivaprasad Tummala <sivaprasad.tummala@amd.com> Tested-by: Venkat Kumar Ande <venkatkumar.ande@amd.com> Tested-by: Dengdui Huang <huangdengdui@huawei.com> Tested-by: Pavan Nikhilesh <pbhagavatula@marvell.com> v3: - Added --tx-burst option to allow independent TX burst configuration - Renamed --burst to --rx-burst for clarity - Renamed variables for clarity: - nb_pkt_per_burst → rx_burst_size - max_tx_burst → tx_burst_size - Modified parsing packet burst logic for RX and TX - Default TX burst size now equals RX burst size - Added logging of selected RX and TX burst sizes - Updated documentation for --rx-burst and --tx-burst options --- doc/guides/sample_app_ug/l3_forward.rst | 6 ++ examples/l3fwd/l3fwd.h | 10 +-- examples/l3fwd/l3fwd_acl.c | 2 +- examples/l3fwd/l3fwd_common.h | 5 +- examples/l3fwd/l3fwd_em.c | 2 +- examples/l3fwd/l3fwd_fib.c | 2 +- examples/l3fwd/l3fwd_lpm.c | 2 +- examples/l3fwd/main.c | 81 ++++++++++++++++--------- 8 files changed, 68 insertions(+), 42 deletions(-) diff --git a/doc/guides/sample_app_ug/l3_forward.rst b/doc/guides/sample_app_ug/l3_forward.rst index 9b0d0350aa..dfe9d68c99 100644 --- a/doc/guides/sample_app_ug/l3_forward.rst +++ b/doc/guides/sample_app_ug/l3_forward.rst @@ -77,6 +77,8 @@ The application has a number of command line options:: [-P] [--lookup LOOKUP_METHOD] --config(port,queue,lcore)[,(port,queue,lcore)] + [--rx-burst NPKTS] + [--tx-burst NPKTS] [--eth-dest=X,MM:MM:MM:MM:MM:MM] [--max-pkt-len PKTLEN] [--no-numa] @@ -113,6 +115,10 @@ Where, * ``--config (port,queue,lcore)[,(port,queue,lcore)]:`` Determines which queues from which ports are mapped to which cores. +* ``--rx-burst NPKTS:`` Optional, RX burst size in decimal (default 32). + +* ``--tx-burst NPKTS:`` Optional, TX burst size in decimal (default 32). + * ``--eth-dest=X,MM:MM:MM:MM:MM:MM:`` Optional, ethernet destination for port X. * ``--max-pkt-len:`` Optional, maximum packet length in decimal (64-9600). diff --git a/examples/l3fwd/l3fwd.h b/examples/l3fwd/l3fwd.h index 0cce3406ee..471e3b488f 100644 --- a/examples/l3fwd/l3fwd.h +++ b/examples/l3fwd/l3fwd.h @@ -32,10 +32,6 @@ #define VECTOR_SIZE_DEFAULT MAX_PKT_BURST #define VECTOR_TMO_NS_DEFAULT 1E6 /* 1ms */ -/* - * 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 NB_SOCKETS 8 @@ -116,7 +112,7 @@ extern struct acl_algorithms acl_alg[]; extern uint32_t max_pkt_len; -extern uint32_t nb_pkt_per_burst; +extern uint32_t rx_burst_size; extern uint32_t mb_mempool_cache_size; /* Send burst of packets on an output interface */ @@ -152,8 +148,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 == rx_burst_size)) { + send_burst(qconf, rx_burst_size, port); len = 0; } diff --git a/examples/l3fwd/l3fwd_acl.c b/examples/l3fwd/l3fwd_acl.c index 4fc4b986cc..a1275e18bc 100644 --- a/examples/l3fwd/l3fwd_acl.c +++ b/examples/l3fwd/l3fwd_acl.c @@ -1136,7 +1136,7 @@ acl_main_loop(__rte_unused void *dummy) portid = qconf->rx_queue_list[i].port_id; queueid = qconf->rx_queue_list[i].queue_id; nb_rx = rte_eth_rx_burst(portid, queueid, - pkts_burst, nb_pkt_per_burst); + pkts_burst, rx_burst_size); if (nb_rx > 0) { nb_drop = acl_process_pkts(pkts_burst, hops, diff --git a/examples/l3fwd/l3fwd_common.h b/examples/l3fwd/l3fwd_common.h index d94e5f1357..ccaf0cd402 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 rx_burst_size; +extern uint32_t tx_burst_size; + /* * 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 >= tx_burst_size && len == 0) { n = rte_eth_tx_burst(port, qconf->tx_queue_id[port], m, num); if (unlikely(n < num)) { do { diff --git a/examples/l3fwd/l3fwd_em.c b/examples/l3fwd/l3fwd_em.c index da9c45e3a4..58c54ed77e 100644 --- a/examples/l3fwd/l3fwd_em.c +++ b/examples/l3fwd/l3fwd_em.c @@ -644,7 +644,7 @@ em_main_loop(__rte_unused void *dummy) portid = qconf->rx_queue_list[i].port_id; queueid = qconf->rx_queue_list[i].queue_id; nb_rx = rte_eth_rx_burst(portid, queueid, pkts_burst, - nb_pkt_per_burst); + rx_burst_size); if (nb_rx == 0) continue; diff --git a/examples/l3fwd/l3fwd_fib.c b/examples/l3fwd/l3fwd_fib.c index 82f1739df7..4fc6bf90d5 100644 --- a/examples/l3fwd/l3fwd_fib.c +++ b/examples/l3fwd/l3fwd_fib.c @@ -239,7 +239,7 @@ fib_main_loop(__rte_unused void *dummy) portid = qconf->rx_queue_list[i].port_id; queueid = qconf->rx_queue_list[i].queue_id; nb_rx = rte_eth_rx_burst(portid, queueid, pkts_burst, - nb_pkt_per_burst); + rx_burst_size); if (nb_rx == 0) continue; diff --git a/examples/l3fwd/l3fwd_lpm.c b/examples/l3fwd/l3fwd_lpm.c index fec0aeb79c..a71eee69ec 100644 --- a/examples/l3fwd/l3fwd_lpm.c +++ b/examples/l3fwd/l3fwd_lpm.c @@ -205,7 +205,7 @@ lpm_main_loop(__rte_unused void *dummy) portid = qconf->rx_queue_list[i].port_id; queueid = qconf->rx_queue_list[i].queue_id; nb_rx = rte_eth_rx_burst(portid, queueid, pkts_burst, - nb_pkt_per_burst); + rx_burst_size); if (nb_rx == 0) continue; diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c index ae3b4f6439..ddd6fec344 100644 --- a/examples/l3fwd/main.c +++ b/examples/l3fwd/main.c @@ -57,8 +57,9 @@ static_assert(MEMPOOL_CACHE_SIZE >= MAX_PKT_BURST, "MAX_PKT_BURST should be at most MEMPOOL_CACHE_SIZE"); 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 rx_burst_size = DEFAULT_PKT_BURST; uint32_t mb_mempool_cache_size = MEMPOOL_CACHE_SIZE; +uint32_t tx_burst_size = DEFAULT_PKT_BURST; /**< Ports set in promiscuous mode off by default. */ static int promiscuous_on; @@ -400,7 +401,8 @@ print_usage(const char *prgname) " --config (port,queue,lcore)[,(port,queue,lcore)]" " [--rx-queue-size NPKTS]" " [--tx-queue-size NPKTS]" - " [--burst NPKTS]" + " [--rx-burst NPKTS]" + " [--tx-burst NPKTS]" " [--mbcache CACHESZ]" " [--eth-dest=X,MM:MM:MM:MM:MM:MM]" " [--max-pkt-len PKTLEN]" @@ -427,7 +429,9 @@ print_usage(const char *prgname) " Default: %d\n" " --tx-queue-size NPKTS: Tx queue size in decimal\n" " Default: %d\n" - " --burst NPKTS: Burst size in decimal\n" + " --rx-burst NPKTS: RX Burst size in decimal\n" + " Default: %d\n" + " --tx-burst NPKTS: TX Burst size in decimal\n" " Default: %d\n" " --mbcache CACHESZ: Mbuf cache size in decimal\n" " Default: %d\n" @@ -460,8 +464,8 @@ print_usage(const char *prgname) " another is route entry at while line leads with character '%c'.\n" " --rule_ipv6=FILE: Specify the ipv6 rules entries file.\n" " --alg: ACL classify method to use, one of: %s.\n\n", - prgname, RX_DESC_DEFAULT, TX_DESC_DEFAULT, DEFAULT_PKT_BURST, MEMPOOL_CACHE_SIZE, - ACL_LEAD_CHAR, ROUTE_LEAD_CHAR, alg); + prgname, RX_DESC_DEFAULT, TX_DESC_DEFAULT, DEFAULT_PKT_BURST, DEFAULT_PKT_BURST, + MEMPOOL_CACHE_SIZE, ACL_LEAD_CHAR, ROUTE_LEAD_CHAR, alg); } static int @@ -695,7 +699,7 @@ parse_mbcache_size(const char *optarg) } static void -parse_pkt_burst(const char *optarg) +parse_pkt_burst(const char *optarg, bool is_rx_burst, uint32_t *burst_sz) { struct rte_eth_dev_info dev_info; unsigned long pkt_burst; @@ -710,31 +714,38 @@ parse_pkt_burst(const char *optarg) if (pkt_burst > MAX_PKT_BURST) { RTE_LOG(INFO, L3FWD, "User provided burst must be <= %d. Using default value %d\n", - MAX_PKT_BURST, nb_pkt_per_burst); + MAX_PKT_BURST, *burst_sz); return; } else if (pkt_burst > 0) { - nb_pkt_per_burst = (uint32_t)pkt_burst; + *burst_sz = (uint32_t)pkt_burst; return; } - /* If user gives a value of zero, query the PMD for its recommended Rx burst size. */ - ret = rte_eth_dev_info_get(0, &dev_info); - if (ret != 0) - return; - burst_size = dev_info.default_rxportconf.burst_size; - if (burst_size == 0) { - RTE_LOG(INFO, L3FWD, "PMD does not recommend a burst size. Using default value %d. " - "User provided value must be in [1, %d]\n", - nb_pkt_per_burst, MAX_PKT_BURST); - return; - } else if (burst_size > MAX_PKT_BURST) { - RTE_LOG(INFO, L3FWD, "PMD recommended burst size %d exceeds maximum value %d. " - "Using default value %d\n", - burst_size, MAX_PKT_BURST, nb_pkt_per_burst); - return; + if (is_rx_burst) { + /* If user gives a value of zero, query the PMD for its recommended + * Rx burst size. + */ + ret = rte_eth_dev_info_get(0, &dev_info); + if (ret != 0) + return; + burst_size = dev_info.default_rxportconf.burst_size; + if (burst_size == 0) { + RTE_LOG(INFO, L3FWD, "PMD does not recommend a burst size. Using default value %d. " + "User provided value must be in [1, %d]\n", + rx_burst_size, MAX_PKT_BURST); + return; + } else if (burst_size > MAX_PKT_BURST) { + RTE_LOG(INFO, L3FWD, "PMD recommended burst size %d exceeds maximum value %d. " + "Using default value %d\n", + burst_size, MAX_PKT_BURST, rx_burst_size); + return; + } + *burst_sz = burst_size; + RTE_LOG(INFO, L3FWD, "Using PMD-provided RX burst value %d\n", burst_size); + } else { + RTE_LOG(INFO, L3FWD, "User provided TX burst is 0. Using default value %d\n", + *burst_sz); } - nb_pkt_per_burst = burst_size; - RTE_LOG(INFO, L3FWD, "Using PMD-provided burst value %d\n", burst_size); } #define MAX_JUMBO_PKT_LEN 9600 @@ -768,7 +779,8 @@ static const char short_options[] = #define CMD_LINE_OPT_RULE_IPV4 "rule_ipv4" #define CMD_LINE_OPT_RULE_IPV6 "rule_ipv6" #define CMD_LINE_OPT_ALG "alg" -#define CMD_LINE_OPT_PKT_BURST "burst" +#define CMD_LINE_OPT_PKT_RX_BURST "rx-burst" +#define CMD_LINE_OPT_PKT_TX_BURST "tx-burst" #define CMD_LINE_OPT_MB_CACHE_SIZE "mbcache" enum { @@ -799,7 +811,8 @@ enum { CMD_LINE_OPT_ENABLE_VECTOR_NUM, CMD_LINE_OPT_VECTOR_SIZE_NUM, CMD_LINE_OPT_VECTOR_TMO_NS_NUM, - CMD_LINE_OPT_PKT_BURST_NUM, + CMD_LINE_OPT_PKT_RX_BURST_NUM, + CMD_LINE_OPT_PKT_TX_BURST_NUM, CMD_LINE_OPT_MB_CACHE_SIZE_NUM, }; @@ -827,7 +840,8 @@ static const struct option lgopts[] = { {CMD_LINE_OPT_RULE_IPV4, 1, 0, CMD_LINE_OPT_RULE_IPV4_NUM}, {CMD_LINE_OPT_RULE_IPV6, 1, 0, CMD_LINE_OPT_RULE_IPV6_NUM}, {CMD_LINE_OPT_ALG, 1, 0, CMD_LINE_OPT_ALG_NUM}, - {CMD_LINE_OPT_PKT_BURST, 1, 0, CMD_LINE_OPT_PKT_BURST_NUM}, + {CMD_LINE_OPT_PKT_RX_BURST, 1, 0, CMD_LINE_OPT_PKT_RX_BURST_NUM}, + {CMD_LINE_OPT_PKT_TX_BURST, 1, 0, CMD_LINE_OPT_PKT_TX_BURST_NUM}, {CMD_LINE_OPT_MB_CACHE_SIZE, 1, 0, CMD_LINE_OPT_MB_CACHE_SIZE_NUM}, {NULL, 0, 0, 0} }; @@ -917,8 +931,12 @@ parse_args(int argc, char **argv) parse_queue_size(optarg, &nb_txd, 0); break; - case CMD_LINE_OPT_PKT_BURST_NUM: - parse_pkt_burst(optarg); + case CMD_LINE_OPT_PKT_RX_BURST_NUM: + parse_pkt_burst(optarg, true, &rx_burst_size); + break; + + case CMD_LINE_OPT_PKT_TX_BURST_NUM: + parse_pkt_burst(optarg, false, &tx_burst_size); break; case CMD_LINE_OPT_MB_CACHE_SIZE_NUM: @@ -1654,6 +1672,9 @@ main(int argc, char **argv) if (ret < 0) rte_exit(EXIT_FAILURE, "Invalid L3FWD parameters\n"); + RTE_LOG(INFO, L3FWD, "Using RX burst %u TX burst %u\n", + rx_burst_size, tx_burst_size); + /* Setup function pointers for lookup method. */ setup_l3fwd_lookup_tables(); -- 2.43.0 ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2025-11-06 14:16 UTC | newest] Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2025-02-12 4:54 [PATCH] examples/l3fwd: adjust Tx burst size based on Rx burst Sivaprasad Tummala 2025-02-12 9:17 ` Ande, Venkat Kumar 2025-02-12 9:46 ` Ande, Venkat Kumar 2025-02-19 16:59 ` Konstantin Ananyev 2025-06-09 9:58 ` [PATCH v2] " Sivaprasad Tummala 2025-06-09 15:21 ` Stephen Hemminger 2025-06-10 14:29 ` [EXTERNAL] " Pavan Nikhilesh Bhagavatula 2025-10-09 2:32 ` Tummala, Sivaprasad 2025-10-31 9:18 ` fengchengwen 2025-11-01 12:53 ` Tummala, Sivaprasad 2025-11-06 14:16 ` [PATCH v3] examples/l3fwd: add Tx burst size configuration option Sivaprasad Tummala
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).