[v2] Warns if IPv4, UDP or TCP checksum offload not available

Message ID 20210914180827.184123-1-usama.nadeem@emumba.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series [v2] Warns if IPv4, UDP or TCP checksum offload not available |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/github-robot: build success github build: passed
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing fail Testing issues
ci/iol-aarch64-compile-testing success Testing PASS

Commit Message

Usama Nadeem Sept. 14, 2021, 6:08 p.m. UTC
  From: usamanadeem321 <usama.nadeem@emumba.com>

Checks if IPV4, UDP and TCP Checksum offloads are available.
If not available, prints a warning message.

Bugzilla ID: 545
Signed-off-by: usamanadeem321 <usama.nadeem@emumba.com>
---
 examples/l3fwd/main.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
  

Comments

Stephen Hemminger Sept. 14, 2021, 6:28 p.m. UTC | #1
On Tue, 14 Sep 2021 23:08:27 +0500
Usama Nadeem <usama.nadeem@emumba.com> wrote:

> +
> +		if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_UDP_CKSUM)
> +			local_port_conf.rxmode.offloads |=
> +			DEV_RX_OFFLOAD_UDP_CKSUM;
> +
> +		else
> +			printf("WARNING: UDP Checksum offload not available.\n");
> +
> +		if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_TCP_CKSUM)
> +			local_port_conf.rxmode.offloads |=
> +			DEV_RX_OFFLOAD_TCP_CKSUM;
> +
> +		else
> +			printf("WARNING: TCP Checksum offload not available.\n");

Why does l3fwd care about L4 checksum offload?
The application should really be just a simple L3 router. But it
seems to have become a test for ptype and depends on TCP/UDP.
  
Ananyev, Konstantin Sept. 14, 2021, 10:22 p.m. UTC | #2
> 
> From: usamanadeem321 <usama.nadeem@emumba.com>
> 
> Checks if IPV4, UDP and TCP Checksum offloads are available.
> If not available, prints a warning message.
> 
> Bugzilla ID: 545
> Signed-off-by: usamanadeem321 <usama.nadeem@emumba.com>
> ---
>  examples/l3fwd/main.c | 22 +++++++++++++++++++++-
>  1 file changed, 21 insertions(+), 1 deletion(-)
> 
> diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c
> index 00ac267af1..ae62bc570d 100644
> --- a/examples/l3fwd/main.c
> +++ b/examples/l3fwd/main.c
> @@ -123,7 +123,6 @@ static struct rte_eth_conf port_conf = {
>  		.mq_mode = ETH_MQ_RX_RSS,
>  		.max_rx_pkt_len = RTE_ETHER_MAX_LEN,
>  		.split_hdr_size = 0,
> -		.offloads = DEV_RX_OFFLOAD_CHECKSUM,
>  	},
>  	.rx_adv_conf = {
>  		.rss_conf = {
> @@ -1039,6 +1038,27 @@ l3fwd_poll_resource_setup(void)
>  			local_port_conf.txmode.offloads |=
>  				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
> 
> +		if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_IPV4_CKSUM)
> +			local_port_conf.rxmode.offloads |=
> +			 DEV_RX_OFFLOAD_IPV4_CKSUM;
> +		else {
> +			printf("WARNING: IPV4 Checksum offload not available.\n");
> +		}
> +
> +		if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_UDP_CKSUM)
> +			local_port_conf.rxmode.offloads |=
> +			DEV_RX_OFFLOAD_UDP_CKSUM;
> +
> +		else
> +			printf("WARNING: UDP Checksum offload not available.\n");
> +
> +		if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_TCP_CKSUM)
> +			local_port_conf.rxmode.offloads |=
> +			DEV_RX_OFFLOAD_TCP_CKSUM;
> +
> +		else
> +			printf("WARNING: TCP Checksum offload not available.\n");
> +

Sorry, but I didn't get the logic:
Application expects some offloads to be supported by HW.
You add the code that checks for offloads, but if they are not supported just prints warning
and continues, as if everything is ok. Doesn't look like correct behaviour to me.
I think, it should either terminate with error message or be prepared to work properly
on HW without these offloads (check cksums in SW if necessary).
In fact I don't see what was wrong with original behaviour, one thing that probably
was missing - more descriptive error message. 

>  		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
>  			dev_info.flow_type_rss_offloads;
> 
> --
> 2.25.1
  
Stephen Hemminger Sept. 14, 2021, 11:44 p.m. UTC | #3
On Tue, 14 Sep 2021 22:22:04 +0000
"Ananyev, Konstantin" <konstantin.ananyev@intel.com> wrote:

