1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2016 6WIND S.A.
3 * Copyright 2016 Mellanox Technologies, Ltd
14 #include <rte_string_fns.h>
15 #include <rte_common.h>
16 #include <rte_ethdev.h>
17 #include <rte_byteorder.h>
18 #include <cmdline_parse.h>
19 #include <cmdline_parse_etheraddr.h>
20 #include <cmdline_parse_string.h>
21 #include <cmdline_parse_num.h>
23 #include <rte_hexdump.h>
24 #include <rte_vxlan.h>
28 #include <rte_geneve.h>
32 /** Parser token indices. */
54 COMMON_PRIORITY_LEVEL,
55 COMMON_INDIRECT_ACTION_ID,
60 /* TOP-level command. */
63 /* Top-level command. */
65 /* Sub-leve commands. */
72 /* Top-level command. */
74 /* Sub-level commands. */
93 /* Tunnel arguments. */
100 /* Destroy arguments. */
103 /* Query arguments. */
106 /* List arguments. */
109 /* Destroy aged flow arguments. */
112 /* Validate/create arguments. */
125 /* Indirect action arguments */
126 INDIRECT_ACTION_CREATE,
127 INDIRECT_ACTION_UPDATE,
128 INDIRECT_ACTION_DESTROY,
129 INDIRECT_ACTION_QUERY,
131 /* Indirect action create arguments */
132 INDIRECT_ACTION_CREATE_ID,
133 INDIRECT_ACTION_INGRESS,
134 INDIRECT_ACTION_EGRESS,
135 INDIRECT_ACTION_TRANSFER,
136 INDIRECT_ACTION_SPEC,
138 /* Indirect action destroy arguments */
139 INDIRECT_ACTION_DESTROY_ID,
141 /* Validate/create pattern. */
169 ITEM_RAW_PATTERN_HEX,
180 ITEM_VLAN_INNER_TYPE,
181 ITEM_VLAN_HAS_MORE_VLAN,
186 ITEM_IPV4_FRAGMENT_OFFSET,
198 ITEM_IPV6_HAS_FRAG_EXT,
218 ITEM_VXLAN_LAST_RSVD,
220 ITEM_E_TAG_GRP_ECID_B,
229 ITEM_GRE_C_RSVD0_VER,
248 ITEM_ARP_ETH_IPV4_SHA,
249 ITEM_ARP_ETH_IPV4_SPA,
250 ITEM_ARP_ETH_IPV4_THA,
251 ITEM_ARP_ETH_IPV4_TPA,
253 ITEM_IPV6_EXT_NEXT_HDR,
255 ITEM_IPV6_FRAG_EXT_NEXT_HDR,
256 ITEM_IPV6_FRAG_EXT_FRAG_DATA,
257 ITEM_IPV6_FRAG_EXT_ID,
262 ITEM_ICMP6_ND_NS_TARGET_ADDR,
264 ITEM_ICMP6_ND_NA_TARGET_ADDR,
266 ITEM_ICMP6_ND_OPT_TYPE,
267 ITEM_ICMP6_ND_OPT_SLA_ETH,
268 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
269 ITEM_ICMP6_ND_OPT_TLA_ETH,
270 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
283 ITEM_HIGIG2_CLASSIFICATION,
289 ITEM_L2TPV3OIP_SESSION_ID,
299 ITEM_ECPRI_COMMON_TYPE,
300 ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
301 ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
302 ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
303 ITEM_ECPRI_MSG_IQ_DATA_PCID,
304 ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
305 ITEM_ECPRI_MSG_DLY_MSR_MSRID,
307 ITEM_GENEVE_OPT_CLASS,
308 ITEM_GENEVE_OPT_TYPE,
309 ITEM_GENEVE_OPT_LENGTH,
310 ITEM_GENEVE_OPT_DATA,
312 ITEM_INTEGRITY_LEVEL,
313 ITEM_INTEGRITY_VALUE,
318 ITEM_PORT_REPRESENTOR,
319 ITEM_PORT_REPRESENTOR_PORT_ID,
320 ITEM_REPRESENTED_PORT,
321 ITEM_REPRESENTED_PORT_ETHDEV_PORT_ID,
323 ITEM_FLEX_ITEM_HANDLE,
324 ITEM_FLEX_PATTERN_HANDLE,
327 ITEM_L2TPV2_COMMON_TYPE,
328 ITEM_L2TPV2_COMMON_TYPE_DATA_L,
329 ITEM_L2TPV2_COMMON_TYPE_CTRL,
330 ITEM_L2TPV2_MSG_DATA_L_LENGTH,
331 ITEM_L2TPV2_MSG_DATA_L_TUNNEL_ID,
332 ITEM_L2TPV2_MSG_DATA_L_SESSION_ID,
333 ITEM_L2TPV2_MSG_CTRL_LENGTH,
334 ITEM_L2TPV2_MSG_CTRL_TUNNEL_ID,
335 ITEM_L2TPV2_MSG_CTRL_SESSION_ID,
336 ITEM_L2TPV2_MSG_CTRL_NS,
337 ITEM_L2TPV2_MSG_CTRL_NR,
343 /* Validate/create actions. */
362 ACTION_RSS_FUNC_DEFAULT,
363 ACTION_RSS_FUNC_TOEPLITZ,
364 ACTION_RSS_FUNC_SIMPLE_XOR,
365 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ,
377 ACTION_PHY_PORT_ORIGINAL,
378 ACTION_PHY_PORT_INDEX,
380 ACTION_PORT_ID_ORIGINAL,
384 ACTION_METER_COLOR_TYPE,
385 ACTION_METER_COLOR_GREEN,
386 ACTION_METER_COLOR_YELLOW,
387 ACTION_METER_COLOR_RED,
389 ACTION_OF_SET_MPLS_TTL,
390 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
391 ACTION_OF_DEC_MPLS_TTL,
392 ACTION_OF_SET_NW_TTL,
393 ACTION_OF_SET_NW_TTL_NW_TTL,
394 ACTION_OF_DEC_NW_TTL,
395 ACTION_OF_COPY_TTL_OUT,
396 ACTION_OF_COPY_TTL_IN,
399 ACTION_OF_PUSH_VLAN_ETHERTYPE,
400 ACTION_OF_SET_VLAN_VID,
401 ACTION_OF_SET_VLAN_VID_VLAN_VID,
402 ACTION_OF_SET_VLAN_PCP,
403 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
405 ACTION_OF_POP_MPLS_ETHERTYPE,
407 ACTION_OF_PUSH_MPLS_ETHERTYPE,
414 ACTION_MPLSOGRE_ENCAP,
415 ACTION_MPLSOGRE_DECAP,
416 ACTION_MPLSOUDP_ENCAP,
417 ACTION_MPLSOUDP_DECAP,
419 ACTION_SET_IPV4_SRC_IPV4_SRC,
421 ACTION_SET_IPV4_DST_IPV4_DST,
423 ACTION_SET_IPV6_SRC_IPV6_SRC,
425 ACTION_SET_IPV6_DST_IPV6_DST,
427 ACTION_SET_TP_SRC_TP_SRC,
429 ACTION_SET_TP_DST_TP_DST,
435 ACTION_SET_MAC_SRC_MAC_SRC,
437 ACTION_SET_MAC_DST_MAC_DST,
439 ACTION_INC_TCP_SEQ_VALUE,
441 ACTION_DEC_TCP_SEQ_VALUE,
443 ACTION_INC_TCP_ACK_VALUE,
445 ACTION_DEC_TCP_ACK_VALUE,
448 ACTION_RAW_ENCAP_INDEX,
449 ACTION_RAW_ENCAP_INDEX_VALUE,
450 ACTION_RAW_DECAP_INDEX,
451 ACTION_RAW_DECAP_INDEX_VALUE,
454 ACTION_SET_TAG_INDEX,
457 ACTION_SET_META_DATA,
458 ACTION_SET_META_MASK,
459 ACTION_SET_IPV4_DSCP,
460 ACTION_SET_IPV4_DSCP_VALUE,
461 ACTION_SET_IPV6_DSCP,
462 ACTION_SET_IPV6_DSCP_VALUE,
468 ACTION_SAMPLE_INDEX_VALUE,
470 INDIRECT_ACTION_ID2PTR,
472 ACTION_MODIFY_FIELD_OP,
473 ACTION_MODIFY_FIELD_OP_VALUE,
474 ACTION_MODIFY_FIELD_DST_TYPE,
475 ACTION_MODIFY_FIELD_DST_TYPE_VALUE,
476 ACTION_MODIFY_FIELD_DST_LEVEL,
477 ACTION_MODIFY_FIELD_DST_OFFSET,
478 ACTION_MODIFY_FIELD_SRC_TYPE,
479 ACTION_MODIFY_FIELD_SRC_TYPE_VALUE,
480 ACTION_MODIFY_FIELD_SRC_LEVEL,
481 ACTION_MODIFY_FIELD_SRC_OFFSET,
482 ACTION_MODIFY_FIELD_SRC_VALUE,
483 ACTION_MODIFY_FIELD_SRC_POINTER,
484 ACTION_MODIFY_FIELD_WIDTH,
486 ACTION_CONNTRACK_UPDATE,
487 ACTION_CONNTRACK_UPDATE_DIR,
488 ACTION_CONNTRACK_UPDATE_CTX,
492 ACTION_PORT_REPRESENTOR,
493 ACTION_PORT_REPRESENTOR_PORT_ID,
494 ACTION_REPRESENTED_PORT,
495 ACTION_REPRESENTED_PORT_ETHDEV_PORT_ID,
498 /** Maximum size for pattern in struct rte_flow_item_raw. */
499 #define ITEM_RAW_PATTERN_SIZE 512
501 /** Maximum size for GENEVE option data pattern in bytes. */
502 #define ITEM_GENEVE_OPT_DATA_SIZE 124
504 /** Storage size for struct rte_flow_item_raw including pattern. */
505 #define ITEM_RAW_SIZE \
506 (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE)
508 /** Maximum size for external pattern in struct rte_flow_action_modify_data. */
509 #define ACTION_MODIFY_PATTERN_SIZE 32
511 /** Storage size for struct rte_flow_action_modify_field including pattern. */
512 #define ACTION_MODIFY_SIZE \
513 (sizeof(struct rte_flow_action_modify_field) + \
514 ACTION_MODIFY_PATTERN_SIZE)
516 /** Maximum number of queue indices in struct rte_flow_action_rss. */
517 #define ACTION_RSS_QUEUE_NUM 128
519 /** Storage for struct rte_flow_action_rss including external data. */
520 struct action_rss_data {
521 struct rte_flow_action_rss conf;
522 uint8_t key[RSS_HASH_KEY_LENGTH];
523 uint16_t queue[ACTION_RSS_QUEUE_NUM];
526 /** Maximum data size in struct rte_flow_action_raw_encap. */
527 #define ACTION_RAW_ENCAP_MAX_DATA 512
528 #define RAW_ENCAP_CONFS_MAX_NUM 8
530 /** Storage for struct rte_flow_action_raw_encap. */
531 struct raw_encap_conf {
532 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
533 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
537 struct raw_encap_conf raw_encap_confs[RAW_ENCAP_CONFS_MAX_NUM];
539 /** Storage for struct rte_flow_action_raw_encap including external data. */
540 struct action_raw_encap_data {
541 struct rte_flow_action_raw_encap conf;
542 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
543 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
547 /** Storage for struct rte_flow_action_raw_decap. */
548 struct raw_decap_conf {
549 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
553 struct raw_decap_conf raw_decap_confs[RAW_ENCAP_CONFS_MAX_NUM];
555 /** Storage for struct rte_flow_action_raw_decap including external data. */
556 struct action_raw_decap_data {
557 struct rte_flow_action_raw_decap conf;
558 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
562 struct vxlan_encap_conf vxlan_encap_conf = {
566 .vni = "\x00\x00\x00",
568 .udp_dst = RTE_BE16(RTE_VXLAN_DEFAULT_PORT),
569 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
570 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
571 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
572 "\x00\x00\x00\x00\x00\x00\x00\x01",
573 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
574 "\x00\x00\x00\x00\x00\x00\x11\x11",
578 .eth_src = "\x00\x00\x00\x00\x00\x00",
579 .eth_dst = "\xff\xff\xff\xff\xff\xff",
582 /** Maximum number of items in struct rte_flow_action_vxlan_encap. */
583 #define ACTION_VXLAN_ENCAP_ITEMS_NUM 6
585 /** Storage for struct rte_flow_action_vxlan_encap including external data. */
586 struct action_vxlan_encap_data {
587 struct rte_flow_action_vxlan_encap conf;
588 struct rte_flow_item items[ACTION_VXLAN_ENCAP_ITEMS_NUM];
589 struct rte_flow_item_eth item_eth;
590 struct rte_flow_item_vlan item_vlan;
592 struct rte_flow_item_ipv4 item_ipv4;
593 struct rte_flow_item_ipv6 item_ipv6;
595 struct rte_flow_item_udp item_udp;
596 struct rte_flow_item_vxlan item_vxlan;
599 struct nvgre_encap_conf nvgre_encap_conf = {
602 .tni = "\x00\x00\x00",
603 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
604 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
605 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
606 "\x00\x00\x00\x00\x00\x00\x00\x01",
607 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
608 "\x00\x00\x00\x00\x00\x00\x11\x11",
610 .eth_src = "\x00\x00\x00\x00\x00\x00",
611 .eth_dst = "\xff\xff\xff\xff\xff\xff",
614 /** Maximum number of items in struct rte_flow_action_nvgre_encap. */
615 #define ACTION_NVGRE_ENCAP_ITEMS_NUM 5
617 /** Storage for struct rte_flow_action_nvgre_encap including external data. */
618 struct action_nvgre_encap_data {
619 struct rte_flow_action_nvgre_encap conf;
620 struct rte_flow_item items[ACTION_NVGRE_ENCAP_ITEMS_NUM];
621 struct rte_flow_item_eth item_eth;
622 struct rte_flow_item_vlan item_vlan;
624 struct rte_flow_item_ipv4 item_ipv4;
625 struct rte_flow_item_ipv6 item_ipv6;
627 struct rte_flow_item_nvgre item_nvgre;
630 struct l2_encap_conf l2_encap_conf;
632 struct l2_decap_conf l2_decap_conf;
634 struct mplsogre_encap_conf mplsogre_encap_conf;
636 struct mplsogre_decap_conf mplsogre_decap_conf;
638 struct mplsoudp_encap_conf mplsoudp_encap_conf;
640 struct mplsoudp_decap_conf mplsoudp_decap_conf;
642 struct rte_flow_action_conntrack conntrack_context;
644 #define ACTION_SAMPLE_ACTIONS_NUM 10
645 #define RAW_SAMPLE_CONFS_MAX_NUM 8
646 /** Storage for struct rte_flow_action_sample including external data. */
647 struct action_sample_data {
648 struct rte_flow_action_sample conf;
651 /** Storage for struct rte_flow_action_sample. */
652 struct raw_sample_conf {
653 struct rte_flow_action data[ACTION_SAMPLE_ACTIONS_NUM];
655 struct raw_sample_conf raw_sample_confs[RAW_SAMPLE_CONFS_MAX_NUM];
656 struct rte_flow_action_mark sample_mark[RAW_SAMPLE_CONFS_MAX_NUM];
657 struct rte_flow_action_queue sample_queue[RAW_SAMPLE_CONFS_MAX_NUM];
658 struct rte_flow_action_count sample_count[RAW_SAMPLE_CONFS_MAX_NUM];
659 struct rte_flow_action_port_id sample_port_id[RAW_SAMPLE_CONFS_MAX_NUM];
660 struct rte_flow_action_raw_encap sample_encap[RAW_SAMPLE_CONFS_MAX_NUM];
661 struct action_vxlan_encap_data sample_vxlan_encap[RAW_SAMPLE_CONFS_MAX_NUM];
662 struct action_nvgre_encap_data sample_nvgre_encap[RAW_SAMPLE_CONFS_MAX_NUM];
663 struct action_rss_data sample_rss_data[RAW_SAMPLE_CONFS_MAX_NUM];
664 struct rte_flow_action_vf sample_vf[RAW_SAMPLE_CONFS_MAX_NUM];
666 static const char *const modify_field_ops[] = {
667 "set", "add", "sub", NULL
670 static const char *const modify_field_ids[] = {
671 "start", "mac_dst", "mac_src",
672 "vlan_type", "vlan_id", "mac_type",
673 "ipv4_dscp", "ipv4_ttl", "ipv4_src", "ipv4_dst",
674 "ipv6_dscp", "ipv6_hoplimit", "ipv6_src", "ipv6_dst",
675 "tcp_port_src", "tcp_port_dst",
676 "tcp_seq_num", "tcp_ack_num", "tcp_flags",
677 "udp_port_src", "udp_port_dst",
678 "vxlan_vni", "geneve_vni", "gtp_teid",
679 "tag", "mark", "meta", "pointer", "value", NULL
682 /** Maximum number of subsequent tokens and arguments on the stack. */
683 #define CTX_STACK_SIZE 16
685 /** Parser context. */
687 /** Stack of subsequent token lists to process. */
688 const enum index *next[CTX_STACK_SIZE];
689 /** Arguments for stacked tokens. */
690 const void *args[CTX_STACK_SIZE];
691 enum index curr; /**< Current token index. */
692 enum index prev; /**< Index of the last token seen. */
693 int next_num; /**< Number of entries in next[]. */
694 int args_num; /**< Number of entries in args[]. */
695 uint32_t eol:1; /**< EOL has been detected. */
696 uint32_t last:1; /**< No more arguments. */
697 portid_t port; /**< Current port ID (for completions). */
698 uint32_t objdata; /**< Object-specific data. */
699 void *object; /**< Address of current object for relative offsets. */
700 void *objmask; /**< Object a full mask must be written to. */
703 /** Token argument. */
705 uint32_t hton:1; /**< Use network byte ordering. */
706 uint32_t sign:1; /**< Value is signed. */
707 uint32_t bounded:1; /**< Value is bounded. */
708 uintmax_t min; /**< Minimum value if bounded. */
709 uintmax_t max; /**< Maximum value if bounded. */
710 uint32_t offset; /**< Relative offset from ctx->object. */
711 uint32_t size; /**< Field size. */
712 const uint8_t *mask; /**< Bit-mask to use instead of offset/size. */
715 /** Parser token definition. */
717 /** Type displayed during completion (defaults to "TOKEN"). */
719 /** Help displayed during completion (defaults to token name). */
721 /** Private data used by parser functions. */
724 * Lists of subsequent tokens to push on the stack. Each call to the
725 * parser consumes the last entry of that stack.
727 const enum index *const *next;
728 /** Arguments stack for subsequent tokens that need them. */
729 const struct arg *const *args;
731 * Token-processing callback, returns -1 in case of error, the
732 * length of the matched string otherwise. If NULL, attempts to
733 * match the token name.
735 * If buf is not NULL, the result should be stored in it according
736 * to context. An error is returned if not large enough.
738 int (*call)(struct context *ctx, const struct token *token,
739 const char *str, unsigned int len,
740 void *buf, unsigned int size);
742 * Callback that provides possible values for this token, used for
743 * completion. Returns -1 in case of error, the number of possible
744 * values otherwise. If NULL, the token name is used.
746 * If buf is not NULL, entry index ent is written to buf and the
747 * full length of the entry is returned (same behavior as
750 int (*comp)(struct context *ctx, const struct token *token,
751 unsigned int ent, char *buf, unsigned int size);
752 /** Mandatory token name, no default value. */
756 /** Static initializer for the next field. */
757 #define NEXT(...) (const enum index *const []){ __VA_ARGS__, NULL, }
759 /** Static initializer for a NEXT() entry. */
760 #define NEXT_ENTRY(...) (const enum index []){ __VA_ARGS__, ZERO, }
762 /** Static initializer for the args field. */
763 #define ARGS(...) (const struct arg *const []){ __VA_ARGS__, NULL, }
765 /** Static initializer for ARGS() to target a field. */
766 #define ARGS_ENTRY(s, f) \
767 (&(const struct arg){ \
768 .offset = offsetof(s, f), \
769 .size = sizeof(((s *)0)->f), \
772 /** Static initializer for ARGS() to target a bit-field. */
773 #define ARGS_ENTRY_BF(s, f, b) \
774 (&(const struct arg){ \
776 .mask = (const void *)&(const s){ .f = (1 << (b)) - 1 }, \
779 /** Static initializer for ARGS() to target a field with limits. */
780 #define ARGS_ENTRY_BOUNDED(s, f, i, a) \
781 (&(const struct arg){ \
785 .offset = offsetof(s, f), \
786 .size = sizeof(((s *)0)->f), \
789 /** Static initializer for ARGS() to target an arbitrary bit-mask. */
790 #define ARGS_ENTRY_MASK(s, f, m) \
791 (&(const struct arg){ \
792 .offset = offsetof(s, f), \
793 .size = sizeof(((s *)0)->f), \
794 .mask = (const void *)(m), \
797 /** Same as ARGS_ENTRY_MASK() using network byte ordering for the value. */
798 #define ARGS_ENTRY_MASK_HTON(s, f, m) \
799 (&(const struct arg){ \
801 .offset = offsetof(s, f), \
802 .size = sizeof(((s *)0)->f), \
803 .mask = (const void *)(m), \
806 /** Static initializer for ARGS() to target a pointer. */
807 #define ARGS_ENTRY_PTR(s, f) \
808 (&(const struct arg){ \
809 .size = sizeof(*((s *)0)->f), \
812 /** Static initializer for ARGS() with arbitrary offset and size. */
813 #define ARGS_ENTRY_ARB(o, s) \
814 (&(const struct arg){ \
819 /** Same as ARGS_ENTRY_ARB() with bounded values. */
820 #define ARGS_ENTRY_ARB_BOUNDED(o, s, i, a) \
821 (&(const struct arg){ \
829 /** Same as ARGS_ENTRY() using network byte ordering. */
830 #define ARGS_ENTRY_HTON(s, f) \
831 (&(const struct arg){ \
833 .offset = offsetof(s, f), \
834 .size = sizeof(((s *)0)->f), \
837 /** Same as ARGS_ENTRY_HTON() for a single argument, without structure. */
838 #define ARG_ENTRY_HTON(s) \
839 (&(const struct arg){ \
845 /** Parser output buffer layout expected by cmd_flow_parsed(). */
847 enum index command; /**< Flow command. */
848 portid_t port; /**< Affected port ID. */
852 uint32_t action_id_n;
853 } ia_destroy; /**< Indirect action destroy arguments. */
856 } ia; /* Indirect action query arguments */
858 struct rte_flow_attr attr;
859 struct tunnel_ops tunnel_ops;
860 struct rte_flow_item *pattern;
861 struct rte_flow_action *actions;
865 } vc; /**< Validate/create arguments. */
869 } destroy; /**< Destroy arguments. */
874 } dump; /**< Dump arguments. */
877 struct rte_flow_action action;
878 } query; /**< Query arguments. */
882 } list; /**< List arguments. */
885 } isolate; /**< Isolated mode arguments. */
888 } aged; /**< Aged arguments. */
891 } policy;/**< Policy arguments. */
896 } flex; /**< Flex arguments*/
897 } args; /**< Command arguments. */
900 /** Private data for pattern items. */
901 struct parse_item_priv {
902 enum rte_flow_item_type type; /**< Item type. */
903 uint32_t size; /**< Size of item specification structure. */
906 #define PRIV_ITEM(t, s) \
907 (&(const struct parse_item_priv){ \
908 .type = RTE_FLOW_ITEM_TYPE_ ## t, \
912 /** Private data for actions. */
913 struct parse_action_priv {
914 enum rte_flow_action_type type; /**< Action type. */
915 uint32_t size; /**< Size of action configuration structure. */
918 #define PRIV_ACTION(t, s) \
919 (&(const struct parse_action_priv){ \
920 .type = RTE_FLOW_ACTION_TYPE_ ## t, \
924 static const enum index next_flex_item[] = {
931 static const enum index next_ia_create_attr[] = {
932 INDIRECT_ACTION_CREATE_ID,
933 INDIRECT_ACTION_INGRESS,
934 INDIRECT_ACTION_EGRESS,
935 INDIRECT_ACTION_TRANSFER,
936 INDIRECT_ACTION_SPEC,
940 static const enum index next_dump_subcmd[] = {
946 static const enum index next_ia_subcmd[] = {
947 INDIRECT_ACTION_CREATE,
948 INDIRECT_ACTION_UPDATE,
949 INDIRECT_ACTION_DESTROY,
950 INDIRECT_ACTION_QUERY,
954 static const enum index next_vc_attr[] = {
966 static const enum index next_destroy_attr[] = {
972 static const enum index next_dump_attr[] = {
978 static const enum index next_list_attr[] = {
984 static const enum index next_aged_attr[] = {
990 static const enum index next_ia_destroy_attr[] = {
991 INDIRECT_ACTION_DESTROY_ID,
996 static const enum index item_param[] = {
1005 static const enum index next_item[] = {
1042 ITEM_ICMP6_ND_OPT_SLA_ETH,
1043 ITEM_ICMP6_ND_OPT_TLA_ETH,
1049 ITEM_PPPOE_PROTO_ID,
1060 ITEM_PORT_REPRESENTOR,
1061 ITEM_REPRESENTED_PORT,
1069 static const enum index item_fuzzy[] = {
1075 static const enum index item_any[] = {
1081 static const enum index item_vf[] = {
1087 static const enum index item_phy_port[] = {
1088 ITEM_PHY_PORT_INDEX,
1093 static const enum index item_port_id[] = {
1099 static const enum index item_mark[] = {
1105 static const enum index item_raw[] = {
1111 ITEM_RAW_PATTERN_HEX,
1116 static const enum index item_eth[] = {
1125 static const enum index item_vlan[] = {
1130 ITEM_VLAN_INNER_TYPE,
1131 ITEM_VLAN_HAS_MORE_VLAN,
1136 static const enum index item_ipv4[] = {
1140 ITEM_IPV4_FRAGMENT_OFFSET,
1149 static const enum index item_ipv6[] = {
1156 ITEM_IPV6_HAS_FRAG_EXT,
1161 static const enum index item_icmp[] = {
1170 static const enum index item_udp[] = {
1177 static const enum index item_tcp[] = {
1185 static const enum index item_sctp[] = {
1194 static const enum index item_vxlan[] = {
1196 ITEM_VXLAN_LAST_RSVD,
1201 static const enum index item_e_tag[] = {
1202 ITEM_E_TAG_GRP_ECID_B,
1207 static const enum index item_nvgre[] = {
1213 static const enum index item_mpls[] = {
1221 static const enum index item_gre[] = {
1223 ITEM_GRE_C_RSVD0_VER,
1231 static const enum index item_gre_key[] = {
1237 static const enum index item_gtp[] = {
1245 static const enum index item_geneve[] = {
1253 static const enum index item_vxlan_gpe[] = {
1259 static const enum index item_arp_eth_ipv4[] = {
1260 ITEM_ARP_ETH_IPV4_SHA,
1261 ITEM_ARP_ETH_IPV4_SPA,
1262 ITEM_ARP_ETH_IPV4_THA,
1263 ITEM_ARP_ETH_IPV4_TPA,
1268 static const enum index item_ipv6_ext[] = {
1269 ITEM_IPV6_EXT_NEXT_HDR,
1274 static const enum index item_ipv6_frag_ext[] = {
1275 ITEM_IPV6_FRAG_EXT_NEXT_HDR,
1276 ITEM_IPV6_FRAG_EXT_FRAG_DATA,
1277 ITEM_IPV6_FRAG_EXT_ID,
1282 static const enum index item_icmp6[] = {
1289 static const enum index item_icmp6_nd_ns[] = {
1290 ITEM_ICMP6_ND_NS_TARGET_ADDR,
1295 static const enum index item_icmp6_nd_na[] = {
1296 ITEM_ICMP6_ND_NA_TARGET_ADDR,
1301 static const enum index item_icmp6_nd_opt[] = {
1302 ITEM_ICMP6_ND_OPT_TYPE,
1307 static const enum index item_icmp6_nd_opt_sla_eth[] = {
1308 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
1313 static const enum index item_icmp6_nd_opt_tla_eth[] = {
1314 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
1319 static const enum index item_meta[] = {
1325 static const enum index item_gtp_psc[] = {
1332 static const enum index item_pppoed[] = {
1338 static const enum index item_pppoes[] = {
1344 static const enum index item_pppoe_proto_id[] = {
1349 static const enum index item_higig2[] = {
1350 ITEM_HIGIG2_CLASSIFICATION,
1356 static const enum index item_esp[] = {
1362 static const enum index item_ah[] = {
1368 static const enum index item_pfcp[] = {
1375 static const enum index next_set_raw[] = {
1381 static const enum index item_tag[] = {
1388 static const enum index item_l2tpv3oip[] = {
1389 ITEM_L2TPV3OIP_SESSION_ID,
1394 static const enum index item_ecpri[] = {
1400 static const enum index item_ecpri_common[] = {
1401 ITEM_ECPRI_COMMON_TYPE,
1405 static const enum index item_ecpri_common_type[] = {
1406 ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
1407 ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
1408 ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
1412 static const enum index item_geneve_opt[] = {
1413 ITEM_GENEVE_OPT_CLASS,
1414 ITEM_GENEVE_OPT_TYPE,
1415 ITEM_GENEVE_OPT_LENGTH,
1416 ITEM_GENEVE_OPT_DATA,
1421 static const enum index item_integrity[] = {
1422 ITEM_INTEGRITY_LEVEL,
1423 ITEM_INTEGRITY_VALUE,
1427 static const enum index item_integrity_lv[] = {
1428 ITEM_INTEGRITY_LEVEL,
1429 ITEM_INTEGRITY_VALUE,
1434 static const enum index item_port_representor[] = {
1435 ITEM_PORT_REPRESENTOR_PORT_ID,
1440 static const enum index item_represented_port[] = {
1441 ITEM_REPRESENTED_PORT_ETHDEV_PORT_ID,
1446 static const enum index item_flex[] = {
1447 ITEM_FLEX_PATTERN_HANDLE,
1448 ITEM_FLEX_ITEM_HANDLE,
1453 static const enum index item_l2tpv2[] = {
1459 static const enum index item_l2tpv2_common[] = {
1460 ITEM_L2TPV2_COMMON_TYPE,
1464 static const enum index item_l2tpv2_common_type[] = {
1465 ITEM_L2TPV2_COMMON_TYPE_DATA_L,
1466 ITEM_L2TPV2_COMMON_TYPE_CTRL,
1470 static const enum index item_ppp[] = {
1478 static const enum index next_action[] = {
1495 ACTION_OF_SET_MPLS_TTL,
1496 ACTION_OF_DEC_MPLS_TTL,
1497 ACTION_OF_SET_NW_TTL,
1498 ACTION_OF_DEC_NW_TTL,
1499 ACTION_OF_COPY_TTL_OUT,
1500 ACTION_OF_COPY_TTL_IN,
1502 ACTION_OF_PUSH_VLAN,
1503 ACTION_OF_SET_VLAN_VID,
1504 ACTION_OF_SET_VLAN_PCP,
1506 ACTION_OF_PUSH_MPLS,
1513 ACTION_MPLSOGRE_ENCAP,
1514 ACTION_MPLSOGRE_DECAP,
1515 ACTION_MPLSOUDP_ENCAP,
1516 ACTION_MPLSOUDP_DECAP,
1517 ACTION_SET_IPV4_SRC,
1518 ACTION_SET_IPV4_DST,
1519 ACTION_SET_IPV6_SRC,
1520 ACTION_SET_IPV6_DST,
1536 ACTION_SET_IPV4_DSCP,
1537 ACTION_SET_IPV6_DSCP,
1541 ACTION_MODIFY_FIELD,
1543 ACTION_CONNTRACK_UPDATE,
1544 ACTION_PORT_REPRESENTOR,
1545 ACTION_REPRESENTED_PORT,
1549 static const enum index action_mark[] = {
1555 static const enum index action_queue[] = {
1561 static const enum index action_count[] = {
1567 static const enum index action_rss[] = {
1578 static const enum index action_vf[] = {
1585 static const enum index action_phy_port[] = {
1586 ACTION_PHY_PORT_ORIGINAL,
1587 ACTION_PHY_PORT_INDEX,
1592 static const enum index action_port_id[] = {
1593 ACTION_PORT_ID_ORIGINAL,
1599 static const enum index action_meter[] = {
1605 static const enum index action_meter_color[] = {
1606 ACTION_METER_COLOR_TYPE,
1611 static const enum index action_of_set_mpls_ttl[] = {
1612 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
1617 static const enum index action_of_set_nw_ttl[] = {
1618 ACTION_OF_SET_NW_TTL_NW_TTL,
1623 static const enum index action_of_push_vlan[] = {
1624 ACTION_OF_PUSH_VLAN_ETHERTYPE,
1629 static const enum index action_of_set_vlan_vid[] = {
1630 ACTION_OF_SET_VLAN_VID_VLAN_VID,
1635 static const enum index action_of_set_vlan_pcp[] = {
1636 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
1641 static const enum index action_of_pop_mpls[] = {
1642 ACTION_OF_POP_MPLS_ETHERTYPE,
1647 static const enum index action_of_push_mpls[] = {
1648 ACTION_OF_PUSH_MPLS_ETHERTYPE,
1653 static const enum index action_set_ipv4_src[] = {
1654 ACTION_SET_IPV4_SRC_IPV4_SRC,
1659 static const enum index action_set_mac_src[] = {
1660 ACTION_SET_MAC_SRC_MAC_SRC,
1665 static const enum index action_set_ipv4_dst[] = {
1666 ACTION_SET_IPV4_DST_IPV4_DST,
1671 static const enum index action_set_ipv6_src[] = {
1672 ACTION_SET_IPV6_SRC_IPV6_SRC,
1677 static const enum index action_set_ipv6_dst[] = {
1678 ACTION_SET_IPV6_DST_IPV6_DST,
1683 static const enum index action_set_tp_src[] = {
1684 ACTION_SET_TP_SRC_TP_SRC,
1689 static const enum index action_set_tp_dst[] = {
1690 ACTION_SET_TP_DST_TP_DST,
1695 static const enum index action_set_ttl[] = {
1701 static const enum index action_jump[] = {
1707 static const enum index action_set_mac_dst[] = {
1708 ACTION_SET_MAC_DST_MAC_DST,
1713 static const enum index action_inc_tcp_seq[] = {
1714 ACTION_INC_TCP_SEQ_VALUE,
1719 static const enum index action_dec_tcp_seq[] = {
1720 ACTION_DEC_TCP_SEQ_VALUE,
1725 static const enum index action_inc_tcp_ack[] = {
1726 ACTION_INC_TCP_ACK_VALUE,
1731 static const enum index action_dec_tcp_ack[] = {
1732 ACTION_DEC_TCP_ACK_VALUE,
1737 static const enum index action_raw_encap[] = {
1738 ACTION_RAW_ENCAP_INDEX,
1743 static const enum index action_raw_decap[] = {
1744 ACTION_RAW_DECAP_INDEX,
1749 static const enum index action_set_tag[] = {
1750 ACTION_SET_TAG_DATA,
1751 ACTION_SET_TAG_INDEX,
1752 ACTION_SET_TAG_MASK,
1757 static const enum index action_set_meta[] = {
1758 ACTION_SET_META_DATA,
1759 ACTION_SET_META_MASK,
1764 static const enum index action_set_ipv4_dscp[] = {
1765 ACTION_SET_IPV4_DSCP_VALUE,
1770 static const enum index action_set_ipv6_dscp[] = {
1771 ACTION_SET_IPV6_DSCP_VALUE,
1776 static const enum index action_age[] = {
1783 static const enum index action_sample[] = {
1785 ACTION_SAMPLE_RATIO,
1786 ACTION_SAMPLE_INDEX,
1791 static const enum index next_action_sample[] = {
1804 static const enum index action_modify_field_dst[] = {
1805 ACTION_MODIFY_FIELD_DST_LEVEL,
1806 ACTION_MODIFY_FIELD_DST_OFFSET,
1807 ACTION_MODIFY_FIELD_SRC_TYPE,
1811 static const enum index action_modify_field_src[] = {
1812 ACTION_MODIFY_FIELD_SRC_LEVEL,
1813 ACTION_MODIFY_FIELD_SRC_OFFSET,
1814 ACTION_MODIFY_FIELD_SRC_VALUE,
1815 ACTION_MODIFY_FIELD_SRC_POINTER,
1816 ACTION_MODIFY_FIELD_WIDTH,
1820 static const enum index action_update_conntrack[] = {
1821 ACTION_CONNTRACK_UPDATE_DIR,
1822 ACTION_CONNTRACK_UPDATE_CTX,
1827 static const enum index action_port_representor[] = {
1828 ACTION_PORT_REPRESENTOR_PORT_ID,
1833 static const enum index action_represented_port[] = {
1834 ACTION_REPRESENTED_PORT_ETHDEV_PORT_ID,
1839 static int parse_set_raw_encap_decap(struct context *, const struct token *,
1840 const char *, unsigned int,
1841 void *, unsigned int);
1842 static int parse_set_sample_action(struct context *, const struct token *,
1843 const char *, unsigned int,
1844 void *, unsigned int);
1845 static int parse_set_init(struct context *, const struct token *,
1846 const char *, unsigned int,
1847 void *, unsigned int);
1849 parse_flex_handle(struct context *, const struct token *,
1850 const char *, unsigned int, void *, unsigned int);
1851 static int parse_init(struct context *, const struct token *,
1852 const char *, unsigned int,
1853 void *, unsigned int);
1854 static int parse_vc(struct context *, const struct token *,
1855 const char *, unsigned int,
1856 void *, unsigned int);
1857 static int parse_vc_spec(struct context *, const struct token *,
1858 const char *, unsigned int, void *, unsigned int);
1859 static int parse_vc_conf(struct context *, const struct token *,
1860 const char *, unsigned int, void *, unsigned int);
1861 static int parse_vc_item_ecpri_type(struct context *, const struct token *,
1862 const char *, unsigned int,
1863 void *, unsigned int);
1864 static int parse_vc_item_l2tpv2_type(struct context *, const struct token *,
1865 const char *, unsigned int,
1866 void *, unsigned int);
1867 static int parse_vc_action_meter_color_type(struct context *,
1868 const struct token *,
1869 const char *, unsigned int, void *,
1871 static int parse_vc_action_rss(struct context *, const struct token *,
1872 const char *, unsigned int, void *,
1874 static int parse_vc_action_rss_func(struct context *, const struct token *,
1875 const char *, unsigned int, void *,
1877 static int parse_vc_action_rss_type(struct context *, const struct token *,
1878 const char *, unsigned int, void *,
1880 static int parse_vc_action_rss_queue(struct context *, const struct token *,
1881 const char *, unsigned int, void *,
1883 static int parse_vc_action_vxlan_encap(struct context *, const struct token *,
1884 const char *, unsigned int, void *,
1886 static int parse_vc_action_nvgre_encap(struct context *, const struct token *,
1887 const char *, unsigned int, void *,
1889 static int parse_vc_action_l2_encap(struct context *, const struct token *,
1890 const char *, unsigned int, void *,
1892 static int parse_vc_action_l2_decap(struct context *, const struct token *,
1893 const char *, unsigned int, void *,
1895 static int parse_vc_action_mplsogre_encap(struct context *,
1896 const struct token *, const char *,
1897 unsigned int, void *, unsigned int);
1898 static int parse_vc_action_mplsogre_decap(struct context *,
1899 const struct token *, const char *,
1900 unsigned int, void *, unsigned int);
1901 static int parse_vc_action_mplsoudp_encap(struct context *,
1902 const struct token *, const char *,
1903 unsigned int, void *, unsigned int);
1904 static int parse_vc_action_mplsoudp_decap(struct context *,
1905 const struct token *, const char *,
1906 unsigned int, void *, unsigned int);
1907 static int parse_vc_action_raw_encap(struct context *,
1908 const struct token *, const char *,
1909 unsigned int, void *, unsigned int);
1910 static int parse_vc_action_raw_decap(struct context *,
1911 const struct token *, const char *,
1912 unsigned int, void *, unsigned int);
1913 static int parse_vc_action_raw_encap_index(struct context *,
1914 const struct token *, const char *,
1915 unsigned int, void *, unsigned int);
1916 static int parse_vc_action_raw_decap_index(struct context *,
1917 const struct token *, const char *,
1918 unsigned int, void *, unsigned int);
1919 static int parse_vc_action_set_meta(struct context *ctx,
1920 const struct token *token, const char *str,
1921 unsigned int len, void *buf,
1923 static int parse_vc_action_sample(struct context *ctx,
1924 const struct token *token, const char *str,
1925 unsigned int len, void *buf,
1928 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
1929 const char *str, unsigned int len, void *buf,
1932 parse_vc_modify_field_op(struct context *ctx, const struct token *token,
1933 const char *str, unsigned int len, void *buf,
1936 parse_vc_modify_field_id(struct context *ctx, const struct token *token,
1937 const char *str, unsigned int len, void *buf,
1940 parse_vc_action_conntrack_update(struct context *ctx, const struct token *token,
1941 const char *str, unsigned int len, void *buf,
1943 static int parse_destroy(struct context *, const struct token *,
1944 const char *, unsigned int,
1945 void *, unsigned int);
1946 static int parse_flush(struct context *, const struct token *,
1947 const char *, unsigned int,
1948 void *, unsigned int);
1949 static int parse_dump(struct context *, const struct token *,
1950 const char *, unsigned int,
1951 void *, unsigned int);
1952 static int parse_query(struct context *, const struct token *,
1953 const char *, unsigned int,
1954 void *, unsigned int);
1955 static int parse_action(struct context *, const struct token *,
1956 const char *, unsigned int,
1957 void *, unsigned int);
1958 static int parse_list(struct context *, const struct token *,
1959 const char *, unsigned int,
1960 void *, unsigned int);
1961 static int parse_aged(struct context *, const struct token *,
1962 const char *, unsigned int,
1963 void *, unsigned int);
1964 static int parse_isolate(struct context *, const struct token *,
1965 const char *, unsigned int,
1966 void *, unsigned int);
1967 static int parse_tunnel(struct context *, const struct token *,
1968 const char *, unsigned int,
1969 void *, unsigned int);
1970 static int parse_flex(struct context *, const struct token *,
1971 const char *, unsigned int, void *, unsigned int);
1972 static int parse_int(struct context *, const struct token *,
1973 const char *, unsigned int,
1974 void *, unsigned int);
1975 static int parse_prefix(struct context *, const struct token *,
1976 const char *, unsigned int,
1977 void *, unsigned int);
1978 static int parse_boolean(struct context *, const struct token *,
1979 const char *, unsigned int,
1980 void *, unsigned int);
1981 static int parse_string(struct context *, const struct token *,
1982 const char *, unsigned int,
1983 void *, unsigned int);
1984 static int parse_hex(struct context *ctx, const struct token *token,
1985 const char *str, unsigned int len,
1986 void *buf, unsigned int size);
1987 static int parse_string0(struct context *, const struct token *,
1988 const char *, unsigned int,
1989 void *, unsigned int);
1990 static int parse_mac_addr(struct context *, const struct token *,
1991 const char *, unsigned int,
1992 void *, unsigned int);
1993 static int parse_ipv4_addr(struct context *, const struct token *,
1994 const char *, unsigned int,
1995 void *, unsigned int);
1996 static int parse_ipv6_addr(struct context *, const struct token *,
1997 const char *, unsigned int,
1998 void *, unsigned int);
1999 static int parse_port(struct context *, const struct token *,
2000 const char *, unsigned int,
2001 void *, unsigned int);
2002 static int parse_ia(struct context *, const struct token *,
2003 const char *, unsigned int,
2004 void *, unsigned int);
2005 static int parse_ia_destroy(struct context *ctx, const struct token *token,
2006 const char *str, unsigned int len,
2007 void *buf, unsigned int size);
2008 static int parse_ia_id2ptr(struct context *ctx, const struct token *token,
2009 const char *str, unsigned int len, void *buf,
2011 static int parse_mp(struct context *, const struct token *,
2012 const char *, unsigned int,
2013 void *, unsigned int);
2014 static int comp_none(struct context *, const struct token *,
2015 unsigned int, char *, unsigned int);
2016 static int comp_boolean(struct context *, const struct token *,
2017 unsigned int, char *, unsigned int);
2018 static int comp_action(struct context *, const struct token *,
2019 unsigned int, char *, unsigned int);
2020 static int comp_port(struct context *, const struct token *,
2021 unsigned int, char *, unsigned int);
2022 static int comp_rule_id(struct context *, const struct token *,
2023 unsigned int, char *, unsigned int);
2024 static int comp_vc_action_rss_type(struct context *, const struct token *,
2025 unsigned int, char *, unsigned int);
2026 static int comp_vc_action_rss_queue(struct context *, const struct token *,
2027 unsigned int, char *, unsigned int);
2028 static int comp_set_raw_index(struct context *, const struct token *,
2029 unsigned int, char *, unsigned int);
2030 static int comp_set_sample_index(struct context *, const struct token *,
2031 unsigned int, char *, unsigned int);
2032 static int comp_set_modify_field_op(struct context *, const struct token *,
2033 unsigned int, char *, unsigned int);
2034 static int comp_set_modify_field_id(struct context *, const struct token *,
2035 unsigned int, char *, unsigned int);
2037 /** Token definitions. */
2038 static const struct token token_list[] = {
2039 /* Special tokens. */
2042 .help = "null entry, abused as the entry point",
2043 .next = NEXT(NEXT_ENTRY(FLOW, ADD)),
2048 .help = "command may end here",
2051 .name = "START_SET",
2052 .help = "null entry, abused as the entry point for set",
2053 .next = NEXT(NEXT_ENTRY(SET)),
2058 .help = "set command may end here",
2060 /* Common tokens. */
2061 [COMMON_INTEGER] = {
2064 .help = "integer value",
2068 [COMMON_UNSIGNED] = {
2069 .name = "{unsigned}",
2071 .help = "unsigned integer value",
2078 .help = "prefix length for bit-mask",
2079 .call = parse_prefix,
2082 [COMMON_BOOLEAN] = {
2083 .name = "{boolean}",
2085 .help = "any boolean value",
2086 .call = parse_boolean,
2087 .comp = comp_boolean,
2092 .help = "fixed string",
2093 .call = parse_string,
2099 .help = "fixed string",
2102 [COMMON_FILE_PATH] = {
2103 .name = "{file path}",
2105 .help = "file path",
2106 .call = parse_string0,
2109 [COMMON_MAC_ADDR] = {
2110 .name = "{MAC address}",
2112 .help = "standard MAC address notation",
2113 .call = parse_mac_addr,
2116 [COMMON_IPV4_ADDR] = {
2117 .name = "{IPv4 address}",
2118 .type = "IPV4 ADDRESS",
2119 .help = "standard IPv4 address notation",
2120 .call = parse_ipv4_addr,
2123 [COMMON_IPV6_ADDR] = {
2124 .name = "{IPv6 address}",
2125 .type = "IPV6 ADDRESS",
2126 .help = "standard IPv6 address notation",
2127 .call = parse_ipv6_addr,
2130 [COMMON_RULE_ID] = {
2131 .name = "{rule id}",
2133 .help = "rule identifier",
2135 .comp = comp_rule_id,
2137 [COMMON_PORT_ID] = {
2138 .name = "{port_id}",
2140 .help = "port identifier",
2144 [COMMON_GROUP_ID] = {
2145 .name = "{group_id}",
2147 .help = "group identifier",
2151 [COMMON_PRIORITY_LEVEL] = {
2154 .help = "priority level",
2158 [COMMON_INDIRECT_ACTION_ID] = {
2159 .name = "{indirect_action_id}",
2160 .type = "INDIRECT_ACTION_ID",
2161 .help = "indirect action id",
2165 [COMMON_POLICY_ID] = {
2166 .name = "{policy_id}",
2167 .type = "POLICY_ID",
2168 .help = "policy id",
2172 [COMMON_FLEX_TOKEN] = {
2173 .name = "{flex token}",
2174 .type = "flex token",
2175 .help = "flex token",
2179 [COMMON_FLEX_HANDLE] = {
2180 .name = "{flex handle}",
2181 .type = "FLEX HANDLE",
2182 .help = "fill flex item data",
2183 .call = parse_flex_handle,
2186 /* Top-level command. */
2189 .type = "{command} {port_id} [{arg} [...]]",
2190 .help = "manage ingress/egress flow rules",
2191 .next = NEXT(NEXT_ENTRY
2206 /* Top-level command. */
2207 [INDIRECT_ACTION] = {
2208 .name = "indirect_action",
2209 .type = "{command} {port_id} [{arg} [...]]",
2210 .help = "manage indirect actions",
2211 .next = NEXT(next_ia_subcmd, NEXT_ENTRY(COMMON_PORT_ID)),
2212 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2215 /* Sub-level commands. */
2216 [INDIRECT_ACTION_CREATE] = {
2218 .help = "create indirect action",
2219 .next = NEXT(next_ia_create_attr),
2222 [INDIRECT_ACTION_UPDATE] = {
2224 .help = "update indirect action",
2225 .next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_SPEC),
2226 NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
2227 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
2230 [INDIRECT_ACTION_DESTROY] = {
2232 .help = "destroy indirect action",
2233 .next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_DESTROY_ID)),
2234 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2235 .call = parse_ia_destroy,
2237 [INDIRECT_ACTION_QUERY] = {
2239 .help = "query indirect action",
2240 .next = NEXT(NEXT_ENTRY(END),
2241 NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
2242 .args = ARGS(ARGS_ENTRY(struct buffer, args.ia.action_id)),
2247 .help = "check whether a flow rule can be created",
2248 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_PORT_ID)),
2249 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2254 .help = "create a flow rule",
2255 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_PORT_ID)),
2256 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2261 .help = "destroy specific flow rules",
2262 .next = NEXT(NEXT_ENTRY(DESTROY_RULE),
2263 NEXT_ENTRY(COMMON_PORT_ID)),
2264 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2265 .call = parse_destroy,
2269 .help = "destroy all flow rules",
2270 .next = NEXT(NEXT_ENTRY(COMMON_PORT_ID)),
2271 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2272 .call = parse_flush,
2276 .help = "dump single/all flow rules to file",
2277 .next = NEXT(next_dump_subcmd, NEXT_ENTRY(COMMON_PORT_ID)),
2278 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2283 .help = "query an existing flow rule",
2284 .next = NEXT(NEXT_ENTRY(QUERY_ACTION),
2285 NEXT_ENTRY(COMMON_RULE_ID),
2286 NEXT_ENTRY(COMMON_PORT_ID)),
2287 .args = ARGS(ARGS_ENTRY(struct buffer, args.query.action.type),
2288 ARGS_ENTRY(struct buffer, args.query.rule),
2289 ARGS_ENTRY(struct buffer, port)),
2290 .call = parse_query,
2294 .help = "list existing flow rules",
2295 .next = NEXT(next_list_attr, NEXT_ENTRY(COMMON_PORT_ID)),
2296 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2301 .help = "list and destroy aged flows",
2302 .next = NEXT(next_aged_attr, NEXT_ENTRY(COMMON_PORT_ID)),
2303 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2308 .help = "restrict ingress traffic to the defined flow rules",
2309 .next = NEXT(NEXT_ENTRY(COMMON_BOOLEAN),
2310 NEXT_ENTRY(COMMON_PORT_ID)),
2311 .args = ARGS(ARGS_ENTRY(struct buffer, args.isolate.set),
2312 ARGS_ENTRY(struct buffer, port)),
2313 .call = parse_isolate,
2316 .name = "flex_item",
2317 .help = "flex item API",
2318 .next = NEXT(next_flex_item),
2321 [FLEX_ITEM_INIT] = {
2323 .help = "flex item init",
2324 .args = ARGS(ARGS_ENTRY(struct buffer, args.flex.token),
2325 ARGS_ENTRY(struct buffer, port)),
2326 .next = NEXT(NEXT_ENTRY(COMMON_FLEX_TOKEN),
2327 NEXT_ENTRY(COMMON_PORT_ID)),
2330 [FLEX_ITEM_CREATE] = {
2332 .help = "flex item create",
2333 .args = ARGS(ARGS_ENTRY(struct buffer, args.flex.filename),
2334 ARGS_ENTRY(struct buffer, args.flex.token),
2335 ARGS_ENTRY(struct buffer, port)),
2336 .next = NEXT(NEXT_ENTRY(COMMON_FILE_PATH),
2337 NEXT_ENTRY(COMMON_FLEX_TOKEN),
2338 NEXT_ENTRY(COMMON_PORT_ID)),
2341 [FLEX_ITEM_DESTROY] = {
2343 .help = "flex item destroy",
2344 .args = ARGS(ARGS_ENTRY(struct buffer, args.flex.token),
2345 ARGS_ENTRY(struct buffer, port)),
2346 .next = NEXT(NEXT_ENTRY(COMMON_FLEX_TOKEN),
2347 NEXT_ENTRY(COMMON_PORT_ID)),
2352 .help = "new tunnel API",
2353 .next = NEXT(NEXT_ENTRY
2354 (TUNNEL_CREATE, TUNNEL_LIST, TUNNEL_DESTROY)),
2355 .call = parse_tunnel,
2357 /* Tunnel arguments. */
2360 .help = "create new tunnel object",
2361 .next = NEXT(NEXT_ENTRY(TUNNEL_CREATE_TYPE),
2362 NEXT_ENTRY(COMMON_PORT_ID)),
2363 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2364 .call = parse_tunnel,
2366 [TUNNEL_CREATE_TYPE] = {
2368 .help = "create new tunnel",
2369 .next = NEXT(NEXT_ENTRY(COMMON_FILE_PATH)),
2370 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, type)),
2371 .call = parse_tunnel,
2373 [TUNNEL_DESTROY] = {
2375 .help = "destroy tunnel",
2376 .next = NEXT(NEXT_ENTRY(TUNNEL_DESTROY_ID),
2377 NEXT_ENTRY(COMMON_PORT_ID)),
2378 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2379 .call = parse_tunnel,
2381 [TUNNEL_DESTROY_ID] = {
2383 .help = "tunnel identifier to destroy",
2384 .next = NEXT(NEXT_ENTRY(COMMON_UNSIGNED)),
2385 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2386 .call = parse_tunnel,
2390 .help = "list existing tunnels",
2391 .next = NEXT(NEXT_ENTRY(COMMON_PORT_ID)),
2392 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2393 .call = parse_tunnel,
2395 /* Destroy arguments. */
2398 .help = "specify a rule identifier",
2399 .next = NEXT(next_destroy_attr, NEXT_ENTRY(COMMON_RULE_ID)),
2400 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.destroy.rule)),
2401 .call = parse_destroy,
2403 /* Dump arguments. */
2407 .next = NEXT(next_dump_attr),
2408 .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file)),
2413 .help = "dump one rule",
2414 .next = NEXT(next_dump_attr, NEXT_ENTRY(COMMON_RULE_ID)),
2415 .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file),
2416 ARGS_ENTRY(struct buffer, args.dump.rule)),
2419 /* Query arguments. */
2423 .help = "action to query, must be part of the rule",
2424 .call = parse_action,
2425 .comp = comp_action,
2427 /* List arguments. */
2430 .help = "specify a group",
2431 .next = NEXT(next_list_attr, NEXT_ENTRY(COMMON_GROUP_ID)),
2432 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.list.group)),
2437 .help = "specify aged flows need be destroyed",
2441 /* Validate/create attributes. */
2444 .help = "specify a group",
2445 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_GROUP_ID)),
2446 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, group)),
2451 .help = "specify a priority level",
2452 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_PRIORITY_LEVEL)),
2453 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, priority)),
2458 .help = "affect rule to ingress",
2459 .next = NEXT(next_vc_attr),
2464 .help = "affect rule to egress",
2465 .next = NEXT(next_vc_attr),
2470 .help = "apply rule directly to endpoints found in pattern",
2471 .next = NEXT(next_vc_attr),
2475 .name = "tunnel_set",
2476 .help = "tunnel steer rule",
2477 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_UNSIGNED)),
2478 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2481 [VC_TUNNEL_MATCH] = {
2482 .name = "tunnel_match",
2483 .help = "tunnel match rule",
2484 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_UNSIGNED)),
2485 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2488 /* Validate/create pattern. */
2491 .help = "submit a list of pattern items",
2492 .next = NEXT(next_item),
2497 .help = "match value perfectly (with full bit-mask)",
2498 .call = parse_vc_spec,
2500 [ITEM_PARAM_SPEC] = {
2502 .help = "match value according to configured bit-mask",
2503 .call = parse_vc_spec,
2505 [ITEM_PARAM_LAST] = {
2507 .help = "specify upper bound to establish a range",
2508 .call = parse_vc_spec,
2510 [ITEM_PARAM_MASK] = {
2512 .help = "specify bit-mask with relevant bits set to one",
2513 .call = parse_vc_spec,
2515 [ITEM_PARAM_PREFIX] = {
2517 .help = "generate bit-mask from a prefix length",
2518 .call = parse_vc_spec,
2522 .help = "specify next pattern item",
2523 .next = NEXT(next_item),
2527 .help = "end list of pattern items",
2528 .priv = PRIV_ITEM(END, 0),
2529 .next = NEXT(NEXT_ENTRY(ACTIONS)),
2534 .help = "no-op pattern item",
2535 .priv = PRIV_ITEM(VOID, 0),
2536 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2541 .help = "perform actions when pattern does not match",
2542 .priv = PRIV_ITEM(INVERT, 0),
2543 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2548 .help = "match any protocol for the current layer",
2549 .priv = PRIV_ITEM(ANY, sizeof(struct rte_flow_item_any)),
2550 .next = NEXT(item_any),
2555 .help = "number of layers covered",
2556 .next = NEXT(item_any, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2557 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_any, num)),
2561 .help = "match traffic from/to the physical function",
2562 .priv = PRIV_ITEM(PF, 0),
2563 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2568 .help = "match traffic from/to a virtual function ID",
2569 .priv = PRIV_ITEM(VF, sizeof(struct rte_flow_item_vf)),
2570 .next = NEXT(item_vf),
2576 .next = NEXT(item_vf, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2577 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_vf, id)),
2581 .help = "match traffic from/to a specific physical port",
2582 .priv = PRIV_ITEM(PHY_PORT,
2583 sizeof(struct rte_flow_item_phy_port)),
2584 .next = NEXT(item_phy_port),
2587 [ITEM_PHY_PORT_INDEX] = {
2589 .help = "physical port index",
2590 .next = NEXT(item_phy_port, NEXT_ENTRY(COMMON_UNSIGNED),
2592 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_phy_port, index)),
2596 .help = "match traffic from/to a given DPDK port ID",
2597 .priv = PRIV_ITEM(PORT_ID,
2598 sizeof(struct rte_flow_item_port_id)),
2599 .next = NEXT(item_port_id),
2602 [ITEM_PORT_ID_ID] = {
2604 .help = "DPDK port ID",
2605 .next = NEXT(item_port_id, NEXT_ENTRY(COMMON_UNSIGNED),
2607 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port_id, id)),
2611 .help = "match traffic against value set in previously matched rule",
2612 .priv = PRIV_ITEM(MARK, sizeof(struct rte_flow_item_mark)),
2613 .next = NEXT(item_mark),
2618 .help = "Integer value to match against",
2619 .next = NEXT(item_mark, NEXT_ENTRY(COMMON_UNSIGNED),
2621 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_mark, id)),
2625 .help = "match an arbitrary byte string",
2626 .priv = PRIV_ITEM(RAW, ITEM_RAW_SIZE),
2627 .next = NEXT(item_raw),
2630 [ITEM_RAW_RELATIVE] = {
2632 .help = "look for pattern after the previous item",
2633 .next = NEXT(item_raw, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
2634 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
2637 [ITEM_RAW_SEARCH] = {
2639 .help = "search pattern from offset (see also limit)",
2640 .next = NEXT(item_raw, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
2641 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
2644 [ITEM_RAW_OFFSET] = {
2646 .help = "absolute or relative offset for pattern",
2647 .next = NEXT(item_raw, NEXT_ENTRY(COMMON_INTEGER), item_param),
2648 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, offset)),
2650 [ITEM_RAW_LIMIT] = {
2652 .help = "search area limit for start of pattern",
2653 .next = NEXT(item_raw, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2654 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, limit)),
2656 [ITEM_RAW_PATTERN] = {
2658 .help = "byte string to look for",
2659 .next = NEXT(item_raw,
2660 NEXT_ENTRY(COMMON_STRING),
2661 NEXT_ENTRY(ITEM_PARAM_IS,
2664 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern),
2665 ARGS_ENTRY(struct rte_flow_item_raw, length),
2666 ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw),
2667 ITEM_RAW_PATTERN_SIZE)),
2669 [ITEM_RAW_PATTERN_HEX] = {
2670 .name = "pattern_hex",
2671 .help = "hex string to look for",
2672 .next = NEXT(item_raw,
2673 NEXT_ENTRY(COMMON_HEX),
2674 NEXT_ENTRY(ITEM_PARAM_IS,
2677 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern),
2678 ARGS_ENTRY(struct rte_flow_item_raw, length),
2679 ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw),
2680 ITEM_RAW_PATTERN_SIZE)),
2684 .help = "match Ethernet header",
2685 .priv = PRIV_ITEM(ETH, sizeof(struct rte_flow_item_eth)),
2686 .next = NEXT(item_eth),
2691 .help = "destination MAC",
2692 .next = NEXT(item_eth, NEXT_ENTRY(COMMON_MAC_ADDR), item_param),
2693 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, dst)),
2697 .help = "source MAC",
2698 .next = NEXT(item_eth, NEXT_ENTRY(COMMON_MAC_ADDR), item_param),
2699 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, src)),
2703 .help = "EtherType",
2704 .next = NEXT(item_eth, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2705 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, type)),
2707 [ITEM_ETH_HAS_VLAN] = {
2709 .help = "packet header contains VLAN",
2710 .next = NEXT(item_eth, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2711 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_eth,
2716 .help = "match 802.1Q/ad VLAN tag",
2717 .priv = PRIV_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)),
2718 .next = NEXT(item_vlan),
2723 .help = "tag control information",
2724 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
2726 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, tci)),
2730 .help = "priority code point",
2731 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
2733 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2738 .help = "drop eligible indicator",
2739 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
2741 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2746 .help = "VLAN identifier",
2747 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
2749 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2752 [ITEM_VLAN_INNER_TYPE] = {
2753 .name = "inner_type",
2754 .help = "inner EtherType",
2755 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
2757 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan,
2760 [ITEM_VLAN_HAS_MORE_VLAN] = {
2761 .name = "has_more_vlan",
2762 .help = "packet header contains another VLAN",
2763 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
2765 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vlan,
2770 .help = "match IPv4 header",
2771 .priv = PRIV_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)),
2772 .next = NEXT(item_ipv4),
2775 [ITEM_IPV4_VER_IHL] = {
2776 .name = "version_ihl",
2777 .help = "match header length",
2778 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
2780 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ipv4,
2785 .help = "type of service",
2786 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
2788 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2789 hdr.type_of_service)),
2792 .name = "packet_id",
2793 .help = "fragment packet id",
2794 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
2796 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2799 [ITEM_IPV4_FRAGMENT_OFFSET] = {
2800 .name = "fragment_offset",
2801 .help = "fragmentation flags and fragment offset",
2802 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
2804 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2805 hdr.fragment_offset)),
2809 .help = "time to live",
2810 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
2812 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2815 [ITEM_IPV4_PROTO] = {
2817 .help = "next protocol ID",
2818 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
2820 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2821 hdr.next_proto_id)),
2825 .help = "source address",
2826 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
2828 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2833 .help = "destination address",
2834 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
2836 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2841 .help = "match IPv6 header",
2842 .priv = PRIV_ITEM(IPV6, sizeof(struct rte_flow_item_ipv6)),
2843 .next = NEXT(item_ipv6),
2848 .help = "traffic class",
2849 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
2851 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2853 "\x0f\xf0\x00\x00")),
2855 [ITEM_IPV6_FLOW] = {
2857 .help = "flow label",
2858 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
2860 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2862 "\x00\x0f\xff\xff")),
2864 [ITEM_IPV6_PROTO] = {
2866 .help = "protocol (next header)",
2867 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
2869 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2874 .help = "hop limit",
2875 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
2877 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2882 .help = "source address",
2883 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_IPV6_ADDR),
2885 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2890 .help = "destination address",
2891 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_IPV6_ADDR),
2893 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2896 [ITEM_IPV6_HAS_FRAG_EXT] = {
2897 .name = "has_frag_ext",
2898 .help = "fragment packet attribute",
2899 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
2901 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_ipv6,
2906 .help = "match ICMP header",
2907 .priv = PRIV_ITEM(ICMP, sizeof(struct rte_flow_item_icmp)),
2908 .next = NEXT(item_icmp),
2911 [ITEM_ICMP_TYPE] = {
2913 .help = "ICMP packet type",
2914 .next = NEXT(item_icmp, NEXT_ENTRY(COMMON_UNSIGNED),
2916 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2919 [ITEM_ICMP_CODE] = {
2921 .help = "ICMP packet code",
2922 .next = NEXT(item_icmp, NEXT_ENTRY(COMMON_UNSIGNED),
2924 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2927 [ITEM_ICMP_IDENT] = {
2929 .help = "ICMP packet identifier",
2930 .next = NEXT(item_icmp, NEXT_ENTRY(COMMON_UNSIGNED),
2932 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2937 .help = "ICMP packet sequence number",
2938 .next = NEXT(item_icmp, NEXT_ENTRY(COMMON_UNSIGNED),
2940 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2945 .help = "match UDP header",
2946 .priv = PRIV_ITEM(UDP, sizeof(struct rte_flow_item_udp)),
2947 .next = NEXT(item_udp),
2952 .help = "UDP source port",
2953 .next = NEXT(item_udp, NEXT_ENTRY(COMMON_UNSIGNED),
2955 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2960 .help = "UDP destination port",
2961 .next = NEXT(item_udp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2962 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2967 .help = "match TCP header",
2968 .priv = PRIV_ITEM(TCP, sizeof(struct rte_flow_item_tcp)),
2969 .next = NEXT(item_tcp),
2974 .help = "TCP source port",
2975 .next = NEXT(item_tcp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2976 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2981 .help = "TCP destination port",
2982 .next = NEXT(item_tcp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2983 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2986 [ITEM_TCP_FLAGS] = {
2988 .help = "TCP flags",
2989 .next = NEXT(item_tcp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2990 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2995 .help = "match SCTP header",
2996 .priv = PRIV_ITEM(SCTP, sizeof(struct rte_flow_item_sctp)),
2997 .next = NEXT(item_sctp),
3002 .help = "SCTP source port",
3003 .next = NEXT(item_sctp, NEXT_ENTRY(COMMON_UNSIGNED),
3005 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
3010 .help = "SCTP destination port",
3011 .next = NEXT(item_sctp, NEXT_ENTRY(COMMON_UNSIGNED),
3013 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
3018 .help = "validation tag",
3019 .next = NEXT(item_sctp, NEXT_ENTRY(COMMON_UNSIGNED),
3021 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
3024 [ITEM_SCTP_CKSUM] = {
3027 .next = NEXT(item_sctp, NEXT_ENTRY(COMMON_UNSIGNED),
3029 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
3034 .help = "match VXLAN header",
3035 .priv = PRIV_ITEM(VXLAN, sizeof(struct rte_flow_item_vxlan)),
3036 .next = NEXT(item_vxlan),
3039 [ITEM_VXLAN_VNI] = {
3041 .help = "VXLAN identifier",
3042 .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
3044 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan, vni)),
3046 [ITEM_VXLAN_LAST_RSVD] = {
3047 .name = "last_rsvd",
3048 .help = "VXLAN last reserved bits",
3049 .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
3051 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan,
3056 .help = "match E-Tag header",
3057 .priv = PRIV_ITEM(E_TAG, sizeof(struct rte_flow_item_e_tag)),
3058 .next = NEXT(item_e_tag),
3061 [ITEM_E_TAG_GRP_ECID_B] = {
3062 .name = "grp_ecid_b",
3063 .help = "GRP and E-CID base",
3064 .next = NEXT(item_e_tag, NEXT_ENTRY(COMMON_UNSIGNED),
3066 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_e_tag,
3072 .help = "match NVGRE header",
3073 .priv = PRIV_ITEM(NVGRE, sizeof(struct rte_flow_item_nvgre)),
3074 .next = NEXT(item_nvgre),
3077 [ITEM_NVGRE_TNI] = {
3079 .help = "virtual subnet ID",
3080 .next = NEXT(item_nvgre, NEXT_ENTRY(COMMON_UNSIGNED),
3082 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_nvgre, tni)),
3086 .help = "match MPLS header",
3087 .priv = PRIV_ITEM(MPLS, sizeof(struct rte_flow_item_mpls)),
3088 .next = NEXT(item_mpls),
3091 [ITEM_MPLS_LABEL] = {
3093 .help = "MPLS label",
3094 .next = NEXT(item_mpls, NEXT_ENTRY(COMMON_UNSIGNED),
3096 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
3102 .help = "MPLS Traffic Class",
3103 .next = NEXT(item_mpls, NEXT_ENTRY(COMMON_UNSIGNED),
3105 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
3111 .help = "MPLS Bottom-of-Stack",
3112 .next = NEXT(item_mpls, NEXT_ENTRY(COMMON_UNSIGNED),
3114 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
3120 .help = "match GRE header",
3121 .priv = PRIV_ITEM(GRE, sizeof(struct rte_flow_item_gre)),
3122 .next = NEXT(item_gre),
3125 [ITEM_GRE_PROTO] = {
3127 .help = "GRE protocol type",
3128 .next = NEXT(item_gre, NEXT_ENTRY(COMMON_UNSIGNED),
3130 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
3133 [ITEM_GRE_C_RSVD0_VER] = {
3134 .name = "c_rsvd0_ver",
3136 "checksum (1b), undefined (1b), key bit (1b),"
3137 " sequence number (1b), reserved 0 (9b),"
3139 .next = NEXT(item_gre, NEXT_ENTRY(COMMON_UNSIGNED),
3141 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
3144 [ITEM_GRE_C_BIT] = {
3146 .help = "checksum bit (C)",
3147 .next = NEXT(item_gre, NEXT_ENTRY(COMMON_BOOLEAN),
3149 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
3151 "\x80\x00\x00\x00")),
3153 [ITEM_GRE_S_BIT] = {
3155 .help = "sequence number bit (S)",
3156 .next = NEXT(item_gre, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
3157 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
3159 "\x10\x00\x00\x00")),
3161 [ITEM_GRE_K_BIT] = {
3163 .help = "key bit (K)",
3164 .next = NEXT(item_gre, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
3165 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
3167 "\x20\x00\x00\x00")),
3171 .help = "fuzzy pattern match, expect faster than default",
3172 .priv = PRIV_ITEM(FUZZY,
3173 sizeof(struct rte_flow_item_fuzzy)),
3174 .next = NEXT(item_fuzzy),
3177 [ITEM_FUZZY_THRESH] = {
3179 .help = "match accuracy threshold",
3180 .next = NEXT(item_fuzzy, NEXT_ENTRY(COMMON_UNSIGNED),
3182 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_fuzzy,
3187 .help = "match GTP header",
3188 .priv = PRIV_ITEM(GTP, sizeof(struct rte_flow_item_gtp)),
3189 .next = NEXT(item_gtp),
3192 [ITEM_GTP_FLAGS] = {
3193 .name = "v_pt_rsv_flags",
3194 .help = "GTP flags",
3195 .next = NEXT(item_gtp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3196 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp,
3199 [ITEM_GTP_MSG_TYPE] = {
3201 .help = "GTP message type",
3202 .next = NEXT(item_gtp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3203 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp, msg_type)),
3207 .help = "tunnel endpoint identifier",
3208 .next = NEXT(item_gtp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3209 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp, teid)),
3213 .help = "match GTP header",
3214 .priv = PRIV_ITEM(GTPC, sizeof(struct rte_flow_item_gtp)),
3215 .next = NEXT(item_gtp),
3220 .help = "match GTP header",
3221 .priv = PRIV_ITEM(GTPU, sizeof(struct rte_flow_item_gtp)),
3222 .next = NEXT(item_gtp),
3227 .help = "match GENEVE header",
3228 .priv = PRIV_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)),
3229 .next = NEXT(item_geneve),
3232 [ITEM_GENEVE_VNI] = {
3234 .help = "virtual network identifier",
3235 .next = NEXT(item_geneve, NEXT_ENTRY(COMMON_UNSIGNED),
3237 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve, vni)),
3239 [ITEM_GENEVE_PROTO] = {
3241 .help = "GENEVE protocol type",
3242 .next = NEXT(item_geneve, NEXT_ENTRY(COMMON_UNSIGNED),
3244 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve,
3247 [ITEM_GENEVE_OPTLEN] = {
3249 .help = "GENEVE options length in dwords",
3250 .next = NEXT(item_geneve, NEXT_ENTRY(COMMON_UNSIGNED),
3252 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_geneve,
3253 ver_opt_len_o_c_rsvd0,
3256 [ITEM_VXLAN_GPE] = {
3257 .name = "vxlan-gpe",
3258 .help = "match VXLAN-GPE header",
3259 .priv = PRIV_ITEM(VXLAN_GPE,
3260 sizeof(struct rte_flow_item_vxlan_gpe)),
3261 .next = NEXT(item_vxlan_gpe),
3264 [ITEM_VXLAN_GPE_VNI] = {
3266 .help = "VXLAN-GPE identifier",
3267 .next = NEXT(item_vxlan_gpe, NEXT_ENTRY(COMMON_UNSIGNED),
3269 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
3272 [ITEM_ARP_ETH_IPV4] = {
3273 .name = "arp_eth_ipv4",
3274 .help = "match ARP header for Ethernet/IPv4",
3275 .priv = PRIV_ITEM(ARP_ETH_IPV4,
3276 sizeof(struct rte_flow_item_arp_eth_ipv4)),
3277 .next = NEXT(item_arp_eth_ipv4),
3280 [ITEM_ARP_ETH_IPV4_SHA] = {
3282 .help = "sender hardware address",
3283 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_MAC_ADDR),
3285 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
3288 [ITEM_ARP_ETH_IPV4_SPA] = {
3290 .help = "sender IPv4 address",
3291 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
3293 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
3296 [ITEM_ARP_ETH_IPV4_THA] = {
3298 .help = "target hardware address",
3299 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_MAC_ADDR),
3301 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
3304 [ITEM_ARP_ETH_IPV4_TPA] = {
3306 .help = "target IPv4 address",
3307 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
3309 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
3314 .help = "match presence of any IPv6 extension header",
3315 .priv = PRIV_ITEM(IPV6_EXT,
3316 sizeof(struct rte_flow_item_ipv6_ext)),
3317 .next = NEXT(item_ipv6_ext),
3320 [ITEM_IPV6_EXT_NEXT_HDR] = {
3322 .help = "next header",
3323 .next = NEXT(item_ipv6_ext, NEXT_ENTRY(COMMON_UNSIGNED),
3325 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_ext,
3328 [ITEM_IPV6_FRAG_EXT] = {
3329 .name = "ipv6_frag_ext",
3330 .help = "match presence of IPv6 fragment extension header",
3331 .priv = PRIV_ITEM(IPV6_FRAG_EXT,
3332 sizeof(struct rte_flow_item_ipv6_frag_ext)),
3333 .next = NEXT(item_ipv6_frag_ext),
3336 [ITEM_IPV6_FRAG_EXT_NEXT_HDR] = {
3338 .help = "next header",
3339 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(COMMON_UNSIGNED),
3341 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ipv6_frag_ext,
3344 [ITEM_IPV6_FRAG_EXT_FRAG_DATA] = {
3345 .name = "frag_data",
3346 .help = "fragment flags and offset",
3347 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(COMMON_UNSIGNED),
3349 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_frag_ext,
3352 [ITEM_IPV6_FRAG_EXT_ID] = {
3353 .name = "packet_id",
3354 .help = "fragment packet id",
3355 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(COMMON_UNSIGNED),
3357 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_frag_ext,
3362 .help = "match any ICMPv6 header",
3363 .priv = PRIV_ITEM(ICMP6, sizeof(struct rte_flow_item_icmp6)),
3364 .next = NEXT(item_icmp6),
3367 [ITEM_ICMP6_TYPE] = {
3369 .help = "ICMPv6 type",
3370 .next = NEXT(item_icmp6, NEXT_ENTRY(COMMON_UNSIGNED),
3372 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
3375 [ITEM_ICMP6_CODE] = {
3377 .help = "ICMPv6 code",
3378 .next = NEXT(item_icmp6, NEXT_ENTRY(COMMON_UNSIGNED),
3380 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
3383 [ITEM_ICMP6_ND_NS] = {
3384 .name = "icmp6_nd_ns",
3385 .help = "match ICMPv6 neighbor discovery solicitation",
3386 .priv = PRIV_ITEM(ICMP6_ND_NS,
3387 sizeof(struct rte_flow_item_icmp6_nd_ns)),
3388 .next = NEXT(item_icmp6_nd_ns),
3391 [ITEM_ICMP6_ND_NS_TARGET_ADDR] = {
3392 .name = "target_addr",
3393 .help = "target address",
3394 .next = NEXT(item_icmp6_nd_ns, NEXT_ENTRY(COMMON_IPV6_ADDR),
3396 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_ns,
3399 [ITEM_ICMP6_ND_NA] = {
3400 .name = "icmp6_nd_na",
3401 .help = "match ICMPv6 neighbor discovery advertisement",
3402 .priv = PRIV_ITEM(ICMP6_ND_NA,
3403 sizeof(struct rte_flow_item_icmp6_nd_na)),
3404 .next = NEXT(item_icmp6_nd_na),
3407 [ITEM_ICMP6_ND_NA_TARGET_ADDR] = {
3408 .name = "target_addr",
3409 .help = "target address",
3410 .next = NEXT(item_icmp6_nd_na, NEXT_ENTRY(COMMON_IPV6_ADDR),
3412 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_na,
3415 [ITEM_ICMP6_ND_OPT] = {
3416 .name = "icmp6_nd_opt",
3417 .help = "match presence of any ICMPv6 neighbor discovery"
3419 .priv = PRIV_ITEM(ICMP6_ND_OPT,
3420 sizeof(struct rte_flow_item_icmp6_nd_opt)),
3421 .next = NEXT(item_icmp6_nd_opt),
3424 [ITEM_ICMP6_ND_OPT_TYPE] = {
3426 .help = "ND option type",
3427 .next = NEXT(item_icmp6_nd_opt, NEXT_ENTRY(COMMON_UNSIGNED),
3429 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_opt,
3432 [ITEM_ICMP6_ND_OPT_SLA_ETH] = {
3433 .name = "icmp6_nd_opt_sla_eth",
3434 .help = "match ICMPv6 neighbor discovery source Ethernet"
3435 " link-layer address option",
3437 (ICMP6_ND_OPT_SLA_ETH,
3438 sizeof(struct rte_flow_item_icmp6_nd_opt_sla_eth)),
3439 .next = NEXT(item_icmp6_nd_opt_sla_eth),
3442 [ITEM_ICMP6_ND_OPT_SLA_ETH_SLA] = {
3444 .help = "source Ethernet LLA",
3445 .next = NEXT(item_icmp6_nd_opt_sla_eth,
3446 NEXT_ENTRY(COMMON_MAC_ADDR), item_param),
3447 .args = ARGS(ARGS_ENTRY_HTON
3448 (struct rte_flow_item_icmp6_nd_opt_sla_eth, sla)),
3450 [ITEM_ICMP6_ND_OPT_TLA_ETH] = {
3451 .name = "icmp6_nd_opt_tla_eth",
3452 .help = "match ICMPv6 neighbor discovery target Ethernet"
3453 " link-layer address option",
3455 (ICMP6_ND_OPT_TLA_ETH,
3456 sizeof(struct rte_flow_item_icmp6_nd_opt_tla_eth)),
3457 .next = NEXT(item_icmp6_nd_opt_tla_eth),
3460 [ITEM_ICMP6_ND_OPT_TLA_ETH_TLA] = {
3462 .help = "target Ethernet LLA",
3463 .next = NEXT(item_icmp6_nd_opt_tla_eth,
3464 NEXT_ENTRY(COMMON_MAC_ADDR), item_param),
3465 .args = ARGS(ARGS_ENTRY_HTON
3466 (struct rte_flow_item_icmp6_nd_opt_tla_eth, tla)),
3470 .help = "match metadata header",
3471 .priv = PRIV_ITEM(META, sizeof(struct rte_flow_item_meta)),
3472 .next = NEXT(item_meta),
3475 [ITEM_META_DATA] = {
3477 .help = "metadata value",
3478 .next = NEXT(item_meta, NEXT_ENTRY(COMMON_UNSIGNED),
3480 .args = ARGS(ARGS_ENTRY_MASK(struct rte_flow_item_meta,
3481 data, "\xff\xff\xff\xff")),
3485 .help = "match GRE key",
3486 .priv = PRIV_ITEM(GRE_KEY, sizeof(rte_be32_t)),
3487 .next = NEXT(item_gre_key),
3490 [ITEM_GRE_KEY_VALUE] = {
3492 .help = "key value",
3493 .next = NEXT(item_gre_key, NEXT_ENTRY(COMMON_UNSIGNED),
3495 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3499 .help = "match GTP extension header with type 0x85",
3500 .priv = PRIV_ITEM(GTP_PSC,
3501 sizeof(struct rte_flow_item_gtp_psc)),
3502 .next = NEXT(item_gtp_psc),
3505 [ITEM_GTP_PSC_QFI] = {
3507 .help = "QoS flow identifier",
3508 .next = NEXT(item_gtp_psc, NEXT_ENTRY(COMMON_UNSIGNED),
3510 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_gtp_psc,
3513 [ITEM_GTP_PSC_PDU_T] = {
3516 .next = NEXT(item_gtp_psc, NEXT_ENTRY(COMMON_UNSIGNED),
3518 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_gtp_psc,
3523 .help = "match PPPoE session header",
3524 .priv = PRIV_ITEM(PPPOES, sizeof(struct rte_flow_item_pppoe)),
3525 .next = NEXT(item_pppoes),
3530 .help = "match PPPoE discovery header",
3531 .priv = PRIV_ITEM(PPPOED, sizeof(struct rte_flow_item_pppoe)),
3532 .next = NEXT(item_pppoed),
3535 [ITEM_PPPOE_SEID] = {
3537 .help = "session identifier",
3538 .next = NEXT(item_pppoes, NEXT_ENTRY(COMMON_UNSIGNED),
3540 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pppoe,
3543 [ITEM_PPPOE_PROTO_ID] = {
3544 .name = "pppoe_proto_id",
3545 .help = "match PPPoE session protocol identifier",
3546 .priv = PRIV_ITEM(PPPOE_PROTO_ID,
3547 sizeof(struct rte_flow_item_pppoe_proto_id)),
3548 .next = NEXT(item_pppoe_proto_id, NEXT_ENTRY(COMMON_UNSIGNED),
3550 .args = ARGS(ARGS_ENTRY_HTON
3551 (struct rte_flow_item_pppoe_proto_id, proto_id)),
3556 .help = "matches higig2 header",
3557 .priv = PRIV_ITEM(HIGIG2,
3558 sizeof(struct rte_flow_item_higig2_hdr)),
3559 .next = NEXT(item_higig2),
3562 [ITEM_HIGIG2_CLASSIFICATION] = {
3563 .name = "classification",
3564 .help = "matches classification of higig2 header",
3565 .next = NEXT(item_higig2, NEXT_ENTRY(COMMON_UNSIGNED),
3567 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
3568 hdr.ppt1.classification)),
3570 [ITEM_HIGIG2_VID] = {
3572 .help = "matches vid of higig2 header",
3573 .next = NEXT(item_higig2, NEXT_ENTRY(COMMON_UNSIGNED),
3575 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
3580 .help = "match tag value",
3581 .priv = PRIV_ITEM(TAG, sizeof(struct rte_flow_item_tag)),
3582 .next = NEXT(item_tag),
3587 .help = "tag value to match",
3588 .next = NEXT(item_tag, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3589 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, data)),
3591 [ITEM_TAG_INDEX] = {
3593 .help = "index of tag array to match",
3594 .next = NEXT(item_tag, NEXT_ENTRY(COMMON_UNSIGNED),
3595 NEXT_ENTRY(ITEM_PARAM_IS)),
3596 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, index)),
3598 [ITEM_L2TPV3OIP] = {
3599 .name = "l2tpv3oip",
3600 .help = "match L2TPv3 over IP header",
3601 .priv = PRIV_ITEM(L2TPV3OIP,
3602 sizeof(struct rte_flow_item_l2tpv3oip)),
3603 .next = NEXT(item_l2tpv3oip),
3606 [ITEM_L2TPV3OIP_SESSION_ID] = {
3607 .name = "session_id",
3608 .help = "session identifier",
3609 .next = NEXT(item_l2tpv3oip, NEXT_ENTRY(COMMON_UNSIGNED),
3611 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv3oip,
3616 .help = "match ESP header",
3617 .priv = PRIV_ITEM(ESP, sizeof(struct rte_flow_item_esp)),
3618 .next = NEXT(item_esp),
3623 .help = "security policy index",
3624 .next = NEXT(item_esp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3625 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_esp,
3630 .help = "match AH header",
3631 .priv = PRIV_ITEM(AH, sizeof(struct rte_flow_item_ah)),
3632 .next = NEXT(item_ah),
3637 .help = "security parameters index",
3638 .next = NEXT(item_ah, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3639 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ah, spi)),
3643 .help = "match pfcp header",
3644 .priv = PRIV_ITEM(PFCP, sizeof(struct rte_flow_item_pfcp)),
3645 .next = NEXT(item_pfcp),
3648 [ITEM_PFCP_S_FIELD] = {
3651 .next = NEXT(item_pfcp, NEXT_ENTRY(COMMON_UNSIGNED),
3653 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp,
3656 [ITEM_PFCP_SEID] = {
3658 .help = "session endpoint identifier",
3659 .next = NEXT(item_pfcp, NEXT_ENTRY(COMMON_UNSIGNED),
3661 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp, seid)),
3665 .help = "match eCPRI header",
3666 .priv = PRIV_ITEM(ECPRI, sizeof(struct rte_flow_item_ecpri)),
3667 .next = NEXT(item_ecpri),
3670 [ITEM_ECPRI_COMMON] = {
3672 .help = "eCPRI common header",
3673 .next = NEXT(item_ecpri_common),
3675 [ITEM_ECPRI_COMMON_TYPE] = {
3677 .help = "type of common header",
3678 .next = NEXT(item_ecpri_common_type),
3679 .args = ARGS(ARG_ENTRY_HTON(struct rte_flow_item_ecpri)),
3681 [ITEM_ECPRI_COMMON_TYPE_IQ_DATA] = {
3683 .help = "Type #0: IQ Data",
3684 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
3686 .call = parse_vc_item_ecpri_type,
3688 [ITEM_ECPRI_MSG_IQ_DATA_PCID] = {
3690 .help = "Physical Channel ID",
3691 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
3692 ITEM_ECPRI_COMMON, ITEM_NEXT),
3693 NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3694 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3697 [ITEM_ECPRI_COMMON_TYPE_RTC_CTRL] = {
3699 .help = "Type #2: Real-Time Control Data",
3700 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
3702 .call = parse_vc_item_ecpri_type,
3704 [ITEM_ECPRI_MSG_RTC_CTRL_RTCID] = {
3706 .help = "Real-Time Control Data ID",
3707 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
3708 ITEM_ECPRI_COMMON, ITEM_NEXT),
3709 NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3710 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3713 [ITEM_ECPRI_COMMON_TYPE_DLY_MSR] = {
3714 .name = "delay_measure",
3715 .help = "Type #5: One-Way Delay Measurement",
3716 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
3718 .call = parse_vc_item_ecpri_type,
3720 [ITEM_ECPRI_MSG_DLY_MSR_MSRID] = {
3722 .help = "Measurement ID",
3723 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
3724 ITEM_ECPRI_COMMON, ITEM_NEXT),
3725 NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3726 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3729 [ITEM_GENEVE_OPT] = {
3730 .name = "geneve-opt",
3731 .help = "GENEVE header option",
3732 .priv = PRIV_ITEM(GENEVE_OPT,
3733 sizeof(struct rte_flow_item_geneve_opt) +
3734 ITEM_GENEVE_OPT_DATA_SIZE),
3735 .next = NEXT(item_geneve_opt),
3738 [ITEM_GENEVE_OPT_CLASS] = {
3740 .help = "GENEVE option class",
3741 .next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_UNSIGNED),
3743 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve_opt,
3746 [ITEM_GENEVE_OPT_TYPE] = {
3748 .help = "GENEVE option type",
3749 .next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_UNSIGNED),
3751 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt,
3754 [ITEM_GENEVE_OPT_LENGTH] = {
3756 .help = "GENEVE option data length (in 32b words)",
3757 .next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_UNSIGNED),
3759 .args = ARGS(ARGS_ENTRY_BOUNDED(
3760 struct rte_flow_item_geneve_opt, option_len,
3763 [ITEM_GENEVE_OPT_DATA] = {
3765 .help = "GENEVE option data pattern",
3766 .next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_HEX),
3768 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt, data),
3769 ARGS_ENTRY_ARB(0, 0),
3771 (sizeof(struct rte_flow_item_geneve_opt),
3772 ITEM_GENEVE_OPT_DATA_SIZE)),
3774 [ITEM_INTEGRITY] = {
3775 .name = "integrity",
3776 .help = "match packet integrity",
3777 .priv = PRIV_ITEM(INTEGRITY,
3778 sizeof(struct rte_flow_item_integrity)),
3779 .next = NEXT(item_integrity),
3782 [ITEM_INTEGRITY_LEVEL] = {
3784 .help = "integrity level",
3785 .next = NEXT(item_integrity_lv, NEXT_ENTRY(COMMON_UNSIGNED),
3787 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_integrity, level)),
3789 [ITEM_INTEGRITY_VALUE] = {
3791 .help = "integrity value",
3792 .next = NEXT(item_integrity_lv, NEXT_ENTRY(COMMON_UNSIGNED),
3794 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_integrity, value)),
3796 [ITEM_CONNTRACK] = {
3797 .name = "conntrack",
3798 .help = "conntrack state",
3799 .next = NEXT(NEXT_ENTRY(ITEM_NEXT), NEXT_ENTRY(COMMON_UNSIGNED),
3801 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_conntrack, flags)),
3803 [ITEM_PORT_REPRESENTOR] = {
3804 .name = "port_representor",
3805 .help = "match traffic entering the embedded switch from the given ethdev",
3806 .priv = PRIV_ITEM(PORT_REPRESENTOR,
3807 sizeof(struct rte_flow_item_ethdev)),
3808 .next = NEXT(item_port_representor),
3811 [ITEM_PORT_REPRESENTOR_PORT_ID] = {
3813 .help = "ethdev port ID",
3814 .next = NEXT(item_port_representor, NEXT_ENTRY(COMMON_UNSIGNED),
3816 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ethdev, port_id)),
3818 [ITEM_REPRESENTED_PORT] = {
3819 .name = "represented_port",
3820 .help = "match traffic entering the embedded switch from the entity represented by the given ethdev",
3821 .priv = PRIV_ITEM(REPRESENTED_PORT,
3822 sizeof(struct rte_flow_item_ethdev)),
3823 .next = NEXT(item_represented_port),
3826 [ITEM_REPRESENTED_PORT_ETHDEV_PORT_ID] = {
3827 .name = "ethdev_port_id",
3828 .help = "ethdev port ID",
3829 .next = NEXT(item_represented_port, NEXT_ENTRY(COMMON_UNSIGNED),
3831 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ethdev, port_id)),
3835 .help = "match flex header",
3836 .priv = PRIV_ITEM(FLEX, sizeof(struct rte_flow_item_flex)),
3837 .next = NEXT(item_flex),
3840 [ITEM_FLEX_ITEM_HANDLE] = {
3842 .help = "flex item handle",
3843 .next = NEXT(item_flex, NEXT_ENTRY(COMMON_FLEX_HANDLE),
3844 NEXT_ENTRY(ITEM_PARAM_IS)),
3845 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_flex, handle)),
3847 [ITEM_FLEX_PATTERN_HANDLE] = {
3849 .help = "flex pattern handle",
3850 .next = NEXT(item_flex, NEXT_ENTRY(COMMON_FLEX_HANDLE),
3851 NEXT_ENTRY(ITEM_PARAM_IS)),
3852 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_flex, pattern)),
3856 .help = "match L2TPv2 header",
3857 .priv = PRIV_ITEM(L2TPV2, sizeof(struct rte_flow_item_l2tpv2)),
3858 .next = NEXT(item_l2tpv2),
3861 [ITEM_L2TPV2_COMMON] = {
3863 .help = "L2TPv2 common header",
3864 .next = NEXT(item_l2tpv2_common),
3866 [ITEM_L2TPV2_COMMON_TYPE] = {
3868 .help = "type of common header",
3869 .next = NEXT(item_l2tpv2_common_type),
3870 .args = ARGS(ARG_ENTRY_HTON(struct rte_flow_item_l2tpv2)),
3872 [ITEM_L2TPV2_COMMON_TYPE_DATA_L] = {
3874 .help = "Type #6: data message with length option",
3875 .next = NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_DATA_L_LENGTH,
3876 ITEM_L2TPV2_MSG_DATA_L_TUNNEL_ID,
3877 ITEM_L2TPV2_MSG_DATA_L_SESSION_ID,
3879 .call = parse_vc_item_l2tpv2_type,
3881 [ITEM_L2TPV2_MSG_DATA_L_LENGTH] = {
3883 .help = "message length",
3884 .next = NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_DATA_L_LENGTH,
3885 ITEM_L2TPV2_COMMON, ITEM_NEXT),
3886 NEXT_ENTRY(COMMON_UNSIGNED),
3888 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
3891 [ITEM_L2TPV2_MSG_DATA_L_TUNNEL_ID] = {
3892 .name = "tunnel_id",
3893 .help = "tunnel identifier",
3894 .next = NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_DATA_L_TUNNEL_ID,
3895 ITEM_L2TPV2_COMMON, ITEM_NEXT),
3896 NEXT_ENTRY(COMMON_UNSIGNED),
3898 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
3899 hdr.type6.tunnel_id)),
3901 [ITEM_L2TPV2_MSG_DATA_L_SESSION_ID] = {
3902 .name = "session_id",
3903 .help = "session identifier",
3904 .next = NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_DATA_L_SESSION_ID,
3905 ITEM_L2TPV2_COMMON, ITEM_NEXT),
3906 NEXT_ENTRY(COMMON_UNSIGNED),
3908 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
3909 hdr.type6.session_id)),
3911 [ITEM_L2TPV2_COMMON_TYPE_CTRL] = {
3913 .help = "Type #3: conrtol message contains length, ns, nr options",
3914 .next = NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_CTRL_LENGTH,
3915 ITEM_L2TPV2_MSG_CTRL_TUNNEL_ID,
3916 ITEM_L2TPV2_MSG_CTRL_SESSION_ID,
3917 ITEM_L2TPV2_MSG_CTRL_NS,
3918 ITEM_L2TPV2_MSG_CTRL_NR,
3920 .call = parse_vc_item_l2tpv2_type,
3922 [ITEM_L2TPV2_MSG_CTRL_LENGTH] = {
3924 .help = "message length",
3925 .next = NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_CTRL_LENGTH,
3926 ITEM_L2TPV2_COMMON, ITEM_NEXT),
3927 NEXT_ENTRY(COMMON_UNSIGNED),
3929 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
3932 [ITEM_L2TPV2_MSG_CTRL_TUNNEL_ID] = {
3933 .name = "tunnel_id",
3934 .help = "tunnel identifier",
3935 .next = NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_CTRL_TUNNEL_ID,
3936 ITEM_L2TPV2_COMMON, ITEM_NEXT),
3937 NEXT_ENTRY(COMMON_UNSIGNED),
3939 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
3940 hdr.type3.tunnel_id)),
3942 [ITEM_L2TPV2_MSG_CTRL_SESSION_ID] = {
3943 .name = "session_id",
3944 .help = "session identifier",
3945 .next = NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_CTRL_SESSION_ID,
3946 ITEM_L2TPV2_COMMON, ITEM_NEXT),
3947 NEXT_ENTRY(COMMON_UNSIGNED),
3949 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
3950 hdr.type3.session_id)),
3952 [ITEM_L2TPV2_MSG_CTRL_NS] = {
3954 .help = "sequence number for message",
3955 .next = NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_CTRL_NS,
3956 ITEM_L2TPV2_COMMON, ITEM_NEXT),
3957 NEXT_ENTRY(COMMON_UNSIGNED),
3959 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
3962 [ITEM_L2TPV2_MSG_CTRL_NR] = {
3964 .help = "sequence number for next receive message",
3965 .next = NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_CTRL_NS,
3966 ITEM_L2TPV2_COMMON, ITEM_NEXT),
3967 NEXT_ENTRY(COMMON_UNSIGNED),
3969 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
3974 .help = "match PPP header",
3975 .priv = PRIV_ITEM(PPP, sizeof(struct rte_flow_item_ppp)),
3976 .next = NEXT(item_ppp),
3981 .help = "PPP address",
3982 .next = NEXT(item_ppp, NEXT_ENTRY(COMMON_UNSIGNED),
3984 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ppp, hdr.addr)),
3988 .help = "PPP control",
3989 .next = NEXT(item_ppp, NEXT_ENTRY(COMMON_UNSIGNED),
3991 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ppp, hdr.ctrl)),
3993 [ITEM_PPP_PROTO_ID] = {
3995 .help = "PPP protocol identifier",
3996 .next = NEXT(item_ppp, NEXT_ENTRY(COMMON_UNSIGNED),
3998 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ppp,
4001 /* Validate/create actions. */
4004 .help = "submit a list of associated actions",
4005 .next = NEXT(next_action),
4010 .help = "specify next action",
4011 .next = NEXT(next_action),
4015 .help = "end list of actions",
4016 .priv = PRIV_ACTION(END, 0),
4021 .help = "no-op action",
4022 .priv = PRIV_ACTION(VOID, 0),
4023 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4026 [ACTION_PASSTHRU] = {
4028 .help = "let subsequent rule process matched packets",
4029 .priv = PRIV_ACTION(PASSTHRU, 0),
4030 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4035 .help = "redirect traffic to a given group",
4036 .priv = PRIV_ACTION(JUMP, sizeof(struct rte_flow_action_jump)),
4037 .next = NEXT(action_jump),
4040 [ACTION_JUMP_GROUP] = {
4042 .help = "group to redirect traffic to",
4043 .next = NEXT(action_jump, NEXT_ENTRY(COMMON_UNSIGNED)),
4044 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump, group)),
4045 .call = parse_vc_conf,
4049 .help = "attach 32 bit value to packets",
4050 .priv = PRIV_ACTION(MARK, sizeof(struct rte_flow_action_mark)),
4051 .next = NEXT(action_mark),
4054 [ACTION_MARK_ID] = {
4056 .help = "32 bit value to return with packets",
4057 .next = NEXT(action_mark, NEXT_ENTRY(COMMON_UNSIGNED)),
4058 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_mark, id)),
4059 .call = parse_vc_conf,
4063 .help = "flag packets",
4064 .priv = PRIV_ACTION(FLAG, 0),
4065 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4070 .help = "assign packets to a given queue index",
4071 .priv = PRIV_ACTION(QUEUE,
4072 sizeof(struct rte_flow_action_queue)),
4073 .next = NEXT(action_queue),
4076 [ACTION_QUEUE_INDEX] = {
4078 .help = "queue index to use",
4079 .next = NEXT(action_queue, NEXT_ENTRY(COMMON_UNSIGNED)),
4080 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_queue, index)),
4081 .call = parse_vc_conf,
4085 .help = "drop packets (note: passthru has priority)",
4086 .priv = PRIV_ACTION(DROP, 0),
4087 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4092 .help = "enable counters for this rule",
4093 .priv = PRIV_ACTION(COUNT,
4094 sizeof(struct rte_flow_action_count)),
4095 .next = NEXT(action_count),
4098 [ACTION_COUNT_ID] = {
4099 .name = "identifier",
4100 .help = "counter identifier to use",
4101 .next = NEXT(action_count, NEXT_ENTRY(COMMON_UNSIGNED)),
4102 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_count, id)),
4103 .call = parse_vc_conf,
4107 .help = "spread packets among several queues",
4108 .priv = PRIV_ACTION(RSS, sizeof(struct action_rss_data)),
4109 .next = NEXT(action_rss),
4110 .call = parse_vc_action_rss,
4112 [ACTION_RSS_FUNC] = {
4114 .help = "RSS hash function to apply",
4115 .next = NEXT(action_rss,
4116 NEXT_ENTRY(ACTION_RSS_FUNC_DEFAULT,
4117 ACTION_RSS_FUNC_TOEPLITZ,
4118 ACTION_RSS_FUNC_SIMPLE_XOR,
4119 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ)),
4121 [ACTION_RSS_FUNC_DEFAULT] = {
4123 .help = "default hash function",
4124 .call = parse_vc_action_rss_func,
4126 [ACTION_RSS_FUNC_TOEPLITZ] = {
4128 .help = "Toeplitz hash function",
4129 .call = parse_vc_action_rss_func,
4131 [ACTION_RSS_FUNC_SIMPLE_XOR] = {
4132 .name = "simple_xor",
4133 .help = "simple XOR hash function",
4134 .call = parse_vc_action_rss_func,
4136 [ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ] = {
4137 .name = "symmetric_toeplitz",
4138 .help = "Symmetric Toeplitz hash function",
4139 .call = parse_vc_action_rss_func,
4141 [ACTION_RSS_LEVEL] = {
4143 .help = "encapsulation level for \"types\"",
4144 .next = NEXT(action_rss, NEXT_ENTRY(COMMON_UNSIGNED)),
4145 .args = ARGS(ARGS_ENTRY_ARB
4146 (offsetof(struct action_rss_data, conf) +
4147 offsetof(struct rte_flow_action_rss, level),
4148 sizeof(((struct rte_flow_action_rss *)0)->
4151 [ACTION_RSS_TYPES] = {
4153 .help = "specific RSS hash types",
4154 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)),
4156 [ACTION_RSS_TYPE] = {
4158 .help = "RSS hash type",
4159 .call = parse_vc_action_rss_type,
4160 .comp = comp_vc_action_rss_type,
4162 [ACTION_RSS_KEY] = {
4164 .help = "RSS hash key",
4165 .next = NEXT(action_rss, NEXT_ENTRY(COMMON_HEX)),
4166 .args = ARGS(ARGS_ENTRY_ARB
4167 (offsetof(struct action_rss_data, conf) +
4168 offsetof(struct rte_flow_action_rss, key),
4169 sizeof(((struct rte_flow_action_rss *)0)->key)),
4171 (offsetof(struct action_rss_data, conf) +
4172 offsetof(struct rte_flow_action_rss, key_len),
4173 sizeof(((struct rte_flow_action_rss *)0)->
4175 ARGS_ENTRY(struct action_rss_data, key)),
4177 [ACTION_RSS_KEY_LEN] = {
4179 .help = "RSS hash key length in bytes",
4180 .next = NEXT(action_rss, NEXT_ENTRY(COMMON_UNSIGNED)),
4181 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4182 (offsetof(struct action_rss_data, conf) +
4183 offsetof(struct rte_flow_action_rss, key_len),
4184 sizeof(((struct rte_flow_action_rss *)0)->
4187 RSS_HASH_KEY_LENGTH)),
4189 [ACTION_RSS_QUEUES] = {
4191 .help = "queue indices to use",
4192 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_QUEUE)),
4193 .call = parse_vc_conf,
4195 [ACTION_RSS_QUEUE] = {
4197 .help = "queue index",
4198 .call = parse_vc_action_rss_queue,
4199 .comp = comp_vc_action_rss_queue,
4203 .help = "direct traffic to physical function",
4204 .priv = PRIV_ACTION(PF, 0),
4205 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4210 .help = "direct traffic to a virtual function ID",
4211 .priv = PRIV_ACTION(VF, sizeof(struct rte_flow_action_vf)),
4212 .next = NEXT(action_vf),
4215 [ACTION_VF_ORIGINAL] = {
4217 .help = "use original VF ID if possible",
4218 .next = NEXT(action_vf, NEXT_ENTRY(COMMON_BOOLEAN)),
4219 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_vf,
4221 .call = parse_vc_conf,
4226 .next = NEXT(action_vf, NEXT_ENTRY(COMMON_UNSIGNED)),
4227 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)),
4228 .call = parse_vc_conf,
4230 [ACTION_PHY_PORT] = {
4232 .help = "direct packets to physical port index",
4233 .priv = PRIV_ACTION(PHY_PORT,
4234 sizeof(struct rte_flow_action_phy_port)),
4235 .next = NEXT(action_phy_port),
4238 [ACTION_PHY_PORT_ORIGINAL] = {
4240 .help = "use original port index if possible",
4241 .next = NEXT(action_phy_port, NEXT_ENTRY(COMMON_BOOLEAN)),
4242 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_phy_port,
4244 .call = parse_vc_conf,
4246 [ACTION_PHY_PORT_INDEX] = {
4248 .help = "physical port index",
4249 .next = NEXT(action_phy_port, NEXT_ENTRY(COMMON_UNSIGNED)),
4250 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_phy_port,
4252 .call = parse_vc_conf,
4254 [ACTION_PORT_ID] = {
4256 .help = "direct matching traffic to a given DPDK port ID",
4257 .priv = PRIV_ACTION(PORT_ID,
4258 sizeof(struct rte_flow_action_port_id)),
4259 .next = NEXT(action_port_id),
4262 [ACTION_PORT_ID_ORIGINAL] = {
4264 .help = "use original DPDK port ID if possible",
4265 .next = NEXT(action_port_id, NEXT_ENTRY(COMMON_BOOLEAN)),
4266 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_port_id,
4268 .call = parse_vc_conf,
4270 [ACTION_PORT_ID_ID] = {
4272 .help = "DPDK port ID",
4273 .next = NEXT(action_port_id, NEXT_ENTRY(COMMON_UNSIGNED)),
4274 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_port_id, id)),
4275 .call = parse_vc_conf,
4279 .help = "meter the directed packets at given id",
4280 .priv = PRIV_ACTION(METER,
4281 sizeof(struct rte_flow_action_meter)),
4282 .next = NEXT(action_meter),
4285 [ACTION_METER_COLOR] = {
4287 .help = "meter color for the packets",
4288 .priv = PRIV_ACTION(METER_COLOR,
4289 sizeof(struct rte_flow_action_meter_color)),
4290 .next = NEXT(action_meter_color),
4293 [ACTION_METER_COLOR_TYPE] = {
4295 .help = "specific meter color",
4296 .next = NEXT(NEXT_ENTRY(ACTION_NEXT),
4297 NEXT_ENTRY(ACTION_METER_COLOR_GREEN,
4298 ACTION_METER_COLOR_YELLOW,
4299 ACTION_METER_COLOR_RED)),
4301 [ACTION_METER_COLOR_GREEN] = {
4303 .help = "meter color green",
4304 .call = parse_vc_action_meter_color_type,
4306 [ACTION_METER_COLOR_YELLOW] = {
4308 .help = "meter color yellow",
4309 .call = parse_vc_action_meter_color_type,
4311 [ACTION_METER_COLOR_RED] = {
4313 .help = "meter color red",
4314 .call = parse_vc_action_meter_color_type,
4316 [ACTION_METER_ID] = {
4318 .help = "meter id to use",
4319 .next = NEXT(action_meter, NEXT_ENTRY(COMMON_UNSIGNED)),
4320 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter, mtr_id)),
4321 .call = parse_vc_conf,
4323 [ACTION_OF_SET_MPLS_TTL] = {
4324 .name = "of_set_mpls_ttl",
4325 .help = "OpenFlow's OFPAT_SET_MPLS_TTL",
4328 sizeof(struct rte_flow_action_of_set_mpls_ttl)),
4329 .next = NEXT(action_of_set_mpls_ttl),
4332 [ACTION_OF_SET_MPLS_TTL_MPLS_TTL] = {
4335 .next = NEXT(action_of_set_mpls_ttl,
4336 NEXT_ENTRY(COMMON_UNSIGNED)),
4337 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_mpls_ttl,
4339 .call = parse_vc_conf,
4341 [ACTION_OF_DEC_MPLS_TTL] = {
4342 .name = "of_dec_mpls_ttl",
4343 .help = "OpenFlow's OFPAT_DEC_MPLS_TTL",
4344 .priv = PRIV_ACTION(OF_DEC_MPLS_TTL, 0),
4345 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4348 [ACTION_OF_SET_NW_TTL] = {
4349 .name = "of_set_nw_ttl",
4350 .help = "OpenFlow's OFPAT_SET_NW_TTL",
4353 sizeof(struct rte_flow_action_of_set_nw_ttl)),
4354 .next = NEXT(action_of_set_nw_ttl),
4357 [ACTION_OF_SET_NW_TTL_NW_TTL] = {
4360 .next = NEXT(action_of_set_nw_ttl, NEXT_ENTRY(COMMON_UNSIGNED)),
4361 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_nw_ttl,
4363 .call = parse_vc_conf,
4365 [ACTION_OF_DEC_NW_TTL] = {
4366 .name = "of_dec_nw_ttl",
4367 .help = "OpenFlow's OFPAT_DEC_NW_TTL",
4368 .priv = PRIV_ACTION(OF_DEC_NW_TTL, 0),
4369 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4372 [ACTION_OF_COPY_TTL_OUT] = {
4373 .name = "of_copy_ttl_out",
4374 .help = "OpenFlow's OFPAT_COPY_TTL_OUT",
4375 .priv = PRIV_ACTION(OF_COPY_TTL_OUT, 0),
4376 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4379 [ACTION_OF_COPY_TTL_IN] = {
4380 .name = "of_copy_ttl_in",
4381 .help = "OpenFlow's OFPAT_COPY_TTL_IN",
4382 .priv = PRIV_ACTION(OF_COPY_TTL_IN, 0),
4383 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4386 [ACTION_OF_POP_VLAN] = {
4387 .name = "of_pop_vlan",
4388 .help = "OpenFlow's OFPAT_POP_VLAN",
4389 .priv = PRIV_ACTION(OF_POP_VLAN, 0),
4390 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4393 [ACTION_OF_PUSH_VLAN] = {
4394 .name = "of_push_vlan",
4395 .help = "OpenFlow's OFPAT_PUSH_VLAN",
4398 sizeof(struct rte_flow_action_of_push_vlan)),
4399 .next = NEXT(action_of_push_vlan),
4402 [ACTION_OF_PUSH_VLAN_ETHERTYPE] = {
4403 .name = "ethertype",
4404 .help = "EtherType",
4405 .next = NEXT(action_of_push_vlan, NEXT_ENTRY(COMMON_UNSIGNED)),
4406 .args = ARGS(ARGS_ENTRY_HTON
4407 (struct rte_flow_action_of_push_vlan,
4409 .call = parse_vc_conf,
4411 [ACTION_OF_SET_VLAN_VID] = {
4412 .name = "of_set_vlan_vid",
4413 .help = "OpenFlow's OFPAT_SET_VLAN_VID",
4416 sizeof(struct rte_flow_action_of_set_vlan_vid)),
4417 .next = NEXT(action_of_set_vlan_vid),
4420 [ACTION_OF_SET_VLAN_VID_VLAN_VID] = {
4423 .next = NEXT(action_of_set_vlan_vid,
4424 NEXT_ENTRY(COMMON_UNSIGNED)),
4425 .args = ARGS(ARGS_ENTRY_HTON
4426 (struct rte_flow_action_of_set_vlan_vid,
4428 .call = parse_vc_conf,
4430 [ACTION_OF_SET_VLAN_PCP] = {
4431 .name = "of_set_vlan_pcp",
4432 .help = "OpenFlow's OFPAT_SET_VLAN_PCP",
4435 sizeof(struct rte_flow_action_of_set_vlan_pcp)),
4436 .next = NEXT(action_of_set_vlan_pcp),
4439 [ACTION_OF_SET_VLAN_PCP_VLAN_PCP] = {
4441 .help = "VLAN priority",
4442 .next = NEXT(action_of_set_vlan_pcp,
4443 NEXT_ENTRY(COMMON_UNSIGNED)),
4444 .args = ARGS(ARGS_ENTRY_HTON
4445 (struct rte_flow_action_of_set_vlan_pcp,
4447 .call = parse_vc_conf,
4449 [ACTION_OF_POP_MPLS] = {
4450 .name = "of_pop_mpls",
4451 .help = "OpenFlow's OFPAT_POP_MPLS",
4452 .priv = PRIV_ACTION(OF_POP_MPLS,
4453 sizeof(struct rte_flow_action_of_pop_mpls)),
4454 .next = NEXT(action_of_pop_mpls),
4457 [ACTION_OF_POP_MPLS_ETHERTYPE] = {
4458 .name = "ethertype",
4459 .help = "EtherType",
4460 .next = NEXT(action_of_pop_mpls, NEXT_ENTRY(COMMON_UNSIGNED)),
4461 .args = ARGS(ARGS_ENTRY_HTON
4462 (struct rte_flow_action_of_pop_mpls,
4464 .call = parse_vc_conf,
4466 [ACTION_OF_PUSH_MPLS] = {
4467 .name = "of_push_mpls",
4468 .help = "OpenFlow's OFPAT_PUSH_MPLS",
4471 sizeof(struct rte_flow_action_of_push_mpls)),
4472 .next = NEXT(action_of_push_mpls),
4475 [ACTION_OF_PUSH_MPLS_ETHERTYPE] = {
4476 .name = "ethertype",
4477 .help = "EtherType",
4478 .next = NEXT(action_of_push_mpls, NEXT_ENTRY(COMMON_UNSIGNED)),
4479 .args = ARGS(ARGS_ENTRY_HTON
4480 (struct rte_flow_action_of_push_mpls,
4482 .call = parse_vc_conf,
4484 [ACTION_VXLAN_ENCAP] = {
4485 .name = "vxlan_encap",
4486 .help = "VXLAN encapsulation, uses configuration set by \"set"
4488 .priv = PRIV_ACTION(VXLAN_ENCAP,
4489 sizeof(struct action_vxlan_encap_data)),
4490 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4491 .call = parse_vc_action_vxlan_encap,
4493 [ACTION_VXLAN_DECAP] = {
4494 .name = "vxlan_decap",
4495 .help = "Performs a decapsulation action by stripping all"
4496 " headers of the VXLAN tunnel network overlay from the"
4498 .priv = PRIV_ACTION(VXLAN_DECAP, 0),
4499 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4502 [ACTION_NVGRE_ENCAP] = {
4503 .name = "nvgre_encap",
4504 .help = "NVGRE encapsulation, uses configuration set by \"set"
4506 .priv = PRIV_ACTION(NVGRE_ENCAP,
4507 sizeof(struct action_nvgre_encap_data)),
4508 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4509 .call = parse_vc_action_nvgre_encap,
4511 [ACTION_NVGRE_DECAP] = {
4512 .name = "nvgre_decap",
4513 .help = "Performs a decapsulation action by stripping all"
4514 " headers of the NVGRE tunnel network overlay from the"
4516 .priv = PRIV_ACTION(NVGRE_DECAP, 0),
4517 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4520 [ACTION_L2_ENCAP] = {
4522 .help = "l2 encap, uses configuration set by"
4523 " \"set l2_encap\"",
4524 .priv = PRIV_ACTION(RAW_ENCAP,
4525 sizeof(struct action_raw_encap_data)),
4526 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4527 .call = parse_vc_action_l2_encap,
4529 [ACTION_L2_DECAP] = {
4531 .help = "l2 decap, uses configuration set by"
4532 " \"set l2_decap\"",
4533 .priv = PRIV_ACTION(RAW_DECAP,
4534 sizeof(struct action_raw_decap_data)),
4535 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4536 .call = parse_vc_action_l2_decap,
4538 [ACTION_MPLSOGRE_ENCAP] = {
4539 .name = "mplsogre_encap",
4540 .help = "mplsogre encapsulation, uses configuration set by"
4541 " \"set mplsogre_encap\"",
4542 .priv = PRIV_ACTION(RAW_ENCAP,
4543 sizeof(struct action_raw_encap_data)),
4544 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4545 .call = parse_vc_action_mplsogre_encap,
4547 [ACTION_MPLSOGRE_DECAP] = {
4548 .name = "mplsogre_decap",
4549 .help = "mplsogre decapsulation, uses configuration set by"
4550 " \"set mplsogre_decap\"",
4551 .priv = PRIV_ACTION(RAW_DECAP,
4552 sizeof(struct action_raw_decap_data)),
4553 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4554 .call = parse_vc_action_mplsogre_decap,
4556 [ACTION_MPLSOUDP_ENCAP] = {
4557 .name = "mplsoudp_encap",
4558 .help = "mplsoudp encapsulation, uses configuration set by"
4559 " \"set mplsoudp_encap\"",
4560 .priv = PRIV_ACTION(RAW_ENCAP,
4561 sizeof(struct action_raw_encap_data)),
4562 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4563 .call = parse_vc_action_mplsoudp_encap,
4565 [ACTION_MPLSOUDP_DECAP] = {
4566 .name = "mplsoudp_decap",
4567 .help = "mplsoudp decapsulation, uses configuration set by"
4568 " \"set mplsoudp_decap\"",
4569 .priv = PRIV_ACTION(RAW_DECAP,
4570 sizeof(struct action_raw_decap_data)),
4571 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4572 .call = parse_vc_action_mplsoudp_decap,
4574 [ACTION_SET_IPV4_SRC] = {
4575 .name = "set_ipv4_src",
4576 .help = "Set a new IPv4 source address in the outermost"
4578 .priv = PRIV_ACTION(SET_IPV4_SRC,
4579 sizeof(struct rte_flow_action_set_ipv4)),
4580 .next = NEXT(action_set_ipv4_src),
4583 [ACTION_SET_IPV4_SRC_IPV4_SRC] = {
4584 .name = "ipv4_addr",
4585 .help = "new IPv4 source address to set",
4586 .next = NEXT(action_set_ipv4_src, NEXT_ENTRY(COMMON_IPV4_ADDR)),
4587 .args = ARGS(ARGS_ENTRY_HTON
4588 (struct rte_flow_action_set_ipv4, ipv4_addr)),
4589 .call = parse_vc_conf,
4591 [ACTION_SET_IPV4_DST] = {
4592 .name = "set_ipv4_dst",
4593 .help = "Set a new IPv4 destination address in the outermost"
4595 .priv = PRIV_ACTION(SET_IPV4_DST,
4596 sizeof(struct rte_flow_action_set_ipv4)),
4597 .next = NEXT(action_set_ipv4_dst),
4600 [ACTION_SET_IPV4_DST_IPV4_DST] = {
4601 .name = "ipv4_addr",
4602 .help = "new IPv4 destination address to set",
4603 .next = NEXT(action_set_ipv4_dst, NEXT_ENTRY(COMMON_IPV4_ADDR)),
4604 .args = ARGS(ARGS_ENTRY_HTON
4605 (struct rte_flow_action_set_ipv4, ipv4_addr)),
4606 .call = parse_vc_conf,
4608 [ACTION_SET_IPV6_SRC] = {
4609 .name = "set_ipv6_src",
4610 .help = "Set a new IPv6 source address in the outermost"
4612 .priv = PRIV_ACTION(SET_IPV6_SRC,
4613 sizeof(struct rte_flow_action_set_ipv6)),
4614 .next = NEXT(action_set_ipv6_src),
4617 [ACTION_SET_IPV6_SRC_IPV6_SRC] = {
4618 .name = "ipv6_addr",
4619 .help = "new IPv6 source address to set",
4620 .next = NEXT(action_set_ipv6_src, NEXT_ENTRY(COMMON_IPV6_ADDR)),
4621 .args = ARGS(ARGS_ENTRY_HTON
4622 (struct rte_flow_action_set_ipv6, ipv6_addr)),
4623 .call = parse_vc_conf,
4625 [ACTION_SET_IPV6_DST] = {
4626 .name = "set_ipv6_dst",
4627 .help = "Set a new IPv6 destination address in the outermost"
4629 .priv = PRIV_ACTION(SET_IPV6_DST,
4630 sizeof(struct rte_flow_action_set_ipv6)),
4631 .next = NEXT(action_set_ipv6_dst),
4634 [ACTION_SET_IPV6_DST_IPV6_DST] = {
4635 .name = "ipv6_addr",
4636 .help = "new IPv6 destination address to set",
4637 .next = NEXT(action_set_ipv6_dst, NEXT_ENTRY(COMMON_IPV6_ADDR)),
4638 .args = ARGS(ARGS_ENTRY_HTON
4639 (struct rte_flow_action_set_ipv6, ipv6_addr)),
4640 .call = parse_vc_conf,
4642 [ACTION_SET_TP_SRC] = {
4643 .name = "set_tp_src",
4644 .help = "set a new source port number in the outermost"
4646 .priv = PRIV_ACTION(SET_TP_SRC,
4647 sizeof(struct rte_flow_action_set_tp)),
4648 .next = NEXT(action_set_tp_src),
4651 [ACTION_SET_TP_SRC_TP_SRC] = {
4653 .help = "new source port number to set",
4654 .next = NEXT(action_set_tp_src, NEXT_ENTRY(COMMON_UNSIGNED)),
4655 .args = ARGS(ARGS_ENTRY_HTON
4656 (struct rte_flow_action_set_tp, port)),
4657 .call = parse_vc_conf,
4659 [ACTION_SET_TP_DST] = {
4660 .name = "set_tp_dst",
4661 .help = "set a new destination port number in the outermost"
4663 .priv = PRIV_ACTION(SET_TP_DST,
4664 sizeof(struct rte_flow_action_set_tp)),
4665 .next = NEXT(action_set_tp_dst),
4668 [ACTION_SET_TP_DST_TP_DST] = {
4670 .help = "new destination port number to set",
4671 .next = NEXT(action_set_tp_dst, NEXT_ENTRY(COMMON_UNSIGNED)),
4672 .args = ARGS(ARGS_ENTRY_HTON
4673 (struct rte_flow_action_set_tp, port)),
4674 .call = parse_vc_conf,
4676 [ACTION_MAC_SWAP] = {
4678 .help = "Swap the source and destination MAC addresses"
4679 " in the outermost Ethernet header",
4680 .priv = PRIV_ACTION(MAC_SWAP, 0),
4681 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4684 [ACTION_DEC_TTL] = {
4686 .help = "decrease network TTL if available",
4687 .priv = PRIV_ACTION(DEC_TTL, 0),
4688 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4691 [ACTION_SET_TTL] = {
4693 .help = "set ttl value",
4694 .priv = PRIV_ACTION(SET_TTL,
4695 sizeof(struct rte_flow_action_set_ttl)),
4696 .next = NEXT(action_set_ttl),
4699 [ACTION_SET_TTL_TTL] = {
4700 .name = "ttl_value",
4701 .help = "new ttl value to set",
4702 .next = NEXT(action_set_ttl, NEXT_ENTRY(COMMON_UNSIGNED)),
4703 .args = ARGS(ARGS_ENTRY_HTON
4704 (struct rte_flow_action_set_ttl, ttl_value)),
4705 .call = parse_vc_conf,
4707 [ACTION_SET_MAC_SRC] = {
4708 .name = "set_mac_src",
4709 .help = "set source mac address",
4710 .priv = PRIV_ACTION(SET_MAC_SRC,
4711 sizeof(struct rte_flow_action_set_mac)),
4712 .next = NEXT(action_set_mac_src),
4715 [ACTION_SET_MAC_SRC_MAC_SRC] = {
4717 .help = "new source mac address",
4718 .next = NEXT(action_set_mac_src, NEXT_ENTRY(COMMON_MAC_ADDR)),
4719 .args = ARGS(ARGS_ENTRY_HTON
4720 (struct rte_flow_action_set_mac, mac_addr)),
4721 .call = parse_vc_conf,
4723 [ACTION_SET_MAC_DST] = {
4724 .name = "set_mac_dst",
4725 .help = "set destination mac address",
4726 .priv = PRIV_ACTION(SET_MAC_DST,
4727 sizeof(struct rte_flow_action_set_mac)),
4728 .next = NEXT(action_set_mac_dst),
4731 [ACTION_SET_MAC_DST_MAC_DST] = {
4733 .help = "new destination mac address to set",
4734 .next = NEXT(action_set_mac_dst, NEXT_ENTRY(COMMON_MAC_ADDR)),
4735 .args = ARGS(ARGS_ENTRY_HTON
4736 (struct rte_flow_action_set_mac, mac_addr)),
4737 .call = parse_vc_conf,
4739 [ACTION_INC_TCP_SEQ] = {
4740 .name = "inc_tcp_seq",
4741 .help = "increase TCP sequence number",
4742 .priv = PRIV_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
4743 .next = NEXT(action_inc_tcp_seq),
4746 [ACTION_INC_TCP_SEQ_VALUE] = {
4748 .help = "the value to increase TCP sequence number by",
4749 .next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(COMMON_UNSIGNED)),
4750 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4751 .call = parse_vc_conf,
4753 [ACTION_DEC_TCP_SEQ] = {
4754 .name = "dec_tcp_seq",
4755 .help = "decrease TCP sequence number",
4756 .priv = PRIV_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
4757 .next = NEXT(action_dec_tcp_seq),
4760 [ACTION_DEC_TCP_SEQ_VALUE] = {
4762 .help = "the value to decrease TCP sequence number by",
4763 .next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(COMMON_UNSIGNED)),
4764 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4765 .call = parse_vc_conf,
4767 [ACTION_INC_TCP_ACK] = {
4768 .name = "inc_tcp_ack",
4769 .help = "increase TCP acknowledgment number",
4770 .priv = PRIV_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
4771 .next = NEXT(action_inc_tcp_ack),
4774 [ACTION_INC_TCP_ACK_VALUE] = {
4776 .help = "the value to increase TCP acknowledgment number by",
4777 .next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(COMMON_UNSIGNED)),
4778 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4779 .call = parse_vc_conf,
4781 [ACTION_DEC_TCP_ACK] = {
4782 .name = "dec_tcp_ack",
4783 .help = "decrease TCP acknowledgment number",
4784 .priv = PRIV_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
4785 .next = NEXT(action_dec_tcp_ack),
4788 [ACTION_DEC_TCP_ACK_VALUE] = {
4790 .help = "the value to decrease TCP acknowledgment number by",
4791 .next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(COMMON_UNSIGNED)),
4792 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4793 .call = parse_vc_conf,
4795 [ACTION_RAW_ENCAP] = {
4796 .name = "raw_encap",
4797 .help = "encapsulation data, defined by set raw_encap",
4798 .priv = PRIV_ACTION(RAW_ENCAP,
4799 sizeof(struct action_raw_encap_data)),
4800 .next = NEXT(action_raw_encap),
4801 .call = parse_vc_action_raw_encap,
4803 [ACTION_RAW_ENCAP_INDEX] = {
4805 .help = "the index of raw_encap_confs",
4806 .next = NEXT(NEXT_ENTRY(ACTION_RAW_ENCAP_INDEX_VALUE)),
4808 [ACTION_RAW_ENCAP_INDEX_VALUE] = {
4811 .help = "unsigned integer value",
4812 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4813 .call = parse_vc_action_raw_encap_index,
4814 .comp = comp_set_raw_index,
4816 [ACTION_RAW_DECAP] = {
4817 .name = "raw_decap",
4818 .help = "decapsulation data, defined by set raw_encap",
4819 .priv = PRIV_ACTION(RAW_DECAP,
4820 sizeof(struct action_raw_decap_data)),
4821 .next = NEXT(action_raw_decap),
4822 .call = parse_vc_action_raw_decap,
4824 [ACTION_RAW_DECAP_INDEX] = {
4826 .help = "the index of raw_encap_confs",
4827 .next = NEXT(NEXT_ENTRY(ACTION_RAW_DECAP_INDEX_VALUE)),
4829 [ACTION_RAW_DECAP_INDEX_VALUE] = {
4832 .help = "unsigned integer value",
4833 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4834 .call = parse_vc_action_raw_decap_index,
4835 .comp = comp_set_raw_index,
4837 [ACTION_MODIFY_FIELD] = {
4838 .name = "modify_field",
4839 .help = "modify destination field with data from source field",
4840 .priv = PRIV_ACTION(MODIFY_FIELD, ACTION_MODIFY_SIZE),
4841 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_OP)),
4844 [ACTION_MODIFY_FIELD_OP] = {
4846 .help = "operation type",
4847 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_TYPE),
4848 NEXT_ENTRY(ACTION_MODIFY_FIELD_OP_VALUE)),
4849 .call = parse_vc_conf,
4851 [ACTION_MODIFY_FIELD_OP_VALUE] = {
4852 .name = "{operation}",
4853 .help = "operation type value",
4854 .call = parse_vc_modify_field_op,
4855 .comp = comp_set_modify_field_op,
4857 [ACTION_MODIFY_FIELD_DST_TYPE] = {
4859 .help = "destination field type",
4860 .next = NEXT(action_modify_field_dst,
4861 NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_TYPE_VALUE)),
4862 .call = parse_vc_conf,
4864 [ACTION_MODIFY_FIELD_DST_TYPE_VALUE] = {
4865 .name = "{dst_type}",
4866 .help = "destination field type value",
4867 .call = parse_vc_modify_field_id,
4868 .comp = comp_set_modify_field_id,
4870 [ACTION_MODIFY_FIELD_DST_LEVEL] = {
4871 .name = "dst_level",
4872 .help = "destination field level",
4873 .next = NEXT(action_modify_field_dst,
4874 NEXT_ENTRY(COMMON_UNSIGNED)),
4875 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4877 .call = parse_vc_conf,
4879 [ACTION_MODIFY_FIELD_DST_OFFSET] = {
4880 .name = "dst_offset",
4881 .help = "destination field bit offset",
4882 .next = NEXT(action_modify_field_dst,
4883 NEXT_ENTRY(COMMON_UNSIGNED)),
4884 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4886 .call = parse_vc_conf,
4888 [ACTION_MODIFY_FIELD_SRC_TYPE] = {
4890 .help = "source field type",
4891 .next = NEXT(action_modify_field_src,
4892 NEXT_ENTRY(ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)),
4893 .call = parse_vc_conf,
4895 [ACTION_MODIFY_FIELD_SRC_TYPE_VALUE] = {
4896 .name = "{src_type}",
4897 .help = "source field type value",
4898 .call = parse_vc_modify_field_id,
4899 .comp = comp_set_modify_field_id,
4901 [ACTION_MODIFY_FIELD_SRC_LEVEL] = {
4902 .name = "src_level",
4903 .help = "source field level",
4904 .next = NEXT(action_modify_field_src,
4905 NEXT_ENTRY(COMMON_UNSIGNED)),
4906 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4908 .call = parse_vc_conf,
4910 [ACTION_MODIFY_FIELD_SRC_OFFSET] = {
4911 .name = "src_offset",
4912 .help = "source field bit offset",
4913 .next = NEXT(action_modify_field_src,
4914 NEXT_ENTRY(COMMON_UNSIGNED)),
4915 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4917 .call = parse_vc_conf,
4919 [ACTION_MODIFY_FIELD_SRC_VALUE] = {
4920 .name = "src_value",
4921 .help = "source immediate value",
4922 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_WIDTH),
4923 NEXT_ENTRY(COMMON_HEX)),
4924 .args = ARGS(ARGS_ENTRY_ARB(0, 0),
4925 ARGS_ENTRY_ARB(0, 0),
4926 ARGS_ENTRY(struct rte_flow_action_modify_field,
4928 .call = parse_vc_conf,
4930 [ACTION_MODIFY_FIELD_SRC_POINTER] = {
4932 .help = "pointer to source immediate value",
4933 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_WIDTH),
4934 NEXT_ENTRY(COMMON_HEX)),
4935 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4937 ARGS_ENTRY_ARB(0, 0),
4939 (sizeof(struct rte_flow_action_modify_field),
4940 ACTION_MODIFY_PATTERN_SIZE)),
4941 .call = parse_vc_conf,
4943 [ACTION_MODIFY_FIELD_WIDTH] = {
4945 .help = "number of bits to copy",
4946 .next = NEXT(NEXT_ENTRY(ACTION_NEXT),
4947 NEXT_ENTRY(COMMON_UNSIGNED)),
4948 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4950 .call = parse_vc_conf,
4952 /* Top level command. */
4955 .help = "set raw encap/decap/sample data",
4956 .type = "set raw_encap|raw_decap <index> <pattern>"
4957 " or set sample_actions <index> <action>",
4958 .next = NEXT(NEXT_ENTRY
4961 SET_SAMPLE_ACTIONS)),
4962 .call = parse_set_init,
4964 /* Sub-level commands. */
4966 .name = "raw_encap",
4967 .help = "set raw encap data",
4968 .next = NEXT(next_set_raw),
4969 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4970 (offsetof(struct buffer, port),
4971 sizeof(((struct buffer *)0)->port),
4972 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
4973 .call = parse_set_raw_encap_decap,
4976 .name = "raw_decap",
4977 .help = "set raw decap data",
4978 .next = NEXT(next_set_raw),
4979 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4980 (offsetof(struct buffer, port),
4981 sizeof(((struct buffer *)0)->port),
4982 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
4983 .call = parse_set_raw_encap_decap,
4987 .type = "COMMON_UNSIGNED",
4988 .help = "index of raw_encap/raw_decap data",
4989 .next = NEXT(next_item),
4992 [SET_SAMPLE_INDEX] = {
4995 .help = "index of sample actions",
4996 .next = NEXT(next_action_sample),
4999 [SET_SAMPLE_ACTIONS] = {
5000 .name = "sample_actions",
5001 .help = "set sample actions list",
5002 .next = NEXT(NEXT_ENTRY(SET_SAMPLE_INDEX)),
5003 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
5004 (offsetof(struct buffer, port),
5005 sizeof(((struct buffer *)0)->port),
5006 0, RAW_SAMPLE_CONFS_MAX_NUM - 1)),
5007 .call = parse_set_sample_action,
5009 [ACTION_SET_TAG] = {
5012 .priv = PRIV_ACTION(SET_TAG,
5013 sizeof(struct rte_flow_action_set_tag)),
5014 .next = NEXT(action_set_tag),
5017 [ACTION_SET_TAG_INDEX] = {
5019 .help = "index of tag array",
5020 .next = NEXT(action_set_tag, NEXT_ENTRY(COMMON_UNSIGNED)),
5021 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_set_tag, index)),
5022 .call = parse_vc_conf,
5024 [ACTION_SET_TAG_DATA] = {
5026 .help = "tag value",
5027 .next = NEXT(action_set_tag, NEXT_ENTRY(COMMON_UNSIGNED)),
5028 .args = ARGS(ARGS_ENTRY
5029 (struct rte_flow_action_set_tag, data)),
5030 .call = parse_vc_conf,
5032 [ACTION_SET_TAG_MASK] = {
5034 .help = "mask for tag value",
5035 .next = NEXT(action_set_tag, NEXT_ENTRY(COMMON_UNSIGNED)),
5036 .args = ARGS(ARGS_ENTRY
5037 (struct rte_flow_action_set_tag, mask)),
5038 .call = parse_vc_conf,
5040 [ACTION_SET_META] = {
5042 .help = "set metadata",
5043 .priv = PRIV_ACTION(SET_META,
5044 sizeof(struct rte_flow_action_set_meta)),
5045 .next = NEXT(action_set_meta),
5046 .call = parse_vc_action_set_meta,
5048 [ACTION_SET_META_DATA] = {
5050 .help = "metadata value",
5051 .next = NEXT(action_set_meta, NEXT_ENTRY(COMMON_UNSIGNED)),
5052 .args = ARGS(ARGS_ENTRY
5053 (struct rte_flow_action_set_meta, data)),
5054 .call = parse_vc_conf,
5056 [ACTION_SET_META_MASK] = {
5058 .help = "mask for metadata value",
5059 .next = NEXT(action_set_meta, NEXT_ENTRY(COMMON_UNSIGNED)),
5060 .args = ARGS(ARGS_ENTRY
5061 (struct rte_flow_action_set_meta, mask)),
5062 .call = parse_vc_conf,
5064 [ACTION_SET_IPV4_DSCP] = {
5065 .name = "set_ipv4_dscp",
5066 .help = "set DSCP value",
5067 .priv = PRIV_ACTION(SET_IPV4_DSCP,
5068 sizeof(struct rte_flow_action_set_dscp)),
5069 .next = NEXT(action_set_ipv4_dscp),
5072 [ACTION_SET_IPV4_DSCP_VALUE] = {
5073 .name = "dscp_value",
5074 .help = "new IPv4 DSCP value to set",
5075 .next = NEXT(action_set_ipv4_dscp, NEXT_ENTRY(COMMON_UNSIGNED)),
5076 .args = ARGS(ARGS_ENTRY
5077 (struct rte_flow_action_set_dscp, dscp)),
5078 .call = parse_vc_conf,
5080 [ACTION_SET_IPV6_DSCP] = {
5081 .name = "set_ipv6_dscp",
5082 .help = "set DSCP value",
5083 .priv = PRIV_ACTION(SET_IPV6_DSCP,
5084 sizeof(struct rte_flow_action_set_dscp)),
5085 .next = NEXT(action_set_ipv6_dscp),
5088 [ACTION_SET_IPV6_DSCP_VALUE] = {
5089 .name = "dscp_value",
5090 .help = "new IPv6 DSCP value to set",
5091 .next = NEXT(action_set_ipv6_dscp, NEXT_ENTRY(COMMON_UNSIGNED)),
5092 .args = ARGS(ARGS_ENTRY
5093 (struct rte_flow_action_set_dscp, dscp)),
5094 .call = parse_vc_conf,
5098 .help = "set a specific metadata header",
5099 .next = NEXT(action_age),
5100 .priv = PRIV_ACTION(AGE,
5101 sizeof(struct rte_flow_action_age)),
5104 [ACTION_AGE_TIMEOUT] = {
5106 .help = "flow age timeout value",
5107 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_age,
5109 .next = NEXT(action_age, NEXT_ENTRY(COMMON_UNSIGNED)),
5110 .call = parse_vc_conf,
5114 .help = "set a sample action",
5115 .next = NEXT(action_sample),
5116 .priv = PRIV_ACTION(SAMPLE,
5117 sizeof(struct action_sample_data)),
5118 .call = parse_vc_action_sample,
5120 [ACTION_SAMPLE_RATIO] = {
5122 .help = "flow sample ratio value",
5123 .next = NEXT(action_sample, NEXT_ENTRY(COMMON_UNSIGNED)),
5124 .args = ARGS(ARGS_ENTRY_ARB
5125 (offsetof(struct action_sample_data, conf) +
5126 offsetof(struct rte_flow_action_sample, ratio),
5127 sizeof(((struct rte_flow_action_sample *)0)->
5130 [ACTION_SAMPLE_INDEX] = {
5132 .help = "the index of sample actions list",
5133 .next = NEXT(NEXT_ENTRY(ACTION_SAMPLE_INDEX_VALUE)),
5135 [ACTION_SAMPLE_INDEX_VALUE] = {
5137 .type = "COMMON_UNSIGNED",
5138 .help = "unsigned integer value",
5139 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
5140 .call = parse_vc_action_sample_index,
5141 .comp = comp_set_sample_index,
5143 [ACTION_CONNTRACK] = {
5144 .name = "conntrack",
5145 .help = "create a conntrack object",
5146 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
5147 .priv = PRIV_ACTION(CONNTRACK,
5148 sizeof(struct rte_flow_action_conntrack)),
5151 [ACTION_CONNTRACK_UPDATE] = {
5152 .name = "conntrack_update",
5153 .help = "update a conntrack object",
5154 .next = NEXT(action_update_conntrack),
5155 .priv = PRIV_ACTION(CONNTRACK,
5156 sizeof(struct rte_flow_modify_conntrack)),
5159 [ACTION_CONNTRACK_UPDATE_DIR] = {
5161 .help = "update a conntrack object direction",
5162 .next = NEXT(action_update_conntrack),
5163 .call = parse_vc_action_conntrack_update,
5165 [ACTION_CONNTRACK_UPDATE_CTX] = {
5167 .help = "update a conntrack object context",
5168 .next = NEXT(action_update_conntrack),
5169 .call = parse_vc_action_conntrack_update,
5171 [ACTION_PORT_REPRESENTOR] = {
5172 .name = "port_representor",
5173 .help = "at embedded switch level, send matching traffic to the given ethdev",
5174 .priv = PRIV_ACTION(PORT_REPRESENTOR,
5175 sizeof(struct rte_flow_action_ethdev)),
5176 .next = NEXT(action_port_representor),
5179 [ACTION_PORT_REPRESENTOR_PORT_ID] = {
5181 .help = "ethdev port ID",
5182 .next = NEXT(action_port_representor,
5183 NEXT_ENTRY(COMMON_UNSIGNED)),
5184 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_ethdev,
5186 .call = parse_vc_conf,
5188 [ACTION_REPRESENTED_PORT] = {
5189 .name = "represented_port",
5190 .help = "at embedded switch level, send matching traffic to the entity represented by the given ethdev",
5191 .priv = PRIV_ACTION(REPRESENTED_PORT,
5192 sizeof(struct rte_flow_action_ethdev)),
5193 .next = NEXT(action_represented_port),
5196 [ACTION_REPRESENTED_PORT_ETHDEV_PORT_ID] = {
5197 .name = "ethdev_port_id",
5198 .help = "ethdev port ID",
5199 .next = NEXT(action_represented_port,
5200 NEXT_ENTRY(COMMON_UNSIGNED)),
5201 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_ethdev,
5203 .call = parse_vc_conf,
5205 /* Indirect action destroy arguments. */
5206 [INDIRECT_ACTION_DESTROY_ID] = {
5207 .name = "action_id",
5208 .help = "specify a indirect action id to destroy",
5209 .next = NEXT(next_ia_destroy_attr,
5210 NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
5211 .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
5212 args.ia_destroy.action_id)),
5213 .call = parse_ia_destroy,
5215 /* Indirect action create arguments. */
5216 [INDIRECT_ACTION_CREATE_ID] = {
5217 .name = "action_id",
5218 .help = "specify a indirect action id to create",
5219 .next = NEXT(next_ia_create_attr,
5220 NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
5221 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
5223 [ACTION_INDIRECT] = {
5225 .help = "apply indirect action by id",
5226 .priv = PRIV_ACTION(INDIRECT, 0),
5227 .next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_ID2PTR)),
5228 .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
5231 [INDIRECT_ACTION_ID2PTR] = {
5232 .name = "{action_id}",
5233 .type = "INDIRECT_ACTION_ID",
5234 .help = "indirect action id",
5235 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
5236 .call = parse_ia_id2ptr,
5239 [INDIRECT_ACTION_INGRESS] = {
5241 .help = "affect rule to ingress",
5242 .next = NEXT(next_ia_create_attr),
5245 [INDIRECT_ACTION_EGRESS] = {
5247 .help = "affect rule to egress",
5248 .next = NEXT(next_ia_create_attr),
5251 [INDIRECT_ACTION_TRANSFER] = {
5253 .help = "affect rule to transfer",
5254 .next = NEXT(next_ia_create_attr),
5257 [INDIRECT_ACTION_SPEC] = {
5259 .help = "specify action to create indirect handle",
5260 .next = NEXT(next_action),
5263 .name = "g_actions",
5264 .help = "submit a list of associated actions for green",
5265 .next = NEXT(next_action),
5269 .name = "y_actions",
5270 .help = "submit a list of associated actions for yellow",
5271 .next = NEXT(next_action),
5274 .name = "r_actions",
5275 .help = "submit a list of associated actions for red",
5276 .next = NEXT(next_action),
5279 /* Top-level command. */
5282 .type = "port meter policy {port_id} {arg}",
5283 .help = "add port meter policy",
5284 .next = NEXT(NEXT_ENTRY(ITEM_POL_PORT)),
5287 /* Sub-level commands. */
5290 .help = "add port meter policy",
5291 .next = NEXT(NEXT_ENTRY(ITEM_POL_METER)),
5293 [ITEM_POL_METER] = {
5295 .help = "add port meter policy",
5296 .next = NEXT(NEXT_ENTRY(ITEM_POL_POLICY)),
5298 [ITEM_POL_POLICY] = {
5300 .help = "add port meter policy",
5301 .next = NEXT(NEXT_ENTRY(ACTION_POL_R),
5302 NEXT_ENTRY(ACTION_POL_Y),
5303 NEXT_ENTRY(ACTION_POL_G),
5304 NEXT_ENTRY(COMMON_POLICY_ID),
5305 NEXT_ENTRY(COMMON_PORT_ID)),
5306 .args = ARGS(ARGS_ENTRY(struct buffer, args.policy.policy_id),
5307 ARGS_ENTRY(struct buffer, port)),
5312 /** Remove and return last entry from argument stack. */
5313 static const struct arg *
5314 pop_args(struct context *ctx)
5316 return ctx->args_num ? ctx->args[--ctx->args_num] : NULL;
5319 /** Add entry on top of the argument stack. */
5321 push_args(struct context *ctx, const struct arg *arg)
5323 if (ctx->args_num == CTX_STACK_SIZE)
5325 ctx->args[ctx->args_num++] = arg;
5329 /** Spread value into buffer according to bit-mask. */
5331 arg_entry_bf_fill(void *dst, uintmax_t val, const struct arg *arg)
5333 uint32_t i = arg->size;
5341 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
5350 unsigned int shift = 0;
5351 uint8_t *buf = (uint8_t *)dst + arg->offset + (i -= sub);
5353 for (shift = 0; arg->mask[i] >> shift; ++shift) {
5354 if (!(arg->mask[i] & (1 << shift)))
5359 *buf &= ~(1 << shift);
5360 *buf |= (val & 1) << shift;
5368 /** Compare a string with a partial one of a given length. */
5370 strcmp_partial(const char *full, const char *partial, size_t partial_len)
5372 int r = strncmp(full, partial, partial_len);
5376 if (strlen(full) <= partial_len)
5378 return full[partial_len];
5382 * Parse a prefix length and generate a bit-mask.
5384 * Last argument (ctx->args) is retrieved to determine mask size, storage
5385 * location and whether the result must use network byte ordering.
5388 parse_prefix(struct context *ctx, const struct token *token,
5389 const char *str, unsigned int len,
5390 void *buf, unsigned int size)
5392 const struct arg *arg = pop_args(ctx);
5393 static const uint8_t conv[] = "\x00\x80\xc0\xe0\xf0\xf8\xfc\xfe\xff";
5400 /* Argument is expected. */
5404 u = strtoumax(str, &end, 0);
5405 if (errno || (size_t)(end - str) != len)
5410 extra = arg_entry_bf_fill(NULL, 0, arg);
5419 if (!arg_entry_bf_fill(ctx->object, v, arg) ||
5420 !arg_entry_bf_fill(ctx->objmask, -1, arg))
5427 if (bytes > size || bytes + !!extra > size)
5431 buf = (uint8_t *)ctx->object + arg->offset;
5432 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
5434 memset((uint8_t *)buf + size - bytes, 0xff, bytes);
5435 memset(buf, 0x00, size - bytes);
5437 ((uint8_t *)buf)[size - bytes - 1] = conv[extra];
5441 memset(buf, 0xff, bytes);
5442 memset((uint8_t *)buf + bytes, 0x00, size - bytes);
5444 ((uint8_t *)buf)[bytes] = conv[extra];
5447 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
5450 push_args(ctx, arg);
5454 /** Default parsing function for token name matching. */
5456 parse_default(struct context *ctx, const struct token *token,
5457 const char *str, unsigned int len,
5458 void *buf, unsigned int size)
5463 if (strcmp_partial(token->name, str, len))
5468 /** Parse flow command, initialize output buffer for subsequent tokens. */
5470 parse_init(struct context *ctx, const struct token *token,
5471 const char *str, unsigned int len,
5472 void *buf, unsigned int size)
5474 struct buffer *out = buf;
5476 /* Token name must match. */
5477 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5479 /* Nothing else to do if there is no buffer. */
5482 /* Make sure buffer is large enough. */
5483 if (size < sizeof(*out))
5485 /* Initialize buffer. */
5486 memset(out, 0x00, sizeof(*out));
5487 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
5490 ctx->objmask = NULL;
5494 /** Parse tokens for indirect action commands. */
5496 parse_ia(struct context *ctx, const struct token *token,
5497 const char *str, unsigned int len,
5498 void *buf, unsigned int size)
5500 struct buffer *out = buf;
5502 /* Token name must match. */
5503 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5505 /* Nothing else to do if there is no buffer. */
5508 if (!out->command) {
5509 if (ctx->curr != INDIRECT_ACTION)
5511 if (sizeof(*out) > size)
5513 out->command = ctx->curr;
5516 ctx->objmask = NULL;
5517 out->args.vc.data = (uint8_t *)out + size;
5520 switch (ctx->curr) {
5521 case INDIRECT_ACTION_CREATE:
5522 case INDIRECT_ACTION_UPDATE:
5523 out->args.vc.actions =
5524 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5526 out->args.vc.attr.group = UINT32_MAX;
5528 case INDIRECT_ACTION_QUERY:
5529 out->command = ctx->curr;
5532 ctx->objmask = NULL;
5534 case INDIRECT_ACTION_EGRESS:
5535 out->args.vc.attr.egress = 1;
5537 case INDIRECT_ACTION_INGRESS:
5538 out->args.vc.attr.ingress = 1;
5540 case INDIRECT_ACTION_TRANSFER:
5541 out->args.vc.attr.transfer = 1;
5549 /** Parse tokens for indirect action destroy command. */
5551 parse_ia_destroy(struct context *ctx, const struct token *token,
5552 const char *str, unsigned int len,
5553 void *buf, unsigned int size)
5555 struct buffer *out = buf;
5556 uint32_t *action_id;
5558 /* Token name must match. */
5559 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5561 /* Nothing else to do if there is no buffer. */
5564 if (!out->command || out->command == INDIRECT_ACTION) {
5565 if (ctx->curr != INDIRECT_ACTION_DESTROY)
5567 if (sizeof(*out) > size)
5569 out->command = ctx->curr;
5572 ctx->objmask = NULL;
5573 out->args.ia_destroy.action_id =
5574 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5578 action_id = out->args.ia_destroy.action_id
5579 + out->args.ia_destroy.action_id_n++;
5580 if ((uint8_t *)action_id > (uint8_t *)out + size)
5583 ctx->object = action_id;
5584 ctx->objmask = NULL;
5588 /** Parse tokens for meter policy action commands. */
5590 parse_mp(struct context *ctx, const struct token *token,
5591 const char *str, unsigned int len,
5592 void *buf, unsigned int size)
5594 struct buffer *out = buf;
5596 /* Token name must match. */
5597 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5599 /* Nothing else to do if there is no buffer. */
5602 if (!out->command) {
5603 if (ctx->curr != ITEM_POL_POLICY)
5605 if (sizeof(*out) > size)
5607 out->command = ctx->curr;
5610 ctx->objmask = NULL;
5611 out->args.vc.data = (uint8_t *)out + size;
5614 switch (ctx->curr) {
5616 out->args.vc.actions =
5617 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5619 out->command = ctx->curr;
5622 ctx->objmask = NULL;
5629 /** Parse tokens for validate/create commands. */
5631 parse_vc(struct context *ctx, const struct token *token,
5632 const char *str, unsigned int len,
5633 void *buf, unsigned int size)
5635 struct buffer *out = buf;
5639 /* Token name must match. */
5640 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5642 /* Nothing else to do if there is no buffer. */
5645 if (!out->command) {
5646 if (ctx->curr != VALIDATE && ctx->curr != CREATE)
5648 if (sizeof(*out) > size)
5650 out->command = ctx->curr;
5653 ctx->objmask = NULL;
5654 out->args.vc.data = (uint8_t *)out + size;
5658 switch (ctx->curr) {
5660 ctx->object = &out->args.vc.attr;
5663 case VC_TUNNEL_MATCH:
5664 ctx->object = &out->args.vc.tunnel_ops;
5667 ctx->objmask = NULL;
5668 switch (ctx->curr) {
5673 out->args.vc.tunnel_ops.enabled = 1;
5674 out->args.vc.tunnel_ops.actions = 1;
5676 case VC_TUNNEL_MATCH:
5677 out->args.vc.tunnel_ops.enabled = 1;
5678 out->args.vc.tunnel_ops.items = 1;
5681 out->args.vc.attr.ingress = 1;
5684 out->args.vc.attr.egress = 1;
5687 out->args.vc.attr.transfer = 1;
5690 out->args.vc.pattern =
5691 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5693 ctx->object = out->args.vc.pattern;
5694 ctx->objmask = NULL;
5697 out->args.vc.actions =
5698 (void *)RTE_ALIGN_CEIL((uintptr_t)
5699 (out->args.vc.pattern +
5700 out->args.vc.pattern_n),
5702 ctx->object = out->args.vc.actions;
5703 ctx->objmask = NULL;
5710 if (!out->args.vc.actions) {
5711 const struct parse_item_priv *priv = token->priv;
5712 struct rte_flow_item *item =
5713 out->args.vc.pattern + out->args.vc.pattern_n;
5715 data_size = priv->size * 3; /* spec, last, mask */
5716 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
5717 (out->args.vc.data - data_size),
5719 if ((uint8_t *)item + sizeof(*item) > data)
5721 *item = (struct rte_flow_item){
5724 ++out->args.vc.pattern_n;
5726 ctx->objmask = NULL;
5728 const struct parse_action_priv *priv = token->priv;
5729 struct rte_flow_action *action =
5730 out->args.vc.actions + out->args.vc.actions_n;
5732 data_size = priv->size; /* configuration */
5733 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
5734 (out->args.vc.data - data_size),
5736 if ((uint8_t *)action + sizeof(*action) > data)
5738 *action = (struct rte_flow_action){
5740 .conf = data_size ? data : NULL,
5742 ++out->args.vc.actions_n;
5743 ctx->object = action;
5744 ctx->objmask = NULL;
5746 memset(data, 0, data_size);
5747 out->args.vc.data = data;
5748 ctx->objdata = data_size;
5752 /** Parse pattern item parameter type. */
5754 parse_vc_spec(struct context *ctx, const struct token *token,
5755 const char *str, unsigned int len,
5756 void *buf, unsigned int size)
5758 struct buffer *out = buf;
5759 struct rte_flow_item *item;
5765 /* Token name must match. */
5766 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5768 /* Parse parameter types. */
5769 switch (ctx->curr) {
5770 static const enum index prefix[] = NEXT_ENTRY(COMMON_PREFIX);
5776 case ITEM_PARAM_SPEC:
5779 case ITEM_PARAM_LAST:
5782 case ITEM_PARAM_PREFIX:
5783 /* Modify next token to expect a prefix. */
5784 if (ctx->next_num < 2)
5786 ctx->next[ctx->next_num - 2] = prefix;
5788 case ITEM_PARAM_MASK:
5794 /* Nothing else to do if there is no buffer. */
5797 if (!out->args.vc.pattern_n)
5799 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
5800 data_size = ctx->objdata / 3; /* spec, last, mask */
5801 /* Point to selected object. */
5802 ctx->object = out->args.vc.data + (data_size * index);
5804 ctx->objmask = out->args.vc.data + (data_size * 2); /* mask */
5805 item->mask = ctx->objmask;
5807 ctx->objmask = NULL;
5808 /* Update relevant item pointer. */
5809 *((const void **[]){ &item->spec, &item->last, &item->mask })[index] =
5814 /** Parse action configuration field. */
5816 parse_vc_conf(struct context *ctx, const struct token *token,
5817 const char *str, unsigned int len,
5818 void *buf, unsigned int size)
5820 struct buffer *out = buf;
5823 /* Token name must match. */
5824 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5826 /* Nothing else to do if there is no buffer. */
5829 /* Point to selected object. */
5830 ctx->object = out->args.vc.data;
5831 ctx->objmask = NULL;
5835 /** Parse eCPRI common header type field. */
5837 parse_vc_item_ecpri_type(struct context *ctx, const struct token *token,
5838 const char *str, unsigned int len,
5839 void *buf, unsigned int size)
5841 struct rte_flow_item_ecpri *ecpri;
5842 struct rte_flow_item_ecpri *ecpri_mask;
5843 struct rte_flow_item *item;
5846 struct buffer *out = buf;
5847 const struct arg *arg;
5850 /* Token name must match. */
5851 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5853 switch (ctx->curr) {
5854 case ITEM_ECPRI_COMMON_TYPE_IQ_DATA:
5855 msg_type = RTE_ECPRI_MSG_TYPE_IQ_DATA;
5857 case ITEM_ECPRI_COMMON_TYPE_RTC_CTRL:
5858 msg_type = RTE_ECPRI_MSG_TYPE_RTC_CTRL;
5860 case ITEM_ECPRI_COMMON_TYPE_DLY_MSR:
5861 msg_type = RTE_ECPRI_MSG_TYPE_DLY_MSR;
5868 arg = pop_args(ctx);
5871 ecpri = (struct rte_flow_item_ecpri *)out->args.vc.data;
5872 ecpri->hdr.common.type = msg_type;
5873 data_size = ctx->objdata / 3; /* spec, last, mask */
5874 ecpri_mask = (struct rte_flow_item_ecpri *)(out->args.vc.data +
5876 ecpri_mask->hdr.common.type = 0xFF;
5878 ecpri->hdr.common.u32 = rte_cpu_to_be_32(ecpri->hdr.common.u32);
5879 ecpri_mask->hdr.common.u32 =
5880 rte_cpu_to_be_32(ecpri_mask->hdr.common.u32);
5882 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
5884 item->mask = ecpri_mask;
5888 /** Parse L2TPv2 common header type field. */
5890 parse_vc_item_l2tpv2_type(struct context *ctx, const struct token *token,
5891 const char *str, unsigned int len,
5892 void *buf, unsigned int size)
5894 struct rte_flow_item_l2tpv2 *l2tpv2;
5895 struct rte_flow_item_l2tpv2 *l2tpv2_mask;
5896 struct rte_flow_item *item;
5898 uint16_t msg_type = 0;
5899 struct buffer *out = buf;
5900 const struct arg *arg;
5903 /* Token name must match. */
5904 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5906 switch (ctx->curr) {
5907 case ITEM_L2TPV2_COMMON_TYPE_DATA_L:
5910 case ITEM_L2TPV2_COMMON_TYPE_CTRL:
5918 arg = pop_args(ctx);
5921 l2tpv2 = (struct rte_flow_item_l2tpv2 *)out->args.vc.data;
5922 l2tpv2->hdr.common.flags_version |= msg_type;
5923 data_size = ctx->objdata / 3; /* spec, last, mask */
5924 l2tpv2_mask = (struct rte_flow_item_l2tpv2 *)(out->args.vc.data +
5926 l2tpv2_mask->hdr.common.flags_version = 0xFFFF;
5928 l2tpv2->hdr.common.flags_version =
5929 rte_cpu_to_be_16(l2tpv2->hdr.common.flags_version);
5930 l2tpv2_mask->hdr.common.flags_version =
5931 rte_cpu_to_be_16(l2tpv2_mask->hdr.common.flags_version);
5933 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
5934 item->spec = l2tpv2;
5935 item->mask = l2tpv2_mask;
5939 /** Parse meter color action type. */
5941 parse_vc_action_meter_color_type(struct context *ctx, const struct token *token,
5942 const char *str, unsigned int len,
5943 void *buf, unsigned int size)
5945 struct rte_flow_action *action_data;
5946 struct rte_flow_action_meter_color *conf;
5947 enum rte_color color;
5951 /* Token name must match. */
5952 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5954 switch (ctx->curr) {
5955 case ACTION_METER_COLOR_GREEN:
5956 color = RTE_COLOR_GREEN;
5958 case ACTION_METER_COLOR_YELLOW:
5959 color = RTE_COLOR_YELLOW;
5961 case ACTION_METER_COLOR_RED:
5962 color = RTE_COLOR_RED;
5970 action_data = ctx->object;
5971 conf = (struct rte_flow_action_meter_color *)
5972 (uintptr_t)(action_data->conf);
5973 conf->color = color;
5977 /** Parse RSS action. */
5979 parse_vc_action_rss(struct context *ctx, const struct token *token,
5980 const char *str, unsigned int len,
5981 void *buf, unsigned int size)
5983 struct buffer *out = buf;
5984 struct rte_flow_action *action;
5985 struct action_rss_data *action_rss_data;
5989 ret = parse_vc(ctx, token, str, len, buf, size);
5992 /* Nothing else to do if there is no buffer. */
5995 if (!out->args.vc.actions_n)
5997 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5998 /* Point to selected object. */
5999 ctx->object = out->args.vc.data;
6000 ctx->objmask = NULL;
6001 /* Set up default configuration. */
6002 action_rss_data = ctx->object;
6003 *action_rss_data = (struct action_rss_data){
6004 .conf = (struct rte_flow_action_rss){
6005 .func = RTE_ETH_HASH_FUNCTION_DEFAULT,
6009 .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM),
6011 .queue = action_rss_data->queue,
6015 for (i = 0; i < action_rss_data->conf.queue_num; ++i)
6016 action_rss_data->queue[i] = i;
6017 action->conf = &action_rss_data->conf;
6022 * Parse func field for RSS action.
6024 * The RTE_ETH_HASH_FUNCTION_* value to assign is derived from the
6025 * ACTION_RSS_FUNC_* index that called this function.
6028 parse_vc_action_rss_func(struct context *ctx, const struct token *token,
6029 const char *str, unsigned int len,
6030 void *buf, unsigned int size)
6032 struct action_rss_data *action_rss_data;
6033 enum rte_eth_hash_function func;
6037 /* Token name must match. */
6038 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6040 switch (ctx->curr) {
6041 case ACTION_RSS_FUNC_DEFAULT:
6042 func = RTE_ETH_HASH_FUNCTION_DEFAULT;
6044 case ACTION_RSS_FUNC_TOEPLITZ:
6045 func = RTE_ETH_HASH_FUNCTION_TOEPLITZ;
6047 case ACTION_RSS_FUNC_SIMPLE_XOR:
6048 func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
6050 case ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ:
6051 func = RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
6058 action_rss_data = ctx->object;
6059 action_rss_data->conf.func = func;
6064 * Parse type field for RSS action.
6066 * Valid tokens are type field names and the "end" token.
6069 parse_vc_action_rss_type(struct context *ctx, const struct token *token,
6070 const char *str, unsigned int len,
6071 void *buf, unsigned int size)
6073 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE);
6074 struct action_rss_data *action_rss_data;
6080 if (ctx->curr != ACTION_RSS_TYPE)
6082 if (!(ctx->objdata >> 16) && ctx->object) {
6083 action_rss_data = ctx->object;
6084 action_rss_data->conf.types = 0;
6086 if (!strcmp_partial("end", str, len)) {
6087 ctx->objdata &= 0xffff;
6090 for (i = 0; rss_type_table[i].str; ++i)
6091 if (!strcmp_partial(rss_type_table[i].str, str, len))
6093 if (!rss_type_table[i].str)
6095 ctx->objdata = 1 << 16 | (ctx->objdata & 0xffff);
6097 if (ctx->next_num == RTE_DIM(ctx->next))
6099 ctx->next[ctx->next_num++] = next;
6102 action_rss_data = ctx->object;
6103 action_rss_data->conf.types |= rss_type_table[i].rss_type;
6108 * Parse queue field for RSS action.
6110 * Valid tokens are queue indices and the "end" token.
6113 parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
6114 const char *str, unsigned int len,
6115 void *buf, unsigned int size)
6117 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE);
6118 struct action_rss_data *action_rss_data;
6119 const struct arg *arg;
6126 if (ctx->curr != ACTION_RSS_QUEUE)
6128 i = ctx->objdata >> 16;
6129 if (!strcmp_partial("end", str, len)) {
6130 ctx->objdata &= 0xffff;
6133 if (i >= ACTION_RSS_QUEUE_NUM)
6135 arg = ARGS_ENTRY_ARB(offsetof(struct action_rss_data, queue) +
6136 i * sizeof(action_rss_data->queue[i]),
6137 sizeof(action_rss_data->queue[i]));
6138 if (push_args(ctx, arg))
6140 ret = parse_int(ctx, token, str, len, NULL, 0);
6146 ctx->objdata = i << 16 | (ctx->objdata & 0xffff);
6148 if (ctx->next_num == RTE_DIM(ctx->next))
6150 ctx->next[ctx->next_num++] = next;
6154 action_rss_data = ctx->object;
6155 action_rss_data->conf.queue_num = i;
6156 action_rss_data->conf.queue = i ? action_rss_data->queue : NULL;
6160 /** Setup VXLAN encap configuration. */
6162 parse_setup_vxlan_encap_data(struct action_vxlan_encap_data *action_vxlan_encap_data)
6164 /* Set up default configuration. */
6165 *action_vxlan_encap_data = (struct action_vxlan_encap_data){
6166 .conf = (struct rte_flow_action_vxlan_encap){
6167 .definition = action_vxlan_encap_data->items,
6171 .type = RTE_FLOW_ITEM_TYPE_ETH,
6172 .spec = &action_vxlan_encap_data->item_eth,
6173 .mask = &rte_flow_item_eth_mask,
6176 .type = RTE_FLOW_ITEM_TYPE_VLAN,
6177 .spec = &action_vxlan_encap_data->item_vlan,
6178 .mask = &rte_flow_item_vlan_mask,
6181 .type = RTE_FLOW_ITEM_TYPE_IPV4,
6182 .spec = &action_vxlan_encap_data->item_ipv4,
6183 .mask = &rte_flow_item_ipv4_mask,
6186 .type = RTE_FLOW_ITEM_TYPE_UDP,
6187 .spec = &action_vxlan_encap_data->item_udp,
6188 .mask = &rte_flow_item_udp_mask,
6191 .type = RTE_FLOW_ITEM_TYPE_VXLAN,
6192 .spec = &action_vxlan_encap_data->item_vxlan,
6193 .mask = &rte_flow_item_vxlan_mask,
6196 .type = RTE_FLOW_ITEM_TYPE_END,
6201 .tci = vxlan_encap_conf.vlan_tci,
6205 .src_addr = vxlan_encap_conf.ipv4_src,
6206 .dst_addr = vxlan_encap_conf.ipv4_dst,
6209 .src_port = vxlan_encap_conf.udp_src,
6210 .dst_port = vxlan_encap_conf.udp_dst,
6212 .item_vxlan.flags = 0,
6214 memcpy(action_vxlan_encap_data->item_eth.dst.addr_bytes,
6215 vxlan_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
6216 memcpy(action_vxlan_encap_data->item_eth.src.addr_bytes,
6217 vxlan_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
6218 if (!vxlan_encap_conf.select_ipv4) {
6219 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.src_addr,
6220 &vxlan_encap_conf.ipv6_src,
6221 sizeof(vxlan_encap_conf.ipv6_src));
6222 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.dst_addr,
6223 &vxlan_encap_conf.ipv6_dst,
6224 sizeof(vxlan_encap_conf.ipv6_dst));
6225 action_vxlan_encap_data->items[2] = (struct rte_flow_item){
6226 .type = RTE_FLOW_ITEM_TYPE_IPV6,
6227 .spec = &action_vxlan_encap_data->item_ipv6,
6228 .mask = &rte_flow_item_ipv6_mask,
6231 if (!vxlan_encap_conf.select_vlan)
6232 action_vxlan_encap_data->items[1].type =
6233 RTE_FLOW_ITEM_TYPE_VOID;
6234 if (vxlan_encap_conf.select_tos_ttl) {
6235 if (vxlan_encap_conf.select_ipv4) {
6236 static struct rte_flow_item_ipv4 ipv4_mask_tos;
6238 memcpy(&ipv4_mask_tos, &rte_flow_item_ipv4_mask,
6239 sizeof(ipv4_mask_tos));
6240 ipv4_mask_tos.hdr.type_of_service = 0xff;
6241 ipv4_mask_tos.hdr.time_to_live = 0xff;
6242 action_vxlan_encap_data->item_ipv4.hdr.type_of_service =
6243 vxlan_encap_conf.ip_tos;
6244 action_vxlan_encap_data->item_ipv4.hdr.time_to_live =
6245 vxlan_encap_conf.ip_ttl;
6246 action_vxlan_encap_data->items[2].mask =
6249 static struct rte_flow_item_ipv6 ipv6_mask_tos;
6251 memcpy(&ipv6_mask_tos, &rte_flow_item_ipv6_mask,
6252 sizeof(ipv6_mask_tos));
6253 ipv6_mask_tos.hdr.vtc_flow |=
6254 RTE_BE32(0xfful << RTE_IPV6_HDR_TC_SHIFT);
6255 ipv6_mask_tos.hdr.hop_limits = 0xff;
6256 action_vxlan_encap_data->item_ipv6.hdr.vtc_flow |=
6258 ((uint32_t)vxlan_encap_conf.ip_tos <<
6259 RTE_IPV6_HDR_TC_SHIFT);
6260 action_vxlan_encap_data->item_ipv6.hdr.hop_limits =
6261 vxlan_encap_conf.ip_ttl;
6262 action_vxlan_encap_data->items[2].mask =
6266 memcpy(action_vxlan_encap_data->item_vxlan.vni, vxlan_encap_conf.vni,
6267 RTE_DIM(vxlan_encap_conf.vni));
6271 /** Parse VXLAN encap action. */
6273 parse_vc_action_vxlan_encap(struct context *ctx, const struct token *token,
6274 const char *str, unsigned int len,
6275 void *buf, unsigned int size)
6277 struct buffer *out = buf;
6278 struct rte_flow_action *action;
6279 struct action_vxlan_encap_data *action_vxlan_encap_data;
6282 ret = parse_vc(ctx, token, str, len, buf, size);
6285 /* Nothing else to do if there is no buffer. */
6288 if (!out->args.vc.actions_n)
6290 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6291 /* Point to selected object. */
6292 ctx->object = out->args.vc.data;
6293 ctx->objmask = NULL;
6294 action_vxlan_encap_data = ctx->object;
6295 parse_setup_vxlan_encap_data(action_vxlan_encap_data);
6296 action->conf = &action_vxlan_encap_data->conf;
6300 /** Setup NVGRE encap configuration. */
6302 parse_setup_nvgre_encap_data(struct action_nvgre_encap_data *action_nvgre_encap_data)
6304 /* Set up default configuration. */
6305 *action_nvgre_encap_data = (struct action_nvgre_encap_data){
6306 .conf = (struct rte_flow_action_nvgre_encap){
6307 .definition = action_nvgre_encap_data->items,
6311 .type = RTE_FLOW_ITEM_TYPE_ETH,
6312 .spec = &action_nvgre_encap_data->item_eth,
6313 .mask = &rte_flow_item_eth_mask,
6316 .type = RTE_FLOW_ITEM_TYPE_VLAN,
6317 .spec = &action_nvgre_encap_data->item_vlan,
6318 .mask = &rte_flow_item_vlan_mask,
6321 .type = RTE_FLOW_ITEM_TYPE_IPV4,
6322 .spec = &action_nvgre_encap_data->item_ipv4,
6323 .mask = &rte_flow_item_ipv4_mask,
6326 .type = RTE_FLOW_ITEM_TYPE_NVGRE,
6327 .spec = &action_nvgre_encap_data->item_nvgre,
6328 .mask = &rte_flow_item_nvgre_mask,
6331 .type = RTE_FLOW_ITEM_TYPE_END,
6336 .tci = nvgre_encap_conf.vlan_tci,
6340 .src_addr = nvgre_encap_conf.ipv4_src,
6341 .dst_addr = nvgre_encap_conf.ipv4_dst,
6343 .item_nvgre.c_k_s_rsvd0_ver = RTE_BE16(0x2000),
6344 .item_nvgre.protocol = RTE_BE16(RTE_ETHER_TYPE_TEB),
6345 .item_nvgre.flow_id = 0,
6347 memcpy(action_nvgre_encap_data->item_eth.dst.addr_bytes,
6348 nvgre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
6349 memcpy(action_nvgre_encap_data->item_eth.src.addr_bytes,
6350 nvgre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
6351 if (!nvgre_encap_conf.select_ipv4) {
6352 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.src_addr,
6353 &nvgre_encap_conf.ipv6_src,
6354 sizeof(nvgre_encap_conf.ipv6_src));
6355 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.dst_addr,
6356 &nvgre_encap_conf.ipv6_dst,
6357 sizeof(nvgre_encap_conf.ipv6_dst));
6358 action_nvgre_encap_data->items[2] = (struct rte_flow_item){
6359 .type = RTE_FLOW_ITEM_TYPE_IPV6,
6360 .spec = &action_nvgre_encap_data->item_ipv6,
6361 .mask = &rte_flow_item_ipv6_mask,
6364 if (!nvgre_encap_conf.select_vlan)
6365 action_nvgre_encap_data->items[1].type =
6366 RTE_FLOW_ITEM_TYPE_VOID;
6367 memcpy(action_nvgre_encap_data->item_nvgre.tni, nvgre_encap_conf.tni,
6368 RTE_DIM(nvgre_encap_conf.tni));
6372 /** Parse NVGRE encap action. */
6374 parse_vc_action_nvgre_encap(struct context *ctx, const struct token *token,
6375 const char *str, unsigned int len,
6376 void *buf, unsigned int size)
6378 struct buffer *out = buf;
6379 struct rte_flow_action *action;
6380 struct action_nvgre_encap_data *action_nvgre_encap_data;
6383 ret = parse_vc(ctx, token, str, len, buf, size);
6386 /* Nothing else to do if there is no buffer. */
6389 if (!out->args.vc.actions_n)
6391 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6392 /* Point to selected object. */
6393 ctx->object = out->args.vc.data;
6394 ctx->objmask = NULL;
6395 action_nvgre_encap_data = ctx->object;
6396 parse_setup_nvgre_encap_data(action_nvgre_encap_data);
6397 action->conf = &action_nvgre_encap_data->conf;
6401 /** Parse l2 encap action. */
6403 parse_vc_action_l2_encap(struct context *ctx, const struct token *token,
6404 const char *str, unsigned int len,
6405 void *buf, unsigned int size)
6407 struct buffer *out = buf;
6408 struct rte_flow_action *action;
6409 struct action_raw_encap_data *action_encap_data;
6410 struct rte_flow_item_eth eth = { .type = 0, };
6411 struct rte_flow_item_vlan vlan = {
6412 .tci = mplsoudp_encap_conf.vlan_tci,
6418 ret = parse_vc(ctx, token, str, len, buf, size);
6421 /* Nothing else to do if there is no buffer. */
6424 if (!out->args.vc.actions_n)
6426 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6427 /* Point to selected object. */
6428 ctx->object = out->args.vc.data;
6429 ctx->objmask = NULL;
6430 /* Copy the headers to the buffer. */
6431 action_encap_data = ctx->object;
6432 *action_encap_data = (struct action_raw_encap_data) {
6433 .conf = (struct rte_flow_action_raw_encap){
6434 .data = action_encap_data->data,
6438 header = action_encap_data->data;
6439 if (l2_encap_conf.select_vlan)
6440 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
6441 else if (l2_encap_conf.select_ipv4)
6442 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6444 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6445 memcpy(eth.dst.addr_bytes,
6446 l2_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
6447 memcpy(eth.src.addr_bytes,
6448 l2_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
6449 memcpy(header, ð, sizeof(eth));
6450 header += sizeof(eth);
6451 if (l2_encap_conf.select_vlan) {
6452 if (l2_encap_conf.select_ipv4)
6453 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6455 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6456 memcpy(header, &vlan, sizeof(vlan));
6457 header += sizeof(vlan);
6459 action_encap_data->conf.size = header -
6460 action_encap_data->data;
6461 action->conf = &action_encap_data->conf;
6465 /** Parse l2 decap action. */
6467 parse_vc_action_l2_decap(struct context *ctx, const struct token *token,
6468 const char *str, unsigned int len,
6469 void *buf, unsigned int size)
6471 struct buffer *out = buf;
6472 struct rte_flow_action *action;
6473 struct action_raw_decap_data *action_decap_data;
6474 struct rte_flow_item_eth eth = { .type = 0, };
6475 struct rte_flow_item_vlan vlan = {
6476 .tci = mplsoudp_encap_conf.vlan_tci,
6482 ret = parse_vc(ctx, token, str, len, buf, size);
6485 /* Nothing else to do if there is no buffer. */
6488 if (!out->args.vc.actions_n)
6490 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6491 /* Point to selected object. */
6492 ctx->object = out->args.vc.data;
6493 ctx->objmask = NULL;
6494 /* Copy the headers to the buffer. */
6495 action_decap_data = ctx->object;
6496 *action_decap_data = (struct action_raw_decap_data) {
6497 .conf = (struct rte_flow_action_raw_decap){
6498 .data = action_decap_data->data,
6502 header = action_decap_data->data;
6503 if (l2_decap_conf.select_vlan)
6504 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
6505 memcpy(header, ð, sizeof(eth));
6506 header += sizeof(eth);
6507 if (l2_decap_conf.select_vlan) {
6508 memcpy(header, &vlan, sizeof(vlan));
6509 header += sizeof(vlan);
6511 action_decap_data->conf.size = header -
6512 action_decap_data->data;
6513 action->conf = &action_decap_data->conf;
6517 #define ETHER_TYPE_MPLS_UNICAST 0x8847
6519 /** Parse MPLSOGRE encap action. */
6521 parse_vc_action_mplsogre_encap(struct context *ctx, const struct token *token,
6522 const char *str, unsigned int len,
6523 void *buf, unsigned int size)
6525 struct buffer *out = buf;
6526 struct rte_flow_action *action;
6527 struct action_raw_encap_data *action_encap_data;
6528 struct rte_flow_item_eth eth = { .type = 0, };
6529 struct rte_flow_item_vlan vlan = {
6530 .tci = mplsogre_encap_conf.vlan_tci,
6533 struct rte_flow_item_ipv4 ipv4 = {
6535 .src_addr = mplsogre_encap_conf.ipv4_src,
6536 .dst_addr = mplsogre_encap_conf.ipv4_dst,
6537 .next_proto_id = IPPROTO_GRE,
6538 .version_ihl = RTE_IPV4_VHL_DEF,
6539 .time_to_live = IPDEFTTL,
6542 struct rte_flow_item_ipv6 ipv6 = {
6544 .proto = IPPROTO_GRE,
6545 .hop_limits = IPDEFTTL,
6548 struct rte_flow_item_gre gre = {
6549 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
6551 struct rte_flow_item_mpls mpls = {
6557 ret = parse_vc(ctx, token, str, len, buf, size);
6560 /* Nothing else to do if there is no buffer. */
6563 if (!out->args.vc.actions_n)
6565 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6566 /* Point to selected object. */
6567 ctx->object = out->args.vc.data;
6568 ctx->objmask = NULL;
6569 /* Copy the headers to the buffer. */
6570 action_encap_data = ctx->object;
6571 *action_encap_data = (struct action_raw_encap_data) {
6572 .conf = (struct rte_flow_action_raw_encap){
6573 .data = action_encap_data->data,
6578 header = action_encap_data->data;
6579 if (mplsogre_encap_conf.select_vlan)
6580 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
6581 else if (mplsogre_encap_conf.select_ipv4)
6582 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6584 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6585 memcpy(eth.dst.addr_bytes,
6586 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
6587 memcpy(eth.src.addr_bytes,
6588 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
6589 memcpy(header, ð, sizeof(eth));
6590 header += sizeof(eth);
6591 if (mplsogre_encap_conf.select_vlan) {
6592 if (mplsogre_encap_conf.select_ipv4)
6593 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6595 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6596 memcpy(header, &vlan, sizeof(vlan));
6597 header += sizeof(vlan);
6599 if (mplsogre_encap_conf.select_ipv4) {
6600 memcpy(header, &ipv4, sizeof(ipv4));
6601 header += sizeof(ipv4);
6603 memcpy(&ipv6.hdr.src_addr,
6604 &mplsogre_encap_conf.ipv6_src,
6605 sizeof(mplsogre_encap_conf.ipv6_src));
6606 memcpy(&ipv6.hdr.dst_addr,
6607 &mplsogre_encap_conf.ipv6_dst,
6608 sizeof(mplsogre_encap_conf.ipv6_dst));
6609 memcpy(header, &ipv6, sizeof(ipv6));
6610 header += sizeof(ipv6);
6612 memcpy(header, &gre, sizeof(gre));
6613 header += sizeof(gre);
6614 memcpy(mpls.label_tc_s, mplsogre_encap_conf.label,
6615 RTE_DIM(mplsogre_encap_conf.label));
6616 mpls.label_tc_s[2] |= 0x1;
6617 memcpy(header, &mpls, sizeof(mpls));
6618 header += sizeof(mpls);
6619 action_encap_data->conf.size = header -
6620 action_encap_data->data;
6621 action->conf = &action_encap_data->conf;
6625 /** Parse MPLSOGRE decap action. */
6627 parse_vc_action_mplsogre_decap(struct context *ctx, const struct token *token,
6628 const char *str, unsigned int len,
6629 void *buf, unsigned int size)
6631 struct buffer *out = buf;
6632 struct rte_flow_action *action;
6633 struct action_raw_decap_data *action_decap_data;
6634 struct rte_flow_item_eth eth = { .type = 0, };
6635 struct rte_flow_item_vlan vlan = {.tci = 0};
6636 struct rte_flow_item_ipv4 ipv4 = {
6638 .next_proto_id = IPPROTO_GRE,
6641 struct rte_flow_item_ipv6 ipv6 = {
6643 .proto = IPPROTO_GRE,
6646 struct rte_flow_item_gre gre = {
6647 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
6649 struct rte_flow_item_mpls mpls;
6653 ret = parse_vc(ctx, token, str, len, buf, size);
6656 /* Nothing else to do if there is no buffer. */
6659 if (!out->args.vc.actions_n)
6661 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6662 /* Point to selected object. */
6663 ctx->object = out->args.vc.data;
6664 ctx->objmask = NULL;
6665 /* Copy the headers to the buffer. */
6666 action_decap_data = ctx->object;
6667 *action_decap_data = (struct action_raw_decap_data) {
6668 .conf = (struct rte_flow_action_raw_decap){
6669 .data = action_decap_data->data,
6673 header = action_decap_data->data;
6674 if (mplsogre_decap_conf.select_vlan)
6675 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
6676 else if (mplsogre_encap_conf.select_ipv4)
6677 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6679 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6680 memcpy(eth.dst.addr_bytes,
6681 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
6682 memcpy(eth.src.addr_bytes,
6683 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
6684 memcpy(header, ð, sizeof(eth));
6685 header += sizeof(eth);
6686 if (mplsogre_encap_conf.select_vlan) {
6687 if (mplsogre_encap_conf.select_ipv4)
6688 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6690 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6691 memcpy(header, &vlan, sizeof(vlan));
6692 header += sizeof(vlan);
6694 if (mplsogre_encap_conf.select_ipv4) {
6695 memcpy(header, &ipv4, sizeof(ipv4));
6696 header += sizeof(ipv4);
6698 memcpy(header, &ipv6, sizeof(ipv6));
6699 header += sizeof(ipv6);
6701 memcpy(header, &gre, sizeof(gre));
6702 header += sizeof(gre);
6703 memset(&mpls, 0, sizeof(mpls));
6704 memcpy(header, &mpls, sizeof(mpls));
6705 header += sizeof(mpls);
6706 action_decap_data->conf.size = header -
6707 action_decap_data->data;
6708 action->conf = &action_decap_data->conf;
6712 /** Parse MPLSOUDP encap action. */
6714 parse_vc_action_mplsoudp_encap(struct context *ctx, const struct token *token,
6715 const char *str, unsigned int len,
6716 void *buf, unsigned int size)
6718 struct buffer *out = buf;
6719 struct rte_flow_action *action;
6720 struct action_raw_encap_data *action_encap_data;
6721 struct rte_flow_item_eth eth = { .type = 0, };
6722 struct rte_flow_item_vlan vlan = {
6723 .tci = mplsoudp_encap_conf.vlan_tci,
6726 struct rte_flow_item_ipv4 ipv4 = {
6728 .src_addr = mplsoudp_encap_conf.ipv4_src,
6729 .dst_addr = mplsoudp_encap_conf.ipv4_dst,
6730 .next_proto_id = IPPROTO_UDP,
6731 .version_ihl = RTE_IPV4_VHL_DEF,
6732 .time_to_live = IPDEFTTL,
6735 struct rte_flow_item_ipv6 ipv6 = {
6737 .proto = IPPROTO_UDP,
6738 .hop_limits = IPDEFTTL,
6741 struct rte_flow_item_udp udp = {
6743 .src_port = mplsoudp_encap_conf.udp_src,
6744 .dst_port = mplsoudp_encap_conf.udp_dst,
6747 struct rte_flow_item_mpls mpls;
6751 ret = parse_vc(ctx, token, str, len, buf, size);
6754 /* Nothing else to do if there is no buffer. */
6757 if (!out->args.vc.actions_n)
6759 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6760 /* Point to selected object. */
6761 ctx->object = out->args.vc.data;
6762 ctx->objmask = NULL;
6763 /* Copy the headers to the buffer. */
6764 action_encap_data = ctx->object;
6765 *action_encap_data = (struct action_raw_encap_data) {
6766 .conf = (struct rte_flow_action_raw_encap){
6767 .data = action_encap_data->data,
6772 header = action_encap_data->data;
6773 if (mplsoudp_encap_conf.select_vlan)
6774 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
6775 else if (mplsoudp_encap_conf.select_ipv4)
6776 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6778 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6779 memcpy(eth.dst.addr_bytes,
6780 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
6781 memcpy(eth.src.addr_bytes,
6782 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
6783 memcpy(header, ð, sizeof(eth));
6784 header += sizeof(eth);
6785 if (mplsoudp_encap_conf.select_vlan) {
6786 if (mplsoudp_encap_conf.select_ipv4)
6787 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6789 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6790 memcpy(header, &vlan, sizeof(vlan));
6791 header += sizeof(vlan);
6793 if (mplsoudp_encap_conf.select_ipv4) {
6794 memcpy(header, &ipv4, sizeof(ipv4));
6795 header += sizeof(ipv4);
6797 memcpy(&ipv6.hdr.src_addr,
6798 &mplsoudp_encap_conf.ipv6_src,
6799 sizeof(mplsoudp_encap_conf.ipv6_src));
6800 memcpy(&ipv6.hdr.dst_addr,
6801 &mplsoudp_encap_conf.ipv6_dst,
6802 sizeof(mplsoudp_encap_conf.ipv6_dst));
6803 memcpy(header, &ipv6, sizeof(ipv6));
6804 header += sizeof(ipv6);
6806 memcpy(header, &udp, sizeof(udp));
6807 header += sizeof(udp);
6808 memcpy(mpls.label_tc_s, mplsoudp_encap_conf.label,
6809 RTE_DIM(mplsoudp_encap_conf.label));
6810 mpls.label_tc_s[2] |= 0x1;
6811 memcpy(header, &mpls, sizeof(mpls));
6812 header += sizeof(mpls);
6813 action_encap_data->conf.size = header -
6814 action_encap_data->data;
6815 action->conf = &action_encap_data->conf;
6819 /** Parse MPLSOUDP decap action. */
6821 parse_vc_action_mplsoudp_decap(struct context *ctx, const struct token *token,
6822 const char *str, unsigned int len,
6823 void *buf, unsigned int size)
6825 struct buffer *out = buf;
6826 struct rte_flow_action *action;
6827 struct action_raw_decap_data *action_decap_data;
6828 struct rte_flow_item_eth eth = { .type = 0, };
6829 struct rte_flow_item_vlan vlan = {.tci = 0};
6830 struct rte_flow_item_ipv4 ipv4 = {
6832 .next_proto_id = IPPROTO_UDP,
6835 struct rte_flow_item_ipv6 ipv6 = {
6837 .proto = IPPROTO_UDP,
6840 struct rte_flow_item_udp udp = {
6842 .dst_port = rte_cpu_to_be_16(6635),
6845 struct rte_flow_item_mpls mpls;
6849 ret = parse_vc(ctx, token, str, len, buf, size);
6852 /* Nothing else to do if there is no buffer. */
6855 if (!out->args.vc.actions_n)
6857 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6858 /* Point to selected object. */
6859 ctx->object = out->args.vc.data;
6860 ctx->objmask = NULL;
6861 /* Copy the headers to the buffer. */
6862 action_decap_data = ctx->object;
6863 *action_decap_data = (struct action_raw_decap_data) {
6864 .conf = (struct rte_flow_action_raw_decap){
6865 .data = action_decap_data->data,
6869 header = action_decap_data->data;
6870 if (mplsoudp_decap_conf.select_vlan)
6871 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
6872 else if (mplsoudp_encap_conf.select_ipv4)
6873 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6875 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6876 memcpy(eth.dst.addr_bytes,
6877 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
6878 memcpy(eth.src.addr_bytes,
6879 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
6880 memcpy(header, ð, sizeof(eth));
6881 header += sizeof(eth);
6882 if (mplsoudp_encap_conf.select_vlan) {
6883 if (mplsoudp_encap_conf.select_ipv4)
6884 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6886 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6887 memcpy(header, &vlan, sizeof(vlan));
6888 header += sizeof(vlan);
6890 if (mplsoudp_encap_conf.select_ipv4) {
6891 memcpy(header, &ipv4, sizeof(ipv4));
6892 header += sizeof(ipv4);
6894 memcpy(header, &ipv6, sizeof(ipv6));
6895 header += sizeof(ipv6);
6897 memcpy(header, &udp, sizeof(udp));
6898 header += sizeof(udp);
6899 memset(&mpls, 0, sizeof(mpls));
6900 memcpy(header, &mpls, sizeof(mpls));
6901 header += sizeof(mpls);
6902 action_decap_data->conf.size = header -
6903 action_decap_data->data;
6904 action->conf = &action_decap_data->conf;
6909 parse_vc_action_raw_decap_index(struct context *ctx, const struct token *token,
6910 const char *str, unsigned int len, void *buf,
6913 struct action_raw_decap_data *action_raw_decap_data;
6914 struct rte_flow_action *action;
6915 const struct arg *arg;
6916 struct buffer *out = buf;
6920 RTE_SET_USED(token);
6923 arg = ARGS_ENTRY_ARB_BOUNDED
6924 (offsetof(struct action_raw_decap_data, idx),
6925 sizeof(((struct action_raw_decap_data *)0)->idx),
6926 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
6927 if (push_args(ctx, arg))
6929 ret = parse_int(ctx, token, str, len, NULL, 0);
6936 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6937 action_raw_decap_data = ctx->object;
6938 idx = action_raw_decap_data->idx;
6939 action_raw_decap_data->conf.data = raw_decap_confs[idx].data;
6940 action_raw_decap_data->conf.size = raw_decap_confs[idx].size;
6941 action->conf = &action_raw_decap_data->conf;
6947 parse_vc_action_raw_encap_index(struct context *ctx, const struct token *token,
6948 const char *str, unsigned int len, void *buf,
6951 struct action_raw_encap_data *action_raw_encap_data;
6952 struct rte_flow_action *action;
6953 const struct arg *arg;
6954 struct buffer *out = buf;
6958 RTE_SET_USED(token);
6961 if (ctx->curr != ACTION_RAW_ENCAP_INDEX_VALUE)
6963 arg = ARGS_ENTRY_ARB_BOUNDED
6964 (offsetof(struct action_raw_encap_data, idx),
6965 sizeof(((struct action_raw_encap_data *)0)->idx),
6966 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
6967 if (push_args(ctx, arg))
6969 ret = parse_int(ctx, token, str, len, NULL, 0);
6976 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6977 action_raw_encap_data = ctx->object;
6978 idx = action_raw_encap_data->idx;
6979 action_raw_encap_data->conf.data = raw_encap_confs[idx].data;
6980 action_raw_encap_data->conf.size = raw_encap_confs[idx].size;
6981 action_raw_encap_data->conf.preserve = NULL;
6982 action->conf = &action_raw_encap_data->conf;
6987 parse_vc_action_raw_encap(struct context *ctx, const struct token *token,
6988 const char *str, unsigned int len, void *buf,
6991 struct buffer *out = buf;
6992 struct rte_flow_action *action;
6993 struct action_raw_encap_data *action_raw_encap_data = NULL;
6996 ret = parse_vc(ctx, token, str, len, buf, size);
6999 /* Nothing else to do if there is no buffer. */
7002 if (!out->args.vc.actions_n)
7004 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
7005 /* Point to selected object. */
7006 ctx->object = out->args.vc.data;
7007 ctx->objmask = NULL;
7008 /* Copy the headers to the buffer. */
7009 action_raw_encap_data = ctx->object;
7010 action_raw_encap_data->conf.data = raw_encap_confs[0].data;
7011 action_raw_encap_data->conf.preserve = NULL;
7012 action_raw_encap_data->conf.size = raw_encap_confs[0].size;
7013 action->conf = &action_raw_encap_data->conf;
7018 parse_vc_action_raw_decap(struct context *ctx, const struct token *token,
7019 const char *str, unsigned int len, void *buf,
7022 struct buffer *out = buf;
7023 struct rte_flow_action *action;
7024 struct action_raw_decap_data *action_raw_decap_data = NULL;
7027 ret = parse_vc(ctx, token, str, len, buf, size);
7030 /* Nothing else to do if there is no buffer. */
7033 if (!out->args.vc.actions_n)
7035 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
7036 /* Point to selected object. */
7037 ctx->object = out->args.vc.data;
7038 ctx->objmask = NULL;
7039 /* Copy the headers to the buffer. */
7040 action_raw_decap_data = ctx->object;
7041 action_raw_decap_data->conf.data = raw_decap_confs[0].data;
7042 action_raw_decap_data->conf.size = raw_decap_confs[0].size;
7043 action->conf = &action_raw_decap_data->conf;
7048 parse_vc_action_set_meta(struct context *ctx, const struct token *token,
7049 const char *str, unsigned int len, void *buf,
7054 ret = parse_vc(ctx, token, str, len, buf, size);
7057 ret = rte_flow_dynf_metadata_register();
7064 parse_vc_action_sample(struct context *ctx, const struct token *token,
7065 const char *str, unsigned int len, void *buf,
7068 struct buffer *out = buf;
7069 struct rte_flow_action *action;
7070 struct action_sample_data *action_sample_data = NULL;
7071 static struct rte_flow_action end_action = {
7072 RTE_FLOW_ACTION_TYPE_END, 0
7076 ret = parse_vc(ctx, token, str, len, buf, size);
7079 /* Nothing else to do if there is no buffer. */
7082 if (!out->args.vc.actions_n)
7084 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
7085 /* Point to selected object. */
7086 ctx->object = out->args.vc.data;
7087 ctx->objmask = NULL;
7088 /* Copy the headers to the buffer. */
7089 action_sample_data = ctx->object;
7090 action_sample_data->conf.actions = &end_action;
7091 action->conf = &action_sample_data->conf;
7096 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
7097 const char *str, unsigned int len, void *buf,
7100 struct action_sample_data *action_sample_data;
7101 struct rte_flow_action *action;
7102 const struct arg *arg;
7103 struct buffer *out = buf;
7107 RTE_SET_USED(token);
7110 if (ctx->curr != ACTION_SAMPLE_INDEX_VALUE)
7112 arg = ARGS_ENTRY_ARB_BOUNDED
7113 (offsetof(struct action_sample_data, idx),
7114 sizeof(((struct action_sample_data *)0)->idx),
7115 0, RAW_SAMPLE_CONFS_MAX_NUM - 1);
7116 if (push_args(ctx, arg))
7118 ret = parse_int(ctx, token, str, len, NULL, 0);
7125 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
7126 action_sample_data = ctx->object;
7127 idx = action_sample_data->idx;
7128 action_sample_data->conf.actions = raw_sample_confs[idx].data;
7129 action->conf = &action_sample_data->conf;
7133 /** Parse operation for modify_field command. */
7135 parse_vc_modify_field_op(struct context *ctx, const struct token *token,
7136 const char *str, unsigned int len, void *buf,
7139 struct rte_flow_action_modify_field *action_modify_field;
7145 if (ctx->curr != ACTION_MODIFY_FIELD_OP_VALUE)
7147 for (i = 0; modify_field_ops[i]; ++i)
7148 if (!strcmp_partial(modify_field_ops[i], str, len))
7150 if (!modify_field_ops[i])
7154 action_modify_field = ctx->object;
7155 action_modify_field->operation = (enum rte_flow_modify_op)i;
7159 /** Parse id for modify_field command. */
7161 parse_vc_modify_field_id(struct context *ctx, const struct token *token,
7162 const char *str, unsigned int len, void *buf,
7165 struct rte_flow_action_modify_field *action_modify_field;
7171 if (ctx->curr != ACTION_MODIFY_FIELD_DST_TYPE_VALUE &&
7172 ctx->curr != ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)
7174 for (i = 0; modify_field_ids[i]; ++i)
7175 if (!strcmp_partial(modify_field_ids[i], str, len))
7177 if (!modify_field_ids[i])
7181 action_modify_field = ctx->object;
7182 if (ctx->curr == ACTION_MODIFY_FIELD_DST_TYPE_VALUE)
7183 action_modify_field->dst.field = (enum rte_flow_field_id)i;
7185 action_modify_field->src.field = (enum rte_flow_field_id)i;
7189 /** Parse the conntrack update, not a rte_flow_action. */
7191 parse_vc_action_conntrack_update(struct context *ctx, const struct token *token,
7192 const char *str, unsigned int len, void *buf,
7195 struct buffer *out = buf;
7196 struct rte_flow_modify_conntrack *ct_modify = NULL;
7199 if (ctx->curr != ACTION_CONNTRACK_UPDATE_CTX &&
7200 ctx->curr != ACTION_CONNTRACK_UPDATE_DIR)
7202 /* Token name must match. */
7203 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7205 /* Nothing else to do if there is no buffer. */
7208 ct_modify = (struct rte_flow_modify_conntrack *)out->args.vc.data;
7209 if (ctx->curr == ACTION_CONNTRACK_UPDATE_DIR) {
7210 ct_modify->new_ct.is_original_dir =
7211 conntrack_context.is_original_dir;
7212 ct_modify->direction = 1;
7216 old_dir = ct_modify->new_ct.is_original_dir;
7217 memcpy(&ct_modify->new_ct, &conntrack_context,
7218 sizeof(conntrack_context));
7219 ct_modify->new_ct.is_original_dir = old_dir;
7220 ct_modify->state = 1;
7225 /** Parse tokens for destroy command. */
7227 parse_destroy(struct context *ctx, const struct token *token,
7228 const char *str, unsigned int len,
7229 void *buf, unsigned int size)
7231 struct buffer *out = buf;
7233 /* Token name must match. */
7234 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7236 /* Nothing else to do if there is no buffer. */
7239 if (!out->command) {
7240 if (ctx->curr != DESTROY)
7242 if (sizeof(*out) > size)
7244 out->command = ctx->curr;
7247 ctx->objmask = NULL;
7248 out->args.destroy.rule =
7249 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7253 if (((uint8_t *)(out->args.destroy.rule + out->args.destroy.rule_n) +
7254 sizeof(*out->args.destroy.rule)) > (uint8_t *)out + size)
7257 ctx->object = out->args.destroy.rule + out->args.destroy.rule_n++;
7258 ctx->objmask = NULL;
7262 /** Parse tokens for flush command. */
7264 parse_flush(struct context *ctx, const struct token *token,
7265 const char *str, unsigned int len,
7266 void *buf, unsigned int size)
7268 struct buffer *out = buf;
7270 /* Token name must match. */
7271 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7273 /* Nothing else to do if there is no buffer. */
7276 if (!out->command) {
7277 if (ctx->curr != FLUSH)
7279 if (sizeof(*out) > size)
7281 out->command = ctx->curr;
7284 ctx->objmask = NULL;
7289 /** Parse tokens for dump command. */
7291 parse_dump(struct context *ctx, const struct token *token,
7292 const char *str, unsigned int len,
7293 void *buf, unsigned int size)
7295 struct buffer *out = buf;
7297 /* Token name must match. */
7298 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7300 /* Nothing else to do if there is no buffer. */
7303 if (!out->command) {
7304 if (ctx->curr != DUMP)
7306 if (sizeof(*out) > size)
7308 out->command = ctx->curr;
7311 ctx->objmask = NULL;
7314 switch (ctx->curr) {
7317 out->args.dump.mode = (ctx->curr == DUMP_ALL) ? true : false;
7318 out->command = ctx->curr;
7321 ctx->objmask = NULL;
7328 /** Parse tokens for query command. */
7330 parse_query(struct context *ctx, const struct token *token,
7331 const char *str, unsigned int len,
7332 void *buf, unsigned int size)
7334 struct buffer *out = buf;
7336 /* Token name must match. */
7337 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7339 /* Nothing else to do if there is no buffer. */
7342 if (!out->command) {
7343 if (ctx->curr != QUERY)
7345 if (sizeof(*out) > size)
7347 out->command = ctx->curr;
7350 ctx->objmask = NULL;
7355 /** Parse action names. */
7357 parse_action(struct context *ctx, const struct token *token,
7358 const char *str, unsigned int len,
7359 void *buf, unsigned int size)
7361 struct buffer *out = buf;
7362 const struct arg *arg = pop_args(ctx);
7366 /* Argument is expected. */
7369 /* Parse action name. */
7370 for (i = 0; next_action[i]; ++i) {
7371 const struct parse_action_priv *priv;
7373 token = &token_list[next_action[i]];
7374 if (strcmp_partial(token->name, str, len))
7380 memcpy((uint8_t *)ctx->object + arg->offset,
7386 push_args(ctx, arg);
7390 /** Parse tokens for list command. */
7392 parse_list(struct context *ctx, const struct token *token,
7393 const char *str, unsigned int len,
7394 void *buf, unsigned int size)
7396 struct buffer *out = buf;
7398 /* Token name must match. */
7399 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7401 /* Nothing else to do if there is no buffer. */
7404 if (!out->command) {
7405 if (ctx->curr != LIST)
7407 if (sizeof(*out) > size)
7409 out->command = ctx->curr;
7412 ctx->objmask = NULL;
7413 out->args.list.group =
7414 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7418 if (((uint8_t *)(out->args.list.group + out->args.list.group_n) +
7419 sizeof(*out->args.list.group)) > (uint8_t *)out + size)
7422 ctx->object = out->args.list.group + out->args.list.group_n++;
7423 ctx->objmask = NULL;
7427 /** Parse tokens for list all aged flows command. */
7429 parse_aged(struct context *ctx, const struct token *token,
7430 const char *str, unsigned int len,
7431 void *buf, unsigned int size)
7433 struct buffer *out = buf;
7435 /* Token name must match. */
7436 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7438 /* Nothing else to do if there is no buffer. */
7441 if (!out->command) {
7442 if (ctx->curr != AGED)
7444 if (sizeof(*out) > size)
7446 out->command = ctx->curr;
7449 ctx->objmask = NULL;
7451 if (ctx->curr == AGED_DESTROY)
7452 out->args.aged.destroy = 1;
7456 /** Parse tokens for isolate command. */
7458 parse_isolate(struct context *ctx, const struct token *token,
7459 const char *str, unsigned int len,
7460 void *buf, unsigned int size)
7462 struct buffer *out = buf;
7464 /* Token name must match. */
7465 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7467 /* Nothing else to do if there is no buffer. */
7470 if (!out->command) {
7471 if (ctx->curr != ISOLATE)
7473 if (sizeof(*out) > size)
7475 out->command = ctx->curr;
7478 ctx->objmask = NULL;
7484 parse_flex(struct context *ctx, const struct token *token,
7485 const char *str, unsigned int len,
7486 void *buf, unsigned int size)
7488 struct buffer *out = buf;
7490 /* Token name must match. */
7491 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7493 /* Nothing else to do if there is no buffer. */
7496 if (out->command == ZERO) {
7497 if (ctx->curr != FLEX)
7499 if (sizeof(*out) > size)
7501 out->command = ctx->curr;
7504 ctx->objmask = NULL;
7506 switch (ctx->curr) {
7509 case FLEX_ITEM_INIT:
7510 case FLEX_ITEM_CREATE:
7511 case FLEX_ITEM_DESTROY:
7512 out->command = ctx->curr;
7521 parse_tunnel(struct context *ctx, const struct token *token,
7522 const char *str, unsigned int len,
7523 void *buf, unsigned int size)
7525 struct buffer *out = buf;
7527 /* Token name must match. */
7528 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7530 /* Nothing else to do if there is no buffer. */
7533 if (!out->command) {
7534 if (ctx->curr != TUNNEL)
7536 if (sizeof(*out) > size)
7538 out->command = ctx->curr;
7541 ctx->objmask = NULL;
7543 switch (ctx->curr) {
7547 case TUNNEL_DESTROY:
7549 out->command = ctx->curr;
7551 case TUNNEL_CREATE_TYPE:
7552 case TUNNEL_DESTROY_ID:
7553 ctx->object = &out->args.vc.tunnel_ops;
7562 * Parse signed/unsigned integers 8 to 64-bit long.
7564 * Last argument (ctx->args) is retrieved to determine integer type and
7568 parse_int(struct context *ctx, const struct token *token,
7569 const char *str, unsigned int len,
7570 void *buf, unsigned int size)
7572 const struct arg *arg = pop_args(ctx);
7577 /* Argument is expected. */
7582 (uintmax_t)strtoimax(str, &end, 0) :
7583 strtoumax(str, &end, 0);
7584 if (errno || (size_t)(end - str) != len)
7587 ((arg->sign && ((intmax_t)u < (intmax_t)arg->min ||
7588 (intmax_t)u > (intmax_t)arg->max)) ||
7589 (!arg->sign && (u < arg->min || u > arg->max))))
7594 if (!arg_entry_bf_fill(ctx->object, u, arg) ||
7595 !arg_entry_bf_fill(ctx->objmask, -1, arg))
7599 buf = (uint8_t *)ctx->object + arg->offset;
7601 if (u > RTE_LEN2MASK(size * CHAR_BIT, uint64_t))
7605 case sizeof(uint8_t):
7606 *(uint8_t *)buf = u;
7608 case sizeof(uint16_t):
7609 *(uint16_t *)buf = arg->hton ? rte_cpu_to_be_16(u) : u;
7611 case sizeof(uint8_t [3]):
7612 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
7614 ((uint8_t *)buf)[0] = u;
7615 ((uint8_t *)buf)[1] = u >> 8;
7616 ((uint8_t *)buf)[2] = u >> 16;
7620 ((uint8_t *)buf)[0] = u >> 16;
7621 ((uint8_t *)buf)[1] = u >> 8;
7622 ((uint8_t *)buf)[2] = u;
7624 case sizeof(uint32_t):
7625 *(uint32_t *)buf = arg->hton ? rte_cpu_to_be_32(u) : u;
7627 case sizeof(uint64_t):
7628 *(uint64_t *)buf = arg->hton ? rte_cpu_to_be_64(u) : u;
7633 if (ctx->objmask && buf != (uint8_t *)ctx->objmask + arg->offset) {
7635 buf = (uint8_t *)ctx->objmask + arg->offset;
7640 push_args(ctx, arg);
7647 * Three arguments (ctx->args) are retrieved from the stack to store data,
7648 * its actual length and address (in that order).
7651 parse_string(struct context *ctx, const struct token *token,
7652 const char *str, unsigned int len,
7653 void *buf, unsigned int size)
7655 const struct arg *arg_data = pop_args(ctx);
7656 const struct arg *arg_len = pop_args(ctx);
7657 const struct arg *arg_addr = pop_args(ctx);
7658 char tmp[16]; /* Ought to be enough. */
7661 /* Arguments are expected. */
7665 push_args(ctx, arg_data);
7669 push_args(ctx, arg_len);
7670 push_args(ctx, arg_data);
7673 size = arg_data->size;
7674 /* Bit-mask fill is not supported. */
7675 if (arg_data->mask || size < len)
7679 /* Let parse_int() fill length information first. */
7680 ret = snprintf(tmp, sizeof(tmp), "%u", len);
7683 push_args(ctx, arg_len);
7684 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
7689 buf = (uint8_t *)ctx->object + arg_data->offset;
7690 /* Output buffer is not necessarily NUL-terminated. */
7691 memcpy(buf, str, len);
7692 memset((uint8_t *)buf + len, 0x00, size - len);
7694 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
7695 /* Save address if requested. */
7696 if (arg_addr->size) {
7697 memcpy((uint8_t *)ctx->object + arg_addr->offset,
7699 (uint8_t *)ctx->object + arg_data->offset
7703 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
7705 (uint8_t *)ctx->objmask + arg_data->offset
7711 push_args(ctx, arg_addr);
7712 push_args(ctx, arg_len);
7713 push_args(ctx, arg_data);
7718 parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
7720 const uint8_t *head = dst;
7723 /* Check input parameters */
7724 if ((src == NULL) ||
7732 /* Convert chars to bytes */
7734 char tmp[3], *end = tmp;
7735 uint32_t read_lim = left & 1 ? 1 : 2;
7737 snprintf(tmp, read_lim + 1, "%s", src);
7738 *dst = strtoul(tmp, &end, 16);
7741 *size = (uint32_t)(dst - head);
7749 *size = (uint32_t)(dst - head);
7754 parse_hex(struct context *ctx, const struct token *token,
7755 const char *str, unsigned int len,
7756 void *buf, unsigned int size)
7758 const struct arg *arg_data = pop_args(ctx);
7759 const struct arg *arg_len = pop_args(ctx);
7760 const struct arg *arg_addr = pop_args(ctx);
7761 char tmp[16]; /* Ought to be enough. */
7763 unsigned int hexlen = len;
7764 unsigned int length = 256;
7765 uint8_t hex_tmp[length];
7767 /* Arguments are expected. */
7771 push_args(ctx, arg_data);
7775 push_args(ctx, arg_len);
7776 push_args(ctx, arg_data);
7779 size = arg_data->size;
7780 /* Bit-mask fill is not supported. */
7786 /* translate bytes string to array. */
7787 if (str[0] == '0' && ((str[1] == 'x') ||
7792 if (hexlen > length)
7794 ret = parse_hex_string(str, hex_tmp, &hexlen);
7797 /* Check the converted binary fits into data buffer. */
7800 /* Let parse_int() fill length information first. */
7801 ret = snprintf(tmp, sizeof(tmp), "%u", hexlen);
7804 /* Save length if requested. */
7805 if (arg_len->size) {
7806 push_args(ctx, arg_len);
7807 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
7813 buf = (uint8_t *)ctx->object + arg_data->offset;
7814 /* Output buffer is not necessarily NUL-terminated. */
7815 memcpy(buf, hex_tmp, hexlen);
7816 memset((uint8_t *)buf + hexlen, 0x00, size - hexlen);
7818 memset((uint8_t *)ctx->objmask + arg_data->offset,
7820 /* Save address if requested. */
7821 if (arg_addr->size) {
7822 memcpy((uint8_t *)ctx->object + arg_addr->offset,
7824 (uint8_t *)ctx->object + arg_data->offset
7828 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
7830 (uint8_t *)ctx->objmask + arg_data->offset
7836 push_args(ctx, arg_addr);
7837 push_args(ctx, arg_len);
7838 push_args(ctx, arg_data);
7844 * Parse a zero-ended string.
7847 parse_string0(struct context *ctx, const struct token *token __rte_unused,
7848 const char *str, unsigned int len,
7849 void *buf, unsigned int size)
7851 const struct arg *arg_data = pop_args(ctx);
7853 /* Arguments are expected. */
7856 size = arg_data->size;
7857 /* Bit-mask fill is not supported. */
7858 if (arg_data->mask || size < len + 1)
7862 buf = (uint8_t *)ctx->object + arg_data->offset;
7863 strncpy(buf, str, len);
7865 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
7868 push_args(ctx, arg_data);
7873 * Parse a MAC address.
7875 * Last argument (ctx->args) is retrieved to determine storage size and
7879 parse_mac_addr(struct context *ctx, const struct token *token,
7880 const char *str, unsigned int len,
7881 void *buf, unsigned int size)
7883 const struct arg *arg = pop_args(ctx);
7884 struct rte_ether_addr tmp;
7888 /* Argument is expected. */
7892 /* Bit-mask fill is not supported. */
7893 if (arg->mask || size != sizeof(tmp))
7895 /* Only network endian is supported. */
7898 ret = cmdline_parse_etheraddr(NULL, str, &tmp, size);
7899 if (ret < 0 || (unsigned int)ret != len)
7903 buf = (uint8_t *)ctx->object + arg->offset;
7904 memcpy(buf, &tmp, size);
7906 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
7909 push_args(ctx, arg);
7914 * Parse an IPv4 address.
7916 * Last argument (ctx->args) is retrieved to determine storage size and
7920 parse_ipv4_addr(struct context *ctx, const struct token *token,
7921 const char *str, unsigned int len,
7922 void *buf, unsigned int size)
7924 const struct arg *arg = pop_args(ctx);
7929 /* Argument is expected. */
7933 /* Bit-mask fill is not supported. */
7934 if (arg->mask || size != sizeof(tmp))
7936 /* Only network endian is supported. */
7939 memcpy(str2, str, len);
7941 ret = inet_pton(AF_INET, str2, &tmp);
7943 /* Attempt integer parsing. */
7944 push_args(ctx, arg);
7945 return parse_int(ctx, token, str, len, buf, size);
7949 buf = (uint8_t *)ctx->object + arg->offset;
7950 memcpy(buf, &tmp, size);
7952 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
7955 push_args(ctx, arg);
7960 * Parse an IPv6 address.
7962 * Last argument (ctx->args) is retrieved to determine storage size and
7966 parse_ipv6_addr(struct context *ctx, const struct token *token,
7967 const char *str, unsigned int len,
7968 void *buf, unsigned int size)
7970 const struct arg *arg = pop_args(ctx);
7972 struct in6_addr tmp;
7976 /* Argument is expected. */
7980 /* Bit-mask fill is not supported. */
7981 if (arg->mask || size != sizeof(tmp))
7983 /* Only network endian is supported. */
7986 memcpy(str2, str, len);
7988 ret = inet_pton(AF_INET6, str2, &tmp);
7993 buf = (uint8_t *)ctx->object + arg->offset;
7994 memcpy(buf, &tmp, size);
7996 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
7999 push_args(ctx, arg);
8003 /** Boolean values (even indices stand for false). */
8004 static const char *const boolean_name[] = {
8014 * Parse a boolean value.
8016 * Last argument (ctx->args) is retrieved to determine storage size and
8020 parse_boolean(struct context *ctx, const struct token *token,
8021 const char *str, unsigned int len,
8022 void *buf, unsigned int size)
8024 const struct arg *arg = pop_args(ctx);
8028 /* Argument is expected. */
8031 for (i = 0; boolean_name[i]; ++i)
8032 if (!strcmp_partial(boolean_name[i], str, len))
8034 /* Process token as integer. */
8035 if (boolean_name[i])
8036 str = i & 1 ? "1" : "0";
8037 push_args(ctx, arg);
8038 ret = parse_int(ctx, token, str, strlen(str), buf, size);
8039 return ret > 0 ? (int)len : ret;
8042 /** Parse port and update context. */
8044 parse_port(struct context *ctx, const struct token *token,
8045 const char *str, unsigned int len,
8046 void *buf, unsigned int size)
8048 struct buffer *out = &(struct buffer){ .port = 0 };
8056 ctx->objmask = NULL;
8057 size = sizeof(*out);
8059 ret = parse_int(ctx, token, str, len, out, size);
8061 ctx->port = out->port;
8068 parse_ia_id2ptr(struct context *ctx, const struct token *token,
8069 const char *str, unsigned int len,
8070 void *buf, unsigned int size)
8072 struct rte_flow_action *action = ctx->object;
8080 ctx->objmask = NULL;
8081 ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
8082 ctx->object = action;
8083 if (ret != (int)len)
8085 /* set indirect action */
8087 action->conf = port_action_handle_get_by_id(ctx->port, id);
8088 ret = (action->conf) ? ret : -1;
8093 /** Parse set command, initialize output buffer for subsequent tokens. */
8095 parse_set_raw_encap_decap(struct context *ctx, const struct token *token,
8096 const char *str, unsigned int len,
8097 void *buf, unsigned int size)
8099 struct buffer *out = buf;
8101 /* Token name must match. */
8102 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8104 /* Nothing else to do if there is no buffer. */
8107 /* Make sure buffer is large enough. */
8108 if (size < sizeof(*out))
8111 ctx->objmask = NULL;
8115 out->command = ctx->curr;
8116 /* For encap/decap we need is pattern */
8117 out->args.vc.pattern = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8122 /** Parse set command, initialize output buffer for subsequent tokens. */
8124 parse_set_sample_action(struct context *ctx, const struct token *token,
8125 const char *str, unsigned int len,
8126 void *buf, unsigned int size)
8128 struct buffer *out = buf;
8130 /* Token name must match. */
8131 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8133 /* Nothing else to do if there is no buffer. */
8136 /* Make sure buffer is large enough. */
8137 if (size < sizeof(*out))
8140 ctx->objmask = NULL;
8144 out->command = ctx->curr;
8145 /* For sampler we need is actions */
8146 out->args.vc.actions = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8152 * Parse set raw_encap/raw_decap command,
8153 * initialize output buffer for subsequent tokens.
8156 parse_set_init(struct context *ctx, const struct token *token,
8157 const char *str, unsigned int len,
8158 void *buf, unsigned int size)
8160 struct buffer *out = buf;
8162 /* Token name must match. */
8163 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8165 /* Nothing else to do if there is no buffer. */
8168 /* Make sure buffer is large enough. */
8169 if (size < sizeof(*out))
8171 /* Initialize buffer. */
8172 memset(out, 0x00, sizeof(*out));
8173 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
8176 ctx->objmask = NULL;
8177 if (!out->command) {
8178 if (ctx->curr != SET)
8180 if (sizeof(*out) > size)
8182 out->command = ctx->curr;
8183 out->args.vc.data = (uint8_t *)out + size;
8184 ctx->object = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8191 * Replace testpmd handles in a flex flow item with real values.
8194 parse_flex_handle(struct context *ctx, const struct token *token,
8195 const char *str, unsigned int len,
8196 void *buf, unsigned int size)
8198 struct rte_flow_item_flex *spec, *mask;
8199 const struct rte_flow_item_flex *src_spec, *src_mask;
8200 const struct arg *arg = pop_args(ctx);
8206 printf("Bad environment\n");
8209 offset = arg->offset;
8210 push_args(ctx, arg);
8211 ret = parse_int(ctx, token, str, len, buf, size);
8212 if (ret <= 0 || !ctx->object)
8214 if (ctx->port >= RTE_MAX_ETHPORTS) {
8215 printf("Bad port\n");
8218 if (offset == offsetof(struct rte_flow_item_flex, handle)) {
8219 const struct flex_item *fp;
8220 struct rte_flow_item_flex *item_flex = ctx->object;
8221 handle = (uint16_t)(uintptr_t)item_flex->handle;
8222 if (handle >= FLEX_MAX_PARSERS_NUM) {
8223 printf("Bad flex item handle\n");
8226 fp = flex_items[ctx->port][handle];
8228 printf("Bad flex item handle\n");
8231 item_flex->handle = fp->flex_handle;
8232 } else if (offset == offsetof(struct rte_flow_item_flex, pattern)) {
8233 handle = (uint16_t)(uintptr_t)
8234 ((struct rte_flow_item_flex *)ctx->object)->pattern;
8235 if (handle >= FLEX_MAX_PATTERNS_NUM) {
8236 printf("Bad pattern handle\n");
8239 src_spec = &flex_patterns[handle].spec;
8240 src_mask = &flex_patterns[handle].mask;
8242 mask = spec + 2; /* spec, last, mask */
8243 /* fill flow rule spec and mask parameters */
8244 spec->length = src_spec->length;
8245 spec->pattern = src_spec->pattern;
8246 mask->length = src_mask->length;
8247 mask->pattern = src_mask->pattern;
8249 printf("Bad arguments - unknown flex item offset\n");
8255 /** No completion. */
8257 comp_none(struct context *ctx, const struct token *token,
8258 unsigned int ent, char *buf, unsigned int size)
8268 /** Complete boolean values. */
8270 comp_boolean(struct context *ctx, const struct token *token,
8271 unsigned int ent, char *buf, unsigned int size)
8277 for (i = 0; boolean_name[i]; ++i)
8278 if (buf && i == ent)
8279 return strlcpy(buf, boolean_name[i], size);
8285 /** Complete action names. */
8287 comp_action(struct context *ctx, const struct token *token,
8288 unsigned int ent, char *buf, unsigned int size)
8294 for (i = 0; next_action[i]; ++i)
8295 if (buf && i == ent)
8296 return strlcpy(buf, token_list[next_action[i]].name,
8303 /** Complete available ports. */
8305 comp_port(struct context *ctx, const struct token *token,
8306 unsigned int ent, char *buf, unsigned int size)
8313 RTE_ETH_FOREACH_DEV(p) {
8314 if (buf && i == ent)
8315 return snprintf(buf, size, "%u", p);
8323 /** Complete available rule IDs. */
8325 comp_rule_id(struct context *ctx, const struct token *token,
8326 unsigned int ent, char *buf, unsigned int size)
8329 struct rte_port *port;
8330 struct port_flow *pf;
8333 if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
8334 ctx->port == (portid_t)RTE_PORT_ALL)
8336 port = &ports[ctx->port];
8337 for (pf = port->flow_list; pf != NULL; pf = pf->next) {
8338 if (buf && i == ent)
8339 return snprintf(buf, size, "%u", pf->id);
8347 /** Complete type field for RSS action. */
8349 comp_vc_action_rss_type(struct context *ctx, const struct token *token,
8350 unsigned int ent, char *buf, unsigned int size)
8356 for (i = 0; rss_type_table[i].str; ++i)
8361 return strlcpy(buf, rss_type_table[ent].str, size);
8363 return snprintf(buf, size, "end");
8367 /** Complete queue field for RSS action. */
8369 comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
8370 unsigned int ent, char *buf, unsigned int size)
8377 return snprintf(buf, size, "%u", ent);
8379 return snprintf(buf, size, "end");
8383 /** Complete index number for set raw_encap/raw_decap commands. */
8385 comp_set_raw_index(struct context *ctx, const struct token *token,
8386 unsigned int ent, char *buf, unsigned int size)
8392 RTE_SET_USED(token);
8393 for (idx = 0; idx < RAW_ENCAP_CONFS_MAX_NUM; ++idx) {
8394 if (buf && idx == ent)
8395 return snprintf(buf, size, "%u", idx);
8401 /** Complete index number for set raw_encap/raw_decap commands. */
8403 comp_set_sample_index(struct context *ctx, const struct token *token,
8404 unsigned int ent, char *buf, unsigned int size)
8410 RTE_SET_USED(token);
8411 for (idx = 0; idx < RAW_SAMPLE_CONFS_MAX_NUM; ++idx) {
8412 if (buf && idx == ent)
8413 return snprintf(buf, size, "%u", idx);
8419 /** Complete operation for modify_field command. */
8421 comp_set_modify_field_op(struct context *ctx, const struct token *token,
8422 unsigned int ent, char *buf, unsigned int size)
8425 RTE_SET_USED(token);
8427 return RTE_DIM(modify_field_ops);
8428 if (ent < RTE_DIM(modify_field_ops) - 1)
8429 return strlcpy(buf, modify_field_ops[ent], size);
8433 /** Complete field id for modify_field command. */
8435 comp_set_modify_field_id(struct context *ctx, const struct token *token,
8436 unsigned int ent, char *buf, unsigned int size)
8440 RTE_SET_USED(token);
8442 return RTE_DIM(modify_field_ids);
8443 if (ent >= RTE_DIM(modify_field_ids) - 1)
8445 name = modify_field_ids[ent];
8446 if (ctx->curr == ACTION_MODIFY_FIELD_SRC_TYPE ||
8447 (strcmp(name, "pointer") && strcmp(name, "value")))
8448 return strlcpy(buf, name, size);
8452 /** Internal context. */
8453 static struct context cmd_flow_context;
8455 /** Global parser instance (cmdline API). */
8456 cmdline_parse_inst_t cmd_flow;
8457 cmdline_parse_inst_t cmd_set_raw;
8459 /** Initialize context. */
8461 cmd_flow_context_init(struct context *ctx)
8463 /* A full memset() is not necessary. */
8473 ctx->objmask = NULL;
8476 /** Parse a token (cmdline API). */
8478 cmd_flow_parse(cmdline_parse_token_hdr_t *hdr, const char *src, void *result,
8481 struct context *ctx = &cmd_flow_context;
8482 const struct token *token;
8483 const enum index *list;
8488 token = &token_list[ctx->curr];
8489 /* Check argument length. */
8492 for (len = 0; src[len]; ++len)
8493 if (src[len] == '#' || isspace(src[len]))
8497 /* Last argument and EOL detection. */
8498 for (i = len; src[i]; ++i)
8499 if (src[i] == '#' || src[i] == '\r' || src[i] == '\n')
8501 else if (!isspace(src[i])) {
8506 if (src[i] == '\r' || src[i] == '\n') {
8510 /* Initialize context if necessary. */
8511 if (!ctx->next_num) {
8514 ctx->next[ctx->next_num++] = token->next[0];
8516 /* Process argument through candidates. */
8517 ctx->prev = ctx->curr;
8518 list = ctx->next[ctx->next_num - 1];
8519 for (i = 0; list[i]; ++i) {
8520 const struct token *next = &token_list[list[i]];
8523 ctx->curr = list[i];
8525 tmp = next->call(ctx, next, src, len, result, size);
8527 tmp = parse_default(ctx, next, src, len, result, size);
8528 if (tmp == -1 || tmp != len)
8536 /* Push subsequent tokens if any. */
8538 for (i = 0; token->next[i]; ++i) {
8539 if (ctx->next_num == RTE_DIM(ctx->next))
8541 ctx->next[ctx->next_num++] = token->next[i];
8543 /* Push arguments if any. */
8545 for (i = 0; token->args[i]; ++i) {
8546 if (ctx->args_num == RTE_DIM(ctx->args))
8548 ctx->args[ctx->args_num++] = token->args[i];
8554 flow_parse(const char *src, void *result, unsigned int size,
8555 struct rte_flow_attr **attr,
8556 struct rte_flow_item **pattern, struct rte_flow_action **actions)
8559 struct context saved_flow_ctx = cmd_flow_context;
8561 cmd_flow_context_init(&cmd_flow_context);
8563 ret = cmd_flow_parse(NULL, src, result, size);
8566 while (isspace(*src))
8569 } while (ret > 0 && strlen(src));
8570 cmd_flow_context = saved_flow_ctx;
8571 *attr = &((struct buffer *)result)->args.vc.attr;
8572 *pattern = ((struct buffer *)result)->args.vc.pattern;
8573 *actions = ((struct buffer *)result)->args.vc.actions;
8574 return (ret >= 0 && !strlen(src)) ? 0 : -1;
8577 /** Return number of completion entries (cmdline API). */
8579 cmd_flow_complete_get_nb(cmdline_parse_token_hdr_t *hdr)
8581 struct context *ctx = &cmd_flow_context;
8582 const struct token *token = &token_list[ctx->curr];
8583 const enum index *list;
8587 /* Count number of tokens in current list. */
8589 list = ctx->next[ctx->next_num - 1];
8591 list = token->next[0];
8592 for (i = 0; list[i]; ++i)
8597 * If there is a single token, use its completion callback, otherwise
8598 * return the number of entries.
8600 token = &token_list[list[0]];
8601 if (i == 1 && token->comp) {
8602 /* Save index for cmd_flow_get_help(). */
8603 ctx->prev = list[0];
8604 return token->comp(ctx, token, 0, NULL, 0);
8609 /** Return a completion entry (cmdline API). */
8611 cmd_flow_complete_get_elt(cmdline_parse_token_hdr_t *hdr, int index,
8612 char *dst, unsigned int size)
8614 struct context *ctx = &cmd_flow_context;
8615 const struct token *token = &token_list[ctx->curr];
8616 const enum index *list;
8620 /* Count number of tokens in current list. */
8622 list = ctx->next[ctx->next_num - 1];
8624 list = token->next[0];
8625 for (i = 0; list[i]; ++i)
8629 /* If there is a single token, use its completion callback. */
8630 token = &token_list[list[0]];
8631 if (i == 1 && token->comp) {
8632 /* Save index for cmd_flow_get_help(). */
8633 ctx->prev = list[0];
8634 return token->comp(ctx, token, index, dst, size) < 0 ? -1 : 0;
8636 /* Otherwise make sure the index is valid and use defaults. */
8639 token = &token_list[list[index]];
8640 strlcpy(dst, token->name, size);
8641 /* Save index for cmd_flow_get_help(). */
8642 ctx->prev = list[index];
8646 /** Populate help strings for current token (cmdline API). */
8648 cmd_flow_get_help(cmdline_parse_token_hdr_t *hdr, char *dst, unsigned int size)
8650 struct context *ctx = &cmd_flow_context;
8651 const struct token *token = &token_list[ctx->prev];
8656 /* Set token type and update global help with details. */
8657 strlcpy(dst, (token->type ? token->type : "TOKEN"), size);
8659 cmd_flow.help_str = token->help;
8661 cmd_flow.help_str = token->name;
8665 /** Token definition template (cmdline API). */
8666 static struct cmdline_token_hdr cmd_flow_token_hdr = {
8667 .ops = &(struct cmdline_token_ops){
8668 .parse = cmd_flow_parse,
8669 .complete_get_nb = cmd_flow_complete_get_nb,
8670 .complete_get_elt = cmd_flow_complete_get_elt,
8671 .get_help = cmd_flow_get_help,
8676 /** Populate the next dynamic token. */
8678 cmd_flow_tok(cmdline_parse_token_hdr_t **hdr,
8679 cmdline_parse_token_hdr_t **hdr_inst)
8681 struct context *ctx = &cmd_flow_context;
8683 /* Always reinitialize context before requesting the first token. */
8684 if (!(hdr_inst - cmd_flow.tokens))
8685 cmd_flow_context_init(ctx);
8686 /* Return NULL when no more tokens are expected. */
8687 if (!ctx->next_num && ctx->curr) {
8691 /* Determine if command should end here. */
8692 if (ctx->eol && ctx->last && ctx->next_num) {
8693 const enum index *list = ctx->next[ctx->next_num - 1];
8696 for (i = 0; list[i]; ++i) {
8703 *hdr = &cmd_flow_token_hdr;
8706 /** Dispatch parsed buffer to function calls. */
8708 cmd_flow_parsed(const struct buffer *in)
8710 switch (in->command) {
8711 case INDIRECT_ACTION_CREATE:
8712 port_action_handle_create(
8713 in->port, in->args.vc.attr.group,
8714 &((const struct rte_flow_indir_action_conf) {
8715 .ingress = in->args.vc.attr.ingress,
8716 .egress = in->args.vc.attr.egress,
8717 .transfer = in->args.vc.attr.transfer,
8719 in->args.vc.actions);
8721 case INDIRECT_ACTION_DESTROY:
8722 port_action_handle_destroy(in->port,
8723 in->args.ia_destroy.action_id_n,
8724 in->args.ia_destroy.action_id);
8726 case INDIRECT_ACTION_UPDATE:
8727 port_action_handle_update(in->port, in->args.vc.attr.group,
8728 in->args.vc.actions);
8730 case INDIRECT_ACTION_QUERY:
8731 port_action_handle_query(in->port, in->args.ia.action_id);
8734 port_flow_validate(in->port, &in->args.vc.attr,
8735 in->args.vc.pattern, in->args.vc.actions,
8736 &in->args.vc.tunnel_ops);
8739 port_flow_create(in->port, &in->args.vc.attr,
8740 in->args.vc.pattern, in->args.vc.actions,
8741 &in->args.vc.tunnel_ops);
8744 port_flow_destroy(in->port, in->args.destroy.rule_n,
8745 in->args.destroy.rule);
8748 port_flow_flush(in->port);
8752 port_flow_dump(in->port, in->args.dump.mode,
8753 in->args.dump.rule, in->args.dump.file);
8756 port_flow_query(in->port, in->args.query.rule,
8757 &in->args.query.action);
8760 port_flow_list(in->port, in->args.list.group_n,
8761 in->args.list.group);
8764 port_flow_isolate(in->port, in->args.isolate.set);
8767 port_flow_aged(in->port, in->args.aged.destroy);
8770 port_flow_tunnel_create(in->port, &in->args.vc.tunnel_ops);
8772 case TUNNEL_DESTROY:
8773 port_flow_tunnel_destroy(in->port, in->args.vc.tunnel_ops.id);
8776 port_flow_tunnel_list(in->port);
8779 port_meter_policy_add(in->port, in->args.policy.policy_id,
8780 in->args.vc.actions);
8782 case FLEX_ITEM_CREATE:
8783 flex_item_create(in->port, in->args.flex.token,
8784 in->args.flex.filename);
8786 case FLEX_ITEM_DESTROY:
8787 flex_item_destroy(in->port, in->args.flex.token);
8794 /** Token generator and output processing callback (cmdline API). */
8796 cmd_flow_cb(void *arg0, struct cmdline *cl, void *arg2)
8799 cmd_flow_tok(arg0, arg2);
8801 cmd_flow_parsed(arg0);
8804 /** Global parser instance (cmdline API). */
8805 cmdline_parse_inst_t cmd_flow = {
8807 .data = NULL, /**< Unused. */
8808 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
8811 }, /**< Tokens are returned by cmd_flow_tok(). */
8814 /** set cmd facility. Reuse cmd flow's infrastructure as much as possible. */
8817 update_fields(uint8_t *buf, struct rte_flow_item *item, uint16_t next_proto)
8819 struct rte_ipv4_hdr *ipv4;
8820 struct rte_ether_hdr *eth;
8821 struct rte_ipv6_hdr *ipv6;
8822 struct rte_vxlan_hdr *vxlan;
8823 struct rte_vxlan_gpe_hdr *gpe;
8824 struct rte_flow_item_nvgre *nvgre;
8825 uint32_t ipv6_vtc_flow;
8827 switch (item->type) {
8828 case RTE_FLOW_ITEM_TYPE_ETH:
8829 eth = (struct rte_ether_hdr *)buf;
8831 eth->ether_type = rte_cpu_to_be_16(next_proto);
8833 case RTE_FLOW_ITEM_TYPE_IPV4:
8834 ipv4 = (struct rte_ipv4_hdr *)buf;
8835 if (!ipv4->version_ihl)
8836 ipv4->version_ihl = RTE_IPV4_VHL_DEF;
8837 if (next_proto && ipv4->next_proto_id == 0)
8838 ipv4->next_proto_id = (uint8_t)next_proto;
8840 case RTE_FLOW_ITEM_TYPE_IPV6:
8841 ipv6 = (struct rte_ipv6_hdr *)buf;
8842 if (next_proto && ipv6->proto == 0)
8843 ipv6->proto = (uint8_t)next_proto;
8844 ipv6_vtc_flow = rte_be_to_cpu_32(ipv6->vtc_flow);
8845 ipv6_vtc_flow &= 0x0FFFFFFF; /*< reset version bits. */
8846 ipv6_vtc_flow |= 0x60000000; /*< set ipv6 version. */
8847 ipv6->vtc_flow = rte_cpu_to_be_32(ipv6_vtc_flow);
8849 case RTE_FLOW_ITEM_TYPE_VXLAN:
8850 vxlan = (struct rte_vxlan_hdr *)buf;
8851 vxlan->vx_flags = 0x08;
8853 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
8854 gpe = (struct rte_vxlan_gpe_hdr *)buf;
8855 gpe->vx_flags = 0x0C;
8857 case RTE_FLOW_ITEM_TYPE_NVGRE:
8858 nvgre = (struct rte_flow_item_nvgre *)buf;
8859 nvgre->protocol = rte_cpu_to_be_16(0x6558);
8860 nvgre->c_k_s_rsvd0_ver = rte_cpu_to_be_16(0x2000);
8867 /** Helper of get item's default mask. */
8869 flow_item_default_mask(const struct rte_flow_item *item)
8871 const void *mask = NULL;
8872 static rte_be32_t gre_key_default_mask = RTE_BE32(UINT32_MAX);
8874 switch (item->type) {
8875 case RTE_FLOW_ITEM_TYPE_ANY:
8876 mask = &rte_flow_item_any_mask;
8878 case RTE_FLOW_ITEM_TYPE_VF:
8879 mask = &rte_flow_item_vf_mask;
8881 case RTE_FLOW_ITEM_TYPE_PORT_ID:
8882 mask = &rte_flow_item_port_id_mask;
8884 case RTE_FLOW_ITEM_TYPE_RAW:
8885 mask = &rte_flow_item_raw_mask;
8887 case RTE_FLOW_ITEM_TYPE_ETH:
8888 mask = &rte_flow_item_eth_mask;
8890 case RTE_FLOW_ITEM_TYPE_VLAN:
8891 mask = &rte_flow_item_vlan_mask;
8893 case RTE_FLOW_ITEM_TYPE_IPV4:
8894 mask = &rte_flow_item_ipv4_mask;
8896 case RTE_FLOW_ITEM_TYPE_IPV6:
8897 mask = &rte_flow_item_ipv6_mask;
8899 case RTE_FLOW_ITEM_TYPE_ICMP:
8900 mask = &rte_flow_item_icmp_mask;
8902 case RTE_FLOW_ITEM_TYPE_UDP:
8903 mask = &rte_flow_item_udp_mask;
8905 case RTE_FLOW_ITEM_TYPE_TCP:
8906 mask = &rte_flow_item_tcp_mask;
8908 case RTE_FLOW_ITEM_TYPE_SCTP:
8909 mask = &rte_flow_item_sctp_mask;
8911 case RTE_FLOW_ITEM_TYPE_VXLAN:
8912 mask = &rte_flow_item_vxlan_mask;
8914 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
8915 mask = &rte_flow_item_vxlan_gpe_mask;
8917 case RTE_FLOW_ITEM_TYPE_E_TAG:
8918 mask = &rte_flow_item_e_tag_mask;
8920 case RTE_FLOW_ITEM_TYPE_NVGRE:
8921 mask = &rte_flow_item_nvgre_mask;
8923 case RTE_FLOW_ITEM_TYPE_MPLS:
8924 mask = &rte_flow_item_mpls_mask;
8926 case RTE_FLOW_ITEM_TYPE_GRE:
8927 mask = &rte_flow_item_gre_mask;
8929 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
8930 mask = &gre_key_default_mask;
8932 case RTE_FLOW_ITEM_TYPE_META:
8933 mask = &rte_flow_item_meta_mask;
8935 case RTE_FLOW_ITEM_TYPE_FUZZY:
8936 mask = &rte_flow_item_fuzzy_mask;
8938 case RTE_FLOW_ITEM_TYPE_GTP:
8939 mask = &rte_flow_item_gtp_mask;
8941 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
8942 mask = &rte_flow_item_gtp_psc_mask;
8944 case RTE_FLOW_ITEM_TYPE_GENEVE:
8945 mask = &rte_flow_item_geneve_mask;
8947 case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
8948 mask = &rte_flow_item_geneve_opt_mask;
8950 case RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID:
8951 mask = &rte_flow_item_pppoe_proto_id_mask;
8953 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
8954 mask = &rte_flow_item_l2tpv3oip_mask;
8956 case RTE_FLOW_ITEM_TYPE_ESP:
8957 mask = &rte_flow_item_esp_mask;
8959 case RTE_FLOW_ITEM_TYPE_AH:
8960 mask = &rte_flow_item_ah_mask;
8962 case RTE_FLOW_ITEM_TYPE_PFCP:
8963 mask = &rte_flow_item_pfcp_mask;
8965 case RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR:
8966 case RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT:
8967 mask = &rte_flow_item_ethdev_mask;
8969 case RTE_FLOW_ITEM_TYPE_L2TPV2:
8970 mask = &rte_flow_item_l2tpv2_mask;
8972 case RTE_FLOW_ITEM_TYPE_PPP:
8973 mask = &rte_flow_item_ppp_mask;
8981 /** Dispatch parsed buffer to function calls. */
8983 cmd_set_raw_parsed_sample(const struct buffer *in)
8985 uint32_t n = in->args.vc.actions_n;
8987 struct rte_flow_action *action = NULL;
8988 struct rte_flow_action *data = NULL;
8989 const struct rte_flow_action_rss *rss = NULL;
8991 uint16_t idx = in->port; /* We borrow port field as index */
8992 uint32_t max_size = sizeof(struct rte_flow_action) *
8993 ACTION_SAMPLE_ACTIONS_NUM;
8995 RTE_ASSERT(in->command == SET_SAMPLE_ACTIONS);
8996 data = (struct rte_flow_action *)&raw_sample_confs[idx].data;
8997 memset(data, 0x00, max_size);
8998 for (; i <= n - 1; i++) {
8999 action = in->args.vc.actions + i;
9000 if (action->type == RTE_FLOW_ACTION_TYPE_END)
9002 switch (action->type) {
9003 case RTE_FLOW_ACTION_TYPE_MARK:
9004 size = sizeof(struct rte_flow_action_mark);
9005 rte_memcpy(&sample_mark[idx],
9006 (const void *)action->conf, size);
9007 action->conf = &sample_mark[idx];
9009 case RTE_FLOW_ACTION_TYPE_COUNT:
9010 size = sizeof(struct rte_flow_action_count);
9011 rte_memcpy(&sample_count[idx],
9012 (const void *)action->conf, size);
9013 action->conf = &sample_count[idx];
9015 case RTE_FLOW_ACTION_TYPE_QUEUE:
9016 size = sizeof(struct rte_flow_action_queue);
9017 rte_memcpy(&sample_queue[idx],
9018 (const void *)action->conf, size);
9019 action->conf = &sample_queue[idx];
9021 case RTE_FLOW_ACTION_TYPE_RSS:
9022 size = sizeof(struct rte_flow_action_rss);
9024 rte_memcpy(&sample_rss_data[idx].conf,
9025 (const void *)rss, size);
9026 if (rss->key_len && rss->key) {
9027 sample_rss_data[idx].conf.key =
9028 sample_rss_data[idx].key;
9029 rte_memcpy((void *)((uintptr_t)
9030 sample_rss_data[idx].conf.key),
9031 (const void *)rss->key,
9032 sizeof(uint8_t) * rss->key_len);
9034 if (rss->queue_num && rss->queue) {
9035 sample_rss_data[idx].conf.queue =
9036 sample_rss_data[idx].queue;
9037 rte_memcpy((void *)((uintptr_t)
9038 sample_rss_data[idx].conf.queue),
9039 (const void *)rss->queue,
9040 sizeof(uint16_t) * rss->queue_num);
9042 action->conf = &sample_rss_data[idx].conf;
9044 case RTE_FLOW_ACTION_TYPE_RAW_ENCAP:
9045 size = sizeof(struct rte_flow_action_raw_encap);
9046 rte_memcpy(&sample_encap[idx],
9047 (const void *)action->conf, size);
9048 action->conf = &sample_encap[idx];
9050 case RTE_FLOW_ACTION_TYPE_PORT_ID:
9051 size = sizeof(struct rte_flow_action_port_id);
9052 rte_memcpy(&sample_port_id[idx],
9053 (const void *)action->conf, size);
9054 action->conf = &sample_port_id[idx];
9056 case RTE_FLOW_ACTION_TYPE_PF:
9058 case RTE_FLOW_ACTION_TYPE_VF:
9059 size = sizeof(struct rte_flow_action_vf);
9060 rte_memcpy(&sample_vf[idx],
9061 (const void *)action->conf, size);
9062 action->conf = &sample_vf[idx];
9064 case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP:
9065 size = sizeof(struct rte_flow_action_vxlan_encap);
9066 parse_setup_vxlan_encap_data(&sample_vxlan_encap[idx]);
9067 action->conf = &sample_vxlan_encap[idx].conf;
9069 case RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP:
9070 size = sizeof(struct rte_flow_action_nvgre_encap);
9071 parse_setup_nvgre_encap_data(&sample_nvgre_encap[idx]);
9072 action->conf = &sample_nvgre_encap[idx];
9075 fprintf(stderr, "Error - Not supported action\n");
9078 rte_memcpy(data, action, sizeof(struct rte_flow_action));
9083 /** Dispatch parsed buffer to function calls. */
9085 cmd_set_raw_parsed(const struct buffer *in)
9087 uint32_t n = in->args.vc.pattern_n;
9089 struct rte_flow_item *item = NULL;
9091 uint8_t *data = NULL;
9092 uint8_t *data_tail = NULL;
9093 size_t *total_size = NULL;
9094 uint16_t upper_layer = 0;
9096 uint16_t idx = in->port; /* We borrow port field as index */
9097 int gtp_psc = -1; /* GTP PSC option index. */
9099 if (in->command == SET_SAMPLE_ACTIONS)
9100 return cmd_set_raw_parsed_sample(in);
9101 RTE_ASSERT(in->command == SET_RAW_ENCAP ||
9102 in->command == SET_RAW_DECAP);
9103 if (in->command == SET_RAW_ENCAP) {
9104 total_size = &raw_encap_confs[idx].size;
9105 data = (uint8_t *)&raw_encap_confs[idx].data;
9107 total_size = &raw_decap_confs[idx].size;
9108 data = (uint8_t *)&raw_decap_confs[idx].data;
9111 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
9112 /* process hdr from upper layer to low layer (L3/L4 -> L2). */
9113 data_tail = data + ACTION_RAW_ENCAP_MAX_DATA;
9114 for (i = n - 1 ; i >= 0; --i) {
9115 const struct rte_flow_item_gtp *gtp;
9116 const struct rte_flow_item_geneve_opt *opt;
9118 item = in->args.vc.pattern + i;
9119 if (item->spec == NULL)
9120 item->spec = flow_item_default_mask(item);
9121 switch (item->type) {
9122 case RTE_FLOW_ITEM_TYPE_ETH:
9123 size = sizeof(struct rte_ether_hdr);
9125 case RTE_FLOW_ITEM_TYPE_VLAN:
9126 size = sizeof(struct rte_vlan_hdr);
9127 proto = RTE_ETHER_TYPE_VLAN;
9129 case RTE_FLOW_ITEM_TYPE_IPV4:
9130 size = sizeof(struct rte_ipv4_hdr);
9131 proto = RTE_ETHER_TYPE_IPV4;
9133 case RTE_FLOW_ITEM_TYPE_IPV6:
9134 size = sizeof(struct rte_ipv6_hdr);
9135 proto = RTE_ETHER_TYPE_IPV6;
9137 case RTE_FLOW_ITEM_TYPE_UDP:
9138 size = sizeof(struct rte_udp_hdr);
9141 case RTE_FLOW_ITEM_TYPE_TCP:
9142 size = sizeof(struct rte_tcp_hdr);
9145 case RTE_FLOW_ITEM_TYPE_VXLAN:
9146 size = sizeof(struct rte_vxlan_hdr);
9148 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
9149 size = sizeof(struct rte_vxlan_gpe_hdr);
9151 case RTE_FLOW_ITEM_TYPE_GRE:
9152 size = sizeof(struct rte_gre_hdr);
9155 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
9156 size = sizeof(rte_be32_t);
9159 case RTE_FLOW_ITEM_TYPE_MPLS:
9160 size = sizeof(struct rte_mpls_hdr);
9163 case RTE_FLOW_ITEM_TYPE_NVGRE:
9164 size = sizeof(struct rte_flow_item_nvgre);
9167 case RTE_FLOW_ITEM_TYPE_GENEVE:
9168 size = sizeof(struct rte_geneve_hdr);
9170 case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
9171 opt = (const struct rte_flow_item_geneve_opt *)
9173 size = offsetof(struct rte_flow_item_geneve_opt, data);
9174 if (opt->option_len && opt->data) {
9175 *total_size += opt->option_len *
9177 rte_memcpy(data_tail - (*total_size),
9179 opt->option_len * sizeof(uint32_t));
9182 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
9183 size = sizeof(rte_be32_t);
9186 case RTE_FLOW_ITEM_TYPE_ESP:
9187 size = sizeof(struct rte_esp_hdr);
9190 case RTE_FLOW_ITEM_TYPE_AH:
9191 size = sizeof(struct rte_flow_item_ah);
9194 case RTE_FLOW_ITEM_TYPE_GTP:
9196 size = sizeof(struct rte_gtp_hdr);
9199 if (gtp_psc != i + 1) {
9201 "Error - GTP PSC does not follow GTP\n");
9205 if ((gtp->v_pt_rsv_flags & 0x07) != 0x04) {
9206 /* Only E flag should be set. */
9208 "Error - GTP unsupported flags\n");
9211 struct rte_gtp_hdr_ext_word ext_word = {
9215 /* We have to add GTP header extra word. */
9216 *total_size += sizeof(ext_word);
9217 rte_memcpy(data_tail - (*total_size),
9218 &ext_word, sizeof(ext_word));
9220 size = sizeof(struct rte_gtp_hdr);
9222 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
9225 "Error - Multiple GTP PSC items\n");
9228 const struct rte_flow_item_gtp_psc
9236 psc.len = sizeof(psc) / 4;
9237 psc.pdu_type = opt->hdr.type;
9238 psc.qfi = opt->hdr.qfi;
9240 *total_size += sizeof(psc);
9241 rte_memcpy(data_tail - (*total_size),
9247 case RTE_FLOW_ITEM_TYPE_PFCP:
9248 size = sizeof(struct rte_flow_item_pfcp);
9250 case RTE_FLOW_ITEM_TYPE_FLEX:
9252 ((const struct rte_flow_item_flex *)
9253 item->spec)->length : 0;
9256 fprintf(stderr, "Error - Not supported item\n");
9259 *total_size += size;
9260 rte_memcpy(data_tail - (*total_size), item->spec, size);
9261 /* update some fields which cannot be set by cmdline */
9262 update_fields((data_tail - (*total_size)), item,
9264 upper_layer = proto;
9266 if (verbose_level & 0x1)
9267 printf("total data size is %zu\n", (*total_size));
9268 RTE_ASSERT((*total_size) <= ACTION_RAW_ENCAP_MAX_DATA);
9269 memmove(data, (data_tail - (*total_size)), *total_size);
9274 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
9277 /** Populate help strings for current token (cmdline API). */
9279 cmd_set_raw_get_help(cmdline_parse_token_hdr_t *hdr, char *dst,
9282 struct context *ctx = &cmd_flow_context;
9283 const struct token *token = &token_list[ctx->prev];
9288 /* Set token type and update global help with details. */
9289 snprintf(dst, size, "%s", (token->type ? token->type : "TOKEN"));
9291 cmd_set_raw.help_str = token->help;
9293 cmd_set_raw.help_str = token->name;
9297 /** Token definition template (cmdline API). */
9298 static struct cmdline_token_hdr cmd_set_raw_token_hdr = {
9299 .ops = &(struct cmdline_token_ops){
9300 .parse = cmd_flow_parse,
9301 .complete_get_nb = cmd_flow_complete_get_nb,
9302 .complete_get_elt = cmd_flow_complete_get_elt,
9303 .get_help = cmd_set_raw_get_help,
9308 /** Populate the next dynamic token. */
9310 cmd_set_raw_tok(cmdline_parse_token_hdr_t **hdr,
9311 cmdline_parse_token_hdr_t **hdr_inst)
9313 struct context *ctx = &cmd_flow_context;
9315 /* Always reinitialize context before requesting the first token. */
9316 if (!(hdr_inst - cmd_set_raw.tokens)) {
9317 cmd_flow_context_init(ctx);
9318 ctx->curr = START_SET;
9320 /* Return NULL when no more tokens are expected. */
9321 if (!ctx->next_num && (ctx->curr != START_SET)) {
9325 /* Determine if command should end here. */
9326 if (ctx->eol && ctx->last && ctx->next_num) {
9327 const enum index *list = ctx->next[ctx->next_num - 1];
9330 for (i = 0; list[i]; ++i) {
9337 *hdr = &cmd_set_raw_token_hdr;
9340 /** Token generator and output processing callback (cmdline API). */
9342 cmd_set_raw_cb(void *arg0, struct cmdline *cl, void *arg2)
9345 cmd_set_raw_tok(arg0, arg2);
9347 cmd_set_raw_parsed(arg0);
9350 /** Global parser instance (cmdline API). */
9351 cmdline_parse_inst_t cmd_set_raw = {
9352 .f = cmd_set_raw_cb,
9353 .data = NULL, /**< Unused. */
9354 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
9357 }, /**< Tokens are returned by cmd_flow_tok(). */
9360 /* *** display raw_encap/raw_decap buf */
9361 struct cmd_show_set_raw_result {
9362 cmdline_fixed_string_t cmd_show;
9363 cmdline_fixed_string_t cmd_what;
9364 cmdline_fixed_string_t cmd_all;
9369 cmd_show_set_raw_parsed(void *parsed_result, struct cmdline *cl, void *data)
9371 struct cmd_show_set_raw_result *res = parsed_result;
9372 uint16_t index = res->cmd_index;
9374 uint8_t *raw_data = NULL;
9375 size_t raw_size = 0;
9376 char title[16] = {0};
9380 if (!strcmp(res->cmd_all, "all")) {
9383 } else if (index >= RAW_ENCAP_CONFS_MAX_NUM) {
9384 fprintf(stderr, "index should be 0-%u\n",
9385 RAW_ENCAP_CONFS_MAX_NUM - 1);
9389 if (!strcmp(res->cmd_what, "raw_encap")) {
9390 raw_data = (uint8_t *)&raw_encap_confs[index].data;
9391 raw_size = raw_encap_confs[index].size;
9392 snprintf(title, 16, "\nindex: %u", index);
9393 rte_hexdump(stdout, title, raw_data, raw_size);
9395 raw_data = (uint8_t *)&raw_decap_confs[index].data;
9396 raw_size = raw_decap_confs[index].size;
9397 snprintf(title, 16, "\nindex: %u", index);
9398 rte_hexdump(stdout, title, raw_data, raw_size);
9400 } while (all && ++index < RAW_ENCAP_CONFS_MAX_NUM);
9403 cmdline_parse_token_string_t cmd_show_set_raw_cmd_show =
9404 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
9406 cmdline_parse_token_string_t cmd_show_set_raw_cmd_what =
9407 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
9408 cmd_what, "raw_encap#raw_decap");
9409 cmdline_parse_token_num_t cmd_show_set_raw_cmd_index =
9410 TOKEN_NUM_INITIALIZER(struct cmd_show_set_raw_result,
9411 cmd_index, RTE_UINT16);
9412 cmdline_parse_token_string_t cmd_show_set_raw_cmd_all =
9413 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
9415 cmdline_parse_inst_t cmd_show_set_raw = {
9416 .f = cmd_show_set_raw_parsed,
9418 .help_str = "show <raw_encap|raw_decap> <index>",
9420 (void *)&cmd_show_set_raw_cmd_show,
9421 (void *)&cmd_show_set_raw_cmd_what,
9422 (void *)&cmd_show_set_raw_cmd_index,
9426 cmdline_parse_inst_t cmd_show_set_raw_all = {
9427 .f = cmd_show_set_raw_parsed,
9429 .help_str = "show <raw_encap|raw_decap> all",
9431 (void *)&cmd_show_set_raw_cmd_show,
9432 (void *)&cmd_show_set_raw_cmd_what,
9433 (void *)&cmd_show_set_raw_cmd_all,