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 /* Shared action arguments */
116 SHARED_ACTION_CREATE,
117 SHARED_ACTION_UPDATE,
118 SHARED_ACTION_DESTROY,
121 /* Shared action create arguments */
122 SHARED_ACTION_CREATE_ID,
123 SHARED_ACTION_INGRESS,
124 SHARED_ACTION_EGRESS,
125 SHARED_ACTION_TRANSFER,
128 /* Shared action destroy arguments */
129 SHARED_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 /* Validate/create actions. */
317 ACTION_RSS_FUNC_DEFAULT,
318 ACTION_RSS_FUNC_TOEPLITZ,
319 ACTION_RSS_FUNC_SIMPLE_XOR,
320 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ,
332 ACTION_PHY_PORT_ORIGINAL,
333 ACTION_PHY_PORT_INDEX,
335 ACTION_PORT_ID_ORIGINAL,
339 ACTION_OF_SET_MPLS_TTL,
340 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
341 ACTION_OF_DEC_MPLS_TTL,
342 ACTION_OF_SET_NW_TTL,
343 ACTION_OF_SET_NW_TTL_NW_TTL,
344 ACTION_OF_DEC_NW_TTL,
345 ACTION_OF_COPY_TTL_OUT,
346 ACTION_OF_COPY_TTL_IN,
349 ACTION_OF_PUSH_VLAN_ETHERTYPE,
350 ACTION_OF_SET_VLAN_VID,
351 ACTION_OF_SET_VLAN_VID_VLAN_VID,
352 ACTION_OF_SET_VLAN_PCP,
353 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
355 ACTION_OF_POP_MPLS_ETHERTYPE,
357 ACTION_OF_PUSH_MPLS_ETHERTYPE,
364 ACTION_MPLSOGRE_ENCAP,
365 ACTION_MPLSOGRE_DECAP,
366 ACTION_MPLSOUDP_ENCAP,
367 ACTION_MPLSOUDP_DECAP,
369 ACTION_SET_IPV4_SRC_IPV4_SRC,
371 ACTION_SET_IPV4_DST_IPV4_DST,
373 ACTION_SET_IPV6_SRC_IPV6_SRC,
375 ACTION_SET_IPV6_DST_IPV6_DST,
377 ACTION_SET_TP_SRC_TP_SRC,
379 ACTION_SET_TP_DST_TP_DST,
385 ACTION_SET_MAC_SRC_MAC_SRC,
387 ACTION_SET_MAC_DST_MAC_DST,
389 ACTION_INC_TCP_SEQ_VALUE,
391 ACTION_DEC_TCP_SEQ_VALUE,
393 ACTION_INC_TCP_ACK_VALUE,
395 ACTION_DEC_TCP_ACK_VALUE,
398 ACTION_RAW_ENCAP_INDEX,
399 ACTION_RAW_ENCAP_INDEX_VALUE,
400 ACTION_RAW_DECAP_INDEX,
401 ACTION_RAW_DECAP_INDEX_VALUE,
404 ACTION_SET_TAG_INDEX,
407 ACTION_SET_META_DATA,
408 ACTION_SET_META_MASK,
409 ACTION_SET_IPV4_DSCP,
410 ACTION_SET_IPV4_DSCP_VALUE,
411 ACTION_SET_IPV6_DSCP,
412 ACTION_SET_IPV6_DSCP_VALUE,
418 ACTION_SAMPLE_INDEX_VALUE,
420 SHARED_ACTION_ID2PTR,
422 ACTION_MODIFY_FIELD_OP,
423 ACTION_MODIFY_FIELD_OP_VALUE,
424 ACTION_MODIFY_FIELD_DST_TYPE,
425 ACTION_MODIFY_FIELD_DST_TYPE_VALUE,
426 ACTION_MODIFY_FIELD_DST_LEVEL,
427 ACTION_MODIFY_FIELD_DST_OFFSET,
428 ACTION_MODIFY_FIELD_SRC_TYPE,
429 ACTION_MODIFY_FIELD_SRC_TYPE_VALUE,
430 ACTION_MODIFY_FIELD_SRC_LEVEL,
431 ACTION_MODIFY_FIELD_SRC_OFFSET,
432 ACTION_MODIFY_FIELD_SRC_VALUE,
433 ACTION_MODIFY_FIELD_WIDTH,
436 /** Maximum size for pattern in struct rte_flow_item_raw. */
437 #define ITEM_RAW_PATTERN_SIZE 40
439 /** Maximum size for GENEVE option data pattern in bytes. */
440 #define ITEM_GENEVE_OPT_DATA_SIZE 124
442 /** Storage size for struct rte_flow_item_raw including pattern. */
443 #define ITEM_RAW_SIZE \
444 (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE)
446 /** Maximum number of queue indices in struct rte_flow_action_rss. */
447 #define ACTION_RSS_QUEUE_NUM 128
449 /** Storage for struct rte_flow_action_rss including external data. */
450 struct action_rss_data {
451 struct rte_flow_action_rss conf;
452 uint8_t key[RSS_HASH_KEY_LENGTH];
453 uint16_t queue[ACTION_RSS_QUEUE_NUM];
456 /** Maximum data size in struct rte_flow_action_raw_encap. */
457 #define ACTION_RAW_ENCAP_MAX_DATA 512
458 #define RAW_ENCAP_CONFS_MAX_NUM 8
460 /** Storage for struct rte_flow_action_raw_encap. */
461 struct raw_encap_conf {
462 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
463 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
467 struct raw_encap_conf raw_encap_confs[RAW_ENCAP_CONFS_MAX_NUM];
469 /** Storage for struct rte_flow_action_raw_encap including external data. */
470 struct action_raw_encap_data {
471 struct rte_flow_action_raw_encap conf;
472 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
473 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
477 /** Storage for struct rte_flow_action_raw_decap. */
478 struct raw_decap_conf {
479 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
483 struct raw_decap_conf raw_decap_confs[RAW_ENCAP_CONFS_MAX_NUM];
485 /** Storage for struct rte_flow_action_raw_decap including external data. */
486 struct action_raw_decap_data {
487 struct rte_flow_action_raw_decap conf;
488 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
492 struct vxlan_encap_conf vxlan_encap_conf = {
496 .vni = "\x00\x00\x00",
498 .udp_dst = RTE_BE16(RTE_VXLAN_DEFAULT_PORT),
499 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
500 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
501 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
502 "\x00\x00\x00\x00\x00\x00\x00\x01",
503 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
504 "\x00\x00\x00\x00\x00\x00\x11\x11",
508 .eth_src = "\x00\x00\x00\x00\x00\x00",
509 .eth_dst = "\xff\xff\xff\xff\xff\xff",
512 /** Maximum number of items in struct rte_flow_action_vxlan_encap. */
513 #define ACTION_VXLAN_ENCAP_ITEMS_NUM 6
515 /** Storage for struct rte_flow_action_vxlan_encap including external data. */
516 struct action_vxlan_encap_data {
517 struct rte_flow_action_vxlan_encap conf;
518 struct rte_flow_item items[ACTION_VXLAN_ENCAP_ITEMS_NUM];
519 struct rte_flow_item_eth item_eth;
520 struct rte_flow_item_vlan item_vlan;
522 struct rte_flow_item_ipv4 item_ipv4;
523 struct rte_flow_item_ipv6 item_ipv6;
525 struct rte_flow_item_udp item_udp;
526 struct rte_flow_item_vxlan item_vxlan;
529 struct nvgre_encap_conf nvgre_encap_conf = {
532 .tni = "\x00\x00\x00",
533 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
534 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
535 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
536 "\x00\x00\x00\x00\x00\x00\x00\x01",
537 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
538 "\x00\x00\x00\x00\x00\x00\x11\x11",
540 .eth_src = "\x00\x00\x00\x00\x00\x00",
541 .eth_dst = "\xff\xff\xff\xff\xff\xff",
544 /** Maximum number of items in struct rte_flow_action_nvgre_encap. */
545 #define ACTION_NVGRE_ENCAP_ITEMS_NUM 5
547 /** Storage for struct rte_flow_action_nvgre_encap including external data. */
548 struct action_nvgre_encap_data {
549 struct rte_flow_action_nvgre_encap conf;
550 struct rte_flow_item items[ACTION_NVGRE_ENCAP_ITEMS_NUM];
551 struct rte_flow_item_eth item_eth;
552 struct rte_flow_item_vlan item_vlan;
554 struct rte_flow_item_ipv4 item_ipv4;
555 struct rte_flow_item_ipv6 item_ipv6;
557 struct rte_flow_item_nvgre item_nvgre;
560 struct l2_encap_conf l2_encap_conf;
562 struct l2_decap_conf l2_decap_conf;
564 struct mplsogre_encap_conf mplsogre_encap_conf;
566 struct mplsogre_decap_conf mplsogre_decap_conf;
568 struct mplsoudp_encap_conf mplsoudp_encap_conf;
570 struct mplsoudp_decap_conf mplsoudp_decap_conf;
572 #define ACTION_SAMPLE_ACTIONS_NUM 10
573 #define RAW_SAMPLE_CONFS_MAX_NUM 8
574 /** Storage for struct rte_flow_action_sample including external data. */
575 struct action_sample_data {
576 struct rte_flow_action_sample conf;
579 /** Storage for struct rte_flow_action_sample. */
580 struct raw_sample_conf {
581 struct rte_flow_action data[ACTION_SAMPLE_ACTIONS_NUM];
583 struct raw_sample_conf raw_sample_confs[RAW_SAMPLE_CONFS_MAX_NUM];
584 struct rte_flow_action_mark sample_mark[RAW_SAMPLE_CONFS_MAX_NUM];
585 struct rte_flow_action_queue sample_queue[RAW_SAMPLE_CONFS_MAX_NUM];
586 struct rte_flow_action_count sample_count[RAW_SAMPLE_CONFS_MAX_NUM];
587 struct rte_flow_action_port_id sample_port_id[RAW_SAMPLE_CONFS_MAX_NUM];
588 struct rte_flow_action_raw_encap sample_encap[RAW_SAMPLE_CONFS_MAX_NUM];
589 struct action_vxlan_encap_data sample_vxlan_encap[RAW_SAMPLE_CONFS_MAX_NUM];
590 struct action_nvgre_encap_data sample_nvgre_encap[RAW_SAMPLE_CONFS_MAX_NUM];
591 struct action_rss_data sample_rss_data[RAW_SAMPLE_CONFS_MAX_NUM];
592 struct rte_flow_action_vf sample_vf[RAW_SAMPLE_CONFS_MAX_NUM];
594 static const char *const modify_field_ops[] = {
595 "set", "add", "sub", NULL
598 static const char *const modify_field_ids[] = {
599 "start", "mac_dst", "mac_src",
600 "vlan_type", "vlan_id", "mac_type",
601 "ipv4_dscp", "ipv4_ttl", "ipv4_src", "ipv4_dst",
602 "ipv6_dscp", "ipv6_hoplimit", "ipv6_src", "ipv6_dst",
603 "tcp_port_src", "tcp_port_dst",
604 "tcp_seq_num", "tcp_ack_num", "tcp_flags",
605 "udp_port_src", "udp_port_dst",
606 "vxlan_vni", "geneve_vni", "gtp_teid",
607 "tag", "mark", "meta", "pointer", "value", NULL
610 /** Maximum number of subsequent tokens and arguments on the stack. */
611 #define CTX_STACK_SIZE 16
613 /** Parser context. */
615 /** Stack of subsequent token lists to process. */
616 const enum index *next[CTX_STACK_SIZE];
617 /** Arguments for stacked tokens. */
618 const void *args[CTX_STACK_SIZE];
619 enum index curr; /**< Current token index. */
620 enum index prev; /**< Index of the last token seen. */
621 int next_num; /**< Number of entries in next[]. */
622 int args_num; /**< Number of entries in args[]. */
623 uint32_t eol:1; /**< EOL has been detected. */
624 uint32_t last:1; /**< No more arguments. */
625 portid_t port; /**< Current port ID (for completions). */
626 uint32_t objdata; /**< Object-specific data. */
627 void *object; /**< Address of current object for relative offsets. */
628 void *objmask; /**< Object a full mask must be written to. */
631 /** Token argument. */
633 uint32_t hton:1; /**< Use network byte ordering. */
634 uint32_t sign:1; /**< Value is signed. */
635 uint32_t bounded:1; /**< Value is bounded. */
636 uintmax_t min; /**< Minimum value if bounded. */
637 uintmax_t max; /**< Maximum value if bounded. */
638 uint32_t offset; /**< Relative offset from ctx->object. */
639 uint32_t size; /**< Field size. */
640 const uint8_t *mask; /**< Bit-mask to use instead of offset/size. */
643 /** Parser token definition. */
645 /** Type displayed during completion (defaults to "TOKEN"). */
647 /** Help displayed during completion (defaults to token name). */
649 /** Private data used by parser functions. */
652 * Lists of subsequent tokens to push on the stack. Each call to the
653 * parser consumes the last entry of that stack.
655 const enum index *const *next;
656 /** Arguments stack for subsequent tokens that need them. */
657 const struct arg *const *args;
659 * Token-processing callback, returns -1 in case of error, the
660 * length of the matched string otherwise. If NULL, attempts to
661 * match the token name.
663 * If buf is not NULL, the result should be stored in it according
664 * to context. An error is returned if not large enough.
666 int (*call)(struct context *ctx, const struct token *token,
667 const char *str, unsigned int len,
668 void *buf, unsigned int size);
670 * Callback that provides possible values for this token, used for
671 * completion. Returns -1 in case of error, the number of possible
672 * values otherwise. If NULL, the token name is used.
674 * If buf is not NULL, entry index ent is written to buf and the
675 * full length of the entry is returned (same behavior as
678 int (*comp)(struct context *ctx, const struct token *token,
679 unsigned int ent, char *buf, unsigned int size);
680 /** Mandatory token name, no default value. */
684 /** Static initializer for the next field. */
685 #define NEXT(...) (const enum index *const []){ __VA_ARGS__, NULL, }
687 /** Static initializer for a NEXT() entry. */
688 #define NEXT_ENTRY(...) (const enum index []){ __VA_ARGS__, ZERO, }
690 /** Static initializer for the args field. */
691 #define ARGS(...) (const struct arg *const []){ __VA_ARGS__, NULL, }
693 /** Static initializer for ARGS() to target a field. */
694 #define ARGS_ENTRY(s, f) \
695 (&(const struct arg){ \
696 .offset = offsetof(s, f), \
697 .size = sizeof(((s *)0)->f), \
700 /** Static initializer for ARGS() to target a bit-field. */
701 #define ARGS_ENTRY_BF(s, f, b) \
702 (&(const struct arg){ \
704 .mask = (const void *)&(const s){ .f = (1 << (b)) - 1 }, \
707 /** Static initializer for ARGS() to target a field with limits. */
708 #define ARGS_ENTRY_BOUNDED(s, f, i, a) \
709 (&(const struct arg){ \
713 .offset = offsetof(s, f), \
714 .size = sizeof(((s *)0)->f), \
717 /** Static initializer for ARGS() to target an arbitrary bit-mask. */
718 #define ARGS_ENTRY_MASK(s, f, m) \
719 (&(const struct arg){ \
720 .offset = offsetof(s, f), \
721 .size = sizeof(((s *)0)->f), \
722 .mask = (const void *)(m), \
725 /** Same as ARGS_ENTRY_MASK() using network byte ordering for the value. */
726 #define ARGS_ENTRY_MASK_HTON(s, f, m) \
727 (&(const struct arg){ \
729 .offset = offsetof(s, f), \
730 .size = sizeof(((s *)0)->f), \
731 .mask = (const void *)(m), \
734 /** Static initializer for ARGS() to target a pointer. */
735 #define ARGS_ENTRY_PTR(s, f) \
736 (&(const struct arg){ \
737 .size = sizeof(*((s *)0)->f), \
740 /** Static initializer for ARGS() with arbitrary offset and size. */
741 #define ARGS_ENTRY_ARB(o, s) \
742 (&(const struct arg){ \
747 /** Same as ARGS_ENTRY_ARB() with bounded values. */
748 #define ARGS_ENTRY_ARB_BOUNDED(o, s, i, a) \
749 (&(const struct arg){ \
757 /** Same as ARGS_ENTRY() using network byte ordering. */
758 #define ARGS_ENTRY_HTON(s, f) \
759 (&(const struct arg){ \
761 .offset = offsetof(s, f), \
762 .size = sizeof(((s *)0)->f), \
765 /** Same as ARGS_ENTRY_HTON() for a single argument, without structure. */
766 #define ARG_ENTRY_HTON(s) \
767 (&(const struct arg){ \
773 /** Parser output buffer layout expected by cmd_flow_parsed(). */
775 enum index command; /**< Flow command. */
776 portid_t port; /**< Affected port ID. */
780 uint32_t action_id_n;
781 } sa_destroy; /**< Shared action destroy arguments. */
784 } sa; /* Shared action query arguments */
786 struct rte_flow_attr attr;
787 struct tunnel_ops tunnel_ops;
788 struct rte_flow_item *pattern;
789 struct rte_flow_action *actions;
793 } vc; /**< Validate/create arguments. */
797 } destroy; /**< Destroy arguments. */
802 } dump; /**< Dump arguments. */
805 struct rte_flow_action action;
806 } query; /**< Query arguments. */
810 } list; /**< List arguments. */
813 } isolate; /**< Isolated mode arguments. */
816 } aged; /**< Aged arguments. */
817 } args; /**< Command arguments. */
820 /** Private data for pattern items. */
821 struct parse_item_priv {
822 enum rte_flow_item_type type; /**< Item type. */
823 uint32_t size; /**< Size of item specification structure. */
826 #define PRIV_ITEM(t, s) \
827 (&(const struct parse_item_priv){ \
828 .type = RTE_FLOW_ITEM_TYPE_ ## t, \
832 /** Private data for actions. */
833 struct parse_action_priv {
834 enum rte_flow_action_type type; /**< Action type. */
835 uint32_t size; /**< Size of action configuration structure. */
838 #define PRIV_ACTION(t, s) \
839 (&(const struct parse_action_priv){ \
840 .type = RTE_FLOW_ACTION_TYPE_ ## t, \
844 static const enum index next_sa_create_attr[] = {
845 SHARED_ACTION_CREATE_ID,
846 SHARED_ACTION_INGRESS,
847 SHARED_ACTION_EGRESS,
848 SHARED_ACTION_TRANSFER,
853 static const enum index next_dump_subcmd[] = {
859 static const enum index next_sa_subcmd[] = {
860 SHARED_ACTION_CREATE,
861 SHARED_ACTION_UPDATE,
862 SHARED_ACTION_DESTROY,
867 static const enum index next_vc_attr[] = {
879 static const enum index next_destroy_attr[] = {
885 static const enum index next_dump_attr[] = {
891 static const enum index next_list_attr[] = {
897 static const enum index next_aged_attr[] = {
903 static const enum index next_sa_destroy_attr[] = {
904 SHARED_ACTION_DESTROY_ID,
909 static const enum index item_param[] = {
918 static const enum index next_item[] = {
955 ITEM_ICMP6_ND_OPT_SLA_ETH,
956 ITEM_ICMP6_ND_OPT_TLA_ETH,
975 static const enum index item_fuzzy[] = {
981 static const enum index item_any[] = {
987 static const enum index item_vf[] = {
993 static const enum index item_phy_port[] = {
999 static const enum index item_port_id[] = {
1005 static const enum index item_mark[] = {
1011 static const enum index item_raw[] = {
1021 static const enum index item_eth[] = {
1030 static const enum index item_vlan[] = {
1035 ITEM_VLAN_INNER_TYPE,
1036 ITEM_VLAN_HAS_MORE_VLAN,
1041 static const enum index item_ipv4[] = {
1043 ITEM_IPV4_FRAGMENT_OFFSET,
1052 static const enum index item_ipv6[] = {
1059 ITEM_IPV6_HAS_FRAG_EXT,
1064 static const enum index item_icmp[] = {
1073 static const enum index item_udp[] = {
1080 static const enum index item_tcp[] = {
1088 static const enum index item_sctp[] = {
1097 static const enum index item_vxlan[] = {
1103 static const enum index item_e_tag[] = {
1104 ITEM_E_TAG_GRP_ECID_B,
1109 static const enum index item_nvgre[] = {
1115 static const enum index item_mpls[] = {
1123 static const enum index item_gre[] = {
1125 ITEM_GRE_C_RSVD0_VER,
1133 static const enum index item_gre_key[] = {
1139 static const enum index item_gtp[] = {
1147 static const enum index item_geneve[] = {
1155 static const enum index item_vxlan_gpe[] = {
1161 static const enum index item_arp_eth_ipv4[] = {
1162 ITEM_ARP_ETH_IPV4_SHA,
1163 ITEM_ARP_ETH_IPV4_SPA,
1164 ITEM_ARP_ETH_IPV4_THA,
1165 ITEM_ARP_ETH_IPV4_TPA,
1170 static const enum index item_ipv6_ext[] = {
1171 ITEM_IPV6_EXT_NEXT_HDR,
1176 static const enum index item_ipv6_frag_ext[] = {
1177 ITEM_IPV6_FRAG_EXT_NEXT_HDR,
1178 ITEM_IPV6_FRAG_EXT_FRAG_DATA,
1183 static const enum index item_icmp6[] = {
1190 static const enum index item_icmp6_nd_ns[] = {
1191 ITEM_ICMP6_ND_NS_TARGET_ADDR,
1196 static const enum index item_icmp6_nd_na[] = {
1197 ITEM_ICMP6_ND_NA_TARGET_ADDR,
1202 static const enum index item_icmp6_nd_opt[] = {
1203 ITEM_ICMP6_ND_OPT_TYPE,
1208 static const enum index item_icmp6_nd_opt_sla_eth[] = {
1209 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
1214 static const enum index item_icmp6_nd_opt_tla_eth[] = {
1215 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
1220 static const enum index item_meta[] = {
1226 static const enum index item_gtp_psc[] = {
1233 static const enum index item_pppoed[] = {
1239 static const enum index item_pppoes[] = {
1245 static const enum index item_pppoe_proto_id[] = {
1250 static const enum index item_higig2[] = {
1251 ITEM_HIGIG2_CLASSIFICATION,
1257 static const enum index item_esp[] = {
1263 static const enum index item_ah[] = {
1269 static const enum index item_pfcp[] = {
1276 static const enum index next_set_raw[] = {
1282 static const enum index item_tag[] = {
1289 static const enum index item_l2tpv3oip[] = {
1290 ITEM_L2TPV3OIP_SESSION_ID,
1295 static const enum index item_ecpri[] = {
1301 static const enum index item_ecpri_common[] = {
1302 ITEM_ECPRI_COMMON_TYPE,
1306 static const enum index item_ecpri_common_type[] = {
1307 ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
1308 ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
1309 ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
1313 static const enum index item_geneve_opt[] = {
1314 ITEM_GENEVE_OPT_CLASS,
1315 ITEM_GENEVE_OPT_TYPE,
1316 ITEM_GENEVE_OPT_LENGTH,
1317 ITEM_GENEVE_OPT_DATA,
1322 static const enum index next_action[] = {
1338 ACTION_OF_SET_MPLS_TTL,
1339 ACTION_OF_DEC_MPLS_TTL,
1340 ACTION_OF_SET_NW_TTL,
1341 ACTION_OF_DEC_NW_TTL,
1342 ACTION_OF_COPY_TTL_OUT,
1343 ACTION_OF_COPY_TTL_IN,
1345 ACTION_OF_PUSH_VLAN,
1346 ACTION_OF_SET_VLAN_VID,
1347 ACTION_OF_SET_VLAN_PCP,
1349 ACTION_OF_PUSH_MPLS,
1356 ACTION_MPLSOGRE_ENCAP,
1357 ACTION_MPLSOGRE_DECAP,
1358 ACTION_MPLSOUDP_ENCAP,
1359 ACTION_MPLSOUDP_DECAP,
1360 ACTION_SET_IPV4_SRC,
1361 ACTION_SET_IPV4_DST,
1362 ACTION_SET_IPV6_SRC,
1363 ACTION_SET_IPV6_DST,
1379 ACTION_SET_IPV4_DSCP,
1380 ACTION_SET_IPV6_DSCP,
1384 ACTION_MODIFY_FIELD,
1388 static const enum index action_mark[] = {
1394 static const enum index action_queue[] = {
1400 static const enum index action_count[] = {
1402 ACTION_COUNT_SHARED,
1407 static const enum index action_rss[] = {
1418 static const enum index action_vf[] = {
1425 static const enum index action_phy_port[] = {
1426 ACTION_PHY_PORT_ORIGINAL,
1427 ACTION_PHY_PORT_INDEX,
1432 static const enum index action_port_id[] = {
1433 ACTION_PORT_ID_ORIGINAL,
1439 static const enum index action_meter[] = {
1445 static const enum index action_of_set_mpls_ttl[] = {
1446 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
1451 static const enum index action_of_set_nw_ttl[] = {
1452 ACTION_OF_SET_NW_TTL_NW_TTL,
1457 static const enum index action_of_push_vlan[] = {
1458 ACTION_OF_PUSH_VLAN_ETHERTYPE,
1463 static const enum index action_of_set_vlan_vid[] = {
1464 ACTION_OF_SET_VLAN_VID_VLAN_VID,
1469 static const enum index action_of_set_vlan_pcp[] = {
1470 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
1475 static const enum index action_of_pop_mpls[] = {
1476 ACTION_OF_POP_MPLS_ETHERTYPE,
1481 static const enum index action_of_push_mpls[] = {
1482 ACTION_OF_PUSH_MPLS_ETHERTYPE,
1487 static const enum index action_set_ipv4_src[] = {
1488 ACTION_SET_IPV4_SRC_IPV4_SRC,
1493 static const enum index action_set_mac_src[] = {
1494 ACTION_SET_MAC_SRC_MAC_SRC,
1499 static const enum index action_set_ipv4_dst[] = {
1500 ACTION_SET_IPV4_DST_IPV4_DST,
1505 static const enum index action_set_ipv6_src[] = {
1506 ACTION_SET_IPV6_SRC_IPV6_SRC,
1511 static const enum index action_set_ipv6_dst[] = {
1512 ACTION_SET_IPV6_DST_IPV6_DST,
1517 static const enum index action_set_tp_src[] = {
1518 ACTION_SET_TP_SRC_TP_SRC,
1523 static const enum index action_set_tp_dst[] = {
1524 ACTION_SET_TP_DST_TP_DST,
1529 static const enum index action_set_ttl[] = {
1535 static const enum index action_jump[] = {
1541 static const enum index action_set_mac_dst[] = {
1542 ACTION_SET_MAC_DST_MAC_DST,
1547 static const enum index action_inc_tcp_seq[] = {
1548 ACTION_INC_TCP_SEQ_VALUE,
1553 static const enum index action_dec_tcp_seq[] = {
1554 ACTION_DEC_TCP_SEQ_VALUE,
1559 static const enum index action_inc_tcp_ack[] = {
1560 ACTION_INC_TCP_ACK_VALUE,
1565 static const enum index action_dec_tcp_ack[] = {
1566 ACTION_DEC_TCP_ACK_VALUE,
1571 static const enum index action_raw_encap[] = {
1572 ACTION_RAW_ENCAP_INDEX,
1577 static const enum index action_raw_decap[] = {
1578 ACTION_RAW_DECAP_INDEX,
1583 static const enum index action_set_tag[] = {
1584 ACTION_SET_TAG_DATA,
1585 ACTION_SET_TAG_INDEX,
1586 ACTION_SET_TAG_MASK,
1591 static const enum index action_set_meta[] = {
1592 ACTION_SET_META_DATA,
1593 ACTION_SET_META_MASK,
1598 static const enum index action_set_ipv4_dscp[] = {
1599 ACTION_SET_IPV4_DSCP_VALUE,
1604 static const enum index action_set_ipv6_dscp[] = {
1605 ACTION_SET_IPV6_DSCP_VALUE,
1610 static const enum index action_age[] = {
1617 static const enum index action_sample[] = {
1619 ACTION_SAMPLE_RATIO,
1620 ACTION_SAMPLE_INDEX,
1625 static const enum index next_action_sample[] = {
1638 static const enum index action_modify_field_dst[] = {
1639 ACTION_MODIFY_FIELD_DST_LEVEL,
1640 ACTION_MODIFY_FIELD_DST_OFFSET,
1641 ACTION_MODIFY_FIELD_SRC_TYPE,
1645 static const enum index action_modify_field_src[] = {
1646 ACTION_MODIFY_FIELD_SRC_LEVEL,
1647 ACTION_MODIFY_FIELD_SRC_OFFSET,
1648 ACTION_MODIFY_FIELD_SRC_VALUE,
1649 ACTION_MODIFY_FIELD_WIDTH,
1653 static int parse_set_raw_encap_decap(struct context *, const struct token *,
1654 const char *, unsigned int,
1655 void *, unsigned int);
1656 static int parse_set_sample_action(struct context *, const struct token *,
1657 const char *, unsigned int,
1658 void *, unsigned int);
1659 static int parse_set_init(struct context *, const struct token *,
1660 const char *, unsigned int,
1661 void *, unsigned int);
1662 static int parse_init(struct context *, const struct token *,
1663 const char *, unsigned int,
1664 void *, unsigned int);
1665 static int parse_vc(struct context *, const struct token *,
1666 const char *, unsigned int,
1667 void *, unsigned int);
1668 static int parse_vc_spec(struct context *, const struct token *,
1669 const char *, unsigned int, void *, unsigned int);
1670 static int parse_vc_conf(struct context *, const struct token *,
1671 const char *, unsigned int, void *, unsigned int);
1672 static int parse_vc_item_ecpri_type(struct context *, const struct token *,
1673 const char *, unsigned int,
1674 void *, unsigned int);
1675 static int parse_vc_action_rss(struct context *, const struct token *,
1676 const char *, unsigned int, void *,
1678 static int parse_vc_action_rss_func(struct context *, const struct token *,
1679 const char *, unsigned int, void *,
1681 static int parse_vc_action_rss_type(struct context *, const struct token *,
1682 const char *, unsigned int, void *,
1684 static int parse_vc_action_rss_queue(struct context *, const struct token *,
1685 const char *, unsigned int, void *,
1687 static int parse_vc_action_vxlan_encap(struct context *, const struct token *,
1688 const char *, unsigned int, void *,
1690 static int parse_vc_action_nvgre_encap(struct context *, const struct token *,
1691 const char *, unsigned int, void *,
1693 static int parse_vc_action_l2_encap(struct context *, const struct token *,
1694 const char *, unsigned int, void *,
1696 static int parse_vc_action_l2_decap(struct context *, const struct token *,
1697 const char *, unsigned int, void *,
1699 static int parse_vc_action_mplsogre_encap(struct context *,
1700 const struct token *, const char *,
1701 unsigned int, void *, unsigned int);
1702 static int parse_vc_action_mplsogre_decap(struct context *,
1703 const struct token *, const char *,
1704 unsigned int, void *, unsigned int);
1705 static int parse_vc_action_mplsoudp_encap(struct context *,
1706 const struct token *, const char *,
1707 unsigned int, void *, unsigned int);
1708 static int parse_vc_action_mplsoudp_decap(struct context *,
1709 const struct token *, const char *,
1710 unsigned int, void *, unsigned int);
1711 static int parse_vc_action_raw_encap(struct context *,
1712 const struct token *, const char *,
1713 unsigned int, void *, unsigned int);
1714 static int parse_vc_action_raw_decap(struct context *,
1715 const struct token *, const char *,
1716 unsigned int, void *, unsigned int);
1717 static int parse_vc_action_raw_encap_index(struct context *,
1718 const struct token *, const char *,
1719 unsigned int, void *, unsigned int);
1720 static int parse_vc_action_raw_decap_index(struct context *,
1721 const struct token *, const char *,
1722 unsigned int, void *, unsigned int);
1723 static int parse_vc_action_set_meta(struct context *ctx,
1724 const struct token *token, const char *str,
1725 unsigned int len, void *buf,
1727 static int parse_vc_action_sample(struct context *ctx,
1728 const struct token *token, const char *str,
1729 unsigned int len, void *buf,
1732 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
1733 const char *str, unsigned int len, void *buf,
1736 parse_vc_modify_field_op(struct context *ctx, const struct token *token,
1737 const char *str, unsigned int len, void *buf,
1740 parse_vc_modify_field_id(struct context *ctx, const struct token *token,
1741 const char *str, unsigned int len, void *buf,
1743 static int parse_destroy(struct context *, const struct token *,
1744 const char *, unsigned int,
1745 void *, unsigned int);
1746 static int parse_flush(struct context *, const struct token *,
1747 const char *, unsigned int,
1748 void *, unsigned int);
1749 static int parse_dump(struct context *, const struct token *,
1750 const char *, unsigned int,
1751 void *, unsigned int);
1752 static int parse_query(struct context *, const struct token *,
1753 const char *, unsigned int,
1754 void *, unsigned int);
1755 static int parse_action(struct context *, const struct token *,
1756 const char *, unsigned int,
1757 void *, unsigned int);
1758 static int parse_list(struct context *, const struct token *,
1759 const char *, unsigned int,
1760 void *, unsigned int);
1761 static int parse_aged(struct context *, const struct token *,
1762 const char *, unsigned int,
1763 void *, unsigned int);
1764 static int parse_isolate(struct context *, const struct token *,
1765 const char *, unsigned int,
1766 void *, unsigned int);
1767 static int parse_tunnel(struct context *, const struct token *,
1768 const char *, unsigned int,
1769 void *, unsigned int);
1770 static int parse_int(struct context *, const struct token *,
1771 const char *, unsigned int,
1772 void *, unsigned int);
1773 static int parse_prefix(struct context *, const struct token *,
1774 const char *, unsigned int,
1775 void *, unsigned int);
1776 static int parse_boolean(struct context *, const struct token *,
1777 const char *, unsigned int,
1778 void *, unsigned int);
1779 static int parse_string(struct context *, const struct token *,
1780 const char *, unsigned int,
1781 void *, unsigned int);
1782 static int parse_hex(struct context *ctx, const struct token *token,
1783 const char *str, unsigned int len,
1784 void *buf, unsigned int size);
1785 static int parse_string0(struct context *, const struct token *,
1786 const char *, unsigned int,
1787 void *, unsigned int);
1788 static int parse_mac_addr(struct context *, const struct token *,
1789 const char *, unsigned int,
1790 void *, unsigned int);
1791 static int parse_ipv4_addr(struct context *, const struct token *,
1792 const char *, unsigned int,
1793 void *, unsigned int);
1794 static int parse_ipv6_addr(struct context *, const struct token *,
1795 const char *, unsigned int,
1796 void *, unsigned int);
1797 static int parse_port(struct context *, const struct token *,
1798 const char *, unsigned int,
1799 void *, unsigned int);
1800 static int parse_sa(struct context *, const struct token *,
1801 const char *, unsigned int,
1802 void *, unsigned int);
1803 static int parse_sa_destroy(struct context *ctx, const struct token *token,
1804 const char *str, unsigned int len,
1805 void *buf, unsigned int size);
1806 static int parse_sa_id2ptr(struct context *ctx, const struct token *token,
1807 const char *str, unsigned int len, void *buf,
1809 static int comp_none(struct context *, const struct token *,
1810 unsigned int, char *, unsigned int);
1811 static int comp_boolean(struct context *, const struct token *,
1812 unsigned int, char *, unsigned int);
1813 static int comp_action(struct context *, const struct token *,
1814 unsigned int, char *, unsigned int);
1815 static int comp_port(struct context *, const struct token *,
1816 unsigned int, char *, unsigned int);
1817 static int comp_rule_id(struct context *, const struct token *,
1818 unsigned int, char *, unsigned int);
1819 static int comp_vc_action_rss_type(struct context *, const struct token *,
1820 unsigned int, char *, unsigned int);
1821 static int comp_vc_action_rss_queue(struct context *, const struct token *,
1822 unsigned int, char *, unsigned int);
1823 static int comp_set_raw_index(struct context *, const struct token *,
1824 unsigned int, char *, unsigned int);
1825 static int comp_set_sample_index(struct context *, const struct token *,
1826 unsigned int, char *, unsigned int);
1827 static int comp_set_modify_field_op(struct context *, const struct token *,
1828 unsigned int, char *, unsigned int);
1829 static int comp_set_modify_field_id(struct context *, const struct token *,
1830 unsigned int, char *, unsigned int);
1832 /** Token definitions. */
1833 static const struct token token_list[] = {
1834 /* Special tokens. */
1837 .help = "null entry, abused as the entry point",
1838 .next = NEXT(NEXT_ENTRY(FLOW)),
1843 .help = "command may end here",
1846 .name = "START_SET",
1847 .help = "null entry, abused as the entry point for set",
1848 .next = NEXT(NEXT_ENTRY(SET)),
1853 .help = "set command may end here",
1855 /* Common tokens. */
1859 .help = "integer value",
1864 .name = "{unsigned}",
1866 .help = "unsigned integer value",
1873 .help = "prefix length for bit-mask",
1874 .call = parse_prefix,
1878 .name = "{boolean}",
1880 .help = "any boolean value",
1881 .call = parse_boolean,
1882 .comp = comp_boolean,
1887 .help = "fixed string",
1888 .call = parse_string,
1894 .help = "fixed string",
1898 .name = "{file path}",
1900 .help = "file path",
1901 .call = parse_string0,
1905 .name = "{MAC address}",
1907 .help = "standard MAC address notation",
1908 .call = parse_mac_addr,
1912 .name = "{IPv4 address}",
1913 .type = "IPV4 ADDRESS",
1914 .help = "standard IPv4 address notation",
1915 .call = parse_ipv4_addr,
1919 .name = "{IPv6 address}",
1920 .type = "IPV6 ADDRESS",
1921 .help = "standard IPv6 address notation",
1922 .call = parse_ipv6_addr,
1926 .name = "{rule id}",
1928 .help = "rule identifier",
1930 .comp = comp_rule_id,
1933 .name = "{port_id}",
1935 .help = "port identifier",
1940 .name = "{group_id}",
1942 .help = "group identifier",
1946 [PRIORITY_LEVEL] = {
1949 .help = "priority level",
1953 [SHARED_ACTION_ID] = {
1954 .name = "{shared_action_id}",
1955 .type = "SHARED_ACTION_ID",
1956 .help = "shared action id",
1960 /* Top-level command. */
1963 .type = "{command} {port_id} [{arg} [...]]",
1964 .help = "manage ingress/egress flow rules",
1965 .next = NEXT(NEXT_ENTRY
1979 /* Top-level command. */
1981 .name = "shared_action",
1982 .type = "{command} {port_id} [{arg} [...]]",
1983 .help = "manage shared actions",
1984 .next = NEXT(next_sa_subcmd, NEXT_ENTRY(PORT_ID)),
1985 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1988 /* Sub-level commands. */
1989 [SHARED_ACTION_CREATE] = {
1991 .help = "create shared action",
1992 .next = NEXT(next_sa_create_attr),
1995 [SHARED_ACTION_UPDATE] = {
1997 .help = "update shared action",
1998 .next = NEXT(NEXT_ENTRY(SHARED_ACTION_SPEC),
1999 NEXT_ENTRY(SHARED_ACTION_ID)),
2000 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
2003 [SHARED_ACTION_DESTROY] = {
2005 .help = "destroy shared action",
2006 .next = NEXT(NEXT_ENTRY(SHARED_ACTION_DESTROY_ID)),
2007 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2008 .call = parse_sa_destroy,
2010 [SHARED_ACTION_QUERY] = {
2012 .help = "query shared action",
2013 .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(SHARED_ACTION_ID)),
2014 .args = ARGS(ARGS_ENTRY(struct buffer, args.sa.action_id)),
2019 .help = "check whether a flow rule can be created",
2020 .next = NEXT(next_vc_attr, NEXT_ENTRY(PORT_ID)),
2021 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2026 .help = "create a flow rule",
2027 .next = NEXT(next_vc_attr, NEXT_ENTRY(PORT_ID)),
2028 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2033 .help = "destroy specific flow rules",
2034 .next = NEXT(NEXT_ENTRY(DESTROY_RULE), NEXT_ENTRY(PORT_ID)),
2035 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2036 .call = parse_destroy,
2040 .help = "destroy all flow rules",
2041 .next = NEXT(NEXT_ENTRY(PORT_ID)),
2042 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2043 .call = parse_flush,
2047 .help = "dump single/all flow rules to file",
2048 .next = NEXT(next_dump_subcmd, NEXT_ENTRY(PORT_ID)),
2049 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2054 .help = "query an existing flow rule",
2055 .next = NEXT(NEXT_ENTRY(QUERY_ACTION),
2056 NEXT_ENTRY(RULE_ID),
2057 NEXT_ENTRY(PORT_ID)),
2058 .args = ARGS(ARGS_ENTRY(struct buffer, args.query.action.type),
2059 ARGS_ENTRY(struct buffer, args.query.rule),
2060 ARGS_ENTRY(struct buffer, port)),
2061 .call = parse_query,
2065 .help = "list existing flow rules",
2066 .next = NEXT(next_list_attr, NEXT_ENTRY(PORT_ID)),
2067 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2072 .help = "list and destroy aged flows",
2073 .next = NEXT(next_aged_attr, NEXT_ENTRY(PORT_ID)),
2074 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2079 .help = "restrict ingress traffic to the defined flow rules",
2080 .next = NEXT(NEXT_ENTRY(BOOLEAN),
2081 NEXT_ENTRY(PORT_ID)),
2082 .args = ARGS(ARGS_ENTRY(struct buffer, args.isolate.set),
2083 ARGS_ENTRY(struct buffer, port)),
2084 .call = parse_isolate,
2088 .help = "new tunnel API",
2089 .next = NEXT(NEXT_ENTRY
2090 (TUNNEL_CREATE, TUNNEL_LIST, TUNNEL_DESTROY)),
2091 .call = parse_tunnel,
2093 /* Tunnel arguments. */
2096 .help = "create new tunnel object",
2097 .next = NEXT(NEXT_ENTRY(TUNNEL_CREATE_TYPE),
2098 NEXT_ENTRY(PORT_ID)),
2099 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2100 .call = parse_tunnel,
2102 [TUNNEL_CREATE_TYPE] = {
2104 .help = "create new tunnel",
2105 .next = NEXT(NEXT_ENTRY(FILE_PATH)),
2106 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, type)),
2107 .call = parse_tunnel,
2109 [TUNNEL_DESTROY] = {
2111 .help = "destroy tunel",
2112 .next = NEXT(NEXT_ENTRY(TUNNEL_DESTROY_ID),
2113 NEXT_ENTRY(PORT_ID)),
2114 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2115 .call = parse_tunnel,
2117 [TUNNEL_DESTROY_ID] = {
2119 .help = "tunnel identifier to testroy",
2120 .next = NEXT(NEXT_ENTRY(UNSIGNED)),
2121 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2122 .call = parse_tunnel,
2126 .help = "list existing tunnels",
2127 .next = NEXT(NEXT_ENTRY(PORT_ID)),
2128 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2129 .call = parse_tunnel,
2131 /* Destroy arguments. */
2134 .help = "specify a rule identifier",
2135 .next = NEXT(next_destroy_attr, NEXT_ENTRY(RULE_ID)),
2136 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.destroy.rule)),
2137 .call = parse_destroy,
2139 /* Dump arguments. */
2143 .next = NEXT(next_dump_attr),
2144 .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file)),
2149 .help = "dump one rule",
2150 .next = NEXT(next_dump_attr, NEXT_ENTRY(RULE_ID)),
2151 .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file),
2152 ARGS_ENTRY(struct buffer, args.dump.rule)),
2155 /* Query arguments. */
2159 .help = "action to query, must be part of the rule",
2160 .call = parse_action,
2161 .comp = comp_action,
2163 /* List arguments. */
2166 .help = "specify a group",
2167 .next = NEXT(next_list_attr, NEXT_ENTRY(GROUP_ID)),
2168 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.list.group)),
2173 .help = "specify aged flows need be destroyed",
2177 /* Validate/create attributes. */
2180 .help = "specify a group",
2181 .next = NEXT(next_vc_attr, NEXT_ENTRY(GROUP_ID)),
2182 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, group)),
2187 .help = "specify a priority level",
2188 .next = NEXT(next_vc_attr, NEXT_ENTRY(PRIORITY_LEVEL)),
2189 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, priority)),
2194 .help = "affect rule to ingress",
2195 .next = NEXT(next_vc_attr),
2200 .help = "affect rule to egress",
2201 .next = NEXT(next_vc_attr),
2206 .help = "apply rule directly to endpoints found in pattern",
2207 .next = NEXT(next_vc_attr),
2211 .name = "tunnel_set",
2212 .help = "tunnel steer rule",
2213 .next = NEXT(next_vc_attr, NEXT_ENTRY(UNSIGNED)),
2214 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2218 .name = "tunnel_match",
2219 .help = "tunnel match rule",
2220 .next = NEXT(next_vc_attr, NEXT_ENTRY(UNSIGNED)),
2221 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2224 /* Validate/create pattern. */
2227 .help = "submit a list of pattern items",
2228 .next = NEXT(next_item),
2233 .help = "match value perfectly (with full bit-mask)",
2234 .call = parse_vc_spec,
2236 [ITEM_PARAM_SPEC] = {
2238 .help = "match value according to configured bit-mask",
2239 .call = parse_vc_spec,
2241 [ITEM_PARAM_LAST] = {
2243 .help = "specify upper bound to establish a range",
2244 .call = parse_vc_spec,
2246 [ITEM_PARAM_MASK] = {
2248 .help = "specify bit-mask with relevant bits set to one",
2249 .call = parse_vc_spec,
2251 [ITEM_PARAM_PREFIX] = {
2253 .help = "generate bit-mask from a prefix length",
2254 .call = parse_vc_spec,
2258 .help = "specify next pattern item",
2259 .next = NEXT(next_item),
2263 .help = "end list of pattern items",
2264 .priv = PRIV_ITEM(END, 0),
2265 .next = NEXT(NEXT_ENTRY(ACTIONS)),
2270 .help = "no-op pattern item",
2271 .priv = PRIV_ITEM(VOID, 0),
2272 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2277 .help = "perform actions when pattern does not match",
2278 .priv = PRIV_ITEM(INVERT, 0),
2279 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2284 .help = "match any protocol for the current layer",
2285 .priv = PRIV_ITEM(ANY, sizeof(struct rte_flow_item_any)),
2286 .next = NEXT(item_any),
2291 .help = "number of layers covered",
2292 .next = NEXT(item_any, NEXT_ENTRY(UNSIGNED), item_param),
2293 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_any, num)),
2297 .help = "match traffic from/to the physical function",
2298 .priv = PRIV_ITEM(PF, 0),
2299 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2304 .help = "match traffic from/to a virtual function ID",
2305 .priv = PRIV_ITEM(VF, sizeof(struct rte_flow_item_vf)),
2306 .next = NEXT(item_vf),
2312 .next = NEXT(item_vf, NEXT_ENTRY(UNSIGNED), item_param),
2313 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_vf, id)),
2317 .help = "match traffic from/to a specific physical port",
2318 .priv = PRIV_ITEM(PHY_PORT,
2319 sizeof(struct rte_flow_item_phy_port)),
2320 .next = NEXT(item_phy_port),
2323 [ITEM_PHY_PORT_INDEX] = {
2325 .help = "physical port index",
2326 .next = NEXT(item_phy_port, NEXT_ENTRY(UNSIGNED), item_param),
2327 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_phy_port, index)),
2331 .help = "match traffic from/to a given DPDK port ID",
2332 .priv = PRIV_ITEM(PORT_ID,
2333 sizeof(struct rte_flow_item_port_id)),
2334 .next = NEXT(item_port_id),
2337 [ITEM_PORT_ID_ID] = {
2339 .help = "DPDK port ID",
2340 .next = NEXT(item_port_id, NEXT_ENTRY(UNSIGNED), item_param),
2341 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port_id, id)),
2345 .help = "match traffic against value set in previously matched rule",
2346 .priv = PRIV_ITEM(MARK, sizeof(struct rte_flow_item_mark)),
2347 .next = NEXT(item_mark),
2352 .help = "Integer value to match against",
2353 .next = NEXT(item_mark, NEXT_ENTRY(UNSIGNED), item_param),
2354 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_mark, id)),
2358 .help = "match an arbitrary byte string",
2359 .priv = PRIV_ITEM(RAW, ITEM_RAW_SIZE),
2360 .next = NEXT(item_raw),
2363 [ITEM_RAW_RELATIVE] = {
2365 .help = "look for pattern after the previous item",
2366 .next = NEXT(item_raw, NEXT_ENTRY(BOOLEAN), item_param),
2367 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
2370 [ITEM_RAW_SEARCH] = {
2372 .help = "search pattern from offset (see also limit)",
2373 .next = NEXT(item_raw, NEXT_ENTRY(BOOLEAN), item_param),
2374 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
2377 [ITEM_RAW_OFFSET] = {
2379 .help = "absolute or relative offset for pattern",
2380 .next = NEXT(item_raw, NEXT_ENTRY(INTEGER), item_param),
2381 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, offset)),
2383 [ITEM_RAW_LIMIT] = {
2385 .help = "search area limit for start of pattern",
2386 .next = NEXT(item_raw, NEXT_ENTRY(UNSIGNED), item_param),
2387 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, limit)),
2389 [ITEM_RAW_PATTERN] = {
2391 .help = "byte string to look for",
2392 .next = NEXT(item_raw,
2394 NEXT_ENTRY(ITEM_PARAM_IS,
2397 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern),
2398 ARGS_ENTRY(struct rte_flow_item_raw, length),
2399 ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw),
2400 ITEM_RAW_PATTERN_SIZE)),
2404 .help = "match Ethernet header",
2405 .priv = PRIV_ITEM(ETH, sizeof(struct rte_flow_item_eth)),
2406 .next = NEXT(item_eth),
2411 .help = "destination MAC",
2412 .next = NEXT(item_eth, NEXT_ENTRY(MAC_ADDR), item_param),
2413 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, dst)),
2417 .help = "source MAC",
2418 .next = NEXT(item_eth, NEXT_ENTRY(MAC_ADDR), item_param),
2419 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, src)),
2423 .help = "EtherType",
2424 .next = NEXT(item_eth, NEXT_ENTRY(UNSIGNED), item_param),
2425 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, type)),
2427 [ITEM_ETH_HAS_VLAN] = {
2429 .help = "packet header contains VLAN",
2430 .next = NEXT(item_eth, NEXT_ENTRY(UNSIGNED), item_param),
2431 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_eth,
2436 .help = "match 802.1Q/ad VLAN tag",
2437 .priv = PRIV_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)),
2438 .next = NEXT(item_vlan),
2443 .help = "tag control information",
2444 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2445 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, tci)),
2449 .help = "priority code point",
2450 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2451 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2456 .help = "drop eligible indicator",
2457 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2458 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2463 .help = "VLAN identifier",
2464 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2465 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2468 [ITEM_VLAN_INNER_TYPE] = {
2469 .name = "inner_type",
2470 .help = "inner EtherType",
2471 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2472 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan,
2475 [ITEM_VLAN_HAS_MORE_VLAN] = {
2476 .name = "has_more_vlan",
2477 .help = "packet header contains another VLAN",
2478 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2479 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vlan,
2484 .help = "match IPv4 header",
2485 .priv = PRIV_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)),
2486 .next = NEXT(item_ipv4),
2491 .help = "type of service",
2492 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2493 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2494 hdr.type_of_service)),
2496 [ITEM_IPV4_FRAGMENT_OFFSET] = {
2497 .name = "fragment_offset",
2498 .help = "fragmentation flags and fragment offset",
2499 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2500 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2501 hdr.fragment_offset)),
2505 .help = "time to live",
2506 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2507 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2510 [ITEM_IPV4_PROTO] = {
2512 .help = "next protocol ID",
2513 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2514 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2515 hdr.next_proto_id)),
2519 .help = "source address",
2520 .next = NEXT(item_ipv4, NEXT_ENTRY(IPV4_ADDR), item_param),
2521 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2526 .help = "destination address",
2527 .next = NEXT(item_ipv4, NEXT_ENTRY(IPV4_ADDR), item_param),
2528 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2533 .help = "match IPv6 header",
2534 .priv = PRIV_ITEM(IPV6, sizeof(struct rte_flow_item_ipv6)),
2535 .next = NEXT(item_ipv6),
2540 .help = "traffic class",
2541 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2542 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2544 "\x0f\xf0\x00\x00")),
2546 [ITEM_IPV6_FLOW] = {
2548 .help = "flow label",
2549 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2550 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2552 "\x00\x0f\xff\xff")),
2554 [ITEM_IPV6_PROTO] = {
2556 .help = "protocol (next header)",
2557 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2558 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2563 .help = "hop limit",
2564 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2565 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2570 .help = "source address",
2571 .next = NEXT(item_ipv6, NEXT_ENTRY(IPV6_ADDR), item_param),
2572 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2577 .help = "destination address",
2578 .next = NEXT(item_ipv6, NEXT_ENTRY(IPV6_ADDR), item_param),
2579 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2582 [ITEM_IPV6_HAS_FRAG_EXT] = {
2583 .name = "has_frag_ext",
2584 .help = "fragment packet attribute",
2585 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2586 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_ipv6,
2591 .help = "match ICMP header",
2592 .priv = PRIV_ITEM(ICMP, sizeof(struct rte_flow_item_icmp)),
2593 .next = NEXT(item_icmp),
2596 [ITEM_ICMP_TYPE] = {
2598 .help = "ICMP packet type",
2599 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2600 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2603 [ITEM_ICMP_CODE] = {
2605 .help = "ICMP packet code",
2606 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2607 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2610 [ITEM_ICMP_IDENT] = {
2612 .help = "ICMP packet identifier",
2613 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2614 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2619 .help = "ICMP packet sequence number",
2620 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2621 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2626 .help = "match UDP header",
2627 .priv = PRIV_ITEM(UDP, sizeof(struct rte_flow_item_udp)),
2628 .next = NEXT(item_udp),
2633 .help = "UDP source port",
2634 .next = NEXT(item_udp, NEXT_ENTRY(UNSIGNED), item_param),
2635 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2640 .help = "UDP destination port",
2641 .next = NEXT(item_udp, NEXT_ENTRY(UNSIGNED), item_param),
2642 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2647 .help = "match TCP header",
2648 .priv = PRIV_ITEM(TCP, sizeof(struct rte_flow_item_tcp)),
2649 .next = NEXT(item_tcp),
2654 .help = "TCP source port",
2655 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2656 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2661 .help = "TCP destination port",
2662 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2663 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2666 [ITEM_TCP_FLAGS] = {
2668 .help = "TCP flags",
2669 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2670 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2675 .help = "match SCTP header",
2676 .priv = PRIV_ITEM(SCTP, sizeof(struct rte_flow_item_sctp)),
2677 .next = NEXT(item_sctp),
2682 .help = "SCTP source port",
2683 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2684 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2689 .help = "SCTP destination port",
2690 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2691 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2696 .help = "validation tag",
2697 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2698 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2701 [ITEM_SCTP_CKSUM] = {
2704 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2705 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2710 .help = "match VXLAN header",
2711 .priv = PRIV_ITEM(VXLAN, sizeof(struct rte_flow_item_vxlan)),
2712 .next = NEXT(item_vxlan),
2715 [ITEM_VXLAN_VNI] = {
2717 .help = "VXLAN identifier",
2718 .next = NEXT(item_vxlan, NEXT_ENTRY(UNSIGNED), item_param),
2719 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan, vni)),
2723 .help = "match E-Tag header",
2724 .priv = PRIV_ITEM(E_TAG, sizeof(struct rte_flow_item_e_tag)),
2725 .next = NEXT(item_e_tag),
2728 [ITEM_E_TAG_GRP_ECID_B] = {
2729 .name = "grp_ecid_b",
2730 .help = "GRP and E-CID base",
2731 .next = NEXT(item_e_tag, NEXT_ENTRY(UNSIGNED), item_param),
2732 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_e_tag,
2738 .help = "match NVGRE header",
2739 .priv = PRIV_ITEM(NVGRE, sizeof(struct rte_flow_item_nvgre)),
2740 .next = NEXT(item_nvgre),
2743 [ITEM_NVGRE_TNI] = {
2745 .help = "virtual subnet ID",
2746 .next = NEXT(item_nvgre, NEXT_ENTRY(UNSIGNED), item_param),
2747 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_nvgre, tni)),
2751 .help = "match MPLS header",
2752 .priv = PRIV_ITEM(MPLS, sizeof(struct rte_flow_item_mpls)),
2753 .next = NEXT(item_mpls),
2756 [ITEM_MPLS_LABEL] = {
2758 .help = "MPLS label",
2759 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2760 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2766 .help = "MPLS Traffic Class",
2767 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2768 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2774 .help = "MPLS Bottom-of-Stack",
2775 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2776 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2782 .help = "match GRE header",
2783 .priv = PRIV_ITEM(GRE, sizeof(struct rte_flow_item_gre)),
2784 .next = NEXT(item_gre),
2787 [ITEM_GRE_PROTO] = {
2789 .help = "GRE protocol type",
2790 .next = NEXT(item_gre, NEXT_ENTRY(UNSIGNED), item_param),
2791 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2794 [ITEM_GRE_C_RSVD0_VER] = {
2795 .name = "c_rsvd0_ver",
2797 "checksum (1b), undefined (1b), key bit (1b),"
2798 " sequence number (1b), reserved 0 (9b),"
2800 .next = NEXT(item_gre, NEXT_ENTRY(UNSIGNED), item_param),
2801 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2804 [ITEM_GRE_C_BIT] = {
2806 .help = "checksum bit (C)",
2807 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2808 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2810 "\x80\x00\x00\x00")),
2812 [ITEM_GRE_S_BIT] = {
2814 .help = "sequence number bit (S)",
2815 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2816 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2818 "\x10\x00\x00\x00")),
2820 [ITEM_GRE_K_BIT] = {
2822 .help = "key bit (K)",
2823 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2824 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2826 "\x20\x00\x00\x00")),
2830 .help = "fuzzy pattern match, expect faster than default",
2831 .priv = PRIV_ITEM(FUZZY,
2832 sizeof(struct rte_flow_item_fuzzy)),
2833 .next = NEXT(item_fuzzy),
2836 [ITEM_FUZZY_THRESH] = {
2838 .help = "match accuracy threshold",
2839 .next = NEXT(item_fuzzy, NEXT_ENTRY(UNSIGNED), item_param),
2840 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_fuzzy,
2845 .help = "match GTP header",
2846 .priv = PRIV_ITEM(GTP, sizeof(struct rte_flow_item_gtp)),
2847 .next = NEXT(item_gtp),
2850 [ITEM_GTP_FLAGS] = {
2851 .name = "v_pt_rsv_flags",
2852 .help = "GTP flags",
2853 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2854 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp,
2857 [ITEM_GTP_MSG_TYPE] = {
2859 .help = "GTP message type",
2860 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2861 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp, msg_type)),
2865 .help = "tunnel endpoint identifier",
2866 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2867 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp, teid)),
2871 .help = "match GTP header",
2872 .priv = PRIV_ITEM(GTPC, sizeof(struct rte_flow_item_gtp)),
2873 .next = NEXT(item_gtp),
2878 .help = "match GTP header",
2879 .priv = PRIV_ITEM(GTPU, sizeof(struct rte_flow_item_gtp)),
2880 .next = NEXT(item_gtp),
2885 .help = "match GENEVE header",
2886 .priv = PRIV_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)),
2887 .next = NEXT(item_geneve),
2890 [ITEM_GENEVE_VNI] = {
2892 .help = "virtual network identifier",
2893 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2894 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve, vni)),
2896 [ITEM_GENEVE_PROTO] = {
2898 .help = "GENEVE protocol type",
2899 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2900 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve,
2903 [ITEM_GENEVE_OPTLEN] = {
2905 .help = "GENEVE options length in dwords",
2906 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2907 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_geneve,
2908 ver_opt_len_o_c_rsvd0,
2911 [ITEM_VXLAN_GPE] = {
2912 .name = "vxlan-gpe",
2913 .help = "match VXLAN-GPE header",
2914 .priv = PRIV_ITEM(VXLAN_GPE,
2915 sizeof(struct rte_flow_item_vxlan_gpe)),
2916 .next = NEXT(item_vxlan_gpe),
2919 [ITEM_VXLAN_GPE_VNI] = {
2921 .help = "VXLAN-GPE identifier",
2922 .next = NEXT(item_vxlan_gpe, NEXT_ENTRY(UNSIGNED), item_param),
2923 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
2926 [ITEM_ARP_ETH_IPV4] = {
2927 .name = "arp_eth_ipv4",
2928 .help = "match ARP header for Ethernet/IPv4",
2929 .priv = PRIV_ITEM(ARP_ETH_IPV4,
2930 sizeof(struct rte_flow_item_arp_eth_ipv4)),
2931 .next = NEXT(item_arp_eth_ipv4),
2934 [ITEM_ARP_ETH_IPV4_SHA] = {
2936 .help = "sender hardware address",
2937 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(MAC_ADDR),
2939 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2942 [ITEM_ARP_ETH_IPV4_SPA] = {
2944 .help = "sender IPv4 address",
2945 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(IPV4_ADDR),
2947 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2950 [ITEM_ARP_ETH_IPV4_THA] = {
2952 .help = "target hardware address",
2953 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(MAC_ADDR),
2955 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2958 [ITEM_ARP_ETH_IPV4_TPA] = {
2960 .help = "target IPv4 address",
2961 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(IPV4_ADDR),
2963 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2968 .help = "match presence of any IPv6 extension header",
2969 .priv = PRIV_ITEM(IPV6_EXT,
2970 sizeof(struct rte_flow_item_ipv6_ext)),
2971 .next = NEXT(item_ipv6_ext),
2974 [ITEM_IPV6_EXT_NEXT_HDR] = {
2976 .help = "next header",
2977 .next = NEXT(item_ipv6_ext, NEXT_ENTRY(UNSIGNED), item_param),
2978 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_ext,
2981 [ITEM_IPV6_FRAG_EXT] = {
2982 .name = "ipv6_frag_ext",
2983 .help = "match presence of IPv6 fragment extension header",
2984 .priv = PRIV_ITEM(IPV6_FRAG_EXT,
2985 sizeof(struct rte_flow_item_ipv6_frag_ext)),
2986 .next = NEXT(item_ipv6_frag_ext),
2989 [ITEM_IPV6_FRAG_EXT_NEXT_HDR] = {
2991 .help = "next header",
2992 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(UNSIGNED),
2994 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ipv6_frag_ext,
2997 [ITEM_IPV6_FRAG_EXT_FRAG_DATA] = {
2998 .name = "frag_data",
2999 .help = "Fragment flags and offset",
3000 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(UNSIGNED),
3002 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_frag_ext,
3007 .help = "match any ICMPv6 header",
3008 .priv = PRIV_ITEM(ICMP6, sizeof(struct rte_flow_item_icmp6)),
3009 .next = NEXT(item_icmp6),
3012 [ITEM_ICMP6_TYPE] = {
3014 .help = "ICMPv6 type",
3015 .next = NEXT(item_icmp6, NEXT_ENTRY(UNSIGNED), item_param),
3016 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
3019 [ITEM_ICMP6_CODE] = {
3021 .help = "ICMPv6 code",
3022 .next = NEXT(item_icmp6, NEXT_ENTRY(UNSIGNED), item_param),
3023 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
3026 [ITEM_ICMP6_ND_NS] = {
3027 .name = "icmp6_nd_ns",
3028 .help = "match ICMPv6 neighbor discovery solicitation",
3029 .priv = PRIV_ITEM(ICMP6_ND_NS,
3030 sizeof(struct rte_flow_item_icmp6_nd_ns)),
3031 .next = NEXT(item_icmp6_nd_ns),
3034 [ITEM_ICMP6_ND_NS_TARGET_ADDR] = {
3035 .name = "target_addr",
3036 .help = "target address",
3037 .next = NEXT(item_icmp6_nd_ns, NEXT_ENTRY(IPV6_ADDR),
3039 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_ns,
3042 [ITEM_ICMP6_ND_NA] = {
3043 .name = "icmp6_nd_na",
3044 .help = "match ICMPv6 neighbor discovery advertisement",
3045 .priv = PRIV_ITEM(ICMP6_ND_NA,
3046 sizeof(struct rte_flow_item_icmp6_nd_na)),
3047 .next = NEXT(item_icmp6_nd_na),
3050 [ITEM_ICMP6_ND_NA_TARGET_ADDR] = {
3051 .name = "target_addr",
3052 .help = "target address",
3053 .next = NEXT(item_icmp6_nd_na, NEXT_ENTRY(IPV6_ADDR),
3055 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_na,
3058 [ITEM_ICMP6_ND_OPT] = {
3059 .name = "icmp6_nd_opt",
3060 .help = "match presence of any ICMPv6 neighbor discovery"
3062 .priv = PRIV_ITEM(ICMP6_ND_OPT,
3063 sizeof(struct rte_flow_item_icmp6_nd_opt)),
3064 .next = NEXT(item_icmp6_nd_opt),
3067 [ITEM_ICMP6_ND_OPT_TYPE] = {
3069 .help = "ND option type",
3070 .next = NEXT(item_icmp6_nd_opt, NEXT_ENTRY(UNSIGNED),
3072 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_opt,
3075 [ITEM_ICMP6_ND_OPT_SLA_ETH] = {
3076 .name = "icmp6_nd_opt_sla_eth",
3077 .help = "match ICMPv6 neighbor discovery source Ethernet"
3078 " link-layer address option",
3080 (ICMP6_ND_OPT_SLA_ETH,
3081 sizeof(struct rte_flow_item_icmp6_nd_opt_sla_eth)),
3082 .next = NEXT(item_icmp6_nd_opt_sla_eth),
3085 [ITEM_ICMP6_ND_OPT_SLA_ETH_SLA] = {
3087 .help = "source Ethernet LLA",
3088 .next = NEXT(item_icmp6_nd_opt_sla_eth, NEXT_ENTRY(MAC_ADDR),
3090 .args = ARGS(ARGS_ENTRY_HTON
3091 (struct rte_flow_item_icmp6_nd_opt_sla_eth, sla)),
3093 [ITEM_ICMP6_ND_OPT_TLA_ETH] = {
3094 .name = "icmp6_nd_opt_tla_eth",
3095 .help = "match ICMPv6 neighbor discovery target Ethernet"
3096 " link-layer address option",
3098 (ICMP6_ND_OPT_TLA_ETH,
3099 sizeof(struct rte_flow_item_icmp6_nd_opt_tla_eth)),
3100 .next = NEXT(item_icmp6_nd_opt_tla_eth),
3103 [ITEM_ICMP6_ND_OPT_TLA_ETH_TLA] = {
3105 .help = "target Ethernet LLA",
3106 .next = NEXT(item_icmp6_nd_opt_tla_eth, NEXT_ENTRY(MAC_ADDR),
3108 .args = ARGS(ARGS_ENTRY_HTON
3109 (struct rte_flow_item_icmp6_nd_opt_tla_eth, tla)),
3113 .help = "match metadata header",
3114 .priv = PRIV_ITEM(META, sizeof(struct rte_flow_item_meta)),
3115 .next = NEXT(item_meta),
3118 [ITEM_META_DATA] = {
3120 .help = "metadata value",
3121 .next = NEXT(item_meta, NEXT_ENTRY(UNSIGNED), item_param),
3122 .args = ARGS(ARGS_ENTRY_MASK(struct rte_flow_item_meta,
3123 data, "\xff\xff\xff\xff")),
3127 .help = "match GRE key",
3128 .priv = PRIV_ITEM(GRE_KEY, sizeof(rte_be32_t)),
3129 .next = NEXT(item_gre_key),
3132 [ITEM_GRE_KEY_VALUE] = {
3134 .help = "key value",
3135 .next = NEXT(item_gre_key, NEXT_ENTRY(UNSIGNED), item_param),
3136 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3140 .help = "match GTP extension header with type 0x85",
3141 .priv = PRIV_ITEM(GTP_PSC,
3142 sizeof(struct rte_flow_item_gtp_psc)),
3143 .next = NEXT(item_gtp_psc),
3146 [ITEM_GTP_PSC_QFI] = {
3148 .help = "QoS flow identifier",
3149 .next = NEXT(item_gtp_psc, NEXT_ENTRY(UNSIGNED), item_param),
3150 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
3153 [ITEM_GTP_PSC_PDU_T] = {
3156 .next = NEXT(item_gtp_psc, NEXT_ENTRY(UNSIGNED), item_param),
3157 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
3162 .help = "match PPPoE session header",
3163 .priv = PRIV_ITEM(PPPOES, sizeof(struct rte_flow_item_pppoe)),
3164 .next = NEXT(item_pppoes),
3169 .help = "match PPPoE discovery header",
3170 .priv = PRIV_ITEM(PPPOED, sizeof(struct rte_flow_item_pppoe)),
3171 .next = NEXT(item_pppoed),
3174 [ITEM_PPPOE_SEID] = {
3176 .help = "session identifier",
3177 .next = NEXT(item_pppoes, NEXT_ENTRY(UNSIGNED), item_param),
3178 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pppoe,
3181 [ITEM_PPPOE_PROTO_ID] = {
3182 .name = "pppoe_proto_id",
3183 .help = "match PPPoE session protocol identifier",
3184 .priv = PRIV_ITEM(PPPOE_PROTO_ID,
3185 sizeof(struct rte_flow_item_pppoe_proto_id)),
3186 .next = NEXT(item_pppoe_proto_id, NEXT_ENTRY(UNSIGNED),
3188 .args = ARGS(ARGS_ENTRY_HTON
3189 (struct rte_flow_item_pppoe_proto_id, proto_id)),
3194 .help = "matches higig2 header",
3195 .priv = PRIV_ITEM(HIGIG2,
3196 sizeof(struct rte_flow_item_higig2_hdr)),
3197 .next = NEXT(item_higig2),
3200 [ITEM_HIGIG2_CLASSIFICATION] = {
3201 .name = "classification",
3202 .help = "matches classification of higig2 header",
3203 .next = NEXT(item_higig2, NEXT_ENTRY(UNSIGNED), item_param),
3204 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
3205 hdr.ppt1.classification)),
3207 [ITEM_HIGIG2_VID] = {
3209 .help = "matches vid of higig2 header",
3210 .next = NEXT(item_higig2, NEXT_ENTRY(UNSIGNED), item_param),
3211 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
3216 .help = "match tag value",
3217 .priv = PRIV_ITEM(TAG, sizeof(struct rte_flow_item_tag)),
3218 .next = NEXT(item_tag),
3223 .help = "tag value to match",
3224 .next = NEXT(item_tag, NEXT_ENTRY(UNSIGNED), item_param),
3225 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, data)),
3227 [ITEM_TAG_INDEX] = {
3229 .help = "index of tag array to match",
3230 .next = NEXT(item_tag, NEXT_ENTRY(UNSIGNED),
3231 NEXT_ENTRY(ITEM_PARAM_IS)),
3232 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, index)),
3234 [ITEM_L2TPV3OIP] = {
3235 .name = "l2tpv3oip",
3236 .help = "match L2TPv3 over IP header",
3237 .priv = PRIV_ITEM(L2TPV3OIP,
3238 sizeof(struct rte_flow_item_l2tpv3oip)),
3239 .next = NEXT(item_l2tpv3oip),
3242 [ITEM_L2TPV3OIP_SESSION_ID] = {
3243 .name = "session_id",
3244 .help = "session identifier",
3245 .next = NEXT(item_l2tpv3oip, NEXT_ENTRY(UNSIGNED), item_param),
3246 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv3oip,
3251 .help = "match ESP header",
3252 .priv = PRIV_ITEM(ESP, sizeof(struct rte_flow_item_esp)),
3253 .next = NEXT(item_esp),
3258 .help = "security policy index",
3259 .next = NEXT(item_esp, NEXT_ENTRY(UNSIGNED), item_param),
3260 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_esp,
3265 .help = "match AH header",
3266 .priv = PRIV_ITEM(AH, sizeof(struct rte_flow_item_ah)),
3267 .next = NEXT(item_ah),
3272 .help = "security parameters index",
3273 .next = NEXT(item_ah, NEXT_ENTRY(UNSIGNED), item_param),
3274 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ah, spi)),
3278 .help = "match pfcp header",
3279 .priv = PRIV_ITEM(PFCP, sizeof(struct rte_flow_item_pfcp)),
3280 .next = NEXT(item_pfcp),
3283 [ITEM_PFCP_S_FIELD] = {
3286 .next = NEXT(item_pfcp, NEXT_ENTRY(UNSIGNED), item_param),
3287 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp,
3290 [ITEM_PFCP_SEID] = {
3292 .help = "session endpoint identifier",
3293 .next = NEXT(item_pfcp, NEXT_ENTRY(UNSIGNED), item_param),
3294 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp, seid)),
3298 .help = "match eCPRI header",
3299 .priv = PRIV_ITEM(ECPRI, sizeof(struct rte_flow_item_ecpri)),
3300 .next = NEXT(item_ecpri),
3303 [ITEM_ECPRI_COMMON] = {
3305 .help = "eCPRI common header",
3306 .next = NEXT(item_ecpri_common),
3308 [ITEM_ECPRI_COMMON_TYPE] = {
3310 .help = "type of common header",
3311 .next = NEXT(item_ecpri_common_type),
3312 .args = ARGS(ARG_ENTRY_HTON(struct rte_flow_item_ecpri)),
3314 [ITEM_ECPRI_COMMON_TYPE_IQ_DATA] = {
3316 .help = "Type #0: IQ Data",
3317 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
3319 .call = parse_vc_item_ecpri_type,
3321 [ITEM_ECPRI_MSG_IQ_DATA_PCID] = {
3323 .help = "Physical Channel ID",
3324 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
3325 ITEM_ECPRI_COMMON, ITEM_NEXT),
3326 NEXT_ENTRY(UNSIGNED), item_param),
3327 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3330 [ITEM_ECPRI_COMMON_TYPE_RTC_CTRL] = {
3332 .help = "Type #2: Real-Time Control Data",
3333 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
3335 .call = parse_vc_item_ecpri_type,
3337 [ITEM_ECPRI_MSG_RTC_CTRL_RTCID] = {
3339 .help = "Real-Time Control Data ID",
3340 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
3341 ITEM_ECPRI_COMMON, ITEM_NEXT),
3342 NEXT_ENTRY(UNSIGNED), item_param),
3343 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3346 [ITEM_ECPRI_COMMON_TYPE_DLY_MSR] = {
3347 .name = "delay_measure",
3348 .help = "Type #5: One-Way Delay Measurement",
3349 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
3351 .call = parse_vc_item_ecpri_type,
3353 [ITEM_ECPRI_MSG_DLY_MSR_MSRID] = {
3355 .help = "Measurement ID",
3356 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
3357 ITEM_ECPRI_COMMON, ITEM_NEXT),
3358 NEXT_ENTRY(UNSIGNED), item_param),
3359 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3362 [ITEM_GENEVE_OPT] = {
3363 .name = "geneve-opt",
3364 .help = "GENEVE header option",
3365 .priv = PRIV_ITEM(GENEVE_OPT,
3366 sizeof(struct rte_flow_item_geneve_opt) +
3367 ITEM_GENEVE_OPT_DATA_SIZE),
3368 .next = NEXT(item_geneve_opt),
3371 [ITEM_GENEVE_OPT_CLASS] = {
3373 .help = "GENEVE option class",
3374 .next = NEXT(item_geneve_opt, NEXT_ENTRY(UNSIGNED), item_param),
3375 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve_opt,
3378 [ITEM_GENEVE_OPT_TYPE] = {
3380 .help = "GENEVE option type",
3381 .next = NEXT(item_geneve_opt, NEXT_ENTRY(UNSIGNED), item_param),
3382 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt,
3385 [ITEM_GENEVE_OPT_LENGTH] = {
3387 .help = "GENEVE option data length (in 32b words)",
3388 .next = NEXT(item_geneve_opt, NEXT_ENTRY(UNSIGNED), item_param),
3389 .args = ARGS(ARGS_ENTRY_BOUNDED(
3390 struct rte_flow_item_geneve_opt, option_len,
3393 [ITEM_GENEVE_OPT_DATA] = {
3395 .help = "GENEVE option data pattern",
3396 .next = NEXT(item_geneve_opt, NEXT_ENTRY(HEX), item_param),
3397 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt, data),
3398 ARGS_ENTRY_ARB(0, 0),
3400 (sizeof(struct rte_flow_item_geneve_opt),
3401 ITEM_GENEVE_OPT_DATA_SIZE)),
3403 /* Validate/create actions. */
3406 .help = "submit a list of associated actions",
3407 .next = NEXT(next_action),
3412 .help = "specify next action",
3413 .next = NEXT(next_action),
3417 .help = "end list of actions",
3418 .priv = PRIV_ACTION(END, 0),
3423 .help = "no-op action",
3424 .priv = PRIV_ACTION(VOID, 0),
3425 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3428 [ACTION_PASSTHRU] = {
3430 .help = "let subsequent rule process matched packets",
3431 .priv = PRIV_ACTION(PASSTHRU, 0),
3432 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3437 .help = "redirect traffic to a given group",
3438 .priv = PRIV_ACTION(JUMP, sizeof(struct rte_flow_action_jump)),
3439 .next = NEXT(action_jump),
3442 [ACTION_JUMP_GROUP] = {
3444 .help = "group to redirect traffic to",
3445 .next = NEXT(action_jump, NEXT_ENTRY(UNSIGNED)),
3446 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump, group)),
3447 .call = parse_vc_conf,
3451 .help = "attach 32 bit value to packets",
3452 .priv = PRIV_ACTION(MARK, sizeof(struct rte_flow_action_mark)),
3453 .next = NEXT(action_mark),
3456 [ACTION_MARK_ID] = {
3458 .help = "32 bit value to return with packets",
3459 .next = NEXT(action_mark, NEXT_ENTRY(UNSIGNED)),
3460 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_mark, id)),
3461 .call = parse_vc_conf,
3465 .help = "flag packets",
3466 .priv = PRIV_ACTION(FLAG, 0),
3467 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3472 .help = "assign packets to a given queue index",
3473 .priv = PRIV_ACTION(QUEUE,
3474 sizeof(struct rte_flow_action_queue)),
3475 .next = NEXT(action_queue),
3478 [ACTION_QUEUE_INDEX] = {
3480 .help = "queue index to use",
3481 .next = NEXT(action_queue, NEXT_ENTRY(UNSIGNED)),
3482 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_queue, index)),
3483 .call = parse_vc_conf,
3487 .help = "drop packets (note: passthru has priority)",
3488 .priv = PRIV_ACTION(DROP, 0),
3489 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3494 .help = "enable counters for this rule",
3495 .priv = PRIV_ACTION(COUNT,
3496 sizeof(struct rte_flow_action_count)),
3497 .next = NEXT(action_count),
3500 [ACTION_COUNT_ID] = {
3501 .name = "identifier",
3502 .help = "counter identifier to use",
3503 .next = NEXT(action_count, NEXT_ENTRY(UNSIGNED)),
3504 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_count, id)),
3505 .call = parse_vc_conf,
3507 [ACTION_COUNT_SHARED] = {
3509 .help = "shared counter",
3510 .next = NEXT(action_count, NEXT_ENTRY(BOOLEAN)),
3511 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_count,
3513 .call = parse_vc_conf,
3517 .help = "spread packets among several queues",
3518 .priv = PRIV_ACTION(RSS, sizeof(struct action_rss_data)),
3519 .next = NEXT(action_rss),
3520 .call = parse_vc_action_rss,
3522 [ACTION_RSS_FUNC] = {
3524 .help = "RSS hash function to apply",
3525 .next = NEXT(action_rss,
3526 NEXT_ENTRY(ACTION_RSS_FUNC_DEFAULT,
3527 ACTION_RSS_FUNC_TOEPLITZ,
3528 ACTION_RSS_FUNC_SIMPLE_XOR,
3529 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ)),
3531 [ACTION_RSS_FUNC_DEFAULT] = {
3533 .help = "default hash function",
3534 .call = parse_vc_action_rss_func,
3536 [ACTION_RSS_FUNC_TOEPLITZ] = {
3538 .help = "Toeplitz hash function",
3539 .call = parse_vc_action_rss_func,
3541 [ACTION_RSS_FUNC_SIMPLE_XOR] = {
3542 .name = "simple_xor",
3543 .help = "simple XOR hash function",
3544 .call = parse_vc_action_rss_func,
3546 [ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ] = {
3547 .name = "symmetric_toeplitz",
3548 .help = "Symmetric Toeplitz hash function",
3549 .call = parse_vc_action_rss_func,
3551 [ACTION_RSS_LEVEL] = {
3553 .help = "encapsulation level for \"types\"",
3554 .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
3555 .args = ARGS(ARGS_ENTRY_ARB
3556 (offsetof(struct action_rss_data, conf) +
3557 offsetof(struct rte_flow_action_rss, level),
3558 sizeof(((struct rte_flow_action_rss *)0)->
3561 [ACTION_RSS_TYPES] = {
3563 .help = "specific RSS hash types",
3564 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)),
3566 [ACTION_RSS_TYPE] = {
3568 .help = "RSS hash type",
3569 .call = parse_vc_action_rss_type,
3570 .comp = comp_vc_action_rss_type,
3572 [ACTION_RSS_KEY] = {
3574 .help = "RSS hash key",
3575 .next = NEXT(action_rss, NEXT_ENTRY(HEX)),
3576 .args = ARGS(ARGS_ENTRY_ARB
3577 (offsetof(struct action_rss_data, conf) +
3578 offsetof(struct rte_flow_action_rss, key),
3579 sizeof(((struct rte_flow_action_rss *)0)->key)),
3581 (offsetof(struct action_rss_data, conf) +
3582 offsetof(struct rte_flow_action_rss, key_len),
3583 sizeof(((struct rte_flow_action_rss *)0)->
3585 ARGS_ENTRY(struct action_rss_data, key)),
3587 [ACTION_RSS_KEY_LEN] = {
3589 .help = "RSS hash key length in bytes",
3590 .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
3591 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
3592 (offsetof(struct action_rss_data, conf) +
3593 offsetof(struct rte_flow_action_rss, key_len),
3594 sizeof(((struct rte_flow_action_rss *)0)->
3597 RSS_HASH_KEY_LENGTH)),
3599 [ACTION_RSS_QUEUES] = {
3601 .help = "queue indices to use",
3602 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_QUEUE)),
3603 .call = parse_vc_conf,
3605 [ACTION_RSS_QUEUE] = {
3607 .help = "queue index",
3608 .call = parse_vc_action_rss_queue,
3609 .comp = comp_vc_action_rss_queue,
3613 .help = "direct traffic to physical function",
3614 .priv = PRIV_ACTION(PF, 0),
3615 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3620 .help = "direct traffic to a virtual function ID",
3621 .priv = PRIV_ACTION(VF, sizeof(struct rte_flow_action_vf)),
3622 .next = NEXT(action_vf),
3625 [ACTION_VF_ORIGINAL] = {
3627 .help = "use original VF ID if possible",
3628 .next = NEXT(action_vf, NEXT_ENTRY(BOOLEAN)),
3629 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_vf,
3631 .call = parse_vc_conf,
3636 .next = NEXT(action_vf, NEXT_ENTRY(UNSIGNED)),
3637 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)),
3638 .call = parse_vc_conf,
3640 [ACTION_PHY_PORT] = {
3642 .help = "direct packets to physical port index",
3643 .priv = PRIV_ACTION(PHY_PORT,
3644 sizeof(struct rte_flow_action_phy_port)),
3645 .next = NEXT(action_phy_port),
3648 [ACTION_PHY_PORT_ORIGINAL] = {
3650 .help = "use original port index if possible",
3651 .next = NEXT(action_phy_port, NEXT_ENTRY(BOOLEAN)),
3652 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_phy_port,
3654 .call = parse_vc_conf,
3656 [ACTION_PHY_PORT_INDEX] = {
3658 .help = "physical port index",
3659 .next = NEXT(action_phy_port, NEXT_ENTRY(UNSIGNED)),
3660 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_phy_port,
3662 .call = parse_vc_conf,
3664 [ACTION_PORT_ID] = {
3666 .help = "direct matching traffic to a given DPDK port ID",
3667 .priv = PRIV_ACTION(PORT_ID,
3668 sizeof(struct rte_flow_action_port_id)),
3669 .next = NEXT(action_port_id),
3672 [ACTION_PORT_ID_ORIGINAL] = {
3674 .help = "use original DPDK port ID if possible",
3675 .next = NEXT(action_port_id, NEXT_ENTRY(BOOLEAN)),
3676 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_port_id,
3678 .call = parse_vc_conf,
3680 [ACTION_PORT_ID_ID] = {
3682 .help = "DPDK port ID",
3683 .next = NEXT(action_port_id, NEXT_ENTRY(UNSIGNED)),
3684 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_port_id, id)),
3685 .call = parse_vc_conf,
3689 .help = "meter the directed packets at given id",
3690 .priv = PRIV_ACTION(METER,
3691 sizeof(struct rte_flow_action_meter)),
3692 .next = NEXT(action_meter),
3695 [ACTION_METER_ID] = {
3697 .help = "meter id to use",
3698 .next = NEXT(action_meter, NEXT_ENTRY(UNSIGNED)),
3699 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter, mtr_id)),
3700 .call = parse_vc_conf,
3702 [ACTION_OF_SET_MPLS_TTL] = {
3703 .name = "of_set_mpls_ttl",
3704 .help = "OpenFlow's OFPAT_SET_MPLS_TTL",
3707 sizeof(struct rte_flow_action_of_set_mpls_ttl)),
3708 .next = NEXT(action_of_set_mpls_ttl),
3711 [ACTION_OF_SET_MPLS_TTL_MPLS_TTL] = {
3714 .next = NEXT(action_of_set_mpls_ttl, NEXT_ENTRY(UNSIGNED)),
3715 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_mpls_ttl,
3717 .call = parse_vc_conf,
3719 [ACTION_OF_DEC_MPLS_TTL] = {
3720 .name = "of_dec_mpls_ttl",
3721 .help = "OpenFlow's OFPAT_DEC_MPLS_TTL",
3722 .priv = PRIV_ACTION(OF_DEC_MPLS_TTL, 0),
3723 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3726 [ACTION_OF_SET_NW_TTL] = {
3727 .name = "of_set_nw_ttl",
3728 .help = "OpenFlow's OFPAT_SET_NW_TTL",
3731 sizeof(struct rte_flow_action_of_set_nw_ttl)),
3732 .next = NEXT(action_of_set_nw_ttl),
3735 [ACTION_OF_SET_NW_TTL_NW_TTL] = {
3738 .next = NEXT(action_of_set_nw_ttl, NEXT_ENTRY(UNSIGNED)),
3739 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_nw_ttl,
3741 .call = parse_vc_conf,
3743 [ACTION_OF_DEC_NW_TTL] = {
3744 .name = "of_dec_nw_ttl",
3745 .help = "OpenFlow's OFPAT_DEC_NW_TTL",
3746 .priv = PRIV_ACTION(OF_DEC_NW_TTL, 0),
3747 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3750 [ACTION_OF_COPY_TTL_OUT] = {
3751 .name = "of_copy_ttl_out",
3752 .help = "OpenFlow's OFPAT_COPY_TTL_OUT",
3753 .priv = PRIV_ACTION(OF_COPY_TTL_OUT, 0),
3754 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3757 [ACTION_OF_COPY_TTL_IN] = {
3758 .name = "of_copy_ttl_in",
3759 .help = "OpenFlow's OFPAT_COPY_TTL_IN",
3760 .priv = PRIV_ACTION(OF_COPY_TTL_IN, 0),
3761 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3764 [ACTION_OF_POP_VLAN] = {
3765 .name = "of_pop_vlan",
3766 .help = "OpenFlow's OFPAT_POP_VLAN",
3767 .priv = PRIV_ACTION(OF_POP_VLAN, 0),
3768 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3771 [ACTION_OF_PUSH_VLAN] = {
3772 .name = "of_push_vlan",
3773 .help = "OpenFlow's OFPAT_PUSH_VLAN",
3776 sizeof(struct rte_flow_action_of_push_vlan)),
3777 .next = NEXT(action_of_push_vlan),
3780 [ACTION_OF_PUSH_VLAN_ETHERTYPE] = {
3781 .name = "ethertype",
3782 .help = "EtherType",
3783 .next = NEXT(action_of_push_vlan, NEXT_ENTRY(UNSIGNED)),
3784 .args = ARGS(ARGS_ENTRY_HTON
3785 (struct rte_flow_action_of_push_vlan,
3787 .call = parse_vc_conf,
3789 [ACTION_OF_SET_VLAN_VID] = {
3790 .name = "of_set_vlan_vid",
3791 .help = "OpenFlow's OFPAT_SET_VLAN_VID",
3794 sizeof(struct rte_flow_action_of_set_vlan_vid)),
3795 .next = NEXT(action_of_set_vlan_vid),
3798 [ACTION_OF_SET_VLAN_VID_VLAN_VID] = {
3801 .next = NEXT(action_of_set_vlan_vid, NEXT_ENTRY(UNSIGNED)),
3802 .args = ARGS(ARGS_ENTRY_HTON
3803 (struct rte_flow_action_of_set_vlan_vid,
3805 .call = parse_vc_conf,
3807 [ACTION_OF_SET_VLAN_PCP] = {
3808 .name = "of_set_vlan_pcp",
3809 .help = "OpenFlow's OFPAT_SET_VLAN_PCP",
3812 sizeof(struct rte_flow_action_of_set_vlan_pcp)),
3813 .next = NEXT(action_of_set_vlan_pcp),
3816 [ACTION_OF_SET_VLAN_PCP_VLAN_PCP] = {
3818 .help = "VLAN priority",
3819 .next = NEXT(action_of_set_vlan_pcp, NEXT_ENTRY(UNSIGNED)),
3820 .args = ARGS(ARGS_ENTRY_HTON
3821 (struct rte_flow_action_of_set_vlan_pcp,
3823 .call = parse_vc_conf,
3825 [ACTION_OF_POP_MPLS] = {
3826 .name = "of_pop_mpls",
3827 .help = "OpenFlow's OFPAT_POP_MPLS",
3828 .priv = PRIV_ACTION(OF_POP_MPLS,
3829 sizeof(struct rte_flow_action_of_pop_mpls)),
3830 .next = NEXT(action_of_pop_mpls),
3833 [ACTION_OF_POP_MPLS_ETHERTYPE] = {
3834 .name = "ethertype",
3835 .help = "EtherType",
3836 .next = NEXT(action_of_pop_mpls, NEXT_ENTRY(UNSIGNED)),
3837 .args = ARGS(ARGS_ENTRY_HTON
3838 (struct rte_flow_action_of_pop_mpls,
3840 .call = parse_vc_conf,
3842 [ACTION_OF_PUSH_MPLS] = {
3843 .name = "of_push_mpls",
3844 .help = "OpenFlow's OFPAT_PUSH_MPLS",
3847 sizeof(struct rte_flow_action_of_push_mpls)),
3848 .next = NEXT(action_of_push_mpls),
3851 [ACTION_OF_PUSH_MPLS_ETHERTYPE] = {
3852 .name = "ethertype",
3853 .help = "EtherType",
3854 .next = NEXT(action_of_push_mpls, NEXT_ENTRY(UNSIGNED)),
3855 .args = ARGS(ARGS_ENTRY_HTON
3856 (struct rte_flow_action_of_push_mpls,
3858 .call = parse_vc_conf,
3860 [ACTION_VXLAN_ENCAP] = {
3861 .name = "vxlan_encap",
3862 .help = "VXLAN encapsulation, uses configuration set by \"set"
3864 .priv = PRIV_ACTION(VXLAN_ENCAP,
3865 sizeof(struct action_vxlan_encap_data)),
3866 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3867 .call = parse_vc_action_vxlan_encap,
3869 [ACTION_VXLAN_DECAP] = {
3870 .name = "vxlan_decap",
3871 .help = "Performs a decapsulation action by stripping all"
3872 " headers of the VXLAN tunnel network overlay from the"
3874 .priv = PRIV_ACTION(VXLAN_DECAP, 0),
3875 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3878 [ACTION_NVGRE_ENCAP] = {
3879 .name = "nvgre_encap",
3880 .help = "NVGRE encapsulation, uses configuration set by \"set"
3882 .priv = PRIV_ACTION(NVGRE_ENCAP,
3883 sizeof(struct action_nvgre_encap_data)),
3884 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3885 .call = parse_vc_action_nvgre_encap,
3887 [ACTION_NVGRE_DECAP] = {
3888 .name = "nvgre_decap",
3889 .help = "Performs a decapsulation action by stripping all"
3890 " headers of the NVGRE tunnel network overlay from the"
3892 .priv = PRIV_ACTION(NVGRE_DECAP, 0),
3893 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3896 [ACTION_L2_ENCAP] = {
3898 .help = "l2 encap, uses configuration set by"
3899 " \"set l2_encap\"",
3900 .priv = PRIV_ACTION(RAW_ENCAP,
3901 sizeof(struct action_raw_encap_data)),
3902 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3903 .call = parse_vc_action_l2_encap,
3905 [ACTION_L2_DECAP] = {
3907 .help = "l2 decap, uses configuration set by"
3908 " \"set l2_decap\"",
3909 .priv = PRIV_ACTION(RAW_DECAP,
3910 sizeof(struct action_raw_decap_data)),
3911 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3912 .call = parse_vc_action_l2_decap,
3914 [ACTION_MPLSOGRE_ENCAP] = {
3915 .name = "mplsogre_encap",
3916 .help = "mplsogre encapsulation, uses configuration set by"
3917 " \"set mplsogre_encap\"",
3918 .priv = PRIV_ACTION(RAW_ENCAP,
3919 sizeof(struct action_raw_encap_data)),
3920 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3921 .call = parse_vc_action_mplsogre_encap,
3923 [ACTION_MPLSOGRE_DECAP] = {
3924 .name = "mplsogre_decap",
3925 .help = "mplsogre decapsulation, uses configuration set by"
3926 " \"set mplsogre_decap\"",
3927 .priv = PRIV_ACTION(RAW_DECAP,
3928 sizeof(struct action_raw_decap_data)),
3929 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3930 .call = parse_vc_action_mplsogre_decap,
3932 [ACTION_MPLSOUDP_ENCAP] = {
3933 .name = "mplsoudp_encap",
3934 .help = "mplsoudp encapsulation, uses configuration set by"
3935 " \"set mplsoudp_encap\"",
3936 .priv = PRIV_ACTION(RAW_ENCAP,
3937 sizeof(struct action_raw_encap_data)),
3938 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3939 .call = parse_vc_action_mplsoudp_encap,
3941 [ACTION_MPLSOUDP_DECAP] = {
3942 .name = "mplsoudp_decap",
3943 .help = "mplsoudp decapsulation, uses configuration set by"
3944 " \"set mplsoudp_decap\"",
3945 .priv = PRIV_ACTION(RAW_DECAP,
3946 sizeof(struct action_raw_decap_data)),
3947 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3948 .call = parse_vc_action_mplsoudp_decap,
3950 [ACTION_SET_IPV4_SRC] = {
3951 .name = "set_ipv4_src",
3952 .help = "Set a new IPv4 source address in the outermost"
3954 .priv = PRIV_ACTION(SET_IPV4_SRC,
3955 sizeof(struct rte_flow_action_set_ipv4)),
3956 .next = NEXT(action_set_ipv4_src),
3959 [ACTION_SET_IPV4_SRC_IPV4_SRC] = {
3960 .name = "ipv4_addr",
3961 .help = "new IPv4 source address to set",
3962 .next = NEXT(action_set_ipv4_src, NEXT_ENTRY(IPV4_ADDR)),
3963 .args = ARGS(ARGS_ENTRY_HTON
3964 (struct rte_flow_action_set_ipv4, ipv4_addr)),
3965 .call = parse_vc_conf,
3967 [ACTION_SET_IPV4_DST] = {
3968 .name = "set_ipv4_dst",
3969 .help = "Set a new IPv4 destination address in the outermost"
3971 .priv = PRIV_ACTION(SET_IPV4_DST,
3972 sizeof(struct rte_flow_action_set_ipv4)),
3973 .next = NEXT(action_set_ipv4_dst),
3976 [ACTION_SET_IPV4_DST_IPV4_DST] = {
3977 .name = "ipv4_addr",
3978 .help = "new IPv4 destination address to set",
3979 .next = NEXT(action_set_ipv4_dst, NEXT_ENTRY(IPV4_ADDR)),
3980 .args = ARGS(ARGS_ENTRY_HTON
3981 (struct rte_flow_action_set_ipv4, ipv4_addr)),
3982 .call = parse_vc_conf,
3984 [ACTION_SET_IPV6_SRC] = {
3985 .name = "set_ipv6_src",
3986 .help = "Set a new IPv6 source address in the outermost"
3988 .priv = PRIV_ACTION(SET_IPV6_SRC,
3989 sizeof(struct rte_flow_action_set_ipv6)),
3990 .next = NEXT(action_set_ipv6_src),
3993 [ACTION_SET_IPV6_SRC_IPV6_SRC] = {
3994 .name = "ipv6_addr",
3995 .help = "new IPv6 source address to set",
3996 .next = NEXT(action_set_ipv6_src, NEXT_ENTRY(IPV6_ADDR)),
3997 .args = ARGS(ARGS_ENTRY_HTON
3998 (struct rte_flow_action_set_ipv6, ipv6_addr)),
3999 .call = parse_vc_conf,
4001 [ACTION_SET_IPV6_DST] = {
4002 .name = "set_ipv6_dst",
4003 .help = "Set a new IPv6 destination address in the outermost"
4005 .priv = PRIV_ACTION(SET_IPV6_DST,
4006 sizeof(struct rte_flow_action_set_ipv6)),
4007 .next = NEXT(action_set_ipv6_dst),
4010 [ACTION_SET_IPV6_DST_IPV6_DST] = {
4011 .name = "ipv6_addr",
4012 .help = "new IPv6 destination address to set",
4013 .next = NEXT(action_set_ipv6_dst, NEXT_ENTRY(IPV6_ADDR)),
4014 .args = ARGS(ARGS_ENTRY_HTON
4015 (struct rte_flow_action_set_ipv6, ipv6_addr)),
4016 .call = parse_vc_conf,
4018 [ACTION_SET_TP_SRC] = {
4019 .name = "set_tp_src",
4020 .help = "set a new source port number in the outermost"
4022 .priv = PRIV_ACTION(SET_TP_SRC,
4023 sizeof(struct rte_flow_action_set_tp)),
4024 .next = NEXT(action_set_tp_src),
4027 [ACTION_SET_TP_SRC_TP_SRC] = {
4029 .help = "new source port number to set",
4030 .next = NEXT(action_set_tp_src, NEXT_ENTRY(UNSIGNED)),
4031 .args = ARGS(ARGS_ENTRY_HTON
4032 (struct rte_flow_action_set_tp, port)),
4033 .call = parse_vc_conf,
4035 [ACTION_SET_TP_DST] = {
4036 .name = "set_tp_dst",
4037 .help = "set a new destination port number in the outermost"
4039 .priv = PRIV_ACTION(SET_TP_DST,
4040 sizeof(struct rte_flow_action_set_tp)),
4041 .next = NEXT(action_set_tp_dst),
4044 [ACTION_SET_TP_DST_TP_DST] = {
4046 .help = "new destination port number to set",
4047 .next = NEXT(action_set_tp_dst, NEXT_ENTRY(UNSIGNED)),
4048 .args = ARGS(ARGS_ENTRY_HTON
4049 (struct rte_flow_action_set_tp, port)),
4050 .call = parse_vc_conf,
4052 [ACTION_MAC_SWAP] = {
4054 .help = "Swap the source and destination MAC addresses"
4055 " in the outermost Ethernet header",
4056 .priv = PRIV_ACTION(MAC_SWAP, 0),
4057 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4060 [ACTION_DEC_TTL] = {
4062 .help = "decrease network TTL if available",
4063 .priv = PRIV_ACTION(DEC_TTL, 0),
4064 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4067 [ACTION_SET_TTL] = {
4069 .help = "set ttl value",
4070 .priv = PRIV_ACTION(SET_TTL,
4071 sizeof(struct rte_flow_action_set_ttl)),
4072 .next = NEXT(action_set_ttl),
4075 [ACTION_SET_TTL_TTL] = {
4076 .name = "ttl_value",
4077 .help = "new ttl value to set",
4078 .next = NEXT(action_set_ttl, NEXT_ENTRY(UNSIGNED)),
4079 .args = ARGS(ARGS_ENTRY_HTON
4080 (struct rte_flow_action_set_ttl, ttl_value)),
4081 .call = parse_vc_conf,
4083 [ACTION_SET_MAC_SRC] = {
4084 .name = "set_mac_src",
4085 .help = "set source mac address",
4086 .priv = PRIV_ACTION(SET_MAC_SRC,
4087 sizeof(struct rte_flow_action_set_mac)),
4088 .next = NEXT(action_set_mac_src),
4091 [ACTION_SET_MAC_SRC_MAC_SRC] = {
4093 .help = "new source mac address",
4094 .next = NEXT(action_set_mac_src, NEXT_ENTRY(MAC_ADDR)),
4095 .args = ARGS(ARGS_ENTRY_HTON
4096 (struct rte_flow_action_set_mac, mac_addr)),
4097 .call = parse_vc_conf,
4099 [ACTION_SET_MAC_DST] = {
4100 .name = "set_mac_dst",
4101 .help = "set destination mac address",
4102 .priv = PRIV_ACTION(SET_MAC_DST,
4103 sizeof(struct rte_flow_action_set_mac)),
4104 .next = NEXT(action_set_mac_dst),
4107 [ACTION_SET_MAC_DST_MAC_DST] = {
4109 .help = "new destination mac address to set",
4110 .next = NEXT(action_set_mac_dst, NEXT_ENTRY(MAC_ADDR)),
4111 .args = ARGS(ARGS_ENTRY_HTON
4112 (struct rte_flow_action_set_mac, mac_addr)),
4113 .call = parse_vc_conf,
4115 [ACTION_INC_TCP_SEQ] = {
4116 .name = "inc_tcp_seq",
4117 .help = "increase TCP sequence number",
4118 .priv = PRIV_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
4119 .next = NEXT(action_inc_tcp_seq),
4122 [ACTION_INC_TCP_SEQ_VALUE] = {
4124 .help = "the value to increase TCP sequence number by",
4125 .next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(UNSIGNED)),
4126 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4127 .call = parse_vc_conf,
4129 [ACTION_DEC_TCP_SEQ] = {
4130 .name = "dec_tcp_seq",
4131 .help = "decrease TCP sequence number",
4132 .priv = PRIV_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
4133 .next = NEXT(action_dec_tcp_seq),
4136 [ACTION_DEC_TCP_SEQ_VALUE] = {
4138 .help = "the value to decrease TCP sequence number by",
4139 .next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(UNSIGNED)),
4140 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4141 .call = parse_vc_conf,
4143 [ACTION_INC_TCP_ACK] = {
4144 .name = "inc_tcp_ack",
4145 .help = "increase TCP acknowledgment number",
4146 .priv = PRIV_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
4147 .next = NEXT(action_inc_tcp_ack),
4150 [ACTION_INC_TCP_ACK_VALUE] = {
4152 .help = "the value to increase TCP acknowledgment number by",
4153 .next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(UNSIGNED)),
4154 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4155 .call = parse_vc_conf,
4157 [ACTION_DEC_TCP_ACK] = {
4158 .name = "dec_tcp_ack",
4159 .help = "decrease TCP acknowledgment number",
4160 .priv = PRIV_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
4161 .next = NEXT(action_dec_tcp_ack),
4164 [ACTION_DEC_TCP_ACK_VALUE] = {
4166 .help = "the value to decrease TCP acknowledgment number by",
4167 .next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(UNSIGNED)),
4168 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4169 .call = parse_vc_conf,
4171 [ACTION_RAW_ENCAP] = {
4172 .name = "raw_encap",
4173 .help = "encapsulation data, defined by set raw_encap",
4174 .priv = PRIV_ACTION(RAW_ENCAP,
4175 sizeof(struct action_raw_encap_data)),
4176 .next = NEXT(action_raw_encap),
4177 .call = parse_vc_action_raw_encap,
4179 [ACTION_RAW_ENCAP_INDEX] = {
4181 .help = "the index of raw_encap_confs",
4182 .next = NEXT(NEXT_ENTRY(ACTION_RAW_ENCAP_INDEX_VALUE)),
4184 [ACTION_RAW_ENCAP_INDEX_VALUE] = {
4187 .help = "unsigned integer value",
4188 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4189 .call = parse_vc_action_raw_encap_index,
4190 .comp = comp_set_raw_index,
4192 [ACTION_RAW_DECAP] = {
4193 .name = "raw_decap",
4194 .help = "decapsulation data, defined by set raw_encap",
4195 .priv = PRIV_ACTION(RAW_DECAP,
4196 sizeof(struct action_raw_decap_data)),
4197 .next = NEXT(action_raw_decap),
4198 .call = parse_vc_action_raw_decap,
4200 [ACTION_RAW_DECAP_INDEX] = {
4202 .help = "the index of raw_encap_confs",
4203 .next = NEXT(NEXT_ENTRY(ACTION_RAW_DECAP_INDEX_VALUE)),
4205 [ACTION_RAW_DECAP_INDEX_VALUE] = {
4208 .help = "unsigned integer value",
4209 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4210 .call = parse_vc_action_raw_decap_index,
4211 .comp = comp_set_raw_index,
4213 [ACTION_MODIFY_FIELD] = {
4214 .name = "modify_field",
4215 .help = "modify destination field with data from source field",
4216 .priv = PRIV_ACTION(MODIFY_FIELD,
4217 sizeof(struct rte_flow_action_modify_field)),
4218 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_OP)),
4221 [ACTION_MODIFY_FIELD_OP] = {
4223 .help = "operation type",
4224 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_TYPE),
4225 NEXT_ENTRY(ACTION_MODIFY_FIELD_OP_VALUE)),
4226 .call = parse_vc_conf,
4228 [ACTION_MODIFY_FIELD_OP_VALUE] = {
4229 .name = "{operation}",
4230 .help = "operation type value",
4231 .call = parse_vc_modify_field_op,
4232 .comp = comp_set_modify_field_op,
4234 [ACTION_MODIFY_FIELD_DST_TYPE] = {
4236 .help = "destination field type",
4237 .next = NEXT(action_modify_field_dst,
4238 NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_TYPE_VALUE)),
4239 .call = parse_vc_conf,
4241 [ACTION_MODIFY_FIELD_DST_TYPE_VALUE] = {
4242 .name = "{dst_type}",
4243 .help = "destination field type value",
4244 .call = parse_vc_modify_field_id,
4245 .comp = comp_set_modify_field_id,
4247 [ACTION_MODIFY_FIELD_DST_LEVEL] = {
4248 .name = "dst_level",
4249 .help = "destination field level",
4250 .next = NEXT(action_modify_field_dst, NEXT_ENTRY(UNSIGNED)),
4251 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4253 .call = parse_vc_conf,
4255 [ACTION_MODIFY_FIELD_DST_OFFSET] = {
4256 .name = "dst_offset",
4257 .help = "destination field bit offset",
4258 .next = NEXT(action_modify_field_dst, NEXT_ENTRY(UNSIGNED)),
4259 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4261 .call = parse_vc_conf,
4263 [ACTION_MODIFY_FIELD_SRC_TYPE] = {
4265 .help = "source field type",
4266 .next = NEXT(action_modify_field_src,
4267 NEXT_ENTRY(ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)),
4268 .call = parse_vc_conf,
4270 [ACTION_MODIFY_FIELD_SRC_TYPE_VALUE] = {
4271 .name = "{src_type}",
4272 .help = "source field type value",
4273 .call = parse_vc_modify_field_id,
4274 .comp = comp_set_modify_field_id,
4276 [ACTION_MODIFY_FIELD_SRC_LEVEL] = {
4277 .name = "src_level",
4278 .help = "source field level",
4279 .next = NEXT(action_modify_field_src, NEXT_ENTRY(UNSIGNED)),
4280 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4282 .call = parse_vc_conf,
4284 [ACTION_MODIFY_FIELD_SRC_OFFSET] = {
4285 .name = "src_offset",
4286 .help = "source field bit offset",
4287 .next = NEXT(action_modify_field_src, NEXT_ENTRY(UNSIGNED)),
4288 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4290 .call = parse_vc_conf,
4292 [ACTION_MODIFY_FIELD_SRC_VALUE] = {
4293 .name = "src_value",
4294 .help = "source immediate value",
4295 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_WIDTH),
4296 NEXT_ENTRY(UNSIGNED)),
4297 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4299 .call = parse_vc_conf,
4301 [ACTION_MODIFY_FIELD_WIDTH] = {
4303 .help = "number of bits to copy",
4304 .next = NEXT(NEXT_ENTRY(ACTION_NEXT),
4305 NEXT_ENTRY(UNSIGNED)),
4306 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4308 .call = parse_vc_conf,
4310 /* Top level command. */
4313 .help = "set raw encap/decap/sample data",
4314 .type = "set raw_encap|raw_decap <index> <pattern>"
4315 " or set sample_actions <index> <action>",
4316 .next = NEXT(NEXT_ENTRY
4319 SET_SAMPLE_ACTIONS)),
4320 .call = parse_set_init,
4322 /* Sub-level commands. */
4324 .name = "raw_encap",
4325 .help = "set raw encap data",
4326 .next = NEXT(next_set_raw),
4327 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4328 (offsetof(struct buffer, port),
4329 sizeof(((struct buffer *)0)->port),
4330 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
4331 .call = parse_set_raw_encap_decap,
4334 .name = "raw_decap",
4335 .help = "set raw decap data",
4336 .next = NEXT(next_set_raw),
4337 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4338 (offsetof(struct buffer, port),
4339 sizeof(((struct buffer *)0)->port),
4340 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
4341 .call = parse_set_raw_encap_decap,
4346 .help = "index of raw_encap/raw_decap data",
4347 .next = NEXT(next_item),
4350 [SET_SAMPLE_INDEX] = {
4353 .help = "index of sample actions",
4354 .next = NEXT(next_action_sample),
4357 [SET_SAMPLE_ACTIONS] = {
4358 .name = "sample_actions",
4359 .help = "set sample actions list",
4360 .next = NEXT(NEXT_ENTRY(SET_SAMPLE_INDEX)),
4361 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4362 (offsetof(struct buffer, port),
4363 sizeof(((struct buffer *)0)->port),
4364 0, RAW_SAMPLE_CONFS_MAX_NUM - 1)),
4365 .call = parse_set_sample_action,
4367 [ACTION_SET_TAG] = {
4370 .priv = PRIV_ACTION(SET_TAG,
4371 sizeof(struct rte_flow_action_set_tag)),
4372 .next = NEXT(action_set_tag),
4375 [ACTION_SET_TAG_INDEX] = {
4377 .help = "index of tag array",
4378 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
4379 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_set_tag, index)),
4380 .call = parse_vc_conf,
4382 [ACTION_SET_TAG_DATA] = {
4384 .help = "tag value",
4385 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
4386 .args = ARGS(ARGS_ENTRY
4387 (struct rte_flow_action_set_tag, data)),
4388 .call = parse_vc_conf,
4390 [ACTION_SET_TAG_MASK] = {
4392 .help = "mask for tag value",
4393 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
4394 .args = ARGS(ARGS_ENTRY
4395 (struct rte_flow_action_set_tag, mask)),
4396 .call = parse_vc_conf,
4398 [ACTION_SET_META] = {
4400 .help = "set metadata",
4401 .priv = PRIV_ACTION(SET_META,
4402 sizeof(struct rte_flow_action_set_meta)),
4403 .next = NEXT(action_set_meta),
4404 .call = parse_vc_action_set_meta,
4406 [ACTION_SET_META_DATA] = {
4408 .help = "metadata value",
4409 .next = NEXT(action_set_meta, NEXT_ENTRY(UNSIGNED)),
4410 .args = ARGS(ARGS_ENTRY
4411 (struct rte_flow_action_set_meta, data)),
4412 .call = parse_vc_conf,
4414 [ACTION_SET_META_MASK] = {
4416 .help = "mask for metadata value",
4417 .next = NEXT(action_set_meta, NEXT_ENTRY(UNSIGNED)),
4418 .args = ARGS(ARGS_ENTRY
4419 (struct rte_flow_action_set_meta, mask)),
4420 .call = parse_vc_conf,
4422 [ACTION_SET_IPV4_DSCP] = {
4423 .name = "set_ipv4_dscp",
4424 .help = "set DSCP value",
4425 .priv = PRIV_ACTION(SET_IPV4_DSCP,
4426 sizeof(struct rte_flow_action_set_dscp)),
4427 .next = NEXT(action_set_ipv4_dscp),
4430 [ACTION_SET_IPV4_DSCP_VALUE] = {
4431 .name = "dscp_value",
4432 .help = "new IPv4 DSCP value to set",
4433 .next = NEXT(action_set_ipv4_dscp, NEXT_ENTRY(UNSIGNED)),
4434 .args = ARGS(ARGS_ENTRY
4435 (struct rte_flow_action_set_dscp, dscp)),
4436 .call = parse_vc_conf,
4438 [ACTION_SET_IPV6_DSCP] = {
4439 .name = "set_ipv6_dscp",
4440 .help = "set DSCP value",
4441 .priv = PRIV_ACTION(SET_IPV6_DSCP,
4442 sizeof(struct rte_flow_action_set_dscp)),
4443 .next = NEXT(action_set_ipv6_dscp),
4446 [ACTION_SET_IPV6_DSCP_VALUE] = {
4447 .name = "dscp_value",
4448 .help = "new IPv6 DSCP value to set",
4449 .next = NEXT(action_set_ipv6_dscp, NEXT_ENTRY(UNSIGNED)),
4450 .args = ARGS(ARGS_ENTRY
4451 (struct rte_flow_action_set_dscp, dscp)),
4452 .call = parse_vc_conf,
4456 .help = "set a specific metadata header",
4457 .next = NEXT(action_age),
4458 .priv = PRIV_ACTION(AGE,
4459 sizeof(struct rte_flow_action_age)),
4462 [ACTION_AGE_TIMEOUT] = {
4464 .help = "flow age timeout value",
4465 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_age,
4467 .next = NEXT(action_age, NEXT_ENTRY(UNSIGNED)),
4468 .call = parse_vc_conf,
4472 .help = "set a sample action",
4473 .next = NEXT(action_sample),
4474 .priv = PRIV_ACTION(SAMPLE,
4475 sizeof(struct action_sample_data)),
4476 .call = parse_vc_action_sample,
4478 [ACTION_SAMPLE_RATIO] = {
4480 .help = "flow sample ratio value",
4481 .next = NEXT(action_sample, NEXT_ENTRY(UNSIGNED)),
4482 .args = ARGS(ARGS_ENTRY_ARB
4483 (offsetof(struct action_sample_data, conf) +
4484 offsetof(struct rte_flow_action_sample, ratio),
4485 sizeof(((struct rte_flow_action_sample *)0)->
4488 [ACTION_SAMPLE_INDEX] = {
4490 .help = "the index of sample actions list",
4491 .next = NEXT(NEXT_ENTRY(ACTION_SAMPLE_INDEX_VALUE)),
4493 [ACTION_SAMPLE_INDEX_VALUE] = {
4496 .help = "unsigned integer value",
4497 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4498 .call = parse_vc_action_sample_index,
4499 .comp = comp_set_sample_index,
4501 /* Shared action destroy arguments. */
4502 [SHARED_ACTION_DESTROY_ID] = {
4503 .name = "action_id",
4504 .help = "specify a shared action id to destroy",
4505 .next = NEXT(next_sa_destroy_attr,
4506 NEXT_ENTRY(SHARED_ACTION_ID)),
4507 .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
4508 args.sa_destroy.action_id)),
4509 .call = parse_sa_destroy,
4511 /* Shared action create arguments. */
4512 [SHARED_ACTION_CREATE_ID] = {
4513 .name = "action_id",
4514 .help = "specify a shared action id to create",
4515 .next = NEXT(next_sa_create_attr,
4516 NEXT_ENTRY(SHARED_ACTION_ID)),
4517 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
4521 .help = "apply shared action by id",
4522 .priv = PRIV_ACTION(SHARED, 0),
4523 .next = NEXT(NEXT_ENTRY(SHARED_ACTION_ID2PTR)),
4524 .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
4527 [SHARED_ACTION_ID2PTR] = {
4528 .name = "{action_id}",
4529 .type = "SHARED_ACTION_ID",
4530 .help = "shared action id",
4531 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4532 .call = parse_sa_id2ptr,
4535 [SHARED_ACTION_INGRESS] = {
4537 .help = "affect rule to ingress",
4538 .next = NEXT(next_sa_create_attr),
4541 [SHARED_ACTION_EGRESS] = {
4543 .help = "affect rule to egress",
4544 .next = NEXT(next_sa_create_attr),
4547 [SHARED_ACTION_TRANSFER] = {
4549 .help = "affect rule to transfer",
4550 .next = NEXT(next_sa_create_attr),
4553 [SHARED_ACTION_SPEC] = {
4555 .help = "specify action to share",
4556 .next = NEXT(next_action),
4560 /** Remove and return last entry from argument stack. */
4561 static const struct arg *
4562 pop_args(struct context *ctx)
4564 return ctx->args_num ? ctx->args[--ctx->args_num] : NULL;
4567 /** Add entry on top of the argument stack. */
4569 push_args(struct context *ctx, const struct arg *arg)
4571 if (ctx->args_num == CTX_STACK_SIZE)
4573 ctx->args[ctx->args_num++] = arg;
4577 /** Spread value into buffer according to bit-mask. */
4579 arg_entry_bf_fill(void *dst, uintmax_t val, const struct arg *arg)
4581 uint32_t i = arg->size;
4589 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
4598 unsigned int shift = 0;
4599 uint8_t *buf = (uint8_t *)dst + arg->offset + (i -= sub);
4601 for (shift = 0; arg->mask[i] >> shift; ++shift) {
4602 if (!(arg->mask[i] & (1 << shift)))
4607 *buf &= ~(1 << shift);
4608 *buf |= (val & 1) << shift;
4616 /** Compare a string with a partial one of a given length. */
4618 strcmp_partial(const char *full, const char *partial, size_t partial_len)
4620 int r = strncmp(full, partial, partial_len);
4624 if (strlen(full) <= partial_len)
4626 return full[partial_len];
4630 * Parse a prefix length and generate a bit-mask.
4632 * Last argument (ctx->args) is retrieved to determine mask size, storage
4633 * location and whether the result must use network byte ordering.
4636 parse_prefix(struct context *ctx, const struct token *token,
4637 const char *str, unsigned int len,
4638 void *buf, unsigned int size)
4640 const struct arg *arg = pop_args(ctx);
4641 static const uint8_t conv[] = "\x00\x80\xc0\xe0\xf0\xf8\xfc\xfe\xff";
4648 /* Argument is expected. */
4652 u = strtoumax(str, &end, 0);
4653 if (errno || (size_t)(end - str) != len)
4658 extra = arg_entry_bf_fill(NULL, 0, arg);
4667 if (!arg_entry_bf_fill(ctx->object, v, arg) ||
4668 !arg_entry_bf_fill(ctx->objmask, -1, arg))
4675 if (bytes > size || bytes + !!extra > size)
4679 buf = (uint8_t *)ctx->object + arg->offset;
4680 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
4682 memset((uint8_t *)buf + size - bytes, 0xff, bytes);
4683 memset(buf, 0x00, size - bytes);
4685 ((uint8_t *)buf)[size - bytes - 1] = conv[extra];
4689 memset(buf, 0xff, bytes);
4690 memset((uint8_t *)buf + bytes, 0x00, size - bytes);
4692 ((uint8_t *)buf)[bytes] = conv[extra];
4695 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
4698 push_args(ctx, arg);
4702 /** Default parsing function for token name matching. */
4704 parse_default(struct context *ctx, const struct token *token,
4705 const char *str, unsigned int len,
4706 void *buf, unsigned int size)
4711 if (strcmp_partial(token->name, str, len))
4716 /** Parse flow command, initialize output buffer for subsequent tokens. */
4718 parse_init(struct context *ctx, const struct token *token,
4719 const char *str, unsigned int len,
4720 void *buf, unsigned int size)
4722 struct buffer *out = buf;
4724 /* Token name must match. */
4725 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4727 /* Nothing else to do if there is no buffer. */
4730 /* Make sure buffer is large enough. */
4731 if (size < sizeof(*out))
4733 /* Initialize buffer. */
4734 memset(out, 0x00, sizeof(*out));
4735 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
4738 ctx->objmask = NULL;
4742 /** Parse tokens for shared action commands. */
4744 parse_sa(struct context *ctx, const struct token *token,
4745 const char *str, unsigned int len,
4746 void *buf, unsigned int size)
4748 struct buffer *out = buf;
4750 /* Token name must match. */
4751 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4753 /* Nothing else to do if there is no buffer. */
4756 if (!out->command) {
4757 if (ctx->curr != SHARED_ACTION)
4759 if (sizeof(*out) > size)
4761 out->command = ctx->curr;
4764 ctx->objmask = NULL;
4765 out->args.vc.data = (uint8_t *)out + size;
4768 switch (ctx->curr) {
4769 case SHARED_ACTION_CREATE:
4770 case SHARED_ACTION_UPDATE:
4771 out->args.vc.actions =
4772 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
4774 out->args.vc.attr.group = UINT32_MAX;
4776 case SHARED_ACTION_QUERY:
4777 out->command = ctx->curr;
4780 ctx->objmask = NULL;
4782 case SHARED_ACTION_EGRESS:
4783 out->args.vc.attr.egress = 1;
4785 case SHARED_ACTION_INGRESS:
4786 out->args.vc.attr.ingress = 1;
4788 case SHARED_ACTION_TRANSFER:
4789 out->args.vc.attr.transfer = 1;
4797 /** Parse tokens for shared action destroy command. */
4799 parse_sa_destroy(struct context *ctx, const struct token *token,
4800 const char *str, unsigned int len,
4801 void *buf, unsigned int size)
4803 struct buffer *out = buf;
4804 uint32_t *action_id;
4806 /* Token name must match. */
4807 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4809 /* Nothing else to do if there is no buffer. */
4812 if (!out->command || out->command == SHARED_ACTION) {
4813 if (ctx->curr != SHARED_ACTION_DESTROY)
4815 if (sizeof(*out) > size)
4817 out->command = ctx->curr;
4820 ctx->objmask = NULL;
4821 out->args.sa_destroy.action_id =
4822 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
4826 action_id = out->args.sa_destroy.action_id
4827 + out->args.sa_destroy.action_id_n++;
4828 if ((uint8_t *)action_id > (uint8_t *)out + size)
4831 ctx->object = action_id;
4832 ctx->objmask = NULL;
4836 /** Parse tokens for validate/create commands. */
4838 parse_vc(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;
4846 /* Token name must match. */
4847 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4849 /* Nothing else to do if there is no buffer. */
4852 if (!out->command) {
4853 if (ctx->curr != VALIDATE && ctx->curr != CREATE)
4855 if (sizeof(*out) > size)
4857 out->command = ctx->curr;
4860 ctx->objmask = NULL;
4861 out->args.vc.data = (uint8_t *)out + size;
4865 switch (ctx->curr) {
4867 ctx->object = &out->args.vc.attr;
4871 ctx->object = &out->args.vc.tunnel_ops;
4874 ctx->objmask = NULL;
4875 switch (ctx->curr) {
4880 out->args.vc.tunnel_ops.enabled = 1;
4881 out->args.vc.tunnel_ops.actions = 1;
4884 out->args.vc.tunnel_ops.enabled = 1;
4885 out->args.vc.tunnel_ops.items = 1;
4888 out->args.vc.attr.ingress = 1;
4891 out->args.vc.attr.egress = 1;
4894 out->args.vc.attr.transfer = 1;
4897 out->args.vc.pattern =
4898 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
4900 ctx->object = out->args.vc.pattern;
4901 ctx->objmask = NULL;
4904 out->args.vc.actions =
4905 (void *)RTE_ALIGN_CEIL((uintptr_t)
4906 (out->args.vc.pattern +
4907 out->args.vc.pattern_n),
4909 ctx->object = out->args.vc.actions;
4910 ctx->objmask = NULL;
4917 if (!out->args.vc.actions) {
4918 const struct parse_item_priv *priv = token->priv;
4919 struct rte_flow_item *item =
4920 out->args.vc.pattern + out->args.vc.pattern_n;
4922 data_size = priv->size * 3; /* spec, last, mask */
4923 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
4924 (out->args.vc.data - data_size),
4926 if ((uint8_t *)item + sizeof(*item) > data)
4928 *item = (struct rte_flow_item){
4931 ++out->args.vc.pattern_n;
4933 ctx->objmask = NULL;
4935 const struct parse_action_priv *priv = token->priv;
4936 struct rte_flow_action *action =
4937 out->args.vc.actions + out->args.vc.actions_n;
4939 data_size = priv->size; /* configuration */
4940 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
4941 (out->args.vc.data - data_size),
4943 if ((uint8_t *)action + sizeof(*action) > data)
4945 *action = (struct rte_flow_action){
4947 .conf = data_size ? data : NULL,
4949 ++out->args.vc.actions_n;
4950 ctx->object = action;
4951 ctx->objmask = NULL;
4953 memset(data, 0, data_size);
4954 out->args.vc.data = data;
4955 ctx->objdata = data_size;
4959 /** Parse pattern item parameter type. */
4961 parse_vc_spec(struct context *ctx, const struct token *token,
4962 const char *str, unsigned int len,
4963 void *buf, unsigned int size)
4965 struct buffer *out = buf;
4966 struct rte_flow_item *item;
4972 /* Token name must match. */
4973 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4975 /* Parse parameter types. */
4976 switch (ctx->curr) {
4977 static const enum index prefix[] = NEXT_ENTRY(PREFIX);
4983 case ITEM_PARAM_SPEC:
4986 case ITEM_PARAM_LAST:
4989 case ITEM_PARAM_PREFIX:
4990 /* Modify next token to expect a prefix. */
4991 if (ctx->next_num < 2)
4993 ctx->next[ctx->next_num - 2] = prefix;
4995 case ITEM_PARAM_MASK:
5001 /* Nothing else to do if there is no buffer. */
5004 if (!out->args.vc.pattern_n)
5006 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
5007 data_size = ctx->objdata / 3; /* spec, last, mask */
5008 /* Point to selected object. */
5009 ctx->object = out->args.vc.data + (data_size * index);
5011 ctx->objmask = out->args.vc.data + (data_size * 2); /* mask */
5012 item->mask = ctx->objmask;
5014 ctx->objmask = NULL;
5015 /* Update relevant item pointer. */
5016 *((const void **[]){ &item->spec, &item->last, &item->mask })[index] =
5021 /** Parse action configuration field. */
5023 parse_vc_conf(struct context *ctx, const struct token *token,
5024 const char *str, unsigned int len,
5025 void *buf, unsigned int size)
5027 struct buffer *out = buf;
5030 /* Token name must match. */
5031 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5033 /* Nothing else to do if there is no buffer. */
5036 /* Point to selected object. */
5037 ctx->object = out->args.vc.data;
5038 ctx->objmask = NULL;
5042 /** Parse eCPRI common header type field. */
5044 parse_vc_item_ecpri_type(struct context *ctx, const struct token *token,
5045 const char *str, unsigned int len,
5046 void *buf, unsigned int size)
5048 struct rte_flow_item_ecpri *ecpri;
5049 struct rte_flow_item_ecpri *ecpri_mask;
5050 struct rte_flow_item *item;
5053 struct buffer *out = buf;
5054 const struct arg *arg;
5057 /* Token name must match. */
5058 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5060 switch (ctx->curr) {
5061 case ITEM_ECPRI_COMMON_TYPE_IQ_DATA:
5062 msg_type = RTE_ECPRI_MSG_TYPE_IQ_DATA;
5064 case ITEM_ECPRI_COMMON_TYPE_RTC_CTRL:
5065 msg_type = RTE_ECPRI_MSG_TYPE_RTC_CTRL;
5067 case ITEM_ECPRI_COMMON_TYPE_DLY_MSR:
5068 msg_type = RTE_ECPRI_MSG_TYPE_DLY_MSR;
5075 arg = pop_args(ctx);
5078 ecpri = (struct rte_flow_item_ecpri *)out->args.vc.data;
5079 ecpri->hdr.common.type = msg_type;
5080 data_size = ctx->objdata / 3; /* spec, last, mask */
5081 ecpri_mask = (struct rte_flow_item_ecpri *)(out->args.vc.data +
5083 ecpri_mask->hdr.common.type = 0xFF;
5085 ecpri->hdr.common.u32 = rte_cpu_to_be_32(ecpri->hdr.common.u32);
5086 ecpri_mask->hdr.common.u32 =
5087 rte_cpu_to_be_32(ecpri_mask->hdr.common.u32);
5089 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
5091 item->mask = ecpri_mask;
5095 /** Parse RSS action. */
5097 parse_vc_action_rss(struct context *ctx, const struct token *token,
5098 const char *str, unsigned int len,
5099 void *buf, unsigned int size)
5101 struct buffer *out = buf;
5102 struct rte_flow_action *action;
5103 struct action_rss_data *action_rss_data;
5107 ret = parse_vc(ctx, token, str, len, buf, size);
5110 /* Nothing else to do if there is no buffer. */
5113 if (!out->args.vc.actions_n)
5115 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5116 /* Point to selected object. */
5117 ctx->object = out->args.vc.data;
5118 ctx->objmask = NULL;
5119 /* Set up default configuration. */
5120 action_rss_data = ctx->object;
5121 *action_rss_data = (struct action_rss_data){
5122 .conf = (struct rte_flow_action_rss){
5123 .func = RTE_ETH_HASH_FUNCTION_DEFAULT,
5127 .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM),
5129 .queue = action_rss_data->queue,
5133 for (i = 0; i < action_rss_data->conf.queue_num; ++i)
5134 action_rss_data->queue[i] = i;
5135 action->conf = &action_rss_data->conf;
5140 * Parse func field for RSS action.
5142 * The RTE_ETH_HASH_FUNCTION_* value to assign is derived from the
5143 * ACTION_RSS_FUNC_* index that called this function.
5146 parse_vc_action_rss_func(struct context *ctx, const struct token *token,
5147 const char *str, unsigned int len,
5148 void *buf, unsigned int size)
5150 struct action_rss_data *action_rss_data;
5151 enum rte_eth_hash_function func;
5155 /* Token name must match. */
5156 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5158 switch (ctx->curr) {
5159 case ACTION_RSS_FUNC_DEFAULT:
5160 func = RTE_ETH_HASH_FUNCTION_DEFAULT;
5162 case ACTION_RSS_FUNC_TOEPLITZ:
5163 func = RTE_ETH_HASH_FUNCTION_TOEPLITZ;
5165 case ACTION_RSS_FUNC_SIMPLE_XOR:
5166 func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
5168 case ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ:
5169 func = RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
5176 action_rss_data = ctx->object;
5177 action_rss_data->conf.func = func;
5182 * Parse type field for RSS action.
5184 * Valid tokens are type field names and the "end" token.
5187 parse_vc_action_rss_type(struct context *ctx, const struct token *token,
5188 const char *str, unsigned int len,
5189 void *buf, unsigned int size)
5191 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE);
5192 struct action_rss_data *action_rss_data;
5198 if (ctx->curr != ACTION_RSS_TYPE)
5200 if (!(ctx->objdata >> 16) && ctx->object) {
5201 action_rss_data = ctx->object;
5202 action_rss_data->conf.types = 0;
5204 if (!strcmp_partial("end", str, len)) {
5205 ctx->objdata &= 0xffff;
5208 for (i = 0; rss_type_table[i].str; ++i)
5209 if (!strcmp_partial(rss_type_table[i].str, str, len))
5211 if (!rss_type_table[i].str)
5213 ctx->objdata = 1 << 16 | (ctx->objdata & 0xffff);
5215 if (ctx->next_num == RTE_DIM(ctx->next))
5217 ctx->next[ctx->next_num++] = next;
5220 action_rss_data = ctx->object;
5221 action_rss_data->conf.types |= rss_type_table[i].rss_type;
5226 * Parse queue field for RSS action.
5228 * Valid tokens are queue indices and the "end" token.
5231 parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
5232 const char *str, unsigned int len,
5233 void *buf, unsigned int size)
5235 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE);
5236 struct action_rss_data *action_rss_data;
5237 const struct arg *arg;
5244 if (ctx->curr != ACTION_RSS_QUEUE)
5246 i = ctx->objdata >> 16;
5247 if (!strcmp_partial("end", str, len)) {
5248 ctx->objdata &= 0xffff;
5251 if (i >= ACTION_RSS_QUEUE_NUM)
5253 arg = ARGS_ENTRY_ARB(offsetof(struct action_rss_data, queue) +
5254 i * sizeof(action_rss_data->queue[i]),
5255 sizeof(action_rss_data->queue[i]));
5256 if (push_args(ctx, arg))
5258 ret = parse_int(ctx, token, str, len, NULL, 0);
5264 ctx->objdata = i << 16 | (ctx->objdata & 0xffff);
5266 if (ctx->next_num == RTE_DIM(ctx->next))
5268 ctx->next[ctx->next_num++] = next;
5272 action_rss_data = ctx->object;
5273 action_rss_data->conf.queue_num = i;
5274 action_rss_data->conf.queue = i ? action_rss_data->queue : NULL;
5278 /** Setup VXLAN encap configuration. */
5280 parse_setup_vxlan_encap_data(struct action_vxlan_encap_data *action_vxlan_encap_data)
5282 /* Set up default configuration. */
5283 *action_vxlan_encap_data = (struct action_vxlan_encap_data){
5284 .conf = (struct rte_flow_action_vxlan_encap){
5285 .definition = action_vxlan_encap_data->items,
5289 .type = RTE_FLOW_ITEM_TYPE_ETH,
5290 .spec = &action_vxlan_encap_data->item_eth,
5291 .mask = &rte_flow_item_eth_mask,
5294 .type = RTE_FLOW_ITEM_TYPE_VLAN,
5295 .spec = &action_vxlan_encap_data->item_vlan,
5296 .mask = &rte_flow_item_vlan_mask,
5299 .type = RTE_FLOW_ITEM_TYPE_IPV4,
5300 .spec = &action_vxlan_encap_data->item_ipv4,
5301 .mask = &rte_flow_item_ipv4_mask,
5304 .type = RTE_FLOW_ITEM_TYPE_UDP,
5305 .spec = &action_vxlan_encap_data->item_udp,
5306 .mask = &rte_flow_item_udp_mask,
5309 .type = RTE_FLOW_ITEM_TYPE_VXLAN,
5310 .spec = &action_vxlan_encap_data->item_vxlan,
5311 .mask = &rte_flow_item_vxlan_mask,
5314 .type = RTE_FLOW_ITEM_TYPE_END,
5319 .tci = vxlan_encap_conf.vlan_tci,
5323 .src_addr = vxlan_encap_conf.ipv4_src,
5324 .dst_addr = vxlan_encap_conf.ipv4_dst,
5327 .src_port = vxlan_encap_conf.udp_src,
5328 .dst_port = vxlan_encap_conf.udp_dst,
5330 .item_vxlan.flags = 0,
5332 memcpy(action_vxlan_encap_data->item_eth.dst.addr_bytes,
5333 vxlan_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5334 memcpy(action_vxlan_encap_data->item_eth.src.addr_bytes,
5335 vxlan_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5336 if (!vxlan_encap_conf.select_ipv4) {
5337 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.src_addr,
5338 &vxlan_encap_conf.ipv6_src,
5339 sizeof(vxlan_encap_conf.ipv6_src));
5340 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.dst_addr,
5341 &vxlan_encap_conf.ipv6_dst,
5342 sizeof(vxlan_encap_conf.ipv6_dst));
5343 action_vxlan_encap_data->items[2] = (struct rte_flow_item){
5344 .type = RTE_FLOW_ITEM_TYPE_IPV6,
5345 .spec = &action_vxlan_encap_data->item_ipv6,
5346 .mask = &rte_flow_item_ipv6_mask,
5349 if (!vxlan_encap_conf.select_vlan)
5350 action_vxlan_encap_data->items[1].type =
5351 RTE_FLOW_ITEM_TYPE_VOID;
5352 if (vxlan_encap_conf.select_tos_ttl) {
5353 if (vxlan_encap_conf.select_ipv4) {
5354 static struct rte_flow_item_ipv4 ipv4_mask_tos;
5356 memcpy(&ipv4_mask_tos, &rte_flow_item_ipv4_mask,
5357 sizeof(ipv4_mask_tos));
5358 ipv4_mask_tos.hdr.type_of_service = 0xff;
5359 ipv4_mask_tos.hdr.time_to_live = 0xff;
5360 action_vxlan_encap_data->item_ipv4.hdr.type_of_service =
5361 vxlan_encap_conf.ip_tos;
5362 action_vxlan_encap_data->item_ipv4.hdr.time_to_live =
5363 vxlan_encap_conf.ip_ttl;
5364 action_vxlan_encap_data->items[2].mask =
5367 static struct rte_flow_item_ipv6 ipv6_mask_tos;
5369 memcpy(&ipv6_mask_tos, &rte_flow_item_ipv6_mask,
5370 sizeof(ipv6_mask_tos));
5371 ipv6_mask_tos.hdr.vtc_flow |=
5372 RTE_BE32(0xfful << RTE_IPV6_HDR_TC_SHIFT);
5373 ipv6_mask_tos.hdr.hop_limits = 0xff;
5374 action_vxlan_encap_data->item_ipv6.hdr.vtc_flow |=
5376 ((uint32_t)vxlan_encap_conf.ip_tos <<
5377 RTE_IPV6_HDR_TC_SHIFT);
5378 action_vxlan_encap_data->item_ipv6.hdr.hop_limits =
5379 vxlan_encap_conf.ip_ttl;
5380 action_vxlan_encap_data->items[2].mask =
5384 memcpy(action_vxlan_encap_data->item_vxlan.vni, vxlan_encap_conf.vni,
5385 RTE_DIM(vxlan_encap_conf.vni));
5389 /** Parse VXLAN encap action. */
5391 parse_vc_action_vxlan_encap(struct context *ctx, const struct token *token,
5392 const char *str, unsigned int len,
5393 void *buf, unsigned int size)
5395 struct buffer *out = buf;
5396 struct rte_flow_action *action;
5397 struct action_vxlan_encap_data *action_vxlan_encap_data;
5400 ret = parse_vc(ctx, token, str, len, buf, size);
5403 /* Nothing else to do if there is no buffer. */
5406 if (!out->args.vc.actions_n)
5408 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5409 /* Point to selected object. */
5410 ctx->object = out->args.vc.data;
5411 ctx->objmask = NULL;
5412 action_vxlan_encap_data = ctx->object;
5413 parse_setup_vxlan_encap_data(action_vxlan_encap_data);
5414 action->conf = &action_vxlan_encap_data->conf;
5418 /** Setup NVGRE encap configuration. */
5420 parse_setup_nvgre_encap_data(struct action_nvgre_encap_data *action_nvgre_encap_data)
5422 /* Set up default configuration. */
5423 *action_nvgre_encap_data = (struct action_nvgre_encap_data){
5424 .conf = (struct rte_flow_action_nvgre_encap){
5425 .definition = action_nvgre_encap_data->items,
5429 .type = RTE_FLOW_ITEM_TYPE_ETH,
5430 .spec = &action_nvgre_encap_data->item_eth,
5431 .mask = &rte_flow_item_eth_mask,
5434 .type = RTE_FLOW_ITEM_TYPE_VLAN,
5435 .spec = &action_nvgre_encap_data->item_vlan,
5436 .mask = &rte_flow_item_vlan_mask,
5439 .type = RTE_FLOW_ITEM_TYPE_IPV4,
5440 .spec = &action_nvgre_encap_data->item_ipv4,
5441 .mask = &rte_flow_item_ipv4_mask,
5444 .type = RTE_FLOW_ITEM_TYPE_NVGRE,
5445 .spec = &action_nvgre_encap_data->item_nvgre,
5446 .mask = &rte_flow_item_nvgre_mask,
5449 .type = RTE_FLOW_ITEM_TYPE_END,
5454 .tci = nvgre_encap_conf.vlan_tci,
5458 .src_addr = nvgre_encap_conf.ipv4_src,
5459 .dst_addr = nvgre_encap_conf.ipv4_dst,
5461 .item_nvgre.c_k_s_rsvd0_ver = RTE_BE16(0x2000),
5462 .item_nvgre.protocol = RTE_BE16(RTE_ETHER_TYPE_TEB),
5463 .item_nvgre.flow_id = 0,
5465 memcpy(action_nvgre_encap_data->item_eth.dst.addr_bytes,
5466 nvgre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5467 memcpy(action_nvgre_encap_data->item_eth.src.addr_bytes,
5468 nvgre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5469 if (!nvgre_encap_conf.select_ipv4) {
5470 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.src_addr,
5471 &nvgre_encap_conf.ipv6_src,
5472 sizeof(nvgre_encap_conf.ipv6_src));
5473 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.dst_addr,
5474 &nvgre_encap_conf.ipv6_dst,
5475 sizeof(nvgre_encap_conf.ipv6_dst));
5476 action_nvgre_encap_data->items[2] = (struct rte_flow_item){
5477 .type = RTE_FLOW_ITEM_TYPE_IPV6,
5478 .spec = &action_nvgre_encap_data->item_ipv6,
5479 .mask = &rte_flow_item_ipv6_mask,
5482 if (!nvgre_encap_conf.select_vlan)
5483 action_nvgre_encap_data->items[1].type =
5484 RTE_FLOW_ITEM_TYPE_VOID;
5485 memcpy(action_nvgre_encap_data->item_nvgre.tni, nvgre_encap_conf.tni,
5486 RTE_DIM(nvgre_encap_conf.tni));
5490 /** Parse NVGRE encap action. */
5492 parse_vc_action_nvgre_encap(struct context *ctx, const struct token *token,
5493 const char *str, unsigned int len,
5494 void *buf, unsigned int size)
5496 struct buffer *out = buf;
5497 struct rte_flow_action *action;
5498 struct action_nvgre_encap_data *action_nvgre_encap_data;
5501 ret = parse_vc(ctx, token, str, len, buf, size);
5504 /* Nothing else to do if there is no buffer. */
5507 if (!out->args.vc.actions_n)
5509 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5510 /* Point to selected object. */
5511 ctx->object = out->args.vc.data;
5512 ctx->objmask = NULL;
5513 action_nvgre_encap_data = ctx->object;
5514 parse_setup_nvgre_encap_data(action_nvgre_encap_data);
5515 action->conf = &action_nvgre_encap_data->conf;
5519 /** Parse l2 encap action. */
5521 parse_vc_action_l2_encap(struct context *ctx, const struct token *token,
5522 const char *str, unsigned int len,
5523 void *buf, unsigned int size)
5525 struct buffer *out = buf;
5526 struct rte_flow_action *action;
5527 struct action_raw_encap_data *action_encap_data;
5528 struct rte_flow_item_eth eth = { .type = 0, };
5529 struct rte_flow_item_vlan vlan = {
5530 .tci = mplsoudp_encap_conf.vlan_tci,
5536 ret = parse_vc(ctx, token, str, len, buf, size);
5539 /* Nothing else to do if there is no buffer. */
5542 if (!out->args.vc.actions_n)
5544 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5545 /* Point to selected object. */
5546 ctx->object = out->args.vc.data;
5547 ctx->objmask = NULL;
5548 /* Copy the headers to the buffer. */
5549 action_encap_data = ctx->object;
5550 *action_encap_data = (struct action_raw_encap_data) {
5551 .conf = (struct rte_flow_action_raw_encap){
5552 .data = action_encap_data->data,
5556 header = action_encap_data->data;
5557 if (l2_encap_conf.select_vlan)
5558 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5559 else if (l2_encap_conf.select_ipv4)
5560 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5562 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5563 memcpy(eth.dst.addr_bytes,
5564 l2_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5565 memcpy(eth.src.addr_bytes,
5566 l2_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5567 memcpy(header, ð, sizeof(eth));
5568 header += sizeof(eth);
5569 if (l2_encap_conf.select_vlan) {
5570 if (l2_encap_conf.select_ipv4)
5571 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5573 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5574 memcpy(header, &vlan, sizeof(vlan));
5575 header += sizeof(vlan);
5577 action_encap_data->conf.size = header -
5578 action_encap_data->data;
5579 action->conf = &action_encap_data->conf;
5583 /** Parse l2 decap action. */
5585 parse_vc_action_l2_decap(struct context *ctx, const struct token *token,
5586 const char *str, unsigned int len,
5587 void *buf, unsigned int size)
5589 struct buffer *out = buf;
5590 struct rte_flow_action *action;
5591 struct action_raw_decap_data *action_decap_data;
5592 struct rte_flow_item_eth eth = { .type = 0, };
5593 struct rte_flow_item_vlan vlan = {
5594 .tci = mplsoudp_encap_conf.vlan_tci,
5600 ret = parse_vc(ctx, token, str, len, buf, size);
5603 /* Nothing else to do if there is no buffer. */
5606 if (!out->args.vc.actions_n)
5608 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5609 /* Point to selected object. */
5610 ctx->object = out->args.vc.data;
5611 ctx->objmask = NULL;
5612 /* Copy the headers to the buffer. */
5613 action_decap_data = ctx->object;
5614 *action_decap_data = (struct action_raw_decap_data) {
5615 .conf = (struct rte_flow_action_raw_decap){
5616 .data = action_decap_data->data,
5620 header = action_decap_data->data;
5621 if (l2_decap_conf.select_vlan)
5622 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5623 memcpy(header, ð, sizeof(eth));
5624 header += sizeof(eth);
5625 if (l2_decap_conf.select_vlan) {
5626 memcpy(header, &vlan, sizeof(vlan));
5627 header += sizeof(vlan);
5629 action_decap_data->conf.size = header -
5630 action_decap_data->data;
5631 action->conf = &action_decap_data->conf;
5635 #define ETHER_TYPE_MPLS_UNICAST 0x8847
5637 /** Parse MPLSOGRE encap action. */
5639 parse_vc_action_mplsogre_encap(struct context *ctx, const struct token *token,
5640 const char *str, unsigned int len,
5641 void *buf, unsigned int size)
5643 struct buffer *out = buf;
5644 struct rte_flow_action *action;
5645 struct action_raw_encap_data *action_encap_data;
5646 struct rte_flow_item_eth eth = { .type = 0, };
5647 struct rte_flow_item_vlan vlan = {
5648 .tci = mplsogre_encap_conf.vlan_tci,
5651 struct rte_flow_item_ipv4 ipv4 = {
5653 .src_addr = mplsogre_encap_conf.ipv4_src,
5654 .dst_addr = mplsogre_encap_conf.ipv4_dst,
5655 .next_proto_id = IPPROTO_GRE,
5656 .version_ihl = RTE_IPV4_VHL_DEF,
5657 .time_to_live = IPDEFTTL,
5660 struct rte_flow_item_ipv6 ipv6 = {
5662 .proto = IPPROTO_GRE,
5663 .hop_limits = IPDEFTTL,
5666 struct rte_flow_item_gre gre = {
5667 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
5669 struct rte_flow_item_mpls mpls = {
5675 ret = parse_vc(ctx, token, str, len, buf, size);
5678 /* Nothing else to do if there is no buffer. */
5681 if (!out->args.vc.actions_n)
5683 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5684 /* Point to selected object. */
5685 ctx->object = out->args.vc.data;
5686 ctx->objmask = NULL;
5687 /* Copy the headers to the buffer. */
5688 action_encap_data = ctx->object;
5689 *action_encap_data = (struct action_raw_encap_data) {
5690 .conf = (struct rte_flow_action_raw_encap){
5691 .data = action_encap_data->data,
5696 header = action_encap_data->data;
5697 if (mplsogre_encap_conf.select_vlan)
5698 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5699 else if (mplsogre_encap_conf.select_ipv4)
5700 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5702 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5703 memcpy(eth.dst.addr_bytes,
5704 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5705 memcpy(eth.src.addr_bytes,
5706 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5707 memcpy(header, ð, sizeof(eth));
5708 header += sizeof(eth);
5709 if (mplsogre_encap_conf.select_vlan) {
5710 if (mplsogre_encap_conf.select_ipv4)
5711 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5713 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5714 memcpy(header, &vlan, sizeof(vlan));
5715 header += sizeof(vlan);
5717 if (mplsogre_encap_conf.select_ipv4) {
5718 memcpy(header, &ipv4, sizeof(ipv4));
5719 header += sizeof(ipv4);
5721 memcpy(&ipv6.hdr.src_addr,
5722 &mplsogre_encap_conf.ipv6_src,
5723 sizeof(mplsogre_encap_conf.ipv6_src));
5724 memcpy(&ipv6.hdr.dst_addr,
5725 &mplsogre_encap_conf.ipv6_dst,
5726 sizeof(mplsogre_encap_conf.ipv6_dst));
5727 memcpy(header, &ipv6, sizeof(ipv6));
5728 header += sizeof(ipv6);
5730 memcpy(header, &gre, sizeof(gre));
5731 header += sizeof(gre);
5732 memcpy(mpls.label_tc_s, mplsogre_encap_conf.label,
5733 RTE_DIM(mplsogre_encap_conf.label));
5734 mpls.label_tc_s[2] |= 0x1;
5735 memcpy(header, &mpls, sizeof(mpls));
5736 header += sizeof(mpls);
5737 action_encap_data->conf.size = header -
5738 action_encap_data->data;
5739 action->conf = &action_encap_data->conf;
5743 /** Parse MPLSOGRE decap action. */
5745 parse_vc_action_mplsogre_decap(struct context *ctx, const struct token *token,
5746 const char *str, unsigned int len,
5747 void *buf, unsigned int size)
5749 struct buffer *out = buf;
5750 struct rte_flow_action *action;
5751 struct action_raw_decap_data *action_decap_data;
5752 struct rte_flow_item_eth eth = { .type = 0, };
5753 struct rte_flow_item_vlan vlan = {.tci = 0};
5754 struct rte_flow_item_ipv4 ipv4 = {
5756 .next_proto_id = IPPROTO_GRE,
5759 struct rte_flow_item_ipv6 ipv6 = {
5761 .proto = IPPROTO_GRE,
5764 struct rte_flow_item_gre gre = {
5765 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
5767 struct rte_flow_item_mpls mpls;
5771 ret = parse_vc(ctx, token, str, len, buf, size);
5774 /* Nothing else to do if there is no buffer. */
5777 if (!out->args.vc.actions_n)
5779 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5780 /* Point to selected object. */
5781 ctx->object = out->args.vc.data;
5782 ctx->objmask = NULL;
5783 /* Copy the headers to the buffer. */
5784 action_decap_data = ctx->object;
5785 *action_decap_data = (struct action_raw_decap_data) {
5786 .conf = (struct rte_flow_action_raw_decap){
5787 .data = action_decap_data->data,
5791 header = action_decap_data->data;
5792 if (mplsogre_decap_conf.select_vlan)
5793 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5794 else if (mplsogre_encap_conf.select_ipv4)
5795 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5797 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5798 memcpy(eth.dst.addr_bytes,
5799 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5800 memcpy(eth.src.addr_bytes,
5801 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5802 memcpy(header, ð, sizeof(eth));
5803 header += sizeof(eth);
5804 if (mplsogre_encap_conf.select_vlan) {
5805 if (mplsogre_encap_conf.select_ipv4)
5806 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5808 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5809 memcpy(header, &vlan, sizeof(vlan));
5810 header += sizeof(vlan);
5812 if (mplsogre_encap_conf.select_ipv4) {
5813 memcpy(header, &ipv4, sizeof(ipv4));
5814 header += sizeof(ipv4);
5816 memcpy(header, &ipv6, sizeof(ipv6));
5817 header += sizeof(ipv6);
5819 memcpy(header, &gre, sizeof(gre));
5820 header += sizeof(gre);
5821 memset(&mpls, 0, sizeof(mpls));
5822 memcpy(header, &mpls, sizeof(mpls));
5823 header += sizeof(mpls);
5824 action_decap_data->conf.size = header -
5825 action_decap_data->data;
5826 action->conf = &action_decap_data->conf;
5830 /** Parse MPLSOUDP encap action. */
5832 parse_vc_action_mplsoudp_encap(struct context *ctx, const struct token *token,
5833 const char *str, unsigned int len,
5834 void *buf, unsigned int size)
5836 struct buffer *out = buf;
5837 struct rte_flow_action *action;
5838 struct action_raw_encap_data *action_encap_data;
5839 struct rte_flow_item_eth eth = { .type = 0, };
5840 struct rte_flow_item_vlan vlan = {
5841 .tci = mplsoudp_encap_conf.vlan_tci,
5844 struct rte_flow_item_ipv4 ipv4 = {
5846 .src_addr = mplsoudp_encap_conf.ipv4_src,
5847 .dst_addr = mplsoudp_encap_conf.ipv4_dst,
5848 .next_proto_id = IPPROTO_UDP,
5849 .version_ihl = RTE_IPV4_VHL_DEF,
5850 .time_to_live = IPDEFTTL,
5853 struct rte_flow_item_ipv6 ipv6 = {
5855 .proto = IPPROTO_UDP,
5856 .hop_limits = IPDEFTTL,
5859 struct rte_flow_item_udp udp = {
5861 .src_port = mplsoudp_encap_conf.udp_src,
5862 .dst_port = mplsoudp_encap_conf.udp_dst,
5865 struct rte_flow_item_mpls mpls;
5869 ret = parse_vc(ctx, token, str, len, buf, size);
5872 /* Nothing else to do if there is no buffer. */
5875 if (!out->args.vc.actions_n)
5877 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5878 /* Point to selected object. */
5879 ctx->object = out->args.vc.data;
5880 ctx->objmask = NULL;
5881 /* Copy the headers to the buffer. */
5882 action_encap_data = ctx->object;
5883 *action_encap_data = (struct action_raw_encap_data) {
5884 .conf = (struct rte_flow_action_raw_encap){
5885 .data = action_encap_data->data,
5890 header = action_encap_data->data;
5891 if (mplsoudp_encap_conf.select_vlan)
5892 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5893 else if (mplsoudp_encap_conf.select_ipv4)
5894 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5896 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5897 memcpy(eth.dst.addr_bytes,
5898 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5899 memcpy(eth.src.addr_bytes,
5900 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5901 memcpy(header, ð, sizeof(eth));
5902 header += sizeof(eth);
5903 if (mplsoudp_encap_conf.select_vlan) {
5904 if (mplsoudp_encap_conf.select_ipv4)
5905 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5907 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5908 memcpy(header, &vlan, sizeof(vlan));
5909 header += sizeof(vlan);
5911 if (mplsoudp_encap_conf.select_ipv4) {
5912 memcpy(header, &ipv4, sizeof(ipv4));
5913 header += sizeof(ipv4);
5915 memcpy(&ipv6.hdr.src_addr,
5916 &mplsoudp_encap_conf.ipv6_src,
5917 sizeof(mplsoudp_encap_conf.ipv6_src));
5918 memcpy(&ipv6.hdr.dst_addr,
5919 &mplsoudp_encap_conf.ipv6_dst,
5920 sizeof(mplsoudp_encap_conf.ipv6_dst));
5921 memcpy(header, &ipv6, sizeof(ipv6));
5922 header += sizeof(ipv6);
5924 memcpy(header, &udp, sizeof(udp));
5925 header += sizeof(udp);
5926 memcpy(mpls.label_tc_s, mplsoudp_encap_conf.label,
5927 RTE_DIM(mplsoudp_encap_conf.label));
5928 mpls.label_tc_s[2] |= 0x1;
5929 memcpy(header, &mpls, sizeof(mpls));
5930 header += sizeof(mpls);
5931 action_encap_data->conf.size = header -
5932 action_encap_data->data;
5933 action->conf = &action_encap_data->conf;
5937 /** Parse MPLSOUDP decap action. */
5939 parse_vc_action_mplsoudp_decap(struct context *ctx, const struct token *token,
5940 const char *str, unsigned int len,
5941 void *buf, unsigned int size)
5943 struct buffer *out = buf;
5944 struct rte_flow_action *action;
5945 struct action_raw_decap_data *action_decap_data;
5946 struct rte_flow_item_eth eth = { .type = 0, };
5947 struct rte_flow_item_vlan vlan = {.tci = 0};
5948 struct rte_flow_item_ipv4 ipv4 = {
5950 .next_proto_id = IPPROTO_UDP,
5953 struct rte_flow_item_ipv6 ipv6 = {
5955 .proto = IPPROTO_UDP,
5958 struct rte_flow_item_udp udp = {
5960 .dst_port = rte_cpu_to_be_16(6635),
5963 struct rte_flow_item_mpls mpls;
5967 ret = parse_vc(ctx, token, str, len, buf, size);
5970 /* Nothing else to do if there is no buffer. */
5973 if (!out->args.vc.actions_n)
5975 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5976 /* Point to selected object. */
5977 ctx->object = out->args.vc.data;
5978 ctx->objmask = NULL;
5979 /* Copy the headers to the buffer. */
5980 action_decap_data = ctx->object;
5981 *action_decap_data = (struct action_raw_decap_data) {
5982 .conf = (struct rte_flow_action_raw_decap){
5983 .data = action_decap_data->data,
5987 header = action_decap_data->data;
5988 if (mplsoudp_decap_conf.select_vlan)
5989 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5990 else if (mplsoudp_encap_conf.select_ipv4)
5991 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5993 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5994 memcpy(eth.dst.addr_bytes,
5995 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5996 memcpy(eth.src.addr_bytes,
5997 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5998 memcpy(header, ð, sizeof(eth));
5999 header += sizeof(eth);
6000 if (mplsoudp_encap_conf.select_vlan) {
6001 if (mplsoudp_encap_conf.select_ipv4)
6002 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
6004 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
6005 memcpy(header, &vlan, sizeof(vlan));
6006 header += sizeof(vlan);
6008 if (mplsoudp_encap_conf.select_ipv4) {
6009 memcpy(header, &ipv4, sizeof(ipv4));
6010 header += sizeof(ipv4);
6012 memcpy(header, &ipv6, sizeof(ipv6));
6013 header += sizeof(ipv6);
6015 memcpy(header, &udp, sizeof(udp));
6016 header += sizeof(udp);
6017 memset(&mpls, 0, sizeof(mpls));
6018 memcpy(header, &mpls, sizeof(mpls));
6019 header += sizeof(mpls);
6020 action_decap_data->conf.size = header -
6021 action_decap_data->data;
6022 action->conf = &action_decap_data->conf;
6027 parse_vc_action_raw_decap_index(struct context *ctx, const struct token *token,
6028 const char *str, unsigned int len, void *buf,
6031 struct action_raw_decap_data *action_raw_decap_data;
6032 struct rte_flow_action *action;
6033 const struct arg *arg;
6034 struct buffer *out = buf;
6038 RTE_SET_USED(token);
6041 arg = ARGS_ENTRY_ARB_BOUNDED
6042 (offsetof(struct action_raw_decap_data, idx),
6043 sizeof(((struct action_raw_decap_data *)0)->idx),
6044 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
6045 if (push_args(ctx, arg))
6047 ret = parse_int(ctx, token, str, len, NULL, 0);
6054 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6055 action_raw_decap_data = ctx->object;
6056 idx = action_raw_decap_data->idx;
6057 action_raw_decap_data->conf.data = raw_decap_confs[idx].data;
6058 action_raw_decap_data->conf.size = raw_decap_confs[idx].size;
6059 action->conf = &action_raw_decap_data->conf;
6065 parse_vc_action_raw_encap_index(struct context *ctx, const struct token *token,
6066 const char *str, unsigned int len, void *buf,
6069 struct action_raw_encap_data *action_raw_encap_data;
6070 struct rte_flow_action *action;
6071 const struct arg *arg;
6072 struct buffer *out = buf;
6076 RTE_SET_USED(token);
6079 if (ctx->curr != ACTION_RAW_ENCAP_INDEX_VALUE)
6081 arg = ARGS_ENTRY_ARB_BOUNDED
6082 (offsetof(struct action_raw_encap_data, idx),
6083 sizeof(((struct action_raw_encap_data *)0)->idx),
6084 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
6085 if (push_args(ctx, arg))
6087 ret = parse_int(ctx, token, str, len, NULL, 0);
6094 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6095 action_raw_encap_data = ctx->object;
6096 idx = action_raw_encap_data->idx;
6097 action_raw_encap_data->conf.data = raw_encap_confs[idx].data;
6098 action_raw_encap_data->conf.size = raw_encap_confs[idx].size;
6099 action_raw_encap_data->conf.preserve = NULL;
6100 action->conf = &action_raw_encap_data->conf;
6105 parse_vc_action_raw_encap(struct context *ctx, const struct token *token,
6106 const char *str, unsigned int len, void *buf,
6109 struct buffer *out = buf;
6110 struct rte_flow_action *action;
6111 struct action_raw_encap_data *action_raw_encap_data = NULL;
6114 ret = parse_vc(ctx, token, str, len, buf, size);
6117 /* Nothing else to do if there is no buffer. */
6120 if (!out->args.vc.actions_n)
6122 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6123 /* Point to selected object. */
6124 ctx->object = out->args.vc.data;
6125 ctx->objmask = NULL;
6126 /* Copy the headers to the buffer. */
6127 action_raw_encap_data = ctx->object;
6128 action_raw_encap_data->conf.data = raw_encap_confs[0].data;
6129 action_raw_encap_data->conf.preserve = NULL;
6130 action_raw_encap_data->conf.size = raw_encap_confs[0].size;
6131 action->conf = &action_raw_encap_data->conf;
6136 parse_vc_action_raw_decap(struct context *ctx, const struct token *token,
6137 const char *str, unsigned int len, void *buf,
6140 struct buffer *out = buf;
6141 struct rte_flow_action *action;
6142 struct action_raw_decap_data *action_raw_decap_data = NULL;
6145 ret = parse_vc(ctx, token, str, len, buf, size);
6148 /* Nothing else to do if there is no buffer. */
6151 if (!out->args.vc.actions_n)
6153 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6154 /* Point to selected object. */
6155 ctx->object = out->args.vc.data;
6156 ctx->objmask = NULL;
6157 /* Copy the headers to the buffer. */
6158 action_raw_decap_data = ctx->object;
6159 action_raw_decap_data->conf.data = raw_decap_confs[0].data;
6160 action_raw_decap_data->conf.size = raw_decap_confs[0].size;
6161 action->conf = &action_raw_decap_data->conf;
6166 parse_vc_action_set_meta(struct context *ctx, const struct token *token,
6167 const char *str, unsigned int len, void *buf,
6172 ret = parse_vc(ctx, token, str, len, buf, size);
6175 ret = rte_flow_dynf_metadata_register();
6182 parse_vc_action_sample(struct context *ctx, const struct token *token,
6183 const char *str, unsigned int len, void *buf,
6186 struct buffer *out = buf;
6187 struct rte_flow_action *action;
6188 struct action_sample_data *action_sample_data = NULL;
6189 static struct rte_flow_action end_action = {
6190 RTE_FLOW_ACTION_TYPE_END, 0
6194 ret = parse_vc(ctx, token, str, len, buf, size);
6197 /* Nothing else to do if there is no buffer. */
6200 if (!out->args.vc.actions_n)
6202 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6203 /* Point to selected object. */
6204 ctx->object = out->args.vc.data;
6205 ctx->objmask = NULL;
6206 /* Copy the headers to the buffer. */
6207 action_sample_data = ctx->object;
6208 action_sample_data->conf.actions = &end_action;
6209 action->conf = &action_sample_data->conf;
6214 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
6215 const char *str, unsigned int len, void *buf,
6218 struct action_sample_data *action_sample_data;
6219 struct rte_flow_action *action;
6220 const struct arg *arg;
6221 struct buffer *out = buf;
6225 RTE_SET_USED(token);
6228 if (ctx->curr != ACTION_SAMPLE_INDEX_VALUE)
6230 arg = ARGS_ENTRY_ARB_BOUNDED
6231 (offsetof(struct action_sample_data, idx),
6232 sizeof(((struct action_sample_data *)0)->idx),
6233 0, RAW_SAMPLE_CONFS_MAX_NUM - 1);
6234 if (push_args(ctx, arg))
6236 ret = parse_int(ctx, token, str, len, NULL, 0);
6243 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6244 action_sample_data = ctx->object;
6245 idx = action_sample_data->idx;
6246 action_sample_data->conf.actions = raw_sample_confs[idx].data;
6247 action->conf = &action_sample_data->conf;
6251 /** Parse operation for modify_field command. */
6253 parse_vc_modify_field_op(struct context *ctx, const struct token *token,
6254 const char *str, unsigned int len, void *buf,
6257 struct rte_flow_action_modify_field *action_modify_field;
6263 if (ctx->curr != ACTION_MODIFY_FIELD_OP_VALUE)
6265 for (i = 0; modify_field_ops[i]; ++i)
6266 if (!strcmp_partial(modify_field_ops[i], str, len))
6268 if (!modify_field_ops[i])
6272 action_modify_field = ctx->object;
6273 action_modify_field->operation = (enum rte_flow_modify_op)i;
6277 /** Parse id for modify_field command. */
6279 parse_vc_modify_field_id(struct context *ctx, const struct token *token,
6280 const char *str, unsigned int len, void *buf,
6283 struct rte_flow_action_modify_field *action_modify_field;
6289 if (ctx->curr != ACTION_MODIFY_FIELD_DST_TYPE_VALUE &&
6290 ctx->curr != ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)
6292 for (i = 0; modify_field_ids[i]; ++i)
6293 if (!strcmp_partial(modify_field_ids[i], str, len))
6295 if (!modify_field_ids[i])
6299 action_modify_field = ctx->object;
6300 if (ctx->curr == ACTION_MODIFY_FIELD_DST_TYPE_VALUE)
6301 action_modify_field->dst.field = (enum rte_flow_field_id)i;
6303 action_modify_field->src.field = (enum rte_flow_field_id)i;
6307 /** Parse tokens for destroy command. */
6309 parse_destroy(struct context *ctx, const struct token *token,
6310 const char *str, unsigned int len,
6311 void *buf, unsigned int size)
6313 struct buffer *out = buf;
6315 /* Token name must match. */
6316 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6318 /* Nothing else to do if there is no buffer. */
6321 if (!out->command) {
6322 if (ctx->curr != DESTROY)
6324 if (sizeof(*out) > size)
6326 out->command = ctx->curr;
6329 ctx->objmask = NULL;
6330 out->args.destroy.rule =
6331 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6335 if (((uint8_t *)(out->args.destroy.rule + out->args.destroy.rule_n) +
6336 sizeof(*out->args.destroy.rule)) > (uint8_t *)out + size)
6339 ctx->object = out->args.destroy.rule + out->args.destroy.rule_n++;
6340 ctx->objmask = NULL;
6344 /** Parse tokens for flush command. */
6346 parse_flush(struct context *ctx, const struct token *token,
6347 const char *str, unsigned int len,
6348 void *buf, unsigned int size)
6350 struct buffer *out = buf;
6352 /* Token name must match. */
6353 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6355 /* Nothing else to do if there is no buffer. */
6358 if (!out->command) {
6359 if (ctx->curr != FLUSH)
6361 if (sizeof(*out) > size)
6363 out->command = ctx->curr;
6366 ctx->objmask = NULL;
6371 /** Parse tokens for dump command. */
6373 parse_dump(struct context *ctx, const struct token *token,
6374 const char *str, unsigned int len,
6375 void *buf, unsigned int size)
6377 struct buffer *out = buf;
6379 /* Token name must match. */
6380 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6382 /* Nothing else to do if there is no buffer. */
6385 if (!out->command) {
6386 if (ctx->curr != DUMP)
6388 if (sizeof(*out) > size)
6390 out->command = ctx->curr;
6393 ctx->objmask = NULL;
6396 switch (ctx->curr) {
6399 out->args.dump.mode = (ctx->curr == DUMP_ALL) ? true : false;
6400 out->command = ctx->curr;
6403 ctx->objmask = NULL;
6410 /** Parse tokens for query command. */
6412 parse_query(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 != QUERY)
6427 if (sizeof(*out) > size)
6429 out->command = ctx->curr;
6432 ctx->objmask = NULL;
6437 /** Parse action names. */
6439 parse_action(struct context *ctx, const struct token *token,
6440 const char *str, unsigned int len,
6441 void *buf, unsigned int size)
6443 struct buffer *out = buf;
6444 const struct arg *arg = pop_args(ctx);
6448 /* Argument is expected. */
6451 /* Parse action name. */
6452 for (i = 0; next_action[i]; ++i) {
6453 const struct parse_action_priv *priv;
6455 token = &token_list[next_action[i]];
6456 if (strcmp_partial(token->name, str, len))
6462 memcpy((uint8_t *)ctx->object + arg->offset,
6468 push_args(ctx, arg);
6472 /** Parse tokens for list command. */
6474 parse_list(struct context *ctx, const struct token *token,
6475 const char *str, unsigned int len,
6476 void *buf, unsigned int size)
6478 struct buffer *out = buf;
6480 /* Token name must match. */
6481 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6483 /* Nothing else to do if there is no buffer. */
6486 if (!out->command) {
6487 if (ctx->curr != LIST)
6489 if (sizeof(*out) > size)
6491 out->command = ctx->curr;
6494 ctx->objmask = NULL;
6495 out->args.list.group =
6496 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6500 if (((uint8_t *)(out->args.list.group + out->args.list.group_n) +
6501 sizeof(*out->args.list.group)) > (uint8_t *)out + size)
6504 ctx->object = out->args.list.group + out->args.list.group_n++;
6505 ctx->objmask = NULL;
6509 /** Parse tokens for list all aged flows command. */
6511 parse_aged(struct context *ctx, const struct token *token,
6512 const char *str, unsigned int len,
6513 void *buf, unsigned int size)
6515 struct buffer *out = buf;
6517 /* Token name must match. */
6518 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6520 /* Nothing else to do if there is no buffer. */
6523 if (!out->command) {
6524 if (ctx->curr != AGED)
6526 if (sizeof(*out) > size)
6528 out->command = ctx->curr;
6531 ctx->objmask = NULL;
6533 if (ctx->curr == AGED_DESTROY)
6534 out->args.aged.destroy = 1;
6538 /** Parse tokens for isolate command. */
6540 parse_isolate(struct context *ctx, const struct token *token,
6541 const char *str, unsigned int len,
6542 void *buf, unsigned int size)
6544 struct buffer *out = buf;
6546 /* Token name must match. */
6547 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6549 /* Nothing else to do if there is no buffer. */
6552 if (!out->command) {
6553 if (ctx->curr != ISOLATE)
6555 if (sizeof(*out) > size)
6557 out->command = ctx->curr;
6560 ctx->objmask = NULL;
6566 parse_tunnel(struct context *ctx, const struct token *token,
6567 const char *str, unsigned int len,
6568 void *buf, unsigned int size)
6570 struct buffer *out = buf;
6572 /* Token name must match. */
6573 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6575 /* Nothing else to do if there is no buffer. */
6578 if (!out->command) {
6579 if (ctx->curr != TUNNEL)
6581 if (sizeof(*out) > size)
6583 out->command = ctx->curr;
6586 ctx->objmask = NULL;
6588 switch (ctx->curr) {
6592 case TUNNEL_DESTROY:
6594 out->command = ctx->curr;
6596 case TUNNEL_CREATE_TYPE:
6597 case TUNNEL_DESTROY_ID:
6598 ctx->object = &out->args.vc.tunnel_ops;
6607 * Parse signed/unsigned integers 8 to 64-bit long.
6609 * Last argument (ctx->args) is retrieved to determine integer type and
6613 parse_int(struct context *ctx, const struct token *token,
6614 const char *str, unsigned int len,
6615 void *buf, unsigned int size)
6617 const struct arg *arg = pop_args(ctx);
6622 /* Argument is expected. */
6627 (uintmax_t)strtoimax(str, &end, 0) :
6628 strtoumax(str, &end, 0);
6629 if (errno || (size_t)(end - str) != len)
6632 ((arg->sign && ((intmax_t)u < (intmax_t)arg->min ||
6633 (intmax_t)u > (intmax_t)arg->max)) ||
6634 (!arg->sign && (u < arg->min || u > arg->max))))
6639 if (!arg_entry_bf_fill(ctx->object, u, arg) ||
6640 !arg_entry_bf_fill(ctx->objmask, -1, arg))
6644 buf = (uint8_t *)ctx->object + arg->offset;
6646 if (u > RTE_LEN2MASK(size * CHAR_BIT, uint64_t))
6650 case sizeof(uint8_t):
6651 *(uint8_t *)buf = u;
6653 case sizeof(uint16_t):
6654 *(uint16_t *)buf = arg->hton ? rte_cpu_to_be_16(u) : u;
6656 case sizeof(uint8_t [3]):
6657 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
6659 ((uint8_t *)buf)[0] = u;
6660 ((uint8_t *)buf)[1] = u >> 8;
6661 ((uint8_t *)buf)[2] = u >> 16;
6665 ((uint8_t *)buf)[0] = u >> 16;
6666 ((uint8_t *)buf)[1] = u >> 8;
6667 ((uint8_t *)buf)[2] = u;
6669 case sizeof(uint32_t):
6670 *(uint32_t *)buf = arg->hton ? rte_cpu_to_be_32(u) : u;
6672 case sizeof(uint64_t):
6673 *(uint64_t *)buf = arg->hton ? rte_cpu_to_be_64(u) : u;
6678 if (ctx->objmask && buf != (uint8_t *)ctx->objmask + arg->offset) {
6680 buf = (uint8_t *)ctx->objmask + arg->offset;
6685 push_args(ctx, arg);
6692 * Three arguments (ctx->args) are retrieved from the stack to store data,
6693 * its actual length and address (in that order).
6696 parse_string(struct context *ctx, const struct token *token,
6697 const char *str, unsigned int len,
6698 void *buf, unsigned int size)
6700 const struct arg *arg_data = pop_args(ctx);
6701 const struct arg *arg_len = pop_args(ctx);
6702 const struct arg *arg_addr = pop_args(ctx);
6703 char tmp[16]; /* Ought to be enough. */
6706 /* Arguments are expected. */
6710 push_args(ctx, arg_data);
6714 push_args(ctx, arg_len);
6715 push_args(ctx, arg_data);
6718 size = arg_data->size;
6719 /* Bit-mask fill is not supported. */
6720 if (arg_data->mask || size < len)
6724 /* Let parse_int() fill length information first. */
6725 ret = snprintf(tmp, sizeof(tmp), "%u", len);
6728 push_args(ctx, arg_len);
6729 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
6734 buf = (uint8_t *)ctx->object + arg_data->offset;
6735 /* Output buffer is not necessarily NUL-terminated. */
6736 memcpy(buf, str, len);
6737 memset((uint8_t *)buf + len, 0x00, size - len);
6739 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
6740 /* Save address if requested. */
6741 if (arg_addr->size) {
6742 memcpy((uint8_t *)ctx->object + arg_addr->offset,
6744 (uint8_t *)ctx->object + arg_data->offset
6748 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
6750 (uint8_t *)ctx->objmask + arg_data->offset
6756 push_args(ctx, arg_addr);
6757 push_args(ctx, arg_len);
6758 push_args(ctx, arg_data);
6763 parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
6769 /* Check input parameters */
6770 if ((src == NULL) ||
6776 /* Convert chars to bytes */
6777 for (i = 0, len = 0; i < *size; i += 2) {
6778 snprintf(tmp, 3, "%s", src + i);
6779 dst[len++] = strtoul(tmp, &c, 16);
6794 parse_hex(struct context *ctx, const struct token *token,
6795 const char *str, unsigned int len,
6796 void *buf, unsigned int size)
6798 const struct arg *arg_data = pop_args(ctx);
6799 const struct arg *arg_len = pop_args(ctx);
6800 const struct arg *arg_addr = pop_args(ctx);
6801 char tmp[16]; /* Ought to be enough. */
6803 unsigned int hexlen = len;
6804 unsigned int length = 256;
6805 uint8_t hex_tmp[length];
6807 /* Arguments are expected. */
6811 push_args(ctx, arg_data);
6815 push_args(ctx, arg_len);
6816 push_args(ctx, arg_data);
6819 size = arg_data->size;
6820 /* Bit-mask fill is not supported. */
6826 /* translate bytes string to array. */
6827 if (str[0] == '0' && ((str[1] == 'x') ||
6832 if (hexlen > length)
6834 ret = parse_hex_string(str, hex_tmp, &hexlen);
6837 /* Let parse_int() fill length information first. */
6838 ret = snprintf(tmp, sizeof(tmp), "%u", hexlen);
6841 /* Save length if requested. */
6842 if (arg_len->size) {
6843 push_args(ctx, arg_len);
6844 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
6850 buf = (uint8_t *)ctx->object + arg_data->offset;
6851 /* Output buffer is not necessarily NUL-terminated. */
6852 memcpy(buf, hex_tmp, hexlen);
6853 memset((uint8_t *)buf + hexlen, 0x00, size - hexlen);
6855 memset((uint8_t *)ctx->objmask + arg_data->offset,
6857 /* Save address if requested. */
6858 if (arg_addr->size) {
6859 memcpy((uint8_t *)ctx->object + arg_addr->offset,
6861 (uint8_t *)ctx->object + arg_data->offset
6865 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
6867 (uint8_t *)ctx->objmask + arg_data->offset
6873 push_args(ctx, arg_addr);
6874 push_args(ctx, arg_len);
6875 push_args(ctx, arg_data);
6881 * Parse a zero-ended string.
6884 parse_string0(struct context *ctx, const struct token *token __rte_unused,
6885 const char *str, unsigned int len,
6886 void *buf, unsigned int size)
6888 const struct arg *arg_data = pop_args(ctx);
6890 /* Arguments are expected. */
6893 size = arg_data->size;
6894 /* Bit-mask fill is not supported. */
6895 if (arg_data->mask || size < len + 1)
6899 buf = (uint8_t *)ctx->object + arg_data->offset;
6900 strncpy(buf, str, len);
6902 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
6905 push_args(ctx, arg_data);
6910 * Parse a MAC address.
6912 * Last argument (ctx->args) is retrieved to determine storage size and
6916 parse_mac_addr(struct context *ctx, const struct token *token,
6917 const char *str, unsigned int len,
6918 void *buf, unsigned int size)
6920 const struct arg *arg = pop_args(ctx);
6921 struct rte_ether_addr tmp;
6925 /* Argument is expected. */
6929 /* Bit-mask fill is not supported. */
6930 if (arg->mask || size != sizeof(tmp))
6932 /* Only network endian is supported. */
6935 ret = cmdline_parse_etheraddr(NULL, str, &tmp, size);
6936 if (ret < 0 || (unsigned int)ret != len)
6940 buf = (uint8_t *)ctx->object + arg->offset;
6941 memcpy(buf, &tmp, size);
6943 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6946 push_args(ctx, arg);
6951 * Parse an IPv4 address.
6953 * Last argument (ctx->args) is retrieved to determine storage size and
6957 parse_ipv4_addr(struct context *ctx, const struct token *token,
6958 const char *str, unsigned int len,
6959 void *buf, unsigned int size)
6961 const struct arg *arg = pop_args(ctx);
6966 /* Argument is expected. */
6970 /* Bit-mask fill is not supported. */
6971 if (arg->mask || size != sizeof(tmp))
6973 /* Only network endian is supported. */
6976 memcpy(str2, str, len);
6978 ret = inet_pton(AF_INET, str2, &tmp);
6980 /* Attempt integer parsing. */
6981 push_args(ctx, arg);
6982 return parse_int(ctx, token, str, len, buf, size);
6986 buf = (uint8_t *)ctx->object + arg->offset;
6987 memcpy(buf, &tmp, size);
6989 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6992 push_args(ctx, arg);
6997 * Parse an IPv6 address.
6999 * Last argument (ctx->args) is retrieved to determine storage size and
7003 parse_ipv6_addr(struct context *ctx, const struct token *token,
7004 const char *str, unsigned int len,
7005 void *buf, unsigned int size)
7007 const struct arg *arg = pop_args(ctx);
7009 struct in6_addr tmp;
7013 /* Argument is expected. */
7017 /* Bit-mask fill is not supported. */
7018 if (arg->mask || size != sizeof(tmp))
7020 /* Only network endian is supported. */
7023 memcpy(str2, str, len);
7025 ret = inet_pton(AF_INET6, str2, &tmp);
7030 buf = (uint8_t *)ctx->object + arg->offset;
7031 memcpy(buf, &tmp, size);
7033 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
7036 push_args(ctx, arg);
7040 /** Boolean values (even indices stand for false). */
7041 static const char *const boolean_name[] = {
7051 * Parse a boolean value.
7053 * Last argument (ctx->args) is retrieved to determine storage size and
7057 parse_boolean(struct context *ctx, const struct token *token,
7058 const char *str, unsigned int len,
7059 void *buf, unsigned int size)
7061 const struct arg *arg = pop_args(ctx);
7065 /* Argument is expected. */
7068 for (i = 0; boolean_name[i]; ++i)
7069 if (!strcmp_partial(boolean_name[i], str, len))
7071 /* Process token as integer. */
7072 if (boolean_name[i])
7073 str = i & 1 ? "1" : "0";
7074 push_args(ctx, arg);
7075 ret = parse_int(ctx, token, str, strlen(str), buf, size);
7076 return ret > 0 ? (int)len : ret;
7079 /** Parse port and update context. */
7081 parse_port(struct context *ctx, const struct token *token,
7082 const char *str, unsigned int len,
7083 void *buf, unsigned int size)
7085 struct buffer *out = &(struct buffer){ .port = 0 };
7093 ctx->objmask = NULL;
7094 size = sizeof(*out);
7096 ret = parse_int(ctx, token, str, len, out, size);
7098 ctx->port = out->port;
7105 parse_sa_id2ptr(struct context *ctx, const struct token *token,
7106 const char *str, unsigned int len,
7107 void *buf, unsigned int size)
7109 struct rte_flow_action *action = ctx->object;
7117 ctx->objmask = NULL;
7118 ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
7119 ctx->object = action;
7120 if (ret != (int)len)
7122 /* set shared action */
7124 action->conf = port_shared_action_get_by_id(ctx->port, id);
7125 ret = (action->conf) ? ret : -1;
7130 /** Parse set command, initialize output buffer for subsequent tokens. */
7132 parse_set_raw_encap_decap(struct context *ctx, const struct token *token,
7133 const char *str, unsigned int len,
7134 void *buf, unsigned int size)
7136 struct buffer *out = buf;
7138 /* Token name must match. */
7139 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7141 /* Nothing else to do if there is no buffer. */
7144 /* Make sure buffer is large enough. */
7145 if (size < sizeof(*out))
7148 ctx->objmask = NULL;
7152 out->command = ctx->curr;
7153 /* For encap/decap we need is pattern */
7154 out->args.vc.pattern = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7159 /** Parse set command, initialize output buffer for subsequent tokens. */
7161 parse_set_sample_action(struct context *ctx, const struct token *token,
7162 const char *str, unsigned int len,
7163 void *buf, unsigned int size)
7165 struct buffer *out = buf;
7167 /* Token name must match. */
7168 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7170 /* Nothing else to do if there is no buffer. */
7173 /* Make sure buffer is large enough. */
7174 if (size < sizeof(*out))
7177 ctx->objmask = NULL;
7181 out->command = ctx->curr;
7182 /* For sampler we need is actions */
7183 out->args.vc.actions = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7189 * Parse set raw_encap/raw_decap command,
7190 * initialize output buffer for subsequent tokens.
7193 parse_set_init(struct context *ctx, const struct token *token,
7194 const char *str, unsigned int len,
7195 void *buf, unsigned int size)
7197 struct buffer *out = buf;
7199 /* Token name must match. */
7200 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7202 /* Nothing else to do if there is no buffer. */
7205 /* Make sure buffer is large enough. */
7206 if (size < sizeof(*out))
7208 /* Initialize buffer. */
7209 memset(out, 0x00, sizeof(*out));
7210 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
7213 ctx->objmask = NULL;
7214 if (!out->command) {
7215 if (ctx->curr != SET)
7217 if (sizeof(*out) > size)
7219 out->command = ctx->curr;
7220 out->args.vc.data = (uint8_t *)out + size;
7221 ctx->object = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7227 /** No completion. */
7229 comp_none(struct context *ctx, const struct token *token,
7230 unsigned int ent, char *buf, unsigned int size)
7240 /** Complete boolean values. */
7242 comp_boolean(struct context *ctx, const struct token *token,
7243 unsigned int ent, char *buf, unsigned int size)
7249 for (i = 0; boolean_name[i]; ++i)
7250 if (buf && i == ent)
7251 return strlcpy(buf, boolean_name[i], size);
7257 /** Complete action names. */
7259 comp_action(struct context *ctx, const struct token *token,
7260 unsigned int ent, char *buf, unsigned int size)
7266 for (i = 0; next_action[i]; ++i)
7267 if (buf && i == ent)
7268 return strlcpy(buf, token_list[next_action[i]].name,
7275 /** Complete available ports. */
7277 comp_port(struct context *ctx, const struct token *token,
7278 unsigned int ent, char *buf, unsigned int size)
7285 RTE_ETH_FOREACH_DEV(p) {
7286 if (buf && i == ent)
7287 return snprintf(buf, size, "%u", p);
7295 /** Complete available rule IDs. */
7297 comp_rule_id(struct context *ctx, const struct token *token,
7298 unsigned int ent, char *buf, unsigned int size)
7301 struct rte_port *port;
7302 struct port_flow *pf;
7305 if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
7306 ctx->port == (portid_t)RTE_PORT_ALL)
7308 port = &ports[ctx->port];
7309 for (pf = port->flow_list; pf != NULL; pf = pf->next) {
7310 if (buf && i == ent)
7311 return snprintf(buf, size, "%u", pf->id);
7319 /** Complete type field for RSS action. */
7321 comp_vc_action_rss_type(struct context *ctx, const struct token *token,
7322 unsigned int ent, char *buf, unsigned int size)
7328 for (i = 0; rss_type_table[i].str; ++i)
7333 return strlcpy(buf, rss_type_table[ent].str, size);
7335 return snprintf(buf, size, "end");
7339 /** Complete queue field for RSS action. */
7341 comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
7342 unsigned int ent, char *buf, unsigned int size)
7349 return snprintf(buf, size, "%u", ent);
7351 return snprintf(buf, size, "end");
7355 /** Complete index number for set raw_encap/raw_decap commands. */
7357 comp_set_raw_index(struct context *ctx, const struct token *token,
7358 unsigned int ent, char *buf, unsigned int size)
7364 RTE_SET_USED(token);
7365 for (idx = 0; idx < RAW_ENCAP_CONFS_MAX_NUM; ++idx) {
7366 if (buf && idx == ent)
7367 return snprintf(buf, size, "%u", idx);
7373 /** Complete index number for set raw_encap/raw_decap commands. */
7375 comp_set_sample_index(struct context *ctx, const struct token *token,
7376 unsigned int ent, char *buf, unsigned int size)
7382 RTE_SET_USED(token);
7383 for (idx = 0; idx < RAW_SAMPLE_CONFS_MAX_NUM; ++idx) {
7384 if (buf && idx == ent)
7385 return snprintf(buf, size, "%u", idx);
7391 /** Complete operation for modify_field command. */
7393 comp_set_modify_field_op(struct context *ctx, const struct token *token,
7394 unsigned int ent, char *buf, unsigned int size)
7399 RTE_SET_USED(token);
7400 for (idx = 0; modify_field_ops[idx]; ++idx)
7405 return strlcpy(buf, modify_field_ops[ent], size);
7409 /** Complete field id for modify_field command. */
7411 comp_set_modify_field_id(struct context *ctx, const struct token *token,
7412 unsigned int ent, char *buf, unsigned int size)
7417 RTE_SET_USED(token);
7418 for (idx = 0; modify_field_ids[idx]; ++idx)
7423 return strlcpy(buf, modify_field_ids[ent], size);
7427 /** Internal context. */
7428 static struct context cmd_flow_context;
7430 /** Global parser instance (cmdline API). */
7431 cmdline_parse_inst_t cmd_flow;
7432 cmdline_parse_inst_t cmd_set_raw;
7434 /** Initialize context. */
7436 cmd_flow_context_init(struct context *ctx)
7438 /* A full memset() is not necessary. */
7448 ctx->objmask = NULL;
7451 /** Parse a token (cmdline API). */
7453 cmd_flow_parse(cmdline_parse_token_hdr_t *hdr, const char *src, void *result,
7456 struct context *ctx = &cmd_flow_context;
7457 const struct token *token;
7458 const enum index *list;
7463 token = &token_list[ctx->curr];
7464 /* Check argument length. */
7467 for (len = 0; src[len]; ++len)
7468 if (src[len] == '#' || isspace(src[len]))
7472 /* Last argument and EOL detection. */
7473 for (i = len; src[i]; ++i)
7474 if (src[i] == '#' || src[i] == '\r' || src[i] == '\n')
7476 else if (!isspace(src[i])) {
7481 if (src[i] == '\r' || src[i] == '\n') {
7485 /* Initialize context if necessary. */
7486 if (!ctx->next_num) {
7489 ctx->next[ctx->next_num++] = token->next[0];
7491 /* Process argument through candidates. */
7492 ctx->prev = ctx->curr;
7493 list = ctx->next[ctx->next_num - 1];
7494 for (i = 0; list[i]; ++i) {
7495 const struct token *next = &token_list[list[i]];
7498 ctx->curr = list[i];
7500 tmp = next->call(ctx, next, src, len, result, size);
7502 tmp = parse_default(ctx, next, src, len, result, size);
7503 if (tmp == -1 || tmp != len)
7511 /* Push subsequent tokens if any. */
7513 for (i = 0; token->next[i]; ++i) {
7514 if (ctx->next_num == RTE_DIM(ctx->next))
7516 ctx->next[ctx->next_num++] = token->next[i];
7518 /* Push arguments if any. */
7520 for (i = 0; token->args[i]; ++i) {
7521 if (ctx->args_num == RTE_DIM(ctx->args))
7523 ctx->args[ctx->args_num++] = token->args[i];
7528 /** Return number of completion entries (cmdline API). */
7530 cmd_flow_complete_get_nb(cmdline_parse_token_hdr_t *hdr)
7532 struct context *ctx = &cmd_flow_context;
7533 const struct token *token = &token_list[ctx->curr];
7534 const enum index *list;
7538 /* Count number of tokens in current list. */
7540 list = ctx->next[ctx->next_num - 1];
7542 list = token->next[0];
7543 for (i = 0; list[i]; ++i)
7548 * If there is a single token, use its completion callback, otherwise
7549 * return the number of entries.
7551 token = &token_list[list[0]];
7552 if (i == 1 && token->comp) {
7553 /* Save index for cmd_flow_get_help(). */
7554 ctx->prev = list[0];
7555 return token->comp(ctx, token, 0, NULL, 0);
7560 /** Return a completion entry (cmdline API). */
7562 cmd_flow_complete_get_elt(cmdline_parse_token_hdr_t *hdr, int index,
7563 char *dst, unsigned int size)
7565 struct context *ctx = &cmd_flow_context;
7566 const struct token *token = &token_list[ctx->curr];
7567 const enum index *list;
7571 /* Count number of tokens in current list. */
7573 list = ctx->next[ctx->next_num - 1];
7575 list = token->next[0];
7576 for (i = 0; list[i]; ++i)
7580 /* If there is a single token, use its completion callback. */
7581 token = &token_list[list[0]];
7582 if (i == 1 && token->comp) {
7583 /* Save index for cmd_flow_get_help(). */
7584 ctx->prev = list[0];
7585 return token->comp(ctx, token, index, dst, size) < 0 ? -1 : 0;
7587 /* Otherwise make sure the index is valid and use defaults. */
7590 token = &token_list[list[index]];
7591 strlcpy(dst, token->name, size);
7592 /* Save index for cmd_flow_get_help(). */
7593 ctx->prev = list[index];
7597 /** Populate help strings for current token (cmdline API). */
7599 cmd_flow_get_help(cmdline_parse_token_hdr_t *hdr, char *dst, unsigned int size)
7601 struct context *ctx = &cmd_flow_context;
7602 const struct token *token = &token_list[ctx->prev];
7607 /* Set token type and update global help with details. */
7608 strlcpy(dst, (token->type ? token->type : "TOKEN"), size);
7610 cmd_flow.help_str = token->help;
7612 cmd_flow.help_str = token->name;
7616 /** Token definition template (cmdline API). */
7617 static struct cmdline_token_hdr cmd_flow_token_hdr = {
7618 .ops = &(struct cmdline_token_ops){
7619 .parse = cmd_flow_parse,
7620 .complete_get_nb = cmd_flow_complete_get_nb,
7621 .complete_get_elt = cmd_flow_complete_get_elt,
7622 .get_help = cmd_flow_get_help,
7627 /** Populate the next dynamic token. */
7629 cmd_flow_tok(cmdline_parse_token_hdr_t **hdr,
7630 cmdline_parse_token_hdr_t **hdr_inst)
7632 struct context *ctx = &cmd_flow_context;
7634 /* Always reinitialize context before requesting the first token. */
7635 if (!(hdr_inst - cmd_flow.tokens))
7636 cmd_flow_context_init(ctx);
7637 /* Return NULL when no more tokens are expected. */
7638 if (!ctx->next_num && ctx->curr) {
7642 /* Determine if command should end here. */
7643 if (ctx->eol && ctx->last && ctx->next_num) {
7644 const enum index *list = ctx->next[ctx->next_num - 1];
7647 for (i = 0; list[i]; ++i) {
7654 *hdr = &cmd_flow_token_hdr;
7657 /** Dispatch parsed buffer to function calls. */
7659 cmd_flow_parsed(const struct buffer *in)
7661 switch (in->command) {
7662 case SHARED_ACTION_CREATE:
7663 port_shared_action_create(
7664 in->port, in->args.vc.attr.group,
7665 &((const struct rte_flow_shared_action_conf) {
7666 .ingress = in->args.vc.attr.ingress,
7667 .egress = in->args.vc.attr.egress,
7668 .transfer = in->args.vc.attr.transfer,
7670 in->args.vc.actions);
7672 case SHARED_ACTION_DESTROY:
7673 port_shared_action_destroy(in->port,
7674 in->args.sa_destroy.action_id_n,
7675 in->args.sa_destroy.action_id);
7677 case SHARED_ACTION_UPDATE:
7678 port_shared_action_update(in->port, in->args.vc.attr.group,
7679 in->args.vc.actions);
7681 case SHARED_ACTION_QUERY:
7682 port_shared_action_query(in->port, in->args.sa.action_id);
7685 port_flow_validate(in->port, &in->args.vc.attr,
7686 in->args.vc.pattern, in->args.vc.actions,
7687 &in->args.vc.tunnel_ops);
7690 port_flow_create(in->port, &in->args.vc.attr,
7691 in->args.vc.pattern, in->args.vc.actions,
7692 &in->args.vc.tunnel_ops);
7695 port_flow_destroy(in->port, in->args.destroy.rule_n,
7696 in->args.destroy.rule);
7699 port_flow_flush(in->port);
7703 port_flow_dump(in->port, in->args.dump.mode,
7704 in->args.dump.rule, in->args.dump.file);
7707 port_flow_query(in->port, in->args.query.rule,
7708 &in->args.query.action);
7711 port_flow_list(in->port, in->args.list.group_n,
7712 in->args.list.group);
7715 port_flow_isolate(in->port, in->args.isolate.set);
7718 port_flow_aged(in->port, in->args.aged.destroy);
7721 port_flow_tunnel_create(in->port, &in->args.vc.tunnel_ops);
7723 case TUNNEL_DESTROY:
7724 port_flow_tunnel_destroy(in->port, in->args.vc.tunnel_ops.id);
7727 port_flow_tunnel_list(in->port);
7734 /** Token generator and output processing callback (cmdline API). */
7736 cmd_flow_cb(void *arg0, struct cmdline *cl, void *arg2)
7739 cmd_flow_tok(arg0, arg2);
7741 cmd_flow_parsed(arg0);
7744 /** Global parser instance (cmdline API). */
7745 cmdline_parse_inst_t cmd_flow = {
7747 .data = NULL, /**< Unused. */
7748 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
7751 }, /**< Tokens are returned by cmd_flow_tok(). */
7754 /** set cmd facility. Reuse cmd flow's infrastructure as much as possible. */
7757 update_fields(uint8_t *buf, struct rte_flow_item *item, uint16_t next_proto)
7759 struct rte_ipv4_hdr *ipv4;
7760 struct rte_ether_hdr *eth;
7761 struct rte_ipv6_hdr *ipv6;
7762 struct rte_vxlan_hdr *vxlan;
7763 struct rte_vxlan_gpe_hdr *gpe;
7764 struct rte_flow_item_nvgre *nvgre;
7765 uint32_t ipv6_vtc_flow;
7767 switch (item->type) {
7768 case RTE_FLOW_ITEM_TYPE_ETH:
7769 eth = (struct rte_ether_hdr *)buf;
7771 eth->ether_type = rte_cpu_to_be_16(next_proto);
7773 case RTE_FLOW_ITEM_TYPE_IPV4:
7774 ipv4 = (struct rte_ipv4_hdr *)buf;
7775 ipv4->version_ihl = 0x45;
7776 if (next_proto && ipv4->next_proto_id == 0)
7777 ipv4->next_proto_id = (uint8_t)next_proto;
7779 case RTE_FLOW_ITEM_TYPE_IPV6:
7780 ipv6 = (struct rte_ipv6_hdr *)buf;
7781 if (next_proto && ipv6->proto == 0)
7782 ipv6->proto = (uint8_t)next_proto;
7783 ipv6_vtc_flow = rte_be_to_cpu_32(ipv6->vtc_flow);
7784 ipv6_vtc_flow &= 0x0FFFFFFF; /*< reset version bits. */
7785 ipv6_vtc_flow |= 0x60000000; /*< set ipv6 version. */
7786 ipv6->vtc_flow = rte_cpu_to_be_32(ipv6_vtc_flow);
7788 case RTE_FLOW_ITEM_TYPE_VXLAN:
7789 vxlan = (struct rte_vxlan_hdr *)buf;
7790 vxlan->vx_flags = 0x08;
7792 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
7793 gpe = (struct rte_vxlan_gpe_hdr *)buf;
7794 gpe->vx_flags = 0x0C;
7796 case RTE_FLOW_ITEM_TYPE_NVGRE:
7797 nvgre = (struct rte_flow_item_nvgre *)buf;
7798 nvgre->protocol = rte_cpu_to_be_16(0x6558);
7799 nvgre->c_k_s_rsvd0_ver = rte_cpu_to_be_16(0x2000);
7806 /** Helper of get item's default mask. */
7808 flow_item_default_mask(const struct rte_flow_item *item)
7810 const void *mask = NULL;
7811 static rte_be32_t gre_key_default_mask = RTE_BE32(UINT32_MAX);
7813 switch (item->type) {
7814 case RTE_FLOW_ITEM_TYPE_ANY:
7815 mask = &rte_flow_item_any_mask;
7817 case RTE_FLOW_ITEM_TYPE_VF:
7818 mask = &rte_flow_item_vf_mask;
7820 case RTE_FLOW_ITEM_TYPE_PORT_ID:
7821 mask = &rte_flow_item_port_id_mask;
7823 case RTE_FLOW_ITEM_TYPE_RAW:
7824 mask = &rte_flow_item_raw_mask;
7826 case RTE_FLOW_ITEM_TYPE_ETH:
7827 mask = &rte_flow_item_eth_mask;
7829 case RTE_FLOW_ITEM_TYPE_VLAN:
7830 mask = &rte_flow_item_vlan_mask;
7832 case RTE_FLOW_ITEM_TYPE_IPV4:
7833 mask = &rte_flow_item_ipv4_mask;
7835 case RTE_FLOW_ITEM_TYPE_IPV6:
7836 mask = &rte_flow_item_ipv6_mask;
7838 case RTE_FLOW_ITEM_TYPE_ICMP:
7839 mask = &rte_flow_item_icmp_mask;
7841 case RTE_FLOW_ITEM_TYPE_UDP:
7842 mask = &rte_flow_item_udp_mask;
7844 case RTE_FLOW_ITEM_TYPE_TCP:
7845 mask = &rte_flow_item_tcp_mask;
7847 case RTE_FLOW_ITEM_TYPE_SCTP:
7848 mask = &rte_flow_item_sctp_mask;
7850 case RTE_FLOW_ITEM_TYPE_VXLAN:
7851 mask = &rte_flow_item_vxlan_mask;
7853 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
7854 mask = &rte_flow_item_vxlan_gpe_mask;
7856 case RTE_FLOW_ITEM_TYPE_E_TAG:
7857 mask = &rte_flow_item_e_tag_mask;
7859 case RTE_FLOW_ITEM_TYPE_NVGRE:
7860 mask = &rte_flow_item_nvgre_mask;
7862 case RTE_FLOW_ITEM_TYPE_MPLS:
7863 mask = &rte_flow_item_mpls_mask;
7865 case RTE_FLOW_ITEM_TYPE_GRE:
7866 mask = &rte_flow_item_gre_mask;
7868 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
7869 mask = &gre_key_default_mask;
7871 case RTE_FLOW_ITEM_TYPE_META:
7872 mask = &rte_flow_item_meta_mask;
7874 case RTE_FLOW_ITEM_TYPE_FUZZY:
7875 mask = &rte_flow_item_fuzzy_mask;
7877 case RTE_FLOW_ITEM_TYPE_GTP:
7878 mask = &rte_flow_item_gtp_mask;
7880 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
7881 mask = &rte_flow_item_gtp_psc_mask;
7883 case RTE_FLOW_ITEM_TYPE_GENEVE:
7884 mask = &rte_flow_item_geneve_mask;
7886 case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
7887 mask = &rte_flow_item_geneve_opt_mask;
7889 case RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID:
7890 mask = &rte_flow_item_pppoe_proto_id_mask;
7892 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
7893 mask = &rte_flow_item_l2tpv3oip_mask;
7895 case RTE_FLOW_ITEM_TYPE_ESP:
7896 mask = &rte_flow_item_esp_mask;
7898 case RTE_FLOW_ITEM_TYPE_AH:
7899 mask = &rte_flow_item_ah_mask;
7901 case RTE_FLOW_ITEM_TYPE_PFCP:
7902 mask = &rte_flow_item_pfcp_mask;
7910 /** Dispatch parsed buffer to function calls. */
7912 cmd_set_raw_parsed_sample(const struct buffer *in)
7914 uint32_t n = in->args.vc.actions_n;
7916 struct rte_flow_action *action = NULL;
7917 struct rte_flow_action *data = NULL;
7918 const struct rte_flow_action_rss *rss = NULL;
7920 uint16_t idx = in->port; /* We borrow port field as index */
7921 uint32_t max_size = sizeof(struct rte_flow_action) *
7922 ACTION_SAMPLE_ACTIONS_NUM;
7924 RTE_ASSERT(in->command == SET_SAMPLE_ACTIONS);
7925 data = (struct rte_flow_action *)&raw_sample_confs[idx].data;
7926 memset(data, 0x00, max_size);
7927 for (; i <= n - 1; i++) {
7928 action = in->args.vc.actions + i;
7929 if (action->type == RTE_FLOW_ACTION_TYPE_END)
7931 switch (action->type) {
7932 case RTE_FLOW_ACTION_TYPE_MARK:
7933 size = sizeof(struct rte_flow_action_mark);
7934 rte_memcpy(&sample_mark[idx],
7935 (const void *)action->conf, size);
7936 action->conf = &sample_mark[idx];
7938 case RTE_FLOW_ACTION_TYPE_COUNT:
7939 size = sizeof(struct rte_flow_action_count);
7940 rte_memcpy(&sample_count[idx],
7941 (const void *)action->conf, size);
7942 action->conf = &sample_count[idx];
7944 case RTE_FLOW_ACTION_TYPE_QUEUE:
7945 size = sizeof(struct rte_flow_action_queue);
7946 rte_memcpy(&sample_queue[idx],
7947 (const void *)action->conf, size);
7948 action->conf = &sample_queue[idx];
7950 case RTE_FLOW_ACTION_TYPE_RSS:
7951 size = sizeof(struct rte_flow_action_rss);
7953 rte_memcpy(&sample_rss_data[idx].conf,
7954 (const void *)rss, size);
7955 if (rss->key_len && rss->key) {
7956 sample_rss_data[idx].conf.key =
7957 sample_rss_data[idx].key;
7958 rte_memcpy((void *)((uintptr_t)
7959 sample_rss_data[idx].conf.key),
7960 (const void *)rss->key,
7961 sizeof(uint8_t) * rss->key_len);
7963 if (rss->queue_num && rss->queue) {
7964 sample_rss_data[idx].conf.queue =
7965 sample_rss_data[idx].queue;
7966 rte_memcpy((void *)((uintptr_t)
7967 sample_rss_data[idx].conf.queue),
7968 (const void *)rss->queue,
7969 sizeof(uint16_t) * rss->queue_num);
7971 action->conf = &sample_rss_data[idx].conf;
7973 case RTE_FLOW_ACTION_TYPE_RAW_ENCAP:
7974 size = sizeof(struct rte_flow_action_raw_encap);
7975 rte_memcpy(&sample_encap[idx],
7976 (const void *)action->conf, size);
7977 action->conf = &sample_encap[idx];
7979 case RTE_FLOW_ACTION_TYPE_PORT_ID:
7980 size = sizeof(struct rte_flow_action_port_id);
7981 rte_memcpy(&sample_port_id[idx],
7982 (const void *)action->conf, size);
7983 action->conf = &sample_port_id[idx];
7985 case RTE_FLOW_ACTION_TYPE_PF:
7987 case RTE_FLOW_ACTION_TYPE_VF:
7988 size = sizeof(struct rte_flow_action_vf);
7989 rte_memcpy(&sample_vf[idx],
7990 (const void *)action->conf, size);
7991 action->conf = &sample_vf[idx];
7993 case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP:
7994 size = sizeof(struct rte_flow_action_vxlan_encap);
7995 parse_setup_vxlan_encap_data(&sample_vxlan_encap[idx]);
7996 action->conf = &sample_vxlan_encap[idx].conf;
7998 case RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP:
7999 size = sizeof(struct rte_flow_action_nvgre_encap);
8000 parse_setup_nvgre_encap_data(&sample_nvgre_encap[idx]);
8001 action->conf = &sample_nvgre_encap[idx];
8004 printf("Error - Not supported action\n");
8007 rte_memcpy(data, action, sizeof(struct rte_flow_action));
8012 /** Dispatch parsed buffer to function calls. */
8014 cmd_set_raw_parsed(const struct buffer *in)
8016 uint32_t n = in->args.vc.pattern_n;
8018 struct rte_flow_item *item = NULL;
8020 uint8_t *data = NULL;
8021 uint8_t *data_tail = NULL;
8022 size_t *total_size = NULL;
8023 uint16_t upper_layer = 0;
8025 uint16_t idx = in->port; /* We borrow port field as index */
8026 int gtp_psc = -1; /* GTP PSC option index. */
8028 if (in->command == SET_SAMPLE_ACTIONS)
8029 return cmd_set_raw_parsed_sample(in);
8030 RTE_ASSERT(in->command == SET_RAW_ENCAP ||
8031 in->command == SET_RAW_DECAP);
8032 if (in->command == SET_RAW_ENCAP) {
8033 total_size = &raw_encap_confs[idx].size;
8034 data = (uint8_t *)&raw_encap_confs[idx].data;
8036 total_size = &raw_decap_confs[idx].size;
8037 data = (uint8_t *)&raw_decap_confs[idx].data;
8040 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
8041 /* process hdr from upper layer to low layer (L3/L4 -> L2). */
8042 data_tail = data + ACTION_RAW_ENCAP_MAX_DATA;
8043 for (i = n - 1 ; i >= 0; --i) {
8044 const struct rte_flow_item_gtp *gtp;
8045 const struct rte_flow_item_geneve_opt *opt;
8047 item = in->args.vc.pattern + i;
8048 if (item->spec == NULL)
8049 item->spec = flow_item_default_mask(item);
8050 switch (item->type) {
8051 case RTE_FLOW_ITEM_TYPE_ETH:
8052 size = sizeof(struct rte_ether_hdr);
8054 case RTE_FLOW_ITEM_TYPE_VLAN:
8055 size = sizeof(struct rte_vlan_hdr);
8056 proto = RTE_ETHER_TYPE_VLAN;
8058 case RTE_FLOW_ITEM_TYPE_IPV4:
8059 size = sizeof(struct rte_ipv4_hdr);
8060 proto = RTE_ETHER_TYPE_IPV4;
8062 case RTE_FLOW_ITEM_TYPE_IPV6:
8063 size = sizeof(struct rte_ipv6_hdr);
8064 proto = RTE_ETHER_TYPE_IPV6;
8066 case RTE_FLOW_ITEM_TYPE_UDP:
8067 size = sizeof(struct rte_udp_hdr);
8070 case RTE_FLOW_ITEM_TYPE_TCP:
8071 size = sizeof(struct rte_tcp_hdr);
8074 case RTE_FLOW_ITEM_TYPE_VXLAN:
8075 size = sizeof(struct rte_vxlan_hdr);
8077 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
8078 size = sizeof(struct rte_vxlan_gpe_hdr);
8080 case RTE_FLOW_ITEM_TYPE_GRE:
8081 size = sizeof(struct rte_gre_hdr);
8084 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
8085 size = sizeof(rte_be32_t);
8088 case RTE_FLOW_ITEM_TYPE_MPLS:
8089 size = sizeof(struct rte_mpls_hdr);
8092 case RTE_FLOW_ITEM_TYPE_NVGRE:
8093 size = sizeof(struct rte_flow_item_nvgre);
8096 case RTE_FLOW_ITEM_TYPE_GENEVE:
8097 size = sizeof(struct rte_geneve_hdr);
8099 case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
8100 opt = (const struct rte_flow_item_geneve_opt *)
8102 size = offsetof(struct rte_flow_item_geneve_opt, data);
8103 if (opt->option_len && opt->data) {
8104 *total_size += opt->option_len *
8106 rte_memcpy(data_tail - (*total_size),
8108 opt->option_len * sizeof(uint32_t));
8111 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
8112 size = sizeof(rte_be32_t);
8115 case RTE_FLOW_ITEM_TYPE_ESP:
8116 size = sizeof(struct rte_esp_hdr);
8119 case RTE_FLOW_ITEM_TYPE_AH:
8120 size = sizeof(struct rte_flow_item_ah);
8123 case RTE_FLOW_ITEM_TYPE_GTP:
8125 size = sizeof(struct rte_gtp_hdr);
8128 if (gtp_psc != i + 1) {
8129 printf("Error - GTP PSC does not follow GTP\n");
8133 if ((gtp->v_pt_rsv_flags & 0x07) != 0x04) {
8134 /* Only E flag should be set. */
8135 printf("Error - GTP unsupported flags\n");
8138 struct rte_gtp_hdr_ext_word ext_word = {
8142 /* We have to add GTP header extra word. */
8143 *total_size += sizeof(ext_word);
8144 rte_memcpy(data_tail - (*total_size),
8145 &ext_word, sizeof(ext_word));
8147 size = sizeof(struct rte_gtp_hdr);
8149 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
8151 printf("Error - Multiple GTP PSC items\n");
8154 const struct rte_flow_item_gtp_psc
8163 if (opt->pdu_type & 0x0F) {
8164 /* Support the minimal option only. */
8165 printf("Error - GTP PSC option with "
8166 "extra fields not supported\n");
8169 psc.len = sizeof(psc);
8170 psc.pdu_type = opt->pdu_type;
8173 *total_size += sizeof(psc);
8174 rte_memcpy(data_tail - (*total_size),
8180 case RTE_FLOW_ITEM_TYPE_PFCP:
8181 size = sizeof(struct rte_flow_item_pfcp);
8184 printf("Error - Not supported item\n");
8187 *total_size += size;
8188 rte_memcpy(data_tail - (*total_size), item->spec, size);
8189 /* update some fields which cannot be set by cmdline */
8190 update_fields((data_tail - (*total_size)), item,
8192 upper_layer = proto;
8194 if (verbose_level & 0x1)
8195 printf("total data size is %zu\n", (*total_size));
8196 RTE_ASSERT((*total_size) <= ACTION_RAW_ENCAP_MAX_DATA);
8197 memmove(data, (data_tail - (*total_size)), *total_size);
8202 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
8205 /** Populate help strings for current token (cmdline API). */
8207 cmd_set_raw_get_help(cmdline_parse_token_hdr_t *hdr, char *dst,
8210 struct context *ctx = &cmd_flow_context;
8211 const struct token *token = &token_list[ctx->prev];
8216 /* Set token type and update global help with details. */
8217 snprintf(dst, size, "%s", (token->type ? token->type : "TOKEN"));
8219 cmd_set_raw.help_str = token->help;
8221 cmd_set_raw.help_str = token->name;
8225 /** Token definition template (cmdline API). */
8226 static struct cmdline_token_hdr cmd_set_raw_token_hdr = {
8227 .ops = &(struct cmdline_token_ops){
8228 .parse = cmd_flow_parse,
8229 .complete_get_nb = cmd_flow_complete_get_nb,
8230 .complete_get_elt = cmd_flow_complete_get_elt,
8231 .get_help = cmd_set_raw_get_help,
8236 /** Populate the next dynamic token. */
8238 cmd_set_raw_tok(cmdline_parse_token_hdr_t **hdr,
8239 cmdline_parse_token_hdr_t **hdr_inst)
8241 struct context *ctx = &cmd_flow_context;
8243 /* Always reinitialize context before requesting the first token. */
8244 if (!(hdr_inst - cmd_set_raw.tokens)) {
8245 cmd_flow_context_init(ctx);
8246 ctx->curr = START_SET;
8248 /* Return NULL when no more tokens are expected. */
8249 if (!ctx->next_num && (ctx->curr != START_SET)) {
8253 /* Determine if command should end here. */
8254 if (ctx->eol && ctx->last && ctx->next_num) {
8255 const enum index *list = ctx->next[ctx->next_num - 1];
8258 for (i = 0; list[i]; ++i) {
8265 *hdr = &cmd_set_raw_token_hdr;
8268 /** Token generator and output processing callback (cmdline API). */
8270 cmd_set_raw_cb(void *arg0, struct cmdline *cl, void *arg2)
8273 cmd_set_raw_tok(arg0, arg2);
8275 cmd_set_raw_parsed(arg0);
8278 /** Global parser instance (cmdline API). */
8279 cmdline_parse_inst_t cmd_set_raw = {
8280 .f = cmd_set_raw_cb,
8281 .data = NULL, /**< Unused. */
8282 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
8285 }, /**< Tokens are returned by cmd_flow_tok(). */
8288 /* *** display raw_encap/raw_decap buf */
8289 struct cmd_show_set_raw_result {
8290 cmdline_fixed_string_t cmd_show;
8291 cmdline_fixed_string_t cmd_what;
8292 cmdline_fixed_string_t cmd_all;
8297 cmd_show_set_raw_parsed(void *parsed_result, struct cmdline *cl, void *data)
8299 struct cmd_show_set_raw_result *res = parsed_result;
8300 uint16_t index = res->cmd_index;
8302 uint8_t *raw_data = NULL;
8303 size_t raw_size = 0;
8304 char title[16] = {0};
8308 if (!strcmp(res->cmd_all, "all")) {
8311 } else if (index >= RAW_ENCAP_CONFS_MAX_NUM) {
8312 printf("index should be 0-%u\n", RAW_ENCAP_CONFS_MAX_NUM - 1);
8316 if (!strcmp(res->cmd_what, "raw_encap")) {
8317 raw_data = (uint8_t *)&raw_encap_confs[index].data;
8318 raw_size = raw_encap_confs[index].size;
8319 snprintf(title, 16, "\nindex: %u", index);
8320 rte_hexdump(stdout, title, raw_data, raw_size);
8322 raw_data = (uint8_t *)&raw_decap_confs[index].data;
8323 raw_size = raw_decap_confs[index].size;
8324 snprintf(title, 16, "\nindex: %u", index);
8325 rte_hexdump(stdout, title, raw_data, raw_size);
8327 } while (all && ++index < RAW_ENCAP_CONFS_MAX_NUM);
8330 cmdline_parse_token_string_t cmd_show_set_raw_cmd_show =
8331 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
8333 cmdline_parse_token_string_t cmd_show_set_raw_cmd_what =
8334 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
8335 cmd_what, "raw_encap#raw_decap");
8336 cmdline_parse_token_num_t cmd_show_set_raw_cmd_index =
8337 TOKEN_NUM_INITIALIZER(struct cmd_show_set_raw_result,
8338 cmd_index, RTE_UINT16);
8339 cmdline_parse_token_string_t cmd_show_set_raw_cmd_all =
8340 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
8342 cmdline_parse_inst_t cmd_show_set_raw = {
8343 .f = cmd_show_set_raw_parsed,
8345 .help_str = "show <raw_encap|raw_decap> <index>",
8347 (void *)&cmd_show_set_raw_cmd_show,
8348 (void *)&cmd_show_set_raw_cmd_what,
8349 (void *)&cmd_show_set_raw_cmd_index,
8353 cmdline_parse_inst_t cmd_show_set_raw_all = {
8354 .f = cmd_show_set_raw_parsed,
8356 .help_str = "show <raw_encap|raw_decap> all",
8358 (void *)&cmd_show_set_raw_cmd_show,
8359 (void *)&cmd_show_set_raw_cmd_what,
8360 (void *)&cmd_show_set_raw_cmd_all,