app/testpmd: introduce new tunnel VXLAN-GPE
Add VXLAN-GPE support to csum forwarding engine and rte flow. Signed-off-by: Xueming Li <xuemingl@mellanox.com> Acked-by: Adrien Mazarguil <adrien.mazarguil@6wind.com> Acked-by: Thomas Monjalon <thomas@monjalon.net>
This commit is contained in:
parent
063f39f26d
commit
39e5e20f0d
@ -154,6 +154,8 @@ enum index {
|
|||||||
ITEM_GENEVE,
|
ITEM_GENEVE,
|
||||||
ITEM_GENEVE_VNI,
|
ITEM_GENEVE_VNI,
|
||||||
ITEM_GENEVE_PROTO,
|
ITEM_GENEVE_PROTO,
|
||||||
|
ITEM_VXLAN_GPE,
|
||||||
|
ITEM_VXLAN_GPE_VNI,
|
||||||
|
|
||||||
/* Validate/create actions. */
|
/* Validate/create actions. */
|
||||||
ACTIONS,
|
ACTIONS,
|
||||||
@ -470,6 +472,7 @@ static const enum index next_item[] = {
|
|||||||
ITEM_GTPC,
|
ITEM_GTPC,
|
||||||
ITEM_GTPU,
|
ITEM_GTPU,
|
||||||
ITEM_GENEVE,
|
ITEM_GENEVE,
|
||||||
|
ITEM_VXLAN_GPE,
|
||||||
ZERO,
|
ZERO,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -626,6 +629,12 @@ static const enum index item_geneve[] = {
|
|||||||
ZERO,
|
ZERO,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const enum index item_vxlan_gpe[] = {
|
||||||
|
ITEM_VXLAN_GPE_VNI,
|
||||||
|
ITEM_NEXT,
|
||||||
|
ZERO,
|
||||||
|
};
|
||||||
|
|
||||||
static const enum index next_action[] = {
|
static const enum index next_action[] = {
|
||||||
ACTION_END,
|
ACTION_END,
|
||||||
ACTION_VOID,
|
ACTION_VOID,
|
||||||
@ -1560,6 +1569,21 @@ static const struct token token_list[] = {
|
|||||||
.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve,
|
.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve,
|
||||||
protocol)),
|
protocol)),
|
||||||
},
|
},
|
||||||
|
[ITEM_VXLAN_GPE] = {
|
||||||
|
.name = "vxlan-gpe",
|
||||||
|
.help = "match VXLAN-GPE header",
|
||||||
|
.priv = PRIV_ITEM(VXLAN_GPE,
|
||||||
|
sizeof(struct rte_flow_item_vxlan_gpe)),
|
||||||
|
.next = NEXT(item_vxlan_gpe),
|
||||||
|
.call = parse_vc,
|
||||||
|
},
|
||||||
|
[ITEM_VXLAN_GPE_VNI] = {
|
||||||
|
.name = "vni",
|
||||||
|
.help = "VXLAN-GPE identifier",
|
||||||
|
.next = NEXT(item_vxlan_gpe, NEXT_ENTRY(UNSIGNED), item_param),
|
||||||
|
.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
|
||||||
|
vni)),
|
||||||
|
},
|
||||||
|
|
||||||
/* Validate/create actions. */
|
/* Validate/create actions. */
|
||||||
[ACTIONS] = {
|
[ACTIONS] = {
|
||||||
|
@ -1014,6 +1014,7 @@ static const struct {
|
|||||||
MK_FLOW_ITEM(GTPC, sizeof(struct rte_flow_item_gtp)),
|
MK_FLOW_ITEM(GTPC, sizeof(struct rte_flow_item_gtp)),
|
||||||
MK_FLOW_ITEM(GTPU, sizeof(struct rte_flow_item_gtp)),
|
MK_FLOW_ITEM(GTPU, sizeof(struct rte_flow_item_gtp)),
|
||||||
MK_FLOW_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)),
|
MK_FLOW_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)),
|
||||||
|
MK_FLOW_ITEM(VXLAN_GPE, sizeof(struct rte_flow_item_vxlan_gpe)),
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Pattern item specification types. */
|
/** Pattern item specification types. */
|
||||||
@ -3132,6 +3133,7 @@ flowtype_to_str(uint16_t flow_type)
|
|||||||
{"vxlan", RTE_ETH_FLOW_VXLAN},
|
{"vxlan", RTE_ETH_FLOW_VXLAN},
|
||||||
{"geneve", RTE_ETH_FLOW_GENEVE},
|
{"geneve", RTE_ETH_FLOW_GENEVE},
|
||||||
{"nvgre", RTE_ETH_FLOW_NVGRE},
|
{"nvgre", RTE_ETH_FLOW_NVGRE},
|
||||||
|
{"vxlan-gpe", RTE_ETH_FLOW_VXLAN_GPE},
|
||||||
};
|
};
|
||||||
|
|
||||||
for (i = 0; i < RTE_DIM(flowtype_str_table); i++) {
|
for (i = 0; i < RTE_DIM(flowtype_str_table); i++) {
|
||||||
|
@ -60,6 +60,8 @@
|
|||||||
#define _htons(x) (x)
|
#define _htons(x) (x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
uint16_t vxlan_gpe_udp_port = 4790;
|
||||||
|
|
||||||
/* structure that caches offload info for the current packet */
|
/* structure that caches offload info for the current packet */
|
||||||
struct testpmd_offload_info {
|
struct testpmd_offload_info {
|
||||||
uint16_t ethertype;
|
uint16_t ethertype;
|
||||||
@ -194,6 +196,70 @@ parse_vxlan(struct udp_hdr *udp_hdr,
|
|||||||
info->l2_len += ETHER_VXLAN_HLEN; /* add udp + vxlan */
|
info->l2_len += ETHER_VXLAN_HLEN; /* add udp + vxlan */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Parse a vxlan-gpe header */
|
||||||
|
static void
|
||||||
|
parse_vxlan_gpe(struct udp_hdr *udp_hdr,
|
||||||
|
struct testpmd_offload_info *info)
|
||||||
|
{
|
||||||
|
struct ether_hdr *eth_hdr;
|
||||||
|
struct ipv4_hdr *ipv4_hdr;
|
||||||
|
struct ipv6_hdr *ipv6_hdr;
|
||||||
|
struct vxlan_gpe_hdr *vxlan_gpe_hdr;
|
||||||
|
uint8_t vxlan_gpe_len = sizeof(*vxlan_gpe_hdr);
|
||||||
|
|
||||||
|
/* Check udp destination port. */
|
||||||
|
if (udp_hdr->dst_port != _htons(vxlan_gpe_udp_port))
|
||||||
|
return;
|
||||||
|
|
||||||
|
vxlan_gpe_hdr = (struct vxlan_gpe_hdr *)((char *)udp_hdr +
|
||||||
|
sizeof(struct udp_hdr));
|
||||||
|
|
||||||
|
if (!vxlan_gpe_hdr->proto || vxlan_gpe_hdr->proto ==
|
||||||
|
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;
|
||||||
|
|
||||||
|
ipv4_hdr = (struct ipv4_hdr *)((char *)vxlan_gpe_hdr +
|
||||||
|
vxlan_gpe_len);
|
||||||
|
|
||||||
|
parse_ipv4(ipv4_hdr, info);
|
||||||
|
info->ethertype = _htons(ETHER_TYPE_IPv4);
|
||||||
|
info->l2_len = 0;
|
||||||
|
|
||||||
|
} else if (vxlan_gpe_hdr->proto == 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;
|
||||||
|
|
||||||
|
ipv6_hdr = (struct ipv6_hdr *)((char *)vxlan_gpe_hdr +
|
||||||
|
vxlan_gpe_len);
|
||||||
|
|
||||||
|
info->ethertype = _htons(ETHER_TYPE_IPv6);
|
||||||
|
parse_ipv6(ipv6_hdr, info);
|
||||||
|
info->l2_len = 0;
|
||||||
|
|
||||||
|
} else if (vxlan_gpe_hdr->proto == 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;
|
||||||
|
|
||||||
|
eth_hdr = (struct ether_hdr *)((char *)vxlan_gpe_hdr +
|
||||||
|
vxlan_gpe_len);
|
||||||
|
|
||||||
|
parse_ethernet(eth_hdr, info);
|
||||||
|
} else
|
||||||
|
return;
|
||||||
|
|
||||||
|
info->l2_len += ETHER_VXLAN_GPE_HLEN;
|
||||||
|
}
|
||||||
|
|
||||||
/* Parse a gre header */
|
/* Parse a gre header */
|
||||||
static void
|
static void
|
||||||
parse_gre(struct simple_gre_hdr *gre_hdr, struct testpmd_offload_info *info)
|
parse_gre(struct simple_gre_hdr *gre_hdr, struct testpmd_offload_info *info)
|
||||||
@ -588,6 +654,10 @@ pkt_copy_split(const struct rte_mbuf *pkt)
|
|||||||
* Ether / (vlan) / IP|IP6 / UDP|TCP|SCTP .
|
* Ether / (vlan) / IP|IP6 / UDP|TCP|SCTP .
|
||||||
* Ether / (vlan) / outer IP|IP6 / outer UDP / VxLAN / Ether / IP|IP6 /
|
* Ether / (vlan) / outer IP|IP6 / outer UDP / VxLAN / Ether / IP|IP6 /
|
||||||
* UDP|TCP|SCTP
|
* UDP|TCP|SCTP
|
||||||
|
* Ether / (vlan) / outer IP|IP6 / outer UDP / VXLAN-GPE / Ether / IP|IP6 /
|
||||||
|
* UDP|TCP|SCTP
|
||||||
|
* Ether / (vlan) / outer IP|IP6 / outer UDP / VXLAN-GPE / IP|IP6 /
|
||||||
|
* UDP|TCP|SCTP
|
||||||
* Ether / (vlan) / outer IP|IP6 / GRE / Ether / IP|IP6 / UDP|TCP|SCTP
|
* Ether / (vlan) / outer IP|IP6 / GRE / Ether / IP|IP6 / UDP|TCP|SCTP
|
||||||
* Ether / (vlan) / outer IP|IP6 / GRE / IP|IP6 / UDP|TCP|SCTP
|
* Ether / (vlan) / outer IP|IP6 / GRE / IP|IP6 / UDP|TCP|SCTP
|
||||||
* Ether / (vlan) / outer IP|IP6 / IP|IP6 / UDP|TCP|SCTP
|
* Ether / (vlan) / outer IP|IP6 / IP|IP6 / UDP|TCP|SCTP
|
||||||
@ -691,9 +761,16 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
|
|||||||
|
|
||||||
udp_hdr = (struct udp_hdr *)((char *)l3_hdr +
|
udp_hdr = (struct udp_hdr *)((char *)l3_hdr +
|
||||||
info.l3_len);
|
info.l3_len);
|
||||||
parse_vxlan(udp_hdr, &info, m->packet_type);
|
parse_vxlan_gpe(udp_hdr, &info);
|
||||||
|
if (info.is_tunnel) {
|
||||||
|
tx_ol_flags |= PKT_TX_TUNNEL_VXLAN_GPE;
|
||||||
|
} else {
|
||||||
|
parse_vxlan(udp_hdr, &info,
|
||||||
|
m->packet_type);
|
||||||
if (info.is_tunnel)
|
if (info.is_tunnel)
|
||||||
tx_ol_flags |= PKT_TX_TUNNEL_VXLAN;
|
tx_ol_flags |=
|
||||||
|
PKT_TX_TUNNEL_VXLAN;
|
||||||
|
}
|
||||||
} else if (info.l4_proto == IPPROTO_GRE) {
|
} else if (info.l4_proto == IPPROTO_GRE) {
|
||||||
struct simple_gre_hdr *gre_hdr;
|
struct simple_gre_hdr *gre_hdr;
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ usage(char* progname)
|
|||||||
"--rss-ip | --rss-udp | "
|
"--rss-ip | --rss-udp | "
|
||||||
"--rxpt= | --rxht= | --rxwt= | --rxfreet= | "
|
"--rxpt= | --rxht= | --rxwt= | --rxfreet= | "
|
||||||
"--txpt= | --txht= | --txwt= | --txfreet= | "
|
"--txpt= | --txht= | --txwt= | --txfreet= | "
|
||||||
"--txrst= | --tx-offloads ]\n",
|
"--txrst= | --tx-offloads= | --vxlan-gpe-port= ]\n",
|
||||||
progname);
|
progname);
|
||||||
#ifdef RTE_LIBRTE_CMDLINE
|
#ifdef RTE_LIBRTE_CMDLINE
|
||||||
printf(" --interactive: run in interactive mode.\n");
|
printf(" --interactive: run in interactive mode.\n");
|
||||||
@ -187,6 +187,7 @@ usage(char* progname)
|
|||||||
"requests flow API isolated mode on all ports at initialization time.\n");
|
"requests flow API isolated mode on all ports at initialization time.\n");
|
||||||
printf(" --tx-offloads=0xXXXXXXXX: hexadecimal bitmask of TX queue offloads\n");
|
printf(" --tx-offloads=0xXXXXXXXX: hexadecimal bitmask of TX queue offloads\n");
|
||||||
printf(" --hot-plug: enable hot plug for device.\n");
|
printf(" --hot-plug: enable hot plug for device.\n");
|
||||||
|
printf(" --vxlan-gpe-port=N: UPD port of tunnel VXLAN-GPE\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef RTE_LIBRTE_CMDLINE
|
#ifdef RTE_LIBRTE_CMDLINE
|
||||||
@ -627,6 +628,7 @@ launch_args_parse(int argc, char** argv)
|
|||||||
{ "mask-event", 1, 0, 0 },
|
{ "mask-event", 1, 0, 0 },
|
||||||
{ "tx-offloads", 1, 0, 0 },
|
{ "tx-offloads", 1, 0, 0 },
|
||||||
{ "hot-plug", 0, 0, 0 },
|
{ "hot-plug", 0, 0, 0 },
|
||||||
|
{ "vxlan-gpe-port", 1, 0, 0 },
|
||||||
{ 0, 0, 0, 0 },
|
{ 0, 0, 0, 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1123,6 +1125,14 @@ launch_args_parse(int argc, char** argv)
|
|||||||
rte_exit(EXIT_FAILURE,
|
rte_exit(EXIT_FAILURE,
|
||||||
"tx-offloads must be >= 0\n");
|
"tx-offloads must be >= 0\n");
|
||||||
}
|
}
|
||||||
|
if (!strcmp(lgopts[opt_idx].name, "vxlan-gpe-port")) {
|
||||||
|
n = atoi(optarg);
|
||||||
|
if (n >= 0)
|
||||||
|
vxlan_gpe_udp_port = (uint16_t)n;
|
||||||
|
else
|
||||||
|
rte_exit(EXIT_FAILURE,
|
||||||
|
"vxlan-gpe-port must be >= 0\n");
|
||||||
|
}
|
||||||
if (!strcmp(lgopts[opt_idx].name, "print-event"))
|
if (!strcmp(lgopts[opt_idx].name, "print-event"))
|
||||||
if (parse_event_printing_config(optarg, 1)) {
|
if (parse_event_printing_config(optarg, 1)) {
|
||||||
rte_exit(EXIT_FAILURE,
|
rte_exit(EXIT_FAILURE,
|
||||||
|
@ -450,6 +450,8 @@ extern uint32_t retry_enabled;
|
|||||||
extern struct fwd_lcore **fwd_lcores;
|
extern struct fwd_lcore **fwd_lcores;
|
||||||
extern struct fwd_stream **fwd_streams;
|
extern struct fwd_stream **fwd_streams;
|
||||||
|
|
||||||
|
extern uint16_t vxlan_gpe_udp_port; /**< UDP port of tunnel VXLAN-GPE. */
|
||||||
|
|
||||||
extern portid_t nb_peer_eth_addrs; /**< Number of peer ethernet addresses. */
|
extern portid_t nb_peer_eth_addrs; /**< Number of peer ethernet addresses. */
|
||||||
extern struct ether_addr peer_eth_addrs[RTE_MAX_ETHPORTS];
|
extern struct ether_addr peer_eth_addrs[RTE_MAX_ETHPORTS];
|
||||||
|
|
||||||
|
@ -485,3 +485,8 @@ The commandline options are:
|
|||||||
* ``--hot-plug``
|
* ``--hot-plug``
|
||||||
|
|
||||||
Enable device event monitor machenism for hotplug.
|
Enable device event monitor machenism for hotplug.
|
||||||
|
|
||||||
|
* ``--vxlan-gpe-port=N``
|
||||||
|
|
||||||
|
Set the UDP port number of tunnel VXLAN-GPE to N.
|
||||||
|
The default value is 4790.
|
||||||
|
@ -3334,6 +3334,10 @@ This section lists supported pattern items and their attributes, if any.
|
|||||||
- ``vni {unsigned}``: virtual network identifier.
|
- ``vni {unsigned}``: virtual network identifier.
|
||||||
- ``protocol {unsigned}``: protocol type.
|
- ``protocol {unsigned}``: protocol type.
|
||||||
|
|
||||||
|
- ``vxlan-gpe``: match VXLAN-GPE header.
|
||||||
|
|
||||||
|
- ``vni {unsigned}``: VXLAN-GPE identifier.
|
||||||
|
|
||||||
Actions list
|
Actions list
|
||||||
^^^^^^^^^^^^
|
^^^^^^^^^^^^
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user