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 if ((out->command == VALIDATE || out->command == CREATE) &&
6871 if (out->command == PATTERN_TEMPLATE_CREATE &&
6876 out->args.vc.actions =
6877 (void *)RTE_ALIGN_CEIL((uintptr_t)
6878 (out->args.vc.pattern +
6879 out->args.vc.pattern_n),
6881 ctx->object = out->args.vc.actions;
6882 ctx->objmask = NULL;
6889 if (!out->args.vc.actions) {
6890 const struct parse_item_priv *priv = token->priv;
6891 struct rte_flow_item *item =
6892 out->args.vc.pattern + out->args.vc.pattern_n;
6894 data_size = priv->size * 3; /* spec, last, mask */
6895 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
6896 (out->args.vc.data - data_size),
6898 if ((uint8_t *)item + sizeof(*item) > data)
6900 *item = (struct rte_flow_item){
6903 ++out->args.vc.pattern_n;
6905 ctx->objmask = NULL;
6907 const struct parse_action_priv *priv = token->priv;
6908 struct rte_flow_action *action =
6909 out->args.vc.actions + out->args.vc.actions_n;
6911 data_size = priv->size; /* configuration */
6912 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
6913 (out->args.vc.data - data_size),
6915 if ((uint8_t *)action + sizeof(*action) > data)
6917 *action = (struct rte_flow_action){
6919 .conf = data_size ? data : NULL,
6921 ++out->args.vc.actions_n;
6922 ctx->object = action;
6923 ctx->objmask = NULL;
6925 memset(data, 0, data_size);
6926 out->args.vc.data = data;
6927 ctx->objdata = data_size;
6931 /** Parse pattern item parameter type. */
6933 parse_vc_spec(struct context *ctx, const struct token *token,
6934 const char *str, unsigned int len,
6935 void *buf, unsigned int size)
6937 struct buffer *out = buf;
6938 struct rte_flow_item *item;
6944 /* Token name must match. */
6945 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6947 /* Parse parameter types. */
6948 switch (ctx->curr) {
6949 static const enum index prefix[] = NEXT_ENTRY(COMMON_PREFIX);
6955 case ITEM_PARAM_SPEC:
6958 case ITEM_PARAM_LAST:
6961 case ITEM_PARAM_PREFIX:
6962 /* Modify next token to expect a prefix. */
6963 if (ctx->next_num < 2)
6965 ctx->next[ctx->next_num - 2] = prefix;
6967 case ITEM_PARAM_MASK:
6973 /* Nothing else to do if there is no buffer. */
6976 if (!out->args.vc.pattern_n)
6978 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
6979 data_size = ctx->objdata / 3; /* spec, last, mask */
6980 /* Point to selected object. */
6981 ctx->object = out->args.vc.data + (data_size * index);
6983 ctx->objmask = out->args.vc.data + (data_size * 2); /* mask */
6984 item->mask = ctx->objmask;
6986 ctx->objmask = NULL;
6987 /* Update relevant item pointer. */
6988 *((const void **[]){ &item->spec, &item->last, &item->mask })[index] =
6993 /** Parse action configuration field. */
6995 parse_vc_conf(struct context *ctx, const struct token *token,
6996 const char *str, unsigned int len,
6997 void *buf, unsigned int size)
6999 struct buffer *out = buf;
7002 /* Token name must match. */
7003 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7005 /* Nothing else to do if there is no buffer. */
7008 /* Point to selected object. */
7009 ctx->object = out->args.vc.data;
7010 ctx->objmask = NULL;
7014 /** Parse eCPRI common header type field. */
7016 parse_vc_item_ecpri_type(struct context *ctx, const struct token *token,
7017 const char *str, unsigned int len,
7018 void *buf, unsigned int size)
7020 struct rte_flow_item_ecpri *ecpri;
7021 struct rte_flow_item_ecpri *ecpri_mask;
7022 struct rte_flow_item *item;
7025 struct buffer *out = buf;
7026 const struct arg *arg;
7029 /* Token name must match. */
7030 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7032 switch (ctx->curr) {
7033 case ITEM_ECPRI_COMMON_TYPE_IQ_DATA:
7034 msg_type = RTE_ECPRI_MSG_TYPE_IQ_DATA;
7036 case ITEM_ECPRI_COMMON_TYPE_RTC_CTRL:
7037 msg_type = RTE_ECPRI_MSG_TYPE_RTC_CTRL;
7039 case ITEM_ECPRI_COMMON_TYPE_DLY_MSR:
7040 msg_type = RTE_ECPRI_MSG_TYPE_DLY_MSR;
7047 arg = pop_args(ctx);
7050 ecpri = (struct rte_flow_item_ecpri *)out->args.vc.data;
7051 ecpri->hdr.common.type = msg_type;
7052 data_size = ctx->objdata / 3; /* spec, last, mask */
7053 ecpri_mask = (struct rte_flow_item_ecpri *)(out->args.vc.data +
7055 ecpri_mask->hdr.common.type = 0xFF;
7057 ecpri->hdr.common.u32 = rte_cpu_to_be_32(ecpri->hdr.common.u32);
7058 ecpri_mask->hdr.common.u32 =
7059 rte_cpu_to_be_32(ecpri_mask->hdr.common.u32);
7061 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
7063 item->mask = ecpri_mask;
7067 /** Parse L2TPv2 common header type field. */
7069 parse_vc_item_l2tpv2_type(struct context *ctx, const struct token *token,
7070 const char *str, unsigned int len,
7071 void *buf, unsigned int size)
7073 struct rte_flow_item_l2tpv2 *l2tpv2;
7074 struct rte_flow_item_l2tpv2 *l2tpv2_mask;
7075 struct rte_flow_item *item;
7077 uint16_t msg_type = 0;
7078 struct buffer *out = buf;
7079 const struct arg *arg;
7082 /* Token name must match. */
7083 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7085 switch (ctx->curr) {
7086 case ITEM_L2TPV2_TYPE_DATA:
7087 msg_type |= RTE_L2TPV2_MSG_TYPE_DATA;
7089 case ITEM_L2TPV2_TYPE_DATA_L:
7090 msg_type |= RTE_L2TPV2_MSG_TYPE_DATA_L;
7092 case ITEM_L2TPV2_TYPE_DATA_S:
7093 msg_type |= RTE_L2TPV2_MSG_TYPE_DATA_S;
7095 case ITEM_L2TPV2_TYPE_DATA_O:
7096 msg_type |= RTE_L2TPV2_MSG_TYPE_DATA_O;
7098 case ITEM_L2TPV2_TYPE_DATA_L_S:
7099 msg_type |= RTE_L2TPV2_MSG_TYPE_DATA_L_S;
7101 case ITEM_L2TPV2_TYPE_CTRL:
7102 msg_type |= RTE_L2TPV2_MSG_TYPE_CONTROL;
7109 arg = pop_args(ctx);
7112 l2tpv2 = (struct rte_flow_item_l2tpv2 *)out->args.vc.data;
7113 l2tpv2->hdr.common.flags_version |= msg_type;
7114 data_size = ctx->objdata / 3; /* spec, last, mask */
7115 l2tpv2_mask = (struct rte_flow_item_l2tpv2 *)(out->args.vc.data +
7117 l2tpv2_mask->hdr.common.flags_version = 0xFFFF;
7119 l2tpv2->hdr.common.flags_version =
7120 rte_cpu_to_be_16(l2tpv2->hdr.common.flags_version);
7121 l2tpv2_mask->hdr.common.flags_version =
7122 rte_cpu_to_be_16(l2tpv2_mask->hdr.common.flags_version);
7124 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
7125 item->spec = l2tpv2;
7126 item->mask = l2tpv2_mask;
7130 /** Parse meter color action type. */
7132 parse_vc_action_meter_color_type(struct context *ctx, const struct token *token,
7133 const char *str, unsigned int len,
7134 void *buf, unsigned int size)
7136 struct rte_flow_action *action_data;
7137 struct rte_flow_action_meter_color *conf;
7138 enum rte_color color;
7142 /* Token name must match. */
7143 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7145 switch (ctx->curr) {
7146 case ACTION_METER_COLOR_GREEN:
7147 color = RTE_COLOR_GREEN;
7149 case ACTION_METER_COLOR_YELLOW:
7150 color = RTE_COLOR_YELLOW;
7152 case ACTION_METER_COLOR_RED:
7153 color = RTE_COLOR_RED;
7161 action_data = ctx->object;
7162 conf = (struct rte_flow_action_meter_color *)
7163 (uintptr_t)(action_data->conf);
7164 conf->color = color;
7168 /** Parse RSS action. */
7170 parse_vc_action_rss(struct context *ctx, const struct token *token,
7171 const char *str, unsigned int len,
7172 void *buf, unsigned int size)
7174 struct buffer *out = buf;
7175 struct rte_flow_action *action;
7176 struct action_rss_data *action_rss_data;
7180 ret = parse_vc(ctx, token, str, len, buf, size);
7183 /* Nothing else to do if there is no buffer. */
7186 if (!out->args.vc.actions_n)
7188 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
7189 /* Point to selected object. */
7190 ctx->object = out->args.vc.data;
7191 ctx->objmask = NULL;
7192 /* Set up default configuration. */
7193 action_rss_data = ctx->object;
7194 *action_rss_data = (struct action_rss_data){
7195 .conf = (struct rte_flow_action_rss){
7196 .func = RTE_ETH_HASH_FUNCTION_DEFAULT,
7200 .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM),
7202 .queue = action_rss_data->queue,
7206 for (i = 0; i < action_rss_data->conf.queue_num; ++i)
7207 action_rss_data->queue[i] = i;
7208 action->conf = &action_rss_data->conf;
7213 * Parse func field for RSS action.
7215 * The RTE_ETH_HASH_FUNCTION_* value to assign is derived from the
7216 * ACTION_RSS_FUNC_* index that called this function.
7219 parse_vc_action_rss_func(struct context *ctx, const struct token *token,
7220 const char *str, unsigned int len,
7221 void *buf, unsigned int size)
7223 struct action_rss_data *action_rss_data;
7224 enum rte_eth_hash_function func;
7228 /* Token name must match. */
7229 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7231 switch (ctx->curr) {
7232 case ACTION_RSS_FUNC_DEFAULT:
7233 func = RTE_ETH_HASH_FUNCTION_DEFAULT;
7235 case ACTION_RSS_FUNC_TOEPLITZ:
7236 func = RTE_ETH_HASH_FUNCTION_TOEPLITZ;
7238 case ACTION_RSS_FUNC_SIMPLE_XOR:
7239 func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
7241 case ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ:
7242 func = RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
7249 action_rss_data = ctx->object;
7250 action_rss_data->conf.func = func;
7255 * Parse type field for RSS action.
7257 * Valid tokens are type field names and the "end" token.
7260 parse_vc_action_rss_type(struct context *ctx, const struct token *token,
7261 const char *str, unsigned int len,
7262 void *buf, unsigned int size)
7264 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE);
7265 struct action_rss_data *action_rss_data;
7271 if (ctx->curr != ACTION_RSS_TYPE)
7273 if (!(ctx->objdata >> 16) && ctx->object) {
7274 action_rss_data = ctx->object;
7275 action_rss_data->conf.types = 0;
7277 if (!strcmp_partial("end", str, len)) {
7278 ctx->objdata &= 0xffff;
7281 for (i = 0; rss_type_table[i].str; ++i)
7282 if (!strcmp_partial(rss_type_table[i].str, str, len))
7284 if (!rss_type_table[i].str)
7286 ctx->objdata = 1 << 16 | (ctx->objdata & 0xffff);
7288 if (ctx->next_num == RTE_DIM(ctx->next))
7290 ctx->next[ctx->next_num++] = next;
7293 action_rss_data = ctx->object;
7294 action_rss_data->conf.types |= rss_type_table[i].rss_type;
7299 * Parse queue field for RSS action.
7301 * Valid tokens are queue indices and the "end" token.
7304 parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
7305 const char *str, unsigned int len,
7306 void *buf, unsigned int size)
7308 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE);
7309 struct action_rss_data *action_rss_data;
7310 const struct arg *arg;
7317 if (ctx->curr != ACTION_RSS_QUEUE)
7319 i = ctx->objdata >> 16;
7320 if (!strcmp_partial("end", str, len)) {
7321 ctx->objdata &= 0xffff;
7324 if (i >= ACTION_RSS_QUEUE_NUM)
7326 arg = ARGS_ENTRY_ARB(offsetof(struct action_rss_data, queue) +
7327 i * sizeof(action_rss_data->queue[i]),
7328 sizeof(action_rss_data->queue[i]));
7329 if (push_args(ctx, arg))
7331 ret = parse_int(ctx, token, str, len, NULL, 0);
7337 ctx->objdata = i << 16 | (ctx->objdata & 0xffff);
7339 if (ctx->next_num == RTE_DIM(ctx->next))
7341 ctx->next[ctx->next_num++] = next;
7345 action_rss_data = ctx->object;
7346 action_rss_data->conf.queue_num = i;
7347 action_rss_data->conf.queue = i ? action_rss_data->queue : NULL;
7351 /** Setup VXLAN encap configuration. */
7353 parse_setup_vxlan_encap_data(struct action_vxlan_encap_data *action_vxlan_encap_data)
7355 /* Set up default configuration. */
7356 *action_vxlan_encap_data = (struct action_vxlan_encap_data){
7357 .conf = (struct rte_flow_action_vxlan_encap){
7358 .definition = action_vxlan_encap_data->items,
7362 .type = RTE_FLOW_ITEM_TYPE_ETH,
7363 .spec = &action_vxlan_encap_data->item_eth,
7364 .mask = &rte_flow_item_eth_mask,
7367 .type = RTE_FLOW_ITEM_TYPE_VLAN,
7368 .spec = &action_vxlan_encap_data->item_vlan,
7369 .mask = &rte_flow_item_vlan_mask,
7372 .type = RTE_FLOW_ITEM_TYPE_IPV4,
7373 .spec = &action_vxlan_encap_data->item_ipv4,
7374 .mask = &rte_flow_item_ipv4_mask,
7377 .type = RTE_FLOW_ITEM_TYPE_UDP,
7378 .spec = &action_vxlan_encap_data->item_udp,
7379 .mask = &rte_flow_item_udp_mask,
7382 .type = RTE_FLOW_ITEM_TYPE_VXLAN,
7383 .spec = &action_vxlan_encap_data->item_vxlan,
7384 .mask = &rte_flow_item_vxlan_mask,
7387 .type = RTE_FLOW_ITEM_TYPE_END,
7392 .tci = vxlan_encap_conf.vlan_tci,
7396 .src_addr = vxlan_encap_conf.ipv4_src,
7397 .dst_addr = vxlan_encap_conf.ipv4_dst,
7400 .src_port = vxlan_encap_conf.udp_src,
7401 .dst_port = vxlan_encap_conf.udp_dst,
7403 .item_vxlan.flags = 0,
7405 memcpy(action_vxlan_encap_data->item_eth.dst.addr_bytes,
7406 vxlan_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
7407 memcpy(action_vxlan_encap_data->item_eth.src.addr_bytes,
7408 vxlan_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
7409 if (!vxlan_encap_conf.select_ipv4) {
7410 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.src_addr,
7411 &vxlan_encap_conf.ipv6_src,
7412 sizeof(vxlan_encap_conf.ipv6_src));
7413 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.dst_addr,
7414 &vxlan_encap_conf.ipv6_dst,
7415 sizeof(vxlan_encap_conf.ipv6_dst));
7416 action_vxlan_encap_data->items[2] = (struct rte_flow_item){
7417 .type = RTE_FLOW_ITEM_TYPE_IPV6,
7418 .spec = &action_vxlan_encap_data->item_ipv6,
7419 .mask = &rte_flow_item_ipv6_mask,
7422 if (!vxlan_encap_conf.select_vlan)
7423 action_vxlan_encap_data->items[1].type =
7424 RTE_FLOW_ITEM_TYPE_VOID;
7425 if (vxlan_encap_conf.select_tos_ttl) {
7426 if (vxlan_encap_conf.select_ipv4) {
7427 static struct rte_flow_item_ipv4 ipv4_mask_tos;
7429 memcpy(&ipv4_mask_tos, &rte_flow_item_ipv4_mask,
7430 sizeof(ipv4_mask_tos));
7431 ipv4_mask_tos.hdr.type_of_service = 0xff;
7432 ipv4_mask_tos.hdr.time_to_live = 0xff;
7433 action_vxlan_encap_data->item_ipv4.hdr.type_of_service =
7434 vxlan_encap_conf.ip_tos;
7435 action_vxlan_encap_data->item_ipv4.hdr.time_to_live =
7436 vxlan_encap_conf.ip_ttl;
7437 action_vxlan_encap_data->items[2].mask =
7440 static struct rte_flow_item_ipv6 ipv6_mask_tos;
7442 memcpy(&ipv6_mask_tos, &rte_flow_item_ipv6_mask,
7443 sizeof(ipv6_mask_tos));
7444 ipv6_mask_tos.hdr.vtc_flow |=
7445 RTE_BE32(0xfful << RTE_IPV6_HDR_TC_SHIFT);
7446 ipv6_mask_tos.hdr.hop_limits = 0xff;
7447 action_vxlan_encap_data->item_ipv6.hdr.vtc_flow |=
7449 ((uint32_t)vxlan_encap_conf.ip_tos <<
7450 RTE_IPV6_HDR_TC_SHIFT);
7451 action_vxlan_encap_data->item_ipv6.hdr.hop_limits =
7452 vxlan_encap_conf.ip_ttl;
7453 action_vxlan_encap_data->items[2].mask =
7457 memcpy(action_vxlan_encap_data->item_vxlan.vni, vxlan_encap_conf.vni,
7458 RTE_DIM(vxlan_encap_conf.vni));
7462 /** Parse VXLAN encap action. */
7464 parse_vc_action_vxlan_encap(struct context *ctx, const struct token *token,
7465 const char *str, unsigned int len,
7466 void *buf, unsigned int size)
7468 struct buffer *out = buf;
7469 struct rte_flow_action *action;
7470 struct action_vxlan_encap_data *action_vxlan_encap_data;
7473 ret = parse_vc(ctx, token, str, len, buf, size);
7476 /* Nothing else to do if there is no buffer. */
7479 if (!out->args.vc.actions_n)
7481 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
7482 /* Point to selected object. */
7483 ctx->object = out->args.vc.data;
7484 ctx->objmask = NULL;
7485 action_vxlan_encap_data = ctx->object;
7486 parse_setup_vxlan_encap_data(action_vxlan_encap_data);
7487 action->conf = &action_vxlan_encap_data->conf;
7491 /** Setup NVGRE encap configuration. */
7493 parse_setup_nvgre_encap_data(struct action_nvgre_encap_data *action_nvgre_encap_data)
7495 /* Set up default configuration. */
7496 *action_nvgre_encap_data = (struct action_nvgre_encap_data){
7497 .conf = (struct rte_flow_action_nvgre_encap){
7498 .definition = action_nvgre_encap_data->items,
7502 .type = RTE_FLOW_ITEM_TYPE_ETH,
7503 .spec = &action_nvgre_encap_data->item_eth,
7504 .mask = &rte_flow_item_eth_mask,
7507 .type = RTE_FLOW_ITEM_TYPE_VLAN,
7508 .spec = &action_nvgre_encap_data->item_vlan,
7509 .mask = &rte_flow_item_vlan_mask,
7512 .type = RTE_FLOW_ITEM_TYPE_IPV4,
7513 .spec = &action_nvgre_encap_data->item_ipv4,
7514 .mask = &rte_flow_item_ipv4_mask,
7517 .type = RTE_FLOW_ITEM_TYPE_NVGRE,
7518 .spec = &action_nvgre_encap_data->item_nvgre,
7519 .mask = &rte_flow_item_nvgre_mask,
7522 .type = RTE_FLOW_ITEM_TYPE_END,
7527 .tci = nvgre_encap_conf.vlan_tci,
7531 .src_addr = nvgre_encap_conf.ipv4_src,
7532 .dst_addr = nvgre_encap_conf.ipv4_dst,
7534 .item_nvgre.c_k_s_rsvd0_ver = RTE_BE16(0x2000),
7535 .item_nvgre.protocol = RTE_BE16(RTE_ETHER_TYPE_TEB),
7536 .item_nvgre.flow_id = 0,
7538 memcpy(action_nvgre_encap_data->item_eth.dst.addr_bytes,
7539 nvgre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
7540 memcpy(action_nvgre_encap_data->item_eth.src.addr_bytes,
7541 nvgre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
7542 if (!nvgre_encap_conf.select_ipv4) {
7543 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.src_addr,
7544 &nvgre_encap_conf.ipv6_src,
7545 sizeof(nvgre_encap_conf.ipv6_src));
7546 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.dst_addr,
7547 &nvgre_encap_conf.ipv6_dst,
7548 sizeof(nvgre_encap_conf.ipv6_dst));
7549 action_nvgre_encap_data->items[2] = (struct rte_flow_item){
7550 .type = RTE_FLOW_ITEM_TYPE_IPV6,
7551 .spec = &action_nvgre_encap_data->item_ipv6,
7552 .mask = &rte_flow_item_ipv6_mask,
7555 if (!nvgre_encap_conf.select_vlan)
7556 action_nvgre_encap_data->items[1].type =
7557 RTE_FLOW_ITEM_TYPE_VOID;
7558 memcpy(action_nvgre_encap_data->item_nvgre.tni, nvgre_encap_conf.tni,
7559 RTE_DIM(nvgre_encap_conf.tni));
7563 /** Parse NVGRE encap action. */
7565 parse_vc_action_nvgre_encap(struct context *ctx, const struct token *token,
7566 const char *str, unsigned int len,
7567 void *buf, unsigned int size)
7569 struct buffer *out = buf;
7570 struct rte_flow_action *action;
7571 struct action_nvgre_encap_data *action_nvgre_encap_data;
7574 ret = parse_vc(ctx, token, str, len, buf, size);
7577 /* Nothing else to do if there is no buffer. */
7580 if (!out->args.vc.actions_n)
7582 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
7583 /* Point to selected object. */
7584 ctx->object = out->args.vc.data;
7585 ctx->objmask = NULL;
7586 action_nvgre_encap_data = ctx->object;
7587 parse_setup_nvgre_encap_data(action_nvgre_encap_data);
7588 action->conf = &action_nvgre_encap_data->conf;
7592 /** Parse l2 encap action. */
7594 parse_vc_action_l2_encap(struct context *ctx, const struct token *token,
7595 const char *str, unsigned int len,
7596 void *buf, unsigned int size)
7598 struct buffer *out = buf;
7599 struct rte_flow_action *action;
7600 struct action_raw_encap_data *action_encap_data;
7601 struct rte_flow_item_eth eth = { .type = 0, };
7602 struct rte_flow_item_vlan vlan = {
7603 .tci = mplsoudp_encap_conf.vlan_tci,
7609 ret = parse_vc(ctx, token, str, len, buf, size);
7612 /* Nothing else to do if there is no buffer. */
7615 if (!out->args.vc.actions_n)
7617 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
7618 /* Point to selected object. */
7619 ctx->object = out->args.vc.data;
7620 ctx->objmask = NULL;
7621 /* Copy the headers to the buffer. */
7622 action_encap_data = ctx->object;
7623 *action_encap_data = (struct action_raw_encap_data) {
7624 .conf = (struct rte_flow_action_raw_encap){
7625 .data = action_encap_data->data,
7629 header = action_encap_data->data;
7630 if (l2_encap_conf.select_vlan)
7631 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
7632 else if (l2_encap_conf.select_ipv4)
7633 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
7635 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
7636 memcpy(eth.dst.addr_bytes,
7637 l2_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
7638 memcpy(eth.src.addr_bytes,
7639 l2_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
7640 memcpy(header, ð, sizeof(eth));
7641 header += sizeof(eth);
7642 if (l2_encap_conf.select_vlan) {
7643 if (l2_encap_conf.select_ipv4)
7644 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
7646 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
7647 memcpy(header, &vlan, sizeof(vlan));
7648 header += sizeof(vlan);
7650 action_encap_data->conf.size = header -
7651 action_encap_data->data;
7652 action->conf = &action_encap_data->conf;
7656 /** Parse l2 decap action. */
7658 parse_vc_action_l2_decap(struct context *ctx, const struct token *token,
7659 const char *str, unsigned int len,
7660 void *buf, unsigned int size)
7662 struct buffer *out = buf;
7663 struct rte_flow_action *action;
7664 struct action_raw_decap_data *action_decap_data;
7665 struct rte_flow_item_eth eth = { .type = 0, };
7666 struct rte_flow_item_vlan vlan = {
7667 .tci = mplsoudp_encap_conf.vlan_tci,
7673 ret = parse_vc(ctx, token, str, len, buf, size);
7676 /* Nothing else to do if there is no buffer. */
7679 if (!out->args.vc.actions_n)
7681 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
7682 /* Point to selected object. */
7683 ctx->object = out->args.vc.data;
7684 ctx->objmask = NULL;
7685 /* Copy the headers to the buffer. */
7686 action_decap_data = ctx->object;
7687 *action_decap_data = (struct action_raw_decap_data) {
7688 .conf = (struct rte_flow_action_raw_decap){
7689 .data = action_decap_data->data,
7693 header = action_decap_data->data;
7694 if (l2_decap_conf.select_vlan)
7695 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
7696 memcpy(header, ð, sizeof(eth));
7697 header += sizeof(eth);
7698 if (l2_decap_conf.select_vlan) {
7699 memcpy(header, &vlan, sizeof(vlan));
7700 header += sizeof(vlan);
7702 action_decap_data->conf.size = header -
7703 action_decap_data->data;
7704 action->conf = &action_decap_data->conf;
7708 #define ETHER_TYPE_MPLS_UNICAST 0x8847
7710 /** Parse MPLSOGRE encap action. */
7712 parse_vc_action_mplsogre_encap(struct context *ctx, const struct token *token,
7713 const char *str, unsigned int len,
7714 void *buf, unsigned int size)
7716 struct buffer *out = buf;
7717 struct rte_flow_action *action;
7718 struct action_raw_encap_data *action_encap_data;
7719 struct rte_flow_item_eth eth = { .type = 0, };
7720 struct rte_flow_item_vlan vlan = {
7721 .tci = mplsogre_encap_conf.vlan_tci,
7724 struct rte_flow_item_ipv4 ipv4 = {
7726 .src_addr = mplsogre_encap_conf.ipv4_src,
7727 .dst_addr = mplsogre_encap_conf.ipv4_dst,
7728 .next_proto_id = IPPROTO_GRE,
7729 .version_ihl = RTE_IPV4_VHL_DEF,
7730 .time_to_live = IPDEFTTL,
7733 struct rte_flow_item_ipv6 ipv6 = {
7735 .proto = IPPROTO_GRE,
7736 .hop_limits = IPDEFTTL,
7739 struct rte_flow_item_gre gre = {
7740 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
7742 struct rte_flow_item_mpls mpls = {
7748 ret = parse_vc(ctx, token, str, len, buf, size);
7751 /* Nothing else to do if there is no buffer. */
7754 if (!out->args.vc.actions_n)
7756 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
7757 /* Point to selected object. */
7758 ctx->object = out->args.vc.data;
7759 ctx->objmask = NULL;
7760 /* Copy the headers to the buffer. */
7761 action_encap_data = ctx->object;
7762 *action_encap_data = (struct action_raw_encap_data) {
7763 .conf = (struct rte_flow_action_raw_encap){
7764 .data = action_encap_data->data,
7769 header = action_encap_data->data;
7770 if (mplsogre_encap_conf.select_vlan)
7771 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
7772 else if (mplsogre_encap_conf.select_ipv4)
7773 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
7775 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
7776 memcpy(eth.dst.addr_bytes,
7777 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
7778 memcpy(eth.src.addr_bytes,
7779 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
7780 memcpy(header, ð, sizeof(eth));
7781 header += sizeof(eth);
7782 if (mplsogre_encap_conf.select_vlan) {
7783 if (mplsogre_encap_conf.select_ipv4)
7784 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
7786 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
7787 memcpy(header, &vlan, sizeof(vlan));
7788 header += sizeof(vlan);
7790 if (mplsogre_encap_conf.select_ipv4) {
7791 memcpy(header, &ipv4, sizeof(ipv4));
7792 header += sizeof(ipv4);
7794 memcpy(&ipv6.hdr.src_addr,
7795 &mplsogre_encap_conf.ipv6_src,
7796 sizeof(mplsogre_encap_conf.ipv6_src));
7797 memcpy(&ipv6.hdr.dst_addr,
7798 &mplsogre_encap_conf.ipv6_dst,
7799 sizeof(mplsogre_encap_conf.ipv6_dst));
7800 memcpy(header, &ipv6, sizeof(ipv6));
7801 header += sizeof(ipv6);
7803 memcpy(header, &gre, sizeof(gre));
7804 header += sizeof(gre);
7805 memcpy(mpls.label_tc_s, mplsogre_encap_conf.label,
7806 RTE_DIM(mplsogre_encap_conf.label));
7807 mpls.label_tc_s[2] |= 0x1;
7808 memcpy(header, &mpls, sizeof(mpls));
7809 header += sizeof(mpls);
7810 action_encap_data->conf.size = header -
7811 action_encap_data->data;
7812 action->conf = &action_encap_data->conf;
7816 /** Parse MPLSOGRE decap action. */
7818 parse_vc_action_mplsogre_decap(struct context *ctx, const struct token *token,
7819 const char *str, unsigned int len,
7820 void *buf, unsigned int size)
7822 struct buffer *out = buf;
7823 struct rte_flow_action *action;
7824 struct action_raw_decap_data *action_decap_data;
7825 struct rte_flow_item_eth eth = { .type = 0, };
7826 struct rte_flow_item_vlan vlan = {.tci = 0};
7827 struct rte_flow_item_ipv4 ipv4 = {
7829 .next_proto_id = IPPROTO_GRE,
7832 struct rte_flow_item_ipv6 ipv6 = {
7834 .proto = IPPROTO_GRE,
7837 struct rte_flow_item_gre gre = {
7838 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
7840 struct rte_flow_item_mpls mpls;
7844 ret = parse_vc(ctx, token, str, len, buf, size);
7847 /* Nothing else to do if there is no buffer. */
7850 if (!out->args.vc.actions_n)
7852 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
7853 /* Point to selected object. */
7854 ctx->object = out->args.vc.data;
7855 ctx->objmask = NULL;
7856 /* Copy the headers to the buffer. */
7857 action_decap_data = ctx->object;
7858 *action_decap_data = (struct action_raw_decap_data) {
7859 .conf = (struct rte_flow_action_raw_decap){
7860 .data = action_decap_data->data,
7864 header = action_decap_data->data;
7865 if (mplsogre_decap_conf.select_vlan)
7866 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
7867 else if (mplsogre_encap_conf.select_ipv4)
7868 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
7870 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
7871 memcpy(eth.dst.addr_bytes,
7872 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
7873 memcpy(eth.src.addr_bytes,
7874 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
7875 memcpy(header, ð, sizeof(eth));
7876 header += sizeof(eth);
7877 if (mplsogre_encap_conf.select_vlan) {
7878 if (mplsogre_encap_conf.select_ipv4)
7879 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
7881 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
7882 memcpy(header, &vlan, sizeof(vlan));
7883 header += sizeof(vlan);
7885 if (mplsogre_encap_conf.select_ipv4) {
7886 memcpy(header, &ipv4, sizeof(ipv4));
7887 header += sizeof(ipv4);
7889 memcpy(header, &ipv6, sizeof(ipv6));
7890 header += sizeof(ipv6);
7892 memcpy(header, &gre, sizeof(gre));
7893 header += sizeof(gre);
7894 memset(&mpls, 0, sizeof(mpls));
7895 memcpy(header, &mpls, sizeof(mpls));
7896 header += sizeof(mpls);
7897 action_decap_data->conf.size = header -
7898 action_decap_data->data;
7899 action->conf = &action_decap_data->conf;
7903 /** Parse MPLSOUDP encap action. */
7905 parse_vc_action_mplsoudp_encap(struct context *ctx, const struct token *token,
7906 const char *str, unsigned int len,
7907 void *buf, unsigned int size)
7909 struct buffer *out = buf;
7910 struct rte_flow_action *action;
7911 struct action_raw_encap_data *action_encap_data;
7912 struct rte_flow_item_eth eth = { .type = 0, };
7913 struct rte_flow_item_vlan vlan = {
7914 .tci = mplsoudp_encap_conf.vlan_tci,
7917 struct rte_flow_item_ipv4 ipv4 = {
7919 .src_addr = mplsoudp_encap_conf.ipv4_src,
7920 .dst_addr = mplsoudp_encap_conf.ipv4_dst,
7921 .next_proto_id = IPPROTO_UDP,
7922 .version_ihl = RTE_IPV4_VHL_DEF,
7923 .time_to_live = IPDEFTTL,
7926 struct rte_flow_item_ipv6 ipv6 = {
7928 .proto = IPPROTO_UDP,
7929 .hop_limits = IPDEFTTL,
7932 struct rte_flow_item_udp udp = {
7934 .src_port = mplsoudp_encap_conf.udp_src,
7935 .dst_port = mplsoudp_encap_conf.udp_dst,
7938 struct rte_flow_item_mpls mpls;
7942 ret = parse_vc(ctx, token, str, len, buf, size);
7945 /* Nothing else to do if there is no buffer. */
7948 if (!out->args.vc.actions_n)
7950 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
7951 /* Point to selected object. */
7952 ctx->object = out->args.vc.data;
7953 ctx->objmask = NULL;
7954 /* Copy the headers to the buffer. */
7955 action_encap_data = ctx->object;
7956 *action_encap_data = (struct action_raw_encap_data) {
7957 .conf = (struct rte_flow_action_raw_encap){
7958 .data = action_encap_data->data,
7963 header = action_encap_data->data;
7964 if (mplsoudp_encap_conf.select_vlan)
7965 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
7966 else if (mplsoudp_encap_conf.select_ipv4)
7967 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
7969 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
7970 memcpy(eth.dst.addr_bytes,
7971 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
7972 memcpy(eth.src.addr_bytes,
7973 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
7974 memcpy(header, ð, sizeof(eth));
7975 header += sizeof(eth);
7976 if (mplsoudp_encap_conf.select_vlan) {
7977 if (mplsoudp_encap_conf.select_ipv4)
7978 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
7980 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
7981 memcpy(header, &vlan, sizeof(vlan));
7982 header += sizeof(vlan);
7984 if (mplsoudp_encap_conf.select_ipv4) {
7985 memcpy(header, &ipv4, sizeof(ipv4));
7986 header += sizeof(ipv4);
7988 memcpy(&ipv6.hdr.src_addr,
7989 &mplsoudp_encap_conf.ipv6_src,
7990 sizeof(mplsoudp_encap_conf.ipv6_src));
7991 memcpy(&ipv6.hdr.dst_addr,
7992 &mplsoudp_encap_conf.ipv6_dst,
7993 sizeof(mplsoudp_encap_conf.ipv6_dst));
7994 memcpy(header, &ipv6, sizeof(ipv6));
7995 header += sizeof(ipv6);
7997 memcpy(header, &udp, sizeof(udp));
7998 header += sizeof(udp);
7999 memcpy(mpls.label_tc_s, mplsoudp_encap_conf.label,
8000 RTE_DIM(mplsoudp_encap_conf.label));
8001 mpls.label_tc_s[2] |= 0x1;
8002 memcpy(header, &mpls, sizeof(mpls));
8003 header += sizeof(mpls);
8004 action_encap_data->conf.size = header -
8005 action_encap_data->data;
8006 action->conf = &action_encap_data->conf;
8010 /** Parse MPLSOUDP decap action. */
8012 parse_vc_action_mplsoudp_decap(struct context *ctx, const struct token *token,
8013 const char *str, unsigned int len,
8014 void *buf, unsigned int size)
8016 struct buffer *out = buf;
8017 struct rte_flow_action *action;
8018 struct action_raw_decap_data *action_decap_data;
8019 struct rte_flow_item_eth eth = { .type = 0, };
8020 struct rte_flow_item_vlan vlan = {.tci = 0};
8021 struct rte_flow_item_ipv4 ipv4 = {
8023 .next_proto_id = IPPROTO_UDP,
8026 struct rte_flow_item_ipv6 ipv6 = {
8028 .proto = IPPROTO_UDP,
8031 struct rte_flow_item_udp udp = {
8033 .dst_port = rte_cpu_to_be_16(6635),
8036 struct rte_flow_item_mpls mpls;
8040 ret = parse_vc(ctx, token, str, len, buf, size);
8043 /* Nothing else to do if there is no buffer. */
8046 if (!out->args.vc.actions_n)
8048 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
8049 /* Point to selected object. */
8050 ctx->object = out->args.vc.data;
8051 ctx->objmask = NULL;
8052 /* Copy the headers to the buffer. */
8053 action_decap_data = ctx->object;
8054 *action_decap_data = (struct action_raw_decap_data) {
8055 .conf = (struct rte_flow_action_raw_decap){
8056 .data = action_decap_data->data,
8060 header = action_decap_data->data;
8061 if (mplsoudp_decap_conf.select_vlan)
8062 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
8063 else if (mplsoudp_encap_conf.select_ipv4)
8064 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
8066 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
8067 memcpy(eth.dst.addr_bytes,
8068 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
8069 memcpy(eth.src.addr_bytes,
8070 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
8071 memcpy(header, ð, sizeof(eth));
8072 header += sizeof(eth);
8073 if (mplsoudp_encap_conf.select_vlan) {
8074 if (mplsoudp_encap_conf.select_ipv4)
8075 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
8077 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
8078 memcpy(header, &vlan, sizeof(vlan));
8079 header += sizeof(vlan);
8081 if (mplsoudp_encap_conf.select_ipv4) {
8082 memcpy(header, &ipv4, sizeof(ipv4));
8083 header += sizeof(ipv4);
8085 memcpy(header, &ipv6, sizeof(ipv6));
8086 header += sizeof(ipv6);
8088 memcpy(header, &udp, sizeof(udp));
8089 header += sizeof(udp);
8090 memset(&mpls, 0, sizeof(mpls));
8091 memcpy(header, &mpls, sizeof(mpls));
8092 header += sizeof(mpls);
8093 action_decap_data->conf.size = header -
8094 action_decap_data->data;
8095 action->conf = &action_decap_data->conf;
8100 parse_vc_action_raw_decap_index(struct context *ctx, const struct token *token,
8101 const char *str, unsigned int len, void *buf,
8104 struct action_raw_decap_data *action_raw_decap_data;
8105 struct rte_flow_action *action;
8106 const struct arg *arg;
8107 struct buffer *out = buf;
8111 RTE_SET_USED(token);
8114 arg = ARGS_ENTRY_ARB_BOUNDED
8115 (offsetof(struct action_raw_decap_data, idx),
8116 sizeof(((struct action_raw_decap_data *)0)->idx),
8117 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
8118 if (push_args(ctx, arg))
8120 ret = parse_int(ctx, token, str, len, NULL, 0);
8127 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
8128 action_raw_decap_data = ctx->object;
8129 idx = action_raw_decap_data->idx;
8130 action_raw_decap_data->conf.data = raw_decap_confs[idx].data;
8131 action_raw_decap_data->conf.size = raw_decap_confs[idx].size;
8132 action->conf = &action_raw_decap_data->conf;
8138 parse_vc_action_raw_encap_index(struct context *ctx, const struct token *token,
8139 const char *str, unsigned int len, void *buf,
8142 struct action_raw_encap_data *action_raw_encap_data;
8143 struct rte_flow_action *action;
8144 const struct arg *arg;
8145 struct buffer *out = buf;
8149 RTE_SET_USED(token);
8152 if (ctx->curr != ACTION_RAW_ENCAP_INDEX_VALUE)
8154 arg = ARGS_ENTRY_ARB_BOUNDED
8155 (offsetof(struct action_raw_encap_data, idx),
8156 sizeof(((struct action_raw_encap_data *)0)->idx),
8157 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
8158 if (push_args(ctx, arg))
8160 ret = parse_int(ctx, token, str, len, NULL, 0);
8167 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
8168 action_raw_encap_data = ctx->object;
8169 idx = action_raw_encap_data->idx;
8170 action_raw_encap_data->conf.data = raw_encap_confs[idx].data;
8171 action_raw_encap_data->conf.size = raw_encap_confs[idx].size;
8172 action_raw_encap_data->conf.preserve = NULL;
8173 action->conf = &action_raw_encap_data->conf;
8178 parse_vc_action_raw_encap(struct context *ctx, const struct token *token,
8179 const char *str, unsigned int len, void *buf,
8182 struct buffer *out = buf;
8183 struct rte_flow_action *action;
8184 struct action_raw_encap_data *action_raw_encap_data = NULL;
8187 ret = parse_vc(ctx, token, str, len, buf, size);
8190 /* Nothing else to do if there is no buffer. */
8193 if (!out->args.vc.actions_n)
8195 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
8196 /* Point to selected object. */
8197 ctx->object = out->args.vc.data;
8198 ctx->objmask = NULL;
8199 /* Copy the headers to the buffer. */
8200 action_raw_encap_data = ctx->object;
8201 action_raw_encap_data->conf.data = raw_encap_confs[0].data;
8202 action_raw_encap_data->conf.preserve = NULL;
8203 action_raw_encap_data->conf.size = raw_encap_confs[0].size;
8204 action->conf = &action_raw_encap_data->conf;
8209 parse_vc_action_raw_decap(struct context *ctx, const struct token *token,
8210 const char *str, unsigned int len, void *buf,
8213 struct buffer *out = buf;
8214 struct rte_flow_action *action;
8215 struct action_raw_decap_data *action_raw_decap_data = NULL;
8218 ret = parse_vc(ctx, token, str, len, buf, size);
8221 /* Nothing else to do if there is no buffer. */
8224 if (!out->args.vc.actions_n)
8226 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
8227 /* Point to selected object. */
8228 ctx->object = out->args.vc.data;
8229 ctx->objmask = NULL;
8230 /* Copy the headers to the buffer. */
8231 action_raw_decap_data = ctx->object;
8232 action_raw_decap_data->conf.data = raw_decap_confs[0].data;
8233 action_raw_decap_data->conf.size = raw_decap_confs[0].size;
8234 action->conf = &action_raw_decap_data->conf;
8239 parse_vc_action_set_meta(struct context *ctx, const struct token *token,
8240 const char *str, unsigned int len, void *buf,
8245 ret = parse_vc(ctx, token, str, len, buf, size);
8248 ret = rte_flow_dynf_metadata_register();
8255 parse_vc_action_sample(struct context *ctx, const struct token *token,
8256 const char *str, unsigned int len, void *buf,
8259 struct buffer *out = buf;
8260 struct rte_flow_action *action;
8261 struct action_sample_data *action_sample_data = NULL;
8262 static struct rte_flow_action end_action = {
8263 RTE_FLOW_ACTION_TYPE_END, 0
8267 ret = parse_vc(ctx, token, str, len, buf, size);
8270 /* Nothing else to do if there is no buffer. */
8273 if (!out->args.vc.actions_n)
8275 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
8276 /* Point to selected object. */
8277 ctx->object = out->args.vc.data;
8278 ctx->objmask = NULL;
8279 /* Copy the headers to the buffer. */
8280 action_sample_data = ctx->object;
8281 action_sample_data->conf.actions = &end_action;
8282 action->conf = &action_sample_data->conf;
8287 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
8288 const char *str, unsigned int len, void *buf,
8291 struct action_sample_data *action_sample_data;
8292 struct rte_flow_action *action;
8293 const struct arg *arg;
8294 struct buffer *out = buf;
8298 RTE_SET_USED(token);
8301 if (ctx->curr != ACTION_SAMPLE_INDEX_VALUE)
8303 arg = ARGS_ENTRY_ARB_BOUNDED
8304 (offsetof(struct action_sample_data, idx),
8305 sizeof(((struct action_sample_data *)0)->idx),
8306 0, RAW_SAMPLE_CONFS_MAX_NUM - 1);
8307 if (push_args(ctx, arg))
8309 ret = parse_int(ctx, token, str, len, NULL, 0);
8316 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
8317 action_sample_data = ctx->object;
8318 idx = action_sample_data->idx;
8319 action_sample_data->conf.actions = raw_sample_confs[idx].data;
8320 action->conf = &action_sample_data->conf;
8324 /** Parse operation for modify_field command. */
8326 parse_vc_modify_field_op(struct context *ctx, const struct token *token,
8327 const char *str, unsigned int len, void *buf,
8330 struct rte_flow_action_modify_field *action_modify_field;
8336 if (ctx->curr != ACTION_MODIFY_FIELD_OP_VALUE)
8338 for (i = 0; modify_field_ops[i]; ++i)
8339 if (!strcmp_partial(modify_field_ops[i], str, len))
8341 if (!modify_field_ops[i])
8345 action_modify_field = ctx->object;
8346 action_modify_field->operation = (enum rte_flow_modify_op)i;
8350 /** Parse id for modify_field command. */
8352 parse_vc_modify_field_id(struct context *ctx, const struct token *token,
8353 const char *str, unsigned int len, void *buf,
8356 struct rte_flow_action_modify_field *action_modify_field;
8362 if (ctx->curr != ACTION_MODIFY_FIELD_DST_TYPE_VALUE &&
8363 ctx->curr != ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)
8365 for (i = 0; modify_field_ids[i]; ++i)
8366 if (!strcmp_partial(modify_field_ids[i], str, len))
8368 if (!modify_field_ids[i])
8372 action_modify_field = ctx->object;
8373 if (ctx->curr == ACTION_MODIFY_FIELD_DST_TYPE_VALUE)
8374 action_modify_field->dst.field = (enum rte_flow_field_id)i;
8376 action_modify_field->src.field = (enum rte_flow_field_id)i;
8380 /** Parse the conntrack update, not a rte_flow_action. */
8382 parse_vc_action_conntrack_update(struct context *ctx, const struct token *token,
8383 const char *str, unsigned int len, void *buf,
8386 struct buffer *out = buf;
8387 struct rte_flow_modify_conntrack *ct_modify = NULL;
8390 if (ctx->curr != ACTION_CONNTRACK_UPDATE_CTX &&
8391 ctx->curr != ACTION_CONNTRACK_UPDATE_DIR)
8393 /* Token name must match. */
8394 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8396 /* Nothing else to do if there is no buffer. */
8399 ct_modify = (struct rte_flow_modify_conntrack *)out->args.vc.data;
8400 if (ctx->curr == ACTION_CONNTRACK_UPDATE_DIR) {
8401 ct_modify->new_ct.is_original_dir =
8402 conntrack_context.is_original_dir;
8403 ct_modify->direction = 1;
8407 old_dir = ct_modify->new_ct.is_original_dir;
8408 memcpy(&ct_modify->new_ct, &conntrack_context,
8409 sizeof(conntrack_context));
8410 ct_modify->new_ct.is_original_dir = old_dir;
8411 ct_modify->state = 1;
8416 /** Parse tokens for destroy command. */
8418 parse_destroy(struct context *ctx, const struct token *token,
8419 const char *str, unsigned int len,
8420 void *buf, unsigned int size)
8422 struct buffer *out = buf;
8424 /* Token name must match. */
8425 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8427 /* Nothing else to do if there is no buffer. */
8430 if (!out->command) {
8431 if (ctx->curr != DESTROY)
8433 if (sizeof(*out) > size)
8435 out->command = ctx->curr;
8438 ctx->objmask = NULL;
8439 out->args.destroy.rule =
8440 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8444 if (((uint8_t *)(out->args.destroy.rule + out->args.destroy.rule_n) +
8445 sizeof(*out->args.destroy.rule)) > (uint8_t *)out + size)
8448 ctx->object = out->args.destroy.rule + out->args.destroy.rule_n++;
8449 ctx->objmask = NULL;
8453 /** Parse tokens for flush command. */
8455 parse_flush(struct context *ctx, const struct token *token,
8456 const char *str, unsigned int len,
8457 void *buf, unsigned int size)
8459 struct buffer *out = buf;
8461 /* Token name must match. */
8462 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8464 /* Nothing else to do if there is no buffer. */
8467 if (!out->command) {
8468 if (ctx->curr != FLUSH)
8470 if (sizeof(*out) > size)
8472 out->command = ctx->curr;
8475 ctx->objmask = NULL;
8480 /** Parse tokens for dump command. */
8482 parse_dump(struct context *ctx, const struct token *token,
8483 const char *str, unsigned int len,
8484 void *buf, unsigned int size)
8486 struct buffer *out = buf;
8488 /* Token name must match. */
8489 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8491 /* Nothing else to do if there is no buffer. */
8494 if (!out->command) {
8495 if (ctx->curr != DUMP)
8497 if (sizeof(*out) > size)
8499 out->command = ctx->curr;
8502 ctx->objmask = NULL;
8505 switch (ctx->curr) {
8508 out->args.dump.mode = (ctx->curr == DUMP_ALL) ? true : false;
8509 out->command = ctx->curr;
8512 ctx->objmask = NULL;
8519 /** Parse tokens for query command. */
8521 parse_query(struct context *ctx, const struct token *token,
8522 const char *str, unsigned int len,
8523 void *buf, unsigned int size)
8525 struct buffer *out = buf;
8527 /* Token name must match. */
8528 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8530 /* Nothing else to do if there is no buffer. */
8533 if (!out->command) {
8534 if (ctx->curr != QUERY)
8536 if (sizeof(*out) > size)
8538 out->command = ctx->curr;
8541 ctx->objmask = NULL;
8546 /** Parse action names. */
8548 parse_action(struct context *ctx, const struct token *token,
8549 const char *str, unsigned int len,
8550 void *buf, unsigned int size)
8552 struct buffer *out = buf;
8553 const struct arg *arg = pop_args(ctx);
8557 /* Argument is expected. */
8560 /* Parse action name. */
8561 for (i = 0; next_action[i]; ++i) {
8562 const struct parse_action_priv *priv;
8564 token = &token_list[next_action[i]];
8565 if (strcmp_partial(token->name, str, len))
8571 memcpy((uint8_t *)ctx->object + arg->offset,
8577 push_args(ctx, arg);
8581 /** Parse tokens for list command. */
8583 parse_list(struct context *ctx, const struct token *token,
8584 const char *str, unsigned int len,
8585 void *buf, unsigned int size)
8587 struct buffer *out = buf;
8589 /* Token name must match. */
8590 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8592 /* Nothing else to do if there is no buffer. */
8595 if (!out->command) {
8596 if (ctx->curr != LIST)
8598 if (sizeof(*out) > size)
8600 out->command = ctx->curr;
8603 ctx->objmask = NULL;
8604 out->args.list.group =
8605 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8609 if (((uint8_t *)(out->args.list.group + out->args.list.group_n) +
8610 sizeof(*out->args.list.group)) > (uint8_t *)out + size)
8613 ctx->object = out->args.list.group + out->args.list.group_n++;
8614 ctx->objmask = NULL;
8618 /** Parse tokens for list all aged flows command. */
8620 parse_aged(struct context *ctx, const struct token *token,
8621 const char *str, unsigned int len,
8622 void *buf, unsigned int size)
8624 struct buffer *out = buf;
8626 /* Token name must match. */
8627 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8629 /* Nothing else to do if there is no buffer. */
8632 if (!out->command) {
8633 if (ctx->curr != AGED)
8635 if (sizeof(*out) > size)
8637 out->command = ctx->curr;
8640 ctx->objmask = NULL;
8642 if (ctx->curr == AGED_DESTROY)
8643 out->args.aged.destroy = 1;
8647 /** Parse tokens for isolate command. */
8649 parse_isolate(struct context *ctx, const struct token *token,
8650 const char *str, unsigned int len,
8651 void *buf, unsigned int size)
8653 struct buffer *out = buf;
8655 /* Token name must match. */
8656 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8658 /* Nothing else to do if there is no buffer. */
8661 if (!out->command) {
8662 if (ctx->curr != ISOLATE)
8664 if (sizeof(*out) > size)
8666 out->command = ctx->curr;
8669 ctx->objmask = NULL;
8674 /** Parse tokens for info/configure command. */
8676 parse_configure(struct context *ctx, const struct token *token,
8677 const char *str, unsigned int len,
8678 void *buf, unsigned int size)
8680 struct buffer *out = buf;
8682 /* Token name must match. */
8683 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8685 /* Nothing else to do if there is no buffer. */
8688 if (!out->command) {
8689 if (ctx->curr != INFO && ctx->curr != CONFIGURE)
8691 if (sizeof(*out) > size)
8693 out->command = ctx->curr;
8696 ctx->objmask = NULL;
8701 /** Parse tokens for template create command. */
8703 parse_template(struct context *ctx, const struct token *token,
8704 const char *str, unsigned int len,
8705 void *buf, unsigned int size)
8707 struct buffer *out = buf;
8709 /* Token name must match. */
8710 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8712 /* Nothing else to do if there is no buffer. */
8715 if (!out->command) {
8716 if (ctx->curr != PATTERN_TEMPLATE &&
8717 ctx->curr != ACTIONS_TEMPLATE)
8719 if (sizeof(*out) > size)
8721 out->command = ctx->curr;
8724 ctx->objmask = NULL;
8725 out->args.vc.data = (uint8_t *)out + size;
8728 switch (ctx->curr) {
8729 case PATTERN_TEMPLATE_CREATE:
8730 out->args.vc.pattern =
8731 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8733 out->args.vc.pat_templ_id = UINT32_MAX;
8734 out->command = ctx->curr;
8737 ctx->objmask = NULL;
8739 case PATTERN_TEMPLATE_EGRESS:
8740 out->args.vc.attr.egress = 1;
8742 case PATTERN_TEMPLATE_INGRESS:
8743 out->args.vc.attr.ingress = 1;
8745 case PATTERN_TEMPLATE_TRANSFER:
8746 out->args.vc.attr.transfer = 1;
8748 case ACTIONS_TEMPLATE_CREATE:
8749 out->args.vc.act_templ_id = UINT32_MAX;
8750 out->command = ctx->curr;
8753 ctx->objmask = NULL;
8755 case ACTIONS_TEMPLATE_SPEC:
8756 out->args.vc.actions =
8757 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8759 ctx->object = out->args.vc.actions;
8760 ctx->objmask = NULL;
8762 case ACTIONS_TEMPLATE_MASK:
8763 out->args.vc.masks =
8764 (void *)RTE_ALIGN_CEIL((uintptr_t)
8765 (out->args.vc.actions +
8766 out->args.vc.actions_n),
8768 ctx->object = out->args.vc.masks;
8769 ctx->objmask = NULL;
8771 case ACTIONS_TEMPLATE_EGRESS:
8772 out->args.vc.attr.egress = 1;
8774 case ACTIONS_TEMPLATE_INGRESS:
8775 out->args.vc.attr.ingress = 1;
8777 case ACTIONS_TEMPLATE_TRANSFER:
8778 out->args.vc.attr.transfer = 1;
8785 /** Parse tokens for template destroy command. */
8787 parse_template_destroy(struct context *ctx, const struct token *token,
8788 const char *str, unsigned int len,
8789 void *buf, unsigned int size)
8791 struct buffer *out = buf;
8792 uint32_t *template_id;
8794 /* Token name must match. */
8795 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8797 /* Nothing else to do if there is no buffer. */
8800 if (!out->command ||
8801 out->command == PATTERN_TEMPLATE ||
8802 out->command == ACTIONS_TEMPLATE) {
8803 if (ctx->curr != PATTERN_TEMPLATE_DESTROY &&
8804 ctx->curr != ACTIONS_TEMPLATE_DESTROY)
8806 if (sizeof(*out) > size)
8808 out->command = ctx->curr;
8811 ctx->objmask = NULL;
8812 out->args.templ_destroy.template_id =
8813 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8817 template_id = out->args.templ_destroy.template_id
8818 + out->args.templ_destroy.template_id_n++;
8819 if ((uint8_t *)template_id > (uint8_t *)out + size)
8822 ctx->object = template_id;
8823 ctx->objmask = NULL;
8827 /** Parse tokens for table create command. */
8829 parse_table(struct context *ctx, const struct token *token,
8830 const char *str, unsigned int len,
8831 void *buf, unsigned int size)
8833 struct buffer *out = buf;
8834 uint32_t *template_id;
8836 /* Token name must match. */
8837 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8839 /* Nothing else to do if there is no buffer. */
8842 if (!out->command) {
8843 if (ctx->curr != TABLE)
8845 if (sizeof(*out) > size)
8847 out->command = ctx->curr;
8850 ctx->objmask = NULL;
8853 switch (ctx->curr) {
8855 out->command = ctx->curr;
8858 ctx->objmask = NULL;
8859 out->args.table.id = UINT32_MAX;
8861 case TABLE_PATTERN_TEMPLATE:
8862 out->args.table.pat_templ_id =
8863 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8865 template_id = out->args.table.pat_templ_id
8866 + out->args.table.pat_templ_id_n++;
8867 if ((uint8_t *)template_id > (uint8_t *)out + size)
8870 ctx->object = template_id;
8871 ctx->objmask = NULL;
8873 case TABLE_ACTIONS_TEMPLATE:
8874 out->args.table.act_templ_id =
8875 (void *)RTE_ALIGN_CEIL((uintptr_t)
8876 (out->args.table.pat_templ_id +
8877 out->args.table.pat_templ_id_n),
8879 template_id = out->args.table.act_templ_id
8880 + out->args.table.act_templ_id_n++;
8881 if ((uint8_t *)template_id > (uint8_t *)out + size)
8884 ctx->object = template_id;
8885 ctx->objmask = NULL;
8888 out->args.table.attr.flow_attr.ingress = 1;
8891 out->args.table.attr.flow_attr.egress = 1;
8893 case TABLE_TRANSFER:
8894 out->args.table.attr.flow_attr.transfer = 1;
8901 /** Parse tokens for table destroy command. */
8903 parse_table_destroy(struct context *ctx, const struct token *token,
8904 const char *str, unsigned int len,
8905 void *buf, unsigned int size)
8907 struct buffer *out = buf;
8910 /* Token name must match. */
8911 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8913 /* Nothing else to do if there is no buffer. */
8916 if (!out->command || out->command == TABLE) {
8917 if (ctx->curr != TABLE_DESTROY)
8919 if (sizeof(*out) > size)
8921 out->command = ctx->curr;
8924 ctx->objmask = NULL;
8925 out->args.table_destroy.table_id =
8926 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8930 table_id = out->args.table_destroy.table_id
8931 + out->args.table_destroy.table_id_n++;
8932 if ((uint8_t *)table_id > (uint8_t *)out + size)
8935 ctx->object = table_id;
8936 ctx->objmask = NULL;
8940 /** Parse tokens for queue create commands. */
8942 parse_qo(struct context *ctx, const struct token *token,
8943 const char *str, unsigned int len,
8944 void *buf, unsigned int size)
8946 struct buffer *out = buf;
8948 /* Token name must match. */
8949 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8951 /* Nothing else to do if there is no buffer. */
8954 if (!out->command) {
8955 if (ctx->curr != QUEUE)
8957 if (sizeof(*out) > size)
8959 out->command = ctx->curr;
8962 ctx->objmask = NULL;
8963 out->args.vc.data = (uint8_t *)out + size;
8966 switch (ctx->curr) {
8968 out->command = ctx->curr;
8971 ctx->objmask = NULL;
8973 case QUEUE_TEMPLATE_TABLE:
8974 case QUEUE_PATTERN_TEMPLATE:
8975 case QUEUE_ACTIONS_TEMPLATE:
8976 case QUEUE_CREATE_POSTPONE:
8979 out->args.vc.pattern =
8980 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8982 ctx->object = out->args.vc.pattern;
8983 ctx->objmask = NULL;
8986 out->args.vc.actions =
8987 (void *)RTE_ALIGN_CEIL((uintptr_t)
8988 (out->args.vc.pattern +
8989 out->args.vc.pattern_n),
8991 ctx->object = out->args.vc.actions;
8992 ctx->objmask = NULL;
8999 /** Parse tokens for queue destroy command. */
9001 parse_qo_destroy(struct context *ctx, const struct token *token,
9002 const char *str, unsigned int len,
9003 void *buf, unsigned int size)
9005 struct buffer *out = buf;
9008 /* Token name must match. */
9009 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
9011 /* Nothing else to do if there is no buffer. */
9014 if (!out->command || out->command == QUEUE) {
9015 if (ctx->curr != QUEUE_DESTROY)
9017 if (sizeof(*out) > size)
9019 out->command = ctx->curr;
9022 ctx->objmask = NULL;
9023 out->args.destroy.rule =
9024 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
9028 switch (ctx->curr) {
9029 case QUEUE_DESTROY_ID:
9030 flow_id = out->args.destroy.rule
9031 + out->args.destroy.rule_n++;
9032 if ((uint8_t *)flow_id > (uint8_t *)out + size)
9035 ctx->object = flow_id;
9036 ctx->objmask = NULL;
9038 case QUEUE_DESTROY_POSTPONE:
9045 /** Parse tokens for push queue command. */
9047 parse_push(struct context *ctx, const struct token *token,
9048 const char *str, unsigned int len,
9049 void *buf, unsigned int size)
9051 struct buffer *out = buf;
9053 /* Token name must match. */
9054 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
9056 /* Nothing else to do if there is no buffer. */
9059 if (!out->command) {
9060 if (ctx->curr != PUSH)
9062 if (sizeof(*out) > size)
9064 out->command = ctx->curr;
9067 ctx->objmask = NULL;
9068 out->args.vc.data = (uint8_t *)out + size;
9073 /** Parse tokens for pull command. */
9075 parse_pull(struct context *ctx, const struct token *token,
9076 const char *str, unsigned int len,
9077 void *buf, unsigned int size)
9079 struct buffer *out = buf;
9081 /* Token name must match. */
9082 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
9084 /* Nothing else to do if there is no buffer. */
9087 if (!out->command) {
9088 if (ctx->curr != PULL)
9090 if (sizeof(*out) > size)
9092 out->command = ctx->curr;
9095 ctx->objmask = NULL;
9096 out->args.vc.data = (uint8_t *)out + size;
9102 parse_flex(struct context *ctx, const struct token *token,
9103 const char *str, unsigned int len,
9104 void *buf, unsigned int size)
9106 struct buffer *out = buf;
9108 /* Token name must match. */
9109 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
9111 /* Nothing else to do if there is no buffer. */
9114 if (out->command == ZERO) {
9115 if (ctx->curr != FLEX)
9117 if (sizeof(*out) > size)
9119 out->command = ctx->curr;
9122 ctx->objmask = NULL;
9124 switch (ctx->curr) {
9127 case FLEX_ITEM_INIT:
9128 case FLEX_ITEM_CREATE:
9129 case FLEX_ITEM_DESTROY:
9130 out->command = ctx->curr;
9139 parse_tunnel(struct context *ctx, const struct token *token,
9140 const char *str, unsigned int len,
9141 void *buf, unsigned int size)
9143 struct buffer *out = buf;
9145 /* Token name must match. */
9146 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
9148 /* Nothing else to do if there is no buffer. */
9151 if (!out->command) {
9152 if (ctx->curr != TUNNEL)
9154 if (sizeof(*out) > size)
9156 out->command = ctx->curr;
9159 ctx->objmask = NULL;
9161 switch (ctx->curr) {
9165 case TUNNEL_DESTROY:
9167 out->command = ctx->curr;
9169 case TUNNEL_CREATE_TYPE:
9170 case TUNNEL_DESTROY_ID:
9171 ctx->object = &out->args.vc.tunnel_ops;
9180 * Parse signed/unsigned integers 8 to 64-bit long.
9182 * Last argument (ctx->args) is retrieved to determine integer type and
9186 parse_int(struct context *ctx, const struct token *token,
9187 const char *str, unsigned int len,
9188 void *buf, unsigned int size)
9190 const struct arg *arg = pop_args(ctx);
9195 /* Argument is expected. */
9200 (uintmax_t)strtoimax(str, &end, 0) :
9201 strtoumax(str, &end, 0);
9202 if (errno || (size_t)(end - str) != len)
9205 ((arg->sign && ((intmax_t)u < (intmax_t)arg->min ||
9206 (intmax_t)u > (intmax_t)arg->max)) ||
9207 (!arg->sign && (u < arg->min || u > arg->max))))
9212 if (!arg_entry_bf_fill(ctx->object, u, arg) ||
9213 !arg_entry_bf_fill(ctx->objmask, -1, arg))
9217 buf = (uint8_t *)ctx->object + arg->offset;
9219 if (u > RTE_LEN2MASK(size * CHAR_BIT, uint64_t))
9223 case sizeof(uint8_t):
9224 *(uint8_t *)buf = u;
9226 case sizeof(uint16_t):
9227 *(uint16_t *)buf = arg->hton ? rte_cpu_to_be_16(u) : u;
9229 case sizeof(uint8_t [3]):
9230 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
9232 ((uint8_t *)buf)[0] = u;
9233 ((uint8_t *)buf)[1] = u >> 8;
9234 ((uint8_t *)buf)[2] = u >> 16;
9238 ((uint8_t *)buf)[0] = u >> 16;
9239 ((uint8_t *)buf)[1] = u >> 8;
9240 ((uint8_t *)buf)[2] = u;
9242 case sizeof(uint32_t):
9243 *(uint32_t *)buf = arg->hton ? rte_cpu_to_be_32(u) : u;
9245 case sizeof(uint64_t):
9246 *(uint64_t *)buf = arg->hton ? rte_cpu_to_be_64(u) : u;
9251 if (ctx->objmask && buf != (uint8_t *)ctx->objmask + arg->offset) {
9253 buf = (uint8_t *)ctx->objmask + arg->offset;
9258 push_args(ctx, arg);
9265 * Three arguments (ctx->args) are retrieved from the stack to store data,
9266 * its actual length and address (in that order).
9269 parse_string(struct context *ctx, const struct token *token,
9270 const char *str, unsigned int len,
9271 void *buf, unsigned int size)
9273 const struct arg *arg_data = pop_args(ctx);
9274 const struct arg *arg_len = pop_args(ctx);
9275 const struct arg *arg_addr = pop_args(ctx);
9276 char tmp[16]; /* Ought to be enough. */
9279 /* Arguments are expected. */
9283 push_args(ctx, arg_data);
9287 push_args(ctx, arg_len);
9288 push_args(ctx, arg_data);
9291 size = arg_data->size;
9292 /* Bit-mask fill is not supported. */
9293 if (arg_data->mask || size < len)
9297 /* Let parse_int() fill length information first. */
9298 ret = snprintf(tmp, sizeof(tmp), "%u", len);
9301 push_args(ctx, arg_len);
9302 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
9307 buf = (uint8_t *)ctx->object + arg_data->offset;
9308 /* Output buffer is not necessarily NUL-terminated. */
9309 memcpy(buf, str, len);
9310 memset((uint8_t *)buf + len, 0x00, size - len);
9312 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
9313 /* Save address if requested. */
9314 if (arg_addr->size) {
9315 memcpy((uint8_t *)ctx->object + arg_addr->offset,
9317 (uint8_t *)ctx->object + arg_data->offset
9321 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
9323 (uint8_t *)ctx->objmask + arg_data->offset
9329 push_args(ctx, arg_addr);
9330 push_args(ctx, arg_len);
9331 push_args(ctx, arg_data);
9336 parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
9338 const uint8_t *head = dst;
9346 /* Convert chars to bytes */
9348 char tmp[3], *end = tmp;
9349 uint32_t read_lim = left & 1 ? 1 : 2;
9351 snprintf(tmp, read_lim + 1, "%s", src);
9352 *dst = strtoul(tmp, &end, 16);
9355 *size = (uint32_t)(dst - head);
9363 *size = (uint32_t)(dst - head);
9368 parse_hex(struct context *ctx, const struct token *token,
9369 const char *str, unsigned int len,
9370 void *buf, unsigned int size)
9372 const struct arg *arg_data = pop_args(ctx);
9373 const struct arg *arg_len = pop_args(ctx);
9374 const struct arg *arg_addr = pop_args(ctx);
9375 char tmp[16]; /* Ought to be enough. */
9377 unsigned int hexlen = len;
9378 unsigned int length = 256;
9379 uint8_t hex_tmp[length];
9381 /* Arguments are expected. */
9385 push_args(ctx, arg_data);
9389 push_args(ctx, arg_len);
9390 push_args(ctx, arg_data);
9393 size = arg_data->size;
9394 /* Bit-mask fill is not supported. */
9400 /* translate bytes string to array. */
9401 if (str[0] == '0' && ((str[1] == 'x') ||
9406 if (hexlen > length)
9408 ret = parse_hex_string(str, hex_tmp, &hexlen);
9411 /* Check the converted binary fits into data buffer. */
9414 /* Let parse_int() fill length information first. */
9415 ret = snprintf(tmp, sizeof(tmp), "%u", hexlen);
9418 /* Save length if requested. */
9419 if (arg_len->size) {
9420 push_args(ctx, arg_len);
9421 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
9427 buf = (uint8_t *)ctx->object + arg_data->offset;
9428 /* Output buffer is not necessarily NUL-terminated. */
9429 memcpy(buf, hex_tmp, hexlen);
9430 memset((uint8_t *)buf + hexlen, 0x00, size - hexlen);
9432 memset((uint8_t *)ctx->objmask + arg_data->offset,
9434 /* Save address if requested. */
9435 if (arg_addr->size) {
9436 memcpy((uint8_t *)ctx->object + arg_addr->offset,
9438 (uint8_t *)ctx->object + arg_data->offset
9442 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
9444 (uint8_t *)ctx->objmask + arg_data->offset
9450 push_args(ctx, arg_addr);
9451 push_args(ctx, arg_len);
9452 push_args(ctx, arg_data);
9458 * Parse a zero-ended string.
9461 parse_string0(struct context *ctx, const struct token *token __rte_unused,
9462 const char *str, unsigned int len,
9463 void *buf, unsigned int size)
9465 const struct arg *arg_data = pop_args(ctx);
9467 /* Arguments are expected. */
9470 size = arg_data->size;
9471 /* Bit-mask fill is not supported. */
9472 if (arg_data->mask || size < len + 1)
9476 buf = (uint8_t *)ctx->object + arg_data->offset;
9477 strncpy(buf, str, len);
9479 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
9482 push_args(ctx, arg_data);
9487 * Parse a MAC address.
9489 * Last argument (ctx->args) is retrieved to determine storage size and
9493 parse_mac_addr(struct context *ctx, const struct token *token,
9494 const char *str, unsigned int len,
9495 void *buf, unsigned int size)
9497 const struct arg *arg = pop_args(ctx);
9498 struct rte_ether_addr tmp;
9502 /* Argument is expected. */
9506 /* Bit-mask fill is not supported. */
9507 if (arg->mask || size != sizeof(tmp))
9509 /* Only network endian is supported. */
9512 ret = cmdline_parse_etheraddr(NULL, str, &tmp, size);
9513 if (ret < 0 || (unsigned int)ret != len)
9517 buf = (uint8_t *)ctx->object + arg->offset;
9518 memcpy(buf, &tmp, size);
9520 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
9523 push_args(ctx, arg);
9528 * Parse an IPv4 address.
9530 * Last argument (ctx->args) is retrieved to determine storage size and
9534 parse_ipv4_addr(struct context *ctx, const struct token *token,
9535 const char *str, unsigned int len,
9536 void *buf, unsigned int size)
9538 const struct arg *arg = pop_args(ctx);
9543 /* Argument is expected. */
9547 /* Bit-mask fill is not supported. */
9548 if (arg->mask || size != sizeof(tmp))
9550 /* Only network endian is supported. */
9553 memcpy(str2, str, len);
9555 ret = inet_pton(AF_INET, str2, &tmp);
9557 /* Attempt integer parsing. */
9558 push_args(ctx, arg);
9559 return parse_int(ctx, token, str, len, buf, size);
9563 buf = (uint8_t *)ctx->object + arg->offset;
9564 memcpy(buf, &tmp, size);
9566 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
9569 push_args(ctx, arg);
9574 * Parse an IPv6 address.
9576 * Last argument (ctx->args) is retrieved to determine storage size and
9580 parse_ipv6_addr(struct context *ctx, const struct token *token,
9581 const char *str, unsigned int len,
9582 void *buf, unsigned int size)
9584 const struct arg *arg = pop_args(ctx);
9586 struct in6_addr tmp;
9590 /* Argument is expected. */
9594 /* Bit-mask fill is not supported. */
9595 if (arg->mask || size != sizeof(tmp))
9597 /* Only network endian is supported. */
9600 memcpy(str2, str, len);
9602 ret = inet_pton(AF_INET6, str2, &tmp);
9607 buf = (uint8_t *)ctx->object + arg->offset;
9608 memcpy(buf, &tmp, size);
9610 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
9613 push_args(ctx, arg);
9617 /** Boolean values (even indices stand for false). */
9618 static const char *const boolean_name[] = {
9628 * Parse a boolean value.
9630 * Last argument (ctx->args) is retrieved to determine storage size and
9634 parse_boolean(struct context *ctx, const struct token *token,
9635 const char *str, unsigned int len,
9636 void *buf, unsigned int size)
9638 const struct arg *arg = pop_args(ctx);
9642 /* Argument is expected. */
9645 for (i = 0; boolean_name[i]; ++i)
9646 if (!strcmp_partial(boolean_name[i], str, len))
9648 /* Process token as integer. */
9649 if (boolean_name[i])
9650 str = i & 1 ? "1" : "0";
9651 push_args(ctx, arg);
9652 ret = parse_int(ctx, token, str, strlen(str), buf, size);
9653 return ret > 0 ? (int)len : ret;
9656 /** Parse port and update context. */
9658 parse_port(struct context *ctx, const struct token *token,
9659 const char *str, unsigned int len,
9660 void *buf, unsigned int size)
9662 struct buffer *out = &(struct buffer){ .port = 0 };
9670 ctx->objmask = NULL;
9671 size = sizeof(*out);
9673 ret = parse_int(ctx, token, str, len, out, size);
9675 ctx->port = out->port;
9682 parse_ia_id2ptr(struct context *ctx, const struct token *token,
9683 const char *str, unsigned int len,
9684 void *buf, unsigned int size)
9686 struct rte_flow_action *action = ctx->object;
9694 ctx->objmask = NULL;
9695 ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
9696 ctx->object = action;
9697 if (ret != (int)len)
9699 /* set indirect action */
9701 action->conf = port_action_handle_get_by_id(ctx->port, id);
9702 ret = (action->conf) ? ret : -1;
9707 /** Parse set command, initialize output buffer for subsequent tokens. */
9709 parse_set_raw_encap_decap(struct context *ctx, const struct token *token,
9710 const char *str, unsigned int len,
9711 void *buf, unsigned int size)
9713 struct buffer *out = buf;
9715 /* Token name must match. */
9716 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
9718 /* Nothing else to do if there is no buffer. */
9721 /* Make sure buffer is large enough. */
9722 if (size < sizeof(*out))
9725 ctx->objmask = NULL;
9729 out->command = ctx->curr;
9730 /* For encap/decap we need is pattern */
9731 out->args.vc.pattern = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
9736 /** Parse set command, initialize output buffer for subsequent tokens. */
9738 parse_set_sample_action(struct context *ctx, const struct token *token,
9739 const char *str, unsigned int len,
9740 void *buf, unsigned int size)
9742 struct buffer *out = buf;
9744 /* Token name must match. */
9745 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
9747 /* Nothing else to do if there is no buffer. */
9750 /* Make sure buffer is large enough. */
9751 if (size < sizeof(*out))
9754 ctx->objmask = NULL;
9758 out->command = ctx->curr;
9759 /* For sampler we need is actions */
9760 out->args.vc.actions = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
9766 * Parse set raw_encap/raw_decap command,
9767 * initialize output buffer for subsequent tokens.
9770 parse_set_init(struct context *ctx, const struct token *token,
9771 const char *str, unsigned int len,
9772 void *buf, unsigned int size)
9774 struct buffer *out = buf;
9776 /* Token name must match. */
9777 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
9779 /* Nothing else to do if there is no buffer. */
9782 /* Make sure buffer is large enough. */
9783 if (size < sizeof(*out))
9785 /* Initialize buffer. */
9786 memset(out, 0x00, sizeof(*out));
9787 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
9790 ctx->objmask = NULL;
9791 if (!out->command) {
9792 if (ctx->curr != SET)
9794 if (sizeof(*out) > size)
9796 out->command = ctx->curr;
9797 out->args.vc.data = (uint8_t *)out + size;
9798 ctx->object = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
9805 * Replace testpmd handles in a flex flow item with real values.
9808 parse_flex_handle(struct context *ctx, const struct token *token,
9809 const char *str, unsigned int len,
9810 void *buf, unsigned int size)
9812 struct rte_flow_item_flex *spec, *mask;
9813 const struct rte_flow_item_flex *src_spec, *src_mask;
9814 const struct arg *arg = pop_args(ctx);
9820 printf("Bad environment\n");
9823 offset = arg->offset;
9824 push_args(ctx, arg);
9825 ret = parse_int(ctx, token, str, len, buf, size);
9826 if (ret <= 0 || !ctx->object)
9828 if (ctx->port >= RTE_MAX_ETHPORTS) {
9829 printf("Bad port\n");
9832 if (offset == offsetof(struct rte_flow_item_flex, handle)) {
9833 const struct flex_item *fp;
9834 struct rte_flow_item_flex *item_flex = ctx->object;
9835 handle = (uint16_t)(uintptr_t)item_flex->handle;
9836 if (handle >= FLEX_MAX_PARSERS_NUM) {
9837 printf("Bad flex item handle\n");
9840 fp = flex_items[ctx->port][handle];
9842 printf("Bad flex item handle\n");
9845 item_flex->handle = fp->flex_handle;
9846 } else if (offset == offsetof(struct rte_flow_item_flex, pattern)) {
9847 handle = (uint16_t)(uintptr_t)
9848 ((struct rte_flow_item_flex *)ctx->object)->pattern;
9849 if (handle >= FLEX_MAX_PATTERNS_NUM) {
9850 printf("Bad pattern handle\n");
9853 src_spec = &flex_patterns[handle].spec;
9854 src_mask = &flex_patterns[handle].mask;
9856 mask = spec + 2; /* spec, last, mask */
9857 /* fill flow rule spec and mask parameters */
9858 spec->length = src_spec->length;
9859 spec->pattern = src_spec->pattern;
9860 mask->length = src_mask->length;
9861 mask->pattern = src_mask->pattern;
9863 printf("Bad arguments - unknown flex item offset\n");
9869 /** No completion. */
9871 comp_none(struct context *ctx, const struct token *token,
9872 unsigned int ent, char *buf, unsigned int size)
9882 /** Complete boolean values. */
9884 comp_boolean(struct context *ctx, const struct token *token,
9885 unsigned int ent, char *buf, unsigned int size)
9891 for (i = 0; boolean_name[i]; ++i)
9892 if (buf && i == ent)
9893 return strlcpy(buf, boolean_name[i], size);
9899 /** Complete action names. */
9901 comp_action(struct context *ctx, const struct token *token,
9902 unsigned int ent, char *buf, unsigned int size)
9908 for (i = 0; next_action[i]; ++i)
9909 if (buf && i == ent)
9910 return strlcpy(buf, token_list[next_action[i]].name,
9917 /** Complete available ports. */
9919 comp_port(struct context *ctx, const struct token *token,
9920 unsigned int ent, char *buf, unsigned int size)
9927 RTE_ETH_FOREACH_DEV(p) {
9928 if (buf && i == ent)
9929 return snprintf(buf, size, "%u", p);
9937 /** Complete available rule IDs. */
9939 comp_rule_id(struct context *ctx, const struct token *token,
9940 unsigned int ent, char *buf, unsigned int size)
9943 struct rte_port *port;
9944 struct port_flow *pf;
9947 if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
9948 ctx->port == (portid_t)RTE_PORT_ALL)
9950 port = &ports[ctx->port];
9951 for (pf = port->flow_list; pf != NULL; pf = pf->next) {
9952 if (buf && i == ent)
9953 return snprintf(buf, size, "%u", pf->id);
9961 /** Complete type field for RSS action. */
9963 comp_vc_action_rss_type(struct context *ctx, const struct token *token,
9964 unsigned int ent, char *buf, unsigned int size)
9970 for (i = 0; rss_type_table[i].str; ++i)
9975 return strlcpy(buf, rss_type_table[ent].str, size);
9977 return snprintf(buf, size, "end");
9981 /** Complete queue field for RSS action. */
9983 comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
9984 unsigned int ent, char *buf, unsigned int size)
9991 return snprintf(buf, size, "%u", ent);
9993 return snprintf(buf, size, "end");
9997 /** Complete index number for set raw_encap/raw_decap commands. */
9999 comp_set_raw_index(struct context *ctx, const struct token *token,
10000 unsigned int ent, char *buf, unsigned int size)
10006 RTE_SET_USED(token);
10007 for (idx = 0; idx < RAW_ENCAP_CONFS_MAX_NUM; ++idx) {
10008 if (buf && idx == ent)
10009 return snprintf(buf, size, "%u", idx);
10015 /** Complete index number for set raw_encap/raw_decap commands. */
10017 comp_set_sample_index(struct context *ctx, const struct token *token,
10018 unsigned int ent, char *buf, unsigned int size)
10024 RTE_SET_USED(token);
10025 for (idx = 0; idx < RAW_SAMPLE_CONFS_MAX_NUM; ++idx) {
10026 if (buf && idx == ent)
10027 return snprintf(buf, size, "%u", idx);
10033 /** Complete operation for modify_field command. */
10035 comp_set_modify_field_op(struct context *ctx, const struct token *token,
10036 unsigned int ent, char *buf, unsigned int size)
10039 RTE_SET_USED(token);
10041 return RTE_DIM(modify_field_ops);
10042 if (ent < RTE_DIM(modify_field_ops) - 1)
10043 return strlcpy(buf, modify_field_ops[ent], size);
10047 /** Complete field id for modify_field command. */
10049 comp_set_modify_field_id(struct context *ctx, const struct token *token,
10050 unsigned int ent, char *buf, unsigned int size)
10054 RTE_SET_USED(token);
10056 return RTE_DIM(modify_field_ids);
10057 if (ent >= RTE_DIM(modify_field_ids) - 1)
10059 name = modify_field_ids[ent];
10060 if (ctx->curr == ACTION_MODIFY_FIELD_SRC_TYPE ||
10061 (strcmp(name, "pointer") && strcmp(name, "value")))
10062 return strlcpy(buf, name, size);
10066 /** Complete available pattern template IDs. */
10068 comp_pattern_template_id(struct context *ctx, const struct token *token,
10069 unsigned int ent, char *buf, unsigned int size)
10071 unsigned int i = 0;
10072 struct rte_port *port;
10073 struct port_template *pt;
10076 if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
10077 ctx->port == (portid_t)RTE_PORT_ALL)
10079 port = &ports[ctx->port];
10080 for (pt = port->pattern_templ_list; pt != NULL; pt = pt->next) {
10081 if (buf && i == ent)
10082 return snprintf(buf, size, "%u", pt->id);
10090 /** Complete available actions template IDs. */
10092 comp_actions_template_id(struct context *ctx, const struct token *token,
10093 unsigned int ent, char *buf, unsigned int size)
10095 unsigned int i = 0;
10096 struct rte_port *port;
10097 struct port_template *pt;
10100 if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
10101 ctx->port == (portid_t)RTE_PORT_ALL)
10103 port = &ports[ctx->port];
10104 for (pt = port->actions_templ_list; pt != NULL; pt = pt->next) {
10105 if (buf && i == ent)
10106 return snprintf(buf, size, "%u", pt->id);
10114 /** Complete available table IDs. */
10116 comp_table_id(struct context *ctx, const struct token *token,
10117 unsigned int ent, char *buf, unsigned int size)
10119 unsigned int i = 0;
10120 struct rte_port *port;
10121 struct port_table *pt;
10124 if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
10125 ctx->port == (portid_t)RTE_PORT_ALL)
10127 port = &ports[ctx->port];
10128 for (pt = port->table_list; pt != NULL; pt = pt->next) {
10129 if (buf && i == ent)
10130 return snprintf(buf, size, "%u", pt->id);
10138 /** Complete available queue IDs. */
10140 comp_queue_id(struct context *ctx, const struct token *token,
10141 unsigned int ent, char *buf, unsigned int size)
10143 unsigned int i = 0;
10144 struct rte_port *port;
10147 if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
10148 ctx->port == (portid_t)RTE_PORT_ALL)
10150 port = &ports[ctx->port];
10151 for (i = 0; i < port->queue_nb; i++) {
10152 if (buf && i == ent)
10153 return snprintf(buf, size, "%u", i);
10160 /** Internal context. */
10161 static struct context cmd_flow_context;
10163 /** Global parser instance (cmdline API). */
10164 cmdline_parse_inst_t cmd_flow;
10165 cmdline_parse_inst_t cmd_set_raw;
10167 /** Initialize context. */
10169 cmd_flow_context_init(struct context *ctx)
10171 /* A full memset() is not necessary. */
10180 ctx->object = NULL;
10181 ctx->objmask = NULL;
10184 /** Parse a token (cmdline API). */
10186 cmd_flow_parse(cmdline_parse_token_hdr_t *hdr, const char *src, void *result,
10189 struct context *ctx = &cmd_flow_context;
10190 const struct token *token;
10191 const enum index *list;
10196 token = &token_list[ctx->curr];
10197 /* Check argument length. */
10200 for (len = 0; src[len]; ++len)
10201 if (src[len] == '#' || isspace(src[len]))
10205 /* Last argument and EOL detection. */
10206 for (i = len; src[i]; ++i)
10207 if (src[i] == '#' || src[i] == '\r' || src[i] == '\n')
10209 else if (!isspace(src[i])) {
10213 for (; src[i]; ++i)
10214 if (src[i] == '\r' || src[i] == '\n') {
10218 /* Initialize context if necessary. */
10219 if (!ctx->next_num) {
10222 ctx->next[ctx->next_num++] = token->next[0];
10224 /* Process argument through candidates. */
10225 ctx->prev = ctx->curr;
10226 list = ctx->next[ctx->next_num - 1];
10227 for (i = 0; list[i]; ++i) {
10228 const struct token *next = &token_list[list[i]];
10231 ctx->curr = list[i];
10233 tmp = next->call(ctx, next, src, len, result, size);
10235 tmp = parse_default(ctx, next, src, len, result, size);
10236 if (tmp == -1 || tmp != len)
10244 /* Push subsequent tokens if any. */
10246 for (i = 0; token->next[i]; ++i) {
10247 if (ctx->next_num == RTE_DIM(ctx->next))
10249 ctx->next[ctx->next_num++] = token->next[i];
10251 /* Push arguments if any. */
10253 for (i = 0; token->args[i]; ++i) {
10254 if (ctx->args_num == RTE_DIM(ctx->args))
10256 ctx->args[ctx->args_num++] = token->args[i];
10262 flow_parse(const char *src, void *result, unsigned int size,
10263 struct rte_flow_attr **attr,
10264 struct rte_flow_item **pattern, struct rte_flow_action **actions)
10267 struct context saved_flow_ctx = cmd_flow_context;
10269 cmd_flow_context_init(&cmd_flow_context);
10271 ret = cmd_flow_parse(NULL, src, result, size);
10274 while (isspace(*src))
10277 } while (ret > 0 && strlen(src));
10278 cmd_flow_context = saved_flow_ctx;
10279 *attr = &((struct buffer *)result)->args.vc.attr;
10280 *pattern = ((struct buffer *)result)->args.vc.pattern;
10281 *actions = ((struct buffer *)result)->args.vc.actions;
10282 return (ret >= 0 && !strlen(src)) ? 0 : -1;
10285 /** Return number of completion entries (cmdline API). */
10287 cmd_flow_complete_get_nb(cmdline_parse_token_hdr_t *hdr)
10289 struct context *ctx = &cmd_flow_context;
10290 const struct token *token = &token_list[ctx->curr];
10291 const enum index *list;
10295 /* Count number of tokens in current list. */
10297 list = ctx->next[ctx->next_num - 1];
10299 list = token->next[0];
10300 for (i = 0; list[i]; ++i)
10305 * If there is a single token, use its completion callback, otherwise
10306 * return the number of entries.
10308 token = &token_list[list[0]];
10309 if (i == 1 && token->comp) {
10310 /* Save index for cmd_flow_get_help(). */
10311 ctx->prev = list[0];
10312 return token->comp(ctx, token, 0, NULL, 0);
10317 /** Return a completion entry (cmdline API). */
10319 cmd_flow_complete_get_elt(cmdline_parse_token_hdr_t *hdr, int index,
10320 char *dst, unsigned int size)
10322 struct context *ctx = &cmd_flow_context;
10323 const struct token *token = &token_list[ctx->curr];
10324 const enum index *list;
10328 /* Count number of tokens in current list. */
10330 list = ctx->next[ctx->next_num - 1];
10332 list = token->next[0];
10333 for (i = 0; list[i]; ++i)
10337 /* If there is a single token, use its completion callback. */
10338 token = &token_list[list[0]];
10339 if (i == 1 && token->comp) {
10340 /* Save index for cmd_flow_get_help(). */
10341 ctx->prev = list[0];
10342 return token->comp(ctx, token, index, dst, size) < 0 ? -1 : 0;
10344 /* Otherwise make sure the index is valid and use defaults. */
10347 token = &token_list[list[index]];
10348 strlcpy(dst, token->name, size);
10349 /* Save index for cmd_flow_get_help(). */
10350 ctx->prev = list[index];
10354 /** Populate help strings for current token (cmdline API). */
10356 cmd_flow_get_help(cmdline_parse_token_hdr_t *hdr, char *dst, unsigned int size)
10358 struct context *ctx = &cmd_flow_context;
10359 const struct token *token = &token_list[ctx->prev];
10364 /* Set token type and update global help with details. */
10365 strlcpy(dst, (token->type ? token->type : "TOKEN"), size);
10367 cmd_flow.help_str = token->help;
10369 cmd_flow.help_str = token->name;
10373 /** Token definition template (cmdline API). */
10374 static struct cmdline_token_hdr cmd_flow_token_hdr = {
10375 .ops = &(struct cmdline_token_ops){
10376 .parse = cmd_flow_parse,
10377 .complete_get_nb = cmd_flow_complete_get_nb,
10378 .complete_get_elt = cmd_flow_complete_get_elt,
10379 .get_help = cmd_flow_get_help,
10384 /** Populate the next dynamic token. */
10386 cmd_flow_tok(cmdline_parse_token_hdr_t **hdr,
10387 cmdline_parse_token_hdr_t **hdr_inst)
10389 struct context *ctx = &cmd_flow_context;
10391 /* Always reinitialize context before requesting the first token. */
10392 if (!(hdr_inst - cmd_flow.tokens))
10393 cmd_flow_context_init(ctx);
10394 /* Return NULL when no more tokens are expected. */
10395 if (!ctx->next_num && ctx->curr) {
10399 /* Determine if command should end here. */
10400 if (ctx->eol && ctx->last && ctx->next_num) {
10401 const enum index *list = ctx->next[ctx->next_num - 1];
10404 for (i = 0; list[i]; ++i) {
10405 if (list[i] != END)
10411 *hdr = &cmd_flow_token_hdr;
10414 /** Dispatch parsed buffer to function calls. */
10416 cmd_flow_parsed(const struct buffer *in)
10418 switch (in->command) {
10420 port_flow_get_info(in->port);
10423 port_flow_configure(in->port,
10424 &in->args.configure.port_attr,
10425 in->args.configure.nb_queue,
10426 &in->args.configure.queue_attr);
10428 case PATTERN_TEMPLATE_CREATE:
10429 port_flow_pattern_template_create(in->port,
10430 in->args.vc.pat_templ_id,
10431 &((const struct rte_flow_pattern_template_attr) {
10432 .relaxed_matching = in->args.vc.attr.reserved,
10433 .ingress = in->args.vc.attr.ingress,
10434 .egress = in->args.vc.attr.egress,
10435 .transfer = in->args.vc.attr.transfer,
10437 in->args.vc.pattern);
10439 case PATTERN_TEMPLATE_DESTROY:
10440 port_flow_pattern_template_destroy(in->port,
10441 in->args.templ_destroy.template_id_n,
10442 in->args.templ_destroy.template_id);
10444 case ACTIONS_TEMPLATE_CREATE:
10445 port_flow_actions_template_create(in->port,
10446 in->args.vc.act_templ_id,
10447 &((const struct rte_flow_actions_template_attr) {
10448 .ingress = in->args.vc.attr.ingress,
10449 .egress = in->args.vc.attr.egress,
10450 .transfer = in->args.vc.attr.transfer,
10452 in->args.vc.actions,
10453 in->args.vc.masks);
10455 case ACTIONS_TEMPLATE_DESTROY:
10456 port_flow_actions_template_destroy(in->port,
10457 in->args.templ_destroy.template_id_n,
10458 in->args.templ_destroy.template_id);
10461 port_flow_template_table_create(in->port, in->args.table.id,
10462 &in->args.table.attr, in->args.table.pat_templ_id_n,
10463 in->args.table.pat_templ_id, in->args.table.act_templ_id_n,
10464 in->args.table.act_templ_id);
10466 case TABLE_DESTROY:
10467 port_flow_template_table_destroy(in->port,
10468 in->args.table_destroy.table_id_n,
10469 in->args.table_destroy.table_id);
10472 port_queue_flow_create(in->port, in->queue, in->postpone,
10473 in->args.vc.table_id, in->args.vc.pat_templ_id,
10474 in->args.vc.act_templ_id, in->args.vc.pattern,
10475 in->args.vc.actions);
10477 case QUEUE_DESTROY:
10478 port_queue_flow_destroy(in->port, in->queue, in->postpone,
10479 in->args.destroy.rule_n,
10480 in->args.destroy.rule);
10483 port_queue_flow_push(in->port, in->queue);
10486 port_queue_flow_pull(in->port, in->queue);
10488 case QUEUE_INDIRECT_ACTION_CREATE:
10489 port_queue_action_handle_create(
10490 in->port, in->queue, in->postpone,
10491 in->args.vc.attr.group,
10492 &((const struct rte_flow_indir_action_conf) {
10493 .ingress = in->args.vc.attr.ingress,
10494 .egress = in->args.vc.attr.egress,
10495 .transfer = in->args.vc.attr.transfer,
10497 in->args.vc.actions);
10499 case QUEUE_INDIRECT_ACTION_DESTROY:
10500 port_queue_action_handle_destroy(in->port,
10501 in->queue, in->postpone,
10502 in->args.ia_destroy.action_id_n,
10503 in->args.ia_destroy.action_id);
10505 case QUEUE_INDIRECT_ACTION_UPDATE:
10506 port_queue_action_handle_update(in->port,
10507 in->queue, in->postpone,
10508 in->args.vc.attr.group,
10509 in->args.vc.actions);
10511 case INDIRECT_ACTION_CREATE:
10512 port_action_handle_create(
10513 in->port, in->args.vc.attr.group,
10514 &((const struct rte_flow_indir_action_conf) {
10515 .ingress = in->args.vc.attr.ingress,
10516 .egress = in->args.vc.attr.egress,
10517 .transfer = in->args.vc.attr.transfer,
10519 in->args.vc.actions);
10521 case INDIRECT_ACTION_DESTROY:
10522 port_action_handle_destroy(in->port,
10523 in->args.ia_destroy.action_id_n,
10524 in->args.ia_destroy.action_id);
10526 case INDIRECT_ACTION_UPDATE:
10527 port_action_handle_update(in->port, in->args.vc.attr.group,
10528 in->args.vc.actions);
10530 case INDIRECT_ACTION_QUERY:
10531 port_action_handle_query(in->port, in->args.ia.action_id);
10534 port_flow_validate(in->port, &in->args.vc.attr,
10535 in->args.vc.pattern, in->args.vc.actions,
10536 &in->args.vc.tunnel_ops);
10539 port_flow_create(in->port, &in->args.vc.attr,
10540 in->args.vc.pattern, in->args.vc.actions,
10541 &in->args.vc.tunnel_ops);
10544 port_flow_destroy(in->port, in->args.destroy.rule_n,
10545 in->args.destroy.rule);
10548 port_flow_flush(in->port);
10552 port_flow_dump(in->port, in->args.dump.mode,
10553 in->args.dump.rule, in->args.dump.file);
10556 port_flow_query(in->port, in->args.query.rule,
10557 &in->args.query.action);
10560 port_flow_list(in->port, in->args.list.group_n,
10561 in->args.list.group);
10564 port_flow_isolate(in->port, in->args.isolate.set);
10567 port_flow_aged(in->port, in->args.aged.destroy);
10569 case TUNNEL_CREATE:
10570 port_flow_tunnel_create(in->port, &in->args.vc.tunnel_ops);
10572 case TUNNEL_DESTROY:
10573 port_flow_tunnel_destroy(in->port, in->args.vc.tunnel_ops.id);
10576 port_flow_tunnel_list(in->port);
10579 port_meter_policy_add(in->port, in->args.policy.policy_id,
10580 in->args.vc.actions);
10582 case FLEX_ITEM_CREATE:
10583 flex_item_create(in->port, in->args.flex.token,
10584 in->args.flex.filename);
10586 case FLEX_ITEM_DESTROY:
10587 flex_item_destroy(in->port, in->args.flex.token);
10594 /** Token generator and output processing callback (cmdline API). */
10596 cmd_flow_cb(void *arg0, struct cmdline *cl, void *arg2)
10599 cmd_flow_tok(arg0, arg2);
10601 cmd_flow_parsed(arg0);
10604 /** Global parser instance (cmdline API). */
10605 cmdline_parse_inst_t cmd_flow = {
10607 .data = NULL, /**< Unused. */
10608 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
10611 }, /**< Tokens are returned by cmd_flow_tok(). */
10614 /** set cmd facility. Reuse cmd flow's infrastructure as much as possible. */
10617 update_fields(uint8_t *buf, struct rte_flow_item *item, uint16_t next_proto)
10619 struct rte_ipv4_hdr *ipv4;
10620 struct rte_ether_hdr *eth;
10621 struct rte_ipv6_hdr *ipv6;
10622 struct rte_vxlan_hdr *vxlan;
10623 struct rte_vxlan_gpe_hdr *gpe;
10624 struct rte_flow_item_nvgre *nvgre;
10625 uint32_t ipv6_vtc_flow;
10627 switch (item->type) {
10628 case RTE_FLOW_ITEM_TYPE_ETH:
10629 eth = (struct rte_ether_hdr *)buf;
10631 eth->ether_type = rte_cpu_to_be_16(next_proto);
10633 case RTE_FLOW_ITEM_TYPE_IPV4:
10634 ipv4 = (struct rte_ipv4_hdr *)buf;
10635 if (!ipv4->version_ihl)
10636 ipv4->version_ihl = RTE_IPV4_VHL_DEF;
10637 if (next_proto && ipv4->next_proto_id == 0)
10638 ipv4->next_proto_id = (uint8_t)next_proto;
10640 case RTE_FLOW_ITEM_TYPE_IPV6:
10641 ipv6 = (struct rte_ipv6_hdr *)buf;
10642 if (next_proto && ipv6->proto == 0)
10643 ipv6->proto = (uint8_t)next_proto;
10644 ipv6_vtc_flow = rte_be_to_cpu_32(ipv6->vtc_flow);
10645 ipv6_vtc_flow &= 0x0FFFFFFF; /*< reset version bits. */
10646 ipv6_vtc_flow |= 0x60000000; /*< set ipv6 version. */
10647 ipv6->vtc_flow = rte_cpu_to_be_32(ipv6_vtc_flow);
10649 case RTE_FLOW_ITEM_TYPE_VXLAN:
10650 vxlan = (struct rte_vxlan_hdr *)buf;
10651 vxlan->vx_flags = 0x08;
10653 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
10654 gpe = (struct rte_vxlan_gpe_hdr *)buf;
10655 gpe->vx_flags = 0x0C;
10657 case RTE_FLOW_ITEM_TYPE_NVGRE:
10658 nvgre = (struct rte_flow_item_nvgre *)buf;
10659 nvgre->protocol = rte_cpu_to_be_16(0x6558);
10660 nvgre->c_k_s_rsvd0_ver = rte_cpu_to_be_16(0x2000);
10667 /** Helper of get item's default mask. */
10668 static const void *
10669 flow_item_default_mask(const struct rte_flow_item *item)
10671 const void *mask = NULL;
10672 static rte_be32_t gre_key_default_mask = RTE_BE32(UINT32_MAX);
10674 switch (item->type) {
10675 case RTE_FLOW_ITEM_TYPE_ANY:
10676 mask = &rte_flow_item_any_mask;
10678 case RTE_FLOW_ITEM_TYPE_VF:
10679 mask = &rte_flow_item_vf_mask;
10681 case RTE_FLOW_ITEM_TYPE_PORT_ID:
10682 mask = &rte_flow_item_port_id_mask;
10684 case RTE_FLOW_ITEM_TYPE_RAW:
10685 mask = &rte_flow_item_raw_mask;
10687 case RTE_FLOW_ITEM_TYPE_ETH:
10688 mask = &rte_flow_item_eth_mask;
10690 case RTE_FLOW_ITEM_TYPE_VLAN:
10691 mask = &rte_flow_item_vlan_mask;
10693 case RTE_FLOW_ITEM_TYPE_IPV4:
10694 mask = &rte_flow_item_ipv4_mask;
10696 case RTE_FLOW_ITEM_TYPE_IPV6:
10697 mask = &rte_flow_item_ipv6_mask;
10699 case RTE_FLOW_ITEM_TYPE_ICMP:
10700 mask = &rte_flow_item_icmp_mask;
10702 case RTE_FLOW_ITEM_TYPE_UDP:
10703 mask = &rte_flow_item_udp_mask;
10705 case RTE_FLOW_ITEM_TYPE_TCP:
10706 mask = &rte_flow_item_tcp_mask;
10708 case RTE_FLOW_ITEM_TYPE_SCTP:
10709 mask = &rte_flow_item_sctp_mask;
10711 case RTE_FLOW_ITEM_TYPE_VXLAN:
10712 mask = &rte_flow_item_vxlan_mask;
10714 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
10715 mask = &rte_flow_item_vxlan_gpe_mask;
10717 case RTE_FLOW_ITEM_TYPE_E_TAG:
10718 mask = &rte_flow_item_e_tag_mask;
10720 case RTE_FLOW_ITEM_TYPE_NVGRE:
10721 mask = &rte_flow_item_nvgre_mask;
10723 case RTE_FLOW_ITEM_TYPE_MPLS:
10724 mask = &rte_flow_item_mpls_mask;
10726 case RTE_FLOW_ITEM_TYPE_GRE:
10727 mask = &rte_flow_item_gre_mask;
10729 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
10730 mask = &gre_key_default_mask;
10732 case RTE_FLOW_ITEM_TYPE_META:
10733 mask = &rte_flow_item_meta_mask;
10735 case RTE_FLOW_ITEM_TYPE_FUZZY:
10736 mask = &rte_flow_item_fuzzy_mask;
10738 case RTE_FLOW_ITEM_TYPE_GTP:
10739 mask = &rte_flow_item_gtp_mask;
10741 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
10742 mask = &rte_flow_item_gtp_psc_mask;
10744 case RTE_FLOW_ITEM_TYPE_GENEVE:
10745 mask = &rte_flow_item_geneve_mask;
10747 case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
10748 mask = &rte_flow_item_geneve_opt_mask;
10750 case RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID:
10751 mask = &rte_flow_item_pppoe_proto_id_mask;
10753 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
10754 mask = &rte_flow_item_l2tpv3oip_mask;
10756 case RTE_FLOW_ITEM_TYPE_ESP:
10757 mask = &rte_flow_item_esp_mask;
10759 case RTE_FLOW_ITEM_TYPE_AH:
10760 mask = &rte_flow_item_ah_mask;
10762 case RTE_FLOW_ITEM_TYPE_PFCP:
10763 mask = &rte_flow_item_pfcp_mask;
10765 case RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR:
10766 case RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT:
10767 mask = &rte_flow_item_ethdev_mask;
10769 case RTE_FLOW_ITEM_TYPE_L2TPV2:
10770 mask = &rte_flow_item_l2tpv2_mask;
10772 case RTE_FLOW_ITEM_TYPE_PPP:
10773 mask = &rte_flow_item_ppp_mask;
10781 /** Dispatch parsed buffer to function calls. */
10783 cmd_set_raw_parsed_sample(const struct buffer *in)
10785 uint32_t n = in->args.vc.actions_n;
10787 struct rte_flow_action *action = NULL;
10788 struct rte_flow_action *data = NULL;
10789 const struct rte_flow_action_rss *rss = NULL;
10791 uint16_t idx = in->port; /* We borrow port field as index */
10792 uint32_t max_size = sizeof(struct rte_flow_action) *
10793 ACTION_SAMPLE_ACTIONS_NUM;
10795 RTE_ASSERT(in->command == SET_SAMPLE_ACTIONS);
10796 data = (struct rte_flow_action *)&raw_sample_confs[idx].data;
10797 memset(data, 0x00, max_size);
10798 for (; i <= n - 1; i++) {
10799 action = in->args.vc.actions + i;
10800 if (action->type == RTE_FLOW_ACTION_TYPE_END)
10802 switch (action->type) {
10803 case RTE_FLOW_ACTION_TYPE_MARK:
10804 size = sizeof(struct rte_flow_action_mark);
10805 rte_memcpy(&sample_mark[idx],
10806 (const void *)action->conf, size);
10807 action->conf = &sample_mark[idx];
10809 case RTE_FLOW_ACTION_TYPE_COUNT:
10810 size = sizeof(struct rte_flow_action_count);
10811 rte_memcpy(&sample_count[idx],
10812 (const void *)action->conf, size);
10813 action->conf = &sample_count[idx];
10815 case RTE_FLOW_ACTION_TYPE_QUEUE:
10816 size = sizeof(struct rte_flow_action_queue);
10817 rte_memcpy(&sample_queue[idx],
10818 (const void *)action->conf, size);
10819 action->conf = &sample_queue[idx];
10821 case RTE_FLOW_ACTION_TYPE_RSS:
10822 size = sizeof(struct rte_flow_action_rss);
10823 rss = action->conf;
10824 rte_memcpy(&sample_rss_data[idx].conf,
10825 (const void *)rss, size);
10826 if (rss->key_len && rss->key) {
10827 sample_rss_data[idx].conf.key =
10828 sample_rss_data[idx].key;
10829 rte_memcpy((void *)((uintptr_t)
10830 sample_rss_data[idx].conf.key),
10831 (const void *)rss->key,
10832 sizeof(uint8_t) * rss->key_len);
10834 if (rss->queue_num && rss->queue) {
10835 sample_rss_data[idx].conf.queue =
10836 sample_rss_data[idx].queue;
10837 rte_memcpy((void *)((uintptr_t)
10838 sample_rss_data[idx].conf.queue),
10839 (const void *)rss->queue,
10840 sizeof(uint16_t) * rss->queue_num);
10842 action->conf = &sample_rss_data[idx].conf;
10844 case RTE_FLOW_ACTION_TYPE_RAW_ENCAP:
10845 size = sizeof(struct rte_flow_action_raw_encap);
10846 rte_memcpy(&sample_encap[idx],
10847 (const void *)action->conf, size);
10848 action->conf = &sample_encap[idx];
10850 case RTE_FLOW_ACTION_TYPE_PORT_ID:
10851 size = sizeof(struct rte_flow_action_port_id);
10852 rte_memcpy(&sample_port_id[idx],
10853 (const void *)action->conf, size);
10854 action->conf = &sample_port_id[idx];
10856 case RTE_FLOW_ACTION_TYPE_PF:
10858 case RTE_FLOW_ACTION_TYPE_VF:
10859 size = sizeof(struct rte_flow_action_vf);
10860 rte_memcpy(&sample_vf[idx],
10861 (const void *)action->conf, size);
10862 action->conf = &sample_vf[idx];
10864 case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP:
10865 size = sizeof(struct rte_flow_action_vxlan_encap);
10866 parse_setup_vxlan_encap_data(&sample_vxlan_encap[idx]);
10867 action->conf = &sample_vxlan_encap[idx].conf;
10869 case RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP:
10870 size = sizeof(struct rte_flow_action_nvgre_encap);
10871 parse_setup_nvgre_encap_data(&sample_nvgre_encap[idx]);
10872 action->conf = &sample_nvgre_encap[idx];
10875 fprintf(stderr, "Error - Not supported action\n");
10878 rte_memcpy(data, action, sizeof(struct rte_flow_action));
10883 /** Dispatch parsed buffer to function calls. */
10885 cmd_set_raw_parsed(const struct buffer *in)
10887 uint32_t n = in->args.vc.pattern_n;
10889 struct rte_flow_item *item = NULL;
10891 uint8_t *data = NULL;
10892 uint8_t *data_tail = NULL;
10893 size_t *total_size = NULL;
10894 uint16_t upper_layer = 0;
10895 uint16_t proto = 0;
10896 uint16_t idx = in->port; /* We borrow port field as index */
10897 int gtp_psc = -1; /* GTP PSC option index. */
10899 if (in->command == SET_SAMPLE_ACTIONS)
10900 return cmd_set_raw_parsed_sample(in);
10901 RTE_ASSERT(in->command == SET_RAW_ENCAP ||
10902 in->command == SET_RAW_DECAP);
10903 if (in->command == SET_RAW_ENCAP) {
10904 total_size = &raw_encap_confs[idx].size;
10905 data = (uint8_t *)&raw_encap_confs[idx].data;
10907 total_size = &raw_decap_confs[idx].size;
10908 data = (uint8_t *)&raw_decap_confs[idx].data;
10911 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
10912 /* process hdr from upper layer to low layer (L3/L4 -> L2). */
10913 data_tail = data + ACTION_RAW_ENCAP_MAX_DATA;
10914 for (i = n - 1 ; i >= 0; --i) {
10915 const struct rte_flow_item_gtp *gtp;
10916 const struct rte_flow_item_geneve_opt *opt;
10918 item = in->args.vc.pattern + i;
10919 if (item->spec == NULL)
10920 item->spec = flow_item_default_mask(item);
10921 switch (item->type) {
10922 case RTE_FLOW_ITEM_TYPE_ETH:
10923 size = sizeof(struct rte_ether_hdr);
10925 case RTE_FLOW_ITEM_TYPE_VLAN:
10926 size = sizeof(struct rte_vlan_hdr);
10927 proto = RTE_ETHER_TYPE_VLAN;
10929 case RTE_FLOW_ITEM_TYPE_IPV4:
10930 size = sizeof(struct rte_ipv4_hdr);
10931 proto = RTE_ETHER_TYPE_IPV4;
10933 case RTE_FLOW_ITEM_TYPE_IPV6:
10934 size = sizeof(struct rte_ipv6_hdr);
10935 proto = RTE_ETHER_TYPE_IPV6;
10937 case RTE_FLOW_ITEM_TYPE_UDP:
10938 size = sizeof(struct rte_udp_hdr);
10941 case RTE_FLOW_ITEM_TYPE_TCP:
10942 size = sizeof(struct rte_tcp_hdr);
10945 case RTE_FLOW_ITEM_TYPE_VXLAN:
10946 size = sizeof(struct rte_vxlan_hdr);
10948 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
10949 size = sizeof(struct rte_vxlan_gpe_hdr);
10951 case RTE_FLOW_ITEM_TYPE_GRE:
10952 size = sizeof(struct rte_gre_hdr);
10955 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
10956 size = sizeof(rte_be32_t);
10959 case RTE_FLOW_ITEM_TYPE_MPLS:
10960 size = sizeof(struct rte_mpls_hdr);
10963 case RTE_FLOW_ITEM_TYPE_NVGRE:
10964 size = sizeof(struct rte_flow_item_nvgre);
10967 case RTE_FLOW_ITEM_TYPE_GENEVE:
10968 size = sizeof(struct rte_geneve_hdr);
10970 case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
10971 opt = (const struct rte_flow_item_geneve_opt *)
10973 size = offsetof(struct rte_flow_item_geneve_opt,
10974 option_len) + sizeof(uint8_t);
10975 if (opt->option_len && opt->data) {
10976 *total_size += opt->option_len *
10978 rte_memcpy(data_tail - (*total_size),
10980 opt->option_len * sizeof(uint32_t));
10983 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
10984 size = sizeof(rte_be32_t);
10987 case RTE_FLOW_ITEM_TYPE_ESP:
10988 size = sizeof(struct rte_esp_hdr);
10991 case RTE_FLOW_ITEM_TYPE_AH:
10992 size = sizeof(struct rte_flow_item_ah);
10995 case RTE_FLOW_ITEM_TYPE_GTP:
10997 size = sizeof(struct rte_gtp_hdr);
11000 if (gtp_psc != i + 1) {
11002 "Error - GTP PSC does not follow GTP\n");
11006 if ((gtp->v_pt_rsv_flags & 0x07) != 0x04) {
11007 /* Only E flag should be set. */
11009 "Error - GTP unsupported flags\n");
11012 struct rte_gtp_hdr_ext_word ext_word = {
11016 /* We have to add GTP header extra word. */
11017 *total_size += sizeof(ext_word);
11018 rte_memcpy(data_tail - (*total_size),
11019 &ext_word, sizeof(ext_word));
11021 size = sizeof(struct rte_gtp_hdr);
11023 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
11024 if (gtp_psc >= 0) {
11026 "Error - Multiple GTP PSC items\n");
11029 const struct rte_flow_item_gtp_psc
11033 uint8_t pdu_type:4;
11037 psc.len = sizeof(psc) / 4;
11038 psc.pdu_type = opt->hdr.type;
11039 psc.qfi = opt->hdr.qfi;
11041 *total_size += sizeof(psc);
11042 rte_memcpy(data_tail - (*total_size),
11043 &psc, sizeof(psc));
11048 case RTE_FLOW_ITEM_TYPE_PFCP:
11049 size = sizeof(struct rte_flow_item_pfcp);
11051 case RTE_FLOW_ITEM_TYPE_FLEX:
11052 size = item->spec ?
11053 ((const struct rte_flow_item_flex *)
11054 item->spec)->length : 0;
11056 case RTE_FLOW_ITEM_TYPE_GRE_OPTION:
11059 const struct rte_flow_item_gre_opt
11061 if (opt->checksum_rsvd.checksum) {
11063 sizeof(opt->checksum_rsvd);
11064 rte_memcpy(data_tail - (*total_size),
11065 &opt->checksum_rsvd,
11066 sizeof(opt->checksum_rsvd));
11068 if (opt->key.key) {
11069 *total_size += sizeof(opt->key.key);
11070 rte_memcpy(data_tail - (*total_size),
11072 sizeof(opt->key.key));
11074 if (opt->sequence.sequence) {
11075 *total_size += sizeof(opt->sequence.sequence);
11076 rte_memcpy(data_tail - (*total_size),
11077 &opt->sequence.sequence,
11078 sizeof(opt->sequence.sequence));
11084 fprintf(stderr, "Error - Not supported item\n");
11087 *total_size += size;
11088 rte_memcpy(data_tail - (*total_size), item->spec, size);
11089 /* update some fields which cannot be set by cmdline */
11090 update_fields((data_tail - (*total_size)), item,
11092 upper_layer = proto;
11094 if (verbose_level & 0x1)
11095 printf("total data size is %zu\n", (*total_size));
11096 RTE_ASSERT((*total_size) <= ACTION_RAW_ENCAP_MAX_DATA);
11097 memmove(data, (data_tail - (*total_size)), *total_size);
11102 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
11105 /** Populate help strings for current token (cmdline API). */
11107 cmd_set_raw_get_help(cmdline_parse_token_hdr_t *hdr, char *dst,
11110 struct context *ctx = &cmd_flow_context;
11111 const struct token *token = &token_list[ctx->prev];
11116 /* Set token type and update global help with details. */
11117 snprintf(dst, size, "%s", (token->type ? token->type : "TOKEN"));
11119 cmd_set_raw.help_str = token->help;
11121 cmd_set_raw.help_str = token->name;
11125 /** Token definition template (cmdline API). */
11126 static struct cmdline_token_hdr cmd_set_raw_token_hdr = {
11127 .ops = &(struct cmdline_token_ops){
11128 .parse = cmd_flow_parse,
11129 .complete_get_nb = cmd_flow_complete_get_nb,
11130 .complete_get_elt = cmd_flow_complete_get_elt,
11131 .get_help = cmd_set_raw_get_help,
11136 /** Populate the next dynamic token. */
11138 cmd_set_raw_tok(cmdline_parse_token_hdr_t **hdr,
11139 cmdline_parse_token_hdr_t **hdr_inst)
11141 struct context *ctx = &cmd_flow_context;
11143 /* Always reinitialize context before requesting the first token. */
11144 if (!(hdr_inst - cmd_set_raw.tokens)) {
11145 cmd_flow_context_init(ctx);
11146 ctx->curr = START_SET;
11148 /* Return NULL when no more tokens are expected. */
11149 if (!ctx->next_num && (ctx->curr != START_SET)) {
11153 /* Determine if command should end here. */
11154 if (ctx->eol && ctx->last && ctx->next_num) {
11155 const enum index *list = ctx->next[ctx->next_num - 1];
11158 for (i = 0; list[i]; ++i) {
11159 if (list[i] != END)
11165 *hdr = &cmd_set_raw_token_hdr;
11168 /** Token generator and output processing callback (cmdline API). */
11170 cmd_set_raw_cb(void *arg0, struct cmdline *cl, void *arg2)
11173 cmd_set_raw_tok(arg0, arg2);
11175 cmd_set_raw_parsed(arg0);
11178 /** Global parser instance (cmdline API). */
11179 cmdline_parse_inst_t cmd_set_raw = {
11180 .f = cmd_set_raw_cb,
11181 .data = NULL, /**< Unused. */
11182 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
11185 }, /**< Tokens are returned by cmd_flow_tok(). */
11188 /* *** display raw_encap/raw_decap buf */
11189 struct cmd_show_set_raw_result {
11190 cmdline_fixed_string_t cmd_show;
11191 cmdline_fixed_string_t cmd_what;
11192 cmdline_fixed_string_t cmd_all;
11193 uint16_t cmd_index;
11197 cmd_show_set_raw_parsed(void *parsed_result, struct cmdline *cl, void *data)
11199 struct cmd_show_set_raw_result *res = parsed_result;
11200 uint16_t index = res->cmd_index;
11202 uint8_t *raw_data = NULL;
11203 size_t raw_size = 0;
11204 char title[16] = {0};
11207 RTE_SET_USED(data);
11208 if (!strcmp(res->cmd_all, "all")) {
11211 } else if (index >= RAW_ENCAP_CONFS_MAX_NUM) {
11212 fprintf(stderr, "index should be 0-%u\n",
11213 RAW_ENCAP_CONFS_MAX_NUM - 1);
11217 if (!strcmp(res->cmd_what, "raw_encap")) {
11218 raw_data = (uint8_t *)&raw_encap_confs[index].data;
11219 raw_size = raw_encap_confs[index].size;
11220 snprintf(title, 16, "\nindex: %u", index);
11221 rte_hexdump(stdout, title, raw_data, raw_size);
11223 raw_data = (uint8_t *)&raw_decap_confs[index].data;
11224 raw_size = raw_decap_confs[index].size;
11225 snprintf(title, 16, "\nindex: %u", index);
11226 rte_hexdump(stdout, title, raw_data, raw_size);
11228 } while (all && ++index < RAW_ENCAP_CONFS_MAX_NUM);
11231 cmdline_parse_token_string_t cmd_show_set_raw_cmd_show =
11232 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
11234 cmdline_parse_token_string_t cmd_show_set_raw_cmd_what =
11235 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
11236 cmd_what, "raw_encap#raw_decap");
11237 cmdline_parse_token_num_t cmd_show_set_raw_cmd_index =
11238 TOKEN_NUM_INITIALIZER(struct cmd_show_set_raw_result,
11239 cmd_index, RTE_UINT16);
11240 cmdline_parse_token_string_t cmd_show_set_raw_cmd_all =
11241 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
11243 cmdline_parse_inst_t cmd_show_set_raw = {
11244 .f = cmd_show_set_raw_parsed,
11246 .help_str = "show <raw_encap|raw_decap> <index>",
11248 (void *)&cmd_show_set_raw_cmd_show,
11249 (void *)&cmd_show_set_raw_cmd_what,
11250 (void *)&cmd_show_set_raw_cmd_index,
11254 cmdline_parse_inst_t cmd_show_set_raw_all = {
11255 .f = cmd_show_set_raw_parsed,
11257 .help_str = "show <raw_encap|raw_decap> all",
11259 (void *)&cmd_show_set_raw_cmd_show,
11260 (void *)&cmd_show_set_raw_cmd_what,
11261 (void *)&cmd_show_set_raw_cmd_all,