[v1] examples/l3fwd: fix jumbo packet drop issue

Message ID 20210727092523.22718-1-rohit.raj@nxp.com (mailing list archive)
State Changes Requested, archived
Delegated to: Ferruh Yigit
Headers
Series [v1] examples/l3fwd: fix jumbo packet drop issue |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/github-robot success github build: passed
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS

Commit Message

Rohit Raj July 27, 2021, 9:25 a.m. UTC
From: Rohit Raj <rohit.raj@nxp.com>

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")

Signed-off-by: Rohit Raj <rohit.raj@nxp.com>
Signed-off-by: Sachin Saxena <sachin.saxena@nxp.com>
Signed-off-by: Vanshika Shukla <vanshika.shukla@nxp.com>
---
 examples/l3fwd/main.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
  

Comments

Singh, Aman Deep Aug. 11, 2021, 10:19 a.m. UTC | #1
Hi Rohit,

On 7/27/2021 2:55 PM, rohit.raj@nxp.com wrote:
> From: Rohit Raj <rohit.raj@nxp.com>
>
> 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")
>
> Signed-off-by: Rohit Raj <rohit.raj@nxp.com>
> Signed-off-by: Sachin Saxena <sachin.saxena@nxp.com>
> Signed-off-by: Vanshika Shukla <vanshika.shukla@nxp.com>
> ---
>   examples/l3fwd/main.c | 14 ++++++++++++++
>   1 file changed, 14 insertions(+)
>
> diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c
> index 4cb800aa15..6aaaa8ecb5 100644
> --- a/examples/l3fwd/main.c
> +++ b/examples/l3fwd/main.c
> @@ -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;

Acked-by: Aman Deep Singh <aman.deep.singh@intel.com>
  
Ferruh Yigit Aug. 11, 2021, 11:30 a.m. UTC | #2
On 7/27/2021 10:25 AM, rohit.raj@nxp.com wrote:
> From: Rohit Raj <rohit.raj@nxp.com>
> 
> 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")
> 
> Signed-off-by: Rohit Raj <rohit.raj@nxp.com>
> Signed-off-by: Sachin Saxena <sachin.saxena@nxp.com>
> Signed-off-by: Vanshika Shukla <vanshika.shukla@nxp.com>
> ---
>  examples/l3fwd/main.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c
> index 4cb800aa15..6aaaa8ecb5 100644
> --- a/examples/l3fwd/main.c
> +++ b/examples/l3fwd/main.c
> @@ -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");

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


> +		}
> +
>  		if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
>  			local_port_conf.txmode.offloads |=
>  				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
>
  

Patch

diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c
index 4cb800aa15..6aaaa8ecb5 100644
--- a/examples/l3fwd/main.c
+++ b/examples/l3fwd/main.c
@@ -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;