Skip to contentSkip to conversation

Add GENEVE protocol parsing to testpmd

PATCH New Ophir Munk 4 participants 50 messages Jul 29, 2020 – Oct 9, 2020 Arm/Amlogic Meson SoC support

lore
Share & tools
lore

Ophir Munk

author
#0 lore raw

cover Add GENEVE protocol parsing to testpmd

This patchset adds GENEVE parsing of inner protocols (IPv4-0x0800, IPv6-0x86dd, Ethernet-0x6558) based on IETF draft-ietf-nvo3-geneve-09.

v1:
Initial version

Ophir Munk (3):
app/testpmd: add GENEVE parsing app/testpmd: enable configuring GENEVE port app/testpmd: reduce tunnel parsing code duplication

 app/test-pmd/csumonly.c     | 120 ++++++++++++++++++++++++++++----------------
 app/test-pmd/parameters.c   |  13 ++++-
 app/test-pmd/testpmd.h      |   1 +
 lib/librte_net/Makefile     |   2 +-
 lib/librte_net/meson.build  |   3 +-
 lib/librte_net/rte_geneve.h |  72 ++++++++++++++++++++++++++
 lib/librte_net/rte_vxlan.h  |   1 +
 7 files changed, 167 insertions(+), 45 deletions(-)
 create mode 100644 lib/librte_net/rte_geneve.h
Signature · 1 line
2.8.4
author
#1 lore raw

PATCH 1/3 app/testpmd: add GENEVE parsing

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.

---
 app/test-pmd/csumonly.c     | 70 ++++++++++++++++++++++++++++++++++++++++++-
 app/test-pmd/testpmd.h      |  1 +
 lib/librte_net/Makefile     |  2 +-
 lib/librte_net/meson.build  |  3 +-
 lib/librte_net/rte_geneve.h | 72 +++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 145 insertions(+), 3 deletions(-)
 create mode 100644 lib/librte_net/rte_geneve.h
app/test-pmd/csumonly.c +69 -1
index 0a96b24..5f29868 100644
@@ -43,6 +43,7 @@
 #include <rte_flow.h>
 #include <rte_gro.h>
 #include <rte_gso.h>
+#include <rte_geneve.h>
 
 #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_GENEVE_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_GENEVE_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)
@@ -873,9 +933,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;
 
app/test-pmd/testpmd.h +1 -0
index 25a12b1..a60e009 100644
@@ -456,6 +456,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];
lib/librte_net/Makefile +1 -1
index 9830e77..9fe99af 100644
@@ -20,6 +20,6 @@ SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_sctp.h rte_icmp.h rte_arp.h
 SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_ether.h rte_gre.h rte_net.h
 SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_net_crc.h rte_mpls.h rte_higig.h
 SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_gtp.h rte_vxlan.h
-SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_ecpri.h
+SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_ecpri.h rte_geneve.h
 
 include $(RTE_SDK)/mk/rte.lib.mk
lib/librte_net/meson.build +2 -1
index 24ed825..52d3a97 100644
@@ -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']
lib/librte_net/rte_geneve.h new file +72 -0

72 lines not on this page · raw message

Signature · 1 line
2.8.4
author
#2 lore raw

PATCH 2/3 app/testpmd: enable configuring GENEVE port

In reply to 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.

---
 app/test-pmd/parameters.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
app/test-pmd/parameters.c +12 -1
index 7cb0e3d..0d135b0 100644
@@ -70,7 +70,8 @@ usage(char* progname)
 	       "--rxpt= | --rxht= | --rxwt= | --rxfreet= | "
 	       "--txpt= | --txht= | --txwt= | --txfreet= | "
 	       "--txrst= | --tx-offloads= | | --rx-offloads= | "
-	       "--vxlan-gpe-port= ]\n",
+	       "--vxlan-gpe-port= ] "
+	       "--geneve-port= ]\n",
 	       progname);
 #ifdef RTE_LIBRTE_CMDLINE
 	printf("  --interactive: run in interactive mode.\n");
@@ -199,6 +200,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-port=N: UPD port of tunnel GENEVE\n");
 	printf("  --mlockall: lock all memory\n");
 	printf("  --no-mlockall: do not lock all memory\n");
 	printf("  --mp-alloc <native|anon|xmem|xmemhuge>: mempool allocation method.\n"
@@ -664,6 +666,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-port",		1, 0, 0 },
 		{ "mlockall",			0, 0, 0 },
 		{ "no-mlockall",		0, 0, 0 },
 		{ "mp-alloc",			1, 0, 0 },
@@ -1298,6 +1301,14 @@ 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-port")) {
+				n = atoi(optarg);
+				if (n >= 0)
+					geneve_udp_port = (uint16_t)n;
+				else
+					rte_exit(EXIT_FAILURE,
+						 "geneve-port must be >= 0\n");
+			}
 			if (!strcmp(lgopts[opt_idx].name, "print-event"))
 				if (parse_event_printing_config(optarg, 1)) {
 					rte_exit(EXIT_FAILURE,
Signature · 1 line
2.8.4
author
#3 lore raw

PATCH 3/3 app/testpmd: reduce tunnel parsing code duplication

In reply to 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.

---
 app/test-pmd/csumonly.c    | 72 +++++++++++++---------------------------------
 lib/librte_net/rte_vxlan.h |  1 +
 2 files changed, 21 insertions(+), 52 deletions(-)
app/test-pmd/csumonly.c +20 -52
index 5f29868..3a0e46e 100644
@@ -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 +
@@ -257,11 +264,7 @@ parse_vxlan(struct rte_udp_hdr *udp_hdr,
 		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 +294,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 +304,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 +314,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 +326,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 +392,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 +401,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 +410,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);
 
lib/librte_net/rte_vxlan.h +1 -0
index c23c10c..2ad6061 100644
@@ -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.
Signature · 1 line
2.8.4
#4 lore raw

v2 cover Add GENEVE protocol parsing to testpmd

This patchset adds GENEVE parsing of inner protocols (IPv4-0x0800, IPv6-0x86dd, Ethernet-0x6558) based on IETF draft-ietf-nvo3-geneve-09.

v1:
Initial version
v2:
Rebased + Minor update in protocol options field:
char opts[0] ===> uint8_t opts[]

Ophir Munk (3):
app/testpmd: add GENEVE parsing app/testpmd: enable configuring GENEVE port app/testpmd: reduce tunnel parsing code duplication

 app/test-pmd/csumonly.c     | 120 ++++++++++++++++++++++++++++----------------
 app/test-pmd/parameters.c   |  13 ++++-
 app/test-pmd/testpmd.h      |   1 +
 lib/librte_net/Makefile     |   2 +-
 lib/librte_net/meson.build  |   3 +-
 lib/librte_net/rte_geneve.h |  72 ++++++++++++++++++++++++++
 lib/librte_net/rte_vxlan.h  |   1 +
 7 files changed, 167 insertions(+), 45 deletions(-)
 create mode 100644 lib/librte_net/rte_geneve.h
Signature · 1 line
2.8.4
#5 lore raw

PATCH v2 1/3 app/testpmd: add GENEVE parsing

From: Ophir Munk <[email protected]>

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.

---
 app/test-pmd/csumonly.c     | 70 ++++++++++++++++++++++++++++++++++++++++++-
 app/test-pmd/testpmd.h      |  1 +
 lib/librte_net/Makefile     |  2 +-
 lib/librte_net/meson.build  |  3 +-
 lib/librte_net/rte_geneve.h | 72 +++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 145 insertions(+), 3 deletions(-)
 create mode 100644 lib/librte_net/rte_geneve.h
app/test-pmd/csumonly.c +69 -1
index 0a96b24..5f29868 100644
@@ -43,6 +43,7 @@
 #include <rte_flow.h>
 #include <rte_gro.h>
 #include <rte_gso.h>
+#include <rte_geneve.h>
 
 #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_GENEVE_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_GENEVE_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)
@@ -873,9 +933,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;
 
app/test-pmd/testpmd.h +1 -0
index 25a12b1..a60e009 100644
@@ -456,6 +456,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];
lib/librte_net/Makefile +1 -1
index 9830e77..9fe99af 100644
@@ -20,6 +20,6 @@ SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_sctp.h rte_icmp.h rte_arp.h
 SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_ether.h rte_gre.h rte_net.h
 SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_net_crc.h rte_mpls.h rte_higig.h
 SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_gtp.h rte_vxlan.h
-SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_ecpri.h
+SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_ecpri.h rte_geneve.h
 
 include $(RTE_SDK)/mk/rte.lib.mk
lib/librte_net/meson.build +2 -1
index 24ed825..52d3a97 100644
@@ -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']
lib/librte_net/rte_geneve.h new file +72 -0

72 lines not on this page · raw message

Signature · 1 line
2.8.4
#6 lore raw

Re: [dpdk-dev] [PATCH v2 1/3] app/testpmd: add GENEVE parsing

Quoted 11 lines · Ophir Munk

From: Ophir Munk <[email protected]>

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.

Quoted 7 lines
---
 app/test-pmd/csumonly.c     | 70 ++++++++++++++++++++++++++++++++++++++++++-
 app/test-pmd/testpmd.h      |  1 +
 lib/librte_net/Makefile     |  2 +-
 lib/librte_net/meson.build  |  3 +-
 lib/librte_net/rte_geneve.h | 72 +++++++++++++++++++++++++++++++++++++++++++++

cc'ed Oliver for the 'rte_geneve.h' part.

#7 lore raw

v3 cover Add GENEVE protocol parsing to testpmd

In reply to Ophir Munk

v1:
Initial version
v2:
Rebased + Minor update in protocol options field:
char opts[0] ===> uint8_t opts[]
v3:
Rebase
document "geneve-port=N" parameter

Ophir Munk (3):
app/testpmd: add GENEVE parsing app/testpmd: enable configuring GENEVE port app/testpmd: reduce tunnel parsing code duplication

 app/test-pmd/csumonly.c               | 120 ++++++++++++++++++++++------------
 app/test-pmd/parameters.c             |  14 +++-
 app/test-pmd/testpmd.h                |   1 +
 doc/guides/testpmd_app_ug/run_app.rst |   5 ++
 lib/librte_net/meson.build            |   3 +-
 lib/librte_net/rte_geneve.h           |  72 ++++++++++++++++++++
 lib/librte_net/rte_vxlan.h            |   1 +
 7 files changed, 171 insertions(+), 45 deletions(-)
 create mode 100644 lib/librte_net/rte_geneve.h
Signature · 1 line
2.8.4
#8 lore raw

PATCH v3 1/3 app/testpmd: add GENEVE parsing

From: Ophir Munk <[email protected]>

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.

---
 app/test-pmd/csumonly.c     | 70 ++++++++++++++++++++++++++++++++++++++++++-
 app/test-pmd/testpmd.h      |  1 +
 lib/librte_net/meson.build  |  3 +-
 lib/librte_net/rte_geneve.h | 72 +++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 144 insertions(+), 2 deletions(-)
 create mode 100644 lib/librte_net/rte_geneve.h
app/test-pmd/csumonly.c +69 -1
index 7ece398..eb87b9b 100644
@@ -43,6 +43,7 @@
 #include <rte_flow.h>
 #include <rte_gro.h>
 #include <rte_gso.h>
+#include <rte_geneve.h>
 
 #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_GENEVE_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_GENEVE_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;
 
app/test-pmd/testpmd.h +1 -0
index a8ae5cc..f405d4e 100644
@@ -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];
lib/librte_net/meson.build +2 -1
index 24ed825..52d3a97 100644
@@ -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']
lib/librte_net/rte_geneve.h new file +72 -0

