Skip to contentSkip to conversation

net: add support for UDP segmentation case

PATCH In review Radu Nicolau 2 participants 3 messages Sep 3, 2021 – Oct 15, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: add support for UDP segmentation case

Add support to the ipv4/ipv6 pseudo-header function when TSO is enabled in the UDP case, eg PKT_TX_UDP_SEG is set in the mbuf ol_flags

---
 lib/net/rte_ip.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/net/rte_ip.h +2 -2
index 05948b69b7..c916ec1b09 100644
@@ -333,7 +333,7 @@ rte_ipv4_phdr_cksum(const struct rte_ipv4_hdr *ipv4_hdr, uint64_t ol_flags)
 	psd_hdr.dst_addr = ipv4_hdr->dst_addr;
 	psd_hdr.zero = 0;
 	psd_hdr.proto = ipv4_hdr->next_proto_id;
-	if (ol_flags & PKT_TX_TCP_SEG) {
+	if (ol_flags & (PKT_TX_TCP_SEG | PKT_TX_UDP_SEG)) {
 		psd_hdr.len = 0;
 	} else {
 		l3_len = rte_be_to_cpu_16(ipv4_hdr->total_length);
@@ -474,7 +474,7 @@ rte_ipv6_phdr_cksum(const struct rte_ipv6_hdr *ipv6_hdr, uint64_t ol_flags)
 	} psd_hdr;
 
 	psd_hdr.proto = (uint32_t)(ipv6_hdr->proto << 24);
-	if (ol_flags & PKT_TX_TCP_SEG) {
+	if (ol_flags & (PKT_TX_TCP_SEG | PKT_TX_UDP_SEG)) {
 		psd_hdr.len = 0;
 	} else {
 		psd_hdr.len = ipv6_hdr->payload_len;
Signature · 1 line
2.25.1
#1 lore raw

Hi Radu,

Quoted 1 line · Radu Nicolau

[PATCH] net: add support for UDP segmentation case

What about this title instead?

net: exclude IP len from phdr cksum if offloading UDP frag

Quoted 2 lines

Add support to the ipv4/ipv6 pseudo-header function when TSO is enabled in the UDP case, eg PKT_TX_UDP_SEG is set in the mbuf ol_flags

I think it would be clearer to say "UDP fragmentation" instead of "TSO is enabled in the UDP case".

Quoted 11 lines
---
 lib/net/rte_ip.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/net/rte_ip.h +0 -0
index 05948b69b7..c916ec1b09 100644

lib/net/rte_ip.h rte_ipv4_phdr_cksum(const struct rte_ipv4_hdr *ipv4_hdr, uint64_t ol_flags) · line 339

Quoted 8 lines
lib/net/rte_ip.h +1 -1
@@ -333,7 +333,7 @@ rte_ipv4_phdr_cksum(const struct rte_ipv4_hdr *ipv4_hdr, uint64_t ol_flags)
 	psd_hdr.dst_addr = ipv4_hdr->dst_addr;
 	psd_hdr.zero = 0;
 	psd_hdr.proto = ipv4_hdr->next_proto_id;
-	if (ol_flags & PKT_TX_TCP_SEG) {
+	if (ol_flags & (PKT_TX_TCP_SEG | PKT_TX_UDP_SEG)) {
 		psd_hdr.len = 0;
 	} else {
 		l3_len = rte_be_to_cpu_16(ipv4_hdr->total_length);

Can you also update the API comment?

Quoted 12 lines
lib/net/rte_ip.h +1 -1
@@ -474,7 +474,7 @@ rte_ipv6_phdr_cksum(const struct rte_ipv6_hdr *ipv6_hdr, uint64_t ol_flags)
 	} psd_hdr;
 
 	psd_hdr.proto = (uint32_t)(ipv6_hdr->proto << 24);
-	if (ol_flags & PKT_TX_TCP_SEG) {
+	if (ol_flags & (PKT_TX_TCP_SEG | PKT_TX_UDP_SEG)) {
 		psd_hdr.len = 0;
 	} else {
 		psd_hdr.len = ipv6_hdr->payload_len;
Signature · 1 line
2.25.1

No objection for this patch, but I think we should consider removing this ol_flags parameter from the pseudo header checksum calculation functions in the future, because it is a bit confusing.

Historically, this was done in commit 4199fdea60c3 ("mbuf: generic support for TCP segmentation offload") because we were expecting that this pseudo-header checksum (required by Intel hw when doing checksum or TSO) will be done in the same way for many drivers (i.e. without the IP length for TSO). I don't know if it is the case.

Or maybe a 'use_0_length' parameter would make more sense than 'ol_flags'.

Thanks,
Olivier

#2 lore raw

Hi Olivier, thanks for the feedback. I marked it as deferred for this release.

Quoted 61 lines · Olivier Matz

Hi Radu,

Quoted 1 line · Radu Nicolau

[PATCH] net: add support for UDP segmentation case

What about this title instead?

net: exclude IP len from phdr cksum if offloading UDP frag

Quoted 2 lines

Add support to the ipv4/ipv6 pseudo-header function when TSO is enabled in the UDP case, eg PKT_TX_UDP_SEG is set in the mbuf ol_flags

I think it would be clearer to say "UDP fragmentation" instead of "TSO is enabled in the UDP case".

Quoted 11 lines
---
  lib/net/rte_ip.h | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
lib/net/rte_ip.h +0 -0
index 05948b69b7..c916ec1b09 100644

lib/net/rte_ip.h rte_ipv4_phdr_cksum(const struct rte_ipv4_hdr *ipv4_hdr, uint64_t ol_flags) · line 339

Quoted 8 lines
lib/net/rte_ip.h +1 -1
@@ -333,7 +333,7 @@ rte_ipv4_phdr_cksum(const struct rte_ipv4_hdr *ipv4_hdr, uint64_t ol_flags)
  	psd_hdr.dst_addr = ipv4_hdr->dst_addr;
  	psd_hdr.zero = 0;
  	psd_hdr.proto = ipv4_hdr->next_proto_id;
-	if (ol_flags & PKT_TX_TCP_SEG) {
+	if (ol_flags & (PKT_TX_TCP_SEG | PKT_TX_UDP_SEG)) {
  		psd_hdr.len = 0;
  	} else {
  		l3_len = rte_be_to_cpu_16(ipv4_hdr->total_length);

Can you also update the API comment?

Quoted 12 lines
lib/net/rte_ip.h +1 -1
@@ -474,7 +474,7 @@ rte_ipv6_phdr_cksum(const struct rte_ipv6_hdr *ipv6_hdr, uint64_t ol_flags)
  	} psd_hdr;
 
  	psd_hdr.proto = (uint32_t)(ipv6_hdr->proto << 24);
-	if (ol_flags & PKT_TX_TCP_SEG) {
+	if (ol_flags & (PKT_TX_TCP_SEG | PKT_TX_UDP_SEG)) {
  		psd_hdr.len = 0;
  	} else {
  		psd_hdr.len = ipv6_hdr->payload_len;
Signature · 1 line
2.25.1

No objection for this patch, but I think we should consider removing this ol_flags parameter from the pseudo header checksum calculation functions in the future, because it is a bit confusing.

Historically, this was done in commit 4199fdea60c3 ("mbuf: generic support for TCP segmentation offload") because we were expecting that this pseudo-header checksum (required by Intel hw when doing checksum or TSO) will be done in the same way for many drivers (i.e. without the IP length for TSO). I don't know if it is the case.

Or maybe a 'use_0_length' parameter would make more sense than 'ol_flags'.

Thanks,
Olivier