> > 
> > From: usamanadeem321 <usama.nadeem@emumba.com>
> > 
> > Checks if IPV4, UDP and TCP Checksum offloads are available.
> > If not available, prints a warning message.
> > 
> > Bugzilla ID: 545
> > Signed-off-by: usamanadeem321 <usama.nadeem@emumba.com>
> > ---
> >  examples/l3fwd/main.c | 22 +++++++++++++++++++++-
> >  1 file changed, 21 insertions(+), 1 deletion(-)
> > 
> > diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c
> > index 00ac267af1..ae62bc570d 100644
> > --- a/examples/l3fwd/main.c
> > +++ b/examples/l3fwd/main.c
> > @@ -123,7 +123,6 @@ static struct rte_eth_conf port_conf = {
> >  		.mq_mode = ETH_MQ_RX_RSS,
> >  		.max_rx_pkt_len = RTE_ETHER_MAX_LEN,
> >  		.split_hdr_size = 0,
> > -		.offloads = DEV_RX_OFFLOAD_CHECKSUM,
> >  	},
> >  	.rx_adv_conf = {
> >  		.rss_conf = {
> > @@ -1039,6 +1038,27 @@ l3fwd_poll_resource_setup(void)
> >  			local_port_conf.txmode.offloads |=
> >  				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
> > 
> > +		if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_IPV4_CKSUM)
> > +			local_port_conf.rxmode.offloads |=
> > +			 DEV_RX_OFFLOAD_IPV4_CKSUM;
> > +		else {
> > +			printf("WARNING: IPV4 Checksum offload not available.\n");
> > +		}
> > +
> > +		if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_UDP_CKSUM)
> > +			local_port_conf.rxmode.offloads |=
> > +			DEV_RX_OFFLOAD_UDP_CKSUM;
> > +
> > +		else
> > +			printf("WARNING: UDP Checksum offload not available.\n");
> > +
> > +		if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_TCP_CKSUM)
> > +			local_port_conf.rxmode.offloads |=
> > +			DEV_RX_OFFLOAD_TCP_CKSUM;
> > +
> > +		else
> > +			printf("WARNING: TCP Checksum offload not available.\n");
> > +  
> 
> Sorry, but I didn't get the logic:
> Application expects some offloads to be supported by HW.

The application is expecting more offloads than is necessary for basic
IP level forwarding which is all the example is documented to do.

  "The application performs L3 forwarding."

> You add the code that checks for offloads, but if they are not supported just prints warning
> and continues, as if everything is ok. Doesn't look like correct behaviour to me.
> I think, it should either terminate with error message or be prepared to work properly
> on HW without these offloads (check cksums in SW if necessary).
> In fact I don't see what was wrong with original behaviour, one thing that probably
> was missing - more descriptive error message. 

It is not a problem with your patch, it is fine.

It is a problem in how l3fwd has grown and changed and no longer really what
was intended in the original version. There is no reason that the application
should be looking at L4 data. In fact, it shouldn't care if it gets TCP, UDP, SCP or DCCP;
but the application now depends on ptype.

It should be possible to do L3 forwarding independent of packet type.
The application only needs to look at Ether type and do IPv4 or IPv6 based on that.
  
