examples/l3fwd: adjust Tx burst size based on Rx burst

Message ID 20250212045416.2393001-1-sivaprasad.tummala@amd.com (mailing list archive)
State New
Delegated to: Thomas Monjalon
Headers
Series examples/l3fwd: adjust Tx burst size based on Rx burst |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing fail Unit Testing FAIL
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-marvell-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS

Commit Message

Sivaprasad Tummala Feb. 12, 2025, 4:54 a.m. UTC
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(-)
  

Comments

Ande, Venkat Kumar Feb. 12, 2025, 9:17 a.m. UTC | #1
[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>
  
Ande, Venkat Kumar Feb. 12, 2025, 9:46 a.m. UTC | #2
[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
  
Konstantin Ananyev Feb. 19, 2025, 4:59 p.m. UTC | #3
> 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
  

Patch

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);
 }