#include <rte_flow.h>
#include <rte_gro.h>
#include <rte_gso.h>
+#include <rte_geneve.h>
#include "testpmd.h"
#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 {
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)
}
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;
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];
* ``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::
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).
'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']
--- /dev/null
+/* 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>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** GENEVE default port. */
+#define RTE_GENEVE_DEFAULT_PORT 6081
+
+/**
+ * GENEVE protocol header. (draft-ietf-nvo3-geneve-09)
+ * Contains:
+ * 2-bits version (must be 0).
+ * 6-bits option length in four byte multiples, not including the eight
+ * bytes of the fixed tunnel header.
+ * 1-bit control packet.
+ * 1-bit critical options in packet.
+ * 6-bits reserved
+ * 16-bits Protocol Type. The protocol data unit after the Geneve header
+ * following the EtherType convention. Ethernet itself is represented by
+ * the value 0x6558.
+ * 24-bits Virtual Network Identifier (VNI). Virtual network unique identified.
+ * 8-bits reserved bits (must be 0 on transmission and ignored on receipt).
+ * More-bits (optional) variable length options.
+ */
+__extension__
+struct rte_geneve_hdr {
+#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
+ uint8_t ver:2; /**< Version. */
+ uint8_t opt_len:6; /**< Options length. */
+ uint8_t oam:1; /**< Control packet. */
+ uint8_t critical:1; /**< Critical packet. */
+ uint8_t reserved1:6; /**< Reserved. */
+#else
+ uint8_t opt_len:6; /**< Options length. */
+ uint8_t ver:2; /**< Version. */
+ uint8_t reserved1:6; /**< Reserved. */
+ uint8_t critical:1; /**< Critical packet. */
+ uint8_t oam:1; /**< Control packet. */
+#endif
+ rte_be16_t proto; /**< Protocol type. */
+ uint8_t vni[3]; /**< Virtual network identifier. */
+ uint8_t reserved2; /**< Reserved. */
+ uint32_t opts[]; /**< Variable length options. */
+} __rte_packed;
+
+/* GENEVE ETH next protocol types */
+#define RTE_GENEVE_TYPE_ETH 0x6558 /**< Ethernet Protocol. */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* RTE_GENEVE_H_ */