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,
59 COMMON_PATTERN_TEMPLATE_ID,
60 COMMON_ACTIONS_TEMPLATE_ID,
64 /* TOP-level command. */
67 /* Top-level command. */
69 /* Sub-leve commands. */
76 /* Top-level command. */
78 /* Sub-level commands. */
105 /* Pattern template arguments. */
106 PATTERN_TEMPLATE_CREATE,
107 PATTERN_TEMPLATE_DESTROY,
108 PATTERN_TEMPLATE_CREATE_ID,
109 PATTERN_TEMPLATE_DESTROY_ID,
110 PATTERN_TEMPLATE_RELAXED_MATCHING,
111 PATTERN_TEMPLATE_INGRESS,
112 PATTERN_TEMPLATE_EGRESS,
113 PATTERN_TEMPLATE_TRANSFER,
114 PATTERN_TEMPLATE_SPEC,
116 /* Actions template arguments. */
117 ACTIONS_TEMPLATE_CREATE,
118 ACTIONS_TEMPLATE_DESTROY,
119 ACTIONS_TEMPLATE_CREATE_ID,
120 ACTIONS_TEMPLATE_DESTROY_ID,
121 ACTIONS_TEMPLATE_INGRESS,
122 ACTIONS_TEMPLATE_EGRESS,
123 ACTIONS_TEMPLATE_TRANSFER,
124 ACTIONS_TEMPLATE_SPEC,
125 ACTIONS_TEMPLATE_MASK,
127 /* Queue arguments. */
130 QUEUE_INDIRECT_ACTION,
132 /* Queue create arguments. */
134 QUEUE_CREATE_POSTPONE,
135 QUEUE_TEMPLATE_TABLE,
136 QUEUE_PATTERN_TEMPLATE,
137 QUEUE_ACTIONS_TEMPLATE,
140 /* Queue destroy arguments. */
142 QUEUE_DESTROY_POSTPONE,
144 /* Queue indirect action arguments */
145 QUEUE_INDIRECT_ACTION_CREATE,
146 QUEUE_INDIRECT_ACTION_UPDATE,
147 QUEUE_INDIRECT_ACTION_DESTROY,
149 /* Queue indirect action create arguments */
150 QUEUE_INDIRECT_ACTION_CREATE_ID,
151 QUEUE_INDIRECT_ACTION_INGRESS,
152 QUEUE_INDIRECT_ACTION_EGRESS,
153 QUEUE_INDIRECT_ACTION_TRANSFER,
154 QUEUE_INDIRECT_ACTION_CREATE_POSTPONE,
155 QUEUE_INDIRECT_ACTION_SPEC,
157 /* Queue indirect action update arguments */
158 QUEUE_INDIRECT_ACTION_UPDATE_POSTPONE,
160 /* Queue indirect action destroy arguments */
161 QUEUE_INDIRECT_ACTION_DESTROY_ID,
162 QUEUE_INDIRECT_ACTION_DESTROY_POSTPONE,
164 /* Push arguments. */
167 /* Pull arguments. */
170 /* Table arguments. */
181 TABLE_PATTERN_TEMPLATE,
182 TABLE_ACTIONS_TEMPLATE,
184 /* Tunnel arguments. */
191 /* Destroy arguments. */
194 /* Query arguments. */
197 /* List arguments. */
200 /* Destroy aged flow arguments. */
203 /* Validate/create arguments. */
216 /* Configure arguments */
217 CONFIG_QUEUES_NUMBER,
219 CONFIG_COUNTERS_NUMBER,
220 CONFIG_AGING_OBJECTS_NUMBER,
221 CONFIG_METERS_NUMBER,
223 /* Indirect action arguments */
224 INDIRECT_ACTION_CREATE,
225 INDIRECT_ACTION_UPDATE,
226 INDIRECT_ACTION_DESTROY,
227 INDIRECT_ACTION_QUERY,
229 /* Indirect action create arguments */
230 INDIRECT_ACTION_CREATE_ID,
231 INDIRECT_ACTION_INGRESS,
232 INDIRECT_ACTION_EGRESS,
233 INDIRECT_ACTION_TRANSFER,
234 INDIRECT_ACTION_SPEC,
236 /* Indirect action destroy arguments */
237 INDIRECT_ACTION_DESTROY_ID,
239 /* Validate/create pattern. */
267 ITEM_RAW_PATTERN_HEX,
278 ITEM_VLAN_INNER_TYPE,
279 ITEM_VLAN_HAS_MORE_VLAN,
284 ITEM_IPV4_FRAGMENT_OFFSET,
296 ITEM_IPV6_HAS_FRAG_EXT,
316 ITEM_VXLAN_LAST_RSVD,
318 ITEM_E_TAG_GRP_ECID_B,
327 ITEM_GRE_C_RSVD0_VER,
346 ITEM_ARP_ETH_IPV4_SHA,
347 ITEM_ARP_ETH_IPV4_SPA,
348 ITEM_ARP_ETH_IPV4_THA,
349 ITEM_ARP_ETH_IPV4_TPA,
351 ITEM_IPV6_EXT_NEXT_HDR,
353 ITEM_IPV6_FRAG_EXT_NEXT_HDR,
354 ITEM_IPV6_FRAG_EXT_FRAG_DATA,
355 ITEM_IPV6_FRAG_EXT_ID,
360 ITEM_ICMP6_ND_NS_TARGET_ADDR,
362 ITEM_ICMP6_ND_NA_TARGET_ADDR,
364 ITEM_ICMP6_ND_OPT_TYPE,
365 ITEM_ICMP6_ND_OPT_SLA_ETH,
366 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
367 ITEM_ICMP6_ND_OPT_TLA_ETH,
368 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
374 ITEM_GRE_OPTION_CHECKSUM,
376 ITEM_GRE_OPTION_SEQUENCE,
385 ITEM_HIGIG2_CLASSIFICATION,
391 ITEM_L2TPV3OIP_SESSION_ID,
401 ITEM_ECPRI_COMMON_TYPE,
402 ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
403 ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
404 ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
405 ITEM_ECPRI_MSG_IQ_DATA_PCID,
406 ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
407 ITEM_ECPRI_MSG_DLY_MSR_MSRID,
409 ITEM_GENEVE_OPT_CLASS,
410 ITEM_GENEVE_OPT_TYPE,
411 ITEM_GENEVE_OPT_LENGTH,
412 ITEM_GENEVE_OPT_DATA,
414 ITEM_INTEGRITY_LEVEL,
415 ITEM_INTEGRITY_VALUE,
420 ITEM_PORT_REPRESENTOR,
421 ITEM_PORT_REPRESENTOR_PORT_ID,
422 ITEM_REPRESENTED_PORT,
423 ITEM_REPRESENTED_PORT_ETHDEV_PORT_ID,
425 ITEM_FLEX_ITEM_HANDLE,
426 ITEM_FLEX_PATTERN_HANDLE,
429 ITEM_L2TPV2_TYPE_DATA,
430 ITEM_L2TPV2_TYPE_DATA_L,
431 ITEM_L2TPV2_TYPE_DATA_S,
432 ITEM_L2TPV2_TYPE_DATA_O,
433 ITEM_L2TPV2_TYPE_DATA_L_S,
434 ITEM_L2TPV2_TYPE_CTRL,
435 ITEM_L2TPV2_MSG_DATA_TUNNEL_ID,
436 ITEM_L2TPV2_MSG_DATA_SESSION_ID,
437 ITEM_L2TPV2_MSG_DATA_L_LENGTH,
438 ITEM_L2TPV2_MSG_DATA_L_TUNNEL_ID,
439 ITEM_L2TPV2_MSG_DATA_L_SESSION_ID,
440 ITEM_L2TPV2_MSG_DATA_S_TUNNEL_ID,
441 ITEM_L2TPV2_MSG_DATA_S_SESSION_ID,
442 ITEM_L2TPV2_MSG_DATA_S_NS,
443 ITEM_L2TPV2_MSG_DATA_S_NR,
444 ITEM_L2TPV2_MSG_DATA_O_TUNNEL_ID,
445 ITEM_L2TPV2_MSG_DATA_O_SESSION_ID,
446 ITEM_L2TPV2_MSG_DATA_O_OFFSET,
447 ITEM_L2TPV2_MSG_DATA_L_S_LENGTH,
448 ITEM_L2TPV2_MSG_DATA_L_S_TUNNEL_ID,
449 ITEM_L2TPV2_MSG_DATA_L_S_SESSION_ID,
450 ITEM_L2TPV2_MSG_DATA_L_S_NS,
451 ITEM_L2TPV2_MSG_DATA_L_S_NR,
452 ITEM_L2TPV2_MSG_CTRL_LENGTH,
453 ITEM_L2TPV2_MSG_CTRL_TUNNEL_ID,
454 ITEM_L2TPV2_MSG_CTRL_SESSION_ID,
455 ITEM_L2TPV2_MSG_CTRL_NS,
456 ITEM_L2TPV2_MSG_CTRL_NR,
462 /* Validate/create actions. */
481 ACTION_RSS_FUNC_DEFAULT,
482 ACTION_RSS_FUNC_TOEPLITZ,
483 ACTION_RSS_FUNC_SIMPLE_XOR,
484 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ,
496 ACTION_PHY_PORT_ORIGINAL,
497 ACTION_PHY_PORT_INDEX,
499 ACTION_PORT_ID_ORIGINAL,
503 ACTION_METER_COLOR_TYPE,
504 ACTION_METER_COLOR_GREEN,
505 ACTION_METER_COLOR_YELLOW,
506 ACTION_METER_COLOR_RED,
508 ACTION_OF_SET_MPLS_TTL,
509 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
510 ACTION_OF_DEC_MPLS_TTL,
511 ACTION_OF_SET_NW_TTL,
512 ACTION_OF_SET_NW_TTL_NW_TTL,
513 ACTION_OF_DEC_NW_TTL,
514 ACTION_OF_COPY_TTL_OUT,
515 ACTION_OF_COPY_TTL_IN,
518 ACTION_OF_PUSH_VLAN_ETHERTYPE,
519 ACTION_OF_SET_VLAN_VID,
520 ACTION_OF_SET_VLAN_VID_VLAN_VID,
521 ACTION_OF_SET_VLAN_PCP,
522 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
524 ACTION_OF_POP_MPLS_ETHERTYPE,
526 ACTION_OF_PUSH_MPLS_ETHERTYPE,
533 ACTION_MPLSOGRE_ENCAP,
534 ACTION_MPLSOGRE_DECAP,
535 ACTION_MPLSOUDP_ENCAP,
536 ACTION_MPLSOUDP_DECAP,
538 ACTION_SET_IPV4_SRC_IPV4_SRC,
540 ACTION_SET_IPV4_DST_IPV4_DST,
542 ACTION_SET_IPV6_SRC_IPV6_SRC,
544 ACTION_SET_IPV6_DST_IPV6_DST,
546 ACTION_SET_TP_SRC_TP_SRC,
548 ACTION_SET_TP_DST_TP_DST,
554 ACTION_SET_MAC_SRC_MAC_SRC,
556 ACTION_SET_MAC_DST_MAC_DST,
558 ACTION_INC_TCP_SEQ_VALUE,
560 ACTION_DEC_TCP_SEQ_VALUE,
562 ACTION_INC_TCP_ACK_VALUE,
564 ACTION_DEC_TCP_ACK_VALUE,
567 ACTION_RAW_ENCAP_INDEX,
568 ACTION_RAW_ENCAP_INDEX_VALUE,
569 ACTION_RAW_DECAP_INDEX,
570 ACTION_RAW_DECAP_INDEX_VALUE,
573 ACTION_SET_TAG_INDEX,
576 ACTION_SET_META_DATA,
577 ACTION_SET_META_MASK,
578 ACTION_SET_IPV4_DSCP,
579 ACTION_SET_IPV4_DSCP_VALUE,
580 ACTION_SET_IPV6_DSCP,
581 ACTION_SET_IPV6_DSCP_VALUE,
587 ACTION_SAMPLE_INDEX_VALUE,
589 INDIRECT_ACTION_ID2PTR,
591 ACTION_MODIFY_FIELD_OP,
592 ACTION_MODIFY_FIELD_OP_VALUE,
593 ACTION_MODIFY_FIELD_DST_TYPE,
594 ACTION_MODIFY_FIELD_DST_TYPE_VALUE,
595 ACTION_MODIFY_FIELD_DST_LEVEL,
596 ACTION_MODIFY_FIELD_DST_OFFSET,
597 ACTION_MODIFY_FIELD_SRC_TYPE,
598 ACTION_MODIFY_FIELD_SRC_TYPE_VALUE,
599 ACTION_MODIFY_FIELD_SRC_LEVEL,
600 ACTION_MODIFY_FIELD_SRC_OFFSET,
601 ACTION_MODIFY_FIELD_SRC_VALUE,
602 ACTION_MODIFY_FIELD_SRC_POINTER,
603 ACTION_MODIFY_FIELD_WIDTH,
605 ACTION_CONNTRACK_UPDATE,
606 ACTION_CONNTRACK_UPDATE_DIR,
607 ACTION_CONNTRACK_UPDATE_CTX,
611 ACTION_PORT_REPRESENTOR,
612 ACTION_PORT_REPRESENTOR_PORT_ID,
613 ACTION_REPRESENTED_PORT,
614 ACTION_REPRESENTED_PORT_ETHDEV_PORT_ID,
617 /** Maximum size for pattern in struct rte_flow_item_raw. */
618 #define ITEM_RAW_PATTERN_SIZE 512
620 /** Maximum size for GENEVE option data pattern in bytes. */
621 #define ITEM_GENEVE_OPT_DATA_SIZE 124
623 /** Storage size for struct rte_flow_item_raw including pattern. */
624 #define ITEM_RAW_SIZE \
625 (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE)
627 /** Maximum size for external pattern in struct rte_flow_action_modify_data. */
628 #define ACTION_MODIFY_PATTERN_SIZE 32
630 /** Storage size for struct rte_flow_action_modify_field including pattern. */
631 #define ACTION_MODIFY_SIZE \
632 (sizeof(struct rte_flow_action_modify_field) + \
633 ACTION_MODIFY_PATTERN_SIZE)
635 /** Maximum number of queue indices in struct rte_flow_action_rss. */
636 #define ACTION_RSS_QUEUE_NUM 128
638 /** Storage for struct rte_flow_action_rss including external data. */
639 struct action_rss_data {
640 struct rte_flow_action_rss conf;
641 uint8_t key[RSS_HASH_KEY_LENGTH];
642 uint16_t queue[ACTION_RSS_QUEUE_NUM];
645 /** Maximum data size in struct rte_flow_action_raw_encap. */
646 #define ACTION_RAW_ENCAP_MAX_DATA 512
647 #define RAW_ENCAP_CONFS_MAX_NUM 8
649 /** Storage for struct rte_flow_action_raw_encap. */
650 struct raw_encap_conf {
651 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
652 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
656 struct raw_encap_conf raw_encap_confs[RAW_ENCAP_CONFS_MAX_NUM];
658 /** Storage for struct rte_flow_action_raw_encap including external data. */
659 struct action_raw_encap_data {
660 struct rte_flow_action_raw_encap conf;
661 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
662 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
666 /** Storage for struct rte_flow_action_raw_decap. */
667 struct raw_decap_conf {
668 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
672 struct raw_decap_conf raw_decap_confs[RAW_ENCAP_CONFS_MAX_NUM];
674 /** Storage for struct rte_flow_action_raw_decap including external data. */
675 struct action_raw_decap_data {
676 struct rte_flow_action_raw_decap conf;
677 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
681 struct vxlan_encap_conf vxlan_encap_conf = {
685 .vni = "\x00\x00\x00",
687 .udp_dst = RTE_BE16(RTE_VXLAN_DEFAULT_PORT),
688 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
689 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
690 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
691 "\x00\x00\x00\x00\x00\x00\x00\x01",
692 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
693 "\x00\x00\x00\x00\x00\x00\x11\x11",
697 .eth_src = "\x00\x00\x00\x00\x00\x00",
698 .eth_dst = "\xff\xff\xff\xff\xff\xff",
701 /** Maximum number of items in struct rte_flow_action_vxlan_encap. */
702 #define ACTION_VXLAN_ENCAP_ITEMS_NUM 6
704 /** Storage for struct rte_flow_action_vxlan_encap including external data. */
705 struct action_vxlan_encap_data {
706 struct rte_flow_action_vxlan_encap conf;
707 struct rte_flow_item items[ACTION_VXLAN_ENCAP_ITEMS_NUM];
708 struct rte_flow_item_eth item_eth;
709 struct rte_flow_item_vlan item_vlan;
711 struct rte_flow_item_ipv4 item_ipv4;
712 struct rte_flow_item_ipv6 item_ipv6;
714 struct rte_flow_item_udp item_udp;
715 struct rte_flow_item_vxlan item_vxlan;
718 struct nvgre_encap_conf nvgre_encap_conf = {
721 .tni = "\x00\x00\x00",
722 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
723 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
724 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
725 "\x00\x00\x00\x00\x00\x00\x00\x01",
726 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
727 "\x00\x00\x00\x00\x00\x00\x11\x11",
729 .eth_src = "\x00\x00\x00\x00\x00\x00",
730 .eth_dst = "\xff\xff\xff\xff\xff\xff",
733 /** Maximum number of items in struct rte_flow_action_nvgre_encap. */
734 #define ACTION_NVGRE_ENCAP_ITEMS_NUM 5
736 /** Storage for struct rte_flow_action_nvgre_encap including external data. */
737 struct action_nvgre_encap_data {
738 struct rte_flow_action_nvgre_encap conf;
739 struct rte_flow_item items[ACTION_NVGRE_ENCAP_ITEMS_NUM];
740 struct rte_flow_item_eth item_eth;
741 struct rte_flow_item_vlan item_vlan;
743 struct rte_flow_item_ipv4 item_ipv4;
744 struct rte_flow_item_ipv6 item_ipv6;
746 struct rte_flow_item_nvgre item_nvgre;
749 struct l2_encap_conf l2_encap_conf;
751 struct l2_decap_conf l2_decap_conf;
753 struct mplsogre_encap_conf mplsogre_encap_conf;
755 struct mplsogre_decap_conf mplsogre_decap_conf;
757 struct mplsoudp_encap_conf mplsoudp_encap_conf;
759 struct mplsoudp_decap_conf mplsoudp_decap_conf;
761 struct rte_flow_action_conntrack conntrack_context;
763 #define ACTION_SAMPLE_ACTIONS_NUM 10
764 #define RAW_SAMPLE_CONFS_MAX_NUM 8
765 /** Storage for struct rte_flow_action_sample including external data. */
766 struct action_sample_data {
767 struct rte_flow_action_sample conf;
770 /** Storage for struct rte_flow_action_sample. */
771 struct raw_sample_conf {
772 struct rte_flow_action data[ACTION_SAMPLE_ACTIONS_NUM];
774 struct raw_sample_conf raw_sample_confs[RAW_SAMPLE_CONFS_MAX_NUM];
775 struct rte_flow_action_mark sample_mark[RAW_SAMPLE_CONFS_MAX_NUM];
776 struct rte_flow_action_queue sample_queue[RAW_SAMPLE_CONFS_MAX_NUM];
777 struct rte_flow_action_count sample_count[RAW_SAMPLE_CONFS_MAX_NUM];
778 struct rte_flow_action_port_id sample_port_id[RAW_SAMPLE_CONFS_MAX_NUM];
779 struct rte_flow_action_raw_encap sample_encap[RAW_SAMPLE_CONFS_MAX_NUM];
780 struct action_vxlan_encap_data sample_vxlan_encap[RAW_SAMPLE_CONFS_MAX_NUM];
781 struct action_nvgre_encap_data sample_nvgre_encap[RAW_SAMPLE_CONFS_MAX_NUM];
782 struct action_rss_data sample_rss_data[RAW_SAMPLE_CONFS_MAX_NUM];
783 struct rte_flow_action_vf sample_vf[RAW_SAMPLE_CONFS_MAX_NUM];
785 static const char *const modify_field_ops[] = {
786 "set", "add", "sub", NULL
789 static const char *const modify_field_ids[] = {
790 "start", "mac_dst", "mac_src",
791 "vlan_type", "vlan_id", "mac_type",
792 "ipv4_dscp", "ipv4_ttl", "ipv4_src", "ipv4_dst",
793 "ipv6_dscp", "ipv6_hoplimit", "ipv6_src", "ipv6_dst",
794 "tcp_port_src", "tcp_port_dst",
795 "tcp_seq_num", "tcp_ack_num", "tcp_flags",
796 "udp_port_src", "udp_port_dst",
797 "vxlan_vni", "geneve_vni", "gtp_teid",
798 "tag", "mark", "meta", "pointer", "value", NULL
801 /** Maximum number of subsequent tokens and arguments on the stack. */
802 #define CTX_STACK_SIZE 16
804 /** Parser context. */
806 /** Stack of subsequent token lists to process. */
807 const enum index *next[CTX_STACK_SIZE];
808 /** Arguments for stacked tokens. */
809 const void *args[CTX_STACK_SIZE];
810 enum index curr; /**< Current token index. */
811 enum index prev; /**< Index of the last token seen. */
812 int next_num; /**< Number of entries in next[]. */
813 int args_num; /**< Number of entries in args[]. */
814 uint32_t eol:1; /**< EOL has been detected. */
815 uint32_t last:1; /**< No more arguments. */
816 portid_t port; /**< Current port ID (for completions). */
817 uint32_t objdata; /**< Object-specific data. */
818 void *object; /**< Address of current object for relative offsets. */
819 void *objmask; /**< Object a full mask must be written to. */
822 /** Token argument. */
824 uint32_t hton:1; /**< Use network byte ordering. */
825 uint32_t sign:1; /**< Value is signed. */
826 uint32_t bounded:1; /**< Value is bounded. */
827 uintmax_t min; /**< Minimum value if bounded. */
828 uintmax_t max; /**< Maximum value if bounded. */
829 uint32_t offset; /**< Relative offset from ctx->object. */
830 uint32_t size; /**< Field size. */
831 const uint8_t *mask; /**< Bit-mask to use instead of offset/size. */
834 /** Parser token definition. */
836 /** Type displayed during completion (defaults to "TOKEN"). */
838 /** Help displayed during completion (defaults to token name). */
840 /** Private data used by parser functions. */
843 * Lists of subsequent tokens to push on the stack. Each call to the
844 * parser consumes the last entry of that stack.
846 const enum index *const *next;
847 /** Arguments stack for subsequent tokens that need them. */
848 const struct arg *const *args;
850 * Token-processing callback, returns -1 in case of error, the
851 * length of the matched string otherwise. If NULL, attempts to
852 * match the token name.
854 * If buf is not NULL, the result should be stored in it according
855 * to context. An error is returned if not large enough.
857 int (*call)(struct context *ctx, const struct token *token,
858 const char *str, unsigned int len,
859 void *buf, unsigned int size);
861 * Callback that provides possible values for this token, used for
862 * completion. Returns -1 in case of error, the number of possible
863 * values otherwise. If NULL, the token name is used.
865 * If buf is not NULL, entry index ent is written to buf and the
866 * full length of the entry is returned (same behavior as
869 int (*comp)(struct context *ctx, const struct token *token,
870 unsigned int ent, char *buf, unsigned int size);
871 /** Mandatory token name, no default value. */
875 /** Static initializer for the next field. */
876 #define NEXT(...) (const enum index *const []){ __VA_ARGS__, NULL, }
878 /** Static initializer for a NEXT() entry. */
879 #define NEXT_ENTRY(...) (const enum index []){ __VA_ARGS__, ZERO, }
881 /** Static initializer for the args field. */
882 #define ARGS(...) (const struct arg *const []){ __VA_ARGS__, NULL, }
884 /** Static initializer for ARGS() to target a field. */
885 #define ARGS_ENTRY(s, f) \
886 (&(const struct arg){ \
887 .offset = offsetof(s, f), \
888 .size = sizeof(((s *)0)->f), \
891 /** Static initializer for ARGS() to target a bit-field. */
892 #define ARGS_ENTRY_BF(s, f, b) \
893 (&(const struct arg){ \
895 .mask = (const void *)&(const s){ .f = (1 << (b)) - 1 }, \
898 /** Static initializer for ARGS() to target a field with limits. */
899 #define ARGS_ENTRY_BOUNDED(s, f, i, a) \
900 (&(const struct arg){ \
904 .offset = offsetof(s, f), \
905 .size = sizeof(((s *)0)->f), \
908 /** Static initializer for ARGS() to target an arbitrary bit-mask. */
909 #define ARGS_ENTRY_MASK(s, f, m) \
910 (&(const struct arg){ \
911 .offset = offsetof(s, f), \
912 .size = sizeof(((s *)0)->f), \
913 .mask = (const void *)(m), \
916 /** Same as ARGS_ENTRY_MASK() using network byte ordering for the value. */
917 #define ARGS_ENTRY_MASK_HTON(s, f, m) \
918 (&(const struct arg){ \
920 .offset = offsetof(s, f), \
921 .size = sizeof(((s *)0)->f), \
922 .mask = (const void *)(m), \
925 /** Static initializer for ARGS() to target a pointer. */
926 #define ARGS_ENTRY_PTR(s, f) \
927 (&(const struct arg){ \
928 .size = sizeof(*((s *)0)->f), \
931 /** Static initializer for ARGS() with arbitrary offset and size. */
932 #define ARGS_ENTRY_ARB(o, s) \
933 (&(const struct arg){ \
938 /** Same as ARGS_ENTRY_ARB() with bounded values. */
939 #define ARGS_ENTRY_ARB_BOUNDED(o, s, i, a) \
940 (&(const struct arg){ \
948 /** Same as ARGS_ENTRY() using network byte ordering. */
949 #define ARGS_ENTRY_HTON(s, f) \
950 (&(const struct arg){ \
952 .offset = offsetof(s, f), \
953 .size = sizeof(((s *)0)->f), \
956 /** Same as ARGS_ENTRY_HTON() for a single argument, without structure. */
957 #define ARG_ENTRY_HTON(s) \
958 (&(const struct arg){ \
964 /** Parser output buffer layout expected by cmd_flow_parsed(). */
966 enum index command; /**< Flow command. */
967 portid_t port; /**< Affected port ID. */
968 queueid_t queue; /** Async queue ID. */
969 bool postpone; /** Postpone async operation */
972 struct rte_flow_port_attr port_attr;
974 struct rte_flow_queue_attr queue_attr;
975 } configure; /**< Configuration arguments. */
977 uint32_t *template_id;
978 uint32_t template_id_n;
979 } templ_destroy; /**< Template destroy arguments. */
982 struct rte_flow_template_table_attr attr;
983 uint32_t *pat_templ_id;
984 uint32_t pat_templ_id_n;
985 uint32_t *act_templ_id;
986 uint32_t act_templ_id_n;
987 } table; /**< Table arguments. */
991 } table_destroy; /**< Template destroy arguments. */
994 uint32_t action_id_n;
995 } ia_destroy; /**< Indirect action destroy arguments. */
998 } ia; /* Indirect action query arguments */
1001 uint32_t pat_templ_id;
1002 uint32_t act_templ_id;
1003 struct rte_flow_attr attr;
1004 struct tunnel_ops tunnel_ops;
1005 struct rte_flow_item *pattern;
1006 struct rte_flow_action *actions;
1007 struct rte_flow_action *masks;
1011 } vc; /**< Validate/create arguments. */
1015 } destroy; /**< Destroy arguments. */
1020 } dump; /**< Dump arguments. */
1023 struct rte_flow_action action;
1024 } query; /**< Query arguments. */
1028 } list; /**< List arguments. */
1031 } isolate; /**< Isolated mode arguments. */
1034 } aged; /**< Aged arguments. */
1037 } policy;/**< Policy arguments. */
1042 } flex; /**< Flex arguments*/
1043 } args; /**< Command arguments. */
1046 /** Private data for pattern items. */
1047 struct parse_item_priv {
1048 enum rte_flow_item_type type; /**< Item type. */
1049 uint32_t size; /**< Size of item specification structure. */
1052 #define PRIV_ITEM(t, s) \
1053 (&(const struct parse_item_priv){ \
1054 .type = RTE_FLOW_ITEM_TYPE_ ## t, \
1058 /** Private data for actions. */
1059 struct parse_action_priv {
1060 enum rte_flow_action_type type; /**< Action type. */
1061 uint32_t size; /**< Size of action configuration structure. */
1064 #define PRIV_ACTION(t, s) \
1065 (&(const struct parse_action_priv){ \
1066 .type = RTE_FLOW_ACTION_TYPE_ ## t, \
1070 static const enum index next_flex_item[] = {
1077 static const enum index next_config_attr[] = {
1078 CONFIG_QUEUES_NUMBER,
1080 CONFIG_COUNTERS_NUMBER,
1081 CONFIG_AGING_OBJECTS_NUMBER,
1082 CONFIG_METERS_NUMBER,
1087 static const enum index next_pt_subcmd[] = {
1088 PATTERN_TEMPLATE_CREATE,
1089 PATTERN_TEMPLATE_DESTROY,
1093 static const enum index next_pt_attr[] = {
1094 PATTERN_TEMPLATE_CREATE_ID,
1095 PATTERN_TEMPLATE_RELAXED_MATCHING,
1096 PATTERN_TEMPLATE_INGRESS,
1097 PATTERN_TEMPLATE_EGRESS,
1098 PATTERN_TEMPLATE_TRANSFER,
1099 PATTERN_TEMPLATE_SPEC,
1103 static const enum index next_pt_destroy_attr[] = {
1104 PATTERN_TEMPLATE_DESTROY_ID,
1109 static const enum index next_at_subcmd[] = {
1110 ACTIONS_TEMPLATE_CREATE,
1111 ACTIONS_TEMPLATE_DESTROY,
1115 static const enum index next_at_attr[] = {
1116 ACTIONS_TEMPLATE_CREATE_ID,
1117 ACTIONS_TEMPLATE_INGRESS,
1118 ACTIONS_TEMPLATE_EGRESS,
1119 ACTIONS_TEMPLATE_TRANSFER,
1120 ACTIONS_TEMPLATE_SPEC,
1124 static const enum index next_at_destroy_attr[] = {
1125 ACTIONS_TEMPLATE_DESTROY_ID,
1130 static const enum index next_table_subcmd[] = {
1136 static const enum index next_table_attr[] = {
1144 TABLE_PATTERN_TEMPLATE,
1145 TABLE_ACTIONS_TEMPLATE,
1150 static const enum index next_table_destroy_attr[] = {
1156 static const enum index next_queue_subcmd[] = {
1159 QUEUE_INDIRECT_ACTION,
1163 static const enum index next_queue_destroy_attr[] = {
1169 static const enum index next_qia_subcmd[] = {
1170 QUEUE_INDIRECT_ACTION_CREATE,
1171 QUEUE_INDIRECT_ACTION_UPDATE,
1172 QUEUE_INDIRECT_ACTION_DESTROY,
1176 static const enum index next_qia_create_attr[] = {
1177 QUEUE_INDIRECT_ACTION_CREATE_ID,
1178 QUEUE_INDIRECT_ACTION_INGRESS,
1179 QUEUE_INDIRECT_ACTION_EGRESS,
1180 QUEUE_INDIRECT_ACTION_TRANSFER,
1181 QUEUE_INDIRECT_ACTION_CREATE_POSTPONE,
1182 QUEUE_INDIRECT_ACTION_SPEC,
1186 static const enum index next_qia_update_attr[] = {
1187 QUEUE_INDIRECT_ACTION_UPDATE_POSTPONE,
1188 QUEUE_INDIRECT_ACTION_SPEC,
1192 static const enum index next_qia_destroy_attr[] = {
1193 QUEUE_INDIRECT_ACTION_DESTROY_POSTPONE,
1194 QUEUE_INDIRECT_ACTION_DESTROY_ID,
1199 static const enum index next_ia_create_attr[] = {
1200 INDIRECT_ACTION_CREATE_ID,
1201 INDIRECT_ACTION_INGRESS,
1202 INDIRECT_ACTION_EGRESS,
1203 INDIRECT_ACTION_TRANSFER,
1204 INDIRECT_ACTION_SPEC,
1208 static const enum index next_dump_subcmd[] = {
1214 static const enum index next_ia_subcmd[] = {
1215 INDIRECT_ACTION_CREATE,
1216 INDIRECT_ACTION_UPDATE,
1217 INDIRECT_ACTION_DESTROY,
1218 INDIRECT_ACTION_QUERY,
1222 static const enum index next_vc_attr[] = {
1234 static const enum index next_destroy_attr[] = {
1240 static const enum index next_dump_attr[] = {
1246 static const enum index next_list_attr[] = {
1252 static const enum index next_aged_attr[] = {
1258 static const enum index next_ia_destroy_attr[] = {
1259 INDIRECT_ACTION_DESTROY_ID,
1264 static const enum index item_param[] = {
1273 static const enum index next_item[] = {
1310 ITEM_ICMP6_ND_OPT_SLA_ETH,
1311 ITEM_ICMP6_ND_OPT_TLA_ETH,
1318 ITEM_PPPOE_PROTO_ID,
1329 ITEM_PORT_REPRESENTOR,
1330 ITEM_REPRESENTED_PORT,
1338 static const enum index item_fuzzy[] = {
1344 static const enum index item_any[] = {
1350 static const enum index item_vf[] = {
1356 static const enum index item_phy_port[] = {
1357 ITEM_PHY_PORT_INDEX,
1362 static const enum index item_port_id[] = {
1368 static const enum index item_mark[] = {
1374 static const enum index item_raw[] = {
1380 ITEM_RAW_PATTERN_HEX,
1385 static const enum index item_eth[] = {
1394 static const enum index item_vlan[] = {
1399 ITEM_VLAN_INNER_TYPE,
1400 ITEM_VLAN_HAS_MORE_VLAN,
1405 static const enum index item_ipv4[] = {
1409 ITEM_IPV4_FRAGMENT_OFFSET,
1418 static const enum index item_ipv6[] = {
1425 ITEM_IPV6_HAS_FRAG_EXT,
1430 static const enum index item_icmp[] = {
1439 static const enum index item_udp[] = {
1446 static const enum index item_tcp[] = {
1454 static const enum index item_sctp[] = {
1463 static const enum index item_vxlan[] = {
1465 ITEM_VXLAN_LAST_RSVD,
1470 static const enum index item_e_tag[] = {
1471 ITEM_E_TAG_GRP_ECID_B,
1476 static const enum index item_nvgre[] = {
1482 static const enum index item_mpls[] = {
1490 static const enum index item_gre[] = {
1492 ITEM_GRE_C_RSVD0_VER,
1500 static const enum index item_gre_key[] = {
1506 static const enum index item_gre_option[] = {
1507 ITEM_GRE_OPTION_CHECKSUM,
1508 ITEM_GRE_OPTION_KEY,
1509 ITEM_GRE_OPTION_SEQUENCE,
1514 static const enum index item_gtp[] = {
1522 static const enum index item_geneve[] = {
1530 static const enum index item_vxlan_gpe[] = {
1536 static const enum index item_arp_eth_ipv4[] = {
1537 ITEM_ARP_ETH_IPV4_SHA,
1538 ITEM_ARP_ETH_IPV4_SPA,
1539 ITEM_ARP_ETH_IPV4_THA,
1540 ITEM_ARP_ETH_IPV4_TPA,
1545 static const enum index item_ipv6_ext[] = {
1546 ITEM_IPV6_EXT_NEXT_HDR,
1551 static const enum index item_ipv6_frag_ext[] = {
1552 ITEM_IPV6_FRAG_EXT_NEXT_HDR,
1553 ITEM_IPV6_FRAG_EXT_FRAG_DATA,
1554 ITEM_IPV6_FRAG_EXT_ID,
1559 static const enum index item_icmp6[] = {
1566 static const enum index item_icmp6_nd_ns[] = {
1567 ITEM_ICMP6_ND_NS_TARGET_ADDR,
1572 static const enum index item_icmp6_nd_na[] = {
1573 ITEM_ICMP6_ND_NA_TARGET_ADDR,
1578 static const enum index item_icmp6_nd_opt[] = {
1579 ITEM_ICMP6_ND_OPT_TYPE,
1584 static const enum index item_icmp6_nd_opt_sla_eth[] = {
1585 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
1590 static const enum index item_icmp6_nd_opt_tla_eth[] = {
1591 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
1596 static const enum index item_meta[] = {
1602 static const enum index item_gtp_psc[] = {
1609 static const enum index item_pppoed[] = {
1615 static const enum index item_pppoes[] = {
1621 static const enum index item_pppoe_proto_id[] = {
1626 static const enum index item_higig2[] = {
1627 ITEM_HIGIG2_CLASSIFICATION,
1633 static const enum index item_esp[] = {
1639 static const enum index item_ah[] = {
1645 static const enum index item_pfcp[] = {
1652 static const enum index next_set_raw[] = {
1658 static const enum index item_tag[] = {
1665 static const enum index item_l2tpv3oip[] = {
1666 ITEM_L2TPV3OIP_SESSION_ID,
1671 static const enum index item_ecpri[] = {
1677 static const enum index item_ecpri_common[] = {
1678 ITEM_ECPRI_COMMON_TYPE,
1682 static const enum index item_ecpri_common_type[] = {
1683 ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
1684 ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
1685 ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
1689 static const enum index item_geneve_opt[] = {
1690 ITEM_GENEVE_OPT_CLASS,
1691 ITEM_GENEVE_OPT_TYPE,
1692 ITEM_GENEVE_OPT_LENGTH,
1693 ITEM_GENEVE_OPT_DATA,
1698 static const enum index item_integrity[] = {
1699 ITEM_INTEGRITY_LEVEL,
1700 ITEM_INTEGRITY_VALUE,
1704 static const enum index item_integrity_lv[] = {
1705 ITEM_INTEGRITY_LEVEL,
1706 ITEM_INTEGRITY_VALUE,
1711 static const enum index item_port_representor[] = {
1712 ITEM_PORT_REPRESENTOR_PORT_ID,
1717 static const enum index item_represented_port[] = {
1718 ITEM_REPRESENTED_PORT_ETHDEV_PORT_ID,
1723 static const enum index item_flex[] = {
1724 ITEM_FLEX_PATTERN_HANDLE,
1725 ITEM_FLEX_ITEM_HANDLE,
1730 static const enum index item_l2tpv2[] = {
1736 static const enum index item_l2tpv2_type[] = {
1737 ITEM_L2TPV2_TYPE_DATA,
1738 ITEM_L2TPV2_TYPE_DATA_L,
1739 ITEM_L2TPV2_TYPE_DATA_S,
1740 ITEM_L2TPV2_TYPE_DATA_O,
1741 ITEM_L2TPV2_TYPE_DATA_L_S,
1742 ITEM_L2TPV2_TYPE_CTRL,
1746 static const enum index item_l2tpv2_type_data[] = {
1747 ITEM_L2TPV2_MSG_DATA_TUNNEL_ID,
1748 ITEM_L2TPV2_MSG_DATA_SESSION_ID,
1753 static const enum index item_l2tpv2_type_data_l[] = {
1754 ITEM_L2TPV2_MSG_DATA_L_LENGTH,
1755 ITEM_L2TPV2_MSG_DATA_L_TUNNEL_ID,
1756 ITEM_L2TPV2_MSG_DATA_L_SESSION_ID,
1761 static const enum index item_l2tpv2_type_data_s[] = {
1762 ITEM_L2TPV2_MSG_DATA_S_TUNNEL_ID,
1763 ITEM_L2TPV2_MSG_DATA_S_SESSION_ID,
1764 ITEM_L2TPV2_MSG_DATA_S_NS,
1765 ITEM_L2TPV2_MSG_DATA_S_NR,
1770 static const enum index item_l2tpv2_type_data_o[] = {
1771 ITEM_L2TPV2_MSG_DATA_O_TUNNEL_ID,
1772 ITEM_L2TPV2_MSG_DATA_O_SESSION_ID,
1773 ITEM_L2TPV2_MSG_DATA_O_OFFSET,
1778 static const enum index item_l2tpv2_type_data_l_s[] = {
1779 ITEM_L2TPV2_MSG_DATA_L_S_LENGTH,
1780 ITEM_L2TPV2_MSG_DATA_L_S_TUNNEL_ID,
1781 ITEM_L2TPV2_MSG_DATA_L_S_SESSION_ID,
1782 ITEM_L2TPV2_MSG_DATA_L_S_NS,
1783 ITEM_L2TPV2_MSG_DATA_L_S_NR,
1788 static const enum index item_l2tpv2_type_ctrl[] = {
1789 ITEM_L2TPV2_MSG_CTRL_LENGTH,
1790 ITEM_L2TPV2_MSG_CTRL_TUNNEL_ID,
1791 ITEM_L2TPV2_MSG_CTRL_SESSION_ID,
1792 ITEM_L2TPV2_MSG_CTRL_NS,
1793 ITEM_L2TPV2_MSG_CTRL_NR,
1798 static const enum index item_ppp[] = {
1806 static const enum index next_action[] = {
1823 ACTION_OF_SET_MPLS_TTL,
1824 ACTION_OF_DEC_MPLS_TTL,
1825 ACTION_OF_SET_NW_TTL,
1826 ACTION_OF_DEC_NW_TTL,
1827 ACTION_OF_COPY_TTL_OUT,
1828 ACTION_OF_COPY_TTL_IN,
1830 ACTION_OF_PUSH_VLAN,
1831 ACTION_OF_SET_VLAN_VID,
1832 ACTION_OF_SET_VLAN_PCP,
1834 ACTION_OF_PUSH_MPLS,
1841 ACTION_MPLSOGRE_ENCAP,
1842 ACTION_MPLSOGRE_DECAP,
1843 ACTION_MPLSOUDP_ENCAP,
1844 ACTION_MPLSOUDP_DECAP,
1845 ACTION_SET_IPV4_SRC,
1846 ACTION_SET_IPV4_DST,
1847 ACTION_SET_IPV6_SRC,
1848 ACTION_SET_IPV6_DST,
1864 ACTION_SET_IPV4_DSCP,
1865 ACTION_SET_IPV6_DSCP,
1869 ACTION_MODIFY_FIELD,
1871 ACTION_CONNTRACK_UPDATE,
1872 ACTION_PORT_REPRESENTOR,
1873 ACTION_REPRESENTED_PORT,
1877 static const enum index action_mark[] = {
1883 static const enum index action_queue[] = {
1889 static const enum index action_count[] = {
1895 static const enum index action_rss[] = {
1906 static const enum index action_vf[] = {
1913 static const enum index action_phy_port[] = {
1914 ACTION_PHY_PORT_ORIGINAL,
1915 ACTION_PHY_PORT_INDEX,
1920 static const enum index action_port_id[] = {
1921 ACTION_PORT_ID_ORIGINAL,
1927 static const enum index action_meter[] = {
1933 static const enum index action_meter_color[] = {
1934 ACTION_METER_COLOR_TYPE,
1939 static const enum index action_of_set_mpls_ttl[] = {
1940 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
1945 static const enum index action_of_set_nw_ttl[] = {
1946 ACTION_OF_SET_NW_TTL_NW_TTL,
1951 static const enum index action_of_push_vlan[] = {
1952 ACTION_OF_PUSH_VLAN_ETHERTYPE,
1957 static const enum index action_of_set_vlan_vid[] = {
1958 ACTION_OF_SET_VLAN_VID_VLAN_VID,
1963 static const enum index action_of_set_vlan_pcp[] = {
1964 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
1969 static const enum index action_of_pop_mpls[] = {
1970 ACTION_OF_POP_MPLS_ETHERTYPE,
1975 static const enum index action_of_push_mpls[] = {
1976 ACTION_OF_PUSH_MPLS_ETHERTYPE,
1981 static const enum index action_set_ipv4_src[] = {
1982 ACTION_SET_IPV4_SRC_IPV4_SRC,
1987 static const enum index action_set_mac_src[] = {
1988 ACTION_SET_MAC_SRC_MAC_SRC,
1993 static const enum index action_set_ipv4_dst[] = {
1994 ACTION_SET_IPV4_DST_IPV4_DST,
1999 static const enum index action_set_ipv6_src[] = {
2000 ACTION_SET_IPV6_SRC_IPV6_SRC,
2005 static const enum index action_set_ipv6_dst[] = {
2006 ACTION_SET_IPV6_DST_IPV6_DST,
2011 static const enum index action_set_tp_src[] = {
2012 ACTION_SET_TP_SRC_TP_SRC,
2017 static const enum index action_set_tp_dst[] = {
2018 ACTION_SET_TP_DST_TP_DST,
2023 static const enum index action_set_ttl[] = {
2029 static const enum index action_jump[] = {
2035 static const enum index action_set_mac_dst[] = {
2036 ACTION_SET_MAC_DST_MAC_DST,
2041 static const enum index action_inc_tcp_seq[] = {
2042 ACTION_INC_TCP_SEQ_VALUE,
2047 static const enum index action_dec_tcp_seq[] = {
2048 ACTION_DEC_TCP_SEQ_VALUE,
2053 static const enum index action_inc_tcp_ack[] = {
2054 ACTION_INC_TCP_ACK_VALUE,
2059 static const enum index action_dec_tcp_ack[] = {
2060 ACTION_DEC_TCP_ACK_VALUE,
2065 static const enum index action_raw_encap[] = {
2066 ACTION_RAW_ENCAP_INDEX,
2071 static const enum index action_raw_decap[] = {
2072 ACTION_RAW_DECAP_INDEX,
2077 static const enum index action_set_tag[] = {
2078 ACTION_SET_TAG_DATA,
2079 ACTION_SET_TAG_INDEX,
2080 ACTION_SET_TAG_MASK,
2085 static const enum index action_set_meta[] = {
2086 ACTION_SET_META_DATA,
2087 ACTION_SET_META_MASK,
2092 static const enum index action_set_ipv4_dscp[] = {
2093 ACTION_SET_IPV4_DSCP_VALUE,
2098 static const enum index action_set_ipv6_dscp[] = {
2099 ACTION_SET_IPV6_DSCP_VALUE,
2104 static const enum index action_age[] = {
2111 static const enum index action_sample[] = {
2113 ACTION_SAMPLE_RATIO,
2114 ACTION_SAMPLE_INDEX,
2119 static const enum index next_action_sample[] = {
2132 static const enum index action_modify_field_dst[] = {
2133 ACTION_MODIFY_FIELD_DST_LEVEL,
2134 ACTION_MODIFY_FIELD_DST_OFFSET,
2135 ACTION_MODIFY_FIELD_SRC_TYPE,
2139 static const enum index action_modify_field_src[] = {
2140 ACTION_MODIFY_FIELD_SRC_LEVEL,
2141 ACTION_MODIFY_FIELD_SRC_OFFSET,
2142 ACTION_MODIFY_FIELD_SRC_VALUE,
2143 ACTION_MODIFY_FIELD_SRC_POINTER,
2144 ACTION_MODIFY_FIELD_WIDTH,
2148 static const enum index action_update_conntrack[] = {
2149 ACTION_CONNTRACK_UPDATE_DIR,
2150 ACTION_CONNTRACK_UPDATE_CTX,
2155 static const enum index action_port_representor[] = {
2156 ACTION_PORT_REPRESENTOR_PORT_ID,
2161 static const enum index action_represented_port[] = {
2162 ACTION_REPRESENTED_PORT_ETHDEV_PORT_ID,
2167 static int parse_set_raw_encap_decap(struct context *, const struct token *,
2168 const char *, unsigned int,
2169 void *, unsigned int);
2170 static int parse_set_sample_action(struct context *, const struct token *,
2171 const char *, unsigned int,
2172 void *, unsigned int);
2173 static int parse_set_init(struct context *, const struct token *,
2174 const char *, unsigned int,
2175 void *, unsigned int);
2177 parse_flex_handle(struct context *, const struct token *,
2178 const char *, unsigned int, void *, unsigned int);
2179 static int parse_init(struct context *, const struct token *,
2180 const char *, unsigned int,
2181 void *, unsigned int);
2182 static int parse_vc(struct context *, const struct token *,
2183 const char *, unsigned int,
2184 void *, unsigned int);
2185 static int parse_vc_spec(struct context *, const struct token *,
2186 const char *, unsigned int, void *, unsigned int);
2187 static int parse_vc_conf(struct context *, const struct token *,
2188 const char *, unsigned int, void *, unsigned int);
2189 static int parse_vc_item_ecpri_type(struct context *, const struct token *,
2190 const char *, unsigned int,
2191 void *, unsigned int);
2192 static int parse_vc_item_l2tpv2_type(struct context *, const struct token *,
2193 const char *, unsigned int,
2194 void *, unsigned int);
2195 static int parse_vc_action_meter_color_type(struct context *,
2196 const struct token *,
2197 const char *, unsigned int, void *,
2199 static int parse_vc_action_rss(struct context *, const struct token *,
2200 const char *, unsigned int, void *,
2202 static int parse_vc_action_rss_func(struct context *, const struct token *,
2203 const char *, unsigned int, void *,
2205 static int parse_vc_action_rss_type(struct context *, const struct token *,
2206 const char *, unsigned int, void *,
2208 static int parse_vc_action_rss_queue(struct context *, const struct token *,
2209 const char *, unsigned int, void *,
2211 static int parse_vc_action_vxlan_encap(struct context *, const struct token *,
2212 const char *, unsigned int, void *,
2214 static int parse_vc_action_nvgre_encap(struct context *, const struct token *,
2215 const char *, unsigned int, void *,
2217 static int parse_vc_action_l2_encap(struct context *, const struct token *,
2218 const char *, unsigned int, void *,
2220 static int parse_vc_action_l2_decap(struct context *, const struct token *,
2221 const char *, unsigned int, void *,
2223 static int parse_vc_action_mplsogre_encap(struct context *,
2224 const struct token *, const char *,
2225 unsigned int, void *, unsigned int);
2226 static int parse_vc_action_mplsogre_decap(struct context *,
2227 const struct token *, const char *,
2228 unsigned int, void *, unsigned int);
2229 static int parse_vc_action_mplsoudp_encap(struct context *,
2230 const struct token *, const char *,
2231 unsigned int, void *, unsigned int);
2232 static int parse_vc_action_mplsoudp_decap(struct context *,
2233 const struct token *, const char *,
2234 unsigned int, void *, unsigned int);
2235 static int parse_vc_action_raw_encap(struct context *,
2236 const struct token *, const char *,
2237 unsigned int, void *, unsigned int);
2238 static int parse_vc_action_raw_decap(struct context *,
2239 const struct token *, const char *,
2240 unsigned int, void *, unsigned int);
2241 static int parse_vc_action_raw_encap_index(struct context *,
2242 const struct token *, const char *,
2243 unsigned int, void *, unsigned int);
2244 static int parse_vc_action_raw_decap_index(struct context *,
2245 const struct token *, const char *,
2246 unsigned int, void *, unsigned int);
2247 static int parse_vc_action_set_meta(struct context *ctx,
2248 const struct token *token, const char *str,
2249 unsigned int len, void *buf,
2251 static int parse_vc_action_sample(struct context *ctx,
2252 const struct token *token, const char *str,
2253 unsigned int len, void *buf,
2256 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
2257 const char *str, unsigned int len, void *buf,
2260 parse_vc_modify_field_op(struct context *ctx, const struct token *token,
2261 const char *str, unsigned int len, void *buf,
2264 parse_vc_modify_field_id(struct context *ctx, const struct token *token,
2265 const char *str, unsigned int len, void *buf,
2268 parse_vc_action_conntrack_update(struct context *ctx, const struct token *token,
2269 const char *str, unsigned int len, void *buf,
2271 static int parse_destroy(struct context *, const struct token *,
2272 const char *, unsigned int,
2273 void *, unsigned int);
2274 static int parse_flush(struct context *, const struct token *,
2275 const char *, unsigned int,
2276 void *, unsigned int);
2277 static int parse_dump(struct context *, const struct token *,
2278 const char *, unsigned int,
2279 void *, unsigned int);
2280 static int parse_query(struct context *, const struct token *,
2281 const char *, unsigned int,
2282 void *, unsigned int);
2283 static int parse_action(struct context *, const struct token *,
2284 const char *, unsigned int,
2285 void *, unsigned int);
2286 static int parse_list(struct context *, const struct token *,
2287 const char *, unsigned int,
2288 void *, unsigned int);
2289 static int parse_aged(struct context *, const struct token *,
2290 const char *, unsigned int,
2291 void *, unsigned int);
2292 static int parse_isolate(struct context *, const struct token *,
2293 const char *, unsigned int,
2294 void *, unsigned int);
2295 static int parse_configure(struct context *, const struct token *,
2296 const char *, unsigned int,
2297 void *, unsigned int);
2298 static int parse_template(struct context *, const struct token *,
2299 const char *, unsigned int,
2300 void *, unsigned int);
2301 static int parse_template_destroy(struct context *, const struct token *,
2302 const char *, unsigned int,
2303 void *, unsigned int);
2304 static int parse_table(struct context *, const struct token *,
2305 const char *, unsigned int, void *, unsigned int);
2306 static int parse_table_destroy(struct context *, const struct token *,
2307 const char *, unsigned int,
2308 void *, unsigned int);
2309 static int parse_qo(struct context *, const struct token *,
2310 const char *, unsigned int,
2311 void *, unsigned int);
2312 static int parse_qo_destroy(struct context *, const struct token *,
2313 const char *, unsigned int,
2314 void *, unsigned int);
2315 static int parse_qia(struct context *, const struct token *,
2316 const char *, unsigned int,
2317 void *, unsigned int);
2318 static int parse_qia_destroy(struct context *, const struct token *,
2319 const char *, unsigned int,
2320 void *, unsigned int);
2321 static int parse_push(struct context *, const struct token *,
2322 const char *, unsigned int,
2323 void *, unsigned int);
2324 static int parse_pull(struct context *, const struct token *,
2325 const char *, unsigned int,
2326 void *, unsigned int);
2327 static int parse_tunnel(struct context *, const struct token *,
2328 const char *, unsigned int,
2329 void *, unsigned int);
2330 static int parse_flex(struct context *, const struct token *,
2331 const char *, unsigned int, void *, unsigned int);
2332 static int parse_int(struct context *, const struct token *,
2333 const char *, unsigned int,
2334 void *, unsigned int);
2335 static int parse_prefix(struct context *, const struct token *,
2336 const char *, unsigned int,
2337 void *, unsigned int);
2338 static int parse_boolean(struct context *, const struct token *,
2339 const char *, unsigned int,
2340 void *, unsigned int);
2341 static int parse_string(struct context *, const struct token *,
2342 const char *, unsigned int,
2343 void *, unsigned int);
2344 static int parse_hex(struct context *ctx, const struct token *token,
2345 const char *str, unsigned int len,
2346 void *buf, unsigned int size);
2347 static int parse_string0(struct context *, const struct token *,
2348 const char *, unsigned int,
2349 void *, unsigned int);
2350 static int parse_mac_addr(struct context *, const struct token *,
2351 const char *, unsigned int,
2352 void *, unsigned int);
2353 static int parse_ipv4_addr(struct context *, const struct token *,
2354 const char *, unsigned int,
2355 void *, unsigned int);
2356 static int parse_ipv6_addr(struct context *, const struct token *,
2357 const char *, unsigned int,
2358 void *, unsigned int);
2359 static int parse_port(struct context *, const struct token *,
2360 const char *, unsigned int,
2361 void *, unsigned int);
2362 static int parse_ia(struct context *, const struct token *,
2363 const char *, unsigned int,
2364 void *, unsigned int);
2365 static int parse_ia_destroy(struct context *ctx, const struct token *token,
2366 const char *str, unsigned int len,
2367 void *buf, unsigned int size);
2368 static int parse_ia_id2ptr(struct context *ctx, const struct token *token,
2369 const char *str, unsigned int len, void *buf,
2371 static int parse_mp(struct context *, const struct token *,
2372 const char *, unsigned int,
2373 void *, unsigned int);
2374 static int comp_none(struct context *, const struct token *,
2375 unsigned int, char *, unsigned int);
2376 static int comp_boolean(struct context *, const struct token *,
2377 unsigned int, char *, unsigned int);
2378 static int comp_action(struct context *, const struct token *,
2379 unsigned int, char *, unsigned int);
2380 static int comp_port(struct context *, const struct token *,
2381 unsigned int, char *, unsigned int);
2382 static int comp_rule_id(struct context *, const struct token *,
2383 unsigned int, char *, unsigned int);
2384 static int comp_vc_action_rss_type(struct context *, const struct token *,
2385 unsigned int, char *, unsigned int);
2386 static int comp_vc_action_rss_queue(struct context *, const struct token *,
2387 unsigned int, char *, unsigned int);
2388 static int comp_set_raw_index(struct context *, const struct token *,
2389 unsigned int, char *, unsigned int);
2390 static int comp_set_sample_index(struct context *, const struct token *,
2391 unsigned int, char *, unsigned int);
2392 static int comp_set_modify_field_op(struct context *, const struct token *,
2393 unsigned int, char *, unsigned int);
2394 static int comp_set_modify_field_id(struct context *, const struct token *,
2395 unsigned int, char *, unsigned int);
2396 static int comp_pattern_template_id(struct context *, const struct token *,
2397 unsigned int, char *, unsigned int);
2398 static int comp_actions_template_id(struct context *, const struct token *,
2399 unsigned int, char *, unsigned int);
2400 static int comp_table_id(struct context *, const struct token *,
2401 unsigned int, char *, unsigned int);
2402 static int comp_queue_id(struct context *, const struct token *,
2403 unsigned int, char *, unsigned int);
2405 /** Token definitions. */
2406 static const struct token token_list[] = {
2407 /* Special tokens. */
2410 .help = "null entry, abused as the entry point",
2411 .next = NEXT(NEXT_ENTRY(FLOW, ADD)),
2416 .help = "command may end here",
2419 .name = "START_SET",
2420 .help = "null entry, abused as the entry point for set",
2421 .next = NEXT(NEXT_ENTRY(SET)),
2426 .help = "set command may end here",
2428 /* Common tokens. */
2429 [COMMON_INTEGER] = {
2432 .help = "integer value",
2436 [COMMON_UNSIGNED] = {
2437 .name = "{unsigned}",
2439 .help = "unsigned integer value",
2446 .help = "prefix length for bit-mask",
2447 .call = parse_prefix,
2450 [COMMON_BOOLEAN] = {
2451 .name = "{boolean}",
2453 .help = "any boolean value",
2454 .call = parse_boolean,
2455 .comp = comp_boolean,
2460 .help = "fixed string",
2461 .call = parse_string,
2467 .help = "fixed string",
2470 [COMMON_FILE_PATH] = {
2471 .name = "{file path}",
2473 .help = "file path",
2474 .call = parse_string0,
2477 [COMMON_MAC_ADDR] = {
2478 .name = "{MAC address}",
2480 .help = "standard MAC address notation",
2481 .call = parse_mac_addr,
2484 [COMMON_IPV4_ADDR] = {
2485 .name = "{IPv4 address}",
2486 .type = "IPV4 ADDRESS",
2487 .help = "standard IPv4 address notation",
2488 .call = parse_ipv4_addr,
2491 [COMMON_IPV6_ADDR] = {
2492 .name = "{IPv6 address}",
2493 .type = "IPV6 ADDRESS",
2494 .help = "standard IPv6 address notation",
2495 .call = parse_ipv6_addr,
2498 [COMMON_RULE_ID] = {
2499 .name = "{rule id}",
2501 .help = "rule identifier",
2503 .comp = comp_rule_id,
2505 [COMMON_PORT_ID] = {
2506 .name = "{port_id}",
2508 .help = "port identifier",
2512 [COMMON_GROUP_ID] = {
2513 .name = "{group_id}",
2515 .help = "group identifier",
2519 [COMMON_PRIORITY_LEVEL] = {
2522 .help = "priority level",
2526 [COMMON_INDIRECT_ACTION_ID] = {
2527 .name = "{indirect_action_id}",
2528 .type = "INDIRECT_ACTION_ID",
2529 .help = "indirect action id",
2533 [COMMON_POLICY_ID] = {
2534 .name = "{policy_id}",
2535 .type = "POLICY_ID",
2536 .help = "policy id",
2540 [COMMON_FLEX_TOKEN] = {
2541 .name = "{flex token}",
2542 .type = "flex token",
2543 .help = "flex token",
2547 [COMMON_FLEX_HANDLE] = {
2548 .name = "{flex handle}",
2549 .type = "FLEX HANDLE",
2550 .help = "fill flex item data",
2551 .call = parse_flex_handle,
2554 [COMMON_PATTERN_TEMPLATE_ID] = {
2555 .name = "{pattern_template_id}",
2556 .type = "PATTERN_TEMPLATE_ID",
2557 .help = "pattern template id",
2559 .comp = comp_pattern_template_id,
2561 [COMMON_ACTIONS_TEMPLATE_ID] = {
2562 .name = "{actions_template_id}",
2563 .type = "ACTIONS_TEMPLATE_ID",
2564 .help = "actions template id",
2566 .comp = comp_actions_template_id,
2568 [COMMON_TABLE_ID] = {
2569 .name = "{table_id}",
2573 .comp = comp_table_id,
2575 [COMMON_QUEUE_ID] = {
2576 .name = "{queue_id}",
2580 .comp = comp_queue_id,
2582 /* Top-level command. */
2585 .type = "{command} {port_id} [{arg} [...]]",
2586 .help = "manage ingress/egress flow rules",
2587 .next = NEXT(NEXT_ENTRY
2610 /* Top-level command. */
2613 .help = "get information about flow engine",
2614 .next = NEXT(NEXT_ENTRY(END),
2615 NEXT_ENTRY(COMMON_PORT_ID)),
2616 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2617 .call = parse_configure,
2619 /* Top-level command. */
2621 .name = "configure",
2622 .help = "configure flow engine",
2623 .next = NEXT(next_config_attr,
2624 NEXT_ENTRY(COMMON_PORT_ID)),
2625 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2626 .call = parse_configure,
2628 /* Configure arguments. */
2629 [CONFIG_QUEUES_NUMBER] = {
2630 .name = "queues_number",
2631 .help = "number of queues",
2632 .next = NEXT(next_config_attr,
2633 NEXT_ENTRY(COMMON_UNSIGNED)),
2634 .args = ARGS(ARGS_ENTRY(struct buffer,
2635 args.configure.nb_queue)),
2637 [CONFIG_QUEUES_SIZE] = {
2638 .name = "queues_size",
2639 .help = "number of elements in queues",
2640 .next = NEXT(next_config_attr,
2641 NEXT_ENTRY(COMMON_UNSIGNED)),
2642 .args = ARGS(ARGS_ENTRY(struct buffer,
2643 args.configure.queue_attr.size)),
2645 [CONFIG_COUNTERS_NUMBER] = {
2646 .name = "counters_number",
2647 .help = "number of counters",
2648 .next = NEXT(next_config_attr,
2649 NEXT_ENTRY(COMMON_UNSIGNED)),
2650 .args = ARGS(ARGS_ENTRY(struct buffer,
2651 args.configure.port_attr.nb_counters)),
2653 [CONFIG_AGING_OBJECTS_NUMBER] = {
2654 .name = "aging_counters_number",
2655 .help = "number of aging objects",
2656 .next = NEXT(next_config_attr,
2657 NEXT_ENTRY(COMMON_UNSIGNED)),
2658 .args = ARGS(ARGS_ENTRY(struct buffer,
2659 args.configure.port_attr.nb_aging_objects)),
2661 [CONFIG_METERS_NUMBER] = {
2662 .name = "meters_number",
2663 .help = "number of meters",
2664 .next = NEXT(next_config_attr,
2665 NEXT_ENTRY(COMMON_UNSIGNED)),
2666 .args = ARGS(ARGS_ENTRY(struct buffer,
2667 args.configure.port_attr.nb_meters)),
2669 /* Top-level command. */
2670 [PATTERN_TEMPLATE] = {
2671 .name = "pattern_template",
2672 .type = "{command} {port_id} [{arg} [...]]",
2673 .help = "manage pattern templates",
2674 .next = NEXT(next_pt_subcmd, NEXT_ENTRY(COMMON_PORT_ID)),
2675 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2676 .call = parse_template,
2678 /* Sub-level commands. */
2679 [PATTERN_TEMPLATE_CREATE] = {
2681 .help = "create pattern template",
2682 .next = NEXT(next_pt_attr),
2683 .call = parse_template,
2685 [PATTERN_TEMPLATE_DESTROY] = {
2687 .help = "destroy pattern template",
2688 .next = NEXT(NEXT_ENTRY(PATTERN_TEMPLATE_DESTROY_ID)),
2689 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2690 .call = parse_template_destroy,
2692 /* Pattern template arguments. */
2693 [PATTERN_TEMPLATE_CREATE_ID] = {
2694 .name = "pattern_template_id",
2695 .help = "specify a pattern template id to create",
2696 .next = NEXT(next_pt_attr,
2697 NEXT_ENTRY(COMMON_PATTERN_TEMPLATE_ID)),
2698 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.pat_templ_id)),
2700 [PATTERN_TEMPLATE_DESTROY_ID] = {
2701 .name = "pattern_template",
2702 .help = "specify a pattern template id to destroy",
2703 .next = NEXT(next_pt_destroy_attr,
2704 NEXT_ENTRY(COMMON_PATTERN_TEMPLATE_ID)),
2705 .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
2706 args.templ_destroy.template_id)),
2707 .call = parse_template_destroy,
2709 [PATTERN_TEMPLATE_RELAXED_MATCHING] = {
2711 .help = "is matching relaxed",
2712 .next = NEXT(next_pt_attr,
2713 NEXT_ENTRY(COMMON_BOOLEAN)),
2714 .args = ARGS(ARGS_ENTRY_BF(struct buffer,
2715 args.vc.attr.reserved, 1)),
2717 [PATTERN_TEMPLATE_INGRESS] = {
2719 .help = "attribute pattern to ingress",
2720 .next = NEXT(next_pt_attr),
2721 .call = parse_template,
2723 [PATTERN_TEMPLATE_EGRESS] = {
2725 .help = "attribute pattern to egress",
2726 .next = NEXT(next_pt_attr),
2727 .call = parse_template,
2729 [PATTERN_TEMPLATE_TRANSFER] = {
2731 .help = "attribute pattern to transfer",
2732 .next = NEXT(next_pt_attr),
2733 .call = parse_template,
2735 [PATTERN_TEMPLATE_SPEC] = {
2737 .help = "specify item to create pattern template",
2738 .next = NEXT(next_item),
2740 /* Top-level command. */
2741 [ACTIONS_TEMPLATE] = {
2742 .name = "actions_template",
2743 .type = "{command} {port_id} [{arg} [...]]",
2744 .help = "manage actions templates",
2745 .next = NEXT(next_at_subcmd, NEXT_ENTRY(COMMON_PORT_ID)),
2746 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2747 .call = parse_template,
2749 /* Sub-level commands. */
2750 [ACTIONS_TEMPLATE_CREATE] = {
2752 .help = "create actions template",
2753 .next = NEXT(next_at_attr),
2754 .call = parse_template,
2756 [ACTIONS_TEMPLATE_DESTROY] = {
2758 .help = "destroy actions template",
2759 .next = NEXT(NEXT_ENTRY(ACTIONS_TEMPLATE_DESTROY_ID)),
2760 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2761 .call = parse_template_destroy,
2763 /* Actions template arguments. */
2764 [ACTIONS_TEMPLATE_CREATE_ID] = {
2765 .name = "actions_template_id",
2766 .help = "specify an actions template id to create",
2767 .next = NEXT(NEXT_ENTRY(ACTIONS_TEMPLATE_MASK),
2768 NEXT_ENTRY(ACTIONS_TEMPLATE_SPEC),
2769 NEXT_ENTRY(COMMON_ACTIONS_TEMPLATE_ID)),
2770 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.act_templ_id)),
2772 [ACTIONS_TEMPLATE_DESTROY_ID] = {
2773 .name = "actions_template",
2774 .help = "specify an actions template id to destroy",
2775 .next = NEXT(next_at_destroy_attr,
2776 NEXT_ENTRY(COMMON_ACTIONS_TEMPLATE_ID)),
2777 .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
2778 args.templ_destroy.template_id)),
2779 .call = parse_template_destroy,
2781 [ACTIONS_TEMPLATE_INGRESS] = {
2783 .help = "attribute actions to ingress",
2784 .next = NEXT(next_at_attr),
2785 .call = parse_template,
2787 [ACTIONS_TEMPLATE_EGRESS] = {
2789 .help = "attribute actions to egress",
2790 .next = NEXT(next_at_attr),
2791 .call = parse_template,
2793 [ACTIONS_TEMPLATE_TRANSFER] = {
2795 .help = "attribute actions to transfer",
2796 .next = NEXT(next_at_attr),
2797 .call = parse_template,
2799 [ACTIONS_TEMPLATE_SPEC] = {
2801 .help = "specify action to create actions template",
2802 .next = NEXT(next_action),
2803 .call = parse_template,
2805 [ACTIONS_TEMPLATE_MASK] = {
2807 .help = "specify action mask to create actions template",
2808 .next = NEXT(next_action),
2809 .call = parse_template,
2811 /* Top-level command. */
2813 .name = "template_table",
2814 .type = "{command} {port_id} [{arg} [...]]",
2815 .help = "manage template tables",
2816 .next = NEXT(next_table_subcmd, NEXT_ENTRY(COMMON_PORT_ID)),
2817 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2818 .call = parse_table,
2820 /* Sub-level commands. */
2823 .help = "create template table",
2824 .next = NEXT(next_table_attr),
2825 .call = parse_table,
2829 .help = "destroy template table",
2830 .next = NEXT(NEXT_ENTRY(TABLE_DESTROY_ID)),
2831 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2832 .call = parse_table_destroy,
2834 /* Table arguments. */
2835 [TABLE_CREATE_ID] = {
2837 .help = "specify table id to create",
2838 .next = NEXT(next_table_attr,
2839 NEXT_ENTRY(COMMON_TABLE_ID)),
2840 .args = ARGS(ARGS_ENTRY(struct buffer, args.table.id)),
2842 [TABLE_DESTROY_ID] = {
2844 .help = "specify table id to destroy",
2845 .next = NEXT(next_table_destroy_attr,
2846 NEXT_ENTRY(COMMON_TABLE_ID)),
2847 .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
2848 args.table_destroy.table_id)),
2849 .call = parse_table_destroy,
2853 .help = "specify a group",
2854 .next = NEXT(next_table_attr, NEXT_ENTRY(COMMON_GROUP_ID)),
2855 .args = ARGS(ARGS_ENTRY(struct buffer,
2856 args.table.attr.flow_attr.group)),
2858 [TABLE_PRIORITY] = {
2860 .help = "specify a priority level",
2861 .next = NEXT(next_table_attr, NEXT_ENTRY(COMMON_PRIORITY_LEVEL)),
2862 .args = ARGS(ARGS_ENTRY(struct buffer,
2863 args.table.attr.flow_attr.priority)),
2867 .help = "affect rule to egress",
2868 .next = NEXT(next_table_attr),
2869 .call = parse_table,
2873 .help = "affect rule to ingress",
2874 .next = NEXT(next_table_attr),
2875 .call = parse_table,
2877 [TABLE_TRANSFER] = {
2879 .help = "affect rule to transfer",
2880 .next = NEXT(next_table_attr),
2881 .call = parse_table,
2883 [TABLE_RULES_NUMBER] = {
2884 .name = "rules_number",
2885 .help = "number of rules in table",
2886 .next = NEXT(next_table_attr,
2887 NEXT_ENTRY(COMMON_UNSIGNED)),
2888 .args = ARGS(ARGS_ENTRY(struct buffer,
2889 args.table.attr.nb_flows)),
2891 [TABLE_PATTERN_TEMPLATE] = {
2892 .name = "pattern_template",
2893 .help = "specify pattern template id",
2894 .next = NEXT(next_table_attr,
2895 NEXT_ENTRY(COMMON_PATTERN_TEMPLATE_ID)),
2896 .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
2897 args.table.pat_templ_id)),
2898 .call = parse_table,
2900 [TABLE_ACTIONS_TEMPLATE] = {
2901 .name = "actions_template",
2902 .help = "specify actions template id",
2903 .next = NEXT(next_table_attr,
2904 NEXT_ENTRY(COMMON_ACTIONS_TEMPLATE_ID)),
2905 .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
2906 args.table.act_templ_id)),
2907 .call = parse_table,
2909 /* Top-level command. */
2912 .help = "queue a flow rule operation",
2913 .next = NEXT(next_queue_subcmd, NEXT_ENTRY(COMMON_PORT_ID)),
2914 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2917 /* Sub-level commands. */
2920 .help = "create a flow rule",
2921 .next = NEXT(NEXT_ENTRY(QUEUE_TEMPLATE_TABLE),
2922 NEXT_ENTRY(COMMON_QUEUE_ID)),
2923 .args = ARGS(ARGS_ENTRY(struct buffer, queue)),
2928 .help = "destroy a flow rule",
2929 .next = NEXT(NEXT_ENTRY(QUEUE_DESTROY_ID),
2930 NEXT_ENTRY(COMMON_QUEUE_ID)),
2931 .args = ARGS(ARGS_ENTRY(struct buffer, queue)),
2932 .call = parse_qo_destroy,
2934 [QUEUE_INDIRECT_ACTION] = {
2935 .name = "indirect_action",
2936 .help = "queue indirect actions",
2937 .next = NEXT(next_qia_subcmd, NEXT_ENTRY(COMMON_QUEUE_ID)),
2938 .args = ARGS(ARGS_ENTRY(struct buffer, queue)),
2941 /* Queue arguments. */
2942 [QUEUE_TEMPLATE_TABLE] = {
2943 .name = "template table",
2944 .help = "specify table id",
2945 .next = NEXT(NEXT_ENTRY(QUEUE_PATTERN_TEMPLATE),
2946 NEXT_ENTRY(COMMON_TABLE_ID)),
2947 .args = ARGS(ARGS_ENTRY(struct buffer,
2951 [QUEUE_PATTERN_TEMPLATE] = {
2952 .name = "pattern_template",
2953 .help = "specify pattern template index",
2954 .next = NEXT(NEXT_ENTRY(QUEUE_ACTIONS_TEMPLATE),
2955 NEXT_ENTRY(COMMON_UNSIGNED)),
2956 .args = ARGS(ARGS_ENTRY(struct buffer,
2957 args.vc.pat_templ_id)),
2960 [QUEUE_ACTIONS_TEMPLATE] = {
2961 .name = "actions_template",
2962 .help = "specify actions template index",
2963 .next = NEXT(NEXT_ENTRY(QUEUE_CREATE_POSTPONE),
2964 NEXT_ENTRY(COMMON_UNSIGNED)),
2965 .args = ARGS(ARGS_ENTRY(struct buffer,
2966 args.vc.act_templ_id)),
2969 [QUEUE_CREATE_POSTPONE] = {
2971 .help = "postpone create operation",
2972 .next = NEXT(NEXT_ENTRY(ITEM_PATTERN),
2973 NEXT_ENTRY(COMMON_BOOLEAN)),
2974 .args = ARGS(ARGS_ENTRY(struct buffer, postpone)),
2977 [QUEUE_DESTROY_POSTPONE] = {
2979 .help = "postpone destroy operation",
2980 .next = NEXT(NEXT_ENTRY(QUEUE_DESTROY_ID),
2981 NEXT_ENTRY(COMMON_BOOLEAN)),
2982 .args = ARGS(ARGS_ENTRY(struct buffer, postpone)),
2983 .call = parse_qo_destroy,
2985 [QUEUE_DESTROY_ID] = {
2987 .help = "specify rule id to destroy",
2988 .next = NEXT(next_queue_destroy_attr,
2989 NEXT_ENTRY(COMMON_UNSIGNED)),
2990 .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
2991 args.destroy.rule)),
2992 .call = parse_qo_destroy,
2994 /* Queue indirect action arguments */
2995 [QUEUE_INDIRECT_ACTION_CREATE] = {
2997 .help = "create indirect action",
2998 .next = NEXT(next_qia_create_attr),
3001 [QUEUE_INDIRECT_ACTION_UPDATE] = {
3003 .help = "update indirect action",
3004 .next = NEXT(next_qia_update_attr,
3005 NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
3006 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
3009 [QUEUE_INDIRECT_ACTION_DESTROY] = {
3011 .help = "destroy indirect action",
3012 .next = NEXT(next_qia_destroy_attr),
3013 .call = parse_qia_destroy,
3015 /* Indirect action destroy arguments. */
3016 [QUEUE_INDIRECT_ACTION_DESTROY_POSTPONE] = {
3018 .help = "postpone destroy operation",
3019 .next = NEXT(next_qia_destroy_attr,
3020 NEXT_ENTRY(COMMON_BOOLEAN)),
3021 .args = ARGS(ARGS_ENTRY(struct buffer, postpone)),
3023 [QUEUE_INDIRECT_ACTION_DESTROY_ID] = {
3024 .name = "action_id",
3025 .help = "specify a indirect action id to destroy",
3026 .next = NEXT(next_qia_destroy_attr,
3027 NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
3028 .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
3029 args.ia_destroy.action_id)),
3030 .call = parse_qia_destroy,
3032 /* Indirect action update arguments. */
3033 [QUEUE_INDIRECT_ACTION_UPDATE_POSTPONE] = {
3035 .help = "postpone update operation",
3036 .next = NEXT(next_qia_update_attr,
3037 NEXT_ENTRY(COMMON_BOOLEAN)),
3038 .args = ARGS(ARGS_ENTRY(struct buffer, postpone)),
3040 /* Indirect action create arguments. */
3041 [QUEUE_INDIRECT_ACTION_CREATE_ID] = {
3042 .name = "action_id",
3043 .help = "specify a indirect action id to create",
3044 .next = NEXT(next_qia_create_attr,
3045 NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
3046 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
3048 [QUEUE_INDIRECT_ACTION_INGRESS] = {
3050 .help = "affect rule to ingress",
3051 .next = NEXT(next_qia_create_attr),
3054 [QUEUE_INDIRECT_ACTION_EGRESS] = {
3056 .help = "affect rule to egress",
3057 .next = NEXT(next_qia_create_attr),
3060 [QUEUE_INDIRECT_ACTION_TRANSFER] = {
3062 .help = "affect rule to transfer",
3063 .next = NEXT(next_qia_create_attr),
3066 [QUEUE_INDIRECT_ACTION_CREATE_POSTPONE] = {
3068 .help = "postpone create operation",
3069 .next = NEXT(next_qia_create_attr,
3070 NEXT_ENTRY(COMMON_BOOLEAN)),
3071 .args = ARGS(ARGS_ENTRY(struct buffer, postpone)),
3073 [QUEUE_INDIRECT_ACTION_SPEC] = {
3075 .help = "specify action to create indirect handle",
3076 .next = NEXT(next_action),
3078 /* Top-level command. */
3081 .help = "push enqueued operations",
3082 .next = NEXT(NEXT_ENTRY(PUSH_QUEUE), NEXT_ENTRY(COMMON_PORT_ID)),
3083 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3086 /* Sub-level commands. */
3089 .help = "specify queue id",
3090 .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(COMMON_QUEUE_ID)),
3091 .args = ARGS(ARGS_ENTRY(struct buffer, queue)),
3093 /* Top-level command. */
3096 .help = "pull flow operations results",
3097 .next = NEXT(NEXT_ENTRY(PULL_QUEUE), NEXT_ENTRY(COMMON_PORT_ID)),
3098 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3101 /* Sub-level commands. */
3104 .help = "specify queue id",
3105 .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(COMMON_QUEUE_ID)),
3106 .args = ARGS(ARGS_ENTRY(struct buffer, queue)),
3108 /* Top-level command. */
3109 [INDIRECT_ACTION] = {
3110 .name = "indirect_action",
3111 .type = "{command} {port_id} [{arg} [...]]",
3112 .help = "manage indirect actions",
3113 .next = NEXT(next_ia_subcmd, NEXT_ENTRY(COMMON_PORT_ID)),
3114 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3117 /* Sub-level commands. */
3118 [INDIRECT_ACTION_CREATE] = {
3120 .help = "create indirect action",
3121 .next = NEXT(next_ia_create_attr),
3124 [INDIRECT_ACTION_UPDATE] = {
3126 .help = "update indirect action",
3127 .next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_SPEC),
3128 NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
3129 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
3132 [INDIRECT_ACTION_DESTROY] = {
3134 .help = "destroy indirect action",
3135 .next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_DESTROY_ID)),
3136 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3137 .call = parse_ia_destroy,
3139 [INDIRECT_ACTION_QUERY] = {
3141 .help = "query indirect action",
3142 .next = NEXT(NEXT_ENTRY(END),
3143 NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
3144 .args = ARGS(ARGS_ENTRY(struct buffer, args.ia.action_id)),
3149 .help = "check whether a flow rule can be created",
3150 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_PORT_ID)),
3151 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3156 .help = "create a flow rule",
3157 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_PORT_ID)),
3158 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3163 .help = "destroy specific flow rules",
3164 .next = NEXT(NEXT_ENTRY(DESTROY_RULE),
3165 NEXT_ENTRY(COMMON_PORT_ID)),
3166 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3167 .call = parse_destroy,
3171 .help = "destroy all flow rules",
3172 .next = NEXT(NEXT_ENTRY(COMMON_PORT_ID)),
3173 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3174 .call = parse_flush,
3178 .help = "dump single/all flow rules to file",
3179 .next = NEXT(next_dump_subcmd, NEXT_ENTRY(COMMON_PORT_ID)),
3180 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3185 .help = "query an existing flow rule",
3186 .next = NEXT(NEXT_ENTRY(QUERY_ACTION),
3187 NEXT_ENTRY(COMMON_RULE_ID),
3188 NEXT_ENTRY(COMMON_PORT_ID)),
3189 .args = ARGS(ARGS_ENTRY(struct buffer, args.query.action.type),
3190 ARGS_ENTRY(struct buffer, args.query.rule),
3191 ARGS_ENTRY(struct buffer, port)),
3192 .call = parse_query,
3196 .help = "list existing flow rules",
3197 .next = NEXT(next_list_attr, NEXT_ENTRY(COMMON_PORT_ID)),
3198 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3203 .help = "list and destroy aged flows",
3204 .next = NEXT(next_aged_attr, NEXT_ENTRY(COMMON_PORT_ID)),
3205 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3210 .help = "restrict ingress traffic to the defined flow rules",
3211 .next = NEXT(NEXT_ENTRY(COMMON_BOOLEAN),
3212 NEXT_ENTRY(COMMON_PORT_ID)),
3213 .args = ARGS(ARGS_ENTRY(struct buffer, args.isolate.set),
3214 ARGS_ENTRY(struct buffer, port)),
3215 .call = parse_isolate,
3218 .name = "flex_item",
3219 .help = "flex item API",
3220 .next = NEXT(next_flex_item),
3223 [FLEX_ITEM_INIT] = {
3225 .help = "flex item init",
3226 .args = ARGS(ARGS_ENTRY(struct buffer, args.flex.token),
3227 ARGS_ENTRY(struct buffer, port)),
3228 .next = NEXT(NEXT_ENTRY(COMMON_FLEX_TOKEN),
3229 NEXT_ENTRY(COMMON_PORT_ID)),
3232 [FLEX_ITEM_CREATE] = {
3234 .help = "flex item create",
3235 .args = ARGS(ARGS_ENTRY(struct buffer, args.flex.filename),
3236 ARGS_ENTRY(struct buffer, args.flex.token),
3237 ARGS_ENTRY(struct buffer, port)),
3238 .next = NEXT(NEXT_ENTRY(COMMON_FILE_PATH),
3239 NEXT_ENTRY(COMMON_FLEX_TOKEN),
3240 NEXT_ENTRY(COMMON_PORT_ID)),
3243 [FLEX_ITEM_DESTROY] = {
3245 .help = "flex item destroy",
3246 .args = ARGS(ARGS_ENTRY(struct buffer, args.flex.token),
3247 ARGS_ENTRY(struct buffer, port)),
3248 .next = NEXT(NEXT_ENTRY(COMMON_FLEX_TOKEN),
3249 NEXT_ENTRY(COMMON_PORT_ID)),
3254 .help = "new tunnel API",
3255 .next = NEXT(NEXT_ENTRY
3256 (TUNNEL_CREATE, TUNNEL_LIST, TUNNEL_DESTROY)),
3257 .call = parse_tunnel,
3259 /* Tunnel arguments. */
3262 .help = "create new tunnel object",
3263 .next = NEXT(NEXT_ENTRY(TUNNEL_CREATE_TYPE),
3264 NEXT_ENTRY(COMMON_PORT_ID)),
3265 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3266 .call = parse_tunnel,
3268 [TUNNEL_CREATE_TYPE] = {
3270 .help = "create new tunnel",
3271 .next = NEXT(NEXT_ENTRY(COMMON_FILE_PATH)),
3272 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, type)),
3273 .call = parse_tunnel,
3275 [TUNNEL_DESTROY] = {
3277 .help = "destroy tunnel",
3278 .next = NEXT(NEXT_ENTRY(TUNNEL_DESTROY_ID),
3279 NEXT_ENTRY(COMMON_PORT_ID)),
3280 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3281 .call = parse_tunnel,
3283 [TUNNEL_DESTROY_ID] = {
3285 .help = "tunnel identifier to destroy",
3286 .next = NEXT(NEXT_ENTRY(COMMON_UNSIGNED)),
3287 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
3288 .call = parse_tunnel,
3292 .help = "list existing tunnels",
3293 .next = NEXT(NEXT_ENTRY(COMMON_PORT_ID)),
3294 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3295 .call = parse_tunnel,
3297 /* Destroy arguments. */
3300 .help = "specify a rule identifier",
3301 .next = NEXT(next_destroy_attr, NEXT_ENTRY(COMMON_RULE_ID)),
3302 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.destroy.rule)),
3303 .call = parse_destroy,
3305 /* Dump arguments. */
3309 .next = NEXT(next_dump_attr),
3310 .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file)),
3315 .help = "dump one rule",
3316 .next = NEXT(next_dump_attr, NEXT_ENTRY(COMMON_RULE_ID)),
3317 .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file),
3318 ARGS_ENTRY(struct buffer, args.dump.rule)),
3321 /* Query arguments. */
3325 .help = "action to query, must be part of the rule",
3326 .call = parse_action,
3327 .comp = comp_action,
3329 /* List arguments. */
3332 .help = "specify a group",
3333 .next = NEXT(next_list_attr, NEXT_ENTRY(COMMON_GROUP_ID)),
3334 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.list.group)),
3339 .help = "specify aged flows need be destroyed",
3343 /* Validate/create attributes. */
3346 .help = "specify a group",
3347 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_GROUP_ID)),
3348 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, group)),
3353 .help = "specify a priority level",
3354 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_PRIORITY_LEVEL)),
3355 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, priority)),
3360 .help = "affect rule to ingress",
3361 .next = NEXT(next_vc_attr),
3366 .help = "affect rule to egress",
3367 .next = NEXT(next_vc_attr),
3372 .help = "apply rule directly to endpoints found in pattern",
3373 .next = NEXT(next_vc_attr),
3377 .name = "tunnel_set",
3378 .help = "tunnel steer rule",
3379 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_UNSIGNED)),
3380 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
3383 [VC_TUNNEL_MATCH] = {
3384 .name = "tunnel_match",
3385 .help = "tunnel match rule",
3386 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_UNSIGNED)),
3387 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
3390 /* Validate/create pattern. */
3393 .help = "submit a list of pattern items",
3394 .next = NEXT(next_item),
3399 .help = "match value perfectly (with full bit-mask)",
3400 .call = parse_vc_spec,
3402 [ITEM_PARAM_SPEC] = {
3404 .help = "match value according to configured bit-mask",
3405 .call = parse_vc_spec,
3407 [ITEM_PARAM_LAST] = {
3409 .help = "specify upper bound to establish a range",
3410 .call = parse_vc_spec,
3412 [ITEM_PARAM_MASK] = {
3414 .help = "specify bit-mask with relevant bits set to one",
3415 .call = parse_vc_spec,
3417 [ITEM_PARAM_PREFIX] = {
3419 .help = "generate bit-mask from a prefix length",
3420 .call = parse_vc_spec,
3424 .help = "specify next pattern item",
3425 .next = NEXT(next_item),
3429 .help = "end list of pattern items",
3430 .priv = PRIV_ITEM(END, 0),
3431 .next = NEXT(NEXT_ENTRY(ACTIONS, END)),
3436 .help = "no-op pattern item",
3437 .priv = PRIV_ITEM(VOID, 0),
3438 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
3443 .help = "perform actions when pattern does not match",
3444 .priv = PRIV_ITEM(INVERT, 0),
3445 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
3450 .help = "match any protocol for the current layer",
3451 .priv = PRIV_ITEM(ANY, sizeof(struct rte_flow_item_any)),
3452 .next = NEXT(item_any),
3457 .help = "number of layers covered",
3458 .next = NEXT(item_any, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3459 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_any, num)),
3463 .help = "match traffic from/to the physical function",
3464 .priv = PRIV_ITEM(PF, 0),
3465 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
3470 .help = "match traffic from/to a virtual function ID",
3471 .priv = PRIV_ITEM(VF, sizeof(struct rte_flow_item_vf)),
3472 .next = NEXT(item_vf),
3478 .next = NEXT(item_vf, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3479 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_vf, id)),
3483 .help = "match traffic from/to a specific physical port",
3484 .priv = PRIV_ITEM(PHY_PORT,
3485 sizeof(struct rte_flow_item_phy_port)),
3486 .next = NEXT(item_phy_port),
3489 [ITEM_PHY_PORT_INDEX] = {
3491 .help = "physical port index",
3492 .next = NEXT(item_phy_port, NEXT_ENTRY(COMMON_UNSIGNED),
3494 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_phy_port, index)),
3498 .help = "match traffic from/to a given DPDK port ID",
3499 .priv = PRIV_ITEM(PORT_ID,
3500 sizeof(struct rte_flow_item_port_id)),
3501 .next = NEXT(item_port_id),
3504 [ITEM_PORT_ID_ID] = {
3506 .help = "DPDK port ID",
3507 .next = NEXT(item_port_id, NEXT_ENTRY(COMMON_UNSIGNED),
3509 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port_id, id)),
3513 .help = "match traffic against value set in previously matched rule",
3514 .priv = PRIV_ITEM(MARK, sizeof(struct rte_flow_item_mark)),
3515 .next = NEXT(item_mark),
3520 .help = "Integer value to match against",
3521 .next = NEXT(item_mark, NEXT_ENTRY(COMMON_UNSIGNED),
3523 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_mark, id)),
3527 .help = "match an arbitrary byte string",
3528 .priv = PRIV_ITEM(RAW, ITEM_RAW_SIZE),
3529 .next = NEXT(item_raw),
3532 [ITEM_RAW_RELATIVE] = {
3534 .help = "look for pattern after the previous item",
3535 .next = NEXT(item_raw, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
3536 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
3539 [ITEM_RAW_SEARCH] = {
3541 .help = "search pattern from offset (see also limit)",
3542 .next = NEXT(item_raw, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
3543 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
3546 [ITEM_RAW_OFFSET] = {
3548 .help = "absolute or relative offset for pattern",
3549 .next = NEXT(item_raw, NEXT_ENTRY(COMMON_INTEGER), item_param),
3550 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, offset)),
3552 [ITEM_RAW_LIMIT] = {
3554 .help = "search area limit for start of pattern",
3555 .next = NEXT(item_raw, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3556 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, limit)),
3558 [ITEM_RAW_PATTERN] = {
3560 .help = "byte string to look for",
3561 .next = NEXT(item_raw,
3562 NEXT_ENTRY(COMMON_STRING),
3563 NEXT_ENTRY(ITEM_PARAM_IS,
3566 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern),
3567 ARGS_ENTRY(struct rte_flow_item_raw, length),
3568 ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw),
3569 ITEM_RAW_PATTERN_SIZE)),
3571 [ITEM_RAW_PATTERN_HEX] = {
3572 .name = "pattern_hex",
3573 .help = "hex string to look for",
3574 .next = NEXT(item_raw,
3575 NEXT_ENTRY(COMMON_HEX),
3576 NEXT_ENTRY(ITEM_PARAM_IS,
3579 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern),
3580 ARGS_ENTRY(struct rte_flow_item_raw, length),
3581 ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw),
3582 ITEM_RAW_PATTERN_SIZE)),
3586 .help = "match Ethernet header",
3587 .priv = PRIV_ITEM(ETH, sizeof(struct rte_flow_item_eth)),
3588 .next = NEXT(item_eth),
3593 .help = "destination MAC",
3594 .next = NEXT(item_eth, NEXT_ENTRY(COMMON_MAC_ADDR), item_param),
3595 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, dst)),
3599 .help = "source MAC",
3600 .next = NEXT(item_eth, NEXT_ENTRY(COMMON_MAC_ADDR), item_param),
3601 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, src)),
3605 .help = "EtherType",
3606 .next = NEXT(item_eth, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3607 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, type)),
3609 [ITEM_ETH_HAS_VLAN] = {
3611 .help = "packet header contains VLAN",
3612 .next = NEXT(item_eth, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3613 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_eth,
3618 .help = "match 802.1Q/ad VLAN tag",
3619 .priv = PRIV_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)),
3620 .next = NEXT(item_vlan),
3625 .help = "tag control information",
3626 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
3628 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, tci)),
3632 .help = "priority code point",
3633 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
3635 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
3640 .help = "drop eligible indicator",
3641 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
3643 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
3648 .help = "VLAN identifier",
3649 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
3651 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
3654 [ITEM_VLAN_INNER_TYPE] = {
3655 .name = "inner_type",
3656 .help = "inner EtherType",
3657 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
3659 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan,
3662 [ITEM_VLAN_HAS_MORE_VLAN] = {
3663 .name = "has_more_vlan",
3664 .help = "packet header contains another VLAN",
3665 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
3667 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vlan,
3672 .help = "match IPv4 header",
3673 .priv = PRIV_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)),
3674 .next = NEXT(item_ipv4),
3677 [ITEM_IPV4_VER_IHL] = {
3678 .name = "version_ihl",
3679 .help = "match header length",
3680 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
3682 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ipv4,
3687 .help = "type of service",
3688 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
3690 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
3691 hdr.type_of_service)),
3694 .name = "packet_id",
3695 .help = "fragment packet id",
3696 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
3698 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
3701 [ITEM_IPV4_FRAGMENT_OFFSET] = {
3702 .name = "fragment_offset",
3703 .help = "fragmentation flags and fragment offset",
3704 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
3706 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
3707 hdr.fragment_offset)),
3711 .help = "time to live",
3712 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
3714 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
3717 [ITEM_IPV4_PROTO] = {
3719 .help = "next protocol ID",
3720 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
3722 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
3723 hdr.next_proto_id)),
3727 .help = "source address",
3728 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
3730 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
3735 .help = "destination address",
3736 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
3738 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
3743 .help = "match IPv6 header",
3744 .priv = PRIV_ITEM(IPV6, sizeof(struct rte_flow_item_ipv6)),
3745 .next = NEXT(item_ipv6),
3750 .help = "traffic class",
3751 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
3753 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
3755 "\x0f\xf0\x00\x00")),
3757 [ITEM_IPV6_FLOW] = {
3759 .help = "flow label",
3760 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
3762 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
3764 "\x00\x0f\xff\xff")),
3766 [ITEM_IPV6_PROTO] = {
3768 .help = "protocol (next header)",
3769 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
3771 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
3776 .help = "hop limit",
3777 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
3779 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
3784 .help = "source address",
3785 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_IPV6_ADDR),
3787 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
3792 .help = "destination address",
3793 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_IPV6_ADDR),
3795 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
3798 [ITEM_IPV6_HAS_FRAG_EXT] = {
3799 .name = "has_frag_ext",
3800 .help = "fragment packet attribute",
3801 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
3803 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_ipv6,
3808 .help = "match ICMP header",
3809 .priv = PRIV_ITEM(ICMP, sizeof(struct rte_flow_item_icmp)),
3810 .next = NEXT(item_icmp),
3813 [ITEM_ICMP_TYPE] = {
3815 .help = "ICMP packet type",
3816 .next = NEXT(item_icmp, NEXT_ENTRY(COMMON_UNSIGNED),
3818 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
3821 [ITEM_ICMP_CODE] = {
3823 .help = "ICMP packet code",
3824 .next = NEXT(item_icmp, NEXT_ENTRY(COMMON_UNSIGNED),
3826 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
3829 [ITEM_ICMP_IDENT] = {
3831 .help = "ICMP packet identifier",
3832 .next = NEXT(item_icmp, NEXT_ENTRY(COMMON_UNSIGNED),
3834 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
3839 .help = "ICMP packet sequence number",
3840 .next = NEXT(item_icmp, NEXT_ENTRY(COMMON_UNSIGNED),
3842 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
3847 .help = "match UDP header",
3848 .priv = PRIV_ITEM(UDP, sizeof(struct rte_flow_item_udp)),
3849 .next = NEXT(item_udp),
3854 .help = "UDP source port",
3855 .next = NEXT(item_udp, NEXT_ENTRY(COMMON_UNSIGNED),
3857 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
3862 .help = "UDP destination port",
3863 .next = NEXT(item_udp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3864 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
3869 .help = "match TCP header",
3870 .priv = PRIV_ITEM(TCP, sizeof(struct rte_flow_item_tcp)),
3871 .next = NEXT(item_tcp),
3876 .help = "TCP source port",
3877 .next = NEXT(item_tcp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3878 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
3883 .help = "TCP destination port",
3884 .next = NEXT(item_tcp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3885 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
3888 [ITEM_TCP_FLAGS] = {
3890 .help = "TCP flags",
3891 .next = NEXT(item_tcp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3892 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
3897 .help = "match SCTP header",
3898 .priv = PRIV_ITEM(SCTP, sizeof(struct rte_flow_item_sctp)),
3899 .next = NEXT(item_sctp),
3904 .help = "SCTP source port",
3905 .next = NEXT(item_sctp, NEXT_ENTRY(COMMON_UNSIGNED),
3907 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
3912 .help = "SCTP destination port",
3913 .next = NEXT(item_sctp, NEXT_ENTRY(COMMON_UNSIGNED),
3915 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
3920 .help = "validation tag",
3921 .next = NEXT(item_sctp, NEXT_ENTRY(COMMON_UNSIGNED),
3923 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
3926 [ITEM_SCTP_CKSUM] = {
3929 .next = NEXT(item_sctp, NEXT_ENTRY(COMMON_UNSIGNED),
3931 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
3936 .help = "match VXLAN header",
3937 .priv = PRIV_ITEM(VXLAN, sizeof(struct rte_flow_item_vxlan)),
3938 .next = NEXT(item_vxlan),
3941 [ITEM_VXLAN_VNI] = {
3943 .help = "VXLAN identifier",
3944 .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
3946 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan, vni)),
3948 [ITEM_VXLAN_LAST_RSVD] = {
3949 .name = "last_rsvd",
3950 .help = "VXLAN last reserved bits",
3951 .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
3953 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan,
3958 .help = "match E-Tag header",
3959 .priv = PRIV_ITEM(E_TAG, sizeof(struct rte_flow_item_e_tag)),
3960 .next = NEXT(item_e_tag),
3963 [ITEM_E_TAG_GRP_ECID_B] = {
3964 .name = "grp_ecid_b",
3965 .help = "GRP and E-CID base",
3966 .next = NEXT(item_e_tag, NEXT_ENTRY(COMMON_UNSIGNED),
3968 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_e_tag,
3974 .help = "match NVGRE header",
3975 .priv = PRIV_ITEM(NVGRE, sizeof(struct rte_flow_item_nvgre)),
3976 .next = NEXT(item_nvgre),
3979 [ITEM_NVGRE_TNI] = {
3981 .help = "virtual subnet ID",
3982 .next = NEXT(item_nvgre, NEXT_ENTRY(COMMON_UNSIGNED),
3984 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_nvgre, tni)),
3988 .help = "match MPLS header",
3989 .priv = PRIV_ITEM(MPLS, sizeof(struct rte_flow_item_mpls)),
3990 .next = NEXT(item_mpls),
3993 [ITEM_MPLS_LABEL] = {
3995 .help = "MPLS label",
3996 .next = NEXT(item_mpls, NEXT_ENTRY(COMMON_UNSIGNED),
3998 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
4004 .help = "MPLS Traffic Class",
4005 .next = NEXT(item_mpls, NEXT_ENTRY(COMMON_UNSIGNED),
4007 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
4013 .help = "MPLS Bottom-of-Stack",
4014 .next = NEXT(item_mpls, NEXT_ENTRY(COMMON_UNSIGNED),
4016 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
4022 .help = "match GRE header",
4023 .priv = PRIV_ITEM(GRE, sizeof(struct rte_flow_item_gre)),
4024 .next = NEXT(item_gre),
4027 [ITEM_GRE_PROTO] = {
4029 .help = "GRE protocol type",
4030 .next = NEXT(item_gre, NEXT_ENTRY(COMMON_UNSIGNED),
4032 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
4035 [ITEM_GRE_C_RSVD0_VER] = {
4036 .name = "c_rsvd0_ver",
4038 "checksum (1b), undefined (1b), key bit (1b),"
4039 " sequence number (1b), reserved 0 (9b),"
4041 .next = NEXT(item_gre, NEXT_ENTRY(COMMON_UNSIGNED),
4043 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
4046 [ITEM_GRE_C_BIT] = {
4048 .help = "checksum bit (C)",
4049 .next = NEXT(item_gre, NEXT_ENTRY(COMMON_BOOLEAN),
4051 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
4053 "\x80\x00\x00\x00")),
4055 [ITEM_GRE_S_BIT] = {
4057 .help = "sequence number bit (S)",
4058 .next = NEXT(item_gre, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
4059 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
4061 "\x10\x00\x00\x00")),
4063 [ITEM_GRE_K_BIT] = {
4065 .help = "key bit (K)",
4066 .next = NEXT(item_gre, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
4067 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
4069 "\x20\x00\x00\x00")),
4073 .help = "fuzzy pattern match, expect faster than default",
4074 .priv = PRIV_ITEM(FUZZY,
4075 sizeof(struct rte_flow_item_fuzzy)),
4076 .next = NEXT(item_fuzzy),
4079 [ITEM_FUZZY_THRESH] = {
4081 .help = "match accuracy threshold",
4082 .next = NEXT(item_fuzzy, NEXT_ENTRY(COMMON_UNSIGNED),
4084 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_fuzzy,
4089 .help = "match GTP header",
4090 .priv = PRIV_ITEM(GTP, sizeof(struct rte_flow_item_gtp)),
4091 .next = NEXT(item_gtp),
4094 [ITEM_GTP_FLAGS] = {
4095 .name = "v_pt_rsv_flags",
4096 .help = "GTP flags",
4097 .next = NEXT(item_gtp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
4098 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp,
4101 [ITEM_GTP_MSG_TYPE] = {
4103 .help = "GTP message type",
4104 .next = NEXT(item_gtp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
4105 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp, msg_type)),
4109 .help = "tunnel endpoint identifier",
4110 .next = NEXT(item_gtp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
4111 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp, teid)),
4115 .help = "match GTP header",
4116 .priv = PRIV_ITEM(GTPC, sizeof(struct rte_flow_item_gtp)),
4117 .next = NEXT(item_gtp),
4122 .help = "match GTP header",
4123 .priv = PRIV_ITEM(GTPU, sizeof(struct rte_flow_item_gtp)),
4124 .next = NEXT(item_gtp),
4129 .help = "match GENEVE header",
4130 .priv = PRIV_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)),
4131 .next = NEXT(item_geneve),
4134 [ITEM_GENEVE_VNI] = {
4136 .help = "virtual network identifier",
4137 .next = NEXT(item_geneve, NEXT_ENTRY(COMMON_UNSIGNED),
4139 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve, vni)),
4141 [ITEM_GENEVE_PROTO] = {
4143 .help = "GENEVE protocol type",
4144 .next = NEXT(item_geneve, NEXT_ENTRY(COMMON_UNSIGNED),
4146 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve,
4149 [ITEM_GENEVE_OPTLEN] = {
4151 .help = "GENEVE options length in dwords",
4152 .next = NEXT(item_geneve, NEXT_ENTRY(COMMON_UNSIGNED),
4154 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_geneve,
4155 ver_opt_len_o_c_rsvd0,
4158 [ITEM_VXLAN_GPE] = {
4159 .name = "vxlan-gpe",
4160 .help = "match VXLAN-GPE header",
4161 .priv = PRIV_ITEM(VXLAN_GPE,
4162 sizeof(struct rte_flow_item_vxlan_gpe)),
4163 .next = NEXT(item_vxlan_gpe),
4166 [ITEM_VXLAN_GPE_VNI] = {
4168 .help = "VXLAN-GPE identifier",
4169 .next = NEXT(item_vxlan_gpe, NEXT_ENTRY(COMMON_UNSIGNED),
4171 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
4174 [ITEM_ARP_ETH_IPV4] = {
4175 .name = "arp_eth_ipv4",
4176 .help = "match ARP header for Ethernet/IPv4",
4177 .priv = PRIV_ITEM(ARP_ETH_IPV4,
4178 sizeof(struct rte_flow_item_arp_eth_ipv4)),
4179 .next = NEXT(item_arp_eth_ipv4),
4182 [ITEM_ARP_ETH_IPV4_SHA] = {
4184 .help = "sender hardware address",
4185 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_MAC_ADDR),
4187 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
4190 [ITEM_ARP_ETH_IPV4_SPA] = {
4192 .help = "sender IPv4 address",
4193 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
4195 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
4198 [ITEM_ARP_ETH_IPV4_THA] = {
4200 .help = "target hardware address",
4201 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_MAC_ADDR),
4203 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
4206 [ITEM_ARP_ETH_IPV4_TPA] = {
4208 .help = "target IPv4 address",
4209 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
4211 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
4216 .help = "match presence of any IPv6 extension header",
4217 .priv = PRIV_ITEM(IPV6_EXT,
4218 sizeof(struct rte_flow_item_ipv6_ext)),
4219 .next = NEXT(item_ipv6_ext),
4222 [ITEM_IPV6_EXT_NEXT_HDR] = {
4224 .help = "next header",
4225 .next = NEXT(item_ipv6_ext, NEXT_ENTRY(COMMON_UNSIGNED),
4227 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_ext,
4230 [ITEM_IPV6_FRAG_EXT] = {
4231 .name = "ipv6_frag_ext",
4232 .help = "match presence of IPv6 fragment extension header",
4233 .priv = PRIV_ITEM(IPV6_FRAG_EXT,
4234 sizeof(struct rte_flow_item_ipv6_frag_ext)),
4235 .next = NEXT(item_ipv6_frag_ext),
4238 [ITEM_IPV6_FRAG_EXT_NEXT_HDR] = {
4240 .help = "next header",
4241 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(COMMON_UNSIGNED),
4243 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ipv6_frag_ext,
4246 [ITEM_IPV6_FRAG_EXT_FRAG_DATA] = {
4247 .name = "frag_data",
4248 .help = "fragment flags and offset",
4249 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(COMMON_UNSIGNED),
4251 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_frag_ext,
4254 [ITEM_IPV6_FRAG_EXT_ID] = {
4255 .name = "packet_id",
4256 .help = "fragment packet id",
4257 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(COMMON_UNSIGNED),
4259 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_frag_ext,
4264 .help = "match any ICMPv6 header",
4265 .priv = PRIV_ITEM(ICMP6, sizeof(struct rte_flow_item_icmp6)),
4266 .next = NEXT(item_icmp6),
4269 [ITEM_ICMP6_TYPE] = {
4271 .help = "ICMPv6 type",
4272 .next = NEXT(item_icmp6, NEXT_ENTRY(COMMON_UNSIGNED),
4274 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
4277 [ITEM_ICMP6_CODE] = {
4279 .help = "ICMPv6 code",
4280 .next = NEXT(item_icmp6, NEXT_ENTRY(COMMON_UNSIGNED),
4282 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
4285 [ITEM_ICMP6_ND_NS] = {
4286 .name = "icmp6_nd_ns",
4287 .help = "match ICMPv6 neighbor discovery solicitation",
4288 .priv = PRIV_ITEM(ICMP6_ND_NS,
4289 sizeof(struct rte_flow_item_icmp6_nd_ns)),
4290 .next = NEXT(item_icmp6_nd_ns),
4293 [ITEM_ICMP6_ND_NS_TARGET_ADDR] = {
4294 .name = "target_addr",
4295 .help = "target address",
4296 .next = NEXT(item_icmp6_nd_ns, NEXT_ENTRY(COMMON_IPV6_ADDR),
4298 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_ns,
4301 [ITEM_ICMP6_ND_NA] = {
4302 .name = "icmp6_nd_na",
4303 .help = "match ICMPv6 neighbor discovery advertisement",
4304 .priv = PRIV_ITEM(ICMP6_ND_NA,
4305 sizeof(struct rte_flow_item_icmp6_nd_na)),
4306 .next = NEXT(item_icmp6_nd_na),
4309 [ITEM_ICMP6_ND_NA_TARGET_ADDR] = {
4310 .name = "target_addr",
4311 .help = "target address",
4312 .next = NEXT(item_icmp6_nd_na, NEXT_ENTRY(COMMON_IPV6_ADDR),
4314 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_na,
4317 [ITEM_ICMP6_ND_OPT] = {
4318 .name = "icmp6_nd_opt",
4319 .help = "match presence of any ICMPv6 neighbor discovery"
4321 .priv = PRIV_ITEM(ICMP6_ND_OPT,
4322 sizeof(struct rte_flow_item_icmp6_nd_opt)),
4323 .next = NEXT(item_icmp6_nd_opt),
4326 [ITEM_ICMP6_ND_OPT_TYPE] = {
4328 .help = "ND option type",
4329 .next = NEXT(item_icmp6_nd_opt, NEXT_ENTRY(COMMON_UNSIGNED),
4331 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_opt,
4334 [ITEM_ICMP6_ND_OPT_SLA_ETH] = {
4335 .name = "icmp6_nd_opt_sla_eth",
4336 .help = "match ICMPv6 neighbor discovery source Ethernet"
4337 " link-layer address option",
4339 (ICMP6_ND_OPT_SLA_ETH,
4340 sizeof(struct rte_flow_item_icmp6_nd_opt_sla_eth)),
4341 .next = NEXT(item_icmp6_nd_opt_sla_eth),
4344 [ITEM_ICMP6_ND_OPT_SLA_ETH_SLA] = {
4346 .help = "source Ethernet LLA",
4347 .next = NEXT(item_icmp6_nd_opt_sla_eth,
4348 NEXT_ENTRY(COMMON_MAC_ADDR), item_param),
4349 .args = ARGS(ARGS_ENTRY_HTON
4350 (struct rte_flow_item_icmp6_nd_opt_sla_eth, sla)),
4352 [ITEM_ICMP6_ND_OPT_TLA_ETH] = {
4353 .name = "icmp6_nd_opt_tla_eth",
4354 .help = "match ICMPv6 neighbor discovery target Ethernet"
4355 " link-layer address option",
4357 (ICMP6_ND_OPT_TLA_ETH,
4358 sizeof(struct rte_flow_item_icmp6_nd_opt_tla_eth)),
4359 .next = NEXT(item_icmp6_nd_opt_tla_eth),
4362 [ITEM_ICMP6_ND_OPT_TLA_ETH_TLA] = {
4364 .help = "target Ethernet LLA",
4365 .next = NEXT(item_icmp6_nd_opt_tla_eth,
4366 NEXT_ENTRY(COMMON_MAC_ADDR), item_param),
4367 .args = ARGS(ARGS_ENTRY_HTON
4368 (struct rte_flow_item_icmp6_nd_opt_tla_eth, tla)),
4372 .help = "match metadata header",
4373 .priv = PRIV_ITEM(META, sizeof(struct rte_flow_item_meta)),
4374 .next = NEXT(item_meta),
4377 [ITEM_META_DATA] = {
4379 .help = "metadata value",
4380 .next = NEXT(item_meta, NEXT_ENTRY(COMMON_UNSIGNED),
4382 .args = ARGS(ARGS_ENTRY_MASK(struct rte_flow_item_meta,
4383 data, "\xff\xff\xff\xff")),
4387 .help = "match GRE key",
4388 .priv = PRIV_ITEM(GRE_KEY, sizeof(rte_be32_t)),
4389 .next = NEXT(item_gre_key),
4392 [ITEM_GRE_KEY_VALUE] = {
4394 .help = "key value",
4395 .next = NEXT(item_gre_key, NEXT_ENTRY(COMMON_UNSIGNED),
4397 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4399 [ITEM_GRE_OPTION] = {
4400 .name = "gre_option",
4401 .help = "match GRE optional fields",
4402 .priv = PRIV_ITEM(GRE_OPTION,
4403 sizeof(struct rte_flow_item_gre_opt)),
4404 .next = NEXT(item_gre_option),
4407 [ITEM_GRE_OPTION_CHECKSUM] = {
4409 .help = "match GRE checksum",
4410 .next = NEXT(item_gre_option, NEXT_ENTRY(COMMON_UNSIGNED),
4412 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre_opt,
4413 checksum_rsvd.checksum)),
4415 [ITEM_GRE_OPTION_KEY] = {
4417 .help = "match GRE key",
4418 .next = NEXT(item_gre_option, NEXT_ENTRY(COMMON_UNSIGNED),
4420 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre_opt,
4423 [ITEM_GRE_OPTION_SEQUENCE] = {
4425 .help = "match GRE sequence",
4426 .next = NEXT(item_gre_option, NEXT_ENTRY(COMMON_UNSIGNED),
4428 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre_opt,
4429 sequence.sequence)),
4433 .help = "match GTP extension header with type 0x85",
4434 .priv = PRIV_ITEM(GTP_PSC,
4435 sizeof(struct rte_flow_item_gtp_psc)),
4436 .next = NEXT(item_gtp_psc),
4439 [ITEM_GTP_PSC_QFI] = {
4441 .help = "QoS flow identifier",
4442 .next = NEXT(item_gtp_psc, NEXT_ENTRY(COMMON_UNSIGNED),
4444 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_gtp_psc,
4447 [ITEM_GTP_PSC_PDU_T] = {
4450 .next = NEXT(item_gtp_psc, NEXT_ENTRY(COMMON_UNSIGNED),
4452 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_gtp_psc,
4457 .help = "match PPPoE session header",
4458 .priv = PRIV_ITEM(PPPOES, sizeof(struct rte_flow_item_pppoe)),
4459 .next = NEXT(item_pppoes),
4464 .help = "match PPPoE discovery header",
4465 .priv = PRIV_ITEM(PPPOED, sizeof(struct rte_flow_item_pppoe)),
4466 .next = NEXT(item_pppoed),
4469 [ITEM_PPPOE_SEID] = {
4471 .help = "session identifier",
4472 .next = NEXT(item_pppoes, NEXT_ENTRY(COMMON_UNSIGNED),
4474 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pppoe,
4477 [ITEM_PPPOE_PROTO_ID] = {
4478 .name = "pppoe_proto_id",
4479 .help = "match PPPoE session protocol identifier",
4480 .priv = PRIV_ITEM(PPPOE_PROTO_ID,
4481 sizeof(struct rte_flow_item_pppoe_proto_id)),
4482 .next = NEXT(item_pppoe_proto_id, NEXT_ENTRY(COMMON_UNSIGNED),
4484 .args = ARGS(ARGS_ENTRY_HTON
4485 (struct rte_flow_item_pppoe_proto_id, proto_id)),
4490 .help = "matches higig2 header",
4491 .priv = PRIV_ITEM(HIGIG2,
4492 sizeof(struct rte_flow_item_higig2_hdr)),
4493 .next = NEXT(item_higig2),
4496 [ITEM_HIGIG2_CLASSIFICATION] = {
4497 .name = "classification",
4498 .help = "matches classification of higig2 header",
4499 .next = NEXT(item_higig2, NEXT_ENTRY(COMMON_UNSIGNED),
4501 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
4502 hdr.ppt1.classification)),
4504 [ITEM_HIGIG2_VID] = {
4506 .help = "matches vid of higig2 header",
4507 .next = NEXT(item_higig2, NEXT_ENTRY(COMMON_UNSIGNED),
4509 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
4514 .help = "match tag value",
4515 .priv = PRIV_ITEM(TAG, sizeof(struct rte_flow_item_tag)),
4516 .next = NEXT(item_tag),
4521 .help = "tag value to match",
4522 .next = NEXT(item_tag, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
4523 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, data)),
4525 [ITEM_TAG_INDEX] = {
4527 .help = "index of tag array to match",
4528 .next = NEXT(item_tag, NEXT_ENTRY(COMMON_UNSIGNED),
4529 NEXT_ENTRY(ITEM_PARAM_IS)),
4530 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, index)),
4532 [ITEM_L2TPV3OIP] = {
4533 .name = "l2tpv3oip",
4534 .help = "match L2TPv3 over IP header",
4535 .priv = PRIV_ITEM(L2TPV3OIP,
4536 sizeof(struct rte_flow_item_l2tpv3oip)),
4537 .next = NEXT(item_l2tpv3oip),
4540 [ITEM_L2TPV3OIP_SESSION_ID] = {
4541 .name = "session_id",
4542 .help = "session identifier",
4543 .next = NEXT(item_l2tpv3oip, NEXT_ENTRY(COMMON_UNSIGNED),
4545 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv3oip,
4550 .help = "match ESP header",
4551 .priv = PRIV_ITEM(ESP, sizeof(struct rte_flow_item_esp)),
4552 .next = NEXT(item_esp),
4557 .help = "security policy index",
4558 .next = NEXT(item_esp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
4559 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_esp,
4564 .help = "match AH header",
4565 .priv = PRIV_ITEM(AH, sizeof(struct rte_flow_item_ah)),
4566 .next = NEXT(item_ah),
4571 .help = "security parameters index",
4572 .next = NEXT(item_ah, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
4573 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ah, spi)),
4577 .help = "match pfcp header",
4578 .priv = PRIV_ITEM(PFCP, sizeof(struct rte_flow_item_pfcp)),
4579 .next = NEXT(item_pfcp),
4582 [ITEM_PFCP_S_FIELD] = {
4585 .next = NEXT(item_pfcp, NEXT_ENTRY(COMMON_UNSIGNED),
4587 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp,
4590 [ITEM_PFCP_SEID] = {
4592 .help = "session endpoint identifier",
4593 .next = NEXT(item_pfcp, NEXT_ENTRY(COMMON_UNSIGNED),
4595 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp, seid)),
4599 .help = "match eCPRI header",
4600 .priv = PRIV_ITEM(ECPRI, sizeof(struct rte_flow_item_ecpri)),
4601 .next = NEXT(item_ecpri),
4604 [ITEM_ECPRI_COMMON] = {
4606 .help = "eCPRI common header",
4607 .next = NEXT(item_ecpri_common),
4609 [ITEM_ECPRI_COMMON_TYPE] = {
4611 .help = "type of common header",
4612 .next = NEXT(item_ecpri_common_type),
4613 .args = ARGS(ARG_ENTRY_HTON(struct rte_flow_item_ecpri)),
4615 [ITEM_ECPRI_COMMON_TYPE_IQ_DATA] = {
4617 .help = "Type #0: IQ Data",
4618 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
4620 .call = parse_vc_item_ecpri_type,
4622 [ITEM_ECPRI_MSG_IQ_DATA_PCID] = {
4624 .help = "Physical Channel ID",
4625 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
4626 ITEM_ECPRI_COMMON, ITEM_NEXT),
4627 NEXT_ENTRY(COMMON_UNSIGNED), item_param),
4628 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
4631 [ITEM_ECPRI_COMMON_TYPE_RTC_CTRL] = {
4633 .help = "Type #2: Real-Time Control Data",
4634 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
4636 .call = parse_vc_item_ecpri_type,
4638 [ITEM_ECPRI_MSG_RTC_CTRL_RTCID] = {
4640 .help = "Real-Time Control Data ID",
4641 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
4642 ITEM_ECPRI_COMMON, ITEM_NEXT),
4643 NEXT_ENTRY(COMMON_UNSIGNED), item_param),
4644 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
4647 [ITEM_ECPRI_COMMON_TYPE_DLY_MSR] = {
4648 .name = "delay_measure",
4649 .help = "Type #5: One-Way Delay Measurement",
4650 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
4652 .call = parse_vc_item_ecpri_type,
4654 [ITEM_ECPRI_MSG_DLY_MSR_MSRID] = {
4656 .help = "Measurement ID",
4657 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
4658 ITEM_ECPRI_COMMON, ITEM_NEXT),
4659 NEXT_ENTRY(COMMON_UNSIGNED), item_param),
4660 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
4663 [ITEM_GENEVE_OPT] = {
4664 .name = "geneve-opt",
4665 .help = "GENEVE header option",
4666 .priv = PRIV_ITEM(GENEVE_OPT,
4667 sizeof(struct rte_flow_item_geneve_opt) +
4668 ITEM_GENEVE_OPT_DATA_SIZE),
4669 .next = NEXT(item_geneve_opt),
4672 [ITEM_GENEVE_OPT_CLASS] = {
4674 .help = "GENEVE option class",
4675 .next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_UNSIGNED),
4677 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve_opt,
4680 [ITEM_GENEVE_OPT_TYPE] = {
4682 .help = "GENEVE option type",
4683 .next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_UNSIGNED),
4685 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt,
4688 [ITEM_GENEVE_OPT_LENGTH] = {
4690 .help = "GENEVE option data length (in 32b words)",
4691 .next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_UNSIGNED),
4693 .args = ARGS(ARGS_ENTRY_BOUNDED(
4694 struct rte_flow_item_geneve_opt, option_len,
4697 [ITEM_GENEVE_OPT_DATA] = {
4699 .help = "GENEVE option data pattern",
4700 .next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_HEX),
4702 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt, data),
4703 ARGS_ENTRY_ARB(0, 0),
4705 (sizeof(struct rte_flow_item_geneve_opt),
4706 ITEM_GENEVE_OPT_DATA_SIZE)),
4708 [ITEM_INTEGRITY] = {
4709 .name = "integrity",
4710 .help = "match packet integrity",
4711 .priv = PRIV_ITEM(INTEGRITY,
4712 sizeof(struct rte_flow_item_integrity)),
4713 .next = NEXT(item_integrity),
4716 [ITEM_INTEGRITY_LEVEL] = {
4718 .help = "integrity level",
4719 .next = NEXT(item_integrity_lv, NEXT_ENTRY(COMMON_UNSIGNED),
4721 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_integrity, level)),
4723 [ITEM_INTEGRITY_VALUE] = {
4725 .help = "integrity value",
4726 .next = NEXT(item_integrity_lv, NEXT_ENTRY(COMMON_UNSIGNED),
4728 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_integrity, value)),
4730 [ITEM_CONNTRACK] = {
4731 .name = "conntrack",
4732 .help = "conntrack state",
4733 .next = NEXT(NEXT_ENTRY(ITEM_NEXT), NEXT_ENTRY(COMMON_UNSIGNED),
4735 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_conntrack, flags)),
4737 [ITEM_PORT_REPRESENTOR] = {
4738 .name = "port_representor",
4739 .help = "match traffic entering the embedded switch from the given ethdev",
4740 .priv = PRIV_ITEM(PORT_REPRESENTOR,
4741 sizeof(struct rte_flow_item_ethdev)),
4742 .next = NEXT(item_port_representor),
4745 [ITEM_PORT_REPRESENTOR_PORT_ID] = {
4747 .help = "ethdev port ID",
4748 .next = NEXT(item_port_representor, NEXT_ENTRY(COMMON_UNSIGNED),
4750 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ethdev, port_id)),
4752 [ITEM_REPRESENTED_PORT] = {
4753 .name = "represented_port",
4754 .help = "match traffic entering the embedded switch from the entity represented by the given ethdev",
4755 .priv = PRIV_ITEM(REPRESENTED_PORT,
4756 sizeof(struct rte_flow_item_ethdev)),
4757 .next = NEXT(item_represented_port),
4760 [ITEM_REPRESENTED_PORT_ETHDEV_PORT_ID] = {
4761 .name = "ethdev_port_id",
4762 .help = "ethdev port ID",
4763 .next = NEXT(item_represented_port, NEXT_ENTRY(COMMON_UNSIGNED),
4765 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ethdev, port_id)),
4769 .help = "match flex header",
4770 .priv = PRIV_ITEM(FLEX, sizeof(struct rte_flow_item_flex)),
4771 .next = NEXT(item_flex),
4774 [ITEM_FLEX_ITEM_HANDLE] = {
4776 .help = "flex item handle",
4777 .next = NEXT(item_flex, NEXT_ENTRY(COMMON_FLEX_HANDLE),
4778 NEXT_ENTRY(ITEM_PARAM_IS)),
4779 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_flex, handle)),
4781 [ITEM_FLEX_PATTERN_HANDLE] = {
4783 .help = "flex pattern handle",
4784 .next = NEXT(item_flex, NEXT_ENTRY(COMMON_FLEX_HANDLE),
4785 NEXT_ENTRY(ITEM_PARAM_IS)),
4786 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_flex, pattern)),
4790 .help = "match L2TPv2 header",
4791 .priv = PRIV_ITEM(L2TPV2, sizeof(struct rte_flow_item_l2tpv2)),
4792 .next = NEXT(item_l2tpv2),
4795 [ITEM_L2TPV2_TYPE] = {
4797 .help = "type of l2tpv2",
4798 .next = NEXT(item_l2tpv2_type),
4799 .args = ARGS(ARG_ENTRY_HTON(struct rte_flow_item_l2tpv2)),
4801 [ITEM_L2TPV2_TYPE_DATA] = {
4803 .help = "Type #7: data message without any options",
4804 .next = NEXT(item_l2tpv2_type_data),
4805 .call = parse_vc_item_l2tpv2_type,
4807 [ITEM_L2TPV2_MSG_DATA_TUNNEL_ID] = {
4808 .name = "tunnel_id",
4809 .help = "tunnel identifier",
4810 .next = NEXT(item_l2tpv2_type_data,
4811 NEXT_ENTRY(COMMON_UNSIGNED),
4813 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
4814 hdr.type7.tunnel_id)),
4816 [ITEM_L2TPV2_MSG_DATA_SESSION_ID] = {
4817 .name = "session_id",
4818 .help = "session identifier",
4819 .next = NEXT(item_l2tpv2_type_data,
4820 NEXT_ENTRY(COMMON_UNSIGNED),
4822 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
4823 hdr.type7.session_id)),
4825 [ITEM_L2TPV2_TYPE_DATA_L] = {
4827 .help = "Type #6: data message with length option",
4828 .next = NEXT(item_l2tpv2_type_data_l),
4829 .call = parse_vc_item_l2tpv2_type,
4831 [ITEM_L2TPV2_MSG_DATA_L_LENGTH] = {
4833 .help = "message length",
4834 .next = NEXT(item_l2tpv2_type_data_l,
4835 NEXT_ENTRY(COMMON_UNSIGNED),
4837 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
4840 [ITEM_L2TPV2_MSG_DATA_L_TUNNEL_ID] = {
4841 .name = "tunnel_id",
4842 .help = "tunnel identifier",
4843 .next = NEXT(item_l2tpv2_type_data_l,
4844 NEXT_ENTRY(COMMON_UNSIGNED),
4846 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
4847 hdr.type6.tunnel_id)),
4849 [ITEM_L2TPV2_MSG_DATA_L_SESSION_ID] = {
4850 .name = "session_id",
4851 .help = "session identifier",
4852 .next = NEXT(item_l2tpv2_type_data_l,
4853 NEXT_ENTRY(COMMON_UNSIGNED),
4855 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
4856 hdr.type6.session_id)),
4858 [ITEM_L2TPV2_TYPE_DATA_S] = {
4860 .help = "Type #5: data message with ns, nr option",
4861 .next = NEXT(item_l2tpv2_type_data_s),
4862 .call = parse_vc_item_l2tpv2_type,
4864 [ITEM_L2TPV2_MSG_DATA_S_TUNNEL_ID] = {
4865 .name = "tunnel_id",
4866 .help = "tunnel identifier",
4867 .next = NEXT(item_l2tpv2_type_data_s,
4868 NEXT_ENTRY(COMMON_UNSIGNED),
4870 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
4871 hdr.type5.tunnel_id)),
4873 [ITEM_L2TPV2_MSG_DATA_S_SESSION_ID] = {
4874 .name = "session_id",
4875 .help = "session identifier",
4876 .next = NEXT(item_l2tpv2_type_data_s,
4877 NEXT_ENTRY(COMMON_UNSIGNED),
4879 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
4880 hdr.type5.session_id)),
4882 [ITEM_L2TPV2_MSG_DATA_S_NS] = {
4884 .help = "sequence number for message",
4885 .next = NEXT(item_l2tpv2_type_data_s,
4886 NEXT_ENTRY(COMMON_UNSIGNED),
4888 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
4891 [ITEM_L2TPV2_MSG_DATA_S_NR] = {
4893 .help = "sequence number for next receive message",
4894 .next = NEXT(item_l2tpv2_type_data_s,
4895 NEXT_ENTRY(COMMON_UNSIGNED),
4897 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
4900 [ITEM_L2TPV2_TYPE_DATA_O] = {
4902 .help = "Type #4: data message with offset option",
4903 .next = NEXT(item_l2tpv2_type_data_o),
4904 .call = parse_vc_item_l2tpv2_type,
4906 [ITEM_L2TPV2_MSG_DATA_O_TUNNEL_ID] = {
4907 .name = "tunnel_id",
4908 .help = "tunnel identifier",
4909 .next = NEXT(item_l2tpv2_type_data_o,
4910 NEXT_ENTRY(COMMON_UNSIGNED),
4912 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
4913 hdr.type4.tunnel_id)),
4915 [ITEM_L2TPV2_MSG_DATA_O_SESSION_ID] = {
4916 .name = "session_id",
4917 .help = "session identifier",
4918 .next = NEXT(item_l2tpv2_type_data_o,
4919 NEXT_ENTRY(COMMON_UNSIGNED),
4921 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
4922 hdr.type5.session_id)),
4924 [ITEM_L2TPV2_MSG_DATA_O_OFFSET] = {
4925 .name = "offset_size",
4926 .help = "the size of offset padding",
4927 .next = NEXT(item_l2tpv2_type_data_o,
4928 NEXT_ENTRY(COMMON_UNSIGNED),
4930 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
4931 hdr.type4.offset_size)),
4933 [ITEM_L2TPV2_TYPE_DATA_L_S] = {
4935 .help = "Type #3: data message contains length, ns, nr "
4937 .next = NEXT(item_l2tpv2_type_data_l_s),
4938 .call = parse_vc_item_l2tpv2_type,
4940 [ITEM_L2TPV2_MSG_DATA_L_S_LENGTH] = {
4942 .help = "message length",
4943 .next = NEXT(item_l2tpv2_type_data_l_s,
4944 NEXT_ENTRY(COMMON_UNSIGNED),
4946 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
4949 [ITEM_L2TPV2_MSG_DATA_L_S_TUNNEL_ID] = {
4950 .name = "tunnel_id",
4951 .help = "tunnel identifier",
4952 .next = NEXT(item_l2tpv2_type_data_l_s,
4953 NEXT_ENTRY(COMMON_UNSIGNED),
4955 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
4956 hdr.type3.tunnel_id)),
4958 [ITEM_L2TPV2_MSG_DATA_L_S_SESSION_ID] = {
4959 .name = "session_id",
4960 .help = "session identifier",
4961 .next = NEXT(item_l2tpv2_type_data_l_s,
4962 NEXT_ENTRY(COMMON_UNSIGNED),
4964 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
4965 hdr.type3.session_id)),
4967 [ITEM_L2TPV2_MSG_DATA_L_S_NS] = {
4969 .help = "sequence number for message",
4970 .next = NEXT(item_l2tpv2_type_data_l_s,
4971 NEXT_ENTRY(COMMON_UNSIGNED),
4973 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
4976 [ITEM_L2TPV2_MSG_DATA_L_S_NR] = {
4978 .help = "sequence number for next receive message",
4979 .next = NEXT(item_l2tpv2_type_data_l_s,
4980 NEXT_ENTRY(COMMON_UNSIGNED),
4982 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
4985 [ITEM_L2TPV2_TYPE_CTRL] = {
4987 .help = "Type #3: conrtol message contains length, ns, nr "
4989 .next = NEXT(item_l2tpv2_type_ctrl),
4990 .call = parse_vc_item_l2tpv2_type,
4992 [ITEM_L2TPV2_MSG_CTRL_LENGTH] = {
4994 .help = "message length",
4995 .next = NEXT(item_l2tpv2_type_ctrl,
4996 NEXT_ENTRY(COMMON_UNSIGNED),
4998 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
5001 [ITEM_L2TPV2_MSG_CTRL_TUNNEL_ID] = {
5002 .name = "tunnel_id",
5003 .help = "tunnel identifier",
5004 .next = NEXT(item_l2tpv2_type_ctrl,
5005 NEXT_ENTRY(COMMON_UNSIGNED),
5007 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
5008 hdr.type3.tunnel_id)),
5010 [ITEM_L2TPV2_MSG_CTRL_SESSION_ID] = {
5011 .name = "session_id",
5012 .help = "session identifier",
5013 .next = NEXT(item_l2tpv2_type_ctrl,
5014 NEXT_ENTRY(COMMON_UNSIGNED),
5016 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
5017 hdr.type3.session_id)),
5019 [ITEM_L2TPV2_MSG_CTRL_NS] = {
5021 .help = "sequence number for message",
5022 .next = NEXT(item_l2tpv2_type_ctrl,
5023 NEXT_ENTRY(COMMON_UNSIGNED),
5025 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
5028 [ITEM_L2TPV2_MSG_CTRL_NR] = {
5030 .help = "sequence number for next receive message",
5031 .next = NEXT(item_l2tpv2_type_ctrl,
5032 NEXT_ENTRY(COMMON_UNSIGNED),
5034 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
5039 .help = "match PPP header",
5040 .priv = PRIV_ITEM(PPP, sizeof(struct rte_flow_item_ppp)),
5041 .next = NEXT(item_ppp),
5046 .help = "PPP address",
5047 .next = NEXT(item_ppp, NEXT_ENTRY(COMMON_UNSIGNED),
5049 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ppp, hdr.addr)),
5053 .help = "PPP control",
5054 .next = NEXT(item_ppp, NEXT_ENTRY(COMMON_UNSIGNED),
5056 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ppp, hdr.ctrl)),
5058 [ITEM_PPP_PROTO_ID] = {
5060 .help = "PPP protocol identifier",
5061 .next = NEXT(item_ppp, NEXT_ENTRY(COMMON_UNSIGNED),
5063 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ppp,
5066 /* Validate/create actions. */
5069 .help = "submit a list of associated actions",
5070 .next = NEXT(next_action),
5075 .help = "specify next action",
5076 .next = NEXT(next_action),
5080 .help = "end list of actions",
5081 .priv = PRIV_ACTION(END, 0),
5086 .help = "no-op action",
5087 .priv = PRIV_ACTION(VOID, 0),
5088 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
5091 [ACTION_PASSTHRU] = {
5093 .help = "let subsequent rule process matched packets",
5094 .priv = PRIV_ACTION(PASSTHRU, 0),
5095 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
5100 .help = "redirect traffic to a given group",
5101 .priv = PRIV_ACTION(JUMP, sizeof(struct rte_flow_action_jump)),
5102 .next = NEXT(action_jump),
5105 [ACTION_JUMP_GROUP] = {
5107 .help = "group to redirect traffic to",
5108 .next = NEXT(action_jump, NEXT_ENTRY(COMMON_UNSIGNED)),
5109 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump, group)),
5110 .call = parse_vc_conf,
5114 .help = "attach 32 bit value to packets",
5115 .priv = PRIV_ACTION(MARK, sizeof(struct rte_flow_action_mark)),
5116 .next = NEXT(action_mark),
5119 [ACTION_MARK_ID] = {
5121 .help = "32 bit value to return with packets",
5122 .next = NEXT(action_mark, NEXT_ENTRY(COMMON_UNSIGNED)),
5123 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_mark, id)),
5124 .call = parse_vc_conf,
5128 .help = "flag packets",
5129 .priv = PRIV_ACTION(FLAG, 0),
5130 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
5135 .help = "assign packets to a given queue index",
5136 .priv = PRIV_ACTION(QUEUE,
5137 sizeof(struct rte_flow_action_queue)),
5138 .next = NEXT(action_queue),
5141 [ACTION_QUEUE_INDEX] = {
5143 .help = "queue index to use",
5144 .next = NEXT(action_queue, NEXT_ENTRY(COMMON_UNSIGNED)),
5145 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_queue, index)),
5146 .call = parse_vc_conf,
5150 .help = "drop packets (note: passthru has priority)",
5151 .priv = PRIV_ACTION(DROP, 0),
5152 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
5157 .help = "enable counters for this rule",
5158 .priv = PRIV_ACTION(COUNT,
5159 sizeof(struct rte_flow_action_count)),
5160 .next = NEXT(action_count),
5163 [ACTION_COUNT_ID] = {
5164 .name = "identifier",
5165 .help = "counter identifier to use",
5166 .next = NEXT(action_count, NEXT_ENTRY(COMMON_UNSIGNED)),
5167 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_count, id)),
5168 .call = parse_vc_conf,
5172 .help = "spread packets among several queues",
5173 .priv = PRIV_ACTION(RSS, sizeof(struct action_rss_data)),
5174 .next = NEXT(action_rss),
5175 .call = parse_vc_action_rss,
5177 [ACTION_RSS_FUNC] = {
5179 .help = "RSS hash function to apply",
5180 .next = NEXT(action_rss,
5181 NEXT_ENTRY(ACTION_RSS_FUNC_DEFAULT,
5182 ACTION_RSS_FUNC_TOEPLITZ,
5183 ACTION_RSS_FUNC_SIMPLE_XOR,
5184 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ)),
5186 [ACTION_RSS_FUNC_DEFAULT] = {
5188 .help = "default hash function",
5189 .call = parse_vc_action_rss_func,
5191 [ACTION_RSS_FUNC_TOEPLITZ] = {
5193 .help = "Toeplitz hash function",
5194 .call = parse_vc_action_rss_func,
5196 [ACTION_RSS_FUNC_SIMPLE_XOR] = {
5197 .name = "simple_xor",
5198 .help = "simple XOR hash function",
5199 .call = parse_vc_action_rss_func,
5201 [ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ] = {
5202 .name = "symmetric_toeplitz",
5203 .help = "Symmetric Toeplitz hash function",
5204 .call = parse_vc_action_rss_func,
5206 [ACTION_RSS_LEVEL] = {
5208 .help = "encapsulation level for \"types\"",
5209 .next = NEXT(action_rss, NEXT_ENTRY(COMMON_UNSIGNED)),
5210 .args = ARGS(ARGS_ENTRY_ARB
5211 (offsetof(struct action_rss_data, conf) +
5212 offsetof(struct rte_flow_action_rss, level),
5213 sizeof(((struct rte_flow_action_rss *)0)->
5216 [ACTION_RSS_TYPES] = {
5218 .help = "specific RSS hash types",
5219 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)),
5221 [ACTION_RSS_TYPE] = {
5223 .help = "RSS hash type",
5224 .call = parse_vc_action_rss_type,
5225 .comp = comp_vc_action_rss_type,
5227 [ACTION_RSS_KEY] = {
5229 .help = "RSS hash key",
5230 .next = NEXT(action_rss, NEXT_ENTRY(COMMON_HEX)),
5231 .args = ARGS(ARGS_ENTRY_ARB
5232 (offsetof(struct action_rss_data, conf) +
5233 offsetof(struct rte_flow_action_rss, key),
5234 sizeof(((struct rte_flow_action_rss *)0)->key)),
5236 (offsetof(struct action_rss_data, conf) +
5237 offsetof(struct rte_flow_action_rss, key_len),
5238 sizeof(((struct rte_flow_action_rss *)0)->
5240 ARGS_ENTRY(struct action_rss_data, key)),
5242 [ACTION_RSS_KEY_LEN] = {
5244 .help = "RSS hash key length in bytes",
5245 .next = NEXT(action_rss, NEXT_ENTRY(COMMON_UNSIGNED)),
5246 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
5247 (offsetof(struct action_rss_data, conf) +
5248 offsetof(struct rte_flow_action_rss, key_len),
5249 sizeof(((struct rte_flow_action_rss *)0)->
5252 RSS_HASH_KEY_LENGTH)),
5254 [ACTION_RSS_QUEUES] = {
5256 .help = "queue indices to use",
5257 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_QUEUE)),
5258 .call = parse_vc_conf,
5260 [ACTION_RSS_QUEUE] = {
5262 .help = "queue index",
5263 .call = parse_vc_action_rss_queue,
5264 .comp = comp_vc_action_rss_queue,
5268 .help = "direct traffic to physical function",
5269 .priv = PRIV_ACTION(PF, 0),
5270 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
5275 .help = "direct traffic to a virtual function ID",
5276 .priv = PRIV_ACTION(VF, sizeof(struct rte_flow_action_vf)),
5277 .next = NEXT(action_vf),
5280 [ACTION_VF_ORIGINAL] = {
5282 .help = "use original VF ID if possible",
5283 .next = NEXT(action_vf, NEXT_ENTRY(COMMON_BOOLEAN)),
5284 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_vf,
5286 .call = parse_vc_conf,
5291 .next = NEXT(action_vf, NEXT_ENTRY(COMMON_UNSIGNED)),
5292 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)),
5293 .call = parse_vc_conf,
5295 [ACTION_PHY_PORT] = {
5297 .help = "direct packets to physical port index",
5298 .priv = PRIV_ACTION(PHY_PORT,
5299 sizeof(struct rte_flow_action_phy_port)),
5300 .next = NEXT(action_phy_port),
5303 [ACTION_PHY_PORT_ORIGINAL] = {
5305 .help = "use original port index if possible",
5306 .next = NEXT(action_phy_port, NEXT_ENTRY(COMMON_BOOLEAN)),
5307 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_phy_port,
5309 .call = parse_vc_conf,
5311 [ACTION_PHY_PORT_INDEX] = {
5313 .help = "physical port index",
5314 .next = NEXT(action_phy_port, NEXT_ENTRY(COMMON_UNSIGNED)),
5315 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_phy_port,
5317 .call = parse_vc_conf,
5319 [ACTION_PORT_ID] = {
5321 .help = "direct matching traffic to a given DPDK port ID",
5322 .priv = PRIV_ACTION(PORT_ID,
5323 sizeof(struct rte_flow_action_port_id)),
5324 .next = NEXT(action_port_id),
5327 [ACTION_PORT_ID_ORIGINAL] = {
5329 .help = "use original DPDK port ID if possible",
5330 .next = NEXT(action_port_id, NEXT_ENTRY(COMMON_BOOLEAN)),
5331 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_port_id,
5333 .call = parse_vc_conf,
5335 [ACTION_PORT_ID_ID] = {
5337 .help = "DPDK port ID",
5338 .next = NEXT(action_port_id, NEXT_ENTRY(COMMON_UNSIGNED)),
5339 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_port_id, id)),
5340 .call = parse_vc_conf,
5344 .help = "meter the directed packets at given id",
5345 .priv = PRIV_ACTION(METER,
5346 sizeof(struct rte_flow_action_meter)),
5347 .next = NEXT(action_meter),
5350 [ACTION_METER_COLOR] = {
5352 .help = "meter color for the packets",
5353 .priv = PRIV_ACTION(METER_COLOR,
5354 sizeof(struct rte_flow_action_meter_color)),
5355 .next = NEXT(action_meter_color),
5358 [ACTION_METER_COLOR_TYPE] = {
5360 .help = "specific meter color",
5361 .next = NEXT(NEXT_ENTRY(ACTION_NEXT),
5362 NEXT_ENTRY(ACTION_METER_COLOR_GREEN,
5363 ACTION_METER_COLOR_YELLOW,
5364 ACTION_METER_COLOR_RED)),
5366 [ACTION_METER_COLOR_GREEN] = {
5368 .help = "meter color green",
5369 .call = parse_vc_action_meter_color_type,
5371 [ACTION_METER_COLOR_YELLOW] = {
5373 .help = "meter color yellow",
5374 .call = parse_vc_action_meter_color_type,
5376 [ACTION_METER_COLOR_RED] = {
5378 .help = "meter color red",
5379 .call = parse_vc_action_meter_color_type,
5381 [ACTION_METER_ID] = {
5383 .help = "meter id to use",
5384 .next = NEXT(action_meter, NEXT_ENTRY(COMMON_UNSIGNED)),
5385 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter, mtr_id)),
5386 .call = parse_vc_conf,
5388 [ACTION_OF_SET_MPLS_TTL] = {
5389 .name = "of_set_mpls_ttl",
5390 .help = "OpenFlow's OFPAT_SET_MPLS_TTL",
5393 sizeof(struct rte_flow_action_of_set_mpls_ttl)),
5394 .next = NEXT(action_of_set_mpls_ttl),
5397 [ACTION_OF_SET_MPLS_TTL_MPLS_TTL] = {
5400 .next = NEXT(action_of_set_mpls_ttl,
5401 NEXT_ENTRY(COMMON_UNSIGNED)),
5402 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_mpls_ttl,
5404 .call = parse_vc_conf,
5406 [ACTION_OF_DEC_MPLS_TTL] = {
5407 .name = "of_dec_mpls_ttl",
5408 .help = "OpenFlow's OFPAT_DEC_MPLS_TTL",
5409 .priv = PRIV_ACTION(OF_DEC_MPLS_TTL, 0),
5410 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
5413 [ACTION_OF_SET_NW_TTL] = {
5414 .name = "of_set_nw_ttl",
5415 .help = "OpenFlow's OFPAT_SET_NW_TTL",
5418 sizeof(struct rte_flow_action_of_set_nw_ttl)),
5419 .next = NEXT(action_of_set_nw_ttl),
5422 [ACTION_OF_SET_NW_TTL_NW_TTL] = {
5425 .next = NEXT(action_of_set_nw_ttl, NEXT_ENTRY(COMMON_UNSIGNED)),
5426 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_nw_ttl,
5428 .call = parse_vc_conf,
5430 [ACTION_OF_DEC_NW_TTL] = {
5431 .name = "of_dec_nw_ttl",
5432 .help = "OpenFlow's OFPAT_DEC_NW_TTL",
5433 .priv = PRIV_ACTION(OF_DEC_NW_TTL, 0),
5434 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
5437 [ACTION_OF_COPY_TTL_OUT] = {
5438 .name = "of_copy_ttl_out",
5439 .help = "OpenFlow's OFPAT_COPY_TTL_OUT",
5440 .priv = PRIV_ACTION(OF_COPY_TTL_OUT, 0),
5441 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
5444 [ACTION_OF_COPY_TTL_IN] = {
5445 .name = "of_copy_ttl_in",
5446 .help = "OpenFlow's OFPAT_COPY_TTL_IN",
5447 .priv = PRIV_ACTION(OF_COPY_TTL_IN, 0),
5448 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
5451 [ACTION_OF_POP_VLAN] = {
5452 .name = "of_pop_vlan",
5453 .help = "OpenFlow's OFPAT_POP_VLAN",
5454 .priv = PRIV_ACTION(OF_POP_VLAN, 0),
5455 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
5458 [ACTION_OF_PUSH_VLAN] = {
5459 .name = "of_push_vlan",
5460 .help = "OpenFlow's OFPAT_PUSH_VLAN",
5463 sizeof(struct rte_flow_action_of_push_vlan)),
5464 .next = NEXT(action_of_push_vlan),
5467 [ACTION_OF_PUSH_VLAN_ETHERTYPE] = {
5468 .name = "ethertype",
5469 .help = "EtherType",
5470 .next = NEXT(action_of_push_vlan, NEXT_ENTRY(COMMON_UNSIGNED)),
5471 .args = ARGS(ARGS_ENTRY_HTON
5472 (struct rte_flow_action_of_push_vlan,
5474 .call = parse_vc_conf,
5476 [ACTION_OF_SET_VLAN_VID] = {
5477 .name = "of_set_vlan_vid",
5478 .help = "OpenFlow's OFPAT_SET_VLAN_VID",
5481 sizeof(struct rte_flow_action_of_set_vlan_vid)),
5482 .next = NEXT(action_of_set_vlan_vid),
5485 [ACTION_OF_SET_VLAN_VID_VLAN_VID] = {
5488 .next = NEXT(action_of_set_vlan_vid,
5489 NEXT_ENTRY(COMMON_UNSIGNED)),
5490 .args = ARGS(ARGS_ENTRY_HTON
5491 (struct rte_flow_action_of_set_vlan_vid,
5493 .call = parse_vc_conf,
5495 [ACTION_OF_SET_VLAN_PCP] = {
5496 .name = "of_set_vlan_pcp",
5497 .help = "OpenFlow's OFPAT_SET_VLAN_PCP",
5500 sizeof(struct rte_flow_action_of_set_vlan_pcp)),
5501 .next = NEXT(action_of_set_vlan_pcp),
5504 [ACTION_OF_SET_VLAN_PCP_VLAN_PCP] = {
5506 .help = "VLAN priority",
5507 .next = NEXT(action_of_set_vlan_pcp,
5508 NEXT_ENTRY(COMMON_UNSIGNED)),
5509 .args = ARGS(ARGS_ENTRY_HTON
5510 (struct rte_flow_action_of_set_vlan_pcp,
5512 .call = parse_vc_conf,
5514 [ACTION_OF_POP_MPLS] = {
5515 .name = "of_pop_mpls",
5516 .help = "OpenFlow's OFPAT_POP_MPLS",
5517 .priv = PRIV_ACTION(OF_POP_MPLS,
5518 sizeof(struct rte_flow_action_of_pop_mpls)),
5519 .next = NEXT(action_of_pop_mpls),
5522 [ACTION_OF_POP_MPLS_ETHERTYPE] = {
5523 .name = "ethertype",
5524 .help = "EtherType",
5525 .next = NEXT(action_of_pop_mpls, NEXT_ENTRY(COMMON_UNSIGNED)),
5526 .args = ARGS(ARGS_ENTRY_HTON
5527 (struct rte_flow_action_of_pop_mpls,
5529 .call = parse_vc_conf,
5531 [ACTION_OF_PUSH_MPLS] = {
5532 .name = "of_push_mpls",
5533 .help = "OpenFlow's OFPAT_PUSH_MPLS",
5536 sizeof(struct rte_flow_action_of_push_mpls)),
5537 .next = NEXT(action_of_push_mpls),
5540 [ACTION_OF_PUSH_MPLS_ETHERTYPE] = {
5541 .name = "ethertype",
5542 .help = "EtherType",
5543 .next = NEXT(action_of_push_mpls, NEXT_ENTRY(COMMON_UNSIGNED)),
5544 .args = ARGS(ARGS_ENTRY_HTON
5545 (struct rte_flow_action_of_push_mpls,
5547 .call = parse_vc_conf,
5549 [ACTION_VXLAN_ENCAP] = {
5550 .name = "vxlan_encap",
5551 .help = "VXLAN encapsulation, uses configuration set by \"set"
5553 .priv = PRIV_ACTION(VXLAN_ENCAP,
5554 sizeof(struct action_vxlan_encap_data)),
5555 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
5556 .call = parse_vc_action_vxlan_encap,
5558 [ACTION_VXLAN_DECAP] = {
5559 .name = "vxlan_decap",
5560 .help = "Performs a decapsulation action by stripping all"
5561 " headers of the VXLAN tunnel network overlay from the"
5563 .priv = PRIV_ACTION(VXLAN_DECAP, 0),
5564 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
5567 [ACTION_NVGRE_ENCAP] = {
5568 .name = "nvgre_encap",
5569 .help = "NVGRE encapsulation, uses configuration set by \"set"
5571 .priv = PRIV_ACTION(NVGRE_ENCAP,
5572 sizeof(struct action_nvgre_encap_data)),
5573 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
5574 .call = parse_vc_action_nvgre_encap,
5576 [ACTION_NVGRE_DECAP] = {
5577 .name = "nvgre_decap",
5578 .help = "Performs a decapsulation action by stripping all"
5579 " headers of the NVGRE tunnel network overlay from the"
5581 .priv = PRIV_ACTION(NVGRE_DECAP, 0),
5582 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
5585 [ACTION_L2_ENCAP] = {
5587 .help = "l2 encap, uses configuration set by"
5588 " \"set l2_encap\"",
5589 .priv = PRIV_ACTION(RAW_ENCAP,
5590 sizeof(struct action_raw_encap_data)),
5591 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
5592 .call = parse_vc_action_l2_encap,
5594 [ACTION_L2_DECAP] = {
5596 .help = "l2 decap, uses configuration set by"
5597 " \"set l2_decap\"",
5598 .priv = PRIV_ACTION(RAW_DECAP,
5599 sizeof(struct action_raw_decap_data)),
5600 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
5601 .call = parse_vc_action_l2_decap,
5603 [ACTION_MPLSOGRE_ENCAP] = {
5604 .name = "mplsogre_encap",
5605 .help = "mplsogre encapsulation, uses configuration set by"
5606 " \"set mplsogre_encap\"",
5607 .priv = PRIV_ACTION(RAW_ENCAP,
5608 sizeof(struct action_raw_encap_data)),
5609 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
5610 .call = parse_vc_action_mplsogre_encap,
5612 [ACTION_MPLSOGRE_DECAP] = {
5613 .name = "mplsogre_decap",
5614 .help = "mplsogre decapsulation, uses configuration set by"
5615 " \"set mplsogre_decap\"",
5616 .priv = PRIV_ACTION(RAW_DECAP,
5617 sizeof(struct action_raw_decap_data)),
5618 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
5619 .call = parse_vc_action_mplsogre_decap,
5621 [ACTION_MPLSOUDP_ENCAP] = {
5622 .name = "mplsoudp_encap",
5623 .help = "mplsoudp encapsulation, uses configuration set by"
5624 " \"set mplsoudp_encap\"",
5625 .priv = PRIV_ACTION(RAW_ENCAP,
5626 sizeof(struct action_raw_encap_data)),
5627 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
5628 .call = parse_vc_action_mplsoudp_encap,
5630 [ACTION_MPLSOUDP_DECAP] = {
5631 .name = "mplsoudp_decap",
5632 .help = "mplsoudp decapsulation, uses configuration set by"
5633 " \"set mplsoudp_decap\"",
5634 .priv = PRIV_ACTION(RAW_DECAP,
5635 sizeof(struct action_raw_decap_data)),
5636 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
5637 .call = parse_vc_action_mplsoudp_decap,
5639 [ACTION_SET_IPV4_SRC] = {
5640 .name = "set_ipv4_src",
5641 .help = "Set a new IPv4 source address in the outermost"
5643 .priv = PRIV_ACTION(SET_IPV4_SRC,
5644 sizeof(struct rte_flow_action_set_ipv4)),
5645 .next = NEXT(action_set_ipv4_src),
5648 [ACTION_SET_IPV4_SRC_IPV4_SRC] = {
5649 .name = "ipv4_addr",
5650 .help = "new IPv4 source address to set",
5651 .next = NEXT(action_set_ipv4_src, NEXT_ENTRY(COMMON_IPV4_ADDR)),
5652 .args = ARGS(ARGS_ENTRY_HTON
5653 (struct rte_flow_action_set_ipv4, ipv4_addr)),
5654 .call = parse_vc_conf,
5656 [ACTION_SET_IPV4_DST] = {
5657 .name = "set_ipv4_dst",
5658 .help = "Set a new IPv4 destination address in the outermost"
5660 .priv = PRIV_ACTION(SET_IPV4_DST,
5661 sizeof(struct rte_flow_action_set_ipv4)),
5662 .next = NEXT(action_set_ipv4_dst),
5665 [ACTION_SET_IPV4_DST_IPV4_DST] = {
5666 .name = "ipv4_addr",
5667 .help = "new IPv4 destination address to set",
5668 .next = NEXT(action_set_ipv4_dst, NEXT_ENTRY(COMMON_IPV4_ADDR)),
5669 .args = ARGS(ARGS_ENTRY_HTON
5670 (struct rte_flow_action_set_ipv4, ipv4_addr)),
5671 .call = parse_vc_conf,
5673 [ACTION_SET_IPV6_SRC] = {
5674 .name = "set_ipv6_src",
5675 .help = "Set a new IPv6 source address in the outermost"
5677 .priv = PRIV_ACTION(SET_IPV6_SRC,
5678 sizeof(struct rte_flow_action_set_ipv6)),
5679 .next = NEXT(action_set_ipv6_src),
5682 [ACTION_SET_IPV6_SRC_IPV6_SRC] = {
5683 .name = "ipv6_addr",
5684 .help = "new IPv6 source address to set",
5685 .next = NEXT(action_set_ipv6_src, NEXT_ENTRY(COMMON_IPV6_ADDR)),
5686 .args = ARGS(ARGS_ENTRY_HTON
5687 (struct rte_flow_action_set_ipv6, ipv6_addr)),
5688 .call = parse_vc_conf,
5690 [ACTION_SET_IPV6_DST] = {
5691 .name = "set_ipv6_dst",
5692 .help = "Set a new IPv6 destination address in the outermost"
5694 .priv = PRIV_ACTION(SET_IPV6_DST,
5695 sizeof(struct rte_flow_action_set_ipv6)),
5696 .next = NEXT(action_set_ipv6_dst),
5699 [ACTION_SET_IPV6_DST_IPV6_DST] = {
5700 .name = "ipv6_addr",
5701 .help = "new IPv6 destination address to set",
5702 .next = NEXT(action_set_ipv6_dst, NEXT_ENTRY(COMMON_IPV6_ADDR)),
5703 .args = ARGS(ARGS_ENTRY_HTON
5704 (struct rte_flow_action_set_ipv6, ipv6_addr)),
5705 .call = parse_vc_conf,
5707 [ACTION_SET_TP_SRC] = {
5708 .name = "set_tp_src",
5709 .help = "set a new source port number in the outermost"
5711 .priv = PRIV_ACTION(SET_TP_SRC,
5712 sizeof(struct rte_flow_action_set_tp)),
5713 .next = NEXT(action_set_tp_src),
5716 [ACTION_SET_TP_SRC_TP_SRC] = {
5718 .help = "new source port number to set",
5719 .next = NEXT(action_set_tp_src, NEXT_ENTRY(COMMON_UNSIGNED)),
5720 .args = ARGS(ARGS_ENTRY_HTON
5721 (struct rte_flow_action_set_tp, port)),
5722 .call = parse_vc_conf,
5724 [ACTION_SET_TP_DST] = {
5725 .name = "set_tp_dst",
5726 .help = "set a new destination port number in the outermost"
5728 .priv = PRIV_ACTION(SET_TP_DST,
5729 sizeof(struct rte_flow_action_set_tp)),
5730 .next = NEXT(action_set_tp_dst),
5733 [ACTION_SET_TP_DST_TP_DST] = {
5735 .help = "new destination port number to set",
5736 .next = NEXT(action_set_tp_dst, NEXT_ENTRY(COMMON_UNSIGNED)),
5737 .args = ARGS(ARGS_ENTRY_HTON
5738 (struct rte_flow_action_set_tp, port)),
5739 .call = parse_vc_conf,
5741 [ACTION_MAC_SWAP] = {
5743 .help = "Swap the source and destination MAC addresses"
5744 " in the outermost Ethernet header",
5745 .priv = PRIV_ACTION(MAC_SWAP, 0),
5746 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
5749 [ACTION_DEC_TTL] = {
5751 .help = "decrease network TTL if available",
5752 .priv = PRIV_ACTION(DEC_TTL, 0),
5753 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
5756 [ACTION_SET_TTL] = {
5758 .help = "set ttl value",
5759 .priv = PRIV_ACTION(SET_TTL,
5760 sizeof(struct rte_flow_action_set_ttl)),
5761 .next = NEXT(action_set_ttl),
5764 [ACTION_SET_TTL_TTL] = {
5765 .name = "ttl_value",
5766 .help = "new ttl value to set",
5767 .next = NEXT(action_set_ttl, NEXT_ENTRY(COMMON_UNSIGNED)),
5768 .args = ARGS(ARGS_ENTRY_HTON
5769 (struct rte_flow_action_set_ttl, ttl_value)),
5770 .call = parse_vc_conf,
5772 [ACTION_SET_MAC_SRC] = {
5773 .name = "set_mac_src",
5774 .help = "set source mac address",
5775 .priv = PRIV_ACTION(SET_MAC_SRC,
5776 sizeof(struct rte_flow_action_set_mac)),
5777 .next = NEXT(action_set_mac_src),
5780 [ACTION_SET_MAC_SRC_MAC_SRC] = {
5782 .help = "new source mac address",
5783 .next = NEXT(action_set_mac_src, NEXT_ENTRY(COMMON_MAC_ADDR)),
5784 .args = ARGS(ARGS_ENTRY_HTON
5785 (struct rte_flow_action_set_mac, mac_addr)),
5786 .call = parse_vc_conf,
5788 [ACTION_SET_MAC_DST] = {
5789 .name = "set_mac_dst",
5790 .help = "set destination mac address",
5791 .priv = PRIV_ACTION(SET_MAC_DST,
5792 sizeof(struct rte_flow_action_set_mac)),
5793 .next = NEXT(action_set_mac_dst),
5796 [ACTION_SET_MAC_DST_MAC_DST] = {
5798 .help = "new destination mac address to set",
5799 .next = NEXT(action_set_mac_dst, NEXT_ENTRY(COMMON_MAC_ADDR)),
5800 .args = ARGS(ARGS_ENTRY_HTON
5801 (struct rte_flow_action_set_mac, mac_addr)),
5802 .call = parse_vc_conf,
5804 [ACTION_INC_TCP_SEQ] = {
5805 .name = "inc_tcp_seq",
5806 .help = "increase TCP sequence number",
5807 .priv = PRIV_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
5808 .next = NEXT(action_inc_tcp_seq),
5811 [ACTION_INC_TCP_SEQ_VALUE] = {
5813 .help = "the value to increase TCP sequence number by",
5814 .next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(COMMON_UNSIGNED)),
5815 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
5816 .call = parse_vc_conf,
5818 [ACTION_DEC_TCP_SEQ] = {
5819 .name = "dec_tcp_seq",
5820 .help = "decrease TCP sequence number",
5821 .priv = PRIV_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
5822 .next = NEXT(action_dec_tcp_seq),
5825 [ACTION_DEC_TCP_SEQ_VALUE] = {
5827 .help = "the value to decrease TCP sequence number by",
5828 .next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(COMMON_UNSIGNED)),
5829 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
5830 .call = parse_vc_conf,
5832 [ACTION_INC_TCP_ACK] = {
5833 .name = "inc_tcp_ack",
5834 .help = "increase TCP acknowledgment number",
5835 .priv = PRIV_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
5836 .next = NEXT(action_inc_tcp_ack),
5839 [ACTION_INC_TCP_ACK_VALUE] = {
5841 .help = "the value to increase TCP acknowledgment number by",
5842 .next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(COMMON_UNSIGNED)),
5843 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
5844 .call = parse_vc_conf,
5846 [ACTION_DEC_TCP_ACK] = {
5847 .name = "dec_tcp_ack",
5848 .help = "decrease TCP acknowledgment number",
5849 .priv = PRIV_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
5850 .next = NEXT(action_dec_tcp_ack),
5853 [ACTION_DEC_TCP_ACK_VALUE] = {
5855 .help = "the value to decrease TCP acknowledgment number by",
5856 .next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(COMMON_UNSIGNED)),
5857 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
5858 .call = parse_vc_conf,
5860 [ACTION_RAW_ENCAP] = {
5861 .name = "raw_encap",
5862 .help = "encapsulation data, defined by set raw_encap",
5863 .priv = PRIV_ACTION(RAW_ENCAP,
5864 sizeof(struct action_raw_encap_data)),
5865 .next = NEXT(action_raw_encap),
5866 .call = parse_vc_action_raw_encap,
5868 [ACTION_RAW_ENCAP_INDEX] = {
5870 .help = "the index of raw_encap_confs",
5871 .next = NEXT(NEXT_ENTRY(ACTION_RAW_ENCAP_INDEX_VALUE)),
5873 [ACTION_RAW_ENCAP_INDEX_VALUE] = {
5876 .help = "unsigned integer value",
5877 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
5878 .call = parse_vc_action_raw_encap_index,
5879 .comp = comp_set_raw_index,
5881 [ACTION_RAW_DECAP] = {
5882 .name = "raw_decap",
5883 .help = "decapsulation data, defined by set raw_encap",
5884 .priv = PRIV_ACTION(RAW_DECAP,
5885 sizeof(struct action_raw_decap_data)),
5886 .next = NEXT(action_raw_decap),
5887 .call = parse_vc_action_raw_decap,
5889 [ACTION_RAW_DECAP_INDEX] = {
5891 .help = "the index of raw_encap_confs",
5892 .next = NEXT(NEXT_ENTRY(ACTION_RAW_DECAP_INDEX_VALUE)),
5894 [ACTION_RAW_DECAP_INDEX_VALUE] = {
5897 .help = "unsigned integer value",
5898 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
5899 .call = parse_vc_action_raw_decap_index,
5900 .comp = comp_set_raw_index,
5902 [ACTION_MODIFY_FIELD] = {
5903 .name = "modify_field",
5904 .help = "modify destination field with data from source field",
5905 .priv = PRIV_ACTION(MODIFY_FIELD, ACTION_MODIFY_SIZE),
5906 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_OP)),
5909 [ACTION_MODIFY_FIELD_OP] = {
5911 .help = "operation type",
5912 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_TYPE),
5913 NEXT_ENTRY(ACTION_MODIFY_FIELD_OP_VALUE)),
5914 .call = parse_vc_conf,
5916 [ACTION_MODIFY_FIELD_OP_VALUE] = {
5917 .name = "{operation}",
5918 .help = "operation type value",
5919 .call = parse_vc_modify_field_op,
5920 .comp = comp_set_modify_field_op,
5922 [ACTION_MODIFY_FIELD_DST_TYPE] = {
5924 .help = "destination field type",
5925 .next = NEXT(action_modify_field_dst,
5926 NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_TYPE_VALUE)),
5927 .call = parse_vc_conf,
5929 [ACTION_MODIFY_FIELD_DST_TYPE_VALUE] = {
5930 .name = "{dst_type}",
5931 .help = "destination field type value",
5932 .call = parse_vc_modify_field_id,
5933 .comp = comp_set_modify_field_id,
5935 [ACTION_MODIFY_FIELD_DST_LEVEL] = {
5936 .name = "dst_level",
5937 .help = "destination field level",
5938 .next = NEXT(action_modify_field_dst,
5939 NEXT_ENTRY(COMMON_UNSIGNED)),
5940 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
5942 .call = parse_vc_conf,
5944 [ACTION_MODIFY_FIELD_DST_OFFSET] = {
5945 .name = "dst_offset",
5946 .help = "destination field bit offset",
5947 .next = NEXT(action_modify_field_dst,
5948 NEXT_ENTRY(COMMON_UNSIGNED)),
5949 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
5951 .call = parse_vc_conf,
5953 [ACTION_MODIFY_FIELD_SRC_TYPE] = {
5955 .help = "source field type",
5956 .next = NEXT(action_modify_field_src,
5957 NEXT_ENTRY(ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)),
5958 .call = parse_vc_conf,
5960 [ACTION_MODIFY_FIELD_SRC_TYPE_VALUE] = {
5961 .name = "{src_type}",
5962 .help = "source field type value",
5963 .call = parse_vc_modify_field_id,
5964 .comp = comp_set_modify_field_id,
5966 [ACTION_MODIFY_FIELD_SRC_LEVEL] = {
5967 .name = "src_level",
5968 .help = "source field level",
5969 .next = NEXT(action_modify_field_src,
5970 NEXT_ENTRY(COMMON_UNSIGNED)),
5971 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
5973 .call = parse_vc_conf,
5975 [ACTION_MODIFY_FIELD_SRC_OFFSET] = {
5976 .name = "src_offset",
5977 .help = "source field bit offset",
5978 .next = NEXT(action_modify_field_src,
5979 NEXT_ENTRY(COMMON_UNSIGNED)),
5980 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
5982 .call = parse_vc_conf,
5984 [ACTION_MODIFY_FIELD_SRC_VALUE] = {
5985 .name = "src_value",
5986 .help = "source immediate value",
5987 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_WIDTH),
5988 NEXT_ENTRY(COMMON_HEX)),
5989 .args = ARGS(ARGS_ENTRY_ARB(0, 0),
5990 ARGS_ENTRY_ARB(0, 0),
5991 ARGS_ENTRY(struct rte_flow_action_modify_field,
5993 .call = parse_vc_conf,
5995 [ACTION_MODIFY_FIELD_SRC_POINTER] = {
5997 .help = "pointer to source immediate value",
5998 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_WIDTH),
5999 NEXT_ENTRY(COMMON_HEX)),
6000 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
6002 ARGS_ENTRY_ARB(0, 0),
6004 (sizeof(struct rte_flow_action_modify_field),
6005 ACTION_MODIFY_PATTERN_SIZE)),
6006 .call = parse_vc_conf,
6008 [ACTION_MODIFY_FIELD_WIDTH] = {
6010 .help = "number of bits to copy",
6011 .next = NEXT(NEXT_ENTRY(ACTION_NEXT),
6012 NEXT_ENTRY(COMMON_UNSIGNED)),
6013 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
6015 .call = parse_vc_conf,
6017 /* Top level command. */
6020 .help = "set raw encap/decap/sample data",
6021 .type = "set raw_encap|raw_decap <index> <pattern>"
6022 " or set sample_actions <index> <action>",
6023 .next = NEXT(NEXT_ENTRY
6026 SET_SAMPLE_ACTIONS)),
6027 .call = parse_set_init,
6029 /* Sub-level commands. */
6031 .name = "raw_encap",
6032 .help = "set raw encap data",
6033 .next = NEXT(next_set_raw),
6034 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
6035 (offsetof(struct buffer, port),
6036 sizeof(((struct buffer *)0)->port),
6037 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
6038 .call = parse_set_raw_encap_decap,
6041 .name = "raw_decap",
6042 .help = "set raw decap data",
6043 .next = NEXT(next_set_raw),
6044 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
6045 (offsetof(struct buffer, port),
6046 sizeof(((struct buffer *)0)->port),
6047 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
6048 .call = parse_set_raw_encap_decap,
6052 .type = "COMMON_UNSIGNED",
6053 .help = "index of raw_encap/raw_decap data",
6054 .next = NEXT(next_item),
6057 [SET_SAMPLE_INDEX] = {
6060 .help = "index of sample actions",
6061 .next = NEXT(next_action_sample),
6064 [SET_SAMPLE_ACTIONS] = {
6065 .name = "sample_actions",
6066 .help = "set sample actions list",
6067 .next = NEXT(NEXT_ENTRY(SET_SAMPLE_INDEX)),
6068 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
6069 (offsetof(struct buffer, port),
6070 sizeof(((struct buffer *)0)->port),
6071 0, RAW_SAMPLE_CONFS_MAX_NUM - 1)),
6072 .call = parse_set_sample_action,
6074 [ACTION_SET_TAG] = {
6077 .priv = PRIV_ACTION(SET_TAG,
6078 sizeof(struct rte_flow_action_set_tag)),
6079 .next = NEXT(action_set_tag),
6082 [ACTION_SET_TAG_INDEX] = {
6084 .help = "index of tag array",
6085 .next = NEXT(action_set_tag, NEXT_ENTRY(COMMON_UNSIGNED)),
6086 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_set_tag, index)),
6087 .call = parse_vc_conf,
6089 [ACTION_SET_TAG_DATA] = {
6091 .help = "tag value",
6092 .next = NEXT(action_set_tag, NEXT_ENTRY(COMMON_UNSIGNED)),
6093 .args = ARGS(ARGS_ENTRY
6094 (struct rte_flow_action_set_tag, data)),
6095 .call = parse_vc_conf,
6097 [ACTION_SET_TAG_MASK] = {
6099 .help = "mask for tag value",
6100 .next = NEXT(action_set_tag, NEXT_ENTRY(COMMON_UNSIGNED)),
6101 .args = ARGS(ARGS_ENTRY
6102 (struct rte_flow_action_set_tag, mask)),
6103 .call = parse_vc_conf,
6105 [ACTION_SET_META] = {
6107 .help = "set metadata",
6108 .priv = PRIV_ACTION(SET_META,
6109 sizeof(struct rte_flow_action_set_meta)),
6110 .next = NEXT(action_set_meta),
6111 .call = parse_vc_action_set_meta,
6113 [ACTION_SET_META_DATA] = {
6115 .help = "metadata value",
6116 .next = NEXT(action_set_meta, NEXT_ENTRY(COMMON_UNSIGNED)),
6117 .args = ARGS(ARGS_ENTRY
6118 (struct rte_flow_action_set_meta, data)),
6119 .call = parse_vc_conf,
6121 [ACTION_SET_META_MASK] = {
6123 .help = "mask for metadata value",
6124 .next = NEXT(action_set_meta, NEXT_ENTRY(COMMON_UNSIGNED)),
6125 .args = ARGS(ARGS_ENTRY
6126 (struct rte_flow_action_set_meta, mask)),
6127 .call = parse_vc_conf,
6129 [ACTION_SET_IPV4_DSCP] = {
6130 .name = "set_ipv4_dscp",
6131 .help = "set DSCP value",
6132 .priv = PRIV_ACTION(SET_IPV4_DSCP,
6133 sizeof(struct rte_flow_action_set_dscp)),
6134 .next = NEXT(action_set_ipv4_dscp),
6137 [ACTION_SET_IPV4_DSCP_VALUE] = {
6138 .name = "dscp_value",
6139 .help = "new IPv4 DSCP value to set",
6140 .next = NEXT(action_set_ipv4_dscp, NEXT_ENTRY(COMMON_UNSIGNED)),
6141 .args = ARGS(ARGS_ENTRY
6142 (struct rte_flow_action_set_dscp, dscp)),
6143 .call = parse_vc_conf,
6145 [ACTION_SET_IPV6_DSCP] = {
6146 .name = "set_ipv6_dscp",
6147 .help = "set DSCP value",
6148 .priv = PRIV_ACTION(SET_IPV6_DSCP,
6149 sizeof(struct rte_flow_action_set_dscp)),
6150 .next = NEXT(action_set_ipv6_dscp),
6153 [ACTION_SET_IPV6_DSCP_VALUE] = {
6154 .name = "dscp_value",
6155 .help = "new IPv6 DSCP value to set",
6156 .next = NEXT(action_set_ipv6_dscp, NEXT_ENTRY(COMMON_UNSIGNED)),
6157 .args = ARGS(ARGS_ENTRY
6158 (struct rte_flow_action_set_dscp, dscp)),
6159 .call = parse_vc_conf,
6163 .help = "set a specific metadata header",
6164 .next = NEXT(action_age),
6165 .priv = PRIV_ACTION(AGE,
6166 sizeof(struct rte_flow_action_age)),
6169 [ACTION_AGE_TIMEOUT] = {
6171 .help = "flow age timeout value",
6172 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_age,
6174 .next = NEXT(action_age, NEXT_ENTRY(COMMON_UNSIGNED)),
6175 .call = parse_vc_conf,
6179 .help = "set a sample action",
6180 .next = NEXT(action_sample),
6181 .priv = PRIV_ACTION(SAMPLE,
6182 sizeof(struct action_sample_data)),
6183 .call = parse_vc_action_sample,
6185 [ACTION_SAMPLE_RATIO] = {
6187 .help = "flow sample ratio value",
6188 .next = NEXT(action_sample, NEXT_ENTRY(COMMON_UNSIGNED)),
6189 .args = ARGS(ARGS_ENTRY_ARB
6190 (offsetof(struct action_sample_data, conf) +
6191 offsetof(struct rte_flow_action_sample, ratio),
6192 sizeof(((struct rte_flow_action_sample *)0)->
6195 [ACTION_SAMPLE_INDEX] = {
6197 .help = "the index of sample actions list",
6198 .next = NEXT(NEXT_ENTRY(ACTION_SAMPLE_INDEX_VALUE)),
6200 [ACTION_SAMPLE_INDEX_VALUE] = {
6202 .type = "COMMON_UNSIGNED",
6203 .help = "unsigned integer value",
6204 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
6205 .call = parse_vc_action_sample_index,
6206 .comp = comp_set_sample_index,
6208 [ACTION_CONNTRACK] = {
6209 .name = "conntrack",
6210 .help = "create a conntrack object",
6211 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
6212 .priv = PRIV_ACTION(CONNTRACK,
6213 sizeof(struct rte_flow_action_conntrack)),
6216 [ACTION_CONNTRACK_UPDATE] = {
6217 .name = "conntrack_update",
6218 .help = "update a conntrack object",
6219 .next = NEXT(action_update_conntrack),
6220 .priv = PRIV_ACTION(CONNTRACK,
6221 sizeof(struct rte_flow_modify_conntrack)),
6224 [ACTION_CONNTRACK_UPDATE_DIR] = {
6226 .help = "update a conntrack object direction",
6227 .next = NEXT(action_update_conntrack),
6228 .call = parse_vc_action_conntrack_update,
6230 [ACTION_CONNTRACK_UPDATE_CTX] = {
6232 .help = "update a conntrack object context",
6233 .next = NEXT(action_update_conntrack),
6234 .call = parse_vc_action_conntrack_update,
6236 [ACTION_PORT_REPRESENTOR] = {
6237 .name = "port_representor",
6238 .help = "at embedded switch level, send matching traffic to the given ethdev",
6239 .priv = PRIV_ACTION(PORT_REPRESENTOR,
6240 sizeof(struct rte_flow_action_ethdev)),
6241 .next = NEXT(action_port_representor),
6244 [ACTION_PORT_REPRESENTOR_PORT_ID] = {
6246 .help = "ethdev port ID",
6247 .next = NEXT(action_port_representor,
6248 NEXT_ENTRY(COMMON_UNSIGNED)),
6249 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_ethdev,
6251 .call = parse_vc_conf,
6253 [ACTION_REPRESENTED_PORT] = {
6254 .name = "represented_port",
6255 .help = "at embedded switch level, send matching traffic to the entity represented by the given ethdev",
6256 .priv = PRIV_ACTION(REPRESENTED_PORT,
6257 sizeof(struct rte_flow_action_ethdev)),
6258 .next = NEXT(action_represented_port),
6261 [ACTION_REPRESENTED_PORT_ETHDEV_PORT_ID] = {
6262 .name = "ethdev_port_id",
6263 .help = "ethdev port ID",
6264 .next = NEXT(action_represented_port,
6265 NEXT_ENTRY(COMMON_UNSIGNED)),
6266 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_ethdev,
6268 .call = parse_vc_conf,
6270 /* Indirect action destroy arguments. */
6271 [INDIRECT_ACTION_DESTROY_ID] = {
6272 .name = "action_id",
6273 .help = "specify a indirect action id to destroy",
6274 .next = NEXT(next_ia_destroy_attr,
6275 NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
6276 .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
6277 args.ia_destroy.action_id)),
6278 .call = parse_ia_destroy,
6280 /* Indirect action create arguments. */
6281 [INDIRECT_ACTION_CREATE_ID] = {
6282 .name = "action_id",
6283 .help = "specify a indirect action id to create",
6284 .next = NEXT(next_ia_create_attr,
6285 NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
6286 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
6288 [ACTION_INDIRECT] = {
6290 .help = "apply indirect action by id",
6291 .priv = PRIV_ACTION(INDIRECT, 0),
6292 .next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_ID2PTR)),
6293 .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
6296 [INDIRECT_ACTION_ID2PTR] = {
6297 .name = "{action_id}",
6298 .type = "INDIRECT_ACTION_ID",
6299 .help = "indirect action id",
6300 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
6301 .call = parse_ia_id2ptr,
6304 [INDIRECT_ACTION_INGRESS] = {
6306 .help = "affect rule to ingress",
6307 .next = NEXT(next_ia_create_attr),
6310 [INDIRECT_ACTION_EGRESS] = {
6312 .help = "affect rule to egress",
6313 .next = NEXT(next_ia_create_attr),
6316 [INDIRECT_ACTION_TRANSFER] = {
6318 .help = "affect rule to transfer",
6319 .next = NEXT(next_ia_create_attr),
6322 [INDIRECT_ACTION_SPEC] = {
6324 .help = "specify action to create indirect handle",
6325 .next = NEXT(next_action),
6328 .name = "g_actions",
6329 .help = "submit a list of associated actions for green",
6330 .next = NEXT(next_action),
6334 .name = "y_actions",
6335 .help = "submit a list of associated actions for yellow",
6336 .next = NEXT(next_action),
6339 .name = "r_actions",
6340 .help = "submit a list of associated actions for red",
6341 .next = NEXT(next_action),
6344 /* Top-level command. */
6347 .type = "port meter policy {port_id} {arg}",
6348 .help = "add port meter policy",
6349 .next = NEXT(NEXT_ENTRY(ITEM_POL_PORT)),
6352 /* Sub-level commands. */
6355 .help = "add port meter policy",
6356 .next = NEXT(NEXT_ENTRY(ITEM_POL_METER)),
6358 [ITEM_POL_METER] = {
6360 .help = "add port meter policy",
6361 .next = NEXT(NEXT_ENTRY(ITEM_POL_POLICY)),
6363 [ITEM_POL_POLICY] = {
6365 .help = "add port meter policy",
6366 .next = NEXT(NEXT_ENTRY(ACTION_POL_R),
6367 NEXT_ENTRY(ACTION_POL_Y),
6368 NEXT_ENTRY(ACTION_POL_G),
6369 NEXT_ENTRY(COMMON_POLICY_ID),
6370 NEXT_ENTRY(COMMON_PORT_ID)),
6371 .args = ARGS(ARGS_ENTRY(struct buffer, args.policy.policy_id),
6372 ARGS_ENTRY(struct buffer, port)),
6377 /** Remove and return last entry from argument stack. */
6378 static const struct arg *
6379 pop_args(struct context *ctx)
6381 return ctx->args_num ? ctx->args[--ctx->args_num] : NULL;
6384 /** Add entry on top of the argument stack. */
6386 push_args(struct context *ctx, const struct arg *arg)
6388 if (ctx->args_num == CTX_STACK_SIZE)
6390 ctx->args[ctx->args_num++] = arg;
6394 /** Spread value into buffer according to bit-mask. */
6396 arg_entry_bf_fill(void *dst, uintmax_t val, const struct arg *arg)
6398 uint32_t i = arg->size;
6406 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
6415 unsigned int shift = 0;
6416 uint8_t *buf = (uint8_t *)dst + arg->offset + (i -= sub);
6418 for (shift = 0; arg->mask[i] >> shift; ++shift) {
6419 if (!(arg->mask[i] & (1 << shift)))
6424 *buf &= ~(1 << shift);
6425 *buf |= (val & 1) << shift;
6433 /** Compare a string with a partial one of a given length. */
6435 strcmp_partial(const char *full, const char *partial, size_t partial_len)
6437 int r = strncmp(full, partial, partial_len);
6441 if (strlen(full) <= partial_len)
6443 return full[partial_len];
6447 * Parse a prefix length and generate a bit-mask.
6449 * Last argument (ctx->args) is retrieved to determine mask size, storage
6450 * location and whether the result must use network byte ordering.
6453 parse_prefix(struct context *ctx, const struct token *token,
6454 const char *str, unsigned int len,
6455 void *buf, unsigned int size)
6457 const struct arg *arg = pop_args(ctx);
6458 static const uint8_t conv[] = "\x00\x80\xc0\xe0\xf0\xf8\xfc\xfe\xff";
6465 /* Argument is expected. */
6469 u = strtoumax(str, &end, 0);
6470 if (errno || (size_t)(end - str) != len)
6475 extra = arg_entry_bf_fill(NULL, 0, arg);
6484 if (!arg_entry_bf_fill(ctx->object, v, arg) ||
6485 !arg_entry_bf_fill(ctx->objmask, -1, arg))
6492 if (bytes > size || bytes + !!extra > size)
6496 buf = (uint8_t *)ctx->object + arg->offset;
6497 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
6499 memset((uint8_t *)buf + size - bytes, 0xff, bytes);
6500 memset(buf, 0x00, size - bytes);
6502 ((uint8_t *)buf)[size - bytes - 1] = conv[extra];
6506 memset(buf, 0xff, bytes);
6507 memset((uint8_t *)buf + bytes, 0x00, size - bytes);
6509 ((uint8_t *)buf)[bytes] = conv[extra];
6512 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6515 push_args(ctx, arg);
6519 /** Default parsing function for token name matching. */
6521 parse_default(struct context *ctx, const struct token *token,
6522 const char *str, unsigned int len,
6523 void *buf, unsigned int size)
6528 if (strcmp_partial(token->name, str, len))
6533 /** Parse flow command, initialize output buffer for subsequent tokens. */
6535 parse_init(struct context *ctx, const struct token *token,
6536 const char *str, unsigned int len,
6537 void *buf, unsigned int size)
6539 struct buffer *out = buf;
6541 /* Token name must match. */
6542 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6544 /* Nothing else to do if there is no buffer. */
6547 /* Make sure buffer is large enough. */
6548 if (size < sizeof(*out))
6550 /* Initialize buffer. */
6551 memset(out, 0x00, sizeof(*out));
6552 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
6555 ctx->objmask = NULL;
6559 /** Parse tokens for indirect action commands. */
6561 parse_ia(struct context *ctx, const struct token *token,
6562 const char *str, unsigned int len,
6563 void *buf, unsigned int size)
6565 struct buffer *out = buf;
6567 /* Token name must match. */
6568 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6570 /* Nothing else to do if there is no buffer. */
6573 if (!out->command) {
6574 if (ctx->curr != INDIRECT_ACTION)
6576 if (sizeof(*out) > size)
6578 out->command = ctx->curr;
6581 ctx->objmask = NULL;
6582 out->args.vc.data = (uint8_t *)out + size;
6585 switch (ctx->curr) {
6586 case INDIRECT_ACTION_CREATE:
6587 case INDIRECT_ACTION_UPDATE:
6588 out->args.vc.actions =
6589 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6591 out->args.vc.attr.group = UINT32_MAX;
6593 case INDIRECT_ACTION_QUERY:
6594 out->command = ctx->curr;
6597 ctx->objmask = NULL;
6599 case INDIRECT_ACTION_EGRESS:
6600 out->args.vc.attr.egress = 1;
6602 case INDIRECT_ACTION_INGRESS:
6603 out->args.vc.attr.ingress = 1;
6605 case INDIRECT_ACTION_TRANSFER:
6606 out->args.vc.attr.transfer = 1;
6614 /** Parse tokens for indirect action destroy command. */
6616 parse_ia_destroy(struct context *ctx, const struct token *token,
6617 const char *str, unsigned int len,
6618 void *buf, unsigned int size)
6620 struct buffer *out = buf;
6621 uint32_t *action_id;
6623 /* Token name must match. */
6624 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6626 /* Nothing else to do if there is no buffer. */
6629 if (!out->command || out->command == INDIRECT_ACTION) {
6630 if (ctx->curr != INDIRECT_ACTION_DESTROY)
6632 if (sizeof(*out) > size)
6634 out->command = ctx->curr;
6637 ctx->objmask = NULL;
6638 out->args.ia_destroy.action_id =
6639 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6643 action_id = out->args.ia_destroy.action_id
6644 + out->args.ia_destroy.action_id_n++;
6645 if ((uint8_t *)action_id > (uint8_t *)out + size)
6648 ctx->object = action_id;
6649 ctx->objmask = NULL;
6653 /** Parse tokens for indirect action commands. */
6655 parse_qia(struct context *ctx, const struct token *token,
6656 const char *str, unsigned int len,
6657 void *buf, unsigned int size)
6659 struct buffer *out = buf;
6661 /* Token name must match. */
6662 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6664 /* Nothing else to do if there is no buffer. */
6667 if (!out->command) {
6668 if (ctx->curr != QUEUE)
6670 if (sizeof(*out) > size)
6672 out->args.vc.data = (uint8_t *)out + size;
6675 switch (ctx->curr) {
6676 case QUEUE_INDIRECT_ACTION:
6678 case QUEUE_INDIRECT_ACTION_CREATE:
6679 case QUEUE_INDIRECT_ACTION_UPDATE:
6680 out->args.vc.actions =
6681 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6683 out->args.vc.attr.group = UINT32_MAX;
6684 out->command = ctx->curr;
6687 ctx->objmask = NULL;
6689 case QUEUE_INDIRECT_ACTION_EGRESS:
6690 out->args.vc.attr.egress = 1;
6692 case QUEUE_INDIRECT_ACTION_INGRESS:
6693 out->args.vc.attr.ingress = 1;
6695 case QUEUE_INDIRECT_ACTION_TRANSFER:
6696 out->args.vc.attr.transfer = 1;
6698 case QUEUE_INDIRECT_ACTION_CREATE_POSTPONE:
6705 /** Parse tokens for indirect action destroy command. */
6707 parse_qia_destroy(struct context *ctx, const struct token *token,
6708 const char *str, unsigned int len,
6709 void *buf, unsigned int size)
6711 struct buffer *out = buf;
6712 uint32_t *action_id;
6714 /* Token name must match. */
6715 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6717 /* Nothing else to do if there is no buffer. */
6720 if (!out->command || out->command == QUEUE) {
6721 if (ctx->curr != QUEUE_INDIRECT_ACTION_DESTROY)
6723 if (sizeof(*out) > size)
6725 out->command = ctx->curr;
6728 ctx->objmask = NULL;
6729 out->args.ia_destroy.action_id =
6730 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6734 switch (ctx->curr) {
6735 case QUEUE_INDIRECT_ACTION:
6736 out->command = ctx->curr;
6739 ctx->objmask = NULL;
6741 case QUEUE_INDIRECT_ACTION_DESTROY_ID:
6742 action_id = out->args.ia_destroy.action_id
6743 + out->args.ia_destroy.action_id_n++;
6744 if ((uint8_t *)action_id > (uint8_t *)out + size)
6747 ctx->object = action_id;
6748 ctx->objmask = NULL;
6750 case QUEUE_INDIRECT_ACTION_DESTROY_POSTPONE:
6757 /** Parse tokens for meter policy action commands. */
6759 parse_mp(struct context *ctx, const struct token *token,
6760 const char *str, unsigned int len,
6761 void *buf, unsigned int size)
6763 struct buffer *out = buf;
6765 /* Token name must match. */
6766 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6768 /* Nothing else to do if there is no buffer. */
6771 if (!out->command) {
6772 if (ctx->curr != ITEM_POL_POLICY)
6774 if (sizeof(*out) > size)
6776 out->command = ctx->curr;
6779 ctx->objmask = NULL;
6780 out->args.vc.data = (uint8_t *)out + size;
6783 switch (ctx->curr) {
6785 out->args.vc.actions =
6786 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6788 out->command = ctx->curr;
6791 ctx->objmask = NULL;
6798 /** Parse tokens for validate/create commands. */
6800 parse_vc(struct context *ctx, const struct token *token,
6801 const char *str, unsigned int len,
6802 void *buf, unsigned int size)
6804 struct buffer *out = buf;
6808 /* Token name must match. */
6809 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6811 /* Nothing else to do if there is no buffer. */
6814 if (!out->command) {
6815 if (ctx->curr != VALIDATE && ctx->curr != CREATE &&
6816 ctx->curr != PATTERN_TEMPLATE_CREATE &&
6817 ctx->curr != ACTIONS_TEMPLATE_CREATE)
6819 if (sizeof(*out) > size)
6821 out->command = ctx->curr;
6824 ctx->objmask = NULL;
6825 out->args.vc.data = (uint8_t *)out + size;
6829 switch (ctx->curr) {
6831 ctx->object = &out->args.vc.attr;
6834 case VC_TUNNEL_MATCH:
6835 ctx->object = &out->args.vc.tunnel_ops;
6838 ctx->objmask = NULL;
6839 switch (ctx->curr) {
6844 out->args.vc.tunnel_ops.enabled = 1;
6845 out->args.vc.tunnel_ops.actions = 1;
6847 case VC_TUNNEL_MATCH:
6848 out->args.vc.tunnel_ops.enabled = 1;
6849 out->args.vc.tunnel_ops.items = 1;
6852 out->args.vc.attr.ingress = 1;
6855 out->args.vc.attr.egress = 1;
6858 out->args.vc.attr.transfer = 1;
6861 out->args.vc.pattern =
6862 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6864 ctx->object = out->args.vc.pattern;
6865 ctx->objmask = NULL;
6868 out->args.vc.actions =
6869 (void *)RTE_ALIGN_CEIL((uintptr_t)
6870 (out->args.vc.pattern +
6871 out->args.vc.pattern_n),
6873 ctx->object = out->args.vc.actions;
6874 ctx->objmask = NULL;
6881 if (!out->args.vc.actions) {
6882 const struct parse_item_priv *priv = token->priv;
6883 struct rte_flow_item *item =
6884 out->args.vc.pattern + out->args.vc.pattern_n;
6886 data_size = priv->size * 3; /* spec, last, mask */
6887 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
6888 (out->args.vc.data - data_size),
6890 if ((uint8_t *)item + sizeof(*item) > data)
6892 *item = (struct rte_flow_item){
6895 ++out->args.vc.pattern_n;
6897 ctx->objmask = NULL;
6899 const struct parse_action_priv *priv = token->priv;
6900 struct rte_flow_action *action =
6901 out->args.vc.actions + out->args.vc.actions_n;
6903 data_size = priv->size; /* configuration */
6904 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
6905 (out->args.vc.data - data_size),
6907 if ((uint8_t *)action + sizeof(*action) > data)
6909 *action = (struct rte_flow_action){
6911 .conf = data_size ? data : NULL,
6913 ++out->args.vc.actions_n;
6914 ctx->object = action;
6915 ctx->objmask = NULL;
6917 memset(data, 0, data_size);
6918 out->args.vc.data = data;
6919 ctx->objdata = data_size;
6923 /** Parse pattern item parameter type. */
6925 parse_vc_spec(struct context *ctx, const struct token *token,
6926 const char *str, unsigned int len,
6927 void *buf, unsigned int size)
6929 struct buffer *out = buf;
6930 struct rte_flow_item *item;
6936 /* Token name must match. */
6937 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6939 /* Parse parameter types. */
6940 switch (ctx->curr) {
6941 static const enum index prefix[] = NEXT_ENTRY(COMMON_PREFIX);
6947 case ITEM_PARAM_SPEC:
6950 case ITEM_PARAM_LAST:
6953 case ITEM_PARAM_PREFIX:
6954 /* Modify next token to expect a prefix. */
6955 if (ctx->next_num < 2)
6957 ctx->next[ctx->next_num - 2] = prefix;
6959 case ITEM_PARAM_MASK:
6965 /* Nothing else to do if there is no buffer. */
6968 if (!out->args.vc.pattern_n)
6970 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
6971 data_size = ctx->objdata / 3; /* spec, last, mask */
6972 /* Point to selected object. */
6973 ctx->object = out->args.vc.data + (data_size * index);
6975 ctx->objmask = out->args.vc.data + (data_size * 2); /* mask */
6976 item->mask = ctx->objmask;
6978 ctx->objmask = NULL;
6979 /* Update relevant item pointer. */
6980 *((const void **[]){ &item->spec, &item->last, &item->mask })[index] =
6985 /** Parse action configuration field. */
6987 parse_vc_conf(struct context *ctx, const struct token *token,
6988 const char *str, unsigned int len,
6989 void *buf, unsigned int size)
6991 struct buffer *out = buf;
6994 /* Token name must match. */
6995 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6997 /* Nothing else to do if there is no buffer. */
7000 /* Point to selected object. */
7001 ctx->object = out->args.vc.data;
7002 ctx->objmask = NULL;
7006 /** Parse eCPRI common header type field. */
7008 parse_vc_item_ecpri_type(struct context *ctx, const struct token *token,
7009 const char *str, unsigned int len,
7010 void *buf, unsigned int size)
7012 struct rte_flow_item_ecpri *ecpri;
7013 struct rte_flow_item_ecpri *ecpri_mask;
7014 struct rte_flow_item *item;
7017 struct buffer *out = buf;
7018 const struct arg *arg;
7021 /* Token name must match. */
7022 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7024 switch (ctx->curr) {
7025 case ITEM_ECPRI_COMMON_TYPE_IQ_DATA:
7026 msg_type = RTE_ECPRI_MSG_TYPE_IQ_DATA;
7028 case ITEM_ECPRI_COMMON_TYPE_RTC_CTRL:
7029 msg_type = RTE_ECPRI_MSG_TYPE_RTC_CTRL;
7031 case ITEM_ECPRI_COMMON_TYPE_DLY_MSR:
7032 msg_type = RTE_ECPRI_MSG_TYPE_DLY_MSR;
7039 arg = pop_args(ctx);
7042 ecpri = (struct rte_flow_item_ecpri *)out->args.vc.data;
7043 ecpri->hdr.common.type = msg_type;
7044 data_size = ctx->objdata / 3; /* spec, last, mask */
7045 ecpri_mask = (struct rte_flow_item_ecpri *)(out->args.vc.data +
7047 ecpri_mask->hdr.common.type = 0xFF;
7049 ecpri->hdr.common.u32 = rte_cpu_to_be_32(ecpri->hdr.common.u32);
7050 ecpri_mask->hdr.common.u32 =
7051 rte_cpu_to_be_32(ecpri_mask->hdr.common.u32);
7053 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
7055 item->mask = ecpri_mask;
7059 /** Parse L2TPv2 common header type field. */
7061 parse_vc_item_l2tpv2_type(struct context *ctx, const struct token *token,
7062 const char *str, unsigned int len,
7063 void *buf, unsigned int size)
7065 struct rte_flow_item_l2tpv2 *l2tpv2;
7066 struct rte_flow_item_l2tpv2 *l2tpv2_mask;
7067 struct rte_flow_item *item;
7069 uint16_t msg_type = 0;
7070 struct buffer *out = buf;
7071 const struct arg *arg;
7074 /* Token name must match. */
7075 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7077 switch (ctx->curr) {
7078 case ITEM_L2TPV2_TYPE_DATA:
7079 msg_type |= RTE_L2TPV2_MSG_TYPE_DATA;
7081 case ITEM_L2TPV2_TYPE_DATA_L:
7082 msg_type |= RTE_L2TPV2_MSG_TYPE_DATA_L;
7084 case ITEM_L2TPV2_TYPE_DATA_S:
7085 msg_type |= RTE_L2TPV2_MSG_TYPE_DATA_S;
7087 case ITEM_L2TPV2_TYPE_DATA_O:
7088 msg_type |= RTE_L2TPV2_MSG_TYPE_DATA_O;
7090 case ITEM_L2TPV2_TYPE_DATA_L_S:
7091 msg_type |= RTE_L2TPV2_MSG_TYPE_DATA_L_S;
7093 case ITEM_L2TPV2_TYPE_CTRL:
7094 msg_type |= RTE_L2TPV2_MSG_TYPE_CONTROL;
7101 arg = pop_args(ctx);
7104 l2tpv2 = (struct rte_flow_item_l2tpv2 *)out->args.vc.data;
7105 l2tpv2->hdr.common.flags_version |= msg_type;
7106 data_size = ctx->objdata / 3; /* spec, last, mask */
7107 l2tpv2_mask = (struct rte_flow_item_l2tpv2 *)(out->args.vc.data +
7109 l2tpv2_mask->hdr.common.flags_version = 0xFFFF;
7111 l2tpv2->hdr.common.flags_version =
7112 rte_cpu_to_be_16(l2tpv2->hdr.common.flags_version);
7113 l2tpv2_mask->hdr.common.flags_version =
7114 rte_cpu_to_be_16(l2tpv2_mask->hdr.common.flags_version);
7116 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
7117 item->spec = l2tpv2;
7118 item->mask = l2tpv2_mask;
7122 /** Parse meter color action type. */
7124 parse_vc_action_meter_color_type(struct context *ctx, const struct token *token,
7125 const char *str, unsigned int len,
7126 void *buf, unsigned int size)
7128 struct rte_flow_action *action_data;
7129 struct rte_flow_action_meter_color *conf;
7130 enum rte_color color;
7134 /* Token name must match. */
7135 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7137 switch (ctx->curr) {
7138 case ACTION_METER_COLOR_GREEN:
7139 color = RTE_COLOR_GREEN;
7141 case ACTION_METER_COLOR_YELLOW:
7142 color = RTE_COLOR_YELLOW;
7144 case ACTION_METER_COLOR_RED:
7145 color = RTE_COLOR_RED;
7153 action_data = ctx->object;
7154 conf = (struct rte_flow_action_meter_color *)
7155 (uintptr_t)(action_data->conf);
7156 conf->color = color;
7160 /** Parse RSS action. */
7162 parse_vc_action_rss(struct context *ctx, const struct token *token,
7163 const char *str, unsigned int len,
7164 void *buf, unsigned int size)
7166 struct buffer *out = buf;
7167 struct rte_flow_action *action;
7168 struct action_rss_data *action_rss_data;
7172 ret = parse_vc(ctx, token, str, len, buf, size);
7175 /* Nothing else to do if there is no buffer. */
7178 if (!out->args.vc.actions_n)
7180 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
7181 /* Point to selected object. */
7182 ctx->object = out->args.vc.data;
7183 ctx->objmask = NULL;
7184 /* Set up default configuration. */
7185 action_rss_data = ctx->object;
7186 *action_rss_data = (struct action_rss_data){
7187 .conf = (struct rte_flow_action_rss){
7188 .func = RTE_ETH_HASH_FUNCTION_DEFAULT,
7192 .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM),
7194 .queue = action_rss_data->queue,
7198 for (i = 0; i < action_rss_data->conf.queue_num; ++i)
7199 action_rss_data->queue[i] = i;
7200 action->conf = &action_rss_data->conf;
7205 * Parse func field for RSS action.
7207 * The RTE_ETH_HASH_FUNCTION_* value to assign is derived from the
7208 * ACTION_RSS_FUNC_* index that called this function.
7211 parse_vc_action_rss_func(struct context *ctx, const struct token *token,
7212 const char *str, unsigned int len,
7213 void *buf, unsigned int size)
7215 struct action_rss_data *action_rss_data;
7216 enum rte_eth_hash_function func;
7220 /* Token name must match. */
7221 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7223 switch (ctx->curr) {
7224 case ACTION_RSS_FUNC_DEFAULT:
7225 func = RTE_ETH_HASH_FUNCTION_DEFAULT;
7227 case ACTION_RSS_FUNC_TOEPLITZ:
7228 func = RTE_ETH_HASH_FUNCTION_TOEPLITZ;
7230 case ACTION_RSS_FUNC_SIMPLE_XOR:
7231 func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
7233 case ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ:
7234 func = RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
7241 action_rss_data = ctx->object;
7242 action_rss_data->conf.func = func;
7247 * Parse type field for RSS action.
7249 * Valid tokens are type field names and the "end" token.
7252 parse_vc_action_rss_type(struct context *ctx, const struct token *token,
7253 const char *str, unsigned int len,
7254 void *buf, unsigned int size)
7256 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE);
7257 struct action_rss_data *action_rss_data;
7263 if (ctx->curr != ACTION_RSS_TYPE)
7265 if (!(ctx->objdata >> 16) && ctx->object) {
7266 action_rss_data = ctx->object;
7267 action_rss_data->conf.types = 0;
7269 if (!strcmp_partial("end", str, len)) {
7270 ctx->objdata &= 0xffff;
7273 for (i = 0; rss_type_table[i].str; ++i)
7274 if (!strcmp_partial(rss_type_table[i].str, str, len))
7276 if (!rss_type_table[i].str)
7278 ctx->objdata = 1 << 16 | (ctx->objdata & 0xffff);
7280 if (ctx->next_num == RTE_DIM(ctx->next))
7282 ctx->next[ctx->next_num++] = next;
7285 action_rss_data = ctx->object;
7286 action_rss_data->conf.types |= rss_type_table[i].rss_type;
7291 * Parse queue field for RSS action.
7293 * Valid tokens are queue indices and the "end" token.
7296 parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
7297 const char *str, unsigned int len,
7298 void *buf, unsigned int size)
7300 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE);
7301 struct action_rss_data *action_rss_data;
7302 const struct arg *arg;
7309 if (ctx->curr != ACTION_RSS_QUEUE)
7311 i = ctx->objdata >> 16;
7312 if (!strcmp_partial("end", str, len)) {
7313 ctx->objdata &= 0xffff;
7316 if (i >= ACTION_RSS_QUEUE_NUM)
7318 arg = ARGS_ENTRY_ARB(offsetof(struct action_rss_data, queue) +
7319 i * sizeof(action_rss_data->queue[i]),
7320 sizeof(action_rss_data->queue[i]));
7321 if (push_args(ctx, arg))
7323 ret = parse_int(ctx, token, str, len, NULL, 0);
7329 ctx->objdata = i << 16 | (ctx->objdata & 0xffff);
7331 if (ctx->next_num == RTE_DIM(ctx->next))
7333 ctx->next[ctx->next_num++] = next;
7337 action_rss_data = ctx->object;
7338 action_rss_data->conf.queue_num = i;
7339 action_rss_data->conf.queue = i ? action_rss_data->queue : NULL;
7343 /** Setup VXLAN encap configuration. */
7345 parse_setup_vxlan_encap_data(struct action_vxlan_encap_data *action_vxlan_encap_data)
7347 /* Set up default configuration. */
7348 *action_vxlan_encap_data = (struct action_vxlan_encap_data){
7349 .conf = (struct rte_flow_action_vxlan_encap){
7350 .definition = action_vxlan_encap_data->items,
7354 .type = RTE_FLOW_ITEM_TYPE_ETH,
7355 .spec = &action_vxlan_encap_data->item_eth,
7356 .mask = &rte_flow_item_eth_mask,
7359 .type = RTE_FLOW_ITEM_TYPE_VLAN,
7360 .spec = &action_vxlan_encap_data->item_vlan,
7361 .mask = &rte_flow_item_vlan_mask,
7364 .type = RTE_FLOW_ITEM_TYPE_IPV4,
7365 .spec = &action_vxlan_encap_data->item_ipv4,
7366 .mask = &rte_flow_item_ipv4_mask,
7369 .type = RTE_FLOW_ITEM_TYPE_UDP,
7370 .spec = &action_vxlan_encap_data->item_udp,
7371 .mask = &rte_flow_item_udp_mask,
7374 .type = RTE_FLOW_ITEM_TYPE_VXLAN,
7375 .spec = &action_vxlan_encap_data->item_vxlan,
7376 .mask = &rte_flow_item_vxlan_mask,
7379 .type = RTE_FLOW_ITEM_TYPE_END,
7384 .tci = vxlan_encap_conf.vlan_tci,
7388 .src_addr = vxlan_encap_conf.ipv4_src,
7389 .dst_addr = vxlan_encap_conf.ipv4_dst,
7392 .src_port = vxlan_encap_conf.udp_src,
7393 .dst_port = vxlan_encap_conf.udp_dst,
7395 .item_vxlan.flags = 0,
7397 memcpy(action_vxlan_encap_data->item_eth.dst.addr_bytes,
7398 vxlan_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
7399 memcpy(action_vxlan_encap_data->item_eth.src.addr_bytes,
7400 vxlan_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
7401 if (!vxlan_encap_conf.select_ipv4) {
7402 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.src_addr,
7403 &vxlan_encap_conf.ipv6_src,
7404 sizeof(vxlan_encap_conf.ipv6_src));
7405 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.dst_addr,
7406 &vxlan_encap_conf.ipv6_dst,
7407 sizeof(vxlan_encap_conf.ipv6_dst));
7408 action_vxlan_encap_data->items[2] = (struct rte_flow_item){
7409 .type = RTE_FLOW_ITEM_TYPE_IPV6,
7410 .spec = &action_vxlan_encap_data->item_ipv6,
7411 .mask = &rte_flow_item_ipv6_mask,
7414 if (!vxlan_encap_conf.select_vlan)
7415 action_vxlan_encap_data->items[1].type =
7416 RTE_FLOW_ITEM_TYPE_VOID;
7417 if (vxlan_encap_conf.select_tos_ttl) {
7418 if (vxlan_encap_conf.select_ipv4) {
7419 static struct rte_flow_item_ipv4 ipv4_mask_tos;
7421 memcpy(&ipv4_mask_tos, &rte_flow_item_ipv4_mask,
7422 sizeof(ipv4_mask_tos));
7423 ipv4_mask_tos.hdr.type_of_service = 0xff;
7424 ipv4_mask_tos.hdr.time_to_live = 0xff;
7425 action_vxlan_encap_data->item_ipv4.hdr.type_of_service =
7426 vxlan_encap_conf.ip_tos;
7427 action_vxlan_encap_data->item_ipv4.hdr.time_to_live =
7428 vxlan_encap_conf.ip_ttl;
7429 action_vxlan_encap_data->items[2].mask =
7432 static struct rte_flow_item_ipv6 ipv6_mask_tos;
7434 memcpy(&ipv6_mask_tos, &rte_flow_item_ipv6_mask,
7435 sizeof(ipv6_mask_tos));
7436 ipv6_mask_tos.hdr.vtc_flow |=
7437 RTE_BE32(0xfful << RTE_IPV6_HDR_TC_SHIFT);
7438 ipv6_mask_tos.hdr.hop_limits = 0xff;
7439 action_vxlan_encap_data->item_ipv6.hdr.vtc_flow |=
7441 ((uint32_t)vxlan_encap_conf.ip_tos <<
7442 RTE_IPV6_HDR_TC_SHIFT);
7443 action_vxlan_encap_data->item_ipv6.hdr.hop_limits =
7444 vxlan_encap_conf.ip_ttl;
7445 action_vxlan_encap_data->items[2].mask =
7449 memcpy(action_vxlan_encap_data->item_vxlan.vni, vxlan_encap_conf.vni,
7450 RTE_DIM(vxlan_encap_conf.vni));
7454 /** Parse VXLAN encap action. */
7456 parse_vc_action_vxlan_encap(struct context *ctx, const struct token *token,
7457 const char *str, unsigned int len,
7458 void *buf, unsigned int size)
7460 struct buffer *out = buf;
7461 struct rte_flow_action *action;
7462 struct action_vxlan_encap_data *action_vxlan_encap_data;
7465 ret = parse_vc(ctx, token, str, len, buf, size);
7468 /* Nothing else to do if there is no buffer. */
7471 if (!out->args.vc.actions_n)
7473 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
7474 /* Point to selected object. */
7475 ctx->object = out->args.vc.data;
7476 ctx->objmask = NULL;
7477 action_vxlan_encap_data = ctx->object;
7478 parse_setup_vxlan_encap_data(action_vxlan_encap_data);
7479 action->conf = &action_vxlan_encap_data->conf;
7483 /** Setup NVGRE encap configuration. */
7485 parse_setup_nvgre_encap_data(struct action_nvgre_encap_data *action_nvgre_encap_data)
7487 /* Set up default configuration. */
7488 *action_nvgre_encap_data = (struct action_nvgre_encap_data){
7489 .conf = (struct rte_flow_action_nvgre_encap){
7490 .definition = action_nvgre_encap_data->items,
7494 .type = RTE_FLOW_ITEM_TYPE_ETH,
7495 .spec = &action_nvgre_encap_data->item_eth,
7496 .mask = &rte_flow_item_eth_mask,
7499 .type = RTE_FLOW_ITEM_TYPE_VLAN,
7500 .spec = &action_nvgre_encap_data->item_vlan,
7501 .mask = &rte_flow_item_vlan_mask,
7504 .type = RTE_FLOW_ITEM_TYPE_IPV4,
7505 .spec = &action_nvgre_encap_data->item_ipv4,
7506 .mask = &rte_flow_item_ipv4_mask,
7509 .type = RTE_FLOW_ITEM_TYPE_NVGRE,
7510 .spec = &action_nvgre_encap_data->item_nvgre,
7511 .mask = &rte_flow_item_nvgre_mask,
7514 .type = RTE_FLOW_ITEM_TYPE_END,
7519 .tci = nvgre_encap_conf.vlan_tci,
7523 .src_addr = nvgre_encap_conf.ipv4_src,
7524 .dst_addr = nvgre_encap_conf.ipv4_dst,
7526 .item_nvgre.c_k_s_rsvd0_ver = RTE_BE16(0x2000),
7527 .item_nvgre.protocol = RTE_BE16(RTE_ETHER_TYPE_TEB),
7528 .item_nvgre.flow_id = 0,
7530 memcpy(action_nvgre_encap_data->item_eth.dst.addr_bytes,
7531 nvgre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
7532 memcpy(action_nvgre_encap_data->item_eth.src.addr_bytes,
7533 nvgre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
7534 if (!nvgre_encap_conf.select_ipv4) {
7535 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.src_addr,
7536 &nvgre_encap_conf.ipv6_src,
7537 sizeof(nvgre_encap_conf.ipv6_src));
7538 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.dst_addr,
7539 &nvgre_encap_conf.ipv6_dst,
7540 sizeof(nvgre_encap_conf.ipv6_dst));
7541 action_nvgre_encap_data->items[2] = (struct rte_flow_item){
7542 .type = RTE_FLOW_ITEM_TYPE_IPV6,
7543 .spec = &action_nvgre_encap_data->item_ipv6,
7544 .mask = &rte_flow_item_ipv6_mask,
7547 if (!nvgre_encap_conf.select_vlan)
7548 action_nvgre_encap_data->items[1].type =
7549 RTE_FLOW_ITEM_TYPE_VOID;
7550 memcpy(action_nvgre_encap_data->item_nvgre.tni, nvgre_encap_conf.tni,
7551 RTE_DIM(nvgre_encap_conf.tni));
7555 /** Parse NVGRE encap action. */
7557 parse_vc_action_nvgre_encap(struct context *ctx, const struct token *token,
7558 const char *str, unsigned int len,
7559 void *buf, unsigned int size)
7561 struct buffer *out = buf;
7562 struct rte_flow_action *action;
7563 struct action_nvgre_encap_data *action_nvgre_encap_data;
7566 ret = parse_vc(ctx, token, str, len, buf, size);
7569 /* Nothing else to do if there is no buffer. */
7572 if (!out->args.vc.actions_n)
7574 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
7575 /* Point to selected object. */
7576 ctx->object = out->args.vc.data;
7577 ctx->objmask = NULL;
7578 action_nvgre_encap_data = ctx->object;
7579 parse_setup_nvgre_encap_data(action_nvgre_encap_data);
7580 action->conf = &action_nvgre_encap_data->conf;
7584 /** Parse l2 encap action. */
7586 parse_vc_action_l2_encap(struct context *ctx, const struct token *token,
7587 const char *str, unsigned int len,
7588 void *buf, unsigned int size)
7590 struct buffer *out = buf;
7591 struct rte_flow_action *action;
7592 struct action_raw_encap_data *action_encap_data;
7593 struct rte_flow_item_eth eth = { .type = 0, };
7594 struct rte_flow_item_vlan vlan = {
7595 .tci = mplsoudp_encap_conf.vlan_tci,
7601 ret = parse_vc(ctx, token, str, len, buf, size);
7604 /* Nothing else to do if there is no buffer. */
7607 if (!out->args.vc.actions_n)
7609 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
7610 /* Point to selected object. */
7611 ctx->object = out->args.vc.data;
7612 ctx->objmask = NULL;
7613 /* Copy the headers to the buffer. */
7614 action_encap_data = ctx->object;
7615 *action_encap_data = (struct action_raw_encap_data) {
7616 .conf = (struct rte_flow_action_raw_encap){
7617 .data = action_encap_data->data,
7621 header = action_encap_data->data;
7622 if (l2_encap_conf.select_vlan)
7623 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
7624 else if (l2_encap_conf.select_ipv4)
7625 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
7627 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
7628 memcpy(eth.dst.addr_bytes,
7629 l2_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
7630 memcpy(eth.src.addr_bytes,
7631 l2_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
7632 memcpy(header, ð, sizeof(eth));
7633 header += sizeof(eth);
7634 if (l2_encap_conf.select_vlan) {
7635 if (l2_encap_conf.select_ipv4)
7636 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
7638 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
7639 memcpy(header, &vlan, sizeof(vlan));
7640 header += sizeof(vlan);
7642 action_encap_data->conf.size = header -
7643 action_encap_data->data;
7644 action->conf = &action_encap_data->conf;
7648 /** Parse l2 decap action. */
7650 parse_vc_action_l2_decap(struct context *ctx, const struct token *token,
7651 const char *str, unsigned int len,
7652 void *buf, unsigned int size)
7654 struct buffer *out = buf;
7655 struct rte_flow_action *action;
7656 struct action_raw_decap_data *action_decap_data;
7657 struct rte_flow_item_eth eth = { .type = 0, };
7658 struct rte_flow_item_vlan vlan = {
7659 .tci = mplsoudp_encap_conf.vlan_tci,
7665 ret = parse_vc(ctx, token, str, len, buf, size);
7668 /* Nothing else to do if there is no buffer. */
7671 if (!out->args.vc.actions_n)
7673 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
7674 /* Point to selected object. */
7675 ctx->object = out->args.vc.data;
7676 ctx->objmask = NULL;
7677 /* Copy the headers to the buffer. */
7678 action_decap_data = ctx->object;
7679 *action_decap_data = (struct action_raw_decap_data) {
7680 .conf = (struct rte_flow_action_raw_decap){
7681 .data = action_decap_data->data,
7685 header = action_decap_data->data;
7686 if (l2_decap_conf.select_vlan)
7687 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
7688 memcpy(header, ð, sizeof(eth));
7689 header += sizeof(eth);
7690 if (l2_decap_conf.select_vlan) {
7691 memcpy(header, &vlan, sizeof(vlan));
7692 header += sizeof(vlan);
7694 action_decap_data->conf.size = header -
7695 action_decap_data->data;
7696 action->conf = &action_decap_data->conf;
7700 #define ETHER_TYPE_MPLS_UNICAST 0x8847
7702 /** Parse MPLSOGRE encap action. */
7704 parse_vc_action_mplsogre_encap(struct context *ctx, const struct token *token,
7705 const char *str, unsigned int len,
7706 void *buf, unsigned int size)
7708 struct buffer *out = buf;
7709 struct rte_flow_action *action;
7710 struct action_raw_encap_data *action_encap_data;
7711 struct rte_flow_item_eth eth = { .type = 0, };
7712 struct rte_flow_item_vlan vlan = {
7713 .tci = mplsogre_encap_conf.vlan_tci,
7716 struct rte_flow_item_ipv4 ipv4 = {
7718 .src_addr = mplsogre_encap_conf.ipv4_src,
7719 .dst_addr = mplsogre_encap_conf.ipv4_dst,
7720 .next_proto_id = IPPROTO_GRE,
7721 .version_ihl = RTE_IPV4_VHL_DEF,
7722 .time_to_live = IPDEFTTL,
7725 struct rte_flow_item_ipv6 ipv6 = {
7727 .proto = IPPROTO_GRE,
7728 .hop_limits = IPDEFTTL,
7731 struct rte_flow_item_gre gre = {
7732 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
7734 struct rte_flow_item_mpls mpls = {
7740 ret = parse_vc(ctx, token, str, len, buf, size);
7743 /* Nothing else to do if there is no buffer. */
7746 if (!out->args.vc.actions_n)
7748 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
7749 /* Point to selected object. */
7750 ctx->object = out->args.vc.data;
7751 ctx->objmask = NULL;
7752 /* Copy the headers to the buffer. */
7753 action_encap_data = ctx->object;
7754 *action_encap_data = (struct action_raw_encap_data) {
7755 .conf = (struct rte_flow_action_raw_encap){
7756 .data = action_encap_data->data,
7761 header = action_encap_data->data;
7762 if (mplsogre_encap_conf.select_vlan)
7763 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
7764 else if (mplsogre_encap_conf.select_ipv4)
7765 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
7767 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
7768 memcpy(eth.dst.addr_bytes,
7769 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
7770 memcpy(eth.src.addr_bytes,
7771 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
7772 memcpy(header, ð, sizeof(eth));
7773 header += sizeof(eth);
7774 if (mplsogre_encap_conf.select_vlan) {
7775 if (mplsogre_encap_conf.select_ipv4)
7776 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
7778 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
7779 memcpy(header, &vlan, sizeof(vlan));
7780 header += sizeof(vlan);
7782 if (mplsogre_encap_conf.select_ipv4) {
7783 memcpy(header, &ipv4, sizeof(ipv4));
7784 header += sizeof(ipv4);
7786 memcpy(&ipv6.hdr.src_addr,
7787 &mplsogre_encap_conf.ipv6_src,
7788 sizeof(mplsogre_encap_conf.ipv6_src));
7789 memcpy(&ipv6.hdr.dst_addr,
7790 &mplsogre_encap_conf.ipv6_dst,
7791 sizeof(mplsogre_encap_conf.ipv6_dst));
7792 memcpy(header, &ipv6, sizeof(ipv6));
7793 header += sizeof(ipv6);
7795 memcpy(header, &gre, sizeof(gre));
7796 header += sizeof(gre);
7797 memcpy(mpls.label_tc_s, mplsogre_encap_conf.label,
7798 RTE_DIM(mplsogre_encap_conf.label));
7799 mpls.label_tc_s[2] |= 0x1;
7800 memcpy(header, &mpls, sizeof(mpls));
7801 header += sizeof(mpls);
7802 action_encap_data->conf.size = header -
7803 action_encap_data->data;
7804 action->conf = &action_encap_data->conf;
7808 /** Parse MPLSOGRE decap action. */
7810 parse_vc_action_mplsogre_decap(struct context *ctx, const struct token *token,
7811 const char *str, unsigned int len,
7812 void *buf, unsigned int size)
7814 struct buffer *out = buf;
7815 struct rte_flow_action *action;
7816 struct action_raw_decap_data *action_decap_data;
7817 struct rte_flow_item_eth eth = { .type = 0, };
7818 struct rte_flow_item_vlan vlan = {.tci = 0};
7819 struct rte_flow_item_ipv4 ipv4 = {
7821 .next_proto_id = IPPROTO_GRE,
7824 struct rte_flow_item_ipv6 ipv6 = {
7826 .proto = IPPROTO_GRE,
7829 struct rte_flow_item_gre gre = {
7830 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
7832 struct rte_flow_item_mpls mpls;
7836 ret = parse_vc(ctx, token, str, len, buf, size);
7839 /* Nothing else to do if there is no buffer. */
7842 if (!out->args.vc.actions_n)
7844 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
7845 /* Point to selected object. */
7846 ctx->object = out->args.vc.data;
7847 ctx->objmask = NULL;
7848 /* Copy the headers to the buffer. */
7849 action_decap_data = ctx->object;
7850 *action_decap_data = (struct action_raw_decap_data) {
7851 .conf = (struct rte_flow_action_raw_decap){
7852 .data = action_decap_data->data,
7856 header = action_decap_data->data;
7857 if (mplsogre_decap_conf.select_vlan)
7858 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
7859 else if (mplsogre_encap_conf.select_ipv4)
7860 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
7862 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
7863 memcpy(eth.dst.addr_bytes,
7864 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
7865 memcpy(eth.src.addr_bytes,
7866 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
7867 memcpy(header, ð, sizeof(eth));
7868 header += sizeof(eth);
7869 if (mplsogre_encap_conf.select_vlan) {
7870 if (mplsogre_encap_conf.select_ipv4)
7871 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
7873 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
7874 memcpy(header, &vlan, sizeof(vlan));
7875 header += sizeof(vlan);
7877 if (mplsogre_encap_conf.select_ipv4) {
7878 memcpy(header, &ipv4, sizeof(ipv4));
7879 header += sizeof(ipv4);
7881 memcpy(header, &ipv6, sizeof(ipv6));
7882 header += sizeof(ipv6);
7884 memcpy(header, &gre, sizeof(gre));
7885 header += sizeof(gre);
7886 memset(&mpls, 0, sizeof(mpls));
7887 memcpy(header, &mpls, sizeof(mpls));
7888 header += sizeof(mpls);
7889 action_decap_data->conf.size = header -
7890 action_decap_data->data;
7891 action->conf = &action_decap_data->conf;
7895 /** Parse MPLSOUDP encap action. */
7897 parse_vc_action_mplsoudp_encap(struct context *ctx, const struct token *token,
7898 const char *str, unsigned int len,
7899 void *buf, unsigned int size)
7901 struct buffer *out = buf;
7902 struct rte_flow_action *action;
7903 struct action_raw_encap_data *action_encap_data;
7904 struct rte_flow_item_eth eth = { .type = 0, };
7905 struct rte_flow_item_vlan vlan = {
7906 .tci = mplsoudp_encap_conf.vlan_tci,
7909 struct rte_flow_item_ipv4 ipv4 = {
7911 .src_addr = mplsoudp_encap_conf.ipv4_src,
7912 .dst_addr = mplsoudp_encap_conf.ipv4_dst,
7913 .next_proto_id = IPPROTO_UDP,
7914 .version_ihl = RTE_IPV4_VHL_DEF,
7915 .time_to_live = IPDEFTTL,
7918 struct rte_flow_item_ipv6 ipv6 = {
7920 .proto = IPPROTO_UDP,
7921 .hop_limits = IPDEFTTL,
7924 struct rte_flow_item_udp udp = {
7926 .src_port = mplsoudp_encap_conf.udp_src,
7927 .dst_port = mplsoudp_encap_conf.udp_dst,
7930 struct rte_flow_item_mpls mpls;
7934 ret = parse_vc(ctx, token, str, len, buf, size);
7937 /* Nothing else to do if there is no buffer. */
7940 if (!out->args.vc.actions_n)
7942 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
7943 /* Point to selected object. */
7944 ctx->object = out->args.vc.data;
7945 ctx->objmask = NULL;
7946 /* Copy the headers to the buffer. */
7947 action_encap_data = ctx->object;
7948 *action_encap_data = (struct action_raw_encap_data) {
7949 .conf = (struct rte_flow_action_raw_encap){
7950 .data = action_encap_data->data,
7955 header = action_encap_data->data;
7956 if (mplsoudp_encap_conf.select_vlan)
7957 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
7958 else if (mplsoudp_encap_conf.select_ipv4)
7959 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
7961 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
7962 memcpy(eth.dst.addr_bytes,
7963 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
7964 memcpy(eth.src.addr_bytes,
7965 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
7966 memcpy(header, ð, sizeof(eth));
7967 header += sizeof(eth);
7968 if (mplsoudp_encap_conf.select_vlan) {
7969 if (mplsoudp_encap_conf.select_ipv4)
7970 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
7972 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
7973 memcpy(header, &vlan, sizeof(vlan));
7974 header += sizeof(vlan);
7976 if (mplsoudp_encap_conf.select_ipv4) {
7977 memcpy(header, &ipv4, sizeof(ipv4));
7978 header += sizeof(ipv4);
7980 memcpy(&ipv6.hdr.src_addr,
7981 &mplsoudp_encap_conf.ipv6_src,
7982 sizeof(mplsoudp_encap_conf.ipv6_src));
7983 memcpy(&ipv6.hdr.dst_addr,
7984 &mplsoudp_encap_conf.ipv6_dst,
7985 sizeof(mplsoudp_encap_conf.ipv6_dst));
7986 memcpy(header, &ipv6, sizeof(ipv6));
7987 header += sizeof(ipv6);
7989 memcpy(header, &udp, sizeof(udp));
7990 header += sizeof(udp);
7991 memcpy(mpls.label_tc_s, mplsoudp_encap_conf.label,
7992 RTE_DIM(mplsoudp_encap_conf.label));
7993 mpls.label_tc_s[2] |= 0x1;
7994 memcpy(header, &mpls, sizeof(mpls));
7995 header += sizeof(mpls);
7996 action_encap_data->conf.size = header -
7997 action_encap_data->data;
7998 action->conf = &action_encap_data->conf;
8002 /** Parse MPLSOUDP decap action. */
8004 parse_vc_action_mplsoudp_decap(struct context *ctx, const struct token *token,
8005 const char *str, unsigned int len,
8006 void *buf, unsigned int size)
8008 struct buffer *out = buf;
8009 struct rte_flow_action *action;
8010 struct action_raw_decap_data *action_decap_data;
8011 struct rte_flow_item_eth eth = { .type = 0, };
8012 struct rte_flow_item_vlan vlan = {.tci = 0};
8013 struct rte_flow_item_ipv4 ipv4 = {
8015 .next_proto_id = IPPROTO_UDP,
8018 struct rte_flow_item_ipv6 ipv6 = {
8020 .proto = IPPROTO_UDP,
8023 struct rte_flow_item_udp udp = {
8025 .dst_port = rte_cpu_to_be_16(6635),
8028 struct rte_flow_item_mpls mpls;
8032 ret = parse_vc(ctx, token, str, len, buf, size);
8035 /* Nothing else to do if there is no buffer. */
8038 if (!out->args.vc.actions_n)
8040 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
8041 /* Point to selected object. */
8042 ctx->object = out->args.vc.data;
8043 ctx->objmask = NULL;
8044 /* Copy the headers to the buffer. */
8045 action_decap_data = ctx->object;
8046 *action_decap_data = (struct action_raw_decap_data) {
8047 .conf = (struct rte_flow_action_raw_decap){
8048 .data = action_decap_data->data,
8052 header = action_decap_data->data;
8053 if (mplsoudp_decap_conf.select_vlan)
8054 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
8055 else if (mplsoudp_encap_conf.select_ipv4)
8056 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
8058 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
8059 memcpy(eth.dst.addr_bytes,
8060 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
8061 memcpy(eth.src.addr_bytes,
8062 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
8063 memcpy(header, ð, sizeof(eth));
8064 header += sizeof(eth);
8065 if (mplsoudp_encap_conf.select_vlan) {
8066 if (mplsoudp_encap_conf.select_ipv4)
8067 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
8069 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
8070 memcpy(header, &vlan, sizeof(vlan));
8071 header += sizeof(vlan);
8073 if (mplsoudp_encap_conf.select_ipv4) {
8074 memcpy(header, &ipv4, sizeof(ipv4));
8075 header += sizeof(ipv4);
8077 memcpy(header, &ipv6, sizeof(ipv6));
8078 header += sizeof(ipv6);
8080 memcpy(header, &udp, sizeof(udp));
8081 header += sizeof(udp);
8082 memset(&mpls, 0, sizeof(mpls));
8083 memcpy(header, &mpls, sizeof(mpls));
8084 header += sizeof(mpls);
8085 action_decap_data->conf.size = header -
8086 action_decap_data->data;
8087 action->conf = &action_decap_data->conf;
8092 parse_vc_action_raw_decap_index(struct context *ctx, const struct token *token,
8093 const char *str, unsigned int len, void *buf,
8096 struct action_raw_decap_data *action_raw_decap_data;
8097 struct rte_flow_action *action;
8098 const struct arg *arg;
8099 struct buffer *out = buf;
8103 RTE_SET_USED(token);
8106 arg = ARGS_ENTRY_ARB_BOUNDED
8107 (offsetof(struct action_raw_decap_data, idx),
8108 sizeof(((struct action_raw_decap_data *)0)->idx),
8109 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
8110 if (push_args(ctx, arg))
8112 ret = parse_int(ctx, token, str, len, NULL, 0);
8119 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
8120 action_raw_decap_data = ctx->object;
8121 idx = action_raw_decap_data->idx;
8122 action_raw_decap_data->conf.data = raw_decap_confs[idx].data;
8123 action_raw_decap_data->conf.size = raw_decap_confs[idx].size;
8124 action->conf = &action_raw_decap_data->conf;
8130 parse_vc_action_raw_encap_index(struct context *ctx, const struct token *token,
8131 const char *str, unsigned int len, void *buf,
8134 struct action_raw_encap_data *action_raw_encap_data;
8135 struct rte_flow_action *action;
8136 const struct arg *arg;
8137 struct buffer *out = buf;
8141 RTE_SET_USED(token);
8144 if (ctx->curr != ACTION_RAW_ENCAP_INDEX_VALUE)
8146 arg = ARGS_ENTRY_ARB_BOUNDED
8147 (offsetof(struct action_raw_encap_data, idx),
8148 sizeof(((struct action_raw_encap_data *)0)->idx),
8149 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
8150 if (push_args(ctx, arg))
8152 ret = parse_int(ctx, token, str, len, NULL, 0);
8159 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
8160 action_raw_encap_data = ctx->object;
8161 idx = action_raw_encap_data->idx;
8162 action_raw_encap_data->conf.data = raw_encap_confs[idx].data;
8163 action_raw_encap_data->conf.size = raw_encap_confs[idx].size;
8164 action_raw_encap_data->conf.preserve = NULL;
8165 action->conf = &action_raw_encap_data->conf;
8170 parse_vc_action_raw_encap(struct context *ctx, const struct token *token,
8171 const char *str, unsigned int len, void *buf,
8174 struct buffer *out = buf;
8175 struct rte_flow_action *action;
8176 struct action_raw_encap_data *action_raw_encap_data = NULL;
8179 ret = parse_vc(ctx, token, str, len, buf, size);
8182 /* Nothing else to do if there is no buffer. */
8185 if (!out->args.vc.actions_n)
8187 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
8188 /* Point to selected object. */
8189 ctx->object = out->args.vc.data;
8190 ctx->objmask = NULL;
8191 /* Copy the headers to the buffer. */
8192 action_raw_encap_data = ctx->object;
8193 action_raw_encap_data->conf.data = raw_encap_confs[0].data;
8194 action_raw_encap_data->conf.preserve = NULL;
8195 action_raw_encap_data->conf.size = raw_encap_confs[0].size;
8196 action->conf = &action_raw_encap_data->conf;
8201 parse_vc_action_raw_decap(struct context *ctx, const struct token *token,
8202 const char *str, unsigned int len, void *buf,
8205 struct buffer *out = buf;
8206 struct rte_flow_action *action;
8207 struct action_raw_decap_data *action_raw_decap_data = NULL;
8210 ret = parse_vc(ctx, token, str, len, buf, size);
8213 /* Nothing else to do if there is no buffer. */
8216 if (!out->args.vc.actions_n)
8218 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
8219 /* Point to selected object. */
8220 ctx->object = out->args.vc.data;
8221 ctx->objmask = NULL;
8222 /* Copy the headers to the buffer. */
8223 action_raw_decap_data = ctx->object;
8224 action_raw_decap_data->conf.data = raw_decap_confs[0].data;
8225 action_raw_decap_data->conf.size = raw_decap_confs[0].size;
8226 action->conf = &action_raw_decap_data->conf;
8231 parse_vc_action_set_meta(struct context *ctx, const struct token *token,
8232 const char *str, unsigned int len, void *buf,
8237 ret = parse_vc(ctx, token, str, len, buf, size);
8240 ret = rte_flow_dynf_metadata_register();
8247 parse_vc_action_sample(struct context *ctx, const struct token *token,
8248 const char *str, unsigned int len, void *buf,
8251 struct buffer *out = buf;
8252 struct rte_flow_action *action;
8253 struct action_sample_data *action_sample_data = NULL;
8254 static struct rte_flow_action end_action = {
8255 RTE_FLOW_ACTION_TYPE_END, 0
8259 ret = parse_vc(ctx, token, str, len, buf, size);
8262 /* Nothing else to do if there is no buffer. */
8265 if (!out->args.vc.actions_n)
8267 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
8268 /* Point to selected object. */
8269 ctx->object = out->args.vc.data;
8270 ctx->objmask = NULL;
8271 /* Copy the headers to the buffer. */
8272 action_sample_data = ctx->object;
8273 action_sample_data->conf.actions = &end_action;
8274 action->conf = &action_sample_data->conf;
8279 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
8280 const char *str, unsigned int len, void *buf,
8283 struct action_sample_data *action_sample_data;
8284 struct rte_flow_action *action;
8285 const struct arg *arg;
8286 struct buffer *out = buf;
8290 RTE_SET_USED(token);
8293 if (ctx->curr != ACTION_SAMPLE_INDEX_VALUE)
8295 arg = ARGS_ENTRY_ARB_BOUNDED
8296 (offsetof(struct action_sample_data, idx),
8297 sizeof(((struct action_sample_data *)0)->idx),
8298 0, RAW_SAMPLE_CONFS_MAX_NUM - 1);
8299 if (push_args(ctx, arg))
8301 ret = parse_int(ctx, token, str, len, NULL, 0);
8308 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
8309 action_sample_data = ctx->object;
8310 idx = action_sample_data->idx;
8311 action_sample_data->conf.actions = raw_sample_confs[idx].data;
8312 action->conf = &action_sample_data->conf;
8316 /** Parse operation for modify_field command. */
8318 parse_vc_modify_field_op(struct context *ctx, const struct token *token,
8319 const char *str, unsigned int len, void *buf,
8322 struct rte_flow_action_modify_field *action_modify_field;
8328 if (ctx->curr != ACTION_MODIFY_FIELD_OP_VALUE)
8330 for (i = 0; modify_field_ops[i]; ++i)
8331 if (!strcmp_partial(modify_field_ops[i], str, len))
8333 if (!modify_field_ops[i])
8337 action_modify_field = ctx->object;
8338 action_modify_field->operation = (enum rte_flow_modify_op)i;
8342 /** Parse id for modify_field command. */
8344 parse_vc_modify_field_id(struct context *ctx, const struct token *token,
8345 const char *str, unsigned int len, void *buf,
8348 struct rte_flow_action_modify_field *action_modify_field;
8354 if (ctx->curr != ACTION_MODIFY_FIELD_DST_TYPE_VALUE &&
8355 ctx->curr != ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)
8357 for (i = 0; modify_field_ids[i]; ++i)
8358 if (!strcmp_partial(modify_field_ids[i], str, len))
8360 if (!modify_field_ids[i])
8364 action_modify_field = ctx->object;
8365 if (ctx->curr == ACTION_MODIFY_FIELD_DST_TYPE_VALUE)
8366 action_modify_field->dst.field = (enum rte_flow_field_id)i;
8368 action_modify_field->src.field = (enum rte_flow_field_id)i;
8372 /** Parse the conntrack update, not a rte_flow_action. */
8374 parse_vc_action_conntrack_update(struct context *ctx, const struct token *token,
8375 const char *str, unsigned int len, void *buf,
8378 struct buffer *out = buf;
8379 struct rte_flow_modify_conntrack *ct_modify = NULL;
8382 if (ctx->curr != ACTION_CONNTRACK_UPDATE_CTX &&
8383 ctx->curr != ACTION_CONNTRACK_UPDATE_DIR)
8385 /* Token name must match. */
8386 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8388 /* Nothing else to do if there is no buffer. */
8391 ct_modify = (struct rte_flow_modify_conntrack *)out->args.vc.data;
8392 if (ctx->curr == ACTION_CONNTRACK_UPDATE_DIR) {
8393 ct_modify->new_ct.is_original_dir =
8394 conntrack_context.is_original_dir;
8395 ct_modify->direction = 1;
8399 old_dir = ct_modify->new_ct.is_original_dir;
8400 memcpy(&ct_modify->new_ct, &conntrack_context,
8401 sizeof(conntrack_context));
8402 ct_modify->new_ct.is_original_dir = old_dir;
8403 ct_modify->state = 1;
8408 /** Parse tokens for destroy command. */
8410 parse_destroy(struct context *ctx, const struct token *token,
8411 const char *str, unsigned int len,
8412 void *buf, unsigned int size)
8414 struct buffer *out = buf;
8416 /* Token name must match. */
8417 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8419 /* Nothing else to do if there is no buffer. */
8422 if (!out->command) {
8423 if (ctx->curr != DESTROY)
8425 if (sizeof(*out) > size)
8427 out->command = ctx->curr;
8430 ctx->objmask = NULL;
8431 out->args.destroy.rule =
8432 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8436 if (((uint8_t *)(out->args.destroy.rule + out->args.destroy.rule_n) +
8437 sizeof(*out->args.destroy.rule)) > (uint8_t *)out + size)
8440 ctx->object = out->args.destroy.rule + out->args.destroy.rule_n++;
8441 ctx->objmask = NULL;
8445 /** Parse tokens for flush command. */
8447 parse_flush(struct context *ctx, const struct token *token,
8448 const char *str, unsigned int len,
8449 void *buf, unsigned int size)
8451 struct buffer *out = buf;
8453 /* Token name must match. */
8454 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8456 /* Nothing else to do if there is no buffer. */
8459 if (!out->command) {
8460 if (ctx->curr != FLUSH)
8462 if (sizeof(*out) > size)
8464 out->command = ctx->curr;
8467 ctx->objmask = NULL;
8472 /** Parse tokens for dump command. */
8474 parse_dump(struct context *ctx, const struct token *token,
8475 const char *str, unsigned int len,
8476 void *buf, unsigned int size)
8478 struct buffer *out = buf;
8480 /* Token name must match. */
8481 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8483 /* Nothing else to do if there is no buffer. */
8486 if (!out->command) {
8487 if (ctx->curr != DUMP)
8489 if (sizeof(*out) > size)
8491 out->command = ctx->curr;
8494 ctx->objmask = NULL;
8497 switch (ctx->curr) {
8500 out->args.dump.mode = (ctx->curr == DUMP_ALL) ? true : false;
8501 out->command = ctx->curr;
8504 ctx->objmask = NULL;
8511 /** Parse tokens for query command. */
8513 parse_query(struct context *ctx, const struct token *token,
8514 const char *str, unsigned int len,
8515 void *buf, unsigned int size)
8517 struct buffer *out = buf;
8519 /* Token name must match. */
8520 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8522 /* Nothing else to do if there is no buffer. */
8525 if (!out->command) {
8526 if (ctx->curr != QUERY)
8528 if (sizeof(*out) > size)
8530 out->command = ctx->curr;
8533 ctx->objmask = NULL;
8538 /** Parse action names. */
8540 parse_action(struct context *ctx, const struct token *token,
8541 const char *str, unsigned int len,
8542 void *buf, unsigned int size)
8544 struct buffer *out = buf;
8545 const struct arg *arg = pop_args(ctx);
8549 /* Argument is expected. */
8552 /* Parse action name. */
8553 for (i = 0; next_action[i]; ++i) {
8554 const struct parse_action_priv *priv;
8556 token = &token_list[next_action[i]];
8557 if (strcmp_partial(token->name, str, len))
8563 memcpy((uint8_t *)ctx->object + arg->offset,
8569 push_args(ctx, arg);
8573 /** Parse tokens for list command. */
8575 parse_list(struct context *ctx, const struct token *token,
8576 const char *str, unsigned int len,
8577 void *buf, unsigned int size)
8579 struct buffer *out = buf;
8581 /* Token name must match. */
8582 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8584 /* Nothing else to do if there is no buffer. */
8587 if (!out->command) {
8588 if (ctx->curr != LIST)
8590 if (sizeof(*out) > size)
8592 out->command = ctx->curr;
8595 ctx->objmask = NULL;
8596 out->args.list.group =
8597 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8601 if (((uint8_t *)(out->args.list.group + out->args.list.group_n) +
8602 sizeof(*out->args.list.group)) > (uint8_t *)out + size)
8605 ctx->object = out->args.list.group + out->args.list.group_n++;
8606 ctx->objmask = NULL;
8610 /** Parse tokens for list all aged flows command. */
8612 parse_aged(struct context *ctx, const struct token *token,
8613 const char *str, unsigned int len,
8614 void *buf, unsigned int size)
8616 struct buffer *out = buf;
8618 /* Token name must match. */
8619 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8621 /* Nothing else to do if there is no buffer. */
8624 if (!out->command) {
8625 if (ctx->curr != AGED)
8627 if (sizeof(*out) > size)
8629 out->command = ctx->curr;
8632 ctx->objmask = NULL;
8634 if (ctx->curr == AGED_DESTROY)
8635 out->args.aged.destroy = 1;
8639 /** Parse tokens for isolate command. */
8641 parse_isolate(struct context *ctx, const struct token *token,
8642 const char *str, unsigned int len,
8643 void *buf, unsigned int size)
8645 struct buffer *out = buf;
8647 /* Token name must match. */
8648 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8650 /* Nothing else to do if there is no buffer. */
8653 if (!out->command) {
8654 if (ctx->curr != ISOLATE)
8656 if (sizeof(*out) > size)
8658 out->command = ctx->curr;
8661 ctx->objmask = NULL;
8666 /** Parse tokens for info/configure command. */
8668 parse_configure(struct context *ctx, const struct token *token,
8669 const char *str, unsigned int len,
8670 void *buf, unsigned int size)
8672 struct buffer *out = buf;
8674 /* Token name must match. */
8675 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8677 /* Nothing else to do if there is no buffer. */
8680 if (!out->command) {
8681 if (ctx->curr != INFO && ctx->curr != CONFIGURE)
8683 if (sizeof(*out) > size)
8685 out->command = ctx->curr;
8688 ctx->objmask = NULL;
8693 /** Parse tokens for template create command. */
8695 parse_template(struct context *ctx, const struct token *token,
8696 const char *str, unsigned int len,
8697 void *buf, unsigned int size)
8699 struct buffer *out = buf;
8701 /* Token name must match. */
8702 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8704 /* Nothing else to do if there is no buffer. */
8707 if (!out->command) {
8708 if (ctx->curr != PATTERN_TEMPLATE &&
8709 ctx->curr != ACTIONS_TEMPLATE)
8711 if (sizeof(*out) > size)
8713 out->command = ctx->curr;
8716 ctx->objmask = NULL;
8717 out->args.vc.data = (uint8_t *)out + size;
8720 switch (ctx->curr) {
8721 case PATTERN_TEMPLATE_CREATE:
8722 out->args.vc.pattern =
8723 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8725 out->args.vc.pat_templ_id = UINT32_MAX;
8726 out->command = ctx->curr;
8729 ctx->objmask = NULL;
8731 case PATTERN_TEMPLATE_EGRESS:
8732 out->args.vc.attr.egress = 1;
8734 case PATTERN_TEMPLATE_INGRESS:
8735 out->args.vc.attr.ingress = 1;
8737 case PATTERN_TEMPLATE_TRANSFER:
8738 out->args.vc.attr.transfer = 1;
8740 case ACTIONS_TEMPLATE_CREATE:
8741 out->args.vc.act_templ_id = UINT32_MAX;
8742 out->command = ctx->curr;
8745 ctx->objmask = NULL;
8747 case ACTIONS_TEMPLATE_SPEC:
8748 out->args.vc.actions =
8749 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8751 ctx->object = out->args.vc.actions;
8752 ctx->objmask = NULL;
8754 case ACTIONS_TEMPLATE_MASK:
8755 out->args.vc.masks =
8756 (void *)RTE_ALIGN_CEIL((uintptr_t)
8757 (out->args.vc.actions +
8758 out->args.vc.actions_n),
8760 ctx->object = out->args.vc.masks;
8761 ctx->objmask = NULL;
8763 case ACTIONS_TEMPLATE_EGRESS:
8764 out->args.vc.attr.egress = 1;
8766 case ACTIONS_TEMPLATE_INGRESS:
8767 out->args.vc.attr.ingress = 1;
8769 case ACTIONS_TEMPLATE_TRANSFER:
8770 out->args.vc.attr.transfer = 1;
8777 /** Parse tokens for template destroy command. */
8779 parse_template_destroy(struct context *ctx, const struct token *token,
8780 const char *str, unsigned int len,
8781 void *buf, unsigned int size)
8783 struct buffer *out = buf;
8784 uint32_t *template_id;
8786 /* Token name must match. */
8787 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8789 /* Nothing else to do if there is no buffer. */
8792 if (!out->command ||
8793 out->command == PATTERN_TEMPLATE ||
8794 out->command == ACTIONS_TEMPLATE) {
8795 if (ctx->curr != PATTERN_TEMPLATE_DESTROY &&
8796 ctx->curr != ACTIONS_TEMPLATE_DESTROY)
8798 if (sizeof(*out) > size)
8800 out->command = ctx->curr;
8803 ctx->objmask = NULL;
8804 out->args.templ_destroy.template_id =
8805 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8809 template_id = out->args.templ_destroy.template_id
8810 + out->args.templ_destroy.template_id_n++;
8811 if ((uint8_t *)template_id > (uint8_t *)out + size)
8814 ctx->object = template_id;
8815 ctx->objmask = NULL;
8819 /** Parse tokens for table create command. */
8821 parse_table(struct context *ctx, const struct token *token,
8822 const char *str, unsigned int len,
8823 void *buf, unsigned int size)
8825 struct buffer *out = buf;
8826 uint32_t *template_id;
8828 /* Token name must match. */
8829 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8831 /* Nothing else to do if there is no buffer. */
8834 if (!out->command) {
8835 if (ctx->curr != TABLE)
8837 if (sizeof(*out) > size)
8839 out->command = ctx->curr;
8842 ctx->objmask = NULL;
8845 switch (ctx->curr) {
8847 out->command = ctx->curr;
8850 ctx->objmask = NULL;
8851 out->args.table.id = UINT32_MAX;
8853 case TABLE_PATTERN_TEMPLATE:
8854 out->args.table.pat_templ_id =
8855 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8857 template_id = out->args.table.pat_templ_id
8858 + out->args.table.pat_templ_id_n++;
8859 if ((uint8_t *)template_id > (uint8_t *)out + size)
8862 ctx->object = template_id;
8863 ctx->objmask = NULL;
8865 case TABLE_ACTIONS_TEMPLATE:
8866 out->args.table.act_templ_id =
8867 (void *)RTE_ALIGN_CEIL((uintptr_t)
8868 (out->args.table.pat_templ_id +
8869 out->args.table.pat_templ_id_n),
8871 template_id = out->args.table.act_templ_id
8872 + out->args.table.act_templ_id_n++;
8873 if ((uint8_t *)template_id > (uint8_t *)out + size)
8876 ctx->object = template_id;
8877 ctx->objmask = NULL;
8880 out->args.table.attr.flow_attr.ingress = 1;
8883 out->args.table.attr.flow_attr.egress = 1;
8885 case TABLE_TRANSFER:
8886 out->args.table.attr.flow_attr.transfer = 1;
8893 /** Parse tokens for table destroy command. */
8895 parse_table_destroy(struct context *ctx, const struct token *token,
8896 const char *str, unsigned int len,
8897 void *buf, unsigned int size)
8899 struct buffer *out = buf;
8902 /* Token name must match. */
8903 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8905 /* Nothing else to do if there is no buffer. */
8908 if (!out->command || out->command == TABLE) {
8909 if (ctx->curr != TABLE_DESTROY)
8911 if (sizeof(*out) > size)
8913 out->command = ctx->curr;
8916 ctx->objmask = NULL;
8917 out->args.table_destroy.table_id =
8918 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8922 table_id = out->args.table_destroy.table_id
8923 + out->args.table_destroy.table_id_n++;
8924 if ((uint8_t *)table_id > (uint8_t *)out + size)
8927 ctx->object = table_id;
8928 ctx->objmask = NULL;
8932 /** Parse tokens for queue create commands. */
8934 parse_qo(struct context *ctx, const struct token *token,
8935 const char *str, unsigned int len,
8936 void *buf, unsigned int size)
8938 struct buffer *out = buf;
8940 /* Token name must match. */
8941 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8943 /* Nothing else to do if there is no buffer. */
8946 if (!out->command) {
8947 if (ctx->curr != QUEUE)
8949 if (sizeof(*out) > size)
8951 out->command = ctx->curr;
8954 ctx->objmask = NULL;
8955 out->args.vc.data = (uint8_t *)out + size;
8958 switch (ctx->curr) {
8960 out->command = ctx->curr;
8963 ctx->objmask = NULL;
8965 case QUEUE_TEMPLATE_TABLE:
8966 case QUEUE_PATTERN_TEMPLATE:
8967 case QUEUE_ACTIONS_TEMPLATE:
8968 case QUEUE_CREATE_POSTPONE:
8971 out->args.vc.pattern =
8972 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8974 ctx->object = out->args.vc.pattern;
8975 ctx->objmask = NULL;
8978 out->args.vc.actions =
8979 (void *)RTE_ALIGN_CEIL((uintptr_t)
8980 (out->args.vc.pattern +
8981 out->args.vc.pattern_n),
8983 ctx->object = out->args.vc.actions;
8984 ctx->objmask = NULL;
8991 /** Parse tokens for queue destroy command. */
8993 parse_qo_destroy(struct context *ctx, const struct token *token,
8994 const char *str, unsigned int len,
8995 void *buf, unsigned int size)
8997 struct buffer *out = buf;
9000 /* Token name must match. */
9001 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
9003 /* Nothing else to do if there is no buffer. */
9006 if (!out->command || out->command == QUEUE) {
9007 if (ctx->curr != QUEUE_DESTROY)
9009 if (sizeof(*out) > size)
9011 out->command = ctx->curr;
9014 ctx->objmask = NULL;
9015 out->args.destroy.rule =
9016 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
9020 switch (ctx->curr) {
9021 case QUEUE_DESTROY_ID:
9022 flow_id = out->args.destroy.rule
9023 + out->args.destroy.rule_n++;
9024 if ((uint8_t *)flow_id > (uint8_t *)out + size)
9027 ctx->object = flow_id;
9028 ctx->objmask = NULL;
9030 case QUEUE_DESTROY_POSTPONE:
9037 /** Parse tokens for push queue command. */
9039 parse_push(struct context *ctx, const struct token *token,
9040 const char *str, unsigned int len,
9041 void *buf, unsigned int size)
9043 struct buffer *out = buf;
9045 /* Token name must match. */
9046 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
9048 /* Nothing else to do if there is no buffer. */
9051 if (!out->command) {
9052 if (ctx->curr != PUSH)
9054 if (sizeof(*out) > size)
9056 out->command = ctx->curr;
9059 ctx->objmask = NULL;
9060 out->args.vc.data = (uint8_t *)out + size;
9065 /** Parse tokens for pull command. */
9067 parse_pull(struct context *ctx, const struct token *token,
9068 const char *str, unsigned int len,
9069 void *buf, unsigned int size)
9071 struct buffer *out = buf;
9073 /* Token name must match. */
9074 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
9076 /* Nothing else to do if there is no buffer. */
9079 if (!out->command) {
9080 if (ctx->curr != PULL)
9082 if (sizeof(*out) > size)
9084 out->command = ctx->curr;
9087 ctx->objmask = NULL;
9088 out->args.vc.data = (uint8_t *)out + size;
9094 parse_flex(struct context *ctx, const struct token *token,
9095 const char *str, unsigned int len,
9096 void *buf, unsigned int size)
9098 struct buffer *out = buf;
9100 /* Token name must match. */
9101 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
9103 /* Nothing else to do if there is no buffer. */
9106 if (out->command == ZERO) {
9107 if (ctx->curr != FLEX)
9109 if (sizeof(*out) > size)
9111 out->command = ctx->curr;
9114 ctx->objmask = NULL;
9116 switch (ctx->curr) {
9119 case FLEX_ITEM_INIT:
9120 case FLEX_ITEM_CREATE:
9121 case FLEX_ITEM_DESTROY:
9122 out->command = ctx->curr;
9131 parse_tunnel(struct context *ctx, const struct token *token,
9132 const char *str, unsigned int len,
9133 void *buf, unsigned int size)
9135 struct buffer *out = buf;
9137 /* Token name must match. */
9138 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
9140 /* Nothing else to do if there is no buffer. */
9143 if (!out->command) {
9144 if (ctx->curr != TUNNEL)
9146 if (sizeof(*out) > size)
9148 out->command = ctx->curr;
9151 ctx->objmask = NULL;
9153 switch (ctx->curr) {
9157 case TUNNEL_DESTROY:
9159 out->command = ctx->curr;
9161 case TUNNEL_CREATE_TYPE:
9162 case TUNNEL_DESTROY_ID:
9163 ctx->object = &out->args.vc.tunnel_ops;
9172 * Parse signed/unsigned integers 8 to 64-bit long.
9174 * Last argument (ctx->args) is retrieved to determine integer type and
9178 parse_int(struct context *ctx, const struct token *token,
9179 const char *str, unsigned int len,
9180 void *buf, unsigned int size)
9182 const struct arg *arg = pop_args(ctx);
9187 /* Argument is expected. */
9192 (uintmax_t)strtoimax(str, &end, 0) :
9193 strtoumax(str, &end, 0);
9194 if (errno || (size_t)(end - str) != len)
9197 ((arg->sign && ((intmax_t)u < (intmax_t)arg->min ||
9198 (intmax_t)u > (intmax_t)arg->max)) ||
9199 (!arg->sign && (u < arg->min || u > arg->max))))
9204 if (!arg_entry_bf_fill(ctx->object, u, arg) ||
9205 !arg_entry_bf_fill(ctx->objmask, -1, arg))
9209 buf = (uint8_t *)ctx->object + arg->offset;
9211 if (u > RTE_LEN2MASK(size * CHAR_BIT, uint64_t))
9215 case sizeof(uint8_t):
9216 *(uint8_t *)buf = u;
9218 case sizeof(uint16_t):
9219 *(uint16_t *)buf = arg->hton ? rte_cpu_to_be_16(u) : u;
9221 case sizeof(uint8_t [3]):
9222 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
9224 ((uint8_t *)buf)[0] = u;
9225 ((uint8_t *)buf)[1] = u >> 8;
9226 ((uint8_t *)buf)[2] = u >> 16;
9230 ((uint8_t *)buf)[0] = u >> 16;
9231 ((uint8_t *)buf)[1] = u >> 8;
9232 ((uint8_t *)buf)[2] = u;
9234 case sizeof(uint32_t):
9235 *(uint32_t *)buf = arg->hton ? rte_cpu_to_be_32(u) : u;
9237 case sizeof(uint64_t):
9238 *(uint64_t *)buf = arg->hton ? rte_cpu_to_be_64(u) : u;
9243 if (ctx->objmask && buf != (uint8_t *)ctx->objmask + arg->offset) {
9245 buf = (uint8_t *)ctx->objmask + arg->offset;
9250 push_args(ctx, arg);
9257 * Three arguments (ctx->args) are retrieved from the stack to store data,
9258 * its actual length and address (in that order).
9261 parse_string(struct context *ctx, const struct token *token,
9262 const char *str, unsigned int len,
9263 void *buf, unsigned int size)
9265 const struct arg *arg_data = pop_args(ctx);
9266 const struct arg *arg_len = pop_args(ctx);
9267 const struct arg *arg_addr = pop_args(ctx);
9268 char tmp[16]; /* Ought to be enough. */
9271 /* Arguments are expected. */
9275 push_args(ctx, arg_data);
9279 push_args(ctx, arg_len);
9280 push_args(ctx, arg_data);
9283 size = arg_data->size;
9284 /* Bit-mask fill is not supported. */
9285 if (arg_data->mask || size < len)
9289 /* Let parse_int() fill length information first. */
9290 ret = snprintf(tmp, sizeof(tmp), "%u", len);
9293 push_args(ctx, arg_len);
9294 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
9299 buf = (uint8_t *)ctx->object + arg_data->offset;
9300 /* Output buffer is not necessarily NUL-terminated. */
9301 memcpy(buf, str, len);
9302 memset((uint8_t *)buf + len, 0x00, size - len);
9304 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
9305 /* Save address if requested. */
9306 if (arg_addr->size) {
9307 memcpy((uint8_t *)ctx->object + arg_addr->offset,
9309 (uint8_t *)ctx->object + arg_data->offset
9313 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
9315 (uint8_t *)ctx->objmask + arg_data->offset
9321 push_args(ctx, arg_addr);
9322 push_args(ctx, arg_len);
9323 push_args(ctx, arg_data);
9328 parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
9330 const uint8_t *head = dst;
9333 /* Check input parameters */
9334 if ((src == NULL) ||
9342 /* Convert chars to bytes */
9344 char tmp[3], *end = tmp;
9345 uint32_t read_lim = left & 1 ? 1 : 2;
9347 snprintf(tmp, read_lim + 1, "%s", src);
9348 *dst = strtoul(tmp, &end, 16);
9351 *size = (uint32_t)(dst - head);
9359 *size = (uint32_t)(dst - head);
9364 parse_hex(struct context *ctx, const struct token *token,
9365 const char *str, unsigned int len,
9366 void *buf, unsigned int size)
9368 const struct arg *arg_data = pop_args(ctx);
9369 const struct arg *arg_len = pop_args(ctx);
9370 const struct arg *arg_addr = pop_args(ctx);
9371 char tmp[16]; /* Ought to be enough. */
9373 unsigned int hexlen = len;
9374 unsigned int length = 256;
9375 uint8_t hex_tmp[length];
9377 /* Arguments are expected. */
9381 push_args(ctx, arg_data);
9385 push_args(ctx, arg_len);
9386 push_args(ctx, arg_data);
9389 size = arg_data->size;
9390 /* Bit-mask fill is not supported. */
9396 /* translate bytes string to array. */
9397 if (str[0] == '0' && ((str[1] == 'x') ||
9402 if (hexlen > length)
9404 ret = parse_hex_string(str, hex_tmp, &hexlen);
9407 /* Check the converted binary fits into data buffer. */
9410 /* Let parse_int() fill length information first. */
9411 ret = snprintf(tmp, sizeof(tmp), "%u", hexlen);
9414 /* Save length if requested. */
9415 if (arg_len->size) {
9416 push_args(ctx, arg_len);
9417 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
9423 buf = (uint8_t *)ctx->object + arg_data->offset;
9424 /* Output buffer is not necessarily NUL-terminated. */
9425 memcpy(buf, hex_tmp, hexlen);
9426 memset((uint8_t *)buf + hexlen, 0x00, size - hexlen);
9428 memset((uint8_t *)ctx->objmask + arg_data->offset,
9430 /* Save address if requested. */
9431 if (arg_addr->size) {
9432 memcpy((uint8_t *)ctx->object + arg_addr->offset,
9434 (uint8_t *)ctx->object + arg_data->offset
9438 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
9440 (uint8_t *)ctx->objmask + arg_data->offset
9446 push_args(ctx, arg_addr);
9447 push_args(ctx, arg_len);
9448 push_args(ctx, arg_data);
9454 * Parse a zero-ended string.
9457 parse_string0(struct context *ctx, const struct token *token __rte_unused,
9458 const char *str, unsigned int len,
9459 void *buf, unsigned int size)
9461 const struct arg *arg_data = pop_args(ctx);
9463 /* Arguments are expected. */
9466 size = arg_data->size;
9467 /* Bit-mask fill is not supported. */
9468 if (arg_data->mask || size < len + 1)
9472 buf = (uint8_t *)ctx->object + arg_data->offset;
9473 strncpy(buf, str, len);
9475 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
9478 push_args(ctx, arg_data);
9483 * Parse a MAC address.
9485 * Last argument (ctx->args) is retrieved to determine storage size and
9489 parse_mac_addr(struct context *ctx, const struct token *token,
9490 const char *str, unsigned int len,
9491 void *buf, unsigned int size)
9493 const struct arg *arg = pop_args(ctx);
9494 struct rte_ether_addr tmp;
9498 /* Argument is expected. */
9502 /* Bit-mask fill is not supported. */
9503 if (arg->mask || size != sizeof(tmp))
9505 /* Only network endian is supported. */
9508 ret = cmdline_parse_etheraddr(NULL, str, &tmp, size);
9509 if (ret < 0 || (unsigned int)ret != len)
9513 buf = (uint8_t *)ctx->object + arg->offset;
9514 memcpy(buf, &tmp, size);
9516 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
9519 push_args(ctx, arg);
9524 * Parse an IPv4 address.
9526 * Last argument (ctx->args) is retrieved to determine storage size and
9530 parse_ipv4_addr(struct context *ctx, const struct token *token,
9531 const char *str, unsigned int len,
9532 void *buf, unsigned int size)
9534 const struct arg *arg = pop_args(ctx);
9539 /* Argument is expected. */
9543 /* Bit-mask fill is not supported. */
9544 if (arg->mask || size != sizeof(tmp))
9546 /* Only network endian is supported. */
9549 memcpy(str2, str, len);
9551 ret = inet_pton(AF_INET, str2, &tmp);
9553 /* Attempt integer parsing. */
9554 push_args(ctx, arg);
9555 return parse_int(ctx, token, str, len, buf, size);
9559 buf = (uint8_t *)ctx->object + arg->offset;
9560 memcpy(buf, &tmp, size);
9562 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
9565 push_args(ctx, arg);
9570 * Parse an IPv6 address.
9572 * Last argument (ctx->args) is retrieved to determine storage size and
9576 parse_ipv6_addr(struct context *ctx, const struct token *token,
9577 const char *str, unsigned int len,
9578 void *buf, unsigned int size)
9580 const struct arg *arg = pop_args(ctx);
9582 struct in6_addr tmp;
9586 /* Argument is expected. */
9590 /* Bit-mask fill is not supported. */
9591 if (arg->mask || size != sizeof(tmp))
9593 /* Only network endian is supported. */
9596 memcpy(str2, str, len);
9598 ret = inet_pton(AF_INET6, str2, &tmp);
9603 buf = (uint8_t *)ctx->object + arg->offset;
9604 memcpy(buf, &tmp, size);
9606 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
9609 push_args(ctx, arg);
9613 /** Boolean values (even indices stand for false). */
9614 static const char *const boolean_name[] = {
9624 * Parse a boolean value.
9626 * Last argument (ctx->args) is retrieved to determine storage size and
9630 parse_boolean(struct context *ctx, const struct token *token,
9631 const char *str, unsigned int len,
9632 void *buf, unsigned int size)
9634 const struct arg *arg = pop_args(ctx);
9638 /* Argument is expected. */
9641 for (i = 0; boolean_name[i]; ++i)
9642 if (!strcmp_partial(boolean_name[i], str, len))
9644 /* Process token as integer. */
9645 if (boolean_name[i])
9646 str = i & 1 ? "1" : "0";
9647 push_args(ctx, arg);
9648 ret = parse_int(ctx, token, str, strlen(str), buf, size);
9649 return ret > 0 ? (int)len : ret;
9652 /** Parse port and update context. */
9654 parse_port(struct context *ctx, const struct token *token,
9655 const char *str, unsigned int len,
9656 void *buf, unsigned int size)
9658 struct buffer *out = &(struct buffer){ .port = 0 };
9666 ctx->objmask = NULL;
9667 size = sizeof(*out);
9669 ret = parse_int(ctx, token, str, len, out, size);
9671 ctx->port = out->port;
9678 parse_ia_id2ptr(struct context *ctx, const struct token *token,
9679 const char *str, unsigned int len,
9680 void *buf, unsigned int size)
9682 struct rte_flow_action *action = ctx->object;
9690 ctx->objmask = NULL;
9691 ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
9692 ctx->object = action;
9693 if (ret != (int)len)
9695 /* set indirect action */
9697 action->conf = port_action_handle_get_by_id(ctx->port, id);
9698 ret = (action->conf) ? ret : -1;
9703 /** Parse set command, initialize output buffer for subsequent tokens. */
9705 parse_set_raw_encap_decap(struct context *ctx, const struct token *token,
9706 const char *str, unsigned int len,
9707 void *buf, unsigned int size)
9709 struct buffer *out = buf;
9711 /* Token name must match. */
9712 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
9714 /* Nothing else to do if there is no buffer. */
9717 /* Make sure buffer is large enough. */
9718 if (size < sizeof(*out))
9721 ctx->objmask = NULL;
9725 out->command = ctx->curr;
9726 /* For encap/decap we need is pattern */
9727 out->args.vc.pattern = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
9732 /** Parse set command, initialize output buffer for subsequent tokens. */
9734 parse_set_sample_action(struct context *ctx, const struct token *token,
9735 const char *str, unsigned int len,
9736 void *buf, unsigned int size)
9738 struct buffer *out = buf;
9740 /* Token name must match. */
9741 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
9743 /* Nothing else to do if there is no buffer. */
9746 /* Make sure buffer is large enough. */
9747 if (size < sizeof(*out))
9750 ctx->objmask = NULL;
9754 out->command = ctx->curr;
9755 /* For sampler we need is actions */
9756 out->args.vc.actions = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
9762 * Parse set raw_encap/raw_decap command,
9763 * initialize output buffer for subsequent tokens.
9766 parse_set_init(struct context *ctx, const struct token *token,
9767 const char *str, unsigned int len,
9768 void *buf, unsigned int size)
9770 struct buffer *out = buf;
9772 /* Token name must match. */
9773 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
9775 /* Nothing else to do if there is no buffer. */
9778 /* Make sure buffer is large enough. */
9779 if (size < sizeof(*out))
9781 /* Initialize buffer. */
9782 memset(out, 0x00, sizeof(*out));
9783 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
9786 ctx->objmask = NULL;
9787 if (!out->command) {
9788 if (ctx->curr != SET)
9790 if (sizeof(*out) > size)
9792 out->command = ctx->curr;
9793 out->args.vc.data = (uint8_t *)out + size;
9794 ctx->object = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
9801 * Replace testpmd handles in a flex flow item with real values.
9804 parse_flex_handle(struct context *ctx, const struct token *token,
9805 const char *str, unsigned int len,
9806 void *buf, unsigned int size)
9808 struct rte_flow_item_flex *spec, *mask;
9809 const struct rte_flow_item_flex *src_spec, *src_mask;
9810 const struct arg *arg = pop_args(ctx);
9816 printf("Bad environment\n");
9819 offset = arg->offset;
9820 push_args(ctx, arg);
9821 ret = parse_int(ctx, token, str, len, buf, size);
9822 if (ret <= 0 || !ctx->object)
9824 if (ctx->port >= RTE_MAX_ETHPORTS) {
9825 printf("Bad port\n");
9828 if (offset == offsetof(struct rte_flow_item_flex, handle)) {
9829 const struct flex_item *fp;
9830 struct rte_flow_item_flex *item_flex = ctx->object;
9831 handle = (uint16_t)(uintptr_t)item_flex->handle;
9832 if (handle >= FLEX_MAX_PARSERS_NUM) {
9833 printf("Bad flex item handle\n");
9836 fp = flex_items[ctx->port][handle];
9838 printf("Bad flex item handle\n");
9841 item_flex->handle = fp->flex_handle;
9842 } else if (offset == offsetof(struct rte_flow_item_flex, pattern)) {
9843 handle = (uint16_t)(uintptr_t)
9844 ((struct rte_flow_item_flex *)ctx->object)->pattern;
9845 if (handle >= FLEX_MAX_PATTERNS_NUM) {
9846 printf("Bad pattern handle\n");
9849 src_spec = &flex_patterns[handle].spec;
9850 src_mask = &flex_patterns[handle].mask;
9852 mask = spec + 2; /* spec, last, mask */
9853 /* fill flow rule spec and mask parameters */
9854 spec->length = src_spec->length;
9855 spec->pattern = src_spec->pattern;
9856 mask->length = src_mask->length;
9857 mask->pattern = src_mask->pattern;
9859 printf("Bad arguments - unknown flex item offset\n");
9865 /** No completion. */
9867 comp_none(struct context *ctx, const struct token *token,
9868 unsigned int ent, char *buf, unsigned int size)
9878 /** Complete boolean values. */
9880 comp_boolean(struct context *ctx, const struct token *token,
9881 unsigned int ent, char *buf, unsigned int size)
9887 for (i = 0; boolean_name[i]; ++i)
9888 if (buf && i == ent)
9889 return strlcpy(buf, boolean_name[i], size);
9895 /** Complete action names. */
9897 comp_action(struct context *ctx, const struct token *token,
9898 unsigned int ent, char *buf, unsigned int size)
9904 for (i = 0; next_action[i]; ++i)
9905 if (buf && i == ent)
9906 return strlcpy(buf, token_list[next_action[i]].name,
9913 /** Complete available ports. */
9915 comp_port(struct context *ctx, const struct token *token,
9916 unsigned int ent, char *buf, unsigned int size)
9923 RTE_ETH_FOREACH_DEV(p) {
9924 if (buf && i == ent)
9925 return snprintf(buf, size, "%u", p);
9933 /** Complete available rule IDs. */
9935 comp_rule_id(struct context *ctx, const struct token *token,
9936 unsigned int ent, char *buf, unsigned int size)
9939 struct rte_port *port;
9940 struct port_flow *pf;
9943 if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
9944 ctx->port == (portid_t)RTE_PORT_ALL)
9946 port = &ports[ctx->port];
9947 for (pf = port->flow_list; pf != NULL; pf = pf->next) {
9948 if (buf && i == ent)
9949 return snprintf(buf, size, "%u", pf->id);
9957 /** Complete type field for RSS action. */
9959 comp_vc_action_rss_type(struct context *ctx, const struct token *token,
9960 unsigned int ent, char *buf, unsigned int size)
9966 for (i = 0; rss_type_table[i].str; ++i)
9971 return strlcpy(buf, rss_type_table[ent].str, size);
9973 return snprintf(buf, size, "end");
9977 /** Complete queue field for RSS action. */
9979 comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
9980 unsigned int ent, char *buf, unsigned int size)
9987 return snprintf(buf, size, "%u", ent);
9989 return snprintf(buf, size, "end");
9993 /** Complete index number for set raw_encap/raw_decap commands. */
9995 comp_set_raw_index(struct context *ctx, const struct token *token,
9996 unsigned int ent, char *buf, unsigned int size)
10002 RTE_SET_USED(token);
10003 for (idx = 0; idx < RAW_ENCAP_CONFS_MAX_NUM; ++idx) {
10004 if (buf && idx == ent)
10005 return snprintf(buf, size, "%u", idx);
10011 /** Complete index number for set raw_encap/raw_decap commands. */
10013 comp_set_sample_index(struct context *ctx, const struct token *token,
10014 unsigned int ent, char *buf, unsigned int size)
10020 RTE_SET_USED(token);
10021 for (idx = 0; idx < RAW_SAMPLE_CONFS_MAX_NUM; ++idx) {
10022 if (buf && idx == ent)
10023 return snprintf(buf, size, "%u", idx);
10029 /** Complete operation for modify_field command. */
10031 comp_set_modify_field_op(struct context *ctx, const struct token *token,
10032 unsigned int ent, char *buf, unsigned int size)
10035 RTE_SET_USED(token);
10037 return RTE_DIM(modify_field_ops);
10038 if (ent < RTE_DIM(modify_field_ops) - 1)
10039 return strlcpy(buf, modify_field_ops[ent], size);
10043 /** Complete field id for modify_field command. */
10045 comp_set_modify_field_id(struct context *ctx, const struct token *token,
10046 unsigned int ent, char *buf, unsigned int size)
10050 RTE_SET_USED(token);
10052 return RTE_DIM(modify_field_ids);
10053 if (ent >= RTE_DIM(modify_field_ids) - 1)
10055 name = modify_field_ids[ent];
10056 if (ctx->curr == ACTION_MODIFY_FIELD_SRC_TYPE ||
10057 (strcmp(name, "pointer") && strcmp(name, "value")))
10058 return strlcpy(buf, name, size);
10062 /** Complete available pattern template IDs. */
10064 comp_pattern_template_id(struct context *ctx, const struct token *token,
10065 unsigned int ent, char *buf, unsigned int size)
10067 unsigned int i = 0;
10068 struct rte_port *port;
10069 struct port_template *pt;
10072 if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
10073 ctx->port == (portid_t)RTE_PORT_ALL)
10075 port = &ports[ctx->port];
10076 for (pt = port->pattern_templ_list; pt != NULL; pt = pt->next) {
10077 if (buf && i == ent)
10078 return snprintf(buf, size, "%u", pt->id);
10086 /** Complete available actions template IDs. */
10088 comp_actions_template_id(struct context *ctx, const struct token *token,
10089 unsigned int ent, char *buf, unsigned int size)
10091 unsigned int i = 0;
10092 struct rte_port *port;
10093 struct port_template *pt;
10096 if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
10097 ctx->port == (portid_t)RTE_PORT_ALL)
10099 port = &ports[ctx->port];
10100 for (pt = port->actions_templ_list; pt != NULL; pt = pt->next) {
10101 if (buf && i == ent)
10102 return snprintf(buf, size, "%u", pt->id);
10110 /** Complete available table IDs. */
10112 comp_table_id(struct context *ctx, const struct token *token,
10113 unsigned int ent, char *buf, unsigned int size)
10115 unsigned int i = 0;
10116 struct rte_port *port;
10117 struct port_table *pt;
10120 if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
10121 ctx->port == (portid_t)RTE_PORT_ALL)
10123 port = &ports[ctx->port];
10124 for (pt = port->table_list; pt != NULL; pt = pt->next) {
10125 if (buf && i == ent)
10126 return snprintf(buf, size, "%u", pt->id);
10134 /** Complete available queue IDs. */
10136 comp_queue_id(struct context *ctx, const struct token *token,
10137 unsigned int ent, char *buf, unsigned int size)
10139 unsigned int i = 0;
10140 struct rte_port *port;
10143 if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
10144 ctx->port == (portid_t)RTE_PORT_ALL)
10146 port = &ports[ctx->port];
10147 for (i = 0; i < port->queue_nb; i++) {
10148 if (buf && i == ent)
10149 return snprintf(buf, size, "%u", i);
10156 /** Internal context. */
10157 static struct context cmd_flow_context;
10159 /** Global parser instance (cmdline API). */
10160 cmdline_parse_inst_t cmd_flow;
10161 cmdline_parse_inst_t cmd_set_raw;
10163 /** Initialize context. */
10165 cmd_flow_context_init(struct context *ctx)
10167 /* A full memset() is not necessary. */
10176 ctx->object = NULL;
10177 ctx->objmask = NULL;
10180 /** Parse a token (cmdline API). */
10182 cmd_flow_parse(cmdline_parse_token_hdr_t *hdr, const char *src, void *result,
10185 struct context *ctx = &cmd_flow_context;
10186 const struct token *token;
10187 const enum index *list;
10192 token = &token_list[ctx->curr];
10193 /* Check argument length. */
10196 for (len = 0; src[len]; ++len)
10197 if (src[len] == '#' || isspace(src[len]))
10201 /* Last argument and EOL detection. */
10202 for (i = len; src[i]; ++i)
10203 if (src[i] == '#' || src[i] == '\r' || src[i] == '\n')
10205 else if (!isspace(src[i])) {
10209 for (; src[i]; ++i)
10210 if (src[i] == '\r' || src[i] == '\n') {
10214 /* Initialize context if necessary. */
10215 if (!ctx->next_num) {
10218 ctx->next[ctx->next_num++] = token->next[0];
10220 /* Process argument through candidates. */
10221 ctx->prev = ctx->curr;
10222 list = ctx->next[ctx->next_num - 1];
10223 for (i = 0; list[i]; ++i) {
10224 const struct token *next = &token_list[list[i]];
10227 ctx->curr = list[i];
10229 tmp = next->call(ctx, next, src, len, result, size);
10231 tmp = parse_default(ctx, next, src, len, result, size);
10232 if (tmp == -1 || tmp != len)
10240 /* Push subsequent tokens if any. */
10242 for (i = 0; token->next[i]; ++i) {
10243 if (ctx->next_num == RTE_DIM(ctx->next))
10245 ctx->next[ctx->next_num++] = token->next[i];
10247 /* Push arguments if any. */
10249 for (i = 0; token->args[i]; ++i) {
10250 if (ctx->args_num == RTE_DIM(ctx->args))
10252 ctx->args[ctx->args_num++] = token->args[i];
10258 flow_parse(const char *src, void *result, unsigned int size,
10259 struct rte_flow_attr **attr,
10260 struct rte_flow_item **pattern, struct rte_flow_action **actions)
10263 struct context saved_flow_ctx = cmd_flow_context;
10265 cmd_flow_context_init(&cmd_flow_context);
10267 ret = cmd_flow_parse(NULL, src, result, size);
10270 while (isspace(*src))
10273 } while (ret > 0 && strlen(src));
10274 cmd_flow_context = saved_flow_ctx;
10275 *attr = &((struct buffer *)result)->args.vc.attr;
10276 *pattern = ((struct buffer *)result)->args.vc.pattern;
10277 *actions = ((struct buffer *)result)->args.vc.actions;
10278 return (ret >= 0 && !strlen(src)) ? 0 : -1;
10281 /** Return number of completion entries (cmdline API). */
10283 cmd_flow_complete_get_nb(cmdline_parse_token_hdr_t *hdr)
10285 struct context *ctx = &cmd_flow_context;
10286 const struct token *token = &token_list[ctx->curr];
10287 const enum index *list;
10291 /* Count number of tokens in current list. */
10293 list = ctx->next[ctx->next_num - 1];
10295 list = token->next[0];
10296 for (i = 0; list[i]; ++i)
10301 * If there is a single token, use its completion callback, otherwise
10302 * return the number of entries.
10304 token = &token_list[list[0]];
10305 if (i == 1 && token->comp) {
10306 /* Save index for cmd_flow_get_help(). */
10307 ctx->prev = list[0];
10308 return token->comp(ctx, token, 0, NULL, 0);
10313 /** Return a completion entry (cmdline API). */
10315 cmd_flow_complete_get_elt(cmdline_parse_token_hdr_t *hdr, int index,
10316 char *dst, unsigned int size)
10318 struct context *ctx = &cmd_flow_context;
10319 const struct token *token = &token_list[ctx->curr];
10320 const enum index *list;
10324 /* Count number of tokens in current list. */
10326 list = ctx->next[ctx->next_num - 1];
10328 list = token->next[0];
10329 for (i = 0; list[i]; ++i)
10333 /* If there is a single token, use its completion callback. */
10334 token = &token_list[list[0]];
10335 if (i == 1 && token->comp) {
10336 /* Save index for cmd_flow_get_help(). */
10337 ctx->prev = list[0];
10338 return token->comp(ctx, token, index, dst, size) < 0 ? -1 : 0;
10340 /* Otherwise make sure the index is valid and use defaults. */
10343 token = &token_list[list[index]];
10344 strlcpy(dst, token->name, size);
10345 /* Save index for cmd_flow_get_help(). */
10346 ctx->prev = list[index];
10350 /** Populate help strings for current token (cmdline API). */
10352 cmd_flow_get_help(cmdline_parse_token_hdr_t *hdr, char *dst, unsigned int size)
10354 struct context *ctx = &cmd_flow_context;
10355 const struct token *token = &token_list[ctx->prev];
10360 /* Set token type and update global help with details. */
10361 strlcpy(dst, (token->type ? token->type : "TOKEN"), size);
10363 cmd_flow.help_str = token->help;
10365 cmd_flow.help_str = token->name;
10369 /** Token definition template (cmdline API). */
10370 static struct cmdline_token_hdr cmd_flow_token_hdr = {
10371 .ops = &(struct cmdline_token_ops){
10372 .parse = cmd_flow_parse,
10373 .complete_get_nb = cmd_flow_complete_get_nb,
10374 .complete_get_elt = cmd_flow_complete_get_elt,
10375 .get_help = cmd_flow_get_help,
10380 /** Populate the next dynamic token. */
10382 cmd_flow_tok(cmdline_parse_token_hdr_t **hdr,
10383 cmdline_parse_token_hdr_t **hdr_inst)
10385 struct context *ctx = &cmd_flow_context;
10387 /* Always reinitialize context before requesting the first token. */
10388 if (!(hdr_inst - cmd_flow.tokens))
10389 cmd_flow_context_init(ctx);
10390 /* Return NULL when no more tokens are expected. */
10391 if (!ctx->next_num && ctx->curr) {
10395 /* Determine if command should end here. */
10396 if (ctx->eol && ctx->last && ctx->next_num) {
10397 const enum index *list = ctx->next[ctx->next_num - 1];
10400 for (i = 0; list[i]; ++i) {
10401 if (list[i] != END)
10407 *hdr = &cmd_flow_token_hdr;
10410 /** Dispatch parsed buffer to function calls. */
10412 cmd_flow_parsed(const struct buffer *in)
10414 switch (in->command) {
10416 port_flow_get_info(in->port);
10419 port_flow_configure(in->port,
10420 &in->args.configure.port_attr,
10421 in->args.configure.nb_queue,
10422 &in->args.configure.queue_attr);
10424 case PATTERN_TEMPLATE_CREATE:
10425 port_flow_pattern_template_create(in->port,
10426 in->args.vc.pat_templ_id,
10427 &((const struct rte_flow_pattern_template_attr) {
10428 .relaxed_matching = in->args.vc.attr.reserved,
10429 .ingress = in->args.vc.attr.ingress,
10430 .egress = in->args.vc.attr.egress,
10431 .transfer = in->args.vc.attr.transfer,
10433 in->args.vc.pattern);
10435 case PATTERN_TEMPLATE_DESTROY:
10436 port_flow_pattern_template_destroy(in->port,
10437 in->args.templ_destroy.template_id_n,
10438 in->args.templ_destroy.template_id);
10440 case ACTIONS_TEMPLATE_CREATE:
10441 port_flow_actions_template_create(in->port,
10442 in->args.vc.act_templ_id,
10443 &((const struct rte_flow_actions_template_attr) {
10444 .ingress = in->args.vc.attr.ingress,
10445 .egress = in->args.vc.attr.egress,
10446 .transfer = in->args.vc.attr.transfer,
10448 in->args.vc.actions,
10449 in->args.vc.masks);
10451 case ACTIONS_TEMPLATE_DESTROY:
10452 port_flow_actions_template_destroy(in->port,
10453 in->args.templ_destroy.template_id_n,
10454 in->args.templ_destroy.template_id);
10457 port_flow_template_table_create(in->port, in->args.table.id,
10458 &in->args.table.attr, in->args.table.pat_templ_id_n,
10459 in->args.table.pat_templ_id, in->args.table.act_templ_id_n,
10460 in->args.table.act_templ_id);
10462 case TABLE_DESTROY:
10463 port_flow_template_table_destroy(in->port,
10464 in->args.table_destroy.table_id_n,
10465 in->args.table_destroy.table_id);
10468 port_queue_flow_create(in->port, in->queue, in->postpone,
10469 in->args.vc.table_id, in->args.vc.pat_templ_id,
10470 in->args.vc.act_templ_id, in->args.vc.pattern,
10471 in->args.vc.actions);
10473 case QUEUE_DESTROY:
10474 port_queue_flow_destroy(in->port, in->queue, in->postpone,
10475 in->args.destroy.rule_n,
10476 in->args.destroy.rule);
10479 port_queue_flow_push(in->port, in->queue);
10482 port_queue_flow_pull(in->port, in->queue);
10484 case QUEUE_INDIRECT_ACTION_CREATE:
10485 port_queue_action_handle_create(
10486 in->port, in->queue, in->postpone,
10487 in->args.vc.attr.group,
10488 &((const struct rte_flow_indir_action_conf) {
10489 .ingress = in->args.vc.attr.ingress,
10490 .egress = in->args.vc.attr.egress,
10491 .transfer = in->args.vc.attr.transfer,
10493 in->args.vc.actions);
10495 case QUEUE_INDIRECT_ACTION_DESTROY:
10496 port_queue_action_handle_destroy(in->port,
10497 in->queue, in->postpone,
10498 in->args.ia_destroy.action_id_n,
10499 in->args.ia_destroy.action_id);
10501 case QUEUE_INDIRECT_ACTION_UPDATE:
10502 port_queue_action_handle_update(in->port,
10503 in->queue, in->postpone,
10504 in->args.vc.attr.group,
10505 in->args.vc.actions);
10507 case INDIRECT_ACTION_CREATE:
10508 port_action_handle_create(
10509 in->port, in->args.vc.attr.group,
10510 &((const struct rte_flow_indir_action_conf) {
10511 .ingress = in->args.vc.attr.ingress,
10512 .egress = in->args.vc.attr.egress,
10513 .transfer = in->args.vc.attr.transfer,
10515 in->args.vc.actions);
10517 case INDIRECT_ACTION_DESTROY:
10518 port_action_handle_destroy(in->port,
10519 in->args.ia_destroy.action_id_n,
10520 in->args.ia_destroy.action_id);
10522 case INDIRECT_ACTION_UPDATE:
10523 port_action_handle_update(in->port, in->args.vc.attr.group,
10524 in->args.vc.actions);
10526 case INDIRECT_ACTION_QUERY:
10527 port_action_handle_query(in->port, in->args.ia.action_id);
10530 port_flow_validate(in->port, &in->args.vc.attr,
10531 in->args.vc.pattern, in->args.vc.actions,
10532 &in->args.vc.tunnel_ops);
10535 port_flow_create(in->port, &in->args.vc.attr,
10536 in->args.vc.pattern, in->args.vc.actions,
10537 &in->args.vc.tunnel_ops);
10540 port_flow_destroy(in->port, in->args.destroy.rule_n,
10541 in->args.destroy.rule);
10544 port_flow_flush(in->port);
10548 port_flow_dump(in->port, in->args.dump.mode,
10549 in->args.dump.rule, in->args.dump.file);
10552 port_flow_query(in->port, in->args.query.rule,
10553 &in->args.query.action);
10556 port_flow_list(in->port, in->args.list.group_n,
10557 in->args.list.group);
10560 port_flow_isolate(in->port, in->args.isolate.set);
10563 port_flow_aged(in->port, in->args.aged.destroy);
10565 case TUNNEL_CREATE:
10566 port_flow_tunnel_create(in->port, &in->args.vc.tunnel_ops);
10568 case TUNNEL_DESTROY:
10569 port_flow_tunnel_destroy(in->port, in->args.vc.tunnel_ops.id);
10572 port_flow_tunnel_list(in->port);
10575 port_meter_policy_add(in->port, in->args.policy.policy_id,
10576 in->args.vc.actions);
10578 case FLEX_ITEM_CREATE:
10579 flex_item_create(in->port, in->args.flex.token,
10580 in->args.flex.filename);
10582 case FLEX_ITEM_DESTROY:
10583 flex_item_destroy(in->port, in->args.flex.token);
10590 /** Token generator and output processing callback (cmdline API). */
10592 cmd_flow_cb(void *arg0, struct cmdline *cl, void *arg2)
10595 cmd_flow_tok(arg0, arg2);
10597 cmd_flow_parsed(arg0);
10600 /** Global parser instance (cmdline API). */
10601 cmdline_parse_inst_t cmd_flow = {
10603 .data = NULL, /**< Unused. */
10604 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
10607 }, /**< Tokens are returned by cmd_flow_tok(). */
10610 /** set cmd facility. Reuse cmd flow's infrastructure as much as possible. */
10613 update_fields(uint8_t *buf, struct rte_flow_item *item, uint16_t next_proto)
10615 struct rte_ipv4_hdr *ipv4;
10616 struct rte_ether_hdr *eth;
10617 struct rte_ipv6_hdr *ipv6;
10618 struct rte_vxlan_hdr *vxlan;
10619 struct rte_vxlan_gpe_hdr *gpe;
10620 struct rte_flow_item_nvgre *nvgre;
10621 uint32_t ipv6_vtc_flow;
10623 switch (item->type) {
10624 case RTE_FLOW_ITEM_TYPE_ETH:
10625 eth = (struct rte_ether_hdr *)buf;
10627 eth->ether_type = rte_cpu_to_be_16(next_proto);
10629 case RTE_FLOW_ITEM_TYPE_IPV4:
10630 ipv4 = (struct rte_ipv4_hdr *)buf;
10631 if (!ipv4->version_ihl)
10632 ipv4->version_ihl = RTE_IPV4_VHL_DEF;
10633 if (next_proto && ipv4->next_proto_id == 0)
10634 ipv4->next_proto_id = (uint8_t)next_proto;
10636 case RTE_FLOW_ITEM_TYPE_IPV6:
10637 ipv6 = (struct rte_ipv6_hdr *)buf;
10638 if (next_proto && ipv6->proto == 0)
10639 ipv6->proto = (uint8_t)next_proto;
10640 ipv6_vtc_flow = rte_be_to_cpu_32(ipv6->vtc_flow);
10641 ipv6_vtc_flow &= 0x0FFFFFFF; /*< reset version bits. */
10642 ipv6_vtc_flow |= 0x60000000; /*< set ipv6 version. */
10643 ipv6->vtc_flow = rte_cpu_to_be_32(ipv6_vtc_flow);
10645 case RTE_FLOW_ITEM_TYPE_VXLAN:
10646 vxlan = (struct rte_vxlan_hdr *)buf;
10647 vxlan->vx_flags = 0x08;
10649 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
10650 gpe = (struct rte_vxlan_gpe_hdr *)buf;
10651 gpe->vx_flags = 0x0C;
10653 case RTE_FLOW_ITEM_TYPE_NVGRE:
10654 nvgre = (struct rte_flow_item_nvgre *)buf;
10655 nvgre->protocol = rte_cpu_to_be_16(0x6558);
10656 nvgre->c_k_s_rsvd0_ver = rte_cpu_to_be_16(0x2000);
10663 /** Helper of get item's default mask. */
10664 static const void *
10665 flow_item_default_mask(const struct rte_flow_item *item)
10667 const void *mask = NULL;
10668 static rte_be32_t gre_key_default_mask = RTE_BE32(UINT32_MAX);
10670 switch (item->type) {
10671 case RTE_FLOW_ITEM_TYPE_ANY:
10672 mask = &rte_flow_item_any_mask;
10674 case RTE_FLOW_ITEM_TYPE_VF:
10675 mask = &rte_flow_item_vf_mask;
10677 case RTE_FLOW_ITEM_TYPE_PORT_ID:
10678 mask = &rte_flow_item_port_id_mask;
10680 case RTE_FLOW_ITEM_TYPE_RAW:
10681 mask = &rte_flow_item_raw_mask;
10683 case RTE_FLOW_ITEM_TYPE_ETH:
10684 mask = &rte_flow_item_eth_mask;
10686 case RTE_FLOW_ITEM_TYPE_VLAN:
10687 mask = &rte_flow_item_vlan_mask;
10689 case RTE_FLOW_ITEM_TYPE_IPV4:
10690 mask = &rte_flow_item_ipv4_mask;
10692 case RTE_FLOW_ITEM_TYPE_IPV6:
10693 mask = &rte_flow_item_ipv6_mask;
10695 case RTE_FLOW_ITEM_TYPE_ICMP:
10696 mask = &rte_flow_item_icmp_mask;
10698 case RTE_FLOW_ITEM_TYPE_UDP:
10699 mask = &rte_flow_item_udp_mask;
10701 case RTE_FLOW_ITEM_TYPE_TCP:
10702 mask = &rte_flow_item_tcp_mask;
10704 case RTE_FLOW_ITEM_TYPE_SCTP:
10705 mask = &rte_flow_item_sctp_mask;
10707 case RTE_FLOW_ITEM_TYPE_VXLAN:
10708 mask = &rte_flow_item_vxlan_mask;
10710 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
10711 mask = &rte_flow_item_vxlan_gpe_mask;
10713 case RTE_FLOW_ITEM_TYPE_E_TAG:
10714 mask = &rte_flow_item_e_tag_mask;
10716 case RTE_FLOW_ITEM_TYPE_NVGRE:
10717 mask = &rte_flow_item_nvgre_mask;
10719 case RTE_FLOW_ITEM_TYPE_MPLS:
10720 mask = &rte_flow_item_mpls_mask;
10722 case RTE_FLOW_ITEM_TYPE_GRE:
10723 mask = &rte_flow_item_gre_mask;
10725 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
10726 mask = &gre_key_default_mask;
10728 case RTE_FLOW_ITEM_TYPE_META:
10729 mask = &rte_flow_item_meta_mask;
10731 case RTE_FLOW_ITEM_TYPE_FUZZY:
10732 mask = &rte_flow_item_fuzzy_mask;
10734 case RTE_FLOW_ITEM_TYPE_GTP:
10735 mask = &rte_flow_item_gtp_mask;
10737 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
10738 mask = &rte_flow_item_gtp_psc_mask;
10740 case RTE_FLOW_ITEM_TYPE_GENEVE:
10741 mask = &rte_flow_item_geneve_mask;
10743 case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
10744 mask = &rte_flow_item_geneve_opt_mask;
10746 case RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID:
10747 mask = &rte_flow_item_pppoe_proto_id_mask;
10749 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
10750 mask = &rte_flow_item_l2tpv3oip_mask;
10752 case RTE_FLOW_ITEM_TYPE_ESP:
10753 mask = &rte_flow_item_esp_mask;
10755 case RTE_FLOW_ITEM_TYPE_AH:
10756 mask = &rte_flow_item_ah_mask;
10758 case RTE_FLOW_ITEM_TYPE_PFCP:
10759 mask = &rte_flow_item_pfcp_mask;
10761 case RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR:
10762 case RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT:
10763 mask = &rte_flow_item_ethdev_mask;
10765 case RTE_FLOW_ITEM_TYPE_L2TPV2:
10766 mask = &rte_flow_item_l2tpv2_mask;
10768 case RTE_FLOW_ITEM_TYPE_PPP:
10769 mask = &rte_flow_item_ppp_mask;
10777 /** Dispatch parsed buffer to function calls. */
10779 cmd_set_raw_parsed_sample(const struct buffer *in)
10781 uint32_t n = in->args.vc.actions_n;
10783 struct rte_flow_action *action = NULL;
10784 struct rte_flow_action *data = NULL;
10785 const struct rte_flow_action_rss *rss = NULL;
10787 uint16_t idx = in->port; /* We borrow port field as index */
10788 uint32_t max_size = sizeof(struct rte_flow_action) *
10789 ACTION_SAMPLE_ACTIONS_NUM;
10791 RTE_ASSERT(in->command == SET_SAMPLE_ACTIONS);
10792 data = (struct rte_flow_action *)&raw_sample_confs[idx].data;
10793 memset(data, 0x00, max_size);
10794 for (; i <= n - 1; i++) {
10795 action = in->args.vc.actions + i;
10796 if (action->type == RTE_FLOW_ACTION_TYPE_END)
10798 switch (action->type) {
10799 case RTE_FLOW_ACTION_TYPE_MARK:
10800 size = sizeof(struct rte_flow_action_mark);
10801 rte_memcpy(&sample_mark[idx],
10802 (const void *)action->conf, size);
10803 action->conf = &sample_mark[idx];
10805 case RTE_FLOW_ACTION_TYPE_COUNT:
10806 size = sizeof(struct rte_flow_action_count);
10807 rte_memcpy(&sample_count[idx],
10808 (const void *)action->conf, size);
10809 action->conf = &sample_count[idx];
10811 case RTE_FLOW_ACTION_TYPE_QUEUE:
10812 size = sizeof(struct rte_flow_action_queue);
10813 rte_memcpy(&sample_queue[idx],
10814 (const void *)action->conf, size);
10815 action->conf = &sample_queue[idx];
10817 case RTE_FLOW_ACTION_TYPE_RSS:
10818 size = sizeof(struct rte_flow_action_rss);
10819 rss = action->conf;
10820 rte_memcpy(&sample_rss_data[idx].conf,
10821 (const void *)rss, size);
10822 if (rss->key_len && rss->key) {
10823 sample_rss_data[idx].conf.key =
10824 sample_rss_data[idx].key;
10825 rte_memcpy((void *)((uintptr_t)
10826 sample_rss_data[idx].conf.key),
10827 (const void *)rss->key,
10828 sizeof(uint8_t) * rss->key_len);
10830 if (rss->queue_num && rss->queue) {
10831 sample_rss_data[idx].conf.queue =
10832 sample_rss_data[idx].queue;
10833 rte_memcpy((void *)((uintptr_t)
10834 sample_rss_data[idx].conf.queue),
10835 (const void *)rss->queue,
10836 sizeof(uint16_t) * rss->queue_num);
10838 action->conf = &sample_rss_data[idx].conf;
10840 case RTE_FLOW_ACTION_TYPE_RAW_ENCAP:
10841 size = sizeof(struct rte_flow_action_raw_encap);
10842 rte_memcpy(&sample_encap[idx],
10843 (const void *)action->conf, size);
10844 action->conf = &sample_encap[idx];
10846 case RTE_FLOW_ACTION_TYPE_PORT_ID:
10847 size = sizeof(struct rte_flow_action_port_id);
10848 rte_memcpy(&sample_port_id[idx],
10849 (const void *)action->conf, size);
10850 action->conf = &sample_port_id[idx];
10852 case RTE_FLOW_ACTION_TYPE_PF:
10854 case RTE_FLOW_ACTION_TYPE_VF:
10855 size = sizeof(struct rte_flow_action_vf);
10856 rte_memcpy(&sample_vf[idx],
10857 (const void *)action->conf, size);
10858 action->conf = &sample_vf[idx];
10860 case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP:
10861 size = sizeof(struct rte_flow_action_vxlan_encap);
10862 parse_setup_vxlan_encap_data(&sample_vxlan_encap[idx]);
10863 action->conf = &sample_vxlan_encap[idx].conf;
10865 case RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP:
10866 size = sizeof(struct rte_flow_action_nvgre_encap);
10867 parse_setup_nvgre_encap_data(&sample_nvgre_encap[idx]);
10868 action->conf = &sample_nvgre_encap[idx];
10871 fprintf(stderr, "Error - Not supported action\n");
10874 rte_memcpy(data, action, sizeof(struct rte_flow_action));
10879 /** Dispatch parsed buffer to function calls. */
10881 cmd_set_raw_parsed(const struct buffer *in)
10883 uint32_t n = in->args.vc.pattern_n;
10885 struct rte_flow_item *item = NULL;
10887 uint8_t *data = NULL;
10888 uint8_t *data_tail = NULL;
10889 size_t *total_size = NULL;
10890 uint16_t upper_layer = 0;
10891 uint16_t proto = 0;
10892 uint16_t idx = in->port; /* We borrow port field as index */
10893 int gtp_psc = -1; /* GTP PSC option index. */
10895 if (in->command == SET_SAMPLE_ACTIONS)
10896 return cmd_set_raw_parsed_sample(in);
10897 RTE_ASSERT(in->command == SET_RAW_ENCAP ||
10898 in->command == SET_RAW_DECAP);
10899 if (in->command == SET_RAW_ENCAP) {
10900 total_size = &raw_encap_confs[idx].size;
10901 data = (uint8_t *)&raw_encap_confs[idx].data;
10903 total_size = &raw_decap_confs[idx].size;
10904 data = (uint8_t *)&raw_decap_confs[idx].data;
10907 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
10908 /* process hdr from upper layer to low layer (L3/L4 -> L2). */
10909 data_tail = data + ACTION_RAW_ENCAP_MAX_DATA;
10910 for (i = n - 1 ; i >= 0; --i) {
10911 const struct rte_flow_item_gtp *gtp;
10912 const struct rte_flow_item_geneve_opt *opt;
10914 item = in->args.vc.pattern + i;
10915 if (item->spec == NULL)
10916 item->spec = flow_item_default_mask(item);
10917 switch (item->type) {
10918 case RTE_FLOW_ITEM_TYPE_ETH:
10919 size = sizeof(struct rte_ether_hdr);
10921 case RTE_FLOW_ITEM_TYPE_VLAN:
10922 size = sizeof(struct rte_vlan_hdr);
10923 proto = RTE_ETHER_TYPE_VLAN;
10925 case RTE_FLOW_ITEM_TYPE_IPV4:
10926 size = sizeof(struct rte_ipv4_hdr);
10927 proto = RTE_ETHER_TYPE_IPV4;
10929 case RTE_FLOW_ITEM_TYPE_IPV6:
10930 size = sizeof(struct rte_ipv6_hdr);
10931 proto = RTE_ETHER_TYPE_IPV6;
10933 case RTE_FLOW_ITEM_TYPE_UDP:
10934 size = sizeof(struct rte_udp_hdr);
10937 case RTE_FLOW_ITEM_TYPE_TCP:
10938 size = sizeof(struct rte_tcp_hdr);
10941 case RTE_FLOW_ITEM_TYPE_VXLAN:
10942 size = sizeof(struct rte_vxlan_hdr);
10944 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
10945 size = sizeof(struct rte_vxlan_gpe_hdr);
10947 case RTE_FLOW_ITEM_TYPE_GRE:
10948 size = sizeof(struct rte_gre_hdr);
10951 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
10952 size = sizeof(rte_be32_t);
10955 case RTE_FLOW_ITEM_TYPE_MPLS:
10956 size = sizeof(struct rte_mpls_hdr);
10959 case RTE_FLOW_ITEM_TYPE_NVGRE:
10960 size = sizeof(struct rte_flow_item_nvgre);
10963 case RTE_FLOW_ITEM_TYPE_GENEVE:
10964 size = sizeof(struct rte_geneve_hdr);
10966 case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
10967 opt = (const struct rte_flow_item_geneve_opt *)
10969 size = offsetof(struct rte_flow_item_geneve_opt, data);
10970 if (opt->option_len && opt->data) {
10971 *total_size += opt->option_len *
10973 rte_memcpy(data_tail - (*total_size),
10975 opt->option_len * sizeof(uint32_t));
10978 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
10979 size = sizeof(rte_be32_t);
10982 case RTE_FLOW_ITEM_TYPE_ESP:
10983 size = sizeof(struct rte_esp_hdr);
10986 case RTE_FLOW_ITEM_TYPE_AH:
10987 size = sizeof(struct rte_flow_item_ah);
10990 case RTE_FLOW_ITEM_TYPE_GTP:
10992 size = sizeof(struct rte_gtp_hdr);
10995 if (gtp_psc != i + 1) {
10997 "Error - GTP PSC does not follow GTP\n");
11001 if ((gtp->v_pt_rsv_flags & 0x07) != 0x04) {
11002 /* Only E flag should be set. */
11004 "Error - GTP unsupported flags\n");
11007 struct rte_gtp_hdr_ext_word ext_word = {
11011 /* We have to add GTP header extra word. */
11012 *total_size += sizeof(ext_word);
11013 rte_memcpy(data_tail - (*total_size),
11014 &ext_word, sizeof(ext_word));
11016 size = sizeof(struct rte_gtp_hdr);
11018 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
11019 if (gtp_psc >= 0) {
11021 "Error - Multiple GTP PSC items\n");
11024 const struct rte_flow_item_gtp_psc
11028 uint8_t pdu_type:4;
11032 psc.len = sizeof(psc) / 4;
11033 psc.pdu_type = opt->hdr.type;
11034 psc.qfi = opt->hdr.qfi;
11036 *total_size += sizeof(psc);
11037 rte_memcpy(data_tail - (*total_size),
11038 &psc, sizeof(psc));
11043 case RTE_FLOW_ITEM_TYPE_PFCP:
11044 size = sizeof(struct rte_flow_item_pfcp);
11046 case RTE_FLOW_ITEM_TYPE_FLEX:
11047 size = item->spec ?
11048 ((const struct rte_flow_item_flex *)
11049 item->spec)->length : 0;
11051 case RTE_FLOW_ITEM_TYPE_GRE_OPTION:
11054 const struct rte_flow_item_gre_opt
11056 if (opt->checksum_rsvd.checksum) {
11058 sizeof(opt->checksum_rsvd);
11059 rte_memcpy(data_tail - (*total_size),
11060 &opt->checksum_rsvd,
11061 sizeof(opt->checksum_rsvd));
11063 if (opt->key.key) {
11064 *total_size += sizeof(opt->key.key);
11065 rte_memcpy(data_tail - (*total_size),
11067 sizeof(opt->key.key));
11069 if (opt->sequence.sequence) {
11070 *total_size += sizeof(opt->sequence.sequence);
11071 rte_memcpy(data_tail - (*total_size),
11072 &opt->sequence.sequence,
11073 sizeof(opt->sequence.sequence));
11079 fprintf(stderr, "Error - Not supported item\n");
11082 *total_size += size;
11083 rte_memcpy(data_tail - (*total_size), item->spec, size);
11084 /* update some fields which cannot be set by cmdline */
11085 update_fields((data_tail - (*total_size)), item,
11087 upper_layer = proto;
11089 if (verbose_level & 0x1)
11090 printf("total data size is %zu\n", (*total_size));
11091 RTE_ASSERT((*total_size) <= ACTION_RAW_ENCAP_MAX_DATA);
11092 memmove(data, (data_tail - (*total_size)), *total_size);
11097 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
11100 /** Populate help strings for current token (cmdline API). */
11102 cmd_set_raw_get_help(cmdline_parse_token_hdr_t *hdr, char *dst,
11105 struct context *ctx = &cmd_flow_context;
11106 const struct token *token = &token_list[ctx->prev];
11111 /* Set token type and update global help with details. */
11112 snprintf(dst, size, "%s", (token->type ? token->type : "TOKEN"));
11114 cmd_set_raw.help_str = token->help;
11116 cmd_set_raw.help_str = token->name;
11120 /** Token definition template (cmdline API). */
11121 static struct cmdline_token_hdr cmd_set_raw_token_hdr = {
11122 .ops = &(struct cmdline_token_ops){
11123 .parse = cmd_flow_parse,
11124 .complete_get_nb = cmd_flow_complete_get_nb,
11125 .complete_get_elt = cmd_flow_complete_get_elt,
11126 .get_help = cmd_set_raw_get_help,
11131 /** Populate the next dynamic token. */
11133 cmd_set_raw_tok(cmdline_parse_token_hdr_t **hdr,
11134 cmdline_parse_token_hdr_t **hdr_inst)
11136 struct context *ctx = &cmd_flow_context;
11138 /* Always reinitialize context before requesting the first token. */
11139 if (!(hdr_inst - cmd_set_raw.tokens)) {
11140 cmd_flow_context_init(ctx);
11141 ctx->curr = START_SET;
11143 /* Return NULL when no more tokens are expected. */
11144 if (!ctx->next_num && (ctx->curr != START_SET)) {
11148 /* Determine if command should end here. */
11149 if (ctx->eol && ctx->last && ctx->next_num) {
11150 const enum index *list = ctx->next[ctx->next_num - 1];
11153 for (i = 0; list[i]; ++i) {
11154 if (list[i] != END)
11160 *hdr = &cmd_set_raw_token_hdr;
11163 /** Token generator and output processing callback (cmdline API). */
11165 cmd_set_raw_cb(void *arg0, struct cmdline *cl, void *arg2)
11168 cmd_set_raw_tok(arg0, arg2);
11170 cmd_set_raw_parsed(arg0);
11173 /** Global parser instance (cmdline API). */
11174 cmdline_parse_inst_t cmd_set_raw = {
11175 .f = cmd_set_raw_cb,
11176 .data = NULL, /**< Unused. */
11177 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
11180 }, /**< Tokens are returned by cmd_flow_tok(). */
11183 /* *** display raw_encap/raw_decap buf */
11184 struct cmd_show_set_raw_result {
11185 cmdline_fixed_string_t cmd_show;
11186 cmdline_fixed_string_t cmd_what;
11187 cmdline_fixed_string_t cmd_all;
11188 uint16_t cmd_index;
11192 cmd_show_set_raw_parsed(void *parsed_result, struct cmdline *cl, void *data)
11194 struct cmd_show_set_raw_result *res = parsed_result;
11195 uint16_t index = res->cmd_index;
11197 uint8_t *raw_data = NULL;
11198 size_t raw_size = 0;
11199 char title[16] = {0};
11202 RTE_SET_USED(data);
11203 if (!strcmp(res->cmd_all, "all")) {
11206 } else if (index >= RAW_ENCAP_CONFS_MAX_NUM) {
11207 fprintf(stderr, "index should be 0-%u\n",
11208 RAW_ENCAP_CONFS_MAX_NUM - 1);
11212 if (!strcmp(res->cmd_what, "raw_encap")) {
11213 raw_data = (uint8_t *)&raw_encap_confs[index].data;
11214 raw_size = raw_encap_confs[index].size;
11215 snprintf(title, 16, "\nindex: %u", index);
11216 rte_hexdump(stdout, title, raw_data, raw_size);
11218 raw_data = (uint8_t *)&raw_decap_confs[index].data;
11219 raw_size = raw_decap_confs[index].size;
11220 snprintf(title, 16, "\nindex: %u", index);
11221 rte_hexdump(stdout, title, raw_data, raw_size);
11223 } while (all && ++index < RAW_ENCAP_CONFS_MAX_NUM);
11226 cmdline_parse_token_string_t cmd_show_set_raw_cmd_show =
11227 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
11229 cmdline_parse_token_string_t cmd_show_set_raw_cmd_what =
11230 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
11231 cmd_what, "raw_encap#raw_decap");
11232 cmdline_parse_token_num_t cmd_show_set_raw_cmd_index =
11233 TOKEN_NUM_INITIALIZER(struct cmd_show_set_raw_result,
11234 cmd_index, RTE_UINT16);
11235 cmdline_parse_token_string_t cmd_show_set_raw_cmd_all =
11236 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
11238 cmdline_parse_inst_t cmd_show_set_raw = {
11239 .f = cmd_show_set_raw_parsed,
11241 .help_str = "show <raw_encap|raw_decap> <index>",
11243 (void *)&cmd_show_set_raw_cmd_show,
11244 (void *)&cmd_show_set_raw_cmd_what,
11245 (void *)&cmd_show_set_raw_cmd_index,
11249 cmdline_parse_inst_t cmd_show_set_raw_all = {
11250 .f = cmd_show_set_raw_parsed,
11252 .help_str = "show <raw_encap|raw_decap> all",
11254 (void *)&cmd_show_set_raw_cmd_show,
11255 (void *)&cmd_show_set_raw_cmd_what,
11256 (void *)&cmd_show_set_raw_cmd_all,