examples: ipv4, udp and tcp checksum offload warning

Message ID 20210913120951.103968-1-usama.nadeem@emumba.com (mailing list archive)
State Superseded, archived
Headers
Series examples: ipv4, udp and tcp checksum offload warning |

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
ci/iol-intel-Performance success Performance Testing PASS

Commit Message

Usama Nadeem Sept. 13, 2021, 12:09 p.m. UTC
  Closes gracefully if IPV4 checksum offload is not available.
Gives warning if UDP or TCP checksum offloads are not available.

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

Comments

Stephen Hemminger Sept. 13, 2021, 3:11 p.m. UTC | #1
On Mon, 13 Sep 2021 17:09:51 +0500
usamanadeem321 <usama.nadeem@emumba.com> wrote:

>  
> +		if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_IPV4_CKSUM)
> +			local_port_conf.rxmode.offloads |=
> +			 DEV_RX_OFFLOAD_IPV4_CKSUM;
> +		else {
> +			rte_exit(EXIT_FAILURE,
> +				"IPV4 Checksum offload not available. (port %u) ",
> +				portid);
> +		}
> +

Why not just do it in software if not available. The IPv4 checksum
is so cheap many operating systems just always do it in software.
  

Patch

diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c
index 00ac267af1..81e605700e 100644
--- a/examples/l3fwd/main.c
+++ b/examples/l3fwd/main.c
@@ -123,7 +123,7 @@  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 +1039,30 @@  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 {
+			rte_exit(EXIT_FAILURE,
+				"IPV4 Checksum offload not available. (port %u) ",
+				portid);
+		}
+
+		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;