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. */
56 COMMON_PRIORITY_LEVEL,
57 COMMON_INDIRECT_ACTION_ID,
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. */
1930 [COMMON_INTEGER] = {
1933 .help = "integer value",
1937 [COMMON_UNSIGNED] = {
1938 .name = "{unsigned}",
1940 .help = "unsigned integer value",
1947 .help = "prefix length for bit-mask",
1948 .call = parse_prefix,
1951 [COMMON_BOOLEAN] = {
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",
1971 [COMMON_FILE_PATH] = {
1972 .name = "{file path}",
1974 .help = "file path",
1975 .call = parse_string0,
1978 [COMMON_MAC_ADDR] = {
1979 .name = "{MAC address}",
1981 .help = "standard MAC address notation",
1982 .call = parse_mac_addr,
1985 [COMMON_IPV4_ADDR] = {
1986 .name = "{IPv4 address}",
1987 .type = "IPV4 ADDRESS",
1988 .help = "standard IPv4 address notation",
1989 .call = parse_ipv4_addr,
1992 [COMMON_IPV6_ADDR] = {
1993 .name = "{IPv6 address}",
1994 .type = "IPV6 ADDRESS",
1995 .help = "standard IPv6 address notation",
1996 .call = parse_ipv6_addr,
1999 [COMMON_RULE_ID] = {
2000 .name = "{rule id}",
2002 .help = "rule identifier",
2004 .comp = comp_rule_id,
2006 [COMMON_PORT_ID] = {
2007 .name = "{port_id}",
2009 .help = "port identifier",
2013 [COMMON_GROUP_ID] = {
2014 .name = "{group_id}",
2016 .help = "group identifier",
2020 [COMMON_PRIORITY_LEVEL] = {
2023 .help = "priority level",
2027 [COMMON_INDIRECT_ACTION_ID] = {
2028 .name = "{indirect_action_id}",
2029 .type = "INDIRECT_ACTION_ID",
2030 .help = "indirect action id",
2034 [COMMON_POLICY_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(COMMON_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(COMMON_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),
2095 NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
2096 .args = ARGS(ARGS_ENTRY(struct buffer, args.ia.action_id)),
2101 .help = "check whether a flow rule can be created",
2102 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_PORT_ID)),
2103 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2108 .help = "create a flow rule",
2109 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_PORT_ID)),
2110 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2115 .help = "destroy specific flow rules",
2116 .next = NEXT(NEXT_ENTRY(DESTROY_RULE),
2117 NEXT_ENTRY(COMMON_PORT_ID)),
2118 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2119 .call = parse_destroy,
2123 .help = "destroy all flow rules",
2124 .next = NEXT(NEXT_ENTRY(COMMON_PORT_ID)),
2125 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2126 .call = parse_flush,
2130 .help = "dump single/all flow rules to file",
2131 .next = NEXT(next_dump_subcmd, NEXT_ENTRY(COMMON_PORT_ID)),
2132 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2137 .help = "query an existing flow rule",
2138 .next = NEXT(NEXT_ENTRY(QUERY_ACTION),
2139 NEXT_ENTRY(COMMON_RULE_ID),
2140 NEXT_ENTRY(COMMON_PORT_ID)),
2141 .args = ARGS(ARGS_ENTRY(struct buffer, args.query.action.type),
2142 ARGS_ENTRY(struct buffer, args.query.rule),
2143 ARGS_ENTRY(struct buffer, port)),
2144 .call = parse_query,
2148 .help = "list existing flow rules",
2149 .next = NEXT(next_list_attr, NEXT_ENTRY(COMMON_PORT_ID)),
2150 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2155 .help = "list and destroy aged flows",
2156 .next = NEXT(next_aged_attr, NEXT_ENTRY(COMMON_PORT_ID)),
2157 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2162 .help = "restrict ingress traffic to the defined flow rules",
2163 .next = NEXT(NEXT_ENTRY(COMMON_BOOLEAN),
2164 NEXT_ENTRY(COMMON_PORT_ID)),
2165 .args = ARGS(ARGS_ENTRY(struct buffer, args.isolate.set),
2166 ARGS_ENTRY(struct buffer, port)),
2167 .call = parse_isolate,
2171 .help = "new tunnel API",
2172 .next = NEXT(NEXT_ENTRY
2173 (TUNNEL_CREATE, TUNNEL_LIST, TUNNEL_DESTROY)),
2174 .call = parse_tunnel,
2176 /* Tunnel arguments. */
2179 .help = "create new tunnel object",
2180 .next = NEXT(NEXT_ENTRY(TUNNEL_CREATE_TYPE),
2181 NEXT_ENTRY(COMMON_PORT_ID)),
2182 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2183 .call = parse_tunnel,
2185 [TUNNEL_CREATE_TYPE] = {
2187 .help = "create new tunnel",
2188 .next = NEXT(NEXT_ENTRY(COMMON_FILE_PATH)),
2189 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, type)),
2190 .call = parse_tunnel,
2192 [TUNNEL_DESTROY] = {
2194 .help = "destroy tunel",
2195 .next = NEXT(NEXT_ENTRY(TUNNEL_DESTROY_ID),
2196 NEXT_ENTRY(COMMON_PORT_ID)),
2197 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2198 .call = parse_tunnel,
2200 [TUNNEL_DESTROY_ID] = {
2202 .help = "tunnel identifier to testroy",
2203 .next = NEXT(NEXT_ENTRY(COMMON_UNSIGNED)),
2204 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2205 .call = parse_tunnel,
2209 .help = "list existing tunnels",
2210 .next = NEXT(NEXT_ENTRY(COMMON_PORT_ID)),
2211 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2212 .call = parse_tunnel,
2214 /* Destroy arguments. */
2217 .help = "specify a rule identifier",
2218 .next = NEXT(next_destroy_attr, NEXT_ENTRY(COMMON_RULE_ID)),
2219 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.destroy.rule)),
2220 .call = parse_destroy,
2222 /* Dump arguments. */
2226 .next = NEXT(next_dump_attr),
2227 .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file)),
2232 .help = "dump one rule",
2233 .next = NEXT(next_dump_attr, NEXT_ENTRY(COMMON_RULE_ID)),
2234 .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file),
2235 ARGS_ENTRY(struct buffer, args.dump.rule)),
2238 /* Query arguments. */
2242 .help = "action to query, must be part of the rule",
2243 .call = parse_action,
2244 .comp = comp_action,
2246 /* List arguments. */
2249 .help = "specify a group",
2250 .next = NEXT(next_list_attr, NEXT_ENTRY(COMMON_GROUP_ID)),
2251 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.list.group)),
2256 .help = "specify aged flows need be destroyed",
2260 /* Validate/create attributes. */
2263 .help = "specify a group",
2264 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_GROUP_ID)),
2265 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, group)),
2270 .help = "specify a priority level",
2271 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_PRIORITY_LEVEL)),
2272 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, priority)),
2277 .help = "affect rule to ingress",
2278 .next = NEXT(next_vc_attr),
2283 .help = "affect rule to egress",
2284 .next = NEXT(next_vc_attr),
2289 .help = "apply rule directly to endpoints found in pattern",
2290 .next = NEXT(next_vc_attr),
2294 .name = "tunnel_set",
2295 .help = "tunnel steer rule",
2296 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_UNSIGNED)),
2297 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2300 [VC_TUNNEL_MATCH] = {
2301 .name = "tunnel_match",
2302 .help = "tunnel match rule",
2303 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_UNSIGNED)),
2304 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2307 /* Validate/create pattern. */
2310 .help = "submit a list of pattern items",
2311 .next = NEXT(next_item),
2316 .help = "match value perfectly (with full bit-mask)",
2317 .call = parse_vc_spec,
2319 [ITEM_PARAM_SPEC] = {
2321 .help = "match value according to configured bit-mask",
2322 .call = parse_vc_spec,
2324 [ITEM_PARAM_LAST] = {
2326 .help = "specify upper bound to establish a range",
2327 .call = parse_vc_spec,
2329 [ITEM_PARAM_MASK] = {
2331 .help = "specify bit-mask with relevant bits set to one",
2332 .call = parse_vc_spec,
2334 [ITEM_PARAM_PREFIX] = {
2336 .help = "generate bit-mask from a prefix length",
2337 .call = parse_vc_spec,
2341 .help = "specify next pattern item",
2342 .next = NEXT(next_item),
2346 .help = "end list of pattern items",
2347 .priv = PRIV_ITEM(END, 0),
2348 .next = NEXT(NEXT_ENTRY(ACTIONS)),
2353 .help = "no-op pattern item",
2354 .priv = PRIV_ITEM(VOID, 0),
2355 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2360 .help = "perform actions when pattern does not match",
2361 .priv = PRIV_ITEM(INVERT, 0),
2362 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2367 .help = "match any protocol for the current layer",
2368 .priv = PRIV_ITEM(ANY, sizeof(struct rte_flow_item_any)),
2369 .next = NEXT(item_any),
2374 .help = "number of layers covered",
2375 .next = NEXT(item_any, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2376 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_any, num)),
2380 .help = "match traffic from/to the physical function",
2381 .priv = PRIV_ITEM(PF, 0),
2382 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2387 .help = "match traffic from/to a virtual function ID",
2388 .priv = PRIV_ITEM(VF, sizeof(struct rte_flow_item_vf)),
2389 .next = NEXT(item_vf),
2395 .next = NEXT(item_vf, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2396 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_vf, id)),
2400 .help = "match traffic from/to a specific physical port",
2401 .priv = PRIV_ITEM(PHY_PORT,
2402 sizeof(struct rte_flow_item_phy_port)),
2403 .next = NEXT(item_phy_port),
2406 [ITEM_PHY_PORT_INDEX] = {
2408 .help = "physical port index",
2409 .next = NEXT(item_phy_port, NEXT_ENTRY(COMMON_UNSIGNED),
2411 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_phy_port, index)),
2415 .help = "match traffic from/to a given DPDK port ID",
2416 .priv = PRIV_ITEM(PORT_ID,
2417 sizeof(struct rte_flow_item_port_id)),
2418 .next = NEXT(item_port_id),
2421 [ITEM_PORT_ID_ID] = {
2423 .help = "DPDK port ID",
2424 .next = NEXT(item_port_id, NEXT_ENTRY(COMMON_UNSIGNED),
2426 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port_id, id)),
2430 .help = "match traffic against value set in previously matched rule",
2431 .priv = PRIV_ITEM(MARK, sizeof(struct rte_flow_item_mark)),
2432 .next = NEXT(item_mark),
2437 .help = "Integer value to match against",
2438 .next = NEXT(item_mark, NEXT_ENTRY(COMMON_UNSIGNED),
2440 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_mark, id)),
2444 .help = "match an arbitrary byte string",
2445 .priv = PRIV_ITEM(RAW, ITEM_RAW_SIZE),
2446 .next = NEXT(item_raw),
2449 [ITEM_RAW_RELATIVE] = {
2451 .help = "look for pattern after the previous item",
2452 .next = NEXT(item_raw, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
2453 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
2456 [ITEM_RAW_SEARCH] = {
2458 .help = "search pattern from offset (see also limit)",
2459 .next = NEXT(item_raw, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
2460 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
2463 [ITEM_RAW_OFFSET] = {
2465 .help = "absolute or relative offset for pattern",
2466 .next = NEXT(item_raw, NEXT_ENTRY(COMMON_INTEGER), item_param),
2467 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, offset)),
2469 [ITEM_RAW_LIMIT] = {
2471 .help = "search area limit for start of pattern",
2472 .next = NEXT(item_raw, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2473 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, limit)),
2475 [ITEM_RAW_PATTERN] = {
2477 .help = "byte string to look for",
2478 .next = NEXT(item_raw,
2479 NEXT_ENTRY(COMMON_STRING),
2480 NEXT_ENTRY(ITEM_PARAM_IS,
2483 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern),
2484 ARGS_ENTRY(struct rte_flow_item_raw, length),
2485 ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw),
2486 ITEM_RAW_PATTERN_SIZE)),
2490 .help = "match Ethernet header",
2491 .priv = PRIV_ITEM(ETH, sizeof(struct rte_flow_item_eth)),
2492 .next = NEXT(item_eth),
2497 .help = "destination MAC",
2498 .next = NEXT(item_eth, NEXT_ENTRY(COMMON_MAC_ADDR), item_param),
2499 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, dst)),
2503 .help = "source MAC",
2504 .next = NEXT(item_eth, NEXT_ENTRY(COMMON_MAC_ADDR), item_param),
2505 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, src)),
2509 .help = "EtherType",
2510 .next = NEXT(item_eth, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2511 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, type)),
2513 [ITEM_ETH_HAS_VLAN] = {
2515 .help = "packet header contains VLAN",
2516 .next = NEXT(item_eth, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2517 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_eth,
2522 .help = "match 802.1Q/ad VLAN tag",
2523 .priv = PRIV_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)),
2524 .next = NEXT(item_vlan),
2529 .help = "tag control information",
2530 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
2532 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, tci)),
2536 .help = "priority code point",
2537 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
2539 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2544 .help = "drop eligible indicator",
2545 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
2547 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2552 .help = "VLAN identifier",
2553 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
2555 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2558 [ITEM_VLAN_INNER_TYPE] = {
2559 .name = "inner_type",
2560 .help = "inner EtherType",
2561 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
2563 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan,
2566 [ITEM_VLAN_HAS_MORE_VLAN] = {
2567 .name = "has_more_vlan",
2568 .help = "packet header contains another VLAN",
2569 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
2571 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vlan,
2576 .help = "match IPv4 header",
2577 .priv = PRIV_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)),
2578 .next = NEXT(item_ipv4),
2583 .help = "type of service",
2584 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
2586 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2587 hdr.type_of_service)),
2590 .name = "packet_id",
2591 .help = "fragment packet id",
2592 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
2594 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2597 [ITEM_IPV4_FRAGMENT_OFFSET] = {
2598 .name = "fragment_offset",
2599 .help = "fragmentation flags and fragment offset",
2600 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
2602 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2603 hdr.fragment_offset)),
2607 .help = "time to live",
2608 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
2610 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2613 [ITEM_IPV4_PROTO] = {
2615 .help = "next protocol ID",
2616 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
2618 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2619 hdr.next_proto_id)),
2623 .help = "source address",
2624 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
2626 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2631 .help = "destination address",
2632 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
2634 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2639 .help = "match IPv6 header",
2640 .priv = PRIV_ITEM(IPV6, sizeof(struct rte_flow_item_ipv6)),
2641 .next = NEXT(item_ipv6),
2646 .help = "traffic class",
2647 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
2649 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2651 "\x0f\xf0\x00\x00")),
2653 [ITEM_IPV6_FLOW] = {
2655 .help = "flow label",
2656 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
2658 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2660 "\x00\x0f\xff\xff")),
2662 [ITEM_IPV6_PROTO] = {
2664 .help = "protocol (next header)",
2665 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
2667 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2672 .help = "hop limit",
2673 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
2675 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2680 .help = "source address",
2681 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_IPV6_ADDR),
2683 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2688 .help = "destination address",
2689 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_IPV6_ADDR),
2691 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2694 [ITEM_IPV6_HAS_FRAG_EXT] = {
2695 .name = "has_frag_ext",
2696 .help = "fragment packet attribute",
2697 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
2699 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_ipv6,
2704 .help = "match ICMP header",
2705 .priv = PRIV_ITEM(ICMP, sizeof(struct rte_flow_item_icmp)),
2706 .next = NEXT(item_icmp),
2709 [ITEM_ICMP_TYPE] = {
2711 .help = "ICMP packet type",
2712 .next = NEXT(item_icmp, NEXT_ENTRY(COMMON_UNSIGNED),
2714 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2717 [ITEM_ICMP_CODE] = {
2719 .help = "ICMP packet code",
2720 .next = NEXT(item_icmp, NEXT_ENTRY(COMMON_UNSIGNED),
2722 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2725 [ITEM_ICMP_IDENT] = {
2727 .help = "ICMP packet identifier",
2728 .next = NEXT(item_icmp, NEXT_ENTRY(COMMON_UNSIGNED),
2730 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2735 .help = "ICMP packet sequence number",
2736 .next = NEXT(item_icmp, NEXT_ENTRY(COMMON_UNSIGNED),
2738 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2743 .help = "match UDP header",
2744 .priv = PRIV_ITEM(UDP, sizeof(struct rte_flow_item_udp)),
2745 .next = NEXT(item_udp),
2750 .help = "UDP source port",
2751 .next = NEXT(item_udp, NEXT_ENTRY(COMMON_UNSIGNED),
2753 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2758 .help = "UDP destination port",
2759 .next = NEXT(item_udp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2760 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2765 .help = "match TCP header",
2766 .priv = PRIV_ITEM(TCP, sizeof(struct rte_flow_item_tcp)),
2767 .next = NEXT(item_tcp),
2772 .help = "TCP source port",
2773 .next = NEXT(item_tcp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2774 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2779 .help = "TCP destination port",
2780 .next = NEXT(item_tcp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2781 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2784 [ITEM_TCP_FLAGS] = {
2786 .help = "TCP flags",
2787 .next = NEXT(item_tcp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2788 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2793 .help = "match SCTP header",
2794 .priv = PRIV_ITEM(SCTP, sizeof(struct rte_flow_item_sctp)),
2795 .next = NEXT(item_sctp),
2800 .help = "SCTP source port",
2801 .next = NEXT(item_sctp, NEXT_ENTRY(COMMON_UNSIGNED),
2803 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2808 .help = "SCTP destination port",
2809 .next = NEXT(item_sctp, NEXT_ENTRY(COMMON_UNSIGNED),
2811 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2816 .help = "validation tag",
2817 .next = NEXT(item_sctp, NEXT_ENTRY(COMMON_UNSIGNED),
2819 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2822 [ITEM_SCTP_CKSUM] = {
2825 .next = NEXT(item_sctp, NEXT_ENTRY(COMMON_UNSIGNED),
2827 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2832 .help = "match VXLAN header",
2833 .priv = PRIV_ITEM(VXLAN, sizeof(struct rte_flow_item_vxlan)),
2834 .next = NEXT(item_vxlan),
2837 [ITEM_VXLAN_VNI] = {
2839 .help = "VXLAN identifier",
2840 .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
2842 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan, vni)),
2846 .help = "match E-Tag header",
2847 .priv = PRIV_ITEM(E_TAG, sizeof(struct rte_flow_item_e_tag)),
2848 .next = NEXT(item_e_tag),
2851 [ITEM_E_TAG_GRP_ECID_B] = {
2852 .name = "grp_ecid_b",
2853 .help = "GRP and E-CID base",
2854 .next = NEXT(item_e_tag, NEXT_ENTRY(COMMON_UNSIGNED),
2856 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_e_tag,
2862 .help = "match NVGRE header",
2863 .priv = PRIV_ITEM(NVGRE, sizeof(struct rte_flow_item_nvgre)),
2864 .next = NEXT(item_nvgre),
2867 [ITEM_NVGRE_TNI] = {
2869 .help = "virtual subnet ID",
2870 .next = NEXT(item_nvgre, NEXT_ENTRY(COMMON_UNSIGNED),
2872 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_nvgre, tni)),
2876 .help = "match MPLS header",
2877 .priv = PRIV_ITEM(MPLS, sizeof(struct rte_flow_item_mpls)),
2878 .next = NEXT(item_mpls),
2881 [ITEM_MPLS_LABEL] = {
2883 .help = "MPLS label",
2884 .next = NEXT(item_mpls, NEXT_ENTRY(COMMON_UNSIGNED),
2886 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2892 .help = "MPLS Traffic Class",
2893 .next = NEXT(item_mpls, NEXT_ENTRY(COMMON_UNSIGNED),
2895 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2901 .help = "MPLS Bottom-of-Stack",
2902 .next = NEXT(item_mpls, NEXT_ENTRY(COMMON_UNSIGNED),
2904 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2910 .help = "match GRE header",
2911 .priv = PRIV_ITEM(GRE, sizeof(struct rte_flow_item_gre)),
2912 .next = NEXT(item_gre),
2915 [ITEM_GRE_PROTO] = {
2917 .help = "GRE protocol type",
2918 .next = NEXT(item_gre, NEXT_ENTRY(COMMON_UNSIGNED),
2920 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2923 [ITEM_GRE_C_RSVD0_VER] = {
2924 .name = "c_rsvd0_ver",
2926 "checksum (1b), undefined (1b), key bit (1b),"
2927 " sequence number (1b), reserved 0 (9b),"
2929 .next = NEXT(item_gre, NEXT_ENTRY(COMMON_UNSIGNED),
2931 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2934 [ITEM_GRE_C_BIT] = {
2936 .help = "checksum bit (C)",
2937 .next = NEXT(item_gre, NEXT_ENTRY(COMMON_BOOLEAN),
2939 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2941 "\x80\x00\x00\x00")),
2943 [ITEM_GRE_S_BIT] = {
2945 .help = "sequence number bit (S)",
2946 .next = NEXT(item_gre, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
2947 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2949 "\x10\x00\x00\x00")),
2951 [ITEM_GRE_K_BIT] = {
2953 .help = "key bit (K)",
2954 .next = NEXT(item_gre, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
2955 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2957 "\x20\x00\x00\x00")),
2961 .help = "fuzzy pattern match, expect faster than default",
2962 .priv = PRIV_ITEM(FUZZY,
2963 sizeof(struct rte_flow_item_fuzzy)),
2964 .next = NEXT(item_fuzzy),
2967 [ITEM_FUZZY_THRESH] = {
2969 .help = "match accuracy threshold",
2970 .next = NEXT(item_fuzzy, NEXT_ENTRY(COMMON_UNSIGNED),
2972 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_fuzzy,
2977 .help = "match GTP header",
2978 .priv = PRIV_ITEM(GTP, sizeof(struct rte_flow_item_gtp)),
2979 .next = NEXT(item_gtp),
2982 [ITEM_GTP_FLAGS] = {
2983 .name = "v_pt_rsv_flags",
2984 .help = "GTP flags",
2985 .next = NEXT(item_gtp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2986 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp,
2989 [ITEM_GTP_MSG_TYPE] = {
2991 .help = "GTP message type",
2992 .next = NEXT(item_gtp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2993 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp, msg_type)),
2997 .help = "tunnel endpoint identifier",
2998 .next = NEXT(item_gtp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2999 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp, teid)),
3003 .help = "match GTP header",
3004 .priv = PRIV_ITEM(GTPC, sizeof(struct rte_flow_item_gtp)),
3005 .next = NEXT(item_gtp),
3010 .help = "match GTP header",
3011 .priv = PRIV_ITEM(GTPU, sizeof(struct rte_flow_item_gtp)),
3012 .next = NEXT(item_gtp),
3017 .help = "match GENEVE header",
3018 .priv = PRIV_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)),
3019 .next = NEXT(item_geneve),
3022 [ITEM_GENEVE_VNI] = {
3024 .help = "virtual network identifier",
3025 .next = NEXT(item_geneve, NEXT_ENTRY(COMMON_UNSIGNED),
3027 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve, vni)),
3029 [ITEM_GENEVE_PROTO] = {
3031 .help = "GENEVE protocol type",
3032 .next = NEXT(item_geneve, NEXT_ENTRY(COMMON_UNSIGNED),
3034 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve,
3037 [ITEM_GENEVE_OPTLEN] = {
3039 .help = "GENEVE options length in dwords",
3040 .next = NEXT(item_geneve, NEXT_ENTRY(COMMON_UNSIGNED),
3042 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_geneve,
3043 ver_opt_len_o_c_rsvd0,
3046 [ITEM_VXLAN_GPE] = {
3047 .name = "vxlan-gpe",
3048 .help = "match VXLAN-GPE header",
3049 .priv = PRIV_ITEM(VXLAN_GPE,
3050 sizeof(struct rte_flow_item_vxlan_gpe)),
3051 .next = NEXT(item_vxlan_gpe),
3054 [ITEM_VXLAN_GPE_VNI] = {
3056 .help = "VXLAN-GPE identifier",
3057 .next = NEXT(item_vxlan_gpe, NEXT_ENTRY(COMMON_UNSIGNED),
3059 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
3062 [ITEM_ARP_ETH_IPV4] = {
3063 .name = "arp_eth_ipv4",
3064 .help = "match ARP header for Ethernet/IPv4",
3065 .priv = PRIV_ITEM(ARP_ETH_IPV4,
3066 sizeof(struct rte_flow_item_arp_eth_ipv4)),
3067 .next = NEXT(item_arp_eth_ipv4),
3070 [ITEM_ARP_ETH_IPV4_SHA] = {
3072 .help = "sender hardware address",
3073 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_MAC_ADDR),
3075 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
3078 [ITEM_ARP_ETH_IPV4_SPA] = {
3080 .help = "sender IPv4 address",
3081 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
3083 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
3086 [ITEM_ARP_ETH_IPV4_THA] = {
3088 .help = "target hardware address",
3089 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_MAC_ADDR),
3091 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
3094 [ITEM_ARP_ETH_IPV4_TPA] = {
3096 .help = "target IPv4 address",
3097 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
3099 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
3104 .help = "match presence of any IPv6 extension header",
3105 .priv = PRIV_ITEM(IPV6_EXT,
3106 sizeof(struct rte_flow_item_ipv6_ext)),
3107 .next = NEXT(item_ipv6_ext),
3110 [ITEM_IPV6_EXT_NEXT_HDR] = {
3112 .help = "next header",
3113 .next = NEXT(item_ipv6_ext, NEXT_ENTRY(COMMON_UNSIGNED),
3115 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_ext,
3118 [ITEM_IPV6_FRAG_EXT] = {
3119 .name = "ipv6_frag_ext",
3120 .help = "match presence of IPv6 fragment extension header",
3121 .priv = PRIV_ITEM(IPV6_FRAG_EXT,
3122 sizeof(struct rte_flow_item_ipv6_frag_ext)),
3123 .next = NEXT(item_ipv6_frag_ext),
3126 [ITEM_IPV6_FRAG_EXT_NEXT_HDR] = {
3128 .help = "next header",
3129 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(COMMON_UNSIGNED),
3131 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ipv6_frag_ext,
3134 [ITEM_IPV6_FRAG_EXT_FRAG_DATA] = {
3135 .name = "frag_data",
3136 .help = "fragment flags and offset",
3137 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(COMMON_UNSIGNED),
3139 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_frag_ext,
3142 [ITEM_IPV6_FRAG_EXT_ID] = {
3143 .name = "packet_id",
3144 .help = "fragment packet id",
3145 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(COMMON_UNSIGNED),
3147 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_frag_ext,
3152 .help = "match any ICMPv6 header",
3153 .priv = PRIV_ITEM(ICMP6, sizeof(struct rte_flow_item_icmp6)),
3154 .next = NEXT(item_icmp6),
3157 [ITEM_ICMP6_TYPE] = {
3159 .help = "ICMPv6 type",
3160 .next = NEXT(item_icmp6, NEXT_ENTRY(COMMON_UNSIGNED),
3162 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
3165 [ITEM_ICMP6_CODE] = {
3167 .help = "ICMPv6 code",
3168 .next = NEXT(item_icmp6, NEXT_ENTRY(COMMON_UNSIGNED),
3170 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
3173 [ITEM_ICMP6_ND_NS] = {
3174 .name = "icmp6_nd_ns",
3175 .help = "match ICMPv6 neighbor discovery solicitation",
3176 .priv = PRIV_ITEM(ICMP6_ND_NS,
3177 sizeof(struct rte_flow_item_icmp6_nd_ns)),
3178 .next = NEXT(item_icmp6_nd_ns),
3181 [ITEM_ICMP6_ND_NS_TARGET_ADDR] = {
3182 .name = "target_addr",
3183 .help = "target address",
3184 .next = NEXT(item_icmp6_nd_ns, NEXT_ENTRY(COMMON_IPV6_ADDR),
3186 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_ns,
3189 [ITEM_ICMP6_ND_NA] = {
3190 .name = "icmp6_nd_na",
3191 .help = "match ICMPv6 neighbor discovery advertisement",
3192 .priv = PRIV_ITEM(ICMP6_ND_NA,
3193 sizeof(struct rte_flow_item_icmp6_nd_na)),
3194 .next = NEXT(item_icmp6_nd_na),
3197 [ITEM_ICMP6_ND_NA_TARGET_ADDR] = {
3198 .name = "target_addr",
3199 .help = "target address",
3200 .next = NEXT(item_icmp6_nd_na, NEXT_ENTRY(COMMON_IPV6_ADDR),
3202 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_na,
3205 [ITEM_ICMP6_ND_OPT] = {
3206 .name = "icmp6_nd_opt",
3207 .help = "match presence of any ICMPv6 neighbor discovery"
3209 .priv = PRIV_ITEM(ICMP6_ND_OPT,
3210 sizeof(struct rte_flow_item_icmp6_nd_opt)),
3211 .next = NEXT(item_icmp6_nd_opt),
3214 [ITEM_ICMP6_ND_OPT_TYPE] = {
3216 .help = "ND option type",
3217 .next = NEXT(item_icmp6_nd_opt, NEXT_ENTRY(COMMON_UNSIGNED),
3219 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_opt,
3222 [ITEM_ICMP6_ND_OPT_SLA_ETH] = {
3223 .name = "icmp6_nd_opt_sla_eth",
3224 .help = "match ICMPv6 neighbor discovery source Ethernet"
3225 " link-layer address option",
3227 (ICMP6_ND_OPT_SLA_ETH,
3228 sizeof(struct rte_flow_item_icmp6_nd_opt_sla_eth)),
3229 .next = NEXT(item_icmp6_nd_opt_sla_eth),
3232 [ITEM_ICMP6_ND_OPT_SLA_ETH_SLA] = {
3234 .help = "source Ethernet LLA",
3235 .next = NEXT(item_icmp6_nd_opt_sla_eth,
3236 NEXT_ENTRY(COMMON_MAC_ADDR), item_param),
3237 .args = ARGS(ARGS_ENTRY_HTON
3238 (struct rte_flow_item_icmp6_nd_opt_sla_eth, sla)),
3240 [ITEM_ICMP6_ND_OPT_TLA_ETH] = {
3241 .name = "icmp6_nd_opt_tla_eth",
3242 .help = "match ICMPv6 neighbor discovery target Ethernet"
3243 " link-layer address option",
3245 (ICMP6_ND_OPT_TLA_ETH,
3246 sizeof(struct rte_flow_item_icmp6_nd_opt_tla_eth)),
3247 .next = NEXT(item_icmp6_nd_opt_tla_eth),
3250 [ITEM_ICMP6_ND_OPT_TLA_ETH_TLA] = {
3252 .help = "target Ethernet LLA",
3253 .next = NEXT(item_icmp6_nd_opt_tla_eth,
3254 NEXT_ENTRY(COMMON_MAC_ADDR), item_param),
3255 .args = ARGS(ARGS_ENTRY_HTON
3256 (struct rte_flow_item_icmp6_nd_opt_tla_eth, tla)),
3260 .help = "match metadata header",
3261 .priv = PRIV_ITEM(META, sizeof(struct rte_flow_item_meta)),
3262 .next = NEXT(item_meta),
3265 [ITEM_META_DATA] = {
3267 .help = "metadata value",
3268 .next = NEXT(item_meta, NEXT_ENTRY(COMMON_UNSIGNED),
3270 .args = ARGS(ARGS_ENTRY_MASK(struct rte_flow_item_meta,
3271 data, "\xff\xff\xff\xff")),
3275 .help = "match GRE key",
3276 .priv = PRIV_ITEM(GRE_KEY, sizeof(rte_be32_t)),
3277 .next = NEXT(item_gre_key),
3280 [ITEM_GRE_KEY_VALUE] = {
3282 .help = "key value",
3283 .next = NEXT(item_gre_key, NEXT_ENTRY(COMMON_UNSIGNED),
3285 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3289 .help = "match GTP extension header with type 0x85",
3290 .priv = PRIV_ITEM(GTP_PSC,
3291 sizeof(struct rte_flow_item_gtp_psc)),
3292 .next = NEXT(item_gtp_psc),
3295 [ITEM_GTP_PSC_QFI] = {
3297 .help = "QoS flow identifier",
3298 .next = NEXT(item_gtp_psc, NEXT_ENTRY(COMMON_UNSIGNED),
3300 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
3303 [ITEM_GTP_PSC_PDU_T] = {
3306 .next = NEXT(item_gtp_psc, NEXT_ENTRY(COMMON_UNSIGNED),
3308 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
3313 .help = "match PPPoE session header",
3314 .priv = PRIV_ITEM(PPPOES, sizeof(struct rte_flow_item_pppoe)),
3315 .next = NEXT(item_pppoes),
3320 .help = "match PPPoE discovery header",
3321 .priv = PRIV_ITEM(PPPOED, sizeof(struct rte_flow_item_pppoe)),
3322 .next = NEXT(item_pppoed),
3325 [ITEM_PPPOE_SEID] = {
3327 .help = "session identifier",
3328 .next = NEXT(item_pppoes, NEXT_ENTRY(COMMON_UNSIGNED),
3330 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pppoe,
3333 [ITEM_PPPOE_PROTO_ID] = {
3334 .name = "pppoe_proto_id",
3335 .help = "match PPPoE session protocol identifier",
3336 .priv = PRIV_ITEM(PPPOE_PROTO_ID,
3337 sizeof(struct rte_flow_item_pppoe_proto_id)),
3338 .next = NEXT(item_pppoe_proto_id, NEXT_ENTRY(COMMON_UNSIGNED),
3340 .args = ARGS(ARGS_ENTRY_HTON
3341 (struct rte_flow_item_pppoe_proto_id, proto_id)),
3346 .help = "matches higig2 header",
3347 .priv = PRIV_ITEM(HIGIG2,
3348 sizeof(struct rte_flow_item_higig2_hdr)),
3349 .next = NEXT(item_higig2),
3352 [ITEM_HIGIG2_CLASSIFICATION] = {
3353 .name = "classification",
3354 .help = "matches classification of higig2 header",
3355 .next = NEXT(item_higig2, NEXT_ENTRY(COMMON_UNSIGNED),
3357 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
3358 hdr.ppt1.classification)),
3360 [ITEM_HIGIG2_VID] = {
3362 .help = "matches vid of higig2 header",
3363 .next = NEXT(item_higig2, NEXT_ENTRY(COMMON_UNSIGNED),
3365 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
3370 .help = "match tag value",
3371 .priv = PRIV_ITEM(TAG, sizeof(struct rte_flow_item_tag)),
3372 .next = NEXT(item_tag),
3377 .help = "tag value to match",
3378 .next = NEXT(item_tag, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3379 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, data)),
3381 [ITEM_TAG_INDEX] = {
3383 .help = "index of tag array to match",
3384 .next = NEXT(item_tag, NEXT_ENTRY(COMMON_UNSIGNED),
3385 NEXT_ENTRY(ITEM_PARAM_IS)),
3386 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, index)),
3388 [ITEM_L2TPV3OIP] = {
3389 .name = "l2tpv3oip",
3390 .help = "match L2TPv3 over IP header",
3391 .priv = PRIV_ITEM(L2TPV3OIP,
3392 sizeof(struct rte_flow_item_l2tpv3oip)),
3393 .next = NEXT(item_l2tpv3oip),
3396 [ITEM_L2TPV3OIP_SESSION_ID] = {
3397 .name = "session_id",
3398 .help = "session identifier",
3399 .next = NEXT(item_l2tpv3oip, NEXT_ENTRY(COMMON_UNSIGNED),
3401 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv3oip,
3406 .help = "match ESP header",
3407 .priv = PRIV_ITEM(ESP, sizeof(struct rte_flow_item_esp)),
3408 .next = NEXT(item_esp),
3413 .help = "security policy index",
3414 .next = NEXT(item_esp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3415 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_esp,
3420 .help = "match AH header",
3421 .priv = PRIV_ITEM(AH, sizeof(struct rte_flow_item_ah)),
3422 .next = NEXT(item_ah),
3427 .help = "security parameters index",
3428 .next = NEXT(item_ah, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3429 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ah, spi)),
3433 .help = "match pfcp header",
3434 .priv = PRIV_ITEM(PFCP, sizeof(struct rte_flow_item_pfcp)),
3435 .next = NEXT(item_pfcp),
3438 [ITEM_PFCP_S_FIELD] = {
3441 .next = NEXT(item_pfcp, NEXT_ENTRY(COMMON_UNSIGNED),
3443 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp,
3446 [ITEM_PFCP_SEID] = {
3448 .help = "session endpoint identifier",
3449 .next = NEXT(item_pfcp, NEXT_ENTRY(COMMON_UNSIGNED),
3451 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp, seid)),
3455 .help = "match eCPRI header",
3456 .priv = PRIV_ITEM(ECPRI, sizeof(struct rte_flow_item_ecpri)),
3457 .next = NEXT(item_ecpri),
3460 [ITEM_ECPRI_COMMON] = {
3462 .help = "eCPRI common header",
3463 .next = NEXT(item_ecpri_common),
3465 [ITEM_ECPRI_COMMON_TYPE] = {
3467 .help = "type of common header",
3468 .next = NEXT(item_ecpri_common_type),
3469 .args = ARGS(ARG_ENTRY_HTON(struct rte_flow_item_ecpri)),
3471 [ITEM_ECPRI_COMMON_TYPE_IQ_DATA] = {
3473 .help = "Type #0: IQ Data",
3474 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
3476 .call = parse_vc_item_ecpri_type,
3478 [ITEM_ECPRI_MSG_IQ_DATA_PCID] = {
3480 .help = "Physical Channel ID",
3481 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
3482 ITEM_ECPRI_COMMON, ITEM_NEXT),
3483 NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3484 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3487 [ITEM_ECPRI_COMMON_TYPE_RTC_CTRL] = {
3489 .help = "Type #2: Real-Time Control Data",
3490 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
3492 .call = parse_vc_item_ecpri_type,
3494 [ITEM_ECPRI_MSG_RTC_CTRL_RTCID] = {
3496 .help = "Real-Time Control Data ID",
3497 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
3498 ITEM_ECPRI_COMMON, ITEM_NEXT),
3499 NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3500 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3503 [ITEM_ECPRI_COMMON_TYPE_DLY_MSR] = {
3504 .name = "delay_measure",
3505 .help = "Type #5: One-Way Delay Measurement",
3506 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
3508 .call = parse_vc_item_ecpri_type,
3510 [ITEM_ECPRI_MSG_DLY_MSR_MSRID] = {
3512 .help = "Measurement ID",
3513 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
3514 ITEM_ECPRI_COMMON, ITEM_NEXT),
3515 NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3516 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3519 [ITEM_GENEVE_OPT] = {
3520 .name = "geneve-opt",
3521 .help = "GENEVE header option",
3522 .priv = PRIV_ITEM(GENEVE_OPT,
3523 sizeof(struct rte_flow_item_geneve_opt) +
3524 ITEM_GENEVE_OPT_DATA_SIZE),
3525 .next = NEXT(item_geneve_opt),
3528 [ITEM_GENEVE_OPT_CLASS] = {
3530 .help = "GENEVE option class",
3531 .next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_UNSIGNED),
3533 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve_opt,
3536 [ITEM_GENEVE_OPT_TYPE] = {
3538 .help = "GENEVE option type",
3539 .next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_UNSIGNED),
3541 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt,
3544 [ITEM_GENEVE_OPT_LENGTH] = {
3546 .help = "GENEVE option data length (in 32b words)",
3547 .next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_UNSIGNED),
3549 .args = ARGS(ARGS_ENTRY_BOUNDED(
3550 struct rte_flow_item_geneve_opt, option_len,
3553 [ITEM_GENEVE_OPT_DATA] = {
3555 .help = "GENEVE option data pattern",
3556 .next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_HEX),
3558 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt, data),
3559 ARGS_ENTRY_ARB(0, 0),
3561 (sizeof(struct rte_flow_item_geneve_opt),
3562 ITEM_GENEVE_OPT_DATA_SIZE)),
3564 [ITEM_INTEGRITY] = {
3565 .name = "integrity",
3566 .help = "match packet integrity",
3567 .priv = PRIV_ITEM(INTEGRITY,
3568 sizeof(struct rte_flow_item_integrity)),
3569 .next = NEXT(item_integrity),
3572 [ITEM_INTEGRITY_LEVEL] = {
3574 .help = "integrity level",
3575 .next = NEXT(item_integrity_lv, NEXT_ENTRY(COMMON_UNSIGNED),
3577 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_integrity, level)),
3579 [ITEM_INTEGRITY_VALUE] = {
3581 .help = "integrity value",
3582 .next = NEXT(item_integrity_lv, NEXT_ENTRY(COMMON_UNSIGNED),
3584 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_integrity, value)),
3586 [ITEM_CONNTRACK] = {
3587 .name = "conntrack",
3588 .help = "conntrack state",
3589 .next = NEXT(NEXT_ENTRY(ITEM_NEXT), NEXT_ENTRY(COMMON_UNSIGNED),
3591 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_conntrack, flags)),
3593 /* Validate/create actions. */
3596 .help = "submit a list of associated actions",
3597 .next = NEXT(next_action),
3602 .help = "specify next action",
3603 .next = NEXT(next_action),
3607 .help = "end list of actions",
3608 .priv = PRIV_ACTION(END, 0),
3613 .help = "no-op action",
3614 .priv = PRIV_ACTION(VOID, 0),
3615 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3618 [ACTION_PASSTHRU] = {
3620 .help = "let subsequent rule process matched packets",
3621 .priv = PRIV_ACTION(PASSTHRU, 0),
3622 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3627 .help = "redirect traffic to a given group",
3628 .priv = PRIV_ACTION(JUMP, sizeof(struct rte_flow_action_jump)),
3629 .next = NEXT(action_jump),
3632 [ACTION_JUMP_GROUP] = {
3634 .help = "group to redirect traffic to",
3635 .next = NEXT(action_jump, NEXT_ENTRY(COMMON_UNSIGNED)),
3636 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump, group)),
3637 .call = parse_vc_conf,
3641 .help = "attach 32 bit value to packets",
3642 .priv = PRIV_ACTION(MARK, sizeof(struct rte_flow_action_mark)),
3643 .next = NEXT(action_mark),
3646 [ACTION_MARK_ID] = {
3648 .help = "32 bit value to return with packets",
3649 .next = NEXT(action_mark, NEXT_ENTRY(COMMON_UNSIGNED)),
3650 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_mark, id)),
3651 .call = parse_vc_conf,
3655 .help = "flag packets",
3656 .priv = PRIV_ACTION(FLAG, 0),
3657 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3662 .help = "assign packets to a given queue index",
3663 .priv = PRIV_ACTION(QUEUE,
3664 sizeof(struct rte_flow_action_queue)),
3665 .next = NEXT(action_queue),
3668 [ACTION_QUEUE_INDEX] = {
3670 .help = "queue index to use",
3671 .next = NEXT(action_queue, NEXT_ENTRY(COMMON_UNSIGNED)),
3672 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_queue, index)),
3673 .call = parse_vc_conf,
3677 .help = "drop packets (note: passthru has priority)",
3678 .priv = PRIV_ACTION(DROP, 0),
3679 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3684 .help = "enable counters for this rule",
3685 .priv = PRIV_ACTION(COUNT,
3686 sizeof(struct rte_flow_action_count)),
3687 .next = NEXT(action_count),
3690 [ACTION_COUNT_ID] = {
3691 .name = "identifier",
3692 .help = "counter identifier to use",
3693 .next = NEXT(action_count, NEXT_ENTRY(COMMON_UNSIGNED)),
3694 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_count, id)),
3695 .call = parse_vc_conf,
3697 [ACTION_COUNT_SHARED] = {
3699 .help = "shared counter",
3700 .next = NEXT(action_count, NEXT_ENTRY(COMMON_BOOLEAN)),
3701 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_count,
3703 .call = parse_vc_conf,
3707 .help = "spread packets among several queues",
3708 .priv = PRIV_ACTION(RSS, sizeof(struct action_rss_data)),
3709 .next = NEXT(action_rss),
3710 .call = parse_vc_action_rss,
3712 [ACTION_RSS_FUNC] = {
3714 .help = "RSS hash function to apply",
3715 .next = NEXT(action_rss,
3716 NEXT_ENTRY(ACTION_RSS_FUNC_DEFAULT,
3717 ACTION_RSS_FUNC_TOEPLITZ,
3718 ACTION_RSS_FUNC_SIMPLE_XOR,
3719 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ)),
3721 [ACTION_RSS_FUNC_DEFAULT] = {
3723 .help = "default hash function",
3724 .call = parse_vc_action_rss_func,
3726 [ACTION_RSS_FUNC_TOEPLITZ] = {
3728 .help = "Toeplitz hash function",
3729 .call = parse_vc_action_rss_func,
3731 [ACTION_RSS_FUNC_SIMPLE_XOR] = {
3732 .name = "simple_xor",
3733 .help = "simple XOR hash function",
3734 .call = parse_vc_action_rss_func,
3736 [ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ] = {
3737 .name = "symmetric_toeplitz",
3738 .help = "Symmetric Toeplitz hash function",
3739 .call = parse_vc_action_rss_func,
3741 [ACTION_RSS_LEVEL] = {
3743 .help = "encapsulation level for \"types\"",
3744 .next = NEXT(action_rss, NEXT_ENTRY(COMMON_UNSIGNED)),
3745 .args = ARGS(ARGS_ENTRY_ARB
3746 (offsetof(struct action_rss_data, conf) +
3747 offsetof(struct rte_flow_action_rss, level),
3748 sizeof(((struct rte_flow_action_rss *)0)->
3751 [ACTION_RSS_TYPES] = {
3753 .help = "specific RSS hash types",
3754 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)),
3756 [ACTION_RSS_TYPE] = {
3758 .help = "RSS hash type",
3759 .call = parse_vc_action_rss_type,
3760 .comp = comp_vc_action_rss_type,
3762 [ACTION_RSS_KEY] = {
3764 .help = "RSS hash key",
3765 .next = NEXT(action_rss, NEXT_ENTRY(COMMON_HEX)),
3766 .args = ARGS(ARGS_ENTRY_ARB
3767 (offsetof(struct action_rss_data, conf) +
3768 offsetof(struct rte_flow_action_rss, key),
3769 sizeof(((struct rte_flow_action_rss *)0)->key)),
3771 (offsetof(struct action_rss_data, conf) +
3772 offsetof(struct rte_flow_action_rss, key_len),
3773 sizeof(((struct rte_flow_action_rss *)0)->
3775 ARGS_ENTRY(struct action_rss_data, key)),
3777 [ACTION_RSS_KEY_LEN] = {
3779 .help = "RSS hash key length in bytes",
3780 .next = NEXT(action_rss, NEXT_ENTRY(COMMON_UNSIGNED)),
3781 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
3782 (offsetof(struct action_rss_data, conf) +
3783 offsetof(struct rte_flow_action_rss, key_len),
3784 sizeof(((struct rte_flow_action_rss *)0)->
3787 RSS_HASH_KEY_LENGTH)),
3789 [ACTION_RSS_QUEUES] = {
3791 .help = "queue indices to use",
3792 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_QUEUE)),
3793 .call = parse_vc_conf,
3795 [ACTION_RSS_QUEUE] = {
3797 .help = "queue index",
3798 .call = parse_vc_action_rss_queue,
3799 .comp = comp_vc_action_rss_queue,
3803 .help = "direct traffic to physical function",
3804 .priv = PRIV_ACTION(PF, 0),
3805 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3810 .help = "direct traffic to a virtual function ID",
3811 .priv = PRIV_ACTION(VF, sizeof(struct rte_flow_action_vf)),
3812 .next = NEXT(action_vf),
3815 [ACTION_VF_ORIGINAL] = {
3817 .help = "use original VF ID if possible",
3818 .next = NEXT(action_vf, NEXT_ENTRY(COMMON_BOOLEAN)),
3819 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_vf,
3821 .call = parse_vc_conf,
3826 .next = NEXT(action_vf, NEXT_ENTRY(COMMON_UNSIGNED)),
3827 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)),
3828 .call = parse_vc_conf,
3830 [ACTION_PHY_PORT] = {
3832 .help = "direct packets to physical port index",
3833 .priv = PRIV_ACTION(PHY_PORT,
3834 sizeof(struct rte_flow_action_phy_port)),
3835 .next = NEXT(action_phy_port),
3838 [ACTION_PHY_PORT_ORIGINAL] = {
3840 .help = "use original port index if possible",
3841 .next = NEXT(action_phy_port, NEXT_ENTRY(COMMON_BOOLEAN)),
3842 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_phy_port,
3844 .call = parse_vc_conf,
3846 [ACTION_PHY_PORT_INDEX] = {
3848 .help = "physical port index",
3849 .next = NEXT(action_phy_port, NEXT_ENTRY(COMMON_UNSIGNED)),
3850 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_phy_port,
3852 .call = parse_vc_conf,
3854 [ACTION_PORT_ID] = {
3856 .help = "direct matching traffic to a given DPDK port ID",
3857 .priv = PRIV_ACTION(PORT_ID,
3858 sizeof(struct rte_flow_action_port_id)),
3859 .next = NEXT(action_port_id),
3862 [ACTION_PORT_ID_ORIGINAL] = {
3864 .help = "use original DPDK port ID if possible",
3865 .next = NEXT(action_port_id, NEXT_ENTRY(COMMON_BOOLEAN)),
3866 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_port_id,
3868 .call = parse_vc_conf,
3870 [ACTION_PORT_ID_ID] = {
3872 .help = "DPDK port ID",
3873 .next = NEXT(action_port_id, NEXT_ENTRY(COMMON_UNSIGNED)),
3874 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_port_id, id)),
3875 .call = parse_vc_conf,
3879 .help = "meter the directed packets at given id",
3880 .priv = PRIV_ACTION(METER,
3881 sizeof(struct rte_flow_action_meter)),
3882 .next = NEXT(action_meter),
3885 [ACTION_METER_COLOR] = {
3887 .help = "meter color for the packets",
3888 .priv = PRIV_ACTION(METER_COLOR,
3889 sizeof(struct rte_flow_action_meter_color)),
3890 .next = NEXT(action_meter_color),
3893 [ACTION_METER_COLOR_TYPE] = {
3895 .help = "specific meter color",
3896 .next = NEXT(NEXT_ENTRY(ACTION_NEXT),
3897 NEXT_ENTRY(ACTION_METER_COLOR_GREEN,
3898 ACTION_METER_COLOR_YELLOW,
3899 ACTION_METER_COLOR_RED)),
3901 [ACTION_METER_COLOR_GREEN] = {
3903 .help = "meter color green",
3904 .call = parse_vc_action_meter_color_type,
3906 [ACTION_METER_COLOR_YELLOW] = {
3908 .help = "meter color yellow",
3909 .call = parse_vc_action_meter_color_type,
3911 [ACTION_METER_COLOR_RED] = {
3913 .help = "meter color red",
3914 .call = parse_vc_action_meter_color_type,
3916 [ACTION_METER_ID] = {
3918 .help = "meter id to use",
3919 .next = NEXT(action_meter, NEXT_ENTRY(COMMON_UNSIGNED)),
3920 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter, mtr_id)),
3921 .call = parse_vc_conf,
3923 [ACTION_OF_SET_MPLS_TTL] = {
3924 .name = "of_set_mpls_ttl",
3925 .help = "OpenFlow's OFPAT_SET_MPLS_TTL",
3928 sizeof(struct rte_flow_action_of_set_mpls_ttl)),
3929 .next = NEXT(action_of_set_mpls_ttl),
3932 [ACTION_OF_SET_MPLS_TTL_MPLS_TTL] = {
3935 .next = NEXT(action_of_set_mpls_ttl,
3936 NEXT_ENTRY(COMMON_UNSIGNED)),
3937 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_mpls_ttl,
3939 .call = parse_vc_conf,
3941 [ACTION_OF_DEC_MPLS_TTL] = {
3942 .name = "of_dec_mpls_ttl",
3943 .help = "OpenFlow's OFPAT_DEC_MPLS_TTL",
3944 .priv = PRIV_ACTION(OF_DEC_MPLS_TTL, 0),
3945 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3948 [ACTION_OF_SET_NW_TTL] = {
3949 .name = "of_set_nw_ttl",
3950 .help = "OpenFlow's OFPAT_SET_NW_TTL",
3953 sizeof(struct rte_flow_action_of_set_nw_ttl)),
3954 .next = NEXT(action_of_set_nw_ttl),
3957 [ACTION_OF_SET_NW_TTL_NW_TTL] = {
3960 .next = NEXT(action_of_set_nw_ttl, NEXT_ENTRY(COMMON_UNSIGNED)),
3961 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_nw_ttl,
3963 .call = parse_vc_conf,
3965 [ACTION_OF_DEC_NW_TTL] = {
3966 .name = "of_dec_nw_ttl",
3967 .help = "OpenFlow's OFPAT_DEC_NW_TTL",
3968 .priv = PRIV_ACTION(OF_DEC_NW_TTL, 0),
3969 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3972 [ACTION_OF_COPY_TTL_OUT] = {
3973 .name = "of_copy_ttl_out",
3974 .help = "OpenFlow's OFPAT_COPY_TTL_OUT",
3975 .priv = PRIV_ACTION(OF_COPY_TTL_OUT, 0),
3976 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3979 [ACTION_OF_COPY_TTL_IN] = {
3980 .name = "of_copy_ttl_in",
3981 .help = "OpenFlow's OFPAT_COPY_TTL_IN",
3982 .priv = PRIV_ACTION(OF_COPY_TTL_IN, 0),
3983 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3986 [ACTION_OF_POP_VLAN] = {
3987 .name = "of_pop_vlan",
3988 .help = "OpenFlow's OFPAT_POP_VLAN",
3989 .priv = PRIV_ACTION(OF_POP_VLAN, 0),
3990 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3993 [ACTION_OF_PUSH_VLAN] = {
3994 .name = "of_push_vlan",
3995 .help = "OpenFlow's OFPAT_PUSH_VLAN",
3998 sizeof(struct rte_flow_action_of_push_vlan)),
3999 .next = NEXT(action_of_push_vlan),
4002 [ACTION_OF_PUSH_VLAN_ETHERTYPE] = {
4003 .name = "ethertype",
4004 .help = "EtherType",
4005 .next = NEXT(action_of_push_vlan, NEXT_ENTRY(COMMON_UNSIGNED)),
4006 .args = ARGS(ARGS_ENTRY_HTON
4007 (struct rte_flow_action_of_push_vlan,
4009 .call = parse_vc_conf,
4011 [ACTION_OF_SET_VLAN_VID] = {
4012 .name = "of_set_vlan_vid",
4013 .help = "OpenFlow's OFPAT_SET_VLAN_VID",
4016 sizeof(struct rte_flow_action_of_set_vlan_vid)),
4017 .next = NEXT(action_of_set_vlan_vid),
4020 [ACTION_OF_SET_VLAN_VID_VLAN_VID] = {
4023 .next = NEXT(action_of_set_vlan_vid,
4024 NEXT_ENTRY(COMMON_UNSIGNED)),
4025 .args = ARGS(ARGS_ENTRY_HTON
4026 (struct rte_flow_action_of_set_vlan_vid,
4028 .call = parse_vc_conf,
4030 [ACTION_OF_SET_VLAN_PCP] = {
4031 .name = "of_set_vlan_pcp",
4032 .help = "OpenFlow's OFPAT_SET_VLAN_PCP",
4035 sizeof(struct rte_flow_action_of_set_vlan_pcp)),
4036 .next = NEXT(action_of_set_vlan_pcp),
4039 [ACTION_OF_SET_VLAN_PCP_VLAN_PCP] = {
4041 .help = "VLAN priority",
4042 .next = NEXT(action_of_set_vlan_pcp,
4043 NEXT_ENTRY(COMMON_UNSIGNED)),
4044 .args = ARGS(ARGS_ENTRY_HTON
4045 (struct rte_flow_action_of_set_vlan_pcp,
4047 .call = parse_vc_conf,
4049 [ACTION_OF_POP_MPLS] = {
4050 .name = "of_pop_mpls",
4051 .help = "OpenFlow's OFPAT_POP_MPLS",
4052 .priv = PRIV_ACTION(OF_POP_MPLS,
4053 sizeof(struct rte_flow_action_of_pop_mpls)),
4054 .next = NEXT(action_of_pop_mpls),
4057 [ACTION_OF_POP_MPLS_ETHERTYPE] = {
4058 .name = "ethertype",
4059 .help = "EtherType",
4060 .next = NEXT(action_of_pop_mpls, NEXT_ENTRY(COMMON_UNSIGNED)),
4061 .args = ARGS(ARGS_ENTRY_HTON
4062 (struct rte_flow_action_of_pop_mpls,
4064 .call = parse_vc_conf,
4066 [ACTION_OF_PUSH_MPLS] = {
4067 .name = "of_push_mpls",
4068 .help = "OpenFlow's OFPAT_PUSH_MPLS",
4071 sizeof(struct rte_flow_action_of_push_mpls)),
4072 .next = NEXT(action_of_push_mpls),
4075 [ACTION_OF_PUSH_MPLS_ETHERTYPE] = {
4076 .name = "ethertype",
4077 .help = "EtherType",
4078 .next = NEXT(action_of_push_mpls, NEXT_ENTRY(COMMON_UNSIGNED)),
4079 .args = ARGS(ARGS_ENTRY_HTON
4080 (struct rte_flow_action_of_push_mpls,
4082 .call = parse_vc_conf,
4084 [ACTION_VXLAN_ENCAP] = {
4085 .name = "vxlan_encap",
4086 .help = "VXLAN encapsulation, uses configuration set by \"set"
4088 .priv = PRIV_ACTION(VXLAN_ENCAP,
4089 sizeof(struct action_vxlan_encap_data)),
4090 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4091 .call = parse_vc_action_vxlan_encap,
4093 [ACTION_VXLAN_DECAP] = {
4094 .name = "vxlan_decap",
4095 .help = "Performs a decapsulation action by stripping all"
4096 " headers of the VXLAN tunnel network overlay from the"
4098 .priv = PRIV_ACTION(VXLAN_DECAP, 0),
4099 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4102 [ACTION_NVGRE_ENCAP] = {
4103 .name = "nvgre_encap",
4104 .help = "NVGRE encapsulation, uses configuration set by \"set"
4106 .priv = PRIV_ACTION(NVGRE_ENCAP,
4107 sizeof(struct action_nvgre_encap_data)),
4108 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4109 .call = parse_vc_action_nvgre_encap,
4111 [ACTION_NVGRE_DECAP] = {
4112 .name = "nvgre_decap",
4113 .help = "Performs a decapsulation action by stripping all"
4114 " headers of the NVGRE tunnel network overlay from the"
4116 .priv = PRIV_ACTION(NVGRE_DECAP, 0),
4117 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4120 [ACTION_L2_ENCAP] = {
4122 .help = "l2 encap, uses configuration set by"
4123 " \"set l2_encap\"",
4124 .priv = PRIV_ACTION(RAW_ENCAP,
4125 sizeof(struct action_raw_encap_data)),
4126 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4127 .call = parse_vc_action_l2_encap,
4129 [ACTION_L2_DECAP] = {
4131 .help = "l2 decap, uses configuration set by"
4132 " \"set l2_decap\"",
4133 .priv = PRIV_ACTION(RAW_DECAP,
4134 sizeof(struct action_raw_decap_data)),
4135 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4136 .call = parse_vc_action_l2_decap,
4138 [ACTION_MPLSOGRE_ENCAP] = {
4139 .name = "mplsogre_encap",
4140 .help = "mplsogre encapsulation, uses configuration set by"
4141 " \"set mplsogre_encap\"",
4142 .priv = PRIV_ACTION(RAW_ENCAP,
4143 sizeof(struct action_raw_encap_data)),
4144 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4145 .call = parse_vc_action_mplsogre_encap,
4147 [ACTION_MPLSOGRE_DECAP] = {
4148 .name = "mplsogre_decap",
4149 .help = "mplsogre decapsulation, uses configuration set by"
4150 " \"set mplsogre_decap\"",
4151 .priv = PRIV_ACTION(RAW_DECAP,
4152 sizeof(struct action_raw_decap_data)),
4153 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4154 .call = parse_vc_action_mplsogre_decap,
4156 [ACTION_MPLSOUDP_ENCAP] = {
4157 .name = "mplsoudp_encap",
4158 .help = "mplsoudp encapsulation, uses configuration set by"
4159 " \"set mplsoudp_encap\"",
4160 .priv = PRIV_ACTION(RAW_ENCAP,
4161 sizeof(struct action_raw_encap_data)),
4162 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4163 .call = parse_vc_action_mplsoudp_encap,
4165 [ACTION_MPLSOUDP_DECAP] = {
4166 .name = "mplsoudp_decap",
4167 .help = "mplsoudp decapsulation, uses configuration set by"
4168 " \"set mplsoudp_decap\"",
4169 .priv = PRIV_ACTION(RAW_DECAP,
4170 sizeof(struct action_raw_decap_data)),
4171 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4172 .call = parse_vc_action_mplsoudp_decap,
4174 [ACTION_SET_IPV4_SRC] = {
4175 .name = "set_ipv4_src",
4176 .help = "Set a new IPv4 source address in the outermost"
4178 .priv = PRIV_ACTION(SET_IPV4_SRC,
4179 sizeof(struct rte_flow_action_set_ipv4)),
4180 .next = NEXT(action_set_ipv4_src),
4183 [ACTION_SET_IPV4_SRC_IPV4_SRC] = {
4184 .name = "ipv4_addr",
4185 .help = "new IPv4 source address to set",
4186 .next = NEXT(action_set_ipv4_src, NEXT_ENTRY(COMMON_IPV4_ADDR)),
4187 .args = ARGS(ARGS_ENTRY_HTON
4188 (struct rte_flow_action_set_ipv4, ipv4_addr)),
4189 .call = parse_vc_conf,
4191 [ACTION_SET_IPV4_DST] = {
4192 .name = "set_ipv4_dst",
4193 .help = "Set a new IPv4 destination address in the outermost"
4195 .priv = PRIV_ACTION(SET_IPV4_DST,
4196 sizeof(struct rte_flow_action_set_ipv4)),
4197 .next = NEXT(action_set_ipv4_dst),
4200 [ACTION_SET_IPV4_DST_IPV4_DST] = {
4201 .name = "ipv4_addr",
4202 .help = "new IPv4 destination address to set",
4203 .next = NEXT(action_set_ipv4_dst, NEXT_ENTRY(COMMON_IPV4_ADDR)),
4204 .args = ARGS(ARGS_ENTRY_HTON
4205 (struct rte_flow_action_set_ipv4, ipv4_addr)),
4206 .call = parse_vc_conf,
4208 [ACTION_SET_IPV6_SRC] = {
4209 .name = "set_ipv6_src",
4210 .help = "Set a new IPv6 source address in the outermost"
4212 .priv = PRIV_ACTION(SET_IPV6_SRC,
4213 sizeof(struct rte_flow_action_set_ipv6)),
4214 .next = NEXT(action_set_ipv6_src),
4217 [ACTION_SET_IPV6_SRC_IPV6_SRC] = {
4218 .name = "ipv6_addr",
4219 .help = "new IPv6 source address to set",
4220 .next = NEXT(action_set_ipv6_src, NEXT_ENTRY(COMMON_IPV6_ADDR)),
4221 .args = ARGS(ARGS_ENTRY_HTON
4222 (struct rte_flow_action_set_ipv6, ipv6_addr)),
4223 .call = parse_vc_conf,
4225 [ACTION_SET_IPV6_DST] = {
4226 .name = "set_ipv6_dst",
4227 .help = "Set a new IPv6 destination address in the outermost"
4229 .priv = PRIV_ACTION(SET_IPV6_DST,
4230 sizeof(struct rte_flow_action_set_ipv6)),
4231 .next = NEXT(action_set_ipv6_dst),
4234 [ACTION_SET_IPV6_DST_IPV6_DST] = {
4235 .name = "ipv6_addr",
4236 .help = "new IPv6 destination address to set",
4237 .next = NEXT(action_set_ipv6_dst, NEXT_ENTRY(COMMON_IPV6_ADDR)),
4238 .args = ARGS(ARGS_ENTRY_HTON
4239 (struct rte_flow_action_set_ipv6, ipv6_addr)),
4240 .call = parse_vc_conf,
4242 [ACTION_SET_TP_SRC] = {
4243 .name = "set_tp_src",
4244 .help = "set a new source port number in the outermost"
4246 .priv = PRIV_ACTION(SET_TP_SRC,
4247 sizeof(struct rte_flow_action_set_tp)),
4248 .next = NEXT(action_set_tp_src),
4251 [ACTION_SET_TP_SRC_TP_SRC] = {
4253 .help = "new source port number to set",
4254 .next = NEXT(action_set_tp_src, NEXT_ENTRY(COMMON_UNSIGNED)),
4255 .args = ARGS(ARGS_ENTRY_HTON
4256 (struct rte_flow_action_set_tp, port)),
4257 .call = parse_vc_conf,
4259 [ACTION_SET_TP_DST] = {
4260 .name = "set_tp_dst",
4261 .help = "set a new destination port number in the outermost"
4263 .priv = PRIV_ACTION(SET_TP_DST,
4264 sizeof(struct rte_flow_action_set_tp)),
4265 .next = NEXT(action_set_tp_dst),
4268 [ACTION_SET_TP_DST_TP_DST] = {
4270 .help = "new destination port number to set",
4271 .next = NEXT(action_set_tp_dst, NEXT_ENTRY(COMMON_UNSIGNED)),
4272 .args = ARGS(ARGS_ENTRY_HTON
4273 (struct rte_flow_action_set_tp, port)),
4274 .call = parse_vc_conf,
4276 [ACTION_MAC_SWAP] = {
4278 .help = "Swap the source and destination MAC addresses"
4279 " in the outermost Ethernet header",
4280 .priv = PRIV_ACTION(MAC_SWAP, 0),
4281 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4284 [ACTION_DEC_TTL] = {
4286 .help = "decrease network TTL if available",
4287 .priv = PRIV_ACTION(DEC_TTL, 0),
4288 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4291 [ACTION_SET_TTL] = {
4293 .help = "set ttl value",
4294 .priv = PRIV_ACTION(SET_TTL,
4295 sizeof(struct rte_flow_action_set_ttl)),
4296 .next = NEXT(action_set_ttl),
4299 [ACTION_SET_TTL_TTL] = {
4300 .name = "ttl_value",
4301 .help = "new ttl value to set",
4302 .next = NEXT(action_set_ttl, NEXT_ENTRY(COMMON_UNSIGNED)),
4303 .args = ARGS(ARGS_ENTRY_HTON
4304 (struct rte_flow_action_set_ttl, ttl_value)),
4305 .call = parse_vc_conf,
4307 [ACTION_SET_MAC_SRC] = {
4308 .name = "set_mac_src",
4309 .help = "set source mac address",
4310 .priv = PRIV_ACTION(SET_MAC_SRC,
4311 sizeof(struct rte_flow_action_set_mac)),
4312 .next = NEXT(action_set_mac_src),
4315 [ACTION_SET_MAC_SRC_MAC_SRC] = {
4317 .help = "new source mac address",
4318 .next = NEXT(action_set_mac_src, NEXT_ENTRY(COMMON_MAC_ADDR)),
4319 .args = ARGS(ARGS_ENTRY_HTON
4320 (struct rte_flow_action_set_mac, mac_addr)),
4321 .call = parse_vc_conf,
4323 [ACTION_SET_MAC_DST] = {
4324 .name = "set_mac_dst",
4325 .help = "set destination mac address",
4326 .priv = PRIV_ACTION(SET_MAC_DST,
4327 sizeof(struct rte_flow_action_set_mac)),
4328 .next = NEXT(action_set_mac_dst),
4331 [ACTION_SET_MAC_DST_MAC_DST] = {
4333 .help = "new destination mac address to set",
4334 .next = NEXT(action_set_mac_dst, NEXT_ENTRY(COMMON_MAC_ADDR)),
4335 .args = ARGS(ARGS_ENTRY_HTON
4336 (struct rte_flow_action_set_mac, mac_addr)),
4337 .call = parse_vc_conf,
4339 [ACTION_INC_TCP_SEQ] = {
4340 .name = "inc_tcp_seq",
4341 .help = "increase TCP sequence number",
4342 .priv = PRIV_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
4343 .next = NEXT(action_inc_tcp_seq),
4346 [ACTION_INC_TCP_SEQ_VALUE] = {
4348 .help = "the value to increase TCP sequence number by",
4349 .next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(COMMON_UNSIGNED)),
4350 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4351 .call = parse_vc_conf,
4353 [ACTION_DEC_TCP_SEQ] = {
4354 .name = "dec_tcp_seq",
4355 .help = "decrease TCP sequence number",
4356 .priv = PRIV_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
4357 .next = NEXT(action_dec_tcp_seq),
4360 [ACTION_DEC_TCP_SEQ_VALUE] = {
4362 .help = "the value to decrease TCP sequence number by",
4363 .next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(COMMON_UNSIGNED)),
4364 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4365 .call = parse_vc_conf,
4367 [ACTION_INC_TCP_ACK] = {
4368 .name = "inc_tcp_ack",
4369 .help = "increase TCP acknowledgment number",
4370 .priv = PRIV_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
4371 .next = NEXT(action_inc_tcp_ack),
4374 [ACTION_INC_TCP_ACK_VALUE] = {
4376 .help = "the value to increase TCP acknowledgment number by",
4377 .next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(COMMON_UNSIGNED)),
4378 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4379 .call = parse_vc_conf,
4381 [ACTION_DEC_TCP_ACK] = {
4382 .name = "dec_tcp_ack",
4383 .help = "decrease TCP acknowledgment number",
4384 .priv = PRIV_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
4385 .next = NEXT(action_dec_tcp_ack),
4388 [ACTION_DEC_TCP_ACK_VALUE] = {
4390 .help = "the value to decrease TCP acknowledgment number by",
4391 .next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(COMMON_UNSIGNED)),
4392 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4393 .call = parse_vc_conf,
4395 [ACTION_RAW_ENCAP] = {
4396 .name = "raw_encap",
4397 .help = "encapsulation data, defined by set raw_encap",
4398 .priv = PRIV_ACTION(RAW_ENCAP,
4399 sizeof(struct action_raw_encap_data)),
4400 .next = NEXT(action_raw_encap),
4401 .call = parse_vc_action_raw_encap,
4403 [ACTION_RAW_ENCAP_INDEX] = {
4405 .help = "the index of raw_encap_confs",
4406 .next = NEXT(NEXT_ENTRY(ACTION_RAW_ENCAP_INDEX_VALUE)),
4408 [ACTION_RAW_ENCAP_INDEX_VALUE] = {
4411 .help = "unsigned integer value",
4412 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4413 .call = parse_vc_action_raw_encap_index,
4414 .comp = comp_set_raw_index,
4416 [ACTION_RAW_DECAP] = {
4417 .name = "raw_decap",
4418 .help = "decapsulation data, defined by set raw_encap",
4419 .priv = PRIV_ACTION(RAW_DECAP,
4420 sizeof(struct action_raw_decap_data)),
4421 .next = NEXT(action_raw_decap),
4422 .call = parse_vc_action_raw_decap,
4424 [ACTION_RAW_DECAP_INDEX] = {
4426 .help = "the index of raw_encap_confs",
4427 .next = NEXT(NEXT_ENTRY(ACTION_RAW_DECAP_INDEX_VALUE)),
4429 [ACTION_RAW_DECAP_INDEX_VALUE] = {
4432 .help = "unsigned integer value",
4433 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4434 .call = parse_vc_action_raw_decap_index,
4435 .comp = comp_set_raw_index,
4437 [ACTION_MODIFY_FIELD] = {
4438 .name = "modify_field",
4439 .help = "modify destination field with data from source field",
4440 .priv = PRIV_ACTION(MODIFY_FIELD,
4441 sizeof(struct rte_flow_action_modify_field)),
4442 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_OP)),
4445 [ACTION_MODIFY_FIELD_OP] = {
4447 .help = "operation type",
4448 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_TYPE),
4449 NEXT_ENTRY(ACTION_MODIFY_FIELD_OP_VALUE)),
4450 .call = parse_vc_conf,
4452 [ACTION_MODIFY_FIELD_OP_VALUE] = {
4453 .name = "{operation}",
4454 .help = "operation type value",
4455 .call = parse_vc_modify_field_op,
4456 .comp = comp_set_modify_field_op,
4458 [ACTION_MODIFY_FIELD_DST_TYPE] = {
4460 .help = "destination field type",
4461 .next = NEXT(action_modify_field_dst,
4462 NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_TYPE_VALUE)),
4463 .call = parse_vc_conf,
4465 [ACTION_MODIFY_FIELD_DST_TYPE_VALUE] = {
4466 .name = "{dst_type}",
4467 .help = "destination field type value",
4468 .call = parse_vc_modify_field_id,
4469 .comp = comp_set_modify_field_id,
4471 [ACTION_MODIFY_FIELD_DST_LEVEL] = {
4472 .name = "dst_level",
4473 .help = "destination field level",
4474 .next = NEXT(action_modify_field_dst,
4475 NEXT_ENTRY(COMMON_UNSIGNED)),
4476 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4478 .call = parse_vc_conf,
4480 [ACTION_MODIFY_FIELD_DST_OFFSET] = {
4481 .name = "dst_offset",
4482 .help = "destination field bit offset",
4483 .next = NEXT(action_modify_field_dst,
4484 NEXT_ENTRY(COMMON_UNSIGNED)),
4485 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4487 .call = parse_vc_conf,
4489 [ACTION_MODIFY_FIELD_SRC_TYPE] = {
4491 .help = "source field type",
4492 .next = NEXT(action_modify_field_src,
4493 NEXT_ENTRY(ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)),
4494 .call = parse_vc_conf,
4496 [ACTION_MODIFY_FIELD_SRC_TYPE_VALUE] = {
4497 .name = "{src_type}",
4498 .help = "source field type value",
4499 .call = parse_vc_modify_field_id,
4500 .comp = comp_set_modify_field_id,
4502 [ACTION_MODIFY_FIELD_SRC_LEVEL] = {
4503 .name = "src_level",
4504 .help = "source field level",
4505 .next = NEXT(action_modify_field_src,
4506 NEXT_ENTRY(COMMON_UNSIGNED)),
4507 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4509 .call = parse_vc_conf,
4511 [ACTION_MODIFY_FIELD_SRC_OFFSET] = {
4512 .name = "src_offset",
4513 .help = "source field bit offset",
4514 .next = NEXT(action_modify_field_src,
4515 NEXT_ENTRY(COMMON_UNSIGNED)),
4516 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4518 .call = parse_vc_conf,
4520 [ACTION_MODIFY_FIELD_SRC_VALUE] = {
4521 .name = "src_value",
4522 .help = "source immediate value",
4523 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_WIDTH),
4524 NEXT_ENTRY(COMMON_UNSIGNED)),
4525 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4527 .call = parse_vc_conf,
4529 [ACTION_MODIFY_FIELD_WIDTH] = {
4531 .help = "number of bits to copy",
4532 .next = NEXT(NEXT_ENTRY(ACTION_NEXT),
4533 NEXT_ENTRY(COMMON_UNSIGNED)),
4534 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4536 .call = parse_vc_conf,
4538 /* Top level command. */
4541 .help = "set raw encap/decap/sample data",
4542 .type = "set raw_encap|raw_decap <index> <pattern>"
4543 " or set sample_actions <index> <action>",
4544 .next = NEXT(NEXT_ENTRY
4547 SET_SAMPLE_ACTIONS)),
4548 .call = parse_set_init,
4550 /* Sub-level commands. */
4552 .name = "raw_encap",
4553 .help = "set raw encap data",
4554 .next = NEXT(next_set_raw),
4555 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4556 (offsetof(struct buffer, port),
4557 sizeof(((struct buffer *)0)->port),
4558 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
4559 .call = parse_set_raw_encap_decap,
4562 .name = "raw_decap",
4563 .help = "set raw decap data",
4564 .next = NEXT(next_set_raw),
4565 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4566 (offsetof(struct buffer, port),
4567 sizeof(((struct buffer *)0)->port),
4568 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
4569 .call = parse_set_raw_encap_decap,
4573 .type = "COMMON_UNSIGNED",
4574 .help = "index of raw_encap/raw_decap data",
4575 .next = NEXT(next_item),
4578 [SET_SAMPLE_INDEX] = {
4581 .help = "index of sample actions",
4582 .next = NEXT(next_action_sample),
4585 [SET_SAMPLE_ACTIONS] = {
4586 .name = "sample_actions",
4587 .help = "set sample actions list",
4588 .next = NEXT(NEXT_ENTRY(SET_SAMPLE_INDEX)),
4589 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4590 (offsetof(struct buffer, port),
4591 sizeof(((struct buffer *)0)->port),
4592 0, RAW_SAMPLE_CONFS_MAX_NUM - 1)),
4593 .call = parse_set_sample_action,
4595 [ACTION_SET_TAG] = {
4598 .priv = PRIV_ACTION(SET_TAG,
4599 sizeof(struct rte_flow_action_set_tag)),
4600 .next = NEXT(action_set_tag),
4603 [ACTION_SET_TAG_INDEX] = {
4605 .help = "index of tag array",
4606 .next = NEXT(action_set_tag, NEXT_ENTRY(COMMON_UNSIGNED)),
4607 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_set_tag, index)),
4608 .call = parse_vc_conf,
4610 [ACTION_SET_TAG_DATA] = {
4612 .help = "tag value",
4613 .next = NEXT(action_set_tag, NEXT_ENTRY(COMMON_UNSIGNED)),
4614 .args = ARGS(ARGS_ENTRY
4615 (struct rte_flow_action_set_tag, data)),
4616 .call = parse_vc_conf,
4618 [ACTION_SET_TAG_MASK] = {
4620 .help = "mask for tag value",
4621 .next = NEXT(action_set_tag, NEXT_ENTRY(COMMON_UNSIGNED)),
4622 .args = ARGS(ARGS_ENTRY
4623 (struct rte_flow_action_set_tag, mask)),
4624 .call = parse_vc_conf,
4626 [ACTION_SET_META] = {
4628 .help = "set metadata",
4629 .priv = PRIV_ACTION(SET_META,
4630 sizeof(struct rte_flow_action_set_meta)),
4631 .next = NEXT(action_set_meta),
4632 .call = parse_vc_action_set_meta,
4634 [ACTION_SET_META_DATA] = {
4636 .help = "metadata value",
4637 .next = NEXT(action_set_meta, NEXT_ENTRY(COMMON_UNSIGNED)),
4638 .args = ARGS(ARGS_ENTRY
4639 (struct rte_flow_action_set_meta, data)),
4640 .call = parse_vc_conf,
4642 [ACTION_SET_META_MASK] = {
4644 .help = "mask for metadata value",
4645 .next = NEXT(action_set_meta, NEXT_ENTRY(COMMON_UNSIGNED)),
4646 .args = ARGS(ARGS_ENTRY
4647 (struct rte_flow_action_set_meta, mask)),
4648 .call = parse_vc_conf,
4650 [ACTION_SET_IPV4_DSCP] = {
4651 .name = "set_ipv4_dscp",
4652 .help = "set DSCP value",
4653 .priv = PRIV_ACTION(SET_IPV4_DSCP,
4654 sizeof(struct rte_flow_action_set_dscp)),
4655 .next = NEXT(action_set_ipv4_dscp),
4658 [ACTION_SET_IPV4_DSCP_VALUE] = {
4659 .name = "dscp_value",
4660 .help = "new IPv4 DSCP value to set",
4661 .next = NEXT(action_set_ipv4_dscp, NEXT_ENTRY(COMMON_UNSIGNED)),
4662 .args = ARGS(ARGS_ENTRY
4663 (struct rte_flow_action_set_dscp, dscp)),
4664 .call = parse_vc_conf,
4666 [ACTION_SET_IPV6_DSCP] = {
4667 .name = "set_ipv6_dscp",
4668 .help = "set DSCP value",
4669 .priv = PRIV_ACTION(SET_IPV6_DSCP,
4670 sizeof(struct rte_flow_action_set_dscp)),
4671 .next = NEXT(action_set_ipv6_dscp),
4674 [ACTION_SET_IPV6_DSCP_VALUE] = {
4675 .name = "dscp_value",
4676 .help = "new IPv6 DSCP value to set",
4677 .next = NEXT(action_set_ipv6_dscp, NEXT_ENTRY(COMMON_UNSIGNED)),
4678 .args = ARGS(ARGS_ENTRY
4679 (struct rte_flow_action_set_dscp, dscp)),
4680 .call = parse_vc_conf,
4684 .help = "set a specific metadata header",
4685 .next = NEXT(action_age),
4686 .priv = PRIV_ACTION(AGE,
4687 sizeof(struct rte_flow_action_age)),
4690 [ACTION_AGE_TIMEOUT] = {
4692 .help = "flow age timeout value",
4693 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_age,
4695 .next = NEXT(action_age, NEXT_ENTRY(COMMON_UNSIGNED)),
4696 .call = parse_vc_conf,
4700 .help = "set a sample action",
4701 .next = NEXT(action_sample),
4702 .priv = PRIV_ACTION(SAMPLE,
4703 sizeof(struct action_sample_data)),
4704 .call = parse_vc_action_sample,
4706 [ACTION_SAMPLE_RATIO] = {
4708 .help = "flow sample ratio value",
4709 .next = NEXT(action_sample, NEXT_ENTRY(COMMON_UNSIGNED)),
4710 .args = ARGS(ARGS_ENTRY_ARB
4711 (offsetof(struct action_sample_data, conf) +
4712 offsetof(struct rte_flow_action_sample, ratio),
4713 sizeof(((struct rte_flow_action_sample *)0)->
4716 [ACTION_SAMPLE_INDEX] = {
4718 .help = "the index of sample actions list",
4719 .next = NEXT(NEXT_ENTRY(ACTION_SAMPLE_INDEX_VALUE)),
4721 [ACTION_SAMPLE_INDEX_VALUE] = {
4723 .type = "COMMON_UNSIGNED",
4724 .help = "unsigned integer value",
4725 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4726 .call = parse_vc_action_sample_index,
4727 .comp = comp_set_sample_index,
4729 [ACTION_CONNTRACK] = {
4730 .name = "conntrack",
4731 .help = "create a conntrack object",
4732 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4733 .priv = PRIV_ACTION(CONNTRACK,
4734 sizeof(struct rte_flow_action_conntrack)),
4737 [ACTION_CONNTRACK_UPDATE] = {
4738 .name = "conntrack_update",
4739 .help = "update a conntrack object",
4740 .next = NEXT(action_update_conntrack),
4741 .priv = PRIV_ACTION(CONNTRACK,
4742 sizeof(struct rte_flow_modify_conntrack)),
4745 [ACTION_CONNTRACK_UPDATE_DIR] = {
4747 .help = "update a conntrack object direction",
4748 .next = NEXT(action_update_conntrack),
4749 .call = parse_vc_action_conntrack_update,
4751 [ACTION_CONNTRACK_UPDATE_CTX] = {
4753 .help = "update a conntrack object context",
4754 .next = NEXT(action_update_conntrack),
4755 .call = parse_vc_action_conntrack_update,
4757 /* Indirect action destroy arguments. */
4758 [INDIRECT_ACTION_DESTROY_ID] = {
4759 .name = "action_id",
4760 .help = "specify a indirect action id to destroy",
4761 .next = NEXT(next_ia_destroy_attr,
4762 NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
4763 .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
4764 args.ia_destroy.action_id)),
4765 .call = parse_ia_destroy,
4767 /* Indirect action create arguments. */
4768 [INDIRECT_ACTION_CREATE_ID] = {
4769 .name = "action_id",
4770 .help = "specify a indirect action id to create",
4771 .next = NEXT(next_ia_create_attr,
4772 NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
4773 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
4775 [ACTION_INDIRECT] = {
4777 .help = "apply indirect action by id",
4778 .priv = PRIV_ACTION(INDIRECT, 0),
4779 .next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_ID2PTR)),
4780 .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
4783 [INDIRECT_ACTION_ID2PTR] = {
4784 .name = "{action_id}",
4785 .type = "INDIRECT_ACTION_ID",
4786 .help = "indirect action id",
4787 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4788 .call = parse_ia_id2ptr,
4791 [INDIRECT_ACTION_INGRESS] = {
4793 .help = "affect rule to ingress",
4794 .next = NEXT(next_ia_create_attr),
4797 [INDIRECT_ACTION_EGRESS] = {
4799 .help = "affect rule to egress",
4800 .next = NEXT(next_ia_create_attr),
4803 [INDIRECT_ACTION_TRANSFER] = {
4805 .help = "affect rule to transfer",
4806 .next = NEXT(next_ia_create_attr),
4809 [INDIRECT_ACTION_SPEC] = {
4811 .help = "specify action to create indirect handle",
4812 .next = NEXT(next_action),
4815 .name = "g_actions",
4816 .help = "submit a list of associated actions for green",
4817 .next = NEXT(next_action),
4821 .name = "y_actions",
4822 .help = "submit a list of associated actions for yellow",
4823 .next = NEXT(next_action),
4826 .name = "r_actions",
4827 .help = "submit a list of associated actions for red",
4828 .next = NEXT(next_action),
4831 /* Top-level command. */
4834 .type = "port meter policy {port_id} {arg}",
4835 .help = "add port meter policy",
4836 .next = NEXT(NEXT_ENTRY(ITEM_POL_PORT)),
4839 /* Sub-level commands. */
4842 .help = "add port meter policy",
4843 .next = NEXT(NEXT_ENTRY(ITEM_POL_METER)),
4845 [ITEM_POL_METER] = {
4847 .help = "add port meter policy",
4848 .next = NEXT(NEXT_ENTRY(ITEM_POL_POLICY)),
4850 [ITEM_POL_POLICY] = {
4852 .help = "add port meter policy",
4853 .next = NEXT(NEXT_ENTRY(ACTION_POL_R),
4854 NEXT_ENTRY(ACTION_POL_Y),
4855 NEXT_ENTRY(ACTION_POL_G),
4856 NEXT_ENTRY(COMMON_POLICY_ID),
4857 NEXT_ENTRY(COMMON_PORT_ID)),
4858 .args = ARGS(ARGS_ENTRY(struct buffer, args.policy.policy_id),
4859 ARGS_ENTRY(struct buffer, port)),
4864 /** Remove and return last entry from argument stack. */
4865 static const struct arg *
4866 pop_args(struct context *ctx)
4868 return ctx->args_num ? ctx->args[--ctx->args_num] : NULL;
4871 /** Add entry on top of the argument stack. */
4873 push_args(struct context *ctx, const struct arg *arg)
4875 if (ctx->args_num == CTX_STACK_SIZE)
4877 ctx->args[ctx->args_num++] = arg;
4881 /** Spread value into buffer according to bit-mask. */
4883 arg_entry_bf_fill(void *dst, uintmax_t val, const struct arg *arg)
4885 uint32_t i = arg->size;
4893 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
4902 unsigned int shift = 0;
4903 uint8_t *buf = (uint8_t *)dst + arg->offset + (i -= sub);
4905 for (shift = 0; arg->mask[i] >> shift; ++shift) {
4906 if (!(arg->mask[i] & (1 << shift)))
4911 *buf &= ~(1 << shift);
4912 *buf |= (val & 1) << shift;
4920 /** Compare a string with a partial one of a given length. */
4922 strcmp_partial(const char *full, const char *partial, size_t partial_len)
4924 int r = strncmp(full, partial, partial_len);
4928 if (strlen(full) <= partial_len)
4930 return full[partial_len];
4934 * Parse a prefix length and generate a bit-mask.
4936 * Last argument (ctx->args) is retrieved to determine mask size, storage
4937 * location and whether the result must use network byte ordering.
4940 parse_prefix(struct context *ctx, const struct token *token,
4941 const char *str, unsigned int len,
4942 void *buf, unsigned int size)
4944 const struct arg *arg = pop_args(ctx);
4945 static const uint8_t conv[] = "\x00\x80\xc0\xe0\xf0\xf8\xfc\xfe\xff";
4952 /* Argument is expected. */
4956 u = strtoumax(str, &end, 0);
4957 if (errno || (size_t)(end - str) != len)
4962 extra = arg_entry_bf_fill(NULL, 0, arg);
4971 if (!arg_entry_bf_fill(ctx->object, v, arg) ||
4972 !arg_entry_bf_fill(ctx->objmask, -1, arg))
4979 if (bytes > size || bytes + !!extra > size)
4983 buf = (uint8_t *)ctx->object + arg->offset;
4984 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
4986 memset((uint8_t *)buf + size - bytes, 0xff, bytes);
4987 memset(buf, 0x00, size - bytes);
4989 ((uint8_t *)buf)[size - bytes - 1] = conv[extra];
4993 memset(buf, 0xff, bytes);
4994 memset((uint8_t *)buf + bytes, 0x00, size - bytes);
4996 ((uint8_t *)buf)[bytes] = conv[extra];
4999 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
5002 push_args(ctx, arg);
5006 /** Default parsing function for token name matching. */
5008 parse_default(struct context *ctx, const struct token *token,
5009 const char *str, unsigned int len,
5010 void *buf, unsigned int size)
5015 if (strcmp_partial(token->name, str, len))
5020 /** Parse flow command, initialize output buffer for subsequent tokens. */
5022 parse_init(struct context *ctx, const struct token *token,
5023 const char *str, unsigned int len,
5024 void *buf, unsigned int size)
5026 struct buffer *out = buf;
5028 /* Token name must match. */
5029 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5031 /* Nothing else to do if there is no buffer. */
5034 /* Make sure buffer is large enough. */
5035 if (size < sizeof(*out))
5037 /* Initialize buffer. */
5038 memset(out, 0x00, sizeof(*out));
5039 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
5042 ctx->objmask = NULL;
5046 /** Parse tokens for indirect action commands. */
5048 parse_ia(struct context *ctx, const struct token *token,
5049 const char *str, unsigned int len,
5050 void *buf, unsigned int size)
5052 struct buffer *out = buf;
5054 /* Token name must match. */
5055 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5057 /* Nothing else to do if there is no buffer. */
5060 if (!out->command) {
5061 if (ctx->curr != INDIRECT_ACTION)
5063 if (sizeof(*out) > size)
5065 out->command = ctx->curr;
5068 ctx->objmask = NULL;
5069 out->args.vc.data = (uint8_t *)out + size;
5072 switch (ctx->curr) {
5073 case INDIRECT_ACTION_CREATE:
5074 case INDIRECT_ACTION_UPDATE:
5075 out->args.vc.actions =
5076 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5078 out->args.vc.attr.group = UINT32_MAX;
5080 case INDIRECT_ACTION_QUERY:
5081 out->command = ctx->curr;
5084 ctx->objmask = NULL;
5086 case INDIRECT_ACTION_EGRESS:
5087 out->args.vc.attr.egress = 1;
5089 case INDIRECT_ACTION_INGRESS:
5090 out->args.vc.attr.ingress = 1;
5092 case INDIRECT_ACTION_TRANSFER:
5093 out->args.vc.attr.transfer = 1;
5101 /** Parse tokens for indirect action destroy command. */
5103 parse_ia_destroy(struct context *ctx, const struct token *token,
5104 const char *str, unsigned int len,
5105 void *buf, unsigned int size)
5107 struct buffer *out = buf;
5108 uint32_t *action_id;
5110 /* Token name must match. */
5111 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5113 /* Nothing else to do if there is no buffer. */
5116 if (!out->command || out->command == INDIRECT_ACTION) {
5117 if (ctx->curr != INDIRECT_ACTION_DESTROY)
5119 if (sizeof(*out) > size)
5121 out->command = ctx->curr;
5124 ctx->objmask = NULL;
5125 out->args.ia_destroy.action_id =
5126 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5130 action_id = out->args.ia_destroy.action_id
5131 + out->args.ia_destroy.action_id_n++;
5132 if ((uint8_t *)action_id > (uint8_t *)out + size)
5135 ctx->object = action_id;
5136 ctx->objmask = NULL;
5140 /** Parse tokens for meter policy action commands. */
5142 parse_mp(struct context *ctx, const struct token *token,
5143 const char *str, unsigned int len,
5144 void *buf, unsigned int size)
5146 struct buffer *out = buf;
5148 /* Token name must match. */
5149 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5151 /* Nothing else to do if there is no buffer. */
5154 if (!out->command) {
5155 if (ctx->curr != ITEM_POL_POLICY)
5157 if (sizeof(*out) > size)
5159 out->command = ctx->curr;
5162 ctx->objmask = NULL;
5163 out->args.vc.data = (uint8_t *)out + size;
5166 switch (ctx->curr) {
5168 out->args.vc.actions =
5169 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5171 out->command = ctx->curr;
5174 ctx->objmask = NULL;
5181 /** Parse tokens for validate/create commands. */
5183 parse_vc(struct context *ctx, const struct token *token,
5184 const char *str, unsigned int len,
5185 void *buf, unsigned int size)
5187 struct buffer *out = buf;
5191 /* Token name must match. */
5192 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5194 /* Nothing else to do if there is no buffer. */
5197 if (!out->command) {
5198 if (ctx->curr != VALIDATE && ctx->curr != CREATE)
5200 if (sizeof(*out) > size)
5202 out->command = ctx->curr;
5205 ctx->objmask = NULL;
5206 out->args.vc.data = (uint8_t *)out + size;
5210 switch (ctx->curr) {
5212 ctx->object = &out->args.vc.attr;
5215 case VC_TUNNEL_MATCH:
5216 ctx->object = &out->args.vc.tunnel_ops;
5219 ctx->objmask = NULL;
5220 switch (ctx->curr) {
5225 out->args.vc.tunnel_ops.enabled = 1;
5226 out->args.vc.tunnel_ops.actions = 1;
5228 case VC_TUNNEL_MATCH:
5229 out->args.vc.tunnel_ops.enabled = 1;
5230 out->args.vc.tunnel_ops.items = 1;
5233 out->args.vc.attr.ingress = 1;
5236 out->args.vc.attr.egress = 1;
5239 out->args.vc.attr.transfer = 1;
5242 out->args.vc.pattern =
5243 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5245 ctx->object = out->args.vc.pattern;
5246 ctx->objmask = NULL;
5249 out->args.vc.actions =
5250 (void *)RTE_ALIGN_CEIL((uintptr_t)
5251 (out->args.vc.pattern +
5252 out->args.vc.pattern_n),
5254 ctx->object = out->args.vc.actions;
5255 ctx->objmask = NULL;
5262 if (!out->args.vc.actions) {
5263 const struct parse_item_priv *priv = token->priv;
5264 struct rte_flow_item *item =
5265 out->args.vc.pattern + out->args.vc.pattern_n;
5267 data_size = priv->size * 3; /* spec, last, mask */
5268 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
5269 (out->args.vc.data - data_size),
5271 if ((uint8_t *)item + sizeof(*item) > data)
5273 *item = (struct rte_flow_item){
5276 ++out->args.vc.pattern_n;
5278 ctx->objmask = NULL;
5280 const struct parse_action_priv *priv = token->priv;
5281 struct rte_flow_action *action =
5282 out->args.vc.actions + out->args.vc.actions_n;
5284 data_size = priv->size; /* configuration */
5285 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
5286 (out->args.vc.data - data_size),
5288 if ((uint8_t *)action + sizeof(*action) > data)
5290 *action = (struct rte_flow_action){
5292 .conf = data_size ? data : NULL,
5294 ++out->args.vc.actions_n;
5295 ctx->object = action;
5296 ctx->objmask = NULL;
5298 memset(data, 0, data_size);
5299 out->args.vc.data = data;
5300 ctx->objdata = data_size;
5304 /** Parse pattern item parameter type. */
5306 parse_vc_spec(struct context *ctx, const struct token *token,
5307 const char *str, unsigned int len,
5308 void *buf, unsigned int size)
5310 struct buffer *out = buf;
5311 struct rte_flow_item *item;
5317 /* Token name must match. */
5318 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5320 /* Parse parameter types. */
5321 switch (ctx->curr) {
5322 static const enum index prefix[] = NEXT_ENTRY(COMMON_PREFIX);
5328 case ITEM_PARAM_SPEC:
5331 case ITEM_PARAM_LAST:
5334 case ITEM_PARAM_PREFIX:
5335 /* Modify next token to expect a prefix. */
5336 if (ctx->next_num < 2)
5338 ctx->next[ctx->next_num - 2] = prefix;
5340 case ITEM_PARAM_MASK:
5346 /* Nothing else to do if there is no buffer. */
5349 if (!out->args.vc.pattern_n)
5351 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
5352 data_size = ctx->objdata / 3; /* spec, last, mask */
5353 /* Point to selected object. */
5354 ctx->object = out->args.vc.data + (data_size * index);
5356 ctx->objmask = out->args.vc.data + (data_size * 2); /* mask */
5357 item->mask = ctx->objmask;
5359 ctx->objmask = NULL;
5360 /* Update relevant item pointer. */
5361 *((const void **[]){ &item->spec, &item->last, &item->mask })[index] =
5366 /** Parse action configuration field. */
5368 parse_vc_conf(struct context *ctx, const struct token *token,
5369 const char *str, unsigned int len,
5370 void *buf, unsigned int size)
5372 struct buffer *out = buf;
5375 /* Token name must match. */
5376 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5378 /* Nothing else to do if there is no buffer. */
5381 /* Point to selected object. */
5382 ctx->object = out->args.vc.data;
5383 ctx->objmask = NULL;
5387 /** Parse eCPRI common header type field. */
5389 parse_vc_item_ecpri_type(struct context *ctx, const struct token *token,
5390 const char *str, unsigned int len,
5391 void *buf, unsigned int size)
5393 struct rte_flow_item_ecpri *ecpri;
5394 struct rte_flow_item_ecpri *ecpri_mask;
5395 struct rte_flow_item *item;
5398 struct buffer *out = buf;
5399 const struct arg *arg;
5402 /* Token name must match. */
5403 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5405 switch (ctx->curr) {
5406 case ITEM_ECPRI_COMMON_TYPE_IQ_DATA:
5407 msg_type = RTE_ECPRI_MSG_TYPE_IQ_DATA;
5409 case ITEM_ECPRI_COMMON_TYPE_RTC_CTRL:
5410 msg_type = RTE_ECPRI_MSG_TYPE_RTC_CTRL;
5412 case ITEM_ECPRI_COMMON_TYPE_DLY_MSR:
5413 msg_type = RTE_ECPRI_MSG_TYPE_DLY_MSR;
5420 arg = pop_args(ctx);
5423 ecpri = (struct rte_flow_item_ecpri *)out->args.vc.data;
5424 ecpri->hdr.common.type = msg_type;
5425 data_size = ctx->objdata / 3; /* spec, last, mask */
5426 ecpri_mask = (struct rte_flow_item_ecpri *)(out->args.vc.data +
5428 ecpri_mask->hdr.common.type = 0xFF;
5430 ecpri->hdr.common.u32 = rte_cpu_to_be_32(ecpri->hdr.common.u32);
5431 ecpri_mask->hdr.common.u32 =
5432 rte_cpu_to_be_32(ecpri_mask->hdr.common.u32);
5434 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
5436 item->mask = ecpri_mask;
5440 /** Parse meter color action type. */
5442 parse_vc_action_meter_color_type(struct context *ctx, const struct token *token,
5443 const char *str, unsigned int len,
5444 void *buf, unsigned int size)
5446 struct rte_flow_action *action_data;
5447 struct rte_flow_action_meter_color *conf;
5448 enum rte_color color;
5452 /* Token name must match. */
5453 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5455 switch (ctx->curr) {
5456 case ACTION_METER_COLOR_GREEN:
5457 color = RTE_COLOR_GREEN;
5459 case ACTION_METER_COLOR_YELLOW:
5460 color = RTE_COLOR_YELLOW;
5462 case ACTION_METER_COLOR_RED:
5463 color = RTE_COLOR_RED;
5471 action_data = ctx->object;
5472 conf = (struct rte_flow_action_meter_color *)
5473 (uintptr_t)(action_data->conf);
5474 conf->color = color;
5478 /** Parse RSS action. */
5480 parse_vc_action_rss(struct context *ctx, const struct token *token,
5481 const char *str, unsigned int len,
5482 void *buf, unsigned int size)
5484 struct buffer *out = buf;
5485 struct rte_flow_action *action;
5486 struct action_rss_data *action_rss_data;
5490 ret = parse_vc(ctx, token, str, len, buf, size);
5493 /* Nothing else to do if there is no buffer. */
5496 if (!out->args.vc.actions_n)
5498 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5499 /* Point to selected object. */
5500 ctx->object = out->args.vc.data;
5501 ctx->objmask = NULL;
5502 /* Set up default configuration. */
5503 action_rss_data = ctx->object;
5504 *action_rss_data = (struct action_rss_data){
5505 .conf = (struct rte_flow_action_rss){
5506 .func = RTE_ETH_HASH_FUNCTION_DEFAULT,
5510 .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM),
5512 .queue = action_rss_data->queue,
5516 for (i = 0; i < action_rss_data->conf.queue_num; ++i)
5517 action_rss_data->queue[i] = i;
5518 action->conf = &action_rss_data->conf;
5523 * Parse func field for RSS action.
5525 * The RTE_ETH_HASH_FUNCTION_* value to assign is derived from the
5526 * ACTION_RSS_FUNC_* index that called this function.
5529 parse_vc_action_rss_func(struct context *ctx, const struct token *token,
5530 const char *str, unsigned int len,
5531 void *buf, unsigned int size)
5533 struct action_rss_data *action_rss_data;
5534 enum rte_eth_hash_function func;
5538 /* Token name must match. */
5539 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5541 switch (ctx->curr) {
5542 case ACTION_RSS_FUNC_DEFAULT:
5543 func = RTE_ETH_HASH_FUNCTION_DEFAULT;
5545 case ACTION_RSS_FUNC_TOEPLITZ:
5546 func = RTE_ETH_HASH_FUNCTION_TOEPLITZ;
5548 case ACTION_RSS_FUNC_SIMPLE_XOR:
5549 func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
5551 case ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ:
5552 func = RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
5559 action_rss_data = ctx->object;
5560 action_rss_data->conf.func = func;
5565 * Parse type field for RSS action.
5567 * Valid tokens are type field names and the "end" token.
5570 parse_vc_action_rss_type(struct context *ctx, const struct token *token,
5571 const char *str, unsigned int len,
5572 void *buf, unsigned int size)
5574 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE);
5575 struct action_rss_data *action_rss_data;
5581 if (ctx->curr != ACTION_RSS_TYPE)
5583 if (!(ctx->objdata >> 16) && ctx->object) {
5584 action_rss_data = ctx->object;
5585 action_rss_data->conf.types = 0;
5587 if (!strcmp_partial("end", str, len)) {
5588 ctx->objdata &= 0xffff;
5591 for (i = 0; rss_type_table[i].str; ++i)
5592 if (!strcmp_partial(rss_type_table[i].str, str, len))
5594 if (!rss_type_table[i].str)
5596 ctx->objdata = 1 << 16 | (ctx->objdata & 0xffff);
5598 if (ctx->next_num == RTE_DIM(ctx->next))
5600 ctx->next[ctx->next_num++] = next;
5603 action_rss_data = ctx->object;
5604 action_rss_data->conf.types |= rss_type_table[i].rss_type;
5609 * Parse queue field for RSS action.
5611 * Valid tokens are queue indices and the "end" token.
5614 parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
5615 const char *str, unsigned int len,
5616 void *buf, unsigned int size)
5618 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE);
5619 struct action_rss_data *action_rss_data;
5620 const struct arg *arg;
5627 if (ctx->curr != ACTION_RSS_QUEUE)
5629 i = ctx->objdata >> 16;
5630 if (!strcmp_partial("end", str, len)) {
5631 ctx->objdata &= 0xffff;
5634 if (i >= ACTION_RSS_QUEUE_NUM)
5636 arg = ARGS_ENTRY_ARB(offsetof(struct action_rss_data, queue) +
5637 i * sizeof(action_rss_data->queue[i]),
5638 sizeof(action_rss_data->queue[i]));
5639 if (push_args(ctx, arg))
5641 ret = parse_int(ctx, token, str, len, NULL, 0);
5647 ctx->objdata = i << 16 | (ctx->objdata & 0xffff);
5649 if (ctx->next_num == RTE_DIM(ctx->next))
5651 ctx->next[ctx->next_num++] = next;
5655 action_rss_data = ctx->object;
5656 action_rss_data->conf.queue_num = i;
5657 action_rss_data->conf.queue = i ? action_rss_data->queue : NULL;
5661 /** Setup VXLAN encap configuration. */
5663 parse_setup_vxlan_encap_data(struct action_vxlan_encap_data *action_vxlan_encap_data)
5665 /* Set up default configuration. */
5666 *action_vxlan_encap_data = (struct action_vxlan_encap_data){
5667 .conf = (struct rte_flow_action_vxlan_encap){
5668 .definition = action_vxlan_encap_data->items,
5672 .type = RTE_FLOW_ITEM_TYPE_ETH,
5673 .spec = &action_vxlan_encap_data->item_eth,
5674 .mask = &rte_flow_item_eth_mask,
5677 .type = RTE_FLOW_ITEM_TYPE_VLAN,
5678 .spec = &action_vxlan_encap_data->item_vlan,
5679 .mask = &rte_flow_item_vlan_mask,
5682 .type = RTE_FLOW_ITEM_TYPE_IPV4,
5683 .spec = &action_vxlan_encap_data->item_ipv4,
5684 .mask = &rte_flow_item_ipv4_mask,
5687 .type = RTE_FLOW_ITEM_TYPE_UDP,
5688 .spec = &action_vxlan_encap_data->item_udp,
5689 .mask = &rte_flow_item_udp_mask,
5692 .type = RTE_FLOW_ITEM_TYPE_VXLAN,
5693 .spec = &action_vxlan_encap_data->item_vxlan,
5694 .mask = &rte_flow_item_vxlan_mask,
5697 .type = RTE_FLOW_ITEM_TYPE_END,
5702 .tci = vxlan_encap_conf.vlan_tci,
5706 .src_addr = vxlan_encap_conf.ipv4_src,
5707 .dst_addr = vxlan_encap_conf.ipv4_dst,
5710 .src_port = vxlan_encap_conf.udp_src,
5711 .dst_port = vxlan_encap_conf.udp_dst,
5713 .item_vxlan.flags = 0,
5715 memcpy(action_vxlan_encap_data->item_eth.dst.addr_bytes,
5716 vxlan_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5717 memcpy(action_vxlan_encap_data->item_eth.src.addr_bytes,
5718 vxlan_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5719 if (!vxlan_encap_conf.select_ipv4) {
5720 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.src_addr,
5721 &vxlan_encap_conf.ipv6_src,
5722 sizeof(vxlan_encap_conf.ipv6_src));
5723 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.dst_addr,
5724 &vxlan_encap_conf.ipv6_dst,
5725 sizeof(vxlan_encap_conf.ipv6_dst));
5726 action_vxlan_encap_data->items[2] = (struct rte_flow_item){
5727 .type = RTE_FLOW_ITEM_TYPE_IPV6,
5728 .spec = &action_vxlan_encap_data->item_ipv6,
5729 .mask = &rte_flow_item_ipv6_mask,
5732 if (!vxlan_encap_conf.select_vlan)
5733 action_vxlan_encap_data->items[1].type =
5734 RTE_FLOW_ITEM_TYPE_VOID;
5735 if (vxlan_encap_conf.select_tos_ttl) {
5736 if (vxlan_encap_conf.select_ipv4) {
5737 static struct rte_flow_item_ipv4 ipv4_mask_tos;
5739 memcpy(&ipv4_mask_tos, &rte_flow_item_ipv4_mask,
5740 sizeof(ipv4_mask_tos));
5741 ipv4_mask_tos.hdr.type_of_service = 0xff;
5742 ipv4_mask_tos.hdr.time_to_live = 0xff;
5743 action_vxlan_encap_data->item_ipv4.hdr.type_of_service =
5744 vxlan_encap_conf.ip_tos;
5745 action_vxlan_encap_data->item_ipv4.hdr.time_to_live =
5746 vxlan_encap_conf.ip_ttl;
5747 action_vxlan_encap_data->items[2].mask =
5750 static struct rte_flow_item_ipv6 ipv6_mask_tos;
5752 memcpy(&ipv6_mask_tos, &rte_flow_item_ipv6_mask,
5753 sizeof(ipv6_mask_tos));
5754 ipv6_mask_tos.hdr.vtc_flow |=
5755 RTE_BE32(0xfful << RTE_IPV6_HDR_TC_SHIFT);
5756 ipv6_mask_tos.hdr.hop_limits = 0xff;
5757 action_vxlan_encap_data->item_ipv6.hdr.vtc_flow |=
5759 ((uint32_t)vxlan_encap_conf.ip_tos <<
5760 RTE_IPV6_HDR_TC_SHIFT);
5761 action_vxlan_encap_data->item_ipv6.hdr.hop_limits =
5762 vxlan_encap_conf.ip_ttl;
5763 action_vxlan_encap_data->items[2].mask =
5767 memcpy(action_vxlan_encap_data->item_vxlan.vni, vxlan_encap_conf.vni,
5768 RTE_DIM(vxlan_encap_conf.vni));
5772 /** Parse VXLAN encap action. */
5774 parse_vc_action_vxlan_encap(struct context *ctx, const struct token *token,
5775 const char *str, unsigned int len,
5776 void *buf, unsigned int size)
5778 struct buffer *out = buf;
5779 struct rte_flow_action *action;
5780 struct action_vxlan_encap_data *action_vxlan_encap_data;
5783 ret = parse_vc(ctx, token, str, len, buf, size);
5786 /* Nothing else to do if there is no buffer. */
5789 if (!out->args.vc.actions_n)
5791 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5792 /* Point to selected object. */
5793 ctx->object = out->args.vc.data;
5794 ctx->objmask = NULL;
5795 action_vxlan_encap_data = ctx->object;
5796 parse_setup_vxlan_encap_data(action_vxlan_encap_data);
5797 action->conf = &action_vxlan_encap_data->conf;
5801 /** Setup NVGRE encap configuration. */
5803 parse_setup_nvgre_encap_data(struct action_nvgre_encap_data *action_nvgre_encap_data)
5805 /* Set up default configuration. */
5806 *action_nvgre_encap_data = (struct action_nvgre_encap_data){
5807 .conf = (struct rte_flow_action_nvgre_encap){
5808 .definition = action_nvgre_encap_data->items,
5812 .type = RTE_FLOW_ITEM_TYPE_ETH,
5813 .spec = &action_nvgre_encap_data->item_eth,
5814 .mask = &rte_flow_item_eth_mask,
5817 .type = RTE_FLOW_ITEM_TYPE_VLAN,
5818 .spec = &action_nvgre_encap_data->item_vlan,
5819 .mask = &rte_flow_item_vlan_mask,
5822 .type = RTE_FLOW_ITEM_TYPE_IPV4,
5823 .spec = &action_nvgre_encap_data->item_ipv4,
5824 .mask = &rte_flow_item_ipv4_mask,
5827 .type = RTE_FLOW_ITEM_TYPE_NVGRE,
5828 .spec = &action_nvgre_encap_data->item_nvgre,
5829 .mask = &rte_flow_item_nvgre_mask,
5832 .type = RTE_FLOW_ITEM_TYPE_END,
5837 .tci = nvgre_encap_conf.vlan_tci,
5841 .src_addr = nvgre_encap_conf.ipv4_src,
5842 .dst_addr = nvgre_encap_conf.ipv4_dst,
5844 .item_nvgre.c_k_s_rsvd0_ver = RTE_BE16(0x2000),
5845 .item_nvgre.protocol = RTE_BE16(RTE_ETHER_TYPE_TEB),
5846 .item_nvgre.flow_id = 0,
5848 memcpy(action_nvgre_encap_data->item_eth.dst.addr_bytes,
5849 nvgre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5850 memcpy(action_nvgre_encap_data->item_eth.src.addr_bytes,
5851 nvgre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5852 if (!nvgre_encap_conf.select_ipv4) {
5853 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.src_addr,
5854 &nvgre_encap_conf.ipv6_src,
5855 sizeof(nvgre_encap_conf.ipv6_src));
5856 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.dst_addr,
5857 &nvgre_encap_conf.ipv6_dst,
5858 sizeof(nvgre_encap_conf.ipv6_dst));
5859 action_nvgre_encap_data->items[2] = (struct rte_flow_item){
5860 .type = RTE_FLOW_ITEM_TYPE_IPV6,
5861 .spec = &action_nvgre_encap_data->item_ipv6,
5862 .mask = &rte_flow_item_ipv6_mask,
5865 if (!nvgre_encap_conf.select_vlan)
5866 action_nvgre_encap_data->items[1].type =
5867 RTE_FLOW_ITEM_TYPE_VOID;
5868 memcpy(action_nvgre_encap_data->item_nvgre.tni, nvgre_encap_conf.tni,
5869 RTE_DIM(nvgre_encap_conf.tni));
5873 /** Parse NVGRE encap action. */
5875 parse_vc_action_nvgre_encap(struct context *ctx, const struct token *token,
5876 const char *str, unsigned int len,
5877 void *buf, unsigned int size)
5879 struct buffer *out = buf;
5880 struct rte_flow_action *action;
5881 struct action_nvgre_encap_data *action_nvgre_encap_data;
5884 ret = parse_vc(ctx, token, str, len, buf, size);
5887 /* Nothing else to do if there is no buffer. */
5890 if (!out->args.vc.actions_n)
5892 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5893 /* Point to selected object. */
5894 ctx->object = out->args.vc.data;
5895 ctx->objmask = NULL;
5896 action_nvgre_encap_data = ctx->object;
5897 parse_setup_nvgre_encap_data(action_nvgre_encap_data);
5898 action->conf = &action_nvgre_encap_data->conf;
5902 /** Parse l2 encap action. */
5904 parse_vc_action_l2_encap(struct context *ctx, const struct token *token,
5905 const char *str, unsigned int len,
5906 void *buf, unsigned int size)
5908 struct buffer *out = buf;
5909 struct rte_flow_action *action;
5910 struct action_raw_encap_data *action_encap_data;
5911 struct rte_flow_item_eth eth = { .type = 0, };
5912 struct rte_flow_item_vlan vlan = {
5913 .tci = mplsoudp_encap_conf.vlan_tci,
5919 ret = parse_vc(ctx, token, str, len, buf, size);
5922 /* Nothing else to do if there is no buffer. */
5925 if (!out->args.vc.actions_n)
5927 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5928 /* Point to selected object. */
5929 ctx->object = out->args.vc.data;
5930 ctx->objmask = NULL;
5931 /* Copy the headers to the buffer. */
5932 action_encap_data = ctx->object;
5933 *action_encap_data = (struct action_raw_encap_data) {
5934 .conf = (struct rte_flow_action_raw_encap){
5935 .data = action_encap_data->data,
5939 header = action_encap_data->data;
5940 if (l2_encap_conf.select_vlan)
5941 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5942 else if (l2_encap_conf.select_ipv4)
5943 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5945 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5946 memcpy(eth.dst.addr_bytes,
5947 l2_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5948 memcpy(eth.src.addr_bytes,
5949 l2_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5950 memcpy(header, ð, sizeof(eth));
5951 header += sizeof(eth);
5952 if (l2_encap_conf.select_vlan) {
5953 if (l2_encap_conf.select_ipv4)
5954 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5956 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5957 memcpy(header, &vlan, sizeof(vlan));
5958 header += sizeof(vlan);
5960 action_encap_data->conf.size = header -
5961 action_encap_data->data;
5962 action->conf = &action_encap_data->conf;
5966 /** Parse l2 decap action. */
5968 parse_vc_action_l2_decap(struct context *ctx, const struct token *token,
5969 const char *str, unsigned int len,
5970 void *buf, unsigned int size)
5972 struct buffer *out = buf;
5973 struct rte_flow_action *action;
5974 struct action_raw_decap_data *action_decap_data;
5975 struct rte_flow_item_eth eth = { .type = 0, };
5976 struct rte_flow_item_vlan vlan = {
5977 .tci = mplsoudp_encap_conf.vlan_tci,
5983 ret = parse_vc(ctx, token, str, len, buf, size);
5986 /* Nothing else to do if there is no buffer. */
5989 if (!out->args.vc.actions_n)
5991 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5992 /* Point to selected object. */
5993 ctx->object = out->args.vc.data;
5994 ctx->objmask = NULL;
5995 /* Copy the headers to the buffer. */
5996 action_decap_data = ctx->object;
5997 *action_decap_data = (struct action_raw_decap_data) {
5998 .conf = (struct rte_flow_action_raw_decap){
5999 .data = action_decap_data->data,
6003 header = action_decap_data->data;
6004 if (l2_decap_conf.select_vlan)
6005 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
6006 memcpy(header, ð, sizeof(eth));
6007 header += sizeof(eth);
6008 if (l2_decap_conf.select_vlan) {
6009 memcpy(header, &vlan, sizeof(vlan));
6010 header += sizeof(vlan);
6012 action_decap_data->conf.size = header -
6013 action_decap_data->data;
6014 action->conf = &action_decap_data->conf;
6018 #define ETHER_TYPE_MPLS_UNICAST 0x8847
6020 /** Parse MPLSOGRE encap action. */
6022 parse_vc_action_mplsogre_encap(struct context *ctx, const struct token *token,
6023 const char *str, unsigned int len,
6024 void *buf, unsigned int size)
6026 struct buffer *out = buf;
6027 struct rte_flow_action *action;
6028 struct action_raw_encap_data *action_encap_data;
6029 struct rte_flow_item_eth eth = { .type = 0, };
6030 struct rte_flow_item_vlan vlan = {
6031 .tci = mplsogre_encap_conf.vlan_tci,
6034 struct rte_flow_item_ipv4 ipv4 = {
6036 .src_addr = mplsogre_encap_conf.ipv4_src,
6037 .dst_addr = mplsogre_encap_conf.ipv4_dst,
6038 .next_proto_id = IPPROTO_GRE,
6039 .version_ihl = RTE_IPV4_VHL_DEF,
6040 .time_to_live = IPDEFTTL,
6043 struct rte_flow_item_ipv6 ipv6 = {
6045 .proto = IPPROTO_GRE,
6046 .hop_limits = IPDEFTTL,
6049 struct rte_flow_item_gre gre = {
6050 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
6052 struct rte_flow_item_mpls mpls = {
6058 ret = parse_vc(ctx, token, str, len, buf, size);
6061 /* Nothing else to do if there is no buffer. */
6064 if (!out->args.vc.actions_n)
6066 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6067 /* Point to selected object. */
6068 ctx->object = out->args.vc.data;
6069 ctx->objmask = NULL;
6070 /* Copy the headers to the buffer. */
6071 action_encap_data = ctx->object;
6072 *action_encap_data = (struct action_raw_encap_data) {
6073 .conf = (struct rte_flow_action_raw_encap){
6074 .data = action_encap_data->data,
6079 header = action_encap_data->data;
6080 if (mplsogre_encap_conf.select_vlan)
6081 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
6082 else if (mplsogre_encap_conf.select_ipv4)
6083 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6085 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6086 memcpy(eth.dst.addr_bytes,
6087 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
6088 memcpy(eth.src.addr_bytes,
6089 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
6090 memcpy(header, ð, sizeof(eth));
6091 header += sizeof(eth);
6092 if (mplsogre_encap_conf.select_vlan) {
6093 if (mplsogre_encap_conf.select_ipv4)
6094 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6096 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6097 memcpy(header, &vlan, sizeof(vlan));
6098 header += sizeof(vlan);
6100 if (mplsogre_encap_conf.select_ipv4) {
6101 memcpy(header, &ipv4, sizeof(ipv4));
6102 header += sizeof(ipv4);
6104 memcpy(&ipv6.hdr.src_addr,
6105 &mplsogre_encap_conf.ipv6_src,
6106 sizeof(mplsogre_encap_conf.ipv6_src));
6107 memcpy(&ipv6.hdr.dst_addr,
6108 &mplsogre_encap_conf.ipv6_dst,
6109 sizeof(mplsogre_encap_conf.ipv6_dst));
6110 memcpy(header, &ipv6, sizeof(ipv6));
6111 header += sizeof(ipv6);
6113 memcpy(header, &gre, sizeof(gre));
6114 header += sizeof(gre);
6115 memcpy(mpls.label_tc_s, mplsogre_encap_conf.label,
6116 RTE_DIM(mplsogre_encap_conf.label));
6117 mpls.label_tc_s[2] |= 0x1;
6118 memcpy(header, &mpls, sizeof(mpls));
6119 header += sizeof(mpls);
6120 action_encap_data->conf.size = header -
6121 action_encap_data->data;
6122 action->conf = &action_encap_data->conf;
6126 /** Parse MPLSOGRE decap action. */
6128 parse_vc_action_mplsogre_decap(struct context *ctx, const struct token *token,
6129 const char *str, unsigned int len,
6130 void *buf, unsigned int size)
6132 struct buffer *out = buf;
6133 struct rte_flow_action *action;
6134 struct action_raw_decap_data *action_decap_data;
6135 struct rte_flow_item_eth eth = { .type = 0, };
6136 struct rte_flow_item_vlan vlan = {.tci = 0};
6137 struct rte_flow_item_ipv4 ipv4 = {
6139 .next_proto_id = IPPROTO_GRE,
6142 struct rte_flow_item_ipv6 ipv6 = {
6144 .proto = IPPROTO_GRE,
6147 struct rte_flow_item_gre gre = {
6148 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
6150 struct rte_flow_item_mpls mpls;
6154 ret = parse_vc(ctx, token, str, len, buf, size);
6157 /* Nothing else to do if there is no buffer. */
6160 if (!out->args.vc.actions_n)
6162 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6163 /* Point to selected object. */
6164 ctx->object = out->args.vc.data;
6165 ctx->objmask = NULL;
6166 /* Copy the headers to the buffer. */
6167 action_decap_data = ctx->object;
6168 *action_decap_data = (struct action_raw_decap_data) {
6169 .conf = (struct rte_flow_action_raw_decap){
6170 .data = action_decap_data->data,
6174 header = action_decap_data->data;
6175 if (mplsogre_decap_conf.select_vlan)
6176 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
6177 else if (mplsogre_encap_conf.select_ipv4)
6178 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6180 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6181 memcpy(eth.dst.addr_bytes,
6182 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
6183 memcpy(eth.src.addr_bytes,
6184 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
6185 memcpy(header, ð, sizeof(eth));
6186 header += sizeof(eth);
6187 if (mplsogre_encap_conf.select_vlan) {
6188 if (mplsogre_encap_conf.select_ipv4)
6189 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6191 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6192 memcpy(header, &vlan, sizeof(vlan));
6193 header += sizeof(vlan);
6195 if (mplsogre_encap_conf.select_ipv4) {
6196 memcpy(header, &ipv4, sizeof(ipv4));
6197 header += sizeof(ipv4);
6199 memcpy(header, &ipv6, sizeof(ipv6));
6200 header += sizeof(ipv6);
6202 memcpy(header, &gre, sizeof(gre));
6203 header += sizeof(gre);
6204 memset(&mpls, 0, sizeof(mpls));
6205 memcpy(header, &mpls, sizeof(mpls));
6206 header += sizeof(mpls);
6207 action_decap_data->conf.size = header -
6208 action_decap_data->data;
6209 action->conf = &action_decap_data->conf;
6213 /** Parse MPLSOUDP encap action. */
6215 parse_vc_action_mplsoudp_encap(struct context *ctx, const struct token *token,
6216 const char *str, unsigned int len,
6217 void *buf, unsigned int size)
6219 struct buffer *out = buf;
6220 struct rte_flow_action *action;
6221 struct action_raw_encap_data *action_encap_data;
6222 struct rte_flow_item_eth eth = { .type = 0, };
6223 struct rte_flow_item_vlan vlan = {
6224 .tci = mplsoudp_encap_conf.vlan_tci,
6227 struct rte_flow_item_ipv4 ipv4 = {
6229 .src_addr = mplsoudp_encap_conf.ipv4_src,
6230 .dst_addr = mplsoudp_encap_conf.ipv4_dst,
6231 .next_proto_id = IPPROTO_UDP,
6232 .version_ihl = RTE_IPV4_VHL_DEF,
6233 .time_to_live = IPDEFTTL,
6236 struct rte_flow_item_ipv6 ipv6 = {
6238 .proto = IPPROTO_UDP,
6239 .hop_limits = IPDEFTTL,
6242 struct rte_flow_item_udp udp = {
6244 .src_port = mplsoudp_encap_conf.udp_src,
6245 .dst_port = mplsoudp_encap_conf.udp_dst,
6248 struct rte_flow_item_mpls mpls;
6252 ret = parse_vc(ctx, token, str, len, buf, size);
6255 /* Nothing else to do if there is no buffer. */
6258 if (!out->args.vc.actions_n)
6260 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6261 /* Point to selected object. */
6262 ctx->object = out->args.vc.data;
6263 ctx->objmask = NULL;
6264 /* Copy the headers to the buffer. */
6265 action_encap_data = ctx->object;
6266 *action_encap_data = (struct action_raw_encap_data) {
6267 .conf = (struct rte_flow_action_raw_encap){
6268 .data = action_encap_data->data,
6273 header = action_encap_data->data;
6274 if (mplsoudp_encap_conf.select_vlan)
6275 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
6276 else if (mplsoudp_encap_conf.select_ipv4)
6277 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6279 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6280 memcpy(eth.dst.addr_bytes,
6281 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
6282 memcpy(eth.src.addr_bytes,
6283 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
6284 memcpy(header, ð, sizeof(eth));
6285 header += sizeof(eth);
6286 if (mplsoudp_encap_conf.select_vlan) {
6287 if (mplsoudp_encap_conf.select_ipv4)
6288 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6290 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6291 memcpy(header, &vlan, sizeof(vlan));
6292 header += sizeof(vlan);
6294 if (mplsoudp_encap_conf.select_ipv4) {
6295 memcpy(header, &ipv4, sizeof(ipv4));
6296 header += sizeof(ipv4);
6298 memcpy(&ipv6.hdr.src_addr,
6299 &mplsoudp_encap_conf.ipv6_src,
6300 sizeof(mplsoudp_encap_conf.ipv6_src));
6301 memcpy(&ipv6.hdr.dst_addr,
6302 &mplsoudp_encap_conf.ipv6_dst,
6303 sizeof(mplsoudp_encap_conf.ipv6_dst));
6304 memcpy(header, &ipv6, sizeof(ipv6));
6305 header += sizeof(ipv6);
6307 memcpy(header, &udp, sizeof(udp));
6308 header += sizeof(udp);
6309 memcpy(mpls.label_tc_s, mplsoudp_encap_conf.label,
6310 RTE_DIM(mplsoudp_encap_conf.label));
6311 mpls.label_tc_s[2] |= 0x1;
6312 memcpy(header, &mpls, sizeof(mpls));
6313 header += sizeof(mpls);
6314 action_encap_data->conf.size = header -
6315 action_encap_data->data;
6316 action->conf = &action_encap_data->conf;
6320 /** Parse MPLSOUDP decap action. */
6322 parse_vc_action_mplsoudp_decap(struct context *ctx, const struct token *token,
6323 const char *str, unsigned int len,
6324 void *buf, unsigned int size)
6326 struct buffer *out = buf;
6327 struct rte_flow_action *action;
6328 struct action_raw_decap_data *action_decap_data;
6329 struct rte_flow_item_eth eth = { .type = 0, };
6330 struct rte_flow_item_vlan vlan = {.tci = 0};
6331 struct rte_flow_item_ipv4 ipv4 = {
6333 .next_proto_id = IPPROTO_UDP,
6336 struct rte_flow_item_ipv6 ipv6 = {
6338 .proto = IPPROTO_UDP,
6341 struct rte_flow_item_udp udp = {
6343 .dst_port = rte_cpu_to_be_16(6635),
6346 struct rte_flow_item_mpls mpls;
6350 ret = parse_vc(ctx, token, str, len, buf, size);
6353 /* Nothing else to do if there is no buffer. */
6356 if (!out->args.vc.actions_n)
6358 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6359 /* Point to selected object. */
6360 ctx->object = out->args.vc.data;
6361 ctx->objmask = NULL;
6362 /* Copy the headers to the buffer. */
6363 action_decap_data = ctx->object;
6364 *action_decap_data = (struct action_raw_decap_data) {
6365 .conf = (struct rte_flow_action_raw_decap){
6366 .data = action_decap_data->data,
6370 header = action_decap_data->data;
6371 if (mplsoudp_decap_conf.select_vlan)
6372 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
6373 else if (mplsoudp_encap_conf.select_ipv4)
6374 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6376 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6377 memcpy(eth.dst.addr_bytes,
6378 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
6379 memcpy(eth.src.addr_bytes,
6380 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
6381 memcpy(header, ð, sizeof(eth));
6382 header += sizeof(eth);
6383 if (mplsoudp_encap_conf.select_vlan) {
6384 if (mplsoudp_encap_conf.select_ipv4)
6385 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6387 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6388 memcpy(header, &vlan, sizeof(vlan));
6389 header += sizeof(vlan);
6391 if (mplsoudp_encap_conf.select_ipv4) {
6392 memcpy(header, &ipv4, sizeof(ipv4));
6393 header += sizeof(ipv4);
6395 memcpy(header, &ipv6, sizeof(ipv6));
6396 header += sizeof(ipv6);
6398 memcpy(header, &udp, sizeof(udp));
6399 header += sizeof(udp);
6400 memset(&mpls, 0, sizeof(mpls));
6401 memcpy(header, &mpls, sizeof(mpls));
6402 header += sizeof(mpls);
6403 action_decap_data->conf.size = header -
6404 action_decap_data->data;
6405 action->conf = &action_decap_data->conf;
6410 parse_vc_action_raw_decap_index(struct context *ctx, const struct token *token,
6411 const char *str, unsigned int len, void *buf,
6414 struct action_raw_decap_data *action_raw_decap_data;
6415 struct rte_flow_action *action;
6416 const struct arg *arg;
6417 struct buffer *out = buf;
6421 RTE_SET_USED(token);
6424 arg = ARGS_ENTRY_ARB_BOUNDED
6425 (offsetof(struct action_raw_decap_data, idx),
6426 sizeof(((struct action_raw_decap_data *)0)->idx),
6427 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
6428 if (push_args(ctx, arg))
6430 ret = parse_int(ctx, token, str, len, NULL, 0);
6437 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6438 action_raw_decap_data = ctx->object;
6439 idx = action_raw_decap_data->idx;
6440 action_raw_decap_data->conf.data = raw_decap_confs[idx].data;
6441 action_raw_decap_data->conf.size = raw_decap_confs[idx].size;
6442 action->conf = &action_raw_decap_data->conf;
6448 parse_vc_action_raw_encap_index(struct context *ctx, const struct token *token,
6449 const char *str, unsigned int len, void *buf,
6452 struct action_raw_encap_data *action_raw_encap_data;
6453 struct rte_flow_action *action;
6454 const struct arg *arg;
6455 struct buffer *out = buf;
6459 RTE_SET_USED(token);
6462 if (ctx->curr != ACTION_RAW_ENCAP_INDEX_VALUE)
6464 arg = ARGS_ENTRY_ARB_BOUNDED
6465 (offsetof(struct action_raw_encap_data, idx),
6466 sizeof(((struct action_raw_encap_data *)0)->idx),
6467 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
6468 if (push_args(ctx, arg))
6470 ret = parse_int(ctx, token, str, len, NULL, 0);
6477 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6478 action_raw_encap_data = ctx->object;
6479 idx = action_raw_encap_data->idx;
6480 action_raw_encap_data->conf.data = raw_encap_confs[idx].data;
6481 action_raw_encap_data->conf.size = raw_encap_confs[idx].size;
6482 action_raw_encap_data->conf.preserve = NULL;
6483 action->conf = &action_raw_encap_data->conf;
6488 parse_vc_action_raw_encap(struct context *ctx, const struct token *token,
6489 const char *str, unsigned int len, void *buf,
6492 struct buffer *out = buf;
6493 struct rte_flow_action *action;
6494 struct action_raw_encap_data *action_raw_encap_data = NULL;
6497 ret = parse_vc(ctx, token, str, len, buf, size);
6500 /* Nothing else to do if there is no buffer. */
6503 if (!out->args.vc.actions_n)
6505 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6506 /* Point to selected object. */
6507 ctx->object = out->args.vc.data;
6508 ctx->objmask = NULL;
6509 /* Copy the headers to the buffer. */
6510 action_raw_encap_data = ctx->object;
6511 action_raw_encap_data->conf.data = raw_encap_confs[0].data;
6512 action_raw_encap_data->conf.preserve = NULL;
6513 action_raw_encap_data->conf.size = raw_encap_confs[0].size;
6514 action->conf = &action_raw_encap_data->conf;
6519 parse_vc_action_raw_decap(struct context *ctx, const struct token *token,
6520 const char *str, unsigned int len, void *buf,
6523 struct buffer *out = buf;
6524 struct rte_flow_action *action;
6525 struct action_raw_decap_data *action_raw_decap_data = NULL;
6528 ret = parse_vc(ctx, token, str, len, buf, size);
6531 /* Nothing else to do if there is no buffer. */
6534 if (!out->args.vc.actions_n)
6536 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6537 /* Point to selected object. */
6538 ctx->object = out->args.vc.data;
6539 ctx->objmask = NULL;
6540 /* Copy the headers to the buffer. */
6541 action_raw_decap_data = ctx->object;
6542 action_raw_decap_data->conf.data = raw_decap_confs[0].data;
6543 action_raw_decap_data->conf.size = raw_decap_confs[0].size;
6544 action->conf = &action_raw_decap_data->conf;
6549 parse_vc_action_set_meta(struct context *ctx, const struct token *token,
6550 const char *str, unsigned int len, void *buf,
6555 ret = parse_vc(ctx, token, str, len, buf, size);
6558 ret = rte_flow_dynf_metadata_register();
6565 parse_vc_action_sample(struct context *ctx, const struct token *token,
6566 const char *str, unsigned int len, void *buf,
6569 struct buffer *out = buf;
6570 struct rte_flow_action *action;
6571 struct action_sample_data *action_sample_data = NULL;
6572 static struct rte_flow_action end_action = {
6573 RTE_FLOW_ACTION_TYPE_END, 0
6577 ret = parse_vc(ctx, token, str, len, buf, size);
6580 /* Nothing else to do if there is no buffer. */
6583 if (!out->args.vc.actions_n)
6585 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6586 /* Point to selected object. */
6587 ctx->object = out->args.vc.data;
6588 ctx->objmask = NULL;
6589 /* Copy the headers to the buffer. */
6590 action_sample_data = ctx->object;
6591 action_sample_data->conf.actions = &end_action;
6592 action->conf = &action_sample_data->conf;
6597 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
6598 const char *str, unsigned int len, void *buf,
6601 struct action_sample_data *action_sample_data;
6602 struct rte_flow_action *action;
6603 const struct arg *arg;
6604 struct buffer *out = buf;
6608 RTE_SET_USED(token);
6611 if (ctx->curr != ACTION_SAMPLE_INDEX_VALUE)
6613 arg = ARGS_ENTRY_ARB_BOUNDED
6614 (offsetof(struct action_sample_data, idx),
6615 sizeof(((struct action_sample_data *)0)->idx),
6616 0, RAW_SAMPLE_CONFS_MAX_NUM - 1);
6617 if (push_args(ctx, arg))
6619 ret = parse_int(ctx, token, str, len, NULL, 0);
6626 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6627 action_sample_data = ctx->object;
6628 idx = action_sample_data->idx;
6629 action_sample_data->conf.actions = raw_sample_confs[idx].data;
6630 action->conf = &action_sample_data->conf;
6634 /** Parse operation for modify_field command. */
6636 parse_vc_modify_field_op(struct context *ctx, const struct token *token,
6637 const char *str, unsigned int len, void *buf,
6640 struct rte_flow_action_modify_field *action_modify_field;
6646 if (ctx->curr != ACTION_MODIFY_FIELD_OP_VALUE)
6648 for (i = 0; modify_field_ops[i]; ++i)
6649 if (!strcmp_partial(modify_field_ops[i], str, len))
6651 if (!modify_field_ops[i])
6655 action_modify_field = ctx->object;
6656 action_modify_field->operation = (enum rte_flow_modify_op)i;
6660 /** Parse id for modify_field command. */
6662 parse_vc_modify_field_id(struct context *ctx, const struct token *token,
6663 const char *str, unsigned int len, void *buf,
6666 struct rte_flow_action_modify_field *action_modify_field;
6672 if (ctx->curr != ACTION_MODIFY_FIELD_DST_TYPE_VALUE &&
6673 ctx->curr != ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)
6675 for (i = 0; modify_field_ids[i]; ++i)
6676 if (!strcmp_partial(modify_field_ids[i], str, len))
6678 if (!modify_field_ids[i])
6682 action_modify_field = ctx->object;
6683 if (ctx->curr == ACTION_MODIFY_FIELD_DST_TYPE_VALUE)
6684 action_modify_field->dst.field = (enum rte_flow_field_id)i;
6686 action_modify_field->src.field = (enum rte_flow_field_id)i;
6690 /** Parse the conntrack update, not a rte_flow_action. */
6692 parse_vc_action_conntrack_update(struct context *ctx, const struct token *token,
6693 const char *str, unsigned int len, void *buf,
6696 struct buffer *out = buf;
6697 struct rte_flow_modify_conntrack *ct_modify = NULL;
6700 if (ctx->curr != ACTION_CONNTRACK_UPDATE_CTX &&
6701 ctx->curr != ACTION_CONNTRACK_UPDATE_DIR)
6703 /* Token name must match. */
6704 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6706 /* Nothing else to do if there is no buffer. */
6709 ct_modify = (struct rte_flow_modify_conntrack *)out->args.vc.data;
6710 if (ctx->curr == ACTION_CONNTRACK_UPDATE_DIR) {
6711 ct_modify->new_ct.is_original_dir =
6712 conntrack_context.is_original_dir;
6713 ct_modify->direction = 1;
6717 old_dir = ct_modify->new_ct.is_original_dir;
6718 memcpy(&ct_modify->new_ct, &conntrack_context,
6719 sizeof(conntrack_context));
6720 ct_modify->new_ct.is_original_dir = old_dir;
6721 ct_modify->state = 1;
6726 /** Parse tokens for destroy command. */
6728 parse_destroy(struct context *ctx, const struct token *token,
6729 const char *str, unsigned int len,
6730 void *buf, unsigned int size)
6732 struct buffer *out = buf;
6734 /* Token name must match. */
6735 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6737 /* Nothing else to do if there is no buffer. */
6740 if (!out->command) {
6741 if (ctx->curr != DESTROY)
6743 if (sizeof(*out) > size)
6745 out->command = ctx->curr;
6748 ctx->objmask = NULL;
6749 out->args.destroy.rule =
6750 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6754 if (((uint8_t *)(out->args.destroy.rule + out->args.destroy.rule_n) +
6755 sizeof(*out->args.destroy.rule)) > (uint8_t *)out + size)
6758 ctx->object = out->args.destroy.rule + out->args.destroy.rule_n++;
6759 ctx->objmask = NULL;
6763 /** Parse tokens for flush command. */
6765 parse_flush(struct context *ctx, const struct token *token,
6766 const char *str, unsigned int len,
6767 void *buf, unsigned int size)
6769 struct buffer *out = buf;
6771 /* Token name must match. */
6772 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6774 /* Nothing else to do if there is no buffer. */
6777 if (!out->command) {
6778 if (ctx->curr != FLUSH)
6780 if (sizeof(*out) > size)
6782 out->command = ctx->curr;
6785 ctx->objmask = NULL;
6790 /** Parse tokens for dump command. */
6792 parse_dump(struct context *ctx, const struct token *token,
6793 const char *str, unsigned int len,
6794 void *buf, unsigned int size)
6796 struct buffer *out = buf;
6798 /* Token name must match. */
6799 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6801 /* Nothing else to do if there is no buffer. */
6804 if (!out->command) {
6805 if (ctx->curr != DUMP)
6807 if (sizeof(*out) > size)
6809 out->command = ctx->curr;
6812 ctx->objmask = NULL;
6815 switch (ctx->curr) {
6818 out->args.dump.mode = (ctx->curr == DUMP_ALL) ? true : false;
6819 out->command = ctx->curr;
6822 ctx->objmask = NULL;
6829 /** Parse tokens for query command. */
6831 parse_query(struct context *ctx, const struct token *token,
6832 const char *str, unsigned int len,
6833 void *buf, unsigned int size)
6835 struct buffer *out = buf;
6837 /* Token name must match. */
6838 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6840 /* Nothing else to do if there is no buffer. */
6843 if (!out->command) {
6844 if (ctx->curr != QUERY)
6846 if (sizeof(*out) > size)
6848 out->command = ctx->curr;
6851 ctx->objmask = NULL;
6856 /** Parse action names. */
6858 parse_action(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;
6863 const struct arg *arg = pop_args(ctx);
6867 /* Argument is expected. */
6870 /* Parse action name. */
6871 for (i = 0; next_action[i]; ++i) {
6872 const struct parse_action_priv *priv;
6874 token = &token_list[next_action[i]];
6875 if (strcmp_partial(token->name, str, len))
6881 memcpy((uint8_t *)ctx->object + arg->offset,
6887 push_args(ctx, arg);
6891 /** Parse tokens for list command. */
6893 parse_list(struct context *ctx, const struct token *token,
6894 const char *str, unsigned int len,
6895 void *buf, unsigned int size)
6897 struct buffer *out = buf;
6899 /* Token name must match. */
6900 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6902 /* Nothing else to do if there is no buffer. */
6905 if (!out->command) {
6906 if (ctx->curr != LIST)
6908 if (sizeof(*out) > size)
6910 out->command = ctx->curr;
6913 ctx->objmask = NULL;
6914 out->args.list.group =
6915 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6919 if (((uint8_t *)(out->args.list.group + out->args.list.group_n) +
6920 sizeof(*out->args.list.group)) > (uint8_t *)out + size)
6923 ctx->object = out->args.list.group + out->args.list.group_n++;
6924 ctx->objmask = NULL;
6928 /** Parse tokens for list all aged flows command. */
6930 parse_aged(struct context *ctx, const struct token *token,
6931 const char *str, unsigned int len,
6932 void *buf, unsigned int size)
6934 struct buffer *out = buf;
6936 /* Token name must match. */
6937 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6939 /* Nothing else to do if there is no buffer. */
6942 if (!out->command) {
6943 if (ctx->curr != AGED)
6945 if (sizeof(*out) > size)
6947 out->command = ctx->curr;
6950 ctx->objmask = NULL;
6952 if (ctx->curr == AGED_DESTROY)
6953 out->args.aged.destroy = 1;
6957 /** Parse tokens for isolate command. */
6959 parse_isolate(struct context *ctx, const struct token *token,
6960 const char *str, unsigned int len,
6961 void *buf, unsigned int size)
6963 struct buffer *out = buf;
6965 /* Token name must match. */
6966 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6968 /* Nothing else to do if there is no buffer. */
6971 if (!out->command) {
6972 if (ctx->curr != ISOLATE)
6974 if (sizeof(*out) > size)
6976 out->command = ctx->curr;
6979 ctx->objmask = NULL;
6985 parse_tunnel(struct context *ctx, const struct token *token,
6986 const char *str, unsigned int len,
6987 void *buf, unsigned int size)
6989 struct buffer *out = buf;
6991 /* Token name must match. */
6992 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6994 /* Nothing else to do if there is no buffer. */
6997 if (!out->command) {
6998 if (ctx->curr != TUNNEL)
7000 if (sizeof(*out) > size)
7002 out->command = ctx->curr;
7005 ctx->objmask = NULL;
7007 switch (ctx->curr) {
7011 case TUNNEL_DESTROY:
7013 out->command = ctx->curr;
7015 case TUNNEL_CREATE_TYPE:
7016 case TUNNEL_DESTROY_ID:
7017 ctx->object = &out->args.vc.tunnel_ops;
7026 * Parse signed/unsigned integers 8 to 64-bit long.
7028 * Last argument (ctx->args) is retrieved to determine integer type and
7032 parse_int(struct context *ctx, const struct token *token,
7033 const char *str, unsigned int len,
7034 void *buf, unsigned int size)
7036 const struct arg *arg = pop_args(ctx);
7041 /* Argument is expected. */
7046 (uintmax_t)strtoimax(str, &end, 0) :
7047 strtoumax(str, &end, 0);
7048 if (errno || (size_t)(end - str) != len)
7051 ((arg->sign && ((intmax_t)u < (intmax_t)arg->min ||
7052 (intmax_t)u > (intmax_t)arg->max)) ||
7053 (!arg->sign && (u < arg->min || u > arg->max))))
7058 if (!arg_entry_bf_fill(ctx->object, u, arg) ||
7059 !arg_entry_bf_fill(ctx->objmask, -1, arg))
7063 buf = (uint8_t *)ctx->object + arg->offset;
7065 if (u > RTE_LEN2MASK(size * CHAR_BIT, uint64_t))
7069 case sizeof(uint8_t):
7070 *(uint8_t *)buf = u;
7072 case sizeof(uint16_t):
7073 *(uint16_t *)buf = arg->hton ? rte_cpu_to_be_16(u) : u;
7075 case sizeof(uint8_t [3]):
7076 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
7078 ((uint8_t *)buf)[0] = u;
7079 ((uint8_t *)buf)[1] = u >> 8;
7080 ((uint8_t *)buf)[2] = u >> 16;
7084 ((uint8_t *)buf)[0] = u >> 16;
7085 ((uint8_t *)buf)[1] = u >> 8;
7086 ((uint8_t *)buf)[2] = u;
7088 case sizeof(uint32_t):
7089 *(uint32_t *)buf = arg->hton ? rte_cpu_to_be_32(u) : u;
7091 case sizeof(uint64_t):
7092 *(uint64_t *)buf = arg->hton ? rte_cpu_to_be_64(u) : u;
7097 if (ctx->objmask && buf != (uint8_t *)ctx->objmask + arg->offset) {
7099 buf = (uint8_t *)ctx->objmask + arg->offset;
7104 push_args(ctx, arg);
7111 * Three arguments (ctx->args) are retrieved from the stack to store data,
7112 * its actual length and address (in that order).
7115 parse_string(struct context *ctx, const struct token *token,
7116 const char *str, unsigned int len,
7117 void *buf, unsigned int size)
7119 const struct arg *arg_data = pop_args(ctx);
7120 const struct arg *arg_len = pop_args(ctx);
7121 const struct arg *arg_addr = pop_args(ctx);
7122 char tmp[16]; /* Ought to be enough. */
7125 /* Arguments are expected. */
7129 push_args(ctx, arg_data);
7133 push_args(ctx, arg_len);
7134 push_args(ctx, arg_data);
7137 size = arg_data->size;
7138 /* Bit-mask fill is not supported. */
7139 if (arg_data->mask || size < len)
7143 /* Let parse_int() fill length information first. */
7144 ret = snprintf(tmp, sizeof(tmp), "%u", len);
7147 push_args(ctx, arg_len);
7148 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
7153 buf = (uint8_t *)ctx->object + arg_data->offset;
7154 /* Output buffer is not necessarily NUL-terminated. */
7155 memcpy(buf, str, len);
7156 memset((uint8_t *)buf + len, 0x00, size - len);
7158 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
7159 /* Save address if requested. */
7160 if (arg_addr->size) {
7161 memcpy((uint8_t *)ctx->object + arg_addr->offset,
7163 (uint8_t *)ctx->object + arg_data->offset
7167 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
7169 (uint8_t *)ctx->objmask + arg_data->offset
7175 push_args(ctx, arg_addr);
7176 push_args(ctx, arg_len);
7177 push_args(ctx, arg_data);
7182 parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
7188 /* Check input parameters */
7189 if ((src == NULL) ||
7195 /* Convert chars to bytes */
7196 for (i = 0, len = 0; i < *size; i += 2) {
7197 snprintf(tmp, 3, "%s", src + i);
7198 dst[len++] = strtoul(tmp, &c, 16);
7213 parse_hex(struct context *ctx, const struct token *token,
7214 const char *str, unsigned int len,
7215 void *buf, unsigned int size)
7217 const struct arg *arg_data = pop_args(ctx);
7218 const struct arg *arg_len = pop_args(ctx);
7219 const struct arg *arg_addr = pop_args(ctx);
7220 char tmp[16]; /* Ought to be enough. */
7222 unsigned int hexlen = len;
7223 unsigned int length = 256;
7224 uint8_t hex_tmp[length];
7226 /* Arguments are expected. */
7230 push_args(ctx, arg_data);
7234 push_args(ctx, arg_len);
7235 push_args(ctx, arg_data);
7238 size = arg_data->size;
7239 /* Bit-mask fill is not supported. */
7245 /* translate bytes string to array. */
7246 if (str[0] == '0' && ((str[1] == 'x') ||
7251 if (hexlen > length)
7253 ret = parse_hex_string(str, hex_tmp, &hexlen);
7256 /* Let parse_int() fill length information first. */
7257 ret = snprintf(tmp, sizeof(tmp), "%u", hexlen);
7260 /* Save length if requested. */
7261 if (arg_len->size) {
7262 push_args(ctx, arg_len);
7263 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
7269 buf = (uint8_t *)ctx->object + arg_data->offset;
7270 /* Output buffer is not necessarily NUL-terminated. */
7271 memcpy(buf, hex_tmp, hexlen);
7272 memset((uint8_t *)buf + hexlen, 0x00, size - hexlen);
7274 memset((uint8_t *)ctx->objmask + arg_data->offset,
7276 /* Save address if requested. */
7277 if (arg_addr->size) {
7278 memcpy((uint8_t *)ctx->object + arg_addr->offset,
7280 (uint8_t *)ctx->object + arg_data->offset
7284 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
7286 (uint8_t *)ctx->objmask + arg_data->offset
7292 push_args(ctx, arg_addr);
7293 push_args(ctx, arg_len);
7294 push_args(ctx, arg_data);
7300 * Parse a zero-ended string.
7303 parse_string0(struct context *ctx, const struct token *token __rte_unused,
7304 const char *str, unsigned int len,
7305 void *buf, unsigned int size)
7307 const struct arg *arg_data = pop_args(ctx);
7309 /* Arguments are expected. */
7312 size = arg_data->size;
7313 /* Bit-mask fill is not supported. */
7314 if (arg_data->mask || size < len + 1)
7318 buf = (uint8_t *)ctx->object + arg_data->offset;
7319 strncpy(buf, str, len);
7321 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
7324 push_args(ctx, arg_data);
7329 * Parse a MAC address.
7331 * Last argument (ctx->args) is retrieved to determine storage size and
7335 parse_mac_addr(struct context *ctx, const struct token *token,
7336 const char *str, unsigned int len,
7337 void *buf, unsigned int size)
7339 const struct arg *arg = pop_args(ctx);
7340 struct rte_ether_addr tmp;
7344 /* Argument is expected. */
7348 /* Bit-mask fill is not supported. */
7349 if (arg->mask || size != sizeof(tmp))
7351 /* Only network endian is supported. */
7354 ret = cmdline_parse_etheraddr(NULL, str, &tmp, size);
7355 if (ret < 0 || (unsigned int)ret != len)
7359 buf = (uint8_t *)ctx->object + arg->offset;
7360 memcpy(buf, &tmp, size);
7362 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
7365 push_args(ctx, arg);
7370 * Parse an IPv4 address.
7372 * Last argument (ctx->args) is retrieved to determine storage size and
7376 parse_ipv4_addr(struct context *ctx, const struct token *token,
7377 const char *str, unsigned int len,
7378 void *buf, unsigned int size)
7380 const struct arg *arg = pop_args(ctx);
7385 /* Argument is expected. */
7389 /* Bit-mask fill is not supported. */
7390 if (arg->mask || size != sizeof(tmp))
7392 /* Only network endian is supported. */
7395 memcpy(str2, str, len);
7397 ret = inet_pton(AF_INET, str2, &tmp);
7399 /* Attempt integer parsing. */
7400 push_args(ctx, arg);
7401 return parse_int(ctx, token, str, len, buf, size);
7405 buf = (uint8_t *)ctx->object + arg->offset;
7406 memcpy(buf, &tmp, size);
7408 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
7411 push_args(ctx, arg);
7416 * Parse an IPv6 address.
7418 * Last argument (ctx->args) is retrieved to determine storage size and
7422 parse_ipv6_addr(struct context *ctx, const struct token *token,
7423 const char *str, unsigned int len,
7424 void *buf, unsigned int size)
7426 const struct arg *arg = pop_args(ctx);
7428 struct in6_addr tmp;
7432 /* Argument is expected. */
7436 /* Bit-mask fill is not supported. */
7437 if (arg->mask || size != sizeof(tmp))
7439 /* Only network endian is supported. */
7442 memcpy(str2, str, len);
7444 ret = inet_pton(AF_INET6, str2, &tmp);
7449 buf = (uint8_t *)ctx->object + arg->offset;
7450 memcpy(buf, &tmp, size);
7452 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
7455 push_args(ctx, arg);
7459 /** Boolean values (even indices stand for false). */
7460 static const char *const boolean_name[] = {
7470 * Parse a boolean value.
7472 * Last argument (ctx->args) is retrieved to determine storage size and
7476 parse_boolean(struct context *ctx, const struct token *token,
7477 const char *str, unsigned int len,
7478 void *buf, unsigned int size)
7480 const struct arg *arg = pop_args(ctx);
7484 /* Argument is expected. */
7487 for (i = 0; boolean_name[i]; ++i)
7488 if (!strcmp_partial(boolean_name[i], str, len))
7490 /* Process token as integer. */
7491 if (boolean_name[i])
7492 str = i & 1 ? "1" : "0";
7493 push_args(ctx, arg);
7494 ret = parse_int(ctx, token, str, strlen(str), buf, size);
7495 return ret > 0 ? (int)len : ret;
7498 /** Parse port and update context. */
7500 parse_port(struct context *ctx, const struct token *token,
7501 const char *str, unsigned int len,
7502 void *buf, unsigned int size)
7504 struct buffer *out = &(struct buffer){ .port = 0 };
7512 ctx->objmask = NULL;
7513 size = sizeof(*out);
7515 ret = parse_int(ctx, token, str, len, out, size);
7517 ctx->port = out->port;
7524 parse_ia_id2ptr(struct context *ctx, const struct token *token,
7525 const char *str, unsigned int len,
7526 void *buf, unsigned int size)
7528 struct rte_flow_action *action = ctx->object;
7536 ctx->objmask = NULL;
7537 ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
7538 ctx->object = action;
7539 if (ret != (int)len)
7541 /* set indirect action */
7543 action->conf = port_action_handle_get_by_id(ctx->port, id);
7544 ret = (action->conf) ? ret : -1;
7549 /** Parse set command, initialize output buffer for subsequent tokens. */
7551 parse_set_raw_encap_decap(struct context *ctx, const struct token *token,
7552 const char *str, unsigned int len,
7553 void *buf, unsigned int size)
7555 struct buffer *out = buf;
7557 /* Token name must match. */
7558 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7560 /* Nothing else to do if there is no buffer. */
7563 /* Make sure buffer is large enough. */
7564 if (size < sizeof(*out))
7567 ctx->objmask = NULL;
7571 out->command = ctx->curr;
7572 /* For encap/decap we need is pattern */
7573 out->args.vc.pattern = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7578 /** Parse set command, initialize output buffer for subsequent tokens. */
7580 parse_set_sample_action(struct context *ctx, const struct token *token,
7581 const char *str, unsigned int len,
7582 void *buf, unsigned int size)
7584 struct buffer *out = buf;
7586 /* Token name must match. */
7587 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7589 /* Nothing else to do if there is no buffer. */
7592 /* Make sure buffer is large enough. */
7593 if (size < sizeof(*out))
7596 ctx->objmask = NULL;
7600 out->command = ctx->curr;
7601 /* For sampler we need is actions */
7602 out->args.vc.actions = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7608 * Parse set raw_encap/raw_decap command,
7609 * initialize output buffer for subsequent tokens.
7612 parse_set_init(struct context *ctx, const struct token *token,
7613 const char *str, unsigned int len,
7614 void *buf, unsigned int size)
7616 struct buffer *out = buf;
7618 /* Token name must match. */
7619 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7621 /* Nothing else to do if there is no buffer. */
7624 /* Make sure buffer is large enough. */
7625 if (size < sizeof(*out))
7627 /* Initialize buffer. */
7628 memset(out, 0x00, sizeof(*out));
7629 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
7632 ctx->objmask = NULL;
7633 if (!out->command) {
7634 if (ctx->curr != SET)
7636 if (sizeof(*out) > size)
7638 out->command = ctx->curr;
7639 out->args.vc.data = (uint8_t *)out + size;
7640 ctx->object = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7646 /** No completion. */
7648 comp_none(struct context *ctx, const struct token *token,
7649 unsigned int ent, char *buf, unsigned int size)
7659 /** Complete boolean values. */
7661 comp_boolean(struct context *ctx, const struct token *token,
7662 unsigned int ent, char *buf, unsigned int size)
7668 for (i = 0; boolean_name[i]; ++i)
7669 if (buf && i == ent)
7670 return strlcpy(buf, boolean_name[i], size);
7676 /** Complete action names. */
7678 comp_action(struct context *ctx, const struct token *token,
7679 unsigned int ent, char *buf, unsigned int size)
7685 for (i = 0; next_action[i]; ++i)
7686 if (buf && i == ent)
7687 return strlcpy(buf, token_list[next_action[i]].name,
7694 /** Complete available ports. */
7696 comp_port(struct context *ctx, const struct token *token,
7697 unsigned int ent, char *buf, unsigned int size)
7704 RTE_ETH_FOREACH_DEV(p) {
7705 if (buf && i == ent)
7706 return snprintf(buf, size, "%u", p);
7714 /** Complete available rule IDs. */
7716 comp_rule_id(struct context *ctx, const struct token *token,
7717 unsigned int ent, char *buf, unsigned int size)
7720 struct rte_port *port;
7721 struct port_flow *pf;
7724 if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
7725 ctx->port == (portid_t)RTE_PORT_ALL)
7727 port = &ports[ctx->port];
7728 for (pf = port->flow_list; pf != NULL; pf = pf->next) {
7729 if (buf && i == ent)
7730 return snprintf(buf, size, "%u", pf->id);
7738 /** Complete type field for RSS action. */
7740 comp_vc_action_rss_type(struct context *ctx, const struct token *token,
7741 unsigned int ent, char *buf, unsigned int size)
7747 for (i = 0; rss_type_table[i].str; ++i)
7752 return strlcpy(buf, rss_type_table[ent].str, size);
7754 return snprintf(buf, size, "end");
7758 /** Complete queue field for RSS action. */
7760 comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
7761 unsigned int ent, char *buf, unsigned int size)
7768 return snprintf(buf, size, "%u", ent);
7770 return snprintf(buf, size, "end");
7774 /** Complete index number for set raw_encap/raw_decap commands. */
7776 comp_set_raw_index(struct context *ctx, const struct token *token,
7777 unsigned int ent, char *buf, unsigned int size)
7783 RTE_SET_USED(token);
7784 for (idx = 0; idx < RAW_ENCAP_CONFS_MAX_NUM; ++idx) {
7785 if (buf && idx == ent)
7786 return snprintf(buf, size, "%u", idx);
7792 /** Complete index number for set raw_encap/raw_decap commands. */
7794 comp_set_sample_index(struct context *ctx, const struct token *token,
7795 unsigned int ent, char *buf, unsigned int size)
7801 RTE_SET_USED(token);
7802 for (idx = 0; idx < RAW_SAMPLE_CONFS_MAX_NUM; ++idx) {
7803 if (buf && idx == ent)
7804 return snprintf(buf, size, "%u", idx);
7810 /** Complete operation for modify_field command. */
7812 comp_set_modify_field_op(struct context *ctx, const struct token *token,
7813 unsigned int ent, char *buf, unsigned int size)
7818 RTE_SET_USED(token);
7819 for (idx = 0; modify_field_ops[idx]; ++idx)
7824 return strlcpy(buf, modify_field_ops[ent], size);
7828 /** Complete field id for modify_field command. */
7830 comp_set_modify_field_id(struct context *ctx, const struct token *token,
7831 unsigned int ent, char *buf, unsigned int size)
7836 RTE_SET_USED(token);
7837 for (idx = 0; modify_field_ids[idx]; ++idx)
7842 return strlcpy(buf, modify_field_ids[ent], size);
7846 /** Internal context. */
7847 static struct context cmd_flow_context;
7849 /** Global parser instance (cmdline API). */
7850 cmdline_parse_inst_t cmd_flow;
7851 cmdline_parse_inst_t cmd_set_raw;
7853 /** Initialize context. */
7855 cmd_flow_context_init(struct context *ctx)
7857 /* A full memset() is not necessary. */
7867 ctx->objmask = NULL;
7870 /** Parse a token (cmdline API). */
7872 cmd_flow_parse(cmdline_parse_token_hdr_t *hdr, const char *src, void *result,
7875 struct context *ctx = &cmd_flow_context;
7876 const struct token *token;
7877 const enum index *list;
7882 token = &token_list[ctx->curr];
7883 /* Check argument length. */
7886 for (len = 0; src[len]; ++len)
7887 if (src[len] == '#' || isspace(src[len]))
7891 /* Last argument and EOL detection. */
7892 for (i = len; src[i]; ++i)
7893 if (src[i] == '#' || src[i] == '\r' || src[i] == '\n')
7895 else if (!isspace(src[i])) {
7900 if (src[i] == '\r' || src[i] == '\n') {
7904 /* Initialize context if necessary. */
7905 if (!ctx->next_num) {
7908 ctx->next[ctx->next_num++] = token->next[0];
7910 /* Process argument through candidates. */
7911 ctx->prev = ctx->curr;
7912 list = ctx->next[ctx->next_num - 1];
7913 for (i = 0; list[i]; ++i) {
7914 const struct token *next = &token_list[list[i]];
7917 ctx->curr = list[i];
7919 tmp = next->call(ctx, next, src, len, result, size);
7921 tmp = parse_default(ctx, next, src, len, result, size);
7922 if (tmp == -1 || tmp != len)
7930 /* Push subsequent tokens if any. */
7932 for (i = 0; token->next[i]; ++i) {
7933 if (ctx->next_num == RTE_DIM(ctx->next))
7935 ctx->next[ctx->next_num++] = token->next[i];
7937 /* Push arguments if any. */
7939 for (i = 0; token->args[i]; ++i) {
7940 if (ctx->args_num == RTE_DIM(ctx->args))
7942 ctx->args[ctx->args_num++] = token->args[i];
7947 /** Return number of completion entries (cmdline API). */
7949 cmd_flow_complete_get_nb(cmdline_parse_token_hdr_t *hdr)
7951 struct context *ctx = &cmd_flow_context;
7952 const struct token *token = &token_list[ctx->curr];
7953 const enum index *list;
7957 /* Count number of tokens in current list. */
7959 list = ctx->next[ctx->next_num - 1];
7961 list = token->next[0];
7962 for (i = 0; list[i]; ++i)
7967 * If there is a single token, use its completion callback, otherwise
7968 * return the number of entries.
7970 token = &token_list[list[0]];
7971 if (i == 1 && token->comp) {
7972 /* Save index for cmd_flow_get_help(). */
7973 ctx->prev = list[0];
7974 return token->comp(ctx, token, 0, NULL, 0);
7979 /** Return a completion entry (cmdline API). */
7981 cmd_flow_complete_get_elt(cmdline_parse_token_hdr_t *hdr, int index,
7982 char *dst, unsigned int size)
7984 struct context *ctx = &cmd_flow_context;
7985 const struct token *token = &token_list[ctx->curr];
7986 const enum index *list;
7990 /* Count number of tokens in current list. */
7992 list = ctx->next[ctx->next_num - 1];
7994 list = token->next[0];
7995 for (i = 0; list[i]; ++i)
7999 /* If there is a single token, use its completion callback. */
8000 token = &token_list[list[0]];
8001 if (i == 1 && token->comp) {
8002 /* Save index for cmd_flow_get_help(). */
8003 ctx->prev = list[0];
8004 return token->comp(ctx, token, index, dst, size) < 0 ? -1 : 0;
8006 /* Otherwise make sure the index is valid and use defaults. */
8009 token = &token_list[list[index]];
8010 strlcpy(dst, token->name, size);
8011 /* Save index for cmd_flow_get_help(). */
8012 ctx->prev = list[index];
8016 /** Populate help strings for current token (cmdline API). */
8018 cmd_flow_get_help(cmdline_parse_token_hdr_t *hdr, char *dst, unsigned int size)
8020 struct context *ctx = &cmd_flow_context;
8021 const struct token *token = &token_list[ctx->prev];
8026 /* Set token type and update global help with details. */
8027 strlcpy(dst, (token->type ? token->type : "TOKEN"), size);
8029 cmd_flow.help_str = token->help;
8031 cmd_flow.help_str = token->name;
8035 /** Token definition template (cmdline API). */
8036 static struct cmdline_token_hdr cmd_flow_token_hdr = {
8037 .ops = &(struct cmdline_token_ops){
8038 .parse = cmd_flow_parse,
8039 .complete_get_nb = cmd_flow_complete_get_nb,
8040 .complete_get_elt = cmd_flow_complete_get_elt,
8041 .get_help = cmd_flow_get_help,
8046 /** Populate the next dynamic token. */
8048 cmd_flow_tok(cmdline_parse_token_hdr_t **hdr,
8049 cmdline_parse_token_hdr_t **hdr_inst)
8051 struct context *ctx = &cmd_flow_context;
8053 /* Always reinitialize context before requesting the first token. */
8054 if (!(hdr_inst - cmd_flow.tokens))
8055 cmd_flow_context_init(ctx);
8056 /* Return NULL when no more tokens are expected. */
8057 if (!ctx->next_num && ctx->curr) {
8061 /* Determine if command should end here. */
8062 if (ctx->eol && ctx->last && ctx->next_num) {
8063 const enum index *list = ctx->next[ctx->next_num - 1];
8066 for (i = 0; list[i]; ++i) {
8073 *hdr = &cmd_flow_token_hdr;
8076 /** Dispatch parsed buffer to function calls. */
8078 cmd_flow_parsed(const struct buffer *in)
8080 switch (in->command) {
8081 case INDIRECT_ACTION_CREATE:
8082 port_action_handle_create(
8083 in->port, in->args.vc.attr.group,
8084 &((const struct rte_flow_indir_action_conf) {
8085 .ingress = in->args.vc.attr.ingress,
8086 .egress = in->args.vc.attr.egress,
8087 .transfer = in->args.vc.attr.transfer,
8089 in->args.vc.actions);
8091 case INDIRECT_ACTION_DESTROY:
8092 port_action_handle_destroy(in->port,
8093 in->args.ia_destroy.action_id_n,
8094 in->args.ia_destroy.action_id);
8096 case INDIRECT_ACTION_UPDATE:
8097 port_action_handle_update(in->port, in->args.vc.attr.group,
8098 in->args.vc.actions);
8100 case INDIRECT_ACTION_QUERY:
8101 port_action_handle_query(in->port, in->args.ia.action_id);
8104 port_flow_validate(in->port, &in->args.vc.attr,
8105 in->args.vc.pattern, in->args.vc.actions,
8106 &in->args.vc.tunnel_ops);
8109 port_flow_create(in->port, &in->args.vc.attr,
8110 in->args.vc.pattern, in->args.vc.actions,
8111 &in->args.vc.tunnel_ops);
8114 port_flow_destroy(in->port, in->args.destroy.rule_n,
8115 in->args.destroy.rule);
8118 port_flow_flush(in->port);
8122 port_flow_dump(in->port, in->args.dump.mode,
8123 in->args.dump.rule, in->args.dump.file);
8126 port_flow_query(in->port, in->args.query.rule,
8127 &in->args.query.action);
8130 port_flow_list(in->port, in->args.list.group_n,
8131 in->args.list.group);
8134 port_flow_isolate(in->port, in->args.isolate.set);
8137 port_flow_aged(in->port, in->args.aged.destroy);
8140 port_flow_tunnel_create(in->port, &in->args.vc.tunnel_ops);
8142 case TUNNEL_DESTROY:
8143 port_flow_tunnel_destroy(in->port, in->args.vc.tunnel_ops.id);
8146 port_flow_tunnel_list(in->port);
8149 port_meter_policy_add(in->port, in->args.policy.policy_id,
8150 in->args.vc.actions);
8157 /** Token generator and output processing callback (cmdline API). */
8159 cmd_flow_cb(void *arg0, struct cmdline *cl, void *arg2)
8162 cmd_flow_tok(arg0, arg2);
8164 cmd_flow_parsed(arg0);
8167 /** Global parser instance (cmdline API). */
8168 cmdline_parse_inst_t cmd_flow = {
8170 .data = NULL, /**< Unused. */
8171 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
8174 }, /**< Tokens are returned by cmd_flow_tok(). */
8177 /** set cmd facility. Reuse cmd flow's infrastructure as much as possible. */
8180 update_fields(uint8_t *buf, struct rte_flow_item *item, uint16_t next_proto)
8182 struct rte_ipv4_hdr *ipv4;
8183 struct rte_ether_hdr *eth;
8184 struct rte_ipv6_hdr *ipv6;
8185 struct rte_vxlan_hdr *vxlan;
8186 struct rte_vxlan_gpe_hdr *gpe;
8187 struct rte_flow_item_nvgre *nvgre;
8188 uint32_t ipv6_vtc_flow;
8190 switch (item->type) {
8191 case RTE_FLOW_ITEM_TYPE_ETH:
8192 eth = (struct rte_ether_hdr *)buf;
8194 eth->ether_type = rte_cpu_to_be_16(next_proto);
8196 case RTE_FLOW_ITEM_TYPE_IPV4:
8197 ipv4 = (struct rte_ipv4_hdr *)buf;
8198 ipv4->version_ihl = 0x45;
8199 if (next_proto && ipv4->next_proto_id == 0)
8200 ipv4->next_proto_id = (uint8_t)next_proto;
8202 case RTE_FLOW_ITEM_TYPE_IPV6:
8203 ipv6 = (struct rte_ipv6_hdr *)buf;
8204 if (next_proto && ipv6->proto == 0)
8205 ipv6->proto = (uint8_t)next_proto;
8206 ipv6_vtc_flow = rte_be_to_cpu_32(ipv6->vtc_flow);
8207 ipv6_vtc_flow &= 0x0FFFFFFF; /*< reset version bits. */
8208 ipv6_vtc_flow |= 0x60000000; /*< set ipv6 version. */
8209 ipv6->vtc_flow = rte_cpu_to_be_32(ipv6_vtc_flow);
8211 case RTE_FLOW_ITEM_TYPE_VXLAN:
8212 vxlan = (struct rte_vxlan_hdr *)buf;
8213 vxlan->vx_flags = 0x08;
8215 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
8216 gpe = (struct rte_vxlan_gpe_hdr *)buf;
8217 gpe->vx_flags = 0x0C;
8219 case RTE_FLOW_ITEM_TYPE_NVGRE:
8220 nvgre = (struct rte_flow_item_nvgre *)buf;
8221 nvgre->protocol = rte_cpu_to_be_16(0x6558);
8222 nvgre->c_k_s_rsvd0_ver = rte_cpu_to_be_16(0x2000);
8229 /** Helper of get item's default mask. */
8231 flow_item_default_mask(const struct rte_flow_item *item)
8233 const void *mask = NULL;
8234 static rte_be32_t gre_key_default_mask = RTE_BE32(UINT32_MAX);
8236 switch (item->type) {
8237 case RTE_FLOW_ITEM_TYPE_ANY:
8238 mask = &rte_flow_item_any_mask;
8240 case RTE_FLOW_ITEM_TYPE_VF:
8241 mask = &rte_flow_item_vf_mask;
8243 case RTE_FLOW_ITEM_TYPE_PORT_ID:
8244 mask = &rte_flow_item_port_id_mask;
8246 case RTE_FLOW_ITEM_TYPE_RAW:
8247 mask = &rte_flow_item_raw_mask;
8249 case RTE_FLOW_ITEM_TYPE_ETH:
8250 mask = &rte_flow_item_eth_mask;
8252 case RTE_FLOW_ITEM_TYPE_VLAN:
8253 mask = &rte_flow_item_vlan_mask;
8255 case RTE_FLOW_ITEM_TYPE_IPV4:
8256 mask = &rte_flow_item_ipv4_mask;
8258 case RTE_FLOW_ITEM_TYPE_IPV6:
8259 mask = &rte_flow_item_ipv6_mask;
8261 case RTE_FLOW_ITEM_TYPE_ICMP:
8262 mask = &rte_flow_item_icmp_mask;
8264 case RTE_FLOW_ITEM_TYPE_UDP:
8265 mask = &rte_flow_item_udp_mask;
8267 case RTE_FLOW_ITEM_TYPE_TCP:
8268 mask = &rte_flow_item_tcp_mask;
8270 case RTE_FLOW_ITEM_TYPE_SCTP:
8271 mask = &rte_flow_item_sctp_mask;
8273 case RTE_FLOW_ITEM_TYPE_VXLAN:
8274 mask = &rte_flow_item_vxlan_mask;
8276 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
8277 mask = &rte_flow_item_vxlan_gpe_mask;
8279 case RTE_FLOW_ITEM_TYPE_E_TAG:
8280 mask = &rte_flow_item_e_tag_mask;
8282 case RTE_FLOW_ITEM_TYPE_NVGRE:
8283 mask = &rte_flow_item_nvgre_mask;
8285 case RTE_FLOW_ITEM_TYPE_MPLS:
8286 mask = &rte_flow_item_mpls_mask;
8288 case RTE_FLOW_ITEM_TYPE_GRE:
8289 mask = &rte_flow_item_gre_mask;
8291 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
8292 mask = &gre_key_default_mask;
8294 case RTE_FLOW_ITEM_TYPE_META:
8295 mask = &rte_flow_item_meta_mask;
8297 case RTE_FLOW_ITEM_TYPE_FUZZY:
8298 mask = &rte_flow_item_fuzzy_mask;
8300 case RTE_FLOW_ITEM_TYPE_GTP:
8301 mask = &rte_flow_item_gtp_mask;
8303 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
8304 mask = &rte_flow_item_gtp_psc_mask;
8306 case RTE_FLOW_ITEM_TYPE_GENEVE:
8307 mask = &rte_flow_item_geneve_mask;
8309 case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
8310 mask = &rte_flow_item_geneve_opt_mask;
8312 case RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID:
8313 mask = &rte_flow_item_pppoe_proto_id_mask;
8315 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
8316 mask = &rte_flow_item_l2tpv3oip_mask;
8318 case RTE_FLOW_ITEM_TYPE_ESP:
8319 mask = &rte_flow_item_esp_mask;
8321 case RTE_FLOW_ITEM_TYPE_AH:
8322 mask = &rte_flow_item_ah_mask;
8324 case RTE_FLOW_ITEM_TYPE_PFCP:
8325 mask = &rte_flow_item_pfcp_mask;
8333 /** Dispatch parsed buffer to function calls. */
8335 cmd_set_raw_parsed_sample(const struct buffer *in)
8337 uint32_t n = in->args.vc.actions_n;
8339 struct rte_flow_action *action = NULL;
8340 struct rte_flow_action *data = NULL;
8341 const struct rte_flow_action_rss *rss = NULL;
8343 uint16_t idx = in->port; /* We borrow port field as index */
8344 uint32_t max_size = sizeof(struct rte_flow_action) *
8345 ACTION_SAMPLE_ACTIONS_NUM;
8347 RTE_ASSERT(in->command == SET_SAMPLE_ACTIONS);
8348 data = (struct rte_flow_action *)&raw_sample_confs[idx].data;
8349 memset(data, 0x00, max_size);
8350 for (; i <= n - 1; i++) {
8351 action = in->args.vc.actions + i;
8352 if (action->type == RTE_FLOW_ACTION_TYPE_END)
8354 switch (action->type) {
8355 case RTE_FLOW_ACTION_TYPE_MARK:
8356 size = sizeof(struct rte_flow_action_mark);
8357 rte_memcpy(&sample_mark[idx],
8358 (const void *)action->conf, size);
8359 action->conf = &sample_mark[idx];
8361 case RTE_FLOW_ACTION_TYPE_COUNT:
8362 size = sizeof(struct rte_flow_action_count);
8363 rte_memcpy(&sample_count[idx],
8364 (const void *)action->conf, size);
8365 action->conf = &sample_count[idx];
8367 case RTE_FLOW_ACTION_TYPE_QUEUE:
8368 size = sizeof(struct rte_flow_action_queue);
8369 rte_memcpy(&sample_queue[idx],
8370 (const void *)action->conf, size);
8371 action->conf = &sample_queue[idx];
8373 case RTE_FLOW_ACTION_TYPE_RSS:
8374 size = sizeof(struct rte_flow_action_rss);
8376 rte_memcpy(&sample_rss_data[idx].conf,
8377 (const void *)rss, size);
8378 if (rss->key_len && rss->key) {
8379 sample_rss_data[idx].conf.key =
8380 sample_rss_data[idx].key;
8381 rte_memcpy((void *)((uintptr_t)
8382 sample_rss_data[idx].conf.key),
8383 (const void *)rss->key,
8384 sizeof(uint8_t) * rss->key_len);
8386 if (rss->queue_num && rss->queue) {
8387 sample_rss_data[idx].conf.queue =
8388 sample_rss_data[idx].queue;
8389 rte_memcpy((void *)((uintptr_t)
8390 sample_rss_data[idx].conf.queue),
8391 (const void *)rss->queue,
8392 sizeof(uint16_t) * rss->queue_num);
8394 action->conf = &sample_rss_data[idx].conf;
8396 case RTE_FLOW_ACTION_TYPE_RAW_ENCAP:
8397 size = sizeof(struct rte_flow_action_raw_encap);
8398 rte_memcpy(&sample_encap[idx],
8399 (const void *)action->conf, size);
8400 action->conf = &sample_encap[idx];
8402 case RTE_FLOW_ACTION_TYPE_PORT_ID:
8403 size = sizeof(struct rte_flow_action_port_id);
8404 rte_memcpy(&sample_port_id[idx],
8405 (const void *)action->conf, size);
8406 action->conf = &sample_port_id[idx];
8408 case RTE_FLOW_ACTION_TYPE_PF:
8410 case RTE_FLOW_ACTION_TYPE_VF:
8411 size = sizeof(struct rte_flow_action_vf);
8412 rte_memcpy(&sample_vf[idx],
8413 (const void *)action->conf, size);
8414 action->conf = &sample_vf[idx];
8416 case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP:
8417 size = sizeof(struct rte_flow_action_vxlan_encap);
8418 parse_setup_vxlan_encap_data(&sample_vxlan_encap[idx]);
8419 action->conf = &sample_vxlan_encap[idx].conf;
8421 case RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP:
8422 size = sizeof(struct rte_flow_action_nvgre_encap);
8423 parse_setup_nvgre_encap_data(&sample_nvgre_encap[idx]);
8424 action->conf = &sample_nvgre_encap[idx];
8427 printf("Error - Not supported action\n");
8430 rte_memcpy(data, action, sizeof(struct rte_flow_action));
8435 /** Dispatch parsed buffer to function calls. */
8437 cmd_set_raw_parsed(const struct buffer *in)
8439 uint32_t n = in->args.vc.pattern_n;
8441 struct rte_flow_item *item = NULL;
8443 uint8_t *data = NULL;
8444 uint8_t *data_tail = NULL;
8445 size_t *total_size = NULL;
8446 uint16_t upper_layer = 0;
8448 uint16_t idx = in->port; /* We borrow port field as index */
8449 int gtp_psc = -1; /* GTP PSC option index. */
8451 if (in->command == SET_SAMPLE_ACTIONS)
8452 return cmd_set_raw_parsed_sample(in);
8453 RTE_ASSERT(in->command == SET_RAW_ENCAP ||
8454 in->command == SET_RAW_DECAP);
8455 if (in->command == SET_RAW_ENCAP) {
8456 total_size = &raw_encap_confs[idx].size;
8457 data = (uint8_t *)&raw_encap_confs[idx].data;
8459 total_size = &raw_decap_confs[idx].size;
8460 data = (uint8_t *)&raw_decap_confs[idx].data;
8463 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
8464 /* process hdr from upper layer to low layer (L3/L4 -> L2). */
8465 data_tail = data + ACTION_RAW_ENCAP_MAX_DATA;
8466 for (i = n - 1 ; i >= 0; --i) {
8467 const struct rte_flow_item_gtp *gtp;
8468 const struct rte_flow_item_geneve_opt *opt;
8470 item = in->args.vc.pattern + i;
8471 if (item->spec == NULL)
8472 item->spec = flow_item_default_mask(item);
8473 switch (item->type) {
8474 case RTE_FLOW_ITEM_TYPE_ETH:
8475 size = sizeof(struct rte_ether_hdr);
8477 case RTE_FLOW_ITEM_TYPE_VLAN:
8478 size = sizeof(struct rte_vlan_hdr);
8479 proto = RTE_ETHER_TYPE_VLAN;
8481 case RTE_FLOW_ITEM_TYPE_IPV4:
8482 size = sizeof(struct rte_ipv4_hdr);
8483 proto = RTE_ETHER_TYPE_IPV4;
8485 case RTE_FLOW_ITEM_TYPE_IPV6:
8486 size = sizeof(struct rte_ipv6_hdr);
8487 proto = RTE_ETHER_TYPE_IPV6;
8489 case RTE_FLOW_ITEM_TYPE_UDP:
8490 size = sizeof(struct rte_udp_hdr);
8493 case RTE_FLOW_ITEM_TYPE_TCP:
8494 size = sizeof(struct rte_tcp_hdr);
8497 case RTE_FLOW_ITEM_TYPE_VXLAN:
8498 size = sizeof(struct rte_vxlan_hdr);
8500 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
8501 size = sizeof(struct rte_vxlan_gpe_hdr);
8503 case RTE_FLOW_ITEM_TYPE_GRE:
8504 size = sizeof(struct rte_gre_hdr);
8507 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
8508 size = sizeof(rte_be32_t);
8511 case RTE_FLOW_ITEM_TYPE_MPLS:
8512 size = sizeof(struct rte_mpls_hdr);
8515 case RTE_FLOW_ITEM_TYPE_NVGRE:
8516 size = sizeof(struct rte_flow_item_nvgre);
8519 case RTE_FLOW_ITEM_TYPE_GENEVE:
8520 size = sizeof(struct rte_geneve_hdr);
8522 case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
8523 opt = (const struct rte_flow_item_geneve_opt *)
8525 size = offsetof(struct rte_flow_item_geneve_opt, data);
8526 if (opt->option_len && opt->data) {
8527 *total_size += opt->option_len *
8529 rte_memcpy(data_tail - (*total_size),
8531 opt->option_len * sizeof(uint32_t));
8534 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
8535 size = sizeof(rte_be32_t);
8538 case RTE_FLOW_ITEM_TYPE_ESP:
8539 size = sizeof(struct rte_esp_hdr);
8542 case RTE_FLOW_ITEM_TYPE_AH:
8543 size = sizeof(struct rte_flow_item_ah);
8546 case RTE_FLOW_ITEM_TYPE_GTP:
8548 size = sizeof(struct rte_gtp_hdr);
8551 if (gtp_psc != i + 1) {
8552 printf("Error - GTP PSC does not follow GTP\n");
8556 if ((gtp->v_pt_rsv_flags & 0x07) != 0x04) {
8557 /* Only E flag should be set. */
8558 printf("Error - GTP unsupported flags\n");
8561 struct rte_gtp_hdr_ext_word ext_word = {
8565 /* We have to add GTP header extra word. */
8566 *total_size += sizeof(ext_word);
8567 rte_memcpy(data_tail - (*total_size),
8568 &ext_word, sizeof(ext_word));
8570 size = sizeof(struct rte_gtp_hdr);
8572 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
8574 printf("Error - Multiple GTP PSC items\n");
8577 const struct rte_flow_item_gtp_psc
8586 if (opt->pdu_type & 0x0F) {
8587 /* Support the minimal option only. */
8588 printf("Error - GTP PSC option with "
8589 "extra fields not supported\n");
8592 psc.len = sizeof(psc);
8593 psc.pdu_type = opt->pdu_type;
8596 *total_size += sizeof(psc);
8597 rte_memcpy(data_tail - (*total_size),
8603 case RTE_FLOW_ITEM_TYPE_PFCP:
8604 size = sizeof(struct rte_flow_item_pfcp);
8607 printf("Error - Not supported item\n");
8610 *total_size += size;
8611 rte_memcpy(data_tail - (*total_size), item->spec, size);
8612 /* update some fields which cannot be set by cmdline */
8613 update_fields((data_tail - (*total_size)), item,
8615 upper_layer = proto;
8617 if (verbose_level & 0x1)
8618 printf("total data size is %zu\n", (*total_size));
8619 RTE_ASSERT((*total_size) <= ACTION_RAW_ENCAP_MAX_DATA);
8620 memmove(data, (data_tail - (*total_size)), *total_size);
8625 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
8628 /** Populate help strings for current token (cmdline API). */
8630 cmd_set_raw_get_help(cmdline_parse_token_hdr_t *hdr, char *dst,
8633 struct context *ctx = &cmd_flow_context;
8634 const struct token *token = &token_list[ctx->prev];
8639 /* Set token type and update global help with details. */
8640 snprintf(dst, size, "%s", (token->type ? token->type : "TOKEN"));
8642 cmd_set_raw.help_str = token->help;
8644 cmd_set_raw.help_str = token->name;
8648 /** Token definition template (cmdline API). */
8649 static struct cmdline_token_hdr cmd_set_raw_token_hdr = {
8650 .ops = &(struct cmdline_token_ops){
8651 .parse = cmd_flow_parse,
8652 .complete_get_nb = cmd_flow_complete_get_nb,
8653 .complete_get_elt = cmd_flow_complete_get_elt,
8654 .get_help = cmd_set_raw_get_help,
8659 /** Populate the next dynamic token. */
8661 cmd_set_raw_tok(cmdline_parse_token_hdr_t **hdr,
8662 cmdline_parse_token_hdr_t **hdr_inst)
8664 struct context *ctx = &cmd_flow_context;
8666 /* Always reinitialize context before requesting the first token. */
8667 if (!(hdr_inst - cmd_set_raw.tokens)) {
8668 cmd_flow_context_init(ctx);
8669 ctx->curr = START_SET;
8671 /* Return NULL when no more tokens are expected. */
8672 if (!ctx->next_num && (ctx->curr != START_SET)) {
8676 /* Determine if command should end here. */
8677 if (ctx->eol && ctx->last && ctx->next_num) {
8678 const enum index *list = ctx->next[ctx->next_num - 1];
8681 for (i = 0; list[i]; ++i) {
8688 *hdr = &cmd_set_raw_token_hdr;
8691 /** Token generator and output processing callback (cmdline API). */
8693 cmd_set_raw_cb(void *arg0, struct cmdline *cl, void *arg2)
8696 cmd_set_raw_tok(arg0, arg2);
8698 cmd_set_raw_parsed(arg0);
8701 /** Global parser instance (cmdline API). */
8702 cmdline_parse_inst_t cmd_set_raw = {
8703 .f = cmd_set_raw_cb,
8704 .data = NULL, /**< Unused. */
8705 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
8708 }, /**< Tokens are returned by cmd_flow_tok(). */
8711 /* *** display raw_encap/raw_decap buf */
8712 struct cmd_show_set_raw_result {
8713 cmdline_fixed_string_t cmd_show;
8714 cmdline_fixed_string_t cmd_what;
8715 cmdline_fixed_string_t cmd_all;
8720 cmd_show_set_raw_parsed(void *parsed_result, struct cmdline *cl, void *data)
8722 struct cmd_show_set_raw_result *res = parsed_result;
8723 uint16_t index = res->cmd_index;
8725 uint8_t *raw_data = NULL;
8726 size_t raw_size = 0;
8727 char title[16] = {0};
8731 if (!strcmp(res->cmd_all, "all")) {
8734 } else if (index >= RAW_ENCAP_CONFS_MAX_NUM) {
8735 printf("index should be 0-%u\n", RAW_ENCAP_CONFS_MAX_NUM - 1);
8739 if (!strcmp(res->cmd_what, "raw_encap")) {
8740 raw_data = (uint8_t *)&raw_encap_confs[index].data;
8741 raw_size = raw_encap_confs[index].size;
8742 snprintf(title, 16, "\nindex: %u", index);
8743 rte_hexdump(stdout, title, raw_data, raw_size);
8745 raw_data = (uint8_t *)&raw_decap_confs[index].data;
8746 raw_size = raw_decap_confs[index].size;
8747 snprintf(title, 16, "\nindex: %u", index);
8748 rte_hexdump(stdout, title, raw_data, raw_size);
8750 } while (all && ++index < RAW_ENCAP_CONFS_MAX_NUM);
8753 cmdline_parse_token_string_t cmd_show_set_raw_cmd_show =
8754 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
8756 cmdline_parse_token_string_t cmd_show_set_raw_cmd_what =
8757 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
8758 cmd_what, "raw_encap#raw_decap");
8759 cmdline_parse_token_num_t cmd_show_set_raw_cmd_index =
8760 TOKEN_NUM_INITIALIZER(struct cmd_show_set_raw_result,
8761 cmd_index, RTE_UINT16);
8762 cmdline_parse_token_string_t cmd_show_set_raw_cmd_all =
8763 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
8765 cmdline_parse_inst_t cmd_show_set_raw = {
8766 .f = cmd_show_set_raw_parsed,
8768 .help_str = "show <raw_encap|raw_decap> <index>",
8770 (void *)&cmd_show_set_raw_cmd_show,
8771 (void *)&cmd_show_set_raw_cmd_what,
8772 (void *)&cmd_show_set_raw_cmd_index,
8776 cmdline_parse_inst_t cmd_show_set_raw_all = {
8777 .f = cmd_show_set_raw_parsed,
8779 .help_str = "show <raw_encap|raw_decap> all",
8781 (void *)&cmd_show_set_raw_cmd_show,
8782 (void *)&cmd_show_set_raw_cmd_what,
8783 (void *)&cmd_show_set_raw_cmd_all,