1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2016 6WIND S.A.
3 * Copyright 2016 Mellanox Technologies, Ltd
14 #include <rte_string_fns.h>
15 #include <rte_common.h>
16 #include <rte_ethdev.h>
17 #include <rte_byteorder.h>
18 #include <cmdline_parse.h>
19 #include <cmdline_parse_etheraddr.h>
20 #include <cmdline_parse_string.h>
21 #include <cmdline_parse_num.h>
23 #include <rte_hexdump.h>
24 #include <rte_vxlan.h>
28 #include <rte_geneve.h>
32 /** Parser token indices. */
54 COMMON_PRIORITY_LEVEL,
55 COMMON_INDIRECT_ACTION_ID,
58 /* TOP-level command. */
61 /* Top-level command. */
63 /* Sub-leve commands. */
70 /* Top-level command. */
72 /* Sub-level commands. */
85 /* Tunnel arguments. */
92 /* Destroy arguments. */
95 /* Query arguments. */
101 /* Destroy aged flow arguments. */
104 /* Validate/create arguments. */
117 /* Indirect action arguments */
118 INDIRECT_ACTION_CREATE,
119 INDIRECT_ACTION_UPDATE,
120 INDIRECT_ACTION_DESTROY,
121 INDIRECT_ACTION_QUERY,
123 /* Indirect action create arguments */
124 INDIRECT_ACTION_CREATE_ID,
125 INDIRECT_ACTION_INGRESS,
126 INDIRECT_ACTION_EGRESS,
127 INDIRECT_ACTION_TRANSFER,
128 INDIRECT_ACTION_SPEC,
130 /* Indirect action destroy arguments */
131 INDIRECT_ACTION_DESTROY_ID,
133 /* Validate/create pattern. */
171 ITEM_VLAN_INNER_TYPE,
172 ITEM_VLAN_HAS_MORE_VLAN,
177 ITEM_IPV4_FRAGMENT_OFFSET,
189 ITEM_IPV6_HAS_FRAG_EXT,
209 ITEM_VXLAN_LAST_RSVD,
211 ITEM_E_TAG_GRP_ECID_B,
220 ITEM_GRE_C_RSVD0_VER,
239 ITEM_ARP_ETH_IPV4_SHA,
240 ITEM_ARP_ETH_IPV4_SPA,
241 ITEM_ARP_ETH_IPV4_THA,
242 ITEM_ARP_ETH_IPV4_TPA,
244 ITEM_IPV6_EXT_NEXT_HDR,
246 ITEM_IPV6_FRAG_EXT_NEXT_HDR,
247 ITEM_IPV6_FRAG_EXT_FRAG_DATA,
248 ITEM_IPV6_FRAG_EXT_ID,
253 ITEM_ICMP6_ND_NS_TARGET_ADDR,
255 ITEM_ICMP6_ND_NA_TARGET_ADDR,
257 ITEM_ICMP6_ND_OPT_TYPE,
258 ITEM_ICMP6_ND_OPT_SLA_ETH,
259 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
260 ITEM_ICMP6_ND_OPT_TLA_ETH,
261 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
274 ITEM_HIGIG2_CLASSIFICATION,
280 ITEM_L2TPV3OIP_SESSION_ID,
290 ITEM_ECPRI_COMMON_TYPE,
291 ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
292 ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
293 ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
294 ITEM_ECPRI_MSG_IQ_DATA_PCID,
295 ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
296 ITEM_ECPRI_MSG_DLY_MSR_MSRID,
298 ITEM_GENEVE_OPT_CLASS,
299 ITEM_GENEVE_OPT_TYPE,
300 ITEM_GENEVE_OPT_LENGTH,
301 ITEM_GENEVE_OPT_DATA,
303 ITEM_INTEGRITY_LEVEL,
304 ITEM_INTEGRITY_VALUE,
310 /* Validate/create actions. */
329 ACTION_RSS_FUNC_DEFAULT,
330 ACTION_RSS_FUNC_TOEPLITZ,
331 ACTION_RSS_FUNC_SIMPLE_XOR,
332 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ,
344 ACTION_PHY_PORT_ORIGINAL,
345 ACTION_PHY_PORT_INDEX,
347 ACTION_PORT_ID_ORIGINAL,
351 ACTION_METER_COLOR_TYPE,
352 ACTION_METER_COLOR_GREEN,
353 ACTION_METER_COLOR_YELLOW,
354 ACTION_METER_COLOR_RED,
356 ACTION_OF_SET_MPLS_TTL,
357 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
358 ACTION_OF_DEC_MPLS_TTL,
359 ACTION_OF_SET_NW_TTL,
360 ACTION_OF_SET_NW_TTL_NW_TTL,
361 ACTION_OF_DEC_NW_TTL,
362 ACTION_OF_COPY_TTL_OUT,
363 ACTION_OF_COPY_TTL_IN,
366 ACTION_OF_PUSH_VLAN_ETHERTYPE,
367 ACTION_OF_SET_VLAN_VID,
368 ACTION_OF_SET_VLAN_VID_VLAN_VID,
369 ACTION_OF_SET_VLAN_PCP,
370 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
372 ACTION_OF_POP_MPLS_ETHERTYPE,
374 ACTION_OF_PUSH_MPLS_ETHERTYPE,
381 ACTION_MPLSOGRE_ENCAP,
382 ACTION_MPLSOGRE_DECAP,
383 ACTION_MPLSOUDP_ENCAP,
384 ACTION_MPLSOUDP_DECAP,
386 ACTION_SET_IPV4_SRC_IPV4_SRC,
388 ACTION_SET_IPV4_DST_IPV4_DST,
390 ACTION_SET_IPV6_SRC_IPV6_SRC,
392 ACTION_SET_IPV6_DST_IPV6_DST,
394 ACTION_SET_TP_SRC_TP_SRC,
396 ACTION_SET_TP_DST_TP_DST,
402 ACTION_SET_MAC_SRC_MAC_SRC,
404 ACTION_SET_MAC_DST_MAC_DST,
406 ACTION_INC_TCP_SEQ_VALUE,
408 ACTION_DEC_TCP_SEQ_VALUE,
410 ACTION_INC_TCP_ACK_VALUE,
412 ACTION_DEC_TCP_ACK_VALUE,
415 ACTION_RAW_ENCAP_INDEX,
416 ACTION_RAW_ENCAP_INDEX_VALUE,
417 ACTION_RAW_DECAP_INDEX,
418 ACTION_RAW_DECAP_INDEX_VALUE,
421 ACTION_SET_TAG_INDEX,
424 ACTION_SET_META_DATA,
425 ACTION_SET_META_MASK,
426 ACTION_SET_IPV4_DSCP,
427 ACTION_SET_IPV4_DSCP_VALUE,
428 ACTION_SET_IPV6_DSCP,
429 ACTION_SET_IPV6_DSCP_VALUE,
435 ACTION_SAMPLE_INDEX_VALUE,
437 INDIRECT_ACTION_ID2PTR,
439 ACTION_MODIFY_FIELD_OP,
440 ACTION_MODIFY_FIELD_OP_VALUE,
441 ACTION_MODIFY_FIELD_DST_TYPE,
442 ACTION_MODIFY_FIELD_DST_TYPE_VALUE,
443 ACTION_MODIFY_FIELD_DST_LEVEL,
444 ACTION_MODIFY_FIELD_DST_OFFSET,
445 ACTION_MODIFY_FIELD_SRC_TYPE,
446 ACTION_MODIFY_FIELD_SRC_TYPE_VALUE,
447 ACTION_MODIFY_FIELD_SRC_LEVEL,
448 ACTION_MODIFY_FIELD_SRC_OFFSET,
449 ACTION_MODIFY_FIELD_SRC_VALUE,
450 ACTION_MODIFY_FIELD_WIDTH,
452 ACTION_CONNTRACK_UPDATE,
453 ACTION_CONNTRACK_UPDATE_DIR,
454 ACTION_CONNTRACK_UPDATE_CTX,
460 /** Maximum size for pattern in struct rte_flow_item_raw. */
461 #define ITEM_RAW_PATTERN_SIZE 40
463 /** Maximum size for GENEVE option data pattern in bytes. */
464 #define ITEM_GENEVE_OPT_DATA_SIZE 124
466 /** Storage size for struct rte_flow_item_raw including pattern. */
467 #define ITEM_RAW_SIZE \
468 (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE)
470 /** Maximum number of queue indices in struct rte_flow_action_rss. */
471 #define ACTION_RSS_QUEUE_NUM 128
473 /** Storage for struct rte_flow_action_rss including external data. */
474 struct action_rss_data {
475 struct rte_flow_action_rss conf;
476 uint8_t key[RSS_HASH_KEY_LENGTH];
477 uint16_t queue[ACTION_RSS_QUEUE_NUM];
480 /** Maximum data size in struct rte_flow_action_raw_encap. */
481 #define ACTION_RAW_ENCAP_MAX_DATA 512
482 #define RAW_ENCAP_CONFS_MAX_NUM 8
484 /** Storage for struct rte_flow_action_raw_encap. */
485 struct raw_encap_conf {
486 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
487 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
491 struct raw_encap_conf raw_encap_confs[RAW_ENCAP_CONFS_MAX_NUM];
493 /** Storage for struct rte_flow_action_raw_encap including external data. */
494 struct action_raw_encap_data {
495 struct rte_flow_action_raw_encap conf;
496 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
497 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
501 /** Storage for struct rte_flow_action_raw_decap. */
502 struct raw_decap_conf {
503 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
507 struct raw_decap_conf raw_decap_confs[RAW_ENCAP_CONFS_MAX_NUM];
509 /** Storage for struct rte_flow_action_raw_decap including external data. */
510 struct action_raw_decap_data {
511 struct rte_flow_action_raw_decap conf;
512 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
516 struct vxlan_encap_conf vxlan_encap_conf = {
520 .vni = "\x00\x00\x00",
522 .udp_dst = RTE_BE16(RTE_VXLAN_DEFAULT_PORT),
523 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
524 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
525 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
526 "\x00\x00\x00\x00\x00\x00\x00\x01",
527 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
528 "\x00\x00\x00\x00\x00\x00\x11\x11",
532 .eth_src = "\x00\x00\x00\x00\x00\x00",
533 .eth_dst = "\xff\xff\xff\xff\xff\xff",
536 /** Maximum number of items in struct rte_flow_action_vxlan_encap. */
537 #define ACTION_VXLAN_ENCAP_ITEMS_NUM 6
539 /** Storage for struct rte_flow_action_vxlan_encap including external data. */
540 struct action_vxlan_encap_data {
541 struct rte_flow_action_vxlan_encap conf;
542 struct rte_flow_item items[ACTION_VXLAN_ENCAP_ITEMS_NUM];
543 struct rte_flow_item_eth item_eth;
544 struct rte_flow_item_vlan item_vlan;
546 struct rte_flow_item_ipv4 item_ipv4;
547 struct rte_flow_item_ipv6 item_ipv6;
549 struct rte_flow_item_udp item_udp;
550 struct rte_flow_item_vxlan item_vxlan;
553 struct nvgre_encap_conf nvgre_encap_conf = {
556 .tni = "\x00\x00\x00",
557 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
558 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
559 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
560 "\x00\x00\x00\x00\x00\x00\x00\x01",
561 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
562 "\x00\x00\x00\x00\x00\x00\x11\x11",
564 .eth_src = "\x00\x00\x00\x00\x00\x00",
565 .eth_dst = "\xff\xff\xff\xff\xff\xff",
568 /** Maximum number of items in struct rte_flow_action_nvgre_encap. */
569 #define ACTION_NVGRE_ENCAP_ITEMS_NUM 5
571 /** Storage for struct rte_flow_action_nvgre_encap including external data. */
572 struct action_nvgre_encap_data {
573 struct rte_flow_action_nvgre_encap conf;
574 struct rte_flow_item items[ACTION_NVGRE_ENCAP_ITEMS_NUM];
575 struct rte_flow_item_eth item_eth;
576 struct rte_flow_item_vlan item_vlan;
578 struct rte_flow_item_ipv4 item_ipv4;
579 struct rte_flow_item_ipv6 item_ipv6;
581 struct rte_flow_item_nvgre item_nvgre;
584 struct l2_encap_conf l2_encap_conf;
586 struct l2_decap_conf l2_decap_conf;
588 struct mplsogre_encap_conf mplsogre_encap_conf;
590 struct mplsogre_decap_conf mplsogre_decap_conf;
592 struct mplsoudp_encap_conf mplsoudp_encap_conf;
594 struct mplsoudp_decap_conf mplsoudp_decap_conf;
596 struct rte_flow_action_conntrack conntrack_context;
598 #define ACTION_SAMPLE_ACTIONS_NUM 10
599 #define RAW_SAMPLE_CONFS_MAX_NUM 8
600 /** Storage for struct rte_flow_action_sample including external data. */
601 struct action_sample_data {
602 struct rte_flow_action_sample conf;
605 /** Storage for struct rte_flow_action_sample. */
606 struct raw_sample_conf {
607 struct rte_flow_action data[ACTION_SAMPLE_ACTIONS_NUM];
609 struct raw_sample_conf raw_sample_confs[RAW_SAMPLE_CONFS_MAX_NUM];
610 struct rte_flow_action_mark sample_mark[RAW_SAMPLE_CONFS_MAX_NUM];
611 struct rte_flow_action_queue sample_queue[RAW_SAMPLE_CONFS_MAX_NUM];
612 struct rte_flow_action_count sample_count[RAW_SAMPLE_CONFS_MAX_NUM];
613 struct rte_flow_action_port_id sample_port_id[RAW_SAMPLE_CONFS_MAX_NUM];
614 struct rte_flow_action_raw_encap sample_encap[RAW_SAMPLE_CONFS_MAX_NUM];
615 struct action_vxlan_encap_data sample_vxlan_encap[RAW_SAMPLE_CONFS_MAX_NUM];
616 struct action_nvgre_encap_data sample_nvgre_encap[RAW_SAMPLE_CONFS_MAX_NUM];
617 struct action_rss_data sample_rss_data[RAW_SAMPLE_CONFS_MAX_NUM];
618 struct rte_flow_action_vf sample_vf[RAW_SAMPLE_CONFS_MAX_NUM];
620 static const char *const modify_field_ops[] = {
621 "set", "add", "sub", NULL
624 static const char *const modify_field_ids[] = {
625 "start", "mac_dst", "mac_src",
626 "vlan_type", "vlan_id", "mac_type",
627 "ipv4_dscp", "ipv4_ttl", "ipv4_src", "ipv4_dst",
628 "ipv6_dscp", "ipv6_hoplimit", "ipv6_src", "ipv6_dst",
629 "tcp_port_src", "tcp_port_dst",
630 "tcp_seq_num", "tcp_ack_num", "tcp_flags",
631 "udp_port_src", "udp_port_dst",
632 "vxlan_vni", "geneve_vni", "gtp_teid",
633 "tag", "mark", "meta", "pointer", "value", NULL
636 /** Maximum number of subsequent tokens and arguments on the stack. */
637 #define CTX_STACK_SIZE 16
639 /** Parser context. */
641 /** Stack of subsequent token lists to process. */
642 const enum index *next[CTX_STACK_SIZE];
643 /** Arguments for stacked tokens. */
644 const void *args[CTX_STACK_SIZE];
645 enum index curr; /**< Current token index. */
646 enum index prev; /**< Index of the last token seen. */
647 int next_num; /**< Number of entries in next[]. */
648 int args_num; /**< Number of entries in args[]. */
649 uint32_t eol:1; /**< EOL has been detected. */
650 uint32_t last:1; /**< No more arguments. */
651 portid_t port; /**< Current port ID (for completions). */
652 uint32_t objdata; /**< Object-specific data. */
653 void *object; /**< Address of current object for relative offsets. */
654 void *objmask; /**< Object a full mask must be written to. */
657 /** Token argument. */
659 uint32_t hton:1; /**< Use network byte ordering. */
660 uint32_t sign:1; /**< Value is signed. */
661 uint32_t bounded:1; /**< Value is bounded. */
662 uintmax_t min; /**< Minimum value if bounded. */
663 uintmax_t max; /**< Maximum value if bounded. */
664 uint32_t offset; /**< Relative offset from ctx->object. */
665 uint32_t size; /**< Field size. */
666 const uint8_t *mask; /**< Bit-mask to use instead of offset/size. */
669 /** Parser token definition. */
671 /** Type displayed during completion (defaults to "TOKEN"). */
673 /** Help displayed during completion (defaults to token name). */
675 /** Private data used by parser functions. */
678 * Lists of subsequent tokens to push on the stack. Each call to the
679 * parser consumes the last entry of that stack.
681 const enum index *const *next;
682 /** Arguments stack for subsequent tokens that need them. */
683 const struct arg *const *args;
685 * Token-processing callback, returns -1 in case of error, the
686 * length of the matched string otherwise. If NULL, attempts to
687 * match the token name.
689 * If buf is not NULL, the result should be stored in it according
690 * to context. An error is returned if not large enough.
692 int (*call)(struct context *ctx, const struct token *token,
693 const char *str, unsigned int len,
694 void *buf, unsigned int size);
696 * Callback that provides possible values for this token, used for
697 * completion. Returns -1 in case of error, the number of possible
698 * values otherwise. If NULL, the token name is used.
700 * If buf is not NULL, entry index ent is written to buf and the
701 * full length of the entry is returned (same behavior as
704 int (*comp)(struct context *ctx, const struct token *token,
705 unsigned int ent, char *buf, unsigned int size);
706 /** Mandatory token name, no default value. */
710 /** Static initializer for the next field. */
711 #define NEXT(...) (const enum index *const []){ __VA_ARGS__, NULL, }
713 /** Static initializer for a NEXT() entry. */
714 #define NEXT_ENTRY(...) (const enum index []){ __VA_ARGS__, ZERO, }
716 /** Static initializer for the args field. */
717 #define ARGS(...) (const struct arg *const []){ __VA_ARGS__, NULL, }
719 /** Static initializer for ARGS() to target a field. */
720 #define ARGS_ENTRY(s, f) \
721 (&(const struct arg){ \
722 .offset = offsetof(s, f), \
723 .size = sizeof(((s *)0)->f), \
726 /** Static initializer for ARGS() to target a bit-field. */
727 #define ARGS_ENTRY_BF(s, f, b) \
728 (&(const struct arg){ \
730 .mask = (const void *)&(const s){ .f = (1 << (b)) - 1 }, \
733 /** Static initializer for ARGS() to target a field with limits. */
734 #define ARGS_ENTRY_BOUNDED(s, f, i, a) \
735 (&(const struct arg){ \
739 .offset = offsetof(s, f), \
740 .size = sizeof(((s *)0)->f), \
743 /** Static initializer for ARGS() to target an arbitrary bit-mask. */
744 #define ARGS_ENTRY_MASK(s, f, m) \
745 (&(const struct arg){ \
746 .offset = offsetof(s, f), \
747 .size = sizeof(((s *)0)->f), \
748 .mask = (const void *)(m), \
751 /** Same as ARGS_ENTRY_MASK() using network byte ordering for the value. */
752 #define ARGS_ENTRY_MASK_HTON(s, f, m) \
753 (&(const struct arg){ \
755 .offset = offsetof(s, f), \
756 .size = sizeof(((s *)0)->f), \
757 .mask = (const void *)(m), \
760 /** Static initializer for ARGS() to target a pointer. */
761 #define ARGS_ENTRY_PTR(s, f) \
762 (&(const struct arg){ \
763 .size = sizeof(*((s *)0)->f), \
766 /** Static initializer for ARGS() with arbitrary offset and size. */
767 #define ARGS_ENTRY_ARB(o, s) \
768 (&(const struct arg){ \
773 /** Same as ARGS_ENTRY_ARB() with bounded values. */
774 #define ARGS_ENTRY_ARB_BOUNDED(o, s, i, a) \
775 (&(const struct arg){ \
783 /** Same as ARGS_ENTRY() using network byte ordering. */
784 #define ARGS_ENTRY_HTON(s, f) \
785 (&(const struct arg){ \
787 .offset = offsetof(s, f), \
788 .size = sizeof(((s *)0)->f), \
791 /** Same as ARGS_ENTRY_HTON() for a single argument, without structure. */
792 #define ARG_ENTRY_HTON(s) \
793 (&(const struct arg){ \
799 /** Parser output buffer layout expected by cmd_flow_parsed(). */
801 enum index command; /**< Flow command. */
802 portid_t port; /**< Affected port ID. */
806 uint32_t action_id_n;
807 } ia_destroy; /**< Indirect action destroy arguments. */
810 } ia; /* Indirect action query arguments */
812 struct rte_flow_attr attr;
813 struct tunnel_ops tunnel_ops;
814 struct rte_flow_item *pattern;
815 struct rte_flow_action *actions;
819 } vc; /**< Validate/create arguments. */
823 } destroy; /**< Destroy arguments. */
828 } dump; /**< Dump arguments. */
831 struct rte_flow_action action;
832 } query; /**< Query arguments. */
836 } list; /**< List arguments. */
839 } isolate; /**< Isolated mode arguments. */
842 } aged; /**< Aged arguments. */
845 } policy;/**< Policy arguments. */
846 } args; /**< Command arguments. */
849 /** Private data for pattern items. */
850 struct parse_item_priv {
851 enum rte_flow_item_type type; /**< Item type. */
852 uint32_t size; /**< Size of item specification structure. */
855 #define PRIV_ITEM(t, s) \
856 (&(const struct parse_item_priv){ \
857 .type = RTE_FLOW_ITEM_TYPE_ ## t, \
861 /** Private data for actions. */
862 struct parse_action_priv {
863 enum rte_flow_action_type type; /**< Action type. */
864 uint32_t size; /**< Size of action configuration structure. */
867 #define PRIV_ACTION(t, s) \
868 (&(const struct parse_action_priv){ \
869 .type = RTE_FLOW_ACTION_TYPE_ ## t, \
873 static const enum index next_ia_create_attr[] = {
874 INDIRECT_ACTION_CREATE_ID,
875 INDIRECT_ACTION_INGRESS,
876 INDIRECT_ACTION_EGRESS,
877 INDIRECT_ACTION_TRANSFER,
878 INDIRECT_ACTION_SPEC,
882 static const enum index next_dump_subcmd[] = {
888 static const enum index next_ia_subcmd[] = {
889 INDIRECT_ACTION_CREATE,
890 INDIRECT_ACTION_UPDATE,
891 INDIRECT_ACTION_DESTROY,
892 INDIRECT_ACTION_QUERY,
896 static const enum index next_vc_attr[] = {
908 static const enum index next_destroy_attr[] = {
914 static const enum index next_dump_attr[] = {
920 static const enum index next_list_attr[] = {
926 static const enum index next_aged_attr[] = {
932 static const enum index next_ia_destroy_attr[] = {
933 INDIRECT_ACTION_DESTROY_ID,
938 static const enum index item_param[] = {
947 static const enum index next_item[] = {
984 ITEM_ICMP6_ND_OPT_SLA_ETH,
985 ITEM_ICMP6_ND_OPT_TLA_ETH,
1006 static const enum index item_fuzzy[] = {
1012 static const enum index item_any[] = {
1018 static const enum index item_vf[] = {
1024 static const enum index item_phy_port[] = {
1025 ITEM_PHY_PORT_INDEX,
1030 static const enum index item_port_id[] = {
1036 static const enum index item_mark[] = {
1042 static const enum index item_raw[] = {
1052 static const enum index item_eth[] = {
1061 static const enum index item_vlan[] = {
1066 ITEM_VLAN_INNER_TYPE,
1067 ITEM_VLAN_HAS_MORE_VLAN,
1072 static const enum index item_ipv4[] = {
1076 ITEM_IPV4_FRAGMENT_OFFSET,
1085 static const enum index item_ipv6[] = {
1092 ITEM_IPV6_HAS_FRAG_EXT,
1097 static const enum index item_icmp[] = {
1106 static const enum index item_udp[] = {
1113 static const enum index item_tcp[] = {
1121 static const enum index item_sctp[] = {
1130 static const enum index item_vxlan[] = {
1132 ITEM_VXLAN_LAST_RSVD,
1137 static const enum index item_e_tag[] = {
1138 ITEM_E_TAG_GRP_ECID_B,
1143 static const enum index item_nvgre[] = {
1149 static const enum index item_mpls[] = {
1157 static const enum index item_gre[] = {
1159 ITEM_GRE_C_RSVD0_VER,
1167 static const enum index item_gre_key[] = {
1173 static const enum index item_gtp[] = {
1181 static const enum index item_geneve[] = {
1189 static const enum index item_vxlan_gpe[] = {
1195 static const enum index item_arp_eth_ipv4[] = {
1196 ITEM_ARP_ETH_IPV4_SHA,
1197 ITEM_ARP_ETH_IPV4_SPA,
1198 ITEM_ARP_ETH_IPV4_THA,
1199 ITEM_ARP_ETH_IPV4_TPA,
1204 static const enum index item_ipv6_ext[] = {
1205 ITEM_IPV6_EXT_NEXT_HDR,
1210 static const enum index item_ipv6_frag_ext[] = {
1211 ITEM_IPV6_FRAG_EXT_NEXT_HDR,
1212 ITEM_IPV6_FRAG_EXT_FRAG_DATA,
1213 ITEM_IPV6_FRAG_EXT_ID,
1218 static const enum index item_icmp6[] = {
1225 static const enum index item_icmp6_nd_ns[] = {
1226 ITEM_ICMP6_ND_NS_TARGET_ADDR,
1231 static const enum index item_icmp6_nd_na[] = {
1232 ITEM_ICMP6_ND_NA_TARGET_ADDR,
1237 static const enum index item_icmp6_nd_opt[] = {
1238 ITEM_ICMP6_ND_OPT_TYPE,
1243 static const enum index item_icmp6_nd_opt_sla_eth[] = {
1244 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
1249 static const enum index item_icmp6_nd_opt_tla_eth[] = {
1250 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
1255 static const enum index item_meta[] = {
1261 static const enum index item_gtp_psc[] = {
1268 static const enum index item_pppoed[] = {
1274 static const enum index item_pppoes[] = {
1280 static const enum index item_pppoe_proto_id[] = {
1285 static const enum index item_higig2[] = {
1286 ITEM_HIGIG2_CLASSIFICATION,
1292 static const enum index item_esp[] = {
1298 static const enum index item_ah[] = {
1304 static const enum index item_pfcp[] = {
1311 static const enum index next_set_raw[] = {
1317 static const enum index item_tag[] = {
1324 static const enum index item_l2tpv3oip[] = {
1325 ITEM_L2TPV3OIP_SESSION_ID,
1330 static const enum index item_ecpri[] = {
1336 static const enum index item_ecpri_common[] = {
1337 ITEM_ECPRI_COMMON_TYPE,
1341 static const enum index item_ecpri_common_type[] = {
1342 ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
1343 ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
1344 ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
1348 static const enum index item_geneve_opt[] = {
1349 ITEM_GENEVE_OPT_CLASS,
1350 ITEM_GENEVE_OPT_TYPE,
1351 ITEM_GENEVE_OPT_LENGTH,
1352 ITEM_GENEVE_OPT_DATA,
1357 static const enum index item_integrity[] = {
1358 ITEM_INTEGRITY_LEVEL,
1359 ITEM_INTEGRITY_VALUE,
1363 static const enum index item_integrity_lv[] = {
1364 ITEM_INTEGRITY_LEVEL,
1365 ITEM_INTEGRITY_VALUE,
1370 static const enum index next_action[] = {
1387 ACTION_OF_SET_MPLS_TTL,
1388 ACTION_OF_DEC_MPLS_TTL,
1389 ACTION_OF_SET_NW_TTL,
1390 ACTION_OF_DEC_NW_TTL,
1391 ACTION_OF_COPY_TTL_OUT,
1392 ACTION_OF_COPY_TTL_IN,
1394 ACTION_OF_PUSH_VLAN,
1395 ACTION_OF_SET_VLAN_VID,
1396 ACTION_OF_SET_VLAN_PCP,
1398 ACTION_OF_PUSH_MPLS,
1405 ACTION_MPLSOGRE_ENCAP,
1406 ACTION_MPLSOGRE_DECAP,
1407 ACTION_MPLSOUDP_ENCAP,
1408 ACTION_MPLSOUDP_DECAP,
1409 ACTION_SET_IPV4_SRC,
1410 ACTION_SET_IPV4_DST,
1411 ACTION_SET_IPV6_SRC,
1412 ACTION_SET_IPV6_DST,
1428 ACTION_SET_IPV4_DSCP,
1429 ACTION_SET_IPV6_DSCP,
1433 ACTION_MODIFY_FIELD,
1435 ACTION_CONNTRACK_UPDATE,
1439 static const enum index action_mark[] = {
1445 static const enum index action_queue[] = {
1451 static const enum index action_count[] = {
1457 static const enum index action_rss[] = {
1468 static const enum index action_vf[] = {
1475 static const enum index action_phy_port[] = {
1476 ACTION_PHY_PORT_ORIGINAL,
1477 ACTION_PHY_PORT_INDEX,
1482 static const enum index action_port_id[] = {
1483 ACTION_PORT_ID_ORIGINAL,
1489 static const enum index action_meter[] = {
1495 static const enum index action_meter_color[] = {
1496 ACTION_METER_COLOR_TYPE,
1501 static const enum index action_of_set_mpls_ttl[] = {
1502 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
1507 static const enum index action_of_set_nw_ttl[] = {
1508 ACTION_OF_SET_NW_TTL_NW_TTL,
1513 static const enum index action_of_push_vlan[] = {
1514 ACTION_OF_PUSH_VLAN_ETHERTYPE,
1519 static const enum index action_of_set_vlan_vid[] = {
1520 ACTION_OF_SET_VLAN_VID_VLAN_VID,
1525 static const enum index action_of_set_vlan_pcp[] = {
1526 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
1531 static const enum index action_of_pop_mpls[] = {
1532 ACTION_OF_POP_MPLS_ETHERTYPE,
1537 static const enum index action_of_push_mpls[] = {
1538 ACTION_OF_PUSH_MPLS_ETHERTYPE,
1543 static const enum index action_set_ipv4_src[] = {
1544 ACTION_SET_IPV4_SRC_IPV4_SRC,
1549 static const enum index action_set_mac_src[] = {
1550 ACTION_SET_MAC_SRC_MAC_SRC,
1555 static const enum index action_set_ipv4_dst[] = {
1556 ACTION_SET_IPV4_DST_IPV4_DST,
1561 static const enum index action_set_ipv6_src[] = {
1562 ACTION_SET_IPV6_SRC_IPV6_SRC,
1567 static const enum index action_set_ipv6_dst[] = {
1568 ACTION_SET_IPV6_DST_IPV6_DST,
1573 static const enum index action_set_tp_src[] = {
1574 ACTION_SET_TP_SRC_TP_SRC,
1579 static const enum index action_set_tp_dst[] = {
1580 ACTION_SET_TP_DST_TP_DST,
1585 static const enum index action_set_ttl[] = {
1591 static const enum index action_jump[] = {
1597 static const enum index action_set_mac_dst[] = {
1598 ACTION_SET_MAC_DST_MAC_DST,
1603 static const enum index action_inc_tcp_seq[] = {
1604 ACTION_INC_TCP_SEQ_VALUE,
1609 static const enum index action_dec_tcp_seq[] = {
1610 ACTION_DEC_TCP_SEQ_VALUE,
1615 static const enum index action_inc_tcp_ack[] = {
1616 ACTION_INC_TCP_ACK_VALUE,
1621 static const enum index action_dec_tcp_ack[] = {
1622 ACTION_DEC_TCP_ACK_VALUE,
1627 static const enum index action_raw_encap[] = {
1628 ACTION_RAW_ENCAP_INDEX,
1633 static const enum index action_raw_decap[] = {
1634 ACTION_RAW_DECAP_INDEX,
1639 static const enum index action_set_tag[] = {
1640 ACTION_SET_TAG_DATA,
1641 ACTION_SET_TAG_INDEX,
1642 ACTION_SET_TAG_MASK,
1647 static const enum index action_set_meta[] = {
1648 ACTION_SET_META_DATA,
1649 ACTION_SET_META_MASK,
1654 static const enum index action_set_ipv4_dscp[] = {
1655 ACTION_SET_IPV4_DSCP_VALUE,
1660 static const enum index action_set_ipv6_dscp[] = {
1661 ACTION_SET_IPV6_DSCP_VALUE,
1666 static const enum index action_age[] = {
1673 static const enum index action_sample[] = {
1675 ACTION_SAMPLE_RATIO,
1676 ACTION_SAMPLE_INDEX,
1681 static const enum index next_action_sample[] = {
1694 static const enum index action_modify_field_dst[] = {
1695 ACTION_MODIFY_FIELD_DST_LEVEL,
1696 ACTION_MODIFY_FIELD_DST_OFFSET,
1697 ACTION_MODIFY_FIELD_SRC_TYPE,
1701 static const enum index action_modify_field_src[] = {
1702 ACTION_MODIFY_FIELD_SRC_LEVEL,
1703 ACTION_MODIFY_FIELD_SRC_OFFSET,
1704 ACTION_MODIFY_FIELD_SRC_VALUE,
1705 ACTION_MODIFY_FIELD_WIDTH,
1709 static const enum index action_update_conntrack[] = {
1710 ACTION_CONNTRACK_UPDATE_DIR,
1711 ACTION_CONNTRACK_UPDATE_CTX,
1716 static int parse_set_raw_encap_decap(struct context *, const struct token *,
1717 const char *, unsigned int,
1718 void *, unsigned int);
1719 static int parse_set_sample_action(struct context *, const struct token *,
1720 const char *, unsigned int,
1721 void *, unsigned int);
1722 static int parse_set_init(struct context *, const struct token *,
1723 const char *, unsigned int,
1724 void *, unsigned int);
1725 static int parse_init(struct context *, const struct token *,
1726 const char *, unsigned int,
1727 void *, unsigned int);
1728 static int parse_vc(struct context *, const struct token *,
1729 const char *, unsigned int,
1730 void *, unsigned int);
1731 static int parse_vc_spec(struct context *, const struct token *,
1732 const char *, unsigned int, void *, unsigned int);
1733 static int parse_vc_conf(struct context *, const struct token *,
1734 const char *, unsigned int, void *, unsigned int);
1735 static int parse_vc_item_ecpri_type(struct context *, const struct token *,
1736 const char *, unsigned int,
1737 void *, unsigned int);
1738 static int parse_vc_action_meter_color_type(struct context *,
1739 const struct token *,
1740 const char *, unsigned int, void *,
1742 static int parse_vc_action_rss(struct context *, const struct token *,
1743 const char *, unsigned int, void *,
1745 static int parse_vc_action_rss_func(struct context *, const struct token *,
1746 const char *, unsigned int, void *,
1748 static int parse_vc_action_rss_type(struct context *, const struct token *,
1749 const char *, unsigned int, void *,
1751 static int parse_vc_action_rss_queue(struct context *, const struct token *,
1752 const char *, unsigned int, void *,
1754 static int parse_vc_action_vxlan_encap(struct context *, const struct token *,
1755 const char *, unsigned int, void *,
1757 static int parse_vc_action_nvgre_encap(struct context *, const struct token *,
1758 const char *, unsigned int, void *,
1760 static int parse_vc_action_l2_encap(struct context *, const struct token *,
1761 const char *, unsigned int, void *,
1763 static int parse_vc_action_l2_decap(struct context *, const struct token *,
1764 const char *, unsigned int, void *,
1766 static int parse_vc_action_mplsogre_encap(struct context *,
1767 const struct token *, const char *,
1768 unsigned int, void *, unsigned int);
1769 static int parse_vc_action_mplsogre_decap(struct context *,
1770 const struct token *, const char *,
1771 unsigned int, void *, unsigned int);
1772 static int parse_vc_action_mplsoudp_encap(struct context *,
1773 const struct token *, const char *,
1774 unsigned int, void *, unsigned int);
1775 static int parse_vc_action_mplsoudp_decap(struct context *,
1776 const struct token *, const char *,
1777 unsigned int, void *, unsigned int);
1778 static int parse_vc_action_raw_encap(struct context *,
1779 const struct token *, const char *,
1780 unsigned int, void *, unsigned int);
1781 static int parse_vc_action_raw_decap(struct context *,
1782 const struct token *, const char *,
1783 unsigned int, void *, unsigned int);
1784 static int parse_vc_action_raw_encap_index(struct context *,
1785 const struct token *, const char *,
1786 unsigned int, void *, unsigned int);
1787 static int parse_vc_action_raw_decap_index(struct context *,
1788 const struct token *, const char *,
1789 unsigned int, void *, unsigned int);
1790 static int parse_vc_action_set_meta(struct context *ctx,
1791 const struct token *token, const char *str,
1792 unsigned int len, void *buf,
1794 static int parse_vc_action_sample(struct context *ctx,
1795 const struct token *token, const char *str,
1796 unsigned int len, void *buf,
1799 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
1800 const char *str, unsigned int len, void *buf,
1803 parse_vc_modify_field_op(struct context *ctx, const struct token *token,
1804 const char *str, unsigned int len, void *buf,
1807 parse_vc_modify_field_id(struct context *ctx, const struct token *token,
1808 const char *str, unsigned int len, void *buf,
1811 parse_vc_action_conntrack_update(struct context *ctx, const struct token *token,
1812 const char *str, unsigned int len, void *buf,
1814 static int parse_destroy(struct context *, const struct token *,
1815 const char *, unsigned int,
1816 void *, unsigned int);
1817 static int parse_flush(struct context *, const struct token *,
1818 const char *, unsigned int,
1819 void *, unsigned int);
1820 static int parse_dump(struct context *, const struct token *,
1821 const char *, unsigned int,
1822 void *, unsigned int);
1823 static int parse_query(struct context *, const struct token *,
1824 const char *, unsigned int,
1825 void *, unsigned int);
1826 static int parse_action(struct context *, const struct token *,
1827 const char *, unsigned int,
1828 void *, unsigned int);
1829 static int parse_list(struct context *, const struct token *,
1830 const char *, unsigned int,
1831 void *, unsigned int);
1832 static int parse_aged(struct context *, const struct token *,
1833 const char *, unsigned int,
1834 void *, unsigned int);
1835 static int parse_isolate(struct context *, const struct token *,
1836 const char *, unsigned int,
1837 void *, unsigned int);
1838 static int parse_tunnel(struct context *, const struct token *,
1839 const char *, unsigned int,
1840 void *, unsigned int);
1841 static int parse_int(struct context *, const struct token *,
1842 const char *, unsigned int,
1843 void *, unsigned int);
1844 static int parse_prefix(struct context *, const struct token *,
1845 const char *, unsigned int,
1846 void *, unsigned int);
1847 static int parse_boolean(struct context *, const struct token *,
1848 const char *, unsigned int,
1849 void *, unsigned int);
1850 static int parse_string(struct context *, const struct token *,
1851 const char *, unsigned int,
1852 void *, unsigned int);
1853 static int parse_hex(struct context *ctx, const struct token *token,
1854 const char *str, unsigned int len,
1855 void *buf, unsigned int size);
1856 static int parse_string0(struct context *, const struct token *,
1857 const char *, unsigned int,
1858 void *, unsigned int);
1859 static int parse_mac_addr(struct context *, const struct token *,
1860 const char *, unsigned int,
1861 void *, unsigned int);
1862 static int parse_ipv4_addr(struct context *, const struct token *,
1863 const char *, unsigned int,
1864 void *, unsigned int);
1865 static int parse_ipv6_addr(struct context *, const struct token *,
1866 const char *, unsigned int,
1867 void *, unsigned int);
1868 static int parse_port(struct context *, const struct token *,
1869 const char *, unsigned int,
1870 void *, unsigned int);
1871 static int parse_ia(struct context *, const struct token *,
1872 const char *, unsigned int,
1873 void *, unsigned int);
1874 static int parse_ia_destroy(struct context *ctx, const struct token *token,
1875 const char *str, unsigned int len,
1876 void *buf, unsigned int size);
1877 static int parse_ia_id2ptr(struct context *ctx, const struct token *token,
1878 const char *str, unsigned int len, void *buf,
1880 static int parse_mp(struct context *, const struct token *,
1881 const char *, unsigned int,
1882 void *, unsigned int);
1883 static int comp_none(struct context *, const struct token *,
1884 unsigned int, char *, unsigned int);
1885 static int comp_boolean(struct context *, const struct token *,
1886 unsigned int, char *, unsigned int);
1887 static int comp_action(struct context *, const struct token *,
1888 unsigned int, char *, unsigned int);
1889 static int comp_port(struct context *, const struct token *,
1890 unsigned int, char *, unsigned int);
1891 static int comp_rule_id(struct context *, const struct token *,
1892 unsigned int, char *, unsigned int);
1893 static int comp_vc_action_rss_type(struct context *, const struct token *,
1894 unsigned int, char *, unsigned int);
1895 static int comp_vc_action_rss_queue(struct context *, const struct token *,
1896 unsigned int, char *, unsigned int);
1897 static int comp_set_raw_index(struct context *, const struct token *,
1898 unsigned int, char *, unsigned int);
1899 static int comp_set_sample_index(struct context *, const struct token *,
1900 unsigned int, char *, unsigned int);
1901 static int comp_set_modify_field_op(struct context *, const struct token *,
1902 unsigned int, char *, unsigned int);
1903 static int comp_set_modify_field_id(struct context *, const struct token *,
1904 unsigned int, char *, unsigned int);
1906 /** Token definitions. */
1907 static const struct token token_list[] = {
1908 /* Special tokens. */
1911 .help = "null entry, abused as the entry point",
1912 .next = NEXT(NEXT_ENTRY(FLOW, ADD)),
1917 .help = "command may end here",
1920 .name = "START_SET",
1921 .help = "null entry, abused as the entry point for set",
1922 .next = NEXT(NEXT_ENTRY(SET)),
1927 .help = "set command may end here",
1929 /* Common tokens. */
1930 [COMMON_INTEGER] = {
1933 .help = "integer value",
1937 [COMMON_UNSIGNED] = {
1938 .name = "{unsigned}",
1940 .help = "unsigned integer value",
1947 .help = "prefix length for bit-mask",
1948 .call = parse_prefix,
1951 [COMMON_BOOLEAN] = {
1952 .name = "{boolean}",
1954 .help = "any boolean value",
1955 .call = parse_boolean,
1956 .comp = comp_boolean,
1961 .help = "fixed string",
1962 .call = parse_string,
1968 .help = "fixed string",
1971 [COMMON_FILE_PATH] = {
1972 .name = "{file path}",
1974 .help = "file path",
1975 .call = parse_string0,
1978 [COMMON_MAC_ADDR] = {
1979 .name = "{MAC address}",
1981 .help = "standard MAC address notation",
1982 .call = parse_mac_addr,
1985 [COMMON_IPV4_ADDR] = {
1986 .name = "{IPv4 address}",
1987 .type = "IPV4 ADDRESS",
1988 .help = "standard IPv4 address notation",
1989 .call = parse_ipv4_addr,
1992 [COMMON_IPV6_ADDR] = {
1993 .name = "{IPv6 address}",
1994 .type = "IPV6 ADDRESS",
1995 .help = "standard IPv6 address notation",
1996 .call = parse_ipv6_addr,
1999 [COMMON_RULE_ID] = {
2000 .name = "{rule id}",
2002 .help = "rule identifier",
2004 .comp = comp_rule_id,
2006 [COMMON_PORT_ID] = {
2007 .name = "{port_id}",
2009 .help = "port identifier",
2013 [COMMON_GROUP_ID] = {
2014 .name = "{group_id}",
2016 .help = "group identifier",
2020 [COMMON_PRIORITY_LEVEL] = {
2023 .help = "priority level",
2027 [COMMON_INDIRECT_ACTION_ID] = {
2028 .name = "{indirect_action_id}",
2029 .type = "INDIRECT_ACTION_ID",
2030 .help = "indirect action id",
2034 [COMMON_POLICY_ID] = {
2035 .name = "{policy_id}",
2036 .type = "POLCIY_ID",
2037 .help = "policy id",
2041 /* Top-level command. */
2044 .type = "{command} {port_id} [{arg} [...]]",
2045 .help = "manage ingress/egress flow rules",
2046 .next = NEXT(NEXT_ENTRY
2060 /* Top-level command. */
2061 [INDIRECT_ACTION] = {
2062 .name = "indirect_action",
2063 .type = "{command} {port_id} [{arg} [...]]",
2064 .help = "manage indirect actions",
2065 .next = NEXT(next_ia_subcmd, NEXT_ENTRY(COMMON_PORT_ID)),
2066 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2069 /* Sub-level commands. */
2070 [INDIRECT_ACTION_CREATE] = {
2072 .help = "create indirect action",
2073 .next = NEXT(next_ia_create_attr),
2076 [INDIRECT_ACTION_UPDATE] = {
2078 .help = "update indirect action",
2079 .next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_SPEC),
2080 NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
2081 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
2084 [INDIRECT_ACTION_DESTROY] = {
2086 .help = "destroy indirect action",
2087 .next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_DESTROY_ID)),
2088 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2089 .call = parse_ia_destroy,
2091 [INDIRECT_ACTION_QUERY] = {
2093 .help = "query indirect action",
2094 .next = NEXT(NEXT_ENTRY(END),
2095 NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
2096 .args = ARGS(ARGS_ENTRY(struct buffer, args.ia.action_id)),
2101 .help = "check whether a flow rule can be created",
2102 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_PORT_ID)),
2103 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2108 .help = "create a flow rule",
2109 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_PORT_ID)),
2110 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2115 .help = "destroy specific flow rules",
2116 .next = NEXT(NEXT_ENTRY(DESTROY_RULE),
2117 NEXT_ENTRY(COMMON_PORT_ID)),
2118 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2119 .call = parse_destroy,
2123 .help = "destroy all flow rules",
2124 .next = NEXT(NEXT_ENTRY(COMMON_PORT_ID)),
2125 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2126 .call = parse_flush,
2130 .help = "dump single/all flow rules to file",
2131 .next = NEXT(next_dump_subcmd, NEXT_ENTRY(COMMON_PORT_ID)),
2132 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2137 .help = "query an existing flow rule",
2138 .next = NEXT(NEXT_ENTRY(QUERY_ACTION),
2139 NEXT_ENTRY(COMMON_RULE_ID),
2140 NEXT_ENTRY(COMMON_PORT_ID)),
2141 .args = ARGS(ARGS_ENTRY(struct buffer, args.query.action.type),
2142 ARGS_ENTRY(struct buffer, args.query.rule),
2143 ARGS_ENTRY(struct buffer, port)),
2144 .call = parse_query,
2148 .help = "list existing flow rules",
2149 .next = NEXT(next_list_attr, NEXT_ENTRY(COMMON_PORT_ID)),
2150 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2155 .help = "list and destroy aged flows",
2156 .next = NEXT(next_aged_attr, NEXT_ENTRY(COMMON_PORT_ID)),
2157 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2162 .help = "restrict ingress traffic to the defined flow rules",
2163 .next = NEXT(NEXT_ENTRY(COMMON_BOOLEAN),
2164 NEXT_ENTRY(COMMON_PORT_ID)),
2165 .args = ARGS(ARGS_ENTRY(struct buffer, args.isolate.set),
2166 ARGS_ENTRY(struct buffer, port)),
2167 .call = parse_isolate,
2171 .help = "new tunnel API",
2172 .next = NEXT(NEXT_ENTRY
2173 (TUNNEL_CREATE, TUNNEL_LIST, TUNNEL_DESTROY)),
2174 .call = parse_tunnel,
2176 /* Tunnel arguments. */
2179 .help = "create new tunnel object",
2180 .next = NEXT(NEXT_ENTRY(TUNNEL_CREATE_TYPE),
2181 NEXT_ENTRY(COMMON_PORT_ID)),
2182 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2183 .call = parse_tunnel,
2185 [TUNNEL_CREATE_TYPE] = {
2187 .help = "create new tunnel",
2188 .next = NEXT(NEXT_ENTRY(COMMON_FILE_PATH)),
2189 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, type)),
2190 .call = parse_tunnel,
2192 [TUNNEL_DESTROY] = {
2194 .help = "destroy tunel",
2195 .next = NEXT(NEXT_ENTRY(TUNNEL_DESTROY_ID),
2196 NEXT_ENTRY(COMMON_PORT_ID)),
2197 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2198 .call = parse_tunnel,
2200 [TUNNEL_DESTROY_ID] = {
2202 .help = "tunnel identifier to testroy",
2203 .next = NEXT(NEXT_ENTRY(COMMON_UNSIGNED)),
2204 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2205 .call = parse_tunnel,
2209 .help = "list existing tunnels",
2210 .next = NEXT(NEXT_ENTRY(COMMON_PORT_ID)),
2211 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2212 .call = parse_tunnel,
2214 /* Destroy arguments. */
2217 .help = "specify a rule identifier",
2218 .next = NEXT(next_destroy_attr, NEXT_ENTRY(COMMON_RULE_ID)),
2219 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.destroy.rule)),
2220 .call = parse_destroy,
2222 /* Dump arguments. */
2226 .next = NEXT(next_dump_attr),
2227 .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file)),
2232 .help = "dump one rule",
2233 .next = NEXT(next_dump_attr, NEXT_ENTRY(COMMON_RULE_ID)),
2234 .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file),
2235 ARGS_ENTRY(struct buffer, args.dump.rule)),
2238 /* Query arguments. */
2242 .help = "action to query, must be part of the rule",
2243 .call = parse_action,
2244 .comp = comp_action,
2246 /* List arguments. */
2249 .help = "specify a group",
2250 .next = NEXT(next_list_attr, NEXT_ENTRY(COMMON_GROUP_ID)),
2251 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.list.group)),
2256 .help = "specify aged flows need be destroyed",
2260 /* Validate/create attributes. */
2263 .help = "specify a group",
2264 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_GROUP_ID)),
2265 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, group)),
2270 .help = "specify a priority level",
2271 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_PRIORITY_LEVEL)),
2272 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, priority)),
2277 .help = "affect rule to ingress",
2278 .next = NEXT(next_vc_attr),
2283 .help = "affect rule to egress",
2284 .next = NEXT(next_vc_attr),
2289 .help = "apply rule directly to endpoints found in pattern",
2290 .next = NEXT(next_vc_attr),
2294 .name = "tunnel_set",
2295 .help = "tunnel steer rule",
2296 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_UNSIGNED)),
2297 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2300 [VC_TUNNEL_MATCH] = {
2301 .name = "tunnel_match",
2302 .help = "tunnel match rule",
2303 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_UNSIGNED)),
2304 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2307 /* Validate/create pattern. */
2310 .help = "submit a list of pattern items",
2311 .next = NEXT(next_item),
2316 .help = "match value perfectly (with full bit-mask)",
2317 .call = parse_vc_spec,
2319 [ITEM_PARAM_SPEC] = {
2321 .help = "match value according to configured bit-mask",
2322 .call = parse_vc_spec,
2324 [ITEM_PARAM_LAST] = {
2326 .help = "specify upper bound to establish a range",
2327 .call = parse_vc_spec,
2329 [ITEM_PARAM_MASK] = {
2331 .help = "specify bit-mask with relevant bits set to one",
2332 .call = parse_vc_spec,
2334 [ITEM_PARAM_PREFIX] = {
2336 .help = "generate bit-mask from a prefix length",
2337 .call = parse_vc_spec,
2341 .help = "specify next pattern item",
2342 .next = NEXT(next_item),
2346 .help = "end list of pattern items",
2347 .priv = PRIV_ITEM(END, 0),
2348 .next = NEXT(NEXT_ENTRY(ACTIONS)),
2353 .help = "no-op pattern item",
2354 .priv = PRIV_ITEM(VOID, 0),
2355 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2360 .help = "perform actions when pattern does not match",
2361 .priv = PRIV_ITEM(INVERT, 0),
2362 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2367 .help = "match any protocol for the current layer",
2368 .priv = PRIV_ITEM(ANY, sizeof(struct rte_flow_item_any)),
2369 .next = NEXT(item_any),
2374 .help = "number of layers covered",
2375 .next = NEXT(item_any, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2376 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_any, num)),
2380 .help = "match traffic from/to the physical function",
2381 .priv = PRIV_ITEM(PF, 0),
2382 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2387 .help = "match traffic from/to a virtual function ID",
2388 .priv = PRIV_ITEM(VF, sizeof(struct rte_flow_item_vf)),
2389 .next = NEXT(item_vf),
2395 .next = NEXT(item_vf, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2396 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_vf, id)),
2400 .help = "match traffic from/to a specific physical port",
2401 .priv = PRIV_ITEM(PHY_PORT,
2402 sizeof(struct rte_flow_item_phy_port)),
2403 .next = NEXT(item_phy_port),
2406 [ITEM_PHY_PORT_INDEX] = {
2408 .help = "physical port index",
2409 .next = NEXT(item_phy_port, NEXT_ENTRY(COMMON_UNSIGNED),
2411 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_phy_port, index)),
2415 .help = "match traffic from/to a given DPDK port ID",
2416 .priv = PRIV_ITEM(PORT_ID,
2417 sizeof(struct rte_flow_item_port_id)),
2418 .next = NEXT(item_port_id),
2421 [ITEM_PORT_ID_ID] = {
2423 .help = "DPDK port ID",
2424 .next = NEXT(item_port_id, NEXT_ENTRY(COMMON_UNSIGNED),
2426 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port_id, id)),
2430 .help = "match traffic against value set in previously matched rule",
2431 .priv = PRIV_ITEM(MARK, sizeof(struct rte_flow_item_mark)),
2432 .next = NEXT(item_mark),
2437 .help = "Integer value to match against",
2438 .next = NEXT(item_mark, NEXT_ENTRY(COMMON_UNSIGNED),
2440 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_mark, id)),
2444 .help = "match an arbitrary byte string",
2445 .priv = PRIV_ITEM(RAW, ITEM_RAW_SIZE),
2446 .next = NEXT(item_raw),
2449 [ITEM_RAW_RELATIVE] = {
2451 .help = "look for pattern after the previous item",
2452 .next = NEXT(item_raw, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
2453 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
2456 [ITEM_RAW_SEARCH] = {
2458 .help = "search pattern from offset (see also limit)",
2459 .next = NEXT(item_raw, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
2460 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
2463 [ITEM_RAW_OFFSET] = {
2465 .help = "absolute or relative offset for pattern",
2466 .next = NEXT(item_raw, NEXT_ENTRY(COMMON_INTEGER), item_param),
2467 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, offset)),
2469 [ITEM_RAW_LIMIT] = {
2471 .help = "search area limit for start of pattern",
2472 .next = NEXT(item_raw, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2473 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, limit)),
2475 [ITEM_RAW_PATTERN] = {
2477 .help = "byte string to look for",
2478 .next = NEXT(item_raw,
2479 NEXT_ENTRY(COMMON_STRING),
2480 NEXT_ENTRY(ITEM_PARAM_IS,
2483 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern),
2484 ARGS_ENTRY(struct rte_flow_item_raw, length),
2485 ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw),
2486 ITEM_RAW_PATTERN_SIZE)),
2490 .help = "match Ethernet header",
2491 .priv = PRIV_ITEM(ETH, sizeof(struct rte_flow_item_eth)),
2492 .next = NEXT(item_eth),
2497 .help = "destination MAC",
2498 .next = NEXT(item_eth, NEXT_ENTRY(COMMON_MAC_ADDR), item_param),
2499 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, dst)),
2503 .help = "source MAC",
2504 .next = NEXT(item_eth, NEXT_ENTRY(COMMON_MAC_ADDR), item_param),
2505 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, src)),
2509 .help = "EtherType",
2510 .next = NEXT(item_eth, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2511 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, type)),
2513 [ITEM_ETH_HAS_VLAN] = {
2515 .help = "packet header contains VLAN",
2516 .next = NEXT(item_eth, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2517 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_eth,
2522 .help = "match 802.1Q/ad VLAN tag",
2523 .priv = PRIV_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)),
2524 .next = NEXT(item_vlan),
2529 .help = "tag control information",
2530 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
2532 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, tci)),
2536 .help = "priority code point",
2537 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
2539 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2544 .help = "drop eligible indicator",
2545 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
2547 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2552 .help = "VLAN identifier",
2553 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
2555 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2558 [ITEM_VLAN_INNER_TYPE] = {
2559 .name = "inner_type",
2560 .help = "inner EtherType",
2561 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
2563 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan,
2566 [ITEM_VLAN_HAS_MORE_VLAN] = {
2567 .name = "has_more_vlan",
2568 .help = "packet header contains another VLAN",
2569 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
2571 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vlan,
2576 .help = "match IPv4 header",
2577 .priv = PRIV_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)),
2578 .next = NEXT(item_ipv4),
2581 [ITEM_IPV4_VER_IHL] = {
2582 .name = "version_ihl",
2583 .help = "match header length",
2584 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
2586 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ipv4,
2591 .help = "type of service",
2592 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
2594 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2595 hdr.type_of_service)),
2598 .name = "packet_id",
2599 .help = "fragment packet id",
2600 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
2602 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2605 [ITEM_IPV4_FRAGMENT_OFFSET] = {
2606 .name = "fragment_offset",
2607 .help = "fragmentation flags and fragment offset",
2608 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
2610 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2611 hdr.fragment_offset)),
2615 .help = "time to live",
2616 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
2618 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2621 [ITEM_IPV4_PROTO] = {
2623 .help = "next protocol ID",
2624 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
2626 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2627 hdr.next_proto_id)),
2631 .help = "source address",
2632 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
2634 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2639 .help = "destination address",
2640 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
2642 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2647 .help = "match IPv6 header",
2648 .priv = PRIV_ITEM(IPV6, sizeof(struct rte_flow_item_ipv6)),
2649 .next = NEXT(item_ipv6),
2654 .help = "traffic class",
2655 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
2657 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2659 "\x0f\xf0\x00\x00")),
2661 [ITEM_IPV6_FLOW] = {
2663 .help = "flow label",
2664 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
2666 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2668 "\x00\x0f\xff\xff")),
2670 [ITEM_IPV6_PROTO] = {
2672 .help = "protocol (next header)",
2673 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
2675 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2680 .help = "hop limit",
2681 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
2683 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2688 .help = "source address",
2689 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_IPV6_ADDR),
2691 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2696 .help = "destination address",
2697 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_IPV6_ADDR),
2699 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2702 [ITEM_IPV6_HAS_FRAG_EXT] = {
2703 .name = "has_frag_ext",
2704 .help = "fragment packet attribute",
2705 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
2707 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_ipv6,
2712 .help = "match ICMP header",
2713 .priv = PRIV_ITEM(ICMP, sizeof(struct rte_flow_item_icmp)),
2714 .next = NEXT(item_icmp),
2717 [ITEM_ICMP_TYPE] = {
2719 .help = "ICMP packet type",
2720 .next = NEXT(item_icmp, NEXT_ENTRY(COMMON_UNSIGNED),
2722 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2725 [ITEM_ICMP_CODE] = {
2727 .help = "ICMP packet code",
2728 .next = NEXT(item_icmp, NEXT_ENTRY(COMMON_UNSIGNED),
2730 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2733 [ITEM_ICMP_IDENT] = {
2735 .help = "ICMP packet identifier",
2736 .next = NEXT(item_icmp, NEXT_ENTRY(COMMON_UNSIGNED),
2738 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2743 .help = "ICMP packet sequence number",
2744 .next = NEXT(item_icmp, NEXT_ENTRY(COMMON_UNSIGNED),
2746 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2751 .help = "match UDP header",
2752 .priv = PRIV_ITEM(UDP, sizeof(struct rte_flow_item_udp)),
2753 .next = NEXT(item_udp),
2758 .help = "UDP source port",
2759 .next = NEXT(item_udp, NEXT_ENTRY(COMMON_UNSIGNED),
2761 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2766 .help = "UDP destination port",
2767 .next = NEXT(item_udp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2768 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2773 .help = "match TCP header",
2774 .priv = PRIV_ITEM(TCP, sizeof(struct rte_flow_item_tcp)),
2775 .next = NEXT(item_tcp),
2780 .help = "TCP source port",
2781 .next = NEXT(item_tcp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2782 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2787 .help = "TCP destination port",
2788 .next = NEXT(item_tcp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2789 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2792 [ITEM_TCP_FLAGS] = {
2794 .help = "TCP flags",
2795 .next = NEXT(item_tcp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2796 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2801 .help = "match SCTP header",
2802 .priv = PRIV_ITEM(SCTP, sizeof(struct rte_flow_item_sctp)),
2803 .next = NEXT(item_sctp),
2808 .help = "SCTP source port",
2809 .next = NEXT(item_sctp, NEXT_ENTRY(COMMON_UNSIGNED),
2811 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2816 .help = "SCTP destination port",
2817 .next = NEXT(item_sctp, NEXT_ENTRY(COMMON_UNSIGNED),
2819 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2824 .help = "validation tag",
2825 .next = NEXT(item_sctp, NEXT_ENTRY(COMMON_UNSIGNED),
2827 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2830 [ITEM_SCTP_CKSUM] = {
2833 .next = NEXT(item_sctp, NEXT_ENTRY(COMMON_UNSIGNED),
2835 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2840 .help = "match VXLAN header",
2841 .priv = PRIV_ITEM(VXLAN, sizeof(struct rte_flow_item_vxlan)),
2842 .next = NEXT(item_vxlan),
2845 [ITEM_VXLAN_VNI] = {
2847 .help = "VXLAN identifier",
2848 .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
2850 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan, vni)),
2852 [ITEM_VXLAN_LAST_RSVD] = {
2853 .name = "last_rsvd",
2854 .help = "VXLAN last reserved bits",
2855 .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
2857 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan,
2862 .help = "match E-Tag header",
2863 .priv = PRIV_ITEM(E_TAG, sizeof(struct rte_flow_item_e_tag)),
2864 .next = NEXT(item_e_tag),
2867 [ITEM_E_TAG_GRP_ECID_B] = {
2868 .name = "grp_ecid_b",
2869 .help = "GRP and E-CID base",
2870 .next = NEXT(item_e_tag, NEXT_ENTRY(COMMON_UNSIGNED),
2872 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_e_tag,
2878 .help = "match NVGRE header",
2879 .priv = PRIV_ITEM(NVGRE, sizeof(struct rte_flow_item_nvgre)),
2880 .next = NEXT(item_nvgre),
2883 [ITEM_NVGRE_TNI] = {
2885 .help = "virtual subnet ID",
2886 .next = NEXT(item_nvgre, NEXT_ENTRY(COMMON_UNSIGNED),
2888 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_nvgre, tni)),
2892 .help = "match MPLS header",
2893 .priv = PRIV_ITEM(MPLS, sizeof(struct rte_flow_item_mpls)),
2894 .next = NEXT(item_mpls),
2897 [ITEM_MPLS_LABEL] = {
2899 .help = "MPLS label",
2900 .next = NEXT(item_mpls, NEXT_ENTRY(COMMON_UNSIGNED),
2902 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2908 .help = "MPLS Traffic Class",
2909 .next = NEXT(item_mpls, NEXT_ENTRY(COMMON_UNSIGNED),
2911 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2917 .help = "MPLS Bottom-of-Stack",
2918 .next = NEXT(item_mpls, NEXT_ENTRY(COMMON_UNSIGNED),
2920 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2926 .help = "match GRE header",
2927 .priv = PRIV_ITEM(GRE, sizeof(struct rte_flow_item_gre)),
2928 .next = NEXT(item_gre),
2931 [ITEM_GRE_PROTO] = {
2933 .help = "GRE protocol type",
2934 .next = NEXT(item_gre, NEXT_ENTRY(COMMON_UNSIGNED),
2936 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2939 [ITEM_GRE_C_RSVD0_VER] = {
2940 .name = "c_rsvd0_ver",
2942 "checksum (1b), undefined (1b), key bit (1b),"
2943 " sequence number (1b), reserved 0 (9b),"
2945 .next = NEXT(item_gre, NEXT_ENTRY(COMMON_UNSIGNED),
2947 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2950 [ITEM_GRE_C_BIT] = {
2952 .help = "checksum bit (C)",
2953 .next = NEXT(item_gre, NEXT_ENTRY(COMMON_BOOLEAN),
2955 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2957 "\x80\x00\x00\x00")),
2959 [ITEM_GRE_S_BIT] = {
2961 .help = "sequence number bit (S)",
2962 .next = NEXT(item_gre, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
2963 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2965 "\x10\x00\x00\x00")),
2967 [ITEM_GRE_K_BIT] = {
2969 .help = "key bit (K)",
2970 .next = NEXT(item_gre, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
2971 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2973 "\x20\x00\x00\x00")),
2977 .help = "fuzzy pattern match, expect faster than default",
2978 .priv = PRIV_ITEM(FUZZY,
2979 sizeof(struct rte_flow_item_fuzzy)),
2980 .next = NEXT(item_fuzzy),
2983 [ITEM_FUZZY_THRESH] = {
2985 .help = "match accuracy threshold",
2986 .next = NEXT(item_fuzzy, NEXT_ENTRY(COMMON_UNSIGNED),
2988 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_fuzzy,
2993 .help = "match GTP header",
2994 .priv = PRIV_ITEM(GTP, sizeof(struct rte_flow_item_gtp)),
2995 .next = NEXT(item_gtp),
2998 [ITEM_GTP_FLAGS] = {
2999 .name = "v_pt_rsv_flags",
3000 .help = "GTP flags",
3001 .next = NEXT(item_gtp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3002 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp,
3005 [ITEM_GTP_MSG_TYPE] = {
3007 .help = "GTP message type",
3008 .next = NEXT(item_gtp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3009 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp, msg_type)),
3013 .help = "tunnel endpoint identifier",
3014 .next = NEXT(item_gtp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3015 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp, teid)),
3019 .help = "match GTP header",
3020 .priv = PRIV_ITEM(GTPC, sizeof(struct rte_flow_item_gtp)),
3021 .next = NEXT(item_gtp),
3026 .help = "match GTP header",
3027 .priv = PRIV_ITEM(GTPU, sizeof(struct rte_flow_item_gtp)),
3028 .next = NEXT(item_gtp),
3033 .help = "match GENEVE header",
3034 .priv = PRIV_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)),
3035 .next = NEXT(item_geneve),
3038 [ITEM_GENEVE_VNI] = {
3040 .help = "virtual network identifier",
3041 .next = NEXT(item_geneve, NEXT_ENTRY(COMMON_UNSIGNED),
3043 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve, vni)),
3045 [ITEM_GENEVE_PROTO] = {
3047 .help = "GENEVE protocol type",
3048 .next = NEXT(item_geneve, NEXT_ENTRY(COMMON_UNSIGNED),
3050 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve,
3053 [ITEM_GENEVE_OPTLEN] = {
3055 .help = "GENEVE options length in dwords",
3056 .next = NEXT(item_geneve, NEXT_ENTRY(COMMON_UNSIGNED),
3058 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_geneve,
3059 ver_opt_len_o_c_rsvd0,
3062 [ITEM_VXLAN_GPE] = {
3063 .name = "vxlan-gpe",
3064 .help = "match VXLAN-GPE header",
3065 .priv = PRIV_ITEM(VXLAN_GPE,
3066 sizeof(struct rte_flow_item_vxlan_gpe)),
3067 .next = NEXT(item_vxlan_gpe),
3070 [ITEM_VXLAN_GPE_VNI] = {
3072 .help = "VXLAN-GPE identifier",
3073 .next = NEXT(item_vxlan_gpe, NEXT_ENTRY(COMMON_UNSIGNED),
3075 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
3078 [ITEM_ARP_ETH_IPV4] = {
3079 .name = "arp_eth_ipv4",
3080 .help = "match ARP header for Ethernet/IPv4",
3081 .priv = PRIV_ITEM(ARP_ETH_IPV4,
3082 sizeof(struct rte_flow_item_arp_eth_ipv4)),
3083 .next = NEXT(item_arp_eth_ipv4),
3086 [ITEM_ARP_ETH_IPV4_SHA] = {
3088 .help = "sender hardware address",
3089 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_MAC_ADDR),
3091 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
3094 [ITEM_ARP_ETH_IPV4_SPA] = {
3096 .help = "sender IPv4 address",
3097 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
3099 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
3102 [ITEM_ARP_ETH_IPV4_THA] = {
3104 .help = "target hardware address",
3105 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_MAC_ADDR),
3107 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
3110 [ITEM_ARP_ETH_IPV4_TPA] = {
3112 .help = "target IPv4 address",
3113 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
3115 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
3120 .help = "match presence of any IPv6 extension header",
3121 .priv = PRIV_ITEM(IPV6_EXT,
3122 sizeof(struct rte_flow_item_ipv6_ext)),
3123 .next = NEXT(item_ipv6_ext),
3126 [ITEM_IPV6_EXT_NEXT_HDR] = {
3128 .help = "next header",
3129 .next = NEXT(item_ipv6_ext, NEXT_ENTRY(COMMON_UNSIGNED),
3131 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_ext,
3134 [ITEM_IPV6_FRAG_EXT] = {
3135 .name = "ipv6_frag_ext",
3136 .help = "match presence of IPv6 fragment extension header",
3137 .priv = PRIV_ITEM(IPV6_FRAG_EXT,
3138 sizeof(struct rte_flow_item_ipv6_frag_ext)),
3139 .next = NEXT(item_ipv6_frag_ext),
3142 [ITEM_IPV6_FRAG_EXT_NEXT_HDR] = {
3144 .help = "next header",
3145 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(COMMON_UNSIGNED),
3147 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ipv6_frag_ext,
3150 [ITEM_IPV6_FRAG_EXT_FRAG_DATA] = {
3151 .name = "frag_data",
3152 .help = "fragment flags and offset",
3153 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(COMMON_UNSIGNED),
3155 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_frag_ext,
3158 [ITEM_IPV6_FRAG_EXT_ID] = {
3159 .name = "packet_id",
3160 .help = "fragment packet id",
3161 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(COMMON_UNSIGNED),
3163 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_frag_ext,
3168 .help = "match any ICMPv6 header",
3169 .priv = PRIV_ITEM(ICMP6, sizeof(struct rte_flow_item_icmp6)),
3170 .next = NEXT(item_icmp6),
3173 [ITEM_ICMP6_TYPE] = {
3175 .help = "ICMPv6 type",
3176 .next = NEXT(item_icmp6, NEXT_ENTRY(COMMON_UNSIGNED),
3178 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
3181 [ITEM_ICMP6_CODE] = {
3183 .help = "ICMPv6 code",
3184 .next = NEXT(item_icmp6, NEXT_ENTRY(COMMON_UNSIGNED),
3186 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
3189 [ITEM_ICMP6_ND_NS] = {
3190 .name = "icmp6_nd_ns",
3191 .help = "match ICMPv6 neighbor discovery solicitation",
3192 .priv = PRIV_ITEM(ICMP6_ND_NS,
3193 sizeof(struct rte_flow_item_icmp6_nd_ns)),
3194 .next = NEXT(item_icmp6_nd_ns),
3197 [ITEM_ICMP6_ND_NS_TARGET_ADDR] = {
3198 .name = "target_addr",
3199 .help = "target address",
3200 .next = NEXT(item_icmp6_nd_ns, NEXT_ENTRY(COMMON_IPV6_ADDR),
3202 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_ns,
3205 [ITEM_ICMP6_ND_NA] = {
3206 .name = "icmp6_nd_na",
3207 .help = "match ICMPv6 neighbor discovery advertisement",
3208 .priv = PRIV_ITEM(ICMP6_ND_NA,
3209 sizeof(struct rte_flow_item_icmp6_nd_na)),
3210 .next = NEXT(item_icmp6_nd_na),
3213 [ITEM_ICMP6_ND_NA_TARGET_ADDR] = {
3214 .name = "target_addr",
3215 .help = "target address",
3216 .next = NEXT(item_icmp6_nd_na, NEXT_ENTRY(COMMON_IPV6_ADDR),
3218 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_na,
3221 [ITEM_ICMP6_ND_OPT] = {
3222 .name = "icmp6_nd_opt",
3223 .help = "match presence of any ICMPv6 neighbor discovery"
3225 .priv = PRIV_ITEM(ICMP6_ND_OPT,
3226 sizeof(struct rte_flow_item_icmp6_nd_opt)),
3227 .next = NEXT(item_icmp6_nd_opt),
3230 [ITEM_ICMP6_ND_OPT_TYPE] = {
3232 .help = "ND option type",
3233 .next = NEXT(item_icmp6_nd_opt, NEXT_ENTRY(COMMON_UNSIGNED),
3235 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_opt,
3238 [ITEM_ICMP6_ND_OPT_SLA_ETH] = {
3239 .name = "icmp6_nd_opt_sla_eth",
3240 .help = "match ICMPv6 neighbor discovery source Ethernet"
3241 " link-layer address option",
3243 (ICMP6_ND_OPT_SLA_ETH,
3244 sizeof(struct rte_flow_item_icmp6_nd_opt_sla_eth)),
3245 .next = NEXT(item_icmp6_nd_opt_sla_eth),
3248 [ITEM_ICMP6_ND_OPT_SLA_ETH_SLA] = {
3250 .help = "source Ethernet LLA",
3251 .next = NEXT(item_icmp6_nd_opt_sla_eth,
3252 NEXT_ENTRY(COMMON_MAC_ADDR), item_param),
3253 .args = ARGS(ARGS_ENTRY_HTON
3254 (struct rte_flow_item_icmp6_nd_opt_sla_eth, sla)),
3256 [ITEM_ICMP6_ND_OPT_TLA_ETH] = {
3257 .name = "icmp6_nd_opt_tla_eth",
3258 .help = "match ICMPv6 neighbor discovery target Ethernet"
3259 " link-layer address option",
3261 (ICMP6_ND_OPT_TLA_ETH,
3262 sizeof(struct rte_flow_item_icmp6_nd_opt_tla_eth)),
3263 .next = NEXT(item_icmp6_nd_opt_tla_eth),
3266 [ITEM_ICMP6_ND_OPT_TLA_ETH_TLA] = {
3268 .help = "target Ethernet LLA",
3269 .next = NEXT(item_icmp6_nd_opt_tla_eth,
3270 NEXT_ENTRY(COMMON_MAC_ADDR), item_param),
3271 .args = ARGS(ARGS_ENTRY_HTON
3272 (struct rte_flow_item_icmp6_nd_opt_tla_eth, tla)),
3276 .help = "match metadata header",
3277 .priv = PRIV_ITEM(META, sizeof(struct rte_flow_item_meta)),
3278 .next = NEXT(item_meta),
3281 [ITEM_META_DATA] = {
3283 .help = "metadata value",
3284 .next = NEXT(item_meta, NEXT_ENTRY(COMMON_UNSIGNED),
3286 .args = ARGS(ARGS_ENTRY_MASK(struct rte_flow_item_meta,
3287 data, "\xff\xff\xff\xff")),
3291 .help = "match GRE key",
3292 .priv = PRIV_ITEM(GRE_KEY, sizeof(rte_be32_t)),
3293 .next = NEXT(item_gre_key),
3296 [ITEM_GRE_KEY_VALUE] = {
3298 .help = "key value",
3299 .next = NEXT(item_gre_key, NEXT_ENTRY(COMMON_UNSIGNED),
3301 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3305 .help = "match GTP extension header with type 0x85",
3306 .priv = PRIV_ITEM(GTP_PSC,
3307 sizeof(struct rte_flow_item_gtp_psc)),
3308 .next = NEXT(item_gtp_psc),
3311 [ITEM_GTP_PSC_QFI] = {
3313 .help = "QoS flow identifier",
3314 .next = NEXT(item_gtp_psc, NEXT_ENTRY(COMMON_UNSIGNED),
3316 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_gtp_psc,
3319 [ITEM_GTP_PSC_PDU_T] = {
3322 .next = NEXT(item_gtp_psc, NEXT_ENTRY(COMMON_UNSIGNED),
3324 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_gtp_psc,
3329 .help = "match PPPoE session header",
3330 .priv = PRIV_ITEM(PPPOES, sizeof(struct rte_flow_item_pppoe)),
3331 .next = NEXT(item_pppoes),
3336 .help = "match PPPoE discovery header",
3337 .priv = PRIV_ITEM(PPPOED, sizeof(struct rte_flow_item_pppoe)),
3338 .next = NEXT(item_pppoed),
3341 [ITEM_PPPOE_SEID] = {
3343 .help = "session identifier",
3344 .next = NEXT(item_pppoes, NEXT_ENTRY(COMMON_UNSIGNED),
3346 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pppoe,
3349 [ITEM_PPPOE_PROTO_ID] = {
3350 .name = "pppoe_proto_id",
3351 .help = "match PPPoE session protocol identifier",
3352 .priv = PRIV_ITEM(PPPOE_PROTO_ID,
3353 sizeof(struct rte_flow_item_pppoe_proto_id)),
3354 .next = NEXT(item_pppoe_proto_id, NEXT_ENTRY(COMMON_UNSIGNED),
3356 .args = ARGS(ARGS_ENTRY_HTON
3357 (struct rte_flow_item_pppoe_proto_id, proto_id)),
3362 .help = "matches higig2 header",
3363 .priv = PRIV_ITEM(HIGIG2,
3364 sizeof(struct rte_flow_item_higig2_hdr)),
3365 .next = NEXT(item_higig2),
3368 [ITEM_HIGIG2_CLASSIFICATION] = {
3369 .name = "classification",
3370 .help = "matches classification of higig2 header",
3371 .next = NEXT(item_higig2, NEXT_ENTRY(COMMON_UNSIGNED),
3373 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
3374 hdr.ppt1.classification)),
3376 [ITEM_HIGIG2_VID] = {
3378 .help = "matches vid of higig2 header",
3379 .next = NEXT(item_higig2, NEXT_ENTRY(COMMON_UNSIGNED),
3381 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
3386 .help = "match tag value",
3387 .priv = PRIV_ITEM(TAG, sizeof(struct rte_flow_item_tag)),
3388 .next = NEXT(item_tag),
3393 .help = "tag value to match",
3394 .next = NEXT(item_tag, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3395 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, data)),
3397 [ITEM_TAG_INDEX] = {
3399 .help = "index of tag array to match",
3400 .next = NEXT(item_tag, NEXT_ENTRY(COMMON_UNSIGNED),
3401 NEXT_ENTRY(ITEM_PARAM_IS)),
3402 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, index)),
3404 [ITEM_L2TPV3OIP] = {
3405 .name = "l2tpv3oip",
3406 .help = "match L2TPv3 over IP header",
3407 .priv = PRIV_ITEM(L2TPV3OIP,
3408 sizeof(struct rte_flow_item_l2tpv3oip)),
3409 .next = NEXT(item_l2tpv3oip),
3412 [ITEM_L2TPV3OIP_SESSION_ID] = {
3413 .name = "session_id",
3414 .help = "session identifier",
3415 .next = NEXT(item_l2tpv3oip, NEXT_ENTRY(COMMON_UNSIGNED),
3417 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv3oip,
3422 .help = "match ESP header",
3423 .priv = PRIV_ITEM(ESP, sizeof(struct rte_flow_item_esp)),
3424 .next = NEXT(item_esp),
3429 .help = "security policy index",
3430 .next = NEXT(item_esp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3431 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_esp,
3436 .help = "match AH header",
3437 .priv = PRIV_ITEM(AH, sizeof(struct rte_flow_item_ah)),
3438 .next = NEXT(item_ah),
3443 .help = "security parameters index",
3444 .next = NEXT(item_ah, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3445 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ah, spi)),
3449 .help = "match pfcp header",
3450 .priv = PRIV_ITEM(PFCP, sizeof(struct rte_flow_item_pfcp)),
3451 .next = NEXT(item_pfcp),
3454 [ITEM_PFCP_S_FIELD] = {
3457 .next = NEXT(item_pfcp, NEXT_ENTRY(COMMON_UNSIGNED),
3459 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp,
3462 [ITEM_PFCP_SEID] = {
3464 .help = "session endpoint identifier",
3465 .next = NEXT(item_pfcp, NEXT_ENTRY(COMMON_UNSIGNED),
3467 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp, seid)),
3471 .help = "match eCPRI header",
3472 .priv = PRIV_ITEM(ECPRI, sizeof(struct rte_flow_item_ecpri)),
3473 .next = NEXT(item_ecpri),
3476 [ITEM_ECPRI_COMMON] = {
3478 .help = "eCPRI common header",
3479 .next = NEXT(item_ecpri_common),
3481 [ITEM_ECPRI_COMMON_TYPE] = {
3483 .help = "type of common header",
3484 .next = NEXT(item_ecpri_common_type),
3485 .args = ARGS(ARG_ENTRY_HTON(struct rte_flow_item_ecpri)),
3487 [ITEM_ECPRI_COMMON_TYPE_IQ_DATA] = {
3489 .help = "Type #0: IQ Data",
3490 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
3492 .call = parse_vc_item_ecpri_type,
3494 [ITEM_ECPRI_MSG_IQ_DATA_PCID] = {
3496 .help = "Physical Channel ID",
3497 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
3498 ITEM_ECPRI_COMMON, ITEM_NEXT),
3499 NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3500 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3503 [ITEM_ECPRI_COMMON_TYPE_RTC_CTRL] = {
3505 .help = "Type #2: Real-Time Control Data",
3506 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
3508 .call = parse_vc_item_ecpri_type,
3510 [ITEM_ECPRI_MSG_RTC_CTRL_RTCID] = {
3512 .help = "Real-Time Control Data ID",
3513 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
3514 ITEM_ECPRI_COMMON, ITEM_NEXT),
3515 NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3516 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3519 [ITEM_ECPRI_COMMON_TYPE_DLY_MSR] = {
3520 .name = "delay_measure",
3521 .help = "Type #5: One-Way Delay Measurement",
3522 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
3524 .call = parse_vc_item_ecpri_type,
3526 [ITEM_ECPRI_MSG_DLY_MSR_MSRID] = {
3528 .help = "Measurement ID",
3529 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
3530 ITEM_ECPRI_COMMON, ITEM_NEXT),
3531 NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3532 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3535 [ITEM_GENEVE_OPT] = {
3536 .name = "geneve-opt",
3537 .help = "GENEVE header option",
3538 .priv = PRIV_ITEM(GENEVE_OPT,
3539 sizeof(struct rte_flow_item_geneve_opt) +
3540 ITEM_GENEVE_OPT_DATA_SIZE),
3541 .next = NEXT(item_geneve_opt),
3544 [ITEM_GENEVE_OPT_CLASS] = {
3546 .help = "GENEVE option class",
3547 .next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_UNSIGNED),
3549 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve_opt,
3552 [ITEM_GENEVE_OPT_TYPE] = {
3554 .help = "GENEVE option type",
3555 .next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_UNSIGNED),
3557 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt,
3560 [ITEM_GENEVE_OPT_LENGTH] = {
3562 .help = "GENEVE option data length (in 32b words)",
3563 .next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_UNSIGNED),
3565 .args = ARGS(ARGS_ENTRY_BOUNDED(
3566 struct rte_flow_item_geneve_opt, option_len,
3569 [ITEM_GENEVE_OPT_DATA] = {
3571 .help = "GENEVE option data pattern",
3572 .next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_HEX),
3574 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt, data),
3575 ARGS_ENTRY_ARB(0, 0),
3577 (sizeof(struct rte_flow_item_geneve_opt),
3578 ITEM_GENEVE_OPT_DATA_SIZE)),
3580 [ITEM_INTEGRITY] = {
3581 .name = "integrity",
3582 .help = "match packet integrity",
3583 .priv = PRIV_ITEM(INTEGRITY,
3584 sizeof(struct rte_flow_item_integrity)),
3585 .next = NEXT(item_integrity),
3588 [ITEM_INTEGRITY_LEVEL] = {
3590 .help = "integrity level",
3591 .next = NEXT(item_integrity_lv, NEXT_ENTRY(COMMON_UNSIGNED),
3593 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_integrity, level)),
3595 [ITEM_INTEGRITY_VALUE] = {
3597 .help = "integrity value",
3598 .next = NEXT(item_integrity_lv, NEXT_ENTRY(COMMON_UNSIGNED),
3600 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_integrity, value)),
3602 [ITEM_CONNTRACK] = {
3603 .name = "conntrack",
3604 .help = "conntrack state",
3605 .next = NEXT(NEXT_ENTRY(ITEM_NEXT), NEXT_ENTRY(COMMON_UNSIGNED),
3607 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_conntrack, flags)),
3609 /* Validate/create actions. */
3612 .help = "submit a list of associated actions",
3613 .next = NEXT(next_action),
3618 .help = "specify next action",
3619 .next = NEXT(next_action),
3623 .help = "end list of actions",
3624 .priv = PRIV_ACTION(END, 0),
3629 .help = "no-op action",
3630 .priv = PRIV_ACTION(VOID, 0),
3631 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3634 [ACTION_PASSTHRU] = {
3636 .help = "let subsequent rule process matched packets",
3637 .priv = PRIV_ACTION(PASSTHRU, 0),
3638 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3643 .help = "redirect traffic to a given group",
3644 .priv = PRIV_ACTION(JUMP, sizeof(struct rte_flow_action_jump)),
3645 .next = NEXT(action_jump),
3648 [ACTION_JUMP_GROUP] = {
3650 .help = "group to redirect traffic to",
3651 .next = NEXT(action_jump, NEXT_ENTRY(COMMON_UNSIGNED)),
3652 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump, group)),
3653 .call = parse_vc_conf,
3657 .help = "attach 32 bit value to packets",
3658 .priv = PRIV_ACTION(MARK, sizeof(struct rte_flow_action_mark)),
3659 .next = NEXT(action_mark),
3662 [ACTION_MARK_ID] = {
3664 .help = "32 bit value to return with packets",
3665 .next = NEXT(action_mark, NEXT_ENTRY(COMMON_UNSIGNED)),
3666 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_mark, id)),
3667 .call = parse_vc_conf,
3671 .help = "flag packets",
3672 .priv = PRIV_ACTION(FLAG, 0),
3673 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3678 .help = "assign packets to a given queue index",
3679 .priv = PRIV_ACTION(QUEUE,
3680 sizeof(struct rte_flow_action_queue)),
3681 .next = NEXT(action_queue),
3684 [ACTION_QUEUE_INDEX] = {
3686 .help = "queue index to use",
3687 .next = NEXT(action_queue, NEXT_ENTRY(COMMON_UNSIGNED)),
3688 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_queue, index)),
3689 .call = parse_vc_conf,
3693 .help = "drop packets (note: passthru has priority)",
3694 .priv = PRIV_ACTION(DROP, 0),
3695 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3700 .help = "enable counters for this rule",
3701 .priv = PRIV_ACTION(COUNT,
3702 sizeof(struct rte_flow_action_count)),
3703 .next = NEXT(action_count),
3706 [ACTION_COUNT_ID] = {
3707 .name = "identifier",
3708 .help = "counter identifier to use",
3709 .next = NEXT(action_count, NEXT_ENTRY(COMMON_UNSIGNED)),
3710 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_count, id)),
3711 .call = parse_vc_conf,
3715 .help = "spread packets among several queues",
3716 .priv = PRIV_ACTION(RSS, sizeof(struct action_rss_data)),
3717 .next = NEXT(action_rss),
3718 .call = parse_vc_action_rss,
3720 [ACTION_RSS_FUNC] = {
3722 .help = "RSS hash function to apply",
3723 .next = NEXT(action_rss,
3724 NEXT_ENTRY(ACTION_RSS_FUNC_DEFAULT,
3725 ACTION_RSS_FUNC_TOEPLITZ,
3726 ACTION_RSS_FUNC_SIMPLE_XOR,
3727 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ)),
3729 [ACTION_RSS_FUNC_DEFAULT] = {
3731 .help = "default hash function",
3732 .call = parse_vc_action_rss_func,
3734 [ACTION_RSS_FUNC_TOEPLITZ] = {
3736 .help = "Toeplitz hash function",
3737 .call = parse_vc_action_rss_func,
3739 [ACTION_RSS_FUNC_SIMPLE_XOR] = {
3740 .name = "simple_xor",
3741 .help = "simple XOR hash function",
3742 .call = parse_vc_action_rss_func,
3744 [ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ] = {
3745 .name = "symmetric_toeplitz",
3746 .help = "Symmetric Toeplitz hash function",
3747 .call = parse_vc_action_rss_func,
3749 [ACTION_RSS_LEVEL] = {
3751 .help = "encapsulation level for \"types\"",
3752 .next = NEXT(action_rss, NEXT_ENTRY(COMMON_UNSIGNED)),
3753 .args = ARGS(ARGS_ENTRY_ARB
3754 (offsetof(struct action_rss_data, conf) +
3755 offsetof(struct rte_flow_action_rss, level),
3756 sizeof(((struct rte_flow_action_rss *)0)->
3759 [ACTION_RSS_TYPES] = {
3761 .help = "specific RSS hash types",
3762 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)),
3764 [ACTION_RSS_TYPE] = {
3766 .help = "RSS hash type",
3767 .call = parse_vc_action_rss_type,
3768 .comp = comp_vc_action_rss_type,
3770 [ACTION_RSS_KEY] = {
3772 .help = "RSS hash key",
3773 .next = NEXT(action_rss, NEXT_ENTRY(COMMON_HEX)),
3774 .args = ARGS(ARGS_ENTRY_ARB
3775 (offsetof(struct action_rss_data, conf) +
3776 offsetof(struct rte_flow_action_rss, key),
3777 sizeof(((struct rte_flow_action_rss *)0)->key)),
3779 (offsetof(struct action_rss_data, conf) +
3780 offsetof(struct rte_flow_action_rss, key_len),
3781 sizeof(((struct rte_flow_action_rss *)0)->
3783 ARGS_ENTRY(struct action_rss_data, key)),
3785 [ACTION_RSS_KEY_LEN] = {
3787 .help = "RSS hash key length in bytes",
3788 .next = NEXT(action_rss, NEXT_ENTRY(COMMON_UNSIGNED)),
3789 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
3790 (offsetof(struct action_rss_data, conf) +
3791 offsetof(struct rte_flow_action_rss, key_len),
3792 sizeof(((struct rte_flow_action_rss *)0)->
3795 RSS_HASH_KEY_LENGTH)),
3797 [ACTION_RSS_QUEUES] = {
3799 .help = "queue indices to use",
3800 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_QUEUE)),
3801 .call = parse_vc_conf,
3803 [ACTION_RSS_QUEUE] = {
3805 .help = "queue index",
3806 .call = parse_vc_action_rss_queue,
3807 .comp = comp_vc_action_rss_queue,
3811 .help = "direct traffic to physical function",
3812 .priv = PRIV_ACTION(PF, 0),
3813 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3818 .help = "direct traffic to a virtual function ID",
3819 .priv = PRIV_ACTION(VF, sizeof(struct rte_flow_action_vf)),
3820 .next = NEXT(action_vf),
3823 [ACTION_VF_ORIGINAL] = {
3825 .help = "use original VF ID if possible",
3826 .next = NEXT(action_vf, NEXT_ENTRY(COMMON_BOOLEAN)),
3827 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_vf,
3829 .call = parse_vc_conf,
3834 .next = NEXT(action_vf, NEXT_ENTRY(COMMON_UNSIGNED)),
3835 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)),
3836 .call = parse_vc_conf,
3838 [ACTION_PHY_PORT] = {
3840 .help = "direct packets to physical port index",
3841 .priv = PRIV_ACTION(PHY_PORT,
3842 sizeof(struct rte_flow_action_phy_port)),
3843 .next = NEXT(action_phy_port),
3846 [ACTION_PHY_PORT_ORIGINAL] = {
3848 .help = "use original port index if possible",
3849 .next = NEXT(action_phy_port, NEXT_ENTRY(COMMON_BOOLEAN)),
3850 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_phy_port,
3852 .call = parse_vc_conf,
3854 [ACTION_PHY_PORT_INDEX] = {
3856 .help = "physical port index",
3857 .next = NEXT(action_phy_port, NEXT_ENTRY(COMMON_UNSIGNED)),
3858 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_phy_port,
3860 .call = parse_vc_conf,
3862 [ACTION_PORT_ID] = {
3864 .help = "direct matching traffic to a given DPDK port ID",
3865 .priv = PRIV_ACTION(PORT_ID,
3866 sizeof(struct rte_flow_action_port_id)),
3867 .next = NEXT(action_port_id),
3870 [ACTION_PORT_ID_ORIGINAL] = {
3872 .help = "use original DPDK port ID if possible",
3873 .next = NEXT(action_port_id, NEXT_ENTRY(COMMON_BOOLEAN)),
3874 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_port_id,
3876 .call = parse_vc_conf,
3878 [ACTION_PORT_ID_ID] = {
3880 .help = "DPDK port ID",
3881 .next = NEXT(action_port_id, NEXT_ENTRY(COMMON_UNSIGNED)),
3882 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_port_id, id)),
3883 .call = parse_vc_conf,
3887 .help = "meter the directed packets at given id",
3888 .priv = PRIV_ACTION(METER,
3889 sizeof(struct rte_flow_action_meter)),
3890 .next = NEXT(action_meter),
3893 [ACTION_METER_COLOR] = {
3895 .help = "meter color for the packets",
3896 .priv = PRIV_ACTION(METER_COLOR,
3897 sizeof(struct rte_flow_action_meter_color)),
3898 .next = NEXT(action_meter_color),
3901 [ACTION_METER_COLOR_TYPE] = {
3903 .help = "specific meter color",
3904 .next = NEXT(NEXT_ENTRY(ACTION_NEXT),
3905 NEXT_ENTRY(ACTION_METER_COLOR_GREEN,
3906 ACTION_METER_COLOR_YELLOW,
3907 ACTION_METER_COLOR_RED)),
3909 [ACTION_METER_COLOR_GREEN] = {
3911 .help = "meter color green",
3912 .call = parse_vc_action_meter_color_type,
3914 [ACTION_METER_COLOR_YELLOW] = {
3916 .help = "meter color yellow",
3917 .call = parse_vc_action_meter_color_type,
3919 [ACTION_METER_COLOR_RED] = {
3921 .help = "meter color red",
3922 .call = parse_vc_action_meter_color_type,
3924 [ACTION_METER_ID] = {
3926 .help = "meter id to use",
3927 .next = NEXT(action_meter, NEXT_ENTRY(COMMON_UNSIGNED)),
3928 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter, mtr_id)),
3929 .call = parse_vc_conf,
3931 [ACTION_OF_SET_MPLS_TTL] = {
3932 .name = "of_set_mpls_ttl",
3933 .help = "OpenFlow's OFPAT_SET_MPLS_TTL",
3936 sizeof(struct rte_flow_action_of_set_mpls_ttl)),
3937 .next = NEXT(action_of_set_mpls_ttl),
3940 [ACTION_OF_SET_MPLS_TTL_MPLS_TTL] = {
3943 .next = NEXT(action_of_set_mpls_ttl,
3944 NEXT_ENTRY(COMMON_UNSIGNED)),
3945 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_mpls_ttl,
3947 .call = parse_vc_conf,
3949 [ACTION_OF_DEC_MPLS_TTL] = {
3950 .name = "of_dec_mpls_ttl",
3951 .help = "OpenFlow's OFPAT_DEC_MPLS_TTL",
3952 .priv = PRIV_ACTION(OF_DEC_MPLS_TTL, 0),
3953 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3956 [ACTION_OF_SET_NW_TTL] = {
3957 .name = "of_set_nw_ttl",
3958 .help = "OpenFlow's OFPAT_SET_NW_TTL",
3961 sizeof(struct rte_flow_action_of_set_nw_ttl)),
3962 .next = NEXT(action_of_set_nw_ttl),
3965 [ACTION_OF_SET_NW_TTL_NW_TTL] = {
3968 .next = NEXT(action_of_set_nw_ttl, NEXT_ENTRY(COMMON_UNSIGNED)),
3969 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_nw_ttl,
3971 .call = parse_vc_conf,
3973 [ACTION_OF_DEC_NW_TTL] = {
3974 .name = "of_dec_nw_ttl",
3975 .help = "OpenFlow's OFPAT_DEC_NW_TTL",
3976 .priv = PRIV_ACTION(OF_DEC_NW_TTL, 0),
3977 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3980 [ACTION_OF_COPY_TTL_OUT] = {
3981 .name = "of_copy_ttl_out",
3982 .help = "OpenFlow's OFPAT_COPY_TTL_OUT",
3983 .priv = PRIV_ACTION(OF_COPY_TTL_OUT, 0),
3984 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3987 [ACTION_OF_COPY_TTL_IN] = {
3988 .name = "of_copy_ttl_in",
3989 .help = "OpenFlow's OFPAT_COPY_TTL_IN",
3990 .priv = PRIV_ACTION(OF_COPY_TTL_IN, 0),
3991 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3994 [ACTION_OF_POP_VLAN] = {
3995 .name = "of_pop_vlan",
3996 .help = "OpenFlow's OFPAT_POP_VLAN",
3997 .priv = PRIV_ACTION(OF_POP_VLAN, 0),
3998 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4001 [ACTION_OF_PUSH_VLAN] = {
4002 .name = "of_push_vlan",
4003 .help = "OpenFlow's OFPAT_PUSH_VLAN",
4006 sizeof(struct rte_flow_action_of_push_vlan)),
4007 .next = NEXT(action_of_push_vlan),
4010 [ACTION_OF_PUSH_VLAN_ETHERTYPE] = {
4011 .name = "ethertype",
4012 .help = "EtherType",
4013 .next = NEXT(action_of_push_vlan, NEXT_ENTRY(COMMON_UNSIGNED)),
4014 .args = ARGS(ARGS_ENTRY_HTON
4015 (struct rte_flow_action_of_push_vlan,
4017 .call = parse_vc_conf,
4019 [ACTION_OF_SET_VLAN_VID] = {
4020 .name = "of_set_vlan_vid",
4021 .help = "OpenFlow's OFPAT_SET_VLAN_VID",
4024 sizeof(struct rte_flow_action_of_set_vlan_vid)),
4025 .next = NEXT(action_of_set_vlan_vid),
4028 [ACTION_OF_SET_VLAN_VID_VLAN_VID] = {
4031 .next = NEXT(action_of_set_vlan_vid,
4032 NEXT_ENTRY(COMMON_UNSIGNED)),
4033 .args = ARGS(ARGS_ENTRY_HTON
4034 (struct rte_flow_action_of_set_vlan_vid,
4036 .call = parse_vc_conf,
4038 [ACTION_OF_SET_VLAN_PCP] = {
4039 .name = "of_set_vlan_pcp",
4040 .help = "OpenFlow's OFPAT_SET_VLAN_PCP",
4043 sizeof(struct rte_flow_action_of_set_vlan_pcp)),
4044 .next = NEXT(action_of_set_vlan_pcp),
4047 [ACTION_OF_SET_VLAN_PCP_VLAN_PCP] = {
4049 .help = "VLAN priority",
4050 .next = NEXT(action_of_set_vlan_pcp,
4051 NEXT_ENTRY(COMMON_UNSIGNED)),
4052 .args = ARGS(ARGS_ENTRY_HTON
4053 (struct rte_flow_action_of_set_vlan_pcp,
4055 .call = parse_vc_conf,
4057 [ACTION_OF_POP_MPLS] = {
4058 .name = "of_pop_mpls",
4059 .help = "OpenFlow's OFPAT_POP_MPLS",
4060 .priv = PRIV_ACTION(OF_POP_MPLS,
4061 sizeof(struct rte_flow_action_of_pop_mpls)),
4062 .next = NEXT(action_of_pop_mpls),
4065 [ACTION_OF_POP_MPLS_ETHERTYPE] = {
4066 .name = "ethertype",
4067 .help = "EtherType",
4068 .next = NEXT(action_of_pop_mpls, NEXT_ENTRY(COMMON_UNSIGNED)),
4069 .args = ARGS(ARGS_ENTRY_HTON
4070 (struct rte_flow_action_of_pop_mpls,
4072 .call = parse_vc_conf,
4074 [ACTION_OF_PUSH_MPLS] = {
4075 .name = "of_push_mpls",
4076 .help = "OpenFlow's OFPAT_PUSH_MPLS",
4079 sizeof(struct rte_flow_action_of_push_mpls)),
4080 .next = NEXT(action_of_push_mpls),
4083 [ACTION_OF_PUSH_MPLS_ETHERTYPE] = {
4084 .name = "ethertype",
4085 .help = "EtherType",
4086 .next = NEXT(action_of_push_mpls, NEXT_ENTRY(COMMON_UNSIGNED)),
4087 .args = ARGS(ARGS_ENTRY_HTON
4088 (struct rte_flow_action_of_push_mpls,
4090 .call = parse_vc_conf,
4092 [ACTION_VXLAN_ENCAP] = {
4093 .name = "vxlan_encap",
4094 .help = "VXLAN encapsulation, uses configuration set by \"set"
4096 .priv = PRIV_ACTION(VXLAN_ENCAP,
4097 sizeof(struct action_vxlan_encap_data)),
4098 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4099 .call = parse_vc_action_vxlan_encap,
4101 [ACTION_VXLAN_DECAP] = {
4102 .name = "vxlan_decap",
4103 .help = "Performs a decapsulation action by stripping all"
4104 " headers of the VXLAN tunnel network overlay from the"
4106 .priv = PRIV_ACTION(VXLAN_DECAP, 0),
4107 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4110 [ACTION_NVGRE_ENCAP] = {
4111 .name = "nvgre_encap",
4112 .help = "NVGRE encapsulation, uses configuration set by \"set"
4114 .priv = PRIV_ACTION(NVGRE_ENCAP,
4115 sizeof(struct action_nvgre_encap_data)),
4116 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4117 .call = parse_vc_action_nvgre_encap,
4119 [ACTION_NVGRE_DECAP] = {
4120 .name = "nvgre_decap",
4121 .help = "Performs a decapsulation action by stripping all"
4122 " headers of the NVGRE tunnel network overlay from the"
4124 .priv = PRIV_ACTION(NVGRE_DECAP, 0),
4125 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4128 [ACTION_L2_ENCAP] = {
4130 .help = "l2 encap, uses configuration set by"
4131 " \"set l2_encap\"",
4132 .priv = PRIV_ACTION(RAW_ENCAP,
4133 sizeof(struct action_raw_encap_data)),
4134 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4135 .call = parse_vc_action_l2_encap,
4137 [ACTION_L2_DECAP] = {
4139 .help = "l2 decap, uses configuration set by"
4140 " \"set l2_decap\"",
4141 .priv = PRIV_ACTION(RAW_DECAP,
4142 sizeof(struct action_raw_decap_data)),
4143 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4144 .call = parse_vc_action_l2_decap,
4146 [ACTION_MPLSOGRE_ENCAP] = {
4147 .name = "mplsogre_encap",
4148 .help = "mplsogre encapsulation, uses configuration set by"
4149 " \"set mplsogre_encap\"",
4150 .priv = PRIV_ACTION(RAW_ENCAP,
4151 sizeof(struct action_raw_encap_data)),
4152 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4153 .call = parse_vc_action_mplsogre_encap,
4155 [ACTION_MPLSOGRE_DECAP] = {
4156 .name = "mplsogre_decap",
4157 .help = "mplsogre decapsulation, uses configuration set by"
4158 " \"set mplsogre_decap\"",
4159 .priv = PRIV_ACTION(RAW_DECAP,
4160 sizeof(struct action_raw_decap_data)),
4161 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4162 .call = parse_vc_action_mplsogre_decap,
4164 [ACTION_MPLSOUDP_ENCAP] = {
4165 .name = "mplsoudp_encap",
4166 .help = "mplsoudp encapsulation, uses configuration set by"
4167 " \"set mplsoudp_encap\"",
4168 .priv = PRIV_ACTION(RAW_ENCAP,
4169 sizeof(struct action_raw_encap_data)),
4170 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4171 .call = parse_vc_action_mplsoudp_encap,
4173 [ACTION_MPLSOUDP_DECAP] = {
4174 .name = "mplsoudp_decap",
4175 .help = "mplsoudp decapsulation, uses configuration set by"
4176 " \"set mplsoudp_decap\"",
4177 .priv = PRIV_ACTION(RAW_DECAP,
4178 sizeof(struct action_raw_decap_data)),
4179 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4180 .call = parse_vc_action_mplsoudp_decap,
4182 [ACTION_SET_IPV4_SRC] = {
4183 .name = "set_ipv4_src",
4184 .help = "Set a new IPv4 source address in the outermost"
4186 .priv = PRIV_ACTION(SET_IPV4_SRC,
4187 sizeof(struct rte_flow_action_set_ipv4)),
4188 .next = NEXT(action_set_ipv4_src),
4191 [ACTION_SET_IPV4_SRC_IPV4_SRC] = {
4192 .name = "ipv4_addr",
4193 .help = "new IPv4 source address to set",
4194 .next = NEXT(action_set_ipv4_src, NEXT_ENTRY(COMMON_IPV4_ADDR)),
4195 .args = ARGS(ARGS_ENTRY_HTON
4196 (struct rte_flow_action_set_ipv4, ipv4_addr)),
4197 .call = parse_vc_conf,
4199 [ACTION_SET_IPV4_DST] = {
4200 .name = "set_ipv4_dst",
4201 .help = "Set a new IPv4 destination address in the outermost"
4203 .priv = PRIV_ACTION(SET_IPV4_DST,
4204 sizeof(struct rte_flow_action_set_ipv4)),
4205 .next = NEXT(action_set_ipv4_dst),
4208 [ACTION_SET_IPV4_DST_IPV4_DST] = {
4209 .name = "ipv4_addr",
4210 .help = "new IPv4 destination address to set",
4211 .next = NEXT(action_set_ipv4_dst, NEXT_ENTRY(COMMON_IPV4_ADDR)),
4212 .args = ARGS(ARGS_ENTRY_HTON
4213 (struct rte_flow_action_set_ipv4, ipv4_addr)),
4214 .call = parse_vc_conf,
4216 [ACTION_SET_IPV6_SRC] = {
4217 .name = "set_ipv6_src",
4218 .help = "Set a new IPv6 source address in the outermost"
4220 .priv = PRIV_ACTION(SET_IPV6_SRC,
4221 sizeof(struct rte_flow_action_set_ipv6)),
4222 .next = NEXT(action_set_ipv6_src),
4225 [ACTION_SET_IPV6_SRC_IPV6_SRC] = {
4226 .name = "ipv6_addr",
4227 .help = "new IPv6 source address to set",
4228 .next = NEXT(action_set_ipv6_src, NEXT_ENTRY(COMMON_IPV6_ADDR)),
4229 .args = ARGS(ARGS_ENTRY_HTON
4230 (struct rte_flow_action_set_ipv6, ipv6_addr)),
4231 .call = parse_vc_conf,
4233 [ACTION_SET_IPV6_DST] = {
4234 .name = "set_ipv6_dst",
4235 .help = "Set a new IPv6 destination address in the outermost"
4237 .priv = PRIV_ACTION(SET_IPV6_DST,
4238 sizeof(struct rte_flow_action_set_ipv6)),
4239 .next = NEXT(action_set_ipv6_dst),
4242 [ACTION_SET_IPV6_DST_IPV6_DST] = {
4243 .name = "ipv6_addr",
4244 .help = "new IPv6 destination address to set",
4245 .next = NEXT(action_set_ipv6_dst, NEXT_ENTRY(COMMON_IPV6_ADDR)),
4246 .args = ARGS(ARGS_ENTRY_HTON
4247 (struct rte_flow_action_set_ipv6, ipv6_addr)),
4248 .call = parse_vc_conf,
4250 [ACTION_SET_TP_SRC] = {
4251 .name = "set_tp_src",
4252 .help = "set a new source port number in the outermost"
4254 .priv = PRIV_ACTION(SET_TP_SRC,
4255 sizeof(struct rte_flow_action_set_tp)),
4256 .next = NEXT(action_set_tp_src),
4259 [ACTION_SET_TP_SRC_TP_SRC] = {
4261 .help = "new source port number to set",
4262 .next = NEXT(action_set_tp_src, NEXT_ENTRY(COMMON_UNSIGNED)),
4263 .args = ARGS(ARGS_ENTRY_HTON
4264 (struct rte_flow_action_set_tp, port)),
4265 .call = parse_vc_conf,
4267 [ACTION_SET_TP_DST] = {
4268 .name = "set_tp_dst",
4269 .help = "set a new destination port number in the outermost"
4271 .priv = PRIV_ACTION(SET_TP_DST,
4272 sizeof(struct rte_flow_action_set_tp)),
4273 .next = NEXT(action_set_tp_dst),
4276 [ACTION_SET_TP_DST_TP_DST] = {
4278 .help = "new destination port number to set",
4279 .next = NEXT(action_set_tp_dst, NEXT_ENTRY(COMMON_UNSIGNED)),
4280 .args = ARGS(ARGS_ENTRY_HTON
4281 (struct rte_flow_action_set_tp, port)),
4282 .call = parse_vc_conf,
4284 [ACTION_MAC_SWAP] = {
4286 .help = "Swap the source and destination MAC addresses"
4287 " in the outermost Ethernet header",
4288 .priv = PRIV_ACTION(MAC_SWAP, 0),
4289 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4292 [ACTION_DEC_TTL] = {
4294 .help = "decrease network TTL if available",
4295 .priv = PRIV_ACTION(DEC_TTL, 0),
4296 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4299 [ACTION_SET_TTL] = {
4301 .help = "set ttl value",
4302 .priv = PRIV_ACTION(SET_TTL,
4303 sizeof(struct rte_flow_action_set_ttl)),
4304 .next = NEXT(action_set_ttl),
4307 [ACTION_SET_TTL_TTL] = {
4308 .name = "ttl_value",
4309 .help = "new ttl value to set",
4310 .next = NEXT(action_set_ttl, NEXT_ENTRY(COMMON_UNSIGNED)),
4311 .args = ARGS(ARGS_ENTRY_HTON
4312 (struct rte_flow_action_set_ttl, ttl_value)),
4313 .call = parse_vc_conf,
4315 [ACTION_SET_MAC_SRC] = {
4316 .name = "set_mac_src",
4317 .help = "set source mac address",
4318 .priv = PRIV_ACTION(SET_MAC_SRC,
4319 sizeof(struct rte_flow_action_set_mac)),
4320 .next = NEXT(action_set_mac_src),
4323 [ACTION_SET_MAC_SRC_MAC_SRC] = {
4325 .help = "new source mac address",
4326 .next = NEXT(action_set_mac_src, NEXT_ENTRY(COMMON_MAC_ADDR)),
4327 .args = ARGS(ARGS_ENTRY_HTON
4328 (struct rte_flow_action_set_mac, mac_addr)),
4329 .call = parse_vc_conf,
4331 [ACTION_SET_MAC_DST] = {
4332 .name = "set_mac_dst",
4333 .help = "set destination mac address",
4334 .priv = PRIV_ACTION(SET_MAC_DST,
4335 sizeof(struct rte_flow_action_set_mac)),
4336 .next = NEXT(action_set_mac_dst),
4339 [ACTION_SET_MAC_DST_MAC_DST] = {
4341 .help = "new destination mac address to set",
4342 .next = NEXT(action_set_mac_dst, NEXT_ENTRY(COMMON_MAC_ADDR)),
4343 .args = ARGS(ARGS_ENTRY_HTON
4344 (struct rte_flow_action_set_mac, mac_addr)),
4345 .call = parse_vc_conf,
4347 [ACTION_INC_TCP_SEQ] = {
4348 .name = "inc_tcp_seq",
4349 .help = "increase TCP sequence number",
4350 .priv = PRIV_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
4351 .next = NEXT(action_inc_tcp_seq),
4354 [ACTION_INC_TCP_SEQ_VALUE] = {
4356 .help = "the value to increase TCP sequence number by",
4357 .next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(COMMON_UNSIGNED)),
4358 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4359 .call = parse_vc_conf,
4361 [ACTION_DEC_TCP_SEQ] = {
4362 .name = "dec_tcp_seq",
4363 .help = "decrease TCP sequence number",
4364 .priv = PRIV_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
4365 .next = NEXT(action_dec_tcp_seq),
4368 [ACTION_DEC_TCP_SEQ_VALUE] = {
4370 .help = "the value to decrease TCP sequence number by",
4371 .next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(COMMON_UNSIGNED)),
4372 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4373 .call = parse_vc_conf,
4375 [ACTION_INC_TCP_ACK] = {
4376 .name = "inc_tcp_ack",
4377 .help = "increase TCP acknowledgment number",
4378 .priv = PRIV_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
4379 .next = NEXT(action_inc_tcp_ack),
4382 [ACTION_INC_TCP_ACK_VALUE] = {
4384 .help = "the value to increase TCP acknowledgment number by",
4385 .next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(COMMON_UNSIGNED)),
4386 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4387 .call = parse_vc_conf,
4389 [ACTION_DEC_TCP_ACK] = {
4390 .name = "dec_tcp_ack",
4391 .help = "decrease TCP acknowledgment number",
4392 .priv = PRIV_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
4393 .next = NEXT(action_dec_tcp_ack),
4396 [ACTION_DEC_TCP_ACK_VALUE] = {
4398 .help = "the value to decrease TCP acknowledgment number by",
4399 .next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(COMMON_UNSIGNED)),
4400 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4401 .call = parse_vc_conf,
4403 [ACTION_RAW_ENCAP] = {
4404 .name = "raw_encap",
4405 .help = "encapsulation data, defined by set raw_encap",
4406 .priv = PRIV_ACTION(RAW_ENCAP,
4407 sizeof(struct action_raw_encap_data)),
4408 .next = NEXT(action_raw_encap),
4409 .call = parse_vc_action_raw_encap,
4411 [ACTION_RAW_ENCAP_INDEX] = {
4413 .help = "the index of raw_encap_confs",
4414 .next = NEXT(NEXT_ENTRY(ACTION_RAW_ENCAP_INDEX_VALUE)),
4416 [ACTION_RAW_ENCAP_INDEX_VALUE] = {
4419 .help = "unsigned integer value",
4420 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4421 .call = parse_vc_action_raw_encap_index,
4422 .comp = comp_set_raw_index,
4424 [ACTION_RAW_DECAP] = {
4425 .name = "raw_decap",
4426 .help = "decapsulation data, defined by set raw_encap",
4427 .priv = PRIV_ACTION(RAW_DECAP,
4428 sizeof(struct action_raw_decap_data)),
4429 .next = NEXT(action_raw_decap),
4430 .call = parse_vc_action_raw_decap,
4432 [ACTION_RAW_DECAP_INDEX] = {
4434 .help = "the index of raw_encap_confs",
4435 .next = NEXT(NEXT_ENTRY(ACTION_RAW_DECAP_INDEX_VALUE)),
4437 [ACTION_RAW_DECAP_INDEX_VALUE] = {
4440 .help = "unsigned integer value",
4441 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4442 .call = parse_vc_action_raw_decap_index,
4443 .comp = comp_set_raw_index,
4445 [ACTION_MODIFY_FIELD] = {
4446 .name = "modify_field",
4447 .help = "modify destination field with data from source field",
4448 .priv = PRIV_ACTION(MODIFY_FIELD,
4449 sizeof(struct rte_flow_action_modify_field)),
4450 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_OP)),
4453 [ACTION_MODIFY_FIELD_OP] = {
4455 .help = "operation type",
4456 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_TYPE),
4457 NEXT_ENTRY(ACTION_MODIFY_FIELD_OP_VALUE)),
4458 .call = parse_vc_conf,
4460 [ACTION_MODIFY_FIELD_OP_VALUE] = {
4461 .name = "{operation}",
4462 .help = "operation type value",
4463 .call = parse_vc_modify_field_op,
4464 .comp = comp_set_modify_field_op,
4466 [ACTION_MODIFY_FIELD_DST_TYPE] = {
4468 .help = "destination field type",
4469 .next = NEXT(action_modify_field_dst,
4470 NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_TYPE_VALUE)),
4471 .call = parse_vc_conf,
4473 [ACTION_MODIFY_FIELD_DST_TYPE_VALUE] = {
4474 .name = "{dst_type}",
4475 .help = "destination field type value",
4476 .call = parse_vc_modify_field_id,
4477 .comp = comp_set_modify_field_id,
4479 [ACTION_MODIFY_FIELD_DST_LEVEL] = {
4480 .name = "dst_level",
4481 .help = "destination field level",
4482 .next = NEXT(action_modify_field_dst,
4483 NEXT_ENTRY(COMMON_UNSIGNED)),
4484 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4486 .call = parse_vc_conf,
4488 [ACTION_MODIFY_FIELD_DST_OFFSET] = {
4489 .name = "dst_offset",
4490 .help = "destination field bit offset",
4491 .next = NEXT(action_modify_field_dst,
4492 NEXT_ENTRY(COMMON_UNSIGNED)),
4493 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4495 .call = parse_vc_conf,
4497 [ACTION_MODIFY_FIELD_SRC_TYPE] = {
4499 .help = "source field type",
4500 .next = NEXT(action_modify_field_src,
4501 NEXT_ENTRY(ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)),
4502 .call = parse_vc_conf,
4504 [ACTION_MODIFY_FIELD_SRC_TYPE_VALUE] = {
4505 .name = "{src_type}",
4506 .help = "source field type value",
4507 .call = parse_vc_modify_field_id,
4508 .comp = comp_set_modify_field_id,
4510 [ACTION_MODIFY_FIELD_SRC_LEVEL] = {
4511 .name = "src_level",
4512 .help = "source field level",
4513 .next = NEXT(action_modify_field_src,
4514 NEXT_ENTRY(COMMON_UNSIGNED)),
4515 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4517 .call = parse_vc_conf,
4519 [ACTION_MODIFY_FIELD_SRC_OFFSET] = {
4520 .name = "src_offset",
4521 .help = "source field bit offset",
4522 .next = NEXT(action_modify_field_src,
4523 NEXT_ENTRY(COMMON_UNSIGNED)),
4524 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4526 .call = parse_vc_conf,
4528 [ACTION_MODIFY_FIELD_SRC_VALUE] = {
4529 .name = "src_value",
4530 .help = "source immediate value",
4531 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_WIDTH),
4532 NEXT_ENTRY(COMMON_UNSIGNED)),
4533 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4535 .call = parse_vc_conf,
4537 [ACTION_MODIFY_FIELD_WIDTH] = {
4539 .help = "number of bits to copy",
4540 .next = NEXT(NEXT_ENTRY(ACTION_NEXT),
4541 NEXT_ENTRY(COMMON_UNSIGNED)),
4542 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4544 .call = parse_vc_conf,
4546 /* Top level command. */
4549 .help = "set raw encap/decap/sample data",
4550 .type = "set raw_encap|raw_decap <index> <pattern>"
4551 " or set sample_actions <index> <action>",
4552 .next = NEXT(NEXT_ENTRY
4555 SET_SAMPLE_ACTIONS)),
4556 .call = parse_set_init,
4558 /* Sub-level commands. */
4560 .name = "raw_encap",
4561 .help = "set raw encap data",
4562 .next = NEXT(next_set_raw),
4563 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4564 (offsetof(struct buffer, port),
4565 sizeof(((struct buffer *)0)->port),
4566 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
4567 .call = parse_set_raw_encap_decap,
4570 .name = "raw_decap",
4571 .help = "set raw decap data",
4572 .next = NEXT(next_set_raw),
4573 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4574 (offsetof(struct buffer, port),
4575 sizeof(((struct buffer *)0)->port),
4576 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
4577 .call = parse_set_raw_encap_decap,
4581 .type = "COMMON_UNSIGNED",
4582 .help = "index of raw_encap/raw_decap data",
4583 .next = NEXT(next_item),
4586 [SET_SAMPLE_INDEX] = {
4589 .help = "index of sample actions",
4590 .next = NEXT(next_action_sample),
4593 [SET_SAMPLE_ACTIONS] = {
4594 .name = "sample_actions",
4595 .help = "set sample actions list",
4596 .next = NEXT(NEXT_ENTRY(SET_SAMPLE_INDEX)),
4597 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4598 (offsetof(struct buffer, port),
4599 sizeof(((struct buffer *)0)->port),
4600 0, RAW_SAMPLE_CONFS_MAX_NUM - 1)),
4601 .call = parse_set_sample_action,
4603 [ACTION_SET_TAG] = {
4606 .priv = PRIV_ACTION(SET_TAG,
4607 sizeof(struct rte_flow_action_set_tag)),
4608 .next = NEXT(action_set_tag),
4611 [ACTION_SET_TAG_INDEX] = {
4613 .help = "index of tag array",
4614 .next = NEXT(action_set_tag, NEXT_ENTRY(COMMON_UNSIGNED)),
4615 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_set_tag, index)),
4616 .call = parse_vc_conf,
4618 [ACTION_SET_TAG_DATA] = {
4620 .help = "tag value",
4621 .next = NEXT(action_set_tag, NEXT_ENTRY(COMMON_UNSIGNED)),
4622 .args = ARGS(ARGS_ENTRY
4623 (struct rte_flow_action_set_tag, data)),
4624 .call = parse_vc_conf,
4626 [ACTION_SET_TAG_MASK] = {
4628 .help = "mask for tag value",
4629 .next = NEXT(action_set_tag, NEXT_ENTRY(COMMON_UNSIGNED)),
4630 .args = ARGS(ARGS_ENTRY
4631 (struct rte_flow_action_set_tag, mask)),
4632 .call = parse_vc_conf,
4634 [ACTION_SET_META] = {
4636 .help = "set metadata",
4637 .priv = PRIV_ACTION(SET_META,
4638 sizeof(struct rte_flow_action_set_meta)),
4639 .next = NEXT(action_set_meta),
4640 .call = parse_vc_action_set_meta,
4642 [ACTION_SET_META_DATA] = {
4644 .help = "metadata value",
4645 .next = NEXT(action_set_meta, NEXT_ENTRY(COMMON_UNSIGNED)),
4646 .args = ARGS(ARGS_ENTRY
4647 (struct rte_flow_action_set_meta, data)),
4648 .call = parse_vc_conf,
4650 [ACTION_SET_META_MASK] = {
4652 .help = "mask for metadata value",
4653 .next = NEXT(action_set_meta, NEXT_ENTRY(COMMON_UNSIGNED)),
4654 .args = ARGS(ARGS_ENTRY
4655 (struct rte_flow_action_set_meta, mask)),
4656 .call = parse_vc_conf,
4658 [ACTION_SET_IPV4_DSCP] = {
4659 .name = "set_ipv4_dscp",
4660 .help = "set DSCP value",
4661 .priv = PRIV_ACTION(SET_IPV4_DSCP,
4662 sizeof(struct rte_flow_action_set_dscp)),
4663 .next = NEXT(action_set_ipv4_dscp),
4666 [ACTION_SET_IPV4_DSCP_VALUE] = {
4667 .name = "dscp_value",
4668 .help = "new IPv4 DSCP value to set",
4669 .next = NEXT(action_set_ipv4_dscp, NEXT_ENTRY(COMMON_UNSIGNED)),
4670 .args = ARGS(ARGS_ENTRY
4671 (struct rte_flow_action_set_dscp, dscp)),
4672 .call = parse_vc_conf,
4674 [ACTION_SET_IPV6_DSCP] = {
4675 .name = "set_ipv6_dscp",
4676 .help = "set DSCP value",
4677 .priv = PRIV_ACTION(SET_IPV6_DSCP,
4678 sizeof(struct rte_flow_action_set_dscp)),
4679 .next = NEXT(action_set_ipv6_dscp),
4682 [ACTION_SET_IPV6_DSCP_VALUE] = {
4683 .name = "dscp_value",
4684 .help = "new IPv6 DSCP value to set",
4685 .next = NEXT(action_set_ipv6_dscp, NEXT_ENTRY(COMMON_UNSIGNED)),
4686 .args = ARGS(ARGS_ENTRY
4687 (struct rte_flow_action_set_dscp, dscp)),
4688 .call = parse_vc_conf,
4692 .help = "set a specific metadata header",
4693 .next = NEXT(action_age),
4694 .priv = PRIV_ACTION(AGE,
4695 sizeof(struct rte_flow_action_age)),
4698 [ACTION_AGE_TIMEOUT] = {
4700 .help = "flow age timeout value",
4701 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_age,
4703 .next = NEXT(action_age, NEXT_ENTRY(COMMON_UNSIGNED)),
4704 .call = parse_vc_conf,
4708 .help = "set a sample action",
4709 .next = NEXT(action_sample),
4710 .priv = PRIV_ACTION(SAMPLE,
4711 sizeof(struct action_sample_data)),
4712 .call = parse_vc_action_sample,
4714 [ACTION_SAMPLE_RATIO] = {
4716 .help = "flow sample ratio value",
4717 .next = NEXT(action_sample, NEXT_ENTRY(COMMON_UNSIGNED)),
4718 .args = ARGS(ARGS_ENTRY_ARB
4719 (offsetof(struct action_sample_data, conf) +
4720 offsetof(struct rte_flow_action_sample, ratio),
4721 sizeof(((struct rte_flow_action_sample *)0)->
4724 [ACTION_SAMPLE_INDEX] = {
4726 .help = "the index of sample actions list",
4727 .next = NEXT(NEXT_ENTRY(ACTION_SAMPLE_INDEX_VALUE)),
4729 [ACTION_SAMPLE_INDEX_VALUE] = {
4731 .type = "COMMON_UNSIGNED",
4732 .help = "unsigned integer value",
4733 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4734 .call = parse_vc_action_sample_index,
4735 .comp = comp_set_sample_index,
4737 [ACTION_CONNTRACK] = {
4738 .name = "conntrack",
4739 .help = "create a conntrack object",
4740 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4741 .priv = PRIV_ACTION(CONNTRACK,
4742 sizeof(struct rte_flow_action_conntrack)),
4745 [ACTION_CONNTRACK_UPDATE] = {
4746 .name = "conntrack_update",
4747 .help = "update a conntrack object",
4748 .next = NEXT(action_update_conntrack),
4749 .priv = PRIV_ACTION(CONNTRACK,
4750 sizeof(struct rte_flow_modify_conntrack)),
4753 [ACTION_CONNTRACK_UPDATE_DIR] = {
4755 .help = "update a conntrack object direction",
4756 .next = NEXT(action_update_conntrack),
4757 .call = parse_vc_action_conntrack_update,
4759 [ACTION_CONNTRACK_UPDATE_CTX] = {
4761 .help = "update a conntrack object context",
4762 .next = NEXT(action_update_conntrack),
4763 .call = parse_vc_action_conntrack_update,
4765 /* Indirect action destroy arguments. */
4766 [INDIRECT_ACTION_DESTROY_ID] = {
4767 .name = "action_id",
4768 .help = "specify a indirect action id to destroy",
4769 .next = NEXT(next_ia_destroy_attr,
4770 NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
4771 .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
4772 args.ia_destroy.action_id)),
4773 .call = parse_ia_destroy,
4775 /* Indirect action create arguments. */
4776 [INDIRECT_ACTION_CREATE_ID] = {
4777 .name = "action_id",
4778 .help = "specify a indirect action id to create",
4779 .next = NEXT(next_ia_create_attr,
4780 NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
4781 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
4783 [ACTION_INDIRECT] = {
4785 .help = "apply indirect action by id",
4786 .priv = PRIV_ACTION(INDIRECT, 0),
4787 .next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_ID2PTR)),
4788 .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
4791 [INDIRECT_ACTION_ID2PTR] = {
4792 .name = "{action_id}",
4793 .type = "INDIRECT_ACTION_ID",
4794 .help = "indirect action id",
4795 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4796 .call = parse_ia_id2ptr,
4799 [INDIRECT_ACTION_INGRESS] = {
4801 .help = "affect rule to ingress",
4802 .next = NEXT(next_ia_create_attr),
4805 [INDIRECT_ACTION_EGRESS] = {
4807 .help = "affect rule to egress",
4808 .next = NEXT(next_ia_create_attr),
4811 [INDIRECT_ACTION_TRANSFER] = {
4813 .help = "affect rule to transfer",
4814 .next = NEXT(next_ia_create_attr),
4817 [INDIRECT_ACTION_SPEC] = {
4819 .help = "specify action to create indirect handle",
4820 .next = NEXT(next_action),
4823 .name = "g_actions",
4824 .help = "submit a list of associated actions for green",
4825 .next = NEXT(next_action),
4829 .name = "y_actions",
4830 .help = "submit a list of associated actions for yellow",
4831 .next = NEXT(next_action),
4834 .name = "r_actions",
4835 .help = "submit a list of associated actions for red",
4836 .next = NEXT(next_action),
4839 /* Top-level command. */
4842 .type = "port meter policy {port_id} {arg}",
4843 .help = "add port meter policy",
4844 .next = NEXT(NEXT_ENTRY(ITEM_POL_PORT)),
4847 /* Sub-level commands. */
4850 .help = "add port meter policy",
4851 .next = NEXT(NEXT_ENTRY(ITEM_POL_METER)),
4853 [ITEM_POL_METER] = {
4855 .help = "add port meter policy",
4856 .next = NEXT(NEXT_ENTRY(ITEM_POL_POLICY)),
4858 [ITEM_POL_POLICY] = {
4860 .help = "add port meter policy",
4861 .next = NEXT(NEXT_ENTRY(ACTION_POL_R),
4862 NEXT_ENTRY(ACTION_POL_Y),
4863 NEXT_ENTRY(ACTION_POL_G),
4864 NEXT_ENTRY(COMMON_POLICY_ID),
4865 NEXT_ENTRY(COMMON_PORT_ID)),
4866 .args = ARGS(ARGS_ENTRY(struct buffer, args.policy.policy_id),
4867 ARGS_ENTRY(struct buffer, port)),
4872 /** Remove and return last entry from argument stack. */
4873 static const struct arg *
4874 pop_args(struct context *ctx)
4876 return ctx->args_num ? ctx->args[--ctx->args_num] : NULL;
4879 /** Add entry on top of the argument stack. */
4881 push_args(struct context *ctx, const struct arg *arg)
4883 if (ctx->args_num == CTX_STACK_SIZE)
4885 ctx->args[ctx->args_num++] = arg;
4889 /** Spread value into buffer according to bit-mask. */
4891 arg_entry_bf_fill(void *dst, uintmax_t val, const struct arg *arg)
4893 uint32_t i = arg->size;
4901 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
4910 unsigned int shift = 0;
4911 uint8_t *buf = (uint8_t *)dst + arg->offset + (i -= sub);
4913 for (shift = 0; arg->mask[i] >> shift; ++shift) {
4914 if (!(arg->mask[i] & (1 << shift)))
4919 *buf &= ~(1 << shift);
4920 *buf |= (val & 1) << shift;
4928 /** Compare a string with a partial one of a given length. */
4930 strcmp_partial(const char *full, const char *partial, size_t partial_len)
4932 int r = strncmp(full, partial, partial_len);
4936 if (strlen(full) <= partial_len)
4938 return full[partial_len];
4942 * Parse a prefix length and generate a bit-mask.
4944 * Last argument (ctx->args) is retrieved to determine mask size, storage
4945 * location and whether the result must use network byte ordering.
4948 parse_prefix(struct context *ctx, const struct token *token,
4949 const char *str, unsigned int len,
4950 void *buf, unsigned int size)
4952 const struct arg *arg = pop_args(ctx);
4953 static const uint8_t conv[] = "\x00\x80\xc0\xe0\xf0\xf8\xfc\xfe\xff";
4960 /* Argument is expected. */
4964 u = strtoumax(str, &end, 0);
4965 if (errno || (size_t)(end - str) != len)
4970 extra = arg_entry_bf_fill(NULL, 0, arg);
4979 if (!arg_entry_bf_fill(ctx->object, v, arg) ||
4980 !arg_entry_bf_fill(ctx->objmask, -1, arg))
4987 if (bytes > size || bytes + !!extra > size)
4991 buf = (uint8_t *)ctx->object + arg->offset;
4992 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
4994 memset((uint8_t *)buf + size - bytes, 0xff, bytes);
4995 memset(buf, 0x00, size - bytes);
4997 ((uint8_t *)buf)[size - bytes - 1] = conv[extra];
5001 memset(buf, 0xff, bytes);
5002 memset((uint8_t *)buf + bytes, 0x00, size - bytes);
5004 ((uint8_t *)buf)[bytes] = conv[extra];
5007 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
5010 push_args(ctx, arg);
5014 /** Default parsing function for token name matching. */
5016 parse_default(struct context *ctx, const struct token *token,
5017 const char *str, unsigned int len,
5018 void *buf, unsigned int size)
5023 if (strcmp_partial(token->name, str, len))
5028 /** Parse flow command, initialize output buffer for subsequent tokens. */
5030 parse_init(struct context *ctx, const struct token *token,
5031 const char *str, unsigned int len,
5032 void *buf, unsigned int size)
5034 struct buffer *out = buf;
5036 /* Token name must match. */
5037 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5039 /* Nothing else to do if there is no buffer. */
5042 /* Make sure buffer is large enough. */
5043 if (size < sizeof(*out))
5045 /* Initialize buffer. */
5046 memset(out, 0x00, sizeof(*out));
5047 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
5050 ctx->objmask = NULL;
5054 /** Parse tokens for indirect action commands. */
5056 parse_ia(struct context *ctx, const struct token *token,
5057 const char *str, unsigned int len,
5058 void *buf, unsigned int size)
5060 struct buffer *out = buf;
5062 /* Token name must match. */
5063 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5065 /* Nothing else to do if there is no buffer. */
5068 if (!out->command) {
5069 if (ctx->curr != INDIRECT_ACTION)
5071 if (sizeof(*out) > size)
5073 out->command = ctx->curr;
5076 ctx->objmask = NULL;
5077 out->args.vc.data = (uint8_t *)out + size;
5080 switch (ctx->curr) {
5081 case INDIRECT_ACTION_CREATE:
5082 case INDIRECT_ACTION_UPDATE:
5083 out->args.vc.actions =
5084 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5086 out->args.vc.attr.group = UINT32_MAX;
5088 case INDIRECT_ACTION_QUERY:
5089 out->command = ctx->curr;
5092 ctx->objmask = NULL;
5094 case INDIRECT_ACTION_EGRESS:
5095 out->args.vc.attr.egress = 1;
5097 case INDIRECT_ACTION_INGRESS:
5098 out->args.vc.attr.ingress = 1;
5100 case INDIRECT_ACTION_TRANSFER:
5101 out->args.vc.attr.transfer = 1;
5109 /** Parse tokens for indirect action destroy command. */
5111 parse_ia_destroy(struct context *ctx, const struct token *token,
5112 const char *str, unsigned int len,
5113 void *buf, unsigned int size)
5115 struct buffer *out = buf;
5116 uint32_t *action_id;
5118 /* Token name must match. */
5119 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5121 /* Nothing else to do if there is no buffer. */
5124 if (!out->command || out->command == INDIRECT_ACTION) {
5125 if (ctx->curr != INDIRECT_ACTION_DESTROY)
5127 if (sizeof(*out) > size)
5129 out->command = ctx->curr;
5132 ctx->objmask = NULL;
5133 out->args.ia_destroy.action_id =
5134 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5138 action_id = out->args.ia_destroy.action_id
5139 + out->args.ia_destroy.action_id_n++;
5140 if ((uint8_t *)action_id > (uint8_t *)out + size)
5143 ctx->object = action_id;
5144 ctx->objmask = NULL;
5148 /** Parse tokens for meter policy action commands. */
5150 parse_mp(struct context *ctx, const struct token *token,
5151 const char *str, unsigned int len,
5152 void *buf, unsigned int size)
5154 struct buffer *out = buf;
5156 /* Token name must match. */
5157 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5159 /* Nothing else to do if there is no buffer. */
5162 if (!out->command) {
5163 if (ctx->curr != ITEM_POL_POLICY)
5165 if (sizeof(*out) > size)
5167 out->command = ctx->curr;
5170 ctx->objmask = NULL;
5171 out->args.vc.data = (uint8_t *)out + size;
5174 switch (ctx->curr) {
5176 out->args.vc.actions =
5177 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5179 out->command = ctx->curr;
5182 ctx->objmask = NULL;
5189 /** Parse tokens for validate/create commands. */
5191 parse_vc(struct context *ctx, const struct token *token,
5192 const char *str, unsigned int len,
5193 void *buf, unsigned int size)
5195 struct buffer *out = buf;
5199 /* Token name must match. */
5200 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5202 /* Nothing else to do if there is no buffer. */
5205 if (!out->command) {
5206 if (ctx->curr != VALIDATE && ctx->curr != CREATE)
5208 if (sizeof(*out) > size)
5210 out->command = ctx->curr;
5213 ctx->objmask = NULL;
5214 out->args.vc.data = (uint8_t *)out + size;
5218 switch (ctx->curr) {
5220 ctx->object = &out->args.vc.attr;
5223 case VC_TUNNEL_MATCH:
5224 ctx->object = &out->args.vc.tunnel_ops;
5227 ctx->objmask = NULL;
5228 switch (ctx->curr) {
5233 out->args.vc.tunnel_ops.enabled = 1;
5234 out->args.vc.tunnel_ops.actions = 1;
5236 case VC_TUNNEL_MATCH:
5237 out->args.vc.tunnel_ops.enabled = 1;
5238 out->args.vc.tunnel_ops.items = 1;
5241 out->args.vc.attr.ingress = 1;
5244 out->args.vc.attr.egress = 1;
5247 out->args.vc.attr.transfer = 1;
5250 out->args.vc.pattern =
5251 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5253 ctx->object = out->args.vc.pattern;
5254 ctx->objmask = NULL;
5257 out->args.vc.actions =
5258 (void *)RTE_ALIGN_CEIL((uintptr_t)
5259 (out->args.vc.pattern +
5260 out->args.vc.pattern_n),
5262 ctx->object = out->args.vc.actions;
5263 ctx->objmask = NULL;
5270 if (!out->args.vc.actions) {
5271 const struct parse_item_priv *priv = token->priv;
5272 struct rte_flow_item *item =
5273 out->args.vc.pattern + out->args.vc.pattern_n;
5275 data_size = priv->size * 3; /* spec, last, mask */
5276 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
5277 (out->args.vc.data - data_size),
5279 if ((uint8_t *)item + sizeof(*item) > data)
5281 *item = (struct rte_flow_item){
5284 ++out->args.vc.pattern_n;
5286 ctx->objmask = NULL;
5288 const struct parse_action_priv *priv = token->priv;
5289 struct rte_flow_action *action =
5290 out->args.vc.actions + out->args.vc.actions_n;
5292 data_size = priv->size; /* configuration */
5293 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
5294 (out->args.vc.data - data_size),
5296 if ((uint8_t *)action + sizeof(*action) > data)
5298 *action = (struct rte_flow_action){
5300 .conf = data_size ? data : NULL,
5302 ++out->args.vc.actions_n;
5303 ctx->object = action;
5304 ctx->objmask = NULL;
5306 memset(data, 0, data_size);
5307 out->args.vc.data = data;
5308 ctx->objdata = data_size;
5312 /** Parse pattern item parameter type. */
5314 parse_vc_spec(struct context *ctx, const struct token *token,
5315 const char *str, unsigned int len,
5316 void *buf, unsigned int size)
5318 struct buffer *out = buf;
5319 struct rte_flow_item *item;
5325 /* Token name must match. */
5326 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5328 /* Parse parameter types. */
5329 switch (ctx->curr) {
5330 static const enum index prefix[] = NEXT_ENTRY(COMMON_PREFIX);
5336 case ITEM_PARAM_SPEC:
5339 case ITEM_PARAM_LAST:
5342 case ITEM_PARAM_PREFIX:
5343 /* Modify next token to expect a prefix. */
5344 if (ctx->next_num < 2)
5346 ctx->next[ctx->next_num - 2] = prefix;
5348 case ITEM_PARAM_MASK:
5354 /* Nothing else to do if there is no buffer. */
5357 if (!out->args.vc.pattern_n)
5359 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
5360 data_size = ctx->objdata / 3; /* spec, last, mask */
5361 /* Point to selected object. */
5362 ctx->object = out->args.vc.data + (data_size * index);
5364 ctx->objmask = out->args.vc.data + (data_size * 2); /* mask */
5365 item->mask = ctx->objmask;
5367 ctx->objmask = NULL;
5368 /* Update relevant item pointer. */
5369 *((const void **[]){ &item->spec, &item->last, &item->mask })[index] =
5374 /** Parse action configuration field. */
5376 parse_vc_conf(struct context *ctx, const struct token *token,
5377 const char *str, unsigned int len,
5378 void *buf, unsigned int size)
5380 struct buffer *out = buf;
5383 /* Token name must match. */
5384 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5386 /* Nothing else to do if there is no buffer. */
5389 /* Point to selected object. */
5390 ctx->object = out->args.vc.data;
5391 ctx->objmask = NULL;
5395 /** Parse eCPRI common header type field. */
5397 parse_vc_item_ecpri_type(struct context *ctx, const struct token *token,
5398 const char *str, unsigned int len,
5399 void *buf, unsigned int size)
5401 struct rte_flow_item_ecpri *ecpri;
5402 struct rte_flow_item_ecpri *ecpri_mask;
5403 struct rte_flow_item *item;
5406 struct buffer *out = buf;
5407 const struct arg *arg;
5410 /* Token name must match. */
5411 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5413 switch (ctx->curr) {
5414 case ITEM_ECPRI_COMMON_TYPE_IQ_DATA:
5415 msg_type = RTE_ECPRI_MSG_TYPE_IQ_DATA;
5417 case ITEM_ECPRI_COMMON_TYPE_RTC_CTRL:
5418 msg_type = RTE_ECPRI_MSG_TYPE_RTC_CTRL;
5420 case ITEM_ECPRI_COMMON_TYPE_DLY_MSR:
5421 msg_type = RTE_ECPRI_MSG_TYPE_DLY_MSR;
5428 arg = pop_args(ctx);
5431 ecpri = (struct rte_flow_item_ecpri *)out->args.vc.data;
5432 ecpri->hdr.common.type = msg_type;
5433 data_size = ctx->objdata / 3; /* spec, last, mask */
5434 ecpri_mask = (struct rte_flow_item_ecpri *)(out->args.vc.data +
5436 ecpri_mask->hdr.common.type = 0xFF;
5438 ecpri->hdr.common.u32 = rte_cpu_to_be_32(ecpri->hdr.common.u32);
5439 ecpri_mask->hdr.common.u32 =
5440 rte_cpu_to_be_32(ecpri_mask->hdr.common.u32);
5442 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
5444 item->mask = ecpri_mask;
5448 /** Parse meter color action type. */
5450 parse_vc_action_meter_color_type(struct context *ctx, const struct token *token,
5451 const char *str, unsigned int len,
5452 void *buf, unsigned int size)
5454 struct rte_flow_action *action_data;
5455 struct rte_flow_action_meter_color *conf;
5456 enum rte_color color;
5460 /* Token name must match. */
5461 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5463 switch (ctx->curr) {
5464 case ACTION_METER_COLOR_GREEN:
5465 color = RTE_COLOR_GREEN;
5467 case ACTION_METER_COLOR_YELLOW:
5468 color = RTE_COLOR_YELLOW;
5470 case ACTION_METER_COLOR_RED:
5471 color = RTE_COLOR_RED;
5479 action_data = ctx->object;
5480 conf = (struct rte_flow_action_meter_color *)
5481 (uintptr_t)(action_data->conf);
5482 conf->color = color;
5486 /** Parse RSS action. */
5488 parse_vc_action_rss(struct context *ctx, const struct token *token,
5489 const char *str, unsigned int len,
5490 void *buf, unsigned int size)
5492 struct buffer *out = buf;
5493 struct rte_flow_action *action;
5494 struct action_rss_data *action_rss_data;
5498 ret = parse_vc(ctx, token, str, len, buf, size);
5501 /* Nothing else to do if there is no buffer. */
5504 if (!out->args.vc.actions_n)
5506 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5507 /* Point to selected object. */
5508 ctx->object = out->args.vc.data;
5509 ctx->objmask = NULL;
5510 /* Set up default configuration. */
5511 action_rss_data = ctx->object;
5512 *action_rss_data = (struct action_rss_data){
5513 .conf = (struct rte_flow_action_rss){
5514 .func = RTE_ETH_HASH_FUNCTION_DEFAULT,
5518 .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM),
5520 .queue = action_rss_data->queue,
5524 for (i = 0; i < action_rss_data->conf.queue_num; ++i)
5525 action_rss_data->queue[i] = i;
5526 action->conf = &action_rss_data->conf;
5531 * Parse func field for RSS action.
5533 * The RTE_ETH_HASH_FUNCTION_* value to assign is derived from the
5534 * ACTION_RSS_FUNC_* index that called this function.
5537 parse_vc_action_rss_func(struct context *ctx, const struct token *token,
5538 const char *str, unsigned int len,
5539 void *buf, unsigned int size)
5541 struct action_rss_data *action_rss_data;
5542 enum rte_eth_hash_function func;
5546 /* Token name must match. */
5547 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5549 switch (ctx->curr) {
5550 case ACTION_RSS_FUNC_DEFAULT:
5551 func = RTE_ETH_HASH_FUNCTION_DEFAULT;
5553 case ACTION_RSS_FUNC_TOEPLITZ:
5554 func = RTE_ETH_HASH_FUNCTION_TOEPLITZ;
5556 case ACTION_RSS_FUNC_SIMPLE_XOR:
5557 func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
5559 case ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ:
5560 func = RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
5567 action_rss_data = ctx->object;
5568 action_rss_data->conf.func = func;
5573 * Parse type field for RSS action.
5575 * Valid tokens are type field names and the "end" token.
5578 parse_vc_action_rss_type(struct context *ctx, const struct token *token,
5579 const char *str, unsigned int len,
5580 void *buf, unsigned int size)
5582 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE);
5583 struct action_rss_data *action_rss_data;
5589 if (ctx->curr != ACTION_RSS_TYPE)
5591 if (!(ctx->objdata >> 16) && ctx->object) {
5592 action_rss_data = ctx->object;
5593 action_rss_data->conf.types = 0;
5595 if (!strcmp_partial("end", str, len)) {
5596 ctx->objdata &= 0xffff;
5599 for (i = 0; rss_type_table[i].str; ++i)
5600 if (!strcmp_partial(rss_type_table[i].str, str, len))
5602 if (!rss_type_table[i].str)
5604 ctx->objdata = 1 << 16 | (ctx->objdata & 0xffff);
5606 if (ctx->next_num == RTE_DIM(ctx->next))
5608 ctx->next[ctx->next_num++] = next;
5611 action_rss_data = ctx->object;
5612 action_rss_data->conf.types |= rss_type_table[i].rss_type;
5617 * Parse queue field for RSS action.
5619 * Valid tokens are queue indices and the "end" token.
5622 parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
5623 const char *str, unsigned int len,
5624 void *buf, unsigned int size)
5626 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE);
5627 struct action_rss_data *action_rss_data;
5628 const struct arg *arg;
5635 if (ctx->curr != ACTION_RSS_QUEUE)
5637 i = ctx->objdata >> 16;
5638 if (!strcmp_partial("end", str, len)) {
5639 ctx->objdata &= 0xffff;
5642 if (i >= ACTION_RSS_QUEUE_NUM)
5644 arg = ARGS_ENTRY_ARB(offsetof(struct action_rss_data, queue) +
5645 i * sizeof(action_rss_data->queue[i]),
5646 sizeof(action_rss_data->queue[i]));
5647 if (push_args(ctx, arg))
5649 ret = parse_int(ctx, token, str, len, NULL, 0);
5655 ctx->objdata = i << 16 | (ctx->objdata & 0xffff);
5657 if (ctx->next_num == RTE_DIM(ctx->next))
5659 ctx->next[ctx->next_num++] = next;
5663 action_rss_data = ctx->object;
5664 action_rss_data->conf.queue_num = i;
5665 action_rss_data->conf.queue = i ? action_rss_data->queue : NULL;
5669 /** Setup VXLAN encap configuration. */
5671 parse_setup_vxlan_encap_data(struct action_vxlan_encap_data *action_vxlan_encap_data)
5673 /* Set up default configuration. */
5674 *action_vxlan_encap_data = (struct action_vxlan_encap_data){
5675 .conf = (struct rte_flow_action_vxlan_encap){
5676 .definition = action_vxlan_encap_data->items,
5680 .type = RTE_FLOW_ITEM_TYPE_ETH,
5681 .spec = &action_vxlan_encap_data->item_eth,
5682 .mask = &rte_flow_item_eth_mask,
5685 .type = RTE_FLOW_ITEM_TYPE_VLAN,
5686 .spec = &action_vxlan_encap_data->item_vlan,
5687 .mask = &rte_flow_item_vlan_mask,
5690 .type = RTE_FLOW_ITEM_TYPE_IPV4,
5691 .spec = &action_vxlan_encap_data->item_ipv4,
5692 .mask = &rte_flow_item_ipv4_mask,
5695 .type = RTE_FLOW_ITEM_TYPE_UDP,
5696 .spec = &action_vxlan_encap_data->item_udp,
5697 .mask = &rte_flow_item_udp_mask,
5700 .type = RTE_FLOW_ITEM_TYPE_VXLAN,
5701 .spec = &action_vxlan_encap_data->item_vxlan,
5702 .mask = &rte_flow_item_vxlan_mask,
5705 .type = RTE_FLOW_ITEM_TYPE_END,
5710 .tci = vxlan_encap_conf.vlan_tci,
5714 .src_addr = vxlan_encap_conf.ipv4_src,
5715 .dst_addr = vxlan_encap_conf.ipv4_dst,
5718 .src_port = vxlan_encap_conf.udp_src,
5719 .dst_port = vxlan_encap_conf.udp_dst,
5721 .item_vxlan.flags = 0,
5723 memcpy(action_vxlan_encap_data->item_eth.dst.addr_bytes,
5724 vxlan_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5725 memcpy(action_vxlan_encap_data->item_eth.src.addr_bytes,
5726 vxlan_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5727 if (!vxlan_encap_conf.select_ipv4) {
5728 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.src_addr,
5729 &vxlan_encap_conf.ipv6_src,
5730 sizeof(vxlan_encap_conf.ipv6_src));
5731 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.dst_addr,
5732 &vxlan_encap_conf.ipv6_dst,
5733 sizeof(vxlan_encap_conf.ipv6_dst));
5734 action_vxlan_encap_data->items[2] = (struct rte_flow_item){
5735 .type = RTE_FLOW_ITEM_TYPE_IPV6,
5736 .spec = &action_vxlan_encap_data->item_ipv6,
5737 .mask = &rte_flow_item_ipv6_mask,
5740 if (!vxlan_encap_conf.select_vlan)
5741 action_vxlan_encap_data->items[1].type =
5742 RTE_FLOW_ITEM_TYPE_VOID;
5743 if (vxlan_encap_conf.select_tos_ttl) {
5744 if (vxlan_encap_conf.select_ipv4) {
5745 static struct rte_flow_item_ipv4 ipv4_mask_tos;
5747 memcpy(&ipv4_mask_tos, &rte_flow_item_ipv4_mask,
5748 sizeof(ipv4_mask_tos));
5749 ipv4_mask_tos.hdr.type_of_service = 0xff;
5750 ipv4_mask_tos.hdr.time_to_live = 0xff;
5751 action_vxlan_encap_data->item_ipv4.hdr.type_of_service =
5752 vxlan_encap_conf.ip_tos;
5753 action_vxlan_encap_data->item_ipv4.hdr.time_to_live =
5754 vxlan_encap_conf.ip_ttl;
5755 action_vxlan_encap_data->items[2].mask =
5758 static struct rte_flow_item_ipv6 ipv6_mask_tos;
5760 memcpy(&ipv6_mask_tos, &rte_flow_item_ipv6_mask,
5761 sizeof(ipv6_mask_tos));
5762 ipv6_mask_tos.hdr.vtc_flow |=
5763 RTE_BE32(0xfful << RTE_IPV6_HDR_TC_SHIFT);
5764 ipv6_mask_tos.hdr.hop_limits = 0xff;
5765 action_vxlan_encap_data->item_ipv6.hdr.vtc_flow |=
5767 ((uint32_t)vxlan_encap_conf.ip_tos <<
5768 RTE_IPV6_HDR_TC_SHIFT);
5769 action_vxlan_encap_data->item_ipv6.hdr.hop_limits =
5770 vxlan_encap_conf.ip_ttl;
5771 action_vxlan_encap_data->items[2].mask =
5775 memcpy(action_vxlan_encap_data->item_vxlan.vni, vxlan_encap_conf.vni,
5776 RTE_DIM(vxlan_encap_conf.vni));
5780 /** Parse VXLAN encap action. */
5782 parse_vc_action_vxlan_encap(struct context *ctx, const struct token *token,
5783 const char *str, unsigned int len,
5784 void *buf, unsigned int size)
5786 struct buffer *out = buf;
5787 struct rte_flow_action *action;
5788 struct action_vxlan_encap_data *action_vxlan_encap_data;
5791 ret = parse_vc(ctx, token, str, len, buf, size);
5794 /* Nothing else to do if there is no buffer. */
5797 if (!out->args.vc.actions_n)
5799 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5800 /* Point to selected object. */
5801 ctx->object = out->args.vc.data;
5802 ctx->objmask = NULL;
5803 action_vxlan_encap_data = ctx->object;
5804 parse_setup_vxlan_encap_data(action_vxlan_encap_data);
5805 action->conf = &action_vxlan_encap_data->conf;
5809 /** Setup NVGRE encap configuration. */
5811 parse_setup_nvgre_encap_data(struct action_nvgre_encap_data *action_nvgre_encap_data)
5813 /* Set up default configuration. */
5814 *action_nvgre_encap_data = (struct action_nvgre_encap_data){
5815 .conf = (struct rte_flow_action_nvgre_encap){
5816 .definition = action_nvgre_encap_data->items,
5820 .type = RTE_FLOW_ITEM_TYPE_ETH,
5821 .spec = &action_nvgre_encap_data->item_eth,
5822 .mask = &rte_flow_item_eth_mask,
5825 .type = RTE_FLOW_ITEM_TYPE_VLAN,
5826 .spec = &action_nvgre_encap_data->item_vlan,
5827 .mask = &rte_flow_item_vlan_mask,
5830 .type = RTE_FLOW_ITEM_TYPE_IPV4,
5831 .spec = &action_nvgre_encap_data->item_ipv4,
5832 .mask = &rte_flow_item_ipv4_mask,
5835 .type = RTE_FLOW_ITEM_TYPE_NVGRE,
5836 .spec = &action_nvgre_encap_data->item_nvgre,
5837 .mask = &rte_flow_item_nvgre_mask,
5840 .type = RTE_FLOW_ITEM_TYPE_END,
5845 .tci = nvgre_encap_conf.vlan_tci,
5849 .src_addr = nvgre_encap_conf.ipv4_src,
5850 .dst_addr = nvgre_encap_conf.ipv4_dst,
5852 .item_nvgre.c_k_s_rsvd0_ver = RTE_BE16(0x2000),
5853 .item_nvgre.protocol = RTE_BE16(RTE_ETHER_TYPE_TEB),
5854 .item_nvgre.flow_id = 0,
5856 memcpy(action_nvgre_encap_data->item_eth.dst.addr_bytes,
5857 nvgre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5858 memcpy(action_nvgre_encap_data->item_eth.src.addr_bytes,
5859 nvgre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5860 if (!nvgre_encap_conf.select_ipv4) {
5861 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.src_addr,
5862 &nvgre_encap_conf.ipv6_src,
5863 sizeof(nvgre_encap_conf.ipv6_src));
5864 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.dst_addr,
5865 &nvgre_encap_conf.ipv6_dst,
5866 sizeof(nvgre_encap_conf.ipv6_dst));
5867 action_nvgre_encap_data->items[2] = (struct rte_flow_item){
5868 .type = RTE_FLOW_ITEM_TYPE_IPV6,
5869 .spec = &action_nvgre_encap_data->item_ipv6,
5870 .mask = &rte_flow_item_ipv6_mask,
5873 if (!nvgre_encap_conf.select_vlan)
5874 action_nvgre_encap_data->items[1].type =
5875 RTE_FLOW_ITEM_TYPE_VOID;
5876 memcpy(action_nvgre_encap_data->item_nvgre.tni, nvgre_encap_conf.tni,
5877 RTE_DIM(nvgre_encap_conf.tni));
5881 /** Parse NVGRE encap action. */
5883 parse_vc_action_nvgre_encap(struct context *ctx, const struct token *token,
5884 const char *str, unsigned int len,
5885 void *buf, unsigned int size)
5887 struct buffer *out = buf;
5888 struct rte_flow_action *action;
5889 struct action_nvgre_encap_data *action_nvgre_encap_data;
5892 ret = parse_vc(ctx, token, str, len, buf, size);
5895 /* Nothing else to do if there is no buffer. */
5898 if (!out->args.vc.actions_n)
5900 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5901 /* Point to selected object. */
5902 ctx->object = out->args.vc.data;
5903 ctx->objmask = NULL;
5904 action_nvgre_encap_data = ctx->object;
5905 parse_setup_nvgre_encap_data(action_nvgre_encap_data);
5906 action->conf = &action_nvgre_encap_data->conf;
5910 /** Parse l2 encap action. */
5912 parse_vc_action_l2_encap(struct context *ctx, const struct token *token,
5913 const char *str, unsigned int len,
5914 void *buf, unsigned int size)
5916 struct buffer *out = buf;
5917 struct rte_flow_action *action;
5918 struct action_raw_encap_data *action_encap_data;
5919 struct rte_flow_item_eth eth = { .type = 0, };
5920 struct rte_flow_item_vlan vlan = {
5921 .tci = mplsoudp_encap_conf.vlan_tci,
5927 ret = parse_vc(ctx, token, str, len, buf, size);
5930 /* Nothing else to do if there is no buffer. */
5933 if (!out->args.vc.actions_n)
5935 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5936 /* Point to selected object. */
5937 ctx->object = out->args.vc.data;
5938 ctx->objmask = NULL;
5939 /* Copy the headers to the buffer. */
5940 action_encap_data = ctx->object;
5941 *action_encap_data = (struct action_raw_encap_data) {
5942 .conf = (struct rte_flow_action_raw_encap){
5943 .data = action_encap_data->data,
5947 header = action_encap_data->data;
5948 if (l2_encap_conf.select_vlan)
5949 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5950 else if (l2_encap_conf.select_ipv4)
5951 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5953 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5954 memcpy(eth.dst.addr_bytes,
5955 l2_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5956 memcpy(eth.src.addr_bytes,
5957 l2_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5958 memcpy(header, ð, sizeof(eth));
5959 header += sizeof(eth);
5960 if (l2_encap_conf.select_vlan) {
5961 if (l2_encap_conf.select_ipv4)
5962 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5964 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5965 memcpy(header, &vlan, sizeof(vlan));
5966 header += sizeof(vlan);
5968 action_encap_data->conf.size = header -
5969 action_encap_data->data;
5970 action->conf = &action_encap_data->conf;
5974 /** Parse l2 decap action. */
5976 parse_vc_action_l2_decap(struct context *ctx, const struct token *token,
5977 const char *str, unsigned int len,
5978 void *buf, unsigned int size)
5980 struct buffer *out = buf;
5981 struct rte_flow_action *action;
5982 struct action_raw_decap_data *action_decap_data;
5983 struct rte_flow_item_eth eth = { .type = 0, };
5984 struct rte_flow_item_vlan vlan = {
5985 .tci = mplsoudp_encap_conf.vlan_tci,
5991 ret = parse_vc(ctx, token, str, len, buf, size);
5994 /* Nothing else to do if there is no buffer. */
5997 if (!out->args.vc.actions_n)
5999 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6000 /* Point to selected object. */
6001 ctx->object = out->args.vc.data;
6002 ctx->objmask = NULL;
6003 /* Copy the headers to the buffer. */
6004 action_decap_data = ctx->object;
6005 *action_decap_data = (struct action_raw_decap_data) {
6006 .conf = (struct rte_flow_action_raw_decap){
6007 .data = action_decap_data->data,
6011 header = action_decap_data->data;
6012 if (l2_decap_conf.select_vlan)
6013 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
6014 memcpy(header, ð, sizeof(eth));
6015 header += sizeof(eth);
6016 if (l2_decap_conf.select_vlan) {
6017 memcpy(header, &vlan, sizeof(vlan));
6018 header += sizeof(vlan);
6020 action_decap_data->conf.size = header -
6021 action_decap_data->data;
6022 action->conf = &action_decap_data->conf;
6026 #define ETHER_TYPE_MPLS_UNICAST 0x8847
6028 /** Parse MPLSOGRE encap action. */
6030 parse_vc_action_mplsogre_encap(struct context *ctx, const struct token *token,
6031 const char *str, unsigned int len,
6032 void *buf, unsigned int size)
6034 struct buffer *out = buf;
6035 struct rte_flow_action *action;
6036 struct action_raw_encap_data *action_encap_data;
6037 struct rte_flow_item_eth eth = { .type = 0, };
6038 struct rte_flow_item_vlan vlan = {
6039 .tci = mplsogre_encap_conf.vlan_tci,
6042 struct rte_flow_item_ipv4 ipv4 = {
6044 .src_addr = mplsogre_encap_conf.ipv4_src,
6045 .dst_addr = mplsogre_encap_conf.ipv4_dst,
6046 .next_proto_id = IPPROTO_GRE,
6047 .version_ihl = RTE_IPV4_VHL_DEF,
6048 .time_to_live = IPDEFTTL,
6051 struct rte_flow_item_ipv6 ipv6 = {
6053 .proto = IPPROTO_GRE,
6054 .hop_limits = IPDEFTTL,
6057 struct rte_flow_item_gre gre = {
6058 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
6060 struct rte_flow_item_mpls mpls = {
6066 ret = parse_vc(ctx, token, str, len, buf, size);
6069 /* Nothing else to do if there is no buffer. */
6072 if (!out->args.vc.actions_n)
6074 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6075 /* Point to selected object. */
6076 ctx->object = out->args.vc.data;
6077 ctx->objmask = NULL;
6078 /* Copy the headers to the buffer. */
6079 action_encap_data = ctx->object;
6080 *action_encap_data = (struct action_raw_encap_data) {
6081 .conf = (struct rte_flow_action_raw_encap){
6082 .data = action_encap_data->data,
6087 header = action_encap_data->data;
6088 if (mplsogre_encap_conf.select_vlan)
6089 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
6090 else if (mplsogre_encap_conf.select_ipv4)
6091 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6093 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6094 memcpy(eth.dst.addr_bytes,
6095 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
6096 memcpy(eth.src.addr_bytes,
6097 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
6098 memcpy(header, ð, sizeof(eth));
6099 header += sizeof(eth);
6100 if (mplsogre_encap_conf.select_vlan) {
6101 if (mplsogre_encap_conf.select_ipv4)
6102 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6104 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6105 memcpy(header, &vlan, sizeof(vlan));
6106 header += sizeof(vlan);
6108 if (mplsogre_encap_conf.select_ipv4) {
6109 memcpy(header, &ipv4, sizeof(ipv4));
6110 header += sizeof(ipv4);
6112 memcpy(&ipv6.hdr.src_addr,
6113 &mplsogre_encap_conf.ipv6_src,
6114 sizeof(mplsogre_encap_conf.ipv6_src));
6115 memcpy(&ipv6.hdr.dst_addr,
6116 &mplsogre_encap_conf.ipv6_dst,
6117 sizeof(mplsogre_encap_conf.ipv6_dst));
6118 memcpy(header, &ipv6, sizeof(ipv6));
6119 header += sizeof(ipv6);
6121 memcpy(header, &gre, sizeof(gre));
6122 header += sizeof(gre);
6123 memcpy(mpls.label_tc_s, mplsogre_encap_conf.label,
6124 RTE_DIM(mplsogre_encap_conf.label));
6125 mpls.label_tc_s[2] |= 0x1;
6126 memcpy(header, &mpls, sizeof(mpls));
6127 header += sizeof(mpls);
6128 action_encap_data->conf.size = header -
6129 action_encap_data->data;
6130 action->conf = &action_encap_data->conf;
6134 /** Parse MPLSOGRE decap action. */
6136 parse_vc_action_mplsogre_decap(struct context *ctx, const struct token *token,
6137 const char *str, unsigned int len,
6138 void *buf, unsigned int size)
6140 struct buffer *out = buf;
6141 struct rte_flow_action *action;
6142 struct action_raw_decap_data *action_decap_data;
6143 struct rte_flow_item_eth eth = { .type = 0, };
6144 struct rte_flow_item_vlan vlan = {.tci = 0};
6145 struct rte_flow_item_ipv4 ipv4 = {
6147 .next_proto_id = IPPROTO_GRE,
6150 struct rte_flow_item_ipv6 ipv6 = {
6152 .proto = IPPROTO_GRE,
6155 struct rte_flow_item_gre gre = {
6156 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
6158 struct rte_flow_item_mpls mpls;
6162 ret = parse_vc(ctx, token, str, len, buf, size);
6165 /* Nothing else to do if there is no buffer. */
6168 if (!out->args.vc.actions_n)
6170 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6171 /* Point to selected object. */
6172 ctx->object = out->args.vc.data;
6173 ctx->objmask = NULL;
6174 /* Copy the headers to the buffer. */
6175 action_decap_data = ctx->object;
6176 *action_decap_data = (struct action_raw_decap_data) {
6177 .conf = (struct rte_flow_action_raw_decap){
6178 .data = action_decap_data->data,
6182 header = action_decap_data->data;
6183 if (mplsogre_decap_conf.select_vlan)
6184 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
6185 else if (mplsogre_encap_conf.select_ipv4)
6186 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6188 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6189 memcpy(eth.dst.addr_bytes,
6190 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
6191 memcpy(eth.src.addr_bytes,
6192 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
6193 memcpy(header, ð, sizeof(eth));
6194 header += sizeof(eth);
6195 if (mplsogre_encap_conf.select_vlan) {
6196 if (mplsogre_encap_conf.select_ipv4)
6197 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6199 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6200 memcpy(header, &vlan, sizeof(vlan));
6201 header += sizeof(vlan);
6203 if (mplsogre_encap_conf.select_ipv4) {
6204 memcpy(header, &ipv4, sizeof(ipv4));
6205 header += sizeof(ipv4);
6207 memcpy(header, &ipv6, sizeof(ipv6));
6208 header += sizeof(ipv6);
6210 memcpy(header, &gre, sizeof(gre));
6211 header += sizeof(gre);
6212 memset(&mpls, 0, sizeof(mpls));
6213 memcpy(header, &mpls, sizeof(mpls));
6214 header += sizeof(mpls);
6215 action_decap_data->conf.size = header -
6216 action_decap_data->data;
6217 action->conf = &action_decap_data->conf;
6221 /** Parse MPLSOUDP encap action. */
6223 parse_vc_action_mplsoudp_encap(struct context *ctx, const struct token *token,
6224 const char *str, unsigned int len,
6225 void *buf, unsigned int size)
6227 struct buffer *out = buf;
6228 struct rte_flow_action *action;
6229 struct action_raw_encap_data *action_encap_data;
6230 struct rte_flow_item_eth eth = { .type = 0, };
6231 struct rte_flow_item_vlan vlan = {
6232 .tci = mplsoudp_encap_conf.vlan_tci,
6235 struct rte_flow_item_ipv4 ipv4 = {
6237 .src_addr = mplsoudp_encap_conf.ipv4_src,
6238 .dst_addr = mplsoudp_encap_conf.ipv4_dst,
6239 .next_proto_id = IPPROTO_UDP,
6240 .version_ihl = RTE_IPV4_VHL_DEF,
6241 .time_to_live = IPDEFTTL,
6244 struct rte_flow_item_ipv6 ipv6 = {
6246 .proto = IPPROTO_UDP,
6247 .hop_limits = IPDEFTTL,
6250 struct rte_flow_item_udp udp = {
6252 .src_port = mplsoudp_encap_conf.udp_src,
6253 .dst_port = mplsoudp_encap_conf.udp_dst,
6256 struct rte_flow_item_mpls mpls;
6260 ret = parse_vc(ctx, token, str, len, buf, size);
6263 /* Nothing else to do if there is no buffer. */
6266 if (!out->args.vc.actions_n)
6268 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6269 /* Point to selected object. */
6270 ctx->object = out->args.vc.data;
6271 ctx->objmask = NULL;
6272 /* Copy the headers to the buffer. */
6273 action_encap_data = ctx->object;
6274 *action_encap_data = (struct action_raw_encap_data) {
6275 .conf = (struct rte_flow_action_raw_encap){
6276 .data = action_encap_data->data,
6281 header = action_encap_data->data;
6282 if (mplsoudp_encap_conf.select_vlan)
6283 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
6284 else if (mplsoudp_encap_conf.select_ipv4)
6285 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6287 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6288 memcpy(eth.dst.addr_bytes,
6289 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
6290 memcpy(eth.src.addr_bytes,
6291 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
6292 memcpy(header, ð, sizeof(eth));
6293 header += sizeof(eth);
6294 if (mplsoudp_encap_conf.select_vlan) {
6295 if (mplsoudp_encap_conf.select_ipv4)
6296 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6298 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6299 memcpy(header, &vlan, sizeof(vlan));
6300 header += sizeof(vlan);
6302 if (mplsoudp_encap_conf.select_ipv4) {
6303 memcpy(header, &ipv4, sizeof(ipv4));
6304 header += sizeof(ipv4);
6306 memcpy(&ipv6.hdr.src_addr,
6307 &mplsoudp_encap_conf.ipv6_src,
6308 sizeof(mplsoudp_encap_conf.ipv6_src));
6309 memcpy(&ipv6.hdr.dst_addr,
6310 &mplsoudp_encap_conf.ipv6_dst,
6311 sizeof(mplsoudp_encap_conf.ipv6_dst));
6312 memcpy(header, &ipv6, sizeof(ipv6));
6313 header += sizeof(ipv6);
6315 memcpy(header, &udp, sizeof(udp));
6316 header += sizeof(udp);
6317 memcpy(mpls.label_tc_s, mplsoudp_encap_conf.label,
6318 RTE_DIM(mplsoudp_encap_conf.label));
6319 mpls.label_tc_s[2] |= 0x1;
6320 memcpy(header, &mpls, sizeof(mpls));
6321 header += sizeof(mpls);
6322 action_encap_data->conf.size = header -
6323 action_encap_data->data;
6324 action->conf = &action_encap_data->conf;
6328 /** Parse MPLSOUDP decap action. */
6330 parse_vc_action_mplsoudp_decap(struct context *ctx, const struct token *token,
6331 const char *str, unsigned int len,
6332 void *buf, unsigned int size)
6334 struct buffer *out = buf;
6335 struct rte_flow_action *action;
6336 struct action_raw_decap_data *action_decap_data;
6337 struct rte_flow_item_eth eth = { .type = 0, };
6338 struct rte_flow_item_vlan vlan = {.tci = 0};
6339 struct rte_flow_item_ipv4 ipv4 = {
6341 .next_proto_id = IPPROTO_UDP,
6344 struct rte_flow_item_ipv6 ipv6 = {
6346 .proto = IPPROTO_UDP,
6349 struct rte_flow_item_udp udp = {
6351 .dst_port = rte_cpu_to_be_16(6635),
6354 struct rte_flow_item_mpls mpls;
6358 ret = parse_vc(ctx, token, str, len, buf, size);
6361 /* Nothing else to do if there is no buffer. */
6364 if (!out->args.vc.actions_n)
6366 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6367 /* Point to selected object. */
6368 ctx->object = out->args.vc.data;
6369 ctx->objmask = NULL;
6370 /* Copy the headers to the buffer. */
6371 action_decap_data = ctx->object;
6372 *action_decap_data = (struct action_raw_decap_data) {
6373 .conf = (struct rte_flow_action_raw_decap){
6374 .data = action_decap_data->data,
6378 header = action_decap_data->data;
6379 if (mplsoudp_decap_conf.select_vlan)
6380 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
6381 else if (mplsoudp_encap_conf.select_ipv4)
6382 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6384 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6385 memcpy(eth.dst.addr_bytes,
6386 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
6387 memcpy(eth.src.addr_bytes,
6388 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
6389 memcpy(header, ð, sizeof(eth));
6390 header += sizeof(eth);
6391 if (mplsoudp_encap_conf.select_vlan) {
6392 if (mplsoudp_encap_conf.select_ipv4)
6393 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6395 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6396 memcpy(header, &vlan, sizeof(vlan));
6397 header += sizeof(vlan);
6399 if (mplsoudp_encap_conf.select_ipv4) {
6400 memcpy(header, &ipv4, sizeof(ipv4));
6401 header += sizeof(ipv4);
6403 memcpy(header, &ipv6, sizeof(ipv6));
6404 header += sizeof(ipv6);
6406 memcpy(header, &udp, sizeof(udp));
6407 header += sizeof(udp);
6408 memset(&mpls, 0, sizeof(mpls));
6409 memcpy(header, &mpls, sizeof(mpls));
6410 header += sizeof(mpls);
6411 action_decap_data->conf.size = header -
6412 action_decap_data->data;
6413 action->conf = &action_decap_data->conf;
6418 parse_vc_action_raw_decap_index(struct context *ctx, const struct token *token,
6419 const char *str, unsigned int len, void *buf,
6422 struct action_raw_decap_data *action_raw_decap_data;
6423 struct rte_flow_action *action;
6424 const struct arg *arg;
6425 struct buffer *out = buf;
6429 RTE_SET_USED(token);
6432 arg = ARGS_ENTRY_ARB_BOUNDED
6433 (offsetof(struct action_raw_decap_data, idx),
6434 sizeof(((struct action_raw_decap_data *)0)->idx),
6435 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
6436 if (push_args(ctx, arg))
6438 ret = parse_int(ctx, token, str, len, NULL, 0);
6445 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6446 action_raw_decap_data = ctx->object;
6447 idx = action_raw_decap_data->idx;
6448 action_raw_decap_data->conf.data = raw_decap_confs[idx].data;
6449 action_raw_decap_data->conf.size = raw_decap_confs[idx].size;
6450 action->conf = &action_raw_decap_data->conf;
6456 parse_vc_action_raw_encap_index(struct context *ctx, const struct token *token,
6457 const char *str, unsigned int len, void *buf,
6460 struct action_raw_encap_data *action_raw_encap_data;
6461 struct rte_flow_action *action;
6462 const struct arg *arg;
6463 struct buffer *out = buf;
6467 RTE_SET_USED(token);
6470 if (ctx->curr != ACTION_RAW_ENCAP_INDEX_VALUE)
6472 arg = ARGS_ENTRY_ARB_BOUNDED
6473 (offsetof(struct action_raw_encap_data, idx),
6474 sizeof(((struct action_raw_encap_data *)0)->idx),
6475 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
6476 if (push_args(ctx, arg))
6478 ret = parse_int(ctx, token, str, len, NULL, 0);
6485 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6486 action_raw_encap_data = ctx->object;
6487 idx = action_raw_encap_data->idx;
6488 action_raw_encap_data->conf.data = raw_encap_confs[idx].data;
6489 action_raw_encap_data->conf.size = raw_encap_confs[idx].size;
6490 action_raw_encap_data->conf.preserve = NULL;
6491 action->conf = &action_raw_encap_data->conf;
6496 parse_vc_action_raw_encap(struct context *ctx, const struct token *token,
6497 const char *str, unsigned int len, void *buf,
6500 struct buffer *out = buf;
6501 struct rte_flow_action *action;
6502 struct action_raw_encap_data *action_raw_encap_data = NULL;
6505 ret = parse_vc(ctx, token, str, len, buf, size);
6508 /* Nothing else to do if there is no buffer. */
6511 if (!out->args.vc.actions_n)
6513 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6514 /* Point to selected object. */
6515 ctx->object = out->args.vc.data;
6516 ctx->objmask = NULL;
6517 /* Copy the headers to the buffer. */
6518 action_raw_encap_data = ctx->object;
6519 action_raw_encap_data->conf.data = raw_encap_confs[0].data;
6520 action_raw_encap_data->conf.preserve = NULL;
6521 action_raw_encap_data->conf.size = raw_encap_confs[0].size;
6522 action->conf = &action_raw_encap_data->conf;
6527 parse_vc_action_raw_decap(struct context *ctx, const struct token *token,
6528 const char *str, unsigned int len, void *buf,
6531 struct buffer *out = buf;
6532 struct rte_flow_action *action;
6533 struct action_raw_decap_data *action_raw_decap_data = NULL;
6536 ret = parse_vc(ctx, token, str, len, buf, size);
6539 /* Nothing else to do if there is no buffer. */
6542 if (!out->args.vc.actions_n)
6544 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6545 /* Point to selected object. */
6546 ctx->object = out->args.vc.data;
6547 ctx->objmask = NULL;
6548 /* Copy the headers to the buffer. */
6549 action_raw_decap_data = ctx->object;
6550 action_raw_decap_data->conf.data = raw_decap_confs[0].data;
6551 action_raw_decap_data->conf.size = raw_decap_confs[0].size;
6552 action->conf = &action_raw_decap_data->conf;
6557 parse_vc_action_set_meta(struct context *ctx, const struct token *token,
6558 const char *str, unsigned int len, void *buf,
6563 ret = parse_vc(ctx, token, str, len, buf, size);
6566 ret = rte_flow_dynf_metadata_register();
6573 parse_vc_action_sample(struct context *ctx, const struct token *token,
6574 const char *str, unsigned int len, void *buf,
6577 struct buffer *out = buf;
6578 struct rte_flow_action *action;
6579 struct action_sample_data *action_sample_data = NULL;
6580 static struct rte_flow_action end_action = {
6581 RTE_FLOW_ACTION_TYPE_END, 0
6585 ret = parse_vc(ctx, token, str, len, buf, size);
6588 /* Nothing else to do if there is no buffer. */
6591 if (!out->args.vc.actions_n)
6593 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6594 /* Point to selected object. */
6595 ctx->object = out->args.vc.data;
6596 ctx->objmask = NULL;
6597 /* Copy the headers to the buffer. */
6598 action_sample_data = ctx->object;
6599 action_sample_data->conf.actions = &end_action;
6600 action->conf = &action_sample_data->conf;
6605 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
6606 const char *str, unsigned int len, void *buf,
6609 struct action_sample_data *action_sample_data;
6610 struct rte_flow_action *action;
6611 const struct arg *arg;
6612 struct buffer *out = buf;
6616 RTE_SET_USED(token);
6619 if (ctx->curr != ACTION_SAMPLE_INDEX_VALUE)
6621 arg = ARGS_ENTRY_ARB_BOUNDED
6622 (offsetof(struct action_sample_data, idx),
6623 sizeof(((struct action_sample_data *)0)->idx),
6624 0, RAW_SAMPLE_CONFS_MAX_NUM - 1);
6625 if (push_args(ctx, arg))
6627 ret = parse_int(ctx, token, str, len, NULL, 0);
6634 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6635 action_sample_data = ctx->object;
6636 idx = action_sample_data->idx;
6637 action_sample_data->conf.actions = raw_sample_confs[idx].data;
6638 action->conf = &action_sample_data->conf;
6642 /** Parse operation for modify_field command. */
6644 parse_vc_modify_field_op(struct context *ctx, const struct token *token,
6645 const char *str, unsigned int len, void *buf,
6648 struct rte_flow_action_modify_field *action_modify_field;
6654 if (ctx->curr != ACTION_MODIFY_FIELD_OP_VALUE)
6656 for (i = 0; modify_field_ops[i]; ++i)
6657 if (!strcmp_partial(modify_field_ops[i], str, len))
6659 if (!modify_field_ops[i])
6663 action_modify_field = ctx->object;
6664 action_modify_field->operation = (enum rte_flow_modify_op)i;
6668 /** Parse id for modify_field command. */
6670 parse_vc_modify_field_id(struct context *ctx, const struct token *token,
6671 const char *str, unsigned int len, void *buf,
6674 struct rte_flow_action_modify_field *action_modify_field;
6680 if (ctx->curr != ACTION_MODIFY_FIELD_DST_TYPE_VALUE &&
6681 ctx->curr != ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)
6683 for (i = 0; modify_field_ids[i]; ++i)
6684 if (!strcmp_partial(modify_field_ids[i], str, len))
6686 if (!modify_field_ids[i])
6690 action_modify_field = ctx->object;
6691 if (ctx->curr == ACTION_MODIFY_FIELD_DST_TYPE_VALUE)
6692 action_modify_field->dst.field = (enum rte_flow_field_id)i;
6694 action_modify_field->src.field = (enum rte_flow_field_id)i;
6698 /** Parse the conntrack update, not a rte_flow_action. */
6700 parse_vc_action_conntrack_update(struct context *ctx, const struct token *token,
6701 const char *str, unsigned int len, void *buf,
6704 struct buffer *out = buf;
6705 struct rte_flow_modify_conntrack *ct_modify = NULL;
6708 if (ctx->curr != ACTION_CONNTRACK_UPDATE_CTX &&
6709 ctx->curr != ACTION_CONNTRACK_UPDATE_DIR)
6711 /* Token name must match. */
6712 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6714 /* Nothing else to do if there is no buffer. */
6717 ct_modify = (struct rte_flow_modify_conntrack *)out->args.vc.data;
6718 if (ctx->curr == ACTION_CONNTRACK_UPDATE_DIR) {
6719 ct_modify->new_ct.is_original_dir =
6720 conntrack_context.is_original_dir;
6721 ct_modify->direction = 1;
6725 old_dir = ct_modify->new_ct.is_original_dir;
6726 memcpy(&ct_modify->new_ct, &conntrack_context,
6727 sizeof(conntrack_context));
6728 ct_modify->new_ct.is_original_dir = old_dir;
6729 ct_modify->state = 1;
6734 /** Parse tokens for destroy command. */
6736 parse_destroy(struct context *ctx, const struct token *token,
6737 const char *str, unsigned int len,
6738 void *buf, unsigned int size)
6740 struct buffer *out = buf;
6742 /* Token name must match. */
6743 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6745 /* Nothing else to do if there is no buffer. */
6748 if (!out->command) {
6749 if (ctx->curr != DESTROY)
6751 if (sizeof(*out) > size)
6753 out->command = ctx->curr;
6756 ctx->objmask = NULL;
6757 out->args.destroy.rule =
6758 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6762 if (((uint8_t *)(out->args.destroy.rule + out->args.destroy.rule_n) +
6763 sizeof(*out->args.destroy.rule)) > (uint8_t *)out + size)
6766 ctx->object = out->args.destroy.rule + out->args.destroy.rule_n++;
6767 ctx->objmask = NULL;
6771 /** Parse tokens for flush command. */
6773 parse_flush(struct context *ctx, const struct token *token,
6774 const char *str, unsigned int len,
6775 void *buf, unsigned int size)
6777 struct buffer *out = buf;
6779 /* Token name must match. */
6780 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6782 /* Nothing else to do if there is no buffer. */
6785 if (!out->command) {
6786 if (ctx->curr != FLUSH)
6788 if (sizeof(*out) > size)
6790 out->command = ctx->curr;
6793 ctx->objmask = NULL;
6798 /** Parse tokens for dump command. */
6800 parse_dump(struct context *ctx, const struct token *token,
6801 const char *str, unsigned int len,
6802 void *buf, unsigned int size)
6804 struct buffer *out = buf;
6806 /* Token name must match. */
6807 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6809 /* Nothing else to do if there is no buffer. */
6812 if (!out->command) {
6813 if (ctx->curr != DUMP)
6815 if (sizeof(*out) > size)
6817 out->command = ctx->curr;
6820 ctx->objmask = NULL;
6823 switch (ctx->curr) {
6826 out->args.dump.mode = (ctx->curr == DUMP_ALL) ? true : false;
6827 out->command = ctx->curr;
6830 ctx->objmask = NULL;
6837 /** Parse tokens for query command. */
6839 parse_query(struct context *ctx, const struct token *token,
6840 const char *str, unsigned int len,
6841 void *buf, unsigned int size)
6843 struct buffer *out = buf;
6845 /* Token name must match. */
6846 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6848 /* Nothing else to do if there is no buffer. */
6851 if (!out->command) {
6852 if (ctx->curr != QUERY)
6854 if (sizeof(*out) > size)
6856 out->command = ctx->curr;
6859 ctx->objmask = NULL;
6864 /** Parse action names. */
6866 parse_action(struct context *ctx, const struct token *token,
6867 const char *str, unsigned int len,
6868 void *buf, unsigned int size)
6870 struct buffer *out = buf;
6871 const struct arg *arg = pop_args(ctx);
6875 /* Argument is expected. */
6878 /* Parse action name. */
6879 for (i = 0; next_action[i]; ++i) {
6880 const struct parse_action_priv *priv;
6882 token = &token_list[next_action[i]];
6883 if (strcmp_partial(token->name, str, len))
6889 memcpy((uint8_t *)ctx->object + arg->offset,
6895 push_args(ctx, arg);
6899 /** Parse tokens for list command. */
6901 parse_list(struct context *ctx, const struct token *token,
6902 const char *str, unsigned int len,
6903 void *buf, unsigned int size)
6905 struct buffer *out = buf;
6907 /* Token name must match. */
6908 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6910 /* Nothing else to do if there is no buffer. */
6913 if (!out->command) {
6914 if (ctx->curr != LIST)
6916 if (sizeof(*out) > size)
6918 out->command = ctx->curr;
6921 ctx->objmask = NULL;
6922 out->args.list.group =
6923 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6927 if (((uint8_t *)(out->args.list.group + out->args.list.group_n) +
6928 sizeof(*out->args.list.group)) > (uint8_t *)out + size)
6931 ctx->object = out->args.list.group + out->args.list.group_n++;
6932 ctx->objmask = NULL;
6936 /** Parse tokens for list all aged flows command. */
6938 parse_aged(struct context *ctx, const struct token *token,
6939 const char *str, unsigned int len,
6940 void *buf, unsigned int size)
6942 struct buffer *out = buf;
6944 /* Token name must match. */
6945 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6947 /* Nothing else to do if there is no buffer. */
6950 if (!out->command) {
6951 if (ctx->curr != AGED)
6953 if (sizeof(*out) > size)
6955 out->command = ctx->curr;
6958 ctx->objmask = NULL;
6960 if (ctx->curr == AGED_DESTROY)
6961 out->args.aged.destroy = 1;
6965 /** Parse tokens for isolate command. */
6967 parse_isolate(struct context *ctx, const struct token *token,
6968 const char *str, unsigned int len,
6969 void *buf, unsigned int size)
6971 struct buffer *out = buf;
6973 /* Token name must match. */
6974 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6976 /* Nothing else to do if there is no buffer. */
6979 if (!out->command) {
6980 if (ctx->curr != ISOLATE)
6982 if (sizeof(*out) > size)
6984 out->command = ctx->curr;
6987 ctx->objmask = NULL;
6993 parse_tunnel(struct context *ctx, const struct token *token,
6994 const char *str, unsigned int len,
6995 void *buf, unsigned int size)
6997 struct buffer *out = buf;
6999 /* Token name must match. */
7000 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7002 /* Nothing else to do if there is no buffer. */
7005 if (!out->command) {
7006 if (ctx->curr != TUNNEL)
7008 if (sizeof(*out) > size)
7010 out->command = ctx->curr;
7013 ctx->objmask = NULL;
7015 switch (ctx->curr) {
7019 case TUNNEL_DESTROY:
7021 out->command = ctx->curr;
7023 case TUNNEL_CREATE_TYPE:
7024 case TUNNEL_DESTROY_ID:
7025 ctx->object = &out->args.vc.tunnel_ops;
7034 * Parse signed/unsigned integers 8 to 64-bit long.
7036 * Last argument (ctx->args) is retrieved to determine integer type and
7040 parse_int(struct context *ctx, const struct token *token,
7041 const char *str, unsigned int len,
7042 void *buf, unsigned int size)
7044 const struct arg *arg = pop_args(ctx);
7049 /* Argument is expected. */
7054 (uintmax_t)strtoimax(str, &end, 0) :
7055 strtoumax(str, &end, 0);
7056 if (errno || (size_t)(end - str) != len)
7059 ((arg->sign && ((intmax_t)u < (intmax_t)arg->min ||
7060 (intmax_t)u > (intmax_t)arg->max)) ||
7061 (!arg->sign && (u < arg->min || u > arg->max))))
7066 if (!arg_entry_bf_fill(ctx->object, u, arg) ||
7067 !arg_entry_bf_fill(ctx->objmask, -1, arg))
7071 buf = (uint8_t *)ctx->object + arg->offset;
7073 if (u > RTE_LEN2MASK(size * CHAR_BIT, uint64_t))
7077 case sizeof(uint8_t):
7078 *(uint8_t *)buf = u;
7080 case sizeof(uint16_t):
7081 *(uint16_t *)buf = arg->hton ? rte_cpu_to_be_16(u) : u;
7083 case sizeof(uint8_t [3]):
7084 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
7086 ((uint8_t *)buf)[0] = u;
7087 ((uint8_t *)buf)[1] = u >> 8;
7088 ((uint8_t *)buf)[2] = u >> 16;
7092 ((uint8_t *)buf)[0] = u >> 16;
7093 ((uint8_t *)buf)[1] = u >> 8;
7094 ((uint8_t *)buf)[2] = u;
7096 case sizeof(uint32_t):
7097 *(uint32_t *)buf = arg->hton ? rte_cpu_to_be_32(u) : u;
7099 case sizeof(uint64_t):
7100 *(uint64_t *)buf = arg->hton ? rte_cpu_to_be_64(u) : u;
7105 if (ctx->objmask && buf != (uint8_t *)ctx->objmask + arg->offset) {
7107 buf = (uint8_t *)ctx->objmask + arg->offset;
7112 push_args(ctx, arg);
7119 * Three arguments (ctx->args) are retrieved from the stack to store data,
7120 * its actual length and address (in that order).
7123 parse_string(struct context *ctx, const struct token *token,
7124 const char *str, unsigned int len,
7125 void *buf, unsigned int size)
7127 const struct arg *arg_data = pop_args(ctx);
7128 const struct arg *arg_len = pop_args(ctx);
7129 const struct arg *arg_addr = pop_args(ctx);
7130 char tmp[16]; /* Ought to be enough. */
7133 /* Arguments are expected. */
7137 push_args(ctx, arg_data);
7141 push_args(ctx, arg_len);
7142 push_args(ctx, arg_data);
7145 size = arg_data->size;
7146 /* Bit-mask fill is not supported. */
7147 if (arg_data->mask || size < len)
7151 /* Let parse_int() fill length information first. */
7152 ret = snprintf(tmp, sizeof(tmp), "%u", len);
7155 push_args(ctx, arg_len);
7156 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
7161 buf = (uint8_t *)ctx->object + arg_data->offset;
7162 /* Output buffer is not necessarily NUL-terminated. */
7163 memcpy(buf, str, len);
7164 memset((uint8_t *)buf + len, 0x00, size - len);
7166 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
7167 /* Save address if requested. */
7168 if (arg_addr->size) {
7169 memcpy((uint8_t *)ctx->object + arg_addr->offset,
7171 (uint8_t *)ctx->object + arg_data->offset
7175 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
7177 (uint8_t *)ctx->objmask + arg_data->offset
7183 push_args(ctx, arg_addr);
7184 push_args(ctx, arg_len);
7185 push_args(ctx, arg_data);
7190 parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
7196 /* Check input parameters */
7197 if ((src == NULL) ||
7203 /* Convert chars to bytes */
7204 for (i = 0, len = 0; i < *size; i += 2) {
7205 snprintf(tmp, 3, "%s", src + i);
7206 dst[len++] = strtoul(tmp, &c, 16);
7221 parse_hex(struct context *ctx, const struct token *token,
7222 const char *str, unsigned int len,
7223 void *buf, unsigned int size)
7225 const struct arg *arg_data = pop_args(ctx);
7226 const struct arg *arg_len = pop_args(ctx);
7227 const struct arg *arg_addr = pop_args(ctx);
7228 char tmp[16]; /* Ought to be enough. */
7230 unsigned int hexlen = len;
7231 unsigned int length = 256;
7232 uint8_t hex_tmp[length];
7234 /* Arguments are expected. */
7238 push_args(ctx, arg_data);
7242 push_args(ctx, arg_len);
7243 push_args(ctx, arg_data);
7246 size = arg_data->size;
7247 /* Bit-mask fill is not supported. */
7253 /* translate bytes string to array. */
7254 if (str[0] == '0' && ((str[1] == 'x') ||
7259 if (hexlen > length)
7261 ret = parse_hex_string(str, hex_tmp, &hexlen);
7264 /* Let parse_int() fill length information first. */
7265 ret = snprintf(tmp, sizeof(tmp), "%u", hexlen);
7268 /* Save length if requested. */
7269 if (arg_len->size) {
7270 push_args(ctx, arg_len);
7271 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
7277 buf = (uint8_t *)ctx->object + arg_data->offset;
7278 /* Output buffer is not necessarily NUL-terminated. */
7279 memcpy(buf, hex_tmp, hexlen);
7280 memset((uint8_t *)buf + hexlen, 0x00, size - hexlen);
7282 memset((uint8_t *)ctx->objmask + arg_data->offset,
7284 /* Save address if requested. */
7285 if (arg_addr->size) {
7286 memcpy((uint8_t *)ctx->object + arg_addr->offset,
7288 (uint8_t *)ctx->object + arg_data->offset
7292 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
7294 (uint8_t *)ctx->objmask + arg_data->offset
7300 push_args(ctx, arg_addr);
7301 push_args(ctx, arg_len);
7302 push_args(ctx, arg_data);
7308 * Parse a zero-ended string.
7311 parse_string0(struct context *ctx, const struct token *token __rte_unused,
7312 const char *str, unsigned int len,
7313 void *buf, unsigned int size)
7315 const struct arg *arg_data = pop_args(ctx);
7317 /* Arguments are expected. */
7320 size = arg_data->size;
7321 /* Bit-mask fill is not supported. */
7322 if (arg_data->mask || size < len + 1)
7326 buf = (uint8_t *)ctx->object + arg_data->offset;
7327 strncpy(buf, str, len);
7329 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
7332 push_args(ctx, arg_data);
7337 * Parse a MAC address.
7339 * Last argument (ctx->args) is retrieved to determine storage size and
7343 parse_mac_addr(struct context *ctx, const struct token *token,
7344 const char *str, unsigned int len,
7345 void *buf, unsigned int size)
7347 const struct arg *arg = pop_args(ctx);
7348 struct rte_ether_addr tmp;
7352 /* Argument is expected. */
7356 /* Bit-mask fill is not supported. */
7357 if (arg->mask || size != sizeof(tmp))
7359 /* Only network endian is supported. */
7362 ret = cmdline_parse_etheraddr(NULL, str, &tmp, size);
7363 if (ret < 0 || (unsigned int)ret != len)
7367 buf = (uint8_t *)ctx->object + arg->offset;
7368 memcpy(buf, &tmp, size);
7370 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
7373 push_args(ctx, arg);
7378 * Parse an IPv4 address.
7380 * Last argument (ctx->args) is retrieved to determine storage size and
7384 parse_ipv4_addr(struct context *ctx, const struct token *token,
7385 const char *str, unsigned int len,
7386 void *buf, unsigned int size)
7388 const struct arg *arg = pop_args(ctx);
7393 /* Argument is expected. */
7397 /* Bit-mask fill is not supported. */
7398 if (arg->mask || size != sizeof(tmp))
7400 /* Only network endian is supported. */
7403 memcpy(str2, str, len);
7405 ret = inet_pton(AF_INET, str2, &tmp);
7407 /* Attempt integer parsing. */
7408 push_args(ctx, arg);
7409 return parse_int(ctx, token, str, len, buf, size);
7413 buf = (uint8_t *)ctx->object + arg->offset;
7414 memcpy(buf, &tmp, size);
7416 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
7419 push_args(ctx, arg);
7424 * Parse an IPv6 address.
7426 * Last argument (ctx->args) is retrieved to determine storage size and
7430 parse_ipv6_addr(struct context *ctx, const struct token *token,
7431 const char *str, unsigned int len,
7432 void *buf, unsigned int size)
7434 const struct arg *arg = pop_args(ctx);
7436 struct in6_addr tmp;
7440 /* Argument is expected. */
7444 /* Bit-mask fill is not supported. */
7445 if (arg->mask || size != sizeof(tmp))
7447 /* Only network endian is supported. */
7450 memcpy(str2, str, len);
7452 ret = inet_pton(AF_INET6, str2, &tmp);
7457 buf = (uint8_t *)ctx->object + arg->offset;
7458 memcpy(buf, &tmp, size);
7460 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
7463 push_args(ctx, arg);
7467 /** Boolean values (even indices stand for false). */
7468 static const char *const boolean_name[] = {
7478 * Parse a boolean value.
7480 * Last argument (ctx->args) is retrieved to determine storage size and
7484 parse_boolean(struct context *ctx, const struct token *token,
7485 const char *str, unsigned int len,
7486 void *buf, unsigned int size)
7488 const struct arg *arg = pop_args(ctx);
7492 /* Argument is expected. */
7495 for (i = 0; boolean_name[i]; ++i)
7496 if (!strcmp_partial(boolean_name[i], str, len))
7498 /* Process token as integer. */
7499 if (boolean_name[i])
7500 str = i & 1 ? "1" : "0";
7501 push_args(ctx, arg);
7502 ret = parse_int(ctx, token, str, strlen(str), buf, size);
7503 return ret > 0 ? (int)len : ret;
7506 /** Parse port and update context. */
7508 parse_port(struct context *ctx, const struct token *token,
7509 const char *str, unsigned int len,
7510 void *buf, unsigned int size)
7512 struct buffer *out = &(struct buffer){ .port = 0 };
7520 ctx->objmask = NULL;
7521 size = sizeof(*out);
7523 ret = parse_int(ctx, token, str, len, out, size);
7525 ctx->port = out->port;
7532 parse_ia_id2ptr(struct context *ctx, const struct token *token,
7533 const char *str, unsigned int len,
7534 void *buf, unsigned int size)
7536 struct rte_flow_action *action = ctx->object;
7544 ctx->objmask = NULL;
7545 ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
7546 ctx->object = action;
7547 if (ret != (int)len)
7549 /* set indirect action */
7551 action->conf = port_action_handle_get_by_id(ctx->port, id);
7552 ret = (action->conf) ? ret : -1;
7557 /** Parse set command, initialize output buffer for subsequent tokens. */
7559 parse_set_raw_encap_decap(struct context *ctx, const struct token *token,
7560 const char *str, unsigned int len,
7561 void *buf, unsigned int size)
7563 struct buffer *out = buf;
7565 /* Token name must match. */
7566 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7568 /* Nothing else to do if there is no buffer. */
7571 /* Make sure buffer is large enough. */
7572 if (size < sizeof(*out))
7575 ctx->objmask = NULL;
7579 out->command = ctx->curr;
7580 /* For encap/decap we need is pattern */
7581 out->args.vc.pattern = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7586 /** Parse set command, initialize output buffer for subsequent tokens. */
7588 parse_set_sample_action(struct context *ctx, const struct token *token,
7589 const char *str, unsigned int len,
7590 void *buf, unsigned int size)
7592 struct buffer *out = buf;
7594 /* Token name must match. */
7595 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7597 /* Nothing else to do if there is no buffer. */
7600 /* Make sure buffer is large enough. */
7601 if (size < sizeof(*out))
7604 ctx->objmask = NULL;
7608 out->command = ctx->curr;
7609 /* For sampler we need is actions */
7610 out->args.vc.actions = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7616 * Parse set raw_encap/raw_decap command,
7617 * initialize output buffer for subsequent tokens.
7620 parse_set_init(struct context *ctx, const struct token *token,
7621 const char *str, unsigned int len,
7622 void *buf, unsigned int size)
7624 struct buffer *out = buf;
7626 /* Token name must match. */
7627 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7629 /* Nothing else to do if there is no buffer. */
7632 /* Make sure buffer is large enough. */
7633 if (size < sizeof(*out))
7635 /* Initialize buffer. */
7636 memset(out, 0x00, sizeof(*out));
7637 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
7640 ctx->objmask = NULL;
7641 if (!out->command) {
7642 if (ctx->curr != SET)
7644 if (sizeof(*out) > size)
7646 out->command = ctx->curr;
7647 out->args.vc.data = (uint8_t *)out + size;
7648 ctx->object = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7654 /** No completion. */
7656 comp_none(struct context *ctx, const struct token *token,
7657 unsigned int ent, char *buf, unsigned int size)
7667 /** Complete boolean values. */
7669 comp_boolean(struct context *ctx, const struct token *token,
7670 unsigned int ent, char *buf, unsigned int size)
7676 for (i = 0; boolean_name[i]; ++i)
7677 if (buf && i == ent)
7678 return strlcpy(buf, boolean_name[i], size);
7684 /** Complete action names. */
7686 comp_action(struct context *ctx, const struct token *token,
7687 unsigned int ent, char *buf, unsigned int size)
7693 for (i = 0; next_action[i]; ++i)
7694 if (buf && i == ent)
7695 return strlcpy(buf, token_list[next_action[i]].name,
7702 /** Complete available ports. */
7704 comp_port(struct context *ctx, const struct token *token,
7705 unsigned int ent, char *buf, unsigned int size)
7712 RTE_ETH_FOREACH_DEV(p) {
7713 if (buf && i == ent)
7714 return snprintf(buf, size, "%u", p);
7722 /** Complete available rule IDs. */
7724 comp_rule_id(struct context *ctx, const struct token *token,
7725 unsigned int ent, char *buf, unsigned int size)
7728 struct rte_port *port;
7729 struct port_flow *pf;
7732 if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
7733 ctx->port == (portid_t)RTE_PORT_ALL)
7735 port = &ports[ctx->port];
7736 for (pf = port->flow_list; pf != NULL; pf = pf->next) {
7737 if (buf && i == ent)
7738 return snprintf(buf, size, "%u", pf->id);
7746 /** Complete type field for RSS action. */
7748 comp_vc_action_rss_type(struct context *ctx, const struct token *token,
7749 unsigned int ent, char *buf, unsigned int size)
7755 for (i = 0; rss_type_table[i].str; ++i)
7760 return strlcpy(buf, rss_type_table[ent].str, size);
7762 return snprintf(buf, size, "end");
7766 /** Complete queue field for RSS action. */
7768 comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
7769 unsigned int ent, char *buf, unsigned int size)
7776 return snprintf(buf, size, "%u", ent);
7778 return snprintf(buf, size, "end");
7782 /** Complete index number for set raw_encap/raw_decap commands. */
7784 comp_set_raw_index(struct context *ctx, const struct token *token,
7785 unsigned int ent, char *buf, unsigned int size)
7791 RTE_SET_USED(token);
7792 for (idx = 0; idx < RAW_ENCAP_CONFS_MAX_NUM; ++idx) {
7793 if (buf && idx == ent)
7794 return snprintf(buf, size, "%u", idx);
7800 /** Complete index number for set raw_encap/raw_decap commands. */
7802 comp_set_sample_index(struct context *ctx, const struct token *token,
7803 unsigned int ent, char *buf, unsigned int size)
7809 RTE_SET_USED(token);
7810 for (idx = 0; idx < RAW_SAMPLE_CONFS_MAX_NUM; ++idx) {
7811 if (buf && idx == ent)
7812 return snprintf(buf, size, "%u", idx);
7818 /** Complete operation for modify_field command. */
7820 comp_set_modify_field_op(struct context *ctx, const struct token *token,
7821 unsigned int ent, char *buf, unsigned int size)
7826 RTE_SET_USED(token);
7827 for (idx = 0; modify_field_ops[idx]; ++idx)
7832 return strlcpy(buf, modify_field_ops[ent], size);
7836 /** Complete field id for modify_field command. */
7838 comp_set_modify_field_id(struct context *ctx, const struct token *token,
7839 unsigned int ent, char *buf, unsigned int size)
7844 RTE_SET_USED(token);
7845 for (idx = 0; modify_field_ids[idx]; ++idx)
7850 return strlcpy(buf, modify_field_ids[ent], size);
7854 /** Internal context. */
7855 static struct context cmd_flow_context;
7857 /** Global parser instance (cmdline API). */
7858 cmdline_parse_inst_t cmd_flow;
7859 cmdline_parse_inst_t cmd_set_raw;
7861 /** Initialize context. */
7863 cmd_flow_context_init(struct context *ctx)
7865 /* A full memset() is not necessary. */
7875 ctx->objmask = NULL;
7878 /** Parse a token (cmdline API). */
7880 cmd_flow_parse(cmdline_parse_token_hdr_t *hdr, const char *src, void *result,
7883 struct context *ctx = &cmd_flow_context;
7884 const struct token *token;
7885 const enum index *list;
7890 token = &token_list[ctx->curr];
7891 /* Check argument length. */
7894 for (len = 0; src[len]; ++len)
7895 if (src[len] == '#' || isspace(src[len]))
7899 /* Last argument and EOL detection. */
7900 for (i = len; src[i]; ++i)
7901 if (src[i] == '#' || src[i] == '\r' || src[i] == '\n')
7903 else if (!isspace(src[i])) {
7908 if (src[i] == '\r' || src[i] == '\n') {
7912 /* Initialize context if necessary. */
7913 if (!ctx->next_num) {
7916 ctx->next[ctx->next_num++] = token->next[0];
7918 /* Process argument through candidates. */
7919 ctx->prev = ctx->curr;
7920 list = ctx->next[ctx->next_num - 1];
7921 for (i = 0; list[i]; ++i) {
7922 const struct token *next = &token_list[list[i]];
7925 ctx->curr = list[i];
7927 tmp = next->call(ctx, next, src, len, result, size);
7929 tmp = parse_default(ctx, next, src, len, result, size);
7930 if (tmp == -1 || tmp != len)
7938 /* Push subsequent tokens if any. */
7940 for (i = 0; token->next[i]; ++i) {
7941 if (ctx->next_num == RTE_DIM(ctx->next))
7943 ctx->next[ctx->next_num++] = token->next[i];
7945 /* Push arguments if any. */
7947 for (i = 0; token->args[i]; ++i) {
7948 if (ctx->args_num == RTE_DIM(ctx->args))
7950 ctx->args[ctx->args_num++] = token->args[i];
7955 /** Return number of completion entries (cmdline API). */
7957 cmd_flow_complete_get_nb(cmdline_parse_token_hdr_t *hdr)
7959 struct context *ctx = &cmd_flow_context;
7960 const struct token *token = &token_list[ctx->curr];
7961 const enum index *list;
7965 /* Count number of tokens in current list. */
7967 list = ctx->next[ctx->next_num - 1];
7969 list = token->next[0];
7970 for (i = 0; list[i]; ++i)
7975 * If there is a single token, use its completion callback, otherwise
7976 * return the number of entries.
7978 token = &token_list[list[0]];
7979 if (i == 1 && token->comp) {
7980 /* Save index for cmd_flow_get_help(). */
7981 ctx->prev = list[0];
7982 return token->comp(ctx, token, 0, NULL, 0);
7987 /** Return a completion entry (cmdline API). */
7989 cmd_flow_complete_get_elt(cmdline_parse_token_hdr_t *hdr, int index,
7990 char *dst, unsigned int size)
7992 struct context *ctx = &cmd_flow_context;
7993 const struct token *token = &token_list[ctx->curr];
7994 const enum index *list;
7998 /* Count number of tokens in current list. */
8000 list = ctx->next[ctx->next_num - 1];
8002 list = token->next[0];
8003 for (i = 0; list[i]; ++i)
8007 /* If there is a single token, use its completion callback. */
8008 token = &token_list[list[0]];
8009 if (i == 1 && token->comp) {
8010 /* Save index for cmd_flow_get_help(). */
8011 ctx->prev = list[0];
8012 return token->comp(ctx, token, index, dst, size) < 0 ? -1 : 0;
8014 /* Otherwise make sure the index is valid and use defaults. */
8017 token = &token_list[list[index]];
8018 strlcpy(dst, token->name, size);
8019 /* Save index for cmd_flow_get_help(). */
8020 ctx->prev = list[index];
8024 /** Populate help strings for current token (cmdline API). */
8026 cmd_flow_get_help(cmdline_parse_token_hdr_t *hdr, char *dst, unsigned int size)
8028 struct context *ctx = &cmd_flow_context;
8029 const struct token *token = &token_list[ctx->prev];
8034 /* Set token type and update global help with details. */
8035 strlcpy(dst, (token->type ? token->type : "TOKEN"), size);
8037 cmd_flow.help_str = token->help;
8039 cmd_flow.help_str = token->name;
8043 /** Token definition template (cmdline API). */
8044 static struct cmdline_token_hdr cmd_flow_token_hdr = {
8045 .ops = &(struct cmdline_token_ops){
8046 .parse = cmd_flow_parse,
8047 .complete_get_nb = cmd_flow_complete_get_nb,
8048 .complete_get_elt = cmd_flow_complete_get_elt,
8049 .get_help = cmd_flow_get_help,
8054 /** Populate the next dynamic token. */
8056 cmd_flow_tok(cmdline_parse_token_hdr_t **hdr,
8057 cmdline_parse_token_hdr_t **hdr_inst)
8059 struct context *ctx = &cmd_flow_context;
8061 /* Always reinitialize context before requesting the first token. */
8062 if (!(hdr_inst - cmd_flow.tokens))
8063 cmd_flow_context_init(ctx);
8064 /* Return NULL when no more tokens are expected. */
8065 if (!ctx->next_num && ctx->curr) {
8069 /* Determine if command should end here. */
8070 if (ctx->eol && ctx->last && ctx->next_num) {
8071 const enum index *list = ctx->next[ctx->next_num - 1];
8074 for (i = 0; list[i]; ++i) {
8081 *hdr = &cmd_flow_token_hdr;
8084 /** Dispatch parsed buffer to function calls. */
8086 cmd_flow_parsed(const struct buffer *in)
8088 switch (in->command) {
8089 case INDIRECT_ACTION_CREATE:
8090 port_action_handle_create(
8091 in->port, in->args.vc.attr.group,
8092 &((const struct rte_flow_indir_action_conf) {
8093 .ingress = in->args.vc.attr.ingress,
8094 .egress = in->args.vc.attr.egress,
8095 .transfer = in->args.vc.attr.transfer,
8097 in->args.vc.actions);
8099 case INDIRECT_ACTION_DESTROY:
8100 port_action_handle_destroy(in->port,
8101 in->args.ia_destroy.action_id_n,
8102 in->args.ia_destroy.action_id);
8104 case INDIRECT_ACTION_UPDATE:
8105 port_action_handle_update(in->port, in->args.vc.attr.group,
8106 in->args.vc.actions);
8108 case INDIRECT_ACTION_QUERY:
8109 port_action_handle_query(in->port, in->args.ia.action_id);
8112 port_flow_validate(in->port, &in->args.vc.attr,
8113 in->args.vc.pattern, in->args.vc.actions,
8114 &in->args.vc.tunnel_ops);
8117 port_flow_create(in->port, &in->args.vc.attr,
8118 in->args.vc.pattern, in->args.vc.actions,
8119 &in->args.vc.tunnel_ops);
8122 port_flow_destroy(in->port, in->args.destroy.rule_n,
8123 in->args.destroy.rule);
8126 port_flow_flush(in->port);
8130 port_flow_dump(in->port, in->args.dump.mode,
8131 in->args.dump.rule, in->args.dump.file);
8134 port_flow_query(in->port, in->args.query.rule,
8135 &in->args.query.action);
8138 port_flow_list(in->port, in->args.list.group_n,
8139 in->args.list.group);
8142 port_flow_isolate(in->port, in->args.isolate.set);
8145 port_flow_aged(in->port, in->args.aged.destroy);
8148 port_flow_tunnel_create(in->port, &in->args.vc.tunnel_ops);
8150 case TUNNEL_DESTROY:
8151 port_flow_tunnel_destroy(in->port, in->args.vc.tunnel_ops.id);
8154 port_flow_tunnel_list(in->port);
8157 port_meter_policy_add(in->port, in->args.policy.policy_id,
8158 in->args.vc.actions);
8165 /** Token generator and output processing callback (cmdline API). */
8167 cmd_flow_cb(void *arg0, struct cmdline *cl, void *arg2)
8170 cmd_flow_tok(arg0, arg2);
8172 cmd_flow_parsed(arg0);
8175 /** Global parser instance (cmdline API). */
8176 cmdline_parse_inst_t cmd_flow = {
8178 .data = NULL, /**< Unused. */
8179 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
8182 }, /**< Tokens are returned by cmd_flow_tok(). */
8185 /** set cmd facility. Reuse cmd flow's infrastructure as much as possible. */
8188 update_fields(uint8_t *buf, struct rte_flow_item *item, uint16_t next_proto)
8190 struct rte_ipv4_hdr *ipv4;
8191 struct rte_ether_hdr *eth;
8192 struct rte_ipv6_hdr *ipv6;
8193 struct rte_vxlan_hdr *vxlan;
8194 struct rte_vxlan_gpe_hdr *gpe;
8195 struct rte_flow_item_nvgre *nvgre;
8196 uint32_t ipv6_vtc_flow;
8198 switch (item->type) {
8199 case RTE_FLOW_ITEM_TYPE_ETH:
8200 eth = (struct rte_ether_hdr *)buf;
8202 eth->ether_type = rte_cpu_to_be_16(next_proto);
8204 case RTE_FLOW_ITEM_TYPE_IPV4:
8205 ipv4 = (struct rte_ipv4_hdr *)buf;
8206 if (!ipv4->version_ihl)
8207 ipv4->version_ihl = RTE_IPV4_VHL_DEF;
8208 if (next_proto && ipv4->next_proto_id == 0)
8209 ipv4->next_proto_id = (uint8_t)next_proto;
8211 case RTE_FLOW_ITEM_TYPE_IPV6:
8212 ipv6 = (struct rte_ipv6_hdr *)buf;
8213 if (next_proto && ipv6->proto == 0)
8214 ipv6->proto = (uint8_t)next_proto;
8215 ipv6_vtc_flow = rte_be_to_cpu_32(ipv6->vtc_flow);
8216 ipv6_vtc_flow &= 0x0FFFFFFF; /*< reset version bits. */
8217 ipv6_vtc_flow |= 0x60000000; /*< set ipv6 version. */
8218 ipv6->vtc_flow = rte_cpu_to_be_32(ipv6_vtc_flow);
8220 case RTE_FLOW_ITEM_TYPE_VXLAN:
8221 vxlan = (struct rte_vxlan_hdr *)buf;
8222 vxlan->vx_flags = 0x08;
8224 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
8225 gpe = (struct rte_vxlan_gpe_hdr *)buf;
8226 gpe->vx_flags = 0x0C;
8228 case RTE_FLOW_ITEM_TYPE_NVGRE:
8229 nvgre = (struct rte_flow_item_nvgre *)buf;
8230 nvgre->protocol = rte_cpu_to_be_16(0x6558);
8231 nvgre->c_k_s_rsvd0_ver = rte_cpu_to_be_16(0x2000);
8238 /** Helper of get item's default mask. */
8240 flow_item_default_mask(const struct rte_flow_item *item)
8242 const void *mask = NULL;
8243 static rte_be32_t gre_key_default_mask = RTE_BE32(UINT32_MAX);
8245 switch (item->type) {
8246 case RTE_FLOW_ITEM_TYPE_ANY:
8247 mask = &rte_flow_item_any_mask;
8249 case RTE_FLOW_ITEM_TYPE_VF:
8250 mask = &rte_flow_item_vf_mask;
8252 case RTE_FLOW_ITEM_TYPE_PORT_ID:
8253 mask = &rte_flow_item_port_id_mask;
8255 case RTE_FLOW_ITEM_TYPE_RAW:
8256 mask = &rte_flow_item_raw_mask;
8258 case RTE_FLOW_ITEM_TYPE_ETH:
8259 mask = &rte_flow_item_eth_mask;
8261 case RTE_FLOW_ITEM_TYPE_VLAN:
8262 mask = &rte_flow_item_vlan_mask;
8264 case RTE_FLOW_ITEM_TYPE_IPV4:
8265 mask = &rte_flow_item_ipv4_mask;
8267 case RTE_FLOW_ITEM_TYPE_IPV6:
8268 mask = &rte_flow_item_ipv6_mask;
8270 case RTE_FLOW_ITEM_TYPE_ICMP:
8271 mask = &rte_flow_item_icmp_mask;
8273 case RTE_FLOW_ITEM_TYPE_UDP:
8274 mask = &rte_flow_item_udp_mask;
8276 case RTE_FLOW_ITEM_TYPE_TCP:
8277 mask = &rte_flow_item_tcp_mask;
8279 case RTE_FLOW_ITEM_TYPE_SCTP:
8280 mask = &rte_flow_item_sctp_mask;
8282 case RTE_FLOW_ITEM_TYPE_VXLAN:
8283 mask = &rte_flow_item_vxlan_mask;
8285 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
8286 mask = &rte_flow_item_vxlan_gpe_mask;
8288 case RTE_FLOW_ITEM_TYPE_E_TAG:
8289 mask = &rte_flow_item_e_tag_mask;
8291 case RTE_FLOW_ITEM_TYPE_NVGRE:
8292 mask = &rte_flow_item_nvgre_mask;
8294 case RTE_FLOW_ITEM_TYPE_MPLS:
8295 mask = &rte_flow_item_mpls_mask;
8297 case RTE_FLOW_ITEM_TYPE_GRE:
8298 mask = &rte_flow_item_gre_mask;
8300 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
8301 mask = &gre_key_default_mask;
8303 case RTE_FLOW_ITEM_TYPE_META:
8304 mask = &rte_flow_item_meta_mask;
8306 case RTE_FLOW_ITEM_TYPE_FUZZY:
8307 mask = &rte_flow_item_fuzzy_mask;
8309 case RTE_FLOW_ITEM_TYPE_GTP:
8310 mask = &rte_flow_item_gtp_mask;
8312 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
8313 mask = &rte_flow_item_gtp_psc_mask;
8315 case RTE_FLOW_ITEM_TYPE_GENEVE:
8316 mask = &rte_flow_item_geneve_mask;
8318 case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
8319 mask = &rte_flow_item_geneve_opt_mask;
8321 case RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID:
8322 mask = &rte_flow_item_pppoe_proto_id_mask;
8324 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
8325 mask = &rte_flow_item_l2tpv3oip_mask;
8327 case RTE_FLOW_ITEM_TYPE_ESP:
8328 mask = &rte_flow_item_esp_mask;
8330 case RTE_FLOW_ITEM_TYPE_AH:
8331 mask = &rte_flow_item_ah_mask;
8333 case RTE_FLOW_ITEM_TYPE_PFCP:
8334 mask = &rte_flow_item_pfcp_mask;
8342 /** Dispatch parsed buffer to function calls. */
8344 cmd_set_raw_parsed_sample(const struct buffer *in)
8346 uint32_t n = in->args.vc.actions_n;
8348 struct rte_flow_action *action = NULL;
8349 struct rte_flow_action *data = NULL;
8350 const struct rte_flow_action_rss *rss = NULL;
8352 uint16_t idx = in->port; /* We borrow port field as index */
8353 uint32_t max_size = sizeof(struct rte_flow_action) *
8354 ACTION_SAMPLE_ACTIONS_NUM;
8356 RTE_ASSERT(in->command == SET_SAMPLE_ACTIONS);
8357 data = (struct rte_flow_action *)&raw_sample_confs[idx].data;
8358 memset(data, 0x00, max_size);
8359 for (; i <= n - 1; i++) {
8360 action = in->args.vc.actions + i;
8361 if (action->type == RTE_FLOW_ACTION_TYPE_END)
8363 switch (action->type) {
8364 case RTE_FLOW_ACTION_TYPE_MARK:
8365 size = sizeof(struct rte_flow_action_mark);
8366 rte_memcpy(&sample_mark[idx],
8367 (const void *)action->conf, size);
8368 action->conf = &sample_mark[idx];
8370 case RTE_FLOW_ACTION_TYPE_COUNT:
8371 size = sizeof(struct rte_flow_action_count);
8372 rte_memcpy(&sample_count[idx],
8373 (const void *)action->conf, size);
8374 action->conf = &sample_count[idx];
8376 case RTE_FLOW_ACTION_TYPE_QUEUE:
8377 size = sizeof(struct rte_flow_action_queue);
8378 rte_memcpy(&sample_queue[idx],
8379 (const void *)action->conf, size);
8380 action->conf = &sample_queue[idx];
8382 case RTE_FLOW_ACTION_TYPE_RSS:
8383 size = sizeof(struct rte_flow_action_rss);
8385 rte_memcpy(&sample_rss_data[idx].conf,
8386 (const void *)rss, size);
8387 if (rss->key_len && rss->key) {
8388 sample_rss_data[idx].conf.key =
8389 sample_rss_data[idx].key;
8390 rte_memcpy((void *)((uintptr_t)
8391 sample_rss_data[idx].conf.key),
8392 (const void *)rss->key,
8393 sizeof(uint8_t) * rss->key_len);
8395 if (rss->queue_num && rss->queue) {
8396 sample_rss_data[idx].conf.queue =
8397 sample_rss_data[idx].queue;
8398 rte_memcpy((void *)((uintptr_t)
8399 sample_rss_data[idx].conf.queue),
8400 (const void *)rss->queue,
8401 sizeof(uint16_t) * rss->queue_num);
8403 action->conf = &sample_rss_data[idx].conf;
8405 case RTE_FLOW_ACTION_TYPE_RAW_ENCAP:
8406 size = sizeof(struct rte_flow_action_raw_encap);
8407 rte_memcpy(&sample_encap[idx],
8408 (const void *)action->conf, size);
8409 action->conf = &sample_encap[idx];
8411 case RTE_FLOW_ACTION_TYPE_PORT_ID:
8412 size = sizeof(struct rte_flow_action_port_id);
8413 rte_memcpy(&sample_port_id[idx],
8414 (const void *)action->conf, size);
8415 action->conf = &sample_port_id[idx];
8417 case RTE_FLOW_ACTION_TYPE_PF:
8419 case RTE_FLOW_ACTION_TYPE_VF:
8420 size = sizeof(struct rte_flow_action_vf);
8421 rte_memcpy(&sample_vf[idx],
8422 (const void *)action->conf, size);
8423 action->conf = &sample_vf[idx];
8425 case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP:
8426 size = sizeof(struct rte_flow_action_vxlan_encap);
8427 parse_setup_vxlan_encap_data(&sample_vxlan_encap[idx]);
8428 action->conf = &sample_vxlan_encap[idx].conf;
8430 case RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP:
8431 size = sizeof(struct rte_flow_action_nvgre_encap);
8432 parse_setup_nvgre_encap_data(&sample_nvgre_encap[idx]);
8433 action->conf = &sample_nvgre_encap[idx];
8436 fprintf(stderr, "Error - Not supported action\n");
8439 rte_memcpy(data, action, sizeof(struct rte_flow_action));
8444 /** Dispatch parsed buffer to function calls. */
8446 cmd_set_raw_parsed(const struct buffer *in)
8448 uint32_t n = in->args.vc.pattern_n;
8450 struct rte_flow_item *item = NULL;
8452 uint8_t *data = NULL;
8453 uint8_t *data_tail = NULL;
8454 size_t *total_size = NULL;
8455 uint16_t upper_layer = 0;
8457 uint16_t idx = in->port; /* We borrow port field as index */
8458 int gtp_psc = -1; /* GTP PSC option index. */
8460 if (in->command == SET_SAMPLE_ACTIONS)
8461 return cmd_set_raw_parsed_sample(in);
8462 RTE_ASSERT(in->command == SET_RAW_ENCAP ||
8463 in->command == SET_RAW_DECAP);
8464 if (in->command == SET_RAW_ENCAP) {
8465 total_size = &raw_encap_confs[idx].size;
8466 data = (uint8_t *)&raw_encap_confs[idx].data;
8468 total_size = &raw_decap_confs[idx].size;
8469 data = (uint8_t *)&raw_decap_confs[idx].data;
8472 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
8473 /* process hdr from upper layer to low layer (L3/L4 -> L2). */
8474 data_tail = data + ACTION_RAW_ENCAP_MAX_DATA;
8475 for (i = n - 1 ; i >= 0; --i) {
8476 const struct rte_flow_item_gtp *gtp;
8477 const struct rte_flow_item_geneve_opt *opt;
8479 item = in->args.vc.pattern + i;
8480 if (item->spec == NULL)
8481 item->spec = flow_item_default_mask(item);
8482 switch (item->type) {
8483 case RTE_FLOW_ITEM_TYPE_ETH:
8484 size = sizeof(struct rte_ether_hdr);
8486 case RTE_FLOW_ITEM_TYPE_VLAN:
8487 size = sizeof(struct rte_vlan_hdr);
8488 proto = RTE_ETHER_TYPE_VLAN;
8490 case RTE_FLOW_ITEM_TYPE_IPV4:
8491 size = sizeof(struct rte_ipv4_hdr);
8492 proto = RTE_ETHER_TYPE_IPV4;
8494 case RTE_FLOW_ITEM_TYPE_IPV6:
8495 size = sizeof(struct rte_ipv6_hdr);
8496 proto = RTE_ETHER_TYPE_IPV6;
8498 case RTE_FLOW_ITEM_TYPE_UDP:
8499 size = sizeof(struct rte_udp_hdr);
8502 case RTE_FLOW_ITEM_TYPE_TCP:
8503 size = sizeof(struct rte_tcp_hdr);
8506 case RTE_FLOW_ITEM_TYPE_VXLAN:
8507 size = sizeof(struct rte_vxlan_hdr);
8509 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
8510 size = sizeof(struct rte_vxlan_gpe_hdr);
8512 case RTE_FLOW_ITEM_TYPE_GRE:
8513 size = sizeof(struct rte_gre_hdr);
8516 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
8517 size = sizeof(rte_be32_t);
8520 case RTE_FLOW_ITEM_TYPE_MPLS:
8521 size = sizeof(struct rte_mpls_hdr);
8524 case RTE_FLOW_ITEM_TYPE_NVGRE:
8525 size = sizeof(struct rte_flow_item_nvgre);
8528 case RTE_FLOW_ITEM_TYPE_GENEVE:
8529 size = sizeof(struct rte_geneve_hdr);
8531 case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
8532 opt = (const struct rte_flow_item_geneve_opt *)
8534 size = offsetof(struct rte_flow_item_geneve_opt, data);
8535 if (opt->option_len && opt->data) {
8536 *total_size += opt->option_len *
8538 rte_memcpy(data_tail - (*total_size),
8540 opt->option_len * sizeof(uint32_t));
8543 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
8544 size = sizeof(rte_be32_t);
8547 case RTE_FLOW_ITEM_TYPE_ESP:
8548 size = sizeof(struct rte_esp_hdr);
8551 case RTE_FLOW_ITEM_TYPE_AH:
8552 size = sizeof(struct rte_flow_item_ah);
8555 case RTE_FLOW_ITEM_TYPE_GTP:
8557 size = sizeof(struct rte_gtp_hdr);
8560 if (gtp_psc != i + 1) {
8562 "Error - GTP PSC does not follow GTP\n");
8566 if ((gtp->v_pt_rsv_flags & 0x07) != 0x04) {
8567 /* Only E flag should be set. */
8569 "Error - GTP unsupported flags\n");
8572 struct rte_gtp_hdr_ext_word ext_word = {
8576 /* We have to add GTP header extra word. */
8577 *total_size += sizeof(ext_word);
8578 rte_memcpy(data_tail - (*total_size),
8579 &ext_word, sizeof(ext_word));
8581 size = sizeof(struct rte_gtp_hdr);
8583 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
8586 "Error - Multiple GTP PSC items\n");
8589 const struct rte_flow_item_gtp_psc
8597 psc.len = sizeof(psc);
8598 psc.pdu_type = opt->hdr.type;
8599 psc.qfi = opt->hdr.qfi;
8601 *total_size += sizeof(psc);
8602 rte_memcpy(data_tail - (*total_size),
8608 case RTE_FLOW_ITEM_TYPE_PFCP:
8609 size = sizeof(struct rte_flow_item_pfcp);
8612 fprintf(stderr, "Error - Not supported item\n");
8615 *total_size += size;
8616 rte_memcpy(data_tail - (*total_size), item->spec, size);
8617 /* update some fields which cannot be set by cmdline */
8618 update_fields((data_tail - (*total_size)), item,
8620 upper_layer = proto;
8622 if (verbose_level & 0x1)
8623 printf("total data size is %zu\n", (*total_size));
8624 RTE_ASSERT((*total_size) <= ACTION_RAW_ENCAP_MAX_DATA);
8625 memmove(data, (data_tail - (*total_size)), *total_size);
8630 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
8633 /** Populate help strings for current token (cmdline API). */
8635 cmd_set_raw_get_help(cmdline_parse_token_hdr_t *hdr, char *dst,
8638 struct context *ctx = &cmd_flow_context;
8639 const struct token *token = &token_list[ctx->prev];
8644 /* Set token type and update global help with details. */
8645 snprintf(dst, size, "%s", (token->type ? token->type : "TOKEN"));
8647 cmd_set_raw.help_str = token->help;
8649 cmd_set_raw.help_str = token->name;
8653 /** Token definition template (cmdline API). */
8654 static struct cmdline_token_hdr cmd_set_raw_token_hdr = {
8655 .ops = &(struct cmdline_token_ops){
8656 .parse = cmd_flow_parse,
8657 .complete_get_nb = cmd_flow_complete_get_nb,
8658 .complete_get_elt = cmd_flow_complete_get_elt,
8659 .get_help = cmd_set_raw_get_help,
8664 /** Populate the next dynamic token. */
8666 cmd_set_raw_tok(cmdline_parse_token_hdr_t **hdr,
8667 cmdline_parse_token_hdr_t **hdr_inst)
8669 struct context *ctx = &cmd_flow_context;
8671 /* Always reinitialize context before requesting the first token. */
8672 if (!(hdr_inst - cmd_set_raw.tokens)) {
8673 cmd_flow_context_init(ctx);
8674 ctx->curr = START_SET;
8676 /* Return NULL when no more tokens are expected. */
8677 if (!ctx->next_num && (ctx->curr != START_SET)) {
8681 /* Determine if command should end here. */
8682 if (ctx->eol && ctx->last && ctx->next_num) {
8683 const enum index *list = ctx->next[ctx->next_num - 1];
8686 for (i = 0; list[i]; ++i) {
8693 *hdr = &cmd_set_raw_token_hdr;
8696 /** Token generator and output processing callback (cmdline API). */
8698 cmd_set_raw_cb(void *arg0, struct cmdline *cl, void *arg2)
8701 cmd_set_raw_tok(arg0, arg2);
8703 cmd_set_raw_parsed(arg0);
8706 /** Global parser instance (cmdline API). */
8707 cmdline_parse_inst_t cmd_set_raw = {
8708 .f = cmd_set_raw_cb,
8709 .data = NULL, /**< Unused. */
8710 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
8713 }, /**< Tokens are returned by cmd_flow_tok(). */
8716 /* *** display raw_encap/raw_decap buf */
8717 struct cmd_show_set_raw_result {
8718 cmdline_fixed_string_t cmd_show;
8719 cmdline_fixed_string_t cmd_what;
8720 cmdline_fixed_string_t cmd_all;
8725 cmd_show_set_raw_parsed(void *parsed_result, struct cmdline *cl, void *data)
8727 struct cmd_show_set_raw_result *res = parsed_result;
8728 uint16_t index = res->cmd_index;
8730 uint8_t *raw_data = NULL;
8731 size_t raw_size = 0;
8732 char title[16] = {0};
8736 if (!strcmp(res->cmd_all, "all")) {
8739 } else if (index >= RAW_ENCAP_CONFS_MAX_NUM) {
8740 fprintf(stderr, "index should be 0-%u\n",
8741 RAW_ENCAP_CONFS_MAX_NUM - 1);
8745 if (!strcmp(res->cmd_what, "raw_encap")) {
8746 raw_data = (uint8_t *)&raw_encap_confs[index].data;
8747 raw_size = raw_encap_confs[index].size;
8748 snprintf(title, 16, "\nindex: %u", index);
8749 rte_hexdump(stdout, title, raw_data, raw_size);
8751 raw_data = (uint8_t *)&raw_decap_confs[index].data;
8752 raw_size = raw_decap_confs[index].size;
8753 snprintf(title, 16, "\nindex: %u", index);
8754 rte_hexdump(stdout, title, raw_data, raw_size);
8756 } while (all && ++index < RAW_ENCAP_CONFS_MAX_NUM);
8759 cmdline_parse_token_string_t cmd_show_set_raw_cmd_show =
8760 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
8762 cmdline_parse_token_string_t cmd_show_set_raw_cmd_what =
8763 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
8764 cmd_what, "raw_encap#raw_decap");
8765 cmdline_parse_token_num_t cmd_show_set_raw_cmd_index =
8766 TOKEN_NUM_INITIALIZER(struct cmd_show_set_raw_result,
8767 cmd_index, RTE_UINT16);
8768 cmdline_parse_token_string_t cmd_show_set_raw_cmd_all =
8769 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
8771 cmdline_parse_inst_t cmd_show_set_raw = {
8772 .f = cmd_show_set_raw_parsed,
8774 .help_str = "show <raw_encap|raw_decap> <index>",
8776 (void *)&cmd_show_set_raw_cmd_show,
8777 (void *)&cmd_show_set_raw_cmd_what,
8778 (void *)&cmd_show_set_raw_cmd_index,
8782 cmdline_parse_inst_t cmd_show_set_raw_all = {
8783 .f = cmd_show_set_raw_parsed,
8785 .help_str = "show <raw_encap|raw_decap> all",
8787 (void *)&cmd_show_set_raw_cmd_show,
8788 (void *)&cmd_show_set_raw_cmd_what,
8789 (void *)&cmd_show_set_raw_cmd_all,