72 lines not on this page · raw message

Signature · 1 line
2.8.4
#9 lore raw

v4 cover Add GENEVE protocol parsing to testpmd

v1:
Initial version
v2:
Rebased + Minor update in protocol options field:
char opts[0] ===> uint8_t opts[]
v3:
Rebase
document "geneve-port=N" parameter
v4:
Mispelling corrections

Ophir Munk (3):
app/testpmd: add GENEVE parsing app/testpmd: enable configuring GENEVE port app/testpmd: reduce tunnel parsing code duplication

 app/test-pmd/csumonly.c               | 120 ++++++++++++++++++++++------------
 app/test-pmd/parameters.c             |  14 +++-
 app/test-pmd/testpmd.h                |   1 +
 doc/guides/testpmd_app_ug/run_app.rst |   5 ++
 lib/librte_net/meson.build            |   3 +-
 lib/librte_net/rte_geneve.h           |  72 ++++++++++++++++++++
 lib/librte_net/rte_vxlan.h            |   1 +
 7 files changed, 171 insertions(+), 45 deletions(-)
 create mode 100644 lib/librte_net/rte_geneve.h
Signature · 1 line
2.8.4
#10 lore raw

PATCH v4 1/3 app/testpmd: add GENEVE parsing

From: Ophir Munk <[email protected]>

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.

---
 app/test-pmd/csumonly.c     | 70 ++++++++++++++++++++++++++++++++++++++++++-
 app/test-pmd/testpmd.h      |  1 +
 lib/librte_net/meson.build  |  3 +-
 lib/librte_net/rte_geneve.h | 72 +++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 144 insertions(+), 2 deletions(-)
 create mode 100644 lib/librte_net/rte_geneve.h
app/test-pmd/csumonly.c +69 -1
index 7ece398..eb87b9b 100644
@@ -43,6 +43,7 @@
 #include <rte_flow.h>
 #include <rte_gro.h>
 #include <rte_gso.h>
+#include <rte_geneve.h>
 
 #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_GENEVE_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_GENEVE_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;
 
app/test-pmd/testpmd.h +1 -0
index a8ae5cc..f405d4e 100644
@@ -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];
lib/librte_net/meson.build +2 -1
index 24ed825..52d3a97 100644
@@ -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']
lib/librte_net/rte_geneve.h new file +72 -0

72 lines not on this page · raw message

Signature · 1 line
2.8.4
#11 lore raw

Re: [dpdk-dev] [PATCH v4 1/3] app/testpmd: add GENEVE parsing

Adding Olivier who is the maintainer of the Network headers (lib/librte_net/rte_geneve.h).

Quoted 241 lines

-----Original Message-----
From: Ophir Munk <[email protected]>
Sent: Tuesday, September 15, 2020 4:17 PM
To: [email protected]; Wenzhuo Lu <[email protected]>; Beilei Xing <[email protected]>; Bernard Iremonger <[email protected]>; Ferruh Yigit <[email protected]>
Cc: Ophir Munk <[email protected]>; Ophir Munk <[email protected]>
Subject: [PATCH v4 1/3] app/testpmd: add GENEVE parsing

From: Ophir Munk <[email protected]>

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.

---
 app/test-pmd/csumonly.c     | 70
++++++++++++++++++++++++++++++++++++++++++-
 app/test-pmd/testpmd.h      |  1 +
 lib/librte_net/meson.build  |  3 +-
 lib/librte_net/rte_geneve.h | 72
+++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 144 insertions(+), 2 deletions(-)  create mode 100644

lib/librte_net/rte_geneve.h

app/test-pmd/csumonly.c index renamed from app/test-pmd/csumonly.c +0 -0

7ece398..eb87b9b 100644

app/test-pmd/csumonly.c +2 -0
@@ -43,6 +43,7 @@
 #include <rte_flow.h>
 #include <rte_gro.h>
 #include <rte_gso.h>
+#include <rte_geneve.h>
 
 #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,

app/test-pmd/csumonly.c +26 -0
 	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;

app/test-pmd/csumonly.c +28 -0
+	if (!geneve_hdr->proto || geneve_hdr->proto ==
+	    _htons(RTE_GENEVE_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_GENEVE_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)

app/test-pmd/csumonly.c +9 -1
 				}
 				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;
app/test-pmd/testpmd.h index renamed from app/test-pmd/testpmd.h +0 -0

a8ae5cc..f405d4e 100644

app/test-pmd/testpmd.h +1 -0
@@ -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/lib/librte_net/meson.build b/lib/librte_net/meson.build index 24ed825..52d3a97 100644

lib/librte_net/meson.build +2 -1
@@ -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..d50f5b3

lib/librte_net/rte_geneve.h new file +63 -0
@@ -0,0 +1,72 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2020 Mellanox Technologies, Ltd  */
+
+#ifndef _RTE_GENEVE_H_
+#define _RTE_GENEVE_H_
+
+/**
+ * @file
+ *
+ * GENEVE-related definitions
+ */
+
+#include <stdint.h>
+
+#include <rte_udp.h>
+
+
+#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 (2).  */
+	uint8_t opt_len:6;	/**< Options length (6). */
+	uint8_t oam:1;		/**< Control packet (1). */
+	uint8_t critical:1;	/**< Critical packet (1). */
+	uint8_t rsvd1:6;	/**< Reserved (6). */
+#else
+	uint8_t opt_len:6;	/**< Options length (6). */
+	uint8_t ver:2;		/**< Version (2).  */
+	uint8_t rsvd1:6;	/**< Reserved (6). */
+	uint8_t critical:1;	/**< Critical packet (1). */
+	uint8_t oam:1;		/**< Control packet (1). */
+#endif
+	rte_be16_t proto;	/**< Protocol type (16). */
+	uint8_t vni[3];		/**< Virtual network identifier (24). */
+	uint8_t rsvd2;		/**< Reserved (8). */
+	uint8_t opts[];		/**<Variable length options. */
+} __rte_packed;
+
+/* GENEVE next protocol types */
+#define RTE_GENEVE_TYPE_IPV4		0x0800 /**< IPv4 Protocol.

*/
+#define RTE_GENEVE_TYPE_IPV6 0x86dd /**< IPv6 Protocol.
*/
+#define RTE_GENEVE_TYPE_ETH 0x6558 /**< Ethernet
Protocol. */

lib/librte_net/rte_geneve.h new file +6 -1
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* RTE_GENEVE_H_ */
--

2.8.4

#12 lore raw

Re: [dpdk-dev] [PATCH v4 1/3] app/testpmd: add GENEVE parsing

In reply to Ophir Munk

Hi Ophir,

Please find some comments below.

Quoted 14 lines · Ophir Munk

From: Ophir Munk <[email protected]>

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.

Quoted 6 lines
 app/test-pmd/csumonly.c     | 70 ++++++++++++++++++++++++++++++++++++++++++-
 app/test-pmd/testpmd.h      |  1 +
 lib/librte_net/meson.build  |  3 +-
 lib/librte_net/rte_geneve.h | 72 +++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 144 insertions(+), 2 deletions(-)
 create mode 100644 lib/librte_net/rte_geneve.h

An entry could be added in doc/api/doxy-api-index.md. Some more protocols are missing, I'll send a patch to add them.

Quoted 9 lines
lib/librte_net/rte_geneve.h new file +6 -0
@@ -0,0 +1,72 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2020 Mellanox Technologies, Ltd
+ */
+
+#ifndef _RTE_GENEVE_H_
+#define _RTE_GENEVE_H_

lib/librte_net/rte_geneve.h line 16

Quoted 10 lines
lib/librte_net/rte_geneve.h new file +10 -0
+
+/**
+ * @file
+ *
+ * GENEVE-related definitions
+ */
+
+#include <stdint.h>
+
+#include <rte_udp.h>

Is this include needed? Maybe it comes from a copy/paste of VXLAN?

Quoted 19 lines
lib/librte_net/rte_geneve.h new file +19 -0
+
+
+#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

lib/librte_net/rte_geneve.h line 45

Quoted 10 lines
lib/librte_net/rte_geneve.h new file +10 -0
+ *	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 (2).  */

Isn't the (2) in the comment redundant with the :2 in the type? Here is how bitfield look like in doxygen documentation:
https://doc.dpdk.org/api/structrte__flow__attr.html#ae4d19341d5298a2bc61f9eb941b1179c

It's true that the field documentation miss the number of bits. So if you feel it's needed, I prefer something more explicit like "(2 bits)" instead of just "(2)".

By the way, there are 2 spaces at the end of the comment.

lib/librte_net/rte_geneve.h line 49

Quoted 4 lines
lib/librte_net/rte_geneve.h new file +4 -0
+	uint8_t opt_len:6;	/**< Options length (6). */
+	uint8_t oam:1;		/**< Control packet (1). */
+	uint8_t critical:1;	/**< Critical packet (1). */
+	uint8_t rsvd1:6;	/**< Reserved (6). */

"reserved" instead of "rsvd"?

The Internet-Draft says "Rsvd" for this one, but "Reserved" for the other.

lib/librte_net/rte_geneve.h line 59

