From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id E5253A0487 for ; Thu, 4 Jul 2019 11:24:36 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 794421B99F; Thu, 4 Jul 2019 11:24:35 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id CCAAD1B997 for ; Thu, 4 Jul 2019 11:24:33 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE2 (envelope-from viacheslavo@mellanox.com) with ESMTPS (AES256-SHA encrypted); 4 Jul 2019 12:24:32 +0300 Received: from pegasus12.mtr.labs.mlnx. (pegasus12.mtr.labs.mlnx [10.210.17.40]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x649OWVi006286; Thu, 4 Jul 2019 12:24:32 +0300 From: Viacheslav Ovsiienko To: dev@dpdk.org Cc: rasland@mellanox.com, Eli Britstein Date: Thu, 4 Jul 2019 09:24:29 +0000 Message-Id: <1562232269-619-1-git-send-email-viacheslavo@mellanox.com> X-Mailer: git-send-email 1.8.3.1 Subject: [dpdk-dev] [PATCH] net/mlx5: zero out UDP csum for IPv6 encap headers X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Eli Britstein 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 Acked-by: Viacheslav Ovsiienko --- 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..14e0707 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 ether_hdr *eth = NULL; + struct vlan_hdr *vlan = NULL; + struct ipv6_hdr *ipv6 = NULL; + struct udp_hdr *udp = NULL; + char *next_hdr; + uint16_t proto; + + eth = (struct ether_hdr *)data; + next_hdr = (char *)(eth + 1); + proto = RTE_BE16(eth->ether_type); + + /* VLAN skipping */ + while (proto == ETHER_TYPE_VLAN || proto == ETHER_TYPE_QINQ) { + next_hdr += sizeof(struct vlan_hdr); + vlan = (struct vlan_hdr *)next_hdr; + proto = RTE_BE16(vlan->eth_proto); + } + + /* HW calculates IPv4 csum. no need to proceed */ + if (proto == ETHER_TYPE_IPv4) + return 0; + + /* non IPv4/IPv6 header. not supported */ + if (proto != ETHER_TYPE_IPv6) { + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ACTION, + NULL, "Cannot offload non IPv4/IPv6"); + } + + ipv6 = (struct ipv6_hdr *)next_hdr; + + /* ignore non UDP */ + if (ipv6->proto != IPPROTO_UDP) + return 0; + + udp = (struct 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