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_rss_data sample_rss_data[RAW_SAMPLE_CONFS_MAX_NUM];
586 struct rte_flow_action_vf sample_vf[RAW_SAMPLE_CONFS_MAX_NUM];
588 static const char *const modify_field_ops[] = {
589 "set", "add", "sub", NULL
592 static const char *const modify_field_ids[] = {
593 "start", "mac_dst", "mac_src",
594 "vlan_type", "vlan_id", "mac_type",
595 "ipv4_dscp", "ipv4_ttl", "ipv4_src", "ipv4_dst",
596 "ipv6_dscp", "ipv6_hoplimit", "ipv6_src", "ipv6_dst",
597 "tcp_port_src", "tcp_port_dst",
598 "tcp_seq_num", "tcp_ack_num", "tcp_flags",
599 "udp_port_src", "udp_port_dst",
600 "vxlan_vni", "geneve_vni", "gtp_teid",
601 "tag", "mark", "meta", "pointer", "value", NULL
604 /** Maximum number of subsequent tokens and arguments on the stack. */
605 #define CTX_STACK_SIZE 16
607 /** Parser context. */
609 /** Stack of subsequent token lists to process. */
610 const enum index *next[CTX_STACK_SIZE];
611 /** Arguments for stacked tokens. */
612 const void *args[CTX_STACK_SIZE];
613 enum index curr; /**< Current token index. */
614 enum index prev; /**< Index of the last token seen. */
615 int next_num; /**< Number of entries in next[]. */
616 int args_num; /**< Number of entries in args[]. */
617 uint32_t eol:1; /**< EOL has been detected. */
618 uint32_t last:1; /**< No more arguments. */
619 portid_t port; /**< Current port ID (for completions). */
620 uint32_t objdata; /**< Object-specific data. */
621 void *object; /**< Address of current object for relative offsets. */
622 void *objmask; /**< Object a full mask must be written to. */
625 /** Token argument. */
627 uint32_t hton:1; /**< Use network byte ordering. */
628 uint32_t sign:1; /**< Value is signed. */
629 uint32_t bounded:1; /**< Value is bounded. */
630 uintmax_t min; /**< Minimum value if bounded. */
631 uintmax_t max; /**< Maximum value if bounded. */
632 uint32_t offset; /**< Relative offset from ctx->object. */
633 uint32_t size; /**< Field size. */
634 const uint8_t *mask; /**< Bit-mask to use instead of offset/size. */
637 /** Parser token definition. */
639 /** Type displayed during completion (defaults to "TOKEN"). */
641 /** Help displayed during completion (defaults to token name). */
643 /** Private data used by parser functions. */
646 * Lists of subsequent tokens to push on the stack. Each call to the
647 * parser consumes the last entry of that stack.
649 const enum index *const *next;
650 /** Arguments stack for subsequent tokens that need them. */
651 const struct arg *const *args;
653 * Token-processing callback, returns -1 in case of error, the
654 * length of the matched string otherwise. If NULL, attempts to
655 * match the token name.
657 * If buf is not NULL, the result should be stored in it according
658 * to context. An error is returned if not large enough.
660 int (*call)(struct context *ctx, const struct token *token,
661 const char *str, unsigned int len,
662 void *buf, unsigned int size);
664 * Callback that provides possible values for this token, used for
665 * completion. Returns -1 in case of error, the number of possible
666 * values otherwise. If NULL, the token name is used.
668 * If buf is not NULL, entry index ent is written to buf and the
669 * full length of the entry is returned (same behavior as
672 int (*comp)(struct context *ctx, const struct token *token,
673 unsigned int ent, char *buf, unsigned int size);
674 /** Mandatory token name, no default value. */
678 /** Static initializer for the next field. */
679 #define NEXT(...) (const enum index *const []){ __VA_ARGS__, NULL, }
681 /** Static initializer for a NEXT() entry. */
682 #define NEXT_ENTRY(...) (const enum index []){ __VA_ARGS__, ZERO, }
684 /** Static initializer for the args field. */
685 #define ARGS(...) (const struct arg *const []){ __VA_ARGS__, NULL, }
687 /** Static initializer for ARGS() to target a field. */
688 #define ARGS_ENTRY(s, f) \
689 (&(const struct arg){ \
690 .offset = offsetof(s, f), \
691 .size = sizeof(((s *)0)->f), \
694 /** Static initializer for ARGS() to target a bit-field. */
695 #define ARGS_ENTRY_BF(s, f, b) \
696 (&(const struct arg){ \
698 .mask = (const void *)&(const s){ .f = (1 << (b)) - 1 }, \
701 /** Static initializer for ARGS() to target a field with limits. */
702 #define ARGS_ENTRY_BOUNDED(s, f, i, a) \
703 (&(const struct arg){ \
707 .offset = offsetof(s, f), \
708 .size = sizeof(((s *)0)->f), \
711 /** Static initializer for ARGS() to target an arbitrary bit-mask. */
712 #define ARGS_ENTRY_MASK(s, f, m) \
713 (&(const struct arg){ \
714 .offset = offsetof(s, f), \
715 .size = sizeof(((s *)0)->f), \
716 .mask = (const void *)(m), \
719 /** Same as ARGS_ENTRY_MASK() using network byte ordering for the value. */
720 #define ARGS_ENTRY_MASK_HTON(s, f, m) \
721 (&(const struct arg){ \
723 .offset = offsetof(s, f), \
724 .size = sizeof(((s *)0)->f), \
725 .mask = (const void *)(m), \
728 /** Static initializer for ARGS() to target a pointer. */
729 #define ARGS_ENTRY_PTR(s, f) \
730 (&(const struct arg){ \
731 .size = sizeof(*((s *)0)->f), \
734 /** Static initializer for ARGS() with arbitrary offset and size. */
735 #define ARGS_ENTRY_ARB(o, s) \
736 (&(const struct arg){ \
741 /** Same as ARGS_ENTRY_ARB() with bounded values. */
742 #define ARGS_ENTRY_ARB_BOUNDED(o, s, i, a) \
743 (&(const struct arg){ \
751 /** Same as ARGS_ENTRY() using network byte ordering. */
752 #define ARGS_ENTRY_HTON(s, f) \
753 (&(const struct arg){ \
755 .offset = offsetof(s, f), \
756 .size = sizeof(((s *)0)->f), \
759 /** Same as ARGS_ENTRY_HTON() for a single argument, without structure. */
760 #define ARG_ENTRY_HTON(s) \
761 (&(const struct arg){ \
767 /** Parser output buffer layout expected by cmd_flow_parsed(). */
769 enum index command; /**< Flow command. */
770 portid_t port; /**< Affected port ID. */
774 uint32_t action_id_n;
775 } sa_destroy; /**< Shared action destroy arguments. */
778 } sa; /* Shared action query arguments */
780 struct rte_flow_attr attr;
781 struct tunnel_ops tunnel_ops;
782 struct rte_flow_item *pattern;
783 struct rte_flow_action *actions;
787 } vc; /**< Validate/create arguments. */
791 } destroy; /**< Destroy arguments. */
794 } dump; /**< Dump arguments. */
797 struct rte_flow_action action;
798 } query; /**< Query arguments. */
802 } list; /**< List arguments. */
805 } isolate; /**< Isolated mode arguments. */
808 } aged; /**< Aged arguments. */
809 } args; /**< Command arguments. */
812 /** Private data for pattern items. */
813 struct parse_item_priv {
814 enum rte_flow_item_type type; /**< Item type. */
815 uint32_t size; /**< Size of item specification structure. */
818 #define PRIV_ITEM(t, s) \
819 (&(const struct parse_item_priv){ \
820 .type = RTE_FLOW_ITEM_TYPE_ ## t, \
824 /** Private data for actions. */
825 struct parse_action_priv {
826 enum rte_flow_action_type type; /**< Action type. */
827 uint32_t size; /**< Size of action configuration structure. */
830 #define PRIV_ACTION(t, s) \
831 (&(const struct parse_action_priv){ \
832 .type = RTE_FLOW_ACTION_TYPE_ ## t, \
836 static const enum index next_sa_create_attr[] = {
837 SHARED_ACTION_CREATE_ID,
838 SHARED_ACTION_INGRESS,
839 SHARED_ACTION_EGRESS,
840 SHARED_ACTION_TRANSFER,
845 static const enum index next_sa_subcmd[] = {
846 SHARED_ACTION_CREATE,
847 SHARED_ACTION_UPDATE,
848 SHARED_ACTION_DESTROY,
853 static const enum index next_vc_attr[] = {
865 static const enum index next_destroy_attr[] = {
871 static const enum index next_dump_attr[] = {
877 static const enum index next_list_attr[] = {
883 static const enum index next_aged_attr[] = {
889 static const enum index next_sa_destroy_attr[] = {
890 SHARED_ACTION_DESTROY_ID,
895 static const enum index item_param[] = {
904 static const enum index next_item[] = {
941 ITEM_ICMP6_ND_OPT_SLA_ETH,
942 ITEM_ICMP6_ND_OPT_TLA_ETH,
961 static const enum index item_fuzzy[] = {
967 static const enum index item_any[] = {
973 static const enum index item_vf[] = {
979 static const enum index item_phy_port[] = {
985 static const enum index item_port_id[] = {
991 static const enum index item_mark[] = {
997 static const enum index item_raw[] = {
1007 static const enum index item_eth[] = {
1016 static const enum index item_vlan[] = {
1021 ITEM_VLAN_INNER_TYPE,
1022 ITEM_VLAN_HAS_MORE_VLAN,
1027 static const enum index item_ipv4[] = {
1029 ITEM_IPV4_FRAGMENT_OFFSET,
1038 static const enum index item_ipv6[] = {
1045 ITEM_IPV6_HAS_FRAG_EXT,
1050 static const enum index item_icmp[] = {
1059 static const enum index item_udp[] = {
1066 static const enum index item_tcp[] = {
1074 static const enum index item_sctp[] = {
1083 static const enum index item_vxlan[] = {
1089 static const enum index item_e_tag[] = {
1090 ITEM_E_TAG_GRP_ECID_B,
1095 static const enum index item_nvgre[] = {
1101 static const enum index item_mpls[] = {
1109 static const enum index item_gre[] = {
1111 ITEM_GRE_C_RSVD0_VER,
1119 static const enum index item_gre_key[] = {
1125 static const enum index item_gtp[] = {
1133 static const enum index item_geneve[] = {
1141 static const enum index item_vxlan_gpe[] = {
1147 static const enum index item_arp_eth_ipv4[] = {
1148 ITEM_ARP_ETH_IPV4_SHA,
1149 ITEM_ARP_ETH_IPV4_SPA,
1150 ITEM_ARP_ETH_IPV4_THA,
1151 ITEM_ARP_ETH_IPV4_TPA,
1156 static const enum index item_ipv6_ext[] = {
1157 ITEM_IPV6_EXT_NEXT_HDR,
1162 static const enum index item_ipv6_frag_ext[] = {
1163 ITEM_IPV6_FRAG_EXT_NEXT_HDR,
1164 ITEM_IPV6_FRAG_EXT_FRAG_DATA,
1169 static const enum index item_icmp6[] = {
1176 static const enum index item_icmp6_nd_ns[] = {
1177 ITEM_ICMP6_ND_NS_TARGET_ADDR,
1182 static const enum index item_icmp6_nd_na[] = {
1183 ITEM_ICMP6_ND_NA_TARGET_ADDR,
1188 static const enum index item_icmp6_nd_opt[] = {
1189 ITEM_ICMP6_ND_OPT_TYPE,
1194 static const enum index item_icmp6_nd_opt_sla_eth[] = {
1195 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
1200 static const enum index item_icmp6_nd_opt_tla_eth[] = {
1201 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
1206 static const enum index item_meta[] = {
1212 static const enum index item_gtp_psc[] = {
1219 static const enum index item_pppoed[] = {
1225 static const enum index item_pppoes[] = {
1231 static const enum index item_pppoe_proto_id[] = {
1236 static const enum index item_higig2[] = {
1237 ITEM_HIGIG2_CLASSIFICATION,
1243 static const enum index item_esp[] = {
1249 static const enum index item_ah[] = {
1255 static const enum index item_pfcp[] = {
1262 static const enum index next_set_raw[] = {
1268 static const enum index item_tag[] = {
1275 static const enum index item_l2tpv3oip[] = {
1276 ITEM_L2TPV3OIP_SESSION_ID,
1281 static const enum index item_ecpri[] = {
1287 static const enum index item_ecpri_common[] = {
1288 ITEM_ECPRI_COMMON_TYPE,
1292 static const enum index item_ecpri_common_type[] = {
1293 ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
1294 ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
1295 ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
1299 static const enum index item_geneve_opt[] = {
1300 ITEM_GENEVE_OPT_CLASS,
1301 ITEM_GENEVE_OPT_TYPE,
1302 ITEM_GENEVE_OPT_LENGTH,
1303 ITEM_GENEVE_OPT_DATA,
1308 static const enum index next_action[] = {
1324 ACTION_OF_SET_MPLS_TTL,
1325 ACTION_OF_DEC_MPLS_TTL,
1326 ACTION_OF_SET_NW_TTL,
1327 ACTION_OF_DEC_NW_TTL,
1328 ACTION_OF_COPY_TTL_OUT,
1329 ACTION_OF_COPY_TTL_IN,
1331 ACTION_OF_PUSH_VLAN,
1332 ACTION_OF_SET_VLAN_VID,
1333 ACTION_OF_SET_VLAN_PCP,
1335 ACTION_OF_PUSH_MPLS,
1342 ACTION_MPLSOGRE_ENCAP,
1343 ACTION_MPLSOGRE_DECAP,
1344 ACTION_MPLSOUDP_ENCAP,
1345 ACTION_MPLSOUDP_DECAP,
1346 ACTION_SET_IPV4_SRC,
1347 ACTION_SET_IPV4_DST,
1348 ACTION_SET_IPV6_SRC,
1349 ACTION_SET_IPV6_DST,
1365 ACTION_SET_IPV4_DSCP,
1366 ACTION_SET_IPV6_DSCP,
1370 ACTION_MODIFY_FIELD,
1374 static const enum index action_mark[] = {
1380 static const enum index action_queue[] = {
1386 static const enum index action_count[] = {
1388 ACTION_COUNT_SHARED,
1393 static const enum index action_rss[] = {
1404 static const enum index action_vf[] = {
1411 static const enum index action_phy_port[] = {
1412 ACTION_PHY_PORT_ORIGINAL,
1413 ACTION_PHY_PORT_INDEX,
1418 static const enum index action_port_id[] = {
1419 ACTION_PORT_ID_ORIGINAL,
1425 static const enum index action_meter[] = {
1431 static const enum index action_of_set_mpls_ttl[] = {
1432 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
1437 static const enum index action_of_set_nw_ttl[] = {
1438 ACTION_OF_SET_NW_TTL_NW_TTL,
1443 static const enum index action_of_push_vlan[] = {
1444 ACTION_OF_PUSH_VLAN_ETHERTYPE,
1449 static const enum index action_of_set_vlan_vid[] = {
1450 ACTION_OF_SET_VLAN_VID_VLAN_VID,
1455 static const enum index action_of_set_vlan_pcp[] = {
1456 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
1461 static const enum index action_of_pop_mpls[] = {
1462 ACTION_OF_POP_MPLS_ETHERTYPE,
1467 static const enum index action_of_push_mpls[] = {
1468 ACTION_OF_PUSH_MPLS_ETHERTYPE,
1473 static const enum index action_set_ipv4_src[] = {
1474 ACTION_SET_IPV4_SRC_IPV4_SRC,
1479 static const enum index action_set_mac_src[] = {
1480 ACTION_SET_MAC_SRC_MAC_SRC,
1485 static const enum index action_set_ipv4_dst[] = {
1486 ACTION_SET_IPV4_DST_IPV4_DST,
1491 static const enum index action_set_ipv6_src[] = {
1492 ACTION_SET_IPV6_SRC_IPV6_SRC,
1497 static const enum index action_set_ipv6_dst[] = {
1498 ACTION_SET_IPV6_DST_IPV6_DST,
1503 static const enum index action_set_tp_src[] = {
1504 ACTION_SET_TP_SRC_TP_SRC,
1509 static const enum index action_set_tp_dst[] = {
1510 ACTION_SET_TP_DST_TP_DST,
1515 static const enum index action_set_ttl[] = {
1521 static const enum index action_jump[] = {
1527 static const enum index action_set_mac_dst[] = {
1528 ACTION_SET_MAC_DST_MAC_DST,
1533 static const enum index action_inc_tcp_seq[] = {
1534 ACTION_INC_TCP_SEQ_VALUE,
1539 static const enum index action_dec_tcp_seq[] = {
1540 ACTION_DEC_TCP_SEQ_VALUE,
1545 static const enum index action_inc_tcp_ack[] = {
1546 ACTION_INC_TCP_ACK_VALUE,
1551 static const enum index action_dec_tcp_ack[] = {
1552 ACTION_DEC_TCP_ACK_VALUE,
1557 static const enum index action_raw_encap[] = {
1558 ACTION_RAW_ENCAP_INDEX,
1563 static const enum index action_raw_decap[] = {
1564 ACTION_RAW_DECAP_INDEX,
1569 static const enum index action_set_tag[] = {
1570 ACTION_SET_TAG_DATA,
1571 ACTION_SET_TAG_INDEX,
1572 ACTION_SET_TAG_MASK,
1577 static const enum index action_set_meta[] = {
1578 ACTION_SET_META_DATA,
1579 ACTION_SET_META_MASK,
1584 static const enum index action_set_ipv4_dscp[] = {
1585 ACTION_SET_IPV4_DSCP_VALUE,
1590 static const enum index action_set_ipv6_dscp[] = {
1591 ACTION_SET_IPV6_DSCP_VALUE,
1596 static const enum index action_age[] = {
1603 static const enum index action_sample[] = {
1605 ACTION_SAMPLE_RATIO,
1606 ACTION_SAMPLE_INDEX,
1611 static const enum index next_action_sample[] = {
1622 static const enum index action_modify_field_dst[] = {
1623 ACTION_MODIFY_FIELD_DST_LEVEL,
1624 ACTION_MODIFY_FIELD_DST_OFFSET,
1625 ACTION_MODIFY_FIELD_SRC_TYPE,
1629 static const enum index action_modify_field_src[] = {
1630 ACTION_MODIFY_FIELD_SRC_LEVEL,
1631 ACTION_MODIFY_FIELD_SRC_OFFSET,
1632 ACTION_MODIFY_FIELD_SRC_VALUE,
1633 ACTION_MODIFY_FIELD_WIDTH,
1637 static int parse_set_raw_encap_decap(struct context *, const struct token *,
1638 const char *, unsigned int,
1639 void *, unsigned int);
1640 static int parse_set_sample_action(struct context *, const struct token *,
1641 const char *, unsigned int,
1642 void *, unsigned int);
1643 static int parse_set_init(struct context *, const struct token *,
1644 const char *, unsigned int,
1645 void *, unsigned int);
1646 static int parse_init(struct context *, const struct token *,
1647 const char *, unsigned int,
1648 void *, unsigned int);
1649 static int parse_vc(struct context *, const struct token *,
1650 const char *, unsigned int,
1651 void *, unsigned int);
1652 static int parse_vc_spec(struct context *, const struct token *,
1653 const char *, unsigned int, void *, unsigned int);
1654 static int parse_vc_conf(struct context *, const struct token *,
1655 const char *, unsigned int, void *, unsigned int);
1656 static int parse_vc_item_ecpri_type(struct context *, const struct token *,
1657 const char *, unsigned int,
1658 void *, unsigned int);
1659 static int parse_vc_action_rss(struct context *, const struct token *,
1660 const char *, unsigned int, void *,
1662 static int parse_vc_action_rss_func(struct context *, const struct token *,
1663 const char *, unsigned int, void *,
1665 static int parse_vc_action_rss_type(struct context *, const struct token *,
1666 const char *, unsigned int, void *,
1668 static int parse_vc_action_rss_queue(struct context *, const struct token *,
1669 const char *, unsigned int, void *,
1671 static int parse_vc_action_vxlan_encap(struct context *, const struct token *,
1672 const char *, unsigned int, void *,
1674 static int parse_vc_action_nvgre_encap(struct context *, const struct token *,
1675 const char *, unsigned int, void *,
1677 static int parse_vc_action_l2_encap(struct context *, const struct token *,
1678 const char *, unsigned int, void *,
1680 static int parse_vc_action_l2_decap(struct context *, const struct token *,
1681 const char *, unsigned int, void *,
1683 static int parse_vc_action_mplsogre_encap(struct context *,
1684 const struct token *, const char *,
1685 unsigned int, void *, unsigned int);
1686 static int parse_vc_action_mplsogre_decap(struct context *,
1687 const struct token *, const char *,
1688 unsigned int, void *, unsigned int);
1689 static int parse_vc_action_mplsoudp_encap(struct context *,
1690 const struct token *, const char *,
1691 unsigned int, void *, unsigned int);
1692 static int parse_vc_action_mplsoudp_decap(struct context *,
1693 const struct token *, const char *,
1694 unsigned int, void *, unsigned int);
1695 static int parse_vc_action_raw_encap(struct context *,
1696 const struct token *, const char *,
1697 unsigned int, void *, unsigned int);
1698 static int parse_vc_action_raw_decap(struct context *,
1699 const struct token *, const char *,
1700 unsigned int, void *, unsigned int);
1701 static int parse_vc_action_raw_encap_index(struct context *,
1702 const struct token *, const char *,
1703 unsigned int, void *, unsigned int);
1704 static int parse_vc_action_raw_decap_index(struct context *,
1705 const struct token *, const char *,
1706 unsigned int, void *, unsigned int);
1707 static int parse_vc_action_set_meta(struct context *ctx,
1708 const struct token *token, const char *str,
1709 unsigned int len, void *buf,
1711 static int parse_vc_action_sample(struct context *ctx,
1712 const struct token *token, const char *str,
1713 unsigned int len, void *buf,
1716 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
1717 const char *str, unsigned int len, void *buf,
1720 parse_vc_modify_field_op(struct context *ctx, const struct token *token,
1721 const char *str, unsigned int len, void *buf,
1724 parse_vc_modify_field_id(struct context *ctx, const struct token *token,
1725 const char *str, unsigned int len, void *buf,
1727 static int parse_destroy(struct context *, const struct token *,
1728 const char *, unsigned int,
1729 void *, unsigned int);
1730 static int parse_flush(struct context *, const struct token *,
1731 const char *, unsigned int,
1732 void *, unsigned int);
1733 static int parse_dump(struct context *, const struct token *,
1734 const char *, unsigned int,
1735 void *, unsigned int);
1736 static int parse_query(struct context *, const struct token *,
1737 const char *, unsigned int,
1738 void *, unsigned int);
1739 static int parse_action(struct context *, const struct token *,
1740 const char *, unsigned int,
1741 void *, unsigned int);
1742 static int parse_list(struct context *, const struct token *,
1743 const char *, unsigned int,
1744 void *, unsigned int);
1745 static int parse_aged(struct context *, const struct token *,
1746 const char *, unsigned int,
1747 void *, unsigned int);
1748 static int parse_isolate(struct context *, const struct token *,
1749 const char *, unsigned int,
1750 void *, unsigned int);
1751 static int parse_tunnel(struct context *, const struct token *,
1752 const char *, unsigned int,
1753 void *, unsigned int);
1754 static int parse_int(struct context *, const struct token *,
1755 const char *, unsigned int,
1756 void *, unsigned int);
1757 static int parse_prefix(struct context *, const struct token *,
1758 const char *, unsigned int,
1759 void *, unsigned int);
1760 static int parse_boolean(struct context *, const struct token *,
1761 const char *, unsigned int,
1762 void *, unsigned int);
1763 static int parse_string(struct context *, const struct token *,
1764 const char *, unsigned int,
1765 void *, unsigned int);
1766 static int parse_hex(struct context *ctx, const struct token *token,
1767 const char *str, unsigned int len,
1768 void *buf, unsigned int size);
1769 static int parse_string0(struct context *, const struct token *,
1770 const char *, unsigned int,
1771 void *, unsigned int);
1772 static int parse_mac_addr(struct context *, const struct token *,
1773 const char *, unsigned int,
1774 void *, unsigned int);
1775 static int parse_ipv4_addr(struct context *, const struct token *,
1776 const char *, unsigned int,
1777 void *, unsigned int);
1778 static int parse_ipv6_addr(struct context *, const struct token *,
1779 const char *, unsigned int,
1780 void *, unsigned int);
1781 static int parse_port(struct context *, const struct token *,
1782 const char *, unsigned int,
1783 void *, unsigned int);
1784 static int parse_sa(struct context *, const struct token *,
1785 const char *, unsigned int,
1786 void *, unsigned int);
1787 static int parse_sa_destroy(struct context *ctx, const struct token *token,
1788 const char *str, unsigned int len,
1789 void *buf, unsigned int size);
1790 static int parse_sa_id2ptr(struct context *ctx, const struct token *token,
1791 const char *str, unsigned int len, void *buf,
1793 static int comp_none(struct context *, const struct token *,
1794 unsigned int, char *, unsigned int);
1795 static int comp_boolean(struct context *, const struct token *,
1796 unsigned int, char *, unsigned int);
1797 static int comp_action(struct context *, const struct token *,
1798 unsigned int, char *, unsigned int);
1799 static int comp_port(struct context *, const struct token *,
1800 unsigned int, char *, unsigned int);
1801 static int comp_rule_id(struct context *, const struct token *,
1802 unsigned int, char *, unsigned int);
1803 static int comp_vc_action_rss_type(struct context *, const struct token *,
1804 unsigned int, char *, unsigned int);
1805 static int comp_vc_action_rss_queue(struct context *, const struct token *,
1806 unsigned int, char *, unsigned int);
1807 static int comp_set_raw_index(struct context *, const struct token *,
1808 unsigned int, char *, unsigned int);
1809 static int comp_set_sample_index(struct context *, const struct token *,
1810 unsigned int, char *, unsigned int);
1811 static int comp_set_modify_field_op(struct context *, const struct token *,
1812 unsigned int, char *, unsigned int);
1813 static int comp_set_modify_field_id(struct context *, const struct token *,
1814 unsigned int, char *, unsigned int);
1816 /** Token definitions. */
1817 static const struct token token_list[] = {
1818 /* Special tokens. */
1821 .help = "null entry, abused as the entry point",
1822 .next = NEXT(NEXT_ENTRY(FLOW)),
1827 .help = "command may end here",
1830 .name = "START_SET",
1831 .help = "null entry, abused as the entry point for set",
1832 .next = NEXT(NEXT_ENTRY(SET)),
1837 .help = "set command may end here",
1839 /* Common tokens. */
1843 .help = "integer value",
1848 .name = "{unsigned}",
1850 .help = "unsigned integer value",
1857 .help = "prefix length for bit-mask",
1858 .call = parse_prefix,
1862 .name = "{boolean}",
1864 .help = "any boolean value",
1865 .call = parse_boolean,
1866 .comp = comp_boolean,
1871 .help = "fixed string",
1872 .call = parse_string,
1878 .help = "fixed string",
1882 .name = "{file path}",
1884 .help = "file path",
1885 .call = parse_string0,
1889 .name = "{MAC address}",
1891 .help = "standard MAC address notation",
1892 .call = parse_mac_addr,
1896 .name = "{IPv4 address}",
1897 .type = "IPV4 ADDRESS",
1898 .help = "standard IPv4 address notation",
1899 .call = parse_ipv4_addr,
1903 .name = "{IPv6 address}",
1904 .type = "IPV6 ADDRESS",
1905 .help = "standard IPv6 address notation",
1906 .call = parse_ipv6_addr,
1910 .name = "{rule id}",
1912 .help = "rule identifier",
1914 .comp = comp_rule_id,
1917 .name = "{port_id}",
1919 .help = "port identifier",
1924 .name = "{group_id}",
1926 .help = "group identifier",
1930 [PRIORITY_LEVEL] = {
1933 .help = "priority level",
1937 [SHARED_ACTION_ID] = {
1938 .name = "{shared_action_id}",
1939 .type = "SHARED_ACTION_ID",
1940 .help = "shared action id",
1944 /* Top-level command. */
1947 .type = "{command} {port_id} [{arg} [...]]",
1948 .help = "manage ingress/egress flow rules",
1949 .next = NEXT(NEXT_ENTRY
1963 /* Top-level command. */
1965 .name = "shared_action",
1966 .type = "{command} {port_id} [{arg} [...]]",
1967 .help = "manage shared actions",
1968 .next = NEXT(next_sa_subcmd, NEXT_ENTRY(PORT_ID)),
1969 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1972 /* Sub-level commands. */
1973 [SHARED_ACTION_CREATE] = {
1975 .help = "create shared action",
1976 .next = NEXT(next_sa_create_attr),
1979 [SHARED_ACTION_UPDATE] = {
1981 .help = "update shared action",
1982 .next = NEXT(NEXT_ENTRY(SHARED_ACTION_SPEC),
1983 NEXT_ENTRY(SHARED_ACTION_ID)),
1984 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
1987 [SHARED_ACTION_DESTROY] = {
1989 .help = "destroy shared action",
1990 .next = NEXT(NEXT_ENTRY(SHARED_ACTION_DESTROY_ID)),
1991 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1992 .call = parse_sa_destroy,
1994 [SHARED_ACTION_QUERY] = {
1996 .help = "query shared action",
1997 .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(SHARED_ACTION_ID)),
1998 .args = ARGS(ARGS_ENTRY(struct buffer, args.sa.action_id)),
2003 .help = "check whether a flow rule can be created",
2004 .next = NEXT(next_vc_attr, NEXT_ENTRY(PORT_ID)),
2005 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2010 .help = "create a flow rule",
2011 .next = NEXT(next_vc_attr, NEXT_ENTRY(PORT_ID)),
2012 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2017 .help = "destroy specific flow rules",
2018 .next = NEXT(NEXT_ENTRY(DESTROY_RULE), NEXT_ENTRY(PORT_ID)),
2019 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2020 .call = parse_destroy,
2024 .help = "destroy all flow rules",
2025 .next = NEXT(NEXT_ENTRY(PORT_ID)),
2026 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2027 .call = parse_flush,
2031 .help = "dump all flow rules to file",
2032 .next = NEXT(next_dump_attr, NEXT_ENTRY(PORT_ID)),
2033 .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file),
2034 ARGS_ENTRY(struct buffer, port)),
2039 .help = "query an existing flow rule",
2040 .next = NEXT(NEXT_ENTRY(QUERY_ACTION),
2041 NEXT_ENTRY(RULE_ID),
2042 NEXT_ENTRY(PORT_ID)),
2043 .args = ARGS(ARGS_ENTRY(struct buffer, args.query.action.type),
2044 ARGS_ENTRY(struct buffer, args.query.rule),
2045 ARGS_ENTRY(struct buffer, port)),
2046 .call = parse_query,
2050 .help = "list existing flow rules",
2051 .next = NEXT(next_list_attr, NEXT_ENTRY(PORT_ID)),
2052 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2057 .help = "list and destroy aged flows",
2058 .next = NEXT(next_aged_attr, NEXT_ENTRY(PORT_ID)),
2059 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2064 .help = "restrict ingress traffic to the defined flow rules",
2065 .next = NEXT(NEXT_ENTRY(BOOLEAN),
2066 NEXT_ENTRY(PORT_ID)),
2067 .args = ARGS(ARGS_ENTRY(struct buffer, args.isolate.set),
2068 ARGS_ENTRY(struct buffer, port)),
2069 .call = parse_isolate,
2073 .help = "new tunnel API",
2074 .next = NEXT(NEXT_ENTRY
2075 (TUNNEL_CREATE, TUNNEL_LIST, TUNNEL_DESTROY)),
2076 .call = parse_tunnel,
2078 /* Tunnel arguments. */
2081 .help = "create new tunnel object",
2082 .next = NEXT(NEXT_ENTRY(TUNNEL_CREATE_TYPE),
2083 NEXT_ENTRY(PORT_ID)),
2084 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2085 .call = parse_tunnel,
2087 [TUNNEL_CREATE_TYPE] = {
2089 .help = "create new tunnel",
2090 .next = NEXT(NEXT_ENTRY(FILE_PATH)),
2091 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, type)),
2092 .call = parse_tunnel,
2094 [TUNNEL_DESTROY] = {
2096 .help = "destroy tunel",
2097 .next = NEXT(NEXT_ENTRY(TUNNEL_DESTROY_ID),
2098 NEXT_ENTRY(PORT_ID)),
2099 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2100 .call = parse_tunnel,
2102 [TUNNEL_DESTROY_ID] = {
2104 .help = "tunnel identifier to testroy",
2105 .next = NEXT(NEXT_ENTRY(UNSIGNED)),
2106 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2107 .call = parse_tunnel,
2111 .help = "list existing tunnels",
2112 .next = NEXT(NEXT_ENTRY(PORT_ID)),
2113 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2114 .call = parse_tunnel,
2116 /* Destroy arguments. */
2119 .help = "specify a rule identifier",
2120 .next = NEXT(next_destroy_attr, NEXT_ENTRY(RULE_ID)),
2121 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.destroy.rule)),
2122 .call = parse_destroy,
2124 /* Query arguments. */
2128 .help = "action to query, must be part of the rule",
2129 .call = parse_action,
2130 .comp = comp_action,
2132 /* List arguments. */
2135 .help = "specify a group",
2136 .next = NEXT(next_list_attr, NEXT_ENTRY(GROUP_ID)),
2137 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.list.group)),
2142 .help = "specify aged flows need be destroyed",
2146 /* Validate/create attributes. */
2149 .help = "specify a group",
2150 .next = NEXT(next_vc_attr, NEXT_ENTRY(GROUP_ID)),
2151 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, group)),
2156 .help = "specify a priority level",
2157 .next = NEXT(next_vc_attr, NEXT_ENTRY(PRIORITY_LEVEL)),
2158 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, priority)),
2163 .help = "affect rule to ingress",
2164 .next = NEXT(next_vc_attr),
2169 .help = "affect rule to egress",
2170 .next = NEXT(next_vc_attr),
2175 .help = "apply rule directly to endpoints found in pattern",
2176 .next = NEXT(next_vc_attr),
2180 .name = "tunnel_set",
2181 .help = "tunnel steer rule",
2182 .next = NEXT(next_vc_attr, NEXT_ENTRY(UNSIGNED)),
2183 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2187 .name = "tunnel_match",
2188 .help = "tunnel match rule",
2189 .next = NEXT(next_vc_attr, NEXT_ENTRY(UNSIGNED)),
2190 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2193 /* Validate/create pattern. */
2196 .help = "submit a list of pattern items",
2197 .next = NEXT(next_item),
2202 .help = "match value perfectly (with full bit-mask)",
2203 .call = parse_vc_spec,
2205 [ITEM_PARAM_SPEC] = {
2207 .help = "match value according to configured bit-mask",
2208 .call = parse_vc_spec,
2210 [ITEM_PARAM_LAST] = {
2212 .help = "specify upper bound to establish a range",
2213 .call = parse_vc_spec,
2215 [ITEM_PARAM_MASK] = {
2217 .help = "specify bit-mask with relevant bits set to one",
2218 .call = parse_vc_spec,
2220 [ITEM_PARAM_PREFIX] = {
2222 .help = "generate bit-mask from a prefix length",
2223 .call = parse_vc_spec,
2227 .help = "specify next pattern item",
2228 .next = NEXT(next_item),
2232 .help = "end list of pattern items",
2233 .priv = PRIV_ITEM(END, 0),
2234 .next = NEXT(NEXT_ENTRY(ACTIONS)),
2239 .help = "no-op pattern item",
2240 .priv = PRIV_ITEM(VOID, 0),
2241 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2246 .help = "perform actions when pattern does not match",
2247 .priv = PRIV_ITEM(INVERT, 0),
2248 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2253 .help = "match any protocol for the current layer",
2254 .priv = PRIV_ITEM(ANY, sizeof(struct rte_flow_item_any)),
2255 .next = NEXT(item_any),
2260 .help = "number of layers covered",
2261 .next = NEXT(item_any, NEXT_ENTRY(UNSIGNED), item_param),
2262 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_any, num)),
2266 .help = "match traffic from/to the physical function",
2267 .priv = PRIV_ITEM(PF, 0),
2268 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2273 .help = "match traffic from/to a virtual function ID",
2274 .priv = PRIV_ITEM(VF, sizeof(struct rte_flow_item_vf)),
2275 .next = NEXT(item_vf),
2281 .next = NEXT(item_vf, NEXT_ENTRY(UNSIGNED), item_param),
2282 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_vf, id)),
2286 .help = "match traffic from/to a specific physical port",
2287 .priv = PRIV_ITEM(PHY_PORT,
2288 sizeof(struct rte_flow_item_phy_port)),
2289 .next = NEXT(item_phy_port),
2292 [ITEM_PHY_PORT_INDEX] = {
2294 .help = "physical port index",
2295 .next = NEXT(item_phy_port, NEXT_ENTRY(UNSIGNED), item_param),
2296 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_phy_port, index)),
2300 .help = "match traffic from/to a given DPDK port ID",
2301 .priv = PRIV_ITEM(PORT_ID,
2302 sizeof(struct rte_flow_item_port_id)),
2303 .next = NEXT(item_port_id),
2306 [ITEM_PORT_ID_ID] = {
2308 .help = "DPDK port ID",
2309 .next = NEXT(item_port_id, NEXT_ENTRY(UNSIGNED), item_param),
2310 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port_id, id)),
2314 .help = "match traffic against value set in previously matched rule",
2315 .priv = PRIV_ITEM(MARK, sizeof(struct rte_flow_item_mark)),
2316 .next = NEXT(item_mark),
2321 .help = "Integer value to match against",
2322 .next = NEXT(item_mark, NEXT_ENTRY(UNSIGNED), item_param),
2323 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_mark, id)),
2327 .help = "match an arbitrary byte string",
2328 .priv = PRIV_ITEM(RAW, ITEM_RAW_SIZE),
2329 .next = NEXT(item_raw),
2332 [ITEM_RAW_RELATIVE] = {
2334 .help = "look for pattern after the previous item",
2335 .next = NEXT(item_raw, NEXT_ENTRY(BOOLEAN), item_param),
2336 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
2339 [ITEM_RAW_SEARCH] = {
2341 .help = "search pattern from offset (see also limit)",
2342 .next = NEXT(item_raw, NEXT_ENTRY(BOOLEAN), item_param),
2343 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
2346 [ITEM_RAW_OFFSET] = {
2348 .help = "absolute or relative offset for pattern",
2349 .next = NEXT(item_raw, NEXT_ENTRY(INTEGER), item_param),
2350 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, offset)),
2352 [ITEM_RAW_LIMIT] = {
2354 .help = "search area limit for start of pattern",
2355 .next = NEXT(item_raw, NEXT_ENTRY(UNSIGNED), item_param),
2356 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, limit)),
2358 [ITEM_RAW_PATTERN] = {
2360 .help = "byte string to look for",
2361 .next = NEXT(item_raw,
2363 NEXT_ENTRY(ITEM_PARAM_IS,
2366 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern),
2367 ARGS_ENTRY(struct rte_flow_item_raw, length),
2368 ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw),
2369 ITEM_RAW_PATTERN_SIZE)),
2373 .help = "match Ethernet header",
2374 .priv = PRIV_ITEM(ETH, sizeof(struct rte_flow_item_eth)),
2375 .next = NEXT(item_eth),
2380 .help = "destination MAC",
2381 .next = NEXT(item_eth, NEXT_ENTRY(MAC_ADDR), item_param),
2382 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, dst)),
2386 .help = "source MAC",
2387 .next = NEXT(item_eth, NEXT_ENTRY(MAC_ADDR), item_param),
2388 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, src)),
2392 .help = "EtherType",
2393 .next = NEXT(item_eth, NEXT_ENTRY(UNSIGNED), item_param),
2394 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, type)),
2396 [ITEM_ETH_HAS_VLAN] = {
2398 .help = "packet header contains VLAN",
2399 .next = NEXT(item_eth, NEXT_ENTRY(UNSIGNED), item_param),
2400 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_eth,
2405 .help = "match 802.1Q/ad VLAN tag",
2406 .priv = PRIV_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)),
2407 .next = NEXT(item_vlan),
2412 .help = "tag control information",
2413 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2414 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, tci)),
2418 .help = "priority code point",
2419 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2420 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2425 .help = "drop eligible indicator",
2426 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2427 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2432 .help = "VLAN identifier",
2433 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2434 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2437 [ITEM_VLAN_INNER_TYPE] = {
2438 .name = "inner_type",
2439 .help = "inner EtherType",
2440 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2441 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan,
2444 [ITEM_VLAN_HAS_MORE_VLAN] = {
2445 .name = "has_more_vlan",
2446 .help = "packet header contains another VLAN",
2447 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2448 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vlan,
2453 .help = "match IPv4 header",
2454 .priv = PRIV_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)),
2455 .next = NEXT(item_ipv4),
2460 .help = "type of service",
2461 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2462 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2463 hdr.type_of_service)),
2465 [ITEM_IPV4_FRAGMENT_OFFSET] = {
2466 .name = "fragment_offset",
2467 .help = "fragmentation flags and fragment offset",
2468 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2469 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2470 hdr.fragment_offset)),
2474 .help = "time to live",
2475 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2476 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2479 [ITEM_IPV4_PROTO] = {
2481 .help = "next protocol ID",
2482 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2483 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2484 hdr.next_proto_id)),
2488 .help = "source address",
2489 .next = NEXT(item_ipv4, NEXT_ENTRY(IPV4_ADDR), item_param),
2490 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2495 .help = "destination address",
2496 .next = NEXT(item_ipv4, NEXT_ENTRY(IPV4_ADDR), item_param),
2497 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2502 .help = "match IPv6 header",
2503 .priv = PRIV_ITEM(IPV6, sizeof(struct rte_flow_item_ipv6)),
2504 .next = NEXT(item_ipv6),
2509 .help = "traffic class",
2510 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2511 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2513 "\x0f\xf0\x00\x00")),
2515 [ITEM_IPV6_FLOW] = {
2517 .help = "flow label",
2518 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2519 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2521 "\x00\x0f\xff\xff")),
2523 [ITEM_IPV6_PROTO] = {
2525 .help = "protocol (next header)",
2526 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2527 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2532 .help = "hop limit",
2533 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2534 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2539 .help = "source address",
2540 .next = NEXT(item_ipv6, NEXT_ENTRY(IPV6_ADDR), item_param),
2541 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2546 .help = "destination address",
2547 .next = NEXT(item_ipv6, NEXT_ENTRY(IPV6_ADDR), item_param),
2548 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2551 [ITEM_IPV6_HAS_FRAG_EXT] = {
2552 .name = "has_frag_ext",
2553 .help = "fragment packet attribute",
2554 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2555 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_ipv6,
2560 .help = "match ICMP header",
2561 .priv = PRIV_ITEM(ICMP, sizeof(struct rte_flow_item_icmp)),
2562 .next = NEXT(item_icmp),
2565 [ITEM_ICMP_TYPE] = {
2567 .help = "ICMP packet type",
2568 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2569 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2572 [ITEM_ICMP_CODE] = {
2574 .help = "ICMP packet code",
2575 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2576 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2579 [ITEM_ICMP_IDENT] = {
2581 .help = "ICMP packet identifier",
2582 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2583 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2588 .help = "ICMP packet sequence number",
2589 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2590 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2595 .help = "match UDP header",
2596 .priv = PRIV_ITEM(UDP, sizeof(struct rte_flow_item_udp)),
2597 .next = NEXT(item_udp),
2602 .help = "UDP source port",
2603 .next = NEXT(item_udp, NEXT_ENTRY(UNSIGNED), item_param),
2604 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2609 .help = "UDP destination port",
2610 .next = NEXT(item_udp, NEXT_ENTRY(UNSIGNED), item_param),
2611 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2616 .help = "match TCP header",
2617 .priv = PRIV_ITEM(TCP, sizeof(struct rte_flow_item_tcp)),
2618 .next = NEXT(item_tcp),
2623 .help = "TCP source port",
2624 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2625 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2630 .help = "TCP destination port",
2631 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2632 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2635 [ITEM_TCP_FLAGS] = {
2637 .help = "TCP flags",
2638 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2639 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2644 .help = "match SCTP header",
2645 .priv = PRIV_ITEM(SCTP, sizeof(struct rte_flow_item_sctp)),
2646 .next = NEXT(item_sctp),
2651 .help = "SCTP source port",
2652 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2653 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2658 .help = "SCTP destination port",
2659 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2660 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2665 .help = "validation tag",
2666 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2667 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2670 [ITEM_SCTP_CKSUM] = {
2673 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2674 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2679 .help = "match VXLAN header",
2680 .priv = PRIV_ITEM(VXLAN, sizeof(struct rte_flow_item_vxlan)),
2681 .next = NEXT(item_vxlan),
2684 [ITEM_VXLAN_VNI] = {
2686 .help = "VXLAN identifier",
2687 .next = NEXT(item_vxlan, NEXT_ENTRY(UNSIGNED), item_param),
2688 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan, vni)),
2692 .help = "match E-Tag header",
2693 .priv = PRIV_ITEM(E_TAG, sizeof(struct rte_flow_item_e_tag)),
2694 .next = NEXT(item_e_tag),
2697 [ITEM_E_TAG_GRP_ECID_B] = {
2698 .name = "grp_ecid_b",
2699 .help = "GRP and E-CID base",
2700 .next = NEXT(item_e_tag, NEXT_ENTRY(UNSIGNED), item_param),
2701 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_e_tag,
2707 .help = "match NVGRE header",
2708 .priv = PRIV_ITEM(NVGRE, sizeof(struct rte_flow_item_nvgre)),
2709 .next = NEXT(item_nvgre),
2712 [ITEM_NVGRE_TNI] = {
2714 .help = "virtual subnet ID",
2715 .next = NEXT(item_nvgre, NEXT_ENTRY(UNSIGNED), item_param),
2716 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_nvgre, tni)),
2720 .help = "match MPLS header",
2721 .priv = PRIV_ITEM(MPLS, sizeof(struct rte_flow_item_mpls)),
2722 .next = NEXT(item_mpls),
2725 [ITEM_MPLS_LABEL] = {
2727 .help = "MPLS label",
2728 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2729 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2735 .help = "MPLS Traffic Class",
2736 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2737 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2743 .help = "MPLS Bottom-of-Stack",
2744 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2745 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2751 .help = "match GRE header",
2752 .priv = PRIV_ITEM(GRE, sizeof(struct rte_flow_item_gre)),
2753 .next = NEXT(item_gre),
2756 [ITEM_GRE_PROTO] = {
2758 .help = "GRE protocol type",
2759 .next = NEXT(item_gre, NEXT_ENTRY(UNSIGNED), item_param),
2760 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2763 [ITEM_GRE_C_RSVD0_VER] = {
2764 .name = "c_rsvd0_ver",
2766 "checksum (1b), undefined (1b), key bit (1b),"
2767 " sequence number (1b), reserved 0 (9b),"
2769 .next = NEXT(item_gre, NEXT_ENTRY(UNSIGNED), item_param),
2770 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2773 [ITEM_GRE_C_BIT] = {
2775 .help = "checksum bit (C)",
2776 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2777 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2779 "\x80\x00\x00\x00")),
2781 [ITEM_GRE_S_BIT] = {
2783 .help = "sequence number bit (S)",
2784 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2785 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2787 "\x10\x00\x00\x00")),
2789 [ITEM_GRE_K_BIT] = {
2791 .help = "key bit (K)",
2792 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2793 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2795 "\x20\x00\x00\x00")),
2799 .help = "fuzzy pattern match, expect faster than default",
2800 .priv = PRIV_ITEM(FUZZY,
2801 sizeof(struct rte_flow_item_fuzzy)),
2802 .next = NEXT(item_fuzzy),
2805 [ITEM_FUZZY_THRESH] = {
2807 .help = "match accuracy threshold",
2808 .next = NEXT(item_fuzzy, NEXT_ENTRY(UNSIGNED), item_param),
2809 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_fuzzy,
2814 .help = "match GTP header",
2815 .priv = PRIV_ITEM(GTP, sizeof(struct rte_flow_item_gtp)),
2816 .next = NEXT(item_gtp),
2819 [ITEM_GTP_FLAGS] = {
2820 .name = "v_pt_rsv_flags",
2821 .help = "GTP flags",
2822 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2823 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp,
2826 [ITEM_GTP_MSG_TYPE] = {
2828 .help = "GTP message type",
2829 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2830 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp, msg_type)),
2834 .help = "tunnel endpoint identifier",
2835 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2836 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp, teid)),
2840 .help = "match GTP header",
2841 .priv = PRIV_ITEM(GTPC, sizeof(struct rte_flow_item_gtp)),
2842 .next = NEXT(item_gtp),
2847 .help = "match GTP header",
2848 .priv = PRIV_ITEM(GTPU, sizeof(struct rte_flow_item_gtp)),
2849 .next = NEXT(item_gtp),
2854 .help = "match GENEVE header",
2855 .priv = PRIV_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)),
2856 .next = NEXT(item_geneve),
2859 [ITEM_GENEVE_VNI] = {
2861 .help = "virtual network identifier",
2862 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2863 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve, vni)),
2865 [ITEM_GENEVE_PROTO] = {
2867 .help = "GENEVE protocol type",
2868 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2869 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve,
2872 [ITEM_GENEVE_OPTLEN] = {
2874 .help = "GENEVE options length in dwords",
2875 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2876 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_geneve,
2877 ver_opt_len_o_c_rsvd0,
2880 [ITEM_VXLAN_GPE] = {
2881 .name = "vxlan-gpe",
2882 .help = "match VXLAN-GPE header",
2883 .priv = PRIV_ITEM(VXLAN_GPE,
2884 sizeof(struct rte_flow_item_vxlan_gpe)),
2885 .next = NEXT(item_vxlan_gpe),
2888 [ITEM_VXLAN_GPE_VNI] = {
2890 .help = "VXLAN-GPE identifier",
2891 .next = NEXT(item_vxlan_gpe, NEXT_ENTRY(UNSIGNED), item_param),
2892 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
2895 [ITEM_ARP_ETH_IPV4] = {
2896 .name = "arp_eth_ipv4",
2897 .help = "match ARP header for Ethernet/IPv4",
2898 .priv = PRIV_ITEM(ARP_ETH_IPV4,
2899 sizeof(struct rte_flow_item_arp_eth_ipv4)),
2900 .next = NEXT(item_arp_eth_ipv4),
2903 [ITEM_ARP_ETH_IPV4_SHA] = {
2905 .help = "sender hardware address",
2906 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(MAC_ADDR),
2908 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2911 [ITEM_ARP_ETH_IPV4_SPA] = {
2913 .help = "sender IPv4 address",
2914 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(IPV4_ADDR),
2916 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2919 [ITEM_ARP_ETH_IPV4_THA] = {
2921 .help = "target hardware address",
2922 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(MAC_ADDR),
2924 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2927 [ITEM_ARP_ETH_IPV4_TPA] = {
2929 .help = "target IPv4 address",
2930 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(IPV4_ADDR),
2932 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2937 .help = "match presence of any IPv6 extension header",
2938 .priv = PRIV_ITEM(IPV6_EXT,
2939 sizeof(struct rte_flow_item_ipv6_ext)),
2940 .next = NEXT(item_ipv6_ext),
2943 [ITEM_IPV6_EXT_NEXT_HDR] = {
2945 .help = "next header",
2946 .next = NEXT(item_ipv6_ext, NEXT_ENTRY(UNSIGNED), item_param),
2947 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_ext,
2950 [ITEM_IPV6_FRAG_EXT] = {
2951 .name = "ipv6_frag_ext",
2952 .help = "match presence of IPv6 fragment extension header",
2953 .priv = PRIV_ITEM(IPV6_FRAG_EXT,
2954 sizeof(struct rte_flow_item_ipv6_frag_ext)),
2955 .next = NEXT(item_ipv6_frag_ext),
2958 [ITEM_IPV6_FRAG_EXT_NEXT_HDR] = {
2960 .help = "next header",
2961 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(UNSIGNED),
2963 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ipv6_frag_ext,
2966 [ITEM_IPV6_FRAG_EXT_FRAG_DATA] = {
2967 .name = "frag_data",
2968 .help = "Fragment flags and offset",
2969 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(UNSIGNED),
2971 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_frag_ext,
2976 .help = "match any ICMPv6 header",
2977 .priv = PRIV_ITEM(ICMP6, sizeof(struct rte_flow_item_icmp6)),
2978 .next = NEXT(item_icmp6),
2981 [ITEM_ICMP6_TYPE] = {
2983 .help = "ICMPv6 type",
2984 .next = NEXT(item_icmp6, NEXT_ENTRY(UNSIGNED), item_param),
2985 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
2988 [ITEM_ICMP6_CODE] = {
2990 .help = "ICMPv6 code",
2991 .next = NEXT(item_icmp6, NEXT_ENTRY(UNSIGNED), item_param),
2992 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
2995 [ITEM_ICMP6_ND_NS] = {
2996 .name = "icmp6_nd_ns",
2997 .help = "match ICMPv6 neighbor discovery solicitation",
2998 .priv = PRIV_ITEM(ICMP6_ND_NS,
2999 sizeof(struct rte_flow_item_icmp6_nd_ns)),
3000 .next = NEXT(item_icmp6_nd_ns),
3003 [ITEM_ICMP6_ND_NS_TARGET_ADDR] = {
3004 .name = "target_addr",
3005 .help = "target address",
3006 .next = NEXT(item_icmp6_nd_ns, NEXT_ENTRY(IPV6_ADDR),
3008 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_ns,
3011 [ITEM_ICMP6_ND_NA] = {
3012 .name = "icmp6_nd_na",
3013 .help = "match ICMPv6 neighbor discovery advertisement",
3014 .priv = PRIV_ITEM(ICMP6_ND_NA,
3015 sizeof(struct rte_flow_item_icmp6_nd_na)),
3016 .next = NEXT(item_icmp6_nd_na),
3019 [ITEM_ICMP6_ND_NA_TARGET_ADDR] = {
3020 .name = "target_addr",
3021 .help = "target address",
3022 .next = NEXT(item_icmp6_nd_na, NEXT_ENTRY(IPV6_ADDR),
3024 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_na,
3027 [ITEM_ICMP6_ND_OPT] = {
3028 .name = "icmp6_nd_opt",
3029 .help = "match presence of any ICMPv6 neighbor discovery"
3031 .priv = PRIV_ITEM(ICMP6_ND_OPT,
3032 sizeof(struct rte_flow_item_icmp6_nd_opt)),
3033 .next = NEXT(item_icmp6_nd_opt),
3036 [ITEM_ICMP6_ND_OPT_TYPE] = {
3038 .help = "ND option type",
3039 .next = NEXT(item_icmp6_nd_opt, NEXT_ENTRY(UNSIGNED),
3041 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_opt,
3044 [ITEM_ICMP6_ND_OPT_SLA_ETH] = {
3045 .name = "icmp6_nd_opt_sla_eth",
3046 .help = "match ICMPv6 neighbor discovery source Ethernet"
3047 " link-layer address option",
3049 (ICMP6_ND_OPT_SLA_ETH,
3050 sizeof(struct rte_flow_item_icmp6_nd_opt_sla_eth)),
3051 .next = NEXT(item_icmp6_nd_opt_sla_eth),
3054 [ITEM_ICMP6_ND_OPT_SLA_ETH_SLA] = {
3056 .help = "source Ethernet LLA",
3057 .next = NEXT(item_icmp6_nd_opt_sla_eth, NEXT_ENTRY(MAC_ADDR),
3059 .args = ARGS(ARGS_ENTRY_HTON
3060 (struct rte_flow_item_icmp6_nd_opt_sla_eth, sla)),
3062 [ITEM_ICMP6_ND_OPT_TLA_ETH] = {
3063 .name = "icmp6_nd_opt_tla_eth",
3064 .help = "match ICMPv6 neighbor discovery target Ethernet"
3065 " link-layer address option",
3067 (ICMP6_ND_OPT_TLA_ETH,
3068 sizeof(struct rte_flow_item_icmp6_nd_opt_tla_eth)),
3069 .next = NEXT(item_icmp6_nd_opt_tla_eth),
3072 [ITEM_ICMP6_ND_OPT_TLA_ETH_TLA] = {
3074 .help = "target Ethernet LLA",
3075 .next = NEXT(item_icmp6_nd_opt_tla_eth, NEXT_ENTRY(MAC_ADDR),
3077 .args = ARGS(ARGS_ENTRY_HTON
3078 (struct rte_flow_item_icmp6_nd_opt_tla_eth, tla)),
3082 .help = "match metadata header",
3083 .priv = PRIV_ITEM(META, sizeof(struct rte_flow_item_meta)),
3084 .next = NEXT(item_meta),
3087 [ITEM_META_DATA] = {
3089 .help = "metadata value",
3090 .next = NEXT(item_meta, NEXT_ENTRY(UNSIGNED), item_param),
3091 .args = ARGS(ARGS_ENTRY_MASK(struct rte_flow_item_meta,
3092 data, "\xff\xff\xff\xff")),
3096 .help = "match GRE key",
3097 .priv = PRIV_ITEM(GRE_KEY, sizeof(rte_be32_t)),
3098 .next = NEXT(item_gre_key),
3101 [ITEM_GRE_KEY_VALUE] = {
3103 .help = "key value",
3104 .next = NEXT(item_gre_key, NEXT_ENTRY(UNSIGNED), item_param),
3105 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3109 .help = "match GTP extension header with type 0x85",
3110 .priv = PRIV_ITEM(GTP_PSC,
3111 sizeof(struct rte_flow_item_gtp_psc)),
3112 .next = NEXT(item_gtp_psc),
3115 [ITEM_GTP_PSC_QFI] = {
3117 .help = "QoS flow identifier",
3118 .next = NEXT(item_gtp_psc, NEXT_ENTRY(UNSIGNED), item_param),
3119 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
3122 [ITEM_GTP_PSC_PDU_T] = {
3125 .next = NEXT(item_gtp_psc, NEXT_ENTRY(UNSIGNED), item_param),
3126 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
3131 .help = "match PPPoE session header",
3132 .priv = PRIV_ITEM(PPPOES, sizeof(struct rte_flow_item_pppoe)),
3133 .next = NEXT(item_pppoes),
3138 .help = "match PPPoE discovery header",
3139 .priv = PRIV_ITEM(PPPOED, sizeof(struct rte_flow_item_pppoe)),
3140 .next = NEXT(item_pppoed),
3143 [ITEM_PPPOE_SEID] = {
3145 .help = "session identifier",
3146 .next = NEXT(item_pppoes, NEXT_ENTRY(UNSIGNED), item_param),
3147 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pppoe,
3150 [ITEM_PPPOE_PROTO_ID] = {
3151 .name = "pppoe_proto_id",
3152 .help = "match PPPoE session protocol identifier",
3153 .priv = PRIV_ITEM(PPPOE_PROTO_ID,
3154 sizeof(struct rte_flow_item_pppoe_proto_id)),
3155 .next = NEXT(item_pppoe_proto_id, NEXT_ENTRY(UNSIGNED),
3157 .args = ARGS(ARGS_ENTRY_HTON
3158 (struct rte_flow_item_pppoe_proto_id, proto_id)),
3163 .help = "matches higig2 header",
3164 .priv = PRIV_ITEM(HIGIG2,
3165 sizeof(struct rte_flow_item_higig2_hdr)),
3166 .next = NEXT(item_higig2),
3169 [ITEM_HIGIG2_CLASSIFICATION] = {
3170 .name = "classification",
3171 .help = "matches classification of higig2 header",
3172 .next = NEXT(item_higig2, NEXT_ENTRY(UNSIGNED), item_param),
3173 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
3174 hdr.ppt1.classification)),
3176 [ITEM_HIGIG2_VID] = {
3178 .help = "matches vid of higig2 header",
3179 .next = NEXT(item_higig2, NEXT_ENTRY(UNSIGNED), item_param),
3180 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
3185 .help = "match tag value",
3186 .priv = PRIV_ITEM(TAG, sizeof(struct rte_flow_item_tag)),
3187 .next = NEXT(item_tag),
3192 .help = "tag value to match",
3193 .next = NEXT(item_tag, NEXT_ENTRY(UNSIGNED), item_param),
3194 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, data)),
3196 [ITEM_TAG_INDEX] = {
3198 .help = "index of tag array to match",
3199 .next = NEXT(item_tag, NEXT_ENTRY(UNSIGNED),
3200 NEXT_ENTRY(ITEM_PARAM_IS)),
3201 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, index)),
3203 [ITEM_L2TPV3OIP] = {
3204 .name = "l2tpv3oip",
3205 .help = "match L2TPv3 over IP header",
3206 .priv = PRIV_ITEM(L2TPV3OIP,
3207 sizeof(struct rte_flow_item_l2tpv3oip)),
3208 .next = NEXT(item_l2tpv3oip),
3211 [ITEM_L2TPV3OIP_SESSION_ID] = {
3212 .name = "session_id",
3213 .help = "session identifier",
3214 .next = NEXT(item_l2tpv3oip, NEXT_ENTRY(UNSIGNED), item_param),
3215 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv3oip,
3220 .help = "match ESP header",
3221 .priv = PRIV_ITEM(ESP, sizeof(struct rte_flow_item_esp)),
3222 .next = NEXT(item_esp),
3227 .help = "security policy index",
3228 .next = NEXT(item_esp, NEXT_ENTRY(UNSIGNED), item_param),
3229 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_esp,
3234 .help = "match AH header",
3235 .priv = PRIV_ITEM(AH, sizeof(struct rte_flow_item_ah)),
3236 .next = NEXT(item_ah),
3241 .help = "security parameters index",
3242 .next = NEXT(item_ah, NEXT_ENTRY(UNSIGNED), item_param),
3243 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ah, spi)),
3247 .help = "match pfcp header",
3248 .priv = PRIV_ITEM(PFCP, sizeof(struct rte_flow_item_pfcp)),
3249 .next = NEXT(item_pfcp),
3252 [ITEM_PFCP_S_FIELD] = {
3255 .next = NEXT(item_pfcp, NEXT_ENTRY(UNSIGNED), item_param),
3256 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp,
3259 [ITEM_PFCP_SEID] = {
3261 .help = "session endpoint identifier",
3262 .next = NEXT(item_pfcp, NEXT_ENTRY(UNSIGNED), item_param),
3263 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp, seid)),
3267 .help = "match eCPRI header",
3268 .priv = PRIV_ITEM(ECPRI, sizeof(struct rte_flow_item_ecpri)),
3269 .next = NEXT(item_ecpri),
3272 [ITEM_ECPRI_COMMON] = {
3274 .help = "eCPRI common header",
3275 .next = NEXT(item_ecpri_common),
3277 [ITEM_ECPRI_COMMON_TYPE] = {
3279 .help = "type of common header",
3280 .next = NEXT(item_ecpri_common_type),
3281 .args = ARGS(ARG_ENTRY_HTON(struct rte_flow_item_ecpri)),
3283 [ITEM_ECPRI_COMMON_TYPE_IQ_DATA] = {
3285 .help = "Type #0: IQ Data",
3286 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
3288 .call = parse_vc_item_ecpri_type,
3290 [ITEM_ECPRI_MSG_IQ_DATA_PCID] = {
3292 .help = "Physical Channel ID",
3293 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
3294 ITEM_ECPRI_COMMON, ITEM_NEXT),
3295 NEXT_ENTRY(UNSIGNED), item_param),
3296 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3299 [ITEM_ECPRI_COMMON_TYPE_RTC_CTRL] = {
3301 .help = "Type #2: Real-Time Control Data",
3302 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
3304 .call = parse_vc_item_ecpri_type,
3306 [ITEM_ECPRI_MSG_RTC_CTRL_RTCID] = {
3308 .help = "Real-Time Control Data ID",
3309 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
3310 ITEM_ECPRI_COMMON, ITEM_NEXT),
3311 NEXT_ENTRY(UNSIGNED), item_param),
3312 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3315 [ITEM_ECPRI_COMMON_TYPE_DLY_MSR] = {
3316 .name = "delay_measure",
3317 .help = "Type #5: One-Way Delay Measurement",
3318 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
3320 .call = parse_vc_item_ecpri_type,
3322 [ITEM_ECPRI_MSG_DLY_MSR_MSRID] = {
3324 .help = "Measurement ID",
3325 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
3326 ITEM_ECPRI_COMMON, ITEM_NEXT),
3327 NEXT_ENTRY(UNSIGNED), item_param),
3328 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3331 [ITEM_GENEVE_OPT] = {
3332 .name = "geneve-opt",
3333 .help = "GENEVE header option",
3334 .priv = PRIV_ITEM(GENEVE_OPT,
3335 sizeof(struct rte_flow_item_geneve_opt) +
3336 ITEM_GENEVE_OPT_DATA_SIZE),
3337 .next = NEXT(item_geneve_opt),
3340 [ITEM_GENEVE_OPT_CLASS] = {
3342 .help = "GENEVE option class",
3343 .next = NEXT(item_geneve_opt, NEXT_ENTRY(UNSIGNED), item_param),
3344 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve_opt,
3347 [ITEM_GENEVE_OPT_TYPE] = {
3349 .help = "GENEVE option type",
3350 .next = NEXT(item_geneve_opt, NEXT_ENTRY(UNSIGNED), item_param),
3351 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt,
3354 [ITEM_GENEVE_OPT_LENGTH] = {
3356 .help = "GENEVE option data length (in 32b words)",
3357 .next = NEXT(item_geneve_opt, NEXT_ENTRY(UNSIGNED), item_param),
3358 .args = ARGS(ARGS_ENTRY_BOUNDED(
3359 struct rte_flow_item_geneve_opt, option_len,
3362 [ITEM_GENEVE_OPT_DATA] = {
3364 .help = "GENEVE option data pattern",
3365 .next = NEXT(item_geneve_opt, NEXT_ENTRY(HEX), item_param),
3366 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt, data),
3367 ARGS_ENTRY_ARB(0, 0),
3369 (sizeof(struct rte_flow_item_geneve_opt),
3370 ITEM_GENEVE_OPT_DATA_SIZE)),
3372 /* Validate/create actions. */
3375 .help = "submit a list of associated actions",
3376 .next = NEXT(next_action),
3381 .help = "specify next action",
3382 .next = NEXT(next_action),
3386 .help = "end list of actions",
3387 .priv = PRIV_ACTION(END, 0),
3392 .help = "no-op action",
3393 .priv = PRIV_ACTION(VOID, 0),
3394 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3397 [ACTION_PASSTHRU] = {
3399 .help = "let subsequent rule process matched packets",
3400 .priv = PRIV_ACTION(PASSTHRU, 0),
3401 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3406 .help = "redirect traffic to a given group",
3407 .priv = PRIV_ACTION(JUMP, sizeof(struct rte_flow_action_jump)),
3408 .next = NEXT(action_jump),
3411 [ACTION_JUMP_GROUP] = {
3413 .help = "group to redirect traffic to",
3414 .next = NEXT(action_jump, NEXT_ENTRY(UNSIGNED)),
3415 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump, group)),
3416 .call = parse_vc_conf,
3420 .help = "attach 32 bit value to packets",
3421 .priv = PRIV_ACTION(MARK, sizeof(struct rte_flow_action_mark)),
3422 .next = NEXT(action_mark),
3425 [ACTION_MARK_ID] = {
3427 .help = "32 bit value to return with packets",
3428 .next = NEXT(action_mark, NEXT_ENTRY(UNSIGNED)),
3429 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_mark, id)),
3430 .call = parse_vc_conf,
3434 .help = "flag packets",
3435 .priv = PRIV_ACTION(FLAG, 0),
3436 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3441 .help = "assign packets to a given queue index",
3442 .priv = PRIV_ACTION(QUEUE,
3443 sizeof(struct rte_flow_action_queue)),
3444 .next = NEXT(action_queue),
3447 [ACTION_QUEUE_INDEX] = {
3449 .help = "queue index to use",
3450 .next = NEXT(action_queue, NEXT_ENTRY(UNSIGNED)),
3451 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_queue, index)),
3452 .call = parse_vc_conf,
3456 .help = "drop packets (note: passthru has priority)",
3457 .priv = PRIV_ACTION(DROP, 0),
3458 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3463 .help = "enable counters for this rule",
3464 .priv = PRIV_ACTION(COUNT,
3465 sizeof(struct rte_flow_action_count)),
3466 .next = NEXT(action_count),
3469 [ACTION_COUNT_ID] = {
3470 .name = "identifier",
3471 .help = "counter identifier to use",
3472 .next = NEXT(action_count, NEXT_ENTRY(UNSIGNED)),
3473 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_count, id)),
3474 .call = parse_vc_conf,
3476 [ACTION_COUNT_SHARED] = {
3478 .help = "shared counter",
3479 .next = NEXT(action_count, NEXT_ENTRY(BOOLEAN)),
3480 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_count,
3482 .call = parse_vc_conf,
3486 .help = "spread packets among several queues",
3487 .priv = PRIV_ACTION(RSS, sizeof(struct action_rss_data)),
3488 .next = NEXT(action_rss),
3489 .call = parse_vc_action_rss,
3491 [ACTION_RSS_FUNC] = {
3493 .help = "RSS hash function to apply",
3494 .next = NEXT(action_rss,
3495 NEXT_ENTRY(ACTION_RSS_FUNC_DEFAULT,
3496 ACTION_RSS_FUNC_TOEPLITZ,
3497 ACTION_RSS_FUNC_SIMPLE_XOR,
3498 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ)),
3500 [ACTION_RSS_FUNC_DEFAULT] = {
3502 .help = "default hash function",
3503 .call = parse_vc_action_rss_func,
3505 [ACTION_RSS_FUNC_TOEPLITZ] = {
3507 .help = "Toeplitz hash function",
3508 .call = parse_vc_action_rss_func,
3510 [ACTION_RSS_FUNC_SIMPLE_XOR] = {
3511 .name = "simple_xor",
3512 .help = "simple XOR hash function",
3513 .call = parse_vc_action_rss_func,
3515 [ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ] = {
3516 .name = "symmetric_toeplitz",
3517 .help = "Symmetric Toeplitz hash function",
3518 .call = parse_vc_action_rss_func,
3520 [ACTION_RSS_LEVEL] = {
3522 .help = "encapsulation level for \"types\"",
3523 .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
3524 .args = ARGS(ARGS_ENTRY_ARB
3525 (offsetof(struct action_rss_data, conf) +
3526 offsetof(struct rte_flow_action_rss, level),
3527 sizeof(((struct rte_flow_action_rss *)0)->
3530 [ACTION_RSS_TYPES] = {
3532 .help = "specific RSS hash types",
3533 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)),
3535 [ACTION_RSS_TYPE] = {
3537 .help = "RSS hash type",
3538 .call = parse_vc_action_rss_type,
3539 .comp = comp_vc_action_rss_type,
3541 [ACTION_RSS_KEY] = {
3543 .help = "RSS hash key",
3544 .next = NEXT(action_rss, NEXT_ENTRY(HEX)),
3545 .args = ARGS(ARGS_ENTRY_ARB
3546 (offsetof(struct action_rss_data, conf) +
3547 offsetof(struct rte_flow_action_rss, key),
3548 sizeof(((struct rte_flow_action_rss *)0)->key)),
3550 (offsetof(struct action_rss_data, conf) +
3551 offsetof(struct rte_flow_action_rss, key_len),
3552 sizeof(((struct rte_flow_action_rss *)0)->
3554 ARGS_ENTRY(struct action_rss_data, key)),
3556 [ACTION_RSS_KEY_LEN] = {
3558 .help = "RSS hash key length in bytes",
3559 .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
3560 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
3561 (offsetof(struct action_rss_data, conf) +
3562 offsetof(struct rte_flow_action_rss, key_len),
3563 sizeof(((struct rte_flow_action_rss *)0)->
3566 RSS_HASH_KEY_LENGTH)),
3568 [ACTION_RSS_QUEUES] = {
3570 .help = "queue indices to use",
3571 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_QUEUE)),
3572 .call = parse_vc_conf,
3574 [ACTION_RSS_QUEUE] = {
3576 .help = "queue index",
3577 .call = parse_vc_action_rss_queue,
3578 .comp = comp_vc_action_rss_queue,
3582 .help = "direct traffic to physical function",
3583 .priv = PRIV_ACTION(PF, 0),
3584 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3589 .help = "direct traffic to a virtual function ID",
3590 .priv = PRIV_ACTION(VF, sizeof(struct rte_flow_action_vf)),
3591 .next = NEXT(action_vf),
3594 [ACTION_VF_ORIGINAL] = {
3596 .help = "use original VF ID if possible",
3597 .next = NEXT(action_vf, NEXT_ENTRY(BOOLEAN)),
3598 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_vf,
3600 .call = parse_vc_conf,
3605 .next = NEXT(action_vf, NEXT_ENTRY(UNSIGNED)),
3606 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)),
3607 .call = parse_vc_conf,
3609 [ACTION_PHY_PORT] = {
3611 .help = "direct packets to physical port index",
3612 .priv = PRIV_ACTION(PHY_PORT,
3613 sizeof(struct rte_flow_action_phy_port)),
3614 .next = NEXT(action_phy_port),
3617 [ACTION_PHY_PORT_ORIGINAL] = {
3619 .help = "use original port index if possible",
3620 .next = NEXT(action_phy_port, NEXT_ENTRY(BOOLEAN)),
3621 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_phy_port,
3623 .call = parse_vc_conf,
3625 [ACTION_PHY_PORT_INDEX] = {
3627 .help = "physical port index",
3628 .next = NEXT(action_phy_port, NEXT_ENTRY(UNSIGNED)),
3629 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_phy_port,
3631 .call = parse_vc_conf,
3633 [ACTION_PORT_ID] = {
3635 .help = "direct matching traffic to a given DPDK port ID",
3636 .priv = PRIV_ACTION(PORT_ID,
3637 sizeof(struct rte_flow_action_port_id)),
3638 .next = NEXT(action_port_id),
3641 [ACTION_PORT_ID_ORIGINAL] = {
3643 .help = "use original DPDK port ID if possible",
3644 .next = NEXT(action_port_id, NEXT_ENTRY(BOOLEAN)),
3645 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_port_id,
3647 .call = parse_vc_conf,
3649 [ACTION_PORT_ID_ID] = {
3651 .help = "DPDK port ID",
3652 .next = NEXT(action_port_id, NEXT_ENTRY(UNSIGNED)),
3653 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_port_id, id)),
3654 .call = parse_vc_conf,
3658 .help = "meter the directed packets at given id",
3659 .priv = PRIV_ACTION(METER,
3660 sizeof(struct rte_flow_action_meter)),
3661 .next = NEXT(action_meter),
3664 [ACTION_METER_ID] = {
3666 .help = "meter id to use",
3667 .next = NEXT(action_meter, NEXT_ENTRY(UNSIGNED)),
3668 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter, mtr_id)),
3669 .call = parse_vc_conf,
3671 [ACTION_OF_SET_MPLS_TTL] = {
3672 .name = "of_set_mpls_ttl",
3673 .help = "OpenFlow's OFPAT_SET_MPLS_TTL",
3676 sizeof(struct rte_flow_action_of_set_mpls_ttl)),
3677 .next = NEXT(action_of_set_mpls_ttl),
3680 [ACTION_OF_SET_MPLS_TTL_MPLS_TTL] = {
3683 .next = NEXT(action_of_set_mpls_ttl, NEXT_ENTRY(UNSIGNED)),
3684 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_mpls_ttl,
3686 .call = parse_vc_conf,
3688 [ACTION_OF_DEC_MPLS_TTL] = {
3689 .name = "of_dec_mpls_ttl",
3690 .help = "OpenFlow's OFPAT_DEC_MPLS_TTL",
3691 .priv = PRIV_ACTION(OF_DEC_MPLS_TTL, 0),
3692 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3695 [ACTION_OF_SET_NW_TTL] = {
3696 .name = "of_set_nw_ttl",
3697 .help = "OpenFlow's OFPAT_SET_NW_TTL",
3700 sizeof(struct rte_flow_action_of_set_nw_ttl)),
3701 .next = NEXT(action_of_set_nw_ttl),
3704 [ACTION_OF_SET_NW_TTL_NW_TTL] = {
3707 .next = NEXT(action_of_set_nw_ttl, NEXT_ENTRY(UNSIGNED)),
3708 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_nw_ttl,
3710 .call = parse_vc_conf,
3712 [ACTION_OF_DEC_NW_TTL] = {
3713 .name = "of_dec_nw_ttl",
3714 .help = "OpenFlow's OFPAT_DEC_NW_TTL",
3715 .priv = PRIV_ACTION(OF_DEC_NW_TTL, 0),
3716 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3719 [ACTION_OF_COPY_TTL_OUT] = {
3720 .name = "of_copy_ttl_out",
3721 .help = "OpenFlow's OFPAT_COPY_TTL_OUT",
3722 .priv = PRIV_ACTION(OF_COPY_TTL_OUT, 0),
3723 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3726 [ACTION_OF_COPY_TTL_IN] = {
3727 .name = "of_copy_ttl_in",
3728 .help = "OpenFlow's OFPAT_COPY_TTL_IN",
3729 .priv = PRIV_ACTION(OF_COPY_TTL_IN, 0),
3730 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3733 [ACTION_OF_POP_VLAN] = {
3734 .name = "of_pop_vlan",
3735 .help = "OpenFlow's OFPAT_POP_VLAN",
3736 .priv = PRIV_ACTION(OF_POP_VLAN, 0),
3737 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3740 [ACTION_OF_PUSH_VLAN] = {
3741 .name = "of_push_vlan",
3742 .help = "OpenFlow's OFPAT_PUSH_VLAN",
3745 sizeof(struct rte_flow_action_of_push_vlan)),
3746 .next = NEXT(action_of_push_vlan),
3749 [ACTION_OF_PUSH_VLAN_ETHERTYPE] = {
3750 .name = "ethertype",
3751 .help = "EtherType",
3752 .next = NEXT(action_of_push_vlan, NEXT_ENTRY(UNSIGNED)),
3753 .args = ARGS(ARGS_ENTRY_HTON
3754 (struct rte_flow_action_of_push_vlan,
3756 .call = parse_vc_conf,
3758 [ACTION_OF_SET_VLAN_VID] = {
3759 .name = "of_set_vlan_vid",
3760 .help = "OpenFlow's OFPAT_SET_VLAN_VID",
3763 sizeof(struct rte_flow_action_of_set_vlan_vid)),
3764 .next = NEXT(action_of_set_vlan_vid),
3767 [ACTION_OF_SET_VLAN_VID_VLAN_VID] = {
3770 .next = NEXT(action_of_set_vlan_vid, NEXT_ENTRY(UNSIGNED)),
3771 .args = ARGS(ARGS_ENTRY_HTON
3772 (struct rte_flow_action_of_set_vlan_vid,
3774 .call = parse_vc_conf,
3776 [ACTION_OF_SET_VLAN_PCP] = {
3777 .name = "of_set_vlan_pcp",
3778 .help = "OpenFlow's OFPAT_SET_VLAN_PCP",
3781 sizeof(struct rte_flow_action_of_set_vlan_pcp)),
3782 .next = NEXT(action_of_set_vlan_pcp),
3785 [ACTION_OF_SET_VLAN_PCP_VLAN_PCP] = {
3787 .help = "VLAN priority",
3788 .next = NEXT(action_of_set_vlan_pcp, NEXT_ENTRY(UNSIGNED)),
3789 .args = ARGS(ARGS_ENTRY_HTON
3790 (struct rte_flow_action_of_set_vlan_pcp,
3792 .call = parse_vc_conf,
3794 [ACTION_OF_POP_MPLS] = {
3795 .name = "of_pop_mpls",
3796 .help = "OpenFlow's OFPAT_POP_MPLS",
3797 .priv = PRIV_ACTION(OF_POP_MPLS,
3798 sizeof(struct rte_flow_action_of_pop_mpls)),
3799 .next = NEXT(action_of_pop_mpls),
3802 [ACTION_OF_POP_MPLS_ETHERTYPE] = {
3803 .name = "ethertype",
3804 .help = "EtherType",
3805 .next = NEXT(action_of_pop_mpls, NEXT_ENTRY(UNSIGNED)),
3806 .args = ARGS(ARGS_ENTRY_HTON
3807 (struct rte_flow_action_of_pop_mpls,
3809 .call = parse_vc_conf,
3811 [ACTION_OF_PUSH_MPLS] = {
3812 .name = "of_push_mpls",
3813 .help = "OpenFlow's OFPAT_PUSH_MPLS",
3816 sizeof(struct rte_flow_action_of_push_mpls)),
3817 .next = NEXT(action_of_push_mpls),
3820 [ACTION_OF_PUSH_MPLS_ETHERTYPE] = {
3821 .name = "ethertype",
3822 .help = "EtherType",
3823 .next = NEXT(action_of_push_mpls, NEXT_ENTRY(UNSIGNED)),
3824 .args = ARGS(ARGS_ENTRY_HTON
3825 (struct rte_flow_action_of_push_mpls,
3827 .call = parse_vc_conf,
3829 [ACTION_VXLAN_ENCAP] = {
3830 .name = "vxlan_encap",
3831 .help = "VXLAN encapsulation, uses configuration set by \"set"
3833 .priv = PRIV_ACTION(VXLAN_ENCAP,
3834 sizeof(struct action_vxlan_encap_data)),
3835 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3836 .call = parse_vc_action_vxlan_encap,
3838 [ACTION_VXLAN_DECAP] = {
3839 .name = "vxlan_decap",
3840 .help = "Performs a decapsulation action by stripping all"
3841 " headers of the VXLAN tunnel network overlay from the"
3843 .priv = PRIV_ACTION(VXLAN_DECAP, 0),
3844 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3847 [ACTION_NVGRE_ENCAP] = {
3848 .name = "nvgre_encap",
3849 .help = "NVGRE encapsulation, uses configuration set by \"set"
3851 .priv = PRIV_ACTION(NVGRE_ENCAP,
3852 sizeof(struct action_nvgre_encap_data)),
3853 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3854 .call = parse_vc_action_nvgre_encap,
3856 [ACTION_NVGRE_DECAP] = {
3857 .name = "nvgre_decap",
3858 .help = "Performs a decapsulation action by stripping all"
3859 " headers of the NVGRE tunnel network overlay from the"
3861 .priv = PRIV_ACTION(NVGRE_DECAP, 0),
3862 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3865 [ACTION_L2_ENCAP] = {
3867 .help = "l2 encap, uses configuration set by"
3868 " \"set l2_encap\"",
3869 .priv = PRIV_ACTION(RAW_ENCAP,
3870 sizeof(struct action_raw_encap_data)),
3871 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3872 .call = parse_vc_action_l2_encap,
3874 [ACTION_L2_DECAP] = {
3876 .help = "l2 decap, uses configuration set by"
3877 " \"set l2_decap\"",
3878 .priv = PRIV_ACTION(RAW_DECAP,
3879 sizeof(struct action_raw_decap_data)),
3880 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3881 .call = parse_vc_action_l2_decap,
3883 [ACTION_MPLSOGRE_ENCAP] = {
3884 .name = "mplsogre_encap",
3885 .help = "mplsogre encapsulation, uses configuration set by"
3886 " \"set mplsogre_encap\"",
3887 .priv = PRIV_ACTION(RAW_ENCAP,
3888 sizeof(struct action_raw_encap_data)),
3889 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3890 .call = parse_vc_action_mplsogre_encap,
3892 [ACTION_MPLSOGRE_DECAP] = {
3893 .name = "mplsogre_decap",
3894 .help = "mplsogre decapsulation, uses configuration set by"
3895 " \"set mplsogre_decap\"",
3896 .priv = PRIV_ACTION(RAW_DECAP,
3897 sizeof(struct action_raw_decap_data)),
3898 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3899 .call = parse_vc_action_mplsogre_decap,
3901 [ACTION_MPLSOUDP_ENCAP] = {
3902 .name = "mplsoudp_encap",
3903 .help = "mplsoudp encapsulation, uses configuration set by"
3904 " \"set mplsoudp_encap\"",
3905 .priv = PRIV_ACTION(RAW_ENCAP,
3906 sizeof(struct action_raw_encap_data)),
3907 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3908 .call = parse_vc_action_mplsoudp_encap,
3910 [ACTION_MPLSOUDP_DECAP] = {
3911 .name = "mplsoudp_decap",
3912 .help = "mplsoudp decapsulation, uses configuration set by"
3913 " \"set mplsoudp_decap\"",
3914 .priv = PRIV_ACTION(RAW_DECAP,
3915 sizeof(struct action_raw_decap_data)),
3916 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3917 .call = parse_vc_action_mplsoudp_decap,
3919 [ACTION_SET_IPV4_SRC] = {
3920 .name = "set_ipv4_src",
3921 .help = "Set a new IPv4 source address in the outermost"
3923 .priv = PRIV_ACTION(SET_IPV4_SRC,
3924 sizeof(struct rte_flow_action_set_ipv4)),
3925 .next = NEXT(action_set_ipv4_src),
3928 [ACTION_SET_IPV4_SRC_IPV4_SRC] = {
3929 .name = "ipv4_addr",
3930 .help = "new IPv4 source address to set",
3931 .next = NEXT(action_set_ipv4_src, NEXT_ENTRY(IPV4_ADDR)),
3932 .args = ARGS(ARGS_ENTRY_HTON
3933 (struct rte_flow_action_set_ipv4, ipv4_addr)),
3934 .call = parse_vc_conf,
3936 [ACTION_SET_IPV4_DST] = {
3937 .name = "set_ipv4_dst",
3938 .help = "Set a new IPv4 destination address in the outermost"
3940 .priv = PRIV_ACTION(SET_IPV4_DST,
3941 sizeof(struct rte_flow_action_set_ipv4)),
3942 .next = NEXT(action_set_ipv4_dst),
3945 [ACTION_SET_IPV4_DST_IPV4_DST] = {
3946 .name = "ipv4_addr",
3947 .help = "new IPv4 destination address to set",
3948 .next = NEXT(action_set_ipv4_dst, NEXT_ENTRY(IPV4_ADDR)),
3949 .args = ARGS(ARGS_ENTRY_HTON
3950 (struct rte_flow_action_set_ipv4, ipv4_addr)),
3951 .call = parse_vc_conf,
3953 [ACTION_SET_IPV6_SRC] = {
3954 .name = "set_ipv6_src",
3955 .help = "Set a new IPv6 source address in the outermost"
3957 .priv = PRIV_ACTION(SET_IPV6_SRC,
3958 sizeof(struct rte_flow_action_set_ipv6)),
3959 .next = NEXT(action_set_ipv6_src),
3962 [ACTION_SET_IPV6_SRC_IPV6_SRC] = {
3963 .name = "ipv6_addr",
3964 .help = "new IPv6 source address to set",
3965 .next = NEXT(action_set_ipv6_src, NEXT_ENTRY(IPV6_ADDR)),
3966 .args = ARGS(ARGS_ENTRY_HTON
3967 (struct rte_flow_action_set_ipv6, ipv6_addr)),
3968 .call = parse_vc_conf,
3970 [ACTION_SET_IPV6_DST] = {
3971 .name = "set_ipv6_dst",
3972 .help = "Set a new IPv6 destination address in the outermost"
3974 .priv = PRIV_ACTION(SET_IPV6_DST,
3975 sizeof(struct rte_flow_action_set_ipv6)),
3976 .next = NEXT(action_set_ipv6_dst),
3979 [ACTION_SET_IPV6_DST_IPV6_DST] = {
3980 .name = "ipv6_addr",
3981 .help = "new IPv6 destination address to set",
3982 .next = NEXT(action_set_ipv6_dst, NEXT_ENTRY(IPV6_ADDR)),
3983 .args = ARGS(ARGS_ENTRY_HTON
3984 (struct rte_flow_action_set_ipv6, ipv6_addr)),
3985 .call = parse_vc_conf,
3987 [ACTION_SET_TP_SRC] = {
3988 .name = "set_tp_src",
3989 .help = "set a new source port number in the outermost"
3991 .priv = PRIV_ACTION(SET_TP_SRC,
3992 sizeof(struct rte_flow_action_set_tp)),
3993 .next = NEXT(action_set_tp_src),
3996 [ACTION_SET_TP_SRC_TP_SRC] = {
3998 .help = "new source port number to set",
3999 .next = NEXT(action_set_tp_src, NEXT_ENTRY(UNSIGNED)),
4000 .args = ARGS(ARGS_ENTRY_HTON
4001 (struct rte_flow_action_set_tp, port)),
4002 .call = parse_vc_conf,
4004 [ACTION_SET_TP_DST] = {
4005 .name = "set_tp_dst",
4006 .help = "set a new destination port number in the outermost"
4008 .priv = PRIV_ACTION(SET_TP_DST,
4009 sizeof(struct rte_flow_action_set_tp)),
4010 .next = NEXT(action_set_tp_dst),
4013 [ACTION_SET_TP_DST_TP_DST] = {
4015 .help = "new destination port number to set",
4016 .next = NEXT(action_set_tp_dst, NEXT_ENTRY(UNSIGNED)),
4017 .args = ARGS(ARGS_ENTRY_HTON
4018 (struct rte_flow_action_set_tp, port)),
4019 .call = parse_vc_conf,
4021 [ACTION_MAC_SWAP] = {
4023 .help = "Swap the source and destination MAC addresses"
4024 " in the outermost Ethernet header",
4025 .priv = PRIV_ACTION(MAC_SWAP, 0),
4026 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4029 [ACTION_DEC_TTL] = {
4031 .help = "decrease network TTL if available",
4032 .priv = PRIV_ACTION(DEC_TTL, 0),
4033 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4036 [ACTION_SET_TTL] = {
4038 .help = "set ttl value",
4039 .priv = PRIV_ACTION(SET_TTL,
4040 sizeof(struct rte_flow_action_set_ttl)),
4041 .next = NEXT(action_set_ttl),
4044 [ACTION_SET_TTL_TTL] = {
4045 .name = "ttl_value",
4046 .help = "new ttl value to set",
4047 .next = NEXT(action_set_ttl, NEXT_ENTRY(UNSIGNED)),
4048 .args = ARGS(ARGS_ENTRY_HTON
4049 (struct rte_flow_action_set_ttl, ttl_value)),
4050 .call = parse_vc_conf,
4052 [ACTION_SET_MAC_SRC] = {
4053 .name = "set_mac_src",
4054 .help = "set source mac address",
4055 .priv = PRIV_ACTION(SET_MAC_SRC,
4056 sizeof(struct rte_flow_action_set_mac)),
4057 .next = NEXT(action_set_mac_src),
4060 [ACTION_SET_MAC_SRC_MAC_SRC] = {
4062 .help = "new source mac address",
4063 .next = NEXT(action_set_mac_src, NEXT_ENTRY(MAC_ADDR)),
4064 .args = ARGS(ARGS_ENTRY_HTON
4065 (struct rte_flow_action_set_mac, mac_addr)),
4066 .call = parse_vc_conf,
4068 [ACTION_SET_MAC_DST] = {
4069 .name = "set_mac_dst",
4070 .help = "set destination mac address",
4071 .priv = PRIV_ACTION(SET_MAC_DST,
4072 sizeof(struct rte_flow_action_set_mac)),
4073 .next = NEXT(action_set_mac_dst),
4076 [ACTION_SET_MAC_DST_MAC_DST] = {
4078 .help = "new destination mac address to set",
4079 .next = NEXT(action_set_mac_dst, NEXT_ENTRY(MAC_ADDR)),
4080 .args = ARGS(ARGS_ENTRY_HTON
4081 (struct rte_flow_action_set_mac, mac_addr)),
4082 .call = parse_vc_conf,
4084 [ACTION_INC_TCP_SEQ] = {
4085 .name = "inc_tcp_seq",
4086 .help = "increase TCP sequence number",
4087 .priv = PRIV_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
4088 .next = NEXT(action_inc_tcp_seq),
4091 [ACTION_INC_TCP_SEQ_VALUE] = {
4093 .help = "the value to increase TCP sequence number by",
4094 .next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(UNSIGNED)),
4095 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4096 .call = parse_vc_conf,
4098 [ACTION_DEC_TCP_SEQ] = {
4099 .name = "dec_tcp_seq",
4100 .help = "decrease TCP sequence number",
4101 .priv = PRIV_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
4102 .next = NEXT(action_dec_tcp_seq),
4105 [ACTION_DEC_TCP_SEQ_VALUE] = {
4107 .help = "the value to decrease TCP sequence number by",
4108 .next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(UNSIGNED)),
4109 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4110 .call = parse_vc_conf,
4112 [ACTION_INC_TCP_ACK] = {
4113 .name = "inc_tcp_ack",
4114 .help = "increase TCP acknowledgment number",
4115 .priv = PRIV_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
4116 .next = NEXT(action_inc_tcp_ack),
4119 [ACTION_INC_TCP_ACK_VALUE] = {
4121 .help = "the value to increase TCP acknowledgment number by",
4122 .next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(UNSIGNED)),
4123 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4124 .call = parse_vc_conf,
4126 [ACTION_DEC_TCP_ACK] = {
4127 .name = "dec_tcp_ack",
4128 .help = "decrease TCP acknowledgment number",
4129 .priv = PRIV_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
4130 .next = NEXT(action_dec_tcp_ack),
4133 [ACTION_DEC_TCP_ACK_VALUE] = {
4135 .help = "the value to decrease TCP acknowledgment number by",
4136 .next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(UNSIGNED)),
4137 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4138 .call = parse_vc_conf,
4140 [ACTION_RAW_ENCAP] = {
4141 .name = "raw_encap",
4142 .help = "encapsulation data, defined by set raw_encap",
4143 .priv = PRIV_ACTION(RAW_ENCAP,
4144 sizeof(struct action_raw_encap_data)),
4145 .next = NEXT(action_raw_encap),
4146 .call = parse_vc_action_raw_encap,
4148 [ACTION_RAW_ENCAP_INDEX] = {
4150 .help = "the index of raw_encap_confs",
4151 .next = NEXT(NEXT_ENTRY(ACTION_RAW_ENCAP_INDEX_VALUE)),
4153 [ACTION_RAW_ENCAP_INDEX_VALUE] = {
4156 .help = "unsigned integer value",
4157 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4158 .call = parse_vc_action_raw_encap_index,
4159 .comp = comp_set_raw_index,
4161 [ACTION_RAW_DECAP] = {
4162 .name = "raw_decap",
4163 .help = "decapsulation data, defined by set raw_encap",
4164 .priv = PRIV_ACTION(RAW_DECAP,
4165 sizeof(struct action_raw_decap_data)),
4166 .next = NEXT(action_raw_decap),
4167 .call = parse_vc_action_raw_decap,
4169 [ACTION_RAW_DECAP_INDEX] = {
4171 .help = "the index of raw_encap_confs",
4172 .next = NEXT(NEXT_ENTRY(ACTION_RAW_DECAP_INDEX_VALUE)),
4174 [ACTION_RAW_DECAP_INDEX_VALUE] = {
4177 .help = "unsigned integer value",
4178 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4179 .call = parse_vc_action_raw_decap_index,
4180 .comp = comp_set_raw_index,
4182 [ACTION_MODIFY_FIELD] = {
4183 .name = "modify_field",
4184 .help = "modify destination field with data from source field",
4185 .priv = PRIV_ACTION(MODIFY_FIELD,
4186 sizeof(struct rte_flow_action_modify_field)),
4187 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_OP)),
4190 [ACTION_MODIFY_FIELD_OP] = {
4192 .help = "operation type",
4193 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_TYPE),
4194 NEXT_ENTRY(ACTION_MODIFY_FIELD_OP_VALUE)),
4195 .call = parse_vc_conf,
4197 [ACTION_MODIFY_FIELD_OP_VALUE] = {
4198 .name = "{operation}",
4199 .help = "operation type value",
4200 .call = parse_vc_modify_field_op,
4201 .comp = comp_set_modify_field_op,
4203 [ACTION_MODIFY_FIELD_DST_TYPE] = {
4205 .help = "destination field type",
4206 .next = NEXT(action_modify_field_dst,
4207 NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_TYPE_VALUE)),
4208 .call = parse_vc_conf,
4210 [ACTION_MODIFY_FIELD_DST_TYPE_VALUE] = {
4211 .name = "{dst_type}",
4212 .help = "destination field type value",
4213 .call = parse_vc_modify_field_id,
4214 .comp = comp_set_modify_field_id,
4216 [ACTION_MODIFY_FIELD_DST_LEVEL] = {
4217 .name = "dst_level",
4218 .help = "destination field level",
4219 .next = NEXT(action_modify_field_dst, NEXT_ENTRY(UNSIGNED)),
4220 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4222 .call = parse_vc_conf,
4224 [ACTION_MODIFY_FIELD_DST_OFFSET] = {
4225 .name = "dst_offset",
4226 .help = "destination field bit offset",
4227 .next = NEXT(action_modify_field_dst, NEXT_ENTRY(UNSIGNED)),
4228 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4230 .call = parse_vc_conf,
4232 [ACTION_MODIFY_FIELD_SRC_TYPE] = {
4234 .help = "source field type",
4235 .next = NEXT(action_modify_field_src,
4236 NEXT_ENTRY(ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)),
4237 .call = parse_vc_conf,
4239 [ACTION_MODIFY_FIELD_SRC_TYPE_VALUE] = {
4240 .name = "{src_type}",
4241 .help = "source field type value",
4242 .call = parse_vc_modify_field_id,
4243 .comp = comp_set_modify_field_id,
4245 [ACTION_MODIFY_FIELD_SRC_LEVEL] = {
4246 .name = "src_level",
4247 .help = "source field level",
4248 .next = NEXT(action_modify_field_src, NEXT_ENTRY(UNSIGNED)),
4249 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4251 .call = parse_vc_conf,
4253 [ACTION_MODIFY_FIELD_SRC_OFFSET] = {
4254 .name = "src_offset",
4255 .help = "source field bit offset",
4256 .next = NEXT(action_modify_field_src, NEXT_ENTRY(UNSIGNED)),
4257 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4259 .call = parse_vc_conf,
4261 [ACTION_MODIFY_FIELD_SRC_VALUE] = {
4262 .name = "src_value",
4263 .help = "source immediate value",
4264 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_WIDTH),
4265 NEXT_ENTRY(UNSIGNED)),
4266 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4268 .call = parse_vc_conf,
4270 [ACTION_MODIFY_FIELD_WIDTH] = {
4272 .help = "number of bits to copy",
4273 .next = NEXT(NEXT_ENTRY(ACTION_NEXT),
4274 NEXT_ENTRY(UNSIGNED)),
4275 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4277 .call = parse_vc_conf,
4279 /* Top level command. */
4282 .help = "set raw encap/decap/sample data",
4283 .type = "set raw_encap|raw_decap <index> <pattern>"
4284 " or set sample_actions <index> <action>",
4285 .next = NEXT(NEXT_ENTRY
4288 SET_SAMPLE_ACTIONS)),
4289 .call = parse_set_init,
4291 /* Sub-level commands. */
4293 .name = "raw_encap",
4294 .help = "set raw encap data",
4295 .next = NEXT(next_set_raw),
4296 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4297 (offsetof(struct buffer, port),
4298 sizeof(((struct buffer *)0)->port),
4299 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
4300 .call = parse_set_raw_encap_decap,
4303 .name = "raw_decap",
4304 .help = "set raw decap data",
4305 .next = NEXT(next_set_raw),
4306 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4307 (offsetof(struct buffer, port),
4308 sizeof(((struct buffer *)0)->port),
4309 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
4310 .call = parse_set_raw_encap_decap,
4315 .help = "index of raw_encap/raw_decap data",
4316 .next = NEXT(next_item),
4319 [SET_SAMPLE_INDEX] = {
4322 .help = "index of sample actions",
4323 .next = NEXT(next_action_sample),
4326 [SET_SAMPLE_ACTIONS] = {
4327 .name = "sample_actions",
4328 .help = "set sample actions list",
4329 .next = NEXT(NEXT_ENTRY(SET_SAMPLE_INDEX)),
4330 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4331 (offsetof(struct buffer, port),
4332 sizeof(((struct buffer *)0)->port),
4333 0, RAW_SAMPLE_CONFS_MAX_NUM - 1)),
4334 .call = parse_set_sample_action,
4336 [ACTION_SET_TAG] = {
4339 .priv = PRIV_ACTION(SET_TAG,
4340 sizeof(struct rte_flow_action_set_tag)),
4341 .next = NEXT(action_set_tag),
4344 [ACTION_SET_TAG_INDEX] = {
4346 .help = "index of tag array",
4347 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
4348 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_set_tag, index)),
4349 .call = parse_vc_conf,
4351 [ACTION_SET_TAG_DATA] = {
4353 .help = "tag value",
4354 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
4355 .args = ARGS(ARGS_ENTRY
4356 (struct rte_flow_action_set_tag, data)),
4357 .call = parse_vc_conf,
4359 [ACTION_SET_TAG_MASK] = {
4361 .help = "mask for tag value",
4362 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
4363 .args = ARGS(ARGS_ENTRY
4364 (struct rte_flow_action_set_tag, mask)),
4365 .call = parse_vc_conf,
4367 [ACTION_SET_META] = {
4369 .help = "set metadata",
4370 .priv = PRIV_ACTION(SET_META,
4371 sizeof(struct rte_flow_action_set_meta)),
4372 .next = NEXT(action_set_meta),
4373 .call = parse_vc_action_set_meta,
4375 [ACTION_SET_META_DATA] = {
4377 .help = "metadata value",
4378 .next = NEXT(action_set_meta, NEXT_ENTRY(UNSIGNED)),
4379 .args = ARGS(ARGS_ENTRY
4380 (struct rte_flow_action_set_meta, data)),
4381 .call = parse_vc_conf,
4383 [ACTION_SET_META_MASK] = {
4385 .help = "mask for metadata value",
4386 .next = NEXT(action_set_meta, NEXT_ENTRY(UNSIGNED)),
4387 .args = ARGS(ARGS_ENTRY
4388 (struct rte_flow_action_set_meta, mask)),
4389 .call = parse_vc_conf,
4391 [ACTION_SET_IPV4_DSCP] = {
4392 .name = "set_ipv4_dscp",
4393 .help = "set DSCP value",
4394 .priv = PRIV_ACTION(SET_IPV4_DSCP,
4395 sizeof(struct rte_flow_action_set_dscp)),
4396 .next = NEXT(action_set_ipv4_dscp),
4399 [ACTION_SET_IPV4_DSCP_VALUE] = {
4400 .name = "dscp_value",
4401 .help = "new IPv4 DSCP value to set",
4402 .next = NEXT(action_set_ipv4_dscp, NEXT_ENTRY(UNSIGNED)),
4403 .args = ARGS(ARGS_ENTRY
4404 (struct rte_flow_action_set_dscp, dscp)),
4405 .call = parse_vc_conf,
4407 [ACTION_SET_IPV6_DSCP] = {
4408 .name = "set_ipv6_dscp",
4409 .help = "set DSCP value",
4410 .priv = PRIV_ACTION(SET_IPV6_DSCP,
4411 sizeof(struct rte_flow_action_set_dscp)),
4412 .next = NEXT(action_set_ipv6_dscp),
4415 [ACTION_SET_IPV6_DSCP_VALUE] = {
4416 .name = "dscp_value",
4417 .help = "new IPv6 DSCP value to set",
4418 .next = NEXT(action_set_ipv6_dscp, NEXT_ENTRY(UNSIGNED)),
4419 .args = ARGS(ARGS_ENTRY
4420 (struct rte_flow_action_set_dscp, dscp)),
4421 .call = parse_vc_conf,
4425 .help = "set a specific metadata header",
4426 .next = NEXT(action_age),
4427 .priv = PRIV_ACTION(AGE,
4428 sizeof(struct rte_flow_action_age)),
4431 [ACTION_AGE_TIMEOUT] = {
4433 .help = "flow age timeout value",
4434 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_age,
4436 .next = NEXT(action_age, NEXT_ENTRY(UNSIGNED)),
4437 .call = parse_vc_conf,
4441 .help = "set a sample action",
4442 .next = NEXT(action_sample),
4443 .priv = PRIV_ACTION(SAMPLE,
4444 sizeof(struct action_sample_data)),
4445 .call = parse_vc_action_sample,
4447 [ACTION_SAMPLE_RATIO] = {
4449 .help = "flow sample ratio value",
4450 .next = NEXT(action_sample, NEXT_ENTRY(UNSIGNED)),
4451 .args = ARGS(ARGS_ENTRY_ARB
4452 (offsetof(struct action_sample_data, conf) +
4453 offsetof(struct rte_flow_action_sample, ratio),
4454 sizeof(((struct rte_flow_action_sample *)0)->
4457 [ACTION_SAMPLE_INDEX] = {
4459 .help = "the index of sample actions list",
4460 .next = NEXT(NEXT_ENTRY(ACTION_SAMPLE_INDEX_VALUE)),
4462 [ACTION_SAMPLE_INDEX_VALUE] = {
4465 .help = "unsigned integer value",
4466 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4467 .call = parse_vc_action_sample_index,
4468 .comp = comp_set_sample_index,
4470 /* Shared action destroy arguments. */
4471 [SHARED_ACTION_DESTROY_ID] = {
4472 .name = "action_id",
4473 .help = "specify a shared action id to destroy",
4474 .next = NEXT(next_sa_destroy_attr,
4475 NEXT_ENTRY(SHARED_ACTION_ID)),
4476 .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
4477 args.sa_destroy.action_id)),
4478 .call = parse_sa_destroy,
4480 /* Shared action create arguments. */
4481 [SHARED_ACTION_CREATE_ID] = {
4482 .name = "action_id",
4483 .help = "specify a shared action id to create",
4484 .next = NEXT(next_sa_create_attr,
4485 NEXT_ENTRY(SHARED_ACTION_ID)),
4486 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
4490 .help = "apply shared action by id",
4491 .priv = PRIV_ACTION(SHARED, 0),
4492 .next = NEXT(NEXT_ENTRY(SHARED_ACTION_ID2PTR)),
4493 .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
4496 [SHARED_ACTION_ID2PTR] = {
4497 .name = "{action_id}",
4498 .type = "SHARED_ACTION_ID",
4499 .help = "shared action id",
4500 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4501 .call = parse_sa_id2ptr,
4504 [SHARED_ACTION_INGRESS] = {
4506 .help = "affect rule to ingress",
4507 .next = NEXT(next_sa_create_attr),
4510 [SHARED_ACTION_EGRESS] = {
4512 .help = "affect rule to egress",
4513 .next = NEXT(next_sa_create_attr),
4516 [SHARED_ACTION_TRANSFER] = {
4518 .help = "affect rule to transfer",
4519 .next = NEXT(next_sa_create_attr),
4522 [SHARED_ACTION_SPEC] = {
4524 .help = "specify action to share",
4525 .next = NEXT(next_action),
4529 /** Remove and return last entry from argument stack. */
4530 static const struct arg *
4531 pop_args(struct context *ctx)
4533 return ctx->args_num ? ctx->args[--ctx->args_num] : NULL;
4536 /** Add entry on top of the argument stack. */
4538 push_args(struct context *ctx, const struct arg *arg)
4540 if (ctx->args_num == CTX_STACK_SIZE)
4542 ctx->args[ctx->args_num++] = arg;
4546 /** Spread value into buffer according to bit-mask. */
4548 arg_entry_bf_fill(void *dst, uintmax_t val, const struct arg *arg)
4550 uint32_t i = arg->size;
4558 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
4567 unsigned int shift = 0;
4568 uint8_t *buf = (uint8_t *)dst + arg->offset + (i -= sub);
4570 for (shift = 0; arg->mask[i] >> shift; ++shift) {
4571 if (!(arg->mask[i] & (1 << shift)))
4576 *buf &= ~(1 << shift);
4577 *buf |= (val & 1) << shift;
4585 /** Compare a string with a partial one of a given length. */
4587 strcmp_partial(const char *full, const char *partial, size_t partial_len)
4589 int r = strncmp(full, partial, partial_len);
4593 if (strlen(full) <= partial_len)
4595 return full[partial_len];
4599 * Parse a prefix length and generate a bit-mask.
4601 * Last argument (ctx->args) is retrieved to determine mask size, storage
4602 * location and whether the result must use network byte ordering.
4605 parse_prefix(struct context *ctx, const struct token *token,
4606 const char *str, unsigned int len,
4607 void *buf, unsigned int size)
4609 const struct arg *arg = pop_args(ctx);
4610 static const uint8_t conv[] = "\x00\x80\xc0\xe0\xf0\xf8\xfc\xfe\xff";
4617 /* Argument is expected. */
4621 u = strtoumax(str, &end, 0);
4622 if (errno || (size_t)(end - str) != len)
4627 extra = arg_entry_bf_fill(NULL, 0, arg);
4636 if (!arg_entry_bf_fill(ctx->object, v, arg) ||
4637 !arg_entry_bf_fill(ctx->objmask, -1, arg))
4644 if (bytes > size || bytes + !!extra > size)
4648 buf = (uint8_t *)ctx->object + arg->offset;
4649 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
4651 memset((uint8_t *)buf + size - bytes, 0xff, bytes);
4652 memset(buf, 0x00, size - bytes);
4654 ((uint8_t *)buf)[size - bytes - 1] = conv[extra];
4658 memset(buf, 0xff, bytes);
4659 memset((uint8_t *)buf + bytes, 0x00, size - bytes);
4661 ((uint8_t *)buf)[bytes] = conv[extra];
4664 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
4667 push_args(ctx, arg);
4671 /** Default parsing function for token name matching. */
4673 parse_default(struct context *ctx, const struct token *token,
4674 const char *str, unsigned int len,
4675 void *buf, unsigned int size)
4680 if (strcmp_partial(token->name, str, len))
4685 /** Parse flow command, initialize output buffer for subsequent tokens. */
4687 parse_init(struct context *ctx, const struct token *token,
4688 const char *str, unsigned int len,
4689 void *buf, unsigned int size)
4691 struct buffer *out = buf;
4693 /* Token name must match. */
4694 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4696 /* Nothing else to do if there is no buffer. */
4699 /* Make sure buffer is large enough. */
4700 if (size < sizeof(*out))
4702 /* Initialize buffer. */
4703 memset(out, 0x00, sizeof(*out));
4704 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
4707 ctx->objmask = NULL;
4711 /** Parse tokens for shared action commands. */
4713 parse_sa(struct context *ctx, const struct token *token,
4714 const char *str, unsigned int len,
4715 void *buf, unsigned int size)
4717 struct buffer *out = buf;
4719 /* Token name must match. */
4720 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4722 /* Nothing else to do if there is no buffer. */
4725 if (!out->command) {
4726 if (ctx->curr != SHARED_ACTION)
4728 if (sizeof(*out) > size)
4730 out->command = ctx->curr;
4733 ctx->objmask = NULL;
4734 out->args.vc.data = (uint8_t *)out + size;
4737 switch (ctx->curr) {
4738 case SHARED_ACTION_CREATE:
4739 case SHARED_ACTION_UPDATE:
4740 out->args.vc.actions =
4741 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
4743 out->args.vc.attr.group = UINT32_MAX;
4745 case SHARED_ACTION_QUERY:
4746 out->command = ctx->curr;
4749 ctx->objmask = NULL;
4751 case SHARED_ACTION_EGRESS:
4752 out->args.vc.attr.egress = 1;
4754 case SHARED_ACTION_INGRESS:
4755 out->args.vc.attr.ingress = 1;
4757 case SHARED_ACTION_TRANSFER:
4758 out->args.vc.attr.transfer = 1;
4766 /** Parse tokens for shared action destroy command. */
4768 parse_sa_destroy(struct context *ctx, const struct token *token,
4769 const char *str, unsigned int len,
4770 void *buf, unsigned int size)
4772 struct buffer *out = buf;
4773 uint32_t *action_id;
4775 /* Token name must match. */
4776 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4778 /* Nothing else to do if there is no buffer. */
4781 if (!out->command || out->command == SHARED_ACTION) {
4782 if (ctx->curr != SHARED_ACTION_DESTROY)
4784 if (sizeof(*out) > size)
4786 out->command = ctx->curr;
4789 ctx->objmask = NULL;
4790 out->args.sa_destroy.action_id =
4791 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
4795 action_id = out->args.sa_destroy.action_id
4796 + out->args.sa_destroy.action_id_n++;
4797 if ((uint8_t *)action_id > (uint8_t *)out + size)
4800 ctx->object = action_id;
4801 ctx->objmask = NULL;
4805 /** Parse tokens for validate/create commands. */
4807 parse_vc(struct context *ctx, const struct token *token,
4808 const char *str, unsigned int len,
4809 void *buf, unsigned int size)
4811 struct buffer *out = buf;
4815 /* Token name must match. */
4816 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4818 /* Nothing else to do if there is no buffer. */
4821 if (!out->command) {
4822 if (ctx->curr != VALIDATE && ctx->curr != CREATE)
4824 if (sizeof(*out) > size)
4826 out->command = ctx->curr;
4829 ctx->objmask = NULL;
4830 out->args.vc.data = (uint8_t *)out + size;
4834 switch (ctx->curr) {
4836 ctx->object = &out->args.vc.attr;
4840 ctx->object = &out->args.vc.tunnel_ops;
4843 ctx->objmask = NULL;
4844 switch (ctx->curr) {
4849 out->args.vc.tunnel_ops.enabled = 1;
4850 out->args.vc.tunnel_ops.actions = 1;
4853 out->args.vc.tunnel_ops.enabled = 1;
4854 out->args.vc.tunnel_ops.items = 1;
4857 out->args.vc.attr.ingress = 1;
4860 out->args.vc.attr.egress = 1;
4863 out->args.vc.attr.transfer = 1;
4866 out->args.vc.pattern =
4867 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
4869 ctx->object = out->args.vc.pattern;
4870 ctx->objmask = NULL;
4873 out->args.vc.actions =
4874 (void *)RTE_ALIGN_CEIL((uintptr_t)
4875 (out->args.vc.pattern +
4876 out->args.vc.pattern_n),
4878 ctx->object = out->args.vc.actions;
4879 ctx->objmask = NULL;
4886 if (!out->args.vc.actions) {
4887 const struct parse_item_priv *priv = token->priv;
4888 struct rte_flow_item *item =
4889 out->args.vc.pattern + out->args.vc.pattern_n;
4891 data_size = priv->size * 3; /* spec, last, mask */
4892 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
4893 (out->args.vc.data - data_size),
4895 if ((uint8_t *)item + sizeof(*item) > data)
4897 *item = (struct rte_flow_item){
4900 ++out->args.vc.pattern_n;
4902 ctx->objmask = NULL;
4904 const struct parse_action_priv *priv = token->priv;
4905 struct rte_flow_action *action =
4906 out->args.vc.actions + out->args.vc.actions_n;
4908 data_size = priv->size; /* configuration */
4909 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
4910 (out->args.vc.data - data_size),
4912 if ((uint8_t *)action + sizeof(*action) > data)
4914 *action = (struct rte_flow_action){
4916 .conf = data_size ? data : NULL,
4918 ++out->args.vc.actions_n;
4919 ctx->object = action;
4920 ctx->objmask = NULL;
4922 memset(data, 0, data_size);
4923 out->args.vc.data = data;
4924 ctx->objdata = data_size;
4928 /** Parse pattern item parameter type. */
4930 parse_vc_spec(struct context *ctx, const struct token *token,
4931 const char *str, unsigned int len,
4932 void *buf, unsigned int size)
4934 struct buffer *out = buf;
4935 struct rte_flow_item *item;
4941 /* Token name must match. */
4942 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4944 /* Parse parameter types. */
4945 switch (ctx->curr) {
4946 static const enum index prefix[] = NEXT_ENTRY(PREFIX);
4952 case ITEM_PARAM_SPEC:
4955 case ITEM_PARAM_LAST:
4958 case ITEM_PARAM_PREFIX:
4959 /* Modify next token to expect a prefix. */
4960 if (ctx->next_num < 2)
4962 ctx->next[ctx->next_num - 2] = prefix;
4964 case ITEM_PARAM_MASK:
4970 /* Nothing else to do if there is no buffer. */
4973 if (!out->args.vc.pattern_n)
4975 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
4976 data_size = ctx->objdata / 3; /* spec, last, mask */
4977 /* Point to selected object. */
4978 ctx->object = out->args.vc.data + (data_size * index);
4980 ctx->objmask = out->args.vc.data + (data_size * 2); /* mask */
4981 item->mask = ctx->objmask;
4983 ctx->objmask = NULL;
4984 /* Update relevant item pointer. */
4985 *((const void **[]){ &item->spec, &item->last, &item->mask })[index] =
4990 /** Parse action configuration field. */
4992 parse_vc_conf(struct context *ctx, const struct token *token,
4993 const char *str, unsigned int len,
4994 void *buf, unsigned int size)
4996 struct buffer *out = buf;
4999 /* Token name must match. */
5000 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5002 /* Nothing else to do if there is no buffer. */
5005 /* Point to selected object. */
5006 ctx->object = out->args.vc.data;
5007 ctx->objmask = NULL;
5011 /** Parse eCPRI common header type field. */
5013 parse_vc_item_ecpri_type(struct context *ctx, const struct token *token,
5014 const char *str, unsigned int len,
5015 void *buf, unsigned int size)
5017 struct rte_flow_item_ecpri *ecpri;
5018 struct rte_flow_item_ecpri *ecpri_mask;
5019 struct rte_flow_item *item;
5022 struct buffer *out = buf;
5023 const struct arg *arg;
5026 /* Token name must match. */
5027 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5029 switch (ctx->curr) {
5030 case ITEM_ECPRI_COMMON_TYPE_IQ_DATA:
5031 msg_type = RTE_ECPRI_MSG_TYPE_IQ_DATA;
5033 case ITEM_ECPRI_COMMON_TYPE_RTC_CTRL:
5034 msg_type = RTE_ECPRI_MSG_TYPE_RTC_CTRL;
5036 case ITEM_ECPRI_COMMON_TYPE_DLY_MSR:
5037 msg_type = RTE_ECPRI_MSG_TYPE_DLY_MSR;
5044 arg = pop_args(ctx);
5047 ecpri = (struct rte_flow_item_ecpri *)out->args.vc.data;
5048 ecpri->hdr.common.type = msg_type;
5049 data_size = ctx->objdata / 3; /* spec, last, mask */
5050 ecpri_mask = (struct rte_flow_item_ecpri *)(out->args.vc.data +
5052 ecpri_mask->hdr.common.type = 0xFF;
5054 ecpri->hdr.common.u32 = rte_cpu_to_be_32(ecpri->hdr.common.u32);
5055 ecpri_mask->hdr.common.u32 =
5056 rte_cpu_to_be_32(ecpri_mask->hdr.common.u32);
5058 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
5060 item->mask = ecpri_mask;
5064 /** Parse RSS action. */
5066 parse_vc_action_rss(struct context *ctx, const struct token *token,
5067 const char *str, unsigned int len,
5068 void *buf, unsigned int size)
5070 struct buffer *out = buf;
5071 struct rte_flow_action *action;
5072 struct action_rss_data *action_rss_data;
5076 ret = parse_vc(ctx, token, str, len, buf, size);
5079 /* Nothing else to do if there is no buffer. */
5082 if (!out->args.vc.actions_n)
5084 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5085 /* Point to selected object. */
5086 ctx->object = out->args.vc.data;
5087 ctx->objmask = NULL;
5088 /* Set up default configuration. */
5089 action_rss_data = ctx->object;
5090 *action_rss_data = (struct action_rss_data){
5091 .conf = (struct rte_flow_action_rss){
5092 .func = RTE_ETH_HASH_FUNCTION_DEFAULT,
5096 .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM),
5098 .queue = action_rss_data->queue,
5102 for (i = 0; i < action_rss_data->conf.queue_num; ++i)
5103 action_rss_data->queue[i] = i;
5104 action->conf = &action_rss_data->conf;
5109 * Parse func field for RSS action.
5111 * The RTE_ETH_HASH_FUNCTION_* value to assign is derived from the
5112 * ACTION_RSS_FUNC_* index that called this function.
5115 parse_vc_action_rss_func(struct context *ctx, const struct token *token,
5116 const char *str, unsigned int len,
5117 void *buf, unsigned int size)
5119 struct action_rss_data *action_rss_data;
5120 enum rte_eth_hash_function func;
5124 /* Token name must match. */
5125 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5127 switch (ctx->curr) {
5128 case ACTION_RSS_FUNC_DEFAULT:
5129 func = RTE_ETH_HASH_FUNCTION_DEFAULT;
5131 case ACTION_RSS_FUNC_TOEPLITZ:
5132 func = RTE_ETH_HASH_FUNCTION_TOEPLITZ;
5134 case ACTION_RSS_FUNC_SIMPLE_XOR:
5135 func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
5137 case ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ:
5138 func = RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
5145 action_rss_data = ctx->object;
5146 action_rss_data->conf.func = func;
5151 * Parse type field for RSS action.
5153 * Valid tokens are type field names and the "end" token.
5156 parse_vc_action_rss_type(struct context *ctx, const struct token *token,
5157 const char *str, unsigned int len,
5158 void *buf, unsigned int size)
5160 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE);
5161 struct action_rss_data *action_rss_data;
5167 if (ctx->curr != ACTION_RSS_TYPE)
5169 if (!(ctx->objdata >> 16) && ctx->object) {
5170 action_rss_data = ctx->object;
5171 action_rss_data->conf.types = 0;
5173 if (!strcmp_partial("end", str, len)) {
5174 ctx->objdata &= 0xffff;
5177 for (i = 0; rss_type_table[i].str; ++i)
5178 if (!strcmp_partial(rss_type_table[i].str, str, len))
5180 if (!rss_type_table[i].str)
5182 ctx->objdata = 1 << 16 | (ctx->objdata & 0xffff);
5184 if (ctx->next_num == RTE_DIM(ctx->next))
5186 ctx->next[ctx->next_num++] = next;
5189 action_rss_data = ctx->object;
5190 action_rss_data->conf.types |= rss_type_table[i].rss_type;
5195 * Parse queue field for RSS action.
5197 * Valid tokens are queue indices and the "end" token.
5200 parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
5201 const char *str, unsigned int len,
5202 void *buf, unsigned int size)
5204 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE);
5205 struct action_rss_data *action_rss_data;
5206 const struct arg *arg;
5213 if (ctx->curr != ACTION_RSS_QUEUE)
5215 i = ctx->objdata >> 16;
5216 if (!strcmp_partial("end", str, len)) {
5217 ctx->objdata &= 0xffff;
5220 if (i >= ACTION_RSS_QUEUE_NUM)
5222 arg = ARGS_ENTRY_ARB(offsetof(struct action_rss_data, queue) +
5223 i * sizeof(action_rss_data->queue[i]),
5224 sizeof(action_rss_data->queue[i]));
5225 if (push_args(ctx, arg))
5227 ret = parse_int(ctx, token, str, len, NULL, 0);
5233 ctx->objdata = i << 16 | (ctx->objdata & 0xffff);
5235 if (ctx->next_num == RTE_DIM(ctx->next))
5237 ctx->next[ctx->next_num++] = next;
5241 action_rss_data = ctx->object;
5242 action_rss_data->conf.queue_num = i;
5243 action_rss_data->conf.queue = i ? action_rss_data->queue : NULL;
5247 /** Parse VXLAN encap action. */
5249 parse_vc_action_vxlan_encap(struct context *ctx, const struct token *token,
5250 const char *str, unsigned int len,
5251 void *buf, unsigned int size)
5253 struct buffer *out = buf;
5254 struct rte_flow_action *action;
5255 struct action_vxlan_encap_data *action_vxlan_encap_data;
5258 ret = parse_vc(ctx, token, str, len, buf, size);
5261 /* Nothing else to do if there is no buffer. */
5264 if (!out->args.vc.actions_n)
5266 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5267 /* Point to selected object. */
5268 ctx->object = out->args.vc.data;
5269 ctx->objmask = NULL;
5270 /* Set up default configuration. */
5271 action_vxlan_encap_data = ctx->object;
5272 *action_vxlan_encap_data = (struct action_vxlan_encap_data){
5273 .conf = (struct rte_flow_action_vxlan_encap){
5274 .definition = action_vxlan_encap_data->items,
5278 .type = RTE_FLOW_ITEM_TYPE_ETH,
5279 .spec = &action_vxlan_encap_data->item_eth,
5280 .mask = &rte_flow_item_eth_mask,
5283 .type = RTE_FLOW_ITEM_TYPE_VLAN,
5284 .spec = &action_vxlan_encap_data->item_vlan,
5285 .mask = &rte_flow_item_vlan_mask,
5288 .type = RTE_FLOW_ITEM_TYPE_IPV4,
5289 .spec = &action_vxlan_encap_data->item_ipv4,
5290 .mask = &rte_flow_item_ipv4_mask,
5293 .type = RTE_FLOW_ITEM_TYPE_UDP,
5294 .spec = &action_vxlan_encap_data->item_udp,
5295 .mask = &rte_flow_item_udp_mask,
5298 .type = RTE_FLOW_ITEM_TYPE_VXLAN,
5299 .spec = &action_vxlan_encap_data->item_vxlan,
5300 .mask = &rte_flow_item_vxlan_mask,
5303 .type = RTE_FLOW_ITEM_TYPE_END,
5308 .tci = vxlan_encap_conf.vlan_tci,
5312 .src_addr = vxlan_encap_conf.ipv4_src,
5313 .dst_addr = vxlan_encap_conf.ipv4_dst,
5316 .src_port = vxlan_encap_conf.udp_src,
5317 .dst_port = vxlan_encap_conf.udp_dst,
5319 .item_vxlan.flags = 0,
5321 memcpy(action_vxlan_encap_data->item_eth.dst.addr_bytes,
5322 vxlan_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5323 memcpy(action_vxlan_encap_data->item_eth.src.addr_bytes,
5324 vxlan_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5325 if (!vxlan_encap_conf.select_ipv4) {
5326 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.src_addr,
5327 &vxlan_encap_conf.ipv6_src,
5328 sizeof(vxlan_encap_conf.ipv6_src));
5329 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.dst_addr,
5330 &vxlan_encap_conf.ipv6_dst,
5331 sizeof(vxlan_encap_conf.ipv6_dst));
5332 action_vxlan_encap_data->items[2] = (struct rte_flow_item){
5333 .type = RTE_FLOW_ITEM_TYPE_IPV6,
5334 .spec = &action_vxlan_encap_data->item_ipv6,
5335 .mask = &rte_flow_item_ipv6_mask,
5338 if (!vxlan_encap_conf.select_vlan)
5339 action_vxlan_encap_data->items[1].type =
5340 RTE_FLOW_ITEM_TYPE_VOID;
5341 if (vxlan_encap_conf.select_tos_ttl) {
5342 if (vxlan_encap_conf.select_ipv4) {
5343 static struct rte_flow_item_ipv4 ipv4_mask_tos;
5345 memcpy(&ipv4_mask_tos, &rte_flow_item_ipv4_mask,
5346 sizeof(ipv4_mask_tos));
5347 ipv4_mask_tos.hdr.type_of_service = 0xff;
5348 ipv4_mask_tos.hdr.time_to_live = 0xff;
5349 action_vxlan_encap_data->item_ipv4.hdr.type_of_service =
5350 vxlan_encap_conf.ip_tos;
5351 action_vxlan_encap_data->item_ipv4.hdr.time_to_live =
5352 vxlan_encap_conf.ip_ttl;
5353 action_vxlan_encap_data->items[2].mask =
5356 static struct rte_flow_item_ipv6 ipv6_mask_tos;
5358 memcpy(&ipv6_mask_tos, &rte_flow_item_ipv6_mask,
5359 sizeof(ipv6_mask_tos));
5360 ipv6_mask_tos.hdr.vtc_flow |=
5361 RTE_BE32(0xfful << RTE_IPV6_HDR_TC_SHIFT);
5362 ipv6_mask_tos.hdr.hop_limits = 0xff;
5363 action_vxlan_encap_data->item_ipv6.hdr.vtc_flow |=
5365 ((uint32_t)vxlan_encap_conf.ip_tos <<
5366 RTE_IPV6_HDR_TC_SHIFT);
5367 action_vxlan_encap_data->item_ipv6.hdr.hop_limits =
5368 vxlan_encap_conf.ip_ttl;
5369 action_vxlan_encap_data->items[2].mask =
5373 memcpy(action_vxlan_encap_data->item_vxlan.vni, vxlan_encap_conf.vni,
5374 RTE_DIM(vxlan_encap_conf.vni));
5375 action->conf = &action_vxlan_encap_data->conf;
5379 /** Parse NVGRE encap action. */
5381 parse_vc_action_nvgre_encap(struct context *ctx, const struct token *token,
5382 const char *str, unsigned int len,
5383 void *buf, unsigned int size)
5385 struct buffer *out = buf;
5386 struct rte_flow_action *action;
5387 struct action_nvgre_encap_data *action_nvgre_encap_data;
5390 ret = parse_vc(ctx, token, str, len, buf, size);
5393 /* Nothing else to do if there is no buffer. */
5396 if (!out->args.vc.actions_n)
5398 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5399 /* Point to selected object. */
5400 ctx->object = out->args.vc.data;
5401 ctx->objmask = NULL;
5402 /* Set up default configuration. */
5403 action_nvgre_encap_data = ctx->object;
5404 *action_nvgre_encap_data = (struct action_nvgre_encap_data){
5405 .conf = (struct rte_flow_action_nvgre_encap){
5406 .definition = action_nvgre_encap_data->items,
5410 .type = RTE_FLOW_ITEM_TYPE_ETH,
5411 .spec = &action_nvgre_encap_data->item_eth,
5412 .mask = &rte_flow_item_eth_mask,
5415 .type = RTE_FLOW_ITEM_TYPE_VLAN,
5416 .spec = &action_nvgre_encap_data->item_vlan,
5417 .mask = &rte_flow_item_vlan_mask,
5420 .type = RTE_FLOW_ITEM_TYPE_IPV4,
5421 .spec = &action_nvgre_encap_data->item_ipv4,
5422 .mask = &rte_flow_item_ipv4_mask,
5425 .type = RTE_FLOW_ITEM_TYPE_NVGRE,
5426 .spec = &action_nvgre_encap_data->item_nvgre,
5427 .mask = &rte_flow_item_nvgre_mask,
5430 .type = RTE_FLOW_ITEM_TYPE_END,
5435 .tci = nvgre_encap_conf.vlan_tci,
5439 .src_addr = nvgre_encap_conf.ipv4_src,
5440 .dst_addr = nvgre_encap_conf.ipv4_dst,
5442 .item_nvgre.flow_id = 0,
5444 memcpy(action_nvgre_encap_data->item_eth.dst.addr_bytes,
5445 nvgre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5446 memcpy(action_nvgre_encap_data->item_eth.src.addr_bytes,
5447 nvgre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5448 if (!nvgre_encap_conf.select_ipv4) {
5449 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.src_addr,
5450 &nvgre_encap_conf.ipv6_src,
5451 sizeof(nvgre_encap_conf.ipv6_src));
5452 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.dst_addr,
5453 &nvgre_encap_conf.ipv6_dst,
5454 sizeof(nvgre_encap_conf.ipv6_dst));
5455 action_nvgre_encap_data->items[2] = (struct rte_flow_item){
5456 .type = RTE_FLOW_ITEM_TYPE_IPV6,
5457 .spec = &action_nvgre_encap_data->item_ipv6,
5458 .mask = &rte_flow_item_ipv6_mask,
5461 if (!nvgre_encap_conf.select_vlan)
5462 action_nvgre_encap_data->items[1].type =
5463 RTE_FLOW_ITEM_TYPE_VOID;
5464 memcpy(action_nvgre_encap_data->item_nvgre.tni, nvgre_encap_conf.tni,
5465 RTE_DIM(nvgre_encap_conf.tni));
5466 action->conf = &action_nvgre_encap_data->conf;
5470 /** Parse l2 encap action. */
5472 parse_vc_action_l2_encap(struct context *ctx, const struct token *token,
5473 const char *str, unsigned int len,
5474 void *buf, unsigned int size)
5476 struct buffer *out = buf;
5477 struct rte_flow_action *action;
5478 struct action_raw_encap_data *action_encap_data;
5479 struct rte_flow_item_eth eth = { .type = 0, };
5480 struct rte_flow_item_vlan vlan = {
5481 .tci = mplsoudp_encap_conf.vlan_tci,
5487 ret = parse_vc(ctx, token, str, len, buf, size);
5490 /* Nothing else to do if there is no buffer. */
5493 if (!out->args.vc.actions_n)
5495 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5496 /* Point to selected object. */
5497 ctx->object = out->args.vc.data;
5498 ctx->objmask = NULL;
5499 /* Copy the headers to the buffer. */
5500 action_encap_data = ctx->object;
5501 *action_encap_data = (struct action_raw_encap_data) {
5502 .conf = (struct rte_flow_action_raw_encap){
5503 .data = action_encap_data->data,
5507 header = action_encap_data->data;
5508 if (l2_encap_conf.select_vlan)
5509 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5510 else if (l2_encap_conf.select_ipv4)
5511 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5513 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5514 memcpy(eth.dst.addr_bytes,
5515 l2_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5516 memcpy(eth.src.addr_bytes,
5517 l2_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5518 memcpy(header, ð, sizeof(eth));
5519 header += sizeof(eth);
5520 if (l2_encap_conf.select_vlan) {
5521 if (l2_encap_conf.select_ipv4)
5522 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5524 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5525 memcpy(header, &vlan, sizeof(vlan));
5526 header += sizeof(vlan);
5528 action_encap_data->conf.size = header -
5529 action_encap_data->data;
5530 action->conf = &action_encap_data->conf;
5534 /** Parse l2 decap action. */
5536 parse_vc_action_l2_decap(struct context *ctx, const struct token *token,
5537 const char *str, unsigned int len,
5538 void *buf, unsigned int size)
5540 struct buffer *out = buf;
5541 struct rte_flow_action *action;
5542 struct action_raw_decap_data *action_decap_data;
5543 struct rte_flow_item_eth eth = { .type = 0, };
5544 struct rte_flow_item_vlan vlan = {
5545 .tci = mplsoudp_encap_conf.vlan_tci,
5551 ret = parse_vc(ctx, token, str, len, buf, size);
5554 /* Nothing else to do if there is no buffer. */
5557 if (!out->args.vc.actions_n)
5559 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5560 /* Point to selected object. */
5561 ctx->object = out->args.vc.data;
5562 ctx->objmask = NULL;
5563 /* Copy the headers to the buffer. */
5564 action_decap_data = ctx->object;
5565 *action_decap_data = (struct action_raw_decap_data) {
5566 .conf = (struct rte_flow_action_raw_decap){
5567 .data = action_decap_data->data,
5571 header = action_decap_data->data;
5572 if (l2_decap_conf.select_vlan)
5573 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5574 memcpy(header, ð, sizeof(eth));
5575 header += sizeof(eth);
5576 if (l2_decap_conf.select_vlan) {
5577 memcpy(header, &vlan, sizeof(vlan));
5578 header += sizeof(vlan);
5580 action_decap_data->conf.size = header -
5581 action_decap_data->data;
5582 action->conf = &action_decap_data->conf;
5586 #define ETHER_TYPE_MPLS_UNICAST 0x8847
5588 /** Parse MPLSOGRE encap action. */
5590 parse_vc_action_mplsogre_encap(struct context *ctx, const struct token *token,
5591 const char *str, unsigned int len,
5592 void *buf, unsigned int size)
5594 struct buffer *out = buf;
5595 struct rte_flow_action *action;
5596 struct action_raw_encap_data *action_encap_data;
5597 struct rte_flow_item_eth eth = { .type = 0, };
5598 struct rte_flow_item_vlan vlan = {
5599 .tci = mplsogre_encap_conf.vlan_tci,
5602 struct rte_flow_item_ipv4 ipv4 = {
5604 .src_addr = mplsogre_encap_conf.ipv4_src,
5605 .dst_addr = mplsogre_encap_conf.ipv4_dst,
5606 .next_proto_id = IPPROTO_GRE,
5607 .version_ihl = RTE_IPV4_VHL_DEF,
5608 .time_to_live = IPDEFTTL,
5611 struct rte_flow_item_ipv6 ipv6 = {
5613 .proto = IPPROTO_GRE,
5614 .hop_limits = IPDEFTTL,
5617 struct rte_flow_item_gre gre = {
5618 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
5620 struct rte_flow_item_mpls mpls = {
5626 ret = parse_vc(ctx, token, str, len, buf, size);
5629 /* Nothing else to do if there is no buffer. */
5632 if (!out->args.vc.actions_n)
5634 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5635 /* Point to selected object. */
5636 ctx->object = out->args.vc.data;
5637 ctx->objmask = NULL;
5638 /* Copy the headers to the buffer. */
5639 action_encap_data = ctx->object;
5640 *action_encap_data = (struct action_raw_encap_data) {
5641 .conf = (struct rte_flow_action_raw_encap){
5642 .data = action_encap_data->data,
5647 header = action_encap_data->data;
5648 if (mplsogre_encap_conf.select_vlan)
5649 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5650 else if (mplsogre_encap_conf.select_ipv4)
5651 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5653 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5654 memcpy(eth.dst.addr_bytes,
5655 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5656 memcpy(eth.src.addr_bytes,
5657 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5658 memcpy(header, ð, sizeof(eth));
5659 header += sizeof(eth);
5660 if (mplsogre_encap_conf.select_vlan) {
5661 if (mplsogre_encap_conf.select_ipv4)
5662 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5664 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5665 memcpy(header, &vlan, sizeof(vlan));
5666 header += sizeof(vlan);
5668 if (mplsogre_encap_conf.select_ipv4) {
5669 memcpy(header, &ipv4, sizeof(ipv4));
5670 header += sizeof(ipv4);
5672 memcpy(&ipv6.hdr.src_addr,
5673 &mplsogre_encap_conf.ipv6_src,
5674 sizeof(mplsogre_encap_conf.ipv6_src));
5675 memcpy(&ipv6.hdr.dst_addr,
5676 &mplsogre_encap_conf.ipv6_dst,
5677 sizeof(mplsogre_encap_conf.ipv6_dst));
5678 memcpy(header, &ipv6, sizeof(ipv6));
5679 header += sizeof(ipv6);
5681 memcpy(header, &gre, sizeof(gre));
5682 header += sizeof(gre);
5683 memcpy(mpls.label_tc_s, mplsogre_encap_conf.label,
5684 RTE_DIM(mplsogre_encap_conf.label));
5685 mpls.label_tc_s[2] |= 0x1;
5686 memcpy(header, &mpls, sizeof(mpls));
5687 header += sizeof(mpls);
5688 action_encap_data->conf.size = header -
5689 action_encap_data->data;
5690 action->conf = &action_encap_data->conf;
5694 /** Parse MPLSOGRE decap action. */
5696 parse_vc_action_mplsogre_decap(struct context *ctx, const struct token *token,
5697 const char *str, unsigned int len,
5698 void *buf, unsigned int size)
5700 struct buffer *out = buf;
5701 struct rte_flow_action *action;
5702 struct action_raw_decap_data *action_decap_data;
5703 struct rte_flow_item_eth eth = { .type = 0, };
5704 struct rte_flow_item_vlan vlan = {.tci = 0};
5705 struct rte_flow_item_ipv4 ipv4 = {
5707 .next_proto_id = IPPROTO_GRE,
5710 struct rte_flow_item_ipv6 ipv6 = {
5712 .proto = IPPROTO_GRE,
5715 struct rte_flow_item_gre gre = {
5716 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
5718 struct rte_flow_item_mpls mpls;
5722 ret = parse_vc(ctx, token, str, len, buf, size);
5725 /* Nothing else to do if there is no buffer. */
5728 if (!out->args.vc.actions_n)
5730 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5731 /* Point to selected object. */
5732 ctx->object = out->args.vc.data;
5733 ctx->objmask = NULL;
5734 /* Copy the headers to the buffer. */
5735 action_decap_data = ctx->object;
5736 *action_decap_data = (struct action_raw_decap_data) {
5737 .conf = (struct rte_flow_action_raw_decap){
5738 .data = action_decap_data->data,
5742 header = action_decap_data->data;
5743 if (mplsogre_decap_conf.select_vlan)
5744 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5745 else if (mplsogre_encap_conf.select_ipv4)
5746 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5748 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5749 memcpy(eth.dst.addr_bytes,
5750 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5751 memcpy(eth.src.addr_bytes,
5752 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5753 memcpy(header, ð, sizeof(eth));
5754 header += sizeof(eth);
5755 if (mplsogre_encap_conf.select_vlan) {
5756 if (mplsogre_encap_conf.select_ipv4)
5757 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5759 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5760 memcpy(header, &vlan, sizeof(vlan));
5761 header += sizeof(vlan);
5763 if (mplsogre_encap_conf.select_ipv4) {
5764 memcpy(header, &ipv4, sizeof(ipv4));
5765 header += sizeof(ipv4);
5767 memcpy(header, &ipv6, sizeof(ipv6));
5768 header += sizeof(ipv6);
5770 memcpy(header, &gre, sizeof(gre));
5771 header += sizeof(gre);
5772 memset(&mpls, 0, sizeof(mpls));
5773 memcpy(header, &mpls, sizeof(mpls));
5774 header += sizeof(mpls);
5775 action_decap_data->conf.size = header -
5776 action_decap_data->data;
5777 action->conf = &action_decap_data->conf;
5781 /** Parse MPLSOUDP encap action. */
5783 parse_vc_action_mplsoudp_encap(struct context *ctx, const struct token *token,
5784 const char *str, unsigned int len,
5785 void *buf, unsigned int size)
5787 struct buffer *out = buf;
5788 struct rte_flow_action *action;
5789 struct action_raw_encap_data *action_encap_data;
5790 struct rte_flow_item_eth eth = { .type = 0, };
5791 struct rte_flow_item_vlan vlan = {
5792 .tci = mplsoudp_encap_conf.vlan_tci,
5795 struct rte_flow_item_ipv4 ipv4 = {
5797 .src_addr = mplsoudp_encap_conf.ipv4_src,
5798 .dst_addr = mplsoudp_encap_conf.ipv4_dst,
5799 .next_proto_id = IPPROTO_UDP,
5800 .version_ihl = RTE_IPV4_VHL_DEF,
5801 .time_to_live = IPDEFTTL,
5804 struct rte_flow_item_ipv6 ipv6 = {
5806 .proto = IPPROTO_UDP,
5807 .hop_limits = IPDEFTTL,
5810 struct rte_flow_item_udp udp = {
5812 .src_port = mplsoudp_encap_conf.udp_src,
5813 .dst_port = mplsoudp_encap_conf.udp_dst,
5816 struct rte_flow_item_mpls mpls;
5820 ret = parse_vc(ctx, token, str, len, buf, size);
5823 /* Nothing else to do if there is no buffer. */
5826 if (!out->args.vc.actions_n)
5828 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5829 /* Point to selected object. */
5830 ctx->object = out->args.vc.data;
5831 ctx->objmask = NULL;
5832 /* Copy the headers to the buffer. */
5833 action_encap_data = ctx->object;
5834 *action_encap_data = (struct action_raw_encap_data) {
5835 .conf = (struct rte_flow_action_raw_encap){
5836 .data = action_encap_data->data,
5841 header = action_encap_data->data;
5842 if (mplsoudp_encap_conf.select_vlan)
5843 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5844 else if (mplsoudp_encap_conf.select_ipv4)
5845 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5847 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5848 memcpy(eth.dst.addr_bytes,
5849 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5850 memcpy(eth.src.addr_bytes,
5851 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5852 memcpy(header, ð, sizeof(eth));
5853 header += sizeof(eth);
5854 if (mplsoudp_encap_conf.select_vlan) {
5855 if (mplsoudp_encap_conf.select_ipv4)
5856 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5858 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5859 memcpy(header, &vlan, sizeof(vlan));
5860 header += sizeof(vlan);
5862 if (mplsoudp_encap_conf.select_ipv4) {
5863 memcpy(header, &ipv4, sizeof(ipv4));
5864 header += sizeof(ipv4);
5866 memcpy(&ipv6.hdr.src_addr,
5867 &mplsoudp_encap_conf.ipv6_src,
5868 sizeof(mplsoudp_encap_conf.ipv6_src));
5869 memcpy(&ipv6.hdr.dst_addr,
5870 &mplsoudp_encap_conf.ipv6_dst,
5871 sizeof(mplsoudp_encap_conf.ipv6_dst));
5872 memcpy(header, &ipv6, sizeof(ipv6));
5873 header += sizeof(ipv6);
5875 memcpy(header, &udp, sizeof(udp));
5876 header += sizeof(udp);
5877 memcpy(mpls.label_tc_s, mplsoudp_encap_conf.label,
5878 RTE_DIM(mplsoudp_encap_conf.label));
5879 mpls.label_tc_s[2] |= 0x1;
5880 memcpy(header, &mpls, sizeof(mpls));
5881 header += sizeof(mpls);
5882 action_encap_data->conf.size = header -
5883 action_encap_data->data;
5884 action->conf = &action_encap_data->conf;
5888 /** Parse MPLSOUDP decap action. */
5890 parse_vc_action_mplsoudp_decap(struct context *ctx, const struct token *token,
5891 const char *str, unsigned int len,
5892 void *buf, unsigned int size)
5894 struct buffer *out = buf;
5895 struct rte_flow_action *action;
5896 struct action_raw_decap_data *action_decap_data;
5897 struct rte_flow_item_eth eth = { .type = 0, };
5898 struct rte_flow_item_vlan vlan = {.tci = 0};
5899 struct rte_flow_item_ipv4 ipv4 = {
5901 .next_proto_id = IPPROTO_UDP,
5904 struct rte_flow_item_ipv6 ipv6 = {
5906 .proto = IPPROTO_UDP,
5909 struct rte_flow_item_udp udp = {
5911 .dst_port = rte_cpu_to_be_16(6635),
5914 struct rte_flow_item_mpls mpls;
5918 ret = parse_vc(ctx, token, str, len, buf, size);
5921 /* Nothing else to do if there is no buffer. */
5924 if (!out->args.vc.actions_n)
5926 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5927 /* Point to selected object. */
5928 ctx->object = out->args.vc.data;
5929 ctx->objmask = NULL;
5930 /* Copy the headers to the buffer. */
5931 action_decap_data = ctx->object;
5932 *action_decap_data = (struct action_raw_decap_data) {
5933 .conf = (struct rte_flow_action_raw_decap){
5934 .data = action_decap_data->data,
5938 header = action_decap_data->data;
5939 if (mplsoudp_decap_conf.select_vlan)
5940 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5941 else if (mplsoudp_encap_conf.select_ipv4)
5942 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5944 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5945 memcpy(eth.dst.addr_bytes,
5946 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5947 memcpy(eth.src.addr_bytes,
5948 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5949 memcpy(header, ð, sizeof(eth));
5950 header += sizeof(eth);
5951 if (mplsoudp_encap_conf.select_vlan) {
5952 if (mplsoudp_encap_conf.select_ipv4)
5953 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5955 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5956 memcpy(header, &vlan, sizeof(vlan));
5957 header += sizeof(vlan);
5959 if (mplsoudp_encap_conf.select_ipv4) {
5960 memcpy(header, &ipv4, sizeof(ipv4));
5961 header += sizeof(ipv4);
5963 memcpy(header, &ipv6, sizeof(ipv6));
5964 header += sizeof(ipv6);
5966 memcpy(header, &udp, sizeof(udp));
5967 header += sizeof(udp);
5968 memset(&mpls, 0, sizeof(mpls));
5969 memcpy(header, &mpls, sizeof(mpls));
5970 header += sizeof(mpls);
5971 action_decap_data->conf.size = header -
5972 action_decap_data->data;
5973 action->conf = &action_decap_data->conf;
5978 parse_vc_action_raw_decap_index(struct context *ctx, const struct token *token,
5979 const char *str, unsigned int len, void *buf,
5982 struct action_raw_decap_data *action_raw_decap_data;
5983 struct rte_flow_action *action;
5984 const struct arg *arg;
5985 struct buffer *out = buf;
5989 RTE_SET_USED(token);
5992 arg = ARGS_ENTRY_ARB_BOUNDED
5993 (offsetof(struct action_raw_decap_data, idx),
5994 sizeof(((struct action_raw_decap_data *)0)->idx),
5995 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
5996 if (push_args(ctx, arg))
5998 ret = parse_int(ctx, token, str, len, NULL, 0);
6005 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6006 action_raw_decap_data = ctx->object;
6007 idx = action_raw_decap_data->idx;
6008 action_raw_decap_data->conf.data = raw_decap_confs[idx].data;
6009 action_raw_decap_data->conf.size = raw_decap_confs[idx].size;
6010 action->conf = &action_raw_decap_data->conf;
6016 parse_vc_action_raw_encap_index(struct context *ctx, const struct token *token,
6017 const char *str, unsigned int len, void *buf,
6020 struct action_raw_encap_data *action_raw_encap_data;
6021 struct rte_flow_action *action;
6022 const struct arg *arg;
6023 struct buffer *out = buf;
6027 RTE_SET_USED(token);
6030 if (ctx->curr != ACTION_RAW_ENCAP_INDEX_VALUE)
6032 arg = ARGS_ENTRY_ARB_BOUNDED
6033 (offsetof(struct action_raw_encap_data, idx),
6034 sizeof(((struct action_raw_encap_data *)0)->idx),
6035 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
6036 if (push_args(ctx, arg))
6038 ret = parse_int(ctx, token, str, len, NULL, 0);
6045 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6046 action_raw_encap_data = ctx->object;
6047 idx = action_raw_encap_data->idx;
6048 action_raw_encap_data->conf.data = raw_encap_confs[idx].data;
6049 action_raw_encap_data->conf.size = raw_encap_confs[idx].size;
6050 action_raw_encap_data->conf.preserve = NULL;
6051 action->conf = &action_raw_encap_data->conf;
6056 parse_vc_action_raw_encap(struct context *ctx, const struct token *token,
6057 const char *str, unsigned int len, void *buf,
6060 struct buffer *out = buf;
6061 struct rte_flow_action *action;
6062 struct action_raw_encap_data *action_raw_encap_data = NULL;
6065 ret = parse_vc(ctx, token, str, len, buf, size);
6068 /* Nothing else to do if there is no buffer. */
6071 if (!out->args.vc.actions_n)
6073 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6074 /* Point to selected object. */
6075 ctx->object = out->args.vc.data;
6076 ctx->objmask = NULL;
6077 /* Copy the headers to the buffer. */
6078 action_raw_encap_data = ctx->object;
6079 action_raw_encap_data->conf.data = raw_encap_confs[0].data;
6080 action_raw_encap_data->conf.preserve = NULL;
6081 action_raw_encap_data->conf.size = raw_encap_confs[0].size;
6082 action->conf = &action_raw_encap_data->conf;
6087 parse_vc_action_raw_decap(struct context *ctx, const struct token *token,
6088 const char *str, unsigned int len, void *buf,
6091 struct buffer *out = buf;
6092 struct rte_flow_action *action;
6093 struct action_raw_decap_data *action_raw_decap_data = NULL;
6096 ret = parse_vc(ctx, token, str, len, buf, size);
6099 /* Nothing else to do if there is no buffer. */
6102 if (!out->args.vc.actions_n)
6104 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6105 /* Point to selected object. */
6106 ctx->object = out->args.vc.data;
6107 ctx->objmask = NULL;
6108 /* Copy the headers to the buffer. */
6109 action_raw_decap_data = ctx->object;
6110 action_raw_decap_data->conf.data = raw_decap_confs[0].data;
6111 action_raw_decap_data->conf.size = raw_decap_confs[0].size;
6112 action->conf = &action_raw_decap_data->conf;
6117 parse_vc_action_set_meta(struct context *ctx, const struct token *token,
6118 const char *str, unsigned int len, void *buf,
6123 ret = parse_vc(ctx, token, str, len, buf, size);
6126 ret = rte_flow_dynf_metadata_register();
6133 parse_vc_action_sample(struct context *ctx, const struct token *token,
6134 const char *str, unsigned int len, void *buf,
6137 struct buffer *out = buf;
6138 struct rte_flow_action *action;
6139 struct action_sample_data *action_sample_data = NULL;
6140 static struct rte_flow_action end_action = {
6141 RTE_FLOW_ACTION_TYPE_END, 0
6145 ret = parse_vc(ctx, token, str, len, buf, size);
6148 /* Nothing else to do if there is no buffer. */
6151 if (!out->args.vc.actions_n)
6153 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6154 /* Point to selected object. */
6155 ctx->object = out->args.vc.data;
6156 ctx->objmask = NULL;
6157 /* Copy the headers to the buffer. */
6158 action_sample_data = ctx->object;
6159 action_sample_data->conf.actions = &end_action;
6160 action->conf = &action_sample_data->conf;
6165 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
6166 const char *str, unsigned int len, void *buf,
6169 struct action_sample_data *action_sample_data;
6170 struct rte_flow_action *action;
6171 const struct arg *arg;
6172 struct buffer *out = buf;
6176 RTE_SET_USED(token);
6179 if (ctx->curr != ACTION_SAMPLE_INDEX_VALUE)
6181 arg = ARGS_ENTRY_ARB_BOUNDED
6182 (offsetof(struct action_sample_data, idx),
6183 sizeof(((struct action_sample_data *)0)->idx),
6184 0, RAW_SAMPLE_CONFS_MAX_NUM - 1);
6185 if (push_args(ctx, arg))
6187 ret = parse_int(ctx, token, str, len, NULL, 0);
6194 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6195 action_sample_data = ctx->object;
6196 idx = action_sample_data->idx;
6197 action_sample_data->conf.actions = raw_sample_confs[idx].data;
6198 action->conf = &action_sample_data->conf;
6202 /** Parse operation for modify_field command. */
6204 parse_vc_modify_field_op(struct context *ctx, const struct token *token,
6205 const char *str, unsigned int len, void *buf,
6208 struct rte_flow_action_modify_field *action_modify_field;
6214 if (ctx->curr != ACTION_MODIFY_FIELD_OP_VALUE)
6216 for (i = 0; modify_field_ops[i]; ++i)
6217 if (!strcmp_partial(modify_field_ops[i], str, len))
6219 if (!modify_field_ops[i])
6223 action_modify_field = ctx->object;
6224 action_modify_field->operation = (enum rte_flow_modify_op)i;
6228 /** Parse id for modify_field command. */
6230 parse_vc_modify_field_id(struct context *ctx, const struct token *token,
6231 const char *str, unsigned int len, void *buf,
6234 struct rte_flow_action_modify_field *action_modify_field;
6240 if (ctx->curr != ACTION_MODIFY_FIELD_DST_TYPE_VALUE &&
6241 ctx->curr != ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)
6243 for (i = 0; modify_field_ids[i]; ++i)
6244 if (!strcmp_partial(modify_field_ids[i], str, len))
6246 if (!modify_field_ids[i])
6250 action_modify_field = ctx->object;
6251 if (ctx->curr == ACTION_MODIFY_FIELD_DST_TYPE_VALUE)
6252 action_modify_field->dst.field = (enum rte_flow_field_id)i;
6254 action_modify_field->src.field = (enum rte_flow_field_id)i;
6258 /** Parse tokens for destroy command. */
6260 parse_destroy(struct context *ctx, const struct token *token,
6261 const char *str, unsigned int len,
6262 void *buf, unsigned int size)
6264 struct buffer *out = buf;
6266 /* Token name must match. */
6267 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6269 /* Nothing else to do if there is no buffer. */
6272 if (!out->command) {
6273 if (ctx->curr != DESTROY)
6275 if (sizeof(*out) > size)
6277 out->command = ctx->curr;
6280 ctx->objmask = NULL;
6281 out->args.destroy.rule =
6282 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6286 if (((uint8_t *)(out->args.destroy.rule + out->args.destroy.rule_n) +
6287 sizeof(*out->args.destroy.rule)) > (uint8_t *)out + size)
6290 ctx->object = out->args.destroy.rule + out->args.destroy.rule_n++;
6291 ctx->objmask = NULL;
6295 /** Parse tokens for flush command. */
6297 parse_flush(struct context *ctx, const struct token *token,
6298 const char *str, unsigned int len,
6299 void *buf, unsigned int size)
6301 struct buffer *out = buf;
6303 /* Token name must match. */
6304 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6306 /* Nothing else to do if there is no buffer. */
6309 if (!out->command) {
6310 if (ctx->curr != FLUSH)
6312 if (sizeof(*out) > size)
6314 out->command = ctx->curr;
6317 ctx->objmask = NULL;
6322 /** Parse tokens for dump command. */
6324 parse_dump(struct context *ctx, const struct token *token,
6325 const char *str, unsigned int len,
6326 void *buf, unsigned int size)
6328 struct buffer *out = buf;
6330 /* Token name must match. */
6331 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6333 /* Nothing else to do if there is no buffer. */
6336 if (!out->command) {
6337 if (ctx->curr != DUMP)
6339 if (sizeof(*out) > size)
6341 out->command = ctx->curr;
6344 ctx->objmask = NULL;
6349 /** Parse tokens for query command. */
6351 parse_query(struct context *ctx, const struct token *token,
6352 const char *str, unsigned int len,
6353 void *buf, unsigned int size)
6355 struct buffer *out = buf;
6357 /* Token name must match. */
6358 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6360 /* Nothing else to do if there is no buffer. */
6363 if (!out->command) {
6364 if (ctx->curr != QUERY)
6366 if (sizeof(*out) > size)
6368 out->command = ctx->curr;
6371 ctx->objmask = NULL;
6376 /** Parse action names. */
6378 parse_action(struct context *ctx, const struct token *token,
6379 const char *str, unsigned int len,
6380 void *buf, unsigned int size)
6382 struct buffer *out = buf;
6383 const struct arg *arg = pop_args(ctx);
6387 /* Argument is expected. */
6390 /* Parse action name. */
6391 for (i = 0; next_action[i]; ++i) {
6392 const struct parse_action_priv *priv;
6394 token = &token_list[next_action[i]];
6395 if (strcmp_partial(token->name, str, len))
6401 memcpy((uint8_t *)ctx->object + arg->offset,
6407 push_args(ctx, arg);
6411 /** Parse tokens for list command. */
6413 parse_list(struct context *ctx, const struct token *token,
6414 const char *str, unsigned int len,
6415 void *buf, unsigned int size)
6417 struct buffer *out = buf;
6419 /* Token name must match. */
6420 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6422 /* Nothing else to do if there is no buffer. */
6425 if (!out->command) {
6426 if (ctx->curr != LIST)
6428 if (sizeof(*out) > size)
6430 out->command = ctx->curr;
6433 ctx->objmask = NULL;
6434 out->args.list.group =
6435 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6439 if (((uint8_t *)(out->args.list.group + out->args.list.group_n) +
6440 sizeof(*out->args.list.group)) > (uint8_t *)out + size)
6443 ctx->object = out->args.list.group + out->args.list.group_n++;
6444 ctx->objmask = NULL;
6448 /** Parse tokens for list all aged flows command. */
6450 parse_aged(struct context *ctx, const struct token *token,
6451 const char *str, unsigned int len,
6452 void *buf, unsigned int size)
6454 struct buffer *out = buf;
6456 /* Token name must match. */
6457 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6459 /* Nothing else to do if there is no buffer. */
6462 if (!out->command) {
6463 if (ctx->curr != AGED)
6465 if (sizeof(*out) > size)
6467 out->command = ctx->curr;
6470 ctx->objmask = NULL;
6472 if (ctx->curr == AGED_DESTROY)
6473 out->args.aged.destroy = 1;
6477 /** Parse tokens for isolate command. */
6479 parse_isolate(struct context *ctx, const struct token *token,
6480 const char *str, unsigned int len,
6481 void *buf, unsigned int size)
6483 struct buffer *out = buf;
6485 /* Token name must match. */
6486 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6488 /* Nothing else to do if there is no buffer. */
6491 if (!out->command) {
6492 if (ctx->curr != ISOLATE)
6494 if (sizeof(*out) > size)
6496 out->command = ctx->curr;
6499 ctx->objmask = NULL;
6505 parse_tunnel(struct context *ctx, const struct token *token,
6506 const char *str, unsigned int len,
6507 void *buf, unsigned int size)
6509 struct buffer *out = buf;
6511 /* Token name must match. */
6512 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6514 /* Nothing else to do if there is no buffer. */
6517 if (!out->command) {
6518 if (ctx->curr != TUNNEL)
6520 if (sizeof(*out) > size)
6522 out->command = ctx->curr;
6525 ctx->objmask = NULL;
6527 switch (ctx->curr) {
6531 case TUNNEL_DESTROY:
6533 out->command = ctx->curr;
6535 case TUNNEL_CREATE_TYPE:
6536 case TUNNEL_DESTROY_ID:
6537 ctx->object = &out->args.vc.tunnel_ops;
6546 * Parse signed/unsigned integers 8 to 64-bit long.
6548 * Last argument (ctx->args) is retrieved to determine integer type and
6552 parse_int(struct context *ctx, const struct token *token,
6553 const char *str, unsigned int len,
6554 void *buf, unsigned int size)
6556 const struct arg *arg = pop_args(ctx);
6561 /* Argument is expected. */
6566 (uintmax_t)strtoimax(str, &end, 0) :
6567 strtoumax(str, &end, 0);
6568 if (errno || (size_t)(end - str) != len)
6571 ((arg->sign && ((intmax_t)u < (intmax_t)arg->min ||
6572 (intmax_t)u > (intmax_t)arg->max)) ||
6573 (!arg->sign && (u < arg->min || u > arg->max))))
6578 if (!arg_entry_bf_fill(ctx->object, u, arg) ||
6579 !arg_entry_bf_fill(ctx->objmask, -1, arg))
6583 buf = (uint8_t *)ctx->object + arg->offset;
6585 if (u > RTE_LEN2MASK(size * CHAR_BIT, uint64_t))
6589 case sizeof(uint8_t):
6590 *(uint8_t *)buf = u;
6592 case sizeof(uint16_t):
6593 *(uint16_t *)buf = arg->hton ? rte_cpu_to_be_16(u) : u;
6595 case sizeof(uint8_t [3]):
6596 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
6598 ((uint8_t *)buf)[0] = u;
6599 ((uint8_t *)buf)[1] = u >> 8;
6600 ((uint8_t *)buf)[2] = u >> 16;
6604 ((uint8_t *)buf)[0] = u >> 16;
6605 ((uint8_t *)buf)[1] = u >> 8;
6606 ((uint8_t *)buf)[2] = u;
6608 case sizeof(uint32_t):
6609 *(uint32_t *)buf = arg->hton ? rte_cpu_to_be_32(u) : u;
6611 case sizeof(uint64_t):
6612 *(uint64_t *)buf = arg->hton ? rte_cpu_to_be_64(u) : u;
6617 if (ctx->objmask && buf != (uint8_t *)ctx->objmask + arg->offset) {
6619 buf = (uint8_t *)ctx->objmask + arg->offset;
6624 push_args(ctx, arg);
6631 * Three arguments (ctx->args) are retrieved from the stack to store data,
6632 * its actual length and address (in that order).
6635 parse_string(struct context *ctx, const struct token *token,
6636 const char *str, unsigned int len,
6637 void *buf, unsigned int size)
6639 const struct arg *arg_data = pop_args(ctx);
6640 const struct arg *arg_len = pop_args(ctx);
6641 const struct arg *arg_addr = pop_args(ctx);
6642 char tmp[16]; /* Ought to be enough. */
6645 /* Arguments are expected. */
6649 push_args(ctx, arg_data);
6653 push_args(ctx, arg_len);
6654 push_args(ctx, arg_data);
6657 size = arg_data->size;
6658 /* Bit-mask fill is not supported. */
6659 if (arg_data->mask || size < len)
6663 /* Let parse_int() fill length information first. */
6664 ret = snprintf(tmp, sizeof(tmp), "%u", len);
6667 push_args(ctx, arg_len);
6668 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
6673 buf = (uint8_t *)ctx->object + arg_data->offset;
6674 /* Output buffer is not necessarily NUL-terminated. */
6675 memcpy(buf, str, len);
6676 memset((uint8_t *)buf + len, 0x00, size - len);
6678 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
6679 /* Save address if requested. */
6680 if (arg_addr->size) {
6681 memcpy((uint8_t *)ctx->object + arg_addr->offset,
6683 (uint8_t *)ctx->object + arg_data->offset
6687 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
6689 (uint8_t *)ctx->objmask + arg_data->offset
6695 push_args(ctx, arg_addr);
6696 push_args(ctx, arg_len);
6697 push_args(ctx, arg_data);
6702 parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
6708 /* Check input parameters */
6709 if ((src == NULL) ||
6715 /* Convert chars to bytes */
6716 for (i = 0, len = 0; i < *size; i += 2) {
6717 snprintf(tmp, 3, "%s", src + i);
6718 dst[len++] = strtoul(tmp, &c, 16);
6733 parse_hex(struct context *ctx, const struct token *token,
6734 const char *str, unsigned int len,
6735 void *buf, unsigned int size)
6737 const struct arg *arg_data = pop_args(ctx);
6738 const struct arg *arg_len = pop_args(ctx);
6739 const struct arg *arg_addr = pop_args(ctx);
6740 char tmp[16]; /* Ought to be enough. */
6742 unsigned int hexlen = len;
6743 unsigned int length = 256;
6744 uint8_t hex_tmp[length];
6746 /* Arguments are expected. */
6750 push_args(ctx, arg_data);
6754 push_args(ctx, arg_len);
6755 push_args(ctx, arg_data);
6758 size = arg_data->size;
6759 /* Bit-mask fill is not supported. */
6765 /* translate bytes string to array. */
6766 if (str[0] == '0' && ((str[1] == 'x') ||
6771 if (hexlen > length)
6773 ret = parse_hex_string(str, hex_tmp, &hexlen);
6776 /* Let parse_int() fill length information first. */
6777 ret = snprintf(tmp, sizeof(tmp), "%u", hexlen);
6780 /* Save length if requested. */
6781 if (arg_len->size) {
6782 push_args(ctx, arg_len);
6783 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
6789 buf = (uint8_t *)ctx->object + arg_data->offset;
6790 /* Output buffer is not necessarily NUL-terminated. */
6791 memcpy(buf, hex_tmp, hexlen);
6792 memset((uint8_t *)buf + hexlen, 0x00, size - hexlen);
6794 memset((uint8_t *)ctx->objmask + arg_data->offset,
6796 /* Save address if requested. */
6797 if (arg_addr->size) {
6798 memcpy((uint8_t *)ctx->object + arg_addr->offset,
6800 (uint8_t *)ctx->object + arg_data->offset
6804 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
6806 (uint8_t *)ctx->objmask + arg_data->offset
6812 push_args(ctx, arg_addr);
6813 push_args(ctx, arg_len);
6814 push_args(ctx, arg_data);
6820 * Parse a zero-ended string.
6823 parse_string0(struct context *ctx, const struct token *token __rte_unused,
6824 const char *str, unsigned int len,
6825 void *buf, unsigned int size)
6827 const struct arg *arg_data = pop_args(ctx);
6829 /* Arguments are expected. */
6832 size = arg_data->size;
6833 /* Bit-mask fill is not supported. */
6834 if (arg_data->mask || size < len + 1)
6838 buf = (uint8_t *)ctx->object + arg_data->offset;
6839 strncpy(buf, str, len);
6841 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
6844 push_args(ctx, arg_data);
6849 * Parse a MAC address.
6851 * Last argument (ctx->args) is retrieved to determine storage size and
6855 parse_mac_addr(struct context *ctx, const struct token *token,
6856 const char *str, unsigned int len,
6857 void *buf, unsigned int size)
6859 const struct arg *arg = pop_args(ctx);
6860 struct rte_ether_addr tmp;
6864 /* Argument is expected. */
6868 /* Bit-mask fill is not supported. */
6869 if (arg->mask || size != sizeof(tmp))
6871 /* Only network endian is supported. */
6874 ret = cmdline_parse_etheraddr(NULL, str, &tmp, size);
6875 if (ret < 0 || (unsigned int)ret != len)
6879 buf = (uint8_t *)ctx->object + arg->offset;
6880 memcpy(buf, &tmp, size);
6882 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6885 push_args(ctx, arg);
6890 * Parse an IPv4 address.
6892 * Last argument (ctx->args) is retrieved to determine storage size and
6896 parse_ipv4_addr(struct context *ctx, const struct token *token,
6897 const char *str, unsigned int len,
6898 void *buf, unsigned int size)
6900 const struct arg *arg = pop_args(ctx);
6905 /* Argument is expected. */
6909 /* Bit-mask fill is not supported. */
6910 if (arg->mask || size != sizeof(tmp))
6912 /* Only network endian is supported. */
6915 memcpy(str2, str, len);
6917 ret = inet_pton(AF_INET, str2, &tmp);
6919 /* Attempt integer parsing. */
6920 push_args(ctx, arg);
6921 return parse_int(ctx, token, str, len, buf, size);
6925 buf = (uint8_t *)ctx->object + arg->offset;
6926 memcpy(buf, &tmp, size);
6928 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6931 push_args(ctx, arg);
6936 * Parse an IPv6 address.
6938 * Last argument (ctx->args) is retrieved to determine storage size and
6942 parse_ipv6_addr(struct context *ctx, const struct token *token,
6943 const char *str, unsigned int len,
6944 void *buf, unsigned int size)
6946 const struct arg *arg = pop_args(ctx);
6948 struct in6_addr tmp;
6952 /* Argument is expected. */
6956 /* Bit-mask fill is not supported. */
6957 if (arg->mask || size != sizeof(tmp))
6959 /* Only network endian is supported. */
6962 memcpy(str2, str, len);
6964 ret = inet_pton(AF_INET6, str2, &tmp);
6969 buf = (uint8_t *)ctx->object + arg->offset;
6970 memcpy(buf, &tmp, size);
6972 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6975 push_args(ctx, arg);
6979 /** Boolean values (even indices stand for false). */
6980 static const char *const boolean_name[] = {
6990 * Parse a boolean value.
6992 * Last argument (ctx->args) is retrieved to determine storage size and
6996 parse_boolean(struct context *ctx, const struct token *token,
6997 const char *str, unsigned int len,
6998 void *buf, unsigned int size)
7000 const struct arg *arg = pop_args(ctx);
7004 /* Argument is expected. */
7007 for (i = 0; boolean_name[i]; ++i)
7008 if (!strcmp_partial(boolean_name[i], str, len))
7010 /* Process token as integer. */
7011 if (boolean_name[i])
7012 str = i & 1 ? "1" : "0";
7013 push_args(ctx, arg);
7014 ret = parse_int(ctx, token, str, strlen(str), buf, size);
7015 return ret > 0 ? (int)len : ret;
7018 /** Parse port and update context. */
7020 parse_port(struct context *ctx, const struct token *token,
7021 const char *str, unsigned int len,
7022 void *buf, unsigned int size)
7024 struct buffer *out = &(struct buffer){ .port = 0 };
7032 ctx->objmask = NULL;
7033 size = sizeof(*out);
7035 ret = parse_int(ctx, token, str, len, out, size);
7037 ctx->port = out->port;
7044 parse_sa_id2ptr(struct context *ctx, const struct token *token,
7045 const char *str, unsigned int len,
7046 void *buf, unsigned int size)
7048 struct rte_flow_action *action = ctx->object;
7056 ctx->objmask = NULL;
7057 ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
7058 ctx->object = action;
7059 if (ret != (int)len)
7061 /* set shared action */
7063 action->conf = port_shared_action_get_by_id(ctx->port, id);
7064 ret = (action->conf) ? ret : -1;
7069 /** Parse set command, initialize output buffer for subsequent tokens. */
7071 parse_set_raw_encap_decap(struct context *ctx, const struct token *token,
7072 const char *str, unsigned int len,
7073 void *buf, unsigned int size)
7075 struct buffer *out = buf;
7077 /* Token name must match. */
7078 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7080 /* Nothing else to do if there is no buffer. */
7083 /* Make sure buffer is large enough. */
7084 if (size < sizeof(*out))
7087 ctx->objmask = NULL;
7091 out->command = ctx->curr;
7092 /* For encap/decap we need is pattern */
7093 out->args.vc.pattern = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7098 /** Parse set command, initialize output buffer for subsequent tokens. */
7100 parse_set_sample_action(struct context *ctx, const struct token *token,
7101 const char *str, unsigned int len,
7102 void *buf, unsigned int size)
7104 struct buffer *out = buf;
7106 /* Token name must match. */
7107 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7109 /* Nothing else to do if there is no buffer. */
7112 /* Make sure buffer is large enough. */
7113 if (size < sizeof(*out))
7116 ctx->objmask = NULL;
7120 out->command = ctx->curr;
7121 /* For sampler we need is actions */
7122 out->args.vc.actions = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7128 * Parse set raw_encap/raw_decap command,
7129 * initialize output buffer for subsequent tokens.
7132 parse_set_init(struct context *ctx, const struct token *token,
7133 const char *str, unsigned int len,
7134 void *buf, unsigned int size)
7136 struct buffer *out = buf;
7138 /* Token name must match. */
7139 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7141 /* Nothing else to do if there is no buffer. */
7144 /* Make sure buffer is large enough. */
7145 if (size < sizeof(*out))
7147 /* Initialize buffer. */
7148 memset(out, 0x00, sizeof(*out));
7149 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
7152 ctx->objmask = NULL;
7153 if (!out->command) {
7154 if (ctx->curr != SET)
7156 if (sizeof(*out) > size)
7158 out->command = ctx->curr;
7159 out->args.vc.data = (uint8_t *)out + size;
7160 ctx->object = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7166 /** No completion. */
7168 comp_none(struct context *ctx, const struct token *token,
7169 unsigned int ent, char *buf, unsigned int size)
7179 /** Complete boolean values. */
7181 comp_boolean(struct context *ctx, const struct token *token,
7182 unsigned int ent, char *buf, unsigned int size)
7188 for (i = 0; boolean_name[i]; ++i)
7189 if (buf && i == ent)
7190 return strlcpy(buf, boolean_name[i], size);
7196 /** Complete action names. */
7198 comp_action(struct context *ctx, const struct token *token,
7199 unsigned int ent, char *buf, unsigned int size)
7205 for (i = 0; next_action[i]; ++i)
7206 if (buf && i == ent)
7207 return strlcpy(buf, token_list[next_action[i]].name,
7214 /** Complete available ports. */
7216 comp_port(struct context *ctx, const struct token *token,
7217 unsigned int ent, char *buf, unsigned int size)
7224 RTE_ETH_FOREACH_DEV(p) {
7225 if (buf && i == ent)
7226 return snprintf(buf, size, "%u", p);
7234 /** Complete available rule IDs. */
7236 comp_rule_id(struct context *ctx, const struct token *token,
7237 unsigned int ent, char *buf, unsigned int size)
7240 struct rte_port *port;
7241 struct port_flow *pf;
7244 if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
7245 ctx->port == (portid_t)RTE_PORT_ALL)
7247 port = &ports[ctx->port];
7248 for (pf = port->flow_list; pf != NULL; pf = pf->next) {
7249 if (buf && i == ent)
7250 return snprintf(buf, size, "%u", pf->id);
7258 /** Complete type field for RSS action. */
7260 comp_vc_action_rss_type(struct context *ctx, const struct token *token,
7261 unsigned int ent, char *buf, unsigned int size)
7267 for (i = 0; rss_type_table[i].str; ++i)
7272 return strlcpy(buf, rss_type_table[ent].str, size);
7274 return snprintf(buf, size, "end");
7278 /** Complete queue field for RSS action. */
7280 comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
7281 unsigned int ent, char *buf, unsigned int size)
7288 return snprintf(buf, size, "%u", ent);
7290 return snprintf(buf, size, "end");
7294 /** Complete index number for set raw_encap/raw_decap commands. */
7296 comp_set_raw_index(struct context *ctx, const struct token *token,
7297 unsigned int ent, char *buf, unsigned int size)
7303 RTE_SET_USED(token);
7304 for (idx = 0; idx < RAW_ENCAP_CONFS_MAX_NUM; ++idx) {
7305 if (buf && idx == ent)
7306 return snprintf(buf, size, "%u", idx);
7312 /** Complete index number for set raw_encap/raw_decap commands. */
7314 comp_set_sample_index(struct context *ctx, const struct token *token,
7315 unsigned int ent, char *buf, unsigned int size)
7321 RTE_SET_USED(token);
7322 for (idx = 0; idx < RAW_SAMPLE_CONFS_MAX_NUM; ++idx) {
7323 if (buf && idx == ent)
7324 return snprintf(buf, size, "%u", idx);
7330 /** Complete operation for modify_field command. */
7332 comp_set_modify_field_op(struct context *ctx, const struct token *token,
7333 unsigned int ent, char *buf, unsigned int size)
7338 RTE_SET_USED(token);
7339 for (idx = 0; modify_field_ops[idx]; ++idx)
7344 return strlcpy(buf, modify_field_ops[ent], size);
7348 /** Complete field id for modify_field command. */
7350 comp_set_modify_field_id(struct context *ctx, const struct token *token,
7351 unsigned int ent, char *buf, unsigned int size)
7356 RTE_SET_USED(token);
7357 for (idx = 0; modify_field_ids[idx]; ++idx)
7362 return strlcpy(buf, modify_field_ids[ent], size);
7366 /** Internal context. */
7367 static struct context cmd_flow_context;
7369 /** Global parser instance (cmdline API). */
7370 cmdline_parse_inst_t cmd_flow;
7371 cmdline_parse_inst_t cmd_set_raw;
7373 /** Initialize context. */
7375 cmd_flow_context_init(struct context *ctx)
7377 /* A full memset() is not necessary. */
7387 ctx->objmask = NULL;
7390 /** Parse a token (cmdline API). */
7392 cmd_flow_parse(cmdline_parse_token_hdr_t *hdr, const char *src, void *result,
7395 struct context *ctx = &cmd_flow_context;
7396 const struct token *token;
7397 const enum index *list;
7402 token = &token_list[ctx->curr];
7403 /* Check argument length. */
7406 for (len = 0; src[len]; ++len)
7407 if (src[len] == '#' || isspace(src[len]))
7411 /* Last argument and EOL detection. */
7412 for (i = len; src[i]; ++i)
7413 if (src[i] == '#' || src[i] == '\r' || src[i] == '\n')
7415 else if (!isspace(src[i])) {
7420 if (src[i] == '\r' || src[i] == '\n') {
7424 /* Initialize context if necessary. */
7425 if (!ctx->next_num) {
7428 ctx->next[ctx->next_num++] = token->next[0];
7430 /* Process argument through candidates. */
7431 ctx->prev = ctx->curr;
7432 list = ctx->next[ctx->next_num - 1];
7433 for (i = 0; list[i]; ++i) {
7434 const struct token *next = &token_list[list[i]];
7437 ctx->curr = list[i];
7439 tmp = next->call(ctx, next, src, len, result, size);
7441 tmp = parse_default(ctx, next, src, len, result, size);
7442 if (tmp == -1 || tmp != len)
7450 /* Push subsequent tokens if any. */
7452 for (i = 0; token->next[i]; ++i) {
7453 if (ctx->next_num == RTE_DIM(ctx->next))
7455 ctx->next[ctx->next_num++] = token->next[i];
7457 /* Push arguments if any. */
7459 for (i = 0; token->args[i]; ++i) {
7460 if (ctx->args_num == RTE_DIM(ctx->args))
7462 ctx->args[ctx->args_num++] = token->args[i];
7467 /** Return number of completion entries (cmdline API). */
7469 cmd_flow_complete_get_nb(cmdline_parse_token_hdr_t *hdr)
7471 struct context *ctx = &cmd_flow_context;
7472 const struct token *token = &token_list[ctx->curr];
7473 const enum index *list;
7477 /* Count number of tokens in current list. */
7479 list = ctx->next[ctx->next_num - 1];
7481 list = token->next[0];
7482 for (i = 0; list[i]; ++i)
7487 * If there is a single token, use its completion callback, otherwise
7488 * return the number of entries.
7490 token = &token_list[list[0]];
7491 if (i == 1 && token->comp) {
7492 /* Save index for cmd_flow_get_help(). */
7493 ctx->prev = list[0];
7494 return token->comp(ctx, token, 0, NULL, 0);
7499 /** Return a completion entry (cmdline API). */
7501 cmd_flow_complete_get_elt(cmdline_parse_token_hdr_t *hdr, int index,
7502 char *dst, unsigned int size)
7504 struct context *ctx = &cmd_flow_context;
7505 const struct token *token = &token_list[ctx->curr];
7506 const enum index *list;
7510 /* Count number of tokens in current list. */
7512 list = ctx->next[ctx->next_num - 1];
7514 list = token->next[0];
7515 for (i = 0; list[i]; ++i)
7519 /* If there is a single token, use its completion callback. */
7520 token = &token_list[list[0]];
7521 if (i == 1 && token->comp) {
7522 /* Save index for cmd_flow_get_help(). */
7523 ctx->prev = list[0];
7524 return token->comp(ctx, token, index, dst, size) < 0 ? -1 : 0;
7526 /* Otherwise make sure the index is valid and use defaults. */
7529 token = &token_list[list[index]];
7530 strlcpy(dst, token->name, size);
7531 /* Save index for cmd_flow_get_help(). */
7532 ctx->prev = list[index];
7536 /** Populate help strings for current token (cmdline API). */
7538 cmd_flow_get_help(cmdline_parse_token_hdr_t *hdr, char *dst, unsigned int size)
7540 struct context *ctx = &cmd_flow_context;
7541 const struct token *token = &token_list[ctx->prev];
7546 /* Set token type and update global help with details. */
7547 strlcpy(dst, (token->type ? token->type : "TOKEN"), size);
7549 cmd_flow.help_str = token->help;
7551 cmd_flow.help_str = token->name;
7555 /** Token definition template (cmdline API). */
7556 static struct cmdline_token_hdr cmd_flow_token_hdr = {
7557 .ops = &(struct cmdline_token_ops){
7558 .parse = cmd_flow_parse,
7559 .complete_get_nb = cmd_flow_complete_get_nb,
7560 .complete_get_elt = cmd_flow_complete_get_elt,
7561 .get_help = cmd_flow_get_help,
7566 /** Populate the next dynamic token. */
7568 cmd_flow_tok(cmdline_parse_token_hdr_t **hdr,
7569 cmdline_parse_token_hdr_t **hdr_inst)
7571 struct context *ctx = &cmd_flow_context;
7573 /* Always reinitialize context before requesting the first token. */
7574 if (!(hdr_inst - cmd_flow.tokens))
7575 cmd_flow_context_init(ctx);
7576 /* Return NULL when no more tokens are expected. */
7577 if (!ctx->next_num && ctx->curr) {
7581 /* Determine if command should end here. */
7582 if (ctx->eol && ctx->last && ctx->next_num) {
7583 const enum index *list = ctx->next[ctx->next_num - 1];
7586 for (i = 0; list[i]; ++i) {
7593 *hdr = &cmd_flow_token_hdr;
7596 /** Dispatch parsed buffer to function calls. */
7598 cmd_flow_parsed(const struct buffer *in)
7600 switch (in->command) {
7601 case SHARED_ACTION_CREATE:
7602 port_shared_action_create(
7603 in->port, in->args.vc.attr.group,
7604 &((const struct rte_flow_shared_action_conf) {
7605 .ingress = in->args.vc.attr.ingress,
7606 .egress = in->args.vc.attr.egress,
7607 .transfer = in->args.vc.attr.transfer,
7609 in->args.vc.actions);
7611 case SHARED_ACTION_DESTROY:
7612 port_shared_action_destroy(in->port,
7613 in->args.sa_destroy.action_id_n,
7614 in->args.sa_destroy.action_id);
7616 case SHARED_ACTION_UPDATE:
7617 port_shared_action_update(in->port, in->args.vc.attr.group,
7618 in->args.vc.actions);
7620 case SHARED_ACTION_QUERY:
7621 port_shared_action_query(in->port, in->args.sa.action_id);
7624 port_flow_validate(in->port, &in->args.vc.attr,
7625 in->args.vc.pattern, in->args.vc.actions,
7626 &in->args.vc.tunnel_ops);
7629 port_flow_create(in->port, &in->args.vc.attr,
7630 in->args.vc.pattern, in->args.vc.actions,
7631 &in->args.vc.tunnel_ops);
7634 port_flow_destroy(in->port, in->args.destroy.rule_n,
7635 in->args.destroy.rule);
7638 port_flow_flush(in->port);
7641 port_flow_dump(in->port, in->args.dump.file);
7644 port_flow_query(in->port, in->args.query.rule,
7645 &in->args.query.action);
7648 port_flow_list(in->port, in->args.list.group_n,
7649 in->args.list.group);
7652 port_flow_isolate(in->port, in->args.isolate.set);
7655 port_flow_aged(in->port, in->args.aged.destroy);
7658 port_flow_tunnel_create(in->port, &in->args.vc.tunnel_ops);
7660 case TUNNEL_DESTROY:
7661 port_flow_tunnel_destroy(in->port, in->args.vc.tunnel_ops.id);
7664 port_flow_tunnel_list(in->port);
7671 /** Token generator and output processing callback (cmdline API). */
7673 cmd_flow_cb(void *arg0, struct cmdline *cl, void *arg2)
7676 cmd_flow_tok(arg0, arg2);
7678 cmd_flow_parsed(arg0);
7681 /** Global parser instance (cmdline API). */
7682 cmdline_parse_inst_t cmd_flow = {
7684 .data = NULL, /**< Unused. */
7685 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
7688 }, /**< Tokens are returned by cmd_flow_tok(). */
7691 /** set cmd facility. Reuse cmd flow's infrastructure as much as possible. */
7694 update_fields(uint8_t *buf, struct rte_flow_item *item, uint16_t next_proto)
7696 struct rte_ipv4_hdr *ipv4;
7697 struct rte_ether_hdr *eth;
7698 struct rte_ipv6_hdr *ipv6;
7699 struct rte_vxlan_hdr *vxlan;
7700 struct rte_vxlan_gpe_hdr *gpe;
7701 struct rte_flow_item_nvgre *nvgre;
7702 uint32_t ipv6_vtc_flow;
7704 switch (item->type) {
7705 case RTE_FLOW_ITEM_TYPE_ETH:
7706 eth = (struct rte_ether_hdr *)buf;
7708 eth->ether_type = rte_cpu_to_be_16(next_proto);
7710 case RTE_FLOW_ITEM_TYPE_IPV4:
7711 ipv4 = (struct rte_ipv4_hdr *)buf;
7712 ipv4->version_ihl = 0x45;
7713 if (next_proto && ipv4->next_proto_id == 0)
7714 ipv4->next_proto_id = (uint8_t)next_proto;
7716 case RTE_FLOW_ITEM_TYPE_IPV6:
7717 ipv6 = (struct rte_ipv6_hdr *)buf;
7718 if (next_proto && ipv6->proto == 0)
7719 ipv6->proto = (uint8_t)next_proto;
7720 ipv6_vtc_flow = rte_be_to_cpu_32(ipv6->vtc_flow);
7721 ipv6_vtc_flow &= 0x0FFFFFFF; /*< reset version bits. */
7722 ipv6_vtc_flow |= 0x60000000; /*< set ipv6 version. */
7723 ipv6->vtc_flow = rte_cpu_to_be_32(ipv6_vtc_flow);
7725 case RTE_FLOW_ITEM_TYPE_VXLAN:
7726 vxlan = (struct rte_vxlan_hdr *)buf;
7727 vxlan->vx_flags = 0x08;
7729 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
7730 gpe = (struct rte_vxlan_gpe_hdr *)buf;
7731 gpe->vx_flags = 0x0C;
7733 case RTE_FLOW_ITEM_TYPE_NVGRE:
7734 nvgre = (struct rte_flow_item_nvgre *)buf;
7735 nvgre->protocol = rte_cpu_to_be_16(0x6558);
7736 nvgre->c_k_s_rsvd0_ver = rte_cpu_to_be_16(0x2000);
7743 /** Helper of get item's default mask. */
7745 flow_item_default_mask(const struct rte_flow_item *item)
7747 const void *mask = NULL;
7748 static rte_be32_t gre_key_default_mask = RTE_BE32(UINT32_MAX);
7750 switch (item->type) {
7751 case RTE_FLOW_ITEM_TYPE_ANY:
7752 mask = &rte_flow_item_any_mask;
7754 case RTE_FLOW_ITEM_TYPE_VF:
7755 mask = &rte_flow_item_vf_mask;
7757 case RTE_FLOW_ITEM_TYPE_PORT_ID:
7758 mask = &rte_flow_item_port_id_mask;
7760 case RTE_FLOW_ITEM_TYPE_RAW:
7761 mask = &rte_flow_item_raw_mask;
7763 case RTE_FLOW_ITEM_TYPE_ETH:
7764 mask = &rte_flow_item_eth_mask;
7766 case RTE_FLOW_ITEM_TYPE_VLAN:
7767 mask = &rte_flow_item_vlan_mask;
7769 case RTE_FLOW_ITEM_TYPE_IPV4:
7770 mask = &rte_flow_item_ipv4_mask;
7772 case RTE_FLOW_ITEM_TYPE_IPV6:
7773 mask = &rte_flow_item_ipv6_mask;
7775 case RTE_FLOW_ITEM_TYPE_ICMP:
7776 mask = &rte_flow_item_icmp_mask;
7778 case RTE_FLOW_ITEM_TYPE_UDP:
7779 mask = &rte_flow_item_udp_mask;
7781 case RTE_FLOW_ITEM_TYPE_TCP:
7782 mask = &rte_flow_item_tcp_mask;
7784 case RTE_FLOW_ITEM_TYPE_SCTP:
7785 mask = &rte_flow_item_sctp_mask;
7787 case RTE_FLOW_ITEM_TYPE_VXLAN:
7788 mask = &rte_flow_item_vxlan_mask;
7790 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
7791 mask = &rte_flow_item_vxlan_gpe_mask;
7793 case RTE_FLOW_ITEM_TYPE_E_TAG:
7794 mask = &rte_flow_item_e_tag_mask;
7796 case RTE_FLOW_ITEM_TYPE_NVGRE:
7797 mask = &rte_flow_item_nvgre_mask;
7799 case RTE_FLOW_ITEM_TYPE_MPLS:
7800 mask = &rte_flow_item_mpls_mask;
7802 case RTE_FLOW_ITEM_TYPE_GRE:
7803 mask = &rte_flow_item_gre_mask;
7805 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
7806 mask = &gre_key_default_mask;
7808 case RTE_FLOW_ITEM_TYPE_META:
7809 mask = &rte_flow_item_meta_mask;
7811 case RTE_FLOW_ITEM_TYPE_FUZZY:
7812 mask = &rte_flow_item_fuzzy_mask;
7814 case RTE_FLOW_ITEM_TYPE_GTP:
7815 mask = &rte_flow_item_gtp_mask;
7817 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
7818 mask = &rte_flow_item_gtp_psc_mask;
7820 case RTE_FLOW_ITEM_TYPE_GENEVE:
7821 mask = &rte_flow_item_geneve_mask;
7823 case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
7824 mask = &rte_flow_item_geneve_opt_mask;
7826 case RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID:
7827 mask = &rte_flow_item_pppoe_proto_id_mask;
7829 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
7830 mask = &rte_flow_item_l2tpv3oip_mask;
7832 case RTE_FLOW_ITEM_TYPE_ESP:
7833 mask = &rte_flow_item_esp_mask;
7835 case RTE_FLOW_ITEM_TYPE_AH:
7836 mask = &rte_flow_item_ah_mask;
7838 case RTE_FLOW_ITEM_TYPE_PFCP:
7839 mask = &rte_flow_item_pfcp_mask;
7847 /** Dispatch parsed buffer to function calls. */
7849 cmd_set_raw_parsed_sample(const struct buffer *in)
7851 uint32_t n = in->args.vc.actions_n;
7853 struct rte_flow_action *action = NULL;
7854 struct rte_flow_action *data = NULL;
7855 const struct rte_flow_action_rss *rss = NULL;
7857 uint16_t idx = in->port; /* We borrow port field as index */
7858 uint32_t max_size = sizeof(struct rte_flow_action) *
7859 ACTION_SAMPLE_ACTIONS_NUM;
7861 RTE_ASSERT(in->command == SET_SAMPLE_ACTIONS);
7862 data = (struct rte_flow_action *)&raw_sample_confs[idx].data;
7863 memset(data, 0x00, max_size);
7864 for (; i <= n - 1; i++) {
7865 action = in->args.vc.actions + i;
7866 if (action->type == RTE_FLOW_ACTION_TYPE_END)
7868 switch (action->type) {
7869 case RTE_FLOW_ACTION_TYPE_MARK:
7870 size = sizeof(struct rte_flow_action_mark);
7871 rte_memcpy(&sample_mark[idx],
7872 (const void *)action->conf, size);
7873 action->conf = &sample_mark[idx];
7875 case RTE_FLOW_ACTION_TYPE_COUNT:
7876 size = sizeof(struct rte_flow_action_count);
7877 rte_memcpy(&sample_count[idx],
7878 (const void *)action->conf, size);
7879 action->conf = &sample_count[idx];
7881 case RTE_FLOW_ACTION_TYPE_QUEUE:
7882 size = sizeof(struct rte_flow_action_queue);
7883 rte_memcpy(&sample_queue[idx],
7884 (const void *)action->conf, size);
7885 action->conf = &sample_queue[idx];
7887 case RTE_FLOW_ACTION_TYPE_RSS:
7888 size = sizeof(struct rte_flow_action_rss);
7890 rte_memcpy(&sample_rss_data[idx].conf,
7891 (const void *)rss, size);
7892 if (rss->key_len && rss->key) {
7893 sample_rss_data[idx].conf.key =
7894 sample_rss_data[idx].key;
7895 rte_memcpy((void *)((uintptr_t)
7896 sample_rss_data[idx].conf.key),
7897 (const void *)rss->key,
7898 sizeof(uint8_t) * rss->key_len);
7900 if (rss->queue_num && rss->queue) {
7901 sample_rss_data[idx].conf.queue =
7902 sample_rss_data[idx].queue;
7903 rte_memcpy((void *)((uintptr_t)
7904 sample_rss_data[idx].conf.queue),
7905 (const void *)rss->queue,
7906 sizeof(uint16_t) * rss->queue_num);
7908 action->conf = &sample_rss_data[idx].conf;
7910 case RTE_FLOW_ACTION_TYPE_RAW_ENCAP:
7911 size = sizeof(struct rte_flow_action_raw_encap);
7912 rte_memcpy(&sample_encap[idx],
7913 (const void *)action->conf, size);
7914 action->conf = &sample_encap[idx];
7916 case RTE_FLOW_ACTION_TYPE_PORT_ID:
7917 size = sizeof(struct rte_flow_action_port_id);
7918 rte_memcpy(&sample_port_id[idx],
7919 (const void *)action->conf, size);
7920 action->conf = &sample_port_id[idx];
7922 case RTE_FLOW_ACTION_TYPE_PF:
7924 case RTE_FLOW_ACTION_TYPE_VF:
7925 size = sizeof(struct rte_flow_action_vf);
7926 rte_memcpy(&sample_vf[idx],
7927 (const void *)action->conf, size);
7928 action->conf = &sample_vf[idx];
7931 printf("Error - Not supported action\n");
7934 rte_memcpy(data, action, sizeof(struct rte_flow_action));
7939 /** Dispatch parsed buffer to function calls. */
7941 cmd_set_raw_parsed(const struct buffer *in)
7943 uint32_t n = in->args.vc.pattern_n;
7945 struct rte_flow_item *item = NULL;
7947 uint8_t *data = NULL;
7948 uint8_t *data_tail = NULL;
7949 size_t *total_size = NULL;
7950 uint16_t upper_layer = 0;
7952 uint16_t idx = in->port; /* We borrow port field as index */
7953 int gtp_psc = -1; /* GTP PSC option index. */
7955 if (in->command == SET_SAMPLE_ACTIONS)
7956 return cmd_set_raw_parsed_sample(in);
7957 RTE_ASSERT(in->command == SET_RAW_ENCAP ||
7958 in->command == SET_RAW_DECAP);
7959 if (in->command == SET_RAW_ENCAP) {
7960 total_size = &raw_encap_confs[idx].size;
7961 data = (uint8_t *)&raw_encap_confs[idx].data;
7963 total_size = &raw_decap_confs[idx].size;
7964 data = (uint8_t *)&raw_decap_confs[idx].data;
7967 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
7968 /* process hdr from upper layer to low layer (L3/L4 -> L2). */
7969 data_tail = data + ACTION_RAW_ENCAP_MAX_DATA;
7970 for (i = n - 1 ; i >= 0; --i) {
7971 const struct rte_flow_item_gtp *gtp;
7972 const struct rte_flow_item_geneve_opt *opt;
7974 item = in->args.vc.pattern + i;
7975 if (item->spec == NULL)
7976 item->spec = flow_item_default_mask(item);
7977 switch (item->type) {
7978 case RTE_FLOW_ITEM_TYPE_ETH:
7979 size = sizeof(struct rte_ether_hdr);
7981 case RTE_FLOW_ITEM_TYPE_VLAN:
7982 size = sizeof(struct rte_vlan_hdr);
7983 proto = RTE_ETHER_TYPE_VLAN;
7985 case RTE_FLOW_ITEM_TYPE_IPV4:
7986 size = sizeof(struct rte_ipv4_hdr);
7987 proto = RTE_ETHER_TYPE_IPV4;
7989 case RTE_FLOW_ITEM_TYPE_IPV6:
7990 size = sizeof(struct rte_ipv6_hdr);
7991 proto = RTE_ETHER_TYPE_IPV6;
7993 case RTE_FLOW_ITEM_TYPE_UDP:
7994 size = sizeof(struct rte_udp_hdr);
7997 case RTE_FLOW_ITEM_TYPE_TCP:
7998 size = sizeof(struct rte_tcp_hdr);
8001 case RTE_FLOW_ITEM_TYPE_VXLAN:
8002 size = sizeof(struct rte_vxlan_hdr);
8004 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
8005 size = sizeof(struct rte_vxlan_gpe_hdr);
8007 case RTE_FLOW_ITEM_TYPE_GRE:
8008 size = sizeof(struct rte_gre_hdr);
8011 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
8012 size = sizeof(rte_be32_t);
8015 case RTE_FLOW_ITEM_TYPE_MPLS:
8016 size = sizeof(struct rte_mpls_hdr);
8019 case RTE_FLOW_ITEM_TYPE_NVGRE:
8020 size = sizeof(struct rte_flow_item_nvgre);
8023 case RTE_FLOW_ITEM_TYPE_GENEVE:
8024 size = sizeof(struct rte_geneve_hdr);
8026 case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
8027 opt = (const struct rte_flow_item_geneve_opt *)
8029 size = offsetof(struct rte_flow_item_geneve_opt, data);
8030 if (opt->option_len && opt->data) {
8031 *total_size += opt->option_len *
8033 rte_memcpy(data_tail - (*total_size),
8035 opt->option_len * sizeof(uint32_t));
8038 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
8039 size = sizeof(rte_be32_t);
8042 case RTE_FLOW_ITEM_TYPE_ESP:
8043 size = sizeof(struct rte_esp_hdr);
8046 case RTE_FLOW_ITEM_TYPE_AH:
8047 size = sizeof(struct rte_flow_item_ah);
8050 case RTE_FLOW_ITEM_TYPE_GTP:
8052 size = sizeof(struct rte_gtp_hdr);
8055 if (gtp_psc != i + 1) {
8056 printf("Error - GTP PSC does not follow GTP\n");
8060 if ((gtp->v_pt_rsv_flags & 0x07) != 0x04) {
8061 /* Only E flag should be set. */
8062 printf("Error - GTP unsupported flags\n");
8065 struct rte_gtp_hdr_ext_word ext_word = {
8069 /* We have to add GTP header extra word. */
8070 *total_size += sizeof(ext_word);
8071 rte_memcpy(data_tail - (*total_size),
8072 &ext_word, sizeof(ext_word));
8074 size = sizeof(struct rte_gtp_hdr);
8076 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
8078 printf("Error - Multiple GTP PSC items\n");
8081 const struct rte_flow_item_gtp_psc
8090 if (opt->pdu_type & 0x0F) {
8091 /* Support the minimal option only. */
8092 printf("Error - GTP PSC option with "
8093 "extra fields not supported\n");
8096 psc.len = sizeof(psc);
8097 psc.pdu_type = opt->pdu_type;
8100 *total_size += sizeof(psc);
8101 rte_memcpy(data_tail - (*total_size),
8107 case RTE_FLOW_ITEM_TYPE_PFCP:
8108 size = sizeof(struct rte_flow_item_pfcp);
8111 printf("Error - Not supported item\n");
8114 *total_size += size;
8115 rte_memcpy(data_tail - (*total_size), item->spec, size);
8116 /* update some fields which cannot be set by cmdline */
8117 update_fields((data_tail - (*total_size)), item,
8119 upper_layer = proto;
8121 if (verbose_level & 0x1)
8122 printf("total data size is %zu\n", (*total_size));
8123 RTE_ASSERT((*total_size) <= ACTION_RAW_ENCAP_MAX_DATA);
8124 memmove(data, (data_tail - (*total_size)), *total_size);
8129 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
8132 /** Populate help strings for current token (cmdline API). */
8134 cmd_set_raw_get_help(cmdline_parse_token_hdr_t *hdr, char *dst,
8137 struct context *ctx = &cmd_flow_context;
8138 const struct token *token = &token_list[ctx->prev];
8143 /* Set token type and update global help with details. */
8144 snprintf(dst, size, "%s", (token->type ? token->type : "TOKEN"));
8146 cmd_set_raw.help_str = token->help;
8148 cmd_set_raw.help_str = token->name;
8152 /** Token definition template (cmdline API). */
8153 static struct cmdline_token_hdr cmd_set_raw_token_hdr = {
8154 .ops = &(struct cmdline_token_ops){
8155 .parse = cmd_flow_parse,
8156 .complete_get_nb = cmd_flow_complete_get_nb,
8157 .complete_get_elt = cmd_flow_complete_get_elt,
8158 .get_help = cmd_set_raw_get_help,
8163 /** Populate the next dynamic token. */
8165 cmd_set_raw_tok(cmdline_parse_token_hdr_t **hdr,
8166 cmdline_parse_token_hdr_t **hdr_inst)
8168 struct context *ctx = &cmd_flow_context;
8170 /* Always reinitialize context before requesting the first token. */
8171 if (!(hdr_inst - cmd_set_raw.tokens)) {
8172 cmd_flow_context_init(ctx);
8173 ctx->curr = START_SET;
8175 /* Return NULL when no more tokens are expected. */
8176 if (!ctx->next_num && (ctx->curr != START_SET)) {
8180 /* Determine if command should end here. */
8181 if (ctx->eol && ctx->last && ctx->next_num) {
8182 const enum index *list = ctx->next[ctx->next_num - 1];
8185 for (i = 0; list[i]; ++i) {
8192 *hdr = &cmd_set_raw_token_hdr;
8195 /** Token generator and output processing callback (cmdline API). */
8197 cmd_set_raw_cb(void *arg0, struct cmdline *cl, void *arg2)
8200 cmd_set_raw_tok(arg0, arg2);
8202 cmd_set_raw_parsed(arg0);
8205 /** Global parser instance (cmdline API). */
8206 cmdline_parse_inst_t cmd_set_raw = {
8207 .f = cmd_set_raw_cb,
8208 .data = NULL, /**< Unused. */
8209 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
8212 }, /**< Tokens are returned by cmd_flow_tok(). */
8215 /* *** display raw_encap/raw_decap buf */
8216 struct cmd_show_set_raw_result {
8217 cmdline_fixed_string_t cmd_show;
8218 cmdline_fixed_string_t cmd_what;
8219 cmdline_fixed_string_t cmd_all;
8224 cmd_show_set_raw_parsed(void *parsed_result, struct cmdline *cl, void *data)
8226 struct cmd_show_set_raw_result *res = parsed_result;
8227 uint16_t index = res->cmd_index;
8229 uint8_t *raw_data = NULL;
8230 size_t raw_size = 0;
8231 char title[16] = {0};
8235 if (!strcmp(res->cmd_all, "all")) {
8238 } else if (index >= RAW_ENCAP_CONFS_MAX_NUM) {
8239 printf("index should be 0-%u\n", RAW_ENCAP_CONFS_MAX_NUM - 1);
8243 if (!strcmp(res->cmd_what, "raw_encap")) {
8244 raw_data = (uint8_t *)&raw_encap_confs[index].data;
8245 raw_size = raw_encap_confs[index].size;
8246 snprintf(title, 16, "\nindex: %u", index);
8247 rte_hexdump(stdout, title, raw_data, raw_size);
8249 raw_data = (uint8_t *)&raw_decap_confs[index].data;
8250 raw_size = raw_decap_confs[index].size;
8251 snprintf(title, 16, "\nindex: %u", index);
8252 rte_hexdump(stdout, title, raw_data, raw_size);
8254 } while (all && ++index < RAW_ENCAP_CONFS_MAX_NUM);
8257 cmdline_parse_token_string_t cmd_show_set_raw_cmd_show =
8258 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
8260 cmdline_parse_token_string_t cmd_show_set_raw_cmd_what =
8261 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
8262 cmd_what, "raw_encap#raw_decap");
8263 cmdline_parse_token_num_t cmd_show_set_raw_cmd_index =
8264 TOKEN_NUM_INITIALIZER(struct cmd_show_set_raw_result,
8265 cmd_index, RTE_UINT16);
8266 cmdline_parse_token_string_t cmd_show_set_raw_cmd_all =
8267 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
8269 cmdline_parse_inst_t cmd_show_set_raw = {
8270 .f = cmd_show_set_raw_parsed,
8272 .help_str = "show <raw_encap|raw_decap> <index>",
8274 (void *)&cmd_show_set_raw_cmd_show,
8275 (void *)&cmd_show_set_raw_cmd_what,
8276 (void *)&cmd_show_set_raw_cmd_index,
8280 cmdline_parse_inst_t cmd_show_set_raw_all = {
8281 .f = cmd_show_set_raw_parsed,
8283 .help_str = "show <raw_encap|raw_decap> all",
8285 (void *)&cmd_show_set_raw_cmd_show,
8286 (void *)&cmd_show_set_raw_cmd_what,
8287 (void *)&cmd_show_set_raw_cmd_all,