Quoted 10 lines
lib/librte_net/rte_geneve.h new file +10 -0
+#else
+	uint8_t opt_len:6;	/**< Options length (6). */
+	uint8_t ver:2;		/**< Version (2).  */
+	uint8_t rsvd1:6;	/**< Reserved (6). */
+	uint8_t critical:1;	/**< Critical packet (1). */
+	uint8_t oam:1;		/**< Control packet (1). */
+#endif
+	rte_be16_t proto;	/**< Protocol type (16). */
+	uint8_t vni[3];		/**< Virtual network identifier (24). */
+	uint8_t rsvd2;		/**< Reserved (8). */

vni is an identifier, so I wonder if it would make sense to have it as an integer instead of an array of uint8. Something like this:

	#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
		uint32_t vni:24;
		uint32_t reserved2:8;
	#else
		uint32_t vni:24;
		uint32_t reserved2:8;
	#endif

lib/librte_net/rte_geneve.h line 60

Quoted 1 line
lib/librte_net/rte_geneve.h new file +1 -0
+	uint8_t opts[];		/**<Variable length options. */

Since the option length is a multiple of four-bytes, would uint32_t[] make more sense here?

Missing a space after "<".

lib/librte_net/rte_geneve.h line 66

Quoted 6 lines
lib/librte_net/rte_geneve.h new file +6 -0
+} __rte_packed;
+
+/* GENEVE next protocol types */
+#define RTE_GENEVE_TYPE_IPV4		0x0800 /**< IPv4 Protocol. */
+#define RTE_GENEVE_TYPE_IPV6		0x86dd /**< IPv6 Protocol. */
+#define RTE_GENEVE_TYPE_ETH		0x6558 /**< Ethernet Protocol. */

From what I understand in the draft, I think only RTE_GENEVE_TYPE_ETH is needed.

Protocol Type (16 bits): The type of the protocol data unit appearing after the Geneve header. This follows the EtherType [ETYPES] convention; with Ethernet itself being represented by the value 0x6558.

Shouldn't we use RTE_ETHER_TYPE_* instead of redefining them here?

0x6558 is RTE_ETHER_TYPE_TEB (Transparent Ethernet Bridging) and is also used in case of NVGRE.

Regards,
Olivier

#13 lore raw

Re: [dpdk-dev] [PATCH v4 1/3] app/testpmd: add GENEVE parsing

Hi Olivier,
Please find comments inline.
I sent v5 based on your review.
http://patches.dpdk.org/project/dpdk/list/?series=12354

Quoted 38 lines

-----Original Message-----
From: Olivier Matz <[email protected]>
Sent: Thursday, September 17, 2020 3:23 PM
To: Ophir Munk <[email protected]>
Cc: [email protected]; Wenzhuo Lu <[email protected]>; Beilei Xing <[email protected]>; Bernard Iremonger <[email protected]>; Ferruh Yigit <[email protected]>; Ophir Munk <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v4 1/3] app/testpmd: add GENEVE parsing

Hi Ophir,

Please find some comments below.

Quoted 11 lines · Ophir Munk

From: Ophir Munk <[email protected]>

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.

Quoted 4 lines
 app/test-pmd/csumonly.c     | 70

++++++++++++++++++++++++++++++++++++++++++-

Quoted 6 lines
 app/test-pmd/testpmd.h      |  1 +
 lib/librte_net/meson.build  |  3 +-
 lib/librte_net/rte_geneve.h | 72
+++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 144 insertions(+), 2 deletions(-)  create mode

100644 lib/librte_net/rte_geneve.h

Quoted 3 lines

An entry could be added in doc/api/doxy-api-index.md. Some more protocols are missing, I'll send a patch to add them.

Thanks for sending a patch. I would appreciate it if it includes Geneve as well.

Quoted 12 lines
Quoted 12 lines
lib/librte_net/rte_geneve.h new file +9 -0
@@ -0,0 +1,72 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2020 Mellanox Technologies, Ltd  */
+
+#ifndef _RTE_GENEVE_H_
+#define _RTE_GENEVE_H_
+
+/**
+ * @file
+ *
Quoted 9 lines

lib/librte_net/rte_geneve.h line 16

Quoted 6 lines
lib/librte_net/rte_geneve.h new file +6 -0
+ * GENEVE-related definitions
+ */
+
+#include <stdint.h>
+
+#include <rte_udp.h>

Is this include needed? Maybe it comes from a copy/paste of VXLAN?

The include was dropped in v5 (not needed).

Quoted 40 lines
Quoted 12 lines
lib/librte_net/rte_geneve.h new file +12 -0
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** GENEVE default port. */
+#define RTE_GENEVE_DEFAULT_PORT 6081
+
+/**
+ * GENEVE protocol header. (draft-ietf-nvo3-geneve-09)
+ * Contains:

lib/librte_net/rte_geneve.h

Quoted 10 lines
lib/librte_net/rte_geneve.h new file +10 -0
+ * 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.

lib/librte_net/rte_geneve.h line 45

Quoted 7 lines
lib/librte_net/rte_geneve.h new file +7 -0
+ * 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 (2).  */

Isn't the (2) in the comment redundant with the :2 in the type? Here is how bitfield look like in doxygen documentation:
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdoc.
dpdk.org%2Fapi%2Fstructrte__flow__attr.html%23ae4d19341d5298a2bc61f 9eb941b1179c&amp;data=02%7C01%7Cophirmu%40nvidia.com%7C95918f4 2491c4832d8a308d85b047a22%7C43083d15727340c1b7db39efd9ccc17a%7 C0%7C0%7C637359422086641153&amp;sdata=LJjYkeHy9eHGc9xu42E%2F8 h54dzxrmiO7V0NCeLXndpU%3D&amp;reserved=0

Quoted 4 lines

It's true that the field documentation miss the number of bits. So if you feel it's needed, I prefer something more explicit like "(2 bits)" instead of just "(2)".

The number of bits is removed from the comments (v5).

Quoted 2 lines

By the way, there are 2 spaces at the end of the comment.

Extra spaces removed.

Quoted 7 lines

lib/librte_net/rte_geneve.h line 49

Quoted 4 lines
lib/librte_net/rte_geneve.h new file +4 -0
+	uint8_t opt_len:6;	/**< Options length (6). */
+	uint8_t oam:1;		/**< Control packet (1). */
+	uint8_t critical:1;	/**< Critical packet (1). */
+	uint8_t rsvd1:6;	/**< Reserved (6). */

"reserved" instead of "rsvd"?

In v5 all "rsvd" fields are renamed as "reserved".

Quoted 16 lines

The Internet-Draft says "Rsvd" for this one, but "Reserved" for the other.

lib/librte_net/rte_geneve.h line 59

Quoted 10 lines
lib/librte_net/rte_geneve.h new file +10 -0
+#else
+	uint8_t opt_len:6;	/**< Options length (6). */
+	uint8_t ver:2;		/**< Version (2).  */
+	uint8_t rsvd1:6;	/**< Reserved (6). */
+	uint8_t critical:1;	/**< Critical packet (1). */
+	uint8_t oam:1;		/**< Control packet (1). */
+#endif
+	rte_be16_t proto;	/**< Protocol type (16). */
+	uint8_t vni[3];		/**< Virtual network identifier (24). */
+	uint8_t rsvd2;		/**< Reserved (8). */

vni is an identifier, so I wonder if it would make sense to have it as an integer instead of an array of uint8. Something like this:

Quoted 8 lines
	#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
		uint32_t vni:24;
		uint32_t reserved2:8;
	#else
		uint32_t vni:24;
		uint32_t reserved2:8;
	#endif

I suggest leaving the vni as is (array of unsigned chars) since I do not see a gain by changing it to an integer of 24 bits.
If we did change - it will not turn VNI from network order to host order. So in case you wanted to print the VNI (host order) you will have to manipulate the bytes order anyway based on endianness. What do you think?

Quoted 5 lines

lib/librte_net/rte_geneve.h line 60

Quoted 1 line
lib/librte_net/rte_geneve.h new file +1 -0
+	uint8_t opts[];		/**<Variable length options. */

Since the option length is a multiple of four-bytes, would uint32_t[] make more sense here?

opts[] type changed to uint32_t in v5.

Quoted 2 lines

Missing a space after "<".

Space added.

Quoted 18 lines

lib/librte_net/rte_geneve.h

Quoted 4 lines
lib/librte_net/rte_geneve.h new file +4 -0
+} __rte_packed;
+
+/* GENEVE next protocol types */
+#define RTE_GENEVE_TYPE_IPV4		0x0800 /**< IPv4 Protocol.

*/

lib/librte_net/rte_geneve.h line 64

Quoted 1 line
lib/librte_net/rte_geneve.h new file +1 -0
+#define RTE_GENEVE_TYPE_IPV6		0x86dd /**< IPv6 Protocol.

*/

lib/librte_net/rte_geneve.h line 65

Quoted 1 line
lib/librte_net/rte_geneve.h new file +1 -0
+#define RTE_GENEVE_TYPE_ETH		0x6558 /**< Ethernet

Protocol. */

From what I understand in the draft, I think only RTE_GENEVE_TYPE_ETH is needed.

Protocol Type (16 bits): The type of the protocol data unit appearing after the Geneve header. This follows the EtherType [ETYPES] convention; with Ethernet itself being represented by the value 0x6558.

Quoted 6 lines

Shouldn't we use RTE_ETHER_TYPE_* instead of redefining them here?

0x6558 is RTE_ETHER_TYPE_TEB (Transparent Ethernet Bridging) and is also used in case of NVGRE.

Definitions RTE_GENEVE_TYPE_IPV4 and RTE_GENEVE_TYPE_IPV6 dropped (remaining with RTE_GENEVE_TYPE_ETH only).

Quoted 2 lines

Regards,
Olivier

Regards,
Ophir

#14 lore raw

v5 cover Add GENEVE protocol parsing to testpmd

In reply to Ophir Munk

v1:
Initial version
v2:
Rebased + Minor update in protocol options field:
char opts[0] ===> uint8_t opts[]
v3:
Rebase
document "geneve-port=N" parameter
v4:
Mispelling corrections
v5:
Rebase + Updates following review
http://patches.dpdk.org/patch/77734/

