Skip to contentSkip to conversation

Removing PKT_TX_IP_CKSUM from fragmentation/reassembly lib

PATCH Superseded Sunil Kumar Kori 4 participants 23 messages May 16, 2019 – Jul 8, 2019

lore
Share & tools
lore
#0 lore raw

cover Removing PKT_TX_IP_CKSUM from fragmentation/reassembly lib

Patchset contains below changes:
------------------------------------------------------------
1. Currently PKT_TX_IP_CKSUM is being set into mbuf->ol_flags during fragmentation and reassemble operation implicitly. Because of this, application is forced to use checksum offload whether it is supported by platform or not.

Also documentation does not provide any expected value of ol_flags in returned mbuf (reassembled or fragmented) so application will never come to know that which offloads are enabled. So transmission may gets failed for the platforms which does not support checksum offload.

Also, IPv6 does not contain any checksum field in header so setting mbuf->ol_flags with PKT_TX_IP_CKSUM is itself invalid.

So removing mentioned flag from the library.

2. Enabling PKT_TX_IP_CKSUM into mbuf->ol_flags at fragmentation and reassembly application itself.

Sunil Kumar Kori (3):
lib/librte_ip_frag: Remove PKT_TX_IP_CKSUM offload flags examples/ip_fragmentation: Enabling IP checksum offload in mbuf examples/ip_reassembly: Enabling IP checksum offload in mbuf

 examples/ip_fragmentation/main.c            | 7 +++++--
 examples/ip_reassembly/main.c               | 6 ++++++
 lib/librte_ip_frag/rte_ipv4_fragmentation.c | 1 -
 lib/librte_ip_frag/rte_ipv4_reassembly.c    | 3 ---
 lib/librte_ip_frag/rte_ipv6_reassembly.c    | 3 ---
 5 files changed, 11 insertions(+), 9 deletions(-)
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/3 lib/librte_ip_frag: Remove PKT_TX_IP_CKSUM offload flags

Currently PKT_TX_IP_CKSUM is being set into mbuf->ol_flags during fragmentation and reassemble operation implicitly. Because of this, application is forced to use checksum offload whether it is supported by platform or not.

Also documentation does not provide any expected value of ol_flags in returned mbuf (reassembled or fragmented) so application will never come to know that which offloads are enabled. So transmission may be failed for the platforms which does not support checksum offload.

Also, IPv6 does not contain any checksum field in header so setting mbuf->ol_flags with PKT_TX_IP_CKSUM is itself invalid.

So removing mentioned flag from the library.

---
 lib/librte_ip_frag/rte_ipv4_fragmentation.c | 1 -
 lib/librte_ip_frag/rte_ipv4_reassembly.c    | 3 ---
 lib/librte_ip_frag/rte_ipv6_reassembly.c    | 3 ---
 3 files changed, 7 deletions(-)
lib/librte_ip_frag/rte_ipv4_fragmentation.c +0 -1
index a96fb03..13e60fb 100644
@@ -173,7 +173,6 @@ static inline void __free_fragments(struct rte_mbuf *mb[], uint32_t num)
 		fragment_offset = (uint16_t)(fragment_offset +
 		    out_pkt->pkt_len - sizeof(struct ipv4_hdr));
 
-		out_pkt->ol_flags |= PKT_TX_IP_CKSUM;
 		out_pkt->l3_len = sizeof(struct ipv4_hdr);
 
 		/* Write the fragment to the output list */
lib/librte_ip_frag/rte_ipv4_reassembly.c +0 -3
index 1029b7a..4e20431 100644
@@ -66,9 +66,6 @@ struct rte_mbuf *
 	m = fp->frags[IP_FIRST_FRAG_IDX].mb;
 	fp->frags[IP_FIRST_FRAG_IDX].mb = NULL;
 
-	/* update mbuf fields for reassembled packet. */
-	m->ol_flags |= PKT_TX_IP_CKSUM;
-
 	/* update ipv4 header for the reassembled packet */
 	ip_hdr = rte_pktmbuf_mtod_offset(m, struct ipv4_hdr *, m->l2_len);
 
lib/librte_ip_frag/rte_ipv6_reassembly.c +0 -3
index 855e3f7..eb8b849 100644
@@ -89,9 +89,6 @@ struct rte_mbuf *
 	m = fp->frags[IP_FIRST_FRAG_IDX].mb;
 	fp->frags[IP_FIRST_FRAG_IDX].mb = NULL;
 
-	/* update mbuf fields for reassembled packet. */
-	m->ol_flags |= PKT_TX_IP_CKSUM;
-
 	/* update ipv6 header for the reassembled datagram */
 	ip_hdr = rte_pktmbuf_mtod_offset(m, struct ipv6_hdr *, m->l2_len);
 
Signature · 1 line
1.8.3.1
#2 lore raw

PATCH 2/3 examples/ip_fragmentation: Enabling IP checksum offload in mbuf

In reply to Sunil Kumar Kori
---
 examples/ip_fragmentation/main.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
