1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2016 6WIND S.A.
3 * Copyright 2016 Mellanox Technologies, Ltd
14 #include <rte_string_fns.h>
15 #include <rte_common.h>
16 #include <rte_ethdev.h>
17 #include <rte_byteorder.h>
18 #include <cmdline_parse.h>
19 #include <cmdline_parse_etheraddr.h>
20 #include <cmdline_parse_string.h>
21 #include <cmdline_parse_num.h>
23 #include <rte_hexdump.h>
24 #include <rte_vxlan.h>
28 #include <rte_geneve.h>
32 /** Parser token indices. */
54 COMMON_PRIORITY_LEVEL,
55 COMMON_INDIRECT_ACTION_ID,
58 /* TOP-level command. */
61 /* Top-level command. */
63 /* Sub-leve commands. */
70 /* Top-level command. */
72 /* Sub-level commands. */
85 /* Tunnel arguments. */
92 /* Destroy arguments. */
95 /* Query arguments. */
101 /* Destroy aged flow arguments. */
104 /* Validate/create arguments. */
117 /* Indirect action arguments */
118 INDIRECT_ACTION_CREATE,
119 INDIRECT_ACTION_UPDATE,
120 INDIRECT_ACTION_DESTROY,
121 INDIRECT_ACTION_QUERY,
123 /* Indirect action create arguments */
124 INDIRECT_ACTION_CREATE_ID,
125 INDIRECT_ACTION_INGRESS,
126 INDIRECT_ACTION_EGRESS,
127 INDIRECT_ACTION_TRANSFER,
128 INDIRECT_ACTION_SPEC,
130 /* Indirect action destroy arguments */
131 INDIRECT_ACTION_DESTROY_ID,
133 /* Validate/create pattern. */
171 ITEM_VLAN_INNER_TYPE,
172 ITEM_VLAN_HAS_MORE_VLAN,
177 ITEM_IPV4_FRAGMENT_OFFSET,
189 ITEM_IPV6_HAS_FRAG_EXT,
209 ITEM_VXLAN_LAST_RSVD,
211 ITEM_E_TAG_GRP_ECID_B,
220 ITEM_GRE_C_RSVD0_VER,
239 ITEM_ARP_ETH_IPV4_SHA,
240 ITEM_ARP_ETH_IPV4_SPA,
241 ITEM_ARP_ETH_IPV4_THA,
242 ITEM_ARP_ETH_IPV4_TPA,
244 ITEM_IPV6_EXT_NEXT_HDR,
246 ITEM_IPV6_FRAG_EXT_NEXT_HDR,
247 ITEM_IPV6_FRAG_EXT_FRAG_DATA,
248 ITEM_IPV6_FRAG_EXT_ID,
253 ITEM_ICMP6_ND_NS_TARGET_ADDR,
255 ITEM_ICMP6_ND_NA_TARGET_ADDR,
257 ITEM_ICMP6_ND_OPT_TYPE,
258 ITEM_ICMP6_ND_OPT_SLA_ETH,
259 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
260 ITEM_ICMP6_ND_OPT_TLA_ETH,
261 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
274 ITEM_HIGIG2_CLASSIFICATION,
280 ITEM_L2TPV3OIP_SESSION_ID,
290 ITEM_ECPRI_COMMON_TYPE,
291 ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
292 ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
293 ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
294 ITEM_ECPRI_MSG_IQ_DATA_PCID,
295 ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
296 ITEM_ECPRI_MSG_DLY_MSR_MSRID,
298 ITEM_GENEVE_OPT_CLASS,
299 ITEM_GENEVE_OPT_TYPE,
300 ITEM_GENEVE_OPT_LENGTH,
301 ITEM_GENEVE_OPT_DATA,
303 ITEM_INTEGRITY_LEVEL,
304 ITEM_INTEGRITY_VALUE,
309 ITEM_PORT_REPRESENTOR,
310 ITEM_PORT_REPRESENTOR_PORT_ID,
311 ITEM_REPRESENTED_PORT,
312 ITEM_REPRESENTED_PORT_ETHDEV_PORT_ID,
314 /* Validate/create actions. */
333 ACTION_RSS_FUNC_DEFAULT,
334 ACTION_RSS_FUNC_TOEPLITZ,
335 ACTION_RSS_FUNC_SIMPLE_XOR,
336 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ,
348 ACTION_PHY_PORT_ORIGINAL,
349 ACTION_PHY_PORT_INDEX,
351 ACTION_PORT_ID_ORIGINAL,
355 ACTION_METER_COLOR_TYPE,
356 ACTION_METER_COLOR_GREEN,
357 ACTION_METER_COLOR_YELLOW,
358 ACTION_METER_COLOR_RED,
360 ACTION_OF_SET_MPLS_TTL,
361 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
362 ACTION_OF_DEC_MPLS_TTL,
363 ACTION_OF_SET_NW_TTL,
364 ACTION_OF_SET_NW_TTL_NW_TTL,
365 ACTION_OF_DEC_NW_TTL,
366 ACTION_OF_COPY_TTL_OUT,
367 ACTION_OF_COPY_TTL_IN,
370 ACTION_OF_PUSH_VLAN_ETHERTYPE,
371 ACTION_OF_SET_VLAN_VID,
372 ACTION_OF_SET_VLAN_VID_VLAN_VID,
373 ACTION_OF_SET_VLAN_PCP,
374 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
376 ACTION_OF_POP_MPLS_ETHERTYPE,
378 ACTION_OF_PUSH_MPLS_ETHERTYPE,
385 ACTION_MPLSOGRE_ENCAP,
386 ACTION_MPLSOGRE_DECAP,
387 ACTION_MPLSOUDP_ENCAP,
388 ACTION_MPLSOUDP_DECAP,
390 ACTION_SET_IPV4_SRC_IPV4_SRC,
392 ACTION_SET_IPV4_DST_IPV4_DST,
394 ACTION_SET_IPV6_SRC_IPV6_SRC,
396 ACTION_SET_IPV6_DST_IPV6_DST,
398 ACTION_SET_TP_SRC_TP_SRC,
400 ACTION_SET_TP_DST_TP_DST,
406 ACTION_SET_MAC_SRC_MAC_SRC,
408 ACTION_SET_MAC_DST_MAC_DST,
410 ACTION_INC_TCP_SEQ_VALUE,
412 ACTION_DEC_TCP_SEQ_VALUE,
414 ACTION_INC_TCP_ACK_VALUE,
416 ACTION_DEC_TCP_ACK_VALUE,
419 ACTION_RAW_ENCAP_INDEX,
420 ACTION_RAW_ENCAP_INDEX_VALUE,
421 ACTION_RAW_DECAP_INDEX,
422 ACTION_RAW_DECAP_INDEX_VALUE,
425 ACTION_SET_TAG_INDEX,
428 ACTION_SET_META_DATA,
429 ACTION_SET_META_MASK,
430 ACTION_SET_IPV4_DSCP,
431 ACTION_SET_IPV4_DSCP_VALUE,
432 ACTION_SET_IPV6_DSCP,
433 ACTION_SET_IPV6_DSCP_VALUE,
439 ACTION_SAMPLE_INDEX_VALUE,
441 INDIRECT_ACTION_ID2PTR,
443 ACTION_MODIFY_FIELD_OP,
444 ACTION_MODIFY_FIELD_OP_VALUE,
445 ACTION_MODIFY_FIELD_DST_TYPE,
446 ACTION_MODIFY_FIELD_DST_TYPE_VALUE,
447 ACTION_MODIFY_FIELD_DST_LEVEL,
448 ACTION_MODIFY_FIELD_DST_OFFSET,
449 ACTION_MODIFY_FIELD_SRC_TYPE,
450 ACTION_MODIFY_FIELD_SRC_TYPE_VALUE,
451 ACTION_MODIFY_FIELD_SRC_LEVEL,
452 ACTION_MODIFY_FIELD_SRC_OFFSET,
453 ACTION_MODIFY_FIELD_SRC_VALUE,
454 ACTION_MODIFY_FIELD_WIDTH,
456 ACTION_CONNTRACK_UPDATE,
457 ACTION_CONNTRACK_UPDATE_DIR,
458 ACTION_CONNTRACK_UPDATE_CTX,
464 /** Maximum size for pattern in struct rte_flow_item_raw. */
465 #define ITEM_RAW_PATTERN_SIZE 40
467 /** Maximum size for GENEVE option data pattern in bytes. */
468 #define ITEM_GENEVE_OPT_DATA_SIZE 124
470 /** Storage size for struct rte_flow_item_raw including pattern. */
471 #define ITEM_RAW_SIZE \
472 (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE)
474 /** Maximum number of queue indices in struct rte_flow_action_rss. */
475 #define ACTION_RSS_QUEUE_NUM 128
477 /** Storage for struct rte_flow_action_rss including external data. */
478 struct action_rss_data {
479 struct rte_flow_action_rss conf;
480 uint8_t key[RSS_HASH_KEY_LENGTH];
481 uint16_t queue[ACTION_RSS_QUEUE_NUM];
484 /** Maximum data size in struct rte_flow_action_raw_encap. */
485 #define ACTION_RAW_ENCAP_MAX_DATA 512
486 #define RAW_ENCAP_CONFS_MAX_NUM 8
488 /** Storage for struct rte_flow_action_raw_encap. */
489 struct raw_encap_conf {
490 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
491 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
495 struct raw_encap_conf raw_encap_confs[RAW_ENCAP_CONFS_MAX_NUM];
497 /** Storage for struct rte_flow_action_raw_encap including external data. */
498 struct action_raw_encap_data {
499 struct rte_flow_action_raw_encap conf;
500 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
501 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
505 /** Storage for struct rte_flow_action_raw_decap. */
506 struct raw_decap_conf {
507 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
511 struct raw_decap_conf raw_decap_confs[RAW_ENCAP_CONFS_MAX_NUM];
513 /** Storage for struct rte_flow_action_raw_decap including external data. */
514 struct action_raw_decap_data {
515 struct rte_flow_action_raw_decap conf;
516 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
520 struct vxlan_encap_conf vxlan_encap_conf = {
524 .vni = "\x00\x00\x00",
526 .udp_dst = RTE_BE16(RTE_VXLAN_DEFAULT_PORT),
527 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
528 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
529 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
530 "\x00\x00\x00\x00\x00\x00\x00\x01",
531 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
532 "\x00\x00\x00\x00\x00\x00\x11\x11",
536 .eth_src = "\x00\x00\x00\x00\x00\x00",
537 .eth_dst = "\xff\xff\xff\xff\xff\xff",
540 /** Maximum number of items in struct rte_flow_action_vxlan_encap. */
541 #define ACTION_VXLAN_ENCAP_ITEMS_NUM 6
543 /** Storage for struct rte_flow_action_vxlan_encap including external data. */
544 struct action_vxlan_encap_data {
545 struct rte_flow_action_vxlan_encap conf;
546 struct rte_flow_item items[ACTION_VXLAN_ENCAP_ITEMS_NUM];
547 struct rte_flow_item_eth item_eth;
548 struct rte_flow_item_vlan item_vlan;
550 struct rte_flow_item_ipv4 item_ipv4;
551 struct rte_flow_item_ipv6 item_ipv6;
553 struct rte_flow_item_udp item_udp;
554 struct rte_flow_item_vxlan item_vxlan;
557 struct nvgre_encap_conf nvgre_encap_conf = {
560 .tni = "\x00\x00\x00",
561 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
562 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
563 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
564 "\x00\x00\x00\x00\x00\x00\x00\x01",
565 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
566 "\x00\x00\x00\x00\x00\x00\x11\x11",
568 .eth_src = "\x00\x00\x00\x00\x00\x00",
569 .eth_dst = "\xff\xff\xff\xff\xff\xff",
572 /** Maximum number of items in struct rte_flow_action_nvgre_encap. */
573 #define ACTION_NVGRE_ENCAP_ITEMS_NUM 5
575 /** Storage for struct rte_flow_action_nvgre_encap including external data. */
576 struct action_nvgre_encap_data {
577 struct rte_flow_action_nvgre_encap conf;
578 struct rte_flow_item items[ACTION_NVGRE_ENCAP_ITEMS_NUM];
579 struct rte_flow_item_eth item_eth;
580 struct rte_flow_item_vlan item_vlan;
582 struct rte_flow_item_ipv4 item_ipv4;
583 struct rte_flow_item_ipv6 item_ipv6;
585 struct rte_flow_item_nvgre item_nvgre;
588 struct l2_encap_conf l2_encap_conf;
590 struct l2_decap_conf l2_decap_conf;
592 struct mplsogre_encap_conf mplsogre_encap_conf;
594 struct mplsogre_decap_conf mplsogre_decap_conf;
596 struct mplsoudp_encap_conf mplsoudp_encap_conf;
598 struct mplsoudp_decap_conf mplsoudp_decap_conf;
600 struct rte_flow_action_conntrack conntrack_context;
602 #define ACTION_SAMPLE_ACTIONS_NUM 10
603 #define RAW_SAMPLE_CONFS_MAX_NUM 8
604 /** Storage for struct rte_flow_action_sample including external data. */
605 struct action_sample_data {
606 struct rte_flow_action_sample conf;
609 /** Storage for struct rte_flow_action_sample. */
610 struct raw_sample_conf {
611 struct rte_flow_action data[ACTION_SAMPLE_ACTIONS_NUM];
613 struct raw_sample_conf raw_sample_confs[RAW_SAMPLE_CONFS_MAX_NUM];
614 struct rte_flow_action_mark sample_mark[RAW_SAMPLE_CONFS_MAX_NUM];
615 struct rte_flow_action_queue sample_queue[RAW_SAMPLE_CONFS_MAX_NUM];
616 struct rte_flow_action_count sample_count[RAW_SAMPLE_CONFS_MAX_NUM];
617 struct rte_flow_action_port_id sample_port_id[RAW_SAMPLE_CONFS_MAX_NUM];
618 struct rte_flow_action_raw_encap sample_encap[RAW_SAMPLE_CONFS_MAX_NUM];
619 struct action_vxlan_encap_data sample_vxlan_encap[RAW_SAMPLE_CONFS_MAX_NUM];
620 struct action_nvgre_encap_data sample_nvgre_encap[RAW_SAMPLE_CONFS_MAX_NUM];
621 struct action_rss_data sample_rss_data[RAW_SAMPLE_CONFS_MAX_NUM];
622 struct rte_flow_action_vf sample_vf[RAW_SAMPLE_CONFS_MAX_NUM];
624 static const char *const modify_field_ops[] = {
625 "set", "add", "sub", NULL
628 static const char *const modify_field_ids[] = {
629 "start", "mac_dst", "mac_src",
630 "vlan_type", "vlan_id", "mac_type",
631 "ipv4_dscp", "ipv4_ttl", "ipv4_src", "ipv4_dst",
632 "ipv6_dscp", "ipv6_hoplimit", "ipv6_src", "ipv6_dst",
633 "tcp_port_src", "tcp_port_dst",
634 "tcp_seq_num", "tcp_ack_num", "tcp_flags",
635 "udp_port_src", "udp_port_dst",
636 "vxlan_vni", "geneve_vni", "gtp_teid",
637 "tag", "mark", "meta", "pointer", "value", NULL
640 /** Maximum number of subsequent tokens and arguments on the stack. */
641 #define CTX_STACK_SIZE 16
643 /** Parser context. */
645 /** Stack of subsequent token lists to process. */
646 const enum index *next[CTX_STACK_SIZE];
647 /** Arguments for stacked tokens. */
648 const void *args[CTX_STACK_SIZE];
649 enum index curr; /**< Current token index. */
650 enum index prev; /**< Index of the last token seen. */
651 int next_num; /**< Number of entries in next[]. */
652 int args_num; /**< Number of entries in args[]. */
653 uint32_t eol:1; /**< EOL has been detected. */
654 uint32_t last:1; /**< No more arguments. */
655 portid_t port; /**< Current port ID (for completions). */
656 uint32_t objdata; /**< Object-specific data. */
657 void *object; /**< Address of current object for relative offsets. */
658 void *objmask; /**< Object a full mask must be written to. */
661 /** Token argument. */
663 uint32_t hton:1; /**< Use network byte ordering. */
664 uint32_t sign:1; /**< Value is signed. */
665 uint32_t bounded:1; /**< Value is bounded. */
666 uintmax_t min; /**< Minimum value if bounded. */
667 uintmax_t max; /**< Maximum value if bounded. */
668 uint32_t offset; /**< Relative offset from ctx->object. */
669 uint32_t size; /**< Field size. */
670 const uint8_t *mask; /**< Bit-mask to use instead of offset/size. */
673 /** Parser token definition. */
675 /** Type displayed during completion (defaults to "TOKEN"). */
677 /** Help displayed during completion (defaults to token name). */
679 /** Private data used by parser functions. */
682 * Lists of subsequent tokens to push on the stack. Each call to the
683 * parser consumes the last entry of that stack.
685 const enum index *const *next;
686 /** Arguments stack for subsequent tokens that need them. */
687 const struct arg *const *args;
689 * Token-processing callback, returns -1 in case of error, the
690 * length of the matched string otherwise. If NULL, attempts to
691 * match the token name.
693 * If buf is not NULL, the result should be stored in it according
694 * to context. An error is returned if not large enough.
696 int (*call)(struct context *ctx, const struct token *token,
697 const char *str, unsigned int len,
698 void *buf, unsigned int size);
700 * Callback that provides possible values for this token, used for
701 * completion. Returns -1 in case of error, the number of possible
702 * values otherwise. If NULL, the token name is used.
704 * If buf is not NULL, entry index ent is written to buf and the
705 * full length of the entry is returned (same behavior as
708 int (*comp)(struct context *ctx, const struct token *token,
709 unsigned int ent, char *buf, unsigned int size);
710 /** Mandatory token name, no default value. */
714 /** Static initializer for the next field. */
715 #define NEXT(...) (const enum index *const []){ __VA_ARGS__, NULL, }
717 /** Static initializer for a NEXT() entry. */
718 #define NEXT_ENTRY(...) (const enum index []){ __VA_ARGS__, ZERO, }
720 /** Static initializer for the args field. */
721 #define ARGS(...) (const struct arg *const []){ __VA_ARGS__, NULL, }
723 /** Static initializer for ARGS() to target a field. */
724 #define ARGS_ENTRY(s, f) \
725 (&(const struct arg){ \
726 .offset = offsetof(s, f), \
727 .size = sizeof(((s *)0)->f), \
730 /** Static initializer for ARGS() to target a bit-field. */
731 #define ARGS_ENTRY_BF(s, f, b) \
732 (&(const struct arg){ \
734 .mask = (const void *)&(const s){ .f = (1 << (b)) - 1 }, \
737 /** Static initializer for ARGS() to target a field with limits. */
738 #define ARGS_ENTRY_BOUNDED(s, f, i, a) \
739 (&(const struct arg){ \
743 .offset = offsetof(s, f), \
744 .size = sizeof(((s *)0)->f), \
747 /** Static initializer for ARGS() to target an arbitrary bit-mask. */
748 #define ARGS_ENTRY_MASK(s, f, m) \
749 (&(const struct arg){ \
750 .offset = offsetof(s, f), \
751 .size = sizeof(((s *)0)->f), \
752 .mask = (const void *)(m), \
755 /** Same as ARGS_ENTRY_MASK() using network byte ordering for the value. */
756 #define ARGS_ENTRY_MASK_HTON(s, f, m) \
757 (&(const struct arg){ \
759 .offset = offsetof(s, f), \
760 .size = sizeof(((s *)0)->f), \
761 .mask = (const void *)(m), \
764 /** Static initializer for ARGS() to target a pointer. */
765 #define ARGS_ENTRY_PTR(s, f) \
766 (&(const struct arg){ \
767 .size = sizeof(*((s *)0)->f), \
770 /** Static initializer for ARGS() with arbitrary offset and size. */
771 #define ARGS_ENTRY_ARB(o, s) \
772 (&(const struct arg){ \
777 /** Same as ARGS_ENTRY_ARB() with bounded values. */
778 #define ARGS_ENTRY_ARB_BOUNDED(o, s, i, a) \
779 (&(const struct arg){ \
787 /** Same as ARGS_ENTRY() using network byte ordering. */
788 #define ARGS_ENTRY_HTON(s, f) \
789 (&(const struct arg){ \
791 .offset = offsetof(s, f), \
792 .size = sizeof(((s *)0)->f), \
795 /** Same as ARGS_ENTRY_HTON() for a single argument, without structure. */
796 #define ARG_ENTRY_HTON(s) \
797 (&(const struct arg){ \
803 /** Parser output buffer layout expected by cmd_flow_parsed(). */
805 enum index command; /**< Flow command. */
806 portid_t port; /**< Affected port ID. */
810 uint32_t action_id_n;
811 } ia_destroy; /**< Indirect action destroy arguments. */
814 } ia; /* Indirect action query arguments */
816 struct rte_flow_attr attr;
817 struct tunnel_ops tunnel_ops;
818 struct rte_flow_item *pattern;
819 struct rte_flow_action *actions;
823 } vc; /**< Validate/create arguments. */
827 } destroy; /**< Destroy arguments. */
832 } dump; /**< Dump arguments. */
835 struct rte_flow_action action;
836 } query; /**< Query arguments. */
840 } list; /**< List arguments. */
843 } isolate; /**< Isolated mode arguments. */
846 } aged; /**< Aged arguments. */
849 } policy;/**< Policy arguments. */
850 } args; /**< Command arguments. */
853 /** Private data for pattern items. */
854 struct parse_item_priv {
855 enum rte_flow_item_type type; /**< Item type. */
856 uint32_t size; /**< Size of item specification structure. */
859 #define PRIV_ITEM(t, s) \
860 (&(const struct parse_item_priv){ \
861 .type = RTE_FLOW_ITEM_TYPE_ ## t, \
865 /** Private data for actions. */
866 struct parse_action_priv {
867 enum rte_flow_action_type type; /**< Action type. */
868 uint32_t size; /**< Size of action configuration structure. */
871 #define PRIV_ACTION(t, s) \
872 (&(const struct parse_action_priv){ \
873 .type = RTE_FLOW_ACTION_TYPE_ ## t, \
877 static const enum index next_ia_create_attr[] = {
878 INDIRECT_ACTION_CREATE_ID,
879 INDIRECT_ACTION_INGRESS,
880 INDIRECT_ACTION_EGRESS,
881 INDIRECT_ACTION_TRANSFER,
882 INDIRECT_ACTION_SPEC,
886 static const enum index next_dump_subcmd[] = {
892 static const enum index next_ia_subcmd[] = {
893 INDIRECT_ACTION_CREATE,
894 INDIRECT_ACTION_UPDATE,
895 INDIRECT_ACTION_DESTROY,
896 INDIRECT_ACTION_QUERY,
900 static const enum index next_vc_attr[] = {
912 static const enum index next_destroy_attr[] = {
918 static const enum index next_dump_attr[] = {
924 static const enum index next_list_attr[] = {
930 static const enum index next_aged_attr[] = {
936 static const enum index next_ia_destroy_attr[] = {
937 INDIRECT_ACTION_DESTROY_ID,
942 static const enum index item_param[] = {
951 static const enum index next_item[] = {
988 ITEM_ICMP6_ND_OPT_SLA_ETH,
989 ITEM_ICMP6_ND_OPT_TLA_ETH,
1006 ITEM_PORT_REPRESENTOR,
1007 ITEM_REPRESENTED_PORT,
1012 static const enum index item_fuzzy[] = {
1018 static const enum index item_any[] = {
1024 static const enum index item_vf[] = {
1030 static const enum index item_phy_port[] = {
1031 ITEM_PHY_PORT_INDEX,
1036 static const enum index item_port_id[] = {
1042 static const enum index item_mark[] = {
1048 static const enum index item_raw[] = {
1058 static const enum index item_eth[] = {
1067 static const enum index item_vlan[] = {
1072 ITEM_VLAN_INNER_TYPE,
1073 ITEM_VLAN_HAS_MORE_VLAN,
1078 static const enum index item_ipv4[] = {
1082 ITEM_IPV4_FRAGMENT_OFFSET,
1091 static const enum index item_ipv6[] = {
1098 ITEM_IPV6_HAS_FRAG_EXT,
1103 static const enum index item_icmp[] = {
1112 static const enum index item_udp[] = {
1119 static const enum index item_tcp[] = {
1127 static const enum index item_sctp[] = {
1136 static const enum index item_vxlan[] = {
1138 ITEM_VXLAN_LAST_RSVD,
1143 static const enum index item_e_tag[] = {
1144 ITEM_E_TAG_GRP_ECID_B,
1149 static const enum index item_nvgre[] = {
1155 static const enum index item_mpls[] = {
1163 static const enum index item_gre[] = {
1165 ITEM_GRE_C_RSVD0_VER,
1173 static const enum index item_gre_key[] = {
1179 static const enum index item_gtp[] = {
1187 static const enum index item_geneve[] = {
1195 static const enum index item_vxlan_gpe[] = {
1201 static const enum index item_arp_eth_ipv4[] = {
1202 ITEM_ARP_ETH_IPV4_SHA,
1203 ITEM_ARP_ETH_IPV4_SPA,
1204 ITEM_ARP_ETH_IPV4_THA,
1205 ITEM_ARP_ETH_IPV4_TPA,
1210 static const enum index item_ipv6_ext[] = {
1211 ITEM_IPV6_EXT_NEXT_HDR,
1216 static const enum index item_ipv6_frag_ext[] = {
1217 ITEM_IPV6_FRAG_EXT_NEXT_HDR,
1218 ITEM_IPV6_FRAG_EXT_FRAG_DATA,
1219 ITEM_IPV6_FRAG_EXT_ID,
1224 static const enum index item_icmp6[] = {
1231 static const enum index item_icmp6_nd_ns[] = {
1232 ITEM_ICMP6_ND_NS_TARGET_ADDR,
1237 static const enum index item_icmp6_nd_na[] = {
1238 ITEM_ICMP6_ND_NA_TARGET_ADDR,
1243 static const enum index item_icmp6_nd_opt[] = {
1244 ITEM_ICMP6_ND_OPT_TYPE,
1249 static const enum index item_icmp6_nd_opt_sla_eth[] = {
1250 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
1255 static const enum index item_icmp6_nd_opt_tla_eth[] = {
1256 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
1261 static const enum index item_meta[] = {
1267 static const enum index item_gtp_psc[] = {
1274 static const enum index item_pppoed[] = {
1280 static const enum index item_pppoes[] = {
1286 static const enum index item_pppoe_proto_id[] = {
1291 static const enum index item_higig2[] = {
1292 ITEM_HIGIG2_CLASSIFICATION,
1298 static const enum index item_esp[] = {
1304 static const enum index item_ah[] = {
1310 static const enum index item_pfcp[] = {
1317 static const enum index next_set_raw[] = {
1323 static const enum index item_tag[] = {
1330 static const enum index item_l2tpv3oip[] = {
1331 ITEM_L2TPV3OIP_SESSION_ID,
1336 static const enum index item_ecpri[] = {
1342 static const enum index item_ecpri_common[] = {
1343 ITEM_ECPRI_COMMON_TYPE,
1347 static const enum index item_ecpri_common_type[] = {
1348 ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
1349 ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
1350 ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
1354 static const enum index item_geneve_opt[] = {
1355 ITEM_GENEVE_OPT_CLASS,
1356 ITEM_GENEVE_OPT_TYPE,
1357 ITEM_GENEVE_OPT_LENGTH,
1358 ITEM_GENEVE_OPT_DATA,
1363 static const enum index item_integrity[] = {
1364 ITEM_INTEGRITY_LEVEL,
1365 ITEM_INTEGRITY_VALUE,
1369 static const enum index item_integrity_lv[] = {
1370 ITEM_INTEGRITY_LEVEL,
1371 ITEM_INTEGRITY_VALUE,
1376 static const enum index item_port_representor[] = {
1377 ITEM_PORT_REPRESENTOR_PORT_ID,
1382 static const enum index item_represented_port[] = {
1383 ITEM_REPRESENTED_PORT_ETHDEV_PORT_ID,
1388 static const enum index next_action[] = {
1405 ACTION_OF_SET_MPLS_TTL,
1406 ACTION_OF_DEC_MPLS_TTL,
1407 ACTION_OF_SET_NW_TTL,
1408 ACTION_OF_DEC_NW_TTL,
1409 ACTION_OF_COPY_TTL_OUT,
1410 ACTION_OF_COPY_TTL_IN,
1412 ACTION_OF_PUSH_VLAN,
1413 ACTION_OF_SET_VLAN_VID,
1414 ACTION_OF_SET_VLAN_PCP,
1416 ACTION_OF_PUSH_MPLS,
1423 ACTION_MPLSOGRE_ENCAP,
1424 ACTION_MPLSOGRE_DECAP,
1425 ACTION_MPLSOUDP_ENCAP,
1426 ACTION_MPLSOUDP_DECAP,
1427 ACTION_SET_IPV4_SRC,
1428 ACTION_SET_IPV4_DST,
1429 ACTION_SET_IPV6_SRC,
1430 ACTION_SET_IPV6_DST,
1446 ACTION_SET_IPV4_DSCP,
1447 ACTION_SET_IPV6_DSCP,
1451 ACTION_MODIFY_FIELD,
1453 ACTION_CONNTRACK_UPDATE,
1457 static const enum index action_mark[] = {
1463 static const enum index action_queue[] = {
1469 static const enum index action_count[] = {
1475 static const enum index action_rss[] = {
1486 static const enum index action_vf[] = {
1493 static const enum index action_phy_port[] = {
1494 ACTION_PHY_PORT_ORIGINAL,
1495 ACTION_PHY_PORT_INDEX,
1500 static const enum index action_port_id[] = {
1501 ACTION_PORT_ID_ORIGINAL,
1507 static const enum index action_meter[] = {
1513 static const enum index action_meter_color[] = {
1514 ACTION_METER_COLOR_TYPE,
1519 static const enum index action_of_set_mpls_ttl[] = {
1520 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
1525 static const enum index action_of_set_nw_ttl[] = {
1526 ACTION_OF_SET_NW_TTL_NW_TTL,
1531 static const enum index action_of_push_vlan[] = {
1532 ACTION_OF_PUSH_VLAN_ETHERTYPE,
1537 static const enum index action_of_set_vlan_vid[] = {
1538 ACTION_OF_SET_VLAN_VID_VLAN_VID,
1543 static const enum index action_of_set_vlan_pcp[] = {
1544 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
1549 static const enum index action_of_pop_mpls[] = {
1550 ACTION_OF_POP_MPLS_ETHERTYPE,
1555 static const enum index action_of_push_mpls[] = {
1556 ACTION_OF_PUSH_MPLS_ETHERTYPE,
1561 static const enum index action_set_ipv4_src[] = {
1562 ACTION_SET_IPV4_SRC_IPV4_SRC,
1567 static const enum index action_set_mac_src[] = {
1568 ACTION_SET_MAC_SRC_MAC_SRC,
1573 static const enum index action_set_ipv4_dst[] = {
1574 ACTION_SET_IPV4_DST_IPV4_DST,
1579 static const enum index action_set_ipv6_src[] = {
1580 ACTION_SET_IPV6_SRC_IPV6_SRC,
1585 static const enum index action_set_ipv6_dst[] = {
1586 ACTION_SET_IPV6_DST_IPV6_DST,
1591 static const enum index action_set_tp_src[] = {
1592 ACTION_SET_TP_SRC_TP_SRC,
1597 static const enum index action_set_tp_dst[] = {
1598 ACTION_SET_TP_DST_TP_DST,
1603 static const enum index action_set_ttl[] = {
1609 static const enum index action_jump[] = {
1615 static const enum index action_set_mac_dst[] = {
1616 ACTION_SET_MAC_DST_MAC_DST,
1621 static const enum index action_inc_tcp_seq[] = {
1622 ACTION_INC_TCP_SEQ_VALUE,
1627 static const enum index action_dec_tcp_seq[] = {
1628 ACTION_DEC_TCP_SEQ_VALUE,
1633 static const enum index action_inc_tcp_ack[] = {
1634 ACTION_INC_TCP_ACK_VALUE,
1639 static const enum index action_dec_tcp_ack[] = {
1640 ACTION_DEC_TCP_ACK_VALUE,
1645 static const enum index action_raw_encap[] = {
1646 ACTION_RAW_ENCAP_INDEX,
1651 static const enum index action_raw_decap[] = {
1652 ACTION_RAW_DECAP_INDEX,
1657 static const enum index action_set_tag[] = {
1658 ACTION_SET_TAG_DATA,
1659 ACTION_SET_TAG_INDEX,
1660 ACTION_SET_TAG_MASK,
1665 static const enum index action_set_meta[] = {
1666 ACTION_SET_META_DATA,
1667 ACTION_SET_META_MASK,
1672 static const enum index action_set_ipv4_dscp[] = {
1673 ACTION_SET_IPV4_DSCP_VALUE,
1678 static const enum index action_set_ipv6_dscp[] = {
1679 ACTION_SET_IPV6_DSCP_VALUE,
1684 static const enum index action_age[] = {
1691 static const enum index action_sample[] = {
1693 ACTION_SAMPLE_RATIO,
1694 ACTION_SAMPLE_INDEX,
1699 static const enum index next_action_sample[] = {
1712 static const enum index action_modify_field_dst[] = {
1713 ACTION_MODIFY_FIELD_DST_LEVEL,
1714 ACTION_MODIFY_FIELD_DST_OFFSET,
1715 ACTION_MODIFY_FIELD_SRC_TYPE,
1719 static const enum index action_modify_field_src[] = {
1720 ACTION_MODIFY_FIELD_SRC_LEVEL,
1721 ACTION_MODIFY_FIELD_SRC_OFFSET,
1722 ACTION_MODIFY_FIELD_SRC_VALUE,
1723 ACTION_MODIFY_FIELD_WIDTH,
1727 static const enum index action_update_conntrack[] = {
1728 ACTION_CONNTRACK_UPDATE_DIR,
1729 ACTION_CONNTRACK_UPDATE_CTX,
1734 static int parse_set_raw_encap_decap(struct context *, const struct token *,
1735 const char *, unsigned int,
1736 void *, unsigned int);
1737 static int parse_set_sample_action(struct context *, const struct token *,
1738 const char *, unsigned int,
1739 void *, unsigned int);
1740 static int parse_set_init(struct context *, const struct token *,
1741 const char *, unsigned int,
1742 void *, unsigned int);
1743 static int parse_init(struct context *, const struct token *,
1744 const char *, unsigned int,
1745 void *, unsigned int);
1746 static int parse_vc(struct context *, const struct token *,
1747 const char *, unsigned int,
1748 void *, unsigned int);
1749 static int parse_vc_spec(struct context *, const struct token *,
1750 const char *, unsigned int, void *, unsigned int);
1751 static int parse_vc_conf(struct context *, const struct token *,
1752 const char *, unsigned int, void *, unsigned int);
1753 static int parse_vc_item_ecpri_type(struct context *, const struct token *,
1754 const char *, unsigned int,
1755 void *, unsigned int);
1756 static int parse_vc_action_meter_color_type(struct context *,
1757 const struct token *,
1758 const char *, unsigned int, void *,
1760 static int parse_vc_action_rss(struct context *, const struct token *,
1761 const char *, unsigned int, void *,
1763 static int parse_vc_action_rss_func(struct context *, const struct token *,
1764 const char *, unsigned int, void *,
1766 static int parse_vc_action_rss_type(struct context *, const struct token *,
1767 const char *, unsigned int, void *,
1769 static int parse_vc_action_rss_queue(struct context *, const struct token *,
1770 const char *, unsigned int, void *,
1772 static int parse_vc_action_vxlan_encap(struct context *, const struct token *,
1773 const char *, unsigned int, void *,
1775 static int parse_vc_action_nvgre_encap(struct context *, const struct token *,
1776 const char *, unsigned int, void *,
1778 static int parse_vc_action_l2_encap(struct context *, const struct token *,
1779 const char *, unsigned int, void *,
1781 static int parse_vc_action_l2_decap(struct context *, const struct token *,
1782 const char *, unsigned int, void *,
1784 static int parse_vc_action_mplsogre_encap(struct context *,
1785 const struct token *, const char *,
1786 unsigned int, void *, unsigned int);
1787 static int parse_vc_action_mplsogre_decap(struct context *,
1788 const struct token *, const char *,
1789 unsigned int, void *, unsigned int);
1790 static int parse_vc_action_mplsoudp_encap(struct context *,
1791 const struct token *, const char *,
1792 unsigned int, void *, unsigned int);
1793 static int parse_vc_action_mplsoudp_decap(struct context *,
1794 const struct token *, const char *,
1795 unsigned int, void *, unsigned int);
1796 static int parse_vc_action_raw_encap(struct context *,
1797 const struct token *, const char *,
1798 unsigned int, void *, unsigned int);
1799 static int parse_vc_action_raw_decap(struct context *,
1800 const struct token *, const char *,
1801 unsigned int, void *, unsigned int);
1802 static int parse_vc_action_raw_encap_index(struct context *,
1803 const struct token *, const char *,
1804 unsigned int, void *, unsigned int);
1805 static int parse_vc_action_raw_decap_index(struct context *,
1806 const struct token *, const char *,
1807 unsigned int, void *, unsigned int);
1808 static int parse_vc_action_set_meta(struct context *ctx,
1809 const struct token *token, const char *str,
1810 unsigned int len, void *buf,
1812 static int parse_vc_action_sample(struct context *ctx,
1813 const struct token *token, const char *str,
1814 unsigned int len, void *buf,
1817 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
1818 const char *str, unsigned int len, void *buf,
1821 parse_vc_modify_field_op(struct context *ctx, const struct token *token,
1822 const char *str, unsigned int len, void *buf,
1825 parse_vc_modify_field_id(struct context *ctx, const struct token *token,
1826 const char *str, unsigned int len, void *buf,
1829 parse_vc_action_conntrack_update(struct context *ctx, const struct token *token,
1830 const char *str, unsigned int len, void *buf,
1832 static int parse_destroy(struct context *, const struct token *,
1833 const char *, unsigned int,
1834 void *, unsigned int);
1835 static int parse_flush(struct context *, const struct token *,
1836 const char *, unsigned int,
1837 void *, unsigned int);
1838 static int parse_dump(struct context *, const struct token *,
1839 const char *, unsigned int,
1840 void *, unsigned int);
1841 static int parse_query(struct context *, const struct token *,
1842 const char *, unsigned int,
1843 void *, unsigned int);
1844 static int parse_action(struct context *, const struct token *,
1845 const char *, unsigned int,
1846 void *, unsigned int);
1847 static int parse_list(struct context *, const struct token *,
1848 const char *, unsigned int,
1849 void *, unsigned int);
1850 static int parse_aged(struct context *, const struct token *,
1851 const char *, unsigned int,
1852 void *, unsigned int);
1853 static int parse_isolate(struct context *, const struct token *,
1854 const char *, unsigned int,
1855 void *, unsigned int);
1856 static int parse_tunnel(struct context *, const struct token *,
1857 const char *, unsigned int,
1858 void *, unsigned int);
1859 static int parse_int(struct context *, const struct token *,
1860 const char *, unsigned int,
1861 void *, unsigned int);
1862 static int parse_prefix(struct context *, const struct token *,
1863 const char *, unsigned int,
1864 void *, unsigned int);
1865 static int parse_boolean(struct context *, const struct token *,
1866 const char *, unsigned int,
1867 void *, unsigned int);
1868 static int parse_string(struct context *, const struct token *,
1869 const char *, unsigned int,
1870 void *, unsigned int);
1871 static int parse_hex(struct context *ctx, const struct token *token,
1872 const char *str, unsigned int len,
1873 void *buf, unsigned int size);
1874 static int parse_string0(struct context *, const struct token *,
1875 const char *, unsigned int,
1876 void *, unsigned int);
1877 static int parse_mac_addr(struct context *, const struct token *,
1878 const char *, unsigned int,
1879 void *, unsigned int);
1880 static int parse_ipv4_addr(struct context *, const struct token *,
1881 const char *, unsigned int,
1882 void *, unsigned int);
1883 static int parse_ipv6_addr(struct context *, const struct token *,
1884 const char *, unsigned int,
1885 void *, unsigned int);
1886 static int parse_port(struct context *, const struct token *,
1887 const char *, unsigned int,
1888 void *, unsigned int);
1889 static int parse_ia(struct context *, const struct token *,
1890 const char *, unsigned int,
1891 void *, unsigned int);
1892 static int parse_ia_destroy(struct context *ctx, const struct token *token,
1893 const char *str, unsigned int len,
1894 void *buf, unsigned int size);
1895 static int parse_ia_id2ptr(struct context *ctx, const struct token *token,
1896 const char *str, unsigned int len, void *buf,
1898 static int parse_mp(struct context *, const struct token *,
1899 const char *, unsigned int,
1900 void *, unsigned int);
1901 static int comp_none(struct context *, const struct token *,
1902 unsigned int, char *, unsigned int);
1903 static int comp_boolean(struct context *, const struct token *,
1904 unsigned int, char *, unsigned int);
1905 static int comp_action(struct context *, const struct token *,
1906 unsigned int, char *, unsigned int);
1907 static int comp_port(struct context *, const struct token *,
1908 unsigned int, char *, unsigned int);
1909 static int comp_rule_id(struct context *, const struct token *,
1910 unsigned int, char *, unsigned int);
1911 static int comp_vc_action_rss_type(struct context *, const struct token *,
1912 unsigned int, char *, unsigned int);
1913 static int comp_vc_action_rss_queue(struct context *, const struct token *,
1914 unsigned int, char *, unsigned int);
1915 static int comp_set_raw_index(struct context *, const struct token *,
1916 unsigned int, char *, unsigned int);
1917 static int comp_set_sample_index(struct context *, const struct token *,
1918 unsigned int, char *, unsigned int);
1919 static int comp_set_modify_field_op(struct context *, const struct token *,
1920 unsigned int, char *, unsigned int);
1921 static int comp_set_modify_field_id(struct context *, const struct token *,
1922 unsigned int, char *, unsigned int);
1924 /** Token definitions. */
1925 static const struct token token_list[] = {
1926 /* Special tokens. */
1929 .help = "null entry, abused as the entry point",
1930 .next = NEXT(NEXT_ENTRY(FLOW, ADD)),
1935 .help = "command may end here",
1938 .name = "START_SET",
1939 .help = "null entry, abused as the entry point for set",
1940 .next = NEXT(NEXT_ENTRY(SET)),
1945 .help = "set command may end here",
1947 /* Common tokens. */
1948 [COMMON_INTEGER] = {
1951 .help = "integer value",
1955 [COMMON_UNSIGNED] = {
1956 .name = "{unsigned}",
1958 .help = "unsigned integer value",
1965 .help = "prefix length for bit-mask",
1966 .call = parse_prefix,
1969 [COMMON_BOOLEAN] = {
1970 .name = "{boolean}",
1972 .help = "any boolean value",
1973 .call = parse_boolean,
1974 .comp = comp_boolean,
1979 .help = "fixed string",
1980 .call = parse_string,
1986 .help = "fixed string",
1989 [COMMON_FILE_PATH] = {
1990 .name = "{file path}",
1992 .help = "file path",
1993 .call = parse_string0,
1996 [COMMON_MAC_ADDR] = {
1997 .name = "{MAC address}",
1999 .help = "standard MAC address notation",
2000 .call = parse_mac_addr,
2003 [COMMON_IPV4_ADDR] = {
2004 .name = "{IPv4 address}",
2005 .type = "IPV4 ADDRESS",
2006 .help = "standard IPv4 address notation",
2007 .call = parse_ipv4_addr,
2010 [COMMON_IPV6_ADDR] = {
2011 .name = "{IPv6 address}",
2012 .type = "IPV6 ADDRESS",
2013 .help = "standard IPv6 address notation",
2014 .call = parse_ipv6_addr,
2017 [COMMON_RULE_ID] = {
2018 .name = "{rule id}",
2020 .help = "rule identifier",
2022 .comp = comp_rule_id,
2024 [COMMON_PORT_ID] = {
2025 .name = "{port_id}",
2027 .help = "port identifier",
2031 [COMMON_GROUP_ID] = {
2032 .name = "{group_id}",
2034 .help = "group identifier",
2038 [COMMON_PRIORITY_LEVEL] = {
2041 .help = "priority level",
2045 [COMMON_INDIRECT_ACTION_ID] = {
2046 .name = "{indirect_action_id}",
2047 .type = "INDIRECT_ACTION_ID",
2048 .help = "indirect action id",
2052 [COMMON_POLICY_ID] = {
2053 .name = "{policy_id}",
2054 .type = "POLCIY_ID",
2055 .help = "policy id",
2059 /* Top-level command. */
2062 .type = "{command} {port_id} [{arg} [...]]",
2063 .help = "manage ingress/egress flow rules",
2064 .next = NEXT(NEXT_ENTRY
2078 /* Top-level command. */
2079 [INDIRECT_ACTION] = {
2080 .name = "indirect_action",
2081 .type = "{command} {port_id} [{arg} [...]]",
2082 .help = "manage indirect actions",
2083 .next = NEXT(next_ia_subcmd, NEXT_ENTRY(COMMON_PORT_ID)),
2084 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2087 /* Sub-level commands. */
2088 [INDIRECT_ACTION_CREATE] = {
2090 .help = "create indirect action",
2091 .next = NEXT(next_ia_create_attr),
2094 [INDIRECT_ACTION_UPDATE] = {
2096 .help = "update indirect action",
2097 .next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_SPEC),
2098 NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
2099 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
2102 [INDIRECT_ACTION_DESTROY] = {
2104 .help = "destroy indirect action",
2105 .next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_DESTROY_ID)),
2106 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2107 .call = parse_ia_destroy,
2109 [INDIRECT_ACTION_QUERY] = {
2111 .help = "query indirect action",
2112 .next = NEXT(NEXT_ENTRY(END),
2113 NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
2114 .args = ARGS(ARGS_ENTRY(struct buffer, args.ia.action_id)),
2119 .help = "check whether a flow rule can be created",
2120 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_PORT_ID)),
2121 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2126 .help = "create a flow rule",
2127 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_PORT_ID)),
2128 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2133 .help = "destroy specific flow rules",
2134 .next = NEXT(NEXT_ENTRY(DESTROY_RULE),
2135 NEXT_ENTRY(COMMON_PORT_ID)),
2136 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2137 .call = parse_destroy,
2141 .help = "destroy all flow rules",
2142 .next = NEXT(NEXT_ENTRY(COMMON_PORT_ID)),
2143 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2144 .call = parse_flush,
2148 .help = "dump single/all flow rules to file",
2149 .next = NEXT(next_dump_subcmd, NEXT_ENTRY(COMMON_PORT_ID)),
2150 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2155 .help = "query an existing flow rule",
2156 .next = NEXT(NEXT_ENTRY(QUERY_ACTION),
2157 NEXT_ENTRY(COMMON_RULE_ID),
2158 NEXT_ENTRY(COMMON_PORT_ID)),
2159 .args = ARGS(ARGS_ENTRY(struct buffer, args.query.action.type),
2160 ARGS_ENTRY(struct buffer, args.query.rule),
2161 ARGS_ENTRY(struct buffer, port)),
2162 .call = parse_query,
2166 .help = "list existing flow rules",
2167 .next = NEXT(next_list_attr, NEXT_ENTRY(COMMON_PORT_ID)),
2168 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2173 .help = "list and destroy aged flows",
2174 .next = NEXT(next_aged_attr, NEXT_ENTRY(COMMON_PORT_ID)),
2175 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2180 .help = "restrict ingress traffic to the defined flow rules",
2181 .next = NEXT(NEXT_ENTRY(COMMON_BOOLEAN),
2182 NEXT_ENTRY(COMMON_PORT_ID)),
2183 .args = ARGS(ARGS_ENTRY(struct buffer, args.isolate.set),
2184 ARGS_ENTRY(struct buffer, port)),
2185 .call = parse_isolate,
2189 .help = "new tunnel API",
2190 .next = NEXT(NEXT_ENTRY
2191 (TUNNEL_CREATE, TUNNEL_LIST, TUNNEL_DESTROY)),
2192 .call = parse_tunnel,
2194 /* Tunnel arguments. */
2197 .help = "create new tunnel object",
2198 .next = NEXT(NEXT_ENTRY(TUNNEL_CREATE_TYPE),
2199 NEXT_ENTRY(COMMON_PORT_ID)),
2200 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2201 .call = parse_tunnel,
2203 [TUNNEL_CREATE_TYPE] = {
2205 .help = "create new tunnel",
2206 .next = NEXT(NEXT_ENTRY(COMMON_FILE_PATH)),
2207 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, type)),
2208 .call = parse_tunnel,
2210 [TUNNEL_DESTROY] = {
2212 .help = "destroy tunel",
2213 .next = NEXT(NEXT_ENTRY(TUNNEL_DESTROY_ID),
2214 NEXT_ENTRY(COMMON_PORT_ID)),
2215 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2216 .call = parse_tunnel,
2218 [TUNNEL_DESTROY_ID] = {
2220 .help = "tunnel identifier to testroy",
2221 .next = NEXT(NEXT_ENTRY(COMMON_UNSIGNED)),
2222 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2223 .call = parse_tunnel,
2227 .help = "list existing tunnels",
2228 .next = NEXT(NEXT_ENTRY(COMMON_PORT_ID)),
2229 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2230 .call = parse_tunnel,
2232 /* Destroy arguments. */
2235 .help = "specify a rule identifier",
2236 .next = NEXT(next_destroy_attr, NEXT_ENTRY(COMMON_RULE_ID)),
2237 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.destroy.rule)),
2238 .call = parse_destroy,
2240 /* Dump arguments. */
2244 .next = NEXT(next_dump_attr),
2245 .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file)),
2250 .help = "dump one rule",
2251 .next = NEXT(next_dump_attr, NEXT_ENTRY(COMMON_RULE_ID)),
2252 .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file),
2253 ARGS_ENTRY(struct buffer, args.dump.rule)),
2256 /* Query arguments. */
2260 .help = "action to query, must be part of the rule",
2261 .call = parse_action,
2262 .comp = comp_action,
2264 /* List arguments. */
2267 .help = "specify a group",
2268 .next = NEXT(next_list_attr, NEXT_ENTRY(COMMON_GROUP_ID)),
2269 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.list.group)),
2274 .help = "specify aged flows need be destroyed",
2278 /* Validate/create attributes. */
2281 .help = "specify a group",
2282 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_GROUP_ID)),
2283 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, group)),
2288 .help = "specify a priority level",
2289 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_PRIORITY_LEVEL)),
2290 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, priority)),
2295 .help = "affect rule to ingress",
2296 .next = NEXT(next_vc_attr),
2301 .help = "affect rule to egress",
2302 .next = NEXT(next_vc_attr),
2307 .help = "apply rule directly to endpoints found in pattern",
2308 .next = NEXT(next_vc_attr),
2312 .name = "tunnel_set",
2313 .help = "tunnel steer rule",
2314 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_UNSIGNED)),
2315 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2318 [VC_TUNNEL_MATCH] = {
2319 .name = "tunnel_match",
2320 .help = "tunnel match rule",
2321 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_UNSIGNED)),
2322 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2325 /* Validate/create pattern. */
2328 .help = "submit a list of pattern items",
2329 .next = NEXT(next_item),
2334 .help = "match value perfectly (with full bit-mask)",
2335 .call = parse_vc_spec,
2337 [ITEM_PARAM_SPEC] = {
2339 .help = "match value according to configured bit-mask",
2340 .call = parse_vc_spec,
2342 [ITEM_PARAM_LAST] = {
2344 .help = "specify upper bound to establish a range",
2345 .call = parse_vc_spec,
2347 [ITEM_PARAM_MASK] = {
2349 .help = "specify bit-mask with relevant bits set to one",
2350 .call = parse_vc_spec,
2352 [ITEM_PARAM_PREFIX] = {
2354 .help = "generate bit-mask from a prefix length",
2355 .call = parse_vc_spec,
2359 .help = "specify next pattern item",
2360 .next = NEXT(next_item),
2364 .help = "end list of pattern items",
2365 .priv = PRIV_ITEM(END, 0),
2366 .next = NEXT(NEXT_ENTRY(ACTIONS)),
2371 .help = "no-op pattern item",
2372 .priv = PRIV_ITEM(VOID, 0),
2373 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2378 .help = "perform actions when pattern does not match",
2379 .priv = PRIV_ITEM(INVERT, 0),
2380 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2385 .help = "match any protocol for the current layer",
2386 .priv = PRIV_ITEM(ANY, sizeof(struct rte_flow_item_any)),
2387 .next = NEXT(item_any),
2392 .help = "number of layers covered",
2393 .next = NEXT(item_any, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2394 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_any, num)),
2398 .help = "match traffic from/to the physical function",
2399 .priv = PRIV_ITEM(PF, 0),
2400 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2405 .help = "match traffic from/to a virtual function ID",
2406 .priv = PRIV_ITEM(VF, sizeof(struct rte_flow_item_vf)),
2407 .next = NEXT(item_vf),
2413 .next = NEXT(item_vf, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2414 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_vf, id)),
2418 .help = "match traffic from/to a specific physical port",
2419 .priv = PRIV_ITEM(PHY_PORT,
2420 sizeof(struct rte_flow_item_phy_port)),
2421 .next = NEXT(item_phy_port),
2424 [ITEM_PHY_PORT_INDEX] = {
2426 .help = "physical port index",
2427 .next = NEXT(item_phy_port, NEXT_ENTRY(COMMON_UNSIGNED),
2429 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_phy_port, index)),
2433 .help = "match traffic from/to a given DPDK port ID",
2434 .priv = PRIV_ITEM(PORT_ID,
2435 sizeof(struct rte_flow_item_port_id)),
2436 .next = NEXT(item_port_id),
2439 [ITEM_PORT_ID_ID] = {
2441 .help = "DPDK port ID",
2442 .next = NEXT(item_port_id, NEXT_ENTRY(COMMON_UNSIGNED),
2444 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port_id, id)),
2448 .help = "match traffic against value set in previously matched rule",
2449 .priv = PRIV_ITEM(MARK, sizeof(struct rte_flow_item_mark)),
2450 .next = NEXT(item_mark),
2455 .help = "Integer value to match against",
2456 .next = NEXT(item_mark, NEXT_ENTRY(COMMON_UNSIGNED),
2458 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_mark, id)),
2462 .help = "match an arbitrary byte string",
2463 .priv = PRIV_ITEM(RAW, ITEM_RAW_SIZE),
2464 .next = NEXT(item_raw),
2467 [ITEM_RAW_RELATIVE] = {
2469 .help = "look for pattern after the previous item",
2470 .next = NEXT(item_raw, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
2471 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
2474 [ITEM_RAW_SEARCH] = {
2476 .help = "search pattern from offset (see also limit)",
2477 .next = NEXT(item_raw, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
2478 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
2481 [ITEM_RAW_OFFSET] = {
2483 .help = "absolute or relative offset for pattern",
2484 .next = NEXT(item_raw, NEXT_ENTRY(COMMON_INTEGER), item_param),
2485 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, offset)),
2487 [ITEM_RAW_LIMIT] = {
2489 .help = "search area limit for start of pattern",
2490 .next = NEXT(item_raw, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2491 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, limit)),
2493 [ITEM_RAW_PATTERN] = {
2495 .help = "byte string to look for",
2496 .next = NEXT(item_raw,
2497 NEXT_ENTRY(COMMON_STRING),
2498 NEXT_ENTRY(ITEM_PARAM_IS,
2501 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern),
2502 ARGS_ENTRY(struct rte_flow_item_raw, length),
2503 ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw),
2504 ITEM_RAW_PATTERN_SIZE)),
2508 .help = "match Ethernet header",
2509 .priv = PRIV_ITEM(ETH, sizeof(struct rte_flow_item_eth)),
2510 .next = NEXT(item_eth),
2515 .help = "destination MAC",
2516 .next = NEXT(item_eth, NEXT_ENTRY(COMMON_MAC_ADDR), item_param),
2517 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, dst)),
2521 .help = "source MAC",
2522 .next = NEXT(item_eth, NEXT_ENTRY(COMMON_MAC_ADDR), item_param),
2523 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, src)),
2527 .help = "EtherType",
2528 .next = NEXT(item_eth, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2529 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, type)),
2531 [ITEM_ETH_HAS_VLAN] = {
2533 .help = "packet header contains VLAN",
2534 .next = NEXT(item_eth, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2535 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_eth,
2540 .help = "match 802.1Q/ad VLAN tag",
2541 .priv = PRIV_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)),
2542 .next = NEXT(item_vlan),
2547 .help = "tag control information",
2548 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
2550 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, tci)),
2554 .help = "priority code point",
2555 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
2557 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2562 .help = "drop eligible indicator",
2563 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
2565 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2570 .help = "VLAN identifier",
2571 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
2573 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2576 [ITEM_VLAN_INNER_TYPE] = {
2577 .name = "inner_type",
2578 .help = "inner EtherType",
2579 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
2581 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan,
2584 [ITEM_VLAN_HAS_MORE_VLAN] = {
2585 .name = "has_more_vlan",
2586 .help = "packet header contains another VLAN",
2587 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
2589 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vlan,
2594 .help = "match IPv4 header",
2595 .priv = PRIV_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)),
2596 .next = NEXT(item_ipv4),
2599 [ITEM_IPV4_VER_IHL] = {
2600 .name = "version_ihl",
2601 .help = "match header length",
2602 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
2604 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ipv4,
2609 .help = "type of service",
2610 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
2612 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2613 hdr.type_of_service)),
2616 .name = "packet_id",
2617 .help = "fragment packet id",
2618 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
2620 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2623 [ITEM_IPV4_FRAGMENT_OFFSET] = {
2624 .name = "fragment_offset",
2625 .help = "fragmentation flags and fragment offset",
2626 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
2628 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2629 hdr.fragment_offset)),
2633 .help = "time to live",
2634 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
2636 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2639 [ITEM_IPV4_PROTO] = {
2641 .help = "next protocol ID",
2642 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
2644 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2645 hdr.next_proto_id)),
2649 .help = "source address",
2650 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
2652 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2657 .help = "destination address",
2658 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
2660 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2665 .help = "match IPv6 header",
2666 .priv = PRIV_ITEM(IPV6, sizeof(struct rte_flow_item_ipv6)),
2667 .next = NEXT(item_ipv6),
2672 .help = "traffic class",
2673 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
2675 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2677 "\x0f\xf0\x00\x00")),
2679 [ITEM_IPV6_FLOW] = {
2681 .help = "flow label",
2682 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
2684 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2686 "\x00\x0f\xff\xff")),
2688 [ITEM_IPV6_PROTO] = {
2690 .help = "protocol (next header)",
2691 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
2693 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2698 .help = "hop limit",
2699 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
2701 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2706 .help = "source address",
2707 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_IPV6_ADDR),
2709 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2714 .help = "destination address",
2715 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_IPV6_ADDR),
2717 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2720 [ITEM_IPV6_HAS_FRAG_EXT] = {
2721 .name = "has_frag_ext",
2722 .help = "fragment packet attribute",
2723 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
2725 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_ipv6,
2730 .help = "match ICMP header",
2731 .priv = PRIV_ITEM(ICMP, sizeof(struct rte_flow_item_icmp)),
2732 .next = NEXT(item_icmp),
2735 [ITEM_ICMP_TYPE] = {
2737 .help = "ICMP packet type",
2738 .next = NEXT(item_icmp, NEXT_ENTRY(COMMON_UNSIGNED),
2740 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2743 [ITEM_ICMP_CODE] = {
2745 .help = "ICMP packet code",
2746 .next = NEXT(item_icmp, NEXT_ENTRY(COMMON_UNSIGNED),
2748 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2751 [ITEM_ICMP_IDENT] = {
2753 .help = "ICMP packet identifier",
2754 .next = NEXT(item_icmp, NEXT_ENTRY(COMMON_UNSIGNED),
2756 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2761 .help = "ICMP packet sequence number",
2762 .next = NEXT(item_icmp, NEXT_ENTRY(COMMON_UNSIGNED),
2764 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2769 .help = "match UDP header",
2770 .priv = PRIV_ITEM(UDP, sizeof(struct rte_flow_item_udp)),
2771 .next = NEXT(item_udp),
2776 .help = "UDP source port",
2777 .next = NEXT(item_udp, NEXT_ENTRY(COMMON_UNSIGNED),
2779 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2784 .help = "UDP destination port",
2785 .next = NEXT(item_udp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2786 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2791 .help = "match TCP header",
2792 .priv = PRIV_ITEM(TCP, sizeof(struct rte_flow_item_tcp)),
2793 .next = NEXT(item_tcp),
2798 .help = "TCP source port",
2799 .next = NEXT(item_tcp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2800 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2805 .help = "TCP destination port",
2806 .next = NEXT(item_tcp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2807 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2810 [ITEM_TCP_FLAGS] = {
2812 .help = "TCP flags",
2813 .next = NEXT(item_tcp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2814 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2819 .help = "match SCTP header",
2820 .priv = PRIV_ITEM(SCTP, sizeof(struct rte_flow_item_sctp)),
2821 .next = NEXT(item_sctp),
2826 .help = "SCTP source port",
2827 .next = NEXT(item_sctp, NEXT_ENTRY(COMMON_UNSIGNED),
2829 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2834 .help = "SCTP destination port",
2835 .next = NEXT(item_sctp, NEXT_ENTRY(COMMON_UNSIGNED),
2837 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2842 .help = "validation tag",
2843 .next = NEXT(item_sctp, NEXT_ENTRY(COMMON_UNSIGNED),
2845 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2848 [ITEM_SCTP_CKSUM] = {
2851 .next = NEXT(item_sctp, NEXT_ENTRY(COMMON_UNSIGNED),
2853 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2858 .help = "match VXLAN header",
2859 .priv = PRIV_ITEM(VXLAN, sizeof(struct rte_flow_item_vxlan)),
2860 .next = NEXT(item_vxlan),
2863 [ITEM_VXLAN_VNI] = {
2865 .help = "VXLAN identifier",
2866 .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
2868 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan, vni)),
2870 [ITEM_VXLAN_LAST_RSVD] = {
2871 .name = "last_rsvd",
2872 .help = "VXLAN last reserved bits",
2873 .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
2875 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan,
2880 .help = "match E-Tag header",
2881 .priv = PRIV_ITEM(E_TAG, sizeof(struct rte_flow_item_e_tag)),
2882 .next = NEXT(item_e_tag),
2885 [ITEM_E_TAG_GRP_ECID_B] = {
2886 .name = "grp_ecid_b",
2887 .help = "GRP and E-CID base",
2888 .next = NEXT(item_e_tag, NEXT_ENTRY(COMMON_UNSIGNED),
2890 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_e_tag,
2896 .help = "match NVGRE header",
2897 .priv = PRIV_ITEM(NVGRE, sizeof(struct rte_flow_item_nvgre)),
2898 .next = NEXT(item_nvgre),
2901 [ITEM_NVGRE_TNI] = {
2903 .help = "virtual subnet ID",
2904 .next = NEXT(item_nvgre, NEXT_ENTRY(COMMON_UNSIGNED),
2906 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_nvgre, tni)),
2910 .help = "match MPLS header",
2911 .priv = PRIV_ITEM(MPLS, sizeof(struct rte_flow_item_mpls)),
2912 .next = NEXT(item_mpls),
2915 [ITEM_MPLS_LABEL] = {
2917 .help = "MPLS label",
2918 .next = NEXT(item_mpls, NEXT_ENTRY(COMMON_UNSIGNED),
2920 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2926 .help = "MPLS Traffic Class",
2927 .next = NEXT(item_mpls, NEXT_ENTRY(COMMON_UNSIGNED),
2929 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2935 .help = "MPLS Bottom-of-Stack",
2936 .next = NEXT(item_mpls, NEXT_ENTRY(COMMON_UNSIGNED),
2938 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2944 .help = "match GRE header",
2945 .priv = PRIV_ITEM(GRE, sizeof(struct rte_flow_item_gre)),
2946 .next = NEXT(item_gre),
2949 [ITEM_GRE_PROTO] = {
2951 .help = "GRE protocol type",
2952 .next = NEXT(item_gre, NEXT_ENTRY(COMMON_UNSIGNED),
2954 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2957 [ITEM_GRE_C_RSVD0_VER] = {
2958 .name = "c_rsvd0_ver",
2960 "checksum (1b), undefined (1b), key bit (1b),"
2961 " sequence number (1b), reserved 0 (9b),"
2963 .next = NEXT(item_gre, NEXT_ENTRY(COMMON_UNSIGNED),
2965 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2968 [ITEM_GRE_C_BIT] = {
2970 .help = "checksum bit (C)",
2971 .next = NEXT(item_gre, NEXT_ENTRY(COMMON_BOOLEAN),
2973 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2975 "\x80\x00\x00\x00")),
2977 [ITEM_GRE_S_BIT] = {
2979 .help = "sequence number bit (S)",
2980 .next = NEXT(item_gre, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
2981 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2983 "\x10\x00\x00\x00")),
2985 [ITEM_GRE_K_BIT] = {
2987 .help = "key bit (K)",
2988 .next = NEXT(item_gre, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
2989 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2991 "\x20\x00\x00\x00")),
2995 .help = "fuzzy pattern match, expect faster than default",
2996 .priv = PRIV_ITEM(FUZZY,
2997 sizeof(struct rte_flow_item_fuzzy)),
2998 .next = NEXT(item_fuzzy),
3001 [ITEM_FUZZY_THRESH] = {
3003 .help = "match accuracy threshold",
3004 .next = NEXT(item_fuzzy, NEXT_ENTRY(COMMON_UNSIGNED),
3006 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_fuzzy,
3011 .help = "match GTP header",
3012 .priv = PRIV_ITEM(GTP, sizeof(struct rte_flow_item_gtp)),
3013 .next = NEXT(item_gtp),
3016 [ITEM_GTP_FLAGS] = {
3017 .name = "v_pt_rsv_flags",
3018 .help = "GTP flags",
3019 .next = NEXT(item_gtp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3020 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp,
3023 [ITEM_GTP_MSG_TYPE] = {
3025 .help = "GTP message type",
3026 .next = NEXT(item_gtp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3027 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp, msg_type)),
3031 .help = "tunnel endpoint identifier",
3032 .next = NEXT(item_gtp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3033 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp, teid)),
3037 .help = "match GTP header",
3038 .priv = PRIV_ITEM(GTPC, sizeof(struct rte_flow_item_gtp)),
3039 .next = NEXT(item_gtp),
3044 .help = "match GTP header",
3045 .priv = PRIV_ITEM(GTPU, sizeof(struct rte_flow_item_gtp)),
3046 .next = NEXT(item_gtp),
3051 .help = "match GENEVE header",
3052 .priv = PRIV_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)),
3053 .next = NEXT(item_geneve),
3056 [ITEM_GENEVE_VNI] = {
3058 .help = "virtual network identifier",
3059 .next = NEXT(item_geneve, NEXT_ENTRY(COMMON_UNSIGNED),
3061 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve, vni)),
3063 [ITEM_GENEVE_PROTO] = {
3065 .help = "GENEVE protocol type",
3066 .next = NEXT(item_geneve, NEXT_ENTRY(COMMON_UNSIGNED),
3068 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve,
3071 [ITEM_GENEVE_OPTLEN] = {
3073 .help = "GENEVE options length in dwords",
3074 .next = NEXT(item_geneve, NEXT_ENTRY(COMMON_UNSIGNED),
3076 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_geneve,
3077 ver_opt_len_o_c_rsvd0,
3080 [ITEM_VXLAN_GPE] = {
3081 .name = "vxlan-gpe",
3082 .help = "match VXLAN-GPE header",
3083 .priv = PRIV_ITEM(VXLAN_GPE,
3084 sizeof(struct rte_flow_item_vxlan_gpe)),
3085 .next = NEXT(item_vxlan_gpe),
3088 [ITEM_VXLAN_GPE_VNI] = {
3090 .help = "VXLAN-GPE identifier",
3091 .next = NEXT(item_vxlan_gpe, NEXT_ENTRY(COMMON_UNSIGNED),
3093 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
3096 [ITEM_ARP_ETH_IPV4] = {
3097 .name = "arp_eth_ipv4",
3098 .help = "match ARP header for Ethernet/IPv4",
3099 .priv = PRIV_ITEM(ARP_ETH_IPV4,
3100 sizeof(struct rte_flow_item_arp_eth_ipv4)),
3101 .next = NEXT(item_arp_eth_ipv4),
3104 [ITEM_ARP_ETH_IPV4_SHA] = {
3106 .help = "sender hardware address",
3107 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_MAC_ADDR),
3109 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
3112 [ITEM_ARP_ETH_IPV4_SPA] = {
3114 .help = "sender IPv4 address",
3115 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
3117 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
3120 [ITEM_ARP_ETH_IPV4_THA] = {
3122 .help = "target hardware address",
3123 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_MAC_ADDR),
3125 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
3128 [ITEM_ARP_ETH_IPV4_TPA] = {
3130 .help = "target IPv4 address",
3131 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
3133 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
3138 .help = "match presence of any IPv6 extension header",
3139 .priv = PRIV_ITEM(IPV6_EXT,
3140 sizeof(struct rte_flow_item_ipv6_ext)),
3141 .next = NEXT(item_ipv6_ext),
3144 [ITEM_IPV6_EXT_NEXT_HDR] = {
3146 .help = "next header",
3147 .next = NEXT(item_ipv6_ext, NEXT_ENTRY(COMMON_UNSIGNED),
3149 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_ext,
3152 [ITEM_IPV6_FRAG_EXT] = {
3153 .name = "ipv6_frag_ext",
3154 .help = "match presence of IPv6 fragment extension header",
3155 .priv = PRIV_ITEM(IPV6_FRAG_EXT,
3156 sizeof(struct rte_flow_item_ipv6_frag_ext)),
3157 .next = NEXT(item_ipv6_frag_ext),
3160 [ITEM_IPV6_FRAG_EXT_NEXT_HDR] = {
3162 .help = "next header",
3163 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(COMMON_UNSIGNED),
3165 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ipv6_frag_ext,
3168 [ITEM_IPV6_FRAG_EXT_FRAG_DATA] = {
3169 .name = "frag_data",
3170 .help = "fragment flags and offset",
3171 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(COMMON_UNSIGNED),
3173 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_frag_ext,
3176 [ITEM_IPV6_FRAG_EXT_ID] = {
3177 .name = "packet_id",
3178 .help = "fragment packet id",
3179 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(COMMON_UNSIGNED),
3181 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_frag_ext,
3186 .help = "match any ICMPv6 header",
3187 .priv = PRIV_ITEM(ICMP6, sizeof(struct rte_flow_item_icmp6)),
3188 .next = NEXT(item_icmp6),
3191 [ITEM_ICMP6_TYPE] = {
3193 .help = "ICMPv6 type",
3194 .next = NEXT(item_icmp6, NEXT_ENTRY(COMMON_UNSIGNED),
3196 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
3199 [ITEM_ICMP6_CODE] = {
3201 .help = "ICMPv6 code",
3202 .next = NEXT(item_icmp6, NEXT_ENTRY(COMMON_UNSIGNED),
3204 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
3207 [ITEM_ICMP6_ND_NS] = {
3208 .name = "icmp6_nd_ns",
3209 .help = "match ICMPv6 neighbor discovery solicitation",
3210 .priv = PRIV_ITEM(ICMP6_ND_NS,
3211 sizeof(struct rte_flow_item_icmp6_nd_ns)),
3212 .next = NEXT(item_icmp6_nd_ns),
3215 [ITEM_ICMP6_ND_NS_TARGET_ADDR] = {
3216 .name = "target_addr",
3217 .help = "target address",
3218 .next = NEXT(item_icmp6_nd_ns, NEXT_ENTRY(COMMON_IPV6_ADDR),
3220 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_ns,
3223 [ITEM_ICMP6_ND_NA] = {
3224 .name = "icmp6_nd_na",
3225 .help = "match ICMPv6 neighbor discovery advertisement",
3226 .priv = PRIV_ITEM(ICMP6_ND_NA,
3227 sizeof(struct rte_flow_item_icmp6_nd_na)),
3228 .next = NEXT(item_icmp6_nd_na),
3231 [ITEM_ICMP6_ND_NA_TARGET_ADDR] = {
3232 .name = "target_addr",
3233 .help = "target address",
3234 .next = NEXT(item_icmp6_nd_na, NEXT_ENTRY(COMMON_IPV6_ADDR),
3236 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_na,
3239 [ITEM_ICMP6_ND_OPT] = {
3240 .name = "icmp6_nd_opt",
3241 .help = "match presence of any ICMPv6 neighbor discovery"
3243 .priv = PRIV_ITEM(ICMP6_ND_OPT,
3244 sizeof(struct rte_flow_item_icmp6_nd_opt)),
3245 .next = NEXT(item_icmp6_nd_opt),
3248 [ITEM_ICMP6_ND_OPT_TYPE] = {
3250 .help = "ND option type",
3251 .next = NEXT(item_icmp6_nd_opt, NEXT_ENTRY(COMMON_UNSIGNED),
3253 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_opt,
3256 [ITEM_ICMP6_ND_OPT_SLA_ETH] = {
3257 .name = "icmp6_nd_opt_sla_eth",
3258 .help = "match ICMPv6 neighbor discovery source Ethernet"
3259 " link-layer address option",
3261 (ICMP6_ND_OPT_SLA_ETH,
3262 sizeof(struct rte_flow_item_icmp6_nd_opt_sla_eth)),
3263 .next = NEXT(item_icmp6_nd_opt_sla_eth),
3266 [ITEM_ICMP6_ND_OPT_SLA_ETH_SLA] = {
3268 .help = "source Ethernet LLA",
3269 .next = NEXT(item_icmp6_nd_opt_sla_eth,
3270 NEXT_ENTRY(COMMON_MAC_ADDR), item_param),
3271 .args = ARGS(ARGS_ENTRY_HTON
3272 (struct rte_flow_item_icmp6_nd_opt_sla_eth, sla)),
3274 [ITEM_ICMP6_ND_OPT_TLA_ETH] = {
3275 .name = "icmp6_nd_opt_tla_eth",
3276 .help = "match ICMPv6 neighbor discovery target Ethernet"
3277 " link-layer address option",
3279 (ICMP6_ND_OPT_TLA_ETH,
3280 sizeof(struct rte_flow_item_icmp6_nd_opt_tla_eth)),
3281 .next = NEXT(item_icmp6_nd_opt_tla_eth),
3284 [ITEM_ICMP6_ND_OPT_TLA_ETH_TLA] = {
3286 .help = "target Ethernet LLA",
3287 .next = NEXT(item_icmp6_nd_opt_tla_eth,
3288 NEXT_ENTRY(COMMON_MAC_ADDR), item_param),
3289 .args = ARGS(ARGS_ENTRY_HTON
3290 (struct rte_flow_item_icmp6_nd_opt_tla_eth, tla)),
3294 .help = "match metadata header",
3295 .priv = PRIV_ITEM(META, sizeof(struct rte_flow_item_meta)),
3296 .next = NEXT(item_meta),
3299 [ITEM_META_DATA] = {
3301 .help = "metadata value",
3302 .next = NEXT(item_meta, NEXT_ENTRY(COMMON_UNSIGNED),
3304 .args = ARGS(ARGS_ENTRY_MASK(struct rte_flow_item_meta,
3305 data, "\xff\xff\xff\xff")),
3309 .help = "match GRE key",
3310 .priv = PRIV_ITEM(GRE_KEY, sizeof(rte_be32_t)),
3311 .next = NEXT(item_gre_key),
3314 [ITEM_GRE_KEY_VALUE] = {
3316 .help = "key value",
3317 .next = NEXT(item_gre_key, NEXT_ENTRY(COMMON_UNSIGNED),
3319 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3323 .help = "match GTP extension header with type 0x85",
3324 .priv = PRIV_ITEM(GTP_PSC,
3325 sizeof(struct rte_flow_item_gtp_psc)),
3326 .next = NEXT(item_gtp_psc),
3329 [ITEM_GTP_PSC_QFI] = {
3331 .help = "QoS flow identifier",
3332 .next = NEXT(item_gtp_psc, NEXT_ENTRY(COMMON_UNSIGNED),
3334 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_gtp_psc,
3337 [ITEM_GTP_PSC_PDU_T] = {
3340 .next = NEXT(item_gtp_psc, NEXT_ENTRY(COMMON_UNSIGNED),
3342 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_gtp_psc,
3347 .help = "match PPPoE session header",
3348 .priv = PRIV_ITEM(PPPOES, sizeof(struct rte_flow_item_pppoe)),
3349 .next = NEXT(item_pppoes),
3354 .help = "match PPPoE discovery header",
3355 .priv = PRIV_ITEM(PPPOED, sizeof(struct rte_flow_item_pppoe)),
3356 .next = NEXT(item_pppoed),
3359 [ITEM_PPPOE_SEID] = {
3361 .help = "session identifier",
3362 .next = NEXT(item_pppoes, NEXT_ENTRY(COMMON_UNSIGNED),
3364 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pppoe,
3367 [ITEM_PPPOE_PROTO_ID] = {
3368 .name = "pppoe_proto_id",
3369 .help = "match PPPoE session protocol identifier",
3370 .priv = PRIV_ITEM(PPPOE_PROTO_ID,
3371 sizeof(struct rte_flow_item_pppoe_proto_id)),
3372 .next = NEXT(item_pppoe_proto_id, NEXT_ENTRY(COMMON_UNSIGNED),
3374 .args = ARGS(ARGS_ENTRY_HTON
3375 (struct rte_flow_item_pppoe_proto_id, proto_id)),
3380 .help = "matches higig2 header",
3381 .priv = PRIV_ITEM(HIGIG2,
3382 sizeof(struct rte_flow_item_higig2_hdr)),
3383 .next = NEXT(item_higig2),
3386 [ITEM_HIGIG2_CLASSIFICATION] = {
3387 .name = "classification",
3388 .help = "matches classification of higig2 header",
3389 .next = NEXT(item_higig2, NEXT_ENTRY(COMMON_UNSIGNED),
3391 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
3392 hdr.ppt1.classification)),
3394 [ITEM_HIGIG2_VID] = {
3396 .help = "matches vid of higig2 header",
3397 .next = NEXT(item_higig2, NEXT_ENTRY(COMMON_UNSIGNED),
3399 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
3404 .help = "match tag value",
3405 .priv = PRIV_ITEM(TAG, sizeof(struct rte_flow_item_tag)),
3406 .next = NEXT(item_tag),
3411 .help = "tag value to match",
3412 .next = NEXT(item_tag, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3413 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, data)),
3415 [ITEM_TAG_INDEX] = {
3417 .help = "index of tag array to match",
3418 .next = NEXT(item_tag, NEXT_ENTRY(COMMON_UNSIGNED),
3419 NEXT_ENTRY(ITEM_PARAM_IS)),
3420 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, index)),
3422 [ITEM_L2TPV3OIP] = {
3423 .name = "l2tpv3oip",
3424 .help = "match L2TPv3 over IP header",
3425 .priv = PRIV_ITEM(L2TPV3OIP,
3426 sizeof(struct rte_flow_item_l2tpv3oip)),
3427 .next = NEXT(item_l2tpv3oip),
3430 [ITEM_L2TPV3OIP_SESSION_ID] = {
3431 .name = "session_id",
3432 .help = "session identifier",
3433 .next = NEXT(item_l2tpv3oip, NEXT_ENTRY(COMMON_UNSIGNED),
3435 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv3oip,
3440 .help = "match ESP header",
3441 .priv = PRIV_ITEM(ESP, sizeof(struct rte_flow_item_esp)),
3442 .next = NEXT(item_esp),
3447 .help = "security policy index",
3448 .next = NEXT(item_esp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3449 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_esp,
3454 .help = "match AH header",
3455 .priv = PRIV_ITEM(AH, sizeof(struct rte_flow_item_ah)),
3456 .next = NEXT(item_ah),
3461 .help = "security parameters index",
3462 .next = NEXT(item_ah, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3463 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ah, spi)),
3467 .help = "match pfcp header",
3468 .priv = PRIV_ITEM(PFCP, sizeof(struct rte_flow_item_pfcp)),
3469 .next = NEXT(item_pfcp),
3472 [ITEM_PFCP_S_FIELD] = {
3475 .next = NEXT(item_pfcp, NEXT_ENTRY(COMMON_UNSIGNED),
3477 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp,
3480 [ITEM_PFCP_SEID] = {
3482 .help = "session endpoint identifier",
3483 .next = NEXT(item_pfcp, NEXT_ENTRY(COMMON_UNSIGNED),
3485 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp, seid)),
3489 .help = "match eCPRI header",
3490 .priv = PRIV_ITEM(ECPRI, sizeof(struct rte_flow_item_ecpri)),
3491 .next = NEXT(item_ecpri),
3494 [ITEM_ECPRI_COMMON] = {
3496 .help = "eCPRI common header",
3497 .next = NEXT(item_ecpri_common),
3499 [ITEM_ECPRI_COMMON_TYPE] = {
3501 .help = "type of common header",
3502 .next = NEXT(item_ecpri_common_type),
3503 .args = ARGS(ARG_ENTRY_HTON(struct rte_flow_item_ecpri)),
3505 [ITEM_ECPRI_COMMON_TYPE_IQ_DATA] = {
3507 .help = "Type #0: IQ Data",
3508 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
3510 .call = parse_vc_item_ecpri_type,
3512 [ITEM_ECPRI_MSG_IQ_DATA_PCID] = {
3514 .help = "Physical Channel ID",
3515 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
3516 ITEM_ECPRI_COMMON, ITEM_NEXT),
3517 NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3518 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3521 [ITEM_ECPRI_COMMON_TYPE_RTC_CTRL] = {
3523 .help = "Type #2: Real-Time Control Data",
3524 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
3526 .call = parse_vc_item_ecpri_type,
3528 [ITEM_ECPRI_MSG_RTC_CTRL_RTCID] = {
3530 .help = "Real-Time Control Data ID",
3531 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
3532 ITEM_ECPRI_COMMON, ITEM_NEXT),
3533 NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3534 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3537 [ITEM_ECPRI_COMMON_TYPE_DLY_MSR] = {
3538 .name = "delay_measure",
3539 .help = "Type #5: One-Way Delay Measurement",
3540 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
3542 .call = parse_vc_item_ecpri_type,
3544 [ITEM_ECPRI_MSG_DLY_MSR_MSRID] = {
3546 .help = "Measurement ID",
3547 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
3548 ITEM_ECPRI_COMMON, ITEM_NEXT),
3549 NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3550 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3553 [ITEM_GENEVE_OPT] = {
3554 .name = "geneve-opt",
3555 .help = "GENEVE header option",
3556 .priv = PRIV_ITEM(GENEVE_OPT,
3557 sizeof(struct rte_flow_item_geneve_opt) +
3558 ITEM_GENEVE_OPT_DATA_SIZE),
3559 .next = NEXT(item_geneve_opt),
3562 [ITEM_GENEVE_OPT_CLASS] = {
3564 .help = "GENEVE option class",
3565 .next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_UNSIGNED),
3567 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve_opt,
3570 [ITEM_GENEVE_OPT_TYPE] = {
3572 .help = "GENEVE option type",
3573 .next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_UNSIGNED),
3575 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt,
3578 [ITEM_GENEVE_OPT_LENGTH] = {
3580 .help = "GENEVE option data length (in 32b words)",
3581 .next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_UNSIGNED),
3583 .args = ARGS(ARGS_ENTRY_BOUNDED(
3584 struct rte_flow_item_geneve_opt, option_len,
3587 [ITEM_GENEVE_OPT_DATA] = {
3589 .help = "GENEVE option data pattern",
3590 .next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_HEX),
3592 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt, data),
3593 ARGS_ENTRY_ARB(0, 0),
3595 (sizeof(struct rte_flow_item_geneve_opt),
3596 ITEM_GENEVE_OPT_DATA_SIZE)),
3598 [ITEM_INTEGRITY] = {
3599 .name = "integrity",
3600 .help = "match packet integrity",
3601 .priv = PRIV_ITEM(INTEGRITY,
3602 sizeof(struct rte_flow_item_integrity)),
3603 .next = NEXT(item_integrity),
3606 [ITEM_INTEGRITY_LEVEL] = {
3608 .help = "integrity level",
3609 .next = NEXT(item_integrity_lv, NEXT_ENTRY(COMMON_UNSIGNED),
3611 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_integrity, level)),
3613 [ITEM_INTEGRITY_VALUE] = {
3615 .help = "integrity value",
3616 .next = NEXT(item_integrity_lv, NEXT_ENTRY(COMMON_UNSIGNED),
3618 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_integrity, value)),
3620 [ITEM_CONNTRACK] = {
3621 .name = "conntrack",
3622 .help = "conntrack state",
3623 .next = NEXT(NEXT_ENTRY(ITEM_NEXT), NEXT_ENTRY(COMMON_UNSIGNED),
3625 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_conntrack, flags)),
3627 [ITEM_PORT_REPRESENTOR] = {
3628 .name = "port_representor",
3629 .help = "match traffic entering the embedded switch from the given ethdev",
3630 .priv = PRIV_ITEM(PORT_REPRESENTOR,
3631 sizeof(struct rte_flow_item_ethdev)),
3632 .next = NEXT(item_port_representor),
3635 [ITEM_PORT_REPRESENTOR_PORT_ID] = {
3637 .help = "ethdev port ID",
3638 .next = NEXT(item_port_representor, NEXT_ENTRY(COMMON_UNSIGNED),
3640 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ethdev, port_id)),
3642 [ITEM_REPRESENTED_PORT] = {
3643 .name = "represented_port",
3644 .help = "match traffic entering the embedded switch from the entity represented by the given ethdev",
3645 .priv = PRIV_ITEM(REPRESENTED_PORT,
3646 sizeof(struct rte_flow_item_ethdev)),
3647 .next = NEXT(item_represented_port),
3650 [ITEM_REPRESENTED_PORT_ETHDEV_PORT_ID] = {
3651 .name = "ethdev_port_id",
3652 .help = "ethdev port ID",
3653 .next = NEXT(item_represented_port, NEXT_ENTRY(COMMON_UNSIGNED),
3655 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ethdev, port_id)),
3657 /* Validate/create actions. */
3660 .help = "submit a list of associated actions",
3661 .next = NEXT(next_action),
3666 .help = "specify next action",
3667 .next = NEXT(next_action),
3671 .help = "end list of actions",
3672 .priv = PRIV_ACTION(END, 0),
3677 .help = "no-op action",
3678 .priv = PRIV_ACTION(VOID, 0),
3679 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3682 [ACTION_PASSTHRU] = {
3684 .help = "let subsequent rule process matched packets",
3685 .priv = PRIV_ACTION(PASSTHRU, 0),
3686 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3691 .help = "redirect traffic to a given group",
3692 .priv = PRIV_ACTION(JUMP, sizeof(struct rte_flow_action_jump)),
3693 .next = NEXT(action_jump),
3696 [ACTION_JUMP_GROUP] = {
3698 .help = "group to redirect traffic to",
3699 .next = NEXT(action_jump, NEXT_ENTRY(COMMON_UNSIGNED)),
3700 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump, group)),
3701 .call = parse_vc_conf,
3705 .help = "attach 32 bit value to packets",
3706 .priv = PRIV_ACTION(MARK, sizeof(struct rte_flow_action_mark)),
3707 .next = NEXT(action_mark),
3710 [ACTION_MARK_ID] = {
3712 .help = "32 bit value to return with packets",
3713 .next = NEXT(action_mark, NEXT_ENTRY(COMMON_UNSIGNED)),
3714 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_mark, id)),
3715 .call = parse_vc_conf,
3719 .help = "flag packets",
3720 .priv = PRIV_ACTION(FLAG, 0),
3721 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3726 .help = "assign packets to a given queue index",
3727 .priv = PRIV_ACTION(QUEUE,
3728 sizeof(struct rte_flow_action_queue)),
3729 .next = NEXT(action_queue),
3732 [ACTION_QUEUE_INDEX] = {
3734 .help = "queue index to use",
3735 .next = NEXT(action_queue, NEXT_ENTRY(COMMON_UNSIGNED)),
3736 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_queue, index)),
3737 .call = parse_vc_conf,
3741 .help = "drop packets (note: passthru has priority)",
3742 .priv = PRIV_ACTION(DROP, 0),
3743 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3748 .help = "enable counters for this rule",
3749 .priv = PRIV_ACTION(COUNT,
3750 sizeof(struct rte_flow_action_count)),
3751 .next = NEXT(action_count),
3754 [ACTION_COUNT_ID] = {
3755 .name = "identifier",
3756 .help = "counter identifier to use",
3757 .next = NEXT(action_count, NEXT_ENTRY(COMMON_UNSIGNED)),
3758 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_count, id)),
3759 .call = parse_vc_conf,
3763 .help = "spread packets among several queues",
3764 .priv = PRIV_ACTION(RSS, sizeof(struct action_rss_data)),
3765 .next = NEXT(action_rss),
3766 .call = parse_vc_action_rss,
3768 [ACTION_RSS_FUNC] = {
3770 .help = "RSS hash function to apply",
3771 .next = NEXT(action_rss,
3772 NEXT_ENTRY(ACTION_RSS_FUNC_DEFAULT,
3773 ACTION_RSS_FUNC_TOEPLITZ,
3774 ACTION_RSS_FUNC_SIMPLE_XOR,
3775 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ)),
3777 [ACTION_RSS_FUNC_DEFAULT] = {
3779 .help = "default hash function",
3780 .call = parse_vc_action_rss_func,
3782 [ACTION_RSS_FUNC_TOEPLITZ] = {
3784 .help = "Toeplitz hash function",
3785 .call = parse_vc_action_rss_func,
3787 [ACTION_RSS_FUNC_SIMPLE_XOR] = {
3788 .name = "simple_xor",
3789 .help = "simple XOR hash function",
3790 .call = parse_vc_action_rss_func,
3792 [ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ] = {
3793 .name = "symmetric_toeplitz",
3794 .help = "Symmetric Toeplitz hash function",
3795 .call = parse_vc_action_rss_func,
3797 [ACTION_RSS_LEVEL] = {
3799 .help = "encapsulation level for \"types\"",
3800 .next = NEXT(action_rss, NEXT_ENTRY(COMMON_UNSIGNED)),
3801 .args = ARGS(ARGS_ENTRY_ARB
3802 (offsetof(struct action_rss_data, conf) +
3803 offsetof(struct rte_flow_action_rss, level),
3804 sizeof(((struct rte_flow_action_rss *)0)->
3807 [ACTION_RSS_TYPES] = {
3809 .help = "specific RSS hash types",
3810 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)),
3812 [ACTION_RSS_TYPE] = {
3814 .help = "RSS hash type",
3815 .call = parse_vc_action_rss_type,
3816 .comp = comp_vc_action_rss_type,
3818 [ACTION_RSS_KEY] = {
3820 .help = "RSS hash key",
3821 .next = NEXT(action_rss, NEXT_ENTRY(COMMON_HEX)),
3822 .args = ARGS(ARGS_ENTRY_ARB
3823 (offsetof(struct action_rss_data, conf) +
3824 offsetof(struct rte_flow_action_rss, key),
3825 sizeof(((struct rte_flow_action_rss *)0)->key)),
3827 (offsetof(struct action_rss_data, conf) +
3828 offsetof(struct rte_flow_action_rss, key_len),
3829 sizeof(((struct rte_flow_action_rss *)0)->
3831 ARGS_ENTRY(struct action_rss_data, key)),
3833 [ACTION_RSS_KEY_LEN] = {
3835 .help = "RSS hash key length in bytes",
3836 .next = NEXT(action_rss, NEXT_ENTRY(COMMON_UNSIGNED)),
3837 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
3838 (offsetof(struct action_rss_data, conf) +
3839 offsetof(struct rte_flow_action_rss, key_len),
3840 sizeof(((struct rte_flow_action_rss *)0)->
3843 RSS_HASH_KEY_LENGTH)),
3845 [ACTION_RSS_QUEUES] = {
3847 .help = "queue indices to use",
3848 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_QUEUE)),
3849 .call = parse_vc_conf,
3851 [ACTION_RSS_QUEUE] = {
3853 .help = "queue index",
3854 .call = parse_vc_action_rss_queue,
3855 .comp = comp_vc_action_rss_queue,
3859 .help = "direct traffic to physical function",
3860 .priv = PRIV_ACTION(PF, 0),
3861 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3866 .help = "direct traffic to a virtual function ID",
3867 .priv = PRIV_ACTION(VF, sizeof(struct rte_flow_action_vf)),
3868 .next = NEXT(action_vf),
3871 [ACTION_VF_ORIGINAL] = {
3873 .help = "use original VF ID if possible",
3874 .next = NEXT(action_vf, NEXT_ENTRY(COMMON_BOOLEAN)),
3875 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_vf,
3877 .call = parse_vc_conf,
3882 .next = NEXT(action_vf, NEXT_ENTRY(COMMON_UNSIGNED)),
3883 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)),
3884 .call = parse_vc_conf,
3886 [ACTION_PHY_PORT] = {
3888 .help = "direct packets to physical port index",
3889 .priv = PRIV_ACTION(PHY_PORT,
3890 sizeof(struct rte_flow_action_phy_port)),
3891 .next = NEXT(action_phy_port),
3894 [ACTION_PHY_PORT_ORIGINAL] = {
3896 .help = "use original port index if possible",
3897 .next = NEXT(action_phy_port, NEXT_ENTRY(COMMON_BOOLEAN)),
3898 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_phy_port,
3900 .call = parse_vc_conf,
3902 [ACTION_PHY_PORT_INDEX] = {
3904 .help = "physical port index",
3905 .next = NEXT(action_phy_port, NEXT_ENTRY(COMMON_UNSIGNED)),
3906 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_phy_port,
3908 .call = parse_vc_conf,
3910 [ACTION_PORT_ID] = {
3912 .help = "direct matching traffic to a given DPDK port ID",
3913 .priv = PRIV_ACTION(PORT_ID,
3914 sizeof(struct rte_flow_action_port_id)),
3915 .next = NEXT(action_port_id),
3918 [ACTION_PORT_ID_ORIGINAL] = {
3920 .help = "use original DPDK port ID if possible",
3921 .next = NEXT(action_port_id, NEXT_ENTRY(COMMON_BOOLEAN)),
3922 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_port_id,
3924 .call = parse_vc_conf,
3926 [ACTION_PORT_ID_ID] = {
3928 .help = "DPDK port ID",
3929 .next = NEXT(action_port_id, NEXT_ENTRY(COMMON_UNSIGNED)),
3930 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_port_id, id)),
3931 .call = parse_vc_conf,
3935 .help = "meter the directed packets at given id",
3936 .priv = PRIV_ACTION(METER,
3937 sizeof(struct rte_flow_action_meter)),
3938 .next = NEXT(action_meter),
3941 [ACTION_METER_COLOR] = {
3943 .help = "meter color for the packets",
3944 .priv = PRIV_ACTION(METER_COLOR,
3945 sizeof(struct rte_flow_action_meter_color)),
3946 .next = NEXT(action_meter_color),
3949 [ACTION_METER_COLOR_TYPE] = {
3951 .help = "specific meter color",
3952 .next = NEXT(NEXT_ENTRY(ACTION_NEXT),
3953 NEXT_ENTRY(ACTION_METER_COLOR_GREEN,
3954 ACTION_METER_COLOR_YELLOW,
3955 ACTION_METER_COLOR_RED)),
3957 [ACTION_METER_COLOR_GREEN] = {
3959 .help = "meter color green",
3960 .call = parse_vc_action_meter_color_type,
3962 [ACTION_METER_COLOR_YELLOW] = {
3964 .help = "meter color yellow",
3965 .call = parse_vc_action_meter_color_type,
3967 [ACTION_METER_COLOR_RED] = {
3969 .help = "meter color red",
3970 .call = parse_vc_action_meter_color_type,
3972 [ACTION_METER_ID] = {
3974 .help = "meter id to use",
3975 .next = NEXT(action_meter, NEXT_ENTRY(COMMON_UNSIGNED)),
3976 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter, mtr_id)),
3977 .call = parse_vc_conf,
3979 [ACTION_OF_SET_MPLS_TTL] = {
3980 .name = "of_set_mpls_ttl",
3981 .help = "OpenFlow's OFPAT_SET_MPLS_TTL",
3984 sizeof(struct rte_flow_action_of_set_mpls_ttl)),
3985 .next = NEXT(action_of_set_mpls_ttl),
3988 [ACTION_OF_SET_MPLS_TTL_MPLS_TTL] = {
3991 .next = NEXT(action_of_set_mpls_ttl,
3992 NEXT_ENTRY(COMMON_UNSIGNED)),
3993 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_mpls_ttl,
3995 .call = parse_vc_conf,
3997 [ACTION_OF_DEC_MPLS_TTL] = {
3998 .name = "of_dec_mpls_ttl",
3999 .help = "OpenFlow's OFPAT_DEC_MPLS_TTL",
4000 .priv = PRIV_ACTION(OF_DEC_MPLS_TTL, 0),
4001 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4004 [ACTION_OF_SET_NW_TTL] = {
4005 .name = "of_set_nw_ttl",
4006 .help = "OpenFlow's OFPAT_SET_NW_TTL",
4009 sizeof(struct rte_flow_action_of_set_nw_ttl)),
4010 .next = NEXT(action_of_set_nw_ttl),
4013 [ACTION_OF_SET_NW_TTL_NW_TTL] = {
4016 .next = NEXT(action_of_set_nw_ttl, NEXT_ENTRY(COMMON_UNSIGNED)),
4017 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_nw_ttl,
4019 .call = parse_vc_conf,
4021 [ACTION_OF_DEC_NW_TTL] = {
4022 .name = "of_dec_nw_ttl",
4023 .help = "OpenFlow's OFPAT_DEC_NW_TTL",
4024 .priv = PRIV_ACTION(OF_DEC_NW_TTL, 0),
4025 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4028 [ACTION_OF_COPY_TTL_OUT] = {
4029 .name = "of_copy_ttl_out",
4030 .help = "OpenFlow's OFPAT_COPY_TTL_OUT",
4031 .priv = PRIV_ACTION(OF_COPY_TTL_OUT, 0),
4032 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4035 [ACTION_OF_COPY_TTL_IN] = {
4036 .name = "of_copy_ttl_in",
4037 .help = "OpenFlow's OFPAT_COPY_TTL_IN",
4038 .priv = PRIV_ACTION(OF_COPY_TTL_IN, 0),
4039 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4042 [ACTION_OF_POP_VLAN] = {
4043 .name = "of_pop_vlan",
4044 .help = "OpenFlow's OFPAT_POP_VLAN",
4045 .priv = PRIV_ACTION(OF_POP_VLAN, 0),
4046 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4049 [ACTION_OF_PUSH_VLAN] = {
4050 .name = "of_push_vlan",
4051 .help = "OpenFlow's OFPAT_PUSH_VLAN",
4054 sizeof(struct rte_flow_action_of_push_vlan)),
4055 .next = NEXT(action_of_push_vlan),
4058 [ACTION_OF_PUSH_VLAN_ETHERTYPE] = {
4059 .name = "ethertype",
4060 .help = "EtherType",
4061 .next = NEXT(action_of_push_vlan, NEXT_ENTRY(COMMON_UNSIGNED)),
4062 .args = ARGS(ARGS_ENTRY_HTON
4063 (struct rte_flow_action_of_push_vlan,
4065 .call = parse_vc_conf,
4067 [ACTION_OF_SET_VLAN_VID] = {
4068 .name = "of_set_vlan_vid",
4069 .help = "OpenFlow's OFPAT_SET_VLAN_VID",
4072 sizeof(struct rte_flow_action_of_set_vlan_vid)),
4073 .next = NEXT(action_of_set_vlan_vid),
4076 [ACTION_OF_SET_VLAN_VID_VLAN_VID] = {
4079 .next = NEXT(action_of_set_vlan_vid,
4080 NEXT_ENTRY(COMMON_UNSIGNED)),
4081 .args = ARGS(ARGS_ENTRY_HTON
4082 (struct rte_flow_action_of_set_vlan_vid,
4084 .call = parse_vc_conf,
4086 [ACTION_OF_SET_VLAN_PCP] = {
4087 .name = "of_set_vlan_pcp",
4088 .help = "OpenFlow's OFPAT_SET_VLAN_PCP",
4091 sizeof(struct rte_flow_action_of_set_vlan_pcp)),
4092 .next = NEXT(action_of_set_vlan_pcp),
4095 [ACTION_OF_SET_VLAN_PCP_VLAN_PCP] = {
4097 .help = "VLAN priority",
4098 .next = NEXT(action_of_set_vlan_pcp,
4099 NEXT_ENTRY(COMMON_UNSIGNED)),
4100 .args = ARGS(ARGS_ENTRY_HTON
4101 (struct rte_flow_action_of_set_vlan_pcp,
4103 .call = parse_vc_conf,
4105 [ACTION_OF_POP_MPLS] = {
4106 .name = "of_pop_mpls",
4107 .help = "OpenFlow's OFPAT_POP_MPLS",
4108 .priv = PRIV_ACTION(OF_POP_MPLS,
4109 sizeof(struct rte_flow_action_of_pop_mpls)),
4110 .next = NEXT(action_of_pop_mpls),
4113 [ACTION_OF_POP_MPLS_ETHERTYPE] = {
4114 .name = "ethertype",
4115 .help = "EtherType",
4116 .next = NEXT(action_of_pop_mpls, NEXT_ENTRY(COMMON_UNSIGNED)),
4117 .args = ARGS(ARGS_ENTRY_HTON
4118 (struct rte_flow_action_of_pop_mpls,
4120 .call = parse_vc_conf,
4122 [ACTION_OF_PUSH_MPLS] = {
4123 .name = "of_push_mpls",
4124 .help = "OpenFlow's OFPAT_PUSH_MPLS",
4127 sizeof(struct rte_flow_action_of_push_mpls)),
4128 .next = NEXT(action_of_push_mpls),
4131 [ACTION_OF_PUSH_MPLS_ETHERTYPE] = {
4132 .name = "ethertype",
4133 .help = "EtherType",
4134 .next = NEXT(action_of_push_mpls, NEXT_ENTRY(COMMON_UNSIGNED)),
4135 .args = ARGS(ARGS_ENTRY_HTON
4136 (struct rte_flow_action_of_push_mpls,
4138 .call = parse_vc_conf,
4140 [ACTION_VXLAN_ENCAP] = {
4141 .name = "vxlan_encap",
4142 .help = "VXLAN encapsulation, uses configuration set by \"set"
4144 .priv = PRIV_ACTION(VXLAN_ENCAP,
4145 sizeof(struct action_vxlan_encap_data)),
4146 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4147 .call = parse_vc_action_vxlan_encap,
4149 [ACTION_VXLAN_DECAP] = {
4150 .name = "vxlan_decap",
4151 .help = "Performs a decapsulation action by stripping all"
4152 " headers of the VXLAN tunnel network overlay from the"
4154 .priv = PRIV_ACTION(VXLAN_DECAP, 0),
4155 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4158 [ACTION_NVGRE_ENCAP] = {
4159 .name = "nvgre_encap",
4160 .help = "NVGRE encapsulation, uses configuration set by \"set"
4162 .priv = PRIV_ACTION(NVGRE_ENCAP,
4163 sizeof(struct action_nvgre_encap_data)),
4164 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4165 .call = parse_vc_action_nvgre_encap,
4167 [ACTION_NVGRE_DECAP] = {
4168 .name = "nvgre_decap",
4169 .help = "Performs a decapsulation action by stripping all"
4170 " headers of the NVGRE tunnel network overlay from the"
4172 .priv = PRIV_ACTION(NVGRE_DECAP, 0),
4173 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4176 [ACTION_L2_ENCAP] = {
4178 .help = "l2 encap, uses configuration set by"
4179 " \"set l2_encap\"",
4180 .priv = PRIV_ACTION(RAW_ENCAP,
4181 sizeof(struct action_raw_encap_data)),
4182 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4183 .call = parse_vc_action_l2_encap,
4185 [ACTION_L2_DECAP] = {
4187 .help = "l2 decap, uses configuration set by"
4188 " \"set l2_decap\"",
4189 .priv = PRIV_ACTION(RAW_DECAP,
4190 sizeof(struct action_raw_decap_data)),
4191 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4192 .call = parse_vc_action_l2_decap,
4194 [ACTION_MPLSOGRE_ENCAP] = {
4195 .name = "mplsogre_encap",
4196 .help = "mplsogre encapsulation, uses configuration set by"
4197 " \"set mplsogre_encap\"",
4198 .priv = PRIV_ACTION(RAW_ENCAP,
4199 sizeof(struct action_raw_encap_data)),
4200 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4201 .call = parse_vc_action_mplsogre_encap,
4203 [ACTION_MPLSOGRE_DECAP] = {
4204 .name = "mplsogre_decap",
4205 .help = "mplsogre decapsulation, uses configuration set by"
4206 " \"set mplsogre_decap\"",
4207 .priv = PRIV_ACTION(RAW_DECAP,
4208 sizeof(struct action_raw_decap_data)),
4209 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4210 .call = parse_vc_action_mplsogre_decap,
4212 [ACTION_MPLSOUDP_ENCAP] = {
4213 .name = "mplsoudp_encap",
4214 .help = "mplsoudp encapsulation, uses configuration set by"
4215 " \"set mplsoudp_encap\"",
4216 .priv = PRIV_ACTION(RAW_ENCAP,
4217 sizeof(struct action_raw_encap_data)),
4218 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4219 .call = parse_vc_action_mplsoudp_encap,
4221 [ACTION_MPLSOUDP_DECAP] = {
4222 .name = "mplsoudp_decap",
4223 .help = "mplsoudp decapsulation, uses configuration set by"
4224 " \"set mplsoudp_decap\"",
4225 .priv = PRIV_ACTION(RAW_DECAP,
4226 sizeof(struct action_raw_decap_data)),
4227 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4228 .call = parse_vc_action_mplsoudp_decap,
4230 [ACTION_SET_IPV4_SRC] = {
4231 .name = "set_ipv4_src",
4232 .help = "Set a new IPv4 source address in the outermost"
4234 .priv = PRIV_ACTION(SET_IPV4_SRC,
4235 sizeof(struct rte_flow_action_set_ipv4)),
4236 .next = NEXT(action_set_ipv4_src),
4239 [ACTION_SET_IPV4_SRC_IPV4_SRC] = {
4240 .name = "ipv4_addr",
4241 .help = "new IPv4 source address to set",
4242 .next = NEXT(action_set_ipv4_src, NEXT_ENTRY(COMMON_IPV4_ADDR)),
4243 .args = ARGS(ARGS_ENTRY_HTON
4244 (struct rte_flow_action_set_ipv4, ipv4_addr)),
4245 .call = parse_vc_conf,
4247 [ACTION_SET_IPV4_DST] = {
4248 .name = "set_ipv4_dst",
4249 .help = "Set a new IPv4 destination address in the outermost"
4251 .priv = PRIV_ACTION(SET_IPV4_DST,
4252 sizeof(struct rte_flow_action_set_ipv4)),
4253 .next = NEXT(action_set_ipv4_dst),
4256 [ACTION_SET_IPV4_DST_IPV4_DST] = {
4257 .name = "ipv4_addr",
4258 .help = "new IPv4 destination address to set",
4259 .next = NEXT(action_set_ipv4_dst, NEXT_ENTRY(COMMON_IPV4_ADDR)),
4260 .args = ARGS(ARGS_ENTRY_HTON
4261 (struct rte_flow_action_set_ipv4, ipv4_addr)),
4262 .call = parse_vc_conf,
4264 [ACTION_SET_IPV6_SRC] = {
4265 .name = "set_ipv6_src",
4266 .help = "Set a new IPv6 source address in the outermost"
4268 .priv = PRIV_ACTION(SET_IPV6_SRC,
4269 sizeof(struct rte_flow_action_set_ipv6)),
4270 .next = NEXT(action_set_ipv6_src),
4273 [ACTION_SET_IPV6_SRC_IPV6_SRC] = {
4274 .name = "ipv6_addr",
4275 .help = "new IPv6 source address to set",
4276 .next = NEXT(action_set_ipv6_src, NEXT_ENTRY(COMMON_IPV6_ADDR)),
4277 .args = ARGS(ARGS_ENTRY_HTON
4278 (struct rte_flow_action_set_ipv6, ipv6_addr)),
4279 .call = parse_vc_conf,
4281 [ACTION_SET_IPV6_DST] = {
4282 .name = "set_ipv6_dst",
4283 .help = "Set a new IPv6 destination address in the outermost"
4285 .priv = PRIV_ACTION(SET_IPV6_DST,
4286 sizeof(struct rte_flow_action_set_ipv6)),
4287 .next = NEXT(action_set_ipv6_dst),
4290 [ACTION_SET_IPV6_DST_IPV6_DST] = {
4291 .name = "ipv6_addr",
4292 .help = "new IPv6 destination address to set",
4293 .next = NEXT(action_set_ipv6_dst, NEXT_ENTRY(COMMON_IPV6_ADDR)),
4294 .args = ARGS(ARGS_ENTRY_HTON
4295 (struct rte_flow_action_set_ipv6, ipv6_addr)),
4296 .call = parse_vc_conf,
4298 [ACTION_SET_TP_SRC] = {
4299 .name = "set_tp_src",
4300 .help = "set a new source port number in the outermost"
4302 .priv = PRIV_ACTION(SET_TP_SRC,
4303 sizeof(struct rte_flow_action_set_tp)),
4304 .next = NEXT(action_set_tp_src),
4307 [ACTION_SET_TP_SRC_TP_SRC] = {
4309 .help = "new source port number to set",
4310 .next = NEXT(action_set_tp_src, NEXT_ENTRY(COMMON_UNSIGNED)),
4311 .args = ARGS(ARGS_ENTRY_HTON
4312 (struct rte_flow_action_set_tp, port)),
4313 .call = parse_vc_conf,
4315 [ACTION_SET_TP_DST] = {
4316 .name = "set_tp_dst",
4317 .help = "set a new destination port number in the outermost"
4319 .priv = PRIV_ACTION(SET_TP_DST,
4320 sizeof(struct rte_flow_action_set_tp)),
4321 .next = NEXT(action_set_tp_dst),
4324 [ACTION_SET_TP_DST_TP_DST] = {
4326 .help = "new destination port number to set",
4327 .next = NEXT(action_set_tp_dst, NEXT_ENTRY(COMMON_UNSIGNED)),
4328 .args = ARGS(ARGS_ENTRY_HTON
4329 (struct rte_flow_action_set_tp, port)),
4330 .call = parse_vc_conf,
4332 [ACTION_MAC_SWAP] = {
4334 .help = "Swap the source and destination MAC addresses"
4335 " in the outermost Ethernet header",
4336 .priv = PRIV_ACTION(MAC_SWAP, 0),
4337 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4340 [ACTION_DEC_TTL] = {
4342 .help = "decrease network TTL if available",
4343 .priv = PRIV_ACTION(DEC_TTL, 0),
4344 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4347 [ACTION_SET_TTL] = {
4349 .help = "set ttl value",
4350 .priv = PRIV_ACTION(SET_TTL,
4351 sizeof(struct rte_flow_action_set_ttl)),
4352 .next = NEXT(action_set_ttl),
4355 [ACTION_SET_TTL_TTL] = {
4356 .name = "ttl_value",
4357 .help = "new ttl value to set",
4358 .next = NEXT(action_set_ttl, NEXT_ENTRY(COMMON_UNSIGNED)),
4359 .args = ARGS(ARGS_ENTRY_HTON
4360 (struct rte_flow_action_set_ttl, ttl_value)),
4361 .call = parse_vc_conf,
4363 [ACTION_SET_MAC_SRC] = {
4364 .name = "set_mac_src",
4365 .help = "set source mac address",
4366 .priv = PRIV_ACTION(SET_MAC_SRC,
4367 sizeof(struct rte_flow_action_set_mac)),
4368 .next = NEXT(action_set_mac_src),
4371 [ACTION_SET_MAC_SRC_MAC_SRC] = {
4373 .help = "new source mac address",
4374 .next = NEXT(action_set_mac_src, NEXT_ENTRY(COMMON_MAC_ADDR)),
4375 .args = ARGS(ARGS_ENTRY_HTON
4376 (struct rte_flow_action_set_mac, mac_addr)),
4377 .call = parse_vc_conf,
4379 [ACTION_SET_MAC_DST] = {
4380 .name = "set_mac_dst",
4381 .help = "set destination mac address",
4382 .priv = PRIV_ACTION(SET_MAC_DST,
4383 sizeof(struct rte_flow_action_set_mac)),
4384 .next = NEXT(action_set_mac_dst),
4387 [ACTION_SET_MAC_DST_MAC_DST] = {
4389 .help = "new destination mac address to set",
4390 .next = NEXT(action_set_mac_dst, NEXT_ENTRY(COMMON_MAC_ADDR)),
4391 .args = ARGS(ARGS_ENTRY_HTON
4392 (struct rte_flow_action_set_mac, mac_addr)),
4393 .call = parse_vc_conf,
4395 [ACTION_INC_TCP_SEQ] = {
4396 .name = "inc_tcp_seq",
4397 .help = "increase TCP sequence number",
4398 .priv = PRIV_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
4399 .next = NEXT(action_inc_tcp_seq),
4402 [ACTION_INC_TCP_SEQ_VALUE] = {
4404 .help = "the value to increase TCP sequence number by",
4405 .next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(COMMON_UNSIGNED)),
4406 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4407 .call = parse_vc_conf,
4409 [ACTION_DEC_TCP_SEQ] = {
4410 .name = "dec_tcp_seq",
4411 .help = "decrease TCP sequence number",
4412 .priv = PRIV_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
4413 .next = NEXT(action_dec_tcp_seq),
4416 [ACTION_DEC_TCP_SEQ_VALUE] = {
4418 .help = "the value to decrease TCP sequence number by",
4419 .next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(COMMON_UNSIGNED)),
4420 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4421 .call = parse_vc_conf,
4423 [ACTION_INC_TCP_ACK] = {
4424 .name = "inc_tcp_ack",
4425 .help = "increase TCP acknowledgment number",
4426 .priv = PRIV_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
4427 .next = NEXT(action_inc_tcp_ack),
4430 [ACTION_INC_TCP_ACK_VALUE] = {
4432 .help = "the value to increase TCP acknowledgment number by",
4433 .next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(COMMON_UNSIGNED)),
4434 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4435 .call = parse_vc_conf,
4437 [ACTION_DEC_TCP_ACK] = {
4438 .name = "dec_tcp_ack",
4439 .help = "decrease TCP acknowledgment number",
4440 .priv = PRIV_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
4441 .next = NEXT(action_dec_tcp_ack),
4444 [ACTION_DEC_TCP_ACK_VALUE] = {
4446 .help = "the value to decrease TCP acknowledgment number by",
4447 .next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(COMMON_UNSIGNED)),
4448 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4449 .call = parse_vc_conf,
4451 [ACTION_RAW_ENCAP] = {
4452 .name = "raw_encap",
4453 .help = "encapsulation data, defined by set raw_encap",
4454 .priv = PRIV_ACTION(RAW_ENCAP,
4455 sizeof(struct action_raw_encap_data)),
4456 .next = NEXT(action_raw_encap),
4457 .call = parse_vc_action_raw_encap,
4459 [ACTION_RAW_ENCAP_INDEX] = {
4461 .help = "the index of raw_encap_confs",
4462 .next = NEXT(NEXT_ENTRY(ACTION_RAW_ENCAP_INDEX_VALUE)),
4464 [ACTION_RAW_ENCAP_INDEX_VALUE] = {
4467 .help = "unsigned integer value",
4468 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4469 .call = parse_vc_action_raw_encap_index,
4470 .comp = comp_set_raw_index,
4472 [ACTION_RAW_DECAP] = {
4473 .name = "raw_decap",
4474 .help = "decapsulation data, defined by set raw_encap",
4475 .priv = PRIV_ACTION(RAW_DECAP,
4476 sizeof(struct action_raw_decap_data)),
4477 .next = NEXT(action_raw_decap),
4478 .call = parse_vc_action_raw_decap,
4480 [ACTION_RAW_DECAP_INDEX] = {
4482 .help = "the index of raw_encap_confs",
4483 .next = NEXT(NEXT_ENTRY(ACTION_RAW_DECAP_INDEX_VALUE)),
4485 [ACTION_RAW_DECAP_INDEX_VALUE] = {
4488 .help = "unsigned integer value",
4489 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4490 .call = parse_vc_action_raw_decap_index,
4491 .comp = comp_set_raw_index,
4493 [ACTION_MODIFY_FIELD] = {
4494 .name = "modify_field",
4495 .help = "modify destination field with data from source field",
4496 .priv = PRIV_ACTION(MODIFY_FIELD,
4497 sizeof(struct rte_flow_action_modify_field)),
4498 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_OP)),
4501 [ACTION_MODIFY_FIELD_OP] = {
4503 .help = "operation type",
4504 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_TYPE),
4505 NEXT_ENTRY(ACTION_MODIFY_FIELD_OP_VALUE)),
4506 .call = parse_vc_conf,
4508 [ACTION_MODIFY_FIELD_OP_VALUE] = {
4509 .name = "{operation}",
4510 .help = "operation type value",
4511 .call = parse_vc_modify_field_op,
4512 .comp = comp_set_modify_field_op,
4514 [ACTION_MODIFY_FIELD_DST_TYPE] = {
4516 .help = "destination field type",
4517 .next = NEXT(action_modify_field_dst,
4518 NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_TYPE_VALUE)),
4519 .call = parse_vc_conf,
4521 [ACTION_MODIFY_FIELD_DST_TYPE_VALUE] = {
4522 .name = "{dst_type}",
4523 .help = "destination field type value",
4524 .call = parse_vc_modify_field_id,
4525 .comp = comp_set_modify_field_id,
4527 [ACTION_MODIFY_FIELD_DST_LEVEL] = {
4528 .name = "dst_level",
4529 .help = "destination field level",
4530 .next = NEXT(action_modify_field_dst,
4531 NEXT_ENTRY(COMMON_UNSIGNED)),
4532 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4534 .call = parse_vc_conf,
4536 [ACTION_MODIFY_FIELD_DST_OFFSET] = {
4537 .name = "dst_offset",
4538 .help = "destination field bit offset",
4539 .next = NEXT(action_modify_field_dst,
4540 NEXT_ENTRY(COMMON_UNSIGNED)),
4541 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4543 .call = parse_vc_conf,
4545 [ACTION_MODIFY_FIELD_SRC_TYPE] = {
4547 .help = "source field type",
4548 .next = NEXT(action_modify_field_src,
4549 NEXT_ENTRY(ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)),
4550 .call = parse_vc_conf,
4552 [ACTION_MODIFY_FIELD_SRC_TYPE_VALUE] = {
4553 .name = "{src_type}",
4554 .help = "source field type value",
4555 .call = parse_vc_modify_field_id,
4556 .comp = comp_set_modify_field_id,
4558 [ACTION_MODIFY_FIELD_SRC_LEVEL] = {
4559 .name = "src_level",
4560 .help = "source field level",
4561 .next = NEXT(action_modify_field_src,
4562 NEXT_ENTRY(COMMON_UNSIGNED)),
4563 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4565 .call = parse_vc_conf,
4567 [ACTION_MODIFY_FIELD_SRC_OFFSET] = {
4568 .name = "src_offset",
4569 .help = "source field bit offset",
4570 .next = NEXT(action_modify_field_src,
4571 NEXT_ENTRY(COMMON_UNSIGNED)),
4572 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4574 .call = parse_vc_conf,
4576 [ACTION_MODIFY_FIELD_SRC_VALUE] = {
4577 .name = "src_value",
4578 .help = "source immediate value",
4579 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_WIDTH),
4580 NEXT_ENTRY(COMMON_UNSIGNED)),
4581 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4583 .call = parse_vc_conf,
4585 [ACTION_MODIFY_FIELD_WIDTH] = {
4587 .help = "number of bits to copy",
4588 .next = NEXT(NEXT_ENTRY(ACTION_NEXT),
4589 NEXT_ENTRY(COMMON_UNSIGNED)),
4590 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4592 .call = parse_vc_conf,
4594 /* Top level command. */
4597 .help = "set raw encap/decap/sample data",
4598 .type = "set raw_encap|raw_decap <index> <pattern>"
4599 " or set sample_actions <index> <action>",
4600 .next = NEXT(NEXT_ENTRY
4603 SET_SAMPLE_ACTIONS)),
4604 .call = parse_set_init,
4606 /* Sub-level commands. */
4608 .name = "raw_encap",
4609 .help = "set raw encap data",
4610 .next = NEXT(next_set_raw),
4611 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4612 (offsetof(struct buffer, port),
4613 sizeof(((struct buffer *)0)->port),
4614 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
4615 .call = parse_set_raw_encap_decap,
4618 .name = "raw_decap",
4619 .help = "set raw decap data",
4620 .next = NEXT(next_set_raw),
4621 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4622 (offsetof(struct buffer, port),
4623 sizeof(((struct buffer *)0)->port),
4624 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
4625 .call = parse_set_raw_encap_decap,
4629 .type = "COMMON_UNSIGNED",
4630 .help = "index of raw_encap/raw_decap data",
4631 .next = NEXT(next_item),
4634 [SET_SAMPLE_INDEX] = {
4637 .help = "index of sample actions",
4638 .next = NEXT(next_action_sample),
4641 [SET_SAMPLE_ACTIONS] = {
4642 .name = "sample_actions",
4643 .help = "set sample actions list",
4644 .next = NEXT(NEXT_ENTRY(SET_SAMPLE_INDEX)),
4645 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4646 (offsetof(struct buffer, port),
4647 sizeof(((struct buffer *)0)->port),
4648 0, RAW_SAMPLE_CONFS_MAX_NUM - 1)),
4649 .call = parse_set_sample_action,
4651 [ACTION_SET_TAG] = {
4654 .priv = PRIV_ACTION(SET_TAG,
4655 sizeof(struct rte_flow_action_set_tag)),
4656 .next = NEXT(action_set_tag),
4659 [ACTION_SET_TAG_INDEX] = {
4661 .help = "index of tag array",
4662 .next = NEXT(action_set_tag, NEXT_ENTRY(COMMON_UNSIGNED)),
4663 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_set_tag, index)),
4664 .call = parse_vc_conf,
4666 [ACTION_SET_TAG_DATA] = {
4668 .help = "tag value",
4669 .next = NEXT(action_set_tag, NEXT_ENTRY(COMMON_UNSIGNED)),
4670 .args = ARGS(ARGS_ENTRY
4671 (struct rte_flow_action_set_tag, data)),
4672 .call = parse_vc_conf,
4674 [ACTION_SET_TAG_MASK] = {
4676 .help = "mask for tag value",
4677 .next = NEXT(action_set_tag, NEXT_ENTRY(COMMON_UNSIGNED)),
4678 .args = ARGS(ARGS_ENTRY
4679 (struct rte_flow_action_set_tag, mask)),
4680 .call = parse_vc_conf,
4682 [ACTION_SET_META] = {
4684 .help = "set metadata",
4685 .priv = PRIV_ACTION(SET_META,
4686 sizeof(struct rte_flow_action_set_meta)),
4687 .next = NEXT(action_set_meta),
4688 .call = parse_vc_action_set_meta,
4690 [ACTION_SET_META_DATA] = {
4692 .help = "metadata value",
4693 .next = NEXT(action_set_meta, NEXT_ENTRY(COMMON_UNSIGNED)),
4694 .args = ARGS(ARGS_ENTRY
4695 (struct rte_flow_action_set_meta, data)),
4696 .call = parse_vc_conf,
4698 [ACTION_SET_META_MASK] = {
4700 .help = "mask for metadata value",
4701 .next = NEXT(action_set_meta, NEXT_ENTRY(COMMON_UNSIGNED)),
4702 .args = ARGS(ARGS_ENTRY
4703 (struct rte_flow_action_set_meta, mask)),
4704 .call = parse_vc_conf,
4706 [ACTION_SET_IPV4_DSCP] = {
4707 .name = "set_ipv4_dscp",
4708 .help = "set DSCP value",
4709 .priv = PRIV_ACTION(SET_IPV4_DSCP,
4710 sizeof(struct rte_flow_action_set_dscp)),
4711 .next = NEXT(action_set_ipv4_dscp),
4714 [ACTION_SET_IPV4_DSCP_VALUE] = {
4715 .name = "dscp_value",
4716 .help = "new IPv4 DSCP value to set",
4717 .next = NEXT(action_set_ipv4_dscp, NEXT_ENTRY(COMMON_UNSIGNED)),
4718 .args = ARGS(ARGS_ENTRY
4719 (struct rte_flow_action_set_dscp, dscp)),
4720 .call = parse_vc_conf,
4722 [ACTION_SET_IPV6_DSCP] = {
4723 .name = "set_ipv6_dscp",
4724 .help = "set DSCP value",
4725 .priv = PRIV_ACTION(SET_IPV6_DSCP,
4726 sizeof(struct rte_flow_action_set_dscp)),
4727 .next = NEXT(action_set_ipv6_dscp),
4730 [ACTION_SET_IPV6_DSCP_VALUE] = {
4731 .name = "dscp_value",
4732 .help = "new IPv6 DSCP value to set",
4733 .next = NEXT(action_set_ipv6_dscp, NEXT_ENTRY(COMMON_UNSIGNED)),
4734 .args = ARGS(ARGS_ENTRY
4735 (struct rte_flow_action_set_dscp, dscp)),
4736 .call = parse_vc_conf,
4740 .help = "set a specific metadata header",
4741 .next = NEXT(action_age),
4742 .priv = PRIV_ACTION(AGE,
4743 sizeof(struct rte_flow_action_age)),
4746 [ACTION_AGE_TIMEOUT] = {
4748 .help = "flow age timeout value",
4749 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_age,
4751 .next = NEXT(action_age, NEXT_ENTRY(COMMON_UNSIGNED)),
4752 .call = parse_vc_conf,
4756 .help = "set a sample action",
4757 .next = NEXT(action_sample),
4758 .priv = PRIV_ACTION(SAMPLE,
4759 sizeof(struct action_sample_data)),
4760 .call = parse_vc_action_sample,
4762 [ACTION_SAMPLE_RATIO] = {
4764 .help = "flow sample ratio value",
4765 .next = NEXT(action_sample, NEXT_ENTRY(COMMON_UNSIGNED)),
4766 .args = ARGS(ARGS_ENTRY_ARB
4767 (offsetof(struct action_sample_data, conf) +
4768 offsetof(struct rte_flow_action_sample, ratio),
4769 sizeof(((struct rte_flow_action_sample *)0)->
4772 [ACTION_SAMPLE_INDEX] = {
4774 .help = "the index of sample actions list",
4775 .next = NEXT(NEXT_ENTRY(ACTION_SAMPLE_INDEX_VALUE)),
4777 [ACTION_SAMPLE_INDEX_VALUE] = {
4779 .type = "COMMON_UNSIGNED",
4780 .help = "unsigned integer value",
4781 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4782 .call = parse_vc_action_sample_index,
4783 .comp = comp_set_sample_index,
4785 [ACTION_CONNTRACK] = {
4786 .name = "conntrack",
4787 .help = "create a conntrack object",
4788 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4789 .priv = PRIV_ACTION(CONNTRACK,
4790 sizeof(struct rte_flow_action_conntrack)),
4793 [ACTION_CONNTRACK_UPDATE] = {
4794 .name = "conntrack_update",
4795 .help = "update a conntrack object",
4796 .next = NEXT(action_update_conntrack),
4797 .priv = PRIV_ACTION(CONNTRACK,
4798 sizeof(struct rte_flow_modify_conntrack)),
4801 [ACTION_CONNTRACK_UPDATE_DIR] = {
4803 .help = "update a conntrack object direction",
4804 .next = NEXT(action_update_conntrack),
4805 .call = parse_vc_action_conntrack_update,
4807 [ACTION_CONNTRACK_UPDATE_CTX] = {
4809 .help = "update a conntrack object context",
4810 .next = NEXT(action_update_conntrack),
4811 .call = parse_vc_action_conntrack_update,
4813 /* Indirect action destroy arguments. */
4814 [INDIRECT_ACTION_DESTROY_ID] = {
4815 .name = "action_id",
4816 .help = "specify a indirect action id to destroy",
4817 .next = NEXT(next_ia_destroy_attr,
4818 NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
4819 .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
4820 args.ia_destroy.action_id)),
4821 .call = parse_ia_destroy,
4823 /* Indirect action create arguments. */
4824 [INDIRECT_ACTION_CREATE_ID] = {
4825 .name = "action_id",
4826 .help = "specify a indirect action id to create",
4827 .next = NEXT(next_ia_create_attr,
4828 NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
4829 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
4831 [ACTION_INDIRECT] = {
4833 .help = "apply indirect action by id",
4834 .priv = PRIV_ACTION(INDIRECT, 0),
4835 .next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_ID2PTR)),
4836 .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
4839 [INDIRECT_ACTION_ID2PTR] = {
4840 .name = "{action_id}",
4841 .type = "INDIRECT_ACTION_ID",
4842 .help = "indirect action id",
4843 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4844 .call = parse_ia_id2ptr,
4847 [INDIRECT_ACTION_INGRESS] = {
4849 .help = "affect rule to ingress",
4850 .next = NEXT(next_ia_create_attr),
4853 [INDIRECT_ACTION_EGRESS] = {
4855 .help = "affect rule to egress",
4856 .next = NEXT(next_ia_create_attr),
4859 [INDIRECT_ACTION_TRANSFER] = {
4861 .help = "affect rule to transfer",
4862 .next = NEXT(next_ia_create_attr),
4865 [INDIRECT_ACTION_SPEC] = {
4867 .help = "specify action to create indirect handle",
4868 .next = NEXT(next_action),
4871 .name = "g_actions",
4872 .help = "submit a list of associated actions for green",
4873 .next = NEXT(next_action),
4877 .name = "y_actions",
4878 .help = "submit a list of associated actions for yellow",
4879 .next = NEXT(next_action),
4882 .name = "r_actions",
4883 .help = "submit a list of associated actions for red",
4884 .next = NEXT(next_action),
4887 /* Top-level command. */
4890 .type = "port meter policy {port_id} {arg}",
4891 .help = "add port meter policy",
4892 .next = NEXT(NEXT_ENTRY(ITEM_POL_PORT)),
4895 /* Sub-level commands. */
4898 .help = "add port meter policy",
4899 .next = NEXT(NEXT_ENTRY(ITEM_POL_METER)),
4901 [ITEM_POL_METER] = {
4903 .help = "add port meter policy",
4904 .next = NEXT(NEXT_ENTRY(ITEM_POL_POLICY)),
4906 [ITEM_POL_POLICY] = {
4908 .help = "add port meter policy",
4909 .next = NEXT(NEXT_ENTRY(ACTION_POL_R),
4910 NEXT_ENTRY(ACTION_POL_Y),
4911 NEXT_ENTRY(ACTION_POL_G),
4912 NEXT_ENTRY(COMMON_POLICY_ID),
4913 NEXT_ENTRY(COMMON_PORT_ID)),
4914 .args = ARGS(ARGS_ENTRY(struct buffer, args.policy.policy_id),
4915 ARGS_ENTRY(struct buffer, port)),
4920 /** Remove and return last entry from argument stack. */
4921 static const struct arg *
4922 pop_args(struct context *ctx)
4924 return ctx->args_num ? ctx->args[--ctx->args_num] : NULL;
4927 /** Add entry on top of the argument stack. */
4929 push_args(struct context *ctx, const struct arg *arg)
4931 if (ctx->args_num == CTX_STACK_SIZE)
4933 ctx->args[ctx->args_num++] = arg;
4937 /** Spread value into buffer according to bit-mask. */
4939 arg_entry_bf_fill(void *dst, uintmax_t val, const struct arg *arg)
4941 uint32_t i = arg->size;
4949 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
4958 unsigned int shift = 0;
4959 uint8_t *buf = (uint8_t *)dst + arg->offset + (i -= sub);
4961 for (shift = 0; arg->mask[i] >> shift; ++shift) {
4962 if (!(arg->mask[i] & (1 << shift)))
4967 *buf &= ~(1 << shift);
4968 *buf |= (val & 1) << shift;
4976 /** Compare a string with a partial one of a given length. */
4978 strcmp_partial(const char *full, const char *partial, size_t partial_len)
4980 int r = strncmp(full, partial, partial_len);
4984 if (strlen(full) <= partial_len)
4986 return full[partial_len];
4990 * Parse a prefix length and generate a bit-mask.
4992 * Last argument (ctx->args) is retrieved to determine mask size, storage
4993 * location and whether the result must use network byte ordering.
4996 parse_prefix(struct context *ctx, const struct token *token,
4997 const char *str, unsigned int len,
4998 void *buf, unsigned int size)
5000 const struct arg *arg = pop_args(ctx);
5001 static const uint8_t conv[] = "\x00\x80\xc0\xe0\xf0\xf8\xfc\xfe\xff";
5008 /* Argument is expected. */
5012 u = strtoumax(str, &end, 0);
5013 if (errno || (size_t)(end - str) != len)
5018 extra = arg_entry_bf_fill(NULL, 0, arg);
5027 if (!arg_entry_bf_fill(ctx->object, v, arg) ||
5028 !arg_entry_bf_fill(ctx->objmask, -1, arg))
5035 if (bytes > size || bytes + !!extra > size)
5039 buf = (uint8_t *)ctx->object + arg->offset;
5040 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
5042 memset((uint8_t *)buf + size - bytes, 0xff, bytes);
5043 memset(buf, 0x00, size - bytes);
5045 ((uint8_t *)buf)[size - bytes - 1] = conv[extra];
5049 memset(buf, 0xff, bytes);
5050 memset((uint8_t *)buf + bytes, 0x00, size - bytes);
5052 ((uint8_t *)buf)[bytes] = conv[extra];
5055 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
5058 push_args(ctx, arg);
5062 /** Default parsing function for token name matching. */
5064 parse_default(struct context *ctx, const struct token *token,
5065 const char *str, unsigned int len,
5066 void *buf, unsigned int size)
5071 if (strcmp_partial(token->name, str, len))
5076 /** Parse flow command, initialize output buffer for subsequent tokens. */
5078 parse_init(struct context *ctx, const struct token *token,
5079 const char *str, unsigned int len,
5080 void *buf, unsigned int size)
5082 struct buffer *out = buf;
5084 /* Token name must match. */
5085 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5087 /* Nothing else to do if there is no buffer. */
5090 /* Make sure buffer is large enough. */
5091 if (size < sizeof(*out))
5093 /* Initialize buffer. */
5094 memset(out, 0x00, sizeof(*out));
5095 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
5098 ctx->objmask = NULL;
5102 /** Parse tokens for indirect action commands. */
5104 parse_ia(struct context *ctx, const struct token *token,
5105 const char *str, unsigned int len,
5106 void *buf, unsigned int size)
5108 struct buffer *out = buf;
5110 /* Token name must match. */
5111 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5113 /* Nothing else to do if there is no buffer. */
5116 if (!out->command) {
5117 if (ctx->curr != INDIRECT_ACTION)
5119 if (sizeof(*out) > size)
5121 out->command = ctx->curr;
5124 ctx->objmask = NULL;
5125 out->args.vc.data = (uint8_t *)out + size;
5128 switch (ctx->curr) {
5129 case INDIRECT_ACTION_CREATE:
5130 case INDIRECT_ACTION_UPDATE:
5131 out->args.vc.actions =
5132 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5134 out->args.vc.attr.group = UINT32_MAX;
5136 case INDIRECT_ACTION_QUERY:
5137 out->command = ctx->curr;
5140 ctx->objmask = NULL;
5142 case INDIRECT_ACTION_EGRESS:
5143 out->args.vc.attr.egress = 1;
5145 case INDIRECT_ACTION_INGRESS:
5146 out->args.vc.attr.ingress = 1;
5148 case INDIRECT_ACTION_TRANSFER:
5149 out->args.vc.attr.transfer = 1;
5157 /** Parse tokens for indirect action destroy command. */
5159 parse_ia_destroy(struct context *ctx, const struct token *token,
5160 const char *str, unsigned int len,
5161 void *buf, unsigned int size)
5163 struct buffer *out = buf;
5164 uint32_t *action_id;
5166 /* Token name must match. */
5167 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5169 /* Nothing else to do if there is no buffer. */
5172 if (!out->command || out->command == INDIRECT_ACTION) {
5173 if (ctx->curr != INDIRECT_ACTION_DESTROY)
5175 if (sizeof(*out) > size)
5177 out->command = ctx->curr;
5180 ctx->objmask = NULL;
5181 out->args.ia_destroy.action_id =
5182 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5186 action_id = out->args.ia_destroy.action_id
5187 + out->args.ia_destroy.action_id_n++;
5188 if ((uint8_t *)action_id > (uint8_t *)out + size)
5191 ctx->object = action_id;
5192 ctx->objmask = NULL;
5196 /** Parse tokens for meter policy action commands. */
5198 parse_mp(struct context *ctx, const struct token *token,
5199 const char *str, unsigned int len,
5200 void *buf, unsigned int size)
5202 struct buffer *out = buf;
5204 /* Token name must match. */
5205 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5207 /* Nothing else to do if there is no buffer. */
5210 if (!out->command) {
5211 if (ctx->curr != ITEM_POL_POLICY)
5213 if (sizeof(*out) > size)
5215 out->command = ctx->curr;
5218 ctx->objmask = NULL;
5219 out->args.vc.data = (uint8_t *)out + size;
5222 switch (ctx->curr) {
5224 out->args.vc.actions =
5225 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5227 out->command = ctx->curr;
5230 ctx->objmask = NULL;
5237 /** Parse tokens for validate/create commands. */
5239 parse_vc(struct context *ctx, const struct token *token,
5240 const char *str, unsigned int len,
5241 void *buf, unsigned int size)
5243 struct buffer *out = buf;
5247 /* Token name must match. */
5248 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5250 /* Nothing else to do if there is no buffer. */
5253 if (!out->command) {
5254 if (ctx->curr != VALIDATE && ctx->curr != CREATE)
5256 if (sizeof(*out) > size)
5258 out->command = ctx->curr;
5261 ctx->objmask = NULL;
5262 out->args.vc.data = (uint8_t *)out + size;
5266 switch (ctx->curr) {
5268 ctx->object = &out->args.vc.attr;
5271 case VC_TUNNEL_MATCH:
5272 ctx->object = &out->args.vc.tunnel_ops;
5275 ctx->objmask = NULL;
5276 switch (ctx->curr) {
5281 out->args.vc.tunnel_ops.enabled = 1;
5282 out->args.vc.tunnel_ops.actions = 1;
5284 case VC_TUNNEL_MATCH:
5285 out->args.vc.tunnel_ops.enabled = 1;
5286 out->args.vc.tunnel_ops.items = 1;
5289 out->args.vc.attr.ingress = 1;
5292 out->args.vc.attr.egress = 1;
5295 out->args.vc.attr.transfer = 1;
5298 out->args.vc.pattern =
5299 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5301 ctx->object = out->args.vc.pattern;
5302 ctx->objmask = NULL;
5305 out->args.vc.actions =
5306 (void *)RTE_ALIGN_CEIL((uintptr_t)
5307 (out->args.vc.pattern +
5308 out->args.vc.pattern_n),
5310 ctx->object = out->args.vc.actions;
5311 ctx->objmask = NULL;
5318 if (!out->args.vc.actions) {
5319 const struct parse_item_priv *priv = token->priv;
5320 struct rte_flow_item *item =
5321 out->args.vc.pattern + out->args.vc.pattern_n;
5323 data_size = priv->size * 3; /* spec, last, mask */
5324 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
5325 (out->args.vc.data - data_size),
5327 if ((uint8_t *)item + sizeof(*item) > data)
5329 *item = (struct rte_flow_item){
5332 ++out->args.vc.pattern_n;
5334 ctx->objmask = NULL;
5336 const struct parse_action_priv *priv = token->priv;
5337 struct rte_flow_action *action =
5338 out->args.vc.actions + out->args.vc.actions_n;
5340 data_size = priv->size; /* configuration */
5341 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
5342 (out->args.vc.data - data_size),
5344 if ((uint8_t *)action + sizeof(*action) > data)
5346 *action = (struct rte_flow_action){
5348 .conf = data_size ? data : NULL,
5350 ++out->args.vc.actions_n;
5351 ctx->object = action;
5352 ctx->objmask = NULL;
5354 memset(data, 0, data_size);
5355 out->args.vc.data = data;
5356 ctx->objdata = data_size;
5360 /** Parse pattern item parameter type. */
5362 parse_vc_spec(struct context *ctx, const struct token *token,
5363 const char *str, unsigned int len,
5364 void *buf, unsigned int size)
5366 struct buffer *out = buf;
5367 struct rte_flow_item *item;
5373 /* Token name must match. */
5374 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5376 /* Parse parameter types. */
5377 switch (ctx->curr) {
5378 static const enum index prefix[] = NEXT_ENTRY(COMMON_PREFIX);
5384 case ITEM_PARAM_SPEC:
5387 case ITEM_PARAM_LAST:
5390 case ITEM_PARAM_PREFIX:
5391 /* Modify next token to expect a prefix. */
5392 if (ctx->next_num < 2)
5394 ctx->next[ctx->next_num - 2] = prefix;
5396 case ITEM_PARAM_MASK:
5402 /* Nothing else to do if there is no buffer. */
5405 if (!out->args.vc.pattern_n)
5407 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
5408 data_size = ctx->objdata / 3; /* spec, last, mask */
5409 /* Point to selected object. */
5410 ctx->object = out->args.vc.data + (data_size * index);
5412 ctx->objmask = out->args.vc.data + (data_size * 2); /* mask */
5413 item->mask = ctx->objmask;
5415 ctx->objmask = NULL;
5416 /* Update relevant item pointer. */
5417 *((const void **[]){ &item->spec, &item->last, &item->mask })[index] =
5422 /** Parse action configuration field. */
5424 parse_vc_conf(struct context *ctx, const struct token *token,
5425 const char *str, unsigned int len,
5426 void *buf, unsigned int size)
5428 struct buffer *out = buf;
5431 /* Token name must match. */
5432 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5434 /* Nothing else to do if there is no buffer. */
5437 /* Point to selected object. */
5438 ctx->object = out->args.vc.data;
5439 ctx->objmask = NULL;
5443 /** Parse eCPRI common header type field. */
5445 parse_vc_item_ecpri_type(struct context *ctx, const struct token *token,
5446 const char *str, unsigned int len,
5447 void *buf, unsigned int size)
5449 struct rte_flow_item_ecpri *ecpri;
5450 struct rte_flow_item_ecpri *ecpri_mask;
5451 struct rte_flow_item *item;
5454 struct buffer *out = buf;
5455 const struct arg *arg;
5458 /* Token name must match. */
5459 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5461 switch (ctx->curr) {
5462 case ITEM_ECPRI_COMMON_TYPE_IQ_DATA:
5463 msg_type = RTE_ECPRI_MSG_TYPE_IQ_DATA;
5465 case ITEM_ECPRI_COMMON_TYPE_RTC_CTRL:
5466 msg_type = RTE_ECPRI_MSG_TYPE_RTC_CTRL;
5468 case ITEM_ECPRI_COMMON_TYPE_DLY_MSR:
5469 msg_type = RTE_ECPRI_MSG_TYPE_DLY_MSR;
5476 arg = pop_args(ctx);
5479 ecpri = (struct rte_flow_item_ecpri *)out->args.vc.data;
5480 ecpri->hdr.common.type = msg_type;
5481 data_size = ctx->objdata / 3; /* spec, last, mask */
5482 ecpri_mask = (struct rte_flow_item_ecpri *)(out->args.vc.data +
5484 ecpri_mask->hdr.common.type = 0xFF;
5486 ecpri->hdr.common.u32 = rte_cpu_to_be_32(ecpri->hdr.common.u32);
5487 ecpri_mask->hdr.common.u32 =
5488 rte_cpu_to_be_32(ecpri_mask->hdr.common.u32);
5490 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
5492 item->mask = ecpri_mask;
5496 /** Parse meter color action type. */
5498 parse_vc_action_meter_color_type(struct context *ctx, const struct token *token,
5499 const char *str, unsigned int len,
5500 void *buf, unsigned int size)
5502 struct rte_flow_action *action_data;
5503 struct rte_flow_action_meter_color *conf;
5504 enum rte_color color;
5508 /* Token name must match. */
5509 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5511 switch (ctx->curr) {
5512 case ACTION_METER_COLOR_GREEN:
5513 color = RTE_COLOR_GREEN;
5515 case ACTION_METER_COLOR_YELLOW:
5516 color = RTE_COLOR_YELLOW;
5518 case ACTION_METER_COLOR_RED:
5519 color = RTE_COLOR_RED;
5527 action_data = ctx->object;
5528 conf = (struct rte_flow_action_meter_color *)
5529 (uintptr_t)(action_data->conf);
5530 conf->color = color;
5534 /** Parse RSS action. */
5536 parse_vc_action_rss(struct context *ctx, const struct token *token,
5537 const char *str, unsigned int len,
5538 void *buf, unsigned int size)
5540 struct buffer *out = buf;
5541 struct rte_flow_action *action;
5542 struct action_rss_data *action_rss_data;
5546 ret = parse_vc(ctx, token, str, len, buf, size);
5549 /* Nothing else to do if there is no buffer. */
5552 if (!out->args.vc.actions_n)
5554 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5555 /* Point to selected object. */
5556 ctx->object = out->args.vc.data;
5557 ctx->objmask = NULL;
5558 /* Set up default configuration. */
5559 action_rss_data = ctx->object;
5560 *action_rss_data = (struct action_rss_data){
5561 .conf = (struct rte_flow_action_rss){
5562 .func = RTE_ETH_HASH_FUNCTION_DEFAULT,
5566 .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM),
5568 .queue = action_rss_data->queue,
5572 for (i = 0; i < action_rss_data->conf.queue_num; ++i)
5573 action_rss_data->queue[i] = i;
5574 action->conf = &action_rss_data->conf;
5579 * Parse func field for RSS action.
5581 * The RTE_ETH_HASH_FUNCTION_* value to assign is derived from the
5582 * ACTION_RSS_FUNC_* index that called this function.
5585 parse_vc_action_rss_func(struct context *ctx, const struct token *token,
5586 const char *str, unsigned int len,
5587 void *buf, unsigned int size)
5589 struct action_rss_data *action_rss_data;
5590 enum rte_eth_hash_function func;
5594 /* Token name must match. */
5595 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5597 switch (ctx->curr) {
5598 case ACTION_RSS_FUNC_DEFAULT:
5599 func = RTE_ETH_HASH_FUNCTION_DEFAULT;
5601 case ACTION_RSS_FUNC_TOEPLITZ:
5602 func = RTE_ETH_HASH_FUNCTION_TOEPLITZ;
5604 case ACTION_RSS_FUNC_SIMPLE_XOR:
5605 func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
5607 case ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ:
5608 func = RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
5615 action_rss_data = ctx->object;
5616 action_rss_data->conf.func = func;
5621 * Parse type field for RSS action.
5623 * Valid tokens are type field names and the "end" token.
5626 parse_vc_action_rss_type(struct context *ctx, const struct token *token,
5627 const char *str, unsigned int len,
5628 void *buf, unsigned int size)
5630 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE);
5631 struct action_rss_data *action_rss_data;
5637 if (ctx->curr != ACTION_RSS_TYPE)
5639 if (!(ctx->objdata >> 16) && ctx->object) {
5640 action_rss_data = ctx->object;
5641 action_rss_data->conf.types = 0;
5643 if (!strcmp_partial("end", str, len)) {
5644 ctx->objdata &= 0xffff;
5647 for (i = 0; rss_type_table[i].str; ++i)
5648 if (!strcmp_partial(rss_type_table[i].str, str, len))
5650 if (!rss_type_table[i].str)
5652 ctx->objdata = 1 << 16 | (ctx->objdata & 0xffff);
5654 if (ctx->next_num == RTE_DIM(ctx->next))
5656 ctx->next[ctx->next_num++] = next;
5659 action_rss_data = ctx->object;
5660 action_rss_data->conf.types |= rss_type_table[i].rss_type;
5665 * Parse queue field for RSS action.
5667 * Valid tokens are queue indices and the "end" token.
5670 parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
5671 const char *str, unsigned int len,
5672 void *buf, unsigned int size)
5674 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE);
5675 struct action_rss_data *action_rss_data;
5676 const struct arg *arg;
5683 if (ctx->curr != ACTION_RSS_QUEUE)
5685 i = ctx->objdata >> 16;
5686 if (!strcmp_partial("end", str, len)) {
5687 ctx->objdata &= 0xffff;
5690 if (i >= ACTION_RSS_QUEUE_NUM)
5692 arg = ARGS_ENTRY_ARB(offsetof(struct action_rss_data, queue) +
5693 i * sizeof(action_rss_data->queue[i]),
5694 sizeof(action_rss_data->queue[i]));
5695 if (push_args(ctx, arg))
5697 ret = parse_int(ctx, token, str, len, NULL, 0);
5703 ctx->objdata = i << 16 | (ctx->objdata & 0xffff);
5705 if (ctx->next_num == RTE_DIM(ctx->next))
5707 ctx->next[ctx->next_num++] = next;
5711 action_rss_data = ctx->object;
5712 action_rss_data->conf.queue_num = i;
5713 action_rss_data->conf.queue = i ? action_rss_data->queue : NULL;
5717 /** Setup VXLAN encap configuration. */
5719 parse_setup_vxlan_encap_data(struct action_vxlan_encap_data *action_vxlan_encap_data)
5721 /* Set up default configuration. */
5722 *action_vxlan_encap_data = (struct action_vxlan_encap_data){
5723 .conf = (struct rte_flow_action_vxlan_encap){
5724 .definition = action_vxlan_encap_data->items,
5728 .type = RTE_FLOW_ITEM_TYPE_ETH,
5729 .spec = &action_vxlan_encap_data->item_eth,
5730 .mask = &rte_flow_item_eth_mask,
5733 .type = RTE_FLOW_ITEM_TYPE_VLAN,
5734 .spec = &action_vxlan_encap_data->item_vlan,
5735 .mask = &rte_flow_item_vlan_mask,
5738 .type = RTE_FLOW_ITEM_TYPE_IPV4,
5739 .spec = &action_vxlan_encap_data->item_ipv4,
5740 .mask = &rte_flow_item_ipv4_mask,
5743 .type = RTE_FLOW_ITEM_TYPE_UDP,
5744 .spec = &action_vxlan_encap_data->item_udp,
5745 .mask = &rte_flow_item_udp_mask,
5748 .type = RTE_FLOW_ITEM_TYPE_VXLAN,
5749 .spec = &action_vxlan_encap_data->item_vxlan,
5750 .mask = &rte_flow_item_vxlan_mask,
5753 .type = RTE_FLOW_ITEM_TYPE_END,
5758 .tci = vxlan_encap_conf.vlan_tci,
5762 .src_addr = vxlan_encap_conf.ipv4_src,
5763 .dst_addr = vxlan_encap_conf.ipv4_dst,
5766 .src_port = vxlan_encap_conf.udp_src,
5767 .dst_port = vxlan_encap_conf.udp_dst,
5769 .item_vxlan.flags = 0,
5771 memcpy(action_vxlan_encap_data->item_eth.dst.addr_bytes,
5772 vxlan_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5773 memcpy(action_vxlan_encap_data->item_eth.src.addr_bytes,
5774 vxlan_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5775 if (!vxlan_encap_conf.select_ipv4) {
5776 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.src_addr,
5777 &vxlan_encap_conf.ipv6_src,
5778 sizeof(vxlan_encap_conf.ipv6_src));
5779 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.dst_addr,
5780 &vxlan_encap_conf.ipv6_dst,
5781 sizeof(vxlan_encap_conf.ipv6_dst));
5782 action_vxlan_encap_data->items[2] = (struct rte_flow_item){
5783 .type = RTE_FLOW_ITEM_TYPE_IPV6,
5784 .spec = &action_vxlan_encap_data->item_ipv6,
5785 .mask = &rte_flow_item_ipv6_mask,
5788 if (!vxlan_encap_conf.select_vlan)
5789 action_vxlan_encap_data->items[1].type =
5790 RTE_FLOW_ITEM_TYPE_VOID;
5791 if (vxlan_encap_conf.select_tos_ttl) {
5792 if (vxlan_encap_conf.select_ipv4) {
5793 static struct rte_flow_item_ipv4 ipv4_mask_tos;
5795 memcpy(&ipv4_mask_tos, &rte_flow_item_ipv4_mask,
5796 sizeof(ipv4_mask_tos));
5797 ipv4_mask_tos.hdr.type_of_service = 0xff;
5798 ipv4_mask_tos.hdr.time_to_live = 0xff;
5799 action_vxlan_encap_data->item_ipv4.hdr.type_of_service =
5800 vxlan_encap_conf.ip_tos;
5801 action_vxlan_encap_data->item_ipv4.hdr.time_to_live =
5802 vxlan_encap_conf.ip_ttl;
5803 action_vxlan_encap_data->items[2].mask =
5806 static struct rte_flow_item_ipv6 ipv6_mask_tos;
5808 memcpy(&ipv6_mask_tos, &rte_flow_item_ipv6_mask,
5809 sizeof(ipv6_mask_tos));
5810 ipv6_mask_tos.hdr.vtc_flow |=
5811 RTE_BE32(0xfful << RTE_IPV6_HDR_TC_SHIFT);
5812 ipv6_mask_tos.hdr.hop_limits = 0xff;
5813 action_vxlan_encap_data->item_ipv6.hdr.vtc_flow |=
5815 ((uint32_t)vxlan_encap_conf.ip_tos <<
5816 RTE_IPV6_HDR_TC_SHIFT);
5817 action_vxlan_encap_data->item_ipv6.hdr.hop_limits =
5818 vxlan_encap_conf.ip_ttl;
5819 action_vxlan_encap_data->items[2].mask =
5823 memcpy(action_vxlan_encap_data->item_vxlan.vni, vxlan_encap_conf.vni,
5824 RTE_DIM(vxlan_encap_conf.vni));
5828 /** Parse VXLAN encap action. */
5830 parse_vc_action_vxlan_encap(struct context *ctx, const struct token *token,
5831 const char *str, unsigned int len,
5832 void *buf, unsigned int size)
5834 struct buffer *out = buf;
5835 struct rte_flow_action *action;
5836 struct action_vxlan_encap_data *action_vxlan_encap_data;
5839 ret = parse_vc(ctx, token, str, len, buf, size);
5842 /* Nothing else to do if there is no buffer. */
5845 if (!out->args.vc.actions_n)
5847 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5848 /* Point to selected object. */
5849 ctx->object = out->args.vc.data;
5850 ctx->objmask = NULL;
5851 action_vxlan_encap_data = ctx->object;
5852 parse_setup_vxlan_encap_data(action_vxlan_encap_data);
5853 action->conf = &action_vxlan_encap_data->conf;
5857 /** Setup NVGRE encap configuration. */
5859 parse_setup_nvgre_encap_data(struct action_nvgre_encap_data *action_nvgre_encap_data)
5861 /* Set up default configuration. */
5862 *action_nvgre_encap_data = (struct action_nvgre_encap_data){
5863 .conf = (struct rte_flow_action_nvgre_encap){
5864 .definition = action_nvgre_encap_data->items,
5868 .type = RTE_FLOW_ITEM_TYPE_ETH,
5869 .spec = &action_nvgre_encap_data->item_eth,
5870 .mask = &rte_flow_item_eth_mask,
5873 .type = RTE_FLOW_ITEM_TYPE_VLAN,
5874 .spec = &action_nvgre_encap_data->item_vlan,
5875 .mask = &rte_flow_item_vlan_mask,
5878 .type = RTE_FLOW_ITEM_TYPE_IPV4,
5879 .spec = &action_nvgre_encap_data->item_ipv4,
5880 .mask = &rte_flow_item_ipv4_mask,
5883 .type = RTE_FLOW_ITEM_TYPE_NVGRE,
5884 .spec = &action_nvgre_encap_data->item_nvgre,
5885 .mask = &rte_flow_item_nvgre_mask,
5888 .type = RTE_FLOW_ITEM_TYPE_END,
5893 .tci = nvgre_encap_conf.vlan_tci,
5897 .src_addr = nvgre_encap_conf.ipv4_src,
5898 .dst_addr = nvgre_encap_conf.ipv4_dst,
5900 .item_nvgre.c_k_s_rsvd0_ver = RTE_BE16(0x2000),
5901 .item_nvgre.protocol = RTE_BE16(RTE_ETHER_TYPE_TEB),
5902 .item_nvgre.flow_id = 0,
5904 memcpy(action_nvgre_encap_data->item_eth.dst.addr_bytes,
5905 nvgre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5906 memcpy(action_nvgre_encap_data->item_eth.src.addr_bytes,
5907 nvgre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5908 if (!nvgre_encap_conf.select_ipv4) {
5909 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.src_addr,
5910 &nvgre_encap_conf.ipv6_src,
5911 sizeof(nvgre_encap_conf.ipv6_src));
5912 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.dst_addr,
5913 &nvgre_encap_conf.ipv6_dst,
5914 sizeof(nvgre_encap_conf.ipv6_dst));
5915 action_nvgre_encap_data->items[2] = (struct rte_flow_item){
5916 .type = RTE_FLOW_ITEM_TYPE_IPV6,
5917 .spec = &action_nvgre_encap_data->item_ipv6,
5918 .mask = &rte_flow_item_ipv6_mask,
5921 if (!nvgre_encap_conf.select_vlan)
5922 action_nvgre_encap_data->items[1].type =
5923 RTE_FLOW_ITEM_TYPE_VOID;
5924 memcpy(action_nvgre_encap_data->item_nvgre.tni, nvgre_encap_conf.tni,
5925 RTE_DIM(nvgre_encap_conf.tni));
5929 /** Parse NVGRE encap action. */
5931 parse_vc_action_nvgre_encap(struct context *ctx, const struct token *token,
5932 const char *str, unsigned int len,
5933 void *buf, unsigned int size)
5935 struct buffer *out = buf;
5936 struct rte_flow_action *action;
5937 struct action_nvgre_encap_data *action_nvgre_encap_data;
5940 ret = parse_vc(ctx, token, str, len, buf, size);
5943 /* Nothing else to do if there is no buffer. */
5946 if (!out->args.vc.actions_n)
5948 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5949 /* Point to selected object. */
5950 ctx->object = out->args.vc.data;
5951 ctx->objmask = NULL;
5952 action_nvgre_encap_data = ctx->object;
5953 parse_setup_nvgre_encap_data(action_nvgre_encap_data);
5954 action->conf = &action_nvgre_encap_data->conf;
5958 /** Parse l2 encap action. */
5960 parse_vc_action_l2_encap(struct context *ctx, const struct token *token,
5961 const char *str, unsigned int len,
5962 void *buf, unsigned int size)
5964 struct buffer *out = buf;
5965 struct rte_flow_action *action;
5966 struct action_raw_encap_data *action_encap_data;
5967 struct rte_flow_item_eth eth = { .type = 0, };
5968 struct rte_flow_item_vlan vlan = {
5969 .tci = mplsoudp_encap_conf.vlan_tci,
5975 ret = parse_vc(ctx, token, str, len, buf, size);
5978 /* Nothing else to do if there is no buffer. */
5981 if (!out->args.vc.actions_n)
5983 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5984 /* Point to selected object. */
5985 ctx->object = out->args.vc.data;
5986 ctx->objmask = NULL;
5987 /* Copy the headers to the buffer. */
5988 action_encap_data = ctx->object;
5989 *action_encap_data = (struct action_raw_encap_data) {
5990 .conf = (struct rte_flow_action_raw_encap){
5991 .data = action_encap_data->data,
5995 header = action_encap_data->data;
5996 if (l2_encap_conf.select_vlan)
5997 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5998 else if (l2_encap_conf.select_ipv4)
5999 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6001 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6002 memcpy(eth.dst.addr_bytes,
6003 l2_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
6004 memcpy(eth.src.addr_bytes,
6005 l2_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
6006 memcpy(header, ð, sizeof(eth));
6007 header += sizeof(eth);
6008 if (l2_encap_conf.select_vlan) {
6009 if (l2_encap_conf.select_ipv4)
6010 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6012 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6013 memcpy(header, &vlan, sizeof(vlan));
6014 header += sizeof(vlan);
6016 action_encap_data->conf.size = header -
6017 action_encap_data->data;
6018 action->conf = &action_encap_data->conf;
6022 /** Parse l2 decap action. */
6024 parse_vc_action_l2_decap(struct context *ctx, const struct token *token,
6025 const char *str, unsigned int len,
6026 void *buf, unsigned int size)
6028 struct buffer *out = buf;
6029 struct rte_flow_action *action;
6030 struct action_raw_decap_data *action_decap_data;
6031 struct rte_flow_item_eth eth = { .type = 0, };
6032 struct rte_flow_item_vlan vlan = {
6033 .tci = mplsoudp_encap_conf.vlan_tci,
6039 ret = parse_vc(ctx, token, str, len, buf, size);
6042 /* Nothing else to do if there is no buffer. */
6045 if (!out->args.vc.actions_n)
6047 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6048 /* Point to selected object. */
6049 ctx->object = out->args.vc.data;
6050 ctx->objmask = NULL;
6051 /* Copy the headers to the buffer. */
6052 action_decap_data = ctx->object;
6053 *action_decap_data = (struct action_raw_decap_data) {
6054 .conf = (struct rte_flow_action_raw_decap){
6055 .data = action_decap_data->data,
6059 header = action_decap_data->data;
6060 if (l2_decap_conf.select_vlan)
6061 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
6062 memcpy(header, ð, sizeof(eth));
6063 header += sizeof(eth);
6064 if (l2_decap_conf.select_vlan) {
6065 memcpy(header, &vlan, sizeof(vlan));
6066 header += sizeof(vlan);
6068 action_decap_data->conf.size = header -
6069 action_decap_data->data;
6070 action->conf = &action_decap_data->conf;
6074 #define ETHER_TYPE_MPLS_UNICAST 0x8847
6076 /** Parse MPLSOGRE encap action. */
6078 parse_vc_action_mplsogre_encap(struct context *ctx, const struct token *token,
6079 const char *str, unsigned int len,
6080 void *buf, unsigned int size)
6082 struct buffer *out = buf;
6083 struct rte_flow_action *action;
6084 struct action_raw_encap_data *action_encap_data;
6085 struct rte_flow_item_eth eth = { .type = 0, };
6086 struct rte_flow_item_vlan vlan = {
6087 .tci = mplsogre_encap_conf.vlan_tci,
6090 struct rte_flow_item_ipv4 ipv4 = {
6092 .src_addr = mplsogre_encap_conf.ipv4_src,
6093 .dst_addr = mplsogre_encap_conf.ipv4_dst,
6094 .next_proto_id = IPPROTO_GRE,
6095 .version_ihl = RTE_IPV4_VHL_DEF,
6096 .time_to_live = IPDEFTTL,
6099 struct rte_flow_item_ipv6 ipv6 = {
6101 .proto = IPPROTO_GRE,
6102 .hop_limits = IPDEFTTL,
6105 struct rte_flow_item_gre gre = {
6106 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
6108 struct rte_flow_item_mpls mpls = {
6114 ret = parse_vc(ctx, token, str, len, buf, size);
6117 /* Nothing else to do if there is no buffer. */
6120 if (!out->args.vc.actions_n)
6122 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6123 /* Point to selected object. */
6124 ctx->object = out->args.vc.data;
6125 ctx->objmask = NULL;
6126 /* Copy the headers to the buffer. */
6127 action_encap_data = ctx->object;
6128 *action_encap_data = (struct action_raw_encap_data) {
6129 .conf = (struct rte_flow_action_raw_encap){
6130 .data = action_encap_data->data,
6135 header = action_encap_data->data;
6136 if (mplsogre_encap_conf.select_vlan)
6137 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
6138 else if (mplsogre_encap_conf.select_ipv4)
6139 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6141 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6142 memcpy(eth.dst.addr_bytes,
6143 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
6144 memcpy(eth.src.addr_bytes,
6145 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
6146 memcpy(header, ð, sizeof(eth));
6147 header += sizeof(eth);
6148 if (mplsogre_encap_conf.select_vlan) {
6149 if (mplsogre_encap_conf.select_ipv4)
6150 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6152 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6153 memcpy(header, &vlan, sizeof(vlan));
6154 header += sizeof(vlan);
6156 if (mplsogre_encap_conf.select_ipv4) {
6157 memcpy(header, &ipv4, sizeof(ipv4));
6158 header += sizeof(ipv4);
6160 memcpy(&ipv6.hdr.src_addr,
6161 &mplsogre_encap_conf.ipv6_src,
6162 sizeof(mplsogre_encap_conf.ipv6_src));
6163 memcpy(&ipv6.hdr.dst_addr,
6164 &mplsogre_encap_conf.ipv6_dst,
6165 sizeof(mplsogre_encap_conf.ipv6_dst));
6166 memcpy(header, &ipv6, sizeof(ipv6));
6167 header += sizeof(ipv6);
6169 memcpy(header, &gre, sizeof(gre));
6170 header += sizeof(gre);
6171 memcpy(mpls.label_tc_s, mplsogre_encap_conf.label,
6172 RTE_DIM(mplsogre_encap_conf.label));
6173 mpls.label_tc_s[2] |= 0x1;
6174 memcpy(header, &mpls, sizeof(mpls));
6175 header += sizeof(mpls);
6176 action_encap_data->conf.size = header -
6177 action_encap_data->data;
6178 action->conf = &action_encap_data->conf;
6182 /** Parse MPLSOGRE decap action. */
6184 parse_vc_action_mplsogre_decap(struct context *ctx, const struct token *token,
6185 const char *str, unsigned int len,
6186 void *buf, unsigned int size)
6188 struct buffer *out = buf;
6189 struct rte_flow_action *action;
6190 struct action_raw_decap_data *action_decap_data;
6191 struct rte_flow_item_eth eth = { .type = 0, };
6192 struct rte_flow_item_vlan vlan = {.tci = 0};
6193 struct rte_flow_item_ipv4 ipv4 = {
6195 .next_proto_id = IPPROTO_GRE,
6198 struct rte_flow_item_ipv6 ipv6 = {
6200 .proto = IPPROTO_GRE,
6203 struct rte_flow_item_gre gre = {
6204 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
6206 struct rte_flow_item_mpls mpls;
6210 ret = parse_vc(ctx, token, str, len, buf, size);
6213 /* Nothing else to do if there is no buffer. */
6216 if (!out->args.vc.actions_n)
6218 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6219 /* Point to selected object. */
6220 ctx->object = out->args.vc.data;
6221 ctx->objmask = NULL;
6222 /* Copy the headers to the buffer. */
6223 action_decap_data = ctx->object;
6224 *action_decap_data = (struct action_raw_decap_data) {
6225 .conf = (struct rte_flow_action_raw_decap){
6226 .data = action_decap_data->data,
6230 header = action_decap_data->data;
6231 if (mplsogre_decap_conf.select_vlan)
6232 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
6233 else if (mplsogre_encap_conf.select_ipv4)
6234 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6236 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6237 memcpy(eth.dst.addr_bytes,
6238 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
6239 memcpy(eth.src.addr_bytes,
6240 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
6241 memcpy(header, ð, sizeof(eth));
6242 header += sizeof(eth);
6243 if (mplsogre_encap_conf.select_vlan) {
6244 if (mplsogre_encap_conf.select_ipv4)
6245 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6247 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6248 memcpy(header, &vlan, sizeof(vlan));
6249 header += sizeof(vlan);
6251 if (mplsogre_encap_conf.select_ipv4) {
6252 memcpy(header, &ipv4, sizeof(ipv4));
6253 header += sizeof(ipv4);
6255 memcpy(header, &ipv6, sizeof(ipv6));
6256 header += sizeof(ipv6);
6258 memcpy(header, &gre, sizeof(gre));
6259 header += sizeof(gre);
6260 memset(&mpls, 0, sizeof(mpls));
6261 memcpy(header, &mpls, sizeof(mpls));
6262 header += sizeof(mpls);
6263 action_decap_data->conf.size = header -
6264 action_decap_data->data;
6265 action->conf = &action_decap_data->conf;
6269 /** Parse MPLSOUDP encap action. */
6271 parse_vc_action_mplsoudp_encap(struct context *ctx, const struct token *token,
6272 const char *str, unsigned int len,
6273 void *buf, unsigned int size)
6275 struct buffer *out = buf;
6276 struct rte_flow_action *action;
6277 struct action_raw_encap_data *action_encap_data;
6278 struct rte_flow_item_eth eth = { .type = 0, };
6279 struct rte_flow_item_vlan vlan = {
6280 .tci = mplsoudp_encap_conf.vlan_tci,
6283 struct rte_flow_item_ipv4 ipv4 = {
6285 .src_addr = mplsoudp_encap_conf.ipv4_src,
6286 .dst_addr = mplsoudp_encap_conf.ipv4_dst,
6287 .next_proto_id = IPPROTO_UDP,
6288 .version_ihl = RTE_IPV4_VHL_DEF,
6289 .time_to_live = IPDEFTTL,
6292 struct rte_flow_item_ipv6 ipv6 = {
6294 .proto = IPPROTO_UDP,
6295 .hop_limits = IPDEFTTL,
6298 struct rte_flow_item_udp udp = {
6300 .src_port = mplsoudp_encap_conf.udp_src,
6301 .dst_port = mplsoudp_encap_conf.udp_dst,
6304 struct rte_flow_item_mpls mpls;
6308 ret = parse_vc(ctx, token, str, len, buf, size);
6311 /* Nothing else to do if there is no buffer. */
6314 if (!out->args.vc.actions_n)
6316 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6317 /* Point to selected object. */
6318 ctx->object = out->args.vc.data;
6319 ctx->objmask = NULL;
6320 /* Copy the headers to the buffer. */
6321 action_encap_data = ctx->object;
6322 *action_encap_data = (struct action_raw_encap_data) {
6323 .conf = (struct rte_flow_action_raw_encap){
6324 .data = action_encap_data->data,
6329 header = action_encap_data->data;
6330 if (mplsoudp_encap_conf.select_vlan)
6331 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
6332 else if (mplsoudp_encap_conf.select_ipv4)
6333 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6335 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6336 memcpy(eth.dst.addr_bytes,
6337 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
6338 memcpy(eth.src.addr_bytes,
6339 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
6340 memcpy(header, ð, sizeof(eth));
6341 header += sizeof(eth);
6342 if (mplsoudp_encap_conf.select_vlan) {
6343 if (mplsoudp_encap_conf.select_ipv4)
6344 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6346 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6347 memcpy(header, &vlan, sizeof(vlan));
6348 header += sizeof(vlan);
6350 if (mplsoudp_encap_conf.select_ipv4) {
6351 memcpy(header, &ipv4, sizeof(ipv4));
6352 header += sizeof(ipv4);
6354 memcpy(&ipv6.hdr.src_addr,
6355 &mplsoudp_encap_conf.ipv6_src,
6356 sizeof(mplsoudp_encap_conf.ipv6_src));
6357 memcpy(&ipv6.hdr.dst_addr,
6358 &mplsoudp_encap_conf.ipv6_dst,
6359 sizeof(mplsoudp_encap_conf.ipv6_dst));
6360 memcpy(header, &ipv6, sizeof(ipv6));
6361 header += sizeof(ipv6);
6363 memcpy(header, &udp, sizeof(udp));
6364 header += sizeof(udp);
6365 memcpy(mpls.label_tc_s, mplsoudp_encap_conf.label,
6366 RTE_DIM(mplsoudp_encap_conf.label));
6367 mpls.label_tc_s[2] |= 0x1;
6368 memcpy(header, &mpls, sizeof(mpls));
6369 header += sizeof(mpls);
6370 action_encap_data->conf.size = header -
6371 action_encap_data->data;
6372 action->conf = &action_encap_data->conf;
6376 /** Parse MPLSOUDP decap action. */
6378 parse_vc_action_mplsoudp_decap(struct context *ctx, const struct token *token,
6379 const char *str, unsigned int len,
6380 void *buf, unsigned int size)
6382 struct buffer *out = buf;
6383 struct rte_flow_action *action;
6384 struct action_raw_decap_data *action_decap_data;
6385 struct rte_flow_item_eth eth = { .type = 0, };
6386 struct rte_flow_item_vlan vlan = {.tci = 0};
6387 struct rte_flow_item_ipv4 ipv4 = {
6389 .next_proto_id = IPPROTO_UDP,
6392 struct rte_flow_item_ipv6 ipv6 = {
6394 .proto = IPPROTO_UDP,
6397 struct rte_flow_item_udp udp = {
6399 .dst_port = rte_cpu_to_be_16(6635),
6402 struct rte_flow_item_mpls mpls;
6406 ret = parse_vc(ctx, token, str, len, buf, size);
6409 /* Nothing else to do if there is no buffer. */
6412 if (!out->args.vc.actions_n)
6414 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6415 /* Point to selected object. */
6416 ctx->object = out->args.vc.data;
6417 ctx->objmask = NULL;
6418 /* Copy the headers to the buffer. */
6419 action_decap_data = ctx->object;
6420 *action_decap_data = (struct action_raw_decap_data) {
6421 .conf = (struct rte_flow_action_raw_decap){
6422 .data = action_decap_data->data,
6426 header = action_decap_data->data;
6427 if (mplsoudp_decap_conf.select_vlan)
6428 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
6429 else if (mplsoudp_encap_conf.select_ipv4)
6430 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6432 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6433 memcpy(eth.dst.addr_bytes,
6434 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
6435 memcpy(eth.src.addr_bytes,
6436 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
6437 memcpy(header, ð, sizeof(eth));
6438 header += sizeof(eth);
6439 if (mplsoudp_encap_conf.select_vlan) {
6440 if (mplsoudp_encap_conf.select_ipv4)
6441 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6443 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6444 memcpy(header, &vlan, sizeof(vlan));
6445 header += sizeof(vlan);
6447 if (mplsoudp_encap_conf.select_ipv4) {
6448 memcpy(header, &ipv4, sizeof(ipv4));
6449 header += sizeof(ipv4);
6451 memcpy(header, &ipv6, sizeof(ipv6));
6452 header += sizeof(ipv6);
6454 memcpy(header, &udp, sizeof(udp));
6455 header += sizeof(udp);
6456 memset(&mpls, 0, sizeof(mpls));
6457 memcpy(header, &mpls, sizeof(mpls));
6458 header += sizeof(mpls);
6459 action_decap_data->conf.size = header -
6460 action_decap_data->data;
6461 action->conf = &action_decap_data->conf;
6466 parse_vc_action_raw_decap_index(struct context *ctx, const struct token *token,
6467 const char *str, unsigned int len, void *buf,
6470 struct action_raw_decap_data *action_raw_decap_data;
6471 struct rte_flow_action *action;
6472 const struct arg *arg;
6473 struct buffer *out = buf;
6477 RTE_SET_USED(token);
6480 arg = ARGS_ENTRY_ARB_BOUNDED
6481 (offsetof(struct action_raw_decap_data, idx),
6482 sizeof(((struct action_raw_decap_data *)0)->idx),
6483 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
6484 if (push_args(ctx, arg))
6486 ret = parse_int(ctx, token, str, len, NULL, 0);
6493 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6494 action_raw_decap_data = ctx->object;
6495 idx = action_raw_decap_data->idx;
6496 action_raw_decap_data->conf.data = raw_decap_confs[idx].data;
6497 action_raw_decap_data->conf.size = raw_decap_confs[idx].size;
6498 action->conf = &action_raw_decap_data->conf;
6504 parse_vc_action_raw_encap_index(struct context *ctx, const struct token *token,
6505 const char *str, unsigned int len, void *buf,
6508 struct action_raw_encap_data *action_raw_encap_data;
6509 struct rte_flow_action *action;
6510 const struct arg *arg;
6511 struct buffer *out = buf;
6515 RTE_SET_USED(token);
6518 if (ctx->curr != ACTION_RAW_ENCAP_INDEX_VALUE)
6520 arg = ARGS_ENTRY_ARB_BOUNDED
6521 (offsetof(struct action_raw_encap_data, idx),
6522 sizeof(((struct action_raw_encap_data *)0)->idx),
6523 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
6524 if (push_args(ctx, arg))
6526 ret = parse_int(ctx, token, str, len, NULL, 0);
6533 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6534 action_raw_encap_data = ctx->object;
6535 idx = action_raw_encap_data->idx;
6536 action_raw_encap_data->conf.data = raw_encap_confs[idx].data;
6537 action_raw_encap_data->conf.size = raw_encap_confs[idx].size;
6538 action_raw_encap_data->conf.preserve = NULL;
6539 action->conf = &action_raw_encap_data->conf;
6544 parse_vc_action_raw_encap(struct context *ctx, const struct token *token,
6545 const char *str, unsigned int len, void *buf,
6548 struct buffer *out = buf;
6549 struct rte_flow_action *action;
6550 struct action_raw_encap_data *action_raw_encap_data = NULL;
6553 ret = parse_vc(ctx, token, str, len, buf, size);
6556 /* Nothing else to do if there is no buffer. */
6559 if (!out->args.vc.actions_n)
6561 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6562 /* Point to selected object. */
6563 ctx->object = out->args.vc.data;
6564 ctx->objmask = NULL;
6565 /* Copy the headers to the buffer. */
6566 action_raw_encap_data = ctx->object;
6567 action_raw_encap_data->conf.data = raw_encap_confs[0].data;
6568 action_raw_encap_data->conf.preserve = NULL;
6569 action_raw_encap_data->conf.size = raw_encap_confs[0].size;
6570 action->conf = &action_raw_encap_data->conf;
6575 parse_vc_action_raw_decap(struct context *ctx, const struct token *token,
6576 const char *str, unsigned int len, void *buf,
6579 struct buffer *out = buf;
6580 struct rte_flow_action *action;
6581 struct action_raw_decap_data *action_raw_decap_data = NULL;
6584 ret = parse_vc(ctx, token, str, len, buf, size);
6587 /* Nothing else to do if there is no buffer. */
6590 if (!out->args.vc.actions_n)
6592 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6593 /* Point to selected object. */
6594 ctx->object = out->args.vc.data;
6595 ctx->objmask = NULL;
6596 /* Copy the headers to the buffer. */
6597 action_raw_decap_data = ctx->object;
6598 action_raw_decap_data->conf.data = raw_decap_confs[0].data;
6599 action_raw_decap_data->conf.size = raw_decap_confs[0].size;
6600 action->conf = &action_raw_decap_data->conf;
6605 parse_vc_action_set_meta(struct context *ctx, const struct token *token,
6606 const char *str, unsigned int len, void *buf,
6611 ret = parse_vc(ctx, token, str, len, buf, size);
6614 ret = rte_flow_dynf_metadata_register();
6621 parse_vc_action_sample(struct context *ctx, const struct token *token,
6622 const char *str, unsigned int len, void *buf,
6625 struct buffer *out = buf;
6626 struct rte_flow_action *action;
6627 struct action_sample_data *action_sample_data = NULL;
6628 static struct rte_flow_action end_action = {
6629 RTE_FLOW_ACTION_TYPE_END, 0
6633 ret = parse_vc(ctx, token, str, len, buf, size);
6636 /* Nothing else to do if there is no buffer. */
6639 if (!out->args.vc.actions_n)
6641 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6642 /* Point to selected object. */
6643 ctx->object = out->args.vc.data;
6644 ctx->objmask = NULL;
6645 /* Copy the headers to the buffer. */
6646 action_sample_data = ctx->object;
6647 action_sample_data->conf.actions = &end_action;
6648 action->conf = &action_sample_data->conf;
6653 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
6654 const char *str, unsigned int len, void *buf,
6657 struct action_sample_data *action_sample_data;
6658 struct rte_flow_action *action;
6659 const struct arg *arg;
6660 struct buffer *out = buf;
6664 RTE_SET_USED(token);
6667 if (ctx->curr != ACTION_SAMPLE_INDEX_VALUE)
6669 arg = ARGS_ENTRY_ARB_BOUNDED
6670 (offsetof(struct action_sample_data, idx),
6671 sizeof(((struct action_sample_data *)0)->idx),
6672 0, RAW_SAMPLE_CONFS_MAX_NUM - 1);
6673 if (push_args(ctx, arg))
6675 ret = parse_int(ctx, token, str, len, NULL, 0);
6682 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6683 action_sample_data = ctx->object;
6684 idx = action_sample_data->idx;
6685 action_sample_data->conf.actions = raw_sample_confs[idx].data;
6686 action->conf = &action_sample_data->conf;
6690 /** Parse operation for modify_field command. */
6692 parse_vc_modify_field_op(struct context *ctx, const struct token *token,
6693 const char *str, unsigned int len, void *buf,
6696 struct rte_flow_action_modify_field *action_modify_field;
6702 if (ctx->curr != ACTION_MODIFY_FIELD_OP_VALUE)
6704 for (i = 0; modify_field_ops[i]; ++i)
6705 if (!strcmp_partial(modify_field_ops[i], str, len))
6707 if (!modify_field_ops[i])
6711 action_modify_field = ctx->object;
6712 action_modify_field->operation = (enum rte_flow_modify_op)i;
6716 /** Parse id for modify_field command. */
6718 parse_vc_modify_field_id(struct context *ctx, const struct token *token,
6719 const char *str, unsigned int len, void *buf,
6722 struct rte_flow_action_modify_field *action_modify_field;
6728 if (ctx->curr != ACTION_MODIFY_FIELD_DST_TYPE_VALUE &&
6729 ctx->curr != ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)
6731 for (i = 0; modify_field_ids[i]; ++i)
6732 if (!strcmp_partial(modify_field_ids[i], str, len))
6734 if (!modify_field_ids[i])
6738 action_modify_field = ctx->object;
6739 if (ctx->curr == ACTION_MODIFY_FIELD_DST_TYPE_VALUE)
6740 action_modify_field->dst.field = (enum rte_flow_field_id)i;
6742 action_modify_field->src.field = (enum rte_flow_field_id)i;
6746 /** Parse the conntrack update, not a rte_flow_action. */
6748 parse_vc_action_conntrack_update(struct context *ctx, const struct token *token,
6749 const char *str, unsigned int len, void *buf,
6752 struct buffer *out = buf;
6753 struct rte_flow_modify_conntrack *ct_modify = NULL;
6756 if (ctx->curr != ACTION_CONNTRACK_UPDATE_CTX &&
6757 ctx->curr != ACTION_CONNTRACK_UPDATE_DIR)
6759 /* Token name must match. */
6760 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6762 /* Nothing else to do if there is no buffer. */
6765 ct_modify = (struct rte_flow_modify_conntrack *)out->args.vc.data;
6766 if (ctx->curr == ACTION_CONNTRACK_UPDATE_DIR) {
6767 ct_modify->new_ct.is_original_dir =
6768 conntrack_context.is_original_dir;
6769 ct_modify->direction = 1;
6773 old_dir = ct_modify->new_ct.is_original_dir;
6774 memcpy(&ct_modify->new_ct, &conntrack_context,
6775 sizeof(conntrack_context));
6776 ct_modify->new_ct.is_original_dir = old_dir;
6777 ct_modify->state = 1;
6782 /** Parse tokens for destroy command. */
6784 parse_destroy(struct context *ctx, const struct token *token,
6785 const char *str, unsigned int len,
6786 void *buf, unsigned int size)
6788 struct buffer *out = buf;
6790 /* Token name must match. */
6791 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6793 /* Nothing else to do if there is no buffer. */
6796 if (!out->command) {
6797 if (ctx->curr != DESTROY)
6799 if (sizeof(*out) > size)
6801 out->command = ctx->curr;
6804 ctx->objmask = NULL;
6805 out->args.destroy.rule =
6806 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6810 if (((uint8_t *)(out->args.destroy.rule + out->args.destroy.rule_n) +
6811 sizeof(*out->args.destroy.rule)) > (uint8_t *)out + size)
6814 ctx->object = out->args.destroy.rule + out->args.destroy.rule_n++;
6815 ctx->objmask = NULL;
6819 /** Parse tokens for flush command. */
6821 parse_flush(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;
6827 /* Token name must match. */
6828 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6830 /* Nothing else to do if there is no buffer. */
6833 if (!out->command) {
6834 if (ctx->curr != FLUSH)
6836 if (sizeof(*out) > size)
6838 out->command = ctx->curr;
6841 ctx->objmask = NULL;
6846 /** Parse tokens for dump command. */
6848 parse_dump(struct context *ctx, const struct token *token,
6849 const char *str, unsigned int len,
6850 void *buf, unsigned int size)
6852 struct buffer *out = buf;
6854 /* Token name must match. */
6855 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6857 /* Nothing else to do if there is no buffer. */
6860 if (!out->command) {
6861 if (ctx->curr != DUMP)
6863 if (sizeof(*out) > size)
6865 out->command = ctx->curr;
6868 ctx->objmask = NULL;
6871 switch (ctx->curr) {
6874 out->args.dump.mode = (ctx->curr == DUMP_ALL) ? true : false;
6875 out->command = ctx->curr;
6878 ctx->objmask = NULL;
6885 /** Parse tokens for query command. */
6887 parse_query(struct context *ctx, const struct token *token,
6888 const char *str, unsigned int len,
6889 void *buf, unsigned int size)
6891 struct buffer *out = buf;
6893 /* Token name must match. */
6894 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6896 /* Nothing else to do if there is no buffer. */
6899 if (!out->command) {
6900 if (ctx->curr != QUERY)
6902 if (sizeof(*out) > size)
6904 out->command = ctx->curr;
6907 ctx->objmask = NULL;
6912 /** Parse action names. */
6914 parse_action(struct context *ctx, const struct token *token,
6915 const char *str, unsigned int len,
6916 void *buf, unsigned int size)
6918 struct buffer *out = buf;
6919 const struct arg *arg = pop_args(ctx);
6923 /* Argument is expected. */
6926 /* Parse action name. */
6927 for (i = 0; next_action[i]; ++i) {
6928 const struct parse_action_priv *priv;
6930 token = &token_list[next_action[i]];
6931 if (strcmp_partial(token->name, str, len))
6937 memcpy((uint8_t *)ctx->object + arg->offset,
6943 push_args(ctx, arg);
6947 /** Parse tokens for list command. */
6949 parse_list(struct context *ctx, const struct token *token,
6950 const char *str, unsigned int len,
6951 void *buf, unsigned int size)
6953 struct buffer *out = buf;
6955 /* Token name must match. */
6956 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6958 /* Nothing else to do if there is no buffer. */
6961 if (!out->command) {
6962 if (ctx->curr != LIST)
6964 if (sizeof(*out) > size)
6966 out->command = ctx->curr;
6969 ctx->objmask = NULL;
6970 out->args.list.group =
6971 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6975 if (((uint8_t *)(out->args.list.group + out->args.list.group_n) +
6976 sizeof(*out->args.list.group)) > (uint8_t *)out + size)
6979 ctx->object = out->args.list.group + out->args.list.group_n++;
6980 ctx->objmask = NULL;
6984 /** Parse tokens for list all aged flows command. */
6986 parse_aged(struct context *ctx, const struct token *token,
6987 const char *str, unsigned int len,
6988 void *buf, unsigned int size)
6990 struct buffer *out = buf;
6992 /* Token name must match. */
6993 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6995 /* Nothing else to do if there is no buffer. */
6998 if (!out->command) {
6999 if (ctx->curr != AGED)
7001 if (sizeof(*out) > size)
7003 out->command = ctx->curr;
7006 ctx->objmask = NULL;
7008 if (ctx->curr == AGED_DESTROY)
7009 out->args.aged.destroy = 1;
7013 /** Parse tokens for isolate command. */
7015 parse_isolate(struct context *ctx, const struct token *token,
7016 const char *str, unsigned int len,
7017 void *buf, unsigned int size)
7019 struct buffer *out = buf;
7021 /* Token name must match. */
7022 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7024 /* Nothing else to do if there is no buffer. */
7027 if (!out->command) {
7028 if (ctx->curr != ISOLATE)
7030 if (sizeof(*out) > size)
7032 out->command = ctx->curr;
7035 ctx->objmask = NULL;
7041 parse_tunnel(struct context *ctx, const struct token *token,
7042 const char *str, unsigned int len,
7043 void *buf, unsigned int size)
7045 struct buffer *out = buf;
7047 /* Token name must match. */
7048 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7050 /* Nothing else to do if there is no buffer. */
7053 if (!out->command) {
7054 if (ctx->curr != TUNNEL)
7056 if (sizeof(*out) > size)
7058 out->command = ctx->curr;
7061 ctx->objmask = NULL;
7063 switch (ctx->curr) {
7067 case TUNNEL_DESTROY:
7069 out->command = ctx->curr;
7071 case TUNNEL_CREATE_TYPE:
7072 case TUNNEL_DESTROY_ID:
7073 ctx->object = &out->args.vc.tunnel_ops;
7082 * Parse signed/unsigned integers 8 to 64-bit long.
7084 * Last argument (ctx->args) is retrieved to determine integer type and
7088 parse_int(struct context *ctx, const struct token *token,
7089 const char *str, unsigned int len,
7090 void *buf, unsigned int size)
7092 const struct arg *arg = pop_args(ctx);
7097 /* Argument is expected. */
7102 (uintmax_t)strtoimax(str, &end, 0) :
7103 strtoumax(str, &end, 0);
7104 if (errno || (size_t)(end - str) != len)
7107 ((arg->sign && ((intmax_t)u < (intmax_t)arg->min ||
7108 (intmax_t)u > (intmax_t)arg->max)) ||
7109 (!arg->sign && (u < arg->min || u > arg->max))))
7114 if (!arg_entry_bf_fill(ctx->object, u, arg) ||
7115 !arg_entry_bf_fill(ctx->objmask, -1, arg))
7119 buf = (uint8_t *)ctx->object + arg->offset;
7121 if (u > RTE_LEN2MASK(size * CHAR_BIT, uint64_t))
7125 case sizeof(uint8_t):
7126 *(uint8_t *)buf = u;
7128 case sizeof(uint16_t):
7129 *(uint16_t *)buf = arg->hton ? rte_cpu_to_be_16(u) : u;
7131 case sizeof(uint8_t [3]):
7132 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
7134 ((uint8_t *)buf)[0] = u;
7135 ((uint8_t *)buf)[1] = u >> 8;
7136 ((uint8_t *)buf)[2] = u >> 16;
7140 ((uint8_t *)buf)[0] = u >> 16;
7141 ((uint8_t *)buf)[1] = u >> 8;
7142 ((uint8_t *)buf)[2] = u;
7144 case sizeof(uint32_t):
7145 *(uint32_t *)buf = arg->hton ? rte_cpu_to_be_32(u) : u;
7147 case sizeof(uint64_t):
7148 *(uint64_t *)buf = arg->hton ? rte_cpu_to_be_64(u) : u;
7153 if (ctx->objmask && buf != (uint8_t *)ctx->objmask + arg->offset) {
7155 buf = (uint8_t *)ctx->objmask + arg->offset;
7160 push_args(ctx, arg);
7167 * Three arguments (ctx->args) are retrieved from the stack to store data,
7168 * its actual length and address (in that order).
7171 parse_string(struct context *ctx, const struct token *token,
7172 const char *str, unsigned int len,
7173 void *buf, unsigned int size)
7175 const struct arg *arg_data = pop_args(ctx);
7176 const struct arg *arg_len = pop_args(ctx);
7177 const struct arg *arg_addr = pop_args(ctx);
7178 char tmp[16]; /* Ought to be enough. */
7181 /* Arguments are expected. */
7185 push_args(ctx, arg_data);
7189 push_args(ctx, arg_len);
7190 push_args(ctx, arg_data);
7193 size = arg_data->size;
7194 /* Bit-mask fill is not supported. */
7195 if (arg_data->mask || size < len)
7199 /* Let parse_int() fill length information first. */
7200 ret = snprintf(tmp, sizeof(tmp), "%u", len);
7203 push_args(ctx, arg_len);
7204 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
7209 buf = (uint8_t *)ctx->object + arg_data->offset;
7210 /* Output buffer is not necessarily NUL-terminated. */
7211 memcpy(buf, str, len);
7212 memset((uint8_t *)buf + len, 0x00, size - len);
7214 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
7215 /* Save address if requested. */
7216 if (arg_addr->size) {
7217 memcpy((uint8_t *)ctx->object + arg_addr->offset,
7219 (uint8_t *)ctx->object + arg_data->offset
7223 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
7225 (uint8_t *)ctx->objmask + arg_data->offset
7231 push_args(ctx, arg_addr);
7232 push_args(ctx, arg_len);
7233 push_args(ctx, arg_data);
7238 parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
7244 /* Check input parameters */
7245 if ((src == NULL) ||
7251 /* Convert chars to bytes */
7252 for (i = 0, len = 0; i < *size; i += 2) {
7253 snprintf(tmp, 3, "%s", src + i);
7254 dst[len++] = strtoul(tmp, &c, 16);
7269 parse_hex(struct context *ctx, const struct token *token,
7270 const char *str, unsigned int len,
7271 void *buf, unsigned int size)
7273 const struct arg *arg_data = pop_args(ctx);
7274 const struct arg *arg_len = pop_args(ctx);
7275 const struct arg *arg_addr = pop_args(ctx);
7276 char tmp[16]; /* Ought to be enough. */
7278 unsigned int hexlen = len;
7279 unsigned int length = 256;
7280 uint8_t hex_tmp[length];
7282 /* Arguments are expected. */
7286 push_args(ctx, arg_data);
7290 push_args(ctx, arg_len);
7291 push_args(ctx, arg_data);
7294 size = arg_data->size;
7295 /* Bit-mask fill is not supported. */
7301 /* translate bytes string to array. */
7302 if (str[0] == '0' && ((str[1] == 'x') ||
7307 if (hexlen > length)
7309 ret = parse_hex_string(str, hex_tmp, &hexlen);
7312 /* Let parse_int() fill length information first. */
7313 ret = snprintf(tmp, sizeof(tmp), "%u", hexlen);
7316 /* Save length if requested. */
7317 if (arg_len->size) {
7318 push_args(ctx, arg_len);
7319 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
7325 buf = (uint8_t *)ctx->object + arg_data->offset;
7326 /* Output buffer is not necessarily NUL-terminated. */
7327 memcpy(buf, hex_tmp, hexlen);
7328 memset((uint8_t *)buf + hexlen, 0x00, size - hexlen);
7330 memset((uint8_t *)ctx->objmask + arg_data->offset,
7332 /* Save address if requested. */
7333 if (arg_addr->size) {
7334 memcpy((uint8_t *)ctx->object + arg_addr->offset,
7336 (uint8_t *)ctx->object + arg_data->offset
7340 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
7342 (uint8_t *)ctx->objmask + arg_data->offset
7348 push_args(ctx, arg_addr);
7349 push_args(ctx, arg_len);
7350 push_args(ctx, arg_data);
7356 * Parse a zero-ended string.
7359 parse_string0(struct context *ctx, const struct token *token __rte_unused,
7360 const char *str, unsigned int len,
7361 void *buf, unsigned int size)
7363 const struct arg *arg_data = pop_args(ctx);
7365 /* Arguments are expected. */
7368 size = arg_data->size;
7369 /* Bit-mask fill is not supported. */
7370 if (arg_data->mask || size < len + 1)
7374 buf = (uint8_t *)ctx->object + arg_data->offset;
7375 strncpy(buf, str, len);
7377 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
7380 push_args(ctx, arg_data);
7385 * Parse a MAC address.
7387 * Last argument (ctx->args) is retrieved to determine storage size and
7391 parse_mac_addr(struct context *ctx, const struct token *token,
7392 const char *str, unsigned int len,
7393 void *buf, unsigned int size)
7395 const struct arg *arg = pop_args(ctx);
7396 struct rte_ether_addr tmp;
7400 /* Argument is expected. */
7404 /* Bit-mask fill is not supported. */
7405 if (arg->mask || size != sizeof(tmp))
7407 /* Only network endian is supported. */
7410 ret = cmdline_parse_etheraddr(NULL, str, &tmp, size);
7411 if (ret < 0 || (unsigned int)ret != len)
7415 buf = (uint8_t *)ctx->object + arg->offset;
7416 memcpy(buf, &tmp, size);
7418 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
7421 push_args(ctx, arg);
7426 * Parse an IPv4 address.
7428 * Last argument (ctx->args) is retrieved to determine storage size and
7432 parse_ipv4_addr(struct context *ctx, const struct token *token,
7433 const char *str, unsigned int len,
7434 void *buf, unsigned int size)
7436 const struct arg *arg = pop_args(ctx);
7441 /* Argument is expected. */
7445 /* Bit-mask fill is not supported. */
7446 if (arg->mask || size != sizeof(tmp))
7448 /* Only network endian is supported. */
7451 memcpy(str2, str, len);
7453 ret = inet_pton(AF_INET, str2, &tmp);
7455 /* Attempt integer parsing. */
7456 push_args(ctx, arg);
7457 return parse_int(ctx, token, str, len, buf, size);
7461 buf = (uint8_t *)ctx->object + arg->offset;
7462 memcpy(buf, &tmp, size);
7464 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
7467 push_args(ctx, arg);
7472 * Parse an IPv6 address.
7474 * Last argument (ctx->args) is retrieved to determine storage size and
7478 parse_ipv6_addr(struct context *ctx, const struct token *token,
7479 const char *str, unsigned int len,
7480 void *buf, unsigned int size)
7482 const struct arg *arg = pop_args(ctx);
7484 struct in6_addr tmp;
7488 /* Argument is expected. */
7492 /* Bit-mask fill is not supported. */
7493 if (arg->mask || size != sizeof(tmp))
7495 /* Only network endian is supported. */
7498 memcpy(str2, str, len);
7500 ret = inet_pton(AF_INET6, str2, &tmp);
7505 buf = (uint8_t *)ctx->object + arg->offset;
7506 memcpy(buf, &tmp, size);
7508 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
7511 push_args(ctx, arg);
7515 /** Boolean values (even indices stand for false). */
7516 static const char *const boolean_name[] = {
7526 * Parse a boolean value.
7528 * Last argument (ctx->args) is retrieved to determine storage size and
7532 parse_boolean(struct context *ctx, const struct token *token,
7533 const char *str, unsigned int len,
7534 void *buf, unsigned int size)
7536 const struct arg *arg = pop_args(ctx);
7540 /* Argument is expected. */
7543 for (i = 0; boolean_name[i]; ++i)
7544 if (!strcmp_partial(boolean_name[i], str, len))
7546 /* Process token as integer. */
7547 if (boolean_name[i])
7548 str = i & 1 ? "1" : "0";
7549 push_args(ctx, arg);
7550 ret = parse_int(ctx, token, str, strlen(str), buf, size);
7551 return ret > 0 ? (int)len : ret;
7554 /** Parse port and update context. */
7556 parse_port(struct context *ctx, const struct token *token,
7557 const char *str, unsigned int len,
7558 void *buf, unsigned int size)
7560 struct buffer *out = &(struct buffer){ .port = 0 };
7568 ctx->objmask = NULL;
7569 size = sizeof(*out);
7571 ret = parse_int(ctx, token, str, len, out, size);
7573 ctx->port = out->port;
7580 parse_ia_id2ptr(struct context *ctx, const struct token *token,
7581 const char *str, unsigned int len,
7582 void *buf, unsigned int size)
7584 struct rte_flow_action *action = ctx->object;
7592 ctx->objmask = NULL;
7593 ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
7594 ctx->object = action;
7595 if (ret != (int)len)
7597 /* set indirect action */
7599 action->conf = port_action_handle_get_by_id(ctx->port, id);
7600 ret = (action->conf) ? ret : -1;
7605 /** Parse set command, initialize output buffer for subsequent tokens. */
7607 parse_set_raw_encap_decap(struct context *ctx, const struct token *token,
7608 const char *str, unsigned int len,
7609 void *buf, unsigned int size)
7611 struct buffer *out = buf;
7613 /* Token name must match. */
7614 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7616 /* Nothing else to do if there is no buffer. */
7619 /* Make sure buffer is large enough. */
7620 if (size < sizeof(*out))
7623 ctx->objmask = NULL;
7627 out->command = ctx->curr;
7628 /* For encap/decap we need is pattern */
7629 out->args.vc.pattern = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7634 /** Parse set command, initialize output buffer for subsequent tokens. */
7636 parse_set_sample_action(struct context *ctx, const struct token *token,
7637 const char *str, unsigned int len,
7638 void *buf, unsigned int size)
7640 struct buffer *out = buf;
7642 /* Token name must match. */
7643 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7645 /* Nothing else to do if there is no buffer. */
7648 /* Make sure buffer is large enough. */
7649 if (size < sizeof(*out))
7652 ctx->objmask = NULL;
7656 out->command = ctx->curr;
7657 /* For sampler we need is actions */
7658 out->args.vc.actions = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7664 * Parse set raw_encap/raw_decap command,
7665 * initialize output buffer for subsequent tokens.
7668 parse_set_init(struct context *ctx, const struct token *token,
7669 const char *str, unsigned int len,
7670 void *buf, unsigned int size)
7672 struct buffer *out = buf;
7674 /* Token name must match. */
7675 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7677 /* Nothing else to do if there is no buffer. */
7680 /* Make sure buffer is large enough. */
7681 if (size < sizeof(*out))
7683 /* Initialize buffer. */
7684 memset(out, 0x00, sizeof(*out));
7685 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
7688 ctx->objmask = NULL;
7689 if (!out->command) {
7690 if (ctx->curr != SET)
7692 if (sizeof(*out) > size)
7694 out->command = ctx->curr;
7695 out->args.vc.data = (uint8_t *)out + size;
7696 ctx->object = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7702 /** No completion. */
7704 comp_none(struct context *ctx, const struct token *token,
7705 unsigned int ent, char *buf, unsigned int size)
7715 /** Complete boolean values. */
7717 comp_boolean(struct context *ctx, const struct token *token,
7718 unsigned int ent, char *buf, unsigned int size)
7724 for (i = 0; boolean_name[i]; ++i)
7725 if (buf && i == ent)
7726 return strlcpy(buf, boolean_name[i], size);
7732 /** Complete action names. */
7734 comp_action(struct context *ctx, const struct token *token,
7735 unsigned int ent, char *buf, unsigned int size)
7741 for (i = 0; next_action[i]; ++i)
7742 if (buf && i == ent)
7743 return strlcpy(buf, token_list[next_action[i]].name,
7750 /** Complete available ports. */
7752 comp_port(struct context *ctx, const struct token *token,
7753 unsigned int ent, char *buf, unsigned int size)
7760 RTE_ETH_FOREACH_DEV(p) {
7761 if (buf && i == ent)
7762 return snprintf(buf, size, "%u", p);
7770 /** Complete available rule IDs. */
7772 comp_rule_id(struct context *ctx, const struct token *token,
7773 unsigned int ent, char *buf, unsigned int size)
7776 struct rte_port *port;
7777 struct port_flow *pf;
7780 if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
7781 ctx->port == (portid_t)RTE_PORT_ALL)
7783 port = &ports[ctx->port];
7784 for (pf = port->flow_list; pf != NULL; pf = pf->next) {
7785 if (buf && i == ent)
7786 return snprintf(buf, size, "%u", pf->id);
7794 /** Complete type field for RSS action. */
7796 comp_vc_action_rss_type(struct context *ctx, const struct token *token,
7797 unsigned int ent, char *buf, unsigned int size)
7803 for (i = 0; rss_type_table[i].str; ++i)
7808 return strlcpy(buf, rss_type_table[ent].str, size);
7810 return snprintf(buf, size, "end");
7814 /** Complete queue field for RSS action. */
7816 comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
7817 unsigned int ent, char *buf, unsigned int size)
7824 return snprintf(buf, size, "%u", ent);
7826 return snprintf(buf, size, "end");
7830 /** Complete index number for set raw_encap/raw_decap commands. */
7832 comp_set_raw_index(struct context *ctx, const struct token *token,
7833 unsigned int ent, char *buf, unsigned int size)
7839 RTE_SET_USED(token);
7840 for (idx = 0; idx < RAW_ENCAP_CONFS_MAX_NUM; ++idx) {
7841 if (buf && idx == ent)
7842 return snprintf(buf, size, "%u", idx);
7848 /** Complete index number for set raw_encap/raw_decap commands. */
7850 comp_set_sample_index(struct context *ctx, const struct token *token,
7851 unsigned int ent, char *buf, unsigned int size)
7857 RTE_SET_USED(token);
7858 for (idx = 0; idx < RAW_SAMPLE_CONFS_MAX_NUM; ++idx) {
7859 if (buf && idx == ent)
7860 return snprintf(buf, size, "%u", idx);
7866 /** Complete operation for modify_field command. */
7868 comp_set_modify_field_op(struct context *ctx, const struct token *token,
7869 unsigned int ent, char *buf, unsigned int size)
7874 RTE_SET_USED(token);
7875 for (idx = 0; modify_field_ops[idx]; ++idx)
7880 return strlcpy(buf, modify_field_ops[ent], size);
7884 /** Complete field id for modify_field command. */
7886 comp_set_modify_field_id(struct context *ctx, const struct token *token,
7887 unsigned int ent, char *buf, unsigned int size)
7892 RTE_SET_USED(token);
7893 for (idx = 0; modify_field_ids[idx]; ++idx)
7898 return strlcpy(buf, modify_field_ids[ent], size);
7902 /** Internal context. */
7903 static struct context cmd_flow_context;
7905 /** Global parser instance (cmdline API). */
7906 cmdline_parse_inst_t cmd_flow;
7907 cmdline_parse_inst_t cmd_set_raw;
7909 /** Initialize context. */
7911 cmd_flow_context_init(struct context *ctx)
7913 /* A full memset() is not necessary. */
7923 ctx->objmask = NULL;
7926 /** Parse a token (cmdline API). */
7928 cmd_flow_parse(cmdline_parse_token_hdr_t *hdr, const char *src, void *result,
7931 struct context *ctx = &cmd_flow_context;
7932 const struct token *token;
7933 const enum index *list;
7938 token = &token_list[ctx->curr];
7939 /* Check argument length. */
7942 for (len = 0; src[len]; ++len)
7943 if (src[len] == '#' || isspace(src[len]))
7947 /* Last argument and EOL detection. */
7948 for (i = len; src[i]; ++i)
7949 if (src[i] == '#' || src[i] == '\r' || src[i] == '\n')
7951 else if (!isspace(src[i])) {
7956 if (src[i] == '\r' || src[i] == '\n') {
7960 /* Initialize context if necessary. */
7961 if (!ctx->next_num) {
7964 ctx->next[ctx->next_num++] = token->next[0];
7966 /* Process argument through candidates. */
7967 ctx->prev = ctx->curr;
7968 list = ctx->next[ctx->next_num - 1];
7969 for (i = 0; list[i]; ++i) {
7970 const struct token *next = &token_list[list[i]];
7973 ctx->curr = list[i];
7975 tmp = next->call(ctx, next, src, len, result, size);
7977 tmp = parse_default(ctx, next, src, len, result, size);
7978 if (tmp == -1 || tmp != len)
7986 /* Push subsequent tokens if any. */
7988 for (i = 0; token->next[i]; ++i) {
7989 if (ctx->next_num == RTE_DIM(ctx->next))
7991 ctx->next[ctx->next_num++] = token->next[i];
7993 /* Push arguments if any. */
7995 for (i = 0; token->args[i]; ++i) {
7996 if (ctx->args_num == RTE_DIM(ctx->args))
7998 ctx->args[ctx->args_num++] = token->args[i];
8003 /** Return number of completion entries (cmdline API). */
8005 cmd_flow_complete_get_nb(cmdline_parse_token_hdr_t *hdr)
8007 struct context *ctx = &cmd_flow_context;
8008 const struct token *token = &token_list[ctx->curr];
8009 const enum index *list;
8013 /* Count number of tokens in current list. */
8015 list = ctx->next[ctx->next_num - 1];
8017 list = token->next[0];
8018 for (i = 0; list[i]; ++i)
8023 * If there is a single token, use its completion callback, otherwise
8024 * return the number of entries.
8026 token = &token_list[list[0]];
8027 if (i == 1 && token->comp) {
8028 /* Save index for cmd_flow_get_help(). */
8029 ctx->prev = list[0];
8030 return token->comp(ctx, token, 0, NULL, 0);
8035 /** Return a completion entry (cmdline API). */
8037 cmd_flow_complete_get_elt(cmdline_parse_token_hdr_t *hdr, int index,
8038 char *dst, unsigned int size)
8040 struct context *ctx = &cmd_flow_context;
8041 const struct token *token = &token_list[ctx->curr];
8042 const enum index *list;
8046 /* Count number of tokens in current list. */
8048 list = ctx->next[ctx->next_num - 1];
8050 list = token->next[0];
8051 for (i = 0; list[i]; ++i)
8055 /* If there is a single token, use its completion callback. */
8056 token = &token_list[list[0]];
8057 if (i == 1 && token->comp) {
8058 /* Save index for cmd_flow_get_help(). */
8059 ctx->prev = list[0];
8060 return token->comp(ctx, token, index, dst, size) < 0 ? -1 : 0;
8062 /* Otherwise make sure the index is valid and use defaults. */
8065 token = &token_list[list[index]];
8066 strlcpy(dst, token->name, size);
8067 /* Save index for cmd_flow_get_help(). */
8068 ctx->prev = list[index];
8072 /** Populate help strings for current token (cmdline API). */
8074 cmd_flow_get_help(cmdline_parse_token_hdr_t *hdr, char *dst, unsigned int size)
8076 struct context *ctx = &cmd_flow_context;
8077 const struct token *token = &token_list[ctx->prev];
8082 /* Set token type and update global help with details. */
8083 strlcpy(dst, (token->type ? token->type : "TOKEN"), size);
8085 cmd_flow.help_str = token->help;
8087 cmd_flow.help_str = token->name;
8091 /** Token definition template (cmdline API). */
8092 static struct cmdline_token_hdr cmd_flow_token_hdr = {
8093 .ops = &(struct cmdline_token_ops){
8094 .parse = cmd_flow_parse,
8095 .complete_get_nb = cmd_flow_complete_get_nb,
8096 .complete_get_elt = cmd_flow_complete_get_elt,
8097 .get_help = cmd_flow_get_help,
8102 /** Populate the next dynamic token. */
8104 cmd_flow_tok(cmdline_parse_token_hdr_t **hdr,
8105 cmdline_parse_token_hdr_t **hdr_inst)
8107 struct context *ctx = &cmd_flow_context;
8109 /* Always reinitialize context before requesting the first token. */
8110 if (!(hdr_inst - cmd_flow.tokens))
8111 cmd_flow_context_init(ctx);
8112 /* Return NULL when no more tokens are expected. */
8113 if (!ctx->next_num && ctx->curr) {
8117 /* Determine if command should end here. */
8118 if (ctx->eol && ctx->last && ctx->next_num) {
8119 const enum index *list = ctx->next[ctx->next_num - 1];
8122 for (i = 0; list[i]; ++i) {
8129 *hdr = &cmd_flow_token_hdr;
8132 /** Dispatch parsed buffer to function calls. */
8134 cmd_flow_parsed(const struct buffer *in)
8136 switch (in->command) {
8137 case INDIRECT_ACTION_CREATE:
8138 port_action_handle_create(
8139 in->port, in->args.vc.attr.group,
8140 &((const struct rte_flow_indir_action_conf) {
8141 .ingress = in->args.vc.attr.ingress,
8142 .egress = in->args.vc.attr.egress,
8143 .transfer = in->args.vc.attr.transfer,
8145 in->args.vc.actions);
8147 case INDIRECT_ACTION_DESTROY:
8148 port_action_handle_destroy(in->port,
8149 in->args.ia_destroy.action_id_n,
8150 in->args.ia_destroy.action_id);
8152 case INDIRECT_ACTION_UPDATE:
8153 port_action_handle_update(in->port, in->args.vc.attr.group,
8154 in->args.vc.actions);
8156 case INDIRECT_ACTION_QUERY:
8157 port_action_handle_query(in->port, in->args.ia.action_id);
8160 port_flow_validate(in->port, &in->args.vc.attr,
8161 in->args.vc.pattern, in->args.vc.actions,
8162 &in->args.vc.tunnel_ops);
8165 port_flow_create(in->port, &in->args.vc.attr,
8166 in->args.vc.pattern, in->args.vc.actions,
8167 &in->args.vc.tunnel_ops);
8170 port_flow_destroy(in->port, in->args.destroy.rule_n,
8171 in->args.destroy.rule);
8174 port_flow_flush(in->port);
8178 port_flow_dump(in->port, in->args.dump.mode,
8179 in->args.dump.rule, in->args.dump.file);
8182 port_flow_query(in->port, in->args.query.rule,
8183 &in->args.query.action);
8186 port_flow_list(in->port, in->args.list.group_n,
8187 in->args.list.group);
8190 port_flow_isolate(in->port, in->args.isolate.set);
8193 port_flow_aged(in->port, in->args.aged.destroy);
8196 port_flow_tunnel_create(in->port, &in->args.vc.tunnel_ops);
8198 case TUNNEL_DESTROY:
8199 port_flow_tunnel_destroy(in->port, in->args.vc.tunnel_ops.id);
8202 port_flow_tunnel_list(in->port);
8205 port_meter_policy_add(in->port, in->args.policy.policy_id,
8206 in->args.vc.actions);
8213 /** Token generator and output processing callback (cmdline API). */
8215 cmd_flow_cb(void *arg0, struct cmdline *cl, void *arg2)
8218 cmd_flow_tok(arg0, arg2);
8220 cmd_flow_parsed(arg0);
8223 /** Global parser instance (cmdline API). */
8224 cmdline_parse_inst_t cmd_flow = {
8226 .data = NULL, /**< Unused. */
8227 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
8230 }, /**< Tokens are returned by cmd_flow_tok(). */
8233 /** set cmd facility. Reuse cmd flow's infrastructure as much as possible. */
8236 update_fields(uint8_t *buf, struct rte_flow_item *item, uint16_t next_proto)
8238 struct rte_ipv4_hdr *ipv4;
8239 struct rte_ether_hdr *eth;
8240 struct rte_ipv6_hdr *ipv6;
8241 struct rte_vxlan_hdr *vxlan;
8242 struct rte_vxlan_gpe_hdr *gpe;
8243 struct rte_flow_item_nvgre *nvgre;
8244 uint32_t ipv6_vtc_flow;
8246 switch (item->type) {
8247 case RTE_FLOW_ITEM_TYPE_ETH:
8248 eth = (struct rte_ether_hdr *)buf;
8250 eth->ether_type = rte_cpu_to_be_16(next_proto);
8252 case RTE_FLOW_ITEM_TYPE_IPV4:
8253 ipv4 = (struct rte_ipv4_hdr *)buf;
8254 if (!ipv4->version_ihl)
8255 ipv4->version_ihl = RTE_IPV4_VHL_DEF;
8256 if (next_proto && ipv4->next_proto_id == 0)
8257 ipv4->next_proto_id = (uint8_t)next_proto;
8259 case RTE_FLOW_ITEM_TYPE_IPV6:
8260 ipv6 = (struct rte_ipv6_hdr *)buf;
8261 if (next_proto && ipv6->proto == 0)
8262 ipv6->proto = (uint8_t)next_proto;
8263 ipv6_vtc_flow = rte_be_to_cpu_32(ipv6->vtc_flow);
8264 ipv6_vtc_flow &= 0x0FFFFFFF; /*< reset version bits. */
8265 ipv6_vtc_flow |= 0x60000000; /*< set ipv6 version. */
8266 ipv6->vtc_flow = rte_cpu_to_be_32(ipv6_vtc_flow);
8268 case RTE_FLOW_ITEM_TYPE_VXLAN:
8269 vxlan = (struct rte_vxlan_hdr *)buf;
8270 vxlan->vx_flags = 0x08;
8272 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
8273 gpe = (struct rte_vxlan_gpe_hdr *)buf;
8274 gpe->vx_flags = 0x0C;
8276 case RTE_FLOW_ITEM_TYPE_NVGRE:
8277 nvgre = (struct rte_flow_item_nvgre *)buf;
8278 nvgre->protocol = rte_cpu_to_be_16(0x6558);
8279 nvgre->c_k_s_rsvd0_ver = rte_cpu_to_be_16(0x2000);
8286 /** Helper of get item's default mask. */
8288 flow_item_default_mask(const struct rte_flow_item *item)
8290 const void *mask = NULL;
8291 static rte_be32_t gre_key_default_mask = RTE_BE32(UINT32_MAX);
8293 switch (item->type) {
8294 case RTE_FLOW_ITEM_TYPE_ANY:
8295 mask = &rte_flow_item_any_mask;
8297 case RTE_FLOW_ITEM_TYPE_VF:
8298 mask = &rte_flow_item_vf_mask;
8300 case RTE_FLOW_ITEM_TYPE_PORT_ID:
8301 mask = &rte_flow_item_port_id_mask;
8303 case RTE_FLOW_ITEM_TYPE_RAW:
8304 mask = &rte_flow_item_raw_mask;
8306 case RTE_FLOW_ITEM_TYPE_ETH:
8307 mask = &rte_flow_item_eth_mask;
8309 case RTE_FLOW_ITEM_TYPE_VLAN:
8310 mask = &rte_flow_item_vlan_mask;
8312 case RTE_FLOW_ITEM_TYPE_IPV4:
8313 mask = &rte_flow_item_ipv4_mask;
8315 case RTE_FLOW_ITEM_TYPE_IPV6:
8316 mask = &rte_flow_item_ipv6_mask;
8318 case RTE_FLOW_ITEM_TYPE_ICMP:
8319 mask = &rte_flow_item_icmp_mask;
8321 case RTE_FLOW_ITEM_TYPE_UDP:
8322 mask = &rte_flow_item_udp_mask;
8324 case RTE_FLOW_ITEM_TYPE_TCP:
8325 mask = &rte_flow_item_tcp_mask;
8327 case RTE_FLOW_ITEM_TYPE_SCTP:
8328 mask = &rte_flow_item_sctp_mask;
8330 case RTE_FLOW_ITEM_TYPE_VXLAN:
8331 mask = &rte_flow_item_vxlan_mask;
8333 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
8334 mask = &rte_flow_item_vxlan_gpe_mask;
8336 case RTE_FLOW_ITEM_TYPE_E_TAG:
8337 mask = &rte_flow_item_e_tag_mask;
8339 case RTE_FLOW_ITEM_TYPE_NVGRE:
8340 mask = &rte_flow_item_nvgre_mask;
8342 case RTE_FLOW_ITEM_TYPE_MPLS:
8343 mask = &rte_flow_item_mpls_mask;
8345 case RTE_FLOW_ITEM_TYPE_GRE:
8346 mask = &rte_flow_item_gre_mask;
8348 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
8349 mask = &gre_key_default_mask;
8351 case RTE_FLOW_ITEM_TYPE_META:
8352 mask = &rte_flow_item_meta_mask;
8354 case RTE_FLOW_ITEM_TYPE_FUZZY:
8355 mask = &rte_flow_item_fuzzy_mask;
8357 case RTE_FLOW_ITEM_TYPE_GTP:
8358 mask = &rte_flow_item_gtp_mask;
8360 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
8361 mask = &rte_flow_item_gtp_psc_mask;
8363 case RTE_FLOW_ITEM_TYPE_GENEVE:
8364 mask = &rte_flow_item_geneve_mask;
8366 case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
8367 mask = &rte_flow_item_geneve_opt_mask;
8369 case RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID:
8370 mask = &rte_flow_item_pppoe_proto_id_mask;
8372 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
8373 mask = &rte_flow_item_l2tpv3oip_mask;
8375 case RTE_FLOW_ITEM_TYPE_ESP:
8376 mask = &rte_flow_item_esp_mask;
8378 case RTE_FLOW_ITEM_TYPE_AH:
8379 mask = &rte_flow_item_ah_mask;
8381 case RTE_FLOW_ITEM_TYPE_PFCP:
8382 mask = &rte_flow_item_pfcp_mask;
8384 case RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR:
8385 case RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT:
8386 mask = &rte_flow_item_ethdev_mask;
8394 /** Dispatch parsed buffer to function calls. */
8396 cmd_set_raw_parsed_sample(const struct buffer *in)
8398 uint32_t n = in->args.vc.actions_n;
8400 struct rte_flow_action *action = NULL;
8401 struct rte_flow_action *data = NULL;
8402 const struct rte_flow_action_rss *rss = NULL;
8404 uint16_t idx = in->port; /* We borrow port field as index */
8405 uint32_t max_size = sizeof(struct rte_flow_action) *
8406 ACTION_SAMPLE_ACTIONS_NUM;
8408 RTE_ASSERT(in->command == SET_SAMPLE_ACTIONS);
8409 data = (struct rte_flow_action *)&raw_sample_confs[idx].data;
8410 memset(data, 0x00, max_size);
8411 for (; i <= n - 1; i++) {
8412 action = in->args.vc.actions + i;
8413 if (action->type == RTE_FLOW_ACTION_TYPE_END)
8415 switch (action->type) {
8416 case RTE_FLOW_ACTION_TYPE_MARK:
8417 size = sizeof(struct rte_flow_action_mark);
8418 rte_memcpy(&sample_mark[idx],
8419 (const void *)action->conf, size);
8420 action->conf = &sample_mark[idx];
8422 case RTE_FLOW_ACTION_TYPE_COUNT:
8423 size = sizeof(struct rte_flow_action_count);
8424 rte_memcpy(&sample_count[idx],
8425 (const void *)action->conf, size);
8426 action->conf = &sample_count[idx];
8428 case RTE_FLOW_ACTION_TYPE_QUEUE:
8429 size = sizeof(struct rte_flow_action_queue);
8430 rte_memcpy(&sample_queue[idx],
8431 (const void *)action->conf, size);
8432 action->conf = &sample_queue[idx];
8434 case RTE_FLOW_ACTION_TYPE_RSS:
8435 size = sizeof(struct rte_flow_action_rss);
8437 rte_memcpy(&sample_rss_data[idx].conf,
8438 (const void *)rss, size);
8439 if (rss->key_len && rss->key) {
8440 sample_rss_data[idx].conf.key =
8441 sample_rss_data[idx].key;
8442 rte_memcpy((void *)((uintptr_t)
8443 sample_rss_data[idx].conf.key),
8444 (const void *)rss->key,
8445 sizeof(uint8_t) * rss->key_len);
8447 if (rss->queue_num && rss->queue) {
8448 sample_rss_data[idx].conf.queue =
8449 sample_rss_data[idx].queue;
8450 rte_memcpy((void *)((uintptr_t)
8451 sample_rss_data[idx].conf.queue),
8452 (const void *)rss->queue,
8453 sizeof(uint16_t) * rss->queue_num);
8455 action->conf = &sample_rss_data[idx].conf;
8457 case RTE_FLOW_ACTION_TYPE_RAW_ENCAP:
8458 size = sizeof(struct rte_flow_action_raw_encap);
8459 rte_memcpy(&sample_encap[idx],
8460 (const void *)action->conf, size);
8461 action->conf = &sample_encap[idx];
8463 case RTE_FLOW_ACTION_TYPE_PORT_ID:
8464 size = sizeof(struct rte_flow_action_port_id);
8465 rte_memcpy(&sample_port_id[idx],
8466 (const void *)action->conf, size);
8467 action->conf = &sample_port_id[idx];
8469 case RTE_FLOW_ACTION_TYPE_PF:
8471 case RTE_FLOW_ACTION_TYPE_VF:
8472 size = sizeof(struct rte_flow_action_vf);
8473 rte_memcpy(&sample_vf[idx],
8474 (const void *)action->conf, size);
8475 action->conf = &sample_vf[idx];
8477 case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP:
8478 size = sizeof(struct rte_flow_action_vxlan_encap);
8479 parse_setup_vxlan_encap_data(&sample_vxlan_encap[idx]);
8480 action->conf = &sample_vxlan_encap[idx].conf;
8482 case RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP:
8483 size = sizeof(struct rte_flow_action_nvgre_encap);
8484 parse_setup_nvgre_encap_data(&sample_nvgre_encap[idx]);
8485 action->conf = &sample_nvgre_encap[idx];
8488 fprintf(stderr, "Error - Not supported action\n");
8491 rte_memcpy(data, action, sizeof(struct rte_flow_action));
8496 /** Dispatch parsed buffer to function calls. */
8498 cmd_set_raw_parsed(const struct buffer *in)
8500 uint32_t n = in->args.vc.pattern_n;
8502 struct rte_flow_item *item = NULL;
8504 uint8_t *data = NULL;
8505 uint8_t *data_tail = NULL;
8506 size_t *total_size = NULL;
8507 uint16_t upper_layer = 0;
8509 uint16_t idx = in->port; /* We borrow port field as index */
8510 int gtp_psc = -1; /* GTP PSC option index. */
8512 if (in->command == SET_SAMPLE_ACTIONS)
8513 return cmd_set_raw_parsed_sample(in);
8514 RTE_ASSERT(in->command == SET_RAW_ENCAP ||
8515 in->command == SET_RAW_DECAP);
8516 if (in->command == SET_RAW_ENCAP) {
8517 total_size = &raw_encap_confs[idx].size;
8518 data = (uint8_t *)&raw_encap_confs[idx].data;
8520 total_size = &raw_decap_confs[idx].size;
8521 data = (uint8_t *)&raw_decap_confs[idx].data;
8524 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
8525 /* process hdr from upper layer to low layer (L3/L4 -> L2). */
8526 data_tail = data + ACTION_RAW_ENCAP_MAX_DATA;
8527 for (i = n - 1 ; i >= 0; --i) {
8528 const struct rte_flow_item_gtp *gtp;
8529 const struct rte_flow_item_geneve_opt *opt;
8531 item = in->args.vc.pattern + i;
8532 if (item->spec == NULL)
8533 item->spec = flow_item_default_mask(item);
8534 switch (item->type) {
8535 case RTE_FLOW_ITEM_TYPE_ETH:
8536 size = sizeof(struct rte_ether_hdr);
8538 case RTE_FLOW_ITEM_TYPE_VLAN:
8539 size = sizeof(struct rte_vlan_hdr);
8540 proto = RTE_ETHER_TYPE_VLAN;
8542 case RTE_FLOW_ITEM_TYPE_IPV4:
8543 size = sizeof(struct rte_ipv4_hdr);
8544 proto = RTE_ETHER_TYPE_IPV4;
8546 case RTE_FLOW_ITEM_TYPE_IPV6:
8547 size = sizeof(struct rte_ipv6_hdr);
8548 proto = RTE_ETHER_TYPE_IPV6;
8550 case RTE_FLOW_ITEM_TYPE_UDP:
8551 size = sizeof(struct rte_udp_hdr);
8554 case RTE_FLOW_ITEM_TYPE_TCP:
8555 size = sizeof(struct rte_tcp_hdr);
8558 case RTE_FLOW_ITEM_TYPE_VXLAN:
8559 size = sizeof(struct rte_vxlan_hdr);
8561 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
8562 size = sizeof(struct rte_vxlan_gpe_hdr);
8564 case RTE_FLOW_ITEM_TYPE_GRE:
8565 size = sizeof(struct rte_gre_hdr);
8568 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
8569 size = sizeof(rte_be32_t);
8572 case RTE_FLOW_ITEM_TYPE_MPLS:
8573 size = sizeof(struct rte_mpls_hdr);
8576 case RTE_FLOW_ITEM_TYPE_NVGRE:
8577 size = sizeof(struct rte_flow_item_nvgre);
8580 case RTE_FLOW_ITEM_TYPE_GENEVE:
8581 size = sizeof(struct rte_geneve_hdr);
8583 case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
8584 opt = (const struct rte_flow_item_geneve_opt *)
8586 size = offsetof(struct rte_flow_item_geneve_opt, data);
8587 if (opt->option_len && opt->data) {
8588 *total_size += opt->option_len *
8590 rte_memcpy(data_tail - (*total_size),
8592 opt->option_len * sizeof(uint32_t));
8595 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
8596 size = sizeof(rte_be32_t);
8599 case RTE_FLOW_ITEM_TYPE_ESP:
8600 size = sizeof(struct rte_esp_hdr);
8603 case RTE_FLOW_ITEM_TYPE_AH:
8604 size = sizeof(struct rte_flow_item_ah);
8607 case RTE_FLOW_ITEM_TYPE_GTP:
8609 size = sizeof(struct rte_gtp_hdr);
8612 if (gtp_psc != i + 1) {
8614 "Error - GTP PSC does not follow GTP\n");
8618 if ((gtp->v_pt_rsv_flags & 0x07) != 0x04) {
8619 /* Only E flag should be set. */
8621 "Error - GTP unsupported flags\n");
8624 struct rte_gtp_hdr_ext_word ext_word = {
8628 /* We have to add GTP header extra word. */
8629 *total_size += sizeof(ext_word);
8630 rte_memcpy(data_tail - (*total_size),
8631 &ext_word, sizeof(ext_word));
8633 size = sizeof(struct rte_gtp_hdr);
8635 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
8638 "Error - Multiple GTP PSC items\n");
8641 const struct rte_flow_item_gtp_psc
8649 psc.len = sizeof(psc);
8650 psc.pdu_type = opt->hdr.type;
8651 psc.qfi = opt->hdr.qfi;
8653 *total_size += sizeof(psc);
8654 rte_memcpy(data_tail - (*total_size),
8660 case RTE_FLOW_ITEM_TYPE_PFCP:
8661 size = sizeof(struct rte_flow_item_pfcp);
8664 fprintf(stderr, "Error - Not supported item\n");
8667 *total_size += size;
8668 rte_memcpy(data_tail - (*total_size), item->spec, size);
8669 /* update some fields which cannot be set by cmdline */
8670 update_fields((data_tail - (*total_size)), item,
8672 upper_layer = proto;
8674 if (verbose_level & 0x1)
8675 printf("total data size is %zu\n", (*total_size));
8676 RTE_ASSERT((*total_size) <= ACTION_RAW_ENCAP_MAX_DATA);
8677 memmove(data, (data_tail - (*total_size)), *total_size);
8682 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
8685 /** Populate help strings for current token (cmdline API). */
8687 cmd_set_raw_get_help(cmdline_parse_token_hdr_t *hdr, char *dst,
8690 struct context *ctx = &cmd_flow_context;
8691 const struct token *token = &token_list[ctx->prev];
8696 /* Set token type and update global help with details. */
8697 snprintf(dst, size, "%s", (token->type ? token->type : "TOKEN"));
8699 cmd_set_raw.help_str = token->help;
8701 cmd_set_raw.help_str = token->name;
8705 /** Token definition template (cmdline API). */
8706 static struct cmdline_token_hdr cmd_set_raw_token_hdr = {
8707 .ops = &(struct cmdline_token_ops){
8708 .parse = cmd_flow_parse,
8709 .complete_get_nb = cmd_flow_complete_get_nb,
8710 .complete_get_elt = cmd_flow_complete_get_elt,
8711 .get_help = cmd_set_raw_get_help,
8716 /** Populate the next dynamic token. */
8718 cmd_set_raw_tok(cmdline_parse_token_hdr_t **hdr,
8719 cmdline_parse_token_hdr_t **hdr_inst)
8721 struct context *ctx = &cmd_flow_context;
8723 /* Always reinitialize context before requesting the first token. */
8724 if (!(hdr_inst - cmd_set_raw.tokens)) {
8725 cmd_flow_context_init(ctx);
8726 ctx->curr = START_SET;
8728 /* Return NULL when no more tokens are expected. */
8729 if (!ctx->next_num && (ctx->curr != START_SET)) {
8733 /* Determine if command should end here. */
8734 if (ctx->eol && ctx->last && ctx->next_num) {
8735 const enum index *list = ctx->next[ctx->next_num - 1];
8738 for (i = 0; list[i]; ++i) {
8745 *hdr = &cmd_set_raw_token_hdr;
8748 /** Token generator and output processing callback (cmdline API). */
8750 cmd_set_raw_cb(void *arg0, struct cmdline *cl, void *arg2)
8753 cmd_set_raw_tok(arg0, arg2);
8755 cmd_set_raw_parsed(arg0);
8758 /** Global parser instance (cmdline API). */
8759 cmdline_parse_inst_t cmd_set_raw = {
8760 .f = cmd_set_raw_cb,
8761 .data = NULL, /**< Unused. */
8762 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
8765 }, /**< Tokens are returned by cmd_flow_tok(). */
8768 /* *** display raw_encap/raw_decap buf */
8769 struct cmd_show_set_raw_result {
8770 cmdline_fixed_string_t cmd_show;
8771 cmdline_fixed_string_t cmd_what;
8772 cmdline_fixed_string_t cmd_all;
8777 cmd_show_set_raw_parsed(void *parsed_result, struct cmdline *cl, void *data)
8779 struct cmd_show_set_raw_result *res = parsed_result;
8780 uint16_t index = res->cmd_index;
8782 uint8_t *raw_data = NULL;
8783 size_t raw_size = 0;
8784 char title[16] = {0};
8788 if (!strcmp(res->cmd_all, "all")) {
8791 } else if (index >= RAW_ENCAP_CONFS_MAX_NUM) {
8792 fprintf(stderr, "index should be 0-%u\n",
8793 RAW_ENCAP_CONFS_MAX_NUM - 1);
8797 if (!strcmp(res->cmd_what, "raw_encap")) {
8798 raw_data = (uint8_t *)&raw_encap_confs[index].data;
8799 raw_size = raw_encap_confs[index].size;
8800 snprintf(title, 16, "\nindex: %u", index);
8801 rte_hexdump(stdout, title, raw_data, raw_size);
8803 raw_data = (uint8_t *)&raw_decap_confs[index].data;
8804 raw_size = raw_decap_confs[index].size;
8805 snprintf(title, 16, "\nindex: %u", index);
8806 rte_hexdump(stdout, title, raw_data, raw_size);
8808 } while (all && ++index < RAW_ENCAP_CONFS_MAX_NUM);
8811 cmdline_parse_token_string_t cmd_show_set_raw_cmd_show =
8812 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
8814 cmdline_parse_token_string_t cmd_show_set_raw_cmd_what =
8815 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
8816 cmd_what, "raw_encap#raw_decap");
8817 cmdline_parse_token_num_t cmd_show_set_raw_cmd_index =
8818 TOKEN_NUM_INITIALIZER(struct cmd_show_set_raw_result,
8819 cmd_index, RTE_UINT16);
8820 cmdline_parse_token_string_t cmd_show_set_raw_cmd_all =
8821 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
8823 cmdline_parse_inst_t cmd_show_set_raw = {
8824 .f = cmd_show_set_raw_parsed,
8826 .help_str = "show <raw_encap|raw_decap> <index>",
8828 (void *)&cmd_show_set_raw_cmd_show,
8829 (void *)&cmd_show_set_raw_cmd_what,
8830 (void *)&cmd_show_set_raw_cmd_index,
8834 cmdline_parse_inst_t cmd_show_set_raw_all = {
8835 .f = cmd_show_set_raw_parsed,
8837 .help_str = "show <raw_encap|raw_decap> all",
8839 (void *)&cmd_show_set_raw_cmd_show,
8840 (void *)&cmd_show_set_raw_cmd_what,
8841 (void *)&cmd_show_set_raw_cmd_all,