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. */
111 /* Shared action arguments */
112 SHARED_ACTION_CREATE,
113 SHARED_ACTION_UPDATE,
114 SHARED_ACTION_DESTROY,
117 /* Shared action create arguments */
118 SHARED_ACTION_CREATE_ID,
119 SHARED_ACTION_INGRESS,
120 SHARED_ACTION_EGRESS,
121 SHARED_ACTION_TRANSFER,
124 /* Shared action destroy arguments */
125 SHARED_ACTION_DESTROY_ID,
127 /* Validate/create pattern. */
165 ITEM_VLAN_INNER_TYPE,
166 ITEM_VLAN_HAS_MORE_VLAN,
169 ITEM_IPV4_FRAGMENT_OFFSET,
181 ITEM_IPV6_HAS_FRAG_EXT,
202 ITEM_E_TAG_GRP_ECID_B,
211 ITEM_GRE_C_RSVD0_VER,
230 ITEM_ARP_ETH_IPV4_SHA,
231 ITEM_ARP_ETH_IPV4_SPA,
232 ITEM_ARP_ETH_IPV4_THA,
233 ITEM_ARP_ETH_IPV4_TPA,
235 ITEM_IPV6_EXT_NEXT_HDR,
237 ITEM_IPV6_FRAG_EXT_NEXT_HDR,
238 ITEM_IPV6_FRAG_EXT_FRAG_DATA,
243 ITEM_ICMP6_ND_NS_TARGET_ADDR,
245 ITEM_ICMP6_ND_NA_TARGET_ADDR,
247 ITEM_ICMP6_ND_OPT_TYPE,
248 ITEM_ICMP6_ND_OPT_SLA_ETH,
249 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
250 ITEM_ICMP6_ND_OPT_TLA_ETH,
251 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
264 ITEM_HIGIG2_CLASSIFICATION,
270 ITEM_L2TPV3OIP_SESSION_ID,
280 ITEM_ECPRI_COMMON_TYPE,
281 ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
282 ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
283 ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
284 ITEM_ECPRI_MSG_IQ_DATA_PCID,
285 ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
286 ITEM_ECPRI_MSG_DLY_MSR_MSRID,
288 ITEM_GENEVE_OPT_CLASS,
289 ITEM_GENEVE_OPT_TYPE,
290 ITEM_GENEVE_OPT_LENGTH,
291 ITEM_GENEVE_OPT_DATA,
293 /* Validate/create actions. */
313 ACTION_RSS_FUNC_DEFAULT,
314 ACTION_RSS_FUNC_TOEPLITZ,
315 ACTION_RSS_FUNC_SIMPLE_XOR,
316 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ,
328 ACTION_PHY_PORT_ORIGINAL,
329 ACTION_PHY_PORT_INDEX,
331 ACTION_PORT_ID_ORIGINAL,
335 ACTION_OF_SET_MPLS_TTL,
336 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
337 ACTION_OF_DEC_MPLS_TTL,
338 ACTION_OF_SET_NW_TTL,
339 ACTION_OF_SET_NW_TTL_NW_TTL,
340 ACTION_OF_DEC_NW_TTL,
341 ACTION_OF_COPY_TTL_OUT,
342 ACTION_OF_COPY_TTL_IN,
345 ACTION_OF_PUSH_VLAN_ETHERTYPE,
346 ACTION_OF_SET_VLAN_VID,
347 ACTION_OF_SET_VLAN_VID_VLAN_VID,
348 ACTION_OF_SET_VLAN_PCP,
349 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
351 ACTION_OF_POP_MPLS_ETHERTYPE,
353 ACTION_OF_PUSH_MPLS_ETHERTYPE,
360 ACTION_MPLSOGRE_ENCAP,
361 ACTION_MPLSOGRE_DECAP,
362 ACTION_MPLSOUDP_ENCAP,
363 ACTION_MPLSOUDP_DECAP,
365 ACTION_SET_IPV4_SRC_IPV4_SRC,
367 ACTION_SET_IPV4_DST_IPV4_DST,
369 ACTION_SET_IPV6_SRC_IPV6_SRC,
371 ACTION_SET_IPV6_DST_IPV6_DST,
373 ACTION_SET_TP_SRC_TP_SRC,
375 ACTION_SET_TP_DST_TP_DST,
381 ACTION_SET_MAC_SRC_MAC_SRC,
383 ACTION_SET_MAC_DST_MAC_DST,
385 ACTION_INC_TCP_SEQ_VALUE,
387 ACTION_DEC_TCP_SEQ_VALUE,
389 ACTION_INC_TCP_ACK_VALUE,
391 ACTION_DEC_TCP_ACK_VALUE,
394 ACTION_RAW_ENCAP_INDEX,
395 ACTION_RAW_ENCAP_INDEX_VALUE,
396 ACTION_RAW_DECAP_INDEX,
397 ACTION_RAW_DECAP_INDEX_VALUE,
400 ACTION_SET_TAG_INDEX,
403 ACTION_SET_META_DATA,
404 ACTION_SET_META_MASK,
405 ACTION_SET_IPV4_DSCP,
406 ACTION_SET_IPV4_DSCP_VALUE,
407 ACTION_SET_IPV6_DSCP,
408 ACTION_SET_IPV6_DSCP_VALUE,
414 ACTION_SAMPLE_INDEX_VALUE,
416 SHARED_ACTION_ID2PTR,
418 ACTION_MODIFY_FIELD_OP,
419 ACTION_MODIFY_FIELD_OP_VALUE,
420 ACTION_MODIFY_FIELD_DST_TYPE,
421 ACTION_MODIFY_FIELD_DST_TYPE_VALUE,
422 ACTION_MODIFY_FIELD_DST_LEVEL,
423 ACTION_MODIFY_FIELD_DST_OFFSET,
424 ACTION_MODIFY_FIELD_SRC_TYPE,
425 ACTION_MODIFY_FIELD_SRC_TYPE_VALUE,
426 ACTION_MODIFY_FIELD_SRC_LEVEL,
427 ACTION_MODIFY_FIELD_SRC_OFFSET,
428 ACTION_MODIFY_FIELD_SRC_VALUE,
429 ACTION_MODIFY_FIELD_WIDTH,
432 /** Maximum size for pattern in struct rte_flow_item_raw. */
433 #define ITEM_RAW_PATTERN_SIZE 40
435 /** Maximum size for GENEVE option data pattern in bytes. */
436 #define ITEM_GENEVE_OPT_DATA_SIZE 124
438 /** Storage size for struct rte_flow_item_raw including pattern. */
439 #define ITEM_RAW_SIZE \
440 (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE)
442 /** Maximum number of queue indices in struct rte_flow_action_rss. */
443 #define ACTION_RSS_QUEUE_NUM 128
445 /** Storage for struct rte_flow_action_rss including external data. */
446 struct action_rss_data {
447 struct rte_flow_action_rss conf;
448 uint8_t key[RSS_HASH_KEY_LENGTH];
449 uint16_t queue[ACTION_RSS_QUEUE_NUM];
452 /** Maximum data size in struct rte_flow_action_raw_encap. */
453 #define ACTION_RAW_ENCAP_MAX_DATA 512
454 #define RAW_ENCAP_CONFS_MAX_NUM 8
456 /** Storage for struct rte_flow_action_raw_encap. */
457 struct raw_encap_conf {
458 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
459 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
463 struct raw_encap_conf raw_encap_confs[RAW_ENCAP_CONFS_MAX_NUM];
465 /** Storage for struct rte_flow_action_raw_encap including external data. */
466 struct action_raw_encap_data {
467 struct rte_flow_action_raw_encap conf;
468 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
469 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
473 /** Storage for struct rte_flow_action_raw_decap. */
474 struct raw_decap_conf {
475 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
479 struct raw_decap_conf raw_decap_confs[RAW_ENCAP_CONFS_MAX_NUM];
481 /** Storage for struct rte_flow_action_raw_decap including external data. */
482 struct action_raw_decap_data {
483 struct rte_flow_action_raw_decap conf;
484 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
488 struct vxlan_encap_conf vxlan_encap_conf = {
492 .vni = "\x00\x00\x00",
494 .udp_dst = RTE_BE16(RTE_VXLAN_DEFAULT_PORT),
495 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
496 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
497 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
498 "\x00\x00\x00\x00\x00\x00\x00\x01",
499 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
500 "\x00\x00\x00\x00\x00\x00\x11\x11",
504 .eth_src = "\x00\x00\x00\x00\x00\x00",
505 .eth_dst = "\xff\xff\xff\xff\xff\xff",
508 /** Maximum number of items in struct rte_flow_action_vxlan_encap. */
509 #define ACTION_VXLAN_ENCAP_ITEMS_NUM 6
511 /** Storage for struct rte_flow_action_vxlan_encap including external data. */
512 struct action_vxlan_encap_data {
513 struct rte_flow_action_vxlan_encap conf;
514 struct rte_flow_item items[ACTION_VXLAN_ENCAP_ITEMS_NUM];
515 struct rte_flow_item_eth item_eth;
516 struct rte_flow_item_vlan item_vlan;
518 struct rte_flow_item_ipv4 item_ipv4;
519 struct rte_flow_item_ipv6 item_ipv6;
521 struct rte_flow_item_udp item_udp;
522 struct rte_flow_item_vxlan item_vxlan;
525 struct nvgre_encap_conf nvgre_encap_conf = {
528 .tni = "\x00\x00\x00",
529 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
530 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
531 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
532 "\x00\x00\x00\x00\x00\x00\x00\x01",
533 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
534 "\x00\x00\x00\x00\x00\x00\x11\x11",
536 .eth_src = "\x00\x00\x00\x00\x00\x00",
537 .eth_dst = "\xff\xff\xff\xff\xff\xff",
540 /** Maximum number of items in struct rte_flow_action_nvgre_encap. */
541 #define ACTION_NVGRE_ENCAP_ITEMS_NUM 5
543 /** Storage for struct rte_flow_action_nvgre_encap including external data. */
544 struct action_nvgre_encap_data {
545 struct rte_flow_action_nvgre_encap conf;
546 struct rte_flow_item items[ACTION_NVGRE_ENCAP_ITEMS_NUM];
547 struct rte_flow_item_eth item_eth;
548 struct rte_flow_item_vlan item_vlan;
550 struct rte_flow_item_ipv4 item_ipv4;
551 struct rte_flow_item_ipv6 item_ipv6;
553 struct rte_flow_item_nvgre item_nvgre;
556 struct l2_encap_conf l2_encap_conf;
558 struct l2_decap_conf l2_decap_conf;
560 struct mplsogre_encap_conf mplsogre_encap_conf;
562 struct mplsogre_decap_conf mplsogre_decap_conf;
564 struct mplsoudp_encap_conf mplsoudp_encap_conf;
566 struct mplsoudp_decap_conf mplsoudp_decap_conf;
568 #define ACTION_SAMPLE_ACTIONS_NUM 10
569 #define RAW_SAMPLE_CONFS_MAX_NUM 8
570 /** Storage for struct rte_flow_action_sample including external data. */
571 struct action_sample_data {
572 struct rte_flow_action_sample conf;
575 /** Storage for struct rte_flow_action_sample. */
576 struct raw_sample_conf {
577 struct rte_flow_action data[ACTION_SAMPLE_ACTIONS_NUM];
579 struct raw_sample_conf raw_sample_confs[RAW_SAMPLE_CONFS_MAX_NUM];
580 struct rte_flow_action_mark sample_mark[RAW_SAMPLE_CONFS_MAX_NUM];
581 struct rte_flow_action_queue sample_queue[RAW_SAMPLE_CONFS_MAX_NUM];
582 struct rte_flow_action_count sample_count[RAW_SAMPLE_CONFS_MAX_NUM];
583 struct rte_flow_action_port_id sample_port_id[RAW_SAMPLE_CONFS_MAX_NUM];
584 struct rte_flow_action_raw_encap sample_encap[RAW_SAMPLE_CONFS_MAX_NUM];
585 struct action_vxlan_encap_data sample_vxlan_encap[RAW_SAMPLE_CONFS_MAX_NUM];
586 struct action_rss_data sample_rss_data[RAW_SAMPLE_CONFS_MAX_NUM];
587 struct rte_flow_action_vf sample_vf[RAW_SAMPLE_CONFS_MAX_NUM];
589 static const char *const modify_field_ops[] = {
590 "set", "add", "sub", NULL
593 static const char *const modify_field_ids[] = {
594 "start", "mac_dst", "mac_src",
595 "vlan_type", "vlan_id", "mac_type",
596 "ipv4_dscp", "ipv4_ttl", "ipv4_src", "ipv4_dst",
597 "ipv6_dscp", "ipv6_hoplimit", "ipv6_src", "ipv6_dst",
598 "tcp_port_src", "tcp_port_dst",
599 "tcp_seq_num", "tcp_ack_num", "tcp_flags",
600 "udp_port_src", "udp_port_dst",
601 "vxlan_vni", "geneve_vni", "gtp_teid",
602 "tag", "mark", "meta", "pointer", "value", NULL
605 /** Maximum number of subsequent tokens and arguments on the stack. */
606 #define CTX_STACK_SIZE 16
608 /** Parser context. */
610 /** Stack of subsequent token lists to process. */
611 const enum index *next[CTX_STACK_SIZE];
612 /** Arguments for stacked tokens. */
613 const void *args[CTX_STACK_SIZE];
614 enum index curr; /**< Current token index. */
615 enum index prev; /**< Index of the last token seen. */
616 int next_num; /**< Number of entries in next[]. */
617 int args_num; /**< Number of entries in args[]. */
618 uint32_t eol:1; /**< EOL has been detected. */
619 uint32_t last:1; /**< No more arguments. */
620 portid_t port; /**< Current port ID (for completions). */
621 uint32_t objdata; /**< Object-specific data. */
622 void *object; /**< Address of current object for relative offsets. */
623 void *objmask; /**< Object a full mask must be written to. */
626 /** Token argument. */
628 uint32_t hton:1; /**< Use network byte ordering. */
629 uint32_t sign:1; /**< Value is signed. */
630 uint32_t bounded:1; /**< Value is bounded. */
631 uintmax_t min; /**< Minimum value if bounded. */
632 uintmax_t max; /**< Maximum value if bounded. */
633 uint32_t offset; /**< Relative offset from ctx->object. */
634 uint32_t size; /**< Field size. */
635 const uint8_t *mask; /**< Bit-mask to use instead of offset/size. */
638 /** Parser token definition. */
640 /** Type displayed during completion (defaults to "TOKEN"). */
642 /** Help displayed during completion (defaults to token name). */
644 /** Private data used by parser functions. */
647 * Lists of subsequent tokens to push on the stack. Each call to the
648 * parser consumes the last entry of that stack.
650 const enum index *const *next;
651 /** Arguments stack for subsequent tokens that need them. */
652 const struct arg *const *args;
654 * Token-processing callback, returns -1 in case of error, the
655 * length of the matched string otherwise. If NULL, attempts to
656 * match the token name.
658 * If buf is not NULL, the result should be stored in it according
659 * to context. An error is returned if not large enough.
661 int (*call)(struct context *ctx, const struct token *token,
662 const char *str, unsigned int len,
663 void *buf, unsigned int size);
665 * Callback that provides possible values for this token, used for
666 * completion. Returns -1 in case of error, the number of possible
667 * values otherwise. If NULL, the token name is used.
669 * If buf is not NULL, entry index ent is written to buf and the
670 * full length of the entry is returned (same behavior as
673 int (*comp)(struct context *ctx, const struct token *token,
674 unsigned int ent, char *buf, unsigned int size);
675 /** Mandatory token name, no default value. */
679 /** Static initializer for the next field. */
680 #define NEXT(...) (const enum index *const []){ __VA_ARGS__, NULL, }
682 /** Static initializer for a NEXT() entry. */
683 #define NEXT_ENTRY(...) (const enum index []){ __VA_ARGS__, ZERO, }
685 /** Static initializer for the args field. */
686 #define ARGS(...) (const struct arg *const []){ __VA_ARGS__, NULL, }
688 /** Static initializer for ARGS() to target a field. */
689 #define ARGS_ENTRY(s, f) \
690 (&(const struct arg){ \
691 .offset = offsetof(s, f), \
692 .size = sizeof(((s *)0)->f), \
695 /** Static initializer for ARGS() to target a bit-field. */
696 #define ARGS_ENTRY_BF(s, f, b) \
697 (&(const struct arg){ \
699 .mask = (const void *)&(const s){ .f = (1 << (b)) - 1 }, \
702 /** Static initializer for ARGS() to target a field with limits. */
703 #define ARGS_ENTRY_BOUNDED(s, f, i, a) \
704 (&(const struct arg){ \
708 .offset = offsetof(s, f), \
709 .size = sizeof(((s *)0)->f), \
712 /** Static initializer for ARGS() to target an arbitrary bit-mask. */
713 #define ARGS_ENTRY_MASK(s, f, m) \
714 (&(const struct arg){ \
715 .offset = offsetof(s, f), \
716 .size = sizeof(((s *)0)->f), \
717 .mask = (const void *)(m), \
720 /** Same as ARGS_ENTRY_MASK() using network byte ordering for the value. */
721 #define ARGS_ENTRY_MASK_HTON(s, f, m) \
722 (&(const struct arg){ \
724 .offset = offsetof(s, f), \
725 .size = sizeof(((s *)0)->f), \
726 .mask = (const void *)(m), \
729 /** Static initializer for ARGS() to target a pointer. */
730 #define ARGS_ENTRY_PTR(s, f) \
731 (&(const struct arg){ \
732 .size = sizeof(*((s *)0)->f), \
735 /** Static initializer for ARGS() with arbitrary offset and size. */
736 #define ARGS_ENTRY_ARB(o, s) \
737 (&(const struct arg){ \
742 /** Same as ARGS_ENTRY_ARB() with bounded values. */
743 #define ARGS_ENTRY_ARB_BOUNDED(o, s, i, a) \
744 (&(const struct arg){ \
752 /** Same as ARGS_ENTRY() using network byte ordering. */
753 #define ARGS_ENTRY_HTON(s, f) \
754 (&(const struct arg){ \
756 .offset = offsetof(s, f), \
757 .size = sizeof(((s *)0)->f), \
760 /** Same as ARGS_ENTRY_HTON() for a single argument, without structure. */
761 #define ARG_ENTRY_HTON(s) \
762 (&(const struct arg){ \
768 /** Parser output buffer layout expected by cmd_flow_parsed(). */
770 enum index command; /**< Flow command. */
771 portid_t port; /**< Affected port ID. */
775 uint32_t action_id_n;
776 } sa_destroy; /**< Shared action destroy arguments. */
779 } sa; /* Shared action query arguments */
781 struct rte_flow_attr attr;
782 struct tunnel_ops tunnel_ops;
783 struct rte_flow_item *pattern;
784 struct rte_flow_action *actions;
788 } vc; /**< Validate/create arguments. */
792 } destroy; /**< Destroy arguments. */
795 } dump; /**< Dump arguments. */
798 struct rte_flow_action action;
799 } query; /**< Query arguments. */
803 } list; /**< List arguments. */
806 } isolate; /**< Isolated mode arguments. */
809 } aged; /**< Aged arguments. */
810 } args; /**< Command arguments. */
813 /** Private data for pattern items. */
814 struct parse_item_priv {
815 enum rte_flow_item_type type; /**< Item type. */
816 uint32_t size; /**< Size of item specification structure. */
819 #define PRIV_ITEM(t, s) \
820 (&(const struct parse_item_priv){ \
821 .type = RTE_FLOW_ITEM_TYPE_ ## t, \
825 /** Private data for actions. */
826 struct parse_action_priv {
827 enum rte_flow_action_type type; /**< Action type. */
828 uint32_t size; /**< Size of action configuration structure. */
831 #define PRIV_ACTION(t, s) \
832 (&(const struct parse_action_priv){ \
833 .type = RTE_FLOW_ACTION_TYPE_ ## t, \
837 static const enum index next_sa_create_attr[] = {
838 SHARED_ACTION_CREATE_ID,
839 SHARED_ACTION_INGRESS,
840 SHARED_ACTION_EGRESS,
841 SHARED_ACTION_TRANSFER,
846 static const enum index next_sa_subcmd[] = {
847 SHARED_ACTION_CREATE,
848 SHARED_ACTION_UPDATE,
849 SHARED_ACTION_DESTROY,
854 static const enum index next_vc_attr[] = {
866 static const enum index next_destroy_attr[] = {
872 static const enum index next_dump_attr[] = {
878 static const enum index next_list_attr[] = {
884 static const enum index next_aged_attr[] = {
890 static const enum index next_sa_destroy_attr[] = {
891 SHARED_ACTION_DESTROY_ID,
896 static const enum index item_param[] = {
905 static const enum index next_item[] = {
942 ITEM_ICMP6_ND_OPT_SLA_ETH,
943 ITEM_ICMP6_ND_OPT_TLA_ETH,
962 static const enum index item_fuzzy[] = {
968 static const enum index item_any[] = {
974 static const enum index item_vf[] = {
980 static const enum index item_phy_port[] = {
986 static const enum index item_port_id[] = {
992 static const enum index item_mark[] = {
998 static const enum index item_raw[] = {
1008 static const enum index item_eth[] = {
1017 static const enum index item_vlan[] = {
1022 ITEM_VLAN_INNER_TYPE,
1023 ITEM_VLAN_HAS_MORE_VLAN,
1028 static const enum index item_ipv4[] = {
1030 ITEM_IPV4_FRAGMENT_OFFSET,
1039 static const enum index item_ipv6[] = {
1046 ITEM_IPV6_HAS_FRAG_EXT,
1051 static const enum index item_icmp[] = {
1060 static const enum index item_udp[] = {
1067 static const enum index item_tcp[] = {
1075 static const enum index item_sctp[] = {
1084 static const enum index item_vxlan[] = {
1090 static const enum index item_e_tag[] = {
1091 ITEM_E_TAG_GRP_ECID_B,
1096 static const enum index item_nvgre[] = {
1102 static const enum index item_mpls[] = {
1110 static const enum index item_gre[] = {
1112 ITEM_GRE_C_RSVD0_VER,
1120 static const enum index item_gre_key[] = {
1126 static const enum index item_gtp[] = {
1134 static const enum index item_geneve[] = {
1142 static const enum index item_vxlan_gpe[] = {
1148 static const enum index item_arp_eth_ipv4[] = {
1149 ITEM_ARP_ETH_IPV4_SHA,
1150 ITEM_ARP_ETH_IPV4_SPA,
1151 ITEM_ARP_ETH_IPV4_THA,
1152 ITEM_ARP_ETH_IPV4_TPA,
1157 static const enum index item_ipv6_ext[] = {
1158 ITEM_IPV6_EXT_NEXT_HDR,
1163 static const enum index item_ipv6_frag_ext[] = {
1164 ITEM_IPV6_FRAG_EXT_NEXT_HDR,
1165 ITEM_IPV6_FRAG_EXT_FRAG_DATA,
1170 static const enum index item_icmp6[] = {
1177 static const enum index item_icmp6_nd_ns[] = {
1178 ITEM_ICMP6_ND_NS_TARGET_ADDR,
1183 static const enum index item_icmp6_nd_na[] = {
1184 ITEM_ICMP6_ND_NA_TARGET_ADDR,
1189 static const enum index item_icmp6_nd_opt[] = {
1190 ITEM_ICMP6_ND_OPT_TYPE,
1195 static const enum index item_icmp6_nd_opt_sla_eth[] = {
1196 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
1201 static const enum index item_icmp6_nd_opt_tla_eth[] = {
1202 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
1207 static const enum index item_meta[] = {
1213 static const enum index item_gtp_psc[] = {
1220 static const enum index item_pppoed[] = {
1226 static const enum index item_pppoes[] = {
1232 static const enum index item_pppoe_proto_id[] = {
1237 static const enum index item_higig2[] = {
1238 ITEM_HIGIG2_CLASSIFICATION,
1244 static const enum index item_esp[] = {
1250 static const enum index item_ah[] = {
1256 static const enum index item_pfcp[] = {
1263 static const enum index next_set_raw[] = {
1269 static const enum index item_tag[] = {
1276 static const enum index item_l2tpv3oip[] = {
1277 ITEM_L2TPV3OIP_SESSION_ID,
1282 static const enum index item_ecpri[] = {
1288 static const enum index item_ecpri_common[] = {
1289 ITEM_ECPRI_COMMON_TYPE,
1293 static const enum index item_ecpri_common_type[] = {
1294 ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
1295 ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
1296 ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
1300 static const enum index item_geneve_opt[] = {
1301 ITEM_GENEVE_OPT_CLASS,
1302 ITEM_GENEVE_OPT_TYPE,
1303 ITEM_GENEVE_OPT_LENGTH,
1304 ITEM_GENEVE_OPT_DATA,
1309 static const enum index next_action[] = {
1325 ACTION_OF_SET_MPLS_TTL,
1326 ACTION_OF_DEC_MPLS_TTL,
1327 ACTION_OF_SET_NW_TTL,
1328 ACTION_OF_DEC_NW_TTL,
1329 ACTION_OF_COPY_TTL_OUT,
1330 ACTION_OF_COPY_TTL_IN,
1332 ACTION_OF_PUSH_VLAN,
1333 ACTION_OF_SET_VLAN_VID,
1334 ACTION_OF_SET_VLAN_PCP,
1336 ACTION_OF_PUSH_MPLS,
1343 ACTION_MPLSOGRE_ENCAP,
1344 ACTION_MPLSOGRE_DECAP,
1345 ACTION_MPLSOUDP_ENCAP,
1346 ACTION_MPLSOUDP_DECAP,
1347 ACTION_SET_IPV4_SRC,
1348 ACTION_SET_IPV4_DST,
1349 ACTION_SET_IPV6_SRC,
1350 ACTION_SET_IPV6_DST,
1366 ACTION_SET_IPV4_DSCP,
1367 ACTION_SET_IPV6_DSCP,
1371 ACTION_MODIFY_FIELD,
1375 static const enum index action_mark[] = {
1381 static const enum index action_queue[] = {
1387 static const enum index action_count[] = {
1389 ACTION_COUNT_SHARED,
1394 static const enum index action_rss[] = {
1405 static const enum index action_vf[] = {
1412 static const enum index action_phy_port[] = {
1413 ACTION_PHY_PORT_ORIGINAL,
1414 ACTION_PHY_PORT_INDEX,
1419 static const enum index action_port_id[] = {
1420 ACTION_PORT_ID_ORIGINAL,
1426 static const enum index action_meter[] = {
1432 static const enum index action_of_set_mpls_ttl[] = {
1433 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
1438 static const enum index action_of_set_nw_ttl[] = {
1439 ACTION_OF_SET_NW_TTL_NW_TTL,
1444 static const enum index action_of_push_vlan[] = {
1445 ACTION_OF_PUSH_VLAN_ETHERTYPE,
1450 static const enum index action_of_set_vlan_vid[] = {
1451 ACTION_OF_SET_VLAN_VID_VLAN_VID,
1456 static const enum index action_of_set_vlan_pcp[] = {
1457 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
1462 static const enum index action_of_pop_mpls[] = {
1463 ACTION_OF_POP_MPLS_ETHERTYPE,
1468 static const enum index action_of_push_mpls[] = {
1469 ACTION_OF_PUSH_MPLS_ETHERTYPE,
1474 static const enum index action_set_ipv4_src[] = {
1475 ACTION_SET_IPV4_SRC_IPV4_SRC,
1480 static const enum index action_set_mac_src[] = {
1481 ACTION_SET_MAC_SRC_MAC_SRC,
1486 static const enum index action_set_ipv4_dst[] = {
1487 ACTION_SET_IPV4_DST_IPV4_DST,
1492 static const enum index action_set_ipv6_src[] = {
1493 ACTION_SET_IPV6_SRC_IPV6_SRC,
1498 static const enum index action_set_ipv6_dst[] = {
1499 ACTION_SET_IPV6_DST_IPV6_DST,
1504 static const enum index action_set_tp_src[] = {
1505 ACTION_SET_TP_SRC_TP_SRC,
1510 static const enum index action_set_tp_dst[] = {
1511 ACTION_SET_TP_DST_TP_DST,
1516 static const enum index action_set_ttl[] = {
1522 static const enum index action_jump[] = {
1528 static const enum index action_set_mac_dst[] = {
1529 ACTION_SET_MAC_DST_MAC_DST,
1534 static const enum index action_inc_tcp_seq[] = {
1535 ACTION_INC_TCP_SEQ_VALUE,
1540 static const enum index action_dec_tcp_seq[] = {
1541 ACTION_DEC_TCP_SEQ_VALUE,
1546 static const enum index action_inc_tcp_ack[] = {
1547 ACTION_INC_TCP_ACK_VALUE,
1552 static const enum index action_dec_tcp_ack[] = {
1553 ACTION_DEC_TCP_ACK_VALUE,
1558 static const enum index action_raw_encap[] = {
1559 ACTION_RAW_ENCAP_INDEX,
1564 static const enum index action_raw_decap[] = {
1565 ACTION_RAW_DECAP_INDEX,
1570 static const enum index action_set_tag[] = {
1571 ACTION_SET_TAG_DATA,
1572 ACTION_SET_TAG_INDEX,
1573 ACTION_SET_TAG_MASK,
1578 static const enum index action_set_meta[] = {
1579 ACTION_SET_META_DATA,
1580 ACTION_SET_META_MASK,
1585 static const enum index action_set_ipv4_dscp[] = {
1586 ACTION_SET_IPV4_DSCP_VALUE,
1591 static const enum index action_set_ipv6_dscp[] = {
1592 ACTION_SET_IPV6_DSCP_VALUE,
1597 static const enum index action_age[] = {
1604 static const enum index action_sample[] = {
1606 ACTION_SAMPLE_RATIO,
1607 ACTION_SAMPLE_INDEX,
1612 static const enum index next_action_sample[] = {
1624 static const enum index action_modify_field_dst[] = {
1625 ACTION_MODIFY_FIELD_DST_LEVEL,
1626 ACTION_MODIFY_FIELD_DST_OFFSET,
1627 ACTION_MODIFY_FIELD_SRC_TYPE,
1631 static const enum index action_modify_field_src[] = {
1632 ACTION_MODIFY_FIELD_SRC_LEVEL,
1633 ACTION_MODIFY_FIELD_SRC_OFFSET,
1634 ACTION_MODIFY_FIELD_SRC_VALUE,
1635 ACTION_MODIFY_FIELD_WIDTH,
1639 static int parse_set_raw_encap_decap(struct context *, const struct token *,
1640 const char *, unsigned int,
1641 void *, unsigned int);
1642 static int parse_set_sample_action(struct context *, const struct token *,
1643 const char *, unsigned int,
1644 void *, unsigned int);
1645 static int parse_set_init(struct context *, const struct token *,
1646 const char *, unsigned int,
1647 void *, unsigned int);
1648 static int parse_init(struct context *, const struct token *,
1649 const char *, unsigned int,
1650 void *, unsigned int);
1651 static int parse_vc(struct context *, const struct token *,
1652 const char *, unsigned int,
1653 void *, unsigned int);
1654 static int parse_vc_spec(struct context *, const struct token *,
1655 const char *, unsigned int, void *, unsigned int);
1656 static int parse_vc_conf(struct context *, const struct token *,
1657 const char *, unsigned int, void *, unsigned int);
1658 static int parse_vc_item_ecpri_type(struct context *, const struct token *,
1659 const char *, unsigned int,
1660 void *, unsigned int);
1661 static int parse_vc_action_rss(struct context *, const struct token *,
1662 const char *, unsigned int, void *,
1664 static int parse_vc_action_rss_func(struct context *, const struct token *,
1665 const char *, unsigned int, void *,
1667 static int parse_vc_action_rss_type(struct context *, const struct token *,
1668 const char *, unsigned int, void *,
1670 static int parse_vc_action_rss_queue(struct context *, const struct token *,
1671 const char *, unsigned int, void *,
1673 static int parse_vc_action_vxlan_encap(struct context *, const struct token *,
1674 const char *, unsigned int, void *,
1676 static int parse_vc_action_nvgre_encap(struct context *, const struct token *,
1677 const char *, unsigned int, void *,
1679 static int parse_vc_action_l2_encap(struct context *, const struct token *,
1680 const char *, unsigned int, void *,
1682 static int parse_vc_action_l2_decap(struct context *, const struct token *,
1683 const char *, unsigned int, void *,
1685 static int parse_vc_action_mplsogre_encap(struct context *,
1686 const struct token *, const char *,
1687 unsigned int, void *, unsigned int);
1688 static int parse_vc_action_mplsogre_decap(struct context *,
1689 const struct token *, const char *,
1690 unsigned int, void *, unsigned int);
1691 static int parse_vc_action_mplsoudp_encap(struct context *,
1692 const struct token *, const char *,
1693 unsigned int, void *, unsigned int);
1694 static int parse_vc_action_mplsoudp_decap(struct context *,
1695 const struct token *, const char *,
1696 unsigned int, void *, unsigned int);
1697 static int parse_vc_action_raw_encap(struct context *,
1698 const struct token *, const char *,
1699 unsigned int, void *, unsigned int);
1700 static int parse_vc_action_raw_decap(struct context *,
1701 const struct token *, const char *,
1702 unsigned int, void *, unsigned int);
1703 static int parse_vc_action_raw_encap_index(struct context *,
1704 const struct token *, const char *,
1705 unsigned int, void *, unsigned int);
1706 static int parse_vc_action_raw_decap_index(struct context *,
1707 const struct token *, const char *,
1708 unsigned int, void *, unsigned int);
1709 static int parse_vc_action_set_meta(struct context *ctx,
1710 const struct token *token, const char *str,
1711 unsigned int len, void *buf,
1713 static int parse_vc_action_sample(struct context *ctx,
1714 const struct token *token, const char *str,
1715 unsigned int len, void *buf,
1718 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
1719 const char *str, unsigned int len, void *buf,
1722 parse_vc_modify_field_op(struct context *ctx, const struct token *token,
1723 const char *str, unsigned int len, void *buf,
1726 parse_vc_modify_field_id(struct context *ctx, const struct token *token,
1727 const char *str, unsigned int len, void *buf,
1729 static int parse_destroy(struct context *, const struct token *,
1730 const char *, unsigned int,
1731 void *, unsigned int);
1732 static int parse_flush(struct context *, const struct token *,
1733 const char *, unsigned int,
1734 void *, unsigned int);
1735 static int parse_dump(struct context *, const struct token *,
1736 const char *, unsigned int,
1737 void *, unsigned int);
1738 static int parse_query(struct context *, const struct token *,
1739 const char *, unsigned int,
1740 void *, unsigned int);
1741 static int parse_action(struct context *, const struct token *,
1742 const char *, unsigned int,
1743 void *, unsigned int);
1744 static int parse_list(struct context *, const struct token *,
1745 const char *, unsigned int,
1746 void *, unsigned int);
1747 static int parse_aged(struct context *, const struct token *,
1748 const char *, unsigned int,
1749 void *, unsigned int);
1750 static int parse_isolate(struct context *, const struct token *,
1751 const char *, unsigned int,
1752 void *, unsigned int);
1753 static int parse_tunnel(struct context *, const struct token *,
1754 const char *, unsigned int,
1755 void *, unsigned int);
1756 static int parse_int(struct context *, const struct token *,
1757 const char *, unsigned int,
1758 void *, unsigned int);
1759 static int parse_prefix(struct context *, const struct token *,
1760 const char *, unsigned int,
1761 void *, unsigned int);
1762 static int parse_boolean(struct context *, const struct token *,
1763 const char *, unsigned int,
1764 void *, unsigned int);
1765 static int parse_string(struct context *, const struct token *,
1766 const char *, unsigned int,
1767 void *, unsigned int);
1768 static int parse_hex(struct context *ctx, const struct token *token,
1769 const char *str, unsigned int len,
1770 void *buf, unsigned int size);
1771 static int parse_string0(struct context *, const struct token *,
1772 const char *, unsigned int,
1773 void *, unsigned int);
1774 static int parse_mac_addr(struct context *, const struct token *,
1775 const char *, unsigned int,
1776 void *, unsigned int);
1777 static int parse_ipv4_addr(struct context *, const struct token *,
1778 const char *, unsigned int,
1779 void *, unsigned int);
1780 static int parse_ipv6_addr(struct context *, const struct token *,
1781 const char *, unsigned int,
1782 void *, unsigned int);
1783 static int parse_port(struct context *, const struct token *,
1784 const char *, unsigned int,
1785 void *, unsigned int);
1786 static int parse_sa(struct context *, const struct token *,
1787 const char *, unsigned int,
1788 void *, unsigned int);
1789 static int parse_sa_destroy(struct context *ctx, const struct token *token,
1790 const char *str, unsigned int len,
1791 void *buf, unsigned int size);
1792 static int parse_sa_id2ptr(struct context *ctx, const struct token *token,
1793 const char *str, unsigned int len, void *buf,
1795 static int comp_none(struct context *, const struct token *,
1796 unsigned int, char *, unsigned int);
1797 static int comp_boolean(struct context *, const struct token *,
1798 unsigned int, char *, unsigned int);
1799 static int comp_action(struct context *, const struct token *,
1800 unsigned int, char *, unsigned int);
1801 static int comp_port(struct context *, const struct token *,
1802 unsigned int, char *, unsigned int);
1803 static int comp_rule_id(struct context *, const struct token *,
1804 unsigned int, char *, unsigned int);
1805 static int comp_vc_action_rss_type(struct context *, const struct token *,
1806 unsigned int, char *, unsigned int);
1807 static int comp_vc_action_rss_queue(struct context *, const struct token *,
1808 unsigned int, char *, unsigned int);
1809 static int comp_set_raw_index(struct context *, const struct token *,
1810 unsigned int, char *, unsigned int);
1811 static int comp_set_sample_index(struct context *, const struct token *,
1812 unsigned int, char *, unsigned int);
1813 static int comp_set_modify_field_op(struct context *, const struct token *,
1814 unsigned int, char *, unsigned int);
1815 static int comp_set_modify_field_id(struct context *, const struct token *,
1816 unsigned int, char *, unsigned int);
1818 /** Token definitions. */
1819 static const struct token token_list[] = {
1820 /* Special tokens. */
1823 .help = "null entry, abused as the entry point",
1824 .next = NEXT(NEXT_ENTRY(FLOW)),
1829 .help = "command may end here",
1832 .name = "START_SET",
1833 .help = "null entry, abused as the entry point for set",
1834 .next = NEXT(NEXT_ENTRY(SET)),
1839 .help = "set command may end here",
1841 /* Common tokens. */
1845 .help = "integer value",
1850 .name = "{unsigned}",
1852 .help = "unsigned integer value",
1859 .help = "prefix length for bit-mask",
1860 .call = parse_prefix,
1864 .name = "{boolean}",
1866 .help = "any boolean value",
1867 .call = parse_boolean,
1868 .comp = comp_boolean,
1873 .help = "fixed string",
1874 .call = parse_string,
1880 .help = "fixed string",
1884 .name = "{file path}",
1886 .help = "file path",
1887 .call = parse_string0,
1891 .name = "{MAC address}",
1893 .help = "standard MAC address notation",
1894 .call = parse_mac_addr,
1898 .name = "{IPv4 address}",
1899 .type = "IPV4 ADDRESS",
1900 .help = "standard IPv4 address notation",
1901 .call = parse_ipv4_addr,
1905 .name = "{IPv6 address}",
1906 .type = "IPV6 ADDRESS",
1907 .help = "standard IPv6 address notation",
1908 .call = parse_ipv6_addr,
1912 .name = "{rule id}",
1914 .help = "rule identifier",
1916 .comp = comp_rule_id,
1919 .name = "{port_id}",
1921 .help = "port identifier",
1926 .name = "{group_id}",
1928 .help = "group identifier",
1932 [PRIORITY_LEVEL] = {
1935 .help = "priority level",
1939 [SHARED_ACTION_ID] = {
1940 .name = "{shared_action_id}",
1941 .type = "SHARED_ACTION_ID",
1942 .help = "shared action id",
1946 /* Top-level command. */
1949 .type = "{command} {port_id} [{arg} [...]]",
1950 .help = "manage ingress/egress flow rules",
1951 .next = NEXT(NEXT_ENTRY
1965 /* Top-level command. */
1967 .name = "shared_action",
1968 .type = "{command} {port_id} [{arg} [...]]",
1969 .help = "manage shared actions",
1970 .next = NEXT(next_sa_subcmd, NEXT_ENTRY(PORT_ID)),
1971 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1974 /* Sub-level commands. */
1975 [SHARED_ACTION_CREATE] = {
1977 .help = "create shared action",
1978 .next = NEXT(next_sa_create_attr),
1981 [SHARED_ACTION_UPDATE] = {
1983 .help = "update shared action",
1984 .next = NEXT(NEXT_ENTRY(SHARED_ACTION_SPEC),
1985 NEXT_ENTRY(SHARED_ACTION_ID)),
1986 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
1989 [SHARED_ACTION_DESTROY] = {
1991 .help = "destroy shared action",
1992 .next = NEXT(NEXT_ENTRY(SHARED_ACTION_DESTROY_ID)),
1993 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1994 .call = parse_sa_destroy,
1996 [SHARED_ACTION_QUERY] = {
1998 .help = "query shared action",
1999 .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(SHARED_ACTION_ID)),
2000 .args = ARGS(ARGS_ENTRY(struct buffer, args.sa.action_id)),
2005 .help = "check whether a flow rule can be created",
2006 .next = NEXT(next_vc_attr, NEXT_ENTRY(PORT_ID)),
2007 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2012 .help = "create a flow rule",
2013 .next = NEXT(next_vc_attr, NEXT_ENTRY(PORT_ID)),
2014 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2019 .help = "destroy specific flow rules",
2020 .next = NEXT(NEXT_ENTRY(DESTROY_RULE), NEXT_ENTRY(PORT_ID)),
2021 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2022 .call = parse_destroy,
2026 .help = "destroy all flow rules",
2027 .next = NEXT(NEXT_ENTRY(PORT_ID)),
2028 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2029 .call = parse_flush,
2033 .help = "dump all flow rules to file",
2034 .next = NEXT(next_dump_attr, NEXT_ENTRY(PORT_ID)),
2035 .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file),
2036 ARGS_ENTRY(struct buffer, port)),
2041 .help = "query an existing flow rule",
2042 .next = NEXT(NEXT_ENTRY(QUERY_ACTION),
2043 NEXT_ENTRY(RULE_ID),
2044 NEXT_ENTRY(PORT_ID)),
2045 .args = ARGS(ARGS_ENTRY(struct buffer, args.query.action.type),
2046 ARGS_ENTRY(struct buffer, args.query.rule),
2047 ARGS_ENTRY(struct buffer, port)),
2048 .call = parse_query,
2052 .help = "list existing flow rules",
2053 .next = NEXT(next_list_attr, NEXT_ENTRY(PORT_ID)),
2054 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2059 .help = "list and destroy aged flows",
2060 .next = NEXT(next_aged_attr, NEXT_ENTRY(PORT_ID)),
2061 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2066 .help = "restrict ingress traffic to the defined flow rules",
2067 .next = NEXT(NEXT_ENTRY(BOOLEAN),
2068 NEXT_ENTRY(PORT_ID)),
2069 .args = ARGS(ARGS_ENTRY(struct buffer, args.isolate.set),
2070 ARGS_ENTRY(struct buffer, port)),
2071 .call = parse_isolate,
2075 .help = "new tunnel API",
2076 .next = NEXT(NEXT_ENTRY
2077 (TUNNEL_CREATE, TUNNEL_LIST, TUNNEL_DESTROY)),
2078 .call = parse_tunnel,
2080 /* Tunnel arguments. */
2083 .help = "create new tunnel object",
2084 .next = NEXT(NEXT_ENTRY(TUNNEL_CREATE_TYPE),
2085 NEXT_ENTRY(PORT_ID)),
2086 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2087 .call = parse_tunnel,
2089 [TUNNEL_CREATE_TYPE] = {
2091 .help = "create new tunnel",
2092 .next = NEXT(NEXT_ENTRY(FILE_PATH)),
2093 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, type)),
2094 .call = parse_tunnel,
2096 [TUNNEL_DESTROY] = {
2098 .help = "destroy tunel",
2099 .next = NEXT(NEXT_ENTRY(TUNNEL_DESTROY_ID),
2100 NEXT_ENTRY(PORT_ID)),
2101 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2102 .call = parse_tunnel,
2104 [TUNNEL_DESTROY_ID] = {
2106 .help = "tunnel identifier to testroy",
2107 .next = NEXT(NEXT_ENTRY(UNSIGNED)),
2108 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2109 .call = parse_tunnel,
2113 .help = "list existing tunnels",
2114 .next = NEXT(NEXT_ENTRY(PORT_ID)),
2115 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2116 .call = parse_tunnel,
2118 /* Destroy arguments. */
2121 .help = "specify a rule identifier",
2122 .next = NEXT(next_destroy_attr, NEXT_ENTRY(RULE_ID)),
2123 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.destroy.rule)),
2124 .call = parse_destroy,
2126 /* Query arguments. */
2130 .help = "action to query, must be part of the rule",
2131 .call = parse_action,
2132 .comp = comp_action,
2134 /* List arguments. */
2137 .help = "specify a group",
2138 .next = NEXT(next_list_attr, NEXT_ENTRY(GROUP_ID)),
2139 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.list.group)),
2144 .help = "specify aged flows need be destroyed",
2148 /* Validate/create attributes. */
2151 .help = "specify a group",
2152 .next = NEXT(next_vc_attr, NEXT_ENTRY(GROUP_ID)),
2153 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, group)),
2158 .help = "specify a priority level",
2159 .next = NEXT(next_vc_attr, NEXT_ENTRY(PRIORITY_LEVEL)),
2160 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, priority)),
2165 .help = "affect rule to ingress",
2166 .next = NEXT(next_vc_attr),
2171 .help = "affect rule to egress",
2172 .next = NEXT(next_vc_attr),
2177 .help = "apply rule directly to endpoints found in pattern",
2178 .next = NEXT(next_vc_attr),
2182 .name = "tunnel_set",
2183 .help = "tunnel steer rule",
2184 .next = NEXT(next_vc_attr, NEXT_ENTRY(UNSIGNED)),
2185 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2189 .name = "tunnel_match",
2190 .help = "tunnel match rule",
2191 .next = NEXT(next_vc_attr, NEXT_ENTRY(UNSIGNED)),
2192 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2195 /* Validate/create pattern. */
2198 .help = "submit a list of pattern items",
2199 .next = NEXT(next_item),
2204 .help = "match value perfectly (with full bit-mask)",
2205 .call = parse_vc_spec,
2207 [ITEM_PARAM_SPEC] = {
2209 .help = "match value according to configured bit-mask",
2210 .call = parse_vc_spec,
2212 [ITEM_PARAM_LAST] = {
2214 .help = "specify upper bound to establish a range",
2215 .call = parse_vc_spec,
2217 [ITEM_PARAM_MASK] = {
2219 .help = "specify bit-mask with relevant bits set to one",
2220 .call = parse_vc_spec,
2222 [ITEM_PARAM_PREFIX] = {
2224 .help = "generate bit-mask from a prefix length",
2225 .call = parse_vc_spec,
2229 .help = "specify next pattern item",
2230 .next = NEXT(next_item),
2234 .help = "end list of pattern items",
2235 .priv = PRIV_ITEM(END, 0),
2236 .next = NEXT(NEXT_ENTRY(ACTIONS)),
2241 .help = "no-op pattern item",
2242 .priv = PRIV_ITEM(VOID, 0),
2243 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2248 .help = "perform actions when pattern does not match",
2249 .priv = PRIV_ITEM(INVERT, 0),
2250 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2255 .help = "match any protocol for the current layer",
2256 .priv = PRIV_ITEM(ANY, sizeof(struct rte_flow_item_any)),
2257 .next = NEXT(item_any),
2262 .help = "number of layers covered",
2263 .next = NEXT(item_any, NEXT_ENTRY(UNSIGNED), item_param),
2264 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_any, num)),
2268 .help = "match traffic from/to the physical function",
2269 .priv = PRIV_ITEM(PF, 0),
2270 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2275 .help = "match traffic from/to a virtual function ID",
2276 .priv = PRIV_ITEM(VF, sizeof(struct rte_flow_item_vf)),
2277 .next = NEXT(item_vf),
2283 .next = NEXT(item_vf, NEXT_ENTRY(UNSIGNED), item_param),
2284 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_vf, id)),
2288 .help = "match traffic from/to a specific physical port",
2289 .priv = PRIV_ITEM(PHY_PORT,
2290 sizeof(struct rte_flow_item_phy_port)),
2291 .next = NEXT(item_phy_port),
2294 [ITEM_PHY_PORT_INDEX] = {
2296 .help = "physical port index",
2297 .next = NEXT(item_phy_port, NEXT_ENTRY(UNSIGNED), item_param),
2298 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_phy_port, index)),
2302 .help = "match traffic from/to a given DPDK port ID",
2303 .priv = PRIV_ITEM(PORT_ID,
2304 sizeof(struct rte_flow_item_port_id)),
2305 .next = NEXT(item_port_id),
2308 [ITEM_PORT_ID_ID] = {
2310 .help = "DPDK port ID",
2311 .next = NEXT(item_port_id, NEXT_ENTRY(UNSIGNED), item_param),
2312 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port_id, id)),
2316 .help = "match traffic against value set in previously matched rule",
2317 .priv = PRIV_ITEM(MARK, sizeof(struct rte_flow_item_mark)),
2318 .next = NEXT(item_mark),
2323 .help = "Integer value to match against",
2324 .next = NEXT(item_mark, NEXT_ENTRY(UNSIGNED), item_param),
2325 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_mark, id)),
2329 .help = "match an arbitrary byte string",
2330 .priv = PRIV_ITEM(RAW, ITEM_RAW_SIZE),
2331 .next = NEXT(item_raw),
2334 [ITEM_RAW_RELATIVE] = {
2336 .help = "look for pattern after the previous item",
2337 .next = NEXT(item_raw, NEXT_ENTRY(BOOLEAN), item_param),
2338 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
2341 [ITEM_RAW_SEARCH] = {
2343 .help = "search pattern from offset (see also limit)",
2344 .next = NEXT(item_raw, NEXT_ENTRY(BOOLEAN), item_param),
2345 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
2348 [ITEM_RAW_OFFSET] = {
2350 .help = "absolute or relative offset for pattern",
2351 .next = NEXT(item_raw, NEXT_ENTRY(INTEGER), item_param),
2352 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, offset)),
2354 [ITEM_RAW_LIMIT] = {
2356 .help = "search area limit for start of pattern",
2357 .next = NEXT(item_raw, NEXT_ENTRY(UNSIGNED), item_param),
2358 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, limit)),
2360 [ITEM_RAW_PATTERN] = {
2362 .help = "byte string to look for",
2363 .next = NEXT(item_raw,
2365 NEXT_ENTRY(ITEM_PARAM_IS,
2368 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern),
2369 ARGS_ENTRY(struct rte_flow_item_raw, length),
2370 ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw),
2371 ITEM_RAW_PATTERN_SIZE)),
2375 .help = "match Ethernet header",
2376 .priv = PRIV_ITEM(ETH, sizeof(struct rte_flow_item_eth)),
2377 .next = NEXT(item_eth),
2382 .help = "destination MAC",
2383 .next = NEXT(item_eth, NEXT_ENTRY(MAC_ADDR), item_param),
2384 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, dst)),
2388 .help = "source MAC",
2389 .next = NEXT(item_eth, NEXT_ENTRY(MAC_ADDR), item_param),
2390 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, src)),
2394 .help = "EtherType",
2395 .next = NEXT(item_eth, NEXT_ENTRY(UNSIGNED), item_param),
2396 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, type)),
2398 [ITEM_ETH_HAS_VLAN] = {
2400 .help = "packet header contains VLAN",
2401 .next = NEXT(item_eth, NEXT_ENTRY(UNSIGNED), item_param),
2402 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_eth,
2407 .help = "match 802.1Q/ad VLAN tag",
2408 .priv = PRIV_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)),
2409 .next = NEXT(item_vlan),
2414 .help = "tag control information",
2415 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2416 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, tci)),
2420 .help = "priority code point",
2421 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2422 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2427 .help = "drop eligible indicator",
2428 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2429 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2434 .help = "VLAN identifier",
2435 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2436 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2439 [ITEM_VLAN_INNER_TYPE] = {
2440 .name = "inner_type",
2441 .help = "inner EtherType",
2442 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2443 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan,
2446 [ITEM_VLAN_HAS_MORE_VLAN] = {
2447 .name = "has_more_vlan",
2448 .help = "packet header contains another VLAN",
2449 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2450 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vlan,
2455 .help = "match IPv4 header",
2456 .priv = PRIV_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)),
2457 .next = NEXT(item_ipv4),
2462 .help = "type of service",
2463 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2464 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2465 hdr.type_of_service)),
2467 [ITEM_IPV4_FRAGMENT_OFFSET] = {
2468 .name = "fragment_offset",
2469 .help = "fragmentation flags and fragment offset",
2470 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2471 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2472 hdr.fragment_offset)),
2476 .help = "time to live",
2477 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2478 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2481 [ITEM_IPV4_PROTO] = {
2483 .help = "next protocol ID",
2484 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2485 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2486 hdr.next_proto_id)),
2490 .help = "source address",
2491 .next = NEXT(item_ipv4, NEXT_ENTRY(IPV4_ADDR), item_param),
2492 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2497 .help = "destination address",
2498 .next = NEXT(item_ipv4, NEXT_ENTRY(IPV4_ADDR), item_param),
2499 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2504 .help = "match IPv6 header",
2505 .priv = PRIV_ITEM(IPV6, sizeof(struct rte_flow_item_ipv6)),
2506 .next = NEXT(item_ipv6),
2511 .help = "traffic class",
2512 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2513 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2515 "\x0f\xf0\x00\x00")),
2517 [ITEM_IPV6_FLOW] = {
2519 .help = "flow label",
2520 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2521 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2523 "\x00\x0f\xff\xff")),
2525 [ITEM_IPV6_PROTO] = {
2527 .help = "protocol (next header)",
2528 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2529 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2534 .help = "hop limit",
2535 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2536 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2541 .help = "source address",
2542 .next = NEXT(item_ipv6, NEXT_ENTRY(IPV6_ADDR), item_param),
2543 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2548 .help = "destination address",
2549 .next = NEXT(item_ipv6, NEXT_ENTRY(IPV6_ADDR), item_param),
2550 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2553 [ITEM_IPV6_HAS_FRAG_EXT] = {
2554 .name = "has_frag_ext",
2555 .help = "fragment packet attribute",
2556 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2557 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_ipv6,
2562 .help = "match ICMP header",
2563 .priv = PRIV_ITEM(ICMP, sizeof(struct rte_flow_item_icmp)),
2564 .next = NEXT(item_icmp),
2567 [ITEM_ICMP_TYPE] = {
2569 .help = "ICMP packet type",
2570 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2571 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2574 [ITEM_ICMP_CODE] = {
2576 .help = "ICMP packet code",
2577 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2578 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2581 [ITEM_ICMP_IDENT] = {
2583 .help = "ICMP packet identifier",
2584 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2585 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2590 .help = "ICMP packet sequence number",
2591 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2592 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2597 .help = "match UDP header",
2598 .priv = PRIV_ITEM(UDP, sizeof(struct rte_flow_item_udp)),
2599 .next = NEXT(item_udp),
2604 .help = "UDP source port",
2605 .next = NEXT(item_udp, NEXT_ENTRY(UNSIGNED), item_param),
2606 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2611 .help = "UDP destination port",
2612 .next = NEXT(item_udp, NEXT_ENTRY(UNSIGNED), item_param),
2613 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2618 .help = "match TCP header",
2619 .priv = PRIV_ITEM(TCP, sizeof(struct rte_flow_item_tcp)),
2620 .next = NEXT(item_tcp),
2625 .help = "TCP source port",
2626 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2627 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2632 .help = "TCP destination port",
2633 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2634 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2637 [ITEM_TCP_FLAGS] = {
2639 .help = "TCP flags",
2640 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2641 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2646 .help = "match SCTP header",
2647 .priv = PRIV_ITEM(SCTP, sizeof(struct rte_flow_item_sctp)),
2648 .next = NEXT(item_sctp),
2653 .help = "SCTP source port",
2654 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2655 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2660 .help = "SCTP destination port",
2661 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2662 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2667 .help = "validation tag",
2668 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2669 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2672 [ITEM_SCTP_CKSUM] = {
2675 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2676 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2681 .help = "match VXLAN header",
2682 .priv = PRIV_ITEM(VXLAN, sizeof(struct rte_flow_item_vxlan)),
2683 .next = NEXT(item_vxlan),
2686 [ITEM_VXLAN_VNI] = {
2688 .help = "VXLAN identifier",
2689 .next = NEXT(item_vxlan, NEXT_ENTRY(UNSIGNED), item_param),
2690 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan, vni)),
2694 .help = "match E-Tag header",
2695 .priv = PRIV_ITEM(E_TAG, sizeof(struct rte_flow_item_e_tag)),
2696 .next = NEXT(item_e_tag),
2699 [ITEM_E_TAG_GRP_ECID_B] = {
2700 .name = "grp_ecid_b",
2701 .help = "GRP and E-CID base",
2702 .next = NEXT(item_e_tag, NEXT_ENTRY(UNSIGNED), item_param),
2703 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_e_tag,
2709 .help = "match NVGRE header",
2710 .priv = PRIV_ITEM(NVGRE, sizeof(struct rte_flow_item_nvgre)),
2711 .next = NEXT(item_nvgre),
2714 [ITEM_NVGRE_TNI] = {
2716 .help = "virtual subnet ID",
2717 .next = NEXT(item_nvgre, NEXT_ENTRY(UNSIGNED), item_param),
2718 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_nvgre, tni)),
2722 .help = "match MPLS header",
2723 .priv = PRIV_ITEM(MPLS, sizeof(struct rte_flow_item_mpls)),
2724 .next = NEXT(item_mpls),
2727 [ITEM_MPLS_LABEL] = {
2729 .help = "MPLS label",
2730 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2731 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2737 .help = "MPLS Traffic Class",
2738 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2739 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2745 .help = "MPLS Bottom-of-Stack",
2746 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2747 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2753 .help = "match GRE header",
2754 .priv = PRIV_ITEM(GRE, sizeof(struct rte_flow_item_gre)),
2755 .next = NEXT(item_gre),
2758 [ITEM_GRE_PROTO] = {
2760 .help = "GRE protocol type",
2761 .next = NEXT(item_gre, NEXT_ENTRY(UNSIGNED), item_param),
2762 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2765 [ITEM_GRE_C_RSVD0_VER] = {
2766 .name = "c_rsvd0_ver",
2768 "checksum (1b), undefined (1b), key bit (1b),"
2769 " sequence number (1b), reserved 0 (9b),"
2771 .next = NEXT(item_gre, NEXT_ENTRY(UNSIGNED), item_param),
2772 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2775 [ITEM_GRE_C_BIT] = {
2777 .help = "checksum bit (C)",
2778 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2779 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2781 "\x80\x00\x00\x00")),
2783 [ITEM_GRE_S_BIT] = {
2785 .help = "sequence number bit (S)",
2786 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2787 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2789 "\x10\x00\x00\x00")),
2791 [ITEM_GRE_K_BIT] = {
2793 .help = "key bit (K)",
2794 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2795 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2797 "\x20\x00\x00\x00")),
2801 .help = "fuzzy pattern match, expect faster than default",
2802 .priv = PRIV_ITEM(FUZZY,
2803 sizeof(struct rte_flow_item_fuzzy)),
2804 .next = NEXT(item_fuzzy),
2807 [ITEM_FUZZY_THRESH] = {
2809 .help = "match accuracy threshold",
2810 .next = NEXT(item_fuzzy, NEXT_ENTRY(UNSIGNED), item_param),
2811 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_fuzzy,
2816 .help = "match GTP header",
2817 .priv = PRIV_ITEM(GTP, sizeof(struct rte_flow_item_gtp)),
2818 .next = NEXT(item_gtp),
2821 [ITEM_GTP_FLAGS] = {
2822 .name = "v_pt_rsv_flags",
2823 .help = "GTP flags",
2824 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2825 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp,
2828 [ITEM_GTP_MSG_TYPE] = {
2830 .help = "GTP message type",
2831 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2832 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp, msg_type)),
2836 .help = "tunnel endpoint identifier",
2837 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2838 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp, teid)),
2842 .help = "match GTP header",
2843 .priv = PRIV_ITEM(GTPC, sizeof(struct rte_flow_item_gtp)),
2844 .next = NEXT(item_gtp),
2849 .help = "match GTP header",
2850 .priv = PRIV_ITEM(GTPU, sizeof(struct rte_flow_item_gtp)),
2851 .next = NEXT(item_gtp),
2856 .help = "match GENEVE header",
2857 .priv = PRIV_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)),
2858 .next = NEXT(item_geneve),
2861 [ITEM_GENEVE_VNI] = {
2863 .help = "virtual network identifier",
2864 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2865 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve, vni)),
2867 [ITEM_GENEVE_PROTO] = {
2869 .help = "GENEVE protocol type",
2870 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2871 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve,
2874 [ITEM_GENEVE_OPTLEN] = {
2876 .help = "GENEVE options length in dwords",
2877 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2878 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_geneve,
2879 ver_opt_len_o_c_rsvd0,
2882 [ITEM_VXLAN_GPE] = {
2883 .name = "vxlan-gpe",
2884 .help = "match VXLAN-GPE header",
2885 .priv = PRIV_ITEM(VXLAN_GPE,
2886 sizeof(struct rte_flow_item_vxlan_gpe)),
2887 .next = NEXT(item_vxlan_gpe),
2890 [ITEM_VXLAN_GPE_VNI] = {
2892 .help = "VXLAN-GPE identifier",
2893 .next = NEXT(item_vxlan_gpe, NEXT_ENTRY(UNSIGNED), item_param),
2894 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
2897 [ITEM_ARP_ETH_IPV4] = {
2898 .name = "arp_eth_ipv4",
2899 .help = "match ARP header for Ethernet/IPv4",
2900 .priv = PRIV_ITEM(ARP_ETH_IPV4,
2901 sizeof(struct rte_flow_item_arp_eth_ipv4)),
2902 .next = NEXT(item_arp_eth_ipv4),
2905 [ITEM_ARP_ETH_IPV4_SHA] = {
2907 .help = "sender hardware address",
2908 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(MAC_ADDR),
2910 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2913 [ITEM_ARP_ETH_IPV4_SPA] = {
2915 .help = "sender IPv4 address",
2916 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(IPV4_ADDR),
2918 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2921 [ITEM_ARP_ETH_IPV4_THA] = {
2923 .help = "target hardware address",
2924 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(MAC_ADDR),
2926 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2929 [ITEM_ARP_ETH_IPV4_TPA] = {
2931 .help = "target IPv4 address",
2932 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(IPV4_ADDR),
2934 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2939 .help = "match presence of any IPv6 extension header",
2940 .priv = PRIV_ITEM(IPV6_EXT,
2941 sizeof(struct rte_flow_item_ipv6_ext)),
2942 .next = NEXT(item_ipv6_ext),
2945 [ITEM_IPV6_EXT_NEXT_HDR] = {
2947 .help = "next header",
2948 .next = NEXT(item_ipv6_ext, NEXT_ENTRY(UNSIGNED), item_param),
2949 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_ext,
2952 [ITEM_IPV6_FRAG_EXT] = {
2953 .name = "ipv6_frag_ext",
2954 .help = "match presence of IPv6 fragment extension header",
2955 .priv = PRIV_ITEM(IPV6_FRAG_EXT,
2956 sizeof(struct rte_flow_item_ipv6_frag_ext)),
2957 .next = NEXT(item_ipv6_frag_ext),
2960 [ITEM_IPV6_FRAG_EXT_NEXT_HDR] = {
2962 .help = "next header",
2963 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(UNSIGNED),
2965 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ipv6_frag_ext,
2968 [ITEM_IPV6_FRAG_EXT_FRAG_DATA] = {
2969 .name = "frag_data",
2970 .help = "Fragment flags and offset",
2971 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(UNSIGNED),
2973 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_frag_ext,
2978 .help = "match any ICMPv6 header",
2979 .priv = PRIV_ITEM(ICMP6, sizeof(struct rte_flow_item_icmp6)),
2980 .next = NEXT(item_icmp6),
2983 [ITEM_ICMP6_TYPE] = {
2985 .help = "ICMPv6 type",
2986 .next = NEXT(item_icmp6, NEXT_ENTRY(UNSIGNED), item_param),
2987 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
2990 [ITEM_ICMP6_CODE] = {
2992 .help = "ICMPv6 code",
2993 .next = NEXT(item_icmp6, NEXT_ENTRY(UNSIGNED), item_param),
2994 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
2997 [ITEM_ICMP6_ND_NS] = {
2998 .name = "icmp6_nd_ns",
2999 .help = "match ICMPv6 neighbor discovery solicitation",
3000 .priv = PRIV_ITEM(ICMP6_ND_NS,
3001 sizeof(struct rte_flow_item_icmp6_nd_ns)),
3002 .next = NEXT(item_icmp6_nd_ns),
3005 [ITEM_ICMP6_ND_NS_TARGET_ADDR] = {
3006 .name = "target_addr",
3007 .help = "target address",
3008 .next = NEXT(item_icmp6_nd_ns, NEXT_ENTRY(IPV6_ADDR),
3010 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_ns,
3013 [ITEM_ICMP6_ND_NA] = {
3014 .name = "icmp6_nd_na",
3015 .help = "match ICMPv6 neighbor discovery advertisement",
3016 .priv = PRIV_ITEM(ICMP6_ND_NA,
3017 sizeof(struct rte_flow_item_icmp6_nd_na)),
3018 .next = NEXT(item_icmp6_nd_na),
3021 [ITEM_ICMP6_ND_NA_TARGET_ADDR] = {
3022 .name = "target_addr",
3023 .help = "target address",
3024 .next = NEXT(item_icmp6_nd_na, NEXT_ENTRY(IPV6_ADDR),
3026 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_na,
3029 [ITEM_ICMP6_ND_OPT] = {
3030 .name = "icmp6_nd_opt",
3031 .help = "match presence of any ICMPv6 neighbor discovery"
3033 .priv = PRIV_ITEM(ICMP6_ND_OPT,
3034 sizeof(struct rte_flow_item_icmp6_nd_opt)),
3035 .next = NEXT(item_icmp6_nd_opt),
3038 [ITEM_ICMP6_ND_OPT_TYPE] = {
3040 .help = "ND option type",
3041 .next = NEXT(item_icmp6_nd_opt, NEXT_ENTRY(UNSIGNED),
3043 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_opt,
3046 [ITEM_ICMP6_ND_OPT_SLA_ETH] = {
3047 .name = "icmp6_nd_opt_sla_eth",
3048 .help = "match ICMPv6 neighbor discovery source Ethernet"
3049 " link-layer address option",
3051 (ICMP6_ND_OPT_SLA_ETH,
3052 sizeof(struct rte_flow_item_icmp6_nd_opt_sla_eth)),
3053 .next = NEXT(item_icmp6_nd_opt_sla_eth),
3056 [ITEM_ICMP6_ND_OPT_SLA_ETH_SLA] = {
3058 .help = "source Ethernet LLA",
3059 .next = NEXT(item_icmp6_nd_opt_sla_eth, NEXT_ENTRY(MAC_ADDR),
3061 .args = ARGS(ARGS_ENTRY_HTON
3062 (struct rte_flow_item_icmp6_nd_opt_sla_eth, sla)),
3064 [ITEM_ICMP6_ND_OPT_TLA_ETH] = {
3065 .name = "icmp6_nd_opt_tla_eth",
3066 .help = "match ICMPv6 neighbor discovery target Ethernet"
3067 " link-layer address option",
3069 (ICMP6_ND_OPT_TLA_ETH,
3070 sizeof(struct rte_flow_item_icmp6_nd_opt_tla_eth)),
3071 .next = NEXT(item_icmp6_nd_opt_tla_eth),
3074 [ITEM_ICMP6_ND_OPT_TLA_ETH_TLA] = {
3076 .help = "target Ethernet LLA",
3077 .next = NEXT(item_icmp6_nd_opt_tla_eth, NEXT_ENTRY(MAC_ADDR),
3079 .args = ARGS(ARGS_ENTRY_HTON
3080 (struct rte_flow_item_icmp6_nd_opt_tla_eth, tla)),
3084 .help = "match metadata header",
3085 .priv = PRIV_ITEM(META, sizeof(struct rte_flow_item_meta)),
3086 .next = NEXT(item_meta),
3089 [ITEM_META_DATA] = {
3091 .help = "metadata value",
3092 .next = NEXT(item_meta, NEXT_ENTRY(UNSIGNED), item_param),
3093 .args = ARGS(ARGS_ENTRY_MASK(struct rte_flow_item_meta,
3094 data, "\xff\xff\xff\xff")),
3098 .help = "match GRE key",
3099 .priv = PRIV_ITEM(GRE_KEY, sizeof(rte_be32_t)),
3100 .next = NEXT(item_gre_key),
3103 [ITEM_GRE_KEY_VALUE] = {
3105 .help = "key value",
3106 .next = NEXT(item_gre_key, NEXT_ENTRY(UNSIGNED), item_param),
3107 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3111 .help = "match GTP extension header with type 0x85",
3112 .priv = PRIV_ITEM(GTP_PSC,
3113 sizeof(struct rte_flow_item_gtp_psc)),
3114 .next = NEXT(item_gtp_psc),
3117 [ITEM_GTP_PSC_QFI] = {
3119 .help = "QoS flow identifier",
3120 .next = NEXT(item_gtp_psc, NEXT_ENTRY(UNSIGNED), item_param),
3121 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
3124 [ITEM_GTP_PSC_PDU_T] = {
3127 .next = NEXT(item_gtp_psc, NEXT_ENTRY(UNSIGNED), item_param),
3128 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
3133 .help = "match PPPoE session header",
3134 .priv = PRIV_ITEM(PPPOES, sizeof(struct rte_flow_item_pppoe)),
3135 .next = NEXT(item_pppoes),
3140 .help = "match PPPoE discovery header",
3141 .priv = PRIV_ITEM(PPPOED, sizeof(struct rte_flow_item_pppoe)),
3142 .next = NEXT(item_pppoed),
3145 [ITEM_PPPOE_SEID] = {
3147 .help = "session identifier",
3148 .next = NEXT(item_pppoes, NEXT_ENTRY(UNSIGNED), item_param),
3149 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pppoe,
3152 [ITEM_PPPOE_PROTO_ID] = {
3153 .name = "pppoe_proto_id",
3154 .help = "match PPPoE session protocol identifier",
3155 .priv = PRIV_ITEM(PPPOE_PROTO_ID,
3156 sizeof(struct rte_flow_item_pppoe_proto_id)),
3157 .next = NEXT(item_pppoe_proto_id, NEXT_ENTRY(UNSIGNED),
3159 .args = ARGS(ARGS_ENTRY_HTON
3160 (struct rte_flow_item_pppoe_proto_id, proto_id)),
3165 .help = "matches higig2 header",
3166 .priv = PRIV_ITEM(HIGIG2,
3167 sizeof(struct rte_flow_item_higig2_hdr)),
3168 .next = NEXT(item_higig2),
3171 [ITEM_HIGIG2_CLASSIFICATION] = {
3172 .name = "classification",
3173 .help = "matches classification of higig2 header",
3174 .next = NEXT(item_higig2, NEXT_ENTRY(UNSIGNED), item_param),
3175 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
3176 hdr.ppt1.classification)),
3178 [ITEM_HIGIG2_VID] = {
3180 .help = "matches vid of higig2 header",
3181 .next = NEXT(item_higig2, NEXT_ENTRY(UNSIGNED), item_param),
3182 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
3187 .help = "match tag value",
3188 .priv = PRIV_ITEM(TAG, sizeof(struct rte_flow_item_tag)),
3189 .next = NEXT(item_tag),
3194 .help = "tag value to match",
3195 .next = NEXT(item_tag, NEXT_ENTRY(UNSIGNED), item_param),
3196 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, data)),
3198 [ITEM_TAG_INDEX] = {
3200 .help = "index of tag array to match",
3201 .next = NEXT(item_tag, NEXT_ENTRY(UNSIGNED),
3202 NEXT_ENTRY(ITEM_PARAM_IS)),
3203 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, index)),
3205 [ITEM_L2TPV3OIP] = {
3206 .name = "l2tpv3oip",
3207 .help = "match L2TPv3 over IP header",
3208 .priv = PRIV_ITEM(L2TPV3OIP,
3209 sizeof(struct rte_flow_item_l2tpv3oip)),
3210 .next = NEXT(item_l2tpv3oip),
3213 [ITEM_L2TPV3OIP_SESSION_ID] = {
3214 .name = "session_id",
3215 .help = "session identifier",
3216 .next = NEXT(item_l2tpv3oip, NEXT_ENTRY(UNSIGNED), item_param),
3217 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv3oip,
3222 .help = "match ESP header",
3223 .priv = PRIV_ITEM(ESP, sizeof(struct rte_flow_item_esp)),
3224 .next = NEXT(item_esp),
3229 .help = "security policy index",
3230 .next = NEXT(item_esp, NEXT_ENTRY(UNSIGNED), item_param),
3231 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_esp,
3236 .help = "match AH header",
3237 .priv = PRIV_ITEM(AH, sizeof(struct rte_flow_item_ah)),
3238 .next = NEXT(item_ah),
3243 .help = "security parameters index",
3244 .next = NEXT(item_ah, NEXT_ENTRY(UNSIGNED), item_param),
3245 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ah, spi)),
3249 .help = "match pfcp header",
3250 .priv = PRIV_ITEM(PFCP, sizeof(struct rte_flow_item_pfcp)),
3251 .next = NEXT(item_pfcp),
3254 [ITEM_PFCP_S_FIELD] = {
3257 .next = NEXT(item_pfcp, NEXT_ENTRY(UNSIGNED), item_param),
3258 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp,
3261 [ITEM_PFCP_SEID] = {
3263 .help = "session endpoint identifier",
3264 .next = NEXT(item_pfcp, NEXT_ENTRY(UNSIGNED), item_param),
3265 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp, seid)),
3269 .help = "match eCPRI header",
3270 .priv = PRIV_ITEM(ECPRI, sizeof(struct rte_flow_item_ecpri)),
3271 .next = NEXT(item_ecpri),
3274 [ITEM_ECPRI_COMMON] = {
3276 .help = "eCPRI common header",
3277 .next = NEXT(item_ecpri_common),
3279 [ITEM_ECPRI_COMMON_TYPE] = {
3281 .help = "type of common header",
3282 .next = NEXT(item_ecpri_common_type),
3283 .args = ARGS(ARG_ENTRY_HTON(struct rte_flow_item_ecpri)),
3285 [ITEM_ECPRI_COMMON_TYPE_IQ_DATA] = {
3287 .help = "Type #0: IQ Data",
3288 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
3290 .call = parse_vc_item_ecpri_type,
3292 [ITEM_ECPRI_MSG_IQ_DATA_PCID] = {
3294 .help = "Physical Channel ID",
3295 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
3296 ITEM_ECPRI_COMMON, ITEM_NEXT),
3297 NEXT_ENTRY(UNSIGNED), item_param),
3298 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3301 [ITEM_ECPRI_COMMON_TYPE_RTC_CTRL] = {
3303 .help = "Type #2: Real-Time Control Data",
3304 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
3306 .call = parse_vc_item_ecpri_type,
3308 [ITEM_ECPRI_MSG_RTC_CTRL_RTCID] = {
3310 .help = "Real-Time Control Data ID",
3311 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
3312 ITEM_ECPRI_COMMON, ITEM_NEXT),
3313 NEXT_ENTRY(UNSIGNED), item_param),
3314 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3317 [ITEM_ECPRI_COMMON_TYPE_DLY_MSR] = {
3318 .name = "delay_measure",
3319 .help = "Type #5: One-Way Delay Measurement",
3320 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
3322 .call = parse_vc_item_ecpri_type,
3324 [ITEM_ECPRI_MSG_DLY_MSR_MSRID] = {
3326 .help = "Measurement ID",
3327 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
3328 ITEM_ECPRI_COMMON, ITEM_NEXT),
3329 NEXT_ENTRY(UNSIGNED), item_param),
3330 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3333 [ITEM_GENEVE_OPT] = {
3334 .name = "geneve-opt",
3335 .help = "GENEVE header option",
3336 .priv = PRIV_ITEM(GENEVE_OPT,
3337 sizeof(struct rte_flow_item_geneve_opt) +
3338 ITEM_GENEVE_OPT_DATA_SIZE),
3339 .next = NEXT(item_geneve_opt),
3342 [ITEM_GENEVE_OPT_CLASS] = {
3344 .help = "GENEVE option class",
3345 .next = NEXT(item_geneve_opt, NEXT_ENTRY(UNSIGNED), item_param),
3346 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve_opt,
3349 [ITEM_GENEVE_OPT_TYPE] = {
3351 .help = "GENEVE option type",
3352 .next = NEXT(item_geneve_opt, NEXT_ENTRY(UNSIGNED), item_param),
3353 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt,
3356 [ITEM_GENEVE_OPT_LENGTH] = {
3358 .help = "GENEVE option data length (in 32b words)",
3359 .next = NEXT(item_geneve_opt, NEXT_ENTRY(UNSIGNED), item_param),
3360 .args = ARGS(ARGS_ENTRY_BOUNDED(
3361 struct rte_flow_item_geneve_opt, option_len,
3364 [ITEM_GENEVE_OPT_DATA] = {
3366 .help = "GENEVE option data pattern",
3367 .next = NEXT(item_geneve_opt, NEXT_ENTRY(HEX), item_param),
3368 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt, data),
3369 ARGS_ENTRY_ARB(0, 0),
3371 (sizeof(struct rte_flow_item_geneve_opt),
3372 ITEM_GENEVE_OPT_DATA_SIZE)),
3374 /* Validate/create actions. */
3377 .help = "submit a list of associated actions",
3378 .next = NEXT(next_action),
3383 .help = "specify next action",
3384 .next = NEXT(next_action),
3388 .help = "end list of actions",
3389 .priv = PRIV_ACTION(END, 0),
3394 .help = "no-op action",
3395 .priv = PRIV_ACTION(VOID, 0),
3396 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3399 [ACTION_PASSTHRU] = {
3401 .help = "let subsequent rule process matched packets",
3402 .priv = PRIV_ACTION(PASSTHRU, 0),
3403 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3408 .help = "redirect traffic to a given group",
3409 .priv = PRIV_ACTION(JUMP, sizeof(struct rte_flow_action_jump)),
3410 .next = NEXT(action_jump),
3413 [ACTION_JUMP_GROUP] = {
3415 .help = "group to redirect traffic to",
3416 .next = NEXT(action_jump, NEXT_ENTRY(UNSIGNED)),
3417 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump, group)),
3418 .call = parse_vc_conf,
3422 .help = "attach 32 bit value to packets",
3423 .priv = PRIV_ACTION(MARK, sizeof(struct rte_flow_action_mark)),
3424 .next = NEXT(action_mark),
3427 [ACTION_MARK_ID] = {
3429 .help = "32 bit value to return with packets",
3430 .next = NEXT(action_mark, NEXT_ENTRY(UNSIGNED)),
3431 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_mark, id)),
3432 .call = parse_vc_conf,
3436 .help = "flag packets",
3437 .priv = PRIV_ACTION(FLAG, 0),
3438 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3443 .help = "assign packets to a given queue index",
3444 .priv = PRIV_ACTION(QUEUE,
3445 sizeof(struct rte_flow_action_queue)),
3446 .next = NEXT(action_queue),
3449 [ACTION_QUEUE_INDEX] = {
3451 .help = "queue index to use",
3452 .next = NEXT(action_queue, NEXT_ENTRY(UNSIGNED)),
3453 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_queue, index)),
3454 .call = parse_vc_conf,
3458 .help = "drop packets (note: passthru has priority)",
3459 .priv = PRIV_ACTION(DROP, 0),
3460 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3465 .help = "enable counters for this rule",
3466 .priv = PRIV_ACTION(COUNT,
3467 sizeof(struct rte_flow_action_count)),
3468 .next = NEXT(action_count),
3471 [ACTION_COUNT_ID] = {
3472 .name = "identifier",
3473 .help = "counter identifier to use",
3474 .next = NEXT(action_count, NEXT_ENTRY(UNSIGNED)),
3475 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_count, id)),
3476 .call = parse_vc_conf,
3478 [ACTION_COUNT_SHARED] = {
3480 .help = "shared counter",
3481 .next = NEXT(action_count, NEXT_ENTRY(BOOLEAN)),
3482 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_count,
3484 .call = parse_vc_conf,
3488 .help = "spread packets among several queues",
3489 .priv = PRIV_ACTION(RSS, sizeof(struct action_rss_data)),
3490 .next = NEXT(action_rss),
3491 .call = parse_vc_action_rss,
3493 [ACTION_RSS_FUNC] = {
3495 .help = "RSS hash function to apply",
3496 .next = NEXT(action_rss,
3497 NEXT_ENTRY(ACTION_RSS_FUNC_DEFAULT,
3498 ACTION_RSS_FUNC_TOEPLITZ,
3499 ACTION_RSS_FUNC_SIMPLE_XOR,
3500 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ)),
3502 [ACTION_RSS_FUNC_DEFAULT] = {
3504 .help = "default hash function",
3505 .call = parse_vc_action_rss_func,
3507 [ACTION_RSS_FUNC_TOEPLITZ] = {
3509 .help = "Toeplitz hash function",
3510 .call = parse_vc_action_rss_func,
3512 [ACTION_RSS_FUNC_SIMPLE_XOR] = {
3513 .name = "simple_xor",
3514 .help = "simple XOR hash function",
3515 .call = parse_vc_action_rss_func,
3517 [ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ] = {
3518 .name = "symmetric_toeplitz",
3519 .help = "Symmetric Toeplitz hash function",
3520 .call = parse_vc_action_rss_func,
3522 [ACTION_RSS_LEVEL] = {
3524 .help = "encapsulation level for \"types\"",
3525 .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
3526 .args = ARGS(ARGS_ENTRY_ARB
3527 (offsetof(struct action_rss_data, conf) +
3528 offsetof(struct rte_flow_action_rss, level),
3529 sizeof(((struct rte_flow_action_rss *)0)->
3532 [ACTION_RSS_TYPES] = {
3534 .help = "specific RSS hash types",
3535 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)),
3537 [ACTION_RSS_TYPE] = {
3539 .help = "RSS hash type",
3540 .call = parse_vc_action_rss_type,
3541 .comp = comp_vc_action_rss_type,
3543 [ACTION_RSS_KEY] = {
3545 .help = "RSS hash key",
3546 .next = NEXT(action_rss, NEXT_ENTRY(HEX)),
3547 .args = ARGS(ARGS_ENTRY_ARB
3548 (offsetof(struct action_rss_data, conf) +
3549 offsetof(struct rte_flow_action_rss, key),
3550 sizeof(((struct rte_flow_action_rss *)0)->key)),
3552 (offsetof(struct action_rss_data, conf) +
3553 offsetof(struct rte_flow_action_rss, key_len),
3554 sizeof(((struct rte_flow_action_rss *)0)->
3556 ARGS_ENTRY(struct action_rss_data, key)),
3558 [ACTION_RSS_KEY_LEN] = {
3560 .help = "RSS hash key length in bytes",
3561 .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
3562 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
3563 (offsetof(struct action_rss_data, conf) +
3564 offsetof(struct rte_flow_action_rss, key_len),
3565 sizeof(((struct rte_flow_action_rss *)0)->
3568 RSS_HASH_KEY_LENGTH)),
3570 [ACTION_RSS_QUEUES] = {
3572 .help = "queue indices to use",
3573 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_QUEUE)),
3574 .call = parse_vc_conf,
3576 [ACTION_RSS_QUEUE] = {
3578 .help = "queue index",
3579 .call = parse_vc_action_rss_queue,
3580 .comp = comp_vc_action_rss_queue,
3584 .help = "direct traffic to physical function",
3585 .priv = PRIV_ACTION(PF, 0),
3586 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3591 .help = "direct traffic to a virtual function ID",
3592 .priv = PRIV_ACTION(VF, sizeof(struct rte_flow_action_vf)),
3593 .next = NEXT(action_vf),
3596 [ACTION_VF_ORIGINAL] = {
3598 .help = "use original VF ID if possible",
3599 .next = NEXT(action_vf, NEXT_ENTRY(BOOLEAN)),
3600 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_vf,
3602 .call = parse_vc_conf,
3607 .next = NEXT(action_vf, NEXT_ENTRY(UNSIGNED)),
3608 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)),
3609 .call = parse_vc_conf,
3611 [ACTION_PHY_PORT] = {
3613 .help = "direct packets to physical port index",
3614 .priv = PRIV_ACTION(PHY_PORT,
3615 sizeof(struct rte_flow_action_phy_port)),
3616 .next = NEXT(action_phy_port),
3619 [ACTION_PHY_PORT_ORIGINAL] = {
3621 .help = "use original port index if possible",
3622 .next = NEXT(action_phy_port, NEXT_ENTRY(BOOLEAN)),
3623 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_phy_port,
3625 .call = parse_vc_conf,
3627 [ACTION_PHY_PORT_INDEX] = {
3629 .help = "physical port index",
3630 .next = NEXT(action_phy_port, NEXT_ENTRY(UNSIGNED)),
3631 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_phy_port,
3633 .call = parse_vc_conf,
3635 [ACTION_PORT_ID] = {
3637 .help = "direct matching traffic to a given DPDK port ID",
3638 .priv = PRIV_ACTION(PORT_ID,
3639 sizeof(struct rte_flow_action_port_id)),
3640 .next = NEXT(action_port_id),
3643 [ACTION_PORT_ID_ORIGINAL] = {
3645 .help = "use original DPDK port ID if possible",
3646 .next = NEXT(action_port_id, NEXT_ENTRY(BOOLEAN)),
3647 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_port_id,
3649 .call = parse_vc_conf,
3651 [ACTION_PORT_ID_ID] = {
3653 .help = "DPDK port ID",
3654 .next = NEXT(action_port_id, NEXT_ENTRY(UNSIGNED)),
3655 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_port_id, id)),
3656 .call = parse_vc_conf,
3660 .help = "meter the directed packets at given id",
3661 .priv = PRIV_ACTION(METER,
3662 sizeof(struct rte_flow_action_meter)),
3663 .next = NEXT(action_meter),
3666 [ACTION_METER_ID] = {
3668 .help = "meter id to use",
3669 .next = NEXT(action_meter, NEXT_ENTRY(UNSIGNED)),
3670 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter, mtr_id)),
3671 .call = parse_vc_conf,
3673 [ACTION_OF_SET_MPLS_TTL] = {
3674 .name = "of_set_mpls_ttl",
3675 .help = "OpenFlow's OFPAT_SET_MPLS_TTL",
3678 sizeof(struct rte_flow_action_of_set_mpls_ttl)),
3679 .next = NEXT(action_of_set_mpls_ttl),
3682 [ACTION_OF_SET_MPLS_TTL_MPLS_TTL] = {
3685 .next = NEXT(action_of_set_mpls_ttl, NEXT_ENTRY(UNSIGNED)),
3686 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_mpls_ttl,
3688 .call = parse_vc_conf,
3690 [ACTION_OF_DEC_MPLS_TTL] = {
3691 .name = "of_dec_mpls_ttl",
3692 .help = "OpenFlow's OFPAT_DEC_MPLS_TTL",
3693 .priv = PRIV_ACTION(OF_DEC_MPLS_TTL, 0),
3694 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3697 [ACTION_OF_SET_NW_TTL] = {
3698 .name = "of_set_nw_ttl",
3699 .help = "OpenFlow's OFPAT_SET_NW_TTL",
3702 sizeof(struct rte_flow_action_of_set_nw_ttl)),
3703 .next = NEXT(action_of_set_nw_ttl),
3706 [ACTION_OF_SET_NW_TTL_NW_TTL] = {
3709 .next = NEXT(action_of_set_nw_ttl, NEXT_ENTRY(UNSIGNED)),
3710 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_nw_ttl,
3712 .call = parse_vc_conf,
3714 [ACTION_OF_DEC_NW_TTL] = {
3715 .name = "of_dec_nw_ttl",
3716 .help = "OpenFlow's OFPAT_DEC_NW_TTL",
3717 .priv = PRIV_ACTION(OF_DEC_NW_TTL, 0),
3718 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3721 [ACTION_OF_COPY_TTL_OUT] = {
3722 .name = "of_copy_ttl_out",
3723 .help = "OpenFlow's OFPAT_COPY_TTL_OUT",
3724 .priv = PRIV_ACTION(OF_COPY_TTL_OUT, 0),
3725 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3728 [ACTION_OF_COPY_TTL_IN] = {
3729 .name = "of_copy_ttl_in",
3730 .help = "OpenFlow's OFPAT_COPY_TTL_IN",
3731 .priv = PRIV_ACTION(OF_COPY_TTL_IN, 0),
3732 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3735 [ACTION_OF_POP_VLAN] = {
3736 .name = "of_pop_vlan",
3737 .help = "OpenFlow's OFPAT_POP_VLAN",
3738 .priv = PRIV_ACTION(OF_POP_VLAN, 0),
3739 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3742 [ACTION_OF_PUSH_VLAN] = {
3743 .name = "of_push_vlan",
3744 .help = "OpenFlow's OFPAT_PUSH_VLAN",
3747 sizeof(struct rte_flow_action_of_push_vlan)),
3748 .next = NEXT(action_of_push_vlan),
3751 [ACTION_OF_PUSH_VLAN_ETHERTYPE] = {
3752 .name = "ethertype",
3753 .help = "EtherType",
3754 .next = NEXT(action_of_push_vlan, NEXT_ENTRY(UNSIGNED)),
3755 .args = ARGS(ARGS_ENTRY_HTON
3756 (struct rte_flow_action_of_push_vlan,
3758 .call = parse_vc_conf,
3760 [ACTION_OF_SET_VLAN_VID] = {
3761 .name = "of_set_vlan_vid",
3762 .help = "OpenFlow's OFPAT_SET_VLAN_VID",
3765 sizeof(struct rte_flow_action_of_set_vlan_vid)),
3766 .next = NEXT(action_of_set_vlan_vid),
3769 [ACTION_OF_SET_VLAN_VID_VLAN_VID] = {
3772 .next = NEXT(action_of_set_vlan_vid, NEXT_ENTRY(UNSIGNED)),
3773 .args = ARGS(ARGS_ENTRY_HTON
3774 (struct rte_flow_action_of_set_vlan_vid,
3776 .call = parse_vc_conf,
3778 [ACTION_OF_SET_VLAN_PCP] = {
3779 .name = "of_set_vlan_pcp",
3780 .help = "OpenFlow's OFPAT_SET_VLAN_PCP",
3783 sizeof(struct rte_flow_action_of_set_vlan_pcp)),
3784 .next = NEXT(action_of_set_vlan_pcp),
3787 [ACTION_OF_SET_VLAN_PCP_VLAN_PCP] = {
3789 .help = "VLAN priority",
3790 .next = NEXT(action_of_set_vlan_pcp, NEXT_ENTRY(UNSIGNED)),
3791 .args = ARGS(ARGS_ENTRY_HTON
3792 (struct rte_flow_action_of_set_vlan_pcp,
3794 .call = parse_vc_conf,
3796 [ACTION_OF_POP_MPLS] = {
3797 .name = "of_pop_mpls",
3798 .help = "OpenFlow's OFPAT_POP_MPLS",
3799 .priv = PRIV_ACTION(OF_POP_MPLS,
3800 sizeof(struct rte_flow_action_of_pop_mpls)),
3801 .next = NEXT(action_of_pop_mpls),
3804 [ACTION_OF_POP_MPLS_ETHERTYPE] = {
3805 .name = "ethertype",
3806 .help = "EtherType",
3807 .next = NEXT(action_of_pop_mpls, NEXT_ENTRY(UNSIGNED)),
3808 .args = ARGS(ARGS_ENTRY_HTON
3809 (struct rte_flow_action_of_pop_mpls,
3811 .call = parse_vc_conf,
3813 [ACTION_OF_PUSH_MPLS] = {
3814 .name = "of_push_mpls",
3815 .help = "OpenFlow's OFPAT_PUSH_MPLS",
3818 sizeof(struct rte_flow_action_of_push_mpls)),
3819 .next = NEXT(action_of_push_mpls),
3822 [ACTION_OF_PUSH_MPLS_ETHERTYPE] = {
3823 .name = "ethertype",
3824 .help = "EtherType",
3825 .next = NEXT(action_of_push_mpls, NEXT_ENTRY(UNSIGNED)),
3826 .args = ARGS(ARGS_ENTRY_HTON
3827 (struct rte_flow_action_of_push_mpls,
3829 .call = parse_vc_conf,
3831 [ACTION_VXLAN_ENCAP] = {
3832 .name = "vxlan_encap",
3833 .help = "VXLAN encapsulation, uses configuration set by \"set"
3835 .priv = PRIV_ACTION(VXLAN_ENCAP,
3836 sizeof(struct action_vxlan_encap_data)),
3837 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3838 .call = parse_vc_action_vxlan_encap,
3840 [ACTION_VXLAN_DECAP] = {
3841 .name = "vxlan_decap",
3842 .help = "Performs a decapsulation action by stripping all"
3843 " headers of the VXLAN tunnel network overlay from the"
3845 .priv = PRIV_ACTION(VXLAN_DECAP, 0),
3846 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3849 [ACTION_NVGRE_ENCAP] = {
3850 .name = "nvgre_encap",
3851 .help = "NVGRE encapsulation, uses configuration set by \"set"
3853 .priv = PRIV_ACTION(NVGRE_ENCAP,
3854 sizeof(struct action_nvgre_encap_data)),
3855 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3856 .call = parse_vc_action_nvgre_encap,
3858 [ACTION_NVGRE_DECAP] = {
3859 .name = "nvgre_decap",
3860 .help = "Performs a decapsulation action by stripping all"
3861 " headers of the NVGRE tunnel network overlay from the"
3863 .priv = PRIV_ACTION(NVGRE_DECAP, 0),
3864 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3867 [ACTION_L2_ENCAP] = {
3869 .help = "l2 encap, uses configuration set by"
3870 " \"set l2_encap\"",
3871 .priv = PRIV_ACTION(RAW_ENCAP,
3872 sizeof(struct action_raw_encap_data)),
3873 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3874 .call = parse_vc_action_l2_encap,
3876 [ACTION_L2_DECAP] = {
3878 .help = "l2 decap, uses configuration set by"
3879 " \"set l2_decap\"",
3880 .priv = PRIV_ACTION(RAW_DECAP,
3881 sizeof(struct action_raw_decap_data)),
3882 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3883 .call = parse_vc_action_l2_decap,
3885 [ACTION_MPLSOGRE_ENCAP] = {
3886 .name = "mplsogre_encap",
3887 .help = "mplsogre encapsulation, uses configuration set by"
3888 " \"set mplsogre_encap\"",
3889 .priv = PRIV_ACTION(RAW_ENCAP,
3890 sizeof(struct action_raw_encap_data)),
3891 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3892 .call = parse_vc_action_mplsogre_encap,
3894 [ACTION_MPLSOGRE_DECAP] = {
3895 .name = "mplsogre_decap",
3896 .help = "mplsogre decapsulation, uses configuration set by"
3897 " \"set mplsogre_decap\"",
3898 .priv = PRIV_ACTION(RAW_DECAP,
3899 sizeof(struct action_raw_decap_data)),
3900 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3901 .call = parse_vc_action_mplsogre_decap,
3903 [ACTION_MPLSOUDP_ENCAP] = {
3904 .name = "mplsoudp_encap",
3905 .help = "mplsoudp encapsulation, uses configuration set by"
3906 " \"set mplsoudp_encap\"",
3907 .priv = PRIV_ACTION(RAW_ENCAP,
3908 sizeof(struct action_raw_encap_data)),
3909 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3910 .call = parse_vc_action_mplsoudp_encap,
3912 [ACTION_MPLSOUDP_DECAP] = {
3913 .name = "mplsoudp_decap",
3914 .help = "mplsoudp decapsulation, uses configuration set by"
3915 " \"set mplsoudp_decap\"",
3916 .priv = PRIV_ACTION(RAW_DECAP,
3917 sizeof(struct action_raw_decap_data)),
3918 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3919 .call = parse_vc_action_mplsoudp_decap,
3921 [ACTION_SET_IPV4_SRC] = {
3922 .name = "set_ipv4_src",
3923 .help = "Set a new IPv4 source address in the outermost"
3925 .priv = PRIV_ACTION(SET_IPV4_SRC,
3926 sizeof(struct rte_flow_action_set_ipv4)),
3927 .next = NEXT(action_set_ipv4_src),
3930 [ACTION_SET_IPV4_SRC_IPV4_SRC] = {
3931 .name = "ipv4_addr",
3932 .help = "new IPv4 source address to set",
3933 .next = NEXT(action_set_ipv4_src, NEXT_ENTRY(IPV4_ADDR)),
3934 .args = ARGS(ARGS_ENTRY_HTON
3935 (struct rte_flow_action_set_ipv4, ipv4_addr)),
3936 .call = parse_vc_conf,
3938 [ACTION_SET_IPV4_DST] = {
3939 .name = "set_ipv4_dst",
3940 .help = "Set a new IPv4 destination address in the outermost"
3942 .priv = PRIV_ACTION(SET_IPV4_DST,
3943 sizeof(struct rte_flow_action_set_ipv4)),
3944 .next = NEXT(action_set_ipv4_dst),
3947 [ACTION_SET_IPV4_DST_IPV4_DST] = {
3948 .name = "ipv4_addr",
3949 .help = "new IPv4 destination address to set",
3950 .next = NEXT(action_set_ipv4_dst, NEXT_ENTRY(IPV4_ADDR)),
3951 .args = ARGS(ARGS_ENTRY_HTON
3952 (struct rte_flow_action_set_ipv4, ipv4_addr)),
3953 .call = parse_vc_conf,
3955 [ACTION_SET_IPV6_SRC] = {
3956 .name = "set_ipv6_src",
3957 .help = "Set a new IPv6 source address in the outermost"
3959 .priv = PRIV_ACTION(SET_IPV6_SRC,
3960 sizeof(struct rte_flow_action_set_ipv6)),
3961 .next = NEXT(action_set_ipv6_src),
3964 [ACTION_SET_IPV6_SRC_IPV6_SRC] = {
3965 .name = "ipv6_addr",
3966 .help = "new IPv6 source address to set",
3967 .next = NEXT(action_set_ipv6_src, NEXT_ENTRY(IPV6_ADDR)),
3968 .args = ARGS(ARGS_ENTRY_HTON
3969 (struct rte_flow_action_set_ipv6, ipv6_addr)),
3970 .call = parse_vc_conf,
3972 [ACTION_SET_IPV6_DST] = {
3973 .name = "set_ipv6_dst",
3974 .help = "Set a new IPv6 destination address in the outermost"
3976 .priv = PRIV_ACTION(SET_IPV6_DST,
3977 sizeof(struct rte_flow_action_set_ipv6)),
3978 .next = NEXT(action_set_ipv6_dst),
3981 [ACTION_SET_IPV6_DST_IPV6_DST] = {
3982 .name = "ipv6_addr",
3983 .help = "new IPv6 destination address to set",
3984 .next = NEXT(action_set_ipv6_dst, NEXT_ENTRY(IPV6_ADDR)),
3985 .args = ARGS(ARGS_ENTRY_HTON
3986 (struct rte_flow_action_set_ipv6, ipv6_addr)),
3987 .call = parse_vc_conf,
3989 [ACTION_SET_TP_SRC] = {
3990 .name = "set_tp_src",
3991 .help = "set a new source port number in the outermost"
3993 .priv = PRIV_ACTION(SET_TP_SRC,
3994 sizeof(struct rte_flow_action_set_tp)),
3995 .next = NEXT(action_set_tp_src),
3998 [ACTION_SET_TP_SRC_TP_SRC] = {
4000 .help = "new source port number to set",
4001 .next = NEXT(action_set_tp_src, NEXT_ENTRY(UNSIGNED)),
4002 .args = ARGS(ARGS_ENTRY_HTON
4003 (struct rte_flow_action_set_tp, port)),
4004 .call = parse_vc_conf,
4006 [ACTION_SET_TP_DST] = {
4007 .name = "set_tp_dst",
4008 .help = "set a new destination port number in the outermost"
4010 .priv = PRIV_ACTION(SET_TP_DST,
4011 sizeof(struct rte_flow_action_set_tp)),
4012 .next = NEXT(action_set_tp_dst),
4015 [ACTION_SET_TP_DST_TP_DST] = {
4017 .help = "new destination port number to set",
4018 .next = NEXT(action_set_tp_dst, NEXT_ENTRY(UNSIGNED)),
4019 .args = ARGS(ARGS_ENTRY_HTON
4020 (struct rte_flow_action_set_tp, port)),
4021 .call = parse_vc_conf,
4023 [ACTION_MAC_SWAP] = {
4025 .help = "Swap the source and destination MAC addresses"
4026 " in the outermost Ethernet header",
4027 .priv = PRIV_ACTION(MAC_SWAP, 0),
4028 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4031 [ACTION_DEC_TTL] = {
4033 .help = "decrease network TTL if available",
4034 .priv = PRIV_ACTION(DEC_TTL, 0),
4035 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4038 [ACTION_SET_TTL] = {
4040 .help = "set ttl value",
4041 .priv = PRIV_ACTION(SET_TTL,
4042 sizeof(struct rte_flow_action_set_ttl)),
4043 .next = NEXT(action_set_ttl),
4046 [ACTION_SET_TTL_TTL] = {
4047 .name = "ttl_value",
4048 .help = "new ttl value to set",
4049 .next = NEXT(action_set_ttl, NEXT_ENTRY(UNSIGNED)),
4050 .args = ARGS(ARGS_ENTRY_HTON
4051 (struct rte_flow_action_set_ttl, ttl_value)),
4052 .call = parse_vc_conf,
4054 [ACTION_SET_MAC_SRC] = {
4055 .name = "set_mac_src",
4056 .help = "set source mac address",
4057 .priv = PRIV_ACTION(SET_MAC_SRC,
4058 sizeof(struct rte_flow_action_set_mac)),
4059 .next = NEXT(action_set_mac_src),
4062 [ACTION_SET_MAC_SRC_MAC_SRC] = {
4064 .help = "new source mac address",
4065 .next = NEXT(action_set_mac_src, NEXT_ENTRY(MAC_ADDR)),
4066 .args = ARGS(ARGS_ENTRY_HTON
4067 (struct rte_flow_action_set_mac, mac_addr)),
4068 .call = parse_vc_conf,
4070 [ACTION_SET_MAC_DST] = {
4071 .name = "set_mac_dst",
4072 .help = "set destination mac address",
4073 .priv = PRIV_ACTION(SET_MAC_DST,
4074 sizeof(struct rte_flow_action_set_mac)),
4075 .next = NEXT(action_set_mac_dst),
4078 [ACTION_SET_MAC_DST_MAC_DST] = {
4080 .help = "new destination mac address to set",
4081 .next = NEXT(action_set_mac_dst, NEXT_ENTRY(MAC_ADDR)),
4082 .args = ARGS(ARGS_ENTRY_HTON
4083 (struct rte_flow_action_set_mac, mac_addr)),
4084 .call = parse_vc_conf,
4086 [ACTION_INC_TCP_SEQ] = {
4087 .name = "inc_tcp_seq",
4088 .help = "increase TCP sequence number",
4089 .priv = PRIV_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
4090 .next = NEXT(action_inc_tcp_seq),
4093 [ACTION_INC_TCP_SEQ_VALUE] = {
4095 .help = "the value to increase TCP sequence number by",
4096 .next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(UNSIGNED)),
4097 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4098 .call = parse_vc_conf,
4100 [ACTION_DEC_TCP_SEQ] = {
4101 .name = "dec_tcp_seq",
4102 .help = "decrease TCP sequence number",
4103 .priv = PRIV_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
4104 .next = NEXT(action_dec_tcp_seq),
4107 [ACTION_DEC_TCP_SEQ_VALUE] = {
4109 .help = "the value to decrease TCP sequence number by",
4110 .next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(UNSIGNED)),
4111 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4112 .call = parse_vc_conf,
4114 [ACTION_INC_TCP_ACK] = {
4115 .name = "inc_tcp_ack",
4116 .help = "increase TCP acknowledgment number",
4117 .priv = PRIV_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
4118 .next = NEXT(action_inc_tcp_ack),
4121 [ACTION_INC_TCP_ACK_VALUE] = {
4123 .help = "the value to increase TCP acknowledgment number by",
4124 .next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(UNSIGNED)),
4125 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4126 .call = parse_vc_conf,
4128 [ACTION_DEC_TCP_ACK] = {
4129 .name = "dec_tcp_ack",
4130 .help = "decrease TCP acknowledgment number",
4131 .priv = PRIV_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
4132 .next = NEXT(action_dec_tcp_ack),
4135 [ACTION_DEC_TCP_ACK_VALUE] = {
4137 .help = "the value to decrease TCP acknowledgment number by",
4138 .next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(UNSIGNED)),
4139 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4140 .call = parse_vc_conf,
4142 [ACTION_RAW_ENCAP] = {
4143 .name = "raw_encap",
4144 .help = "encapsulation data, defined by set raw_encap",
4145 .priv = PRIV_ACTION(RAW_ENCAP,
4146 sizeof(struct action_raw_encap_data)),
4147 .next = NEXT(action_raw_encap),
4148 .call = parse_vc_action_raw_encap,
4150 [ACTION_RAW_ENCAP_INDEX] = {
4152 .help = "the index of raw_encap_confs",
4153 .next = NEXT(NEXT_ENTRY(ACTION_RAW_ENCAP_INDEX_VALUE)),
4155 [ACTION_RAW_ENCAP_INDEX_VALUE] = {
4158 .help = "unsigned integer value",
4159 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4160 .call = parse_vc_action_raw_encap_index,
4161 .comp = comp_set_raw_index,
4163 [ACTION_RAW_DECAP] = {
4164 .name = "raw_decap",
4165 .help = "decapsulation data, defined by set raw_encap",
4166 .priv = PRIV_ACTION(RAW_DECAP,
4167 sizeof(struct action_raw_decap_data)),
4168 .next = NEXT(action_raw_decap),
4169 .call = parse_vc_action_raw_decap,
4171 [ACTION_RAW_DECAP_INDEX] = {
4173 .help = "the index of raw_encap_confs",
4174 .next = NEXT(NEXT_ENTRY(ACTION_RAW_DECAP_INDEX_VALUE)),
4176 [ACTION_RAW_DECAP_INDEX_VALUE] = {
4179 .help = "unsigned integer value",
4180 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4181 .call = parse_vc_action_raw_decap_index,
4182 .comp = comp_set_raw_index,
4184 [ACTION_MODIFY_FIELD] = {
4185 .name = "modify_field",
4186 .help = "modify destination field with data from source field",
4187 .priv = PRIV_ACTION(MODIFY_FIELD,
4188 sizeof(struct rte_flow_action_modify_field)),
4189 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_OP)),
4192 [ACTION_MODIFY_FIELD_OP] = {
4194 .help = "operation type",
4195 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_TYPE),
4196 NEXT_ENTRY(ACTION_MODIFY_FIELD_OP_VALUE)),
4197 .call = parse_vc_conf,
4199 [ACTION_MODIFY_FIELD_OP_VALUE] = {
4200 .name = "{operation}",
4201 .help = "operation type value",
4202 .call = parse_vc_modify_field_op,
4203 .comp = comp_set_modify_field_op,
4205 [ACTION_MODIFY_FIELD_DST_TYPE] = {
4207 .help = "destination field type",
4208 .next = NEXT(action_modify_field_dst,
4209 NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_TYPE_VALUE)),
4210 .call = parse_vc_conf,
4212 [ACTION_MODIFY_FIELD_DST_TYPE_VALUE] = {
4213 .name = "{dst_type}",
4214 .help = "destination field type value",
4215 .call = parse_vc_modify_field_id,
4216 .comp = comp_set_modify_field_id,
4218 [ACTION_MODIFY_FIELD_DST_LEVEL] = {
4219 .name = "dst_level",
4220 .help = "destination field level",
4221 .next = NEXT(action_modify_field_dst, NEXT_ENTRY(UNSIGNED)),
4222 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4224 .call = parse_vc_conf,
4226 [ACTION_MODIFY_FIELD_DST_OFFSET] = {
4227 .name = "dst_offset",
4228 .help = "destination field bit offset",
4229 .next = NEXT(action_modify_field_dst, NEXT_ENTRY(UNSIGNED)),
4230 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4232 .call = parse_vc_conf,
4234 [ACTION_MODIFY_FIELD_SRC_TYPE] = {
4236 .help = "source field type",
4237 .next = NEXT(action_modify_field_src,
4238 NEXT_ENTRY(ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)),
4239 .call = parse_vc_conf,
4241 [ACTION_MODIFY_FIELD_SRC_TYPE_VALUE] = {
4242 .name = "{src_type}",
4243 .help = "source field type value",
4244 .call = parse_vc_modify_field_id,
4245 .comp = comp_set_modify_field_id,
4247 [ACTION_MODIFY_FIELD_SRC_LEVEL] = {
4248 .name = "src_level",
4249 .help = "source field level",
4250 .next = NEXT(action_modify_field_src, NEXT_ENTRY(UNSIGNED)),
4251 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4253 .call = parse_vc_conf,
4255 [ACTION_MODIFY_FIELD_SRC_OFFSET] = {
4256 .name = "src_offset",
4257 .help = "source field bit offset",
4258 .next = NEXT(action_modify_field_src, NEXT_ENTRY(UNSIGNED)),
4259 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4261 .call = parse_vc_conf,
4263 [ACTION_MODIFY_FIELD_SRC_VALUE] = {
4264 .name = "src_value",
4265 .help = "source immediate value",
4266 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_WIDTH),
4267 NEXT_ENTRY(UNSIGNED)),
4268 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4270 .call = parse_vc_conf,
4272 [ACTION_MODIFY_FIELD_WIDTH] = {
4274 .help = "number of bits to copy",
4275 .next = NEXT(NEXT_ENTRY(ACTION_NEXT),
4276 NEXT_ENTRY(UNSIGNED)),
4277 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4279 .call = parse_vc_conf,
4281 /* Top level command. */
4284 .help = "set raw encap/decap/sample data",
4285 .type = "set raw_encap|raw_decap <index> <pattern>"
4286 " or set sample_actions <index> <action>",
4287 .next = NEXT(NEXT_ENTRY
4290 SET_SAMPLE_ACTIONS)),
4291 .call = parse_set_init,
4293 /* Sub-level commands. */
4295 .name = "raw_encap",
4296 .help = "set raw encap data",
4297 .next = NEXT(next_set_raw),
4298 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4299 (offsetof(struct buffer, port),
4300 sizeof(((struct buffer *)0)->port),
4301 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
4302 .call = parse_set_raw_encap_decap,
4305 .name = "raw_decap",
4306 .help = "set raw decap data",
4307 .next = NEXT(next_set_raw),
4308 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4309 (offsetof(struct buffer, port),
4310 sizeof(((struct buffer *)0)->port),
4311 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
4312 .call = parse_set_raw_encap_decap,
4317 .help = "index of raw_encap/raw_decap data",
4318 .next = NEXT(next_item),
4321 [SET_SAMPLE_INDEX] = {
4324 .help = "index of sample actions",
4325 .next = NEXT(next_action_sample),
4328 [SET_SAMPLE_ACTIONS] = {
4329 .name = "sample_actions",
4330 .help = "set sample actions list",
4331 .next = NEXT(NEXT_ENTRY(SET_SAMPLE_INDEX)),
4332 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4333 (offsetof(struct buffer, port),
4334 sizeof(((struct buffer *)0)->port),
4335 0, RAW_SAMPLE_CONFS_MAX_NUM - 1)),
4336 .call = parse_set_sample_action,
4338 [ACTION_SET_TAG] = {
4341 .priv = PRIV_ACTION(SET_TAG,
4342 sizeof(struct rte_flow_action_set_tag)),
4343 .next = NEXT(action_set_tag),
4346 [ACTION_SET_TAG_INDEX] = {
4348 .help = "index of tag array",
4349 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
4350 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_set_tag, index)),
4351 .call = parse_vc_conf,
4353 [ACTION_SET_TAG_DATA] = {
4355 .help = "tag value",
4356 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
4357 .args = ARGS(ARGS_ENTRY
4358 (struct rte_flow_action_set_tag, data)),
4359 .call = parse_vc_conf,
4361 [ACTION_SET_TAG_MASK] = {
4363 .help = "mask for tag value",
4364 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
4365 .args = ARGS(ARGS_ENTRY
4366 (struct rte_flow_action_set_tag, mask)),
4367 .call = parse_vc_conf,
4369 [ACTION_SET_META] = {
4371 .help = "set metadata",
4372 .priv = PRIV_ACTION(SET_META,
4373 sizeof(struct rte_flow_action_set_meta)),
4374 .next = NEXT(action_set_meta),
4375 .call = parse_vc_action_set_meta,
4377 [ACTION_SET_META_DATA] = {
4379 .help = "metadata value",
4380 .next = NEXT(action_set_meta, NEXT_ENTRY(UNSIGNED)),
4381 .args = ARGS(ARGS_ENTRY
4382 (struct rte_flow_action_set_meta, data)),
4383 .call = parse_vc_conf,
4385 [ACTION_SET_META_MASK] = {
4387 .help = "mask for metadata value",
4388 .next = NEXT(action_set_meta, NEXT_ENTRY(UNSIGNED)),
4389 .args = ARGS(ARGS_ENTRY
4390 (struct rte_flow_action_set_meta, mask)),
4391 .call = parse_vc_conf,
4393 [ACTION_SET_IPV4_DSCP] = {
4394 .name = "set_ipv4_dscp",
4395 .help = "set DSCP value",
4396 .priv = PRIV_ACTION(SET_IPV4_DSCP,
4397 sizeof(struct rte_flow_action_set_dscp)),
4398 .next = NEXT(action_set_ipv4_dscp),
4401 [ACTION_SET_IPV4_DSCP_VALUE] = {
4402 .name = "dscp_value",
4403 .help = "new IPv4 DSCP value to set",
4404 .next = NEXT(action_set_ipv4_dscp, NEXT_ENTRY(UNSIGNED)),
4405 .args = ARGS(ARGS_ENTRY
4406 (struct rte_flow_action_set_dscp, dscp)),
4407 .call = parse_vc_conf,
4409 [ACTION_SET_IPV6_DSCP] = {
4410 .name = "set_ipv6_dscp",
4411 .help = "set DSCP value",
4412 .priv = PRIV_ACTION(SET_IPV6_DSCP,
4413 sizeof(struct rte_flow_action_set_dscp)),
4414 .next = NEXT(action_set_ipv6_dscp),
4417 [ACTION_SET_IPV6_DSCP_VALUE] = {
4418 .name = "dscp_value",
4419 .help = "new IPv6 DSCP value to set",
4420 .next = NEXT(action_set_ipv6_dscp, NEXT_ENTRY(UNSIGNED)),
4421 .args = ARGS(ARGS_ENTRY
4422 (struct rte_flow_action_set_dscp, dscp)),
4423 .call = parse_vc_conf,
4427 .help = "set a specific metadata header",
4428 .next = NEXT(action_age),
4429 .priv = PRIV_ACTION(AGE,
4430 sizeof(struct rte_flow_action_age)),
4433 [ACTION_AGE_TIMEOUT] = {
4435 .help = "flow age timeout value",
4436 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_age,
4438 .next = NEXT(action_age, NEXT_ENTRY(UNSIGNED)),
4439 .call = parse_vc_conf,
4443 .help = "set a sample action",
4444 .next = NEXT(action_sample),
4445 .priv = PRIV_ACTION(SAMPLE,
4446 sizeof(struct action_sample_data)),
4447 .call = parse_vc_action_sample,
4449 [ACTION_SAMPLE_RATIO] = {
4451 .help = "flow sample ratio value",
4452 .next = NEXT(action_sample, NEXT_ENTRY(UNSIGNED)),
4453 .args = ARGS(ARGS_ENTRY_ARB
4454 (offsetof(struct action_sample_data, conf) +
4455 offsetof(struct rte_flow_action_sample, ratio),
4456 sizeof(((struct rte_flow_action_sample *)0)->
4459 [ACTION_SAMPLE_INDEX] = {
4461 .help = "the index of sample actions list",
4462 .next = NEXT(NEXT_ENTRY(ACTION_SAMPLE_INDEX_VALUE)),
4464 [ACTION_SAMPLE_INDEX_VALUE] = {
4467 .help = "unsigned integer value",
4468 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4469 .call = parse_vc_action_sample_index,
4470 .comp = comp_set_sample_index,
4472 /* Shared action destroy arguments. */
4473 [SHARED_ACTION_DESTROY_ID] = {
4474 .name = "action_id",
4475 .help = "specify a shared action id to destroy",
4476 .next = NEXT(next_sa_destroy_attr,
4477 NEXT_ENTRY(SHARED_ACTION_ID)),
4478 .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
4479 args.sa_destroy.action_id)),
4480 .call = parse_sa_destroy,
4482 /* Shared action create arguments. */
4483 [SHARED_ACTION_CREATE_ID] = {
4484 .name = "action_id",
4485 .help = "specify a shared action id to create",
4486 .next = NEXT(next_sa_create_attr,
4487 NEXT_ENTRY(SHARED_ACTION_ID)),
4488 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
4492 .help = "apply shared action by id",
4493 .priv = PRIV_ACTION(SHARED, 0),
4494 .next = NEXT(NEXT_ENTRY(SHARED_ACTION_ID2PTR)),
4495 .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
4498 [SHARED_ACTION_ID2PTR] = {
4499 .name = "{action_id}",
4500 .type = "SHARED_ACTION_ID",
4501 .help = "shared action id",
4502 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4503 .call = parse_sa_id2ptr,
4506 [SHARED_ACTION_INGRESS] = {
4508 .help = "affect rule to ingress",
4509 .next = NEXT(next_sa_create_attr),
4512 [SHARED_ACTION_EGRESS] = {
4514 .help = "affect rule to egress",
4515 .next = NEXT(next_sa_create_attr),
4518 [SHARED_ACTION_TRANSFER] = {
4520 .help = "affect rule to transfer",
4521 .next = NEXT(next_sa_create_attr),
4524 [SHARED_ACTION_SPEC] = {
4526 .help = "specify action to share",
4527 .next = NEXT(next_action),
4531 /** Remove and return last entry from argument stack. */
4532 static const struct arg *
4533 pop_args(struct context *ctx)
4535 return ctx->args_num ? ctx->args[--ctx->args_num] : NULL;
4538 /** Add entry on top of the argument stack. */
4540 push_args(struct context *ctx, const struct arg *arg)
4542 if (ctx->args_num == CTX_STACK_SIZE)
4544 ctx->args[ctx->args_num++] = arg;
4548 /** Spread value into buffer according to bit-mask. */
4550 arg_entry_bf_fill(void *dst, uintmax_t val, const struct arg *arg)
4552 uint32_t i = arg->size;
4560 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
4569 unsigned int shift = 0;
4570 uint8_t *buf = (uint8_t *)dst + arg->offset + (i -= sub);
4572 for (shift = 0; arg->mask[i] >> shift; ++shift) {
4573 if (!(arg->mask[i] & (1 << shift)))
4578 *buf &= ~(1 << shift);
4579 *buf |= (val & 1) << shift;
4587 /** Compare a string with a partial one of a given length. */
4589 strcmp_partial(const char *full, const char *partial, size_t partial_len)
4591 int r = strncmp(full, partial, partial_len);
4595 if (strlen(full) <= partial_len)
4597 return full[partial_len];
4601 * Parse a prefix length and generate a bit-mask.
4603 * Last argument (ctx->args) is retrieved to determine mask size, storage
4604 * location and whether the result must use network byte ordering.
4607 parse_prefix(struct context *ctx, const struct token *token,
4608 const char *str, unsigned int len,
4609 void *buf, unsigned int size)
4611 const struct arg *arg = pop_args(ctx);
4612 static const uint8_t conv[] = "\x00\x80\xc0\xe0\xf0\xf8\xfc\xfe\xff";
4619 /* Argument is expected. */
4623 u = strtoumax(str, &end, 0);
4624 if (errno || (size_t)(end - str) != len)
4629 extra = arg_entry_bf_fill(NULL, 0, arg);
4638 if (!arg_entry_bf_fill(ctx->object, v, arg) ||
4639 !arg_entry_bf_fill(ctx->objmask, -1, arg))
4646 if (bytes > size || bytes + !!extra > size)
4650 buf = (uint8_t *)ctx->object + arg->offset;
4651 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
4653 memset((uint8_t *)buf + size - bytes, 0xff, bytes);
4654 memset(buf, 0x00, size - bytes);
4656 ((uint8_t *)buf)[size - bytes - 1] = conv[extra];
4660 memset(buf, 0xff, bytes);
4661 memset((uint8_t *)buf + bytes, 0x00, size - bytes);
4663 ((uint8_t *)buf)[bytes] = conv[extra];
4666 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
4669 push_args(ctx, arg);
4673 /** Default parsing function for token name matching. */
4675 parse_default(struct context *ctx, const struct token *token,
4676 const char *str, unsigned int len,
4677 void *buf, unsigned int size)
4682 if (strcmp_partial(token->name, str, len))
4687 /** Parse flow command, initialize output buffer for subsequent tokens. */
4689 parse_init(struct context *ctx, const struct token *token,
4690 const char *str, unsigned int len,
4691 void *buf, unsigned int size)
4693 struct buffer *out = buf;
4695 /* Token name must match. */
4696 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4698 /* Nothing else to do if there is no buffer. */
4701 /* Make sure buffer is large enough. */
4702 if (size < sizeof(*out))
4704 /* Initialize buffer. */
4705 memset(out, 0x00, sizeof(*out));
4706 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
4709 ctx->objmask = NULL;
4713 /** Parse tokens for shared action commands. */
4715 parse_sa(struct context *ctx, const struct token *token,
4716 const char *str, unsigned int len,
4717 void *buf, unsigned int size)
4719 struct buffer *out = buf;
4721 /* Token name must match. */
4722 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4724 /* Nothing else to do if there is no buffer. */
4727 if (!out->command) {
4728 if (ctx->curr != SHARED_ACTION)
4730 if (sizeof(*out) > size)
4732 out->command = ctx->curr;
4735 ctx->objmask = NULL;
4736 out->args.vc.data = (uint8_t *)out + size;
4739 switch (ctx->curr) {
4740 case SHARED_ACTION_CREATE:
4741 case SHARED_ACTION_UPDATE:
4742 out->args.vc.actions =
4743 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
4745 out->args.vc.attr.group = UINT32_MAX;
4747 case SHARED_ACTION_QUERY:
4748 out->command = ctx->curr;
4751 ctx->objmask = NULL;
4753 case SHARED_ACTION_EGRESS:
4754 out->args.vc.attr.egress = 1;
4756 case SHARED_ACTION_INGRESS:
4757 out->args.vc.attr.ingress = 1;
4759 case SHARED_ACTION_TRANSFER:
4760 out->args.vc.attr.transfer = 1;
4768 /** Parse tokens for shared action destroy command. */
4770 parse_sa_destroy(struct context *ctx, const struct token *token,
4771 const char *str, unsigned int len,
4772 void *buf, unsigned int size)
4774 struct buffer *out = buf;
4775 uint32_t *action_id;
4777 /* Token name must match. */
4778 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4780 /* Nothing else to do if there is no buffer. */
4783 if (!out->command || out->command == SHARED_ACTION) {
4784 if (ctx->curr != SHARED_ACTION_DESTROY)
4786 if (sizeof(*out) > size)
4788 out->command = ctx->curr;
4791 ctx->objmask = NULL;
4792 out->args.sa_destroy.action_id =
4793 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
4797 action_id = out->args.sa_destroy.action_id
4798 + out->args.sa_destroy.action_id_n++;
4799 if ((uint8_t *)action_id > (uint8_t *)out + size)
4802 ctx->object = action_id;
4803 ctx->objmask = NULL;
4807 /** Parse tokens for validate/create commands. */
4809 parse_vc(struct context *ctx, const struct token *token,
4810 const char *str, unsigned int len,
4811 void *buf, unsigned int size)
4813 struct buffer *out = buf;
4817 /* Token name must match. */
4818 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4820 /* Nothing else to do if there is no buffer. */
4823 if (!out->command) {
4824 if (ctx->curr != VALIDATE && ctx->curr != CREATE)
4826 if (sizeof(*out) > size)
4828 out->command = ctx->curr;
4831 ctx->objmask = NULL;
4832 out->args.vc.data = (uint8_t *)out + size;
4836 switch (ctx->curr) {
4838 ctx->object = &out->args.vc.attr;
4842 ctx->object = &out->args.vc.tunnel_ops;
4845 ctx->objmask = NULL;
4846 switch (ctx->curr) {
4851 out->args.vc.tunnel_ops.enabled = 1;
4852 out->args.vc.tunnel_ops.actions = 1;
4855 out->args.vc.tunnel_ops.enabled = 1;
4856 out->args.vc.tunnel_ops.items = 1;
4859 out->args.vc.attr.ingress = 1;
4862 out->args.vc.attr.egress = 1;
4865 out->args.vc.attr.transfer = 1;
4868 out->args.vc.pattern =
4869 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
4871 ctx->object = out->args.vc.pattern;
4872 ctx->objmask = NULL;
4875 out->args.vc.actions =
4876 (void *)RTE_ALIGN_CEIL((uintptr_t)
4877 (out->args.vc.pattern +
4878 out->args.vc.pattern_n),
4880 ctx->object = out->args.vc.actions;
4881 ctx->objmask = NULL;
4888 if (!out->args.vc.actions) {
4889 const struct parse_item_priv *priv = token->priv;
4890 struct rte_flow_item *item =
4891 out->args.vc.pattern + out->args.vc.pattern_n;
4893 data_size = priv->size * 3; /* spec, last, mask */
4894 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
4895 (out->args.vc.data - data_size),
4897 if ((uint8_t *)item + sizeof(*item) > data)
4899 *item = (struct rte_flow_item){
4902 ++out->args.vc.pattern_n;
4904 ctx->objmask = NULL;
4906 const struct parse_action_priv *priv = token->priv;
4907 struct rte_flow_action *action =
4908 out->args.vc.actions + out->args.vc.actions_n;
4910 data_size = priv->size; /* configuration */
4911 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
4912 (out->args.vc.data - data_size),
4914 if ((uint8_t *)action + sizeof(*action) > data)
4916 *action = (struct rte_flow_action){
4918 .conf = data_size ? data : NULL,
4920 ++out->args.vc.actions_n;
4921 ctx->object = action;
4922 ctx->objmask = NULL;
4924 memset(data, 0, data_size);
4925 out->args.vc.data = data;
4926 ctx->objdata = data_size;
4930 /** Parse pattern item parameter type. */
4932 parse_vc_spec(struct context *ctx, const struct token *token,
4933 const char *str, unsigned int len,
4934 void *buf, unsigned int size)
4936 struct buffer *out = buf;
4937 struct rte_flow_item *item;
4943 /* Token name must match. */
4944 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4946 /* Parse parameter types. */
4947 switch (ctx->curr) {
4948 static const enum index prefix[] = NEXT_ENTRY(PREFIX);
4954 case ITEM_PARAM_SPEC:
4957 case ITEM_PARAM_LAST:
4960 case ITEM_PARAM_PREFIX:
4961 /* Modify next token to expect a prefix. */
4962 if (ctx->next_num < 2)
4964 ctx->next[ctx->next_num - 2] = prefix;
4966 case ITEM_PARAM_MASK:
4972 /* Nothing else to do if there is no buffer. */
4975 if (!out->args.vc.pattern_n)
4977 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
4978 data_size = ctx->objdata / 3; /* spec, last, mask */
4979 /* Point to selected object. */
4980 ctx->object = out->args.vc.data + (data_size * index);
4982 ctx->objmask = out->args.vc.data + (data_size * 2); /* mask */
4983 item->mask = ctx->objmask;
4985 ctx->objmask = NULL;
4986 /* Update relevant item pointer. */
4987 *((const void **[]){ &item->spec, &item->last, &item->mask })[index] =
4992 /** Parse action configuration field. */
4994 parse_vc_conf(struct context *ctx, const struct token *token,
4995 const char *str, unsigned int len,
4996 void *buf, unsigned int size)
4998 struct buffer *out = buf;
5001 /* Token name must match. */
5002 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5004 /* Nothing else to do if there is no buffer. */
5007 /* Point to selected object. */
5008 ctx->object = out->args.vc.data;
5009 ctx->objmask = NULL;
5013 /** Parse eCPRI common header type field. */
5015 parse_vc_item_ecpri_type(struct context *ctx, const struct token *token,
5016 const char *str, unsigned int len,
5017 void *buf, unsigned int size)
5019 struct rte_flow_item_ecpri *ecpri;
5020 struct rte_flow_item_ecpri *ecpri_mask;
5021 struct rte_flow_item *item;
5024 struct buffer *out = buf;
5025 const struct arg *arg;
5028 /* Token name must match. */
5029 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5031 switch (ctx->curr) {
5032 case ITEM_ECPRI_COMMON_TYPE_IQ_DATA:
5033 msg_type = RTE_ECPRI_MSG_TYPE_IQ_DATA;
5035 case ITEM_ECPRI_COMMON_TYPE_RTC_CTRL:
5036 msg_type = RTE_ECPRI_MSG_TYPE_RTC_CTRL;
5038 case ITEM_ECPRI_COMMON_TYPE_DLY_MSR:
5039 msg_type = RTE_ECPRI_MSG_TYPE_DLY_MSR;
5046 arg = pop_args(ctx);
5049 ecpri = (struct rte_flow_item_ecpri *)out->args.vc.data;
5050 ecpri->hdr.common.type = msg_type;
5051 data_size = ctx->objdata / 3; /* spec, last, mask */
5052 ecpri_mask = (struct rte_flow_item_ecpri *)(out->args.vc.data +
5054 ecpri_mask->hdr.common.type = 0xFF;
5056 ecpri->hdr.common.u32 = rte_cpu_to_be_32(ecpri->hdr.common.u32);
5057 ecpri_mask->hdr.common.u32 =
5058 rte_cpu_to_be_32(ecpri_mask->hdr.common.u32);
5060 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
5062 item->mask = ecpri_mask;
5066 /** Parse RSS action. */
5068 parse_vc_action_rss(struct context *ctx, const struct token *token,
5069 const char *str, unsigned int len,
5070 void *buf, unsigned int size)
5072 struct buffer *out = buf;
5073 struct rte_flow_action *action;
5074 struct action_rss_data *action_rss_data;
5078 ret = parse_vc(ctx, token, str, len, buf, size);
5081 /* Nothing else to do if there is no buffer. */
5084 if (!out->args.vc.actions_n)
5086 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5087 /* Point to selected object. */
5088 ctx->object = out->args.vc.data;
5089 ctx->objmask = NULL;
5090 /* Set up default configuration. */
5091 action_rss_data = ctx->object;
5092 *action_rss_data = (struct action_rss_data){
5093 .conf = (struct rte_flow_action_rss){
5094 .func = RTE_ETH_HASH_FUNCTION_DEFAULT,
5098 .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM),
5100 .queue = action_rss_data->queue,
5104 for (i = 0; i < action_rss_data->conf.queue_num; ++i)
5105 action_rss_data->queue[i] = i;
5106 action->conf = &action_rss_data->conf;
5111 * Parse func field for RSS action.
5113 * The RTE_ETH_HASH_FUNCTION_* value to assign is derived from the
5114 * ACTION_RSS_FUNC_* index that called this function.
5117 parse_vc_action_rss_func(struct context *ctx, const struct token *token,
5118 const char *str, unsigned int len,
5119 void *buf, unsigned int size)
5121 struct action_rss_data *action_rss_data;
5122 enum rte_eth_hash_function func;
5126 /* Token name must match. */
5127 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5129 switch (ctx->curr) {
5130 case ACTION_RSS_FUNC_DEFAULT:
5131 func = RTE_ETH_HASH_FUNCTION_DEFAULT;
5133 case ACTION_RSS_FUNC_TOEPLITZ:
5134 func = RTE_ETH_HASH_FUNCTION_TOEPLITZ;
5136 case ACTION_RSS_FUNC_SIMPLE_XOR:
5137 func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
5139 case ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ:
5140 func = RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
5147 action_rss_data = ctx->object;
5148 action_rss_data->conf.func = func;
5153 * Parse type field for RSS action.
5155 * Valid tokens are type field names and the "end" token.
5158 parse_vc_action_rss_type(struct context *ctx, const struct token *token,
5159 const char *str, unsigned int len,
5160 void *buf, unsigned int size)
5162 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE);
5163 struct action_rss_data *action_rss_data;
5169 if (ctx->curr != ACTION_RSS_TYPE)
5171 if (!(ctx->objdata >> 16) && ctx->object) {
5172 action_rss_data = ctx->object;
5173 action_rss_data->conf.types = 0;
5175 if (!strcmp_partial("end", str, len)) {
5176 ctx->objdata &= 0xffff;
5179 for (i = 0; rss_type_table[i].str; ++i)
5180 if (!strcmp_partial(rss_type_table[i].str, str, len))
5182 if (!rss_type_table[i].str)
5184 ctx->objdata = 1 << 16 | (ctx->objdata & 0xffff);
5186 if (ctx->next_num == RTE_DIM(ctx->next))
5188 ctx->next[ctx->next_num++] = next;
5191 action_rss_data = ctx->object;
5192 action_rss_data->conf.types |= rss_type_table[i].rss_type;
5197 * Parse queue field for RSS action.
5199 * Valid tokens are queue indices and the "end" token.
5202 parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
5203 const char *str, unsigned int len,
5204 void *buf, unsigned int size)
5206 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE);
5207 struct action_rss_data *action_rss_data;
5208 const struct arg *arg;
5215 if (ctx->curr != ACTION_RSS_QUEUE)
5217 i = ctx->objdata >> 16;
5218 if (!strcmp_partial("end", str, len)) {
5219 ctx->objdata &= 0xffff;
5222 if (i >= ACTION_RSS_QUEUE_NUM)
5224 arg = ARGS_ENTRY_ARB(offsetof(struct action_rss_data, queue) +
5225 i * sizeof(action_rss_data->queue[i]),
5226 sizeof(action_rss_data->queue[i]));
5227 if (push_args(ctx, arg))
5229 ret = parse_int(ctx, token, str, len, NULL, 0);
5235 ctx->objdata = i << 16 | (ctx->objdata & 0xffff);
5237 if (ctx->next_num == RTE_DIM(ctx->next))
5239 ctx->next[ctx->next_num++] = next;
5243 action_rss_data = ctx->object;
5244 action_rss_data->conf.queue_num = i;
5245 action_rss_data->conf.queue = i ? action_rss_data->queue : NULL;
5249 /** Setup VXLAN encap configuration. */
5251 parse_setup_vxlan_encap_data(struct action_vxlan_encap_data *action_vxlan_encap_data)
5253 /* Set up default configuration. */
5254 *action_vxlan_encap_data = (struct action_vxlan_encap_data){
5255 .conf = (struct rte_flow_action_vxlan_encap){
5256 .definition = action_vxlan_encap_data->items,
5260 .type = RTE_FLOW_ITEM_TYPE_ETH,
5261 .spec = &action_vxlan_encap_data->item_eth,
5262 .mask = &rte_flow_item_eth_mask,
5265 .type = RTE_FLOW_ITEM_TYPE_VLAN,
5266 .spec = &action_vxlan_encap_data->item_vlan,
5267 .mask = &rte_flow_item_vlan_mask,
5270 .type = RTE_FLOW_ITEM_TYPE_IPV4,
5271 .spec = &action_vxlan_encap_data->item_ipv4,
5272 .mask = &rte_flow_item_ipv4_mask,
5275 .type = RTE_FLOW_ITEM_TYPE_UDP,
5276 .spec = &action_vxlan_encap_data->item_udp,
5277 .mask = &rte_flow_item_udp_mask,
5280 .type = RTE_FLOW_ITEM_TYPE_VXLAN,
5281 .spec = &action_vxlan_encap_data->item_vxlan,
5282 .mask = &rte_flow_item_vxlan_mask,
5285 .type = RTE_FLOW_ITEM_TYPE_END,
5290 .tci = vxlan_encap_conf.vlan_tci,
5294 .src_addr = vxlan_encap_conf.ipv4_src,
5295 .dst_addr = vxlan_encap_conf.ipv4_dst,
5298 .src_port = vxlan_encap_conf.udp_src,
5299 .dst_port = vxlan_encap_conf.udp_dst,
5301 .item_vxlan.flags = 0,
5303 memcpy(action_vxlan_encap_data->item_eth.dst.addr_bytes,
5304 vxlan_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5305 memcpy(action_vxlan_encap_data->item_eth.src.addr_bytes,
5306 vxlan_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5307 if (!vxlan_encap_conf.select_ipv4) {
5308 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.src_addr,
5309 &vxlan_encap_conf.ipv6_src,
5310 sizeof(vxlan_encap_conf.ipv6_src));
5311 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.dst_addr,
5312 &vxlan_encap_conf.ipv6_dst,
5313 sizeof(vxlan_encap_conf.ipv6_dst));
5314 action_vxlan_encap_data->items[2] = (struct rte_flow_item){
5315 .type = RTE_FLOW_ITEM_TYPE_IPV6,
5316 .spec = &action_vxlan_encap_data->item_ipv6,
5317 .mask = &rte_flow_item_ipv6_mask,
5320 if (!vxlan_encap_conf.select_vlan)
5321 action_vxlan_encap_data->items[1].type =
5322 RTE_FLOW_ITEM_TYPE_VOID;
5323 if (vxlan_encap_conf.select_tos_ttl) {
5324 if (vxlan_encap_conf.select_ipv4) {
5325 static struct rte_flow_item_ipv4 ipv4_mask_tos;
5327 memcpy(&ipv4_mask_tos, &rte_flow_item_ipv4_mask,
5328 sizeof(ipv4_mask_tos));
5329 ipv4_mask_tos.hdr.type_of_service = 0xff;
5330 ipv4_mask_tos.hdr.time_to_live = 0xff;
5331 action_vxlan_encap_data->item_ipv4.hdr.type_of_service =
5332 vxlan_encap_conf.ip_tos;
5333 action_vxlan_encap_data->item_ipv4.hdr.time_to_live =
5334 vxlan_encap_conf.ip_ttl;
5335 action_vxlan_encap_data->items[2].mask =
5338 static struct rte_flow_item_ipv6 ipv6_mask_tos;
5340 memcpy(&ipv6_mask_tos, &rte_flow_item_ipv6_mask,
5341 sizeof(ipv6_mask_tos));
5342 ipv6_mask_tos.hdr.vtc_flow |=
5343 RTE_BE32(0xfful << RTE_IPV6_HDR_TC_SHIFT);
5344 ipv6_mask_tos.hdr.hop_limits = 0xff;
5345 action_vxlan_encap_data->item_ipv6.hdr.vtc_flow |=
5347 ((uint32_t)vxlan_encap_conf.ip_tos <<
5348 RTE_IPV6_HDR_TC_SHIFT);
5349 action_vxlan_encap_data->item_ipv6.hdr.hop_limits =
5350 vxlan_encap_conf.ip_ttl;
5351 action_vxlan_encap_data->items[2].mask =
5355 memcpy(action_vxlan_encap_data->item_vxlan.vni, vxlan_encap_conf.vni,
5356 RTE_DIM(vxlan_encap_conf.vni));
5360 /** Parse VXLAN encap action. */
5362 parse_vc_action_vxlan_encap(struct context *ctx, const struct token *token,
5363 const char *str, unsigned int len,
5364 void *buf, unsigned int size)
5366 struct buffer *out = buf;
5367 struct rte_flow_action *action;
5368 struct action_vxlan_encap_data *action_vxlan_encap_data;
5371 ret = parse_vc(ctx, token, str, len, buf, size);
5374 /* Nothing else to do if there is no buffer. */
5377 if (!out->args.vc.actions_n)
5379 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5380 /* Point to selected object. */
5381 ctx->object = out->args.vc.data;
5382 ctx->objmask = NULL;
5383 action_vxlan_encap_data = ctx->object;
5384 parse_setup_vxlan_encap_data(action_vxlan_encap_data);
5385 action->conf = &action_vxlan_encap_data->conf;
5389 /** Setup NVGRE encap configuration. */
5391 parse_setup_nvgre_encap_data(struct action_nvgre_encap_data *action_nvgre_encap_data)
5393 /* Set up default configuration. */
5394 *action_nvgre_encap_data = (struct action_nvgre_encap_data){
5395 .conf = (struct rte_flow_action_nvgre_encap){
5396 .definition = action_nvgre_encap_data->items,
5400 .type = RTE_FLOW_ITEM_TYPE_ETH,
5401 .spec = &action_nvgre_encap_data->item_eth,
5402 .mask = &rte_flow_item_eth_mask,
5405 .type = RTE_FLOW_ITEM_TYPE_VLAN,
5406 .spec = &action_nvgre_encap_data->item_vlan,
5407 .mask = &rte_flow_item_vlan_mask,
5410 .type = RTE_FLOW_ITEM_TYPE_IPV4,
5411 .spec = &action_nvgre_encap_data->item_ipv4,
5412 .mask = &rte_flow_item_ipv4_mask,
5415 .type = RTE_FLOW_ITEM_TYPE_NVGRE,
5416 .spec = &action_nvgre_encap_data->item_nvgre,
5417 .mask = &rte_flow_item_nvgre_mask,
5420 .type = RTE_FLOW_ITEM_TYPE_END,
5425 .tci = nvgre_encap_conf.vlan_tci,
5429 .src_addr = nvgre_encap_conf.ipv4_src,
5430 .dst_addr = nvgre_encap_conf.ipv4_dst,
5432 .item_nvgre.c_k_s_rsvd0_ver = RTE_BE16(0x2000),
5433 .item_nvgre.protocol = RTE_BE16(RTE_ETHER_TYPE_TEB),
5434 .item_nvgre.flow_id = 0,
5436 memcpy(action_nvgre_encap_data->item_eth.dst.addr_bytes,
5437 nvgre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5438 memcpy(action_nvgre_encap_data->item_eth.src.addr_bytes,
5439 nvgre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5440 if (!nvgre_encap_conf.select_ipv4) {
5441 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.src_addr,
5442 &nvgre_encap_conf.ipv6_src,
5443 sizeof(nvgre_encap_conf.ipv6_src));
5444 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.dst_addr,
5445 &nvgre_encap_conf.ipv6_dst,
5446 sizeof(nvgre_encap_conf.ipv6_dst));
5447 action_nvgre_encap_data->items[2] = (struct rte_flow_item){
5448 .type = RTE_FLOW_ITEM_TYPE_IPV6,
5449 .spec = &action_nvgre_encap_data->item_ipv6,
5450 .mask = &rte_flow_item_ipv6_mask,
5453 if (!nvgre_encap_conf.select_vlan)
5454 action_nvgre_encap_data->items[1].type =
5455 RTE_FLOW_ITEM_TYPE_VOID;
5456 memcpy(action_nvgre_encap_data->item_nvgre.tni, nvgre_encap_conf.tni,
5457 RTE_DIM(nvgre_encap_conf.tni));
5461 /** Parse NVGRE encap action. */
5463 parse_vc_action_nvgre_encap(struct context *ctx, const struct token *token,
5464 const char *str, unsigned int len,
5465 void *buf, unsigned int size)
5467 struct buffer *out = buf;
5468 struct rte_flow_action *action;
5469 struct action_nvgre_encap_data *action_nvgre_encap_data;
5472 ret = parse_vc(ctx, token, str, len, buf, size);
5475 /* Nothing else to do if there is no buffer. */
5478 if (!out->args.vc.actions_n)
5480 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5481 /* Point to selected object. */
5482 ctx->object = out->args.vc.data;
5483 ctx->objmask = NULL;
5484 action_nvgre_encap_data = ctx->object;
5485 parse_setup_nvgre_encap_data(action_nvgre_encap_data);
5486 action->conf = &action_nvgre_encap_data->conf;
5490 /** Parse l2 encap action. */
5492 parse_vc_action_l2_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_raw_encap_data *action_encap_data;
5499 struct rte_flow_item_eth eth = { .type = 0, };
5500 struct rte_flow_item_vlan vlan = {
5501 .tci = mplsoudp_encap_conf.vlan_tci,
5507 ret = parse_vc(ctx, token, str, len, buf, size);
5510 /* Nothing else to do if there is no buffer. */
5513 if (!out->args.vc.actions_n)
5515 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5516 /* Point to selected object. */
5517 ctx->object = out->args.vc.data;
5518 ctx->objmask = NULL;
5519 /* Copy the headers to the buffer. */
5520 action_encap_data = ctx->object;
5521 *action_encap_data = (struct action_raw_encap_data) {
5522 .conf = (struct rte_flow_action_raw_encap){
5523 .data = action_encap_data->data,
5527 header = action_encap_data->data;
5528 if (l2_encap_conf.select_vlan)
5529 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5530 else if (l2_encap_conf.select_ipv4)
5531 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5533 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5534 memcpy(eth.dst.addr_bytes,
5535 l2_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5536 memcpy(eth.src.addr_bytes,
5537 l2_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5538 memcpy(header, ð, sizeof(eth));
5539 header += sizeof(eth);
5540 if (l2_encap_conf.select_vlan) {
5541 if (l2_encap_conf.select_ipv4)
5542 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5544 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5545 memcpy(header, &vlan, sizeof(vlan));
5546 header += sizeof(vlan);
5548 action_encap_data->conf.size = header -
5549 action_encap_data->data;
5550 action->conf = &action_encap_data->conf;
5554 /** Parse l2 decap action. */
5556 parse_vc_action_l2_decap(struct context *ctx, const struct token *token,
5557 const char *str, unsigned int len,
5558 void *buf, unsigned int size)
5560 struct buffer *out = buf;
5561 struct rte_flow_action *action;
5562 struct action_raw_decap_data *action_decap_data;
5563 struct rte_flow_item_eth eth = { .type = 0, };
5564 struct rte_flow_item_vlan vlan = {
5565 .tci = mplsoudp_encap_conf.vlan_tci,
5571 ret = parse_vc(ctx, token, str, len, buf, size);
5574 /* Nothing else to do if there is no buffer. */
5577 if (!out->args.vc.actions_n)
5579 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5580 /* Point to selected object. */
5581 ctx->object = out->args.vc.data;
5582 ctx->objmask = NULL;
5583 /* Copy the headers to the buffer. */
5584 action_decap_data = ctx->object;
5585 *action_decap_data = (struct action_raw_decap_data) {
5586 .conf = (struct rte_flow_action_raw_decap){
5587 .data = action_decap_data->data,
5591 header = action_decap_data->data;
5592 if (l2_decap_conf.select_vlan)
5593 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5594 memcpy(header, ð, sizeof(eth));
5595 header += sizeof(eth);
5596 if (l2_decap_conf.select_vlan) {
5597 memcpy(header, &vlan, sizeof(vlan));
5598 header += sizeof(vlan);
5600 action_decap_data->conf.size = header -
5601 action_decap_data->data;
5602 action->conf = &action_decap_data->conf;
5606 #define ETHER_TYPE_MPLS_UNICAST 0x8847
5608 /** Parse MPLSOGRE encap action. */
5610 parse_vc_action_mplsogre_encap(struct context *ctx, const struct token *token,
5611 const char *str, unsigned int len,
5612 void *buf, unsigned int size)
5614 struct buffer *out = buf;
5615 struct rte_flow_action *action;
5616 struct action_raw_encap_data *action_encap_data;
5617 struct rte_flow_item_eth eth = { .type = 0, };
5618 struct rte_flow_item_vlan vlan = {
5619 .tci = mplsogre_encap_conf.vlan_tci,
5622 struct rte_flow_item_ipv4 ipv4 = {
5624 .src_addr = mplsogre_encap_conf.ipv4_src,
5625 .dst_addr = mplsogre_encap_conf.ipv4_dst,
5626 .next_proto_id = IPPROTO_GRE,
5627 .version_ihl = RTE_IPV4_VHL_DEF,
5628 .time_to_live = IPDEFTTL,
5631 struct rte_flow_item_ipv6 ipv6 = {
5633 .proto = IPPROTO_GRE,
5634 .hop_limits = IPDEFTTL,
5637 struct rte_flow_item_gre gre = {
5638 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
5640 struct rte_flow_item_mpls mpls = {
5646 ret = parse_vc(ctx, token, str, len, buf, size);
5649 /* Nothing else to do if there is no buffer. */
5652 if (!out->args.vc.actions_n)
5654 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5655 /* Point to selected object. */
5656 ctx->object = out->args.vc.data;
5657 ctx->objmask = NULL;
5658 /* Copy the headers to the buffer. */
5659 action_encap_data = ctx->object;
5660 *action_encap_data = (struct action_raw_encap_data) {
5661 .conf = (struct rte_flow_action_raw_encap){
5662 .data = action_encap_data->data,
5667 header = action_encap_data->data;
5668 if (mplsogre_encap_conf.select_vlan)
5669 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5670 else if (mplsogre_encap_conf.select_ipv4)
5671 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5673 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5674 memcpy(eth.dst.addr_bytes,
5675 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5676 memcpy(eth.src.addr_bytes,
5677 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5678 memcpy(header, ð, sizeof(eth));
5679 header += sizeof(eth);
5680 if (mplsogre_encap_conf.select_vlan) {
5681 if (mplsogre_encap_conf.select_ipv4)
5682 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5684 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5685 memcpy(header, &vlan, sizeof(vlan));
5686 header += sizeof(vlan);
5688 if (mplsogre_encap_conf.select_ipv4) {
5689 memcpy(header, &ipv4, sizeof(ipv4));
5690 header += sizeof(ipv4);
5692 memcpy(&ipv6.hdr.src_addr,
5693 &mplsogre_encap_conf.ipv6_src,
5694 sizeof(mplsogre_encap_conf.ipv6_src));
5695 memcpy(&ipv6.hdr.dst_addr,
5696 &mplsogre_encap_conf.ipv6_dst,
5697 sizeof(mplsogre_encap_conf.ipv6_dst));
5698 memcpy(header, &ipv6, sizeof(ipv6));
5699 header += sizeof(ipv6);
5701 memcpy(header, &gre, sizeof(gre));
5702 header += sizeof(gre);
5703 memcpy(mpls.label_tc_s, mplsogre_encap_conf.label,
5704 RTE_DIM(mplsogre_encap_conf.label));
5705 mpls.label_tc_s[2] |= 0x1;
5706 memcpy(header, &mpls, sizeof(mpls));
5707 header += sizeof(mpls);
5708 action_encap_data->conf.size = header -
5709 action_encap_data->data;
5710 action->conf = &action_encap_data->conf;
5714 /** Parse MPLSOGRE decap action. */
5716 parse_vc_action_mplsogre_decap(struct context *ctx, const struct token *token,
5717 const char *str, unsigned int len,
5718 void *buf, unsigned int size)
5720 struct buffer *out = buf;
5721 struct rte_flow_action *action;
5722 struct action_raw_decap_data *action_decap_data;
5723 struct rte_flow_item_eth eth = { .type = 0, };
5724 struct rte_flow_item_vlan vlan = {.tci = 0};
5725 struct rte_flow_item_ipv4 ipv4 = {
5727 .next_proto_id = IPPROTO_GRE,
5730 struct rte_flow_item_ipv6 ipv6 = {
5732 .proto = IPPROTO_GRE,
5735 struct rte_flow_item_gre gre = {
5736 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
5738 struct rte_flow_item_mpls mpls;
5742 ret = parse_vc(ctx, token, str, len, buf, size);
5745 /* Nothing else to do if there is no buffer. */
5748 if (!out->args.vc.actions_n)
5750 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5751 /* Point to selected object. */
5752 ctx->object = out->args.vc.data;
5753 ctx->objmask = NULL;
5754 /* Copy the headers to the buffer. */
5755 action_decap_data = ctx->object;
5756 *action_decap_data = (struct action_raw_decap_data) {
5757 .conf = (struct rte_flow_action_raw_decap){
5758 .data = action_decap_data->data,
5762 header = action_decap_data->data;
5763 if (mplsogre_decap_conf.select_vlan)
5764 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5765 else if (mplsogre_encap_conf.select_ipv4)
5766 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5768 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5769 memcpy(eth.dst.addr_bytes,
5770 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5771 memcpy(eth.src.addr_bytes,
5772 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5773 memcpy(header, ð, sizeof(eth));
5774 header += sizeof(eth);
5775 if (mplsogre_encap_conf.select_vlan) {
5776 if (mplsogre_encap_conf.select_ipv4)
5777 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5779 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5780 memcpy(header, &vlan, sizeof(vlan));
5781 header += sizeof(vlan);
5783 if (mplsogre_encap_conf.select_ipv4) {
5784 memcpy(header, &ipv4, sizeof(ipv4));
5785 header += sizeof(ipv4);
5787 memcpy(header, &ipv6, sizeof(ipv6));
5788 header += sizeof(ipv6);
5790 memcpy(header, &gre, sizeof(gre));
5791 header += sizeof(gre);
5792 memset(&mpls, 0, sizeof(mpls));
5793 memcpy(header, &mpls, sizeof(mpls));
5794 header += sizeof(mpls);
5795 action_decap_data->conf.size = header -
5796 action_decap_data->data;
5797 action->conf = &action_decap_data->conf;
5801 /** Parse MPLSOUDP encap action. */
5803 parse_vc_action_mplsoudp_encap(struct context *ctx, const struct token *token,
5804 const char *str, unsigned int len,
5805 void *buf, unsigned int size)
5807 struct buffer *out = buf;
5808 struct rte_flow_action *action;
5809 struct action_raw_encap_data *action_encap_data;
5810 struct rte_flow_item_eth eth = { .type = 0, };
5811 struct rte_flow_item_vlan vlan = {
5812 .tci = mplsoudp_encap_conf.vlan_tci,
5815 struct rte_flow_item_ipv4 ipv4 = {
5817 .src_addr = mplsoudp_encap_conf.ipv4_src,
5818 .dst_addr = mplsoudp_encap_conf.ipv4_dst,
5819 .next_proto_id = IPPROTO_UDP,
5820 .version_ihl = RTE_IPV4_VHL_DEF,
5821 .time_to_live = IPDEFTTL,
5824 struct rte_flow_item_ipv6 ipv6 = {
5826 .proto = IPPROTO_UDP,
5827 .hop_limits = IPDEFTTL,
5830 struct rte_flow_item_udp udp = {
5832 .src_port = mplsoudp_encap_conf.udp_src,
5833 .dst_port = mplsoudp_encap_conf.udp_dst,
5836 struct rte_flow_item_mpls mpls;
5840 ret = parse_vc(ctx, token, str, len, buf, size);
5843 /* Nothing else to do if there is no buffer. */
5846 if (!out->args.vc.actions_n)
5848 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5849 /* Point to selected object. */
5850 ctx->object = out->args.vc.data;
5851 ctx->objmask = NULL;
5852 /* Copy the headers to the buffer. */
5853 action_encap_data = ctx->object;
5854 *action_encap_data = (struct action_raw_encap_data) {
5855 .conf = (struct rte_flow_action_raw_encap){
5856 .data = action_encap_data->data,
5861 header = action_encap_data->data;
5862 if (mplsoudp_encap_conf.select_vlan)
5863 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5864 else if (mplsoudp_encap_conf.select_ipv4)
5865 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5867 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5868 memcpy(eth.dst.addr_bytes,
5869 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5870 memcpy(eth.src.addr_bytes,
5871 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5872 memcpy(header, ð, sizeof(eth));
5873 header += sizeof(eth);
5874 if (mplsoudp_encap_conf.select_vlan) {
5875 if (mplsoudp_encap_conf.select_ipv4)
5876 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5878 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5879 memcpy(header, &vlan, sizeof(vlan));
5880 header += sizeof(vlan);
5882 if (mplsoudp_encap_conf.select_ipv4) {
5883 memcpy(header, &ipv4, sizeof(ipv4));
5884 header += sizeof(ipv4);
5886 memcpy(&ipv6.hdr.src_addr,
5887 &mplsoudp_encap_conf.ipv6_src,
5888 sizeof(mplsoudp_encap_conf.ipv6_src));
5889 memcpy(&ipv6.hdr.dst_addr,
5890 &mplsoudp_encap_conf.ipv6_dst,
5891 sizeof(mplsoudp_encap_conf.ipv6_dst));
5892 memcpy(header, &ipv6, sizeof(ipv6));
5893 header += sizeof(ipv6);
5895 memcpy(header, &udp, sizeof(udp));
5896 header += sizeof(udp);
5897 memcpy(mpls.label_tc_s, mplsoudp_encap_conf.label,
5898 RTE_DIM(mplsoudp_encap_conf.label));
5899 mpls.label_tc_s[2] |= 0x1;
5900 memcpy(header, &mpls, sizeof(mpls));
5901 header += sizeof(mpls);
5902 action_encap_data->conf.size = header -
5903 action_encap_data->data;
5904 action->conf = &action_encap_data->conf;
5908 /** Parse MPLSOUDP decap action. */
5910 parse_vc_action_mplsoudp_decap(struct context *ctx, const struct token *token,
5911 const char *str, unsigned int len,
5912 void *buf, unsigned int size)
5914 struct buffer *out = buf;
5915 struct rte_flow_action *action;
5916 struct action_raw_decap_data *action_decap_data;
5917 struct rte_flow_item_eth eth = { .type = 0, };
5918 struct rte_flow_item_vlan vlan = {.tci = 0};
5919 struct rte_flow_item_ipv4 ipv4 = {
5921 .next_proto_id = IPPROTO_UDP,
5924 struct rte_flow_item_ipv6 ipv6 = {
5926 .proto = IPPROTO_UDP,
5929 struct rte_flow_item_udp udp = {
5931 .dst_port = rte_cpu_to_be_16(6635),
5934 struct rte_flow_item_mpls mpls;
5938 ret = parse_vc(ctx, token, str, len, buf, size);
5941 /* Nothing else to do if there is no buffer. */
5944 if (!out->args.vc.actions_n)
5946 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5947 /* Point to selected object. */
5948 ctx->object = out->args.vc.data;
5949 ctx->objmask = NULL;
5950 /* Copy the headers to the buffer. */
5951 action_decap_data = ctx->object;
5952 *action_decap_data = (struct action_raw_decap_data) {
5953 .conf = (struct rte_flow_action_raw_decap){
5954 .data = action_decap_data->data,
5958 header = action_decap_data->data;
5959 if (mplsoudp_decap_conf.select_vlan)
5960 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5961 else if (mplsoudp_encap_conf.select_ipv4)
5962 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5964 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5965 memcpy(eth.dst.addr_bytes,
5966 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5967 memcpy(eth.src.addr_bytes,
5968 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5969 memcpy(header, ð, sizeof(eth));
5970 header += sizeof(eth);
5971 if (mplsoudp_encap_conf.select_vlan) {
5972 if (mplsoudp_encap_conf.select_ipv4)
5973 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5975 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5976 memcpy(header, &vlan, sizeof(vlan));
5977 header += sizeof(vlan);
5979 if (mplsoudp_encap_conf.select_ipv4) {
5980 memcpy(header, &ipv4, sizeof(ipv4));
5981 header += sizeof(ipv4);
5983 memcpy(header, &ipv6, sizeof(ipv6));
5984 header += sizeof(ipv6);
5986 memcpy(header, &udp, sizeof(udp));
5987 header += sizeof(udp);
5988 memset(&mpls, 0, sizeof(mpls));
5989 memcpy(header, &mpls, sizeof(mpls));
5990 header += sizeof(mpls);
5991 action_decap_data->conf.size = header -
5992 action_decap_data->data;
5993 action->conf = &action_decap_data->conf;
5998 parse_vc_action_raw_decap_index(struct context *ctx, const struct token *token,
5999 const char *str, unsigned int len, void *buf,
6002 struct action_raw_decap_data *action_raw_decap_data;
6003 struct rte_flow_action *action;
6004 const struct arg *arg;
6005 struct buffer *out = buf;
6009 RTE_SET_USED(token);
6012 arg = ARGS_ENTRY_ARB_BOUNDED
6013 (offsetof(struct action_raw_decap_data, idx),
6014 sizeof(((struct action_raw_decap_data *)0)->idx),
6015 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
6016 if (push_args(ctx, arg))
6018 ret = parse_int(ctx, token, str, len, NULL, 0);
6025 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6026 action_raw_decap_data = ctx->object;
6027 idx = action_raw_decap_data->idx;
6028 action_raw_decap_data->conf.data = raw_decap_confs[idx].data;
6029 action_raw_decap_data->conf.size = raw_decap_confs[idx].size;
6030 action->conf = &action_raw_decap_data->conf;
6036 parse_vc_action_raw_encap_index(struct context *ctx, const struct token *token,
6037 const char *str, unsigned int len, void *buf,
6040 struct action_raw_encap_data *action_raw_encap_data;
6041 struct rte_flow_action *action;
6042 const struct arg *arg;
6043 struct buffer *out = buf;
6047 RTE_SET_USED(token);
6050 if (ctx->curr != ACTION_RAW_ENCAP_INDEX_VALUE)
6052 arg = ARGS_ENTRY_ARB_BOUNDED
6053 (offsetof(struct action_raw_encap_data, idx),
6054 sizeof(((struct action_raw_encap_data *)0)->idx),
6055 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
6056 if (push_args(ctx, arg))
6058 ret = parse_int(ctx, token, str, len, NULL, 0);
6065 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6066 action_raw_encap_data = ctx->object;
6067 idx = action_raw_encap_data->idx;
6068 action_raw_encap_data->conf.data = raw_encap_confs[idx].data;
6069 action_raw_encap_data->conf.size = raw_encap_confs[idx].size;
6070 action_raw_encap_data->conf.preserve = NULL;
6071 action->conf = &action_raw_encap_data->conf;
6076 parse_vc_action_raw_encap(struct context *ctx, const struct token *token,
6077 const char *str, unsigned int len, void *buf,
6080 struct buffer *out = buf;
6081 struct rte_flow_action *action;
6082 struct action_raw_encap_data *action_raw_encap_data = NULL;
6085 ret = parse_vc(ctx, token, str, len, buf, size);
6088 /* Nothing else to do if there is no buffer. */
6091 if (!out->args.vc.actions_n)
6093 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6094 /* Point to selected object. */
6095 ctx->object = out->args.vc.data;
6096 ctx->objmask = NULL;
6097 /* Copy the headers to the buffer. */
6098 action_raw_encap_data = ctx->object;
6099 action_raw_encap_data->conf.data = raw_encap_confs[0].data;
6100 action_raw_encap_data->conf.preserve = NULL;
6101 action_raw_encap_data->conf.size = raw_encap_confs[0].size;
6102 action->conf = &action_raw_encap_data->conf;
6107 parse_vc_action_raw_decap(struct context *ctx, const struct token *token,
6108 const char *str, unsigned int len, void *buf,
6111 struct buffer *out = buf;
6112 struct rte_flow_action *action;
6113 struct action_raw_decap_data *action_raw_decap_data = NULL;
6116 ret = parse_vc(ctx, token, str, len, buf, size);
6119 /* Nothing else to do if there is no buffer. */
6122 if (!out->args.vc.actions_n)
6124 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6125 /* Point to selected object. */
6126 ctx->object = out->args.vc.data;
6127 ctx->objmask = NULL;
6128 /* Copy the headers to the buffer. */
6129 action_raw_decap_data = ctx->object;
6130 action_raw_decap_data->conf.data = raw_decap_confs[0].data;
6131 action_raw_decap_data->conf.size = raw_decap_confs[0].size;
6132 action->conf = &action_raw_decap_data->conf;
6137 parse_vc_action_set_meta(struct context *ctx, const struct token *token,
6138 const char *str, unsigned int len, void *buf,
6143 ret = parse_vc(ctx, token, str, len, buf, size);
6146 ret = rte_flow_dynf_metadata_register();
6153 parse_vc_action_sample(struct context *ctx, const struct token *token,
6154 const char *str, unsigned int len, void *buf,
6157 struct buffer *out = buf;
6158 struct rte_flow_action *action;
6159 struct action_sample_data *action_sample_data = NULL;
6160 static struct rte_flow_action end_action = {
6161 RTE_FLOW_ACTION_TYPE_END, 0
6165 ret = parse_vc(ctx, token, str, len, buf, size);
6168 /* Nothing else to do if there is no buffer. */
6171 if (!out->args.vc.actions_n)
6173 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6174 /* Point to selected object. */
6175 ctx->object = out->args.vc.data;
6176 ctx->objmask = NULL;
6177 /* Copy the headers to the buffer. */
6178 action_sample_data = ctx->object;
6179 action_sample_data->conf.actions = &end_action;
6180 action->conf = &action_sample_data->conf;
6185 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
6186 const char *str, unsigned int len, void *buf,
6189 struct action_sample_data *action_sample_data;
6190 struct rte_flow_action *action;
6191 const struct arg *arg;
6192 struct buffer *out = buf;
6196 RTE_SET_USED(token);
6199 if (ctx->curr != ACTION_SAMPLE_INDEX_VALUE)
6201 arg = ARGS_ENTRY_ARB_BOUNDED
6202 (offsetof(struct action_sample_data, idx),
6203 sizeof(((struct action_sample_data *)0)->idx),
6204 0, RAW_SAMPLE_CONFS_MAX_NUM - 1);
6205 if (push_args(ctx, arg))
6207 ret = parse_int(ctx, token, str, len, NULL, 0);
6214 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6215 action_sample_data = ctx->object;
6216 idx = action_sample_data->idx;
6217 action_sample_data->conf.actions = raw_sample_confs[idx].data;
6218 action->conf = &action_sample_data->conf;
6222 /** Parse operation for modify_field command. */
6224 parse_vc_modify_field_op(struct context *ctx, const struct token *token,
6225 const char *str, unsigned int len, void *buf,
6228 struct rte_flow_action_modify_field *action_modify_field;
6234 if (ctx->curr != ACTION_MODIFY_FIELD_OP_VALUE)
6236 for (i = 0; modify_field_ops[i]; ++i)
6237 if (!strcmp_partial(modify_field_ops[i], str, len))
6239 if (!modify_field_ops[i])
6243 action_modify_field = ctx->object;
6244 action_modify_field->operation = (enum rte_flow_modify_op)i;
6248 /** Parse id for modify_field command. */
6250 parse_vc_modify_field_id(struct context *ctx, const struct token *token,
6251 const char *str, unsigned int len, void *buf,
6254 struct rte_flow_action_modify_field *action_modify_field;
6260 if (ctx->curr != ACTION_MODIFY_FIELD_DST_TYPE_VALUE &&
6261 ctx->curr != ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)
6263 for (i = 0; modify_field_ids[i]; ++i)
6264 if (!strcmp_partial(modify_field_ids[i], str, len))
6266 if (!modify_field_ids[i])
6270 action_modify_field = ctx->object;
6271 if (ctx->curr == ACTION_MODIFY_FIELD_DST_TYPE_VALUE)
6272 action_modify_field->dst.field = (enum rte_flow_field_id)i;
6274 action_modify_field->src.field = (enum rte_flow_field_id)i;
6278 /** Parse tokens for destroy command. */
6280 parse_destroy(struct context *ctx, const struct token *token,
6281 const char *str, unsigned int len,
6282 void *buf, unsigned int size)
6284 struct buffer *out = buf;
6286 /* Token name must match. */
6287 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6289 /* Nothing else to do if there is no buffer. */
6292 if (!out->command) {
6293 if (ctx->curr != DESTROY)
6295 if (sizeof(*out) > size)
6297 out->command = ctx->curr;
6300 ctx->objmask = NULL;
6301 out->args.destroy.rule =
6302 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6306 if (((uint8_t *)(out->args.destroy.rule + out->args.destroy.rule_n) +
6307 sizeof(*out->args.destroy.rule)) > (uint8_t *)out + size)
6310 ctx->object = out->args.destroy.rule + out->args.destroy.rule_n++;
6311 ctx->objmask = NULL;
6315 /** Parse tokens for flush command. */
6317 parse_flush(struct context *ctx, const struct token *token,
6318 const char *str, unsigned int len,
6319 void *buf, unsigned int size)
6321 struct buffer *out = buf;
6323 /* Token name must match. */
6324 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6326 /* Nothing else to do if there is no buffer. */
6329 if (!out->command) {
6330 if (ctx->curr != FLUSH)
6332 if (sizeof(*out) > size)
6334 out->command = ctx->curr;
6337 ctx->objmask = NULL;
6342 /** Parse tokens for dump command. */
6344 parse_dump(struct context *ctx, const struct token *token,
6345 const char *str, unsigned int len,
6346 void *buf, unsigned int size)
6348 struct buffer *out = buf;
6350 /* Token name must match. */
6351 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6353 /* Nothing else to do if there is no buffer. */
6356 if (!out->command) {
6357 if (ctx->curr != DUMP)
6359 if (sizeof(*out) > size)
6361 out->command = ctx->curr;
6364 ctx->objmask = NULL;
6369 /** Parse tokens for query command. */
6371 parse_query(struct context *ctx, const struct token *token,
6372 const char *str, unsigned int len,
6373 void *buf, unsigned int size)
6375 struct buffer *out = buf;
6377 /* Token name must match. */
6378 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6380 /* Nothing else to do if there is no buffer. */
6383 if (!out->command) {
6384 if (ctx->curr != QUERY)
6386 if (sizeof(*out) > size)
6388 out->command = ctx->curr;
6391 ctx->objmask = NULL;
6396 /** Parse action names. */
6398 parse_action(struct context *ctx, const struct token *token,
6399 const char *str, unsigned int len,
6400 void *buf, unsigned int size)
6402 struct buffer *out = buf;
6403 const struct arg *arg = pop_args(ctx);
6407 /* Argument is expected. */
6410 /* Parse action name. */
6411 for (i = 0; next_action[i]; ++i) {
6412 const struct parse_action_priv *priv;
6414 token = &token_list[next_action[i]];
6415 if (strcmp_partial(token->name, str, len))
6421 memcpy((uint8_t *)ctx->object + arg->offset,
6427 push_args(ctx, arg);
6431 /** Parse tokens for list command. */
6433 parse_list(struct context *ctx, const struct token *token,
6434 const char *str, unsigned int len,
6435 void *buf, unsigned int size)
6437 struct buffer *out = buf;
6439 /* Token name must match. */
6440 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6442 /* Nothing else to do if there is no buffer. */
6445 if (!out->command) {
6446 if (ctx->curr != LIST)
6448 if (sizeof(*out) > size)
6450 out->command = ctx->curr;
6453 ctx->objmask = NULL;
6454 out->args.list.group =
6455 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6459 if (((uint8_t *)(out->args.list.group + out->args.list.group_n) +
6460 sizeof(*out->args.list.group)) > (uint8_t *)out + size)
6463 ctx->object = out->args.list.group + out->args.list.group_n++;
6464 ctx->objmask = NULL;
6468 /** Parse tokens for list all aged flows command. */
6470 parse_aged(struct context *ctx, const struct token *token,
6471 const char *str, unsigned int len,
6472 void *buf, unsigned int size)
6474 struct buffer *out = buf;
6476 /* Token name must match. */
6477 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6479 /* Nothing else to do if there is no buffer. */
6482 if (!out->command) {
6483 if (ctx->curr != AGED)
6485 if (sizeof(*out) > size)
6487 out->command = ctx->curr;
6490 ctx->objmask = NULL;
6492 if (ctx->curr == AGED_DESTROY)
6493 out->args.aged.destroy = 1;
6497 /** Parse tokens for isolate command. */
6499 parse_isolate(struct context *ctx, const struct token *token,
6500 const char *str, unsigned int len,
6501 void *buf, unsigned int size)
6503 struct buffer *out = buf;
6505 /* Token name must match. */
6506 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6508 /* Nothing else to do if there is no buffer. */
6511 if (!out->command) {
6512 if (ctx->curr != ISOLATE)
6514 if (sizeof(*out) > size)
6516 out->command = ctx->curr;
6519 ctx->objmask = NULL;
6525 parse_tunnel(struct context *ctx, const struct token *token,
6526 const char *str, unsigned int len,
6527 void *buf, unsigned int size)
6529 struct buffer *out = buf;
6531 /* Token name must match. */
6532 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6534 /* Nothing else to do if there is no buffer. */
6537 if (!out->command) {
6538 if (ctx->curr != TUNNEL)
6540 if (sizeof(*out) > size)
6542 out->command = ctx->curr;
6545 ctx->objmask = NULL;
6547 switch (ctx->curr) {
6551 case TUNNEL_DESTROY:
6553 out->command = ctx->curr;
6555 case TUNNEL_CREATE_TYPE:
6556 case TUNNEL_DESTROY_ID:
6557 ctx->object = &out->args.vc.tunnel_ops;
6566 * Parse signed/unsigned integers 8 to 64-bit long.
6568 * Last argument (ctx->args) is retrieved to determine integer type and
6572 parse_int(struct context *ctx, const struct token *token,
6573 const char *str, unsigned int len,
6574 void *buf, unsigned int size)
6576 const struct arg *arg = pop_args(ctx);
6581 /* Argument is expected. */
6586 (uintmax_t)strtoimax(str, &end, 0) :
6587 strtoumax(str, &end, 0);
6588 if (errno || (size_t)(end - str) != len)
6591 ((arg->sign && ((intmax_t)u < (intmax_t)arg->min ||
6592 (intmax_t)u > (intmax_t)arg->max)) ||
6593 (!arg->sign && (u < arg->min || u > arg->max))))
6598 if (!arg_entry_bf_fill(ctx->object, u, arg) ||
6599 !arg_entry_bf_fill(ctx->objmask, -1, arg))
6603 buf = (uint8_t *)ctx->object + arg->offset;
6605 if (u > RTE_LEN2MASK(size * CHAR_BIT, uint64_t))
6609 case sizeof(uint8_t):
6610 *(uint8_t *)buf = u;
6612 case sizeof(uint16_t):
6613 *(uint16_t *)buf = arg->hton ? rte_cpu_to_be_16(u) : u;
6615 case sizeof(uint8_t [3]):
6616 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
6618 ((uint8_t *)buf)[0] = u;
6619 ((uint8_t *)buf)[1] = u >> 8;
6620 ((uint8_t *)buf)[2] = u >> 16;
6624 ((uint8_t *)buf)[0] = u >> 16;
6625 ((uint8_t *)buf)[1] = u >> 8;
6626 ((uint8_t *)buf)[2] = u;
6628 case sizeof(uint32_t):
6629 *(uint32_t *)buf = arg->hton ? rte_cpu_to_be_32(u) : u;
6631 case sizeof(uint64_t):
6632 *(uint64_t *)buf = arg->hton ? rte_cpu_to_be_64(u) : u;
6637 if (ctx->objmask && buf != (uint8_t *)ctx->objmask + arg->offset) {
6639 buf = (uint8_t *)ctx->objmask + arg->offset;
6644 push_args(ctx, arg);
6651 * Three arguments (ctx->args) are retrieved from the stack to store data,
6652 * its actual length and address (in that order).
6655 parse_string(struct context *ctx, const struct token *token,
6656 const char *str, unsigned int len,
6657 void *buf, unsigned int size)
6659 const struct arg *arg_data = pop_args(ctx);
6660 const struct arg *arg_len = pop_args(ctx);
6661 const struct arg *arg_addr = pop_args(ctx);
6662 char tmp[16]; /* Ought to be enough. */
6665 /* Arguments are expected. */
6669 push_args(ctx, arg_data);
6673 push_args(ctx, arg_len);
6674 push_args(ctx, arg_data);
6677 size = arg_data->size;
6678 /* Bit-mask fill is not supported. */
6679 if (arg_data->mask || size < len)
6683 /* Let parse_int() fill length information first. */
6684 ret = snprintf(tmp, sizeof(tmp), "%u", len);
6687 push_args(ctx, arg_len);
6688 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
6693 buf = (uint8_t *)ctx->object + arg_data->offset;
6694 /* Output buffer is not necessarily NUL-terminated. */
6695 memcpy(buf, str, len);
6696 memset((uint8_t *)buf + len, 0x00, size - len);
6698 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
6699 /* Save address if requested. */
6700 if (arg_addr->size) {
6701 memcpy((uint8_t *)ctx->object + arg_addr->offset,
6703 (uint8_t *)ctx->object + arg_data->offset
6707 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
6709 (uint8_t *)ctx->objmask + arg_data->offset
6715 push_args(ctx, arg_addr);
6716 push_args(ctx, arg_len);
6717 push_args(ctx, arg_data);
6722 parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
6728 /* Check input parameters */
6729 if ((src == NULL) ||
6735 /* Convert chars to bytes */
6736 for (i = 0, len = 0; i < *size; i += 2) {
6737 snprintf(tmp, 3, "%s", src + i);
6738 dst[len++] = strtoul(tmp, &c, 16);
6753 parse_hex(struct context *ctx, const struct token *token,
6754 const char *str, unsigned int len,
6755 void *buf, unsigned int size)
6757 const struct arg *arg_data = pop_args(ctx);
6758 const struct arg *arg_len = pop_args(ctx);
6759 const struct arg *arg_addr = pop_args(ctx);
6760 char tmp[16]; /* Ought to be enough. */
6762 unsigned int hexlen = len;
6763 unsigned int length = 256;
6764 uint8_t hex_tmp[length];
6766 /* Arguments are expected. */
6770 push_args(ctx, arg_data);
6774 push_args(ctx, arg_len);
6775 push_args(ctx, arg_data);
6778 size = arg_data->size;
6779 /* Bit-mask fill is not supported. */
6785 /* translate bytes string to array. */
6786 if (str[0] == '0' && ((str[1] == 'x') ||
6791 if (hexlen > length)
6793 ret = parse_hex_string(str, hex_tmp, &hexlen);
6796 /* Let parse_int() fill length information first. */
6797 ret = snprintf(tmp, sizeof(tmp), "%u", hexlen);
6800 /* Save length if requested. */
6801 if (arg_len->size) {
6802 push_args(ctx, arg_len);
6803 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
6809 buf = (uint8_t *)ctx->object + arg_data->offset;
6810 /* Output buffer is not necessarily NUL-terminated. */
6811 memcpy(buf, hex_tmp, hexlen);
6812 memset((uint8_t *)buf + hexlen, 0x00, size - hexlen);
6814 memset((uint8_t *)ctx->objmask + arg_data->offset,
6816 /* Save address if requested. */
6817 if (arg_addr->size) {
6818 memcpy((uint8_t *)ctx->object + arg_addr->offset,
6820 (uint8_t *)ctx->object + arg_data->offset
6824 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
6826 (uint8_t *)ctx->objmask + arg_data->offset
6832 push_args(ctx, arg_addr);
6833 push_args(ctx, arg_len);
6834 push_args(ctx, arg_data);
6840 * Parse a zero-ended string.
6843 parse_string0(struct context *ctx, const struct token *token __rte_unused,
6844 const char *str, unsigned int len,
6845 void *buf, unsigned int size)
6847 const struct arg *arg_data = pop_args(ctx);
6849 /* Arguments are expected. */
6852 size = arg_data->size;
6853 /* Bit-mask fill is not supported. */
6854 if (arg_data->mask || size < len + 1)
6858 buf = (uint8_t *)ctx->object + arg_data->offset;
6859 strncpy(buf, str, len);
6861 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
6864 push_args(ctx, arg_data);
6869 * Parse a MAC address.
6871 * Last argument (ctx->args) is retrieved to determine storage size and
6875 parse_mac_addr(struct context *ctx, const struct token *token,
6876 const char *str, unsigned int len,
6877 void *buf, unsigned int size)
6879 const struct arg *arg = pop_args(ctx);
6880 struct rte_ether_addr tmp;
6884 /* Argument is expected. */
6888 /* Bit-mask fill is not supported. */
6889 if (arg->mask || size != sizeof(tmp))
6891 /* Only network endian is supported. */
6894 ret = cmdline_parse_etheraddr(NULL, str, &tmp, size);
6895 if (ret < 0 || (unsigned int)ret != len)
6899 buf = (uint8_t *)ctx->object + arg->offset;
6900 memcpy(buf, &tmp, size);
6902 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6905 push_args(ctx, arg);
6910 * Parse an IPv4 address.
6912 * Last argument (ctx->args) is retrieved to determine storage size and
6916 parse_ipv4_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);
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 memcpy(str2, str, len);
6937 ret = inet_pton(AF_INET, str2, &tmp);
6939 /* Attempt integer parsing. */
6940 push_args(ctx, arg);
6941 return parse_int(ctx, token, str, len, buf, size);
6945 buf = (uint8_t *)ctx->object + arg->offset;
6946 memcpy(buf, &tmp, size);
6948 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6951 push_args(ctx, arg);
6956 * Parse an IPv6 address.
6958 * Last argument (ctx->args) is retrieved to determine storage size and
6962 parse_ipv6_addr(struct context *ctx, const struct token *token,
6963 const char *str, unsigned int len,
6964 void *buf, unsigned int size)
6966 const struct arg *arg = pop_args(ctx);
6968 struct in6_addr tmp;
6972 /* Argument is expected. */
6976 /* Bit-mask fill is not supported. */
6977 if (arg->mask || size != sizeof(tmp))
6979 /* Only network endian is supported. */
6982 memcpy(str2, str, len);
6984 ret = inet_pton(AF_INET6, str2, &tmp);
6989 buf = (uint8_t *)ctx->object + arg->offset;
6990 memcpy(buf, &tmp, size);
6992 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6995 push_args(ctx, arg);
6999 /** Boolean values (even indices stand for false). */
7000 static const char *const boolean_name[] = {
7010 * Parse a boolean value.
7012 * Last argument (ctx->args) is retrieved to determine storage size and
7016 parse_boolean(struct context *ctx, const struct token *token,
7017 const char *str, unsigned int len,
7018 void *buf, unsigned int size)
7020 const struct arg *arg = pop_args(ctx);
7024 /* Argument is expected. */
7027 for (i = 0; boolean_name[i]; ++i)
7028 if (!strcmp_partial(boolean_name[i], str, len))
7030 /* Process token as integer. */
7031 if (boolean_name[i])
7032 str = i & 1 ? "1" : "0";
7033 push_args(ctx, arg);
7034 ret = parse_int(ctx, token, str, strlen(str), buf, size);
7035 return ret > 0 ? (int)len : ret;
7038 /** Parse port and update context. */
7040 parse_port(struct context *ctx, const struct token *token,
7041 const char *str, unsigned int len,
7042 void *buf, unsigned int size)
7044 struct buffer *out = &(struct buffer){ .port = 0 };
7052 ctx->objmask = NULL;
7053 size = sizeof(*out);
7055 ret = parse_int(ctx, token, str, len, out, size);
7057 ctx->port = out->port;
7064 parse_sa_id2ptr(struct context *ctx, const struct token *token,
7065 const char *str, unsigned int len,
7066 void *buf, unsigned int size)
7068 struct rte_flow_action *action = ctx->object;
7076 ctx->objmask = NULL;
7077 ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
7078 ctx->object = action;
7079 if (ret != (int)len)
7081 /* set shared action */
7083 action->conf = port_shared_action_get_by_id(ctx->port, id);
7084 ret = (action->conf) ? ret : -1;
7089 /** Parse set command, initialize output buffer for subsequent tokens. */
7091 parse_set_raw_encap_decap(struct context *ctx, const struct token *token,
7092 const char *str, unsigned int len,
7093 void *buf, unsigned int size)
7095 struct buffer *out = buf;
7097 /* Token name must match. */
7098 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7100 /* Nothing else to do if there is no buffer. */
7103 /* Make sure buffer is large enough. */
7104 if (size < sizeof(*out))
7107 ctx->objmask = NULL;
7111 out->command = ctx->curr;
7112 /* For encap/decap we need is pattern */
7113 out->args.vc.pattern = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7118 /** Parse set command, initialize output buffer for subsequent tokens. */
7120 parse_set_sample_action(struct context *ctx, const struct token *token,
7121 const char *str, unsigned int len,
7122 void *buf, unsigned int size)
7124 struct buffer *out = buf;
7126 /* Token name must match. */
7127 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7129 /* Nothing else to do if there is no buffer. */
7132 /* Make sure buffer is large enough. */
7133 if (size < sizeof(*out))
7136 ctx->objmask = NULL;
7140 out->command = ctx->curr;
7141 /* For sampler we need is actions */
7142 out->args.vc.actions = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7148 * Parse set raw_encap/raw_decap command,
7149 * initialize output buffer for subsequent tokens.
7152 parse_set_init(struct context *ctx, const struct token *token,
7153 const char *str, unsigned int len,
7154 void *buf, unsigned int size)
7156 struct buffer *out = buf;
7158 /* Token name must match. */
7159 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7161 /* Nothing else to do if there is no buffer. */
7164 /* Make sure buffer is large enough. */
7165 if (size < sizeof(*out))
7167 /* Initialize buffer. */
7168 memset(out, 0x00, sizeof(*out));
7169 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
7172 ctx->objmask = NULL;
7173 if (!out->command) {
7174 if (ctx->curr != SET)
7176 if (sizeof(*out) > size)
7178 out->command = ctx->curr;
7179 out->args.vc.data = (uint8_t *)out + size;
7180 ctx->object = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7186 /** No completion. */
7188 comp_none(struct context *ctx, const struct token *token,
7189 unsigned int ent, char *buf, unsigned int size)
7199 /** Complete boolean values. */
7201 comp_boolean(struct context *ctx, const struct token *token,
7202 unsigned int ent, char *buf, unsigned int size)
7208 for (i = 0; boolean_name[i]; ++i)
7209 if (buf && i == ent)
7210 return strlcpy(buf, boolean_name[i], size);
7216 /** Complete action names. */
7218 comp_action(struct context *ctx, const struct token *token,
7219 unsigned int ent, char *buf, unsigned int size)
7225 for (i = 0; next_action[i]; ++i)
7226 if (buf && i == ent)
7227 return strlcpy(buf, token_list[next_action[i]].name,
7234 /** Complete available ports. */
7236 comp_port(struct context *ctx, const struct token *token,
7237 unsigned int ent, char *buf, unsigned int size)
7244 RTE_ETH_FOREACH_DEV(p) {
7245 if (buf && i == ent)
7246 return snprintf(buf, size, "%u", p);
7254 /** Complete available rule IDs. */
7256 comp_rule_id(struct context *ctx, const struct token *token,
7257 unsigned int ent, char *buf, unsigned int size)
7260 struct rte_port *port;
7261 struct port_flow *pf;
7264 if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
7265 ctx->port == (portid_t)RTE_PORT_ALL)
7267 port = &ports[ctx->port];
7268 for (pf = port->flow_list; pf != NULL; pf = pf->next) {
7269 if (buf && i == ent)
7270 return snprintf(buf, size, "%u", pf->id);
7278 /** Complete type field for RSS action. */
7280 comp_vc_action_rss_type(struct context *ctx, const struct token *token,
7281 unsigned int ent, char *buf, unsigned int size)
7287 for (i = 0; rss_type_table[i].str; ++i)
7292 return strlcpy(buf, rss_type_table[ent].str, size);
7294 return snprintf(buf, size, "end");
7298 /** Complete queue field for RSS action. */
7300 comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
7301 unsigned int ent, char *buf, unsigned int size)
7308 return snprintf(buf, size, "%u", ent);
7310 return snprintf(buf, size, "end");
7314 /** Complete index number for set raw_encap/raw_decap commands. */
7316 comp_set_raw_index(struct context *ctx, const struct token *token,
7317 unsigned int ent, char *buf, unsigned int size)
7323 RTE_SET_USED(token);
7324 for (idx = 0; idx < RAW_ENCAP_CONFS_MAX_NUM; ++idx) {
7325 if (buf && idx == ent)
7326 return snprintf(buf, size, "%u", idx);
7332 /** Complete index number for set raw_encap/raw_decap commands. */
7334 comp_set_sample_index(struct context *ctx, const struct token *token,
7335 unsigned int ent, char *buf, unsigned int size)
7341 RTE_SET_USED(token);
7342 for (idx = 0; idx < RAW_SAMPLE_CONFS_MAX_NUM; ++idx) {
7343 if (buf && idx == ent)
7344 return snprintf(buf, size, "%u", idx);
7350 /** Complete operation for modify_field command. */
7352 comp_set_modify_field_op(struct context *ctx, const struct token *token,
7353 unsigned int ent, char *buf, unsigned int size)
7358 RTE_SET_USED(token);
7359 for (idx = 0; modify_field_ops[idx]; ++idx)
7364 return strlcpy(buf, modify_field_ops[ent], size);
7368 /** Complete field id for modify_field command. */
7370 comp_set_modify_field_id(struct context *ctx, const struct token *token,
7371 unsigned int ent, char *buf, unsigned int size)
7376 RTE_SET_USED(token);
7377 for (idx = 0; modify_field_ids[idx]; ++idx)
7382 return strlcpy(buf, modify_field_ids[ent], size);
7386 /** Internal context. */
7387 static struct context cmd_flow_context;
7389 /** Global parser instance (cmdline API). */
7390 cmdline_parse_inst_t cmd_flow;
7391 cmdline_parse_inst_t cmd_set_raw;
7393 /** Initialize context. */
7395 cmd_flow_context_init(struct context *ctx)
7397 /* A full memset() is not necessary. */
7407 ctx->objmask = NULL;
7410 /** Parse a token (cmdline API). */
7412 cmd_flow_parse(cmdline_parse_token_hdr_t *hdr, const char *src, void *result,
7415 struct context *ctx = &cmd_flow_context;
7416 const struct token *token;
7417 const enum index *list;
7422 token = &token_list[ctx->curr];
7423 /* Check argument length. */
7426 for (len = 0; src[len]; ++len)
7427 if (src[len] == '#' || isspace(src[len]))
7431 /* Last argument and EOL detection. */
7432 for (i = len; src[i]; ++i)
7433 if (src[i] == '#' || src[i] == '\r' || src[i] == '\n')
7435 else if (!isspace(src[i])) {
7440 if (src[i] == '\r' || src[i] == '\n') {
7444 /* Initialize context if necessary. */
7445 if (!ctx->next_num) {
7448 ctx->next[ctx->next_num++] = token->next[0];
7450 /* Process argument through candidates. */
7451 ctx->prev = ctx->curr;
7452 list = ctx->next[ctx->next_num - 1];
7453 for (i = 0; list[i]; ++i) {
7454 const struct token *next = &token_list[list[i]];
7457 ctx->curr = list[i];
7459 tmp = next->call(ctx, next, src, len, result, size);
7461 tmp = parse_default(ctx, next, src, len, result, size);
7462 if (tmp == -1 || tmp != len)
7470 /* Push subsequent tokens if any. */
7472 for (i = 0; token->next[i]; ++i) {
7473 if (ctx->next_num == RTE_DIM(ctx->next))
7475 ctx->next[ctx->next_num++] = token->next[i];
7477 /* Push arguments if any. */
7479 for (i = 0; token->args[i]; ++i) {
7480 if (ctx->args_num == RTE_DIM(ctx->args))
7482 ctx->args[ctx->args_num++] = token->args[i];
7487 /** Return number of completion entries (cmdline API). */
7489 cmd_flow_complete_get_nb(cmdline_parse_token_hdr_t *hdr)
7491 struct context *ctx = &cmd_flow_context;
7492 const struct token *token = &token_list[ctx->curr];
7493 const enum index *list;
7497 /* Count number of tokens in current list. */
7499 list = ctx->next[ctx->next_num - 1];
7501 list = token->next[0];
7502 for (i = 0; list[i]; ++i)
7507 * If there is a single token, use its completion callback, otherwise
7508 * return the number of entries.
7510 token = &token_list[list[0]];
7511 if (i == 1 && token->comp) {
7512 /* Save index for cmd_flow_get_help(). */
7513 ctx->prev = list[0];
7514 return token->comp(ctx, token, 0, NULL, 0);
7519 /** Return a completion entry (cmdline API). */
7521 cmd_flow_complete_get_elt(cmdline_parse_token_hdr_t *hdr, int index,
7522 char *dst, unsigned int size)
7524 struct context *ctx = &cmd_flow_context;
7525 const struct token *token = &token_list[ctx->curr];
7526 const enum index *list;
7530 /* Count number of tokens in current list. */
7532 list = ctx->next[ctx->next_num - 1];
7534 list = token->next[0];
7535 for (i = 0; list[i]; ++i)
7539 /* If there is a single token, use its completion callback. */
7540 token = &token_list[list[0]];
7541 if (i == 1 && token->comp) {
7542 /* Save index for cmd_flow_get_help(). */
7543 ctx->prev = list[0];
7544 return token->comp(ctx, token, index, dst, size) < 0 ? -1 : 0;
7546 /* Otherwise make sure the index is valid and use defaults. */
7549 token = &token_list[list[index]];
7550 strlcpy(dst, token->name, size);
7551 /* Save index for cmd_flow_get_help(). */
7552 ctx->prev = list[index];
7556 /** Populate help strings for current token (cmdline API). */
7558 cmd_flow_get_help(cmdline_parse_token_hdr_t *hdr, char *dst, unsigned int size)
7560 struct context *ctx = &cmd_flow_context;
7561 const struct token *token = &token_list[ctx->prev];
7566 /* Set token type and update global help with details. */
7567 strlcpy(dst, (token->type ? token->type : "TOKEN"), size);
7569 cmd_flow.help_str = token->help;
7571 cmd_flow.help_str = token->name;
7575 /** Token definition template (cmdline API). */
7576 static struct cmdline_token_hdr cmd_flow_token_hdr = {
7577 .ops = &(struct cmdline_token_ops){
7578 .parse = cmd_flow_parse,
7579 .complete_get_nb = cmd_flow_complete_get_nb,
7580 .complete_get_elt = cmd_flow_complete_get_elt,
7581 .get_help = cmd_flow_get_help,
7586 /** Populate the next dynamic token. */
7588 cmd_flow_tok(cmdline_parse_token_hdr_t **hdr,
7589 cmdline_parse_token_hdr_t **hdr_inst)
7591 struct context *ctx = &cmd_flow_context;
7593 /* Always reinitialize context before requesting the first token. */
7594 if (!(hdr_inst - cmd_flow.tokens))
7595 cmd_flow_context_init(ctx);
7596 /* Return NULL when no more tokens are expected. */
7597 if (!ctx->next_num && ctx->curr) {
7601 /* Determine if command should end here. */
7602 if (ctx->eol && ctx->last && ctx->next_num) {
7603 const enum index *list = ctx->next[ctx->next_num - 1];
7606 for (i = 0; list[i]; ++i) {
7613 *hdr = &cmd_flow_token_hdr;
7616 /** Dispatch parsed buffer to function calls. */
7618 cmd_flow_parsed(const struct buffer *in)
7620 switch (in->command) {
7621 case SHARED_ACTION_CREATE:
7622 port_shared_action_create(
7623 in->port, in->args.vc.attr.group,
7624 &((const struct rte_flow_shared_action_conf) {
7625 .ingress = in->args.vc.attr.ingress,
7626 .egress = in->args.vc.attr.egress,
7627 .transfer = in->args.vc.attr.transfer,
7629 in->args.vc.actions);
7631 case SHARED_ACTION_DESTROY:
7632 port_shared_action_destroy(in->port,
7633 in->args.sa_destroy.action_id_n,
7634 in->args.sa_destroy.action_id);
7636 case SHARED_ACTION_UPDATE:
7637 port_shared_action_update(in->port, in->args.vc.attr.group,
7638 in->args.vc.actions);
7640 case SHARED_ACTION_QUERY:
7641 port_shared_action_query(in->port, in->args.sa.action_id);
7644 port_flow_validate(in->port, &in->args.vc.attr,
7645 in->args.vc.pattern, in->args.vc.actions,
7646 &in->args.vc.tunnel_ops);
7649 port_flow_create(in->port, &in->args.vc.attr,
7650 in->args.vc.pattern, in->args.vc.actions,
7651 &in->args.vc.tunnel_ops);
7654 port_flow_destroy(in->port, in->args.destroy.rule_n,
7655 in->args.destroy.rule);
7658 port_flow_flush(in->port);
7661 port_flow_dump(in->port, in->args.dump.file);
7664 port_flow_query(in->port, in->args.query.rule,
7665 &in->args.query.action);
7668 port_flow_list(in->port, in->args.list.group_n,
7669 in->args.list.group);
7672 port_flow_isolate(in->port, in->args.isolate.set);
7675 port_flow_aged(in->port, in->args.aged.destroy);
7678 port_flow_tunnel_create(in->port, &in->args.vc.tunnel_ops);
7680 case TUNNEL_DESTROY:
7681 port_flow_tunnel_destroy(in->port, in->args.vc.tunnel_ops.id);
7684 port_flow_tunnel_list(in->port);
7691 /** Token generator and output processing callback (cmdline API). */
7693 cmd_flow_cb(void *arg0, struct cmdline *cl, void *arg2)
7696 cmd_flow_tok(arg0, arg2);
7698 cmd_flow_parsed(arg0);
7701 /** Global parser instance (cmdline API). */
7702 cmdline_parse_inst_t cmd_flow = {
7704 .data = NULL, /**< Unused. */
7705 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
7708 }, /**< Tokens are returned by cmd_flow_tok(). */
7711 /** set cmd facility. Reuse cmd flow's infrastructure as much as possible. */
7714 update_fields(uint8_t *buf, struct rte_flow_item *item, uint16_t next_proto)
7716 struct rte_ipv4_hdr *ipv4;
7717 struct rte_ether_hdr *eth;
7718 struct rte_ipv6_hdr *ipv6;
7719 struct rte_vxlan_hdr *vxlan;
7720 struct rte_vxlan_gpe_hdr *gpe;
7721 struct rte_flow_item_nvgre *nvgre;
7722 uint32_t ipv6_vtc_flow;
7724 switch (item->type) {
7725 case RTE_FLOW_ITEM_TYPE_ETH:
7726 eth = (struct rte_ether_hdr *)buf;
7728 eth->ether_type = rte_cpu_to_be_16(next_proto);
7730 case RTE_FLOW_ITEM_TYPE_IPV4:
7731 ipv4 = (struct rte_ipv4_hdr *)buf;
7732 ipv4->version_ihl = 0x45;
7733 if (next_proto && ipv4->next_proto_id == 0)
7734 ipv4->next_proto_id = (uint8_t)next_proto;
7736 case RTE_FLOW_ITEM_TYPE_IPV6:
7737 ipv6 = (struct rte_ipv6_hdr *)buf;
7738 if (next_proto && ipv6->proto == 0)
7739 ipv6->proto = (uint8_t)next_proto;
7740 ipv6_vtc_flow = rte_be_to_cpu_32(ipv6->vtc_flow);
7741 ipv6_vtc_flow &= 0x0FFFFFFF; /*< reset version bits. */
7742 ipv6_vtc_flow |= 0x60000000; /*< set ipv6 version. */
7743 ipv6->vtc_flow = rte_cpu_to_be_32(ipv6_vtc_flow);
7745 case RTE_FLOW_ITEM_TYPE_VXLAN:
7746 vxlan = (struct rte_vxlan_hdr *)buf;
7747 vxlan->vx_flags = 0x08;
7749 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
7750 gpe = (struct rte_vxlan_gpe_hdr *)buf;
7751 gpe->vx_flags = 0x0C;
7753 case RTE_FLOW_ITEM_TYPE_NVGRE:
7754 nvgre = (struct rte_flow_item_nvgre *)buf;
7755 nvgre->protocol = rte_cpu_to_be_16(0x6558);
7756 nvgre->c_k_s_rsvd0_ver = rte_cpu_to_be_16(0x2000);
7763 /** Helper of get item's default mask. */
7765 flow_item_default_mask(const struct rte_flow_item *item)
7767 const void *mask = NULL;
7768 static rte_be32_t gre_key_default_mask = RTE_BE32(UINT32_MAX);
7770 switch (item->type) {
7771 case RTE_FLOW_ITEM_TYPE_ANY:
7772 mask = &rte_flow_item_any_mask;
7774 case RTE_FLOW_ITEM_TYPE_VF:
7775 mask = &rte_flow_item_vf_mask;
7777 case RTE_FLOW_ITEM_TYPE_PORT_ID:
7778 mask = &rte_flow_item_port_id_mask;
7780 case RTE_FLOW_ITEM_TYPE_RAW:
7781 mask = &rte_flow_item_raw_mask;
7783 case RTE_FLOW_ITEM_TYPE_ETH:
7784 mask = &rte_flow_item_eth_mask;
7786 case RTE_FLOW_ITEM_TYPE_VLAN:
7787 mask = &rte_flow_item_vlan_mask;
7789 case RTE_FLOW_ITEM_TYPE_IPV4:
7790 mask = &rte_flow_item_ipv4_mask;
7792 case RTE_FLOW_ITEM_TYPE_IPV6:
7793 mask = &rte_flow_item_ipv6_mask;
7795 case RTE_FLOW_ITEM_TYPE_ICMP:
7796 mask = &rte_flow_item_icmp_mask;
7798 case RTE_FLOW_ITEM_TYPE_UDP:
7799 mask = &rte_flow_item_udp_mask;
7801 case RTE_FLOW_ITEM_TYPE_TCP:
7802 mask = &rte_flow_item_tcp_mask;
7804 case RTE_FLOW_ITEM_TYPE_SCTP:
7805 mask = &rte_flow_item_sctp_mask;
7807 case RTE_FLOW_ITEM_TYPE_VXLAN:
7808 mask = &rte_flow_item_vxlan_mask;
7810 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
7811 mask = &rte_flow_item_vxlan_gpe_mask;
7813 case RTE_FLOW_ITEM_TYPE_E_TAG:
7814 mask = &rte_flow_item_e_tag_mask;
7816 case RTE_FLOW_ITEM_TYPE_NVGRE:
7817 mask = &rte_flow_item_nvgre_mask;
7819 case RTE_FLOW_ITEM_TYPE_MPLS:
7820 mask = &rte_flow_item_mpls_mask;
7822 case RTE_FLOW_ITEM_TYPE_GRE:
7823 mask = &rte_flow_item_gre_mask;
7825 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
7826 mask = &gre_key_default_mask;
7828 case RTE_FLOW_ITEM_TYPE_META:
7829 mask = &rte_flow_item_meta_mask;
7831 case RTE_FLOW_ITEM_TYPE_FUZZY:
7832 mask = &rte_flow_item_fuzzy_mask;
7834 case RTE_FLOW_ITEM_TYPE_GTP:
7835 mask = &rte_flow_item_gtp_mask;
7837 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
7838 mask = &rte_flow_item_gtp_psc_mask;
7840 case RTE_FLOW_ITEM_TYPE_GENEVE:
7841 mask = &rte_flow_item_geneve_mask;
7843 case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
7844 mask = &rte_flow_item_geneve_opt_mask;
7846 case RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID:
7847 mask = &rte_flow_item_pppoe_proto_id_mask;
7849 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
7850 mask = &rte_flow_item_l2tpv3oip_mask;
7852 case RTE_FLOW_ITEM_TYPE_ESP:
7853 mask = &rte_flow_item_esp_mask;
7855 case RTE_FLOW_ITEM_TYPE_AH:
7856 mask = &rte_flow_item_ah_mask;
7858 case RTE_FLOW_ITEM_TYPE_PFCP:
7859 mask = &rte_flow_item_pfcp_mask;
7867 /** Dispatch parsed buffer to function calls. */
7869 cmd_set_raw_parsed_sample(const struct buffer *in)
7871 uint32_t n = in->args.vc.actions_n;
7873 struct rte_flow_action *action = NULL;
7874 struct rte_flow_action *data = NULL;
7875 const struct rte_flow_action_rss *rss = NULL;
7877 uint16_t idx = in->port; /* We borrow port field as index */
7878 uint32_t max_size = sizeof(struct rte_flow_action) *
7879 ACTION_SAMPLE_ACTIONS_NUM;
7881 RTE_ASSERT(in->command == SET_SAMPLE_ACTIONS);
7882 data = (struct rte_flow_action *)&raw_sample_confs[idx].data;
7883 memset(data, 0x00, max_size);
7884 for (; i <= n - 1; i++) {
7885 action = in->args.vc.actions + i;
7886 if (action->type == RTE_FLOW_ACTION_TYPE_END)
7888 switch (action->type) {
7889 case RTE_FLOW_ACTION_TYPE_MARK:
7890 size = sizeof(struct rte_flow_action_mark);
7891 rte_memcpy(&sample_mark[idx],
7892 (const void *)action->conf, size);
7893 action->conf = &sample_mark[idx];
7895 case RTE_FLOW_ACTION_TYPE_COUNT:
7896 size = sizeof(struct rte_flow_action_count);
7897 rte_memcpy(&sample_count[idx],
7898 (const void *)action->conf, size);
7899 action->conf = &sample_count[idx];
7901 case RTE_FLOW_ACTION_TYPE_QUEUE:
7902 size = sizeof(struct rte_flow_action_queue);
7903 rte_memcpy(&sample_queue[idx],
7904 (const void *)action->conf, size);
7905 action->conf = &sample_queue[idx];
7907 case RTE_FLOW_ACTION_TYPE_RSS:
7908 size = sizeof(struct rte_flow_action_rss);
7910 rte_memcpy(&sample_rss_data[idx].conf,
7911 (const void *)rss, size);
7912 if (rss->key_len && rss->key) {
7913 sample_rss_data[idx].conf.key =
7914 sample_rss_data[idx].key;
7915 rte_memcpy((void *)((uintptr_t)
7916 sample_rss_data[idx].conf.key),
7917 (const void *)rss->key,
7918 sizeof(uint8_t) * rss->key_len);
7920 if (rss->queue_num && rss->queue) {
7921 sample_rss_data[idx].conf.queue =
7922 sample_rss_data[idx].queue;
7923 rte_memcpy((void *)((uintptr_t)
7924 sample_rss_data[idx].conf.queue),
7925 (const void *)rss->queue,
7926 sizeof(uint16_t) * rss->queue_num);
7928 action->conf = &sample_rss_data[idx].conf;
7930 case RTE_FLOW_ACTION_TYPE_RAW_ENCAP:
7931 size = sizeof(struct rte_flow_action_raw_encap);
7932 rte_memcpy(&sample_encap[idx],
7933 (const void *)action->conf, size);
7934 action->conf = &sample_encap[idx];
7936 case RTE_FLOW_ACTION_TYPE_PORT_ID:
7937 size = sizeof(struct rte_flow_action_port_id);
7938 rte_memcpy(&sample_port_id[idx],
7939 (const void *)action->conf, size);
7940 action->conf = &sample_port_id[idx];
7942 case RTE_FLOW_ACTION_TYPE_PF:
7944 case RTE_FLOW_ACTION_TYPE_VF:
7945 size = sizeof(struct rte_flow_action_vf);
7946 rte_memcpy(&sample_vf[idx],
7947 (const void *)action->conf, size);
7948 action->conf = &sample_vf[idx];
7950 case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP:
7951 size = sizeof(struct rte_flow_action_vxlan_encap);
7952 parse_setup_vxlan_encap_data(&sample_vxlan_encap[idx]);
7953 action->conf = &sample_vxlan_encap[idx].conf;
7956 printf("Error - Not supported action\n");
7959 rte_memcpy(data, action, sizeof(struct rte_flow_action));
7964 /** Dispatch parsed buffer to function calls. */
7966 cmd_set_raw_parsed(const struct buffer *in)
7968 uint32_t n = in->args.vc.pattern_n;
7970 struct rte_flow_item *item = NULL;
7972 uint8_t *data = NULL;
7973 uint8_t *data_tail = NULL;
7974 size_t *total_size = NULL;
7975 uint16_t upper_layer = 0;
7977 uint16_t idx = in->port; /* We borrow port field as index */
7978 int gtp_psc = -1; /* GTP PSC option index. */
7980 if (in->command == SET_SAMPLE_ACTIONS)
7981 return cmd_set_raw_parsed_sample(in);
7982 RTE_ASSERT(in->command == SET_RAW_ENCAP ||
7983 in->command == SET_RAW_DECAP);
7984 if (in->command == SET_RAW_ENCAP) {
7985 total_size = &raw_encap_confs[idx].size;
7986 data = (uint8_t *)&raw_encap_confs[idx].data;
7988 total_size = &raw_decap_confs[idx].size;
7989 data = (uint8_t *)&raw_decap_confs[idx].data;
7992 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
7993 /* process hdr from upper layer to low layer (L3/L4 -> L2). */
7994 data_tail = data + ACTION_RAW_ENCAP_MAX_DATA;
7995 for (i = n - 1 ; i >= 0; --i) {
7996 const struct rte_flow_item_gtp *gtp;
7997 const struct rte_flow_item_geneve_opt *opt;
7999 item = in->args.vc.pattern + i;
8000 if (item->spec == NULL)
8001 item->spec = flow_item_default_mask(item);
8002 switch (item->type) {
8003 case RTE_FLOW_ITEM_TYPE_ETH:
8004 size = sizeof(struct rte_ether_hdr);
8006 case RTE_FLOW_ITEM_TYPE_VLAN:
8007 size = sizeof(struct rte_vlan_hdr);
8008 proto = RTE_ETHER_TYPE_VLAN;
8010 case RTE_FLOW_ITEM_TYPE_IPV4:
8011 size = sizeof(struct rte_ipv4_hdr);
8012 proto = RTE_ETHER_TYPE_IPV4;
8014 case RTE_FLOW_ITEM_TYPE_IPV6:
8015 size = sizeof(struct rte_ipv6_hdr);
8016 proto = RTE_ETHER_TYPE_IPV6;
8018 case RTE_FLOW_ITEM_TYPE_UDP:
8019 size = sizeof(struct rte_udp_hdr);
8022 case RTE_FLOW_ITEM_TYPE_TCP:
8023 size = sizeof(struct rte_tcp_hdr);
8026 case RTE_FLOW_ITEM_TYPE_VXLAN:
8027 size = sizeof(struct rte_vxlan_hdr);
8029 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
8030 size = sizeof(struct rte_vxlan_gpe_hdr);
8032 case RTE_FLOW_ITEM_TYPE_GRE:
8033 size = sizeof(struct rte_gre_hdr);
8036 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
8037 size = sizeof(rte_be32_t);
8040 case RTE_FLOW_ITEM_TYPE_MPLS:
8041 size = sizeof(struct rte_mpls_hdr);
8044 case RTE_FLOW_ITEM_TYPE_NVGRE:
8045 size = sizeof(struct rte_flow_item_nvgre);
8048 case RTE_FLOW_ITEM_TYPE_GENEVE:
8049 size = sizeof(struct rte_geneve_hdr);
8051 case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
8052 opt = (const struct rte_flow_item_geneve_opt *)
8054 size = offsetof(struct rte_flow_item_geneve_opt, data);
8055 if (opt->option_len && opt->data) {
8056 *total_size += opt->option_len *
8058 rte_memcpy(data_tail - (*total_size),
8060 opt->option_len * sizeof(uint32_t));
8063 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
8064 size = sizeof(rte_be32_t);
8067 case RTE_FLOW_ITEM_TYPE_ESP:
8068 size = sizeof(struct rte_esp_hdr);
8071 case RTE_FLOW_ITEM_TYPE_AH:
8072 size = sizeof(struct rte_flow_item_ah);
8075 case RTE_FLOW_ITEM_TYPE_GTP:
8077 size = sizeof(struct rte_gtp_hdr);
8080 if (gtp_psc != i + 1) {
8081 printf("Error - GTP PSC does not follow GTP\n");
8085 if ((gtp->v_pt_rsv_flags & 0x07) != 0x04) {
8086 /* Only E flag should be set. */
8087 printf("Error - GTP unsupported flags\n");
8090 struct rte_gtp_hdr_ext_word ext_word = {
8094 /* We have to add GTP header extra word. */
8095 *total_size += sizeof(ext_word);
8096 rte_memcpy(data_tail - (*total_size),
8097 &ext_word, sizeof(ext_word));
8099 size = sizeof(struct rte_gtp_hdr);
8101 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
8103 printf("Error - Multiple GTP PSC items\n");
8106 const struct rte_flow_item_gtp_psc
8115 if (opt->pdu_type & 0x0F) {
8116 /* Support the minimal option only. */
8117 printf("Error - GTP PSC option with "
8118 "extra fields not supported\n");
8121 psc.len = sizeof(psc);
8122 psc.pdu_type = opt->pdu_type;
8125 *total_size += sizeof(psc);
8126 rte_memcpy(data_tail - (*total_size),
8132 case RTE_FLOW_ITEM_TYPE_PFCP:
8133 size = sizeof(struct rte_flow_item_pfcp);
8136 printf("Error - Not supported item\n");
8139 *total_size += size;
8140 rte_memcpy(data_tail - (*total_size), item->spec, size);
8141 /* update some fields which cannot be set by cmdline */
8142 update_fields((data_tail - (*total_size)), item,
8144 upper_layer = proto;
8146 if (verbose_level & 0x1)
8147 printf("total data size is %zu\n", (*total_size));
8148 RTE_ASSERT((*total_size) <= ACTION_RAW_ENCAP_MAX_DATA);
8149 memmove(data, (data_tail - (*total_size)), *total_size);
8154 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
8157 /** Populate help strings for current token (cmdline API). */
8159 cmd_set_raw_get_help(cmdline_parse_token_hdr_t *hdr, char *dst,
8162 struct context *ctx = &cmd_flow_context;
8163 const struct token *token = &token_list[ctx->prev];
8168 /* Set token type and update global help with details. */
8169 snprintf(dst, size, "%s", (token->type ? token->type : "TOKEN"));
8171 cmd_set_raw.help_str = token->help;
8173 cmd_set_raw.help_str = token->name;
8177 /** Token definition template (cmdline API). */
8178 static struct cmdline_token_hdr cmd_set_raw_token_hdr = {
8179 .ops = &(struct cmdline_token_ops){
8180 .parse = cmd_flow_parse,
8181 .complete_get_nb = cmd_flow_complete_get_nb,
8182 .complete_get_elt = cmd_flow_complete_get_elt,
8183 .get_help = cmd_set_raw_get_help,
8188 /** Populate the next dynamic token. */
8190 cmd_set_raw_tok(cmdline_parse_token_hdr_t **hdr,
8191 cmdline_parse_token_hdr_t **hdr_inst)
8193 struct context *ctx = &cmd_flow_context;
8195 /* Always reinitialize context before requesting the first token. */
8196 if (!(hdr_inst - cmd_set_raw.tokens)) {
8197 cmd_flow_context_init(ctx);
8198 ctx->curr = START_SET;
8200 /* Return NULL when no more tokens are expected. */
8201 if (!ctx->next_num && (ctx->curr != START_SET)) {
8205 /* Determine if command should end here. */
8206 if (ctx->eol && ctx->last && ctx->next_num) {
8207 const enum index *list = ctx->next[ctx->next_num - 1];
8210 for (i = 0; list[i]; ++i) {
8217 *hdr = &cmd_set_raw_token_hdr;
8220 /** Token generator and output processing callback (cmdline API). */
8222 cmd_set_raw_cb(void *arg0, struct cmdline *cl, void *arg2)
8225 cmd_set_raw_tok(arg0, arg2);
8227 cmd_set_raw_parsed(arg0);
8230 /** Global parser instance (cmdline API). */
8231 cmdline_parse_inst_t cmd_set_raw = {
8232 .f = cmd_set_raw_cb,
8233 .data = NULL, /**< Unused. */
8234 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
8237 }, /**< Tokens are returned by cmd_flow_tok(). */
8240 /* *** display raw_encap/raw_decap buf */
8241 struct cmd_show_set_raw_result {
8242 cmdline_fixed_string_t cmd_show;
8243 cmdline_fixed_string_t cmd_what;
8244 cmdline_fixed_string_t cmd_all;
8249 cmd_show_set_raw_parsed(void *parsed_result, struct cmdline *cl, void *data)
8251 struct cmd_show_set_raw_result *res = parsed_result;
8252 uint16_t index = res->cmd_index;
8254 uint8_t *raw_data = NULL;
8255 size_t raw_size = 0;
8256 char title[16] = {0};
8260 if (!strcmp(res->cmd_all, "all")) {
8263 } else if (index >= RAW_ENCAP_CONFS_MAX_NUM) {
8264 printf("index should be 0-%u\n", RAW_ENCAP_CONFS_MAX_NUM - 1);
8268 if (!strcmp(res->cmd_what, "raw_encap")) {
8269 raw_data = (uint8_t *)&raw_encap_confs[index].data;
8270 raw_size = raw_encap_confs[index].size;
8271 snprintf(title, 16, "\nindex: %u", index);
8272 rte_hexdump(stdout, title, raw_data, raw_size);
8274 raw_data = (uint8_t *)&raw_decap_confs[index].data;
8275 raw_size = raw_decap_confs[index].size;
8276 snprintf(title, 16, "\nindex: %u", index);
8277 rte_hexdump(stdout, title, raw_data, raw_size);
8279 } while (all && ++index < RAW_ENCAP_CONFS_MAX_NUM);
8282 cmdline_parse_token_string_t cmd_show_set_raw_cmd_show =
8283 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
8285 cmdline_parse_token_string_t cmd_show_set_raw_cmd_what =
8286 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
8287 cmd_what, "raw_encap#raw_decap");
8288 cmdline_parse_token_num_t cmd_show_set_raw_cmd_index =
8289 TOKEN_NUM_INITIALIZER(struct cmd_show_set_raw_result,
8290 cmd_index, RTE_UINT16);
8291 cmdline_parse_token_string_t cmd_show_set_raw_cmd_all =
8292 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
8294 cmdline_parse_inst_t cmd_show_set_raw = {
8295 .f = cmd_show_set_raw_parsed,
8297 .help_str = "show <raw_encap|raw_decap> <index>",
8299 (void *)&cmd_show_set_raw_cmd_show,
8300 (void *)&cmd_show_set_raw_cmd_what,
8301 (void *)&cmd_show_set_raw_cmd_index,
8305 cmdline_parse_inst_t cmd_show_set_raw_all = {
8306 .f = cmd_show_set_raw_parsed,
8308 .help_str = "show <raw_encap|raw_decap> all",
8310 (void *)&cmd_show_set_raw_cmd_show,
8311 (void *)&cmd_show_set_raw_cmd_what,
8312 (void *)&cmd_show_set_raw_cmd_all,