examples/ip_fragmentation/main.c +5 -2
index e90a61e..d821967 100644
@@ -354,10 +354,13 @@ struct rte_lpm6_config lpm6_config = {
 
 		/* src addr */
 		ether_addr_copy(&ports_eth_addr[port_out], &eth_hdr->s_addr);
-		if (ipv6)
+		if (ipv6) {
 			eth_hdr->ether_type = rte_be_to_cpu_16(ETHER_TYPE_IPv6);
-		else
+			m->ol_flags |= PKT_TX_IPV6;
+		} else {
 			eth_hdr->ether_type = rte_be_to_cpu_16(ETHER_TYPE_IPv4);
+			m->ol_flags |= (PKT_TX_IPV4 | PKT_TX_IP_CKSUM);
+		}
 	}
 
 	len += len2;
Signature · 1 line
1.8.3.1
#3 lore raw

PATCH 3/3 examples/ip_reassembly: Enabling IP checksum offload in mbuf

In reply to Sunil Kumar Kori
---
 examples/ip_reassembly/main.c | 6 ++++++
 1 file changed, 6 insertions(+)
examples/ip_reassembly/main.c +6 -0
index 17b55d4..686e364 100644
@@ -353,6 +353,9 @@ struct rte_lpm6_config lpm6_config = {
 					struct ether_hdr *);
 				ip_hdr = (struct ipv4_hdr *)(eth_hdr + 1);
 			}
+
+			/* update offloading flags */
+			m->ol_flags |= (PKT_TX_IPV4 | PKT_TX_IP_CKSUM);
 		}
 		ip_dst = rte_be_to_cpu_32(ip_hdr->dst_addr);
 
@@ -391,6 +394,9 @@ struct rte_lpm6_config lpm6_config = {
 				eth_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *);
 				ip_hdr = (struct ipv6_hdr *)(eth_hdr + 1);
 			}
+
+			/* update offloading flags */
+			m->ol_flags |= PKT_TX_IPV6;
 		}
 
 		/* Find destination port */
Signature · 1 line
1.8.3.1
#4 lore raw

v2 cover Removing PKT_TX_IP_CKSUM from fragmentation/reassembly lib

In reply to Sunil Kumar Kori

v2: Checkpath warning are removed

Patchset contains below changes:
------------------------------------------------------------
1. Currently PKT_TX_IP_CKSUM is being set into mbuf->ol_flags during fragmentation and reassemble operation implicitly. Because of this, application is forced to use checksum offload whether it is supported by platform or not.

Also documentation does not provide any expected value of ol_flags in returned mbuf (reassembled or fragmented) so application will never come to know that which offloads are enabled. So transmission may gets failed for the platforms which does not support checksum offload.

Also, IPv6 does not contain any checksum field in header so setting mbuf->ol_flags with PKT_TX_IP_CKSUM is itself invalid.

So removing mentioned flag from the library.

2. Enabling PKT_TX_IP_CKSUM into mbuf->ol_flags at fragmentation and reassembly application itself.

Sunil Kumar Kori (3):
lib/librte_ip_frag: Remove PKT_TX_IP_CKSUM offload flags examples/ip_fragmentation: Enabling IP checksum offload in mbuf examples/ip_reassembly: Enabling IP checksum offload in mbuf

 examples/ip_fragmentation/main.c            | 7 +++++--
 examples/ip_reassembly/main.c               | 6 ++++++
 lib/librte_ip_frag/rte_ipv4_fragmentation.c | 1 -
 lib/librte_ip_frag/rte_ipv4_reassembly.c    | 3 ---
 lib/librte_ip_frag/rte_ipv6_reassembly.c    | 3 ---
 5 files changed, 11 insertions(+), 9 deletions(-)
Signature · 1 line
1.8.3.1
#5 lore raw

PATCH v2 1/3 lib/librte_ip_frag: Remove PKT_TX_IP_CKSUM offload flags

Currently PKT_TX_IP_CKSUM is being set into mbuf->ol_flags during fragmentation and reassemble operation implicitly. Because of this, application is forced to use checksum offload whether it is supported by platform or not.

Also documentation does not provide any expected value of ol_flags in returned mbuf (reassembled or fragmented) so application will never come to know that which offloads are enabled. So transmission may be failed for the platforms which does not support checksum offload.

Also, IPv6 does not contain any checksum field in header so setting mbuf->ol_flags with PKT_TX_IP_CKSUM is itself invalid.

So removing mentioned flag from the library.

---
 lib/librte_ip_frag/rte_ipv4_fragmentation.c | 1 -
 lib/librte_ip_frag/rte_ipv4_reassembly.c    | 3 ---
 lib/librte_ip_frag/rte_ipv6_reassembly.c    | 3 ---
 3 files changed, 7 deletions(-)
lib/librte_ip_frag/rte_ipv4_fragmentation.c +0 -1
index a96fb03..13e60fb 100644
@@ -173,7 +173,6 @@ static inline void __free_fragments(struct rte_mbuf *mb[], uint32_t num)
 		fragment_offset = (uint16_t)(fragment_offset +
 		    out_pkt->pkt_len - sizeof(struct ipv4_hdr));
 