Ophir Munk (3):
app/testpmd: add GENEVE parsing app/testpmd: enable configuring GENEVE port app/testpmd: reduce tunnel parsing code duplication

 app/test-pmd/csumonly.c               | 120 ++++++++++++++++++++++------------
 app/test-pmd/parameters.c             |  14 +++-
 app/test-pmd/testpmd.h                |   1 +
 doc/guides/testpmd_app_ug/run_app.rst |   5 ++
 lib/librte_net/meson.build            |   3 +-
 lib/librte_net/rte_geneve.h           |  66 +++++++++++++++++++
 lib/librte_net/rte_vxlan.h            |   1 +
 7 files changed, 165 insertions(+), 45 deletions(-)
 create mode 100644 lib/librte_net/rte_geneve.h
Signature · 1 line
2.8.4
#15 lore raw

PATCH v5 1/3 app/testpmd: add GENEVE parsing

From: Ophir Munk <[email protected]>

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.

---
 app/test-pmd/csumonly.c     | 70 ++++++++++++++++++++++++++++++++++++++++++++-
 app/test-pmd/testpmd.h      |  1 +
 lib/librte_net/meson.build  |  3 +-
 lib/librte_net/rte_geneve.h | 66 ++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 138 insertions(+), 2 deletions(-)
 create mode 100644 lib/librte_net/rte_geneve.h
app/test-pmd/csumonly.c +69 -1
index 7ece398..a9f33c6 100644
@@ -43,6 +43,7 @@
 #include <rte_flow.h>
 #include <rte_gro.h>
 #include <rte_gso.h>
+#include <rte_geneve.h>
 
 #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;
 
app/test-pmd/testpmd.h +1 -0
index f139fe7..bd08a64 100644
@@ -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];
lib/librte_net/meson.build +2 -1
index 24ed825..52d3a97 100644
@@ -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']
lib/librte_net/rte_geneve.h new file +66 -0

66 lines not on this page · raw message

Signature · 1 line
2.8.4
#16 lore raw

Re: [dpdk-dev] [PATCH v5 1/3] app/testpmd: add GENEVE parsing

Quoted 33 lines · Ophir Munk

From: Ophir Munk <[email protected]>

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.

---
  app/test-pmd/csumonly.c     | 70 ++++++++++++++++++++++++++++++++++++++++++++-
  app/test-pmd/testpmd.h      |  1 +
  lib/librte_net/meson.build  |  3 +-
  lib/librte_net/rte_geneve.h | 66 ++++++++++++++++++++++++++++++++++++++++++
  4 files changed, 138 insertions(+), 2 deletions(-)

create mode 100644 lib/librte_net/rte_geneve.h

app/test-pmd/csumonly.c +1 -0
index 7ece398..a9f33c6 100644
@@ -43,6 +43,7 @@
  #include <rte_flow.h>
  #include <rte_gro.h>
  #include <rte_gso.h>
+#include <rte_geneve.h>
 
  #include "testpmd.h"
 

app/test-pmd/csumonly.c line 68

Quoted 5 lines
app/test-pmd/csumonly.c +1 -0
@@ -63,6 +64,7 @@
  #endif
 
  uint16_t vxlan_gpe_udp_port = 4790;
+uint16_t geneve_udp_port = RTE_GENEVE_DEFAULT_PORT;
 

There is a testpmd command to configure the NIC for GENEVE port, "port config (port_id) udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe (udp_port)"

You are adding support to testpmd to parse the GENEVE packets, but I think these two commads should be consistent.

What do you think "port config N add geneve X" update the 'geneve_udp_port=X"?

<...>

Quoted 6 lines
app/test-pmd/csumonly.c +1 -1
@@ -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) {

app/test-pmd/csumonly.c pkt_burst_checksum_forward(struct fwd_stream *fs) · line 938

Quoted 10 lines
app/test-pmd/csumonly.c +8 -0
  					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;
+				}

Can you please update the "csum parse-tunnel" documentation to mention "geneve" protocol?

#17 lore raw

Re: [dpdk-dev] [PATCH v5 1/3] app/testpmd: add GENEVE parsing

Hi Ferruh,
Please find comments inline.

Quoted 4 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Tuesday, October 6, 2020 5:31 PM
To: Ophir Munk <[email protected]>; [email protected]; Wenzhuo Lu

<...>

Quoted 9 lines
Quoted 4 lines

uint16_t vxlan_gpe_udp_port = 4790;
+uint16_t geneve_udp_port = RTE_GENEVE_DEFAULT_PORT;

There is a testpmd command to configure the NIC for GENEVE port, "port config (port_id) udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe (udp_port)"

Quoted 8 lines

You are adding support to testpmd to parse the GENEVE packets, but I think these two commads should be consistent.

What do you think "port config N add geneve X" update the 'geneve_udp_port=X"?

<...>

It is not as simple as suggested.
The command "port config N add geneve X" can be repeated several times - adding another geneve port to the NIC Hardware/Firmware to recognize. As a result the NIC is configured with multiple geneve ports. On the other hand geneve_udp_port is a single variable - so whenever a new "port config" command is executed - we will override the last geneve port and forget all the precedent ones. The port config command also has a "rm" option in addition to "add". So if we removed the last port - what will we assigned to geneve_udp_port? We need to have a small data base for managing geneve ports.
testpmd also has an option " --geneve-port=N". It should be synched with the "port config" command.

Another issue to consider is if there is a need for the suggested feature. I think the "port config" is mainly targeted for offloading. So the NIC will probably encap/decap a packet with geneve - leaving testpmd paring unneeded.

My point is that your suggestion requires an RFC before implementation.

Quoted 14 lines

Review pkt_burst_checksum_forward(struct fwd_stream

Quoted 2 lines
(quoted diff) +0 -0
@@ -865,9 +925,17 @@ pkt_burst_checksum_forward(struct fwd_stream

*fs)

Quoted 11 lines
app/test-pmd/csumonly.c +5 -1
  				}
  				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) {
Quoted 8 lines

app/test-pmd/csumonly.c pkt_burst_checksum_forward(struct fwd_stream *fs) · line 938

Quoted 4 lines
app/test-pmd/csumonly.c +4 -0
+					tx_ol_flags |=
+						PKT_TX_TUNNEL_GENEVE;
+					goto tunnel_update;
+				}

Can you please update the "csum parse-tunnel" documentation to mention "geneve"
protocol?

Done in v6. I added other missing tunnel protocols (in alphabetical order) such as "gtp". Since it is more than geneve I added it to the 3rd (cleanup) commit.

#18 lore raw

Re: [dpdk-dev] [PATCH v5 1/3] app/testpmd: add GENEVE parsing

Quoted 26 lines · Ophir Munk

Hi Ferruh,
Please find comments inline.

Quoted 4 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Tuesday, October 6, 2020 5:31 PM
To: Ophir Munk <[email protected]>; [email protected]; Wenzhuo Lu

<...>

Quoted 9 lines
Quoted 4 lines
   uint16_t vxlan_gpe_udp_port = 4790;

+uint16_t geneve_udp_port = RTE_GENEVE_DEFAULT_PORT;

There is a testpmd command to configure the NIC for GENEVE port, "port config (port_id) udp_tunnel_port add|rm vxlan|geneve|vxlan-gpe (udp_port)"

Quoted 8 lines

You are adding support to testpmd to parse the GENEVE packets, but I think these two commads should be consistent.

What do you think "port config N add geneve X" update the 'geneve_udp_port=X"?

<...>

Quoted 9 lines

It is not as simple as suggested.
The command "port config N add geneve X" can be repeated several times - adding another geneve port to the NIC Hardware/Firmware to recognize. As a result the NIC is configured with multiple geneve ports. On the other hand geneve_udp_port is a single variable - so whenever a new "port config" command is executed - we will override the last geneve port and forget all the precedent ones. The port config command also has a "rm" option in addition to "add". So if we removed the last port - what will we assigned to geneve_udp_port? We need to have a small data base for managing geneve ports.
testpmd also has an option " --geneve-port=N". It should be synched with the "port config" command.

Another issue to consider is if there is a need for the suggested feature. I think the "port config" is mainly targeted for offloading. So the NIC will probably encap/decap a packet with geneve - leaving testpmd paring unneeded.

My point is that your suggestion requires an RFC before implementation.

I am not sure about adding database for geneve ports, I think no need to make it more complex.

Only when user set via "--geneve-port=N", it is the port for testpmd to parse (same for 'geneve_udp_port' global variable), but when user give command "port config N add geneve X" it is to configure the NIC to offload the parsing. This is too confusing, user can't know (or remember) this without checking the source code.

Can we rename the command and variable to highlight that it is for testpmd to parse, I think that will be enough, instead of trying to merge them, which is hard as you described above.

What do you think for "--testpmd-geneve-port=N" parameter and 'testpmd_geneve_udp_port' variable name?
We can also update the documentation to say this is only the port testpmd uses for parsing, HW may be configured to use another port.

Quoted 23 lines
Quoted 14 lines

Review pkt_burst_checksum_forward(struct fwd_stream

Quoted 2 lines
(quoted diff) +0 -0
@@ -865,9 +925,17 @@ pkt_burst_checksum_forward(struct fwd_stream

*fs)

Quoted 11 lines
app/test-pmd/csumonly.c +5 -1
   				}
   				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) {
Quoted 8 lines

app/test-pmd/csumonly.c pkt_burst_checksum_forward(struct fwd_stream *fs) · line 938

Quoted 4 lines
app/test-pmd/csumonly.c +4 -0
+					tx_ol_flags |=
+						PKT_TX_TUNNEL_GENEVE;
+					goto tunnel_update;
+				}

Can you please update the "csum parse-tunnel" documentation to mention "geneve"
protocol?

Quoted 2 lines

Done in v6. I added other missing tunnel protocols (in alphabetical order) such as "gtp". Since it is more than geneve I added it to the 3rd (cleanup) commit.

Would you mind adding the 'geneve' with the patch adding 'geneve' support (1/3), and add the other missing ones in the patch 3/3 ?

#19 lore raw

Re: [dpdk-dev] [PATCH v5 1/3] app/testpmd: add GENEVE parsing

Quoted 6 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, October 7, 2020 7:25 PM
To: Ophir Munk <[email protected]>; [email protected]; Wenzhuo Lu

<...>

Quoted 6 lines

Only when user set via "--geneve-port=N", it is the port for testpmd to parse (same for 'geneve_udp_port' global variable), but when user give command "port config N add geneve X" it is to configure the NIC to offload the parsing. This is too confusing, user can't know (or remember) this without checking the source code.

Quoted 6 lines

Can we rename the command and variable to highlight that it is for testpmd to parse, I think that will be enough, instead of trying to merge them, which is hard as you described above.

