DPDK patches and discussions
 help / color / mirror / Atom feed
From: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
To: dev@dpdk.org
Cc: rasland@mellanox.com, Eli Britstein <elibr@mellanox.com>
Subject: [dpdk-dev] [PATCH v2] net/mlx5: zero out UDP csum for IPv6 encap headers
Date: Thu,  4 Jul 2019 11:16:28 +0000	[thread overview]
Message-ID: <1562238988-13138-1-git-send-email-viacheslavo@mellanox.com> (raw)

From: Eli Britstein <elibr@mellanox.com>

Mellanox NICs do not support UDP checksum hardware tx offload over IPv6.
This limitation becomes critical for UDP based tunnels like VXLAN.
Beside the UDP checksum validity is required by IPv6 there is an option
in Linux to allow accepting UDP zero sum (see udp6zerocsumrx in iproute2
package).

This patch zeroes out the UDP checksum field for encapsulation headers
in raw encap action.

Signed-off-by: Eli Britstein <elibr@mellanox.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
---
 drivers/net/mlx5/mlx5_flow_dv.c | 46 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 933ad0b..0e6d17d 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -1362,6 +1362,50 @@ struct field_modify_info modify_tcp[] = {
 	return 0;
 }
 
+static int
+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_ipv6_hdr *ipv6 = NULL;
+	struct rte_udp_hdr *udp = NULL;
+	char *next_hdr;
+	uint16_t proto;
+
+	eth = (struct rte_ether_hdr *)data;
+	next_hdr = (char *)(eth + 1);
+	proto = RTE_BE16(eth->ether_type);
+
+	/* VLAN skipping */
+	while (proto == RTE_ETHER_TYPE_VLAN || proto == RTE_ETHER_TYPE_QINQ) {
+		next_hdr += sizeof(struct rte_vlan_hdr);
+		vlan = (struct rte_vlan_hdr *)next_hdr;
+		proto = RTE_BE16(vlan->eth_proto);
+	}
+
+	/* 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) {
+		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;
+
+	udp = (struct rte_udp_hdr *)(ipv6 + 1);
+	udp->dgram_cksum = 0;
+
+	return 0;
+}
+
 /**
  * Convert L2 encap action to DV specification.
  *
@@ -1400,6 +1444,8 @@ struct field_modify_info modify_tcp[] = {
 			(const struct rte_flow_action_raw_encap *)action->conf;
 		res.size = raw_encap_data->size;
 		memcpy(res.buf, raw_encap_data->data, res.size);
+		if (flow_dv_zero_encap_udp_csum(res.buf, error))
+			return -rte_errno;
 	} else {
 		if (action->type == RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP)
 			encap_data =
-- 
1.8.3.1


             reply	other threads:[~2019-07-04 11:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-04 11:16 Viacheslav Ovsiienko [this message]
2019-07-08 11:40 ` Raslan Darawsheh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1562238988-13138-1-git-send-email-viacheslavo@mellanox.com \
    --to=viacheslavo@mellanox.com \
    --cc=dev@dpdk.org \
    --cc=elibr@mellanox.com \
    --cc=rasland@mellanox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).