Skip to contentSkip to conversation

examples/l3fwd: fix jumbo packet drop issue

PATCH Superseded [email protected] 4 participants 6 messages Jul 27, 2021 – Nov 16, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 examples/l3fwd: fix jumbo packet drop issue

From: Rohit Raj <[email protected]>

l3fwd uses mbufs with 2KB data size. If we enable jumbo packets, it is not able to store packets with size greater than 2KB, hence these packets are dropped.

This patch fixes this issue by enabling scatter for jumbo packet, if it is supported by NIC.

If scatter is not supported by NIC and max jumbo packet length is greater than default mbuf data size, then application exits with proper error message.

Fixes f68aad7904f ("examples/l3fwd: update")
---
 examples/l3fwd/main.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
examples/l3fwd/main.c +14 -0
index 4cb800aa15..6aaaa8ecb5 100644
@@ -1035,6 +1035,20 @@ l3fwd_poll_resource_setup(void)
 				"Error during getting device (port %u) info: %s\n",
 				portid, strerror(-ret));
 
+		/* Enable Receive side SCATTER, if supported by NIC,
+		 * when jumbo packet is enabled.
+		 */
+		if (local_port_conf.rxmode.offloads &
+				DEV_RX_OFFLOAD_JUMBO_FRAME){
+			if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_SCATTER)
+				local_port_conf.rxmode.offloads |=
+						DEV_RX_OFFLOAD_SCATTER;
+			else if (local_port_conf.rxmode.max_rx_pkt_len >
+					RTE_MBUF_DEFAULT_DATAROOM)
+				rte_exit(EXIT_FAILURE,
+					"Max packet length greater than default MBUF size\n");
+		}
+
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#1 lore raw

Hi Rohit,

Quoted 37 lines · On 7/27/2021 2:55 PM, [email protected] wrote:

From: Rohit Raj <[email protected]>

l3fwd uses mbufs with 2KB data size. If we enable jumbo packets, it is not able to store packets with size greater than 2KB, hence these packets are dropped.

This patch fixes this issue by enabling scatter for jumbo packet, if it is supported by NIC.

If scatter is not supported by NIC and max jumbo packet length is greater than default mbuf data size, then application exits with proper error message.

Fixes f68aad7904f ("examples/l3fwd: update")
---
  examples/l3fwd/main.c | 14 ++++++++++++++
  1 file changed, 14 insertions(+)
examples/l3fwd/main.c +7 -0
index 4cb800aa15..6aaaa8ecb5 100644
@@ -1035,6 +1035,20 @@ l3fwd_poll_resource_setup(void)
  				"Error during getting device (port %u) info: %s\n",
  				portid, strerror(-ret));
 
+		/* Enable Receive side SCATTER, if supported by NIC,
+		 * when jumbo packet is enabled.
+		 */
+		if (local_port_conf.rxmode.offloads &
+				DEV_RX_OFFLOAD_JUMBO_FRAME){
+			if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_SCATTER)
+				local_port_conf.rxmode.offloads |=

examples/l3fwd/main.c l3fwd_poll_resource_setup(void) · line 1054

Quoted 10 lines
examples/l3fwd/main.c +7 -0
+						DEV_RX_OFFLOAD_SCATTER;
+			else if (local_port_conf.rxmode.max_rx_pkt_len >
+					RTE_MBUF_DEFAULT_DATAROOM)
+				rte_exit(EXIT_FAILURE,
+					"Max packet length greater than default MBUF size\n");
+		}
+
  		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
  			local_port_conf.txmode.offloads |=
  				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
#2 lore raw
In reply to [email protected]
Quoted 32 lines · On 7/27/2021 10:25 AM, [email protected] wrote:

From: Rohit Raj <[email protected]>

l3fwd uses mbufs with 2KB data size. If we enable jumbo packets, it is not able to store packets with size greater than 2KB, hence these packets are dropped.

This patch fixes this issue by enabling scatter for jumbo packet, if it is supported by NIC.

If scatter is not supported by NIC and max jumbo packet length is greater than default mbuf data size, then application exits with proper error message.

Fixes f68aad7904f ("examples/l3fwd: update")
---
 examples/l3fwd/main.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