What do you think for "--testpmd-geneve-port=N" parameter and 'testpmd_geneve_udp_port' variable name?

I am suggesting two options:
1. "--geneve-port-identifier=N" and "geneve_udp_port_identifier" as variable name.
2. "--geneve-parsed-port=N" and "geneve_udp_port" as variable name. Can you select one of them?

Quoted 3 lines

We can also update the documentation to say this is only the port testpmd uses for parsing, HW may be configured to use another port.

Will update documentation.

<...>

Quoted 7 lines
Quoted 1 line

Done in v6. I added other missing tunnel protocols (in alphabetical order)

such as "gtp". Since it is more than geneve I added it to the 3rd (cleanup) commit.

Quoted 1 line

Would you mind adding the 'geneve' with the patch adding 'geneve' support (1/3), and add the other missing ones in the patch 3/3 ?

Will update accordingly

#20 lore raw

Re: [dpdk-dev] [PATCH v5 1/3] app/testpmd: add GENEVE parsing

Quoted 17 lines · Ophir Munk
Quoted 6 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, October 7, 2020 7:25 PM
To: Ophir Munk <[email protected]>; [email protected]; Wenzhuo Lu

<...>

Quoted 10 lines

Only when user set via "--geneve-port=N", it is the port for testpmd to parse (same for 'geneve_udp_port' global variable), but when user give command "port config N add geneve X" it is to configure the NIC to offload the parsing. This is too confusing, user can't know (or remember) this without checking the source code.

Can we rename the command and variable to highlight that it is for testpmd to parse, I think that will be enough, instead of trying to merge them, which is hard as you described above.

Quoted 8 lines
Quoted 2 lines

What do you think for "--testpmd-geneve-port=N" parameter and 'testpmd_geneve_udp_port' variable name?

I am suggesting two options:
1. "--geneve-port-identifier=N" and "geneve_udp_port_identifier" as variable name.
2. "--geneve-parsed-port=N" and "geneve_udp_port" as variable name. Can you select one of them?

I think 'identifier' doesn't add any more clarification, lets go with (2). Thanks.

Quoted 17 lines
Quoted 3 lines

We can also update the documentation to say this is only the port testpmd uses for parsing, HW may be configured to use another port.

Will update documentation.

<...>

Quoted 7 lines
Quoted 1 line

Done in v6. I added other missing tunnel protocols (in alphabetical order)

such as "gtp". Since it is more than geneve I added it to the 3rd (cleanup) commit.

Quoted 1 line

Would you mind adding the 'geneve' with the patch adding 'geneve' support (1/3), and add the other missing ones in the patch 3/3 ?

Will update accordingly

#21 lore raw

v6 cover Add GENEVE protocol parsing to testpmd

In reply to Ophir Munk

v1:
Initial version
v2:
Rebased + Minor update in protocol options field:
char opts[0] ===> uint8_t opts[]
v3:
Rebase
document "geneve-port=N" parameter
v4:
Mispelling corrections
v5:
Rebase + Updates following review
http://patches.dpdk.org/patch/77734/
v6:
Rebase + Updates following reviews: more cleanup and added documentation.

Ophir Munk (3):
app/testpmd: add GENEVE parsing
app/testpmd: enable configuring GENEVE port
app/testpmd: tunnel parsing protocols cleanup

 app/test-pmd/cmdline_flow.c                 |   3 +-
 app/test-pmd/csumonly.c                     | 129 ++++++++++++++++++----------
 app/test-pmd/parameters.c                   |  14 ++-
 app/test-pmd/testpmd.h                      |   1 +
 doc/guides/testpmd_app_ug/run_app.rst       |   5 ++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |   6 +-
 lib/librte_net/meson.build                  |   3 +-
 lib/librte_net/rte_geneve.h                 |  66 ++++++++++++++
 lib/librte_net/rte_vxlan.h                  |   1 +
 9 files changed, 175 insertions(+), 53 deletions(-)
 create mode 100644 lib/librte_net/rte_geneve.h
Signature · 1 line
2.8.4
#22 lore raw

PATCH v6 1/3 app/testpmd: add GENEVE parsing

From: Ophir Munk <[email protected]>

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.

---
 app/test-pmd/csumonly.c     | 70 ++++++++++++++++++++++++++++++++++++++++++++-
 app/test-pmd/testpmd.h      |  1 +
 lib/librte_net/meson.build  |  3 +-
 lib/librte_net/rte_geneve.h | 66 ++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 138 insertions(+), 2 deletions(-)
 create mode 100644 lib/librte_net/rte_geneve.h
app/test-pmd/csumonly.c +69 -1
index 7ece398..a9f33c6 100644
@@ -43,6 +43,7 @@
 #include <rte_flow.h>
 #include <rte_gro.h>
 #include <rte_gso.h>
+#include <rte_geneve.h>
 
 #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;
 
app/test-pmd/testpmd.h +1 -0
index c7e7e41..14aae7c 100644
@@ -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];
lib/librte_net/meson.build +2 -1
index 24ed825..52d3a97 100644
@@ -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']
lib/librte_net/rte_geneve.h new file +66 -0

66 lines not on this page · raw message

Signature · 1 line
2.8.4
#23 lore raw

v7 cover Add GENEVE protocol parsing to testpmd

v1:
Initial version
v2:
Rebased + Minor update in protocol options field:
char opts[0] ===> uint8_t opts[]
v3:
Rebase
document "geneve-port=N" parameter
v4:
Mispelling corrections
v5:
Rebase + Updates following review
http://patches.dpdk.org/patch/77734/
v6:
Rebase + Updates following reviews: more cleanup and added documentation. v7:
Updates following reviews: rename geneve-port as geneve-parsed-port + added documentation.

Ophir Munk (3):
app/testpmd: add GENEVE parsing
app/testpmd: enable configuring GENEVE port
app/testpmd: tunnel parsing protocols cleanup

 app/test-pmd/cmdline_flow.c                 |   3 +-
 app/test-pmd/csumonly.c                     | 129 ++++++++++++++++++----------
 app/test-pmd/parameters.c                   |  15 +++-
 app/test-pmd/testpmd.h                      |   1 +
 doc/guides/testpmd_app_ug/run_app.rst       |   6 ++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |   6 +-
 lib/librte_net/meson.build                  |   3 +-
 lib/librte_net/rte_geneve.h                 |  66 ++++++++++++++
 lib/librte_net/rte_vxlan.h                  |   1 +
 9 files changed, 177 insertions(+), 53 deletions(-)
 create mode 100644 lib/librte_net/rte_geneve.h
Signature · 1 line
2.8.4
#24 lore raw

PATCH v7 1/3 app/testpmd: add GENEVE parsing

From: Ophir Munk <[email protected]>

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.

---
 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
app/test-pmd/csumonly.c +69 -1
index 7ece398..a9f33c6 100644
@@ -43,6 +43,7 @@
 #include <rte_flow.h>
 #include <rte_gro.h>
 #include <rte_gso.h>
+#include <rte_geneve.h>
 
 #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;
 
app/test-pmd/testpmd.h +1 -0
index c7e7e41..14aae7c 100644
@@ -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];
doc/guides/testpmd_app_ug/testpmd_funcs.rst +3 -3
index 72bdb1b..c448e2d 100644
@@ -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).
lib/librte_net/meson.build +2 -1
index 24ed825..52d3a97 100644
@@ -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']
lib/librte_net/rte_geneve.h new file +66 -0

66 lines not on this page · raw message

Signature · 1 line
2.8.4
#25 lore raw

PATCH v7 2/3 app/testpmd: enable configuring GENEVE port

In reply to Ophir Munk

From: Ophir Munk <[email protected]>

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.

---
 app/test-pmd/parameters.c             | 15 +++++++++++++--
 doc/guides/testpmd_app_ug/run_app.rst |  6 ++++++
 2 files changed, 19 insertions(+), 2 deletions(-)
app/test-pmd/parameters.c +13 -2
index 1ead595..15ce8c1 100644
@@ -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 <native|anon|xmem|xmemhuge>: 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,
doc/guides/testpmd_app_ug/run_app.rst +6 -0
index e2539f6..ec085c2 100644
@@ -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.
Signature · 1 line
2.8.4
#26 lore raw

PATCH v7 3/3 app/testpmd: tunnel parsing protocols cleanup

In reply to Ophir Munk

From: Ophir Munk <[email protected]>

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.

---
 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(-)
app/test-pmd/cmdline_flow.c +2 -1
index 6e04d53..761ac5a 100644
@@ -23,6 +23,7 @@
 #include <cmdline_parse_num.h>
 #include <rte_flow.h>
 #include <rte_hexdump.h>
+#include <rte_vxlan.h>
 
 #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"
app/test-pmd/csumonly.c +25 -56

150 lines not on this page · raw message

doc/guides/testpmd_app_ug/testpmd_funcs.rst +3 -3
index c448e2d..5cd2079 100644
@@ -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).
lib/librte_net/rte_vxlan.h +1 -0
index c23c10c..2ad6061 100644
@@ -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.
Signature · 1 line
2.8.4
Reviewed-by on the v7 series
#27 lore raw
In reply to Ophir Munk
Quoted 19 lines · Ophir Munk

v1:
Initial version
v2:
Rebased + Minor update in protocol options field:
char opts[0] ===> uint8_t opts[]
v3:
Rebase
document "geneve-port=N" parameter
v4:
Mispelling corrections
v5:
Rebase + Updates following review
http://patches.dpdk.org/patch/77734/
v6:
Rebase + Updates following reviews: more cleanup and added documentation. v7:
Updates following reviews: rename geneve-port as geneve-parsed-port + added documentation.

Quoted 5 lines

Ophir Munk (3):
app/testpmd: add GENEVE parsing
app/testpmd: enable configuring GENEVE port
app/testpmd: tunnel parsing protocols cleanup

For series,

Series applied to dpdk-next-net/main, thanks.

#28 lore raw

PATCH v6 2/3 app/testpmd: enable configuring GENEVE port

In reply to Ophir Munk

From: Ophir Munk <[email protected]>

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.

---
 app/test-pmd/parameters.c             | 14 ++++++++++++--
 doc/guides/testpmd_app_ug/run_app.rst |  5 +++++
 2 files changed, 17 insertions(+), 2 deletions(-)
