DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] net/mlx5: zero encap UDP csum for IPv4 too
@ 2023-11-13  7:29 Bing Zhao
  2023-11-13  8:01 ` Suanming Mou
  2023-11-14  8:14 ` Raslan Darawsheh
  0 siblings, 2 replies; 3+ messages in thread
From: Bing Zhao @ 2023-11-13  7:29 UTC (permalink / raw)
  To: matan, viacheslavo, rasland, suanmingm, orika; +Cc: dev, Eli Britstein, stable

From: Eli Britstein <elibr@nvidia.com>

A zero UDP csum indicates it should not be validated by the receiver.
The HW may not calculate UDP csum after encap.

The cited commit made sure the UDP csum is zero for UDP over IPv6,
mistakenly not handling UDP over IPv4. Fix it.

Fixes: bf1d7d9a033a ("net/mlx5: zero out UDP checksum in encapsulation")
Cc: stable@dpdk.org

Signed-off-by: Eli Britstein <elibr@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow_dv.c | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 9753af2cb1..115d730317 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -4713,6 +4713,7 @@ flow_dv_zero_encap_udp_csum(void *data, struct rte_flow_error *error)
 {
 	struct rte_ether_hdr *eth = NULL;
 	struct rte_vlan_hdr *vlan = NULL;
+	struct rte_ipv4_hdr *ipv4 = NULL;
 	struct rte_ipv6_hdr *ipv6 = NULL;
 	struct rte_udp_hdr *udp = NULL;
 	char *next_hdr;
@@ -4729,24 +4730,27 @@ flow_dv_zero_encap_udp_csum(void *data, struct rte_flow_error *error)
 		next_hdr += sizeof(struct rte_vlan_hdr);
 	}
 
-	/* HW calculates IPv4 csum. no need to proceed */
-	if (proto == RTE_ETHER_TYPE_IPV4)
-		return 0;
-
 	/* non IPv4/IPv6 header. not supported */
-	if (proto != RTE_ETHER_TYPE_IPV6) {
+	if (proto != RTE_ETHER_TYPE_IPV4 && proto != RTE_ETHER_TYPE_IPV6) {
 		return rte_flow_error_set(error, ENOTSUP,
 					  RTE_FLOW_ERROR_TYPE_ACTION,
 					  NULL, "Cannot offload non IPv4/IPv6");
 	}
 
-	ipv6 = (struct rte_ipv6_hdr *)next_hdr;
-
-	/* ignore non UDP */
-	if (ipv6->proto != IPPROTO_UDP)
-		return 0;
+	if (proto == RTE_ETHER_TYPE_IPV4) {
+		ipv4 = (struct rte_ipv4_hdr *)next_hdr;
+		/* ignore non UDP */
+		if (ipv4->next_proto_id != IPPROTO_UDP)
+			return 0;
+		udp = (struct rte_udp_hdr *)(ipv4 + 1);
+	} else {
+		ipv6 = (struct rte_ipv6_hdr *)next_hdr;
+		/* ignore non UDP */
+		if (ipv6->proto != IPPROTO_UDP)
+			return 0;
+		udp = (struct rte_udp_hdr *)(ipv6 + 1);
+	}
 
-	udp = (struct rte_udp_hdr *)(ipv6 + 1);
 	udp->dgram_cksum = 0;
 
 	return 0;
-- 
2.34.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] net/mlx5: zero encap UDP csum for IPv4 too
  2023-11-13  7:29 [PATCH] net/mlx5: zero encap UDP csum for IPv4 too Bing Zhao
@ 2023-11-13  8:01 ` Suanming Mou
  2023-11-14  8:14 ` Raslan Darawsheh
  1 sibling, 0 replies; 3+ messages in thread
From: Suanming Mou @ 2023-11-13  8:01 UTC (permalink / raw)
  To: Bing Zhao, Matan Azrad, Slava Ovsiienko, Raslan Darawsheh, Ori Kam
  Cc: dev, Eli Britstein, stable

Hi,

> -----Original Message-----
> From: Bing Zhao <bingz@nvidia.com>
> Sent: Monday, November 13, 2023 3:30 PM
> To: Matan Azrad <matan@nvidia.com>; Slava Ovsiienko
> <viacheslavo@nvidia.com>; Raslan Darawsheh <rasland@nvidia.com>; Suanming
> Mou <suanmingm@nvidia.com>; Ori Kam <orika@nvidia.com>
> Cc: dev@dpdk.org; Eli Britstein <elibr@nvidia.com>; stable@dpdk.org
> Subject: [PATCH] net/mlx5: zero encap UDP csum for IPv4 too
> 
> From: Eli Britstein <elibr@nvidia.com>
> 
> A zero UDP csum indicates it should not be validated by the receiver.
> The HW may not calculate UDP csum after encap.
> 
> The cited commit made sure the UDP csum is zero for UDP over IPv6, mistakenly
> not handling UDP over IPv4. Fix it.
> 
> Fixes: bf1d7d9a033a ("net/mlx5: zero out UDP checksum in encapsulation")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Eli Britstein <elibr@nvidia.com>