-		out_pkt->ol_flags |= PKT_TX_IP_CKSUM;
 		out_pkt->l3_len = sizeof(struct ipv4_hdr);
 
 		/* Write the fragment to the output list */
lib/librte_ip_frag/rte_ipv4_reassembly.c +0 -3
index 1029b7a..4e20431 100644
@@ -66,9 +66,6 @@ struct rte_mbuf *
 	m = fp->frags[IP_FIRST_FRAG_IDX].mb;
 	fp->frags[IP_FIRST_FRAG_IDX].mb = NULL;
 
-	/* update mbuf fields for reassembled packet. */
-	m->ol_flags |= PKT_TX_IP_CKSUM;
-
 	/* update ipv4 header for the reassembled packet */
 	ip_hdr = rte_pktmbuf_mtod_offset(m, struct ipv4_hdr *, m->l2_len);
 
lib/librte_ip_frag/rte_ipv6_reassembly.c +0 -3
index 855e3f7..eb8b849 100644
@@ -89,9 +89,6 @@ struct rte_mbuf *
 	m = fp->frags[IP_FIRST_FRAG_IDX].mb;
 	fp->frags[IP_FIRST_FRAG_IDX].mb = NULL;
 
-	/* update mbuf fields for reassembled packet. */
-	m->ol_flags |= PKT_TX_IP_CKSUM;
-
 	/* update ipv6 header for the reassembled datagram */
 	ip_hdr = rte_pktmbuf_mtod_offset(m, struct ipv6_hdr *, m->l2_len);
 
Signature · 1 line
1.8.3.1
Acked-by on v2 1/3
#6 lore raw

Re: [dpdk-dev] [PATCH v2 1/3] lib/librte_ip_frag: Remove PKT_TX_IP_CKSUM offload flags

Hi,

Quoted 10 lines

Currently PKT_TX_IP_CKSUM is being set into mbuf->ol_flags during fragmentation and reassemble operation implicitly. Because of this, application is forced to use checksum offload whether it is supported by platform or not.

Also documentation does not provide any expected value of ol_flags in returned mbuf (reassembled or fragmented) so application will never come to know that which offloads are enabled. So transmission may be failed for the platforms which does not support checksum offload.

Quoted 4 lines

Also, IPv6 does not contain any checksum field in header so setting mbuf->ol_flags with PKT_TX_IP_CKSUM is itself invalid.

So removing mentioned flag from the library.

As there is a change in public API behavior, I think it deserves update in release notes. Apart from that:

Quoted 50 lines
---
 lib/librte_ip_frag/rte_ipv4_fragmentation.c | 1 -
 lib/librte_ip_frag/rte_ipv4_reassembly.c    | 3 ---
 lib/librte_ip_frag/rte_ipv6_reassembly.c    | 3 ---
 3 files changed, 7 deletions(-)
lib/librte_ip_frag/rte_ipv4_fragmentation.c +0 -1
index a96fb03..13e60fb 100644
@@ -173,7 +173,6 @@ static inline void __free_fragments(struct rte_mbuf *mb[], uint32_t num)
 		fragment_offset = (uint16_t)(fragment_offset +
 		    out_pkt->pkt_len - sizeof(struct ipv4_hdr));
 
-		out_pkt->ol_flags |= PKT_TX_IP_CKSUM;
 		out_pkt->l3_len = sizeof(struct ipv4_hdr);
 
 		/* Write the fragment to the output list */
lib/librte_ip_frag/rte_ipv4_reassembly.c +0 -3
index 1029b7a..4e20431 100644
@@ -66,9 +66,6 @@ struct rte_mbuf *
 	m = fp->frags[IP_FIRST_FRAG_IDX].mb;
 	fp->frags[IP_FIRST_FRAG_IDX].mb = NULL;
 
-	/* update mbuf fields for reassembled packet. */
-	m->ol_flags |= PKT_TX_IP_CKSUM;
-
 	/* update ipv4 header for the reassembled packet */
 	ip_hdr = rte_pktmbuf_mtod_offset(m, struct ipv4_hdr *, m->l2_len);
 
lib/librte_ip_frag/rte_ipv6_reassembly.c +0 -4
index 855e3f7..eb8b849 100644
@@ -89,9 +89,6 @@ struct rte_mbuf *
 	m = fp->frags[IP_FIRST_FRAG_IDX].mb;
 	fp->frags[IP_FIRST_FRAG_IDX].mb = NULL;
 
-	/* update mbuf fields for reassembled packet. */
-	m->ol_flags |= PKT_TX_IP_CKSUM;
-
 	/* update ipv6 header for the reassembled datagram */
 	ip_hdr = rte_pktmbuf_mtod_offset(m, struct ipv6_hdr *, m->l2_len);
 
--

1.8.3.1

#7 lore raw

Re: [dpdk-dev] [PATCH v2 1/3] lib/librte_ip_frag: Remove PKT_TX_IP_CKSUM offload flags

18/05/2019 17:18, Ananyev, Konstantin:

Quoted 13 lines

Hi,

Quoted 10 lines

Currently PKT_TX_IP_CKSUM is being set into mbuf->ol_flags during fragmentation and reassemble operation implicitly. Because of this, application is forced to use checksum offload whether it is supported by platform or not.

