LIST,
AGED,
ISOLATE,
+ TUNNEL,
+
+ /* Tunnel arguments. */
+ TUNNEL_CREATE,
+ TUNNEL_CREATE_TYPE,
+ TUNNEL_LIST,
+ TUNNEL_DESTROY,
+ TUNNEL_DESTROY_ID,
/* Destroy arguments. */
DESTROY_RULE,
INGRESS,
EGRESS,
TRANSFER,
+ TUNNEL_SET,
+ TUNNEL_MATCH,
/* Shared action arguments */
SHARED_ACTION_CREATE,
ITEM_ETH_DST,
ITEM_ETH_SRC,
ITEM_ETH_TYPE,
+ ITEM_ETH_HAS_VLAN,
ITEM_VLAN,
ITEM_VLAN_TCI,
ITEM_VLAN_PCP,
ITEM_VLAN_DEI,
ITEM_VLAN_VID,
ITEM_VLAN_INNER_TYPE,
+ ITEM_VLAN_HAS_MORE_VLAN,
ITEM_IPV4,
ITEM_IPV4_TOS,
+ ITEM_IPV4_FRAGMENT_OFFSET,
ITEM_IPV4_TTL,
ITEM_IPV4_PROTO,
ITEM_IPV4_SRC,
ITEM_IPV6_HOP,
ITEM_IPV6_SRC,
ITEM_IPV6_DST,
+ ITEM_IPV6_HAS_FRAG_EXT,
ITEM_ICMP,
ITEM_ICMP_TYPE,
ITEM_ICMP_CODE,
ITEM_ARP_ETH_IPV4_TPA,
ITEM_IPV6_EXT,
ITEM_IPV6_EXT_NEXT_HDR,
+ ITEM_IPV6_FRAG_EXT,
+ ITEM_IPV6_FRAG_EXT_NEXT_HDR,
+ ITEM_IPV6_FRAG_EXT_FRAG_DATA,
ITEM_ICMP6,
ITEM_ICMP6_TYPE,
ITEM_ICMP6_CODE,
} sa; /* Shared action query arguments */
struct {
struct rte_flow_attr attr;
+ struct tunnel_ops tunnel_ops;
struct rte_flow_item *pattern;
struct rte_flow_action *actions;
uint32_t pattern_n;
INGRESS,
EGRESS,
TRANSFER,
+ TUNNEL_SET,
+ TUNNEL_MATCH,
PATTERN,
ZERO,
};
+static const enum index tunnel_create_attr[] = {
+ TUNNEL_CREATE,
+ TUNNEL_CREATE_TYPE,
+ END,
+ ZERO,
+};
+
+static const enum index tunnel_destroy_attr[] = {
+ TUNNEL_DESTROY,
+ TUNNEL_DESTROY_ID,
+ END,
+ ZERO,
+};
+
+static const enum index tunnel_list_attr[] = {
+ TUNNEL_LIST,
+ END,
+ ZERO,
+};
+
static const enum index next_destroy_attr[] = {
DESTROY_RULE,
END,
ITEM_VXLAN_GPE,
ITEM_ARP_ETH_IPV4,
ITEM_IPV6_EXT,
+ ITEM_IPV6_FRAG_EXT,
ITEM_ICMP6,
ITEM_ICMP6_ND_NS,
ITEM_ICMP6_ND_NA,
ITEM_ETH_DST,
ITEM_ETH_SRC,
ITEM_ETH_TYPE,
+ ITEM_ETH_HAS_VLAN,
ITEM_NEXT,
ZERO,
};
ITEM_VLAN_DEI,
ITEM_VLAN_VID,
ITEM_VLAN_INNER_TYPE,
+ ITEM_VLAN_HAS_MORE_VLAN,
ITEM_NEXT,
ZERO,
};
static const enum index item_ipv4[] = {
ITEM_IPV4_TOS,
+ ITEM_IPV4_FRAGMENT_OFFSET,
ITEM_IPV4_TTL,
ITEM_IPV4_PROTO,
ITEM_IPV4_SRC,
ITEM_IPV6_HOP,
ITEM_IPV6_SRC,
ITEM_IPV6_DST,
+ ITEM_IPV6_HAS_FRAG_EXT,
ITEM_NEXT,
ZERO,
};
ZERO,
};
+static const enum index item_ipv6_frag_ext[] = {
+ ITEM_IPV6_FRAG_EXT_NEXT_HDR,
+ ITEM_IPV6_FRAG_EXT_FRAG_DATA,
+ ITEM_NEXT,
+ ZERO,
+};
+
static const enum index item_icmp6[] = {
ITEM_ICMP6_TYPE,
ITEM_ICMP6_CODE,
static int parse_isolate(struct context *, const struct token *,
const char *, unsigned int,
void *, unsigned int);
+static int parse_tunnel(struct context *, const struct token *,
+ const char *, unsigned int,
+ void *, unsigned int);
static int parse_int(struct context *, const struct token *,
const char *, unsigned int,
void *, unsigned int);
LIST,
AGED,
QUERY,
- ISOLATE)),
+ ISOLATE,
+ TUNNEL)),
.call = parse_init,
},
/* Top-level command. */
ARGS_ENTRY(struct buffer, port)),
.call = parse_isolate,
},
+ [TUNNEL] = {
+ .name = "tunnel",
+ .help = "new tunnel API",
+ .next = NEXT(NEXT_ENTRY
+ (TUNNEL_CREATE, TUNNEL_LIST, TUNNEL_DESTROY)),
+ .call = parse_tunnel,
+ },
+ /* Tunnel arguments. */
+ [TUNNEL_CREATE] = {
+ .name = "create",
+ .help = "create new tunnel object",
+ .next = NEXT(tunnel_create_attr, NEXT_ENTRY(PORT_ID)),
+ .args = ARGS(ARGS_ENTRY(struct buffer, port)),
+ .call = parse_tunnel,
+ },
+ [TUNNEL_CREATE_TYPE] = {
+ .name = "type",
+ .help = "create new tunnel",
+ .next = NEXT(tunnel_create_attr, NEXT_ENTRY(FILE_PATH)),
+ .args = ARGS(ARGS_ENTRY(struct tunnel_ops, type)),
+ .call = parse_tunnel,
+ },
+ [TUNNEL_DESTROY] = {
+ .name = "destroy",
+ .help = "destroy tunel",
+ .next = NEXT(tunnel_destroy_attr, NEXT_ENTRY(PORT_ID)),
+ .args = ARGS(ARGS_ENTRY(struct buffer, port)),
+ .call = parse_tunnel,
+ },
+ [TUNNEL_DESTROY_ID] = {
+ .name = "id",
+ .help = "tunnel identifier to testroy",
+ .next = NEXT(tunnel_destroy_attr, NEXT_ENTRY(UNSIGNED)),
+ .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
+ .call = parse_tunnel,
+ },
+ [TUNNEL_LIST] = {
+ .name = "list",
+ .help = "list existing tunnels",
+ .next = NEXT(tunnel_list_attr, NEXT_ENTRY(PORT_ID)),
+ .args = ARGS(ARGS_ENTRY(struct buffer, port)),
+ .call = parse_tunnel,
+ },
/* Destroy arguments. */
[DESTROY_RULE] = {
.name = "rule",
.next = NEXT(next_vc_attr),
.call = parse_vc,
},
+ [TUNNEL_SET] = {
+ .name = "tunnel_set",
+ .help = "tunnel steer rule",
+ .next = NEXT(next_vc_attr, NEXT_ENTRY(UNSIGNED)),
+ .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
+ .call = parse_vc,
+ },
+ [TUNNEL_MATCH] = {
+ .name = "tunnel_match",
+ .help = "tunnel match rule",
+ .next = NEXT(next_vc_attr, NEXT_ENTRY(UNSIGNED)),
+ .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
+ .call = parse_vc,
+ },
/* Validate/create pattern. */
[PATTERN] = {
.name = "pattern",
.next = NEXT(item_eth, NEXT_ENTRY(UNSIGNED), item_param),
.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, type)),
},
+ [ITEM_ETH_HAS_VLAN] = {
+ .name = "has_vlan",
+ .help = "packet header contains VLAN",
+ .next = NEXT(item_eth, NEXT_ENTRY(UNSIGNED), item_param),
+ .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_eth,
+ has_vlan, 1)),
+ },
[ITEM_VLAN] = {
.name = "vlan",
.help = "match 802.1Q/ad VLAN tag",
.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan,
inner_type)),
},
+ [ITEM_VLAN_HAS_MORE_VLAN] = {
+ .name = "has_more_vlan",
+ .help = "packet header contains another VLAN",
+ .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
+ .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vlan,
+ has_more_vlan, 1)),
+ },
[ITEM_IPV4] = {
.name = "ipv4",
.help = "match IPv4 header",
.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
hdr.type_of_service)),
},
+ [ITEM_IPV4_FRAGMENT_OFFSET] = {
+ .name = "fragment_offset",
+ .help = "fragmentation flags and fragment offset",
+ .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
+ .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
+ hdr.fragment_offset)),
+ },
[ITEM_IPV4_TTL] = {
.name = "ttl",
.help = "time to live",
.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
hdr.dst_addr)),
},
+ [ITEM_IPV6_HAS_FRAG_EXT] = {
+ .name = "has_frag_ext",
+ .help = "fragment packet attribute",
+ .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
+ .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_ipv6,
+ has_frag_ext, 1)),
+ },
[ITEM_ICMP] = {
.name = "icmp",
.help = "match ICMP header",
.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_ext,
next_hdr)),
},
+ [ITEM_IPV6_FRAG_EXT] = {
+ .name = "ipv6_frag_ext",
+ .help = "match presence of IPv6 fragment extension header",
+ .priv = PRIV_ITEM(IPV6_FRAG_EXT,
+ sizeof(struct rte_flow_item_ipv6_frag_ext)),
+ .next = NEXT(item_ipv6_frag_ext),
+ .call = parse_vc,
+ },
+ [ITEM_IPV6_FRAG_EXT_NEXT_HDR] = {
+ .name = "next_hdr",
+ .help = "next header",
+ .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(UNSIGNED),
+ item_param),
+ .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ipv6_frag_ext,
+ hdr.next_header)),
+ },
+ [ITEM_IPV6_FRAG_EXT_FRAG_DATA] = {
+ .name = "frag_data",
+ .help = "Fragment flags and offset",
+ .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(UNSIGNED),
+ item_param),
+ .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_frag_ext,
+ hdr.frag_data)),
+ },
[ITEM_ICMP6] = {
.name = "icmp6",
.help = "match any ICMPv6 header",
return len;
}
ctx->objdata = 0;
- ctx->object = &out->args.vc.attr;
+ switch (ctx->curr) {
+ default:
+ ctx->object = &out->args.vc.attr;
+ break;
+ case TUNNEL_SET:
+ case TUNNEL_MATCH:
+ ctx->object = &out->args.vc.tunnel_ops;
+ break;
+ }
ctx->objmask = NULL;
switch (ctx->curr) {
case GROUP:
case PRIORITY:
return len;
+ case TUNNEL_SET:
+ out->args.vc.tunnel_ops.enabled = 1;
+ out->args.vc.tunnel_ops.actions = 1;
+ return len;
+ case TUNNEL_MATCH:
+ out->args.vc.tunnel_ops.enabled = 1;
+ out->args.vc.tunnel_ops.items = 1;
+ return len;
case INGRESS:
out->args.vc.attr.ingress = 1;
return len;
return len;
}
+static int
+parse_tunnel(struct context *ctx, const struct token *token,
+ const char *str, unsigned int len,
+ void *buf, unsigned int size)
+{
+ struct buffer *out = buf;
+
+ /* Token name must match. */
+ if (parse_default(ctx, token, str, len, NULL, 0) < 0)
+ return -1;
+ /* Nothing else to do if there is no buffer. */
+ if (!out)
+ return len;
+ if (!out->command) {
+ if (ctx->curr != TUNNEL)
+ return -1;
+ if (sizeof(*out) > size)
+ return -1;
+ out->command = ctx->curr;
+ ctx->objdata = 0;
+ ctx->object = out;
+ ctx->objmask = NULL;
+ } else {
+ switch (ctx->curr) {
+ default:
+ break;
+ case TUNNEL_CREATE:
+ case TUNNEL_DESTROY:
+ case TUNNEL_LIST:
+ out->command = ctx->curr;
+ break;
+ case TUNNEL_CREATE_TYPE:
+ case TUNNEL_DESTROY_ID:
+ ctx->object = &out->args.vc.tunnel_ops;
+ break;
+ }
+ }
+
+ return len;
+}
+
/**
* Parse signed/unsigned integers 8 to 64-bit long.
*
break;
case VALIDATE:
port_flow_validate(in->port, &in->args.vc.attr,
- in->args.vc.pattern, in->args.vc.actions);
+ in->args.vc.pattern, in->args.vc.actions,
+ &in->args.vc.tunnel_ops);
break;
case CREATE:
port_flow_create(in->port, &in->args.vc.attr,
- in->args.vc.pattern, in->args.vc.actions);
+ in->args.vc.pattern, in->args.vc.actions,
+ &in->args.vc.tunnel_ops);
break;
case DESTROY:
port_flow_destroy(in->port, in->args.destroy.rule_n,
case AGED:
port_flow_aged(in->port, in->args.aged.destroy);
break;
+ case TUNNEL_CREATE:
+ port_flow_tunnel_create(in->port, &in->args.vc.tunnel_ops);
+ break;
+ case TUNNEL_DESTROY:
+ port_flow_tunnel_destroy(in->port, in->args.vc.tunnel_ops.id);
+ break;
+ case TUNNEL_LIST:
+ port_flow_tunnel_list(in->port);
+ break;
default:
break;
}