Acked-by: Suanming Mou <suanmingm@nvidia.com>

> ---
>  drivers/net/mlx5/mlx5_flow_dv.c | 26 +++++++++++++++-----------
>  1 file changed, 15 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
> index 9753af2cb1..115d730317 100644
> --- a/drivers/net/mlx5/mlx5_flow_dv.c
> +++ b/drivers/net/mlx5/mlx5_flow_dv.c
> @@ -4713,6 +4713,7 @@ flow_dv_zero_encap_udp_csum(void *data, struct
> rte_flow_error *error)  {
>  	struct rte_ether_hdr *eth = NULL;
>  	struct rte_vlan_hdr *vlan = NULL;
> +	struct rte_ipv4_hdr *ipv4 = NULL;
>  	struct rte_ipv6_hdr *ipv6 = NULL;
>  	struct rte_udp_hdr *udp = NULL;
>  	char *next_hdr;
> @@ -4729,24 +4730,27 @@ flow_dv_zero_encap_udp_csum(void *data, struct
> rte_flow_error *error)
>  		next_hdr += sizeof(struct rte_vlan_hdr);
>  	}
> 
> -	/* HW calculates IPv4 csum. no need to proceed */
> -	if (proto == RTE_ETHER_TYPE_IPV4)
> -		return 0;
> -
>  	/* non IPv4/IPv6 header. not supported */
> -	if (proto != RTE_ETHER_TYPE_IPV6) {
> +	if (proto != RTE_ETHER_TYPE_IPV4 && proto != RTE_ETHER_TYPE_IPV6)
> {
>  		return rte_flow_error_set(error, ENOTSUP,
>  					  RTE_FLOW_ERROR_TYPE_ACTION,
>  					  NULL, "Cannot offload non
> IPv4/IPv6");
>  	}
> 
> -	ipv6 = (struct rte_ipv6_hdr *)next_hdr;
> -
> -	/* ignore non UDP */
> -	if (ipv6->proto != IPPROTO_UDP)
> -		return 0;
> +	if (proto == RTE_ETHER_TYPE_IPV4) {
> +		ipv4 = (struct rte_ipv4_hdr *)next_hdr;
> +		/* ignore non UDP */
> +		if (ipv4->next_proto_id != IPPROTO_UDP)
> +			return 0;
> +		udp = (struct rte_udp_hdr *)(ipv4 + 1);
> +	} else {
> +		ipv6 = (struct rte_ipv6_hdr *)next_hdr;
> +		/* ignore non UDP */
> +		if (ipv6->proto != IPPROTO_UDP)
> +			return 0;
> +		udp = (struct rte_udp_hdr *)(ipv6 + 1);
> +	}
> 
> -	udp = (struct rte_udp_hdr *)(ipv6 + 1);
>  	udp->dgram_cksum = 0;
> 
>  	return 0;
> --
> 2.34.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] net/mlx5: zero encap UDP csum for IPv4 too
  2023-11-13  7:29 [PATCH] net/mlx5: zero encap UDP csum for IPv4 too Bing Zhao
  2023-11-13  8:01 ` Suanming Mou
@ 2023-11-14  8:14 ` Raslan Darawsheh
  1 sibling, 0 replies; 3+ messages in thread
From: Raslan Darawsheh @ 2023-11-14  8:14 UTC (permalink / raw)
  To: Bing Zhao, Matan Azrad, Slava Ovsiienko, Suanming Mou, Ori Kam
  Cc: dev, Eli Britstein, stable

Hi,

> -----Original Message-----
> From: Bing Zhao <bingz@nvidia.com>
> Sent: Monday, November 13, 2023 9:30 AM
> To: Matan Azrad <matan@nvidia.com>; Slava Ovsiienko
> <viacheslavo@nvidia.com>; Raslan Darawsheh <rasland@nvidia.com>;
> Suanming Mou <suanmingm@nvidia.com>; Ori Kam <orika@nvidia.com>
> Cc: dev@dpdk.org; Eli Britstein <elibr@nvidia.com>; stable@dpdk.org
> Subject: [PATCH] net/mlx5: zero encap UDP csum for IPv4 too
> 
> From: Eli Britstein <elibr@nvidia.com>
> 
> A zero UDP csum indicates it should not be validated by the receiver.
> The HW may not calculate UDP csum after encap.
> 
> The cited commit made sure the UDP csum is zero for UDP over IPv6,
> mistakenly not handling UDP over IPv4. Fix it.
> 
> Fixes: bf1d7d9a033a ("net/mlx5: zero out UDP checksum in encapsulation")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Eli Britstein <elibr@nvidia.com>
> ---

Patch applied to next-net-mlx,

Kindest regards
Raslan Darawsheh

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-11-14  8:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-13  7:29 [PATCH] net/mlx5: zero encap UDP csum for IPv4 too Bing Zhao
2023-11-13  8:01 ` Suanming Mou
2023-11-14  8:14 ` Raslan Darawsheh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).