Ananyev, Konstantin Sept. 15, 2021, 8:43 a.m. UTC | #4
> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Wednesday, September 15, 2021 12:44 AM
> To: Ananyev, Konstantin <konstantin.ananyev@intel.com>
> Cc: Usama Nadeem <usama.nadeem@emumba.com>; thomas@monjalon.net; dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v2] Warns if IPv4, UDP or TCP checksum offload not available
> 
> On Tue, 14 Sep 2021 22:22:04 +0000
> "Ananyev, Konstantin" <konstantin.ananyev@intel.com> wrote:
> 
> > >
> > > From: usamanadeem321 <usama.nadeem@emumba.com>
> > >
> > > Checks if IPV4, UDP and TCP Checksum offloads are available.
> > > If not available, prints a warning message.
> > >
> > > Bugzilla ID: 545
> > > Signed-off-by: usamanadeem321 <usama.nadeem@emumba.com>
> > > ---
> > >  examples/l3fwd/main.c | 22 +++++++++++++++++++++-
> > >  1 file changed, 21 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c
> > > index 00ac267af1..ae62bc570d 100644
> > > --- a/examples/l3fwd/main.c
> > > +++ b/examples/l3fwd/main.c
> > > @@ -123,7 +123,6 @@ static struct rte_eth_conf port_conf = {
> > >  		.mq_mode = ETH_MQ_RX_RSS,
> > >  		.max_rx_pkt_len = RTE_ETHER_MAX_LEN,
> > >  		.split_hdr_size = 0,
> > > -		.offloads = DEV_RX_OFFLOAD_CHECKSUM,
> > >  	},
> > >  	.rx_adv_conf = {
> > >  		.rss_conf = {
> > > @@ -1039,6 +1038,27 @@ l3fwd_poll_resource_setup(void)
> > >  			local_port_conf.txmode.offloads |=
> > >  				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
> > >
> > > +		if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_IPV4_CKSUM)
> > > +			local_port_conf.rxmode.offloads |=
> > > +			 DEV_RX_OFFLOAD_IPV4_CKSUM;
> > > +		else {
> > > +			printf("WARNING: IPV4 Checksum offload not available.\n");
> > > +		}
> > > +
> > > +		if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_UDP_CKSUM)
> > > +			local_port_conf.rxmode.offloads |=
> > > +			DEV_RX_OFFLOAD_UDP_CKSUM;
> > > +
> > > +		else
> > > +			printf("WARNING: UDP Checksum offload not available.\n");
> > > +
> > > +		if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_TCP_CKSUM)
> > > +			local_port_conf.rxmode.offloads |=
> > > +			DEV_RX_OFFLOAD_TCP_CKSUM;
> > > +
> > > +		else
> > > +			printf("WARNING: TCP Checksum offload not available.\n");
> > > +
> >
> > Sorry, but I didn't get the logic:
> > Application expects some offloads to be supported by HW.
> 
> The application is expecting more offloads than is necessary for basic
> IP level forwarding which is all the example is documented to do.
> 
>   "The application performs L3 forwarding."
> 
> > You add the code that checks for offloads, but if they are not supported just prints warning
> > and continues, as if everything is ok. Doesn't look like correct behaviour to me.
> > I think, it should either terminate with error message or be prepared to work properly
> > on HW without these offloads (check cksums in SW if necessary).
> > In fact I don't see what was wrong with original behaviour, one thing that probably
> > was missing - more descriptive error message.
> 
> It is not a problem with your patch, it is fine.
> 
> It is a problem in how l3fwd has grown and changed and no longer really what
> was intended in the original version. There is no reason that the application
> should be looking at L4 data. In fact, it shouldn't care if it gets TCP, UDP, SCP or DCCP;
> but the application now depends on ptype.
> 
> It should be possible to do L3 forwarding independent of packet type.
> The application only needs to look at Ether type and do IPv4 or IPv6 based on that.
> 

As I remember l3fwd cares about L4 headers (chan cksums) because it can do FWD decisions
based on 5-tuple (exact-macth mode).
I presume that's the reason L4 cksum offloads was enabled at first place.
For LPM/FIB I believe ipv4 cksum check should be sufficient.
If we believe that some offloads are excessive,
then I think right way is to simply remove them
(with updating docs and source in a proper way etc.).
Just printing warnings and continuing seems wrong to me.
  

Patch

diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c
index 00ac267af1..ae62bc570d 100644
--- a/examples/l3fwd/main.c
+++ b/examples/l3fwd/main.c
@@ -123,7 +123,6 @@  static struct rte_eth_conf port_conf = {
 		.mq_mode = ETH_MQ_RX_RSS,
 		.max_rx_pkt_len = RTE_ETHER_MAX_LEN,
 		.split_hdr_size = 0,
-		.offloads = DEV_RX_OFFLOAD_CHECKSUM,
 	},
 	.rx_adv_conf = {
 		.rss_conf = {
@@ -1039,6 +1038,27 @@  l3fwd_poll_resource_setup(void)
 			local_port_conf.txmode.offloads |=
 				DEV_TX_OFFLOAD_MBUF_FAST_FREE;
 
+		if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_IPV4_CKSUM)
+			local_port_conf.rxmode.offloads |=
+			 DEV_RX_OFFLOAD_IPV4_CKSUM;
+		else {
+			printf("WARNING: IPV4 Checksum offload not available.\n");
+		}
+
+		if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_UDP_CKSUM)
+			local_port_conf.rxmode.offloads |=
+			DEV_RX_OFFLOAD_UDP_CKSUM;
+
+		else
+			printf("WARNING: UDP Checksum offload not available.\n");
+
+		if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_TCP_CKSUM)
+			local_port_conf.rxmode.offloads |=
+			DEV_RX_OFFLOAD_TCP_CKSUM;
+
+		else
+			printf("WARNING: TCP Checksum offload not available.\n");
+
 		local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
 			dev_info.flow_type_rss_offloads;