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>
26 #include <rte_vxlan.h>
30 /** Parser token indices. */
55 /* Top-level command. */
57 /* Sub-leve commands. */
64 /* Top-level command. */
66 /* Sub-level commands. */
78 /* Destroy arguments. */
81 /* Query arguments. */
87 /* Destroy aged flow arguments. */
90 /* Validate/create arguments. */
97 /* Shared action arguments */
100 SHARED_ACTION_DESTROY,
103 /* Shared action create arguments */
104 SHARED_ACTION_CREATE_ID,
105 SHARED_ACTION_INGRESS,
106 SHARED_ACTION_EGRESS,
109 /* Shared action destroy arguments */
110 SHARED_ACTION_DESTROY_ID,
112 /* Validate/create pattern. */
149 ITEM_VLAN_INNER_TYPE,
152 ITEM_IPV4_FRAGMENT_OFFSET,
164 ITEM_IPV6_HAS_FRAG_EXT,
185 ITEM_E_TAG_GRP_ECID_B,
194 ITEM_GRE_C_RSVD0_VER,
212 ITEM_ARP_ETH_IPV4_SHA,
213 ITEM_ARP_ETH_IPV4_SPA,
214 ITEM_ARP_ETH_IPV4_THA,
215 ITEM_ARP_ETH_IPV4_TPA,
217 ITEM_IPV6_EXT_NEXT_HDR,
219 ITEM_IPV6_FRAG_EXT_NEXT_HDR,
220 ITEM_IPV6_FRAG_EXT_FRAG_DATA,
225 ITEM_ICMP6_ND_NS_TARGET_ADDR,
227 ITEM_ICMP6_ND_NA_TARGET_ADDR,
229 ITEM_ICMP6_ND_OPT_TYPE,
230 ITEM_ICMP6_ND_OPT_SLA_ETH,
231 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
232 ITEM_ICMP6_ND_OPT_TLA_ETH,
233 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
246 ITEM_HIGIG2_CLASSIFICATION,
252 ITEM_L2TPV3OIP_SESSION_ID,
262 ITEM_ECPRI_COMMON_TYPE,
263 ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
264 ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
265 ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
266 ITEM_ECPRI_MSG_IQ_DATA_PCID,
267 ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
268 ITEM_ECPRI_MSG_DLY_MSR_MSRID,
270 /* Validate/create actions. */
290 ACTION_RSS_FUNC_DEFAULT,
291 ACTION_RSS_FUNC_TOEPLITZ,
292 ACTION_RSS_FUNC_SIMPLE_XOR,
293 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ,
305 ACTION_PHY_PORT_ORIGINAL,
306 ACTION_PHY_PORT_INDEX,
308 ACTION_PORT_ID_ORIGINAL,
312 ACTION_OF_SET_MPLS_TTL,
313 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
314 ACTION_OF_DEC_MPLS_TTL,
315 ACTION_OF_SET_NW_TTL,
316 ACTION_OF_SET_NW_TTL_NW_TTL,
317 ACTION_OF_DEC_NW_TTL,
318 ACTION_OF_COPY_TTL_OUT,
319 ACTION_OF_COPY_TTL_IN,
322 ACTION_OF_PUSH_VLAN_ETHERTYPE,
323 ACTION_OF_SET_VLAN_VID,
324 ACTION_OF_SET_VLAN_VID_VLAN_VID,
325 ACTION_OF_SET_VLAN_PCP,
326 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
328 ACTION_OF_POP_MPLS_ETHERTYPE,
330 ACTION_OF_PUSH_MPLS_ETHERTYPE,
337 ACTION_MPLSOGRE_ENCAP,
338 ACTION_MPLSOGRE_DECAP,
339 ACTION_MPLSOUDP_ENCAP,
340 ACTION_MPLSOUDP_DECAP,
342 ACTION_SET_IPV4_SRC_IPV4_SRC,
344 ACTION_SET_IPV4_DST_IPV4_DST,
346 ACTION_SET_IPV6_SRC_IPV6_SRC,
348 ACTION_SET_IPV6_DST_IPV6_DST,
350 ACTION_SET_TP_SRC_TP_SRC,
352 ACTION_SET_TP_DST_TP_DST,
358 ACTION_SET_MAC_SRC_MAC_SRC,
360 ACTION_SET_MAC_DST_MAC_DST,
362 ACTION_INC_TCP_SEQ_VALUE,
364 ACTION_DEC_TCP_SEQ_VALUE,
366 ACTION_INC_TCP_ACK_VALUE,
368 ACTION_DEC_TCP_ACK_VALUE,
371 ACTION_RAW_ENCAP_INDEX,
372 ACTION_RAW_ENCAP_INDEX_VALUE,
373 ACTION_RAW_DECAP_INDEX,
374 ACTION_RAW_DECAP_INDEX_VALUE,
377 ACTION_SET_TAG_INDEX,
380 ACTION_SET_META_DATA,
381 ACTION_SET_META_MASK,
382 ACTION_SET_IPV4_DSCP,
383 ACTION_SET_IPV4_DSCP_VALUE,
384 ACTION_SET_IPV6_DSCP,
385 ACTION_SET_IPV6_DSCP_VALUE,
391 ACTION_SAMPLE_INDEX_VALUE,
393 SHARED_ACTION_ID2PTR,
396 /** Maximum size for pattern in struct rte_flow_item_raw. */
397 #define ITEM_RAW_PATTERN_SIZE 40
399 /** Storage size for struct rte_flow_item_raw including pattern. */
400 #define ITEM_RAW_SIZE \
401 (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE)
403 /** Maximum number of queue indices in struct rte_flow_action_rss. */
404 #define ACTION_RSS_QUEUE_NUM 128
406 /** Storage for struct rte_flow_action_rss including external data. */
407 struct action_rss_data {
408 struct rte_flow_action_rss conf;
409 uint8_t key[RSS_HASH_KEY_LENGTH];
410 uint16_t queue[ACTION_RSS_QUEUE_NUM];
413 /** Maximum data size in struct rte_flow_action_raw_encap. */
414 #define ACTION_RAW_ENCAP_MAX_DATA 128
415 #define RAW_ENCAP_CONFS_MAX_NUM 8
417 /** Storage for struct rte_flow_action_raw_encap. */
418 struct raw_encap_conf {
419 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
420 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
424 struct raw_encap_conf raw_encap_confs[RAW_ENCAP_CONFS_MAX_NUM];
426 /** Storage for struct rte_flow_action_raw_encap including external data. */
427 struct action_raw_encap_data {
428 struct rte_flow_action_raw_encap conf;
429 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
430 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
434 /** Storage for struct rte_flow_action_raw_decap. */
435 struct raw_decap_conf {
436 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
440 struct raw_decap_conf raw_decap_confs[RAW_ENCAP_CONFS_MAX_NUM];
442 /** Storage for struct rte_flow_action_raw_decap including external data. */
443 struct action_raw_decap_data {
444 struct rte_flow_action_raw_decap conf;
445 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
449 struct vxlan_encap_conf vxlan_encap_conf = {
453 .vni = "\x00\x00\x00",
455 .udp_dst = RTE_BE16(RTE_VXLAN_DEFAULT_PORT),
456 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
457 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
458 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
459 "\x00\x00\x00\x00\x00\x00\x00\x01",
460 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
461 "\x00\x00\x00\x00\x00\x00\x11\x11",
465 .eth_src = "\x00\x00\x00\x00\x00\x00",
466 .eth_dst = "\xff\xff\xff\xff\xff\xff",
469 /** Maximum number of items in struct rte_flow_action_vxlan_encap. */
470 #define ACTION_VXLAN_ENCAP_ITEMS_NUM 6
472 /** Storage for struct rte_flow_action_vxlan_encap including external data. */
473 struct action_vxlan_encap_data {
474 struct rte_flow_action_vxlan_encap conf;
475 struct rte_flow_item items[ACTION_VXLAN_ENCAP_ITEMS_NUM];
476 struct rte_flow_item_eth item_eth;
477 struct rte_flow_item_vlan item_vlan;
479 struct rte_flow_item_ipv4 item_ipv4;
480 struct rte_flow_item_ipv6 item_ipv6;
482 struct rte_flow_item_udp item_udp;
483 struct rte_flow_item_vxlan item_vxlan;
486 struct nvgre_encap_conf nvgre_encap_conf = {
489 .tni = "\x00\x00\x00",
490 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
491 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
492 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
493 "\x00\x00\x00\x00\x00\x00\x00\x01",
494 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
495 "\x00\x00\x00\x00\x00\x00\x11\x11",
497 .eth_src = "\x00\x00\x00\x00\x00\x00",
498 .eth_dst = "\xff\xff\xff\xff\xff\xff",
501 /** Maximum number of items in struct rte_flow_action_nvgre_encap. */
502 #define ACTION_NVGRE_ENCAP_ITEMS_NUM 5
504 /** Storage for struct rte_flow_action_nvgre_encap including external data. */
505 struct action_nvgre_encap_data {
506 struct rte_flow_action_nvgre_encap conf;
507 struct rte_flow_item items[ACTION_NVGRE_ENCAP_ITEMS_NUM];
508 struct rte_flow_item_eth item_eth;
509 struct rte_flow_item_vlan item_vlan;
511 struct rte_flow_item_ipv4 item_ipv4;
512 struct rte_flow_item_ipv6 item_ipv6;
514 struct rte_flow_item_nvgre item_nvgre;
517 struct l2_encap_conf l2_encap_conf;
519 struct l2_decap_conf l2_decap_conf;
521 struct mplsogre_encap_conf mplsogre_encap_conf;
523 struct mplsogre_decap_conf mplsogre_decap_conf;
525 struct mplsoudp_encap_conf mplsoudp_encap_conf;
527 struct mplsoudp_decap_conf mplsoudp_decap_conf;
529 #define ACTION_SAMPLE_ACTIONS_NUM 10
530 #define RAW_SAMPLE_CONFS_MAX_NUM 8
531 /** Storage for struct rte_flow_action_sample including external data. */
532 struct action_sample_data {
533 struct rte_flow_action_sample conf;
536 /** Storage for struct rte_flow_action_sample. */
537 struct raw_sample_conf {
538 struct rte_flow_action data[ACTION_SAMPLE_ACTIONS_NUM];
540 struct raw_sample_conf raw_sample_confs[RAW_SAMPLE_CONFS_MAX_NUM];
541 struct rte_flow_action_mark sample_mark[RAW_SAMPLE_CONFS_MAX_NUM];
542 struct rte_flow_action_queue sample_queue[RAW_SAMPLE_CONFS_MAX_NUM];
543 struct rte_flow_action_count sample_count[RAW_SAMPLE_CONFS_MAX_NUM];
544 struct rte_flow_action_port_id sample_port_id[RAW_SAMPLE_CONFS_MAX_NUM];
545 struct rte_flow_action_raw_encap sample_encap[RAW_SAMPLE_CONFS_MAX_NUM];
547 /** Maximum number of subsequent tokens and arguments on the stack. */
548 #define CTX_STACK_SIZE 16
550 /** Parser context. */
552 /** Stack of subsequent token lists to process. */
553 const enum index *next[CTX_STACK_SIZE];
554 /** Arguments for stacked tokens. */
555 const void *args[CTX_STACK_SIZE];
556 enum index curr; /**< Current token index. */
557 enum index prev; /**< Index of the last token seen. */
558 int next_num; /**< Number of entries in next[]. */
559 int args_num; /**< Number of entries in args[]. */
560 uint32_t eol:1; /**< EOL has been detected. */
561 uint32_t last:1; /**< No more arguments. */
562 portid_t port; /**< Current port ID (for completions). */
563 uint32_t objdata; /**< Object-specific data. */
564 void *object; /**< Address of current object for relative offsets. */
565 void *objmask; /**< Object a full mask must be written to. */
568 /** Token argument. */
570 uint32_t hton:1; /**< Use network byte ordering. */
571 uint32_t sign:1; /**< Value is signed. */
572 uint32_t bounded:1; /**< Value is bounded. */
573 uintmax_t min; /**< Minimum value if bounded. */
574 uintmax_t max; /**< Maximum value if bounded. */
575 uint32_t offset; /**< Relative offset from ctx->object. */
576 uint32_t size; /**< Field size. */
577 const uint8_t *mask; /**< Bit-mask to use instead of offset/size. */
580 /** Parser token definition. */
582 /** Type displayed during completion (defaults to "TOKEN"). */
584 /** Help displayed during completion (defaults to token name). */
586 /** Private data used by parser functions. */
589 * Lists of subsequent tokens to push on the stack. Each call to the
590 * parser consumes the last entry of that stack.
592 const enum index *const *next;
593 /** Arguments stack for subsequent tokens that need them. */
594 const struct arg *const *args;
596 * Token-processing callback, returns -1 in case of error, the
597 * length of the matched string otherwise. If NULL, attempts to
598 * match the token name.
600 * If buf is not NULL, the result should be stored in it according
601 * to context. An error is returned if not large enough.
603 int (*call)(struct context *ctx, const struct token *token,
604 const char *str, unsigned int len,
605 void *buf, unsigned int size);
607 * Callback that provides possible values for this token, used for
608 * completion. Returns -1 in case of error, the number of possible
609 * values otherwise. If NULL, the token name is used.
611 * If buf is not NULL, entry index ent is written to buf and the
612 * full length of the entry is returned (same behavior as
615 int (*comp)(struct context *ctx, const struct token *token,
616 unsigned int ent, char *buf, unsigned int size);
617 /** Mandatory token name, no default value. */
621 /** Static initializer for the next field. */
622 #define NEXT(...) (const enum index *const []){ __VA_ARGS__, NULL, }
624 /** Static initializer for a NEXT() entry. */
625 #define NEXT_ENTRY(...) (const enum index []){ __VA_ARGS__, ZERO, }
627 /** Static initializer for the args field. */
628 #define ARGS(...) (const struct arg *const []){ __VA_ARGS__, NULL, }
630 /** Static initializer for ARGS() to target a field. */
631 #define ARGS_ENTRY(s, f) \
632 (&(const struct arg){ \
633 .offset = offsetof(s, f), \
634 .size = sizeof(((s *)0)->f), \
637 /** Static initializer for ARGS() to target a bit-field. */
638 #define ARGS_ENTRY_BF(s, f, b) \
639 (&(const struct arg){ \
641 .mask = (const void *)&(const s){ .f = (1 << (b)) - 1 }, \
644 /** Static initializer for ARGS() to target an arbitrary bit-mask. */
645 #define ARGS_ENTRY_MASK(s, f, m) \
646 (&(const struct arg){ \
647 .offset = offsetof(s, f), \
648 .size = sizeof(((s *)0)->f), \
649 .mask = (const void *)(m), \
652 /** Same as ARGS_ENTRY_MASK() using network byte ordering for the value. */
653 #define ARGS_ENTRY_MASK_HTON(s, f, m) \
654 (&(const struct arg){ \
656 .offset = offsetof(s, f), \
657 .size = sizeof(((s *)0)->f), \
658 .mask = (const void *)(m), \
661 /** Static initializer for ARGS() to target a pointer. */
662 #define ARGS_ENTRY_PTR(s, f) \
663 (&(const struct arg){ \
664 .size = sizeof(*((s *)0)->f), \
667 /** Static initializer for ARGS() with arbitrary offset and size. */
668 #define ARGS_ENTRY_ARB(o, s) \
669 (&(const struct arg){ \
674 /** Same as ARGS_ENTRY_ARB() with bounded values. */
675 #define ARGS_ENTRY_ARB_BOUNDED(o, s, i, a) \
676 (&(const struct arg){ \
684 /** Same as ARGS_ENTRY() using network byte ordering. */
685 #define ARGS_ENTRY_HTON(s, f) \
686 (&(const struct arg){ \
688 .offset = offsetof(s, f), \
689 .size = sizeof(((s *)0)->f), \
692 /** Same as ARGS_ENTRY_HTON() for a single argument, without structure. */
693 #define ARG_ENTRY_HTON(s) \
694 (&(const struct arg){ \
700 /** Parser output buffer layout expected by cmd_flow_parsed(). */
702 enum index command; /**< Flow command. */
703 portid_t port; /**< Affected port ID. */
707 uint32_t action_id_n;
708 } sa_destroy; /**< Shared action destroy arguments. */
711 } sa; /* Shared action query arguments */
713 struct rte_flow_attr attr;
714 struct rte_flow_item *pattern;
715 struct rte_flow_action *actions;
719 } vc; /**< Validate/create arguments. */
723 } destroy; /**< Destroy arguments. */
726 } dump; /**< Dump arguments. */
729 struct rte_flow_action action;
730 } query; /**< Query arguments. */
734 } list; /**< List arguments. */
737 } isolate; /**< Isolated mode arguments. */
740 } aged; /**< Aged arguments. */
741 } args; /**< Command arguments. */
744 /** Private data for pattern items. */
745 struct parse_item_priv {
746 enum rte_flow_item_type type; /**< Item type. */
747 uint32_t size; /**< Size of item specification structure. */
750 #define PRIV_ITEM(t, s) \
751 (&(const struct parse_item_priv){ \
752 .type = RTE_FLOW_ITEM_TYPE_ ## t, \
756 /** Private data for actions. */
757 struct parse_action_priv {
758 enum rte_flow_action_type type; /**< Action type. */
759 uint32_t size; /**< Size of action configuration structure. */
762 #define PRIV_ACTION(t, s) \
763 (&(const struct parse_action_priv){ \
764 .type = RTE_FLOW_ACTION_TYPE_ ## t, \
768 static const enum index next_sa_create_attr[] = {
769 SHARED_ACTION_CREATE_ID,
770 SHARED_ACTION_INGRESS,
771 SHARED_ACTION_EGRESS,
776 static const enum index next_sa_subcmd[] = {
777 SHARED_ACTION_CREATE,
778 SHARED_ACTION_UPDATE,
779 SHARED_ACTION_DESTROY,
784 static const enum index next_vc_attr[] = {
794 static const enum index next_destroy_attr[] = {
800 static const enum index next_dump_attr[] = {
806 static const enum index next_list_attr[] = {
812 static const enum index next_aged_attr[] = {
818 static const enum index next_sa_destroy_attr[] = {
819 SHARED_ACTION_DESTROY_ID,
824 static const enum index item_param[] = {
833 static const enum index next_item[] = {
870 ITEM_ICMP6_ND_OPT_SLA_ETH,
871 ITEM_ICMP6_ND_OPT_TLA_ETH,
889 static const enum index item_fuzzy[] = {
895 static const enum index item_any[] = {
901 static const enum index item_vf[] = {
907 static const enum index item_phy_port[] = {
913 static const enum index item_port_id[] = {
919 static const enum index item_mark[] = {
925 static const enum index item_raw[] = {
935 static const enum index item_eth[] = {
943 static const enum index item_vlan[] = {
948 ITEM_VLAN_INNER_TYPE,
953 static const enum index item_ipv4[] = {
955 ITEM_IPV4_FRAGMENT_OFFSET,
964 static const enum index item_ipv6[] = {
971 ITEM_IPV6_HAS_FRAG_EXT,
976 static const enum index item_icmp[] = {
985 static const enum index item_udp[] = {
992 static const enum index item_tcp[] = {
1000 static const enum index item_sctp[] = {
1009 static const enum index item_vxlan[] = {
1015 static const enum index item_e_tag[] = {
1016 ITEM_E_TAG_GRP_ECID_B,
1021 static const enum index item_nvgre[] = {
1027 static const enum index item_mpls[] = {
1035 static const enum index item_gre[] = {
1037 ITEM_GRE_C_RSVD0_VER,
1045 static const enum index item_gre_key[] = {
1051 static const enum index item_gtp[] = {
1059 static const enum index item_geneve[] = {
1066 static const enum index item_vxlan_gpe[] = {
1072 static const enum index item_arp_eth_ipv4[] = {
1073 ITEM_ARP_ETH_IPV4_SHA,
1074 ITEM_ARP_ETH_IPV4_SPA,
1075 ITEM_ARP_ETH_IPV4_THA,
1076 ITEM_ARP_ETH_IPV4_TPA,
1081 static const enum index item_ipv6_ext[] = {
1082 ITEM_IPV6_EXT_NEXT_HDR,
1087 static const enum index item_ipv6_frag_ext[] = {
1088 ITEM_IPV6_FRAG_EXT_NEXT_HDR,
1089 ITEM_IPV6_FRAG_EXT_FRAG_DATA,
1094 static const enum index item_icmp6[] = {
1101 static const enum index item_icmp6_nd_ns[] = {
1102 ITEM_ICMP6_ND_NS_TARGET_ADDR,
1107 static const enum index item_icmp6_nd_na[] = {
1108 ITEM_ICMP6_ND_NA_TARGET_ADDR,
1113 static const enum index item_icmp6_nd_opt[] = {
1114 ITEM_ICMP6_ND_OPT_TYPE,
1119 static const enum index item_icmp6_nd_opt_sla_eth[] = {
1120 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
1125 static const enum index item_icmp6_nd_opt_tla_eth[] = {
1126 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
1131 static const enum index item_meta[] = {
1137 static const enum index item_gtp_psc[] = {
1144 static const enum index item_pppoed[] = {
1150 static const enum index item_pppoes[] = {
1156 static const enum index item_pppoe_proto_id[] = {
1161 static const enum index item_higig2[] = {
1162 ITEM_HIGIG2_CLASSIFICATION,
1168 static const enum index item_esp[] = {
1174 static const enum index item_ah[] = {
1180 static const enum index item_pfcp[] = {
1187 static const enum index next_set_raw[] = {
1193 static const enum index item_tag[] = {
1200 static const enum index item_l2tpv3oip[] = {
1201 ITEM_L2TPV3OIP_SESSION_ID,
1206 static const enum index item_ecpri[] = {
1212 static const enum index item_ecpri_common[] = {
1213 ITEM_ECPRI_COMMON_TYPE,
1217 static const enum index item_ecpri_common_type[] = {
1218 ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
1219 ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
1220 ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
1224 static const enum index next_action[] = {
1240 ACTION_OF_SET_MPLS_TTL,
1241 ACTION_OF_DEC_MPLS_TTL,
1242 ACTION_OF_SET_NW_TTL,
1243 ACTION_OF_DEC_NW_TTL,
1244 ACTION_OF_COPY_TTL_OUT,
1245 ACTION_OF_COPY_TTL_IN,
1247 ACTION_OF_PUSH_VLAN,
1248 ACTION_OF_SET_VLAN_VID,
1249 ACTION_OF_SET_VLAN_PCP,
1251 ACTION_OF_PUSH_MPLS,
1258 ACTION_MPLSOGRE_ENCAP,
1259 ACTION_MPLSOGRE_DECAP,
1260 ACTION_MPLSOUDP_ENCAP,
1261 ACTION_MPLSOUDP_DECAP,
1262 ACTION_SET_IPV4_SRC,
1263 ACTION_SET_IPV4_DST,
1264 ACTION_SET_IPV6_SRC,
1265 ACTION_SET_IPV6_DST,
1281 ACTION_SET_IPV4_DSCP,
1282 ACTION_SET_IPV6_DSCP,
1289 static const enum index action_mark[] = {
1295 static const enum index action_queue[] = {
1301 static const enum index action_count[] = {
1303 ACTION_COUNT_SHARED,
1308 static const enum index action_rss[] = {
1319 static const enum index action_vf[] = {
1326 static const enum index action_phy_port[] = {
1327 ACTION_PHY_PORT_ORIGINAL,
1328 ACTION_PHY_PORT_INDEX,
1333 static const enum index action_port_id[] = {
1334 ACTION_PORT_ID_ORIGINAL,
1340 static const enum index action_meter[] = {
1346 static const enum index action_of_set_mpls_ttl[] = {
1347 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
1352 static const enum index action_of_set_nw_ttl[] = {
1353 ACTION_OF_SET_NW_TTL_NW_TTL,
1358 static const enum index action_of_push_vlan[] = {
1359 ACTION_OF_PUSH_VLAN_ETHERTYPE,
1364 static const enum index action_of_set_vlan_vid[] = {
1365 ACTION_OF_SET_VLAN_VID_VLAN_VID,
1370 static const enum index action_of_set_vlan_pcp[] = {
1371 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
1376 static const enum index action_of_pop_mpls[] = {
1377 ACTION_OF_POP_MPLS_ETHERTYPE,
1382 static const enum index action_of_push_mpls[] = {
1383 ACTION_OF_PUSH_MPLS_ETHERTYPE,
1388 static const enum index action_set_ipv4_src[] = {
1389 ACTION_SET_IPV4_SRC_IPV4_SRC,
1394 static const enum index action_set_mac_src[] = {
1395 ACTION_SET_MAC_SRC_MAC_SRC,
1400 static const enum index action_set_ipv4_dst[] = {
1401 ACTION_SET_IPV4_DST_IPV4_DST,
1406 static const enum index action_set_ipv6_src[] = {
1407 ACTION_SET_IPV6_SRC_IPV6_SRC,
1412 static const enum index action_set_ipv6_dst[] = {
1413 ACTION_SET_IPV6_DST_IPV6_DST,
1418 static const enum index action_set_tp_src[] = {
1419 ACTION_SET_TP_SRC_TP_SRC,
1424 static const enum index action_set_tp_dst[] = {
1425 ACTION_SET_TP_DST_TP_DST,
1430 static const enum index action_set_ttl[] = {
1436 static const enum index action_jump[] = {
1442 static const enum index action_set_mac_dst[] = {
1443 ACTION_SET_MAC_DST_MAC_DST,
1448 static const enum index action_inc_tcp_seq[] = {
1449 ACTION_INC_TCP_SEQ_VALUE,
1454 static const enum index action_dec_tcp_seq[] = {
1455 ACTION_DEC_TCP_SEQ_VALUE,
1460 static const enum index action_inc_tcp_ack[] = {
1461 ACTION_INC_TCP_ACK_VALUE,
1466 static const enum index action_dec_tcp_ack[] = {
1467 ACTION_DEC_TCP_ACK_VALUE,
1472 static const enum index action_raw_encap[] = {
1473 ACTION_RAW_ENCAP_INDEX,
1478 static const enum index action_raw_decap[] = {
1479 ACTION_RAW_DECAP_INDEX,
1484 static const enum index action_set_tag[] = {
1485 ACTION_SET_TAG_DATA,
1486 ACTION_SET_TAG_INDEX,
1487 ACTION_SET_TAG_MASK,
1492 static const enum index action_set_meta[] = {
1493 ACTION_SET_META_DATA,
1494 ACTION_SET_META_MASK,
1499 static const enum index action_set_ipv4_dscp[] = {
1500 ACTION_SET_IPV4_DSCP_VALUE,
1505 static const enum index action_set_ipv6_dscp[] = {
1506 ACTION_SET_IPV6_DSCP_VALUE,
1511 static const enum index action_age[] = {
1518 static const enum index action_sample[] = {
1520 ACTION_SAMPLE_RATIO,
1521 ACTION_SAMPLE_INDEX,
1526 static const enum index next_action_sample[] = {
1536 static int parse_set_raw_encap_decap(struct context *, const struct token *,
1537 const char *, unsigned int,
1538 void *, unsigned int);
1539 static int parse_set_sample_action(struct context *, const struct token *,
1540 const char *, unsigned int,
1541 void *, unsigned int);
1542 static int parse_set_init(struct context *, const struct token *,
1543 const char *, unsigned int,
1544 void *, unsigned int);
1545 static int parse_init(struct context *, const struct token *,
1546 const char *, unsigned int,
1547 void *, unsigned int);
1548 static int parse_vc(struct context *, const struct token *,
1549 const char *, unsigned int,
1550 void *, unsigned int);
1551 static int parse_vc_spec(struct context *, const struct token *,
1552 const char *, unsigned int, void *, unsigned int);
1553 static int parse_vc_conf(struct context *, const struct token *,
1554 const char *, unsigned int, void *, unsigned int);
1555 static int parse_vc_item_ecpri_type(struct context *, const struct token *,
1556 const char *, unsigned int,
1557 void *, unsigned int);
1558 static int parse_vc_action_rss(struct context *, const struct token *,
1559 const char *, unsigned int, void *,
1561 static int parse_vc_action_rss_func(struct context *, const struct token *,
1562 const char *, unsigned int, void *,
1564 static int parse_vc_action_rss_type(struct context *, const struct token *,
1565 const char *, unsigned int, void *,
1567 static int parse_vc_action_rss_queue(struct context *, const struct token *,
1568 const char *, unsigned int, void *,
1570 static int parse_vc_action_vxlan_encap(struct context *, const struct token *,
1571 const char *, unsigned int, void *,
1573 static int parse_vc_action_nvgre_encap(struct context *, const struct token *,
1574 const char *, unsigned int, void *,
1576 static int parse_vc_action_l2_encap(struct context *, const struct token *,
1577 const char *, unsigned int, void *,
1579 static int parse_vc_action_l2_decap(struct context *, const struct token *,
1580 const char *, unsigned int, void *,
1582 static int parse_vc_action_mplsogre_encap(struct context *,
1583 const struct token *, const char *,
1584 unsigned int, void *, unsigned int);
1585 static int parse_vc_action_mplsogre_decap(struct context *,
1586 const struct token *, const char *,
1587 unsigned int, void *, unsigned int);
1588 static int parse_vc_action_mplsoudp_encap(struct context *,
1589 const struct token *, const char *,
1590 unsigned int, void *, unsigned int);
1591 static int parse_vc_action_mplsoudp_decap(struct context *,
1592 const struct token *, const char *,
1593 unsigned int, void *, unsigned int);
1594 static int parse_vc_action_raw_encap(struct context *,
1595 const struct token *, const char *,
1596 unsigned int, void *, unsigned int);
1597 static int parse_vc_action_raw_decap(struct context *,
1598 const struct token *, const char *,
1599 unsigned int, void *, unsigned int);
1600 static int parse_vc_action_raw_encap_index(struct context *,
1601 const struct token *, const char *,
1602 unsigned int, void *, unsigned int);
1603 static int parse_vc_action_raw_decap_index(struct context *,
1604 const struct token *, const char *,
1605 unsigned int, void *, unsigned int);
1606 static int parse_vc_action_set_meta(struct context *ctx,
1607 const struct token *token, const char *str,
1608 unsigned int len, void *buf,
1610 static int parse_vc_action_sample(struct context *ctx,
1611 const struct token *token, const char *str,
1612 unsigned int len, void *buf,
1615 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
1616 const char *str, unsigned int len, void *buf,
1618 static int parse_destroy(struct context *, const struct token *,
1619 const char *, unsigned int,
1620 void *, unsigned int);
1621 static int parse_flush(struct context *, const struct token *,
1622 const char *, unsigned int,
1623 void *, unsigned int);
1624 static int parse_dump(struct context *, const struct token *,
1625 const char *, unsigned int,
1626 void *, unsigned int);
1627 static int parse_query(struct context *, const struct token *,
1628 const char *, unsigned int,
1629 void *, unsigned int);
1630 static int parse_action(struct context *, const struct token *,
1631 const char *, unsigned int,
1632 void *, unsigned int);
1633 static int parse_list(struct context *, const struct token *,
1634 const char *, unsigned int,
1635 void *, unsigned int);
1636 static int parse_aged(struct context *, const struct token *,
1637 const char *, unsigned int,
1638 void *, unsigned int);
1639 static int parse_isolate(struct context *, const struct token *,
1640 const char *, unsigned int,
1641 void *, unsigned int);
1642 static int parse_int(struct context *, const struct token *,
1643 const char *, unsigned int,
1644 void *, unsigned int);
1645 static int parse_prefix(struct context *, const struct token *,
1646 const char *, unsigned int,
1647 void *, unsigned int);
1648 static int parse_boolean(struct context *, const struct token *,
1649 const char *, unsigned int,
1650 void *, unsigned int);
1651 static int parse_string(struct context *, const struct token *,
1652 const char *, unsigned int,
1653 void *, unsigned int);
1654 static int parse_hex(struct context *ctx, const struct token *token,
1655 const char *str, unsigned int len,
1656 void *buf, unsigned int size);
1657 static int parse_string0(struct context *, const struct token *,
1658 const char *, unsigned int,
1659 void *, unsigned int);
1660 static int parse_mac_addr(struct context *, const struct token *,
1661 const char *, unsigned int,
1662 void *, unsigned int);
1663 static int parse_ipv4_addr(struct context *, const struct token *,
1664 const char *, unsigned int,
1665 void *, unsigned int);
1666 static int parse_ipv6_addr(struct context *, const struct token *,
1667 const char *, unsigned int,
1668 void *, unsigned int);
1669 static int parse_port(struct context *, const struct token *,
1670 const char *, unsigned int,
1671 void *, unsigned int);
1672 static int parse_sa(struct context *, const struct token *,
1673 const char *, unsigned int,
1674 void *, unsigned int);
1675 static int parse_sa_destroy(struct context *ctx, const struct token *token,
1676 const char *str, unsigned int len,
1677 void *buf, unsigned int size);
1678 static int parse_sa_id2ptr(struct context *ctx, const struct token *token,
1679 const char *str, unsigned int len, void *buf,
1681 static int comp_none(struct context *, const struct token *,
1682 unsigned int, char *, unsigned int);
1683 static int comp_boolean(struct context *, const struct token *,
1684 unsigned int, char *, unsigned int);
1685 static int comp_action(struct context *, const struct token *,
1686 unsigned int, char *, unsigned int);
1687 static int comp_port(struct context *, const struct token *,
1688 unsigned int, char *, unsigned int);
1689 static int comp_rule_id(struct context *, const struct token *,
1690 unsigned int, char *, unsigned int);
1691 static int comp_vc_action_rss_type(struct context *, const struct token *,
1692 unsigned int, char *, unsigned int);
1693 static int comp_vc_action_rss_queue(struct context *, const struct token *,
1694 unsigned int, char *, unsigned int);
1695 static int comp_set_raw_index(struct context *, const struct token *,
1696 unsigned int, char *, unsigned int);
1697 static int comp_set_sample_index(struct context *, const struct token *,
1698 unsigned int, char *, unsigned int);
1700 /** Token definitions. */
1701 static const struct token token_list[] = {
1702 /* Special tokens. */
1705 .help = "null entry, abused as the entry point",
1706 .next = NEXT(NEXT_ENTRY(FLOW)),
1711 .help = "command may end here",
1714 .name = "START_SET",
1715 .help = "null entry, abused as the entry point for set",
1716 .next = NEXT(NEXT_ENTRY(SET)),
1721 .help = "set command may end here",
1723 /* Common tokens. */
1727 .help = "integer value",
1732 .name = "{unsigned}",
1734 .help = "unsigned integer value",
1741 .help = "prefix length for bit-mask",
1742 .call = parse_prefix,
1746 .name = "{boolean}",
1748 .help = "any boolean value",
1749 .call = parse_boolean,
1750 .comp = comp_boolean,
1755 .help = "fixed string",
1756 .call = parse_string,
1762 .help = "fixed string",
1766 .name = "{file path}",
1768 .help = "file path",
1769 .call = parse_string0,
1773 .name = "{MAC address}",
1775 .help = "standard MAC address notation",
1776 .call = parse_mac_addr,
1780 .name = "{IPv4 address}",
1781 .type = "IPV4 ADDRESS",
1782 .help = "standard IPv4 address notation",
1783 .call = parse_ipv4_addr,
1787 .name = "{IPv6 address}",
1788 .type = "IPV6 ADDRESS",
1789 .help = "standard IPv6 address notation",
1790 .call = parse_ipv6_addr,
1794 .name = "{rule id}",
1796 .help = "rule identifier",
1798 .comp = comp_rule_id,
1801 .name = "{port_id}",
1803 .help = "port identifier",
1808 .name = "{group_id}",
1810 .help = "group identifier",
1814 [PRIORITY_LEVEL] = {
1817 .help = "priority level",
1821 [SHARED_ACTION_ID] = {
1822 .name = "{shared_action_id}",
1823 .type = "SHARED_ACTION_ID",
1824 .help = "shared action id",
1828 /* Top-level command. */
1831 .type = "{command} {port_id} [{arg} [...]]",
1832 .help = "manage ingress/egress flow rules",
1833 .next = NEXT(NEXT_ENTRY
1846 /* Top-level command. */
1848 .name = "shared_action",
1849 .type = "{command} {port_id} [{arg} [...]]",
1850 .help = "manage shared actions",
1851 .next = NEXT(next_sa_subcmd, NEXT_ENTRY(PORT_ID)),
1852 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1855 /* Sub-level commands. */
1856 [SHARED_ACTION_CREATE] = {
1858 .help = "create shared action",
1859 .next = NEXT(next_sa_create_attr),
1862 [SHARED_ACTION_UPDATE] = {
1864 .help = "update shared action",
1865 .next = NEXT(NEXT_ENTRY(SHARED_ACTION_SPEC),
1866 NEXT_ENTRY(SHARED_ACTION_ID)),
1867 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
1870 [SHARED_ACTION_DESTROY] = {
1872 .help = "destroy shared action",
1873 .next = NEXT(NEXT_ENTRY(SHARED_ACTION_DESTROY_ID)),
1874 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1875 .call = parse_sa_destroy,
1877 [SHARED_ACTION_QUERY] = {
1879 .help = "query shared action",
1880 .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(SHARED_ACTION_ID)),
1881 .args = ARGS(ARGS_ENTRY(struct buffer, args.sa.action_id)),
1886 .help = "check whether a flow rule can be created",
1887 .next = NEXT(next_vc_attr, NEXT_ENTRY(PORT_ID)),
1888 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1893 .help = "create a flow rule",
1894 .next = NEXT(next_vc_attr, NEXT_ENTRY(PORT_ID)),
1895 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1900 .help = "destroy specific flow rules",
1901 .next = NEXT(NEXT_ENTRY(DESTROY_RULE), NEXT_ENTRY(PORT_ID)),
1902 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1903 .call = parse_destroy,
1907 .help = "destroy all flow rules",
1908 .next = NEXT(NEXT_ENTRY(PORT_ID)),
1909 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1910 .call = parse_flush,
1914 .help = "dump all flow rules to file",
1915 .next = NEXT(next_dump_attr, NEXT_ENTRY(PORT_ID)),
1916 .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file),
1917 ARGS_ENTRY(struct buffer, port)),
1922 .help = "query an existing flow rule",
1923 .next = NEXT(NEXT_ENTRY(QUERY_ACTION),
1924 NEXT_ENTRY(RULE_ID),
1925 NEXT_ENTRY(PORT_ID)),
1926 .args = ARGS(ARGS_ENTRY(struct buffer, args.query.action.type),
1927 ARGS_ENTRY(struct buffer, args.query.rule),
1928 ARGS_ENTRY(struct buffer, port)),
1929 .call = parse_query,
1933 .help = "list existing flow rules",
1934 .next = NEXT(next_list_attr, NEXT_ENTRY(PORT_ID)),
1935 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1940 .help = "list and destroy aged flows",
1941 .next = NEXT(next_aged_attr, NEXT_ENTRY(PORT_ID)),
1942 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1947 .help = "restrict ingress traffic to the defined flow rules",
1948 .next = NEXT(NEXT_ENTRY(BOOLEAN),
1949 NEXT_ENTRY(PORT_ID)),
1950 .args = ARGS(ARGS_ENTRY(struct buffer, args.isolate.set),
1951 ARGS_ENTRY(struct buffer, port)),
1952 .call = parse_isolate,
1954 /* Destroy arguments. */
1957 .help = "specify a rule identifier",
1958 .next = NEXT(next_destroy_attr, NEXT_ENTRY(RULE_ID)),
1959 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.destroy.rule)),
1960 .call = parse_destroy,
1962 /* Query arguments. */
1966 .help = "action to query, must be part of the rule",
1967 .call = parse_action,
1968 .comp = comp_action,
1970 /* List arguments. */
1973 .help = "specify a group",
1974 .next = NEXT(next_list_attr, NEXT_ENTRY(GROUP_ID)),
1975 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.list.group)),
1980 .help = "specify aged flows need be destroyed",
1984 /* Validate/create attributes. */
1987 .help = "specify a group",
1988 .next = NEXT(next_vc_attr, NEXT_ENTRY(GROUP_ID)),
1989 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, group)),
1994 .help = "specify a priority level",
1995 .next = NEXT(next_vc_attr, NEXT_ENTRY(PRIORITY_LEVEL)),
1996 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, priority)),
2001 .help = "affect rule to ingress",
2002 .next = NEXT(next_vc_attr),
2007 .help = "affect rule to egress",
2008 .next = NEXT(next_vc_attr),
2013 .help = "apply rule directly to endpoints found in pattern",
2014 .next = NEXT(next_vc_attr),
2017 /* Validate/create pattern. */
2020 .help = "submit a list of pattern items",
2021 .next = NEXT(next_item),
2026 .help = "match value perfectly (with full bit-mask)",
2027 .call = parse_vc_spec,
2029 [ITEM_PARAM_SPEC] = {
2031 .help = "match value according to configured bit-mask",
2032 .call = parse_vc_spec,
2034 [ITEM_PARAM_LAST] = {
2036 .help = "specify upper bound to establish a range",
2037 .call = parse_vc_spec,
2039 [ITEM_PARAM_MASK] = {
2041 .help = "specify bit-mask with relevant bits set to one",
2042 .call = parse_vc_spec,
2044 [ITEM_PARAM_PREFIX] = {
2046 .help = "generate bit-mask from a prefix length",
2047 .call = parse_vc_spec,
2051 .help = "specify next pattern item",
2052 .next = NEXT(next_item),
2056 .help = "end list of pattern items",
2057 .priv = PRIV_ITEM(END, 0),
2058 .next = NEXT(NEXT_ENTRY(ACTIONS)),
2063 .help = "no-op pattern item",
2064 .priv = PRIV_ITEM(VOID, 0),
2065 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2070 .help = "perform actions when pattern does not match",
2071 .priv = PRIV_ITEM(INVERT, 0),
2072 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2077 .help = "match any protocol for the current layer",
2078 .priv = PRIV_ITEM(ANY, sizeof(struct rte_flow_item_any)),
2079 .next = NEXT(item_any),
2084 .help = "number of layers covered",
2085 .next = NEXT(item_any, NEXT_ENTRY(UNSIGNED), item_param),
2086 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_any, num)),
2090 .help = "match traffic from/to the physical function",
2091 .priv = PRIV_ITEM(PF, 0),
2092 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2097 .help = "match traffic from/to a virtual function ID",
2098 .priv = PRIV_ITEM(VF, sizeof(struct rte_flow_item_vf)),
2099 .next = NEXT(item_vf),
2105 .next = NEXT(item_vf, NEXT_ENTRY(UNSIGNED), item_param),
2106 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_vf, id)),
2110 .help = "match traffic from/to a specific physical port",
2111 .priv = PRIV_ITEM(PHY_PORT,
2112 sizeof(struct rte_flow_item_phy_port)),
2113 .next = NEXT(item_phy_port),
2116 [ITEM_PHY_PORT_INDEX] = {
2118 .help = "physical port index",
2119 .next = NEXT(item_phy_port, NEXT_ENTRY(UNSIGNED), item_param),
2120 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_phy_port, index)),
2124 .help = "match traffic from/to a given DPDK port ID",
2125 .priv = PRIV_ITEM(PORT_ID,
2126 sizeof(struct rte_flow_item_port_id)),
2127 .next = NEXT(item_port_id),
2130 [ITEM_PORT_ID_ID] = {
2132 .help = "DPDK port ID",
2133 .next = NEXT(item_port_id, NEXT_ENTRY(UNSIGNED), item_param),
2134 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port_id, id)),
2138 .help = "match traffic against value set in previously matched rule",
2139 .priv = PRIV_ITEM(MARK, sizeof(struct rte_flow_item_mark)),
2140 .next = NEXT(item_mark),
2145 .help = "Integer value to match against",
2146 .next = NEXT(item_mark, NEXT_ENTRY(UNSIGNED), item_param),
2147 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_mark, id)),
2151 .help = "match an arbitrary byte string",
2152 .priv = PRIV_ITEM(RAW, ITEM_RAW_SIZE),
2153 .next = NEXT(item_raw),
2156 [ITEM_RAW_RELATIVE] = {
2158 .help = "look for pattern after the previous item",
2159 .next = NEXT(item_raw, NEXT_ENTRY(BOOLEAN), item_param),
2160 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
2163 [ITEM_RAW_SEARCH] = {
2165 .help = "search pattern from offset (see also limit)",
2166 .next = NEXT(item_raw, NEXT_ENTRY(BOOLEAN), item_param),
2167 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
2170 [ITEM_RAW_OFFSET] = {
2172 .help = "absolute or relative offset for pattern",
2173 .next = NEXT(item_raw, NEXT_ENTRY(INTEGER), item_param),
2174 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, offset)),
2176 [ITEM_RAW_LIMIT] = {
2178 .help = "search area limit for start of pattern",
2179 .next = NEXT(item_raw, NEXT_ENTRY(UNSIGNED), item_param),
2180 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, limit)),
2182 [ITEM_RAW_PATTERN] = {
2184 .help = "byte string to look for",
2185 .next = NEXT(item_raw,
2187 NEXT_ENTRY(ITEM_PARAM_IS,
2190 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern),
2191 ARGS_ENTRY(struct rte_flow_item_raw, length),
2192 ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw),
2193 ITEM_RAW_PATTERN_SIZE)),
2197 .help = "match Ethernet header",
2198 .priv = PRIV_ITEM(ETH, sizeof(struct rte_flow_item_eth)),
2199 .next = NEXT(item_eth),
2204 .help = "destination MAC",
2205 .next = NEXT(item_eth, NEXT_ENTRY(MAC_ADDR), item_param),
2206 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, dst)),
2210 .help = "source MAC",
2211 .next = NEXT(item_eth, NEXT_ENTRY(MAC_ADDR), item_param),
2212 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, src)),
2216 .help = "EtherType",
2217 .next = NEXT(item_eth, NEXT_ENTRY(UNSIGNED), item_param),
2218 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, type)),
2222 .help = "match 802.1Q/ad VLAN tag",
2223 .priv = PRIV_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)),
2224 .next = NEXT(item_vlan),
2229 .help = "tag control information",
2230 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2231 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, tci)),
2235 .help = "priority code point",
2236 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2237 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2242 .help = "drop eligible indicator",
2243 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2244 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2249 .help = "VLAN identifier",
2250 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2251 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2254 [ITEM_VLAN_INNER_TYPE] = {
2255 .name = "inner_type",
2256 .help = "inner EtherType",
2257 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2258 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan,
2263 .help = "match IPv4 header",
2264 .priv = PRIV_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)),
2265 .next = NEXT(item_ipv4),
2270 .help = "type of service",
2271 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2272 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2273 hdr.type_of_service)),
2275 [ITEM_IPV4_FRAGMENT_OFFSET] = {
2276 .name = "fragment_offset",
2277 .help = "fragmentation flags and fragment offset",
2278 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2279 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2280 hdr.fragment_offset)),
2284 .help = "time to live",
2285 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2286 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2289 [ITEM_IPV4_PROTO] = {
2291 .help = "next protocol ID",
2292 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2293 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2294 hdr.next_proto_id)),
2298 .help = "source address",
2299 .next = NEXT(item_ipv4, NEXT_ENTRY(IPV4_ADDR), item_param),
2300 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2305 .help = "destination address",
2306 .next = NEXT(item_ipv4, NEXT_ENTRY(IPV4_ADDR), item_param),
2307 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2312 .help = "match IPv6 header",
2313 .priv = PRIV_ITEM(IPV6, sizeof(struct rte_flow_item_ipv6)),
2314 .next = NEXT(item_ipv6),
2319 .help = "traffic class",
2320 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2321 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2323 "\x0f\xf0\x00\x00")),
2325 [ITEM_IPV6_FLOW] = {
2327 .help = "flow label",
2328 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2329 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2331 "\x00\x0f\xff\xff")),
2333 [ITEM_IPV6_PROTO] = {
2335 .help = "protocol (next header)",
2336 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2337 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2342 .help = "hop limit",
2343 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2344 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2349 .help = "source address",
2350 .next = NEXT(item_ipv6, NEXT_ENTRY(IPV6_ADDR), item_param),
2351 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2356 .help = "destination address",
2357 .next = NEXT(item_ipv6, NEXT_ENTRY(IPV6_ADDR), item_param),
2358 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2361 [ITEM_IPV6_HAS_FRAG_EXT] = {
2362 .name = "has_frag_ext",
2363 .help = "fragment packet attribute",
2364 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2365 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_ipv6,
2370 .help = "match ICMP header",
2371 .priv = PRIV_ITEM(ICMP, sizeof(struct rte_flow_item_icmp)),
2372 .next = NEXT(item_icmp),
2375 [ITEM_ICMP_TYPE] = {
2377 .help = "ICMP packet type",
2378 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2379 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2382 [ITEM_ICMP_CODE] = {
2384 .help = "ICMP packet code",
2385 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2386 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2389 [ITEM_ICMP_IDENT] = {
2391 .help = "ICMP packet identifier",
2392 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2393 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2398 .help = "ICMP packet sequence number",
2399 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2400 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2405 .help = "match UDP header",
2406 .priv = PRIV_ITEM(UDP, sizeof(struct rte_flow_item_udp)),
2407 .next = NEXT(item_udp),
2412 .help = "UDP source port",
2413 .next = NEXT(item_udp, NEXT_ENTRY(UNSIGNED), item_param),
2414 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2419 .help = "UDP destination port",
2420 .next = NEXT(item_udp, NEXT_ENTRY(UNSIGNED), item_param),
2421 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2426 .help = "match TCP header",
2427 .priv = PRIV_ITEM(TCP, sizeof(struct rte_flow_item_tcp)),
2428 .next = NEXT(item_tcp),
2433 .help = "TCP source port",
2434 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2435 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2440 .help = "TCP destination port",
2441 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2442 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2445 [ITEM_TCP_FLAGS] = {
2447 .help = "TCP flags",
2448 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2449 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2454 .help = "match SCTP header",
2455 .priv = PRIV_ITEM(SCTP, sizeof(struct rte_flow_item_sctp)),
2456 .next = NEXT(item_sctp),
2461 .help = "SCTP source port",
2462 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2463 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2468 .help = "SCTP destination port",
2469 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2470 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2475 .help = "validation tag",
2476 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2477 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2480 [ITEM_SCTP_CKSUM] = {
2483 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2484 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2489 .help = "match VXLAN header",
2490 .priv = PRIV_ITEM(VXLAN, sizeof(struct rte_flow_item_vxlan)),
2491 .next = NEXT(item_vxlan),
2494 [ITEM_VXLAN_VNI] = {
2496 .help = "VXLAN identifier",
2497 .next = NEXT(item_vxlan, NEXT_ENTRY(UNSIGNED), item_param),
2498 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan, vni)),
2502 .help = "match E-Tag header",
2503 .priv = PRIV_ITEM(E_TAG, sizeof(struct rte_flow_item_e_tag)),
2504 .next = NEXT(item_e_tag),
2507 [ITEM_E_TAG_GRP_ECID_B] = {
2508 .name = "grp_ecid_b",
2509 .help = "GRP and E-CID base",
2510 .next = NEXT(item_e_tag, NEXT_ENTRY(UNSIGNED), item_param),
2511 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_e_tag,
2517 .help = "match NVGRE header",
2518 .priv = PRIV_ITEM(NVGRE, sizeof(struct rte_flow_item_nvgre)),
2519 .next = NEXT(item_nvgre),
2522 [ITEM_NVGRE_TNI] = {
2524 .help = "virtual subnet ID",
2525 .next = NEXT(item_nvgre, NEXT_ENTRY(UNSIGNED), item_param),
2526 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_nvgre, tni)),
2530 .help = "match MPLS header",
2531 .priv = PRIV_ITEM(MPLS, sizeof(struct rte_flow_item_mpls)),
2532 .next = NEXT(item_mpls),
2535 [ITEM_MPLS_LABEL] = {
2537 .help = "MPLS label",
2538 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2539 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2545 .help = "MPLS Traffic Class",
2546 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2547 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2553 .help = "MPLS Bottom-of-Stack",
2554 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2555 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2561 .help = "match GRE header",
2562 .priv = PRIV_ITEM(GRE, sizeof(struct rte_flow_item_gre)),
2563 .next = NEXT(item_gre),
2566 [ITEM_GRE_PROTO] = {
2568 .help = "GRE protocol type",
2569 .next = NEXT(item_gre, NEXT_ENTRY(UNSIGNED), item_param),
2570 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2573 [ITEM_GRE_C_RSVD0_VER] = {
2574 .name = "c_rsvd0_ver",
2576 "checksum (1b), undefined (1b), key bit (1b),"
2577 " sequence number (1b), reserved 0 (9b),"
2579 .next = NEXT(item_gre, NEXT_ENTRY(UNSIGNED), item_param),
2580 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2583 [ITEM_GRE_C_BIT] = {
2585 .help = "checksum bit (C)",
2586 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2587 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2589 "\x80\x00\x00\x00")),
2591 [ITEM_GRE_S_BIT] = {
2593 .help = "sequence number bit (S)",
2594 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2595 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2597 "\x10\x00\x00\x00")),
2599 [ITEM_GRE_K_BIT] = {
2601 .help = "key bit (K)",
2602 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2603 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2605 "\x20\x00\x00\x00")),
2609 .help = "fuzzy pattern match, expect faster than default",
2610 .priv = PRIV_ITEM(FUZZY,
2611 sizeof(struct rte_flow_item_fuzzy)),
2612 .next = NEXT(item_fuzzy),
2615 [ITEM_FUZZY_THRESH] = {
2617 .help = "match accuracy threshold",
2618 .next = NEXT(item_fuzzy, NEXT_ENTRY(UNSIGNED), item_param),
2619 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_fuzzy,
2624 .help = "match GTP header",
2625 .priv = PRIV_ITEM(GTP, sizeof(struct rte_flow_item_gtp)),
2626 .next = NEXT(item_gtp),
2629 [ITEM_GTP_FLAGS] = {
2630 .name = "v_pt_rsv_flags",
2631 .help = "GTP flags",
2632 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2633 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp,
2636 [ITEM_GTP_MSG_TYPE] = {
2638 .help = "GTP message type",
2639 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2640 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp, msg_type)),
2644 .help = "tunnel endpoint identifier",
2645 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2646 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp, teid)),
2650 .help = "match GTP header",
2651 .priv = PRIV_ITEM(GTPC, sizeof(struct rte_flow_item_gtp)),
2652 .next = NEXT(item_gtp),
2657 .help = "match GTP header",
2658 .priv = PRIV_ITEM(GTPU, sizeof(struct rte_flow_item_gtp)),
2659 .next = NEXT(item_gtp),
2664 .help = "match GENEVE header",
2665 .priv = PRIV_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)),
2666 .next = NEXT(item_geneve),
2669 [ITEM_GENEVE_VNI] = {
2671 .help = "virtual network identifier",
2672 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2673 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve, vni)),
2675 [ITEM_GENEVE_PROTO] = {
2677 .help = "GENEVE protocol type",
2678 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2679 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve,
2682 [ITEM_VXLAN_GPE] = {
2683 .name = "vxlan-gpe",
2684 .help = "match VXLAN-GPE header",
2685 .priv = PRIV_ITEM(VXLAN_GPE,
2686 sizeof(struct rte_flow_item_vxlan_gpe)),
2687 .next = NEXT(item_vxlan_gpe),
2690 [ITEM_VXLAN_GPE_VNI] = {
2692 .help = "VXLAN-GPE identifier",
2693 .next = NEXT(item_vxlan_gpe, NEXT_ENTRY(UNSIGNED), item_param),
2694 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
2697 [ITEM_ARP_ETH_IPV4] = {
2698 .name = "arp_eth_ipv4",
2699 .help = "match ARP header for Ethernet/IPv4",
2700 .priv = PRIV_ITEM(ARP_ETH_IPV4,
2701 sizeof(struct rte_flow_item_arp_eth_ipv4)),
2702 .next = NEXT(item_arp_eth_ipv4),
2705 [ITEM_ARP_ETH_IPV4_SHA] = {
2707 .help = "sender hardware address",
2708 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(MAC_ADDR),
2710 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2713 [ITEM_ARP_ETH_IPV4_SPA] = {
2715 .help = "sender IPv4 address",
2716 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(IPV4_ADDR),
2718 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2721 [ITEM_ARP_ETH_IPV4_THA] = {
2723 .help = "target hardware address",
2724 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(MAC_ADDR),
2726 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2729 [ITEM_ARP_ETH_IPV4_TPA] = {
2731 .help = "target IPv4 address",
2732 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(IPV4_ADDR),
2734 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2739 .help = "match presence of any IPv6 extension header",
2740 .priv = PRIV_ITEM(IPV6_EXT,
2741 sizeof(struct rte_flow_item_ipv6_ext)),
2742 .next = NEXT(item_ipv6_ext),
2745 [ITEM_IPV6_EXT_NEXT_HDR] = {
2747 .help = "next header",
2748 .next = NEXT(item_ipv6_ext, NEXT_ENTRY(UNSIGNED), item_param),
2749 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_ext,
2752 [ITEM_IPV6_FRAG_EXT] = {
2753 .name = "ipv6_frag_ext",
2754 .help = "match presence of IPv6 fragment extension header",
2755 .priv = PRIV_ITEM(IPV6_FRAG_EXT,
2756 sizeof(struct rte_flow_item_ipv6_frag_ext)),
2757 .next = NEXT(item_ipv6_frag_ext),
2760 [ITEM_IPV6_FRAG_EXT_NEXT_HDR] = {
2762 .help = "next header",
2763 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(UNSIGNED),
2765 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ipv6_frag_ext,
2768 [ITEM_IPV6_FRAG_EXT_FRAG_DATA] = {
2769 .name = "frag_data",
2770 .help = "Fragment flags and offset",
2771 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(UNSIGNED),
2773 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_frag_ext,
2778 .help = "match any ICMPv6 header",
2779 .priv = PRIV_ITEM(ICMP6, sizeof(struct rte_flow_item_icmp6)),
2780 .next = NEXT(item_icmp6),
2783 [ITEM_ICMP6_TYPE] = {
2785 .help = "ICMPv6 type",
2786 .next = NEXT(item_icmp6, NEXT_ENTRY(UNSIGNED), item_param),
2787 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
2790 [ITEM_ICMP6_CODE] = {
2792 .help = "ICMPv6 code",
2793 .next = NEXT(item_icmp6, NEXT_ENTRY(UNSIGNED), item_param),
2794 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
2797 [ITEM_ICMP6_ND_NS] = {
2798 .name = "icmp6_nd_ns",
2799 .help = "match ICMPv6 neighbor discovery solicitation",
2800 .priv = PRIV_ITEM(ICMP6_ND_NS,
2801 sizeof(struct rte_flow_item_icmp6_nd_ns)),
2802 .next = NEXT(item_icmp6_nd_ns),
2805 [ITEM_ICMP6_ND_NS_TARGET_ADDR] = {
2806 .name = "target_addr",
2807 .help = "target address",
2808 .next = NEXT(item_icmp6_nd_ns, NEXT_ENTRY(IPV6_ADDR),
2810 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_ns,
2813 [ITEM_ICMP6_ND_NA] = {
2814 .name = "icmp6_nd_na",
2815 .help = "match ICMPv6 neighbor discovery advertisement",
2816 .priv = PRIV_ITEM(ICMP6_ND_NA,
2817 sizeof(struct rte_flow_item_icmp6_nd_na)),
2818 .next = NEXT(item_icmp6_nd_na),
2821 [ITEM_ICMP6_ND_NA_TARGET_ADDR] = {
2822 .name = "target_addr",
2823 .help = "target address",
2824 .next = NEXT(item_icmp6_nd_na, NEXT_ENTRY(IPV6_ADDR),
2826 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_na,
2829 [ITEM_ICMP6_ND_OPT] = {
2830 .name = "icmp6_nd_opt",
2831 .help = "match presence of any ICMPv6 neighbor discovery"
2833 .priv = PRIV_ITEM(ICMP6_ND_OPT,
2834 sizeof(struct rte_flow_item_icmp6_nd_opt)),
2835 .next = NEXT(item_icmp6_nd_opt),
2838 [ITEM_ICMP6_ND_OPT_TYPE] = {
2840 .help = "ND option type",
2841 .next = NEXT(item_icmp6_nd_opt, NEXT_ENTRY(UNSIGNED),
2843 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_opt,
2846 [ITEM_ICMP6_ND_OPT_SLA_ETH] = {
2847 .name = "icmp6_nd_opt_sla_eth",
2848 .help = "match ICMPv6 neighbor discovery source Ethernet"
2849 " link-layer address option",
2851 (ICMP6_ND_OPT_SLA_ETH,
2852 sizeof(struct rte_flow_item_icmp6_nd_opt_sla_eth)),
2853 .next = NEXT(item_icmp6_nd_opt_sla_eth),
2856 [ITEM_ICMP6_ND_OPT_SLA_ETH_SLA] = {
2858 .help = "source Ethernet LLA",
2859 .next = NEXT(item_icmp6_nd_opt_sla_eth, NEXT_ENTRY(MAC_ADDR),
2861 .args = ARGS(ARGS_ENTRY_HTON
2862 (struct rte_flow_item_icmp6_nd_opt_sla_eth, sla)),
2864 [ITEM_ICMP6_ND_OPT_TLA_ETH] = {
2865 .name = "icmp6_nd_opt_tla_eth",
2866 .help = "match ICMPv6 neighbor discovery target Ethernet"
2867 " link-layer address option",
2869 (ICMP6_ND_OPT_TLA_ETH,
2870 sizeof(struct rte_flow_item_icmp6_nd_opt_tla_eth)),
2871 .next = NEXT(item_icmp6_nd_opt_tla_eth),
2874 [ITEM_ICMP6_ND_OPT_TLA_ETH_TLA] = {
2876 .help = "target Ethernet LLA",
2877 .next = NEXT(item_icmp6_nd_opt_tla_eth, NEXT_ENTRY(MAC_ADDR),
2879 .args = ARGS(ARGS_ENTRY_HTON
2880 (struct rte_flow_item_icmp6_nd_opt_tla_eth, tla)),
2884 .help = "match metadata header",
2885 .priv = PRIV_ITEM(META, sizeof(struct rte_flow_item_meta)),
2886 .next = NEXT(item_meta),
2889 [ITEM_META_DATA] = {
2891 .help = "metadata value",
2892 .next = NEXT(item_meta, NEXT_ENTRY(UNSIGNED), item_param),
2893 .args = ARGS(ARGS_ENTRY_MASK(struct rte_flow_item_meta,
2894 data, "\xff\xff\xff\xff")),
2898 .help = "match GRE key",
2899 .priv = PRIV_ITEM(GRE_KEY, sizeof(rte_be32_t)),
2900 .next = NEXT(item_gre_key),
2903 [ITEM_GRE_KEY_VALUE] = {
2905 .help = "key value",
2906 .next = NEXT(item_gre_key, NEXT_ENTRY(UNSIGNED), item_param),
2907 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
2911 .help = "match GTP extension header with type 0x85",
2912 .priv = PRIV_ITEM(GTP_PSC,
2913 sizeof(struct rte_flow_item_gtp_psc)),
2914 .next = NEXT(item_gtp_psc),
2917 [ITEM_GTP_PSC_QFI] = {
2919 .help = "QoS flow identifier",
2920 .next = NEXT(item_gtp_psc, NEXT_ENTRY(UNSIGNED), item_param),
2921 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
2924 [ITEM_GTP_PSC_PDU_T] = {
2927 .next = NEXT(item_gtp_psc, NEXT_ENTRY(UNSIGNED), item_param),
2928 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
2933 .help = "match PPPoE session header",
2934 .priv = PRIV_ITEM(PPPOES, sizeof(struct rte_flow_item_pppoe)),
2935 .next = NEXT(item_pppoes),
2940 .help = "match PPPoE discovery header",
2941 .priv = PRIV_ITEM(PPPOED, sizeof(struct rte_flow_item_pppoe)),
2942 .next = NEXT(item_pppoed),
2945 [ITEM_PPPOE_SEID] = {
2947 .help = "session identifier",
2948 .next = NEXT(item_pppoes, NEXT_ENTRY(UNSIGNED), item_param),
2949 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pppoe,
2952 [ITEM_PPPOE_PROTO_ID] = {
2953 .name = "pppoe_proto_id",
2954 .help = "match PPPoE session protocol identifier",
2955 .priv = PRIV_ITEM(PPPOE_PROTO_ID,
2956 sizeof(struct rte_flow_item_pppoe_proto_id)),
2957 .next = NEXT(item_pppoe_proto_id, NEXT_ENTRY(UNSIGNED),
2959 .args = ARGS(ARGS_ENTRY_HTON
2960 (struct rte_flow_item_pppoe_proto_id, proto_id)),
2965 .help = "matches higig2 header",
2966 .priv = PRIV_ITEM(HIGIG2,
2967 sizeof(struct rte_flow_item_higig2_hdr)),
2968 .next = NEXT(item_higig2),
2971 [ITEM_HIGIG2_CLASSIFICATION] = {
2972 .name = "classification",
2973 .help = "matches classification of higig2 header",
2974 .next = NEXT(item_higig2, NEXT_ENTRY(UNSIGNED), item_param),
2975 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
2976 hdr.ppt1.classification)),
2978 [ITEM_HIGIG2_VID] = {
2980 .help = "matches vid of higig2 header",
2981 .next = NEXT(item_higig2, NEXT_ENTRY(UNSIGNED), item_param),
2982 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
2987 .help = "match tag value",
2988 .priv = PRIV_ITEM(TAG, sizeof(struct rte_flow_item_tag)),
2989 .next = NEXT(item_tag),
2994 .help = "tag value to match",
2995 .next = NEXT(item_tag, NEXT_ENTRY(UNSIGNED), item_param),
2996 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, data)),
2998 [ITEM_TAG_INDEX] = {
3000 .help = "index of tag array to match",
3001 .next = NEXT(item_tag, NEXT_ENTRY(UNSIGNED),
3002 NEXT_ENTRY(ITEM_PARAM_IS)),
3003 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, index)),
3005 [ITEM_L2TPV3OIP] = {
3006 .name = "l2tpv3oip",
3007 .help = "match L2TPv3 over IP header",
3008 .priv = PRIV_ITEM(L2TPV3OIP,
3009 sizeof(struct rte_flow_item_l2tpv3oip)),
3010 .next = NEXT(item_l2tpv3oip),
3013 [ITEM_L2TPV3OIP_SESSION_ID] = {
3014 .name = "session_id",
3015 .help = "session identifier",
3016 .next = NEXT(item_l2tpv3oip, NEXT_ENTRY(UNSIGNED), item_param),
3017 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv3oip,
3022 .help = "match ESP header",
3023 .priv = PRIV_ITEM(ESP, sizeof(struct rte_flow_item_esp)),
3024 .next = NEXT(item_esp),
3029 .help = "security policy index",
3030 .next = NEXT(item_esp, NEXT_ENTRY(UNSIGNED), item_param),
3031 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_esp,
3036 .help = "match AH header",
3037 .priv = PRIV_ITEM(AH, sizeof(struct rte_flow_item_ah)),
3038 .next = NEXT(item_ah),
3043 .help = "security parameters index",
3044 .next = NEXT(item_ah, NEXT_ENTRY(UNSIGNED), item_param),
3045 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ah, spi)),
3049 .help = "match pfcp header",
3050 .priv = PRIV_ITEM(PFCP, sizeof(struct rte_flow_item_pfcp)),
3051 .next = NEXT(item_pfcp),
3054 [ITEM_PFCP_S_FIELD] = {
3057 .next = NEXT(item_pfcp, NEXT_ENTRY(UNSIGNED), item_param),
3058 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp,
3061 [ITEM_PFCP_SEID] = {
3063 .help = "session endpoint identifier",
3064 .next = NEXT(item_pfcp, NEXT_ENTRY(UNSIGNED), item_param),
3065 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp, seid)),
3069 .help = "match eCPRI header",
3070 .priv = PRIV_ITEM(ECPRI, sizeof(struct rte_flow_item_ecpri)),
3071 .next = NEXT(item_ecpri),
3074 [ITEM_ECPRI_COMMON] = {
3076 .help = "eCPRI common header",
3077 .next = NEXT(item_ecpri_common),
3079 [ITEM_ECPRI_COMMON_TYPE] = {
3081 .help = "type of common header",
3082 .next = NEXT(item_ecpri_common_type),
3083 .args = ARGS(ARG_ENTRY_HTON(struct rte_flow_item_ecpri)),
3085 [ITEM_ECPRI_COMMON_TYPE_IQ_DATA] = {
3087 .help = "Type #0: IQ Data",
3088 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
3090 .call = parse_vc_item_ecpri_type,
3092 [ITEM_ECPRI_MSG_IQ_DATA_PCID] = {
3094 .help = "Physical Channel ID",
3095 .next = NEXT(item_ecpri, NEXT_ENTRY(UNSIGNED), item_param),
3096 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3099 [ITEM_ECPRI_COMMON_TYPE_RTC_CTRL] = {
3101 .help = "Type #2: Real-Time Control Data",
3102 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
3104 .call = parse_vc_item_ecpri_type,
3106 [ITEM_ECPRI_MSG_RTC_CTRL_RTCID] = {
3108 .help = "Real-Time Control Data ID",
3109 .next = NEXT(item_ecpri, NEXT_ENTRY(UNSIGNED), item_param),
3110 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3113 [ITEM_ECPRI_COMMON_TYPE_DLY_MSR] = {
3114 .name = "delay_measure",
3115 .help = "Type #5: One-Way Delay Measurement",
3116 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
3118 .call = parse_vc_item_ecpri_type,
3120 [ITEM_ECPRI_MSG_DLY_MSR_MSRID] = {
3122 .help = "Measurement ID",
3123 .next = NEXT(item_ecpri, NEXT_ENTRY(UNSIGNED), item_param),
3124 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3127 /* Validate/create actions. */
3130 .help = "submit a list of associated actions",
3131 .next = NEXT(next_action),
3136 .help = "specify next action",
3137 .next = NEXT(next_action),
3141 .help = "end list of actions",
3142 .priv = PRIV_ACTION(END, 0),
3147 .help = "no-op action",
3148 .priv = PRIV_ACTION(VOID, 0),
3149 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3152 [ACTION_PASSTHRU] = {
3154 .help = "let subsequent rule process matched packets",
3155 .priv = PRIV_ACTION(PASSTHRU, 0),
3156 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3161 .help = "redirect traffic to a given group",
3162 .priv = PRIV_ACTION(JUMP, sizeof(struct rte_flow_action_jump)),
3163 .next = NEXT(action_jump),
3166 [ACTION_JUMP_GROUP] = {
3168 .help = "group to redirect traffic to",
3169 .next = NEXT(action_jump, NEXT_ENTRY(UNSIGNED)),
3170 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump, group)),
3171 .call = parse_vc_conf,
3175 .help = "attach 32 bit value to packets",
3176 .priv = PRIV_ACTION(MARK, sizeof(struct rte_flow_action_mark)),
3177 .next = NEXT(action_mark),
3180 [ACTION_MARK_ID] = {
3182 .help = "32 bit value to return with packets",
3183 .next = NEXT(action_mark, NEXT_ENTRY(UNSIGNED)),
3184 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_mark, id)),
3185 .call = parse_vc_conf,
3189 .help = "flag packets",
3190 .priv = PRIV_ACTION(FLAG, 0),
3191 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3196 .help = "assign packets to a given queue index",
3197 .priv = PRIV_ACTION(QUEUE,
3198 sizeof(struct rte_flow_action_queue)),
3199 .next = NEXT(action_queue),
3202 [ACTION_QUEUE_INDEX] = {
3204 .help = "queue index to use",
3205 .next = NEXT(action_queue, NEXT_ENTRY(UNSIGNED)),
3206 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_queue, index)),
3207 .call = parse_vc_conf,
3211 .help = "drop packets (note: passthru has priority)",
3212 .priv = PRIV_ACTION(DROP, 0),
3213 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3218 .help = "enable counters for this rule",
3219 .priv = PRIV_ACTION(COUNT,
3220 sizeof(struct rte_flow_action_count)),
3221 .next = NEXT(action_count),
3224 [ACTION_COUNT_ID] = {
3225 .name = "identifier",
3226 .help = "counter identifier to use",
3227 .next = NEXT(action_count, NEXT_ENTRY(UNSIGNED)),
3228 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_count, id)),
3229 .call = parse_vc_conf,
3231 [ACTION_COUNT_SHARED] = {
3233 .help = "shared counter",
3234 .next = NEXT(action_count, NEXT_ENTRY(BOOLEAN)),
3235 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_count,
3237 .call = parse_vc_conf,
3241 .help = "spread packets among several queues",
3242 .priv = PRIV_ACTION(RSS, sizeof(struct action_rss_data)),
3243 .next = NEXT(action_rss),
3244 .call = parse_vc_action_rss,
3246 [ACTION_RSS_FUNC] = {
3248 .help = "RSS hash function to apply",
3249 .next = NEXT(action_rss,
3250 NEXT_ENTRY(ACTION_RSS_FUNC_DEFAULT,
3251 ACTION_RSS_FUNC_TOEPLITZ,
3252 ACTION_RSS_FUNC_SIMPLE_XOR,
3253 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ)),
3255 [ACTION_RSS_FUNC_DEFAULT] = {
3257 .help = "default hash function",
3258 .call = parse_vc_action_rss_func,
3260 [ACTION_RSS_FUNC_TOEPLITZ] = {
3262 .help = "Toeplitz hash function",
3263 .call = parse_vc_action_rss_func,
3265 [ACTION_RSS_FUNC_SIMPLE_XOR] = {
3266 .name = "simple_xor",
3267 .help = "simple XOR hash function",
3268 .call = parse_vc_action_rss_func,
3270 [ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ] = {
3271 .name = "symmetric_toeplitz",
3272 .help = "Symmetric Toeplitz hash function",
3273 .call = parse_vc_action_rss_func,
3275 [ACTION_RSS_LEVEL] = {
3277 .help = "encapsulation level for \"types\"",
3278 .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
3279 .args = ARGS(ARGS_ENTRY_ARB
3280 (offsetof(struct action_rss_data, conf) +
3281 offsetof(struct rte_flow_action_rss, level),
3282 sizeof(((struct rte_flow_action_rss *)0)->
3285 [ACTION_RSS_TYPES] = {
3287 .help = "specific RSS hash types",
3288 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)),
3290 [ACTION_RSS_TYPE] = {
3292 .help = "RSS hash type",
3293 .call = parse_vc_action_rss_type,
3294 .comp = comp_vc_action_rss_type,
3296 [ACTION_RSS_KEY] = {
3298 .help = "RSS hash key",
3299 .next = NEXT(action_rss, NEXT_ENTRY(HEX)),
3300 .args = ARGS(ARGS_ENTRY_ARB(0, 0),
3302 (offsetof(struct action_rss_data, conf) +
3303 offsetof(struct rte_flow_action_rss, key_len),
3304 sizeof(((struct rte_flow_action_rss *)0)->
3306 ARGS_ENTRY(struct action_rss_data, key)),
3308 [ACTION_RSS_KEY_LEN] = {
3310 .help = "RSS hash key length in bytes",
3311 .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
3312 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
3313 (offsetof(struct action_rss_data, conf) +
3314 offsetof(struct rte_flow_action_rss, key_len),
3315 sizeof(((struct rte_flow_action_rss *)0)->
3318 RSS_HASH_KEY_LENGTH)),
3320 [ACTION_RSS_QUEUES] = {
3322 .help = "queue indices to use",
3323 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_QUEUE)),
3324 .call = parse_vc_conf,
3326 [ACTION_RSS_QUEUE] = {
3328 .help = "queue index",
3329 .call = parse_vc_action_rss_queue,
3330 .comp = comp_vc_action_rss_queue,
3334 .help = "direct traffic to physical function",
3335 .priv = PRIV_ACTION(PF, 0),
3336 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3341 .help = "direct traffic to a virtual function ID",
3342 .priv = PRIV_ACTION(VF, sizeof(struct rte_flow_action_vf)),
3343 .next = NEXT(action_vf),
3346 [ACTION_VF_ORIGINAL] = {
3348 .help = "use original VF ID if possible",
3349 .next = NEXT(action_vf, NEXT_ENTRY(BOOLEAN)),
3350 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_vf,
3352 .call = parse_vc_conf,
3357 .next = NEXT(action_vf, NEXT_ENTRY(UNSIGNED)),
3358 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)),
3359 .call = parse_vc_conf,
3361 [ACTION_PHY_PORT] = {
3363 .help = "direct packets to physical port index",
3364 .priv = PRIV_ACTION(PHY_PORT,
3365 sizeof(struct rte_flow_action_phy_port)),
3366 .next = NEXT(action_phy_port),
3369 [ACTION_PHY_PORT_ORIGINAL] = {
3371 .help = "use original port index if possible",
3372 .next = NEXT(action_phy_port, NEXT_ENTRY(BOOLEAN)),
3373 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_phy_port,
3375 .call = parse_vc_conf,
3377 [ACTION_PHY_PORT_INDEX] = {
3379 .help = "physical port index",
3380 .next = NEXT(action_phy_port, NEXT_ENTRY(UNSIGNED)),
3381 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_phy_port,
3383 .call = parse_vc_conf,
3385 [ACTION_PORT_ID] = {
3387 .help = "direct matching traffic to a given DPDK port ID",
3388 .priv = PRIV_ACTION(PORT_ID,
3389 sizeof(struct rte_flow_action_port_id)),
3390 .next = NEXT(action_port_id),
3393 [ACTION_PORT_ID_ORIGINAL] = {
3395 .help = "use original DPDK port ID if possible",
3396 .next = NEXT(action_port_id, NEXT_ENTRY(BOOLEAN)),
3397 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_port_id,
3399 .call = parse_vc_conf,
3401 [ACTION_PORT_ID_ID] = {
3403 .help = "DPDK port ID",
3404 .next = NEXT(action_port_id, NEXT_ENTRY(UNSIGNED)),
3405 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_port_id, id)),
3406 .call = parse_vc_conf,
3410 .help = "meter the directed packets at given id",
3411 .priv = PRIV_ACTION(METER,
3412 sizeof(struct rte_flow_action_meter)),
3413 .next = NEXT(action_meter),
3416 [ACTION_METER_ID] = {
3418 .help = "meter id to use",
3419 .next = NEXT(action_meter, NEXT_ENTRY(UNSIGNED)),
3420 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter, mtr_id)),
3421 .call = parse_vc_conf,
3423 [ACTION_OF_SET_MPLS_TTL] = {
3424 .name = "of_set_mpls_ttl",
3425 .help = "OpenFlow's OFPAT_SET_MPLS_TTL",
3428 sizeof(struct rte_flow_action_of_set_mpls_ttl)),
3429 .next = NEXT(action_of_set_mpls_ttl),
3432 [ACTION_OF_SET_MPLS_TTL_MPLS_TTL] = {
3435 .next = NEXT(action_of_set_mpls_ttl, NEXT_ENTRY(UNSIGNED)),
3436 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_mpls_ttl,
3438 .call = parse_vc_conf,
3440 [ACTION_OF_DEC_MPLS_TTL] = {
3441 .name = "of_dec_mpls_ttl",
3442 .help = "OpenFlow's OFPAT_DEC_MPLS_TTL",
3443 .priv = PRIV_ACTION(OF_DEC_MPLS_TTL, 0),
3444 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3447 [ACTION_OF_SET_NW_TTL] = {
3448 .name = "of_set_nw_ttl",
3449 .help = "OpenFlow's OFPAT_SET_NW_TTL",
3452 sizeof(struct rte_flow_action_of_set_nw_ttl)),
3453 .next = NEXT(action_of_set_nw_ttl),
3456 [ACTION_OF_SET_NW_TTL_NW_TTL] = {
3459 .next = NEXT(action_of_set_nw_ttl, NEXT_ENTRY(UNSIGNED)),
3460 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_nw_ttl,
3462 .call = parse_vc_conf,
3464 [ACTION_OF_DEC_NW_TTL] = {
3465 .name = "of_dec_nw_ttl",
3466 .help = "OpenFlow's OFPAT_DEC_NW_TTL",
3467 .priv = PRIV_ACTION(OF_DEC_NW_TTL, 0),
3468 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3471 [ACTION_OF_COPY_TTL_OUT] = {
3472 .name = "of_copy_ttl_out",
3473 .help = "OpenFlow's OFPAT_COPY_TTL_OUT",
3474 .priv = PRIV_ACTION(OF_COPY_TTL_OUT, 0),
3475 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3478 [ACTION_OF_COPY_TTL_IN] = {
3479 .name = "of_copy_ttl_in",
3480 .help = "OpenFlow's OFPAT_COPY_TTL_IN",
3481 .priv = PRIV_ACTION(OF_COPY_TTL_IN, 0),
3482 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3485 [ACTION_OF_POP_VLAN] = {
3486 .name = "of_pop_vlan",
3487 .help = "OpenFlow's OFPAT_POP_VLAN",
3488 .priv = PRIV_ACTION(OF_POP_VLAN, 0),
3489 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3492 [ACTION_OF_PUSH_VLAN] = {
3493 .name = "of_push_vlan",
3494 .help = "OpenFlow's OFPAT_PUSH_VLAN",
3497 sizeof(struct rte_flow_action_of_push_vlan)),
3498 .next = NEXT(action_of_push_vlan),
3501 [ACTION_OF_PUSH_VLAN_ETHERTYPE] = {
3502 .name = "ethertype",
3503 .help = "EtherType",
3504 .next = NEXT(action_of_push_vlan, NEXT_ENTRY(UNSIGNED)),
3505 .args = ARGS(ARGS_ENTRY_HTON
3506 (struct rte_flow_action_of_push_vlan,
3508 .call = parse_vc_conf,
3510 [ACTION_OF_SET_VLAN_VID] = {
3511 .name = "of_set_vlan_vid",
3512 .help = "OpenFlow's OFPAT_SET_VLAN_VID",
3515 sizeof(struct rte_flow_action_of_set_vlan_vid)),
3516 .next = NEXT(action_of_set_vlan_vid),
3519 [ACTION_OF_SET_VLAN_VID_VLAN_VID] = {
3522 .next = NEXT(action_of_set_vlan_vid, NEXT_ENTRY(UNSIGNED)),
3523 .args = ARGS(ARGS_ENTRY_HTON
3524 (struct rte_flow_action_of_set_vlan_vid,
3526 .call = parse_vc_conf,
3528 [ACTION_OF_SET_VLAN_PCP] = {
3529 .name = "of_set_vlan_pcp",
3530 .help = "OpenFlow's OFPAT_SET_VLAN_PCP",
3533 sizeof(struct rte_flow_action_of_set_vlan_pcp)),
3534 .next = NEXT(action_of_set_vlan_pcp),
3537 [ACTION_OF_SET_VLAN_PCP_VLAN_PCP] = {
3539 .help = "VLAN priority",
3540 .next = NEXT(action_of_set_vlan_pcp, NEXT_ENTRY(UNSIGNED)),
3541 .args = ARGS(ARGS_ENTRY_HTON
3542 (struct rte_flow_action_of_set_vlan_pcp,
3544 .call = parse_vc_conf,
3546 [ACTION_OF_POP_MPLS] = {
3547 .name = "of_pop_mpls",
3548 .help = "OpenFlow's OFPAT_POP_MPLS",
3549 .priv = PRIV_ACTION(OF_POP_MPLS,
3550 sizeof(struct rte_flow_action_of_pop_mpls)),
3551 .next = NEXT(action_of_pop_mpls),
3554 [ACTION_OF_POP_MPLS_ETHERTYPE] = {
3555 .name = "ethertype",
3556 .help = "EtherType",
3557 .next = NEXT(action_of_pop_mpls, NEXT_ENTRY(UNSIGNED)),
3558 .args = ARGS(ARGS_ENTRY_HTON
3559 (struct rte_flow_action_of_pop_mpls,
3561 .call = parse_vc_conf,
3563 [ACTION_OF_PUSH_MPLS] = {
3564 .name = "of_push_mpls",
3565 .help = "OpenFlow's OFPAT_PUSH_MPLS",
3568 sizeof(struct rte_flow_action_of_push_mpls)),
3569 .next = NEXT(action_of_push_mpls),
3572 [ACTION_OF_PUSH_MPLS_ETHERTYPE] = {
3573 .name = "ethertype",
3574 .help = "EtherType",
3575 .next = NEXT(action_of_push_mpls, NEXT_ENTRY(UNSIGNED)),
3576 .args = ARGS(ARGS_ENTRY_HTON
3577 (struct rte_flow_action_of_push_mpls,
3579 .call = parse_vc_conf,
3581 [ACTION_VXLAN_ENCAP] = {
3582 .name = "vxlan_encap",
3583 .help = "VXLAN encapsulation, uses configuration set by \"set"
3585 .priv = PRIV_ACTION(VXLAN_ENCAP,
3586 sizeof(struct action_vxlan_encap_data)),
3587 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3588 .call = parse_vc_action_vxlan_encap,
3590 [ACTION_VXLAN_DECAP] = {
3591 .name = "vxlan_decap",
3592 .help = "Performs a decapsulation action by stripping all"
3593 " headers of the VXLAN tunnel network overlay from the"
3595 .priv = PRIV_ACTION(VXLAN_DECAP, 0),
3596 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3599 [ACTION_NVGRE_ENCAP] = {
3600 .name = "nvgre_encap",
3601 .help = "NVGRE encapsulation, uses configuration set by \"set"
3603 .priv = PRIV_ACTION(NVGRE_ENCAP,
3604 sizeof(struct action_nvgre_encap_data)),
3605 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3606 .call = parse_vc_action_nvgre_encap,
3608 [ACTION_NVGRE_DECAP] = {
3609 .name = "nvgre_decap",
3610 .help = "Performs a decapsulation action by stripping all"
3611 " headers of the NVGRE tunnel network overlay from the"
3613 .priv = PRIV_ACTION(NVGRE_DECAP, 0),
3614 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3617 [ACTION_L2_ENCAP] = {
3619 .help = "l2 encap, uses configuration set by"
3620 " \"set l2_encap\"",
3621 .priv = PRIV_ACTION(RAW_ENCAP,
3622 sizeof(struct action_raw_encap_data)),
3623 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3624 .call = parse_vc_action_l2_encap,
3626 [ACTION_L2_DECAP] = {
3628 .help = "l2 decap, uses configuration set by"
3629 " \"set l2_decap\"",
3630 .priv = PRIV_ACTION(RAW_DECAP,
3631 sizeof(struct action_raw_decap_data)),
3632 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3633 .call = parse_vc_action_l2_decap,
3635 [ACTION_MPLSOGRE_ENCAP] = {
3636 .name = "mplsogre_encap",
3637 .help = "mplsogre encapsulation, uses configuration set by"
3638 " \"set mplsogre_encap\"",
3639 .priv = PRIV_ACTION(RAW_ENCAP,
3640 sizeof(struct action_raw_encap_data)),
3641 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3642 .call = parse_vc_action_mplsogre_encap,
3644 [ACTION_MPLSOGRE_DECAP] = {
3645 .name = "mplsogre_decap",
3646 .help = "mplsogre decapsulation, uses configuration set by"
3647 " \"set mplsogre_decap\"",
3648 .priv = PRIV_ACTION(RAW_DECAP,
3649 sizeof(struct action_raw_decap_data)),
3650 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3651 .call = parse_vc_action_mplsogre_decap,
3653 [ACTION_MPLSOUDP_ENCAP] = {
3654 .name = "mplsoudp_encap",
3655 .help = "mplsoudp encapsulation, uses configuration set by"
3656 " \"set mplsoudp_encap\"",
3657 .priv = PRIV_ACTION(RAW_ENCAP,
3658 sizeof(struct action_raw_encap_data)),
3659 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3660 .call = parse_vc_action_mplsoudp_encap,
3662 [ACTION_MPLSOUDP_DECAP] = {
3663 .name = "mplsoudp_decap",
3664 .help = "mplsoudp decapsulation, uses configuration set by"
3665 " \"set mplsoudp_decap\"",
3666 .priv = PRIV_ACTION(RAW_DECAP,
3667 sizeof(struct action_raw_decap_data)),
3668 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3669 .call = parse_vc_action_mplsoudp_decap,
3671 [ACTION_SET_IPV4_SRC] = {
3672 .name = "set_ipv4_src",
3673 .help = "Set a new IPv4 source address in the outermost"
3675 .priv = PRIV_ACTION(SET_IPV4_SRC,
3676 sizeof(struct rte_flow_action_set_ipv4)),
3677 .next = NEXT(action_set_ipv4_src),
3680 [ACTION_SET_IPV4_SRC_IPV4_SRC] = {
3681 .name = "ipv4_addr",
3682 .help = "new IPv4 source address to set",
3683 .next = NEXT(action_set_ipv4_src, NEXT_ENTRY(IPV4_ADDR)),
3684 .args = ARGS(ARGS_ENTRY_HTON
3685 (struct rte_flow_action_set_ipv4, ipv4_addr)),
3686 .call = parse_vc_conf,
3688 [ACTION_SET_IPV4_DST] = {
3689 .name = "set_ipv4_dst",
3690 .help = "Set a new IPv4 destination address in the outermost"
3692 .priv = PRIV_ACTION(SET_IPV4_DST,
3693 sizeof(struct rte_flow_action_set_ipv4)),
3694 .next = NEXT(action_set_ipv4_dst),
3697 [ACTION_SET_IPV4_DST_IPV4_DST] = {
3698 .name = "ipv4_addr",
3699 .help = "new IPv4 destination address to set",
3700 .next = NEXT(action_set_ipv4_dst, NEXT_ENTRY(IPV4_ADDR)),
3701 .args = ARGS(ARGS_ENTRY_HTON
3702 (struct rte_flow_action_set_ipv4, ipv4_addr)),
3703 .call = parse_vc_conf,
3705 [ACTION_SET_IPV6_SRC] = {
3706 .name = "set_ipv6_src",
3707 .help = "Set a new IPv6 source address in the outermost"
3709 .priv = PRIV_ACTION(SET_IPV6_SRC,
3710 sizeof(struct rte_flow_action_set_ipv6)),
3711 .next = NEXT(action_set_ipv6_src),
3714 [ACTION_SET_IPV6_SRC_IPV6_SRC] = {
3715 .name = "ipv6_addr",
3716 .help = "new IPv6 source address to set",
3717 .next = NEXT(action_set_ipv6_src, NEXT_ENTRY(IPV6_ADDR)),
3718 .args = ARGS(ARGS_ENTRY_HTON
3719 (struct rte_flow_action_set_ipv6, ipv6_addr)),
3720 .call = parse_vc_conf,
3722 [ACTION_SET_IPV6_DST] = {
3723 .name = "set_ipv6_dst",
3724 .help = "Set a new IPv6 destination address in the outermost"
3726 .priv = PRIV_ACTION(SET_IPV6_DST,
3727 sizeof(struct rte_flow_action_set_ipv6)),
3728 .next = NEXT(action_set_ipv6_dst),
3731 [ACTION_SET_IPV6_DST_IPV6_DST] = {
3732 .name = "ipv6_addr",
3733 .help = "new IPv6 destination address to set",
3734 .next = NEXT(action_set_ipv6_dst, NEXT_ENTRY(IPV6_ADDR)),
3735 .args = ARGS(ARGS_ENTRY_HTON
3736 (struct rte_flow_action_set_ipv6, ipv6_addr)),
3737 .call = parse_vc_conf,
3739 [ACTION_SET_TP_SRC] = {
3740 .name = "set_tp_src",
3741 .help = "set a new source port number in the outermost"
3743 .priv = PRIV_ACTION(SET_TP_SRC,
3744 sizeof(struct rte_flow_action_set_tp)),
3745 .next = NEXT(action_set_tp_src),
3748 [ACTION_SET_TP_SRC_TP_SRC] = {
3750 .help = "new source port number to set",
3751 .next = NEXT(action_set_tp_src, NEXT_ENTRY(UNSIGNED)),
3752 .args = ARGS(ARGS_ENTRY_HTON
3753 (struct rte_flow_action_set_tp, port)),
3754 .call = parse_vc_conf,
3756 [ACTION_SET_TP_DST] = {
3757 .name = "set_tp_dst",
3758 .help = "set a new destination port number in the outermost"
3760 .priv = PRIV_ACTION(SET_TP_DST,
3761 sizeof(struct rte_flow_action_set_tp)),
3762 .next = NEXT(action_set_tp_dst),
3765 [ACTION_SET_TP_DST_TP_DST] = {
3767 .help = "new destination port number to set",
3768 .next = NEXT(action_set_tp_dst, NEXT_ENTRY(UNSIGNED)),
3769 .args = ARGS(ARGS_ENTRY_HTON
3770 (struct rte_flow_action_set_tp, port)),
3771 .call = parse_vc_conf,
3773 [ACTION_MAC_SWAP] = {
3775 .help = "Swap the source and destination MAC addresses"
3776 " in the outermost Ethernet header",
3777 .priv = PRIV_ACTION(MAC_SWAP, 0),
3778 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3781 [ACTION_DEC_TTL] = {
3783 .help = "decrease network TTL if available",
3784 .priv = PRIV_ACTION(DEC_TTL, 0),
3785 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3788 [ACTION_SET_TTL] = {
3790 .help = "set ttl value",
3791 .priv = PRIV_ACTION(SET_TTL,
3792 sizeof(struct rte_flow_action_set_ttl)),
3793 .next = NEXT(action_set_ttl),
3796 [ACTION_SET_TTL_TTL] = {
3797 .name = "ttl_value",
3798 .help = "new ttl value to set",
3799 .next = NEXT(action_set_ttl, NEXT_ENTRY(UNSIGNED)),
3800 .args = ARGS(ARGS_ENTRY_HTON
3801 (struct rte_flow_action_set_ttl, ttl_value)),
3802 .call = parse_vc_conf,
3804 [ACTION_SET_MAC_SRC] = {
3805 .name = "set_mac_src",
3806 .help = "set source mac address",
3807 .priv = PRIV_ACTION(SET_MAC_SRC,
3808 sizeof(struct rte_flow_action_set_mac)),
3809 .next = NEXT(action_set_mac_src),
3812 [ACTION_SET_MAC_SRC_MAC_SRC] = {
3814 .help = "new source mac address",
3815 .next = NEXT(action_set_mac_src, NEXT_ENTRY(MAC_ADDR)),
3816 .args = ARGS(ARGS_ENTRY_HTON
3817 (struct rte_flow_action_set_mac, mac_addr)),
3818 .call = parse_vc_conf,
3820 [ACTION_SET_MAC_DST] = {
3821 .name = "set_mac_dst",
3822 .help = "set destination mac address",
3823 .priv = PRIV_ACTION(SET_MAC_DST,
3824 sizeof(struct rte_flow_action_set_mac)),
3825 .next = NEXT(action_set_mac_dst),
3828 [ACTION_SET_MAC_DST_MAC_DST] = {
3830 .help = "new destination mac address to set",
3831 .next = NEXT(action_set_mac_dst, NEXT_ENTRY(MAC_ADDR)),
3832 .args = ARGS(ARGS_ENTRY_HTON
3833 (struct rte_flow_action_set_mac, mac_addr)),
3834 .call = parse_vc_conf,
3836 [ACTION_INC_TCP_SEQ] = {
3837 .name = "inc_tcp_seq",
3838 .help = "increase TCP sequence number",
3839 .priv = PRIV_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
3840 .next = NEXT(action_inc_tcp_seq),
3843 [ACTION_INC_TCP_SEQ_VALUE] = {
3845 .help = "the value to increase TCP sequence number by",
3846 .next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(UNSIGNED)),
3847 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3848 .call = parse_vc_conf,
3850 [ACTION_DEC_TCP_SEQ] = {
3851 .name = "dec_tcp_seq",
3852 .help = "decrease TCP sequence number",
3853 .priv = PRIV_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
3854 .next = NEXT(action_dec_tcp_seq),
3857 [ACTION_DEC_TCP_SEQ_VALUE] = {
3859 .help = "the value to decrease TCP sequence number by",
3860 .next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(UNSIGNED)),
3861 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3862 .call = parse_vc_conf,
3864 [ACTION_INC_TCP_ACK] = {
3865 .name = "inc_tcp_ack",
3866 .help = "increase TCP acknowledgment number",
3867 .priv = PRIV_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
3868 .next = NEXT(action_inc_tcp_ack),
3871 [ACTION_INC_TCP_ACK_VALUE] = {
3873 .help = "the value to increase TCP acknowledgment number by",
3874 .next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(UNSIGNED)),
3875 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3876 .call = parse_vc_conf,
3878 [ACTION_DEC_TCP_ACK] = {
3879 .name = "dec_tcp_ack",
3880 .help = "decrease TCP acknowledgment number",
3881 .priv = PRIV_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
3882 .next = NEXT(action_dec_tcp_ack),
3885 [ACTION_DEC_TCP_ACK_VALUE] = {
3887 .help = "the value to decrease TCP acknowledgment number by",
3888 .next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(UNSIGNED)),
3889 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3890 .call = parse_vc_conf,
3892 [ACTION_RAW_ENCAP] = {
3893 .name = "raw_encap",
3894 .help = "encapsulation data, defined by set raw_encap",
3895 .priv = PRIV_ACTION(RAW_ENCAP,
3896 sizeof(struct action_raw_encap_data)),
3897 .next = NEXT(action_raw_encap),
3898 .call = parse_vc_action_raw_encap,
3900 [ACTION_RAW_ENCAP_INDEX] = {
3902 .help = "the index of raw_encap_confs",
3903 .next = NEXT(NEXT_ENTRY(ACTION_RAW_ENCAP_INDEX_VALUE)),
3905 [ACTION_RAW_ENCAP_INDEX_VALUE] = {
3908 .help = "unsigned integer value",
3909 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3910 .call = parse_vc_action_raw_encap_index,
3911 .comp = comp_set_raw_index,
3913 [ACTION_RAW_DECAP] = {
3914 .name = "raw_decap",
3915 .help = "decapsulation data, defined by set raw_encap",
3916 .priv = PRIV_ACTION(RAW_DECAP,
3917 sizeof(struct action_raw_decap_data)),
3918 .next = NEXT(action_raw_decap),
3919 .call = parse_vc_action_raw_decap,
3921 [ACTION_RAW_DECAP_INDEX] = {
3923 .help = "the index of raw_encap_confs",
3924 .next = NEXT(NEXT_ENTRY(ACTION_RAW_DECAP_INDEX_VALUE)),
3926 [ACTION_RAW_DECAP_INDEX_VALUE] = {
3929 .help = "unsigned integer value",
3930 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3931 .call = parse_vc_action_raw_decap_index,
3932 .comp = comp_set_raw_index,
3934 /* Top level command. */
3937 .help = "set raw encap/decap/sample data",
3938 .type = "set raw_encap|raw_decap <index> <pattern>"
3939 " or set sample_actions <index> <action>",
3940 .next = NEXT(NEXT_ENTRY
3943 SET_SAMPLE_ACTIONS)),
3944 .call = parse_set_init,
3946 /* Sub-level commands. */
3948 .name = "raw_encap",
3949 .help = "set raw encap data",
3950 .next = NEXT(next_set_raw),
3951 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
3952 (offsetof(struct buffer, port),
3953 sizeof(((struct buffer *)0)->port),
3954 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
3955 .call = parse_set_raw_encap_decap,
3958 .name = "raw_decap",
3959 .help = "set raw decap data",
3960 .next = NEXT(next_set_raw),
3961 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
3962 (offsetof(struct buffer, port),
3963 sizeof(((struct buffer *)0)->port),
3964 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
3965 .call = parse_set_raw_encap_decap,
3970 .help = "index of raw_encap/raw_decap data",
3971 .next = NEXT(next_item),
3974 [SET_SAMPLE_INDEX] = {
3977 .help = "index of sample actions",
3978 .next = NEXT(next_action_sample),
3981 [SET_SAMPLE_ACTIONS] = {
3982 .name = "sample_actions",
3983 .help = "set sample actions list",
3984 .next = NEXT(NEXT_ENTRY(SET_SAMPLE_INDEX)),
3985 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
3986 (offsetof(struct buffer, port),
3987 sizeof(((struct buffer *)0)->port),
3988 0, RAW_SAMPLE_CONFS_MAX_NUM - 1)),
3989 .call = parse_set_sample_action,
3991 [ACTION_SET_TAG] = {
3994 .priv = PRIV_ACTION(SET_TAG,
3995 sizeof(struct rte_flow_action_set_tag)),
3996 .next = NEXT(action_set_tag),
3999 [ACTION_SET_TAG_INDEX] = {
4001 .help = "index of tag array",
4002 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
4003 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_set_tag, index)),
4004 .call = parse_vc_conf,
4006 [ACTION_SET_TAG_DATA] = {
4008 .help = "tag value",
4009 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
4010 .args = ARGS(ARGS_ENTRY
4011 (struct rte_flow_action_set_tag, data)),
4012 .call = parse_vc_conf,
4014 [ACTION_SET_TAG_MASK] = {
4016 .help = "mask for tag value",
4017 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
4018 .args = ARGS(ARGS_ENTRY
4019 (struct rte_flow_action_set_tag, mask)),
4020 .call = parse_vc_conf,
4022 [ACTION_SET_META] = {
4024 .help = "set metadata",
4025 .priv = PRIV_ACTION(SET_META,
4026 sizeof(struct rte_flow_action_set_meta)),
4027 .next = NEXT(action_set_meta),
4028 .call = parse_vc_action_set_meta,
4030 [ACTION_SET_META_DATA] = {
4032 .help = "metadata value",
4033 .next = NEXT(action_set_meta, NEXT_ENTRY(UNSIGNED)),
4034 .args = ARGS(ARGS_ENTRY
4035 (struct rte_flow_action_set_meta, data)),
4036 .call = parse_vc_conf,
4038 [ACTION_SET_META_MASK] = {
4040 .help = "mask for metadata value",
4041 .next = NEXT(action_set_meta, NEXT_ENTRY(UNSIGNED)),
4042 .args = ARGS(ARGS_ENTRY
4043 (struct rte_flow_action_set_meta, mask)),
4044 .call = parse_vc_conf,
4046 [ACTION_SET_IPV4_DSCP] = {
4047 .name = "set_ipv4_dscp",
4048 .help = "set DSCP value",
4049 .priv = PRIV_ACTION(SET_IPV4_DSCP,
4050 sizeof(struct rte_flow_action_set_dscp)),
4051 .next = NEXT(action_set_ipv4_dscp),
4054 [ACTION_SET_IPV4_DSCP_VALUE] = {
4055 .name = "dscp_value",
4056 .help = "new IPv4 DSCP value to set",
4057 .next = NEXT(action_set_ipv4_dscp, NEXT_ENTRY(UNSIGNED)),
4058 .args = ARGS(ARGS_ENTRY
4059 (struct rte_flow_action_set_dscp, dscp)),
4060 .call = parse_vc_conf,
4062 [ACTION_SET_IPV6_DSCP] = {
4063 .name = "set_ipv6_dscp",
4064 .help = "set DSCP value",
4065 .priv = PRIV_ACTION(SET_IPV6_DSCP,
4066 sizeof(struct rte_flow_action_set_dscp)),
4067 .next = NEXT(action_set_ipv6_dscp),
4070 [ACTION_SET_IPV6_DSCP_VALUE] = {
4071 .name = "dscp_value",
4072 .help = "new IPv6 DSCP value to set",
4073 .next = NEXT(action_set_ipv6_dscp, NEXT_ENTRY(UNSIGNED)),
4074 .args = ARGS(ARGS_ENTRY
4075 (struct rte_flow_action_set_dscp, dscp)),
4076 .call = parse_vc_conf,
4080 .help = "set a specific metadata header",
4081 .next = NEXT(action_age),
4082 .priv = PRIV_ACTION(AGE,
4083 sizeof(struct rte_flow_action_age)),
4086 [ACTION_AGE_TIMEOUT] = {
4088 .help = "flow age timeout value",
4089 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_age,
4091 .next = NEXT(action_age, NEXT_ENTRY(UNSIGNED)),
4092 .call = parse_vc_conf,
4096 .help = "set a sample action",
4097 .next = NEXT(action_sample),
4098 .priv = PRIV_ACTION(SAMPLE,
4099 sizeof(struct action_sample_data)),
4100 .call = parse_vc_action_sample,
4102 [ACTION_SAMPLE_RATIO] = {
4104 .help = "flow sample ratio value",
4105 .next = NEXT(action_sample, NEXT_ENTRY(UNSIGNED)),
4106 .args = ARGS(ARGS_ENTRY_ARB
4107 (offsetof(struct action_sample_data, conf) +
4108 offsetof(struct rte_flow_action_sample, ratio),
4109 sizeof(((struct rte_flow_action_sample *)0)->
4112 [ACTION_SAMPLE_INDEX] = {
4114 .help = "the index of sample actions list",
4115 .next = NEXT(NEXT_ENTRY(ACTION_SAMPLE_INDEX_VALUE)),
4117 [ACTION_SAMPLE_INDEX_VALUE] = {
4120 .help = "unsigned integer value",
4121 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4122 .call = parse_vc_action_sample_index,
4123 .comp = comp_set_sample_index,
4125 /* Shared action destroy arguments. */
4126 [SHARED_ACTION_DESTROY_ID] = {
4127 .name = "action_id",
4128 .help = "specify a shared action id to destroy",
4129 .next = NEXT(next_sa_destroy_attr,
4130 NEXT_ENTRY(SHARED_ACTION_ID)),
4131 .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
4132 args.sa_destroy.action_id)),
4133 .call = parse_sa_destroy,
4135 /* Shared action create arguments. */
4136 [SHARED_ACTION_CREATE_ID] = {
4137 .name = "action_id",
4138 .help = "specify a shared action id to create",
4139 .next = NEXT(next_sa_create_attr,
4140 NEXT_ENTRY(SHARED_ACTION_ID)),
4141 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
4145 .help = "apply shared action by id",
4146 .priv = PRIV_ACTION(SHARED, 0),
4147 .next = NEXT(NEXT_ENTRY(SHARED_ACTION_ID2PTR)),
4148 .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
4151 [SHARED_ACTION_ID2PTR] = {
4152 .name = "{action_id}",
4153 .type = "SHARED_ACTION_ID",
4154 .help = "shared action id",
4155 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4156 .call = parse_sa_id2ptr,
4159 [SHARED_ACTION_INGRESS] = {
4161 .help = "affect rule to ingress",
4162 .next = NEXT(next_sa_create_attr),
4165 [SHARED_ACTION_EGRESS] = {
4167 .help = "affect rule to egress",
4168 .next = NEXT(next_sa_create_attr),
4171 [SHARED_ACTION_SPEC] = {
4173 .help = "specify action to share",
4174 .next = NEXT(next_action),
4178 /** Remove and return last entry from argument stack. */
4179 static const struct arg *
4180 pop_args(struct context *ctx)
4182 return ctx->args_num ? ctx->args[--ctx->args_num] : NULL;
4185 /** Add entry on top of the argument stack. */
4187 push_args(struct context *ctx, const struct arg *arg)
4189 if (ctx->args_num == CTX_STACK_SIZE)
4191 ctx->args[ctx->args_num++] = arg;
4195 /** Spread value into buffer according to bit-mask. */
4197 arg_entry_bf_fill(void *dst, uintmax_t val, const struct arg *arg)
4199 uint32_t i = arg->size;
4207 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
4216 unsigned int shift = 0;
4217 uint8_t *buf = (uint8_t *)dst + arg->offset + (i -= sub);
4219 for (shift = 0; arg->mask[i] >> shift; ++shift) {
4220 if (!(arg->mask[i] & (1 << shift)))
4225 *buf &= ~(1 << shift);
4226 *buf |= (val & 1) << shift;
4234 /** Compare a string with a partial one of a given length. */
4236 strcmp_partial(const char *full, const char *partial, size_t partial_len)
4238 int r = strncmp(full, partial, partial_len);
4242 if (strlen(full) <= partial_len)
4244 return full[partial_len];
4248 * Parse a prefix length and generate a bit-mask.
4250 * Last argument (ctx->args) is retrieved to determine mask size, storage
4251 * location and whether the result must use network byte ordering.
4254 parse_prefix(struct context *ctx, const struct token *token,
4255 const char *str, unsigned int len,
4256 void *buf, unsigned int size)
4258 const struct arg *arg = pop_args(ctx);
4259 static const uint8_t conv[] = "\x00\x80\xc0\xe0\xf0\xf8\xfc\xfe\xff";
4266 /* Argument is expected. */
4270 u = strtoumax(str, &end, 0);
4271 if (errno || (size_t)(end - str) != len)
4276 extra = arg_entry_bf_fill(NULL, 0, arg);
4285 if (!arg_entry_bf_fill(ctx->object, v, arg) ||
4286 !arg_entry_bf_fill(ctx->objmask, -1, arg))
4293 if (bytes > size || bytes + !!extra > size)
4297 buf = (uint8_t *)ctx->object + arg->offset;
4298 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
4300 memset((uint8_t *)buf + size - bytes, 0xff, bytes);
4301 memset(buf, 0x00, size - bytes);
4303 ((uint8_t *)buf)[size - bytes - 1] = conv[extra];
4307 memset(buf, 0xff, bytes);
4308 memset((uint8_t *)buf + bytes, 0x00, size - bytes);
4310 ((uint8_t *)buf)[bytes] = conv[extra];
4313 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
4316 push_args(ctx, arg);
4320 /** Default parsing function for token name matching. */
4322 parse_default(struct context *ctx, const struct token *token,
4323 const char *str, unsigned int len,
4324 void *buf, unsigned int size)
4329 if (strcmp_partial(token->name, str, len))
4334 /** Parse flow command, initialize output buffer for subsequent tokens. */
4336 parse_init(struct context *ctx, const struct token *token,
4337 const char *str, unsigned int len,
4338 void *buf, unsigned int size)
4340 struct buffer *out = buf;
4342 /* Token name must match. */
4343 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4345 /* Nothing else to do if there is no buffer. */
4348 /* Make sure buffer is large enough. */
4349 if (size < sizeof(*out))
4351 /* Initialize buffer. */
4352 memset(out, 0x00, sizeof(*out));
4353 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
4356 ctx->objmask = NULL;
4360 /** Parse tokens for shared action commands. */
4362 parse_sa(struct context *ctx, const struct token *token,
4363 const char *str, unsigned int len,
4364 void *buf, unsigned int size)
4366 struct buffer *out = buf;
4368 /* Token name must match. */
4369 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4371 /* Nothing else to do if there is no buffer. */
4374 if (!out->command) {
4375 if (ctx->curr != SHARED_ACTION)
4377 if (sizeof(*out) > size)
4379 out->command = ctx->curr;
4382 ctx->objmask = NULL;
4383 out->args.vc.data = (uint8_t *)out + size;
4386 switch (ctx->curr) {
4387 case SHARED_ACTION_CREATE:
4388 case SHARED_ACTION_UPDATE:
4389 out->args.vc.actions =
4390 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
4392 out->args.vc.attr.group = UINT32_MAX;
4394 case SHARED_ACTION_QUERY:
4395 out->command = ctx->curr;
4398 ctx->objmask = NULL;
4400 case SHARED_ACTION_EGRESS:
4401 out->args.vc.attr.egress = 1;
4403 case SHARED_ACTION_INGRESS:
4404 out->args.vc.attr.ingress = 1;
4412 /** Parse tokens for shared action destroy command. */
4414 parse_sa_destroy(struct context *ctx, const struct token *token,
4415 const char *str, unsigned int len,
4416 void *buf, unsigned int size)
4418 struct buffer *out = buf;
4419 uint32_t *action_id;
4421 /* Token name must match. */
4422 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4424 /* Nothing else to do if there is no buffer. */
4427 if (!out->command || out->command == SHARED_ACTION) {
4428 if (ctx->curr != SHARED_ACTION_DESTROY)
4430 if (sizeof(*out) > size)
4432 out->command = ctx->curr;
4435 ctx->objmask = NULL;
4436 out->args.sa_destroy.action_id =
4437 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
4441 action_id = out->args.sa_destroy.action_id
4442 + out->args.sa_destroy.action_id_n++;
4443 if ((uint8_t *)action_id > (uint8_t *)out + size)
4446 ctx->object = action_id;
4447 ctx->objmask = NULL;
4451 /** Parse tokens for validate/create commands. */
4453 parse_vc(struct context *ctx, const struct token *token,
4454 const char *str, unsigned int len,
4455 void *buf, unsigned int size)
4457 struct buffer *out = buf;
4461 /* Token name must match. */
4462 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4464 /* Nothing else to do if there is no buffer. */
4467 if (!out->command) {
4468 if (ctx->curr != VALIDATE && ctx->curr != CREATE)
4470 if (sizeof(*out) > size)
4472 out->command = ctx->curr;
4475 ctx->objmask = NULL;
4476 out->args.vc.data = (uint8_t *)out + size;
4480 ctx->object = &out->args.vc.attr;
4481 ctx->objmask = NULL;
4482 switch (ctx->curr) {
4487 out->args.vc.attr.ingress = 1;
4490 out->args.vc.attr.egress = 1;
4493 out->args.vc.attr.transfer = 1;
4496 out->args.vc.pattern =
4497 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
4499 ctx->object = out->args.vc.pattern;
4500 ctx->objmask = NULL;
4503 out->args.vc.actions =
4504 (void *)RTE_ALIGN_CEIL((uintptr_t)
4505 (out->args.vc.pattern +
4506 out->args.vc.pattern_n),
4508 ctx->object = out->args.vc.actions;
4509 ctx->objmask = NULL;
4516 if (!out->args.vc.actions) {
4517 const struct parse_item_priv *priv = token->priv;
4518 struct rte_flow_item *item =
4519 out->args.vc.pattern + out->args.vc.pattern_n;
4521 data_size = priv->size * 3; /* spec, last, mask */
4522 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
4523 (out->args.vc.data - data_size),
4525 if ((uint8_t *)item + sizeof(*item) > data)
4527 *item = (struct rte_flow_item){
4530 ++out->args.vc.pattern_n;
4532 ctx->objmask = NULL;
4534 const struct parse_action_priv *priv = token->priv;
4535 struct rte_flow_action *action =
4536 out->args.vc.actions + out->args.vc.actions_n;
4538 data_size = priv->size; /* configuration */
4539 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
4540 (out->args.vc.data - data_size),
4542 if ((uint8_t *)action + sizeof(*action) > data)
4544 *action = (struct rte_flow_action){
4546 .conf = data_size ? data : NULL,
4548 ++out->args.vc.actions_n;
4549 ctx->object = action;
4550 ctx->objmask = NULL;
4552 memset(data, 0, data_size);
4553 out->args.vc.data = data;
4554 ctx->objdata = data_size;
4558 /** Parse pattern item parameter type. */
4560 parse_vc_spec(struct context *ctx, const struct token *token,
4561 const char *str, unsigned int len,
4562 void *buf, unsigned int size)
4564 struct buffer *out = buf;
4565 struct rte_flow_item *item;
4571 /* Token name must match. */
4572 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4574 /* Parse parameter types. */
4575 switch (ctx->curr) {
4576 static const enum index prefix[] = NEXT_ENTRY(PREFIX);
4582 case ITEM_PARAM_SPEC:
4585 case ITEM_PARAM_LAST:
4588 case ITEM_PARAM_PREFIX:
4589 /* Modify next token to expect a prefix. */
4590 if (ctx->next_num < 2)
4592 ctx->next[ctx->next_num - 2] = prefix;
4594 case ITEM_PARAM_MASK:
4600 /* Nothing else to do if there is no buffer. */
4603 if (!out->args.vc.pattern_n)
4605 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
4606 data_size = ctx->objdata / 3; /* spec, last, mask */
4607 /* Point to selected object. */
4608 ctx->object = out->args.vc.data + (data_size * index);
4610 ctx->objmask = out->args.vc.data + (data_size * 2); /* mask */
4611 item->mask = ctx->objmask;
4613 ctx->objmask = NULL;
4614 /* Update relevant item pointer. */
4615 *((const void **[]){ &item->spec, &item->last, &item->mask })[index] =
4620 /** Parse action configuration field. */
4622 parse_vc_conf(struct context *ctx, const struct token *token,
4623 const char *str, unsigned int len,
4624 void *buf, unsigned int size)
4626 struct buffer *out = buf;
4629 /* Token name must match. */
4630 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4632 /* Nothing else to do if there is no buffer. */
4635 /* Point to selected object. */
4636 ctx->object = out->args.vc.data;
4637 ctx->objmask = NULL;
4641 /** Parse eCPRI common header type field. */
4643 parse_vc_item_ecpri_type(struct context *ctx, const struct token *token,
4644 const char *str, unsigned int len,
4645 void *buf, unsigned int size)
4647 struct rte_flow_item_ecpri *ecpri;
4648 struct rte_flow_item_ecpri *ecpri_mask;
4649 struct rte_flow_item *item;
4652 struct buffer *out = buf;
4653 const struct arg *arg;
4656 /* Token name must match. */
4657 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4659 switch (ctx->curr) {
4660 case ITEM_ECPRI_COMMON_TYPE_IQ_DATA:
4661 msg_type = RTE_ECPRI_MSG_TYPE_IQ_DATA;
4663 case ITEM_ECPRI_COMMON_TYPE_RTC_CTRL:
4664 msg_type = RTE_ECPRI_MSG_TYPE_RTC_CTRL;
4666 case ITEM_ECPRI_COMMON_TYPE_DLY_MSR:
4667 msg_type = RTE_ECPRI_MSG_TYPE_DLY_MSR;
4674 arg = pop_args(ctx);
4677 ecpri = (struct rte_flow_item_ecpri *)out->args.vc.data;
4678 ecpri->hdr.common.type = msg_type;
4679 data_size = ctx->objdata / 3; /* spec, last, mask */
4680 ecpri_mask = (struct rte_flow_item_ecpri *)(out->args.vc.data +
4682 ecpri_mask->hdr.common.type = 0xFF;
4684 ecpri->hdr.common.u32 = rte_cpu_to_be_32(ecpri->hdr.common.u32);
4685 ecpri_mask->hdr.common.u32 =
4686 rte_cpu_to_be_32(ecpri_mask->hdr.common.u32);
4688 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
4690 item->mask = ecpri_mask;
4694 /** Parse RSS action. */
4696 parse_vc_action_rss(struct context *ctx, const struct token *token,
4697 const char *str, unsigned int len,
4698 void *buf, unsigned int size)
4700 struct buffer *out = buf;
4701 struct rte_flow_action *action;
4702 struct action_rss_data *action_rss_data;
4706 ret = parse_vc(ctx, token, str, len, buf, size);
4709 /* Nothing else to do if there is no buffer. */
4712 if (!out->args.vc.actions_n)
4714 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4715 /* Point to selected object. */
4716 ctx->object = out->args.vc.data;
4717 ctx->objmask = NULL;
4718 /* Set up default configuration. */
4719 action_rss_data = ctx->object;
4720 *action_rss_data = (struct action_rss_data){
4721 .conf = (struct rte_flow_action_rss){
4722 .func = RTE_ETH_HASH_FUNCTION_DEFAULT,
4725 .key_len = sizeof(action_rss_data->key),
4726 .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM),
4727 .key = action_rss_data->key,
4728 .queue = action_rss_data->queue,
4730 .key = "testpmd's default RSS hash key, "
4731 "override it for better balancing",
4734 for (i = 0; i < action_rss_data->conf.queue_num; ++i)
4735 action_rss_data->queue[i] = i;
4736 if (!port_id_is_invalid(ctx->port, DISABLED_WARN) &&
4737 ctx->port != (portid_t)RTE_PORT_ALL) {
4738 struct rte_eth_dev_info info;
4741 ret2 = rte_eth_dev_info_get(ctx->port, &info);
4745 action_rss_data->conf.key_len =
4746 RTE_MIN(sizeof(action_rss_data->key),
4747 info.hash_key_size);
4749 action->conf = &action_rss_data->conf;
4754 * Parse func field for RSS action.
4756 * The RTE_ETH_HASH_FUNCTION_* value to assign is derived from the
4757 * ACTION_RSS_FUNC_* index that called this function.
4760 parse_vc_action_rss_func(struct context *ctx, const struct token *token,
4761 const char *str, unsigned int len,
4762 void *buf, unsigned int size)
4764 struct action_rss_data *action_rss_data;
4765 enum rte_eth_hash_function func;
4769 /* Token name must match. */
4770 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4772 switch (ctx->curr) {
4773 case ACTION_RSS_FUNC_DEFAULT:
4774 func = RTE_ETH_HASH_FUNCTION_DEFAULT;
4776 case ACTION_RSS_FUNC_TOEPLITZ:
4777 func = RTE_ETH_HASH_FUNCTION_TOEPLITZ;
4779 case ACTION_RSS_FUNC_SIMPLE_XOR:
4780 func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
4782 case ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ:
4783 func = RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
4790 action_rss_data = ctx->object;
4791 action_rss_data->conf.func = func;
4796 * Parse type field for RSS action.
4798 * Valid tokens are type field names and the "end" token.
4801 parse_vc_action_rss_type(struct context *ctx, const struct token *token,
4802 const char *str, unsigned int len,
4803 void *buf, unsigned int size)
4805 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE);
4806 struct action_rss_data *action_rss_data;
4812 if (ctx->curr != ACTION_RSS_TYPE)
4814 if (!(ctx->objdata >> 16) && ctx->object) {
4815 action_rss_data = ctx->object;
4816 action_rss_data->conf.types = 0;
4818 if (!strcmp_partial("end", str, len)) {
4819 ctx->objdata &= 0xffff;
4822 for (i = 0; rss_type_table[i].str; ++i)
4823 if (!strcmp_partial(rss_type_table[i].str, str, len))
4825 if (!rss_type_table[i].str)
4827 ctx->objdata = 1 << 16 | (ctx->objdata & 0xffff);
4829 if (ctx->next_num == RTE_DIM(ctx->next))
4831 ctx->next[ctx->next_num++] = next;
4834 action_rss_data = ctx->object;
4835 action_rss_data->conf.types |= rss_type_table[i].rss_type;
4840 * Parse queue field for RSS action.
4842 * Valid tokens are queue indices and the "end" token.
4845 parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
4846 const char *str, unsigned int len,
4847 void *buf, unsigned int size)
4849 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE);
4850 struct action_rss_data *action_rss_data;
4851 const struct arg *arg;
4858 if (ctx->curr != ACTION_RSS_QUEUE)
4860 i = ctx->objdata >> 16;
4861 if (!strcmp_partial("end", str, len)) {
4862 ctx->objdata &= 0xffff;
4865 if (i >= ACTION_RSS_QUEUE_NUM)
4867 arg = ARGS_ENTRY_ARB(offsetof(struct action_rss_data, queue) +
4868 i * sizeof(action_rss_data->queue[i]),
4869 sizeof(action_rss_data->queue[i]));
4870 if (push_args(ctx, arg))
4872 ret = parse_int(ctx, token, str, len, NULL, 0);
4878 ctx->objdata = i << 16 | (ctx->objdata & 0xffff);
4880 if (ctx->next_num == RTE_DIM(ctx->next))
4882 ctx->next[ctx->next_num++] = next;
4886 action_rss_data = ctx->object;
4887 action_rss_data->conf.queue_num = i;
4888 action_rss_data->conf.queue = i ? action_rss_data->queue : NULL;
4892 /** Parse VXLAN encap action. */
4894 parse_vc_action_vxlan_encap(struct context *ctx, const struct token *token,
4895 const char *str, unsigned int len,
4896 void *buf, unsigned int size)
4898 struct buffer *out = buf;
4899 struct rte_flow_action *action;
4900 struct action_vxlan_encap_data *action_vxlan_encap_data;
4903 ret = parse_vc(ctx, token, str, len, buf, size);
4906 /* Nothing else to do if there is no buffer. */
4909 if (!out->args.vc.actions_n)
4911 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4912 /* Point to selected object. */
4913 ctx->object = out->args.vc.data;
4914 ctx->objmask = NULL;
4915 /* Set up default configuration. */
4916 action_vxlan_encap_data = ctx->object;
4917 *action_vxlan_encap_data = (struct action_vxlan_encap_data){
4918 .conf = (struct rte_flow_action_vxlan_encap){
4919 .definition = action_vxlan_encap_data->items,
4923 .type = RTE_FLOW_ITEM_TYPE_ETH,
4924 .spec = &action_vxlan_encap_data->item_eth,
4925 .mask = &rte_flow_item_eth_mask,
4928 .type = RTE_FLOW_ITEM_TYPE_VLAN,
4929 .spec = &action_vxlan_encap_data->item_vlan,
4930 .mask = &rte_flow_item_vlan_mask,
4933 .type = RTE_FLOW_ITEM_TYPE_IPV4,
4934 .spec = &action_vxlan_encap_data->item_ipv4,
4935 .mask = &rte_flow_item_ipv4_mask,
4938 .type = RTE_FLOW_ITEM_TYPE_UDP,
4939 .spec = &action_vxlan_encap_data->item_udp,
4940 .mask = &rte_flow_item_udp_mask,
4943 .type = RTE_FLOW_ITEM_TYPE_VXLAN,
4944 .spec = &action_vxlan_encap_data->item_vxlan,
4945 .mask = &rte_flow_item_vxlan_mask,
4948 .type = RTE_FLOW_ITEM_TYPE_END,
4953 .tci = vxlan_encap_conf.vlan_tci,
4957 .src_addr = vxlan_encap_conf.ipv4_src,
4958 .dst_addr = vxlan_encap_conf.ipv4_dst,
4961 .src_port = vxlan_encap_conf.udp_src,
4962 .dst_port = vxlan_encap_conf.udp_dst,
4964 .item_vxlan.flags = 0,
4966 memcpy(action_vxlan_encap_data->item_eth.dst.addr_bytes,
4967 vxlan_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
4968 memcpy(action_vxlan_encap_data->item_eth.src.addr_bytes,
4969 vxlan_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
4970 if (!vxlan_encap_conf.select_ipv4) {
4971 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.src_addr,
4972 &vxlan_encap_conf.ipv6_src,
4973 sizeof(vxlan_encap_conf.ipv6_src));
4974 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.dst_addr,
4975 &vxlan_encap_conf.ipv6_dst,
4976 sizeof(vxlan_encap_conf.ipv6_dst));
4977 action_vxlan_encap_data->items[2] = (struct rte_flow_item){
4978 .type = RTE_FLOW_ITEM_TYPE_IPV6,
4979 .spec = &action_vxlan_encap_data->item_ipv6,
4980 .mask = &rte_flow_item_ipv6_mask,
4983 if (!vxlan_encap_conf.select_vlan)
4984 action_vxlan_encap_data->items[1].type =
4985 RTE_FLOW_ITEM_TYPE_VOID;
4986 if (vxlan_encap_conf.select_tos_ttl) {
4987 if (vxlan_encap_conf.select_ipv4) {
4988 static struct rte_flow_item_ipv4 ipv4_mask_tos;
4990 memcpy(&ipv4_mask_tos, &rte_flow_item_ipv4_mask,
4991 sizeof(ipv4_mask_tos));
4992 ipv4_mask_tos.hdr.type_of_service = 0xff;
4993 ipv4_mask_tos.hdr.time_to_live = 0xff;
4994 action_vxlan_encap_data->item_ipv4.hdr.type_of_service =
4995 vxlan_encap_conf.ip_tos;
4996 action_vxlan_encap_data->item_ipv4.hdr.time_to_live =
4997 vxlan_encap_conf.ip_ttl;
4998 action_vxlan_encap_data->items[2].mask =
5001 static struct rte_flow_item_ipv6 ipv6_mask_tos;
5003 memcpy(&ipv6_mask_tos, &rte_flow_item_ipv6_mask,
5004 sizeof(ipv6_mask_tos));
5005 ipv6_mask_tos.hdr.vtc_flow |=
5006 RTE_BE32(0xfful << RTE_IPV6_HDR_TC_SHIFT);
5007 ipv6_mask_tos.hdr.hop_limits = 0xff;
5008 action_vxlan_encap_data->item_ipv6.hdr.vtc_flow |=
5010 ((uint32_t)vxlan_encap_conf.ip_tos <<
5011 RTE_IPV6_HDR_TC_SHIFT);
5012 action_vxlan_encap_data->item_ipv6.hdr.hop_limits =
5013 vxlan_encap_conf.ip_ttl;
5014 action_vxlan_encap_data->items[2].mask =
5018 memcpy(action_vxlan_encap_data->item_vxlan.vni, vxlan_encap_conf.vni,
5019 RTE_DIM(vxlan_encap_conf.vni));
5020 action->conf = &action_vxlan_encap_data->conf;
5024 /** Parse NVGRE encap action. */
5026 parse_vc_action_nvgre_encap(struct context *ctx, const struct token *token,
5027 const char *str, unsigned int len,
5028 void *buf, unsigned int size)
5030 struct buffer *out = buf;
5031 struct rte_flow_action *action;
5032 struct action_nvgre_encap_data *action_nvgre_encap_data;
5035 ret = parse_vc(ctx, token, str, len, buf, size);
5038 /* Nothing else to do if there is no buffer. */
5041 if (!out->args.vc.actions_n)
5043 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5044 /* Point to selected object. */
5045 ctx->object = out->args.vc.data;
5046 ctx->objmask = NULL;
5047 /* Set up default configuration. */
5048 action_nvgre_encap_data = ctx->object;
5049 *action_nvgre_encap_data = (struct action_nvgre_encap_data){
5050 .conf = (struct rte_flow_action_nvgre_encap){
5051 .definition = action_nvgre_encap_data->items,
5055 .type = RTE_FLOW_ITEM_TYPE_ETH,
5056 .spec = &action_nvgre_encap_data->item_eth,
5057 .mask = &rte_flow_item_eth_mask,
5060 .type = RTE_FLOW_ITEM_TYPE_VLAN,
5061 .spec = &action_nvgre_encap_data->item_vlan,
5062 .mask = &rte_flow_item_vlan_mask,
5065 .type = RTE_FLOW_ITEM_TYPE_IPV4,
5066 .spec = &action_nvgre_encap_data->item_ipv4,
5067 .mask = &rte_flow_item_ipv4_mask,
5070 .type = RTE_FLOW_ITEM_TYPE_NVGRE,
5071 .spec = &action_nvgre_encap_data->item_nvgre,
5072 .mask = &rte_flow_item_nvgre_mask,
5075 .type = RTE_FLOW_ITEM_TYPE_END,
5080 .tci = nvgre_encap_conf.vlan_tci,
5084 .src_addr = nvgre_encap_conf.ipv4_src,
5085 .dst_addr = nvgre_encap_conf.ipv4_dst,
5087 .item_nvgre.flow_id = 0,
5089 memcpy(action_nvgre_encap_data->item_eth.dst.addr_bytes,
5090 nvgre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5091 memcpy(action_nvgre_encap_data->item_eth.src.addr_bytes,
5092 nvgre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5093 if (!nvgre_encap_conf.select_ipv4) {
5094 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.src_addr,
5095 &nvgre_encap_conf.ipv6_src,
5096 sizeof(nvgre_encap_conf.ipv6_src));
5097 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.dst_addr,
5098 &nvgre_encap_conf.ipv6_dst,
5099 sizeof(nvgre_encap_conf.ipv6_dst));
5100 action_nvgre_encap_data->items[2] = (struct rte_flow_item){
5101 .type = RTE_FLOW_ITEM_TYPE_IPV6,
5102 .spec = &action_nvgre_encap_data->item_ipv6,
5103 .mask = &rte_flow_item_ipv6_mask,
5106 if (!nvgre_encap_conf.select_vlan)
5107 action_nvgre_encap_data->items[1].type =
5108 RTE_FLOW_ITEM_TYPE_VOID;
5109 memcpy(action_nvgre_encap_data->item_nvgre.tni, nvgre_encap_conf.tni,
5110 RTE_DIM(nvgre_encap_conf.tni));
5111 action->conf = &action_nvgre_encap_data->conf;
5115 /** Parse l2 encap action. */
5117 parse_vc_action_l2_encap(struct context *ctx, const struct token *token,
5118 const char *str, unsigned int len,
5119 void *buf, unsigned int size)
5121 struct buffer *out = buf;
5122 struct rte_flow_action *action;
5123 struct action_raw_encap_data *action_encap_data;
5124 struct rte_flow_item_eth eth = { .type = 0, };
5125 struct rte_flow_item_vlan vlan = {
5126 .tci = mplsoudp_encap_conf.vlan_tci,
5132 ret = parse_vc(ctx, token, str, len, buf, size);
5135 /* Nothing else to do if there is no buffer. */
5138 if (!out->args.vc.actions_n)
5140 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5141 /* Point to selected object. */
5142 ctx->object = out->args.vc.data;
5143 ctx->objmask = NULL;
5144 /* Copy the headers to the buffer. */
5145 action_encap_data = ctx->object;
5146 *action_encap_data = (struct action_raw_encap_data) {
5147 .conf = (struct rte_flow_action_raw_encap){
5148 .data = action_encap_data->data,
5152 header = action_encap_data->data;
5153 if (l2_encap_conf.select_vlan)
5154 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5155 else if (l2_encap_conf.select_ipv4)
5156 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5158 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5159 memcpy(eth.dst.addr_bytes,
5160 l2_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5161 memcpy(eth.src.addr_bytes,
5162 l2_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5163 memcpy(header, ð, sizeof(eth));
5164 header += sizeof(eth);
5165 if (l2_encap_conf.select_vlan) {
5166 if (l2_encap_conf.select_ipv4)
5167 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5169 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5170 memcpy(header, &vlan, sizeof(vlan));
5171 header += sizeof(vlan);
5173 action_encap_data->conf.size = header -
5174 action_encap_data->data;
5175 action->conf = &action_encap_data->conf;
5179 /** Parse l2 decap action. */
5181 parse_vc_action_l2_decap(struct context *ctx, const struct token *token,
5182 const char *str, unsigned int len,
5183 void *buf, unsigned int size)
5185 struct buffer *out = buf;
5186 struct rte_flow_action *action;
5187 struct action_raw_decap_data *action_decap_data;
5188 struct rte_flow_item_eth eth = { .type = 0, };
5189 struct rte_flow_item_vlan vlan = {
5190 .tci = mplsoudp_encap_conf.vlan_tci,
5196 ret = parse_vc(ctx, token, str, len, buf, size);
5199 /* Nothing else to do if there is no buffer. */
5202 if (!out->args.vc.actions_n)
5204 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5205 /* Point to selected object. */
5206 ctx->object = out->args.vc.data;
5207 ctx->objmask = NULL;
5208 /* Copy the headers to the buffer. */
5209 action_decap_data = ctx->object;
5210 *action_decap_data = (struct action_raw_decap_data) {
5211 .conf = (struct rte_flow_action_raw_decap){
5212 .data = action_decap_data->data,
5216 header = action_decap_data->data;
5217 if (l2_decap_conf.select_vlan)
5218 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5219 memcpy(header, ð, sizeof(eth));
5220 header += sizeof(eth);
5221 if (l2_decap_conf.select_vlan) {
5222 memcpy(header, &vlan, sizeof(vlan));
5223 header += sizeof(vlan);
5225 action_decap_data->conf.size = header -
5226 action_decap_data->data;
5227 action->conf = &action_decap_data->conf;
5231 #define ETHER_TYPE_MPLS_UNICAST 0x8847
5233 /** Parse MPLSOGRE encap action. */
5235 parse_vc_action_mplsogre_encap(struct context *ctx, const struct token *token,
5236 const char *str, unsigned int len,
5237 void *buf, unsigned int size)
5239 struct buffer *out = buf;
5240 struct rte_flow_action *action;
5241 struct action_raw_encap_data *action_encap_data;
5242 struct rte_flow_item_eth eth = { .type = 0, };
5243 struct rte_flow_item_vlan vlan = {
5244 .tci = mplsogre_encap_conf.vlan_tci,
5247 struct rte_flow_item_ipv4 ipv4 = {
5249 .src_addr = mplsogre_encap_conf.ipv4_src,
5250 .dst_addr = mplsogre_encap_conf.ipv4_dst,
5251 .next_proto_id = IPPROTO_GRE,
5252 .version_ihl = RTE_IPV4_VHL_DEF,
5253 .time_to_live = IPDEFTTL,
5256 struct rte_flow_item_ipv6 ipv6 = {
5258 .proto = IPPROTO_GRE,
5259 .hop_limits = IPDEFTTL,
5262 struct rte_flow_item_gre gre = {
5263 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
5265 struct rte_flow_item_mpls mpls = {
5271 ret = parse_vc(ctx, token, str, len, buf, size);
5274 /* Nothing else to do if there is no buffer. */
5277 if (!out->args.vc.actions_n)
5279 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5280 /* Point to selected object. */
5281 ctx->object = out->args.vc.data;
5282 ctx->objmask = NULL;
5283 /* Copy the headers to the buffer. */
5284 action_encap_data = ctx->object;
5285 *action_encap_data = (struct action_raw_encap_data) {
5286 .conf = (struct rte_flow_action_raw_encap){
5287 .data = action_encap_data->data,
5292 header = action_encap_data->data;
5293 if (mplsogre_encap_conf.select_vlan)
5294 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5295 else if (mplsogre_encap_conf.select_ipv4)
5296 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5298 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5299 memcpy(eth.dst.addr_bytes,
5300 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5301 memcpy(eth.src.addr_bytes,
5302 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5303 memcpy(header, ð, sizeof(eth));
5304 header += sizeof(eth);
5305 if (mplsogre_encap_conf.select_vlan) {
5306 if (mplsogre_encap_conf.select_ipv4)
5307 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5309 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5310 memcpy(header, &vlan, sizeof(vlan));
5311 header += sizeof(vlan);
5313 if (mplsogre_encap_conf.select_ipv4) {
5314 memcpy(header, &ipv4, sizeof(ipv4));
5315 header += sizeof(ipv4);
5317 memcpy(&ipv6.hdr.src_addr,
5318 &mplsogre_encap_conf.ipv6_src,
5319 sizeof(mplsogre_encap_conf.ipv6_src));
5320 memcpy(&ipv6.hdr.dst_addr,
5321 &mplsogre_encap_conf.ipv6_dst,
5322 sizeof(mplsogre_encap_conf.ipv6_dst));
5323 memcpy(header, &ipv6, sizeof(ipv6));
5324 header += sizeof(ipv6);
5326 memcpy(header, &gre, sizeof(gre));
5327 header += sizeof(gre);
5328 memcpy(mpls.label_tc_s, mplsogre_encap_conf.label,
5329 RTE_DIM(mplsogre_encap_conf.label));
5330 mpls.label_tc_s[2] |= 0x1;
5331 memcpy(header, &mpls, sizeof(mpls));
5332 header += sizeof(mpls);
5333 action_encap_data->conf.size = header -
5334 action_encap_data->data;
5335 action->conf = &action_encap_data->conf;
5339 /** Parse MPLSOGRE decap action. */
5341 parse_vc_action_mplsogre_decap(struct context *ctx, const struct token *token,
5342 const char *str, unsigned int len,
5343 void *buf, unsigned int size)
5345 struct buffer *out = buf;
5346 struct rte_flow_action *action;
5347 struct action_raw_decap_data *action_decap_data;
5348 struct rte_flow_item_eth eth = { .type = 0, };
5349 struct rte_flow_item_vlan vlan = {.tci = 0};
5350 struct rte_flow_item_ipv4 ipv4 = {
5352 .next_proto_id = IPPROTO_GRE,
5355 struct rte_flow_item_ipv6 ipv6 = {
5357 .proto = IPPROTO_GRE,
5360 struct rte_flow_item_gre gre = {
5361 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
5363 struct rte_flow_item_mpls mpls;
5367 ret = parse_vc(ctx, token, str, len, buf, size);
5370 /* Nothing else to do if there is no buffer. */
5373 if (!out->args.vc.actions_n)
5375 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5376 /* Point to selected object. */
5377 ctx->object = out->args.vc.data;
5378 ctx->objmask = NULL;
5379 /* Copy the headers to the buffer. */
5380 action_decap_data = ctx->object;
5381 *action_decap_data = (struct action_raw_decap_data) {
5382 .conf = (struct rte_flow_action_raw_decap){
5383 .data = action_decap_data->data,
5387 header = action_decap_data->data;
5388 if (mplsogre_decap_conf.select_vlan)
5389 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5390 else if (mplsogre_encap_conf.select_ipv4)
5391 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5393 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5394 memcpy(eth.dst.addr_bytes,
5395 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5396 memcpy(eth.src.addr_bytes,
5397 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5398 memcpy(header, ð, sizeof(eth));
5399 header += sizeof(eth);
5400 if (mplsogre_encap_conf.select_vlan) {
5401 if (mplsogre_encap_conf.select_ipv4)
5402 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5404 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5405 memcpy(header, &vlan, sizeof(vlan));
5406 header += sizeof(vlan);
5408 if (mplsogre_encap_conf.select_ipv4) {
5409 memcpy(header, &ipv4, sizeof(ipv4));
5410 header += sizeof(ipv4);
5412 memcpy(header, &ipv6, sizeof(ipv6));
5413 header += sizeof(ipv6);
5415 memcpy(header, &gre, sizeof(gre));
5416 header += sizeof(gre);
5417 memset(&mpls, 0, sizeof(mpls));
5418 memcpy(header, &mpls, sizeof(mpls));
5419 header += sizeof(mpls);
5420 action_decap_data->conf.size = header -
5421 action_decap_data->data;
5422 action->conf = &action_decap_data->conf;
5426 /** Parse MPLSOUDP encap action. */
5428 parse_vc_action_mplsoudp_encap(struct context *ctx, const struct token *token,
5429 const char *str, unsigned int len,
5430 void *buf, unsigned int size)
5432 struct buffer *out = buf;
5433 struct rte_flow_action *action;
5434 struct action_raw_encap_data *action_encap_data;
5435 struct rte_flow_item_eth eth = { .type = 0, };
5436 struct rte_flow_item_vlan vlan = {
5437 .tci = mplsoudp_encap_conf.vlan_tci,
5440 struct rte_flow_item_ipv4 ipv4 = {
5442 .src_addr = mplsoudp_encap_conf.ipv4_src,
5443 .dst_addr = mplsoudp_encap_conf.ipv4_dst,
5444 .next_proto_id = IPPROTO_UDP,
5445 .version_ihl = RTE_IPV4_VHL_DEF,
5446 .time_to_live = IPDEFTTL,
5449 struct rte_flow_item_ipv6 ipv6 = {
5451 .proto = IPPROTO_UDP,
5452 .hop_limits = IPDEFTTL,
5455 struct rte_flow_item_udp udp = {
5457 .src_port = mplsoudp_encap_conf.udp_src,
5458 .dst_port = mplsoudp_encap_conf.udp_dst,
5461 struct rte_flow_item_mpls mpls;
5465 ret = parse_vc(ctx, token, str, len, buf, size);
5468 /* Nothing else to do if there is no buffer. */
5471 if (!out->args.vc.actions_n)
5473 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5474 /* Point to selected object. */
5475 ctx->object = out->args.vc.data;
5476 ctx->objmask = NULL;
5477 /* Copy the headers to the buffer. */
5478 action_encap_data = ctx->object;
5479 *action_encap_data = (struct action_raw_encap_data) {
5480 .conf = (struct rte_flow_action_raw_encap){
5481 .data = action_encap_data->data,
5486 header = action_encap_data->data;
5487 if (mplsoudp_encap_conf.select_vlan)
5488 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5489 else if (mplsoudp_encap_conf.select_ipv4)
5490 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5492 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5493 memcpy(eth.dst.addr_bytes,
5494 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5495 memcpy(eth.src.addr_bytes,
5496 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5497 memcpy(header, ð, sizeof(eth));
5498 header += sizeof(eth);
5499 if (mplsoudp_encap_conf.select_vlan) {
5500 if (mplsoudp_encap_conf.select_ipv4)
5501 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5503 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5504 memcpy(header, &vlan, sizeof(vlan));
5505 header += sizeof(vlan);
5507 if (mplsoudp_encap_conf.select_ipv4) {
5508 memcpy(header, &ipv4, sizeof(ipv4));
5509 header += sizeof(ipv4);
5511 memcpy(&ipv6.hdr.src_addr,
5512 &mplsoudp_encap_conf.ipv6_src,
5513 sizeof(mplsoudp_encap_conf.ipv6_src));
5514 memcpy(&ipv6.hdr.dst_addr,
5515 &mplsoudp_encap_conf.ipv6_dst,
5516 sizeof(mplsoudp_encap_conf.ipv6_dst));
5517 memcpy(header, &ipv6, sizeof(ipv6));
5518 header += sizeof(ipv6);
5520 memcpy(header, &udp, sizeof(udp));
5521 header += sizeof(udp);
5522 memcpy(mpls.label_tc_s, mplsoudp_encap_conf.label,
5523 RTE_DIM(mplsoudp_encap_conf.label));
5524 mpls.label_tc_s[2] |= 0x1;
5525 memcpy(header, &mpls, sizeof(mpls));
5526 header += sizeof(mpls);
5527 action_encap_data->conf.size = header -
5528 action_encap_data->data;
5529 action->conf = &action_encap_data->conf;
5533 /** Parse MPLSOUDP decap action. */
5535 parse_vc_action_mplsoudp_decap(struct context *ctx, const struct token *token,
5536 const char *str, unsigned int len,
5537 void *buf, unsigned int size)
5539 struct buffer *out = buf;
5540 struct rte_flow_action *action;
5541 struct action_raw_decap_data *action_decap_data;
5542 struct rte_flow_item_eth eth = { .type = 0, };
5543 struct rte_flow_item_vlan vlan = {.tci = 0};
5544 struct rte_flow_item_ipv4 ipv4 = {
5546 .next_proto_id = IPPROTO_UDP,
5549 struct rte_flow_item_ipv6 ipv6 = {
5551 .proto = IPPROTO_UDP,
5554 struct rte_flow_item_udp udp = {
5556 .dst_port = rte_cpu_to_be_16(6635),
5559 struct rte_flow_item_mpls mpls;
5563 ret = parse_vc(ctx, token, str, len, buf, size);
5566 /* Nothing else to do if there is no buffer. */
5569 if (!out->args.vc.actions_n)
5571 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5572 /* Point to selected object. */
5573 ctx->object = out->args.vc.data;
5574 ctx->objmask = NULL;
5575 /* Copy the headers to the buffer. */
5576 action_decap_data = ctx->object;
5577 *action_decap_data = (struct action_raw_decap_data) {
5578 .conf = (struct rte_flow_action_raw_decap){
5579 .data = action_decap_data->data,
5583 header = action_decap_data->data;
5584 if (mplsoudp_decap_conf.select_vlan)
5585 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5586 else if (mplsoudp_encap_conf.select_ipv4)
5587 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5589 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5590 memcpy(eth.dst.addr_bytes,
5591 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5592 memcpy(eth.src.addr_bytes,
5593 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5594 memcpy(header, ð, sizeof(eth));
5595 header += sizeof(eth);
5596 if (mplsoudp_encap_conf.select_vlan) {
5597 if (mplsoudp_encap_conf.select_ipv4)
5598 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5600 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5601 memcpy(header, &vlan, sizeof(vlan));
5602 header += sizeof(vlan);
5604 if (mplsoudp_encap_conf.select_ipv4) {
5605 memcpy(header, &ipv4, sizeof(ipv4));
5606 header += sizeof(ipv4);
5608 memcpy(header, &ipv6, sizeof(ipv6));
5609 header += sizeof(ipv6);
5611 memcpy(header, &udp, sizeof(udp));
5612 header += sizeof(udp);
5613 memset(&mpls, 0, sizeof(mpls));
5614 memcpy(header, &mpls, sizeof(mpls));
5615 header += sizeof(mpls);
5616 action_decap_data->conf.size = header -
5617 action_decap_data->data;
5618 action->conf = &action_decap_data->conf;
5623 parse_vc_action_raw_decap_index(struct context *ctx, const struct token *token,
5624 const char *str, unsigned int len, void *buf,
5627 struct action_raw_decap_data *action_raw_decap_data;
5628 struct rte_flow_action *action;
5629 const struct arg *arg;
5630 struct buffer *out = buf;
5634 RTE_SET_USED(token);
5637 arg = ARGS_ENTRY_ARB_BOUNDED
5638 (offsetof(struct action_raw_decap_data, idx),
5639 sizeof(((struct action_raw_decap_data *)0)->idx),
5640 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
5641 if (push_args(ctx, arg))
5643 ret = parse_int(ctx, token, str, len, NULL, 0);
5650 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5651 action_raw_decap_data = ctx->object;
5652 idx = action_raw_decap_data->idx;
5653 action_raw_decap_data->conf.data = raw_decap_confs[idx].data;
5654 action_raw_decap_data->conf.size = raw_decap_confs[idx].size;
5655 action->conf = &action_raw_decap_data->conf;
5661 parse_vc_action_raw_encap_index(struct context *ctx, const struct token *token,
5662 const char *str, unsigned int len, void *buf,
5665 struct action_raw_encap_data *action_raw_encap_data;
5666 struct rte_flow_action *action;
5667 const struct arg *arg;
5668 struct buffer *out = buf;
5672 RTE_SET_USED(token);
5675 if (ctx->curr != ACTION_RAW_ENCAP_INDEX_VALUE)
5677 arg = ARGS_ENTRY_ARB_BOUNDED
5678 (offsetof(struct action_raw_encap_data, idx),
5679 sizeof(((struct action_raw_encap_data *)0)->idx),
5680 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
5681 if (push_args(ctx, arg))
5683 ret = parse_int(ctx, token, str, len, NULL, 0);
5690 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5691 action_raw_encap_data = ctx->object;
5692 idx = action_raw_encap_data->idx;
5693 action_raw_encap_data->conf.data = raw_encap_confs[idx].data;
5694 action_raw_encap_data->conf.size = raw_encap_confs[idx].size;
5695 action_raw_encap_data->conf.preserve = NULL;
5696 action->conf = &action_raw_encap_data->conf;
5701 parse_vc_action_raw_encap(struct context *ctx, const struct token *token,
5702 const char *str, unsigned int len, void *buf,
5705 struct buffer *out = buf;
5706 struct rte_flow_action *action;
5707 struct action_raw_encap_data *action_raw_encap_data = NULL;
5710 ret = parse_vc(ctx, token, str, len, buf, size);
5713 /* Nothing else to do if there is no buffer. */
5716 if (!out->args.vc.actions_n)
5718 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5719 /* Point to selected object. */
5720 ctx->object = out->args.vc.data;
5721 ctx->objmask = NULL;
5722 /* Copy the headers to the buffer. */
5723 action_raw_encap_data = ctx->object;
5724 action_raw_encap_data->conf.data = raw_encap_confs[0].data;
5725 action_raw_encap_data->conf.preserve = NULL;
5726 action_raw_encap_data->conf.size = raw_encap_confs[0].size;
5727 action->conf = &action_raw_encap_data->conf;
5732 parse_vc_action_raw_decap(struct context *ctx, const struct token *token,
5733 const char *str, unsigned int len, void *buf,
5736 struct buffer *out = buf;
5737 struct rte_flow_action *action;
5738 struct action_raw_decap_data *action_raw_decap_data = NULL;
5741 ret = parse_vc(ctx, token, str, len, buf, size);
5744 /* Nothing else to do if there is no buffer. */
5747 if (!out->args.vc.actions_n)
5749 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5750 /* Point to selected object. */
5751 ctx->object = out->args.vc.data;
5752 ctx->objmask = NULL;
5753 /* Copy the headers to the buffer. */
5754 action_raw_decap_data = ctx->object;
5755 action_raw_decap_data->conf.data = raw_decap_confs[0].data;
5756 action_raw_decap_data->conf.size = raw_decap_confs[0].size;
5757 action->conf = &action_raw_decap_data->conf;
5762 parse_vc_action_set_meta(struct context *ctx, const struct token *token,
5763 const char *str, unsigned int len, void *buf,
5768 ret = parse_vc(ctx, token, str, len, buf, size);
5771 ret = rte_flow_dynf_metadata_register();
5778 parse_vc_action_sample(struct context *ctx, const struct token *token,
5779 const char *str, unsigned int len, void *buf,
5782 struct buffer *out = buf;
5783 struct rte_flow_action *action;
5784 struct action_sample_data *action_sample_data = NULL;
5785 static struct rte_flow_action end_action = {
5786 RTE_FLOW_ACTION_TYPE_END, 0
5790 ret = parse_vc(ctx, token, str, len, buf, size);
5793 /* Nothing else to do if there is no buffer. */
5796 if (!out->args.vc.actions_n)
5798 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5799 /* Point to selected object. */
5800 ctx->object = out->args.vc.data;
5801 ctx->objmask = NULL;
5802 /* Copy the headers to the buffer. */
5803 action_sample_data = ctx->object;
5804 action_sample_data->conf.actions = &end_action;
5805 action->conf = &action_sample_data->conf;
5810 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
5811 const char *str, unsigned int len, void *buf,
5814 struct action_sample_data *action_sample_data;
5815 struct rte_flow_action *action;
5816 const struct arg *arg;
5817 struct buffer *out = buf;
5821 RTE_SET_USED(token);
5824 if (ctx->curr != ACTION_SAMPLE_INDEX_VALUE)
5826 arg = ARGS_ENTRY_ARB_BOUNDED
5827 (offsetof(struct action_sample_data, idx),
5828 sizeof(((struct action_sample_data *)0)->idx),
5829 0, RAW_SAMPLE_CONFS_MAX_NUM - 1);
5830 if (push_args(ctx, arg))
5832 ret = parse_int(ctx, token, str, len, NULL, 0);
5839 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5840 action_sample_data = ctx->object;
5841 idx = action_sample_data->idx;
5842 action_sample_data->conf.actions = raw_sample_confs[idx].data;
5843 action->conf = &action_sample_data->conf;
5847 /** Parse tokens for destroy command. */
5849 parse_destroy(struct context *ctx, const struct token *token,
5850 const char *str, unsigned int len,
5851 void *buf, unsigned int size)
5853 struct buffer *out = buf;
5855 /* Token name must match. */
5856 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5858 /* Nothing else to do if there is no buffer. */
5861 if (!out->command) {
5862 if (ctx->curr != DESTROY)
5864 if (sizeof(*out) > size)
5866 out->command = ctx->curr;
5869 ctx->objmask = NULL;
5870 out->args.destroy.rule =
5871 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5875 if (((uint8_t *)(out->args.destroy.rule + out->args.destroy.rule_n) +
5876 sizeof(*out->args.destroy.rule)) > (uint8_t *)out + size)
5879 ctx->object = out->args.destroy.rule + out->args.destroy.rule_n++;
5880 ctx->objmask = NULL;
5884 /** Parse tokens for flush command. */
5886 parse_flush(struct context *ctx, const struct token *token,
5887 const char *str, unsigned int len,
5888 void *buf, unsigned int size)
5890 struct buffer *out = buf;
5892 /* Token name must match. */
5893 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5895 /* Nothing else to do if there is no buffer. */
5898 if (!out->command) {
5899 if (ctx->curr != FLUSH)
5901 if (sizeof(*out) > size)
5903 out->command = ctx->curr;
5906 ctx->objmask = NULL;
5911 /** Parse tokens for dump command. */
5913 parse_dump(struct context *ctx, const struct token *token,
5914 const char *str, unsigned int len,
5915 void *buf, unsigned int size)
5917 struct buffer *out = buf;
5919 /* Token name must match. */
5920 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5922 /* Nothing else to do if there is no buffer. */
5925 if (!out->command) {
5926 if (ctx->curr != DUMP)
5928 if (sizeof(*out) > size)
5930 out->command = ctx->curr;
5933 ctx->objmask = NULL;
5938 /** Parse tokens for query command. */
5940 parse_query(struct context *ctx, const struct token *token,
5941 const char *str, unsigned int len,
5942 void *buf, unsigned int size)
5944 struct buffer *out = buf;
5946 /* Token name must match. */
5947 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5949 /* Nothing else to do if there is no buffer. */
5952 if (!out->command) {
5953 if (ctx->curr != QUERY)
5955 if (sizeof(*out) > size)
5957 out->command = ctx->curr;
5960 ctx->objmask = NULL;
5965 /** Parse action names. */
5967 parse_action(struct context *ctx, const struct token *token,
5968 const char *str, unsigned int len,
5969 void *buf, unsigned int size)
5971 struct buffer *out = buf;
5972 const struct arg *arg = pop_args(ctx);
5976 /* Argument is expected. */
5979 /* Parse action name. */
5980 for (i = 0; next_action[i]; ++i) {
5981 const struct parse_action_priv *priv;
5983 token = &token_list[next_action[i]];
5984 if (strcmp_partial(token->name, str, len))
5990 memcpy((uint8_t *)ctx->object + arg->offset,
5996 push_args(ctx, arg);
6000 /** Parse tokens for list command. */
6002 parse_list(struct context *ctx, const struct token *token,
6003 const char *str, unsigned int len,
6004 void *buf, unsigned int size)
6006 struct buffer *out = buf;
6008 /* Token name must match. */
6009 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6011 /* Nothing else to do if there is no buffer. */
6014 if (!out->command) {
6015 if (ctx->curr != LIST)
6017 if (sizeof(*out) > size)
6019 out->command = ctx->curr;
6022 ctx->objmask = NULL;
6023 out->args.list.group =
6024 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6028 if (((uint8_t *)(out->args.list.group + out->args.list.group_n) +
6029 sizeof(*out->args.list.group)) > (uint8_t *)out + size)
6032 ctx->object = out->args.list.group + out->args.list.group_n++;
6033 ctx->objmask = NULL;
6037 /** Parse tokens for list all aged flows command. */
6039 parse_aged(struct context *ctx, const struct token *token,
6040 const char *str, unsigned int len,
6041 void *buf, unsigned int size)
6043 struct buffer *out = buf;
6045 /* Token name must match. */
6046 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6048 /* Nothing else to do if there is no buffer. */
6051 if (!out->command) {
6052 if (ctx->curr != AGED)
6054 if (sizeof(*out) > size)
6056 out->command = ctx->curr;
6059 ctx->objmask = NULL;
6061 if (ctx->curr == AGED_DESTROY)
6062 out->args.aged.destroy = 1;
6066 /** Parse tokens for isolate command. */
6068 parse_isolate(struct context *ctx, const struct token *token,
6069 const char *str, unsigned int len,
6070 void *buf, unsigned int size)
6072 struct buffer *out = buf;
6074 /* Token name must match. */
6075 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6077 /* Nothing else to do if there is no buffer. */
6080 if (!out->command) {
6081 if (ctx->curr != ISOLATE)
6083 if (sizeof(*out) > size)
6085 out->command = ctx->curr;
6088 ctx->objmask = NULL;
6094 * Parse signed/unsigned integers 8 to 64-bit long.
6096 * Last argument (ctx->args) is retrieved to determine integer type and
6100 parse_int(struct context *ctx, const struct token *token,
6101 const char *str, unsigned int len,
6102 void *buf, unsigned int size)
6104 const struct arg *arg = pop_args(ctx);
6109 /* Argument is expected. */
6114 (uintmax_t)strtoimax(str, &end, 0) :
6115 strtoumax(str, &end, 0);
6116 if (errno || (size_t)(end - str) != len)
6119 ((arg->sign && ((intmax_t)u < (intmax_t)arg->min ||
6120 (intmax_t)u > (intmax_t)arg->max)) ||
6121 (!arg->sign && (u < arg->min || u > arg->max))))
6126 if (!arg_entry_bf_fill(ctx->object, u, arg) ||
6127 !arg_entry_bf_fill(ctx->objmask, -1, arg))
6131 buf = (uint8_t *)ctx->object + arg->offset;
6133 if (u > RTE_LEN2MASK(size * CHAR_BIT, uint64_t))
6137 case sizeof(uint8_t):
6138 *(uint8_t *)buf = u;
6140 case sizeof(uint16_t):
6141 *(uint16_t *)buf = arg->hton ? rte_cpu_to_be_16(u) : u;
6143 case sizeof(uint8_t [3]):
6144 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
6146 ((uint8_t *)buf)[0] = u;
6147 ((uint8_t *)buf)[1] = u >> 8;
6148 ((uint8_t *)buf)[2] = u >> 16;
6152 ((uint8_t *)buf)[0] = u >> 16;
6153 ((uint8_t *)buf)[1] = u >> 8;
6154 ((uint8_t *)buf)[2] = u;
6156 case sizeof(uint32_t):
6157 *(uint32_t *)buf = arg->hton ? rte_cpu_to_be_32(u) : u;
6159 case sizeof(uint64_t):
6160 *(uint64_t *)buf = arg->hton ? rte_cpu_to_be_64(u) : u;
6165 if (ctx->objmask && buf != (uint8_t *)ctx->objmask + arg->offset) {
6167 buf = (uint8_t *)ctx->objmask + arg->offset;
6172 push_args(ctx, arg);
6179 * Three arguments (ctx->args) are retrieved from the stack to store data,
6180 * its actual length and address (in that order).
6183 parse_string(struct context *ctx, const struct token *token,
6184 const char *str, unsigned int len,
6185 void *buf, unsigned int size)
6187 const struct arg *arg_data = pop_args(ctx);
6188 const struct arg *arg_len = pop_args(ctx);
6189 const struct arg *arg_addr = pop_args(ctx);
6190 char tmp[16]; /* Ought to be enough. */
6193 /* Arguments are expected. */
6197 push_args(ctx, arg_data);
6201 push_args(ctx, arg_len);
6202 push_args(ctx, arg_data);
6205 size = arg_data->size;
6206 /* Bit-mask fill is not supported. */
6207 if (arg_data->mask || size < len)
6211 /* Let parse_int() fill length information first. */
6212 ret = snprintf(tmp, sizeof(tmp), "%u", len);
6215 push_args(ctx, arg_len);
6216 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
6221 buf = (uint8_t *)ctx->object + arg_data->offset;
6222 /* Output buffer is not necessarily NUL-terminated. */
6223 memcpy(buf, str, len);
6224 memset((uint8_t *)buf + len, 0x00, size - len);
6226 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
6227 /* Save address if requested. */
6228 if (arg_addr->size) {
6229 memcpy((uint8_t *)ctx->object + arg_addr->offset,
6231 (uint8_t *)ctx->object + arg_data->offset
6235 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
6237 (uint8_t *)ctx->objmask + arg_data->offset
6243 push_args(ctx, arg_addr);
6244 push_args(ctx, arg_len);
6245 push_args(ctx, arg_data);
6250 parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
6256 /* Check input parameters */
6257 if ((src == NULL) ||
6263 /* Convert chars to bytes */
6264 for (i = 0, len = 0; i < *size; i += 2) {
6265 snprintf(tmp, 3, "%s", src + i);
6266 dst[len++] = strtoul(tmp, &c, 16);
6281 parse_hex(struct context *ctx, const struct token *token,
6282 const char *str, unsigned int len,
6283 void *buf, unsigned int size)
6285 const struct arg *arg_data = pop_args(ctx);
6286 const struct arg *arg_len = pop_args(ctx);
6287 const struct arg *arg_addr = pop_args(ctx);
6288 char tmp[16]; /* Ought to be enough. */
6290 unsigned int hexlen = len;
6291 unsigned int length = 256;
6292 uint8_t hex_tmp[length];
6294 /* Arguments are expected. */
6298 push_args(ctx, arg_data);
6302 push_args(ctx, arg_len);
6303 push_args(ctx, arg_data);
6306 size = arg_data->size;
6307 /* Bit-mask fill is not supported. */
6313 /* translate bytes string to array. */
6314 if (str[0] == '0' && ((str[1] == 'x') ||
6319 if (hexlen > length)
6321 ret = parse_hex_string(str, hex_tmp, &hexlen);
6324 /* Let parse_int() fill length information first. */
6325 ret = snprintf(tmp, sizeof(tmp), "%u", hexlen);
6328 push_args(ctx, arg_len);
6329 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
6334 buf = (uint8_t *)ctx->object + arg_data->offset;
6335 /* Output buffer is not necessarily NUL-terminated. */
6336 memcpy(buf, hex_tmp, hexlen);
6337 memset((uint8_t *)buf + hexlen, 0x00, size - hexlen);
6339 memset((uint8_t *)ctx->objmask + arg_data->offset,
6341 /* Save address if requested. */
6342 if (arg_addr->size) {
6343 memcpy((uint8_t *)ctx->object + arg_addr->offset,
6345 (uint8_t *)ctx->object + arg_data->offset
6349 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
6351 (uint8_t *)ctx->objmask + arg_data->offset
6357 push_args(ctx, arg_addr);
6358 push_args(ctx, arg_len);
6359 push_args(ctx, arg_data);
6365 * Parse a zero-ended string.
6368 parse_string0(struct context *ctx, const struct token *token __rte_unused,
6369 const char *str, unsigned int len,
6370 void *buf, unsigned int size)
6372 const struct arg *arg_data = pop_args(ctx);
6374 /* Arguments are expected. */
6377 size = arg_data->size;
6378 /* Bit-mask fill is not supported. */
6379 if (arg_data->mask || size < len + 1)
6383 buf = (uint8_t *)ctx->object + arg_data->offset;
6384 strncpy(buf, str, len);
6386 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
6389 push_args(ctx, arg_data);
6394 * Parse a MAC address.
6396 * Last argument (ctx->args) is retrieved to determine storage size and
6400 parse_mac_addr(struct context *ctx, const struct token *token,
6401 const char *str, unsigned int len,
6402 void *buf, unsigned int size)
6404 const struct arg *arg = pop_args(ctx);
6405 struct rte_ether_addr tmp;
6409 /* Argument is expected. */
6413 /* Bit-mask fill is not supported. */
6414 if (arg->mask || size != sizeof(tmp))
6416 /* Only network endian is supported. */
6419 ret = cmdline_parse_etheraddr(NULL, str, &tmp, size);
6420 if (ret < 0 || (unsigned int)ret != len)
6424 buf = (uint8_t *)ctx->object + arg->offset;
6425 memcpy(buf, &tmp, size);
6427 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6430 push_args(ctx, arg);
6435 * Parse an IPv4 address.
6437 * Last argument (ctx->args) is retrieved to determine storage size and
6441 parse_ipv4_addr(struct context *ctx, const struct token *token,
6442 const char *str, unsigned int len,
6443 void *buf, unsigned int size)
6445 const struct arg *arg = pop_args(ctx);
6450 /* Argument is expected. */
6454 /* Bit-mask fill is not supported. */
6455 if (arg->mask || size != sizeof(tmp))
6457 /* Only network endian is supported. */
6460 memcpy(str2, str, len);
6462 ret = inet_pton(AF_INET, str2, &tmp);
6464 /* Attempt integer parsing. */
6465 push_args(ctx, arg);
6466 return parse_int(ctx, token, str, len, buf, size);
6470 buf = (uint8_t *)ctx->object + arg->offset;
6471 memcpy(buf, &tmp, size);
6473 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6476 push_args(ctx, arg);
6481 * Parse an IPv6 address.
6483 * Last argument (ctx->args) is retrieved to determine storage size and
6487 parse_ipv6_addr(struct context *ctx, const struct token *token,
6488 const char *str, unsigned int len,
6489 void *buf, unsigned int size)
6491 const struct arg *arg = pop_args(ctx);
6493 struct in6_addr tmp;
6497 /* Argument is expected. */
6501 /* Bit-mask fill is not supported. */
6502 if (arg->mask || size != sizeof(tmp))
6504 /* Only network endian is supported. */
6507 memcpy(str2, str, len);
6509 ret = inet_pton(AF_INET6, str2, &tmp);
6514 buf = (uint8_t *)ctx->object + arg->offset;
6515 memcpy(buf, &tmp, size);
6517 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6520 push_args(ctx, arg);
6524 /** Boolean values (even indices stand for false). */
6525 static const char *const boolean_name[] = {
6535 * Parse a boolean value.
6537 * Last argument (ctx->args) is retrieved to determine storage size and
6541 parse_boolean(struct context *ctx, const struct token *token,
6542 const char *str, unsigned int len,
6543 void *buf, unsigned int size)
6545 const struct arg *arg = pop_args(ctx);
6549 /* Argument is expected. */
6552 for (i = 0; boolean_name[i]; ++i)
6553 if (!strcmp_partial(boolean_name[i], str, len))
6555 /* Process token as integer. */
6556 if (boolean_name[i])
6557 str = i & 1 ? "1" : "0";
6558 push_args(ctx, arg);
6559 ret = parse_int(ctx, token, str, strlen(str), buf, size);
6560 return ret > 0 ? (int)len : ret;
6563 /** Parse port and update context. */
6565 parse_port(struct context *ctx, const struct token *token,
6566 const char *str, unsigned int len,
6567 void *buf, unsigned int size)
6569 struct buffer *out = &(struct buffer){ .port = 0 };
6577 ctx->objmask = NULL;
6578 size = sizeof(*out);
6580 ret = parse_int(ctx, token, str, len, out, size);
6582 ctx->port = out->port;
6589 parse_sa_id2ptr(struct context *ctx, const struct token *token,
6590 const char *str, unsigned int len,
6591 void *buf, unsigned int size)
6593 struct rte_flow_action *action = ctx->object;
6601 ctx->objmask = NULL;
6602 ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
6603 ctx->object = action;
6604 if (ret != (int)len)
6606 /* set shared action */
6608 action->conf = port_shared_action_get_by_id(ctx->port, id);
6609 ret = (action->conf) ? ret : -1;
6614 /** Parse set command, initialize output buffer for subsequent tokens. */
6616 parse_set_raw_encap_decap(struct context *ctx, const struct token *token,
6617 const char *str, unsigned int len,
6618 void *buf, unsigned int size)
6620 struct buffer *out = buf;
6622 /* Token name must match. */
6623 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6625 /* Nothing else to do if there is no buffer. */
6628 /* Make sure buffer is large enough. */
6629 if (size < sizeof(*out))
6632 ctx->objmask = NULL;
6636 out->command = ctx->curr;
6637 /* For encap/decap we need is pattern */
6638 out->args.vc.pattern = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6643 /** Parse set command, initialize output buffer for subsequent tokens. */
6645 parse_set_sample_action(struct context *ctx, const struct token *token,
6646 const char *str, unsigned int len,
6647 void *buf, unsigned int size)
6649 struct buffer *out = buf;
6651 /* Token name must match. */
6652 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6654 /* Nothing else to do if there is no buffer. */
6657 /* Make sure buffer is large enough. */
6658 if (size < sizeof(*out))
6661 ctx->objmask = NULL;
6665 out->command = ctx->curr;
6666 /* For sampler we need is actions */
6667 out->args.vc.actions = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6673 * Parse set raw_encap/raw_decap command,
6674 * initialize output buffer for subsequent tokens.
6677 parse_set_init(struct context *ctx, const struct token *token,
6678 const char *str, unsigned int len,
6679 void *buf, unsigned int size)
6681 struct buffer *out = buf;
6683 /* Token name must match. */
6684 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6686 /* Nothing else to do if there is no buffer. */
6689 /* Make sure buffer is large enough. */
6690 if (size < sizeof(*out))
6692 /* Initialize buffer. */
6693 memset(out, 0x00, sizeof(*out));
6694 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
6697 ctx->objmask = NULL;
6698 if (!out->command) {
6699 if (ctx->curr != SET)
6701 if (sizeof(*out) > size)
6703 out->command = ctx->curr;
6704 out->args.vc.data = (uint8_t *)out + size;
6705 ctx->object = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6711 /** No completion. */
6713 comp_none(struct context *ctx, const struct token *token,
6714 unsigned int ent, char *buf, unsigned int size)
6724 /** Complete boolean values. */
6726 comp_boolean(struct context *ctx, const struct token *token,
6727 unsigned int ent, char *buf, unsigned int size)
6733 for (i = 0; boolean_name[i]; ++i)
6734 if (buf && i == ent)
6735 return strlcpy(buf, boolean_name[i], size);
6741 /** Complete action names. */
6743 comp_action(struct context *ctx, const struct token *token,
6744 unsigned int ent, char *buf, unsigned int size)
6750 for (i = 0; next_action[i]; ++i)
6751 if (buf && i == ent)
6752 return strlcpy(buf, token_list[next_action[i]].name,
6759 /** Complete available ports. */
6761 comp_port(struct context *ctx, const struct token *token,
6762 unsigned int ent, char *buf, unsigned int size)
6769 RTE_ETH_FOREACH_DEV(p) {
6770 if (buf && i == ent)
6771 return snprintf(buf, size, "%u", p);
6779 /** Complete available rule IDs. */
6781 comp_rule_id(struct context *ctx, const struct token *token,
6782 unsigned int ent, char *buf, unsigned int size)
6785 struct rte_port *port;
6786 struct port_flow *pf;
6789 if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
6790 ctx->port == (portid_t)RTE_PORT_ALL)
6792 port = &ports[ctx->port];
6793 for (pf = port->flow_list; pf != NULL; pf = pf->next) {
6794 if (buf && i == ent)
6795 return snprintf(buf, size, "%u", pf->id);
6803 /** Complete type field for RSS action. */
6805 comp_vc_action_rss_type(struct context *ctx, const struct token *token,
6806 unsigned int ent, char *buf, unsigned int size)
6812 for (i = 0; rss_type_table[i].str; ++i)
6817 return strlcpy(buf, rss_type_table[ent].str, size);
6819 return snprintf(buf, size, "end");
6823 /** Complete queue field for RSS action. */
6825 comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
6826 unsigned int ent, char *buf, unsigned int size)
6833 return snprintf(buf, size, "%u", ent);
6835 return snprintf(buf, size, "end");
6839 /** Complete index number for set raw_encap/raw_decap commands. */
6841 comp_set_raw_index(struct context *ctx, const struct token *token,
6842 unsigned int ent, char *buf, unsigned int size)
6848 RTE_SET_USED(token);
6849 for (idx = 0; idx < RAW_ENCAP_CONFS_MAX_NUM; ++idx) {
6850 if (buf && idx == ent)
6851 return snprintf(buf, size, "%u", idx);
6857 /** Complete index number for set raw_encap/raw_decap commands. */
6859 comp_set_sample_index(struct context *ctx, const struct token *token,
6860 unsigned int ent, char *buf, unsigned int size)
6866 RTE_SET_USED(token);
6867 for (idx = 0; idx < RAW_SAMPLE_CONFS_MAX_NUM; ++idx) {
6868 if (buf && idx == ent)
6869 return snprintf(buf, size, "%u", idx);
6875 /** Internal context. */
6876 static struct context cmd_flow_context;
6878 /** Global parser instance (cmdline API). */
6879 cmdline_parse_inst_t cmd_flow;
6880 cmdline_parse_inst_t cmd_set_raw;
6882 /** Initialize context. */
6884 cmd_flow_context_init(struct context *ctx)
6886 /* A full memset() is not necessary. */
6896 ctx->objmask = NULL;
6899 /** Parse a token (cmdline API). */
6901 cmd_flow_parse(cmdline_parse_token_hdr_t *hdr, const char *src, void *result,
6904 struct context *ctx = &cmd_flow_context;
6905 const struct token *token;
6906 const enum index *list;
6911 token = &token_list[ctx->curr];
6912 /* Check argument length. */
6915 for (len = 0; src[len]; ++len)
6916 if (src[len] == '#' || isspace(src[len]))
6920 /* Last argument and EOL detection. */
6921 for (i = len; src[i]; ++i)
6922 if (src[i] == '#' || src[i] == '\r' || src[i] == '\n')
6924 else if (!isspace(src[i])) {
6929 if (src[i] == '\r' || src[i] == '\n') {
6933 /* Initialize context if necessary. */
6934 if (!ctx->next_num) {
6937 ctx->next[ctx->next_num++] = token->next[0];
6939 /* Process argument through candidates. */
6940 ctx->prev = ctx->curr;
6941 list = ctx->next[ctx->next_num - 1];
6942 for (i = 0; list[i]; ++i) {
6943 const struct token *next = &token_list[list[i]];
6946 ctx->curr = list[i];
6948 tmp = next->call(ctx, next, src, len, result, size);
6950 tmp = parse_default(ctx, next, src, len, result, size);
6951 if (tmp == -1 || tmp != len)
6959 /* Push subsequent tokens if any. */
6961 for (i = 0; token->next[i]; ++i) {
6962 if (ctx->next_num == RTE_DIM(ctx->next))
6964 ctx->next[ctx->next_num++] = token->next[i];
6966 /* Push arguments if any. */
6968 for (i = 0; token->args[i]; ++i) {
6969 if (ctx->args_num == RTE_DIM(ctx->args))
6971 ctx->args[ctx->args_num++] = token->args[i];
6976 /** Return number of completion entries (cmdline API). */
6978 cmd_flow_complete_get_nb(cmdline_parse_token_hdr_t *hdr)
6980 struct context *ctx = &cmd_flow_context;
6981 const struct token *token = &token_list[ctx->curr];
6982 const enum index *list;
6986 /* Count number of tokens in current list. */
6988 list = ctx->next[ctx->next_num - 1];
6990 list = token->next[0];
6991 for (i = 0; list[i]; ++i)
6996 * If there is a single token, use its completion callback, otherwise
6997 * return the number of entries.
6999 token = &token_list[list[0]];
7000 if (i == 1 && token->comp) {
7001 /* Save index for cmd_flow_get_help(). */
7002 ctx->prev = list[0];
7003 return token->comp(ctx, token, 0, NULL, 0);
7008 /** Return a completion entry (cmdline API). */
7010 cmd_flow_complete_get_elt(cmdline_parse_token_hdr_t *hdr, int index,
7011 char *dst, unsigned int size)
7013 struct context *ctx = &cmd_flow_context;
7014 const struct token *token = &token_list[ctx->curr];
7015 const enum index *list;
7019 /* Count number of tokens in current list. */
7021 list = ctx->next[ctx->next_num - 1];
7023 list = token->next[0];
7024 for (i = 0; list[i]; ++i)
7028 /* If there is a single token, use its completion callback. */
7029 token = &token_list[list[0]];
7030 if (i == 1 && token->comp) {
7031 /* Save index for cmd_flow_get_help(). */
7032 ctx->prev = list[0];
7033 return token->comp(ctx, token, index, dst, size) < 0 ? -1 : 0;
7035 /* Otherwise make sure the index is valid and use defaults. */
7038 token = &token_list[list[index]];
7039 strlcpy(dst, token->name, size);
7040 /* Save index for cmd_flow_get_help(). */
7041 ctx->prev = list[index];
7045 /** Populate help strings for current token (cmdline API). */
7047 cmd_flow_get_help(cmdline_parse_token_hdr_t *hdr, char *dst, unsigned int size)
7049 struct context *ctx = &cmd_flow_context;
7050 const struct token *token = &token_list[ctx->prev];
7055 /* Set token type and update global help with details. */
7056 strlcpy(dst, (token->type ? token->type : "TOKEN"), size);
7058 cmd_flow.help_str = token->help;
7060 cmd_flow.help_str = token->name;
7064 /** Token definition template (cmdline API). */
7065 static struct cmdline_token_hdr cmd_flow_token_hdr = {
7066 .ops = &(struct cmdline_token_ops){
7067 .parse = cmd_flow_parse,
7068 .complete_get_nb = cmd_flow_complete_get_nb,
7069 .complete_get_elt = cmd_flow_complete_get_elt,
7070 .get_help = cmd_flow_get_help,
7075 /** Populate the next dynamic token. */
7077 cmd_flow_tok(cmdline_parse_token_hdr_t **hdr,
7078 cmdline_parse_token_hdr_t **hdr_inst)
7080 struct context *ctx = &cmd_flow_context;
7082 /* Always reinitialize context before requesting the first token. */
7083 if (!(hdr_inst - cmd_flow.tokens))
7084 cmd_flow_context_init(ctx);
7085 /* Return NULL when no more tokens are expected. */
7086 if (!ctx->next_num && ctx->curr) {
7090 /* Determine if command should end here. */
7091 if (ctx->eol && ctx->last && ctx->next_num) {
7092 const enum index *list = ctx->next[ctx->next_num - 1];
7095 for (i = 0; list[i]; ++i) {
7102 *hdr = &cmd_flow_token_hdr;
7105 /** Dispatch parsed buffer to function calls. */
7107 cmd_flow_parsed(const struct buffer *in)
7109 switch (in->command) {
7110 case SHARED_ACTION_CREATE:
7111 port_shared_action_create(
7112 in->port, in->args.vc.attr.group,
7113 &((const struct rte_flow_shared_action_conf) {
7114 .ingress = in->args.vc.attr.ingress,
7115 .egress = in->args.vc.attr.egress,
7117 in->args.vc.actions);
7119 case SHARED_ACTION_DESTROY:
7120 port_shared_action_destroy(in->port,
7121 in->args.sa_destroy.action_id_n,
7122 in->args.sa_destroy.action_id);
7124 case SHARED_ACTION_UPDATE:
7125 port_shared_action_update(in->port, in->args.vc.attr.group,
7126 in->args.vc.actions);
7128 case SHARED_ACTION_QUERY:
7129 port_shared_action_query(in->port, in->args.sa.action_id);
7132 port_flow_validate(in->port, &in->args.vc.attr,
7133 in->args.vc.pattern, in->args.vc.actions);
7136 port_flow_create(in->port, &in->args.vc.attr,
7137 in->args.vc.pattern, in->args.vc.actions);
7140 port_flow_destroy(in->port, in->args.destroy.rule_n,
7141 in->args.destroy.rule);
7144 port_flow_flush(in->port);
7147 port_flow_dump(in->port, in->args.dump.file);
7150 port_flow_query(in->port, in->args.query.rule,
7151 &in->args.query.action);
7154 port_flow_list(in->port, in->args.list.group_n,
7155 in->args.list.group);
7158 port_flow_isolate(in->port, in->args.isolate.set);
7161 port_flow_aged(in->port, in->args.aged.destroy);
7168 /** Token generator and output processing callback (cmdline API). */
7170 cmd_flow_cb(void *arg0, struct cmdline *cl, void *arg2)
7173 cmd_flow_tok(arg0, arg2);
7175 cmd_flow_parsed(arg0);
7178 /** Global parser instance (cmdline API). */
7179 cmdline_parse_inst_t cmd_flow = {
7181 .data = NULL, /**< Unused. */
7182 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
7185 }, /**< Tokens are returned by cmd_flow_tok(). */
7188 /** set cmd facility. Reuse cmd flow's infrastructure as much as possible. */
7191 update_fields(uint8_t *buf, struct rte_flow_item *item, uint16_t next_proto)
7193 struct rte_flow_item_ipv4 *ipv4;
7194 struct rte_flow_item_eth *eth;
7195 struct rte_flow_item_ipv6 *ipv6;
7196 struct rte_flow_item_vxlan *vxlan;
7197 struct rte_flow_item_vxlan_gpe *gpe;
7198 struct rte_flow_item_nvgre *nvgre;
7199 uint32_t ipv6_vtc_flow;
7201 switch (item->type) {
7202 case RTE_FLOW_ITEM_TYPE_ETH:
7203 eth = (struct rte_flow_item_eth *)buf;
7205 eth->type = rte_cpu_to_be_16(next_proto);
7207 case RTE_FLOW_ITEM_TYPE_IPV4:
7208 ipv4 = (struct rte_flow_item_ipv4 *)buf;
7209 ipv4->hdr.version_ihl = 0x45;
7210 if (next_proto && ipv4->hdr.next_proto_id == 0)
7211 ipv4->hdr.next_proto_id = (uint8_t)next_proto;
7213 case RTE_FLOW_ITEM_TYPE_IPV6:
7214 ipv6 = (struct rte_flow_item_ipv6 *)buf;
7215 if (next_proto && ipv6->hdr.proto == 0)
7216 ipv6->hdr.proto = (uint8_t)next_proto;
7217 ipv6_vtc_flow = rte_be_to_cpu_32(ipv6->hdr.vtc_flow);
7218 ipv6_vtc_flow &= 0x0FFFFFFF; /*< reset version bits. */
7219 ipv6_vtc_flow |= 0x60000000; /*< set ipv6 version. */
7220 ipv6->hdr.vtc_flow = rte_cpu_to_be_32(ipv6_vtc_flow);
7222 case RTE_FLOW_ITEM_TYPE_VXLAN:
7223 vxlan = (struct rte_flow_item_vxlan *)buf;
7224 vxlan->flags = 0x08;
7226 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
7227 gpe = (struct rte_flow_item_vxlan_gpe *)buf;
7230 case RTE_FLOW_ITEM_TYPE_NVGRE:
7231 nvgre = (struct rte_flow_item_nvgre *)buf;
7232 nvgre->protocol = rte_cpu_to_be_16(0x6558);
7233 nvgre->c_k_s_rsvd0_ver = rte_cpu_to_be_16(0x2000);
7240 /** Helper of get item's default mask. */
7242 flow_item_default_mask(const struct rte_flow_item *item)
7244 const void *mask = NULL;
7245 static rte_be32_t gre_key_default_mask = RTE_BE32(UINT32_MAX);
7247 switch (item->type) {
7248 case RTE_FLOW_ITEM_TYPE_ANY:
7249 mask = &rte_flow_item_any_mask;
7251 case RTE_FLOW_ITEM_TYPE_VF:
7252 mask = &rte_flow_item_vf_mask;
7254 case RTE_FLOW_ITEM_TYPE_PORT_ID:
7255 mask = &rte_flow_item_port_id_mask;
7257 case RTE_FLOW_ITEM_TYPE_RAW:
7258 mask = &rte_flow_item_raw_mask;
7260 case RTE_FLOW_ITEM_TYPE_ETH:
7261 mask = &rte_flow_item_eth_mask;
7263 case RTE_FLOW_ITEM_TYPE_VLAN:
7264 mask = &rte_flow_item_vlan_mask;
7266 case RTE_FLOW_ITEM_TYPE_IPV4:
7267 mask = &rte_flow_item_ipv4_mask;
7269 case RTE_FLOW_ITEM_TYPE_IPV6:
7270 mask = &rte_flow_item_ipv6_mask;
7272 case RTE_FLOW_ITEM_TYPE_ICMP:
7273 mask = &rte_flow_item_icmp_mask;
7275 case RTE_FLOW_ITEM_TYPE_UDP:
7276 mask = &rte_flow_item_udp_mask;
7278 case RTE_FLOW_ITEM_TYPE_TCP:
7279 mask = &rte_flow_item_tcp_mask;
7281 case RTE_FLOW_ITEM_TYPE_SCTP:
7282 mask = &rte_flow_item_sctp_mask;
7284 case RTE_FLOW_ITEM_TYPE_VXLAN:
7285 mask = &rte_flow_item_vxlan_mask;
7287 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
7288 mask = &rte_flow_item_vxlan_gpe_mask;
7290 case RTE_FLOW_ITEM_TYPE_E_TAG:
7291 mask = &rte_flow_item_e_tag_mask;
7293 case RTE_FLOW_ITEM_TYPE_NVGRE:
7294 mask = &rte_flow_item_nvgre_mask;
7296 case RTE_FLOW_ITEM_TYPE_MPLS:
7297 mask = &rte_flow_item_mpls_mask;
7299 case RTE_FLOW_ITEM_TYPE_GRE:
7300 mask = &rte_flow_item_gre_mask;
7302 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
7303 mask = &gre_key_default_mask;
7305 case RTE_FLOW_ITEM_TYPE_META:
7306 mask = &rte_flow_item_meta_mask;
7308 case RTE_FLOW_ITEM_TYPE_FUZZY:
7309 mask = &rte_flow_item_fuzzy_mask;
7311 case RTE_FLOW_ITEM_TYPE_GTP:
7312 mask = &rte_flow_item_gtp_mask;
7314 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
7315 mask = &rte_flow_item_gtp_psc_mask;
7317 case RTE_FLOW_ITEM_TYPE_GENEVE:
7318 mask = &rte_flow_item_geneve_mask;
7320 case RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID:
7321 mask = &rte_flow_item_pppoe_proto_id_mask;
7323 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
7324 mask = &rte_flow_item_l2tpv3oip_mask;
7326 case RTE_FLOW_ITEM_TYPE_ESP:
7327 mask = &rte_flow_item_esp_mask;
7329 case RTE_FLOW_ITEM_TYPE_AH:
7330 mask = &rte_flow_item_ah_mask;
7332 case RTE_FLOW_ITEM_TYPE_PFCP:
7333 mask = &rte_flow_item_pfcp_mask;
7341 /** Dispatch parsed buffer to function calls. */
7343 cmd_set_raw_parsed_sample(const struct buffer *in)
7345 uint32_t n = in->args.vc.actions_n;
7347 struct rte_flow_action *action = NULL;
7348 struct rte_flow_action *data = NULL;
7350 uint16_t idx = in->port; /* We borrow port field as index */
7351 uint32_t max_size = sizeof(struct rte_flow_action) *
7352 ACTION_SAMPLE_ACTIONS_NUM;
7354 RTE_ASSERT(in->command == SET_SAMPLE_ACTIONS);
7355 data = (struct rte_flow_action *)&raw_sample_confs[idx].data;
7356 memset(data, 0x00, max_size);
7357 for (; i <= n - 1; i++) {
7358 action = in->args.vc.actions + i;
7359 if (action->type == RTE_FLOW_ACTION_TYPE_END)
7361 switch (action->type) {
7362 case RTE_FLOW_ACTION_TYPE_MARK:
7363 size = sizeof(struct rte_flow_action_mark);
7364 rte_memcpy(&sample_mark[idx],
7365 (const void *)action->conf, size);
7366 action->conf = &sample_mark[idx];
7368 case RTE_FLOW_ACTION_TYPE_COUNT:
7369 size = sizeof(struct rte_flow_action_count);
7370 rte_memcpy(&sample_count[idx],
7371 (const void *)action->conf, size);
7372 action->conf = &sample_count[idx];
7374 case RTE_FLOW_ACTION_TYPE_QUEUE:
7375 size = sizeof(struct rte_flow_action_queue);
7376 rte_memcpy(&sample_queue[idx],
7377 (const void *)action->conf, size);
7378 action->conf = &sample_queue[idx];
7380 case RTE_FLOW_ACTION_TYPE_RAW_ENCAP:
7381 size = sizeof(struct rte_flow_action_raw_encap);
7382 rte_memcpy(&sample_encap[idx],
7383 (const void *)action->conf, size);
7384 action->conf = &sample_encap[idx];
7386 case RTE_FLOW_ACTION_TYPE_PORT_ID:
7387 size = sizeof(struct rte_flow_action_port_id);
7388 rte_memcpy(&sample_port_id[idx],
7389 (const void *)action->conf, size);
7390 action->conf = &sample_port_id[idx];
7393 printf("Error - Not supported action\n");
7396 rte_memcpy(data, action, sizeof(struct rte_flow_action));
7401 /** Dispatch parsed buffer to function calls. */
7403 cmd_set_raw_parsed(const struct buffer *in)
7405 uint32_t n = in->args.vc.pattern_n;
7407 struct rte_flow_item *item = NULL;
7409 uint8_t *data = NULL;
7410 uint8_t *data_tail = NULL;
7411 size_t *total_size = NULL;
7412 uint16_t upper_layer = 0;
7414 uint16_t idx = in->port; /* We borrow port field as index */
7416 if (in->command == SET_SAMPLE_ACTIONS)
7417 return cmd_set_raw_parsed_sample(in);
7418 RTE_ASSERT(in->command == SET_RAW_ENCAP ||
7419 in->command == SET_RAW_DECAP);
7420 if (in->command == SET_RAW_ENCAP) {
7421 total_size = &raw_encap_confs[idx].size;
7422 data = (uint8_t *)&raw_encap_confs[idx].data;
7424 total_size = &raw_decap_confs[idx].size;
7425 data = (uint8_t *)&raw_decap_confs[idx].data;
7428 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
7429 /* process hdr from upper layer to low layer (L3/L4 -> L2). */
7430 data_tail = data + ACTION_RAW_ENCAP_MAX_DATA;
7431 for (i = n - 1 ; i >= 0; --i) {
7432 item = in->args.vc.pattern + i;
7433 if (item->spec == NULL)
7434 item->spec = flow_item_default_mask(item);
7435 switch (item->type) {
7436 case RTE_FLOW_ITEM_TYPE_ETH:
7437 size = sizeof(struct rte_flow_item_eth);
7439 case RTE_FLOW_ITEM_TYPE_VLAN:
7440 size = sizeof(struct rte_flow_item_vlan);
7441 proto = RTE_ETHER_TYPE_VLAN;
7443 case RTE_FLOW_ITEM_TYPE_IPV4:
7444 size = sizeof(struct rte_flow_item_ipv4);
7445 proto = RTE_ETHER_TYPE_IPV4;
7447 case RTE_FLOW_ITEM_TYPE_IPV6:
7448 size = sizeof(struct rte_flow_item_ipv6);
7449 proto = RTE_ETHER_TYPE_IPV6;
7451 case RTE_FLOW_ITEM_TYPE_UDP:
7452 size = sizeof(struct rte_flow_item_udp);
7455 case RTE_FLOW_ITEM_TYPE_TCP:
7456 size = sizeof(struct rte_flow_item_tcp);
7459 case RTE_FLOW_ITEM_TYPE_VXLAN:
7460 size = sizeof(struct rte_flow_item_vxlan);
7462 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
7463 size = sizeof(struct rte_flow_item_vxlan_gpe);
7465 case RTE_FLOW_ITEM_TYPE_GRE:
7466 size = sizeof(struct rte_flow_item_gre);
7469 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
7470 size = sizeof(rte_be32_t);
7473 case RTE_FLOW_ITEM_TYPE_MPLS:
7474 size = sizeof(struct rte_flow_item_mpls);
7477 case RTE_FLOW_ITEM_TYPE_NVGRE:
7478 size = sizeof(struct rte_flow_item_nvgre);
7481 case RTE_FLOW_ITEM_TYPE_GENEVE:
7482 size = sizeof(struct rte_flow_item_geneve);
7484 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
7485 size = sizeof(struct rte_flow_item_l2tpv3oip);
7488 case RTE_FLOW_ITEM_TYPE_ESP:
7489 size = sizeof(struct rte_flow_item_esp);
7492 case RTE_FLOW_ITEM_TYPE_AH:
7493 size = sizeof(struct rte_flow_item_ah);
7496 case RTE_FLOW_ITEM_TYPE_GTP:
7497 size = sizeof(struct rte_flow_item_gtp);
7499 case RTE_FLOW_ITEM_TYPE_PFCP:
7500 size = sizeof(struct rte_flow_item_pfcp);
7503 printf("Error - Not supported item\n");
7505 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
7508 *total_size += size;
7509 rte_memcpy(data_tail - (*total_size), item->spec, size);
7510 /* update some fields which cannot be set by cmdline */
7511 update_fields((data_tail - (*total_size)), item,
7513 upper_layer = proto;
7515 if (verbose_level & 0x1)
7516 printf("total data size is %zu\n", (*total_size));
7517 RTE_ASSERT((*total_size) <= ACTION_RAW_ENCAP_MAX_DATA);
7518 memmove(data, (data_tail - (*total_size)), *total_size);
7521 /** Populate help strings for current token (cmdline API). */
7523 cmd_set_raw_get_help(cmdline_parse_token_hdr_t *hdr, char *dst,
7526 struct context *ctx = &cmd_flow_context;
7527 const struct token *token = &token_list[ctx->prev];
7532 /* Set token type and update global help with details. */
7533 snprintf(dst, size, "%s", (token->type ? token->type : "TOKEN"));
7535 cmd_set_raw.help_str = token->help;
7537 cmd_set_raw.help_str = token->name;
7541 /** Token definition template (cmdline API). */
7542 static struct cmdline_token_hdr cmd_set_raw_token_hdr = {
7543 .ops = &(struct cmdline_token_ops){
7544 .parse = cmd_flow_parse,
7545 .complete_get_nb = cmd_flow_complete_get_nb,
7546 .complete_get_elt = cmd_flow_complete_get_elt,
7547 .get_help = cmd_set_raw_get_help,
7552 /** Populate the next dynamic token. */
7554 cmd_set_raw_tok(cmdline_parse_token_hdr_t **hdr,
7555 cmdline_parse_token_hdr_t **hdr_inst)
7557 struct context *ctx = &cmd_flow_context;
7559 /* Always reinitialize context before requesting the first token. */
7560 if (!(hdr_inst - cmd_set_raw.tokens)) {
7561 cmd_flow_context_init(ctx);
7562 ctx->curr = START_SET;
7564 /* Return NULL when no more tokens are expected. */
7565 if (!ctx->next_num && (ctx->curr != START_SET)) {
7569 /* Determine if command should end here. */
7570 if (ctx->eol && ctx->last && ctx->next_num) {
7571 const enum index *list = ctx->next[ctx->next_num - 1];
7574 for (i = 0; list[i]; ++i) {
7581 *hdr = &cmd_set_raw_token_hdr;
7584 /** Token generator and output processing callback (cmdline API). */
7586 cmd_set_raw_cb(void *arg0, struct cmdline *cl, void *arg2)
7589 cmd_set_raw_tok(arg0, arg2);
7591 cmd_set_raw_parsed(arg0);
7594 /** Global parser instance (cmdline API). */
7595 cmdline_parse_inst_t cmd_set_raw = {
7596 .f = cmd_set_raw_cb,
7597 .data = NULL, /**< Unused. */
7598 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
7601 }, /**< Tokens are returned by cmd_flow_tok(). */
7604 /* *** display raw_encap/raw_decap buf */
7605 struct cmd_show_set_raw_result {
7606 cmdline_fixed_string_t cmd_show;
7607 cmdline_fixed_string_t cmd_what;
7608 cmdline_fixed_string_t cmd_all;
7613 cmd_show_set_raw_parsed(void *parsed_result, struct cmdline *cl, void *data)
7615 struct cmd_show_set_raw_result *res = parsed_result;
7616 uint16_t index = res->cmd_index;
7618 uint8_t *raw_data = NULL;
7619 size_t raw_size = 0;
7620 char title[16] = {0};
7624 if (!strcmp(res->cmd_all, "all")) {
7627 } else if (index >= RAW_ENCAP_CONFS_MAX_NUM) {
7628 printf("index should be 0-%u\n", RAW_ENCAP_CONFS_MAX_NUM - 1);
7632 if (!strcmp(res->cmd_what, "raw_encap")) {
7633 raw_data = (uint8_t *)&raw_encap_confs[index].data;
7634 raw_size = raw_encap_confs[index].size;
7635 snprintf(title, 16, "\nindex: %u", index);
7636 rte_hexdump(stdout, title, raw_data, raw_size);
7638 raw_data = (uint8_t *)&raw_decap_confs[index].data;
7639 raw_size = raw_decap_confs[index].size;
7640 snprintf(title, 16, "\nindex: %u", index);
7641 rte_hexdump(stdout, title, raw_data, raw_size);
7643 } while (all && ++index < RAW_ENCAP_CONFS_MAX_NUM);
7646 cmdline_parse_token_string_t cmd_show_set_raw_cmd_show =
7647 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
7649 cmdline_parse_token_string_t cmd_show_set_raw_cmd_what =
7650 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
7651 cmd_what, "raw_encap#raw_decap");
7652 cmdline_parse_token_num_t cmd_show_set_raw_cmd_index =
7653 TOKEN_NUM_INITIALIZER(struct cmd_show_set_raw_result,
7655 cmdline_parse_token_string_t cmd_show_set_raw_cmd_all =
7656 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
7658 cmdline_parse_inst_t cmd_show_set_raw = {
7659 .f = cmd_show_set_raw_parsed,
7661 .help_str = "show <raw_encap|raw_decap> <index>",
7663 (void *)&cmd_show_set_raw_cmd_show,
7664 (void *)&cmd_show_set_raw_cmd_what,
7665 (void *)&cmd_show_set_raw_cmd_index,
7669 cmdline_parse_inst_t cmd_show_set_raw_all = {
7670 .f = cmd_show_set_raw_parsed,
7672 .help_str = "show <raw_encap|raw_decap> all",
7674 (void *)&cmd_show_set_raw_cmd_show,
7675 (void *)&cmd_show_set_raw_cmd_what,
7676 (void *)&cmd_show_set_raw_cmd_all,