1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2016 6WIND S.A.
3 * Copyright 2016 Mellanox Technologies, Ltd
14 #include <rte_string_fns.h>
15 #include <rte_common.h>
16 #include <rte_ethdev.h>
17 #include <rte_byteorder.h>
18 #include <cmdline_parse.h>
19 #include <cmdline_parse_etheraddr.h>
20 #include <cmdline_parse_string.h>
21 #include <cmdline_parse_num.h>
23 #include <rte_hexdump.h>
24 #include <rte_vxlan.h>
28 #include <rte_geneve.h>
32 /** Parser token indices. */
54 COMMON_PRIORITY_LEVEL,
55 COMMON_INDIRECT_ACTION_ID,
58 /* TOP-level command. */
61 /* Top-level command. */
63 /* Sub-leve commands. */
70 /* Top-level command. */
72 /* Sub-level commands. */
85 /* Tunnel arguments. */
92 /* Destroy arguments. */
95 /* Query arguments. */
101 /* Destroy aged flow arguments. */
104 /* Validate/create arguments. */
117 /* Indirect action arguments */
118 INDIRECT_ACTION_CREATE,
119 INDIRECT_ACTION_UPDATE,
120 INDIRECT_ACTION_DESTROY,
121 INDIRECT_ACTION_QUERY,
123 /* Indirect action create arguments */
124 INDIRECT_ACTION_CREATE_ID,
125 INDIRECT_ACTION_INGRESS,
126 INDIRECT_ACTION_EGRESS,
127 INDIRECT_ACTION_TRANSFER,
128 INDIRECT_ACTION_SPEC,
130 /* Indirect action destroy arguments */
131 INDIRECT_ACTION_DESTROY_ID,
133 /* Validate/create pattern. */
171 ITEM_VLAN_INNER_TYPE,
172 ITEM_VLAN_HAS_MORE_VLAN,
177 ITEM_IPV4_FRAGMENT_OFFSET,
189 ITEM_IPV6_HAS_FRAG_EXT,
209 ITEM_VXLAN_LAST_RSVD,
211 ITEM_E_TAG_GRP_ECID_B,
220 ITEM_GRE_C_RSVD0_VER,
239 ITEM_ARP_ETH_IPV4_SHA,
240 ITEM_ARP_ETH_IPV4_SPA,
241 ITEM_ARP_ETH_IPV4_THA,
242 ITEM_ARP_ETH_IPV4_TPA,
244 ITEM_IPV6_EXT_NEXT_HDR,
246 ITEM_IPV6_FRAG_EXT_NEXT_HDR,
247 ITEM_IPV6_FRAG_EXT_FRAG_DATA,
248 ITEM_IPV6_FRAG_EXT_ID,
253 ITEM_ICMP6_ND_NS_TARGET_ADDR,
255 ITEM_ICMP6_ND_NA_TARGET_ADDR,
257 ITEM_ICMP6_ND_OPT_TYPE,
258 ITEM_ICMP6_ND_OPT_SLA_ETH,
259 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
260 ITEM_ICMP6_ND_OPT_TLA_ETH,
261 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
274 ITEM_HIGIG2_CLASSIFICATION,
280 ITEM_L2TPV3OIP_SESSION_ID,
290 ITEM_ECPRI_COMMON_TYPE,
291 ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
292 ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
293 ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
294 ITEM_ECPRI_MSG_IQ_DATA_PCID,
295 ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
296 ITEM_ECPRI_MSG_DLY_MSR_MSRID,
298 ITEM_GENEVE_OPT_CLASS,
299 ITEM_GENEVE_OPT_TYPE,
300 ITEM_GENEVE_OPT_LENGTH,
301 ITEM_GENEVE_OPT_DATA,
303 ITEM_INTEGRITY_LEVEL,
304 ITEM_INTEGRITY_VALUE,
309 ITEM_PORT_REPRESENTOR,
310 ITEM_PORT_REPRESENTOR_PORT_ID,
311 ITEM_REPRESENTED_PORT,
312 ITEM_REPRESENTED_PORT_ETHDEV_PORT_ID,
314 /* Validate/create actions. */
333 ACTION_RSS_FUNC_DEFAULT,
334 ACTION_RSS_FUNC_TOEPLITZ,
335 ACTION_RSS_FUNC_SIMPLE_XOR,
336 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ,
348 ACTION_PHY_PORT_ORIGINAL,
349 ACTION_PHY_PORT_INDEX,
351 ACTION_PORT_ID_ORIGINAL,
355 ACTION_METER_COLOR_TYPE,
356 ACTION_METER_COLOR_GREEN,
357 ACTION_METER_COLOR_YELLOW,
358 ACTION_METER_COLOR_RED,
360 ACTION_OF_SET_MPLS_TTL,
361 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
362 ACTION_OF_DEC_MPLS_TTL,
363 ACTION_OF_SET_NW_TTL,
364 ACTION_OF_SET_NW_TTL_NW_TTL,
365 ACTION_OF_DEC_NW_TTL,
366 ACTION_OF_COPY_TTL_OUT,
367 ACTION_OF_COPY_TTL_IN,
370 ACTION_OF_PUSH_VLAN_ETHERTYPE,
371 ACTION_OF_SET_VLAN_VID,
372 ACTION_OF_SET_VLAN_VID_VLAN_VID,
373 ACTION_OF_SET_VLAN_PCP,
374 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
376 ACTION_OF_POP_MPLS_ETHERTYPE,
378 ACTION_OF_PUSH_MPLS_ETHERTYPE,
385 ACTION_MPLSOGRE_ENCAP,
386 ACTION_MPLSOGRE_DECAP,
387 ACTION_MPLSOUDP_ENCAP,
388 ACTION_MPLSOUDP_DECAP,
390 ACTION_SET_IPV4_SRC_IPV4_SRC,
392 ACTION_SET_IPV4_DST_IPV4_DST,
394 ACTION_SET_IPV6_SRC_IPV6_SRC,
396 ACTION_SET_IPV6_DST_IPV6_DST,
398 ACTION_SET_TP_SRC_TP_SRC,
400 ACTION_SET_TP_DST_TP_DST,
406 ACTION_SET_MAC_SRC_MAC_SRC,
408 ACTION_SET_MAC_DST_MAC_DST,
410 ACTION_INC_TCP_SEQ_VALUE,
412 ACTION_DEC_TCP_SEQ_VALUE,
414 ACTION_INC_TCP_ACK_VALUE,
416 ACTION_DEC_TCP_ACK_VALUE,
419 ACTION_RAW_ENCAP_INDEX,
420 ACTION_RAW_ENCAP_INDEX_VALUE,
421 ACTION_RAW_DECAP_INDEX,
422 ACTION_RAW_DECAP_INDEX_VALUE,
425 ACTION_SET_TAG_INDEX,
428 ACTION_SET_META_DATA,
429 ACTION_SET_META_MASK,
430 ACTION_SET_IPV4_DSCP,
431 ACTION_SET_IPV4_DSCP_VALUE,
432 ACTION_SET_IPV6_DSCP,
433 ACTION_SET_IPV6_DSCP_VALUE,
439 ACTION_SAMPLE_INDEX_VALUE,
441 INDIRECT_ACTION_ID2PTR,
443 ACTION_MODIFY_FIELD_OP,
444 ACTION_MODIFY_FIELD_OP_VALUE,
445 ACTION_MODIFY_FIELD_DST_TYPE,
446 ACTION_MODIFY_FIELD_DST_TYPE_VALUE,
447 ACTION_MODIFY_FIELD_DST_LEVEL,
448 ACTION_MODIFY_FIELD_DST_OFFSET,
449 ACTION_MODIFY_FIELD_SRC_TYPE,
450 ACTION_MODIFY_FIELD_SRC_TYPE_VALUE,
451 ACTION_MODIFY_FIELD_SRC_LEVEL,
452 ACTION_MODIFY_FIELD_SRC_OFFSET,
453 ACTION_MODIFY_FIELD_SRC_VALUE,
454 ACTION_MODIFY_FIELD_SRC_POINTER,
455 ACTION_MODIFY_FIELD_WIDTH,
457 ACTION_CONNTRACK_UPDATE,
458 ACTION_CONNTRACK_UPDATE_DIR,
459 ACTION_CONNTRACK_UPDATE_CTX,
463 ACTION_PORT_REPRESENTOR,
464 ACTION_PORT_REPRESENTOR_PORT_ID,
465 ACTION_REPRESENTED_PORT,
466 ACTION_REPRESENTED_PORT_ETHDEV_PORT_ID,
469 /** Maximum size for pattern in struct rte_flow_item_raw. */
470 #define ITEM_RAW_PATTERN_SIZE 40
472 /** Maximum size for GENEVE option data pattern in bytes. */
473 #define ITEM_GENEVE_OPT_DATA_SIZE 124
475 /** Storage size for struct rte_flow_item_raw including pattern. */
476 #define ITEM_RAW_SIZE \
477 (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE)
479 /** Maximum size for external pattern in struct rte_flow_action_modify_data. */
480 #define ACTION_MODIFY_PATTERN_SIZE 32
482 /** Storage size for struct rte_flow_action_modify_field including pattern. */
483 #define ACTION_MODIFY_SIZE \
484 (sizeof(struct rte_flow_action_modify_field) + \
485 ACTION_MODIFY_PATTERN_SIZE)
487 /** Maximum number of queue indices in struct rte_flow_action_rss. */
488 #define ACTION_RSS_QUEUE_NUM 128
490 /** Storage for struct rte_flow_action_rss including external data. */
491 struct action_rss_data {
492 struct rte_flow_action_rss conf;
493 uint8_t key[RSS_HASH_KEY_LENGTH];
494 uint16_t queue[ACTION_RSS_QUEUE_NUM];
497 /** Maximum data size in struct rte_flow_action_raw_encap. */
498 #define ACTION_RAW_ENCAP_MAX_DATA 512
499 #define RAW_ENCAP_CONFS_MAX_NUM 8
501 /** Storage for struct rte_flow_action_raw_encap. */
502 struct raw_encap_conf {
503 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
504 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
508 struct raw_encap_conf raw_encap_confs[RAW_ENCAP_CONFS_MAX_NUM];
510 /** Storage for struct rte_flow_action_raw_encap including external data. */
511 struct action_raw_encap_data {
512 struct rte_flow_action_raw_encap conf;
513 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
514 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
518 /** Storage for struct rte_flow_action_raw_decap. */
519 struct raw_decap_conf {
520 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
524 struct raw_decap_conf raw_decap_confs[RAW_ENCAP_CONFS_MAX_NUM];
526 /** Storage for struct rte_flow_action_raw_decap including external data. */
527 struct action_raw_decap_data {
528 struct rte_flow_action_raw_decap conf;
529 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
533 struct vxlan_encap_conf vxlan_encap_conf = {
537 .vni = "\x00\x00\x00",
539 .udp_dst = RTE_BE16(RTE_VXLAN_DEFAULT_PORT),
540 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
541 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
542 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
543 "\x00\x00\x00\x00\x00\x00\x00\x01",
544 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
545 "\x00\x00\x00\x00\x00\x00\x11\x11",
549 .eth_src = "\x00\x00\x00\x00\x00\x00",
550 .eth_dst = "\xff\xff\xff\xff\xff\xff",
553 /** Maximum number of items in struct rte_flow_action_vxlan_encap. */
554 #define ACTION_VXLAN_ENCAP_ITEMS_NUM 6
556 /** Storage for struct rte_flow_action_vxlan_encap including external data. */
557 struct action_vxlan_encap_data {
558 struct rte_flow_action_vxlan_encap conf;
559 struct rte_flow_item items[ACTION_VXLAN_ENCAP_ITEMS_NUM];
560 struct rte_flow_item_eth item_eth;
561 struct rte_flow_item_vlan item_vlan;
563 struct rte_flow_item_ipv4 item_ipv4;
564 struct rte_flow_item_ipv6 item_ipv6;
566 struct rte_flow_item_udp item_udp;
567 struct rte_flow_item_vxlan item_vxlan;
570 struct nvgre_encap_conf nvgre_encap_conf = {
573 .tni = "\x00\x00\x00",
574 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
575 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
576 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
577 "\x00\x00\x00\x00\x00\x00\x00\x01",
578 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
579 "\x00\x00\x00\x00\x00\x00\x11\x11",
581 .eth_src = "\x00\x00\x00\x00\x00\x00",
582 .eth_dst = "\xff\xff\xff\xff\xff\xff",
585 /** Maximum number of items in struct rte_flow_action_nvgre_encap. */
586 #define ACTION_NVGRE_ENCAP_ITEMS_NUM 5
588 /** Storage for struct rte_flow_action_nvgre_encap including external data. */
589 struct action_nvgre_encap_data {
590 struct rte_flow_action_nvgre_encap conf;
591 struct rte_flow_item items[ACTION_NVGRE_ENCAP_ITEMS_NUM];
592 struct rte_flow_item_eth item_eth;
593 struct rte_flow_item_vlan item_vlan;
595 struct rte_flow_item_ipv4 item_ipv4;
596 struct rte_flow_item_ipv6 item_ipv6;
598 struct rte_flow_item_nvgre item_nvgre;
601 struct l2_encap_conf l2_encap_conf;
603 struct l2_decap_conf l2_decap_conf;
605 struct mplsogre_encap_conf mplsogre_encap_conf;
607 struct mplsogre_decap_conf mplsogre_decap_conf;
609 struct mplsoudp_encap_conf mplsoudp_encap_conf;
611 struct mplsoudp_decap_conf mplsoudp_decap_conf;
613 struct rte_flow_action_conntrack conntrack_context;
615 #define ACTION_SAMPLE_ACTIONS_NUM 10
616 #define RAW_SAMPLE_CONFS_MAX_NUM 8
617 /** Storage for struct rte_flow_action_sample including external data. */
618 struct action_sample_data {
619 struct rte_flow_action_sample conf;
622 /** Storage for struct rte_flow_action_sample. */
623 struct raw_sample_conf {
624 struct rte_flow_action data[ACTION_SAMPLE_ACTIONS_NUM];
626 struct raw_sample_conf raw_sample_confs[RAW_SAMPLE_CONFS_MAX_NUM];
627 struct rte_flow_action_mark sample_mark[RAW_SAMPLE_CONFS_MAX_NUM];
628 struct rte_flow_action_queue sample_queue[RAW_SAMPLE_CONFS_MAX_NUM];
629 struct rte_flow_action_count sample_count[RAW_SAMPLE_CONFS_MAX_NUM];
630 struct rte_flow_action_port_id sample_port_id[RAW_SAMPLE_CONFS_MAX_NUM];
631 struct rte_flow_action_raw_encap sample_encap[RAW_SAMPLE_CONFS_MAX_NUM];
632 struct action_vxlan_encap_data sample_vxlan_encap[RAW_SAMPLE_CONFS_MAX_NUM];
633 struct action_nvgre_encap_data sample_nvgre_encap[RAW_SAMPLE_CONFS_MAX_NUM];
634 struct action_rss_data sample_rss_data[RAW_SAMPLE_CONFS_MAX_NUM];
635 struct rte_flow_action_vf sample_vf[RAW_SAMPLE_CONFS_MAX_NUM];
637 static const char *const modify_field_ops[] = {
638 "set", "add", "sub", NULL
641 static const char *const modify_field_ids[] = {
642 "start", "mac_dst", "mac_src",
643 "vlan_type", "vlan_id", "mac_type",
644 "ipv4_dscp", "ipv4_ttl", "ipv4_src", "ipv4_dst",
645 "ipv6_dscp", "ipv6_hoplimit", "ipv6_src", "ipv6_dst",
646 "tcp_port_src", "tcp_port_dst",
647 "tcp_seq_num", "tcp_ack_num", "tcp_flags",
648 "udp_port_src", "udp_port_dst",
649 "vxlan_vni", "geneve_vni", "gtp_teid",
650 "tag", "mark", "meta", "pointer", "value", NULL
653 /** Maximum number of subsequent tokens and arguments on the stack. */
654 #define CTX_STACK_SIZE 16
656 /** Parser context. */
658 /** Stack of subsequent token lists to process. */
659 const enum index *next[CTX_STACK_SIZE];
660 /** Arguments for stacked tokens. */
661 const void *args[CTX_STACK_SIZE];
662 enum index curr; /**< Current token index. */
663 enum index prev; /**< Index of the last token seen. */
664 int next_num; /**< Number of entries in next[]. */
665 int args_num; /**< Number of entries in args[]. */
666 uint32_t eol:1; /**< EOL has been detected. */
667 uint32_t last:1; /**< No more arguments. */
668 portid_t port; /**< Current port ID (for completions). */
669 uint32_t objdata; /**< Object-specific data. */
670 void *object; /**< Address of current object for relative offsets. */
671 void *objmask; /**< Object a full mask must be written to. */
674 /** Token argument. */
676 uint32_t hton:1; /**< Use network byte ordering. */
677 uint32_t sign:1; /**< Value is signed. */
678 uint32_t bounded:1; /**< Value is bounded. */
679 uintmax_t min; /**< Minimum value if bounded. */
680 uintmax_t max; /**< Maximum value if bounded. */
681 uint32_t offset; /**< Relative offset from ctx->object. */
682 uint32_t size; /**< Field size. */
683 const uint8_t *mask; /**< Bit-mask to use instead of offset/size. */
686 /** Parser token definition. */
688 /** Type displayed during completion (defaults to "TOKEN"). */
690 /** Help displayed during completion (defaults to token name). */
692 /** Private data used by parser functions. */
695 * Lists of subsequent tokens to push on the stack. Each call to the
696 * parser consumes the last entry of that stack.
698 const enum index *const *next;
699 /** Arguments stack for subsequent tokens that need them. */
700 const struct arg *const *args;
702 * Token-processing callback, returns -1 in case of error, the
703 * length of the matched string otherwise. If NULL, attempts to
704 * match the token name.
706 * If buf is not NULL, the result should be stored in it according
707 * to context. An error is returned if not large enough.
709 int (*call)(struct context *ctx, const struct token *token,
710 const char *str, unsigned int len,
711 void *buf, unsigned int size);
713 * Callback that provides possible values for this token, used for
714 * completion. Returns -1 in case of error, the number of possible
715 * values otherwise. If NULL, the token name is used.
717 * If buf is not NULL, entry index ent is written to buf and the
718 * full length of the entry is returned (same behavior as
721 int (*comp)(struct context *ctx, const struct token *token,
722 unsigned int ent, char *buf, unsigned int size);
723 /** Mandatory token name, no default value. */
727 /** Static initializer for the next field. */
728 #define NEXT(...) (const enum index *const []){ __VA_ARGS__, NULL, }
730 /** Static initializer for a NEXT() entry. */
731 #define NEXT_ENTRY(...) (const enum index []){ __VA_ARGS__, ZERO, }
733 /** Static initializer for the args field. */
734 #define ARGS(...) (const struct arg *const []){ __VA_ARGS__, NULL, }
736 /** Static initializer for ARGS() to target a field. */
737 #define ARGS_ENTRY(s, f) \
738 (&(const struct arg){ \
739 .offset = offsetof(s, f), \
740 .size = sizeof(((s *)0)->f), \
743 /** Static initializer for ARGS() to target a bit-field. */
744 #define ARGS_ENTRY_BF(s, f, b) \
745 (&(const struct arg){ \
747 .mask = (const void *)&(const s){ .f = (1 << (b)) - 1 }, \
750 /** Static initializer for ARGS() to target a field with limits. */
751 #define ARGS_ENTRY_BOUNDED(s, f, i, a) \
752 (&(const struct arg){ \
756 .offset = offsetof(s, f), \
757 .size = sizeof(((s *)0)->f), \
760 /** Static initializer for ARGS() to target an arbitrary bit-mask. */
761 #define ARGS_ENTRY_MASK(s, f, m) \
762 (&(const struct arg){ \
763 .offset = offsetof(s, f), \
764 .size = sizeof(((s *)0)->f), \
765 .mask = (const void *)(m), \
768 /** Same as ARGS_ENTRY_MASK() using network byte ordering for the value. */
769 #define ARGS_ENTRY_MASK_HTON(s, f, m) \
770 (&(const struct arg){ \
772 .offset = offsetof(s, f), \
773 .size = sizeof(((s *)0)->f), \
774 .mask = (const void *)(m), \
777 /** Static initializer for ARGS() to target a pointer. */
778 #define ARGS_ENTRY_PTR(s, f) \
779 (&(const struct arg){ \
780 .size = sizeof(*((s *)0)->f), \
783 /** Static initializer for ARGS() with arbitrary offset and size. */
784 #define ARGS_ENTRY_ARB(o, s) \
785 (&(const struct arg){ \
790 /** Same as ARGS_ENTRY_ARB() with bounded values. */
791 #define ARGS_ENTRY_ARB_BOUNDED(o, s, i, a) \
792 (&(const struct arg){ \
800 /** Same as ARGS_ENTRY() using network byte ordering. */
801 #define ARGS_ENTRY_HTON(s, f) \
802 (&(const struct arg){ \
804 .offset = offsetof(s, f), \
805 .size = sizeof(((s *)0)->f), \
808 /** Same as ARGS_ENTRY_HTON() for a single argument, without structure. */
809 #define ARG_ENTRY_HTON(s) \
810 (&(const struct arg){ \
816 /** Parser output buffer layout expected by cmd_flow_parsed(). */
818 enum index command; /**< Flow command. */
819 portid_t port; /**< Affected port ID. */
823 uint32_t action_id_n;
824 } ia_destroy; /**< Indirect action destroy arguments. */
827 } ia; /* Indirect action query arguments */
829 struct rte_flow_attr attr;
830 struct tunnel_ops tunnel_ops;
831 struct rte_flow_item *pattern;
832 struct rte_flow_action *actions;
836 } vc; /**< Validate/create arguments. */
840 } destroy; /**< Destroy arguments. */
845 } dump; /**< Dump arguments. */
848 struct rte_flow_action action;
849 } query; /**< Query arguments. */
853 } list; /**< List arguments. */
856 } isolate; /**< Isolated mode arguments. */
859 } aged; /**< Aged arguments. */
862 } policy;/**< Policy arguments. */
863 } args; /**< Command arguments. */
866 /** Private data for pattern items. */
867 struct parse_item_priv {
868 enum rte_flow_item_type type; /**< Item type. */
869 uint32_t size; /**< Size of item specification structure. */
872 #define PRIV_ITEM(t, s) \
873 (&(const struct parse_item_priv){ \
874 .type = RTE_FLOW_ITEM_TYPE_ ## t, \
878 /** Private data for actions. */
879 struct parse_action_priv {
880 enum rte_flow_action_type type; /**< Action type. */
881 uint32_t size; /**< Size of action configuration structure. */
884 #define PRIV_ACTION(t, s) \
885 (&(const struct parse_action_priv){ \
886 .type = RTE_FLOW_ACTION_TYPE_ ## t, \
890 static const enum index next_ia_create_attr[] = {
891 INDIRECT_ACTION_CREATE_ID,
892 INDIRECT_ACTION_INGRESS,
893 INDIRECT_ACTION_EGRESS,
894 INDIRECT_ACTION_TRANSFER,
895 INDIRECT_ACTION_SPEC,
899 static const enum index next_dump_subcmd[] = {
905 static const enum index next_ia_subcmd[] = {
906 INDIRECT_ACTION_CREATE,
907 INDIRECT_ACTION_UPDATE,
908 INDIRECT_ACTION_DESTROY,
909 INDIRECT_ACTION_QUERY,
913 static const enum index next_vc_attr[] = {
925 static const enum index next_destroy_attr[] = {
931 static const enum index next_dump_attr[] = {
937 static const enum index next_list_attr[] = {
943 static const enum index next_aged_attr[] = {
949 static const enum index next_ia_destroy_attr[] = {
950 INDIRECT_ACTION_DESTROY_ID,
955 static const enum index item_param[] = {
964 static const enum index next_item[] = {
1001 ITEM_ICMP6_ND_OPT_SLA_ETH,
1002 ITEM_ICMP6_ND_OPT_TLA_ETH,
1008 ITEM_PPPOE_PROTO_ID,
1019 ITEM_PORT_REPRESENTOR,
1020 ITEM_REPRESENTED_PORT,
1025 static const enum index item_fuzzy[] = {
1031 static const enum index item_any[] = {
1037 static const enum index item_vf[] = {
1043 static const enum index item_phy_port[] = {
1044 ITEM_PHY_PORT_INDEX,
1049 static const enum index item_port_id[] = {
1055 static const enum index item_mark[] = {
1061 static const enum index item_raw[] = {
1071 static const enum index item_eth[] = {
1080 static const enum index item_vlan[] = {
1085 ITEM_VLAN_INNER_TYPE,
1086 ITEM_VLAN_HAS_MORE_VLAN,
1091 static const enum index item_ipv4[] = {
1095 ITEM_IPV4_FRAGMENT_OFFSET,
1104 static const enum index item_ipv6[] = {
1111 ITEM_IPV6_HAS_FRAG_EXT,
1116 static const enum index item_icmp[] = {
1125 static const enum index item_udp[] = {
1132 static const enum index item_tcp[] = {
1140 static const enum index item_sctp[] = {
1149 static const enum index item_vxlan[] = {
1151 ITEM_VXLAN_LAST_RSVD,
1156 static const enum index item_e_tag[] = {
1157 ITEM_E_TAG_GRP_ECID_B,
1162 static const enum index item_nvgre[] = {
1168 static const enum index item_mpls[] = {
1176 static const enum index item_gre[] = {
1178 ITEM_GRE_C_RSVD0_VER,
1186 static const enum index item_gre_key[] = {
1192 static const enum index item_gtp[] = {
1200 static const enum index item_geneve[] = {
1208 static const enum index item_vxlan_gpe[] = {
1214 static const enum index item_arp_eth_ipv4[] = {
1215 ITEM_ARP_ETH_IPV4_SHA,
1216 ITEM_ARP_ETH_IPV4_SPA,
1217 ITEM_ARP_ETH_IPV4_THA,
1218 ITEM_ARP_ETH_IPV4_TPA,
1223 static const enum index item_ipv6_ext[] = {
1224 ITEM_IPV6_EXT_NEXT_HDR,
1229 static const enum index item_ipv6_frag_ext[] = {
1230 ITEM_IPV6_FRAG_EXT_NEXT_HDR,
1231 ITEM_IPV6_FRAG_EXT_FRAG_DATA,
1232 ITEM_IPV6_FRAG_EXT_ID,
1237 static const enum index item_icmp6[] = {
1244 static const enum index item_icmp6_nd_ns[] = {
1245 ITEM_ICMP6_ND_NS_TARGET_ADDR,
1250 static const enum index item_icmp6_nd_na[] = {
1251 ITEM_ICMP6_ND_NA_TARGET_ADDR,
1256 static const enum index item_icmp6_nd_opt[] = {
1257 ITEM_ICMP6_ND_OPT_TYPE,
1262 static const enum index item_icmp6_nd_opt_sla_eth[] = {
1263 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
1268 static const enum index item_icmp6_nd_opt_tla_eth[] = {
1269 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
1274 static const enum index item_meta[] = {
1280 static const enum index item_gtp_psc[] = {
1287 static const enum index item_pppoed[] = {
1293 static const enum index item_pppoes[] = {
1299 static const enum index item_pppoe_proto_id[] = {
1304 static const enum index item_higig2[] = {
1305 ITEM_HIGIG2_CLASSIFICATION,
1311 static const enum index item_esp[] = {
1317 static const enum index item_ah[] = {
1323 static const enum index item_pfcp[] = {
1330 static const enum index next_set_raw[] = {
1336 static const enum index item_tag[] = {
1343 static const enum index item_l2tpv3oip[] = {
1344 ITEM_L2TPV3OIP_SESSION_ID,
1349 static const enum index item_ecpri[] = {
1355 static const enum index item_ecpri_common[] = {
1356 ITEM_ECPRI_COMMON_TYPE,
1360 static const enum index item_ecpri_common_type[] = {
1361 ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
1362 ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
1363 ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
1367 static const enum index item_geneve_opt[] = {
1368 ITEM_GENEVE_OPT_CLASS,
1369 ITEM_GENEVE_OPT_TYPE,
1370 ITEM_GENEVE_OPT_LENGTH,
1371 ITEM_GENEVE_OPT_DATA,
1376 static const enum index item_integrity[] = {
1377 ITEM_INTEGRITY_LEVEL,
1378 ITEM_INTEGRITY_VALUE,
1382 static const enum index item_integrity_lv[] = {
1383 ITEM_INTEGRITY_LEVEL,
1384 ITEM_INTEGRITY_VALUE,
1389 static const enum index item_port_representor[] = {
1390 ITEM_PORT_REPRESENTOR_PORT_ID,
1395 static const enum index item_represented_port[] = {
1396 ITEM_REPRESENTED_PORT_ETHDEV_PORT_ID,
1401 static const enum index next_action[] = {
1418 ACTION_OF_SET_MPLS_TTL,
1419 ACTION_OF_DEC_MPLS_TTL,
1420 ACTION_OF_SET_NW_TTL,
1421 ACTION_OF_DEC_NW_TTL,
1422 ACTION_OF_COPY_TTL_OUT,
1423 ACTION_OF_COPY_TTL_IN,
1425 ACTION_OF_PUSH_VLAN,
1426 ACTION_OF_SET_VLAN_VID,
1427 ACTION_OF_SET_VLAN_PCP,
1429 ACTION_OF_PUSH_MPLS,
1436 ACTION_MPLSOGRE_ENCAP,
1437 ACTION_MPLSOGRE_DECAP,
1438 ACTION_MPLSOUDP_ENCAP,
1439 ACTION_MPLSOUDP_DECAP,
1440 ACTION_SET_IPV4_SRC,
1441 ACTION_SET_IPV4_DST,
1442 ACTION_SET_IPV6_SRC,
1443 ACTION_SET_IPV6_DST,
1459 ACTION_SET_IPV4_DSCP,
1460 ACTION_SET_IPV6_DSCP,
1464 ACTION_MODIFY_FIELD,
1466 ACTION_CONNTRACK_UPDATE,
1467 ACTION_PORT_REPRESENTOR,
1468 ACTION_REPRESENTED_PORT,
1472 static const enum index action_mark[] = {
1478 static const enum index action_queue[] = {
1484 static const enum index action_count[] = {
1490 static const enum index action_rss[] = {
1501 static const enum index action_vf[] = {
1508 static const enum index action_phy_port[] = {
1509 ACTION_PHY_PORT_ORIGINAL,
1510 ACTION_PHY_PORT_INDEX,
1515 static const enum index action_port_id[] = {
1516 ACTION_PORT_ID_ORIGINAL,
1522 static const enum index action_meter[] = {
1528 static const enum index action_meter_color[] = {
1529 ACTION_METER_COLOR_TYPE,
1534 static const enum index action_of_set_mpls_ttl[] = {
1535 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
1540 static const enum index action_of_set_nw_ttl[] = {
1541 ACTION_OF_SET_NW_TTL_NW_TTL,
1546 static const enum index action_of_push_vlan[] = {
1547 ACTION_OF_PUSH_VLAN_ETHERTYPE,
1552 static const enum index action_of_set_vlan_vid[] = {
1553 ACTION_OF_SET_VLAN_VID_VLAN_VID,
1558 static const enum index action_of_set_vlan_pcp[] = {
1559 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
1564 static const enum index action_of_pop_mpls[] = {
1565 ACTION_OF_POP_MPLS_ETHERTYPE,
1570 static const enum index action_of_push_mpls[] = {
1571 ACTION_OF_PUSH_MPLS_ETHERTYPE,
1576 static const enum index action_set_ipv4_src[] = {
1577 ACTION_SET_IPV4_SRC_IPV4_SRC,
1582 static const enum index action_set_mac_src[] = {
1583 ACTION_SET_MAC_SRC_MAC_SRC,
1588 static const enum index action_set_ipv4_dst[] = {
1589 ACTION_SET_IPV4_DST_IPV4_DST,
1594 static const enum index action_set_ipv6_src[] = {
1595 ACTION_SET_IPV6_SRC_IPV6_SRC,
1600 static const enum index action_set_ipv6_dst[] = {
1601 ACTION_SET_IPV6_DST_IPV6_DST,
1606 static const enum index action_set_tp_src[] = {
1607 ACTION_SET_TP_SRC_TP_SRC,
1612 static const enum index action_set_tp_dst[] = {
1613 ACTION_SET_TP_DST_TP_DST,
1618 static const enum index action_set_ttl[] = {
1624 static const enum index action_jump[] = {
1630 static const enum index action_set_mac_dst[] = {
1631 ACTION_SET_MAC_DST_MAC_DST,
1636 static const enum index action_inc_tcp_seq[] = {
1637 ACTION_INC_TCP_SEQ_VALUE,
1642 static const enum index action_dec_tcp_seq[] = {
1643 ACTION_DEC_TCP_SEQ_VALUE,
1648 static const enum index action_inc_tcp_ack[] = {
1649 ACTION_INC_TCP_ACK_VALUE,
1654 static const enum index action_dec_tcp_ack[] = {
1655 ACTION_DEC_TCP_ACK_VALUE,
1660 static const enum index action_raw_encap[] = {
1661 ACTION_RAW_ENCAP_INDEX,
1666 static const enum index action_raw_decap[] = {
1667 ACTION_RAW_DECAP_INDEX,
1672 static const enum index action_set_tag[] = {
1673 ACTION_SET_TAG_DATA,
1674 ACTION_SET_TAG_INDEX,
1675 ACTION_SET_TAG_MASK,
1680 static const enum index action_set_meta[] = {
1681 ACTION_SET_META_DATA,
1682 ACTION_SET_META_MASK,
1687 static const enum index action_set_ipv4_dscp[] = {
1688 ACTION_SET_IPV4_DSCP_VALUE,
1693 static const enum index action_set_ipv6_dscp[] = {
1694 ACTION_SET_IPV6_DSCP_VALUE,
1699 static const enum index action_age[] = {
1706 static const enum index action_sample[] = {
1708 ACTION_SAMPLE_RATIO,
1709 ACTION_SAMPLE_INDEX,
1714 static const enum index next_action_sample[] = {
1727 static const enum index action_modify_field_dst[] = {
1728 ACTION_MODIFY_FIELD_DST_LEVEL,
1729 ACTION_MODIFY_FIELD_DST_OFFSET,
1730 ACTION_MODIFY_FIELD_SRC_TYPE,
1734 static const enum index action_modify_field_src[] = {
1735 ACTION_MODIFY_FIELD_SRC_LEVEL,
1736 ACTION_MODIFY_FIELD_SRC_OFFSET,
1737 ACTION_MODIFY_FIELD_SRC_VALUE,
1738 ACTION_MODIFY_FIELD_SRC_POINTER,
1739 ACTION_MODIFY_FIELD_WIDTH,
1743 static const enum index action_update_conntrack[] = {
1744 ACTION_CONNTRACK_UPDATE_DIR,
1745 ACTION_CONNTRACK_UPDATE_CTX,
1750 static const enum index action_port_representor[] = {
1751 ACTION_PORT_REPRESENTOR_PORT_ID,
1756 static const enum index action_represented_port[] = {
1757 ACTION_REPRESENTED_PORT_ETHDEV_PORT_ID,
1762 static int parse_set_raw_encap_decap(struct context *, const struct token *,
1763 const char *, unsigned int,
1764 void *, unsigned int);
1765 static int parse_set_sample_action(struct context *, const struct token *,
1766 const char *, unsigned int,
1767 void *, unsigned int);
1768 static int parse_set_init(struct context *, const struct token *,
1769 const char *, unsigned int,
1770 void *, unsigned int);
1771 static int parse_init(struct context *, const struct token *,
1772 const char *, unsigned int,
1773 void *, unsigned int);
1774 static int parse_vc(struct context *, const struct token *,
1775 const char *, unsigned int,
1776 void *, unsigned int);
1777 static int parse_vc_spec(struct context *, const struct token *,
1778 const char *, unsigned int, void *, unsigned int);
1779 static int parse_vc_conf(struct context *, const struct token *,
1780 const char *, unsigned int, void *, unsigned int);
1781 static int parse_vc_item_ecpri_type(struct context *, const struct token *,
1782 const char *, unsigned int,
1783 void *, unsigned int);
1784 static int parse_vc_action_meter_color_type(struct context *,
1785 const struct token *,
1786 const char *, unsigned int, void *,
1788 static int parse_vc_action_rss(struct context *, const struct token *,
1789 const char *, unsigned int, void *,
1791 static int parse_vc_action_rss_func(struct context *, const struct token *,
1792 const char *, unsigned int, void *,
1794 static int parse_vc_action_rss_type(struct context *, const struct token *,
1795 const char *, unsigned int, void *,
1797 static int parse_vc_action_rss_queue(struct context *, const struct token *,
1798 const char *, unsigned int, void *,
1800 static int parse_vc_action_vxlan_encap(struct context *, const struct token *,
1801 const char *, unsigned int, void *,
1803 static int parse_vc_action_nvgre_encap(struct context *, const struct token *,
1804 const char *, unsigned int, void *,
1806 static int parse_vc_action_l2_encap(struct context *, const struct token *,
1807 const char *, unsigned int, void *,
1809 static int parse_vc_action_l2_decap(struct context *, const struct token *,
1810 const char *, unsigned int, void *,
1812 static int parse_vc_action_mplsogre_encap(struct context *,
1813 const struct token *, const char *,
1814 unsigned int, void *, unsigned int);
1815 static int parse_vc_action_mplsogre_decap(struct context *,
1816 const struct token *, const char *,
1817 unsigned int, void *, unsigned int);
1818 static int parse_vc_action_mplsoudp_encap(struct context *,
1819 const struct token *, const char *,
1820 unsigned int, void *, unsigned int);
1821 static int parse_vc_action_mplsoudp_decap(struct context *,
1822 const struct token *, const char *,
1823 unsigned int, void *, unsigned int);
1824 static int parse_vc_action_raw_encap(struct context *,
1825 const struct token *, const char *,
1826 unsigned int, void *, unsigned int);
1827 static int parse_vc_action_raw_decap(struct context *,
1828 const struct token *, const char *,
1829 unsigned int, void *, unsigned int);
1830 static int parse_vc_action_raw_encap_index(struct context *,
1831 const struct token *, const char *,
1832 unsigned int, void *, unsigned int);
1833 static int parse_vc_action_raw_decap_index(struct context *,
1834 const struct token *, const char *,
1835 unsigned int, void *, unsigned int);
1836 static int parse_vc_action_set_meta(struct context *ctx,
1837 const struct token *token, const char *str,
1838 unsigned int len, void *buf,
1840 static int parse_vc_action_sample(struct context *ctx,
1841 const struct token *token, const char *str,
1842 unsigned int len, void *buf,
1845 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
1846 const char *str, unsigned int len, void *buf,
1849 parse_vc_modify_field_op(struct context *ctx, const struct token *token,
1850 const char *str, unsigned int len, void *buf,
1853 parse_vc_modify_field_id(struct context *ctx, const struct token *token,
1854 const char *str, unsigned int len, void *buf,
1857 parse_vc_action_conntrack_update(struct context *ctx, const struct token *token,
1858 const char *str, unsigned int len, void *buf,
1860 static int parse_destroy(struct context *, const struct token *,
1861 const char *, unsigned int,
1862 void *, unsigned int);
1863 static int parse_flush(struct context *, const struct token *,
1864 const char *, unsigned int,
1865 void *, unsigned int);
1866 static int parse_dump(struct context *, const struct token *,
1867 const char *, unsigned int,
1868 void *, unsigned int);
1869 static int parse_query(struct context *, const struct token *,
1870 const char *, unsigned int,
1871 void *, unsigned int);
1872 static int parse_action(struct context *, const struct token *,
1873 const char *, unsigned int,
1874 void *, unsigned int);
1875 static int parse_list(struct context *, const struct token *,
1876 const char *, unsigned int,
1877 void *, unsigned int);
1878 static int parse_aged(struct context *, const struct token *,
1879 const char *, unsigned int,
1880 void *, unsigned int);
1881 static int parse_isolate(struct context *, const struct token *,
1882 const char *, unsigned int,
1883 void *, unsigned int);
1884 static int parse_tunnel(struct context *, const struct token *,
1885 const char *, unsigned int,
1886 void *, unsigned int);
1887 static int parse_int(struct context *, const struct token *,
1888 const char *, unsigned int,
1889 void *, unsigned int);
1890 static int parse_prefix(struct context *, const struct token *,
1891 const char *, unsigned int,
1892 void *, unsigned int);
1893 static int parse_boolean(struct context *, const struct token *,
1894 const char *, unsigned int,
1895 void *, unsigned int);
1896 static int parse_string(struct context *, const struct token *,
1897 const char *, unsigned int,
1898 void *, unsigned int);
1899 static int parse_hex(struct context *ctx, const struct token *token,
1900 const char *str, unsigned int len,
1901 void *buf, unsigned int size);
1902 static int parse_string0(struct context *, const struct token *,
1903 const char *, unsigned int,
1904 void *, unsigned int);
1905 static int parse_mac_addr(struct context *, const struct token *,
1906 const char *, unsigned int,
1907 void *, unsigned int);
1908 static int parse_ipv4_addr(struct context *, const struct token *,
1909 const char *, unsigned int,
1910 void *, unsigned int);
1911 static int parse_ipv6_addr(struct context *, const struct token *,
1912 const char *, unsigned int,
1913 void *, unsigned int);
1914 static int parse_port(struct context *, const struct token *,
1915 const char *, unsigned int,
1916 void *, unsigned int);
1917 static int parse_ia(struct context *, const struct token *,
1918 const char *, unsigned int,
1919 void *, unsigned int);
1920 static int parse_ia_destroy(struct context *ctx, const struct token *token,
1921 const char *str, unsigned int len,
1922 void *buf, unsigned int size);
1923 static int parse_ia_id2ptr(struct context *ctx, const struct token *token,
1924 const char *str, unsigned int len, void *buf,
1926 static int parse_mp(struct context *, const struct token *,
1927 const char *, unsigned int,
1928 void *, unsigned int);
1929 static int comp_none(struct context *, const struct token *,
1930 unsigned int, char *, unsigned int);
1931 static int comp_boolean(struct context *, const struct token *,
1932 unsigned int, char *, unsigned int);
1933 static int comp_action(struct context *, const struct token *,
1934 unsigned int, char *, unsigned int);
1935 static int comp_port(struct context *, const struct token *,
1936 unsigned int, char *, unsigned int);
1937 static int comp_rule_id(struct context *, const struct token *,
1938 unsigned int, char *, unsigned int);
1939 static int comp_vc_action_rss_type(struct context *, const struct token *,
1940 unsigned int, char *, unsigned int);
1941 static int comp_vc_action_rss_queue(struct context *, const struct token *,
1942 unsigned int, char *, unsigned int);
1943 static int comp_set_raw_index(struct context *, const struct token *,
1944 unsigned int, char *, unsigned int);
1945 static int comp_set_sample_index(struct context *, const struct token *,
1946 unsigned int, char *, unsigned int);
1947 static int comp_set_modify_field_op(struct context *, const struct token *,
1948 unsigned int, char *, unsigned int);
1949 static int comp_set_modify_field_id(struct context *, const struct token *,
1950 unsigned int, char *, unsigned int);
1952 /** Token definitions. */
1953 static const struct token token_list[] = {
1954 /* Special tokens. */
1957 .help = "null entry, abused as the entry point",
1958 .next = NEXT(NEXT_ENTRY(FLOW, ADD)),
1963 .help = "command may end here",
1966 .name = "START_SET",
1967 .help = "null entry, abused as the entry point for set",
1968 .next = NEXT(NEXT_ENTRY(SET)),
1973 .help = "set command may end here",
1975 /* Common tokens. */
1976 [COMMON_INTEGER] = {
1979 .help = "integer value",
1983 [COMMON_UNSIGNED] = {
1984 .name = "{unsigned}",
1986 .help = "unsigned integer value",
1993 .help = "prefix length for bit-mask",
1994 .call = parse_prefix,
1997 [COMMON_BOOLEAN] = {
1998 .name = "{boolean}",
2000 .help = "any boolean value",
2001 .call = parse_boolean,
2002 .comp = comp_boolean,
2007 .help = "fixed string",
2008 .call = parse_string,
2014 .help = "fixed string",
2017 [COMMON_FILE_PATH] = {
2018 .name = "{file path}",
2020 .help = "file path",
2021 .call = parse_string0,
2024 [COMMON_MAC_ADDR] = {
2025 .name = "{MAC address}",
2027 .help = "standard MAC address notation",
2028 .call = parse_mac_addr,
2031 [COMMON_IPV4_ADDR] = {
2032 .name = "{IPv4 address}",
2033 .type = "IPV4 ADDRESS",
2034 .help = "standard IPv4 address notation",
2035 .call = parse_ipv4_addr,
2038 [COMMON_IPV6_ADDR] = {
2039 .name = "{IPv6 address}",
2040 .type = "IPV6 ADDRESS",
2041 .help = "standard IPv6 address notation",
2042 .call = parse_ipv6_addr,
2045 [COMMON_RULE_ID] = {
2046 .name = "{rule id}",
2048 .help = "rule identifier",
2050 .comp = comp_rule_id,
2052 [COMMON_PORT_ID] = {
2053 .name = "{port_id}",
2055 .help = "port identifier",
2059 [COMMON_GROUP_ID] = {
2060 .name = "{group_id}",
2062 .help = "group identifier",
2066 [COMMON_PRIORITY_LEVEL] = {
2069 .help = "priority level",
2073 [COMMON_INDIRECT_ACTION_ID] = {
2074 .name = "{indirect_action_id}",
2075 .type = "INDIRECT_ACTION_ID",
2076 .help = "indirect action id",
2080 [COMMON_POLICY_ID] = {
2081 .name = "{policy_id}",
2082 .type = "POLCIY_ID",
2083 .help = "policy id",
2087 /* Top-level command. */
2090 .type = "{command} {port_id} [{arg} [...]]",
2091 .help = "manage ingress/egress flow rules",
2092 .next = NEXT(NEXT_ENTRY
2106 /* Top-level command. */
2107 [INDIRECT_ACTION] = {
2108 .name = "indirect_action",
2109 .type = "{command} {port_id} [{arg} [...]]",
2110 .help = "manage indirect actions",
2111 .next = NEXT(next_ia_subcmd, NEXT_ENTRY(COMMON_PORT_ID)),
2112 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2115 /* Sub-level commands. */
2116 [INDIRECT_ACTION_CREATE] = {
2118 .help = "create indirect action",
2119 .next = NEXT(next_ia_create_attr),
2122 [INDIRECT_ACTION_UPDATE] = {
2124 .help = "update indirect action",
2125 .next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_SPEC),
2126 NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
2127 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
2130 [INDIRECT_ACTION_DESTROY] = {
2132 .help = "destroy indirect action",
2133 .next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_DESTROY_ID)),
2134 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2135 .call = parse_ia_destroy,
2137 [INDIRECT_ACTION_QUERY] = {
2139 .help = "query indirect action",
2140 .next = NEXT(NEXT_ENTRY(END),
2141 NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
2142 .args = ARGS(ARGS_ENTRY(struct buffer, args.ia.action_id)),
2147 .help = "check whether a flow rule can be created",
2148 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_PORT_ID)),
2149 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2154 .help = "create a flow rule",
2155 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_PORT_ID)),
2156 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2161 .help = "destroy specific flow rules",
2162 .next = NEXT(NEXT_ENTRY(DESTROY_RULE),
2163 NEXT_ENTRY(COMMON_PORT_ID)),
2164 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2165 .call = parse_destroy,
2169 .help = "destroy all flow rules",
2170 .next = NEXT(NEXT_ENTRY(COMMON_PORT_ID)),
2171 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2172 .call = parse_flush,
2176 .help = "dump single/all flow rules to file",
2177 .next = NEXT(next_dump_subcmd, NEXT_ENTRY(COMMON_PORT_ID)),
2178 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2183 .help = "query an existing flow rule",
2184 .next = NEXT(NEXT_ENTRY(QUERY_ACTION),
2185 NEXT_ENTRY(COMMON_RULE_ID),
2186 NEXT_ENTRY(COMMON_PORT_ID)),
2187 .args = ARGS(ARGS_ENTRY(struct buffer, args.query.action.type),
2188 ARGS_ENTRY(struct buffer, args.query.rule),
2189 ARGS_ENTRY(struct buffer, port)),
2190 .call = parse_query,
2194 .help = "list existing flow rules",
2195 .next = NEXT(next_list_attr, NEXT_ENTRY(COMMON_PORT_ID)),
2196 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2201 .help = "list and destroy aged flows",
2202 .next = NEXT(next_aged_attr, NEXT_ENTRY(COMMON_PORT_ID)),
2203 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2208 .help = "restrict ingress traffic to the defined flow rules",
2209 .next = NEXT(NEXT_ENTRY(COMMON_BOOLEAN),
2210 NEXT_ENTRY(COMMON_PORT_ID)),
2211 .args = ARGS(ARGS_ENTRY(struct buffer, args.isolate.set),
2212 ARGS_ENTRY(struct buffer, port)),
2213 .call = parse_isolate,
2217 .help = "new tunnel API",
2218 .next = NEXT(NEXT_ENTRY
2219 (TUNNEL_CREATE, TUNNEL_LIST, TUNNEL_DESTROY)),
2220 .call = parse_tunnel,
2222 /* Tunnel arguments. */
2225 .help = "create new tunnel object",
2226 .next = NEXT(NEXT_ENTRY(TUNNEL_CREATE_TYPE),
2227 NEXT_ENTRY(COMMON_PORT_ID)),
2228 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2229 .call = parse_tunnel,
2231 [TUNNEL_CREATE_TYPE] = {
2233 .help = "create new tunnel",
2234 .next = NEXT(NEXT_ENTRY(COMMON_FILE_PATH)),
2235 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, type)),
2236 .call = parse_tunnel,
2238 [TUNNEL_DESTROY] = {
2240 .help = "destroy tunel",
2241 .next = NEXT(NEXT_ENTRY(TUNNEL_DESTROY_ID),
2242 NEXT_ENTRY(COMMON_PORT_ID)),
2243 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2244 .call = parse_tunnel,
2246 [TUNNEL_DESTROY_ID] = {
2248 .help = "tunnel identifier to testroy",
2249 .next = NEXT(NEXT_ENTRY(COMMON_UNSIGNED)),
2250 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2251 .call = parse_tunnel,
2255 .help = "list existing tunnels",
2256 .next = NEXT(NEXT_ENTRY(COMMON_PORT_ID)),
2257 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2258 .call = parse_tunnel,
2260 /* Destroy arguments. */
2263 .help = "specify a rule identifier",
2264 .next = NEXT(next_destroy_attr, NEXT_ENTRY(COMMON_RULE_ID)),
2265 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.destroy.rule)),
2266 .call = parse_destroy,
2268 /* Dump arguments. */
2272 .next = NEXT(next_dump_attr),
2273 .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file)),
2278 .help = "dump one rule",
2279 .next = NEXT(next_dump_attr, NEXT_ENTRY(COMMON_RULE_ID)),
2280 .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file),
2281 ARGS_ENTRY(struct buffer, args.dump.rule)),
2284 /* Query arguments. */
2288 .help = "action to query, must be part of the rule",
2289 .call = parse_action,
2290 .comp = comp_action,
2292 /* List arguments. */
2295 .help = "specify a group",
2296 .next = NEXT(next_list_attr, NEXT_ENTRY(COMMON_GROUP_ID)),
2297 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.list.group)),
2302 .help = "specify aged flows need be destroyed",
2306 /* Validate/create attributes. */
2309 .help = "specify a group",
2310 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_GROUP_ID)),
2311 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, group)),
2316 .help = "specify a priority level",
2317 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_PRIORITY_LEVEL)),
2318 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, priority)),
2323 .help = "affect rule to ingress",
2324 .next = NEXT(next_vc_attr),
2329 .help = "affect rule to egress",
2330 .next = NEXT(next_vc_attr),
2335 .help = "apply rule directly to endpoints found in pattern",
2336 .next = NEXT(next_vc_attr),
2340 .name = "tunnel_set",
2341 .help = "tunnel steer rule",
2342 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_UNSIGNED)),
2343 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2346 [VC_TUNNEL_MATCH] = {
2347 .name = "tunnel_match",
2348 .help = "tunnel match rule",
2349 .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_UNSIGNED)),
2350 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2353 /* Validate/create pattern. */
2356 .help = "submit a list of pattern items",
2357 .next = NEXT(next_item),
2362 .help = "match value perfectly (with full bit-mask)",
2363 .call = parse_vc_spec,
2365 [ITEM_PARAM_SPEC] = {
2367 .help = "match value according to configured bit-mask",
2368 .call = parse_vc_spec,
2370 [ITEM_PARAM_LAST] = {
2372 .help = "specify upper bound to establish a range",
2373 .call = parse_vc_spec,
2375 [ITEM_PARAM_MASK] = {
2377 .help = "specify bit-mask with relevant bits set to one",
2378 .call = parse_vc_spec,
2380 [ITEM_PARAM_PREFIX] = {
2382 .help = "generate bit-mask from a prefix length",
2383 .call = parse_vc_spec,
2387 .help = "specify next pattern item",
2388 .next = NEXT(next_item),
2392 .help = "end list of pattern items",
2393 .priv = PRIV_ITEM(END, 0),
2394 .next = NEXT(NEXT_ENTRY(ACTIONS)),
2399 .help = "no-op pattern item",
2400 .priv = PRIV_ITEM(VOID, 0),
2401 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2406 .help = "perform actions when pattern does not match",
2407 .priv = PRIV_ITEM(INVERT, 0),
2408 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2413 .help = "match any protocol for the current layer",
2414 .priv = PRIV_ITEM(ANY, sizeof(struct rte_flow_item_any)),
2415 .next = NEXT(item_any),
2420 .help = "number of layers covered",
2421 .next = NEXT(item_any, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2422 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_any, num)),
2426 .help = "match traffic from/to the physical function",
2427 .priv = PRIV_ITEM(PF, 0),
2428 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2433 .help = "match traffic from/to a virtual function ID",
2434 .priv = PRIV_ITEM(VF, sizeof(struct rte_flow_item_vf)),
2435 .next = NEXT(item_vf),
2441 .next = NEXT(item_vf, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2442 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_vf, id)),
2446 .help = "match traffic from/to a specific physical port",
2447 .priv = PRIV_ITEM(PHY_PORT,
2448 sizeof(struct rte_flow_item_phy_port)),
2449 .next = NEXT(item_phy_port),
2452 [ITEM_PHY_PORT_INDEX] = {
2454 .help = "physical port index",
2455 .next = NEXT(item_phy_port, NEXT_ENTRY(COMMON_UNSIGNED),
2457 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_phy_port, index)),
2461 .help = "match traffic from/to a given DPDK port ID",
2462 .priv = PRIV_ITEM(PORT_ID,
2463 sizeof(struct rte_flow_item_port_id)),
2464 .next = NEXT(item_port_id),
2467 [ITEM_PORT_ID_ID] = {
2469 .help = "DPDK port ID",
2470 .next = NEXT(item_port_id, NEXT_ENTRY(COMMON_UNSIGNED),
2472 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port_id, id)),
2476 .help = "match traffic against value set in previously matched rule",
2477 .priv = PRIV_ITEM(MARK, sizeof(struct rte_flow_item_mark)),
2478 .next = NEXT(item_mark),
2483 .help = "Integer value to match against",
2484 .next = NEXT(item_mark, NEXT_ENTRY(COMMON_UNSIGNED),
2486 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_mark, id)),
2490 .help = "match an arbitrary byte string",
2491 .priv = PRIV_ITEM(RAW, ITEM_RAW_SIZE),
2492 .next = NEXT(item_raw),
2495 [ITEM_RAW_RELATIVE] = {
2497 .help = "look for pattern after the previous item",
2498 .next = NEXT(item_raw, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
2499 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
2502 [ITEM_RAW_SEARCH] = {
2504 .help = "search pattern from offset (see also limit)",
2505 .next = NEXT(item_raw, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
2506 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
2509 [ITEM_RAW_OFFSET] = {
2511 .help = "absolute or relative offset for pattern",
2512 .next = NEXT(item_raw, NEXT_ENTRY(COMMON_INTEGER), item_param),
2513 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, offset)),
2515 [ITEM_RAW_LIMIT] = {
2517 .help = "search area limit for start of pattern",
2518 .next = NEXT(item_raw, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2519 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, limit)),
2521 [ITEM_RAW_PATTERN] = {
2523 .help = "byte string to look for",
2524 .next = NEXT(item_raw,
2525 NEXT_ENTRY(COMMON_STRING),
2526 NEXT_ENTRY(ITEM_PARAM_IS,
2529 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern),
2530 ARGS_ENTRY(struct rte_flow_item_raw, length),
2531 ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw),
2532 ITEM_RAW_PATTERN_SIZE)),
2536 .help = "match Ethernet header",
2537 .priv = PRIV_ITEM(ETH, sizeof(struct rte_flow_item_eth)),
2538 .next = NEXT(item_eth),
2543 .help = "destination MAC",
2544 .next = NEXT(item_eth, NEXT_ENTRY(COMMON_MAC_ADDR), item_param),
2545 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, dst)),
2549 .help = "source MAC",
2550 .next = NEXT(item_eth, NEXT_ENTRY(COMMON_MAC_ADDR), item_param),
2551 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, src)),
2555 .help = "EtherType",
2556 .next = NEXT(item_eth, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2557 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, type)),
2559 [ITEM_ETH_HAS_VLAN] = {
2561 .help = "packet header contains VLAN",
2562 .next = NEXT(item_eth, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2563 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_eth,
2568 .help = "match 802.1Q/ad VLAN tag",
2569 .priv = PRIV_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)),
2570 .next = NEXT(item_vlan),
2575 .help = "tag control information",
2576 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
2578 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, tci)),
2582 .help = "priority code point",
2583 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
2585 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2590 .help = "drop eligible indicator",
2591 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
2593 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2598 .help = "VLAN identifier",
2599 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
2601 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2604 [ITEM_VLAN_INNER_TYPE] = {
2605 .name = "inner_type",
2606 .help = "inner EtherType",
2607 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
2609 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan,
2612 [ITEM_VLAN_HAS_MORE_VLAN] = {
2613 .name = "has_more_vlan",
2614 .help = "packet header contains another VLAN",
2615 .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
2617 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vlan,
2622 .help = "match IPv4 header",
2623 .priv = PRIV_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)),
2624 .next = NEXT(item_ipv4),
2627 [ITEM_IPV4_VER_IHL] = {
2628 .name = "version_ihl",
2629 .help = "match header length",
2630 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
2632 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ipv4,
2637 .help = "type of service",
2638 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
2640 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2641 hdr.type_of_service)),
2644 .name = "packet_id",
2645 .help = "fragment packet id",
2646 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
2648 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2651 [ITEM_IPV4_FRAGMENT_OFFSET] = {
2652 .name = "fragment_offset",
2653 .help = "fragmentation flags and fragment offset",
2654 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
2656 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2657 hdr.fragment_offset)),
2661 .help = "time to live",
2662 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
2664 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2667 [ITEM_IPV4_PROTO] = {
2669 .help = "next protocol ID",
2670 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
2672 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2673 hdr.next_proto_id)),
2677 .help = "source address",
2678 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
2680 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2685 .help = "destination address",
2686 .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
2688 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2693 .help = "match IPv6 header",
2694 .priv = PRIV_ITEM(IPV6, sizeof(struct rte_flow_item_ipv6)),
2695 .next = NEXT(item_ipv6),
2700 .help = "traffic class",
2701 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
2703 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2705 "\x0f\xf0\x00\x00")),
2707 [ITEM_IPV6_FLOW] = {
2709 .help = "flow label",
2710 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
2712 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2714 "\x00\x0f\xff\xff")),
2716 [ITEM_IPV6_PROTO] = {
2718 .help = "protocol (next header)",
2719 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
2721 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2726 .help = "hop limit",
2727 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
2729 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2734 .help = "source address",
2735 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_IPV6_ADDR),
2737 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2742 .help = "destination address",
2743 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_IPV6_ADDR),
2745 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2748 [ITEM_IPV6_HAS_FRAG_EXT] = {
2749 .name = "has_frag_ext",
2750 .help = "fragment packet attribute",
2751 .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
2753 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_ipv6,
2758 .help = "match ICMP header",
2759 .priv = PRIV_ITEM(ICMP, sizeof(struct rte_flow_item_icmp)),
2760 .next = NEXT(item_icmp),
2763 [ITEM_ICMP_TYPE] = {
2765 .help = "ICMP packet type",
2766 .next = NEXT(item_icmp, NEXT_ENTRY(COMMON_UNSIGNED),
2768 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2771 [ITEM_ICMP_CODE] = {
2773 .help = "ICMP packet code",
2774 .next = NEXT(item_icmp, NEXT_ENTRY(COMMON_UNSIGNED),
2776 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2779 [ITEM_ICMP_IDENT] = {
2781 .help = "ICMP packet identifier",
2782 .next = NEXT(item_icmp, NEXT_ENTRY(COMMON_UNSIGNED),
2784 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2789 .help = "ICMP packet sequence number",
2790 .next = NEXT(item_icmp, NEXT_ENTRY(COMMON_UNSIGNED),
2792 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2797 .help = "match UDP header",
2798 .priv = PRIV_ITEM(UDP, sizeof(struct rte_flow_item_udp)),
2799 .next = NEXT(item_udp),
2804 .help = "UDP source port",
2805 .next = NEXT(item_udp, NEXT_ENTRY(COMMON_UNSIGNED),
2807 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2812 .help = "UDP destination port",
2813 .next = NEXT(item_udp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2814 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2819 .help = "match TCP header",
2820 .priv = PRIV_ITEM(TCP, sizeof(struct rte_flow_item_tcp)),
2821 .next = NEXT(item_tcp),
2826 .help = "TCP source port",
2827 .next = NEXT(item_tcp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2828 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2833 .help = "TCP destination port",
2834 .next = NEXT(item_tcp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2835 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2838 [ITEM_TCP_FLAGS] = {
2840 .help = "TCP flags",
2841 .next = NEXT(item_tcp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
2842 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2847 .help = "match SCTP header",
2848 .priv = PRIV_ITEM(SCTP, sizeof(struct rte_flow_item_sctp)),
2849 .next = NEXT(item_sctp),
2854 .help = "SCTP source port",
2855 .next = NEXT(item_sctp, NEXT_ENTRY(COMMON_UNSIGNED),
2857 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2862 .help = "SCTP destination port",
2863 .next = NEXT(item_sctp, NEXT_ENTRY(COMMON_UNSIGNED),
2865 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2870 .help = "validation tag",
2871 .next = NEXT(item_sctp, NEXT_ENTRY(COMMON_UNSIGNED),
2873 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2876 [ITEM_SCTP_CKSUM] = {
2879 .next = NEXT(item_sctp, NEXT_ENTRY(COMMON_UNSIGNED),
2881 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2886 .help = "match VXLAN header",
2887 .priv = PRIV_ITEM(VXLAN, sizeof(struct rte_flow_item_vxlan)),
2888 .next = NEXT(item_vxlan),
2891 [ITEM_VXLAN_VNI] = {
2893 .help = "VXLAN identifier",
2894 .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
2896 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan, vni)),
2898 [ITEM_VXLAN_LAST_RSVD] = {
2899 .name = "last_rsvd",
2900 .help = "VXLAN last reserved bits",
2901 .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
2903 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan,
2908 .help = "match E-Tag header",
2909 .priv = PRIV_ITEM(E_TAG, sizeof(struct rte_flow_item_e_tag)),
2910 .next = NEXT(item_e_tag),
2913 [ITEM_E_TAG_GRP_ECID_B] = {
2914 .name = "grp_ecid_b",
2915 .help = "GRP and E-CID base",
2916 .next = NEXT(item_e_tag, NEXT_ENTRY(COMMON_UNSIGNED),
2918 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_e_tag,
2924 .help = "match NVGRE header",
2925 .priv = PRIV_ITEM(NVGRE, sizeof(struct rte_flow_item_nvgre)),
2926 .next = NEXT(item_nvgre),
2929 [ITEM_NVGRE_TNI] = {
2931 .help = "virtual subnet ID",
2932 .next = NEXT(item_nvgre, NEXT_ENTRY(COMMON_UNSIGNED),
2934 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_nvgre, tni)),
2938 .help = "match MPLS header",
2939 .priv = PRIV_ITEM(MPLS, sizeof(struct rte_flow_item_mpls)),
2940 .next = NEXT(item_mpls),
2943 [ITEM_MPLS_LABEL] = {
2945 .help = "MPLS label",
2946 .next = NEXT(item_mpls, NEXT_ENTRY(COMMON_UNSIGNED),
2948 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2954 .help = "MPLS Traffic Class",
2955 .next = NEXT(item_mpls, NEXT_ENTRY(COMMON_UNSIGNED),
2957 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2963 .help = "MPLS Bottom-of-Stack",
2964 .next = NEXT(item_mpls, NEXT_ENTRY(COMMON_UNSIGNED),
2966 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2972 .help = "match GRE header",
2973 .priv = PRIV_ITEM(GRE, sizeof(struct rte_flow_item_gre)),
2974 .next = NEXT(item_gre),
2977 [ITEM_GRE_PROTO] = {
2979 .help = "GRE protocol type",
2980 .next = NEXT(item_gre, NEXT_ENTRY(COMMON_UNSIGNED),
2982 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2985 [ITEM_GRE_C_RSVD0_VER] = {
2986 .name = "c_rsvd0_ver",
2988 "checksum (1b), undefined (1b), key bit (1b),"
2989 " sequence number (1b), reserved 0 (9b),"
2991 .next = NEXT(item_gre, NEXT_ENTRY(COMMON_UNSIGNED),
2993 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2996 [ITEM_GRE_C_BIT] = {
2998 .help = "checksum bit (C)",
2999 .next = NEXT(item_gre, NEXT_ENTRY(COMMON_BOOLEAN),
3001 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
3003 "\x80\x00\x00\x00")),
3005 [ITEM_GRE_S_BIT] = {
3007 .help = "sequence number bit (S)",
3008 .next = NEXT(item_gre, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
3009 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
3011 "\x10\x00\x00\x00")),
3013 [ITEM_GRE_K_BIT] = {
3015 .help = "key bit (K)",
3016 .next = NEXT(item_gre, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
3017 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
3019 "\x20\x00\x00\x00")),
3023 .help = "fuzzy pattern match, expect faster than default",
3024 .priv = PRIV_ITEM(FUZZY,
3025 sizeof(struct rte_flow_item_fuzzy)),
3026 .next = NEXT(item_fuzzy),
3029 [ITEM_FUZZY_THRESH] = {
3031 .help = "match accuracy threshold",
3032 .next = NEXT(item_fuzzy, NEXT_ENTRY(COMMON_UNSIGNED),
3034 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_fuzzy,
3039 .help = "match GTP header",
3040 .priv = PRIV_ITEM(GTP, sizeof(struct rte_flow_item_gtp)),
3041 .next = NEXT(item_gtp),
3044 [ITEM_GTP_FLAGS] = {
3045 .name = "v_pt_rsv_flags",
3046 .help = "GTP flags",
3047 .next = NEXT(item_gtp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3048 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp,
3051 [ITEM_GTP_MSG_TYPE] = {
3053 .help = "GTP message type",
3054 .next = NEXT(item_gtp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3055 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp, msg_type)),
3059 .help = "tunnel endpoint identifier",
3060 .next = NEXT(item_gtp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3061 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp, teid)),
3065 .help = "match GTP header",
3066 .priv = PRIV_ITEM(GTPC, sizeof(struct rte_flow_item_gtp)),
3067 .next = NEXT(item_gtp),
3072 .help = "match GTP header",
3073 .priv = PRIV_ITEM(GTPU, sizeof(struct rte_flow_item_gtp)),
3074 .next = NEXT(item_gtp),
3079 .help = "match GENEVE header",
3080 .priv = PRIV_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)),
3081 .next = NEXT(item_geneve),
3084 [ITEM_GENEVE_VNI] = {
3086 .help = "virtual network identifier",
3087 .next = NEXT(item_geneve, NEXT_ENTRY(COMMON_UNSIGNED),
3089 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve, vni)),
3091 [ITEM_GENEVE_PROTO] = {
3093 .help = "GENEVE protocol type",
3094 .next = NEXT(item_geneve, NEXT_ENTRY(COMMON_UNSIGNED),
3096 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve,
3099 [ITEM_GENEVE_OPTLEN] = {
3101 .help = "GENEVE options length in dwords",
3102 .next = NEXT(item_geneve, NEXT_ENTRY(COMMON_UNSIGNED),
3104 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_geneve,
3105 ver_opt_len_o_c_rsvd0,
3108 [ITEM_VXLAN_GPE] = {
3109 .name = "vxlan-gpe",
3110 .help = "match VXLAN-GPE header",
3111 .priv = PRIV_ITEM(VXLAN_GPE,
3112 sizeof(struct rte_flow_item_vxlan_gpe)),
3113 .next = NEXT(item_vxlan_gpe),
3116 [ITEM_VXLAN_GPE_VNI] = {
3118 .help = "VXLAN-GPE identifier",
3119 .next = NEXT(item_vxlan_gpe, NEXT_ENTRY(COMMON_UNSIGNED),
3121 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
3124 [ITEM_ARP_ETH_IPV4] = {
3125 .name = "arp_eth_ipv4",
3126 .help = "match ARP header for Ethernet/IPv4",
3127 .priv = PRIV_ITEM(ARP_ETH_IPV4,
3128 sizeof(struct rte_flow_item_arp_eth_ipv4)),
3129 .next = NEXT(item_arp_eth_ipv4),
3132 [ITEM_ARP_ETH_IPV4_SHA] = {
3134 .help = "sender hardware address",
3135 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_MAC_ADDR),
3137 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
3140 [ITEM_ARP_ETH_IPV4_SPA] = {
3142 .help = "sender IPv4 address",
3143 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
3145 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
3148 [ITEM_ARP_ETH_IPV4_THA] = {
3150 .help = "target hardware address",
3151 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_MAC_ADDR),
3153 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
3156 [ITEM_ARP_ETH_IPV4_TPA] = {
3158 .help = "target IPv4 address",
3159 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
3161 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
3166 .help = "match presence of any IPv6 extension header",
3167 .priv = PRIV_ITEM(IPV6_EXT,
3168 sizeof(struct rte_flow_item_ipv6_ext)),
3169 .next = NEXT(item_ipv6_ext),
3172 [ITEM_IPV6_EXT_NEXT_HDR] = {
3174 .help = "next header",
3175 .next = NEXT(item_ipv6_ext, NEXT_ENTRY(COMMON_UNSIGNED),
3177 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_ext,
3180 [ITEM_IPV6_FRAG_EXT] = {
3181 .name = "ipv6_frag_ext",
3182 .help = "match presence of IPv6 fragment extension header",
3183 .priv = PRIV_ITEM(IPV6_FRAG_EXT,
3184 sizeof(struct rte_flow_item_ipv6_frag_ext)),
3185 .next = NEXT(item_ipv6_frag_ext),
3188 [ITEM_IPV6_FRAG_EXT_NEXT_HDR] = {
3190 .help = "next header",
3191 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(COMMON_UNSIGNED),
3193 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ipv6_frag_ext,
3196 [ITEM_IPV6_FRAG_EXT_FRAG_DATA] = {
3197 .name = "frag_data",
3198 .help = "fragment flags and offset",
3199 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(COMMON_UNSIGNED),
3201 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_frag_ext,
3204 [ITEM_IPV6_FRAG_EXT_ID] = {
3205 .name = "packet_id",
3206 .help = "fragment packet id",
3207 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(COMMON_UNSIGNED),
3209 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_frag_ext,
3214 .help = "match any ICMPv6 header",
3215 .priv = PRIV_ITEM(ICMP6, sizeof(struct rte_flow_item_icmp6)),
3216 .next = NEXT(item_icmp6),
3219 [ITEM_ICMP6_TYPE] = {
3221 .help = "ICMPv6 type",
3222 .next = NEXT(item_icmp6, NEXT_ENTRY(COMMON_UNSIGNED),
3224 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
3227 [ITEM_ICMP6_CODE] = {
3229 .help = "ICMPv6 code",
3230 .next = NEXT(item_icmp6, NEXT_ENTRY(COMMON_UNSIGNED),
3232 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
3235 [ITEM_ICMP6_ND_NS] = {
3236 .name = "icmp6_nd_ns",
3237 .help = "match ICMPv6 neighbor discovery solicitation",
3238 .priv = PRIV_ITEM(ICMP6_ND_NS,
3239 sizeof(struct rte_flow_item_icmp6_nd_ns)),
3240 .next = NEXT(item_icmp6_nd_ns),
3243 [ITEM_ICMP6_ND_NS_TARGET_ADDR] = {
3244 .name = "target_addr",
3245 .help = "target address",
3246 .next = NEXT(item_icmp6_nd_ns, NEXT_ENTRY(COMMON_IPV6_ADDR),
3248 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_ns,
3251 [ITEM_ICMP6_ND_NA] = {
3252 .name = "icmp6_nd_na",
3253 .help = "match ICMPv6 neighbor discovery advertisement",
3254 .priv = PRIV_ITEM(ICMP6_ND_NA,
3255 sizeof(struct rte_flow_item_icmp6_nd_na)),
3256 .next = NEXT(item_icmp6_nd_na),
3259 [ITEM_ICMP6_ND_NA_TARGET_ADDR] = {
3260 .name = "target_addr",
3261 .help = "target address",
3262 .next = NEXT(item_icmp6_nd_na, NEXT_ENTRY(COMMON_IPV6_ADDR),
3264 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_na,
3267 [ITEM_ICMP6_ND_OPT] = {
3268 .name = "icmp6_nd_opt",
3269 .help = "match presence of any ICMPv6 neighbor discovery"
3271 .priv = PRIV_ITEM(ICMP6_ND_OPT,
3272 sizeof(struct rte_flow_item_icmp6_nd_opt)),
3273 .next = NEXT(item_icmp6_nd_opt),
3276 [ITEM_ICMP6_ND_OPT_TYPE] = {
3278 .help = "ND option type",
3279 .next = NEXT(item_icmp6_nd_opt, NEXT_ENTRY(COMMON_UNSIGNED),
3281 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_opt,
3284 [ITEM_ICMP6_ND_OPT_SLA_ETH] = {
3285 .name = "icmp6_nd_opt_sla_eth",
3286 .help = "match ICMPv6 neighbor discovery source Ethernet"
3287 " link-layer address option",
3289 (ICMP6_ND_OPT_SLA_ETH,
3290 sizeof(struct rte_flow_item_icmp6_nd_opt_sla_eth)),
3291 .next = NEXT(item_icmp6_nd_opt_sla_eth),
3294 [ITEM_ICMP6_ND_OPT_SLA_ETH_SLA] = {
3296 .help = "source Ethernet LLA",
3297 .next = NEXT(item_icmp6_nd_opt_sla_eth,
3298 NEXT_ENTRY(COMMON_MAC_ADDR), item_param),
3299 .args = ARGS(ARGS_ENTRY_HTON
3300 (struct rte_flow_item_icmp6_nd_opt_sla_eth, sla)),
3302 [ITEM_ICMP6_ND_OPT_TLA_ETH] = {
3303 .name = "icmp6_nd_opt_tla_eth",
3304 .help = "match ICMPv6 neighbor discovery target Ethernet"
3305 " link-layer address option",
3307 (ICMP6_ND_OPT_TLA_ETH,
3308 sizeof(struct rte_flow_item_icmp6_nd_opt_tla_eth)),
3309 .next = NEXT(item_icmp6_nd_opt_tla_eth),
3312 [ITEM_ICMP6_ND_OPT_TLA_ETH_TLA] = {
3314 .help = "target Ethernet LLA",
3315 .next = NEXT(item_icmp6_nd_opt_tla_eth,
3316 NEXT_ENTRY(COMMON_MAC_ADDR), item_param),
3317 .args = ARGS(ARGS_ENTRY_HTON
3318 (struct rte_flow_item_icmp6_nd_opt_tla_eth, tla)),
3322 .help = "match metadata header",
3323 .priv = PRIV_ITEM(META, sizeof(struct rte_flow_item_meta)),
3324 .next = NEXT(item_meta),
3327 [ITEM_META_DATA] = {
3329 .help = "metadata value",
3330 .next = NEXT(item_meta, NEXT_ENTRY(COMMON_UNSIGNED),
3332 .args = ARGS(ARGS_ENTRY_MASK(struct rte_flow_item_meta,
3333 data, "\xff\xff\xff\xff")),
3337 .help = "match GRE key",
3338 .priv = PRIV_ITEM(GRE_KEY, sizeof(rte_be32_t)),
3339 .next = NEXT(item_gre_key),
3342 [ITEM_GRE_KEY_VALUE] = {
3344 .help = "key value",
3345 .next = NEXT(item_gre_key, NEXT_ENTRY(COMMON_UNSIGNED),
3347 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3351 .help = "match GTP extension header with type 0x85",
3352 .priv = PRIV_ITEM(GTP_PSC,
3353 sizeof(struct rte_flow_item_gtp_psc)),
3354 .next = NEXT(item_gtp_psc),
3357 [ITEM_GTP_PSC_QFI] = {
3359 .help = "QoS flow identifier",
3360 .next = NEXT(item_gtp_psc, NEXT_ENTRY(COMMON_UNSIGNED),
3362 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_gtp_psc,
3365 [ITEM_GTP_PSC_PDU_T] = {
3368 .next = NEXT(item_gtp_psc, NEXT_ENTRY(COMMON_UNSIGNED),
3370 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_gtp_psc,
3375 .help = "match PPPoE session header",
3376 .priv = PRIV_ITEM(PPPOES, sizeof(struct rte_flow_item_pppoe)),
3377 .next = NEXT(item_pppoes),
3382 .help = "match PPPoE discovery header",
3383 .priv = PRIV_ITEM(PPPOED, sizeof(struct rte_flow_item_pppoe)),
3384 .next = NEXT(item_pppoed),
3387 [ITEM_PPPOE_SEID] = {
3389 .help = "session identifier",
3390 .next = NEXT(item_pppoes, NEXT_ENTRY(COMMON_UNSIGNED),
3392 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pppoe,
3395 [ITEM_PPPOE_PROTO_ID] = {
3396 .name = "pppoe_proto_id",
3397 .help = "match PPPoE session protocol identifier",
3398 .priv = PRIV_ITEM(PPPOE_PROTO_ID,
3399 sizeof(struct rte_flow_item_pppoe_proto_id)),
3400 .next = NEXT(item_pppoe_proto_id, NEXT_ENTRY(COMMON_UNSIGNED),
3402 .args = ARGS(ARGS_ENTRY_HTON
3403 (struct rte_flow_item_pppoe_proto_id, proto_id)),
3408 .help = "matches higig2 header",
3409 .priv = PRIV_ITEM(HIGIG2,
3410 sizeof(struct rte_flow_item_higig2_hdr)),
3411 .next = NEXT(item_higig2),
3414 [ITEM_HIGIG2_CLASSIFICATION] = {
3415 .name = "classification",
3416 .help = "matches classification of higig2 header",
3417 .next = NEXT(item_higig2, NEXT_ENTRY(COMMON_UNSIGNED),
3419 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
3420 hdr.ppt1.classification)),
3422 [ITEM_HIGIG2_VID] = {
3424 .help = "matches vid of higig2 header",
3425 .next = NEXT(item_higig2, NEXT_ENTRY(COMMON_UNSIGNED),
3427 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
3432 .help = "match tag value",
3433 .priv = PRIV_ITEM(TAG, sizeof(struct rte_flow_item_tag)),
3434 .next = NEXT(item_tag),
3439 .help = "tag value to match",
3440 .next = NEXT(item_tag, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3441 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, data)),
3443 [ITEM_TAG_INDEX] = {
3445 .help = "index of tag array to match",
3446 .next = NEXT(item_tag, NEXT_ENTRY(COMMON_UNSIGNED),
3447 NEXT_ENTRY(ITEM_PARAM_IS)),
3448 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, index)),
3450 [ITEM_L2TPV3OIP] = {
3451 .name = "l2tpv3oip",
3452 .help = "match L2TPv3 over IP header",
3453 .priv = PRIV_ITEM(L2TPV3OIP,
3454 sizeof(struct rte_flow_item_l2tpv3oip)),
3455 .next = NEXT(item_l2tpv3oip),
3458 [ITEM_L2TPV3OIP_SESSION_ID] = {
3459 .name = "session_id",
3460 .help = "session identifier",
3461 .next = NEXT(item_l2tpv3oip, NEXT_ENTRY(COMMON_UNSIGNED),
3463 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv3oip,
3468 .help = "match ESP header",
3469 .priv = PRIV_ITEM(ESP, sizeof(struct rte_flow_item_esp)),
3470 .next = NEXT(item_esp),
3475 .help = "security policy index",
3476 .next = NEXT(item_esp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3477 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_esp,
3482 .help = "match AH header",
3483 .priv = PRIV_ITEM(AH, sizeof(struct rte_flow_item_ah)),
3484 .next = NEXT(item_ah),
3489 .help = "security parameters index",
3490 .next = NEXT(item_ah, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3491 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ah, spi)),
3495 .help = "match pfcp header",
3496 .priv = PRIV_ITEM(PFCP, sizeof(struct rte_flow_item_pfcp)),
3497 .next = NEXT(item_pfcp),
3500 [ITEM_PFCP_S_FIELD] = {
3503 .next = NEXT(item_pfcp, NEXT_ENTRY(COMMON_UNSIGNED),
3505 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp,
3508 [ITEM_PFCP_SEID] = {
3510 .help = "session endpoint identifier",
3511 .next = NEXT(item_pfcp, NEXT_ENTRY(COMMON_UNSIGNED),
3513 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp, seid)),
3517 .help = "match eCPRI header",
3518 .priv = PRIV_ITEM(ECPRI, sizeof(struct rte_flow_item_ecpri)),
3519 .next = NEXT(item_ecpri),
3522 [ITEM_ECPRI_COMMON] = {
3524 .help = "eCPRI common header",
3525 .next = NEXT(item_ecpri_common),
3527 [ITEM_ECPRI_COMMON_TYPE] = {
3529 .help = "type of common header",
3530 .next = NEXT(item_ecpri_common_type),
3531 .args = ARGS(ARG_ENTRY_HTON(struct rte_flow_item_ecpri)),
3533 [ITEM_ECPRI_COMMON_TYPE_IQ_DATA] = {
3535 .help = "Type #0: IQ Data",
3536 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
3538 .call = parse_vc_item_ecpri_type,
3540 [ITEM_ECPRI_MSG_IQ_DATA_PCID] = {
3542 .help = "Physical Channel ID",
3543 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
3544 ITEM_ECPRI_COMMON, ITEM_NEXT),
3545 NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3546 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3549 [ITEM_ECPRI_COMMON_TYPE_RTC_CTRL] = {
3551 .help = "Type #2: Real-Time Control Data",
3552 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
3554 .call = parse_vc_item_ecpri_type,
3556 [ITEM_ECPRI_MSG_RTC_CTRL_RTCID] = {
3558 .help = "Real-Time Control Data ID",
3559 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
3560 ITEM_ECPRI_COMMON, ITEM_NEXT),
3561 NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3562 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3565 [ITEM_ECPRI_COMMON_TYPE_DLY_MSR] = {
3566 .name = "delay_measure",
3567 .help = "Type #5: One-Way Delay Measurement",
3568 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
3570 .call = parse_vc_item_ecpri_type,
3572 [ITEM_ECPRI_MSG_DLY_MSR_MSRID] = {
3574 .help = "Measurement ID",
3575 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
3576 ITEM_ECPRI_COMMON, ITEM_NEXT),
3577 NEXT_ENTRY(COMMON_UNSIGNED), item_param),
3578 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3581 [ITEM_GENEVE_OPT] = {
3582 .name = "geneve-opt",
3583 .help = "GENEVE header option",
3584 .priv = PRIV_ITEM(GENEVE_OPT,
3585 sizeof(struct rte_flow_item_geneve_opt) +
3586 ITEM_GENEVE_OPT_DATA_SIZE),
3587 .next = NEXT(item_geneve_opt),
3590 [ITEM_GENEVE_OPT_CLASS] = {
3592 .help = "GENEVE option class",
3593 .next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_UNSIGNED),
3595 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve_opt,
3598 [ITEM_GENEVE_OPT_TYPE] = {
3600 .help = "GENEVE option type",
3601 .next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_UNSIGNED),
3603 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt,
3606 [ITEM_GENEVE_OPT_LENGTH] = {
3608 .help = "GENEVE option data length (in 32b words)",
3609 .next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_UNSIGNED),
3611 .args = ARGS(ARGS_ENTRY_BOUNDED(
3612 struct rte_flow_item_geneve_opt, option_len,
3615 [ITEM_GENEVE_OPT_DATA] = {
3617 .help = "GENEVE option data pattern",
3618 .next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_HEX),
3620 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt, data),
3621 ARGS_ENTRY_ARB(0, 0),
3623 (sizeof(struct rte_flow_item_geneve_opt),
3624 ITEM_GENEVE_OPT_DATA_SIZE)),
3626 [ITEM_INTEGRITY] = {
3627 .name = "integrity",
3628 .help = "match packet integrity",
3629 .priv = PRIV_ITEM(INTEGRITY,
3630 sizeof(struct rte_flow_item_integrity)),
3631 .next = NEXT(item_integrity),
3634 [ITEM_INTEGRITY_LEVEL] = {
3636 .help = "integrity level",
3637 .next = NEXT(item_integrity_lv, NEXT_ENTRY(COMMON_UNSIGNED),
3639 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_integrity, level)),
3641 [ITEM_INTEGRITY_VALUE] = {
3643 .help = "integrity value",
3644 .next = NEXT(item_integrity_lv, NEXT_ENTRY(COMMON_UNSIGNED),
3646 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_integrity, value)),
3648 [ITEM_CONNTRACK] = {
3649 .name = "conntrack",
3650 .help = "conntrack state",
3651 .next = NEXT(NEXT_ENTRY(ITEM_NEXT), NEXT_ENTRY(COMMON_UNSIGNED),
3653 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_conntrack, flags)),
3655 [ITEM_PORT_REPRESENTOR] = {
3656 .name = "port_representor",
3657 .help = "match traffic entering the embedded switch from the given ethdev",
3658 .priv = PRIV_ITEM(PORT_REPRESENTOR,
3659 sizeof(struct rte_flow_item_ethdev)),
3660 .next = NEXT(item_port_representor),
3663 [ITEM_PORT_REPRESENTOR_PORT_ID] = {
3665 .help = "ethdev port ID",
3666 .next = NEXT(item_port_representor, NEXT_ENTRY(COMMON_UNSIGNED),
3668 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ethdev, port_id)),
3670 [ITEM_REPRESENTED_PORT] = {
3671 .name = "represented_port",
3672 .help = "match traffic entering the embedded switch from the entity represented by the given ethdev",
3673 .priv = PRIV_ITEM(REPRESENTED_PORT,
3674 sizeof(struct rte_flow_item_ethdev)),
3675 .next = NEXT(item_represented_port),
3678 [ITEM_REPRESENTED_PORT_ETHDEV_PORT_ID] = {
3679 .name = "ethdev_port_id",
3680 .help = "ethdev port ID",
3681 .next = NEXT(item_represented_port, NEXT_ENTRY(COMMON_UNSIGNED),
3683 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ethdev, port_id)),
3685 /* Validate/create actions. */
3688 .help = "submit a list of associated actions",
3689 .next = NEXT(next_action),
3694 .help = "specify next action",
3695 .next = NEXT(next_action),
3699 .help = "end list of actions",
3700 .priv = PRIV_ACTION(END, 0),
3705 .help = "no-op action",
3706 .priv = PRIV_ACTION(VOID, 0),
3707 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3710 [ACTION_PASSTHRU] = {
3712 .help = "let subsequent rule process matched packets",
3713 .priv = PRIV_ACTION(PASSTHRU, 0),
3714 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3719 .help = "redirect traffic to a given group",
3720 .priv = PRIV_ACTION(JUMP, sizeof(struct rte_flow_action_jump)),
3721 .next = NEXT(action_jump),
3724 [ACTION_JUMP_GROUP] = {
3726 .help = "group to redirect traffic to",
3727 .next = NEXT(action_jump, NEXT_ENTRY(COMMON_UNSIGNED)),
3728 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump, group)),
3729 .call = parse_vc_conf,
3733 .help = "attach 32 bit value to packets",
3734 .priv = PRIV_ACTION(MARK, sizeof(struct rte_flow_action_mark)),
3735 .next = NEXT(action_mark),
3738 [ACTION_MARK_ID] = {
3740 .help = "32 bit value to return with packets",
3741 .next = NEXT(action_mark, NEXT_ENTRY(COMMON_UNSIGNED)),
3742 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_mark, id)),
3743 .call = parse_vc_conf,
3747 .help = "flag packets",
3748 .priv = PRIV_ACTION(FLAG, 0),
3749 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3754 .help = "assign packets to a given queue index",
3755 .priv = PRIV_ACTION(QUEUE,
3756 sizeof(struct rte_flow_action_queue)),
3757 .next = NEXT(action_queue),
3760 [ACTION_QUEUE_INDEX] = {
3762 .help = "queue index to use",
3763 .next = NEXT(action_queue, NEXT_ENTRY(COMMON_UNSIGNED)),
3764 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_queue, index)),
3765 .call = parse_vc_conf,
3769 .help = "drop packets (note: passthru has priority)",
3770 .priv = PRIV_ACTION(DROP, 0),
3771 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3776 .help = "enable counters for this rule",
3777 .priv = PRIV_ACTION(COUNT,
3778 sizeof(struct rte_flow_action_count)),
3779 .next = NEXT(action_count),
3782 [ACTION_COUNT_ID] = {
3783 .name = "identifier",
3784 .help = "counter identifier to use",
3785 .next = NEXT(action_count, NEXT_ENTRY(COMMON_UNSIGNED)),
3786 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_count, id)),
3787 .call = parse_vc_conf,
3791 .help = "spread packets among several queues",
3792 .priv = PRIV_ACTION(RSS, sizeof(struct action_rss_data)),
3793 .next = NEXT(action_rss),
3794 .call = parse_vc_action_rss,
3796 [ACTION_RSS_FUNC] = {
3798 .help = "RSS hash function to apply",
3799 .next = NEXT(action_rss,
3800 NEXT_ENTRY(ACTION_RSS_FUNC_DEFAULT,
3801 ACTION_RSS_FUNC_TOEPLITZ,
3802 ACTION_RSS_FUNC_SIMPLE_XOR,
3803 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ)),
3805 [ACTION_RSS_FUNC_DEFAULT] = {
3807 .help = "default hash function",
3808 .call = parse_vc_action_rss_func,
3810 [ACTION_RSS_FUNC_TOEPLITZ] = {
3812 .help = "Toeplitz hash function",
3813 .call = parse_vc_action_rss_func,
3815 [ACTION_RSS_FUNC_SIMPLE_XOR] = {
3816 .name = "simple_xor",
3817 .help = "simple XOR hash function",
3818 .call = parse_vc_action_rss_func,
3820 [ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ] = {
3821 .name = "symmetric_toeplitz",
3822 .help = "Symmetric Toeplitz hash function",
3823 .call = parse_vc_action_rss_func,
3825 [ACTION_RSS_LEVEL] = {
3827 .help = "encapsulation level for \"types\"",
3828 .next = NEXT(action_rss, NEXT_ENTRY(COMMON_UNSIGNED)),
3829 .args = ARGS(ARGS_ENTRY_ARB
3830 (offsetof(struct action_rss_data, conf) +
3831 offsetof(struct rte_flow_action_rss, level),
3832 sizeof(((struct rte_flow_action_rss *)0)->
3835 [ACTION_RSS_TYPES] = {
3837 .help = "specific RSS hash types",
3838 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)),
3840 [ACTION_RSS_TYPE] = {
3842 .help = "RSS hash type",
3843 .call = parse_vc_action_rss_type,
3844 .comp = comp_vc_action_rss_type,
3846 [ACTION_RSS_KEY] = {
3848 .help = "RSS hash key",
3849 .next = NEXT(action_rss, NEXT_ENTRY(COMMON_HEX)),
3850 .args = ARGS(ARGS_ENTRY_ARB
3851 (offsetof(struct action_rss_data, conf) +
3852 offsetof(struct rte_flow_action_rss, key),
3853 sizeof(((struct rte_flow_action_rss *)0)->key)),
3855 (offsetof(struct action_rss_data, conf) +
3856 offsetof(struct rte_flow_action_rss, key_len),
3857 sizeof(((struct rte_flow_action_rss *)0)->
3859 ARGS_ENTRY(struct action_rss_data, key)),
3861 [ACTION_RSS_KEY_LEN] = {
3863 .help = "RSS hash key length in bytes",
3864 .next = NEXT(action_rss, NEXT_ENTRY(COMMON_UNSIGNED)),
3865 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
3866 (offsetof(struct action_rss_data, conf) +
3867 offsetof(struct rte_flow_action_rss, key_len),
3868 sizeof(((struct rte_flow_action_rss *)0)->
3871 RSS_HASH_KEY_LENGTH)),
3873 [ACTION_RSS_QUEUES] = {
3875 .help = "queue indices to use",
3876 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_QUEUE)),
3877 .call = parse_vc_conf,
3879 [ACTION_RSS_QUEUE] = {
3881 .help = "queue index",
3882 .call = parse_vc_action_rss_queue,
3883 .comp = comp_vc_action_rss_queue,
3887 .help = "direct traffic to physical function",
3888 .priv = PRIV_ACTION(PF, 0),
3889 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3894 .help = "direct traffic to a virtual function ID",
3895 .priv = PRIV_ACTION(VF, sizeof(struct rte_flow_action_vf)),
3896 .next = NEXT(action_vf),
3899 [ACTION_VF_ORIGINAL] = {
3901 .help = "use original VF ID if possible",
3902 .next = NEXT(action_vf, NEXT_ENTRY(COMMON_BOOLEAN)),
3903 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_vf,
3905 .call = parse_vc_conf,
3910 .next = NEXT(action_vf, NEXT_ENTRY(COMMON_UNSIGNED)),
3911 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)),
3912 .call = parse_vc_conf,
3914 [ACTION_PHY_PORT] = {
3916 .help = "direct packets to physical port index",
3917 .priv = PRIV_ACTION(PHY_PORT,
3918 sizeof(struct rte_flow_action_phy_port)),
3919 .next = NEXT(action_phy_port),
3922 [ACTION_PHY_PORT_ORIGINAL] = {
3924 .help = "use original port index if possible",
3925 .next = NEXT(action_phy_port, NEXT_ENTRY(COMMON_BOOLEAN)),
3926 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_phy_port,
3928 .call = parse_vc_conf,
3930 [ACTION_PHY_PORT_INDEX] = {
3932 .help = "physical port index",
3933 .next = NEXT(action_phy_port, NEXT_ENTRY(COMMON_UNSIGNED)),
3934 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_phy_port,
3936 .call = parse_vc_conf,
3938 [ACTION_PORT_ID] = {
3940 .help = "direct matching traffic to a given DPDK port ID",
3941 .priv = PRIV_ACTION(PORT_ID,
3942 sizeof(struct rte_flow_action_port_id)),
3943 .next = NEXT(action_port_id),
3946 [ACTION_PORT_ID_ORIGINAL] = {
3948 .help = "use original DPDK port ID if possible",
3949 .next = NEXT(action_port_id, NEXT_ENTRY(COMMON_BOOLEAN)),
3950 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_port_id,
3952 .call = parse_vc_conf,
3954 [ACTION_PORT_ID_ID] = {
3956 .help = "DPDK port ID",
3957 .next = NEXT(action_port_id, NEXT_ENTRY(COMMON_UNSIGNED)),
3958 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_port_id, id)),
3959 .call = parse_vc_conf,
3963 .help = "meter the directed packets at given id",
3964 .priv = PRIV_ACTION(METER,
3965 sizeof(struct rte_flow_action_meter)),
3966 .next = NEXT(action_meter),
3969 [ACTION_METER_COLOR] = {
3971 .help = "meter color for the packets",
3972 .priv = PRIV_ACTION(METER_COLOR,
3973 sizeof(struct rte_flow_action_meter_color)),
3974 .next = NEXT(action_meter_color),
3977 [ACTION_METER_COLOR_TYPE] = {
3979 .help = "specific meter color",
3980 .next = NEXT(NEXT_ENTRY(ACTION_NEXT),
3981 NEXT_ENTRY(ACTION_METER_COLOR_GREEN,
3982 ACTION_METER_COLOR_YELLOW,
3983 ACTION_METER_COLOR_RED)),
3985 [ACTION_METER_COLOR_GREEN] = {
3987 .help = "meter color green",
3988 .call = parse_vc_action_meter_color_type,
3990 [ACTION_METER_COLOR_YELLOW] = {
3992 .help = "meter color yellow",
3993 .call = parse_vc_action_meter_color_type,
3995 [ACTION_METER_COLOR_RED] = {
3997 .help = "meter color red",
3998 .call = parse_vc_action_meter_color_type,
4000 [ACTION_METER_ID] = {
4002 .help = "meter id to use",
4003 .next = NEXT(action_meter, NEXT_ENTRY(COMMON_UNSIGNED)),
4004 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter, mtr_id)),
4005 .call = parse_vc_conf,
4007 [ACTION_OF_SET_MPLS_TTL] = {
4008 .name = "of_set_mpls_ttl",
4009 .help = "OpenFlow's OFPAT_SET_MPLS_TTL",
4012 sizeof(struct rte_flow_action_of_set_mpls_ttl)),
4013 .next = NEXT(action_of_set_mpls_ttl),
4016 [ACTION_OF_SET_MPLS_TTL_MPLS_TTL] = {
4019 .next = NEXT(action_of_set_mpls_ttl,
4020 NEXT_ENTRY(COMMON_UNSIGNED)),
4021 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_mpls_ttl,
4023 .call = parse_vc_conf,
4025 [ACTION_OF_DEC_MPLS_TTL] = {
4026 .name = "of_dec_mpls_ttl",
4027 .help = "OpenFlow's OFPAT_DEC_MPLS_TTL",
4028 .priv = PRIV_ACTION(OF_DEC_MPLS_TTL, 0),
4029 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4032 [ACTION_OF_SET_NW_TTL] = {
4033 .name = "of_set_nw_ttl",
4034 .help = "OpenFlow's OFPAT_SET_NW_TTL",
4037 sizeof(struct rte_flow_action_of_set_nw_ttl)),
4038 .next = NEXT(action_of_set_nw_ttl),
4041 [ACTION_OF_SET_NW_TTL_NW_TTL] = {
4044 .next = NEXT(action_of_set_nw_ttl, NEXT_ENTRY(COMMON_UNSIGNED)),
4045 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_nw_ttl,
4047 .call = parse_vc_conf,
4049 [ACTION_OF_DEC_NW_TTL] = {
4050 .name = "of_dec_nw_ttl",
4051 .help = "OpenFlow's OFPAT_DEC_NW_TTL",
4052 .priv = PRIV_ACTION(OF_DEC_NW_TTL, 0),
4053 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4056 [ACTION_OF_COPY_TTL_OUT] = {
4057 .name = "of_copy_ttl_out",
4058 .help = "OpenFlow's OFPAT_COPY_TTL_OUT",
4059 .priv = PRIV_ACTION(OF_COPY_TTL_OUT, 0),
4060 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4063 [ACTION_OF_COPY_TTL_IN] = {
4064 .name = "of_copy_ttl_in",
4065 .help = "OpenFlow's OFPAT_COPY_TTL_IN",
4066 .priv = PRIV_ACTION(OF_COPY_TTL_IN, 0),
4067 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4070 [ACTION_OF_POP_VLAN] = {
4071 .name = "of_pop_vlan",
4072 .help = "OpenFlow's OFPAT_POP_VLAN",
4073 .priv = PRIV_ACTION(OF_POP_VLAN, 0),
4074 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4077 [ACTION_OF_PUSH_VLAN] = {
4078 .name = "of_push_vlan",
4079 .help = "OpenFlow's OFPAT_PUSH_VLAN",
4082 sizeof(struct rte_flow_action_of_push_vlan)),
4083 .next = NEXT(action_of_push_vlan),
4086 [ACTION_OF_PUSH_VLAN_ETHERTYPE] = {
4087 .name = "ethertype",
4088 .help = "EtherType",
4089 .next = NEXT(action_of_push_vlan, NEXT_ENTRY(COMMON_UNSIGNED)),
4090 .args = ARGS(ARGS_ENTRY_HTON
4091 (struct rte_flow_action_of_push_vlan,
4093 .call = parse_vc_conf,
4095 [ACTION_OF_SET_VLAN_VID] = {
4096 .name = "of_set_vlan_vid",
4097 .help = "OpenFlow's OFPAT_SET_VLAN_VID",
4100 sizeof(struct rte_flow_action_of_set_vlan_vid)),
4101 .next = NEXT(action_of_set_vlan_vid),
4104 [ACTION_OF_SET_VLAN_VID_VLAN_VID] = {
4107 .next = NEXT(action_of_set_vlan_vid,
4108 NEXT_ENTRY(COMMON_UNSIGNED)),
4109 .args = ARGS(ARGS_ENTRY_HTON
4110 (struct rte_flow_action_of_set_vlan_vid,
4112 .call = parse_vc_conf,
4114 [ACTION_OF_SET_VLAN_PCP] = {
4115 .name = "of_set_vlan_pcp",
4116 .help = "OpenFlow's OFPAT_SET_VLAN_PCP",
4119 sizeof(struct rte_flow_action_of_set_vlan_pcp)),
4120 .next = NEXT(action_of_set_vlan_pcp),
4123 [ACTION_OF_SET_VLAN_PCP_VLAN_PCP] = {
4125 .help = "VLAN priority",
4126 .next = NEXT(action_of_set_vlan_pcp,
4127 NEXT_ENTRY(COMMON_UNSIGNED)),
4128 .args = ARGS(ARGS_ENTRY_HTON
4129 (struct rte_flow_action_of_set_vlan_pcp,
4131 .call = parse_vc_conf,
4133 [ACTION_OF_POP_MPLS] = {
4134 .name = "of_pop_mpls",
4135 .help = "OpenFlow's OFPAT_POP_MPLS",
4136 .priv = PRIV_ACTION(OF_POP_MPLS,
4137 sizeof(struct rte_flow_action_of_pop_mpls)),
4138 .next = NEXT(action_of_pop_mpls),
4141 [ACTION_OF_POP_MPLS_ETHERTYPE] = {
4142 .name = "ethertype",
4143 .help = "EtherType",
4144 .next = NEXT(action_of_pop_mpls, NEXT_ENTRY(COMMON_UNSIGNED)),
4145 .args = ARGS(ARGS_ENTRY_HTON
4146 (struct rte_flow_action_of_pop_mpls,
4148 .call = parse_vc_conf,
4150 [ACTION_OF_PUSH_MPLS] = {
4151 .name = "of_push_mpls",
4152 .help = "OpenFlow's OFPAT_PUSH_MPLS",
4155 sizeof(struct rte_flow_action_of_push_mpls)),
4156 .next = NEXT(action_of_push_mpls),
4159 [ACTION_OF_PUSH_MPLS_ETHERTYPE] = {
4160 .name = "ethertype",
4161 .help = "EtherType",
4162 .next = NEXT(action_of_push_mpls, NEXT_ENTRY(COMMON_UNSIGNED)),
4163 .args = ARGS(ARGS_ENTRY_HTON
4164 (struct rte_flow_action_of_push_mpls,
4166 .call = parse_vc_conf,
4168 [ACTION_VXLAN_ENCAP] = {
4169 .name = "vxlan_encap",
4170 .help = "VXLAN encapsulation, uses configuration set by \"set"
4172 .priv = PRIV_ACTION(VXLAN_ENCAP,
4173 sizeof(struct action_vxlan_encap_data)),
4174 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4175 .call = parse_vc_action_vxlan_encap,
4177 [ACTION_VXLAN_DECAP] = {
4178 .name = "vxlan_decap",
4179 .help = "Performs a decapsulation action by stripping all"
4180 " headers of the VXLAN tunnel network overlay from the"
4182 .priv = PRIV_ACTION(VXLAN_DECAP, 0),
4183 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4186 [ACTION_NVGRE_ENCAP] = {
4187 .name = "nvgre_encap",
4188 .help = "NVGRE encapsulation, uses configuration set by \"set"
4190 .priv = PRIV_ACTION(NVGRE_ENCAP,
4191 sizeof(struct action_nvgre_encap_data)),
4192 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4193 .call = parse_vc_action_nvgre_encap,
4195 [ACTION_NVGRE_DECAP] = {
4196 .name = "nvgre_decap",
4197 .help = "Performs a decapsulation action by stripping all"
4198 " headers of the NVGRE tunnel network overlay from the"
4200 .priv = PRIV_ACTION(NVGRE_DECAP, 0),
4201 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4204 [ACTION_L2_ENCAP] = {
4206 .help = "l2 encap, uses configuration set by"
4207 " \"set l2_encap\"",
4208 .priv = PRIV_ACTION(RAW_ENCAP,
4209 sizeof(struct action_raw_encap_data)),
4210 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4211 .call = parse_vc_action_l2_encap,
4213 [ACTION_L2_DECAP] = {
4215 .help = "l2 decap, uses configuration set by"
4216 " \"set l2_decap\"",
4217 .priv = PRIV_ACTION(RAW_DECAP,
4218 sizeof(struct action_raw_decap_data)),
4219 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4220 .call = parse_vc_action_l2_decap,
4222 [ACTION_MPLSOGRE_ENCAP] = {
4223 .name = "mplsogre_encap",
4224 .help = "mplsogre encapsulation, uses configuration set by"
4225 " \"set mplsogre_encap\"",
4226 .priv = PRIV_ACTION(RAW_ENCAP,
4227 sizeof(struct action_raw_encap_data)),
4228 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4229 .call = parse_vc_action_mplsogre_encap,
4231 [ACTION_MPLSOGRE_DECAP] = {
4232 .name = "mplsogre_decap",
4233 .help = "mplsogre decapsulation, uses configuration set by"
4234 " \"set mplsogre_decap\"",
4235 .priv = PRIV_ACTION(RAW_DECAP,
4236 sizeof(struct action_raw_decap_data)),
4237 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4238 .call = parse_vc_action_mplsogre_decap,
4240 [ACTION_MPLSOUDP_ENCAP] = {
4241 .name = "mplsoudp_encap",
4242 .help = "mplsoudp encapsulation, uses configuration set by"
4243 " \"set mplsoudp_encap\"",
4244 .priv = PRIV_ACTION(RAW_ENCAP,
4245 sizeof(struct action_raw_encap_data)),
4246 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4247 .call = parse_vc_action_mplsoudp_encap,
4249 [ACTION_MPLSOUDP_DECAP] = {
4250 .name = "mplsoudp_decap",
4251 .help = "mplsoudp decapsulation, uses configuration set by"
4252 " \"set mplsoudp_decap\"",
4253 .priv = PRIV_ACTION(RAW_DECAP,
4254 sizeof(struct action_raw_decap_data)),
4255 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4256 .call = parse_vc_action_mplsoudp_decap,
4258 [ACTION_SET_IPV4_SRC] = {
4259 .name = "set_ipv4_src",
4260 .help = "Set a new IPv4 source address in the outermost"
4262 .priv = PRIV_ACTION(SET_IPV4_SRC,
4263 sizeof(struct rte_flow_action_set_ipv4)),
4264 .next = NEXT(action_set_ipv4_src),
4267 [ACTION_SET_IPV4_SRC_IPV4_SRC] = {
4268 .name = "ipv4_addr",
4269 .help = "new IPv4 source address to set",
4270 .next = NEXT(action_set_ipv4_src, NEXT_ENTRY(COMMON_IPV4_ADDR)),
4271 .args = ARGS(ARGS_ENTRY_HTON
4272 (struct rte_flow_action_set_ipv4, ipv4_addr)),
4273 .call = parse_vc_conf,
4275 [ACTION_SET_IPV4_DST] = {
4276 .name = "set_ipv4_dst",
4277 .help = "Set a new IPv4 destination address in the outermost"
4279 .priv = PRIV_ACTION(SET_IPV4_DST,
4280 sizeof(struct rte_flow_action_set_ipv4)),
4281 .next = NEXT(action_set_ipv4_dst),
4284 [ACTION_SET_IPV4_DST_IPV4_DST] = {
4285 .name = "ipv4_addr",
4286 .help = "new IPv4 destination address to set",
4287 .next = NEXT(action_set_ipv4_dst, NEXT_ENTRY(COMMON_IPV4_ADDR)),
4288 .args = ARGS(ARGS_ENTRY_HTON
4289 (struct rte_flow_action_set_ipv4, ipv4_addr)),
4290 .call = parse_vc_conf,
4292 [ACTION_SET_IPV6_SRC] = {
4293 .name = "set_ipv6_src",
4294 .help = "Set a new IPv6 source address in the outermost"
4296 .priv = PRIV_ACTION(SET_IPV6_SRC,
4297 sizeof(struct rte_flow_action_set_ipv6)),
4298 .next = NEXT(action_set_ipv6_src),
4301 [ACTION_SET_IPV6_SRC_IPV6_SRC] = {
4302 .name = "ipv6_addr",
4303 .help = "new IPv6 source address to set",
4304 .next = NEXT(action_set_ipv6_src, NEXT_ENTRY(COMMON_IPV6_ADDR)),
4305 .args = ARGS(ARGS_ENTRY_HTON
4306 (struct rte_flow_action_set_ipv6, ipv6_addr)),
4307 .call = parse_vc_conf,
4309 [ACTION_SET_IPV6_DST] = {
4310 .name = "set_ipv6_dst",
4311 .help = "Set a new IPv6 destination address in the outermost"
4313 .priv = PRIV_ACTION(SET_IPV6_DST,
4314 sizeof(struct rte_flow_action_set_ipv6)),
4315 .next = NEXT(action_set_ipv6_dst),
4318 [ACTION_SET_IPV6_DST_IPV6_DST] = {
4319 .name = "ipv6_addr",
4320 .help = "new IPv6 destination address to set",
4321 .next = NEXT(action_set_ipv6_dst, NEXT_ENTRY(COMMON_IPV6_ADDR)),
4322 .args = ARGS(ARGS_ENTRY_HTON
4323 (struct rte_flow_action_set_ipv6, ipv6_addr)),
4324 .call = parse_vc_conf,
4326 [ACTION_SET_TP_SRC] = {
4327 .name = "set_tp_src",
4328 .help = "set a new source port number in the outermost"
4330 .priv = PRIV_ACTION(SET_TP_SRC,
4331 sizeof(struct rte_flow_action_set_tp)),
4332 .next = NEXT(action_set_tp_src),
4335 [ACTION_SET_TP_SRC_TP_SRC] = {
4337 .help = "new source port number to set",
4338 .next = NEXT(action_set_tp_src, NEXT_ENTRY(COMMON_UNSIGNED)),
4339 .args = ARGS(ARGS_ENTRY_HTON
4340 (struct rte_flow_action_set_tp, port)),
4341 .call = parse_vc_conf,
4343 [ACTION_SET_TP_DST] = {
4344 .name = "set_tp_dst",
4345 .help = "set a new destination port number in the outermost"
4347 .priv = PRIV_ACTION(SET_TP_DST,
4348 sizeof(struct rte_flow_action_set_tp)),
4349 .next = NEXT(action_set_tp_dst),
4352 [ACTION_SET_TP_DST_TP_DST] = {
4354 .help = "new destination port number to set",
4355 .next = NEXT(action_set_tp_dst, NEXT_ENTRY(COMMON_UNSIGNED)),
4356 .args = ARGS(ARGS_ENTRY_HTON
4357 (struct rte_flow_action_set_tp, port)),
4358 .call = parse_vc_conf,
4360 [ACTION_MAC_SWAP] = {
4362 .help = "Swap the source and destination MAC addresses"
4363 " in the outermost Ethernet header",
4364 .priv = PRIV_ACTION(MAC_SWAP, 0),
4365 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4368 [ACTION_DEC_TTL] = {
4370 .help = "decrease network TTL if available",
4371 .priv = PRIV_ACTION(DEC_TTL, 0),
4372 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4375 [ACTION_SET_TTL] = {
4377 .help = "set ttl value",
4378 .priv = PRIV_ACTION(SET_TTL,
4379 sizeof(struct rte_flow_action_set_ttl)),
4380 .next = NEXT(action_set_ttl),
4383 [ACTION_SET_TTL_TTL] = {
4384 .name = "ttl_value",
4385 .help = "new ttl value to set",
4386 .next = NEXT(action_set_ttl, NEXT_ENTRY(COMMON_UNSIGNED)),
4387 .args = ARGS(ARGS_ENTRY_HTON
4388 (struct rte_flow_action_set_ttl, ttl_value)),
4389 .call = parse_vc_conf,
4391 [ACTION_SET_MAC_SRC] = {
4392 .name = "set_mac_src",
4393 .help = "set source mac address",
4394 .priv = PRIV_ACTION(SET_MAC_SRC,
4395 sizeof(struct rte_flow_action_set_mac)),
4396 .next = NEXT(action_set_mac_src),
4399 [ACTION_SET_MAC_SRC_MAC_SRC] = {
4401 .help = "new source mac address",
4402 .next = NEXT(action_set_mac_src, NEXT_ENTRY(COMMON_MAC_ADDR)),
4403 .args = ARGS(ARGS_ENTRY_HTON
4404 (struct rte_flow_action_set_mac, mac_addr)),
4405 .call = parse_vc_conf,
4407 [ACTION_SET_MAC_DST] = {
4408 .name = "set_mac_dst",
4409 .help = "set destination mac address",
4410 .priv = PRIV_ACTION(SET_MAC_DST,
4411 sizeof(struct rte_flow_action_set_mac)),
4412 .next = NEXT(action_set_mac_dst),
4415 [ACTION_SET_MAC_DST_MAC_DST] = {
4417 .help = "new destination mac address to set",
4418 .next = NEXT(action_set_mac_dst, NEXT_ENTRY(COMMON_MAC_ADDR)),
4419 .args = ARGS(ARGS_ENTRY_HTON
4420 (struct rte_flow_action_set_mac, mac_addr)),
4421 .call = parse_vc_conf,
4423 [ACTION_INC_TCP_SEQ] = {
4424 .name = "inc_tcp_seq",
4425 .help = "increase TCP sequence number",
4426 .priv = PRIV_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
4427 .next = NEXT(action_inc_tcp_seq),
4430 [ACTION_INC_TCP_SEQ_VALUE] = {
4432 .help = "the value to increase TCP sequence number by",
4433 .next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(COMMON_UNSIGNED)),
4434 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4435 .call = parse_vc_conf,
4437 [ACTION_DEC_TCP_SEQ] = {
4438 .name = "dec_tcp_seq",
4439 .help = "decrease TCP sequence number",
4440 .priv = PRIV_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
4441 .next = NEXT(action_dec_tcp_seq),
4444 [ACTION_DEC_TCP_SEQ_VALUE] = {
4446 .help = "the value to decrease TCP sequence number by",
4447 .next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(COMMON_UNSIGNED)),
4448 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4449 .call = parse_vc_conf,
4451 [ACTION_INC_TCP_ACK] = {
4452 .name = "inc_tcp_ack",
4453 .help = "increase TCP acknowledgment number",
4454 .priv = PRIV_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
4455 .next = NEXT(action_inc_tcp_ack),
4458 [ACTION_INC_TCP_ACK_VALUE] = {
4460 .help = "the value to increase TCP acknowledgment number by",
4461 .next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(COMMON_UNSIGNED)),
4462 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4463 .call = parse_vc_conf,
4465 [ACTION_DEC_TCP_ACK] = {
4466 .name = "dec_tcp_ack",
4467 .help = "decrease TCP acknowledgment number",
4468 .priv = PRIV_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
4469 .next = NEXT(action_dec_tcp_ack),
4472 [ACTION_DEC_TCP_ACK_VALUE] = {
4474 .help = "the value to decrease TCP acknowledgment number by",
4475 .next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(COMMON_UNSIGNED)),
4476 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4477 .call = parse_vc_conf,
4479 [ACTION_RAW_ENCAP] = {
4480 .name = "raw_encap",
4481 .help = "encapsulation data, defined by set raw_encap",
4482 .priv = PRIV_ACTION(RAW_ENCAP,
4483 sizeof(struct action_raw_encap_data)),
4484 .next = NEXT(action_raw_encap),
4485 .call = parse_vc_action_raw_encap,
4487 [ACTION_RAW_ENCAP_INDEX] = {
4489 .help = "the index of raw_encap_confs",
4490 .next = NEXT(NEXT_ENTRY(ACTION_RAW_ENCAP_INDEX_VALUE)),
4492 [ACTION_RAW_ENCAP_INDEX_VALUE] = {
4495 .help = "unsigned integer value",
4496 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4497 .call = parse_vc_action_raw_encap_index,
4498 .comp = comp_set_raw_index,
4500 [ACTION_RAW_DECAP] = {
4501 .name = "raw_decap",
4502 .help = "decapsulation data, defined by set raw_encap",
4503 .priv = PRIV_ACTION(RAW_DECAP,
4504 sizeof(struct action_raw_decap_data)),
4505 .next = NEXT(action_raw_decap),
4506 .call = parse_vc_action_raw_decap,
4508 [ACTION_RAW_DECAP_INDEX] = {
4510 .help = "the index of raw_encap_confs",
4511 .next = NEXT(NEXT_ENTRY(ACTION_RAW_DECAP_INDEX_VALUE)),
4513 [ACTION_RAW_DECAP_INDEX_VALUE] = {
4516 .help = "unsigned integer value",
4517 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4518 .call = parse_vc_action_raw_decap_index,
4519 .comp = comp_set_raw_index,
4521 [ACTION_MODIFY_FIELD] = {
4522 .name = "modify_field",
4523 .help = "modify destination field with data from source field",
4524 .priv = PRIV_ACTION(MODIFY_FIELD, ACTION_MODIFY_SIZE),
4525 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_OP)),
4528 [ACTION_MODIFY_FIELD_OP] = {
4530 .help = "operation type",
4531 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_TYPE),
4532 NEXT_ENTRY(ACTION_MODIFY_FIELD_OP_VALUE)),
4533 .call = parse_vc_conf,
4535 [ACTION_MODIFY_FIELD_OP_VALUE] = {
4536 .name = "{operation}",
4537 .help = "operation type value",
4538 .call = parse_vc_modify_field_op,
4539 .comp = comp_set_modify_field_op,
4541 [ACTION_MODIFY_FIELD_DST_TYPE] = {
4543 .help = "destination field type",
4544 .next = NEXT(action_modify_field_dst,
4545 NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_TYPE_VALUE)),
4546 .call = parse_vc_conf,
4548 [ACTION_MODIFY_FIELD_DST_TYPE_VALUE] = {
4549 .name = "{dst_type}",
4550 .help = "destination field type value",
4551 .call = parse_vc_modify_field_id,
4552 .comp = comp_set_modify_field_id,
4554 [ACTION_MODIFY_FIELD_DST_LEVEL] = {
4555 .name = "dst_level",
4556 .help = "destination field level",
4557 .next = NEXT(action_modify_field_dst,
4558 NEXT_ENTRY(COMMON_UNSIGNED)),
4559 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4561 .call = parse_vc_conf,
4563 [ACTION_MODIFY_FIELD_DST_OFFSET] = {
4564 .name = "dst_offset",
4565 .help = "destination field bit offset",
4566 .next = NEXT(action_modify_field_dst,
4567 NEXT_ENTRY(COMMON_UNSIGNED)),
4568 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4570 .call = parse_vc_conf,
4572 [ACTION_MODIFY_FIELD_SRC_TYPE] = {
4574 .help = "source field type",
4575 .next = NEXT(action_modify_field_src,
4576 NEXT_ENTRY(ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)),
4577 .call = parse_vc_conf,
4579 [ACTION_MODIFY_FIELD_SRC_TYPE_VALUE] = {
4580 .name = "{src_type}",
4581 .help = "source field type value",
4582 .call = parse_vc_modify_field_id,
4583 .comp = comp_set_modify_field_id,
4585 [ACTION_MODIFY_FIELD_SRC_LEVEL] = {
4586 .name = "src_level",
4587 .help = "source field level",
4588 .next = NEXT(action_modify_field_src,
4589 NEXT_ENTRY(COMMON_UNSIGNED)),
4590 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4592 .call = parse_vc_conf,
4594 [ACTION_MODIFY_FIELD_SRC_OFFSET] = {
4595 .name = "src_offset",
4596 .help = "source field bit offset",
4597 .next = NEXT(action_modify_field_src,
4598 NEXT_ENTRY(COMMON_UNSIGNED)),
4599 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4601 .call = parse_vc_conf,
4603 [ACTION_MODIFY_FIELD_SRC_VALUE] = {
4604 .name = "src_value",
4605 .help = "source immediate value",
4606 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_WIDTH),
4607 NEXT_ENTRY(COMMON_HEX)),
4608 .args = ARGS(ARGS_ENTRY_ARB(0, 0),
4609 ARGS_ENTRY_ARB(0, 0),
4610 ARGS_ENTRY(struct rte_flow_action_modify_field,
4612 .call = parse_vc_conf,
4614 [ACTION_MODIFY_FIELD_SRC_POINTER] = {
4616 .help = "pointer to source immediate value",
4617 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_WIDTH),
4618 NEXT_ENTRY(COMMON_HEX)),
4619 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4621 ARGS_ENTRY_ARB(0, 0),
4623 (sizeof(struct rte_flow_action_modify_field),
4624 ACTION_MODIFY_PATTERN_SIZE)),
4625 .call = parse_vc_conf,
4627 [ACTION_MODIFY_FIELD_WIDTH] = {
4629 .help = "number of bits to copy",
4630 .next = NEXT(NEXT_ENTRY(ACTION_NEXT),
4631 NEXT_ENTRY(COMMON_UNSIGNED)),
4632 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4634 .call = parse_vc_conf,
4636 /* Top level command. */
4639 .help = "set raw encap/decap/sample data",
4640 .type = "set raw_encap|raw_decap <index> <pattern>"
4641 " or set sample_actions <index> <action>",
4642 .next = NEXT(NEXT_ENTRY
4645 SET_SAMPLE_ACTIONS)),
4646 .call = parse_set_init,
4648 /* Sub-level commands. */
4650 .name = "raw_encap",
4651 .help = "set raw encap data",
4652 .next = NEXT(next_set_raw),
4653 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4654 (offsetof(struct buffer, port),
4655 sizeof(((struct buffer *)0)->port),
4656 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
4657 .call = parse_set_raw_encap_decap,
4660 .name = "raw_decap",
4661 .help = "set raw decap data",
4662 .next = NEXT(next_set_raw),
4663 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4664 (offsetof(struct buffer, port),
4665 sizeof(((struct buffer *)0)->port),
4666 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
4667 .call = parse_set_raw_encap_decap,
4671 .type = "COMMON_UNSIGNED",
4672 .help = "index of raw_encap/raw_decap data",
4673 .next = NEXT(next_item),
4676 [SET_SAMPLE_INDEX] = {
4679 .help = "index of sample actions",
4680 .next = NEXT(next_action_sample),
4683 [SET_SAMPLE_ACTIONS] = {
4684 .name = "sample_actions",
4685 .help = "set sample actions list",
4686 .next = NEXT(NEXT_ENTRY(SET_SAMPLE_INDEX)),
4687 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4688 (offsetof(struct buffer, port),
4689 sizeof(((struct buffer *)0)->port),
4690 0, RAW_SAMPLE_CONFS_MAX_NUM - 1)),
4691 .call = parse_set_sample_action,
4693 [ACTION_SET_TAG] = {
4696 .priv = PRIV_ACTION(SET_TAG,
4697 sizeof(struct rte_flow_action_set_tag)),
4698 .next = NEXT(action_set_tag),
4701 [ACTION_SET_TAG_INDEX] = {
4703 .help = "index of tag array",
4704 .next = NEXT(action_set_tag, NEXT_ENTRY(COMMON_UNSIGNED)),
4705 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_set_tag, index)),
4706 .call = parse_vc_conf,
4708 [ACTION_SET_TAG_DATA] = {
4710 .help = "tag value",
4711 .next = NEXT(action_set_tag, NEXT_ENTRY(COMMON_UNSIGNED)),
4712 .args = ARGS(ARGS_ENTRY
4713 (struct rte_flow_action_set_tag, data)),
4714 .call = parse_vc_conf,
4716 [ACTION_SET_TAG_MASK] = {
4718 .help = "mask for tag value",
4719 .next = NEXT(action_set_tag, NEXT_ENTRY(COMMON_UNSIGNED)),
4720 .args = ARGS(ARGS_ENTRY
4721 (struct rte_flow_action_set_tag, mask)),
4722 .call = parse_vc_conf,
4724 [ACTION_SET_META] = {
4726 .help = "set metadata",
4727 .priv = PRIV_ACTION(SET_META,
4728 sizeof(struct rte_flow_action_set_meta)),
4729 .next = NEXT(action_set_meta),
4730 .call = parse_vc_action_set_meta,
4732 [ACTION_SET_META_DATA] = {
4734 .help = "metadata value",
4735 .next = NEXT(action_set_meta, NEXT_ENTRY(COMMON_UNSIGNED)),
4736 .args = ARGS(ARGS_ENTRY
4737 (struct rte_flow_action_set_meta, data)),
4738 .call = parse_vc_conf,
4740 [ACTION_SET_META_MASK] = {
4742 .help = "mask for metadata value",
4743 .next = NEXT(action_set_meta, NEXT_ENTRY(COMMON_UNSIGNED)),
4744 .args = ARGS(ARGS_ENTRY
4745 (struct rte_flow_action_set_meta, mask)),
4746 .call = parse_vc_conf,
4748 [ACTION_SET_IPV4_DSCP] = {
4749 .name = "set_ipv4_dscp",
4750 .help = "set DSCP value",
4751 .priv = PRIV_ACTION(SET_IPV4_DSCP,
4752 sizeof(struct rte_flow_action_set_dscp)),
4753 .next = NEXT(action_set_ipv4_dscp),
4756 [ACTION_SET_IPV4_DSCP_VALUE] = {
4757 .name = "dscp_value",
4758 .help = "new IPv4 DSCP value to set",
4759 .next = NEXT(action_set_ipv4_dscp, NEXT_ENTRY(COMMON_UNSIGNED)),
4760 .args = ARGS(ARGS_ENTRY
4761 (struct rte_flow_action_set_dscp, dscp)),
4762 .call = parse_vc_conf,
4764 [ACTION_SET_IPV6_DSCP] = {
4765 .name = "set_ipv6_dscp",
4766 .help = "set DSCP value",
4767 .priv = PRIV_ACTION(SET_IPV6_DSCP,
4768 sizeof(struct rte_flow_action_set_dscp)),
4769 .next = NEXT(action_set_ipv6_dscp),
4772 [ACTION_SET_IPV6_DSCP_VALUE] = {
4773 .name = "dscp_value",
4774 .help = "new IPv6 DSCP value to set",
4775 .next = NEXT(action_set_ipv6_dscp, NEXT_ENTRY(COMMON_UNSIGNED)),
4776 .args = ARGS(ARGS_ENTRY
4777 (struct rte_flow_action_set_dscp, dscp)),
4778 .call = parse_vc_conf,
4782 .help = "set a specific metadata header",
4783 .next = NEXT(action_age),
4784 .priv = PRIV_ACTION(AGE,
4785 sizeof(struct rte_flow_action_age)),
4788 [ACTION_AGE_TIMEOUT] = {
4790 .help = "flow age timeout value",
4791 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_age,
4793 .next = NEXT(action_age, NEXT_ENTRY(COMMON_UNSIGNED)),
4794 .call = parse_vc_conf,
4798 .help = "set a sample action",
4799 .next = NEXT(action_sample),
4800 .priv = PRIV_ACTION(SAMPLE,
4801 sizeof(struct action_sample_data)),
4802 .call = parse_vc_action_sample,
4804 [ACTION_SAMPLE_RATIO] = {
4806 .help = "flow sample ratio value",
4807 .next = NEXT(action_sample, NEXT_ENTRY(COMMON_UNSIGNED)),
4808 .args = ARGS(ARGS_ENTRY_ARB
4809 (offsetof(struct action_sample_data, conf) +
4810 offsetof(struct rte_flow_action_sample, ratio),
4811 sizeof(((struct rte_flow_action_sample *)0)->
4814 [ACTION_SAMPLE_INDEX] = {
4816 .help = "the index of sample actions list",
4817 .next = NEXT(NEXT_ENTRY(ACTION_SAMPLE_INDEX_VALUE)),
4819 [ACTION_SAMPLE_INDEX_VALUE] = {
4821 .type = "COMMON_UNSIGNED",
4822 .help = "unsigned integer value",
4823 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4824 .call = parse_vc_action_sample_index,
4825 .comp = comp_set_sample_index,
4827 [ACTION_CONNTRACK] = {
4828 .name = "conntrack",
4829 .help = "create a conntrack object",
4830 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4831 .priv = PRIV_ACTION(CONNTRACK,
4832 sizeof(struct rte_flow_action_conntrack)),
4835 [ACTION_CONNTRACK_UPDATE] = {
4836 .name = "conntrack_update",
4837 .help = "update a conntrack object",
4838 .next = NEXT(action_update_conntrack),
4839 .priv = PRIV_ACTION(CONNTRACK,
4840 sizeof(struct rte_flow_modify_conntrack)),
4843 [ACTION_CONNTRACK_UPDATE_DIR] = {
4845 .help = "update a conntrack object direction",
4846 .next = NEXT(action_update_conntrack),
4847 .call = parse_vc_action_conntrack_update,
4849 [ACTION_CONNTRACK_UPDATE_CTX] = {
4851 .help = "update a conntrack object context",
4852 .next = NEXT(action_update_conntrack),
4853 .call = parse_vc_action_conntrack_update,
4855 [ACTION_PORT_REPRESENTOR] = {
4856 .name = "port_representor",
4857 .help = "at embedded switch level, send matching traffic to the given ethdev",
4858 .priv = PRIV_ACTION(PORT_REPRESENTOR,
4859 sizeof(struct rte_flow_action_ethdev)),
4860 .next = NEXT(action_port_representor),
4863 [ACTION_PORT_REPRESENTOR_PORT_ID] = {
4865 .help = "ethdev port ID",
4866 .next = NEXT(action_port_representor,
4867 NEXT_ENTRY(COMMON_UNSIGNED)),
4868 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_ethdev,
4870 .call = parse_vc_conf,
4872 [ACTION_REPRESENTED_PORT] = {
4873 .name = "represented_port",
4874 .help = "at embedded switch level, send matching traffic to the entity represented by the given ethdev",
4875 .priv = PRIV_ACTION(REPRESENTED_PORT,
4876 sizeof(struct rte_flow_action_ethdev)),
4877 .next = NEXT(action_represented_port),
4880 [ACTION_REPRESENTED_PORT_ETHDEV_PORT_ID] = {
4881 .name = "ethdev_port_id",
4882 .help = "ethdev port ID",
4883 .next = NEXT(action_represented_port,
4884 NEXT_ENTRY(COMMON_UNSIGNED)),
4885 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_ethdev,
4887 .call = parse_vc_conf,
4889 /* Indirect action destroy arguments. */
4890 [INDIRECT_ACTION_DESTROY_ID] = {
4891 .name = "action_id",
4892 .help = "specify a indirect action id to destroy",
4893 .next = NEXT(next_ia_destroy_attr,
4894 NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
4895 .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
4896 args.ia_destroy.action_id)),
4897 .call = parse_ia_destroy,
4899 /* Indirect action create arguments. */
4900 [INDIRECT_ACTION_CREATE_ID] = {
4901 .name = "action_id",
4902 .help = "specify a indirect action id to create",
4903 .next = NEXT(next_ia_create_attr,
4904 NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
4905 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
4907 [ACTION_INDIRECT] = {
4909 .help = "apply indirect action by id",
4910 .priv = PRIV_ACTION(INDIRECT, 0),
4911 .next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_ID2PTR)),
4912 .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
4915 [INDIRECT_ACTION_ID2PTR] = {
4916 .name = "{action_id}",
4917 .type = "INDIRECT_ACTION_ID",
4918 .help = "indirect action id",
4919 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4920 .call = parse_ia_id2ptr,
4923 [INDIRECT_ACTION_INGRESS] = {
4925 .help = "affect rule to ingress",
4926 .next = NEXT(next_ia_create_attr),
4929 [INDIRECT_ACTION_EGRESS] = {
4931 .help = "affect rule to egress",
4932 .next = NEXT(next_ia_create_attr),
4935 [INDIRECT_ACTION_TRANSFER] = {
4937 .help = "affect rule to transfer",
4938 .next = NEXT(next_ia_create_attr),
4941 [INDIRECT_ACTION_SPEC] = {
4943 .help = "specify action to create indirect handle",
4944 .next = NEXT(next_action),
4947 .name = "g_actions",
4948 .help = "submit a list of associated actions for green",
4949 .next = NEXT(next_action),
4953 .name = "y_actions",
4954 .help = "submit a list of associated actions for yellow",
4955 .next = NEXT(next_action),
4958 .name = "r_actions",
4959 .help = "submit a list of associated actions for red",
4960 .next = NEXT(next_action),
4963 /* Top-level command. */
4966 .type = "port meter policy {port_id} {arg}",
4967 .help = "add port meter policy",
4968 .next = NEXT(NEXT_ENTRY(ITEM_POL_PORT)),
4971 /* Sub-level commands. */
4974 .help = "add port meter policy",
4975 .next = NEXT(NEXT_ENTRY(ITEM_POL_METER)),
4977 [ITEM_POL_METER] = {
4979 .help = "add port meter policy",
4980 .next = NEXT(NEXT_ENTRY(ITEM_POL_POLICY)),
4982 [ITEM_POL_POLICY] = {
4984 .help = "add port meter policy",
4985 .next = NEXT(NEXT_ENTRY(ACTION_POL_R),
4986 NEXT_ENTRY(ACTION_POL_Y),
4987 NEXT_ENTRY(ACTION_POL_G),
4988 NEXT_ENTRY(COMMON_POLICY_ID),
4989 NEXT_ENTRY(COMMON_PORT_ID)),
4990 .args = ARGS(ARGS_ENTRY(struct buffer, args.policy.policy_id),
4991 ARGS_ENTRY(struct buffer, port)),
4996 /** Remove and return last entry from argument stack. */
4997 static const struct arg *
4998 pop_args(struct context *ctx)
5000 return ctx->args_num ? ctx->args[--ctx->args_num] : NULL;
5003 /** Add entry on top of the argument stack. */
5005 push_args(struct context *ctx, const struct arg *arg)
5007 if (ctx->args_num == CTX_STACK_SIZE)
5009 ctx->args[ctx->args_num++] = arg;
5013 /** Spread value into buffer according to bit-mask. */
5015 arg_entry_bf_fill(void *dst, uintmax_t val, const struct arg *arg)
5017 uint32_t i = arg->size;
5025 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
5034 unsigned int shift = 0;
5035 uint8_t *buf = (uint8_t *)dst + arg->offset + (i -= sub);
5037 for (shift = 0; arg->mask[i] >> shift; ++shift) {
5038 if (!(arg->mask[i] & (1 << shift)))
5043 *buf &= ~(1 << shift);
5044 *buf |= (val & 1) << shift;
5052 /** Compare a string with a partial one of a given length. */
5054 strcmp_partial(const char *full, const char *partial, size_t partial_len)
5056 int r = strncmp(full, partial, partial_len);
5060 if (strlen(full) <= partial_len)
5062 return full[partial_len];
5066 * Parse a prefix length and generate a bit-mask.
5068 * Last argument (ctx->args) is retrieved to determine mask size, storage
5069 * location and whether the result must use network byte ordering.
5072 parse_prefix(struct context *ctx, const struct token *token,
5073 const char *str, unsigned int len,
5074 void *buf, unsigned int size)
5076 const struct arg *arg = pop_args(ctx);
5077 static const uint8_t conv[] = "\x00\x80\xc0\xe0\xf0\xf8\xfc\xfe\xff";
5084 /* Argument is expected. */
5088 u = strtoumax(str, &end, 0);
5089 if (errno || (size_t)(end - str) != len)
5094 extra = arg_entry_bf_fill(NULL, 0, arg);
5103 if (!arg_entry_bf_fill(ctx->object, v, arg) ||
5104 !arg_entry_bf_fill(ctx->objmask, -1, arg))
5111 if (bytes > size || bytes + !!extra > size)
5115 buf = (uint8_t *)ctx->object + arg->offset;
5116 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
5118 memset((uint8_t *)buf + size - bytes, 0xff, bytes);
5119 memset(buf, 0x00, size - bytes);
5121 ((uint8_t *)buf)[size - bytes - 1] = conv[extra];
5125 memset(buf, 0xff, bytes);
5126 memset((uint8_t *)buf + bytes, 0x00, size - bytes);
5128 ((uint8_t *)buf)[bytes] = conv[extra];
5131 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
5134 push_args(ctx, arg);
5138 /** Default parsing function for token name matching. */
5140 parse_default(struct context *ctx, const struct token *token,
5141 const char *str, unsigned int len,
5142 void *buf, unsigned int size)
5147 if (strcmp_partial(token->name, str, len))
5152 /** Parse flow command, initialize output buffer for subsequent tokens. */
5154 parse_init(struct context *ctx, const struct token *token,
5155 const char *str, unsigned int len,
5156 void *buf, unsigned int size)
5158 struct buffer *out = buf;
5160 /* Token name must match. */
5161 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5163 /* Nothing else to do if there is no buffer. */
5166 /* Make sure buffer is large enough. */
5167 if (size < sizeof(*out))
5169 /* Initialize buffer. */
5170 memset(out, 0x00, sizeof(*out));
5171 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
5174 ctx->objmask = NULL;
5178 /** Parse tokens for indirect action commands. */
5180 parse_ia(struct context *ctx, const struct token *token,
5181 const char *str, unsigned int len,
5182 void *buf, unsigned int size)
5184 struct buffer *out = buf;
5186 /* Token name must match. */
5187 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5189 /* Nothing else to do if there is no buffer. */
5192 if (!out->command) {
5193 if (ctx->curr != INDIRECT_ACTION)
5195 if (sizeof(*out) > size)
5197 out->command = ctx->curr;
5200 ctx->objmask = NULL;
5201 out->args.vc.data = (uint8_t *)out + size;
5204 switch (ctx->curr) {
5205 case INDIRECT_ACTION_CREATE:
5206 case INDIRECT_ACTION_UPDATE:
5207 out->args.vc.actions =
5208 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5210 out->args.vc.attr.group = UINT32_MAX;
5212 case INDIRECT_ACTION_QUERY:
5213 out->command = ctx->curr;
5216 ctx->objmask = NULL;
5218 case INDIRECT_ACTION_EGRESS:
5219 out->args.vc.attr.egress = 1;
5221 case INDIRECT_ACTION_INGRESS:
5222 out->args.vc.attr.ingress = 1;
5224 case INDIRECT_ACTION_TRANSFER:
5225 out->args.vc.attr.transfer = 1;
5233 /** Parse tokens for indirect action destroy command. */
5235 parse_ia_destroy(struct context *ctx, const struct token *token,
5236 const char *str, unsigned int len,
5237 void *buf, unsigned int size)
5239 struct buffer *out = buf;
5240 uint32_t *action_id;
5242 /* Token name must match. */
5243 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5245 /* Nothing else to do if there is no buffer. */
5248 if (!out->command || out->command == INDIRECT_ACTION) {
5249 if (ctx->curr != INDIRECT_ACTION_DESTROY)
5251 if (sizeof(*out) > size)
5253 out->command = ctx->curr;
5256 ctx->objmask = NULL;
5257 out->args.ia_destroy.action_id =
5258 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5262 action_id = out->args.ia_destroy.action_id
5263 + out->args.ia_destroy.action_id_n++;
5264 if ((uint8_t *)action_id > (uint8_t *)out + size)
5267 ctx->object = action_id;
5268 ctx->objmask = NULL;
5272 /** Parse tokens for meter policy action commands. */
5274 parse_mp(struct context *ctx, const struct token *token,
5275 const char *str, unsigned int len,
5276 void *buf, unsigned int size)
5278 struct buffer *out = buf;
5280 /* Token name must match. */
5281 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5283 /* Nothing else to do if there is no buffer. */
5286 if (!out->command) {
5287 if (ctx->curr != ITEM_POL_POLICY)
5289 if (sizeof(*out) > size)
5291 out->command = ctx->curr;
5294 ctx->objmask = NULL;
5295 out->args.vc.data = (uint8_t *)out + size;
5298 switch (ctx->curr) {
5300 out->args.vc.actions =
5301 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5303 out->command = ctx->curr;
5306 ctx->objmask = NULL;
5313 /** Parse tokens for validate/create commands. */
5315 parse_vc(struct context *ctx, const struct token *token,
5316 const char *str, unsigned int len,
5317 void *buf, unsigned int size)
5319 struct buffer *out = buf;
5323 /* Token name must match. */
5324 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5326 /* Nothing else to do if there is no buffer. */
5329 if (!out->command) {
5330 if (ctx->curr != VALIDATE && ctx->curr != CREATE)
5332 if (sizeof(*out) > size)
5334 out->command = ctx->curr;
5337 ctx->objmask = NULL;
5338 out->args.vc.data = (uint8_t *)out + size;
5342 switch (ctx->curr) {
5344 ctx->object = &out->args.vc.attr;
5347 case VC_TUNNEL_MATCH:
5348 ctx->object = &out->args.vc.tunnel_ops;
5351 ctx->objmask = NULL;
5352 switch (ctx->curr) {
5357 out->args.vc.tunnel_ops.enabled = 1;
5358 out->args.vc.tunnel_ops.actions = 1;
5360 case VC_TUNNEL_MATCH:
5361 out->args.vc.tunnel_ops.enabled = 1;
5362 out->args.vc.tunnel_ops.items = 1;
5365 out->args.vc.attr.ingress = 1;
5368 out->args.vc.attr.egress = 1;
5371 out->args.vc.attr.transfer = 1;
5374 out->args.vc.pattern =
5375 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5377 ctx->object = out->args.vc.pattern;
5378 ctx->objmask = NULL;
5381 out->args.vc.actions =
5382 (void *)RTE_ALIGN_CEIL((uintptr_t)
5383 (out->args.vc.pattern +
5384 out->args.vc.pattern_n),
5386 ctx->object = out->args.vc.actions;
5387 ctx->objmask = NULL;
5394 if (!out->args.vc.actions) {
5395 const struct parse_item_priv *priv = token->priv;
5396 struct rte_flow_item *item =
5397 out->args.vc.pattern + out->args.vc.pattern_n;
5399 data_size = priv->size * 3; /* spec, last, mask */
5400 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
5401 (out->args.vc.data - data_size),
5403 if ((uint8_t *)item + sizeof(*item) > data)
5405 *item = (struct rte_flow_item){
5408 ++out->args.vc.pattern_n;
5410 ctx->objmask = NULL;
5412 const struct parse_action_priv *priv = token->priv;
5413 struct rte_flow_action *action =
5414 out->args.vc.actions + out->args.vc.actions_n;
5416 data_size = priv->size; /* configuration */
5417 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
5418 (out->args.vc.data - data_size),
5420 if ((uint8_t *)action + sizeof(*action) > data)
5422 *action = (struct rte_flow_action){
5424 .conf = data_size ? data : NULL,
5426 ++out->args.vc.actions_n;
5427 ctx->object = action;
5428 ctx->objmask = NULL;
5430 memset(data, 0, data_size);
5431 out->args.vc.data = data;
5432 ctx->objdata = data_size;
5436 /** Parse pattern item parameter type. */
5438 parse_vc_spec(struct context *ctx, const struct token *token,
5439 const char *str, unsigned int len,
5440 void *buf, unsigned int size)
5442 struct buffer *out = buf;
5443 struct rte_flow_item *item;
5449 /* Token name must match. */
5450 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5452 /* Parse parameter types. */
5453 switch (ctx->curr) {
5454 static const enum index prefix[] = NEXT_ENTRY(COMMON_PREFIX);
5460 case ITEM_PARAM_SPEC:
5463 case ITEM_PARAM_LAST:
5466 case ITEM_PARAM_PREFIX:
5467 /* Modify next token to expect a prefix. */
5468 if (ctx->next_num < 2)
5470 ctx->next[ctx->next_num - 2] = prefix;
5472 case ITEM_PARAM_MASK:
5478 /* Nothing else to do if there is no buffer. */
5481 if (!out->args.vc.pattern_n)
5483 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
5484 data_size = ctx->objdata / 3; /* spec, last, mask */
5485 /* Point to selected object. */
5486 ctx->object = out->args.vc.data + (data_size * index);
5488 ctx->objmask = out->args.vc.data + (data_size * 2); /* mask */
5489 item->mask = ctx->objmask;
5491 ctx->objmask = NULL;
5492 /* Update relevant item pointer. */
5493 *((const void **[]){ &item->spec, &item->last, &item->mask })[index] =
5498 /** Parse action configuration field. */
5500 parse_vc_conf(struct context *ctx, const struct token *token,
5501 const char *str, unsigned int len,
5502 void *buf, unsigned int size)
5504 struct buffer *out = buf;
5507 /* Token name must match. */
5508 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5510 /* Nothing else to do if there is no buffer. */
5513 /* Point to selected object. */
5514 ctx->object = out->args.vc.data;
5515 ctx->objmask = NULL;
5519 /** Parse eCPRI common header type field. */
5521 parse_vc_item_ecpri_type(struct context *ctx, const struct token *token,
5522 const char *str, unsigned int len,
5523 void *buf, unsigned int size)
5525 struct rte_flow_item_ecpri *ecpri;
5526 struct rte_flow_item_ecpri *ecpri_mask;
5527 struct rte_flow_item *item;
5530 struct buffer *out = buf;
5531 const struct arg *arg;
5534 /* Token name must match. */
5535 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5537 switch (ctx->curr) {
5538 case ITEM_ECPRI_COMMON_TYPE_IQ_DATA:
5539 msg_type = RTE_ECPRI_MSG_TYPE_IQ_DATA;
5541 case ITEM_ECPRI_COMMON_TYPE_RTC_CTRL:
5542 msg_type = RTE_ECPRI_MSG_TYPE_RTC_CTRL;
5544 case ITEM_ECPRI_COMMON_TYPE_DLY_MSR:
5545 msg_type = RTE_ECPRI_MSG_TYPE_DLY_MSR;
5552 arg = pop_args(ctx);
5555 ecpri = (struct rte_flow_item_ecpri *)out->args.vc.data;
5556 ecpri->hdr.common.type = msg_type;
5557 data_size = ctx->objdata / 3; /* spec, last, mask */
5558 ecpri_mask = (struct rte_flow_item_ecpri *)(out->args.vc.data +
5560 ecpri_mask->hdr.common.type = 0xFF;
5562 ecpri->hdr.common.u32 = rte_cpu_to_be_32(ecpri->hdr.common.u32);
5563 ecpri_mask->hdr.common.u32 =
5564 rte_cpu_to_be_32(ecpri_mask->hdr.common.u32);
5566 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
5568 item->mask = ecpri_mask;
5572 /** Parse meter color action type. */
5574 parse_vc_action_meter_color_type(struct context *ctx, const struct token *token,
5575 const char *str, unsigned int len,
5576 void *buf, unsigned int size)
5578 struct rte_flow_action *action_data;
5579 struct rte_flow_action_meter_color *conf;
5580 enum rte_color color;
5584 /* Token name must match. */
5585 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5587 switch (ctx->curr) {
5588 case ACTION_METER_COLOR_GREEN:
5589 color = RTE_COLOR_GREEN;
5591 case ACTION_METER_COLOR_YELLOW:
5592 color = RTE_COLOR_YELLOW;
5594 case ACTION_METER_COLOR_RED:
5595 color = RTE_COLOR_RED;
5603 action_data = ctx->object;
5604 conf = (struct rte_flow_action_meter_color *)
5605 (uintptr_t)(action_data->conf);
5606 conf->color = color;
5610 /** Parse RSS action. */
5612 parse_vc_action_rss(struct context *ctx, const struct token *token,
5613 const char *str, unsigned int len,
5614 void *buf, unsigned int size)
5616 struct buffer *out = buf;
5617 struct rte_flow_action *action;
5618 struct action_rss_data *action_rss_data;
5622 ret = parse_vc(ctx, token, str, len, buf, size);
5625 /* Nothing else to do if there is no buffer. */
5628 if (!out->args.vc.actions_n)
5630 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5631 /* Point to selected object. */
5632 ctx->object = out->args.vc.data;
5633 ctx->objmask = NULL;
5634 /* Set up default configuration. */
5635 action_rss_data = ctx->object;
5636 *action_rss_data = (struct action_rss_data){
5637 .conf = (struct rte_flow_action_rss){
5638 .func = RTE_ETH_HASH_FUNCTION_DEFAULT,
5642 .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM),
5644 .queue = action_rss_data->queue,
5648 for (i = 0; i < action_rss_data->conf.queue_num; ++i)
5649 action_rss_data->queue[i] = i;
5650 action->conf = &action_rss_data->conf;
5655 * Parse func field for RSS action.
5657 * The RTE_ETH_HASH_FUNCTION_* value to assign is derived from the
5658 * ACTION_RSS_FUNC_* index that called this function.
5661 parse_vc_action_rss_func(struct context *ctx, const struct token *token,
5662 const char *str, unsigned int len,
5663 void *buf, unsigned int size)
5665 struct action_rss_data *action_rss_data;
5666 enum rte_eth_hash_function func;
5670 /* Token name must match. */
5671 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5673 switch (ctx->curr) {
5674 case ACTION_RSS_FUNC_DEFAULT:
5675 func = RTE_ETH_HASH_FUNCTION_DEFAULT;
5677 case ACTION_RSS_FUNC_TOEPLITZ:
5678 func = RTE_ETH_HASH_FUNCTION_TOEPLITZ;
5680 case ACTION_RSS_FUNC_SIMPLE_XOR:
5681 func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
5683 case ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ:
5684 func = RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
5691 action_rss_data = ctx->object;
5692 action_rss_data->conf.func = func;
5697 * Parse type field for RSS action.
5699 * Valid tokens are type field names and the "end" token.
5702 parse_vc_action_rss_type(struct context *ctx, const struct token *token,
5703 const char *str, unsigned int len,
5704 void *buf, unsigned int size)
5706 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE);
5707 struct action_rss_data *action_rss_data;
5713 if (ctx->curr != ACTION_RSS_TYPE)
5715 if (!(ctx->objdata >> 16) && ctx->object) {
5716 action_rss_data = ctx->object;
5717 action_rss_data->conf.types = 0;
5719 if (!strcmp_partial("end", str, len)) {
5720 ctx->objdata &= 0xffff;
5723 for (i = 0; rss_type_table[i].str; ++i)
5724 if (!strcmp_partial(rss_type_table[i].str, str, len))
5726 if (!rss_type_table[i].str)
5728 ctx->objdata = 1 << 16 | (ctx->objdata & 0xffff);
5730 if (ctx->next_num == RTE_DIM(ctx->next))
5732 ctx->next[ctx->next_num++] = next;
5735 action_rss_data = ctx->object;
5736 action_rss_data->conf.types |= rss_type_table[i].rss_type;
5741 * Parse queue field for RSS action.
5743 * Valid tokens are queue indices and the "end" token.
5746 parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
5747 const char *str, unsigned int len,
5748 void *buf, unsigned int size)
5750 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE);
5751 struct action_rss_data *action_rss_data;
5752 const struct arg *arg;
5759 if (ctx->curr != ACTION_RSS_QUEUE)
5761 i = ctx->objdata >> 16;
5762 if (!strcmp_partial("end", str, len)) {
5763 ctx->objdata &= 0xffff;
5766 if (i >= ACTION_RSS_QUEUE_NUM)
5768 arg = ARGS_ENTRY_ARB(offsetof(struct action_rss_data, queue) +
5769 i * sizeof(action_rss_data->queue[i]),
5770 sizeof(action_rss_data->queue[i]));
5771 if (push_args(ctx, arg))
5773 ret = parse_int(ctx, token, str, len, NULL, 0);
5779 ctx->objdata = i << 16 | (ctx->objdata & 0xffff);
5781 if (ctx->next_num == RTE_DIM(ctx->next))
5783 ctx->next[ctx->next_num++] = next;
5787 action_rss_data = ctx->object;
5788 action_rss_data->conf.queue_num = i;
5789 action_rss_data->conf.queue = i ? action_rss_data->queue : NULL;
5793 /** Setup VXLAN encap configuration. */
5795 parse_setup_vxlan_encap_data(struct action_vxlan_encap_data *action_vxlan_encap_data)
5797 /* Set up default configuration. */
5798 *action_vxlan_encap_data = (struct action_vxlan_encap_data){
5799 .conf = (struct rte_flow_action_vxlan_encap){
5800 .definition = action_vxlan_encap_data->items,
5804 .type = RTE_FLOW_ITEM_TYPE_ETH,
5805 .spec = &action_vxlan_encap_data->item_eth,
5806 .mask = &rte_flow_item_eth_mask,
5809 .type = RTE_FLOW_ITEM_TYPE_VLAN,
5810 .spec = &action_vxlan_encap_data->item_vlan,
5811 .mask = &rte_flow_item_vlan_mask,
5814 .type = RTE_FLOW_ITEM_TYPE_IPV4,
5815 .spec = &action_vxlan_encap_data->item_ipv4,
5816 .mask = &rte_flow_item_ipv4_mask,
5819 .type = RTE_FLOW_ITEM_TYPE_UDP,
5820 .spec = &action_vxlan_encap_data->item_udp,
5821 .mask = &rte_flow_item_udp_mask,
5824 .type = RTE_FLOW_ITEM_TYPE_VXLAN,
5825 .spec = &action_vxlan_encap_data->item_vxlan,
5826 .mask = &rte_flow_item_vxlan_mask,
5829 .type = RTE_FLOW_ITEM_TYPE_END,
5834 .tci = vxlan_encap_conf.vlan_tci,
5838 .src_addr = vxlan_encap_conf.ipv4_src,
5839 .dst_addr = vxlan_encap_conf.ipv4_dst,
5842 .src_port = vxlan_encap_conf.udp_src,
5843 .dst_port = vxlan_encap_conf.udp_dst,
5845 .item_vxlan.flags = 0,
5847 memcpy(action_vxlan_encap_data->item_eth.dst.addr_bytes,
5848 vxlan_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5849 memcpy(action_vxlan_encap_data->item_eth.src.addr_bytes,
5850 vxlan_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5851 if (!vxlan_encap_conf.select_ipv4) {
5852 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.src_addr,
5853 &vxlan_encap_conf.ipv6_src,
5854 sizeof(vxlan_encap_conf.ipv6_src));
5855 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.dst_addr,
5856 &vxlan_encap_conf.ipv6_dst,
5857 sizeof(vxlan_encap_conf.ipv6_dst));
5858 action_vxlan_encap_data->items[2] = (struct rte_flow_item){
5859 .type = RTE_FLOW_ITEM_TYPE_IPV6,
5860 .spec = &action_vxlan_encap_data->item_ipv6,
5861 .mask = &rte_flow_item_ipv6_mask,
5864 if (!vxlan_encap_conf.select_vlan)
5865 action_vxlan_encap_data->items[1].type =
5866 RTE_FLOW_ITEM_TYPE_VOID;
5867 if (vxlan_encap_conf.select_tos_ttl) {
5868 if (vxlan_encap_conf.select_ipv4) {
5869 static struct rte_flow_item_ipv4 ipv4_mask_tos;
5871 memcpy(&ipv4_mask_tos, &rte_flow_item_ipv4_mask,
5872 sizeof(ipv4_mask_tos));
5873 ipv4_mask_tos.hdr.type_of_service = 0xff;
5874 ipv4_mask_tos.hdr.time_to_live = 0xff;
5875 action_vxlan_encap_data->item_ipv4.hdr.type_of_service =
5876 vxlan_encap_conf.ip_tos;
5877 action_vxlan_encap_data->item_ipv4.hdr.time_to_live =
5878 vxlan_encap_conf.ip_ttl;
5879 action_vxlan_encap_data->items[2].mask =
5882 static struct rte_flow_item_ipv6 ipv6_mask_tos;
5884 memcpy(&ipv6_mask_tos, &rte_flow_item_ipv6_mask,
5885 sizeof(ipv6_mask_tos));
5886 ipv6_mask_tos.hdr.vtc_flow |=
5887 RTE_BE32(0xfful << RTE_IPV6_HDR_TC_SHIFT);
5888 ipv6_mask_tos.hdr.hop_limits = 0xff;
5889 action_vxlan_encap_data->item_ipv6.hdr.vtc_flow |=
5891 ((uint32_t)vxlan_encap_conf.ip_tos <<
5892 RTE_IPV6_HDR_TC_SHIFT);
5893 action_vxlan_encap_data->item_ipv6.hdr.hop_limits =
5894 vxlan_encap_conf.ip_ttl;
5895 action_vxlan_encap_data->items[2].mask =
5899 memcpy(action_vxlan_encap_data->item_vxlan.vni, vxlan_encap_conf.vni,
5900 RTE_DIM(vxlan_encap_conf.vni));
5904 /** Parse VXLAN encap action. */
5906 parse_vc_action_vxlan_encap(struct context *ctx, const struct token *token,
5907 const char *str, unsigned int len,
5908 void *buf, unsigned int size)
5910 struct buffer *out = buf;
5911 struct rte_flow_action *action;
5912 struct action_vxlan_encap_data *action_vxlan_encap_data;
5915 ret = parse_vc(ctx, token, str, len, buf, size);
5918 /* Nothing else to do if there is no buffer. */
5921 if (!out->args.vc.actions_n)
5923 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5924 /* Point to selected object. */
5925 ctx->object = out->args.vc.data;
5926 ctx->objmask = NULL;
5927 action_vxlan_encap_data = ctx->object;
5928 parse_setup_vxlan_encap_data(action_vxlan_encap_data);
5929 action->conf = &action_vxlan_encap_data->conf;
5933 /** Setup NVGRE encap configuration. */
5935 parse_setup_nvgre_encap_data(struct action_nvgre_encap_data *action_nvgre_encap_data)
5937 /* Set up default configuration. */
5938 *action_nvgre_encap_data = (struct action_nvgre_encap_data){
5939 .conf = (struct rte_flow_action_nvgre_encap){
5940 .definition = action_nvgre_encap_data->items,
5944 .type = RTE_FLOW_ITEM_TYPE_ETH,
5945 .spec = &action_nvgre_encap_data->item_eth,
5946 .mask = &rte_flow_item_eth_mask,
5949 .type = RTE_FLOW_ITEM_TYPE_VLAN,
5950 .spec = &action_nvgre_encap_data->item_vlan,
5951 .mask = &rte_flow_item_vlan_mask,
5954 .type = RTE_FLOW_ITEM_TYPE_IPV4,
5955 .spec = &action_nvgre_encap_data->item_ipv4,
5956 .mask = &rte_flow_item_ipv4_mask,
5959 .type = RTE_FLOW_ITEM_TYPE_NVGRE,
5960 .spec = &action_nvgre_encap_data->item_nvgre,
5961 .mask = &rte_flow_item_nvgre_mask,
5964 .type = RTE_FLOW_ITEM_TYPE_END,
5969 .tci = nvgre_encap_conf.vlan_tci,
5973 .src_addr = nvgre_encap_conf.ipv4_src,
5974 .dst_addr = nvgre_encap_conf.ipv4_dst,
5976 .item_nvgre.c_k_s_rsvd0_ver = RTE_BE16(0x2000),
5977 .item_nvgre.protocol = RTE_BE16(RTE_ETHER_TYPE_TEB),
5978 .item_nvgre.flow_id = 0,
5980 memcpy(action_nvgre_encap_data->item_eth.dst.addr_bytes,
5981 nvgre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5982 memcpy(action_nvgre_encap_data->item_eth.src.addr_bytes,
5983 nvgre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5984 if (!nvgre_encap_conf.select_ipv4) {
5985 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.src_addr,
5986 &nvgre_encap_conf.ipv6_src,
5987 sizeof(nvgre_encap_conf.ipv6_src));
5988 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.dst_addr,
5989 &nvgre_encap_conf.ipv6_dst,
5990 sizeof(nvgre_encap_conf.ipv6_dst));
5991 action_nvgre_encap_data->items[2] = (struct rte_flow_item){
5992 .type = RTE_FLOW_ITEM_TYPE_IPV6,
5993 .spec = &action_nvgre_encap_data->item_ipv6,
5994 .mask = &rte_flow_item_ipv6_mask,
5997 if (!nvgre_encap_conf.select_vlan)
5998 action_nvgre_encap_data->items[1].type =
5999 RTE_FLOW_ITEM_TYPE_VOID;
6000 memcpy(action_nvgre_encap_data->item_nvgre.tni, nvgre_encap_conf.tni,
6001 RTE_DIM(nvgre_encap_conf.tni));
6005 /** Parse NVGRE encap action. */
6007 parse_vc_action_nvgre_encap(struct context *ctx, const struct token *token,
6008 const char *str, unsigned int len,
6009 void *buf, unsigned int size)
6011 struct buffer *out = buf;
6012 struct rte_flow_action *action;
6013 struct action_nvgre_encap_data *action_nvgre_encap_data;
6016 ret = parse_vc(ctx, token, str, len, buf, size);
6019 /* Nothing else to do if there is no buffer. */
6022 if (!out->args.vc.actions_n)
6024 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6025 /* Point to selected object. */
6026 ctx->object = out->args.vc.data;
6027 ctx->objmask = NULL;
6028 action_nvgre_encap_data = ctx->object;
6029 parse_setup_nvgre_encap_data(action_nvgre_encap_data);
6030 action->conf = &action_nvgre_encap_data->conf;
6034 /** Parse l2 encap action. */
6036 parse_vc_action_l2_encap(struct context *ctx, const struct token *token,
6037 const char *str, unsigned int len,
6038 void *buf, unsigned int size)
6040 struct buffer *out = buf;
6041 struct rte_flow_action *action;
6042 struct action_raw_encap_data *action_encap_data;
6043 struct rte_flow_item_eth eth = { .type = 0, };
6044 struct rte_flow_item_vlan vlan = {
6045 .tci = mplsoudp_encap_conf.vlan_tci,
6051 ret = parse_vc(ctx, token, str, len, buf, size);
6054 /* Nothing else to do if there is no buffer. */
6057 if (!out->args.vc.actions_n)
6059 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6060 /* Point to selected object. */
6061 ctx->object = out->args.vc.data;
6062 ctx->objmask = NULL;
6063 /* Copy the headers to the buffer. */
6064 action_encap_data = ctx->object;
6065 *action_encap_data = (struct action_raw_encap_data) {
6066 .conf = (struct rte_flow_action_raw_encap){
6067 .data = action_encap_data->data,
6071 header = action_encap_data->data;
6072 if (l2_encap_conf.select_vlan)
6073 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
6074 else if (l2_encap_conf.select_ipv4)
6075 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6077 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6078 memcpy(eth.dst.addr_bytes,
6079 l2_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
6080 memcpy(eth.src.addr_bytes,
6081 l2_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
6082 memcpy(header, ð, sizeof(eth));
6083 header += sizeof(eth);
6084 if (l2_encap_conf.select_vlan) {
6085 if (l2_encap_conf.select_ipv4)
6086 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6088 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6089 memcpy(header, &vlan, sizeof(vlan));
6090 header += sizeof(vlan);
6092 action_encap_data->conf.size = header -
6093 action_encap_data->data;
6094 action->conf = &action_encap_data->conf;
6098 /** Parse l2 decap action. */
6100 parse_vc_action_l2_decap(struct context *ctx, const struct token *token,
6101 const char *str, unsigned int len,
6102 void *buf, unsigned int size)
6104 struct buffer *out = buf;
6105 struct rte_flow_action *action;
6106 struct action_raw_decap_data *action_decap_data;
6107 struct rte_flow_item_eth eth = { .type = 0, };
6108 struct rte_flow_item_vlan vlan = {
6109 .tci = mplsoudp_encap_conf.vlan_tci,
6115 ret = parse_vc(ctx, token, str, len, buf, size);
6118 /* Nothing else to do if there is no buffer. */
6121 if (!out->args.vc.actions_n)
6123 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6124 /* Point to selected object. */
6125 ctx->object = out->args.vc.data;
6126 ctx->objmask = NULL;
6127 /* Copy the headers to the buffer. */
6128 action_decap_data = ctx->object;
6129 *action_decap_data = (struct action_raw_decap_data) {
6130 .conf = (struct rte_flow_action_raw_decap){
6131 .data = action_decap_data->data,
6135 header = action_decap_data->data;
6136 if (l2_decap_conf.select_vlan)
6137 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
6138 memcpy(header, ð, sizeof(eth));
6139 header += sizeof(eth);
6140 if (l2_decap_conf.select_vlan) {
6141 memcpy(header, &vlan, sizeof(vlan));
6142 header += sizeof(vlan);
6144 action_decap_data->conf.size = header -
6145 action_decap_data->data;
6146 action->conf = &action_decap_data->conf;
6150 #define ETHER_TYPE_MPLS_UNICAST 0x8847
6152 /** Parse MPLSOGRE encap action. */
6154 parse_vc_action_mplsogre_encap(struct context *ctx, const struct token *token,
6155 const char *str, unsigned int len,
6156 void *buf, unsigned int size)
6158 struct buffer *out = buf;
6159 struct rte_flow_action *action;
6160 struct action_raw_encap_data *action_encap_data;
6161 struct rte_flow_item_eth eth = { .type = 0, };
6162 struct rte_flow_item_vlan vlan = {
6163 .tci = mplsogre_encap_conf.vlan_tci,
6166 struct rte_flow_item_ipv4 ipv4 = {
6168 .src_addr = mplsogre_encap_conf.ipv4_src,
6169 .dst_addr = mplsogre_encap_conf.ipv4_dst,
6170 .next_proto_id = IPPROTO_GRE,
6171 .version_ihl = RTE_IPV4_VHL_DEF,
6172 .time_to_live = IPDEFTTL,
6175 struct rte_flow_item_ipv6 ipv6 = {
6177 .proto = IPPROTO_GRE,
6178 .hop_limits = IPDEFTTL,
6181 struct rte_flow_item_gre gre = {
6182 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
6184 struct rte_flow_item_mpls mpls = {
6190 ret = parse_vc(ctx, token, str, len, buf, size);
6193 /* Nothing else to do if there is no buffer. */
6196 if (!out->args.vc.actions_n)
6198 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6199 /* Point to selected object. */
6200 ctx->object = out->args.vc.data;
6201 ctx->objmask = NULL;
6202 /* Copy the headers to the buffer. */
6203 action_encap_data = ctx->object;
6204 *action_encap_data = (struct action_raw_encap_data) {
6205 .conf = (struct rte_flow_action_raw_encap){
6206 .data = action_encap_data->data,
6211 header = action_encap_data->data;
6212 if (mplsogre_encap_conf.select_vlan)
6213 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
6214 else if (mplsogre_encap_conf.select_ipv4)
6215 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6217 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6218 memcpy(eth.dst.addr_bytes,
6219 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
6220 memcpy(eth.src.addr_bytes,
6221 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
6222 memcpy(header, ð, sizeof(eth));
6223 header += sizeof(eth);
6224 if (mplsogre_encap_conf.select_vlan) {
6225 if (mplsogre_encap_conf.select_ipv4)
6226 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6228 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6229 memcpy(header, &vlan, sizeof(vlan));
6230 header += sizeof(vlan);
6232 if (mplsogre_encap_conf.select_ipv4) {
6233 memcpy(header, &ipv4, sizeof(ipv4));
6234 header += sizeof(ipv4);
6236 memcpy(&ipv6.hdr.src_addr,
6237 &mplsogre_encap_conf.ipv6_src,
6238 sizeof(mplsogre_encap_conf.ipv6_src));
6239 memcpy(&ipv6.hdr.dst_addr,
6240 &mplsogre_encap_conf.ipv6_dst,
6241 sizeof(mplsogre_encap_conf.ipv6_dst));
6242 memcpy(header, &ipv6, sizeof(ipv6));
6243 header += sizeof(ipv6);
6245 memcpy(header, &gre, sizeof(gre));
6246 header += sizeof(gre);
6247 memcpy(mpls.label_tc_s, mplsogre_encap_conf.label,
6248 RTE_DIM(mplsogre_encap_conf.label));
6249 mpls.label_tc_s[2] |= 0x1;
6250 memcpy(header, &mpls, sizeof(mpls));
6251 header += sizeof(mpls);
6252 action_encap_data->conf.size = header -
6253 action_encap_data->data;
6254 action->conf = &action_encap_data->conf;
6258 /** Parse MPLSOGRE decap action. */
6260 parse_vc_action_mplsogre_decap(struct context *ctx, const struct token *token,
6261 const char *str, unsigned int len,
6262 void *buf, unsigned int size)
6264 struct buffer *out = buf;
6265 struct rte_flow_action *action;
6266 struct action_raw_decap_data *action_decap_data;
6267 struct rte_flow_item_eth eth = { .type = 0, };
6268 struct rte_flow_item_vlan vlan = {.tci = 0};
6269 struct rte_flow_item_ipv4 ipv4 = {
6271 .next_proto_id = IPPROTO_GRE,
6274 struct rte_flow_item_ipv6 ipv6 = {
6276 .proto = IPPROTO_GRE,
6279 struct rte_flow_item_gre gre = {
6280 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
6282 struct rte_flow_item_mpls mpls;
6286 ret = parse_vc(ctx, token, str, len, buf, size);
6289 /* Nothing else to do if there is no buffer. */
6292 if (!out->args.vc.actions_n)
6294 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6295 /* Point to selected object. */
6296 ctx->object = out->args.vc.data;
6297 ctx->objmask = NULL;
6298 /* Copy the headers to the buffer. */
6299 action_decap_data = ctx->object;
6300 *action_decap_data = (struct action_raw_decap_data) {
6301 .conf = (struct rte_flow_action_raw_decap){
6302 .data = action_decap_data->data,
6306 header = action_decap_data->data;
6307 if (mplsogre_decap_conf.select_vlan)
6308 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
6309 else if (mplsogre_encap_conf.select_ipv4)
6310 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6312 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6313 memcpy(eth.dst.addr_bytes,
6314 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
6315 memcpy(eth.src.addr_bytes,
6316 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
6317 memcpy(header, ð, sizeof(eth));
6318 header += sizeof(eth);
6319 if (mplsogre_encap_conf.select_vlan) {
6320 if (mplsogre_encap_conf.select_ipv4)
6321 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6323 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6324 memcpy(header, &vlan, sizeof(vlan));
6325 header += sizeof(vlan);
6327 if (mplsogre_encap_conf.select_ipv4) {
6328 memcpy(header, &ipv4, sizeof(ipv4));
6329 header += sizeof(ipv4);
6331 memcpy(header, &ipv6, sizeof(ipv6));
6332 header += sizeof(ipv6);
6334 memcpy(header, &gre, sizeof(gre));
6335 header += sizeof(gre);
6336 memset(&mpls, 0, sizeof(mpls));
6337 memcpy(header, &mpls, sizeof(mpls));
6338 header += sizeof(mpls);
6339 action_decap_data->conf.size = header -
6340 action_decap_data->data;
6341 action->conf = &action_decap_data->conf;
6345 /** Parse MPLSOUDP encap action. */
6347 parse_vc_action_mplsoudp_encap(struct context *ctx, const struct token *token,
6348 const char *str, unsigned int len,
6349 void *buf, unsigned int size)
6351 struct buffer *out = buf;
6352 struct rte_flow_action *action;
6353 struct action_raw_encap_data *action_encap_data;
6354 struct rte_flow_item_eth eth = { .type = 0, };
6355 struct rte_flow_item_vlan vlan = {
6356 .tci = mplsoudp_encap_conf.vlan_tci,
6359 struct rte_flow_item_ipv4 ipv4 = {
6361 .src_addr = mplsoudp_encap_conf.ipv4_src,
6362 .dst_addr = mplsoudp_encap_conf.ipv4_dst,
6363 .next_proto_id = IPPROTO_UDP,
6364 .version_ihl = RTE_IPV4_VHL_DEF,
6365 .time_to_live = IPDEFTTL,
6368 struct rte_flow_item_ipv6 ipv6 = {
6370 .proto = IPPROTO_UDP,
6371 .hop_limits = IPDEFTTL,
6374 struct rte_flow_item_udp udp = {
6376 .src_port = mplsoudp_encap_conf.udp_src,
6377 .dst_port = mplsoudp_encap_conf.udp_dst,
6380 struct rte_flow_item_mpls mpls;
6384 ret = parse_vc(ctx, token, str, len, buf, size);
6387 /* Nothing else to do if there is no buffer. */
6390 if (!out->args.vc.actions_n)
6392 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6393 /* Point to selected object. */
6394 ctx->object = out->args.vc.data;
6395 ctx->objmask = NULL;
6396 /* Copy the headers to the buffer. */
6397 action_encap_data = ctx->object;
6398 *action_encap_data = (struct action_raw_encap_data) {
6399 .conf = (struct rte_flow_action_raw_encap){
6400 .data = action_encap_data->data,
6405 header = action_encap_data->data;
6406 if (mplsoudp_encap_conf.select_vlan)
6407 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
6408 else if (mplsoudp_encap_conf.select_ipv4)
6409 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6411 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6412 memcpy(eth.dst.addr_bytes,
6413 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
6414 memcpy(eth.src.addr_bytes,
6415 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
6416 memcpy(header, ð, sizeof(eth));
6417 header += sizeof(eth);
6418 if (mplsoudp_encap_conf.select_vlan) {
6419 if (mplsoudp_encap_conf.select_ipv4)
6420 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6422 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6423 memcpy(header, &vlan, sizeof(vlan));
6424 header += sizeof(vlan);
6426 if (mplsoudp_encap_conf.select_ipv4) {
6427 memcpy(header, &ipv4, sizeof(ipv4));
6428 header += sizeof(ipv4);
6430 memcpy(&ipv6.hdr.src_addr,
6431 &mplsoudp_encap_conf.ipv6_src,
6432 sizeof(mplsoudp_encap_conf.ipv6_src));
6433 memcpy(&ipv6.hdr.dst_addr,
6434 &mplsoudp_encap_conf.ipv6_dst,
6435 sizeof(mplsoudp_encap_conf.ipv6_dst));
6436 memcpy(header, &ipv6, sizeof(ipv6));
6437 header += sizeof(ipv6);
6439 memcpy(header, &udp, sizeof(udp));
6440 header += sizeof(udp);
6441 memcpy(mpls.label_tc_s, mplsoudp_encap_conf.label,
6442 RTE_DIM(mplsoudp_encap_conf.label));
6443 mpls.label_tc_s[2] |= 0x1;
6444 memcpy(header, &mpls, sizeof(mpls));
6445 header += sizeof(mpls);
6446 action_encap_data->conf.size = header -
6447 action_encap_data->data;
6448 action->conf = &action_encap_data->conf;
6452 /** Parse MPLSOUDP decap action. */
6454 parse_vc_action_mplsoudp_decap(struct context *ctx, const struct token *token,
6455 const char *str, unsigned int len,
6456 void *buf, unsigned int size)
6458 struct buffer *out = buf;
6459 struct rte_flow_action *action;
6460 struct action_raw_decap_data *action_decap_data;
6461 struct rte_flow_item_eth eth = { .type = 0, };
6462 struct rte_flow_item_vlan vlan = {.tci = 0};
6463 struct rte_flow_item_ipv4 ipv4 = {
6465 .next_proto_id = IPPROTO_UDP,
6468 struct rte_flow_item_ipv6 ipv6 = {
6470 .proto = IPPROTO_UDP,
6473 struct rte_flow_item_udp udp = {
6475 .dst_port = rte_cpu_to_be_16(6635),
6478 struct rte_flow_item_mpls mpls;
6482 ret = parse_vc(ctx, token, str, len, buf, size);
6485 /* Nothing else to do if there is no buffer. */
6488 if (!out->args.vc.actions_n)
6490 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6491 /* Point to selected object. */
6492 ctx->object = out->args.vc.data;
6493 ctx->objmask = NULL;
6494 /* Copy the headers to the buffer. */
6495 action_decap_data = ctx->object;
6496 *action_decap_data = (struct action_raw_decap_data) {
6497 .conf = (struct rte_flow_action_raw_decap){
6498 .data = action_decap_data->data,
6502 header = action_decap_data->data;
6503 if (mplsoudp_decap_conf.select_vlan)
6504 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
6505 else if (mplsoudp_encap_conf.select_ipv4)
6506 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6508 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6509 memcpy(eth.dst.addr_bytes,
6510 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
6511 memcpy(eth.src.addr_bytes,
6512 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
6513 memcpy(header, ð, sizeof(eth));
6514 header += sizeof(eth);
6515 if (mplsoudp_encap_conf.select_vlan) {
6516 if (mplsoudp_encap_conf.select_ipv4)
6517 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6519 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6520 memcpy(header, &vlan, sizeof(vlan));
6521 header += sizeof(vlan);
6523 if (mplsoudp_encap_conf.select_ipv4) {
6524 memcpy(header, &ipv4, sizeof(ipv4));
6525 header += sizeof(ipv4);
6527 memcpy(header, &ipv6, sizeof(ipv6));
6528 header += sizeof(ipv6);
6530 memcpy(header, &udp, sizeof(udp));
6531 header += sizeof(udp);
6532 memset(&mpls, 0, sizeof(mpls));
6533 memcpy(header, &mpls, sizeof(mpls));
6534 header += sizeof(mpls);
6535 action_decap_data->conf.size = header -
6536 action_decap_data->data;
6537 action->conf = &action_decap_data->conf;
6542 parse_vc_action_raw_decap_index(struct context *ctx, const struct token *token,
6543 const char *str, unsigned int len, void *buf,
6546 struct action_raw_decap_data *action_raw_decap_data;
6547 struct rte_flow_action *action;
6548 const struct arg *arg;
6549 struct buffer *out = buf;
6553 RTE_SET_USED(token);
6556 arg = ARGS_ENTRY_ARB_BOUNDED
6557 (offsetof(struct action_raw_decap_data, idx),
6558 sizeof(((struct action_raw_decap_data *)0)->idx),
6559 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
6560 if (push_args(ctx, arg))
6562 ret = parse_int(ctx, token, str, len, NULL, 0);
6569 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6570 action_raw_decap_data = ctx->object;
6571 idx = action_raw_decap_data->idx;
6572 action_raw_decap_data->conf.data = raw_decap_confs[idx].data;
6573 action_raw_decap_data->conf.size = raw_decap_confs[idx].size;
6574 action->conf = &action_raw_decap_data->conf;
6580 parse_vc_action_raw_encap_index(struct context *ctx, const struct token *token,
6581 const char *str, unsigned int len, void *buf,
6584 struct action_raw_encap_data *action_raw_encap_data;
6585 struct rte_flow_action *action;
6586 const struct arg *arg;
6587 struct buffer *out = buf;
6591 RTE_SET_USED(token);
6594 if (ctx->curr != ACTION_RAW_ENCAP_INDEX_VALUE)
6596 arg = ARGS_ENTRY_ARB_BOUNDED
6597 (offsetof(struct action_raw_encap_data, idx),
6598 sizeof(((struct action_raw_encap_data *)0)->idx),
6599 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
6600 if (push_args(ctx, arg))
6602 ret = parse_int(ctx, token, str, len, NULL, 0);
6609 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6610 action_raw_encap_data = ctx->object;
6611 idx = action_raw_encap_data->idx;
6612 action_raw_encap_data->conf.data = raw_encap_confs[idx].data;
6613 action_raw_encap_data->conf.size = raw_encap_confs[idx].size;
6614 action_raw_encap_data->conf.preserve = NULL;
6615 action->conf = &action_raw_encap_data->conf;
6620 parse_vc_action_raw_encap(struct context *ctx, const struct token *token,
6621 const char *str, unsigned int len, void *buf,
6624 struct buffer *out = buf;
6625 struct rte_flow_action *action;
6626 struct action_raw_encap_data *action_raw_encap_data = NULL;
6629 ret = parse_vc(ctx, token, str, len, buf, size);
6632 /* Nothing else to do if there is no buffer. */
6635 if (!out->args.vc.actions_n)
6637 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6638 /* Point to selected object. */
6639 ctx->object = out->args.vc.data;
6640 ctx->objmask = NULL;
6641 /* Copy the headers to the buffer. */
6642 action_raw_encap_data = ctx->object;
6643 action_raw_encap_data->conf.data = raw_encap_confs[0].data;
6644 action_raw_encap_data->conf.preserve = NULL;
6645 action_raw_encap_data->conf.size = raw_encap_confs[0].size;
6646 action->conf = &action_raw_encap_data->conf;
6651 parse_vc_action_raw_decap(struct context *ctx, const struct token *token,
6652 const char *str, unsigned int len, void *buf,
6655 struct buffer *out = buf;
6656 struct rte_flow_action *action;
6657 struct action_raw_decap_data *action_raw_decap_data = NULL;
6660 ret = parse_vc(ctx, token, str, len, buf, size);
6663 /* Nothing else to do if there is no buffer. */
6666 if (!out->args.vc.actions_n)
6668 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6669 /* Point to selected object. */
6670 ctx->object = out->args.vc.data;
6671 ctx->objmask = NULL;
6672 /* Copy the headers to the buffer. */
6673 action_raw_decap_data = ctx->object;
6674 action_raw_decap_data->conf.data = raw_decap_confs[0].data;
6675 action_raw_decap_data->conf.size = raw_decap_confs[0].size;
6676 action->conf = &action_raw_decap_data->conf;
6681 parse_vc_action_set_meta(struct context *ctx, const struct token *token,
6682 const char *str, unsigned int len, void *buf,
6687 ret = parse_vc(ctx, token, str, len, buf, size);
6690 ret = rte_flow_dynf_metadata_register();
6697 parse_vc_action_sample(struct context *ctx, const struct token *token,
6698 const char *str, unsigned int len, void *buf,
6701 struct buffer *out = buf;
6702 struct rte_flow_action *action;
6703 struct action_sample_data *action_sample_data = NULL;
6704 static struct rte_flow_action end_action = {
6705 RTE_FLOW_ACTION_TYPE_END, 0
6709 ret = parse_vc(ctx, token, str, len, buf, size);
6712 /* Nothing else to do if there is no buffer. */
6715 if (!out->args.vc.actions_n)
6717 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6718 /* Point to selected object. */
6719 ctx->object = out->args.vc.data;
6720 ctx->objmask = NULL;
6721 /* Copy the headers to the buffer. */
6722 action_sample_data = ctx->object;
6723 action_sample_data->conf.actions = &end_action;
6724 action->conf = &action_sample_data->conf;
6729 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
6730 const char *str, unsigned int len, void *buf,
6733 struct action_sample_data *action_sample_data;
6734 struct rte_flow_action *action;
6735 const struct arg *arg;
6736 struct buffer *out = buf;
6740 RTE_SET_USED(token);
6743 if (ctx->curr != ACTION_SAMPLE_INDEX_VALUE)
6745 arg = ARGS_ENTRY_ARB_BOUNDED
6746 (offsetof(struct action_sample_data, idx),
6747 sizeof(((struct action_sample_data *)0)->idx),
6748 0, RAW_SAMPLE_CONFS_MAX_NUM - 1);
6749 if (push_args(ctx, arg))
6751 ret = parse_int(ctx, token, str, len, NULL, 0);
6758 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6759 action_sample_data = ctx->object;
6760 idx = action_sample_data->idx;
6761 action_sample_data->conf.actions = raw_sample_confs[idx].data;
6762 action->conf = &action_sample_data->conf;
6766 /** Parse operation for modify_field command. */
6768 parse_vc_modify_field_op(struct context *ctx, const struct token *token,
6769 const char *str, unsigned int len, void *buf,
6772 struct rte_flow_action_modify_field *action_modify_field;
6778 if (ctx->curr != ACTION_MODIFY_FIELD_OP_VALUE)
6780 for (i = 0; modify_field_ops[i]; ++i)
6781 if (!strcmp_partial(modify_field_ops[i], str, len))
6783 if (!modify_field_ops[i])
6787 action_modify_field = ctx->object;
6788 action_modify_field->operation = (enum rte_flow_modify_op)i;
6792 /** Parse id for modify_field command. */
6794 parse_vc_modify_field_id(struct context *ctx, const struct token *token,
6795 const char *str, unsigned int len, void *buf,
6798 struct rte_flow_action_modify_field *action_modify_field;
6804 if (ctx->curr != ACTION_MODIFY_FIELD_DST_TYPE_VALUE &&
6805 ctx->curr != ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)
6807 for (i = 0; modify_field_ids[i]; ++i)
6808 if (!strcmp_partial(modify_field_ids[i], str, len))
6810 if (!modify_field_ids[i])
6814 action_modify_field = ctx->object;
6815 if (ctx->curr == ACTION_MODIFY_FIELD_DST_TYPE_VALUE)
6816 action_modify_field->dst.field = (enum rte_flow_field_id)i;
6818 action_modify_field->src.field = (enum rte_flow_field_id)i;
6822 /** Parse the conntrack update, not a rte_flow_action. */
6824 parse_vc_action_conntrack_update(struct context *ctx, const struct token *token,
6825 const char *str, unsigned int len, void *buf,
6828 struct buffer *out = buf;
6829 struct rte_flow_modify_conntrack *ct_modify = NULL;
6832 if (ctx->curr != ACTION_CONNTRACK_UPDATE_CTX &&
6833 ctx->curr != ACTION_CONNTRACK_UPDATE_DIR)
6835 /* Token name must match. */
6836 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6838 /* Nothing else to do if there is no buffer. */
6841 ct_modify = (struct rte_flow_modify_conntrack *)out->args.vc.data;
6842 if (ctx->curr == ACTION_CONNTRACK_UPDATE_DIR) {
6843 ct_modify->new_ct.is_original_dir =
6844 conntrack_context.is_original_dir;
6845 ct_modify->direction = 1;
6849 old_dir = ct_modify->new_ct.is_original_dir;
6850 memcpy(&ct_modify->new_ct, &conntrack_context,
6851 sizeof(conntrack_context));
6852 ct_modify->new_ct.is_original_dir = old_dir;
6853 ct_modify->state = 1;
6858 /** Parse tokens for destroy command. */
6860 parse_destroy(struct context *ctx, const struct token *token,
6861 const char *str, unsigned int len,
6862 void *buf, unsigned int size)
6864 struct buffer *out = buf;
6866 /* Token name must match. */
6867 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6869 /* Nothing else to do if there is no buffer. */
6872 if (!out->command) {
6873 if (ctx->curr != DESTROY)
6875 if (sizeof(*out) > size)
6877 out->command = ctx->curr;
6880 ctx->objmask = NULL;
6881 out->args.destroy.rule =
6882 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6886 if (((uint8_t *)(out->args.destroy.rule + out->args.destroy.rule_n) +
6887 sizeof(*out->args.destroy.rule)) > (uint8_t *)out + size)
6890 ctx->object = out->args.destroy.rule + out->args.destroy.rule_n++;
6891 ctx->objmask = NULL;
6895 /** Parse tokens for flush command. */
6897 parse_flush(struct context *ctx, const struct token *token,
6898 const char *str, unsigned int len,
6899 void *buf, unsigned int size)
6901 struct buffer *out = buf;
6903 /* Token name must match. */
6904 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6906 /* Nothing else to do if there is no buffer. */
6909 if (!out->command) {
6910 if (ctx->curr != FLUSH)
6912 if (sizeof(*out) > size)
6914 out->command = ctx->curr;
6917 ctx->objmask = NULL;
6922 /** Parse tokens for dump command. */
6924 parse_dump(struct context *ctx, const struct token *token,
6925 const char *str, unsigned int len,
6926 void *buf, unsigned int size)
6928 struct buffer *out = buf;
6930 /* Token name must match. */
6931 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6933 /* Nothing else to do if there is no buffer. */
6936 if (!out->command) {
6937 if (ctx->curr != DUMP)
6939 if (sizeof(*out) > size)
6941 out->command = ctx->curr;
6944 ctx->objmask = NULL;
6947 switch (ctx->curr) {
6950 out->args.dump.mode = (ctx->curr == DUMP_ALL) ? true : false;
6951 out->command = ctx->curr;
6954 ctx->objmask = NULL;
6961 /** Parse tokens for query command. */
6963 parse_query(struct context *ctx, const struct token *token,
6964 const char *str, unsigned int len,
6965 void *buf, unsigned int size)
6967 struct buffer *out = buf;
6969 /* Token name must match. */
6970 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6972 /* Nothing else to do if there is no buffer. */
6975 if (!out->command) {
6976 if (ctx->curr != QUERY)
6978 if (sizeof(*out) > size)
6980 out->command = ctx->curr;
6983 ctx->objmask = NULL;
6988 /** Parse action names. */
6990 parse_action(struct context *ctx, const struct token *token,
6991 const char *str, unsigned int len,
6992 void *buf, unsigned int size)
6994 struct buffer *out = buf;
6995 const struct arg *arg = pop_args(ctx);
6999 /* Argument is expected. */
7002 /* Parse action name. */
7003 for (i = 0; next_action[i]; ++i) {
7004 const struct parse_action_priv *priv;
7006 token = &token_list[next_action[i]];
7007 if (strcmp_partial(token->name, str, len))
7013 memcpy((uint8_t *)ctx->object + arg->offset,
7019 push_args(ctx, arg);
7023 /** Parse tokens for list command. */
7025 parse_list(struct context *ctx, const struct token *token,
7026 const char *str, unsigned int len,
7027 void *buf, unsigned int size)
7029 struct buffer *out = buf;
7031 /* Token name must match. */
7032 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7034 /* Nothing else to do if there is no buffer. */
7037 if (!out->command) {
7038 if (ctx->curr != LIST)
7040 if (sizeof(*out) > size)
7042 out->command = ctx->curr;
7045 ctx->objmask = NULL;
7046 out->args.list.group =
7047 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7051 if (((uint8_t *)(out->args.list.group + out->args.list.group_n) +
7052 sizeof(*out->args.list.group)) > (uint8_t *)out + size)
7055 ctx->object = out->args.list.group + out->args.list.group_n++;
7056 ctx->objmask = NULL;
7060 /** Parse tokens for list all aged flows command. */
7062 parse_aged(struct context *ctx, const struct token *token,
7063 const char *str, unsigned int len,
7064 void *buf, unsigned int size)
7066 struct buffer *out = buf;
7068 /* Token name must match. */
7069 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7071 /* Nothing else to do if there is no buffer. */
7074 if (!out->command) {
7075 if (ctx->curr != AGED)
7077 if (sizeof(*out) > size)
7079 out->command = ctx->curr;
7082 ctx->objmask = NULL;
7084 if (ctx->curr == AGED_DESTROY)
7085 out->args.aged.destroy = 1;
7089 /** Parse tokens for isolate command. */
7091 parse_isolate(struct context *ctx, const struct token *token,
7092 const char *str, unsigned int len,
7093 void *buf, unsigned int size)
7095 struct buffer *out = buf;
7097 /* Token name must match. */
7098 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7100 /* Nothing else to do if there is no buffer. */
7103 if (!out->command) {
7104 if (ctx->curr != ISOLATE)
7106 if (sizeof(*out) > size)
7108 out->command = ctx->curr;
7111 ctx->objmask = NULL;
7117 parse_tunnel(struct context *ctx, const struct token *token,
7118 const char *str, unsigned int len,
7119 void *buf, unsigned int size)
7121 struct buffer *out = buf;
7123 /* Token name must match. */
7124 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7126 /* Nothing else to do if there is no buffer. */
7129 if (!out->command) {
7130 if (ctx->curr != TUNNEL)
7132 if (sizeof(*out) > size)
7134 out->command = ctx->curr;
7137 ctx->objmask = NULL;
7139 switch (ctx->curr) {
7143 case TUNNEL_DESTROY:
7145 out->command = ctx->curr;
7147 case TUNNEL_CREATE_TYPE:
7148 case TUNNEL_DESTROY_ID:
7149 ctx->object = &out->args.vc.tunnel_ops;
7158 * Parse signed/unsigned integers 8 to 64-bit long.
7160 * Last argument (ctx->args) is retrieved to determine integer type and
7164 parse_int(struct context *ctx, const struct token *token,
7165 const char *str, unsigned int len,
7166 void *buf, unsigned int size)
7168 const struct arg *arg = pop_args(ctx);
7173 /* Argument is expected. */
7178 (uintmax_t)strtoimax(str, &end, 0) :
7179 strtoumax(str, &end, 0);
7180 if (errno || (size_t)(end - str) != len)
7183 ((arg->sign && ((intmax_t)u < (intmax_t)arg->min ||
7184 (intmax_t)u > (intmax_t)arg->max)) ||
7185 (!arg->sign && (u < arg->min || u > arg->max))))
7190 if (!arg_entry_bf_fill(ctx->object, u, arg) ||
7191 !arg_entry_bf_fill(ctx->objmask, -1, arg))
7195 buf = (uint8_t *)ctx->object + arg->offset;
7197 if (u > RTE_LEN2MASK(size * CHAR_BIT, uint64_t))
7201 case sizeof(uint8_t):
7202 *(uint8_t *)buf = u;
7204 case sizeof(uint16_t):
7205 *(uint16_t *)buf = arg->hton ? rte_cpu_to_be_16(u) : u;
7207 case sizeof(uint8_t [3]):
7208 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
7210 ((uint8_t *)buf)[0] = u;
7211 ((uint8_t *)buf)[1] = u >> 8;
7212 ((uint8_t *)buf)[2] = u >> 16;
7216 ((uint8_t *)buf)[0] = u >> 16;
7217 ((uint8_t *)buf)[1] = u >> 8;
7218 ((uint8_t *)buf)[2] = u;
7220 case sizeof(uint32_t):
7221 *(uint32_t *)buf = arg->hton ? rte_cpu_to_be_32(u) : u;
7223 case sizeof(uint64_t):
7224 *(uint64_t *)buf = arg->hton ? rte_cpu_to_be_64(u) : u;
7229 if (ctx->objmask && buf != (uint8_t *)ctx->objmask + arg->offset) {
7231 buf = (uint8_t *)ctx->objmask + arg->offset;
7236 push_args(ctx, arg);
7243 * Three arguments (ctx->args) are retrieved from the stack to store data,
7244 * its actual length and address (in that order).
7247 parse_string(struct context *ctx, const struct token *token,
7248 const char *str, unsigned int len,
7249 void *buf, unsigned int size)
7251 const struct arg *arg_data = pop_args(ctx);
7252 const struct arg *arg_len = pop_args(ctx);
7253 const struct arg *arg_addr = pop_args(ctx);
7254 char tmp[16]; /* Ought to be enough. */
7257 /* Arguments are expected. */
7261 push_args(ctx, arg_data);
7265 push_args(ctx, arg_len);
7266 push_args(ctx, arg_data);
7269 size = arg_data->size;
7270 /* Bit-mask fill is not supported. */
7271 if (arg_data->mask || size < len)
7275 /* Let parse_int() fill length information first. */
7276 ret = snprintf(tmp, sizeof(tmp), "%u", len);
7279 push_args(ctx, arg_len);
7280 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
7285 buf = (uint8_t *)ctx->object + arg_data->offset;
7286 /* Output buffer is not necessarily NUL-terminated. */
7287 memcpy(buf, str, len);
7288 memset((uint8_t *)buf + len, 0x00, size - len);
7290 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
7291 /* Save address if requested. */
7292 if (arg_addr->size) {
7293 memcpy((uint8_t *)ctx->object + arg_addr->offset,
7295 (uint8_t *)ctx->object + arg_data->offset
7299 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
7301 (uint8_t *)ctx->objmask + arg_data->offset
7307 push_args(ctx, arg_addr);
7308 push_args(ctx, arg_len);
7309 push_args(ctx, arg_data);
7314 parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
7320 /* Check input parameters */
7321 if ((src == NULL) ||
7327 /* Convert chars to bytes */
7328 for (i = 0, len = 0; i < *size; i += 2) {
7329 snprintf(tmp, 3, "%s", src + i);
7330 dst[len++] = strtoul(tmp, &c, 16);
7345 parse_hex(struct context *ctx, const struct token *token,
7346 const char *str, unsigned int len,
7347 void *buf, unsigned int size)
7349 const struct arg *arg_data = pop_args(ctx);
7350 const struct arg *arg_len = pop_args(ctx);
7351 const struct arg *arg_addr = pop_args(ctx);
7352 char tmp[16]; /* Ought to be enough. */
7354 unsigned int hexlen = len;
7355 unsigned int length = 256;
7356 uint8_t hex_tmp[length];
7358 /* Arguments are expected. */
7362 push_args(ctx, arg_data);
7366 push_args(ctx, arg_len);
7367 push_args(ctx, arg_data);
7370 size = arg_data->size;
7371 /* Bit-mask fill is not supported. */
7377 /* translate bytes string to array. */
7378 if (str[0] == '0' && ((str[1] == 'x') ||
7383 if (hexlen > length)
7385 ret = parse_hex_string(str, hex_tmp, &hexlen);
7388 /* Let parse_int() fill length information first. */
7389 ret = snprintf(tmp, sizeof(tmp), "%u", hexlen);
7392 /* Save length if requested. */
7393 if (arg_len->size) {
7394 push_args(ctx, arg_len);
7395 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
7401 buf = (uint8_t *)ctx->object + arg_data->offset;
7402 /* Output buffer is not necessarily NUL-terminated. */
7403 memcpy(buf, hex_tmp, hexlen);
7404 memset((uint8_t *)buf + hexlen, 0x00, size - hexlen);
7406 memset((uint8_t *)ctx->objmask + arg_data->offset,
7408 /* Save address if requested. */
7409 if (arg_addr->size) {
7410 memcpy((uint8_t *)ctx->object + arg_addr->offset,
7412 (uint8_t *)ctx->object + arg_data->offset
7416 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
7418 (uint8_t *)ctx->objmask + arg_data->offset
7424 push_args(ctx, arg_addr);
7425 push_args(ctx, arg_len);
7426 push_args(ctx, arg_data);
7432 * Parse a zero-ended string.
7435 parse_string0(struct context *ctx, const struct token *token __rte_unused,
7436 const char *str, unsigned int len,
7437 void *buf, unsigned int size)
7439 const struct arg *arg_data = pop_args(ctx);
7441 /* Arguments are expected. */
7444 size = arg_data->size;
7445 /* Bit-mask fill is not supported. */
7446 if (arg_data->mask || size < len + 1)
7450 buf = (uint8_t *)ctx->object + arg_data->offset;
7451 strncpy(buf, str, len);
7453 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
7456 push_args(ctx, arg_data);
7461 * Parse a MAC address.
7463 * Last argument (ctx->args) is retrieved to determine storage size and
7467 parse_mac_addr(struct context *ctx, const struct token *token,
7468 const char *str, unsigned int len,
7469 void *buf, unsigned int size)
7471 const struct arg *arg = pop_args(ctx);
7472 struct rte_ether_addr tmp;
7476 /* Argument is expected. */
7480 /* Bit-mask fill is not supported. */
7481 if (arg->mask || size != sizeof(tmp))
7483 /* Only network endian is supported. */
7486 ret = cmdline_parse_etheraddr(NULL, str, &tmp, size);
7487 if (ret < 0 || (unsigned int)ret != len)
7491 buf = (uint8_t *)ctx->object + arg->offset;
7492 memcpy(buf, &tmp, size);
7494 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
7497 push_args(ctx, arg);
7502 * Parse an IPv4 address.
7504 * Last argument (ctx->args) is retrieved to determine storage size and
7508 parse_ipv4_addr(struct context *ctx, const struct token *token,
7509 const char *str, unsigned int len,
7510 void *buf, unsigned int size)
7512 const struct arg *arg = pop_args(ctx);
7517 /* Argument is expected. */
7521 /* Bit-mask fill is not supported. */
7522 if (arg->mask || size != sizeof(tmp))
7524 /* Only network endian is supported. */
7527 memcpy(str2, str, len);
7529 ret = inet_pton(AF_INET, str2, &tmp);
7531 /* Attempt integer parsing. */
7532 push_args(ctx, arg);
7533 return parse_int(ctx, token, str, len, buf, size);
7537 buf = (uint8_t *)ctx->object + arg->offset;
7538 memcpy(buf, &tmp, size);
7540 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
7543 push_args(ctx, arg);
7548 * Parse an IPv6 address.
7550 * Last argument (ctx->args) is retrieved to determine storage size and
7554 parse_ipv6_addr(struct context *ctx, const struct token *token,
7555 const char *str, unsigned int len,
7556 void *buf, unsigned int size)
7558 const struct arg *arg = pop_args(ctx);
7560 struct in6_addr tmp;
7564 /* Argument is expected. */
7568 /* Bit-mask fill is not supported. */
7569 if (arg->mask || size != sizeof(tmp))
7571 /* Only network endian is supported. */
7574 memcpy(str2, str, len);
7576 ret = inet_pton(AF_INET6, str2, &tmp);
7581 buf = (uint8_t *)ctx->object + arg->offset;
7582 memcpy(buf, &tmp, size);
7584 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
7587 push_args(ctx, arg);
7591 /** Boolean values (even indices stand for false). */
7592 static const char *const boolean_name[] = {
7602 * Parse a boolean value.
7604 * Last argument (ctx->args) is retrieved to determine storage size and
7608 parse_boolean(struct context *ctx, const struct token *token,
7609 const char *str, unsigned int len,
7610 void *buf, unsigned int size)
7612 const struct arg *arg = pop_args(ctx);
7616 /* Argument is expected. */
7619 for (i = 0; boolean_name[i]; ++i)
7620 if (!strcmp_partial(boolean_name[i], str, len))
7622 /* Process token as integer. */
7623 if (boolean_name[i])
7624 str = i & 1 ? "1" : "0";
7625 push_args(ctx, arg);
7626 ret = parse_int(ctx, token, str, strlen(str), buf, size);
7627 return ret > 0 ? (int)len : ret;
7630 /** Parse port and update context. */
7632 parse_port(struct context *ctx, const struct token *token,
7633 const char *str, unsigned int len,
7634 void *buf, unsigned int size)
7636 struct buffer *out = &(struct buffer){ .port = 0 };
7644 ctx->objmask = NULL;
7645 size = sizeof(*out);
7647 ret = parse_int(ctx, token, str, len, out, size);
7649 ctx->port = out->port;
7656 parse_ia_id2ptr(struct context *ctx, const struct token *token,
7657 const char *str, unsigned int len,
7658 void *buf, unsigned int size)
7660 struct rte_flow_action *action = ctx->object;
7668 ctx->objmask = NULL;
7669 ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
7670 ctx->object = action;
7671 if (ret != (int)len)
7673 /* set indirect action */
7675 action->conf = port_action_handle_get_by_id(ctx->port, id);
7676 ret = (action->conf) ? ret : -1;
7681 /** Parse set command, initialize output buffer for subsequent tokens. */
7683 parse_set_raw_encap_decap(struct context *ctx, const struct token *token,
7684 const char *str, unsigned int len,
7685 void *buf, unsigned int size)
7687 struct buffer *out = buf;
7689 /* Token name must match. */
7690 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7692 /* Nothing else to do if there is no buffer. */
7695 /* Make sure buffer is large enough. */
7696 if (size < sizeof(*out))
7699 ctx->objmask = NULL;
7703 out->command = ctx->curr;
7704 /* For encap/decap we need is pattern */
7705 out->args.vc.pattern = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7710 /** Parse set command, initialize output buffer for subsequent tokens. */
7712 parse_set_sample_action(struct context *ctx, const struct token *token,
7713 const char *str, unsigned int len,
7714 void *buf, unsigned int size)
7716 struct buffer *out = buf;
7718 /* Token name must match. */
7719 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7721 /* Nothing else to do if there is no buffer. */
7724 /* Make sure buffer is large enough. */
7725 if (size < sizeof(*out))
7728 ctx->objmask = NULL;
7732 out->command = ctx->curr;
7733 /* For sampler we need is actions */
7734 out->args.vc.actions = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7740 * Parse set raw_encap/raw_decap command,
7741 * initialize output buffer for subsequent tokens.
7744 parse_set_init(struct context *ctx, const struct token *token,
7745 const char *str, unsigned int len,
7746 void *buf, unsigned int size)
7748 struct buffer *out = buf;
7750 /* Token name must match. */
7751 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7753 /* Nothing else to do if there is no buffer. */
7756 /* Make sure buffer is large enough. */
7757 if (size < sizeof(*out))
7759 /* Initialize buffer. */
7760 memset(out, 0x00, sizeof(*out));
7761 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
7764 ctx->objmask = NULL;
7765 if (!out->command) {
7766 if (ctx->curr != SET)
7768 if (sizeof(*out) > size)
7770 out->command = ctx->curr;
7771 out->args.vc.data = (uint8_t *)out + size;
7772 ctx->object = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7778 /** No completion. */
7780 comp_none(struct context *ctx, const struct token *token,
7781 unsigned int ent, char *buf, unsigned int size)
7791 /** Complete boolean values. */
7793 comp_boolean(struct context *ctx, const struct token *token,
7794 unsigned int ent, char *buf, unsigned int size)
7800 for (i = 0; boolean_name[i]; ++i)
7801 if (buf && i == ent)
7802 return strlcpy(buf, boolean_name[i], size);
7808 /** Complete action names. */
7810 comp_action(struct context *ctx, const struct token *token,
7811 unsigned int ent, char *buf, unsigned int size)
7817 for (i = 0; next_action[i]; ++i)
7818 if (buf && i == ent)
7819 return strlcpy(buf, token_list[next_action[i]].name,
7826 /** Complete available ports. */
7828 comp_port(struct context *ctx, const struct token *token,
7829 unsigned int ent, char *buf, unsigned int size)
7836 RTE_ETH_FOREACH_DEV(p) {
7837 if (buf && i == ent)
7838 return snprintf(buf, size, "%u", p);
7846 /** Complete available rule IDs. */
7848 comp_rule_id(struct context *ctx, const struct token *token,
7849 unsigned int ent, char *buf, unsigned int size)
7852 struct rte_port *port;
7853 struct port_flow *pf;
7856 if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
7857 ctx->port == (portid_t)RTE_PORT_ALL)
7859 port = &ports[ctx->port];
7860 for (pf = port->flow_list; pf != NULL; pf = pf->next) {
7861 if (buf && i == ent)
7862 return snprintf(buf, size, "%u", pf->id);
7870 /** Complete type field for RSS action. */
7872 comp_vc_action_rss_type(struct context *ctx, const struct token *token,
7873 unsigned int ent, char *buf, unsigned int size)
7879 for (i = 0; rss_type_table[i].str; ++i)
7884 return strlcpy(buf, rss_type_table[ent].str, size);
7886 return snprintf(buf, size, "end");
7890 /** Complete queue field for RSS action. */
7892 comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
7893 unsigned int ent, char *buf, unsigned int size)
7900 return snprintf(buf, size, "%u", ent);
7902 return snprintf(buf, size, "end");
7906 /** Complete index number for set raw_encap/raw_decap commands. */
7908 comp_set_raw_index(struct context *ctx, const struct token *token,
7909 unsigned int ent, char *buf, unsigned int size)
7915 RTE_SET_USED(token);
7916 for (idx = 0; idx < RAW_ENCAP_CONFS_MAX_NUM; ++idx) {
7917 if (buf && idx == ent)
7918 return snprintf(buf, size, "%u", idx);
7924 /** Complete index number for set raw_encap/raw_decap commands. */
7926 comp_set_sample_index(struct context *ctx, const struct token *token,
7927 unsigned int ent, char *buf, unsigned int size)
7933 RTE_SET_USED(token);
7934 for (idx = 0; idx < RAW_SAMPLE_CONFS_MAX_NUM; ++idx) {
7935 if (buf && idx == ent)
7936 return snprintf(buf, size, "%u", idx);
7942 /** Complete operation for modify_field command. */
7944 comp_set_modify_field_op(struct context *ctx, const struct token *token,
7945 unsigned int ent, char *buf, unsigned int size)
7948 RTE_SET_USED(token);
7950 return RTE_DIM(modify_field_ops);
7951 if (ent < RTE_DIM(modify_field_ops) - 1)
7952 return strlcpy(buf, modify_field_ops[ent], size);
7956 /** Complete field id for modify_field command. */
7958 comp_set_modify_field_id(struct context *ctx, const struct token *token,
7959 unsigned int ent, char *buf, unsigned int size)
7963 RTE_SET_USED(token);
7965 return RTE_DIM(modify_field_ids);
7966 if (ent >= RTE_DIM(modify_field_ids) - 1)
7968 name = modify_field_ids[ent];
7969 if (ctx->curr == ACTION_MODIFY_FIELD_SRC_TYPE ||
7970 (strcmp(name, "pointer") && strcmp(name, "value")))
7971 return strlcpy(buf, name, size);
7975 /** Internal context. */
7976 static struct context cmd_flow_context;
7978 /** Global parser instance (cmdline API). */
7979 cmdline_parse_inst_t cmd_flow;
7980 cmdline_parse_inst_t cmd_set_raw;
7982 /** Initialize context. */
7984 cmd_flow_context_init(struct context *ctx)
7986 /* A full memset() is not necessary. */
7996 ctx->objmask = NULL;
7999 /** Parse a token (cmdline API). */
8001 cmd_flow_parse(cmdline_parse_token_hdr_t *hdr, const char *src, void *result,
8004 struct context *ctx = &cmd_flow_context;
8005 const struct token *token;
8006 const enum index *list;
8011 token = &token_list[ctx->curr];
8012 /* Check argument length. */
8015 for (len = 0; src[len]; ++len)
8016 if (src[len] == '#' || isspace(src[len]))
8020 /* Last argument and EOL detection. */
8021 for (i = len; src[i]; ++i)
8022 if (src[i] == '#' || src[i] == '\r' || src[i] == '\n')
8024 else if (!isspace(src[i])) {
8029 if (src[i] == '\r' || src[i] == '\n') {
8033 /* Initialize context if necessary. */
8034 if (!ctx->next_num) {
8037 ctx->next[ctx->next_num++] = token->next[0];
8039 /* Process argument through candidates. */
8040 ctx->prev = ctx->curr;
8041 list = ctx->next[ctx->next_num - 1];
8042 for (i = 0; list[i]; ++i) {
8043 const struct token *next = &token_list[list[i]];
8046 ctx->curr = list[i];
8048 tmp = next->call(ctx, next, src, len, result, size);
8050 tmp = parse_default(ctx, next, src, len, result, size);
8051 if (tmp == -1 || tmp != len)
8059 /* Push subsequent tokens if any. */
8061 for (i = 0; token->next[i]; ++i) {
8062 if (ctx->next_num == RTE_DIM(ctx->next))
8064 ctx->next[ctx->next_num++] = token->next[i];
8066 /* Push arguments if any. */
8068 for (i = 0; token->args[i]; ++i) {
8069 if (ctx->args_num == RTE_DIM(ctx->args))
8071 ctx->args[ctx->args_num++] = token->args[i];
8076 /** Return number of completion entries (cmdline API). */
8078 cmd_flow_complete_get_nb(cmdline_parse_token_hdr_t *hdr)
8080 struct context *ctx = &cmd_flow_context;
8081 const struct token *token = &token_list[ctx->curr];
8082 const enum index *list;
8086 /* Count number of tokens in current list. */
8088 list = ctx->next[ctx->next_num - 1];
8090 list = token->next[0];
8091 for (i = 0; list[i]; ++i)
8096 * If there is a single token, use its completion callback, otherwise
8097 * return the number of entries.
8099 token = &token_list[list[0]];
8100 if (i == 1 && token->comp) {
8101 /* Save index for cmd_flow_get_help(). */
8102 ctx->prev = list[0];
8103 return token->comp(ctx, token, 0, NULL, 0);
8108 /** Return a completion entry (cmdline API). */
8110 cmd_flow_complete_get_elt(cmdline_parse_token_hdr_t *hdr, int index,
8111 char *dst, unsigned int size)
8113 struct context *ctx = &cmd_flow_context;
8114 const struct token *token = &token_list[ctx->curr];
8115 const enum index *list;
8119 /* Count number of tokens in current list. */
8121 list = ctx->next[ctx->next_num - 1];
8123 list = token->next[0];
8124 for (i = 0; list[i]; ++i)
8128 /* If there is a single token, use its completion callback. */
8129 token = &token_list[list[0]];
8130 if (i == 1 && token->comp) {
8131 /* Save index for cmd_flow_get_help(). */
8132 ctx->prev = list[0];
8133 return token->comp(ctx, token, index, dst, size) < 0 ? -1 : 0;
8135 /* Otherwise make sure the index is valid and use defaults. */
8138 token = &token_list[list[index]];
8139 strlcpy(dst, token->name, size);
8140 /* Save index for cmd_flow_get_help(). */
8141 ctx->prev = list[index];
8145 /** Populate help strings for current token (cmdline API). */
8147 cmd_flow_get_help(cmdline_parse_token_hdr_t *hdr, char *dst, unsigned int size)
8149 struct context *ctx = &cmd_flow_context;
8150 const struct token *token = &token_list[ctx->prev];
8155 /* Set token type and update global help with details. */
8156 strlcpy(dst, (token->type ? token->type : "TOKEN"), size);
8158 cmd_flow.help_str = token->help;
8160 cmd_flow.help_str = token->name;
8164 /** Token definition template (cmdline API). */
8165 static struct cmdline_token_hdr cmd_flow_token_hdr = {
8166 .ops = &(struct cmdline_token_ops){
8167 .parse = cmd_flow_parse,
8168 .complete_get_nb = cmd_flow_complete_get_nb,
8169 .complete_get_elt = cmd_flow_complete_get_elt,
8170 .get_help = cmd_flow_get_help,
8175 /** Populate the next dynamic token. */
8177 cmd_flow_tok(cmdline_parse_token_hdr_t **hdr,
8178 cmdline_parse_token_hdr_t **hdr_inst)
8180 struct context *ctx = &cmd_flow_context;
8182 /* Always reinitialize context before requesting the first token. */
8183 if (!(hdr_inst - cmd_flow.tokens))
8184 cmd_flow_context_init(ctx);
8185 /* Return NULL when no more tokens are expected. */
8186 if (!ctx->next_num && ctx->curr) {
8190 /* Determine if command should end here. */
8191 if (ctx->eol && ctx->last && ctx->next_num) {
8192 const enum index *list = ctx->next[ctx->next_num - 1];
8195 for (i = 0; list[i]; ++i) {
8202 *hdr = &cmd_flow_token_hdr;
8205 /** Dispatch parsed buffer to function calls. */
8207 cmd_flow_parsed(const struct buffer *in)
8209 switch (in->command) {
8210 case INDIRECT_ACTION_CREATE:
8211 port_action_handle_create(
8212 in->port, in->args.vc.attr.group,
8213 &((const struct rte_flow_indir_action_conf) {
8214 .ingress = in->args.vc.attr.ingress,
8215 .egress = in->args.vc.attr.egress,
8216 .transfer = in->args.vc.attr.transfer,
8218 in->args.vc.actions);
8220 case INDIRECT_ACTION_DESTROY:
8221 port_action_handle_destroy(in->port,
8222 in->args.ia_destroy.action_id_n,
8223 in->args.ia_destroy.action_id);
8225 case INDIRECT_ACTION_UPDATE:
8226 port_action_handle_update(in->port, in->args.vc.attr.group,
8227 in->args.vc.actions);
8229 case INDIRECT_ACTION_QUERY:
8230 port_action_handle_query(in->port, in->args.ia.action_id);
8233 port_flow_validate(in->port, &in->args.vc.attr,
8234 in->args.vc.pattern, in->args.vc.actions,
8235 &in->args.vc.tunnel_ops);
8238 port_flow_create(in->port, &in->args.vc.attr,
8239 in->args.vc.pattern, in->args.vc.actions,
8240 &in->args.vc.tunnel_ops);
8243 port_flow_destroy(in->port, in->args.destroy.rule_n,
8244 in->args.destroy.rule);
8247 port_flow_flush(in->port);
8251 port_flow_dump(in->port, in->args.dump.mode,
8252 in->args.dump.rule, in->args.dump.file);
8255 port_flow_query(in->port, in->args.query.rule,
8256 &in->args.query.action);
8259 port_flow_list(in->port, in->args.list.group_n,
8260 in->args.list.group);
8263 port_flow_isolate(in->port, in->args.isolate.set);
8266 port_flow_aged(in->port, in->args.aged.destroy);
8269 port_flow_tunnel_create(in->port, &in->args.vc.tunnel_ops);
8271 case TUNNEL_DESTROY:
8272 port_flow_tunnel_destroy(in->port, in->args.vc.tunnel_ops.id);
8275 port_flow_tunnel_list(in->port);
8278 port_meter_policy_add(in->port, in->args.policy.policy_id,
8279 in->args.vc.actions);
8286 /** Token generator and output processing callback (cmdline API). */
8288 cmd_flow_cb(void *arg0, struct cmdline *cl, void *arg2)
8291 cmd_flow_tok(arg0, arg2);
8293 cmd_flow_parsed(arg0);
8296 /** Global parser instance (cmdline API). */
8297 cmdline_parse_inst_t cmd_flow = {
8299 .data = NULL, /**< Unused. */
8300 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
8303 }, /**< Tokens are returned by cmd_flow_tok(). */
8306 /** set cmd facility. Reuse cmd flow's infrastructure as much as possible. */
8309 update_fields(uint8_t *buf, struct rte_flow_item *item, uint16_t next_proto)
8311 struct rte_ipv4_hdr *ipv4;
8312 struct rte_ether_hdr *eth;
8313 struct rte_ipv6_hdr *ipv6;
8314 struct rte_vxlan_hdr *vxlan;
8315 struct rte_vxlan_gpe_hdr *gpe;
8316 struct rte_flow_item_nvgre *nvgre;
8317 uint32_t ipv6_vtc_flow;
8319 switch (item->type) {
8320 case RTE_FLOW_ITEM_TYPE_ETH:
8321 eth = (struct rte_ether_hdr *)buf;
8323 eth->ether_type = rte_cpu_to_be_16(next_proto);
8325 case RTE_FLOW_ITEM_TYPE_IPV4:
8326 ipv4 = (struct rte_ipv4_hdr *)buf;
8327 if (!ipv4->version_ihl)
8328 ipv4->version_ihl = RTE_IPV4_VHL_DEF;
8329 if (next_proto && ipv4->next_proto_id == 0)
8330 ipv4->next_proto_id = (uint8_t)next_proto;
8332 case RTE_FLOW_ITEM_TYPE_IPV6:
8333 ipv6 = (struct rte_ipv6_hdr *)buf;
8334 if (next_proto && ipv6->proto == 0)
8335 ipv6->proto = (uint8_t)next_proto;
8336 ipv6_vtc_flow = rte_be_to_cpu_32(ipv6->vtc_flow);
8337 ipv6_vtc_flow &= 0x0FFFFFFF; /*< reset version bits. */
8338 ipv6_vtc_flow |= 0x60000000; /*< set ipv6 version. */
8339 ipv6->vtc_flow = rte_cpu_to_be_32(ipv6_vtc_flow);
8341 case RTE_FLOW_ITEM_TYPE_VXLAN:
8342 vxlan = (struct rte_vxlan_hdr *)buf;
8343 vxlan->vx_flags = 0x08;
8345 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
8346 gpe = (struct rte_vxlan_gpe_hdr *)buf;
8347 gpe->vx_flags = 0x0C;
8349 case RTE_FLOW_ITEM_TYPE_NVGRE:
8350 nvgre = (struct rte_flow_item_nvgre *)buf;
8351 nvgre->protocol = rte_cpu_to_be_16(0x6558);
8352 nvgre->c_k_s_rsvd0_ver = rte_cpu_to_be_16(0x2000);
8359 /** Helper of get item's default mask. */
8361 flow_item_default_mask(const struct rte_flow_item *item)
8363 const void *mask = NULL;
8364 static rte_be32_t gre_key_default_mask = RTE_BE32(UINT32_MAX);
8366 switch (item->type) {
8367 case RTE_FLOW_ITEM_TYPE_ANY:
8368 mask = &rte_flow_item_any_mask;
8370 case RTE_FLOW_ITEM_TYPE_VF:
8371 mask = &rte_flow_item_vf_mask;
8373 case RTE_FLOW_ITEM_TYPE_PORT_ID:
8374 mask = &rte_flow_item_port_id_mask;
8376 case RTE_FLOW_ITEM_TYPE_RAW:
8377 mask = &rte_flow_item_raw_mask;
8379 case RTE_FLOW_ITEM_TYPE_ETH:
8380 mask = &rte_flow_item_eth_mask;
8382 case RTE_FLOW_ITEM_TYPE_VLAN:
8383 mask = &rte_flow_item_vlan_mask;
8385 case RTE_FLOW_ITEM_TYPE_IPV4:
8386 mask = &rte_flow_item_ipv4_mask;
8388 case RTE_FLOW_ITEM_TYPE_IPV6:
8389 mask = &rte_flow_item_ipv6_mask;
8391 case RTE_FLOW_ITEM_TYPE_ICMP:
8392 mask = &rte_flow_item_icmp_mask;
8394 case RTE_FLOW_ITEM_TYPE_UDP:
8395 mask = &rte_flow_item_udp_mask;
8397 case RTE_FLOW_ITEM_TYPE_TCP:
8398 mask = &rte_flow_item_tcp_mask;
8400 case RTE_FLOW_ITEM_TYPE_SCTP:
8401 mask = &rte_flow_item_sctp_mask;
8403 case RTE_FLOW_ITEM_TYPE_VXLAN:
8404 mask = &rte_flow_item_vxlan_mask;
8406 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
8407 mask = &rte_flow_item_vxlan_gpe_mask;
8409 case RTE_FLOW_ITEM_TYPE_E_TAG:
8410 mask = &rte_flow_item_e_tag_mask;
8412 case RTE_FLOW_ITEM_TYPE_NVGRE:
8413 mask = &rte_flow_item_nvgre_mask;
8415 case RTE_FLOW_ITEM_TYPE_MPLS:
8416 mask = &rte_flow_item_mpls_mask;
8418 case RTE_FLOW_ITEM_TYPE_GRE:
8419 mask = &rte_flow_item_gre_mask;
8421 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
8422 mask = &gre_key_default_mask;
8424 case RTE_FLOW_ITEM_TYPE_META:
8425 mask = &rte_flow_item_meta_mask;
8427 case RTE_FLOW_ITEM_TYPE_FUZZY:
8428 mask = &rte_flow_item_fuzzy_mask;
8430 case RTE_FLOW_ITEM_TYPE_GTP:
8431 mask = &rte_flow_item_gtp_mask;
8433 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
8434 mask = &rte_flow_item_gtp_psc_mask;
8436 case RTE_FLOW_ITEM_TYPE_GENEVE:
8437 mask = &rte_flow_item_geneve_mask;
8439 case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
8440 mask = &rte_flow_item_geneve_opt_mask;
8442 case RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID:
8443 mask = &rte_flow_item_pppoe_proto_id_mask;
8445 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
8446 mask = &rte_flow_item_l2tpv3oip_mask;
8448 case RTE_FLOW_ITEM_TYPE_ESP:
8449 mask = &rte_flow_item_esp_mask;
8451 case RTE_FLOW_ITEM_TYPE_AH:
8452 mask = &rte_flow_item_ah_mask;
8454 case RTE_FLOW_ITEM_TYPE_PFCP:
8455 mask = &rte_flow_item_pfcp_mask;
8457 case RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR:
8458 case RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT:
8459 mask = &rte_flow_item_ethdev_mask;
8467 /** Dispatch parsed buffer to function calls. */
8469 cmd_set_raw_parsed_sample(const struct buffer *in)
8471 uint32_t n = in->args.vc.actions_n;
8473 struct rte_flow_action *action = NULL;
8474 struct rte_flow_action *data = NULL;
8475 const struct rte_flow_action_rss *rss = NULL;
8477 uint16_t idx = in->port; /* We borrow port field as index */
8478 uint32_t max_size = sizeof(struct rte_flow_action) *
8479 ACTION_SAMPLE_ACTIONS_NUM;
8481 RTE_ASSERT(in->command == SET_SAMPLE_ACTIONS);
8482 data = (struct rte_flow_action *)&raw_sample_confs[idx].data;
8483 memset(data, 0x00, max_size);
8484 for (; i <= n - 1; i++) {
8485 action = in->args.vc.actions + i;
8486 if (action->type == RTE_FLOW_ACTION_TYPE_END)
8488 switch (action->type) {
8489 case RTE_FLOW_ACTION_TYPE_MARK:
8490 size = sizeof(struct rte_flow_action_mark);
8491 rte_memcpy(&sample_mark[idx],
8492 (const void *)action->conf, size);
8493 action->conf = &sample_mark[idx];
8495 case RTE_FLOW_ACTION_TYPE_COUNT:
8496 size = sizeof(struct rte_flow_action_count);
8497 rte_memcpy(&sample_count[idx],
8498 (const void *)action->conf, size);
8499 action->conf = &sample_count[idx];
8501 case RTE_FLOW_ACTION_TYPE_QUEUE:
8502 size = sizeof(struct rte_flow_action_queue);
8503 rte_memcpy(&sample_queue[idx],
8504 (const void *)action->conf, size);
8505 action->conf = &sample_queue[idx];
8507 case RTE_FLOW_ACTION_TYPE_RSS:
8508 size = sizeof(struct rte_flow_action_rss);
8510 rte_memcpy(&sample_rss_data[idx].conf,
8511 (const void *)rss, size);
8512 if (rss->key_len && rss->key) {
8513 sample_rss_data[idx].conf.key =
8514 sample_rss_data[idx].key;
8515 rte_memcpy((void *)((uintptr_t)
8516 sample_rss_data[idx].conf.key),
8517 (const void *)rss->key,
8518 sizeof(uint8_t) * rss->key_len);
8520 if (rss->queue_num && rss->queue) {
8521 sample_rss_data[idx].conf.queue =
8522 sample_rss_data[idx].queue;
8523 rte_memcpy((void *)((uintptr_t)
8524 sample_rss_data[idx].conf.queue),
8525 (const void *)rss->queue,
8526 sizeof(uint16_t) * rss->queue_num);
8528 action->conf = &sample_rss_data[idx].conf;
8530 case RTE_FLOW_ACTION_TYPE_RAW_ENCAP:
8531 size = sizeof(struct rte_flow_action_raw_encap);
8532 rte_memcpy(&sample_encap[idx],
8533 (const void *)action->conf, size);
8534 action->conf = &sample_encap[idx];
8536 case RTE_FLOW_ACTION_TYPE_PORT_ID:
8537 size = sizeof(struct rte_flow_action_port_id);
8538 rte_memcpy(&sample_port_id[idx],
8539 (const void *)action->conf, size);
8540 action->conf = &sample_port_id[idx];
8542 case RTE_FLOW_ACTION_TYPE_PF:
8544 case RTE_FLOW_ACTION_TYPE_VF:
8545 size = sizeof(struct rte_flow_action_vf);
8546 rte_memcpy(&sample_vf[idx],
8547 (const void *)action->conf, size);
8548 action->conf = &sample_vf[idx];
8550 case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP:
8551 size = sizeof(struct rte_flow_action_vxlan_encap);
8552 parse_setup_vxlan_encap_data(&sample_vxlan_encap[idx]);
8553 action->conf = &sample_vxlan_encap[idx].conf;
8555 case RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP:
8556 size = sizeof(struct rte_flow_action_nvgre_encap);
8557 parse_setup_nvgre_encap_data(&sample_nvgre_encap[idx]);
8558 action->conf = &sample_nvgre_encap[idx];
8561 fprintf(stderr, "Error - Not supported action\n");
8564 rte_memcpy(data, action, sizeof(struct rte_flow_action));
8569 /** Dispatch parsed buffer to function calls. */
8571 cmd_set_raw_parsed(const struct buffer *in)
8573 uint32_t n = in->args.vc.pattern_n;
8575 struct rte_flow_item *item = NULL;
8577 uint8_t *data = NULL;
8578 uint8_t *data_tail = NULL;
8579 size_t *total_size = NULL;
8580 uint16_t upper_layer = 0;
8582 uint16_t idx = in->port; /* We borrow port field as index */
8583 int gtp_psc = -1; /* GTP PSC option index. */
8585 if (in->command == SET_SAMPLE_ACTIONS)
8586 return cmd_set_raw_parsed_sample(in);
8587 RTE_ASSERT(in->command == SET_RAW_ENCAP ||
8588 in->command == SET_RAW_DECAP);
8589 if (in->command == SET_RAW_ENCAP) {
8590 total_size = &raw_encap_confs[idx].size;
8591 data = (uint8_t *)&raw_encap_confs[idx].data;
8593 total_size = &raw_decap_confs[idx].size;
8594 data = (uint8_t *)&raw_decap_confs[idx].data;
8597 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
8598 /* process hdr from upper layer to low layer (L3/L4 -> L2). */
8599 data_tail = data + ACTION_RAW_ENCAP_MAX_DATA;
8600 for (i = n - 1 ; i >= 0; --i) {
8601 const struct rte_flow_item_gtp *gtp;
8602 const struct rte_flow_item_geneve_opt *opt;
8604 item = in->args.vc.pattern + i;
8605 if (item->spec == NULL)
8606 item->spec = flow_item_default_mask(item);
8607 switch (item->type) {
8608 case RTE_FLOW_ITEM_TYPE_ETH:
8609 size = sizeof(struct rte_ether_hdr);
8611 case RTE_FLOW_ITEM_TYPE_VLAN:
8612 size = sizeof(struct rte_vlan_hdr);
8613 proto = RTE_ETHER_TYPE_VLAN;
8615 case RTE_FLOW_ITEM_TYPE_IPV4:
8616 size = sizeof(struct rte_ipv4_hdr);
8617 proto = RTE_ETHER_TYPE_IPV4;
8619 case RTE_FLOW_ITEM_TYPE_IPV6:
8620 size = sizeof(struct rte_ipv6_hdr);
8621 proto = RTE_ETHER_TYPE_IPV6;
8623 case RTE_FLOW_ITEM_TYPE_UDP:
8624 size = sizeof(struct rte_udp_hdr);
8627 case RTE_FLOW_ITEM_TYPE_TCP:
8628 size = sizeof(struct rte_tcp_hdr);
8631 case RTE_FLOW_ITEM_TYPE_VXLAN:
8632 size = sizeof(struct rte_vxlan_hdr);
8634 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
8635 size = sizeof(struct rte_vxlan_gpe_hdr);
8637 case RTE_FLOW_ITEM_TYPE_GRE:
8638 size = sizeof(struct rte_gre_hdr);
8641 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
8642 size = sizeof(rte_be32_t);
8645 case RTE_FLOW_ITEM_TYPE_MPLS:
8646 size = sizeof(struct rte_mpls_hdr);
8649 case RTE_FLOW_ITEM_TYPE_NVGRE:
8650 size = sizeof(struct rte_flow_item_nvgre);
8653 case RTE_FLOW_ITEM_TYPE_GENEVE:
8654 size = sizeof(struct rte_geneve_hdr);
8656 case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
8657 opt = (const struct rte_flow_item_geneve_opt *)
8659 size = offsetof(struct rte_flow_item_geneve_opt, data);
8660 if (opt->option_len && opt->data) {
8661 *total_size += opt->option_len *
8663 rte_memcpy(data_tail - (*total_size),
8665 opt->option_len * sizeof(uint32_t));
8668 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
8669 size = sizeof(rte_be32_t);
8672 case RTE_FLOW_ITEM_TYPE_ESP:
8673 size = sizeof(struct rte_esp_hdr);
8676 case RTE_FLOW_ITEM_TYPE_AH:
8677 size = sizeof(struct rte_flow_item_ah);
8680 case RTE_FLOW_ITEM_TYPE_GTP:
8682 size = sizeof(struct rte_gtp_hdr);
8685 if (gtp_psc != i + 1) {
8687 "Error - GTP PSC does not follow GTP\n");
8691 if ((gtp->v_pt_rsv_flags & 0x07) != 0x04) {
8692 /* Only E flag should be set. */
8694 "Error - GTP unsupported flags\n");
8697 struct rte_gtp_hdr_ext_word ext_word = {
8701 /* We have to add GTP header extra word. */
8702 *total_size += sizeof(ext_word);
8703 rte_memcpy(data_tail - (*total_size),
8704 &ext_word, sizeof(ext_word));
8706 size = sizeof(struct rte_gtp_hdr);
8708 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
8711 "Error - Multiple GTP PSC items\n");
8714 const struct rte_flow_item_gtp_psc
8722 psc.len = sizeof(psc);
8723 psc.pdu_type = opt->hdr.type;
8724 psc.qfi = opt->hdr.qfi;
8726 *total_size += sizeof(psc);
8727 rte_memcpy(data_tail - (*total_size),
8733 case RTE_FLOW_ITEM_TYPE_PFCP:
8734 size = sizeof(struct rte_flow_item_pfcp);
8737 fprintf(stderr, "Error - Not supported item\n");
8740 *total_size += size;
8741 rte_memcpy(data_tail - (*total_size), item->spec, size);
8742 /* update some fields which cannot be set by cmdline */
8743 update_fields((data_tail - (*total_size)), item,
8745 upper_layer = proto;
8747 if (verbose_level & 0x1)
8748 printf("total data size is %zu\n", (*total_size));
8749 RTE_ASSERT((*total_size) <= ACTION_RAW_ENCAP_MAX_DATA);
8750 memmove(data, (data_tail - (*total_size)), *total_size);
8755 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
8758 /** Populate help strings for current token (cmdline API). */
8760 cmd_set_raw_get_help(cmdline_parse_token_hdr_t *hdr, char *dst,
8763 struct context *ctx = &cmd_flow_context;
8764 const struct token *token = &token_list[ctx->prev];
8769 /* Set token type and update global help with details. */
8770 snprintf(dst, size, "%s", (token->type ? token->type : "TOKEN"));
8772 cmd_set_raw.help_str = token->help;
8774 cmd_set_raw.help_str = token->name;
8778 /** Token definition template (cmdline API). */
8779 static struct cmdline_token_hdr cmd_set_raw_token_hdr = {
8780 .ops = &(struct cmdline_token_ops){
8781 .parse = cmd_flow_parse,
8782 .complete_get_nb = cmd_flow_complete_get_nb,
8783 .complete_get_elt = cmd_flow_complete_get_elt,
8784 .get_help = cmd_set_raw_get_help,
8789 /** Populate the next dynamic token. */
8791 cmd_set_raw_tok(cmdline_parse_token_hdr_t **hdr,
8792 cmdline_parse_token_hdr_t **hdr_inst)
8794 struct context *ctx = &cmd_flow_context;
8796 /* Always reinitialize context before requesting the first token. */
8797 if (!(hdr_inst - cmd_set_raw.tokens)) {
8798 cmd_flow_context_init(ctx);
8799 ctx->curr = START_SET;
8801 /* Return NULL when no more tokens are expected. */
8802 if (!ctx->next_num && (ctx->curr != START_SET)) {
8806 /* Determine if command should end here. */
8807 if (ctx->eol && ctx->last && ctx->next_num) {
8808 const enum index *list = ctx->next[ctx->next_num - 1];
8811 for (i = 0; list[i]; ++i) {
8818 *hdr = &cmd_set_raw_token_hdr;
8821 /** Token generator and output processing callback (cmdline API). */
8823 cmd_set_raw_cb(void *arg0, struct cmdline *cl, void *arg2)
8826 cmd_set_raw_tok(arg0, arg2);
8828 cmd_set_raw_parsed(arg0);
8831 /** Global parser instance (cmdline API). */
8832 cmdline_parse_inst_t cmd_set_raw = {
8833 .f = cmd_set_raw_cb,
8834 .data = NULL, /**< Unused. */
8835 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
8838 }, /**< Tokens are returned by cmd_flow_tok(). */
8841 /* *** display raw_encap/raw_decap buf */
8842 struct cmd_show_set_raw_result {
8843 cmdline_fixed_string_t cmd_show;
8844 cmdline_fixed_string_t cmd_what;
8845 cmdline_fixed_string_t cmd_all;
8850 cmd_show_set_raw_parsed(void *parsed_result, struct cmdline *cl, void *data)
8852 struct cmd_show_set_raw_result *res = parsed_result;
8853 uint16_t index = res->cmd_index;
8855 uint8_t *raw_data = NULL;
8856 size_t raw_size = 0;
8857 char title[16] = {0};
8861 if (!strcmp(res->cmd_all, "all")) {
8864 } else if (index >= RAW_ENCAP_CONFS_MAX_NUM) {
8865 fprintf(stderr, "index should be 0-%u\n",
8866 RAW_ENCAP_CONFS_MAX_NUM - 1);
8870 if (!strcmp(res->cmd_what, "raw_encap")) {
8871 raw_data = (uint8_t *)&raw_encap_confs[index].data;
8872 raw_size = raw_encap_confs[index].size;
8873 snprintf(title, 16, "\nindex: %u", index);
8874 rte_hexdump(stdout, title, raw_data, raw_size);
8876 raw_data = (uint8_t *)&raw_decap_confs[index].data;
8877 raw_size = raw_decap_confs[index].size;
8878 snprintf(title, 16, "\nindex: %u", index);
8879 rte_hexdump(stdout, title, raw_data, raw_size);
8881 } while (all && ++index < RAW_ENCAP_CONFS_MAX_NUM);
8884 cmdline_parse_token_string_t cmd_show_set_raw_cmd_show =
8885 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
8887 cmdline_parse_token_string_t cmd_show_set_raw_cmd_what =
8888 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
8889 cmd_what, "raw_encap#raw_decap");
8890 cmdline_parse_token_num_t cmd_show_set_raw_cmd_index =
8891 TOKEN_NUM_INITIALIZER(struct cmd_show_set_raw_result,
8892 cmd_index, RTE_UINT16);
8893 cmdline_parse_token_string_t cmd_show_set_raw_cmd_all =
8894 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
8896 cmdline_parse_inst_t cmd_show_set_raw = {
8897 .f = cmd_show_set_raw_parsed,
8899 .help_str = "show <raw_encap|raw_decap> <index>",
8901 (void *)&cmd_show_set_raw_cmd_show,
8902 (void *)&cmd_show_set_raw_cmd_what,
8903 (void *)&cmd_show_set_raw_cmd_index,
8907 cmdline_parse_inst_t cmd_show_set_raw_all = {
8908 .f = cmd_show_set_raw_parsed,
8910 .help_str = "show <raw_encap|raw_decap> all",
8912 (void *)&cmd_show_set_raw_cmd_show,
8913 (void *)&cmd_show_set_raw_cmd_what,
8914 (void *)&cmd_show_set_raw_cmd_all,