1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2016 6WIND S.A.
3 * Copyright 2016 Mellanox Technologies, Ltd
13 #include <arpa/inet.h>
14 #include <sys/socket.h>
16 #include <rte_string_fns.h>
17 #include <rte_common.h>
18 #include <rte_ethdev.h>
19 #include <rte_byteorder.h>
20 #include <cmdline_parse.h>
21 #include <cmdline_parse_etheraddr.h>
22 #include <cmdline_parse_string.h>
23 #include <cmdline_parse_num.h>
25 #include <rte_hexdump.h>
26 #include <rte_vxlan.h>
30 #include <rte_geneve.h>
34 /** Parser token indices. */
59 /* Top-level command. */
61 /* Sub-leve commands. */
68 /* Top-level command. */
70 /* Sub-level commands. */
83 /* Tunnel arguments. */
90 /* Destroy arguments. */
93 /* Query arguments. */
99 /* Destroy aged flow arguments. */
102 /* Validate/create arguments. */
115 /* Indirect action arguments */
116 INDIRECT_ACTION_CREATE,
117 INDIRECT_ACTION_UPDATE,
118 INDIRECT_ACTION_DESTROY,
119 INDIRECT_ACTION_QUERY,
121 /* Indirect action create arguments */
122 INDIRECT_ACTION_CREATE_ID,
123 INDIRECT_ACTION_INGRESS,
124 INDIRECT_ACTION_EGRESS,
125 INDIRECT_ACTION_TRANSFER,
126 INDIRECT_ACTION_SPEC,
128 /* Indirect action destroy arguments */
129 INDIRECT_ACTION_DESTROY_ID,
131 /* Validate/create pattern. */
169 ITEM_VLAN_INNER_TYPE,
170 ITEM_VLAN_HAS_MORE_VLAN,
173 ITEM_IPV4_FRAGMENT_OFFSET,
185 ITEM_IPV6_HAS_FRAG_EXT,
206 ITEM_E_TAG_GRP_ECID_B,
215 ITEM_GRE_C_RSVD0_VER,
234 ITEM_ARP_ETH_IPV4_SHA,
235 ITEM_ARP_ETH_IPV4_SPA,
236 ITEM_ARP_ETH_IPV4_THA,
237 ITEM_ARP_ETH_IPV4_TPA,
239 ITEM_IPV6_EXT_NEXT_HDR,
241 ITEM_IPV6_FRAG_EXT_NEXT_HDR,
242 ITEM_IPV6_FRAG_EXT_FRAG_DATA,
247 ITEM_ICMP6_ND_NS_TARGET_ADDR,
249 ITEM_ICMP6_ND_NA_TARGET_ADDR,
251 ITEM_ICMP6_ND_OPT_TYPE,
252 ITEM_ICMP6_ND_OPT_SLA_ETH,
253 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
254 ITEM_ICMP6_ND_OPT_TLA_ETH,
255 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
268 ITEM_HIGIG2_CLASSIFICATION,
274 ITEM_L2TPV3OIP_SESSION_ID,
284 ITEM_ECPRI_COMMON_TYPE,
285 ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
286 ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
287 ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
288 ITEM_ECPRI_MSG_IQ_DATA_PCID,
289 ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
290 ITEM_ECPRI_MSG_DLY_MSR_MSRID,
292 ITEM_GENEVE_OPT_CLASS,
293 ITEM_GENEVE_OPT_TYPE,
294 ITEM_GENEVE_OPT_LENGTH,
295 ITEM_GENEVE_OPT_DATA,
297 ITEM_INTEGRITY_LEVEL,
298 ITEM_INTEGRITY_VALUE,
300 /* Validate/create actions. */
320 ACTION_RSS_FUNC_DEFAULT,
321 ACTION_RSS_FUNC_TOEPLITZ,
322 ACTION_RSS_FUNC_SIMPLE_XOR,
323 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ,
335 ACTION_PHY_PORT_ORIGINAL,
336 ACTION_PHY_PORT_INDEX,
338 ACTION_PORT_ID_ORIGINAL,
342 ACTION_OF_SET_MPLS_TTL,
343 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
344 ACTION_OF_DEC_MPLS_TTL,
345 ACTION_OF_SET_NW_TTL,
346 ACTION_OF_SET_NW_TTL_NW_TTL,
347 ACTION_OF_DEC_NW_TTL,
348 ACTION_OF_COPY_TTL_OUT,
349 ACTION_OF_COPY_TTL_IN,
352 ACTION_OF_PUSH_VLAN_ETHERTYPE,
353 ACTION_OF_SET_VLAN_VID,
354 ACTION_OF_SET_VLAN_VID_VLAN_VID,
355 ACTION_OF_SET_VLAN_PCP,
356 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
358 ACTION_OF_POP_MPLS_ETHERTYPE,
360 ACTION_OF_PUSH_MPLS_ETHERTYPE,
367 ACTION_MPLSOGRE_ENCAP,
368 ACTION_MPLSOGRE_DECAP,
369 ACTION_MPLSOUDP_ENCAP,
370 ACTION_MPLSOUDP_DECAP,
372 ACTION_SET_IPV4_SRC_IPV4_SRC,
374 ACTION_SET_IPV4_DST_IPV4_DST,
376 ACTION_SET_IPV6_SRC_IPV6_SRC,
378 ACTION_SET_IPV6_DST_IPV6_DST,
380 ACTION_SET_TP_SRC_TP_SRC,
382 ACTION_SET_TP_DST_TP_DST,
388 ACTION_SET_MAC_SRC_MAC_SRC,
390 ACTION_SET_MAC_DST_MAC_DST,
392 ACTION_INC_TCP_SEQ_VALUE,
394 ACTION_DEC_TCP_SEQ_VALUE,
396 ACTION_INC_TCP_ACK_VALUE,
398 ACTION_DEC_TCP_ACK_VALUE,
401 ACTION_RAW_ENCAP_INDEX,
402 ACTION_RAW_ENCAP_INDEX_VALUE,
403 ACTION_RAW_DECAP_INDEX,
404 ACTION_RAW_DECAP_INDEX_VALUE,
407 ACTION_SET_TAG_INDEX,
410 ACTION_SET_META_DATA,
411 ACTION_SET_META_MASK,
412 ACTION_SET_IPV4_DSCP,
413 ACTION_SET_IPV4_DSCP_VALUE,
414 ACTION_SET_IPV6_DSCP,
415 ACTION_SET_IPV6_DSCP_VALUE,
421 ACTION_SAMPLE_INDEX_VALUE,
423 INDIRECT_ACTION_ID2PTR,
425 ACTION_MODIFY_FIELD_OP,
426 ACTION_MODIFY_FIELD_OP_VALUE,
427 ACTION_MODIFY_FIELD_DST_TYPE,
428 ACTION_MODIFY_FIELD_DST_TYPE_VALUE,
429 ACTION_MODIFY_FIELD_DST_LEVEL,
430 ACTION_MODIFY_FIELD_DST_OFFSET,
431 ACTION_MODIFY_FIELD_SRC_TYPE,
432 ACTION_MODIFY_FIELD_SRC_TYPE_VALUE,
433 ACTION_MODIFY_FIELD_SRC_LEVEL,
434 ACTION_MODIFY_FIELD_SRC_OFFSET,
435 ACTION_MODIFY_FIELD_SRC_VALUE,
436 ACTION_MODIFY_FIELD_WIDTH,
439 /** Maximum size for pattern in struct rte_flow_item_raw. */
440 #define ITEM_RAW_PATTERN_SIZE 40
442 /** Maximum size for GENEVE option data pattern in bytes. */
443 #define ITEM_GENEVE_OPT_DATA_SIZE 124
445 /** Storage size for struct rte_flow_item_raw including pattern. */
446 #define ITEM_RAW_SIZE \
447 (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE)
449 /** Maximum number of queue indices in struct rte_flow_action_rss. */
450 #define ACTION_RSS_QUEUE_NUM 128
452 /** Storage for struct rte_flow_action_rss including external data. */
453 struct action_rss_data {
454 struct rte_flow_action_rss conf;
455 uint8_t key[RSS_HASH_KEY_LENGTH];
456 uint16_t queue[ACTION_RSS_QUEUE_NUM];
459 /** Maximum data size in struct rte_flow_action_raw_encap. */
460 #define ACTION_RAW_ENCAP_MAX_DATA 512
461 #define RAW_ENCAP_CONFS_MAX_NUM 8
463 /** Storage for struct rte_flow_action_raw_encap. */
464 struct raw_encap_conf {
465 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
466 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
470 struct raw_encap_conf raw_encap_confs[RAW_ENCAP_CONFS_MAX_NUM];
472 /** Storage for struct rte_flow_action_raw_encap including external data. */
473 struct action_raw_encap_data {
474 struct rte_flow_action_raw_encap conf;
475 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
476 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
480 /** Storage for struct rte_flow_action_raw_decap. */
481 struct raw_decap_conf {
482 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
486 struct raw_decap_conf raw_decap_confs[RAW_ENCAP_CONFS_MAX_NUM];
488 /** Storage for struct rte_flow_action_raw_decap including external data. */
489 struct action_raw_decap_data {
490 struct rte_flow_action_raw_decap conf;
491 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
495 struct vxlan_encap_conf vxlan_encap_conf = {
499 .vni = "\x00\x00\x00",
501 .udp_dst = RTE_BE16(RTE_VXLAN_DEFAULT_PORT),
502 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
503 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
504 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
505 "\x00\x00\x00\x00\x00\x00\x00\x01",
506 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
507 "\x00\x00\x00\x00\x00\x00\x11\x11",
511 .eth_src = "\x00\x00\x00\x00\x00\x00",
512 .eth_dst = "\xff\xff\xff\xff\xff\xff",
515 /** Maximum number of items in struct rte_flow_action_vxlan_encap. */
516 #define ACTION_VXLAN_ENCAP_ITEMS_NUM 6
518 /** Storage for struct rte_flow_action_vxlan_encap including external data. */
519 struct action_vxlan_encap_data {
520 struct rte_flow_action_vxlan_encap conf;
521 struct rte_flow_item items[ACTION_VXLAN_ENCAP_ITEMS_NUM];
522 struct rte_flow_item_eth item_eth;
523 struct rte_flow_item_vlan item_vlan;
525 struct rte_flow_item_ipv4 item_ipv4;
526 struct rte_flow_item_ipv6 item_ipv6;
528 struct rte_flow_item_udp item_udp;
529 struct rte_flow_item_vxlan item_vxlan;
532 struct nvgre_encap_conf nvgre_encap_conf = {
535 .tni = "\x00\x00\x00",
536 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
537 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
538 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
539 "\x00\x00\x00\x00\x00\x00\x00\x01",
540 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
541 "\x00\x00\x00\x00\x00\x00\x11\x11",
543 .eth_src = "\x00\x00\x00\x00\x00\x00",
544 .eth_dst = "\xff\xff\xff\xff\xff\xff",
547 /** Maximum number of items in struct rte_flow_action_nvgre_encap. */
548 #define ACTION_NVGRE_ENCAP_ITEMS_NUM 5
550 /** Storage for struct rte_flow_action_nvgre_encap including external data. */
551 struct action_nvgre_encap_data {
552 struct rte_flow_action_nvgre_encap conf;
553 struct rte_flow_item items[ACTION_NVGRE_ENCAP_ITEMS_NUM];
554 struct rte_flow_item_eth item_eth;
555 struct rte_flow_item_vlan item_vlan;
557 struct rte_flow_item_ipv4 item_ipv4;
558 struct rte_flow_item_ipv6 item_ipv6;
560 struct rte_flow_item_nvgre item_nvgre;
563 struct l2_encap_conf l2_encap_conf;
565 struct l2_decap_conf l2_decap_conf;
567 struct mplsogre_encap_conf mplsogre_encap_conf;
569 struct mplsogre_decap_conf mplsogre_decap_conf;
571 struct mplsoudp_encap_conf mplsoudp_encap_conf;
573 struct mplsoudp_decap_conf mplsoudp_decap_conf;
575 #define ACTION_SAMPLE_ACTIONS_NUM 10
576 #define RAW_SAMPLE_CONFS_MAX_NUM 8
577 /** Storage for struct rte_flow_action_sample including external data. */
578 struct action_sample_data {
579 struct rte_flow_action_sample conf;
582 /** Storage for struct rte_flow_action_sample. */
583 struct raw_sample_conf {
584 struct rte_flow_action data[ACTION_SAMPLE_ACTIONS_NUM];
586 struct raw_sample_conf raw_sample_confs[RAW_SAMPLE_CONFS_MAX_NUM];
587 struct rte_flow_action_mark sample_mark[RAW_SAMPLE_CONFS_MAX_NUM];
588 struct rte_flow_action_queue sample_queue[RAW_SAMPLE_CONFS_MAX_NUM];
589 struct rte_flow_action_count sample_count[RAW_SAMPLE_CONFS_MAX_NUM];
590 struct rte_flow_action_port_id sample_port_id[RAW_SAMPLE_CONFS_MAX_NUM];
591 struct rte_flow_action_raw_encap sample_encap[RAW_SAMPLE_CONFS_MAX_NUM];
592 struct action_vxlan_encap_data sample_vxlan_encap[RAW_SAMPLE_CONFS_MAX_NUM];
593 struct action_nvgre_encap_data sample_nvgre_encap[RAW_SAMPLE_CONFS_MAX_NUM];
594 struct action_rss_data sample_rss_data[RAW_SAMPLE_CONFS_MAX_NUM];
595 struct rte_flow_action_vf sample_vf[RAW_SAMPLE_CONFS_MAX_NUM];
597 static const char *const modify_field_ops[] = {
598 "set", "add", "sub", NULL
601 static const char *const modify_field_ids[] = {
602 "start", "mac_dst", "mac_src",
603 "vlan_type", "vlan_id", "mac_type",
604 "ipv4_dscp", "ipv4_ttl", "ipv4_src", "ipv4_dst",
605 "ipv6_dscp", "ipv6_hoplimit", "ipv6_src", "ipv6_dst",
606 "tcp_port_src", "tcp_port_dst",
607 "tcp_seq_num", "tcp_ack_num", "tcp_flags",
608 "udp_port_src", "udp_port_dst",
609 "vxlan_vni", "geneve_vni", "gtp_teid",
610 "tag", "mark", "meta", "pointer", "value", NULL
613 /** Maximum number of subsequent tokens and arguments on the stack. */
614 #define CTX_STACK_SIZE 16
616 /** Parser context. */
618 /** Stack of subsequent token lists to process. */
619 const enum index *next[CTX_STACK_SIZE];
620 /** Arguments for stacked tokens. */
621 const void *args[CTX_STACK_SIZE];
622 enum index curr; /**< Current token index. */
623 enum index prev; /**< Index of the last token seen. */
624 int next_num; /**< Number of entries in next[]. */
625 int args_num; /**< Number of entries in args[]. */
626 uint32_t eol:1; /**< EOL has been detected. */
627 uint32_t last:1; /**< No more arguments. */
628 portid_t port; /**< Current port ID (for completions). */
629 uint32_t objdata; /**< Object-specific data. */
630 void *object; /**< Address of current object for relative offsets. */
631 void *objmask; /**< Object a full mask must be written to. */
634 /** Token argument. */
636 uint32_t hton:1; /**< Use network byte ordering. */
637 uint32_t sign:1; /**< Value is signed. */
638 uint32_t bounded:1; /**< Value is bounded. */
639 uintmax_t min; /**< Minimum value if bounded. */
640 uintmax_t max; /**< Maximum value if bounded. */
641 uint32_t offset; /**< Relative offset from ctx->object. */
642 uint32_t size; /**< Field size. */
643 const uint8_t *mask; /**< Bit-mask to use instead of offset/size. */
646 /** Parser token definition. */
648 /** Type displayed during completion (defaults to "TOKEN"). */
650 /** Help displayed during completion (defaults to token name). */
652 /** Private data used by parser functions. */
655 * Lists of subsequent tokens to push on the stack. Each call to the
656 * parser consumes the last entry of that stack.
658 const enum index *const *next;
659 /** Arguments stack for subsequent tokens that need them. */
660 const struct arg *const *args;
662 * Token-processing callback, returns -1 in case of error, the
663 * length of the matched string otherwise. If NULL, attempts to
664 * match the token name.
666 * If buf is not NULL, the result should be stored in it according
667 * to context. An error is returned if not large enough.
669 int (*call)(struct context *ctx, const struct token *token,
670 const char *str, unsigned int len,
671 void *buf, unsigned int size);
673 * Callback that provides possible values for this token, used for
674 * completion. Returns -1 in case of error, the number of possible
675 * values otherwise. If NULL, the token name is used.
677 * If buf is not NULL, entry index ent is written to buf and the
678 * full length of the entry is returned (same behavior as
681 int (*comp)(struct context *ctx, const struct token *token,
682 unsigned int ent, char *buf, unsigned int size);
683 /** Mandatory token name, no default value. */
687 /** Static initializer for the next field. */
688 #define NEXT(...) (const enum index *const []){ __VA_ARGS__, NULL, }
690 /** Static initializer for a NEXT() entry. */
691 #define NEXT_ENTRY(...) (const enum index []){ __VA_ARGS__, ZERO, }
693 /** Static initializer for the args field. */
694 #define ARGS(...) (const struct arg *const []){ __VA_ARGS__, NULL, }
696 /** Static initializer for ARGS() to target a field. */
697 #define ARGS_ENTRY(s, f) \
698 (&(const struct arg){ \
699 .offset = offsetof(s, f), \
700 .size = sizeof(((s *)0)->f), \
703 /** Static initializer for ARGS() to target a bit-field. */
704 #define ARGS_ENTRY_BF(s, f, b) \
705 (&(const struct arg){ \
707 .mask = (const void *)&(const s){ .f = (1 << (b)) - 1 }, \
710 /** Static initializer for ARGS() to target a field with limits. */
711 #define ARGS_ENTRY_BOUNDED(s, f, i, a) \
712 (&(const struct arg){ \
716 .offset = offsetof(s, f), \
717 .size = sizeof(((s *)0)->f), \
720 /** Static initializer for ARGS() to target an arbitrary bit-mask. */
721 #define ARGS_ENTRY_MASK(s, f, m) \
722 (&(const struct arg){ \
723 .offset = offsetof(s, f), \
724 .size = sizeof(((s *)0)->f), \
725 .mask = (const void *)(m), \
728 /** Same as ARGS_ENTRY_MASK() using network byte ordering for the value. */
729 #define ARGS_ENTRY_MASK_HTON(s, f, m) \
730 (&(const struct arg){ \
732 .offset = offsetof(s, f), \
733 .size = sizeof(((s *)0)->f), \
734 .mask = (const void *)(m), \
737 /** Static initializer for ARGS() to target a pointer. */
738 #define ARGS_ENTRY_PTR(s, f) \
739 (&(const struct arg){ \
740 .size = sizeof(*((s *)0)->f), \
743 /** Static initializer for ARGS() with arbitrary offset and size. */
744 #define ARGS_ENTRY_ARB(o, s) \
745 (&(const struct arg){ \
750 /** Same as ARGS_ENTRY_ARB() with bounded values. */
751 #define ARGS_ENTRY_ARB_BOUNDED(o, s, i, a) \
752 (&(const struct arg){ \
760 /** Same as ARGS_ENTRY() using network byte ordering. */
761 #define ARGS_ENTRY_HTON(s, f) \
762 (&(const struct arg){ \
764 .offset = offsetof(s, f), \
765 .size = sizeof(((s *)0)->f), \
768 /** Same as ARGS_ENTRY_HTON() for a single argument, without structure. */
769 #define ARG_ENTRY_HTON(s) \
770 (&(const struct arg){ \
776 /** Parser output buffer layout expected by cmd_flow_parsed(). */
778 enum index command; /**< Flow command. */
779 portid_t port; /**< Affected port ID. */
783 uint32_t action_id_n;
784 } ia_destroy; /**< Indirect action destroy arguments. */
787 } ia; /* Indirect action query arguments */
789 struct rte_flow_attr attr;
790 struct tunnel_ops tunnel_ops;
791 struct rte_flow_item *pattern;
792 struct rte_flow_action *actions;
796 } vc; /**< Validate/create arguments. */
800 } destroy; /**< Destroy arguments. */
805 } dump; /**< Dump arguments. */
808 struct rte_flow_action action;
809 } query; /**< Query arguments. */
813 } list; /**< List arguments. */
816 } isolate; /**< Isolated mode arguments. */
819 } aged; /**< Aged arguments. */
820 } args; /**< Command arguments. */
823 /** Private data for pattern items. */
824 struct parse_item_priv {
825 enum rte_flow_item_type type; /**< Item type. */
826 uint32_t size; /**< Size of item specification structure. */
829 #define PRIV_ITEM(t, s) \
830 (&(const struct parse_item_priv){ \
831 .type = RTE_FLOW_ITEM_TYPE_ ## t, \
835 /** Private data for actions. */
836 struct parse_action_priv {
837 enum rte_flow_action_type type; /**< Action type. */
838 uint32_t size; /**< Size of action configuration structure. */
841 #define PRIV_ACTION(t, s) \
842 (&(const struct parse_action_priv){ \
843 .type = RTE_FLOW_ACTION_TYPE_ ## t, \
847 static const enum index next_ia_create_attr[] = {
848 INDIRECT_ACTION_CREATE_ID,
849 INDIRECT_ACTION_INGRESS,
850 INDIRECT_ACTION_EGRESS,
851 INDIRECT_ACTION_TRANSFER,
852 INDIRECT_ACTION_SPEC,
856 static const enum index next_dump_subcmd[] = {
862 static const enum index next_ia_subcmd[] = {
863 INDIRECT_ACTION_CREATE,
864 INDIRECT_ACTION_UPDATE,
865 INDIRECT_ACTION_DESTROY,
866 INDIRECT_ACTION_QUERY,
870 static const enum index next_vc_attr[] = {
882 static const enum index next_destroy_attr[] = {
888 static const enum index next_dump_attr[] = {
894 static const enum index next_list_attr[] = {
900 static const enum index next_aged_attr[] = {
906 static const enum index next_ia_destroy_attr[] = {
907 INDIRECT_ACTION_DESTROY_ID,
912 static const enum index item_param[] = {
921 static const enum index next_item[] = {
958 ITEM_ICMP6_ND_OPT_SLA_ETH,
959 ITEM_ICMP6_ND_OPT_TLA_ETH,
979 static const enum index item_fuzzy[] = {
985 static const enum index item_any[] = {
991 static const enum index item_vf[] = {
997 static const enum index item_phy_port[] = {
1003 static const enum index item_port_id[] = {
1009 static const enum index item_mark[] = {
1015 static const enum index item_raw[] = {
1025 static const enum index item_eth[] = {
1034 static const enum index item_vlan[] = {
1039 ITEM_VLAN_INNER_TYPE,
1040 ITEM_VLAN_HAS_MORE_VLAN,
1045 static const enum index item_ipv4[] = {
1047 ITEM_IPV4_FRAGMENT_OFFSET,
1056 static const enum index item_ipv6[] = {
1063 ITEM_IPV6_HAS_FRAG_EXT,
1068 static const enum index item_icmp[] = {
1077 static const enum index item_udp[] = {
1084 static const enum index item_tcp[] = {
1092 static const enum index item_sctp[] = {
1101 static const enum index item_vxlan[] = {
1107 static const enum index item_e_tag[] = {
1108 ITEM_E_TAG_GRP_ECID_B,
1113 static const enum index item_nvgre[] = {
1119 static const enum index item_mpls[] = {
1127 static const enum index item_gre[] = {
1129 ITEM_GRE_C_RSVD0_VER,
1137 static const enum index item_gre_key[] = {
1143 static const enum index item_gtp[] = {
1151 static const enum index item_geneve[] = {
1159 static const enum index item_vxlan_gpe[] = {
1165 static const enum index item_arp_eth_ipv4[] = {
1166 ITEM_ARP_ETH_IPV4_SHA,
1167 ITEM_ARP_ETH_IPV4_SPA,
1168 ITEM_ARP_ETH_IPV4_THA,
1169 ITEM_ARP_ETH_IPV4_TPA,
1174 static const enum index item_ipv6_ext[] = {
1175 ITEM_IPV6_EXT_NEXT_HDR,
1180 static const enum index item_ipv6_frag_ext[] = {
1181 ITEM_IPV6_FRAG_EXT_NEXT_HDR,
1182 ITEM_IPV6_FRAG_EXT_FRAG_DATA,
1187 static const enum index item_icmp6[] = {
1194 static const enum index item_icmp6_nd_ns[] = {
1195 ITEM_ICMP6_ND_NS_TARGET_ADDR,
1200 static const enum index item_icmp6_nd_na[] = {
1201 ITEM_ICMP6_ND_NA_TARGET_ADDR,
1206 static const enum index item_icmp6_nd_opt[] = {
1207 ITEM_ICMP6_ND_OPT_TYPE,
1212 static const enum index item_icmp6_nd_opt_sla_eth[] = {
1213 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
1218 static const enum index item_icmp6_nd_opt_tla_eth[] = {
1219 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
1224 static const enum index item_meta[] = {
1230 static const enum index item_gtp_psc[] = {
1237 static const enum index item_pppoed[] = {
1243 static const enum index item_pppoes[] = {
1249 static const enum index item_pppoe_proto_id[] = {
1254 static const enum index item_higig2[] = {
1255 ITEM_HIGIG2_CLASSIFICATION,
1261 static const enum index item_esp[] = {
1267 static const enum index item_ah[] = {
1273 static const enum index item_pfcp[] = {
1280 static const enum index next_set_raw[] = {
1286 static const enum index item_tag[] = {
1293 static const enum index item_l2tpv3oip[] = {
1294 ITEM_L2TPV3OIP_SESSION_ID,
1299 static const enum index item_ecpri[] = {
1305 static const enum index item_ecpri_common[] = {
1306 ITEM_ECPRI_COMMON_TYPE,
1310 static const enum index item_ecpri_common_type[] = {
1311 ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
1312 ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
1313 ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
1317 static const enum index item_geneve_opt[] = {
1318 ITEM_GENEVE_OPT_CLASS,
1319 ITEM_GENEVE_OPT_TYPE,
1320 ITEM_GENEVE_OPT_LENGTH,
1321 ITEM_GENEVE_OPT_DATA,
1326 static const enum index item_integrity[] = {
1327 ITEM_INTEGRITY_LEVEL,
1328 ITEM_INTEGRITY_VALUE,
1332 static const enum index item_integrity_lv[] = {
1333 ITEM_INTEGRITY_LEVEL,
1334 ITEM_INTEGRITY_VALUE,
1339 static const enum index next_action[] = {
1355 ACTION_OF_SET_MPLS_TTL,
1356 ACTION_OF_DEC_MPLS_TTL,
1357 ACTION_OF_SET_NW_TTL,
1358 ACTION_OF_DEC_NW_TTL,
1359 ACTION_OF_COPY_TTL_OUT,
1360 ACTION_OF_COPY_TTL_IN,
1362 ACTION_OF_PUSH_VLAN,
1363 ACTION_OF_SET_VLAN_VID,
1364 ACTION_OF_SET_VLAN_PCP,
1366 ACTION_OF_PUSH_MPLS,
1373 ACTION_MPLSOGRE_ENCAP,
1374 ACTION_MPLSOGRE_DECAP,
1375 ACTION_MPLSOUDP_ENCAP,
1376 ACTION_MPLSOUDP_DECAP,
1377 ACTION_SET_IPV4_SRC,
1378 ACTION_SET_IPV4_DST,
1379 ACTION_SET_IPV6_SRC,
1380 ACTION_SET_IPV6_DST,
1396 ACTION_SET_IPV4_DSCP,
1397 ACTION_SET_IPV6_DSCP,
1401 ACTION_MODIFY_FIELD,
1405 static const enum index action_mark[] = {
1411 static const enum index action_queue[] = {
1417 static const enum index action_count[] = {
1419 ACTION_COUNT_SHARED,
1424 static const enum index action_rss[] = {
1435 static const enum index action_vf[] = {
1442 static const enum index action_phy_port[] = {
1443 ACTION_PHY_PORT_ORIGINAL,
1444 ACTION_PHY_PORT_INDEX,
1449 static const enum index action_port_id[] = {
1450 ACTION_PORT_ID_ORIGINAL,
1456 static const enum index action_meter[] = {
1462 static const enum index action_of_set_mpls_ttl[] = {
1463 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
1468 static const enum index action_of_set_nw_ttl[] = {
1469 ACTION_OF_SET_NW_TTL_NW_TTL,
1474 static const enum index action_of_push_vlan[] = {
1475 ACTION_OF_PUSH_VLAN_ETHERTYPE,
1480 static const enum index action_of_set_vlan_vid[] = {
1481 ACTION_OF_SET_VLAN_VID_VLAN_VID,
1486 static const enum index action_of_set_vlan_pcp[] = {
1487 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
1492 static const enum index action_of_pop_mpls[] = {
1493 ACTION_OF_POP_MPLS_ETHERTYPE,
1498 static const enum index action_of_push_mpls[] = {
1499 ACTION_OF_PUSH_MPLS_ETHERTYPE,
1504 static const enum index action_set_ipv4_src[] = {
1505 ACTION_SET_IPV4_SRC_IPV4_SRC,
1510 static const enum index action_set_mac_src[] = {
1511 ACTION_SET_MAC_SRC_MAC_SRC,
1516 static const enum index action_set_ipv4_dst[] = {
1517 ACTION_SET_IPV4_DST_IPV4_DST,
1522 static const enum index action_set_ipv6_src[] = {
1523 ACTION_SET_IPV6_SRC_IPV6_SRC,
1528 static const enum index action_set_ipv6_dst[] = {
1529 ACTION_SET_IPV6_DST_IPV6_DST,
1534 static const enum index action_set_tp_src[] = {
1535 ACTION_SET_TP_SRC_TP_SRC,
1540 static const enum index action_set_tp_dst[] = {
1541 ACTION_SET_TP_DST_TP_DST,
1546 static const enum index action_set_ttl[] = {
1552 static const enum index action_jump[] = {
1558 static const enum index action_set_mac_dst[] = {
1559 ACTION_SET_MAC_DST_MAC_DST,
1564 static const enum index action_inc_tcp_seq[] = {
1565 ACTION_INC_TCP_SEQ_VALUE,
1570 static const enum index action_dec_tcp_seq[] = {
1571 ACTION_DEC_TCP_SEQ_VALUE,
1576 static const enum index action_inc_tcp_ack[] = {
1577 ACTION_INC_TCP_ACK_VALUE,
1582 static const enum index action_dec_tcp_ack[] = {
1583 ACTION_DEC_TCP_ACK_VALUE,
1588 static const enum index action_raw_encap[] = {
1589 ACTION_RAW_ENCAP_INDEX,
1594 static const enum index action_raw_decap[] = {
1595 ACTION_RAW_DECAP_INDEX,
1600 static const enum index action_set_tag[] = {
1601 ACTION_SET_TAG_DATA,
1602 ACTION_SET_TAG_INDEX,
1603 ACTION_SET_TAG_MASK,
1608 static const enum index action_set_meta[] = {
1609 ACTION_SET_META_DATA,
1610 ACTION_SET_META_MASK,
1615 static const enum index action_set_ipv4_dscp[] = {
1616 ACTION_SET_IPV4_DSCP_VALUE,
1621 static const enum index action_set_ipv6_dscp[] = {
1622 ACTION_SET_IPV6_DSCP_VALUE,
1627 static const enum index action_age[] = {
1634 static const enum index action_sample[] = {
1636 ACTION_SAMPLE_RATIO,
1637 ACTION_SAMPLE_INDEX,
1642 static const enum index next_action_sample[] = {
1655 static const enum index action_modify_field_dst[] = {
1656 ACTION_MODIFY_FIELD_DST_LEVEL,
1657 ACTION_MODIFY_FIELD_DST_OFFSET,
1658 ACTION_MODIFY_FIELD_SRC_TYPE,
1662 static const enum index action_modify_field_src[] = {
1663 ACTION_MODIFY_FIELD_SRC_LEVEL,
1664 ACTION_MODIFY_FIELD_SRC_OFFSET,
1665 ACTION_MODIFY_FIELD_SRC_VALUE,
1666 ACTION_MODIFY_FIELD_WIDTH,
1670 static int parse_set_raw_encap_decap(struct context *, const struct token *,
1671 const char *, unsigned int,
1672 void *, unsigned int);
1673 static int parse_set_sample_action(struct context *, const struct token *,
1674 const char *, unsigned int,
1675 void *, unsigned int);
1676 static int parse_set_init(struct context *, const struct token *,
1677 const char *, unsigned int,
1678 void *, unsigned int);
1679 static int parse_init(struct context *, const struct token *,
1680 const char *, unsigned int,
1681 void *, unsigned int);
1682 static int parse_vc(struct context *, const struct token *,
1683 const char *, unsigned int,
1684 void *, unsigned int);
1685 static int parse_vc_spec(struct context *, const struct token *,
1686 const char *, unsigned int, void *, unsigned int);
1687 static int parse_vc_conf(struct context *, const struct token *,
1688 const char *, unsigned int, void *, unsigned int);
1689 static int parse_vc_item_ecpri_type(struct context *, const struct token *,
1690 const char *, unsigned int,
1691 void *, unsigned int);
1692 static int parse_vc_action_rss(struct context *, const struct token *,
1693 const char *, unsigned int, void *,
1695 static int parse_vc_action_rss_func(struct context *, const struct token *,
1696 const char *, unsigned int, void *,
1698 static int parse_vc_action_rss_type(struct context *, const struct token *,
1699 const char *, unsigned int, void *,
1701 static int parse_vc_action_rss_queue(struct context *, const struct token *,
1702 const char *, unsigned int, void *,
1704 static int parse_vc_action_vxlan_encap(struct context *, const struct token *,
1705 const char *, unsigned int, void *,
1707 static int parse_vc_action_nvgre_encap(struct context *, const struct token *,
1708 const char *, unsigned int, void *,
1710 static int parse_vc_action_l2_encap(struct context *, const struct token *,
1711 const char *, unsigned int, void *,
1713 static int parse_vc_action_l2_decap(struct context *, const struct token *,
1714 const char *, unsigned int, void *,
1716 static int parse_vc_action_mplsogre_encap(struct context *,
1717 const struct token *, const char *,
1718 unsigned int, void *, unsigned int);
1719 static int parse_vc_action_mplsogre_decap(struct context *,
1720 const struct token *, const char *,
1721 unsigned int, void *, unsigned int);
1722 static int parse_vc_action_mplsoudp_encap(struct context *,
1723 const struct token *, const char *,
1724 unsigned int, void *, unsigned int);
1725 static int parse_vc_action_mplsoudp_decap(struct context *,
1726 const struct token *, const char *,
1727 unsigned int, void *, unsigned int);
1728 static int parse_vc_action_raw_encap(struct context *,
1729 const struct token *, const char *,
1730 unsigned int, void *, unsigned int);
1731 static int parse_vc_action_raw_decap(struct context *,
1732 const struct token *, const char *,
1733 unsigned int, void *, unsigned int);
1734 static int parse_vc_action_raw_encap_index(struct context *,
1735 const struct token *, const char *,
1736 unsigned int, void *, unsigned int);
1737 static int parse_vc_action_raw_decap_index(struct context *,
1738 const struct token *, const char *,
1739 unsigned int, void *, unsigned int);
1740 static int parse_vc_action_set_meta(struct context *ctx,
1741 const struct token *token, const char *str,
1742 unsigned int len, void *buf,
1744 static int parse_vc_action_sample(struct context *ctx,
1745 const struct token *token, const char *str,
1746 unsigned int len, void *buf,
1749 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
1750 const char *str, unsigned int len, void *buf,
1753 parse_vc_modify_field_op(struct context *ctx, const struct token *token,
1754 const char *str, unsigned int len, void *buf,
1757 parse_vc_modify_field_id(struct context *ctx, const struct token *token,
1758 const char *str, unsigned int len, void *buf,
1760 static int parse_destroy(struct context *, const struct token *,
1761 const char *, unsigned int,
1762 void *, unsigned int);
1763 static int parse_flush(struct context *, const struct token *,
1764 const char *, unsigned int,
1765 void *, unsigned int);
1766 static int parse_dump(struct context *, const struct token *,
1767 const char *, unsigned int,
1768 void *, unsigned int);
1769 static int parse_query(struct context *, const struct token *,
1770 const char *, unsigned int,
1771 void *, unsigned int);
1772 static int parse_action(struct context *, const struct token *,
1773 const char *, unsigned int,
1774 void *, unsigned int);
1775 static int parse_list(struct context *, const struct token *,
1776 const char *, unsigned int,
1777 void *, unsigned int);
1778 static int parse_aged(struct context *, const struct token *,
1779 const char *, unsigned int,
1780 void *, unsigned int);
1781 static int parse_isolate(struct context *, const struct token *,
1782 const char *, unsigned int,
1783 void *, unsigned int);
1784 static int parse_tunnel(struct context *, const struct token *,
1785 const char *, unsigned int,
1786 void *, unsigned int);
1787 static int parse_int(struct context *, const struct token *,
1788 const char *, unsigned int,
1789 void *, unsigned int);
1790 static int parse_prefix(struct context *, const struct token *,
1791 const char *, unsigned int,
1792 void *, unsigned int);
1793 static int parse_boolean(struct context *, const struct token *,
1794 const char *, unsigned int,
1795 void *, unsigned int);
1796 static int parse_string(struct context *, const struct token *,
1797 const char *, unsigned int,
1798 void *, unsigned int);
1799 static int parse_hex(struct context *ctx, const struct token *token,
1800 const char *str, unsigned int len,
1801 void *buf, unsigned int size);
1802 static int parse_string0(struct context *, const struct token *,
1803 const char *, unsigned int,
1804 void *, unsigned int);
1805 static int parse_mac_addr(struct context *, const struct token *,
1806 const char *, unsigned int,
1807 void *, unsigned int);
1808 static int parse_ipv4_addr(struct context *, const struct token *,
1809 const char *, unsigned int,
1810 void *, unsigned int);
1811 static int parse_ipv6_addr(struct context *, const struct token *,
1812 const char *, unsigned int,
1813 void *, unsigned int);
1814 static int parse_port(struct context *, const struct token *,
1815 const char *, unsigned int,
1816 void *, unsigned int);
1817 static int parse_ia(struct context *, const struct token *,
1818 const char *, unsigned int,
1819 void *, unsigned int);
1820 static int parse_ia_destroy(struct context *ctx, const struct token *token,
1821 const char *str, unsigned int len,
1822 void *buf, unsigned int size);
1823 static int parse_ia_id2ptr(struct context *ctx, const struct token *token,
1824 const char *str, unsigned int len, void *buf,
1826 static int comp_none(struct context *, const struct token *,
1827 unsigned int, char *, unsigned int);
1828 static int comp_boolean(struct context *, const struct token *,
1829 unsigned int, char *, unsigned int);
1830 static int comp_action(struct context *, const struct token *,
1831 unsigned int, char *, unsigned int);
1832 static int comp_port(struct context *, const struct token *,
1833 unsigned int, char *, unsigned int);
1834 static int comp_rule_id(struct context *, const struct token *,
1835 unsigned int, char *, unsigned int);
1836 static int comp_vc_action_rss_type(struct context *, const struct token *,
1837 unsigned int, char *, unsigned int);
1838 static int comp_vc_action_rss_queue(struct context *, const struct token *,
1839 unsigned int, char *, unsigned int);
1840 static int comp_set_raw_index(struct context *, const struct token *,
1841 unsigned int, char *, unsigned int);
1842 static int comp_set_sample_index(struct context *, const struct token *,
1843 unsigned int, char *, unsigned int);
1844 static int comp_set_modify_field_op(struct context *, const struct token *,
1845 unsigned int, char *, unsigned int);
1846 static int comp_set_modify_field_id(struct context *, const struct token *,
1847 unsigned int, char *, unsigned int);
1849 /** Token definitions. */
1850 static const struct token token_list[] = {
1851 /* Special tokens. */
1854 .help = "null entry, abused as the entry point",
1855 .next = NEXT(NEXT_ENTRY(FLOW)),
1860 .help = "command may end here",
1863 .name = "START_SET",
1864 .help = "null entry, abused as the entry point for set",
1865 .next = NEXT(NEXT_ENTRY(SET)),
1870 .help = "set command may end here",
1872 /* Common tokens. */
1876 .help = "integer value",
1881 .name = "{unsigned}",
1883 .help = "unsigned integer value",
1890 .help = "prefix length for bit-mask",
1891 .call = parse_prefix,
1895 .name = "{boolean}",
1897 .help = "any boolean value",
1898 .call = parse_boolean,
1899 .comp = comp_boolean,
1904 .help = "fixed string",
1905 .call = parse_string,
1911 .help = "fixed string",
1915 .name = "{file path}",
1917 .help = "file path",
1918 .call = parse_string0,
1922 .name = "{MAC address}",
1924 .help = "standard MAC address notation",
1925 .call = parse_mac_addr,
1929 .name = "{IPv4 address}",
1930 .type = "IPV4 ADDRESS",
1931 .help = "standard IPv4 address notation",
1932 .call = parse_ipv4_addr,
1936 .name = "{IPv6 address}",
1937 .type = "IPV6 ADDRESS",
1938 .help = "standard IPv6 address notation",
1939 .call = parse_ipv6_addr,
1943 .name = "{rule id}",
1945 .help = "rule identifier",
1947 .comp = comp_rule_id,
1950 .name = "{port_id}",
1952 .help = "port identifier",
1957 .name = "{group_id}",
1959 .help = "group identifier",
1963 [PRIORITY_LEVEL] = {
1966 .help = "priority level",
1970 [INDIRECT_ACTION_ID] = {
1971 .name = "{indirect_action_id}",
1972 .type = "INDIRECT_ACTION_ID",
1973 .help = "indirect action id",
1977 /* Top-level command. */
1980 .type = "{command} {port_id} [{arg} [...]]",
1981 .help = "manage ingress/egress flow rules",
1982 .next = NEXT(NEXT_ENTRY
1996 /* Top-level command. */
1997 [INDIRECT_ACTION] = {
1998 .name = "indirect_action",
1999 .type = "{command} {port_id} [{arg} [...]]",
2000 .help = "manage indirect actions",
2001 .next = NEXT(next_ia_subcmd, NEXT_ENTRY(PORT_ID)),
2002 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2005 /* Sub-level commands. */
2006 [INDIRECT_ACTION_CREATE] = {
2008 .help = "create indirect action",
2009 .next = NEXT(next_ia_create_attr),
2012 [INDIRECT_ACTION_UPDATE] = {
2014 .help = "update indirect action",
2015 .next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_SPEC),
2016 NEXT_ENTRY(INDIRECT_ACTION_ID)),
2017 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
2020 [INDIRECT_ACTION_DESTROY] = {
2022 .help = "destroy indirect action",
2023 .next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_DESTROY_ID)),
2024 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2025 .call = parse_ia_destroy,
2027 [INDIRECT_ACTION_QUERY] = {
2029 .help = "query indirect action",
2030 .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(INDIRECT_ACTION_ID)),
2031 .args = ARGS(ARGS_ENTRY(struct buffer, args.ia.action_id)),
2036 .help = "check whether a flow rule can be created",
2037 .next = NEXT(next_vc_attr, NEXT_ENTRY(PORT_ID)),
2038 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2043 .help = "create a flow rule",
2044 .next = NEXT(next_vc_attr, NEXT_ENTRY(PORT_ID)),
2045 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2050 .help = "destroy specific flow rules",
2051 .next = NEXT(NEXT_ENTRY(DESTROY_RULE), NEXT_ENTRY(PORT_ID)),
2052 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2053 .call = parse_destroy,
2057 .help = "destroy all flow rules",
2058 .next = NEXT(NEXT_ENTRY(PORT_ID)),
2059 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2060 .call = parse_flush,
2064 .help = "dump single/all flow rules to file",
2065 .next = NEXT(next_dump_subcmd, NEXT_ENTRY(PORT_ID)),
2066 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2071 .help = "query an existing flow rule",
2072 .next = NEXT(NEXT_ENTRY(QUERY_ACTION),
2073 NEXT_ENTRY(RULE_ID),
2074 NEXT_ENTRY(PORT_ID)),
2075 .args = ARGS(ARGS_ENTRY(struct buffer, args.query.action.type),
2076 ARGS_ENTRY(struct buffer, args.query.rule),
2077 ARGS_ENTRY(struct buffer, port)),
2078 .call = parse_query,
2082 .help = "list existing flow rules",
2083 .next = NEXT(next_list_attr, NEXT_ENTRY(PORT_ID)),
2084 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2089 .help = "list and destroy aged flows",
2090 .next = NEXT(next_aged_attr, NEXT_ENTRY(PORT_ID)),
2091 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2096 .help = "restrict ingress traffic to the defined flow rules",
2097 .next = NEXT(NEXT_ENTRY(BOOLEAN),
2098 NEXT_ENTRY(PORT_ID)),
2099 .args = ARGS(ARGS_ENTRY(struct buffer, args.isolate.set),
2100 ARGS_ENTRY(struct buffer, port)),
2101 .call = parse_isolate,
2105 .help = "new tunnel API",
2106 .next = NEXT(NEXT_ENTRY
2107 (TUNNEL_CREATE, TUNNEL_LIST, TUNNEL_DESTROY)),
2108 .call = parse_tunnel,
2110 /* Tunnel arguments. */
2113 .help = "create new tunnel object",
2114 .next = NEXT(NEXT_ENTRY(TUNNEL_CREATE_TYPE),
2115 NEXT_ENTRY(PORT_ID)),
2116 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2117 .call = parse_tunnel,
2119 [TUNNEL_CREATE_TYPE] = {
2121 .help = "create new tunnel",
2122 .next = NEXT(NEXT_ENTRY(FILE_PATH)),
2123 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, type)),
2124 .call = parse_tunnel,
2126 [TUNNEL_DESTROY] = {
2128 .help = "destroy tunel",
2129 .next = NEXT(NEXT_ENTRY(TUNNEL_DESTROY_ID),
2130 NEXT_ENTRY(PORT_ID)),
2131 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2132 .call = parse_tunnel,
2134 [TUNNEL_DESTROY_ID] = {
2136 .help = "tunnel identifier to testroy",
2137 .next = NEXT(NEXT_ENTRY(UNSIGNED)),
2138 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2139 .call = parse_tunnel,
2143 .help = "list existing tunnels",
2144 .next = NEXT(NEXT_ENTRY(PORT_ID)),
2145 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2146 .call = parse_tunnel,
2148 /* Destroy arguments. */
2151 .help = "specify a rule identifier",
2152 .next = NEXT(next_destroy_attr, NEXT_ENTRY(RULE_ID)),
2153 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.destroy.rule)),
2154 .call = parse_destroy,
2156 /* Dump arguments. */
2160 .next = NEXT(next_dump_attr),
2161 .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file)),
2166 .help = "dump one rule",
2167 .next = NEXT(next_dump_attr, NEXT_ENTRY(RULE_ID)),
2168 .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file),
2169 ARGS_ENTRY(struct buffer, args.dump.rule)),
2172 /* Query arguments. */
2176 .help = "action to query, must be part of the rule",
2177 .call = parse_action,
2178 .comp = comp_action,
2180 /* List arguments. */
2183 .help = "specify a group",
2184 .next = NEXT(next_list_attr, NEXT_ENTRY(GROUP_ID)),
2185 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.list.group)),
2190 .help = "specify aged flows need be destroyed",
2194 /* Validate/create attributes. */
2197 .help = "specify a group",
2198 .next = NEXT(next_vc_attr, NEXT_ENTRY(GROUP_ID)),
2199 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, group)),
2204 .help = "specify a priority level",
2205 .next = NEXT(next_vc_attr, NEXT_ENTRY(PRIORITY_LEVEL)),
2206 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, priority)),
2211 .help = "affect rule to ingress",
2212 .next = NEXT(next_vc_attr),
2217 .help = "affect rule to egress",
2218 .next = NEXT(next_vc_attr),
2223 .help = "apply rule directly to endpoints found in pattern",
2224 .next = NEXT(next_vc_attr),
2228 .name = "tunnel_set",
2229 .help = "tunnel steer rule",
2230 .next = NEXT(next_vc_attr, NEXT_ENTRY(UNSIGNED)),
2231 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2235 .name = "tunnel_match",
2236 .help = "tunnel match rule",
2237 .next = NEXT(next_vc_attr, NEXT_ENTRY(UNSIGNED)),
2238 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2241 /* Validate/create pattern. */
2244 .help = "submit a list of pattern items",
2245 .next = NEXT(next_item),
2250 .help = "match value perfectly (with full bit-mask)",
2251 .call = parse_vc_spec,
2253 [ITEM_PARAM_SPEC] = {
2255 .help = "match value according to configured bit-mask",
2256 .call = parse_vc_spec,
2258 [ITEM_PARAM_LAST] = {
2260 .help = "specify upper bound to establish a range",
2261 .call = parse_vc_spec,
2263 [ITEM_PARAM_MASK] = {
2265 .help = "specify bit-mask with relevant bits set to one",
2266 .call = parse_vc_spec,
2268 [ITEM_PARAM_PREFIX] = {
2270 .help = "generate bit-mask from a prefix length",
2271 .call = parse_vc_spec,
2275 .help = "specify next pattern item",
2276 .next = NEXT(next_item),
2280 .help = "end list of pattern items",
2281 .priv = PRIV_ITEM(END, 0),
2282 .next = NEXT(NEXT_ENTRY(ACTIONS)),
2287 .help = "no-op pattern item",
2288 .priv = PRIV_ITEM(VOID, 0),
2289 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2294 .help = "perform actions when pattern does not match",
2295 .priv = PRIV_ITEM(INVERT, 0),
2296 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2301 .help = "match any protocol for the current layer",
2302 .priv = PRIV_ITEM(ANY, sizeof(struct rte_flow_item_any)),
2303 .next = NEXT(item_any),
2308 .help = "number of layers covered",
2309 .next = NEXT(item_any, NEXT_ENTRY(UNSIGNED), item_param),
2310 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_any, num)),
2314 .help = "match traffic from/to the physical function",
2315 .priv = PRIV_ITEM(PF, 0),
2316 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2321 .help = "match traffic from/to a virtual function ID",
2322 .priv = PRIV_ITEM(VF, sizeof(struct rte_flow_item_vf)),
2323 .next = NEXT(item_vf),
2329 .next = NEXT(item_vf, NEXT_ENTRY(UNSIGNED), item_param),
2330 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_vf, id)),
2334 .help = "match traffic from/to a specific physical port",
2335 .priv = PRIV_ITEM(PHY_PORT,
2336 sizeof(struct rte_flow_item_phy_port)),
2337 .next = NEXT(item_phy_port),
2340 [ITEM_PHY_PORT_INDEX] = {
2342 .help = "physical port index",
2343 .next = NEXT(item_phy_port, NEXT_ENTRY(UNSIGNED), item_param),
2344 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_phy_port, index)),
2348 .help = "match traffic from/to a given DPDK port ID",
2349 .priv = PRIV_ITEM(PORT_ID,
2350 sizeof(struct rte_flow_item_port_id)),
2351 .next = NEXT(item_port_id),
2354 [ITEM_PORT_ID_ID] = {
2356 .help = "DPDK port ID",
2357 .next = NEXT(item_port_id, NEXT_ENTRY(UNSIGNED), item_param),
2358 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port_id, id)),
2362 .help = "match traffic against value set in previously matched rule",
2363 .priv = PRIV_ITEM(MARK, sizeof(struct rte_flow_item_mark)),
2364 .next = NEXT(item_mark),
2369 .help = "Integer value to match against",
2370 .next = NEXT(item_mark, NEXT_ENTRY(UNSIGNED), item_param),
2371 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_mark, id)),
2375 .help = "match an arbitrary byte string",
2376 .priv = PRIV_ITEM(RAW, ITEM_RAW_SIZE),
2377 .next = NEXT(item_raw),
2380 [ITEM_RAW_RELATIVE] = {
2382 .help = "look for pattern after the previous item",
2383 .next = NEXT(item_raw, NEXT_ENTRY(BOOLEAN), item_param),
2384 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
2387 [ITEM_RAW_SEARCH] = {
2389 .help = "search pattern from offset (see also limit)",
2390 .next = NEXT(item_raw, NEXT_ENTRY(BOOLEAN), item_param),
2391 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
2394 [ITEM_RAW_OFFSET] = {
2396 .help = "absolute or relative offset for pattern",
2397 .next = NEXT(item_raw, NEXT_ENTRY(INTEGER), item_param),
2398 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, offset)),
2400 [ITEM_RAW_LIMIT] = {
2402 .help = "search area limit for start of pattern",
2403 .next = NEXT(item_raw, NEXT_ENTRY(UNSIGNED), item_param),
2404 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, limit)),
2406 [ITEM_RAW_PATTERN] = {
2408 .help = "byte string to look for",
2409 .next = NEXT(item_raw,
2411 NEXT_ENTRY(ITEM_PARAM_IS,
2414 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern),
2415 ARGS_ENTRY(struct rte_flow_item_raw, length),
2416 ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw),
2417 ITEM_RAW_PATTERN_SIZE)),
2421 .help = "match Ethernet header",
2422 .priv = PRIV_ITEM(ETH, sizeof(struct rte_flow_item_eth)),
2423 .next = NEXT(item_eth),
2428 .help = "destination MAC",
2429 .next = NEXT(item_eth, NEXT_ENTRY(MAC_ADDR), item_param),
2430 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, dst)),
2434 .help = "source MAC",
2435 .next = NEXT(item_eth, NEXT_ENTRY(MAC_ADDR), item_param),
2436 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, src)),
2440 .help = "EtherType",
2441 .next = NEXT(item_eth, NEXT_ENTRY(UNSIGNED), item_param),
2442 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, type)),
2444 [ITEM_ETH_HAS_VLAN] = {
2446 .help = "packet header contains VLAN",
2447 .next = NEXT(item_eth, NEXT_ENTRY(UNSIGNED), item_param),
2448 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_eth,
2453 .help = "match 802.1Q/ad VLAN tag",
2454 .priv = PRIV_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)),
2455 .next = NEXT(item_vlan),
2460 .help = "tag control information",
2461 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2462 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, tci)),
2466 .help = "priority code point",
2467 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2468 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2473 .help = "drop eligible indicator",
2474 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2475 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2480 .help = "VLAN identifier",
2481 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2482 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2485 [ITEM_VLAN_INNER_TYPE] = {
2486 .name = "inner_type",
2487 .help = "inner EtherType",
2488 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2489 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan,
2492 [ITEM_VLAN_HAS_MORE_VLAN] = {
2493 .name = "has_more_vlan",
2494 .help = "packet header contains another VLAN",
2495 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2496 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vlan,
2501 .help = "match IPv4 header",
2502 .priv = PRIV_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)),
2503 .next = NEXT(item_ipv4),
2508 .help = "type of service",
2509 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2510 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2511 hdr.type_of_service)),
2513 [ITEM_IPV4_FRAGMENT_OFFSET] = {
2514 .name = "fragment_offset",
2515 .help = "fragmentation flags and fragment offset",
2516 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2517 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2518 hdr.fragment_offset)),
2522 .help = "time to live",
2523 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2524 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2527 [ITEM_IPV4_PROTO] = {
2529 .help = "next protocol ID",
2530 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2531 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2532 hdr.next_proto_id)),
2536 .help = "source address",
2537 .next = NEXT(item_ipv4, NEXT_ENTRY(IPV4_ADDR), item_param),
2538 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2543 .help = "destination address",
2544 .next = NEXT(item_ipv4, NEXT_ENTRY(IPV4_ADDR), item_param),
2545 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2550 .help = "match IPv6 header",
2551 .priv = PRIV_ITEM(IPV6, sizeof(struct rte_flow_item_ipv6)),
2552 .next = NEXT(item_ipv6),
2557 .help = "traffic class",
2558 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2559 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2561 "\x0f\xf0\x00\x00")),
2563 [ITEM_IPV6_FLOW] = {
2565 .help = "flow label",
2566 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2567 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2569 "\x00\x0f\xff\xff")),
2571 [ITEM_IPV6_PROTO] = {
2573 .help = "protocol (next header)",
2574 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2575 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2580 .help = "hop limit",
2581 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2582 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2587 .help = "source address",
2588 .next = NEXT(item_ipv6, NEXT_ENTRY(IPV6_ADDR), item_param),
2589 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2594 .help = "destination address",
2595 .next = NEXT(item_ipv6, NEXT_ENTRY(IPV6_ADDR), item_param),
2596 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2599 [ITEM_IPV6_HAS_FRAG_EXT] = {
2600 .name = "has_frag_ext",
2601 .help = "fragment packet attribute",
2602 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2603 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_ipv6,
2608 .help = "match ICMP header",
2609 .priv = PRIV_ITEM(ICMP, sizeof(struct rte_flow_item_icmp)),
2610 .next = NEXT(item_icmp),
2613 [ITEM_ICMP_TYPE] = {
2615 .help = "ICMP packet type",
2616 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2617 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2620 [ITEM_ICMP_CODE] = {
2622 .help = "ICMP packet code",
2623 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2624 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2627 [ITEM_ICMP_IDENT] = {
2629 .help = "ICMP packet identifier",
2630 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2631 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2636 .help = "ICMP packet sequence number",
2637 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2638 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2643 .help = "match UDP header",
2644 .priv = PRIV_ITEM(UDP, sizeof(struct rte_flow_item_udp)),
2645 .next = NEXT(item_udp),
2650 .help = "UDP source port",
2651 .next = NEXT(item_udp, NEXT_ENTRY(UNSIGNED), item_param),
2652 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2657 .help = "UDP destination port",
2658 .next = NEXT(item_udp, NEXT_ENTRY(UNSIGNED), item_param),
2659 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2664 .help = "match TCP header",
2665 .priv = PRIV_ITEM(TCP, sizeof(struct rte_flow_item_tcp)),
2666 .next = NEXT(item_tcp),
2671 .help = "TCP source port",
2672 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2673 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2678 .help = "TCP destination port",
2679 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2680 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2683 [ITEM_TCP_FLAGS] = {
2685 .help = "TCP flags",
2686 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2687 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2692 .help = "match SCTP header",
2693 .priv = PRIV_ITEM(SCTP, sizeof(struct rte_flow_item_sctp)),
2694 .next = NEXT(item_sctp),
2699 .help = "SCTP source port",
2700 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2701 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2706 .help = "SCTP destination port",
2707 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2708 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2713 .help = "validation tag",
2714 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2715 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2718 [ITEM_SCTP_CKSUM] = {
2721 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2722 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2727 .help = "match VXLAN header",
2728 .priv = PRIV_ITEM(VXLAN, sizeof(struct rte_flow_item_vxlan)),
2729 .next = NEXT(item_vxlan),
2732 [ITEM_VXLAN_VNI] = {
2734 .help = "VXLAN identifier",
2735 .next = NEXT(item_vxlan, NEXT_ENTRY(UNSIGNED), item_param),
2736 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan, vni)),
2740 .help = "match E-Tag header",
2741 .priv = PRIV_ITEM(E_TAG, sizeof(struct rte_flow_item_e_tag)),
2742 .next = NEXT(item_e_tag),
2745 [ITEM_E_TAG_GRP_ECID_B] = {
2746 .name = "grp_ecid_b",
2747 .help = "GRP and E-CID base",
2748 .next = NEXT(item_e_tag, NEXT_ENTRY(UNSIGNED), item_param),
2749 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_e_tag,
2755 .help = "match NVGRE header",
2756 .priv = PRIV_ITEM(NVGRE, sizeof(struct rte_flow_item_nvgre)),
2757 .next = NEXT(item_nvgre),
2760 [ITEM_NVGRE_TNI] = {
2762 .help = "virtual subnet ID",
2763 .next = NEXT(item_nvgre, NEXT_ENTRY(UNSIGNED), item_param),
2764 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_nvgre, tni)),
2768 .help = "match MPLS header",
2769 .priv = PRIV_ITEM(MPLS, sizeof(struct rte_flow_item_mpls)),
2770 .next = NEXT(item_mpls),
2773 [ITEM_MPLS_LABEL] = {
2775 .help = "MPLS label",
2776 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2777 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2783 .help = "MPLS Traffic Class",
2784 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2785 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2791 .help = "MPLS Bottom-of-Stack",
2792 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2793 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2799 .help = "match GRE header",
2800 .priv = PRIV_ITEM(GRE, sizeof(struct rte_flow_item_gre)),
2801 .next = NEXT(item_gre),
2804 [ITEM_GRE_PROTO] = {
2806 .help = "GRE protocol type",
2807 .next = NEXT(item_gre, NEXT_ENTRY(UNSIGNED), item_param),
2808 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2811 [ITEM_GRE_C_RSVD0_VER] = {
2812 .name = "c_rsvd0_ver",
2814 "checksum (1b), undefined (1b), key bit (1b),"
2815 " sequence number (1b), reserved 0 (9b),"
2817 .next = NEXT(item_gre, NEXT_ENTRY(UNSIGNED), item_param),
2818 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2821 [ITEM_GRE_C_BIT] = {
2823 .help = "checksum bit (C)",
2824 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2825 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2827 "\x80\x00\x00\x00")),
2829 [ITEM_GRE_S_BIT] = {
2831 .help = "sequence number bit (S)",
2832 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2833 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2835 "\x10\x00\x00\x00")),
2837 [ITEM_GRE_K_BIT] = {
2839 .help = "key bit (K)",
2840 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2841 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2843 "\x20\x00\x00\x00")),
2847 .help = "fuzzy pattern match, expect faster than default",
2848 .priv = PRIV_ITEM(FUZZY,
2849 sizeof(struct rte_flow_item_fuzzy)),
2850 .next = NEXT(item_fuzzy),
2853 [ITEM_FUZZY_THRESH] = {
2855 .help = "match accuracy threshold",
2856 .next = NEXT(item_fuzzy, NEXT_ENTRY(UNSIGNED), item_param),
2857 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_fuzzy,
2862 .help = "match GTP header",
2863 .priv = PRIV_ITEM(GTP, sizeof(struct rte_flow_item_gtp)),
2864 .next = NEXT(item_gtp),
2867 [ITEM_GTP_FLAGS] = {
2868 .name = "v_pt_rsv_flags",
2869 .help = "GTP flags",
2870 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2871 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp,
2874 [ITEM_GTP_MSG_TYPE] = {
2876 .help = "GTP message type",
2877 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2878 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp, msg_type)),
2882 .help = "tunnel endpoint identifier",
2883 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2884 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp, teid)),
2888 .help = "match GTP header",
2889 .priv = PRIV_ITEM(GTPC, sizeof(struct rte_flow_item_gtp)),
2890 .next = NEXT(item_gtp),
2895 .help = "match GTP header",
2896 .priv = PRIV_ITEM(GTPU, sizeof(struct rte_flow_item_gtp)),
2897 .next = NEXT(item_gtp),
2902 .help = "match GENEVE header",
2903 .priv = PRIV_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)),
2904 .next = NEXT(item_geneve),
2907 [ITEM_GENEVE_VNI] = {
2909 .help = "virtual network identifier",
2910 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2911 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve, vni)),
2913 [ITEM_GENEVE_PROTO] = {
2915 .help = "GENEVE protocol type",
2916 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2917 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve,
2920 [ITEM_GENEVE_OPTLEN] = {
2922 .help = "GENEVE options length in dwords",
2923 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2924 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_geneve,
2925 ver_opt_len_o_c_rsvd0,
2928 [ITEM_VXLAN_GPE] = {
2929 .name = "vxlan-gpe",
2930 .help = "match VXLAN-GPE header",
2931 .priv = PRIV_ITEM(VXLAN_GPE,
2932 sizeof(struct rte_flow_item_vxlan_gpe)),
2933 .next = NEXT(item_vxlan_gpe),
2936 [ITEM_VXLAN_GPE_VNI] = {
2938 .help = "VXLAN-GPE identifier",
2939 .next = NEXT(item_vxlan_gpe, NEXT_ENTRY(UNSIGNED), item_param),
2940 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
2943 [ITEM_ARP_ETH_IPV4] = {
2944 .name = "arp_eth_ipv4",
2945 .help = "match ARP header for Ethernet/IPv4",
2946 .priv = PRIV_ITEM(ARP_ETH_IPV4,
2947 sizeof(struct rte_flow_item_arp_eth_ipv4)),
2948 .next = NEXT(item_arp_eth_ipv4),
2951 [ITEM_ARP_ETH_IPV4_SHA] = {
2953 .help = "sender hardware address",
2954 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(MAC_ADDR),
2956 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2959 [ITEM_ARP_ETH_IPV4_SPA] = {
2961 .help = "sender IPv4 address",
2962 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(IPV4_ADDR),
2964 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2967 [ITEM_ARP_ETH_IPV4_THA] = {
2969 .help = "target hardware address",
2970 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(MAC_ADDR),
2972 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2975 [ITEM_ARP_ETH_IPV4_TPA] = {
2977 .help = "target IPv4 address",
2978 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(IPV4_ADDR),
2980 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2985 .help = "match presence of any IPv6 extension header",
2986 .priv = PRIV_ITEM(IPV6_EXT,
2987 sizeof(struct rte_flow_item_ipv6_ext)),
2988 .next = NEXT(item_ipv6_ext),
2991 [ITEM_IPV6_EXT_NEXT_HDR] = {
2993 .help = "next header",
2994 .next = NEXT(item_ipv6_ext, NEXT_ENTRY(UNSIGNED), item_param),
2995 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_ext,
2998 [ITEM_IPV6_FRAG_EXT] = {
2999 .name = "ipv6_frag_ext",
3000 .help = "match presence of IPv6 fragment extension header",
3001 .priv = PRIV_ITEM(IPV6_FRAG_EXT,
3002 sizeof(struct rte_flow_item_ipv6_frag_ext)),
3003 .next = NEXT(item_ipv6_frag_ext),
3006 [ITEM_IPV6_FRAG_EXT_NEXT_HDR] = {
3008 .help = "next header",
3009 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(UNSIGNED),
3011 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ipv6_frag_ext,
3014 [ITEM_IPV6_FRAG_EXT_FRAG_DATA] = {
3015 .name = "frag_data",
3016 .help = "Fragment flags and offset",
3017 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(UNSIGNED),
3019 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_frag_ext,
3024 .help = "match any ICMPv6 header",
3025 .priv = PRIV_ITEM(ICMP6, sizeof(struct rte_flow_item_icmp6)),
3026 .next = NEXT(item_icmp6),
3029 [ITEM_ICMP6_TYPE] = {
3031 .help = "ICMPv6 type",
3032 .next = NEXT(item_icmp6, NEXT_ENTRY(UNSIGNED), item_param),
3033 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
3036 [ITEM_ICMP6_CODE] = {
3038 .help = "ICMPv6 code",
3039 .next = NEXT(item_icmp6, NEXT_ENTRY(UNSIGNED), item_param),
3040 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
3043 [ITEM_ICMP6_ND_NS] = {
3044 .name = "icmp6_nd_ns",
3045 .help = "match ICMPv6 neighbor discovery solicitation",
3046 .priv = PRIV_ITEM(ICMP6_ND_NS,
3047 sizeof(struct rte_flow_item_icmp6_nd_ns)),
3048 .next = NEXT(item_icmp6_nd_ns),
3051 [ITEM_ICMP6_ND_NS_TARGET_ADDR] = {
3052 .name = "target_addr",
3053 .help = "target address",
3054 .next = NEXT(item_icmp6_nd_ns, NEXT_ENTRY(IPV6_ADDR),
3056 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_ns,
3059 [ITEM_ICMP6_ND_NA] = {
3060 .name = "icmp6_nd_na",
3061 .help = "match ICMPv6 neighbor discovery advertisement",
3062 .priv = PRIV_ITEM(ICMP6_ND_NA,
3063 sizeof(struct rte_flow_item_icmp6_nd_na)),
3064 .next = NEXT(item_icmp6_nd_na),
3067 [ITEM_ICMP6_ND_NA_TARGET_ADDR] = {
3068 .name = "target_addr",
3069 .help = "target address",
3070 .next = NEXT(item_icmp6_nd_na, NEXT_ENTRY(IPV6_ADDR),
3072 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_na,
3075 [ITEM_ICMP6_ND_OPT] = {
3076 .name = "icmp6_nd_opt",
3077 .help = "match presence of any ICMPv6 neighbor discovery"
3079 .priv = PRIV_ITEM(ICMP6_ND_OPT,
3080 sizeof(struct rte_flow_item_icmp6_nd_opt)),
3081 .next = NEXT(item_icmp6_nd_opt),
3084 [ITEM_ICMP6_ND_OPT_TYPE] = {
3086 .help = "ND option type",
3087 .next = NEXT(item_icmp6_nd_opt, NEXT_ENTRY(UNSIGNED),
3089 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_opt,
3092 [ITEM_ICMP6_ND_OPT_SLA_ETH] = {
3093 .name = "icmp6_nd_opt_sla_eth",
3094 .help = "match ICMPv6 neighbor discovery source Ethernet"
3095 " link-layer address option",
3097 (ICMP6_ND_OPT_SLA_ETH,
3098 sizeof(struct rte_flow_item_icmp6_nd_opt_sla_eth)),
3099 .next = NEXT(item_icmp6_nd_opt_sla_eth),
3102 [ITEM_ICMP6_ND_OPT_SLA_ETH_SLA] = {
3104 .help = "source Ethernet LLA",
3105 .next = NEXT(item_icmp6_nd_opt_sla_eth, NEXT_ENTRY(MAC_ADDR),
3107 .args = ARGS(ARGS_ENTRY_HTON
3108 (struct rte_flow_item_icmp6_nd_opt_sla_eth, sla)),
3110 [ITEM_ICMP6_ND_OPT_TLA_ETH] = {
3111 .name = "icmp6_nd_opt_tla_eth",
3112 .help = "match ICMPv6 neighbor discovery target Ethernet"
3113 " link-layer address option",
3115 (ICMP6_ND_OPT_TLA_ETH,
3116 sizeof(struct rte_flow_item_icmp6_nd_opt_tla_eth)),
3117 .next = NEXT(item_icmp6_nd_opt_tla_eth),
3120 [ITEM_ICMP6_ND_OPT_TLA_ETH_TLA] = {
3122 .help = "target Ethernet LLA",
3123 .next = NEXT(item_icmp6_nd_opt_tla_eth, NEXT_ENTRY(MAC_ADDR),
3125 .args = ARGS(ARGS_ENTRY_HTON
3126 (struct rte_flow_item_icmp6_nd_opt_tla_eth, tla)),
3130 .help = "match metadata header",
3131 .priv = PRIV_ITEM(META, sizeof(struct rte_flow_item_meta)),
3132 .next = NEXT(item_meta),
3135 [ITEM_META_DATA] = {
3137 .help = "metadata value",
3138 .next = NEXT(item_meta, NEXT_ENTRY(UNSIGNED), item_param),
3139 .args = ARGS(ARGS_ENTRY_MASK(struct rte_flow_item_meta,
3140 data, "\xff\xff\xff\xff")),
3144 .help = "match GRE key",
3145 .priv = PRIV_ITEM(GRE_KEY, sizeof(rte_be32_t)),
3146 .next = NEXT(item_gre_key),
3149 [ITEM_GRE_KEY_VALUE] = {
3151 .help = "key value",
3152 .next = NEXT(item_gre_key, NEXT_ENTRY(UNSIGNED), item_param),
3153 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3157 .help = "match GTP extension header with type 0x85",
3158 .priv = PRIV_ITEM(GTP_PSC,
3159 sizeof(struct rte_flow_item_gtp_psc)),
3160 .next = NEXT(item_gtp_psc),
3163 [ITEM_GTP_PSC_QFI] = {
3165 .help = "QoS flow identifier",
3166 .next = NEXT(item_gtp_psc, NEXT_ENTRY(UNSIGNED), item_param),
3167 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
3170 [ITEM_GTP_PSC_PDU_T] = {
3173 .next = NEXT(item_gtp_psc, NEXT_ENTRY(UNSIGNED), item_param),
3174 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
3179 .help = "match PPPoE session header",
3180 .priv = PRIV_ITEM(PPPOES, sizeof(struct rte_flow_item_pppoe)),
3181 .next = NEXT(item_pppoes),
3186 .help = "match PPPoE discovery header",
3187 .priv = PRIV_ITEM(PPPOED, sizeof(struct rte_flow_item_pppoe)),
3188 .next = NEXT(item_pppoed),
3191 [ITEM_PPPOE_SEID] = {
3193 .help = "session identifier",
3194 .next = NEXT(item_pppoes, NEXT_ENTRY(UNSIGNED), item_param),
3195 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pppoe,
3198 [ITEM_PPPOE_PROTO_ID] = {
3199 .name = "pppoe_proto_id",
3200 .help = "match PPPoE session protocol identifier",
3201 .priv = PRIV_ITEM(PPPOE_PROTO_ID,
3202 sizeof(struct rte_flow_item_pppoe_proto_id)),
3203 .next = NEXT(item_pppoe_proto_id, NEXT_ENTRY(UNSIGNED),
3205 .args = ARGS(ARGS_ENTRY_HTON
3206 (struct rte_flow_item_pppoe_proto_id, proto_id)),
3211 .help = "matches higig2 header",
3212 .priv = PRIV_ITEM(HIGIG2,
3213 sizeof(struct rte_flow_item_higig2_hdr)),
3214 .next = NEXT(item_higig2),
3217 [ITEM_HIGIG2_CLASSIFICATION] = {
3218 .name = "classification",
3219 .help = "matches classification of higig2 header",
3220 .next = NEXT(item_higig2, NEXT_ENTRY(UNSIGNED), item_param),
3221 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
3222 hdr.ppt1.classification)),
3224 [ITEM_HIGIG2_VID] = {
3226 .help = "matches vid of higig2 header",
3227 .next = NEXT(item_higig2, NEXT_ENTRY(UNSIGNED), item_param),
3228 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
3233 .help = "match tag value",
3234 .priv = PRIV_ITEM(TAG, sizeof(struct rte_flow_item_tag)),
3235 .next = NEXT(item_tag),
3240 .help = "tag value to match",
3241 .next = NEXT(item_tag, NEXT_ENTRY(UNSIGNED), item_param),
3242 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, data)),
3244 [ITEM_TAG_INDEX] = {
3246 .help = "index of tag array to match",
3247 .next = NEXT(item_tag, NEXT_ENTRY(UNSIGNED),
3248 NEXT_ENTRY(ITEM_PARAM_IS)),
3249 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, index)),
3251 [ITEM_L2TPV3OIP] = {
3252 .name = "l2tpv3oip",
3253 .help = "match L2TPv3 over IP header",
3254 .priv = PRIV_ITEM(L2TPV3OIP,
3255 sizeof(struct rte_flow_item_l2tpv3oip)),
3256 .next = NEXT(item_l2tpv3oip),
3259 [ITEM_L2TPV3OIP_SESSION_ID] = {
3260 .name = "session_id",
3261 .help = "session identifier",
3262 .next = NEXT(item_l2tpv3oip, NEXT_ENTRY(UNSIGNED), item_param),
3263 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv3oip,
3268 .help = "match ESP header",
3269 .priv = PRIV_ITEM(ESP, sizeof(struct rte_flow_item_esp)),
3270 .next = NEXT(item_esp),
3275 .help = "security policy index",
3276 .next = NEXT(item_esp, NEXT_ENTRY(UNSIGNED), item_param),
3277 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_esp,
3282 .help = "match AH header",
3283 .priv = PRIV_ITEM(AH, sizeof(struct rte_flow_item_ah)),
3284 .next = NEXT(item_ah),
3289 .help = "security parameters index",
3290 .next = NEXT(item_ah, NEXT_ENTRY(UNSIGNED), item_param),
3291 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ah, spi)),
3295 .help = "match pfcp header",
3296 .priv = PRIV_ITEM(PFCP, sizeof(struct rte_flow_item_pfcp)),
3297 .next = NEXT(item_pfcp),
3300 [ITEM_PFCP_S_FIELD] = {
3303 .next = NEXT(item_pfcp, NEXT_ENTRY(UNSIGNED), item_param),
3304 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp,
3307 [ITEM_PFCP_SEID] = {
3309 .help = "session endpoint identifier",
3310 .next = NEXT(item_pfcp, NEXT_ENTRY(UNSIGNED), item_param),
3311 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp, seid)),
3315 .help = "match eCPRI header",
3316 .priv = PRIV_ITEM(ECPRI, sizeof(struct rte_flow_item_ecpri)),
3317 .next = NEXT(item_ecpri),
3320 [ITEM_ECPRI_COMMON] = {
3322 .help = "eCPRI common header",
3323 .next = NEXT(item_ecpri_common),
3325 [ITEM_ECPRI_COMMON_TYPE] = {
3327 .help = "type of common header",
3328 .next = NEXT(item_ecpri_common_type),
3329 .args = ARGS(ARG_ENTRY_HTON(struct rte_flow_item_ecpri)),
3331 [ITEM_ECPRI_COMMON_TYPE_IQ_DATA] = {
3333 .help = "Type #0: IQ Data",
3334 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
3336 .call = parse_vc_item_ecpri_type,
3338 [ITEM_ECPRI_MSG_IQ_DATA_PCID] = {
3340 .help = "Physical Channel ID",
3341 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
3342 ITEM_ECPRI_COMMON, ITEM_NEXT),
3343 NEXT_ENTRY(UNSIGNED), item_param),
3344 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3347 [ITEM_ECPRI_COMMON_TYPE_RTC_CTRL] = {
3349 .help = "Type #2: Real-Time Control Data",
3350 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
3352 .call = parse_vc_item_ecpri_type,
3354 [ITEM_ECPRI_MSG_RTC_CTRL_RTCID] = {
3356 .help = "Real-Time Control Data ID",
3357 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
3358 ITEM_ECPRI_COMMON, ITEM_NEXT),
3359 NEXT_ENTRY(UNSIGNED), item_param),
3360 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3363 [ITEM_ECPRI_COMMON_TYPE_DLY_MSR] = {
3364 .name = "delay_measure",
3365 .help = "Type #5: One-Way Delay Measurement",
3366 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
3368 .call = parse_vc_item_ecpri_type,
3370 [ITEM_ECPRI_MSG_DLY_MSR_MSRID] = {
3372 .help = "Measurement ID",
3373 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
3374 ITEM_ECPRI_COMMON, ITEM_NEXT),
3375 NEXT_ENTRY(UNSIGNED), item_param),
3376 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3379 [ITEM_GENEVE_OPT] = {
3380 .name = "geneve-opt",
3381 .help = "GENEVE header option",
3382 .priv = PRIV_ITEM(GENEVE_OPT,
3383 sizeof(struct rte_flow_item_geneve_opt) +
3384 ITEM_GENEVE_OPT_DATA_SIZE),
3385 .next = NEXT(item_geneve_opt),
3388 [ITEM_GENEVE_OPT_CLASS] = {
3390 .help = "GENEVE option class",
3391 .next = NEXT(item_geneve_opt, NEXT_ENTRY(UNSIGNED), item_param),
3392 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve_opt,
3395 [ITEM_GENEVE_OPT_TYPE] = {
3397 .help = "GENEVE option type",
3398 .next = NEXT(item_geneve_opt, NEXT_ENTRY(UNSIGNED), item_param),
3399 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt,
3402 [ITEM_GENEVE_OPT_LENGTH] = {
3404 .help = "GENEVE option data length (in 32b words)",
3405 .next = NEXT(item_geneve_opt, NEXT_ENTRY(UNSIGNED), item_param),
3406 .args = ARGS(ARGS_ENTRY_BOUNDED(
3407 struct rte_flow_item_geneve_opt, option_len,
3410 [ITEM_GENEVE_OPT_DATA] = {
3412 .help = "GENEVE option data pattern",
3413 .next = NEXT(item_geneve_opt, NEXT_ENTRY(HEX), item_param),
3414 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt, data),
3415 ARGS_ENTRY_ARB(0, 0),
3417 (sizeof(struct rte_flow_item_geneve_opt),
3418 ITEM_GENEVE_OPT_DATA_SIZE)),
3420 [ITEM_INTEGRITY] = {
3421 .name = "integrity",
3422 .help = "match packet integrity",
3423 .priv = PRIV_ITEM(INTEGRITY,
3424 sizeof(struct rte_flow_item_integrity)),
3425 .next = NEXT(item_integrity),
3428 [ITEM_INTEGRITY_LEVEL] = {
3430 .help = "integrity level",
3431 .next = NEXT(item_integrity_lv, NEXT_ENTRY(UNSIGNED),
3433 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_integrity, level)),
3435 [ITEM_INTEGRITY_VALUE] = {
3437 .help = "integrity value",
3438 .next = NEXT(item_integrity_lv, NEXT_ENTRY(UNSIGNED),
3440 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_integrity, value)),
3442 /* Validate/create actions. */
3445 .help = "submit a list of associated actions",
3446 .next = NEXT(next_action),
3451 .help = "specify next action",
3452 .next = NEXT(next_action),
3456 .help = "end list of actions",
3457 .priv = PRIV_ACTION(END, 0),
3462 .help = "no-op action",
3463 .priv = PRIV_ACTION(VOID, 0),
3464 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3467 [ACTION_PASSTHRU] = {
3469 .help = "let subsequent rule process matched packets",
3470 .priv = PRIV_ACTION(PASSTHRU, 0),
3471 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3476 .help = "redirect traffic to a given group",
3477 .priv = PRIV_ACTION(JUMP, sizeof(struct rte_flow_action_jump)),
3478 .next = NEXT(action_jump),
3481 [ACTION_JUMP_GROUP] = {
3483 .help = "group to redirect traffic to",
3484 .next = NEXT(action_jump, NEXT_ENTRY(UNSIGNED)),
3485 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump, group)),
3486 .call = parse_vc_conf,
3490 .help = "attach 32 bit value to packets",
3491 .priv = PRIV_ACTION(MARK, sizeof(struct rte_flow_action_mark)),
3492 .next = NEXT(action_mark),
3495 [ACTION_MARK_ID] = {
3497 .help = "32 bit value to return with packets",
3498 .next = NEXT(action_mark, NEXT_ENTRY(UNSIGNED)),
3499 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_mark, id)),
3500 .call = parse_vc_conf,
3504 .help = "flag packets",
3505 .priv = PRIV_ACTION(FLAG, 0),
3506 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3511 .help = "assign packets to a given queue index",
3512 .priv = PRIV_ACTION(QUEUE,
3513 sizeof(struct rte_flow_action_queue)),
3514 .next = NEXT(action_queue),
3517 [ACTION_QUEUE_INDEX] = {
3519 .help = "queue index to use",
3520 .next = NEXT(action_queue, NEXT_ENTRY(UNSIGNED)),
3521 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_queue, index)),
3522 .call = parse_vc_conf,
3526 .help = "drop packets (note: passthru has priority)",
3527 .priv = PRIV_ACTION(DROP, 0),
3528 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3533 .help = "enable counters for this rule",
3534 .priv = PRIV_ACTION(COUNT,
3535 sizeof(struct rte_flow_action_count)),
3536 .next = NEXT(action_count),
3539 [ACTION_COUNT_ID] = {
3540 .name = "identifier",
3541 .help = "counter identifier to use",
3542 .next = NEXT(action_count, NEXT_ENTRY(UNSIGNED)),
3543 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_count, id)),
3544 .call = parse_vc_conf,
3546 [ACTION_COUNT_SHARED] = {
3548 .help = "shared counter",
3549 .next = NEXT(action_count, NEXT_ENTRY(BOOLEAN)),
3550 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_count,
3552 .call = parse_vc_conf,
3556 .help = "spread packets among several queues",
3557 .priv = PRIV_ACTION(RSS, sizeof(struct action_rss_data)),
3558 .next = NEXT(action_rss),
3559 .call = parse_vc_action_rss,
3561 [ACTION_RSS_FUNC] = {
3563 .help = "RSS hash function to apply",
3564 .next = NEXT(action_rss,
3565 NEXT_ENTRY(ACTION_RSS_FUNC_DEFAULT,
3566 ACTION_RSS_FUNC_TOEPLITZ,
3567 ACTION_RSS_FUNC_SIMPLE_XOR,
3568 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ)),
3570 [ACTION_RSS_FUNC_DEFAULT] = {
3572 .help = "default hash function",
3573 .call = parse_vc_action_rss_func,
3575 [ACTION_RSS_FUNC_TOEPLITZ] = {
3577 .help = "Toeplitz hash function",
3578 .call = parse_vc_action_rss_func,
3580 [ACTION_RSS_FUNC_SIMPLE_XOR] = {
3581 .name = "simple_xor",
3582 .help = "simple XOR hash function",
3583 .call = parse_vc_action_rss_func,
3585 [ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ] = {
3586 .name = "symmetric_toeplitz",
3587 .help = "Symmetric Toeplitz hash function",
3588 .call = parse_vc_action_rss_func,
3590 [ACTION_RSS_LEVEL] = {
3592 .help = "encapsulation level for \"types\"",
3593 .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
3594 .args = ARGS(ARGS_ENTRY_ARB
3595 (offsetof(struct action_rss_data, conf) +
3596 offsetof(struct rte_flow_action_rss, level),
3597 sizeof(((struct rte_flow_action_rss *)0)->
3600 [ACTION_RSS_TYPES] = {
3602 .help = "specific RSS hash types",
3603 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)),
3605 [ACTION_RSS_TYPE] = {
3607 .help = "RSS hash type",
3608 .call = parse_vc_action_rss_type,
3609 .comp = comp_vc_action_rss_type,
3611 [ACTION_RSS_KEY] = {
3613 .help = "RSS hash key",
3614 .next = NEXT(action_rss, NEXT_ENTRY(HEX)),
3615 .args = ARGS(ARGS_ENTRY_ARB
3616 (offsetof(struct action_rss_data, conf) +
3617 offsetof(struct rte_flow_action_rss, key),
3618 sizeof(((struct rte_flow_action_rss *)0)->key)),
3620 (offsetof(struct action_rss_data, conf) +
3621 offsetof(struct rte_flow_action_rss, key_len),
3622 sizeof(((struct rte_flow_action_rss *)0)->
3624 ARGS_ENTRY(struct action_rss_data, key)),
3626 [ACTION_RSS_KEY_LEN] = {
3628 .help = "RSS hash key length in bytes",
3629 .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
3630 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
3631 (offsetof(struct action_rss_data, conf) +
3632 offsetof(struct rte_flow_action_rss, key_len),
3633 sizeof(((struct rte_flow_action_rss *)0)->
3636 RSS_HASH_KEY_LENGTH)),
3638 [ACTION_RSS_QUEUES] = {
3640 .help = "queue indices to use",
3641 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_QUEUE)),
3642 .call = parse_vc_conf,
3644 [ACTION_RSS_QUEUE] = {
3646 .help = "queue index",
3647 .call = parse_vc_action_rss_queue,
3648 .comp = comp_vc_action_rss_queue,
3652 .help = "direct traffic to physical function",
3653 .priv = PRIV_ACTION(PF, 0),
3654 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3659 .help = "direct traffic to a virtual function ID",
3660 .priv = PRIV_ACTION(VF, sizeof(struct rte_flow_action_vf)),
3661 .next = NEXT(action_vf),
3664 [ACTION_VF_ORIGINAL] = {
3666 .help = "use original VF ID if possible",
3667 .next = NEXT(action_vf, NEXT_ENTRY(BOOLEAN)),
3668 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_vf,
3670 .call = parse_vc_conf,
3675 .next = NEXT(action_vf, NEXT_ENTRY(UNSIGNED)),
3676 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)),
3677 .call = parse_vc_conf,
3679 [ACTION_PHY_PORT] = {
3681 .help = "direct packets to physical port index",
3682 .priv = PRIV_ACTION(PHY_PORT,
3683 sizeof(struct rte_flow_action_phy_port)),
3684 .next = NEXT(action_phy_port),
3687 [ACTION_PHY_PORT_ORIGINAL] = {
3689 .help = "use original port index if possible",
3690 .next = NEXT(action_phy_port, NEXT_ENTRY(BOOLEAN)),
3691 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_phy_port,
3693 .call = parse_vc_conf,
3695 [ACTION_PHY_PORT_INDEX] = {
3697 .help = "physical port index",
3698 .next = NEXT(action_phy_port, NEXT_ENTRY(UNSIGNED)),
3699 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_phy_port,
3701 .call = parse_vc_conf,
3703 [ACTION_PORT_ID] = {
3705 .help = "direct matching traffic to a given DPDK port ID",
3706 .priv = PRIV_ACTION(PORT_ID,
3707 sizeof(struct rte_flow_action_port_id)),
3708 .next = NEXT(action_port_id),
3711 [ACTION_PORT_ID_ORIGINAL] = {
3713 .help = "use original DPDK port ID if possible",
3714 .next = NEXT(action_port_id, NEXT_ENTRY(BOOLEAN)),
3715 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_port_id,
3717 .call = parse_vc_conf,
3719 [ACTION_PORT_ID_ID] = {
3721 .help = "DPDK port ID",
3722 .next = NEXT(action_port_id, NEXT_ENTRY(UNSIGNED)),
3723 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_port_id, id)),
3724 .call = parse_vc_conf,
3728 .help = "meter the directed packets at given id",
3729 .priv = PRIV_ACTION(METER,
3730 sizeof(struct rte_flow_action_meter)),
3731 .next = NEXT(action_meter),
3734 [ACTION_METER_ID] = {
3736 .help = "meter id to use",
3737 .next = NEXT(action_meter, NEXT_ENTRY(UNSIGNED)),
3738 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter, mtr_id)),
3739 .call = parse_vc_conf,
3741 [ACTION_OF_SET_MPLS_TTL] = {
3742 .name = "of_set_mpls_ttl",
3743 .help = "OpenFlow's OFPAT_SET_MPLS_TTL",
3746 sizeof(struct rte_flow_action_of_set_mpls_ttl)),
3747 .next = NEXT(action_of_set_mpls_ttl),
3750 [ACTION_OF_SET_MPLS_TTL_MPLS_TTL] = {
3753 .next = NEXT(action_of_set_mpls_ttl, NEXT_ENTRY(UNSIGNED)),
3754 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_mpls_ttl,
3756 .call = parse_vc_conf,
3758 [ACTION_OF_DEC_MPLS_TTL] = {
3759 .name = "of_dec_mpls_ttl",
3760 .help = "OpenFlow's OFPAT_DEC_MPLS_TTL",
3761 .priv = PRIV_ACTION(OF_DEC_MPLS_TTL, 0),
3762 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3765 [ACTION_OF_SET_NW_TTL] = {
3766 .name = "of_set_nw_ttl",
3767 .help = "OpenFlow's OFPAT_SET_NW_TTL",
3770 sizeof(struct rte_flow_action_of_set_nw_ttl)),
3771 .next = NEXT(action_of_set_nw_ttl),
3774 [ACTION_OF_SET_NW_TTL_NW_TTL] = {
3777 .next = NEXT(action_of_set_nw_ttl, NEXT_ENTRY(UNSIGNED)),
3778 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_nw_ttl,
3780 .call = parse_vc_conf,
3782 [ACTION_OF_DEC_NW_TTL] = {
3783 .name = "of_dec_nw_ttl",
3784 .help = "OpenFlow's OFPAT_DEC_NW_TTL",
3785 .priv = PRIV_ACTION(OF_DEC_NW_TTL, 0),
3786 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3789 [ACTION_OF_COPY_TTL_OUT] = {
3790 .name = "of_copy_ttl_out",
3791 .help = "OpenFlow's OFPAT_COPY_TTL_OUT",
3792 .priv = PRIV_ACTION(OF_COPY_TTL_OUT, 0),
3793 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3796 [ACTION_OF_COPY_TTL_IN] = {
3797 .name = "of_copy_ttl_in",
3798 .help = "OpenFlow's OFPAT_COPY_TTL_IN",
3799 .priv = PRIV_ACTION(OF_COPY_TTL_IN, 0),
3800 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3803 [ACTION_OF_POP_VLAN] = {
3804 .name = "of_pop_vlan",
3805 .help = "OpenFlow's OFPAT_POP_VLAN",
3806 .priv = PRIV_ACTION(OF_POP_VLAN, 0),
3807 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3810 [ACTION_OF_PUSH_VLAN] = {
3811 .name = "of_push_vlan",
3812 .help = "OpenFlow's OFPAT_PUSH_VLAN",
3815 sizeof(struct rte_flow_action_of_push_vlan)),
3816 .next = NEXT(action_of_push_vlan),
3819 [ACTION_OF_PUSH_VLAN_ETHERTYPE] = {
3820 .name = "ethertype",
3821 .help = "EtherType",
3822 .next = NEXT(action_of_push_vlan, NEXT_ENTRY(UNSIGNED)),
3823 .args = ARGS(ARGS_ENTRY_HTON
3824 (struct rte_flow_action_of_push_vlan,
3826 .call = parse_vc_conf,
3828 [ACTION_OF_SET_VLAN_VID] = {
3829 .name = "of_set_vlan_vid",
3830 .help = "OpenFlow's OFPAT_SET_VLAN_VID",
3833 sizeof(struct rte_flow_action_of_set_vlan_vid)),
3834 .next = NEXT(action_of_set_vlan_vid),
3837 [ACTION_OF_SET_VLAN_VID_VLAN_VID] = {
3840 .next = NEXT(action_of_set_vlan_vid, NEXT_ENTRY(UNSIGNED)),
3841 .args = ARGS(ARGS_ENTRY_HTON
3842 (struct rte_flow_action_of_set_vlan_vid,
3844 .call = parse_vc_conf,
3846 [ACTION_OF_SET_VLAN_PCP] = {
3847 .name = "of_set_vlan_pcp",
3848 .help = "OpenFlow's OFPAT_SET_VLAN_PCP",
3851 sizeof(struct rte_flow_action_of_set_vlan_pcp)),
3852 .next = NEXT(action_of_set_vlan_pcp),
3855 [ACTION_OF_SET_VLAN_PCP_VLAN_PCP] = {
3857 .help = "VLAN priority",
3858 .next = NEXT(action_of_set_vlan_pcp, NEXT_ENTRY(UNSIGNED)),
3859 .args = ARGS(ARGS_ENTRY_HTON
3860 (struct rte_flow_action_of_set_vlan_pcp,
3862 .call = parse_vc_conf,
3864 [ACTION_OF_POP_MPLS] = {
3865 .name = "of_pop_mpls",
3866 .help = "OpenFlow's OFPAT_POP_MPLS",
3867 .priv = PRIV_ACTION(OF_POP_MPLS,
3868 sizeof(struct rte_flow_action_of_pop_mpls)),
3869 .next = NEXT(action_of_pop_mpls),
3872 [ACTION_OF_POP_MPLS_ETHERTYPE] = {
3873 .name = "ethertype",
3874 .help = "EtherType",
3875 .next = NEXT(action_of_pop_mpls, NEXT_ENTRY(UNSIGNED)),
3876 .args = ARGS(ARGS_ENTRY_HTON
3877 (struct rte_flow_action_of_pop_mpls,
3879 .call = parse_vc_conf,
3881 [ACTION_OF_PUSH_MPLS] = {
3882 .name = "of_push_mpls",
3883 .help = "OpenFlow's OFPAT_PUSH_MPLS",
3886 sizeof(struct rte_flow_action_of_push_mpls)),
3887 .next = NEXT(action_of_push_mpls),
3890 [ACTION_OF_PUSH_MPLS_ETHERTYPE] = {
3891 .name = "ethertype",
3892 .help = "EtherType",
3893 .next = NEXT(action_of_push_mpls, NEXT_ENTRY(UNSIGNED)),
3894 .args = ARGS(ARGS_ENTRY_HTON
3895 (struct rte_flow_action_of_push_mpls,
3897 .call = parse_vc_conf,
3899 [ACTION_VXLAN_ENCAP] = {
3900 .name = "vxlan_encap",
3901 .help = "VXLAN encapsulation, uses configuration set by \"set"
3903 .priv = PRIV_ACTION(VXLAN_ENCAP,
3904 sizeof(struct action_vxlan_encap_data)),
3905 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3906 .call = parse_vc_action_vxlan_encap,
3908 [ACTION_VXLAN_DECAP] = {
3909 .name = "vxlan_decap",
3910 .help = "Performs a decapsulation action by stripping all"
3911 " headers of the VXLAN tunnel network overlay from the"
3913 .priv = PRIV_ACTION(VXLAN_DECAP, 0),
3914 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3917 [ACTION_NVGRE_ENCAP] = {
3918 .name = "nvgre_encap",
3919 .help = "NVGRE encapsulation, uses configuration set by \"set"
3921 .priv = PRIV_ACTION(NVGRE_ENCAP,
3922 sizeof(struct action_nvgre_encap_data)),
3923 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3924 .call = parse_vc_action_nvgre_encap,
3926 [ACTION_NVGRE_DECAP] = {
3927 .name = "nvgre_decap",
3928 .help = "Performs a decapsulation action by stripping all"
3929 " headers of the NVGRE tunnel network overlay from the"
3931 .priv = PRIV_ACTION(NVGRE_DECAP, 0),
3932 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3935 [ACTION_L2_ENCAP] = {
3937 .help = "l2 encap, uses configuration set by"
3938 " \"set l2_encap\"",
3939 .priv = PRIV_ACTION(RAW_ENCAP,
3940 sizeof(struct action_raw_encap_data)),
3941 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3942 .call = parse_vc_action_l2_encap,
3944 [ACTION_L2_DECAP] = {
3946 .help = "l2 decap, uses configuration set by"
3947 " \"set l2_decap\"",
3948 .priv = PRIV_ACTION(RAW_DECAP,
3949 sizeof(struct action_raw_decap_data)),
3950 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3951 .call = parse_vc_action_l2_decap,
3953 [ACTION_MPLSOGRE_ENCAP] = {
3954 .name = "mplsogre_encap",
3955 .help = "mplsogre encapsulation, uses configuration set by"
3956 " \"set mplsogre_encap\"",
3957 .priv = PRIV_ACTION(RAW_ENCAP,
3958 sizeof(struct action_raw_encap_data)),
3959 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3960 .call = parse_vc_action_mplsogre_encap,
3962 [ACTION_MPLSOGRE_DECAP] = {
3963 .name = "mplsogre_decap",
3964 .help = "mplsogre decapsulation, uses configuration set by"
3965 " \"set mplsogre_decap\"",
3966 .priv = PRIV_ACTION(RAW_DECAP,
3967 sizeof(struct action_raw_decap_data)),
3968 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3969 .call = parse_vc_action_mplsogre_decap,
3971 [ACTION_MPLSOUDP_ENCAP] = {
3972 .name = "mplsoudp_encap",
3973 .help = "mplsoudp encapsulation, uses configuration set by"
3974 " \"set mplsoudp_encap\"",
3975 .priv = PRIV_ACTION(RAW_ENCAP,
3976 sizeof(struct action_raw_encap_data)),
3977 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3978 .call = parse_vc_action_mplsoudp_encap,
3980 [ACTION_MPLSOUDP_DECAP] = {
3981 .name = "mplsoudp_decap",
3982 .help = "mplsoudp decapsulation, uses configuration set by"
3983 " \"set mplsoudp_decap\"",
3984 .priv = PRIV_ACTION(RAW_DECAP,
3985 sizeof(struct action_raw_decap_data)),
3986 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3987 .call = parse_vc_action_mplsoudp_decap,
3989 [ACTION_SET_IPV4_SRC] = {
3990 .name = "set_ipv4_src",
3991 .help = "Set a new IPv4 source address in the outermost"
3993 .priv = PRIV_ACTION(SET_IPV4_SRC,
3994 sizeof(struct rte_flow_action_set_ipv4)),
3995 .next = NEXT(action_set_ipv4_src),
3998 [ACTION_SET_IPV4_SRC_IPV4_SRC] = {
3999 .name = "ipv4_addr",
4000 .help = "new IPv4 source address to set",
4001 .next = NEXT(action_set_ipv4_src, NEXT_ENTRY(IPV4_ADDR)),
4002 .args = ARGS(ARGS_ENTRY_HTON
4003 (struct rte_flow_action_set_ipv4, ipv4_addr)),
4004 .call = parse_vc_conf,
4006 [ACTION_SET_IPV4_DST] = {
4007 .name = "set_ipv4_dst",
4008 .help = "Set a new IPv4 destination address in the outermost"
4010 .priv = PRIV_ACTION(SET_IPV4_DST,
4011 sizeof(struct rte_flow_action_set_ipv4)),
4012 .next = NEXT(action_set_ipv4_dst),
4015 [ACTION_SET_IPV4_DST_IPV4_DST] = {
4016 .name = "ipv4_addr",
4017 .help = "new IPv4 destination address to set",
4018 .next = NEXT(action_set_ipv4_dst, NEXT_ENTRY(IPV4_ADDR)),
4019 .args = ARGS(ARGS_ENTRY_HTON
4020 (struct rte_flow_action_set_ipv4, ipv4_addr)),
4021 .call = parse_vc_conf,
4023 [ACTION_SET_IPV6_SRC] = {
4024 .name = "set_ipv6_src",
4025 .help = "Set a new IPv6 source address in the outermost"
4027 .priv = PRIV_ACTION(SET_IPV6_SRC,
4028 sizeof(struct rte_flow_action_set_ipv6)),
4029 .next = NEXT(action_set_ipv6_src),
4032 [ACTION_SET_IPV6_SRC_IPV6_SRC] = {
4033 .name = "ipv6_addr",
4034 .help = "new IPv6 source address to set",
4035 .next = NEXT(action_set_ipv6_src, NEXT_ENTRY(IPV6_ADDR)),
4036 .args = ARGS(ARGS_ENTRY_HTON
4037 (struct rte_flow_action_set_ipv6, ipv6_addr)),
4038 .call = parse_vc_conf,
4040 [ACTION_SET_IPV6_DST] = {
4041 .name = "set_ipv6_dst",
4042 .help = "Set a new IPv6 destination address in the outermost"
4044 .priv = PRIV_ACTION(SET_IPV6_DST,
4045 sizeof(struct rte_flow_action_set_ipv6)),
4046 .next = NEXT(action_set_ipv6_dst),
4049 [ACTION_SET_IPV6_DST_IPV6_DST] = {
4050 .name = "ipv6_addr",
4051 .help = "new IPv6 destination address to set",
4052 .next = NEXT(action_set_ipv6_dst, NEXT_ENTRY(IPV6_ADDR)),
4053 .args = ARGS(ARGS_ENTRY_HTON
4054 (struct rte_flow_action_set_ipv6, ipv6_addr)),
4055 .call = parse_vc_conf,
4057 [ACTION_SET_TP_SRC] = {
4058 .name = "set_tp_src",
4059 .help = "set a new source port number in the outermost"
4061 .priv = PRIV_ACTION(SET_TP_SRC,
4062 sizeof(struct rte_flow_action_set_tp)),
4063 .next = NEXT(action_set_tp_src),
4066 [ACTION_SET_TP_SRC_TP_SRC] = {
4068 .help = "new source port number to set",
4069 .next = NEXT(action_set_tp_src, NEXT_ENTRY(UNSIGNED)),
4070 .args = ARGS(ARGS_ENTRY_HTON
4071 (struct rte_flow_action_set_tp, port)),
4072 .call = parse_vc_conf,
4074 [ACTION_SET_TP_DST] = {
4075 .name = "set_tp_dst",
4076 .help = "set a new destination port number in the outermost"
4078 .priv = PRIV_ACTION(SET_TP_DST,
4079 sizeof(struct rte_flow_action_set_tp)),
4080 .next = NEXT(action_set_tp_dst),
4083 [ACTION_SET_TP_DST_TP_DST] = {
4085 .help = "new destination port number to set",
4086 .next = NEXT(action_set_tp_dst, NEXT_ENTRY(UNSIGNED)),
4087 .args = ARGS(ARGS_ENTRY_HTON
4088 (struct rte_flow_action_set_tp, port)),
4089 .call = parse_vc_conf,
4091 [ACTION_MAC_SWAP] = {
4093 .help = "Swap the source and destination MAC addresses"
4094 " in the outermost Ethernet header",
4095 .priv = PRIV_ACTION(MAC_SWAP, 0),
4096 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4099 [ACTION_DEC_TTL] = {
4101 .help = "decrease network TTL if available",
4102 .priv = PRIV_ACTION(DEC_TTL, 0),
4103 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4106 [ACTION_SET_TTL] = {
4108 .help = "set ttl value",
4109 .priv = PRIV_ACTION(SET_TTL,
4110 sizeof(struct rte_flow_action_set_ttl)),
4111 .next = NEXT(action_set_ttl),
4114 [ACTION_SET_TTL_TTL] = {
4115 .name = "ttl_value",
4116 .help = "new ttl value to set",
4117 .next = NEXT(action_set_ttl, NEXT_ENTRY(UNSIGNED)),
4118 .args = ARGS(ARGS_ENTRY_HTON
4119 (struct rte_flow_action_set_ttl, ttl_value)),
4120 .call = parse_vc_conf,
4122 [ACTION_SET_MAC_SRC] = {
4123 .name = "set_mac_src",
4124 .help = "set source mac address",
4125 .priv = PRIV_ACTION(SET_MAC_SRC,
4126 sizeof(struct rte_flow_action_set_mac)),
4127 .next = NEXT(action_set_mac_src),
4130 [ACTION_SET_MAC_SRC_MAC_SRC] = {
4132 .help = "new source mac address",
4133 .next = NEXT(action_set_mac_src, NEXT_ENTRY(MAC_ADDR)),
4134 .args = ARGS(ARGS_ENTRY_HTON
4135 (struct rte_flow_action_set_mac, mac_addr)),
4136 .call = parse_vc_conf,
4138 [ACTION_SET_MAC_DST] = {
4139 .name = "set_mac_dst",
4140 .help = "set destination mac address",
4141 .priv = PRIV_ACTION(SET_MAC_DST,
4142 sizeof(struct rte_flow_action_set_mac)),
4143 .next = NEXT(action_set_mac_dst),
4146 [ACTION_SET_MAC_DST_MAC_DST] = {
4148 .help = "new destination mac address to set",
4149 .next = NEXT(action_set_mac_dst, NEXT_ENTRY(MAC_ADDR)),
4150 .args = ARGS(ARGS_ENTRY_HTON
4151 (struct rte_flow_action_set_mac, mac_addr)),
4152 .call = parse_vc_conf,
4154 [ACTION_INC_TCP_SEQ] = {
4155 .name = "inc_tcp_seq",
4156 .help = "increase TCP sequence number",
4157 .priv = PRIV_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
4158 .next = NEXT(action_inc_tcp_seq),
4161 [ACTION_INC_TCP_SEQ_VALUE] = {
4163 .help = "the value to increase TCP sequence number by",
4164 .next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(UNSIGNED)),
4165 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4166 .call = parse_vc_conf,
4168 [ACTION_DEC_TCP_SEQ] = {
4169 .name = "dec_tcp_seq",
4170 .help = "decrease TCP sequence number",
4171 .priv = PRIV_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
4172 .next = NEXT(action_dec_tcp_seq),
4175 [ACTION_DEC_TCP_SEQ_VALUE] = {
4177 .help = "the value to decrease TCP sequence number by",
4178 .next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(UNSIGNED)),
4179 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4180 .call = parse_vc_conf,
4182 [ACTION_INC_TCP_ACK] = {
4183 .name = "inc_tcp_ack",
4184 .help = "increase TCP acknowledgment number",
4185 .priv = PRIV_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
4186 .next = NEXT(action_inc_tcp_ack),
4189 [ACTION_INC_TCP_ACK_VALUE] = {
4191 .help = "the value to increase TCP acknowledgment number by",
4192 .next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(UNSIGNED)),
4193 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4194 .call = parse_vc_conf,
4196 [ACTION_DEC_TCP_ACK] = {
4197 .name = "dec_tcp_ack",
4198 .help = "decrease TCP acknowledgment number",
4199 .priv = PRIV_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
4200 .next = NEXT(action_dec_tcp_ack),
4203 [ACTION_DEC_TCP_ACK_VALUE] = {
4205 .help = "the value to decrease TCP acknowledgment number by",
4206 .next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(UNSIGNED)),
4207 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4208 .call = parse_vc_conf,
4210 [ACTION_RAW_ENCAP] = {
4211 .name = "raw_encap",
4212 .help = "encapsulation data, defined by set raw_encap",
4213 .priv = PRIV_ACTION(RAW_ENCAP,
4214 sizeof(struct action_raw_encap_data)),
4215 .next = NEXT(action_raw_encap),
4216 .call = parse_vc_action_raw_encap,
4218 [ACTION_RAW_ENCAP_INDEX] = {
4220 .help = "the index of raw_encap_confs",
4221 .next = NEXT(NEXT_ENTRY(ACTION_RAW_ENCAP_INDEX_VALUE)),
4223 [ACTION_RAW_ENCAP_INDEX_VALUE] = {
4226 .help = "unsigned integer value",
4227 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4228 .call = parse_vc_action_raw_encap_index,
4229 .comp = comp_set_raw_index,
4231 [ACTION_RAW_DECAP] = {
4232 .name = "raw_decap",
4233 .help = "decapsulation data, defined by set raw_encap",
4234 .priv = PRIV_ACTION(RAW_DECAP,
4235 sizeof(struct action_raw_decap_data)),
4236 .next = NEXT(action_raw_decap),
4237 .call = parse_vc_action_raw_decap,
4239 [ACTION_RAW_DECAP_INDEX] = {
4241 .help = "the index of raw_encap_confs",
4242 .next = NEXT(NEXT_ENTRY(ACTION_RAW_DECAP_INDEX_VALUE)),
4244 [ACTION_RAW_DECAP_INDEX_VALUE] = {
4247 .help = "unsigned integer value",
4248 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4249 .call = parse_vc_action_raw_decap_index,
4250 .comp = comp_set_raw_index,
4252 [ACTION_MODIFY_FIELD] = {
4253 .name = "modify_field",
4254 .help = "modify destination field with data from source field",
4255 .priv = PRIV_ACTION(MODIFY_FIELD,
4256 sizeof(struct rte_flow_action_modify_field)),
4257 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_OP)),
4260 [ACTION_MODIFY_FIELD_OP] = {
4262 .help = "operation type",
4263 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_TYPE),
4264 NEXT_ENTRY(ACTION_MODIFY_FIELD_OP_VALUE)),
4265 .call = parse_vc_conf,
4267 [ACTION_MODIFY_FIELD_OP_VALUE] = {
4268 .name = "{operation}",
4269 .help = "operation type value",
4270 .call = parse_vc_modify_field_op,
4271 .comp = comp_set_modify_field_op,
4273 [ACTION_MODIFY_FIELD_DST_TYPE] = {
4275 .help = "destination field type",
4276 .next = NEXT(action_modify_field_dst,
4277 NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_TYPE_VALUE)),
4278 .call = parse_vc_conf,
4280 [ACTION_MODIFY_FIELD_DST_TYPE_VALUE] = {
4281 .name = "{dst_type}",
4282 .help = "destination field type value",
4283 .call = parse_vc_modify_field_id,
4284 .comp = comp_set_modify_field_id,
4286 [ACTION_MODIFY_FIELD_DST_LEVEL] = {
4287 .name = "dst_level",
4288 .help = "destination field level",
4289 .next = NEXT(action_modify_field_dst, NEXT_ENTRY(UNSIGNED)),
4290 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4292 .call = parse_vc_conf,
4294 [ACTION_MODIFY_FIELD_DST_OFFSET] = {
4295 .name = "dst_offset",
4296 .help = "destination field bit offset",
4297 .next = NEXT(action_modify_field_dst, NEXT_ENTRY(UNSIGNED)),
4298 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4300 .call = parse_vc_conf,
4302 [ACTION_MODIFY_FIELD_SRC_TYPE] = {
4304 .help = "source field type",
4305 .next = NEXT(action_modify_field_src,
4306 NEXT_ENTRY(ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)),
4307 .call = parse_vc_conf,
4309 [ACTION_MODIFY_FIELD_SRC_TYPE_VALUE] = {
4310 .name = "{src_type}",
4311 .help = "source field type value",
4312 .call = parse_vc_modify_field_id,
4313 .comp = comp_set_modify_field_id,
4315 [ACTION_MODIFY_FIELD_SRC_LEVEL] = {
4316 .name = "src_level",
4317 .help = "source field level",
4318 .next = NEXT(action_modify_field_src, NEXT_ENTRY(UNSIGNED)),
4319 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4321 .call = parse_vc_conf,
4323 [ACTION_MODIFY_FIELD_SRC_OFFSET] = {
4324 .name = "src_offset",
4325 .help = "source field bit offset",
4326 .next = NEXT(action_modify_field_src, NEXT_ENTRY(UNSIGNED)),
4327 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4329 .call = parse_vc_conf,
4331 [ACTION_MODIFY_FIELD_SRC_VALUE] = {
4332 .name = "src_value",
4333 .help = "source immediate value",
4334 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_WIDTH),
4335 NEXT_ENTRY(UNSIGNED)),
4336 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4338 .call = parse_vc_conf,
4340 [ACTION_MODIFY_FIELD_WIDTH] = {
4342 .help = "number of bits to copy",
4343 .next = NEXT(NEXT_ENTRY(ACTION_NEXT),
4344 NEXT_ENTRY(UNSIGNED)),
4345 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4347 .call = parse_vc_conf,
4349 /* Top level command. */
4352 .help = "set raw encap/decap/sample data",
4353 .type = "set raw_encap|raw_decap <index> <pattern>"
4354 " or set sample_actions <index> <action>",
4355 .next = NEXT(NEXT_ENTRY
4358 SET_SAMPLE_ACTIONS)),
4359 .call = parse_set_init,
4361 /* Sub-level commands. */
4363 .name = "raw_encap",
4364 .help = "set raw encap data",
4365 .next = NEXT(next_set_raw),
4366 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4367 (offsetof(struct buffer, port),
4368 sizeof(((struct buffer *)0)->port),
4369 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
4370 .call = parse_set_raw_encap_decap,
4373 .name = "raw_decap",
4374 .help = "set raw decap data",
4375 .next = NEXT(next_set_raw),
4376 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4377 (offsetof(struct buffer, port),
4378 sizeof(((struct buffer *)0)->port),
4379 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
4380 .call = parse_set_raw_encap_decap,
4385 .help = "index of raw_encap/raw_decap data",
4386 .next = NEXT(next_item),
4389 [SET_SAMPLE_INDEX] = {
4392 .help = "index of sample actions",
4393 .next = NEXT(next_action_sample),
4396 [SET_SAMPLE_ACTIONS] = {
4397 .name = "sample_actions",
4398 .help = "set sample actions list",
4399 .next = NEXT(NEXT_ENTRY(SET_SAMPLE_INDEX)),
4400 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4401 (offsetof(struct buffer, port),
4402 sizeof(((struct buffer *)0)->port),
4403 0, RAW_SAMPLE_CONFS_MAX_NUM - 1)),
4404 .call = parse_set_sample_action,
4406 [ACTION_SET_TAG] = {
4409 .priv = PRIV_ACTION(SET_TAG,
4410 sizeof(struct rte_flow_action_set_tag)),
4411 .next = NEXT(action_set_tag),
4414 [ACTION_SET_TAG_INDEX] = {
4416 .help = "index of tag array",
4417 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
4418 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_set_tag, index)),
4419 .call = parse_vc_conf,
4421 [ACTION_SET_TAG_DATA] = {
4423 .help = "tag value",
4424 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
4425 .args = ARGS(ARGS_ENTRY
4426 (struct rte_flow_action_set_tag, data)),
4427 .call = parse_vc_conf,
4429 [ACTION_SET_TAG_MASK] = {
4431 .help = "mask for tag value",
4432 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
4433 .args = ARGS(ARGS_ENTRY
4434 (struct rte_flow_action_set_tag, mask)),
4435 .call = parse_vc_conf,
4437 [ACTION_SET_META] = {
4439 .help = "set metadata",
4440 .priv = PRIV_ACTION(SET_META,
4441 sizeof(struct rte_flow_action_set_meta)),
4442 .next = NEXT(action_set_meta),
4443 .call = parse_vc_action_set_meta,
4445 [ACTION_SET_META_DATA] = {
4447 .help = "metadata value",
4448 .next = NEXT(action_set_meta, NEXT_ENTRY(UNSIGNED)),
4449 .args = ARGS(ARGS_ENTRY
4450 (struct rte_flow_action_set_meta, data)),
4451 .call = parse_vc_conf,
4453 [ACTION_SET_META_MASK] = {
4455 .help = "mask for metadata value",
4456 .next = NEXT(action_set_meta, NEXT_ENTRY(UNSIGNED)),
4457 .args = ARGS(ARGS_ENTRY
4458 (struct rte_flow_action_set_meta, mask)),
4459 .call = parse_vc_conf,
4461 [ACTION_SET_IPV4_DSCP] = {
4462 .name = "set_ipv4_dscp",
4463 .help = "set DSCP value",
4464 .priv = PRIV_ACTION(SET_IPV4_DSCP,
4465 sizeof(struct rte_flow_action_set_dscp)),
4466 .next = NEXT(action_set_ipv4_dscp),
4469 [ACTION_SET_IPV4_DSCP_VALUE] = {
4470 .name = "dscp_value",
4471 .help = "new IPv4 DSCP value to set",
4472 .next = NEXT(action_set_ipv4_dscp, NEXT_ENTRY(UNSIGNED)),
4473 .args = ARGS(ARGS_ENTRY
4474 (struct rte_flow_action_set_dscp, dscp)),
4475 .call = parse_vc_conf,
4477 [ACTION_SET_IPV6_DSCP] = {
4478 .name = "set_ipv6_dscp",
4479 .help = "set DSCP value",
4480 .priv = PRIV_ACTION(SET_IPV6_DSCP,
4481 sizeof(struct rte_flow_action_set_dscp)),
4482 .next = NEXT(action_set_ipv6_dscp),
4485 [ACTION_SET_IPV6_DSCP_VALUE] = {
4486 .name = "dscp_value",
4487 .help = "new IPv6 DSCP value to set",
4488 .next = NEXT(action_set_ipv6_dscp, NEXT_ENTRY(UNSIGNED)),
4489 .args = ARGS(ARGS_ENTRY
4490 (struct rte_flow_action_set_dscp, dscp)),
4491 .call = parse_vc_conf,
4495 .help = "set a specific metadata header",
4496 .next = NEXT(action_age),
4497 .priv = PRIV_ACTION(AGE,
4498 sizeof(struct rte_flow_action_age)),
4501 [ACTION_AGE_TIMEOUT] = {
4503 .help = "flow age timeout value",
4504 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_age,
4506 .next = NEXT(action_age, NEXT_ENTRY(UNSIGNED)),
4507 .call = parse_vc_conf,
4511 .help = "set a sample action",
4512 .next = NEXT(action_sample),
4513 .priv = PRIV_ACTION(SAMPLE,
4514 sizeof(struct action_sample_data)),
4515 .call = parse_vc_action_sample,
4517 [ACTION_SAMPLE_RATIO] = {
4519 .help = "flow sample ratio value",
4520 .next = NEXT(action_sample, NEXT_ENTRY(UNSIGNED)),
4521 .args = ARGS(ARGS_ENTRY_ARB
4522 (offsetof(struct action_sample_data, conf) +
4523 offsetof(struct rte_flow_action_sample, ratio),
4524 sizeof(((struct rte_flow_action_sample *)0)->
4527 [ACTION_SAMPLE_INDEX] = {
4529 .help = "the index of sample actions list",
4530 .next = NEXT(NEXT_ENTRY(ACTION_SAMPLE_INDEX_VALUE)),
4532 [ACTION_SAMPLE_INDEX_VALUE] = {
4535 .help = "unsigned integer value",
4536 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4537 .call = parse_vc_action_sample_index,
4538 .comp = comp_set_sample_index,
4540 /* Indirect action destroy arguments. */
4541 [INDIRECT_ACTION_DESTROY_ID] = {
4542 .name = "action_id",
4543 .help = "specify a indirect action id to destroy",
4544 .next = NEXT(next_ia_destroy_attr,
4545 NEXT_ENTRY(INDIRECT_ACTION_ID)),
4546 .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
4547 args.ia_destroy.action_id)),
4548 .call = parse_ia_destroy,
4550 /* Indirect action create arguments. */
4551 [INDIRECT_ACTION_CREATE_ID] = {
4552 .name = "action_id",
4553 .help = "specify a indirect action id to create",
4554 .next = NEXT(next_ia_create_attr,
4555 NEXT_ENTRY(INDIRECT_ACTION_ID)),
4556 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
4558 [ACTION_INDIRECT] = {
4560 .help = "apply indirect action by id",
4561 .priv = PRIV_ACTION(INDIRECT, 0),
4562 .next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_ID2PTR)),
4563 .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
4566 [INDIRECT_ACTION_ID2PTR] = {
4567 .name = "{action_id}",
4568 .type = "INDIRECT_ACTION_ID",
4569 .help = "indirect action id",
4570 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4571 .call = parse_ia_id2ptr,
4574 [INDIRECT_ACTION_INGRESS] = {
4576 .help = "affect rule to ingress",
4577 .next = NEXT(next_ia_create_attr),
4580 [INDIRECT_ACTION_EGRESS] = {
4582 .help = "affect rule to egress",
4583 .next = NEXT(next_ia_create_attr),
4586 [INDIRECT_ACTION_TRANSFER] = {
4588 .help = "affect rule to transfer",
4589 .next = NEXT(next_ia_create_attr),
4592 [INDIRECT_ACTION_SPEC] = {
4594 .help = "specify action to create indirect handle",
4595 .next = NEXT(next_action),
4599 /** Remove and return last entry from argument stack. */
4600 static const struct arg *
4601 pop_args(struct context *ctx)
4603 return ctx->args_num ? ctx->args[--ctx->args_num] : NULL;
4606 /** Add entry on top of the argument stack. */
4608 push_args(struct context *ctx, const struct arg *arg)
4610 if (ctx->args_num == CTX_STACK_SIZE)
4612 ctx->args[ctx->args_num++] = arg;
4616 /** Spread value into buffer according to bit-mask. */
4618 arg_entry_bf_fill(void *dst, uintmax_t val, const struct arg *arg)
4620 uint32_t i = arg->size;
4628 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
4637 unsigned int shift = 0;
4638 uint8_t *buf = (uint8_t *)dst + arg->offset + (i -= sub);
4640 for (shift = 0; arg->mask[i] >> shift; ++shift) {
4641 if (!(arg->mask[i] & (1 << shift)))
4646 *buf &= ~(1 << shift);
4647 *buf |= (val & 1) << shift;
4655 /** Compare a string with a partial one of a given length. */
4657 strcmp_partial(const char *full, const char *partial, size_t partial_len)
4659 int r = strncmp(full, partial, partial_len);
4663 if (strlen(full) <= partial_len)
4665 return full[partial_len];
4669 * Parse a prefix length and generate a bit-mask.
4671 * Last argument (ctx->args) is retrieved to determine mask size, storage
4672 * location and whether the result must use network byte ordering.
4675 parse_prefix(struct context *ctx, const struct token *token,
4676 const char *str, unsigned int len,
4677 void *buf, unsigned int size)
4679 const struct arg *arg = pop_args(ctx);
4680 static const uint8_t conv[] = "\x00\x80\xc0\xe0\xf0\xf8\xfc\xfe\xff";
4687 /* Argument is expected. */
4691 u = strtoumax(str, &end, 0);
4692 if (errno || (size_t)(end - str) != len)
4697 extra = arg_entry_bf_fill(NULL, 0, arg);
4706 if (!arg_entry_bf_fill(ctx->object, v, arg) ||
4707 !arg_entry_bf_fill(ctx->objmask, -1, arg))
4714 if (bytes > size || bytes + !!extra > size)
4718 buf = (uint8_t *)ctx->object + arg->offset;
4719 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
4721 memset((uint8_t *)buf + size - bytes, 0xff, bytes);
4722 memset(buf, 0x00, size - bytes);
4724 ((uint8_t *)buf)[size - bytes - 1] = conv[extra];
4728 memset(buf, 0xff, bytes);
4729 memset((uint8_t *)buf + bytes, 0x00, size - bytes);
4731 ((uint8_t *)buf)[bytes] = conv[extra];
4734 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
4737 push_args(ctx, arg);
4741 /** Default parsing function for token name matching. */
4743 parse_default(struct context *ctx, const struct token *token,
4744 const char *str, unsigned int len,
4745 void *buf, unsigned int size)
4750 if (strcmp_partial(token->name, str, len))
4755 /** Parse flow command, initialize output buffer for subsequent tokens. */
4757 parse_init(struct context *ctx, const struct token *token,
4758 const char *str, unsigned int len,
4759 void *buf, unsigned int size)
4761 struct buffer *out = buf;
4763 /* Token name must match. */
4764 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4766 /* Nothing else to do if there is no buffer. */
4769 /* Make sure buffer is large enough. */
4770 if (size < sizeof(*out))
4772 /* Initialize buffer. */
4773 memset(out, 0x00, sizeof(*out));
4774 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
4777 ctx->objmask = NULL;
4781 /** Parse tokens for indirect action commands. */
4783 parse_ia(struct context *ctx, const struct token *token,
4784 const char *str, unsigned int len,
4785 void *buf, unsigned int size)
4787 struct buffer *out = buf;
4789 /* Token name must match. */
4790 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4792 /* Nothing else to do if there is no buffer. */
4795 if (!out->command) {
4796 if (ctx->curr != INDIRECT_ACTION)
4798 if (sizeof(*out) > size)
4800 out->command = ctx->curr;
4803 ctx->objmask = NULL;
4804 out->args.vc.data = (uint8_t *)out + size;
4807 switch (ctx->curr) {
4808 case INDIRECT_ACTION_CREATE:
4809 case INDIRECT_ACTION_UPDATE:
4810 out->args.vc.actions =
4811 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
4813 out->args.vc.attr.group = UINT32_MAX;
4815 case INDIRECT_ACTION_QUERY:
4816 out->command = ctx->curr;
4819 ctx->objmask = NULL;
4821 case INDIRECT_ACTION_EGRESS:
4822 out->args.vc.attr.egress = 1;
4824 case INDIRECT_ACTION_INGRESS:
4825 out->args.vc.attr.ingress = 1;
4827 case INDIRECT_ACTION_TRANSFER:
4828 out->args.vc.attr.transfer = 1;
4836 /** Parse tokens for indirect action destroy command. */
4838 parse_ia_destroy(struct context *ctx, const struct token *token,
4839 const char *str, unsigned int len,
4840 void *buf, unsigned int size)
4842 struct buffer *out = buf;
4843 uint32_t *action_id;
4845 /* Token name must match. */
4846 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4848 /* Nothing else to do if there is no buffer. */
4851 if (!out->command || out->command == INDIRECT_ACTION) {
4852 if (ctx->curr != INDIRECT_ACTION_DESTROY)
4854 if (sizeof(*out) > size)
4856 out->command = ctx->curr;
4859 ctx->objmask = NULL;
4860 out->args.ia_destroy.action_id =
4861 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
4865 action_id = out->args.ia_destroy.action_id
4866 + out->args.ia_destroy.action_id_n++;
4867 if ((uint8_t *)action_id > (uint8_t *)out + size)
4870 ctx->object = action_id;
4871 ctx->objmask = NULL;
4875 /** Parse tokens for validate/create commands. */
4877 parse_vc(struct context *ctx, const struct token *token,
4878 const char *str, unsigned int len,
4879 void *buf, unsigned int size)
4881 struct buffer *out = buf;
4885 /* Token name must match. */
4886 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4888 /* Nothing else to do if there is no buffer. */
4891 if (!out->command) {
4892 if (ctx->curr != VALIDATE && ctx->curr != CREATE)
4894 if (sizeof(*out) > size)
4896 out->command = ctx->curr;
4899 ctx->objmask = NULL;
4900 out->args.vc.data = (uint8_t *)out + size;
4904 switch (ctx->curr) {
4906 ctx->object = &out->args.vc.attr;
4910 ctx->object = &out->args.vc.tunnel_ops;
4913 ctx->objmask = NULL;
4914 switch (ctx->curr) {
4919 out->args.vc.tunnel_ops.enabled = 1;
4920 out->args.vc.tunnel_ops.actions = 1;
4923 out->args.vc.tunnel_ops.enabled = 1;
4924 out->args.vc.tunnel_ops.items = 1;
4927 out->args.vc.attr.ingress = 1;
4930 out->args.vc.attr.egress = 1;
4933 out->args.vc.attr.transfer = 1;
4936 out->args.vc.pattern =
4937 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
4939 ctx->object = out->args.vc.pattern;
4940 ctx->objmask = NULL;
4943 out->args.vc.actions =
4944 (void *)RTE_ALIGN_CEIL((uintptr_t)
4945 (out->args.vc.pattern +
4946 out->args.vc.pattern_n),
4948 ctx->object = out->args.vc.actions;
4949 ctx->objmask = NULL;
4956 if (!out->args.vc.actions) {
4957 const struct parse_item_priv *priv = token->priv;
4958 struct rte_flow_item *item =
4959 out->args.vc.pattern + out->args.vc.pattern_n;
4961 data_size = priv->size * 3; /* spec, last, mask */
4962 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
4963 (out->args.vc.data - data_size),
4965 if ((uint8_t *)item + sizeof(*item) > data)
4967 *item = (struct rte_flow_item){
4970 ++out->args.vc.pattern_n;
4972 ctx->objmask = NULL;
4974 const struct parse_action_priv *priv = token->priv;
4975 struct rte_flow_action *action =
4976 out->args.vc.actions + out->args.vc.actions_n;
4978 data_size = priv->size; /* configuration */
4979 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
4980 (out->args.vc.data - data_size),
4982 if ((uint8_t *)action + sizeof(*action) > data)
4984 *action = (struct rte_flow_action){
4986 .conf = data_size ? data : NULL,
4988 ++out->args.vc.actions_n;
4989 ctx->object = action;
4990 ctx->objmask = NULL;
4992 memset(data, 0, data_size);
4993 out->args.vc.data = data;
4994 ctx->objdata = data_size;
4998 /** Parse pattern item parameter type. */
5000 parse_vc_spec(struct context *ctx, const struct token *token,
5001 const char *str, unsigned int len,
5002 void *buf, unsigned int size)
5004 struct buffer *out = buf;
5005 struct rte_flow_item *item;
5011 /* Token name must match. */
5012 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5014 /* Parse parameter types. */
5015 switch (ctx->curr) {
5016 static const enum index prefix[] = NEXT_ENTRY(PREFIX);
5022 case ITEM_PARAM_SPEC:
5025 case ITEM_PARAM_LAST:
5028 case ITEM_PARAM_PREFIX:
5029 /* Modify next token to expect a prefix. */
5030 if (ctx->next_num < 2)
5032 ctx->next[ctx->next_num - 2] = prefix;
5034 case ITEM_PARAM_MASK:
5040 /* Nothing else to do if there is no buffer. */
5043 if (!out->args.vc.pattern_n)
5045 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
5046 data_size = ctx->objdata / 3; /* spec, last, mask */
5047 /* Point to selected object. */
5048 ctx->object = out->args.vc.data + (data_size * index);
5050 ctx->objmask = out->args.vc.data + (data_size * 2); /* mask */
5051 item->mask = ctx->objmask;
5053 ctx->objmask = NULL;
5054 /* Update relevant item pointer. */
5055 *((const void **[]){ &item->spec, &item->last, &item->mask })[index] =
5060 /** Parse action configuration field. */
5062 parse_vc_conf(struct context *ctx, const struct token *token,
5063 const char *str, unsigned int len,
5064 void *buf, unsigned int size)
5066 struct buffer *out = buf;
5069 /* Token name must match. */
5070 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5072 /* Nothing else to do if there is no buffer. */
5075 /* Point to selected object. */
5076 ctx->object = out->args.vc.data;
5077 ctx->objmask = NULL;
5081 /** Parse eCPRI common header type field. */
5083 parse_vc_item_ecpri_type(struct context *ctx, const struct token *token,
5084 const char *str, unsigned int len,
5085 void *buf, unsigned int size)
5087 struct rte_flow_item_ecpri *ecpri;
5088 struct rte_flow_item_ecpri *ecpri_mask;
5089 struct rte_flow_item *item;
5092 struct buffer *out = buf;
5093 const struct arg *arg;
5096 /* Token name must match. */
5097 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5099 switch (ctx->curr) {
5100 case ITEM_ECPRI_COMMON_TYPE_IQ_DATA:
5101 msg_type = RTE_ECPRI_MSG_TYPE_IQ_DATA;
5103 case ITEM_ECPRI_COMMON_TYPE_RTC_CTRL:
5104 msg_type = RTE_ECPRI_MSG_TYPE_RTC_CTRL;
5106 case ITEM_ECPRI_COMMON_TYPE_DLY_MSR:
5107 msg_type = RTE_ECPRI_MSG_TYPE_DLY_MSR;
5114 arg = pop_args(ctx);
5117 ecpri = (struct rte_flow_item_ecpri *)out->args.vc.data;
5118 ecpri->hdr.common.type = msg_type;
5119 data_size = ctx->objdata / 3; /* spec, last, mask */
5120 ecpri_mask = (struct rte_flow_item_ecpri *)(out->args.vc.data +
5122 ecpri_mask->hdr.common.type = 0xFF;
5124 ecpri->hdr.common.u32 = rte_cpu_to_be_32(ecpri->hdr.common.u32);
5125 ecpri_mask->hdr.common.u32 =
5126 rte_cpu_to_be_32(ecpri_mask->hdr.common.u32);
5128 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
5130 item->mask = ecpri_mask;
5134 /** Parse RSS action. */
5136 parse_vc_action_rss(struct context *ctx, const struct token *token,
5137 const char *str, unsigned int len,
5138 void *buf, unsigned int size)
5140 struct buffer *out = buf;
5141 struct rte_flow_action *action;
5142 struct action_rss_data *action_rss_data;
5146 ret = parse_vc(ctx, token, str, len, buf, size);
5149 /* Nothing else to do if there is no buffer. */
5152 if (!out->args.vc.actions_n)
5154 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5155 /* Point to selected object. */
5156 ctx->object = out->args.vc.data;
5157 ctx->objmask = NULL;
5158 /* Set up default configuration. */
5159 action_rss_data = ctx->object;
5160 *action_rss_data = (struct action_rss_data){
5161 .conf = (struct rte_flow_action_rss){
5162 .func = RTE_ETH_HASH_FUNCTION_DEFAULT,
5166 .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM),
5168 .queue = action_rss_data->queue,
5172 for (i = 0; i < action_rss_data->conf.queue_num; ++i)
5173 action_rss_data->queue[i] = i;
5174 action->conf = &action_rss_data->conf;
5179 * Parse func field for RSS action.
5181 * The RTE_ETH_HASH_FUNCTION_* value to assign is derived from the
5182 * ACTION_RSS_FUNC_* index that called this function.
5185 parse_vc_action_rss_func(struct context *ctx, const struct token *token,
5186 const char *str, unsigned int len,
5187 void *buf, unsigned int size)
5189 struct action_rss_data *action_rss_data;
5190 enum rte_eth_hash_function func;
5194 /* Token name must match. */
5195 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5197 switch (ctx->curr) {
5198 case ACTION_RSS_FUNC_DEFAULT:
5199 func = RTE_ETH_HASH_FUNCTION_DEFAULT;
5201 case ACTION_RSS_FUNC_TOEPLITZ:
5202 func = RTE_ETH_HASH_FUNCTION_TOEPLITZ;
5204 case ACTION_RSS_FUNC_SIMPLE_XOR:
5205 func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
5207 case ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ:
5208 func = RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
5215 action_rss_data = ctx->object;
5216 action_rss_data->conf.func = func;
5221 * Parse type field for RSS action.
5223 * Valid tokens are type field names and the "end" token.
5226 parse_vc_action_rss_type(struct context *ctx, const struct token *token,
5227 const char *str, unsigned int len,
5228 void *buf, unsigned int size)
5230 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE);
5231 struct action_rss_data *action_rss_data;
5237 if (ctx->curr != ACTION_RSS_TYPE)
5239 if (!(ctx->objdata >> 16) && ctx->object) {
5240 action_rss_data = ctx->object;
5241 action_rss_data->conf.types = 0;
5243 if (!strcmp_partial("end", str, len)) {
5244 ctx->objdata &= 0xffff;
5247 for (i = 0; rss_type_table[i].str; ++i)
5248 if (!strcmp_partial(rss_type_table[i].str, str, len))
5250 if (!rss_type_table[i].str)
5252 ctx->objdata = 1 << 16 | (ctx->objdata & 0xffff);
5254 if (ctx->next_num == RTE_DIM(ctx->next))
5256 ctx->next[ctx->next_num++] = next;
5259 action_rss_data = ctx->object;
5260 action_rss_data->conf.types |= rss_type_table[i].rss_type;
5265 * Parse queue field for RSS action.
5267 * Valid tokens are queue indices and the "end" token.
5270 parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
5271 const char *str, unsigned int len,
5272 void *buf, unsigned int size)
5274 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE);
5275 struct action_rss_data *action_rss_data;
5276 const struct arg *arg;
5283 if (ctx->curr != ACTION_RSS_QUEUE)
5285 i = ctx->objdata >> 16;
5286 if (!strcmp_partial("end", str, len)) {
5287 ctx->objdata &= 0xffff;
5290 if (i >= ACTION_RSS_QUEUE_NUM)
5292 arg = ARGS_ENTRY_ARB(offsetof(struct action_rss_data, queue) +
5293 i * sizeof(action_rss_data->queue[i]),
5294 sizeof(action_rss_data->queue[i]));
5295 if (push_args(ctx, arg))
5297 ret = parse_int(ctx, token, str, len, NULL, 0);
5303 ctx->objdata = i << 16 | (ctx->objdata & 0xffff);
5305 if (ctx->next_num == RTE_DIM(ctx->next))
5307 ctx->next[ctx->next_num++] = next;
5311 action_rss_data = ctx->object;
5312 action_rss_data->conf.queue_num = i;
5313 action_rss_data->conf.queue = i ? action_rss_data->queue : NULL;
5317 /** Setup VXLAN encap configuration. */
5319 parse_setup_vxlan_encap_data(struct action_vxlan_encap_data *action_vxlan_encap_data)
5321 /* Set up default configuration. */
5322 *action_vxlan_encap_data = (struct action_vxlan_encap_data){
5323 .conf = (struct rte_flow_action_vxlan_encap){
5324 .definition = action_vxlan_encap_data->items,
5328 .type = RTE_FLOW_ITEM_TYPE_ETH,
5329 .spec = &action_vxlan_encap_data->item_eth,
5330 .mask = &rte_flow_item_eth_mask,
5333 .type = RTE_FLOW_ITEM_TYPE_VLAN,
5334 .spec = &action_vxlan_encap_data->item_vlan,
5335 .mask = &rte_flow_item_vlan_mask,
5338 .type = RTE_FLOW_ITEM_TYPE_IPV4,
5339 .spec = &action_vxlan_encap_data->item_ipv4,
5340 .mask = &rte_flow_item_ipv4_mask,
5343 .type = RTE_FLOW_ITEM_TYPE_UDP,
5344 .spec = &action_vxlan_encap_data->item_udp,
5345 .mask = &rte_flow_item_udp_mask,
5348 .type = RTE_FLOW_ITEM_TYPE_VXLAN,
5349 .spec = &action_vxlan_encap_data->item_vxlan,
5350 .mask = &rte_flow_item_vxlan_mask,
5353 .type = RTE_FLOW_ITEM_TYPE_END,
5358 .tci = vxlan_encap_conf.vlan_tci,
5362 .src_addr = vxlan_encap_conf.ipv4_src,
5363 .dst_addr = vxlan_encap_conf.ipv4_dst,
5366 .src_port = vxlan_encap_conf.udp_src,
5367 .dst_port = vxlan_encap_conf.udp_dst,
5369 .item_vxlan.flags = 0,
5371 memcpy(action_vxlan_encap_data->item_eth.dst.addr_bytes,
5372 vxlan_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5373 memcpy(action_vxlan_encap_data->item_eth.src.addr_bytes,
5374 vxlan_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5375 if (!vxlan_encap_conf.select_ipv4) {
5376 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.src_addr,
5377 &vxlan_encap_conf.ipv6_src,
5378 sizeof(vxlan_encap_conf.ipv6_src));
5379 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.dst_addr,
5380 &vxlan_encap_conf.ipv6_dst,
5381 sizeof(vxlan_encap_conf.ipv6_dst));
5382 action_vxlan_encap_data->items[2] = (struct rte_flow_item){
5383 .type = RTE_FLOW_ITEM_TYPE_IPV6,
5384 .spec = &action_vxlan_encap_data->item_ipv6,
5385 .mask = &rte_flow_item_ipv6_mask,
5388 if (!vxlan_encap_conf.select_vlan)
5389 action_vxlan_encap_data->items[1].type =
5390 RTE_FLOW_ITEM_TYPE_VOID;
5391 if (vxlan_encap_conf.select_tos_ttl) {
5392 if (vxlan_encap_conf.select_ipv4) {
5393 static struct rte_flow_item_ipv4 ipv4_mask_tos;
5395 memcpy(&ipv4_mask_tos, &rte_flow_item_ipv4_mask,
5396 sizeof(ipv4_mask_tos));
5397 ipv4_mask_tos.hdr.type_of_service = 0xff;
5398 ipv4_mask_tos.hdr.time_to_live = 0xff;
5399 action_vxlan_encap_data->item_ipv4.hdr.type_of_service =
5400 vxlan_encap_conf.ip_tos;
5401 action_vxlan_encap_data->item_ipv4.hdr.time_to_live =
5402 vxlan_encap_conf.ip_ttl;
5403 action_vxlan_encap_data->items[2].mask =
5406 static struct rte_flow_item_ipv6 ipv6_mask_tos;
5408 memcpy(&ipv6_mask_tos, &rte_flow_item_ipv6_mask,
5409 sizeof(ipv6_mask_tos));
5410 ipv6_mask_tos.hdr.vtc_flow |=
5411 RTE_BE32(0xfful << RTE_IPV6_HDR_TC_SHIFT);
5412 ipv6_mask_tos.hdr.hop_limits = 0xff;
5413 action_vxlan_encap_data->item_ipv6.hdr.vtc_flow |=
5415 ((uint32_t)vxlan_encap_conf.ip_tos <<
5416 RTE_IPV6_HDR_TC_SHIFT);
5417 action_vxlan_encap_data->item_ipv6.hdr.hop_limits =
5418 vxlan_encap_conf.ip_ttl;
5419 action_vxlan_encap_data->items[2].mask =
5423 memcpy(action_vxlan_encap_data->item_vxlan.vni, vxlan_encap_conf.vni,
5424 RTE_DIM(vxlan_encap_conf.vni));
5428 /** Parse VXLAN encap action. */
5430 parse_vc_action_vxlan_encap(struct context *ctx, const struct token *token,
5431 const char *str, unsigned int len,
5432 void *buf, unsigned int size)
5434 struct buffer *out = buf;
5435 struct rte_flow_action *action;
5436 struct action_vxlan_encap_data *action_vxlan_encap_data;
5439 ret = parse_vc(ctx, token, str, len, buf, size);
5442 /* Nothing else to do if there is no buffer. */
5445 if (!out->args.vc.actions_n)
5447 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5448 /* Point to selected object. */
5449 ctx->object = out->args.vc.data;
5450 ctx->objmask = NULL;
5451 action_vxlan_encap_data = ctx->object;
5452 parse_setup_vxlan_encap_data(action_vxlan_encap_data);
5453 action->conf = &action_vxlan_encap_data->conf;
5457 /** Setup NVGRE encap configuration. */
5459 parse_setup_nvgre_encap_data(struct action_nvgre_encap_data *action_nvgre_encap_data)
5461 /* Set up default configuration. */
5462 *action_nvgre_encap_data = (struct action_nvgre_encap_data){
5463 .conf = (struct rte_flow_action_nvgre_encap){
5464 .definition = action_nvgre_encap_data->items,
5468 .type = RTE_FLOW_ITEM_TYPE_ETH,
5469 .spec = &action_nvgre_encap_data->item_eth,
5470 .mask = &rte_flow_item_eth_mask,
5473 .type = RTE_FLOW_ITEM_TYPE_VLAN,
5474 .spec = &action_nvgre_encap_data->item_vlan,
5475 .mask = &rte_flow_item_vlan_mask,
5478 .type = RTE_FLOW_ITEM_TYPE_IPV4,
5479 .spec = &action_nvgre_encap_data->item_ipv4,
5480 .mask = &rte_flow_item_ipv4_mask,
5483 .type = RTE_FLOW_ITEM_TYPE_NVGRE,
5484 .spec = &action_nvgre_encap_data->item_nvgre,
5485 .mask = &rte_flow_item_nvgre_mask,
5488 .type = RTE_FLOW_ITEM_TYPE_END,
5493 .tci = nvgre_encap_conf.vlan_tci,
5497 .src_addr = nvgre_encap_conf.ipv4_src,
5498 .dst_addr = nvgre_encap_conf.ipv4_dst,
5500 .item_nvgre.c_k_s_rsvd0_ver = RTE_BE16(0x2000),
5501 .item_nvgre.protocol = RTE_BE16(RTE_ETHER_TYPE_TEB),
5502 .item_nvgre.flow_id = 0,
5504 memcpy(action_nvgre_encap_data->item_eth.dst.addr_bytes,
5505 nvgre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5506 memcpy(action_nvgre_encap_data->item_eth.src.addr_bytes,
5507 nvgre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5508 if (!nvgre_encap_conf.select_ipv4) {
5509 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.src_addr,
5510 &nvgre_encap_conf.ipv6_src,
5511 sizeof(nvgre_encap_conf.ipv6_src));
5512 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.dst_addr,
5513 &nvgre_encap_conf.ipv6_dst,
5514 sizeof(nvgre_encap_conf.ipv6_dst));
5515 action_nvgre_encap_data->items[2] = (struct rte_flow_item){
5516 .type = RTE_FLOW_ITEM_TYPE_IPV6,
5517 .spec = &action_nvgre_encap_data->item_ipv6,
5518 .mask = &rte_flow_item_ipv6_mask,
5521 if (!nvgre_encap_conf.select_vlan)
5522 action_nvgre_encap_data->items[1].type =
5523 RTE_FLOW_ITEM_TYPE_VOID;
5524 memcpy(action_nvgre_encap_data->item_nvgre.tni, nvgre_encap_conf.tni,
5525 RTE_DIM(nvgre_encap_conf.tni));
5529 /** Parse NVGRE encap action. */
5531 parse_vc_action_nvgre_encap(struct context *ctx, const struct token *token,
5532 const char *str, unsigned int len,
5533 void *buf, unsigned int size)
5535 struct buffer *out = buf;
5536 struct rte_flow_action *action;
5537 struct action_nvgre_encap_data *action_nvgre_encap_data;
5540 ret = parse_vc(ctx, token, str, len, buf, size);
5543 /* Nothing else to do if there is no buffer. */
5546 if (!out->args.vc.actions_n)
5548 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5549 /* Point to selected object. */
5550 ctx->object = out->args.vc.data;
5551 ctx->objmask = NULL;
5552 action_nvgre_encap_data = ctx->object;
5553 parse_setup_nvgre_encap_data(action_nvgre_encap_data);
5554 action->conf = &action_nvgre_encap_data->conf;
5558 /** Parse l2 encap action. */
5560 parse_vc_action_l2_encap(struct context *ctx, const struct token *token,
5561 const char *str, unsigned int len,
5562 void *buf, unsigned int size)
5564 struct buffer *out = buf;
5565 struct rte_flow_action *action;
5566 struct action_raw_encap_data *action_encap_data;
5567 struct rte_flow_item_eth eth = { .type = 0, };
5568 struct rte_flow_item_vlan vlan = {
5569 .tci = mplsoudp_encap_conf.vlan_tci,
5575 ret = parse_vc(ctx, token, str, len, buf, size);
5578 /* Nothing else to do if there is no buffer. */
5581 if (!out->args.vc.actions_n)
5583 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5584 /* Point to selected object. */
5585 ctx->object = out->args.vc.data;
5586 ctx->objmask = NULL;
5587 /* Copy the headers to the buffer. */
5588 action_encap_data = ctx->object;
5589 *action_encap_data = (struct action_raw_encap_data) {
5590 .conf = (struct rte_flow_action_raw_encap){
5591 .data = action_encap_data->data,
5595 header = action_encap_data->data;
5596 if (l2_encap_conf.select_vlan)
5597 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5598 else if (l2_encap_conf.select_ipv4)
5599 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5601 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5602 memcpy(eth.dst.addr_bytes,
5603 l2_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5604 memcpy(eth.src.addr_bytes,
5605 l2_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5606 memcpy(header, ð, sizeof(eth));
5607 header += sizeof(eth);
5608 if (l2_encap_conf.select_vlan) {
5609 if (l2_encap_conf.select_ipv4)
5610 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5612 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5613 memcpy(header, &vlan, sizeof(vlan));
5614 header += sizeof(vlan);
5616 action_encap_data->conf.size = header -
5617 action_encap_data->data;
5618 action->conf = &action_encap_data->conf;
5622 /** Parse l2 decap action. */
5624 parse_vc_action_l2_decap(struct context *ctx, const struct token *token,
5625 const char *str, unsigned int len,
5626 void *buf, unsigned int size)
5628 struct buffer *out = buf;
5629 struct rte_flow_action *action;
5630 struct action_raw_decap_data *action_decap_data;
5631 struct rte_flow_item_eth eth = { .type = 0, };
5632 struct rte_flow_item_vlan vlan = {
5633 .tci = mplsoudp_encap_conf.vlan_tci,
5639 ret = parse_vc(ctx, token, str, len, buf, size);
5642 /* Nothing else to do if there is no buffer. */
5645 if (!out->args.vc.actions_n)
5647 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5648 /* Point to selected object. */
5649 ctx->object = out->args.vc.data;
5650 ctx->objmask = NULL;
5651 /* Copy the headers to the buffer. */
5652 action_decap_data = ctx->object;
5653 *action_decap_data = (struct action_raw_decap_data) {
5654 .conf = (struct rte_flow_action_raw_decap){
5655 .data = action_decap_data->data,
5659 header = action_decap_data->data;
5660 if (l2_decap_conf.select_vlan)
5661 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5662 memcpy(header, ð, sizeof(eth));
5663 header += sizeof(eth);
5664 if (l2_decap_conf.select_vlan) {
5665 memcpy(header, &vlan, sizeof(vlan));
5666 header += sizeof(vlan);
5668 action_decap_data->conf.size = header -
5669 action_decap_data->data;
5670 action->conf = &action_decap_data->conf;
5674 #define ETHER_TYPE_MPLS_UNICAST 0x8847
5676 /** Parse MPLSOGRE encap action. */
5678 parse_vc_action_mplsogre_encap(struct context *ctx, const struct token *token,
5679 const char *str, unsigned int len,
5680 void *buf, unsigned int size)
5682 struct buffer *out = buf;
5683 struct rte_flow_action *action;
5684 struct action_raw_encap_data *action_encap_data;
5685 struct rte_flow_item_eth eth = { .type = 0, };
5686 struct rte_flow_item_vlan vlan = {
5687 .tci = mplsogre_encap_conf.vlan_tci,
5690 struct rte_flow_item_ipv4 ipv4 = {
5692 .src_addr = mplsogre_encap_conf.ipv4_src,
5693 .dst_addr = mplsogre_encap_conf.ipv4_dst,
5694 .next_proto_id = IPPROTO_GRE,
5695 .version_ihl = RTE_IPV4_VHL_DEF,
5696 .time_to_live = IPDEFTTL,
5699 struct rte_flow_item_ipv6 ipv6 = {
5701 .proto = IPPROTO_GRE,
5702 .hop_limits = IPDEFTTL,
5705 struct rte_flow_item_gre gre = {
5706 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
5708 struct rte_flow_item_mpls mpls = {
5714 ret = parse_vc(ctx, token, str, len, buf, size);
5717 /* Nothing else to do if there is no buffer. */
5720 if (!out->args.vc.actions_n)
5722 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5723 /* Point to selected object. */
5724 ctx->object = out->args.vc.data;
5725 ctx->objmask = NULL;
5726 /* Copy the headers to the buffer. */
5727 action_encap_data = ctx->object;
5728 *action_encap_data = (struct action_raw_encap_data) {
5729 .conf = (struct rte_flow_action_raw_encap){
5730 .data = action_encap_data->data,
5735 header = action_encap_data->data;
5736 if (mplsogre_encap_conf.select_vlan)
5737 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5738 else if (mplsogre_encap_conf.select_ipv4)
5739 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5741 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5742 memcpy(eth.dst.addr_bytes,
5743 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5744 memcpy(eth.src.addr_bytes,
5745 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5746 memcpy(header, ð, sizeof(eth));
5747 header += sizeof(eth);
5748 if (mplsogre_encap_conf.select_vlan) {
5749 if (mplsogre_encap_conf.select_ipv4)
5750 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5752 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5753 memcpy(header, &vlan, sizeof(vlan));
5754 header += sizeof(vlan);
5756 if (mplsogre_encap_conf.select_ipv4) {
5757 memcpy(header, &ipv4, sizeof(ipv4));
5758 header += sizeof(ipv4);
5760 memcpy(&ipv6.hdr.src_addr,
5761 &mplsogre_encap_conf.ipv6_src,
5762 sizeof(mplsogre_encap_conf.ipv6_src));
5763 memcpy(&ipv6.hdr.dst_addr,
5764 &mplsogre_encap_conf.ipv6_dst,
5765 sizeof(mplsogre_encap_conf.ipv6_dst));
5766 memcpy(header, &ipv6, sizeof(ipv6));
5767 header += sizeof(ipv6);
5769 memcpy(header, &gre, sizeof(gre));
5770 header += sizeof(gre);
5771 memcpy(mpls.label_tc_s, mplsogre_encap_conf.label,
5772 RTE_DIM(mplsogre_encap_conf.label));
5773 mpls.label_tc_s[2] |= 0x1;
5774 memcpy(header, &mpls, sizeof(mpls));
5775 header += sizeof(mpls);
5776 action_encap_data->conf.size = header -
5777 action_encap_data->data;
5778 action->conf = &action_encap_data->conf;
5782 /** Parse MPLSOGRE decap action. */
5784 parse_vc_action_mplsogre_decap(struct context *ctx, const struct token *token,
5785 const char *str, unsigned int len,
5786 void *buf, unsigned int size)
5788 struct buffer *out = buf;
5789 struct rte_flow_action *action;
5790 struct action_raw_decap_data *action_decap_data;
5791 struct rte_flow_item_eth eth = { .type = 0, };
5792 struct rte_flow_item_vlan vlan = {.tci = 0};
5793 struct rte_flow_item_ipv4 ipv4 = {
5795 .next_proto_id = IPPROTO_GRE,
5798 struct rte_flow_item_ipv6 ipv6 = {
5800 .proto = IPPROTO_GRE,
5803 struct rte_flow_item_gre gre = {
5804 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
5806 struct rte_flow_item_mpls mpls;
5810 ret = parse_vc(ctx, token, str, len, buf, size);
5813 /* Nothing else to do if there is no buffer. */
5816 if (!out->args.vc.actions_n)
5818 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5819 /* Point to selected object. */
5820 ctx->object = out->args.vc.data;
5821 ctx->objmask = NULL;
5822 /* Copy the headers to the buffer. */
5823 action_decap_data = ctx->object;
5824 *action_decap_data = (struct action_raw_decap_data) {
5825 .conf = (struct rte_flow_action_raw_decap){
5826 .data = action_decap_data->data,
5830 header = action_decap_data->data;
5831 if (mplsogre_decap_conf.select_vlan)
5832 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5833 else if (mplsogre_encap_conf.select_ipv4)
5834 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5836 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5837 memcpy(eth.dst.addr_bytes,
5838 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5839 memcpy(eth.src.addr_bytes,
5840 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5841 memcpy(header, ð, sizeof(eth));
5842 header += sizeof(eth);
5843 if (mplsogre_encap_conf.select_vlan) {
5844 if (mplsogre_encap_conf.select_ipv4)
5845 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5847 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5848 memcpy(header, &vlan, sizeof(vlan));
5849 header += sizeof(vlan);
5851 if (mplsogre_encap_conf.select_ipv4) {
5852 memcpy(header, &ipv4, sizeof(ipv4));
5853 header += sizeof(ipv4);
5855 memcpy(header, &ipv6, sizeof(ipv6));
5856 header += sizeof(ipv6);
5858 memcpy(header, &gre, sizeof(gre));
5859 header += sizeof(gre);
5860 memset(&mpls, 0, sizeof(mpls));
5861 memcpy(header, &mpls, sizeof(mpls));
5862 header += sizeof(mpls);
5863 action_decap_data->conf.size = header -
5864 action_decap_data->data;
5865 action->conf = &action_decap_data->conf;
5869 /** Parse MPLSOUDP encap action. */
5871 parse_vc_action_mplsoudp_encap(struct context *ctx, const struct token *token,
5872 const char *str, unsigned int len,
5873 void *buf, unsigned int size)
5875 struct buffer *out = buf;
5876 struct rte_flow_action *action;
5877 struct action_raw_encap_data *action_encap_data;
5878 struct rte_flow_item_eth eth = { .type = 0, };
5879 struct rte_flow_item_vlan vlan = {
5880 .tci = mplsoudp_encap_conf.vlan_tci,
5883 struct rte_flow_item_ipv4 ipv4 = {
5885 .src_addr = mplsoudp_encap_conf.ipv4_src,
5886 .dst_addr = mplsoudp_encap_conf.ipv4_dst,
5887 .next_proto_id = IPPROTO_UDP,
5888 .version_ihl = RTE_IPV4_VHL_DEF,
5889 .time_to_live = IPDEFTTL,
5892 struct rte_flow_item_ipv6 ipv6 = {
5894 .proto = IPPROTO_UDP,
5895 .hop_limits = IPDEFTTL,
5898 struct rte_flow_item_udp udp = {
5900 .src_port = mplsoudp_encap_conf.udp_src,
5901 .dst_port = mplsoudp_encap_conf.udp_dst,
5904 struct rte_flow_item_mpls mpls;
5908 ret = parse_vc(ctx, token, str, len, buf, size);
5911 /* Nothing else to do if there is no buffer. */
5914 if (!out->args.vc.actions_n)
5916 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5917 /* Point to selected object. */
5918 ctx->object = out->args.vc.data;
5919 ctx->objmask = NULL;
5920 /* Copy the headers to the buffer. */
5921 action_encap_data = ctx->object;
5922 *action_encap_data = (struct action_raw_encap_data) {
5923 .conf = (struct rte_flow_action_raw_encap){
5924 .data = action_encap_data->data,
5929 header = action_encap_data->data;
5930 if (mplsoudp_encap_conf.select_vlan)
5931 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5932 else if (mplsoudp_encap_conf.select_ipv4)
5933 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5935 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5936 memcpy(eth.dst.addr_bytes,
5937 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5938 memcpy(eth.src.addr_bytes,
5939 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5940 memcpy(header, ð, sizeof(eth));
5941 header += sizeof(eth);
5942 if (mplsoudp_encap_conf.select_vlan) {
5943 if (mplsoudp_encap_conf.select_ipv4)
5944 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5946 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5947 memcpy(header, &vlan, sizeof(vlan));
5948 header += sizeof(vlan);
5950 if (mplsoudp_encap_conf.select_ipv4) {
5951 memcpy(header, &ipv4, sizeof(ipv4));
5952 header += sizeof(ipv4);
5954 memcpy(&ipv6.hdr.src_addr,
5955 &mplsoudp_encap_conf.ipv6_src,
5956 sizeof(mplsoudp_encap_conf.ipv6_src));
5957 memcpy(&ipv6.hdr.dst_addr,
5958 &mplsoudp_encap_conf.ipv6_dst,
5959 sizeof(mplsoudp_encap_conf.ipv6_dst));
5960 memcpy(header, &ipv6, sizeof(ipv6));
5961 header += sizeof(ipv6);
5963 memcpy(header, &udp, sizeof(udp));
5964 header += sizeof(udp);
5965 memcpy(mpls.label_tc_s, mplsoudp_encap_conf.label,
5966 RTE_DIM(mplsoudp_encap_conf.label));
5967 mpls.label_tc_s[2] |= 0x1;
5968 memcpy(header, &mpls, sizeof(mpls));
5969 header += sizeof(mpls);
5970 action_encap_data->conf.size = header -
5971 action_encap_data->data;
5972 action->conf = &action_encap_data->conf;
5976 /** Parse MPLSOUDP decap action. */
5978 parse_vc_action_mplsoudp_decap(struct context *ctx, const struct token *token,
5979 const char *str, unsigned int len,
5980 void *buf, unsigned int size)
5982 struct buffer *out = buf;
5983 struct rte_flow_action *action;
5984 struct action_raw_decap_data *action_decap_data;
5985 struct rte_flow_item_eth eth = { .type = 0, };
5986 struct rte_flow_item_vlan vlan = {.tci = 0};
5987 struct rte_flow_item_ipv4 ipv4 = {
5989 .next_proto_id = IPPROTO_UDP,
5992 struct rte_flow_item_ipv6 ipv6 = {
5994 .proto = IPPROTO_UDP,
5997 struct rte_flow_item_udp udp = {
5999 .dst_port = rte_cpu_to_be_16(6635),
6002 struct rte_flow_item_mpls mpls;
6006 ret = parse_vc(ctx, token, str, len, buf, size);
6009 /* Nothing else to do if there is no buffer. */
6012 if (!out->args.vc.actions_n)
6014 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6015 /* Point to selected object. */
6016 ctx->object = out->args.vc.data;
6017 ctx->objmask = NULL;
6018 /* Copy the headers to the buffer. */
6019 action_decap_data = ctx->object;
6020 *action_decap_data = (struct action_raw_decap_data) {
6021 .conf = (struct rte_flow_action_raw_decap){
6022 .data = action_decap_data->data,
6026 header = action_decap_data->data;
6027 if (mplsoudp_decap_conf.select_vlan)
6028 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
6029 else if (mplsoudp_encap_conf.select_ipv4)
6030 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6032 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6033 memcpy(eth.dst.addr_bytes,
6034 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
6035 memcpy(eth.src.addr_bytes,
6036 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
6037 memcpy(header, ð, sizeof(eth));
6038 header += sizeof(eth);
6039 if (mplsoudp_encap_conf.select_vlan) {
6040 if (mplsoudp_encap_conf.select_ipv4)
6041 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6043 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6044 memcpy(header, &vlan, sizeof(vlan));
6045 header += sizeof(vlan);
6047 if (mplsoudp_encap_conf.select_ipv4) {
6048 memcpy(header, &ipv4, sizeof(ipv4));
6049 header += sizeof(ipv4);
6051 memcpy(header, &ipv6, sizeof(ipv6));
6052 header += sizeof(ipv6);
6054 memcpy(header, &udp, sizeof(udp));
6055 header += sizeof(udp);
6056 memset(&mpls, 0, sizeof(mpls));
6057 memcpy(header, &mpls, sizeof(mpls));
6058 header += sizeof(mpls);
6059 action_decap_data->conf.size = header -
6060 action_decap_data->data;
6061 action->conf = &action_decap_data->conf;
6066 parse_vc_action_raw_decap_index(struct context *ctx, const struct token *token,
6067 const char *str, unsigned int len, void *buf,
6070 struct action_raw_decap_data *action_raw_decap_data;
6071 struct rte_flow_action *action;
6072 const struct arg *arg;
6073 struct buffer *out = buf;
6077 RTE_SET_USED(token);
6080 arg = ARGS_ENTRY_ARB_BOUNDED
6081 (offsetof(struct action_raw_decap_data, idx),
6082 sizeof(((struct action_raw_decap_data *)0)->idx),
6083 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
6084 if (push_args(ctx, arg))
6086 ret = parse_int(ctx, token, str, len, NULL, 0);
6093 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6094 action_raw_decap_data = ctx->object;
6095 idx = action_raw_decap_data->idx;
6096 action_raw_decap_data->conf.data = raw_decap_confs[idx].data;
6097 action_raw_decap_data->conf.size = raw_decap_confs[idx].size;
6098 action->conf = &action_raw_decap_data->conf;
6104 parse_vc_action_raw_encap_index(struct context *ctx, const struct token *token,
6105 const char *str, unsigned int len, void *buf,
6108 struct action_raw_encap_data *action_raw_encap_data;
6109 struct rte_flow_action *action;
6110 const struct arg *arg;
6111 struct buffer *out = buf;
6115 RTE_SET_USED(token);
6118 if (ctx->curr != ACTION_RAW_ENCAP_INDEX_VALUE)
6120 arg = ARGS_ENTRY_ARB_BOUNDED
6121 (offsetof(struct action_raw_encap_data, idx),
6122 sizeof(((struct action_raw_encap_data *)0)->idx),
6123 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
6124 if (push_args(ctx, arg))
6126 ret = parse_int(ctx, token, str, len, NULL, 0);
6133 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6134 action_raw_encap_data = ctx->object;
6135 idx = action_raw_encap_data->idx;
6136 action_raw_encap_data->conf.data = raw_encap_confs[idx].data;
6137 action_raw_encap_data->conf.size = raw_encap_confs[idx].size;
6138 action_raw_encap_data->conf.preserve = NULL;
6139 action->conf = &action_raw_encap_data->conf;
6144 parse_vc_action_raw_encap(struct context *ctx, const struct token *token,
6145 const char *str, unsigned int len, void *buf,
6148 struct buffer *out = buf;
6149 struct rte_flow_action *action;
6150 struct action_raw_encap_data *action_raw_encap_data = NULL;
6153 ret = parse_vc(ctx, token, str, len, buf, size);
6156 /* Nothing else to do if there is no buffer. */
6159 if (!out->args.vc.actions_n)
6161 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6162 /* Point to selected object. */
6163 ctx->object = out->args.vc.data;
6164 ctx->objmask = NULL;
6165 /* Copy the headers to the buffer. */
6166 action_raw_encap_data = ctx->object;
6167 action_raw_encap_data->conf.data = raw_encap_confs[0].data;
6168 action_raw_encap_data->conf.preserve = NULL;
6169 action_raw_encap_data->conf.size = raw_encap_confs[0].size;
6170 action->conf = &action_raw_encap_data->conf;
6175 parse_vc_action_raw_decap(struct context *ctx, const struct token *token,
6176 const char *str, unsigned int len, void *buf,
6179 struct buffer *out = buf;
6180 struct rte_flow_action *action;
6181 struct action_raw_decap_data *action_raw_decap_data = NULL;
6184 ret = parse_vc(ctx, token, str, len, buf, size);
6187 /* Nothing else to do if there is no buffer. */
6190 if (!out->args.vc.actions_n)
6192 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6193 /* Point to selected object. */
6194 ctx->object = out->args.vc.data;
6195 ctx->objmask = NULL;
6196 /* Copy the headers to the buffer. */
6197 action_raw_decap_data = ctx->object;
6198 action_raw_decap_data->conf.data = raw_decap_confs[0].data;
6199 action_raw_decap_data->conf.size = raw_decap_confs[0].size;
6200 action->conf = &action_raw_decap_data->conf;
6205 parse_vc_action_set_meta(struct context *ctx, const struct token *token,
6206 const char *str, unsigned int len, void *buf,
6211 ret = parse_vc(ctx, token, str, len, buf, size);
6214 ret = rte_flow_dynf_metadata_register();
6221 parse_vc_action_sample(struct context *ctx, const struct token *token,
6222 const char *str, unsigned int len, void *buf,
6225 struct buffer *out = buf;
6226 struct rte_flow_action *action;
6227 struct action_sample_data *action_sample_data = NULL;
6228 static struct rte_flow_action end_action = {
6229 RTE_FLOW_ACTION_TYPE_END, 0
6233 ret = parse_vc(ctx, token, str, len, buf, size);
6236 /* Nothing else to do if there is no buffer. */
6239 if (!out->args.vc.actions_n)
6241 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6242 /* Point to selected object. */
6243 ctx->object = out->args.vc.data;
6244 ctx->objmask = NULL;
6245 /* Copy the headers to the buffer. */
6246 action_sample_data = ctx->object;
6247 action_sample_data->conf.actions = &end_action;
6248 action->conf = &action_sample_data->conf;
6253 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
6254 const char *str, unsigned int len, void *buf,
6257 struct action_sample_data *action_sample_data;
6258 struct rte_flow_action *action;
6259 const struct arg *arg;
6260 struct buffer *out = buf;
6264 RTE_SET_USED(token);
6267 if (ctx->curr != ACTION_SAMPLE_INDEX_VALUE)
6269 arg = ARGS_ENTRY_ARB_BOUNDED
6270 (offsetof(struct action_sample_data, idx),
6271 sizeof(((struct action_sample_data *)0)->idx),
6272 0, RAW_SAMPLE_CONFS_MAX_NUM - 1);
6273 if (push_args(ctx, arg))
6275 ret = parse_int(ctx, token, str, len, NULL, 0);
6282 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6283 action_sample_data = ctx->object;
6284 idx = action_sample_data->idx;
6285 action_sample_data->conf.actions = raw_sample_confs[idx].data;
6286 action->conf = &action_sample_data->conf;
6290 /** Parse operation for modify_field command. */
6292 parse_vc_modify_field_op(struct context *ctx, const struct token *token,
6293 const char *str, unsigned int len, void *buf,
6296 struct rte_flow_action_modify_field *action_modify_field;
6302 if (ctx->curr != ACTION_MODIFY_FIELD_OP_VALUE)
6304 for (i = 0; modify_field_ops[i]; ++i)
6305 if (!strcmp_partial(modify_field_ops[i], str, len))
6307 if (!modify_field_ops[i])
6311 action_modify_field = ctx->object;
6312 action_modify_field->operation = (enum rte_flow_modify_op)i;
6316 /** Parse id for modify_field command. */
6318 parse_vc_modify_field_id(struct context *ctx, const struct token *token,
6319 const char *str, unsigned int len, void *buf,
6322 struct rte_flow_action_modify_field *action_modify_field;
6328 if (ctx->curr != ACTION_MODIFY_FIELD_DST_TYPE_VALUE &&
6329 ctx->curr != ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)
6331 for (i = 0; modify_field_ids[i]; ++i)
6332 if (!strcmp_partial(modify_field_ids[i], str, len))
6334 if (!modify_field_ids[i])
6338 action_modify_field = ctx->object;
6339 if (ctx->curr == ACTION_MODIFY_FIELD_DST_TYPE_VALUE)
6340 action_modify_field->dst.field = (enum rte_flow_field_id)i;
6342 action_modify_field->src.field = (enum rte_flow_field_id)i;
6346 /** Parse tokens for destroy command. */
6348 parse_destroy(struct context *ctx, const struct token *token,
6349 const char *str, unsigned int len,
6350 void *buf, unsigned int size)
6352 struct buffer *out = buf;
6354 /* Token name must match. */
6355 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6357 /* Nothing else to do if there is no buffer. */
6360 if (!out->command) {
6361 if (ctx->curr != DESTROY)
6363 if (sizeof(*out) > size)
6365 out->command = ctx->curr;
6368 ctx->objmask = NULL;
6369 out->args.destroy.rule =
6370 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6374 if (((uint8_t *)(out->args.destroy.rule + out->args.destroy.rule_n) +
6375 sizeof(*out->args.destroy.rule)) > (uint8_t *)out + size)
6378 ctx->object = out->args.destroy.rule + out->args.destroy.rule_n++;
6379 ctx->objmask = NULL;
6383 /** Parse tokens for flush command. */
6385 parse_flush(struct context *ctx, const struct token *token,
6386 const char *str, unsigned int len,
6387 void *buf, unsigned int size)
6389 struct buffer *out = buf;
6391 /* Token name must match. */
6392 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6394 /* Nothing else to do if there is no buffer. */
6397 if (!out->command) {
6398 if (ctx->curr != FLUSH)
6400 if (sizeof(*out) > size)
6402 out->command = ctx->curr;
6405 ctx->objmask = NULL;
6410 /** Parse tokens for dump command. */
6412 parse_dump(struct context *ctx, const struct token *token,
6413 const char *str, unsigned int len,
6414 void *buf, unsigned int size)
6416 struct buffer *out = buf;
6418 /* Token name must match. */
6419 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6421 /* Nothing else to do if there is no buffer. */
6424 if (!out->command) {
6425 if (ctx->curr != DUMP)
6427 if (sizeof(*out) > size)
6429 out->command = ctx->curr;
6432 ctx->objmask = NULL;
6435 switch (ctx->curr) {
6438 out->args.dump.mode = (ctx->curr == DUMP_ALL) ? true : false;
6439 out->command = ctx->curr;
6442 ctx->objmask = NULL;
6449 /** Parse tokens for query command. */
6451 parse_query(struct context *ctx, const struct token *token,
6452 const char *str, unsigned int len,
6453 void *buf, unsigned int size)
6455 struct buffer *out = buf;
6457 /* Token name must match. */
6458 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6460 /* Nothing else to do if there is no buffer. */
6463 if (!out->command) {
6464 if (ctx->curr != QUERY)
6466 if (sizeof(*out) > size)
6468 out->command = ctx->curr;
6471 ctx->objmask = NULL;
6476 /** Parse action names. */
6478 parse_action(struct context *ctx, const struct token *token,
6479 const char *str, unsigned int len,
6480 void *buf, unsigned int size)
6482 struct buffer *out = buf;
6483 const struct arg *arg = pop_args(ctx);
6487 /* Argument is expected. */
6490 /* Parse action name. */
6491 for (i = 0; next_action[i]; ++i) {
6492 const struct parse_action_priv *priv;
6494 token = &token_list[next_action[i]];
6495 if (strcmp_partial(token->name, str, len))
6501 memcpy((uint8_t *)ctx->object + arg->offset,
6507 push_args(ctx, arg);
6511 /** Parse tokens for list command. */
6513 parse_list(struct context *ctx, const struct token *token,
6514 const char *str, unsigned int len,
6515 void *buf, unsigned int size)
6517 struct buffer *out = buf;
6519 /* Token name must match. */
6520 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6522 /* Nothing else to do if there is no buffer. */
6525 if (!out->command) {
6526 if (ctx->curr != LIST)
6528 if (sizeof(*out) > size)
6530 out->command = ctx->curr;
6533 ctx->objmask = NULL;
6534 out->args.list.group =
6535 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6539 if (((uint8_t *)(out->args.list.group + out->args.list.group_n) +
6540 sizeof(*out->args.list.group)) > (uint8_t *)out + size)
6543 ctx->object = out->args.list.group + out->args.list.group_n++;
6544 ctx->objmask = NULL;
6548 /** Parse tokens for list all aged flows command. */
6550 parse_aged(struct context *ctx, const struct token *token,
6551 const char *str, unsigned int len,
6552 void *buf, unsigned int size)
6554 struct buffer *out = buf;
6556 /* Token name must match. */
6557 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6559 /* Nothing else to do if there is no buffer. */
6562 if (!out->command) {
6563 if (ctx->curr != AGED)
6565 if (sizeof(*out) > size)
6567 out->command = ctx->curr;
6570 ctx->objmask = NULL;
6572 if (ctx->curr == AGED_DESTROY)
6573 out->args.aged.destroy = 1;
6577 /** Parse tokens for isolate command. */
6579 parse_isolate(struct context *ctx, const struct token *token,
6580 const char *str, unsigned int len,
6581 void *buf, unsigned int size)
6583 struct buffer *out = buf;
6585 /* Token name must match. */
6586 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6588 /* Nothing else to do if there is no buffer. */
6591 if (!out->command) {
6592 if (ctx->curr != ISOLATE)
6594 if (sizeof(*out) > size)
6596 out->command = ctx->curr;
6599 ctx->objmask = NULL;
6605 parse_tunnel(struct context *ctx, const struct token *token,
6606 const char *str, unsigned int len,
6607 void *buf, unsigned int size)
6609 struct buffer *out = buf;
6611 /* Token name must match. */
6612 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6614 /* Nothing else to do if there is no buffer. */
6617 if (!out->command) {
6618 if (ctx->curr != TUNNEL)
6620 if (sizeof(*out) > size)
6622 out->command = ctx->curr;
6625 ctx->objmask = NULL;
6627 switch (ctx->curr) {
6631 case TUNNEL_DESTROY:
6633 out->command = ctx->curr;
6635 case TUNNEL_CREATE_TYPE:
6636 case TUNNEL_DESTROY_ID:
6637 ctx->object = &out->args.vc.tunnel_ops;
6646 * Parse signed/unsigned integers 8 to 64-bit long.
6648 * Last argument (ctx->args) is retrieved to determine integer type and
6652 parse_int(struct context *ctx, const struct token *token,
6653 const char *str, unsigned int len,
6654 void *buf, unsigned int size)
6656 const struct arg *arg = pop_args(ctx);
6661 /* Argument is expected. */
6666 (uintmax_t)strtoimax(str, &end, 0) :
6667 strtoumax(str, &end, 0);
6668 if (errno || (size_t)(end - str) != len)
6671 ((arg->sign && ((intmax_t)u < (intmax_t)arg->min ||
6672 (intmax_t)u > (intmax_t)arg->max)) ||
6673 (!arg->sign && (u < arg->min || u > arg->max))))
6678 if (!arg_entry_bf_fill(ctx->object, u, arg) ||
6679 !arg_entry_bf_fill(ctx->objmask, -1, arg))
6683 buf = (uint8_t *)ctx->object + arg->offset;
6685 if (u > RTE_LEN2MASK(size * CHAR_BIT, uint64_t))
6689 case sizeof(uint8_t):
6690 *(uint8_t *)buf = u;
6692 case sizeof(uint16_t):
6693 *(uint16_t *)buf = arg->hton ? rte_cpu_to_be_16(u) : u;
6695 case sizeof(uint8_t [3]):
6696 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
6698 ((uint8_t *)buf)[0] = u;
6699 ((uint8_t *)buf)[1] = u >> 8;
6700 ((uint8_t *)buf)[2] = u >> 16;
6704 ((uint8_t *)buf)[0] = u >> 16;
6705 ((uint8_t *)buf)[1] = u >> 8;
6706 ((uint8_t *)buf)[2] = u;
6708 case sizeof(uint32_t):
6709 *(uint32_t *)buf = arg->hton ? rte_cpu_to_be_32(u) : u;
6711 case sizeof(uint64_t):
6712 *(uint64_t *)buf = arg->hton ? rte_cpu_to_be_64(u) : u;
6717 if (ctx->objmask && buf != (uint8_t *)ctx->objmask + arg->offset) {
6719 buf = (uint8_t *)ctx->objmask + arg->offset;
6724 push_args(ctx, arg);
6731 * Three arguments (ctx->args) are retrieved from the stack to store data,
6732 * its actual length and address (in that order).
6735 parse_string(struct context *ctx, const struct token *token,
6736 const char *str, unsigned int len,
6737 void *buf, unsigned int size)
6739 const struct arg *arg_data = pop_args(ctx);
6740 const struct arg *arg_len = pop_args(ctx);
6741 const struct arg *arg_addr = pop_args(ctx);
6742 char tmp[16]; /* Ought to be enough. */
6745 /* Arguments are expected. */
6749 push_args(ctx, arg_data);
6753 push_args(ctx, arg_len);
6754 push_args(ctx, arg_data);
6757 size = arg_data->size;
6758 /* Bit-mask fill is not supported. */
6759 if (arg_data->mask || size < len)
6763 /* Let parse_int() fill length information first. */
6764 ret = snprintf(tmp, sizeof(tmp), "%u", len);
6767 push_args(ctx, arg_len);
6768 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
6773 buf = (uint8_t *)ctx->object + arg_data->offset;
6774 /* Output buffer is not necessarily NUL-terminated. */
6775 memcpy(buf, str, len);
6776 memset((uint8_t *)buf + len, 0x00, size - len);
6778 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
6779 /* Save address if requested. */
6780 if (arg_addr->size) {
6781 memcpy((uint8_t *)ctx->object + arg_addr->offset,
6783 (uint8_t *)ctx->object + arg_data->offset
6787 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
6789 (uint8_t *)ctx->objmask + arg_data->offset
6795 push_args(ctx, arg_addr);
6796 push_args(ctx, arg_len);
6797 push_args(ctx, arg_data);
6802 parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
6808 /* Check input parameters */
6809 if ((src == NULL) ||
6815 /* Convert chars to bytes */
6816 for (i = 0, len = 0; i < *size; i += 2) {
6817 snprintf(tmp, 3, "%s", src + i);
6818 dst[len++] = strtoul(tmp, &c, 16);
6833 parse_hex(struct context *ctx, const struct token *token,
6834 const char *str, unsigned int len,
6835 void *buf, unsigned int size)
6837 const struct arg *arg_data = pop_args(ctx);
6838 const struct arg *arg_len = pop_args(ctx);
6839 const struct arg *arg_addr = pop_args(ctx);
6840 char tmp[16]; /* Ought to be enough. */
6842 unsigned int hexlen = len;
6843 unsigned int length = 256;
6844 uint8_t hex_tmp[length];
6846 /* Arguments are expected. */
6850 push_args(ctx, arg_data);
6854 push_args(ctx, arg_len);
6855 push_args(ctx, arg_data);
6858 size = arg_data->size;
6859 /* Bit-mask fill is not supported. */
6865 /* translate bytes string to array. */
6866 if (str[0] == '0' && ((str[1] == 'x') ||
6871 if (hexlen > length)
6873 ret = parse_hex_string(str, hex_tmp, &hexlen);
6876 /* Let parse_int() fill length information first. */
6877 ret = snprintf(tmp, sizeof(tmp), "%u", hexlen);
6880 /* Save length if requested. */
6881 if (arg_len->size) {
6882 push_args(ctx, arg_len);
6883 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
6889 buf = (uint8_t *)ctx->object + arg_data->offset;
6890 /* Output buffer is not necessarily NUL-terminated. */
6891 memcpy(buf, hex_tmp, hexlen);
6892 memset((uint8_t *)buf + hexlen, 0x00, size - hexlen);
6894 memset((uint8_t *)ctx->objmask + arg_data->offset,
6896 /* Save address if requested. */
6897 if (arg_addr->size) {
6898 memcpy((uint8_t *)ctx->object + arg_addr->offset,
6900 (uint8_t *)ctx->object + arg_data->offset
6904 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
6906 (uint8_t *)ctx->objmask + arg_data->offset
6912 push_args(ctx, arg_addr);
6913 push_args(ctx, arg_len);
6914 push_args(ctx, arg_data);
6920 * Parse a zero-ended string.
6923 parse_string0(struct context *ctx, const struct token *token __rte_unused,
6924 const char *str, unsigned int len,
6925 void *buf, unsigned int size)
6927 const struct arg *arg_data = pop_args(ctx);
6929 /* Arguments are expected. */
6932 size = arg_data->size;
6933 /* Bit-mask fill is not supported. */
6934 if (arg_data->mask || size < len + 1)
6938 buf = (uint8_t *)ctx->object + arg_data->offset;
6939 strncpy(buf, str, len);
6941 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
6944 push_args(ctx, arg_data);
6949 * Parse a MAC address.
6951 * Last argument (ctx->args) is retrieved to determine storage size and
6955 parse_mac_addr(struct context *ctx, const struct token *token,
6956 const char *str, unsigned int len,
6957 void *buf, unsigned int size)
6959 const struct arg *arg = pop_args(ctx);
6960 struct rte_ether_addr tmp;
6964 /* Argument is expected. */
6968 /* Bit-mask fill is not supported. */
6969 if (arg->mask || size != sizeof(tmp))
6971 /* Only network endian is supported. */
6974 ret = cmdline_parse_etheraddr(NULL, str, &tmp, size);
6975 if (ret < 0 || (unsigned int)ret != len)
6979 buf = (uint8_t *)ctx->object + arg->offset;
6980 memcpy(buf, &tmp, size);
6982 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6985 push_args(ctx, arg);
6990 * Parse an IPv4 address.
6992 * Last argument (ctx->args) is retrieved to determine storage size and
6996 parse_ipv4_addr(struct context *ctx, const struct token *token,
6997 const char *str, unsigned int len,
6998 void *buf, unsigned int size)
7000 const struct arg *arg = pop_args(ctx);
7005 /* Argument is expected. */
7009 /* Bit-mask fill is not supported. */
7010 if (arg->mask || size != sizeof(tmp))
7012 /* Only network endian is supported. */
7015 memcpy(str2, str, len);
7017 ret = inet_pton(AF_INET, str2, &tmp);
7019 /* Attempt integer parsing. */
7020 push_args(ctx, arg);
7021 return parse_int(ctx, token, str, len, buf, size);
7025 buf = (uint8_t *)ctx->object + arg->offset;
7026 memcpy(buf, &tmp, size);
7028 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
7031 push_args(ctx, arg);
7036 * Parse an IPv6 address.
7038 * Last argument (ctx->args) is retrieved to determine storage size and
7042 parse_ipv6_addr(struct context *ctx, const struct token *token,
7043 const char *str, unsigned int len,
7044 void *buf, unsigned int size)
7046 const struct arg *arg = pop_args(ctx);
7048 struct in6_addr tmp;
7052 /* Argument is expected. */
7056 /* Bit-mask fill is not supported. */
7057 if (arg->mask || size != sizeof(tmp))
7059 /* Only network endian is supported. */
7062 memcpy(str2, str, len);
7064 ret = inet_pton(AF_INET6, str2, &tmp);
7069 buf = (uint8_t *)ctx->object + arg->offset;
7070 memcpy(buf, &tmp, size);
7072 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
7075 push_args(ctx, arg);
7079 /** Boolean values (even indices stand for false). */
7080 static const char *const boolean_name[] = {
7090 * Parse a boolean value.
7092 * Last argument (ctx->args) is retrieved to determine storage size and
7096 parse_boolean(struct context *ctx, const struct token *token,
7097 const char *str, unsigned int len,
7098 void *buf, unsigned int size)
7100 const struct arg *arg = pop_args(ctx);
7104 /* Argument is expected. */
7107 for (i = 0; boolean_name[i]; ++i)
7108 if (!strcmp_partial(boolean_name[i], str, len))
7110 /* Process token as integer. */
7111 if (boolean_name[i])
7112 str = i & 1 ? "1" : "0";
7113 push_args(ctx, arg);
7114 ret = parse_int(ctx, token, str, strlen(str), buf, size);
7115 return ret > 0 ? (int)len : ret;
7118 /** Parse port and update context. */
7120 parse_port(struct context *ctx, const struct token *token,
7121 const char *str, unsigned int len,
7122 void *buf, unsigned int size)
7124 struct buffer *out = &(struct buffer){ .port = 0 };
7132 ctx->objmask = NULL;
7133 size = sizeof(*out);
7135 ret = parse_int(ctx, token, str, len, out, size);
7137 ctx->port = out->port;
7144 parse_ia_id2ptr(struct context *ctx, const struct token *token,
7145 const char *str, unsigned int len,
7146 void *buf, unsigned int size)
7148 struct rte_flow_action *action = ctx->object;
7156 ctx->objmask = NULL;
7157 ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
7158 ctx->object = action;
7159 if (ret != (int)len)
7161 /* set indirect action */
7163 action->conf = port_action_handle_get_by_id(ctx->port, id);
7164 ret = (action->conf) ? ret : -1;
7169 /** Parse set command, initialize output buffer for subsequent tokens. */
7171 parse_set_raw_encap_decap(struct context *ctx, const struct token *token,
7172 const char *str, unsigned int len,
7173 void *buf, unsigned int size)
7175 struct buffer *out = buf;
7177 /* Token name must match. */
7178 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7180 /* Nothing else to do if there is no buffer. */
7183 /* Make sure buffer is large enough. */
7184 if (size < sizeof(*out))
7187 ctx->objmask = NULL;
7191 out->command = ctx->curr;
7192 /* For encap/decap we need is pattern */
7193 out->args.vc.pattern = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7198 /** Parse set command, initialize output buffer for subsequent tokens. */
7200 parse_set_sample_action(struct context *ctx, const struct token *token,
7201 const char *str, unsigned int len,
7202 void *buf, unsigned int size)
7204 struct buffer *out = buf;
7206 /* Token name must match. */
7207 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7209 /* Nothing else to do if there is no buffer. */
7212 /* Make sure buffer is large enough. */
7213 if (size < sizeof(*out))
7216 ctx->objmask = NULL;
7220 out->command = ctx->curr;
7221 /* For sampler we need is actions */
7222 out->args.vc.actions = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7228 * Parse set raw_encap/raw_decap command,
7229 * initialize output buffer for subsequent tokens.
7232 parse_set_init(struct context *ctx, const struct token *token,
7233 const char *str, unsigned int len,
7234 void *buf, unsigned int size)
7236 struct buffer *out = buf;
7238 /* Token name must match. */
7239 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7241 /* Nothing else to do if there is no buffer. */
7244 /* Make sure buffer is large enough. */
7245 if (size < sizeof(*out))
7247 /* Initialize buffer. */
7248 memset(out, 0x00, sizeof(*out));
7249 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
7252 ctx->objmask = NULL;
7253 if (!out->command) {
7254 if (ctx->curr != SET)
7256 if (sizeof(*out) > size)
7258 out->command = ctx->curr;
7259 out->args.vc.data = (uint8_t *)out + size;
7260 ctx->object = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7266 /** No completion. */
7268 comp_none(struct context *ctx, const struct token *token,
7269 unsigned int ent, char *buf, unsigned int size)
7279 /** Complete boolean values. */
7281 comp_boolean(struct context *ctx, const struct token *token,
7282 unsigned int ent, char *buf, unsigned int size)
7288 for (i = 0; boolean_name[i]; ++i)
7289 if (buf && i == ent)
7290 return strlcpy(buf, boolean_name[i], size);
7296 /** Complete action names. */
7298 comp_action(struct context *ctx, const struct token *token,
7299 unsigned int ent, char *buf, unsigned int size)
7305 for (i = 0; next_action[i]; ++i)
7306 if (buf && i == ent)
7307 return strlcpy(buf, token_list[next_action[i]].name,
7314 /** Complete available ports. */
7316 comp_port(struct context *ctx, const struct token *token,
7317 unsigned int ent, char *buf, unsigned int size)
7324 RTE_ETH_FOREACH_DEV(p) {
7325 if (buf && i == ent)
7326 return snprintf(buf, size, "%u", p);
7334 /** Complete available rule IDs. */
7336 comp_rule_id(struct context *ctx, const struct token *token,
7337 unsigned int ent, char *buf, unsigned int size)
7340 struct rte_port *port;
7341 struct port_flow *pf;
7344 if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
7345 ctx->port == (portid_t)RTE_PORT_ALL)
7347 port = &ports[ctx->port];
7348 for (pf = port->flow_list; pf != NULL; pf = pf->next) {
7349 if (buf && i == ent)
7350 return snprintf(buf, size, "%u", pf->id);
7358 /** Complete type field for RSS action. */
7360 comp_vc_action_rss_type(struct context *ctx, const struct token *token,
7361 unsigned int ent, char *buf, unsigned int size)
7367 for (i = 0; rss_type_table[i].str; ++i)
7372 return strlcpy(buf, rss_type_table[ent].str, size);
7374 return snprintf(buf, size, "end");
7378 /** Complete queue field for RSS action. */
7380 comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
7381 unsigned int ent, char *buf, unsigned int size)
7388 return snprintf(buf, size, "%u", ent);
7390 return snprintf(buf, size, "end");
7394 /** Complete index number for set raw_encap/raw_decap commands. */
7396 comp_set_raw_index(struct context *ctx, const struct token *token,
7397 unsigned int ent, char *buf, unsigned int size)
7403 RTE_SET_USED(token);
7404 for (idx = 0; idx < RAW_ENCAP_CONFS_MAX_NUM; ++idx) {
7405 if (buf && idx == ent)
7406 return snprintf(buf, size, "%u", idx);
7412 /** Complete index number for set raw_encap/raw_decap commands. */
7414 comp_set_sample_index(struct context *ctx, const struct token *token,
7415 unsigned int ent, char *buf, unsigned int size)
7421 RTE_SET_USED(token);
7422 for (idx = 0; idx < RAW_SAMPLE_CONFS_MAX_NUM; ++idx) {
7423 if (buf && idx == ent)
7424 return snprintf(buf, size, "%u", idx);
7430 /** Complete operation for modify_field command. */
7432 comp_set_modify_field_op(struct context *ctx, const struct token *token,
7433 unsigned int ent, char *buf, unsigned int size)
7438 RTE_SET_USED(token);
7439 for (idx = 0; modify_field_ops[idx]; ++idx)
7444 return strlcpy(buf, modify_field_ops[ent], size);
7448 /** Complete field id for modify_field command. */
7450 comp_set_modify_field_id(struct context *ctx, const struct token *token,
7451 unsigned int ent, char *buf, unsigned int size)
7456 RTE_SET_USED(token);
7457 for (idx = 0; modify_field_ids[idx]; ++idx)
7462 return strlcpy(buf, modify_field_ids[ent], size);
7466 /** Internal context. */
7467 static struct context cmd_flow_context;
7469 /** Global parser instance (cmdline API). */
7470 cmdline_parse_inst_t cmd_flow;
7471 cmdline_parse_inst_t cmd_set_raw;
7473 /** Initialize context. */
7475 cmd_flow_context_init(struct context *ctx)
7477 /* A full memset() is not necessary. */
7487 ctx->objmask = NULL;
7490 /** Parse a token (cmdline API). */
7492 cmd_flow_parse(cmdline_parse_token_hdr_t *hdr, const char *src, void *result,
7495 struct context *ctx = &cmd_flow_context;
7496 const struct token *token;
7497 const enum index *list;
7502 token = &token_list[ctx->curr];
7503 /* Check argument length. */
7506 for (len = 0; src[len]; ++len)
7507 if (src[len] == '#' || isspace(src[len]))
7511 /* Last argument and EOL detection. */
7512 for (i = len; src[i]; ++i)
7513 if (src[i] == '#' || src[i] == '\r' || src[i] == '\n')
7515 else if (!isspace(src[i])) {
7520 if (src[i] == '\r' || src[i] == '\n') {
7524 /* Initialize context if necessary. */
7525 if (!ctx->next_num) {
7528 ctx->next[ctx->next_num++] = token->next[0];
7530 /* Process argument through candidates. */
7531 ctx->prev = ctx->curr;
7532 list = ctx->next[ctx->next_num - 1];
7533 for (i = 0; list[i]; ++i) {
7534 const struct token *next = &token_list[list[i]];
7537 ctx->curr = list[i];
7539 tmp = next->call(ctx, next, src, len, result, size);
7541 tmp = parse_default(ctx, next, src, len, result, size);
7542 if (tmp == -1 || tmp != len)
7550 /* Push subsequent tokens if any. */
7552 for (i = 0; token->next[i]; ++i) {
7553 if (ctx->next_num == RTE_DIM(ctx->next))
7555 ctx->next[ctx->next_num++] = token->next[i];
7557 /* Push arguments if any. */
7559 for (i = 0; token->args[i]; ++i) {
7560 if (ctx->args_num == RTE_DIM(ctx->args))
7562 ctx->args[ctx->args_num++] = token->args[i];
7567 /** Return number of completion entries (cmdline API). */
7569 cmd_flow_complete_get_nb(cmdline_parse_token_hdr_t *hdr)
7571 struct context *ctx = &cmd_flow_context;
7572 const struct token *token = &token_list[ctx->curr];
7573 const enum index *list;
7577 /* Count number of tokens in current list. */
7579 list = ctx->next[ctx->next_num - 1];
7581 list = token->next[0];
7582 for (i = 0; list[i]; ++i)
7587 * If there is a single token, use its completion callback, otherwise
7588 * return the number of entries.
7590 token = &token_list[list[0]];
7591 if (i == 1 && token->comp) {
7592 /* Save index for cmd_flow_get_help(). */
7593 ctx->prev = list[0];
7594 return token->comp(ctx, token, 0, NULL, 0);
7599 /** Return a completion entry (cmdline API). */
7601 cmd_flow_complete_get_elt(cmdline_parse_token_hdr_t *hdr, int index,
7602 char *dst, unsigned int size)
7604 struct context *ctx = &cmd_flow_context;
7605 const struct token *token = &token_list[ctx->curr];
7606 const enum index *list;
7610 /* Count number of tokens in current list. */
7612 list = ctx->next[ctx->next_num - 1];
7614 list = token->next[0];
7615 for (i = 0; list[i]; ++i)
7619 /* If there is a single token, use its completion callback. */
7620 token = &token_list[list[0]];
7621 if (i == 1 && token->comp) {
7622 /* Save index for cmd_flow_get_help(). */
7623 ctx->prev = list[0];
7624 return token->comp(ctx, token, index, dst, size) < 0 ? -1 : 0;
7626 /* Otherwise make sure the index is valid and use defaults. */
7629 token = &token_list[list[index]];
7630 strlcpy(dst, token->name, size);
7631 /* Save index for cmd_flow_get_help(). */
7632 ctx->prev = list[index];
7636 /** Populate help strings for current token (cmdline API). */
7638 cmd_flow_get_help(cmdline_parse_token_hdr_t *hdr, char *dst, unsigned int size)
7640 struct context *ctx = &cmd_flow_context;
7641 const struct token *token = &token_list[ctx->prev];
7646 /* Set token type and update global help with details. */
7647 strlcpy(dst, (token->type ? token->type : "TOKEN"), size);
7649 cmd_flow.help_str = token->help;
7651 cmd_flow.help_str = token->name;
7655 /** Token definition template (cmdline API). */
7656 static struct cmdline_token_hdr cmd_flow_token_hdr = {
7657 .ops = &(struct cmdline_token_ops){
7658 .parse = cmd_flow_parse,
7659 .complete_get_nb = cmd_flow_complete_get_nb,
7660 .complete_get_elt = cmd_flow_complete_get_elt,
7661 .get_help = cmd_flow_get_help,
7666 /** Populate the next dynamic token. */
7668 cmd_flow_tok(cmdline_parse_token_hdr_t **hdr,
7669 cmdline_parse_token_hdr_t **hdr_inst)
7671 struct context *ctx = &cmd_flow_context;
7673 /* Always reinitialize context before requesting the first token. */
7674 if (!(hdr_inst - cmd_flow.tokens))
7675 cmd_flow_context_init(ctx);
7676 /* Return NULL when no more tokens are expected. */
7677 if (!ctx->next_num && ctx->curr) {
7681 /* Determine if command should end here. */
7682 if (ctx->eol && ctx->last && ctx->next_num) {
7683 const enum index *list = ctx->next[ctx->next_num - 1];
7686 for (i = 0; list[i]; ++i) {
7693 *hdr = &cmd_flow_token_hdr;
7696 /** Dispatch parsed buffer to function calls. */
7698 cmd_flow_parsed(const struct buffer *in)
7700 switch (in->command) {
7701 case INDIRECT_ACTION_CREATE:
7702 port_action_handle_create(
7703 in->port, in->args.vc.attr.group,
7704 &((const struct rte_flow_indir_action_conf) {
7705 .ingress = in->args.vc.attr.ingress,
7706 .egress = in->args.vc.attr.egress,
7707 .transfer = in->args.vc.attr.transfer,
7709 in->args.vc.actions);
7711 case INDIRECT_ACTION_DESTROY:
7712 port_action_handle_destroy(in->port,
7713 in->args.ia_destroy.action_id_n,
7714 in->args.ia_destroy.action_id);
7716 case INDIRECT_ACTION_UPDATE:
7717 port_action_handle_update(in->port, in->args.vc.attr.group,
7718 in->args.vc.actions);
7720 case INDIRECT_ACTION_QUERY:
7721 port_action_handle_query(in->port, in->args.ia.action_id);
7724 port_flow_validate(in->port, &in->args.vc.attr,
7725 in->args.vc.pattern, in->args.vc.actions,
7726 &in->args.vc.tunnel_ops);
7729 port_flow_create(in->port, &in->args.vc.attr,
7730 in->args.vc.pattern, in->args.vc.actions,
7731 &in->args.vc.tunnel_ops);
7734 port_flow_destroy(in->port, in->args.destroy.rule_n,
7735 in->args.destroy.rule);
7738 port_flow_flush(in->port);
7742 port_flow_dump(in->port, in->args.dump.mode,
7743 in->args.dump.rule, in->args.dump.file);
7746 port_flow_query(in->port, in->args.query.rule,
7747 &in->args.query.action);
7750 port_flow_list(in->port, in->args.list.group_n,
7751 in->args.list.group);
7754 port_flow_isolate(in->port, in->args.isolate.set);
7757 port_flow_aged(in->port, in->args.aged.destroy);
7760 port_flow_tunnel_create(in->port, &in->args.vc.tunnel_ops);
7762 case TUNNEL_DESTROY:
7763 port_flow_tunnel_destroy(in->port, in->args.vc.tunnel_ops.id);
7766 port_flow_tunnel_list(in->port);
7773 /** Token generator and output processing callback (cmdline API). */
7775 cmd_flow_cb(void *arg0, struct cmdline *cl, void *arg2)
7778 cmd_flow_tok(arg0, arg2);
7780 cmd_flow_parsed(arg0);
7783 /** Global parser instance (cmdline API). */
7784 cmdline_parse_inst_t cmd_flow = {
7786 .data = NULL, /**< Unused. */
7787 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
7790 }, /**< Tokens are returned by cmd_flow_tok(). */
7793 /** set cmd facility. Reuse cmd flow's infrastructure as much as possible. */
7796 update_fields(uint8_t *buf, struct rte_flow_item *item, uint16_t next_proto)
7798 struct rte_ipv4_hdr *ipv4;
7799 struct rte_ether_hdr *eth;
7800 struct rte_ipv6_hdr *ipv6;
7801 struct rte_vxlan_hdr *vxlan;
7802 struct rte_vxlan_gpe_hdr *gpe;
7803 struct rte_flow_item_nvgre *nvgre;
7804 uint32_t ipv6_vtc_flow;
7806 switch (item->type) {
7807 case RTE_FLOW_ITEM_TYPE_ETH:
7808 eth = (struct rte_ether_hdr *)buf;
7810 eth->ether_type = rte_cpu_to_be_16(next_proto);
7812 case RTE_FLOW_ITEM_TYPE_IPV4:
7813 ipv4 = (struct rte_ipv4_hdr *)buf;
7814 ipv4->version_ihl = 0x45;
7815 if (next_proto && ipv4->next_proto_id == 0)
7816 ipv4->next_proto_id = (uint8_t)next_proto;
7818 case RTE_FLOW_ITEM_TYPE_IPV6:
7819 ipv6 = (struct rte_ipv6_hdr *)buf;
7820 if (next_proto && ipv6->proto == 0)
7821 ipv6->proto = (uint8_t)next_proto;
7822 ipv6_vtc_flow = rte_be_to_cpu_32(ipv6->vtc_flow);
7823 ipv6_vtc_flow &= 0x0FFFFFFF; /*< reset version bits. */
7824 ipv6_vtc_flow |= 0x60000000; /*< set ipv6 version. */
7825 ipv6->vtc_flow = rte_cpu_to_be_32(ipv6_vtc_flow);
7827 case RTE_FLOW_ITEM_TYPE_VXLAN:
7828 vxlan = (struct rte_vxlan_hdr *)buf;
7829 vxlan->vx_flags = 0x08;
7831 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
7832 gpe = (struct rte_vxlan_gpe_hdr *)buf;
7833 gpe->vx_flags = 0x0C;
7835 case RTE_FLOW_ITEM_TYPE_NVGRE:
7836 nvgre = (struct rte_flow_item_nvgre *)buf;
7837 nvgre->protocol = rte_cpu_to_be_16(0x6558);
7838 nvgre->c_k_s_rsvd0_ver = rte_cpu_to_be_16(0x2000);
7845 /** Helper of get item's default mask. */
7847 flow_item_default_mask(const struct rte_flow_item *item)
7849 const void *mask = NULL;
7850 static rte_be32_t gre_key_default_mask = RTE_BE32(UINT32_MAX);
7852 switch (item->type) {
7853 case RTE_FLOW_ITEM_TYPE_ANY:
7854 mask = &rte_flow_item_any_mask;
7856 case RTE_FLOW_ITEM_TYPE_VF:
7857 mask = &rte_flow_item_vf_mask;
7859 case RTE_FLOW_ITEM_TYPE_PORT_ID:
7860 mask = &rte_flow_item_port_id_mask;
7862 case RTE_FLOW_ITEM_TYPE_RAW:
7863 mask = &rte_flow_item_raw_mask;
7865 case RTE_FLOW_ITEM_TYPE_ETH:
7866 mask = &rte_flow_item_eth_mask;
7868 case RTE_FLOW_ITEM_TYPE_VLAN:
7869 mask = &rte_flow_item_vlan_mask;
7871 case RTE_FLOW_ITEM_TYPE_IPV4:
7872 mask = &rte_flow_item_ipv4_mask;
7874 case RTE_FLOW_ITEM_TYPE_IPV6:
7875 mask = &rte_flow_item_ipv6_mask;
7877 case RTE_FLOW_ITEM_TYPE_ICMP:
7878 mask = &rte_flow_item_icmp_mask;
7880 case RTE_FLOW_ITEM_TYPE_UDP:
7881 mask = &rte_flow_item_udp_mask;
7883 case RTE_FLOW_ITEM_TYPE_TCP:
7884 mask = &rte_flow_item_tcp_mask;
7886 case RTE_FLOW_ITEM_TYPE_SCTP:
7887 mask = &rte_flow_item_sctp_mask;
7889 case RTE_FLOW_ITEM_TYPE_VXLAN:
7890 mask = &rte_flow_item_vxlan_mask;
7892 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
7893 mask = &rte_flow_item_vxlan_gpe_mask;
7895 case RTE_FLOW_ITEM_TYPE_E_TAG:
7896 mask = &rte_flow_item_e_tag_mask;
7898 case RTE_FLOW_ITEM_TYPE_NVGRE:
7899 mask = &rte_flow_item_nvgre_mask;
7901 case RTE_FLOW_ITEM_TYPE_MPLS:
7902 mask = &rte_flow_item_mpls_mask;
7904 case RTE_FLOW_ITEM_TYPE_GRE:
7905 mask = &rte_flow_item_gre_mask;
7907 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
7908 mask = &gre_key_default_mask;
7910 case RTE_FLOW_ITEM_TYPE_META:
7911 mask = &rte_flow_item_meta_mask;
7913 case RTE_FLOW_ITEM_TYPE_FUZZY:
7914 mask = &rte_flow_item_fuzzy_mask;
7916 case RTE_FLOW_ITEM_TYPE_GTP:
7917 mask = &rte_flow_item_gtp_mask;
7919 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
7920 mask = &rte_flow_item_gtp_psc_mask;
7922 case RTE_FLOW_ITEM_TYPE_GENEVE:
7923 mask = &rte_flow_item_geneve_mask;
7925 case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
7926 mask = &rte_flow_item_geneve_opt_mask;
7928 case RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID:
7929 mask = &rte_flow_item_pppoe_proto_id_mask;
7931 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
7932 mask = &rte_flow_item_l2tpv3oip_mask;
7934 case RTE_FLOW_ITEM_TYPE_ESP:
7935 mask = &rte_flow_item_esp_mask;
7937 case RTE_FLOW_ITEM_TYPE_AH:
7938 mask = &rte_flow_item_ah_mask;
7940 case RTE_FLOW_ITEM_TYPE_PFCP:
7941 mask = &rte_flow_item_pfcp_mask;
7949 /** Dispatch parsed buffer to function calls. */
7951 cmd_set_raw_parsed_sample(const struct buffer *in)
7953 uint32_t n = in->args.vc.actions_n;
7955 struct rte_flow_action *action = NULL;
7956 struct rte_flow_action *data = NULL;
7957 const struct rte_flow_action_rss *rss = NULL;
7959 uint16_t idx = in->port; /* We borrow port field as index */
7960 uint32_t max_size = sizeof(struct rte_flow_action) *
7961 ACTION_SAMPLE_ACTIONS_NUM;
7963 RTE_ASSERT(in->command == SET_SAMPLE_ACTIONS);
7964 data = (struct rte_flow_action *)&raw_sample_confs[idx].data;
7965 memset(data, 0x00, max_size);
7966 for (; i <= n - 1; i++) {
7967 action = in->args.vc.actions + i;
7968 if (action->type == RTE_FLOW_ACTION_TYPE_END)
7970 switch (action->type) {
7971 case RTE_FLOW_ACTION_TYPE_MARK:
7972 size = sizeof(struct rte_flow_action_mark);
7973 rte_memcpy(&sample_mark[idx],
7974 (const void *)action->conf, size);
7975 action->conf = &sample_mark[idx];
7977 case RTE_FLOW_ACTION_TYPE_COUNT:
7978 size = sizeof(struct rte_flow_action_count);
7979 rte_memcpy(&sample_count[idx],
7980 (const void *)action->conf, size);
7981 action->conf = &sample_count[idx];
7983 case RTE_FLOW_ACTION_TYPE_QUEUE:
7984 size = sizeof(struct rte_flow_action_queue);
7985 rte_memcpy(&sample_queue[idx],
7986 (const void *)action->conf, size);
7987 action->conf = &sample_queue[idx];
7989 case RTE_FLOW_ACTION_TYPE_RSS:
7990 size = sizeof(struct rte_flow_action_rss);
7992 rte_memcpy(&sample_rss_data[idx].conf,
7993 (const void *)rss, size);
7994 if (rss->key_len && rss->key) {
7995 sample_rss_data[idx].conf.key =
7996 sample_rss_data[idx].key;
7997 rte_memcpy((void *)((uintptr_t)
7998 sample_rss_data[idx].conf.key),
7999 (const void *)rss->key,
8000 sizeof(uint8_t) * rss->key_len);
8002 if (rss->queue_num && rss->queue) {
8003 sample_rss_data[idx].conf.queue =
8004 sample_rss_data[idx].queue;
8005 rte_memcpy((void *)((uintptr_t)
8006 sample_rss_data[idx].conf.queue),
8007 (const void *)rss->queue,
8008 sizeof(uint16_t) * rss->queue_num);
8010 action->conf = &sample_rss_data[idx].conf;
8012 case RTE_FLOW_ACTION_TYPE_RAW_ENCAP:
8013 size = sizeof(struct rte_flow_action_raw_encap);
8014 rte_memcpy(&sample_encap[idx],
8015 (const void *)action->conf, size);
8016 action->conf = &sample_encap[idx];
8018 case RTE_FLOW_ACTION_TYPE_PORT_ID:
8019 size = sizeof(struct rte_flow_action_port_id);
8020 rte_memcpy(&sample_port_id[idx],
8021 (const void *)action->conf, size);
8022 action->conf = &sample_port_id[idx];
8024 case RTE_FLOW_ACTION_TYPE_PF:
8026 case RTE_FLOW_ACTION_TYPE_VF:
8027 size = sizeof(struct rte_flow_action_vf);
8028 rte_memcpy(&sample_vf[idx],
8029 (const void *)action->conf, size);
8030 action->conf = &sample_vf[idx];
8032 case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP:
8033 size = sizeof(struct rte_flow_action_vxlan_encap);
8034 parse_setup_vxlan_encap_data(&sample_vxlan_encap[idx]);
8035 action->conf = &sample_vxlan_encap[idx].conf;
8037 case RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP:
8038 size = sizeof(struct rte_flow_action_nvgre_encap);
8039 parse_setup_nvgre_encap_data(&sample_nvgre_encap[idx]);
8040 action->conf = &sample_nvgre_encap[idx];
8043 printf("Error - Not supported action\n");
8046 rte_memcpy(data, action, sizeof(struct rte_flow_action));
8051 /** Dispatch parsed buffer to function calls. */
8053 cmd_set_raw_parsed(const struct buffer *in)
8055 uint32_t n = in->args.vc.pattern_n;
8057 struct rte_flow_item *item = NULL;
8059 uint8_t *data = NULL;
8060 uint8_t *data_tail = NULL;
8061 size_t *total_size = NULL;
8062 uint16_t upper_layer = 0;
8064 uint16_t idx = in->port; /* We borrow port field as index */
8065 int gtp_psc = -1; /* GTP PSC option index. */
8067 if (in->command == SET_SAMPLE_ACTIONS)
8068 return cmd_set_raw_parsed_sample(in);
8069 RTE_ASSERT(in->command == SET_RAW_ENCAP ||
8070 in->command == SET_RAW_DECAP);
8071 if (in->command == SET_RAW_ENCAP) {
8072 total_size = &raw_encap_confs[idx].size;
8073 data = (uint8_t *)&raw_encap_confs[idx].data;
8075 total_size = &raw_decap_confs[idx].size;
8076 data = (uint8_t *)&raw_decap_confs[idx].data;
8079 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
8080 /* process hdr from upper layer to low layer (L3/L4 -> L2). */
8081 data_tail = data + ACTION_RAW_ENCAP_MAX_DATA;
8082 for (i = n - 1 ; i >= 0; --i) {
8083 const struct rte_flow_item_gtp *gtp;
8084 const struct rte_flow_item_geneve_opt *opt;
8086 item = in->args.vc.pattern + i;
8087 if (item->spec == NULL)
8088 item->spec = flow_item_default_mask(item);
8089 switch (item->type) {
8090 case RTE_FLOW_ITEM_TYPE_ETH:
8091 size = sizeof(struct rte_ether_hdr);
8093 case RTE_FLOW_ITEM_TYPE_VLAN:
8094 size = sizeof(struct rte_vlan_hdr);
8095 proto = RTE_ETHER_TYPE_VLAN;
8097 case RTE_FLOW_ITEM_TYPE_IPV4:
8098 size = sizeof(struct rte_ipv4_hdr);
8099 proto = RTE_ETHER_TYPE_IPV4;
8101 case RTE_FLOW_ITEM_TYPE_IPV6:
8102 size = sizeof(struct rte_ipv6_hdr);
8103 proto = RTE_ETHER_TYPE_IPV6;
8105 case RTE_FLOW_ITEM_TYPE_UDP:
8106 size = sizeof(struct rte_udp_hdr);
8109 case RTE_FLOW_ITEM_TYPE_TCP:
8110 size = sizeof(struct rte_tcp_hdr);
8113 case RTE_FLOW_ITEM_TYPE_VXLAN:
8114 size = sizeof(struct rte_vxlan_hdr);
8116 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
8117 size = sizeof(struct rte_vxlan_gpe_hdr);
8119 case RTE_FLOW_ITEM_TYPE_GRE:
8120 size = sizeof(struct rte_gre_hdr);
8123 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
8124 size = sizeof(rte_be32_t);
8127 case RTE_FLOW_ITEM_TYPE_MPLS:
8128 size = sizeof(struct rte_mpls_hdr);
8131 case RTE_FLOW_ITEM_TYPE_NVGRE:
8132 size = sizeof(struct rte_flow_item_nvgre);
8135 case RTE_FLOW_ITEM_TYPE_GENEVE:
8136 size = sizeof(struct rte_geneve_hdr);
8138 case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
8139 opt = (const struct rte_flow_item_geneve_opt *)
8141 size = offsetof(struct rte_flow_item_geneve_opt, data);
8142 if (opt->option_len && opt->data) {
8143 *total_size += opt->option_len *
8145 rte_memcpy(data_tail - (*total_size),
8147 opt->option_len * sizeof(uint32_t));
8150 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
8151 size = sizeof(rte_be32_t);
8154 case RTE_FLOW_ITEM_TYPE_ESP:
8155 size = sizeof(struct rte_esp_hdr);
8158 case RTE_FLOW_ITEM_TYPE_AH:
8159 size = sizeof(struct rte_flow_item_ah);
8162 case RTE_FLOW_ITEM_TYPE_GTP:
8164 size = sizeof(struct rte_gtp_hdr);
8167 if (gtp_psc != i + 1) {
8168 printf("Error - GTP PSC does not follow GTP\n");
8172 if ((gtp->v_pt_rsv_flags & 0x07) != 0x04) {
8173 /* Only E flag should be set. */
8174 printf("Error - GTP unsupported flags\n");
8177 struct rte_gtp_hdr_ext_word ext_word = {
8181 /* We have to add GTP header extra word. */
8182 *total_size += sizeof(ext_word);
8183 rte_memcpy(data_tail - (*total_size),
8184 &ext_word, sizeof(ext_word));
8186 size = sizeof(struct rte_gtp_hdr);
8188 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
8190 printf("Error - Multiple GTP PSC items\n");
8193 const struct rte_flow_item_gtp_psc
8202 if (opt->pdu_type & 0x0F) {
8203 /* Support the minimal option only. */
8204 printf("Error - GTP PSC option with "
8205 "extra fields not supported\n");
8208 psc.len = sizeof(psc);
8209 psc.pdu_type = opt->pdu_type;
8212 *total_size += sizeof(psc);
8213 rte_memcpy(data_tail - (*total_size),
8219 case RTE_FLOW_ITEM_TYPE_PFCP:
8220 size = sizeof(struct rte_flow_item_pfcp);
8223 printf("Error - Not supported item\n");
8226 *total_size += size;
8227 rte_memcpy(data_tail - (*total_size), item->spec, size);
8228 /* update some fields which cannot be set by cmdline */
8229 update_fields((data_tail - (*total_size)), item,
8231 upper_layer = proto;
8233 if (verbose_level & 0x1)
8234 printf("total data size is %zu\n", (*total_size));
8235 RTE_ASSERT((*total_size) <= ACTION_RAW_ENCAP_MAX_DATA);
8236 memmove(data, (data_tail - (*total_size)), *total_size);
8241 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
8244 /** Populate help strings for current token (cmdline API). */
8246 cmd_set_raw_get_help(cmdline_parse_token_hdr_t *hdr, char *dst,
8249 struct context *ctx = &cmd_flow_context;
8250 const struct token *token = &token_list[ctx->prev];
8255 /* Set token type and update global help with details. */
8256 snprintf(dst, size, "%s", (token->type ? token->type : "TOKEN"));
8258 cmd_set_raw.help_str = token->help;
8260 cmd_set_raw.help_str = token->name;
8264 /** Token definition template (cmdline API). */
8265 static struct cmdline_token_hdr cmd_set_raw_token_hdr = {
8266 .ops = &(struct cmdline_token_ops){
8267 .parse = cmd_flow_parse,
8268 .complete_get_nb = cmd_flow_complete_get_nb,
8269 .complete_get_elt = cmd_flow_complete_get_elt,
8270 .get_help = cmd_set_raw_get_help,
8275 /** Populate the next dynamic token. */
8277 cmd_set_raw_tok(cmdline_parse_token_hdr_t **hdr,
8278 cmdline_parse_token_hdr_t **hdr_inst)
8280 struct context *ctx = &cmd_flow_context;
8282 /* Always reinitialize context before requesting the first token. */
8283 if (!(hdr_inst - cmd_set_raw.tokens)) {
8284 cmd_flow_context_init(ctx);
8285 ctx->curr = START_SET;
8287 /* Return NULL when no more tokens are expected. */
8288 if (!ctx->next_num && (ctx->curr != START_SET)) {
8292 /* Determine if command should end here. */
8293 if (ctx->eol && ctx->last && ctx->next_num) {
8294 const enum index *list = ctx->next[ctx->next_num - 1];
8297 for (i = 0; list[i]; ++i) {
8304 *hdr = &cmd_set_raw_token_hdr;
8307 /** Token generator and output processing callback (cmdline API). */
8309 cmd_set_raw_cb(void *arg0, struct cmdline *cl, void *arg2)
8312 cmd_set_raw_tok(arg0, arg2);
8314 cmd_set_raw_parsed(arg0);
8317 /** Global parser instance (cmdline API). */
8318 cmdline_parse_inst_t cmd_set_raw = {
8319 .f = cmd_set_raw_cb,
8320 .data = NULL, /**< Unused. */
8321 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
8324 }, /**< Tokens are returned by cmd_flow_tok(). */
8327 /* *** display raw_encap/raw_decap buf */
8328 struct cmd_show_set_raw_result {
8329 cmdline_fixed_string_t cmd_show;
8330 cmdline_fixed_string_t cmd_what;
8331 cmdline_fixed_string_t cmd_all;
8336 cmd_show_set_raw_parsed(void *parsed_result, struct cmdline *cl, void *data)
8338 struct cmd_show_set_raw_result *res = parsed_result;
8339 uint16_t index = res->cmd_index;
8341 uint8_t *raw_data = NULL;
8342 size_t raw_size = 0;
8343 char title[16] = {0};
8347 if (!strcmp(res->cmd_all, "all")) {
8350 } else if (index >= RAW_ENCAP_CONFS_MAX_NUM) {
8351 printf("index should be 0-%u\n", RAW_ENCAP_CONFS_MAX_NUM - 1);
8355 if (!strcmp(res->cmd_what, "raw_encap")) {
8356 raw_data = (uint8_t *)&raw_encap_confs[index].data;
8357 raw_size = raw_encap_confs[index].size;
8358 snprintf(title, 16, "\nindex: %u", index);
8359 rte_hexdump(stdout, title, raw_data, raw_size);
8361 raw_data = (uint8_t *)&raw_decap_confs[index].data;
8362 raw_size = raw_decap_confs[index].size;
8363 snprintf(title, 16, "\nindex: %u", index);
8364 rte_hexdump(stdout, title, raw_data, raw_size);
8366 } while (all && ++index < RAW_ENCAP_CONFS_MAX_NUM);
8369 cmdline_parse_token_string_t cmd_show_set_raw_cmd_show =
8370 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
8372 cmdline_parse_token_string_t cmd_show_set_raw_cmd_what =
8373 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
8374 cmd_what, "raw_encap#raw_decap");
8375 cmdline_parse_token_num_t cmd_show_set_raw_cmd_index =
8376 TOKEN_NUM_INITIALIZER(struct cmd_show_set_raw_result,
8377 cmd_index, RTE_UINT16);
8378 cmdline_parse_token_string_t cmd_show_set_raw_cmd_all =
8379 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
8381 cmdline_parse_inst_t cmd_show_set_raw = {
8382 .f = cmd_show_set_raw_parsed,
8384 .help_str = "show <raw_encap|raw_decap> <index>",
8386 (void *)&cmd_show_set_raw_cmd_show,
8387 (void *)&cmd_show_set_raw_cmd_what,
8388 (void *)&cmd_show_set_raw_cmd_index,
8392 cmdline_parse_inst_t cmd_show_set_raw_all = {
8393 .f = cmd_show_set_raw_parsed,
8395 .help_str = "show <raw_encap|raw_decap> all",
8397 (void *)&cmd_show_set_raw_cmd_show,
8398 (void *)&cmd_show_set_raw_cmd_what,
8399 (void *)&cmd_show_set_raw_cmd_all,