1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2016 6WIND S.A.
3 * Copyright 2016 Mellanox Technologies, Ltd
13 #include <arpa/inet.h>
14 #include <sys/socket.h>
16 #include <rte_string_fns.h>
17 #include <rte_common.h>
18 #include <rte_ethdev.h>
19 #include <rte_byteorder.h>
20 #include <cmdline_parse.h>
21 #include <cmdline_parse_etheraddr.h>
22 #include <cmdline_parse_string.h>
23 #include <cmdline_parse_num.h>
25 #include <rte_hexdump.h>
26 #include <rte_vxlan.h>
30 #include <rte_geneve.h>
34 /** Parser token indices. */
60 /* TOP-level command. */
63 /* Top-level command. */
65 /* Sub-leve commands. */
72 /* Top-level command. */
74 /* Sub-level commands. */
87 /* Tunnel arguments. */
94 /* Destroy arguments. */
97 /* Query arguments. */
100 /* List arguments. */
103 /* Destroy aged flow arguments. */
106 /* Validate/create arguments. */
119 /* Indirect action arguments */
120 INDIRECT_ACTION_CREATE,
121 INDIRECT_ACTION_UPDATE,
122 INDIRECT_ACTION_DESTROY,
123 INDIRECT_ACTION_QUERY,
125 /* Indirect action create arguments */
126 INDIRECT_ACTION_CREATE_ID,
127 INDIRECT_ACTION_INGRESS,
128 INDIRECT_ACTION_EGRESS,
129 INDIRECT_ACTION_TRANSFER,
130 INDIRECT_ACTION_SPEC,
132 /* Indirect action destroy arguments */
133 INDIRECT_ACTION_DESTROY_ID,
135 /* Validate/create pattern. */
173 ITEM_VLAN_INNER_TYPE,
174 ITEM_VLAN_HAS_MORE_VLAN,
178 ITEM_IPV4_FRAGMENT_OFFSET,
190 ITEM_IPV6_HAS_FRAG_EXT,
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,
310 /* Validate/create actions. */
330 ACTION_RSS_FUNC_DEFAULT,
331 ACTION_RSS_FUNC_TOEPLITZ,
332 ACTION_RSS_FUNC_SIMPLE_XOR,
333 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ,
345 ACTION_PHY_PORT_ORIGINAL,
346 ACTION_PHY_PORT_INDEX,
348 ACTION_PORT_ID_ORIGINAL,
352 ACTION_METER_COLOR_TYPE,
353 ACTION_METER_COLOR_GREEN,
354 ACTION_METER_COLOR_YELLOW,
355 ACTION_METER_COLOR_RED,
357 ACTION_OF_SET_MPLS_TTL,
358 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
359 ACTION_OF_DEC_MPLS_TTL,
360 ACTION_OF_SET_NW_TTL,
361 ACTION_OF_SET_NW_TTL_NW_TTL,
362 ACTION_OF_DEC_NW_TTL,
363 ACTION_OF_COPY_TTL_OUT,
364 ACTION_OF_COPY_TTL_IN,
367 ACTION_OF_PUSH_VLAN_ETHERTYPE,
368 ACTION_OF_SET_VLAN_VID,
369 ACTION_OF_SET_VLAN_VID_VLAN_VID,
370 ACTION_OF_SET_VLAN_PCP,
371 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
373 ACTION_OF_POP_MPLS_ETHERTYPE,
375 ACTION_OF_PUSH_MPLS_ETHERTYPE,
382 ACTION_MPLSOGRE_ENCAP,
383 ACTION_MPLSOGRE_DECAP,
384 ACTION_MPLSOUDP_ENCAP,
385 ACTION_MPLSOUDP_DECAP,
387 ACTION_SET_IPV4_SRC_IPV4_SRC,
389 ACTION_SET_IPV4_DST_IPV4_DST,
391 ACTION_SET_IPV6_SRC_IPV6_SRC,
393 ACTION_SET_IPV6_DST_IPV6_DST,
395 ACTION_SET_TP_SRC_TP_SRC,
397 ACTION_SET_TP_DST_TP_DST,
403 ACTION_SET_MAC_SRC_MAC_SRC,
405 ACTION_SET_MAC_DST_MAC_DST,
407 ACTION_INC_TCP_SEQ_VALUE,
409 ACTION_DEC_TCP_SEQ_VALUE,
411 ACTION_INC_TCP_ACK_VALUE,
413 ACTION_DEC_TCP_ACK_VALUE,
416 ACTION_RAW_ENCAP_INDEX,
417 ACTION_RAW_ENCAP_INDEX_VALUE,
418 ACTION_RAW_DECAP_INDEX,
419 ACTION_RAW_DECAP_INDEX_VALUE,
422 ACTION_SET_TAG_INDEX,
425 ACTION_SET_META_DATA,
426 ACTION_SET_META_MASK,
427 ACTION_SET_IPV4_DSCP,
428 ACTION_SET_IPV4_DSCP_VALUE,
429 ACTION_SET_IPV6_DSCP,
430 ACTION_SET_IPV6_DSCP_VALUE,
436 ACTION_SAMPLE_INDEX_VALUE,
438 INDIRECT_ACTION_ID2PTR,
440 ACTION_MODIFY_FIELD_OP,
441 ACTION_MODIFY_FIELD_OP_VALUE,
442 ACTION_MODIFY_FIELD_DST_TYPE,
443 ACTION_MODIFY_FIELD_DST_TYPE_VALUE,
444 ACTION_MODIFY_FIELD_DST_LEVEL,
445 ACTION_MODIFY_FIELD_DST_OFFSET,
446 ACTION_MODIFY_FIELD_SRC_TYPE,
447 ACTION_MODIFY_FIELD_SRC_TYPE_VALUE,
448 ACTION_MODIFY_FIELD_SRC_LEVEL,
449 ACTION_MODIFY_FIELD_SRC_OFFSET,
450 ACTION_MODIFY_FIELD_SRC_VALUE,
451 ACTION_MODIFY_FIELD_WIDTH,
453 ACTION_CONNTRACK_UPDATE,
454 ACTION_CONNTRACK_UPDATE_DIR,
455 ACTION_CONNTRACK_UPDATE_CTX,
461 /** Maximum size for pattern in struct rte_flow_item_raw. */
462 #define ITEM_RAW_PATTERN_SIZE 40
464 /** Maximum size for GENEVE option data pattern in bytes. */
465 #define ITEM_GENEVE_OPT_DATA_SIZE 124
467 /** Storage size for struct rte_flow_item_raw including pattern. */
468 #define ITEM_RAW_SIZE \
469 (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE)
471 /** Maximum number of queue indices in struct rte_flow_action_rss. */
472 #define ACTION_RSS_QUEUE_NUM 128
474 /** Storage for struct rte_flow_action_rss including external data. */
475 struct action_rss_data {
476 struct rte_flow_action_rss conf;
477 uint8_t key[RSS_HASH_KEY_LENGTH];
478 uint16_t queue[ACTION_RSS_QUEUE_NUM];
481 /** Maximum data size in struct rte_flow_action_raw_encap. */
482 #define ACTION_RAW_ENCAP_MAX_DATA 512
483 #define RAW_ENCAP_CONFS_MAX_NUM 8
485 /** Storage for struct rte_flow_action_raw_encap. */
486 struct raw_encap_conf {
487 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
488 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
492 struct raw_encap_conf raw_encap_confs[RAW_ENCAP_CONFS_MAX_NUM];
494 /** Storage for struct rte_flow_action_raw_encap including external data. */
495 struct action_raw_encap_data {
496 struct rte_flow_action_raw_encap conf;
497 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
498 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
502 /** Storage for struct rte_flow_action_raw_decap. */
503 struct raw_decap_conf {
504 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
508 struct raw_decap_conf raw_decap_confs[RAW_ENCAP_CONFS_MAX_NUM];
510 /** Storage for struct rte_flow_action_raw_decap including external data. */
511 struct action_raw_decap_data {
512 struct rte_flow_action_raw_decap conf;
513 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
517 struct vxlan_encap_conf vxlan_encap_conf = {
521 .vni = "\x00\x00\x00",
523 .udp_dst = RTE_BE16(RTE_VXLAN_DEFAULT_PORT),
524 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
525 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
526 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
527 "\x00\x00\x00\x00\x00\x00\x00\x01",
528 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
529 "\x00\x00\x00\x00\x00\x00\x11\x11",
533 .eth_src = "\x00\x00\x00\x00\x00\x00",
534 .eth_dst = "\xff\xff\xff\xff\xff\xff",
537 /** Maximum number of items in struct rte_flow_action_vxlan_encap. */
538 #define ACTION_VXLAN_ENCAP_ITEMS_NUM 6
540 /** Storage for struct rte_flow_action_vxlan_encap including external data. */
541 struct action_vxlan_encap_data {
542 struct rte_flow_action_vxlan_encap conf;
543 struct rte_flow_item items[ACTION_VXLAN_ENCAP_ITEMS_NUM];
544 struct rte_flow_item_eth item_eth;
545 struct rte_flow_item_vlan item_vlan;
547 struct rte_flow_item_ipv4 item_ipv4;
548 struct rte_flow_item_ipv6 item_ipv6;
550 struct rte_flow_item_udp item_udp;
551 struct rte_flow_item_vxlan item_vxlan;
554 struct nvgre_encap_conf nvgre_encap_conf = {
557 .tni = "\x00\x00\x00",
558 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
559 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
560 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
561 "\x00\x00\x00\x00\x00\x00\x00\x01",
562 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
563 "\x00\x00\x00\x00\x00\x00\x11\x11",
565 .eth_src = "\x00\x00\x00\x00\x00\x00",
566 .eth_dst = "\xff\xff\xff\xff\xff\xff",
569 /** Maximum number of items in struct rte_flow_action_nvgre_encap. */
570 #define ACTION_NVGRE_ENCAP_ITEMS_NUM 5
572 /** Storage for struct rte_flow_action_nvgre_encap including external data. */
573 struct action_nvgre_encap_data {
574 struct rte_flow_action_nvgre_encap conf;
575 struct rte_flow_item items[ACTION_NVGRE_ENCAP_ITEMS_NUM];
576 struct rte_flow_item_eth item_eth;
577 struct rte_flow_item_vlan item_vlan;
579 struct rte_flow_item_ipv4 item_ipv4;
580 struct rte_flow_item_ipv6 item_ipv6;
582 struct rte_flow_item_nvgre item_nvgre;
585 struct l2_encap_conf l2_encap_conf;
587 struct l2_decap_conf l2_decap_conf;
589 struct mplsogre_encap_conf mplsogre_encap_conf;
591 struct mplsogre_decap_conf mplsogre_decap_conf;
593 struct mplsoudp_encap_conf mplsoudp_encap_conf;
595 struct mplsoudp_decap_conf mplsoudp_decap_conf;
597 struct rte_flow_action_conntrack conntrack_context;
599 #define ACTION_SAMPLE_ACTIONS_NUM 10
600 #define RAW_SAMPLE_CONFS_MAX_NUM 8
601 /** Storage for struct rte_flow_action_sample including external data. */
602 struct action_sample_data {
603 struct rte_flow_action_sample conf;
606 /** Storage for struct rte_flow_action_sample. */
607 struct raw_sample_conf {
608 struct rte_flow_action data[ACTION_SAMPLE_ACTIONS_NUM];
610 struct raw_sample_conf raw_sample_confs[RAW_SAMPLE_CONFS_MAX_NUM];
611 struct rte_flow_action_mark sample_mark[RAW_SAMPLE_CONFS_MAX_NUM];
612 struct rte_flow_action_queue sample_queue[RAW_SAMPLE_CONFS_MAX_NUM];
613 struct rte_flow_action_count sample_count[RAW_SAMPLE_CONFS_MAX_NUM];
614 struct rte_flow_action_port_id sample_port_id[RAW_SAMPLE_CONFS_MAX_NUM];
615 struct rte_flow_action_raw_encap sample_encap[RAW_SAMPLE_CONFS_MAX_NUM];
616 struct action_vxlan_encap_data sample_vxlan_encap[RAW_SAMPLE_CONFS_MAX_NUM];
617 struct action_nvgre_encap_data sample_nvgre_encap[RAW_SAMPLE_CONFS_MAX_NUM];
618 struct action_rss_data sample_rss_data[RAW_SAMPLE_CONFS_MAX_NUM];
619 struct rte_flow_action_vf sample_vf[RAW_SAMPLE_CONFS_MAX_NUM];
621 static const char *const modify_field_ops[] = {
622 "set", "add", "sub", NULL
625 static const char *const modify_field_ids[] = {
626 "start", "mac_dst", "mac_src",
627 "vlan_type", "vlan_id", "mac_type",
628 "ipv4_dscp", "ipv4_ttl", "ipv4_src", "ipv4_dst",
629 "ipv6_dscp", "ipv6_hoplimit", "ipv6_src", "ipv6_dst",
630 "tcp_port_src", "tcp_port_dst",
631 "tcp_seq_num", "tcp_ack_num", "tcp_flags",
632 "udp_port_src", "udp_port_dst",
633 "vxlan_vni", "geneve_vni", "gtp_teid",
634 "tag", "mark", "meta", "pointer", "value", NULL
637 /** Maximum number of subsequent tokens and arguments on the stack. */
638 #define CTX_STACK_SIZE 16
640 /** Parser context. */
642 /** Stack of subsequent token lists to process. */
643 const enum index *next[CTX_STACK_SIZE];
644 /** Arguments for stacked tokens. */
645 const void *args[CTX_STACK_SIZE];
646 enum index curr; /**< Current token index. */
647 enum index prev; /**< Index of the last token seen. */
648 int next_num; /**< Number of entries in next[]. */
649 int args_num; /**< Number of entries in args[]. */
650 uint32_t eol:1; /**< EOL has been detected. */
651 uint32_t last:1; /**< No more arguments. */
652 portid_t port; /**< Current port ID (for completions). */
653 uint32_t objdata; /**< Object-specific data. */
654 void *object; /**< Address of current object for relative offsets. */
655 void *objmask; /**< Object a full mask must be written to. */
658 /** Token argument. */
660 uint32_t hton:1; /**< Use network byte ordering. */
661 uint32_t sign:1; /**< Value is signed. */
662 uint32_t bounded:1; /**< Value is bounded. */
663 uintmax_t min; /**< Minimum value if bounded. */
664 uintmax_t max; /**< Maximum value if bounded. */
665 uint32_t offset; /**< Relative offset from ctx->object. */
666 uint32_t size; /**< Field size. */
667 const uint8_t *mask; /**< Bit-mask to use instead of offset/size. */
670 /** Parser token definition. */
672 /** Type displayed during completion (defaults to "TOKEN"). */
674 /** Help displayed during completion (defaults to token name). */
676 /** Private data used by parser functions. */
679 * Lists of subsequent tokens to push on the stack. Each call to the
680 * parser consumes the last entry of that stack.
682 const enum index *const *next;
683 /** Arguments stack for subsequent tokens that need them. */
684 const struct arg *const *args;
686 * Token-processing callback, returns -1 in case of error, the
687 * length of the matched string otherwise. If NULL, attempts to
688 * match the token name.
690 * If buf is not NULL, the result should be stored in it according
691 * to context. An error is returned if not large enough.
693 int (*call)(struct context *ctx, const struct token *token,
694 const char *str, unsigned int len,
695 void *buf, unsigned int size);
697 * Callback that provides possible values for this token, used for
698 * completion. Returns -1 in case of error, the number of possible
699 * values otherwise. If NULL, the token name is used.
701 * If buf is not NULL, entry index ent is written to buf and the
702 * full length of the entry is returned (same behavior as
705 int (*comp)(struct context *ctx, const struct token *token,
706 unsigned int ent, char *buf, unsigned int size);
707 /** Mandatory token name, no default value. */
711 /** Static initializer for the next field. */
712 #define NEXT(...) (const enum index *const []){ __VA_ARGS__, NULL, }
714 /** Static initializer for a NEXT() entry. */
715 #define NEXT_ENTRY(...) (const enum index []){ __VA_ARGS__, ZERO, }
717 /** Static initializer for the args field. */
718 #define ARGS(...) (const struct arg *const []){ __VA_ARGS__, NULL, }
720 /** Static initializer for ARGS() to target a field. */
721 #define ARGS_ENTRY(s, f) \
722 (&(const struct arg){ \
723 .offset = offsetof(s, f), \
724 .size = sizeof(((s *)0)->f), \
727 /** Static initializer for ARGS() to target a bit-field. */
728 #define ARGS_ENTRY_BF(s, f, b) \
729 (&(const struct arg){ \
731 .mask = (const void *)&(const s){ .f = (1 << (b)) - 1 }, \
734 /** Static initializer for ARGS() to target a field with limits. */
735 #define ARGS_ENTRY_BOUNDED(s, f, i, a) \
736 (&(const struct arg){ \
740 .offset = offsetof(s, f), \
741 .size = sizeof(((s *)0)->f), \
744 /** Static initializer for ARGS() to target an arbitrary bit-mask. */
745 #define ARGS_ENTRY_MASK(s, f, m) \
746 (&(const struct arg){ \
747 .offset = offsetof(s, f), \
748 .size = sizeof(((s *)0)->f), \
749 .mask = (const void *)(m), \
752 /** Same as ARGS_ENTRY_MASK() using network byte ordering for the value. */
753 #define ARGS_ENTRY_MASK_HTON(s, f, m) \
754 (&(const struct arg){ \
756 .offset = offsetof(s, f), \
757 .size = sizeof(((s *)0)->f), \
758 .mask = (const void *)(m), \
761 /** Static initializer for ARGS() to target a pointer. */
762 #define ARGS_ENTRY_PTR(s, f) \
763 (&(const struct arg){ \
764 .size = sizeof(*((s *)0)->f), \
767 /** Static initializer for ARGS() with arbitrary offset and size. */
768 #define ARGS_ENTRY_ARB(o, s) \
769 (&(const struct arg){ \
774 /** Same as ARGS_ENTRY_ARB() with bounded values. */
775 #define ARGS_ENTRY_ARB_BOUNDED(o, s, i, a) \
776 (&(const struct arg){ \
784 /** Same as ARGS_ENTRY() using network byte ordering. */
785 #define ARGS_ENTRY_HTON(s, f) \
786 (&(const struct arg){ \
788 .offset = offsetof(s, f), \
789 .size = sizeof(((s *)0)->f), \
792 /** Same as ARGS_ENTRY_HTON() for a single argument, without structure. */
793 #define ARG_ENTRY_HTON(s) \
794 (&(const struct arg){ \
800 /** Parser output buffer layout expected by cmd_flow_parsed(). */
802 enum index command; /**< Flow command. */
803 portid_t port; /**< Affected port ID. */
807 uint32_t action_id_n;
808 } ia_destroy; /**< Indirect action destroy arguments. */
811 } ia; /* Indirect action query arguments */
813 struct rte_flow_attr attr;
814 struct tunnel_ops tunnel_ops;
815 struct rte_flow_item *pattern;
816 struct rte_flow_action *actions;
820 } vc; /**< Validate/create arguments. */
824 } destroy; /**< Destroy arguments. */
829 } dump; /**< Dump arguments. */
832 struct rte_flow_action action;
833 } query; /**< Query arguments. */
837 } list; /**< List arguments. */
840 } isolate; /**< Isolated mode arguments. */
843 } aged; /**< Aged arguments. */
846 } policy;/**< Policy arguments. */
847 } args; /**< Command arguments. */
850 /** Private data for pattern items. */
851 struct parse_item_priv {
852 enum rte_flow_item_type type; /**< Item type. */
853 uint32_t size; /**< Size of item specification structure. */
856 #define PRIV_ITEM(t, s) \
857 (&(const struct parse_item_priv){ \
858 .type = RTE_FLOW_ITEM_TYPE_ ## t, \
862 /** Private data for actions. */
863 struct parse_action_priv {
864 enum rte_flow_action_type type; /**< Action type. */
865 uint32_t size; /**< Size of action configuration structure. */
868 #define PRIV_ACTION(t, s) \
869 (&(const struct parse_action_priv){ \
870 .type = RTE_FLOW_ACTION_TYPE_ ## t, \
874 static const enum index next_ia_create_attr[] = {
875 INDIRECT_ACTION_CREATE_ID,
876 INDIRECT_ACTION_INGRESS,
877 INDIRECT_ACTION_EGRESS,
878 INDIRECT_ACTION_TRANSFER,
879 INDIRECT_ACTION_SPEC,
883 static const enum index next_dump_subcmd[] = {
889 static const enum index next_ia_subcmd[] = {
890 INDIRECT_ACTION_CREATE,
891 INDIRECT_ACTION_UPDATE,
892 INDIRECT_ACTION_DESTROY,
893 INDIRECT_ACTION_QUERY,
897 static const enum index next_vc_attr[] = {
909 static const enum index next_destroy_attr[] = {
915 static const enum index next_dump_attr[] = {
921 static const enum index next_list_attr[] = {
927 static const enum index next_aged_attr[] = {
933 static const enum index next_ia_destroy_attr[] = {
934 INDIRECT_ACTION_DESTROY_ID,
939 static const enum index item_param[] = {
948 static const enum index next_item[] = {
985 ITEM_ICMP6_ND_OPT_SLA_ETH,
986 ITEM_ICMP6_ND_OPT_TLA_ETH,
1007 static const enum index item_fuzzy[] = {
1013 static const enum index item_any[] = {
1019 static const enum index item_vf[] = {
1025 static const enum index item_phy_port[] = {
1026 ITEM_PHY_PORT_INDEX,
1031 static const enum index item_port_id[] = {
1037 static const enum index item_mark[] = {
1043 static const enum index item_raw[] = {
1053 static const enum index item_eth[] = {
1062 static const enum index item_vlan[] = {
1067 ITEM_VLAN_INNER_TYPE,
1068 ITEM_VLAN_HAS_MORE_VLAN,
1073 static const enum index item_ipv4[] = {
1076 ITEM_IPV4_FRAGMENT_OFFSET,
1085 static const enum index item_ipv6[] = {
1092 ITEM_IPV6_HAS_FRAG_EXT,
1097 static const enum index item_icmp[] = {
1106 static const enum index item_udp[] = {
1113 static const enum index item_tcp[] = {
1121 static const enum index item_sctp[] = {
1130 static const enum index item_vxlan[] = {
1136 static const enum index item_e_tag[] = {
1137 ITEM_E_TAG_GRP_ECID_B,
1142 static const enum index item_nvgre[] = {
1148 static const enum index item_mpls[] = {
1156 static const enum index item_gre[] = {
1158 ITEM_GRE_C_RSVD0_VER,
1166 static const enum index item_gre_key[] = {
1172 static const enum index item_gtp[] = {
1180 static const enum index item_geneve[] = {
1188 static const enum index item_vxlan_gpe[] = {
1194 static const enum index item_arp_eth_ipv4[] = {
1195 ITEM_ARP_ETH_IPV4_SHA,
1196 ITEM_ARP_ETH_IPV4_SPA,
1197 ITEM_ARP_ETH_IPV4_THA,
1198 ITEM_ARP_ETH_IPV4_TPA,
1203 static const enum index item_ipv6_ext[] = {
1204 ITEM_IPV6_EXT_NEXT_HDR,
1209 static const enum index item_ipv6_frag_ext[] = {
1210 ITEM_IPV6_FRAG_EXT_NEXT_HDR,
1211 ITEM_IPV6_FRAG_EXT_FRAG_DATA,
1212 ITEM_IPV6_FRAG_EXT_ID,
1217 static const enum index item_icmp6[] = {
1224 static const enum index item_icmp6_nd_ns[] = {
1225 ITEM_ICMP6_ND_NS_TARGET_ADDR,
1230 static const enum index item_icmp6_nd_na[] = {
1231 ITEM_ICMP6_ND_NA_TARGET_ADDR,
1236 static const enum index item_icmp6_nd_opt[] = {
1237 ITEM_ICMP6_ND_OPT_TYPE,
1242 static const enum index item_icmp6_nd_opt_sla_eth[] = {
1243 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
1248 static const enum index item_icmp6_nd_opt_tla_eth[] = {
1249 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
1254 static const enum index item_meta[] = {
1260 static const enum index item_gtp_psc[] = {
1267 static const enum index item_pppoed[] = {
1273 static const enum index item_pppoes[] = {
1279 static const enum index item_pppoe_proto_id[] = {
1284 static const enum index item_higig2[] = {
1285 ITEM_HIGIG2_CLASSIFICATION,
1291 static const enum index item_esp[] = {
1297 static const enum index item_ah[] = {
1303 static const enum index item_pfcp[] = {
1310 static const enum index next_set_raw[] = {
1316 static const enum index item_tag[] = {
1323 static const enum index item_l2tpv3oip[] = {
1324 ITEM_L2TPV3OIP_SESSION_ID,
1329 static const enum index item_ecpri[] = {
1335 static const enum index item_ecpri_common[] = {
1336 ITEM_ECPRI_COMMON_TYPE,
1340 static const enum index item_ecpri_common_type[] = {
1341 ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
1342 ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
1343 ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
1347 static const enum index item_geneve_opt[] = {
1348 ITEM_GENEVE_OPT_CLASS,
1349 ITEM_GENEVE_OPT_TYPE,
1350 ITEM_GENEVE_OPT_LENGTH,
1351 ITEM_GENEVE_OPT_DATA,
1356 static const enum index item_integrity[] = {
1357 ITEM_INTEGRITY_LEVEL,
1358 ITEM_INTEGRITY_VALUE,
1362 static const enum index item_integrity_lv[] = {
1363 ITEM_INTEGRITY_LEVEL,
1364 ITEM_INTEGRITY_VALUE,
1369 static const enum index next_action[] = {
1386 ACTION_OF_SET_MPLS_TTL,
1387 ACTION_OF_DEC_MPLS_TTL,
1388 ACTION_OF_SET_NW_TTL,
1389 ACTION_OF_DEC_NW_TTL,
1390 ACTION_OF_COPY_TTL_OUT,
1391 ACTION_OF_COPY_TTL_IN,
1393 ACTION_OF_PUSH_VLAN,
1394 ACTION_OF_SET_VLAN_VID,
1395 ACTION_OF_SET_VLAN_PCP,
1397 ACTION_OF_PUSH_MPLS,
1404 ACTION_MPLSOGRE_ENCAP,
1405 ACTION_MPLSOGRE_DECAP,
1406 ACTION_MPLSOUDP_ENCAP,
1407 ACTION_MPLSOUDP_DECAP,
1408 ACTION_SET_IPV4_SRC,
1409 ACTION_SET_IPV4_DST,
1410 ACTION_SET_IPV6_SRC,
1411 ACTION_SET_IPV6_DST,
1427 ACTION_SET_IPV4_DSCP,
1428 ACTION_SET_IPV6_DSCP,
1432 ACTION_MODIFY_FIELD,
1434 ACTION_CONNTRACK_UPDATE,
1438 static const enum index action_mark[] = {
1444 static const enum index action_queue[] = {
1450 static const enum index action_count[] = {
1452 ACTION_COUNT_SHARED,
1457 static const enum index action_rss[] = {
1468 static const enum index action_vf[] = {
1475 static const enum index action_phy_port[] = {
1476 ACTION_PHY_PORT_ORIGINAL,
1477 ACTION_PHY_PORT_INDEX,
1482 static const enum index action_port_id[] = {
1483 ACTION_PORT_ID_ORIGINAL,
1489 static const enum index action_meter[] = {
1495 static const enum index action_meter_color[] = {
1496 ACTION_METER_COLOR_TYPE,
1501 static const enum index action_of_set_mpls_ttl[] = {
1502 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
1507 static const enum index action_of_set_nw_ttl[] = {
1508 ACTION_OF_SET_NW_TTL_NW_TTL,
1513 static const enum index action_of_push_vlan[] = {
1514 ACTION_OF_PUSH_VLAN_ETHERTYPE,
1519 static const enum index action_of_set_vlan_vid[] = {
1520 ACTION_OF_SET_VLAN_VID_VLAN_VID,
1525 static const enum index action_of_set_vlan_pcp[] = {
1526 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
1531 static const enum index action_of_pop_mpls[] = {
1532 ACTION_OF_POP_MPLS_ETHERTYPE,
1537 static const enum index action_of_push_mpls[] = {
1538 ACTION_OF_PUSH_MPLS_ETHERTYPE,
1543 static const enum index action_set_ipv4_src[] = {
1544 ACTION_SET_IPV4_SRC_IPV4_SRC,
1549 static const enum index action_set_mac_src[] = {
1550 ACTION_SET_MAC_SRC_MAC_SRC,
1555 static const enum index action_set_ipv4_dst[] = {
1556 ACTION_SET_IPV4_DST_IPV4_DST,
1561 static const enum index action_set_ipv6_src[] = {
1562 ACTION_SET_IPV6_SRC_IPV6_SRC,
1567 static const enum index action_set_ipv6_dst[] = {
1568 ACTION_SET_IPV6_DST_IPV6_DST,
1573 static const enum index action_set_tp_src[] = {
1574 ACTION_SET_TP_SRC_TP_SRC,
1579 static const enum index action_set_tp_dst[] = {
1580 ACTION_SET_TP_DST_TP_DST,
1585 static const enum index action_set_ttl[] = {
1591 static const enum index action_jump[] = {
1597 static const enum index action_set_mac_dst[] = {
1598 ACTION_SET_MAC_DST_MAC_DST,
1603 static const enum index action_inc_tcp_seq[] = {
1604 ACTION_INC_TCP_SEQ_VALUE,
1609 static const enum index action_dec_tcp_seq[] = {
1610 ACTION_DEC_TCP_SEQ_VALUE,
1615 static const enum index action_inc_tcp_ack[] = {
1616 ACTION_INC_TCP_ACK_VALUE,
1621 static const enum index action_dec_tcp_ack[] = {
1622 ACTION_DEC_TCP_ACK_VALUE,
1627 static const enum index action_raw_encap[] = {
1628 ACTION_RAW_ENCAP_INDEX,
1633 static const enum index action_raw_decap[] = {
1634 ACTION_RAW_DECAP_INDEX,
1639 static const enum index action_set_tag[] = {
1640 ACTION_SET_TAG_DATA,
1641 ACTION_SET_TAG_INDEX,
1642 ACTION_SET_TAG_MASK,
1647 static const enum index action_set_meta[] = {
1648 ACTION_SET_META_DATA,
1649 ACTION_SET_META_MASK,
1654 static const enum index action_set_ipv4_dscp[] = {
1655 ACTION_SET_IPV4_DSCP_VALUE,
1660 static const enum index action_set_ipv6_dscp[] = {
1661 ACTION_SET_IPV6_DSCP_VALUE,
1666 static const enum index action_age[] = {
1673 static const enum index action_sample[] = {
1675 ACTION_SAMPLE_RATIO,
1676 ACTION_SAMPLE_INDEX,
1681 static const enum index next_action_sample[] = {
1694 static const enum index action_modify_field_dst[] = {
1695 ACTION_MODIFY_FIELD_DST_LEVEL,
1696 ACTION_MODIFY_FIELD_DST_OFFSET,
1697 ACTION_MODIFY_FIELD_SRC_TYPE,
1701 static const enum index action_modify_field_src[] = {
1702 ACTION_MODIFY_FIELD_SRC_LEVEL,
1703 ACTION_MODIFY_FIELD_SRC_OFFSET,
1704 ACTION_MODIFY_FIELD_SRC_VALUE,
1705 ACTION_MODIFY_FIELD_WIDTH,
1709 static const enum index action_update_conntrack[] = {
1710 ACTION_CONNTRACK_UPDATE_DIR,
1711 ACTION_CONNTRACK_UPDATE_CTX,
1716 static int parse_set_raw_encap_decap(struct context *, const struct token *,
1717 const char *, unsigned int,
1718 void *, unsigned int);
1719 static int parse_set_sample_action(struct context *, const struct token *,
1720 const char *, unsigned int,
1721 void *, unsigned int);
1722 static int parse_set_init(struct context *, const struct token *,
1723 const char *, unsigned int,
1724 void *, unsigned int);
1725 static int parse_init(struct context *, const struct token *,
1726 const char *, unsigned int,
1727 void *, unsigned int);
1728 static int parse_vc(struct context *, const struct token *,
1729 const char *, unsigned int,
1730 void *, unsigned int);
1731 static int parse_vc_spec(struct context *, const struct token *,
1732 const char *, unsigned int, void *, unsigned int);
1733 static int parse_vc_conf(struct context *, const struct token *,
1734 const char *, unsigned int, void *, unsigned int);
1735 static int parse_vc_item_ecpri_type(struct context *, const struct token *,
1736 const char *, unsigned int,
1737 void *, unsigned int);
1738 static int parse_vc_action_meter_color_type(struct context *,
1739 const struct token *,
1740 const char *, unsigned int, void *,
1742 static int parse_vc_action_rss(struct context *, const struct token *,
1743 const char *, unsigned int, void *,
1745 static int parse_vc_action_rss_func(struct context *, const struct token *,
1746 const char *, unsigned int, void *,
1748 static int parse_vc_action_rss_type(struct context *, const struct token *,
1749 const char *, unsigned int, void *,
1751 static int parse_vc_action_rss_queue(struct context *, const struct token *,
1752 const char *, unsigned int, void *,
1754 static int parse_vc_action_vxlan_encap(struct context *, const struct token *,
1755 const char *, unsigned int, void *,
1757 static int parse_vc_action_nvgre_encap(struct context *, const struct token *,
1758 const char *, unsigned int, void *,
1760 static int parse_vc_action_l2_encap(struct context *, const struct token *,
1761 const char *, unsigned int, void *,
1763 static int parse_vc_action_l2_decap(struct context *, const struct token *,
1764 const char *, unsigned int, void *,
1766 static int parse_vc_action_mplsogre_encap(struct context *,
1767 const struct token *, const char *,
1768 unsigned int, void *, unsigned int);
1769 static int parse_vc_action_mplsogre_decap(struct context *,
1770 const struct token *, const char *,
1771 unsigned int, void *, unsigned int);
1772 static int parse_vc_action_mplsoudp_encap(struct context *,
1773 const struct token *, const char *,
1774 unsigned int, void *, unsigned int);
1775 static int parse_vc_action_mplsoudp_decap(struct context *,
1776 const struct token *, const char *,
1777 unsigned int, void *, unsigned int);
1778 static int parse_vc_action_raw_encap(struct context *,
1779 const struct token *, const char *,
1780 unsigned int, void *, unsigned int);
1781 static int parse_vc_action_raw_decap(struct context *,
1782 const struct token *, const char *,
1783 unsigned int, void *, unsigned int);
1784 static int parse_vc_action_raw_encap_index(struct context *,
1785 const struct token *, const char *,
1786 unsigned int, void *, unsigned int);
1787 static int parse_vc_action_raw_decap_index(struct context *,
1788 const struct token *, const char *,
1789 unsigned int, void *, unsigned int);
1790 static int parse_vc_action_set_meta(struct context *ctx,
1791 const struct token *token, const char *str,
1792 unsigned int len, void *buf,
1794 static int parse_vc_action_sample(struct context *ctx,
1795 const struct token *token, const char *str,
1796 unsigned int len, void *buf,
1799 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
1800 const char *str, unsigned int len, void *buf,
1803 parse_vc_modify_field_op(struct context *ctx, const struct token *token,
1804 const char *str, unsigned int len, void *buf,
1807 parse_vc_modify_field_id(struct context *ctx, const struct token *token,
1808 const char *str, unsigned int len, void *buf,
1811 parse_vc_action_conntrack_update(struct context *ctx, const struct token *token,
1812 const char *str, unsigned int len, void *buf,
1814 static int parse_destroy(struct context *, const struct token *,
1815 const char *, unsigned int,
1816 void *, unsigned int);
1817 static int parse_flush(struct context *, const struct token *,
1818 const char *, unsigned int,
1819 void *, unsigned int);
1820 static int parse_dump(struct context *, const struct token *,
1821 const char *, unsigned int,
1822 void *, unsigned int);
1823 static int parse_query(struct context *, const struct token *,
1824 const char *, unsigned int,
1825 void *, unsigned int);
1826 static int parse_action(struct context *, const struct token *,
1827 const char *, unsigned int,
1828 void *, unsigned int);
1829 static int parse_list(struct context *, const struct token *,
1830 const char *, unsigned int,
1831 void *, unsigned int);
1832 static int parse_aged(struct context *, const struct token *,
1833 const char *, unsigned int,
1834 void *, unsigned int);
1835 static int parse_isolate(struct context *, const struct token *,
1836 const char *, unsigned int,
1837 void *, unsigned int);
1838 static int parse_tunnel(struct context *, const struct token *,
1839 const char *, unsigned int,
1840 void *, unsigned int);
1841 static int parse_int(struct context *, const struct token *,
1842 const char *, unsigned int,
1843 void *, unsigned int);
1844 static int parse_prefix(struct context *, const struct token *,
1845 const char *, unsigned int,
1846 void *, unsigned int);
1847 static int parse_boolean(struct context *, const struct token *,
1848 const char *, unsigned int,
1849 void *, unsigned int);
1850 static int parse_string(struct context *, const struct token *,
1851 const char *, unsigned int,
1852 void *, unsigned int);
1853 static int parse_hex(struct context *ctx, const struct token *token,
1854 const char *str, unsigned int len,
1855 void *buf, unsigned int size);
1856 static int parse_string0(struct context *, const struct token *,
1857 const char *, unsigned int,
1858 void *, unsigned int);
1859 static int parse_mac_addr(struct context *, const struct token *,
1860 const char *, unsigned int,
1861 void *, unsigned int);
1862 static int parse_ipv4_addr(struct context *, const struct token *,
1863 const char *, unsigned int,
1864 void *, unsigned int);
1865 static int parse_ipv6_addr(struct context *, const struct token *,
1866 const char *, unsigned int,
1867 void *, unsigned int);
1868 static int parse_port(struct context *, const struct token *,
1869 const char *, unsigned int,
1870 void *, unsigned int);
1871 static int parse_ia(struct context *, const struct token *,
1872 const char *, unsigned int,
1873 void *, unsigned int);
1874 static int parse_ia_destroy(struct context *ctx, const struct token *token,
1875 const char *str, unsigned int len,
1876 void *buf, unsigned int size);
1877 static int parse_ia_id2ptr(struct context *ctx, const struct token *token,
1878 const char *str, unsigned int len, void *buf,
1880 static int parse_mp(struct context *, const struct token *,
1881 const char *, unsigned int,
1882 void *, unsigned int);
1883 static int comp_none(struct context *, const struct token *,
1884 unsigned int, char *, unsigned int);
1885 static int comp_boolean(struct context *, const struct token *,
1886 unsigned int, char *, unsigned int);
1887 static int comp_action(struct context *, const struct token *,
1888 unsigned int, char *, unsigned int);
1889 static int comp_port(struct context *, const struct token *,
1890 unsigned int, char *, unsigned int);
1891 static int comp_rule_id(struct context *, const struct token *,
1892 unsigned int, char *, unsigned int);
1893 static int comp_vc_action_rss_type(struct context *, const struct token *,
1894 unsigned int, char *, unsigned int);
1895 static int comp_vc_action_rss_queue(struct context *, const struct token *,
1896 unsigned int, char *, unsigned int);
1897 static int comp_set_raw_index(struct context *, const struct token *,
1898 unsigned int, char *, unsigned int);
1899 static int comp_set_sample_index(struct context *, const struct token *,
1900 unsigned int, char *, unsigned int);
1901 static int comp_set_modify_field_op(struct context *, const struct token *,
1902 unsigned int, char *, unsigned int);
1903 static int comp_set_modify_field_id(struct context *, const struct token *,
1904 unsigned int, char *, unsigned int);
1906 /** Token definitions. */
1907 static const struct token token_list[] = {
1908 /* Special tokens. */
1911 .help = "null entry, abused as the entry point",
1912 .next = NEXT(NEXT_ENTRY(FLOW, ADD)),
1917 .help = "command may end here",
1920 .name = "START_SET",
1921 .help = "null entry, abused as the entry point for set",
1922 .next = NEXT(NEXT_ENTRY(SET)),
1927 .help = "set command may end here",
1929 /* Common tokens. */
1933 .help = "integer value",
1938 .name = "{unsigned}",
1940 .help = "unsigned integer value",
1947 .help = "prefix length for bit-mask",
1948 .call = parse_prefix,
1952 .name = "{boolean}",
1954 .help = "any boolean value",
1955 .call = parse_boolean,
1956 .comp = comp_boolean,
1961 .help = "fixed string",
1962 .call = parse_string,
1968 .help = "fixed string",
1972 .name = "{file path}",
1974 .help = "file path",
1975 .call = parse_string0,
1979 .name = "{MAC address}",
1981 .help = "standard MAC address notation",
1982 .call = parse_mac_addr,
1986 .name = "{IPv4 address}",
1987 .type = "IPV4 ADDRESS",
1988 .help = "standard IPv4 address notation",
1989 .call = parse_ipv4_addr,
1993 .name = "{IPv6 address}",
1994 .type = "IPV6 ADDRESS",
1995 .help = "standard IPv6 address notation",
1996 .call = parse_ipv6_addr,
2000 .name = "{rule id}",
2002 .help = "rule identifier",
2004 .comp = comp_rule_id,
2007 .name = "{port_id}",
2009 .help = "port identifier",
2014 .name = "{group_id}",
2016 .help = "group identifier",
2020 [PRIORITY_LEVEL] = {
2023 .help = "priority level",
2027 [INDIRECT_ACTION_ID] = {
2028 .name = "{indirect_action_id}",
2029 .type = "INDIRECT_ACTION_ID",
2030 .help = "indirect action id",
2035 .name = "{policy_id}",
2036 .type = "POLCIY_ID",
2037 .help = "policy id",
2041 /* Top-level command. */
2044 .type = "{command} {port_id} [{arg} [...]]",
2045 .help = "manage ingress/egress flow rules",
2046 .next = NEXT(NEXT_ENTRY
2060 /* Top-level command. */
2061 [INDIRECT_ACTION] = {
2062 .name = "indirect_action",
2063 .type = "{command} {port_id} [{arg} [...]]",
2064 .help = "manage indirect actions",
2065 .next = NEXT(next_ia_subcmd, NEXT_ENTRY(PORT_ID)),
2066 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2069 /* Sub-level commands. */
2070 [INDIRECT_ACTION_CREATE] = {
2072 .help = "create indirect action",
2073 .next = NEXT(next_ia_create_attr),
2076 [INDIRECT_ACTION_UPDATE] = {
2078 .help = "update indirect action",
2079 .next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_SPEC),
2080 NEXT_ENTRY(INDIRECT_ACTION_ID)),
2081 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
2084 [INDIRECT_ACTION_DESTROY] = {
2086 .help = "destroy indirect action",
2087 .next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_DESTROY_ID)),
2088 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2089 .call = parse_ia_destroy,
2091 [INDIRECT_ACTION_QUERY] = {
2093 .help = "query indirect action",
2094 .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(INDIRECT_ACTION_ID)),
2095 .args = ARGS(ARGS_ENTRY(struct buffer, args.ia.action_id)),
2100 .help = "check whether a flow rule can be created",
2101 .next = NEXT(next_vc_attr, NEXT_ENTRY(PORT_ID)),
2102 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2107 .help = "create a flow rule",
2108 .next = NEXT(next_vc_attr, NEXT_ENTRY(PORT_ID)),
2109 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2114 .help = "destroy specific flow rules",
2115 .next = NEXT(NEXT_ENTRY(DESTROY_RULE), NEXT_ENTRY(PORT_ID)),
2116 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2117 .call = parse_destroy,
2121 .help = "destroy all flow rules",
2122 .next = NEXT(NEXT_ENTRY(PORT_ID)),
2123 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2124 .call = parse_flush,
2128 .help = "dump single/all flow rules to file",
2129 .next = NEXT(next_dump_subcmd, NEXT_ENTRY(PORT_ID)),
2130 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2135 .help = "query an existing flow rule",
2136 .next = NEXT(NEXT_ENTRY(QUERY_ACTION),
2137 NEXT_ENTRY(RULE_ID),
2138 NEXT_ENTRY(PORT_ID)),
2139 .args = ARGS(ARGS_ENTRY(struct buffer, args.query.action.type),
2140 ARGS_ENTRY(struct buffer, args.query.rule),
2141 ARGS_ENTRY(struct buffer, port)),
2142 .call = parse_query,
2146 .help = "list existing flow rules",
2147 .next = NEXT(next_list_attr, NEXT_ENTRY(PORT_ID)),
2148 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2153 .help = "list and destroy aged flows",
2154 .next = NEXT(next_aged_attr, NEXT_ENTRY(PORT_ID)),
2155 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2160 .help = "restrict ingress traffic to the defined flow rules",
2161 .next = NEXT(NEXT_ENTRY(BOOLEAN),
2162 NEXT_ENTRY(PORT_ID)),
2163 .args = ARGS(ARGS_ENTRY(struct buffer, args.isolate.set),
2164 ARGS_ENTRY(struct buffer, port)),
2165 .call = parse_isolate,
2169 .help = "new tunnel API",
2170 .next = NEXT(NEXT_ENTRY
2171 (TUNNEL_CREATE, TUNNEL_LIST, TUNNEL_DESTROY)),
2172 .call = parse_tunnel,
2174 /* Tunnel arguments. */
2177 .help = "create new tunnel object",
2178 .next = NEXT(NEXT_ENTRY(TUNNEL_CREATE_TYPE),
2179 NEXT_ENTRY(PORT_ID)),
2180 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2181 .call = parse_tunnel,
2183 [TUNNEL_CREATE_TYPE] = {
2185 .help = "create new tunnel",
2186 .next = NEXT(NEXT_ENTRY(FILE_PATH)),
2187 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, type)),
2188 .call = parse_tunnel,
2190 [TUNNEL_DESTROY] = {
2192 .help = "destroy tunel",
2193 .next = NEXT(NEXT_ENTRY(TUNNEL_DESTROY_ID),
2194 NEXT_ENTRY(PORT_ID)),
2195 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2196 .call = parse_tunnel,
2198 [TUNNEL_DESTROY_ID] = {
2200 .help = "tunnel identifier to testroy",
2201 .next = NEXT(NEXT_ENTRY(UNSIGNED)),
2202 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2203 .call = parse_tunnel,
2207 .help = "list existing tunnels",
2208 .next = NEXT(NEXT_ENTRY(PORT_ID)),
2209 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2210 .call = parse_tunnel,
2212 /* Destroy arguments. */
2215 .help = "specify a rule identifier",
2216 .next = NEXT(next_destroy_attr, NEXT_ENTRY(RULE_ID)),
2217 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.destroy.rule)),
2218 .call = parse_destroy,
2220 /* Dump arguments. */
2224 .next = NEXT(next_dump_attr),
2225 .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file)),
2230 .help = "dump one rule",
2231 .next = NEXT(next_dump_attr, NEXT_ENTRY(RULE_ID)),
2232 .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file),
2233 ARGS_ENTRY(struct buffer, args.dump.rule)),
2236 /* Query arguments. */
2240 .help = "action to query, must be part of the rule",
2241 .call = parse_action,
2242 .comp = comp_action,
2244 /* List arguments. */
2247 .help = "specify a group",
2248 .next = NEXT(next_list_attr, NEXT_ENTRY(GROUP_ID)),
2249 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.list.group)),
2254 .help = "specify aged flows need be destroyed",
2258 /* Validate/create attributes. */
2261 .help = "specify a group",
2262 .next = NEXT(next_vc_attr, NEXT_ENTRY(GROUP_ID)),
2263 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, group)),
2268 .help = "specify a priority level",
2269 .next = NEXT(next_vc_attr, NEXT_ENTRY(PRIORITY_LEVEL)),
2270 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, priority)),
2275 .help = "affect rule to ingress",
2276 .next = NEXT(next_vc_attr),
2281 .help = "affect rule to egress",
2282 .next = NEXT(next_vc_attr),
2287 .help = "apply rule directly to endpoints found in pattern",
2288 .next = NEXT(next_vc_attr),
2292 .name = "tunnel_set",
2293 .help = "tunnel steer rule",
2294 .next = NEXT(next_vc_attr, NEXT_ENTRY(UNSIGNED)),
2295 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2299 .name = "tunnel_match",
2300 .help = "tunnel match rule",
2301 .next = NEXT(next_vc_attr, NEXT_ENTRY(UNSIGNED)),
2302 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2305 /* Validate/create pattern. */
2308 .help = "submit a list of pattern items",
2309 .next = NEXT(next_item),
2314 .help = "match value perfectly (with full bit-mask)",
2315 .call = parse_vc_spec,
2317 [ITEM_PARAM_SPEC] = {
2319 .help = "match value according to configured bit-mask",
2320 .call = parse_vc_spec,
2322 [ITEM_PARAM_LAST] = {
2324 .help = "specify upper bound to establish a range",
2325 .call = parse_vc_spec,
2327 [ITEM_PARAM_MASK] = {
2329 .help = "specify bit-mask with relevant bits set to one",
2330 .call = parse_vc_spec,
2332 [ITEM_PARAM_PREFIX] = {
2334 .help = "generate bit-mask from a prefix length",
2335 .call = parse_vc_spec,
2339 .help = "specify next pattern item",
2340 .next = NEXT(next_item),
2344 .help = "end list of pattern items",
2345 .priv = PRIV_ITEM(END, 0),
2346 .next = NEXT(NEXT_ENTRY(ACTIONS)),
2351 .help = "no-op pattern item",
2352 .priv = PRIV_ITEM(VOID, 0),
2353 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2358 .help = "perform actions when pattern does not match",
2359 .priv = PRIV_ITEM(INVERT, 0),
2360 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2365 .help = "match any protocol for the current layer",
2366 .priv = PRIV_ITEM(ANY, sizeof(struct rte_flow_item_any)),
2367 .next = NEXT(item_any),
2372 .help = "number of layers covered",
2373 .next = NEXT(item_any, NEXT_ENTRY(UNSIGNED), item_param),
2374 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_any, num)),
2378 .help = "match traffic from/to the physical function",
2379 .priv = PRIV_ITEM(PF, 0),
2380 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2385 .help = "match traffic from/to a virtual function ID",
2386 .priv = PRIV_ITEM(VF, sizeof(struct rte_flow_item_vf)),
2387 .next = NEXT(item_vf),
2393 .next = NEXT(item_vf, NEXT_ENTRY(UNSIGNED), item_param),
2394 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_vf, id)),
2398 .help = "match traffic from/to a specific physical port",
2399 .priv = PRIV_ITEM(PHY_PORT,
2400 sizeof(struct rte_flow_item_phy_port)),
2401 .next = NEXT(item_phy_port),
2404 [ITEM_PHY_PORT_INDEX] = {
2406 .help = "physical port index",
2407 .next = NEXT(item_phy_port, NEXT_ENTRY(UNSIGNED), item_param),
2408 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_phy_port, index)),
2412 .help = "match traffic from/to a given DPDK port ID",
2413 .priv = PRIV_ITEM(PORT_ID,
2414 sizeof(struct rte_flow_item_port_id)),
2415 .next = NEXT(item_port_id),
2418 [ITEM_PORT_ID_ID] = {
2420 .help = "DPDK port ID",
2421 .next = NEXT(item_port_id, NEXT_ENTRY(UNSIGNED), item_param),
2422 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port_id, id)),
2426 .help = "match traffic against value set in previously matched rule",
2427 .priv = PRIV_ITEM(MARK, sizeof(struct rte_flow_item_mark)),
2428 .next = NEXT(item_mark),
2433 .help = "Integer value to match against",
2434 .next = NEXT(item_mark, NEXT_ENTRY(UNSIGNED), item_param),
2435 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_mark, id)),
2439 .help = "match an arbitrary byte string",
2440 .priv = PRIV_ITEM(RAW, ITEM_RAW_SIZE),
2441 .next = NEXT(item_raw),
2444 [ITEM_RAW_RELATIVE] = {
2446 .help = "look for pattern after the previous item",
2447 .next = NEXT(item_raw, NEXT_ENTRY(BOOLEAN), item_param),
2448 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
2451 [ITEM_RAW_SEARCH] = {
2453 .help = "search pattern from offset (see also limit)",
2454 .next = NEXT(item_raw, NEXT_ENTRY(BOOLEAN), item_param),
2455 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
2458 [ITEM_RAW_OFFSET] = {
2460 .help = "absolute or relative offset for pattern",
2461 .next = NEXT(item_raw, NEXT_ENTRY(INTEGER), item_param),
2462 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, offset)),
2464 [ITEM_RAW_LIMIT] = {
2466 .help = "search area limit for start of pattern",
2467 .next = NEXT(item_raw, NEXT_ENTRY(UNSIGNED), item_param),
2468 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, limit)),
2470 [ITEM_RAW_PATTERN] = {
2472 .help = "byte string to look for",
2473 .next = NEXT(item_raw,
2475 NEXT_ENTRY(ITEM_PARAM_IS,
2478 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern),
2479 ARGS_ENTRY(struct rte_flow_item_raw, length),
2480 ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw),
2481 ITEM_RAW_PATTERN_SIZE)),
2485 .help = "match Ethernet header",
2486 .priv = PRIV_ITEM(ETH, sizeof(struct rte_flow_item_eth)),
2487 .next = NEXT(item_eth),
2492 .help = "destination MAC",
2493 .next = NEXT(item_eth, NEXT_ENTRY(MAC_ADDR), item_param),
2494 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, dst)),
2498 .help = "source MAC",
2499 .next = NEXT(item_eth, NEXT_ENTRY(MAC_ADDR), item_param),
2500 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, src)),
2504 .help = "EtherType",
2505 .next = NEXT(item_eth, NEXT_ENTRY(UNSIGNED), item_param),
2506 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, type)),
2508 [ITEM_ETH_HAS_VLAN] = {
2510 .help = "packet header contains VLAN",
2511 .next = NEXT(item_eth, NEXT_ENTRY(UNSIGNED), item_param),
2512 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_eth,
2517 .help = "match 802.1Q/ad VLAN tag",
2518 .priv = PRIV_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)),
2519 .next = NEXT(item_vlan),
2524 .help = "tag control information",
2525 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2526 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, tci)),
2530 .help = "priority code point",
2531 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2532 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2537 .help = "drop eligible indicator",
2538 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2539 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2544 .help = "VLAN identifier",
2545 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2546 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2549 [ITEM_VLAN_INNER_TYPE] = {
2550 .name = "inner_type",
2551 .help = "inner EtherType",
2552 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2553 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan,
2556 [ITEM_VLAN_HAS_MORE_VLAN] = {
2557 .name = "has_more_vlan",
2558 .help = "packet header contains another VLAN",
2559 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2560 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vlan,
2565 .help = "match IPv4 header",
2566 .priv = PRIV_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)),
2567 .next = NEXT(item_ipv4),
2572 .help = "type of service",
2573 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2574 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2575 hdr.type_of_service)),
2578 .name = "packet_id",
2579 .help = "fragment packet id",
2580 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2581 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2584 [ITEM_IPV4_FRAGMENT_OFFSET] = {
2585 .name = "fragment_offset",
2586 .help = "fragmentation flags and fragment offset",
2587 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2588 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2589 hdr.fragment_offset)),
2593 .help = "time to live",
2594 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2595 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2598 [ITEM_IPV4_PROTO] = {
2600 .help = "next protocol ID",
2601 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2602 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2603 hdr.next_proto_id)),
2607 .help = "source address",
2608 .next = NEXT(item_ipv4, NEXT_ENTRY(IPV4_ADDR), item_param),
2609 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2614 .help = "destination address",
2615 .next = NEXT(item_ipv4, NEXT_ENTRY(IPV4_ADDR), item_param),
2616 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2621 .help = "match IPv6 header",
2622 .priv = PRIV_ITEM(IPV6, sizeof(struct rte_flow_item_ipv6)),
2623 .next = NEXT(item_ipv6),
2628 .help = "traffic class",
2629 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2630 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2632 "\x0f\xf0\x00\x00")),
2634 [ITEM_IPV6_FLOW] = {
2636 .help = "flow label",
2637 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2638 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2640 "\x00\x0f\xff\xff")),
2642 [ITEM_IPV6_PROTO] = {
2644 .help = "protocol (next header)",
2645 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2646 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2651 .help = "hop limit",
2652 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2653 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2658 .help = "source address",
2659 .next = NEXT(item_ipv6, NEXT_ENTRY(IPV6_ADDR), item_param),
2660 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2665 .help = "destination address",
2666 .next = NEXT(item_ipv6, NEXT_ENTRY(IPV6_ADDR), item_param),
2667 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2670 [ITEM_IPV6_HAS_FRAG_EXT] = {
2671 .name = "has_frag_ext",
2672 .help = "fragment packet attribute",
2673 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2674 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_ipv6,
2679 .help = "match ICMP header",
2680 .priv = PRIV_ITEM(ICMP, sizeof(struct rte_flow_item_icmp)),
2681 .next = NEXT(item_icmp),
2684 [ITEM_ICMP_TYPE] = {
2686 .help = "ICMP packet type",
2687 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2688 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2691 [ITEM_ICMP_CODE] = {
2693 .help = "ICMP packet code",
2694 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2695 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2698 [ITEM_ICMP_IDENT] = {
2700 .help = "ICMP packet identifier",
2701 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2702 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2707 .help = "ICMP packet sequence number",
2708 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2709 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2714 .help = "match UDP header",
2715 .priv = PRIV_ITEM(UDP, sizeof(struct rte_flow_item_udp)),
2716 .next = NEXT(item_udp),
2721 .help = "UDP source port",
2722 .next = NEXT(item_udp, NEXT_ENTRY(UNSIGNED), item_param),
2723 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2728 .help = "UDP destination port",
2729 .next = NEXT(item_udp, NEXT_ENTRY(UNSIGNED), item_param),
2730 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2735 .help = "match TCP header",
2736 .priv = PRIV_ITEM(TCP, sizeof(struct rte_flow_item_tcp)),
2737 .next = NEXT(item_tcp),
2742 .help = "TCP source port",
2743 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2744 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2749 .help = "TCP destination port",
2750 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2751 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2754 [ITEM_TCP_FLAGS] = {
2756 .help = "TCP flags",
2757 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2758 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2763 .help = "match SCTP header",
2764 .priv = PRIV_ITEM(SCTP, sizeof(struct rte_flow_item_sctp)),
2765 .next = NEXT(item_sctp),
2770 .help = "SCTP source port",
2771 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2772 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2777 .help = "SCTP destination port",
2778 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2779 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2784 .help = "validation tag",
2785 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2786 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2789 [ITEM_SCTP_CKSUM] = {
2792 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2793 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2798 .help = "match VXLAN header",
2799 .priv = PRIV_ITEM(VXLAN, sizeof(struct rte_flow_item_vxlan)),
2800 .next = NEXT(item_vxlan),
2803 [ITEM_VXLAN_VNI] = {
2805 .help = "VXLAN identifier",
2806 .next = NEXT(item_vxlan, NEXT_ENTRY(UNSIGNED), item_param),
2807 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan, vni)),
2811 .help = "match E-Tag header",
2812 .priv = PRIV_ITEM(E_TAG, sizeof(struct rte_flow_item_e_tag)),
2813 .next = NEXT(item_e_tag),
2816 [ITEM_E_TAG_GRP_ECID_B] = {
2817 .name = "grp_ecid_b",
2818 .help = "GRP and E-CID base",
2819 .next = NEXT(item_e_tag, NEXT_ENTRY(UNSIGNED), item_param),
2820 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_e_tag,
2826 .help = "match NVGRE header",
2827 .priv = PRIV_ITEM(NVGRE, sizeof(struct rte_flow_item_nvgre)),
2828 .next = NEXT(item_nvgre),
2831 [ITEM_NVGRE_TNI] = {
2833 .help = "virtual subnet ID",
2834 .next = NEXT(item_nvgre, NEXT_ENTRY(UNSIGNED), item_param),
2835 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_nvgre, tni)),
2839 .help = "match MPLS header",
2840 .priv = PRIV_ITEM(MPLS, sizeof(struct rte_flow_item_mpls)),
2841 .next = NEXT(item_mpls),
2844 [ITEM_MPLS_LABEL] = {
2846 .help = "MPLS label",
2847 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2848 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2854 .help = "MPLS Traffic Class",
2855 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2856 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2862 .help = "MPLS Bottom-of-Stack",
2863 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2864 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2870 .help = "match GRE header",
2871 .priv = PRIV_ITEM(GRE, sizeof(struct rte_flow_item_gre)),
2872 .next = NEXT(item_gre),
2875 [ITEM_GRE_PROTO] = {
2877 .help = "GRE protocol type",
2878 .next = NEXT(item_gre, NEXT_ENTRY(UNSIGNED), item_param),
2879 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2882 [ITEM_GRE_C_RSVD0_VER] = {
2883 .name = "c_rsvd0_ver",
2885 "checksum (1b), undefined (1b), key bit (1b),"
2886 " sequence number (1b), reserved 0 (9b),"
2888 .next = NEXT(item_gre, NEXT_ENTRY(UNSIGNED), item_param),
2889 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2892 [ITEM_GRE_C_BIT] = {
2894 .help = "checksum bit (C)",
2895 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2896 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2898 "\x80\x00\x00\x00")),
2900 [ITEM_GRE_S_BIT] = {
2902 .help = "sequence number bit (S)",
2903 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2904 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2906 "\x10\x00\x00\x00")),
2908 [ITEM_GRE_K_BIT] = {
2910 .help = "key bit (K)",
2911 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2912 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2914 "\x20\x00\x00\x00")),
2918 .help = "fuzzy pattern match, expect faster than default",
2919 .priv = PRIV_ITEM(FUZZY,
2920 sizeof(struct rte_flow_item_fuzzy)),
2921 .next = NEXT(item_fuzzy),
2924 [ITEM_FUZZY_THRESH] = {
2926 .help = "match accuracy threshold",
2927 .next = NEXT(item_fuzzy, NEXT_ENTRY(UNSIGNED), item_param),
2928 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_fuzzy,
2933 .help = "match GTP header",
2934 .priv = PRIV_ITEM(GTP, sizeof(struct rte_flow_item_gtp)),
2935 .next = NEXT(item_gtp),
2938 [ITEM_GTP_FLAGS] = {
2939 .name = "v_pt_rsv_flags",
2940 .help = "GTP flags",
2941 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2942 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp,
2945 [ITEM_GTP_MSG_TYPE] = {
2947 .help = "GTP message type",
2948 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2949 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp, msg_type)),
2953 .help = "tunnel endpoint identifier",
2954 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2955 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp, teid)),
2959 .help = "match GTP header",
2960 .priv = PRIV_ITEM(GTPC, sizeof(struct rte_flow_item_gtp)),
2961 .next = NEXT(item_gtp),
2966 .help = "match GTP header",
2967 .priv = PRIV_ITEM(GTPU, sizeof(struct rte_flow_item_gtp)),
2968 .next = NEXT(item_gtp),
2973 .help = "match GENEVE header",
2974 .priv = PRIV_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)),
2975 .next = NEXT(item_geneve),
2978 [ITEM_GENEVE_VNI] = {
2980 .help = "virtual network identifier",
2981 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2982 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve, vni)),
2984 [ITEM_GENEVE_PROTO] = {
2986 .help = "GENEVE protocol type",
2987 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2988 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve,
2991 [ITEM_GENEVE_OPTLEN] = {
2993 .help = "GENEVE options length in dwords",
2994 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2995 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_geneve,
2996 ver_opt_len_o_c_rsvd0,
2999 [ITEM_VXLAN_GPE] = {
3000 .name = "vxlan-gpe",
3001 .help = "match VXLAN-GPE header",
3002 .priv = PRIV_ITEM(VXLAN_GPE,
3003 sizeof(struct rte_flow_item_vxlan_gpe)),
3004 .next = NEXT(item_vxlan_gpe),
3007 [ITEM_VXLAN_GPE_VNI] = {
3009 .help = "VXLAN-GPE identifier",
3010 .next = NEXT(item_vxlan_gpe, NEXT_ENTRY(UNSIGNED), item_param),
3011 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
3014 [ITEM_ARP_ETH_IPV4] = {
3015 .name = "arp_eth_ipv4",
3016 .help = "match ARP header for Ethernet/IPv4",
3017 .priv = PRIV_ITEM(ARP_ETH_IPV4,
3018 sizeof(struct rte_flow_item_arp_eth_ipv4)),
3019 .next = NEXT(item_arp_eth_ipv4),
3022 [ITEM_ARP_ETH_IPV4_SHA] = {
3024 .help = "sender hardware address",
3025 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(MAC_ADDR),
3027 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
3030 [ITEM_ARP_ETH_IPV4_SPA] = {
3032 .help = "sender IPv4 address",
3033 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(IPV4_ADDR),
3035 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
3038 [ITEM_ARP_ETH_IPV4_THA] = {
3040 .help = "target hardware address",
3041 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(MAC_ADDR),
3043 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
3046 [ITEM_ARP_ETH_IPV4_TPA] = {
3048 .help = "target IPv4 address",
3049 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(IPV4_ADDR),
3051 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
3056 .help = "match presence of any IPv6 extension header",
3057 .priv = PRIV_ITEM(IPV6_EXT,
3058 sizeof(struct rte_flow_item_ipv6_ext)),
3059 .next = NEXT(item_ipv6_ext),
3062 [ITEM_IPV6_EXT_NEXT_HDR] = {
3064 .help = "next header",
3065 .next = NEXT(item_ipv6_ext, NEXT_ENTRY(UNSIGNED), item_param),
3066 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_ext,
3069 [ITEM_IPV6_FRAG_EXT] = {
3070 .name = "ipv6_frag_ext",
3071 .help = "match presence of IPv6 fragment extension header",
3072 .priv = PRIV_ITEM(IPV6_FRAG_EXT,
3073 sizeof(struct rte_flow_item_ipv6_frag_ext)),
3074 .next = NEXT(item_ipv6_frag_ext),
3077 [ITEM_IPV6_FRAG_EXT_NEXT_HDR] = {
3079 .help = "next header",
3080 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(UNSIGNED),
3082 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ipv6_frag_ext,
3085 [ITEM_IPV6_FRAG_EXT_FRAG_DATA] = {
3086 .name = "frag_data",
3087 .help = "fragment flags and offset",
3088 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(UNSIGNED),
3090 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_frag_ext,
3093 [ITEM_IPV6_FRAG_EXT_ID] = {
3094 .name = "packet_id",
3095 .help = "fragment packet id",
3096 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(UNSIGNED),
3098 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_frag_ext,
3103 .help = "match any ICMPv6 header",
3104 .priv = PRIV_ITEM(ICMP6, sizeof(struct rte_flow_item_icmp6)),
3105 .next = NEXT(item_icmp6),
3108 [ITEM_ICMP6_TYPE] = {
3110 .help = "ICMPv6 type",
3111 .next = NEXT(item_icmp6, NEXT_ENTRY(UNSIGNED), item_param),
3112 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
3115 [ITEM_ICMP6_CODE] = {
3117 .help = "ICMPv6 code",
3118 .next = NEXT(item_icmp6, NEXT_ENTRY(UNSIGNED), item_param),
3119 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
3122 [ITEM_ICMP6_ND_NS] = {
3123 .name = "icmp6_nd_ns",
3124 .help = "match ICMPv6 neighbor discovery solicitation",
3125 .priv = PRIV_ITEM(ICMP6_ND_NS,
3126 sizeof(struct rte_flow_item_icmp6_nd_ns)),
3127 .next = NEXT(item_icmp6_nd_ns),
3130 [ITEM_ICMP6_ND_NS_TARGET_ADDR] = {
3131 .name = "target_addr",
3132 .help = "target address",
3133 .next = NEXT(item_icmp6_nd_ns, NEXT_ENTRY(IPV6_ADDR),
3135 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_ns,
3138 [ITEM_ICMP6_ND_NA] = {
3139 .name = "icmp6_nd_na",
3140 .help = "match ICMPv6 neighbor discovery advertisement",
3141 .priv = PRIV_ITEM(ICMP6_ND_NA,
3142 sizeof(struct rte_flow_item_icmp6_nd_na)),
3143 .next = NEXT(item_icmp6_nd_na),
3146 [ITEM_ICMP6_ND_NA_TARGET_ADDR] = {
3147 .name = "target_addr",
3148 .help = "target address",
3149 .next = NEXT(item_icmp6_nd_na, NEXT_ENTRY(IPV6_ADDR),
3151 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_na,
3154 [ITEM_ICMP6_ND_OPT] = {
3155 .name = "icmp6_nd_opt",
3156 .help = "match presence of any ICMPv6 neighbor discovery"
3158 .priv = PRIV_ITEM(ICMP6_ND_OPT,
3159 sizeof(struct rte_flow_item_icmp6_nd_opt)),
3160 .next = NEXT(item_icmp6_nd_opt),
3163 [ITEM_ICMP6_ND_OPT_TYPE] = {
3165 .help = "ND option type",
3166 .next = NEXT(item_icmp6_nd_opt, NEXT_ENTRY(UNSIGNED),
3168 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_opt,
3171 [ITEM_ICMP6_ND_OPT_SLA_ETH] = {
3172 .name = "icmp6_nd_opt_sla_eth",
3173 .help = "match ICMPv6 neighbor discovery source Ethernet"
3174 " link-layer address option",
3176 (ICMP6_ND_OPT_SLA_ETH,
3177 sizeof(struct rte_flow_item_icmp6_nd_opt_sla_eth)),
3178 .next = NEXT(item_icmp6_nd_opt_sla_eth),
3181 [ITEM_ICMP6_ND_OPT_SLA_ETH_SLA] = {
3183 .help = "source Ethernet LLA",
3184 .next = NEXT(item_icmp6_nd_opt_sla_eth, NEXT_ENTRY(MAC_ADDR),
3186 .args = ARGS(ARGS_ENTRY_HTON
3187 (struct rte_flow_item_icmp6_nd_opt_sla_eth, sla)),
3189 [ITEM_ICMP6_ND_OPT_TLA_ETH] = {
3190 .name = "icmp6_nd_opt_tla_eth",
3191 .help = "match ICMPv6 neighbor discovery target Ethernet"
3192 " link-layer address option",
3194 (ICMP6_ND_OPT_TLA_ETH,
3195 sizeof(struct rte_flow_item_icmp6_nd_opt_tla_eth)),
3196 .next = NEXT(item_icmp6_nd_opt_tla_eth),
3199 [ITEM_ICMP6_ND_OPT_TLA_ETH_TLA] = {
3201 .help = "target Ethernet LLA",
3202 .next = NEXT(item_icmp6_nd_opt_tla_eth, NEXT_ENTRY(MAC_ADDR),
3204 .args = ARGS(ARGS_ENTRY_HTON
3205 (struct rte_flow_item_icmp6_nd_opt_tla_eth, tla)),
3209 .help = "match metadata header",
3210 .priv = PRIV_ITEM(META, sizeof(struct rte_flow_item_meta)),
3211 .next = NEXT(item_meta),
3214 [ITEM_META_DATA] = {
3216 .help = "metadata value",
3217 .next = NEXT(item_meta, NEXT_ENTRY(UNSIGNED), item_param),
3218 .args = ARGS(ARGS_ENTRY_MASK(struct rte_flow_item_meta,
3219 data, "\xff\xff\xff\xff")),
3223 .help = "match GRE key",
3224 .priv = PRIV_ITEM(GRE_KEY, sizeof(rte_be32_t)),
3225 .next = NEXT(item_gre_key),
3228 [ITEM_GRE_KEY_VALUE] = {
3230 .help = "key value",
3231 .next = NEXT(item_gre_key, NEXT_ENTRY(UNSIGNED), item_param),
3232 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3236 .help = "match GTP extension header with type 0x85",
3237 .priv = PRIV_ITEM(GTP_PSC,
3238 sizeof(struct rte_flow_item_gtp_psc)),
3239 .next = NEXT(item_gtp_psc),
3242 [ITEM_GTP_PSC_QFI] = {
3244 .help = "QoS flow identifier",
3245 .next = NEXT(item_gtp_psc, NEXT_ENTRY(UNSIGNED), item_param),
3246 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
3249 [ITEM_GTP_PSC_PDU_T] = {
3252 .next = NEXT(item_gtp_psc, NEXT_ENTRY(UNSIGNED), item_param),
3253 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
3258 .help = "match PPPoE session header",
3259 .priv = PRIV_ITEM(PPPOES, sizeof(struct rte_flow_item_pppoe)),
3260 .next = NEXT(item_pppoes),
3265 .help = "match PPPoE discovery header",
3266 .priv = PRIV_ITEM(PPPOED, sizeof(struct rte_flow_item_pppoe)),
3267 .next = NEXT(item_pppoed),
3270 [ITEM_PPPOE_SEID] = {
3272 .help = "session identifier",
3273 .next = NEXT(item_pppoes, NEXT_ENTRY(UNSIGNED), item_param),
3274 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pppoe,
3277 [ITEM_PPPOE_PROTO_ID] = {
3278 .name = "pppoe_proto_id",
3279 .help = "match PPPoE session protocol identifier",
3280 .priv = PRIV_ITEM(PPPOE_PROTO_ID,
3281 sizeof(struct rte_flow_item_pppoe_proto_id)),
3282 .next = NEXT(item_pppoe_proto_id, NEXT_ENTRY(UNSIGNED),
3284 .args = ARGS(ARGS_ENTRY_HTON
3285 (struct rte_flow_item_pppoe_proto_id, proto_id)),
3290 .help = "matches higig2 header",
3291 .priv = PRIV_ITEM(HIGIG2,
3292 sizeof(struct rte_flow_item_higig2_hdr)),
3293 .next = NEXT(item_higig2),
3296 [ITEM_HIGIG2_CLASSIFICATION] = {
3297 .name = "classification",
3298 .help = "matches classification of higig2 header",
3299 .next = NEXT(item_higig2, NEXT_ENTRY(UNSIGNED), item_param),
3300 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
3301 hdr.ppt1.classification)),
3303 [ITEM_HIGIG2_VID] = {
3305 .help = "matches vid of higig2 header",
3306 .next = NEXT(item_higig2, NEXT_ENTRY(UNSIGNED), item_param),
3307 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
3312 .help = "match tag value",
3313 .priv = PRIV_ITEM(TAG, sizeof(struct rte_flow_item_tag)),
3314 .next = NEXT(item_tag),
3319 .help = "tag value to match",
3320 .next = NEXT(item_tag, NEXT_ENTRY(UNSIGNED), item_param),
3321 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, data)),
3323 [ITEM_TAG_INDEX] = {
3325 .help = "index of tag array to match",
3326 .next = NEXT(item_tag, NEXT_ENTRY(UNSIGNED),
3327 NEXT_ENTRY(ITEM_PARAM_IS)),
3328 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, index)),
3330 [ITEM_L2TPV3OIP] = {
3331 .name = "l2tpv3oip",
3332 .help = "match L2TPv3 over IP header",
3333 .priv = PRIV_ITEM(L2TPV3OIP,
3334 sizeof(struct rte_flow_item_l2tpv3oip)),
3335 .next = NEXT(item_l2tpv3oip),
3338 [ITEM_L2TPV3OIP_SESSION_ID] = {
3339 .name = "session_id",
3340 .help = "session identifier",
3341 .next = NEXT(item_l2tpv3oip, NEXT_ENTRY(UNSIGNED), item_param),
3342 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv3oip,
3347 .help = "match ESP header",
3348 .priv = PRIV_ITEM(ESP, sizeof(struct rte_flow_item_esp)),
3349 .next = NEXT(item_esp),
3354 .help = "security policy index",
3355 .next = NEXT(item_esp, NEXT_ENTRY(UNSIGNED), item_param),
3356 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_esp,
3361 .help = "match AH header",
3362 .priv = PRIV_ITEM(AH, sizeof(struct rte_flow_item_ah)),
3363 .next = NEXT(item_ah),
3368 .help = "security parameters index",
3369 .next = NEXT(item_ah, NEXT_ENTRY(UNSIGNED), item_param),
3370 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ah, spi)),
3374 .help = "match pfcp header",
3375 .priv = PRIV_ITEM(PFCP, sizeof(struct rte_flow_item_pfcp)),
3376 .next = NEXT(item_pfcp),
3379 [ITEM_PFCP_S_FIELD] = {
3382 .next = NEXT(item_pfcp, NEXT_ENTRY(UNSIGNED), item_param),
3383 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp,
3386 [ITEM_PFCP_SEID] = {
3388 .help = "session endpoint identifier",
3389 .next = NEXT(item_pfcp, NEXT_ENTRY(UNSIGNED), item_param),
3390 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp, seid)),
3394 .help = "match eCPRI header",
3395 .priv = PRIV_ITEM(ECPRI, sizeof(struct rte_flow_item_ecpri)),
3396 .next = NEXT(item_ecpri),
3399 [ITEM_ECPRI_COMMON] = {
3401 .help = "eCPRI common header",
3402 .next = NEXT(item_ecpri_common),
3404 [ITEM_ECPRI_COMMON_TYPE] = {
3406 .help = "type of common header",
3407 .next = NEXT(item_ecpri_common_type),
3408 .args = ARGS(ARG_ENTRY_HTON(struct rte_flow_item_ecpri)),
3410 [ITEM_ECPRI_COMMON_TYPE_IQ_DATA] = {
3412 .help = "Type #0: IQ Data",
3413 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
3415 .call = parse_vc_item_ecpri_type,
3417 [ITEM_ECPRI_MSG_IQ_DATA_PCID] = {
3419 .help = "Physical Channel ID",
3420 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
3421 ITEM_ECPRI_COMMON, ITEM_NEXT),
3422 NEXT_ENTRY(UNSIGNED), item_param),
3423 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3426 [ITEM_ECPRI_COMMON_TYPE_RTC_CTRL] = {
3428 .help = "Type #2: Real-Time Control Data",
3429 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
3431 .call = parse_vc_item_ecpri_type,
3433 [ITEM_ECPRI_MSG_RTC_CTRL_RTCID] = {
3435 .help = "Real-Time Control Data ID",
3436 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
3437 ITEM_ECPRI_COMMON, ITEM_NEXT),
3438 NEXT_ENTRY(UNSIGNED), item_param),
3439 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3442 [ITEM_ECPRI_COMMON_TYPE_DLY_MSR] = {
3443 .name = "delay_measure",
3444 .help = "Type #5: One-Way Delay Measurement",
3445 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
3447 .call = parse_vc_item_ecpri_type,
3449 [ITEM_ECPRI_MSG_DLY_MSR_MSRID] = {
3451 .help = "Measurement ID",
3452 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
3453 ITEM_ECPRI_COMMON, ITEM_NEXT),
3454 NEXT_ENTRY(UNSIGNED), item_param),
3455 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3458 [ITEM_GENEVE_OPT] = {
3459 .name = "geneve-opt",
3460 .help = "GENEVE header option",
3461 .priv = PRIV_ITEM(GENEVE_OPT,
3462 sizeof(struct rte_flow_item_geneve_opt) +
3463 ITEM_GENEVE_OPT_DATA_SIZE),
3464 .next = NEXT(item_geneve_opt),
3467 [ITEM_GENEVE_OPT_CLASS] = {
3469 .help = "GENEVE option class",
3470 .next = NEXT(item_geneve_opt, NEXT_ENTRY(UNSIGNED), item_param),
3471 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve_opt,
3474 [ITEM_GENEVE_OPT_TYPE] = {
3476 .help = "GENEVE option type",
3477 .next = NEXT(item_geneve_opt, NEXT_ENTRY(UNSIGNED), item_param),
3478 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt,
3481 [ITEM_GENEVE_OPT_LENGTH] = {
3483 .help = "GENEVE option data length (in 32b words)",
3484 .next = NEXT(item_geneve_opt, NEXT_ENTRY(UNSIGNED), item_param),
3485 .args = ARGS(ARGS_ENTRY_BOUNDED(
3486 struct rte_flow_item_geneve_opt, option_len,
3489 [ITEM_GENEVE_OPT_DATA] = {
3491 .help = "GENEVE option data pattern",
3492 .next = NEXT(item_geneve_opt, NEXT_ENTRY(HEX), item_param),
3493 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt, data),
3494 ARGS_ENTRY_ARB(0, 0),
3496 (sizeof(struct rte_flow_item_geneve_opt),
3497 ITEM_GENEVE_OPT_DATA_SIZE)),
3499 [ITEM_INTEGRITY] = {
3500 .name = "integrity",
3501 .help = "match packet integrity",
3502 .priv = PRIV_ITEM(INTEGRITY,
3503 sizeof(struct rte_flow_item_integrity)),
3504 .next = NEXT(item_integrity),
3507 [ITEM_INTEGRITY_LEVEL] = {
3509 .help = "integrity level",
3510 .next = NEXT(item_integrity_lv, NEXT_ENTRY(UNSIGNED),
3512 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_integrity, level)),
3514 [ITEM_INTEGRITY_VALUE] = {
3516 .help = "integrity value",
3517 .next = NEXT(item_integrity_lv, NEXT_ENTRY(UNSIGNED),
3519 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_integrity, value)),
3521 [ITEM_CONNTRACK] = {
3522 .name = "conntrack",
3523 .help = "conntrack state",
3524 .next = NEXT(NEXT_ENTRY(ITEM_NEXT), NEXT_ENTRY(UNSIGNED),
3526 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_conntrack, flags)),
3528 /* Validate/create actions. */
3531 .help = "submit a list of associated actions",
3532 .next = NEXT(next_action),
3537 .help = "specify next action",
3538 .next = NEXT(next_action),
3542 .help = "end list of actions",
3543 .priv = PRIV_ACTION(END, 0),
3548 .help = "no-op action",
3549 .priv = PRIV_ACTION(VOID, 0),
3550 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3553 [ACTION_PASSTHRU] = {
3555 .help = "let subsequent rule process matched packets",
3556 .priv = PRIV_ACTION(PASSTHRU, 0),
3557 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3562 .help = "redirect traffic to a given group",
3563 .priv = PRIV_ACTION(JUMP, sizeof(struct rte_flow_action_jump)),
3564 .next = NEXT(action_jump),
3567 [ACTION_JUMP_GROUP] = {
3569 .help = "group to redirect traffic to",
3570 .next = NEXT(action_jump, NEXT_ENTRY(UNSIGNED)),
3571 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump, group)),
3572 .call = parse_vc_conf,
3576 .help = "attach 32 bit value to packets",
3577 .priv = PRIV_ACTION(MARK, sizeof(struct rte_flow_action_mark)),
3578 .next = NEXT(action_mark),
3581 [ACTION_MARK_ID] = {
3583 .help = "32 bit value to return with packets",
3584 .next = NEXT(action_mark, NEXT_ENTRY(UNSIGNED)),
3585 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_mark, id)),
3586 .call = parse_vc_conf,
3590 .help = "flag packets",
3591 .priv = PRIV_ACTION(FLAG, 0),
3592 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3597 .help = "assign packets to a given queue index",
3598 .priv = PRIV_ACTION(QUEUE,
3599 sizeof(struct rte_flow_action_queue)),
3600 .next = NEXT(action_queue),
3603 [ACTION_QUEUE_INDEX] = {
3605 .help = "queue index to use",
3606 .next = NEXT(action_queue, NEXT_ENTRY(UNSIGNED)),
3607 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_queue, index)),
3608 .call = parse_vc_conf,
3612 .help = "drop packets (note: passthru has priority)",
3613 .priv = PRIV_ACTION(DROP, 0),
3614 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3619 .help = "enable counters for this rule",
3620 .priv = PRIV_ACTION(COUNT,
3621 sizeof(struct rte_flow_action_count)),
3622 .next = NEXT(action_count),
3625 [ACTION_COUNT_ID] = {
3626 .name = "identifier",
3627 .help = "counter identifier to use",
3628 .next = NEXT(action_count, NEXT_ENTRY(UNSIGNED)),
3629 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_count, id)),
3630 .call = parse_vc_conf,
3632 [ACTION_COUNT_SHARED] = {
3634 .help = "shared counter",
3635 .next = NEXT(action_count, NEXT_ENTRY(BOOLEAN)),
3636 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_count,
3638 .call = parse_vc_conf,
3642 .help = "spread packets among several queues",
3643 .priv = PRIV_ACTION(RSS, sizeof(struct action_rss_data)),
3644 .next = NEXT(action_rss),
3645 .call = parse_vc_action_rss,
3647 [ACTION_RSS_FUNC] = {
3649 .help = "RSS hash function to apply",
3650 .next = NEXT(action_rss,
3651 NEXT_ENTRY(ACTION_RSS_FUNC_DEFAULT,
3652 ACTION_RSS_FUNC_TOEPLITZ,
3653 ACTION_RSS_FUNC_SIMPLE_XOR,
3654 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ)),
3656 [ACTION_RSS_FUNC_DEFAULT] = {
3658 .help = "default hash function",
3659 .call = parse_vc_action_rss_func,
3661 [ACTION_RSS_FUNC_TOEPLITZ] = {
3663 .help = "Toeplitz hash function",
3664 .call = parse_vc_action_rss_func,
3666 [ACTION_RSS_FUNC_SIMPLE_XOR] = {
3667 .name = "simple_xor",
3668 .help = "simple XOR hash function",
3669 .call = parse_vc_action_rss_func,
3671 [ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ] = {
3672 .name = "symmetric_toeplitz",
3673 .help = "Symmetric Toeplitz hash function",
3674 .call = parse_vc_action_rss_func,
3676 [ACTION_RSS_LEVEL] = {
3678 .help = "encapsulation level for \"types\"",
3679 .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
3680 .args = ARGS(ARGS_ENTRY_ARB
3681 (offsetof(struct action_rss_data, conf) +
3682 offsetof(struct rte_flow_action_rss, level),
3683 sizeof(((struct rte_flow_action_rss *)0)->
3686 [ACTION_RSS_TYPES] = {
3688 .help = "specific RSS hash types",
3689 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)),
3691 [ACTION_RSS_TYPE] = {
3693 .help = "RSS hash type",
3694 .call = parse_vc_action_rss_type,
3695 .comp = comp_vc_action_rss_type,
3697 [ACTION_RSS_KEY] = {
3699 .help = "RSS hash key",
3700 .next = NEXT(action_rss, NEXT_ENTRY(HEX)),
3701 .args = ARGS(ARGS_ENTRY_ARB
3702 (offsetof(struct action_rss_data, conf) +
3703 offsetof(struct rte_flow_action_rss, key),
3704 sizeof(((struct rte_flow_action_rss *)0)->key)),
3706 (offsetof(struct action_rss_data, conf) +
3707 offsetof(struct rte_flow_action_rss, key_len),
3708 sizeof(((struct rte_flow_action_rss *)0)->
3710 ARGS_ENTRY(struct action_rss_data, key)),
3712 [ACTION_RSS_KEY_LEN] = {
3714 .help = "RSS hash key length in bytes",
3715 .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
3716 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
3717 (offsetof(struct action_rss_data, conf) +
3718 offsetof(struct rte_flow_action_rss, key_len),
3719 sizeof(((struct rte_flow_action_rss *)0)->
3722 RSS_HASH_KEY_LENGTH)),
3724 [ACTION_RSS_QUEUES] = {
3726 .help = "queue indices to use",
3727 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_QUEUE)),
3728 .call = parse_vc_conf,
3730 [ACTION_RSS_QUEUE] = {
3732 .help = "queue index",
3733 .call = parse_vc_action_rss_queue,
3734 .comp = comp_vc_action_rss_queue,
3738 .help = "direct traffic to physical function",
3739 .priv = PRIV_ACTION(PF, 0),
3740 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3745 .help = "direct traffic to a virtual function ID",
3746 .priv = PRIV_ACTION(VF, sizeof(struct rte_flow_action_vf)),
3747 .next = NEXT(action_vf),
3750 [ACTION_VF_ORIGINAL] = {
3752 .help = "use original VF ID if possible",
3753 .next = NEXT(action_vf, NEXT_ENTRY(BOOLEAN)),
3754 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_vf,
3756 .call = parse_vc_conf,
3761 .next = NEXT(action_vf, NEXT_ENTRY(UNSIGNED)),
3762 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)),
3763 .call = parse_vc_conf,
3765 [ACTION_PHY_PORT] = {
3767 .help = "direct packets to physical port index",
3768 .priv = PRIV_ACTION(PHY_PORT,
3769 sizeof(struct rte_flow_action_phy_port)),
3770 .next = NEXT(action_phy_port),
3773 [ACTION_PHY_PORT_ORIGINAL] = {
3775 .help = "use original port index if possible",
3776 .next = NEXT(action_phy_port, NEXT_ENTRY(BOOLEAN)),
3777 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_phy_port,
3779 .call = parse_vc_conf,
3781 [ACTION_PHY_PORT_INDEX] = {
3783 .help = "physical port index",
3784 .next = NEXT(action_phy_port, NEXT_ENTRY(UNSIGNED)),
3785 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_phy_port,
3787 .call = parse_vc_conf,
3789 [ACTION_PORT_ID] = {
3791 .help = "direct matching traffic to a given DPDK port ID",
3792 .priv = PRIV_ACTION(PORT_ID,
3793 sizeof(struct rte_flow_action_port_id)),
3794 .next = NEXT(action_port_id),
3797 [ACTION_PORT_ID_ORIGINAL] = {
3799 .help = "use original DPDK port ID if possible",
3800 .next = NEXT(action_port_id, NEXT_ENTRY(BOOLEAN)),
3801 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_port_id,
3803 .call = parse_vc_conf,
3805 [ACTION_PORT_ID_ID] = {
3807 .help = "DPDK port ID",
3808 .next = NEXT(action_port_id, NEXT_ENTRY(UNSIGNED)),
3809 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_port_id, id)),
3810 .call = parse_vc_conf,
3814 .help = "meter the directed packets at given id",
3815 .priv = PRIV_ACTION(METER,
3816 sizeof(struct rte_flow_action_meter)),
3817 .next = NEXT(action_meter),
3820 [ACTION_METER_COLOR] = {
3822 .help = "meter color for the packets",
3823 .priv = PRIV_ACTION(METER_COLOR,
3824 sizeof(struct rte_flow_action_meter_color)),
3825 .next = NEXT(action_meter_color),
3828 [ACTION_METER_COLOR_TYPE] = {
3830 .help = "specific meter color",
3831 .next = NEXT(NEXT_ENTRY(ACTION_NEXT),
3832 NEXT_ENTRY(ACTION_METER_COLOR_GREEN,
3833 ACTION_METER_COLOR_YELLOW,
3834 ACTION_METER_COLOR_RED)),
3836 [ACTION_METER_COLOR_GREEN] = {
3838 .help = "meter color green",
3839 .call = parse_vc_action_meter_color_type,
3841 [ACTION_METER_COLOR_YELLOW] = {
3843 .help = "meter color yellow",
3844 .call = parse_vc_action_meter_color_type,
3846 [ACTION_METER_COLOR_RED] = {
3848 .help = "meter color red",
3849 .call = parse_vc_action_meter_color_type,
3851 [ACTION_METER_ID] = {
3853 .help = "meter id to use",
3854 .next = NEXT(action_meter, NEXT_ENTRY(UNSIGNED)),
3855 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter, mtr_id)),
3856 .call = parse_vc_conf,
3858 [ACTION_OF_SET_MPLS_TTL] = {
3859 .name = "of_set_mpls_ttl",
3860 .help = "OpenFlow's OFPAT_SET_MPLS_TTL",
3863 sizeof(struct rte_flow_action_of_set_mpls_ttl)),
3864 .next = NEXT(action_of_set_mpls_ttl),
3867 [ACTION_OF_SET_MPLS_TTL_MPLS_TTL] = {
3870 .next = NEXT(action_of_set_mpls_ttl, NEXT_ENTRY(UNSIGNED)),
3871 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_mpls_ttl,
3873 .call = parse_vc_conf,
3875 [ACTION_OF_DEC_MPLS_TTL] = {
3876 .name = "of_dec_mpls_ttl",
3877 .help = "OpenFlow's OFPAT_DEC_MPLS_TTL",
3878 .priv = PRIV_ACTION(OF_DEC_MPLS_TTL, 0),
3879 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3882 [ACTION_OF_SET_NW_TTL] = {
3883 .name = "of_set_nw_ttl",
3884 .help = "OpenFlow's OFPAT_SET_NW_TTL",
3887 sizeof(struct rte_flow_action_of_set_nw_ttl)),
3888 .next = NEXT(action_of_set_nw_ttl),
3891 [ACTION_OF_SET_NW_TTL_NW_TTL] = {
3894 .next = NEXT(action_of_set_nw_ttl, NEXT_ENTRY(UNSIGNED)),
3895 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_nw_ttl,
3897 .call = parse_vc_conf,
3899 [ACTION_OF_DEC_NW_TTL] = {
3900 .name = "of_dec_nw_ttl",
3901 .help = "OpenFlow's OFPAT_DEC_NW_TTL",
3902 .priv = PRIV_ACTION(OF_DEC_NW_TTL, 0),
3903 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3906 [ACTION_OF_COPY_TTL_OUT] = {
3907 .name = "of_copy_ttl_out",
3908 .help = "OpenFlow's OFPAT_COPY_TTL_OUT",
3909 .priv = PRIV_ACTION(OF_COPY_TTL_OUT, 0),
3910 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3913 [ACTION_OF_COPY_TTL_IN] = {
3914 .name = "of_copy_ttl_in",
3915 .help = "OpenFlow's OFPAT_COPY_TTL_IN",
3916 .priv = PRIV_ACTION(OF_COPY_TTL_IN, 0),
3917 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3920 [ACTION_OF_POP_VLAN] = {
3921 .name = "of_pop_vlan",
3922 .help = "OpenFlow's OFPAT_POP_VLAN",
3923 .priv = PRIV_ACTION(OF_POP_VLAN, 0),
3924 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3927 [ACTION_OF_PUSH_VLAN] = {
3928 .name = "of_push_vlan",
3929 .help = "OpenFlow's OFPAT_PUSH_VLAN",
3932 sizeof(struct rte_flow_action_of_push_vlan)),
3933 .next = NEXT(action_of_push_vlan),
3936 [ACTION_OF_PUSH_VLAN_ETHERTYPE] = {
3937 .name = "ethertype",
3938 .help = "EtherType",
3939 .next = NEXT(action_of_push_vlan, NEXT_ENTRY(UNSIGNED)),
3940 .args = ARGS(ARGS_ENTRY_HTON
3941 (struct rte_flow_action_of_push_vlan,
3943 .call = parse_vc_conf,
3945 [ACTION_OF_SET_VLAN_VID] = {
3946 .name = "of_set_vlan_vid",
3947 .help = "OpenFlow's OFPAT_SET_VLAN_VID",
3950 sizeof(struct rte_flow_action_of_set_vlan_vid)),
3951 .next = NEXT(action_of_set_vlan_vid),
3954 [ACTION_OF_SET_VLAN_VID_VLAN_VID] = {
3957 .next = NEXT(action_of_set_vlan_vid, NEXT_ENTRY(UNSIGNED)),
3958 .args = ARGS(ARGS_ENTRY_HTON
3959 (struct rte_flow_action_of_set_vlan_vid,
3961 .call = parse_vc_conf,
3963 [ACTION_OF_SET_VLAN_PCP] = {
3964 .name = "of_set_vlan_pcp",
3965 .help = "OpenFlow's OFPAT_SET_VLAN_PCP",
3968 sizeof(struct rte_flow_action_of_set_vlan_pcp)),
3969 .next = NEXT(action_of_set_vlan_pcp),
3972 [ACTION_OF_SET_VLAN_PCP_VLAN_PCP] = {
3974 .help = "VLAN priority",
3975 .next = NEXT(action_of_set_vlan_pcp, NEXT_ENTRY(UNSIGNED)),
3976 .args = ARGS(ARGS_ENTRY_HTON
3977 (struct rte_flow_action_of_set_vlan_pcp,
3979 .call = parse_vc_conf,
3981 [ACTION_OF_POP_MPLS] = {
3982 .name = "of_pop_mpls",
3983 .help = "OpenFlow's OFPAT_POP_MPLS",
3984 .priv = PRIV_ACTION(OF_POP_MPLS,
3985 sizeof(struct rte_flow_action_of_pop_mpls)),
3986 .next = NEXT(action_of_pop_mpls),
3989 [ACTION_OF_POP_MPLS_ETHERTYPE] = {
3990 .name = "ethertype",
3991 .help = "EtherType",
3992 .next = NEXT(action_of_pop_mpls, NEXT_ENTRY(UNSIGNED)),
3993 .args = ARGS(ARGS_ENTRY_HTON
3994 (struct rte_flow_action_of_pop_mpls,
3996 .call = parse_vc_conf,
3998 [ACTION_OF_PUSH_MPLS] = {
3999 .name = "of_push_mpls",
4000 .help = "OpenFlow's OFPAT_PUSH_MPLS",
4003 sizeof(struct rte_flow_action_of_push_mpls)),
4004 .next = NEXT(action_of_push_mpls),
4007 [ACTION_OF_PUSH_MPLS_ETHERTYPE] = {
4008 .name = "ethertype",
4009 .help = "EtherType",
4010 .next = NEXT(action_of_push_mpls, NEXT_ENTRY(UNSIGNED)),
4011 .args = ARGS(ARGS_ENTRY_HTON
4012 (struct rte_flow_action_of_push_mpls,
4014 .call = parse_vc_conf,
4016 [ACTION_VXLAN_ENCAP] = {
4017 .name = "vxlan_encap",
4018 .help = "VXLAN encapsulation, uses configuration set by \"set"
4020 .priv = PRIV_ACTION(VXLAN_ENCAP,
4021 sizeof(struct action_vxlan_encap_data)),
4022 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4023 .call = parse_vc_action_vxlan_encap,
4025 [ACTION_VXLAN_DECAP] = {
4026 .name = "vxlan_decap",
4027 .help = "Performs a decapsulation action by stripping all"
4028 " headers of the VXLAN tunnel network overlay from the"
4030 .priv = PRIV_ACTION(VXLAN_DECAP, 0),
4031 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4034 [ACTION_NVGRE_ENCAP] = {
4035 .name = "nvgre_encap",
4036 .help = "NVGRE encapsulation, uses configuration set by \"set"
4038 .priv = PRIV_ACTION(NVGRE_ENCAP,
4039 sizeof(struct action_nvgre_encap_data)),
4040 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4041 .call = parse_vc_action_nvgre_encap,
4043 [ACTION_NVGRE_DECAP] = {
4044 .name = "nvgre_decap",
4045 .help = "Performs a decapsulation action by stripping all"
4046 " headers of the NVGRE tunnel network overlay from the"
4048 .priv = PRIV_ACTION(NVGRE_DECAP, 0),
4049 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4052 [ACTION_L2_ENCAP] = {
4054 .help = "l2 encap, uses configuration set by"
4055 " \"set l2_encap\"",
4056 .priv = PRIV_ACTION(RAW_ENCAP,
4057 sizeof(struct action_raw_encap_data)),
4058 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4059 .call = parse_vc_action_l2_encap,
4061 [ACTION_L2_DECAP] = {
4063 .help = "l2 decap, uses configuration set by"
4064 " \"set l2_decap\"",
4065 .priv = PRIV_ACTION(RAW_DECAP,
4066 sizeof(struct action_raw_decap_data)),
4067 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4068 .call = parse_vc_action_l2_decap,
4070 [ACTION_MPLSOGRE_ENCAP] = {
4071 .name = "mplsogre_encap",
4072 .help = "mplsogre encapsulation, uses configuration set by"
4073 " \"set mplsogre_encap\"",
4074 .priv = PRIV_ACTION(RAW_ENCAP,
4075 sizeof(struct action_raw_encap_data)),
4076 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4077 .call = parse_vc_action_mplsogre_encap,
4079 [ACTION_MPLSOGRE_DECAP] = {
4080 .name = "mplsogre_decap",
4081 .help = "mplsogre decapsulation, uses configuration set by"
4082 " \"set mplsogre_decap\"",
4083 .priv = PRIV_ACTION(RAW_DECAP,
4084 sizeof(struct action_raw_decap_data)),
4085 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4086 .call = parse_vc_action_mplsogre_decap,
4088 [ACTION_MPLSOUDP_ENCAP] = {
4089 .name = "mplsoudp_encap",
4090 .help = "mplsoudp encapsulation, uses configuration set by"
4091 " \"set mplsoudp_encap\"",
4092 .priv = PRIV_ACTION(RAW_ENCAP,
4093 sizeof(struct action_raw_encap_data)),
4094 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4095 .call = parse_vc_action_mplsoudp_encap,
4097 [ACTION_MPLSOUDP_DECAP] = {
4098 .name = "mplsoudp_decap",
4099 .help = "mplsoudp decapsulation, uses configuration set by"
4100 " \"set mplsoudp_decap\"",
4101 .priv = PRIV_ACTION(RAW_DECAP,
4102 sizeof(struct action_raw_decap_data)),
4103 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4104 .call = parse_vc_action_mplsoudp_decap,
4106 [ACTION_SET_IPV4_SRC] = {
4107 .name = "set_ipv4_src",
4108 .help = "Set a new IPv4 source address in the outermost"
4110 .priv = PRIV_ACTION(SET_IPV4_SRC,
4111 sizeof(struct rte_flow_action_set_ipv4)),
4112 .next = NEXT(action_set_ipv4_src),
4115 [ACTION_SET_IPV4_SRC_IPV4_SRC] = {
4116 .name = "ipv4_addr",
4117 .help = "new IPv4 source address to set",
4118 .next = NEXT(action_set_ipv4_src, NEXT_ENTRY(IPV4_ADDR)),
4119 .args = ARGS(ARGS_ENTRY_HTON
4120 (struct rte_flow_action_set_ipv4, ipv4_addr)),
4121 .call = parse_vc_conf,
4123 [ACTION_SET_IPV4_DST] = {
4124 .name = "set_ipv4_dst",
4125 .help = "Set a new IPv4 destination address in the outermost"
4127 .priv = PRIV_ACTION(SET_IPV4_DST,
4128 sizeof(struct rte_flow_action_set_ipv4)),
4129 .next = NEXT(action_set_ipv4_dst),
4132 [ACTION_SET_IPV4_DST_IPV4_DST] = {
4133 .name = "ipv4_addr",
4134 .help = "new IPv4 destination address to set",
4135 .next = NEXT(action_set_ipv4_dst, NEXT_ENTRY(IPV4_ADDR)),
4136 .args = ARGS(ARGS_ENTRY_HTON
4137 (struct rte_flow_action_set_ipv4, ipv4_addr)),
4138 .call = parse_vc_conf,
4140 [ACTION_SET_IPV6_SRC] = {
4141 .name = "set_ipv6_src",
4142 .help = "Set a new IPv6 source address in the outermost"
4144 .priv = PRIV_ACTION(SET_IPV6_SRC,
4145 sizeof(struct rte_flow_action_set_ipv6)),
4146 .next = NEXT(action_set_ipv6_src),
4149 [ACTION_SET_IPV6_SRC_IPV6_SRC] = {
4150 .name = "ipv6_addr",
4151 .help = "new IPv6 source address to set",
4152 .next = NEXT(action_set_ipv6_src, NEXT_ENTRY(IPV6_ADDR)),
4153 .args = ARGS(ARGS_ENTRY_HTON
4154 (struct rte_flow_action_set_ipv6, ipv6_addr)),
4155 .call = parse_vc_conf,
4157 [ACTION_SET_IPV6_DST] = {
4158 .name = "set_ipv6_dst",
4159 .help = "Set a new IPv6 destination address in the outermost"
4161 .priv = PRIV_ACTION(SET_IPV6_DST,
4162 sizeof(struct rte_flow_action_set_ipv6)),
4163 .next = NEXT(action_set_ipv6_dst),
4166 [ACTION_SET_IPV6_DST_IPV6_DST] = {
4167 .name = "ipv6_addr",
4168 .help = "new IPv6 destination address to set",
4169 .next = NEXT(action_set_ipv6_dst, NEXT_ENTRY(IPV6_ADDR)),
4170 .args = ARGS(ARGS_ENTRY_HTON
4171 (struct rte_flow_action_set_ipv6, ipv6_addr)),
4172 .call = parse_vc_conf,
4174 [ACTION_SET_TP_SRC] = {
4175 .name = "set_tp_src",
4176 .help = "set a new source port number in the outermost"
4178 .priv = PRIV_ACTION(SET_TP_SRC,
4179 sizeof(struct rte_flow_action_set_tp)),
4180 .next = NEXT(action_set_tp_src),
4183 [ACTION_SET_TP_SRC_TP_SRC] = {
4185 .help = "new source port number to set",
4186 .next = NEXT(action_set_tp_src, NEXT_ENTRY(UNSIGNED)),
4187 .args = ARGS(ARGS_ENTRY_HTON
4188 (struct rte_flow_action_set_tp, port)),
4189 .call = parse_vc_conf,
4191 [ACTION_SET_TP_DST] = {
4192 .name = "set_tp_dst",
4193 .help = "set a new destination port number in the outermost"
4195 .priv = PRIV_ACTION(SET_TP_DST,
4196 sizeof(struct rte_flow_action_set_tp)),
4197 .next = NEXT(action_set_tp_dst),
4200 [ACTION_SET_TP_DST_TP_DST] = {
4202 .help = "new destination port number to set",
4203 .next = NEXT(action_set_tp_dst, NEXT_ENTRY(UNSIGNED)),
4204 .args = ARGS(ARGS_ENTRY_HTON
4205 (struct rte_flow_action_set_tp, port)),
4206 .call = parse_vc_conf,
4208 [ACTION_MAC_SWAP] = {
4210 .help = "Swap the source and destination MAC addresses"
4211 " in the outermost Ethernet header",
4212 .priv = PRIV_ACTION(MAC_SWAP, 0),
4213 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4216 [ACTION_DEC_TTL] = {
4218 .help = "decrease network TTL if available",
4219 .priv = PRIV_ACTION(DEC_TTL, 0),
4220 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4223 [ACTION_SET_TTL] = {
4225 .help = "set ttl value",
4226 .priv = PRIV_ACTION(SET_TTL,
4227 sizeof(struct rte_flow_action_set_ttl)),
4228 .next = NEXT(action_set_ttl),
4231 [ACTION_SET_TTL_TTL] = {
4232 .name = "ttl_value",
4233 .help = "new ttl value to set",
4234 .next = NEXT(action_set_ttl, NEXT_ENTRY(UNSIGNED)),
4235 .args = ARGS(ARGS_ENTRY_HTON
4236 (struct rte_flow_action_set_ttl, ttl_value)),
4237 .call = parse_vc_conf,
4239 [ACTION_SET_MAC_SRC] = {
4240 .name = "set_mac_src",
4241 .help = "set source mac address",
4242 .priv = PRIV_ACTION(SET_MAC_SRC,
4243 sizeof(struct rte_flow_action_set_mac)),
4244 .next = NEXT(action_set_mac_src),
4247 [ACTION_SET_MAC_SRC_MAC_SRC] = {
4249 .help = "new source mac address",
4250 .next = NEXT(action_set_mac_src, NEXT_ENTRY(MAC_ADDR)),
4251 .args = ARGS(ARGS_ENTRY_HTON
4252 (struct rte_flow_action_set_mac, mac_addr)),
4253 .call = parse_vc_conf,
4255 [ACTION_SET_MAC_DST] = {
4256 .name = "set_mac_dst",
4257 .help = "set destination mac address",
4258 .priv = PRIV_ACTION(SET_MAC_DST,
4259 sizeof(struct rte_flow_action_set_mac)),
4260 .next = NEXT(action_set_mac_dst),
4263 [ACTION_SET_MAC_DST_MAC_DST] = {
4265 .help = "new destination mac address to set",
4266 .next = NEXT(action_set_mac_dst, NEXT_ENTRY(MAC_ADDR)),
4267 .args = ARGS(ARGS_ENTRY_HTON
4268 (struct rte_flow_action_set_mac, mac_addr)),
4269 .call = parse_vc_conf,
4271 [ACTION_INC_TCP_SEQ] = {
4272 .name = "inc_tcp_seq",
4273 .help = "increase TCP sequence number",
4274 .priv = PRIV_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
4275 .next = NEXT(action_inc_tcp_seq),
4278 [ACTION_INC_TCP_SEQ_VALUE] = {
4280 .help = "the value to increase TCP sequence number by",
4281 .next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(UNSIGNED)),
4282 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4283 .call = parse_vc_conf,
4285 [ACTION_DEC_TCP_SEQ] = {
4286 .name = "dec_tcp_seq",
4287 .help = "decrease TCP sequence number",
4288 .priv = PRIV_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
4289 .next = NEXT(action_dec_tcp_seq),
4292 [ACTION_DEC_TCP_SEQ_VALUE] = {
4294 .help = "the value to decrease TCP sequence number by",
4295 .next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(UNSIGNED)),
4296 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4297 .call = parse_vc_conf,
4299 [ACTION_INC_TCP_ACK] = {
4300 .name = "inc_tcp_ack",
4301 .help = "increase TCP acknowledgment number",
4302 .priv = PRIV_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
4303 .next = NEXT(action_inc_tcp_ack),
4306 [ACTION_INC_TCP_ACK_VALUE] = {
4308 .help = "the value to increase TCP acknowledgment number by",
4309 .next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(UNSIGNED)),
4310 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4311 .call = parse_vc_conf,
4313 [ACTION_DEC_TCP_ACK] = {
4314 .name = "dec_tcp_ack",
4315 .help = "decrease TCP acknowledgment number",
4316 .priv = PRIV_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
4317 .next = NEXT(action_dec_tcp_ack),
4320 [ACTION_DEC_TCP_ACK_VALUE] = {
4322 .help = "the value to decrease TCP acknowledgment number by",
4323 .next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(UNSIGNED)),
4324 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4325 .call = parse_vc_conf,
4327 [ACTION_RAW_ENCAP] = {
4328 .name = "raw_encap",
4329 .help = "encapsulation data, defined by set raw_encap",
4330 .priv = PRIV_ACTION(RAW_ENCAP,
4331 sizeof(struct action_raw_encap_data)),
4332 .next = NEXT(action_raw_encap),
4333 .call = parse_vc_action_raw_encap,
4335 [ACTION_RAW_ENCAP_INDEX] = {
4337 .help = "the index of raw_encap_confs",
4338 .next = NEXT(NEXT_ENTRY(ACTION_RAW_ENCAP_INDEX_VALUE)),
4340 [ACTION_RAW_ENCAP_INDEX_VALUE] = {
4343 .help = "unsigned integer value",
4344 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4345 .call = parse_vc_action_raw_encap_index,
4346 .comp = comp_set_raw_index,
4348 [ACTION_RAW_DECAP] = {
4349 .name = "raw_decap",
4350 .help = "decapsulation data, defined by set raw_encap",
4351 .priv = PRIV_ACTION(RAW_DECAP,
4352 sizeof(struct action_raw_decap_data)),
4353 .next = NEXT(action_raw_decap),
4354 .call = parse_vc_action_raw_decap,
4356 [ACTION_RAW_DECAP_INDEX] = {
4358 .help = "the index of raw_encap_confs",
4359 .next = NEXT(NEXT_ENTRY(ACTION_RAW_DECAP_INDEX_VALUE)),
4361 [ACTION_RAW_DECAP_INDEX_VALUE] = {
4364 .help = "unsigned integer value",
4365 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4366 .call = parse_vc_action_raw_decap_index,
4367 .comp = comp_set_raw_index,
4369 [ACTION_MODIFY_FIELD] = {
4370 .name = "modify_field",
4371 .help = "modify destination field with data from source field",
4372 .priv = PRIV_ACTION(MODIFY_FIELD,
4373 sizeof(struct rte_flow_action_modify_field)),
4374 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_OP)),
4377 [ACTION_MODIFY_FIELD_OP] = {
4379 .help = "operation type",
4380 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_TYPE),
4381 NEXT_ENTRY(ACTION_MODIFY_FIELD_OP_VALUE)),
4382 .call = parse_vc_conf,
4384 [ACTION_MODIFY_FIELD_OP_VALUE] = {
4385 .name = "{operation}",
4386 .help = "operation type value",
4387 .call = parse_vc_modify_field_op,
4388 .comp = comp_set_modify_field_op,
4390 [ACTION_MODIFY_FIELD_DST_TYPE] = {
4392 .help = "destination field type",
4393 .next = NEXT(action_modify_field_dst,
4394 NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_TYPE_VALUE)),
4395 .call = parse_vc_conf,
4397 [ACTION_MODIFY_FIELD_DST_TYPE_VALUE] = {
4398 .name = "{dst_type}",
4399 .help = "destination field type value",
4400 .call = parse_vc_modify_field_id,
4401 .comp = comp_set_modify_field_id,
4403 [ACTION_MODIFY_FIELD_DST_LEVEL] = {
4404 .name = "dst_level",
4405 .help = "destination field level",
4406 .next = NEXT(action_modify_field_dst, NEXT_ENTRY(UNSIGNED)),
4407 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4409 .call = parse_vc_conf,
4411 [ACTION_MODIFY_FIELD_DST_OFFSET] = {
4412 .name = "dst_offset",
4413 .help = "destination field bit offset",
4414 .next = NEXT(action_modify_field_dst, NEXT_ENTRY(UNSIGNED)),
4415 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4417 .call = parse_vc_conf,
4419 [ACTION_MODIFY_FIELD_SRC_TYPE] = {
4421 .help = "source field type",
4422 .next = NEXT(action_modify_field_src,
4423 NEXT_ENTRY(ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)),
4424 .call = parse_vc_conf,
4426 [ACTION_MODIFY_FIELD_SRC_TYPE_VALUE] = {
4427 .name = "{src_type}",
4428 .help = "source field type value",
4429 .call = parse_vc_modify_field_id,
4430 .comp = comp_set_modify_field_id,
4432 [ACTION_MODIFY_FIELD_SRC_LEVEL] = {
4433 .name = "src_level",
4434 .help = "source field level",
4435 .next = NEXT(action_modify_field_src, NEXT_ENTRY(UNSIGNED)),
4436 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4438 .call = parse_vc_conf,
4440 [ACTION_MODIFY_FIELD_SRC_OFFSET] = {
4441 .name = "src_offset",
4442 .help = "source field bit offset",
4443 .next = NEXT(action_modify_field_src, NEXT_ENTRY(UNSIGNED)),
4444 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4446 .call = parse_vc_conf,
4448 [ACTION_MODIFY_FIELD_SRC_VALUE] = {
4449 .name = "src_value",
4450 .help = "source immediate value",
4451 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_WIDTH),
4452 NEXT_ENTRY(UNSIGNED)),
4453 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4455 .call = parse_vc_conf,
4457 [ACTION_MODIFY_FIELD_WIDTH] = {
4459 .help = "number of bits to copy",
4460 .next = NEXT(NEXT_ENTRY(ACTION_NEXT),
4461 NEXT_ENTRY(UNSIGNED)),
4462 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4464 .call = parse_vc_conf,
4466 /* Top level command. */
4469 .help = "set raw encap/decap/sample data",
4470 .type = "set raw_encap|raw_decap <index> <pattern>"
4471 " or set sample_actions <index> <action>",
4472 .next = NEXT(NEXT_ENTRY
4475 SET_SAMPLE_ACTIONS)),
4476 .call = parse_set_init,
4478 /* Sub-level commands. */
4480 .name = "raw_encap",
4481 .help = "set raw encap data",
4482 .next = NEXT(next_set_raw),
4483 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4484 (offsetof(struct buffer, port),
4485 sizeof(((struct buffer *)0)->port),
4486 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
4487 .call = parse_set_raw_encap_decap,
4490 .name = "raw_decap",
4491 .help = "set raw decap data",
4492 .next = NEXT(next_set_raw),
4493 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4494 (offsetof(struct buffer, port),
4495 sizeof(((struct buffer *)0)->port),
4496 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
4497 .call = parse_set_raw_encap_decap,
4502 .help = "index of raw_encap/raw_decap data",
4503 .next = NEXT(next_item),
4506 [SET_SAMPLE_INDEX] = {
4509 .help = "index of sample actions",
4510 .next = NEXT(next_action_sample),
4513 [SET_SAMPLE_ACTIONS] = {
4514 .name = "sample_actions",
4515 .help = "set sample actions list",
4516 .next = NEXT(NEXT_ENTRY(SET_SAMPLE_INDEX)),
4517 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4518 (offsetof(struct buffer, port),
4519 sizeof(((struct buffer *)0)->port),
4520 0, RAW_SAMPLE_CONFS_MAX_NUM - 1)),
4521 .call = parse_set_sample_action,
4523 [ACTION_SET_TAG] = {
4526 .priv = PRIV_ACTION(SET_TAG,
4527 sizeof(struct rte_flow_action_set_tag)),
4528 .next = NEXT(action_set_tag),
4531 [ACTION_SET_TAG_INDEX] = {
4533 .help = "index of tag array",
4534 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
4535 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_set_tag, index)),
4536 .call = parse_vc_conf,
4538 [ACTION_SET_TAG_DATA] = {
4540 .help = "tag value",
4541 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
4542 .args = ARGS(ARGS_ENTRY
4543 (struct rte_flow_action_set_tag, data)),
4544 .call = parse_vc_conf,
4546 [ACTION_SET_TAG_MASK] = {
4548 .help = "mask for tag value",
4549 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
4550 .args = ARGS(ARGS_ENTRY
4551 (struct rte_flow_action_set_tag, mask)),
4552 .call = parse_vc_conf,
4554 [ACTION_SET_META] = {
4556 .help = "set metadata",
4557 .priv = PRIV_ACTION(SET_META,
4558 sizeof(struct rte_flow_action_set_meta)),
4559 .next = NEXT(action_set_meta),
4560 .call = parse_vc_action_set_meta,
4562 [ACTION_SET_META_DATA] = {
4564 .help = "metadata value",
4565 .next = NEXT(action_set_meta, NEXT_ENTRY(UNSIGNED)),
4566 .args = ARGS(ARGS_ENTRY
4567 (struct rte_flow_action_set_meta, data)),
4568 .call = parse_vc_conf,
4570 [ACTION_SET_META_MASK] = {
4572 .help = "mask for metadata value",
4573 .next = NEXT(action_set_meta, NEXT_ENTRY(UNSIGNED)),
4574 .args = ARGS(ARGS_ENTRY
4575 (struct rte_flow_action_set_meta, mask)),
4576 .call = parse_vc_conf,
4578 [ACTION_SET_IPV4_DSCP] = {
4579 .name = "set_ipv4_dscp",
4580 .help = "set DSCP value",
4581 .priv = PRIV_ACTION(SET_IPV4_DSCP,
4582 sizeof(struct rte_flow_action_set_dscp)),
4583 .next = NEXT(action_set_ipv4_dscp),
4586 [ACTION_SET_IPV4_DSCP_VALUE] = {
4587 .name = "dscp_value",
4588 .help = "new IPv4 DSCP value to set",
4589 .next = NEXT(action_set_ipv4_dscp, NEXT_ENTRY(UNSIGNED)),
4590 .args = ARGS(ARGS_ENTRY
4591 (struct rte_flow_action_set_dscp, dscp)),
4592 .call = parse_vc_conf,
4594 [ACTION_SET_IPV6_DSCP] = {
4595 .name = "set_ipv6_dscp",
4596 .help = "set DSCP value",
4597 .priv = PRIV_ACTION(SET_IPV6_DSCP,
4598 sizeof(struct rte_flow_action_set_dscp)),
4599 .next = NEXT(action_set_ipv6_dscp),
4602 [ACTION_SET_IPV6_DSCP_VALUE] = {
4603 .name = "dscp_value",
4604 .help = "new IPv6 DSCP value to set",
4605 .next = NEXT(action_set_ipv6_dscp, NEXT_ENTRY(UNSIGNED)),
4606 .args = ARGS(ARGS_ENTRY
4607 (struct rte_flow_action_set_dscp, dscp)),
4608 .call = parse_vc_conf,
4612 .help = "set a specific metadata header",
4613 .next = NEXT(action_age),
4614 .priv = PRIV_ACTION(AGE,
4615 sizeof(struct rte_flow_action_age)),
4618 [ACTION_AGE_TIMEOUT] = {
4620 .help = "flow age timeout value",
4621 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_age,
4623 .next = NEXT(action_age, NEXT_ENTRY(UNSIGNED)),
4624 .call = parse_vc_conf,
4628 .help = "set a sample action",
4629 .next = NEXT(action_sample),
4630 .priv = PRIV_ACTION(SAMPLE,
4631 sizeof(struct action_sample_data)),
4632 .call = parse_vc_action_sample,
4634 [ACTION_SAMPLE_RATIO] = {
4636 .help = "flow sample ratio value",
4637 .next = NEXT(action_sample, NEXT_ENTRY(UNSIGNED)),
4638 .args = ARGS(ARGS_ENTRY_ARB
4639 (offsetof(struct action_sample_data, conf) +
4640 offsetof(struct rte_flow_action_sample, ratio),
4641 sizeof(((struct rte_flow_action_sample *)0)->
4644 [ACTION_SAMPLE_INDEX] = {
4646 .help = "the index of sample actions list",
4647 .next = NEXT(NEXT_ENTRY(ACTION_SAMPLE_INDEX_VALUE)),
4649 [ACTION_SAMPLE_INDEX_VALUE] = {
4652 .help = "unsigned integer value",
4653 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4654 .call = parse_vc_action_sample_index,
4655 .comp = comp_set_sample_index,
4657 [ACTION_CONNTRACK] = {
4658 .name = "conntrack",
4659 .help = "create a conntrack object",
4660 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4661 .priv = PRIV_ACTION(CONNTRACK,
4662 sizeof(struct rte_flow_action_conntrack)),
4665 [ACTION_CONNTRACK_UPDATE] = {
4666 .name = "conntrack_update",
4667 .help = "update a conntrack object",
4668 .next = NEXT(action_update_conntrack),
4669 .priv = PRIV_ACTION(CONNTRACK,
4670 sizeof(struct rte_flow_modify_conntrack)),
4673 [ACTION_CONNTRACK_UPDATE_DIR] = {
4675 .help = "update a conntrack object direction",
4676 .next = NEXT(action_update_conntrack),
4677 .call = parse_vc_action_conntrack_update,
4679 [ACTION_CONNTRACK_UPDATE_CTX] = {
4681 .help = "update a conntrack object context",
4682 .next = NEXT(action_update_conntrack),
4683 .call = parse_vc_action_conntrack_update,
4685 /* Indirect action destroy arguments. */
4686 [INDIRECT_ACTION_DESTROY_ID] = {
4687 .name = "action_id",
4688 .help = "specify a indirect action id to destroy",
4689 .next = NEXT(next_ia_destroy_attr,
4690 NEXT_ENTRY(INDIRECT_ACTION_ID)),
4691 .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
4692 args.ia_destroy.action_id)),
4693 .call = parse_ia_destroy,
4695 /* Indirect action create arguments. */
4696 [INDIRECT_ACTION_CREATE_ID] = {
4697 .name = "action_id",
4698 .help = "specify a indirect action id to create",
4699 .next = NEXT(next_ia_create_attr,
4700 NEXT_ENTRY(INDIRECT_ACTION_ID)),
4701 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
4703 [ACTION_INDIRECT] = {
4705 .help = "apply indirect action by id",
4706 .priv = PRIV_ACTION(INDIRECT, 0),
4707 .next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_ID2PTR)),
4708 .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
4711 [INDIRECT_ACTION_ID2PTR] = {
4712 .name = "{action_id}",
4713 .type = "INDIRECT_ACTION_ID",
4714 .help = "indirect action id",
4715 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4716 .call = parse_ia_id2ptr,
4719 [INDIRECT_ACTION_INGRESS] = {
4721 .help = "affect rule to ingress",
4722 .next = NEXT(next_ia_create_attr),
4725 [INDIRECT_ACTION_EGRESS] = {
4727 .help = "affect rule to egress",
4728 .next = NEXT(next_ia_create_attr),
4731 [INDIRECT_ACTION_TRANSFER] = {
4733 .help = "affect rule to transfer",
4734 .next = NEXT(next_ia_create_attr),
4737 [INDIRECT_ACTION_SPEC] = {
4739 .help = "specify action to create indirect handle",
4740 .next = NEXT(next_action),
4743 .name = "g_actions",
4744 .help = "submit a list of associated actions for green",
4745 .next = NEXT(next_action),
4749 .name = "y_actions",
4750 .help = "submit a list of associated actions for yellow",
4751 .next = NEXT(next_action),
4754 .name = "r_actions",
4755 .help = "submit a list of associated actions for red",
4756 .next = NEXT(next_action),
4759 /* Top-level command. */
4762 .type = "port meter policy {port_id} {arg}",
4763 .help = "add port meter policy",
4764 .next = NEXT(NEXT_ENTRY(ITEM_POL_PORT)),
4767 /* Sub-level commands. */
4770 .help = "add port meter policy",
4771 .next = NEXT(NEXT_ENTRY(ITEM_POL_METER)),
4773 [ITEM_POL_METER] = {
4775 .help = "add port meter policy",
4776 .next = NEXT(NEXT_ENTRY(ITEM_POL_POLICY)),
4778 [ITEM_POL_POLICY] = {
4780 .help = "add port meter policy",
4781 .next = NEXT(NEXT_ENTRY(ACTION_POL_R),
4782 NEXT_ENTRY(ACTION_POL_Y),
4783 NEXT_ENTRY(ACTION_POL_G),
4784 NEXT_ENTRY(POLICY_ID),
4785 NEXT_ENTRY(PORT_ID)),
4786 .args = ARGS(ARGS_ENTRY(struct buffer, args.policy.policy_id),
4787 ARGS_ENTRY(struct buffer, port)),
4792 /** Remove and return last entry from argument stack. */
4793 static const struct arg *
4794 pop_args(struct context *ctx)
4796 return ctx->args_num ? ctx->args[--ctx->args_num] : NULL;
4799 /** Add entry on top of the argument stack. */
4801 push_args(struct context *ctx, const struct arg *arg)
4803 if (ctx->args_num == CTX_STACK_SIZE)
4805 ctx->args[ctx->args_num++] = arg;
4809 /** Spread value into buffer according to bit-mask. */
4811 arg_entry_bf_fill(void *dst, uintmax_t val, const struct arg *arg)
4813 uint32_t i = arg->size;
4821 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
4830 unsigned int shift = 0;
4831 uint8_t *buf = (uint8_t *)dst + arg->offset + (i -= sub);
4833 for (shift = 0; arg->mask[i] >> shift; ++shift) {
4834 if (!(arg->mask[i] & (1 << shift)))
4839 *buf &= ~(1 << shift);
4840 *buf |= (val & 1) << shift;
4848 /** Compare a string with a partial one of a given length. */
4850 strcmp_partial(const char *full, const char *partial, size_t partial_len)
4852 int r = strncmp(full, partial, partial_len);
4856 if (strlen(full) <= partial_len)
4858 return full[partial_len];
4862 * Parse a prefix length and generate a bit-mask.
4864 * Last argument (ctx->args) is retrieved to determine mask size, storage
4865 * location and whether the result must use network byte ordering.
4868 parse_prefix(struct context *ctx, const struct token *token,
4869 const char *str, unsigned int len,
4870 void *buf, unsigned int size)
4872 const struct arg *arg = pop_args(ctx);
4873 static const uint8_t conv[] = "\x00\x80\xc0\xe0\xf0\xf8\xfc\xfe\xff";
4880 /* Argument is expected. */
4884 u = strtoumax(str, &end, 0);
4885 if (errno || (size_t)(end - str) != len)
4890 extra = arg_entry_bf_fill(NULL, 0, arg);
4899 if (!arg_entry_bf_fill(ctx->object, v, arg) ||
4900 !arg_entry_bf_fill(ctx->objmask, -1, arg))
4907 if (bytes > size || bytes + !!extra > size)
4911 buf = (uint8_t *)ctx->object + arg->offset;
4912 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
4914 memset((uint8_t *)buf + size - bytes, 0xff, bytes);
4915 memset(buf, 0x00, size - bytes);
4917 ((uint8_t *)buf)[size - bytes - 1] = conv[extra];
4921 memset(buf, 0xff, bytes);
4922 memset((uint8_t *)buf + bytes, 0x00, size - bytes);
4924 ((uint8_t *)buf)[bytes] = conv[extra];
4927 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
4930 push_args(ctx, arg);
4934 /** Default parsing function for token name matching. */
4936 parse_default(struct context *ctx, const struct token *token,
4937 const char *str, unsigned int len,
4938 void *buf, unsigned int size)
4943 if (strcmp_partial(token->name, str, len))
4948 /** Parse flow command, initialize output buffer for subsequent tokens. */
4950 parse_init(struct context *ctx, const struct token *token,
4951 const char *str, unsigned int len,
4952 void *buf, unsigned int size)
4954 struct buffer *out = buf;
4956 /* Token name must match. */
4957 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4959 /* Nothing else to do if there is no buffer. */
4962 /* Make sure buffer is large enough. */
4963 if (size < sizeof(*out))
4965 /* Initialize buffer. */
4966 memset(out, 0x00, sizeof(*out));
4967 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
4970 ctx->objmask = NULL;
4974 /** Parse tokens for indirect action commands. */
4976 parse_ia(struct context *ctx, const struct token *token,
4977 const char *str, unsigned int len,
4978 void *buf, unsigned int size)
4980 struct buffer *out = buf;
4982 /* Token name must match. */
4983 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4985 /* Nothing else to do if there is no buffer. */
4988 if (!out->command) {
4989 if (ctx->curr != INDIRECT_ACTION)
4991 if (sizeof(*out) > size)
4993 out->command = ctx->curr;
4996 ctx->objmask = NULL;
4997 out->args.vc.data = (uint8_t *)out + size;
5000 switch (ctx->curr) {
5001 case INDIRECT_ACTION_CREATE:
5002 case INDIRECT_ACTION_UPDATE:
5003 out->args.vc.actions =
5004 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5006 out->args.vc.attr.group = UINT32_MAX;
5008 case INDIRECT_ACTION_QUERY:
5009 out->command = ctx->curr;
5012 ctx->objmask = NULL;
5014 case INDIRECT_ACTION_EGRESS:
5015 out->args.vc.attr.egress = 1;
5017 case INDIRECT_ACTION_INGRESS:
5018 out->args.vc.attr.ingress = 1;
5020 case INDIRECT_ACTION_TRANSFER:
5021 out->args.vc.attr.transfer = 1;
5029 /** Parse tokens for indirect action destroy command. */
5031 parse_ia_destroy(struct context *ctx, const struct token *token,
5032 const char *str, unsigned int len,
5033 void *buf, unsigned int size)
5035 struct buffer *out = buf;
5036 uint32_t *action_id;
5038 /* Token name must match. */
5039 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5041 /* Nothing else to do if there is no buffer. */
5044 if (!out->command || out->command == INDIRECT_ACTION) {
5045 if (ctx->curr != INDIRECT_ACTION_DESTROY)
5047 if (sizeof(*out) > size)
5049 out->command = ctx->curr;
5052 ctx->objmask = NULL;
5053 out->args.ia_destroy.action_id =
5054 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5058 action_id = out->args.ia_destroy.action_id
5059 + out->args.ia_destroy.action_id_n++;
5060 if ((uint8_t *)action_id > (uint8_t *)out + size)
5063 ctx->object = action_id;
5064 ctx->objmask = NULL;
5068 /** Parse tokens for meter policy action commands. */
5070 parse_mp(struct context *ctx, const struct token *token,
5071 const char *str, unsigned int len,
5072 void *buf, unsigned int size)
5074 struct buffer *out = buf;
5076 /* Token name must match. */
5077 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5079 /* Nothing else to do if there is no buffer. */
5082 if (!out->command) {
5083 if (ctx->curr != ITEM_POL_POLICY)
5085 if (sizeof(*out) > size)
5087 out->command = ctx->curr;
5090 ctx->objmask = NULL;
5091 out->args.vc.data = (uint8_t *)out + size;
5094 switch (ctx->curr) {
5096 out->args.vc.actions =
5097 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5099 out->command = ctx->curr;
5102 ctx->objmask = NULL;
5109 /** Parse tokens for validate/create commands. */
5111 parse_vc(struct context *ctx, const struct token *token,
5112 const char *str, unsigned int len,
5113 void *buf, unsigned int size)
5115 struct buffer *out = buf;
5119 /* Token name must match. */
5120 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5122 /* Nothing else to do if there is no buffer. */
5125 if (!out->command) {
5126 if (ctx->curr != VALIDATE && ctx->curr != CREATE)
5128 if (sizeof(*out) > size)
5130 out->command = ctx->curr;
5133 ctx->objmask = NULL;
5134 out->args.vc.data = (uint8_t *)out + size;
5138 switch (ctx->curr) {
5140 ctx->object = &out->args.vc.attr;
5144 ctx->object = &out->args.vc.tunnel_ops;
5147 ctx->objmask = NULL;
5148 switch (ctx->curr) {
5153 out->args.vc.tunnel_ops.enabled = 1;
5154 out->args.vc.tunnel_ops.actions = 1;
5157 out->args.vc.tunnel_ops.enabled = 1;
5158 out->args.vc.tunnel_ops.items = 1;
5161 out->args.vc.attr.ingress = 1;
5164 out->args.vc.attr.egress = 1;
5167 out->args.vc.attr.transfer = 1;
5170 out->args.vc.pattern =
5171 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5173 ctx->object = out->args.vc.pattern;
5174 ctx->objmask = NULL;
5177 out->args.vc.actions =
5178 (void *)RTE_ALIGN_CEIL((uintptr_t)
5179 (out->args.vc.pattern +
5180 out->args.vc.pattern_n),
5182 ctx->object = out->args.vc.actions;
5183 ctx->objmask = NULL;
5190 if (!out->args.vc.actions) {
5191 const struct parse_item_priv *priv = token->priv;
5192 struct rte_flow_item *item =
5193 out->args.vc.pattern + out->args.vc.pattern_n;
5195 data_size = priv->size * 3; /* spec, last, mask */
5196 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
5197 (out->args.vc.data - data_size),
5199 if ((uint8_t *)item + sizeof(*item) > data)
5201 *item = (struct rte_flow_item){
5204 ++out->args.vc.pattern_n;
5206 ctx->objmask = NULL;
5208 const struct parse_action_priv *priv = token->priv;
5209 struct rte_flow_action *action =
5210 out->args.vc.actions + out->args.vc.actions_n;
5212 data_size = priv->size; /* configuration */
5213 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
5214 (out->args.vc.data - data_size),
5216 if ((uint8_t *)action + sizeof(*action) > data)
5218 *action = (struct rte_flow_action){
5220 .conf = data_size ? data : NULL,
5222 ++out->args.vc.actions_n;
5223 ctx->object = action;
5224 ctx->objmask = NULL;
5226 memset(data, 0, data_size);
5227 out->args.vc.data = data;
5228 ctx->objdata = data_size;
5232 /** Parse pattern item parameter type. */
5234 parse_vc_spec(struct context *ctx, const struct token *token,
5235 const char *str, unsigned int len,
5236 void *buf, unsigned int size)
5238 struct buffer *out = buf;
5239 struct rte_flow_item *item;
5245 /* Token name must match. */
5246 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5248 /* Parse parameter types. */
5249 switch (ctx->curr) {
5250 static const enum index prefix[] = NEXT_ENTRY(PREFIX);
5256 case ITEM_PARAM_SPEC:
5259 case ITEM_PARAM_LAST:
5262 case ITEM_PARAM_PREFIX:
5263 /* Modify next token to expect a prefix. */
5264 if (ctx->next_num < 2)
5266 ctx->next[ctx->next_num - 2] = prefix;
5268 case ITEM_PARAM_MASK:
5274 /* Nothing else to do if there is no buffer. */
5277 if (!out->args.vc.pattern_n)
5279 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
5280 data_size = ctx->objdata / 3; /* spec, last, mask */
5281 /* Point to selected object. */
5282 ctx->object = out->args.vc.data + (data_size * index);
5284 ctx->objmask = out->args.vc.data + (data_size * 2); /* mask */
5285 item->mask = ctx->objmask;
5287 ctx->objmask = NULL;
5288 /* Update relevant item pointer. */
5289 *((const void **[]){ &item->spec, &item->last, &item->mask })[index] =
5294 /** Parse action configuration field. */
5296 parse_vc_conf(struct context *ctx, const struct token *token,
5297 const char *str, unsigned int len,
5298 void *buf, unsigned int size)
5300 struct buffer *out = buf;
5303 /* Token name must match. */
5304 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5306 /* Nothing else to do if there is no buffer. */
5309 /* Point to selected object. */
5310 ctx->object = out->args.vc.data;
5311 ctx->objmask = NULL;
5315 /** Parse eCPRI common header type field. */
5317 parse_vc_item_ecpri_type(struct context *ctx, const struct token *token,
5318 const char *str, unsigned int len,
5319 void *buf, unsigned int size)
5321 struct rte_flow_item_ecpri *ecpri;
5322 struct rte_flow_item_ecpri *ecpri_mask;
5323 struct rte_flow_item *item;
5326 struct buffer *out = buf;
5327 const struct arg *arg;
5330 /* Token name must match. */
5331 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5333 switch (ctx->curr) {
5334 case ITEM_ECPRI_COMMON_TYPE_IQ_DATA:
5335 msg_type = RTE_ECPRI_MSG_TYPE_IQ_DATA;
5337 case ITEM_ECPRI_COMMON_TYPE_RTC_CTRL:
5338 msg_type = RTE_ECPRI_MSG_TYPE_RTC_CTRL;
5340 case ITEM_ECPRI_COMMON_TYPE_DLY_MSR:
5341 msg_type = RTE_ECPRI_MSG_TYPE_DLY_MSR;
5348 arg = pop_args(ctx);
5351 ecpri = (struct rte_flow_item_ecpri *)out->args.vc.data;
5352 ecpri->hdr.common.type = msg_type;
5353 data_size = ctx->objdata / 3; /* spec, last, mask */
5354 ecpri_mask = (struct rte_flow_item_ecpri *)(out->args.vc.data +
5356 ecpri_mask->hdr.common.type = 0xFF;
5358 ecpri->hdr.common.u32 = rte_cpu_to_be_32(ecpri->hdr.common.u32);
5359 ecpri_mask->hdr.common.u32 =
5360 rte_cpu_to_be_32(ecpri_mask->hdr.common.u32);
5362 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
5364 item->mask = ecpri_mask;
5368 /** Parse meter color action type. */
5370 parse_vc_action_meter_color_type(struct context *ctx, const struct token *token,
5371 const char *str, unsigned int len,
5372 void *buf, unsigned int size)
5374 struct rte_flow_action *action_data;
5375 struct rte_flow_action_meter_color *conf;
5376 enum rte_color color;
5380 /* Token name must match. */
5381 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5383 switch (ctx->curr) {
5384 case ACTION_METER_COLOR_GREEN:
5385 color = RTE_COLOR_GREEN;
5387 case ACTION_METER_COLOR_YELLOW:
5388 color = RTE_COLOR_YELLOW;
5390 case ACTION_METER_COLOR_RED:
5391 color = RTE_COLOR_RED;
5399 action_data = ctx->object;
5400 conf = (struct rte_flow_action_meter_color *)
5401 (uintptr_t)(action_data->conf);
5402 conf->color = color;
5406 /** Parse RSS action. */
5408 parse_vc_action_rss(struct context *ctx, const struct token *token,
5409 const char *str, unsigned int len,
5410 void *buf, unsigned int size)
5412 struct buffer *out = buf;
5413 struct rte_flow_action *action;
5414 struct action_rss_data *action_rss_data;
5418 ret = parse_vc(ctx, token, str, len, buf, size);
5421 /* Nothing else to do if there is no buffer. */
5424 if (!out->args.vc.actions_n)
5426 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5427 /* Point to selected object. */
5428 ctx->object = out->args.vc.data;
5429 ctx->objmask = NULL;
5430 /* Set up default configuration. */
5431 action_rss_data = ctx->object;
5432 *action_rss_data = (struct action_rss_data){
5433 .conf = (struct rte_flow_action_rss){
5434 .func = RTE_ETH_HASH_FUNCTION_DEFAULT,
5438 .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM),
5440 .queue = action_rss_data->queue,
5444 for (i = 0; i < action_rss_data->conf.queue_num; ++i)
5445 action_rss_data->queue[i] = i;
5446 action->conf = &action_rss_data->conf;
5451 * Parse func field for RSS action.
5453 * The RTE_ETH_HASH_FUNCTION_* value to assign is derived from the
5454 * ACTION_RSS_FUNC_* index that called this function.
5457 parse_vc_action_rss_func(struct context *ctx, const struct token *token,
5458 const char *str, unsigned int len,
5459 void *buf, unsigned int size)
5461 struct action_rss_data *action_rss_data;
5462 enum rte_eth_hash_function func;
5466 /* Token name must match. */
5467 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5469 switch (ctx->curr) {
5470 case ACTION_RSS_FUNC_DEFAULT:
5471 func = RTE_ETH_HASH_FUNCTION_DEFAULT;
5473 case ACTION_RSS_FUNC_TOEPLITZ:
5474 func = RTE_ETH_HASH_FUNCTION_TOEPLITZ;
5476 case ACTION_RSS_FUNC_SIMPLE_XOR:
5477 func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
5479 case ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ:
5480 func = RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
5487 action_rss_data = ctx->object;
5488 action_rss_data->conf.func = func;
5493 * Parse type field for RSS action.
5495 * Valid tokens are type field names and the "end" token.
5498 parse_vc_action_rss_type(struct context *ctx, const struct token *token,
5499 const char *str, unsigned int len,
5500 void *buf, unsigned int size)
5502 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE);
5503 struct action_rss_data *action_rss_data;
5509 if (ctx->curr != ACTION_RSS_TYPE)
5511 if (!(ctx->objdata >> 16) && ctx->object) {
5512 action_rss_data = ctx->object;
5513 action_rss_data->conf.types = 0;
5515 if (!strcmp_partial("end", str, len)) {
5516 ctx->objdata &= 0xffff;
5519 for (i = 0; rss_type_table[i].str; ++i)
5520 if (!strcmp_partial(rss_type_table[i].str, str, len))
5522 if (!rss_type_table[i].str)
5524 ctx->objdata = 1 << 16 | (ctx->objdata & 0xffff);
5526 if (ctx->next_num == RTE_DIM(ctx->next))
5528 ctx->next[ctx->next_num++] = next;
5531 action_rss_data = ctx->object;
5532 action_rss_data->conf.types |= rss_type_table[i].rss_type;
5537 * Parse queue field for RSS action.
5539 * Valid tokens are queue indices and the "end" token.
5542 parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
5543 const char *str, unsigned int len,
5544 void *buf, unsigned int size)
5546 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE);
5547 struct action_rss_data *action_rss_data;
5548 const struct arg *arg;
5555 if (ctx->curr != ACTION_RSS_QUEUE)
5557 i = ctx->objdata >> 16;
5558 if (!strcmp_partial("end", str, len)) {
5559 ctx->objdata &= 0xffff;
5562 if (i >= ACTION_RSS_QUEUE_NUM)
5564 arg = ARGS_ENTRY_ARB(offsetof(struct action_rss_data, queue) +
5565 i * sizeof(action_rss_data->queue[i]),
5566 sizeof(action_rss_data->queue[i]));
5567 if (push_args(ctx, arg))
5569 ret = parse_int(ctx, token, str, len, NULL, 0);
5575 ctx->objdata = i << 16 | (ctx->objdata & 0xffff);
5577 if (ctx->next_num == RTE_DIM(ctx->next))
5579 ctx->next[ctx->next_num++] = next;
5583 action_rss_data = ctx->object;
5584 action_rss_data->conf.queue_num = i;
5585 action_rss_data->conf.queue = i ? action_rss_data->queue : NULL;
5589 /** Setup VXLAN encap configuration. */
5591 parse_setup_vxlan_encap_data(struct action_vxlan_encap_data *action_vxlan_encap_data)
5593 /* Set up default configuration. */
5594 *action_vxlan_encap_data = (struct action_vxlan_encap_data){
5595 .conf = (struct rte_flow_action_vxlan_encap){
5596 .definition = action_vxlan_encap_data->items,
5600 .type = RTE_FLOW_ITEM_TYPE_ETH,
5601 .spec = &action_vxlan_encap_data->item_eth,
5602 .mask = &rte_flow_item_eth_mask,
5605 .type = RTE_FLOW_ITEM_TYPE_VLAN,
5606 .spec = &action_vxlan_encap_data->item_vlan,
5607 .mask = &rte_flow_item_vlan_mask,
5610 .type = RTE_FLOW_ITEM_TYPE_IPV4,
5611 .spec = &action_vxlan_encap_data->item_ipv4,
5612 .mask = &rte_flow_item_ipv4_mask,
5615 .type = RTE_FLOW_ITEM_TYPE_UDP,
5616 .spec = &action_vxlan_encap_data->item_udp,
5617 .mask = &rte_flow_item_udp_mask,
5620 .type = RTE_FLOW_ITEM_TYPE_VXLAN,
5621 .spec = &action_vxlan_encap_data->item_vxlan,
5622 .mask = &rte_flow_item_vxlan_mask,
5625 .type = RTE_FLOW_ITEM_TYPE_END,
5630 .tci = vxlan_encap_conf.vlan_tci,
5634 .src_addr = vxlan_encap_conf.ipv4_src,
5635 .dst_addr = vxlan_encap_conf.ipv4_dst,
5638 .src_port = vxlan_encap_conf.udp_src,
5639 .dst_port = vxlan_encap_conf.udp_dst,
5641 .item_vxlan.flags = 0,
5643 memcpy(action_vxlan_encap_data->item_eth.dst.addr_bytes,
5644 vxlan_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5645 memcpy(action_vxlan_encap_data->item_eth.src.addr_bytes,
5646 vxlan_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5647 if (!vxlan_encap_conf.select_ipv4) {
5648 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.src_addr,
5649 &vxlan_encap_conf.ipv6_src,
5650 sizeof(vxlan_encap_conf.ipv6_src));
5651 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.dst_addr,
5652 &vxlan_encap_conf.ipv6_dst,
5653 sizeof(vxlan_encap_conf.ipv6_dst));
5654 action_vxlan_encap_data->items[2] = (struct rte_flow_item){
5655 .type = RTE_FLOW_ITEM_TYPE_IPV6,
5656 .spec = &action_vxlan_encap_data->item_ipv6,
5657 .mask = &rte_flow_item_ipv6_mask,
5660 if (!vxlan_encap_conf.select_vlan)
5661 action_vxlan_encap_data->items[1].type =
5662 RTE_FLOW_ITEM_TYPE_VOID;
5663 if (vxlan_encap_conf.select_tos_ttl) {
5664 if (vxlan_encap_conf.select_ipv4) {
5665 static struct rte_flow_item_ipv4 ipv4_mask_tos;
5667 memcpy(&ipv4_mask_tos, &rte_flow_item_ipv4_mask,
5668 sizeof(ipv4_mask_tos));
5669 ipv4_mask_tos.hdr.type_of_service = 0xff;
5670 ipv4_mask_tos.hdr.time_to_live = 0xff;
5671 action_vxlan_encap_data->item_ipv4.hdr.type_of_service =
5672 vxlan_encap_conf.ip_tos;
5673 action_vxlan_encap_data->item_ipv4.hdr.time_to_live =
5674 vxlan_encap_conf.ip_ttl;
5675 action_vxlan_encap_data->items[2].mask =
5678 static struct rte_flow_item_ipv6 ipv6_mask_tos;
5680 memcpy(&ipv6_mask_tos, &rte_flow_item_ipv6_mask,
5681 sizeof(ipv6_mask_tos));
5682 ipv6_mask_tos.hdr.vtc_flow |=
5683 RTE_BE32(0xfful << RTE_IPV6_HDR_TC_SHIFT);
5684 ipv6_mask_tos.hdr.hop_limits = 0xff;
5685 action_vxlan_encap_data->item_ipv6.hdr.vtc_flow |=
5687 ((uint32_t)vxlan_encap_conf.ip_tos <<
5688 RTE_IPV6_HDR_TC_SHIFT);
5689 action_vxlan_encap_data->item_ipv6.hdr.hop_limits =
5690 vxlan_encap_conf.ip_ttl;
5691 action_vxlan_encap_data->items[2].mask =
5695 memcpy(action_vxlan_encap_data->item_vxlan.vni, vxlan_encap_conf.vni,
5696 RTE_DIM(vxlan_encap_conf.vni));
5700 /** Parse VXLAN encap action. */
5702 parse_vc_action_vxlan_encap(struct context *ctx, const struct token *token,
5703 const char *str, unsigned int len,
5704 void *buf, unsigned int size)
5706 struct buffer *out = buf;
5707 struct rte_flow_action *action;
5708 struct action_vxlan_encap_data *action_vxlan_encap_data;
5711 ret = parse_vc(ctx, token, str, len, buf, size);
5714 /* Nothing else to do if there is no buffer. */
5717 if (!out->args.vc.actions_n)
5719 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5720 /* Point to selected object. */
5721 ctx->object = out->args.vc.data;
5722 ctx->objmask = NULL;
5723 action_vxlan_encap_data = ctx->object;
5724 parse_setup_vxlan_encap_data(action_vxlan_encap_data);
5725 action->conf = &action_vxlan_encap_data->conf;
5729 /** Setup NVGRE encap configuration. */
5731 parse_setup_nvgre_encap_data(struct action_nvgre_encap_data *action_nvgre_encap_data)
5733 /* Set up default configuration. */
5734 *action_nvgre_encap_data = (struct action_nvgre_encap_data){
5735 .conf = (struct rte_flow_action_nvgre_encap){
5736 .definition = action_nvgre_encap_data->items,
5740 .type = RTE_FLOW_ITEM_TYPE_ETH,
5741 .spec = &action_nvgre_encap_data->item_eth,
5742 .mask = &rte_flow_item_eth_mask,
5745 .type = RTE_FLOW_ITEM_TYPE_VLAN,
5746 .spec = &action_nvgre_encap_data->item_vlan,
5747 .mask = &rte_flow_item_vlan_mask,
5750 .type = RTE_FLOW_ITEM_TYPE_IPV4,
5751 .spec = &action_nvgre_encap_data->item_ipv4,
5752 .mask = &rte_flow_item_ipv4_mask,
5755 .type = RTE_FLOW_ITEM_TYPE_NVGRE,
5756 .spec = &action_nvgre_encap_data->item_nvgre,
5757 .mask = &rte_flow_item_nvgre_mask,
5760 .type = RTE_FLOW_ITEM_TYPE_END,
5765 .tci = nvgre_encap_conf.vlan_tci,
5769 .src_addr = nvgre_encap_conf.ipv4_src,
5770 .dst_addr = nvgre_encap_conf.ipv4_dst,
5772 .item_nvgre.c_k_s_rsvd0_ver = RTE_BE16(0x2000),
5773 .item_nvgre.protocol = RTE_BE16(RTE_ETHER_TYPE_TEB),
5774 .item_nvgre.flow_id = 0,
5776 memcpy(action_nvgre_encap_data->item_eth.dst.addr_bytes,
5777 nvgre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5778 memcpy(action_nvgre_encap_data->item_eth.src.addr_bytes,
5779 nvgre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5780 if (!nvgre_encap_conf.select_ipv4) {
5781 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.src_addr,
5782 &nvgre_encap_conf.ipv6_src,
5783 sizeof(nvgre_encap_conf.ipv6_src));
5784 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.dst_addr,
5785 &nvgre_encap_conf.ipv6_dst,
5786 sizeof(nvgre_encap_conf.ipv6_dst));
5787 action_nvgre_encap_data->items[2] = (struct rte_flow_item){
5788 .type = RTE_FLOW_ITEM_TYPE_IPV6,
5789 .spec = &action_nvgre_encap_data->item_ipv6,
5790 .mask = &rte_flow_item_ipv6_mask,
5793 if (!nvgre_encap_conf.select_vlan)
5794 action_nvgre_encap_data->items[1].type =
5795 RTE_FLOW_ITEM_TYPE_VOID;
5796 memcpy(action_nvgre_encap_data->item_nvgre.tni, nvgre_encap_conf.tni,
5797 RTE_DIM(nvgre_encap_conf.tni));
5801 /** Parse NVGRE encap action. */
5803 parse_vc_action_nvgre_encap(struct context *ctx, const struct token *token,
5804 const char *str, unsigned int len,
5805 void *buf, unsigned int size)
5807 struct buffer *out = buf;
5808 struct rte_flow_action *action;
5809 struct action_nvgre_encap_data *action_nvgre_encap_data;
5812 ret = parse_vc(ctx, token, str, len, buf, size);
5815 /* Nothing else to do if there is no buffer. */
5818 if (!out->args.vc.actions_n)
5820 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5821 /* Point to selected object. */
5822 ctx->object = out->args.vc.data;
5823 ctx->objmask = NULL;
5824 action_nvgre_encap_data = ctx->object;
5825 parse_setup_nvgre_encap_data(action_nvgre_encap_data);
5826 action->conf = &action_nvgre_encap_data->conf;
5830 /** Parse l2 encap action. */
5832 parse_vc_action_l2_encap(struct context *ctx, const struct token *token,
5833 const char *str, unsigned int len,
5834 void *buf, unsigned int size)
5836 struct buffer *out = buf;
5837 struct rte_flow_action *action;
5838 struct action_raw_encap_data *action_encap_data;
5839 struct rte_flow_item_eth eth = { .type = 0, };
5840 struct rte_flow_item_vlan vlan = {
5841 .tci = mplsoudp_encap_conf.vlan_tci,
5847 ret = parse_vc(ctx, token, str, len, buf, size);
5850 /* Nothing else to do if there is no buffer. */
5853 if (!out->args.vc.actions_n)
5855 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5856 /* Point to selected object. */
5857 ctx->object = out->args.vc.data;
5858 ctx->objmask = NULL;
5859 /* Copy the headers to the buffer. */
5860 action_encap_data = ctx->object;
5861 *action_encap_data = (struct action_raw_encap_data) {
5862 .conf = (struct rte_flow_action_raw_encap){
5863 .data = action_encap_data->data,
5867 header = action_encap_data->data;
5868 if (l2_encap_conf.select_vlan)
5869 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5870 else if (l2_encap_conf.select_ipv4)
5871 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5873 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5874 memcpy(eth.dst.addr_bytes,
5875 l2_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5876 memcpy(eth.src.addr_bytes,
5877 l2_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5878 memcpy(header, ð, sizeof(eth));
5879 header += sizeof(eth);
5880 if (l2_encap_conf.select_vlan) {
5881 if (l2_encap_conf.select_ipv4)
5882 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5884 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5885 memcpy(header, &vlan, sizeof(vlan));
5886 header += sizeof(vlan);
5888 action_encap_data->conf.size = header -
5889 action_encap_data->data;
5890 action->conf = &action_encap_data->conf;
5894 /** Parse l2 decap action. */
5896 parse_vc_action_l2_decap(struct context *ctx, const struct token *token,
5897 const char *str, unsigned int len,
5898 void *buf, unsigned int size)
5900 struct buffer *out = buf;
5901 struct rte_flow_action *action;
5902 struct action_raw_decap_data *action_decap_data;
5903 struct rte_flow_item_eth eth = { .type = 0, };
5904 struct rte_flow_item_vlan vlan = {
5905 .tci = mplsoudp_encap_conf.vlan_tci,
5911 ret = parse_vc(ctx, token, str, len, buf, size);
5914 /* Nothing else to do if there is no buffer. */
5917 if (!out->args.vc.actions_n)
5919 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5920 /* Point to selected object. */
5921 ctx->object = out->args.vc.data;
5922 ctx->objmask = NULL;
5923 /* Copy the headers to the buffer. */
5924 action_decap_data = ctx->object;
5925 *action_decap_data = (struct action_raw_decap_data) {
5926 .conf = (struct rte_flow_action_raw_decap){
5927 .data = action_decap_data->data,
5931 header = action_decap_data->data;
5932 if (l2_decap_conf.select_vlan)
5933 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5934 memcpy(header, ð, sizeof(eth));
5935 header += sizeof(eth);
5936 if (l2_decap_conf.select_vlan) {
5937 memcpy(header, &vlan, sizeof(vlan));
5938 header += sizeof(vlan);
5940 action_decap_data->conf.size = header -
5941 action_decap_data->data;
5942 action->conf = &action_decap_data->conf;
5946 #define ETHER_TYPE_MPLS_UNICAST 0x8847
5948 /** Parse MPLSOGRE encap action. */
5950 parse_vc_action_mplsogre_encap(struct context *ctx, const struct token *token,
5951 const char *str, unsigned int len,
5952 void *buf, unsigned int size)
5954 struct buffer *out = buf;
5955 struct rte_flow_action *action;
5956 struct action_raw_encap_data *action_encap_data;
5957 struct rte_flow_item_eth eth = { .type = 0, };
5958 struct rte_flow_item_vlan vlan = {
5959 .tci = mplsogre_encap_conf.vlan_tci,
5962 struct rte_flow_item_ipv4 ipv4 = {
5964 .src_addr = mplsogre_encap_conf.ipv4_src,
5965 .dst_addr = mplsogre_encap_conf.ipv4_dst,
5966 .next_proto_id = IPPROTO_GRE,
5967 .version_ihl = RTE_IPV4_VHL_DEF,
5968 .time_to_live = IPDEFTTL,
5971 struct rte_flow_item_ipv6 ipv6 = {
5973 .proto = IPPROTO_GRE,
5974 .hop_limits = IPDEFTTL,
5977 struct rte_flow_item_gre gre = {
5978 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
5980 struct rte_flow_item_mpls mpls = {
5986 ret = parse_vc(ctx, token, str, len, buf, size);
5989 /* Nothing else to do if there is no buffer. */
5992 if (!out->args.vc.actions_n)
5994 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5995 /* Point to selected object. */
5996 ctx->object = out->args.vc.data;
5997 ctx->objmask = NULL;
5998 /* Copy the headers to the buffer. */
5999 action_encap_data = ctx->object;
6000 *action_encap_data = (struct action_raw_encap_data) {
6001 .conf = (struct rte_flow_action_raw_encap){
6002 .data = action_encap_data->data,
6007 header = action_encap_data->data;
6008 if (mplsogre_encap_conf.select_vlan)
6009 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
6010 else if (mplsogre_encap_conf.select_ipv4)
6011 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6013 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6014 memcpy(eth.dst.addr_bytes,
6015 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
6016 memcpy(eth.src.addr_bytes,
6017 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
6018 memcpy(header, ð, sizeof(eth));
6019 header += sizeof(eth);
6020 if (mplsogre_encap_conf.select_vlan) {
6021 if (mplsogre_encap_conf.select_ipv4)
6022 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6024 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6025 memcpy(header, &vlan, sizeof(vlan));
6026 header += sizeof(vlan);
6028 if (mplsogre_encap_conf.select_ipv4) {
6029 memcpy(header, &ipv4, sizeof(ipv4));
6030 header += sizeof(ipv4);
6032 memcpy(&ipv6.hdr.src_addr,
6033 &mplsogre_encap_conf.ipv6_src,
6034 sizeof(mplsogre_encap_conf.ipv6_src));
6035 memcpy(&ipv6.hdr.dst_addr,
6036 &mplsogre_encap_conf.ipv6_dst,
6037 sizeof(mplsogre_encap_conf.ipv6_dst));
6038 memcpy(header, &ipv6, sizeof(ipv6));
6039 header += sizeof(ipv6);
6041 memcpy(header, &gre, sizeof(gre));
6042 header += sizeof(gre);
6043 memcpy(mpls.label_tc_s, mplsogre_encap_conf.label,
6044 RTE_DIM(mplsogre_encap_conf.label));
6045 mpls.label_tc_s[2] |= 0x1;
6046 memcpy(header, &mpls, sizeof(mpls));
6047 header += sizeof(mpls);
6048 action_encap_data->conf.size = header -
6049 action_encap_data->data;
6050 action->conf = &action_encap_data->conf;
6054 /** Parse MPLSOGRE decap action. */
6056 parse_vc_action_mplsogre_decap(struct context *ctx, const struct token *token,
6057 const char *str, unsigned int len,
6058 void *buf, unsigned int size)
6060 struct buffer *out = buf;
6061 struct rte_flow_action *action;
6062 struct action_raw_decap_data *action_decap_data;
6063 struct rte_flow_item_eth eth = { .type = 0, };
6064 struct rte_flow_item_vlan vlan = {.tci = 0};
6065 struct rte_flow_item_ipv4 ipv4 = {
6067 .next_proto_id = IPPROTO_GRE,
6070 struct rte_flow_item_ipv6 ipv6 = {
6072 .proto = IPPROTO_GRE,
6075 struct rte_flow_item_gre gre = {
6076 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
6078 struct rte_flow_item_mpls mpls;
6082 ret = parse_vc(ctx, token, str, len, buf, size);
6085 /* Nothing else to do if there is no buffer. */
6088 if (!out->args.vc.actions_n)
6090 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6091 /* Point to selected object. */
6092 ctx->object = out->args.vc.data;
6093 ctx->objmask = NULL;
6094 /* Copy the headers to the buffer. */
6095 action_decap_data = ctx->object;
6096 *action_decap_data = (struct action_raw_decap_data) {
6097 .conf = (struct rte_flow_action_raw_decap){
6098 .data = action_decap_data->data,
6102 header = action_decap_data->data;
6103 if (mplsogre_decap_conf.select_vlan)
6104 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
6105 else if (mplsogre_encap_conf.select_ipv4)
6106 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6108 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6109 memcpy(eth.dst.addr_bytes,
6110 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
6111 memcpy(eth.src.addr_bytes,
6112 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
6113 memcpy(header, ð, sizeof(eth));
6114 header += sizeof(eth);
6115 if (mplsogre_encap_conf.select_vlan) {
6116 if (mplsogre_encap_conf.select_ipv4)
6117 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6119 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6120 memcpy(header, &vlan, sizeof(vlan));
6121 header += sizeof(vlan);
6123 if (mplsogre_encap_conf.select_ipv4) {
6124 memcpy(header, &ipv4, sizeof(ipv4));
6125 header += sizeof(ipv4);
6127 memcpy(header, &ipv6, sizeof(ipv6));
6128 header += sizeof(ipv6);
6130 memcpy(header, &gre, sizeof(gre));
6131 header += sizeof(gre);
6132 memset(&mpls, 0, sizeof(mpls));
6133 memcpy(header, &mpls, sizeof(mpls));
6134 header += sizeof(mpls);
6135 action_decap_data->conf.size = header -
6136 action_decap_data->data;
6137 action->conf = &action_decap_data->conf;
6141 /** Parse MPLSOUDP encap action. */
6143 parse_vc_action_mplsoudp_encap(struct context *ctx, const struct token *token,
6144 const char *str, unsigned int len,
6145 void *buf, unsigned int size)
6147 struct buffer *out = buf;
6148 struct rte_flow_action *action;
6149 struct action_raw_encap_data *action_encap_data;
6150 struct rte_flow_item_eth eth = { .type = 0, };
6151 struct rte_flow_item_vlan vlan = {
6152 .tci = mplsoudp_encap_conf.vlan_tci,
6155 struct rte_flow_item_ipv4 ipv4 = {
6157 .src_addr = mplsoudp_encap_conf.ipv4_src,
6158 .dst_addr = mplsoudp_encap_conf.ipv4_dst,
6159 .next_proto_id = IPPROTO_UDP,
6160 .version_ihl = RTE_IPV4_VHL_DEF,
6161 .time_to_live = IPDEFTTL,
6164 struct rte_flow_item_ipv6 ipv6 = {
6166 .proto = IPPROTO_UDP,
6167 .hop_limits = IPDEFTTL,
6170 struct rte_flow_item_udp udp = {
6172 .src_port = mplsoudp_encap_conf.udp_src,
6173 .dst_port = mplsoudp_encap_conf.udp_dst,
6176 struct rte_flow_item_mpls mpls;
6180 ret = parse_vc(ctx, token, str, len, buf, size);
6183 /* Nothing else to do if there is no buffer. */
6186 if (!out->args.vc.actions_n)
6188 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6189 /* Point to selected object. */
6190 ctx->object = out->args.vc.data;
6191 ctx->objmask = NULL;
6192 /* Copy the headers to the buffer. */
6193 action_encap_data = ctx->object;
6194 *action_encap_data = (struct action_raw_encap_data) {
6195 .conf = (struct rte_flow_action_raw_encap){
6196 .data = action_encap_data->data,
6201 header = action_encap_data->data;
6202 if (mplsoudp_encap_conf.select_vlan)
6203 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
6204 else if (mplsoudp_encap_conf.select_ipv4)
6205 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6207 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6208 memcpy(eth.dst.addr_bytes,
6209 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
6210 memcpy(eth.src.addr_bytes,
6211 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
6212 memcpy(header, ð, sizeof(eth));
6213 header += sizeof(eth);
6214 if (mplsoudp_encap_conf.select_vlan) {
6215 if (mplsoudp_encap_conf.select_ipv4)
6216 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6218 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6219 memcpy(header, &vlan, sizeof(vlan));
6220 header += sizeof(vlan);
6222 if (mplsoudp_encap_conf.select_ipv4) {
6223 memcpy(header, &ipv4, sizeof(ipv4));
6224 header += sizeof(ipv4);
6226 memcpy(&ipv6.hdr.src_addr,
6227 &mplsoudp_encap_conf.ipv6_src,
6228 sizeof(mplsoudp_encap_conf.ipv6_src));
6229 memcpy(&ipv6.hdr.dst_addr,
6230 &mplsoudp_encap_conf.ipv6_dst,
6231 sizeof(mplsoudp_encap_conf.ipv6_dst));
6232 memcpy(header, &ipv6, sizeof(ipv6));
6233 header += sizeof(ipv6);
6235 memcpy(header, &udp, sizeof(udp));
6236 header += sizeof(udp);
6237 memcpy(mpls.label_tc_s, mplsoudp_encap_conf.label,
6238 RTE_DIM(mplsoudp_encap_conf.label));
6239 mpls.label_tc_s[2] |= 0x1;
6240 memcpy(header, &mpls, sizeof(mpls));
6241 header += sizeof(mpls);
6242 action_encap_data->conf.size = header -
6243 action_encap_data->data;
6244 action->conf = &action_encap_data->conf;
6248 /** Parse MPLSOUDP decap action. */
6250 parse_vc_action_mplsoudp_decap(struct context *ctx, const struct token *token,
6251 const char *str, unsigned int len,
6252 void *buf, unsigned int size)
6254 struct buffer *out = buf;
6255 struct rte_flow_action *action;
6256 struct action_raw_decap_data *action_decap_data;
6257 struct rte_flow_item_eth eth = { .type = 0, };
6258 struct rte_flow_item_vlan vlan = {.tci = 0};
6259 struct rte_flow_item_ipv4 ipv4 = {
6261 .next_proto_id = IPPROTO_UDP,
6264 struct rte_flow_item_ipv6 ipv6 = {
6266 .proto = IPPROTO_UDP,
6269 struct rte_flow_item_udp udp = {
6271 .dst_port = rte_cpu_to_be_16(6635),
6274 struct rte_flow_item_mpls mpls;
6278 ret = parse_vc(ctx, token, str, len, buf, size);
6281 /* Nothing else to do if there is no buffer. */
6284 if (!out->args.vc.actions_n)
6286 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6287 /* Point to selected object. */
6288 ctx->object = out->args.vc.data;
6289 ctx->objmask = NULL;
6290 /* Copy the headers to the buffer. */
6291 action_decap_data = ctx->object;
6292 *action_decap_data = (struct action_raw_decap_data) {
6293 .conf = (struct rte_flow_action_raw_decap){
6294 .data = action_decap_data->data,
6298 header = action_decap_data->data;
6299 if (mplsoudp_decap_conf.select_vlan)
6300 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
6301 else if (mplsoudp_encap_conf.select_ipv4)
6302 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6304 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6305 memcpy(eth.dst.addr_bytes,
6306 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
6307 memcpy(eth.src.addr_bytes,
6308 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
6309 memcpy(header, ð, sizeof(eth));
6310 header += sizeof(eth);
6311 if (mplsoudp_encap_conf.select_vlan) {
6312 if (mplsoudp_encap_conf.select_ipv4)
6313 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6315 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6316 memcpy(header, &vlan, sizeof(vlan));
6317 header += sizeof(vlan);
6319 if (mplsoudp_encap_conf.select_ipv4) {
6320 memcpy(header, &ipv4, sizeof(ipv4));
6321 header += sizeof(ipv4);
6323 memcpy(header, &ipv6, sizeof(ipv6));
6324 header += sizeof(ipv6);
6326 memcpy(header, &udp, sizeof(udp));
6327 header += sizeof(udp);
6328 memset(&mpls, 0, sizeof(mpls));
6329 memcpy(header, &mpls, sizeof(mpls));
6330 header += sizeof(mpls);
6331 action_decap_data->conf.size = header -
6332 action_decap_data->data;
6333 action->conf = &action_decap_data->conf;
6338 parse_vc_action_raw_decap_index(struct context *ctx, const struct token *token,
6339 const char *str, unsigned int len, void *buf,
6342 struct action_raw_decap_data *action_raw_decap_data;
6343 struct rte_flow_action *action;
6344 const struct arg *arg;
6345 struct buffer *out = buf;
6349 RTE_SET_USED(token);
6352 arg = ARGS_ENTRY_ARB_BOUNDED
6353 (offsetof(struct action_raw_decap_data, idx),
6354 sizeof(((struct action_raw_decap_data *)0)->idx),
6355 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
6356 if (push_args(ctx, arg))
6358 ret = parse_int(ctx, token, str, len, NULL, 0);
6365 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6366 action_raw_decap_data = ctx->object;
6367 idx = action_raw_decap_data->idx;
6368 action_raw_decap_data->conf.data = raw_decap_confs[idx].data;
6369 action_raw_decap_data->conf.size = raw_decap_confs[idx].size;
6370 action->conf = &action_raw_decap_data->conf;
6376 parse_vc_action_raw_encap_index(struct context *ctx, const struct token *token,
6377 const char *str, unsigned int len, void *buf,
6380 struct action_raw_encap_data *action_raw_encap_data;
6381 struct rte_flow_action *action;
6382 const struct arg *arg;
6383 struct buffer *out = buf;
6387 RTE_SET_USED(token);
6390 if (ctx->curr != ACTION_RAW_ENCAP_INDEX_VALUE)
6392 arg = ARGS_ENTRY_ARB_BOUNDED
6393 (offsetof(struct action_raw_encap_data, idx),
6394 sizeof(((struct action_raw_encap_data *)0)->idx),
6395 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
6396 if (push_args(ctx, arg))
6398 ret = parse_int(ctx, token, str, len, NULL, 0);
6405 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6406 action_raw_encap_data = ctx->object;
6407 idx = action_raw_encap_data->idx;
6408 action_raw_encap_data->conf.data = raw_encap_confs[idx].data;
6409 action_raw_encap_data->conf.size = raw_encap_confs[idx].size;
6410 action_raw_encap_data->conf.preserve = NULL;
6411 action->conf = &action_raw_encap_data->conf;
6416 parse_vc_action_raw_encap(struct context *ctx, const struct token *token,
6417 const char *str, unsigned int len, void *buf,
6420 struct buffer *out = buf;
6421 struct rte_flow_action *action;
6422 struct action_raw_encap_data *action_raw_encap_data = NULL;
6425 ret = parse_vc(ctx, token, str, len, buf, size);
6428 /* Nothing else to do if there is no buffer. */
6431 if (!out->args.vc.actions_n)
6433 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6434 /* Point to selected object. */
6435 ctx->object = out->args.vc.data;
6436 ctx->objmask = NULL;
6437 /* Copy the headers to the buffer. */
6438 action_raw_encap_data = ctx->object;
6439 action_raw_encap_data->conf.data = raw_encap_confs[0].data;
6440 action_raw_encap_data->conf.preserve = NULL;
6441 action_raw_encap_data->conf.size = raw_encap_confs[0].size;
6442 action->conf = &action_raw_encap_data->conf;
6447 parse_vc_action_raw_decap(struct context *ctx, const struct token *token,
6448 const char *str, unsigned int len, void *buf,
6451 struct buffer *out = buf;
6452 struct rte_flow_action *action;
6453 struct action_raw_decap_data *action_raw_decap_data = NULL;
6456 ret = parse_vc(ctx, token, str, len, buf, size);
6459 /* Nothing else to do if there is no buffer. */
6462 if (!out->args.vc.actions_n)
6464 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6465 /* Point to selected object. */
6466 ctx->object = out->args.vc.data;
6467 ctx->objmask = NULL;
6468 /* Copy the headers to the buffer. */
6469 action_raw_decap_data = ctx->object;
6470 action_raw_decap_data->conf.data = raw_decap_confs[0].data;
6471 action_raw_decap_data->conf.size = raw_decap_confs[0].size;
6472 action->conf = &action_raw_decap_data->conf;
6477 parse_vc_action_set_meta(struct context *ctx, const struct token *token,
6478 const char *str, unsigned int len, void *buf,
6483 ret = parse_vc(ctx, token, str, len, buf, size);
6486 ret = rte_flow_dynf_metadata_register();
6493 parse_vc_action_sample(struct context *ctx, const struct token *token,
6494 const char *str, unsigned int len, void *buf,
6497 struct buffer *out = buf;
6498 struct rte_flow_action *action;
6499 struct action_sample_data *action_sample_data = NULL;
6500 static struct rte_flow_action end_action = {
6501 RTE_FLOW_ACTION_TYPE_END, 0
6505 ret = parse_vc(ctx, token, str, len, buf, size);
6508 /* Nothing else to do if there is no buffer. */
6511 if (!out->args.vc.actions_n)
6513 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6514 /* Point to selected object. */
6515 ctx->object = out->args.vc.data;
6516 ctx->objmask = NULL;
6517 /* Copy the headers to the buffer. */
6518 action_sample_data = ctx->object;
6519 action_sample_data->conf.actions = &end_action;
6520 action->conf = &action_sample_data->conf;
6525 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
6526 const char *str, unsigned int len, void *buf,
6529 struct action_sample_data *action_sample_data;
6530 struct rte_flow_action *action;
6531 const struct arg *arg;
6532 struct buffer *out = buf;
6536 RTE_SET_USED(token);
6539 if (ctx->curr != ACTION_SAMPLE_INDEX_VALUE)
6541 arg = ARGS_ENTRY_ARB_BOUNDED
6542 (offsetof(struct action_sample_data, idx),
6543 sizeof(((struct action_sample_data *)0)->idx),
6544 0, RAW_SAMPLE_CONFS_MAX_NUM - 1);
6545 if (push_args(ctx, arg))
6547 ret = parse_int(ctx, token, str, len, NULL, 0);
6554 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6555 action_sample_data = ctx->object;
6556 idx = action_sample_data->idx;
6557 action_sample_data->conf.actions = raw_sample_confs[idx].data;
6558 action->conf = &action_sample_data->conf;
6562 /** Parse operation for modify_field command. */
6564 parse_vc_modify_field_op(struct context *ctx, const struct token *token,
6565 const char *str, unsigned int len, void *buf,
6568 struct rte_flow_action_modify_field *action_modify_field;
6574 if (ctx->curr != ACTION_MODIFY_FIELD_OP_VALUE)
6576 for (i = 0; modify_field_ops[i]; ++i)
6577 if (!strcmp_partial(modify_field_ops[i], str, len))
6579 if (!modify_field_ops[i])
6583 action_modify_field = ctx->object;
6584 action_modify_field->operation = (enum rte_flow_modify_op)i;
6588 /** Parse id for modify_field command. */
6590 parse_vc_modify_field_id(struct context *ctx, const struct token *token,
6591 const char *str, unsigned int len, void *buf,
6594 struct rte_flow_action_modify_field *action_modify_field;
6600 if (ctx->curr != ACTION_MODIFY_FIELD_DST_TYPE_VALUE &&
6601 ctx->curr != ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)
6603 for (i = 0; modify_field_ids[i]; ++i)
6604 if (!strcmp_partial(modify_field_ids[i], str, len))
6606 if (!modify_field_ids[i])
6610 action_modify_field = ctx->object;
6611 if (ctx->curr == ACTION_MODIFY_FIELD_DST_TYPE_VALUE)
6612 action_modify_field->dst.field = (enum rte_flow_field_id)i;
6614 action_modify_field->src.field = (enum rte_flow_field_id)i;
6618 /** Parse the conntrack update, not a rte_flow_action. */
6620 parse_vc_action_conntrack_update(struct context *ctx, const struct token *token,
6621 const char *str, unsigned int len, void *buf,
6624 struct buffer *out = buf;
6625 struct rte_flow_modify_conntrack *ct_modify = NULL;
6628 if (ctx->curr != ACTION_CONNTRACK_UPDATE_CTX &&
6629 ctx->curr != ACTION_CONNTRACK_UPDATE_DIR)
6631 /* Token name must match. */
6632 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6634 ct_modify = (struct rte_flow_modify_conntrack *)out->args.vc.data;
6635 /* Nothing else to do if there is no buffer. */
6638 if (ctx->curr == ACTION_CONNTRACK_UPDATE_DIR) {
6639 ct_modify->new_ct.is_original_dir =
6640 conntrack_context.is_original_dir;
6641 ct_modify->direction = 1;
6645 old_dir = ct_modify->new_ct.is_original_dir;
6646 memcpy(&ct_modify->new_ct, &conntrack_context,
6647 sizeof(conntrack_context));
6648 ct_modify->new_ct.is_original_dir = old_dir;
6649 ct_modify->state = 1;
6654 /** Parse tokens for destroy command. */
6656 parse_destroy(struct context *ctx, const struct token *token,
6657 const char *str, unsigned int len,
6658 void *buf, unsigned int size)
6660 struct buffer *out = buf;
6662 /* Token name must match. */
6663 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6665 /* Nothing else to do if there is no buffer. */
6668 if (!out->command) {
6669 if (ctx->curr != DESTROY)
6671 if (sizeof(*out) > size)
6673 out->command = ctx->curr;
6676 ctx->objmask = NULL;
6677 out->args.destroy.rule =
6678 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6682 if (((uint8_t *)(out->args.destroy.rule + out->args.destroy.rule_n) +
6683 sizeof(*out->args.destroy.rule)) > (uint8_t *)out + size)
6686 ctx->object = out->args.destroy.rule + out->args.destroy.rule_n++;
6687 ctx->objmask = NULL;
6691 /** Parse tokens for flush command. */
6693 parse_flush(struct context *ctx, const struct token *token,
6694 const char *str, unsigned int len,
6695 void *buf, unsigned int size)
6697 struct buffer *out = buf;
6699 /* Token name must match. */
6700 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6702 /* Nothing else to do if there is no buffer. */
6705 if (!out->command) {
6706 if (ctx->curr != FLUSH)
6708 if (sizeof(*out) > size)
6710 out->command = ctx->curr;
6713 ctx->objmask = NULL;
6718 /** Parse tokens for dump command. */
6720 parse_dump(struct context *ctx, const struct token *token,
6721 const char *str, unsigned int len,
6722 void *buf, unsigned int size)
6724 struct buffer *out = buf;
6726 /* Token name must match. */
6727 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6729 /* Nothing else to do if there is no buffer. */
6732 if (!out->command) {
6733 if (ctx->curr != DUMP)
6735 if (sizeof(*out) > size)
6737 out->command = ctx->curr;
6740 ctx->objmask = NULL;
6743 switch (ctx->curr) {
6746 out->args.dump.mode = (ctx->curr == DUMP_ALL) ? true : false;
6747 out->command = ctx->curr;
6750 ctx->objmask = NULL;
6757 /** Parse tokens for query command. */
6759 parse_query(struct context *ctx, const struct token *token,
6760 const char *str, unsigned int len,
6761 void *buf, unsigned int size)
6763 struct buffer *out = buf;
6765 /* Token name must match. */
6766 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6768 /* Nothing else to do if there is no buffer. */
6771 if (!out->command) {
6772 if (ctx->curr != QUERY)
6774 if (sizeof(*out) > size)
6776 out->command = ctx->curr;
6779 ctx->objmask = NULL;
6784 /** Parse action names. */
6786 parse_action(struct context *ctx, const struct token *token,
6787 const char *str, unsigned int len,
6788 void *buf, unsigned int size)
6790 struct buffer *out = buf;
6791 const struct arg *arg = pop_args(ctx);
6795 /* Argument is expected. */
6798 /* Parse action name. */
6799 for (i = 0; next_action[i]; ++i) {
6800 const struct parse_action_priv *priv;
6802 token = &token_list[next_action[i]];
6803 if (strcmp_partial(token->name, str, len))
6809 memcpy((uint8_t *)ctx->object + arg->offset,
6815 push_args(ctx, arg);
6819 /** Parse tokens for list command. */
6821 parse_list(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 != LIST)
6836 if (sizeof(*out) > size)
6838 out->command = ctx->curr;
6841 ctx->objmask = NULL;
6842 out->args.list.group =
6843 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6847 if (((uint8_t *)(out->args.list.group + out->args.list.group_n) +
6848 sizeof(*out->args.list.group)) > (uint8_t *)out + size)
6851 ctx->object = out->args.list.group + out->args.list.group_n++;
6852 ctx->objmask = NULL;
6856 /** Parse tokens for list all aged flows command. */
6858 parse_aged(struct context *ctx, const struct token *token,
6859 const char *str, unsigned int len,
6860 void *buf, unsigned int size)
6862 struct buffer *out = buf;
6864 /* Token name must match. */
6865 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6867 /* Nothing else to do if there is no buffer. */
6870 if (!out->command) {
6871 if (ctx->curr != AGED)
6873 if (sizeof(*out) > size)
6875 out->command = ctx->curr;
6878 ctx->objmask = NULL;
6880 if (ctx->curr == AGED_DESTROY)
6881 out->args.aged.destroy = 1;
6885 /** Parse tokens for isolate command. */
6887 parse_isolate(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 != ISOLATE)
6902 if (sizeof(*out) > size)
6904 out->command = ctx->curr;
6907 ctx->objmask = NULL;
6913 parse_tunnel(struct context *ctx, const struct token *token,
6914 const char *str, unsigned int len,
6915 void *buf, unsigned int size)
6917 struct buffer *out = buf;
6919 /* Token name must match. */
6920 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6922 /* Nothing else to do if there is no buffer. */
6925 if (!out->command) {
6926 if (ctx->curr != TUNNEL)
6928 if (sizeof(*out) > size)
6930 out->command = ctx->curr;
6933 ctx->objmask = NULL;
6935 switch (ctx->curr) {
6939 case TUNNEL_DESTROY:
6941 out->command = ctx->curr;
6943 case TUNNEL_CREATE_TYPE:
6944 case TUNNEL_DESTROY_ID:
6945 ctx->object = &out->args.vc.tunnel_ops;
6954 * Parse signed/unsigned integers 8 to 64-bit long.
6956 * Last argument (ctx->args) is retrieved to determine integer type and
6960 parse_int(struct context *ctx, const struct token *token,
6961 const char *str, unsigned int len,
6962 void *buf, unsigned int size)
6964 const struct arg *arg = pop_args(ctx);
6969 /* Argument is expected. */
6974 (uintmax_t)strtoimax(str, &end, 0) :
6975 strtoumax(str, &end, 0);
6976 if (errno || (size_t)(end - str) != len)
6979 ((arg->sign && ((intmax_t)u < (intmax_t)arg->min ||
6980 (intmax_t)u > (intmax_t)arg->max)) ||
6981 (!arg->sign && (u < arg->min || u > arg->max))))
6986 if (!arg_entry_bf_fill(ctx->object, u, arg) ||
6987 !arg_entry_bf_fill(ctx->objmask, -1, arg))
6991 buf = (uint8_t *)ctx->object + arg->offset;
6993 if (u > RTE_LEN2MASK(size * CHAR_BIT, uint64_t))
6997 case sizeof(uint8_t):
6998 *(uint8_t *)buf = u;
7000 case sizeof(uint16_t):
7001 *(uint16_t *)buf = arg->hton ? rte_cpu_to_be_16(u) : u;
7003 case sizeof(uint8_t [3]):
7004 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
7006 ((uint8_t *)buf)[0] = u;
7007 ((uint8_t *)buf)[1] = u >> 8;
7008 ((uint8_t *)buf)[2] = u >> 16;
7012 ((uint8_t *)buf)[0] = u >> 16;
7013 ((uint8_t *)buf)[1] = u >> 8;
7014 ((uint8_t *)buf)[2] = u;
7016 case sizeof(uint32_t):
7017 *(uint32_t *)buf = arg->hton ? rte_cpu_to_be_32(u) : u;
7019 case sizeof(uint64_t):
7020 *(uint64_t *)buf = arg->hton ? rte_cpu_to_be_64(u) : u;
7025 if (ctx->objmask && buf != (uint8_t *)ctx->objmask + arg->offset) {
7027 buf = (uint8_t *)ctx->objmask + arg->offset;
7032 push_args(ctx, arg);
7039 * Three arguments (ctx->args) are retrieved from the stack to store data,
7040 * its actual length and address (in that order).
7043 parse_string(struct context *ctx, const struct token *token,
7044 const char *str, unsigned int len,
7045 void *buf, unsigned int size)
7047 const struct arg *arg_data = pop_args(ctx);
7048 const struct arg *arg_len = pop_args(ctx);
7049 const struct arg *arg_addr = pop_args(ctx);
7050 char tmp[16]; /* Ought to be enough. */
7053 /* Arguments are expected. */
7057 push_args(ctx, arg_data);
7061 push_args(ctx, arg_len);
7062 push_args(ctx, arg_data);
7065 size = arg_data->size;
7066 /* Bit-mask fill is not supported. */
7067 if (arg_data->mask || size < len)
7071 /* Let parse_int() fill length information first. */
7072 ret = snprintf(tmp, sizeof(tmp), "%u", len);
7075 push_args(ctx, arg_len);
7076 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
7081 buf = (uint8_t *)ctx->object + arg_data->offset;
7082 /* Output buffer is not necessarily NUL-terminated. */
7083 memcpy(buf, str, len);
7084 memset((uint8_t *)buf + len, 0x00, size - len);
7086 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
7087 /* Save address if requested. */
7088 if (arg_addr->size) {
7089 memcpy((uint8_t *)ctx->object + arg_addr->offset,
7091 (uint8_t *)ctx->object + arg_data->offset
7095 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
7097 (uint8_t *)ctx->objmask + arg_data->offset
7103 push_args(ctx, arg_addr);
7104 push_args(ctx, arg_len);
7105 push_args(ctx, arg_data);
7110 parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
7116 /* Check input parameters */
7117 if ((src == NULL) ||
7123 /* Convert chars to bytes */
7124 for (i = 0, len = 0; i < *size; i += 2) {
7125 snprintf(tmp, 3, "%s", src + i);
7126 dst[len++] = strtoul(tmp, &c, 16);
7141 parse_hex(struct context *ctx, const struct token *token,
7142 const char *str, unsigned int len,
7143 void *buf, unsigned int size)
7145 const struct arg *arg_data = pop_args(ctx);
7146 const struct arg *arg_len = pop_args(ctx);
7147 const struct arg *arg_addr = pop_args(ctx);
7148 char tmp[16]; /* Ought to be enough. */
7150 unsigned int hexlen = len;
7151 unsigned int length = 256;
7152 uint8_t hex_tmp[length];
7154 /* Arguments are expected. */
7158 push_args(ctx, arg_data);
7162 push_args(ctx, arg_len);
7163 push_args(ctx, arg_data);
7166 size = arg_data->size;
7167 /* Bit-mask fill is not supported. */
7173 /* translate bytes string to array. */
7174 if (str[0] == '0' && ((str[1] == 'x') ||
7179 if (hexlen > length)
7181 ret = parse_hex_string(str, hex_tmp, &hexlen);
7184 /* Let parse_int() fill length information first. */
7185 ret = snprintf(tmp, sizeof(tmp), "%u", hexlen);
7188 /* Save length if requested. */
7189 if (arg_len->size) {
7190 push_args(ctx, arg_len);
7191 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
7197 buf = (uint8_t *)ctx->object + arg_data->offset;
7198 /* Output buffer is not necessarily NUL-terminated. */
7199 memcpy(buf, hex_tmp, hexlen);
7200 memset((uint8_t *)buf + hexlen, 0x00, size - hexlen);
7202 memset((uint8_t *)ctx->objmask + arg_data->offset,
7204 /* Save address if requested. */
7205 if (arg_addr->size) {
7206 memcpy((uint8_t *)ctx->object + arg_addr->offset,
7208 (uint8_t *)ctx->object + arg_data->offset
7212 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
7214 (uint8_t *)ctx->objmask + arg_data->offset
7220 push_args(ctx, arg_addr);
7221 push_args(ctx, arg_len);
7222 push_args(ctx, arg_data);
7228 * Parse a zero-ended string.
7231 parse_string0(struct context *ctx, const struct token *token __rte_unused,
7232 const char *str, unsigned int len,
7233 void *buf, unsigned int size)
7235 const struct arg *arg_data = pop_args(ctx);
7237 /* Arguments are expected. */
7240 size = arg_data->size;
7241 /* Bit-mask fill is not supported. */
7242 if (arg_data->mask || size < len + 1)
7246 buf = (uint8_t *)ctx->object + arg_data->offset;
7247 strncpy(buf, str, len);
7249 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
7252 push_args(ctx, arg_data);
7257 * Parse a MAC address.
7259 * Last argument (ctx->args) is retrieved to determine storage size and
7263 parse_mac_addr(struct context *ctx, const struct token *token,
7264 const char *str, unsigned int len,
7265 void *buf, unsigned int size)
7267 const struct arg *arg = pop_args(ctx);
7268 struct rte_ether_addr tmp;
7272 /* Argument is expected. */
7276 /* Bit-mask fill is not supported. */
7277 if (arg->mask || size != sizeof(tmp))
7279 /* Only network endian is supported. */
7282 ret = cmdline_parse_etheraddr(NULL, str, &tmp, size);
7283 if (ret < 0 || (unsigned int)ret != len)
7287 buf = (uint8_t *)ctx->object + arg->offset;
7288 memcpy(buf, &tmp, size);
7290 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
7293 push_args(ctx, arg);
7298 * Parse an IPv4 address.
7300 * Last argument (ctx->args) is retrieved to determine storage size and
7304 parse_ipv4_addr(struct context *ctx, const struct token *token,
7305 const char *str, unsigned int len,
7306 void *buf, unsigned int size)
7308 const struct arg *arg = pop_args(ctx);
7313 /* Argument is expected. */
7317 /* Bit-mask fill is not supported. */
7318 if (arg->mask || size != sizeof(tmp))
7320 /* Only network endian is supported. */
7323 memcpy(str2, str, len);
7325 ret = inet_pton(AF_INET, str2, &tmp);
7327 /* Attempt integer parsing. */
7328 push_args(ctx, arg);
7329 return parse_int(ctx, token, str, len, buf, size);
7333 buf = (uint8_t *)ctx->object + arg->offset;
7334 memcpy(buf, &tmp, size);
7336 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
7339 push_args(ctx, arg);
7344 * Parse an IPv6 address.
7346 * Last argument (ctx->args) is retrieved to determine storage size and
7350 parse_ipv6_addr(struct context *ctx, const struct token *token,
7351 const char *str, unsigned int len,
7352 void *buf, unsigned int size)
7354 const struct arg *arg = pop_args(ctx);
7356 struct in6_addr tmp;
7360 /* Argument is expected. */
7364 /* Bit-mask fill is not supported. */
7365 if (arg->mask || size != sizeof(tmp))
7367 /* Only network endian is supported. */
7370 memcpy(str2, str, len);
7372 ret = inet_pton(AF_INET6, str2, &tmp);
7377 buf = (uint8_t *)ctx->object + arg->offset;
7378 memcpy(buf, &tmp, size);
7380 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
7383 push_args(ctx, arg);
7387 /** Boolean values (even indices stand for false). */
7388 static const char *const boolean_name[] = {
7398 * Parse a boolean value.
7400 * Last argument (ctx->args) is retrieved to determine storage size and
7404 parse_boolean(struct context *ctx, const struct token *token,
7405 const char *str, unsigned int len,
7406 void *buf, unsigned int size)
7408 const struct arg *arg = pop_args(ctx);
7412 /* Argument is expected. */
7415 for (i = 0; boolean_name[i]; ++i)
7416 if (!strcmp_partial(boolean_name[i], str, len))
7418 /* Process token as integer. */
7419 if (boolean_name[i])
7420 str = i & 1 ? "1" : "0";
7421 push_args(ctx, arg);
7422 ret = parse_int(ctx, token, str, strlen(str), buf, size);
7423 return ret > 0 ? (int)len : ret;
7426 /** Parse port and update context. */
7428 parse_port(struct context *ctx, const struct token *token,
7429 const char *str, unsigned int len,
7430 void *buf, unsigned int size)
7432 struct buffer *out = &(struct buffer){ .port = 0 };
7440 ctx->objmask = NULL;
7441 size = sizeof(*out);
7443 ret = parse_int(ctx, token, str, len, out, size);
7445 ctx->port = out->port;
7452 parse_ia_id2ptr(struct context *ctx, const struct token *token,
7453 const char *str, unsigned int len,
7454 void *buf, unsigned int size)
7456 struct rte_flow_action *action = ctx->object;
7464 ctx->objmask = NULL;
7465 ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
7466 ctx->object = action;
7467 if (ret != (int)len)
7469 /* set indirect action */
7471 action->conf = port_action_handle_get_by_id(ctx->port, id);
7472 ret = (action->conf) ? ret : -1;
7477 /** Parse set command, initialize output buffer for subsequent tokens. */
7479 parse_set_raw_encap_decap(struct context *ctx, const struct token *token,
7480 const char *str, unsigned int len,
7481 void *buf, unsigned int size)
7483 struct buffer *out = buf;
7485 /* Token name must match. */
7486 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7488 /* Nothing else to do if there is no buffer. */
7491 /* Make sure buffer is large enough. */
7492 if (size < sizeof(*out))
7495 ctx->objmask = NULL;
7499 out->command = ctx->curr;
7500 /* For encap/decap we need is pattern */
7501 out->args.vc.pattern = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7506 /** Parse set command, initialize output buffer for subsequent tokens. */
7508 parse_set_sample_action(struct context *ctx, const struct token *token,
7509 const char *str, unsigned int len,
7510 void *buf, unsigned int size)
7512 struct buffer *out = buf;
7514 /* Token name must match. */
7515 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7517 /* Nothing else to do if there is no buffer. */
7520 /* Make sure buffer is large enough. */
7521 if (size < sizeof(*out))
7524 ctx->objmask = NULL;
7528 out->command = ctx->curr;
7529 /* For sampler we need is actions */
7530 out->args.vc.actions = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7536 * Parse set raw_encap/raw_decap command,
7537 * initialize output buffer for subsequent tokens.
7540 parse_set_init(struct context *ctx, const struct token *token,
7541 const char *str, unsigned int len,
7542 void *buf, unsigned int size)
7544 struct buffer *out = buf;
7546 /* Token name must match. */
7547 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7549 /* Nothing else to do if there is no buffer. */
7552 /* Make sure buffer is large enough. */
7553 if (size < sizeof(*out))
7555 /* Initialize buffer. */
7556 memset(out, 0x00, sizeof(*out));
7557 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
7560 ctx->objmask = NULL;
7561 if (!out->command) {
7562 if (ctx->curr != SET)
7564 if (sizeof(*out) > size)
7566 out->command = ctx->curr;
7567 out->args.vc.data = (uint8_t *)out + size;
7568 ctx->object = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7574 /** No completion. */
7576 comp_none(struct context *ctx, const struct token *token,
7577 unsigned int ent, char *buf, unsigned int size)
7587 /** Complete boolean values. */
7589 comp_boolean(struct context *ctx, const struct token *token,
7590 unsigned int ent, char *buf, unsigned int size)
7596 for (i = 0; boolean_name[i]; ++i)
7597 if (buf && i == ent)
7598 return strlcpy(buf, boolean_name[i], size);
7604 /** Complete action names. */
7606 comp_action(struct context *ctx, const struct token *token,
7607 unsigned int ent, char *buf, unsigned int size)
7613 for (i = 0; next_action[i]; ++i)
7614 if (buf && i == ent)
7615 return strlcpy(buf, token_list[next_action[i]].name,
7622 /** Complete available ports. */
7624 comp_port(struct context *ctx, const struct token *token,
7625 unsigned int ent, char *buf, unsigned int size)
7632 RTE_ETH_FOREACH_DEV(p) {
7633 if (buf && i == ent)
7634 return snprintf(buf, size, "%u", p);
7642 /** Complete available rule IDs. */
7644 comp_rule_id(struct context *ctx, const struct token *token,
7645 unsigned int ent, char *buf, unsigned int size)
7648 struct rte_port *port;
7649 struct port_flow *pf;
7652 if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
7653 ctx->port == (portid_t)RTE_PORT_ALL)
7655 port = &ports[ctx->port];
7656 for (pf = port->flow_list; pf != NULL; pf = pf->next) {
7657 if (buf && i == ent)
7658 return snprintf(buf, size, "%u", pf->id);
7666 /** Complete type field for RSS action. */
7668 comp_vc_action_rss_type(struct context *ctx, const struct token *token,
7669 unsigned int ent, char *buf, unsigned int size)
7675 for (i = 0; rss_type_table[i].str; ++i)
7680 return strlcpy(buf, rss_type_table[ent].str, size);
7682 return snprintf(buf, size, "end");
7686 /** Complete queue field for RSS action. */
7688 comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
7689 unsigned int ent, char *buf, unsigned int size)
7696 return snprintf(buf, size, "%u", ent);
7698 return snprintf(buf, size, "end");
7702 /** Complete index number for set raw_encap/raw_decap commands. */
7704 comp_set_raw_index(struct context *ctx, const struct token *token,
7705 unsigned int ent, char *buf, unsigned int size)
7711 RTE_SET_USED(token);
7712 for (idx = 0; idx < RAW_ENCAP_CONFS_MAX_NUM; ++idx) {
7713 if (buf && idx == ent)
7714 return snprintf(buf, size, "%u", idx);
7720 /** Complete index number for set raw_encap/raw_decap commands. */
7722 comp_set_sample_index(struct context *ctx, const struct token *token,
7723 unsigned int ent, char *buf, unsigned int size)
7729 RTE_SET_USED(token);
7730 for (idx = 0; idx < RAW_SAMPLE_CONFS_MAX_NUM; ++idx) {
7731 if (buf && idx == ent)
7732 return snprintf(buf, size, "%u", idx);
7738 /** Complete operation for modify_field command. */
7740 comp_set_modify_field_op(struct context *ctx, const struct token *token,
7741 unsigned int ent, char *buf, unsigned int size)
7746 RTE_SET_USED(token);
7747 for (idx = 0; modify_field_ops[idx]; ++idx)
7752 return strlcpy(buf, modify_field_ops[ent], size);
7756 /** Complete field id for modify_field command. */
7758 comp_set_modify_field_id(struct context *ctx, const struct token *token,
7759 unsigned int ent, char *buf, unsigned int size)
7764 RTE_SET_USED(token);
7765 for (idx = 0; modify_field_ids[idx]; ++idx)
7770 return strlcpy(buf, modify_field_ids[ent], size);
7774 /** Internal context. */
7775 static struct context cmd_flow_context;
7777 /** Global parser instance (cmdline API). */
7778 cmdline_parse_inst_t cmd_flow;
7779 cmdline_parse_inst_t cmd_set_raw;
7781 /** Initialize context. */
7783 cmd_flow_context_init(struct context *ctx)
7785 /* A full memset() is not necessary. */
7795 ctx->objmask = NULL;
7798 /** Parse a token (cmdline API). */
7800 cmd_flow_parse(cmdline_parse_token_hdr_t *hdr, const char *src, void *result,
7803 struct context *ctx = &cmd_flow_context;
7804 const struct token *token;
7805 const enum index *list;
7810 token = &token_list[ctx->curr];
7811 /* Check argument length. */
7814 for (len = 0; src[len]; ++len)
7815 if (src[len] == '#' || isspace(src[len]))
7819 /* Last argument and EOL detection. */
7820 for (i = len; src[i]; ++i)
7821 if (src[i] == '#' || src[i] == '\r' || src[i] == '\n')
7823 else if (!isspace(src[i])) {
7828 if (src[i] == '\r' || src[i] == '\n') {
7832 /* Initialize context if necessary. */
7833 if (!ctx->next_num) {
7836 ctx->next[ctx->next_num++] = token->next[0];
7838 /* Process argument through candidates. */
7839 ctx->prev = ctx->curr;
7840 list = ctx->next[ctx->next_num - 1];
7841 for (i = 0; list[i]; ++i) {
7842 const struct token *next = &token_list[list[i]];
7845 ctx->curr = list[i];
7847 tmp = next->call(ctx, next, src, len, result, size);
7849 tmp = parse_default(ctx, next, src, len, result, size);
7850 if (tmp == -1 || tmp != len)
7858 /* Push subsequent tokens if any. */
7860 for (i = 0; token->next[i]; ++i) {
7861 if (ctx->next_num == RTE_DIM(ctx->next))
7863 ctx->next[ctx->next_num++] = token->next[i];
7865 /* Push arguments if any. */
7867 for (i = 0; token->args[i]; ++i) {
7868 if (ctx->args_num == RTE_DIM(ctx->args))
7870 ctx->args[ctx->args_num++] = token->args[i];
7875 /** Return number of completion entries (cmdline API). */
7877 cmd_flow_complete_get_nb(cmdline_parse_token_hdr_t *hdr)
7879 struct context *ctx = &cmd_flow_context;
7880 const struct token *token = &token_list[ctx->curr];
7881 const enum index *list;
7885 /* Count number of tokens in current list. */
7887 list = ctx->next[ctx->next_num - 1];
7889 list = token->next[0];
7890 for (i = 0; list[i]; ++i)
7895 * If there is a single token, use its completion callback, otherwise
7896 * return the number of entries.
7898 token = &token_list[list[0]];
7899 if (i == 1 && token->comp) {
7900 /* Save index for cmd_flow_get_help(). */
7901 ctx->prev = list[0];
7902 return token->comp(ctx, token, 0, NULL, 0);
7907 /** Return a completion entry (cmdline API). */
7909 cmd_flow_complete_get_elt(cmdline_parse_token_hdr_t *hdr, int index,
7910 char *dst, unsigned int size)
7912 struct context *ctx = &cmd_flow_context;
7913 const struct token *token = &token_list[ctx->curr];
7914 const enum index *list;
7918 /* Count number of tokens in current list. */
7920 list = ctx->next[ctx->next_num - 1];
7922 list = token->next[0];
7923 for (i = 0; list[i]; ++i)
7927 /* If there is a single token, use its completion callback. */
7928 token = &token_list[list[0]];
7929 if (i == 1 && token->comp) {
7930 /* Save index for cmd_flow_get_help(). */
7931 ctx->prev = list[0];
7932 return token->comp(ctx, token, index, dst, size) < 0 ? -1 : 0;
7934 /* Otherwise make sure the index is valid and use defaults. */
7937 token = &token_list[list[index]];
7938 strlcpy(dst, token->name, size);
7939 /* Save index for cmd_flow_get_help(). */
7940 ctx->prev = list[index];
7944 /** Populate help strings for current token (cmdline API). */
7946 cmd_flow_get_help(cmdline_parse_token_hdr_t *hdr, char *dst, unsigned int size)
7948 struct context *ctx = &cmd_flow_context;
7949 const struct token *token = &token_list[ctx->prev];
7954 /* Set token type and update global help with details. */
7955 strlcpy(dst, (token->type ? token->type : "TOKEN"), size);
7957 cmd_flow.help_str = token->help;
7959 cmd_flow.help_str = token->name;
7963 /** Token definition template (cmdline API). */
7964 static struct cmdline_token_hdr cmd_flow_token_hdr = {
7965 .ops = &(struct cmdline_token_ops){
7966 .parse = cmd_flow_parse,
7967 .complete_get_nb = cmd_flow_complete_get_nb,
7968 .complete_get_elt = cmd_flow_complete_get_elt,
7969 .get_help = cmd_flow_get_help,
7974 /** Populate the next dynamic token. */
7976 cmd_flow_tok(cmdline_parse_token_hdr_t **hdr,
7977 cmdline_parse_token_hdr_t **hdr_inst)
7979 struct context *ctx = &cmd_flow_context;
7981 /* Always reinitialize context before requesting the first token. */
7982 if (!(hdr_inst - cmd_flow.tokens))
7983 cmd_flow_context_init(ctx);
7984 /* Return NULL when no more tokens are expected. */
7985 if (!ctx->next_num && ctx->curr) {
7989 /* Determine if command should end here. */
7990 if (ctx->eol && ctx->last && ctx->next_num) {
7991 const enum index *list = ctx->next[ctx->next_num - 1];
7994 for (i = 0; list[i]; ++i) {
8001 *hdr = &cmd_flow_token_hdr;
8004 /** Dispatch parsed buffer to function calls. */
8006 cmd_flow_parsed(const struct buffer *in)
8008 switch (in->command) {
8009 case INDIRECT_ACTION_CREATE:
8010 port_action_handle_create(
8011 in->port, in->args.vc.attr.group,
8012 &((const struct rte_flow_indir_action_conf) {
8013 .ingress = in->args.vc.attr.ingress,
8014 .egress = in->args.vc.attr.egress,
8015 .transfer = in->args.vc.attr.transfer,
8017 in->args.vc.actions);
8019 case INDIRECT_ACTION_DESTROY:
8020 port_action_handle_destroy(in->port,
8021 in->args.ia_destroy.action_id_n,
8022 in->args.ia_destroy.action_id);
8024 case INDIRECT_ACTION_UPDATE:
8025 port_action_handle_update(in->port, in->args.vc.attr.group,
8026 in->args.vc.actions);
8028 case INDIRECT_ACTION_QUERY:
8029 port_action_handle_query(in->port, in->args.ia.action_id);
8032 port_flow_validate(in->port, &in->args.vc.attr,
8033 in->args.vc.pattern, in->args.vc.actions,
8034 &in->args.vc.tunnel_ops);
8037 port_flow_create(in->port, &in->args.vc.attr,
8038 in->args.vc.pattern, in->args.vc.actions,
8039 &in->args.vc.tunnel_ops);
8042 port_flow_destroy(in->port, in->args.destroy.rule_n,
8043 in->args.destroy.rule);
8046 port_flow_flush(in->port);
8050 port_flow_dump(in->port, in->args.dump.mode,
8051 in->args.dump.rule, in->args.dump.file);
8054 port_flow_query(in->port, in->args.query.rule,
8055 &in->args.query.action);
8058 port_flow_list(in->port, in->args.list.group_n,
8059 in->args.list.group);
8062 port_flow_isolate(in->port, in->args.isolate.set);
8065 port_flow_aged(in->port, in->args.aged.destroy);
8068 port_flow_tunnel_create(in->port, &in->args.vc.tunnel_ops);
8070 case TUNNEL_DESTROY:
8071 port_flow_tunnel_destroy(in->port, in->args.vc.tunnel_ops.id);
8074 port_flow_tunnel_list(in->port);
8077 port_meter_policy_add(in->port, in->args.policy.policy_id,
8078 in->args.vc.actions);
8085 /** Token generator and output processing callback (cmdline API). */
8087 cmd_flow_cb(void *arg0, struct cmdline *cl, void *arg2)
8090 cmd_flow_tok(arg0, arg2);
8092 cmd_flow_parsed(arg0);
8095 /** Global parser instance (cmdline API). */
8096 cmdline_parse_inst_t cmd_flow = {
8098 .data = NULL, /**< Unused. */
8099 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
8102 }, /**< Tokens are returned by cmd_flow_tok(). */
8105 /** set cmd facility. Reuse cmd flow's infrastructure as much as possible. */
8108 update_fields(uint8_t *buf, struct rte_flow_item *item, uint16_t next_proto)
8110 struct rte_ipv4_hdr *ipv4;
8111 struct rte_ether_hdr *eth;
8112 struct rte_ipv6_hdr *ipv6;
8113 struct rte_vxlan_hdr *vxlan;
8114 struct rte_vxlan_gpe_hdr *gpe;
8115 struct rte_flow_item_nvgre *nvgre;
8116 uint32_t ipv6_vtc_flow;
8118 switch (item->type) {
8119 case RTE_FLOW_ITEM_TYPE_ETH:
8120 eth = (struct rte_ether_hdr *)buf;
8122 eth->ether_type = rte_cpu_to_be_16(next_proto);
8124 case RTE_FLOW_ITEM_TYPE_IPV4:
8125 ipv4 = (struct rte_ipv4_hdr *)buf;
8126 ipv4->version_ihl = 0x45;
8127 if (next_proto && ipv4->next_proto_id == 0)
8128 ipv4->next_proto_id = (uint8_t)next_proto;
8130 case RTE_FLOW_ITEM_TYPE_IPV6:
8131 ipv6 = (struct rte_ipv6_hdr *)buf;
8132 if (next_proto && ipv6->proto == 0)
8133 ipv6->proto = (uint8_t)next_proto;
8134 ipv6_vtc_flow = rte_be_to_cpu_32(ipv6->vtc_flow);
8135 ipv6_vtc_flow &= 0x0FFFFFFF; /*< reset version bits. */
8136 ipv6_vtc_flow |= 0x60000000; /*< set ipv6 version. */
8137 ipv6->vtc_flow = rte_cpu_to_be_32(ipv6_vtc_flow);
8139 case RTE_FLOW_ITEM_TYPE_VXLAN:
8140 vxlan = (struct rte_vxlan_hdr *)buf;
8141 vxlan->vx_flags = 0x08;
8143 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
8144 gpe = (struct rte_vxlan_gpe_hdr *)buf;
8145 gpe->vx_flags = 0x0C;
8147 case RTE_FLOW_ITEM_TYPE_NVGRE:
8148 nvgre = (struct rte_flow_item_nvgre *)buf;
8149 nvgre->protocol = rte_cpu_to_be_16(0x6558);
8150 nvgre->c_k_s_rsvd0_ver = rte_cpu_to_be_16(0x2000);
8157 /** Helper of get item's default mask. */
8159 flow_item_default_mask(const struct rte_flow_item *item)
8161 const void *mask = NULL;
8162 static rte_be32_t gre_key_default_mask = RTE_BE32(UINT32_MAX);
8164 switch (item->type) {
8165 case RTE_FLOW_ITEM_TYPE_ANY:
8166 mask = &rte_flow_item_any_mask;
8168 case RTE_FLOW_ITEM_TYPE_VF:
8169 mask = &rte_flow_item_vf_mask;
8171 case RTE_FLOW_ITEM_TYPE_PORT_ID:
8172 mask = &rte_flow_item_port_id_mask;
8174 case RTE_FLOW_ITEM_TYPE_RAW:
8175 mask = &rte_flow_item_raw_mask;
8177 case RTE_FLOW_ITEM_TYPE_ETH:
8178 mask = &rte_flow_item_eth_mask;
8180 case RTE_FLOW_ITEM_TYPE_VLAN:
8181 mask = &rte_flow_item_vlan_mask;
8183 case RTE_FLOW_ITEM_TYPE_IPV4:
8184 mask = &rte_flow_item_ipv4_mask;
8186 case RTE_FLOW_ITEM_TYPE_IPV6:
8187 mask = &rte_flow_item_ipv6_mask;
8189 case RTE_FLOW_ITEM_TYPE_ICMP:
8190 mask = &rte_flow_item_icmp_mask;
8192 case RTE_FLOW_ITEM_TYPE_UDP:
8193 mask = &rte_flow_item_udp_mask;
8195 case RTE_FLOW_ITEM_TYPE_TCP:
8196 mask = &rte_flow_item_tcp_mask;
8198 case RTE_FLOW_ITEM_TYPE_SCTP:
8199 mask = &rte_flow_item_sctp_mask;
8201 case RTE_FLOW_ITEM_TYPE_VXLAN:
8202 mask = &rte_flow_item_vxlan_mask;
8204 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
8205 mask = &rte_flow_item_vxlan_gpe_mask;
8207 case RTE_FLOW_ITEM_TYPE_E_TAG:
8208 mask = &rte_flow_item_e_tag_mask;
8210 case RTE_FLOW_ITEM_TYPE_NVGRE:
8211 mask = &rte_flow_item_nvgre_mask;
8213 case RTE_FLOW_ITEM_TYPE_MPLS:
8214 mask = &rte_flow_item_mpls_mask;
8216 case RTE_FLOW_ITEM_TYPE_GRE:
8217 mask = &rte_flow_item_gre_mask;
8219 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
8220 mask = &gre_key_default_mask;
8222 case RTE_FLOW_ITEM_TYPE_META:
8223 mask = &rte_flow_item_meta_mask;
8225 case RTE_FLOW_ITEM_TYPE_FUZZY:
8226 mask = &rte_flow_item_fuzzy_mask;
8228 case RTE_FLOW_ITEM_TYPE_GTP:
8229 mask = &rte_flow_item_gtp_mask;
8231 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
8232 mask = &rte_flow_item_gtp_psc_mask;
8234 case RTE_FLOW_ITEM_TYPE_GENEVE:
8235 mask = &rte_flow_item_geneve_mask;
8237 case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
8238 mask = &rte_flow_item_geneve_opt_mask;
8240 case RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID:
8241 mask = &rte_flow_item_pppoe_proto_id_mask;
8243 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
8244 mask = &rte_flow_item_l2tpv3oip_mask;
8246 case RTE_FLOW_ITEM_TYPE_ESP:
8247 mask = &rte_flow_item_esp_mask;
8249 case RTE_FLOW_ITEM_TYPE_AH:
8250 mask = &rte_flow_item_ah_mask;
8252 case RTE_FLOW_ITEM_TYPE_PFCP:
8253 mask = &rte_flow_item_pfcp_mask;
8261 /** Dispatch parsed buffer to function calls. */
8263 cmd_set_raw_parsed_sample(const struct buffer *in)
8265 uint32_t n = in->args.vc.actions_n;
8267 struct rte_flow_action *action = NULL;
8268 struct rte_flow_action *data = NULL;
8269 const struct rte_flow_action_rss *rss = NULL;
8271 uint16_t idx = in->port; /* We borrow port field as index */
8272 uint32_t max_size = sizeof(struct rte_flow_action) *
8273 ACTION_SAMPLE_ACTIONS_NUM;
8275 RTE_ASSERT(in->command == SET_SAMPLE_ACTIONS);
8276 data = (struct rte_flow_action *)&raw_sample_confs[idx].data;
8277 memset(data, 0x00, max_size);
8278 for (; i <= n - 1; i++) {
8279 action = in->args.vc.actions + i;
8280 if (action->type == RTE_FLOW_ACTION_TYPE_END)
8282 switch (action->type) {
8283 case RTE_FLOW_ACTION_TYPE_MARK:
8284 size = sizeof(struct rte_flow_action_mark);
8285 rte_memcpy(&sample_mark[idx],
8286 (const void *)action->conf, size);
8287 action->conf = &sample_mark[idx];
8289 case RTE_FLOW_ACTION_TYPE_COUNT:
8290 size = sizeof(struct rte_flow_action_count);
8291 rte_memcpy(&sample_count[idx],
8292 (const void *)action->conf, size);
8293 action->conf = &sample_count[idx];
8295 case RTE_FLOW_ACTION_TYPE_QUEUE:
8296 size = sizeof(struct rte_flow_action_queue);
8297 rte_memcpy(&sample_queue[idx],
8298 (const void *)action->conf, size);
8299 action->conf = &sample_queue[idx];
8301 case RTE_FLOW_ACTION_TYPE_RSS:
8302 size = sizeof(struct rte_flow_action_rss);
8304 rte_memcpy(&sample_rss_data[idx].conf,
8305 (const void *)rss, size);
8306 if (rss->key_len && rss->key) {
8307 sample_rss_data[idx].conf.key =
8308 sample_rss_data[idx].key;
8309 rte_memcpy((void *)((uintptr_t)
8310 sample_rss_data[idx].conf.key),
8311 (const void *)rss->key,
8312 sizeof(uint8_t) * rss->key_len);
8314 if (rss->queue_num && rss->queue) {
8315 sample_rss_data[idx].conf.queue =
8316 sample_rss_data[idx].queue;
8317 rte_memcpy((void *)((uintptr_t)
8318 sample_rss_data[idx].conf.queue),
8319 (const void *)rss->queue,
8320 sizeof(uint16_t) * rss->queue_num);
8322 action->conf = &sample_rss_data[idx].conf;
8324 case RTE_FLOW_ACTION_TYPE_RAW_ENCAP:
8325 size = sizeof(struct rte_flow_action_raw_encap);
8326 rte_memcpy(&sample_encap[idx],
8327 (const void *)action->conf, size);
8328 action->conf = &sample_encap[idx];
8330 case RTE_FLOW_ACTION_TYPE_PORT_ID:
8331 size = sizeof(struct rte_flow_action_port_id);
8332 rte_memcpy(&sample_port_id[idx],
8333 (const void *)action->conf, size);
8334 action->conf = &sample_port_id[idx];
8336 case RTE_FLOW_ACTION_TYPE_PF:
8338 case RTE_FLOW_ACTION_TYPE_VF:
8339 size = sizeof(struct rte_flow_action_vf);
8340 rte_memcpy(&sample_vf[idx],
8341 (const void *)action->conf, size);
8342 action->conf = &sample_vf[idx];
8344 case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP:
8345 size = sizeof(struct rte_flow_action_vxlan_encap);
8346 parse_setup_vxlan_encap_data(&sample_vxlan_encap[idx]);
8347 action->conf = &sample_vxlan_encap[idx].conf;
8349 case RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP:
8350 size = sizeof(struct rte_flow_action_nvgre_encap);
8351 parse_setup_nvgre_encap_data(&sample_nvgre_encap[idx]);
8352 action->conf = &sample_nvgre_encap[idx];
8355 printf("Error - Not supported action\n");
8358 rte_memcpy(data, action, sizeof(struct rte_flow_action));
8363 /** Dispatch parsed buffer to function calls. */
8365 cmd_set_raw_parsed(const struct buffer *in)
8367 uint32_t n = in->args.vc.pattern_n;
8369 struct rte_flow_item *item = NULL;
8371 uint8_t *data = NULL;
8372 uint8_t *data_tail = NULL;
8373 size_t *total_size = NULL;
8374 uint16_t upper_layer = 0;
8376 uint16_t idx = in->port; /* We borrow port field as index */
8377 int gtp_psc = -1; /* GTP PSC option index. */
8379 if (in->command == SET_SAMPLE_ACTIONS)
8380 return cmd_set_raw_parsed_sample(in);
8381 RTE_ASSERT(in->command == SET_RAW_ENCAP ||
8382 in->command == SET_RAW_DECAP);
8383 if (in->command == SET_RAW_ENCAP) {
8384 total_size = &raw_encap_confs[idx].size;
8385 data = (uint8_t *)&raw_encap_confs[idx].data;
8387 total_size = &raw_decap_confs[idx].size;
8388 data = (uint8_t *)&raw_decap_confs[idx].data;
8391 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
8392 /* process hdr from upper layer to low layer (L3/L4 -> L2). */
8393 data_tail = data + ACTION_RAW_ENCAP_MAX_DATA;
8394 for (i = n - 1 ; i >= 0; --i) {
8395 const struct rte_flow_item_gtp *gtp;
8396 const struct rte_flow_item_geneve_opt *opt;
8398 item = in->args.vc.pattern + i;
8399 if (item->spec == NULL)
8400 item->spec = flow_item_default_mask(item);
8401 switch (item->type) {
8402 case RTE_FLOW_ITEM_TYPE_ETH:
8403 size = sizeof(struct rte_ether_hdr);
8405 case RTE_FLOW_ITEM_TYPE_VLAN:
8406 size = sizeof(struct rte_vlan_hdr);
8407 proto = RTE_ETHER_TYPE_VLAN;
8409 case RTE_FLOW_ITEM_TYPE_IPV4:
8410 size = sizeof(struct rte_ipv4_hdr);
8411 proto = RTE_ETHER_TYPE_IPV4;
8413 case RTE_FLOW_ITEM_TYPE_IPV6:
8414 size = sizeof(struct rte_ipv6_hdr);
8415 proto = RTE_ETHER_TYPE_IPV6;
8417 case RTE_FLOW_ITEM_TYPE_UDP:
8418 size = sizeof(struct rte_udp_hdr);
8421 case RTE_FLOW_ITEM_TYPE_TCP:
8422 size = sizeof(struct rte_tcp_hdr);
8425 case RTE_FLOW_ITEM_TYPE_VXLAN:
8426 size = sizeof(struct rte_vxlan_hdr);
8428 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
8429 size = sizeof(struct rte_vxlan_gpe_hdr);
8431 case RTE_FLOW_ITEM_TYPE_GRE:
8432 size = sizeof(struct rte_gre_hdr);
8435 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
8436 size = sizeof(rte_be32_t);
8439 case RTE_FLOW_ITEM_TYPE_MPLS:
8440 size = sizeof(struct rte_mpls_hdr);
8443 case RTE_FLOW_ITEM_TYPE_NVGRE:
8444 size = sizeof(struct rte_flow_item_nvgre);
8447 case RTE_FLOW_ITEM_TYPE_GENEVE:
8448 size = sizeof(struct rte_geneve_hdr);
8450 case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
8451 opt = (const struct rte_flow_item_geneve_opt *)
8453 size = offsetof(struct rte_flow_item_geneve_opt, data);
8454 if (opt->option_len && opt->data) {
8455 *total_size += opt->option_len *
8457 rte_memcpy(data_tail - (*total_size),
8459 opt->option_len * sizeof(uint32_t));
8462 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
8463 size = sizeof(rte_be32_t);
8466 case RTE_FLOW_ITEM_TYPE_ESP:
8467 size = sizeof(struct rte_esp_hdr);
8470 case RTE_FLOW_ITEM_TYPE_AH:
8471 size = sizeof(struct rte_flow_item_ah);
8474 case RTE_FLOW_ITEM_TYPE_GTP:
8476 size = sizeof(struct rte_gtp_hdr);
8479 if (gtp_psc != i + 1) {
8480 printf("Error - GTP PSC does not follow GTP\n");
8484 if ((gtp->v_pt_rsv_flags & 0x07) != 0x04) {
8485 /* Only E flag should be set. */
8486 printf("Error - GTP unsupported flags\n");
8489 struct rte_gtp_hdr_ext_word ext_word = {
8493 /* We have to add GTP header extra word. */
8494 *total_size += sizeof(ext_word);
8495 rte_memcpy(data_tail - (*total_size),
8496 &ext_word, sizeof(ext_word));
8498 size = sizeof(struct rte_gtp_hdr);
8500 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
8502 printf("Error - Multiple GTP PSC items\n");
8505 const struct rte_flow_item_gtp_psc
8514 if (opt->pdu_type & 0x0F) {
8515 /* Support the minimal option only. */
8516 printf("Error - GTP PSC option with "
8517 "extra fields not supported\n");
8520 psc.len = sizeof(psc);
8521 psc.pdu_type = opt->pdu_type;
8524 *total_size += sizeof(psc);
8525 rte_memcpy(data_tail - (*total_size),
8531 case RTE_FLOW_ITEM_TYPE_PFCP:
8532 size = sizeof(struct rte_flow_item_pfcp);
8535 printf("Error - Not supported item\n");
8538 *total_size += size;
8539 rte_memcpy(data_tail - (*total_size), item->spec, size);
8540 /* update some fields which cannot be set by cmdline */
8541 update_fields((data_tail - (*total_size)), item,
8543 upper_layer = proto;
8545 if (verbose_level & 0x1)
8546 printf("total data size is %zu\n", (*total_size));
8547 RTE_ASSERT((*total_size) <= ACTION_RAW_ENCAP_MAX_DATA);
8548 memmove(data, (data_tail - (*total_size)), *total_size);
8553 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
8556 /** Populate help strings for current token (cmdline API). */
8558 cmd_set_raw_get_help(cmdline_parse_token_hdr_t *hdr, char *dst,
8561 struct context *ctx = &cmd_flow_context;
8562 const struct token *token = &token_list[ctx->prev];
8567 /* Set token type and update global help with details. */
8568 snprintf(dst, size, "%s", (token->type ? token->type : "TOKEN"));
8570 cmd_set_raw.help_str = token->help;
8572 cmd_set_raw.help_str = token->name;
8576 /** Token definition template (cmdline API). */
8577 static struct cmdline_token_hdr cmd_set_raw_token_hdr = {
8578 .ops = &(struct cmdline_token_ops){
8579 .parse = cmd_flow_parse,
8580 .complete_get_nb = cmd_flow_complete_get_nb,
8581 .complete_get_elt = cmd_flow_complete_get_elt,
8582 .get_help = cmd_set_raw_get_help,
8587 /** Populate the next dynamic token. */
8589 cmd_set_raw_tok(cmdline_parse_token_hdr_t **hdr,
8590 cmdline_parse_token_hdr_t **hdr_inst)
8592 struct context *ctx = &cmd_flow_context;
8594 /* Always reinitialize context before requesting the first token. */
8595 if (!(hdr_inst - cmd_set_raw.tokens)) {
8596 cmd_flow_context_init(ctx);
8597 ctx->curr = START_SET;
8599 /* Return NULL when no more tokens are expected. */
8600 if (!ctx->next_num && (ctx->curr != START_SET)) {
8604 /* Determine if command should end here. */
8605 if (ctx->eol && ctx->last && ctx->next_num) {
8606 const enum index *list = ctx->next[ctx->next_num - 1];
8609 for (i = 0; list[i]; ++i) {
8616 *hdr = &cmd_set_raw_token_hdr;
8619 /** Token generator and output processing callback (cmdline API). */
8621 cmd_set_raw_cb(void *arg0, struct cmdline *cl, void *arg2)
8624 cmd_set_raw_tok(arg0, arg2);
8626 cmd_set_raw_parsed(arg0);
8629 /** Global parser instance (cmdline API). */
8630 cmdline_parse_inst_t cmd_set_raw = {
8631 .f = cmd_set_raw_cb,
8632 .data = NULL, /**< Unused. */
8633 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
8636 }, /**< Tokens are returned by cmd_flow_tok(). */
8639 /* *** display raw_encap/raw_decap buf */
8640 struct cmd_show_set_raw_result {
8641 cmdline_fixed_string_t cmd_show;
8642 cmdline_fixed_string_t cmd_what;
8643 cmdline_fixed_string_t cmd_all;
8648 cmd_show_set_raw_parsed(void *parsed_result, struct cmdline *cl, void *data)
8650 struct cmd_show_set_raw_result *res = parsed_result;
8651 uint16_t index = res->cmd_index;
8653 uint8_t *raw_data = NULL;
8654 size_t raw_size = 0;
8655 char title[16] = {0};
8659 if (!strcmp(res->cmd_all, "all")) {
8662 } else if (index >= RAW_ENCAP_CONFS_MAX_NUM) {
8663 printf("index should be 0-%u\n", RAW_ENCAP_CONFS_MAX_NUM - 1);
8667 if (!strcmp(res->cmd_what, "raw_encap")) {
8668 raw_data = (uint8_t *)&raw_encap_confs[index].data;
8669 raw_size = raw_encap_confs[index].size;
8670 snprintf(title, 16, "\nindex: %u", index);
8671 rte_hexdump(stdout, title, raw_data, raw_size);
8673 raw_data = (uint8_t *)&raw_decap_confs[index].data;
8674 raw_size = raw_decap_confs[index].size;
8675 snprintf(title, 16, "\nindex: %u", index);
8676 rte_hexdump(stdout, title, raw_data, raw_size);
8678 } while (all && ++index < RAW_ENCAP_CONFS_MAX_NUM);
8681 cmdline_parse_token_string_t cmd_show_set_raw_cmd_show =
8682 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
8684 cmdline_parse_token_string_t cmd_show_set_raw_cmd_what =
8685 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
8686 cmd_what, "raw_encap#raw_decap");
8687 cmdline_parse_token_num_t cmd_show_set_raw_cmd_index =
8688 TOKEN_NUM_INITIALIZER(struct cmd_show_set_raw_result,
8689 cmd_index, RTE_UINT16);
8690 cmdline_parse_token_string_t cmd_show_set_raw_cmd_all =
8691 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
8693 cmdline_parse_inst_t cmd_show_set_raw = {
8694 .f = cmd_show_set_raw_parsed,
8696 .help_str = "show <raw_encap|raw_decap> <index>",
8698 (void *)&cmd_show_set_raw_cmd_show,
8699 (void *)&cmd_show_set_raw_cmd_what,
8700 (void *)&cmd_show_set_raw_cmd_index,
8704 cmdline_parse_inst_t cmd_show_set_raw_all = {
8705 .f = cmd_show_set_raw_parsed,
8707 .help_str = "show <raw_encap|raw_decap> all",
8709 (void *)&cmd_show_set_raw_cmd_show,
8710 (void *)&cmd_show_set_raw_cmd_what,
8711 (void *)&cmd_show_set_raw_cmd_all,