examples/l3fwd/main.c +2 -0
index 4cb800aa15..6aaaa8ecb5 100644
@@ -1035,6 +1035,20 @@ l3fwd_poll_resource_setup(void)
 				"Error during getting device (port %u) info: %s\n",
 				portid, strerror(-ret));
 
+		/* Enable Receive side SCATTER, if supported by NIC,
+		 * when jumbo packet is enabled.

examples/l3fwd/main.c l3fwd_poll_resource_setup(void) · line 1049

Quoted 10 lines
examples/l3fwd/main.c +10 -0
+		 */
+		if (local_port_conf.rxmode.offloads &
+				DEV_RX_OFFLOAD_JUMBO_FRAME){
+			if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_SCATTER)
+				local_port_conf.rxmode.offloads |=
+						DEV_RX_OFFLOAD_SCATTER;
+			else if (local_port_conf.rxmode.max_rx_pkt_len >
+					RTE_MBUF_DEFAULT_DATAROOM)
+				rte_exit(EXIT_FAILURE,
+					"Max packet length greater than default MBUF size\n");

This is a configuration set by application. So application is failing itself because of configuration it sets, seems odd.

I guess the jumbo frame can be enabled when user provides '--enable-jumbo' argument. What do you think adding above check where that argument is parsed.

Btw, no need to enable scattered Rx if the packets fits into buffer, so above check can be done slightly different:

if (max_rx_pkt_len > buffer_size)
if (OFFLOAD_SCATTER supported)
enable OFFLOAD_SCATTER
else
fail

Quoted 6 lines
examples/l3fwd/main.c +2 -0
+		}
+
 		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
#3 lore raw

PATCH v2 1/1 examples/l3fwd: fix jumbo packet drop issue

In reply to [email protected]

From: Rohit Raj <[email protected]>

l3fwd uses mbufs with 2KB data size. If we enable jumbo packets, it is not able to store packets with size greater than 2KB, hence these packets are dropped.

This patch fixes this issue by enabling scatter for jumbo packet, if it is supported by NIC.

If scatter is not supported by NIC and max packet length is greater than default mbuf data size, then application exits with proper error message.

Fixes f68aad7904f ("examples/l3fwd: update")

---

v2:
* Improved the check to not enable Rx scatter when packets fits into buffer.
* Check if jumbo packet is enabled using max_rx_pktlen instead of jumbo packet flag.

 examples/l3fwd/main.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
examples/l3fwd/main.c +13 -0
index d69373f881..61448c759c 100644
@@ -1109,6 +1109,19 @@ l3fwd_poll_resource_setup(void)
 				"Invalid max packet length: %u (port %u)\n",
 				max_pkt_len, portid);
 
+		/* Enable Receive side SCATTER, if supported by NIC,
+		 * when jumbo packet is enabled.
+		 */
+		if (dev_info.max_rx_pktlen > RTE_MBUF_DEFAULT_DATAROOM) {
+			if (dev_info.rx_offload_capa &
+			    RTE_ETH_RX_OFFLOAD_SCATTER)
+				local_port_conf.rxmode.offloads |=
+						RTE_ETH_RX_OFFLOAD_SCATTER;
+			else
+				rte_exit(EXIT_FAILURE,
+					 "Max packet length greater than default MBUF size\n");
+		}
+
 		if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
Signature · 1 line
2.17.1
#4 lore raw
Quoted 36 lines

From: Rohit Raj <[email protected]>

l3fwd uses mbufs with 2KB data size. If we enable jumbo packets, it is not able to store packets with size greater than 2KB, hence these packets are dropped.

This patch fixes this issue by enabling scatter for jumbo packet, if it is supported by NIC.

If scatter is not supported by NIC and max packet length is greater than default mbuf data size, then application exits with proper error message.

Fixes f68aad7904f ("examples/l3fwd: update")

---

v2:
* Improved the check to not enable Rx scatter when packets fits into buffer.
* Check if jumbo packet is enabled using max_rx_pktlen instead of jumbo packet flag.

 examples/l3fwd/main.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
