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,
60 /* TOP-level command. */
63 /* Top-level command. */
65 /* Sub-leve commands. */
72 /* Top-level command. */
74 /* Sub-level commands. */
93 /* Tunnel arguments. */
100 /* Destroy arguments. */
103 /* Query arguments. */
106 /* List arguments. */
109 /* Destroy aged flow arguments. */
112 /* Validate/create arguments. */
125 /* Indirect action arguments */
126 INDIRECT_ACTION_CREATE,
127 INDIRECT_ACTION_UPDATE,
128 INDIRECT_ACTION_DESTROY,
129 INDIRECT_ACTION_QUERY,
131 /* Indirect action create arguments */
132 INDIRECT_ACTION_CREATE_ID,
133 INDIRECT_ACTION_INGRESS,
134 INDIRECT_ACTION_EGRESS,
135 INDIRECT_ACTION_TRANSFER,
136 INDIRECT_ACTION_SPEC,
138 /* Indirect action destroy arguments */
139 INDIRECT_ACTION_DESTROY_ID,
141 /* Validate/create pattern. */
179 ITEM_VLAN_INNER_TYPE,
180 ITEM_VLAN_HAS_MORE_VLAN,
185 ITEM_IPV4_FRAGMENT_OFFSET,
197 ITEM_IPV6_HAS_FRAG_EXT,
217 ITEM_VXLAN_LAST_RSVD,
219 ITEM_E_TAG_GRP_ECID_B,
228 ITEM_GRE_C_RSVD0_VER,
247 ITEM_ARP_ETH_IPV4_SHA,
248 ITEM_ARP_ETH_IPV4_SPA,
249 ITEM_ARP_ETH_IPV4_THA,
250 ITEM_ARP_ETH_IPV4_TPA,
252 ITEM_IPV6_EXT_NEXT_HDR,
254 ITEM_IPV6_FRAG_EXT_NEXT_HDR,
255 ITEM_IPV6_FRAG_EXT_FRAG_DATA,
256 ITEM_IPV6_FRAG_EXT_ID,
261 ITEM_ICMP6_ND_NS_TARGET_ADDR,
263 ITEM_ICMP6_ND_NA_TARGET_ADDR,
265 ITEM_ICMP6_ND_OPT_TYPE,
266 ITEM_ICMP6_ND_OPT_SLA_ETH,
267 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
268 ITEM_ICMP6_ND_OPT_TLA_ETH,
269 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
282 ITEM_HIGIG2_CLASSIFICATION,
288 ITEM_L2TPV3OIP_SESSION_ID,
298 ITEM_ECPRI_COMMON_TYPE,
299 ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
300 ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
301 ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
302 ITEM_ECPRI_MSG_IQ_DATA_PCID,
303 ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
304 ITEM_ECPRI_MSG_DLY_MSR_MSRID,
306 ITEM_GENEVE_OPT_CLASS,
307 ITEM_GENEVE_OPT_TYPE,
308 ITEM_GENEVE_OPT_LENGTH,
309 ITEM_GENEVE_OPT_DATA,
311 ITEM_INTEGRITY_LEVEL,
312 ITEM_INTEGRITY_VALUE,
317 ITEM_PORT_REPRESENTOR,
318 ITEM_PORT_REPRESENTOR_PORT_ID,
319 ITEM_REPRESENTED_PORT,
320 ITEM_REPRESENTED_PORT_ETHDEV_PORT_ID,
322 ITEM_FLEX_ITEM_HANDLE,
323 ITEM_FLEX_PATTERN_HANDLE,
326 ITEM_L2TPV2_COMMON_TYPE,
327 ITEM_L2TPV2_COMMON_TYPE_DATA_L,
328 ITEM_L2TPV2_COMMON_TYPE_CTRL,
329 ITEM_L2TPV2_MSG_DATA_L_LENGTH,
330 ITEM_L2TPV2_MSG_DATA_L_TUNNEL_ID,
331 ITEM_L2TPV2_MSG_DATA_L_SESSION_ID,
332 ITEM_L2TPV2_MSG_CTRL_LENGTH,
333 ITEM_L2TPV2_MSG_CTRL_TUNNEL_ID,
334 ITEM_L2TPV2_MSG_CTRL_SESSION_ID,
335 ITEM_L2TPV2_MSG_CTRL_NS,
336 ITEM_L2TPV2_MSG_CTRL_NR,
342 /* Validate/create actions. */
361 ACTION_RSS_FUNC_DEFAULT,
362 ACTION_RSS_FUNC_TOEPLITZ,
363 ACTION_RSS_FUNC_SIMPLE_XOR,
364 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ,
376 ACTION_PHY_PORT_ORIGINAL,
377 ACTION_PHY_PORT_INDEX,
379 ACTION_PORT_ID_ORIGINAL,
383 ACTION_METER_COLOR_TYPE,
384 ACTION_METER_COLOR_GREEN,
385 ACTION_METER_COLOR_YELLOW,
386 ACTION_METER_COLOR_RED,
388 ACTION_OF_SET_MPLS_TTL,
389 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
390 ACTION_OF_DEC_MPLS_TTL,
391 ACTION_OF_SET_NW_TTL,
392 ACTION_OF_SET_NW_TTL_NW_TTL,
393 ACTION_OF_DEC_NW_TTL,
394 ACTION_OF_COPY_TTL_OUT,
395 ACTION_OF_COPY_TTL_IN,
398 ACTION_OF_PUSH_VLAN_ETHERTYPE,
399 ACTION_OF_SET_VLAN_VID,
400 ACTION_OF_SET_VLAN_VID_VLAN_VID,
401 ACTION_OF_SET_VLAN_PCP,
402 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
404 ACTION_OF_POP_MPLS_ETHERTYPE,
406 ACTION_OF_PUSH_MPLS_ETHERTYPE,
413 ACTION_MPLSOGRE_ENCAP,
414 ACTION_MPLSOGRE_DECAP,
415 ACTION_MPLSOUDP_ENCAP,
416 ACTION_MPLSOUDP_DECAP,
418 ACTION_SET_IPV4_SRC_IPV4_SRC,
420 ACTION_SET_IPV4_DST_IPV4_DST,
422 ACTION_SET_IPV6_SRC_IPV6_SRC,
424 ACTION_SET_IPV6_DST_IPV6_DST,
426 ACTION_SET_TP_SRC_TP_SRC,
428 ACTION_SET_TP_DST_TP_DST,
434 ACTION_SET_MAC_SRC_MAC_SRC,
436 ACTION_SET_MAC_DST_MAC_DST,
438 ACTION_INC_TCP_SEQ_VALUE,
440 ACTION_DEC_TCP_SEQ_VALUE,
442 ACTION_INC_TCP_ACK_VALUE,
444 ACTION_DEC_TCP_ACK_VALUE,
447 ACTION_RAW_ENCAP_INDEX,
448 ACTION_RAW_ENCAP_INDEX_VALUE,
449 ACTION_RAW_DECAP_INDEX,
450 ACTION_RAW_DECAP_INDEX_VALUE,
453 ACTION_SET_TAG_INDEX,
456 ACTION_SET_META_DATA,
457 ACTION_SET_META_MASK,
458 ACTION_SET_IPV4_DSCP,
459 ACTION_SET_IPV4_DSCP_VALUE,
460 ACTION_SET_IPV6_DSCP,
461 ACTION_SET_IPV6_DSCP_VALUE,
467 ACTION_SAMPLE_INDEX_VALUE,
469 INDIRECT_ACTION_ID2PTR,
471 ACTION_MODIFY_FIELD_OP,
472 ACTION_MODIFY_FIELD_OP_VALUE,
473 ACTION_MODIFY_FIELD_DST_TYPE,
474 ACTION_MODIFY_FIELD_DST_TYPE_VALUE,
475 ACTION_MODIFY_FIELD_DST_LEVEL,
476 ACTION_MODIFY_FIELD_DST_OFFSET,
477 ACTION_MODIFY_FIELD_SRC_TYPE,
478 ACTION_MODIFY_FIELD_SRC_TYPE_VALUE,
479 ACTION_MODIFY_FIELD_SRC_LEVEL,
480 ACTION_MODIFY_FIELD_SRC_OFFSET,
481 ACTION_MODIFY_FIELD_SRC_VALUE,
482 ACTION_MODIFY_FIELD_SRC_POINTER,
483 ACTION_MODIFY_FIELD_WIDTH,
485 ACTION_CONNTRACK_UPDATE,
486 ACTION_CONNTRACK_UPDATE_DIR,
487 ACTION_CONNTRACK_UPDATE_CTX,
491 ACTION_PORT_REPRESENTOR,
492 ACTION_PORT_REPRESENTOR_PORT_ID,
493 ACTION_REPRESENTED_PORT,
494 ACTION_REPRESENTED_PORT_ETHDEV_PORT_ID,
497 /** Maximum size for pattern in struct rte_flow_item_raw. */
498 #define ITEM_RAW_PATTERN_SIZE 40
500 /** Maximum size for GENEVE option data pattern in bytes. */
501 #define ITEM_GENEVE_OPT_DATA_SIZE 124
503 /** Storage size for struct rte_flow_item_raw including pattern. */
504 #define ITEM_RAW_SIZE \
505 (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE)
507 /** Maximum size for external pattern in struct rte_flow_action_modify_data. */
508 #define ACTION_MODIFY_PATTERN_SIZE 32
510 /** Storage size for struct rte_flow_action_modify_field including pattern. */
511 #define ACTION_MODIFY_SIZE \
512 (sizeof(struct rte_flow_action_modify_field) + \
513 ACTION_MODIFY_PATTERN_SIZE)
515 /** Maximum number of queue indices in struct rte_flow_action_rss. */
516 #define ACTION_RSS_QUEUE_NUM 128
518 /** Storage for struct rte_flow_action_rss including external data. */
519 struct action_rss_data {
520 struct rte_flow_action_rss conf;
521 uint8_t key[RSS_HASH_KEY_LENGTH];
522 uint16_t queue[ACTION_RSS_QUEUE_NUM];
525 /** Maximum data size in struct rte_flow_action_raw_encap. */
526 #define ACTION_RAW_ENCAP_MAX_DATA 512
527 #define RAW_ENCAP_CONFS_MAX_NUM 8
529 /** Storage for struct rte_flow_action_raw_encap. */
530 struct raw_encap_conf {
531 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
532 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
536 struct raw_encap_conf raw_encap_confs[RAW_ENCAP_CONFS_MAX_NUM];
538 /** Storage for struct rte_flow_action_raw_encap including external data. */
539 struct action_raw_encap_data {
540 struct rte_flow_action_raw_encap conf;
541 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
542 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
546 /** Storage for struct rte_flow_action_raw_decap. */
547 struct raw_decap_conf {
548 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
552 struct raw_decap_conf raw_decap_confs[RAW_ENCAP_CONFS_MAX_NUM];
554 /** Storage for struct rte_flow_action_raw_decap including external data. */
555 struct action_raw_decap_data {
556 struct rte_flow_action_raw_decap conf;
557 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
561 struct vxlan_encap_conf vxlan_encap_conf = {
565 .vni = "\x00\x00\x00",
567 .udp_dst = RTE_BE16(RTE_VXLAN_DEFAULT_PORT),
568 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
569 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
570 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
571 "\x00\x00\x00\x00\x00\x00\x00\x01",
572 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
573 "\x00\x00\x00\x00\x00\x00\x11\x11",
577 .eth_src = "\x00\x00\x00\x00\x00\x00",
578 .eth_dst = "\xff\xff\xff\xff\xff\xff",
581 /** Maximum number of items in struct rte_flow_action_vxlan_encap. */
582 #define ACTION_VXLAN_ENCAP_ITEMS_NUM 6
584 /** Storage for struct rte_flow_action_vxlan_encap including external data. */
585 struct action_vxlan_encap_data {
586 struct rte_flow_action_vxlan_encap conf;
587 struct rte_flow_item items[ACTION_VXLAN_ENCAP_ITEMS_NUM];
588 struct rte_flow_item_eth item_eth;
589 struct rte_flow_item_vlan item_vlan;
591 struct rte_flow_item_ipv4 item_ipv4;
592 struct rte_flow_item_ipv6 item_ipv6;
594 struct rte_flow_item_udp item_udp;
595 struct rte_flow_item_vxlan item_vxlan;
598 struct nvgre_encap_conf nvgre_encap_conf = {
601 .tni = "\x00\x00\x00",
602 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
603 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
604 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
605 "\x00\x00\x00\x00\x00\x00\x00\x01",
606 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
607 "\x00\x00\x00\x00\x00\x00\x11\x11",
609 .eth_src = "\x00\x00\x00\x00\x00\x00",
610 .eth_dst = "\xff\xff\xff\xff\xff\xff",
613 /** Maximum number of items in struct rte_flow_action_nvgre_encap. */
614 #define ACTION_NVGRE_ENCAP_ITEMS_NUM 5
616 /** Storage for struct rte_flow_action_nvgre_encap including external data. */
617 struct action_nvgre_encap_data {
618 struct rte_flow_action_nvgre_encap conf;
619 struct rte_flow_item items[ACTION_NVGRE_ENCAP_ITEMS_NUM];
620 struct rte_flow_item_eth item_eth;
621 struct rte_flow_item_vlan item_vlan;
623 struct rte_flow_item_ipv4 item_ipv4;
624 struct rte_flow_item_ipv6 item_ipv6;
626 struct rte_flow_item_nvgre item_nvgre;
629 struct l2_encap_conf l2_encap_conf;
631 struct l2_decap_conf l2_decap_conf;
633 struct mplsogre_encap_conf mplsogre_encap_conf;
635 struct mplsogre_decap_conf mplsogre_decap_conf;
637 struct mplsoudp_encap_conf mplsoudp_encap_conf;
639 struct mplsoudp_decap_conf mplsoudp_decap_conf;
641 struct rte_flow_action_conntrack conntrack_context;
643 #define ACTION_SAMPLE_ACTIONS_NUM 10
644 #define RAW_SAMPLE_CONFS_MAX_NUM 8
645 /** Storage for struct rte_flow_action_sample including external data. */
646 struct action_sample_data {
647 struct rte_flow_action_sample conf;
650 /** Storage for struct rte_flow_action_sample. */
651 struct raw_sample_conf {
652 struct rte_flow_action data[ACTION_SAMPLE_ACTIONS_NUM];
654 struct raw_sample_conf raw_sample_confs[RAW_SAMPLE_CONFS_MAX_NUM];
655 struct rte_flow_action_mark sample_mark[RAW_SAMPLE_CONFS_MAX_NUM];
656 struct rte_flow_action_queue sample_queue[RAW_SAMPLE_CONFS_MAX_NUM];
657 struct rte_flow_action_count sample_count[RAW_SAMPLE_CONFS_MAX_NUM];
658 struct rte_flow_action_port_id sample_port_id[RAW_SAMPLE_CONFS_MAX_NUM];
659 struct rte_flow_action_raw_encap sample_encap[RAW_SAMPLE_CONFS_MAX_NUM];
660 struct action_vxlan_encap_data sample_vxlan_encap[RAW_SAMPLE_CONFS_MAX_NUM];
661 struct action_nvgre_encap_data sample_nvgre_encap[RAW_SAMPLE_CONFS_MAX_NUM];
662 struct action_rss_data sample_rss_data[RAW_SAMPLE_CONFS_MAX_NUM];
663 struct rte_flow_action_vf sample_vf[RAW_SAMPLE_CONFS_MAX_NUM];
665 static const char *const modify_field_ops[] = {
666 "set", "add", "sub", NULL
669 static const char *const modify_field_ids[] = {
670 "start", "mac_dst", "mac_src",
671 "vlan_type", "vlan_id", "mac_type",
672 "ipv4_dscp", "ipv4_ttl", "ipv4_src", "ipv4_dst",
673 "ipv6_dscp", "ipv6_hoplimit", "ipv6_src", "ipv6_dst",
674 "tcp_port_src", "tcp_port_dst",
675 "tcp_seq_num", "tcp_ack_num", "tcp_flags",
676 "udp_port_src", "udp_port_dst",
677 "vxlan_vni", "geneve_vni", "gtp_teid",
678 "tag", "mark", "meta", "pointer", "value", NULL
681 /** Maximum number of subsequent tokens and arguments on the stack. */
682 #define CTX_STACK_SIZE 16
684 /** Parser context. */
686 /** Stack of subsequent token lists to process. */
687 const enum index *next[CTX_STACK_SIZE];
688 /** Arguments for stacked tokens. */
689 const void *args[CTX_STACK_SIZE];
690 enum index curr; /**< Current token index. */
691 enum index prev; /**< Index of the last token seen. */
692 int next_num; /**< Number of entries in next[]. */
693 int args_num; /**< Number of entries in args[]. */
694 uint32_t eol:1; /**< EOL has been detected. */
695 uint32_t last:1; /**< No more arguments. */
696 portid_t port; /**< Current port ID (for completions). */
697 uint32_t objdata; /**< Object-specific data. */
698 void *object; /**< Address of current object for relative offsets. */
699 void *objmask; /**< Object a full mask must be written to. */
702 /** Token argument. */
704 uint32_t hton:1; /**< Use network byte ordering. */
705 uint32_t sign:1; /**< Value is signed. */
706 uint32_t bounded:1; /**< Value is bounded. */
707 uintmax_t min; /**< Minimum value if bounded. */
708 uintmax_t max; /**< Maximum value if bounded. */
709 uint32_t offset; /**< Relative offset from ctx->object. */
710 uint32_t size; /**< Field size. */
711 const uint8_t *mask; /**< Bit-mask to use instead of offset/size. */
714 /** Parser token definition. */
716 /** Type displayed during completion (defaults to "TOKEN"). */
718 /** Help displayed during completion (defaults to token name). */
720 /** Private data used by parser functions. */
723 * Lists of subsequent tokens to push on the stack. Each call to the
724 * parser consumes the last entry of that stack.
726 const enum index *const *next;
727 /** Arguments stack for subsequent tokens that need them. */
728 const struct arg *const *args;
730 * Token-processing callback, returns -1 in case of error, the
731 * length of the matched string otherwise. If NULL, attempts to
732 * match the token name.
734 * If buf is not NULL, the result should be stored in it according
735 * to context. An error is returned if not large enough.
737 int (*call)(struct context *ctx, const struct token *token,
738 const char *str, unsigned int len,
739 void *buf, unsigned int size);
741 * Callback that provides possible values for this token, used for
742 * completion. Returns -1 in case of error, the number of possible
743 * values otherwise. If NULL, the token name is used.
745 * If buf is not NULL, entry index ent is written to buf and the
746 * full length of the entry is returned (same behavior as
749 int (*comp)(struct context *ctx, const struct token *token,
750 unsigned int ent, char *buf, unsigned int size);
751 /** Mandatory token name, no default value. */
755 /** Static initializer for the next field. */
756 #define NEXT(...) (const enum index *const []){ __VA_ARGS__, NULL, }
758 /** Static initializer for a NEXT() entry. */
759 #define NEXT_ENTRY(...) (const enum index []){ __VA_ARGS__, ZERO, }
761 /** Static initializer for the args field. */
762 #define ARGS(...) (const struct arg *const []){ __VA_ARGS__, NULL, }
764 /** Static initializer for ARGS() to target a field. */
765 #define ARGS_ENTRY(s, f) \
766 (&(const struct arg){ \
767 .offset = offsetof(s, f), \
768 .size = sizeof(((s *)0)->f), \
771 /** Static initializer for ARGS() to target a bit-field. */
772 #define ARGS_ENTRY_BF(s, f, b) \
773 (&(const struct arg){ \
775 .mask = (const void *)&(const s){ .f = (1 << (b)) - 1 }, \
778 /** Static initializer for ARGS() to target a field with limits. */
779 #define ARGS_ENTRY_BOUNDED(s, f, i, a) \
780 (&(const struct arg){ \
784 .offset = offsetof(s, f), \
785 .size = sizeof(((s *)0)->f), \
788 /** Static initializer for ARGS() to target an arbitrary bit-mask. */
789 #define ARGS_ENTRY_MASK(s, f, m) \
790 (&(const struct arg){ \
791 .offset = offsetof(s, f), \
792 .size = sizeof(((s *)0)->f), \
793 .mask = (const void *)(m), \
796 /** Same as ARGS_ENTRY_MASK() using network byte ordering for the value. */
797 #define ARGS_ENTRY_MASK_HTON(s, f, m) \
798 (&(const struct arg){ \
800 .offset = offsetof(s, f), \
801 .size = sizeof(((s *)0)->f), \
802 .mask = (const void *)(m), \
805 /** Static initializer for ARGS() to target a pointer. */
806 #define ARGS_ENTRY_PTR(s, f) \
807 (&(const struct arg){ \
808 .size = sizeof(*((s *)0)->f), \
811 /** Static initializer for ARGS() with arbitrary offset and size. */
812 #define ARGS_ENTRY_ARB(o, s) \
813 (&(const struct arg){ \
818 /** Same as ARGS_ENTRY_ARB() with bounded values. */
819 #define ARGS_ENTRY_ARB_BOUNDED(o, s, i, a) \
820 (&(const struct arg){ \
828 /** Same as ARGS_ENTRY() using network byte ordering. */
829 #define ARGS_ENTRY_HTON(s, f) \
830 (&(const struct arg){ \
832 .offset = offsetof(s, f), \
833 .size = sizeof(((s *)0)->f), \
836 /** Same as ARGS_ENTRY_HTON() for a single argument, without structure. */
837 #define ARG_ENTRY_HTON(s) \
838 (&(const struct arg){ \
844 /** Parser output buffer layout expected by cmd_flow_parsed(). */
846 enum index command; /**< Flow command. */
847 portid_t port; /**< Affected port ID. */
851 uint32_t action_id_n;
852 } ia_destroy; /**< Indirect action destroy arguments. */
855 } ia; /* Indirect action query arguments */
857 struct rte_flow_attr attr;
858 struct tunnel_ops tunnel_ops;
859 struct rte_flow_item *pattern;
860 struct rte_flow_action *actions;
864 } vc; /**< Validate/create arguments. */
868 } destroy; /**< Destroy arguments. */
873 } dump; /**< Dump arguments. */
876 struct rte_flow_action action;
877 } query; /**< Query arguments. */
881 } list; /**< List arguments. */
884 } isolate; /**< Isolated mode arguments. */
887 } aged; /**< Aged arguments. */
890 } policy;/**< Policy arguments. */
895 } flex; /**< Flex arguments*/
896 } args; /**< Command arguments. */
899 /** Private data for pattern items. */
900 struct parse_item_priv {
901 enum rte_flow_item_type type; /**< Item type. */
902 uint32_t size; /**< Size of item specification structure. */
905 #define PRIV_ITEM(t, s) \
906 (&(const struct parse_item_priv){ \
907 .type = RTE_FLOW_ITEM_TYPE_ ## t, \
911 /** Private data for actions. */
912 struct parse_action_priv {
913 enum rte_flow_action_type type; /**< Action type. */
914 uint32_t size; /**< Size of action configuration structure. */
917 #define PRIV_ACTION(t, s) \
918 (&(const struct parse_action_priv){ \
919 .type = RTE_FLOW_ACTION_TYPE_ ## t, \
923 static const enum index next_flex_item[] = {
930 static const enum index next_ia_create_attr[] = {
931 INDIRECT_ACTION_CREATE_ID,
932 INDIRECT_ACTION_INGRESS,
933 INDIRECT_ACTION_EGRESS,
934 INDIRECT_ACTION_TRANSFER,
935 INDIRECT_ACTION_SPEC,
939 static const enum index next_dump_subcmd[] = {
945 static const enum index next_ia_subcmd[] = {
946 INDIRECT_ACTION_CREATE,
947 INDIRECT_ACTION_UPDATE,
948 INDIRECT_ACTION_DESTROY,
949 INDIRECT_ACTION_QUERY,
953 static const enum index next_vc_attr[] = {
965 static const enum index next_destroy_attr[] = {
971 static const enum index next_dump_attr[] = {
977 static const enum index next_list_attr[] = {
983 static const enum index next_aged_attr[] = {
989 static const enum index next_ia_destroy_attr[] = {
990 INDIRECT_ACTION_DESTROY_ID,
995 static const enum index item_param[] = {
1004 static const enum index next_item[] = {
1041 ITEM_ICMP6_ND_OPT_SLA_ETH,
1042 ITEM_ICMP6_ND_OPT_TLA_ETH,
1048 ITEM_PPPOE_PROTO_ID,
1059 ITEM_PORT_REPRESENTOR,
1060 ITEM_REPRESENTED_PORT,
1068 static const enum index item_fuzzy[] = {
1074 static const enum index item_any[] = {
1080 static const enum index item_vf[] = {
1086 static const enum index item_phy_port[] = {
1087 ITEM_PHY_PORT_INDEX,
1092 static const enum index item_port_id[] = {
1098 static const enum index item_mark[] = {
1104 static const enum index item_raw[] = {
1114 static const enum index item_eth[] = {
1123 static const enum index item_vlan[] = {
1128 ITEM_VLAN_INNER_TYPE,
1129 ITEM_VLAN_HAS_MORE_VLAN,
1134 static const enum index item_ipv4[] = {
1138 ITEM_IPV4_FRAGMENT_OFFSET,
1147 static const enum index item_ipv6[] = {
1154 ITEM_IPV6_HAS_FRAG_EXT,
1159 static const enum index item_icmp[] = {
1168 static const enum index item_udp[] = {
1175 static const enum index item_tcp[] = {
1183 static const enum index item_sctp[] = {
1192 static const enum index item_vxlan[] = {
1194 ITEM_VXLAN_LAST_RSVD,
1199 static const enum index item_e_tag[] = {
1200 ITEM_E_TAG_GRP_ECID_B,
1205 static const enum index item_nvgre[] = {
1211 static const enum index item_mpls[] = {
1219 static const enum index item_gre[] = {
1221 ITEM_GRE_C_RSVD0_VER,
1229 static const enum index item_gre_key[] = {
1235 static const enum index item_gtp[] = {
1243 static const enum index item_geneve[] = {
1251 static const enum index item_vxlan_gpe[] = {
1257 static const enum index item_arp_eth_ipv4[] = {
1258 ITEM_ARP_ETH_IPV4_SHA,
1259 ITEM_ARP_ETH_IPV4_SPA,
1260 ITEM_ARP_ETH_IPV4_THA,
1261 ITEM_ARP_ETH_IPV4_TPA,
1266 static const enum index item_ipv6_ext[] = {
1267 ITEM_IPV6_EXT_NEXT_HDR,
1272 static const enum index item_ipv6_frag_ext[] = {
1273 ITEM_IPV6_FRAG_EXT_NEXT_HDR,
1274 ITEM_IPV6_FRAG_EXT_FRAG_DATA,
1275 ITEM_IPV6_FRAG_EXT_ID,
1280 static const enum index item_icmp6[] = {
1287 static const enum index item_icmp6_nd_ns[] = {
1288 ITEM_ICMP6_ND_NS_TARGET_ADDR,
1293 static const enum index item_icmp6_nd_na[] = {
1294 ITEM_ICMP6_ND_NA_TARGET_ADDR,
1299 static const enum index item_icmp6_nd_opt[] = {
1300 ITEM_ICMP6_ND_OPT_TYPE,
1305 static const enum index item_icmp6_nd_opt_sla_eth[] = {
1306 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
1311 static const enum index item_icmp6_nd_opt_tla_eth[] = {
1312 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
1317 static const enum index item_meta[] = {
1323 static const enum index item_gtp_psc[] = {
1330 static const enum index item_pppoed[] = {
1336 static const enum index item_pppoes[] = {
1342 static const enum index item_pppoe_proto_id[] = {
1347 static const enum index item_higig2[] = {
1348 ITEM_HIGIG2_CLASSIFICATION,
1354 static const enum index item_esp[] = {
1360 static const enum index item_ah[] = {
1366 static const enum index item_pfcp[] = {
1373 static const enum index next_set_raw[] = {
1379 static const enum index item_tag[] = {
1386 static const enum index item_l2tpv3oip[] = {
1387 ITEM_L2TPV3OIP_SESSION_ID,
1392 static const enum index item_ecpri[] = {
1398 static const enum index item_ecpri_common[] = {
1399 ITEM_ECPRI_COMMON_TYPE,
1403 static const enum index item_ecpri_common_type[] = {
1404 ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
1405 ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
1406 ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
1410 static const enum index item_geneve_opt[] = {
1411 ITEM_GENEVE_OPT_CLASS,
1412 ITEM_GENEVE_OPT_TYPE,
1413 ITEM_GENEVE_OPT_LENGTH,
1414 ITEM_GENEVE_OPT_DATA,
1419 static const enum index item_integrity[] = {
1420 ITEM_INTEGRITY_LEVEL,
1421 ITEM_INTEGRITY_VALUE,
1425 static const enum index item_integrity_lv[] = {
1426 ITEM_INTEGRITY_LEVEL,
1427 ITEM_INTEGRITY_VALUE,
1432 static const enum index item_port_representor[] = {
1433 ITEM_PORT_REPRESENTOR_PORT_ID,
1438 static const enum index item_represented_port[] = {
1439 ITEM_REPRESENTED_PORT_ETHDEV_PORT_ID,
1444 static const enum index item_flex[] = {
1445 ITEM_FLEX_PATTERN_HANDLE,
1446 ITEM_FLEX_ITEM_HANDLE,
1451 static const enum index item_l2tpv2[] = {
1457 static const enum index item_l2tpv2_common[] = {
1458 ITEM_L2TPV2_COMMON_TYPE,
1462 static const enum index item_l2tpv2_common_type[] = {
1463 ITEM_L2TPV2_COMMON_TYPE_DATA_L,
1464 ITEM_L2TPV2_COMMON_TYPE_CTRL,
1468 static const enum index item_ppp[] = {
1476 static const enum index next_action[] = {
1493 ACTION_OF_SET_MPLS_TTL,
1494 ACTION_OF_DEC_MPLS_TTL,
1495 ACTION_OF_SET_NW_TTL,
1496 ACTION_OF_DEC_NW_TTL,
1497 ACTION_OF_COPY_TTL_OUT,
1498 ACTION_OF_COPY_TTL_IN,
1500 ACTION_OF_PUSH_VLAN,
1501 ACTION_OF_SET_VLAN_VID,
1502 ACTION_OF_SET_VLAN_PCP,
1504 ACTION_OF_PUSH_MPLS,
1511 ACTION_MPLSOGRE_ENCAP,
1512 ACTION_MPLSOGRE_DECAP,
1513 ACTION_MPLSOUDP_ENCAP,
1514 ACTION_MPLSOUDP_DECAP,
1515 ACTION_SET_IPV4_SRC,
1516 ACTION_SET_IPV4_DST,
1517 ACTION_SET_IPV6_SRC,
1518 ACTION_SET_IPV6_DST,
1534 ACTION_SET_IPV4_DSCP,
1535 ACTION_SET_IPV6_DSCP,
1539 ACTION_MODIFY_FIELD,
1541 ACTION_CONNTRACK_UPDATE,
1542 ACTION_PORT_REPRESENTOR,
1543 ACTION_REPRESENTED_PORT,
1547 static const enum index action_mark[] = {
1553 static const enum index action_queue[] = {
1559 static const enum index action_count[] = {
1565 static const enum index action_rss[] = {
1576 static const enum index action_vf[] = {
1583 static const enum index action_phy_port[] = {
1584 ACTION_PHY_PORT_ORIGINAL,
1585 ACTION_PHY_PORT_INDEX,
1590 static const enum index action_port_id[] = {
1591 ACTION_PORT_ID_ORIGINAL,
1597 static const enum index action_meter[] = {
1603 static const enum index action_meter_color[] = {
1604 ACTION_METER_COLOR_TYPE,
1609 static const enum index action_of_set_mpls_ttl[] = {
1610 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
1615 static const enum index action_of_set_nw_ttl[] = {
1616 ACTION_OF_SET_NW_TTL_NW_TTL,
1621 static const enum index action_of_push_vlan[] = {
1622 ACTION_OF_PUSH_VLAN_ETHERTYPE,
1627 static const enum index action_of_set_vlan_vid[] = {
1628 ACTION_OF_SET_VLAN_VID_VLAN_VID,
1633 static const enum index action_of_set_vlan_pcp[] = {
1634 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
1639 static const enum index action_of_pop_mpls[] = {
1640 ACTION_OF_POP_MPLS_ETHERTYPE,
1645 static const enum index action_of_push_mpls[] = {
1646 ACTION_OF_PUSH_MPLS_ETHERTYPE,
1651 static const enum index action_set_ipv4_src[] = {
1652 ACTION_SET_IPV4_SRC_IPV4_SRC,
1657 static const enum index action_set_mac_src[] = {
1658 ACTION_SET_MAC_SRC_MAC_SRC,
1663 static const enum index action_set_ipv4_dst[] = {
1664 ACTION_SET_IPV4_DST_IPV4_DST,
1669 static const enum index action_set_ipv6_src[] = {
1670 ACTION_SET_IPV6_SRC_IPV6_SRC,
1675 static const enum index action_set_ipv6_dst[] = {
1676 ACTION_SET_IPV6_DST_IPV6_DST,
1681 static const enum index action_set_tp_src[] = {
1682 ACTION_SET_TP_SRC_TP_SRC,
1687 static const enum index action_set_tp_dst[] = {
1688 ACTION_SET_TP_DST_TP_DST,
1693 static const enum index action_set_ttl[] = {
1699 static const enum index action_jump[] = {
1705 static const enum index action_set_mac_dst[] = {
1706 ACTION_SET_MAC_DST_MAC_DST,
1711 static const enum index action_inc_tcp_seq[] = {
1712 ACTION_INC_TCP_SEQ_VALUE,
1717 static const enum index action_dec_tcp_seq[] = {
1718 ACTION_DEC_TCP_SEQ_VALUE,
1723 static const enum index action_inc_tcp_ack[] = {
1724 ACTION_INC_TCP_ACK_VALUE,
1729 static const enum index action_dec_tcp_ack[] = {
1730 ACTION_DEC_TCP_ACK_VALUE,
1735 static const enum index action_raw_encap[] = {
1736 ACTION_RAW_ENCAP_INDEX,
1741 static const enum index action_raw_decap[] = {
1742 ACTION_RAW_DECAP_INDEX,
1747 static const enum index action_set_tag[] = {
1748 ACTION_SET_TAG_DATA,
1749 ACTION_SET_TAG_INDEX,
1750 ACTION_SET_TAG_MASK,
1755 static const enum index action_set_meta[] = {
1756 ACTION_SET_META_DATA,
1757 ACTION_SET_META_MASK,
1762 static const enum index action_set_ipv4_dscp[] = {
1763 ACTION_SET_IPV4_DSCP_VALUE,
1768 static const enum index action_set_ipv6_dscp[] = {
1769 ACTION_SET_IPV6_DSCP_VALUE,
1774 static const enum index action_age[] = {
1781 static const enum index action_sample[] = {
1783 ACTION_SAMPLE_RATIO,
1784 ACTION_SAMPLE_INDEX,
1789 static const enum index next_action_sample[] = {
1802 static const enum index action_modify_field_dst[] = {
1803 ACTION_MODIFY_FIELD_DST_LEVEL,
1804 ACTION_MODIFY_FIELD_DST_OFFSET,
1805 ACTION_MODIFY_FIELD_SRC_TYPE,
1809 static const enum index action_modify_field_src[] = {
1810 ACTION_MODIFY_FIELD_SRC_LEVEL,
1811 ACTION_MODIFY_FIELD_SRC_OFFSET,
1812 ACTION_MODIFY_FIELD_SRC_VALUE,
1813 ACTION_MODIFY_FIELD_SRC_POINTER,
1814 ACTION_MODIFY_FIELD_WIDTH,
1818 static const enum index action_update_conntrack[] = {
1819 ACTION_CONNTRACK_UPDATE_DIR,
1820 ACTION_CONNTRACK_UPDATE_CTX,
1825 static const enum index action_port_representor[] = {
1826 ACTION_PORT_REPRESENTOR_PORT_ID,
1831 static const enum index action_represented_port[] = {
1832 ACTION_REPRESENTED_PORT_ETHDEV_PORT_ID,
1837 static int parse_set_raw_encap_decap(struct context *, const struct token *,
1838 const char *, unsigned int,
1839 void *, unsigned int);
1840 static int parse_set_sample_action(struct context *, const struct token *,
1841 const char *, unsigned int,
1842 void *, unsigned int);
1843 static int parse_set_init(struct context *, const struct token *,
1844 const char *, unsigned int,
1845 void *, unsigned int);
1847 parse_flex_handle(struct context *, const struct token *,
1848 const char *, unsigned int, void *, unsigned int);
1849 static int parse_init(struct context *, const struct token *,
1850 const char *, unsigned int,
1851 void *, unsigned int);
1852 static int parse_vc(struct context *, const struct token *,
1853 const char *, unsigned int,
1854 void *, unsigned int);
1855 static int parse_vc_spec(struct context *, const struct token *,
1856 const char *, unsigned int, void *, unsigned int);
1857 static int parse_vc_conf(struct context *, const struct token *,
1858 const char *, unsigned int, void *, unsigned int);
1859 static int parse_vc_item_ecpri_type(struct context *, const struct token *,
1860 const char *, unsigned int,
1861 void *, unsigned int);
1862 static int parse_vc_item_l2tpv2_type(struct context *, const struct token *,
1863 const char *, unsigned int,
1864 void *, unsigned int);
1865 static int parse_vc_action_meter_color_type(struct context *,
1866 const struct token *,
1867 const char *, unsigned int, void *,
1869 static int parse_vc_action_rss(struct context *, const struct token *,
1870 const char *, unsigned int, void *,
1872 static int parse_vc_action_rss_func(struct context *, const struct token *,
1873 const char *, unsigned int, void *,
1875 static int parse_vc_action_rss_type(struct context *, const struct token *,
1876 const char *, unsigned int, void *,
1878 static int parse_vc_action_rss_queue(struct context *, const struct token *,
1879 const char *, unsigned int, void *,
1881 static int parse_vc_action_vxlan_encap(struct context *, const struct token *,
1882 const char *, unsigned int, void *,
1884 static int parse_vc_action_nvgre_encap(struct context *, const struct token *,
1885 const char *, unsigned int, void *,
1887 static int parse_vc_action_l2_encap(struct context *, const struct token *,
1888 const char *, unsigned int, void *,
1890 static int parse_vc_action_l2_decap(struct context *, const struct token *,
1891 const char *, unsigned int, void *,
1893 static int parse_vc_action_mplsogre_encap(struct context *,
1894 const struct token *, const char *,
1895 unsigned int, void *, unsigned int);
1896 static int parse_vc_action_mplsogre_decap(struct context *,
1897 const struct token *, const char *,
1898 unsigned int, void *, unsigned int);
1899 static int parse_vc_action_mplsoudp_encap(struct context *,
1900 const struct token *, const char *,
1901 unsigned int, void *, unsigned int);
1902 static int parse_vc_action_mplsoudp_decap(struct context *,
1903 const struct token *, const char *,
1904 unsigned int, void *, unsigned int);
1905 static int parse_vc_action_raw_encap(struct context *,
1906 const struct token *, const char *,
1907 unsigned int, void *, unsigned int);
1908 static int parse_vc_action_raw_decap(struct context *,
1909 const struct token *, const char *,
1910 unsigned int, void *, unsigned int);
1911 static int parse_vc_action_raw_encap_index(struct context *,
1912 const struct token *, const char *,
1913 unsigned int, void *, unsigned int);
1914 static int parse_vc_action_raw_decap_index(struct context *,
1915 const struct token *, const char *,
1916 unsigned int, void *, unsigned int);
1917 static int parse_vc_action_set_meta(struct context *ctx,
1918 const struct token *token, const char *str,
1919 unsigned int len, void *buf,
1921 static int parse_vc_action_sample(struct context *ctx,
1922 const struct token *token, const char *str,
1923 unsigned int len, void *buf,
1926 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
1927 const char *str, unsigned int len, void *buf,
1930 parse_vc_modify_field_op(struct context *ctx, const struct token *token,
1931 const char *str, unsigned int len, void *buf,
1934 parse_vc_modify_field_id(struct context *ctx, const struct token *token,
1935 const char *str, unsigned int len, void *buf,
1938 parse_vc_action_conntrack_update(struct context *ctx, const struct token *token,
1939 const char *str, unsigned int len, void *buf,
1941 static int parse_destroy(struct context *, const struct token *,
1942 const char *, unsigned int,
1943 void *, unsigned int);
1944 static int parse_flush(struct context *, const struct token *,
1945 const char *, unsigned int,
1946 void *, unsigned int);
1947 static int parse_dump(struct context *, const struct token *,
1948 const char *, unsigned int,
1949 void *, unsigned int);
1950 static int parse_query(struct context *, const struct token *,
1951 const char *, unsigned int,
1952 void *, unsigned int);
1953 static int parse_action(struct context *, const struct token *,
1954 const char *, unsigned int,
1955 void *, unsigned int);
1956 static int parse_list(struct context *, const struct token *,
1957 const char *, unsigned int,
1958 void *, unsigned int);
1959 static int parse_aged(struct context *, const struct token *,
1960 const char *, unsigned int,
1961 void *, unsigned int);
1962 static int parse_isolate(struct context *, const struct token *,
1963 const char *, unsigned int,
1964 void *, unsigned int);
1965 static int parse_tunnel(struct context *, const struct token *,
1966 const char *, unsigned int,
1967 void *, unsigned int);
1968 static int parse_flex(struct context *, const struct token *,
1969 const char *, unsigned int, void *, unsigned int);
1970 static int parse_int(struct context *, const struct token *,
1971 const char *, unsigned int,
1972 void *, unsigned int);
1973 static int parse_prefix(struct context *, const struct token *,
1974 const char *, unsigned int,
1975 void *, unsigned int);
1976 static int parse_boolean(struct context *, const struct token *,
1977 const char *, unsigned int,
1978 void *, unsigned int);
1979 static int parse_string(struct context *, const struct token *,
1980 const char *, unsigned int,
1981 void *, unsigned int);
1982 static int parse_hex(struct context *ctx, const struct token *token,
1983 const char *str, unsigned int len,
1984 void *buf, unsigned int size);
1985 static int parse_string0(struct context *, const struct token *,
1986 const char *, unsigned int,
1987 void *, unsigned int);
1988 static int parse_mac_addr(struct context *, const struct token *,
1989 const char *, unsigned int,
1990 void *, unsigned int);
1991 static int parse_ipv4_addr(struct context *, const struct token *,
1992 const char *, unsigned int,
1993 void *, unsigned int);
1994 static int parse_ipv6_addr(struct context *, const struct token *,
1995 const char *, unsigned int,
1996 void *, unsigned int);
1997 static int parse_port(struct context *, const struct token *,
1998 const char *, unsigned int,
1999 void *, unsigned int);
2000 static int parse_ia(struct context *, const struct token *,
2001 const char *, unsigned int,
2002 void *, unsigned int);
2003 static int parse_ia_destroy(struct context *ctx, const struct token *token,
2004 const char *str, unsigned int len,
2005 void *buf, unsigned int size);
2006 static int parse_ia_id2ptr(struct context *ctx, const struct token *token,
2007 const char *str, unsigned int len, void *buf,
2009 static int parse_mp(struct context *, const struct token *,
2010 const char *, unsigned int,
2011 void *, unsigned int);
2012 static int comp_none(struct context *, const struct token *,
2013 unsigned int, char *, unsigned int);
2014 static int comp_boolean(struct context *, const struct token *,
2015 unsigned int, char *, unsigned int);
2016 static int comp_action(struct context *, const struct token *,
2017 unsigned int, char *, unsigned int);
2018 static int comp_port(struct context *, const struct token *,
2019 unsigned int, char *, unsigned int);
2020 static int comp_rule_id(struct context *, const struct token *,
2021 unsigned int, char *, unsigned int);
2022 static int comp_vc_action_rss_type(struct context *, const struct token *,
2023 unsigned int, char *, unsigned int);
2024 static int comp_vc_action_rss_queue(struct context *, const struct token *,
2025 unsigned int, char *, unsigned int);
2026 static int comp_set_raw_index(struct context *, const struct token *,
2027 unsigned int, char *, unsigned int);
2028 static int comp_set_sample_index(struct context *, const struct token *,
2029 unsigned int, char *, unsigned int);
2030 static int comp_set_modify_field_op(struct context *, const struct token *,
2031 unsigned int, char *, unsigned int);
2032 static int comp_set_modify_field_id(struct context *, const struct token *,
2033 unsigned int, char *, unsigned int);
2035 /** Token definitions. */
2036 static const struct token token_list[] = {
2037 /* Special tokens. */
2040 .help = "null entry, abused as the entry point",
2041 .next = NEXT(NEXT_ENTRY(FLOW, ADD)),
2046 .help = "command may end here",
2049 .name = "START_SET",
2050 .help = "null entry, abused as the entry point for set",
2051 .next = NEXT(NEXT_ENTRY(SET)),
2056 .help = "set command may end here",
2058 /* Common tokens. */
2059 [COMMON_INTEGER] = {
2062 .help = "integer value",
2066 [COMMON_UNSIGNED] = {
2067 .name = "{unsigned}",
2069 .help = "unsigned integer value",
2076 .help = "prefix length for bit-mask",
2077 .call = parse_prefix,
2080 [COMMON_BOOLEAN] = {
2081 .name = "{boolean}",
2083 .help = "any boolean value",
2084 .call = parse_boolean,
2085 .comp = comp_boolean,
2090 .help = "fixed string",
2091 .call = parse_string,
2097 .help = "fixed string",
2100 [COMMON_FILE_PATH] = {
2101 .name = "{file path}",
2103 .help = "file path",
2104 .call = parse_string0,
2107 [COMMON_MAC_ADDR] = {
2108 .name = "{MAC address}",
2110 .help = "standard MAC address notation",
2111 .call = parse_mac_addr,
2114 [COMMON_IPV4_ADDR] = {
2115 .name = "{IPv4 address}",
2116 .type = "IPV4 ADDRESS",
2117 .help = "standard IPv4 address notation",
2118 .call = parse_ipv4_addr,
2121 [COMMON_IPV6_ADDR] = {
2122 .name = "{IPv6 address}",
2123 .type = "IPV6 ADDRESS",
2124 .help = "standard IPv6 address notation",
2125 .call = parse_ipv6_addr,
2128 [COMMON_RULE_ID] = {
2129 .name = "{rule id}",
2131 .help = "rule identifier",
2133 .comp = comp_rule_id,
2135 [COMMON_PORT_ID] = {
2136 .name = "{port_id}",
2138 .help = "port identifier",
2142 [COMMON_GROUP_ID] = {
2143 .name = "{group_id}",
2145 .help = "group identifier",
2149 [COMMON_PRIORITY_LEVEL] = {
2152 .help = "priority level",
2156 [COMMON_INDIRECT_ACTION_ID] = {
2157 .name = "{indirect_action_id}",
2158 .type = "INDIRECT_ACTION_ID",
2159 .help = "indirect action id",
2163 [COMMON_POLICY_ID] = {
2164 .name = "{policy_id}",
2165 .type = "POLCIY_ID",
2166 .help = "policy id",
2170 [COMMON_FLEX_TOKEN] = {
2171 .name = "{flex token}",
2172 .type = "flex token",
2173 .help = "flex token",
2177 [COMMON_FLEX_HANDLE] = {
2178 .name = "{flex handle}",
2179 .type = "FLEX HANDLE",
2180 .help = "fill flex item data",
2181 .call = parse_flex_handle,
2184 /* Top-level command. */
2187 .type = "{command} {port_id} [{arg} [...]]",
2188 .help = "manage ingress/egress flow rules",
2189 .next = NEXT(NEXT_ENTRY
2204 /* Top-level command. */
2205 [INDIRECT_ACTION] = {
2206 .name = "indirect_action",
2207 .type = "{command} {port_id} [{arg} [...]]",
2208 .help = "manage indirect actions",
2209 .next = NEXT(next_ia_subcmd, NEXT_ENTRY(COMMON_PORT_ID)),
2210 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2213 /* Sub-level commands. */
2214 [INDIRECT_ACTION_CREATE] = {
2216 .help = "create indirect action",
2217 .next = NEXT(next_ia_create_attr),
2220 [INDIRECT_ACTION_UPDATE] = {
2222 .help = "update indirect action",
2223 .next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_SPEC),
2224 NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
2225 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
2228 [INDIRECT_ACTION_DESTROY] = {
2230 .help = "destroy indirect action",
2231 .next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_DESTROY_ID)),
2232 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2233 .call = parse_ia_destroy,
2235 [INDIRECT_ACTION_QUERY] = {
2237 .help = "query indirect action",
2238 .next = NEXT(NEXT_ENTRY(END),
2239 NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
2240 .args = ARGS(ARGS_ENTRY(struct buffer, args.ia.action_id)),
2245 .help = "check whether a flow rule can be created",
2246 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_PORT_ID)),
2247 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2252 .help = "create a flow rule",
2253 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_PORT_ID)),
2254 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2259 .help = "destroy specific flow rules",
2260 .next = NEXT(NEXT_ENTRY(DESTROY_RULE),
2261 NEXT_ENTRY(COMMON_PORT_ID)),
2262 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2263 .call = parse_destroy,
2267 .help = "destroy all flow rules",
2268 .next = NEXT(NEXT_ENTRY(COMMON_PORT_ID)),
2269 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2270 .call = parse_flush,
2274 .help = "dump single/all flow rules to file",
2275 .next = NEXT(next_dump_subcmd, NEXT_ENTRY(COMMON_PORT_ID)),
2276 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2281 .help = "query an existing flow rule",
2282 .next = NEXT(NEXT_ENTRY(QUERY_ACTION),
2283 NEXT_ENTRY(COMMON_RULE_ID),
2284 NEXT_ENTRY(COMMON_PORT_ID)),
2285 .args = ARGS(ARGS_ENTRY(struct buffer, args.query.action.type),
2286 ARGS_ENTRY(struct buffer, args.query.rule),
2287 ARGS_ENTRY(struct buffer, port)),
2288 .call = parse_query,
2292 .help = "list existing flow rules",
2293 .next = NEXT(next_list_attr, NEXT_ENTRY(COMMON_PORT_ID)),
2294 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2299 .help = "list and destroy aged flows",
2300 .next = NEXT(next_aged_attr, NEXT_ENTRY(COMMON_PORT_ID)),
2301 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2306 .help = "restrict ingress traffic to the defined flow rules",
2307 .next = NEXT(NEXT_ENTRY(COMMON_BOOLEAN),
2308 NEXT_ENTRY(COMMON_PORT_ID)),
2309 .args = ARGS(ARGS_ENTRY(struct buffer, args.isolate.set),
2310 ARGS_ENTRY(struct buffer, port)),
2311 .call = parse_isolate,
2314 .name = "flex_item",
2315 .help = "flex item API",
2316 .next = NEXT(next_flex_item),
2319 [FLEX_ITEM_INIT] = {
2321 .help = "flex item init",
2322 .args = ARGS(ARGS_ENTRY(struct buffer, args.flex.token),
2323 ARGS_ENTRY(struct buffer, port)),
2324 .next = NEXT(NEXT_ENTRY(COMMON_FLEX_TOKEN),
2325 NEXT_ENTRY(COMMON_PORT_ID)),
2328 [FLEX_ITEM_CREATE] = {
2330 .help = "flex item create",
2331 .args = ARGS(ARGS_ENTRY(struct buffer, args.flex.filename),
2332 ARGS_ENTRY(struct buffer, args.flex.token),
2333 ARGS_ENTRY(struct buffer, port)),
2334 .next = NEXT(NEXT_ENTRY(COMMON_FILE_PATH),
2335 NEXT_ENTRY(COMMON_FLEX_TOKEN),
2336 NEXT_ENTRY(COMMON_PORT_ID)),
2339 [FLEX_ITEM_DESTROY] = {
2341 .help = "flex item destroy",
2342 .args = ARGS(ARGS_ENTRY(struct buffer, args.flex.token),
2343 ARGS_ENTRY(struct buffer, port)),
2344 .next = NEXT(NEXT_ENTRY(COMMON_FLEX_TOKEN),
2345 NEXT_ENTRY(COMMON_PORT_ID)),
2350 .help = "new tunnel API",
2351 .next = NEXT(NEXT_ENTRY
2352 (TUNNEL_CREATE, TUNNEL_LIST, TUNNEL_DESTROY)),
2353 .call = parse_tunnel,
2355 /* Tunnel arguments. */
2358 .help = "create new tunnel object",
2359 .next = NEXT(NEXT_ENTRY(TUNNEL_CREATE_TYPE),
2360 NEXT_ENTRY(COMMON_PORT_ID)),
2361 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2362 .call = parse_tunnel,
2364 [TUNNEL_CREATE_TYPE] = {
2366 .help = "create new tunnel",
2367 .next = NEXT(NEXT_ENTRY(COMMON_FILE_PATH)),
2368 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, type)),
2369 .call = parse_tunnel,
2371 [TUNNEL_DESTROY] = {
2373 .help = "destroy tunel",
2374 .next = NEXT(NEXT_ENTRY(TUNNEL_DESTROY_ID),
2375 NEXT_ENTRY(COMMON_PORT_ID)),
2376 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2377 .call = parse_tunnel,
2379 [TUNNEL_DESTROY_ID] = {
2381 .help = "tunnel identifier to testroy",
2382 .next = NEXT(NEXT_ENTRY(COMMON_UNSIGNED)),
2383 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2384 .call = parse_tunnel,
2388 .help = "list existing tunnels",
2389 .next = NEXT(NEXT_ENTRY(COMMON_PORT_ID)),
2390 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2391 .call = parse_tunnel,
2393 /* Destroy arguments. */
2396 .help = "specify a rule identifier",
2397 .next = NEXT(next_destroy_attr, NEXT_ENTRY(COMMON_RULE_ID)),
2398 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.destroy.rule)),
2399 .call = parse_destroy,
2401 /* Dump arguments. */
2405 .next = NEXT(next_dump_attr),
2406 .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file)),
2411 .help = "dump one rule",
2412 .next = NEXT(next_dump_attr, NEXT_ENTRY(COMMON_RULE_ID)),
2413 .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file),
2414 ARGS_ENTRY(struct buffer, args.dump.rule)),
2417 /* Query arguments. */
2421 .help = "action to query, must be part of the rule",
2422 .call = parse_action,
2423 .comp = comp_action,
2425 /* List arguments. */
2428 .help = "specify a group",
2429 .next = NEXT(next_list_attr, NEXT_ENTRY(COMMON_GROUP_ID)),
2430 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.list.group)),
2435 .help = "specify aged flows need be destroyed",
2439 /* Validate/create attributes. */
2442 .help = "specify a group",
2443 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_GROUP_ID)),
2444 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, group)),
2449 .help = "specify a priority level",
2450 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_PRIORITY_LEVEL)),
2451 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, priority)),
2456 .help = "affect rule to ingress",
2457 .next = NEXT(next_vc_attr),
2462 .help = "affect rule to egress",
2463 .next = NEXT(next_vc_attr),
2468 .help = "apply rule directly to endpoints found in pattern",
2469 .next = NEXT(next_vc_attr),
2473 .name = "tunnel_set",
2474 .help = "tunnel steer rule",
2475 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_UNSIGNED)),
2476 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2479 [VC_TUNNEL_MATCH] = {
2480 .name = "tunnel_match",
2481 .help = "tunnel match rule",
2482 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_UNSIGNED)),
2483 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2486 /* Validate/create pattern. */
2489 .help = "submit a list of pattern items",
2490 .next = NEXT(next_item),
2495 .help = "match value perfectly (with full bit-mask)",
2496 .call = parse_vc_spec,
2498 [ITEM_PARAM_SPEC] = {
2500 .help = "match value according to configured bit-mask",
2501 .call = parse_vc_spec,
2503 [ITEM_PARAM_LAST] = {
2505 .help = "specify upper bound to establish a range",
2506 .call = parse_vc_spec,
2508 [ITEM_PARAM_MASK] = {
2510 .help = "specify bit-mask with relevant bits set to one",
2511 .call = parse_vc_spec,
2513 [ITEM_PARAM_PREFIX] = {
2515 .help = "generate bit-mask from a prefix length",
2516 .call = parse_vc_spec,
2520 .help = "specify next pattern item",
2521 .next = NEXT(next_item),
2525 .help = "end list of pattern items",
2526 .priv = PRIV_ITEM(END, 0),
2527 .next = NEXT(NEXT_ENTRY(ACTIONS)),
2532 .help = "no-op pattern item",
2533 .priv = PRIV_ITEM(VOID, 0),
2534 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2539 .help = "perform actions when pattern does not match",
2540 .priv = PRIV_ITEM(INVERT, 0),
2541 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2546 .help = "match any protocol for the current layer",
2547 .priv = PRIV_ITEM(ANY, sizeof(struct rte_flow_item_any)),
2548 .next = NEXT(item_any),
2553 .help = "number of layers covered",
2554 .next = NEXT(item_any, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2555 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_any, num)),
2559 .help = "match traffic from/to the physical function",
2560 .priv = PRIV_ITEM(PF, 0),
2561 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2566 .help = "match traffic from/to a virtual function ID",
2567 .priv = PRIV_ITEM(VF, sizeof(struct rte_flow_item_vf)),
2568 .next = NEXT(item_vf),
2574 .next = NEXT(item_vf, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2575 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_vf, id)),
2579 .help = "match traffic from/to a specific physical port",
2580 .priv = PRIV_ITEM(PHY_PORT,
2581 sizeof(struct rte_flow_item_phy_port)),
2582 .next = NEXT(item_phy_port),
2585 [ITEM_PHY_PORT_INDEX] = {
2587 .help = "physical port index",
2588 .next = NEXT(item_phy_port, NEXT_ENTRY(COMMON_UNSIGNED),
2590 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_phy_port, index)),
2594 .help = "match traffic from/to a given DPDK port ID",
2595 .priv = PRIV_ITEM(PORT_ID,
2596 sizeof(struct rte_flow_item_port_id)),
2597 .next = NEXT(item_port_id),
2600 [ITEM_PORT_ID_ID] = {
2602 .help = "DPDK port ID",
2603 .next = NEXT(item_port_id, NEXT_ENTRY(COMMON_UNSIGNED),
2605 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port_id, id)),
2609 .help = "match traffic against value set in previously matched rule",
2610 .priv = PRIV_ITEM(MARK, sizeof(struct rte_flow_item_mark)),
2611 .next = NEXT(item_mark),
2616 .help = "Integer value to match against",
2617 .next = NEXT(item_mark, NEXT_ENTRY(COMMON_UNSIGNED),
2619 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_mark, id)),
2623 .help = "match an arbitrary byte string",
2624 .priv = PRIV_ITEM(RAW, ITEM_RAW_SIZE),
2625 .next = NEXT(item_raw),
2628 [ITEM_RAW_RELATIVE] = {
2630 .help = "look for pattern after the previous item",
2631 .next = NEXT(item_raw, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
2632 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
2635 [ITEM_RAW_SEARCH] = {
2637 .help = "search pattern from offset (see also limit)",
2638 .next = NEXT(item_raw, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
2639 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
2642 [ITEM_RAW_OFFSET] = {
2644 .help = "absolute or relative offset for pattern",
2645 .next = NEXT(item_raw, NEXT_ENTRY(COMMON_INTEGER), item_param),
2646 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, offset)),
2648 [ITEM_RAW_LIMIT] = {
2650 .help = "search area limit for start of pattern",
2651 .next = NEXT(item_raw, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2652 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, limit)),
2654 [ITEM_RAW_PATTERN] = {
2656 .help = "byte string to look for",
2657 .next = NEXT(item_raw,
2658 NEXT_ENTRY(COMMON_STRING),
2659 NEXT_ENTRY(ITEM_PARAM_IS,
2662 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern),
2663 ARGS_ENTRY(struct rte_flow_item_raw, length),
2664 ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw),
2665 ITEM_RAW_PATTERN_SIZE)),
2669 .help = "match Ethernet header",
2670 .priv = PRIV_ITEM(ETH, sizeof(struct rte_flow_item_eth)),
2671 .next = NEXT(item_eth),
2676 .help = "destination MAC",
2677 .next = NEXT(item_eth, NEXT_ENTRY(COMMON_MAC_ADDR), item_param),
2678 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, dst)),
2682 .help = "source MAC",
2683 .next = NEXT(item_eth, NEXT_ENTRY(COMMON_MAC_ADDR), item_param),
2684 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, src)),
2688 .help = "EtherType",
2689 .next = NEXT(item_eth, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2690 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, type)),
2692 [ITEM_ETH_HAS_VLAN] = {
2694 .help = "packet header contains VLAN",
2695 .next = NEXT(item_eth, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2696 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_eth,
2701 .help = "match 802.1Q/ad VLAN tag",
2702 .priv = PRIV_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)),
2703 .next = NEXT(item_vlan),
2708 .help = "tag control information",
2709 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
2711 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, tci)),
2715 .help = "priority code point",
2716 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
2718 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2723 .help = "drop eligible indicator",
2724 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
2726 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2731 .help = "VLAN identifier",
2732 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
2734 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2737 [ITEM_VLAN_INNER_TYPE] = {
2738 .name = "inner_type",
2739 .help = "inner EtherType",
2740 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
2742 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan,
2745 [ITEM_VLAN_HAS_MORE_VLAN] = {
2746 .name = "has_more_vlan",
2747 .help = "packet header contains another VLAN",
2748 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
2750 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vlan,
2755 .help = "match IPv4 header",
2756 .priv = PRIV_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)),
2757 .next = NEXT(item_ipv4),
2760 [ITEM_IPV4_VER_IHL] = {
2761 .name = "version_ihl",
2762 .help = "match header length",
2763 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
2765 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ipv4,
2770 .help = "type of service",
2771 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
2773 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2774 hdr.type_of_service)),
2777 .name = "packet_id",
2778 .help = "fragment packet id",
2779 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
2781 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2784 [ITEM_IPV4_FRAGMENT_OFFSET] = {
2785 .name = "fragment_offset",
2786 .help = "fragmentation flags and fragment offset",
2787 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
2789 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2790 hdr.fragment_offset)),
2794 .help = "time to live",
2795 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
2797 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2800 [ITEM_IPV4_PROTO] = {
2802 .help = "next protocol ID",
2803 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
2805 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2806 hdr.next_proto_id)),
2810 .help = "source address",
2811 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
2813 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2818 .help = "destination address",
2819 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
2821 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2826 .help = "match IPv6 header",
2827 .priv = PRIV_ITEM(IPV6, sizeof(struct rte_flow_item_ipv6)),
2828 .next = NEXT(item_ipv6),
2833 .help = "traffic class",
2834 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
2836 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2838 "\x0f\xf0\x00\x00")),
2840 [ITEM_IPV6_FLOW] = {
2842 .help = "flow label",
2843 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
2845 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2847 "\x00\x0f\xff\xff")),
2849 [ITEM_IPV6_PROTO] = {
2851 .help = "protocol (next header)",
2852 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
2854 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2859 .help = "hop limit",
2860 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
2862 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2867 .help = "source address",
2868 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_IPV6_ADDR),
2870 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2875 .help = "destination address",
2876 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_IPV6_ADDR),
2878 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2881 [ITEM_IPV6_HAS_FRAG_EXT] = {
2882 .name = "has_frag_ext",
2883 .help = "fragment packet attribute",
2884 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
2886 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_ipv6,
2891 .help = "match ICMP header",
2892 .priv = PRIV_ITEM(ICMP, sizeof(struct rte_flow_item_icmp)),
2893 .next = NEXT(item_icmp),
2896 [ITEM_ICMP_TYPE] = {
2898 .help = "ICMP packet type",
2899 .next = NEXT(item_icmp, NEXT_ENTRY(COMMON_UNSIGNED),
2901 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2904 [ITEM_ICMP_CODE] = {
2906 .help = "ICMP packet code",
2907 .next = NEXT(item_icmp, NEXT_ENTRY(COMMON_UNSIGNED),
2909 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2912 [ITEM_ICMP_IDENT] = {
2914 .help = "ICMP packet identifier",
2915 .next = NEXT(item_icmp, NEXT_ENTRY(COMMON_UNSIGNED),
2917 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2922 .help = "ICMP packet sequence number",
2923 .next = NEXT(item_icmp, NEXT_ENTRY(COMMON_UNSIGNED),
2925 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2930 .help = "match UDP header",
2931 .priv = PRIV_ITEM(UDP, sizeof(struct rte_flow_item_udp)),
2932 .next = NEXT(item_udp),
2937 .help = "UDP source port",
2938 .next = NEXT(item_udp, NEXT_ENTRY(COMMON_UNSIGNED),
2940 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2945 .help = "UDP destination port",
2946 .next = NEXT(item_udp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2947 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2952 .help = "match TCP header",
2953 .priv = PRIV_ITEM(TCP, sizeof(struct rte_flow_item_tcp)),
2954 .next = NEXT(item_tcp),
2959 .help = "TCP source port",
2960 .next = NEXT(item_tcp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2961 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2966 .help = "TCP destination port",
2967 .next = NEXT(item_tcp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2968 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2971 [ITEM_TCP_FLAGS] = {
2973 .help = "TCP flags",
2974 .next = NEXT(item_tcp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2975 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2980 .help = "match SCTP header",
2981 .priv = PRIV_ITEM(SCTP, sizeof(struct rte_flow_item_sctp)),
2982 .next = NEXT(item_sctp),
2987 .help = "SCTP source port",
2988 .next = NEXT(item_sctp, NEXT_ENTRY(COMMON_UNSIGNED),
2990 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2995 .help = "SCTP destination port",
2996 .next = NEXT(item_sctp, NEXT_ENTRY(COMMON_UNSIGNED),
2998 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
3003 .help = "validation tag",
3004 .next = NEXT(item_sctp, NEXT_ENTRY(COMMON_UNSIGNED),
3006 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
3009 [ITEM_SCTP_CKSUM] = {
3012 .next = NEXT(item_sctp, NEXT_ENTRY(COMMON_UNSIGNED),
3014 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
3019 .help = "match VXLAN header",
3020 .priv = PRIV_ITEM(VXLAN, sizeof(struct rte_flow_item_vxlan)),
3021 .next = NEXT(item_vxlan),
3024 [ITEM_VXLAN_VNI] = {
3026 .help = "VXLAN identifier",
3027 .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
3029 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan, vni)),
3031 [ITEM_VXLAN_LAST_RSVD] = {
3032 .name = "last_rsvd",
3033 .help = "VXLAN last reserved bits",
3034 .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
3036 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan,
3041 .help = "match E-Tag header",
3042 .priv = PRIV_ITEM(E_TAG, sizeof(struct rte_flow_item_e_tag)),
3043 .next = NEXT(item_e_tag),
3046 [ITEM_E_TAG_GRP_ECID_B] = {
3047 .name = "grp_ecid_b",
3048 .help = "GRP and E-CID base",
3049 .next = NEXT(item_e_tag, NEXT_ENTRY(COMMON_UNSIGNED),
3051 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_e_tag,
3057 .help = "match NVGRE header",
3058 .priv = PRIV_ITEM(NVGRE, sizeof(struct rte_flow_item_nvgre)),
3059 .next = NEXT(item_nvgre),
3062 [ITEM_NVGRE_TNI] = {
3064 .help = "virtual subnet ID",
3065 .next = NEXT(item_nvgre, NEXT_ENTRY(COMMON_UNSIGNED),
3067 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_nvgre, tni)),
3071 .help = "match MPLS header",
3072 .priv = PRIV_ITEM(MPLS, sizeof(struct rte_flow_item_mpls)),
3073 .next = NEXT(item_mpls),
3076 [ITEM_MPLS_LABEL] = {
3078 .help = "MPLS label",
3079 .next = NEXT(item_mpls, NEXT_ENTRY(COMMON_UNSIGNED),
3081 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
3087 .help = "MPLS Traffic Class",
3088 .next = NEXT(item_mpls, NEXT_ENTRY(COMMON_UNSIGNED),
3090 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
3096 .help = "MPLS Bottom-of-Stack",
3097 .next = NEXT(item_mpls, NEXT_ENTRY(COMMON_UNSIGNED),
3099 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
3105 .help = "match GRE header",
3106 .priv = PRIV_ITEM(GRE, sizeof(struct rte_flow_item_gre)),
3107 .next = NEXT(item_gre),
3110 [ITEM_GRE_PROTO] = {
3112 .help = "GRE protocol type",
3113 .next = NEXT(item_gre, NEXT_ENTRY(COMMON_UNSIGNED),
3115 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
3118 [ITEM_GRE_C_RSVD0_VER] = {
3119 .name = "c_rsvd0_ver",
3121 "checksum (1b), undefined (1b), key bit (1b),"
3122 " sequence number (1b), reserved 0 (9b),"
3124 .next = NEXT(item_gre, NEXT_ENTRY(COMMON_UNSIGNED),
3126 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
3129 [ITEM_GRE_C_BIT] = {
3131 .help = "checksum bit (C)",
3132 .next = NEXT(item_gre, NEXT_ENTRY(COMMON_BOOLEAN),
3134 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
3136 "\x80\x00\x00\x00")),
3138 [ITEM_GRE_S_BIT] = {
3140 .help = "sequence number bit (S)",
3141 .next = NEXT(item_gre, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
3142 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
3144 "\x10\x00\x00\x00")),
3146 [ITEM_GRE_K_BIT] = {
3148 .help = "key bit (K)",
3149 .next = NEXT(item_gre, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
3150 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
3152 "\x20\x00\x00\x00")),
3156 .help = "fuzzy pattern match, expect faster than default",
3157 .priv = PRIV_ITEM(FUZZY,
3158 sizeof(struct rte_flow_item_fuzzy)),
3159 .next = NEXT(item_fuzzy),
3162 [ITEM_FUZZY_THRESH] = {
3164 .help = "match accuracy threshold",
3165 .next = NEXT(item_fuzzy, NEXT_ENTRY(COMMON_UNSIGNED),
3167 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_fuzzy,
3172 .help = "match GTP header",
3173 .priv = PRIV_ITEM(GTP, sizeof(struct rte_flow_item_gtp)),
3174 .next = NEXT(item_gtp),
3177 [ITEM_GTP_FLAGS] = {
3178 .name = "v_pt_rsv_flags",
3179 .help = "GTP flags",
3180 .next = NEXT(item_gtp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3181 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp,
3184 [ITEM_GTP_MSG_TYPE] = {
3186 .help = "GTP message type",
3187 .next = NEXT(item_gtp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3188 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp, msg_type)),
3192 .help = "tunnel endpoint identifier",
3193 .next = NEXT(item_gtp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3194 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp, teid)),
3198 .help = "match GTP header",
3199 .priv = PRIV_ITEM(GTPC, sizeof(struct rte_flow_item_gtp)),
3200 .next = NEXT(item_gtp),
3205 .help = "match GTP header",
3206 .priv = PRIV_ITEM(GTPU, sizeof(struct rte_flow_item_gtp)),
3207 .next = NEXT(item_gtp),
3212 .help = "match GENEVE header",
3213 .priv = PRIV_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)),
3214 .next = NEXT(item_geneve),
3217 [ITEM_GENEVE_VNI] = {
3219 .help = "virtual network identifier",
3220 .next = NEXT(item_geneve, NEXT_ENTRY(COMMON_UNSIGNED),
3222 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve, vni)),
3224 [ITEM_GENEVE_PROTO] = {
3226 .help = "GENEVE protocol type",
3227 .next = NEXT(item_geneve, NEXT_ENTRY(COMMON_UNSIGNED),
3229 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve,
3232 [ITEM_GENEVE_OPTLEN] = {
3234 .help = "GENEVE options length in dwords",
3235 .next = NEXT(item_geneve, NEXT_ENTRY(COMMON_UNSIGNED),
3237 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_geneve,
3238 ver_opt_len_o_c_rsvd0,
3241 [ITEM_VXLAN_GPE] = {
3242 .name = "vxlan-gpe",
3243 .help = "match VXLAN-GPE header",
3244 .priv = PRIV_ITEM(VXLAN_GPE,
3245 sizeof(struct rte_flow_item_vxlan_gpe)),
3246 .next = NEXT(item_vxlan_gpe),
3249 [ITEM_VXLAN_GPE_VNI] = {
3251 .help = "VXLAN-GPE identifier",
3252 .next = NEXT(item_vxlan_gpe, NEXT_ENTRY(COMMON_UNSIGNED),
3254 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
3257 [ITEM_ARP_ETH_IPV4] = {
3258 .name = "arp_eth_ipv4",
3259 .help = "match ARP header for Ethernet/IPv4",
3260 .priv = PRIV_ITEM(ARP_ETH_IPV4,
3261 sizeof(struct rte_flow_item_arp_eth_ipv4)),
3262 .next = NEXT(item_arp_eth_ipv4),
3265 [ITEM_ARP_ETH_IPV4_SHA] = {
3267 .help = "sender hardware address",
3268 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_MAC_ADDR),
3270 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
3273 [ITEM_ARP_ETH_IPV4_SPA] = {
3275 .help = "sender IPv4 address",
3276 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
3278 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
3281 [ITEM_ARP_ETH_IPV4_THA] = {
3283 .help = "target hardware address",
3284 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_MAC_ADDR),
3286 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
3289 [ITEM_ARP_ETH_IPV4_TPA] = {
3291 .help = "target IPv4 address",
3292 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
3294 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
3299 .help = "match presence of any IPv6 extension header",
3300 .priv = PRIV_ITEM(IPV6_EXT,
3301 sizeof(struct rte_flow_item_ipv6_ext)),
3302 .next = NEXT(item_ipv6_ext),
3305 [ITEM_IPV6_EXT_NEXT_HDR] = {
3307 .help = "next header",
3308 .next = NEXT(item_ipv6_ext, NEXT_ENTRY(COMMON_UNSIGNED),
3310 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_ext,
3313 [ITEM_IPV6_FRAG_EXT] = {
3314 .name = "ipv6_frag_ext",
3315 .help = "match presence of IPv6 fragment extension header",
3316 .priv = PRIV_ITEM(IPV6_FRAG_EXT,
3317 sizeof(struct rte_flow_item_ipv6_frag_ext)),
3318 .next = NEXT(item_ipv6_frag_ext),
3321 [ITEM_IPV6_FRAG_EXT_NEXT_HDR] = {
3323 .help = "next header",
3324 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(COMMON_UNSIGNED),
3326 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ipv6_frag_ext,
3329 [ITEM_IPV6_FRAG_EXT_FRAG_DATA] = {
3330 .name = "frag_data",
3331 .help = "fragment flags and offset",
3332 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(COMMON_UNSIGNED),
3334 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_frag_ext,
3337 [ITEM_IPV6_FRAG_EXT_ID] = {
3338 .name = "packet_id",
3339 .help = "fragment packet id",
3340 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(COMMON_UNSIGNED),
3342 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_frag_ext,
3347 .help = "match any ICMPv6 header",
3348 .priv = PRIV_ITEM(ICMP6, sizeof(struct rte_flow_item_icmp6)),
3349 .next = NEXT(item_icmp6),
3352 [ITEM_ICMP6_TYPE] = {
3354 .help = "ICMPv6 type",
3355 .next = NEXT(item_icmp6, NEXT_ENTRY(COMMON_UNSIGNED),
3357 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
3360 [ITEM_ICMP6_CODE] = {
3362 .help = "ICMPv6 code",
3363 .next = NEXT(item_icmp6, NEXT_ENTRY(COMMON_UNSIGNED),
3365 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
3368 [ITEM_ICMP6_ND_NS] = {
3369 .name = "icmp6_nd_ns",
3370 .help = "match ICMPv6 neighbor discovery solicitation",
3371 .priv = PRIV_ITEM(ICMP6_ND_NS,
3372 sizeof(struct rte_flow_item_icmp6_nd_ns)),
3373 .next = NEXT(item_icmp6_nd_ns),
3376 [ITEM_ICMP6_ND_NS_TARGET_ADDR] = {
3377 .name = "target_addr",
3378 .help = "target address",
3379 .next = NEXT(item_icmp6_nd_ns, NEXT_ENTRY(COMMON_IPV6_ADDR),
3381 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_ns,
3384 [ITEM_ICMP6_ND_NA] = {
3385 .name = "icmp6_nd_na",
3386 .help = "match ICMPv6 neighbor discovery advertisement",
3387 .priv = PRIV_ITEM(ICMP6_ND_NA,
3388 sizeof(struct rte_flow_item_icmp6_nd_na)),
3389 .next = NEXT(item_icmp6_nd_na),
3392 [ITEM_ICMP6_ND_NA_TARGET_ADDR] = {
3393 .name = "target_addr",
3394 .help = "target address",
3395 .next = NEXT(item_icmp6_nd_na, NEXT_ENTRY(COMMON_IPV6_ADDR),
3397 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_na,
3400 [ITEM_ICMP6_ND_OPT] = {
3401 .name = "icmp6_nd_opt",
3402 .help = "match presence of any ICMPv6 neighbor discovery"
3404 .priv = PRIV_ITEM(ICMP6_ND_OPT,
3405 sizeof(struct rte_flow_item_icmp6_nd_opt)),
3406 .next = NEXT(item_icmp6_nd_opt),
3409 [ITEM_ICMP6_ND_OPT_TYPE] = {
3411 .help = "ND option type",
3412 .next = NEXT(item_icmp6_nd_opt, NEXT_ENTRY(COMMON_UNSIGNED),
3414 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_opt,
3417 [ITEM_ICMP6_ND_OPT_SLA_ETH] = {
3418 .name = "icmp6_nd_opt_sla_eth",
3419 .help = "match ICMPv6 neighbor discovery source Ethernet"
3420 " link-layer address option",
3422 (ICMP6_ND_OPT_SLA_ETH,
3423 sizeof(struct rte_flow_item_icmp6_nd_opt_sla_eth)),
3424 .next = NEXT(item_icmp6_nd_opt_sla_eth),
3427 [ITEM_ICMP6_ND_OPT_SLA_ETH_SLA] = {
3429 .help = "source Ethernet LLA",
3430 .next = NEXT(item_icmp6_nd_opt_sla_eth,
3431 NEXT_ENTRY(COMMON_MAC_ADDR), item_param),
3432 .args = ARGS(ARGS_ENTRY_HTON
3433 (struct rte_flow_item_icmp6_nd_opt_sla_eth, sla)),
3435 [ITEM_ICMP6_ND_OPT_TLA_ETH] = {
3436 .name = "icmp6_nd_opt_tla_eth",
3437 .help = "match ICMPv6 neighbor discovery target Ethernet"
3438 " link-layer address option",
3440 (ICMP6_ND_OPT_TLA_ETH,
3441 sizeof(struct rte_flow_item_icmp6_nd_opt_tla_eth)),
3442 .next = NEXT(item_icmp6_nd_opt_tla_eth),
3445 [ITEM_ICMP6_ND_OPT_TLA_ETH_TLA] = {
3447 .help = "target Ethernet LLA",
3448 .next = NEXT(item_icmp6_nd_opt_tla_eth,
3449 NEXT_ENTRY(COMMON_MAC_ADDR), item_param),
3450 .args = ARGS(ARGS_ENTRY_HTON
3451 (struct rte_flow_item_icmp6_nd_opt_tla_eth, tla)),
3455 .help = "match metadata header",
3456 .priv = PRIV_ITEM(META, sizeof(struct rte_flow_item_meta)),
3457 .next = NEXT(item_meta),
3460 [ITEM_META_DATA] = {
3462 .help = "metadata value",
3463 .next = NEXT(item_meta, NEXT_ENTRY(COMMON_UNSIGNED),
3465 .args = ARGS(ARGS_ENTRY_MASK(struct rte_flow_item_meta,
3466 data, "\xff\xff\xff\xff")),
3470 .help = "match GRE key",
3471 .priv = PRIV_ITEM(GRE_KEY, sizeof(rte_be32_t)),
3472 .next = NEXT(item_gre_key),
3475 [ITEM_GRE_KEY_VALUE] = {
3477 .help = "key value",
3478 .next = NEXT(item_gre_key, NEXT_ENTRY(COMMON_UNSIGNED),
3480 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3484 .help = "match GTP extension header with type 0x85",
3485 .priv = PRIV_ITEM(GTP_PSC,
3486 sizeof(struct rte_flow_item_gtp_psc)),
3487 .next = NEXT(item_gtp_psc),
3490 [ITEM_GTP_PSC_QFI] = {
3492 .help = "QoS flow identifier",
3493 .next = NEXT(item_gtp_psc, NEXT_ENTRY(COMMON_UNSIGNED),
3495 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_gtp_psc,
3498 [ITEM_GTP_PSC_PDU_T] = {
3501 .next = NEXT(item_gtp_psc, NEXT_ENTRY(COMMON_UNSIGNED),
3503 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_gtp_psc,
3508 .help = "match PPPoE session header",
3509 .priv = PRIV_ITEM(PPPOES, sizeof(struct rte_flow_item_pppoe)),
3510 .next = NEXT(item_pppoes),
3515 .help = "match PPPoE discovery header",
3516 .priv = PRIV_ITEM(PPPOED, sizeof(struct rte_flow_item_pppoe)),
3517 .next = NEXT(item_pppoed),
3520 [ITEM_PPPOE_SEID] = {
3522 .help = "session identifier",
3523 .next = NEXT(item_pppoes, NEXT_ENTRY(COMMON_UNSIGNED),
3525 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pppoe,
3528 [ITEM_PPPOE_PROTO_ID] = {
3529 .name = "pppoe_proto_id",
3530 .help = "match PPPoE session protocol identifier",
3531 .priv = PRIV_ITEM(PPPOE_PROTO_ID,
3532 sizeof(struct rte_flow_item_pppoe_proto_id)),
3533 .next = NEXT(item_pppoe_proto_id, NEXT_ENTRY(COMMON_UNSIGNED),
3535 .args = ARGS(ARGS_ENTRY_HTON
3536 (struct rte_flow_item_pppoe_proto_id, proto_id)),
3541 .help = "matches higig2 header",
3542 .priv = PRIV_ITEM(HIGIG2,
3543 sizeof(struct rte_flow_item_higig2_hdr)),
3544 .next = NEXT(item_higig2),
3547 [ITEM_HIGIG2_CLASSIFICATION] = {
3548 .name = "classification",
3549 .help = "matches classification of higig2 header",
3550 .next = NEXT(item_higig2, NEXT_ENTRY(COMMON_UNSIGNED),
3552 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
3553 hdr.ppt1.classification)),
3555 [ITEM_HIGIG2_VID] = {
3557 .help = "matches vid of higig2 header",
3558 .next = NEXT(item_higig2, NEXT_ENTRY(COMMON_UNSIGNED),
3560 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
3565 .help = "match tag value",
3566 .priv = PRIV_ITEM(TAG, sizeof(struct rte_flow_item_tag)),
3567 .next = NEXT(item_tag),
3572 .help = "tag value to match",
3573 .next = NEXT(item_tag, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3574 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, data)),
3576 [ITEM_TAG_INDEX] = {
3578 .help = "index of tag array to match",
3579 .next = NEXT(item_tag, NEXT_ENTRY(COMMON_UNSIGNED),
3580 NEXT_ENTRY(ITEM_PARAM_IS)),
3581 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, index)),
3583 [ITEM_L2TPV3OIP] = {
3584 .name = "l2tpv3oip",
3585 .help = "match L2TPv3 over IP header",
3586 .priv = PRIV_ITEM(L2TPV3OIP,
3587 sizeof(struct rte_flow_item_l2tpv3oip)),
3588 .next = NEXT(item_l2tpv3oip),
3591 [ITEM_L2TPV3OIP_SESSION_ID] = {
3592 .name = "session_id",
3593 .help = "session identifier",
3594 .next = NEXT(item_l2tpv3oip, NEXT_ENTRY(COMMON_UNSIGNED),
3596 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv3oip,
3601 .help = "match ESP header",
3602 .priv = PRIV_ITEM(ESP, sizeof(struct rte_flow_item_esp)),
3603 .next = NEXT(item_esp),
3608 .help = "security policy index",
3609 .next = NEXT(item_esp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3610 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_esp,
3615 .help = "match AH header",
3616 .priv = PRIV_ITEM(AH, sizeof(struct rte_flow_item_ah)),
3617 .next = NEXT(item_ah),
3622 .help = "security parameters index",
3623 .next = NEXT(item_ah, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3624 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ah, spi)),
3628 .help = "match pfcp header",
3629 .priv = PRIV_ITEM(PFCP, sizeof(struct rte_flow_item_pfcp)),
3630 .next = NEXT(item_pfcp),
3633 [ITEM_PFCP_S_FIELD] = {
3636 .next = NEXT(item_pfcp, NEXT_ENTRY(COMMON_UNSIGNED),
3638 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp,
3641 [ITEM_PFCP_SEID] = {
3643 .help = "session endpoint identifier",
3644 .next = NEXT(item_pfcp, NEXT_ENTRY(COMMON_UNSIGNED),
3646 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp, seid)),
3650 .help = "match eCPRI header",
3651 .priv = PRIV_ITEM(ECPRI, sizeof(struct rte_flow_item_ecpri)),
3652 .next = NEXT(item_ecpri),
3655 [ITEM_ECPRI_COMMON] = {
3657 .help = "eCPRI common header",
3658 .next = NEXT(item_ecpri_common),
3660 [ITEM_ECPRI_COMMON_TYPE] = {
3662 .help = "type of common header",
3663 .next = NEXT(item_ecpri_common_type),
3664 .args = ARGS(ARG_ENTRY_HTON(struct rte_flow_item_ecpri)),
3666 [ITEM_ECPRI_COMMON_TYPE_IQ_DATA] = {
3668 .help = "Type #0: IQ Data",
3669 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
3671 .call = parse_vc_item_ecpri_type,
3673 [ITEM_ECPRI_MSG_IQ_DATA_PCID] = {
3675 .help = "Physical Channel ID",
3676 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
3677 ITEM_ECPRI_COMMON, ITEM_NEXT),
3678 NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3679 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3682 [ITEM_ECPRI_COMMON_TYPE_RTC_CTRL] = {
3684 .help = "Type #2: Real-Time Control Data",
3685 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
3687 .call = parse_vc_item_ecpri_type,
3689 [ITEM_ECPRI_MSG_RTC_CTRL_RTCID] = {
3691 .help = "Real-Time Control Data ID",
3692 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
3693 ITEM_ECPRI_COMMON, ITEM_NEXT),
3694 NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3695 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3698 [ITEM_ECPRI_COMMON_TYPE_DLY_MSR] = {
3699 .name = "delay_measure",
3700 .help = "Type #5: One-Way Delay Measurement",
3701 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
3703 .call = parse_vc_item_ecpri_type,
3705 [ITEM_ECPRI_MSG_DLY_MSR_MSRID] = {
3707 .help = "Measurement ID",
3708 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
3709 ITEM_ECPRI_COMMON, ITEM_NEXT),
3710 NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3711 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3714 [ITEM_GENEVE_OPT] = {
3715 .name = "geneve-opt",
3716 .help = "GENEVE header option",
3717 .priv = PRIV_ITEM(GENEVE_OPT,
3718 sizeof(struct rte_flow_item_geneve_opt) +
3719 ITEM_GENEVE_OPT_DATA_SIZE),
3720 .next = NEXT(item_geneve_opt),
3723 [ITEM_GENEVE_OPT_CLASS] = {
3725 .help = "GENEVE option class",
3726 .next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_UNSIGNED),
3728 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve_opt,
3731 [ITEM_GENEVE_OPT_TYPE] = {
3733 .help = "GENEVE option type",
3734 .next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_UNSIGNED),
3736 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt,
3739 [ITEM_GENEVE_OPT_LENGTH] = {
3741 .help = "GENEVE option data length (in 32b words)",
3742 .next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_UNSIGNED),
3744 .args = ARGS(ARGS_ENTRY_BOUNDED(
3745 struct rte_flow_item_geneve_opt, option_len,
3748 [ITEM_GENEVE_OPT_DATA] = {
3750 .help = "GENEVE option data pattern",
3751 .next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_HEX),
3753 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt, data),
3754 ARGS_ENTRY_ARB(0, 0),
3756 (sizeof(struct rte_flow_item_geneve_opt),
3757 ITEM_GENEVE_OPT_DATA_SIZE)),
3759 [ITEM_INTEGRITY] = {
3760 .name = "integrity",
3761 .help = "match packet integrity",
3762 .priv = PRIV_ITEM(INTEGRITY,
3763 sizeof(struct rte_flow_item_integrity)),
3764 .next = NEXT(item_integrity),
3767 [ITEM_INTEGRITY_LEVEL] = {
3769 .help = "integrity level",
3770 .next = NEXT(item_integrity_lv, NEXT_ENTRY(COMMON_UNSIGNED),
3772 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_integrity, level)),
3774 [ITEM_INTEGRITY_VALUE] = {
3776 .help = "integrity value",
3777 .next = NEXT(item_integrity_lv, NEXT_ENTRY(COMMON_UNSIGNED),
3779 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_integrity, value)),
3781 [ITEM_CONNTRACK] = {
3782 .name = "conntrack",
3783 .help = "conntrack state",
3784 .next = NEXT(NEXT_ENTRY(ITEM_NEXT), NEXT_ENTRY(COMMON_UNSIGNED),
3786 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_conntrack, flags)),
3788 [ITEM_PORT_REPRESENTOR] = {
3789 .name = "port_representor",
3790 .help = "match traffic entering the embedded switch from the given ethdev",
3791 .priv = PRIV_ITEM(PORT_REPRESENTOR,
3792 sizeof(struct rte_flow_item_ethdev)),
3793 .next = NEXT(item_port_representor),
3796 [ITEM_PORT_REPRESENTOR_PORT_ID] = {
3798 .help = "ethdev port ID",
3799 .next = NEXT(item_port_representor, NEXT_ENTRY(COMMON_UNSIGNED),
3801 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ethdev, port_id)),
3803 [ITEM_REPRESENTED_PORT] = {
3804 .name = "represented_port",
3805 .help = "match traffic entering the embedded switch from the entity represented by the given ethdev",
3806 .priv = PRIV_ITEM(REPRESENTED_PORT,
3807 sizeof(struct rte_flow_item_ethdev)),
3808 .next = NEXT(item_represented_port),
3811 [ITEM_REPRESENTED_PORT_ETHDEV_PORT_ID] = {
3812 .name = "ethdev_port_id",
3813 .help = "ethdev port ID",
3814 .next = NEXT(item_represented_port, NEXT_ENTRY(COMMON_UNSIGNED),
3816 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ethdev, port_id)),
3820 .help = "match flex header",
3821 .priv = PRIV_ITEM(FLEX, sizeof(struct rte_flow_item_flex)),
3822 .next = NEXT(item_flex),
3825 [ITEM_FLEX_ITEM_HANDLE] = {
3827 .help = "flex item handle",
3828 .next = NEXT(item_flex, NEXT_ENTRY(COMMON_FLEX_HANDLE),
3829 NEXT_ENTRY(ITEM_PARAM_IS)),
3830 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_flex, handle)),
3832 [ITEM_FLEX_PATTERN_HANDLE] = {
3834 .help = "flex pattern handle",
3835 .next = NEXT(item_flex, NEXT_ENTRY(COMMON_FLEX_HANDLE),
3836 NEXT_ENTRY(ITEM_PARAM_IS)),
3837 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_flex, pattern)),
3841 .help = "match L2TPv2 header",
3842 .priv = PRIV_ITEM(L2TPV2, sizeof(struct rte_flow_item_l2tpv2)),
3843 .next = NEXT(item_l2tpv2),
3846 [ITEM_L2TPV2_COMMON] = {
3848 .help = "L2TPv2 common header",
3849 .next = NEXT(item_l2tpv2_common),
3851 [ITEM_L2TPV2_COMMON_TYPE] = {
3853 .help = "type of common header",
3854 .next = NEXT(item_l2tpv2_common_type),
3855 .args = ARGS(ARG_ENTRY_HTON(struct rte_flow_item_l2tpv2)),
3857 [ITEM_L2TPV2_COMMON_TYPE_DATA_L] = {
3859 .help = "Type #6: data message with length option",
3860 .next = NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_DATA_L_LENGTH,
3861 ITEM_L2TPV2_MSG_DATA_L_TUNNEL_ID,
3862 ITEM_L2TPV2_MSG_DATA_L_SESSION_ID,
3864 .call = parse_vc_item_l2tpv2_type,
3866 [ITEM_L2TPV2_MSG_DATA_L_LENGTH] = {
3868 .help = "message length",
3869 .next = NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_DATA_L_LENGTH,
3870 ITEM_L2TPV2_COMMON, ITEM_NEXT),
3871 NEXT_ENTRY(COMMON_UNSIGNED),
3873 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
3876 [ITEM_L2TPV2_MSG_DATA_L_TUNNEL_ID] = {
3877 .name = "tunnel_id",
3878 .help = "tunnel identifier",
3879 .next = NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_DATA_L_TUNNEL_ID,
3880 ITEM_L2TPV2_COMMON, ITEM_NEXT),
3881 NEXT_ENTRY(COMMON_UNSIGNED),
3883 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
3884 hdr.type6.tunnel_id)),
3886 [ITEM_L2TPV2_MSG_DATA_L_SESSION_ID] = {
3887 .name = "session_id",
3888 .help = "session identifier",
3889 .next = NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_DATA_L_SESSION_ID,
3890 ITEM_L2TPV2_COMMON, ITEM_NEXT),
3891 NEXT_ENTRY(COMMON_UNSIGNED),
3893 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
3894 hdr.type6.session_id)),
3896 [ITEM_L2TPV2_COMMON_TYPE_CTRL] = {
3898 .help = "Type #3: conrtol message contains length, ns, nr options",
3899 .next = NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_CTRL_LENGTH,
3900 ITEM_L2TPV2_MSG_CTRL_TUNNEL_ID,
3901 ITEM_L2TPV2_MSG_CTRL_SESSION_ID,
3902 ITEM_L2TPV2_MSG_CTRL_NS,
3903 ITEM_L2TPV2_MSG_CTRL_NR,
3905 .call = parse_vc_item_l2tpv2_type,
3907 [ITEM_L2TPV2_MSG_CTRL_LENGTH] = {
3909 .help = "message length",
3910 .next = NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_CTRL_LENGTH,
3911 ITEM_L2TPV2_COMMON, ITEM_NEXT),
3912 NEXT_ENTRY(COMMON_UNSIGNED),
3914 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
3917 [ITEM_L2TPV2_MSG_CTRL_TUNNEL_ID] = {
3918 .name = "tunnel_id",
3919 .help = "tunnel identifier",
3920 .next = NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_CTRL_TUNNEL_ID,
3921 ITEM_L2TPV2_COMMON, ITEM_NEXT),
3922 NEXT_ENTRY(COMMON_UNSIGNED),
3924 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
3925 hdr.type3.tunnel_id)),
3927 [ITEM_L2TPV2_MSG_CTRL_SESSION_ID] = {
3928 .name = "session_id",
3929 .help = "session identifier",
3930 .next = NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_CTRL_SESSION_ID,
3931 ITEM_L2TPV2_COMMON, ITEM_NEXT),
3932 NEXT_ENTRY(COMMON_UNSIGNED),
3934 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
3935 hdr.type3.session_id)),
3937 [ITEM_L2TPV2_MSG_CTRL_NS] = {
3939 .help = "sequence number for message",
3940 .next = NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_CTRL_NS,
3941 ITEM_L2TPV2_COMMON, ITEM_NEXT),
3942 NEXT_ENTRY(COMMON_UNSIGNED),
3944 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
3947 [ITEM_L2TPV2_MSG_CTRL_NR] = {
3949 .help = "sequence number for next receive message",
3950 .next = NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_CTRL_NS,
3951 ITEM_L2TPV2_COMMON, ITEM_NEXT),
3952 NEXT_ENTRY(COMMON_UNSIGNED),
3954 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
3959 .help = "match PPP header",
3960 .priv = PRIV_ITEM(PPP, sizeof(struct rte_flow_item_ppp)),
3961 .next = NEXT(item_ppp),
3966 .help = "PPP address",
3967 .next = NEXT(item_ppp, NEXT_ENTRY(COMMON_UNSIGNED),
3969 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ppp, hdr.addr)),
3973 .help = "PPP control",
3974 .next = NEXT(item_ppp, NEXT_ENTRY(COMMON_UNSIGNED),
3976 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ppp, hdr.ctrl)),
3978 [ITEM_PPP_PROTO_ID] = {
3980 .help = "PPP protocol identifier",
3981 .next = NEXT(item_ppp, NEXT_ENTRY(COMMON_UNSIGNED),
3983 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ppp,
3986 /* Validate/create actions. */
3989 .help = "submit a list of associated actions",
3990 .next = NEXT(next_action),
3995 .help = "specify next action",
3996 .next = NEXT(next_action),
4000 .help = "end list of actions",
4001 .priv = PRIV_ACTION(END, 0),
4006 .help = "no-op action",
4007 .priv = PRIV_ACTION(VOID, 0),
4008 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4011 [ACTION_PASSTHRU] = {
4013 .help = "let subsequent rule process matched packets",
4014 .priv = PRIV_ACTION(PASSTHRU, 0),
4015 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4020 .help = "redirect traffic to a given group",
4021 .priv = PRIV_ACTION(JUMP, sizeof(struct rte_flow_action_jump)),
4022 .next = NEXT(action_jump),
4025 [ACTION_JUMP_GROUP] = {
4027 .help = "group to redirect traffic to",
4028 .next = NEXT(action_jump, NEXT_ENTRY(COMMON_UNSIGNED)),
4029 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump, group)),
4030 .call = parse_vc_conf,
4034 .help = "attach 32 bit value to packets",
4035 .priv = PRIV_ACTION(MARK, sizeof(struct rte_flow_action_mark)),
4036 .next = NEXT(action_mark),
4039 [ACTION_MARK_ID] = {
4041 .help = "32 bit value to return with packets",
4042 .next = NEXT(action_mark, NEXT_ENTRY(COMMON_UNSIGNED)),
4043 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_mark, id)),
4044 .call = parse_vc_conf,
4048 .help = "flag packets",
4049 .priv = PRIV_ACTION(FLAG, 0),
4050 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4055 .help = "assign packets to a given queue index",
4056 .priv = PRIV_ACTION(QUEUE,
4057 sizeof(struct rte_flow_action_queue)),
4058 .next = NEXT(action_queue),
4061 [ACTION_QUEUE_INDEX] = {
4063 .help = "queue index to use",
4064 .next = NEXT(action_queue, NEXT_ENTRY(COMMON_UNSIGNED)),
4065 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_queue, index)),
4066 .call = parse_vc_conf,
4070 .help = "drop packets (note: passthru has priority)",
4071 .priv = PRIV_ACTION(DROP, 0),
4072 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4077 .help = "enable counters for this rule",
4078 .priv = PRIV_ACTION(COUNT,
4079 sizeof(struct rte_flow_action_count)),
4080 .next = NEXT(action_count),
4083 [ACTION_COUNT_ID] = {
4084 .name = "identifier",
4085 .help = "counter identifier to use",
4086 .next = NEXT(action_count, NEXT_ENTRY(COMMON_UNSIGNED)),
4087 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_count, id)),
4088 .call = parse_vc_conf,
4092 .help = "spread packets among several queues",
4093 .priv = PRIV_ACTION(RSS, sizeof(struct action_rss_data)),
4094 .next = NEXT(action_rss),
4095 .call = parse_vc_action_rss,
4097 [ACTION_RSS_FUNC] = {
4099 .help = "RSS hash function to apply",
4100 .next = NEXT(action_rss,
4101 NEXT_ENTRY(ACTION_RSS_FUNC_DEFAULT,
4102 ACTION_RSS_FUNC_TOEPLITZ,
4103 ACTION_RSS_FUNC_SIMPLE_XOR,
4104 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ)),
4106 [ACTION_RSS_FUNC_DEFAULT] = {
4108 .help = "default hash function",
4109 .call = parse_vc_action_rss_func,
4111 [ACTION_RSS_FUNC_TOEPLITZ] = {
4113 .help = "Toeplitz hash function",
4114 .call = parse_vc_action_rss_func,
4116 [ACTION_RSS_FUNC_SIMPLE_XOR] = {
4117 .name = "simple_xor",
4118 .help = "simple XOR hash function",
4119 .call = parse_vc_action_rss_func,
4121 [ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ] = {
4122 .name = "symmetric_toeplitz",
4123 .help = "Symmetric Toeplitz hash function",
4124 .call = parse_vc_action_rss_func,
4126 [ACTION_RSS_LEVEL] = {
4128 .help = "encapsulation level for \"types\"",
4129 .next = NEXT(action_rss, NEXT_ENTRY(COMMON_UNSIGNED)),
4130 .args = ARGS(ARGS_ENTRY_ARB
4131 (offsetof(struct action_rss_data, conf) +
4132 offsetof(struct rte_flow_action_rss, level),
4133 sizeof(((struct rte_flow_action_rss *)0)->
4136 [ACTION_RSS_TYPES] = {
4138 .help = "specific RSS hash types",
4139 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)),
4141 [ACTION_RSS_TYPE] = {
4143 .help = "RSS hash type",
4144 .call = parse_vc_action_rss_type,
4145 .comp = comp_vc_action_rss_type,
4147 [ACTION_RSS_KEY] = {
4149 .help = "RSS hash key",
4150 .next = NEXT(action_rss, NEXT_ENTRY(COMMON_HEX)),
4151 .args = ARGS(ARGS_ENTRY_ARB
4152 (offsetof(struct action_rss_data, conf) +
4153 offsetof(struct rte_flow_action_rss, key),
4154 sizeof(((struct rte_flow_action_rss *)0)->key)),
4156 (offsetof(struct action_rss_data, conf) +
4157 offsetof(struct rte_flow_action_rss, key_len),
4158 sizeof(((struct rte_flow_action_rss *)0)->
4160 ARGS_ENTRY(struct action_rss_data, key)),
4162 [ACTION_RSS_KEY_LEN] = {
4164 .help = "RSS hash key length in bytes",
4165 .next = NEXT(action_rss, NEXT_ENTRY(COMMON_UNSIGNED)),
4166 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4167 (offsetof(struct action_rss_data, conf) +
4168 offsetof(struct rte_flow_action_rss, key_len),
4169 sizeof(((struct rte_flow_action_rss *)0)->
4172 RSS_HASH_KEY_LENGTH)),
4174 [ACTION_RSS_QUEUES] = {
4176 .help = "queue indices to use",
4177 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_QUEUE)),
4178 .call = parse_vc_conf,
4180 [ACTION_RSS_QUEUE] = {
4182 .help = "queue index",
4183 .call = parse_vc_action_rss_queue,
4184 .comp = comp_vc_action_rss_queue,
4188 .help = "direct traffic to physical function",
4189 .priv = PRIV_ACTION(PF, 0),
4190 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4195 .help = "direct traffic to a virtual function ID",
4196 .priv = PRIV_ACTION(VF, sizeof(struct rte_flow_action_vf)),
4197 .next = NEXT(action_vf),
4200 [ACTION_VF_ORIGINAL] = {
4202 .help = "use original VF ID if possible",
4203 .next = NEXT(action_vf, NEXT_ENTRY(COMMON_BOOLEAN)),
4204 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_vf,
4206 .call = parse_vc_conf,
4211 .next = NEXT(action_vf, NEXT_ENTRY(COMMON_UNSIGNED)),
4212 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)),
4213 .call = parse_vc_conf,
4215 [ACTION_PHY_PORT] = {
4217 .help = "direct packets to physical port index",
4218 .priv = PRIV_ACTION(PHY_PORT,
4219 sizeof(struct rte_flow_action_phy_port)),
4220 .next = NEXT(action_phy_port),
4223 [ACTION_PHY_PORT_ORIGINAL] = {
4225 .help = "use original port index if possible",
4226 .next = NEXT(action_phy_port, NEXT_ENTRY(COMMON_BOOLEAN)),
4227 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_phy_port,
4229 .call = parse_vc_conf,
4231 [ACTION_PHY_PORT_INDEX] = {
4233 .help = "physical port index",
4234 .next = NEXT(action_phy_port, NEXT_ENTRY(COMMON_UNSIGNED)),
4235 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_phy_port,
4237 .call = parse_vc_conf,
4239 [ACTION_PORT_ID] = {
4241 .help = "direct matching traffic to a given DPDK port ID",
4242 .priv = PRIV_ACTION(PORT_ID,
4243 sizeof(struct rte_flow_action_port_id)),
4244 .next = NEXT(action_port_id),
4247 [ACTION_PORT_ID_ORIGINAL] = {
4249 .help = "use original DPDK port ID if possible",
4250 .next = NEXT(action_port_id, NEXT_ENTRY(COMMON_BOOLEAN)),
4251 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_port_id,
4253 .call = parse_vc_conf,
4255 [ACTION_PORT_ID_ID] = {
4257 .help = "DPDK port ID",
4258 .next = NEXT(action_port_id, NEXT_ENTRY(COMMON_UNSIGNED)),
4259 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_port_id, id)),
4260 .call = parse_vc_conf,
4264 .help = "meter the directed packets at given id",
4265 .priv = PRIV_ACTION(METER,
4266 sizeof(struct rte_flow_action_meter)),
4267 .next = NEXT(action_meter),
4270 [ACTION_METER_COLOR] = {
4272 .help = "meter color for the packets",
4273 .priv = PRIV_ACTION(METER_COLOR,
4274 sizeof(struct rte_flow_action_meter_color)),
4275 .next = NEXT(action_meter_color),
4278 [ACTION_METER_COLOR_TYPE] = {
4280 .help = "specific meter color",
4281 .next = NEXT(NEXT_ENTRY(ACTION_NEXT),
4282 NEXT_ENTRY(ACTION_METER_COLOR_GREEN,
4283 ACTION_METER_COLOR_YELLOW,
4284 ACTION_METER_COLOR_RED)),
4286 [ACTION_METER_COLOR_GREEN] = {
4288 .help = "meter color green",
4289 .call = parse_vc_action_meter_color_type,
4291 [ACTION_METER_COLOR_YELLOW] = {
4293 .help = "meter color yellow",
4294 .call = parse_vc_action_meter_color_type,
4296 [ACTION_METER_COLOR_RED] = {
4298 .help = "meter color red",
4299 .call = parse_vc_action_meter_color_type,
4301 [ACTION_METER_ID] = {
4303 .help = "meter id to use",
4304 .next = NEXT(action_meter, NEXT_ENTRY(COMMON_UNSIGNED)),
4305 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter, mtr_id)),
4306 .call = parse_vc_conf,
4308 [ACTION_OF_SET_MPLS_TTL] = {
4309 .name = "of_set_mpls_ttl",
4310 .help = "OpenFlow's OFPAT_SET_MPLS_TTL",
4313 sizeof(struct rte_flow_action_of_set_mpls_ttl)),
4314 .next = NEXT(action_of_set_mpls_ttl),
4317 [ACTION_OF_SET_MPLS_TTL_MPLS_TTL] = {
4320 .next = NEXT(action_of_set_mpls_ttl,
4321 NEXT_ENTRY(COMMON_UNSIGNED)),
4322 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_mpls_ttl,
4324 .call = parse_vc_conf,
4326 [ACTION_OF_DEC_MPLS_TTL] = {
4327 .name = "of_dec_mpls_ttl",
4328 .help = "OpenFlow's OFPAT_DEC_MPLS_TTL",
4329 .priv = PRIV_ACTION(OF_DEC_MPLS_TTL, 0),
4330 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4333 [ACTION_OF_SET_NW_TTL] = {
4334 .name = "of_set_nw_ttl",
4335 .help = "OpenFlow's OFPAT_SET_NW_TTL",
4338 sizeof(struct rte_flow_action_of_set_nw_ttl)),
4339 .next = NEXT(action_of_set_nw_ttl),
4342 [ACTION_OF_SET_NW_TTL_NW_TTL] = {
4345 .next = NEXT(action_of_set_nw_ttl, NEXT_ENTRY(COMMON_UNSIGNED)),
4346 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_nw_ttl,
4348 .call = parse_vc_conf,
4350 [ACTION_OF_DEC_NW_TTL] = {
4351 .name = "of_dec_nw_ttl",
4352 .help = "OpenFlow's OFPAT_DEC_NW_TTL",
4353 .priv = PRIV_ACTION(OF_DEC_NW_TTL, 0),
4354 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4357 [ACTION_OF_COPY_TTL_OUT] = {
4358 .name = "of_copy_ttl_out",
4359 .help = "OpenFlow's OFPAT_COPY_TTL_OUT",
4360 .priv = PRIV_ACTION(OF_COPY_TTL_OUT, 0),
4361 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4364 [ACTION_OF_COPY_TTL_IN] = {
4365 .name = "of_copy_ttl_in",
4366 .help = "OpenFlow's OFPAT_COPY_TTL_IN",
4367 .priv = PRIV_ACTION(OF_COPY_TTL_IN, 0),
4368 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4371 [ACTION_OF_POP_VLAN] = {
4372 .name = "of_pop_vlan",
4373 .help = "OpenFlow's OFPAT_POP_VLAN",
4374 .priv = PRIV_ACTION(OF_POP_VLAN, 0),
4375 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4378 [ACTION_OF_PUSH_VLAN] = {
4379 .name = "of_push_vlan",
4380 .help = "OpenFlow's OFPAT_PUSH_VLAN",
4383 sizeof(struct rte_flow_action_of_push_vlan)),
4384 .next = NEXT(action_of_push_vlan),
4387 [ACTION_OF_PUSH_VLAN_ETHERTYPE] = {
4388 .name = "ethertype",
4389 .help = "EtherType",
4390 .next = NEXT(action_of_push_vlan, NEXT_ENTRY(COMMON_UNSIGNED)),
4391 .args = ARGS(ARGS_ENTRY_HTON
4392 (struct rte_flow_action_of_push_vlan,
4394 .call = parse_vc_conf,
4396 [ACTION_OF_SET_VLAN_VID] = {
4397 .name = "of_set_vlan_vid",
4398 .help = "OpenFlow's OFPAT_SET_VLAN_VID",
4401 sizeof(struct rte_flow_action_of_set_vlan_vid)),
4402 .next = NEXT(action_of_set_vlan_vid),
4405 [ACTION_OF_SET_VLAN_VID_VLAN_VID] = {
4408 .next = NEXT(action_of_set_vlan_vid,
4409 NEXT_ENTRY(COMMON_UNSIGNED)),
4410 .args = ARGS(ARGS_ENTRY_HTON
4411 (struct rte_flow_action_of_set_vlan_vid,
4413 .call = parse_vc_conf,
4415 [ACTION_OF_SET_VLAN_PCP] = {
4416 .name = "of_set_vlan_pcp",
4417 .help = "OpenFlow's OFPAT_SET_VLAN_PCP",
4420 sizeof(struct rte_flow_action_of_set_vlan_pcp)),
4421 .next = NEXT(action_of_set_vlan_pcp),
4424 [ACTION_OF_SET_VLAN_PCP_VLAN_PCP] = {
4426 .help = "VLAN priority",
4427 .next = NEXT(action_of_set_vlan_pcp,
4428 NEXT_ENTRY(COMMON_UNSIGNED)),
4429 .args = ARGS(ARGS_ENTRY_HTON
4430 (struct rte_flow_action_of_set_vlan_pcp,
4432 .call = parse_vc_conf,
4434 [ACTION_OF_POP_MPLS] = {
4435 .name = "of_pop_mpls",
4436 .help = "OpenFlow's OFPAT_POP_MPLS",
4437 .priv = PRIV_ACTION(OF_POP_MPLS,
4438 sizeof(struct rte_flow_action_of_pop_mpls)),
4439 .next = NEXT(action_of_pop_mpls),
4442 [ACTION_OF_POP_MPLS_ETHERTYPE] = {
4443 .name = "ethertype",
4444 .help = "EtherType",
4445 .next = NEXT(action_of_pop_mpls, NEXT_ENTRY(COMMON_UNSIGNED)),
4446 .args = ARGS(ARGS_ENTRY_HTON
4447 (struct rte_flow_action_of_pop_mpls,
4449 .call = parse_vc_conf,
4451 [ACTION_OF_PUSH_MPLS] = {
4452 .name = "of_push_mpls",
4453 .help = "OpenFlow's OFPAT_PUSH_MPLS",
4456 sizeof(struct rte_flow_action_of_push_mpls)),
4457 .next = NEXT(action_of_push_mpls),
4460 [ACTION_OF_PUSH_MPLS_ETHERTYPE] = {
4461 .name = "ethertype",
4462 .help = "EtherType",
4463 .next = NEXT(action_of_push_mpls, NEXT_ENTRY(COMMON_UNSIGNED)),
4464 .args = ARGS(ARGS_ENTRY_HTON
4465 (struct rte_flow_action_of_push_mpls,
4467 .call = parse_vc_conf,
4469 [ACTION_VXLAN_ENCAP] = {
4470 .name = "vxlan_encap",
4471 .help = "VXLAN encapsulation, uses configuration set by \"set"
4473 .priv = PRIV_ACTION(VXLAN_ENCAP,
4474 sizeof(struct action_vxlan_encap_data)),
4475 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4476 .call = parse_vc_action_vxlan_encap,
4478 [ACTION_VXLAN_DECAP] = {
4479 .name = "vxlan_decap",
4480 .help = "Performs a decapsulation action by stripping all"
4481 " headers of the VXLAN tunnel network overlay from the"
4483 .priv = PRIV_ACTION(VXLAN_DECAP, 0),
4484 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4487 [ACTION_NVGRE_ENCAP] = {
4488 .name = "nvgre_encap",
4489 .help = "NVGRE encapsulation, uses configuration set by \"set"
4491 .priv = PRIV_ACTION(NVGRE_ENCAP,
4492 sizeof(struct action_nvgre_encap_data)),
4493 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4494 .call = parse_vc_action_nvgre_encap,
4496 [ACTION_NVGRE_DECAP] = {
4497 .name = "nvgre_decap",
4498 .help = "Performs a decapsulation action by stripping all"
4499 " headers of the NVGRE tunnel network overlay from the"
4501 .priv = PRIV_ACTION(NVGRE_DECAP, 0),
4502 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4505 [ACTION_L2_ENCAP] = {
4507 .help = "l2 encap, uses configuration set by"
4508 " \"set l2_encap\"",
4509 .priv = PRIV_ACTION(RAW_ENCAP,
4510 sizeof(struct action_raw_encap_data)),
4511 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4512 .call = parse_vc_action_l2_encap,
4514 [ACTION_L2_DECAP] = {
4516 .help = "l2 decap, uses configuration set by"
4517 " \"set l2_decap\"",
4518 .priv = PRIV_ACTION(RAW_DECAP,
4519 sizeof(struct action_raw_decap_data)),
4520 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4521 .call = parse_vc_action_l2_decap,
4523 [ACTION_MPLSOGRE_ENCAP] = {
4524 .name = "mplsogre_encap",
4525 .help = "mplsogre encapsulation, uses configuration set by"
4526 " \"set mplsogre_encap\"",
4527 .priv = PRIV_ACTION(RAW_ENCAP,
4528 sizeof(struct action_raw_encap_data)),
4529 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4530 .call = parse_vc_action_mplsogre_encap,
4532 [ACTION_MPLSOGRE_DECAP] = {
4533 .name = "mplsogre_decap",
4534 .help = "mplsogre decapsulation, uses configuration set by"
4535 " \"set mplsogre_decap\"",
4536 .priv = PRIV_ACTION(RAW_DECAP,
4537 sizeof(struct action_raw_decap_data)),
4538 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4539 .call = parse_vc_action_mplsogre_decap,
4541 [ACTION_MPLSOUDP_ENCAP] = {
4542 .name = "mplsoudp_encap",
4543 .help = "mplsoudp encapsulation, uses configuration set by"
4544 " \"set mplsoudp_encap\"",
4545 .priv = PRIV_ACTION(RAW_ENCAP,
4546 sizeof(struct action_raw_encap_data)),
4547 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4548 .call = parse_vc_action_mplsoudp_encap,
4550 [ACTION_MPLSOUDP_DECAP] = {
4551 .name = "mplsoudp_decap",
4552 .help = "mplsoudp decapsulation, uses configuration set by"
4553 " \"set mplsoudp_decap\"",
4554 .priv = PRIV_ACTION(RAW_DECAP,
4555 sizeof(struct action_raw_decap_data)),
4556 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4557 .call = parse_vc_action_mplsoudp_decap,
4559 [ACTION_SET_IPV4_SRC] = {
4560 .name = "set_ipv4_src",
4561 .help = "Set a new IPv4 source address in the outermost"
4563 .priv = PRIV_ACTION(SET_IPV4_SRC,
4564 sizeof(struct rte_flow_action_set_ipv4)),
4565 .next = NEXT(action_set_ipv4_src),
4568 [ACTION_SET_IPV4_SRC_IPV4_SRC] = {
4569 .name = "ipv4_addr",
4570 .help = "new IPv4 source address to set",
4571 .next = NEXT(action_set_ipv4_src, NEXT_ENTRY(COMMON_IPV4_ADDR)),
4572 .args = ARGS(ARGS_ENTRY_HTON
4573 (struct rte_flow_action_set_ipv4, ipv4_addr)),
4574 .call = parse_vc_conf,
4576 [ACTION_SET_IPV4_DST] = {
4577 .name = "set_ipv4_dst",
4578 .help = "Set a new IPv4 destination address in the outermost"
4580 .priv = PRIV_ACTION(SET_IPV4_DST,
4581 sizeof(struct rte_flow_action_set_ipv4)),
4582 .next = NEXT(action_set_ipv4_dst),
4585 [ACTION_SET_IPV4_DST_IPV4_DST] = {
4586 .name = "ipv4_addr",
4587 .help = "new IPv4 destination address to set",
4588 .next = NEXT(action_set_ipv4_dst, NEXT_ENTRY(COMMON_IPV4_ADDR)),
4589 .args = ARGS(ARGS_ENTRY_HTON
4590 (struct rte_flow_action_set_ipv4, ipv4_addr)),
4591 .call = parse_vc_conf,
4593 [ACTION_SET_IPV6_SRC] = {
4594 .name = "set_ipv6_src",
4595 .help = "Set a new IPv6 source address in the outermost"
4597 .priv = PRIV_ACTION(SET_IPV6_SRC,
4598 sizeof(struct rte_flow_action_set_ipv6)),
4599 .next = NEXT(action_set_ipv6_src),
4602 [ACTION_SET_IPV6_SRC_IPV6_SRC] = {
4603 .name = "ipv6_addr",
4604 .help = "new IPv6 source address to set",
4605 .next = NEXT(action_set_ipv6_src, NEXT_ENTRY(COMMON_IPV6_ADDR)),
4606 .args = ARGS(ARGS_ENTRY_HTON
4607 (struct rte_flow_action_set_ipv6, ipv6_addr)),
4608 .call = parse_vc_conf,
4610 [ACTION_SET_IPV6_DST] = {
4611 .name = "set_ipv6_dst",
4612 .help = "Set a new IPv6 destination address in the outermost"
4614 .priv = PRIV_ACTION(SET_IPV6_DST,
4615 sizeof(struct rte_flow_action_set_ipv6)),
4616 .next = NEXT(action_set_ipv6_dst),
4619 [ACTION_SET_IPV6_DST_IPV6_DST] = {
4620 .name = "ipv6_addr",
4621 .help = "new IPv6 destination address to set",
4622 .next = NEXT(action_set_ipv6_dst, NEXT_ENTRY(COMMON_IPV6_ADDR)),
4623 .args = ARGS(ARGS_ENTRY_HTON
4624 (struct rte_flow_action_set_ipv6, ipv6_addr)),
4625 .call = parse_vc_conf,
4627 [ACTION_SET_TP_SRC] = {
4628 .name = "set_tp_src",
4629 .help = "set a new source port number in the outermost"
4631 .priv = PRIV_ACTION(SET_TP_SRC,
4632 sizeof(struct rte_flow_action_set_tp)),
4633 .next = NEXT(action_set_tp_src),
4636 [ACTION_SET_TP_SRC_TP_SRC] = {
4638 .help = "new source port number to set",
4639 .next = NEXT(action_set_tp_src, NEXT_ENTRY(COMMON_UNSIGNED)),
4640 .args = ARGS(ARGS_ENTRY_HTON
4641 (struct rte_flow_action_set_tp, port)),
4642 .call = parse_vc_conf,
4644 [ACTION_SET_TP_DST] = {
4645 .name = "set_tp_dst",
4646 .help = "set a new destination port number in the outermost"
4648 .priv = PRIV_ACTION(SET_TP_DST,
4649 sizeof(struct rte_flow_action_set_tp)),
4650 .next = NEXT(action_set_tp_dst),
4653 [ACTION_SET_TP_DST_TP_DST] = {
4655 .help = "new destination port number to set",
4656 .next = NEXT(action_set_tp_dst, NEXT_ENTRY(COMMON_UNSIGNED)),
4657 .args = ARGS(ARGS_ENTRY_HTON
4658 (struct rte_flow_action_set_tp, port)),
4659 .call = parse_vc_conf,
4661 [ACTION_MAC_SWAP] = {
4663 .help = "Swap the source and destination MAC addresses"
4664 " in the outermost Ethernet header",
4665 .priv = PRIV_ACTION(MAC_SWAP, 0),
4666 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4669 [ACTION_DEC_TTL] = {
4671 .help = "decrease network TTL if available",
4672 .priv = PRIV_ACTION(DEC_TTL, 0),
4673 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4676 [ACTION_SET_TTL] = {
4678 .help = "set ttl value",
4679 .priv = PRIV_ACTION(SET_TTL,
4680 sizeof(struct rte_flow_action_set_ttl)),
4681 .next = NEXT(action_set_ttl),
4684 [ACTION_SET_TTL_TTL] = {
4685 .name = "ttl_value",
4686 .help = "new ttl value to set",
4687 .next = NEXT(action_set_ttl, NEXT_ENTRY(COMMON_UNSIGNED)),
4688 .args = ARGS(ARGS_ENTRY_HTON
4689 (struct rte_flow_action_set_ttl, ttl_value)),
4690 .call = parse_vc_conf,
4692 [ACTION_SET_MAC_SRC] = {
4693 .name = "set_mac_src",
4694 .help = "set source mac address",
4695 .priv = PRIV_ACTION(SET_MAC_SRC,
4696 sizeof(struct rte_flow_action_set_mac)),
4697 .next = NEXT(action_set_mac_src),
4700 [ACTION_SET_MAC_SRC_MAC_SRC] = {
4702 .help = "new source mac address",
4703 .next = NEXT(action_set_mac_src, NEXT_ENTRY(COMMON_MAC_ADDR)),
4704 .args = ARGS(ARGS_ENTRY_HTON
4705 (struct rte_flow_action_set_mac, mac_addr)),
4706 .call = parse_vc_conf,
4708 [ACTION_SET_MAC_DST] = {
4709 .name = "set_mac_dst",
4710 .help = "set destination mac address",
4711 .priv = PRIV_ACTION(SET_MAC_DST,
4712 sizeof(struct rte_flow_action_set_mac)),
4713 .next = NEXT(action_set_mac_dst),
4716 [ACTION_SET_MAC_DST_MAC_DST] = {
4718 .help = "new destination mac address to set",
4719 .next = NEXT(action_set_mac_dst, NEXT_ENTRY(COMMON_MAC_ADDR)),
4720 .args = ARGS(ARGS_ENTRY_HTON
4721 (struct rte_flow_action_set_mac, mac_addr)),
4722 .call = parse_vc_conf,
4724 [ACTION_INC_TCP_SEQ] = {
4725 .name = "inc_tcp_seq",
4726 .help = "increase TCP sequence number",
4727 .priv = PRIV_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
4728 .next = NEXT(action_inc_tcp_seq),
4731 [ACTION_INC_TCP_SEQ_VALUE] = {
4733 .help = "the value to increase TCP sequence number by",
4734 .next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(COMMON_UNSIGNED)),
4735 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4736 .call = parse_vc_conf,
4738 [ACTION_DEC_TCP_SEQ] = {
4739 .name = "dec_tcp_seq",
4740 .help = "decrease TCP sequence number",
4741 .priv = PRIV_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
4742 .next = NEXT(action_dec_tcp_seq),
4745 [ACTION_DEC_TCP_SEQ_VALUE] = {
4747 .help = "the value to decrease TCP sequence number by",
4748 .next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(COMMON_UNSIGNED)),
4749 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4750 .call = parse_vc_conf,
4752 [ACTION_INC_TCP_ACK] = {
4753 .name = "inc_tcp_ack",
4754 .help = "increase TCP acknowledgment number",
4755 .priv = PRIV_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
4756 .next = NEXT(action_inc_tcp_ack),
4759 [ACTION_INC_TCP_ACK_VALUE] = {
4761 .help = "the value to increase TCP acknowledgment number by",
4762 .next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(COMMON_UNSIGNED)),
4763 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4764 .call = parse_vc_conf,
4766 [ACTION_DEC_TCP_ACK] = {
4767 .name = "dec_tcp_ack",
4768 .help = "decrease TCP acknowledgment number",
4769 .priv = PRIV_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
4770 .next = NEXT(action_dec_tcp_ack),
4773 [ACTION_DEC_TCP_ACK_VALUE] = {
4775 .help = "the value to decrease TCP acknowledgment number by",
4776 .next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(COMMON_UNSIGNED)),
4777 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4778 .call = parse_vc_conf,
4780 [ACTION_RAW_ENCAP] = {
4781 .name = "raw_encap",
4782 .help = "encapsulation data, defined by set raw_encap",
4783 .priv = PRIV_ACTION(RAW_ENCAP,
4784 sizeof(struct action_raw_encap_data)),
4785 .next = NEXT(action_raw_encap),
4786 .call = parse_vc_action_raw_encap,
4788 [ACTION_RAW_ENCAP_INDEX] = {
4790 .help = "the index of raw_encap_confs",
4791 .next = NEXT(NEXT_ENTRY(ACTION_RAW_ENCAP_INDEX_VALUE)),
4793 [ACTION_RAW_ENCAP_INDEX_VALUE] = {
4796 .help = "unsigned integer value",
4797 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4798 .call = parse_vc_action_raw_encap_index,
4799 .comp = comp_set_raw_index,
4801 [ACTION_RAW_DECAP] = {
4802 .name = "raw_decap",
4803 .help = "decapsulation data, defined by set raw_encap",
4804 .priv = PRIV_ACTION(RAW_DECAP,
4805 sizeof(struct action_raw_decap_data)),
4806 .next = NEXT(action_raw_decap),
4807 .call = parse_vc_action_raw_decap,
4809 [ACTION_RAW_DECAP_INDEX] = {
4811 .help = "the index of raw_encap_confs",
4812 .next = NEXT(NEXT_ENTRY(ACTION_RAW_DECAP_INDEX_VALUE)),
4814 [ACTION_RAW_DECAP_INDEX_VALUE] = {
4817 .help = "unsigned integer value",
4818 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4819 .call = parse_vc_action_raw_decap_index,
4820 .comp = comp_set_raw_index,
4822 [ACTION_MODIFY_FIELD] = {
4823 .name = "modify_field",
4824 .help = "modify destination field with data from source field",
4825 .priv = PRIV_ACTION(MODIFY_FIELD, ACTION_MODIFY_SIZE),
4826 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_OP)),
4829 [ACTION_MODIFY_FIELD_OP] = {
4831 .help = "operation type",
4832 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_TYPE),
4833 NEXT_ENTRY(ACTION_MODIFY_FIELD_OP_VALUE)),
4834 .call = parse_vc_conf,
4836 [ACTION_MODIFY_FIELD_OP_VALUE] = {
4837 .name = "{operation}",
4838 .help = "operation type value",
4839 .call = parse_vc_modify_field_op,
4840 .comp = comp_set_modify_field_op,
4842 [ACTION_MODIFY_FIELD_DST_TYPE] = {
4844 .help = "destination field type",
4845 .next = NEXT(action_modify_field_dst,
4846 NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_TYPE_VALUE)),
4847 .call = parse_vc_conf,
4849 [ACTION_MODIFY_FIELD_DST_TYPE_VALUE] = {
4850 .name = "{dst_type}",
4851 .help = "destination field type value",
4852 .call = parse_vc_modify_field_id,
4853 .comp = comp_set_modify_field_id,
4855 [ACTION_MODIFY_FIELD_DST_LEVEL] = {
4856 .name = "dst_level",
4857 .help = "destination field level",
4858 .next = NEXT(action_modify_field_dst,
4859 NEXT_ENTRY(COMMON_UNSIGNED)),
4860 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4862 .call = parse_vc_conf,
4864 [ACTION_MODIFY_FIELD_DST_OFFSET] = {
4865 .name = "dst_offset",
4866 .help = "destination field bit offset",
4867 .next = NEXT(action_modify_field_dst,
4868 NEXT_ENTRY(COMMON_UNSIGNED)),
4869 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4871 .call = parse_vc_conf,
4873 [ACTION_MODIFY_FIELD_SRC_TYPE] = {
4875 .help = "source field type",
4876 .next = NEXT(action_modify_field_src,
4877 NEXT_ENTRY(ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)),
4878 .call = parse_vc_conf,
4880 [ACTION_MODIFY_FIELD_SRC_TYPE_VALUE] = {
4881 .name = "{src_type}",
4882 .help = "source field type value",
4883 .call = parse_vc_modify_field_id,
4884 .comp = comp_set_modify_field_id,
4886 [ACTION_MODIFY_FIELD_SRC_LEVEL] = {
4887 .name = "src_level",
4888 .help = "source field level",
4889 .next = NEXT(action_modify_field_src,
4890 NEXT_ENTRY(COMMON_UNSIGNED)),
4891 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4893 .call = parse_vc_conf,
4895 [ACTION_MODIFY_FIELD_SRC_OFFSET] = {
4896 .name = "src_offset",
4897 .help = "source field bit offset",
4898 .next = NEXT(action_modify_field_src,
4899 NEXT_ENTRY(COMMON_UNSIGNED)),
4900 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4902 .call = parse_vc_conf,
4904 [ACTION_MODIFY_FIELD_SRC_VALUE] = {
4905 .name = "src_value",
4906 .help = "source immediate value",
4907 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_WIDTH),
4908 NEXT_ENTRY(COMMON_HEX)),
4909 .args = ARGS(ARGS_ENTRY_ARB(0, 0),
4910 ARGS_ENTRY_ARB(0, 0),
4911 ARGS_ENTRY(struct rte_flow_action_modify_field,
4913 .call = parse_vc_conf,
4915 [ACTION_MODIFY_FIELD_SRC_POINTER] = {
4917 .help = "pointer to source immediate value",
4918 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_WIDTH),
4919 NEXT_ENTRY(COMMON_HEX)),
4920 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4922 ARGS_ENTRY_ARB(0, 0),
4924 (sizeof(struct rte_flow_action_modify_field),
4925 ACTION_MODIFY_PATTERN_SIZE)),
4926 .call = parse_vc_conf,
4928 [ACTION_MODIFY_FIELD_WIDTH] = {
4930 .help = "number of bits to copy",
4931 .next = NEXT(NEXT_ENTRY(ACTION_NEXT),
4932 NEXT_ENTRY(COMMON_UNSIGNED)),
4933 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4935 .call = parse_vc_conf,
4937 /* Top level command. */
4940 .help = "set raw encap/decap/sample data",
4941 .type = "set raw_encap|raw_decap <index> <pattern>"
4942 " or set sample_actions <index> <action>",
4943 .next = NEXT(NEXT_ENTRY
4946 SET_SAMPLE_ACTIONS)),
4947 .call = parse_set_init,
4949 /* Sub-level commands. */
4951 .name = "raw_encap",
4952 .help = "set raw encap data",
4953 .next = NEXT(next_set_raw),
4954 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4955 (offsetof(struct buffer, port),
4956 sizeof(((struct buffer *)0)->port),
4957 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
4958 .call = parse_set_raw_encap_decap,
4961 .name = "raw_decap",
4962 .help = "set raw decap data",
4963 .next = NEXT(next_set_raw),
4964 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4965 (offsetof(struct buffer, port),
4966 sizeof(((struct buffer *)0)->port),
4967 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
4968 .call = parse_set_raw_encap_decap,
4972 .type = "COMMON_UNSIGNED",
4973 .help = "index of raw_encap/raw_decap data",
4974 .next = NEXT(next_item),
4977 [SET_SAMPLE_INDEX] = {
4980 .help = "index of sample actions",
4981 .next = NEXT(next_action_sample),
4984 [SET_SAMPLE_ACTIONS] = {
4985 .name = "sample_actions",
4986 .help = "set sample actions list",
4987 .next = NEXT(NEXT_ENTRY(SET_SAMPLE_INDEX)),
4988 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4989 (offsetof(struct buffer, port),
4990 sizeof(((struct buffer *)0)->port),
4991 0, RAW_SAMPLE_CONFS_MAX_NUM - 1)),
4992 .call = parse_set_sample_action,
4994 [ACTION_SET_TAG] = {
4997 .priv = PRIV_ACTION(SET_TAG,
4998 sizeof(struct rte_flow_action_set_tag)),
4999 .next = NEXT(action_set_tag),
5002 [ACTION_SET_TAG_INDEX] = {
5004 .help = "index of tag array",
5005 .next = NEXT(action_set_tag, NEXT_ENTRY(COMMON_UNSIGNED)),
5006 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_set_tag, index)),
5007 .call = parse_vc_conf,
5009 [ACTION_SET_TAG_DATA] = {
5011 .help = "tag value",
5012 .next = NEXT(action_set_tag, NEXT_ENTRY(COMMON_UNSIGNED)),
5013 .args = ARGS(ARGS_ENTRY
5014 (struct rte_flow_action_set_tag, data)),
5015 .call = parse_vc_conf,
5017 [ACTION_SET_TAG_MASK] = {
5019 .help = "mask for tag value",
5020 .next = NEXT(action_set_tag, NEXT_ENTRY(COMMON_UNSIGNED)),
5021 .args = ARGS(ARGS_ENTRY
5022 (struct rte_flow_action_set_tag, mask)),
5023 .call = parse_vc_conf,
5025 [ACTION_SET_META] = {
5027 .help = "set metadata",
5028 .priv = PRIV_ACTION(SET_META,
5029 sizeof(struct rte_flow_action_set_meta)),
5030 .next = NEXT(action_set_meta),
5031 .call = parse_vc_action_set_meta,
5033 [ACTION_SET_META_DATA] = {
5035 .help = "metadata value",
5036 .next = NEXT(action_set_meta, NEXT_ENTRY(COMMON_UNSIGNED)),
5037 .args = ARGS(ARGS_ENTRY
5038 (struct rte_flow_action_set_meta, data)),
5039 .call = parse_vc_conf,
5041 [ACTION_SET_META_MASK] = {
5043 .help = "mask for metadata value",
5044 .next = NEXT(action_set_meta, NEXT_ENTRY(COMMON_UNSIGNED)),
5045 .args = ARGS(ARGS_ENTRY
5046 (struct rte_flow_action_set_meta, mask)),
5047 .call = parse_vc_conf,
5049 [ACTION_SET_IPV4_DSCP] = {
5050 .name = "set_ipv4_dscp",
5051 .help = "set DSCP value",
5052 .priv = PRIV_ACTION(SET_IPV4_DSCP,
5053 sizeof(struct rte_flow_action_set_dscp)),
5054 .next = NEXT(action_set_ipv4_dscp),
5057 [ACTION_SET_IPV4_DSCP_VALUE] = {
5058 .name = "dscp_value",
5059 .help = "new IPv4 DSCP value to set",
5060 .next = NEXT(action_set_ipv4_dscp, NEXT_ENTRY(COMMON_UNSIGNED)),
5061 .args = ARGS(ARGS_ENTRY
5062 (struct rte_flow_action_set_dscp, dscp)),
5063 .call = parse_vc_conf,
5065 [ACTION_SET_IPV6_DSCP] = {
5066 .name = "set_ipv6_dscp",
5067 .help = "set DSCP value",
5068 .priv = PRIV_ACTION(SET_IPV6_DSCP,
5069 sizeof(struct rte_flow_action_set_dscp)),
5070 .next = NEXT(action_set_ipv6_dscp),
5073 [ACTION_SET_IPV6_DSCP_VALUE] = {
5074 .name = "dscp_value",
5075 .help = "new IPv6 DSCP value to set",
5076 .next = NEXT(action_set_ipv6_dscp, NEXT_ENTRY(COMMON_UNSIGNED)),
5077 .args = ARGS(ARGS_ENTRY
5078 (struct rte_flow_action_set_dscp, dscp)),
5079 .call = parse_vc_conf,
5083 .help = "set a specific metadata header",
5084 .next = NEXT(action_age),
5085 .priv = PRIV_ACTION(AGE,
5086 sizeof(struct rte_flow_action_age)),
5089 [ACTION_AGE_TIMEOUT] = {
5091 .help = "flow age timeout value",
5092 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_age,
5094 .next = NEXT(action_age, NEXT_ENTRY(COMMON_UNSIGNED)),
5095 .call = parse_vc_conf,
5099 .help = "set a sample action",
5100 .next = NEXT(action_sample),
5101 .priv = PRIV_ACTION(SAMPLE,
5102 sizeof(struct action_sample_data)),
5103 .call = parse_vc_action_sample,
5105 [ACTION_SAMPLE_RATIO] = {
5107 .help = "flow sample ratio value",
5108 .next = NEXT(action_sample, NEXT_ENTRY(COMMON_UNSIGNED)),
5109 .args = ARGS(ARGS_ENTRY_ARB
5110 (offsetof(struct action_sample_data, conf) +
5111 offsetof(struct rte_flow_action_sample, ratio),
5112 sizeof(((struct rte_flow_action_sample *)0)->
5115 [ACTION_SAMPLE_INDEX] = {
5117 .help = "the index of sample actions list",
5118 .next = NEXT(NEXT_ENTRY(ACTION_SAMPLE_INDEX_VALUE)),
5120 [ACTION_SAMPLE_INDEX_VALUE] = {
5122 .type = "COMMON_UNSIGNED",
5123 .help = "unsigned integer value",
5124 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
5125 .call = parse_vc_action_sample_index,
5126 .comp = comp_set_sample_index,
5128 [ACTION_CONNTRACK] = {
5129 .name = "conntrack",
5130 .help = "create a conntrack object",
5131 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
5132 .priv = PRIV_ACTION(CONNTRACK,
5133 sizeof(struct rte_flow_action_conntrack)),
5136 [ACTION_CONNTRACK_UPDATE] = {
5137 .name = "conntrack_update",
5138 .help = "update a conntrack object",
5139 .next = NEXT(action_update_conntrack),
5140 .priv = PRIV_ACTION(CONNTRACK,
5141 sizeof(struct rte_flow_modify_conntrack)),
5144 [ACTION_CONNTRACK_UPDATE_DIR] = {
5146 .help = "update a conntrack object direction",
5147 .next = NEXT(action_update_conntrack),
5148 .call = parse_vc_action_conntrack_update,
5150 [ACTION_CONNTRACK_UPDATE_CTX] = {
5152 .help = "update a conntrack object context",
5153 .next = NEXT(action_update_conntrack),
5154 .call = parse_vc_action_conntrack_update,
5156 [ACTION_PORT_REPRESENTOR] = {
5157 .name = "port_representor",
5158 .help = "at embedded switch level, send matching traffic to the given ethdev",
5159 .priv = PRIV_ACTION(PORT_REPRESENTOR,
5160 sizeof(struct rte_flow_action_ethdev)),
5161 .next = NEXT(action_port_representor),
5164 [ACTION_PORT_REPRESENTOR_PORT_ID] = {
5166 .help = "ethdev port ID",
5167 .next = NEXT(action_port_representor,
5168 NEXT_ENTRY(COMMON_UNSIGNED)),
5169 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_ethdev,
5171 .call = parse_vc_conf,
5173 [ACTION_REPRESENTED_PORT] = {
5174 .name = "represented_port",
5175 .help = "at embedded switch level, send matching traffic to the entity represented by the given ethdev",
5176 .priv = PRIV_ACTION(REPRESENTED_PORT,
5177 sizeof(struct rte_flow_action_ethdev)),
5178 .next = NEXT(action_represented_port),
5181 [ACTION_REPRESENTED_PORT_ETHDEV_PORT_ID] = {
5182 .name = "ethdev_port_id",
5183 .help = "ethdev port ID",
5184 .next = NEXT(action_represented_port,
5185 NEXT_ENTRY(COMMON_UNSIGNED)),
5186 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_ethdev,
5188 .call = parse_vc_conf,
5190 /* Indirect action destroy arguments. */
5191 [INDIRECT_ACTION_DESTROY_ID] = {
5192 .name = "action_id",
5193 .help = "specify a indirect action id to destroy",
5194 .next = NEXT(next_ia_destroy_attr,
5195 NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
5196 .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
5197 args.ia_destroy.action_id)),
5198 .call = parse_ia_destroy,
5200 /* Indirect action create arguments. */
5201 [INDIRECT_ACTION_CREATE_ID] = {
5202 .name = "action_id",
5203 .help = "specify a indirect action id to create",
5204 .next = NEXT(next_ia_create_attr,
5205 NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
5206 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
5208 [ACTION_INDIRECT] = {
5210 .help = "apply indirect action by id",
5211 .priv = PRIV_ACTION(INDIRECT, 0),
5212 .next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_ID2PTR)),
5213 .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
5216 [INDIRECT_ACTION_ID2PTR] = {
5217 .name = "{action_id}",
5218 .type = "INDIRECT_ACTION_ID",
5219 .help = "indirect action id",
5220 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
5221 .call = parse_ia_id2ptr,
5224 [INDIRECT_ACTION_INGRESS] = {
5226 .help = "affect rule to ingress",
5227 .next = NEXT(next_ia_create_attr),
5230 [INDIRECT_ACTION_EGRESS] = {
5232 .help = "affect rule to egress",
5233 .next = NEXT(next_ia_create_attr),
5236 [INDIRECT_ACTION_TRANSFER] = {
5238 .help = "affect rule to transfer",
5239 .next = NEXT(next_ia_create_attr),
5242 [INDIRECT_ACTION_SPEC] = {
5244 .help = "specify action to create indirect handle",
5245 .next = NEXT(next_action),
5248 .name = "g_actions",
5249 .help = "submit a list of associated actions for green",
5250 .next = NEXT(next_action),
5254 .name = "y_actions",
5255 .help = "submit a list of associated actions for yellow",
5256 .next = NEXT(next_action),
5259 .name = "r_actions",
5260 .help = "submit a list of associated actions for red",
5261 .next = NEXT(next_action),
5264 /* Top-level command. */
5267 .type = "port meter policy {port_id} {arg}",
5268 .help = "add port meter policy",
5269 .next = NEXT(NEXT_ENTRY(ITEM_POL_PORT)),
5272 /* Sub-level commands. */
5275 .help = "add port meter policy",
5276 .next = NEXT(NEXT_ENTRY(ITEM_POL_METER)),
5278 [ITEM_POL_METER] = {
5280 .help = "add port meter policy",
5281 .next = NEXT(NEXT_ENTRY(ITEM_POL_POLICY)),
5283 [ITEM_POL_POLICY] = {
5285 .help = "add port meter policy",
5286 .next = NEXT(NEXT_ENTRY(ACTION_POL_R),
5287 NEXT_ENTRY(ACTION_POL_Y),
5288 NEXT_ENTRY(ACTION_POL_G),
5289 NEXT_ENTRY(COMMON_POLICY_ID),
5290 NEXT_ENTRY(COMMON_PORT_ID)),
5291 .args = ARGS(ARGS_ENTRY(struct buffer, args.policy.policy_id),
5292 ARGS_ENTRY(struct buffer, port)),
5297 /** Remove and return last entry from argument stack. */
5298 static const struct arg *
5299 pop_args(struct context *ctx)
5301 return ctx->args_num ? ctx->args[--ctx->args_num] : NULL;
5304 /** Add entry on top of the argument stack. */
5306 push_args(struct context *ctx, const struct arg *arg)
5308 if (ctx->args_num == CTX_STACK_SIZE)
5310 ctx->args[ctx->args_num++] = arg;
5314 /** Spread value into buffer according to bit-mask. */
5316 arg_entry_bf_fill(void *dst, uintmax_t val, const struct arg *arg)
5318 uint32_t i = arg->size;
5326 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
5335 unsigned int shift = 0;
5336 uint8_t *buf = (uint8_t *)dst + arg->offset + (i -= sub);
5338 for (shift = 0; arg->mask[i] >> shift; ++shift) {
5339 if (!(arg->mask[i] & (1 << shift)))
5344 *buf &= ~(1 << shift);
5345 *buf |= (val & 1) << shift;
5353 /** Compare a string with a partial one of a given length. */
5355 strcmp_partial(const char *full, const char *partial, size_t partial_len)
5357 int r = strncmp(full, partial, partial_len);
5361 if (strlen(full) <= partial_len)
5363 return full[partial_len];
5367 * Parse a prefix length and generate a bit-mask.
5369 * Last argument (ctx->args) is retrieved to determine mask size, storage
5370 * location and whether the result must use network byte ordering.
5373 parse_prefix(struct context *ctx, const struct token *token,
5374 const char *str, unsigned int len,
5375 void *buf, unsigned int size)
5377 const struct arg *arg = pop_args(ctx);
5378 static const uint8_t conv[] = "\x00\x80\xc0\xe0\xf0\xf8\xfc\xfe\xff";
5385 /* Argument is expected. */
5389 u = strtoumax(str, &end, 0);
5390 if (errno || (size_t)(end - str) != len)
5395 extra = arg_entry_bf_fill(NULL, 0, arg);
5404 if (!arg_entry_bf_fill(ctx->object, v, arg) ||
5405 !arg_entry_bf_fill(ctx->objmask, -1, arg))
5412 if (bytes > size || bytes + !!extra > size)
5416 buf = (uint8_t *)ctx->object + arg->offset;
5417 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
5419 memset((uint8_t *)buf + size - bytes, 0xff, bytes);
5420 memset(buf, 0x00, size - bytes);
5422 ((uint8_t *)buf)[size - bytes - 1] = conv[extra];
5426 memset(buf, 0xff, bytes);
5427 memset((uint8_t *)buf + bytes, 0x00, size - bytes);
5429 ((uint8_t *)buf)[bytes] = conv[extra];
5432 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
5435 push_args(ctx, arg);
5439 /** Default parsing function for token name matching. */
5441 parse_default(struct context *ctx, const struct token *token,
5442 const char *str, unsigned int len,
5443 void *buf, unsigned int size)
5448 if (strcmp_partial(token->name, str, len))
5453 /** Parse flow command, initialize output buffer for subsequent tokens. */
5455 parse_init(struct context *ctx, const struct token *token,
5456 const char *str, unsigned int len,
5457 void *buf, unsigned int size)
5459 struct buffer *out = buf;
5461 /* Token name must match. */
5462 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5464 /* Nothing else to do if there is no buffer. */
5467 /* Make sure buffer is large enough. */
5468 if (size < sizeof(*out))
5470 /* Initialize buffer. */
5471 memset(out, 0x00, sizeof(*out));
5472 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
5475 ctx->objmask = NULL;
5479 /** Parse tokens for indirect action commands. */
5481 parse_ia(struct context *ctx, const struct token *token,
5482 const char *str, unsigned int len,
5483 void *buf, unsigned int size)
5485 struct buffer *out = buf;
5487 /* Token name must match. */
5488 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5490 /* Nothing else to do if there is no buffer. */
5493 if (!out->command) {
5494 if (ctx->curr != INDIRECT_ACTION)
5496 if (sizeof(*out) > size)
5498 out->command = ctx->curr;
5501 ctx->objmask = NULL;
5502 out->args.vc.data = (uint8_t *)out + size;
5505 switch (ctx->curr) {
5506 case INDIRECT_ACTION_CREATE:
5507 case INDIRECT_ACTION_UPDATE:
5508 out->args.vc.actions =
5509 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5511 out->args.vc.attr.group = UINT32_MAX;
5513 case INDIRECT_ACTION_QUERY:
5514 out->command = ctx->curr;
5517 ctx->objmask = NULL;
5519 case INDIRECT_ACTION_EGRESS:
5520 out->args.vc.attr.egress = 1;
5522 case INDIRECT_ACTION_INGRESS:
5523 out->args.vc.attr.ingress = 1;
5525 case INDIRECT_ACTION_TRANSFER:
5526 out->args.vc.attr.transfer = 1;
5534 /** Parse tokens for indirect action destroy command. */
5536 parse_ia_destroy(struct context *ctx, const struct token *token,
5537 const char *str, unsigned int len,
5538 void *buf, unsigned int size)
5540 struct buffer *out = buf;
5541 uint32_t *action_id;
5543 /* Token name must match. */
5544 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5546 /* Nothing else to do if there is no buffer. */
5549 if (!out->command || out->command == INDIRECT_ACTION) {
5550 if (ctx->curr != INDIRECT_ACTION_DESTROY)
5552 if (sizeof(*out) > size)
5554 out->command = ctx->curr;
5557 ctx->objmask = NULL;
5558 out->args.ia_destroy.action_id =
5559 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5563 action_id = out->args.ia_destroy.action_id
5564 + out->args.ia_destroy.action_id_n++;
5565 if ((uint8_t *)action_id > (uint8_t *)out + size)
5568 ctx->object = action_id;
5569 ctx->objmask = NULL;
5573 /** Parse tokens for meter policy action commands. */
5575 parse_mp(struct context *ctx, const struct token *token,
5576 const char *str, unsigned int len,
5577 void *buf, unsigned int size)
5579 struct buffer *out = buf;
5581 /* Token name must match. */
5582 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5584 /* Nothing else to do if there is no buffer. */
5587 if (!out->command) {
5588 if (ctx->curr != ITEM_POL_POLICY)
5590 if (sizeof(*out) > size)
5592 out->command = ctx->curr;
5595 ctx->objmask = NULL;
5596 out->args.vc.data = (uint8_t *)out + size;
5599 switch (ctx->curr) {
5601 out->args.vc.actions =
5602 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5604 out->command = ctx->curr;
5607 ctx->objmask = NULL;
5614 /** Parse tokens for validate/create commands. */
5616 parse_vc(struct context *ctx, const struct token *token,
5617 const char *str, unsigned int len,
5618 void *buf, unsigned int size)
5620 struct buffer *out = buf;
5624 /* Token name must match. */
5625 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5627 /* Nothing else to do if there is no buffer. */
5630 if (!out->command) {
5631 if (ctx->curr != VALIDATE && ctx->curr != CREATE)
5633 if (sizeof(*out) > size)
5635 out->command = ctx->curr;
5638 ctx->objmask = NULL;
5639 out->args.vc.data = (uint8_t *)out + size;
5643 switch (ctx->curr) {
5645 ctx->object = &out->args.vc.attr;
5648 case VC_TUNNEL_MATCH:
5649 ctx->object = &out->args.vc.tunnel_ops;
5652 ctx->objmask = NULL;
5653 switch (ctx->curr) {
5658 out->args.vc.tunnel_ops.enabled = 1;
5659 out->args.vc.tunnel_ops.actions = 1;
5661 case VC_TUNNEL_MATCH:
5662 out->args.vc.tunnel_ops.enabled = 1;
5663 out->args.vc.tunnel_ops.items = 1;
5666 out->args.vc.attr.ingress = 1;
5669 out->args.vc.attr.egress = 1;
5672 out->args.vc.attr.transfer = 1;
5675 out->args.vc.pattern =
5676 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5678 ctx->object = out->args.vc.pattern;
5679 ctx->objmask = NULL;
5682 out->args.vc.actions =
5683 (void *)RTE_ALIGN_CEIL((uintptr_t)
5684 (out->args.vc.pattern +
5685 out->args.vc.pattern_n),
5687 ctx->object = out->args.vc.actions;
5688 ctx->objmask = NULL;
5695 if (!out->args.vc.actions) {
5696 const struct parse_item_priv *priv = token->priv;
5697 struct rte_flow_item *item =
5698 out->args.vc.pattern + out->args.vc.pattern_n;
5700 data_size = priv->size * 3; /* spec, last, mask */
5701 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
5702 (out->args.vc.data - data_size),
5704 if ((uint8_t *)item + sizeof(*item) > data)
5706 *item = (struct rte_flow_item){
5709 ++out->args.vc.pattern_n;
5711 ctx->objmask = NULL;
5713 const struct parse_action_priv *priv = token->priv;
5714 struct rte_flow_action *action =
5715 out->args.vc.actions + out->args.vc.actions_n;
5717 data_size = priv->size; /* configuration */
5718 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
5719 (out->args.vc.data - data_size),
5721 if ((uint8_t *)action + sizeof(*action) > data)
5723 *action = (struct rte_flow_action){
5725 .conf = data_size ? data : NULL,
5727 ++out->args.vc.actions_n;
5728 ctx->object = action;
5729 ctx->objmask = NULL;
5731 memset(data, 0, data_size);
5732 out->args.vc.data = data;
5733 ctx->objdata = data_size;
5737 /** Parse pattern item parameter type. */
5739 parse_vc_spec(struct context *ctx, const struct token *token,
5740 const char *str, unsigned int len,
5741 void *buf, unsigned int size)
5743 struct buffer *out = buf;
5744 struct rte_flow_item *item;
5750 /* Token name must match. */
5751 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5753 /* Parse parameter types. */
5754 switch (ctx->curr) {
5755 static const enum index prefix[] = NEXT_ENTRY(COMMON_PREFIX);
5761 case ITEM_PARAM_SPEC:
5764 case ITEM_PARAM_LAST:
5767 case ITEM_PARAM_PREFIX:
5768 /* Modify next token to expect a prefix. */
5769 if (ctx->next_num < 2)
5771 ctx->next[ctx->next_num - 2] = prefix;
5773 case ITEM_PARAM_MASK:
5779 /* Nothing else to do if there is no buffer. */
5782 if (!out->args.vc.pattern_n)
5784 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
5785 data_size = ctx->objdata / 3; /* spec, last, mask */
5786 /* Point to selected object. */
5787 ctx->object = out->args.vc.data + (data_size * index);
5789 ctx->objmask = out->args.vc.data + (data_size * 2); /* mask */
5790 item->mask = ctx->objmask;
5792 ctx->objmask = NULL;
5793 /* Update relevant item pointer. */
5794 *((const void **[]){ &item->spec, &item->last, &item->mask })[index] =
5799 /** Parse action configuration field. */
5801 parse_vc_conf(struct context *ctx, const struct token *token,
5802 const char *str, unsigned int len,
5803 void *buf, unsigned int size)
5805 struct buffer *out = buf;
5808 /* Token name must match. */
5809 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5811 /* Nothing else to do if there is no buffer. */
5814 /* Point to selected object. */
5815 ctx->object = out->args.vc.data;
5816 ctx->objmask = NULL;
5820 /** Parse eCPRI common header type field. */
5822 parse_vc_item_ecpri_type(struct context *ctx, const struct token *token,
5823 const char *str, unsigned int len,
5824 void *buf, unsigned int size)
5826 struct rte_flow_item_ecpri *ecpri;
5827 struct rte_flow_item_ecpri *ecpri_mask;
5828 struct rte_flow_item *item;
5831 struct buffer *out = buf;
5832 const struct arg *arg;
5835 /* Token name must match. */
5836 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5838 switch (ctx->curr) {
5839 case ITEM_ECPRI_COMMON_TYPE_IQ_DATA:
5840 msg_type = RTE_ECPRI_MSG_TYPE_IQ_DATA;
5842 case ITEM_ECPRI_COMMON_TYPE_RTC_CTRL:
5843 msg_type = RTE_ECPRI_MSG_TYPE_RTC_CTRL;
5845 case ITEM_ECPRI_COMMON_TYPE_DLY_MSR:
5846 msg_type = RTE_ECPRI_MSG_TYPE_DLY_MSR;
5853 arg = pop_args(ctx);
5856 ecpri = (struct rte_flow_item_ecpri *)out->args.vc.data;
5857 ecpri->hdr.common.type = msg_type;
5858 data_size = ctx->objdata / 3; /* spec, last, mask */
5859 ecpri_mask = (struct rte_flow_item_ecpri *)(out->args.vc.data +
5861 ecpri_mask->hdr.common.type = 0xFF;
5863 ecpri->hdr.common.u32 = rte_cpu_to_be_32(ecpri->hdr.common.u32);
5864 ecpri_mask->hdr.common.u32 =
5865 rte_cpu_to_be_32(ecpri_mask->hdr.common.u32);
5867 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
5869 item->mask = ecpri_mask;
5873 /** Parse L2TPv2 common header type field. */
5875 parse_vc_item_l2tpv2_type(struct context *ctx, const struct token *token,
5876 const char *str, unsigned int len,
5877 void *buf, unsigned int size)
5879 struct rte_flow_item_l2tpv2 *l2tpv2;
5880 struct rte_flow_item_l2tpv2 *l2tpv2_mask;
5881 struct rte_flow_item *item;
5883 uint16_t msg_type = 0;
5884 struct buffer *out = buf;
5885 const struct arg *arg;
5888 /* Token name must match. */
5889 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5891 switch (ctx->curr) {
5892 case ITEM_L2TPV2_COMMON_TYPE_DATA_L:
5895 case ITEM_L2TPV2_COMMON_TYPE_CTRL:
5903 arg = pop_args(ctx);
5906 l2tpv2 = (struct rte_flow_item_l2tpv2 *)out->args.vc.data;
5907 l2tpv2->hdr.common.flags_version |= msg_type;
5908 data_size = ctx->objdata / 3; /* spec, last, mask */
5909 l2tpv2_mask = (struct rte_flow_item_l2tpv2 *)(out->args.vc.data +
5911 l2tpv2_mask->hdr.common.flags_version = 0xFFFF;
5913 l2tpv2->hdr.common.flags_version =
5914 rte_cpu_to_be_16(l2tpv2->hdr.common.flags_version);
5915 l2tpv2_mask->hdr.common.flags_version =
5916 rte_cpu_to_be_16(l2tpv2_mask->hdr.common.flags_version);
5918 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
5919 item->spec = l2tpv2;
5920 item->mask = l2tpv2_mask;
5924 /** Parse meter color action type. */
5926 parse_vc_action_meter_color_type(struct context *ctx, const struct token *token,
5927 const char *str, unsigned int len,
5928 void *buf, unsigned int size)
5930 struct rte_flow_action *action_data;
5931 struct rte_flow_action_meter_color *conf;
5932 enum rte_color color;
5936 /* Token name must match. */
5937 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5939 switch (ctx->curr) {
5940 case ACTION_METER_COLOR_GREEN:
5941 color = RTE_COLOR_GREEN;
5943 case ACTION_METER_COLOR_YELLOW:
5944 color = RTE_COLOR_YELLOW;
5946 case ACTION_METER_COLOR_RED:
5947 color = RTE_COLOR_RED;
5955 action_data = ctx->object;
5956 conf = (struct rte_flow_action_meter_color *)
5957 (uintptr_t)(action_data->conf);
5958 conf->color = color;
5962 /** Parse RSS action. */
5964 parse_vc_action_rss(struct context *ctx, const struct token *token,
5965 const char *str, unsigned int len,
5966 void *buf, unsigned int size)
5968 struct buffer *out = buf;
5969 struct rte_flow_action *action;
5970 struct action_rss_data *action_rss_data;
5974 ret = parse_vc(ctx, token, str, len, buf, size);
5977 /* Nothing else to do if there is no buffer. */
5980 if (!out->args.vc.actions_n)
5982 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5983 /* Point to selected object. */
5984 ctx->object = out->args.vc.data;
5985 ctx->objmask = NULL;
5986 /* Set up default configuration. */
5987 action_rss_data = ctx->object;
5988 *action_rss_data = (struct action_rss_data){
5989 .conf = (struct rte_flow_action_rss){
5990 .func = RTE_ETH_HASH_FUNCTION_DEFAULT,
5994 .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM),
5996 .queue = action_rss_data->queue,
6000 for (i = 0; i < action_rss_data->conf.queue_num; ++i)
6001 action_rss_data->queue[i] = i;
6002 action->conf = &action_rss_data->conf;
6007 * Parse func field for RSS action.
6009 * The RTE_ETH_HASH_FUNCTION_* value to assign is derived from the
6010 * ACTION_RSS_FUNC_* index that called this function.
6013 parse_vc_action_rss_func(struct context *ctx, const struct token *token,
6014 const char *str, unsigned int len,
6015 void *buf, unsigned int size)
6017 struct action_rss_data *action_rss_data;
6018 enum rte_eth_hash_function func;
6022 /* Token name must match. */
6023 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6025 switch (ctx->curr) {
6026 case ACTION_RSS_FUNC_DEFAULT:
6027 func = RTE_ETH_HASH_FUNCTION_DEFAULT;
6029 case ACTION_RSS_FUNC_TOEPLITZ:
6030 func = RTE_ETH_HASH_FUNCTION_TOEPLITZ;
6032 case ACTION_RSS_FUNC_SIMPLE_XOR:
6033 func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
6035 case ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ:
6036 func = RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
6043 action_rss_data = ctx->object;
6044 action_rss_data->conf.func = func;
6049 * Parse type field for RSS action.
6051 * Valid tokens are type field names and the "end" token.
6054 parse_vc_action_rss_type(struct context *ctx, const struct token *token,
6055 const char *str, unsigned int len,
6056 void *buf, unsigned int size)
6058 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE);
6059 struct action_rss_data *action_rss_data;
6065 if (ctx->curr != ACTION_RSS_TYPE)
6067 if (!(ctx->objdata >> 16) && ctx->object) {
6068 action_rss_data = ctx->object;
6069 action_rss_data->conf.types = 0;
6071 if (!strcmp_partial("end", str, len)) {
6072 ctx->objdata &= 0xffff;
6075 for (i = 0; rss_type_table[i].str; ++i)
6076 if (!strcmp_partial(rss_type_table[i].str, str, len))
6078 if (!rss_type_table[i].str)
6080 ctx->objdata = 1 << 16 | (ctx->objdata & 0xffff);
6082 if (ctx->next_num == RTE_DIM(ctx->next))
6084 ctx->next[ctx->next_num++] = next;
6087 action_rss_data = ctx->object;
6088 action_rss_data->conf.types |= rss_type_table[i].rss_type;
6093 * Parse queue field for RSS action.
6095 * Valid tokens are queue indices and the "end" token.
6098 parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
6099 const char *str, unsigned int len,
6100 void *buf, unsigned int size)
6102 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE);
6103 struct action_rss_data *action_rss_data;
6104 const struct arg *arg;
6111 if (ctx->curr != ACTION_RSS_QUEUE)
6113 i = ctx->objdata >> 16;
6114 if (!strcmp_partial("end", str, len)) {
6115 ctx->objdata &= 0xffff;
6118 if (i >= ACTION_RSS_QUEUE_NUM)
6120 arg = ARGS_ENTRY_ARB(offsetof(struct action_rss_data, queue) +
6121 i * sizeof(action_rss_data->queue[i]),
6122 sizeof(action_rss_data->queue[i]));
6123 if (push_args(ctx, arg))
6125 ret = parse_int(ctx, token, str, len, NULL, 0);
6131 ctx->objdata = i << 16 | (ctx->objdata & 0xffff);
6133 if (ctx->next_num == RTE_DIM(ctx->next))
6135 ctx->next[ctx->next_num++] = next;
6139 action_rss_data = ctx->object;
6140 action_rss_data->conf.queue_num = i;
6141 action_rss_data->conf.queue = i ? action_rss_data->queue : NULL;
6145 /** Setup VXLAN encap configuration. */
6147 parse_setup_vxlan_encap_data(struct action_vxlan_encap_data *action_vxlan_encap_data)
6149 /* Set up default configuration. */
6150 *action_vxlan_encap_data = (struct action_vxlan_encap_data){
6151 .conf = (struct rte_flow_action_vxlan_encap){
6152 .definition = action_vxlan_encap_data->items,
6156 .type = RTE_FLOW_ITEM_TYPE_ETH,
6157 .spec = &action_vxlan_encap_data->item_eth,
6158 .mask = &rte_flow_item_eth_mask,
6161 .type = RTE_FLOW_ITEM_TYPE_VLAN,
6162 .spec = &action_vxlan_encap_data->item_vlan,
6163 .mask = &rte_flow_item_vlan_mask,
6166 .type = RTE_FLOW_ITEM_TYPE_IPV4,
6167 .spec = &action_vxlan_encap_data->item_ipv4,
6168 .mask = &rte_flow_item_ipv4_mask,
6171 .type = RTE_FLOW_ITEM_TYPE_UDP,
6172 .spec = &action_vxlan_encap_data->item_udp,
6173 .mask = &rte_flow_item_udp_mask,
6176 .type = RTE_FLOW_ITEM_TYPE_VXLAN,
6177 .spec = &action_vxlan_encap_data->item_vxlan,
6178 .mask = &rte_flow_item_vxlan_mask,
6181 .type = RTE_FLOW_ITEM_TYPE_END,
6186 .tci = vxlan_encap_conf.vlan_tci,
6190 .src_addr = vxlan_encap_conf.ipv4_src,
6191 .dst_addr = vxlan_encap_conf.ipv4_dst,
6194 .src_port = vxlan_encap_conf.udp_src,
6195 .dst_port = vxlan_encap_conf.udp_dst,
6197 .item_vxlan.flags = 0,
6199 memcpy(action_vxlan_encap_data->item_eth.dst.addr_bytes,
6200 vxlan_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
6201 memcpy(action_vxlan_encap_data->item_eth.src.addr_bytes,
6202 vxlan_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
6203 if (!vxlan_encap_conf.select_ipv4) {
6204 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.src_addr,
6205 &vxlan_encap_conf.ipv6_src,
6206 sizeof(vxlan_encap_conf.ipv6_src));
6207 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.dst_addr,
6208 &vxlan_encap_conf.ipv6_dst,
6209 sizeof(vxlan_encap_conf.ipv6_dst));
6210 action_vxlan_encap_data->items[2] = (struct rte_flow_item){
6211 .type = RTE_FLOW_ITEM_TYPE_IPV6,
6212 .spec = &action_vxlan_encap_data->item_ipv6,
6213 .mask = &rte_flow_item_ipv6_mask,
6216 if (!vxlan_encap_conf.select_vlan)
6217 action_vxlan_encap_data->items[1].type =
6218 RTE_FLOW_ITEM_TYPE_VOID;
6219 if (vxlan_encap_conf.select_tos_ttl) {
6220 if (vxlan_encap_conf.select_ipv4) {
6221 static struct rte_flow_item_ipv4 ipv4_mask_tos;
6223 memcpy(&ipv4_mask_tos, &rte_flow_item_ipv4_mask,
6224 sizeof(ipv4_mask_tos));
6225 ipv4_mask_tos.hdr.type_of_service = 0xff;
6226 ipv4_mask_tos.hdr.time_to_live = 0xff;
6227 action_vxlan_encap_data->item_ipv4.hdr.type_of_service =
6228 vxlan_encap_conf.ip_tos;
6229 action_vxlan_encap_data->item_ipv4.hdr.time_to_live =
6230 vxlan_encap_conf.ip_ttl;
6231 action_vxlan_encap_data->items[2].mask =
6234 static struct rte_flow_item_ipv6 ipv6_mask_tos;
6236 memcpy(&ipv6_mask_tos, &rte_flow_item_ipv6_mask,
6237 sizeof(ipv6_mask_tos));
6238 ipv6_mask_tos.hdr.vtc_flow |=
6239 RTE_BE32(0xfful << RTE_IPV6_HDR_TC_SHIFT);
6240 ipv6_mask_tos.hdr.hop_limits = 0xff;
6241 action_vxlan_encap_data->item_ipv6.hdr.vtc_flow |=
6243 ((uint32_t)vxlan_encap_conf.ip_tos <<
6244 RTE_IPV6_HDR_TC_SHIFT);
6245 action_vxlan_encap_data->item_ipv6.hdr.hop_limits =
6246 vxlan_encap_conf.ip_ttl;
6247 action_vxlan_encap_data->items[2].mask =
6251 memcpy(action_vxlan_encap_data->item_vxlan.vni, vxlan_encap_conf.vni,
6252 RTE_DIM(vxlan_encap_conf.vni));
6256 /** Parse VXLAN encap action. */
6258 parse_vc_action_vxlan_encap(struct context *ctx, const struct token *token,
6259 const char *str, unsigned int len,
6260 void *buf, unsigned int size)
6262 struct buffer *out = buf;
6263 struct rte_flow_action *action;
6264 struct action_vxlan_encap_data *action_vxlan_encap_data;
6267 ret = parse_vc(ctx, token, str, len, buf, size);
6270 /* Nothing else to do if there is no buffer. */
6273 if (!out->args.vc.actions_n)
6275 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6276 /* Point to selected object. */
6277 ctx->object = out->args.vc.data;
6278 ctx->objmask = NULL;
6279 action_vxlan_encap_data = ctx->object;
6280 parse_setup_vxlan_encap_data(action_vxlan_encap_data);
6281 action->conf = &action_vxlan_encap_data->conf;
6285 /** Setup NVGRE encap configuration. */
6287 parse_setup_nvgre_encap_data(struct action_nvgre_encap_data *action_nvgre_encap_data)
6289 /* Set up default configuration. */
6290 *action_nvgre_encap_data = (struct action_nvgre_encap_data){
6291 .conf = (struct rte_flow_action_nvgre_encap){
6292 .definition = action_nvgre_encap_data->items,
6296 .type = RTE_FLOW_ITEM_TYPE_ETH,
6297 .spec = &action_nvgre_encap_data->item_eth,
6298 .mask = &rte_flow_item_eth_mask,
6301 .type = RTE_FLOW_ITEM_TYPE_VLAN,
6302 .spec = &action_nvgre_encap_data->item_vlan,
6303 .mask = &rte_flow_item_vlan_mask,
6306 .type = RTE_FLOW_ITEM_TYPE_IPV4,
6307 .spec = &action_nvgre_encap_data->item_ipv4,
6308 .mask = &rte_flow_item_ipv4_mask,
6311 .type = RTE_FLOW_ITEM_TYPE_NVGRE,
6312 .spec = &action_nvgre_encap_data->item_nvgre,
6313 .mask = &rte_flow_item_nvgre_mask,
6316 .type = RTE_FLOW_ITEM_TYPE_END,
6321 .tci = nvgre_encap_conf.vlan_tci,
6325 .src_addr = nvgre_encap_conf.ipv4_src,
6326 .dst_addr = nvgre_encap_conf.ipv4_dst,
6328 .item_nvgre.c_k_s_rsvd0_ver = RTE_BE16(0x2000),
6329 .item_nvgre.protocol = RTE_BE16(RTE_ETHER_TYPE_TEB),
6330 .item_nvgre.flow_id = 0,
6332 memcpy(action_nvgre_encap_data->item_eth.dst.addr_bytes,
6333 nvgre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
6334 memcpy(action_nvgre_encap_data->item_eth.src.addr_bytes,
6335 nvgre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
6336 if (!nvgre_encap_conf.select_ipv4) {
6337 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.src_addr,
6338 &nvgre_encap_conf.ipv6_src,
6339 sizeof(nvgre_encap_conf.ipv6_src));
6340 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.dst_addr,
6341 &nvgre_encap_conf.ipv6_dst,
6342 sizeof(nvgre_encap_conf.ipv6_dst));
6343 action_nvgre_encap_data->items[2] = (struct rte_flow_item){
6344 .type = RTE_FLOW_ITEM_TYPE_IPV6,
6345 .spec = &action_nvgre_encap_data->item_ipv6,
6346 .mask = &rte_flow_item_ipv6_mask,
6349 if (!nvgre_encap_conf.select_vlan)
6350 action_nvgre_encap_data->items[1].type =
6351 RTE_FLOW_ITEM_TYPE_VOID;
6352 memcpy(action_nvgre_encap_data->item_nvgre.tni, nvgre_encap_conf.tni,
6353 RTE_DIM(nvgre_encap_conf.tni));
6357 /** Parse NVGRE encap action. */
6359 parse_vc_action_nvgre_encap(struct context *ctx, const struct token *token,
6360 const char *str, unsigned int len,
6361 void *buf, unsigned int size)
6363 struct buffer *out = buf;
6364 struct rte_flow_action *action;
6365 struct action_nvgre_encap_data *action_nvgre_encap_data;
6368 ret = parse_vc(ctx, token, str, len, buf, size);
6371 /* Nothing else to do if there is no buffer. */
6374 if (!out->args.vc.actions_n)
6376 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6377 /* Point to selected object. */
6378 ctx->object = out->args.vc.data;
6379 ctx->objmask = NULL;
6380 action_nvgre_encap_data = ctx->object;
6381 parse_setup_nvgre_encap_data(action_nvgre_encap_data);
6382 action->conf = &action_nvgre_encap_data->conf;
6386 /** Parse l2 encap action. */
6388 parse_vc_action_l2_encap(struct context *ctx, const struct token *token,
6389 const char *str, unsigned int len,
6390 void *buf, unsigned int size)
6392 struct buffer *out = buf;
6393 struct rte_flow_action *action;
6394 struct action_raw_encap_data *action_encap_data;
6395 struct rte_flow_item_eth eth = { .type = 0, };
6396 struct rte_flow_item_vlan vlan = {
6397 .tci = mplsoudp_encap_conf.vlan_tci,
6403 ret = parse_vc(ctx, token, str, len, buf, size);
6406 /* Nothing else to do if there is no buffer. */
6409 if (!out->args.vc.actions_n)
6411 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6412 /* Point to selected object. */
6413 ctx->object = out->args.vc.data;
6414 ctx->objmask = NULL;
6415 /* Copy the headers to the buffer. */
6416 action_encap_data = ctx->object;
6417 *action_encap_data = (struct action_raw_encap_data) {
6418 .conf = (struct rte_flow_action_raw_encap){
6419 .data = action_encap_data->data,
6423 header = action_encap_data->data;
6424 if (l2_encap_conf.select_vlan)
6425 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
6426 else if (l2_encap_conf.select_ipv4)
6427 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6429 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6430 memcpy(eth.dst.addr_bytes,
6431 l2_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
6432 memcpy(eth.src.addr_bytes,
6433 l2_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
6434 memcpy(header, ð, sizeof(eth));
6435 header += sizeof(eth);
6436 if (l2_encap_conf.select_vlan) {
6437 if (l2_encap_conf.select_ipv4)
6438 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6440 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6441 memcpy(header, &vlan, sizeof(vlan));
6442 header += sizeof(vlan);
6444 action_encap_data->conf.size = header -
6445 action_encap_data->data;
6446 action->conf = &action_encap_data->conf;
6450 /** Parse l2 decap action. */
6452 parse_vc_action_l2_decap(struct context *ctx, const struct token *token,
6453 const char *str, unsigned int len,
6454 void *buf, unsigned int size)
6456 struct buffer *out = buf;
6457 struct rte_flow_action *action;
6458 struct action_raw_decap_data *action_decap_data;
6459 struct rte_flow_item_eth eth = { .type = 0, };
6460 struct rte_flow_item_vlan vlan = {
6461 .tci = mplsoudp_encap_conf.vlan_tci,
6467 ret = parse_vc(ctx, token, str, len, buf, size);
6470 /* Nothing else to do if there is no buffer. */
6473 if (!out->args.vc.actions_n)
6475 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6476 /* Point to selected object. */
6477 ctx->object = out->args.vc.data;
6478 ctx->objmask = NULL;
6479 /* Copy the headers to the buffer. */
6480 action_decap_data = ctx->object;
6481 *action_decap_data = (struct action_raw_decap_data) {
6482 .conf = (struct rte_flow_action_raw_decap){
6483 .data = action_decap_data->data,
6487 header = action_decap_data->data;
6488 if (l2_decap_conf.select_vlan)
6489 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
6490 memcpy(header, ð, sizeof(eth));
6491 header += sizeof(eth);
6492 if (l2_decap_conf.select_vlan) {
6493 memcpy(header, &vlan, sizeof(vlan));
6494 header += sizeof(vlan);
6496 action_decap_data->conf.size = header -
6497 action_decap_data->data;
6498 action->conf = &action_decap_data->conf;
6502 #define ETHER_TYPE_MPLS_UNICAST 0x8847
6504 /** Parse MPLSOGRE encap action. */
6506 parse_vc_action_mplsogre_encap(struct context *ctx, const struct token *token,
6507 const char *str, unsigned int len,
6508 void *buf, unsigned int size)
6510 struct buffer *out = buf;
6511 struct rte_flow_action *action;
6512 struct action_raw_encap_data *action_encap_data;
6513 struct rte_flow_item_eth eth = { .type = 0, };
6514 struct rte_flow_item_vlan vlan = {
6515 .tci = mplsogre_encap_conf.vlan_tci,
6518 struct rte_flow_item_ipv4 ipv4 = {
6520 .src_addr = mplsogre_encap_conf.ipv4_src,
6521 .dst_addr = mplsogre_encap_conf.ipv4_dst,
6522 .next_proto_id = IPPROTO_GRE,
6523 .version_ihl = RTE_IPV4_VHL_DEF,
6524 .time_to_live = IPDEFTTL,
6527 struct rte_flow_item_ipv6 ipv6 = {
6529 .proto = IPPROTO_GRE,
6530 .hop_limits = IPDEFTTL,
6533 struct rte_flow_item_gre gre = {
6534 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
6536 struct rte_flow_item_mpls mpls = {
6542 ret = parse_vc(ctx, token, str, len, buf, size);
6545 /* Nothing else to do if there is no buffer. */
6548 if (!out->args.vc.actions_n)
6550 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6551 /* Point to selected object. */
6552 ctx->object = out->args.vc.data;
6553 ctx->objmask = NULL;
6554 /* Copy the headers to the buffer. */
6555 action_encap_data = ctx->object;
6556 *action_encap_data = (struct action_raw_encap_data) {
6557 .conf = (struct rte_flow_action_raw_encap){
6558 .data = action_encap_data->data,
6563 header = action_encap_data->data;
6564 if (mplsogre_encap_conf.select_vlan)
6565 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
6566 else if (mplsogre_encap_conf.select_ipv4)
6567 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6569 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6570 memcpy(eth.dst.addr_bytes,
6571 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
6572 memcpy(eth.src.addr_bytes,
6573 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
6574 memcpy(header, ð, sizeof(eth));
6575 header += sizeof(eth);
6576 if (mplsogre_encap_conf.select_vlan) {
6577 if (mplsogre_encap_conf.select_ipv4)
6578 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6580 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6581 memcpy(header, &vlan, sizeof(vlan));
6582 header += sizeof(vlan);
6584 if (mplsogre_encap_conf.select_ipv4) {
6585 memcpy(header, &ipv4, sizeof(ipv4));
6586 header += sizeof(ipv4);
6588 memcpy(&ipv6.hdr.src_addr,
6589 &mplsogre_encap_conf.ipv6_src,
6590 sizeof(mplsogre_encap_conf.ipv6_src));
6591 memcpy(&ipv6.hdr.dst_addr,
6592 &mplsogre_encap_conf.ipv6_dst,
6593 sizeof(mplsogre_encap_conf.ipv6_dst));
6594 memcpy(header, &ipv6, sizeof(ipv6));
6595 header += sizeof(ipv6);
6597 memcpy(header, &gre, sizeof(gre));
6598 header += sizeof(gre);
6599 memcpy(mpls.label_tc_s, mplsogre_encap_conf.label,
6600 RTE_DIM(mplsogre_encap_conf.label));
6601 mpls.label_tc_s[2] |= 0x1;
6602 memcpy(header, &mpls, sizeof(mpls));
6603 header += sizeof(mpls);
6604 action_encap_data->conf.size = header -
6605 action_encap_data->data;
6606 action->conf = &action_encap_data->conf;
6610 /** Parse MPLSOGRE decap action. */
6612 parse_vc_action_mplsogre_decap(struct context *ctx, const struct token *token,
6613 const char *str, unsigned int len,
6614 void *buf, unsigned int size)
6616 struct buffer *out = buf;
6617 struct rte_flow_action *action;
6618 struct action_raw_decap_data *action_decap_data;
6619 struct rte_flow_item_eth eth = { .type = 0, };
6620 struct rte_flow_item_vlan vlan = {.tci = 0};
6621 struct rte_flow_item_ipv4 ipv4 = {
6623 .next_proto_id = IPPROTO_GRE,
6626 struct rte_flow_item_ipv6 ipv6 = {
6628 .proto = IPPROTO_GRE,
6631 struct rte_flow_item_gre gre = {
6632 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
6634 struct rte_flow_item_mpls mpls;
6638 ret = parse_vc(ctx, token, str, len, buf, size);
6641 /* Nothing else to do if there is no buffer. */
6644 if (!out->args.vc.actions_n)
6646 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6647 /* Point to selected object. */
6648 ctx->object = out->args.vc.data;
6649 ctx->objmask = NULL;
6650 /* Copy the headers to the buffer. */
6651 action_decap_data = ctx->object;
6652 *action_decap_data = (struct action_raw_decap_data) {
6653 .conf = (struct rte_flow_action_raw_decap){
6654 .data = action_decap_data->data,
6658 header = action_decap_data->data;
6659 if (mplsogre_decap_conf.select_vlan)
6660 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
6661 else if (mplsogre_encap_conf.select_ipv4)
6662 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6664 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6665 memcpy(eth.dst.addr_bytes,
6666 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
6667 memcpy(eth.src.addr_bytes,
6668 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
6669 memcpy(header, ð, sizeof(eth));
6670 header += sizeof(eth);
6671 if (mplsogre_encap_conf.select_vlan) {
6672 if (mplsogre_encap_conf.select_ipv4)
6673 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6675 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6676 memcpy(header, &vlan, sizeof(vlan));
6677 header += sizeof(vlan);
6679 if (mplsogre_encap_conf.select_ipv4) {
6680 memcpy(header, &ipv4, sizeof(ipv4));
6681 header += sizeof(ipv4);
6683 memcpy(header, &ipv6, sizeof(ipv6));
6684 header += sizeof(ipv6);
6686 memcpy(header, &gre, sizeof(gre));
6687 header += sizeof(gre);
6688 memset(&mpls, 0, sizeof(mpls));
6689 memcpy(header, &mpls, sizeof(mpls));
6690 header += sizeof(mpls);
6691 action_decap_data->conf.size = header -
6692 action_decap_data->data;
6693 action->conf = &action_decap_data->conf;
6697 /** Parse MPLSOUDP encap action. */
6699 parse_vc_action_mplsoudp_encap(struct context *ctx, const struct token *token,
6700 const char *str, unsigned int len,
6701 void *buf, unsigned int size)
6703 struct buffer *out = buf;
6704 struct rte_flow_action *action;
6705 struct action_raw_encap_data *action_encap_data;
6706 struct rte_flow_item_eth eth = { .type = 0, };
6707 struct rte_flow_item_vlan vlan = {
6708 .tci = mplsoudp_encap_conf.vlan_tci,
6711 struct rte_flow_item_ipv4 ipv4 = {
6713 .src_addr = mplsoudp_encap_conf.ipv4_src,
6714 .dst_addr = mplsoudp_encap_conf.ipv4_dst,
6715 .next_proto_id = IPPROTO_UDP,
6716 .version_ihl = RTE_IPV4_VHL_DEF,
6717 .time_to_live = IPDEFTTL,
6720 struct rte_flow_item_ipv6 ipv6 = {
6722 .proto = IPPROTO_UDP,
6723 .hop_limits = IPDEFTTL,
6726 struct rte_flow_item_udp udp = {
6728 .src_port = mplsoudp_encap_conf.udp_src,
6729 .dst_port = mplsoudp_encap_conf.udp_dst,
6732 struct rte_flow_item_mpls mpls;
6736 ret = parse_vc(ctx, token, str, len, buf, size);
6739 /* Nothing else to do if there is no buffer. */
6742 if (!out->args.vc.actions_n)
6744 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6745 /* Point to selected object. */
6746 ctx->object = out->args.vc.data;
6747 ctx->objmask = NULL;
6748 /* Copy the headers to the buffer. */
6749 action_encap_data = ctx->object;
6750 *action_encap_data = (struct action_raw_encap_data) {
6751 .conf = (struct rte_flow_action_raw_encap){
6752 .data = action_encap_data->data,
6757 header = action_encap_data->data;
6758 if (mplsoudp_encap_conf.select_vlan)
6759 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
6760 else if (mplsoudp_encap_conf.select_ipv4)
6761 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6763 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6764 memcpy(eth.dst.addr_bytes,
6765 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
6766 memcpy(eth.src.addr_bytes,
6767 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
6768 memcpy(header, ð, sizeof(eth));
6769 header += sizeof(eth);
6770 if (mplsoudp_encap_conf.select_vlan) {
6771 if (mplsoudp_encap_conf.select_ipv4)
6772 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6774 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6775 memcpy(header, &vlan, sizeof(vlan));
6776 header += sizeof(vlan);
6778 if (mplsoudp_encap_conf.select_ipv4) {
6779 memcpy(header, &ipv4, sizeof(ipv4));
6780 header += sizeof(ipv4);
6782 memcpy(&ipv6.hdr.src_addr,
6783 &mplsoudp_encap_conf.ipv6_src,
6784 sizeof(mplsoudp_encap_conf.ipv6_src));
6785 memcpy(&ipv6.hdr.dst_addr,
6786 &mplsoudp_encap_conf.ipv6_dst,
6787 sizeof(mplsoudp_encap_conf.ipv6_dst));
6788 memcpy(header, &ipv6, sizeof(ipv6));
6789 header += sizeof(ipv6);
6791 memcpy(header, &udp, sizeof(udp));
6792 header += sizeof(udp);
6793 memcpy(mpls.label_tc_s, mplsoudp_encap_conf.label,
6794 RTE_DIM(mplsoudp_encap_conf.label));
6795 mpls.label_tc_s[2] |= 0x1;
6796 memcpy(header, &mpls, sizeof(mpls));
6797 header += sizeof(mpls);
6798 action_encap_data->conf.size = header -
6799 action_encap_data->data;
6800 action->conf = &action_encap_data->conf;
6804 /** Parse MPLSOUDP decap action. */
6806 parse_vc_action_mplsoudp_decap(struct context *ctx, const struct token *token,
6807 const char *str, unsigned int len,
6808 void *buf, unsigned int size)
6810 struct buffer *out = buf;
6811 struct rte_flow_action *action;
6812 struct action_raw_decap_data *action_decap_data;
6813 struct rte_flow_item_eth eth = { .type = 0, };
6814 struct rte_flow_item_vlan vlan = {.tci = 0};
6815 struct rte_flow_item_ipv4 ipv4 = {
6817 .next_proto_id = IPPROTO_UDP,
6820 struct rte_flow_item_ipv6 ipv6 = {
6822 .proto = IPPROTO_UDP,
6825 struct rte_flow_item_udp udp = {
6827 .dst_port = rte_cpu_to_be_16(6635),
6830 struct rte_flow_item_mpls mpls;
6834 ret = parse_vc(ctx, token, str, len, buf, size);
6837 /* Nothing else to do if there is no buffer. */
6840 if (!out->args.vc.actions_n)
6842 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6843 /* Point to selected object. */
6844 ctx->object = out->args.vc.data;
6845 ctx->objmask = NULL;
6846 /* Copy the headers to the buffer. */
6847 action_decap_data = ctx->object;
6848 *action_decap_data = (struct action_raw_decap_data) {
6849 .conf = (struct rte_flow_action_raw_decap){
6850 .data = action_decap_data->data,
6854 header = action_decap_data->data;
6855 if (mplsoudp_decap_conf.select_vlan)
6856 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
6857 else if (mplsoudp_encap_conf.select_ipv4)
6858 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6860 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6861 memcpy(eth.dst.addr_bytes,
6862 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
6863 memcpy(eth.src.addr_bytes,
6864 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
6865 memcpy(header, ð, sizeof(eth));
6866 header += sizeof(eth);
6867 if (mplsoudp_encap_conf.select_vlan) {
6868 if (mplsoudp_encap_conf.select_ipv4)
6869 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6871 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6872 memcpy(header, &vlan, sizeof(vlan));
6873 header += sizeof(vlan);
6875 if (mplsoudp_encap_conf.select_ipv4) {
6876 memcpy(header, &ipv4, sizeof(ipv4));
6877 header += sizeof(ipv4);
6879 memcpy(header, &ipv6, sizeof(ipv6));
6880 header += sizeof(ipv6);
6882 memcpy(header, &udp, sizeof(udp));
6883 header += sizeof(udp);
6884 memset(&mpls, 0, sizeof(mpls));
6885 memcpy(header, &mpls, sizeof(mpls));
6886 header += sizeof(mpls);
6887 action_decap_data->conf.size = header -
6888 action_decap_data->data;
6889 action->conf = &action_decap_data->conf;
6894 parse_vc_action_raw_decap_index(struct context *ctx, const struct token *token,
6895 const char *str, unsigned int len, void *buf,
6898 struct action_raw_decap_data *action_raw_decap_data;
6899 struct rte_flow_action *action;
6900 const struct arg *arg;
6901 struct buffer *out = buf;
6905 RTE_SET_USED(token);
6908 arg = ARGS_ENTRY_ARB_BOUNDED
6909 (offsetof(struct action_raw_decap_data, idx),
6910 sizeof(((struct action_raw_decap_data *)0)->idx),
6911 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
6912 if (push_args(ctx, arg))
6914 ret = parse_int(ctx, token, str, len, NULL, 0);
6921 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6922 action_raw_decap_data = ctx->object;
6923 idx = action_raw_decap_data->idx;
6924 action_raw_decap_data->conf.data = raw_decap_confs[idx].data;
6925 action_raw_decap_data->conf.size = raw_decap_confs[idx].size;
6926 action->conf = &action_raw_decap_data->conf;
6932 parse_vc_action_raw_encap_index(struct context *ctx, const struct token *token,
6933 const char *str, unsigned int len, void *buf,
6936 struct action_raw_encap_data *action_raw_encap_data;
6937 struct rte_flow_action *action;
6938 const struct arg *arg;
6939 struct buffer *out = buf;
6943 RTE_SET_USED(token);
6946 if (ctx->curr != ACTION_RAW_ENCAP_INDEX_VALUE)
6948 arg = ARGS_ENTRY_ARB_BOUNDED
6949 (offsetof(struct action_raw_encap_data, idx),
6950 sizeof(((struct action_raw_encap_data *)0)->idx),
6951 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
6952 if (push_args(ctx, arg))
6954 ret = parse_int(ctx, token, str, len, NULL, 0);
6961 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6962 action_raw_encap_data = ctx->object;
6963 idx = action_raw_encap_data->idx;
6964 action_raw_encap_data->conf.data = raw_encap_confs[idx].data;
6965 action_raw_encap_data->conf.size = raw_encap_confs[idx].size;
6966 action_raw_encap_data->conf.preserve = NULL;
6967 action->conf = &action_raw_encap_data->conf;
6972 parse_vc_action_raw_encap(struct context *ctx, const struct token *token,
6973 const char *str, unsigned int len, void *buf,
6976 struct buffer *out = buf;
6977 struct rte_flow_action *action;
6978 struct action_raw_encap_data *action_raw_encap_data = NULL;
6981 ret = parse_vc(ctx, token, str, len, buf, size);
6984 /* Nothing else to do if there is no buffer. */
6987 if (!out->args.vc.actions_n)
6989 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6990 /* Point to selected object. */
6991 ctx->object = out->args.vc.data;
6992 ctx->objmask = NULL;
6993 /* Copy the headers to the buffer. */
6994 action_raw_encap_data = ctx->object;
6995 action_raw_encap_data->conf.data = raw_encap_confs[0].data;
6996 action_raw_encap_data->conf.preserve = NULL;
6997 action_raw_encap_data->conf.size = raw_encap_confs[0].size;
6998 action->conf = &action_raw_encap_data->conf;
7003 parse_vc_action_raw_decap(struct context *ctx, const struct token *token,
7004 const char *str, unsigned int len, void *buf,
7007 struct buffer *out = buf;
7008 struct rte_flow_action *action;
7009 struct action_raw_decap_data *action_raw_decap_data = NULL;
7012 ret = parse_vc(ctx, token, str, len, buf, size);
7015 /* Nothing else to do if there is no buffer. */
7018 if (!out->args.vc.actions_n)
7020 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
7021 /* Point to selected object. */
7022 ctx->object = out->args.vc.data;
7023 ctx->objmask = NULL;
7024 /* Copy the headers to the buffer. */
7025 action_raw_decap_data = ctx->object;
7026 action_raw_decap_data->conf.data = raw_decap_confs[0].data;
7027 action_raw_decap_data->conf.size = raw_decap_confs[0].size;
7028 action->conf = &action_raw_decap_data->conf;
7033 parse_vc_action_set_meta(struct context *ctx, const struct token *token,
7034 const char *str, unsigned int len, void *buf,
7039 ret = parse_vc(ctx, token, str, len, buf, size);
7042 ret = rte_flow_dynf_metadata_register();
7049 parse_vc_action_sample(struct context *ctx, const struct token *token,
7050 const char *str, unsigned int len, void *buf,
7053 struct buffer *out = buf;
7054 struct rte_flow_action *action;
7055 struct action_sample_data *action_sample_data = NULL;
7056 static struct rte_flow_action end_action = {
7057 RTE_FLOW_ACTION_TYPE_END, 0
7061 ret = parse_vc(ctx, token, str, len, buf, size);
7064 /* Nothing else to do if there is no buffer. */
7067 if (!out->args.vc.actions_n)
7069 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
7070 /* Point to selected object. */
7071 ctx->object = out->args.vc.data;
7072 ctx->objmask = NULL;
7073 /* Copy the headers to the buffer. */
7074 action_sample_data = ctx->object;
7075 action_sample_data->conf.actions = &end_action;
7076 action->conf = &action_sample_data->conf;
7081 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
7082 const char *str, unsigned int len, void *buf,
7085 struct action_sample_data *action_sample_data;
7086 struct rte_flow_action *action;
7087 const struct arg *arg;
7088 struct buffer *out = buf;
7092 RTE_SET_USED(token);
7095 if (ctx->curr != ACTION_SAMPLE_INDEX_VALUE)
7097 arg = ARGS_ENTRY_ARB_BOUNDED
7098 (offsetof(struct action_sample_data, idx),
7099 sizeof(((struct action_sample_data *)0)->idx),
7100 0, RAW_SAMPLE_CONFS_MAX_NUM - 1);
7101 if (push_args(ctx, arg))
7103 ret = parse_int(ctx, token, str, len, NULL, 0);
7110 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
7111 action_sample_data = ctx->object;
7112 idx = action_sample_data->idx;
7113 action_sample_data->conf.actions = raw_sample_confs[idx].data;
7114 action->conf = &action_sample_data->conf;
7118 /** Parse operation for modify_field command. */
7120 parse_vc_modify_field_op(struct context *ctx, const struct token *token,
7121 const char *str, unsigned int len, void *buf,
7124 struct rte_flow_action_modify_field *action_modify_field;
7130 if (ctx->curr != ACTION_MODIFY_FIELD_OP_VALUE)
7132 for (i = 0; modify_field_ops[i]; ++i)
7133 if (!strcmp_partial(modify_field_ops[i], str, len))
7135 if (!modify_field_ops[i])
7139 action_modify_field = ctx->object;
7140 action_modify_field->operation = (enum rte_flow_modify_op)i;
7144 /** Parse id for modify_field command. */
7146 parse_vc_modify_field_id(struct context *ctx, const struct token *token,
7147 const char *str, unsigned int len, void *buf,
7150 struct rte_flow_action_modify_field *action_modify_field;
7156 if (ctx->curr != ACTION_MODIFY_FIELD_DST_TYPE_VALUE &&
7157 ctx->curr != ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)
7159 for (i = 0; modify_field_ids[i]; ++i)
7160 if (!strcmp_partial(modify_field_ids[i], str, len))
7162 if (!modify_field_ids[i])
7166 action_modify_field = ctx->object;
7167 if (ctx->curr == ACTION_MODIFY_FIELD_DST_TYPE_VALUE)
7168 action_modify_field->dst.field = (enum rte_flow_field_id)i;
7170 action_modify_field->src.field = (enum rte_flow_field_id)i;
7174 /** Parse the conntrack update, not a rte_flow_action. */
7176 parse_vc_action_conntrack_update(struct context *ctx, const struct token *token,
7177 const char *str, unsigned int len, void *buf,
7180 struct buffer *out = buf;
7181 struct rte_flow_modify_conntrack *ct_modify = NULL;
7184 if (ctx->curr != ACTION_CONNTRACK_UPDATE_CTX &&
7185 ctx->curr != ACTION_CONNTRACK_UPDATE_DIR)
7187 /* Token name must match. */
7188 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7190 /* Nothing else to do if there is no buffer. */
7193 ct_modify = (struct rte_flow_modify_conntrack *)out->args.vc.data;
7194 if (ctx->curr == ACTION_CONNTRACK_UPDATE_DIR) {
7195 ct_modify->new_ct.is_original_dir =
7196 conntrack_context.is_original_dir;
7197 ct_modify->direction = 1;
7201 old_dir = ct_modify->new_ct.is_original_dir;
7202 memcpy(&ct_modify->new_ct, &conntrack_context,
7203 sizeof(conntrack_context));
7204 ct_modify->new_ct.is_original_dir = old_dir;
7205 ct_modify->state = 1;
7210 /** Parse tokens for destroy command. */
7212 parse_destroy(struct context *ctx, const struct token *token,
7213 const char *str, unsigned int len,
7214 void *buf, unsigned int size)
7216 struct buffer *out = buf;
7218 /* Token name must match. */
7219 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7221 /* Nothing else to do if there is no buffer. */
7224 if (!out->command) {
7225 if (ctx->curr != DESTROY)
7227 if (sizeof(*out) > size)
7229 out->command = ctx->curr;
7232 ctx->objmask = NULL;
7233 out->args.destroy.rule =
7234 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7238 if (((uint8_t *)(out->args.destroy.rule + out->args.destroy.rule_n) +
7239 sizeof(*out->args.destroy.rule)) > (uint8_t *)out + size)
7242 ctx->object = out->args.destroy.rule + out->args.destroy.rule_n++;
7243 ctx->objmask = NULL;
7247 /** Parse tokens for flush command. */
7249 parse_flush(struct context *ctx, const struct token *token,
7250 const char *str, unsigned int len,
7251 void *buf, unsigned int size)
7253 struct buffer *out = buf;
7255 /* Token name must match. */
7256 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7258 /* Nothing else to do if there is no buffer. */
7261 if (!out->command) {
7262 if (ctx->curr != FLUSH)
7264 if (sizeof(*out) > size)
7266 out->command = ctx->curr;
7269 ctx->objmask = NULL;
7274 /** Parse tokens for dump command. */
7276 parse_dump(struct context *ctx, const struct token *token,
7277 const char *str, unsigned int len,
7278 void *buf, unsigned int size)
7280 struct buffer *out = buf;
7282 /* Token name must match. */
7283 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7285 /* Nothing else to do if there is no buffer. */
7288 if (!out->command) {
7289 if (ctx->curr != DUMP)
7291 if (sizeof(*out) > size)
7293 out->command = ctx->curr;
7296 ctx->objmask = NULL;
7299 switch (ctx->curr) {
7302 out->args.dump.mode = (ctx->curr == DUMP_ALL) ? true : false;
7303 out->command = ctx->curr;
7306 ctx->objmask = NULL;
7313 /** Parse tokens for query command. */
7315 parse_query(struct context *ctx, const struct token *token,
7316 const char *str, unsigned int len,
7317 void *buf, unsigned int size)
7319 struct buffer *out = buf;
7321 /* Token name must match. */
7322 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7324 /* Nothing else to do if there is no buffer. */
7327 if (!out->command) {
7328 if (ctx->curr != QUERY)
7330 if (sizeof(*out) > size)
7332 out->command = ctx->curr;
7335 ctx->objmask = NULL;
7340 /** Parse action names. */
7342 parse_action(struct context *ctx, const struct token *token,
7343 const char *str, unsigned int len,
7344 void *buf, unsigned int size)
7346 struct buffer *out = buf;
7347 const struct arg *arg = pop_args(ctx);
7351 /* Argument is expected. */
7354 /* Parse action name. */
7355 for (i = 0; next_action[i]; ++i) {
7356 const struct parse_action_priv *priv;
7358 token = &token_list[next_action[i]];
7359 if (strcmp_partial(token->name, str, len))
7365 memcpy((uint8_t *)ctx->object + arg->offset,
7371 push_args(ctx, arg);
7375 /** Parse tokens for list command. */
7377 parse_list(struct context *ctx, const struct token *token,
7378 const char *str, unsigned int len,
7379 void *buf, unsigned int size)
7381 struct buffer *out = buf;
7383 /* Token name must match. */
7384 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7386 /* Nothing else to do if there is no buffer. */
7389 if (!out->command) {
7390 if (ctx->curr != LIST)
7392 if (sizeof(*out) > size)
7394 out->command = ctx->curr;
7397 ctx->objmask = NULL;
7398 out->args.list.group =
7399 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7403 if (((uint8_t *)(out->args.list.group + out->args.list.group_n) +
7404 sizeof(*out->args.list.group)) > (uint8_t *)out + size)
7407 ctx->object = out->args.list.group + out->args.list.group_n++;
7408 ctx->objmask = NULL;
7412 /** Parse tokens for list all aged flows command. */
7414 parse_aged(struct context *ctx, const struct token *token,
7415 const char *str, unsigned int len,
7416 void *buf, unsigned int size)
7418 struct buffer *out = buf;
7420 /* Token name must match. */
7421 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7423 /* Nothing else to do if there is no buffer. */
7426 if (!out->command) {
7427 if (ctx->curr != AGED)
7429 if (sizeof(*out) > size)
7431 out->command = ctx->curr;
7434 ctx->objmask = NULL;
7436 if (ctx->curr == AGED_DESTROY)
7437 out->args.aged.destroy = 1;
7441 /** Parse tokens for isolate command. */
7443 parse_isolate(struct context *ctx, const struct token *token,
7444 const char *str, unsigned int len,
7445 void *buf, unsigned int size)
7447 struct buffer *out = buf;
7449 /* Token name must match. */
7450 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7452 /* Nothing else to do if there is no buffer. */
7455 if (!out->command) {
7456 if (ctx->curr != ISOLATE)
7458 if (sizeof(*out) > size)
7460 out->command = ctx->curr;
7463 ctx->objmask = NULL;
7469 parse_flex(struct context *ctx, const struct token *token,
7470 const char *str, unsigned int len,
7471 void *buf, unsigned int size)
7473 struct buffer *out = buf;
7475 /* Token name must match. */
7476 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7478 /* Nothing else to do if there is no buffer. */
7481 if (out->command == ZERO) {
7482 if (ctx->curr != FLEX)
7484 if (sizeof(*out) > size)
7486 out->command = ctx->curr;
7489 ctx->objmask = NULL;
7491 switch (ctx->curr) {
7494 case FLEX_ITEM_INIT:
7495 case FLEX_ITEM_CREATE:
7496 case FLEX_ITEM_DESTROY:
7497 out->command = ctx->curr;
7506 parse_tunnel(struct context *ctx, const struct token *token,
7507 const char *str, unsigned int len,
7508 void *buf, unsigned int size)
7510 struct buffer *out = buf;
7512 /* Token name must match. */
7513 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7515 /* Nothing else to do if there is no buffer. */
7518 if (!out->command) {
7519 if (ctx->curr != TUNNEL)
7521 if (sizeof(*out) > size)
7523 out->command = ctx->curr;
7526 ctx->objmask = NULL;
7528 switch (ctx->curr) {
7532 case TUNNEL_DESTROY:
7534 out->command = ctx->curr;
7536 case TUNNEL_CREATE_TYPE:
7537 case TUNNEL_DESTROY_ID:
7538 ctx->object = &out->args.vc.tunnel_ops;
7547 * Parse signed/unsigned integers 8 to 64-bit long.
7549 * Last argument (ctx->args) is retrieved to determine integer type and
7553 parse_int(struct context *ctx, const struct token *token,
7554 const char *str, unsigned int len,
7555 void *buf, unsigned int size)
7557 const struct arg *arg = pop_args(ctx);
7562 /* Argument is expected. */
7567 (uintmax_t)strtoimax(str, &end, 0) :
7568 strtoumax(str, &end, 0);
7569 if (errno || (size_t)(end - str) != len)
7572 ((arg->sign && ((intmax_t)u < (intmax_t)arg->min ||
7573 (intmax_t)u > (intmax_t)arg->max)) ||
7574 (!arg->sign && (u < arg->min || u > arg->max))))
7579 if (!arg_entry_bf_fill(ctx->object, u, arg) ||
7580 !arg_entry_bf_fill(ctx->objmask, -1, arg))
7584 buf = (uint8_t *)ctx->object + arg->offset;
7586 if (u > RTE_LEN2MASK(size * CHAR_BIT, uint64_t))
7590 case sizeof(uint8_t):
7591 *(uint8_t *)buf = u;
7593 case sizeof(uint16_t):
7594 *(uint16_t *)buf = arg->hton ? rte_cpu_to_be_16(u) : u;
7596 case sizeof(uint8_t [3]):
7597 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
7599 ((uint8_t *)buf)[0] = u;
7600 ((uint8_t *)buf)[1] = u >> 8;
7601 ((uint8_t *)buf)[2] = u >> 16;
7605 ((uint8_t *)buf)[0] = u >> 16;
7606 ((uint8_t *)buf)[1] = u >> 8;
7607 ((uint8_t *)buf)[2] = u;
7609 case sizeof(uint32_t):
7610 *(uint32_t *)buf = arg->hton ? rte_cpu_to_be_32(u) : u;
7612 case sizeof(uint64_t):
7613 *(uint64_t *)buf = arg->hton ? rte_cpu_to_be_64(u) : u;
7618 if (ctx->objmask && buf != (uint8_t *)ctx->objmask + arg->offset) {
7620 buf = (uint8_t *)ctx->objmask + arg->offset;
7625 push_args(ctx, arg);
7632 * Three arguments (ctx->args) are retrieved from the stack to store data,
7633 * its actual length and address (in that order).
7636 parse_string(struct context *ctx, const struct token *token,
7637 const char *str, unsigned int len,
7638 void *buf, unsigned int size)
7640 const struct arg *arg_data = pop_args(ctx);
7641 const struct arg *arg_len = pop_args(ctx);
7642 const struct arg *arg_addr = pop_args(ctx);
7643 char tmp[16]; /* Ought to be enough. */
7646 /* Arguments are expected. */
7650 push_args(ctx, arg_data);
7654 push_args(ctx, arg_len);
7655 push_args(ctx, arg_data);
7658 size = arg_data->size;
7659 /* Bit-mask fill is not supported. */
7660 if (arg_data->mask || size < len)
7664 /* Let parse_int() fill length information first. */
7665 ret = snprintf(tmp, sizeof(tmp), "%u", len);
7668 push_args(ctx, arg_len);
7669 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
7674 buf = (uint8_t *)ctx->object + arg_data->offset;
7675 /* Output buffer is not necessarily NUL-terminated. */
7676 memcpy(buf, str, len);
7677 memset((uint8_t *)buf + len, 0x00, size - len);
7679 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
7680 /* Save address if requested. */
7681 if (arg_addr->size) {
7682 memcpy((uint8_t *)ctx->object + arg_addr->offset,
7684 (uint8_t *)ctx->object + arg_data->offset
7688 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
7690 (uint8_t *)ctx->objmask + arg_data->offset
7696 push_args(ctx, arg_addr);
7697 push_args(ctx, arg_len);
7698 push_args(ctx, arg_data);
7703 parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
7709 /* Check input parameters */
7710 if ((src == NULL) ||
7716 /* Convert chars to bytes */
7717 for (i = 0, len = 0; i < *size; i += 2) {
7718 snprintf(tmp, 3, "%s", src + i);
7719 dst[len++] = strtoul(tmp, &c, 16);
7734 parse_hex(struct context *ctx, const struct token *token,
7735 const char *str, unsigned int len,
7736 void *buf, unsigned int size)
7738 const struct arg *arg_data = pop_args(ctx);
7739 const struct arg *arg_len = pop_args(ctx);
7740 const struct arg *arg_addr = pop_args(ctx);
7741 char tmp[16]; /* Ought to be enough. */
7743 unsigned int hexlen = len;
7744 unsigned int length = 256;
7745 uint8_t hex_tmp[length];
7747 /* Arguments are expected. */
7751 push_args(ctx, arg_data);
7755 push_args(ctx, arg_len);
7756 push_args(ctx, arg_data);
7759 size = arg_data->size;
7760 /* Bit-mask fill is not supported. */
7766 /* translate bytes string to array. */
7767 if (str[0] == '0' && ((str[1] == 'x') ||
7772 if (hexlen > length)
7774 ret = parse_hex_string(str, hex_tmp, &hexlen);
7777 /* Check the converted binary fits into data buffer. */
7780 /* Let parse_int() fill length information first. */
7781 ret = snprintf(tmp, sizeof(tmp), "%u", hexlen);
7784 /* Save length if requested. */
7785 if (arg_len->size) {
7786 push_args(ctx, arg_len);
7787 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
7793 buf = (uint8_t *)ctx->object + arg_data->offset;
7794 /* Output buffer is not necessarily NUL-terminated. */
7795 memcpy(buf, hex_tmp, hexlen);
7796 memset((uint8_t *)buf + hexlen, 0x00, size - hexlen);
7798 memset((uint8_t *)ctx->objmask + arg_data->offset,
7800 /* Save address if requested. */
7801 if (arg_addr->size) {
7802 memcpy((uint8_t *)ctx->object + arg_addr->offset,
7804 (uint8_t *)ctx->object + arg_data->offset
7808 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
7810 (uint8_t *)ctx->objmask + arg_data->offset
7816 push_args(ctx, arg_addr);
7817 push_args(ctx, arg_len);
7818 push_args(ctx, arg_data);
7824 * Parse a zero-ended string.
7827 parse_string0(struct context *ctx, const struct token *token __rte_unused,
7828 const char *str, unsigned int len,
7829 void *buf, unsigned int size)
7831 const struct arg *arg_data = pop_args(ctx);
7833 /* Arguments are expected. */
7836 size = arg_data->size;
7837 /* Bit-mask fill is not supported. */
7838 if (arg_data->mask || size < len + 1)
7842 buf = (uint8_t *)ctx->object + arg_data->offset;
7843 strncpy(buf, str, len);
7845 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
7848 push_args(ctx, arg_data);
7853 * Parse a MAC address.
7855 * Last argument (ctx->args) is retrieved to determine storage size and
7859 parse_mac_addr(struct context *ctx, const struct token *token,
7860 const char *str, unsigned int len,
7861 void *buf, unsigned int size)
7863 const struct arg *arg = pop_args(ctx);
7864 struct rte_ether_addr tmp;
7868 /* Argument is expected. */
7872 /* Bit-mask fill is not supported. */
7873 if (arg->mask || size != sizeof(tmp))
7875 /* Only network endian is supported. */
7878 ret = cmdline_parse_etheraddr(NULL, str, &tmp, size);
7879 if (ret < 0 || (unsigned int)ret != len)
7883 buf = (uint8_t *)ctx->object + arg->offset;
7884 memcpy(buf, &tmp, size);
7886 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
7889 push_args(ctx, arg);
7894 * Parse an IPv4 address.
7896 * Last argument (ctx->args) is retrieved to determine storage size and
7900 parse_ipv4_addr(struct context *ctx, const struct token *token,
7901 const char *str, unsigned int len,
7902 void *buf, unsigned int size)
7904 const struct arg *arg = pop_args(ctx);
7909 /* Argument is expected. */
7913 /* Bit-mask fill is not supported. */
7914 if (arg->mask || size != sizeof(tmp))
7916 /* Only network endian is supported. */
7919 memcpy(str2, str, len);
7921 ret = inet_pton(AF_INET, str2, &tmp);
7923 /* Attempt integer parsing. */
7924 push_args(ctx, arg);
7925 return parse_int(ctx, token, str, len, buf, size);
7929 buf = (uint8_t *)ctx->object + arg->offset;
7930 memcpy(buf, &tmp, size);
7932 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
7935 push_args(ctx, arg);
7940 * Parse an IPv6 address.
7942 * Last argument (ctx->args) is retrieved to determine storage size and
7946 parse_ipv6_addr(struct context *ctx, const struct token *token,
7947 const char *str, unsigned int len,
7948 void *buf, unsigned int size)
7950 const struct arg *arg = pop_args(ctx);
7952 struct in6_addr tmp;
7956 /* Argument is expected. */
7960 /* Bit-mask fill is not supported. */
7961 if (arg->mask || size != sizeof(tmp))
7963 /* Only network endian is supported. */
7966 memcpy(str2, str, len);
7968 ret = inet_pton(AF_INET6, str2, &tmp);
7973 buf = (uint8_t *)ctx->object + arg->offset;
7974 memcpy(buf, &tmp, size);
7976 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
7979 push_args(ctx, arg);
7983 /** Boolean values (even indices stand for false). */
7984 static const char *const boolean_name[] = {
7994 * Parse a boolean value.
7996 * Last argument (ctx->args) is retrieved to determine storage size and
8000 parse_boolean(struct context *ctx, const struct token *token,
8001 const char *str, unsigned int len,
8002 void *buf, unsigned int size)
8004 const struct arg *arg = pop_args(ctx);
8008 /* Argument is expected. */
8011 for (i = 0; boolean_name[i]; ++i)
8012 if (!strcmp_partial(boolean_name[i], str, len))
8014 /* Process token as integer. */
8015 if (boolean_name[i])
8016 str = i & 1 ? "1" : "0";
8017 push_args(ctx, arg);
8018 ret = parse_int(ctx, token, str, strlen(str), buf, size);
8019 return ret > 0 ? (int)len : ret;
8022 /** Parse port and update context. */
8024 parse_port(struct context *ctx, const struct token *token,
8025 const char *str, unsigned int len,
8026 void *buf, unsigned int size)
8028 struct buffer *out = &(struct buffer){ .port = 0 };
8036 ctx->objmask = NULL;
8037 size = sizeof(*out);
8039 ret = parse_int(ctx, token, str, len, out, size);
8041 ctx->port = out->port;
8048 parse_ia_id2ptr(struct context *ctx, const struct token *token,
8049 const char *str, unsigned int len,
8050 void *buf, unsigned int size)
8052 struct rte_flow_action *action = ctx->object;
8060 ctx->objmask = NULL;
8061 ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
8062 ctx->object = action;
8063 if (ret != (int)len)
8065 /* set indirect action */
8067 action->conf = port_action_handle_get_by_id(ctx->port, id);
8068 ret = (action->conf) ? ret : -1;
8073 /** Parse set command, initialize output buffer for subsequent tokens. */
8075 parse_set_raw_encap_decap(struct context *ctx, const struct token *token,
8076 const char *str, unsigned int len,
8077 void *buf, unsigned int size)
8079 struct buffer *out = buf;
8081 /* Token name must match. */
8082 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8084 /* Nothing else to do if there is no buffer. */
8087 /* Make sure buffer is large enough. */
8088 if (size < sizeof(*out))
8091 ctx->objmask = NULL;
8095 out->command = ctx->curr;
8096 /* For encap/decap we need is pattern */
8097 out->args.vc.pattern = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8102 /** Parse set command, initialize output buffer for subsequent tokens. */
8104 parse_set_sample_action(struct context *ctx, const struct token *token,
8105 const char *str, unsigned int len,
8106 void *buf, unsigned int size)
8108 struct buffer *out = buf;
8110 /* Token name must match. */
8111 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8113 /* Nothing else to do if there is no buffer. */
8116 /* Make sure buffer is large enough. */
8117 if (size < sizeof(*out))
8120 ctx->objmask = NULL;
8124 out->command = ctx->curr;
8125 /* For sampler we need is actions */
8126 out->args.vc.actions = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8132 * Parse set raw_encap/raw_decap command,
8133 * initialize output buffer for subsequent tokens.
8136 parse_set_init(struct context *ctx, const struct token *token,
8137 const char *str, unsigned int len,
8138 void *buf, unsigned int size)
8140 struct buffer *out = buf;
8142 /* Token name must match. */
8143 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8145 /* Nothing else to do if there is no buffer. */
8148 /* Make sure buffer is large enough. */
8149 if (size < sizeof(*out))
8151 /* Initialize buffer. */
8152 memset(out, 0x00, sizeof(*out));
8153 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
8156 ctx->objmask = NULL;
8157 if (!out->command) {
8158 if (ctx->curr != SET)
8160 if (sizeof(*out) > size)
8162 out->command = ctx->curr;
8163 out->args.vc.data = (uint8_t *)out + size;
8164 ctx->object = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8171 * Replace testpmd handles in a flex flow item with real values.
8174 parse_flex_handle(struct context *ctx, const struct token *token,
8175 const char *str, unsigned int len,
8176 void *buf, unsigned int size)
8178 struct rte_flow_item_flex *spec, *mask;
8179 const struct rte_flow_item_flex *src_spec, *src_mask;
8180 const struct arg *arg = pop_args(ctx);
8186 printf("Bad environment\n");
8189 offset = arg->offset;
8190 push_args(ctx, arg);
8191 ret = parse_int(ctx, token, str, len, buf, size);
8192 if (ret <= 0 || !ctx->object)
8194 if (ctx->port >= RTE_MAX_ETHPORTS) {
8195 printf("Bad port\n");
8198 if (offset == offsetof(struct rte_flow_item_flex, handle)) {
8199 const struct flex_item *fp;
8200 struct rte_flow_item_flex *item_flex = ctx->object;
8201 handle = (uint16_t)(uintptr_t)item_flex->handle;
8202 if (handle >= FLEX_MAX_PARSERS_NUM) {
8203 printf("Bad flex item handle\n");
8206 fp = flex_items[ctx->port][handle];
8208 printf("Bad flex item handle\n");
8211 item_flex->handle = fp->flex_handle;
8212 } else if (offset == offsetof(struct rte_flow_item_flex, pattern)) {
8213 handle = (uint16_t)(uintptr_t)
8214 ((struct rte_flow_item_flex *)ctx->object)->pattern;
8215 if (handle >= FLEX_MAX_PATTERNS_NUM) {
8216 printf("Bad pattern handle\n");
8219 src_spec = &flex_patterns[handle].spec;
8220 src_mask = &flex_patterns[handle].mask;
8222 mask = spec + 2; /* spec, last, mask */
8223 /* fill flow rule spec and mask parameters */
8224 spec->length = src_spec->length;
8225 spec->pattern = src_spec->pattern;
8226 mask->length = src_mask->length;
8227 mask->pattern = src_mask->pattern;
8229 printf("Bad arguments - unknown flex item offset\n");
8235 /** No completion. */
8237 comp_none(struct context *ctx, const struct token *token,
8238 unsigned int ent, char *buf, unsigned int size)
8248 /** Complete boolean values. */
8250 comp_boolean(struct context *ctx, const struct token *token,
8251 unsigned int ent, char *buf, unsigned int size)
8257 for (i = 0; boolean_name[i]; ++i)
8258 if (buf && i == ent)
8259 return strlcpy(buf, boolean_name[i], size);
8265 /** Complete action names. */
8267 comp_action(struct context *ctx, const struct token *token,
8268 unsigned int ent, char *buf, unsigned int size)
8274 for (i = 0; next_action[i]; ++i)
8275 if (buf && i == ent)
8276 return strlcpy(buf, token_list[next_action[i]].name,
8283 /** Complete available ports. */
8285 comp_port(struct context *ctx, const struct token *token,
8286 unsigned int ent, char *buf, unsigned int size)
8293 RTE_ETH_FOREACH_DEV(p) {
8294 if (buf && i == ent)
8295 return snprintf(buf, size, "%u", p);
8303 /** Complete available rule IDs. */
8305 comp_rule_id(struct context *ctx, const struct token *token,
8306 unsigned int ent, char *buf, unsigned int size)
8309 struct rte_port *port;
8310 struct port_flow *pf;
8313 if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
8314 ctx->port == (portid_t)RTE_PORT_ALL)
8316 port = &ports[ctx->port];
8317 for (pf = port->flow_list; pf != NULL; pf = pf->next) {
8318 if (buf && i == ent)
8319 return snprintf(buf, size, "%u", pf->id);
8327 /** Complete type field for RSS action. */
8329 comp_vc_action_rss_type(struct context *ctx, const struct token *token,
8330 unsigned int ent, char *buf, unsigned int size)
8336 for (i = 0; rss_type_table[i].str; ++i)
8341 return strlcpy(buf, rss_type_table[ent].str, size);
8343 return snprintf(buf, size, "end");
8347 /** Complete queue field for RSS action. */
8349 comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
8350 unsigned int ent, char *buf, unsigned int size)
8357 return snprintf(buf, size, "%u", ent);
8359 return snprintf(buf, size, "end");
8363 /** Complete index number for set raw_encap/raw_decap commands. */
8365 comp_set_raw_index(struct context *ctx, const struct token *token,
8366 unsigned int ent, char *buf, unsigned int size)
8372 RTE_SET_USED(token);
8373 for (idx = 0; idx < RAW_ENCAP_CONFS_MAX_NUM; ++idx) {
8374 if (buf && idx == ent)
8375 return snprintf(buf, size, "%u", idx);
8381 /** Complete index number for set raw_encap/raw_decap commands. */
8383 comp_set_sample_index(struct context *ctx, const struct token *token,
8384 unsigned int ent, char *buf, unsigned int size)
8390 RTE_SET_USED(token);
8391 for (idx = 0; idx < RAW_SAMPLE_CONFS_MAX_NUM; ++idx) {
8392 if (buf && idx == ent)
8393 return snprintf(buf, size, "%u", idx);
8399 /** Complete operation for modify_field command. */
8401 comp_set_modify_field_op(struct context *ctx, const struct token *token,
8402 unsigned int ent, char *buf, unsigned int size)
8405 RTE_SET_USED(token);
8407 return RTE_DIM(modify_field_ops);
8408 if (ent < RTE_DIM(modify_field_ops) - 1)
8409 return strlcpy(buf, modify_field_ops[ent], size);
8413 /** Complete field id for modify_field command. */
8415 comp_set_modify_field_id(struct context *ctx, const struct token *token,
8416 unsigned int ent, char *buf, unsigned int size)
8420 RTE_SET_USED(token);
8422 return RTE_DIM(modify_field_ids);
8423 if (ent >= RTE_DIM(modify_field_ids) - 1)
8425 name = modify_field_ids[ent];
8426 if (ctx->curr == ACTION_MODIFY_FIELD_SRC_TYPE ||
8427 (strcmp(name, "pointer") && strcmp(name, "value")))
8428 return strlcpy(buf, name, size);
8432 /** Internal context. */
8433 static struct context cmd_flow_context;
8435 /** Global parser instance (cmdline API). */
8436 cmdline_parse_inst_t cmd_flow;
8437 cmdline_parse_inst_t cmd_set_raw;
8439 /** Initialize context. */
8441 cmd_flow_context_init(struct context *ctx)
8443 /* A full memset() is not necessary. */
8453 ctx->objmask = NULL;
8456 /** Parse a token (cmdline API). */
8458 cmd_flow_parse(cmdline_parse_token_hdr_t *hdr, const char *src, void *result,
8461 struct context *ctx = &cmd_flow_context;
8462 const struct token *token;
8463 const enum index *list;
8468 token = &token_list[ctx->curr];
8469 /* Check argument length. */
8472 for (len = 0; src[len]; ++len)
8473 if (src[len] == '#' || isspace(src[len]))
8477 /* Last argument and EOL detection. */
8478 for (i = len; src[i]; ++i)
8479 if (src[i] == '#' || src[i] == '\r' || src[i] == '\n')
8481 else if (!isspace(src[i])) {
8486 if (src[i] == '\r' || src[i] == '\n') {
8490 /* Initialize context if necessary. */
8491 if (!ctx->next_num) {
8494 ctx->next[ctx->next_num++] = token->next[0];
8496 /* Process argument through candidates. */
8497 ctx->prev = ctx->curr;
8498 list = ctx->next[ctx->next_num - 1];
8499 for (i = 0; list[i]; ++i) {
8500 const struct token *next = &token_list[list[i]];
8503 ctx->curr = list[i];
8505 tmp = next->call(ctx, next, src, len, result, size);
8507 tmp = parse_default(ctx, next, src, len, result, size);
8508 if (tmp == -1 || tmp != len)
8516 /* Push subsequent tokens if any. */
8518 for (i = 0; token->next[i]; ++i) {
8519 if (ctx->next_num == RTE_DIM(ctx->next))
8521 ctx->next[ctx->next_num++] = token->next[i];
8523 /* Push arguments if any. */
8525 for (i = 0; token->args[i]; ++i) {
8526 if (ctx->args_num == RTE_DIM(ctx->args))
8528 ctx->args[ctx->args_num++] = token->args[i];
8534 flow_parse(const char *src, void *result, unsigned int size,
8535 struct rte_flow_attr **attr,
8536 struct rte_flow_item **pattern, struct rte_flow_action **actions)
8539 struct context saved_flow_ctx = cmd_flow_context;
8541 cmd_flow_context_init(&cmd_flow_context);
8543 ret = cmd_flow_parse(NULL, src, result, size);
8546 while (isspace(*src))
8549 } while (ret > 0 && strlen(src));
8550 cmd_flow_context = saved_flow_ctx;
8551 *attr = &((struct buffer *)result)->args.vc.attr;
8552 *pattern = ((struct buffer *)result)->args.vc.pattern;
8553 *actions = ((struct buffer *)result)->args.vc.actions;
8554 return (ret >= 0 && !strlen(src)) ? 0 : -1;
8557 /** Return number of completion entries (cmdline API). */
8559 cmd_flow_complete_get_nb(cmdline_parse_token_hdr_t *hdr)
8561 struct context *ctx = &cmd_flow_context;
8562 const struct token *token = &token_list[ctx->curr];
8563 const enum index *list;
8567 /* Count number of tokens in current list. */
8569 list = ctx->next[ctx->next_num - 1];
8571 list = token->next[0];
8572 for (i = 0; list[i]; ++i)
8577 * If there is a single token, use its completion callback, otherwise
8578 * return the number of entries.
8580 token = &token_list[list[0]];
8581 if (i == 1 && token->comp) {
8582 /* Save index for cmd_flow_get_help(). */
8583 ctx->prev = list[0];
8584 return token->comp(ctx, token, 0, NULL, 0);
8589 /** Return a completion entry (cmdline API). */
8591 cmd_flow_complete_get_elt(cmdline_parse_token_hdr_t *hdr, int index,
8592 char *dst, unsigned int size)
8594 struct context *ctx = &cmd_flow_context;
8595 const struct token *token = &token_list[ctx->curr];
8596 const enum index *list;
8600 /* Count number of tokens in current list. */
8602 list = ctx->next[ctx->next_num - 1];
8604 list = token->next[0];
8605 for (i = 0; list[i]; ++i)
8609 /* If there is a single token, use its completion callback. */
8610 token = &token_list[list[0]];
8611 if (i == 1 && token->comp) {
8612 /* Save index for cmd_flow_get_help(). */
8613 ctx->prev = list[0];
8614 return token->comp(ctx, token, index, dst, size) < 0 ? -1 : 0;
8616 /* Otherwise make sure the index is valid and use defaults. */
8619 token = &token_list[list[index]];
8620 strlcpy(dst, token->name, size);
8621 /* Save index for cmd_flow_get_help(). */
8622 ctx->prev = list[index];
8626 /** Populate help strings for current token (cmdline API). */
8628 cmd_flow_get_help(cmdline_parse_token_hdr_t *hdr, char *dst, unsigned int size)
8630 struct context *ctx = &cmd_flow_context;
8631 const struct token *token = &token_list[ctx->prev];
8636 /* Set token type and update global help with details. */
8637 strlcpy(dst, (token->type ? token->type : "TOKEN"), size);
8639 cmd_flow.help_str = token->help;
8641 cmd_flow.help_str = token->name;
8645 /** Token definition template (cmdline API). */
8646 static struct cmdline_token_hdr cmd_flow_token_hdr = {
8647 .ops = &(struct cmdline_token_ops){
8648 .parse = cmd_flow_parse,
8649 .complete_get_nb = cmd_flow_complete_get_nb,
8650 .complete_get_elt = cmd_flow_complete_get_elt,
8651 .get_help = cmd_flow_get_help,
8656 /** Populate the next dynamic token. */
8658 cmd_flow_tok(cmdline_parse_token_hdr_t **hdr,
8659 cmdline_parse_token_hdr_t **hdr_inst)
8661 struct context *ctx = &cmd_flow_context;
8663 /* Always reinitialize context before requesting the first token. */
8664 if (!(hdr_inst - cmd_flow.tokens))
8665 cmd_flow_context_init(ctx);
8666 /* Return NULL when no more tokens are expected. */
8667 if (!ctx->next_num && ctx->curr) {
8671 /* Determine if command should end here. */
8672 if (ctx->eol && ctx->last && ctx->next_num) {
8673 const enum index *list = ctx->next[ctx->next_num - 1];
8676 for (i = 0; list[i]; ++i) {
8683 *hdr = &cmd_flow_token_hdr;
8686 /** Dispatch parsed buffer to function calls. */
8688 cmd_flow_parsed(const struct buffer *in)
8690 switch (in->command) {
8691 case INDIRECT_ACTION_CREATE:
8692 port_action_handle_create(
8693 in->port, in->args.vc.attr.group,
8694 &((const struct rte_flow_indir_action_conf) {
8695 .ingress = in->args.vc.attr.ingress,
8696 .egress = in->args.vc.attr.egress,
8697 .transfer = in->args.vc.attr.transfer,
8699 in->args.vc.actions);
8701 case INDIRECT_ACTION_DESTROY:
8702 port_action_handle_destroy(in->port,
8703 in->args.ia_destroy.action_id_n,
8704 in->args.ia_destroy.action_id);
8706 case INDIRECT_ACTION_UPDATE:
8707 port_action_handle_update(in->port, in->args.vc.attr.group,
8708 in->args.vc.actions);
8710 case INDIRECT_ACTION_QUERY:
8711 port_action_handle_query(in->port, in->args.ia.action_id);
8714 port_flow_validate(in->port, &in->args.vc.attr,
8715 in->args.vc.pattern, in->args.vc.actions,
8716 &in->args.vc.tunnel_ops);
8719 port_flow_create(in->port, &in->args.vc.attr,
8720 in->args.vc.pattern, in->args.vc.actions,
8721 &in->args.vc.tunnel_ops);
8724 port_flow_destroy(in->port, in->args.destroy.rule_n,
8725 in->args.destroy.rule);
8728 port_flow_flush(in->port);
8732 port_flow_dump(in->port, in->args.dump.mode,
8733 in->args.dump.rule, in->args.dump.file);
8736 port_flow_query(in->port, in->args.query.rule,
8737 &in->args.query.action);
8740 port_flow_list(in->port, in->args.list.group_n,
8741 in->args.list.group);
8744 port_flow_isolate(in->port, in->args.isolate.set);
8747 port_flow_aged(in->port, in->args.aged.destroy);
8750 port_flow_tunnel_create(in->port, &in->args.vc.tunnel_ops);
8752 case TUNNEL_DESTROY:
8753 port_flow_tunnel_destroy(in->port, in->args.vc.tunnel_ops.id);
8756 port_flow_tunnel_list(in->port);
8759 port_meter_policy_add(in->port, in->args.policy.policy_id,
8760 in->args.vc.actions);
8762 case FLEX_ITEM_CREATE:
8763 flex_item_create(in->port, in->args.flex.token,
8764 in->args.flex.filename);
8766 case FLEX_ITEM_DESTROY:
8767 flex_item_destroy(in->port, in->args.flex.token);
8774 /** Token generator and output processing callback (cmdline API). */
8776 cmd_flow_cb(void *arg0, struct cmdline *cl, void *arg2)
8779 cmd_flow_tok(arg0, arg2);
8781 cmd_flow_parsed(arg0);
8784 /** Global parser instance (cmdline API). */
8785 cmdline_parse_inst_t cmd_flow = {
8787 .data = NULL, /**< Unused. */
8788 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
8791 }, /**< Tokens are returned by cmd_flow_tok(). */
8794 /** set cmd facility. Reuse cmd flow's infrastructure as much as possible. */
8797 update_fields(uint8_t *buf, struct rte_flow_item *item, uint16_t next_proto)
8799 struct rte_ipv4_hdr *ipv4;
8800 struct rte_ether_hdr *eth;
8801 struct rte_ipv6_hdr *ipv6;
8802 struct rte_vxlan_hdr *vxlan;
8803 struct rte_vxlan_gpe_hdr *gpe;
8804 struct rte_flow_item_nvgre *nvgre;
8805 uint32_t ipv6_vtc_flow;
8807 switch (item->type) {
8808 case RTE_FLOW_ITEM_TYPE_ETH:
8809 eth = (struct rte_ether_hdr *)buf;
8811 eth->ether_type = rte_cpu_to_be_16(next_proto);
8813 case RTE_FLOW_ITEM_TYPE_IPV4:
8814 ipv4 = (struct rte_ipv4_hdr *)buf;
8815 if (!ipv4->version_ihl)
8816 ipv4->version_ihl = RTE_IPV4_VHL_DEF;
8817 if (next_proto && ipv4->next_proto_id == 0)
8818 ipv4->next_proto_id = (uint8_t)next_proto;
8820 case RTE_FLOW_ITEM_TYPE_IPV6:
8821 ipv6 = (struct rte_ipv6_hdr *)buf;
8822 if (next_proto && ipv6->proto == 0)
8823 ipv6->proto = (uint8_t)next_proto;
8824 ipv6_vtc_flow = rte_be_to_cpu_32(ipv6->vtc_flow);
8825 ipv6_vtc_flow &= 0x0FFFFFFF; /*< reset version bits. */
8826 ipv6_vtc_flow |= 0x60000000; /*< set ipv6 version. */
8827 ipv6->vtc_flow = rte_cpu_to_be_32(ipv6_vtc_flow);
8829 case RTE_FLOW_ITEM_TYPE_VXLAN:
8830 vxlan = (struct rte_vxlan_hdr *)buf;
8831 vxlan->vx_flags = 0x08;
8833 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
8834 gpe = (struct rte_vxlan_gpe_hdr *)buf;
8835 gpe->vx_flags = 0x0C;
8837 case RTE_FLOW_ITEM_TYPE_NVGRE:
8838 nvgre = (struct rte_flow_item_nvgre *)buf;
8839 nvgre->protocol = rte_cpu_to_be_16(0x6558);
8840 nvgre->c_k_s_rsvd0_ver = rte_cpu_to_be_16(0x2000);
8847 /** Helper of get item's default mask. */
8849 flow_item_default_mask(const struct rte_flow_item *item)
8851 const void *mask = NULL;
8852 static rte_be32_t gre_key_default_mask = RTE_BE32(UINT32_MAX);
8854 switch (item->type) {
8855 case RTE_FLOW_ITEM_TYPE_ANY:
8856 mask = &rte_flow_item_any_mask;
8858 case RTE_FLOW_ITEM_TYPE_VF:
8859 mask = &rte_flow_item_vf_mask;
8861 case RTE_FLOW_ITEM_TYPE_PORT_ID:
8862 mask = &rte_flow_item_port_id_mask;
8864 case RTE_FLOW_ITEM_TYPE_RAW:
8865 mask = &rte_flow_item_raw_mask;
8867 case RTE_FLOW_ITEM_TYPE_ETH:
8868 mask = &rte_flow_item_eth_mask;
8870 case RTE_FLOW_ITEM_TYPE_VLAN:
8871 mask = &rte_flow_item_vlan_mask;
8873 case RTE_FLOW_ITEM_TYPE_IPV4:
8874 mask = &rte_flow_item_ipv4_mask;
8876 case RTE_FLOW_ITEM_TYPE_IPV6:
8877 mask = &rte_flow_item_ipv6_mask;
8879 case RTE_FLOW_ITEM_TYPE_ICMP:
8880 mask = &rte_flow_item_icmp_mask;
8882 case RTE_FLOW_ITEM_TYPE_UDP:
8883 mask = &rte_flow_item_udp_mask;
8885 case RTE_FLOW_ITEM_TYPE_TCP:
8886 mask = &rte_flow_item_tcp_mask;
8888 case RTE_FLOW_ITEM_TYPE_SCTP:
8889 mask = &rte_flow_item_sctp_mask;
8891 case RTE_FLOW_ITEM_TYPE_VXLAN:
8892 mask = &rte_flow_item_vxlan_mask;
8894 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
8895 mask = &rte_flow_item_vxlan_gpe_mask;
8897 case RTE_FLOW_ITEM_TYPE_E_TAG:
8898 mask = &rte_flow_item_e_tag_mask;
8900 case RTE_FLOW_ITEM_TYPE_NVGRE:
8901 mask = &rte_flow_item_nvgre_mask;
8903 case RTE_FLOW_ITEM_TYPE_MPLS:
8904 mask = &rte_flow_item_mpls_mask;
8906 case RTE_FLOW_ITEM_TYPE_GRE:
8907 mask = &rte_flow_item_gre_mask;
8909 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
8910 mask = &gre_key_default_mask;
8912 case RTE_FLOW_ITEM_TYPE_META:
8913 mask = &rte_flow_item_meta_mask;
8915 case RTE_FLOW_ITEM_TYPE_FUZZY:
8916 mask = &rte_flow_item_fuzzy_mask;
8918 case RTE_FLOW_ITEM_TYPE_GTP:
8919 mask = &rte_flow_item_gtp_mask;
8921 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
8922 mask = &rte_flow_item_gtp_psc_mask;
8924 case RTE_FLOW_ITEM_TYPE_GENEVE:
8925 mask = &rte_flow_item_geneve_mask;
8927 case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
8928 mask = &rte_flow_item_geneve_opt_mask;
8930 case RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID:
8931 mask = &rte_flow_item_pppoe_proto_id_mask;
8933 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
8934 mask = &rte_flow_item_l2tpv3oip_mask;
8936 case RTE_FLOW_ITEM_TYPE_ESP:
8937 mask = &rte_flow_item_esp_mask;
8939 case RTE_FLOW_ITEM_TYPE_AH:
8940 mask = &rte_flow_item_ah_mask;
8942 case RTE_FLOW_ITEM_TYPE_PFCP:
8943 mask = &rte_flow_item_pfcp_mask;
8945 case RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR:
8946 case RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT:
8947 mask = &rte_flow_item_ethdev_mask;
8949 case RTE_FLOW_ITEM_TYPE_L2TPV2:
8950 mask = &rte_flow_item_l2tpv2_mask;
8952 case RTE_FLOW_ITEM_TYPE_PPP:
8953 mask = &rte_flow_item_ppp_mask;
8961 /** Dispatch parsed buffer to function calls. */
8963 cmd_set_raw_parsed_sample(const struct buffer *in)
8965 uint32_t n = in->args.vc.actions_n;
8967 struct rte_flow_action *action = NULL;
8968 struct rte_flow_action *data = NULL;
8969 const struct rte_flow_action_rss *rss = NULL;
8971 uint16_t idx = in->port; /* We borrow port field as index */
8972 uint32_t max_size = sizeof(struct rte_flow_action) *
8973 ACTION_SAMPLE_ACTIONS_NUM;
8975 RTE_ASSERT(in->command == SET_SAMPLE_ACTIONS);
8976 data = (struct rte_flow_action *)&raw_sample_confs[idx].data;
8977 memset(data, 0x00, max_size);
8978 for (; i <= n - 1; i++) {
8979 action = in->args.vc.actions + i;
8980 if (action->type == RTE_FLOW_ACTION_TYPE_END)
8982 switch (action->type) {
8983 case RTE_FLOW_ACTION_TYPE_MARK:
8984 size = sizeof(struct rte_flow_action_mark);
8985 rte_memcpy(&sample_mark[idx],
8986 (const void *)action->conf, size);
8987 action->conf = &sample_mark[idx];
8989 case RTE_FLOW_ACTION_TYPE_COUNT:
8990 size = sizeof(struct rte_flow_action_count);
8991 rte_memcpy(&sample_count[idx],
8992 (const void *)action->conf, size);
8993 action->conf = &sample_count[idx];
8995 case RTE_FLOW_ACTION_TYPE_QUEUE:
8996 size = sizeof(struct rte_flow_action_queue);
8997 rte_memcpy(&sample_queue[idx],
8998 (const void *)action->conf, size);
8999 action->conf = &sample_queue[idx];
9001 case RTE_FLOW_ACTION_TYPE_RSS:
9002 size = sizeof(struct rte_flow_action_rss);
9004 rte_memcpy(&sample_rss_data[idx].conf,
9005 (const void *)rss, size);
9006 if (rss->key_len && rss->key) {
9007 sample_rss_data[idx].conf.key =
9008 sample_rss_data[idx].key;
9009 rte_memcpy((void *)((uintptr_t)
9010 sample_rss_data[idx].conf.key),
9011 (const void *)rss->key,
9012 sizeof(uint8_t) * rss->key_len);
9014 if (rss->queue_num && rss->queue) {
9015 sample_rss_data[idx].conf.queue =
9016 sample_rss_data[idx].queue;
9017 rte_memcpy((void *)((uintptr_t)
9018 sample_rss_data[idx].conf.queue),
9019 (const void *)rss->queue,
9020 sizeof(uint16_t) * rss->queue_num);
9022 action->conf = &sample_rss_data[idx].conf;
9024 case RTE_FLOW_ACTION_TYPE_RAW_ENCAP:
9025 size = sizeof(struct rte_flow_action_raw_encap);
9026 rte_memcpy(&sample_encap[idx],
9027 (const void *)action->conf, size);
9028 action->conf = &sample_encap[idx];
9030 case RTE_FLOW_ACTION_TYPE_PORT_ID:
9031 size = sizeof(struct rte_flow_action_port_id);
9032 rte_memcpy(&sample_port_id[idx],
9033 (const void *)action->conf, size);
9034 action->conf = &sample_port_id[idx];
9036 case RTE_FLOW_ACTION_TYPE_PF:
9038 case RTE_FLOW_ACTION_TYPE_VF:
9039 size = sizeof(struct rte_flow_action_vf);
9040 rte_memcpy(&sample_vf[idx],
9041 (const void *)action->conf, size);
9042 action->conf = &sample_vf[idx];
9044 case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP:
9045 size = sizeof(struct rte_flow_action_vxlan_encap);
9046 parse_setup_vxlan_encap_data(&sample_vxlan_encap[idx]);
9047 action->conf = &sample_vxlan_encap[idx].conf;
9049 case RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP:
9050 size = sizeof(struct rte_flow_action_nvgre_encap);
9051 parse_setup_nvgre_encap_data(&sample_nvgre_encap[idx]);
9052 action->conf = &sample_nvgre_encap[idx];
9055 fprintf(stderr, "Error - Not supported action\n");
9058 rte_memcpy(data, action, sizeof(struct rte_flow_action));
9063 /** Dispatch parsed buffer to function calls. */
9065 cmd_set_raw_parsed(const struct buffer *in)
9067 uint32_t n = in->args.vc.pattern_n;
9069 struct rte_flow_item *item = NULL;
9071 uint8_t *data = NULL;
9072 uint8_t *data_tail = NULL;
9073 size_t *total_size = NULL;
9074 uint16_t upper_layer = 0;
9076 uint16_t idx = in->port; /* We borrow port field as index */
9077 int gtp_psc = -1; /* GTP PSC option index. */
9079 if (in->command == SET_SAMPLE_ACTIONS)
9080 return cmd_set_raw_parsed_sample(in);
9081 RTE_ASSERT(in->command == SET_RAW_ENCAP ||
9082 in->command == SET_RAW_DECAP);
9083 if (in->command == SET_RAW_ENCAP) {
9084 total_size = &raw_encap_confs[idx].size;
9085 data = (uint8_t *)&raw_encap_confs[idx].data;
9087 total_size = &raw_decap_confs[idx].size;
9088 data = (uint8_t *)&raw_decap_confs[idx].data;
9091 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
9092 /* process hdr from upper layer to low layer (L3/L4 -> L2). */
9093 data_tail = data + ACTION_RAW_ENCAP_MAX_DATA;
9094 for (i = n - 1 ; i >= 0; --i) {
9095 const struct rte_flow_item_gtp *gtp;
9096 const struct rte_flow_item_geneve_opt *opt;
9098 item = in->args.vc.pattern + i;
9099 if (item->spec == NULL)
9100 item->spec = flow_item_default_mask(item);
9101 switch (item->type) {
9102 case RTE_FLOW_ITEM_TYPE_ETH:
9103 size = sizeof(struct rte_ether_hdr);
9105 case RTE_FLOW_ITEM_TYPE_VLAN:
9106 size = sizeof(struct rte_vlan_hdr);
9107 proto = RTE_ETHER_TYPE_VLAN;
9109 case RTE_FLOW_ITEM_TYPE_IPV4:
9110 size = sizeof(struct rte_ipv4_hdr);
9111 proto = RTE_ETHER_TYPE_IPV4;
9113 case RTE_FLOW_ITEM_TYPE_IPV6:
9114 size = sizeof(struct rte_ipv6_hdr);
9115 proto = RTE_ETHER_TYPE_IPV6;
9117 case RTE_FLOW_ITEM_TYPE_UDP:
9118 size = sizeof(struct rte_udp_hdr);
9121 case RTE_FLOW_ITEM_TYPE_TCP:
9122 size = sizeof(struct rte_tcp_hdr);
9125 case RTE_FLOW_ITEM_TYPE_VXLAN:
9126 size = sizeof(struct rte_vxlan_hdr);
9128 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
9129 size = sizeof(struct rte_vxlan_gpe_hdr);
9131 case RTE_FLOW_ITEM_TYPE_GRE:
9132 size = sizeof(struct rte_gre_hdr);
9135 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
9136 size = sizeof(rte_be32_t);
9139 case RTE_FLOW_ITEM_TYPE_MPLS:
9140 size = sizeof(struct rte_mpls_hdr);
9143 case RTE_FLOW_ITEM_TYPE_NVGRE:
9144 size = sizeof(struct rte_flow_item_nvgre);
9147 case RTE_FLOW_ITEM_TYPE_GENEVE:
9148 size = sizeof(struct rte_geneve_hdr);
9150 case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
9151 opt = (const struct rte_flow_item_geneve_opt *)
9153 size = offsetof(struct rte_flow_item_geneve_opt, data);
9154 if (opt->option_len && opt->data) {
9155 *total_size += opt->option_len *
9157 rte_memcpy(data_tail - (*total_size),
9159 opt->option_len * sizeof(uint32_t));
9162 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
9163 size = sizeof(rte_be32_t);
9166 case RTE_FLOW_ITEM_TYPE_ESP:
9167 size = sizeof(struct rte_esp_hdr);
9170 case RTE_FLOW_ITEM_TYPE_AH:
9171 size = sizeof(struct rte_flow_item_ah);
9174 case RTE_FLOW_ITEM_TYPE_GTP:
9176 size = sizeof(struct rte_gtp_hdr);
9179 if (gtp_psc != i + 1) {
9181 "Error - GTP PSC does not follow GTP\n");
9185 if ((gtp->v_pt_rsv_flags & 0x07) != 0x04) {
9186 /* Only E flag should be set. */
9188 "Error - GTP unsupported flags\n");
9191 struct rte_gtp_hdr_ext_word ext_word = {
9195 /* We have to add GTP header extra word. */
9196 *total_size += sizeof(ext_word);
9197 rte_memcpy(data_tail - (*total_size),
9198 &ext_word, sizeof(ext_word));
9200 size = sizeof(struct rte_gtp_hdr);
9202 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
9205 "Error - Multiple GTP PSC items\n");
9208 const struct rte_flow_item_gtp_psc
9216 psc.len = sizeof(psc);
9217 psc.pdu_type = opt->hdr.type;
9218 psc.qfi = opt->hdr.qfi;
9220 *total_size += sizeof(psc);
9221 rte_memcpy(data_tail - (*total_size),
9227 case RTE_FLOW_ITEM_TYPE_PFCP:
9228 size = sizeof(struct rte_flow_item_pfcp);
9230 case RTE_FLOW_ITEM_TYPE_FLEX:
9232 ((const struct rte_flow_item_flex *)
9233 item->spec)->length : 0;
9236 fprintf(stderr, "Error - Not supported item\n");
9239 *total_size += size;
9240 rte_memcpy(data_tail - (*total_size), item->spec, size);
9241 /* update some fields which cannot be set by cmdline */
9242 update_fields((data_tail - (*total_size)), item,
9244 upper_layer = proto;
9246 if (verbose_level & 0x1)
9247 printf("total data size is %zu\n", (*total_size));
9248 RTE_ASSERT((*total_size) <= ACTION_RAW_ENCAP_MAX_DATA);
9249 memmove(data, (data_tail - (*total_size)), *total_size);
9254 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
9257 /** Populate help strings for current token (cmdline API). */
9259 cmd_set_raw_get_help(cmdline_parse_token_hdr_t *hdr, char *dst,
9262 struct context *ctx = &cmd_flow_context;
9263 const struct token *token = &token_list[ctx->prev];
9268 /* Set token type and update global help with details. */
9269 snprintf(dst, size, "%s", (token->type ? token->type : "TOKEN"));
9271 cmd_set_raw.help_str = token->help;
9273 cmd_set_raw.help_str = token->name;
9277 /** Token definition template (cmdline API). */
9278 static struct cmdline_token_hdr cmd_set_raw_token_hdr = {
9279 .ops = &(struct cmdline_token_ops){
9280 .parse = cmd_flow_parse,
9281 .complete_get_nb = cmd_flow_complete_get_nb,
9282 .complete_get_elt = cmd_flow_complete_get_elt,
9283 .get_help = cmd_set_raw_get_help,
9288 /** Populate the next dynamic token. */
9290 cmd_set_raw_tok(cmdline_parse_token_hdr_t **hdr,
9291 cmdline_parse_token_hdr_t **hdr_inst)
9293 struct context *ctx = &cmd_flow_context;
9295 /* Always reinitialize context before requesting the first token. */
9296 if (!(hdr_inst - cmd_set_raw.tokens)) {
9297 cmd_flow_context_init(ctx);
9298 ctx->curr = START_SET;
9300 /* Return NULL when no more tokens are expected. */
9301 if (!ctx->next_num && (ctx->curr != START_SET)) {
9305 /* Determine if command should end here. */
9306 if (ctx->eol && ctx->last && ctx->next_num) {
9307 const enum index *list = ctx->next[ctx->next_num - 1];
9310 for (i = 0; list[i]; ++i) {
9317 *hdr = &cmd_set_raw_token_hdr;
9320 /** Token generator and output processing callback (cmdline API). */
9322 cmd_set_raw_cb(void *arg0, struct cmdline *cl, void *arg2)
9325 cmd_set_raw_tok(arg0, arg2);
9327 cmd_set_raw_parsed(arg0);
9330 /** Global parser instance (cmdline API). */
9331 cmdline_parse_inst_t cmd_set_raw = {
9332 .f = cmd_set_raw_cb,
9333 .data = NULL, /**< Unused. */
9334 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
9337 }, /**< Tokens are returned by cmd_flow_tok(). */
9340 /* *** display raw_encap/raw_decap buf */
9341 struct cmd_show_set_raw_result {
9342 cmdline_fixed_string_t cmd_show;
9343 cmdline_fixed_string_t cmd_what;
9344 cmdline_fixed_string_t cmd_all;
9349 cmd_show_set_raw_parsed(void *parsed_result, struct cmdline *cl, void *data)
9351 struct cmd_show_set_raw_result *res = parsed_result;
9352 uint16_t index = res->cmd_index;
9354 uint8_t *raw_data = NULL;
9355 size_t raw_size = 0;
9356 char title[16] = {0};
9360 if (!strcmp(res->cmd_all, "all")) {
9363 } else if (index >= RAW_ENCAP_CONFS_MAX_NUM) {
9364 fprintf(stderr, "index should be 0-%u\n",
9365 RAW_ENCAP_CONFS_MAX_NUM - 1);
9369 if (!strcmp(res->cmd_what, "raw_encap")) {
9370 raw_data = (uint8_t *)&raw_encap_confs[index].data;
9371 raw_size = raw_encap_confs[index].size;
9372 snprintf(title, 16, "\nindex: %u", index);
9373 rte_hexdump(stdout, title, raw_data, raw_size);
9375 raw_data = (uint8_t *)&raw_decap_confs[index].data;
9376 raw_size = raw_decap_confs[index].size;
9377 snprintf(title, 16, "\nindex: %u", index);
9378 rte_hexdump(stdout, title, raw_data, raw_size);
9380 } while (all && ++index < RAW_ENCAP_CONFS_MAX_NUM);
9383 cmdline_parse_token_string_t cmd_show_set_raw_cmd_show =
9384 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
9386 cmdline_parse_token_string_t cmd_show_set_raw_cmd_what =
9387 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
9388 cmd_what, "raw_encap#raw_decap");
9389 cmdline_parse_token_num_t cmd_show_set_raw_cmd_index =
9390 TOKEN_NUM_INITIALIZER(struct cmd_show_set_raw_result,
9391 cmd_index, RTE_UINT16);
9392 cmdline_parse_token_string_t cmd_show_set_raw_cmd_all =
9393 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
9395 cmdline_parse_inst_t cmd_show_set_raw = {
9396 .f = cmd_show_set_raw_parsed,
9398 .help_str = "show <raw_encap|raw_decap> <index>",
9400 (void *)&cmd_show_set_raw_cmd_show,
9401 (void *)&cmd_show_set_raw_cmd_what,
9402 (void *)&cmd_show_set_raw_cmd_index,
9406 cmdline_parse_inst_t cmd_show_set_raw_all = {
9407 .f = cmd_show_set_raw_parsed,
9409 .help_str = "show <raw_encap|raw_decap> all",
9411 (void *)&cmd_show_set_raw_cmd_show,
9412 (void *)&cmd_show_set_raw_cmd_what,
9413 (void *)&cmd_show_set_raw_cmd_all,