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.c_k_s_rsvd0_ver = RTE_BE16(0x2000),
5443 .item_nvgre.protocol = RTE_BE16(RTE_ETHER_TYPE_TEB),
5444 .item_nvgre.flow_id = 0,
5446 memcpy(action_nvgre_encap_data->item_eth.dst.addr_bytes,
5447 nvgre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5448 memcpy(action_nvgre_encap_data->item_eth.src.addr_bytes,
5449 nvgre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5450 if (!nvgre_encap_conf.select_ipv4) {
5451 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.src_addr,
5452 &nvgre_encap_conf.ipv6_src,
5453 sizeof(nvgre_encap_conf.ipv6_src));
5454 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.dst_addr,
5455 &nvgre_encap_conf.ipv6_dst,
5456 sizeof(nvgre_encap_conf.ipv6_dst));
5457 action_nvgre_encap_data->items[2] = (struct rte_flow_item){
5458 .type = RTE_FLOW_ITEM_TYPE_IPV6,
5459 .spec = &action_nvgre_encap_data->item_ipv6,
5460 .mask = &rte_flow_item_ipv6_mask,
5463 if (!nvgre_encap_conf.select_vlan)
5464 action_nvgre_encap_data->items[1].type =
5465 RTE_FLOW_ITEM_TYPE_VOID;
5466 memcpy(action_nvgre_encap_data->item_nvgre.tni, nvgre_encap_conf.tni,
5467 RTE_DIM(nvgre_encap_conf.tni));
5468 action->conf = &action_nvgre_encap_data->conf;
5472 /** Parse l2 encap action. */
5474 parse_vc_action_l2_encap(struct context *ctx, const struct token *token,
5475 const char *str, unsigned int len,
5476 void *buf, unsigned int size)
5478 struct buffer *out = buf;
5479 struct rte_flow_action *action;
5480 struct action_raw_encap_data *action_encap_data;
5481 struct rte_flow_item_eth eth = { .type = 0, };
5482 struct rte_flow_item_vlan vlan = {
5483 .tci = mplsoudp_encap_conf.vlan_tci,
5489 ret = parse_vc(ctx, token, str, len, buf, size);
5492 /* Nothing else to do if there is no buffer. */
5495 if (!out->args.vc.actions_n)
5497 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5498 /* Point to selected object. */
5499 ctx->object = out->args.vc.data;
5500 ctx->objmask = NULL;
5501 /* Copy the headers to the buffer. */
5502 action_encap_data = ctx->object;
5503 *action_encap_data = (struct action_raw_encap_data) {
5504 .conf = (struct rte_flow_action_raw_encap){
5505 .data = action_encap_data->data,
5509 header = action_encap_data->data;
5510 if (l2_encap_conf.select_vlan)
5511 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5512 else if (l2_encap_conf.select_ipv4)
5513 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5515 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5516 memcpy(eth.dst.addr_bytes,
5517 l2_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5518 memcpy(eth.src.addr_bytes,
5519 l2_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5520 memcpy(header, ð, sizeof(eth));
5521 header += sizeof(eth);
5522 if (l2_encap_conf.select_vlan) {
5523 if (l2_encap_conf.select_ipv4)
5524 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5526 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5527 memcpy(header, &vlan, sizeof(vlan));
5528 header += sizeof(vlan);
5530 action_encap_data->conf.size = header -
5531 action_encap_data->data;
5532 action->conf = &action_encap_data->conf;
5536 /** Parse l2 decap action. */
5538 parse_vc_action_l2_decap(struct context *ctx, const struct token *token,
5539 const char *str, unsigned int len,
5540 void *buf, unsigned int size)
5542 struct buffer *out = buf;
5543 struct rte_flow_action *action;
5544 struct action_raw_decap_data *action_decap_data;
5545 struct rte_flow_item_eth eth = { .type = 0, };
5546 struct rte_flow_item_vlan vlan = {
5547 .tci = mplsoudp_encap_conf.vlan_tci,
5553 ret = parse_vc(ctx, token, str, len, buf, size);
5556 /* Nothing else to do if there is no buffer. */
5559 if (!out->args.vc.actions_n)
5561 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5562 /* Point to selected object. */
5563 ctx->object = out->args.vc.data;
5564 ctx->objmask = NULL;
5565 /* Copy the headers to the buffer. */
5566 action_decap_data = ctx->object;
5567 *action_decap_data = (struct action_raw_decap_data) {
5568 .conf = (struct rte_flow_action_raw_decap){
5569 .data = action_decap_data->data,
5573 header = action_decap_data->data;
5574 if (l2_decap_conf.select_vlan)
5575 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5576 memcpy(header, ð, sizeof(eth));
5577 header += sizeof(eth);
5578 if (l2_decap_conf.select_vlan) {
5579 memcpy(header, &vlan, sizeof(vlan));
5580 header += sizeof(vlan);
5582 action_decap_data->conf.size = header -
5583 action_decap_data->data;
5584 action->conf = &action_decap_data->conf;
5588 #define ETHER_TYPE_MPLS_UNICAST 0x8847
5590 /** Parse MPLSOGRE encap action. */
5592 parse_vc_action_mplsogre_encap(struct context *ctx, const struct token *token,
5593 const char *str, unsigned int len,
5594 void *buf, unsigned int size)
5596 struct buffer *out = buf;
5597 struct rte_flow_action *action;
5598 struct action_raw_encap_data *action_encap_data;
5599 struct rte_flow_item_eth eth = { .type = 0, };
5600 struct rte_flow_item_vlan vlan = {
5601 .tci = mplsogre_encap_conf.vlan_tci,
5604 struct rte_flow_item_ipv4 ipv4 = {
5606 .src_addr = mplsogre_encap_conf.ipv4_src,
5607 .dst_addr = mplsogre_encap_conf.ipv4_dst,
5608 .next_proto_id = IPPROTO_GRE,
5609 .version_ihl = RTE_IPV4_VHL_DEF,
5610 .time_to_live = IPDEFTTL,
5613 struct rte_flow_item_ipv6 ipv6 = {
5615 .proto = IPPROTO_GRE,
5616 .hop_limits = IPDEFTTL,
5619 struct rte_flow_item_gre gre = {
5620 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
5622 struct rte_flow_item_mpls mpls = {
5628 ret = parse_vc(ctx, token, str, len, buf, size);
5631 /* Nothing else to do if there is no buffer. */
5634 if (!out->args.vc.actions_n)
5636 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5637 /* Point to selected object. */
5638 ctx->object = out->args.vc.data;
5639 ctx->objmask = NULL;
5640 /* Copy the headers to the buffer. */
5641 action_encap_data = ctx->object;
5642 *action_encap_data = (struct action_raw_encap_data) {
5643 .conf = (struct rte_flow_action_raw_encap){
5644 .data = action_encap_data->data,
5649 header = action_encap_data->data;
5650 if (mplsogre_encap_conf.select_vlan)
5651 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5652 else if (mplsogre_encap_conf.select_ipv4)
5653 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5655 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5656 memcpy(eth.dst.addr_bytes,
5657 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5658 memcpy(eth.src.addr_bytes,
5659 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5660 memcpy(header, ð, sizeof(eth));
5661 header += sizeof(eth);
5662 if (mplsogre_encap_conf.select_vlan) {
5663 if (mplsogre_encap_conf.select_ipv4)
5664 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5666 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5667 memcpy(header, &vlan, sizeof(vlan));
5668 header += sizeof(vlan);
5670 if (mplsogre_encap_conf.select_ipv4) {
5671 memcpy(header, &ipv4, sizeof(ipv4));
5672 header += sizeof(ipv4);
5674 memcpy(&ipv6.hdr.src_addr,
5675 &mplsogre_encap_conf.ipv6_src,
5676 sizeof(mplsogre_encap_conf.ipv6_src));
5677 memcpy(&ipv6.hdr.dst_addr,
5678 &mplsogre_encap_conf.ipv6_dst,
5679 sizeof(mplsogre_encap_conf.ipv6_dst));
5680 memcpy(header, &ipv6, sizeof(ipv6));
5681 header += sizeof(ipv6);
5683 memcpy(header, &gre, sizeof(gre));
5684 header += sizeof(gre);
5685 memcpy(mpls.label_tc_s, mplsogre_encap_conf.label,
5686 RTE_DIM(mplsogre_encap_conf.label));
5687 mpls.label_tc_s[2] |= 0x1;
5688 memcpy(header, &mpls, sizeof(mpls));
5689 header += sizeof(mpls);
5690 action_encap_data->conf.size = header -
5691 action_encap_data->data;
5692 action->conf = &action_encap_data->conf;
5696 /** Parse MPLSOGRE decap action. */
5698 parse_vc_action_mplsogre_decap(struct context *ctx, const struct token *token,
5699 const char *str, unsigned int len,
5700 void *buf, unsigned int size)
5702 struct buffer *out = buf;
5703 struct rte_flow_action *action;
5704 struct action_raw_decap_data *action_decap_data;
5705 struct rte_flow_item_eth eth = { .type = 0, };
5706 struct rte_flow_item_vlan vlan = {.tci = 0};
5707 struct rte_flow_item_ipv4 ipv4 = {
5709 .next_proto_id = IPPROTO_GRE,
5712 struct rte_flow_item_ipv6 ipv6 = {
5714 .proto = IPPROTO_GRE,
5717 struct rte_flow_item_gre gre = {
5718 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
5720 struct rte_flow_item_mpls mpls;
5724 ret = parse_vc(ctx, token, str, len, buf, size);
5727 /* Nothing else to do if there is no buffer. */
5730 if (!out->args.vc.actions_n)
5732 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5733 /* Point to selected object. */
5734 ctx->object = out->args.vc.data;
5735 ctx->objmask = NULL;
5736 /* Copy the headers to the buffer. */
5737 action_decap_data = ctx->object;
5738 *action_decap_data = (struct action_raw_decap_data) {
5739 .conf = (struct rte_flow_action_raw_decap){
5740 .data = action_decap_data->data,
5744 header = action_decap_data->data;
5745 if (mplsogre_decap_conf.select_vlan)
5746 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5747 else if (mplsogre_encap_conf.select_ipv4)
5748 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5750 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5751 memcpy(eth.dst.addr_bytes,
5752 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5753 memcpy(eth.src.addr_bytes,
5754 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5755 memcpy(header, ð, sizeof(eth));
5756 header += sizeof(eth);
5757 if (mplsogre_encap_conf.select_vlan) {
5758 if (mplsogre_encap_conf.select_ipv4)
5759 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5761 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5762 memcpy(header, &vlan, sizeof(vlan));
5763 header += sizeof(vlan);
5765 if (mplsogre_encap_conf.select_ipv4) {
5766 memcpy(header, &ipv4, sizeof(ipv4));
5767 header += sizeof(ipv4);
5769 memcpy(header, &ipv6, sizeof(ipv6));
5770 header += sizeof(ipv6);
5772 memcpy(header, &gre, sizeof(gre));
5773 header += sizeof(gre);
5774 memset(&mpls, 0, sizeof(mpls));
5775 memcpy(header, &mpls, sizeof(mpls));
5776 header += sizeof(mpls);
5777 action_decap_data->conf.size = header -
5778 action_decap_data->data;
5779 action->conf = &action_decap_data->conf;
5783 /** Parse MPLSOUDP encap action. */
5785 parse_vc_action_mplsoudp_encap(struct context *ctx, const struct token *token,
5786 const char *str, unsigned int len,
5787 void *buf, unsigned int size)
5789 struct buffer *out = buf;
5790 struct rte_flow_action *action;
5791 struct action_raw_encap_data *action_encap_data;
5792 struct rte_flow_item_eth eth = { .type = 0, };
5793 struct rte_flow_item_vlan vlan = {
5794 .tci = mplsoudp_encap_conf.vlan_tci,
5797 struct rte_flow_item_ipv4 ipv4 = {
5799 .src_addr = mplsoudp_encap_conf.ipv4_src,
5800 .dst_addr = mplsoudp_encap_conf.ipv4_dst,
5801 .next_proto_id = IPPROTO_UDP,
5802 .version_ihl = RTE_IPV4_VHL_DEF,
5803 .time_to_live = IPDEFTTL,
5806 struct rte_flow_item_ipv6 ipv6 = {
5808 .proto = IPPROTO_UDP,
5809 .hop_limits = IPDEFTTL,
5812 struct rte_flow_item_udp udp = {
5814 .src_port = mplsoudp_encap_conf.udp_src,
5815 .dst_port = mplsoudp_encap_conf.udp_dst,
5818 struct rte_flow_item_mpls mpls;
5822 ret = parse_vc(ctx, token, str, len, buf, size);
5825 /* Nothing else to do if there is no buffer. */
5828 if (!out->args.vc.actions_n)
5830 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5831 /* Point to selected object. */
5832 ctx->object = out->args.vc.data;
5833 ctx->objmask = NULL;
5834 /* Copy the headers to the buffer. */
5835 action_encap_data = ctx->object;
5836 *action_encap_data = (struct action_raw_encap_data) {
5837 .conf = (struct rte_flow_action_raw_encap){
5838 .data = action_encap_data->data,
5843 header = action_encap_data->data;
5844 if (mplsoudp_encap_conf.select_vlan)
5845 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5846 else if (mplsoudp_encap_conf.select_ipv4)
5847 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5849 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5850 memcpy(eth.dst.addr_bytes,
5851 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5852 memcpy(eth.src.addr_bytes,
5853 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5854 memcpy(header, ð, sizeof(eth));
5855 header += sizeof(eth);
5856 if (mplsoudp_encap_conf.select_vlan) {
5857 if (mplsoudp_encap_conf.select_ipv4)
5858 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5860 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5861 memcpy(header, &vlan, sizeof(vlan));
5862 header += sizeof(vlan);
5864 if (mplsoudp_encap_conf.select_ipv4) {
5865 memcpy(header, &ipv4, sizeof(ipv4));
5866 header += sizeof(ipv4);
5868 memcpy(&ipv6.hdr.src_addr,
5869 &mplsoudp_encap_conf.ipv6_src,
5870 sizeof(mplsoudp_encap_conf.ipv6_src));
5871 memcpy(&ipv6.hdr.dst_addr,
5872 &mplsoudp_encap_conf.ipv6_dst,
5873 sizeof(mplsoudp_encap_conf.ipv6_dst));
5874 memcpy(header, &ipv6, sizeof(ipv6));
5875 header += sizeof(ipv6);
5877 memcpy(header, &udp, sizeof(udp));
5878 header += sizeof(udp);
5879 memcpy(mpls.label_tc_s, mplsoudp_encap_conf.label,
5880 RTE_DIM(mplsoudp_encap_conf.label));
5881 mpls.label_tc_s[2] |= 0x1;
5882 memcpy(header, &mpls, sizeof(mpls));
5883 header += sizeof(mpls);
5884 action_encap_data->conf.size = header -
5885 action_encap_data->data;
5886 action->conf = &action_encap_data->conf;
5890 /** Parse MPLSOUDP decap action. */
5892 parse_vc_action_mplsoudp_decap(struct context *ctx, const struct token *token,
5893 const char *str, unsigned int len,
5894 void *buf, unsigned int size)
5896 struct buffer *out = buf;
5897 struct rte_flow_action *action;
5898 struct action_raw_decap_data *action_decap_data;
5899 struct rte_flow_item_eth eth = { .type = 0, };
5900 struct rte_flow_item_vlan vlan = {.tci = 0};
5901 struct rte_flow_item_ipv4 ipv4 = {
5903 .next_proto_id = IPPROTO_UDP,
5906 struct rte_flow_item_ipv6 ipv6 = {
5908 .proto = IPPROTO_UDP,
5911 struct rte_flow_item_udp udp = {
5913 .dst_port = rte_cpu_to_be_16(6635),
5916 struct rte_flow_item_mpls mpls;
5920 ret = parse_vc(ctx, token, str, len, buf, size);
5923 /* Nothing else to do if there is no buffer. */
5926 if (!out->args.vc.actions_n)
5928 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5929 /* Point to selected object. */
5930 ctx->object = out->args.vc.data;
5931 ctx->objmask = NULL;
5932 /* Copy the headers to the buffer. */
5933 action_decap_data = ctx->object;
5934 *action_decap_data = (struct action_raw_decap_data) {
5935 .conf = (struct rte_flow_action_raw_decap){
5936 .data = action_decap_data->data,
5940 header = action_decap_data->data;
5941 if (mplsoudp_decap_conf.select_vlan)
5942 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5943 else if (mplsoudp_encap_conf.select_ipv4)
5944 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5946 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5947 memcpy(eth.dst.addr_bytes,
5948 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5949 memcpy(eth.src.addr_bytes,
5950 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5951 memcpy(header, ð, sizeof(eth));
5952 header += sizeof(eth);
5953 if (mplsoudp_encap_conf.select_vlan) {
5954 if (mplsoudp_encap_conf.select_ipv4)
5955 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5957 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5958 memcpy(header, &vlan, sizeof(vlan));
5959 header += sizeof(vlan);
5961 if (mplsoudp_encap_conf.select_ipv4) {
5962 memcpy(header, &ipv4, sizeof(ipv4));
5963 header += sizeof(ipv4);
5965 memcpy(header, &ipv6, sizeof(ipv6));
5966 header += sizeof(ipv6);
5968 memcpy(header, &udp, sizeof(udp));
5969 header += sizeof(udp);
5970 memset(&mpls, 0, sizeof(mpls));
5971 memcpy(header, &mpls, sizeof(mpls));
5972 header += sizeof(mpls);
5973 action_decap_data->conf.size = header -
5974 action_decap_data->data;
5975 action->conf = &action_decap_data->conf;
5980 parse_vc_action_raw_decap_index(struct context *ctx, const struct token *token,
5981 const char *str, unsigned int len, void *buf,
5984 struct action_raw_decap_data *action_raw_decap_data;
5985 struct rte_flow_action *action;
5986 const struct arg *arg;
5987 struct buffer *out = buf;
5991 RTE_SET_USED(token);
5994 arg = ARGS_ENTRY_ARB_BOUNDED
5995 (offsetof(struct action_raw_decap_data, idx),
5996 sizeof(((struct action_raw_decap_data *)0)->idx),
5997 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
5998 if (push_args(ctx, arg))
6000 ret = parse_int(ctx, token, str, len, NULL, 0);
6007 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6008 action_raw_decap_data = ctx->object;
6009 idx = action_raw_decap_data->idx;
6010 action_raw_decap_data->conf.data = raw_decap_confs[idx].data;
6011 action_raw_decap_data->conf.size = raw_decap_confs[idx].size;
6012 action->conf = &action_raw_decap_data->conf;
6018 parse_vc_action_raw_encap_index(struct context *ctx, const struct token *token,
6019 const char *str, unsigned int len, void *buf,
6022 struct action_raw_encap_data *action_raw_encap_data;
6023 struct rte_flow_action *action;
6024 const struct arg *arg;
6025 struct buffer *out = buf;
6029 RTE_SET_USED(token);
6032 if (ctx->curr != ACTION_RAW_ENCAP_INDEX_VALUE)
6034 arg = ARGS_ENTRY_ARB_BOUNDED
6035 (offsetof(struct action_raw_encap_data, idx),
6036 sizeof(((struct action_raw_encap_data *)0)->idx),
6037 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
6038 if (push_args(ctx, arg))
6040 ret = parse_int(ctx, token, str, len, NULL, 0);
6047 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6048 action_raw_encap_data = ctx->object;
6049 idx = action_raw_encap_data->idx;
6050 action_raw_encap_data->conf.data = raw_encap_confs[idx].data;
6051 action_raw_encap_data->conf.size = raw_encap_confs[idx].size;
6052 action_raw_encap_data->conf.preserve = NULL;
6053 action->conf = &action_raw_encap_data->conf;
6058 parse_vc_action_raw_encap(struct context *ctx, const struct token *token,
6059 const char *str, unsigned int len, void *buf,
6062 struct buffer *out = buf;
6063 struct rte_flow_action *action;
6064 struct action_raw_encap_data *action_raw_encap_data = NULL;
6067 ret = parse_vc(ctx, token, str, len, buf, size);
6070 /* Nothing else to do if there is no buffer. */
6073 if (!out->args.vc.actions_n)
6075 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6076 /* Point to selected object. */
6077 ctx->object = out->args.vc.data;
6078 ctx->objmask = NULL;
6079 /* Copy the headers to the buffer. */
6080 action_raw_encap_data = ctx->object;
6081 action_raw_encap_data->conf.data = raw_encap_confs[0].data;
6082 action_raw_encap_data->conf.preserve = NULL;
6083 action_raw_encap_data->conf.size = raw_encap_confs[0].size;
6084 action->conf = &action_raw_encap_data->conf;
6089 parse_vc_action_raw_decap(struct context *ctx, const struct token *token,
6090 const char *str, unsigned int len, void *buf,
6093 struct buffer *out = buf;
6094 struct rte_flow_action *action;
6095 struct action_raw_decap_data *action_raw_decap_data = NULL;
6098 ret = parse_vc(ctx, token, str, len, buf, size);
6101 /* Nothing else to do if there is no buffer. */
6104 if (!out->args.vc.actions_n)
6106 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6107 /* Point to selected object. */
6108 ctx->object = out->args.vc.data;
6109 ctx->objmask = NULL;
6110 /* Copy the headers to the buffer. */
6111 action_raw_decap_data = ctx->object;
6112 action_raw_decap_data->conf.data = raw_decap_confs[0].data;
6113 action_raw_decap_data->conf.size = raw_decap_confs[0].size;
6114 action->conf = &action_raw_decap_data->conf;
6119 parse_vc_action_set_meta(struct context *ctx, const struct token *token,
6120 const char *str, unsigned int len, void *buf,
6125 ret = parse_vc(ctx, token, str, len, buf, size);
6128 ret = rte_flow_dynf_metadata_register();
6135 parse_vc_action_sample(struct context *ctx, const struct token *token,
6136 const char *str, unsigned int len, void *buf,
6139 struct buffer *out = buf;
6140 struct rte_flow_action *action;
6141 struct action_sample_data *action_sample_data = NULL;
6142 static struct rte_flow_action end_action = {
6143 RTE_FLOW_ACTION_TYPE_END, 0
6147 ret = parse_vc(ctx, token, str, len, buf, size);
6150 /* Nothing else to do if there is no buffer. */
6153 if (!out->args.vc.actions_n)
6155 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6156 /* Point to selected object. */
6157 ctx->object = out->args.vc.data;
6158 ctx->objmask = NULL;
6159 /* Copy the headers to the buffer. */
6160 action_sample_data = ctx->object;
6161 action_sample_data->conf.actions = &end_action;
6162 action->conf = &action_sample_data->conf;
6167 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
6168 const char *str, unsigned int len, void *buf,
6171 struct action_sample_data *action_sample_data;
6172 struct rte_flow_action *action;
6173 const struct arg *arg;
6174 struct buffer *out = buf;
6178 RTE_SET_USED(token);
6181 if (ctx->curr != ACTION_SAMPLE_INDEX_VALUE)
6183 arg = ARGS_ENTRY_ARB_BOUNDED
6184 (offsetof(struct action_sample_data, idx),
6185 sizeof(((struct action_sample_data *)0)->idx),
6186 0, RAW_SAMPLE_CONFS_MAX_NUM - 1);
6187 if (push_args(ctx, arg))
6189 ret = parse_int(ctx, token, str, len, NULL, 0);
6196 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6197 action_sample_data = ctx->object;
6198 idx = action_sample_data->idx;
6199 action_sample_data->conf.actions = raw_sample_confs[idx].data;
6200 action->conf = &action_sample_data->conf;
6204 /** Parse operation for modify_field command. */
6206 parse_vc_modify_field_op(struct context *ctx, const struct token *token,
6207 const char *str, unsigned int len, void *buf,
6210 struct rte_flow_action_modify_field *action_modify_field;
6216 if (ctx->curr != ACTION_MODIFY_FIELD_OP_VALUE)
6218 for (i = 0; modify_field_ops[i]; ++i)
6219 if (!strcmp_partial(modify_field_ops[i], str, len))
6221 if (!modify_field_ops[i])
6225 action_modify_field = ctx->object;
6226 action_modify_field->operation = (enum rte_flow_modify_op)i;
6230 /** Parse id for modify_field command. */
6232 parse_vc_modify_field_id(struct context *ctx, const struct token *token,
6233 const char *str, unsigned int len, void *buf,
6236 struct rte_flow_action_modify_field *action_modify_field;
6242 if (ctx->curr != ACTION_MODIFY_FIELD_DST_TYPE_VALUE &&
6243 ctx->curr != ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)
6245 for (i = 0; modify_field_ids[i]; ++i)
6246 if (!strcmp_partial(modify_field_ids[i], str, len))
6248 if (!modify_field_ids[i])
6252 action_modify_field = ctx->object;
6253 if (ctx->curr == ACTION_MODIFY_FIELD_DST_TYPE_VALUE)
6254 action_modify_field->dst.field = (enum rte_flow_field_id)i;
6256 action_modify_field->src.field = (enum rte_flow_field_id)i;
6260 /** Parse tokens for destroy command. */
6262 parse_destroy(struct context *ctx, const struct token *token,
6263 const char *str, unsigned int len,
6264 void *buf, unsigned int size)
6266 struct buffer *out = buf;
6268 /* Token name must match. */
6269 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6271 /* Nothing else to do if there is no buffer. */
6274 if (!out->command) {
6275 if (ctx->curr != DESTROY)
6277 if (sizeof(*out) > size)
6279 out->command = ctx->curr;
6282 ctx->objmask = NULL;
6283 out->args.destroy.rule =
6284 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6288 if (((uint8_t *)(out->args.destroy.rule + out->args.destroy.rule_n) +
6289 sizeof(*out->args.destroy.rule)) > (uint8_t *)out + size)
6292 ctx->object = out->args.destroy.rule + out->args.destroy.rule_n++;
6293 ctx->objmask = NULL;
6297 /** Parse tokens for flush command. */
6299 parse_flush(struct context *ctx, const struct token *token,
6300 const char *str, unsigned int len,
6301 void *buf, unsigned int size)
6303 struct buffer *out = buf;
6305 /* Token name must match. */
6306 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6308 /* Nothing else to do if there is no buffer. */
6311 if (!out->command) {
6312 if (ctx->curr != FLUSH)
6314 if (sizeof(*out) > size)
6316 out->command = ctx->curr;
6319 ctx->objmask = NULL;
6324 /** Parse tokens for dump command. */
6326 parse_dump(struct context *ctx, const struct token *token,
6327 const char *str, unsigned int len,
6328 void *buf, unsigned int size)
6330 struct buffer *out = buf;
6332 /* Token name must match. */
6333 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6335 /* Nothing else to do if there is no buffer. */
6338 if (!out->command) {
6339 if (ctx->curr != DUMP)
6341 if (sizeof(*out) > size)
6343 out->command = ctx->curr;
6346 ctx->objmask = NULL;
6351 /** Parse tokens for query command. */
6353 parse_query(struct context *ctx, const struct token *token,
6354 const char *str, unsigned int len,
6355 void *buf, unsigned int size)
6357 struct buffer *out = buf;
6359 /* Token name must match. */
6360 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6362 /* Nothing else to do if there is no buffer. */
6365 if (!out->command) {
6366 if (ctx->curr != QUERY)
6368 if (sizeof(*out) > size)
6370 out->command = ctx->curr;
6373 ctx->objmask = NULL;
6378 /** Parse action names. */
6380 parse_action(struct context *ctx, const struct token *token,
6381 const char *str, unsigned int len,
6382 void *buf, unsigned int size)
6384 struct buffer *out = buf;
6385 const struct arg *arg = pop_args(ctx);
6389 /* Argument is expected. */
6392 /* Parse action name. */
6393 for (i = 0; next_action[i]; ++i) {
6394 const struct parse_action_priv *priv;
6396 token = &token_list[next_action[i]];
6397 if (strcmp_partial(token->name, str, len))
6403 memcpy((uint8_t *)ctx->object + arg->offset,
6409 push_args(ctx, arg);
6413 /** Parse tokens for list command. */
6415 parse_list(struct context *ctx, const struct token *token,
6416 const char *str, unsigned int len,
6417 void *buf, unsigned int size)
6419 struct buffer *out = buf;
6421 /* Token name must match. */
6422 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6424 /* Nothing else to do if there is no buffer. */
6427 if (!out->command) {
6428 if (ctx->curr != LIST)
6430 if (sizeof(*out) > size)
6432 out->command = ctx->curr;
6435 ctx->objmask = NULL;
6436 out->args.list.group =
6437 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6441 if (((uint8_t *)(out->args.list.group + out->args.list.group_n) +
6442 sizeof(*out->args.list.group)) > (uint8_t *)out + size)
6445 ctx->object = out->args.list.group + out->args.list.group_n++;
6446 ctx->objmask = NULL;
6450 /** Parse tokens for list all aged flows command. */
6452 parse_aged(struct context *ctx, const struct token *token,
6453 const char *str, unsigned int len,
6454 void *buf, unsigned int size)
6456 struct buffer *out = buf;
6458 /* Token name must match. */
6459 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6461 /* Nothing else to do if there is no buffer. */
6464 if (!out->command) {
6465 if (ctx->curr != AGED)
6467 if (sizeof(*out) > size)
6469 out->command = ctx->curr;
6472 ctx->objmask = NULL;
6474 if (ctx->curr == AGED_DESTROY)
6475 out->args.aged.destroy = 1;
6479 /** Parse tokens for isolate command. */
6481 parse_isolate(struct context *ctx, const struct token *token,
6482 const char *str, unsigned int len,
6483 void *buf, unsigned int size)
6485 struct buffer *out = buf;
6487 /* Token name must match. */
6488 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6490 /* Nothing else to do if there is no buffer. */
6493 if (!out->command) {
6494 if (ctx->curr != ISOLATE)
6496 if (sizeof(*out) > size)
6498 out->command = ctx->curr;
6501 ctx->objmask = NULL;
6507 parse_tunnel(struct context *ctx, const struct token *token,
6508 const char *str, unsigned int len,
6509 void *buf, unsigned int size)
6511 struct buffer *out = buf;
6513 /* Token name must match. */
6514 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6516 /* Nothing else to do if there is no buffer. */
6519 if (!out->command) {
6520 if (ctx->curr != TUNNEL)
6522 if (sizeof(*out) > size)
6524 out->command = ctx->curr;
6527 ctx->objmask = NULL;
6529 switch (ctx->curr) {
6533 case TUNNEL_DESTROY:
6535 out->command = ctx->curr;
6537 case TUNNEL_CREATE_TYPE:
6538 case TUNNEL_DESTROY_ID:
6539 ctx->object = &out->args.vc.tunnel_ops;
6548 * Parse signed/unsigned integers 8 to 64-bit long.
6550 * Last argument (ctx->args) is retrieved to determine integer type and
6554 parse_int(struct context *ctx, const struct token *token,
6555 const char *str, unsigned int len,
6556 void *buf, unsigned int size)
6558 const struct arg *arg = pop_args(ctx);
6563 /* Argument is expected. */
6568 (uintmax_t)strtoimax(str, &end, 0) :
6569 strtoumax(str, &end, 0);
6570 if (errno || (size_t)(end - str) != len)
6573 ((arg->sign && ((intmax_t)u < (intmax_t)arg->min ||
6574 (intmax_t)u > (intmax_t)arg->max)) ||
6575 (!arg->sign && (u < arg->min || u > arg->max))))
6580 if (!arg_entry_bf_fill(ctx->object, u, arg) ||
6581 !arg_entry_bf_fill(ctx->objmask, -1, arg))
6585 buf = (uint8_t *)ctx->object + arg->offset;
6587 if (u > RTE_LEN2MASK(size * CHAR_BIT, uint64_t))
6591 case sizeof(uint8_t):
6592 *(uint8_t *)buf = u;
6594 case sizeof(uint16_t):
6595 *(uint16_t *)buf = arg->hton ? rte_cpu_to_be_16(u) : u;
6597 case sizeof(uint8_t [3]):
6598 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
6600 ((uint8_t *)buf)[0] = u;
6601 ((uint8_t *)buf)[1] = u >> 8;
6602 ((uint8_t *)buf)[2] = u >> 16;
6606 ((uint8_t *)buf)[0] = u >> 16;
6607 ((uint8_t *)buf)[1] = u >> 8;
6608 ((uint8_t *)buf)[2] = u;
6610 case sizeof(uint32_t):
6611 *(uint32_t *)buf = arg->hton ? rte_cpu_to_be_32(u) : u;
6613 case sizeof(uint64_t):
6614 *(uint64_t *)buf = arg->hton ? rte_cpu_to_be_64(u) : u;
6619 if (ctx->objmask && buf != (uint8_t *)ctx->objmask + arg->offset) {
6621 buf = (uint8_t *)ctx->objmask + arg->offset;
6626 push_args(ctx, arg);
6633 * Three arguments (ctx->args) are retrieved from the stack to store data,
6634 * its actual length and address (in that order).
6637 parse_string(struct context *ctx, const struct token *token,
6638 const char *str, unsigned int len,
6639 void *buf, unsigned int size)
6641 const struct arg *arg_data = pop_args(ctx);
6642 const struct arg *arg_len = pop_args(ctx);
6643 const struct arg *arg_addr = pop_args(ctx);
6644 char tmp[16]; /* Ought to be enough. */
6647 /* Arguments are expected. */
6651 push_args(ctx, arg_data);
6655 push_args(ctx, arg_len);
6656 push_args(ctx, arg_data);
6659 size = arg_data->size;
6660 /* Bit-mask fill is not supported. */
6661 if (arg_data->mask || size < len)
6665 /* Let parse_int() fill length information first. */
6666 ret = snprintf(tmp, sizeof(tmp), "%u", len);
6669 push_args(ctx, arg_len);
6670 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
6675 buf = (uint8_t *)ctx->object + arg_data->offset;
6676 /* Output buffer is not necessarily NUL-terminated. */
6677 memcpy(buf, str, len);
6678 memset((uint8_t *)buf + len, 0x00, size - len);
6680 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
6681 /* Save address if requested. */
6682 if (arg_addr->size) {
6683 memcpy((uint8_t *)ctx->object + arg_addr->offset,
6685 (uint8_t *)ctx->object + arg_data->offset
6689 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
6691 (uint8_t *)ctx->objmask + arg_data->offset
6697 push_args(ctx, arg_addr);
6698 push_args(ctx, arg_len);
6699 push_args(ctx, arg_data);
6704 parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
6710 /* Check input parameters */
6711 if ((src == NULL) ||
6717 /* Convert chars to bytes */
6718 for (i = 0, len = 0; i < *size; i += 2) {
6719 snprintf(tmp, 3, "%s", src + i);
6720 dst[len++] = strtoul(tmp, &c, 16);
6735 parse_hex(struct context *ctx, const struct token *token,
6736 const char *str, unsigned int len,
6737 void *buf, unsigned int size)
6739 const struct arg *arg_data = pop_args(ctx);
6740 const struct arg *arg_len = pop_args(ctx);
6741 const struct arg *arg_addr = pop_args(ctx);
6742 char tmp[16]; /* Ought to be enough. */
6744 unsigned int hexlen = len;
6745 unsigned int length = 256;
6746 uint8_t hex_tmp[length];
6748 /* Arguments are expected. */
6752 push_args(ctx, arg_data);
6756 push_args(ctx, arg_len);
6757 push_args(ctx, arg_data);
6760 size = arg_data->size;
6761 /* Bit-mask fill is not supported. */
6767 /* translate bytes string to array. */
6768 if (str[0] == '0' && ((str[1] == 'x') ||
6773 if (hexlen > length)
6775 ret = parse_hex_string(str, hex_tmp, &hexlen);
6778 /* Let parse_int() fill length information first. */
6779 ret = snprintf(tmp, sizeof(tmp), "%u", hexlen);
6782 /* Save length if requested. */
6783 if (arg_len->size) {
6784 push_args(ctx, arg_len);
6785 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
6791 buf = (uint8_t *)ctx->object + arg_data->offset;
6792 /* Output buffer is not necessarily NUL-terminated. */
6793 memcpy(buf, hex_tmp, hexlen);
6794 memset((uint8_t *)buf + hexlen, 0x00, size - hexlen);
6796 memset((uint8_t *)ctx->objmask + arg_data->offset,
6798 /* Save address if requested. */
6799 if (arg_addr->size) {
6800 memcpy((uint8_t *)ctx->object + arg_addr->offset,
6802 (uint8_t *)ctx->object + arg_data->offset
6806 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
6808 (uint8_t *)ctx->objmask + arg_data->offset
6814 push_args(ctx, arg_addr);
6815 push_args(ctx, arg_len);
6816 push_args(ctx, arg_data);
6822 * Parse a zero-ended string.
6825 parse_string0(struct context *ctx, const struct token *token __rte_unused,
6826 const char *str, unsigned int len,
6827 void *buf, unsigned int size)
6829 const struct arg *arg_data = pop_args(ctx);
6831 /* Arguments are expected. */
6834 size = arg_data->size;
6835 /* Bit-mask fill is not supported. */
6836 if (arg_data->mask || size < len + 1)
6840 buf = (uint8_t *)ctx->object + arg_data->offset;
6841 strncpy(buf, str, len);
6843 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
6846 push_args(ctx, arg_data);
6851 * Parse a MAC address.
6853 * Last argument (ctx->args) is retrieved to determine storage size and
6857 parse_mac_addr(struct context *ctx, const struct token *token,
6858 const char *str, unsigned int len,
6859 void *buf, unsigned int size)
6861 const struct arg *arg = pop_args(ctx);
6862 struct rte_ether_addr tmp;
6866 /* Argument is expected. */
6870 /* Bit-mask fill is not supported. */
6871 if (arg->mask || size != sizeof(tmp))
6873 /* Only network endian is supported. */
6876 ret = cmdline_parse_etheraddr(NULL, str, &tmp, size);
6877 if (ret < 0 || (unsigned int)ret != len)
6881 buf = (uint8_t *)ctx->object + arg->offset;
6882 memcpy(buf, &tmp, size);
6884 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6887 push_args(ctx, arg);
6892 * Parse an IPv4 address.
6894 * Last argument (ctx->args) is retrieved to determine storage size and
6898 parse_ipv4_addr(struct context *ctx, const struct token *token,
6899 const char *str, unsigned int len,
6900 void *buf, unsigned int size)
6902 const struct arg *arg = pop_args(ctx);
6907 /* Argument is expected. */
6911 /* Bit-mask fill is not supported. */
6912 if (arg->mask || size != sizeof(tmp))
6914 /* Only network endian is supported. */
6917 memcpy(str2, str, len);
6919 ret = inet_pton(AF_INET, str2, &tmp);
6921 /* Attempt integer parsing. */
6922 push_args(ctx, arg);
6923 return parse_int(ctx, token, str, len, buf, size);
6927 buf = (uint8_t *)ctx->object + arg->offset;
6928 memcpy(buf, &tmp, size);
6930 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6933 push_args(ctx, arg);
6938 * Parse an IPv6 address.
6940 * Last argument (ctx->args) is retrieved to determine storage size and
6944 parse_ipv6_addr(struct context *ctx, const struct token *token,
6945 const char *str, unsigned int len,
6946 void *buf, unsigned int size)
6948 const struct arg *arg = pop_args(ctx);
6950 struct in6_addr tmp;
6954 /* Argument is expected. */
6958 /* Bit-mask fill is not supported. */
6959 if (arg->mask || size != sizeof(tmp))
6961 /* Only network endian is supported. */
6964 memcpy(str2, str, len);
6966 ret = inet_pton(AF_INET6, str2, &tmp);
6971 buf = (uint8_t *)ctx->object + arg->offset;
6972 memcpy(buf, &tmp, size);
6974 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6977 push_args(ctx, arg);
6981 /** Boolean values (even indices stand for false). */
6982 static const char *const boolean_name[] = {
6992 * Parse a boolean value.
6994 * Last argument (ctx->args) is retrieved to determine storage size and
6998 parse_boolean(struct context *ctx, const struct token *token,
6999 const char *str, unsigned int len,
7000 void *buf, unsigned int size)
7002 const struct arg *arg = pop_args(ctx);
7006 /* Argument is expected. */
7009 for (i = 0; boolean_name[i]; ++i)
7010 if (!strcmp_partial(boolean_name[i], str, len))
7012 /* Process token as integer. */
7013 if (boolean_name[i])
7014 str = i & 1 ? "1" : "0";
7015 push_args(ctx, arg);
7016 ret = parse_int(ctx, token, str, strlen(str), buf, size);
7017 return ret > 0 ? (int)len : ret;
7020 /** Parse port and update context. */
7022 parse_port(struct context *ctx, const struct token *token,
7023 const char *str, unsigned int len,
7024 void *buf, unsigned int size)
7026 struct buffer *out = &(struct buffer){ .port = 0 };
7034 ctx->objmask = NULL;
7035 size = sizeof(*out);
7037 ret = parse_int(ctx, token, str, len, out, size);
7039 ctx->port = out->port;
7046 parse_sa_id2ptr(struct context *ctx, const struct token *token,
7047 const char *str, unsigned int len,
7048 void *buf, unsigned int size)
7050 struct rte_flow_action *action = ctx->object;
7058 ctx->objmask = NULL;
7059 ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
7060 ctx->object = action;
7061 if (ret != (int)len)
7063 /* set shared action */
7065 action->conf = port_shared_action_get_by_id(ctx->port, id);
7066 ret = (action->conf) ? ret : -1;
7071 /** Parse set command, initialize output buffer for subsequent tokens. */
7073 parse_set_raw_encap_decap(struct context *ctx, const struct token *token,
7074 const char *str, unsigned int len,
7075 void *buf, unsigned int size)
7077 struct buffer *out = buf;
7079 /* Token name must match. */
7080 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7082 /* Nothing else to do if there is no buffer. */
7085 /* Make sure buffer is large enough. */
7086 if (size < sizeof(*out))
7089 ctx->objmask = NULL;
7093 out->command = ctx->curr;
7094 /* For encap/decap we need is pattern */
7095 out->args.vc.pattern = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7100 /** Parse set command, initialize output buffer for subsequent tokens. */
7102 parse_set_sample_action(struct context *ctx, const struct token *token,
7103 const char *str, unsigned int len,
7104 void *buf, unsigned int size)
7106 struct buffer *out = buf;
7108 /* Token name must match. */
7109 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7111 /* Nothing else to do if there is no buffer. */
7114 /* Make sure buffer is large enough. */
7115 if (size < sizeof(*out))
7118 ctx->objmask = NULL;
7122 out->command = ctx->curr;
7123 /* For sampler we need is actions */
7124 out->args.vc.actions = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7130 * Parse set raw_encap/raw_decap command,
7131 * initialize output buffer for subsequent tokens.
7134 parse_set_init(struct context *ctx, const struct token *token,
7135 const char *str, unsigned int len,
7136 void *buf, unsigned int size)
7138 struct buffer *out = buf;
7140 /* Token name must match. */
7141 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7143 /* Nothing else to do if there is no buffer. */
7146 /* Make sure buffer is large enough. */
7147 if (size < sizeof(*out))
7149 /* Initialize buffer. */
7150 memset(out, 0x00, sizeof(*out));
7151 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
7154 ctx->objmask = NULL;
7155 if (!out->command) {
7156 if (ctx->curr != SET)
7158 if (sizeof(*out) > size)
7160 out->command = ctx->curr;
7161 out->args.vc.data = (uint8_t *)out + size;
7162 ctx->object = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7168 /** No completion. */
7170 comp_none(struct context *ctx, const struct token *token,
7171 unsigned int ent, char *buf, unsigned int size)
7181 /** Complete boolean values. */
7183 comp_boolean(struct context *ctx, const struct token *token,
7184 unsigned int ent, char *buf, unsigned int size)
7190 for (i = 0; boolean_name[i]; ++i)
7191 if (buf && i == ent)
7192 return strlcpy(buf, boolean_name[i], size);
7198 /** Complete action names. */
7200 comp_action(struct context *ctx, const struct token *token,
7201 unsigned int ent, char *buf, unsigned int size)
7207 for (i = 0; next_action[i]; ++i)
7208 if (buf && i == ent)
7209 return strlcpy(buf, token_list[next_action[i]].name,
7216 /** Complete available ports. */
7218 comp_port(struct context *ctx, const struct token *token,
7219 unsigned int ent, char *buf, unsigned int size)
7226 RTE_ETH_FOREACH_DEV(p) {
7227 if (buf && i == ent)
7228 return snprintf(buf, size, "%u", p);
7236 /** Complete available rule IDs. */
7238 comp_rule_id(struct context *ctx, const struct token *token,
7239 unsigned int ent, char *buf, unsigned int size)
7242 struct rte_port *port;
7243 struct port_flow *pf;
7246 if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
7247 ctx->port == (portid_t)RTE_PORT_ALL)
7249 port = &ports[ctx->port];
7250 for (pf = port->flow_list; pf != NULL; pf = pf->next) {
7251 if (buf && i == ent)
7252 return snprintf(buf, size, "%u", pf->id);
7260 /** Complete type field for RSS action. */
7262 comp_vc_action_rss_type(struct context *ctx, const struct token *token,
7263 unsigned int ent, char *buf, unsigned int size)
7269 for (i = 0; rss_type_table[i].str; ++i)
7274 return strlcpy(buf, rss_type_table[ent].str, size);
7276 return snprintf(buf, size, "end");
7280 /** Complete queue field for RSS action. */
7282 comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
7283 unsigned int ent, char *buf, unsigned int size)
7290 return snprintf(buf, size, "%u", ent);
7292 return snprintf(buf, size, "end");
7296 /** Complete index number for set raw_encap/raw_decap commands. */
7298 comp_set_raw_index(struct context *ctx, const struct token *token,
7299 unsigned int ent, char *buf, unsigned int size)
7305 RTE_SET_USED(token);
7306 for (idx = 0; idx < RAW_ENCAP_CONFS_MAX_NUM; ++idx) {
7307 if (buf && idx == ent)
7308 return snprintf(buf, size, "%u", idx);
7314 /** Complete index number for set raw_encap/raw_decap commands. */
7316 comp_set_sample_index(struct context *ctx, const struct token *token,
7317 unsigned int ent, char *buf, unsigned int size)
7323 RTE_SET_USED(token);
7324 for (idx = 0; idx < RAW_SAMPLE_CONFS_MAX_NUM; ++idx) {
7325 if (buf && idx == ent)
7326 return snprintf(buf, size, "%u", idx);
7332 /** Complete operation for modify_field command. */
7334 comp_set_modify_field_op(struct context *ctx, const struct token *token,
7335 unsigned int ent, char *buf, unsigned int size)
7340 RTE_SET_USED(token);
7341 for (idx = 0; modify_field_ops[idx]; ++idx)
7346 return strlcpy(buf, modify_field_ops[ent], size);
7350 /** Complete field id for modify_field command. */
7352 comp_set_modify_field_id(struct context *ctx, const struct token *token,
7353 unsigned int ent, char *buf, unsigned int size)
7358 RTE_SET_USED(token);
7359 for (idx = 0; modify_field_ids[idx]; ++idx)
7364 return strlcpy(buf, modify_field_ids[ent], size);
7368 /** Internal context. */
7369 static struct context cmd_flow_context;
7371 /** Global parser instance (cmdline API). */
7372 cmdline_parse_inst_t cmd_flow;
7373 cmdline_parse_inst_t cmd_set_raw;
7375 /** Initialize context. */
7377 cmd_flow_context_init(struct context *ctx)
7379 /* A full memset() is not necessary. */
7389 ctx->objmask = NULL;
7392 /** Parse a token (cmdline API). */
7394 cmd_flow_parse(cmdline_parse_token_hdr_t *hdr, const char *src, void *result,
7397 struct context *ctx = &cmd_flow_context;
7398 const struct token *token;
7399 const enum index *list;
7404 token = &token_list[ctx->curr];
7405 /* Check argument length. */
7408 for (len = 0; src[len]; ++len)
7409 if (src[len] == '#' || isspace(src[len]))
7413 /* Last argument and EOL detection. */
7414 for (i = len; src[i]; ++i)
7415 if (src[i] == '#' || src[i] == '\r' || src[i] == '\n')
7417 else if (!isspace(src[i])) {
7422 if (src[i] == '\r' || src[i] == '\n') {
7426 /* Initialize context if necessary. */
7427 if (!ctx->next_num) {
7430 ctx->next[ctx->next_num++] = token->next[0];
7432 /* Process argument through candidates. */
7433 ctx->prev = ctx->curr;
7434 list = ctx->next[ctx->next_num - 1];
7435 for (i = 0; list[i]; ++i) {
7436 const struct token *next = &token_list[list[i]];
7439 ctx->curr = list[i];
7441 tmp = next->call(ctx, next, src, len, result, size);
7443 tmp = parse_default(ctx, next, src, len, result, size);
7444 if (tmp == -1 || tmp != len)
7452 /* Push subsequent tokens if any. */
7454 for (i = 0; token->next[i]; ++i) {
7455 if (ctx->next_num == RTE_DIM(ctx->next))
7457 ctx->next[ctx->next_num++] = token->next[i];
7459 /* Push arguments if any. */
7461 for (i = 0; token->args[i]; ++i) {
7462 if (ctx->args_num == RTE_DIM(ctx->args))
7464 ctx->args[ctx->args_num++] = token->args[i];
7469 /** Return number of completion entries (cmdline API). */
7471 cmd_flow_complete_get_nb(cmdline_parse_token_hdr_t *hdr)
7473 struct context *ctx = &cmd_flow_context;
7474 const struct token *token = &token_list[ctx->curr];
7475 const enum index *list;
7479 /* Count number of tokens in current list. */
7481 list = ctx->next[ctx->next_num - 1];
7483 list = token->next[0];
7484 for (i = 0; list[i]; ++i)
7489 * If there is a single token, use its completion callback, otherwise
7490 * return the number of entries.
7492 token = &token_list[list[0]];
7493 if (i == 1 && token->comp) {
7494 /* Save index for cmd_flow_get_help(). */
7495 ctx->prev = list[0];
7496 return token->comp(ctx, token, 0, NULL, 0);
7501 /** Return a completion entry (cmdline API). */
7503 cmd_flow_complete_get_elt(cmdline_parse_token_hdr_t *hdr, int index,
7504 char *dst, unsigned int size)
7506 struct context *ctx = &cmd_flow_context;
7507 const struct token *token = &token_list[ctx->curr];
7508 const enum index *list;
7512 /* Count number of tokens in current list. */
7514 list = ctx->next[ctx->next_num - 1];
7516 list = token->next[0];
7517 for (i = 0; list[i]; ++i)
7521 /* If there is a single token, use its completion callback. */
7522 token = &token_list[list[0]];
7523 if (i == 1 && token->comp) {
7524 /* Save index for cmd_flow_get_help(). */
7525 ctx->prev = list[0];
7526 return token->comp(ctx, token, index, dst, size) < 0 ? -1 : 0;
7528 /* Otherwise make sure the index is valid and use defaults. */
7531 token = &token_list[list[index]];
7532 strlcpy(dst, token->name, size);
7533 /* Save index for cmd_flow_get_help(). */
7534 ctx->prev = list[index];
7538 /** Populate help strings for current token (cmdline API). */
7540 cmd_flow_get_help(cmdline_parse_token_hdr_t *hdr, char *dst, unsigned int size)
7542 struct context *ctx = &cmd_flow_context;
7543 const struct token *token = &token_list[ctx->prev];
7548 /* Set token type and update global help with details. */
7549 strlcpy(dst, (token->type ? token->type : "TOKEN"), size);
7551 cmd_flow.help_str = token->help;
7553 cmd_flow.help_str = token->name;
7557 /** Token definition template (cmdline API). */
7558 static struct cmdline_token_hdr cmd_flow_token_hdr = {
7559 .ops = &(struct cmdline_token_ops){
7560 .parse = cmd_flow_parse,
7561 .complete_get_nb = cmd_flow_complete_get_nb,
7562 .complete_get_elt = cmd_flow_complete_get_elt,
7563 .get_help = cmd_flow_get_help,
7568 /** Populate the next dynamic token. */
7570 cmd_flow_tok(cmdline_parse_token_hdr_t **hdr,
7571 cmdline_parse_token_hdr_t **hdr_inst)
7573 struct context *ctx = &cmd_flow_context;
7575 /* Always reinitialize context before requesting the first token. */
7576 if (!(hdr_inst - cmd_flow.tokens))
7577 cmd_flow_context_init(ctx);
7578 /* Return NULL when no more tokens are expected. */
7579 if (!ctx->next_num && ctx->curr) {
7583 /* Determine if command should end here. */
7584 if (ctx->eol && ctx->last && ctx->next_num) {
7585 const enum index *list = ctx->next[ctx->next_num - 1];
7588 for (i = 0; list[i]; ++i) {
7595 *hdr = &cmd_flow_token_hdr;
7598 /** Dispatch parsed buffer to function calls. */
7600 cmd_flow_parsed(const struct buffer *in)
7602 switch (in->command) {
7603 case SHARED_ACTION_CREATE:
7604 port_shared_action_create(
7605 in->port, in->args.vc.attr.group,
7606 &((const struct rte_flow_shared_action_conf) {
7607 .ingress = in->args.vc.attr.ingress,
7608 .egress = in->args.vc.attr.egress,
7609 .transfer = in->args.vc.attr.transfer,
7611 in->args.vc.actions);
7613 case SHARED_ACTION_DESTROY:
7614 port_shared_action_destroy(in->port,
7615 in->args.sa_destroy.action_id_n,
7616 in->args.sa_destroy.action_id);
7618 case SHARED_ACTION_UPDATE:
7619 port_shared_action_update(in->port, in->args.vc.attr.group,
7620 in->args.vc.actions);
7622 case SHARED_ACTION_QUERY:
7623 port_shared_action_query(in->port, in->args.sa.action_id);
7626 port_flow_validate(in->port, &in->args.vc.attr,
7627 in->args.vc.pattern, in->args.vc.actions,
7628 &in->args.vc.tunnel_ops);
7631 port_flow_create(in->port, &in->args.vc.attr,
7632 in->args.vc.pattern, in->args.vc.actions,
7633 &in->args.vc.tunnel_ops);
7636 port_flow_destroy(in->port, in->args.destroy.rule_n,
7637 in->args.destroy.rule);
7640 port_flow_flush(in->port);
7643 port_flow_dump(in->port, in->args.dump.file);
7646 port_flow_query(in->port, in->args.query.rule,
7647 &in->args.query.action);
7650 port_flow_list(in->port, in->args.list.group_n,
7651 in->args.list.group);
7654 port_flow_isolate(in->port, in->args.isolate.set);
7657 port_flow_aged(in->port, in->args.aged.destroy);
7660 port_flow_tunnel_create(in->port, &in->args.vc.tunnel_ops);
7662 case TUNNEL_DESTROY:
7663 port_flow_tunnel_destroy(in->port, in->args.vc.tunnel_ops.id);
7666 port_flow_tunnel_list(in->port);
7673 /** Token generator and output processing callback (cmdline API). */
7675 cmd_flow_cb(void *arg0, struct cmdline *cl, void *arg2)
7678 cmd_flow_tok(arg0, arg2);
7680 cmd_flow_parsed(arg0);
7683 /** Global parser instance (cmdline API). */
7684 cmdline_parse_inst_t cmd_flow = {
7686 .data = NULL, /**< Unused. */
7687 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
7690 }, /**< Tokens are returned by cmd_flow_tok(). */
7693 /** set cmd facility. Reuse cmd flow's infrastructure as much as possible. */
7696 update_fields(uint8_t *buf, struct rte_flow_item *item, uint16_t next_proto)
7698 struct rte_ipv4_hdr *ipv4;
7699 struct rte_ether_hdr *eth;
7700 struct rte_ipv6_hdr *ipv6;
7701 struct rte_vxlan_hdr *vxlan;
7702 struct rte_vxlan_gpe_hdr *gpe;
7703 struct rte_flow_item_nvgre *nvgre;
7704 uint32_t ipv6_vtc_flow;
7706 switch (item->type) {
7707 case RTE_FLOW_ITEM_TYPE_ETH:
7708 eth = (struct rte_ether_hdr *)buf;
7710 eth->ether_type = rte_cpu_to_be_16(next_proto);
7712 case RTE_FLOW_ITEM_TYPE_IPV4:
7713 ipv4 = (struct rte_ipv4_hdr *)buf;
7714 ipv4->version_ihl = 0x45;
7715 if (next_proto && ipv4->next_proto_id == 0)
7716 ipv4->next_proto_id = (uint8_t)next_proto;
7718 case RTE_FLOW_ITEM_TYPE_IPV6:
7719 ipv6 = (struct rte_ipv6_hdr *)buf;
7720 if (next_proto && ipv6->proto == 0)
7721 ipv6->proto = (uint8_t)next_proto;
7722 ipv6_vtc_flow = rte_be_to_cpu_32(ipv6->vtc_flow);
7723 ipv6_vtc_flow &= 0x0FFFFFFF; /*< reset version bits. */
7724 ipv6_vtc_flow |= 0x60000000; /*< set ipv6 version. */
7725 ipv6->vtc_flow = rte_cpu_to_be_32(ipv6_vtc_flow);
7727 case RTE_FLOW_ITEM_TYPE_VXLAN:
7728 vxlan = (struct rte_vxlan_hdr *)buf;
7729 vxlan->vx_flags = 0x08;
7731 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
7732 gpe = (struct rte_vxlan_gpe_hdr *)buf;
7733 gpe->vx_flags = 0x0C;
7735 case RTE_FLOW_ITEM_TYPE_NVGRE:
7736 nvgre = (struct rte_flow_item_nvgre *)buf;
7737 nvgre->protocol = rte_cpu_to_be_16(0x6558);
7738 nvgre->c_k_s_rsvd0_ver = rte_cpu_to_be_16(0x2000);
7745 /** Helper of get item's default mask. */
7747 flow_item_default_mask(const struct rte_flow_item *item)
7749 const void *mask = NULL;
7750 static rte_be32_t gre_key_default_mask = RTE_BE32(UINT32_MAX);
7752 switch (item->type) {
7753 case RTE_FLOW_ITEM_TYPE_ANY:
7754 mask = &rte_flow_item_any_mask;
7756 case RTE_FLOW_ITEM_TYPE_VF:
7757 mask = &rte_flow_item_vf_mask;
7759 case RTE_FLOW_ITEM_TYPE_PORT_ID:
7760 mask = &rte_flow_item_port_id_mask;
7762 case RTE_FLOW_ITEM_TYPE_RAW:
7763 mask = &rte_flow_item_raw_mask;
7765 case RTE_FLOW_ITEM_TYPE_ETH:
7766 mask = &rte_flow_item_eth_mask;
7768 case RTE_FLOW_ITEM_TYPE_VLAN:
7769 mask = &rte_flow_item_vlan_mask;
7771 case RTE_FLOW_ITEM_TYPE_IPV4:
7772 mask = &rte_flow_item_ipv4_mask;
7774 case RTE_FLOW_ITEM_TYPE_IPV6:
7775 mask = &rte_flow_item_ipv6_mask;
7777 case RTE_FLOW_ITEM_TYPE_ICMP:
7778 mask = &rte_flow_item_icmp_mask;
7780 case RTE_FLOW_ITEM_TYPE_UDP:
7781 mask = &rte_flow_item_udp_mask;
7783 case RTE_FLOW_ITEM_TYPE_TCP:
7784 mask = &rte_flow_item_tcp_mask;
7786 case RTE_FLOW_ITEM_TYPE_SCTP:
7787 mask = &rte_flow_item_sctp_mask;
7789 case RTE_FLOW_ITEM_TYPE_VXLAN:
7790 mask = &rte_flow_item_vxlan_mask;
7792 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
7793 mask = &rte_flow_item_vxlan_gpe_mask;
7795 case RTE_FLOW_ITEM_TYPE_E_TAG:
7796 mask = &rte_flow_item_e_tag_mask;
7798 case RTE_FLOW_ITEM_TYPE_NVGRE:
7799 mask = &rte_flow_item_nvgre_mask;
7801 case RTE_FLOW_ITEM_TYPE_MPLS:
7802 mask = &rte_flow_item_mpls_mask;
7804 case RTE_FLOW_ITEM_TYPE_GRE:
7805 mask = &rte_flow_item_gre_mask;
7807 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
7808 mask = &gre_key_default_mask;
7810 case RTE_FLOW_ITEM_TYPE_META:
7811 mask = &rte_flow_item_meta_mask;
7813 case RTE_FLOW_ITEM_TYPE_FUZZY:
7814 mask = &rte_flow_item_fuzzy_mask;
7816 case RTE_FLOW_ITEM_TYPE_GTP:
7817 mask = &rte_flow_item_gtp_mask;
7819 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
7820 mask = &rte_flow_item_gtp_psc_mask;
7822 case RTE_FLOW_ITEM_TYPE_GENEVE:
7823 mask = &rte_flow_item_geneve_mask;
7825 case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
7826 mask = &rte_flow_item_geneve_opt_mask;
7828 case RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID:
7829 mask = &rte_flow_item_pppoe_proto_id_mask;
7831 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
7832 mask = &rte_flow_item_l2tpv3oip_mask;
7834 case RTE_FLOW_ITEM_TYPE_ESP:
7835 mask = &rte_flow_item_esp_mask;
7837 case RTE_FLOW_ITEM_TYPE_AH:
7838 mask = &rte_flow_item_ah_mask;
7840 case RTE_FLOW_ITEM_TYPE_PFCP:
7841 mask = &rte_flow_item_pfcp_mask;
7849 /** Dispatch parsed buffer to function calls. */
7851 cmd_set_raw_parsed_sample(const struct buffer *in)
7853 uint32_t n = in->args.vc.actions_n;
7855 struct rte_flow_action *action = NULL;
7856 struct rte_flow_action *data = NULL;
7857 const struct rte_flow_action_rss *rss = NULL;
7859 uint16_t idx = in->port; /* We borrow port field as index */
7860 uint32_t max_size = sizeof(struct rte_flow_action) *
7861 ACTION_SAMPLE_ACTIONS_NUM;
7863 RTE_ASSERT(in->command == SET_SAMPLE_ACTIONS);
7864 data = (struct rte_flow_action *)&raw_sample_confs[idx].data;
7865 memset(data, 0x00, max_size);
7866 for (; i <= n - 1; i++) {
7867 action = in->args.vc.actions + i;
7868 if (action->type == RTE_FLOW_ACTION_TYPE_END)
7870 switch (action->type) {
7871 case RTE_FLOW_ACTION_TYPE_MARK:
7872 size = sizeof(struct rte_flow_action_mark);
7873 rte_memcpy(&sample_mark[idx],
7874 (const void *)action->conf, size);
7875 action->conf = &sample_mark[idx];
7877 case RTE_FLOW_ACTION_TYPE_COUNT:
7878 size = sizeof(struct rte_flow_action_count);
7879 rte_memcpy(&sample_count[idx],
7880 (const void *)action->conf, size);
7881 action->conf = &sample_count[idx];
7883 case RTE_FLOW_ACTION_TYPE_QUEUE:
7884 size = sizeof(struct rte_flow_action_queue);
7885 rte_memcpy(&sample_queue[idx],
7886 (const void *)action->conf, size);
7887 action->conf = &sample_queue[idx];
7889 case RTE_FLOW_ACTION_TYPE_RSS:
7890 size = sizeof(struct rte_flow_action_rss);
7892 rte_memcpy(&sample_rss_data[idx].conf,
7893 (const void *)rss, size);
7894 if (rss->key_len && rss->key) {
7895 sample_rss_data[idx].conf.key =
7896 sample_rss_data[idx].key;
7897 rte_memcpy((void *)((uintptr_t)
7898 sample_rss_data[idx].conf.key),
7899 (const void *)rss->key,
7900 sizeof(uint8_t) * rss->key_len);
7902 if (rss->queue_num && rss->queue) {
7903 sample_rss_data[idx].conf.queue =
7904 sample_rss_data[idx].queue;
7905 rte_memcpy((void *)((uintptr_t)
7906 sample_rss_data[idx].conf.queue),
7907 (const void *)rss->queue,
7908 sizeof(uint16_t) * rss->queue_num);
7910 action->conf = &sample_rss_data[idx].conf;
7912 case RTE_FLOW_ACTION_TYPE_RAW_ENCAP:
7913 size = sizeof(struct rte_flow_action_raw_encap);
7914 rte_memcpy(&sample_encap[idx],
7915 (const void *)action->conf, size);
7916 action->conf = &sample_encap[idx];
7918 case RTE_FLOW_ACTION_TYPE_PORT_ID:
7919 size = sizeof(struct rte_flow_action_port_id);
7920 rte_memcpy(&sample_port_id[idx],
7921 (const void *)action->conf, size);
7922 action->conf = &sample_port_id[idx];
7924 case RTE_FLOW_ACTION_TYPE_PF:
7926 case RTE_FLOW_ACTION_TYPE_VF:
7927 size = sizeof(struct rte_flow_action_vf);
7928 rte_memcpy(&sample_vf[idx],
7929 (const void *)action->conf, size);
7930 action->conf = &sample_vf[idx];
7933 printf("Error - Not supported action\n");
7936 rte_memcpy(data, action, sizeof(struct rte_flow_action));
7941 /** Dispatch parsed buffer to function calls. */
7943 cmd_set_raw_parsed(const struct buffer *in)
7945 uint32_t n = in->args.vc.pattern_n;
7947 struct rte_flow_item *item = NULL;
7949 uint8_t *data = NULL;
7950 uint8_t *data_tail = NULL;
7951 size_t *total_size = NULL;
7952 uint16_t upper_layer = 0;
7954 uint16_t idx = in->port; /* We borrow port field as index */
7955 int gtp_psc = -1; /* GTP PSC option index. */
7957 if (in->command == SET_SAMPLE_ACTIONS)
7958 return cmd_set_raw_parsed_sample(in);
7959 RTE_ASSERT(in->command == SET_RAW_ENCAP ||
7960 in->command == SET_RAW_DECAP);
7961 if (in->command == SET_RAW_ENCAP) {
7962 total_size = &raw_encap_confs[idx].size;
7963 data = (uint8_t *)&raw_encap_confs[idx].data;
7965 total_size = &raw_decap_confs[idx].size;
7966 data = (uint8_t *)&raw_decap_confs[idx].data;
7969 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
7970 /* process hdr from upper layer to low layer (L3/L4 -> L2). */
7971 data_tail = data + ACTION_RAW_ENCAP_MAX_DATA;
7972 for (i = n - 1 ; i >= 0; --i) {
7973 const struct rte_flow_item_gtp *gtp;
7974 const struct rte_flow_item_geneve_opt *opt;
7976 item = in->args.vc.pattern + i;
7977 if (item->spec == NULL)
7978 item->spec = flow_item_default_mask(item);
7979 switch (item->type) {
7980 case RTE_FLOW_ITEM_TYPE_ETH:
7981 size = sizeof(struct rte_ether_hdr);
7983 case RTE_FLOW_ITEM_TYPE_VLAN:
7984 size = sizeof(struct rte_vlan_hdr);
7985 proto = RTE_ETHER_TYPE_VLAN;
7987 case RTE_FLOW_ITEM_TYPE_IPV4:
7988 size = sizeof(struct rte_ipv4_hdr);
7989 proto = RTE_ETHER_TYPE_IPV4;
7991 case RTE_FLOW_ITEM_TYPE_IPV6:
7992 size = sizeof(struct rte_ipv6_hdr);
7993 proto = RTE_ETHER_TYPE_IPV6;
7995 case RTE_FLOW_ITEM_TYPE_UDP:
7996 size = sizeof(struct rte_udp_hdr);
7999 case RTE_FLOW_ITEM_TYPE_TCP:
8000 size = sizeof(struct rte_tcp_hdr);
8003 case RTE_FLOW_ITEM_TYPE_VXLAN:
8004 size = sizeof(struct rte_vxlan_hdr);
8006 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
8007 size = sizeof(struct rte_vxlan_gpe_hdr);
8009 case RTE_FLOW_ITEM_TYPE_GRE:
8010 size = sizeof(struct rte_gre_hdr);
8013 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
8014 size = sizeof(rte_be32_t);
8017 case RTE_FLOW_ITEM_TYPE_MPLS:
8018 size = sizeof(struct rte_mpls_hdr);
8021 case RTE_FLOW_ITEM_TYPE_NVGRE:
8022 size = sizeof(struct rte_flow_item_nvgre);
8025 case RTE_FLOW_ITEM_TYPE_GENEVE:
8026 size = sizeof(struct rte_geneve_hdr);
8028 case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
8029 opt = (const struct rte_flow_item_geneve_opt *)
8031 size = offsetof(struct rte_flow_item_geneve_opt, data);
8032 if (opt->option_len && opt->data) {
8033 *total_size += opt->option_len *
8035 rte_memcpy(data_tail - (*total_size),
8037 opt->option_len * sizeof(uint32_t));
8040 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
8041 size = sizeof(rte_be32_t);
8044 case RTE_FLOW_ITEM_TYPE_ESP:
8045 size = sizeof(struct rte_esp_hdr);
8048 case RTE_FLOW_ITEM_TYPE_AH:
8049 size = sizeof(struct rte_flow_item_ah);
8052 case RTE_FLOW_ITEM_TYPE_GTP:
8054 size = sizeof(struct rte_gtp_hdr);
8057 if (gtp_psc != i + 1) {
8058 printf("Error - GTP PSC does not follow GTP\n");
8062 if ((gtp->v_pt_rsv_flags & 0x07) != 0x04) {
8063 /* Only E flag should be set. */
8064 printf("Error - GTP unsupported flags\n");
8067 struct rte_gtp_hdr_ext_word ext_word = {
8071 /* We have to add GTP header extra word. */
8072 *total_size += sizeof(ext_word);
8073 rte_memcpy(data_tail - (*total_size),
8074 &ext_word, sizeof(ext_word));
8076 size = sizeof(struct rte_gtp_hdr);
8078 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
8080 printf("Error - Multiple GTP PSC items\n");
8083 const struct rte_flow_item_gtp_psc
8092 if (opt->pdu_type & 0x0F) {
8093 /* Support the minimal option only. */
8094 printf("Error - GTP PSC option with "
8095 "extra fields not supported\n");
8098 psc.len = sizeof(psc);
8099 psc.pdu_type = opt->pdu_type;
8102 *total_size += sizeof(psc);
8103 rte_memcpy(data_tail - (*total_size),
8109 case RTE_FLOW_ITEM_TYPE_PFCP:
8110 size = sizeof(struct rte_flow_item_pfcp);
8113 printf("Error - Not supported item\n");
8116 *total_size += size;
8117 rte_memcpy(data_tail - (*total_size), item->spec, size);
8118 /* update some fields which cannot be set by cmdline */
8119 update_fields((data_tail - (*total_size)), item,
8121 upper_layer = proto;
8123 if (verbose_level & 0x1)
8124 printf("total data size is %zu\n", (*total_size));
8125 RTE_ASSERT((*total_size) <= ACTION_RAW_ENCAP_MAX_DATA);
8126 memmove(data, (data_tail - (*total_size)), *total_size);
8131 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
8134 /** Populate help strings for current token (cmdline API). */
8136 cmd_set_raw_get_help(cmdline_parse_token_hdr_t *hdr, char *dst,
8139 struct context *ctx = &cmd_flow_context;
8140 const struct token *token = &token_list[ctx->prev];
8145 /* Set token type and update global help with details. */
8146 snprintf(dst, size, "%s", (token->type ? token->type : "TOKEN"));
8148 cmd_set_raw.help_str = token->help;
8150 cmd_set_raw.help_str = token->name;
8154 /** Token definition template (cmdline API). */
8155 static struct cmdline_token_hdr cmd_set_raw_token_hdr = {
8156 .ops = &(struct cmdline_token_ops){
8157 .parse = cmd_flow_parse,
8158 .complete_get_nb = cmd_flow_complete_get_nb,
8159 .complete_get_elt = cmd_flow_complete_get_elt,
8160 .get_help = cmd_set_raw_get_help,
8165 /** Populate the next dynamic token. */
8167 cmd_set_raw_tok(cmdline_parse_token_hdr_t **hdr,
8168 cmdline_parse_token_hdr_t **hdr_inst)
8170 struct context *ctx = &cmd_flow_context;
8172 /* Always reinitialize context before requesting the first token. */
8173 if (!(hdr_inst - cmd_set_raw.tokens)) {
8174 cmd_flow_context_init(ctx);
8175 ctx->curr = START_SET;
8177 /* Return NULL when no more tokens are expected. */
8178 if (!ctx->next_num && (ctx->curr != START_SET)) {
8182 /* Determine if command should end here. */
8183 if (ctx->eol && ctx->last && ctx->next_num) {
8184 const enum index *list = ctx->next[ctx->next_num - 1];
8187 for (i = 0; list[i]; ++i) {
8194 *hdr = &cmd_set_raw_token_hdr;
8197 /** Token generator and output processing callback (cmdline API). */
8199 cmd_set_raw_cb(void *arg0, struct cmdline *cl, void *arg2)
8202 cmd_set_raw_tok(arg0, arg2);
8204 cmd_set_raw_parsed(arg0);
8207 /** Global parser instance (cmdline API). */
8208 cmdline_parse_inst_t cmd_set_raw = {
8209 .f = cmd_set_raw_cb,
8210 .data = NULL, /**< Unused. */
8211 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
8214 }, /**< Tokens are returned by cmd_flow_tok(). */
8217 /* *** display raw_encap/raw_decap buf */
8218 struct cmd_show_set_raw_result {
8219 cmdline_fixed_string_t cmd_show;
8220 cmdline_fixed_string_t cmd_what;
8221 cmdline_fixed_string_t cmd_all;
8226 cmd_show_set_raw_parsed(void *parsed_result, struct cmdline *cl, void *data)
8228 struct cmd_show_set_raw_result *res = parsed_result;
8229 uint16_t index = res->cmd_index;
8231 uint8_t *raw_data = NULL;
8232 size_t raw_size = 0;
8233 char title[16] = {0};
8237 if (!strcmp(res->cmd_all, "all")) {
8240 } else if (index >= RAW_ENCAP_CONFS_MAX_NUM) {
8241 printf("index should be 0-%u\n", RAW_ENCAP_CONFS_MAX_NUM - 1);
8245 if (!strcmp(res->cmd_what, "raw_encap")) {
8246 raw_data = (uint8_t *)&raw_encap_confs[index].data;
8247 raw_size = raw_encap_confs[index].size;
8248 snprintf(title, 16, "\nindex: %u", index);
8249 rte_hexdump(stdout, title, raw_data, raw_size);
8251 raw_data = (uint8_t *)&raw_decap_confs[index].data;
8252 raw_size = raw_decap_confs[index].size;
8253 snprintf(title, 16, "\nindex: %u", index);
8254 rte_hexdump(stdout, title, raw_data, raw_size);
8256 } while (all && ++index < RAW_ENCAP_CONFS_MAX_NUM);
8259 cmdline_parse_token_string_t cmd_show_set_raw_cmd_show =
8260 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
8262 cmdline_parse_token_string_t cmd_show_set_raw_cmd_what =
8263 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
8264 cmd_what, "raw_encap#raw_decap");
8265 cmdline_parse_token_num_t cmd_show_set_raw_cmd_index =
8266 TOKEN_NUM_INITIALIZER(struct cmd_show_set_raw_result,
8267 cmd_index, RTE_UINT16);
8268 cmdline_parse_token_string_t cmd_show_set_raw_cmd_all =
8269 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
8271 cmdline_parse_inst_t cmd_show_set_raw = {
8272 .f = cmd_show_set_raw_parsed,
8274 .help_str = "show <raw_encap|raw_decap> <index>",
8276 (void *)&cmd_show_set_raw_cmd_show,
8277 (void *)&cmd_show_set_raw_cmd_what,
8278 (void *)&cmd_show_set_raw_cmd_index,
8282 cmdline_parse_inst_t cmd_show_set_raw_all = {
8283 .f = cmd_show_set_raw_parsed,
8285 .help_str = "show <raw_encap|raw_decap> all",
8287 (void *)&cmd_show_set_raw_cmd_show,
8288 (void *)&cmd_show_set_raw_cmd_what,
8289 (void *)&cmd_show_set_raw_cmd_all,