Also documentation does not provide any expected value of ol_flags in returned mbuf (reassembled or fragmented) so application will never come to know that which offloads are enabled. So transmission may be failed for the platforms which does not support checksum offload.

Quoted 8 lines
Quoted 4 lines

Also, IPv6 does not contain any checksum field in header so setting mbuf->ol_flags with PKT_TX_IP_CKSUM is itself invalid.

So removing mentioned flag from the library.

As there is a change in public API behavior, I think it deserves update in release notes. Apart from that:

Is it safe to do this behaviour change?
You did not reply about updating the release notes. Why did you drop this patch in v3?

#8 lore raw

Re: [dpdk-dev] [PATCH v2 1/3] lib/librte_ip_frag: Remove PKT_TX_IP_CKSUM offload flags

26/06/2019 23:10, Thomas Monjalon:

Quoted 19 lines

18/05/2019 17:18, Ananyev, Konstantin:

Quoted 18 lines

Hi,

Quoted 14 lines

Currently PKT_TX_IP_CKSUM is being set into mbuf->ol_flags during fragmentation and reassemble operation implicitly. Because of this, application is forced to use checksum offload whether it is supported by platform or not.

Also documentation does not provide any expected value of ol_flags in returned mbuf (reassembled or fragmented) so application will never come to know that which offloads are enabled. So transmission may be failed for the platforms which does not support checksum offload.

Also, IPv6 does not contain any checksum field in header so setting mbuf->ol_flags with PKT_TX_IP_CKSUM is itself invalid.

So removing mentioned flag from the library.

Quoted 7 lines
Quoted 3 lines

As there is a change in public API behavior, I think it deserves update in release notes. Apart from that:

Is it safe to do this behaviour change?
You did not reply about updating the release notes. Why did you drop this patch in v3?

No reply?
May I consider this series won't go in 19.08 release?

#9 lore raw

Re: [dpdk-dev] [PATCH v2 1/3] lib/librte_ip_frag: Remove PKT_TX_IP_CKSUM offload flags

Quoted 33 lines

-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Thursday, July 4, 2019 5:53 PM
To: Sunil Kumar Kori <[email protected]>
Cc: [email protected]; Ananyev, Konstantin <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v2 1/3] lib/librte_ip_frag: Remove PKT_TX_IP_CKSUM offload flags

26/06/2019 23:10, Thomas Monjalon:

Quoted 23 lines

18/05/2019 17:18, Ananyev, Konstantin:

Quoted 21 lines

Hi,

Quoted 10 lines

Currently PKT_TX_IP_CKSUM is being set into mbuf->ol_flags during fragmentation and reassemble operation implicitly. Because of this, application is forced to use checksum offload whether it is supported by platform or not.

Also documentation does not provide any expected value of ol_flags in returned mbuf (reassembled or fragmented) so application will never come to know that which offloads are enabled. So transmission may be failed for the platforms which does not support checksum offload.

Quoted 4 lines

Also, IPv6 does not contain any checksum field in header so setting mbuf->ol_flags with PKT_TX_IP_CKSUM is itself invalid.

So removing mentioned flag from the library.

As there is a change in public API behavior, I think it deserves update in release notes. Apart from that:

Quoted 6 lines
Quoted 3 lines

Is it safe to do this behaviour change?
You did not reply about updating the release notes. Why did you drop this patch in v3?

No reply?
May I consider this series won't go in 19.08 release?

I think we better push it into 19.08.
It is a real problem, I hit it myself while working on adding reassemble/fragmentation support into ipsec-secgw.
Sunil, can you prepare new version as asked by Thomas?
Konstantin

#10 lore raw

PATCH v2 2/3 examples/ip_fragmentation: Enabling IP checksum offload in mbuf

In reply to Sunil Kumar Kori

As per the documentation to use any IP offload features, application must set required offload flags into mbuf->ol_flags.

---
 examples/ip_fragmentation/main.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
examples/ip_fragmentation/main.c +5 -2
index e90a61e..d821967 100644
@@ -354,10 +354,13 @@ struct rte_lpm6_config lpm6_config = {
 
 		/* src addr */
 		ether_addr_copy(&ports_eth_addr[port_out], &eth_hdr->s_addr);
-		if (ipv6)
+		if (ipv6) {
 			eth_hdr->ether_type = rte_be_to_cpu_16(ETHER_TYPE_IPv6);
-		else
+			m->ol_flags |= PKT_TX_IPV6;
+		} else {
 			eth_hdr->ether_type = rte_be_to_cpu_16(ETHER_TYPE_IPv4);
+			m->ol_flags |= (PKT_TX_IPV4 | PKT_TX_IP_CKSUM);
+		}
 	}
 
 	len += len2;
Signature · 1 line
1.8.3.1
#11 lore raw

Re: [dpdk-dev] [PATCH v2 2/3] examples/ip_fragmentation: Enabling IP checksum offload in mbuf

Quoted 22 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Sunil Kumar Kori
Sent: Thursday, May 16, 2019 12:42 PM
To: [email protected]
Cc: [email protected]
Subject: [dpdk-dev] [PATCH v2 2/3] examples/ip_fragmentation: Enabling IP checksum offload in mbuf

