lib/net: support UDP pseudo-header for UFO

Message ID 20230112092608.868006-1-zhichaox.zeng@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series lib/net: support UDP pseudo-header for UFO |

Checks

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

Commit Message

Zhichao Zeng Jan. 12, 2023, 9:26 a.m. UTC
  Add UDP pseudo-header processing for UDP segmentation offload
by adding the UDP_SEG flag.

Signed-off-by: Zhichao Zeng <zhichaox.zeng@intel.com>
---
 lib/net/rte_ip.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Zhichao Zeng Feb. 8, 2023, 10:35 a.m. UTC | #1
Hi Olivier

Could you please help to review this patch? Thanks.

BR
Zhichao
> -----Original Message-----
> From: Zeng, ZhichaoX <zhichaox.zeng@intel.com>
> Sent: Thursday, January 12, 2023 5:26 PM
> To: dev@dpdk.org
> Cc: Zhou, YidingX <yidingx.zhou@intel.com>; Zeng, ZhichaoX
> <zhichaox.zeng@intel.com>; Matz, Olivier <olivier.matz@6wind.com>
> Subject: [PATCH] lib/net: support UDP pseudo-header for UFO
> 
> Add UDP pseudo-header processing for UDP segmentation offload by adding
> the UDP_SEG flag.
> 
> Signed-off-by: Zhichao Zeng <zhichaox.zeng@intel.com>
  
Olivier Matz Feb. 10, 2023, 1:20 p.m. UTC | #2
Hello Zhichao,

Sorry for the delayed response.

On Thu, Jan 12, 2023 at 05:26:08PM +0800, Zhichao Zeng wrote:
> Add UDP pseudo-header processing for UDP segmentation offload
> by adding the UDP_SEG flag.
> 
> Signed-off-by: Zhichao Zeng <zhichaox.zeng@intel.com>
> ---
>  lib/net/rte_ip.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/net/rte_ip.h b/lib/net/rte_ip.h
> index 9c8e8206f0..4761ede747 100644
> --- a/lib/net/rte_ip.h
> +++ b/lib/net/rte_ip.h
> @@ -345,7 +345,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 & RTE_MBUF_F_TX_TCP_SEG) {
> +	if (ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG)) {
>  		psd_hdr.len = 0;
>  	} else {
>  		l3_len = rte_be_to_cpu_16(ipv4_hdr->total_length);
> -- 
> 2.25.1
> 

Can you give some more detail about how rte_ipv4_phdr_cksum() is called in your
use-case? (what driver, what libs, what use-case)

Currently, I see that only the iavf driver supports udp-segmented packets. The
lib/vhost is also able to pass the offload information to the virtio ring.

For me, the mbufs that have offload flags and that are being transmitted to a
driver should use the rte_eth_tx_prepare() API. This function will (among other
things) update the required checksums in the packet when Tx offload is set.

Most drivers call rte_net_intel_cksum_flags_prepare() in their tx_pkt_prepare
callback, so I suspect this function has to be updated. Note that updating it
may have an impact on its user that supports UDP_SEG (lib/vhost and
driver/net/iavf).

I'm not saying that the patch is wrong, but I would like to better understand
why you need it.

Regards,
Olivier
  
Zhichao Zeng Feb. 13, 2023, 10:22 a.m. UTC | #3
Hi Olivier,

Thanks for your comments. 

Yes, this patch is to support the UDP fragmentation offload feature
in the iavf driver, which is planned to be fully supported in 23.07.

It's my fault for not clarifying the details. In addition, is it acceptable
to add the UDP_SEG flag separately now?

If it's acceptable, I'll resubmit v2 and add more details into the log.
If not, I'll submit it later with the rest code of the UFO feature.

BR
Zhichao

> -----Original Message-----
> From: Olivier Matz <olivier.matz@6wind.com>
> Sent: Friday, February 10, 2023 9:20 PM
> To: Zeng, ZhichaoX <zhichaox.zeng@intel.com>
> Cc: dev@dpdk.org; Zhou, YidingX <yidingx.zhou@intel.com>
> Subject: Re: [PATCH] lib/net: support UDP pseudo-header for UFO
> 
> Hello Zhichao,
> 
> Sorry for the delayed response.
> 
> >
> 
> Can you give some more detail about how rte_ipv4_phdr_cksum() is called in
> your
> use-case? (what driver, what libs, what use-case)
> 
> Currently, I see that only the iavf driver supports udp-segmented packets.
> The
> lib/vhost is also able to pass the offload information to the virtio ring.
> 
> For me, the mbufs that have offload flags and that are being transmitted to a
> driver should use the rte_eth_tx_prepare() API. This function will (among
> other
> things) update the required checksums in the packet when Tx offload is set.
> 
> Most drivers call rte_net_intel_cksum_flags_prepare() in their
> tx_pkt_prepare
> callback, so I suspect this function has to be updated. Note that updating it
> may have an impact on its user that supports UDP_SEG (lib/vhost and
> driver/net/iavf).
> 
> I'm not saying that the patch is wrong, but I would like to better understand
> why you need it.
> 
> Regards,
> Olivier
  

Patch

diff --git a/lib/net/rte_ip.h b/lib/net/rte_ip.h
index 9c8e8206f0..4761ede747 100644
--- a/lib/net/rte_ip.h
+++ b/lib/net/rte_ip.h
@@ -345,7 +345,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 & RTE_MBUF_F_TX_TCP_SEG) {
+	if (ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG)) {
 		psd_hdr.len = 0;
 	} else {
 		l3_len = rte_be_to_cpu_16(ipv4_hdr->total_length);