From patchwork Thu Oct 8 20:16:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ophir Munk X-Patchwork-Id: 80080 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 164C5A04BC; Thu, 8 Oct 2020 22:17:23 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AC05A1B755; Thu, 8 Oct 2020 22:17:20 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 202021B755 for ; Thu, 8 Oct 2020 22:17:19 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from ophirmu@nvidia.com) with SMTP; 8 Oct 2020 23:17:16 +0300 Received: from nvidia.com (pegasus05.mtr.labs.mlnx [10.210.16.100]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 098KHGi3002319; Thu, 8 Oct 2020 23:17:16 +0300 From: Ophir Munk To: dev@dpdk.org, Ferruh Yigit , Olivier Matz , Wenzhuo Lu , Jingjing Wu , Bernard Iremonger Cc: Ophir Munk Date: Thu, 8 Oct 2020 20:16:54 +0000 Message-Id: <20201008201656.19865-2-ophirmu@nvidia.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20201008201656.19865-1-ophirmu@nvidia.com> References: <20201007153055.28820-2-ophirmu@nvidia.com> <20201008201656.19865-1-ophirmu@nvidia.com> Subject: [dpdk-dev] [PATCH v7 1/3] app/testpmd: add GENEVE parsing 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: Ophir Munk GENEVE is a widely used tunneling protocol in modern Virtualized Networks. testpmd already supports parsing of several tunneling protocols including VXLAN, VXLAN-GPE, GRE. This commit adds GENEVE parsing of inner protocols (IPv4-0x0800, IPv6-0x86dd, Ethernet-0x6558) based on IETF draft-ietf-nvo3-geneve-09. GENEVE is considered more flexible than the other protocols. In terms of protocol format GENEVE header has a variable length options as opposed to other tunneling protocols which have a fixed header size. Signed-off-by: Ophir Munk --- app/test-pmd/csumonly.c | 70 ++++++++++++++++++++++++++++- app/test-pmd/testpmd.h | 1 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 6 +-- lib/librte_net/meson.build | 3 +- lib/librte_net/rte_geneve.h | 66 +++++++++++++++++++++++++++ 5 files changed, 141 insertions(+), 5 deletions(-) create mode 100644 lib/librte_net/rte_geneve.h diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 7ece398..a9f33c6 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -43,6 +43,7 @@ #include #include #include +#include #include "testpmd.h" @@ -63,6 +64,7 @@ #endif uint16_t vxlan_gpe_udp_port = 4790; +uint16_t geneve_udp_port = RTE_GENEVE_DEFAULT_PORT; /* structure that caches offload info for the current packet */ struct testpmd_offload_info { @@ -333,6 +335,64 @@ parse_vxlan_gpe(struct rte_udp_hdr *udp_hdr, info->l2_len += RTE_ETHER_VXLAN_GPE_HLEN; } +/* Fill in outer layers length */ +static void +update_tunnel_outer(struct testpmd_offload_info *info) +{ + info->is_tunnel = 1; + info->outer_ethertype = info->ethertype; + info->outer_l2_len = info->l2_len; + info->outer_l3_len = info->l3_len; + info->outer_l4_proto = info->l4_proto; +} + +/* Parse a geneve header */ +static void +parse_geneve(struct rte_udp_hdr *udp_hdr, + struct testpmd_offload_info *info) +{ + struct rte_ether_hdr *eth_hdr; + struct rte_ipv4_hdr *ipv4_hdr; + struct rte_ipv6_hdr *ipv6_hdr; + struct rte_geneve_hdr *geneve_hdr; + uint16_t geneve_len; + + /* Check udp destination port. */ + if (udp_hdr->dst_port != _htons(geneve_udp_port)) + return; + + geneve_hdr = (struct rte_geneve_hdr *)((char *)udp_hdr + + sizeof(struct rte_udp_hdr)); + geneve_len = sizeof(struct rte_geneve_hdr) + geneve_hdr->opt_len * 4; + if (!geneve_hdr->proto || geneve_hdr->proto == + _htons(RTE_ETHER_TYPE_IPV4)) { + update_tunnel_outer(info); + ipv4_hdr = (struct rte_ipv4_hdr *)((char *)geneve_hdr + + geneve_len); + parse_ipv4(ipv4_hdr, info); + info->ethertype = _htons(RTE_ETHER_TYPE_IPV4); + info->l2_len = 0; + } else if (geneve_hdr->proto == _htons(RTE_ETHER_TYPE_IPV6)) { + update_tunnel_outer(info); + ipv6_hdr = (struct rte_ipv6_hdr *)((char *)geneve_hdr + + geneve_len); + info->ethertype = _htons(RTE_ETHER_TYPE_IPV6); + parse_ipv6(ipv6_hdr, info); + info->l2_len = 0; + + } else if (geneve_hdr->proto == _htons(RTE_GENEVE_TYPE_ETH)) { + update_tunnel_outer(info); + eth_hdr = (struct rte_ether_hdr *)((char *)geneve_hdr + + geneve_len); + parse_ethernet(eth_hdr, info); + } else + return; + + info->l2_len += + (sizeof(struct rte_udp_hdr) + sizeof(struct rte_geneve_hdr) + + ((struct rte_geneve_hdr *)geneve_hdr)->opt_len * 4); +} + /* Parse a gre header */ static void parse_gre(struct simple_gre_hdr *gre_hdr, struct testpmd_offload_info *info) @@ -865,9 +925,17 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) } parse_vxlan(udp_hdr, &info, m->packet_type); - if (info.is_tunnel) + if (info.is_tunnel) { tx_ol_flags |= PKT_TX_TUNNEL_VXLAN; + goto tunnel_update; + } + parse_geneve(udp_hdr, &info); + if (info.is_tunnel) { + tx_ol_flags |= + PKT_TX_TUNNEL_GENEVE; + goto tunnel_update; + } } else if (info.l4_proto == IPPROTO_GRE) { struct simple_gre_hdr *gre_hdr; diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index c7e7e41..14aae7c 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -452,6 +452,7 @@ extern struct fwd_lcore **fwd_lcores; extern struct fwd_stream **fwd_streams; extern uint16_t vxlan_gpe_udp_port; /**< UDP port of tunnel VXLAN-GPE. */ +extern uint16_t geneve_udp_port; /**< UDP port of tunnel GENEVE. */ extern portid_t nb_peer_eth_addrs; /**< Number of peer ethernet addresses. */ extern struct rte_ether_addr peer_eth_addrs[RTE_MAX_ETHPORTS]; diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 72bdb1b..c448e2d 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -1135,11 +1135,11 @@ Where: * ``ip|udp|tcp|sctp`` always relate to the inner layer. * ``outer-ip`` relates to the outer IP layer (only for IPv4) in the case where the packet is recognized - as a tunnel packet by the forwarding engine (vxlan, gre and ipip are + as a tunnel packet by the forwarding engine (vxlan, gre, ipip and geneve are supported). See also the ``csum parse-tunnel`` command. * ``outer-udp`` relates to the outer UDP layer in the case where the packet is recognized - as a tunnel packet by the forwarding engine (vxlan, vxlan-gpe are + as a tunnel packet by the forwarding engine (vxlan, vxlan-gpe, geneve are supported). See also the ``csum parse-tunnel`` command. .. note:: @@ -1199,7 +1199,7 @@ engine:: testpmd> csum parse-tunnel (on|off) (tx_port_id) If enabled, the csum forward engine will try to recognize supported -tunnel headers (vxlan, gre, ipip). +tunnel headers (vxlan, gre, ipip, geneve). If disabled, treat tunnel packets as non-tunneled packets (a inner header is handled as a packet payload). diff --git a/lib/librte_net/meson.build b/lib/librte_net/meson.build index 24ed825..52d3a97 100644 --- a/lib/librte_net/meson.build +++ b/lib/librte_net/meson.build @@ -16,7 +16,8 @@ headers = files('rte_ip.h', 'rte_net_crc.h', 'rte_mpls.h', 'rte_higig.h', - 'rte_ecpri.h') + 'rte_ecpri.h', + 'rte_geneve.h') sources = files('rte_arp.c', 'rte_ether.c', 'rte_net.c', 'rte_net_crc.c') deps += ['mbuf'] diff --git a/lib/librte_net/rte_geneve.h b/lib/librte_net/rte_geneve.h new file mode 100644 index 0000000..bb67724 --- /dev/null +++ b/lib/librte_net/rte_geneve.h @@ -0,0 +1,66 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2020 Mellanox Technologies, Ltd + */ + +#ifndef _RTE_GENEVE_H_ +#define _RTE_GENEVE_H_ + +/** + * @file + * + * GENEVE-related definitions + */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** GENEVE default port. */ +#define RTE_GENEVE_DEFAULT_PORT 6081 + +/** + * GENEVE protocol header. (draft-ietf-nvo3-geneve-09) + * Contains: + * 2-bits version (must be 0). + * 6-bits option length in four byte multiples, not including the eight + * bytes of the fixed tunnel header. + * 1-bit control packet. + * 1-bit critical options in packet. + * 6-bits reserved + * 16-bits Protocol Type. The protocol data unit after the Geneve header + * following the EtherType convention. Ethernet itself is represented by + * the value 0x6558. + * 24-bits Virtual Network Identifier (VNI). Virtual network unique identified. + * 8-bits reserved bits (must be 0 on transmission and ignored on receipt). + * More-bits (optional) variable length options. + */ +__extension__ +struct rte_geneve_hdr { +#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN + uint8_t ver:2; /**< Version. */ + uint8_t opt_len:6; /**< Options length. */ + uint8_t oam:1; /**< Control packet. */ + uint8_t critical:1; /**< Critical packet. */ + uint8_t reserved1:6; /**< Reserved. */ +#else + uint8_t opt_len:6; /**< Options length. */ + uint8_t ver:2; /**< Version. */ + uint8_t reserved1:6; /**< Reserved. */ + uint8_t critical:1; /**< Critical packet. */ + uint8_t oam:1; /**< Control packet. */ +#endif + rte_be16_t proto; /**< Protocol type. */ + uint8_t vni[3]; /**< Virtual network identifier. */ + uint8_t reserved2; /**< Reserved. */ + uint32_t opts[]; /**< Variable length options. */ +} __rte_packed; + +/* GENEVE ETH next protocol types */ +#define RTE_GENEVE_TYPE_ETH 0x6558 /**< Ethernet Protocol. */ + +#ifdef __cplusplus +} +#endif + +#endif /* RTE_GENEVE_H_ */ From patchwork Thu Oct 8 20:16:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ophir Munk X-Patchwork-Id: 80083 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id ECC92A04BC; Thu, 8 Oct 2020 22:18:18 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2AF761BA68; Thu, 8 Oct 2020 22:17:26 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 0BF8C1B733 for ; Thu, 8 Oct 2020 22:17:18 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from ophirmu@nvidia.com) with SMTP; 8 Oct 2020 23:17:16 +0300 Received: from nvidia.com (pegasus05.mtr.labs.mlnx [10.210.16.100]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 098KHGi4002319; Thu, 8 Oct 2020 23:17:16 +0300 From: Ophir Munk To: dev@dpdk.org, Ferruh Yigit , Olivier Matz , Wenzhuo Lu , Jingjing Wu , Bernard Iremonger Cc: Ophir Munk Date: Thu, 8 Oct 2020 20:16:55 +0000 Message-Id: <20201008201656.19865-3-ophirmu@nvidia.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20201008201656.19865-1-ophirmu@nvidia.com> References: <20201007153055.28820-2-ophirmu@nvidia.com> <20201008201656.19865-1-ophirmu@nvidia.com> Subject: [dpdk-dev] [PATCH v7 2/3] app/testpmd: enable configuring GENEVE port 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: Ophir Munk IANA has assigned port 6081 as the fixed well-known destination port for GENEVE. Nevertheless draft-ietf-nvo3-geneve-09 recommends that implementations make this configurable. This commit enables specifying any positive UDP destination port number for GENEVE protocol parsing. Signed-off-by: Ophir Munk --- app/test-pmd/parameters.c | 15 +++++++++++++-- doc/guides/testpmd_app_ug/run_app.rst | 6 ++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index 1ead595..15ce8c1 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -70,8 +70,8 @@ usage(char* progname) "--rxpt= | --rxht= | --rxwt= |" " --rxfreet= | --txpt= | --txht= | --txwt= | --txfreet= | " "--txrst= | --tx-offloads= | | --rx-offloads= | " - "--vxlan-gpe-port= | --record-core-cycles | " - "--record-burst-stats]\n", + "--vxlan-gpe-port= | --geneve-parsed-port= | " + "--record-core-cycles | --record-burst-stats]\n", progname); #ifdef RTE_LIBRTE_CMDLINE printf(" --interactive: run in interactive mode.\n"); @@ -202,6 +202,7 @@ usage(char* progname) printf(" --rx-offloads=0xXXXXXXXX: hexadecimal bitmask of RX queue offloads\n"); printf(" --hot-plug: enable hot plug for device.\n"); printf(" --vxlan-gpe-port=N: UPD port of tunnel VXLAN-GPE\n"); + printf(" --geneve-parsed-port=N: UPD port to parse GENEVE tunnel protocol\n"); printf(" --mlockall: lock all memory\n"); printf(" --no-mlockall: do not lock all memory\n"); printf(" --mp-alloc : mempool allocation method.\n" @@ -671,6 +672,7 @@ launch_args_parse(int argc, char** argv) { "rx-offloads", 1, 0, 0 }, { "hot-plug", 0, 0, 0 }, { "vxlan-gpe-port", 1, 0, 0 }, + { "geneve-parsed-port", 1, 0, 0 }, { "mlockall", 0, 0, 0 }, { "no-mlockall", 0, 0, 0 }, { "mp-alloc", 1, 0, 0 }, @@ -1311,6 +1313,15 @@ launch_args_parse(int argc, char** argv) rte_exit(EXIT_FAILURE, "vxlan-gpe-port must be >= 0\n"); } + if (!strcmp(lgopts[opt_idx].name, + "geneve-parsed-port")) { + n = atoi(optarg); + if (n >= 0) + geneve_udp_port = (uint16_t)n; + else + rte_exit(EXIT_FAILURE, + "geneve-parsed-port must be >= 0\n"); + } if (!strcmp(lgopts[opt_idx].name, "print-event")) if (parse_event_printing_config(optarg, 1)) { rte_exit(EXIT_FAILURE, diff --git a/doc/guides/testpmd_app_ug/run_app.rst b/doc/guides/testpmd_app_ug/run_app.rst index e2539f6..ec085c2 100644 --- a/doc/guides/testpmd_app_ug/run_app.rst +++ b/doc/guides/testpmd_app_ug/run_app.rst @@ -426,6 +426,12 @@ The command line options are: Set the UDP port number of tunnel VXLAN-GPE to N. The default value is 4790. +* ``--geneve-parsed-port=N`` + + Set the UDP port number that is used for parsing the GENEVE protocol to N. + HW may be configured with another tunnel Geneve port. + The default value is 6081. + * ``--mlockall`` Enable locking all memory. From patchwork Thu Oct 8 20:16:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ophir Munk X-Patchwork-Id: 80082 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id A0CDFA04BC; Thu, 8 Oct 2020 22:17:58 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1D8B31B875; Thu, 8 Oct 2020 22:17:24 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 265491B774 for ; Thu, 8 Oct 2020 22:17:19 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from ophirmu@nvidia.com) with SMTP; 8 Oct 2020 23:17:16 +0300 Received: from nvidia.com (pegasus05.mtr.labs.mlnx [10.210.16.100]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 098KHGi5002319; Thu, 8 Oct 2020 23:17:16 +0300 From: Ophir Munk To: dev@dpdk.org, Ferruh Yigit , Olivier Matz , Wenzhuo Lu , Jingjing Wu , Bernard Iremonger Cc: Ophir Munk Date: Thu, 8 Oct 2020 20:16:56 +0000 Message-Id: <20201008201656.19865-4-ophirmu@nvidia.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20201008201656.19865-1-ophirmu@nvidia.com> References: <20201007153055.28820-2-ophirmu@nvidia.com> <20201008201656.19865-1-ophirmu@nvidia.com> Subject: [dpdk-dev] [PATCH v7 3/3] app/testpmd: tunnel parsing protocols cleanup 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: Ophir Munk This is a cleanup commit. It assembles all tunnel outer updates into one function call to avoid code duplications. It defines RTE_VXLAN_GPE_DEFAULT_PORT (4790) in accordance with all other tunnel protocol definitions. It replaces all numeric values 4789 in their corresponding definition RTE_VXLAN_GPE_DEFAULT_PORT. It updates the 'csum parse-tunnel' documentation. Signed-off-by: Ophir Munk --- app/test-pmd/cmdline_flow.c | 3 +- app/test-pmd/csumonly.c | 81 +++++++++-------------------- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 6 +-- lib/librte_net/rte_vxlan.h | 1 + 4 files changed, 31 insertions(+), 60 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 6e04d53..761ac5a 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "testpmd.h" @@ -421,7 +422,7 @@ struct vxlan_encap_conf vxlan_encap_conf = { .select_tos_ttl = 0, .vni = "\x00\x00\x00", .udp_src = 0, - .udp_dst = RTE_BE16(4789), + .udp_dst = RTE_BE16(RTE_VXLAN_DEFAULT_PORT), .ipv4_src = RTE_IPV4(127, 0, 0, 1), .ipv4_dst = RTE_IPV4(255, 255, 255, 255), .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00" diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index a9f33c6..8f2f840 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -63,7 +63,7 @@ #define _htons(x) (x) #endif -uint16_t vxlan_gpe_udp_port = 4790; +uint16_t vxlan_gpe_udp_port = RTE_VXLAN_GPE_DEFAULT_PORT; uint16_t geneve_udp_port = RTE_GENEVE_DEFAULT_PORT; /* structure that caches offload info for the current packet */ @@ -181,6 +181,17 @@ parse_ethernet(struct rte_ether_hdr *eth_hdr, struct testpmd_offload_info *info) } } +/* Fill in outer layers length */ +static void +update_tunnel_outer(struct testpmd_offload_info *info) +{ + info->is_tunnel = 1; + info->outer_ethertype = info->ethertype; + info->outer_l2_len = info->l2_len; + info->outer_l3_len = info->l3_len; + info->outer_l4_proto = info->l4_proto; +} + /* * Parse a GTP protocol header. * No optional fields and next extension header type. @@ -201,11 +212,7 @@ parse_gtp(struct rte_udp_hdr *udp_hdr, udp_hdr->dst_port != _htons(RTE_GTPU_UDP_PORT)) return; - info->is_tunnel = 1; - info->outer_ethertype = info->ethertype; - info->outer_l2_len = info->l2_len; - info->outer_l3_len = info->l3_len; - info->outer_l4_proto = info->l4_proto; + update_tunnel_outer(info); info->l2_len = 0; gtp_hdr = (struct rte_gtp_hdr *)((char *)udp_hdr + @@ -250,18 +257,15 @@ parse_vxlan(struct rte_udp_hdr *udp_hdr, { struct rte_ether_hdr *eth_hdr; - /* check udp destination port, 4789 is the default vxlan port - * (rfc7348) or that the rx offload flag is set (i40e only - * currently) */ - if (udp_hdr->dst_port != _htons(4789) && + /* check udp destination port, RTE_VXLAN_DEFAULT_PORT (4789) is the + * default vxlan port (rfc7348) or that the rx offload flag is set + * (i40e only currently) + */ + if (udp_hdr->dst_port != _htons(RTE_VXLAN_DEFAULT_PORT) && RTE_ETH_IS_TUNNEL_PKT(pkt_type) == 0) return; - info->is_tunnel = 1; - info->outer_ethertype = info->ethertype; - info->outer_l2_len = info->l2_len; - info->outer_l3_len = info->l3_len; - info->outer_l4_proto = info->l4_proto; + update_tunnel_outer(info); eth_hdr = (struct rte_ether_hdr *)((char *)udp_hdr + sizeof(struct rte_udp_hdr) + @@ -291,11 +295,7 @@ parse_vxlan_gpe(struct rte_udp_hdr *udp_hdr, if (!vxlan_gpe_hdr->proto || vxlan_gpe_hdr->proto == RTE_VXLAN_GPE_TYPE_IPV4) { - info->is_tunnel = 1; - info->outer_ethertype = info->ethertype; - info->outer_l2_len = info->l2_len; - info->outer_l3_len = info->l3_len; - info->outer_l4_proto = info->l4_proto; + update_tunnel_outer(info); ipv4_hdr = (struct rte_ipv4_hdr *)((char *)vxlan_gpe_hdr + vxlan_gpe_len); @@ -305,11 +305,7 @@ parse_vxlan_gpe(struct rte_udp_hdr *udp_hdr, info->l2_len = 0; } else if (vxlan_gpe_hdr->proto == RTE_VXLAN_GPE_TYPE_IPV6) { - info->is_tunnel = 1; - info->outer_ethertype = info->ethertype; - info->outer_l2_len = info->l2_len; - info->outer_l3_len = info->l3_len; - info->outer_l4_proto = info->l4_proto; + update_tunnel_outer(info); ipv6_hdr = (struct rte_ipv6_hdr *)((char *)vxlan_gpe_hdr + vxlan_gpe_len); @@ -319,11 +315,7 @@ parse_vxlan_gpe(struct rte_udp_hdr *udp_hdr, info->l2_len = 0; } else if (vxlan_gpe_hdr->proto == RTE_VXLAN_GPE_TYPE_ETH) { - info->is_tunnel = 1; - info->outer_ethertype = info->ethertype; - info->outer_l2_len = info->l2_len; - info->outer_l3_len = info->l3_len; - info->outer_l4_proto = info->l4_proto; + update_tunnel_outer(info); eth_hdr = (struct rte_ether_hdr *)((char *)vxlan_gpe_hdr + vxlan_gpe_len); @@ -335,17 +327,6 @@ parse_vxlan_gpe(struct rte_udp_hdr *udp_hdr, info->l2_len += RTE_ETHER_VXLAN_GPE_HLEN; } -/* Fill in outer layers length */ -static void -update_tunnel_outer(struct testpmd_offload_info *info) -{ - info->is_tunnel = 1; - info->outer_ethertype = info->ethertype; - info->outer_l2_len = info->l2_len; - info->outer_l3_len = info->l3_len; - info->outer_l4_proto = info->l4_proto; -} - /* Parse a geneve header */ static void parse_geneve(struct rte_udp_hdr *udp_hdr, @@ -412,11 +393,7 @@ parse_gre(struct simple_gre_hdr *gre_hdr, struct testpmd_offload_info *info) gre_len += GRE_EXT_LEN; if (gre_hdr->proto == _htons(RTE_ETHER_TYPE_IPV4)) { - info->is_tunnel = 1; - info->outer_ethertype = info->ethertype; - info->outer_l2_len = info->l2_len; - info->outer_l3_len = info->l3_len; - info->outer_l4_proto = info->l4_proto; + update_tunnel_outer(info); ipv4_hdr = (struct rte_ipv4_hdr *)((char *)gre_hdr + gre_len); @@ -425,11 +402,7 @@ parse_gre(struct simple_gre_hdr *gre_hdr, struct testpmd_offload_info *info) info->l2_len = 0; } else if (gre_hdr->proto == _htons(RTE_ETHER_TYPE_IPV6)) { - info->is_tunnel = 1; - info->outer_ethertype = info->ethertype; - info->outer_l2_len = info->l2_len; - info->outer_l3_len = info->l3_len; - info->outer_l4_proto = info->l4_proto; + update_tunnel_outer(info); ipv6_hdr = (struct rte_ipv6_hdr *)((char *)gre_hdr + gre_len); @@ -438,11 +411,7 @@ parse_gre(struct simple_gre_hdr *gre_hdr, struct testpmd_offload_info *info) info->l2_len = 0; } else if (gre_hdr->proto == _htons(RTE_ETHER_TYPE_TEB)) { - info->is_tunnel = 1; - info->outer_ethertype = info->ethertype; - info->outer_l2_len = info->l2_len; - info->outer_l3_len = info->l3_len; - info->outer_l4_proto = info->l4_proto; + update_tunnel_outer(info); eth_hdr = (struct rte_ether_hdr *)((char *)gre_hdr + gre_len); diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index c448e2d..5cd2079 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -1135,11 +1135,11 @@ Where: * ``ip|udp|tcp|sctp`` always relate to the inner layer. * ``outer-ip`` relates to the outer IP layer (only for IPv4) in the case where the packet is recognized - as a tunnel packet by the forwarding engine (vxlan, gre, ipip and geneve are + as a tunnel packet by the forwarding engine (geneve, gre, gtp, ipip, vxlan and vxlan-gpe are supported). See also the ``csum parse-tunnel`` command. * ``outer-udp`` relates to the outer UDP layer in the case where the packet is recognized - as a tunnel packet by the forwarding engine (vxlan, vxlan-gpe, geneve are + as a tunnel packet by the forwarding engine (geneve, gtp, vxlan and vxlan-gpe are supported). See also the ``csum parse-tunnel`` command. .. note:: @@ -1199,7 +1199,7 @@ engine:: testpmd> csum parse-tunnel (on|off) (tx_port_id) If enabled, the csum forward engine will try to recognize supported -tunnel headers (vxlan, gre, ipip, geneve). +tunnel headers (geneve, gtp, gre, ipip, vxlan, vxlan-gpe). If disabled, treat tunnel packets as non-tunneled packets (a inner header is handled as a packet payload). diff --git a/lib/librte_net/rte_vxlan.h b/lib/librte_net/rte_vxlan.h index c23c10c..2ad6061 100644 --- a/lib/librte_net/rte_vxlan.h +++ b/lib/librte_net/rte_vxlan.h @@ -22,6 +22,7 @@ extern "C" { /** VXLAN default port. */ #define RTE_VXLAN_DEFAULT_PORT 4789 +#define RTE_VXLAN_GPE_DEFAULT_PORT 4790 /** * VXLAN protocol header.