app/test-pmd/parameters.c +12 -2
index 1ead595..dcc9343 100644
@@ -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-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-port=N: UPD port of tunnel GENEVE\n");
 	printf("  --mlockall: lock all memory\n");
 	printf("  --no-mlockall: do not lock all memory\n");
 	printf("  --mp-alloc <native|anon|xmem|xmemhuge>: 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-port",		1, 0, 0 },
 		{ "mlockall",			0, 0, 0 },
 		{ "no-mlockall",		0, 0, 0 },
 		{ "mp-alloc",			1, 0, 0 },
@@ -1311,6 +1313,14 @@ 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-port")) {
+				n = atoi(optarg);
+				if (n >= 0)
+					geneve_udp_port = (uint16_t)n;
+				else
+					rte_exit(EXIT_FAILURE,
+						 "geneve-port must be >= 0\n");
+			}
 			if (!strcmp(lgopts[opt_idx].name, "print-event"))
 				if (parse_event_printing_config(optarg, 1)) {
 					rte_exit(EXIT_FAILURE,
doc/guides/testpmd_app_ug/run_app.rst +5 -0
index e2539f6..dbd22f1 100644
@@ -426,6 +426,11 @@ The command line options are:
     Set the UDP port number of tunnel VXLAN-GPE to N.
     The default value is 4790.
 
+*   ``--geneve-port=N``
+
+    Set the UDP port number of tunnel GENEVE to N.
+    The default value is 6081.
+
 *   ``--mlockall``
 
     Enable locking all memory.
Signature · 1 line
2.8.4
#29 lore raw

PATCH v6 3/3 app/testpmd: tunnel parsing protocols cleanup

In reply to Ophir Munk

From: Ophir Munk <[email protected]>

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.

---
 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(-)
app/test-pmd/cmdline_flow.c +2 -1
index 6e04d53..761ac5a 100644
@@ -23,6 +23,7 @@
 #include <cmdline_parse_num.h>
 #include <rte_flow.h>
 #include <rte_hexdump.h>
+#include <rte_vxlan.h>
 
 #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"
app/test-pmd/csumonly.c +25 -56

150 lines not on this page · raw message

doc/guides/testpmd_app_ug/testpmd_funcs.rst +3 -3
index 72bdb1b..bc6f2fd 100644
@@ -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 (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 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).
+tunnel headers (ipip, geneve, gtp, gre, vxlan, vxlan-gpe).
 
 If disabled, treat tunnel packets as non-tunneled packets (a inner
 header is handled as a packet payload).
lib/librte_net/rte_vxlan.h +1 -0
index c23c10c..2ad6061 100644
@@ -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.
Signature · 1 line
2.8.4
#30 lore raw

Re: [dpdk-dev] [PATCH v6 3/3] app/testpmd: tunnel parsing protocols cleanup

Quoted 11 lines · Ophir Munk

From: Ophir Munk <[email protected]>

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.

Quoted 5 lines
---
  app/test-pmd/cmdline_flow.c                 |  3 +-
  app/test-pmd/csumonly.c                     | 81 +++++++++--------------------
  doc/guides/testpmd_app_ug/testpmd_funcs.rst |  6 +--

I think this documentation update should be part of 1/3, if there will be a new version can you please move, if not I can do myself while merging.

Quoted 2 lines
  lib/librte_net/rte_vxlan.h                  |  1 +
  4 files changed, 31 insertions(+), 60 deletions(-)

<...>

#31 lore raw

PATCH v5 2/3 app/testpmd: enable configuring GENEVE port

In reply to Ophir Munk

From: Ophir Munk <[email protected]>

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.

---
 app/test-pmd/parameters.c             | 14 ++++++++++++--
 doc/guides/testpmd_app_ug/run_app.rst |  5 +++++
 2 files changed, 17 insertions(+), 2 deletions(-)
app/test-pmd/parameters.c +12 -2
index 8c2aa13..d10397c 100644
@@ -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-port= | "
+	       "--record-core-cycles | --record-burst-stats]\n",
 	       progname);
 #ifdef RTE_LIBRTE_CMDLINE
 	printf("  --interactive: run in interactive mode.\n");
@@ -200,6 +200,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-port=N: UPD port of tunnel GENEVE\n");
 	printf("  --mlockall: lock all memory\n");
 	printf("  --no-mlockall: do not lock all memory\n");
 	printf("  --mp-alloc <native|anon|xmem|xmemhuge>: mempool allocation method.\n"
@@ -667,6 +668,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-port",		1, 0, 0 },
 		{ "mlockall",			0, 0, 0 },
 		{ "no-mlockall",		0, 0, 0 },
 		{ "mp-alloc",			1, 0, 0 },
@@ -1303,6 +1305,14 @@ 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-port")) {
+				n = atoi(optarg);
+				if (n >= 0)
+					geneve_udp_port = (uint16_t)n;
+				else
+					rte_exit(EXIT_FAILURE,
+						 "geneve-port must be >= 0\n");
+			}
 			if (!strcmp(lgopts[opt_idx].name, "print-event"))
 				if (parse_event_printing_config(optarg, 1)) {
 					rte_exit(EXIT_FAILURE,
doc/guides/testpmd_app_ug/run_app.rst +5 -0
index e2539f6..dbd22f1 100644
@@ -426,6 +426,11 @@ The command line options are:
     Set the UDP port number of tunnel VXLAN-GPE to N.
     The default value is 4790.
 
+*   ``--geneve-port=N``
+
+    Set the UDP port number of tunnel GENEVE to N.
+    The default value is 6081.
+
 *   ``--mlockall``
 
     Enable locking all memory.
Signature · 1 line
2.8.4
#32 lore raw

PATCH v5 3/3 app/testpmd: reduce tunnel parsing code duplication

In reply to Ophir Munk

From: Ophir Munk <[email protected]>

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.

---
 app/test-pmd/csumonly.c    | 72 +++++++++++++---------------------------------
 lib/librte_net/rte_vxlan.h |  1 +
 2 files changed, 21 insertions(+), 52 deletions(-)
app/test-pmd/csumonly.c +20 -52
index a9f33c6..7f9bfa6 100644
@@ -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 +
@@ -257,11 +264,7 @@ parse_vxlan(struct rte_udp_hdr *udp_hdr,
 		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 +294,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 +304,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 +314,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 +326,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 +392,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 +401,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 +410,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);
 
lib/librte_net/rte_vxlan.h +1 -0
index c23c10c..2ad6061 100644
@@ -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.
Signature · 1 line
2.8.4
#33 lore raw

Re: [dpdk-dev] [PATCH v5 3/3] app/testpmd: reduce tunnel parsing code duplication

Quoted 18 lines · Ophir Munk

From: Ophir Munk <[email protected]>

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.

---
  app/test-pmd/csumonly.c    | 72 +++++++++++++---------------------------------
  lib/librte_net/rte_vxlan.h |  1 +
  2 files changed, 21 insertions(+), 52 deletions(-)
app/test-pmd/csumonly.c +0 -0
index a9f33c6..7f9bfa6 100644

app/test-pmd/csumonly.c line 67

Quoted 6 lines
app/test-pmd/csumonly.c +1 -1
@@ -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;

'RTE_VXLAN_DEFAULT_PORT' seems defined but '4789' still used as hardcoded in this file, since you are touching these, can you please update that usage too?

#34 lore raw

Re: [dpdk-dev] [PATCH v5 3/3] app/testpmd: reduce tunnel parsing code duplication

Quoted 4 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Tuesday, October 6, 2020 5:30 PM

...

Quoted 2 lines

Subject: Re: [PATCH v5 3/3] app/testpmd: reduce tunnel parsing code duplication

...

Quoted 3 lines

'RTE_VXLAN_DEFAULT_PORT' seems defined but '4789' still used as hardcoded in this file, since you are touching these, can you please update that usage too?

Done in v6

#35 lore raw
In reply to Ophir Munk
Quoted 14 lines · Ophir Munk

v1:
Initial version
v2:
Rebased + Minor update in protocol options field:
char opts[0] ===> uint8_t opts[]
v3:
Rebase
document "geneve-port=N" parameter
v4:
Mispelling corrections
v5:
Rebase + Updates following review
http://patches.dpdk.org/patch/77734/

Quoted 5 lines

Ophir Munk (3):
app/testpmd: add GENEVE parsing app/testpmd: enable configuring GENEVE port app/testpmd: reduce tunnel parsing code duplication

Hi Ophir,

The patchset looks good except a few comments I put into the patches.

But I have two highlevel questions/comments,

1) The testpmd tunnel parsing feature is not documented properly, there are various related commands but there is no documentation to put all together. What do you think putting a new section for it under the "Testpmd Runtime Functions" (testpmd_funcs.rst) with this patchset?

2) The 'csum' forwarding engine seems become forwarding engine for the case where packet payload needs to be parsed, like gro/gso, tunnel parse. Even the description of the forwarding engine in the documentation is not accurate now. I wonder if we should rename the forwarding engine at this stage?

#36 lore raw

Hi Ferruh,
I sent V6 which addresses your last review.

Please see more comments inline.

Quoted 37 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Tuesday, October 6, 2020 5:59 PM

Quoted 4 lines · Ophir Munk

v1:
Initial version
v2:
Rebased + Minor update in protocol options field:

Quoted 9 lines

char opts[0] ===> uint8_t opts[]
v3:
Rebase
document "geneve-port=N" parameter
v4:
Mispelling corrections
v5:
Rebase + Updates following review

https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpatch

Quoted 1 line

es.dpdk.org%2Fpatch%2F77734%2F&amp;data=02%7C01%7Cophirmu%40nv idia.com

Quoted 1 line

%7C1b01b5de39d24d61e38008d86a086ae2%7C43083d15727340c1b7db39e fd9ccc17a

Quoted 1 line

%7C0%7C0%7C637375931691373733&amp;sdata=csLb5OdTmWlpv1k4Z7ZZ YN1b1d2cd8

Quoted 7 lines

%2BTxxnydgNnyQ4%3D&amp;reserved=0

Ophir Munk (3):
app/testpmd: add GENEVE parsing app/testpmd: enable configuring GENEVE port app/testpmd: reduce tunnel parsing code duplication

Hi Ophir,

Quoted 8 lines

The patchset looks good except a few comments I put into the patches.

But I have two highlevel questions/comments,

1) The testpmd tunnel parsing feature is not documented properly, there are various related commands but there is no documentation to put all together. What do you think putting a new section for it under the "Testpmd Runtime Functions" (testpmd_funcs.rst) with this patchset?

