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];
586 static const char *const modify_field_ops[] = {
587 "set", "add", "sub", NULL
590 static const char *const modify_field_ids[] = {
591 "start", "mac_dst", "mac_src",
592 "vlan_type", "vlan_id", "mac_type",
593 "ipv4_dscp", "ipv4_ttl", "ipv4_src", "ipv4_dst",
594 "ipv6_hoplimit", "ipv6_src", "ipv6_dst",
595 "tcp_port_src", "tcp_port_dst",
596 "tcp_seq_num", "tcp_ack_num", "tcp_flags",
597 "udp_port_src", "udp_port_dst",
598 "vxlan_vni", "geneve_vni", "gtp_teid",
599 "tag", "mark", "meta", "pointer", "value", NULL
602 /** Maximum number of subsequent tokens and arguments on the stack. */
603 #define CTX_STACK_SIZE 16
605 /** Parser context. */
607 /** Stack of subsequent token lists to process. */
608 const enum index *next[CTX_STACK_SIZE];
609 /** Arguments for stacked tokens. */
610 const void *args[CTX_STACK_SIZE];
611 enum index curr; /**< Current token index. */
612 enum index prev; /**< Index of the last token seen. */
613 int next_num; /**< Number of entries in next[]. */
614 int args_num; /**< Number of entries in args[]. */
615 uint32_t eol:1; /**< EOL has been detected. */
616 uint32_t last:1; /**< No more arguments. */
617 portid_t port; /**< Current port ID (for completions). */
618 uint32_t objdata; /**< Object-specific data. */
619 void *object; /**< Address of current object for relative offsets. */
620 void *objmask; /**< Object a full mask must be written to. */
623 /** Token argument. */
625 uint32_t hton:1; /**< Use network byte ordering. */
626 uint32_t sign:1; /**< Value is signed. */
627 uint32_t bounded:1; /**< Value is bounded. */
628 uintmax_t min; /**< Minimum value if bounded. */
629 uintmax_t max; /**< Maximum value if bounded. */
630 uint32_t offset; /**< Relative offset from ctx->object. */
631 uint32_t size; /**< Field size. */
632 const uint8_t *mask; /**< Bit-mask to use instead of offset/size. */
635 /** Parser token definition. */
637 /** Type displayed during completion (defaults to "TOKEN"). */
639 /** Help displayed during completion (defaults to token name). */
641 /** Private data used by parser functions. */
644 * Lists of subsequent tokens to push on the stack. Each call to the
645 * parser consumes the last entry of that stack.
647 const enum index *const *next;
648 /** Arguments stack for subsequent tokens that need them. */
649 const struct arg *const *args;
651 * Token-processing callback, returns -1 in case of error, the
652 * length of the matched string otherwise. If NULL, attempts to
653 * match the token name.
655 * If buf is not NULL, the result should be stored in it according
656 * to context. An error is returned if not large enough.
658 int (*call)(struct context *ctx, const struct token *token,
659 const char *str, unsigned int len,
660 void *buf, unsigned int size);
662 * Callback that provides possible values for this token, used for
663 * completion. Returns -1 in case of error, the number of possible
664 * values otherwise. If NULL, the token name is used.
666 * If buf is not NULL, entry index ent is written to buf and the
667 * full length of the entry is returned (same behavior as
670 int (*comp)(struct context *ctx, const struct token *token,
671 unsigned int ent, char *buf, unsigned int size);
672 /** Mandatory token name, no default value. */
676 /** Static initializer for the next field. */
677 #define NEXT(...) (const enum index *const []){ __VA_ARGS__, NULL, }
679 /** Static initializer for a NEXT() entry. */
680 #define NEXT_ENTRY(...) (const enum index []){ __VA_ARGS__, ZERO, }
682 /** Static initializer for the args field. */
683 #define ARGS(...) (const struct arg *const []){ __VA_ARGS__, NULL, }
685 /** Static initializer for ARGS() to target a field. */
686 #define ARGS_ENTRY(s, f) \
687 (&(const struct arg){ \
688 .offset = offsetof(s, f), \
689 .size = sizeof(((s *)0)->f), \
692 /** Static initializer for ARGS() to target a bit-field. */
693 #define ARGS_ENTRY_BF(s, f, b) \
694 (&(const struct arg){ \
696 .mask = (const void *)&(const s){ .f = (1 << (b)) - 1 }, \
699 /** Static initializer for ARGS() to target a field with limits. */
700 #define ARGS_ENTRY_BOUNDED(s, f, i, a) \
701 (&(const struct arg){ \
705 .offset = offsetof(s, f), \
706 .size = sizeof(((s *)0)->f), \
709 /** Static initializer for ARGS() to target an arbitrary bit-mask. */
710 #define ARGS_ENTRY_MASK(s, f, m) \
711 (&(const struct arg){ \
712 .offset = offsetof(s, f), \
713 .size = sizeof(((s *)0)->f), \
714 .mask = (const void *)(m), \
717 /** Same as ARGS_ENTRY_MASK() using network byte ordering for the value. */
718 #define ARGS_ENTRY_MASK_HTON(s, f, m) \
719 (&(const struct arg){ \
721 .offset = offsetof(s, f), \
722 .size = sizeof(((s *)0)->f), \
723 .mask = (const void *)(m), \
726 /** Static initializer for ARGS() to target a pointer. */
727 #define ARGS_ENTRY_PTR(s, f) \
728 (&(const struct arg){ \
729 .size = sizeof(*((s *)0)->f), \
732 /** Static initializer for ARGS() with arbitrary offset and size. */
733 #define ARGS_ENTRY_ARB(o, s) \
734 (&(const struct arg){ \
739 /** Same as ARGS_ENTRY_ARB() with bounded values. */
740 #define ARGS_ENTRY_ARB_BOUNDED(o, s, i, a) \
741 (&(const struct arg){ \
749 /** Same as ARGS_ENTRY() using network byte ordering. */
750 #define ARGS_ENTRY_HTON(s, f) \
751 (&(const struct arg){ \
753 .offset = offsetof(s, f), \
754 .size = sizeof(((s *)0)->f), \
757 /** Same as ARGS_ENTRY_HTON() for a single argument, without structure. */
758 #define ARG_ENTRY_HTON(s) \
759 (&(const struct arg){ \
765 /** Parser output buffer layout expected by cmd_flow_parsed(). */
767 enum index command; /**< Flow command. */
768 portid_t port; /**< Affected port ID. */
772 uint32_t action_id_n;
773 } sa_destroy; /**< Shared action destroy arguments. */
776 } sa; /* Shared action query arguments */
778 struct rte_flow_attr attr;
779 struct tunnel_ops tunnel_ops;
780 struct rte_flow_item *pattern;
781 struct rte_flow_action *actions;
785 } vc; /**< Validate/create arguments. */
789 } destroy; /**< Destroy arguments. */
792 } dump; /**< Dump arguments. */
795 struct rte_flow_action action;
796 } query; /**< Query arguments. */
800 } list; /**< List arguments. */
803 } isolate; /**< Isolated mode arguments. */
806 } aged; /**< Aged arguments. */
807 } args; /**< Command arguments. */
810 /** Private data for pattern items. */
811 struct parse_item_priv {
812 enum rte_flow_item_type type; /**< Item type. */
813 uint32_t size; /**< Size of item specification structure. */
816 #define PRIV_ITEM(t, s) \
817 (&(const struct parse_item_priv){ \
818 .type = RTE_FLOW_ITEM_TYPE_ ## t, \
822 /** Private data for actions. */
823 struct parse_action_priv {
824 enum rte_flow_action_type type; /**< Action type. */
825 uint32_t size; /**< Size of action configuration structure. */
828 #define PRIV_ACTION(t, s) \
829 (&(const struct parse_action_priv){ \
830 .type = RTE_FLOW_ACTION_TYPE_ ## t, \
834 static const enum index next_sa_create_attr[] = {
835 SHARED_ACTION_CREATE_ID,
836 SHARED_ACTION_INGRESS,
837 SHARED_ACTION_EGRESS,
838 SHARED_ACTION_TRANSFER,
843 static const enum index next_sa_subcmd[] = {
844 SHARED_ACTION_CREATE,
845 SHARED_ACTION_UPDATE,
846 SHARED_ACTION_DESTROY,
851 static const enum index next_vc_attr[] = {
863 static const enum index next_destroy_attr[] = {
869 static const enum index next_dump_attr[] = {
875 static const enum index next_list_attr[] = {
881 static const enum index next_aged_attr[] = {
887 static const enum index next_sa_destroy_attr[] = {
888 SHARED_ACTION_DESTROY_ID,
893 static const enum index item_param[] = {
902 static const enum index next_item[] = {
939 ITEM_ICMP6_ND_OPT_SLA_ETH,
940 ITEM_ICMP6_ND_OPT_TLA_ETH,
959 static const enum index item_fuzzy[] = {
965 static const enum index item_any[] = {
971 static const enum index item_vf[] = {
977 static const enum index item_phy_port[] = {
983 static const enum index item_port_id[] = {
989 static const enum index item_mark[] = {
995 static const enum index item_raw[] = {
1005 static const enum index item_eth[] = {
1014 static const enum index item_vlan[] = {
1019 ITEM_VLAN_INNER_TYPE,
1020 ITEM_VLAN_HAS_MORE_VLAN,
1025 static const enum index item_ipv4[] = {
1027 ITEM_IPV4_FRAGMENT_OFFSET,
1036 static const enum index item_ipv6[] = {
1043 ITEM_IPV6_HAS_FRAG_EXT,
1048 static const enum index item_icmp[] = {
1057 static const enum index item_udp[] = {
1064 static const enum index item_tcp[] = {
1072 static const enum index item_sctp[] = {
1081 static const enum index item_vxlan[] = {
1087 static const enum index item_e_tag[] = {
1088 ITEM_E_TAG_GRP_ECID_B,
1093 static const enum index item_nvgre[] = {
1099 static const enum index item_mpls[] = {
1107 static const enum index item_gre[] = {
1109 ITEM_GRE_C_RSVD0_VER,
1117 static const enum index item_gre_key[] = {
1123 static const enum index item_gtp[] = {
1131 static const enum index item_geneve[] = {
1139 static const enum index item_vxlan_gpe[] = {
1145 static const enum index item_arp_eth_ipv4[] = {
1146 ITEM_ARP_ETH_IPV4_SHA,
1147 ITEM_ARP_ETH_IPV4_SPA,
1148 ITEM_ARP_ETH_IPV4_THA,
1149 ITEM_ARP_ETH_IPV4_TPA,
1154 static const enum index item_ipv6_ext[] = {
1155 ITEM_IPV6_EXT_NEXT_HDR,
1160 static const enum index item_ipv6_frag_ext[] = {
1161 ITEM_IPV6_FRAG_EXT_NEXT_HDR,
1162 ITEM_IPV6_FRAG_EXT_FRAG_DATA,
1167 static const enum index item_icmp6[] = {
1174 static const enum index item_icmp6_nd_ns[] = {
1175 ITEM_ICMP6_ND_NS_TARGET_ADDR,
1180 static const enum index item_icmp6_nd_na[] = {
1181 ITEM_ICMP6_ND_NA_TARGET_ADDR,
1186 static const enum index item_icmp6_nd_opt[] = {
1187 ITEM_ICMP6_ND_OPT_TYPE,
1192 static const enum index item_icmp6_nd_opt_sla_eth[] = {
1193 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
1198 static const enum index item_icmp6_nd_opt_tla_eth[] = {
1199 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
1204 static const enum index item_meta[] = {
1210 static const enum index item_gtp_psc[] = {
1217 static const enum index item_pppoed[] = {
1223 static const enum index item_pppoes[] = {
1229 static const enum index item_pppoe_proto_id[] = {
1234 static const enum index item_higig2[] = {
1235 ITEM_HIGIG2_CLASSIFICATION,
1241 static const enum index item_esp[] = {
1247 static const enum index item_ah[] = {
1253 static const enum index item_pfcp[] = {
1260 static const enum index next_set_raw[] = {
1266 static const enum index item_tag[] = {
1273 static const enum index item_l2tpv3oip[] = {
1274 ITEM_L2TPV3OIP_SESSION_ID,
1279 static const enum index item_ecpri[] = {
1285 static const enum index item_ecpri_common[] = {
1286 ITEM_ECPRI_COMMON_TYPE,
1290 static const enum index item_ecpri_common_type[] = {
1291 ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
1292 ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
1293 ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
1297 static const enum index item_geneve_opt[] = {
1298 ITEM_GENEVE_OPT_CLASS,
1299 ITEM_GENEVE_OPT_TYPE,
1300 ITEM_GENEVE_OPT_LENGTH,
1301 ITEM_GENEVE_OPT_DATA,
1306 static const enum index next_action[] = {
1322 ACTION_OF_SET_MPLS_TTL,
1323 ACTION_OF_DEC_MPLS_TTL,
1324 ACTION_OF_SET_NW_TTL,
1325 ACTION_OF_DEC_NW_TTL,
1326 ACTION_OF_COPY_TTL_OUT,
1327 ACTION_OF_COPY_TTL_IN,
1329 ACTION_OF_PUSH_VLAN,
1330 ACTION_OF_SET_VLAN_VID,
1331 ACTION_OF_SET_VLAN_PCP,
1333 ACTION_OF_PUSH_MPLS,
1340 ACTION_MPLSOGRE_ENCAP,
1341 ACTION_MPLSOGRE_DECAP,
1342 ACTION_MPLSOUDP_ENCAP,
1343 ACTION_MPLSOUDP_DECAP,
1344 ACTION_SET_IPV4_SRC,
1345 ACTION_SET_IPV4_DST,
1346 ACTION_SET_IPV6_SRC,
1347 ACTION_SET_IPV6_DST,
1363 ACTION_SET_IPV4_DSCP,
1364 ACTION_SET_IPV6_DSCP,
1368 ACTION_MODIFY_FIELD,
1372 static const enum index action_mark[] = {
1378 static const enum index action_queue[] = {
1384 static const enum index action_count[] = {
1386 ACTION_COUNT_SHARED,
1391 static const enum index action_rss[] = {
1402 static const enum index action_vf[] = {
1409 static const enum index action_phy_port[] = {
1410 ACTION_PHY_PORT_ORIGINAL,
1411 ACTION_PHY_PORT_INDEX,
1416 static const enum index action_port_id[] = {
1417 ACTION_PORT_ID_ORIGINAL,
1423 static const enum index action_meter[] = {
1429 static const enum index action_of_set_mpls_ttl[] = {
1430 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
1435 static const enum index action_of_set_nw_ttl[] = {
1436 ACTION_OF_SET_NW_TTL_NW_TTL,
1441 static const enum index action_of_push_vlan[] = {
1442 ACTION_OF_PUSH_VLAN_ETHERTYPE,
1447 static const enum index action_of_set_vlan_vid[] = {
1448 ACTION_OF_SET_VLAN_VID_VLAN_VID,
1453 static const enum index action_of_set_vlan_pcp[] = {
1454 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
1459 static const enum index action_of_pop_mpls[] = {
1460 ACTION_OF_POP_MPLS_ETHERTYPE,
1465 static const enum index action_of_push_mpls[] = {
1466 ACTION_OF_PUSH_MPLS_ETHERTYPE,
1471 static const enum index action_set_ipv4_src[] = {
1472 ACTION_SET_IPV4_SRC_IPV4_SRC,
1477 static const enum index action_set_mac_src[] = {
1478 ACTION_SET_MAC_SRC_MAC_SRC,
1483 static const enum index action_set_ipv4_dst[] = {
1484 ACTION_SET_IPV4_DST_IPV4_DST,
1489 static const enum index action_set_ipv6_src[] = {
1490 ACTION_SET_IPV6_SRC_IPV6_SRC,
1495 static const enum index action_set_ipv6_dst[] = {
1496 ACTION_SET_IPV6_DST_IPV6_DST,
1501 static const enum index action_set_tp_src[] = {
1502 ACTION_SET_TP_SRC_TP_SRC,
1507 static const enum index action_set_tp_dst[] = {
1508 ACTION_SET_TP_DST_TP_DST,
1513 static const enum index action_set_ttl[] = {
1519 static const enum index action_jump[] = {
1525 static const enum index action_set_mac_dst[] = {
1526 ACTION_SET_MAC_DST_MAC_DST,
1531 static const enum index action_inc_tcp_seq[] = {
1532 ACTION_INC_TCP_SEQ_VALUE,
1537 static const enum index action_dec_tcp_seq[] = {
1538 ACTION_DEC_TCP_SEQ_VALUE,
1543 static const enum index action_inc_tcp_ack[] = {
1544 ACTION_INC_TCP_ACK_VALUE,
1549 static const enum index action_dec_tcp_ack[] = {
1550 ACTION_DEC_TCP_ACK_VALUE,
1555 static const enum index action_raw_encap[] = {
1556 ACTION_RAW_ENCAP_INDEX,
1561 static const enum index action_raw_decap[] = {
1562 ACTION_RAW_DECAP_INDEX,
1567 static const enum index action_set_tag[] = {
1568 ACTION_SET_TAG_DATA,
1569 ACTION_SET_TAG_INDEX,
1570 ACTION_SET_TAG_MASK,
1575 static const enum index action_set_meta[] = {
1576 ACTION_SET_META_DATA,
1577 ACTION_SET_META_MASK,
1582 static const enum index action_set_ipv4_dscp[] = {
1583 ACTION_SET_IPV4_DSCP_VALUE,
1588 static const enum index action_set_ipv6_dscp[] = {
1589 ACTION_SET_IPV6_DSCP_VALUE,
1594 static const enum index action_age[] = {
1601 static const enum index action_sample[] = {
1603 ACTION_SAMPLE_RATIO,
1604 ACTION_SAMPLE_INDEX,
1609 static const enum index next_action_sample[] = {
1619 static const enum index action_modify_field_dst[] = {
1620 ACTION_MODIFY_FIELD_DST_LEVEL,
1621 ACTION_MODIFY_FIELD_DST_OFFSET,
1622 ACTION_MODIFY_FIELD_SRC_TYPE,
1626 static const enum index action_modify_field_src[] = {
1627 ACTION_MODIFY_FIELD_SRC_LEVEL,
1628 ACTION_MODIFY_FIELD_SRC_OFFSET,
1629 ACTION_MODIFY_FIELD_SRC_VALUE,
1630 ACTION_MODIFY_FIELD_WIDTH,
1634 static int parse_set_raw_encap_decap(struct context *, const struct token *,
1635 const char *, unsigned int,
1636 void *, unsigned int);
1637 static int parse_set_sample_action(struct context *, const struct token *,
1638 const char *, unsigned int,
1639 void *, unsigned int);
1640 static int parse_set_init(struct context *, const struct token *,
1641 const char *, unsigned int,
1642 void *, unsigned int);
1643 static int parse_init(struct context *, const struct token *,
1644 const char *, unsigned int,
1645 void *, unsigned int);
1646 static int parse_vc(struct context *, const struct token *,
1647 const char *, unsigned int,
1648 void *, unsigned int);
1649 static int parse_vc_spec(struct context *, const struct token *,
1650 const char *, unsigned int, void *, unsigned int);
1651 static int parse_vc_conf(struct context *, const struct token *,
1652 const char *, unsigned int, void *, unsigned int);
1653 static int parse_vc_item_ecpri_type(struct context *, const struct token *,
1654 const char *, unsigned int,
1655 void *, unsigned int);
1656 static int parse_vc_action_rss(struct context *, const struct token *,
1657 const char *, unsigned int, void *,
1659 static int parse_vc_action_rss_func(struct context *, const struct token *,
1660 const char *, unsigned int, void *,
1662 static int parse_vc_action_rss_type(struct context *, const struct token *,
1663 const char *, unsigned int, void *,
1665 static int parse_vc_action_rss_queue(struct context *, const struct token *,
1666 const char *, unsigned int, void *,
1668 static int parse_vc_action_vxlan_encap(struct context *, const struct token *,
1669 const char *, unsigned int, void *,
1671 static int parse_vc_action_nvgre_encap(struct context *, const struct token *,
1672 const char *, unsigned int, void *,
1674 static int parse_vc_action_l2_encap(struct context *, const struct token *,
1675 const char *, unsigned int, void *,
1677 static int parse_vc_action_l2_decap(struct context *, const struct token *,
1678 const char *, unsigned int, void *,
1680 static int parse_vc_action_mplsogre_encap(struct context *,
1681 const struct token *, const char *,
1682 unsigned int, void *, unsigned int);
1683 static int parse_vc_action_mplsogre_decap(struct context *,
1684 const struct token *, const char *,
1685 unsigned int, void *, unsigned int);
1686 static int parse_vc_action_mplsoudp_encap(struct context *,
1687 const struct token *, const char *,
1688 unsigned int, void *, unsigned int);
1689 static int parse_vc_action_mplsoudp_decap(struct context *,
1690 const struct token *, const char *,
1691 unsigned int, void *, unsigned int);
1692 static int parse_vc_action_raw_encap(struct context *,
1693 const struct token *, const char *,
1694 unsigned int, void *, unsigned int);
1695 static int parse_vc_action_raw_decap(struct context *,
1696 const struct token *, const char *,
1697 unsigned int, void *, unsigned int);
1698 static int parse_vc_action_raw_encap_index(struct context *,
1699 const struct token *, const char *,
1700 unsigned int, void *, unsigned int);
1701 static int parse_vc_action_raw_decap_index(struct context *,
1702 const struct token *, const char *,
1703 unsigned int, void *, unsigned int);
1704 static int parse_vc_action_set_meta(struct context *ctx,
1705 const struct token *token, const char *str,
1706 unsigned int len, void *buf,
1708 static int parse_vc_action_sample(struct context *ctx,
1709 const struct token *token, const char *str,
1710 unsigned int len, void *buf,
1713 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
1714 const char *str, unsigned int len, void *buf,
1717 parse_vc_modify_field_op(struct context *ctx, const struct token *token,
1718 const char *str, unsigned int len, void *buf,
1721 parse_vc_modify_field_id(struct context *ctx, const struct token *token,
1722 const char *str, unsigned int len, void *buf,
1724 static int parse_destroy(struct context *, const struct token *,
1725 const char *, unsigned int,
1726 void *, unsigned int);
1727 static int parse_flush(struct context *, const struct token *,
1728 const char *, unsigned int,
1729 void *, unsigned int);
1730 static int parse_dump(struct context *, const struct token *,
1731 const char *, unsigned int,
1732 void *, unsigned int);
1733 static int parse_query(struct context *, const struct token *,
1734 const char *, unsigned int,
1735 void *, unsigned int);
1736 static int parse_action(struct context *, const struct token *,
1737 const char *, unsigned int,
1738 void *, unsigned int);
1739 static int parse_list(struct context *, const struct token *,
1740 const char *, unsigned int,
1741 void *, unsigned int);
1742 static int parse_aged(struct context *, const struct token *,
1743 const char *, unsigned int,
1744 void *, unsigned int);
1745 static int parse_isolate(struct context *, const struct token *,
1746 const char *, unsigned int,
1747 void *, unsigned int);
1748 static int parse_tunnel(struct context *, const struct token *,
1749 const char *, unsigned int,
1750 void *, unsigned int);
1751 static int parse_int(struct context *, const struct token *,
1752 const char *, unsigned int,
1753 void *, unsigned int);
1754 static int parse_prefix(struct context *, const struct token *,
1755 const char *, unsigned int,
1756 void *, unsigned int);
1757 static int parse_boolean(struct context *, const struct token *,
1758 const char *, unsigned int,
1759 void *, unsigned int);
1760 static int parse_string(struct context *, const struct token *,
1761 const char *, unsigned int,
1762 void *, unsigned int);
1763 static int parse_hex(struct context *ctx, const struct token *token,
1764 const char *str, unsigned int len,
1765 void *buf, unsigned int size);
1766 static int parse_string0(struct context *, const struct token *,
1767 const char *, unsigned int,
1768 void *, unsigned int);
1769 static int parse_mac_addr(struct context *, const struct token *,
1770 const char *, unsigned int,
1771 void *, unsigned int);
1772 static int parse_ipv4_addr(struct context *, const struct token *,
1773 const char *, unsigned int,
1774 void *, unsigned int);
1775 static int parse_ipv6_addr(struct context *, const struct token *,
1776 const char *, unsigned int,
1777 void *, unsigned int);
1778 static int parse_port(struct context *, const struct token *,
1779 const char *, unsigned int,
1780 void *, unsigned int);
1781 static int parse_sa(struct context *, const struct token *,
1782 const char *, unsigned int,
1783 void *, unsigned int);
1784 static int parse_sa_destroy(struct context *ctx, const struct token *token,
1785 const char *str, unsigned int len,
1786 void *buf, unsigned int size);
1787 static int parse_sa_id2ptr(struct context *ctx, const struct token *token,
1788 const char *str, unsigned int len, void *buf,
1790 static int comp_none(struct context *, const struct token *,
1791 unsigned int, char *, unsigned int);
1792 static int comp_boolean(struct context *, const struct token *,
1793 unsigned int, char *, unsigned int);
1794 static int comp_action(struct context *, const struct token *,
1795 unsigned int, char *, unsigned int);
1796 static int comp_port(struct context *, const struct token *,
1797 unsigned int, char *, unsigned int);
1798 static int comp_rule_id(struct context *, const struct token *,
1799 unsigned int, char *, unsigned int);
1800 static int comp_vc_action_rss_type(struct context *, const struct token *,
1801 unsigned int, char *, unsigned int);
1802 static int comp_vc_action_rss_queue(struct context *, const struct token *,
1803 unsigned int, char *, unsigned int);
1804 static int comp_set_raw_index(struct context *, const struct token *,
1805 unsigned int, char *, unsigned int);
1806 static int comp_set_sample_index(struct context *, const struct token *,
1807 unsigned int, char *, unsigned int);
1808 static int comp_set_modify_field_op(struct context *, const struct token *,
1809 unsigned int, char *, unsigned int);
1810 static int comp_set_modify_field_id(struct context *, const struct token *,
1811 unsigned int, char *, unsigned int);
1813 /** Token definitions. */
1814 static const struct token token_list[] = {
1815 /* Special tokens. */
1818 .help = "null entry, abused as the entry point",
1819 .next = NEXT(NEXT_ENTRY(FLOW)),
1824 .help = "command may end here",
1827 .name = "START_SET",
1828 .help = "null entry, abused as the entry point for set",
1829 .next = NEXT(NEXT_ENTRY(SET)),
1834 .help = "set command may end here",
1836 /* Common tokens. */
1840 .help = "integer value",
1845 .name = "{unsigned}",
1847 .help = "unsigned integer value",
1854 .help = "prefix length for bit-mask",
1855 .call = parse_prefix,
1859 .name = "{boolean}",
1861 .help = "any boolean value",
1862 .call = parse_boolean,
1863 .comp = comp_boolean,
1868 .help = "fixed string",
1869 .call = parse_string,
1875 .help = "fixed string",
1879 .name = "{file path}",
1881 .help = "file path",
1882 .call = parse_string0,
1886 .name = "{MAC address}",
1888 .help = "standard MAC address notation",
1889 .call = parse_mac_addr,
1893 .name = "{IPv4 address}",
1894 .type = "IPV4 ADDRESS",
1895 .help = "standard IPv4 address notation",
1896 .call = parse_ipv4_addr,
1900 .name = "{IPv6 address}",
1901 .type = "IPV6 ADDRESS",
1902 .help = "standard IPv6 address notation",
1903 .call = parse_ipv6_addr,
1907 .name = "{rule id}",
1909 .help = "rule identifier",
1911 .comp = comp_rule_id,
1914 .name = "{port_id}",
1916 .help = "port identifier",
1921 .name = "{group_id}",
1923 .help = "group identifier",
1927 [PRIORITY_LEVEL] = {
1930 .help = "priority level",
1934 [SHARED_ACTION_ID] = {
1935 .name = "{shared_action_id}",
1936 .type = "SHARED_ACTION_ID",
1937 .help = "shared action id",
1941 /* Top-level command. */
1944 .type = "{command} {port_id} [{arg} [...]]",
1945 .help = "manage ingress/egress flow rules",
1946 .next = NEXT(NEXT_ENTRY
1960 /* Top-level command. */
1962 .name = "shared_action",
1963 .type = "{command} {port_id} [{arg} [...]]",
1964 .help = "manage shared actions",
1965 .next = NEXT(next_sa_subcmd, NEXT_ENTRY(PORT_ID)),
1966 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1969 /* Sub-level commands. */
1970 [SHARED_ACTION_CREATE] = {
1972 .help = "create shared action",
1973 .next = NEXT(next_sa_create_attr),
1976 [SHARED_ACTION_UPDATE] = {
1978 .help = "update shared action",
1979 .next = NEXT(NEXT_ENTRY(SHARED_ACTION_SPEC),
1980 NEXT_ENTRY(SHARED_ACTION_ID)),
1981 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
1984 [SHARED_ACTION_DESTROY] = {
1986 .help = "destroy shared action",
1987 .next = NEXT(NEXT_ENTRY(SHARED_ACTION_DESTROY_ID)),
1988 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1989 .call = parse_sa_destroy,
1991 [SHARED_ACTION_QUERY] = {
1993 .help = "query shared action",
1994 .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(SHARED_ACTION_ID)),
1995 .args = ARGS(ARGS_ENTRY(struct buffer, args.sa.action_id)),
2000 .help = "check whether a flow rule can be created",
2001 .next = NEXT(next_vc_attr, NEXT_ENTRY(PORT_ID)),
2002 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2007 .help = "create a flow rule",
2008 .next = NEXT(next_vc_attr, NEXT_ENTRY(PORT_ID)),
2009 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2014 .help = "destroy specific flow rules",
2015 .next = NEXT(NEXT_ENTRY(DESTROY_RULE), NEXT_ENTRY(PORT_ID)),
2016 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2017 .call = parse_destroy,
2021 .help = "destroy all flow rules",
2022 .next = NEXT(NEXT_ENTRY(PORT_ID)),
2023 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2024 .call = parse_flush,
2028 .help = "dump all flow rules to file",
2029 .next = NEXT(next_dump_attr, NEXT_ENTRY(PORT_ID)),
2030 .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file),
2031 ARGS_ENTRY(struct buffer, port)),
2036 .help = "query an existing flow rule",
2037 .next = NEXT(NEXT_ENTRY(QUERY_ACTION),
2038 NEXT_ENTRY(RULE_ID),
2039 NEXT_ENTRY(PORT_ID)),
2040 .args = ARGS(ARGS_ENTRY(struct buffer, args.query.action.type),
2041 ARGS_ENTRY(struct buffer, args.query.rule),
2042 ARGS_ENTRY(struct buffer, port)),
2043 .call = parse_query,
2047 .help = "list existing flow rules",
2048 .next = NEXT(next_list_attr, NEXT_ENTRY(PORT_ID)),
2049 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2054 .help = "list and destroy aged flows",
2055 .next = NEXT(next_aged_attr, NEXT_ENTRY(PORT_ID)),
2056 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2061 .help = "restrict ingress traffic to the defined flow rules",
2062 .next = NEXT(NEXT_ENTRY(BOOLEAN),
2063 NEXT_ENTRY(PORT_ID)),
2064 .args = ARGS(ARGS_ENTRY(struct buffer, args.isolate.set),
2065 ARGS_ENTRY(struct buffer, port)),
2066 .call = parse_isolate,
2070 .help = "new tunnel API",
2071 .next = NEXT(NEXT_ENTRY
2072 (TUNNEL_CREATE, TUNNEL_LIST, TUNNEL_DESTROY)),
2073 .call = parse_tunnel,
2075 /* Tunnel arguments. */
2078 .help = "create new tunnel object",
2079 .next = NEXT(NEXT_ENTRY(TUNNEL_CREATE_TYPE),
2080 NEXT_ENTRY(PORT_ID)),
2081 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2082 .call = parse_tunnel,
2084 [TUNNEL_CREATE_TYPE] = {
2086 .help = "create new tunnel",
2087 .next = NEXT(NEXT_ENTRY(FILE_PATH)),
2088 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, type)),
2089 .call = parse_tunnel,
2091 [TUNNEL_DESTROY] = {
2093 .help = "destroy tunel",
2094 .next = NEXT(NEXT_ENTRY(TUNNEL_DESTROY_ID),
2095 NEXT_ENTRY(PORT_ID)),
2096 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2097 .call = parse_tunnel,
2099 [TUNNEL_DESTROY_ID] = {
2101 .help = "tunnel identifier to testroy",
2102 .next = NEXT(NEXT_ENTRY(UNSIGNED)),
2103 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2104 .call = parse_tunnel,
2108 .help = "list existing tunnels",
2109 .next = NEXT(NEXT_ENTRY(PORT_ID)),
2110 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2111 .call = parse_tunnel,
2113 /* Destroy arguments. */
2116 .help = "specify a rule identifier",
2117 .next = NEXT(next_destroy_attr, NEXT_ENTRY(RULE_ID)),
2118 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.destroy.rule)),
2119 .call = parse_destroy,
2121 /* Query arguments. */
2125 .help = "action to query, must be part of the rule",
2126 .call = parse_action,
2127 .comp = comp_action,
2129 /* List arguments. */
2132 .help = "specify a group",
2133 .next = NEXT(next_list_attr, NEXT_ENTRY(GROUP_ID)),
2134 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.list.group)),
2139 .help = "specify aged flows need be destroyed",
2143 /* Validate/create attributes. */
2146 .help = "specify a group",
2147 .next = NEXT(next_vc_attr, NEXT_ENTRY(GROUP_ID)),
2148 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, group)),
2153 .help = "specify a priority level",
2154 .next = NEXT(next_vc_attr, NEXT_ENTRY(PRIORITY_LEVEL)),
2155 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, priority)),
2160 .help = "affect rule to ingress",
2161 .next = NEXT(next_vc_attr),
2166 .help = "affect rule to egress",
2167 .next = NEXT(next_vc_attr),
2172 .help = "apply rule directly to endpoints found in pattern",
2173 .next = NEXT(next_vc_attr),
2177 .name = "tunnel_set",
2178 .help = "tunnel steer rule",
2179 .next = NEXT(next_vc_attr, NEXT_ENTRY(UNSIGNED)),
2180 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2184 .name = "tunnel_match",
2185 .help = "tunnel match rule",
2186 .next = NEXT(next_vc_attr, NEXT_ENTRY(UNSIGNED)),
2187 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2190 /* Validate/create pattern. */
2193 .help = "submit a list of pattern items",
2194 .next = NEXT(next_item),
2199 .help = "match value perfectly (with full bit-mask)",
2200 .call = parse_vc_spec,
2202 [ITEM_PARAM_SPEC] = {
2204 .help = "match value according to configured bit-mask",
2205 .call = parse_vc_spec,
2207 [ITEM_PARAM_LAST] = {
2209 .help = "specify upper bound to establish a range",
2210 .call = parse_vc_spec,
2212 [ITEM_PARAM_MASK] = {
2214 .help = "specify bit-mask with relevant bits set to one",
2215 .call = parse_vc_spec,
2217 [ITEM_PARAM_PREFIX] = {
2219 .help = "generate bit-mask from a prefix length",
2220 .call = parse_vc_spec,
2224 .help = "specify next pattern item",
2225 .next = NEXT(next_item),
2229 .help = "end list of pattern items",
2230 .priv = PRIV_ITEM(END, 0),
2231 .next = NEXT(NEXT_ENTRY(ACTIONS)),
2236 .help = "no-op pattern item",
2237 .priv = PRIV_ITEM(VOID, 0),
2238 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2243 .help = "perform actions when pattern does not match",
2244 .priv = PRIV_ITEM(INVERT, 0),
2245 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2250 .help = "match any protocol for the current layer",
2251 .priv = PRIV_ITEM(ANY, sizeof(struct rte_flow_item_any)),
2252 .next = NEXT(item_any),
2257 .help = "number of layers covered",
2258 .next = NEXT(item_any, NEXT_ENTRY(UNSIGNED), item_param),
2259 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_any, num)),
2263 .help = "match traffic from/to the physical function",
2264 .priv = PRIV_ITEM(PF, 0),
2265 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2270 .help = "match traffic from/to a virtual function ID",
2271 .priv = PRIV_ITEM(VF, sizeof(struct rte_flow_item_vf)),
2272 .next = NEXT(item_vf),
2278 .next = NEXT(item_vf, NEXT_ENTRY(UNSIGNED), item_param),
2279 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_vf, id)),
2283 .help = "match traffic from/to a specific physical port",
2284 .priv = PRIV_ITEM(PHY_PORT,
2285 sizeof(struct rte_flow_item_phy_port)),
2286 .next = NEXT(item_phy_port),
2289 [ITEM_PHY_PORT_INDEX] = {
2291 .help = "physical port index",
2292 .next = NEXT(item_phy_port, NEXT_ENTRY(UNSIGNED), item_param),
2293 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_phy_port, index)),
2297 .help = "match traffic from/to a given DPDK port ID",
2298 .priv = PRIV_ITEM(PORT_ID,
2299 sizeof(struct rte_flow_item_port_id)),
2300 .next = NEXT(item_port_id),
2303 [ITEM_PORT_ID_ID] = {
2305 .help = "DPDK port ID",
2306 .next = NEXT(item_port_id, NEXT_ENTRY(UNSIGNED), item_param),
2307 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port_id, id)),
2311 .help = "match traffic against value set in previously matched rule",
2312 .priv = PRIV_ITEM(MARK, sizeof(struct rte_flow_item_mark)),
2313 .next = NEXT(item_mark),
2318 .help = "Integer value to match against",
2319 .next = NEXT(item_mark, NEXT_ENTRY(UNSIGNED), item_param),
2320 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_mark, id)),
2324 .help = "match an arbitrary byte string",
2325 .priv = PRIV_ITEM(RAW, ITEM_RAW_SIZE),
2326 .next = NEXT(item_raw),
2329 [ITEM_RAW_RELATIVE] = {
2331 .help = "look for pattern after the previous item",
2332 .next = NEXT(item_raw, NEXT_ENTRY(BOOLEAN), item_param),
2333 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
2336 [ITEM_RAW_SEARCH] = {
2338 .help = "search pattern from offset (see also limit)",
2339 .next = NEXT(item_raw, NEXT_ENTRY(BOOLEAN), item_param),
2340 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
2343 [ITEM_RAW_OFFSET] = {
2345 .help = "absolute or relative offset for pattern",
2346 .next = NEXT(item_raw, NEXT_ENTRY(INTEGER), item_param),
2347 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, offset)),
2349 [ITEM_RAW_LIMIT] = {
2351 .help = "search area limit for start of pattern",
2352 .next = NEXT(item_raw, NEXT_ENTRY(UNSIGNED), item_param),
2353 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, limit)),
2355 [ITEM_RAW_PATTERN] = {
2357 .help = "byte string to look for",
2358 .next = NEXT(item_raw,
2360 NEXT_ENTRY(ITEM_PARAM_IS,
2363 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern),
2364 ARGS_ENTRY(struct rte_flow_item_raw, length),
2365 ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw),
2366 ITEM_RAW_PATTERN_SIZE)),
2370 .help = "match Ethernet header",
2371 .priv = PRIV_ITEM(ETH, sizeof(struct rte_flow_item_eth)),
2372 .next = NEXT(item_eth),
2377 .help = "destination MAC",
2378 .next = NEXT(item_eth, NEXT_ENTRY(MAC_ADDR), item_param),
2379 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, dst)),
2383 .help = "source MAC",
2384 .next = NEXT(item_eth, NEXT_ENTRY(MAC_ADDR), item_param),
2385 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, src)),
2389 .help = "EtherType",
2390 .next = NEXT(item_eth, NEXT_ENTRY(UNSIGNED), item_param),
2391 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, type)),
2393 [ITEM_ETH_HAS_VLAN] = {
2395 .help = "packet header contains VLAN",
2396 .next = NEXT(item_eth, NEXT_ENTRY(UNSIGNED), item_param),
2397 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_eth,
2402 .help = "match 802.1Q/ad VLAN tag",
2403 .priv = PRIV_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)),
2404 .next = NEXT(item_vlan),
2409 .help = "tag control information",
2410 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2411 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, tci)),
2415 .help = "priority code point",
2416 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2417 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2422 .help = "drop eligible indicator",
2423 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2424 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2429 .help = "VLAN identifier",
2430 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2431 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2434 [ITEM_VLAN_INNER_TYPE] = {
2435 .name = "inner_type",
2436 .help = "inner EtherType",
2437 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2438 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan,
2441 [ITEM_VLAN_HAS_MORE_VLAN] = {
2442 .name = "has_more_vlan",
2443 .help = "packet header contains another VLAN",
2444 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2445 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vlan,
2450 .help = "match IPv4 header",
2451 .priv = PRIV_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)),
2452 .next = NEXT(item_ipv4),
2457 .help = "type of service",
2458 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2459 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2460 hdr.type_of_service)),
2462 [ITEM_IPV4_FRAGMENT_OFFSET] = {
2463 .name = "fragment_offset",
2464 .help = "fragmentation flags and fragment offset",
2465 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2466 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2467 hdr.fragment_offset)),
2471 .help = "time to live",
2472 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2473 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2476 [ITEM_IPV4_PROTO] = {
2478 .help = "next protocol ID",
2479 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2480 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2481 hdr.next_proto_id)),
2485 .help = "source address",
2486 .next = NEXT(item_ipv4, NEXT_ENTRY(IPV4_ADDR), item_param),
2487 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2492 .help = "destination address",
2493 .next = NEXT(item_ipv4, NEXT_ENTRY(IPV4_ADDR), item_param),
2494 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2499 .help = "match IPv6 header",
2500 .priv = PRIV_ITEM(IPV6, sizeof(struct rte_flow_item_ipv6)),
2501 .next = NEXT(item_ipv6),
2506 .help = "traffic class",
2507 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2508 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2510 "\x0f\xf0\x00\x00")),
2512 [ITEM_IPV6_FLOW] = {
2514 .help = "flow label",
2515 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2516 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2518 "\x00\x0f\xff\xff")),
2520 [ITEM_IPV6_PROTO] = {
2522 .help = "protocol (next header)",
2523 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2524 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2529 .help = "hop limit",
2530 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2531 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2536 .help = "source address",
2537 .next = NEXT(item_ipv6, NEXT_ENTRY(IPV6_ADDR), item_param),
2538 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2543 .help = "destination address",
2544 .next = NEXT(item_ipv6, NEXT_ENTRY(IPV6_ADDR), item_param),
2545 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2548 [ITEM_IPV6_HAS_FRAG_EXT] = {
2549 .name = "has_frag_ext",
2550 .help = "fragment packet attribute",
2551 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2552 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_ipv6,
2557 .help = "match ICMP header",
2558 .priv = PRIV_ITEM(ICMP, sizeof(struct rte_flow_item_icmp)),
2559 .next = NEXT(item_icmp),
2562 [ITEM_ICMP_TYPE] = {
2564 .help = "ICMP packet type",
2565 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2566 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2569 [ITEM_ICMP_CODE] = {
2571 .help = "ICMP packet code",
2572 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2573 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2576 [ITEM_ICMP_IDENT] = {
2578 .help = "ICMP packet identifier",
2579 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2580 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2585 .help = "ICMP packet sequence number",
2586 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2587 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2592 .help = "match UDP header",
2593 .priv = PRIV_ITEM(UDP, sizeof(struct rte_flow_item_udp)),
2594 .next = NEXT(item_udp),
2599 .help = "UDP source port",
2600 .next = NEXT(item_udp, NEXT_ENTRY(UNSIGNED), item_param),
2601 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2606 .help = "UDP destination port",
2607 .next = NEXT(item_udp, NEXT_ENTRY(UNSIGNED), item_param),
2608 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2613 .help = "match TCP header",
2614 .priv = PRIV_ITEM(TCP, sizeof(struct rte_flow_item_tcp)),
2615 .next = NEXT(item_tcp),
2620 .help = "TCP source port",
2621 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2622 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2627 .help = "TCP destination port",
2628 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2629 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2632 [ITEM_TCP_FLAGS] = {
2634 .help = "TCP flags",
2635 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2636 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2641 .help = "match SCTP header",
2642 .priv = PRIV_ITEM(SCTP, sizeof(struct rte_flow_item_sctp)),
2643 .next = NEXT(item_sctp),
2648 .help = "SCTP source port",
2649 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2650 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2655 .help = "SCTP destination port",
2656 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2657 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2662 .help = "validation tag",
2663 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2664 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2667 [ITEM_SCTP_CKSUM] = {
2670 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2671 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2676 .help = "match VXLAN header",
2677 .priv = PRIV_ITEM(VXLAN, sizeof(struct rte_flow_item_vxlan)),
2678 .next = NEXT(item_vxlan),
2681 [ITEM_VXLAN_VNI] = {
2683 .help = "VXLAN identifier",
2684 .next = NEXT(item_vxlan, NEXT_ENTRY(UNSIGNED), item_param),
2685 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan, vni)),
2689 .help = "match E-Tag header",
2690 .priv = PRIV_ITEM(E_TAG, sizeof(struct rte_flow_item_e_tag)),
2691 .next = NEXT(item_e_tag),
2694 [ITEM_E_TAG_GRP_ECID_B] = {
2695 .name = "grp_ecid_b",
2696 .help = "GRP and E-CID base",
2697 .next = NEXT(item_e_tag, NEXT_ENTRY(UNSIGNED), item_param),
2698 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_e_tag,
2704 .help = "match NVGRE header",
2705 .priv = PRIV_ITEM(NVGRE, sizeof(struct rte_flow_item_nvgre)),
2706 .next = NEXT(item_nvgre),
2709 [ITEM_NVGRE_TNI] = {
2711 .help = "virtual subnet ID",
2712 .next = NEXT(item_nvgre, NEXT_ENTRY(UNSIGNED), item_param),
2713 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_nvgre, tni)),
2717 .help = "match MPLS header",
2718 .priv = PRIV_ITEM(MPLS, sizeof(struct rte_flow_item_mpls)),
2719 .next = NEXT(item_mpls),
2722 [ITEM_MPLS_LABEL] = {
2724 .help = "MPLS label",
2725 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2726 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2732 .help = "MPLS Traffic Class",
2733 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2734 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2740 .help = "MPLS Bottom-of-Stack",
2741 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2742 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2748 .help = "match GRE header",
2749 .priv = PRIV_ITEM(GRE, sizeof(struct rte_flow_item_gre)),
2750 .next = NEXT(item_gre),
2753 [ITEM_GRE_PROTO] = {
2755 .help = "GRE protocol type",
2756 .next = NEXT(item_gre, NEXT_ENTRY(UNSIGNED), item_param),
2757 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2760 [ITEM_GRE_C_RSVD0_VER] = {
2761 .name = "c_rsvd0_ver",
2763 "checksum (1b), undefined (1b), key bit (1b),"
2764 " sequence number (1b), reserved 0 (9b),"
2766 .next = NEXT(item_gre, NEXT_ENTRY(UNSIGNED), item_param),
2767 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2770 [ITEM_GRE_C_BIT] = {
2772 .help = "checksum bit (C)",
2773 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2774 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2776 "\x80\x00\x00\x00")),
2778 [ITEM_GRE_S_BIT] = {
2780 .help = "sequence number bit (S)",
2781 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2782 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2784 "\x10\x00\x00\x00")),
2786 [ITEM_GRE_K_BIT] = {
2788 .help = "key bit (K)",
2789 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2790 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2792 "\x20\x00\x00\x00")),
2796 .help = "fuzzy pattern match, expect faster than default",
2797 .priv = PRIV_ITEM(FUZZY,
2798 sizeof(struct rte_flow_item_fuzzy)),
2799 .next = NEXT(item_fuzzy),
2802 [ITEM_FUZZY_THRESH] = {
2804 .help = "match accuracy threshold",
2805 .next = NEXT(item_fuzzy, NEXT_ENTRY(UNSIGNED), item_param),
2806 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_fuzzy,
2811 .help = "match GTP header",
2812 .priv = PRIV_ITEM(GTP, sizeof(struct rte_flow_item_gtp)),
2813 .next = NEXT(item_gtp),
2816 [ITEM_GTP_FLAGS] = {
2817 .name = "v_pt_rsv_flags",
2818 .help = "GTP flags",
2819 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2820 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp,
2823 [ITEM_GTP_MSG_TYPE] = {
2825 .help = "GTP message type",
2826 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2827 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp, msg_type)),
2831 .help = "tunnel endpoint identifier",
2832 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2833 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp, teid)),
2837 .help = "match GTP header",
2838 .priv = PRIV_ITEM(GTPC, sizeof(struct rte_flow_item_gtp)),
2839 .next = NEXT(item_gtp),
2844 .help = "match GTP header",
2845 .priv = PRIV_ITEM(GTPU, sizeof(struct rte_flow_item_gtp)),
2846 .next = NEXT(item_gtp),
2851 .help = "match GENEVE header",
2852 .priv = PRIV_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)),
2853 .next = NEXT(item_geneve),
2856 [ITEM_GENEVE_VNI] = {
2858 .help = "virtual network identifier",
2859 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2860 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve, vni)),
2862 [ITEM_GENEVE_PROTO] = {
2864 .help = "GENEVE protocol type",
2865 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2866 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve,
2869 [ITEM_GENEVE_OPTLEN] = {
2871 .help = "GENEVE options length in dwords",
2872 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2873 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_geneve,
2874 ver_opt_len_o_c_rsvd0,
2877 [ITEM_VXLAN_GPE] = {
2878 .name = "vxlan-gpe",
2879 .help = "match VXLAN-GPE header",
2880 .priv = PRIV_ITEM(VXLAN_GPE,
2881 sizeof(struct rte_flow_item_vxlan_gpe)),
2882 .next = NEXT(item_vxlan_gpe),
2885 [ITEM_VXLAN_GPE_VNI] = {
2887 .help = "VXLAN-GPE identifier",
2888 .next = NEXT(item_vxlan_gpe, NEXT_ENTRY(UNSIGNED), item_param),
2889 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
2892 [ITEM_ARP_ETH_IPV4] = {
2893 .name = "arp_eth_ipv4",
2894 .help = "match ARP header for Ethernet/IPv4",
2895 .priv = PRIV_ITEM(ARP_ETH_IPV4,
2896 sizeof(struct rte_flow_item_arp_eth_ipv4)),
2897 .next = NEXT(item_arp_eth_ipv4),
2900 [ITEM_ARP_ETH_IPV4_SHA] = {
2902 .help = "sender hardware address",
2903 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(MAC_ADDR),
2905 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2908 [ITEM_ARP_ETH_IPV4_SPA] = {
2910 .help = "sender IPv4 address",
2911 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(IPV4_ADDR),
2913 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2916 [ITEM_ARP_ETH_IPV4_THA] = {
2918 .help = "target hardware address",
2919 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(MAC_ADDR),
2921 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2924 [ITEM_ARP_ETH_IPV4_TPA] = {
2926 .help = "target IPv4 address",
2927 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(IPV4_ADDR),
2929 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2934 .help = "match presence of any IPv6 extension header",
2935 .priv = PRIV_ITEM(IPV6_EXT,
2936 sizeof(struct rte_flow_item_ipv6_ext)),
2937 .next = NEXT(item_ipv6_ext),
2940 [ITEM_IPV6_EXT_NEXT_HDR] = {
2942 .help = "next header",
2943 .next = NEXT(item_ipv6_ext, NEXT_ENTRY(UNSIGNED), item_param),
2944 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_ext,
2947 [ITEM_IPV6_FRAG_EXT] = {
2948 .name = "ipv6_frag_ext",
2949 .help = "match presence of IPv6 fragment extension header",
2950 .priv = PRIV_ITEM(IPV6_FRAG_EXT,
2951 sizeof(struct rte_flow_item_ipv6_frag_ext)),
2952 .next = NEXT(item_ipv6_frag_ext),
2955 [ITEM_IPV6_FRAG_EXT_NEXT_HDR] = {
2957 .help = "next header",
2958 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(UNSIGNED),
2960 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ipv6_frag_ext,
2963 [ITEM_IPV6_FRAG_EXT_FRAG_DATA] = {
2964 .name = "frag_data",
2965 .help = "Fragment flags and offset",
2966 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(UNSIGNED),
2968 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_frag_ext,
2973 .help = "match any ICMPv6 header",
2974 .priv = PRIV_ITEM(ICMP6, sizeof(struct rte_flow_item_icmp6)),
2975 .next = NEXT(item_icmp6),
2978 [ITEM_ICMP6_TYPE] = {
2980 .help = "ICMPv6 type",
2981 .next = NEXT(item_icmp6, NEXT_ENTRY(UNSIGNED), item_param),
2982 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
2985 [ITEM_ICMP6_CODE] = {
2987 .help = "ICMPv6 code",
2988 .next = NEXT(item_icmp6, NEXT_ENTRY(UNSIGNED), item_param),
2989 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
2992 [ITEM_ICMP6_ND_NS] = {
2993 .name = "icmp6_nd_ns",
2994 .help = "match ICMPv6 neighbor discovery solicitation",
2995 .priv = PRIV_ITEM(ICMP6_ND_NS,
2996 sizeof(struct rte_flow_item_icmp6_nd_ns)),
2997 .next = NEXT(item_icmp6_nd_ns),
3000 [ITEM_ICMP6_ND_NS_TARGET_ADDR] = {
3001 .name = "target_addr",
3002 .help = "target address",
3003 .next = NEXT(item_icmp6_nd_ns, NEXT_ENTRY(IPV6_ADDR),
3005 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_ns,
3008 [ITEM_ICMP6_ND_NA] = {
3009 .name = "icmp6_nd_na",
3010 .help = "match ICMPv6 neighbor discovery advertisement",
3011 .priv = PRIV_ITEM(ICMP6_ND_NA,
3012 sizeof(struct rte_flow_item_icmp6_nd_na)),
3013 .next = NEXT(item_icmp6_nd_na),
3016 [ITEM_ICMP6_ND_NA_TARGET_ADDR] = {
3017 .name = "target_addr",
3018 .help = "target address",
3019 .next = NEXT(item_icmp6_nd_na, NEXT_ENTRY(IPV6_ADDR),
3021 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_na,
3024 [ITEM_ICMP6_ND_OPT] = {
3025 .name = "icmp6_nd_opt",
3026 .help = "match presence of any ICMPv6 neighbor discovery"
3028 .priv = PRIV_ITEM(ICMP6_ND_OPT,
3029 sizeof(struct rte_flow_item_icmp6_nd_opt)),
3030 .next = NEXT(item_icmp6_nd_opt),
3033 [ITEM_ICMP6_ND_OPT_TYPE] = {
3035 .help = "ND option type",
3036 .next = NEXT(item_icmp6_nd_opt, NEXT_ENTRY(UNSIGNED),
3038 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_opt,
3041 [ITEM_ICMP6_ND_OPT_SLA_ETH] = {
3042 .name = "icmp6_nd_opt_sla_eth",
3043 .help = "match ICMPv6 neighbor discovery source Ethernet"
3044 " link-layer address option",
3046 (ICMP6_ND_OPT_SLA_ETH,
3047 sizeof(struct rte_flow_item_icmp6_nd_opt_sla_eth)),
3048 .next = NEXT(item_icmp6_nd_opt_sla_eth),
3051 [ITEM_ICMP6_ND_OPT_SLA_ETH_SLA] = {
3053 .help = "source Ethernet LLA",
3054 .next = NEXT(item_icmp6_nd_opt_sla_eth, NEXT_ENTRY(MAC_ADDR),
3056 .args = ARGS(ARGS_ENTRY_HTON
3057 (struct rte_flow_item_icmp6_nd_opt_sla_eth, sla)),
3059 [ITEM_ICMP6_ND_OPT_TLA_ETH] = {
3060 .name = "icmp6_nd_opt_tla_eth",
3061 .help = "match ICMPv6 neighbor discovery target Ethernet"
3062 " link-layer address option",
3064 (ICMP6_ND_OPT_TLA_ETH,
3065 sizeof(struct rte_flow_item_icmp6_nd_opt_tla_eth)),
3066 .next = NEXT(item_icmp6_nd_opt_tla_eth),
3069 [ITEM_ICMP6_ND_OPT_TLA_ETH_TLA] = {
3071 .help = "target Ethernet LLA",
3072 .next = NEXT(item_icmp6_nd_opt_tla_eth, NEXT_ENTRY(MAC_ADDR),
3074 .args = ARGS(ARGS_ENTRY_HTON
3075 (struct rte_flow_item_icmp6_nd_opt_tla_eth, tla)),
3079 .help = "match metadata header",
3080 .priv = PRIV_ITEM(META, sizeof(struct rte_flow_item_meta)),
3081 .next = NEXT(item_meta),
3084 [ITEM_META_DATA] = {
3086 .help = "metadata value",
3087 .next = NEXT(item_meta, NEXT_ENTRY(UNSIGNED), item_param),
3088 .args = ARGS(ARGS_ENTRY_MASK(struct rte_flow_item_meta,
3089 data, "\xff\xff\xff\xff")),
3093 .help = "match GRE key",
3094 .priv = PRIV_ITEM(GRE_KEY, sizeof(rte_be32_t)),
3095 .next = NEXT(item_gre_key),
3098 [ITEM_GRE_KEY_VALUE] = {
3100 .help = "key value",
3101 .next = NEXT(item_gre_key, NEXT_ENTRY(UNSIGNED), item_param),
3102 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3106 .help = "match GTP extension header with type 0x85",
3107 .priv = PRIV_ITEM(GTP_PSC,
3108 sizeof(struct rte_flow_item_gtp_psc)),
3109 .next = NEXT(item_gtp_psc),
3112 [ITEM_GTP_PSC_QFI] = {
3114 .help = "QoS flow identifier",
3115 .next = NEXT(item_gtp_psc, NEXT_ENTRY(UNSIGNED), item_param),
3116 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
3119 [ITEM_GTP_PSC_PDU_T] = {
3122 .next = NEXT(item_gtp_psc, NEXT_ENTRY(UNSIGNED), item_param),
3123 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
3128 .help = "match PPPoE session header",
3129 .priv = PRIV_ITEM(PPPOES, sizeof(struct rte_flow_item_pppoe)),
3130 .next = NEXT(item_pppoes),
3135 .help = "match PPPoE discovery header",
3136 .priv = PRIV_ITEM(PPPOED, sizeof(struct rte_flow_item_pppoe)),
3137 .next = NEXT(item_pppoed),
3140 [ITEM_PPPOE_SEID] = {
3142 .help = "session identifier",
3143 .next = NEXT(item_pppoes, NEXT_ENTRY(UNSIGNED), item_param),
3144 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pppoe,
3147 [ITEM_PPPOE_PROTO_ID] = {
3148 .name = "pppoe_proto_id",
3149 .help = "match PPPoE session protocol identifier",
3150 .priv = PRIV_ITEM(PPPOE_PROTO_ID,
3151 sizeof(struct rte_flow_item_pppoe_proto_id)),
3152 .next = NEXT(item_pppoe_proto_id, NEXT_ENTRY(UNSIGNED),
3154 .args = ARGS(ARGS_ENTRY_HTON
3155 (struct rte_flow_item_pppoe_proto_id, proto_id)),
3160 .help = "matches higig2 header",
3161 .priv = PRIV_ITEM(HIGIG2,
3162 sizeof(struct rte_flow_item_higig2_hdr)),
3163 .next = NEXT(item_higig2),
3166 [ITEM_HIGIG2_CLASSIFICATION] = {
3167 .name = "classification",
3168 .help = "matches classification of higig2 header",
3169 .next = NEXT(item_higig2, NEXT_ENTRY(UNSIGNED), item_param),
3170 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
3171 hdr.ppt1.classification)),
3173 [ITEM_HIGIG2_VID] = {
3175 .help = "matches vid of higig2 header",
3176 .next = NEXT(item_higig2, NEXT_ENTRY(UNSIGNED), item_param),
3177 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
3182 .help = "match tag value",
3183 .priv = PRIV_ITEM(TAG, sizeof(struct rte_flow_item_tag)),
3184 .next = NEXT(item_tag),
3189 .help = "tag value to match",
3190 .next = NEXT(item_tag, NEXT_ENTRY(UNSIGNED), item_param),
3191 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, data)),
3193 [ITEM_TAG_INDEX] = {
3195 .help = "index of tag array to match",
3196 .next = NEXT(item_tag, NEXT_ENTRY(UNSIGNED),
3197 NEXT_ENTRY(ITEM_PARAM_IS)),
3198 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, index)),
3200 [ITEM_L2TPV3OIP] = {
3201 .name = "l2tpv3oip",
3202 .help = "match L2TPv3 over IP header",
3203 .priv = PRIV_ITEM(L2TPV3OIP,
3204 sizeof(struct rte_flow_item_l2tpv3oip)),
3205 .next = NEXT(item_l2tpv3oip),
3208 [ITEM_L2TPV3OIP_SESSION_ID] = {
3209 .name = "session_id",
3210 .help = "session identifier",
3211 .next = NEXT(item_l2tpv3oip, NEXT_ENTRY(UNSIGNED), item_param),
3212 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv3oip,
3217 .help = "match ESP header",
3218 .priv = PRIV_ITEM(ESP, sizeof(struct rte_flow_item_esp)),
3219 .next = NEXT(item_esp),
3224 .help = "security policy index",
3225 .next = NEXT(item_esp, NEXT_ENTRY(UNSIGNED), item_param),
3226 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_esp,
3231 .help = "match AH header",
3232 .priv = PRIV_ITEM(AH, sizeof(struct rte_flow_item_ah)),
3233 .next = NEXT(item_ah),
3238 .help = "security parameters index",
3239 .next = NEXT(item_ah, NEXT_ENTRY(UNSIGNED), item_param),
3240 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ah, spi)),
3244 .help = "match pfcp header",
3245 .priv = PRIV_ITEM(PFCP, sizeof(struct rte_flow_item_pfcp)),
3246 .next = NEXT(item_pfcp),
3249 [ITEM_PFCP_S_FIELD] = {
3252 .next = NEXT(item_pfcp, NEXT_ENTRY(UNSIGNED), item_param),
3253 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp,
3256 [ITEM_PFCP_SEID] = {
3258 .help = "session endpoint identifier",
3259 .next = NEXT(item_pfcp, NEXT_ENTRY(UNSIGNED), item_param),
3260 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp, seid)),
3264 .help = "match eCPRI header",
3265 .priv = PRIV_ITEM(ECPRI, sizeof(struct rte_flow_item_ecpri)),
3266 .next = NEXT(item_ecpri),
3269 [ITEM_ECPRI_COMMON] = {
3271 .help = "eCPRI common header",
3272 .next = NEXT(item_ecpri_common),
3274 [ITEM_ECPRI_COMMON_TYPE] = {
3276 .help = "type of common header",
3277 .next = NEXT(item_ecpri_common_type),
3278 .args = ARGS(ARG_ENTRY_HTON(struct rte_flow_item_ecpri)),
3280 [ITEM_ECPRI_COMMON_TYPE_IQ_DATA] = {
3282 .help = "Type #0: IQ Data",
3283 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
3285 .call = parse_vc_item_ecpri_type,
3287 [ITEM_ECPRI_MSG_IQ_DATA_PCID] = {
3289 .help = "Physical Channel ID",
3290 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
3291 ITEM_ECPRI_COMMON, ITEM_NEXT),
3292 NEXT_ENTRY(UNSIGNED), item_param),
3293 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3296 [ITEM_ECPRI_COMMON_TYPE_RTC_CTRL] = {
3298 .help = "Type #2: Real-Time Control Data",
3299 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
3301 .call = parse_vc_item_ecpri_type,
3303 [ITEM_ECPRI_MSG_RTC_CTRL_RTCID] = {
3305 .help = "Real-Time Control Data ID",
3306 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
3307 ITEM_ECPRI_COMMON, ITEM_NEXT),
3308 NEXT_ENTRY(UNSIGNED), item_param),
3309 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3312 [ITEM_ECPRI_COMMON_TYPE_DLY_MSR] = {
3313 .name = "delay_measure",
3314 .help = "Type #5: One-Way Delay Measurement",
3315 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
3317 .call = parse_vc_item_ecpri_type,
3319 [ITEM_ECPRI_MSG_DLY_MSR_MSRID] = {
3321 .help = "Measurement ID",
3322 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
3323 ITEM_ECPRI_COMMON, ITEM_NEXT),
3324 NEXT_ENTRY(UNSIGNED), item_param),
3325 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3328 [ITEM_GENEVE_OPT] = {
3329 .name = "geneve-opt",
3330 .help = "GENEVE header option",
3331 .priv = PRIV_ITEM(GENEVE_OPT,
3332 sizeof(struct rte_flow_item_geneve_opt) +
3333 ITEM_GENEVE_OPT_DATA_SIZE),
3334 .next = NEXT(item_geneve_opt),
3337 [ITEM_GENEVE_OPT_CLASS] = {
3339 .help = "GENEVE option class",
3340 .next = NEXT(item_geneve_opt, NEXT_ENTRY(UNSIGNED), item_param),
3341 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve_opt,
3344 [ITEM_GENEVE_OPT_TYPE] = {
3346 .help = "GENEVE option type",
3347 .next = NEXT(item_geneve_opt, NEXT_ENTRY(UNSIGNED), item_param),
3348 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt,
3351 [ITEM_GENEVE_OPT_LENGTH] = {
3353 .help = "GENEVE option data length (in 32b words)",
3354 .next = NEXT(item_geneve_opt, NEXT_ENTRY(UNSIGNED), item_param),
3355 .args = ARGS(ARGS_ENTRY_BOUNDED(
3356 struct rte_flow_item_geneve_opt, option_len,
3359 [ITEM_GENEVE_OPT_DATA] = {
3361 .help = "GENEVE option data pattern",
3362 .next = NEXT(item_geneve_opt, NEXT_ENTRY(HEX), item_param),
3363 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt, data),
3364 ARGS_ENTRY_ARB(0, 0),
3366 (sizeof(struct rte_flow_item_geneve_opt),
3367 ITEM_GENEVE_OPT_DATA_SIZE)),
3369 /* Validate/create actions. */
3372 .help = "submit a list of associated actions",
3373 .next = NEXT(next_action),
3378 .help = "specify next action",
3379 .next = NEXT(next_action),
3383 .help = "end list of actions",
3384 .priv = PRIV_ACTION(END, 0),
3389 .help = "no-op action",
3390 .priv = PRIV_ACTION(VOID, 0),
3391 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3394 [ACTION_PASSTHRU] = {
3396 .help = "let subsequent rule process matched packets",
3397 .priv = PRIV_ACTION(PASSTHRU, 0),
3398 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3403 .help = "redirect traffic to a given group",
3404 .priv = PRIV_ACTION(JUMP, sizeof(struct rte_flow_action_jump)),
3405 .next = NEXT(action_jump),
3408 [ACTION_JUMP_GROUP] = {
3410 .help = "group to redirect traffic to",
3411 .next = NEXT(action_jump, NEXT_ENTRY(UNSIGNED)),
3412 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump, group)),
3413 .call = parse_vc_conf,
3417 .help = "attach 32 bit value to packets",
3418 .priv = PRIV_ACTION(MARK, sizeof(struct rte_flow_action_mark)),
3419 .next = NEXT(action_mark),
3422 [ACTION_MARK_ID] = {
3424 .help = "32 bit value to return with packets",
3425 .next = NEXT(action_mark, NEXT_ENTRY(UNSIGNED)),
3426 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_mark, id)),
3427 .call = parse_vc_conf,
3431 .help = "flag packets",
3432 .priv = PRIV_ACTION(FLAG, 0),
3433 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3438 .help = "assign packets to a given queue index",
3439 .priv = PRIV_ACTION(QUEUE,
3440 sizeof(struct rte_flow_action_queue)),
3441 .next = NEXT(action_queue),
3444 [ACTION_QUEUE_INDEX] = {
3446 .help = "queue index to use",
3447 .next = NEXT(action_queue, NEXT_ENTRY(UNSIGNED)),
3448 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_queue, index)),
3449 .call = parse_vc_conf,
3453 .help = "drop packets (note: passthru has priority)",
3454 .priv = PRIV_ACTION(DROP, 0),
3455 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3460 .help = "enable counters for this rule",
3461 .priv = PRIV_ACTION(COUNT,
3462 sizeof(struct rte_flow_action_count)),
3463 .next = NEXT(action_count),
3466 [ACTION_COUNT_ID] = {
3467 .name = "identifier",
3468 .help = "counter identifier to use",
3469 .next = NEXT(action_count, NEXT_ENTRY(UNSIGNED)),
3470 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_count, id)),
3471 .call = parse_vc_conf,
3473 [ACTION_COUNT_SHARED] = {
3475 .help = "shared counter",
3476 .next = NEXT(action_count, NEXT_ENTRY(BOOLEAN)),
3477 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_count,
3479 .call = parse_vc_conf,
3483 .help = "spread packets among several queues",
3484 .priv = PRIV_ACTION(RSS, sizeof(struct action_rss_data)),
3485 .next = NEXT(action_rss),
3486 .call = parse_vc_action_rss,
3488 [ACTION_RSS_FUNC] = {
3490 .help = "RSS hash function to apply",
3491 .next = NEXT(action_rss,
3492 NEXT_ENTRY(ACTION_RSS_FUNC_DEFAULT,
3493 ACTION_RSS_FUNC_TOEPLITZ,
3494 ACTION_RSS_FUNC_SIMPLE_XOR,
3495 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ)),
3497 [ACTION_RSS_FUNC_DEFAULT] = {
3499 .help = "default hash function",
3500 .call = parse_vc_action_rss_func,
3502 [ACTION_RSS_FUNC_TOEPLITZ] = {
3504 .help = "Toeplitz hash function",
3505 .call = parse_vc_action_rss_func,
3507 [ACTION_RSS_FUNC_SIMPLE_XOR] = {
3508 .name = "simple_xor",
3509 .help = "simple XOR hash function",
3510 .call = parse_vc_action_rss_func,
3512 [ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ] = {
3513 .name = "symmetric_toeplitz",
3514 .help = "Symmetric Toeplitz hash function",
3515 .call = parse_vc_action_rss_func,
3517 [ACTION_RSS_LEVEL] = {
3519 .help = "encapsulation level for \"types\"",
3520 .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
3521 .args = ARGS(ARGS_ENTRY_ARB
3522 (offsetof(struct action_rss_data, conf) +
3523 offsetof(struct rte_flow_action_rss, level),
3524 sizeof(((struct rte_flow_action_rss *)0)->
3527 [ACTION_RSS_TYPES] = {
3529 .help = "specific RSS hash types",
3530 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)),
3532 [ACTION_RSS_TYPE] = {
3534 .help = "RSS hash type",
3535 .call = parse_vc_action_rss_type,
3536 .comp = comp_vc_action_rss_type,
3538 [ACTION_RSS_KEY] = {
3540 .help = "RSS hash key",
3541 .next = NEXT(action_rss, NEXT_ENTRY(HEX)),
3542 .args = ARGS(ARGS_ENTRY_ARB(0, 0),
3544 (offsetof(struct action_rss_data, conf) +
3545 offsetof(struct rte_flow_action_rss, key_len),
3546 sizeof(((struct rte_flow_action_rss *)0)->
3548 ARGS_ENTRY(struct action_rss_data, key)),
3550 [ACTION_RSS_KEY_LEN] = {
3552 .help = "RSS hash key length in bytes",
3553 .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
3554 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
3555 (offsetof(struct action_rss_data, conf) +
3556 offsetof(struct rte_flow_action_rss, key_len),
3557 sizeof(((struct rte_flow_action_rss *)0)->
3560 RSS_HASH_KEY_LENGTH)),
3562 [ACTION_RSS_QUEUES] = {
3564 .help = "queue indices to use",
3565 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_QUEUE)),
3566 .call = parse_vc_conf,
3568 [ACTION_RSS_QUEUE] = {
3570 .help = "queue index",
3571 .call = parse_vc_action_rss_queue,
3572 .comp = comp_vc_action_rss_queue,
3576 .help = "direct traffic to physical function",
3577 .priv = PRIV_ACTION(PF, 0),
3578 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3583 .help = "direct traffic to a virtual function ID",
3584 .priv = PRIV_ACTION(VF, sizeof(struct rte_flow_action_vf)),
3585 .next = NEXT(action_vf),
3588 [ACTION_VF_ORIGINAL] = {
3590 .help = "use original VF ID if possible",
3591 .next = NEXT(action_vf, NEXT_ENTRY(BOOLEAN)),
3592 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_vf,
3594 .call = parse_vc_conf,
3599 .next = NEXT(action_vf, NEXT_ENTRY(UNSIGNED)),
3600 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)),
3601 .call = parse_vc_conf,
3603 [ACTION_PHY_PORT] = {
3605 .help = "direct packets to physical port index",
3606 .priv = PRIV_ACTION(PHY_PORT,
3607 sizeof(struct rte_flow_action_phy_port)),
3608 .next = NEXT(action_phy_port),
3611 [ACTION_PHY_PORT_ORIGINAL] = {
3613 .help = "use original port index if possible",
3614 .next = NEXT(action_phy_port, NEXT_ENTRY(BOOLEAN)),
3615 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_phy_port,
3617 .call = parse_vc_conf,
3619 [ACTION_PHY_PORT_INDEX] = {
3621 .help = "physical port index",
3622 .next = NEXT(action_phy_port, NEXT_ENTRY(UNSIGNED)),
3623 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_phy_port,
3625 .call = parse_vc_conf,
3627 [ACTION_PORT_ID] = {
3629 .help = "direct matching traffic to a given DPDK port ID",
3630 .priv = PRIV_ACTION(PORT_ID,
3631 sizeof(struct rte_flow_action_port_id)),
3632 .next = NEXT(action_port_id),
3635 [ACTION_PORT_ID_ORIGINAL] = {
3637 .help = "use original DPDK port ID if possible",
3638 .next = NEXT(action_port_id, NEXT_ENTRY(BOOLEAN)),
3639 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_port_id,
3641 .call = parse_vc_conf,
3643 [ACTION_PORT_ID_ID] = {
3645 .help = "DPDK port ID",
3646 .next = NEXT(action_port_id, NEXT_ENTRY(UNSIGNED)),
3647 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_port_id, id)),
3648 .call = parse_vc_conf,
3652 .help = "meter the directed packets at given id",
3653 .priv = PRIV_ACTION(METER,
3654 sizeof(struct rte_flow_action_meter)),
3655 .next = NEXT(action_meter),
3658 [ACTION_METER_ID] = {
3660 .help = "meter id to use",
3661 .next = NEXT(action_meter, NEXT_ENTRY(UNSIGNED)),
3662 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter, mtr_id)),
3663 .call = parse_vc_conf,
3665 [ACTION_OF_SET_MPLS_TTL] = {
3666 .name = "of_set_mpls_ttl",
3667 .help = "OpenFlow's OFPAT_SET_MPLS_TTL",
3670 sizeof(struct rte_flow_action_of_set_mpls_ttl)),
3671 .next = NEXT(action_of_set_mpls_ttl),
3674 [ACTION_OF_SET_MPLS_TTL_MPLS_TTL] = {
3677 .next = NEXT(action_of_set_mpls_ttl, NEXT_ENTRY(UNSIGNED)),
3678 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_mpls_ttl,
3680 .call = parse_vc_conf,
3682 [ACTION_OF_DEC_MPLS_TTL] = {
3683 .name = "of_dec_mpls_ttl",
3684 .help = "OpenFlow's OFPAT_DEC_MPLS_TTL",
3685 .priv = PRIV_ACTION(OF_DEC_MPLS_TTL, 0),
3686 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3689 [ACTION_OF_SET_NW_TTL] = {
3690 .name = "of_set_nw_ttl",
3691 .help = "OpenFlow's OFPAT_SET_NW_TTL",
3694 sizeof(struct rte_flow_action_of_set_nw_ttl)),
3695 .next = NEXT(action_of_set_nw_ttl),
3698 [ACTION_OF_SET_NW_TTL_NW_TTL] = {
3701 .next = NEXT(action_of_set_nw_ttl, NEXT_ENTRY(UNSIGNED)),
3702 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_nw_ttl,
3704 .call = parse_vc_conf,
3706 [ACTION_OF_DEC_NW_TTL] = {
3707 .name = "of_dec_nw_ttl",
3708 .help = "OpenFlow's OFPAT_DEC_NW_TTL",
3709 .priv = PRIV_ACTION(OF_DEC_NW_TTL, 0),
3710 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3713 [ACTION_OF_COPY_TTL_OUT] = {
3714 .name = "of_copy_ttl_out",
3715 .help = "OpenFlow's OFPAT_COPY_TTL_OUT",
3716 .priv = PRIV_ACTION(OF_COPY_TTL_OUT, 0),
3717 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3720 [ACTION_OF_COPY_TTL_IN] = {
3721 .name = "of_copy_ttl_in",
3722 .help = "OpenFlow's OFPAT_COPY_TTL_IN",
3723 .priv = PRIV_ACTION(OF_COPY_TTL_IN, 0),
3724 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3727 [ACTION_OF_POP_VLAN] = {
3728 .name = "of_pop_vlan",
3729 .help = "OpenFlow's OFPAT_POP_VLAN",
3730 .priv = PRIV_ACTION(OF_POP_VLAN, 0),
3731 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3734 [ACTION_OF_PUSH_VLAN] = {
3735 .name = "of_push_vlan",
3736 .help = "OpenFlow's OFPAT_PUSH_VLAN",
3739 sizeof(struct rte_flow_action_of_push_vlan)),
3740 .next = NEXT(action_of_push_vlan),
3743 [ACTION_OF_PUSH_VLAN_ETHERTYPE] = {
3744 .name = "ethertype",
3745 .help = "EtherType",
3746 .next = NEXT(action_of_push_vlan, NEXT_ENTRY(UNSIGNED)),
3747 .args = ARGS(ARGS_ENTRY_HTON
3748 (struct rte_flow_action_of_push_vlan,
3750 .call = parse_vc_conf,
3752 [ACTION_OF_SET_VLAN_VID] = {
3753 .name = "of_set_vlan_vid",
3754 .help = "OpenFlow's OFPAT_SET_VLAN_VID",
3757 sizeof(struct rte_flow_action_of_set_vlan_vid)),
3758 .next = NEXT(action_of_set_vlan_vid),
3761 [ACTION_OF_SET_VLAN_VID_VLAN_VID] = {
3764 .next = NEXT(action_of_set_vlan_vid, NEXT_ENTRY(UNSIGNED)),
3765 .args = ARGS(ARGS_ENTRY_HTON
3766 (struct rte_flow_action_of_set_vlan_vid,
3768 .call = parse_vc_conf,
3770 [ACTION_OF_SET_VLAN_PCP] = {
3771 .name = "of_set_vlan_pcp",
3772 .help = "OpenFlow's OFPAT_SET_VLAN_PCP",
3775 sizeof(struct rte_flow_action_of_set_vlan_pcp)),
3776 .next = NEXT(action_of_set_vlan_pcp),
3779 [ACTION_OF_SET_VLAN_PCP_VLAN_PCP] = {
3781 .help = "VLAN priority",
3782 .next = NEXT(action_of_set_vlan_pcp, NEXT_ENTRY(UNSIGNED)),
3783 .args = ARGS(ARGS_ENTRY_HTON
3784 (struct rte_flow_action_of_set_vlan_pcp,
3786 .call = parse_vc_conf,
3788 [ACTION_OF_POP_MPLS] = {
3789 .name = "of_pop_mpls",
3790 .help = "OpenFlow's OFPAT_POP_MPLS",
3791 .priv = PRIV_ACTION(OF_POP_MPLS,
3792 sizeof(struct rte_flow_action_of_pop_mpls)),
3793 .next = NEXT(action_of_pop_mpls),
3796 [ACTION_OF_POP_MPLS_ETHERTYPE] = {
3797 .name = "ethertype",
3798 .help = "EtherType",
3799 .next = NEXT(action_of_pop_mpls, NEXT_ENTRY(UNSIGNED)),
3800 .args = ARGS(ARGS_ENTRY_HTON
3801 (struct rte_flow_action_of_pop_mpls,
3803 .call = parse_vc_conf,
3805 [ACTION_OF_PUSH_MPLS] = {
3806 .name = "of_push_mpls",
3807 .help = "OpenFlow's OFPAT_PUSH_MPLS",
3810 sizeof(struct rte_flow_action_of_push_mpls)),
3811 .next = NEXT(action_of_push_mpls),
3814 [ACTION_OF_PUSH_MPLS_ETHERTYPE] = {
3815 .name = "ethertype",
3816 .help = "EtherType",
3817 .next = NEXT(action_of_push_mpls, NEXT_ENTRY(UNSIGNED)),
3818 .args = ARGS(ARGS_ENTRY_HTON
3819 (struct rte_flow_action_of_push_mpls,
3821 .call = parse_vc_conf,
3823 [ACTION_VXLAN_ENCAP] = {
3824 .name = "vxlan_encap",
3825 .help = "VXLAN encapsulation, uses configuration set by \"set"
3827 .priv = PRIV_ACTION(VXLAN_ENCAP,
3828 sizeof(struct action_vxlan_encap_data)),
3829 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3830 .call = parse_vc_action_vxlan_encap,
3832 [ACTION_VXLAN_DECAP] = {
3833 .name = "vxlan_decap",
3834 .help = "Performs a decapsulation action by stripping all"
3835 " headers of the VXLAN tunnel network overlay from the"
3837 .priv = PRIV_ACTION(VXLAN_DECAP, 0),
3838 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3841 [ACTION_NVGRE_ENCAP] = {
3842 .name = "nvgre_encap",
3843 .help = "NVGRE encapsulation, uses configuration set by \"set"
3845 .priv = PRIV_ACTION(NVGRE_ENCAP,
3846 sizeof(struct action_nvgre_encap_data)),
3847 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3848 .call = parse_vc_action_nvgre_encap,
3850 [ACTION_NVGRE_DECAP] = {
3851 .name = "nvgre_decap",
3852 .help = "Performs a decapsulation action by stripping all"
3853 " headers of the NVGRE tunnel network overlay from the"
3855 .priv = PRIV_ACTION(NVGRE_DECAP, 0),
3856 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3859 [ACTION_L2_ENCAP] = {
3861 .help = "l2 encap, uses configuration set by"
3862 " \"set l2_encap\"",
3863 .priv = PRIV_ACTION(RAW_ENCAP,
3864 sizeof(struct action_raw_encap_data)),
3865 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3866 .call = parse_vc_action_l2_encap,
3868 [ACTION_L2_DECAP] = {
3870 .help = "l2 decap, uses configuration set by"
3871 " \"set l2_decap\"",
3872 .priv = PRIV_ACTION(RAW_DECAP,
3873 sizeof(struct action_raw_decap_data)),
3874 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3875 .call = parse_vc_action_l2_decap,
3877 [ACTION_MPLSOGRE_ENCAP] = {
3878 .name = "mplsogre_encap",
3879 .help = "mplsogre encapsulation, uses configuration set by"
3880 " \"set mplsogre_encap\"",
3881 .priv = PRIV_ACTION(RAW_ENCAP,
3882 sizeof(struct action_raw_encap_data)),
3883 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3884 .call = parse_vc_action_mplsogre_encap,
3886 [ACTION_MPLSOGRE_DECAP] = {
3887 .name = "mplsogre_decap",
3888 .help = "mplsogre decapsulation, uses configuration set by"
3889 " \"set mplsogre_decap\"",
3890 .priv = PRIV_ACTION(RAW_DECAP,
3891 sizeof(struct action_raw_decap_data)),
3892 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3893 .call = parse_vc_action_mplsogre_decap,
3895 [ACTION_MPLSOUDP_ENCAP] = {
3896 .name = "mplsoudp_encap",
3897 .help = "mplsoudp encapsulation, uses configuration set by"
3898 " \"set mplsoudp_encap\"",
3899 .priv = PRIV_ACTION(RAW_ENCAP,
3900 sizeof(struct action_raw_encap_data)),
3901 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3902 .call = parse_vc_action_mplsoudp_encap,
3904 [ACTION_MPLSOUDP_DECAP] = {
3905 .name = "mplsoudp_decap",
3906 .help = "mplsoudp decapsulation, uses configuration set by"
3907 " \"set mplsoudp_decap\"",
3908 .priv = PRIV_ACTION(RAW_DECAP,
3909 sizeof(struct action_raw_decap_data)),
3910 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3911 .call = parse_vc_action_mplsoudp_decap,
3913 [ACTION_SET_IPV4_SRC] = {
3914 .name = "set_ipv4_src",
3915 .help = "Set a new IPv4 source address in the outermost"
3917 .priv = PRIV_ACTION(SET_IPV4_SRC,
3918 sizeof(struct rte_flow_action_set_ipv4)),
3919 .next = NEXT(action_set_ipv4_src),
3922 [ACTION_SET_IPV4_SRC_IPV4_SRC] = {
3923 .name = "ipv4_addr",
3924 .help = "new IPv4 source address to set",
3925 .next = NEXT(action_set_ipv4_src, NEXT_ENTRY(IPV4_ADDR)),
3926 .args = ARGS(ARGS_ENTRY_HTON
3927 (struct rte_flow_action_set_ipv4, ipv4_addr)),
3928 .call = parse_vc_conf,
3930 [ACTION_SET_IPV4_DST] = {
3931 .name = "set_ipv4_dst",
3932 .help = "Set a new IPv4 destination address in the outermost"
3934 .priv = PRIV_ACTION(SET_IPV4_DST,
3935 sizeof(struct rte_flow_action_set_ipv4)),
3936 .next = NEXT(action_set_ipv4_dst),
3939 [ACTION_SET_IPV4_DST_IPV4_DST] = {
3940 .name = "ipv4_addr",
3941 .help = "new IPv4 destination address to set",
3942 .next = NEXT(action_set_ipv4_dst, NEXT_ENTRY(IPV4_ADDR)),
3943 .args = ARGS(ARGS_ENTRY_HTON
3944 (struct rte_flow_action_set_ipv4, ipv4_addr)),
3945 .call = parse_vc_conf,
3947 [ACTION_SET_IPV6_SRC] = {
3948 .name = "set_ipv6_src",
3949 .help = "Set a new IPv6 source address in the outermost"
3951 .priv = PRIV_ACTION(SET_IPV6_SRC,
3952 sizeof(struct rte_flow_action_set_ipv6)),
3953 .next = NEXT(action_set_ipv6_src),
3956 [ACTION_SET_IPV6_SRC_IPV6_SRC] = {
3957 .name = "ipv6_addr",
3958 .help = "new IPv6 source address to set",
3959 .next = NEXT(action_set_ipv6_src, NEXT_ENTRY(IPV6_ADDR)),
3960 .args = ARGS(ARGS_ENTRY_HTON
3961 (struct rte_flow_action_set_ipv6, ipv6_addr)),
3962 .call = parse_vc_conf,
3964 [ACTION_SET_IPV6_DST] = {
3965 .name = "set_ipv6_dst",
3966 .help = "Set a new IPv6 destination address in the outermost"
3968 .priv = PRIV_ACTION(SET_IPV6_DST,
3969 sizeof(struct rte_flow_action_set_ipv6)),
3970 .next = NEXT(action_set_ipv6_dst),
3973 [ACTION_SET_IPV6_DST_IPV6_DST] = {
3974 .name = "ipv6_addr",
3975 .help = "new IPv6 destination address to set",
3976 .next = NEXT(action_set_ipv6_dst, NEXT_ENTRY(IPV6_ADDR)),
3977 .args = ARGS(ARGS_ENTRY_HTON
3978 (struct rte_flow_action_set_ipv6, ipv6_addr)),
3979 .call = parse_vc_conf,
3981 [ACTION_SET_TP_SRC] = {
3982 .name = "set_tp_src",
3983 .help = "set a new source port number in the outermost"
3985 .priv = PRIV_ACTION(SET_TP_SRC,
3986 sizeof(struct rte_flow_action_set_tp)),
3987 .next = NEXT(action_set_tp_src),
3990 [ACTION_SET_TP_SRC_TP_SRC] = {
3992 .help = "new source port number to set",
3993 .next = NEXT(action_set_tp_src, NEXT_ENTRY(UNSIGNED)),
3994 .args = ARGS(ARGS_ENTRY_HTON
3995 (struct rte_flow_action_set_tp, port)),
3996 .call = parse_vc_conf,
3998 [ACTION_SET_TP_DST] = {
3999 .name = "set_tp_dst",
4000 .help = "set a new destination port number in the outermost"
4002 .priv = PRIV_ACTION(SET_TP_DST,
4003 sizeof(struct rte_flow_action_set_tp)),
4004 .next = NEXT(action_set_tp_dst),
4007 [ACTION_SET_TP_DST_TP_DST] = {
4009 .help = "new destination port number to set",
4010 .next = NEXT(action_set_tp_dst, NEXT_ENTRY(UNSIGNED)),
4011 .args = ARGS(ARGS_ENTRY_HTON
4012 (struct rte_flow_action_set_tp, port)),
4013 .call = parse_vc_conf,
4015 [ACTION_MAC_SWAP] = {
4017 .help = "Swap the source and destination MAC addresses"
4018 " in the outermost Ethernet header",
4019 .priv = PRIV_ACTION(MAC_SWAP, 0),
4020 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4023 [ACTION_DEC_TTL] = {
4025 .help = "decrease network TTL if available",
4026 .priv = PRIV_ACTION(DEC_TTL, 0),
4027 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4030 [ACTION_SET_TTL] = {
4032 .help = "set ttl value",
4033 .priv = PRIV_ACTION(SET_TTL,
4034 sizeof(struct rte_flow_action_set_ttl)),
4035 .next = NEXT(action_set_ttl),
4038 [ACTION_SET_TTL_TTL] = {
4039 .name = "ttl_value",
4040 .help = "new ttl value to set",
4041 .next = NEXT(action_set_ttl, NEXT_ENTRY(UNSIGNED)),
4042 .args = ARGS(ARGS_ENTRY_HTON
4043 (struct rte_flow_action_set_ttl, ttl_value)),
4044 .call = parse_vc_conf,
4046 [ACTION_SET_MAC_SRC] = {
4047 .name = "set_mac_src",
4048 .help = "set source mac address",
4049 .priv = PRIV_ACTION(SET_MAC_SRC,
4050 sizeof(struct rte_flow_action_set_mac)),
4051 .next = NEXT(action_set_mac_src),
4054 [ACTION_SET_MAC_SRC_MAC_SRC] = {
4056 .help = "new source mac address",
4057 .next = NEXT(action_set_mac_src, NEXT_ENTRY(MAC_ADDR)),
4058 .args = ARGS(ARGS_ENTRY_HTON
4059 (struct rte_flow_action_set_mac, mac_addr)),
4060 .call = parse_vc_conf,
4062 [ACTION_SET_MAC_DST] = {
4063 .name = "set_mac_dst",
4064 .help = "set destination mac address",
4065 .priv = PRIV_ACTION(SET_MAC_DST,
4066 sizeof(struct rte_flow_action_set_mac)),
4067 .next = NEXT(action_set_mac_dst),
4070 [ACTION_SET_MAC_DST_MAC_DST] = {
4072 .help = "new destination mac address to set",
4073 .next = NEXT(action_set_mac_dst, NEXT_ENTRY(MAC_ADDR)),
4074 .args = ARGS(ARGS_ENTRY_HTON
4075 (struct rte_flow_action_set_mac, mac_addr)),
4076 .call = parse_vc_conf,
4078 [ACTION_INC_TCP_SEQ] = {
4079 .name = "inc_tcp_seq",
4080 .help = "increase TCP sequence number",
4081 .priv = PRIV_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
4082 .next = NEXT(action_inc_tcp_seq),
4085 [ACTION_INC_TCP_SEQ_VALUE] = {
4087 .help = "the value to increase TCP sequence number by",
4088 .next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(UNSIGNED)),
4089 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4090 .call = parse_vc_conf,
4092 [ACTION_DEC_TCP_SEQ] = {
4093 .name = "dec_tcp_seq",
4094 .help = "decrease TCP sequence number",
4095 .priv = PRIV_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
4096 .next = NEXT(action_dec_tcp_seq),
4099 [ACTION_DEC_TCP_SEQ_VALUE] = {
4101 .help = "the value to decrease TCP sequence number by",
4102 .next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(UNSIGNED)),
4103 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4104 .call = parse_vc_conf,
4106 [ACTION_INC_TCP_ACK] = {
4107 .name = "inc_tcp_ack",
4108 .help = "increase TCP acknowledgment number",
4109 .priv = PRIV_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
4110 .next = NEXT(action_inc_tcp_ack),
4113 [ACTION_INC_TCP_ACK_VALUE] = {
4115 .help = "the value to increase TCP acknowledgment number by",
4116 .next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(UNSIGNED)),
4117 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4118 .call = parse_vc_conf,
4120 [ACTION_DEC_TCP_ACK] = {
4121 .name = "dec_tcp_ack",
4122 .help = "decrease TCP acknowledgment number",
4123 .priv = PRIV_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
4124 .next = NEXT(action_dec_tcp_ack),
4127 [ACTION_DEC_TCP_ACK_VALUE] = {
4129 .help = "the value to decrease TCP acknowledgment number by",
4130 .next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(UNSIGNED)),
4131 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4132 .call = parse_vc_conf,
4134 [ACTION_RAW_ENCAP] = {
4135 .name = "raw_encap",
4136 .help = "encapsulation data, defined by set raw_encap",
4137 .priv = PRIV_ACTION(RAW_ENCAP,
4138 sizeof(struct action_raw_encap_data)),
4139 .next = NEXT(action_raw_encap),
4140 .call = parse_vc_action_raw_encap,
4142 [ACTION_RAW_ENCAP_INDEX] = {
4144 .help = "the index of raw_encap_confs",
4145 .next = NEXT(NEXT_ENTRY(ACTION_RAW_ENCAP_INDEX_VALUE)),
4147 [ACTION_RAW_ENCAP_INDEX_VALUE] = {
4150 .help = "unsigned integer value",
4151 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4152 .call = parse_vc_action_raw_encap_index,
4153 .comp = comp_set_raw_index,
4155 [ACTION_RAW_DECAP] = {
4156 .name = "raw_decap",
4157 .help = "decapsulation data, defined by set raw_encap",
4158 .priv = PRIV_ACTION(RAW_DECAP,
4159 sizeof(struct action_raw_decap_data)),
4160 .next = NEXT(action_raw_decap),
4161 .call = parse_vc_action_raw_decap,
4163 [ACTION_RAW_DECAP_INDEX] = {
4165 .help = "the index of raw_encap_confs",
4166 .next = NEXT(NEXT_ENTRY(ACTION_RAW_DECAP_INDEX_VALUE)),
4168 [ACTION_RAW_DECAP_INDEX_VALUE] = {
4171 .help = "unsigned integer value",
4172 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4173 .call = parse_vc_action_raw_decap_index,
4174 .comp = comp_set_raw_index,
4176 [ACTION_MODIFY_FIELD] = {
4177 .name = "modify_field",
4178 .help = "modify destination field with data from source field",
4179 .priv = PRIV_ACTION(MODIFY_FIELD,
4180 sizeof(struct rte_flow_action_modify_field)),
4181 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_OP)),
4184 [ACTION_MODIFY_FIELD_OP] = {
4186 .help = "operation type",
4187 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_TYPE),
4188 NEXT_ENTRY(ACTION_MODIFY_FIELD_OP_VALUE)),
4189 .call = parse_vc_conf,
4191 [ACTION_MODIFY_FIELD_OP_VALUE] = {
4192 .name = "{operation}",
4193 .help = "operation type value",
4194 .call = parse_vc_modify_field_op,
4195 .comp = comp_set_modify_field_op,
4197 [ACTION_MODIFY_FIELD_DST_TYPE] = {
4199 .help = "destination field type",
4200 .next = NEXT(action_modify_field_dst,
4201 NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_TYPE_VALUE)),
4202 .call = parse_vc_conf,
4204 [ACTION_MODIFY_FIELD_DST_TYPE_VALUE] = {
4205 .name = "{dst_type}",
4206 .help = "destination field type value",
4207 .call = parse_vc_modify_field_id,
4208 .comp = comp_set_modify_field_id,
4210 [ACTION_MODIFY_FIELD_DST_LEVEL] = {
4211 .name = "dst_level",
4212 .help = "destination field level",
4213 .next = NEXT(action_modify_field_dst, NEXT_ENTRY(UNSIGNED)),
4214 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4216 .call = parse_vc_conf,
4218 [ACTION_MODIFY_FIELD_DST_OFFSET] = {
4219 .name = "dst_offset",
4220 .help = "destination field bit offset",
4221 .next = NEXT(action_modify_field_dst, NEXT_ENTRY(UNSIGNED)),
4222 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4224 .call = parse_vc_conf,
4226 [ACTION_MODIFY_FIELD_SRC_TYPE] = {
4228 .help = "source field type",
4229 .next = NEXT(action_modify_field_src,
4230 NEXT_ENTRY(ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)),
4231 .call = parse_vc_conf,
4233 [ACTION_MODIFY_FIELD_SRC_TYPE_VALUE] = {
4234 .name = "{src_type}",
4235 .help = "source field type value",
4236 .call = parse_vc_modify_field_id,
4237 .comp = comp_set_modify_field_id,
4239 [ACTION_MODIFY_FIELD_SRC_LEVEL] = {
4240 .name = "src_level",
4241 .help = "source field level",
4242 .next = NEXT(action_modify_field_src, NEXT_ENTRY(UNSIGNED)),
4243 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4245 .call = parse_vc_conf,
4247 [ACTION_MODIFY_FIELD_SRC_OFFSET] = {
4248 .name = "src_offset",
4249 .help = "source field bit offset",
4250 .next = NEXT(action_modify_field_src, NEXT_ENTRY(UNSIGNED)),
4251 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4253 .call = parse_vc_conf,
4255 [ACTION_MODIFY_FIELD_SRC_VALUE] = {
4256 .name = "src_value",
4257 .help = "source immediate value",
4258 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_WIDTH),
4259 NEXT_ENTRY(UNSIGNED)),
4260 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4262 .call = parse_vc_conf,
4264 [ACTION_MODIFY_FIELD_WIDTH] = {
4266 .help = "number of bits to copy",
4267 .next = NEXT(NEXT_ENTRY(ACTION_NEXT),
4268 NEXT_ENTRY(UNSIGNED)),
4269 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4271 .call = parse_vc_conf,
4273 /* Top level command. */
4276 .help = "set raw encap/decap/sample data",
4277 .type = "set raw_encap|raw_decap <index> <pattern>"
4278 " or set sample_actions <index> <action>",
4279 .next = NEXT(NEXT_ENTRY
4282 SET_SAMPLE_ACTIONS)),
4283 .call = parse_set_init,
4285 /* Sub-level commands. */
4287 .name = "raw_encap",
4288 .help = "set raw encap data",
4289 .next = NEXT(next_set_raw),
4290 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4291 (offsetof(struct buffer, port),
4292 sizeof(((struct buffer *)0)->port),
4293 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
4294 .call = parse_set_raw_encap_decap,
4297 .name = "raw_decap",
4298 .help = "set raw decap data",
4299 .next = NEXT(next_set_raw),
4300 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4301 (offsetof(struct buffer, port),
4302 sizeof(((struct buffer *)0)->port),
4303 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
4304 .call = parse_set_raw_encap_decap,
4309 .help = "index of raw_encap/raw_decap data",
4310 .next = NEXT(next_item),
4313 [SET_SAMPLE_INDEX] = {
4316 .help = "index of sample actions",
4317 .next = NEXT(next_action_sample),
4320 [SET_SAMPLE_ACTIONS] = {
4321 .name = "sample_actions",
4322 .help = "set sample actions list",
4323 .next = NEXT(NEXT_ENTRY(SET_SAMPLE_INDEX)),
4324 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4325 (offsetof(struct buffer, port),
4326 sizeof(((struct buffer *)0)->port),
4327 0, RAW_SAMPLE_CONFS_MAX_NUM - 1)),
4328 .call = parse_set_sample_action,
4330 [ACTION_SET_TAG] = {
4333 .priv = PRIV_ACTION(SET_TAG,
4334 sizeof(struct rte_flow_action_set_tag)),
4335 .next = NEXT(action_set_tag),
4338 [ACTION_SET_TAG_INDEX] = {
4340 .help = "index of tag array",
4341 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
4342 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_set_tag, index)),
4343 .call = parse_vc_conf,
4345 [ACTION_SET_TAG_DATA] = {
4347 .help = "tag value",
4348 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
4349 .args = ARGS(ARGS_ENTRY
4350 (struct rte_flow_action_set_tag, data)),
4351 .call = parse_vc_conf,
4353 [ACTION_SET_TAG_MASK] = {
4355 .help = "mask for tag value",
4356 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
4357 .args = ARGS(ARGS_ENTRY
4358 (struct rte_flow_action_set_tag, mask)),
4359 .call = parse_vc_conf,
4361 [ACTION_SET_META] = {
4363 .help = "set metadata",
4364 .priv = PRIV_ACTION(SET_META,
4365 sizeof(struct rte_flow_action_set_meta)),
4366 .next = NEXT(action_set_meta),
4367 .call = parse_vc_action_set_meta,
4369 [ACTION_SET_META_DATA] = {
4371 .help = "metadata value",
4372 .next = NEXT(action_set_meta, NEXT_ENTRY(UNSIGNED)),
4373 .args = ARGS(ARGS_ENTRY
4374 (struct rte_flow_action_set_meta, data)),
4375 .call = parse_vc_conf,
4377 [ACTION_SET_META_MASK] = {
4379 .help = "mask for metadata value",
4380 .next = NEXT(action_set_meta, NEXT_ENTRY(UNSIGNED)),
4381 .args = ARGS(ARGS_ENTRY
4382 (struct rte_flow_action_set_meta, mask)),
4383 .call = parse_vc_conf,
4385 [ACTION_SET_IPV4_DSCP] = {
4386 .name = "set_ipv4_dscp",
4387 .help = "set DSCP value",
4388 .priv = PRIV_ACTION(SET_IPV4_DSCP,
4389 sizeof(struct rte_flow_action_set_dscp)),
4390 .next = NEXT(action_set_ipv4_dscp),
4393 [ACTION_SET_IPV4_DSCP_VALUE] = {
4394 .name = "dscp_value",
4395 .help = "new IPv4 DSCP value to set",
4396 .next = NEXT(action_set_ipv4_dscp, NEXT_ENTRY(UNSIGNED)),
4397 .args = ARGS(ARGS_ENTRY
4398 (struct rte_flow_action_set_dscp, dscp)),
4399 .call = parse_vc_conf,
4401 [ACTION_SET_IPV6_DSCP] = {
4402 .name = "set_ipv6_dscp",
4403 .help = "set DSCP value",
4404 .priv = PRIV_ACTION(SET_IPV6_DSCP,
4405 sizeof(struct rte_flow_action_set_dscp)),
4406 .next = NEXT(action_set_ipv6_dscp),
4409 [ACTION_SET_IPV6_DSCP_VALUE] = {
4410 .name = "dscp_value",
4411 .help = "new IPv6 DSCP value to set",
4412 .next = NEXT(action_set_ipv6_dscp, NEXT_ENTRY(UNSIGNED)),
4413 .args = ARGS(ARGS_ENTRY
4414 (struct rte_flow_action_set_dscp, dscp)),
4415 .call = parse_vc_conf,
4419 .help = "set a specific metadata header",
4420 .next = NEXT(action_age),
4421 .priv = PRIV_ACTION(AGE,
4422 sizeof(struct rte_flow_action_age)),
4425 [ACTION_AGE_TIMEOUT] = {
4427 .help = "flow age timeout value",
4428 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_age,
4430 .next = NEXT(action_age, NEXT_ENTRY(UNSIGNED)),
4431 .call = parse_vc_conf,
4435 .help = "set a sample action",
4436 .next = NEXT(action_sample),
4437 .priv = PRIV_ACTION(SAMPLE,
4438 sizeof(struct action_sample_data)),
4439 .call = parse_vc_action_sample,
4441 [ACTION_SAMPLE_RATIO] = {
4443 .help = "flow sample ratio value",
4444 .next = NEXT(action_sample, NEXT_ENTRY(UNSIGNED)),
4445 .args = ARGS(ARGS_ENTRY_ARB
4446 (offsetof(struct action_sample_data, conf) +
4447 offsetof(struct rte_flow_action_sample, ratio),
4448 sizeof(((struct rte_flow_action_sample *)0)->
4451 [ACTION_SAMPLE_INDEX] = {
4453 .help = "the index of sample actions list",
4454 .next = NEXT(NEXT_ENTRY(ACTION_SAMPLE_INDEX_VALUE)),
4456 [ACTION_SAMPLE_INDEX_VALUE] = {
4459 .help = "unsigned integer value",
4460 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4461 .call = parse_vc_action_sample_index,
4462 .comp = comp_set_sample_index,
4464 /* Shared action destroy arguments. */
4465 [SHARED_ACTION_DESTROY_ID] = {
4466 .name = "action_id",
4467 .help = "specify a shared action id to destroy",
4468 .next = NEXT(next_sa_destroy_attr,
4469 NEXT_ENTRY(SHARED_ACTION_ID)),
4470 .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
4471 args.sa_destroy.action_id)),
4472 .call = parse_sa_destroy,
4474 /* Shared action create arguments. */
4475 [SHARED_ACTION_CREATE_ID] = {
4476 .name = "action_id",
4477 .help = "specify a shared action id to create",
4478 .next = NEXT(next_sa_create_attr,
4479 NEXT_ENTRY(SHARED_ACTION_ID)),
4480 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
4484 .help = "apply shared action by id",
4485 .priv = PRIV_ACTION(SHARED, 0),
4486 .next = NEXT(NEXT_ENTRY(SHARED_ACTION_ID2PTR)),
4487 .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
4490 [SHARED_ACTION_ID2PTR] = {
4491 .name = "{action_id}",
4492 .type = "SHARED_ACTION_ID",
4493 .help = "shared action id",
4494 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4495 .call = parse_sa_id2ptr,
4498 [SHARED_ACTION_INGRESS] = {
4500 .help = "affect rule to ingress",
4501 .next = NEXT(next_sa_create_attr),
4504 [SHARED_ACTION_EGRESS] = {
4506 .help = "affect rule to egress",
4507 .next = NEXT(next_sa_create_attr),
4510 [SHARED_ACTION_TRANSFER] = {
4512 .help = "affect rule to transfer",
4513 .next = NEXT(next_sa_create_attr),
4516 [SHARED_ACTION_SPEC] = {
4518 .help = "specify action to share",
4519 .next = NEXT(next_action),
4523 /** Remove and return last entry from argument stack. */
4524 static const struct arg *
4525 pop_args(struct context *ctx)
4527 return ctx->args_num ? ctx->args[--ctx->args_num] : NULL;
4530 /** Add entry on top of the argument stack. */
4532 push_args(struct context *ctx, const struct arg *arg)
4534 if (ctx->args_num == CTX_STACK_SIZE)
4536 ctx->args[ctx->args_num++] = arg;
4540 /** Spread value into buffer according to bit-mask. */
4542 arg_entry_bf_fill(void *dst, uintmax_t val, const struct arg *arg)
4544 uint32_t i = arg->size;
4552 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
4561 unsigned int shift = 0;
4562 uint8_t *buf = (uint8_t *)dst + arg->offset + (i -= sub);
4564 for (shift = 0; arg->mask[i] >> shift; ++shift) {
4565 if (!(arg->mask[i] & (1 << shift)))
4570 *buf &= ~(1 << shift);
4571 *buf |= (val & 1) << shift;
4579 /** Compare a string with a partial one of a given length. */
4581 strcmp_partial(const char *full, const char *partial, size_t partial_len)
4583 int r = strncmp(full, partial, partial_len);
4587 if (strlen(full) <= partial_len)
4589 return full[partial_len];
4593 * Parse a prefix length and generate a bit-mask.
4595 * Last argument (ctx->args) is retrieved to determine mask size, storage
4596 * location and whether the result must use network byte ordering.
4599 parse_prefix(struct context *ctx, const struct token *token,
4600 const char *str, unsigned int len,
4601 void *buf, unsigned int size)
4603 const struct arg *arg = pop_args(ctx);
4604 static const uint8_t conv[] = "\x00\x80\xc0\xe0\xf0\xf8\xfc\xfe\xff";
4611 /* Argument is expected. */
4615 u = strtoumax(str, &end, 0);
4616 if (errno || (size_t)(end - str) != len)
4621 extra = arg_entry_bf_fill(NULL, 0, arg);
4630 if (!arg_entry_bf_fill(ctx->object, v, arg) ||
4631 !arg_entry_bf_fill(ctx->objmask, -1, arg))
4638 if (bytes > size || bytes + !!extra > size)
4642 buf = (uint8_t *)ctx->object + arg->offset;
4643 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
4645 memset((uint8_t *)buf + size - bytes, 0xff, bytes);
4646 memset(buf, 0x00, size - bytes);
4648 ((uint8_t *)buf)[size - bytes - 1] = conv[extra];
4652 memset(buf, 0xff, bytes);
4653 memset((uint8_t *)buf + bytes, 0x00, size - bytes);
4655 ((uint8_t *)buf)[bytes] = conv[extra];
4658 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
4661 push_args(ctx, arg);
4665 /** Default parsing function for token name matching. */
4667 parse_default(struct context *ctx, const struct token *token,
4668 const char *str, unsigned int len,
4669 void *buf, unsigned int size)
4674 if (strcmp_partial(token->name, str, len))
4679 /** Parse flow command, initialize output buffer for subsequent tokens. */
4681 parse_init(struct context *ctx, const struct token *token,
4682 const char *str, unsigned int len,
4683 void *buf, unsigned int size)
4685 struct buffer *out = buf;
4687 /* Token name must match. */
4688 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4690 /* Nothing else to do if there is no buffer. */
4693 /* Make sure buffer is large enough. */
4694 if (size < sizeof(*out))
4696 /* Initialize buffer. */
4697 memset(out, 0x00, sizeof(*out));
4698 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
4701 ctx->objmask = NULL;
4705 /** Parse tokens for shared action commands. */
4707 parse_sa(struct context *ctx, const struct token *token,
4708 const char *str, unsigned int len,
4709 void *buf, unsigned int size)
4711 struct buffer *out = buf;
4713 /* Token name must match. */
4714 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4716 /* Nothing else to do if there is no buffer. */
4719 if (!out->command) {
4720 if (ctx->curr != SHARED_ACTION)
4722 if (sizeof(*out) > size)
4724 out->command = ctx->curr;
4727 ctx->objmask = NULL;
4728 out->args.vc.data = (uint8_t *)out + size;
4731 switch (ctx->curr) {
4732 case SHARED_ACTION_CREATE:
4733 case SHARED_ACTION_UPDATE:
4734 out->args.vc.actions =
4735 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
4737 out->args.vc.attr.group = UINT32_MAX;
4739 case SHARED_ACTION_QUERY:
4740 out->command = ctx->curr;
4743 ctx->objmask = NULL;
4745 case SHARED_ACTION_EGRESS:
4746 out->args.vc.attr.egress = 1;
4748 case SHARED_ACTION_INGRESS:
4749 out->args.vc.attr.ingress = 1;
4751 case SHARED_ACTION_TRANSFER:
4752 out->args.vc.attr.transfer = 1;
4760 /** Parse tokens for shared action destroy command. */
4762 parse_sa_destroy(struct context *ctx, const struct token *token,
4763 const char *str, unsigned int len,
4764 void *buf, unsigned int size)
4766 struct buffer *out = buf;
4767 uint32_t *action_id;
4769 /* Token name must match. */
4770 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4772 /* Nothing else to do if there is no buffer. */
4775 if (!out->command || out->command == SHARED_ACTION) {
4776 if (ctx->curr != SHARED_ACTION_DESTROY)
4778 if (sizeof(*out) > size)
4780 out->command = ctx->curr;
4783 ctx->objmask = NULL;
4784 out->args.sa_destroy.action_id =
4785 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
4789 action_id = out->args.sa_destroy.action_id
4790 + out->args.sa_destroy.action_id_n++;
4791 if ((uint8_t *)action_id > (uint8_t *)out + size)
4794 ctx->object = action_id;
4795 ctx->objmask = NULL;
4799 /** Parse tokens for validate/create commands. */
4801 parse_vc(struct context *ctx, const struct token *token,
4802 const char *str, unsigned int len,
4803 void *buf, unsigned int size)
4805 struct buffer *out = buf;
4809 /* Token name must match. */
4810 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4812 /* Nothing else to do if there is no buffer. */
4815 if (!out->command) {
4816 if (ctx->curr != VALIDATE && ctx->curr != CREATE)
4818 if (sizeof(*out) > size)
4820 out->command = ctx->curr;
4823 ctx->objmask = NULL;
4824 out->args.vc.data = (uint8_t *)out + size;
4828 switch (ctx->curr) {
4830 ctx->object = &out->args.vc.attr;
4834 ctx->object = &out->args.vc.tunnel_ops;
4837 ctx->objmask = NULL;
4838 switch (ctx->curr) {
4843 out->args.vc.tunnel_ops.enabled = 1;
4844 out->args.vc.tunnel_ops.actions = 1;
4847 out->args.vc.tunnel_ops.enabled = 1;
4848 out->args.vc.tunnel_ops.items = 1;
4851 out->args.vc.attr.ingress = 1;
4854 out->args.vc.attr.egress = 1;
4857 out->args.vc.attr.transfer = 1;
4860 out->args.vc.pattern =
4861 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
4863 ctx->object = out->args.vc.pattern;
4864 ctx->objmask = NULL;
4867 out->args.vc.actions =
4868 (void *)RTE_ALIGN_CEIL((uintptr_t)
4869 (out->args.vc.pattern +
4870 out->args.vc.pattern_n),
4872 ctx->object = out->args.vc.actions;
4873 ctx->objmask = NULL;
4880 if (!out->args.vc.actions) {
4881 const struct parse_item_priv *priv = token->priv;
4882 struct rte_flow_item *item =
4883 out->args.vc.pattern + out->args.vc.pattern_n;
4885 data_size = priv->size * 3; /* spec, last, mask */
4886 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
4887 (out->args.vc.data - data_size),
4889 if ((uint8_t *)item + sizeof(*item) > data)
4891 *item = (struct rte_flow_item){
4894 ++out->args.vc.pattern_n;
4896 ctx->objmask = NULL;
4898 const struct parse_action_priv *priv = token->priv;
4899 struct rte_flow_action *action =
4900 out->args.vc.actions + out->args.vc.actions_n;
4902 data_size = priv->size; /* configuration */
4903 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
4904 (out->args.vc.data - data_size),
4906 if ((uint8_t *)action + sizeof(*action) > data)
4908 *action = (struct rte_flow_action){
4910 .conf = data_size ? data : NULL,
4912 ++out->args.vc.actions_n;
4913 ctx->object = action;
4914 ctx->objmask = NULL;
4916 memset(data, 0, data_size);
4917 out->args.vc.data = data;
4918 ctx->objdata = data_size;
4922 /** Parse pattern item parameter type. */
4924 parse_vc_spec(struct context *ctx, const struct token *token,
4925 const char *str, unsigned int len,
4926 void *buf, unsigned int size)
4928 struct buffer *out = buf;
4929 struct rte_flow_item *item;
4935 /* Token name must match. */
4936 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4938 /* Parse parameter types. */
4939 switch (ctx->curr) {
4940 static const enum index prefix[] = NEXT_ENTRY(PREFIX);
4946 case ITEM_PARAM_SPEC:
4949 case ITEM_PARAM_LAST:
4952 case ITEM_PARAM_PREFIX:
4953 /* Modify next token to expect a prefix. */
4954 if (ctx->next_num < 2)
4956 ctx->next[ctx->next_num - 2] = prefix;
4958 case ITEM_PARAM_MASK:
4964 /* Nothing else to do if there is no buffer. */
4967 if (!out->args.vc.pattern_n)
4969 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
4970 data_size = ctx->objdata / 3; /* spec, last, mask */
4971 /* Point to selected object. */
4972 ctx->object = out->args.vc.data + (data_size * index);
4974 ctx->objmask = out->args.vc.data + (data_size * 2); /* mask */
4975 item->mask = ctx->objmask;
4977 ctx->objmask = NULL;
4978 /* Update relevant item pointer. */
4979 *((const void **[]){ &item->spec, &item->last, &item->mask })[index] =
4984 /** Parse action configuration field. */
4986 parse_vc_conf(struct context *ctx, const struct token *token,
4987 const char *str, unsigned int len,
4988 void *buf, unsigned int size)
4990 struct buffer *out = buf;
4993 /* Token name must match. */
4994 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4996 /* Nothing else to do if there is no buffer. */
4999 /* Point to selected object. */
5000 ctx->object = out->args.vc.data;
5001 ctx->objmask = NULL;
5005 /** Parse eCPRI common header type field. */
5007 parse_vc_item_ecpri_type(struct context *ctx, const struct token *token,
5008 const char *str, unsigned int len,
5009 void *buf, unsigned int size)
5011 struct rte_flow_item_ecpri *ecpri;
5012 struct rte_flow_item_ecpri *ecpri_mask;
5013 struct rte_flow_item *item;
5016 struct buffer *out = buf;
5017 const struct arg *arg;
5020 /* Token name must match. */
5021 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5023 switch (ctx->curr) {
5024 case ITEM_ECPRI_COMMON_TYPE_IQ_DATA:
5025 msg_type = RTE_ECPRI_MSG_TYPE_IQ_DATA;
5027 case ITEM_ECPRI_COMMON_TYPE_RTC_CTRL:
5028 msg_type = RTE_ECPRI_MSG_TYPE_RTC_CTRL;
5030 case ITEM_ECPRI_COMMON_TYPE_DLY_MSR:
5031 msg_type = RTE_ECPRI_MSG_TYPE_DLY_MSR;
5038 arg = pop_args(ctx);
5041 ecpri = (struct rte_flow_item_ecpri *)out->args.vc.data;
5042 ecpri->hdr.common.type = msg_type;
5043 data_size = ctx->objdata / 3; /* spec, last, mask */
5044 ecpri_mask = (struct rte_flow_item_ecpri *)(out->args.vc.data +
5046 ecpri_mask->hdr.common.type = 0xFF;
5048 ecpri->hdr.common.u32 = rte_cpu_to_be_32(ecpri->hdr.common.u32);
5049 ecpri_mask->hdr.common.u32 =
5050 rte_cpu_to_be_32(ecpri_mask->hdr.common.u32);
5052 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
5054 item->mask = ecpri_mask;
5058 /** Parse RSS action. */
5060 parse_vc_action_rss(struct context *ctx, const struct token *token,
5061 const char *str, unsigned int len,
5062 void *buf, unsigned int size)
5064 struct buffer *out = buf;
5065 struct rte_flow_action *action;
5066 struct action_rss_data *action_rss_data;
5070 ret = parse_vc(ctx, token, str, len, buf, size);
5073 /* Nothing else to do if there is no buffer. */
5076 if (!out->args.vc.actions_n)
5078 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5079 /* Point to selected object. */
5080 ctx->object = out->args.vc.data;
5081 ctx->objmask = NULL;
5082 /* Set up default configuration. */
5083 action_rss_data = ctx->object;
5084 *action_rss_data = (struct action_rss_data){
5085 .conf = (struct rte_flow_action_rss){
5086 .func = RTE_ETH_HASH_FUNCTION_DEFAULT,
5090 .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM),
5092 .queue = action_rss_data->queue,
5096 for (i = 0; i < action_rss_data->conf.queue_num; ++i)
5097 action_rss_data->queue[i] = i;
5098 action->conf = &action_rss_data->conf;
5103 * Parse func field for RSS action.
5105 * The RTE_ETH_HASH_FUNCTION_* value to assign is derived from the
5106 * ACTION_RSS_FUNC_* index that called this function.
5109 parse_vc_action_rss_func(struct context *ctx, const struct token *token,
5110 const char *str, unsigned int len,
5111 void *buf, unsigned int size)
5113 struct action_rss_data *action_rss_data;
5114 enum rte_eth_hash_function func;
5118 /* Token name must match. */
5119 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5121 switch (ctx->curr) {
5122 case ACTION_RSS_FUNC_DEFAULT:
5123 func = RTE_ETH_HASH_FUNCTION_DEFAULT;
5125 case ACTION_RSS_FUNC_TOEPLITZ:
5126 func = RTE_ETH_HASH_FUNCTION_TOEPLITZ;
5128 case ACTION_RSS_FUNC_SIMPLE_XOR:
5129 func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
5131 case ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ:
5132 func = RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
5139 action_rss_data = ctx->object;
5140 action_rss_data->conf.func = func;
5145 * Parse type field for RSS action.
5147 * Valid tokens are type field names and the "end" token.
5150 parse_vc_action_rss_type(struct context *ctx, const struct token *token,
5151 const char *str, unsigned int len,
5152 void *buf, unsigned int size)
5154 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE);
5155 struct action_rss_data *action_rss_data;
5161 if (ctx->curr != ACTION_RSS_TYPE)
5163 if (!(ctx->objdata >> 16) && ctx->object) {
5164 action_rss_data = ctx->object;
5165 action_rss_data->conf.types = 0;
5167 if (!strcmp_partial("end", str, len)) {
5168 ctx->objdata &= 0xffff;
5171 for (i = 0; rss_type_table[i].str; ++i)
5172 if (!strcmp_partial(rss_type_table[i].str, str, len))
5174 if (!rss_type_table[i].str)
5176 ctx->objdata = 1 << 16 | (ctx->objdata & 0xffff);
5178 if (ctx->next_num == RTE_DIM(ctx->next))
5180 ctx->next[ctx->next_num++] = next;
5183 action_rss_data = ctx->object;
5184 action_rss_data->conf.types |= rss_type_table[i].rss_type;
5189 * Parse queue field for RSS action.
5191 * Valid tokens are queue indices and the "end" token.
5194 parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
5195 const char *str, unsigned int len,
5196 void *buf, unsigned int size)
5198 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE);
5199 struct action_rss_data *action_rss_data;
5200 const struct arg *arg;
5207 if (ctx->curr != ACTION_RSS_QUEUE)
5209 i = ctx->objdata >> 16;
5210 if (!strcmp_partial("end", str, len)) {
5211 ctx->objdata &= 0xffff;
5214 if (i >= ACTION_RSS_QUEUE_NUM)
5216 arg = ARGS_ENTRY_ARB(offsetof(struct action_rss_data, queue) +
5217 i * sizeof(action_rss_data->queue[i]),
5218 sizeof(action_rss_data->queue[i]));
5219 if (push_args(ctx, arg))
5221 ret = parse_int(ctx, token, str, len, NULL, 0);
5227 ctx->objdata = i << 16 | (ctx->objdata & 0xffff);
5229 if (ctx->next_num == RTE_DIM(ctx->next))
5231 ctx->next[ctx->next_num++] = next;
5235 action_rss_data = ctx->object;
5236 action_rss_data->conf.queue_num = i;
5237 action_rss_data->conf.queue = i ? action_rss_data->queue : NULL;
5241 /** Parse VXLAN encap action. */
5243 parse_vc_action_vxlan_encap(struct context *ctx, const struct token *token,
5244 const char *str, unsigned int len,
5245 void *buf, unsigned int size)
5247 struct buffer *out = buf;
5248 struct rte_flow_action *action;
5249 struct action_vxlan_encap_data *action_vxlan_encap_data;
5252 ret = parse_vc(ctx, token, str, len, buf, size);
5255 /* Nothing else to do if there is no buffer. */
5258 if (!out->args.vc.actions_n)
5260 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5261 /* Point to selected object. */
5262 ctx->object = out->args.vc.data;
5263 ctx->objmask = NULL;
5264 /* Set up default configuration. */
5265 action_vxlan_encap_data = ctx->object;
5266 *action_vxlan_encap_data = (struct action_vxlan_encap_data){
5267 .conf = (struct rte_flow_action_vxlan_encap){
5268 .definition = action_vxlan_encap_data->items,
5272 .type = RTE_FLOW_ITEM_TYPE_ETH,
5273 .spec = &action_vxlan_encap_data->item_eth,
5274 .mask = &rte_flow_item_eth_mask,
5277 .type = RTE_FLOW_ITEM_TYPE_VLAN,
5278 .spec = &action_vxlan_encap_data->item_vlan,
5279 .mask = &rte_flow_item_vlan_mask,
5282 .type = RTE_FLOW_ITEM_TYPE_IPV4,
5283 .spec = &action_vxlan_encap_data->item_ipv4,
5284 .mask = &rte_flow_item_ipv4_mask,
5287 .type = RTE_FLOW_ITEM_TYPE_UDP,
5288 .spec = &action_vxlan_encap_data->item_udp,
5289 .mask = &rte_flow_item_udp_mask,
5292 .type = RTE_FLOW_ITEM_TYPE_VXLAN,
5293 .spec = &action_vxlan_encap_data->item_vxlan,
5294 .mask = &rte_flow_item_vxlan_mask,
5297 .type = RTE_FLOW_ITEM_TYPE_END,
5302 .tci = vxlan_encap_conf.vlan_tci,
5306 .src_addr = vxlan_encap_conf.ipv4_src,
5307 .dst_addr = vxlan_encap_conf.ipv4_dst,
5310 .src_port = vxlan_encap_conf.udp_src,
5311 .dst_port = vxlan_encap_conf.udp_dst,
5313 .item_vxlan.flags = 0,
5315 memcpy(action_vxlan_encap_data->item_eth.dst.addr_bytes,
5316 vxlan_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5317 memcpy(action_vxlan_encap_data->item_eth.src.addr_bytes,
5318 vxlan_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5319 if (!vxlan_encap_conf.select_ipv4) {
5320 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.src_addr,
5321 &vxlan_encap_conf.ipv6_src,
5322 sizeof(vxlan_encap_conf.ipv6_src));
5323 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.dst_addr,
5324 &vxlan_encap_conf.ipv6_dst,
5325 sizeof(vxlan_encap_conf.ipv6_dst));
5326 action_vxlan_encap_data->items[2] = (struct rte_flow_item){
5327 .type = RTE_FLOW_ITEM_TYPE_IPV6,
5328 .spec = &action_vxlan_encap_data->item_ipv6,
5329 .mask = &rte_flow_item_ipv6_mask,
5332 if (!vxlan_encap_conf.select_vlan)
5333 action_vxlan_encap_data->items[1].type =
5334 RTE_FLOW_ITEM_TYPE_VOID;
5335 if (vxlan_encap_conf.select_tos_ttl) {
5336 if (vxlan_encap_conf.select_ipv4) {
5337 static struct rte_flow_item_ipv4 ipv4_mask_tos;
5339 memcpy(&ipv4_mask_tos, &rte_flow_item_ipv4_mask,
5340 sizeof(ipv4_mask_tos));
5341 ipv4_mask_tos.hdr.type_of_service = 0xff;
5342 ipv4_mask_tos.hdr.time_to_live = 0xff;
5343 action_vxlan_encap_data->item_ipv4.hdr.type_of_service =
5344 vxlan_encap_conf.ip_tos;
5345 action_vxlan_encap_data->item_ipv4.hdr.time_to_live =
5346 vxlan_encap_conf.ip_ttl;
5347 action_vxlan_encap_data->items[2].mask =
5350 static struct rte_flow_item_ipv6 ipv6_mask_tos;
5352 memcpy(&ipv6_mask_tos, &rte_flow_item_ipv6_mask,
5353 sizeof(ipv6_mask_tos));
5354 ipv6_mask_tos.hdr.vtc_flow |=
5355 RTE_BE32(0xfful << RTE_IPV6_HDR_TC_SHIFT);
5356 ipv6_mask_tos.hdr.hop_limits = 0xff;
5357 action_vxlan_encap_data->item_ipv6.hdr.vtc_flow |=
5359 ((uint32_t)vxlan_encap_conf.ip_tos <<
5360 RTE_IPV6_HDR_TC_SHIFT);
5361 action_vxlan_encap_data->item_ipv6.hdr.hop_limits =
5362 vxlan_encap_conf.ip_ttl;
5363 action_vxlan_encap_data->items[2].mask =
5367 memcpy(action_vxlan_encap_data->item_vxlan.vni, vxlan_encap_conf.vni,
5368 RTE_DIM(vxlan_encap_conf.vni));
5369 action->conf = &action_vxlan_encap_data->conf;
5373 /** Parse NVGRE encap action. */
5375 parse_vc_action_nvgre_encap(struct context *ctx, const struct token *token,
5376 const char *str, unsigned int len,
5377 void *buf, unsigned int size)
5379 struct buffer *out = buf;
5380 struct rte_flow_action *action;
5381 struct action_nvgre_encap_data *action_nvgre_encap_data;
5384 ret = parse_vc(ctx, token, str, len, buf, size);
5387 /* Nothing else to do if there is no buffer. */
5390 if (!out->args.vc.actions_n)
5392 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5393 /* Point to selected object. */
5394 ctx->object = out->args.vc.data;
5395 ctx->objmask = NULL;
5396 /* Set up default configuration. */
5397 action_nvgre_encap_data = ctx->object;
5398 *action_nvgre_encap_data = (struct action_nvgre_encap_data){
5399 .conf = (struct rte_flow_action_nvgre_encap){
5400 .definition = action_nvgre_encap_data->items,
5404 .type = RTE_FLOW_ITEM_TYPE_ETH,
5405 .spec = &action_nvgre_encap_data->item_eth,
5406 .mask = &rte_flow_item_eth_mask,
5409 .type = RTE_FLOW_ITEM_TYPE_VLAN,
5410 .spec = &action_nvgre_encap_data->item_vlan,
5411 .mask = &rte_flow_item_vlan_mask,
5414 .type = RTE_FLOW_ITEM_TYPE_IPV4,
5415 .spec = &action_nvgre_encap_data->item_ipv4,
5416 .mask = &rte_flow_item_ipv4_mask,
5419 .type = RTE_FLOW_ITEM_TYPE_NVGRE,
5420 .spec = &action_nvgre_encap_data->item_nvgre,
5421 .mask = &rte_flow_item_nvgre_mask,
5424 .type = RTE_FLOW_ITEM_TYPE_END,
5429 .tci = nvgre_encap_conf.vlan_tci,
5433 .src_addr = nvgre_encap_conf.ipv4_src,
5434 .dst_addr = nvgre_encap_conf.ipv4_dst,
5436 .item_nvgre.flow_id = 0,
5438 memcpy(action_nvgre_encap_data->item_eth.dst.addr_bytes,
5439 nvgre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5440 memcpy(action_nvgre_encap_data->item_eth.src.addr_bytes,
5441 nvgre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5442 if (!nvgre_encap_conf.select_ipv4) {
5443 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.src_addr,
5444 &nvgre_encap_conf.ipv6_src,
5445 sizeof(nvgre_encap_conf.ipv6_src));
5446 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.dst_addr,
5447 &nvgre_encap_conf.ipv6_dst,
5448 sizeof(nvgre_encap_conf.ipv6_dst));
5449 action_nvgre_encap_data->items[2] = (struct rte_flow_item){
5450 .type = RTE_FLOW_ITEM_TYPE_IPV6,
5451 .spec = &action_nvgre_encap_data->item_ipv6,
5452 .mask = &rte_flow_item_ipv6_mask,
5455 if (!nvgre_encap_conf.select_vlan)
5456 action_nvgre_encap_data->items[1].type =
5457 RTE_FLOW_ITEM_TYPE_VOID;
5458 memcpy(action_nvgre_encap_data->item_nvgre.tni, nvgre_encap_conf.tni,
5459 RTE_DIM(nvgre_encap_conf.tni));
5460 action->conf = &action_nvgre_encap_data->conf;
5464 /** Parse l2 encap action. */
5466 parse_vc_action_l2_encap(struct context *ctx, const struct token *token,
5467 const char *str, unsigned int len,
5468 void *buf, unsigned int size)
5470 struct buffer *out = buf;
5471 struct rte_flow_action *action;
5472 struct action_raw_encap_data *action_encap_data;
5473 struct rte_flow_item_eth eth = { .type = 0, };
5474 struct rte_flow_item_vlan vlan = {
5475 .tci = mplsoudp_encap_conf.vlan_tci,
5481 ret = parse_vc(ctx, token, str, len, buf, size);
5484 /* Nothing else to do if there is no buffer. */
5487 if (!out->args.vc.actions_n)
5489 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5490 /* Point to selected object. */
5491 ctx->object = out->args.vc.data;
5492 ctx->objmask = NULL;
5493 /* Copy the headers to the buffer. */
5494 action_encap_data = ctx->object;
5495 *action_encap_data = (struct action_raw_encap_data) {
5496 .conf = (struct rte_flow_action_raw_encap){
5497 .data = action_encap_data->data,
5501 header = action_encap_data->data;
5502 if (l2_encap_conf.select_vlan)
5503 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5504 else if (l2_encap_conf.select_ipv4)
5505 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5507 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5508 memcpy(eth.dst.addr_bytes,
5509 l2_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5510 memcpy(eth.src.addr_bytes,
5511 l2_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5512 memcpy(header, ð, sizeof(eth));
5513 header += sizeof(eth);
5514 if (l2_encap_conf.select_vlan) {
5515 if (l2_encap_conf.select_ipv4)
5516 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5518 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5519 memcpy(header, &vlan, sizeof(vlan));
5520 header += sizeof(vlan);
5522 action_encap_data->conf.size = header -
5523 action_encap_data->data;
5524 action->conf = &action_encap_data->conf;
5528 /** Parse l2 decap action. */
5530 parse_vc_action_l2_decap(struct context *ctx, const struct token *token,
5531 const char *str, unsigned int len,
5532 void *buf, unsigned int size)
5534 struct buffer *out = buf;
5535 struct rte_flow_action *action;
5536 struct action_raw_decap_data *action_decap_data;
5537 struct rte_flow_item_eth eth = { .type = 0, };
5538 struct rte_flow_item_vlan vlan = {
5539 .tci = mplsoudp_encap_conf.vlan_tci,
5545 ret = parse_vc(ctx, token, str, len, buf, size);
5548 /* Nothing else to do if there is no buffer. */
5551 if (!out->args.vc.actions_n)
5553 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5554 /* Point to selected object. */
5555 ctx->object = out->args.vc.data;
5556 ctx->objmask = NULL;
5557 /* Copy the headers to the buffer. */
5558 action_decap_data = ctx->object;
5559 *action_decap_data = (struct action_raw_decap_data) {
5560 .conf = (struct rte_flow_action_raw_decap){
5561 .data = action_decap_data->data,
5565 header = action_decap_data->data;
5566 if (l2_decap_conf.select_vlan)
5567 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5568 memcpy(header, ð, sizeof(eth));
5569 header += sizeof(eth);
5570 if (l2_decap_conf.select_vlan) {
5571 memcpy(header, &vlan, sizeof(vlan));
5572 header += sizeof(vlan);
5574 action_decap_data->conf.size = header -
5575 action_decap_data->data;
5576 action->conf = &action_decap_data->conf;
5580 #define ETHER_TYPE_MPLS_UNICAST 0x8847
5582 /** Parse MPLSOGRE encap action. */
5584 parse_vc_action_mplsogre_encap(struct context *ctx, const struct token *token,
5585 const char *str, unsigned int len,
5586 void *buf, unsigned int size)
5588 struct buffer *out = buf;
5589 struct rte_flow_action *action;
5590 struct action_raw_encap_data *action_encap_data;
5591 struct rte_flow_item_eth eth = { .type = 0, };
5592 struct rte_flow_item_vlan vlan = {
5593 .tci = mplsogre_encap_conf.vlan_tci,
5596 struct rte_flow_item_ipv4 ipv4 = {
5598 .src_addr = mplsogre_encap_conf.ipv4_src,
5599 .dst_addr = mplsogre_encap_conf.ipv4_dst,
5600 .next_proto_id = IPPROTO_GRE,
5601 .version_ihl = RTE_IPV4_VHL_DEF,
5602 .time_to_live = IPDEFTTL,
5605 struct rte_flow_item_ipv6 ipv6 = {
5607 .proto = IPPROTO_GRE,
5608 .hop_limits = IPDEFTTL,
5611 struct rte_flow_item_gre gre = {
5612 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
5614 struct rte_flow_item_mpls mpls = {
5620 ret = parse_vc(ctx, token, str, len, buf, size);
5623 /* Nothing else to do if there is no buffer. */
5626 if (!out->args.vc.actions_n)
5628 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5629 /* Point to selected object. */
5630 ctx->object = out->args.vc.data;
5631 ctx->objmask = NULL;
5632 /* Copy the headers to the buffer. */
5633 action_encap_data = ctx->object;
5634 *action_encap_data = (struct action_raw_encap_data) {
5635 .conf = (struct rte_flow_action_raw_encap){
5636 .data = action_encap_data->data,
5641 header = action_encap_data->data;
5642 if (mplsogre_encap_conf.select_vlan)
5643 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5644 else if (mplsogre_encap_conf.select_ipv4)
5645 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5647 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5648 memcpy(eth.dst.addr_bytes,
5649 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5650 memcpy(eth.src.addr_bytes,
5651 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5652 memcpy(header, ð, sizeof(eth));
5653 header += sizeof(eth);
5654 if (mplsogre_encap_conf.select_vlan) {
5655 if (mplsogre_encap_conf.select_ipv4)
5656 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5658 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5659 memcpy(header, &vlan, sizeof(vlan));
5660 header += sizeof(vlan);
5662 if (mplsogre_encap_conf.select_ipv4) {
5663 memcpy(header, &ipv4, sizeof(ipv4));
5664 header += sizeof(ipv4);
5666 memcpy(&ipv6.hdr.src_addr,
5667 &mplsogre_encap_conf.ipv6_src,
5668 sizeof(mplsogre_encap_conf.ipv6_src));
5669 memcpy(&ipv6.hdr.dst_addr,
5670 &mplsogre_encap_conf.ipv6_dst,
5671 sizeof(mplsogre_encap_conf.ipv6_dst));
5672 memcpy(header, &ipv6, sizeof(ipv6));
5673 header += sizeof(ipv6);
5675 memcpy(header, &gre, sizeof(gre));
5676 header += sizeof(gre);
5677 memcpy(mpls.label_tc_s, mplsogre_encap_conf.label,
5678 RTE_DIM(mplsogre_encap_conf.label));
5679 mpls.label_tc_s[2] |= 0x1;
5680 memcpy(header, &mpls, sizeof(mpls));
5681 header += sizeof(mpls);
5682 action_encap_data->conf.size = header -
5683 action_encap_data->data;
5684 action->conf = &action_encap_data->conf;
5688 /** Parse MPLSOGRE decap action. */
5690 parse_vc_action_mplsogre_decap(struct context *ctx, const struct token *token,
5691 const char *str, unsigned int len,
5692 void *buf, unsigned int size)
5694 struct buffer *out = buf;
5695 struct rte_flow_action *action;
5696 struct action_raw_decap_data *action_decap_data;
5697 struct rte_flow_item_eth eth = { .type = 0, };
5698 struct rte_flow_item_vlan vlan = {.tci = 0};
5699 struct rte_flow_item_ipv4 ipv4 = {
5701 .next_proto_id = IPPROTO_GRE,
5704 struct rte_flow_item_ipv6 ipv6 = {
5706 .proto = IPPROTO_GRE,
5709 struct rte_flow_item_gre gre = {
5710 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
5712 struct rte_flow_item_mpls mpls;
5716 ret = parse_vc(ctx, token, str, len, buf, size);
5719 /* Nothing else to do if there is no buffer. */
5722 if (!out->args.vc.actions_n)
5724 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5725 /* Point to selected object. */
5726 ctx->object = out->args.vc.data;
5727 ctx->objmask = NULL;
5728 /* Copy the headers to the buffer. */
5729 action_decap_data = ctx->object;
5730 *action_decap_data = (struct action_raw_decap_data) {
5731 .conf = (struct rte_flow_action_raw_decap){
5732 .data = action_decap_data->data,
5736 header = action_decap_data->data;
5737 if (mplsogre_decap_conf.select_vlan)
5738 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5739 else if (mplsogre_encap_conf.select_ipv4)
5740 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5742 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5743 memcpy(eth.dst.addr_bytes,
5744 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5745 memcpy(eth.src.addr_bytes,
5746 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5747 memcpy(header, ð, sizeof(eth));
5748 header += sizeof(eth);
5749 if (mplsogre_encap_conf.select_vlan) {
5750 if (mplsogre_encap_conf.select_ipv4)
5751 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5753 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5754 memcpy(header, &vlan, sizeof(vlan));
5755 header += sizeof(vlan);
5757 if (mplsogre_encap_conf.select_ipv4) {
5758 memcpy(header, &ipv4, sizeof(ipv4));
5759 header += sizeof(ipv4);
5761 memcpy(header, &ipv6, sizeof(ipv6));
5762 header += sizeof(ipv6);
5764 memcpy(header, &gre, sizeof(gre));
5765 header += sizeof(gre);
5766 memset(&mpls, 0, sizeof(mpls));
5767 memcpy(header, &mpls, sizeof(mpls));
5768 header += sizeof(mpls);
5769 action_decap_data->conf.size = header -
5770 action_decap_data->data;
5771 action->conf = &action_decap_data->conf;
5775 /** Parse MPLSOUDP encap action. */
5777 parse_vc_action_mplsoudp_encap(struct context *ctx, const struct token *token,
5778 const char *str, unsigned int len,
5779 void *buf, unsigned int size)
5781 struct buffer *out = buf;
5782 struct rte_flow_action *action;
5783 struct action_raw_encap_data *action_encap_data;
5784 struct rte_flow_item_eth eth = { .type = 0, };
5785 struct rte_flow_item_vlan vlan = {
5786 .tci = mplsoudp_encap_conf.vlan_tci,
5789 struct rte_flow_item_ipv4 ipv4 = {
5791 .src_addr = mplsoudp_encap_conf.ipv4_src,
5792 .dst_addr = mplsoudp_encap_conf.ipv4_dst,
5793 .next_proto_id = IPPROTO_UDP,
5794 .version_ihl = RTE_IPV4_VHL_DEF,
5795 .time_to_live = IPDEFTTL,
5798 struct rte_flow_item_ipv6 ipv6 = {
5800 .proto = IPPROTO_UDP,
5801 .hop_limits = IPDEFTTL,
5804 struct rte_flow_item_udp udp = {
5806 .src_port = mplsoudp_encap_conf.udp_src,
5807 .dst_port = mplsoudp_encap_conf.udp_dst,
5810 struct rte_flow_item_mpls mpls;
5814 ret = parse_vc(ctx, token, str, len, buf, size);
5817 /* Nothing else to do if there is no buffer. */
5820 if (!out->args.vc.actions_n)
5822 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5823 /* Point to selected object. */
5824 ctx->object = out->args.vc.data;
5825 ctx->objmask = NULL;
5826 /* Copy the headers to the buffer. */
5827 action_encap_data = ctx->object;
5828 *action_encap_data = (struct action_raw_encap_data) {
5829 .conf = (struct rte_flow_action_raw_encap){
5830 .data = action_encap_data->data,
5835 header = action_encap_data->data;
5836 if (mplsoudp_encap_conf.select_vlan)
5837 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5838 else if (mplsoudp_encap_conf.select_ipv4)
5839 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5841 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5842 memcpy(eth.dst.addr_bytes,
5843 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5844 memcpy(eth.src.addr_bytes,
5845 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5846 memcpy(header, ð, sizeof(eth));
5847 header += sizeof(eth);
5848 if (mplsoudp_encap_conf.select_vlan) {
5849 if (mplsoudp_encap_conf.select_ipv4)
5850 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5852 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5853 memcpy(header, &vlan, sizeof(vlan));
5854 header += sizeof(vlan);
5856 if (mplsoudp_encap_conf.select_ipv4) {
5857 memcpy(header, &ipv4, sizeof(ipv4));
5858 header += sizeof(ipv4);
5860 memcpy(&ipv6.hdr.src_addr,
5861 &mplsoudp_encap_conf.ipv6_src,
5862 sizeof(mplsoudp_encap_conf.ipv6_src));
5863 memcpy(&ipv6.hdr.dst_addr,
5864 &mplsoudp_encap_conf.ipv6_dst,
5865 sizeof(mplsoudp_encap_conf.ipv6_dst));
5866 memcpy(header, &ipv6, sizeof(ipv6));
5867 header += sizeof(ipv6);
5869 memcpy(header, &udp, sizeof(udp));
5870 header += sizeof(udp);
5871 memcpy(mpls.label_tc_s, mplsoudp_encap_conf.label,
5872 RTE_DIM(mplsoudp_encap_conf.label));
5873 mpls.label_tc_s[2] |= 0x1;
5874 memcpy(header, &mpls, sizeof(mpls));
5875 header += sizeof(mpls);
5876 action_encap_data->conf.size = header -
5877 action_encap_data->data;
5878 action->conf = &action_encap_data->conf;
5882 /** Parse MPLSOUDP decap action. */
5884 parse_vc_action_mplsoudp_decap(struct context *ctx, const struct token *token,
5885 const char *str, unsigned int len,
5886 void *buf, unsigned int size)
5888 struct buffer *out = buf;
5889 struct rte_flow_action *action;
5890 struct action_raw_decap_data *action_decap_data;
5891 struct rte_flow_item_eth eth = { .type = 0, };
5892 struct rte_flow_item_vlan vlan = {.tci = 0};
5893 struct rte_flow_item_ipv4 ipv4 = {
5895 .next_proto_id = IPPROTO_UDP,
5898 struct rte_flow_item_ipv6 ipv6 = {
5900 .proto = IPPROTO_UDP,
5903 struct rte_flow_item_udp udp = {
5905 .dst_port = rte_cpu_to_be_16(6635),
5908 struct rte_flow_item_mpls mpls;
5912 ret = parse_vc(ctx, token, str, len, buf, size);
5915 /* Nothing else to do if there is no buffer. */
5918 if (!out->args.vc.actions_n)
5920 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5921 /* Point to selected object. */
5922 ctx->object = out->args.vc.data;
5923 ctx->objmask = NULL;
5924 /* Copy the headers to the buffer. */
5925 action_decap_data = ctx->object;
5926 *action_decap_data = (struct action_raw_decap_data) {
5927 .conf = (struct rte_flow_action_raw_decap){
5928 .data = action_decap_data->data,
5932 header = action_decap_data->data;
5933 if (mplsoudp_decap_conf.select_vlan)
5934 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5935 else if (mplsoudp_encap_conf.select_ipv4)
5936 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5938 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5939 memcpy(eth.dst.addr_bytes,
5940 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5941 memcpy(eth.src.addr_bytes,
5942 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5943 memcpy(header, ð, sizeof(eth));
5944 header += sizeof(eth);
5945 if (mplsoudp_encap_conf.select_vlan) {
5946 if (mplsoudp_encap_conf.select_ipv4)
5947 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5949 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5950 memcpy(header, &vlan, sizeof(vlan));
5951 header += sizeof(vlan);
5953 if (mplsoudp_encap_conf.select_ipv4) {
5954 memcpy(header, &ipv4, sizeof(ipv4));
5955 header += sizeof(ipv4);
5957 memcpy(header, &ipv6, sizeof(ipv6));
5958 header += sizeof(ipv6);
5960 memcpy(header, &udp, sizeof(udp));
5961 header += sizeof(udp);
5962 memset(&mpls, 0, sizeof(mpls));
5963 memcpy(header, &mpls, sizeof(mpls));
5964 header += sizeof(mpls);
5965 action_decap_data->conf.size = header -
5966 action_decap_data->data;
5967 action->conf = &action_decap_data->conf;
5972 parse_vc_action_raw_decap_index(struct context *ctx, const struct token *token,
5973 const char *str, unsigned int len, void *buf,
5976 struct action_raw_decap_data *action_raw_decap_data;
5977 struct rte_flow_action *action;
5978 const struct arg *arg;
5979 struct buffer *out = buf;
5983 RTE_SET_USED(token);
5986 arg = ARGS_ENTRY_ARB_BOUNDED
5987 (offsetof(struct action_raw_decap_data, idx),
5988 sizeof(((struct action_raw_decap_data *)0)->idx),
5989 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
5990 if (push_args(ctx, arg))
5992 ret = parse_int(ctx, token, str, len, NULL, 0);
5999 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6000 action_raw_decap_data = ctx->object;
6001 idx = action_raw_decap_data->idx;
6002 action_raw_decap_data->conf.data = raw_decap_confs[idx].data;
6003 action_raw_decap_data->conf.size = raw_decap_confs[idx].size;
6004 action->conf = &action_raw_decap_data->conf;
6010 parse_vc_action_raw_encap_index(struct context *ctx, const struct token *token,
6011 const char *str, unsigned int len, void *buf,
6014 struct action_raw_encap_data *action_raw_encap_data;
6015 struct rte_flow_action *action;
6016 const struct arg *arg;
6017 struct buffer *out = buf;
6021 RTE_SET_USED(token);
6024 if (ctx->curr != ACTION_RAW_ENCAP_INDEX_VALUE)
6026 arg = ARGS_ENTRY_ARB_BOUNDED
6027 (offsetof(struct action_raw_encap_data, idx),
6028 sizeof(((struct action_raw_encap_data *)0)->idx),
6029 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
6030 if (push_args(ctx, arg))
6032 ret = parse_int(ctx, token, str, len, NULL, 0);
6039 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6040 action_raw_encap_data = ctx->object;
6041 idx = action_raw_encap_data->idx;
6042 action_raw_encap_data->conf.data = raw_encap_confs[idx].data;
6043 action_raw_encap_data->conf.size = raw_encap_confs[idx].size;
6044 action_raw_encap_data->conf.preserve = NULL;
6045 action->conf = &action_raw_encap_data->conf;
6050 parse_vc_action_raw_encap(struct context *ctx, const struct token *token,
6051 const char *str, unsigned int len, void *buf,
6054 struct buffer *out = buf;
6055 struct rte_flow_action *action;
6056 struct action_raw_encap_data *action_raw_encap_data = NULL;
6059 ret = parse_vc(ctx, token, str, len, buf, size);
6062 /* Nothing else to do if there is no buffer. */
6065 if (!out->args.vc.actions_n)
6067 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6068 /* Point to selected object. */
6069 ctx->object = out->args.vc.data;
6070 ctx->objmask = NULL;
6071 /* Copy the headers to the buffer. */
6072 action_raw_encap_data = ctx->object;
6073 action_raw_encap_data->conf.data = raw_encap_confs[0].data;
6074 action_raw_encap_data->conf.preserve = NULL;
6075 action_raw_encap_data->conf.size = raw_encap_confs[0].size;
6076 action->conf = &action_raw_encap_data->conf;
6081 parse_vc_action_raw_decap(struct context *ctx, const struct token *token,
6082 const char *str, unsigned int len, void *buf,
6085 struct buffer *out = buf;
6086 struct rte_flow_action *action;
6087 struct action_raw_decap_data *action_raw_decap_data = NULL;
6090 ret = parse_vc(ctx, token, str, len, buf, size);
6093 /* Nothing else to do if there is no buffer. */
6096 if (!out->args.vc.actions_n)
6098 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6099 /* Point to selected object. */
6100 ctx->object = out->args.vc.data;
6101 ctx->objmask = NULL;
6102 /* Copy the headers to the buffer. */
6103 action_raw_decap_data = ctx->object;
6104 action_raw_decap_data->conf.data = raw_decap_confs[0].data;
6105 action_raw_decap_data->conf.size = raw_decap_confs[0].size;
6106 action->conf = &action_raw_decap_data->conf;
6111 parse_vc_action_set_meta(struct context *ctx, const struct token *token,
6112 const char *str, unsigned int len, void *buf,
6117 ret = parse_vc(ctx, token, str, len, buf, size);
6120 ret = rte_flow_dynf_metadata_register();
6127 parse_vc_action_sample(struct context *ctx, const struct token *token,
6128 const char *str, unsigned int len, void *buf,
6131 struct buffer *out = buf;
6132 struct rte_flow_action *action;
6133 struct action_sample_data *action_sample_data = NULL;
6134 static struct rte_flow_action end_action = {
6135 RTE_FLOW_ACTION_TYPE_END, 0
6139 ret = parse_vc(ctx, token, str, len, buf, size);
6142 /* Nothing else to do if there is no buffer. */
6145 if (!out->args.vc.actions_n)
6147 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6148 /* Point to selected object. */
6149 ctx->object = out->args.vc.data;
6150 ctx->objmask = NULL;
6151 /* Copy the headers to the buffer. */
6152 action_sample_data = ctx->object;
6153 action_sample_data->conf.actions = &end_action;
6154 action->conf = &action_sample_data->conf;
6159 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
6160 const char *str, unsigned int len, void *buf,
6163 struct action_sample_data *action_sample_data;
6164 struct rte_flow_action *action;
6165 const struct arg *arg;
6166 struct buffer *out = buf;
6170 RTE_SET_USED(token);
6173 if (ctx->curr != ACTION_SAMPLE_INDEX_VALUE)
6175 arg = ARGS_ENTRY_ARB_BOUNDED
6176 (offsetof(struct action_sample_data, idx),
6177 sizeof(((struct action_sample_data *)0)->idx),
6178 0, RAW_SAMPLE_CONFS_MAX_NUM - 1);
6179 if (push_args(ctx, arg))
6181 ret = parse_int(ctx, token, str, len, NULL, 0);
6188 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6189 action_sample_data = ctx->object;
6190 idx = action_sample_data->idx;
6191 action_sample_data->conf.actions = raw_sample_confs[idx].data;
6192 action->conf = &action_sample_data->conf;
6196 /** Parse operation for modify_field command. */
6198 parse_vc_modify_field_op(struct context *ctx, const struct token *token,
6199 const char *str, unsigned int len, void *buf,
6202 struct rte_flow_action_modify_field *action_modify_field;
6208 if (ctx->curr != ACTION_MODIFY_FIELD_OP_VALUE)
6210 for (i = 0; modify_field_ops[i]; ++i)
6211 if (!strcmp_partial(modify_field_ops[i], str, len))
6213 if (!modify_field_ops[i])
6217 action_modify_field = ctx->object;
6218 action_modify_field->operation = (enum rte_flow_modify_op)i;
6222 /** Parse id for modify_field command. */
6224 parse_vc_modify_field_id(struct context *ctx, const struct token *token,
6225 const char *str, unsigned int len, void *buf,
6228 struct rte_flow_action_modify_field *action_modify_field;
6234 if (ctx->curr != ACTION_MODIFY_FIELD_DST_TYPE_VALUE &&
6235 ctx->curr != ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)
6237 for (i = 0; modify_field_ids[i]; ++i)
6238 if (!strcmp_partial(modify_field_ids[i], str, len))
6240 if (!modify_field_ids[i])
6244 action_modify_field = ctx->object;
6245 if (ctx->curr == ACTION_MODIFY_FIELD_DST_TYPE_VALUE)
6246 action_modify_field->dst.field = (enum rte_flow_field_id)i;
6248 action_modify_field->src.field = (enum rte_flow_field_id)i;
6252 /** Parse tokens for destroy command. */
6254 parse_destroy(struct context *ctx, const struct token *token,
6255 const char *str, unsigned int len,
6256 void *buf, unsigned int size)
6258 struct buffer *out = buf;
6260 /* Token name must match. */
6261 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6263 /* Nothing else to do if there is no buffer. */
6266 if (!out->command) {
6267 if (ctx->curr != DESTROY)
6269 if (sizeof(*out) > size)
6271 out->command = ctx->curr;
6274 ctx->objmask = NULL;
6275 out->args.destroy.rule =
6276 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6280 if (((uint8_t *)(out->args.destroy.rule + out->args.destroy.rule_n) +
6281 sizeof(*out->args.destroy.rule)) > (uint8_t *)out + size)
6284 ctx->object = out->args.destroy.rule + out->args.destroy.rule_n++;
6285 ctx->objmask = NULL;
6289 /** Parse tokens for flush command. */
6291 parse_flush(struct context *ctx, const struct token *token,
6292 const char *str, unsigned int len,
6293 void *buf, unsigned int size)
6295 struct buffer *out = buf;
6297 /* Token name must match. */
6298 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6300 /* Nothing else to do if there is no buffer. */
6303 if (!out->command) {
6304 if (ctx->curr != FLUSH)
6306 if (sizeof(*out) > size)
6308 out->command = ctx->curr;
6311 ctx->objmask = NULL;
6316 /** Parse tokens for dump command. */
6318 parse_dump(struct context *ctx, const struct token *token,
6319 const char *str, unsigned int len,
6320 void *buf, unsigned int size)
6322 struct buffer *out = buf;
6324 /* Token name must match. */
6325 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6327 /* Nothing else to do if there is no buffer. */
6330 if (!out->command) {
6331 if (ctx->curr != DUMP)
6333 if (sizeof(*out) > size)
6335 out->command = ctx->curr;
6338 ctx->objmask = NULL;
6343 /** Parse tokens for query command. */
6345 parse_query(struct context *ctx, const struct token *token,
6346 const char *str, unsigned int len,
6347 void *buf, unsigned int size)
6349 struct buffer *out = buf;
6351 /* Token name must match. */
6352 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6354 /* Nothing else to do if there is no buffer. */
6357 if (!out->command) {
6358 if (ctx->curr != QUERY)
6360 if (sizeof(*out) > size)
6362 out->command = ctx->curr;
6365 ctx->objmask = NULL;
6370 /** Parse action names. */
6372 parse_action(struct context *ctx, const struct token *token,
6373 const char *str, unsigned int len,
6374 void *buf, unsigned int size)
6376 struct buffer *out = buf;
6377 const struct arg *arg = pop_args(ctx);
6381 /* Argument is expected. */
6384 /* Parse action name. */
6385 for (i = 0; next_action[i]; ++i) {
6386 const struct parse_action_priv *priv;
6388 token = &token_list[next_action[i]];
6389 if (strcmp_partial(token->name, str, len))
6395 memcpy((uint8_t *)ctx->object + arg->offset,
6401 push_args(ctx, arg);
6405 /** Parse tokens for list command. */
6407 parse_list(struct context *ctx, const struct token *token,
6408 const char *str, unsigned int len,
6409 void *buf, unsigned int size)
6411 struct buffer *out = buf;
6413 /* Token name must match. */
6414 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6416 /* Nothing else to do if there is no buffer. */
6419 if (!out->command) {
6420 if (ctx->curr != LIST)
6422 if (sizeof(*out) > size)
6424 out->command = ctx->curr;
6427 ctx->objmask = NULL;
6428 out->args.list.group =
6429 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6433 if (((uint8_t *)(out->args.list.group + out->args.list.group_n) +
6434 sizeof(*out->args.list.group)) > (uint8_t *)out + size)
6437 ctx->object = out->args.list.group + out->args.list.group_n++;
6438 ctx->objmask = NULL;
6442 /** Parse tokens for list all aged flows command. */
6444 parse_aged(struct context *ctx, const struct token *token,
6445 const char *str, unsigned int len,
6446 void *buf, unsigned int size)
6448 struct buffer *out = buf;
6450 /* Token name must match. */
6451 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6453 /* Nothing else to do if there is no buffer. */
6456 if (!out->command) {
6457 if (ctx->curr != AGED)
6459 if (sizeof(*out) > size)
6461 out->command = ctx->curr;
6464 ctx->objmask = NULL;
6466 if (ctx->curr == AGED_DESTROY)
6467 out->args.aged.destroy = 1;
6471 /** Parse tokens for isolate command. */
6473 parse_isolate(struct context *ctx, const struct token *token,
6474 const char *str, unsigned int len,
6475 void *buf, unsigned int size)
6477 struct buffer *out = buf;
6479 /* Token name must match. */
6480 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6482 /* Nothing else to do if there is no buffer. */
6485 if (!out->command) {
6486 if (ctx->curr != ISOLATE)
6488 if (sizeof(*out) > size)
6490 out->command = ctx->curr;
6493 ctx->objmask = NULL;
6499 parse_tunnel(struct context *ctx, const struct token *token,
6500 const char *str, unsigned int len,
6501 void *buf, unsigned int size)
6503 struct buffer *out = buf;
6505 /* Token name must match. */
6506 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6508 /* Nothing else to do if there is no buffer. */
6511 if (!out->command) {
6512 if (ctx->curr != TUNNEL)
6514 if (sizeof(*out) > size)
6516 out->command = ctx->curr;
6519 ctx->objmask = NULL;
6521 switch (ctx->curr) {
6525 case TUNNEL_DESTROY:
6527 out->command = ctx->curr;
6529 case TUNNEL_CREATE_TYPE:
6530 case TUNNEL_DESTROY_ID:
6531 ctx->object = &out->args.vc.tunnel_ops;
6540 * Parse signed/unsigned integers 8 to 64-bit long.
6542 * Last argument (ctx->args) is retrieved to determine integer type and
6546 parse_int(struct context *ctx, const struct token *token,
6547 const char *str, unsigned int len,
6548 void *buf, unsigned int size)
6550 const struct arg *arg = pop_args(ctx);
6555 /* Argument is expected. */
6560 (uintmax_t)strtoimax(str, &end, 0) :
6561 strtoumax(str, &end, 0);
6562 if (errno || (size_t)(end - str) != len)
6565 ((arg->sign && ((intmax_t)u < (intmax_t)arg->min ||
6566 (intmax_t)u > (intmax_t)arg->max)) ||
6567 (!arg->sign && (u < arg->min || u > arg->max))))
6572 if (!arg_entry_bf_fill(ctx->object, u, arg) ||
6573 !arg_entry_bf_fill(ctx->objmask, -1, arg))
6577 buf = (uint8_t *)ctx->object + arg->offset;
6579 if (u > RTE_LEN2MASK(size * CHAR_BIT, uint64_t))
6583 case sizeof(uint8_t):
6584 *(uint8_t *)buf = u;
6586 case sizeof(uint16_t):
6587 *(uint16_t *)buf = arg->hton ? rte_cpu_to_be_16(u) : u;
6589 case sizeof(uint8_t [3]):
6590 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
6592 ((uint8_t *)buf)[0] = u;
6593 ((uint8_t *)buf)[1] = u >> 8;
6594 ((uint8_t *)buf)[2] = u >> 16;
6598 ((uint8_t *)buf)[0] = u >> 16;
6599 ((uint8_t *)buf)[1] = u >> 8;
6600 ((uint8_t *)buf)[2] = u;
6602 case sizeof(uint32_t):
6603 *(uint32_t *)buf = arg->hton ? rte_cpu_to_be_32(u) : u;
6605 case sizeof(uint64_t):
6606 *(uint64_t *)buf = arg->hton ? rte_cpu_to_be_64(u) : u;
6611 if (ctx->objmask && buf != (uint8_t *)ctx->objmask + arg->offset) {
6613 buf = (uint8_t *)ctx->objmask + arg->offset;
6618 push_args(ctx, arg);
6625 * Three arguments (ctx->args) are retrieved from the stack to store data,
6626 * its actual length and address (in that order).
6629 parse_string(struct context *ctx, const struct token *token,
6630 const char *str, unsigned int len,
6631 void *buf, unsigned int size)
6633 const struct arg *arg_data = pop_args(ctx);
6634 const struct arg *arg_len = pop_args(ctx);
6635 const struct arg *arg_addr = pop_args(ctx);
6636 char tmp[16]; /* Ought to be enough. */
6639 /* Arguments are expected. */
6643 push_args(ctx, arg_data);
6647 push_args(ctx, arg_len);
6648 push_args(ctx, arg_data);
6651 size = arg_data->size;
6652 /* Bit-mask fill is not supported. */
6653 if (arg_data->mask || size < len)
6657 /* Let parse_int() fill length information first. */
6658 ret = snprintf(tmp, sizeof(tmp), "%u", len);
6661 push_args(ctx, arg_len);
6662 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
6667 buf = (uint8_t *)ctx->object + arg_data->offset;
6668 /* Output buffer is not necessarily NUL-terminated. */
6669 memcpy(buf, str, len);
6670 memset((uint8_t *)buf + len, 0x00, size - len);
6672 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
6673 /* Save address if requested. */
6674 if (arg_addr->size) {
6675 memcpy((uint8_t *)ctx->object + arg_addr->offset,
6677 (uint8_t *)ctx->object + arg_data->offset
6681 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
6683 (uint8_t *)ctx->objmask + arg_data->offset
6689 push_args(ctx, arg_addr);
6690 push_args(ctx, arg_len);
6691 push_args(ctx, arg_data);
6696 parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
6702 /* Check input parameters */
6703 if ((src == NULL) ||
6709 /* Convert chars to bytes */
6710 for (i = 0, len = 0; i < *size; i += 2) {
6711 snprintf(tmp, 3, "%s", src + i);
6712 dst[len++] = strtoul(tmp, &c, 16);
6727 parse_hex(struct context *ctx, const struct token *token,
6728 const char *str, unsigned int len,
6729 void *buf, unsigned int size)
6731 const struct arg *arg_data = pop_args(ctx);
6732 const struct arg *arg_len = pop_args(ctx);
6733 const struct arg *arg_addr = pop_args(ctx);
6734 char tmp[16]; /* Ought to be enough. */
6736 unsigned int hexlen = len;
6737 unsigned int length = 256;
6738 uint8_t hex_tmp[length];
6740 /* Arguments are expected. */
6744 push_args(ctx, arg_data);
6748 push_args(ctx, arg_len);
6749 push_args(ctx, arg_data);
6752 size = arg_data->size;
6753 /* Bit-mask fill is not supported. */
6759 /* translate bytes string to array. */
6760 if (str[0] == '0' && ((str[1] == 'x') ||
6765 if (hexlen > length)
6767 ret = parse_hex_string(str, hex_tmp, &hexlen);
6770 /* Let parse_int() fill length information first. */
6771 ret = snprintf(tmp, sizeof(tmp), "%u", hexlen);
6774 /* Save length if requested. */
6775 if (arg_len->size) {
6776 push_args(ctx, arg_len);
6777 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
6783 buf = (uint8_t *)ctx->object + arg_data->offset;
6784 /* Output buffer is not necessarily NUL-terminated. */
6785 memcpy(buf, hex_tmp, hexlen);
6786 memset((uint8_t *)buf + hexlen, 0x00, size - hexlen);
6788 memset((uint8_t *)ctx->objmask + arg_data->offset,
6790 /* Save address if requested. */
6791 if (arg_addr->size) {
6792 memcpy((uint8_t *)ctx->object + arg_addr->offset,
6794 (uint8_t *)ctx->object + arg_data->offset
6798 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
6800 (uint8_t *)ctx->objmask + arg_data->offset
6806 push_args(ctx, arg_addr);
6807 push_args(ctx, arg_len);
6808 push_args(ctx, arg_data);
6814 * Parse a zero-ended string.
6817 parse_string0(struct context *ctx, const struct token *token __rte_unused,
6818 const char *str, unsigned int len,
6819 void *buf, unsigned int size)
6821 const struct arg *arg_data = pop_args(ctx);
6823 /* Arguments are expected. */
6826 size = arg_data->size;
6827 /* Bit-mask fill is not supported. */
6828 if (arg_data->mask || size < len + 1)
6832 buf = (uint8_t *)ctx->object + arg_data->offset;
6833 strncpy(buf, str, len);
6835 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
6838 push_args(ctx, arg_data);
6843 * Parse a MAC address.
6845 * Last argument (ctx->args) is retrieved to determine storage size and
6849 parse_mac_addr(struct context *ctx, const struct token *token,
6850 const char *str, unsigned int len,
6851 void *buf, unsigned int size)
6853 const struct arg *arg = pop_args(ctx);
6854 struct rte_ether_addr tmp;
6858 /* Argument is expected. */
6862 /* Bit-mask fill is not supported. */
6863 if (arg->mask || size != sizeof(tmp))
6865 /* Only network endian is supported. */
6868 ret = cmdline_parse_etheraddr(NULL, str, &tmp, size);
6869 if (ret < 0 || (unsigned int)ret != len)
6873 buf = (uint8_t *)ctx->object + arg->offset;
6874 memcpy(buf, &tmp, size);
6876 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6879 push_args(ctx, arg);
6884 * Parse an IPv4 address.
6886 * Last argument (ctx->args) is retrieved to determine storage size and
6890 parse_ipv4_addr(struct context *ctx, const struct token *token,
6891 const char *str, unsigned int len,
6892 void *buf, unsigned int size)
6894 const struct arg *arg = pop_args(ctx);
6899 /* Argument is expected. */
6903 /* Bit-mask fill is not supported. */
6904 if (arg->mask || size != sizeof(tmp))
6906 /* Only network endian is supported. */
6909 memcpy(str2, str, len);
6911 ret = inet_pton(AF_INET, str2, &tmp);
6913 /* Attempt integer parsing. */
6914 push_args(ctx, arg);
6915 return parse_int(ctx, token, str, len, buf, size);
6919 buf = (uint8_t *)ctx->object + arg->offset;
6920 memcpy(buf, &tmp, size);
6922 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6925 push_args(ctx, arg);
6930 * Parse an IPv6 address.
6932 * Last argument (ctx->args) is retrieved to determine storage size and
6936 parse_ipv6_addr(struct context *ctx, const struct token *token,
6937 const char *str, unsigned int len,
6938 void *buf, unsigned int size)
6940 const struct arg *arg = pop_args(ctx);
6942 struct in6_addr tmp;
6946 /* Argument is expected. */
6950 /* Bit-mask fill is not supported. */
6951 if (arg->mask || size != sizeof(tmp))
6953 /* Only network endian is supported. */
6956 memcpy(str2, str, len);
6958 ret = inet_pton(AF_INET6, str2, &tmp);
6963 buf = (uint8_t *)ctx->object + arg->offset;
6964 memcpy(buf, &tmp, size);
6966 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6969 push_args(ctx, arg);
6973 /** Boolean values (even indices stand for false). */
6974 static const char *const boolean_name[] = {
6984 * Parse a boolean value.
6986 * Last argument (ctx->args) is retrieved to determine storage size and
6990 parse_boolean(struct context *ctx, const struct token *token,
6991 const char *str, unsigned int len,
6992 void *buf, unsigned int size)
6994 const struct arg *arg = pop_args(ctx);
6998 /* Argument is expected. */
7001 for (i = 0; boolean_name[i]; ++i)
7002 if (!strcmp_partial(boolean_name[i], str, len))
7004 /* Process token as integer. */
7005 if (boolean_name[i])
7006 str = i & 1 ? "1" : "0";
7007 push_args(ctx, arg);
7008 ret = parse_int(ctx, token, str, strlen(str), buf, size);
7009 return ret > 0 ? (int)len : ret;
7012 /** Parse port and update context. */
7014 parse_port(struct context *ctx, const struct token *token,
7015 const char *str, unsigned int len,
7016 void *buf, unsigned int size)
7018 struct buffer *out = &(struct buffer){ .port = 0 };
7026 ctx->objmask = NULL;
7027 size = sizeof(*out);
7029 ret = parse_int(ctx, token, str, len, out, size);
7031 ctx->port = out->port;
7038 parse_sa_id2ptr(struct context *ctx, const struct token *token,
7039 const char *str, unsigned int len,
7040 void *buf, unsigned int size)
7042 struct rte_flow_action *action = ctx->object;
7050 ctx->objmask = NULL;
7051 ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
7052 ctx->object = action;
7053 if (ret != (int)len)
7055 /* set shared action */
7057 action->conf = port_shared_action_get_by_id(ctx->port, id);
7058 ret = (action->conf) ? ret : -1;
7063 /** Parse set command, initialize output buffer for subsequent tokens. */
7065 parse_set_raw_encap_decap(struct context *ctx, const struct token *token,
7066 const char *str, unsigned int len,
7067 void *buf, unsigned int size)
7069 struct buffer *out = buf;
7071 /* Token name must match. */
7072 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7074 /* Nothing else to do if there is no buffer. */
7077 /* Make sure buffer is large enough. */
7078 if (size < sizeof(*out))
7081 ctx->objmask = NULL;
7085 out->command = ctx->curr;
7086 /* For encap/decap we need is pattern */
7087 out->args.vc.pattern = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7092 /** Parse set command, initialize output buffer for subsequent tokens. */
7094 parse_set_sample_action(struct context *ctx, const struct token *token,
7095 const char *str, unsigned int len,
7096 void *buf, unsigned int size)
7098 struct buffer *out = buf;
7100 /* Token name must match. */
7101 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7103 /* Nothing else to do if there is no buffer. */
7106 /* Make sure buffer is large enough. */
7107 if (size < sizeof(*out))
7110 ctx->objmask = NULL;
7114 out->command = ctx->curr;
7115 /* For sampler we need is actions */
7116 out->args.vc.actions = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7122 * Parse set raw_encap/raw_decap command,
7123 * initialize output buffer for subsequent tokens.
7126 parse_set_init(struct context *ctx, const struct token *token,
7127 const char *str, unsigned int len,
7128 void *buf, unsigned int size)
7130 struct buffer *out = buf;
7132 /* Token name must match. */
7133 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7135 /* Nothing else to do if there is no buffer. */
7138 /* Make sure buffer is large enough. */
7139 if (size < sizeof(*out))
7141 /* Initialize buffer. */
7142 memset(out, 0x00, sizeof(*out));
7143 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
7146 ctx->objmask = NULL;
7147 if (!out->command) {
7148 if (ctx->curr != SET)
7150 if (sizeof(*out) > size)
7152 out->command = ctx->curr;
7153 out->args.vc.data = (uint8_t *)out + size;
7154 ctx->object = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7160 /** No completion. */
7162 comp_none(struct context *ctx, const struct token *token,
7163 unsigned int ent, char *buf, unsigned int size)
7173 /** Complete boolean values. */
7175 comp_boolean(struct context *ctx, const struct token *token,
7176 unsigned int ent, char *buf, unsigned int size)
7182 for (i = 0; boolean_name[i]; ++i)
7183 if (buf && i == ent)
7184 return strlcpy(buf, boolean_name[i], size);
7190 /** Complete action names. */
7192 comp_action(struct context *ctx, const struct token *token,
7193 unsigned int ent, char *buf, unsigned int size)
7199 for (i = 0; next_action[i]; ++i)
7200 if (buf && i == ent)
7201 return strlcpy(buf, token_list[next_action[i]].name,
7208 /** Complete available ports. */
7210 comp_port(struct context *ctx, const struct token *token,
7211 unsigned int ent, char *buf, unsigned int size)
7218 RTE_ETH_FOREACH_DEV(p) {
7219 if (buf && i == ent)
7220 return snprintf(buf, size, "%u", p);
7228 /** Complete available rule IDs. */
7230 comp_rule_id(struct context *ctx, const struct token *token,
7231 unsigned int ent, char *buf, unsigned int size)
7234 struct rte_port *port;
7235 struct port_flow *pf;
7238 if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
7239 ctx->port == (portid_t)RTE_PORT_ALL)
7241 port = &ports[ctx->port];
7242 for (pf = port->flow_list; pf != NULL; pf = pf->next) {
7243 if (buf && i == ent)
7244 return snprintf(buf, size, "%u", pf->id);
7252 /** Complete type field for RSS action. */
7254 comp_vc_action_rss_type(struct context *ctx, const struct token *token,
7255 unsigned int ent, char *buf, unsigned int size)
7261 for (i = 0; rss_type_table[i].str; ++i)
7266 return strlcpy(buf, rss_type_table[ent].str, size);
7268 return snprintf(buf, size, "end");
7272 /** Complete queue field for RSS action. */
7274 comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
7275 unsigned int ent, char *buf, unsigned int size)
7282 return snprintf(buf, size, "%u", ent);
7284 return snprintf(buf, size, "end");
7288 /** Complete index number for set raw_encap/raw_decap commands. */
7290 comp_set_raw_index(struct context *ctx, const struct token *token,
7291 unsigned int ent, char *buf, unsigned int size)
7297 RTE_SET_USED(token);
7298 for (idx = 0; idx < RAW_ENCAP_CONFS_MAX_NUM; ++idx) {
7299 if (buf && idx == ent)
7300 return snprintf(buf, size, "%u", idx);
7306 /** Complete index number for set raw_encap/raw_decap commands. */
7308 comp_set_sample_index(struct context *ctx, const struct token *token,
7309 unsigned int ent, char *buf, unsigned int size)
7315 RTE_SET_USED(token);
7316 for (idx = 0; idx < RAW_SAMPLE_CONFS_MAX_NUM; ++idx) {
7317 if (buf && idx == ent)
7318 return snprintf(buf, size, "%u", idx);
7324 /** Complete operation for modify_field command. */
7326 comp_set_modify_field_op(struct context *ctx, const struct token *token,
7327 unsigned int ent, char *buf, unsigned int size)
7332 RTE_SET_USED(token);
7333 for (idx = 0; modify_field_ops[idx]; ++idx)
7338 return strlcpy(buf, modify_field_ops[ent], size);
7342 /** Complete field id for modify_field command. */
7344 comp_set_modify_field_id(struct context *ctx, const struct token *token,
7345 unsigned int ent, char *buf, unsigned int size)
7350 RTE_SET_USED(token);
7351 for (idx = 0; modify_field_ids[idx]; ++idx)
7356 return strlcpy(buf, modify_field_ids[ent], size);
7360 /** Internal context. */
7361 static struct context cmd_flow_context;
7363 /** Global parser instance (cmdline API). */
7364 cmdline_parse_inst_t cmd_flow;
7365 cmdline_parse_inst_t cmd_set_raw;
7367 /** Initialize context. */
7369 cmd_flow_context_init(struct context *ctx)
7371 /* A full memset() is not necessary. */
7381 ctx->objmask = NULL;
7384 /** Parse a token (cmdline API). */
7386 cmd_flow_parse(cmdline_parse_token_hdr_t *hdr, const char *src, void *result,
7389 struct context *ctx = &cmd_flow_context;
7390 const struct token *token;
7391 const enum index *list;
7396 token = &token_list[ctx->curr];
7397 /* Check argument length. */
7400 for (len = 0; src[len]; ++len)
7401 if (src[len] == '#' || isspace(src[len]))
7405 /* Last argument and EOL detection. */
7406 for (i = len; src[i]; ++i)
7407 if (src[i] == '#' || src[i] == '\r' || src[i] == '\n')
7409 else if (!isspace(src[i])) {
7414 if (src[i] == '\r' || src[i] == '\n') {
7418 /* Initialize context if necessary. */
7419 if (!ctx->next_num) {
7422 ctx->next[ctx->next_num++] = token->next[0];
7424 /* Process argument through candidates. */
7425 ctx->prev = ctx->curr;
7426 list = ctx->next[ctx->next_num - 1];
7427 for (i = 0; list[i]; ++i) {
7428 const struct token *next = &token_list[list[i]];
7431 ctx->curr = list[i];
7433 tmp = next->call(ctx, next, src, len, result, size);
7435 tmp = parse_default(ctx, next, src, len, result, size);
7436 if (tmp == -1 || tmp != len)
7444 /* Push subsequent tokens if any. */
7446 for (i = 0; token->next[i]; ++i) {
7447 if (ctx->next_num == RTE_DIM(ctx->next))
7449 ctx->next[ctx->next_num++] = token->next[i];
7451 /* Push arguments if any. */
7453 for (i = 0; token->args[i]; ++i) {
7454 if (ctx->args_num == RTE_DIM(ctx->args))
7456 ctx->args[ctx->args_num++] = token->args[i];
7461 /** Return number of completion entries (cmdline API). */
7463 cmd_flow_complete_get_nb(cmdline_parse_token_hdr_t *hdr)
7465 struct context *ctx = &cmd_flow_context;
7466 const struct token *token = &token_list[ctx->curr];
7467 const enum index *list;
7471 /* Count number of tokens in current list. */
7473 list = ctx->next[ctx->next_num - 1];
7475 list = token->next[0];
7476 for (i = 0; list[i]; ++i)
7481 * If there is a single token, use its completion callback, otherwise
7482 * return the number of entries.
7484 token = &token_list[list[0]];
7485 if (i == 1 && token->comp) {
7486 /* Save index for cmd_flow_get_help(). */
7487 ctx->prev = list[0];
7488 return token->comp(ctx, token, 0, NULL, 0);
7493 /** Return a completion entry (cmdline API). */
7495 cmd_flow_complete_get_elt(cmdline_parse_token_hdr_t *hdr, int index,
7496 char *dst, unsigned int size)
7498 struct context *ctx = &cmd_flow_context;
7499 const struct token *token = &token_list[ctx->curr];
7500 const enum index *list;
7504 /* Count number of tokens in current list. */
7506 list = ctx->next[ctx->next_num - 1];
7508 list = token->next[0];
7509 for (i = 0; list[i]; ++i)
7513 /* If there is a single token, use its completion callback. */
7514 token = &token_list[list[0]];
7515 if (i == 1 && token->comp) {
7516 /* Save index for cmd_flow_get_help(). */
7517 ctx->prev = list[0];
7518 return token->comp(ctx, token, index, dst, size) < 0 ? -1 : 0;
7520 /* Otherwise make sure the index is valid and use defaults. */
7523 token = &token_list[list[index]];
7524 strlcpy(dst, token->name, size);
7525 /* Save index for cmd_flow_get_help(). */
7526 ctx->prev = list[index];
7530 /** Populate help strings for current token (cmdline API). */
7532 cmd_flow_get_help(cmdline_parse_token_hdr_t *hdr, char *dst, unsigned int size)
7534 struct context *ctx = &cmd_flow_context;
7535 const struct token *token = &token_list[ctx->prev];
7540 /* Set token type and update global help with details. */
7541 strlcpy(dst, (token->type ? token->type : "TOKEN"), size);
7543 cmd_flow.help_str = token->help;
7545 cmd_flow.help_str = token->name;
7549 /** Token definition template (cmdline API). */
7550 static struct cmdline_token_hdr cmd_flow_token_hdr = {
7551 .ops = &(struct cmdline_token_ops){
7552 .parse = cmd_flow_parse,
7553 .complete_get_nb = cmd_flow_complete_get_nb,
7554 .complete_get_elt = cmd_flow_complete_get_elt,
7555 .get_help = cmd_flow_get_help,
7560 /** Populate the next dynamic token. */
7562 cmd_flow_tok(cmdline_parse_token_hdr_t **hdr,
7563 cmdline_parse_token_hdr_t **hdr_inst)
7565 struct context *ctx = &cmd_flow_context;
7567 /* Always reinitialize context before requesting the first token. */
7568 if (!(hdr_inst - cmd_flow.tokens))
7569 cmd_flow_context_init(ctx);
7570 /* Return NULL when no more tokens are expected. */
7571 if (!ctx->next_num && ctx->curr) {
7575 /* Determine if command should end here. */
7576 if (ctx->eol && ctx->last && ctx->next_num) {
7577 const enum index *list = ctx->next[ctx->next_num - 1];
7580 for (i = 0; list[i]; ++i) {
7587 *hdr = &cmd_flow_token_hdr;
7590 /** Dispatch parsed buffer to function calls. */
7592 cmd_flow_parsed(const struct buffer *in)
7594 switch (in->command) {
7595 case SHARED_ACTION_CREATE:
7596 port_shared_action_create(
7597 in->port, in->args.vc.attr.group,
7598 &((const struct rte_flow_shared_action_conf) {
7599 .ingress = in->args.vc.attr.ingress,
7600 .egress = in->args.vc.attr.egress,
7601 .transfer = in->args.vc.attr.transfer,
7603 in->args.vc.actions);
7605 case SHARED_ACTION_DESTROY:
7606 port_shared_action_destroy(in->port,
7607 in->args.sa_destroy.action_id_n,
7608 in->args.sa_destroy.action_id);
7610 case SHARED_ACTION_UPDATE:
7611 port_shared_action_update(in->port, in->args.vc.attr.group,
7612 in->args.vc.actions);
7614 case SHARED_ACTION_QUERY:
7615 port_shared_action_query(in->port, in->args.sa.action_id);
7618 port_flow_validate(in->port, &in->args.vc.attr,
7619 in->args.vc.pattern, in->args.vc.actions,
7620 &in->args.vc.tunnel_ops);
7623 port_flow_create(in->port, &in->args.vc.attr,
7624 in->args.vc.pattern, in->args.vc.actions,
7625 &in->args.vc.tunnel_ops);
7628 port_flow_destroy(in->port, in->args.destroy.rule_n,
7629 in->args.destroy.rule);
7632 port_flow_flush(in->port);
7635 port_flow_dump(in->port, in->args.dump.file);
7638 port_flow_query(in->port, in->args.query.rule,
7639 &in->args.query.action);
7642 port_flow_list(in->port, in->args.list.group_n,
7643 in->args.list.group);
7646 port_flow_isolate(in->port, in->args.isolate.set);
7649 port_flow_aged(in->port, in->args.aged.destroy);
7652 port_flow_tunnel_create(in->port, &in->args.vc.tunnel_ops);
7654 case TUNNEL_DESTROY:
7655 port_flow_tunnel_destroy(in->port, in->args.vc.tunnel_ops.id);
7658 port_flow_tunnel_list(in->port);
7665 /** Token generator and output processing callback (cmdline API). */
7667 cmd_flow_cb(void *arg0, struct cmdline *cl, void *arg2)
7670 cmd_flow_tok(arg0, arg2);
7672 cmd_flow_parsed(arg0);
7675 /** Global parser instance (cmdline API). */
7676 cmdline_parse_inst_t cmd_flow = {
7678 .data = NULL, /**< Unused. */
7679 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
7682 }, /**< Tokens are returned by cmd_flow_tok(). */
7685 /** set cmd facility. Reuse cmd flow's infrastructure as much as possible. */
7688 update_fields(uint8_t *buf, struct rte_flow_item *item, uint16_t next_proto)
7690 struct rte_ipv4_hdr *ipv4;
7691 struct rte_ether_hdr *eth;
7692 struct rte_ipv6_hdr *ipv6;
7693 struct rte_vxlan_hdr *vxlan;
7694 struct rte_vxlan_gpe_hdr *gpe;
7695 struct rte_flow_item_nvgre *nvgre;
7696 uint32_t ipv6_vtc_flow;
7698 switch (item->type) {
7699 case RTE_FLOW_ITEM_TYPE_ETH:
7700 eth = (struct rte_ether_hdr *)buf;
7702 eth->ether_type = rte_cpu_to_be_16(next_proto);
7704 case RTE_FLOW_ITEM_TYPE_IPV4:
7705 ipv4 = (struct rte_ipv4_hdr *)buf;
7706 ipv4->version_ihl = 0x45;
7707 if (next_proto && ipv4->next_proto_id == 0)
7708 ipv4->next_proto_id = (uint8_t)next_proto;
7710 case RTE_FLOW_ITEM_TYPE_IPV6:
7711 ipv6 = (struct rte_ipv6_hdr *)buf;
7712 if (next_proto && ipv6->proto == 0)
7713 ipv6->proto = (uint8_t)next_proto;
7714 ipv6_vtc_flow = rte_be_to_cpu_32(ipv6->vtc_flow);
7715 ipv6_vtc_flow &= 0x0FFFFFFF; /*< reset version bits. */
7716 ipv6_vtc_flow |= 0x60000000; /*< set ipv6 version. */
7717 ipv6->vtc_flow = rte_cpu_to_be_32(ipv6_vtc_flow);
7719 case RTE_FLOW_ITEM_TYPE_VXLAN:
7720 vxlan = (struct rte_vxlan_hdr *)buf;
7721 vxlan->vx_flags = 0x08;
7723 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
7724 gpe = (struct rte_vxlan_gpe_hdr *)buf;
7725 gpe->vx_flags = 0x0C;
7727 case RTE_FLOW_ITEM_TYPE_NVGRE:
7728 nvgre = (struct rte_flow_item_nvgre *)buf;
7729 nvgre->protocol = rte_cpu_to_be_16(0x6558);
7730 nvgre->c_k_s_rsvd0_ver = rte_cpu_to_be_16(0x2000);
7737 /** Helper of get item's default mask. */
7739 flow_item_default_mask(const struct rte_flow_item *item)
7741 const void *mask = NULL;
7742 static rte_be32_t gre_key_default_mask = RTE_BE32(UINT32_MAX);
7744 switch (item->type) {
7745 case RTE_FLOW_ITEM_TYPE_ANY:
7746 mask = &rte_flow_item_any_mask;
7748 case RTE_FLOW_ITEM_TYPE_VF:
7749 mask = &rte_flow_item_vf_mask;
7751 case RTE_FLOW_ITEM_TYPE_PORT_ID:
7752 mask = &rte_flow_item_port_id_mask;
7754 case RTE_FLOW_ITEM_TYPE_RAW:
7755 mask = &rte_flow_item_raw_mask;
7757 case RTE_FLOW_ITEM_TYPE_ETH:
7758 mask = &rte_flow_item_eth_mask;
7760 case RTE_FLOW_ITEM_TYPE_VLAN:
7761 mask = &rte_flow_item_vlan_mask;
7763 case RTE_FLOW_ITEM_TYPE_IPV4:
7764 mask = &rte_flow_item_ipv4_mask;
7766 case RTE_FLOW_ITEM_TYPE_IPV6:
7767 mask = &rte_flow_item_ipv6_mask;
7769 case RTE_FLOW_ITEM_TYPE_ICMP:
7770 mask = &rte_flow_item_icmp_mask;
7772 case RTE_FLOW_ITEM_TYPE_UDP:
7773 mask = &rte_flow_item_udp_mask;
7775 case RTE_FLOW_ITEM_TYPE_TCP:
7776 mask = &rte_flow_item_tcp_mask;
7778 case RTE_FLOW_ITEM_TYPE_SCTP:
7779 mask = &rte_flow_item_sctp_mask;
7781 case RTE_FLOW_ITEM_TYPE_VXLAN:
7782 mask = &rte_flow_item_vxlan_mask;
7784 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
7785 mask = &rte_flow_item_vxlan_gpe_mask;
7787 case RTE_FLOW_ITEM_TYPE_E_TAG:
7788 mask = &rte_flow_item_e_tag_mask;
7790 case RTE_FLOW_ITEM_TYPE_NVGRE:
7791 mask = &rte_flow_item_nvgre_mask;
7793 case RTE_FLOW_ITEM_TYPE_MPLS:
7794 mask = &rte_flow_item_mpls_mask;
7796 case RTE_FLOW_ITEM_TYPE_GRE:
7797 mask = &rte_flow_item_gre_mask;
7799 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
7800 mask = &gre_key_default_mask;
7802 case RTE_FLOW_ITEM_TYPE_META:
7803 mask = &rte_flow_item_meta_mask;
7805 case RTE_FLOW_ITEM_TYPE_FUZZY:
7806 mask = &rte_flow_item_fuzzy_mask;
7808 case RTE_FLOW_ITEM_TYPE_GTP:
7809 mask = &rte_flow_item_gtp_mask;
7811 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
7812 mask = &rte_flow_item_gtp_psc_mask;
7814 case RTE_FLOW_ITEM_TYPE_GENEVE:
7815 mask = &rte_flow_item_geneve_mask;
7817 case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
7818 mask = &rte_flow_item_geneve_opt_mask;
7820 case RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID:
7821 mask = &rte_flow_item_pppoe_proto_id_mask;
7823 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
7824 mask = &rte_flow_item_l2tpv3oip_mask;
7826 case RTE_FLOW_ITEM_TYPE_ESP:
7827 mask = &rte_flow_item_esp_mask;
7829 case RTE_FLOW_ITEM_TYPE_AH:
7830 mask = &rte_flow_item_ah_mask;
7832 case RTE_FLOW_ITEM_TYPE_PFCP:
7833 mask = &rte_flow_item_pfcp_mask;
7841 /** Dispatch parsed buffer to function calls. */
7843 cmd_set_raw_parsed_sample(const struct buffer *in)
7845 uint32_t n = in->args.vc.actions_n;
7847 struct rte_flow_action *action = NULL;
7848 struct rte_flow_action *data = NULL;
7850 uint16_t idx = in->port; /* We borrow port field as index */
7851 uint32_t max_size = sizeof(struct rte_flow_action) *
7852 ACTION_SAMPLE_ACTIONS_NUM;
7854 RTE_ASSERT(in->command == SET_SAMPLE_ACTIONS);
7855 data = (struct rte_flow_action *)&raw_sample_confs[idx].data;
7856 memset(data, 0x00, max_size);
7857 for (; i <= n - 1; i++) {
7858 action = in->args.vc.actions + i;
7859 if (action->type == RTE_FLOW_ACTION_TYPE_END)
7861 switch (action->type) {
7862 case RTE_FLOW_ACTION_TYPE_MARK:
7863 size = sizeof(struct rte_flow_action_mark);
7864 rte_memcpy(&sample_mark[idx],
7865 (const void *)action->conf, size);
7866 action->conf = &sample_mark[idx];
7868 case RTE_FLOW_ACTION_TYPE_COUNT:
7869 size = sizeof(struct rte_flow_action_count);
7870 rte_memcpy(&sample_count[idx],
7871 (const void *)action->conf, size);
7872 action->conf = &sample_count[idx];
7874 case RTE_FLOW_ACTION_TYPE_QUEUE:
7875 size = sizeof(struct rte_flow_action_queue);
7876 rte_memcpy(&sample_queue[idx],
7877 (const void *)action->conf, size);
7878 action->conf = &sample_queue[idx];
7880 case RTE_FLOW_ACTION_TYPE_RAW_ENCAP:
7881 size = sizeof(struct rte_flow_action_raw_encap);
7882 rte_memcpy(&sample_encap[idx],
7883 (const void *)action->conf, size);
7884 action->conf = &sample_encap[idx];
7886 case RTE_FLOW_ACTION_TYPE_PORT_ID:
7887 size = sizeof(struct rte_flow_action_port_id);
7888 rte_memcpy(&sample_port_id[idx],
7889 (const void *)action->conf, size);
7890 action->conf = &sample_port_id[idx];
7893 printf("Error - Not supported action\n");
7896 rte_memcpy(data, action, sizeof(struct rte_flow_action));
7901 /** Dispatch parsed buffer to function calls. */
7903 cmd_set_raw_parsed(const struct buffer *in)
7905 uint32_t n = in->args.vc.pattern_n;
7907 struct rte_flow_item *item = NULL;
7909 uint8_t *data = NULL;
7910 uint8_t *data_tail = NULL;
7911 size_t *total_size = NULL;
7912 uint16_t upper_layer = 0;
7914 uint16_t idx = in->port; /* We borrow port field as index */
7915 int gtp_psc = -1; /* GTP PSC option index. */
7917 if (in->command == SET_SAMPLE_ACTIONS)
7918 return cmd_set_raw_parsed_sample(in);
7919 RTE_ASSERT(in->command == SET_RAW_ENCAP ||
7920 in->command == SET_RAW_DECAP);
7921 if (in->command == SET_RAW_ENCAP) {
7922 total_size = &raw_encap_confs[idx].size;
7923 data = (uint8_t *)&raw_encap_confs[idx].data;
7925 total_size = &raw_decap_confs[idx].size;
7926 data = (uint8_t *)&raw_decap_confs[idx].data;
7929 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
7930 /* process hdr from upper layer to low layer (L3/L4 -> L2). */
7931 data_tail = data + ACTION_RAW_ENCAP_MAX_DATA;
7932 for (i = n - 1 ; i >= 0; --i) {
7933 const struct rte_flow_item_gtp *gtp;
7934 const struct rte_flow_item_geneve_opt *opt;
7936 item = in->args.vc.pattern + i;
7937 if (item->spec == NULL)
7938 item->spec = flow_item_default_mask(item);
7939 switch (item->type) {
7940 case RTE_FLOW_ITEM_TYPE_ETH:
7941 size = sizeof(struct rte_ether_hdr);
7943 case RTE_FLOW_ITEM_TYPE_VLAN:
7944 size = sizeof(struct rte_vlan_hdr);
7945 proto = RTE_ETHER_TYPE_VLAN;
7947 case RTE_FLOW_ITEM_TYPE_IPV4:
7948 size = sizeof(struct rte_ipv4_hdr);
7949 proto = RTE_ETHER_TYPE_IPV4;
7951 case RTE_FLOW_ITEM_TYPE_IPV6:
7952 size = sizeof(struct rte_ipv6_hdr);
7953 proto = RTE_ETHER_TYPE_IPV6;
7955 case RTE_FLOW_ITEM_TYPE_UDP:
7956 size = sizeof(struct rte_udp_hdr);
7959 case RTE_FLOW_ITEM_TYPE_TCP:
7960 size = sizeof(struct rte_tcp_hdr);
7963 case RTE_FLOW_ITEM_TYPE_VXLAN:
7964 size = sizeof(struct rte_vxlan_hdr);
7966 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
7967 size = sizeof(struct rte_vxlan_gpe_hdr);
7969 case RTE_FLOW_ITEM_TYPE_GRE:
7970 size = sizeof(struct rte_gre_hdr);
7973 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
7974 size = sizeof(rte_be32_t);
7977 case RTE_FLOW_ITEM_TYPE_MPLS:
7978 size = sizeof(struct rte_mpls_hdr);
7981 case RTE_FLOW_ITEM_TYPE_NVGRE:
7982 size = sizeof(struct rte_flow_item_nvgre);
7985 case RTE_FLOW_ITEM_TYPE_GENEVE:
7986 size = sizeof(struct rte_geneve_hdr);
7988 case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
7989 opt = (const struct rte_flow_item_geneve_opt *)
7991 size = offsetof(struct rte_flow_item_geneve_opt, data);
7992 if (opt->option_len && opt->data) {
7993 *total_size += opt->option_len *
7995 rte_memcpy(data_tail - (*total_size),
7997 opt->option_len * sizeof(uint32_t));
8000 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
8001 size = sizeof(rte_be32_t);
8004 case RTE_FLOW_ITEM_TYPE_ESP:
8005 size = sizeof(struct rte_esp_hdr);
8008 case RTE_FLOW_ITEM_TYPE_AH:
8009 size = sizeof(struct rte_flow_item_ah);
8012 case RTE_FLOW_ITEM_TYPE_GTP:
8014 size = sizeof(struct rte_gtp_hdr);
8017 if (gtp_psc != i + 1) {
8018 printf("Error - GTP PSC does not follow GTP\n");
8022 if ((gtp->v_pt_rsv_flags & 0x07) != 0x04) {
8023 /* Only E flag should be set. */
8024 printf("Error - GTP unsupported flags\n");
8027 struct rte_gtp_hdr_ext_word ext_word = {
8031 /* We have to add GTP header extra word. */
8032 *total_size += sizeof(ext_word);
8033 rte_memcpy(data_tail - (*total_size),
8034 &ext_word, sizeof(ext_word));
8036 size = sizeof(struct rte_gtp_hdr);
8038 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
8040 printf("Error - Multiple GTP PSC items\n");
8043 const struct rte_flow_item_gtp_psc
8052 if (opt->pdu_type & 0x0F) {
8053 /* Support the minimal option only. */
8054 printf("Error - GTP PSC option with "
8055 "extra fields not supported\n");
8058 psc.len = sizeof(psc);
8059 psc.pdu_type = opt->pdu_type;
8062 *total_size += sizeof(psc);
8063 rte_memcpy(data_tail - (*total_size),
8069 case RTE_FLOW_ITEM_TYPE_PFCP:
8070 size = sizeof(struct rte_flow_item_pfcp);
8073 printf("Error - Not supported item\n");
8076 *total_size += size;
8077 rte_memcpy(data_tail - (*total_size), item->spec, size);
8078 /* update some fields which cannot be set by cmdline */
8079 update_fields((data_tail - (*total_size)), item,
8081 upper_layer = proto;
8083 if (verbose_level & 0x1)
8084 printf("total data size is %zu\n", (*total_size));
8085 RTE_ASSERT((*total_size) <= ACTION_RAW_ENCAP_MAX_DATA);
8086 memmove(data, (data_tail - (*total_size)), *total_size);
8091 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
8094 /** Populate help strings for current token (cmdline API). */
8096 cmd_set_raw_get_help(cmdline_parse_token_hdr_t *hdr, char *dst,
8099 struct context *ctx = &cmd_flow_context;
8100 const struct token *token = &token_list[ctx->prev];
8105 /* Set token type and update global help with details. */
8106 snprintf(dst, size, "%s", (token->type ? token->type : "TOKEN"));
8108 cmd_set_raw.help_str = token->help;
8110 cmd_set_raw.help_str = token->name;
8114 /** Token definition template (cmdline API). */
8115 static struct cmdline_token_hdr cmd_set_raw_token_hdr = {
8116 .ops = &(struct cmdline_token_ops){
8117 .parse = cmd_flow_parse,
8118 .complete_get_nb = cmd_flow_complete_get_nb,
8119 .complete_get_elt = cmd_flow_complete_get_elt,
8120 .get_help = cmd_set_raw_get_help,
8125 /** Populate the next dynamic token. */
8127 cmd_set_raw_tok(cmdline_parse_token_hdr_t **hdr,
8128 cmdline_parse_token_hdr_t **hdr_inst)
8130 struct context *ctx = &cmd_flow_context;
8132 /* Always reinitialize context before requesting the first token. */
8133 if (!(hdr_inst - cmd_set_raw.tokens)) {
8134 cmd_flow_context_init(ctx);
8135 ctx->curr = START_SET;
8137 /* Return NULL when no more tokens are expected. */
8138 if (!ctx->next_num && (ctx->curr != START_SET)) {
8142 /* Determine if command should end here. */
8143 if (ctx->eol && ctx->last && ctx->next_num) {
8144 const enum index *list = ctx->next[ctx->next_num - 1];
8147 for (i = 0; list[i]; ++i) {
8154 *hdr = &cmd_set_raw_token_hdr;
8157 /** Token generator and output processing callback (cmdline API). */
8159 cmd_set_raw_cb(void *arg0, struct cmdline *cl, void *arg2)
8162 cmd_set_raw_tok(arg0, arg2);
8164 cmd_set_raw_parsed(arg0);
8167 /** Global parser instance (cmdline API). */
8168 cmdline_parse_inst_t cmd_set_raw = {
8169 .f = cmd_set_raw_cb,
8170 .data = NULL, /**< Unused. */
8171 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
8174 }, /**< Tokens are returned by cmd_flow_tok(). */
8177 /* *** display raw_encap/raw_decap buf */
8178 struct cmd_show_set_raw_result {
8179 cmdline_fixed_string_t cmd_show;
8180 cmdline_fixed_string_t cmd_what;
8181 cmdline_fixed_string_t cmd_all;
8186 cmd_show_set_raw_parsed(void *parsed_result, struct cmdline *cl, void *data)
8188 struct cmd_show_set_raw_result *res = parsed_result;
8189 uint16_t index = res->cmd_index;
8191 uint8_t *raw_data = NULL;
8192 size_t raw_size = 0;
8193 char title[16] = {0};
8197 if (!strcmp(res->cmd_all, "all")) {
8200 } else if (index >= RAW_ENCAP_CONFS_MAX_NUM) {
8201 printf("index should be 0-%u\n", RAW_ENCAP_CONFS_MAX_NUM - 1);
8205 if (!strcmp(res->cmd_what, "raw_encap")) {
8206 raw_data = (uint8_t *)&raw_encap_confs[index].data;
8207 raw_size = raw_encap_confs[index].size;
8208 snprintf(title, 16, "\nindex: %u", index);
8209 rte_hexdump(stdout, title, raw_data, raw_size);
8211 raw_data = (uint8_t *)&raw_decap_confs[index].data;
8212 raw_size = raw_decap_confs[index].size;
8213 snprintf(title, 16, "\nindex: %u", index);
8214 rte_hexdump(stdout, title, raw_data, raw_size);
8216 } while (all && ++index < RAW_ENCAP_CONFS_MAX_NUM);
8219 cmdline_parse_token_string_t cmd_show_set_raw_cmd_show =
8220 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
8222 cmdline_parse_token_string_t cmd_show_set_raw_cmd_what =
8223 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
8224 cmd_what, "raw_encap#raw_decap");
8225 cmdline_parse_token_num_t cmd_show_set_raw_cmd_index =
8226 TOKEN_NUM_INITIALIZER(struct cmd_show_set_raw_result,
8227 cmd_index, RTE_UINT16);
8228 cmdline_parse_token_string_t cmd_show_set_raw_cmd_all =
8229 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
8231 cmdline_parse_inst_t cmd_show_set_raw = {
8232 .f = cmd_show_set_raw_parsed,
8234 .help_str = "show <raw_encap|raw_decap> <index>",
8236 (void *)&cmd_show_set_raw_cmd_show,
8237 (void *)&cmd_show_set_raw_cmd_what,
8238 (void *)&cmd_show_set_raw_cmd_index,
8242 cmdline_parse_inst_t cmd_show_set_raw_all = {
8243 .f = cmd_show_set_raw_parsed,
8245 .help_str = "show <raw_encap|raw_decap> all",
8247 (void *)&cmd_show_set_raw_cmd_show,
8248 (void *)&cmd_show_set_raw_cmd_what,
8249 (void *)&cmd_show_set_raw_cmd_all,