examples/l3fwd/main.c +0 -0
index d69373f881..61448c759c 100644

examples/l3fwd/main.c l3fwd_poll_resource_setup(void) · line 1114

Quoted 6 lines
examples/l3fwd/main.c +3 -0
@@ -1109,6 +1109,19 @@ l3fwd_poll_resource_setup(void)
 				"Invalid max packet length: %u (port %u)\n",
 				max_pkt_len, portid);
 
+		/* Enable Receive side SCATTER, if supported by NIC,
+		 * when jumbo packet is enabled.
+		 */

From the code below, it looks like you always enable scatter if HW supports it. Without paying attention to max_pkt_len provided by user.

Quoted 15 lines
examples/l3fwd/main.c +10 -1
+		if (dev_info.max_rx_pktlen > RTE_MBUF_DEFAULT_DATAROOM) {
+			if (dev_info.rx_offload_capa &
+			    RTE_ETH_RX_OFFLOAD_SCATTER)
+				local_port_conf.rxmode.offloads |=
+						RTE_ETH_RX_OFFLOAD_SCATTER;
+			else
+				rte_exit(EXIT_FAILURE,
+					 "Max packet length greater than default MBUF size\n");
+		}
+
 		if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE)
 			local_port_conf.txmode.offloads |=
 				RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
--

2.17.1

author
#5 lore raw
Quoted 48 lines

-----Original Message-----
From: Ananyev, Konstantin <[email protected]>
Sent: Friday, November 12, 2021 3:11 PM
To: Rohit Raj <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>
Cc: Nipun Gupta <[email protected]>; Sachin Saxena <[email protected]>; Vanshika Shukla <[email protected]>
Subject: [EXT] RE: [PATCH v2] examples/l3fwd: fix jumbo packet drop issue

Caution: EXT Email

Quoted 37 lines

From: Rohit Raj <[email protected]>

l3fwd uses mbufs with 2KB data size. If we enable jumbo packets, it is not able to store packets with size greater than 2KB, hence these packets are dropped.

This patch fixes this issue by enabling scatter for jumbo packet, if it is supported by NIC.

If scatter is not supported by NIC and max packet length is greater than default mbuf data size, then application exits with proper error message.

Fixes f68aad7904f ("examples/l3fwd: update")

---

v2:
* Improved the check to not enable Rx scatter when packets fits into buffer.
* Check if jumbo packet is enabled using max_rx_pktlen instead of jumbo packet flag.

 examples/l3fwd/main.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
examples/l3fwd/main.c index renamed from examples/l3fwd/main.c +0 -0

d69373f881..61448c759c 100644

examples/l3fwd/main.c +0 -0
@@ -1109,6 +1109,19 @@ l3fwd_poll_resource_setup(void)
                              "Invalid max packet length: %u (port %u)\n",
                              max_pkt_len, portid);
 
Quoted 7 lines

examples/l3fwd/main.c l3fwd_poll_resource_setup(void) · line 1114

Quoted 3 lines
examples/l3fwd/main.c +3 -0
+             /* Enable Receive side SCATTER, if supported by NIC,
+              * when jumbo packet is enabled.
+              */

From the code below, it looks like you always enable scatter if HW supports it. Without paying attention to max_pkt_len provided by user.

You are right. I will fix this check in next updated version of patch.

Quoted 17 lines

examples/l3fwd/main.c l3fwd_poll_resource_setup(void)

Quoted 12 lines
examples/l3fwd/main.c +10 -0
+             if (dev_info.max_rx_pktlen > RTE_MBUF_DEFAULT_DATAROOM) {
+                     if (dev_info.rx_offload_capa &
+                         RTE_ETH_RX_OFFLOAD_SCATTER)
+                             local_port_conf.rxmode.offloads |=
+                                             RTE_ETH_RX_OFFLOAD_SCATTER;
+                     else
+                             rte_exit(EXIT_FAILURE,
+                                      "Max packet length greater than default MBUF size\n");
+             }
+
              if (dev_info.tx_offload_capa &

RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE)

Quoted 4 lines
examples/l3fwd/main.c +0 -1
                      local_port_conf.txmode.offloads |=
                              RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
--

2.17.1