I prefer this to be in a separate patchset.
Geneve in testpmd is not complete yet. I know that there is current work in progress to add geneve options to flows. Maybe its worth waiting till Geneve is finalized in testpmd.

Quoted 6 lines

2) The 'csum' forwarding engine seems become forwarding engine for the case where packet payload needs to be parsed, like gro/gso, tunnel parse. Even the description of the forwarding engine in the documentation is not accurate now.
I wonder if we should rename the forwarding engine at this stage?

Can you please be more specific to which renaming you are referring to? Can you give examples?

#37 lore raw
Quoted 56 lines · Ophir Munk

Hi Ferruh,
I sent V6 which addresses your last review.

Please see more comments inline.

Quoted 37 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Tuesday, October 6, 2020 5:59 PM

Quoted 4 lines · Ophir Munk

v1:
Initial version
v2:
Rebased + Minor update in protocol options field:

Quoted 9 lines

char opts[0] ===> uint8_t opts[]
v3:
Rebase
document "geneve-port=N" parameter
v4:
Mispelling corrections
v5:
Rebase + Updates following review

https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpatch

Quoted 1 line

es.dpdk.org%2Fpatch%2F77734%2F&amp;data=02%7C01%7Cophirmu%40nv idia.com

Quoted 1 line

%7C1b01b5de39d24d61e38008d86a086ae2%7C43083d15727340c1b7db39e fd9ccc17a

Quoted 1 line

%7C0%7C0%7C637375931691373733&amp;sdata=csLb5OdTmWlpv1k4Z7ZZ YN1b1d2cd8

Quoted 7 lines

%2BTxxnydgNnyQ4%3D&amp;reserved=0

Ophir Munk (3):
app/testpmd: add GENEVE parsing app/testpmd: enable configuring GENEVE port app/testpmd: reduce tunnel parsing code duplication

Hi Ophir,

Quoted 8 lines

The patchset looks good except a few comments I put into the patches.

But I have two highlevel questions/comments,

1) The testpmd tunnel parsing feature is not documented properly, there are various related commands but there is no documentation to put all together. What do you think putting a new section for it under the "Testpmd Runtime Functions" (testpmd_funcs.rst) with this patchset?

I prefer this to be in a separate patchset.
Geneve in testpmd is not complete yet. I know that there is current work in progress to add geneve options to flows. Maybe its worth waiting till Geneve is finalized in testpmd.

Quoted 1 line
Quoted 9 lines
Quoted 5 lines

2) The 'csum' forwarding engine seems become forwarding engine for the case where packet payload needs to be parsed, like gro/gso, tunnel parse. Even the description of the forwarding engine in the documentation is not accurate now.
I wonder if we should rename the forwarding engine at this stage?

Can you please be more specific to which renaming you are referring to? Can you give examples?

I am asking about forwarding engine name, it is 'csum' and in documentation it is described as:
"
Changes the checksum field with hardware or software methods depending on the offload flags on the packet. "

So the initial purpose of the forwarding engine is to calculate checksums (or offload calculation to HW) before sending packets, but now it detects and parses the tunneling protocols and updates packet accordingly and logs it. It also does GRO and GSO.

Is the forwarding engine name 'csum' still make sense, or should we find something else. I don't have any suggestion, just the question.

#38 lore raw

PATCH v4 2/3 app/testpmd: enable configuring GENEVE port

In reply to Ophir Munk

From: Ophir Munk <[email protected]>

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.

---
 app/test-pmd/parameters.c             | 14 ++++++++++++--
 doc/guides/testpmd_app_ug/run_app.rst |  5 +++++
 2 files changed, 17 insertions(+), 2 deletions(-)
app/test-pmd/parameters.c +12 -2
index 7845153..25e2935 100644
@@ -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-port= | "
+	       "--record-core-cycles | --record-burst-stats]\n",
 	       progname);
 #ifdef RTE_LIBRTE_CMDLINE
 	printf("  --interactive: run in interactive mode.\n");
@@ -200,6 +200,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-port=N: UPD port of tunnel GENEVE\n");
 	printf("  --mlockall: lock all memory\n");
 	printf("  --no-mlockall: do not lock all memory\n");
 	printf("  --mp-alloc <native|anon|xmem|xmemhuge>: mempool allocation method.\n"
@@ -667,6 +668,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-port",		1, 0, 0 },
 		{ "mlockall",			0, 0, 0 },
 		{ "no-mlockall",		0, 0, 0 },
 		{ "mp-alloc",			1, 0, 0 },
@@ -1303,6 +1305,14 @@ 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-port")) {
+				n = atoi(optarg);
+				if (n >= 0)
+					geneve_udp_port = (uint16_t)n;
+				else
+					rte_exit(EXIT_FAILURE,
+						 "geneve-port must be >= 0\n");
+			}
 			if (!strcmp(lgopts[opt_idx].name, "print-event"))
 				if (parse_event_printing_config(optarg, 1)) {
 					rte_exit(EXIT_FAILURE,
doc/guides/testpmd_app_ug/run_app.rst +5 -0
index e2539f6..dbd22f1 100644
@@ -426,6 +426,11 @@ The command line options are:
     Set the UDP port number of tunnel VXLAN-GPE to N.
     The default value is 4790.
 
+*   ``--geneve-port=N``
+
+    Set the UDP port number of tunnel GENEVE to N.
+    The default value is 6081.
+
 *   ``--mlockall``
 
     Enable locking all memory.
Signature · 1 line
2.8.4
#39 lore raw

PATCH v4 3/3 app/testpmd: reduce tunnel parsing code duplication

In reply to Ophir Munk

From: Ophir Munk <[email protected]>

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.

---
 app/test-pmd/csumonly.c    | 72 +++++++++++++---------------------------------
 lib/librte_net/rte_vxlan.h |  1 +
 2 files changed, 21 insertions(+), 52 deletions(-)
app/test-pmd/csumonly.c +20 -52
index eb87b9b..6f24a14 100644
@@ -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 +
@@ -257,11 +264,7 @@ parse_vxlan(struct rte_udp_hdr *udp_hdr,
 		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 +294,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 +304,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 +314,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 +326,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 +392,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 +401,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 +410,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);
 
lib/librte_net/rte_vxlan.h +1 -0
index c23c10c..2ad6061 100644
@@ -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.
Signature · 1 line
2.8.4
#40 lore raw

PATCH v3 2/3 app/testpmd: enable configuring GENEVE port

In reply to Ophir Munk

From: Ophir Munk <[email protected]>

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.

---
 app/test-pmd/parameters.c             | 14 ++++++++++++--
 doc/guides/testpmd_app_ug/run_app.rst |  5 +++++
 2 files changed, 17 insertions(+), 2 deletions(-)
app/test-pmd/parameters.c +12 -2
index 7845153..25e2935 100644
@@ -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-port= | "
+	       "--record-core-cycles | --record-burst-stats]\n",
 	       progname);
 #ifdef RTE_LIBRTE_CMDLINE
 	printf("  --interactive: run in interactive mode.\n");
@@ -200,6 +200,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-port=N: UPD port of tunnel GENEVE\n");
 	printf("  --mlockall: lock all memory\n");
 	printf("  --no-mlockall: do not lock all memory\n");
 	printf("  --mp-alloc <native|anon|xmem|xmemhuge>: mempool allocation method.\n"
@@ -667,6 +668,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-port",		1, 0, 0 },
 		{ "mlockall",			0, 0, 0 },
 		{ "no-mlockall",		0, 0, 0 },
 		{ "mp-alloc",			1, 0, 0 },
@@ -1303,6 +1305,14 @@ 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-port")) {
+				n = atoi(optarg);
+				if (n >= 0)
+					geneve_udp_port = (uint16_t)n;
+				else
+					rte_exit(EXIT_FAILURE,
+						 "geneve-port must be >= 0\n");
+			}
 			if (!strcmp(lgopts[opt_idx].name, "print-event"))
 				if (parse_event_printing_config(optarg, 1)) {
 					rte_exit(EXIT_FAILURE,
doc/guides/testpmd_app_ug/run_app.rst +5 -0
index e2539f6..dbd22f1 100644
@@ -426,6 +426,11 @@ The command line options are:
     Set the UDP port number of tunnel VXLAN-GPE to N.
     The default value is 4790.
 
+*   ``--geneve-port=N``
+
+    Set the UDP port number of tunnel GENEVE to N.
+    The default value is 6081.
+
 *   ``--mlockall``
 
     Enable locking all memory.
Signature · 1 line
2.8.4
#41 lore raw

PATCH v3 3/3 app/testpmd: reduce tunnel parsing code duplication

In reply to Ophir Munk

From: Ophir Munk <[email protected]>

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.

---
 app/test-pmd/csumonly.c    | 72 +++++++++++++---------------------------------
 lib/librte_net/rte_vxlan.h |  1 +
 2 files changed, 21 insertions(+), 52 deletions(-)
app/test-pmd/csumonly.c +20 -52
index eb87b9b..6f24a14 100644
@@ -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 +
@@ -257,11 +264,7 @@ parse_vxlan(struct rte_udp_hdr *udp_hdr,
 		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 +294,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 +304,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 +314,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 +326,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 +392,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 +401,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 +410,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);
 
lib/librte_net/rte_vxlan.h +1 -0
index c23c10c..2ad6061 100644
@@ -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.
Signature · 1 line
2.8.4
#42 lore raw

PATCH v2 2/3 app/testpmd: enable configuring GENEVE port

In reply to Ophir Munk

From: Ophir Munk <[email protected]>

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.

---
 app/test-pmd/parameters.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
app/test-pmd/parameters.c +12 -1
index 7cb0e3d..0d135b0 100644
@@ -70,7 +70,8 @@ usage(char* progname)
 	       "--rxpt= | --rxht= | --rxwt= | --rxfreet= | "
 	       "--txpt= | --txht= | --txwt= | --txfreet= | "
 	       "--txrst= | --tx-offloads= | | --rx-offloads= | "
-	       "--vxlan-gpe-port= ]\n",
+	       "--vxlan-gpe-port= ] "
+	       "--geneve-port= ]\n",
 	       progname);
 #ifdef RTE_LIBRTE_CMDLINE
 	printf("  --interactive: run in interactive mode.\n");
@@ -199,6 +200,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-port=N: UPD port of tunnel GENEVE\n");
 	printf("  --mlockall: lock all memory\n");
 	printf("  --no-mlockall: do not lock all memory\n");
 	printf("  --mp-alloc <native|anon|xmem|xmemhuge>: mempool allocation method.\n"
@@ -664,6 +666,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-port",		1, 0, 0 },
 		{ "mlockall",			0, 0, 0 },
 		{ "no-mlockall",		0, 0, 0 },
 		{ "mp-alloc",			1, 0, 0 },
@@ -1298,6 +1301,14 @@ 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-port")) {
+				n = atoi(optarg);
+				if (n >= 0)
+					geneve_udp_port = (uint16_t)n;
+				else
+					rte_exit(EXIT_FAILURE,
+						 "geneve-port must be >= 0\n");
+			}
 			if (!strcmp(lgopts[opt_idx].name, "print-event"))
 				if (parse_event_printing_config(optarg, 1)) {
 					rte_exit(EXIT_FAILURE,
Signature · 1 line
2.8.4
#43 lore raw

Re: [dpdk-dev] [PATCH v2 2/3] app/testpmd: enable configuring GENEVE port

Quoted 17 lines · Ophir Munk

From: Ophir Munk <[email protected]>

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.

---
 app/test-pmd/parameters.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
app/test-pmd/parameters.c +0 -0
index 7cb0e3d..0d135b0 100644

app/test-pmd/parameters.c usage(char* progname) · line 75

Quoted 7 lines
app/test-pmd/parameters.c +2 -1
@@ -70,7 +70,8 @@ usage(char* progname)
 	       "--rxpt= | --rxht= | --rxwt= | --rxfreet= | "
 	       "--txpt= | --txht= | --txwt= | --txfreet= | "
 	       "--txrst= | --tx-offloads= | | --rx-offloads= | "
-	       "--vxlan-gpe-port= ]\n",
+	       "--vxlan-gpe-port= ] "
+	       "--geneve-port= ]\n",
 	       progname);

Hi Ophir,

Is there a command line to update the geneve port?

I can see there are some parameter for other tunneling too, but do you find providing parameter useful? I think command line better since it is more flexible, what do you think?

#44 lore raw

Re: [dpdk-dev] [PATCH v2 2/3] app/testpmd: enable configuring GENEVE port

Hi Ferruh,
I don't think that having the flexibility to specify the Geneve protocol in the command line will have an added value.
The reason is that any Geneve setup has a fixed protocol number for the duration of the test lifetime (fixed and synched by all the peers in the lab). The protocol number is not dynamic. So even if we could specify the protocol in the command line - it would be a onetime setting after testpmd startup. Therefore, it is simpler to have it as parameter only.

Regards,
Ophir

Quoted 43 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Monday, September 14, 2020 8:31 PM
To: Ophir Munk <[email protected]>; [email protected]; Wenzhuo Lu <[email protected]>; Beilei Xing <[email protected]>; Bernard Iremonger <[email protected]>
Cc: Ophir Munk <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2 2/3] app/testpmd: enable configuring GENEVE port

Quoted 17 lines · Ophir Munk

From: Ophir Munk <[email protected]>

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.

---
 app/test-pmd/parameters.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
app/test-pmd/parameters.c +0 -0
index 7cb0e3d..0d135b0 100644

app/test-pmd/parameters.c usage(char* progname) · line 75

Quoted 7 lines
app/test-pmd/parameters.c +2 -1
@@ -70,7 +70,8 @@ usage(char* progname)
 	       "--rxpt= | --rxht= | --rxwt= | --rxfreet= | "
 	       "--txpt= | --txht= | --txwt= | --txfreet= | "
 	       "--txrst= | --tx-offloads= | | --rx-offloads= | "
-	       "--vxlan-gpe-port= ]\n",
+	       "--vxlan-gpe-port= ] "
+	       "--geneve-port= ]\n",
 	       progname);

Hi Ophir,

Is there a command line to update the geneve port?

I can see there are some parameter for other tunneling too, but do you find providing parameter useful? I think command line better since it is more flexible, what do you think?

#45 lore raw

Re: [dpdk-dev] [PATCH v2 2/3] app/testpmd: enable configuring GENEVE port

Quoted 5 lines · Ophir Munk

Hi Ferruh,
I don't think that having the flexibility to specify the Geneve protocol in the command line will have an added value.
The reason is that any Geneve setup has a fixed protocol number for the duration of the test lifetime (fixed and synched by all the peers in the lab). The protocol number is not dynamic. So even if we could specify the protocol in the command line - it would be a onetime setting after testpmd startup. Therefore, it is simpler to have it as parameter only.

OK, if you think there is a value.

Overall, not specific to this patch, it bothers me not having any guideline what to add as a parameter, and not able to say what is implemented as parameter without searching for it ...

Quoted 46 lines

Regards,
Ophir

Quoted 43 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Monday, September 14, 2020 8:31 PM
To: Ophir Munk <[email protected]>; [email protected]; Wenzhuo Lu <[email protected]>; Beilei Xing <[email protected]>; Bernard Iremonger <[email protected]>
Cc: Ophir Munk <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2 2/3] app/testpmd: enable configuring GENEVE port

