1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2016 6WIND S.A.
3 * Copyright 2016 Mellanox Technologies, Ltd
13 #include <arpa/inet.h>
14 #include <sys/socket.h>
16 #include <rte_string_fns.h>
17 #include <rte_common.h>
18 #include <rte_ethdev.h>
19 #include <rte_byteorder.h>
20 #include <cmdline_parse.h>
21 #include <cmdline_parse_etheraddr.h>
22 #include <cmdline_parse_string.h>
23 #include <cmdline_parse_num.h>
25 #include <rte_hexdump.h>
29 /** Parser token indices. */
52 /* Top-level command. */
54 /* Sub-leve commands. */
59 /* Top-level command. */
61 /* Sub-level commands. */
70 /* Destroy arguments. */
73 /* Query arguments. */
79 /* Validate/create arguments. */
86 /* Validate/create pattern. */
123 ITEM_VLAN_INNER_TYPE,
155 ITEM_E_TAG_GRP_ECID_B,
164 ITEM_GRE_C_RSVD0_VER,
181 ITEM_ARP_ETH_IPV4_SHA,
182 ITEM_ARP_ETH_IPV4_SPA,
183 ITEM_ARP_ETH_IPV4_THA,
184 ITEM_ARP_ETH_IPV4_TPA,
186 ITEM_IPV6_EXT_NEXT_HDR,
191 ITEM_ICMP6_ND_NS_TARGET_ADDR,
193 ITEM_ICMP6_ND_NA_TARGET_ADDR,
195 ITEM_ICMP6_ND_OPT_TYPE,
196 ITEM_ICMP6_ND_OPT_SLA_ETH,
197 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
198 ITEM_ICMP6_ND_OPT_TLA_ETH,
199 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
212 ITEM_HIGIG2_CLASSIFICATION,
218 ITEM_L2TPV3OIP_SESSION_ID,
222 /* Validate/create actions. */
242 ACTION_RSS_FUNC_DEFAULT,
243 ACTION_RSS_FUNC_TOEPLITZ,
244 ACTION_RSS_FUNC_SIMPLE_XOR,
245 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ,
257 ACTION_PHY_PORT_ORIGINAL,
258 ACTION_PHY_PORT_INDEX,
260 ACTION_PORT_ID_ORIGINAL,
264 ACTION_OF_SET_MPLS_TTL,
265 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
266 ACTION_OF_DEC_MPLS_TTL,
267 ACTION_OF_SET_NW_TTL,
268 ACTION_OF_SET_NW_TTL_NW_TTL,
269 ACTION_OF_DEC_NW_TTL,
270 ACTION_OF_COPY_TTL_OUT,
271 ACTION_OF_COPY_TTL_IN,
274 ACTION_OF_PUSH_VLAN_ETHERTYPE,
275 ACTION_OF_SET_VLAN_VID,
276 ACTION_OF_SET_VLAN_VID_VLAN_VID,
277 ACTION_OF_SET_VLAN_PCP,
278 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
280 ACTION_OF_POP_MPLS_ETHERTYPE,
282 ACTION_OF_PUSH_MPLS_ETHERTYPE,
289 ACTION_MPLSOGRE_ENCAP,
290 ACTION_MPLSOGRE_DECAP,
291 ACTION_MPLSOUDP_ENCAP,
292 ACTION_MPLSOUDP_DECAP,
294 ACTION_SET_IPV4_SRC_IPV4_SRC,
296 ACTION_SET_IPV4_DST_IPV4_DST,
298 ACTION_SET_IPV6_SRC_IPV6_SRC,
300 ACTION_SET_IPV6_DST_IPV6_DST,
302 ACTION_SET_TP_SRC_TP_SRC,
304 ACTION_SET_TP_DST_TP_DST,
310 ACTION_SET_MAC_SRC_MAC_SRC,
312 ACTION_SET_MAC_DST_MAC_DST,
314 ACTION_INC_TCP_SEQ_VALUE,
316 ACTION_DEC_TCP_SEQ_VALUE,
318 ACTION_INC_TCP_ACK_VALUE,
320 ACTION_DEC_TCP_ACK_VALUE,
323 ACTION_RAW_ENCAP_INDEX,
324 ACTION_RAW_ENCAP_INDEX_VALUE,
325 ACTION_RAW_DECAP_INDEX,
326 ACTION_RAW_DECAP_INDEX_VALUE,
329 ACTION_SET_TAG_INDEX,
332 ACTION_SET_META_DATA,
333 ACTION_SET_META_MASK,
334 ACTION_SET_IPV4_DSCP,
335 ACTION_SET_IPV4_DSCP_VALUE,
336 ACTION_SET_IPV6_DSCP,
337 ACTION_SET_IPV6_DSCP_VALUE,
340 /** Maximum size for pattern in struct rte_flow_item_raw. */
341 #define ITEM_RAW_PATTERN_SIZE 40
343 /** Storage size for struct rte_flow_item_raw including pattern. */
344 #define ITEM_RAW_SIZE \
345 (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE)
347 /** Maximum number of queue indices in struct rte_flow_action_rss. */
348 #define ACTION_RSS_QUEUE_NUM 128
350 /** Storage for struct rte_flow_action_rss including external data. */
351 struct action_rss_data {
352 struct rte_flow_action_rss conf;
353 uint8_t key[RSS_HASH_KEY_LENGTH];
354 uint16_t queue[ACTION_RSS_QUEUE_NUM];
357 /** Maximum data size in struct rte_flow_action_raw_encap. */
358 #define ACTION_RAW_ENCAP_MAX_DATA 128
359 #define RAW_ENCAP_CONFS_MAX_NUM 8
361 /** Storage for struct rte_flow_action_raw_encap. */
362 struct raw_encap_conf {
363 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
364 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
368 struct raw_encap_conf raw_encap_confs[RAW_ENCAP_CONFS_MAX_NUM];
370 /** Storage for struct rte_flow_action_raw_encap including external data. */
371 struct action_raw_encap_data {
372 struct rte_flow_action_raw_encap conf;
373 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
374 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
378 /** Storage for struct rte_flow_action_raw_decap. */
379 struct raw_decap_conf {
380 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
384 struct raw_decap_conf raw_decap_confs[RAW_ENCAP_CONFS_MAX_NUM];
386 /** Storage for struct rte_flow_action_raw_decap including external data. */
387 struct action_raw_decap_data {
388 struct rte_flow_action_raw_decap conf;
389 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
393 struct vxlan_encap_conf vxlan_encap_conf = {
397 .vni = "\x00\x00\x00",
399 .udp_dst = RTE_BE16(4789),
400 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
401 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
402 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
403 "\x00\x00\x00\x00\x00\x00\x00\x01",
404 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
405 "\x00\x00\x00\x00\x00\x00\x11\x11",
409 .eth_src = "\x00\x00\x00\x00\x00\x00",
410 .eth_dst = "\xff\xff\xff\xff\xff\xff",
413 /** Maximum number of items in struct rte_flow_action_vxlan_encap. */
414 #define ACTION_VXLAN_ENCAP_ITEMS_NUM 6
416 /** Storage for struct rte_flow_action_vxlan_encap including external data. */
417 struct action_vxlan_encap_data {
418 struct rte_flow_action_vxlan_encap conf;
419 struct rte_flow_item items[ACTION_VXLAN_ENCAP_ITEMS_NUM];
420 struct rte_flow_item_eth item_eth;
421 struct rte_flow_item_vlan item_vlan;
423 struct rte_flow_item_ipv4 item_ipv4;
424 struct rte_flow_item_ipv6 item_ipv6;
426 struct rte_flow_item_udp item_udp;
427 struct rte_flow_item_vxlan item_vxlan;
430 struct nvgre_encap_conf nvgre_encap_conf = {
433 .tni = "\x00\x00\x00",
434 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
435 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
436 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
437 "\x00\x00\x00\x00\x00\x00\x00\x01",
438 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
439 "\x00\x00\x00\x00\x00\x00\x11\x11",
441 .eth_src = "\x00\x00\x00\x00\x00\x00",
442 .eth_dst = "\xff\xff\xff\xff\xff\xff",
445 /** Maximum number of items in struct rte_flow_action_nvgre_encap. */
446 #define ACTION_NVGRE_ENCAP_ITEMS_NUM 5
448 /** Storage for struct rte_flow_action_nvgre_encap including external data. */
449 struct action_nvgre_encap_data {
450 struct rte_flow_action_nvgre_encap conf;
451 struct rte_flow_item items[ACTION_NVGRE_ENCAP_ITEMS_NUM];
452 struct rte_flow_item_eth item_eth;
453 struct rte_flow_item_vlan item_vlan;
455 struct rte_flow_item_ipv4 item_ipv4;
456 struct rte_flow_item_ipv6 item_ipv6;
458 struct rte_flow_item_nvgre item_nvgre;
461 struct l2_encap_conf l2_encap_conf;
463 struct l2_decap_conf l2_decap_conf;
465 struct mplsogre_encap_conf mplsogre_encap_conf;
467 struct mplsogre_decap_conf mplsogre_decap_conf;
469 struct mplsoudp_encap_conf mplsoudp_encap_conf;
471 struct mplsoudp_decap_conf mplsoudp_decap_conf;
473 /** Maximum number of subsequent tokens and arguments on the stack. */
474 #define CTX_STACK_SIZE 16
476 /** Parser context. */
478 /** Stack of subsequent token lists to process. */
479 const enum index *next[CTX_STACK_SIZE];
480 /** Arguments for stacked tokens. */
481 const void *args[CTX_STACK_SIZE];
482 enum index curr; /**< Current token index. */
483 enum index prev; /**< Index of the last token seen. */
484 int next_num; /**< Number of entries in next[]. */
485 int args_num; /**< Number of entries in args[]. */
486 uint32_t eol:1; /**< EOL has been detected. */
487 uint32_t last:1; /**< No more arguments. */
488 portid_t port; /**< Current port ID (for completions). */
489 uint32_t objdata; /**< Object-specific data. */
490 void *object; /**< Address of current object for relative offsets. */
491 void *objmask; /**< Object a full mask must be written to. */
494 /** Token argument. */
496 uint32_t hton:1; /**< Use network byte ordering. */
497 uint32_t sign:1; /**< Value is signed. */
498 uint32_t bounded:1; /**< Value is bounded. */
499 uintmax_t min; /**< Minimum value if bounded. */
500 uintmax_t max; /**< Maximum value if bounded. */
501 uint32_t offset; /**< Relative offset from ctx->object. */
502 uint32_t size; /**< Field size. */
503 const uint8_t *mask; /**< Bit-mask to use instead of offset/size. */
506 /** Parser token definition. */
508 /** Type displayed during completion (defaults to "TOKEN"). */
510 /** Help displayed during completion (defaults to token name). */
512 /** Private data used by parser functions. */
515 * Lists of subsequent tokens to push on the stack. Each call to the
516 * parser consumes the last entry of that stack.
518 const enum index *const *next;
519 /** Arguments stack for subsequent tokens that need them. */
520 const struct arg *const *args;
522 * Token-processing callback, returns -1 in case of error, the
523 * length of the matched string otherwise. If NULL, attempts to
524 * match the token name.
526 * If buf is not NULL, the result should be stored in it according
527 * to context. An error is returned if not large enough.
529 int (*call)(struct context *ctx, const struct token *token,
530 const char *str, unsigned int len,
531 void *buf, unsigned int size);
533 * Callback that provides possible values for this token, used for
534 * completion. Returns -1 in case of error, the number of possible
535 * values otherwise. If NULL, the token name is used.
537 * If buf is not NULL, entry index ent is written to buf and the
538 * full length of the entry is returned (same behavior as
541 int (*comp)(struct context *ctx, const struct token *token,
542 unsigned int ent, char *buf, unsigned int size);
543 /** Mandatory token name, no default value. */
547 /** Static initializer for the next field. */
548 #define NEXT(...) (const enum index *const []){ __VA_ARGS__, NULL, }
550 /** Static initializer for a NEXT() entry. */
551 #define NEXT_ENTRY(...) (const enum index []){ __VA_ARGS__, ZERO, }
553 /** Static initializer for the args field. */
554 #define ARGS(...) (const struct arg *const []){ __VA_ARGS__, NULL, }
556 /** Static initializer for ARGS() to target a field. */
557 #define ARGS_ENTRY(s, f) \
558 (&(const struct arg){ \
559 .offset = offsetof(s, f), \
560 .size = sizeof(((s *)0)->f), \
563 /** Static initializer for ARGS() to target a bit-field. */
564 #define ARGS_ENTRY_BF(s, f, b) \
565 (&(const struct arg){ \
567 .mask = (const void *)&(const s){ .f = (1 << (b)) - 1 }, \
570 /** Static initializer for ARGS() to target an arbitrary bit-mask. */
571 #define ARGS_ENTRY_MASK(s, f, m) \
572 (&(const struct arg){ \
573 .offset = offsetof(s, f), \
574 .size = sizeof(((s *)0)->f), \
575 .mask = (const void *)(m), \
578 /** Same as ARGS_ENTRY_MASK() using network byte ordering for the value. */
579 #define ARGS_ENTRY_MASK_HTON(s, f, m) \
580 (&(const struct arg){ \
582 .offset = offsetof(s, f), \
583 .size = sizeof(((s *)0)->f), \
584 .mask = (const void *)(m), \
587 /** Static initializer for ARGS() to target a pointer. */
588 #define ARGS_ENTRY_PTR(s, f) \
589 (&(const struct arg){ \
590 .size = sizeof(*((s *)0)->f), \
593 /** Static initializer for ARGS() with arbitrary offset and size. */
594 #define ARGS_ENTRY_ARB(o, s) \
595 (&(const struct arg){ \
600 /** Same as ARGS_ENTRY_ARB() with bounded values. */
601 #define ARGS_ENTRY_ARB_BOUNDED(o, s, i, a) \
602 (&(const struct arg){ \
610 /** Same as ARGS_ENTRY() using network byte ordering. */
611 #define ARGS_ENTRY_HTON(s, f) \
612 (&(const struct arg){ \
614 .offset = offsetof(s, f), \
615 .size = sizeof(((s *)0)->f), \
618 /** Same as ARGS_ENTRY_HTON() for a single argument, without structure. */
619 #define ARG_ENTRY_HTON(s) \
620 (&(const struct arg){ \
626 /** Parser output buffer layout expected by cmd_flow_parsed(). */
628 enum index command; /**< Flow command. */
629 portid_t port; /**< Affected port ID. */
632 struct rte_flow_attr attr;
633 struct rte_flow_item *pattern;
634 struct rte_flow_action *actions;
638 } vc; /**< Validate/create arguments. */
642 } destroy; /**< Destroy arguments. */
645 struct rte_flow_action action;
646 } query; /**< Query arguments. */
650 } list; /**< List arguments. */
653 } isolate; /**< Isolated mode arguments. */
654 } args; /**< Command arguments. */
657 /** Private data for pattern items. */
658 struct parse_item_priv {
659 enum rte_flow_item_type type; /**< Item type. */
660 uint32_t size; /**< Size of item specification structure. */
663 #define PRIV_ITEM(t, s) \
664 (&(const struct parse_item_priv){ \
665 .type = RTE_FLOW_ITEM_TYPE_ ## t, \
669 /** Private data for actions. */
670 struct parse_action_priv {
671 enum rte_flow_action_type type; /**< Action type. */
672 uint32_t size; /**< Size of action configuration structure. */
675 #define PRIV_ACTION(t, s) \
676 (&(const struct parse_action_priv){ \
677 .type = RTE_FLOW_ACTION_TYPE_ ## t, \
681 static const enum index next_vc_attr[] = {
691 static const enum index next_destroy_attr[] = {
697 static const enum index next_list_attr[] = {
703 static const enum index item_param[] = {
712 static const enum index next_item[] = {
748 ITEM_ICMP6_ND_OPT_SLA_ETH,
749 ITEM_ICMP6_ND_OPT_TLA_ETH,
764 static const enum index item_fuzzy[] = {
770 static const enum index item_any[] = {
776 static const enum index item_vf[] = {
782 static const enum index item_phy_port[] = {
788 static const enum index item_port_id[] = {
794 static const enum index item_mark[] = {
800 static const enum index item_raw[] = {
810 static const enum index item_eth[] = {
818 static const enum index item_vlan[] = {
823 ITEM_VLAN_INNER_TYPE,
828 static const enum index item_ipv4[] = {
838 static const enum index item_ipv6[] = {
849 static const enum index item_icmp[] = {
856 static const enum index item_udp[] = {
863 static const enum index item_tcp[] = {
871 static const enum index item_sctp[] = {
880 static const enum index item_vxlan[] = {
886 static const enum index item_e_tag[] = {
887 ITEM_E_TAG_GRP_ECID_B,
892 static const enum index item_nvgre[] = {
898 static const enum index item_mpls[] = {
906 static const enum index item_gre[] = {
908 ITEM_GRE_C_RSVD0_VER,
916 static const enum index item_gre_key[] = {
922 static const enum index item_gtp[] = {
929 static const enum index item_geneve[] = {
936 static const enum index item_vxlan_gpe[] = {
942 static const enum index item_arp_eth_ipv4[] = {
943 ITEM_ARP_ETH_IPV4_SHA,
944 ITEM_ARP_ETH_IPV4_SPA,
945 ITEM_ARP_ETH_IPV4_THA,
946 ITEM_ARP_ETH_IPV4_TPA,
951 static const enum index item_ipv6_ext[] = {
952 ITEM_IPV6_EXT_NEXT_HDR,
957 static const enum index item_icmp6[] = {
964 static const enum index item_icmp6_nd_ns[] = {
965 ITEM_ICMP6_ND_NS_TARGET_ADDR,
970 static const enum index item_icmp6_nd_na[] = {
971 ITEM_ICMP6_ND_NA_TARGET_ADDR,
976 static const enum index item_icmp6_nd_opt[] = {
977 ITEM_ICMP6_ND_OPT_TYPE,
982 static const enum index item_icmp6_nd_opt_sla_eth[] = {
983 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
988 static const enum index item_icmp6_nd_opt_tla_eth[] = {
989 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
994 static const enum index item_meta[] = {
1000 static const enum index item_gtp_psc[] = {
1007 static const enum index item_pppoed[] = {
1013 static const enum index item_pppoes[] = {
1019 static const enum index item_pppoe_proto_id[] = {
1020 ITEM_PPPOE_PROTO_ID,
1025 static const enum index item_higig2[] = {
1026 ITEM_HIGIG2_CLASSIFICATION,
1032 static const enum index item_esp[] = {
1038 static const enum index next_set_raw[] = {
1044 static const enum index item_tag[] = {
1051 static const enum index item_l2tpv3oip[] = {
1052 ITEM_L2TPV3OIP_SESSION_ID,
1057 static const enum index next_action[] = {
1073 ACTION_OF_SET_MPLS_TTL,
1074 ACTION_OF_DEC_MPLS_TTL,
1075 ACTION_OF_SET_NW_TTL,
1076 ACTION_OF_DEC_NW_TTL,
1077 ACTION_OF_COPY_TTL_OUT,
1078 ACTION_OF_COPY_TTL_IN,
1080 ACTION_OF_PUSH_VLAN,
1081 ACTION_OF_SET_VLAN_VID,
1082 ACTION_OF_SET_VLAN_PCP,
1084 ACTION_OF_PUSH_MPLS,
1091 ACTION_MPLSOGRE_ENCAP,
1092 ACTION_MPLSOGRE_DECAP,
1093 ACTION_MPLSOUDP_ENCAP,
1094 ACTION_MPLSOUDP_DECAP,
1095 ACTION_SET_IPV4_SRC,
1096 ACTION_SET_IPV4_DST,
1097 ACTION_SET_IPV6_SRC,
1098 ACTION_SET_IPV6_DST,
1114 ACTION_SET_IPV4_DSCP,
1115 ACTION_SET_IPV6_DSCP,
1119 static const enum index action_mark[] = {
1125 static const enum index action_queue[] = {
1131 static const enum index action_count[] = {
1133 ACTION_COUNT_SHARED,
1138 static const enum index action_rss[] = {
1149 static const enum index action_vf[] = {
1156 static const enum index action_phy_port[] = {
1157 ACTION_PHY_PORT_ORIGINAL,
1158 ACTION_PHY_PORT_INDEX,
1163 static const enum index action_port_id[] = {
1164 ACTION_PORT_ID_ORIGINAL,
1170 static const enum index action_meter[] = {
1176 static const enum index action_of_set_mpls_ttl[] = {
1177 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
1182 static const enum index action_of_set_nw_ttl[] = {
1183 ACTION_OF_SET_NW_TTL_NW_TTL,
1188 static const enum index action_of_push_vlan[] = {
1189 ACTION_OF_PUSH_VLAN_ETHERTYPE,
1194 static const enum index action_of_set_vlan_vid[] = {
1195 ACTION_OF_SET_VLAN_VID_VLAN_VID,
1200 static const enum index action_of_set_vlan_pcp[] = {
1201 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
1206 static const enum index action_of_pop_mpls[] = {
1207 ACTION_OF_POP_MPLS_ETHERTYPE,
1212 static const enum index action_of_push_mpls[] = {
1213 ACTION_OF_PUSH_MPLS_ETHERTYPE,
1218 static const enum index action_set_ipv4_src[] = {
1219 ACTION_SET_IPV4_SRC_IPV4_SRC,
1224 static const enum index action_set_mac_src[] = {
1225 ACTION_SET_MAC_SRC_MAC_SRC,
1230 static const enum index action_set_ipv4_dst[] = {
1231 ACTION_SET_IPV4_DST_IPV4_DST,
1236 static const enum index action_set_ipv6_src[] = {
1237 ACTION_SET_IPV6_SRC_IPV6_SRC,
1242 static const enum index action_set_ipv6_dst[] = {
1243 ACTION_SET_IPV6_DST_IPV6_DST,
1248 static const enum index action_set_tp_src[] = {
1249 ACTION_SET_TP_SRC_TP_SRC,
1254 static const enum index action_set_tp_dst[] = {
1255 ACTION_SET_TP_DST_TP_DST,
1260 static const enum index action_set_ttl[] = {
1266 static const enum index action_jump[] = {
1272 static const enum index action_set_mac_dst[] = {
1273 ACTION_SET_MAC_DST_MAC_DST,
1278 static const enum index action_inc_tcp_seq[] = {
1279 ACTION_INC_TCP_SEQ_VALUE,
1284 static const enum index action_dec_tcp_seq[] = {
1285 ACTION_DEC_TCP_SEQ_VALUE,
1290 static const enum index action_inc_tcp_ack[] = {
1291 ACTION_INC_TCP_ACK_VALUE,
1296 static const enum index action_dec_tcp_ack[] = {
1297 ACTION_DEC_TCP_ACK_VALUE,
1302 static const enum index action_raw_encap[] = {
1303 ACTION_RAW_ENCAP_INDEX,
1308 static const enum index action_raw_decap[] = {
1309 ACTION_RAW_DECAP_INDEX,
1314 static const enum index action_set_tag[] = {
1315 ACTION_SET_TAG_DATA,
1316 ACTION_SET_TAG_INDEX,
1317 ACTION_SET_TAG_MASK,
1322 static const enum index action_set_meta[] = {
1323 ACTION_SET_META_DATA,
1324 ACTION_SET_META_MASK,
1329 static const enum index action_set_ipv4_dscp[] = {
1330 ACTION_SET_IPV4_DSCP_VALUE,
1335 static const enum index action_set_ipv6_dscp[] = {
1336 ACTION_SET_IPV6_DSCP_VALUE,
1341 static int parse_set_raw_encap_decap(struct context *, const struct token *,
1342 const char *, unsigned int,
1343 void *, unsigned int);
1344 static int parse_set_init(struct context *, const struct token *,
1345 const char *, unsigned int,
1346 void *, unsigned int);
1347 static int parse_init(struct context *, const struct token *,
1348 const char *, unsigned int,
1349 void *, unsigned int);
1350 static int parse_vc(struct context *, const struct token *,
1351 const char *, unsigned int,
1352 void *, unsigned int);
1353 static int parse_vc_spec(struct context *, const struct token *,
1354 const char *, unsigned int, void *, unsigned int);
1355 static int parse_vc_conf(struct context *, const struct token *,
1356 const char *, unsigned int, void *, unsigned int);
1357 static int parse_vc_action_rss(struct context *, const struct token *,
1358 const char *, unsigned int, void *,
1360 static int parse_vc_action_rss_func(struct context *, const struct token *,
1361 const char *, unsigned int, void *,
1363 static int parse_vc_action_rss_type(struct context *, const struct token *,
1364 const char *, unsigned int, void *,
1366 static int parse_vc_action_rss_queue(struct context *, const struct token *,
1367 const char *, unsigned int, void *,
1369 static int parse_vc_action_vxlan_encap(struct context *, const struct token *,
1370 const char *, unsigned int, void *,
1372 static int parse_vc_action_nvgre_encap(struct context *, const struct token *,
1373 const char *, unsigned int, void *,
1375 static int parse_vc_action_l2_encap(struct context *, const struct token *,
1376 const char *, unsigned int, void *,
1378 static int parse_vc_action_l2_decap(struct context *, const struct token *,
1379 const char *, unsigned int, void *,
1381 static int parse_vc_action_mplsogre_encap(struct context *,
1382 const struct token *, const char *,
1383 unsigned int, void *, unsigned int);
1384 static int parse_vc_action_mplsogre_decap(struct context *,
1385 const struct token *, const char *,
1386 unsigned int, void *, unsigned int);
1387 static int parse_vc_action_mplsoudp_encap(struct context *,
1388 const struct token *, const char *,
1389 unsigned int, void *, unsigned int);
1390 static int parse_vc_action_mplsoudp_decap(struct context *,
1391 const struct token *, const char *,
1392 unsigned int, void *, unsigned int);
1393 static int parse_vc_action_raw_encap(struct context *,
1394 const struct token *, const char *,
1395 unsigned int, void *, unsigned int);
1396 static int parse_vc_action_raw_decap(struct context *,
1397 const struct token *, const char *,
1398 unsigned int, void *, unsigned int);
1399 static int parse_vc_action_raw_encap_index(struct context *,
1400 const struct token *, const char *,
1401 unsigned int, void *, unsigned int);
1402 static int parse_vc_action_raw_decap_index(struct context *,
1403 const struct token *, const char *,
1404 unsigned int, void *, unsigned int);
1405 static int parse_vc_action_set_meta(struct context *ctx,
1406 const struct token *token, const char *str,
1407 unsigned int len, void *buf,
1409 static int parse_destroy(struct context *, const struct token *,
1410 const char *, unsigned int,
1411 void *, unsigned int);
1412 static int parse_flush(struct context *, const struct token *,
1413 const char *, unsigned int,
1414 void *, unsigned int);
1415 static int parse_query(struct context *, const struct token *,
1416 const char *, unsigned int,
1417 void *, unsigned int);
1418 static int parse_action(struct context *, const struct token *,
1419 const char *, unsigned int,
1420 void *, unsigned int);
1421 static int parse_list(struct context *, const struct token *,
1422 const char *, unsigned int,
1423 void *, unsigned int);
1424 static int parse_isolate(struct context *, const struct token *,
1425 const char *, unsigned int,
1426 void *, unsigned int);
1427 static int parse_int(struct context *, const struct token *,
1428 const char *, unsigned int,
1429 void *, unsigned int);
1430 static int parse_prefix(struct context *, const struct token *,
1431 const char *, unsigned int,
1432 void *, unsigned int);
1433 static int parse_boolean(struct context *, const struct token *,
1434 const char *, unsigned int,
1435 void *, unsigned int);
1436 static int parse_string(struct context *, const struct token *,
1437 const char *, unsigned int,
1438 void *, unsigned int);
1439 static int parse_hex(struct context *ctx, const struct token *token,
1440 const char *str, unsigned int len,
1441 void *buf, unsigned int size);
1442 static int parse_mac_addr(struct context *, const struct token *,
1443 const char *, unsigned int,
1444 void *, unsigned int);
1445 static int parse_ipv4_addr(struct context *, const struct token *,
1446 const char *, unsigned int,
1447 void *, unsigned int);
1448 static int parse_ipv6_addr(struct context *, const struct token *,
1449 const char *, unsigned int,
1450 void *, unsigned int);
1451 static int parse_port(struct context *, const struct token *,
1452 const char *, unsigned int,
1453 void *, unsigned int);
1454 static int comp_none(struct context *, const struct token *,
1455 unsigned int, char *, unsigned int);
1456 static int comp_boolean(struct context *, const struct token *,
1457 unsigned int, char *, unsigned int);
1458 static int comp_action(struct context *, const struct token *,
1459 unsigned int, char *, unsigned int);
1460 static int comp_port(struct context *, const struct token *,
1461 unsigned int, char *, unsigned int);
1462 static int comp_rule_id(struct context *, const struct token *,
1463 unsigned int, char *, unsigned int);
1464 static int comp_vc_action_rss_type(struct context *, const struct token *,
1465 unsigned int, char *, unsigned int);
1466 static int comp_vc_action_rss_queue(struct context *, const struct token *,
1467 unsigned int, char *, unsigned int);
1468 static int comp_set_raw_index(struct context *, const struct token *,
1469 unsigned int, char *, unsigned int);
1471 /** Token definitions. */
1472 static const struct token token_list[] = {
1473 /* Special tokens. */
1476 .help = "null entry, abused as the entry point",
1477 .next = NEXT(NEXT_ENTRY(FLOW)),
1482 .help = "command may end here",
1485 .name = "START_SET",
1486 .help = "null entry, abused as the entry point for set",
1487 .next = NEXT(NEXT_ENTRY(SET)),
1492 .help = "set command may end here",
1494 /* Common tokens. */
1498 .help = "integer value",
1503 .name = "{unsigned}",
1505 .help = "unsigned integer value",
1512 .help = "prefix length for bit-mask",
1513 .call = parse_prefix,
1517 .name = "{boolean}",
1519 .help = "any boolean value",
1520 .call = parse_boolean,
1521 .comp = comp_boolean,
1526 .help = "fixed string",
1527 .call = parse_string,
1533 .help = "fixed string",
1538 .name = "{MAC address}",
1540 .help = "standard MAC address notation",
1541 .call = parse_mac_addr,
1545 .name = "{IPv4 address}",
1546 .type = "IPV4 ADDRESS",
1547 .help = "standard IPv4 address notation",
1548 .call = parse_ipv4_addr,
1552 .name = "{IPv6 address}",
1553 .type = "IPV6 ADDRESS",
1554 .help = "standard IPv6 address notation",
1555 .call = parse_ipv6_addr,
1559 .name = "{rule id}",
1561 .help = "rule identifier",
1563 .comp = comp_rule_id,
1566 .name = "{port_id}",
1568 .help = "port identifier",
1573 .name = "{group_id}",
1575 .help = "group identifier",
1579 [PRIORITY_LEVEL] = {
1582 .help = "priority level",
1586 /* Top-level command. */
1589 .type = "{command} {port_id} [{arg} [...]]",
1590 .help = "manage ingress/egress flow rules",
1591 .next = NEXT(NEXT_ENTRY
1601 /* Sub-level commands. */
1604 .help = "check whether a flow rule can be created",
1605 .next = NEXT(next_vc_attr, NEXT_ENTRY(PORT_ID)),
1606 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1611 .help = "create a flow rule",
1612 .next = NEXT(next_vc_attr, NEXT_ENTRY(PORT_ID)),
1613 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1618 .help = "destroy specific flow rules",
1619 .next = NEXT(NEXT_ENTRY(DESTROY_RULE), NEXT_ENTRY(PORT_ID)),
1620 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1621 .call = parse_destroy,
1625 .help = "destroy all flow rules",
1626 .next = NEXT(NEXT_ENTRY(PORT_ID)),
1627 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1628 .call = parse_flush,
1632 .help = "query an existing flow rule",
1633 .next = NEXT(NEXT_ENTRY(QUERY_ACTION),
1634 NEXT_ENTRY(RULE_ID),
1635 NEXT_ENTRY(PORT_ID)),
1636 .args = ARGS(ARGS_ENTRY(struct buffer, args.query.action.type),
1637 ARGS_ENTRY(struct buffer, args.query.rule),
1638 ARGS_ENTRY(struct buffer, port)),
1639 .call = parse_query,
1643 .help = "list existing flow rules",
1644 .next = NEXT(next_list_attr, NEXT_ENTRY(PORT_ID)),
1645 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1650 .help = "restrict ingress traffic to the defined flow rules",
1651 .next = NEXT(NEXT_ENTRY(BOOLEAN),
1652 NEXT_ENTRY(PORT_ID)),
1653 .args = ARGS(ARGS_ENTRY(struct buffer, args.isolate.set),
1654 ARGS_ENTRY(struct buffer, port)),
1655 .call = parse_isolate,
1657 /* Destroy arguments. */
1660 .help = "specify a rule identifier",
1661 .next = NEXT(next_destroy_attr, NEXT_ENTRY(RULE_ID)),
1662 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.destroy.rule)),
1663 .call = parse_destroy,
1665 /* Query arguments. */
1669 .help = "action to query, must be part of the rule",
1670 .call = parse_action,
1671 .comp = comp_action,
1673 /* List arguments. */
1676 .help = "specify a group",
1677 .next = NEXT(next_list_attr, NEXT_ENTRY(GROUP_ID)),
1678 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.list.group)),
1681 /* Validate/create attributes. */
1684 .help = "specify a group",
1685 .next = NEXT(next_vc_attr, NEXT_ENTRY(GROUP_ID)),
1686 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, group)),
1691 .help = "specify a priority level",
1692 .next = NEXT(next_vc_attr, NEXT_ENTRY(PRIORITY_LEVEL)),
1693 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, priority)),
1698 .help = "affect rule to ingress",
1699 .next = NEXT(next_vc_attr),
1704 .help = "affect rule to egress",
1705 .next = NEXT(next_vc_attr),
1710 .help = "apply rule directly to endpoints found in pattern",
1711 .next = NEXT(next_vc_attr),
1714 /* Validate/create pattern. */
1717 .help = "submit a list of pattern items",
1718 .next = NEXT(next_item),
1723 .help = "match value perfectly (with full bit-mask)",
1724 .call = parse_vc_spec,
1726 [ITEM_PARAM_SPEC] = {
1728 .help = "match value according to configured bit-mask",
1729 .call = parse_vc_spec,
1731 [ITEM_PARAM_LAST] = {
1733 .help = "specify upper bound to establish a range",
1734 .call = parse_vc_spec,
1736 [ITEM_PARAM_MASK] = {
1738 .help = "specify bit-mask with relevant bits set to one",
1739 .call = parse_vc_spec,
1741 [ITEM_PARAM_PREFIX] = {
1743 .help = "generate bit-mask from a prefix length",
1744 .call = parse_vc_spec,
1748 .help = "specify next pattern item",
1749 .next = NEXT(next_item),
1753 .help = "end list of pattern items",
1754 .priv = PRIV_ITEM(END, 0),
1755 .next = NEXT(NEXT_ENTRY(ACTIONS)),
1760 .help = "no-op pattern item",
1761 .priv = PRIV_ITEM(VOID, 0),
1762 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
1767 .help = "perform actions when pattern does not match",
1768 .priv = PRIV_ITEM(INVERT, 0),
1769 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
1774 .help = "match any protocol for the current layer",
1775 .priv = PRIV_ITEM(ANY, sizeof(struct rte_flow_item_any)),
1776 .next = NEXT(item_any),
1781 .help = "number of layers covered",
1782 .next = NEXT(item_any, NEXT_ENTRY(UNSIGNED), item_param),
1783 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_any, num)),
1787 .help = "match traffic from/to the physical function",
1788 .priv = PRIV_ITEM(PF, 0),
1789 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
1794 .help = "match traffic from/to a virtual function ID",
1795 .priv = PRIV_ITEM(VF, sizeof(struct rte_flow_item_vf)),
1796 .next = NEXT(item_vf),
1802 .next = NEXT(item_vf, NEXT_ENTRY(UNSIGNED), item_param),
1803 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_vf, id)),
1807 .help = "match traffic from/to a specific physical port",
1808 .priv = PRIV_ITEM(PHY_PORT,
1809 sizeof(struct rte_flow_item_phy_port)),
1810 .next = NEXT(item_phy_port),
1813 [ITEM_PHY_PORT_INDEX] = {
1815 .help = "physical port index",
1816 .next = NEXT(item_phy_port, NEXT_ENTRY(UNSIGNED), item_param),
1817 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_phy_port, index)),
1821 .help = "match traffic from/to a given DPDK port ID",
1822 .priv = PRIV_ITEM(PORT_ID,
1823 sizeof(struct rte_flow_item_port_id)),
1824 .next = NEXT(item_port_id),
1827 [ITEM_PORT_ID_ID] = {
1829 .help = "DPDK port ID",
1830 .next = NEXT(item_port_id, NEXT_ENTRY(UNSIGNED), item_param),
1831 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port_id, id)),
1835 .help = "match traffic against value set in previously matched rule",
1836 .priv = PRIV_ITEM(MARK, sizeof(struct rte_flow_item_mark)),
1837 .next = NEXT(item_mark),
1842 .help = "Integer value to match against",
1843 .next = NEXT(item_mark, NEXT_ENTRY(UNSIGNED), item_param),
1844 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_mark, id)),
1848 .help = "match an arbitrary byte string",
1849 .priv = PRIV_ITEM(RAW, ITEM_RAW_SIZE),
1850 .next = NEXT(item_raw),
1853 [ITEM_RAW_RELATIVE] = {
1855 .help = "look for pattern after the previous item",
1856 .next = NEXT(item_raw, NEXT_ENTRY(BOOLEAN), item_param),
1857 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
1860 [ITEM_RAW_SEARCH] = {
1862 .help = "search pattern from offset (see also limit)",
1863 .next = NEXT(item_raw, NEXT_ENTRY(BOOLEAN), item_param),
1864 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
1867 [ITEM_RAW_OFFSET] = {
1869 .help = "absolute or relative offset for pattern",
1870 .next = NEXT(item_raw, NEXT_ENTRY(INTEGER), item_param),
1871 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, offset)),
1873 [ITEM_RAW_LIMIT] = {
1875 .help = "search area limit for start of pattern",
1876 .next = NEXT(item_raw, NEXT_ENTRY(UNSIGNED), item_param),
1877 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, limit)),
1879 [ITEM_RAW_PATTERN] = {
1881 .help = "byte string to look for",
1882 .next = NEXT(item_raw,
1884 NEXT_ENTRY(ITEM_PARAM_IS,
1887 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern),
1888 ARGS_ENTRY(struct rte_flow_item_raw, length),
1889 ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw),
1890 ITEM_RAW_PATTERN_SIZE)),
1894 .help = "match Ethernet header",
1895 .priv = PRIV_ITEM(ETH, sizeof(struct rte_flow_item_eth)),
1896 .next = NEXT(item_eth),
1901 .help = "destination MAC",
1902 .next = NEXT(item_eth, NEXT_ENTRY(MAC_ADDR), item_param),
1903 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, dst)),
1907 .help = "source MAC",
1908 .next = NEXT(item_eth, NEXT_ENTRY(MAC_ADDR), item_param),
1909 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, src)),
1913 .help = "EtherType",
1914 .next = NEXT(item_eth, NEXT_ENTRY(UNSIGNED), item_param),
1915 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, type)),
1919 .help = "match 802.1Q/ad VLAN tag",
1920 .priv = PRIV_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)),
1921 .next = NEXT(item_vlan),
1926 .help = "tag control information",
1927 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
1928 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, tci)),
1932 .help = "priority code point",
1933 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
1934 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
1939 .help = "drop eligible indicator",
1940 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
1941 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
1946 .help = "VLAN identifier",
1947 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
1948 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
1951 [ITEM_VLAN_INNER_TYPE] = {
1952 .name = "inner_type",
1953 .help = "inner EtherType",
1954 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
1955 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan,
1960 .help = "match IPv4 header",
1961 .priv = PRIV_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)),
1962 .next = NEXT(item_ipv4),
1967 .help = "type of service",
1968 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
1969 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
1970 hdr.type_of_service)),
1974 .help = "time to live",
1975 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
1976 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
1979 [ITEM_IPV4_PROTO] = {
1981 .help = "next protocol ID",
1982 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
1983 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
1984 hdr.next_proto_id)),
1988 .help = "source address",
1989 .next = NEXT(item_ipv4, NEXT_ENTRY(IPV4_ADDR), item_param),
1990 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
1995 .help = "destination address",
1996 .next = NEXT(item_ipv4, NEXT_ENTRY(IPV4_ADDR), item_param),
1997 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2002 .help = "match IPv6 header",
2003 .priv = PRIV_ITEM(IPV6, sizeof(struct rte_flow_item_ipv6)),
2004 .next = NEXT(item_ipv6),
2009 .help = "traffic class",
2010 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2011 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2013 "\x0f\xf0\x00\x00")),
2015 [ITEM_IPV6_FLOW] = {
2017 .help = "flow label",
2018 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2019 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2021 "\x00\x0f\xff\xff")),
2023 [ITEM_IPV6_PROTO] = {
2025 .help = "protocol (next header)",
2026 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2027 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2032 .help = "hop limit",
2033 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2034 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2039 .help = "source address",
2040 .next = NEXT(item_ipv6, NEXT_ENTRY(IPV6_ADDR), item_param),
2041 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2046 .help = "destination address",
2047 .next = NEXT(item_ipv6, NEXT_ENTRY(IPV6_ADDR), item_param),
2048 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2053 .help = "match ICMP header",
2054 .priv = PRIV_ITEM(ICMP, sizeof(struct rte_flow_item_icmp)),
2055 .next = NEXT(item_icmp),
2058 [ITEM_ICMP_TYPE] = {
2060 .help = "ICMP packet type",
2061 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2062 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2065 [ITEM_ICMP_CODE] = {
2067 .help = "ICMP packet code",
2068 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2069 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2074 .help = "match UDP header",
2075 .priv = PRIV_ITEM(UDP, sizeof(struct rte_flow_item_udp)),
2076 .next = NEXT(item_udp),
2081 .help = "UDP source port",
2082 .next = NEXT(item_udp, NEXT_ENTRY(UNSIGNED), item_param),
2083 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2088 .help = "UDP destination port",
2089 .next = NEXT(item_udp, NEXT_ENTRY(UNSIGNED), item_param),
2090 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2095 .help = "match TCP header",
2096 .priv = PRIV_ITEM(TCP, sizeof(struct rte_flow_item_tcp)),
2097 .next = NEXT(item_tcp),
2102 .help = "TCP source port",
2103 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2104 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2109 .help = "TCP destination port",
2110 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2111 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2114 [ITEM_TCP_FLAGS] = {
2116 .help = "TCP flags",
2117 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2118 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2123 .help = "match SCTP header",
2124 .priv = PRIV_ITEM(SCTP, sizeof(struct rte_flow_item_sctp)),
2125 .next = NEXT(item_sctp),
2130 .help = "SCTP source port",
2131 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2132 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2137 .help = "SCTP destination port",
2138 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2139 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2144 .help = "validation tag",
2145 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2146 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2149 [ITEM_SCTP_CKSUM] = {
2152 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2153 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2158 .help = "match VXLAN header",
2159 .priv = PRIV_ITEM(VXLAN, sizeof(struct rte_flow_item_vxlan)),
2160 .next = NEXT(item_vxlan),
2163 [ITEM_VXLAN_VNI] = {
2165 .help = "VXLAN identifier",
2166 .next = NEXT(item_vxlan, NEXT_ENTRY(UNSIGNED), item_param),
2167 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan, vni)),
2171 .help = "match E-Tag header",
2172 .priv = PRIV_ITEM(E_TAG, sizeof(struct rte_flow_item_e_tag)),
2173 .next = NEXT(item_e_tag),
2176 [ITEM_E_TAG_GRP_ECID_B] = {
2177 .name = "grp_ecid_b",
2178 .help = "GRP and E-CID base",
2179 .next = NEXT(item_e_tag, NEXT_ENTRY(UNSIGNED), item_param),
2180 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_e_tag,
2186 .help = "match NVGRE header",
2187 .priv = PRIV_ITEM(NVGRE, sizeof(struct rte_flow_item_nvgre)),
2188 .next = NEXT(item_nvgre),
2191 [ITEM_NVGRE_TNI] = {
2193 .help = "virtual subnet ID",
2194 .next = NEXT(item_nvgre, NEXT_ENTRY(UNSIGNED), item_param),
2195 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_nvgre, tni)),
2199 .help = "match MPLS header",
2200 .priv = PRIV_ITEM(MPLS, sizeof(struct rte_flow_item_mpls)),
2201 .next = NEXT(item_mpls),
2204 [ITEM_MPLS_LABEL] = {
2206 .help = "MPLS label",
2207 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2208 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2214 .help = "MPLS Traffic Class",
2215 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2216 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2222 .help = "MPLS Bottom-of-Stack",
2223 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2224 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2230 .help = "match GRE header",
2231 .priv = PRIV_ITEM(GRE, sizeof(struct rte_flow_item_gre)),
2232 .next = NEXT(item_gre),
2235 [ITEM_GRE_PROTO] = {
2237 .help = "GRE protocol type",
2238 .next = NEXT(item_gre, NEXT_ENTRY(UNSIGNED), item_param),
2239 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2242 [ITEM_GRE_C_RSVD0_VER] = {
2243 .name = "c_rsvd0_ver",
2245 "checksum (1b), undefined (1b), key bit (1b),"
2246 " sequence number (1b), reserved 0 (9b),"
2248 .next = NEXT(item_gre, NEXT_ENTRY(UNSIGNED), item_param),
2249 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2252 [ITEM_GRE_C_BIT] = {
2254 .help = "checksum bit (C)",
2255 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2256 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2258 "\x80\x00\x00\x00")),
2260 [ITEM_GRE_S_BIT] = {
2262 .help = "sequence number bit (S)",
2263 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2264 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2266 "\x10\x00\x00\x00")),
2268 [ITEM_GRE_K_BIT] = {
2270 .help = "key bit (K)",
2271 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2272 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2274 "\x20\x00\x00\x00")),
2278 .help = "fuzzy pattern match, expect faster than default",
2279 .priv = PRIV_ITEM(FUZZY,
2280 sizeof(struct rte_flow_item_fuzzy)),
2281 .next = NEXT(item_fuzzy),
2284 [ITEM_FUZZY_THRESH] = {
2286 .help = "match accuracy threshold",
2287 .next = NEXT(item_fuzzy, NEXT_ENTRY(UNSIGNED), item_param),
2288 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_fuzzy,
2293 .help = "match GTP header",
2294 .priv = PRIV_ITEM(GTP, sizeof(struct rte_flow_item_gtp)),
2295 .next = NEXT(item_gtp),
2298 [ITEM_GTP_MSG_TYPE] = {
2300 .help = "GTP message type",
2301 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2302 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp,
2307 .help = "tunnel endpoint identifier",
2308 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2309 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp, teid)),
2313 .help = "match GTP header",
2314 .priv = PRIV_ITEM(GTPC, sizeof(struct rte_flow_item_gtp)),
2315 .next = NEXT(item_gtp),
2320 .help = "match GTP header",
2321 .priv = PRIV_ITEM(GTPU, sizeof(struct rte_flow_item_gtp)),
2322 .next = NEXT(item_gtp),
2327 .help = "match GENEVE header",
2328 .priv = PRIV_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)),
2329 .next = NEXT(item_geneve),
2332 [ITEM_GENEVE_VNI] = {
2334 .help = "virtual network identifier",
2335 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2336 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve, vni)),
2338 [ITEM_GENEVE_PROTO] = {
2340 .help = "GENEVE protocol type",
2341 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2342 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve,
2345 [ITEM_VXLAN_GPE] = {
2346 .name = "vxlan-gpe",
2347 .help = "match VXLAN-GPE header",
2348 .priv = PRIV_ITEM(VXLAN_GPE,
2349 sizeof(struct rte_flow_item_vxlan_gpe)),
2350 .next = NEXT(item_vxlan_gpe),
2353 [ITEM_VXLAN_GPE_VNI] = {
2355 .help = "VXLAN-GPE identifier",
2356 .next = NEXT(item_vxlan_gpe, NEXT_ENTRY(UNSIGNED), item_param),
2357 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
2360 [ITEM_ARP_ETH_IPV4] = {
2361 .name = "arp_eth_ipv4",
2362 .help = "match ARP header for Ethernet/IPv4",
2363 .priv = PRIV_ITEM(ARP_ETH_IPV4,
2364 sizeof(struct rte_flow_item_arp_eth_ipv4)),
2365 .next = NEXT(item_arp_eth_ipv4),
2368 [ITEM_ARP_ETH_IPV4_SHA] = {
2370 .help = "sender hardware address",
2371 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(MAC_ADDR),
2373 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2376 [ITEM_ARP_ETH_IPV4_SPA] = {
2378 .help = "sender IPv4 address",
2379 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(IPV4_ADDR),
2381 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2384 [ITEM_ARP_ETH_IPV4_THA] = {
2386 .help = "target hardware address",
2387 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(MAC_ADDR),
2389 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2392 [ITEM_ARP_ETH_IPV4_TPA] = {
2394 .help = "target IPv4 address",
2395 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(IPV4_ADDR),
2397 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2402 .help = "match presence of any IPv6 extension header",
2403 .priv = PRIV_ITEM(IPV6_EXT,
2404 sizeof(struct rte_flow_item_ipv6_ext)),
2405 .next = NEXT(item_ipv6_ext),
2408 [ITEM_IPV6_EXT_NEXT_HDR] = {
2410 .help = "next header",
2411 .next = NEXT(item_ipv6_ext, NEXT_ENTRY(UNSIGNED), item_param),
2412 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_ext,
2417 .help = "match any ICMPv6 header",
2418 .priv = PRIV_ITEM(ICMP6, sizeof(struct rte_flow_item_icmp6)),
2419 .next = NEXT(item_icmp6),
2422 [ITEM_ICMP6_TYPE] = {
2424 .help = "ICMPv6 type",
2425 .next = NEXT(item_icmp6, NEXT_ENTRY(UNSIGNED), item_param),
2426 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
2429 [ITEM_ICMP6_CODE] = {
2431 .help = "ICMPv6 code",
2432 .next = NEXT(item_icmp6, NEXT_ENTRY(UNSIGNED), item_param),
2433 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
2436 [ITEM_ICMP6_ND_NS] = {
2437 .name = "icmp6_nd_ns",
2438 .help = "match ICMPv6 neighbor discovery solicitation",
2439 .priv = PRIV_ITEM(ICMP6_ND_NS,
2440 sizeof(struct rte_flow_item_icmp6_nd_ns)),
2441 .next = NEXT(item_icmp6_nd_ns),
2444 [ITEM_ICMP6_ND_NS_TARGET_ADDR] = {
2445 .name = "target_addr",
2446 .help = "target address",
2447 .next = NEXT(item_icmp6_nd_ns, NEXT_ENTRY(IPV6_ADDR),
2449 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_ns,
2452 [ITEM_ICMP6_ND_NA] = {
2453 .name = "icmp6_nd_na",
2454 .help = "match ICMPv6 neighbor discovery advertisement",
2455 .priv = PRIV_ITEM(ICMP6_ND_NA,
2456 sizeof(struct rte_flow_item_icmp6_nd_na)),
2457 .next = NEXT(item_icmp6_nd_na),
2460 [ITEM_ICMP6_ND_NA_TARGET_ADDR] = {
2461 .name = "target_addr",
2462 .help = "target address",
2463 .next = NEXT(item_icmp6_nd_na, NEXT_ENTRY(IPV6_ADDR),
2465 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_na,
2468 [ITEM_ICMP6_ND_OPT] = {
2469 .name = "icmp6_nd_opt",
2470 .help = "match presence of any ICMPv6 neighbor discovery"
2472 .priv = PRIV_ITEM(ICMP6_ND_OPT,
2473 sizeof(struct rte_flow_item_icmp6_nd_opt)),
2474 .next = NEXT(item_icmp6_nd_opt),
2477 [ITEM_ICMP6_ND_OPT_TYPE] = {
2479 .help = "ND option type",
2480 .next = NEXT(item_icmp6_nd_opt, NEXT_ENTRY(UNSIGNED),
2482 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_opt,
2485 [ITEM_ICMP6_ND_OPT_SLA_ETH] = {
2486 .name = "icmp6_nd_opt_sla_eth",
2487 .help = "match ICMPv6 neighbor discovery source Ethernet"
2488 " link-layer address option",
2490 (ICMP6_ND_OPT_SLA_ETH,
2491 sizeof(struct rte_flow_item_icmp6_nd_opt_sla_eth)),
2492 .next = NEXT(item_icmp6_nd_opt_sla_eth),
2495 [ITEM_ICMP6_ND_OPT_SLA_ETH_SLA] = {
2497 .help = "source Ethernet LLA",
2498 .next = NEXT(item_icmp6_nd_opt_sla_eth, NEXT_ENTRY(MAC_ADDR),
2500 .args = ARGS(ARGS_ENTRY_HTON
2501 (struct rte_flow_item_icmp6_nd_opt_sla_eth, sla)),
2503 [ITEM_ICMP6_ND_OPT_TLA_ETH] = {
2504 .name = "icmp6_nd_opt_tla_eth",
2505 .help = "match ICMPv6 neighbor discovery target Ethernet"
2506 " link-layer address option",
2508 (ICMP6_ND_OPT_TLA_ETH,
2509 sizeof(struct rte_flow_item_icmp6_nd_opt_tla_eth)),
2510 .next = NEXT(item_icmp6_nd_opt_tla_eth),
2513 [ITEM_ICMP6_ND_OPT_TLA_ETH_TLA] = {
2515 .help = "target Ethernet LLA",
2516 .next = NEXT(item_icmp6_nd_opt_tla_eth, NEXT_ENTRY(MAC_ADDR),
2518 .args = ARGS(ARGS_ENTRY_HTON
2519 (struct rte_flow_item_icmp6_nd_opt_tla_eth, tla)),
2523 .help = "match metadata header",
2524 .priv = PRIV_ITEM(META, sizeof(struct rte_flow_item_meta)),
2525 .next = NEXT(item_meta),
2528 [ITEM_META_DATA] = {
2530 .help = "metadata value",
2531 .next = NEXT(item_meta, NEXT_ENTRY(UNSIGNED), item_param),
2532 .args = ARGS(ARGS_ENTRY_MASK(struct rte_flow_item_meta,
2533 data, "\xff\xff\xff\xff")),
2537 .help = "match GRE key",
2538 .priv = PRIV_ITEM(GRE_KEY, sizeof(rte_be32_t)),
2539 .next = NEXT(item_gre_key),
2542 [ITEM_GRE_KEY_VALUE] = {
2544 .help = "key value",
2545 .next = NEXT(item_gre_key, NEXT_ENTRY(UNSIGNED), item_param),
2546 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
2550 .help = "match GTP extension header with type 0x85",
2551 .priv = PRIV_ITEM(GTP_PSC,
2552 sizeof(struct rte_flow_item_gtp_psc)),
2553 .next = NEXT(item_gtp_psc),
2556 [ITEM_GTP_PSC_QFI] = {
2558 .help = "QoS flow identifier",
2559 .next = NEXT(item_gtp_psc, NEXT_ENTRY(UNSIGNED), item_param),
2560 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
2563 [ITEM_GTP_PSC_PDU_T] = {
2566 .next = NEXT(item_gtp_psc, NEXT_ENTRY(UNSIGNED), item_param),
2567 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
2572 .help = "match PPPoE session header",
2573 .priv = PRIV_ITEM(PPPOES, sizeof(struct rte_flow_item_pppoe)),
2574 .next = NEXT(item_pppoes),
2579 .help = "match PPPoE discovery header",
2580 .priv = PRIV_ITEM(PPPOED, sizeof(struct rte_flow_item_pppoe)),
2581 .next = NEXT(item_pppoed),
2584 [ITEM_PPPOE_SEID] = {
2586 .help = "session identifier",
2587 .next = NEXT(item_pppoes, NEXT_ENTRY(UNSIGNED), item_param),
2588 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pppoe,
2591 [ITEM_PPPOE_PROTO_ID] = {
2593 .help = "match PPPoE session protocol identifier",
2594 .priv = PRIV_ITEM(PPPOE_PROTO_ID,
2595 sizeof(struct rte_flow_item_pppoe_proto_id)),
2596 .next = NEXT(item_pppoe_proto_id),
2601 .help = "matches higig2 header",
2602 .priv = PRIV_ITEM(HIGIG2,
2603 sizeof(struct rte_flow_item_higig2_hdr)),
2604 .next = NEXT(item_higig2),
2607 [ITEM_HIGIG2_CLASSIFICATION] = {
2608 .name = "classification",
2609 .help = "matches classification of higig2 header",
2610 .next = NEXT(item_higig2, NEXT_ENTRY(UNSIGNED), item_param),
2611 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
2612 hdr.ppt1.classification)),
2614 [ITEM_HIGIG2_VID] = {
2616 .help = "matches vid of higig2 header",
2617 .next = NEXT(item_higig2, NEXT_ENTRY(UNSIGNED), item_param),
2618 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
2623 .help = "match tag value",
2624 .priv = PRIV_ITEM(TAG, sizeof(struct rte_flow_item_tag)),
2625 .next = NEXT(item_tag),
2630 .help = "tag value to match",
2631 .next = NEXT(item_tag, NEXT_ENTRY(UNSIGNED), item_param),
2632 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, data)),
2634 [ITEM_TAG_INDEX] = {
2636 .help = "index of tag array to match",
2637 .next = NEXT(item_tag, NEXT_ENTRY(UNSIGNED),
2638 NEXT_ENTRY(ITEM_PARAM_IS)),
2639 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, index)),
2641 [ITEM_L2TPV3OIP] = {
2642 .name = "l2tpv3oip",
2643 .help = "match L2TPv3 over IP header",
2644 .priv = PRIV_ITEM(L2TPV3OIP,
2645 sizeof(struct rte_flow_item_l2tpv3oip)),
2646 .next = NEXT(item_l2tpv3oip),
2649 [ITEM_L2TPV3OIP_SESSION_ID] = {
2650 .name = "session_id",
2651 .help = "session identifier",
2652 .next = NEXT(item_l2tpv3oip, NEXT_ENTRY(UNSIGNED), item_param),
2653 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv3oip,
2658 .help = "match ESP header",
2659 .priv = PRIV_ITEM(ESP, sizeof(struct rte_flow_item_esp)),
2660 .next = NEXT(item_esp),
2665 .help = "security policy index",
2666 .next = NEXT(item_esp, NEXT_ENTRY(UNSIGNED), item_param),
2667 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_esp,
2670 /* Validate/create actions. */
2673 .help = "submit a list of associated actions",
2674 .next = NEXT(next_action),
2679 .help = "specify next action",
2680 .next = NEXT(next_action),
2684 .help = "end list of actions",
2685 .priv = PRIV_ACTION(END, 0),
2690 .help = "no-op action",
2691 .priv = PRIV_ACTION(VOID, 0),
2692 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
2695 [ACTION_PASSTHRU] = {
2697 .help = "let subsequent rule process matched packets",
2698 .priv = PRIV_ACTION(PASSTHRU, 0),
2699 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
2704 .help = "redirect traffic to a given group",
2705 .priv = PRIV_ACTION(JUMP, sizeof(struct rte_flow_action_jump)),
2706 .next = NEXT(action_jump),
2709 [ACTION_JUMP_GROUP] = {
2711 .help = "group to redirect traffic to",
2712 .next = NEXT(action_jump, NEXT_ENTRY(UNSIGNED)),
2713 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump, group)),
2714 .call = parse_vc_conf,
2718 .help = "attach 32 bit value to packets",
2719 .priv = PRIV_ACTION(MARK, sizeof(struct rte_flow_action_mark)),
2720 .next = NEXT(action_mark),
2723 [ACTION_MARK_ID] = {
2725 .help = "32 bit value to return with packets",
2726 .next = NEXT(action_mark, NEXT_ENTRY(UNSIGNED)),
2727 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_mark, id)),
2728 .call = parse_vc_conf,
2732 .help = "flag packets",
2733 .priv = PRIV_ACTION(FLAG, 0),
2734 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
2739 .help = "assign packets to a given queue index",
2740 .priv = PRIV_ACTION(QUEUE,
2741 sizeof(struct rte_flow_action_queue)),
2742 .next = NEXT(action_queue),
2745 [ACTION_QUEUE_INDEX] = {
2747 .help = "queue index to use",
2748 .next = NEXT(action_queue, NEXT_ENTRY(UNSIGNED)),
2749 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_queue, index)),
2750 .call = parse_vc_conf,
2754 .help = "drop packets (note: passthru has priority)",
2755 .priv = PRIV_ACTION(DROP, 0),
2756 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
2761 .help = "enable counters for this rule",
2762 .priv = PRIV_ACTION(COUNT,
2763 sizeof(struct rte_flow_action_count)),
2764 .next = NEXT(action_count),
2767 [ACTION_COUNT_ID] = {
2768 .name = "identifier",
2769 .help = "counter identifier to use",
2770 .next = NEXT(action_count, NEXT_ENTRY(UNSIGNED)),
2771 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_count, id)),
2772 .call = parse_vc_conf,
2774 [ACTION_COUNT_SHARED] = {
2776 .help = "shared counter",
2777 .next = NEXT(action_count, NEXT_ENTRY(BOOLEAN)),
2778 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_count,
2780 .call = parse_vc_conf,
2784 .help = "spread packets among several queues",
2785 .priv = PRIV_ACTION(RSS, sizeof(struct action_rss_data)),
2786 .next = NEXT(action_rss),
2787 .call = parse_vc_action_rss,
2789 [ACTION_RSS_FUNC] = {
2791 .help = "RSS hash function to apply",
2792 .next = NEXT(action_rss,
2793 NEXT_ENTRY(ACTION_RSS_FUNC_DEFAULT,
2794 ACTION_RSS_FUNC_TOEPLITZ,
2795 ACTION_RSS_FUNC_SIMPLE_XOR,
2796 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ)),
2798 [ACTION_RSS_FUNC_DEFAULT] = {
2800 .help = "default hash function",
2801 .call = parse_vc_action_rss_func,
2803 [ACTION_RSS_FUNC_TOEPLITZ] = {
2805 .help = "Toeplitz hash function",
2806 .call = parse_vc_action_rss_func,
2808 [ACTION_RSS_FUNC_SIMPLE_XOR] = {
2809 .name = "simple_xor",
2810 .help = "simple XOR hash function",
2811 .call = parse_vc_action_rss_func,
2813 [ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ] = {
2814 .name = "symmetric_toeplitz",
2815 .help = "Symmetric Toeplitz hash function",
2816 .call = parse_vc_action_rss_func,
2818 [ACTION_RSS_LEVEL] = {
2820 .help = "encapsulation level for \"types\"",
2821 .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
2822 .args = ARGS(ARGS_ENTRY_ARB
2823 (offsetof(struct action_rss_data, conf) +
2824 offsetof(struct rte_flow_action_rss, level),
2825 sizeof(((struct rte_flow_action_rss *)0)->
2828 [ACTION_RSS_TYPES] = {
2830 .help = "specific RSS hash types",
2831 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)),
2833 [ACTION_RSS_TYPE] = {
2835 .help = "RSS hash type",
2836 .call = parse_vc_action_rss_type,
2837 .comp = comp_vc_action_rss_type,
2839 [ACTION_RSS_KEY] = {
2841 .help = "RSS hash key",
2842 .next = NEXT(action_rss, NEXT_ENTRY(HEX)),
2843 .args = ARGS(ARGS_ENTRY_ARB(0, 0),
2845 (offsetof(struct action_rss_data, conf) +
2846 offsetof(struct rte_flow_action_rss, key_len),
2847 sizeof(((struct rte_flow_action_rss *)0)->
2849 ARGS_ENTRY(struct action_rss_data, key)),
2851 [ACTION_RSS_KEY_LEN] = {
2853 .help = "RSS hash key length in bytes",
2854 .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
2855 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
2856 (offsetof(struct action_rss_data, conf) +
2857 offsetof(struct rte_flow_action_rss, key_len),
2858 sizeof(((struct rte_flow_action_rss *)0)->
2861 RSS_HASH_KEY_LENGTH)),
2863 [ACTION_RSS_QUEUES] = {
2865 .help = "queue indices to use",
2866 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_QUEUE)),
2867 .call = parse_vc_conf,
2869 [ACTION_RSS_QUEUE] = {
2871 .help = "queue index",
2872 .call = parse_vc_action_rss_queue,
2873 .comp = comp_vc_action_rss_queue,
2877 .help = "direct traffic to physical function",
2878 .priv = PRIV_ACTION(PF, 0),
2879 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
2884 .help = "direct traffic to a virtual function ID",
2885 .priv = PRIV_ACTION(VF, sizeof(struct rte_flow_action_vf)),
2886 .next = NEXT(action_vf),
2889 [ACTION_VF_ORIGINAL] = {
2891 .help = "use original VF ID if possible",
2892 .next = NEXT(action_vf, NEXT_ENTRY(BOOLEAN)),
2893 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_vf,
2895 .call = parse_vc_conf,
2900 .next = NEXT(action_vf, NEXT_ENTRY(UNSIGNED)),
2901 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)),
2902 .call = parse_vc_conf,
2904 [ACTION_PHY_PORT] = {
2906 .help = "direct packets to physical port index",
2907 .priv = PRIV_ACTION(PHY_PORT,
2908 sizeof(struct rte_flow_action_phy_port)),
2909 .next = NEXT(action_phy_port),
2912 [ACTION_PHY_PORT_ORIGINAL] = {
2914 .help = "use original port index if possible",
2915 .next = NEXT(action_phy_port, NEXT_ENTRY(BOOLEAN)),
2916 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_phy_port,
2918 .call = parse_vc_conf,
2920 [ACTION_PHY_PORT_INDEX] = {
2922 .help = "physical port index",
2923 .next = NEXT(action_phy_port, NEXT_ENTRY(UNSIGNED)),
2924 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_phy_port,
2926 .call = parse_vc_conf,
2928 [ACTION_PORT_ID] = {
2930 .help = "direct matching traffic to a given DPDK port ID",
2931 .priv = PRIV_ACTION(PORT_ID,
2932 sizeof(struct rte_flow_action_port_id)),
2933 .next = NEXT(action_port_id),
2936 [ACTION_PORT_ID_ORIGINAL] = {
2938 .help = "use original DPDK port ID if possible",
2939 .next = NEXT(action_port_id, NEXT_ENTRY(BOOLEAN)),
2940 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_port_id,
2942 .call = parse_vc_conf,
2944 [ACTION_PORT_ID_ID] = {
2946 .help = "DPDK port ID",
2947 .next = NEXT(action_port_id, NEXT_ENTRY(UNSIGNED)),
2948 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_port_id, id)),
2949 .call = parse_vc_conf,
2953 .help = "meter the directed packets at given id",
2954 .priv = PRIV_ACTION(METER,
2955 sizeof(struct rte_flow_action_meter)),
2956 .next = NEXT(action_meter),
2959 [ACTION_METER_ID] = {
2961 .help = "meter id to use",
2962 .next = NEXT(action_meter, NEXT_ENTRY(UNSIGNED)),
2963 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter, mtr_id)),
2964 .call = parse_vc_conf,
2966 [ACTION_OF_SET_MPLS_TTL] = {
2967 .name = "of_set_mpls_ttl",
2968 .help = "OpenFlow's OFPAT_SET_MPLS_TTL",
2971 sizeof(struct rte_flow_action_of_set_mpls_ttl)),
2972 .next = NEXT(action_of_set_mpls_ttl),
2975 [ACTION_OF_SET_MPLS_TTL_MPLS_TTL] = {
2978 .next = NEXT(action_of_set_mpls_ttl, NEXT_ENTRY(UNSIGNED)),
2979 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_mpls_ttl,
2981 .call = parse_vc_conf,
2983 [ACTION_OF_DEC_MPLS_TTL] = {
2984 .name = "of_dec_mpls_ttl",
2985 .help = "OpenFlow's OFPAT_DEC_MPLS_TTL",
2986 .priv = PRIV_ACTION(OF_DEC_MPLS_TTL, 0),
2987 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
2990 [ACTION_OF_SET_NW_TTL] = {
2991 .name = "of_set_nw_ttl",
2992 .help = "OpenFlow's OFPAT_SET_NW_TTL",
2995 sizeof(struct rte_flow_action_of_set_nw_ttl)),
2996 .next = NEXT(action_of_set_nw_ttl),
2999 [ACTION_OF_SET_NW_TTL_NW_TTL] = {
3002 .next = NEXT(action_of_set_nw_ttl, NEXT_ENTRY(UNSIGNED)),
3003 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_nw_ttl,
3005 .call = parse_vc_conf,
3007 [ACTION_OF_DEC_NW_TTL] = {
3008 .name = "of_dec_nw_ttl",
3009 .help = "OpenFlow's OFPAT_DEC_NW_TTL",
3010 .priv = PRIV_ACTION(OF_DEC_NW_TTL, 0),
3011 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3014 [ACTION_OF_COPY_TTL_OUT] = {
3015 .name = "of_copy_ttl_out",
3016 .help = "OpenFlow's OFPAT_COPY_TTL_OUT",
3017 .priv = PRIV_ACTION(OF_COPY_TTL_OUT, 0),
3018 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3021 [ACTION_OF_COPY_TTL_IN] = {
3022 .name = "of_copy_ttl_in",
3023 .help = "OpenFlow's OFPAT_COPY_TTL_IN",
3024 .priv = PRIV_ACTION(OF_COPY_TTL_IN, 0),
3025 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3028 [ACTION_OF_POP_VLAN] = {
3029 .name = "of_pop_vlan",
3030 .help = "OpenFlow's OFPAT_POP_VLAN",
3031 .priv = PRIV_ACTION(OF_POP_VLAN, 0),
3032 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3035 [ACTION_OF_PUSH_VLAN] = {
3036 .name = "of_push_vlan",
3037 .help = "OpenFlow's OFPAT_PUSH_VLAN",
3040 sizeof(struct rte_flow_action_of_push_vlan)),
3041 .next = NEXT(action_of_push_vlan),
3044 [ACTION_OF_PUSH_VLAN_ETHERTYPE] = {
3045 .name = "ethertype",
3046 .help = "EtherType",
3047 .next = NEXT(action_of_push_vlan, NEXT_ENTRY(UNSIGNED)),
3048 .args = ARGS(ARGS_ENTRY_HTON
3049 (struct rte_flow_action_of_push_vlan,
3051 .call = parse_vc_conf,
3053 [ACTION_OF_SET_VLAN_VID] = {
3054 .name = "of_set_vlan_vid",
3055 .help = "OpenFlow's OFPAT_SET_VLAN_VID",
3058 sizeof(struct rte_flow_action_of_set_vlan_vid)),
3059 .next = NEXT(action_of_set_vlan_vid),
3062 [ACTION_OF_SET_VLAN_VID_VLAN_VID] = {
3065 .next = NEXT(action_of_set_vlan_vid, NEXT_ENTRY(UNSIGNED)),
3066 .args = ARGS(ARGS_ENTRY_HTON
3067 (struct rte_flow_action_of_set_vlan_vid,
3069 .call = parse_vc_conf,
3071 [ACTION_OF_SET_VLAN_PCP] = {
3072 .name = "of_set_vlan_pcp",
3073 .help = "OpenFlow's OFPAT_SET_VLAN_PCP",
3076 sizeof(struct rte_flow_action_of_set_vlan_pcp)),
3077 .next = NEXT(action_of_set_vlan_pcp),
3080 [ACTION_OF_SET_VLAN_PCP_VLAN_PCP] = {
3082 .help = "VLAN priority",
3083 .next = NEXT(action_of_set_vlan_pcp, NEXT_ENTRY(UNSIGNED)),
3084 .args = ARGS(ARGS_ENTRY_HTON
3085 (struct rte_flow_action_of_set_vlan_pcp,
3087 .call = parse_vc_conf,
3089 [ACTION_OF_POP_MPLS] = {
3090 .name = "of_pop_mpls",
3091 .help = "OpenFlow's OFPAT_POP_MPLS",
3092 .priv = PRIV_ACTION(OF_POP_MPLS,
3093 sizeof(struct rte_flow_action_of_pop_mpls)),
3094 .next = NEXT(action_of_pop_mpls),
3097 [ACTION_OF_POP_MPLS_ETHERTYPE] = {
3098 .name = "ethertype",
3099 .help = "EtherType",
3100 .next = NEXT(action_of_pop_mpls, NEXT_ENTRY(UNSIGNED)),
3101 .args = ARGS(ARGS_ENTRY_HTON
3102 (struct rte_flow_action_of_pop_mpls,
3104 .call = parse_vc_conf,
3106 [ACTION_OF_PUSH_MPLS] = {
3107 .name = "of_push_mpls",
3108 .help = "OpenFlow's OFPAT_PUSH_MPLS",
3111 sizeof(struct rte_flow_action_of_push_mpls)),
3112 .next = NEXT(action_of_push_mpls),
3115 [ACTION_OF_PUSH_MPLS_ETHERTYPE] = {
3116 .name = "ethertype",
3117 .help = "EtherType",
3118 .next = NEXT(action_of_push_mpls, NEXT_ENTRY(UNSIGNED)),
3119 .args = ARGS(ARGS_ENTRY_HTON
3120 (struct rte_flow_action_of_push_mpls,
3122 .call = parse_vc_conf,
3124 [ACTION_VXLAN_ENCAP] = {
3125 .name = "vxlan_encap",
3126 .help = "VXLAN encapsulation, uses configuration set by \"set"
3128 .priv = PRIV_ACTION(VXLAN_ENCAP,
3129 sizeof(struct action_vxlan_encap_data)),
3130 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3131 .call = parse_vc_action_vxlan_encap,
3133 [ACTION_VXLAN_DECAP] = {
3134 .name = "vxlan_decap",
3135 .help = "Performs a decapsulation action by stripping all"
3136 " headers of the VXLAN tunnel network overlay from the"
3138 .priv = PRIV_ACTION(VXLAN_DECAP, 0),
3139 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3142 [ACTION_NVGRE_ENCAP] = {
3143 .name = "nvgre_encap",
3144 .help = "NVGRE encapsulation, uses configuration set by \"set"
3146 .priv = PRIV_ACTION(NVGRE_ENCAP,
3147 sizeof(struct action_nvgre_encap_data)),
3148 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3149 .call = parse_vc_action_nvgre_encap,
3151 [ACTION_NVGRE_DECAP] = {
3152 .name = "nvgre_decap",
3153 .help = "Performs a decapsulation action by stripping all"
3154 " headers of the NVGRE tunnel network overlay from the"
3156 .priv = PRIV_ACTION(NVGRE_DECAP, 0),
3157 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3160 [ACTION_L2_ENCAP] = {
3162 .help = "l2 encap, uses configuration set by"
3163 " \"set l2_encap\"",
3164 .priv = PRIV_ACTION(RAW_ENCAP,
3165 sizeof(struct action_raw_encap_data)),
3166 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3167 .call = parse_vc_action_l2_encap,
3169 [ACTION_L2_DECAP] = {
3171 .help = "l2 decap, uses configuration set by"
3172 " \"set l2_decap\"",
3173 .priv = PRIV_ACTION(RAW_DECAP,
3174 sizeof(struct action_raw_decap_data)),
3175 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3176 .call = parse_vc_action_l2_decap,
3178 [ACTION_MPLSOGRE_ENCAP] = {
3179 .name = "mplsogre_encap",
3180 .help = "mplsogre encapsulation, uses configuration set by"
3181 " \"set mplsogre_encap\"",
3182 .priv = PRIV_ACTION(RAW_ENCAP,
3183 sizeof(struct action_raw_encap_data)),
3184 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3185 .call = parse_vc_action_mplsogre_encap,
3187 [ACTION_MPLSOGRE_DECAP] = {
3188 .name = "mplsogre_decap",
3189 .help = "mplsogre decapsulation, uses configuration set by"
3190 " \"set mplsogre_decap\"",
3191 .priv = PRIV_ACTION(RAW_DECAP,
3192 sizeof(struct action_raw_decap_data)),
3193 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3194 .call = parse_vc_action_mplsogre_decap,
3196 [ACTION_MPLSOUDP_ENCAP] = {
3197 .name = "mplsoudp_encap",
3198 .help = "mplsoudp encapsulation, uses configuration set by"
3199 " \"set mplsoudp_encap\"",
3200 .priv = PRIV_ACTION(RAW_ENCAP,
3201 sizeof(struct action_raw_encap_data)),
3202 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3203 .call = parse_vc_action_mplsoudp_encap,
3205 [ACTION_MPLSOUDP_DECAP] = {
3206 .name = "mplsoudp_decap",
3207 .help = "mplsoudp decapsulation, uses configuration set by"
3208 " \"set mplsoudp_decap\"",
3209 .priv = PRIV_ACTION(RAW_DECAP,
3210 sizeof(struct action_raw_decap_data)),
3211 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3212 .call = parse_vc_action_mplsoudp_decap,
3214 [ACTION_SET_IPV4_SRC] = {
3215 .name = "set_ipv4_src",
3216 .help = "Set a new IPv4 source address in the outermost"
3218 .priv = PRIV_ACTION(SET_IPV4_SRC,
3219 sizeof(struct rte_flow_action_set_ipv4)),
3220 .next = NEXT(action_set_ipv4_src),
3223 [ACTION_SET_IPV4_SRC_IPV4_SRC] = {
3224 .name = "ipv4_addr",
3225 .help = "new IPv4 source address to set",
3226 .next = NEXT(action_set_ipv4_src, NEXT_ENTRY(IPV4_ADDR)),
3227 .args = ARGS(ARGS_ENTRY_HTON
3228 (struct rte_flow_action_set_ipv4, ipv4_addr)),
3229 .call = parse_vc_conf,
3231 [ACTION_SET_IPV4_DST] = {
3232 .name = "set_ipv4_dst",
3233 .help = "Set a new IPv4 destination address in the outermost"
3235 .priv = PRIV_ACTION(SET_IPV4_DST,
3236 sizeof(struct rte_flow_action_set_ipv4)),
3237 .next = NEXT(action_set_ipv4_dst),
3240 [ACTION_SET_IPV4_DST_IPV4_DST] = {
3241 .name = "ipv4_addr",
3242 .help = "new IPv4 destination address to set",
3243 .next = NEXT(action_set_ipv4_dst, NEXT_ENTRY(IPV4_ADDR)),
3244 .args = ARGS(ARGS_ENTRY_HTON
3245 (struct rte_flow_action_set_ipv4, ipv4_addr)),
3246 .call = parse_vc_conf,
3248 [ACTION_SET_IPV6_SRC] = {
3249 .name = "set_ipv6_src",
3250 .help = "Set a new IPv6 source address in the outermost"
3252 .priv = PRIV_ACTION(SET_IPV6_SRC,
3253 sizeof(struct rte_flow_action_set_ipv6)),
3254 .next = NEXT(action_set_ipv6_src),
3257 [ACTION_SET_IPV6_SRC_IPV6_SRC] = {
3258 .name = "ipv6_addr",
3259 .help = "new IPv6 source address to set",
3260 .next = NEXT(action_set_ipv6_src, NEXT_ENTRY(IPV6_ADDR)),
3261 .args = ARGS(ARGS_ENTRY_HTON
3262 (struct rte_flow_action_set_ipv6, ipv6_addr)),
3263 .call = parse_vc_conf,
3265 [ACTION_SET_IPV6_DST] = {
3266 .name = "set_ipv6_dst",
3267 .help = "Set a new IPv6 destination address in the outermost"
3269 .priv = PRIV_ACTION(SET_IPV6_DST,
3270 sizeof(struct rte_flow_action_set_ipv6)),
3271 .next = NEXT(action_set_ipv6_dst),
3274 [ACTION_SET_IPV6_DST_IPV6_DST] = {
3275 .name = "ipv6_addr",
3276 .help = "new IPv6 destination address to set",
3277 .next = NEXT(action_set_ipv6_dst, NEXT_ENTRY(IPV6_ADDR)),
3278 .args = ARGS(ARGS_ENTRY_HTON
3279 (struct rte_flow_action_set_ipv6, ipv6_addr)),
3280 .call = parse_vc_conf,
3282 [ACTION_SET_TP_SRC] = {
3283 .name = "set_tp_src",
3284 .help = "set a new source port number in the outermost"
3286 .priv = PRIV_ACTION(SET_TP_SRC,
3287 sizeof(struct rte_flow_action_set_tp)),
3288 .next = NEXT(action_set_tp_src),
3291 [ACTION_SET_TP_SRC_TP_SRC] = {
3293 .help = "new source port number to set",
3294 .next = NEXT(action_set_tp_src, NEXT_ENTRY(UNSIGNED)),
3295 .args = ARGS(ARGS_ENTRY_HTON
3296 (struct rte_flow_action_set_tp, port)),
3297 .call = parse_vc_conf,
3299 [ACTION_SET_TP_DST] = {
3300 .name = "set_tp_dst",
3301 .help = "set a new destination port number in the outermost"
3303 .priv = PRIV_ACTION(SET_TP_DST,
3304 sizeof(struct rte_flow_action_set_tp)),
3305 .next = NEXT(action_set_tp_dst),
3308 [ACTION_SET_TP_DST_TP_DST] = {
3310 .help = "new destination port number to set",
3311 .next = NEXT(action_set_tp_dst, NEXT_ENTRY(UNSIGNED)),
3312 .args = ARGS(ARGS_ENTRY_HTON
3313 (struct rte_flow_action_set_tp, port)),
3314 .call = parse_vc_conf,
3316 [ACTION_MAC_SWAP] = {
3318 .help = "Swap the source and destination MAC addresses"
3319 " in the outermost Ethernet header",
3320 .priv = PRIV_ACTION(MAC_SWAP, 0),
3321 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3324 [ACTION_DEC_TTL] = {
3326 .help = "decrease network TTL if available",
3327 .priv = PRIV_ACTION(DEC_TTL, 0),
3328 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3331 [ACTION_SET_TTL] = {
3333 .help = "set ttl value",
3334 .priv = PRIV_ACTION(SET_TTL,
3335 sizeof(struct rte_flow_action_set_ttl)),
3336 .next = NEXT(action_set_ttl),
3339 [ACTION_SET_TTL_TTL] = {
3340 .name = "ttl_value",
3341 .help = "new ttl value to set",
3342 .next = NEXT(action_set_ttl, NEXT_ENTRY(UNSIGNED)),
3343 .args = ARGS(ARGS_ENTRY_HTON
3344 (struct rte_flow_action_set_ttl, ttl_value)),
3345 .call = parse_vc_conf,
3347 [ACTION_SET_MAC_SRC] = {
3348 .name = "set_mac_src",
3349 .help = "set source mac address",
3350 .priv = PRIV_ACTION(SET_MAC_SRC,
3351 sizeof(struct rte_flow_action_set_mac)),
3352 .next = NEXT(action_set_mac_src),
3355 [ACTION_SET_MAC_SRC_MAC_SRC] = {
3357 .help = "new source mac address",
3358 .next = NEXT(action_set_mac_src, NEXT_ENTRY(MAC_ADDR)),
3359 .args = ARGS(ARGS_ENTRY_HTON
3360 (struct rte_flow_action_set_mac, mac_addr)),
3361 .call = parse_vc_conf,
3363 [ACTION_SET_MAC_DST] = {
3364 .name = "set_mac_dst",
3365 .help = "set destination mac address",
3366 .priv = PRIV_ACTION(SET_MAC_DST,
3367 sizeof(struct rte_flow_action_set_mac)),
3368 .next = NEXT(action_set_mac_dst),
3371 [ACTION_SET_MAC_DST_MAC_DST] = {
3373 .help = "new destination mac address to set",
3374 .next = NEXT(action_set_mac_dst, NEXT_ENTRY(MAC_ADDR)),
3375 .args = ARGS(ARGS_ENTRY_HTON
3376 (struct rte_flow_action_set_mac, mac_addr)),
3377 .call = parse_vc_conf,
3379 [ACTION_INC_TCP_SEQ] = {
3380 .name = "inc_tcp_seq",
3381 .help = "increase TCP sequence number",
3382 .priv = PRIV_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
3383 .next = NEXT(action_inc_tcp_seq),
3386 [ACTION_INC_TCP_SEQ_VALUE] = {
3388 .help = "the value to increase TCP sequence number by",
3389 .next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(UNSIGNED)),
3390 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3391 .call = parse_vc_conf,
3393 [ACTION_DEC_TCP_SEQ] = {
3394 .name = "dec_tcp_seq",
3395 .help = "decrease TCP sequence number",
3396 .priv = PRIV_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
3397 .next = NEXT(action_dec_tcp_seq),
3400 [ACTION_DEC_TCP_SEQ_VALUE] = {
3402 .help = "the value to decrease TCP sequence number by",
3403 .next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(UNSIGNED)),
3404 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3405 .call = parse_vc_conf,
3407 [ACTION_INC_TCP_ACK] = {
3408 .name = "inc_tcp_ack",
3409 .help = "increase TCP acknowledgment number",
3410 .priv = PRIV_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
3411 .next = NEXT(action_inc_tcp_ack),
3414 [ACTION_INC_TCP_ACK_VALUE] = {
3416 .help = "the value to increase TCP acknowledgment number by",
3417 .next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(UNSIGNED)),
3418 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3419 .call = parse_vc_conf,
3421 [ACTION_DEC_TCP_ACK] = {
3422 .name = "dec_tcp_ack",
3423 .help = "decrease TCP acknowledgment number",
3424 .priv = PRIV_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
3425 .next = NEXT(action_dec_tcp_ack),
3428 [ACTION_DEC_TCP_ACK_VALUE] = {
3430 .help = "the value to decrease TCP acknowledgment number by",
3431 .next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(UNSIGNED)),
3432 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3433 .call = parse_vc_conf,
3435 [ACTION_RAW_ENCAP] = {
3436 .name = "raw_encap",
3437 .help = "encapsulation data, defined by set raw_encap",
3438 .priv = PRIV_ACTION(RAW_ENCAP,
3439 sizeof(struct action_raw_encap_data)),
3440 .next = NEXT(action_raw_encap),
3441 .call = parse_vc_action_raw_encap,
3443 [ACTION_RAW_ENCAP_INDEX] = {
3445 .help = "the index of raw_encap_confs",
3446 .next = NEXT(NEXT_ENTRY(ACTION_RAW_ENCAP_INDEX_VALUE)),
3448 [ACTION_RAW_ENCAP_INDEX_VALUE] = {
3451 .help = "unsigned integer value",
3452 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3453 .call = parse_vc_action_raw_encap_index,
3454 .comp = comp_set_raw_index,
3456 [ACTION_RAW_DECAP] = {
3457 .name = "raw_decap",
3458 .help = "decapsulation data, defined by set raw_encap",
3459 .priv = PRIV_ACTION(RAW_DECAP,
3460 sizeof(struct action_raw_decap_data)),
3461 .next = NEXT(action_raw_decap),
3462 .call = parse_vc_action_raw_decap,
3464 [ACTION_RAW_DECAP_INDEX] = {
3466 .help = "the index of raw_encap_confs",
3467 .next = NEXT(NEXT_ENTRY(ACTION_RAW_DECAP_INDEX_VALUE)),
3469 [ACTION_RAW_DECAP_INDEX_VALUE] = {
3472 .help = "unsigned integer value",
3473 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3474 .call = parse_vc_action_raw_decap_index,
3475 .comp = comp_set_raw_index,
3477 /* Top level command. */
3480 .help = "set raw encap/decap data",
3481 .type = "set raw_encap|raw_decap <index> <pattern>",
3482 .next = NEXT(NEXT_ENTRY
3485 .call = parse_set_init,
3487 /* Sub-level commands. */
3489 .name = "raw_encap",
3490 .help = "set raw encap data",
3491 .next = NEXT(next_set_raw),
3492 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
3493 (offsetof(struct buffer, port),
3494 sizeof(((struct buffer *)0)->port),
3495 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
3496 .call = parse_set_raw_encap_decap,
3499 .name = "raw_decap",
3500 .help = "set raw decap data",
3501 .next = NEXT(next_set_raw),
3502 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
3503 (offsetof(struct buffer, port),
3504 sizeof(((struct buffer *)0)->port),
3505 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
3506 .call = parse_set_raw_encap_decap,
3511 .help = "index of raw_encap/raw_decap data",
3512 .next = NEXT(next_item),
3515 [ACTION_SET_TAG] = {
3518 .priv = PRIV_ACTION(SET_TAG,
3519 sizeof(struct rte_flow_action_set_tag)),
3520 .next = NEXT(action_set_tag),
3523 [ACTION_SET_TAG_INDEX] = {
3525 .help = "index of tag array",
3526 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
3527 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_set_tag, index)),
3528 .call = parse_vc_conf,
3530 [ACTION_SET_TAG_DATA] = {
3532 .help = "tag value",
3533 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
3534 .args = ARGS(ARGS_ENTRY
3535 (struct rte_flow_action_set_tag, data)),
3536 .call = parse_vc_conf,
3538 [ACTION_SET_TAG_MASK] = {
3540 .help = "mask for tag value",
3541 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
3542 .args = ARGS(ARGS_ENTRY
3543 (struct rte_flow_action_set_tag, mask)),
3544 .call = parse_vc_conf,
3546 [ACTION_SET_META] = {
3548 .help = "set metadata",
3549 .priv = PRIV_ACTION(SET_META,
3550 sizeof(struct rte_flow_action_set_meta)),
3551 .next = NEXT(action_set_meta),
3552 .call = parse_vc_action_set_meta,
3554 [ACTION_SET_META_DATA] = {
3556 .help = "metadata value",
3557 .next = NEXT(action_set_meta, NEXT_ENTRY(UNSIGNED)),
3558 .args = ARGS(ARGS_ENTRY
3559 (struct rte_flow_action_set_meta, data)),
3560 .call = parse_vc_conf,
3562 [ACTION_SET_META_MASK] = {
3564 .help = "mask for metadata value",
3565 .next = NEXT(action_set_meta, NEXT_ENTRY(UNSIGNED)),
3566 .args = ARGS(ARGS_ENTRY
3567 (struct rte_flow_action_set_meta, mask)),
3568 .call = parse_vc_conf,
3570 [ACTION_SET_IPV4_DSCP] = {
3571 .name = "set_ipv4_dscp",
3572 .help = "set DSCP value",
3573 .priv = PRIV_ACTION(SET_IPV4_DSCP,
3574 sizeof(struct rte_flow_action_set_dscp)),
3575 .next = NEXT(action_set_ipv4_dscp),
3578 [ACTION_SET_IPV4_DSCP_VALUE] = {
3579 .name = "dscp_value",
3580 .help = "new IPv4 DSCP value to set",
3581 .next = NEXT(action_set_ipv4_dscp, NEXT_ENTRY(UNSIGNED)),
3582 .args = ARGS(ARGS_ENTRY
3583 (struct rte_flow_action_set_dscp, dscp)),
3584 .call = parse_vc_conf,
3586 [ACTION_SET_IPV6_DSCP] = {
3587 .name = "set_ipv6_dscp",
3588 .help = "set DSCP value",
3589 .priv = PRIV_ACTION(SET_IPV6_DSCP,
3590 sizeof(struct rte_flow_action_set_dscp)),
3591 .next = NEXT(action_set_ipv6_dscp),
3594 [ACTION_SET_IPV6_DSCP_VALUE] = {
3595 .name = "dscp_value",
3596 .help = "new IPv6 DSCP value to set",
3597 .next = NEXT(action_set_ipv6_dscp, NEXT_ENTRY(UNSIGNED)),
3598 .args = ARGS(ARGS_ENTRY
3599 (struct rte_flow_action_set_dscp, dscp)),
3600 .call = parse_vc_conf,
3604 /** Remove and return last entry from argument stack. */
3605 static const struct arg *
3606 pop_args(struct context *ctx)
3608 return ctx->args_num ? ctx->args[--ctx->args_num] : NULL;
3611 /** Add entry on top of the argument stack. */
3613 push_args(struct context *ctx, const struct arg *arg)
3615 if (ctx->args_num == CTX_STACK_SIZE)
3617 ctx->args[ctx->args_num++] = arg;
3621 /** Spread value into buffer according to bit-mask. */
3623 arg_entry_bf_fill(void *dst, uintmax_t val, const struct arg *arg)
3625 uint32_t i = arg->size;
3633 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
3642 unsigned int shift = 0;
3643 uint8_t *buf = (uint8_t *)dst + arg->offset + (i -= sub);
3645 for (shift = 0; arg->mask[i] >> shift; ++shift) {
3646 if (!(arg->mask[i] & (1 << shift)))
3651 *buf &= ~(1 << shift);
3652 *buf |= (val & 1) << shift;
3660 /** Compare a string with a partial one of a given length. */
3662 strcmp_partial(const char *full, const char *partial, size_t partial_len)
3664 int r = strncmp(full, partial, partial_len);
3668 if (strlen(full) <= partial_len)
3670 return full[partial_len];
3674 * Parse a prefix length and generate a bit-mask.
3676 * Last argument (ctx->args) is retrieved to determine mask size, storage
3677 * location and whether the result must use network byte ordering.
3680 parse_prefix(struct context *ctx, const struct token *token,
3681 const char *str, unsigned int len,
3682 void *buf, unsigned int size)
3684 const struct arg *arg = pop_args(ctx);
3685 static const uint8_t conv[] = "\x00\x80\xc0\xe0\xf0\xf8\xfc\xfe\xff";
3692 /* Argument is expected. */
3696 u = strtoumax(str, &end, 0);
3697 if (errno || (size_t)(end - str) != len)
3702 extra = arg_entry_bf_fill(NULL, 0, arg);
3711 if (!arg_entry_bf_fill(ctx->object, v, arg) ||
3712 !arg_entry_bf_fill(ctx->objmask, -1, arg))
3719 if (bytes > size || bytes + !!extra > size)
3723 buf = (uint8_t *)ctx->object + arg->offset;
3724 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
3726 memset((uint8_t *)buf + size - bytes, 0xff, bytes);
3727 memset(buf, 0x00, size - bytes);
3729 ((uint8_t *)buf)[size - bytes - 1] = conv[extra];
3733 memset(buf, 0xff, bytes);
3734 memset((uint8_t *)buf + bytes, 0x00, size - bytes);
3736 ((uint8_t *)buf)[bytes] = conv[extra];
3739 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
3742 push_args(ctx, arg);
3746 /** Default parsing function for token name matching. */
3748 parse_default(struct context *ctx, const struct token *token,
3749 const char *str, unsigned int len,
3750 void *buf, unsigned int size)
3755 if (strcmp_partial(token->name, str, len))
3760 /** Parse flow command, initialize output buffer for subsequent tokens. */
3762 parse_init(struct context *ctx, const struct token *token,
3763 const char *str, unsigned int len,
3764 void *buf, unsigned int size)
3766 struct buffer *out = buf;
3768 /* Token name must match. */
3769 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
3771 /* Nothing else to do if there is no buffer. */
3774 /* Make sure buffer is large enough. */
3775 if (size < sizeof(*out))
3777 /* Initialize buffer. */
3778 memset(out, 0x00, sizeof(*out));
3779 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
3782 ctx->objmask = NULL;
3786 /** Parse tokens for validate/create commands. */
3788 parse_vc(struct context *ctx, const struct token *token,
3789 const char *str, unsigned int len,
3790 void *buf, unsigned int size)
3792 struct buffer *out = buf;
3796 /* Token name must match. */
3797 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
3799 /* Nothing else to do if there is no buffer. */
3802 if (!out->command) {
3803 if (ctx->curr != VALIDATE && ctx->curr != CREATE)
3805 if (sizeof(*out) > size)
3807 out->command = ctx->curr;
3810 ctx->objmask = NULL;
3811 out->args.vc.data = (uint8_t *)out + size;
3815 ctx->object = &out->args.vc.attr;
3816 ctx->objmask = NULL;
3817 switch (ctx->curr) {
3822 out->args.vc.attr.ingress = 1;
3825 out->args.vc.attr.egress = 1;
3828 out->args.vc.attr.transfer = 1;
3831 out->args.vc.pattern =
3832 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
3834 ctx->object = out->args.vc.pattern;
3835 ctx->objmask = NULL;
3838 out->args.vc.actions =
3839 (void *)RTE_ALIGN_CEIL((uintptr_t)
3840 (out->args.vc.pattern +
3841 out->args.vc.pattern_n),
3843 ctx->object = out->args.vc.actions;
3844 ctx->objmask = NULL;
3851 if (!out->args.vc.actions) {
3852 const struct parse_item_priv *priv = token->priv;
3853 struct rte_flow_item *item =
3854 out->args.vc.pattern + out->args.vc.pattern_n;
3856 data_size = priv->size * 3; /* spec, last, mask */
3857 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
3858 (out->args.vc.data - data_size),
3860 if ((uint8_t *)item + sizeof(*item) > data)
3862 *item = (struct rte_flow_item){
3865 ++out->args.vc.pattern_n;
3867 ctx->objmask = NULL;
3869 const struct parse_action_priv *priv = token->priv;
3870 struct rte_flow_action *action =
3871 out->args.vc.actions + out->args.vc.actions_n;
3873 data_size = priv->size; /* configuration */
3874 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
3875 (out->args.vc.data - data_size),
3877 if ((uint8_t *)action + sizeof(*action) > data)
3879 *action = (struct rte_flow_action){
3881 .conf = data_size ? data : NULL,
3883 ++out->args.vc.actions_n;
3884 ctx->object = action;
3885 ctx->objmask = NULL;
3887 memset(data, 0, data_size);
3888 out->args.vc.data = data;
3889 ctx->objdata = data_size;
3893 /** Parse pattern item parameter type. */
3895 parse_vc_spec(struct context *ctx, const struct token *token,
3896 const char *str, unsigned int len,
3897 void *buf, unsigned int size)
3899 struct buffer *out = buf;
3900 struct rte_flow_item *item;
3906 /* Token name must match. */
3907 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
3909 /* Parse parameter types. */
3910 switch (ctx->curr) {
3911 static const enum index prefix[] = NEXT_ENTRY(PREFIX);
3917 case ITEM_PARAM_SPEC:
3920 case ITEM_PARAM_LAST:
3923 case ITEM_PARAM_PREFIX:
3924 /* Modify next token to expect a prefix. */
3925 if (ctx->next_num < 2)
3927 ctx->next[ctx->next_num - 2] = prefix;
3929 case ITEM_PARAM_MASK:
3935 /* Nothing else to do if there is no buffer. */
3938 if (!out->args.vc.pattern_n)
3940 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
3941 data_size = ctx->objdata / 3; /* spec, last, mask */
3942 /* Point to selected object. */
3943 ctx->object = out->args.vc.data + (data_size * index);
3945 ctx->objmask = out->args.vc.data + (data_size * 2); /* mask */
3946 item->mask = ctx->objmask;
3948 ctx->objmask = NULL;
3949 /* Update relevant item pointer. */
3950 *((const void **[]){ &item->spec, &item->last, &item->mask })[index] =
3955 /** Parse action configuration field. */
3957 parse_vc_conf(struct context *ctx, const struct token *token,
3958 const char *str, unsigned int len,
3959 void *buf, unsigned int size)
3961 struct buffer *out = buf;
3964 /* Token name must match. */
3965 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
3967 /* Nothing else to do if there is no buffer. */
3970 /* Point to selected object. */
3971 ctx->object = out->args.vc.data;
3972 ctx->objmask = NULL;
3976 /** Parse RSS action. */
3978 parse_vc_action_rss(struct context *ctx, const struct token *token,
3979 const char *str, unsigned int len,
3980 void *buf, unsigned int size)
3982 struct buffer *out = buf;
3983 struct rte_flow_action *action;
3984 struct action_rss_data *action_rss_data;
3988 ret = parse_vc(ctx, token, str, len, buf, size);
3991 /* Nothing else to do if there is no buffer. */
3994 if (!out->args.vc.actions_n)
3996 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
3997 /* Point to selected object. */
3998 ctx->object = out->args.vc.data;
3999 ctx->objmask = NULL;
4000 /* Set up default configuration. */
4001 action_rss_data = ctx->object;
4002 *action_rss_data = (struct action_rss_data){
4003 .conf = (struct rte_flow_action_rss){
4004 .func = RTE_ETH_HASH_FUNCTION_DEFAULT,
4007 .key_len = sizeof(action_rss_data->key),
4008 .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM),
4009 .key = action_rss_data->key,
4010 .queue = action_rss_data->queue,
4012 .key = "testpmd's default RSS hash key, "
4013 "override it for better balancing",
4016 for (i = 0; i < action_rss_data->conf.queue_num; ++i)
4017 action_rss_data->queue[i] = i;
4018 if (!port_id_is_invalid(ctx->port, DISABLED_WARN) &&
4019 ctx->port != (portid_t)RTE_PORT_ALL) {
4020 struct rte_eth_dev_info info;
4023 ret2 = rte_eth_dev_info_get(ctx->port, &info);
4027 action_rss_data->conf.key_len =
4028 RTE_MIN(sizeof(action_rss_data->key),
4029 info.hash_key_size);
4031 action->conf = &action_rss_data->conf;
4036 * Parse func field for RSS action.
4038 * The RTE_ETH_HASH_FUNCTION_* value to assign is derived from the
4039 * ACTION_RSS_FUNC_* index that called this function.
4042 parse_vc_action_rss_func(struct context *ctx, const struct token *token,
4043 const char *str, unsigned int len,
4044 void *buf, unsigned int size)
4046 struct action_rss_data *action_rss_data;
4047 enum rte_eth_hash_function func;
4051 /* Token name must match. */
4052 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4054 switch (ctx->curr) {
4055 case ACTION_RSS_FUNC_DEFAULT:
4056 func = RTE_ETH_HASH_FUNCTION_DEFAULT;
4058 case ACTION_RSS_FUNC_TOEPLITZ:
4059 func = RTE_ETH_HASH_FUNCTION_TOEPLITZ;
4061 case ACTION_RSS_FUNC_SIMPLE_XOR:
4062 func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
4064 case ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ:
4065 func = RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
4072 action_rss_data = ctx->object;
4073 action_rss_data->conf.func = func;
4078 * Parse type field for RSS action.
4080 * Valid tokens are type field names and the "end" token.
4083 parse_vc_action_rss_type(struct context *ctx, const struct token *token,
4084 const char *str, unsigned int len,
4085 void *buf, unsigned int size)
4087 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE);
4088 struct action_rss_data *action_rss_data;
4094 if (ctx->curr != ACTION_RSS_TYPE)
4096 if (!(ctx->objdata >> 16) && ctx->object) {
4097 action_rss_data = ctx->object;
4098 action_rss_data->conf.types = 0;
4100 if (!strcmp_partial("end", str, len)) {
4101 ctx->objdata &= 0xffff;
4104 for (i = 0; rss_type_table[i].str; ++i)
4105 if (!strcmp_partial(rss_type_table[i].str, str, len))
4107 if (!rss_type_table[i].str)
4109 ctx->objdata = 1 << 16 | (ctx->objdata & 0xffff);
4111 if (ctx->next_num == RTE_DIM(ctx->next))
4113 ctx->next[ctx->next_num++] = next;
4116 action_rss_data = ctx->object;
4117 action_rss_data->conf.types |= rss_type_table[i].rss_type;
4122 * Parse queue field for RSS action.
4124 * Valid tokens are queue indices and the "end" token.
4127 parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
4128 const char *str, unsigned int len,
4129 void *buf, unsigned int size)
4131 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE);
4132 struct action_rss_data *action_rss_data;
4133 const struct arg *arg;
4140 if (ctx->curr != ACTION_RSS_QUEUE)
4142 i = ctx->objdata >> 16;
4143 if (!strcmp_partial("end", str, len)) {
4144 ctx->objdata &= 0xffff;
4147 if (i >= ACTION_RSS_QUEUE_NUM)
4149 arg = ARGS_ENTRY_ARB(offsetof(struct action_rss_data, queue) +
4150 i * sizeof(action_rss_data->queue[i]),
4151 sizeof(action_rss_data->queue[i]));
4152 if (push_args(ctx, arg))
4154 ret = parse_int(ctx, token, str, len, NULL, 0);
4160 ctx->objdata = i << 16 | (ctx->objdata & 0xffff);
4162 if (ctx->next_num == RTE_DIM(ctx->next))
4164 ctx->next[ctx->next_num++] = next;
4168 action_rss_data = ctx->object;
4169 action_rss_data->conf.queue_num = i;
4170 action_rss_data->conf.queue = i ? action_rss_data->queue : NULL;
4174 /** Parse VXLAN encap action. */
4176 parse_vc_action_vxlan_encap(struct context *ctx, const struct token *token,
4177 const char *str, unsigned int len,
4178 void *buf, unsigned int size)
4180 struct buffer *out = buf;
4181 struct rte_flow_action *action;
4182 struct action_vxlan_encap_data *action_vxlan_encap_data;
4185 ret = parse_vc(ctx, token, str, len, buf, size);
4188 /* Nothing else to do if there is no buffer. */
4191 if (!out->args.vc.actions_n)
4193 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4194 /* Point to selected object. */
4195 ctx->object = out->args.vc.data;
4196 ctx->objmask = NULL;
4197 /* Set up default configuration. */
4198 action_vxlan_encap_data = ctx->object;
4199 *action_vxlan_encap_data = (struct action_vxlan_encap_data){
4200 .conf = (struct rte_flow_action_vxlan_encap){
4201 .definition = action_vxlan_encap_data->items,
4205 .type = RTE_FLOW_ITEM_TYPE_ETH,
4206 .spec = &action_vxlan_encap_data->item_eth,
4207 .mask = &rte_flow_item_eth_mask,
4210 .type = RTE_FLOW_ITEM_TYPE_VLAN,
4211 .spec = &action_vxlan_encap_data->item_vlan,
4212 .mask = &rte_flow_item_vlan_mask,
4215 .type = RTE_FLOW_ITEM_TYPE_IPV4,
4216 .spec = &action_vxlan_encap_data->item_ipv4,
4217 .mask = &rte_flow_item_ipv4_mask,
4220 .type = RTE_FLOW_ITEM_TYPE_UDP,
4221 .spec = &action_vxlan_encap_data->item_udp,
4222 .mask = &rte_flow_item_udp_mask,
4225 .type = RTE_FLOW_ITEM_TYPE_VXLAN,
4226 .spec = &action_vxlan_encap_data->item_vxlan,
4227 .mask = &rte_flow_item_vxlan_mask,
4230 .type = RTE_FLOW_ITEM_TYPE_END,
4235 .tci = vxlan_encap_conf.vlan_tci,
4239 .src_addr = vxlan_encap_conf.ipv4_src,
4240 .dst_addr = vxlan_encap_conf.ipv4_dst,
4243 .src_port = vxlan_encap_conf.udp_src,
4244 .dst_port = vxlan_encap_conf.udp_dst,
4246 .item_vxlan.flags = 0,
4248 memcpy(action_vxlan_encap_data->item_eth.dst.addr_bytes,
4249 vxlan_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
4250 memcpy(action_vxlan_encap_data->item_eth.src.addr_bytes,
4251 vxlan_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
4252 if (!vxlan_encap_conf.select_ipv4) {
4253 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.src_addr,
4254 &vxlan_encap_conf.ipv6_src,
4255 sizeof(vxlan_encap_conf.ipv6_src));
4256 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.dst_addr,
4257 &vxlan_encap_conf.ipv6_dst,
4258 sizeof(vxlan_encap_conf.ipv6_dst));
4259 action_vxlan_encap_data->items[2] = (struct rte_flow_item){
4260 .type = RTE_FLOW_ITEM_TYPE_IPV6,
4261 .spec = &action_vxlan_encap_data->item_ipv6,
4262 .mask = &rte_flow_item_ipv6_mask,
4265 if (!vxlan_encap_conf.select_vlan)
4266 action_vxlan_encap_data->items[1].type =
4267 RTE_FLOW_ITEM_TYPE_VOID;
4268 if (vxlan_encap_conf.select_tos_ttl) {
4269 if (vxlan_encap_conf.select_ipv4) {
4270 static struct rte_flow_item_ipv4 ipv4_mask_tos;
4272 memcpy(&ipv4_mask_tos, &rte_flow_item_ipv4_mask,
4273 sizeof(ipv4_mask_tos));
4274 ipv4_mask_tos.hdr.type_of_service = 0xff;
4275 ipv4_mask_tos.hdr.time_to_live = 0xff;
4276 action_vxlan_encap_data->item_ipv4.hdr.type_of_service =
4277 vxlan_encap_conf.ip_tos;
4278 action_vxlan_encap_data->item_ipv4.hdr.time_to_live =
4279 vxlan_encap_conf.ip_ttl;
4280 action_vxlan_encap_data->items[2].mask =
4283 static struct rte_flow_item_ipv6 ipv6_mask_tos;
4285 memcpy(&ipv6_mask_tos, &rte_flow_item_ipv6_mask,
4286 sizeof(ipv6_mask_tos));
4287 ipv6_mask_tos.hdr.vtc_flow |=
4288 RTE_BE32(0xfful << RTE_IPV6_HDR_TC_SHIFT);
4289 ipv6_mask_tos.hdr.hop_limits = 0xff;
4290 action_vxlan_encap_data->item_ipv6.hdr.vtc_flow |=
4292 ((uint32_t)vxlan_encap_conf.ip_tos <<
4293 RTE_IPV6_HDR_TC_SHIFT);
4294 action_vxlan_encap_data->item_ipv6.hdr.hop_limits =
4295 vxlan_encap_conf.ip_ttl;
4296 action_vxlan_encap_data->items[2].mask =
4300 memcpy(action_vxlan_encap_data->item_vxlan.vni, vxlan_encap_conf.vni,
4301 RTE_DIM(vxlan_encap_conf.vni));
4302 action->conf = &action_vxlan_encap_data->conf;
4306 /** Parse NVGRE encap action. */
4308 parse_vc_action_nvgre_encap(struct context *ctx, const struct token *token,
4309 const char *str, unsigned int len,
4310 void *buf, unsigned int size)
4312 struct buffer *out = buf;
4313 struct rte_flow_action *action;
4314 struct action_nvgre_encap_data *action_nvgre_encap_data;
4317 ret = parse_vc(ctx, token, str, len, buf, size);
4320 /* Nothing else to do if there is no buffer. */
4323 if (!out->args.vc.actions_n)
4325 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4326 /* Point to selected object. */
4327 ctx->object = out->args.vc.data;
4328 ctx->objmask = NULL;
4329 /* Set up default configuration. */
4330 action_nvgre_encap_data = ctx->object;
4331 *action_nvgre_encap_data = (struct action_nvgre_encap_data){
4332 .conf = (struct rte_flow_action_nvgre_encap){
4333 .definition = action_nvgre_encap_data->items,
4337 .type = RTE_FLOW_ITEM_TYPE_ETH,
4338 .spec = &action_nvgre_encap_data->item_eth,
4339 .mask = &rte_flow_item_eth_mask,
4342 .type = RTE_FLOW_ITEM_TYPE_VLAN,
4343 .spec = &action_nvgre_encap_data->item_vlan,
4344 .mask = &rte_flow_item_vlan_mask,
4347 .type = RTE_FLOW_ITEM_TYPE_IPV4,
4348 .spec = &action_nvgre_encap_data->item_ipv4,
4349 .mask = &rte_flow_item_ipv4_mask,
4352 .type = RTE_FLOW_ITEM_TYPE_NVGRE,
4353 .spec = &action_nvgre_encap_data->item_nvgre,
4354 .mask = &rte_flow_item_nvgre_mask,
4357 .type = RTE_FLOW_ITEM_TYPE_END,
4362 .tci = nvgre_encap_conf.vlan_tci,
4366 .src_addr = nvgre_encap_conf.ipv4_src,
4367 .dst_addr = nvgre_encap_conf.ipv4_dst,
4369 .item_nvgre.flow_id = 0,
4371 memcpy(action_nvgre_encap_data->item_eth.dst.addr_bytes,
4372 nvgre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
4373 memcpy(action_nvgre_encap_data->item_eth.src.addr_bytes,
4374 nvgre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
4375 if (!nvgre_encap_conf.select_ipv4) {
4376 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.src_addr,
4377 &nvgre_encap_conf.ipv6_src,
4378 sizeof(nvgre_encap_conf.ipv6_src));
4379 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.dst_addr,
4380 &nvgre_encap_conf.ipv6_dst,
4381 sizeof(nvgre_encap_conf.ipv6_dst));
4382 action_nvgre_encap_data->items[2] = (struct rte_flow_item){
4383 .type = RTE_FLOW_ITEM_TYPE_IPV6,
4384 .spec = &action_nvgre_encap_data->item_ipv6,
4385 .mask = &rte_flow_item_ipv6_mask,
4388 if (!nvgre_encap_conf.select_vlan)
4389 action_nvgre_encap_data->items[1].type =
4390 RTE_FLOW_ITEM_TYPE_VOID;
4391 memcpy(action_nvgre_encap_data->item_nvgre.tni, nvgre_encap_conf.tni,
4392 RTE_DIM(nvgre_encap_conf.tni));
4393 action->conf = &action_nvgre_encap_data->conf;
4397 /** Parse l2 encap action. */
4399 parse_vc_action_l2_encap(struct context *ctx, const struct token *token,
4400 const char *str, unsigned int len,
4401 void *buf, unsigned int size)
4403 struct buffer *out = buf;
4404 struct rte_flow_action *action;
4405 struct action_raw_encap_data *action_encap_data;
4406 struct rte_flow_item_eth eth = { .type = 0, };
4407 struct rte_flow_item_vlan vlan = {
4408 .tci = mplsoudp_encap_conf.vlan_tci,
4414 ret = parse_vc(ctx, token, str, len, buf, size);
4417 /* Nothing else to do if there is no buffer. */
4420 if (!out->args.vc.actions_n)
4422 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4423 /* Point to selected object. */
4424 ctx->object = out->args.vc.data;
4425 ctx->objmask = NULL;
4426 /* Copy the headers to the buffer. */
4427 action_encap_data = ctx->object;
4428 *action_encap_data = (struct action_raw_encap_data) {
4429 .conf = (struct rte_flow_action_raw_encap){
4430 .data = action_encap_data->data,
4434 header = action_encap_data->data;
4435 if (l2_encap_conf.select_vlan)
4436 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
4437 else if (l2_encap_conf.select_ipv4)
4438 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
4440 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
4441 memcpy(eth.dst.addr_bytes,
4442 l2_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
4443 memcpy(eth.src.addr_bytes,
4444 l2_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
4445 memcpy(header, ð, sizeof(eth));
4446 header += sizeof(eth);
4447 if (l2_encap_conf.select_vlan) {
4448 if (l2_encap_conf.select_ipv4)
4449 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
4451 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
4452 memcpy(header, &vlan, sizeof(vlan));
4453 header += sizeof(vlan);
4455 action_encap_data->conf.size = header -
4456 action_encap_data->data;
4457 action->conf = &action_encap_data->conf;
4461 /** Parse l2 decap action. */
4463 parse_vc_action_l2_decap(struct context *ctx, const struct token *token,
4464 const char *str, unsigned int len,
4465 void *buf, unsigned int size)
4467 struct buffer *out = buf;
4468 struct rte_flow_action *action;
4469 struct action_raw_decap_data *action_decap_data;
4470 struct rte_flow_item_eth eth = { .type = 0, };
4471 struct rte_flow_item_vlan vlan = {
4472 .tci = mplsoudp_encap_conf.vlan_tci,
4478 ret = parse_vc(ctx, token, str, len, buf, size);
4481 /* Nothing else to do if there is no buffer. */
4484 if (!out->args.vc.actions_n)
4486 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4487 /* Point to selected object. */
4488 ctx->object = out->args.vc.data;
4489 ctx->objmask = NULL;
4490 /* Copy the headers to the buffer. */
4491 action_decap_data = ctx->object;
4492 *action_decap_data = (struct action_raw_decap_data) {
4493 .conf = (struct rte_flow_action_raw_decap){
4494 .data = action_decap_data->data,
4498 header = action_decap_data->data;
4499 if (l2_decap_conf.select_vlan)
4500 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
4501 memcpy(header, ð, sizeof(eth));
4502 header += sizeof(eth);
4503 if (l2_decap_conf.select_vlan) {
4504 memcpy(header, &vlan, sizeof(vlan));
4505 header += sizeof(vlan);
4507 action_decap_data->conf.size = header -
4508 action_decap_data->data;
4509 action->conf = &action_decap_data->conf;
4513 #define ETHER_TYPE_MPLS_UNICAST 0x8847
4515 /** Parse MPLSOGRE encap action. */
4517 parse_vc_action_mplsogre_encap(struct context *ctx, const struct token *token,
4518 const char *str, unsigned int len,
4519 void *buf, unsigned int size)
4521 struct buffer *out = buf;
4522 struct rte_flow_action *action;
4523 struct action_raw_encap_data *action_encap_data;
4524 struct rte_flow_item_eth eth = { .type = 0, };
4525 struct rte_flow_item_vlan vlan = {
4526 .tci = mplsogre_encap_conf.vlan_tci,
4529 struct rte_flow_item_ipv4 ipv4 = {
4531 .src_addr = mplsogre_encap_conf.ipv4_src,
4532 .dst_addr = mplsogre_encap_conf.ipv4_dst,
4533 .next_proto_id = IPPROTO_GRE,
4534 .version_ihl = RTE_IPV4_VHL_DEF,
4535 .time_to_live = IPDEFTTL,
4538 struct rte_flow_item_ipv6 ipv6 = {
4540 .proto = IPPROTO_GRE,
4541 .hop_limits = IPDEFTTL,
4544 struct rte_flow_item_gre gre = {
4545 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
4547 struct rte_flow_item_mpls mpls;
4551 ret = parse_vc(ctx, token, str, len, buf, size);
4554 /* Nothing else to do if there is no buffer. */
4557 if (!out->args.vc.actions_n)
4559 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4560 /* Point to selected object. */
4561 ctx->object = out->args.vc.data;
4562 ctx->objmask = NULL;
4563 /* Copy the headers to the buffer. */
4564 action_encap_data = ctx->object;
4565 *action_encap_data = (struct action_raw_encap_data) {
4566 .conf = (struct rte_flow_action_raw_encap){
4567 .data = action_encap_data->data,
4572 header = action_encap_data->data;
4573 if (mplsogre_encap_conf.select_vlan)
4574 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
4575 else if (mplsogre_encap_conf.select_ipv4)
4576 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
4578 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
4579 memcpy(eth.dst.addr_bytes,
4580 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
4581 memcpy(eth.src.addr_bytes,
4582 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
4583 memcpy(header, ð, sizeof(eth));
4584 header += sizeof(eth);
4585 if (mplsogre_encap_conf.select_vlan) {
4586 if (mplsogre_encap_conf.select_ipv4)
4587 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
4589 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
4590 memcpy(header, &vlan, sizeof(vlan));
4591 header += sizeof(vlan);
4593 if (mplsogre_encap_conf.select_ipv4) {
4594 memcpy(header, &ipv4, sizeof(ipv4));
4595 header += sizeof(ipv4);
4597 memcpy(&ipv6.hdr.src_addr,
4598 &mplsogre_encap_conf.ipv6_src,
4599 sizeof(mplsogre_encap_conf.ipv6_src));
4600 memcpy(&ipv6.hdr.dst_addr,
4601 &mplsogre_encap_conf.ipv6_dst,
4602 sizeof(mplsogre_encap_conf.ipv6_dst));
4603 memcpy(header, &ipv6, sizeof(ipv6));
4604 header += sizeof(ipv6);
4606 memcpy(header, &gre, sizeof(gre));
4607 header += sizeof(gre);
4608 memcpy(mpls.label_tc_s, mplsogre_encap_conf.label,
4609 RTE_DIM(mplsogre_encap_conf.label));
4610 mpls.label_tc_s[2] |= 0x1;
4611 memcpy(header, &mpls, sizeof(mpls));
4612 header += sizeof(mpls);
4613 action_encap_data->conf.size = header -
4614 action_encap_data->data;
4615 action->conf = &action_encap_data->conf;
4619 /** Parse MPLSOGRE decap action. */
4621 parse_vc_action_mplsogre_decap(struct context *ctx, const struct token *token,
4622 const char *str, unsigned int len,
4623 void *buf, unsigned int size)
4625 struct buffer *out = buf;
4626 struct rte_flow_action *action;
4627 struct action_raw_decap_data *action_decap_data;
4628 struct rte_flow_item_eth eth = { .type = 0, };
4629 struct rte_flow_item_vlan vlan = {.tci = 0};
4630 struct rte_flow_item_ipv4 ipv4 = {
4632 .next_proto_id = IPPROTO_GRE,
4635 struct rte_flow_item_ipv6 ipv6 = {
4637 .proto = IPPROTO_GRE,
4640 struct rte_flow_item_gre gre = {
4641 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
4643 struct rte_flow_item_mpls mpls;
4647 ret = parse_vc(ctx, token, str, len, buf, size);
4650 /* Nothing else to do if there is no buffer. */
4653 if (!out->args.vc.actions_n)
4655 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4656 /* Point to selected object. */
4657 ctx->object = out->args.vc.data;
4658 ctx->objmask = NULL;
4659 /* Copy the headers to the buffer. */
4660 action_decap_data = ctx->object;
4661 *action_decap_data = (struct action_raw_decap_data) {
4662 .conf = (struct rte_flow_action_raw_decap){
4663 .data = action_decap_data->data,
4667 header = action_decap_data->data;
4668 if (mplsogre_decap_conf.select_vlan)
4669 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
4670 else if (mplsogre_encap_conf.select_ipv4)
4671 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
4673 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
4674 memcpy(eth.dst.addr_bytes,
4675 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
4676 memcpy(eth.src.addr_bytes,
4677 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
4678 memcpy(header, ð, sizeof(eth));
4679 header += sizeof(eth);
4680 if (mplsogre_encap_conf.select_vlan) {
4681 if (mplsogre_encap_conf.select_ipv4)
4682 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
4684 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
4685 memcpy(header, &vlan, sizeof(vlan));
4686 header += sizeof(vlan);
4688 if (mplsogre_encap_conf.select_ipv4) {
4689 memcpy(header, &ipv4, sizeof(ipv4));
4690 header += sizeof(ipv4);
4692 memcpy(header, &ipv6, sizeof(ipv6));
4693 header += sizeof(ipv6);
4695 memcpy(header, &gre, sizeof(gre));
4696 header += sizeof(gre);
4697 memset(&mpls, 0, sizeof(mpls));
4698 memcpy(header, &mpls, sizeof(mpls));
4699 header += sizeof(mpls);
4700 action_decap_data->conf.size = header -
4701 action_decap_data->data;
4702 action->conf = &action_decap_data->conf;
4706 /** Parse MPLSOUDP encap action. */
4708 parse_vc_action_mplsoudp_encap(struct context *ctx, const struct token *token,
4709 const char *str, unsigned int len,
4710 void *buf, unsigned int size)
4712 struct buffer *out = buf;
4713 struct rte_flow_action *action;
4714 struct action_raw_encap_data *action_encap_data;
4715 struct rte_flow_item_eth eth = { .type = 0, };
4716 struct rte_flow_item_vlan vlan = {
4717 .tci = mplsoudp_encap_conf.vlan_tci,
4720 struct rte_flow_item_ipv4 ipv4 = {
4722 .src_addr = mplsoudp_encap_conf.ipv4_src,
4723 .dst_addr = mplsoudp_encap_conf.ipv4_dst,
4724 .next_proto_id = IPPROTO_UDP,
4725 .version_ihl = RTE_IPV4_VHL_DEF,
4726 .time_to_live = IPDEFTTL,
4729 struct rte_flow_item_ipv6 ipv6 = {
4731 .proto = IPPROTO_UDP,
4732 .hop_limits = IPDEFTTL,
4735 struct rte_flow_item_udp udp = {
4737 .src_port = mplsoudp_encap_conf.udp_src,
4738 .dst_port = mplsoudp_encap_conf.udp_dst,
4741 struct rte_flow_item_mpls mpls;
4745 ret = parse_vc(ctx, token, str, len, buf, size);
4748 /* Nothing else to do if there is no buffer. */
4751 if (!out->args.vc.actions_n)
4753 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4754 /* Point to selected object. */
4755 ctx->object = out->args.vc.data;
4756 ctx->objmask = NULL;
4757 /* Copy the headers to the buffer. */
4758 action_encap_data = ctx->object;
4759 *action_encap_data = (struct action_raw_encap_data) {
4760 .conf = (struct rte_flow_action_raw_encap){
4761 .data = action_encap_data->data,
4766 header = action_encap_data->data;
4767 if (mplsoudp_encap_conf.select_vlan)
4768 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
4769 else if (mplsoudp_encap_conf.select_ipv4)
4770 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
4772 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
4773 memcpy(eth.dst.addr_bytes,
4774 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
4775 memcpy(eth.src.addr_bytes,
4776 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
4777 memcpy(header, ð, sizeof(eth));
4778 header += sizeof(eth);
4779 if (mplsoudp_encap_conf.select_vlan) {
4780 if (mplsoudp_encap_conf.select_ipv4)
4781 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
4783 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
4784 memcpy(header, &vlan, sizeof(vlan));
4785 header += sizeof(vlan);
4787 if (mplsoudp_encap_conf.select_ipv4) {
4788 memcpy(header, &ipv4, sizeof(ipv4));
4789 header += sizeof(ipv4);
4791 memcpy(&ipv6.hdr.src_addr,
4792 &mplsoudp_encap_conf.ipv6_src,
4793 sizeof(mplsoudp_encap_conf.ipv6_src));
4794 memcpy(&ipv6.hdr.dst_addr,
4795 &mplsoudp_encap_conf.ipv6_dst,
4796 sizeof(mplsoudp_encap_conf.ipv6_dst));
4797 memcpy(header, &ipv6, sizeof(ipv6));
4798 header += sizeof(ipv6);
4800 memcpy(header, &udp, sizeof(udp));
4801 header += sizeof(udp);
4802 memcpy(mpls.label_tc_s, mplsoudp_encap_conf.label,
4803 RTE_DIM(mplsoudp_encap_conf.label));
4804 mpls.label_tc_s[2] |= 0x1;
4805 memcpy(header, &mpls, sizeof(mpls));
4806 header += sizeof(mpls);
4807 action_encap_data->conf.size = header -
4808 action_encap_data->data;
4809 action->conf = &action_encap_data->conf;
4813 /** Parse MPLSOUDP decap action. */
4815 parse_vc_action_mplsoudp_decap(struct context *ctx, const struct token *token,
4816 const char *str, unsigned int len,
4817 void *buf, unsigned int size)
4819 struct buffer *out = buf;
4820 struct rte_flow_action *action;
4821 struct action_raw_decap_data *action_decap_data;
4822 struct rte_flow_item_eth eth = { .type = 0, };
4823 struct rte_flow_item_vlan vlan = {.tci = 0};
4824 struct rte_flow_item_ipv4 ipv4 = {
4826 .next_proto_id = IPPROTO_UDP,
4829 struct rte_flow_item_ipv6 ipv6 = {
4831 .proto = IPPROTO_UDP,
4834 struct rte_flow_item_udp udp = {
4836 .dst_port = rte_cpu_to_be_16(6635),
4839 struct rte_flow_item_mpls mpls;
4843 ret = parse_vc(ctx, token, str, len, buf, size);
4846 /* Nothing else to do if there is no buffer. */
4849 if (!out->args.vc.actions_n)
4851 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4852 /* Point to selected object. */
4853 ctx->object = out->args.vc.data;
4854 ctx->objmask = NULL;
4855 /* Copy the headers to the buffer. */
4856 action_decap_data = ctx->object;
4857 *action_decap_data = (struct action_raw_decap_data) {
4858 .conf = (struct rte_flow_action_raw_decap){
4859 .data = action_decap_data->data,
4863 header = action_decap_data->data;
4864 if (mplsoudp_decap_conf.select_vlan)
4865 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
4866 else if (mplsoudp_encap_conf.select_ipv4)
4867 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
4869 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
4870 memcpy(eth.dst.addr_bytes,
4871 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
4872 memcpy(eth.src.addr_bytes,
4873 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
4874 memcpy(header, ð, sizeof(eth));
4875 header += sizeof(eth);
4876 if (mplsoudp_encap_conf.select_vlan) {
4877 if (mplsoudp_encap_conf.select_ipv4)
4878 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
4880 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
4881 memcpy(header, &vlan, sizeof(vlan));
4882 header += sizeof(vlan);
4884 if (mplsoudp_encap_conf.select_ipv4) {
4885 memcpy(header, &ipv4, sizeof(ipv4));
4886 header += sizeof(ipv4);
4888 memcpy(header, &ipv6, sizeof(ipv6));
4889 header += sizeof(ipv6);
4891 memcpy(header, &udp, sizeof(udp));
4892 header += sizeof(udp);
4893 memset(&mpls, 0, sizeof(mpls));
4894 memcpy(header, &mpls, sizeof(mpls));
4895 header += sizeof(mpls);
4896 action_decap_data->conf.size = header -
4897 action_decap_data->data;
4898 action->conf = &action_decap_data->conf;
4903 parse_vc_action_raw_decap_index(struct context *ctx, const struct token *token,
4904 const char *str, unsigned int len, void *buf,
4907 struct action_raw_decap_data *action_raw_decap_data;
4908 struct rte_flow_action *action;
4909 const struct arg *arg;
4910 struct buffer *out = buf;
4914 RTE_SET_USED(token);
4917 arg = ARGS_ENTRY_ARB_BOUNDED
4918 (offsetof(struct action_raw_decap_data, idx),
4919 sizeof(((struct action_raw_decap_data *)0)->idx),
4920 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
4921 if (push_args(ctx, arg))
4923 ret = parse_int(ctx, token, str, len, NULL, 0);
4930 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4931 action_raw_decap_data = ctx->object;
4932 idx = action_raw_decap_data->idx;
4933 action_raw_decap_data->conf.data = raw_decap_confs[idx].data;
4934 action_raw_decap_data->conf.size = raw_decap_confs[idx].size;
4935 action->conf = &action_raw_decap_data->conf;
4941 parse_vc_action_raw_encap_index(struct context *ctx, const struct token *token,
4942 const char *str, unsigned int len, void *buf,
4945 struct action_raw_encap_data *action_raw_encap_data;
4946 struct rte_flow_action *action;
4947 const struct arg *arg;
4948 struct buffer *out = buf;
4952 RTE_SET_USED(token);
4955 if (ctx->curr != ACTION_RAW_ENCAP_INDEX_VALUE)
4957 arg = ARGS_ENTRY_ARB_BOUNDED
4958 (offsetof(struct action_raw_encap_data, idx),
4959 sizeof(((struct action_raw_encap_data *)0)->idx),
4960 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
4961 if (push_args(ctx, arg))
4963 ret = parse_int(ctx, token, str, len, NULL, 0);
4970 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4971 action_raw_encap_data = ctx->object;
4972 idx = action_raw_encap_data->idx;
4973 action_raw_encap_data->conf.data = raw_encap_confs[idx].data;
4974 action_raw_encap_data->conf.size = raw_encap_confs[idx].size;
4975 action_raw_encap_data->conf.preserve = NULL;
4976 action->conf = &action_raw_encap_data->conf;
4981 parse_vc_action_raw_encap(struct context *ctx, const struct token *token,
4982 const char *str, unsigned int len, void *buf,
4985 struct buffer *out = buf;
4986 struct rte_flow_action *action;
4987 struct action_raw_encap_data *action_raw_encap_data = NULL;
4990 ret = parse_vc(ctx, token, str, len, buf, size);
4993 /* Nothing else to do if there is no buffer. */
4996 if (!out->args.vc.actions_n)
4998 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4999 /* Point to selected object. */
5000 ctx->object = out->args.vc.data;
5001 ctx->objmask = NULL;
5002 /* Copy the headers to the buffer. */
5003 action_raw_encap_data = ctx->object;
5004 action_raw_encap_data->conf.data = raw_encap_confs[0].data;
5005 action_raw_encap_data->conf.preserve = NULL;
5006 action_raw_encap_data->conf.size = raw_encap_confs[0].size;
5007 action->conf = &action_raw_encap_data->conf;
5012 parse_vc_action_raw_decap(struct context *ctx, const struct token *token,
5013 const char *str, unsigned int len, void *buf,
5016 struct buffer *out = buf;
5017 struct rte_flow_action *action;
5018 struct action_raw_decap_data *action_raw_decap_data = NULL;
5021 ret = parse_vc(ctx, token, str, len, buf, size);
5024 /* Nothing else to do if there is no buffer. */
5027 if (!out->args.vc.actions_n)
5029 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5030 /* Point to selected object. */
5031 ctx->object = out->args.vc.data;
5032 ctx->objmask = NULL;
5033 /* Copy the headers to the buffer. */
5034 action_raw_decap_data = ctx->object;
5035 action_raw_decap_data->conf.data = raw_decap_confs[0].data;
5036 action_raw_decap_data->conf.size = raw_decap_confs[0].size;
5037 action->conf = &action_raw_decap_data->conf;
5042 parse_vc_action_set_meta(struct context *ctx, const struct token *token,
5043 const char *str, unsigned int len, void *buf,
5048 ret = parse_vc(ctx, token, str, len, buf, size);
5051 ret = rte_flow_dynf_metadata_register();
5057 /** Parse tokens for destroy command. */
5059 parse_destroy(struct context *ctx, const struct token *token,
5060 const char *str, unsigned int len,
5061 void *buf, unsigned int size)
5063 struct buffer *out = buf;
5065 /* Token name must match. */
5066 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5068 /* Nothing else to do if there is no buffer. */
5071 if (!out->command) {
5072 if (ctx->curr != DESTROY)
5074 if (sizeof(*out) > size)
5076 out->command = ctx->curr;
5079 ctx->objmask = NULL;
5080 out->args.destroy.rule =
5081 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5085 if (((uint8_t *)(out->args.destroy.rule + out->args.destroy.rule_n) +
5086 sizeof(*out->args.destroy.rule)) > (uint8_t *)out + size)
5089 ctx->object = out->args.destroy.rule + out->args.destroy.rule_n++;
5090 ctx->objmask = NULL;
5094 /** Parse tokens for flush command. */
5096 parse_flush(struct context *ctx, const struct token *token,
5097 const char *str, unsigned int len,
5098 void *buf, unsigned int size)
5100 struct buffer *out = buf;
5102 /* Token name must match. */
5103 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5105 /* Nothing else to do if there is no buffer. */
5108 if (!out->command) {
5109 if (ctx->curr != FLUSH)
5111 if (sizeof(*out) > size)
5113 out->command = ctx->curr;
5116 ctx->objmask = NULL;
5121 /** Parse tokens for query command. */
5123 parse_query(struct context *ctx, const struct token *token,
5124 const char *str, unsigned int len,
5125 void *buf, unsigned int size)
5127 struct buffer *out = buf;
5129 /* Token name must match. */
5130 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5132 /* Nothing else to do if there is no buffer. */
5135 if (!out->command) {
5136 if (ctx->curr != QUERY)
5138 if (sizeof(*out) > size)
5140 out->command = ctx->curr;
5143 ctx->objmask = NULL;
5148 /** Parse action names. */
5150 parse_action(struct context *ctx, const struct token *token,
5151 const char *str, unsigned int len,
5152 void *buf, unsigned int size)
5154 struct buffer *out = buf;
5155 const struct arg *arg = pop_args(ctx);
5159 /* Argument is expected. */
5162 /* Parse action name. */
5163 for (i = 0; next_action[i]; ++i) {
5164 const struct parse_action_priv *priv;
5166 token = &token_list[next_action[i]];
5167 if (strcmp_partial(token->name, str, len))
5173 memcpy((uint8_t *)ctx->object + arg->offset,
5179 push_args(ctx, arg);
5183 /** Parse tokens for list command. */
5185 parse_list(struct context *ctx, const struct token *token,
5186 const char *str, unsigned int len,
5187 void *buf, unsigned int size)
5189 struct buffer *out = buf;
5191 /* Token name must match. */
5192 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5194 /* Nothing else to do if there is no buffer. */
5197 if (!out->command) {
5198 if (ctx->curr != LIST)
5200 if (sizeof(*out) > size)
5202 out->command = ctx->curr;
5205 ctx->objmask = NULL;
5206 out->args.list.group =
5207 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5211 if (((uint8_t *)(out->args.list.group + out->args.list.group_n) +
5212 sizeof(*out->args.list.group)) > (uint8_t *)out + size)
5215 ctx->object = out->args.list.group + out->args.list.group_n++;
5216 ctx->objmask = NULL;
5220 /** Parse tokens for isolate command. */
5222 parse_isolate(struct context *ctx, const struct token *token,
5223 const char *str, unsigned int len,
5224 void *buf, unsigned int size)
5226 struct buffer *out = buf;
5228 /* Token name must match. */
5229 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5231 /* Nothing else to do if there is no buffer. */
5234 if (!out->command) {
5235 if (ctx->curr != ISOLATE)
5237 if (sizeof(*out) > size)
5239 out->command = ctx->curr;
5242 ctx->objmask = NULL;
5248 * Parse signed/unsigned integers 8 to 64-bit long.
5250 * Last argument (ctx->args) is retrieved to determine integer type and
5254 parse_int(struct context *ctx, const struct token *token,
5255 const char *str, unsigned int len,
5256 void *buf, unsigned int size)
5258 const struct arg *arg = pop_args(ctx);
5263 /* Argument is expected. */
5268 (uintmax_t)strtoimax(str, &end, 0) :
5269 strtoumax(str, &end, 0);
5270 if (errno || (size_t)(end - str) != len)
5273 ((arg->sign && ((intmax_t)u < (intmax_t)arg->min ||
5274 (intmax_t)u > (intmax_t)arg->max)) ||
5275 (!arg->sign && (u < arg->min || u > arg->max))))
5280 if (!arg_entry_bf_fill(ctx->object, u, arg) ||
5281 !arg_entry_bf_fill(ctx->objmask, -1, arg))
5285 buf = (uint8_t *)ctx->object + arg->offset;
5287 if (u > RTE_LEN2MASK(size * CHAR_BIT, uint64_t))
5291 case sizeof(uint8_t):
5292 *(uint8_t *)buf = u;
5294 case sizeof(uint16_t):
5295 *(uint16_t *)buf = arg->hton ? rte_cpu_to_be_16(u) : u;
5297 case sizeof(uint8_t [3]):
5298 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
5300 ((uint8_t *)buf)[0] = u;
5301 ((uint8_t *)buf)[1] = u >> 8;
5302 ((uint8_t *)buf)[2] = u >> 16;
5306 ((uint8_t *)buf)[0] = u >> 16;
5307 ((uint8_t *)buf)[1] = u >> 8;
5308 ((uint8_t *)buf)[2] = u;
5310 case sizeof(uint32_t):
5311 *(uint32_t *)buf = arg->hton ? rte_cpu_to_be_32(u) : u;
5313 case sizeof(uint64_t):
5314 *(uint64_t *)buf = arg->hton ? rte_cpu_to_be_64(u) : u;
5319 if (ctx->objmask && buf != (uint8_t *)ctx->objmask + arg->offset) {
5321 buf = (uint8_t *)ctx->objmask + arg->offset;
5326 push_args(ctx, arg);
5333 * Three arguments (ctx->args) are retrieved from the stack to store data,
5334 * its actual length and address (in that order).
5337 parse_string(struct context *ctx, const struct token *token,
5338 const char *str, unsigned int len,
5339 void *buf, unsigned int size)
5341 const struct arg *arg_data = pop_args(ctx);
5342 const struct arg *arg_len = pop_args(ctx);
5343 const struct arg *arg_addr = pop_args(ctx);
5344 char tmp[16]; /* Ought to be enough. */
5347 /* Arguments are expected. */
5351 push_args(ctx, arg_data);
5355 push_args(ctx, arg_len);
5356 push_args(ctx, arg_data);
5359 size = arg_data->size;
5360 /* Bit-mask fill is not supported. */
5361 if (arg_data->mask || size < len)
5365 /* Let parse_int() fill length information first. */
5366 ret = snprintf(tmp, sizeof(tmp), "%u", len);
5369 push_args(ctx, arg_len);
5370 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
5375 buf = (uint8_t *)ctx->object + arg_data->offset;
5376 /* Output buffer is not necessarily NUL-terminated. */
5377 memcpy(buf, str, len);
5378 memset((uint8_t *)buf + len, 0x00, size - len);
5380 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
5381 /* Save address if requested. */
5382 if (arg_addr->size) {
5383 memcpy((uint8_t *)ctx->object + arg_addr->offset,
5385 (uint8_t *)ctx->object + arg_data->offset
5389 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
5391 (uint8_t *)ctx->objmask + arg_data->offset
5397 push_args(ctx, arg_addr);
5398 push_args(ctx, arg_len);
5399 push_args(ctx, arg_data);
5404 parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
5410 /* Check input parameters */
5411 if ((src == NULL) ||
5417 /* Convert chars to bytes */
5418 for (i = 0, len = 0; i < *size; i += 2) {
5419 snprintf(tmp, 3, "%s", src + i);
5420 dst[len++] = strtoul(tmp, &c, 16);
5435 parse_hex(struct context *ctx, const struct token *token,
5436 const char *str, unsigned int len,
5437 void *buf, unsigned int size)
5439 const struct arg *arg_data = pop_args(ctx);
5440 const struct arg *arg_len = pop_args(ctx);
5441 const struct arg *arg_addr = pop_args(ctx);
5442 char tmp[16]; /* Ought to be enough. */
5444 unsigned int hexlen = len;
5445 unsigned int length = 256;
5446 uint8_t hex_tmp[length];
5448 /* Arguments are expected. */
5452 push_args(ctx, arg_data);
5456 push_args(ctx, arg_len);
5457 push_args(ctx, arg_data);
5460 size = arg_data->size;
5461 /* Bit-mask fill is not supported. */
5467 /* translate bytes string to array. */
5468 if (str[0] == '0' && ((str[1] == 'x') ||
5473 if (hexlen > length)
5475 ret = parse_hex_string(str, hex_tmp, &hexlen);
5478 /* Let parse_int() fill length information first. */
5479 ret = snprintf(tmp, sizeof(tmp), "%u", hexlen);
5482 push_args(ctx, arg_len);
5483 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
5488 buf = (uint8_t *)ctx->object + arg_data->offset;
5489 /* Output buffer is not necessarily NUL-terminated. */
5490 memcpy(buf, hex_tmp, hexlen);
5491 memset((uint8_t *)buf + hexlen, 0x00, size - hexlen);
5493 memset((uint8_t *)ctx->objmask + arg_data->offset,
5495 /* Save address if requested. */
5496 if (arg_addr->size) {
5497 memcpy((uint8_t *)ctx->object + arg_addr->offset,
5499 (uint8_t *)ctx->object + arg_data->offset
5503 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
5505 (uint8_t *)ctx->objmask + arg_data->offset
5511 push_args(ctx, arg_addr);
5512 push_args(ctx, arg_len);
5513 push_args(ctx, arg_data);
5519 * Parse a MAC address.
5521 * Last argument (ctx->args) is retrieved to determine storage size and
5525 parse_mac_addr(struct context *ctx, const struct token *token,
5526 const char *str, unsigned int len,
5527 void *buf, unsigned int size)
5529 const struct arg *arg = pop_args(ctx);
5530 struct rte_ether_addr tmp;
5534 /* Argument is expected. */
5538 /* Bit-mask fill is not supported. */
5539 if (arg->mask || size != sizeof(tmp))
5541 /* Only network endian is supported. */
5544 ret = cmdline_parse_etheraddr(NULL, str, &tmp, size);
5545 if (ret < 0 || (unsigned int)ret != len)
5549 buf = (uint8_t *)ctx->object + arg->offset;
5550 memcpy(buf, &tmp, size);
5552 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
5555 push_args(ctx, arg);
5560 * Parse an IPv4 address.
5562 * Last argument (ctx->args) is retrieved to determine storage size and
5566 parse_ipv4_addr(struct context *ctx, const struct token *token,
5567 const char *str, unsigned int len,
5568 void *buf, unsigned int size)
5570 const struct arg *arg = pop_args(ctx);
5575 /* Argument is expected. */
5579 /* Bit-mask fill is not supported. */
5580 if (arg->mask || size != sizeof(tmp))
5582 /* Only network endian is supported. */
5585 memcpy(str2, str, len);
5587 ret = inet_pton(AF_INET, str2, &tmp);
5589 /* Attempt integer parsing. */
5590 push_args(ctx, arg);
5591 return parse_int(ctx, token, str, len, buf, size);
5595 buf = (uint8_t *)ctx->object + arg->offset;
5596 memcpy(buf, &tmp, size);
5598 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
5601 push_args(ctx, arg);
5606 * Parse an IPv6 address.
5608 * Last argument (ctx->args) is retrieved to determine storage size and
5612 parse_ipv6_addr(struct context *ctx, const struct token *token,
5613 const char *str, unsigned int len,
5614 void *buf, unsigned int size)
5616 const struct arg *arg = pop_args(ctx);
5618 struct in6_addr tmp;
5622 /* Argument is expected. */
5626 /* Bit-mask fill is not supported. */
5627 if (arg->mask || size != sizeof(tmp))
5629 /* Only network endian is supported. */
5632 memcpy(str2, str, len);
5634 ret = inet_pton(AF_INET6, str2, &tmp);
5639 buf = (uint8_t *)ctx->object + arg->offset;
5640 memcpy(buf, &tmp, size);
5642 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
5645 push_args(ctx, arg);
5649 /** Boolean values (even indices stand for false). */
5650 static const char *const boolean_name[] = {
5660 * Parse a boolean value.
5662 * Last argument (ctx->args) is retrieved to determine storage size and
5666 parse_boolean(struct context *ctx, const struct token *token,
5667 const char *str, unsigned int len,
5668 void *buf, unsigned int size)
5670 const struct arg *arg = pop_args(ctx);
5674 /* Argument is expected. */
5677 for (i = 0; boolean_name[i]; ++i)
5678 if (!strcmp_partial(boolean_name[i], str, len))
5680 /* Process token as integer. */
5681 if (boolean_name[i])
5682 str = i & 1 ? "1" : "0";
5683 push_args(ctx, arg);
5684 ret = parse_int(ctx, token, str, strlen(str), buf, size);
5685 return ret > 0 ? (int)len : ret;
5688 /** Parse port and update context. */
5690 parse_port(struct context *ctx, const struct token *token,
5691 const char *str, unsigned int len,
5692 void *buf, unsigned int size)
5694 struct buffer *out = &(struct buffer){ .port = 0 };
5702 ctx->objmask = NULL;
5703 size = sizeof(*out);
5705 ret = parse_int(ctx, token, str, len, out, size);
5707 ctx->port = out->port;
5713 /** Parse set command, initialize output buffer for subsequent tokens. */
5715 parse_set_raw_encap_decap(struct context *ctx, const struct token *token,
5716 const char *str, unsigned int len,
5717 void *buf, unsigned int size)
5719 struct buffer *out = buf;
5721 /* Token name must match. */
5722 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5724 /* Nothing else to do if there is no buffer. */
5727 /* Make sure buffer is large enough. */
5728 if (size < sizeof(*out))
5731 ctx->objmask = NULL;
5735 out->command = ctx->curr;
5740 * Parse set raw_encap/raw_decap command,
5741 * initialize output buffer for subsequent tokens.
5744 parse_set_init(struct context *ctx, const struct token *token,
5745 const char *str, unsigned int len,
5746 void *buf, unsigned int size)
5748 struct buffer *out = buf;
5750 /* Token name must match. */
5751 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5753 /* Nothing else to do if there is no buffer. */
5756 /* Make sure buffer is large enough. */
5757 if (size < sizeof(*out))
5759 /* Initialize buffer. */
5760 memset(out, 0x00, sizeof(*out));
5761 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
5764 ctx->objmask = NULL;
5765 if (!out->command) {
5766 if (ctx->curr != SET)
5768 if (sizeof(*out) > size)
5770 out->command = ctx->curr;
5771 out->args.vc.data = (uint8_t *)out + size;
5772 /* All we need is pattern */
5773 out->args.vc.pattern =
5774 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5776 ctx->object = out->args.vc.pattern;
5781 /** No completion. */
5783 comp_none(struct context *ctx, const struct token *token,
5784 unsigned int ent, char *buf, unsigned int size)
5794 /** Complete boolean values. */
5796 comp_boolean(struct context *ctx, const struct token *token,
5797 unsigned int ent, char *buf, unsigned int size)
5803 for (i = 0; boolean_name[i]; ++i)
5804 if (buf && i == ent)
5805 return strlcpy(buf, boolean_name[i], size);
5811 /** Complete action names. */
5813 comp_action(struct context *ctx, const struct token *token,
5814 unsigned int ent, char *buf, unsigned int size)
5820 for (i = 0; next_action[i]; ++i)
5821 if (buf && i == ent)
5822 return strlcpy(buf, token_list[next_action[i]].name,
5829 /** Complete available ports. */
5831 comp_port(struct context *ctx, const struct token *token,
5832 unsigned int ent, char *buf, unsigned int size)
5839 RTE_ETH_FOREACH_DEV(p) {
5840 if (buf && i == ent)
5841 return snprintf(buf, size, "%u", p);
5849 /** Complete available rule IDs. */
5851 comp_rule_id(struct context *ctx, const struct token *token,
5852 unsigned int ent, char *buf, unsigned int size)
5855 struct rte_port *port;
5856 struct port_flow *pf;
5859 if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
5860 ctx->port == (portid_t)RTE_PORT_ALL)
5862 port = &ports[ctx->port];
5863 for (pf = port->flow_list; pf != NULL; pf = pf->next) {
5864 if (buf && i == ent)
5865 return snprintf(buf, size, "%u", pf->id);
5873 /** Complete type field for RSS action. */
5875 comp_vc_action_rss_type(struct context *ctx, const struct token *token,
5876 unsigned int ent, char *buf, unsigned int size)
5882 for (i = 0; rss_type_table[i].str; ++i)
5887 return strlcpy(buf, rss_type_table[ent].str, size);
5889 return snprintf(buf, size, "end");
5893 /** Complete queue field for RSS action. */
5895 comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
5896 unsigned int ent, char *buf, unsigned int size)
5903 return snprintf(buf, size, "%u", ent);
5905 return snprintf(buf, size, "end");
5909 /** Complete index number for set raw_encap/raw_decap commands. */
5911 comp_set_raw_index(struct context *ctx, const struct token *token,
5912 unsigned int ent, char *buf, unsigned int size)
5918 RTE_SET_USED(token);
5919 for (idx = 0; idx < RAW_ENCAP_CONFS_MAX_NUM; ++idx) {
5920 if (buf && idx == ent)
5921 return snprintf(buf, size, "%u", idx);
5927 /** Internal context. */
5928 static struct context cmd_flow_context;
5930 /** Global parser instance (cmdline API). */
5931 cmdline_parse_inst_t cmd_flow;
5932 cmdline_parse_inst_t cmd_set_raw;
5934 /** Initialize context. */
5936 cmd_flow_context_init(struct context *ctx)
5938 /* A full memset() is not necessary. */
5948 ctx->objmask = NULL;
5951 /** Parse a token (cmdline API). */
5953 cmd_flow_parse(cmdline_parse_token_hdr_t *hdr, const char *src, void *result,
5956 struct context *ctx = &cmd_flow_context;
5957 const struct token *token;
5958 const enum index *list;
5963 token = &token_list[ctx->curr];
5964 /* Check argument length. */
5967 for (len = 0; src[len]; ++len)
5968 if (src[len] == '#' || isspace(src[len]))
5972 /* Last argument and EOL detection. */
5973 for (i = len; src[i]; ++i)
5974 if (src[i] == '#' || src[i] == '\r' || src[i] == '\n')
5976 else if (!isspace(src[i])) {
5981 if (src[i] == '\r' || src[i] == '\n') {
5985 /* Initialize context if necessary. */
5986 if (!ctx->next_num) {
5989 ctx->next[ctx->next_num++] = token->next[0];
5991 /* Process argument through candidates. */
5992 ctx->prev = ctx->curr;
5993 list = ctx->next[ctx->next_num - 1];
5994 for (i = 0; list[i]; ++i) {
5995 const struct token *next = &token_list[list[i]];
5998 ctx->curr = list[i];
6000 tmp = next->call(ctx, next, src, len, result, size);
6002 tmp = parse_default(ctx, next, src, len, result, size);
6003 if (tmp == -1 || tmp != len)
6011 /* Push subsequent tokens if any. */
6013 for (i = 0; token->next[i]; ++i) {
6014 if (ctx->next_num == RTE_DIM(ctx->next))
6016 ctx->next[ctx->next_num++] = token->next[i];
6018 /* Push arguments if any. */
6020 for (i = 0; token->args[i]; ++i) {
6021 if (ctx->args_num == RTE_DIM(ctx->args))
6023 ctx->args[ctx->args_num++] = token->args[i];
6028 /** Return number of completion entries (cmdline API). */
6030 cmd_flow_complete_get_nb(cmdline_parse_token_hdr_t *hdr)
6032 struct context *ctx = &cmd_flow_context;
6033 const struct token *token = &token_list[ctx->curr];
6034 const enum index *list;
6038 /* Count number of tokens in current list. */
6040 list = ctx->next[ctx->next_num - 1];
6042 list = token->next[0];
6043 for (i = 0; list[i]; ++i)
6048 * If there is a single token, use its completion callback, otherwise
6049 * return the number of entries.
6051 token = &token_list[list[0]];
6052 if (i == 1 && token->comp) {
6053 /* Save index for cmd_flow_get_help(). */
6054 ctx->prev = list[0];
6055 return token->comp(ctx, token, 0, NULL, 0);
6060 /** Return a completion entry (cmdline API). */
6062 cmd_flow_complete_get_elt(cmdline_parse_token_hdr_t *hdr, int index,
6063 char *dst, unsigned int size)
6065 struct context *ctx = &cmd_flow_context;
6066 const struct token *token = &token_list[ctx->curr];
6067 const enum index *list;
6071 /* Count number of tokens in current list. */
6073 list = ctx->next[ctx->next_num - 1];
6075 list = token->next[0];
6076 for (i = 0; list[i]; ++i)
6080 /* If there is a single token, use its completion callback. */
6081 token = &token_list[list[0]];
6082 if (i == 1 && token->comp) {
6083 /* Save index for cmd_flow_get_help(). */
6084 ctx->prev = list[0];
6085 return token->comp(ctx, token, index, dst, size) < 0 ? -1 : 0;
6087 /* Otherwise make sure the index is valid and use defaults. */
6090 token = &token_list[list[index]];
6091 strlcpy(dst, token->name, size);
6092 /* Save index for cmd_flow_get_help(). */
6093 ctx->prev = list[index];
6097 /** Populate help strings for current token (cmdline API). */
6099 cmd_flow_get_help(cmdline_parse_token_hdr_t *hdr, char *dst, unsigned int size)
6101 struct context *ctx = &cmd_flow_context;
6102 const struct token *token = &token_list[ctx->prev];
6107 /* Set token type and update global help with details. */
6108 strlcpy(dst, (token->type ? token->type : "TOKEN"), size);
6110 cmd_flow.help_str = token->help;
6112 cmd_flow.help_str = token->name;
6116 /** Token definition template (cmdline API). */
6117 static struct cmdline_token_hdr cmd_flow_token_hdr = {
6118 .ops = &(struct cmdline_token_ops){
6119 .parse = cmd_flow_parse,
6120 .complete_get_nb = cmd_flow_complete_get_nb,
6121 .complete_get_elt = cmd_flow_complete_get_elt,
6122 .get_help = cmd_flow_get_help,
6127 /** Populate the next dynamic token. */
6129 cmd_flow_tok(cmdline_parse_token_hdr_t **hdr,
6130 cmdline_parse_token_hdr_t **hdr_inst)
6132 struct context *ctx = &cmd_flow_context;
6134 /* Always reinitialize context before requesting the first token. */
6135 if (!(hdr_inst - cmd_flow.tokens))
6136 cmd_flow_context_init(ctx);
6137 /* Return NULL when no more tokens are expected. */
6138 if (!ctx->next_num && ctx->curr) {
6142 /* Determine if command should end here. */
6143 if (ctx->eol && ctx->last && ctx->next_num) {
6144 const enum index *list = ctx->next[ctx->next_num - 1];
6147 for (i = 0; list[i]; ++i) {
6154 *hdr = &cmd_flow_token_hdr;
6157 /** Dispatch parsed buffer to function calls. */
6159 cmd_flow_parsed(const struct buffer *in)
6161 switch (in->command) {
6163 port_flow_validate(in->port, &in->args.vc.attr,
6164 in->args.vc.pattern, in->args.vc.actions);
6167 port_flow_create(in->port, &in->args.vc.attr,
6168 in->args.vc.pattern, in->args.vc.actions);
6171 port_flow_destroy(in->port, in->args.destroy.rule_n,
6172 in->args.destroy.rule);
6175 port_flow_flush(in->port);
6178 port_flow_query(in->port, in->args.query.rule,
6179 &in->args.query.action);
6182 port_flow_list(in->port, in->args.list.group_n,
6183 in->args.list.group);
6186 port_flow_isolate(in->port, in->args.isolate.set);
6193 /** Token generator and output processing callback (cmdline API). */
6195 cmd_flow_cb(void *arg0, struct cmdline *cl, void *arg2)
6198 cmd_flow_tok(arg0, arg2);
6200 cmd_flow_parsed(arg0);
6203 /** Global parser instance (cmdline API). */
6204 cmdline_parse_inst_t cmd_flow = {
6206 .data = NULL, /**< Unused. */
6207 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
6210 }, /**< Tokens are returned by cmd_flow_tok(). */
6213 /** set cmd facility. Reuse cmd flow's infrastructure as much as possible. */
6216 update_fields(uint8_t *buf, struct rte_flow_item *item, uint16_t next_proto)
6218 struct rte_flow_item_ipv4 *ipv4;
6219 struct rte_flow_item_eth *eth;
6220 struct rte_flow_item_ipv6 *ipv6;
6221 struct rte_flow_item_vxlan *vxlan;
6222 struct rte_flow_item_vxlan_gpe *gpe;
6223 struct rte_flow_item_nvgre *nvgre;
6224 uint32_t ipv6_vtc_flow;
6226 switch (item->type) {
6227 case RTE_FLOW_ITEM_TYPE_ETH:
6228 eth = (struct rte_flow_item_eth *)buf;
6230 eth->type = rte_cpu_to_be_16(next_proto);
6232 case RTE_FLOW_ITEM_TYPE_IPV4:
6233 ipv4 = (struct rte_flow_item_ipv4 *)buf;
6234 ipv4->hdr.version_ihl = 0x45;
6235 if (next_proto && ipv4->hdr.next_proto_id == 0)
6236 ipv4->hdr.next_proto_id = (uint8_t)next_proto;
6238 case RTE_FLOW_ITEM_TYPE_IPV6:
6239 ipv6 = (struct rte_flow_item_ipv6 *)buf;
6240 if (next_proto && ipv6->hdr.proto == 0)
6241 ipv6->hdr.proto = (uint8_t)next_proto;
6242 ipv6_vtc_flow = rte_be_to_cpu_32(ipv6->hdr.vtc_flow);
6243 ipv6_vtc_flow &= 0x0FFFFFFF; /*< reset version bits. */
6244 ipv6_vtc_flow |= 0x60000000; /*< set ipv6 version. */
6245 ipv6->hdr.vtc_flow = rte_cpu_to_be_32(ipv6_vtc_flow);
6247 case RTE_FLOW_ITEM_TYPE_VXLAN:
6248 vxlan = (struct rte_flow_item_vxlan *)buf;
6249 vxlan->flags = 0x08;
6251 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
6252 gpe = (struct rte_flow_item_vxlan_gpe *)buf;
6255 case RTE_FLOW_ITEM_TYPE_NVGRE:
6256 nvgre = (struct rte_flow_item_nvgre *)buf;
6257 nvgre->protocol = rte_cpu_to_be_16(0x6558);
6258 nvgre->c_k_s_rsvd0_ver = rte_cpu_to_be_16(0x2000);
6265 /** Helper of get item's default mask. */
6267 flow_item_default_mask(const struct rte_flow_item *item)
6269 const void *mask = NULL;
6270 static rte_be32_t gre_key_default_mask = RTE_BE32(UINT32_MAX);
6272 switch (item->type) {
6273 case RTE_FLOW_ITEM_TYPE_ANY:
6274 mask = &rte_flow_item_any_mask;
6276 case RTE_FLOW_ITEM_TYPE_VF:
6277 mask = &rte_flow_item_vf_mask;
6279 case RTE_FLOW_ITEM_TYPE_PORT_ID:
6280 mask = &rte_flow_item_port_id_mask;
6282 case RTE_FLOW_ITEM_TYPE_RAW:
6283 mask = &rte_flow_item_raw_mask;
6285 case RTE_FLOW_ITEM_TYPE_ETH:
6286 mask = &rte_flow_item_eth_mask;
6288 case RTE_FLOW_ITEM_TYPE_VLAN:
6289 mask = &rte_flow_item_vlan_mask;
6291 case RTE_FLOW_ITEM_TYPE_IPV4:
6292 mask = &rte_flow_item_ipv4_mask;
6294 case RTE_FLOW_ITEM_TYPE_IPV6:
6295 mask = &rte_flow_item_ipv6_mask;
6297 case RTE_FLOW_ITEM_TYPE_ICMP:
6298 mask = &rte_flow_item_icmp_mask;
6300 case RTE_FLOW_ITEM_TYPE_UDP:
6301 mask = &rte_flow_item_udp_mask;
6303 case RTE_FLOW_ITEM_TYPE_TCP:
6304 mask = &rte_flow_item_tcp_mask;
6306 case RTE_FLOW_ITEM_TYPE_SCTP:
6307 mask = &rte_flow_item_sctp_mask;
6309 case RTE_FLOW_ITEM_TYPE_VXLAN:
6310 mask = &rte_flow_item_vxlan_mask;
6312 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
6313 mask = &rte_flow_item_vxlan_gpe_mask;
6315 case RTE_FLOW_ITEM_TYPE_E_TAG:
6316 mask = &rte_flow_item_e_tag_mask;
6318 case RTE_FLOW_ITEM_TYPE_NVGRE:
6319 mask = &rte_flow_item_nvgre_mask;
6321 case RTE_FLOW_ITEM_TYPE_MPLS:
6322 mask = &rte_flow_item_mpls_mask;
6324 case RTE_FLOW_ITEM_TYPE_GRE:
6325 mask = &rte_flow_item_gre_mask;
6327 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
6328 mask = &gre_key_default_mask;
6330 case RTE_FLOW_ITEM_TYPE_META:
6331 mask = &rte_flow_item_meta_mask;
6333 case RTE_FLOW_ITEM_TYPE_FUZZY:
6334 mask = &rte_flow_item_fuzzy_mask;
6336 case RTE_FLOW_ITEM_TYPE_GTP:
6337 mask = &rte_flow_item_gtp_mask;
6339 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
6340 mask = &rte_flow_item_gtp_psc_mask;
6342 case RTE_FLOW_ITEM_TYPE_GENEVE:
6343 mask = &rte_flow_item_geneve_mask;
6345 case RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID:
6346 mask = &rte_flow_item_pppoe_proto_id_mask;
6348 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
6349 mask = &rte_flow_item_l2tpv3oip_mask;
6351 case RTE_FLOW_ITEM_TYPE_ESP:
6352 mask = &rte_flow_item_esp_mask;
6362 /** Dispatch parsed buffer to function calls. */
6364 cmd_set_raw_parsed(const struct buffer *in)
6366 uint32_t n = in->args.vc.pattern_n;
6368 struct rte_flow_item *item = NULL;
6370 uint8_t *data = NULL;
6371 uint8_t *data_tail = NULL;
6372 size_t *total_size = NULL;
6373 uint16_t upper_layer = 0;
6375 uint16_t idx = in->port; /* We borrow port field as index */
6377 RTE_ASSERT(in->command == SET_RAW_ENCAP ||
6378 in->command == SET_RAW_DECAP);
6379 if (in->command == SET_RAW_ENCAP) {
6380 total_size = &raw_encap_confs[idx].size;
6381 data = (uint8_t *)&raw_encap_confs[idx].data;
6383 total_size = &raw_decap_confs[idx].size;
6384 data = (uint8_t *)&raw_decap_confs[idx].data;
6387 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
6388 /* process hdr from upper layer to low layer (L3/L4 -> L2). */
6389 data_tail = data + ACTION_RAW_ENCAP_MAX_DATA;
6390 for (i = n - 1 ; i >= 0; --i) {
6391 item = in->args.vc.pattern + i;
6392 if (item->spec == NULL)
6393 item->spec = flow_item_default_mask(item);
6394 switch (item->type) {
6395 case RTE_FLOW_ITEM_TYPE_ETH:
6396 size = sizeof(struct rte_flow_item_eth);
6398 case RTE_FLOW_ITEM_TYPE_VLAN:
6399 size = sizeof(struct rte_flow_item_vlan);
6400 proto = RTE_ETHER_TYPE_VLAN;
6402 case RTE_FLOW_ITEM_TYPE_IPV4:
6403 size = sizeof(struct rte_flow_item_ipv4);
6404 proto = RTE_ETHER_TYPE_IPV4;
6406 case RTE_FLOW_ITEM_TYPE_IPV6:
6407 size = sizeof(struct rte_flow_item_ipv6);
6408 proto = RTE_ETHER_TYPE_IPV6;
6410 case RTE_FLOW_ITEM_TYPE_UDP:
6411 size = sizeof(struct rte_flow_item_udp);
6414 case RTE_FLOW_ITEM_TYPE_TCP:
6415 size = sizeof(struct rte_flow_item_tcp);
6418 case RTE_FLOW_ITEM_TYPE_VXLAN:
6419 size = sizeof(struct rte_flow_item_vxlan);
6421 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
6422 size = sizeof(struct rte_flow_item_vxlan_gpe);
6424 case RTE_FLOW_ITEM_TYPE_GRE:
6425 size = sizeof(struct rte_flow_item_gre);
6428 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
6429 size = sizeof(rte_be32_t);
6432 case RTE_FLOW_ITEM_TYPE_MPLS:
6433 size = sizeof(struct rte_flow_item_mpls);
6436 case RTE_FLOW_ITEM_TYPE_NVGRE:
6437 size = sizeof(struct rte_flow_item_nvgre);
6440 case RTE_FLOW_ITEM_TYPE_GENEVE:
6441 size = sizeof(struct rte_flow_item_geneve);
6443 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
6444 size = sizeof(struct rte_flow_item_l2tpv3oip);
6447 case RTE_FLOW_ITEM_TYPE_ESP:
6448 size = sizeof(struct rte_flow_item_esp);
6452 printf("Error - Not supported item\n");
6454 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
6457 *total_size += size;
6458 rte_memcpy(data_tail - (*total_size), item->spec, size);
6459 /* update some fields which cannot be set by cmdline */
6460 update_fields((data_tail - (*total_size)), item,
6462 upper_layer = proto;
6464 if (verbose_level & 0x1)
6465 printf("total data size is %zu\n", (*total_size));
6466 RTE_ASSERT((*total_size) <= ACTION_RAW_ENCAP_MAX_DATA);
6467 memmove(data, (data_tail - (*total_size)), *total_size);
6470 /** Populate help strings for current token (cmdline API). */
6472 cmd_set_raw_get_help(cmdline_parse_token_hdr_t *hdr, char *dst,
6475 struct context *ctx = &cmd_flow_context;
6476 const struct token *token = &token_list[ctx->prev];
6481 /* Set token type and update global help with details. */
6482 snprintf(dst, size, "%s", (token->type ? token->type : "TOKEN"));
6484 cmd_set_raw.help_str = token->help;
6486 cmd_set_raw.help_str = token->name;
6490 /** Token definition template (cmdline API). */
6491 static struct cmdline_token_hdr cmd_set_raw_token_hdr = {
6492 .ops = &(struct cmdline_token_ops){
6493 .parse = cmd_flow_parse,
6494 .complete_get_nb = cmd_flow_complete_get_nb,
6495 .complete_get_elt = cmd_flow_complete_get_elt,
6496 .get_help = cmd_set_raw_get_help,
6501 /** Populate the next dynamic token. */
6503 cmd_set_raw_tok(cmdline_parse_token_hdr_t **hdr,
6504 cmdline_parse_token_hdr_t **hdr_inst)
6506 struct context *ctx = &cmd_flow_context;
6508 /* Always reinitialize context before requesting the first token. */
6509 if (!(hdr_inst - cmd_set_raw.tokens)) {
6510 cmd_flow_context_init(ctx);
6511 ctx->curr = START_SET;
6513 /* Return NULL when no more tokens are expected. */
6514 if (!ctx->next_num && (ctx->curr != START_SET)) {
6518 /* Determine if command should end here. */
6519 if (ctx->eol && ctx->last && ctx->next_num) {
6520 const enum index *list = ctx->next[ctx->next_num - 1];
6523 for (i = 0; list[i]; ++i) {
6530 *hdr = &cmd_set_raw_token_hdr;
6533 /** Token generator and output processing callback (cmdline API). */
6535 cmd_set_raw_cb(void *arg0, struct cmdline *cl, void *arg2)
6538 cmd_set_raw_tok(arg0, arg2);
6540 cmd_set_raw_parsed(arg0);
6543 /** Global parser instance (cmdline API). */
6544 cmdline_parse_inst_t cmd_set_raw = {
6545 .f = cmd_set_raw_cb,
6546 .data = NULL, /**< Unused. */
6547 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
6550 }, /**< Tokens are returned by cmd_flow_tok(). */
6553 /* *** display raw_encap/raw_decap buf */
6554 struct cmd_show_set_raw_result {
6555 cmdline_fixed_string_t cmd_show;
6556 cmdline_fixed_string_t cmd_what;
6557 cmdline_fixed_string_t cmd_all;
6562 cmd_show_set_raw_parsed(void *parsed_result, struct cmdline *cl, void *data)
6564 struct cmd_show_set_raw_result *res = parsed_result;
6565 uint16_t index = res->cmd_index;
6567 uint8_t *raw_data = NULL;
6568 size_t raw_size = 0;
6569 char title[16] = {0};
6573 if (!strcmp(res->cmd_all, "all")) {
6576 } else if (index >= RAW_ENCAP_CONFS_MAX_NUM) {
6577 printf("index should be 0-%u\n", RAW_ENCAP_CONFS_MAX_NUM - 1);
6581 if (!strcmp(res->cmd_what, "raw_encap")) {
6582 raw_data = (uint8_t *)&raw_encap_confs[index].data;
6583 raw_size = raw_encap_confs[index].size;
6584 snprintf(title, 16, "\nindex: %u", index);
6585 rte_hexdump(stdout, title, raw_data, raw_size);
6587 raw_data = (uint8_t *)&raw_decap_confs[index].data;
6588 raw_size = raw_decap_confs[index].size;
6589 snprintf(title, 16, "\nindex: %u", index);
6590 rte_hexdump(stdout, title, raw_data, raw_size);
6592 } while (all && ++index < RAW_ENCAP_CONFS_MAX_NUM);
6595 cmdline_parse_token_string_t cmd_show_set_raw_cmd_show =
6596 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
6598 cmdline_parse_token_string_t cmd_show_set_raw_cmd_what =
6599 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
6600 cmd_what, "raw_encap#raw_decap");
6601 cmdline_parse_token_num_t cmd_show_set_raw_cmd_index =
6602 TOKEN_NUM_INITIALIZER(struct cmd_show_set_raw_result,
6604 cmdline_parse_token_string_t cmd_show_set_raw_cmd_all =
6605 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
6607 cmdline_parse_inst_t cmd_show_set_raw = {
6608 .f = cmd_show_set_raw_parsed,
6610 .help_str = "show <raw_encap|raw_decap> <index>",
6612 (void *)&cmd_show_set_raw_cmd_show,
6613 (void *)&cmd_show_set_raw_cmd_what,
6614 (void *)&cmd_show_set_raw_cmd_index,
6618 cmdline_parse_inst_t cmd_show_set_raw_all = {
6619 .f = cmd_show_set_raw_parsed,
6621 .help_str = "show <raw_encap|raw_decap> all",
6623 (void *)&cmd_show_set_raw_cmd_show,
6624 (void *)&cmd_show_set_raw_cmd_what,
6625 (void *)&cmd_show_set_raw_cmd_all,