As per the documentation to use any IP offload features, application must set required offload flags into mbuf->ol_flags.

---
 examples/ip_fragmentation/main.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
examples/ip_fragmentation/main.c +0 -0
index e90a61e..d821967 100644

examples/ip_fragmentation/main.c struct rte_lpm6_config lpm6_config = { · line 359

Quoted 8 lines
examples/ip_fragmentation/main.c +2 -2
@@ -354,10 +354,13 @@ struct rte_lpm6_config lpm6_config = {
 
 		/* src addr */
 		ether_addr_copy(&ports_eth_addr[port_out], &eth_hdr->s_addr);
-		if (ipv6)
+		if (ipv6) {
 			eth_hdr->ether_type = rte_be_to_cpu_16(ETHER_TYPE_IPv6);
-		else
+			m->ol_flags |= PKT_TX_IPV6;

Is there is any point to do that?
This sample app, as I remember doesn't request any extra HW offloads. Same comment for patch #3.
Konstantin

Quoted 9 lines
examples/ip_fragmentation/main.c +3 -1
+		} else {
 			eth_hdr->ether_type = rte_be_to_cpu_16(ETHER_TYPE_IPv4);
+			m->ol_flags |= (PKT_TX_IPV4 | PKT_TX_IP_CKSUM);
+		}
 	}
 
 	len += len2;
--

1.8.3.1

#12 lore raw

Re: [dpdk-dev] [PATCH v2 2/3] examples/ip_fragmentation: Enabling IP checksum offload in mbuf

Hi,

Regards
Sunil Kumar Kori

Quoted 42 lines

-----Original Message-----
From: Ananyev, Konstantin <[email protected]>
Sent: Saturday, May 18, 2019 8:51 PM
To: Sunil Kumar Kori <[email protected]>; [email protected]
Subject: [EXT] RE: [dpdk-dev] [PATCH v2 2/3] examples/ip_fragmentation:
Enabling IP checksum offload in mbuf

External Email

----------------------------------------------------------------------

Quoted 6 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Sunil Kumar Kori
Sent: Thursday, May 16, 2019 12:42 PM
To: [email protected]
Cc: [email protected]
Subject: [dpdk-dev] [PATCH v2 2/3] examples/ip_fragmentation: Enabling IP

checksum offload in mbuf

Review

Quoted 10 lines

As per the documentation to use any IP offload features, application must set required offload flags into mbuf->ol_flags.

---
 examples/ip_fragmentation/main.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/examples/ip_fragmentation/main.c

examples/ip_fragmentation/main.c struct rte_lpm6_config lpm6_config = { · line 359

Quoted 11 lines

index e90a61e..d821967 100644

examples/ip_fragmentation/main.c +1 -1
@@ -354,10 +354,13 @@ struct rte_lpm6_config lpm6_config = {
 
 		/* src addr */
 		ether_addr_copy(&ports_eth_addr[port_out], &eth_hdr-
 s_addr);
-		if (ipv6)
+		if (ipv6) {
 			eth_hdr->ether_type =

rte_be_to_cpu_16(ETHER_TYPE_IPv6);

Quoted 9 lines

examples/ip_fragmentation/main.c struct rte_lpm6_config lpm6_config = { · line 359

Quoted 2 lines
examples/ip_fragmentation/main.c +1 -1
-		else
+			m->ol_flags |= PKT_TX_IPV6;

Is there is any point to do that?
This sample app, as I remember doesn't request any extra HW offloads. Same comment for patch #3.
Konstantin

Is this comment valid for IPv6 only ?
Otherwise for IPv4, it is required as IP checksum is neither being updated by library nor by the application.

Quoted 10 lines

examples/ip_fragmentation/main.c struct rte_lpm6_config lpm6_config = { · line 362

Quoted 2 lines
examples/ip_fragmentation/main.c +1 -0
+		} else {
 			eth_hdr->ether_type =

rte_be_to_cpu_16(ETHER_TYPE_IPv4);

Quoted 7 lines
examples/ip_fragmentation/main.c +2 -0
+			m->ol_flags |= (PKT_TX_IPV4 | PKT_TX_IP_CKSUM);
+		}
 	}
 

len += len2;
--
1.8.3.1

#13 lore raw

Re: [dpdk-dev] [PATCH v2 2/3] examples/ip_fragmentation: Enabling IP checksum offload in mbuf

Quoted 64 lines

-----Original Message-----
From: Sunil Kumar Kori [mailto:[email protected]]
Sent: Monday, May 20, 2019 9:09 AM
To: Ananyev, Konstantin <[email protected]>; [email protected]
Subject: RE: [dpdk-dev] [PATCH v2 2/3] examples/ip_fragmentation: Enabling IP checksum offload in mbuf

Hi,

Regards
Sunil Kumar Kori

Quoted 42 lines

-----Original Message-----
From: Ananyev, Konstantin <[email protected]>
Sent: Saturday, May 18, 2019 8:51 PM
To: Sunil Kumar Kori <[email protected]>; [email protected]
Subject: [EXT] RE: [dpdk-dev] [PATCH v2 2/3] examples/ip_fragmentation:
Enabling IP checksum offload in mbuf

External Email

----------------------------------------------------------------------

Quoted 6 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Sunil Kumar Kori
Sent: Thursday, May 16, 2019 12:42 PM
To: [email protected]
Cc: [email protected]
Subject: [dpdk-dev] [PATCH v2 2/3] examples/ip_fragmentation: Enabling IP

checksum offload in mbuf

Review

Quoted 10 lines

As per the documentation to use any IP offload features, application must set required offload flags into mbuf->ol_flags.

---
 examples/ip_fragmentation/main.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/examples/ip_fragmentation/main.c

examples/ip_fragmentation/main.c struct rte_lpm6_config lpm6_config = { · line 359

Quoted 11 lines

index e90a61e..d821967 100644

examples/ip_fragmentation/main.c +1 -1
@@ -354,10 +354,13 @@ struct rte_lpm6_config lpm6_config = {
 
 		/* src addr */
 		ether_addr_copy(&ports_eth_addr[port_out], &eth_hdr-
 s_addr);
-		if (ipv6)
+		if (ipv6) {
 			eth_hdr->ether_type =

rte_be_to_cpu_16(ETHER_TYPE_IPv6);

Quoted 9 lines

examples/ip_fragmentation/main.c struct rte_lpm6_config lpm6_config = { · line 359

Quoted 2 lines
examples/ip_fragmentation/main.c +1 -1
-		else
+			m->ol_flags |= PKT_TX_IPV6;

Is there is any point to do that?
This sample app, as I remember doesn't request any extra HW offloads. Same comment for patch #3.
Konstantin

Quoted 1 line

Is this comment valid for IPv6 only ?

Yes, my comment is about the following line of code:
m->ol_flags |= PKT_TX_IPV6;

Quoted 12 lines

Otherwise for IPv4, it is required as IP checksum is neither being updated by library nor by the application.

Quoted 10 lines

examples/ip_fragmentation/main.c struct rte_lpm6_config lpm6_config = { · line 362

Quoted 2 lines
examples/ip_fragmentation/main.c +1 -0
+		} else {
 			eth_hdr->ether_type =

rte_be_to_cpu_16(ETHER_TYPE_IPv4);

Quoted 7 lines
examples/ip_fragmentation/main.c +2 -0
+			m->ol_flags |= (PKT_TX_IPV4 | PKT_TX_IP_CKSUM);
+		}
 	}
 

len += len2;
--
1.8.3.1

#14 lore raw

PATCH v3 1/2 examples/ip_fragmentation: Enabling IP checksum offload in mbuf

In reply to Sunil Kumar Kori

As per the documentation to use any IP offload features, application must set required offload flags into mbuf->ol_flags.

---
 examples/ip_fragmentation/main.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
examples/ip_fragmentation/main.c +4 -2
index e90a61e..719d6f4 100644
@@ -354,10 +354,12 @@ struct rte_lpm6_config lpm6_config = {
 
 		/* src addr */
 		ether_addr_copy(&ports_eth_addr[port_out], &eth_hdr->s_addr);
-		if (ipv6)
+		if (ipv6) {
 			eth_hdr->ether_type = rte_be_to_cpu_16(ETHER_TYPE_IPv6);
-		else
+		} else {
 			eth_hdr->ether_type = rte_be_to_cpu_16(ETHER_TYPE_IPv4);
+			m->ol_flags |= (PKT_TX_IPV4 | PKT_TX_IP_CKSUM);
+		}
 	}
 
 	len += len2;
Signature · 1 line
1.8.3.1
#15 lore raw

PATCH v3 2/2 examples/ip_reassembly: Enabling IP checksum offload in mbuf

As per the documentation to use any IP offload features, application must set required offload flags into mbuf->ol_flags.

---
 examples/ip_reassembly/main.c | 3 +++
 1 file changed, 3 insertions(+)
examples/ip_reassembly/main.c +3 -0
index 17b55d4..0ad526c 100644
@@ -353,6 +353,9 @@ struct rte_lpm6_config lpm6_config = {
 					struct ether_hdr *);
 				ip_hdr = (struct ipv4_hdr *)(eth_hdr + 1);
 			}
+
+			/* update offloading flags */
+			m->ol_flags |= (PKT_TX_IPV4 | PKT_TX_IP_CKSUM);
 		}
 		ip_dst = rte_be_to_cpu_32(ip_hdr->dst_addr);
 
Signature · 1 line
1.8.3.1
Acked-by on v3 2/2
#16 lore raw

Re: [dpdk-dev] [PATCH v3 2/2] examples/ip_reassembly: Enabling IP checksum offload in mbuf

Quoted 15 lines

As per the documentation to use any IP offload features, application must set required offload flags into mbuf->ol_flags.

---
 examples/ip_reassembly/main.c | 3 +++
 1 file changed, 3 insertions(+)
examples/ip_reassembly/main.c +0 -0
index 17b55d4..0ad526c 100644

examples/ip_reassembly/main.c struct rte_lpm6_config lpm6_config = {

Quoted 10 lines
examples/ip_reassembly/main.c +3 -1
@@ -353,6 +353,9 @@ struct rte_lpm6_config lpm6_config = {
 					struct ether_hdr *);
 				ip_hdr = (struct ipv4_hdr *)(eth_hdr + 1);
 			}
+
+			/* update offloading flags */
+			m->ol_flags |= (PKT_TX_IPV4 | PKT_TX_IP_CKSUM);
 		}
 		ip_dst = rte_be_to_cpu_32(ip_hdr->dst_addr);
 
--
Quoted 1 line

1.8.3.1

Acked-by on v3 1/2
#17 lore raw

Re: [dpdk-dev] [PATCH v3 1/2] examples/ip_fragmentation: Enabling IP checksum offload in mbuf

In reply to Sunil Kumar Kori
Quoted 19 lines

As per the documentation to use any IP offload features, application must set required offload flags into mbuf->ol_flags.

---
 examples/ip_fragmentation/main.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
examples/ip_fragmentation/main.c +1 -1
index e90a61e..719d6f4 100644
@@ -354,10 +354,12 @@ struct rte_lpm6_config lpm6_config = {
 
 		/* src addr */
 		ether_addr_copy(&ports_eth_addr[port_out], &eth_hdr->s_addr);
-		if (ipv6)
+		if (ipv6) {

examples/ip_fragmentation/main.c struct rte_lpm6_config lpm6_config = {

Quoted 10 lines
examples/ip_fragmentation/main.c +3 -2
 			eth_hdr->ether_type = rte_be_to_cpu_16(ETHER_TYPE_IPv6);
-		else
+		} else {
 			eth_hdr->ether_type = rte_be_to_cpu_16(ETHER_TYPE_IPv4);
+			m->ol_flags |= (PKT_TX_IPV4 | PKT_TX_IP_CKSUM);
+		}
 	}
 
 	len += len2;
--
Quoted 1 line

1.8.3.1

#18 lore raw

PATCH v4 1/3 lib/librte_ip_frag: remove IP checkum offload flag

In reply to Sunil Kumar Kori

From: Sunil Kumar Kori <[email protected]>

Currently PKT_TX_IP_CKSUM is being set into mbuf->ol_flags during fragmentation and reassemble operation implicitly. Because of this, application is forced to use checksum offload whether it is supported by platform or not.

Also documentation does not provide any expected value of ol_flags in returned mbuf (reassembled or fragmented) so application will never come to know that which offloads are enabled. So transmission may be failed for the platforms which does not support checksum offload.

Also, IPv6 does not contain any checksum field in header so setting mbuf->ol_flags with PKT_TX_IP_CKSUM is itself invalid.

So removing mentioned flag from the library.

---
v4:
- Update release notes

---
 doc/guides/rel_notes/release_19_08.rst   | 15 +++++++++++++++
 lib/librte_ip_frag/rte_ipv4_reassembly.c |  3 ---
 lib/librte_ip_frag/rte_ipv6_reassembly.c |  3 ---
 3 files changed, 15 insertions(+), 6 deletions(-)
doc/guides/rel_notes/release_19_08.rst +15 -0
index defbc5e27..ad9cbf4a2 100644
@@ -281,6 +281,21 @@ ABI Changes
 * bbdev: New operations and parameters added to support new 5GNR operations.
   The bbdev ABI is still kept experimental.
 
+* ip_fragmentation: IP fragmentation library converts input mbuf into fragments
+  using input MTU size via ``rte_ipv4_fragment_packet`` interface.
+  Once fragmentation is done, each ``mbuf->ol_flags`` are set to enable IP
+  checksum H/W offload irrespective of the platform capability.
+  Cleared IP checksum H/W offload flag from the library. The application must
+  set this flag if it is supported by the platform and application wishes to
+  use it.
+
+* ip_reassembly: IP reassembly library converts the list of fragments into a
+  reassembled packet via ``rte_ipv4_frag_reassemble_packet`` interface.
+  Once reassembly is done, ``mbuf->ol_flags`` are set to enable IP checksum H/W
+  offload irrespective of the platform capability. Cleared IP checksum H/W
+  offload flag from the library. The application must set this flag if it is
+  supported by the platform and application wishes to use it.
+
 
 Shared Library Versions
 -----------------------
lib/librte_ip_frag/rte_ipv4_reassembly.c +0 -3
index b7b92ed28..1dda8aca0 100644
@@ -66,9 +66,6 @@ ipv4_frag_reassemble(struct ip_frag_pkt *fp)
 	m = fp->frags[IP_FIRST_FRAG_IDX].mb;
 	fp->frags[IP_FIRST_FRAG_IDX].mb = NULL;
 
-	/* update mbuf fields for reassembled packet. */
-	m->ol_flags |= PKT_TX_IP_CKSUM;
-
 	/* update ipv4 header for the reassembled packet */
 	ip_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *, m->l2_len);
 
lib/librte_ip_frag/rte_ipv6_reassembly.c +0 -3
index 169b01a5d..ad0105518 100644
@@ -89,9 +89,6 @@ ipv6_frag_reassemble(struct ip_frag_pkt *fp)
 	m = fp->frags[IP_FIRST_FRAG_IDX].mb;
 	fp->frags[IP_FIRST_FRAG_IDX].mb = NULL;
 
-	/* update mbuf fields for reassembled packet. */
-	m->ol_flags |= PKT_TX_IP_CKSUM;
-
 	/* update ipv6 header for the reassembled datagram */
 	ip_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv6_hdr *, m->l2_len);
 
Signature · 1 line
2.22.0
#19 lore raw

PATCH v4 2/3 examples/ip_fragmentation: enable IP checksum offload

From: Sunil Kumar Kori <[email protected]>

As per the documentation to use any IP offload features, application must set required offload flags into mbuf->ol_flags.

---
v4:
- Rebased to top of tree
- Fix check-gitlog.sh issues

---
 examples/ip_fragmentation/main.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
examples/ip_fragmentation/main.c +4 -2
index 85c0100f7..ccaf23ff0 100644
@@ -357,12 +357,14 @@ l3fwd_simple_forward(struct rte_mbuf *m, struct lcore_queue_conf *qconf,
 		/* src addr */
 		rte_ether_addr_copy(&ports_eth_addr[port_out],
 				&eth_hdr->s_addr);
-		if (ipv6)
+		if (ipv6) {
 			eth_hdr->ether_type =
 				rte_be_to_cpu_16(RTE_ETHER_TYPE_IPV6);
-		else
+		} else {
 			eth_hdr->ether_type =
 				rte_be_to_cpu_16(RTE_ETHER_TYPE_IPV4);
+			m->ol_flags |= (PKT_TX_IPV4 | PKT_TX_IP_CKSUM);
+		}
 	}
 
 	len += len2;
Signature · 1 line
2.22.0
#20 lore raw

PATCH v4 3/3 examples/ip_reassembly: enable IP checksum offload

In reply to [email protected]

From: Sunil Kumar Kori <[email protected]>

As per the documentation to use any IP offload features, application must set required offload flags into mbuf->ol_flags.

---
v4:
- Rebased to top of tree
- Fix check-gitlog.sh issues

---
 examples/ip_reassembly/main.c | 3 +++
 1 file changed, 3 insertions(+)
examples/ip_reassembly/main.c +3 -0
index fbd09341f..38b39be6b 100644
@@ -353,6 +353,9 @@ reassemble(struct rte_mbuf *m, uint16_t portid, uint32_t queue,
 					struct rte_ether_hdr *);
 				ip_hdr = (struct rte_ipv4_hdr *)(eth_hdr + 1);
 			}
+
+			/* update offloading flags */
+			m->ol_flags |= (PKT_TX_IPV4 | PKT_TX_IP_CKSUM);
 		}
 		ip_dst = rte_be_to_cpu_32(ip_hdr->dst_addr);
 
Signature · 1 line
2.22.0
#21 lore raw

Re: [dpdk-dev] [PATCH v4 1/3] lib/librte_ip_frag: remove IP checkum offload flag

In reply to [email protected]

08/07/2019 06:32, [email protected]:

Quoted 12 lines

From: Sunil Kumar Kori <[email protected]>

Currently PKT_TX_IP_CKSUM is being set into mbuf->ol_flags during fragmentation and reassemble operation implicitly. Because of this, application is forced to use checksum offload whether it is supported by platform or not.

Also documentation does not provide any expected value of ol_flags in returned mbuf (reassembled or fragmented) so application will never come to know that which offloads are enabled. So transmission may be failed for the platforms which does not support checksum offload.

Quoted 7 lines

Also, IPv6 does not contain any checksum field in header so setting mbuf->ol_flags with PKT_TX_IP_CKSUM is itself invalid.

So removing mentioned flag from the library.

Applied, thanks

PS: I move the release notes from ABI to API changes as it is an API behaviour change.

#22 lore raw

PATCH v2 3/3 examples/ip_reassembly: Enabling IP checksum offload in mbuf

In reply to Sunil Kumar Kori

As per the documentation to use any IP offload features, application must set required offload flags into mbuf->ol_flags.

---
 examples/ip_reassembly/main.c | 6 ++++++
 1 file changed, 6 insertions(+)
examples/ip_reassembly/main.c +6 -0
index 17b55d4..686e364 100644
@@ -353,6 +353,9 @@ struct rte_lpm6_config lpm6_config = {
 					struct ether_hdr *);
 				ip_hdr = (struct ipv4_hdr *)(eth_hdr + 1);
 			}
+
+			/* update offloading flags */
+			m->ol_flags |= (PKT_TX_IPV4 | PKT_TX_IP_CKSUM);
 		}
 		ip_dst = rte_be_to_cpu_32(ip_hdr->dst_addr);
 
@@ -391,6 +394,9 @@ struct rte_lpm6_config lpm6_config = {
 				eth_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *);
 				ip_hdr = (struct ipv6_hdr *)(eth_hdr + 1);
 			}
+
+			/* update offloading flags */
+			m->ol_flags |= PKT_TX_IPV6;
 		}
 
 		/* Find destination port */
Signature · 1 line
1.8.3.1