Quoted 17 lines · Ophir Munk

From: Ophir Munk <[email protected]>

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.

---
 app/test-pmd/parameters.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
app/test-pmd/parameters.c +0 -0
index 7cb0e3d..0d135b0 100644

app/test-pmd/parameters.c usage(char* progname) · line 75

Quoted 7 lines
app/test-pmd/parameters.c +2 -1
@@ -70,7 +70,8 @@ usage(char* progname)
 	       "--rxpt= | --rxht= | --rxwt= | --rxfreet= | "
 	       "--txpt= | --txht= | --txwt= | --txfreet= | "
 	       "--txrst= | --tx-offloads= | | --rx-offloads= | "
-	       "--vxlan-gpe-port= ]\n",
+	       "--vxlan-gpe-port= ] "
+	       "--geneve-port= ]\n",
 	       progname);

Hi Ophir,

Is there a command line to update the geneve port?

I can see there are some parameter for other tunneling too, but do you find providing parameter useful? I think command line better since it is more flexible, what do you think?

#46 lore raw

Re: [dpdk-dev] [PATCH v2 2/3] app/testpmd: enable configuring GENEVE port

Hi Ferruh,
I added to documentation the new parameter "--geneve-port=N" (second patch in the series). I also rebased the series and sent v3.

Regards,
Ophir

Quoted 19 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>

Quoted 1 line

I don't think that having the flexibility to specify the Geneve protocol in the

command line will have an added value.

Quoted 1 line

The reason is that any Geneve setup has a fixed protocol number for the

duration of the test lifetime (fixed and synched by all the peers in the lab). The protocol number is not dynamic.

Quoted 1 line

So even if we could specify the protocol in the command line - it would be

a onetime setting after testpmd startup. Therefore, it is simpler to have it as parameter only.

Quoted 1 line

Overall, not specific to this patch, it bothers me not having any guideline what to add as a parameter, and not able to say what is implemented as parameter without searching for it ...

Quoted 3 lines

Regards,
Ophir

#47 lore raw

Re: [dpdk-dev] [PATCH v2 2/3] app/testpmd: enable configuring GENEVE port

Hi,
V4 sent with misspelling corrections.

Regards,
Ophir

Quoted 18 lines

-----Original Message-----
From: Ophir Munk
Sent: Tuesday, September 15, 2020 3:59 PM
To: Ferruh Yigit <[email protected]>; [email protected]; Wenzhuo Lu <[email protected]>; Beilei Xing <[email protected]>; Bernard Iremonger <[email protected]>
Cc: Ophir Munk <[email protected]>; Raslan Darawsheh <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 2/3] app/testpmd: enable configuring GENEVE port

Hi Ferruh,
I added to documentation the new parameter "--geneve-port=N" (second patch in the series).
I also rebased the series and sent v3.

Regards,
Ophir

#48 lore raw

PATCH v2 3/3 app/testpmd: reduce tunnel parsing code duplication

In reply to Ophir Munk

From: Ophir Munk <[email protected]>

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.

---
 app/test-pmd/csumonly.c    | 72 +++++++++++++---------------------------------
 lib/librte_net/rte_vxlan.h |  1 +
 2 files changed, 21 insertions(+), 52 deletions(-)
app/test-pmd/csumonly.c +20 -52
index 5f29868..3a0e46e 100644
@@ -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 +
@@ -257,11 +264,7 @@ parse_vxlan(struct rte_udp_hdr *udp_hdr,
 		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 +294,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 +304,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 +314,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 +326,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 +392,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 +401,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 +410,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);
 
lib/librte_net/rte_vxlan.h +1 -0
index c23c10c..2ad6061 100644
@@ -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.
Signature · 1 line
2.8.4
#49 lore raw
In reply to Ophir Munk

Hello Wenzhou, Beilei, Bernard,
I saw no comments regarding v1 or v2 of this patch set.
Please let me know if you have any question. Otherwise - can it be merged?

Regards,
Ophir

Quoted 37 lines

-----Original Message-----
From: Ophir Munk <[email protected]>
Sent: Thursday, August 27, 2020 10:03 AM
To: [email protected]; Wenzhuo Lu <[email protected]>; Beilei Xing <[email protected]>; Bernard Iremonger <[email protected]>
Cc: Ophir Munk <[email protected]>
Subject: [PATCH v2 0/3] Add GENEVE protocol parsing to testpmd

This patchset adds GENEVE parsing of inner protocols (IPv4-0x0800, IPv6- 0x86dd,
Ethernet-0x6558) based on IETF draft-ietf-nvo3-geneve-09.

v1:
Initial version
v2:
Rebased + Minor update in protocol options field:
char opts[0] ===> uint8_t opts[]

Ophir Munk (3):
app/testpmd: add GENEVE parsing app/testpmd: enable configuring GENEVE port app/testpmd: reduce tunnel parsing code duplication

 app/test-pmd/csumonly.c     | 120 ++++++++++++++++++++++++++++---------
-------
 app/test-pmd/parameters.c   |  13 ++++-
 app/test-pmd/testpmd.h      |   1 +
 lib/librte_net/Makefile     |   2 +-
 lib/librte_net/meson.build  |   3 +-
 lib/librte_net/rte_geneve.h |  72 ++++++++++++++++++++++++++
 lib/librte_net/rte_vxlan.h  |   1 +
 7 files changed, 167 insertions(+), 45 deletions(-)  create mode 100644

lib/librte_net/rte_geneve.h

--
2.8.4