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,
229 ITEM_ARP_ETH_IPV4_SHA,
230 ITEM_ARP_ETH_IPV4_SPA,
231 ITEM_ARP_ETH_IPV4_THA,
232 ITEM_ARP_ETH_IPV4_TPA,
234 ITEM_IPV6_EXT_NEXT_HDR,
236 ITEM_IPV6_FRAG_EXT_NEXT_HDR,
237 ITEM_IPV6_FRAG_EXT_FRAG_DATA,
242 ITEM_ICMP6_ND_NS_TARGET_ADDR,
244 ITEM_ICMP6_ND_NA_TARGET_ADDR,
246 ITEM_ICMP6_ND_OPT_TYPE,
247 ITEM_ICMP6_ND_OPT_SLA_ETH,
248 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
249 ITEM_ICMP6_ND_OPT_TLA_ETH,
250 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
263 ITEM_HIGIG2_CLASSIFICATION,
269 ITEM_L2TPV3OIP_SESSION_ID,
279 ITEM_ECPRI_COMMON_TYPE,
280 ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
281 ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
282 ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
283 ITEM_ECPRI_MSG_IQ_DATA_PCID,
284 ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
285 ITEM_ECPRI_MSG_DLY_MSR_MSRID,
287 ITEM_GENEVE_OPT_CLASS,
288 ITEM_GENEVE_OPT_TYPE,
289 ITEM_GENEVE_OPT_LENGTH,
290 ITEM_GENEVE_OPT_DATA,
292 /* Validate/create actions. */
312 ACTION_RSS_FUNC_DEFAULT,
313 ACTION_RSS_FUNC_TOEPLITZ,
314 ACTION_RSS_FUNC_SIMPLE_XOR,
315 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ,
327 ACTION_PHY_PORT_ORIGINAL,
328 ACTION_PHY_PORT_INDEX,
330 ACTION_PORT_ID_ORIGINAL,
334 ACTION_OF_SET_MPLS_TTL,
335 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
336 ACTION_OF_DEC_MPLS_TTL,
337 ACTION_OF_SET_NW_TTL,
338 ACTION_OF_SET_NW_TTL_NW_TTL,
339 ACTION_OF_DEC_NW_TTL,
340 ACTION_OF_COPY_TTL_OUT,
341 ACTION_OF_COPY_TTL_IN,
344 ACTION_OF_PUSH_VLAN_ETHERTYPE,
345 ACTION_OF_SET_VLAN_VID,
346 ACTION_OF_SET_VLAN_VID_VLAN_VID,
347 ACTION_OF_SET_VLAN_PCP,
348 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
350 ACTION_OF_POP_MPLS_ETHERTYPE,
352 ACTION_OF_PUSH_MPLS_ETHERTYPE,
359 ACTION_MPLSOGRE_ENCAP,
360 ACTION_MPLSOGRE_DECAP,
361 ACTION_MPLSOUDP_ENCAP,
362 ACTION_MPLSOUDP_DECAP,
364 ACTION_SET_IPV4_SRC_IPV4_SRC,
366 ACTION_SET_IPV4_DST_IPV4_DST,
368 ACTION_SET_IPV6_SRC_IPV6_SRC,
370 ACTION_SET_IPV6_DST_IPV6_DST,
372 ACTION_SET_TP_SRC_TP_SRC,
374 ACTION_SET_TP_DST_TP_DST,
380 ACTION_SET_MAC_SRC_MAC_SRC,
382 ACTION_SET_MAC_DST_MAC_DST,
384 ACTION_INC_TCP_SEQ_VALUE,
386 ACTION_DEC_TCP_SEQ_VALUE,
388 ACTION_INC_TCP_ACK_VALUE,
390 ACTION_DEC_TCP_ACK_VALUE,
393 ACTION_RAW_ENCAP_INDEX,
394 ACTION_RAW_ENCAP_INDEX_VALUE,
395 ACTION_RAW_DECAP_INDEX,
396 ACTION_RAW_DECAP_INDEX_VALUE,
399 ACTION_SET_TAG_INDEX,
402 ACTION_SET_META_DATA,
403 ACTION_SET_META_MASK,
404 ACTION_SET_IPV4_DSCP,
405 ACTION_SET_IPV4_DSCP_VALUE,
406 ACTION_SET_IPV6_DSCP,
407 ACTION_SET_IPV6_DSCP_VALUE,
413 ACTION_SAMPLE_INDEX_VALUE,
415 SHARED_ACTION_ID2PTR,
418 /** Maximum size for pattern in struct rte_flow_item_raw. */
419 #define ITEM_RAW_PATTERN_SIZE 40
421 /** Maximum size for GENEVE option data pattern in bytes. */
422 #define ITEM_GENEVE_OPT_DATA_SIZE 124
424 /** Storage size for struct rte_flow_item_raw including pattern. */
425 #define ITEM_RAW_SIZE \
426 (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE)
428 /** Maximum number of queue indices in struct rte_flow_action_rss. */
429 #define ACTION_RSS_QUEUE_NUM 128
431 /** Storage for struct rte_flow_action_rss including external data. */
432 struct action_rss_data {
433 struct rte_flow_action_rss conf;
434 uint8_t key[RSS_HASH_KEY_LENGTH];
435 uint16_t queue[ACTION_RSS_QUEUE_NUM];
438 /** Maximum data size in struct rte_flow_action_raw_encap. */
439 #define ACTION_RAW_ENCAP_MAX_DATA 512
440 #define RAW_ENCAP_CONFS_MAX_NUM 8
442 /** Storage for struct rte_flow_action_raw_encap. */
443 struct raw_encap_conf {
444 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
445 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
449 struct raw_encap_conf raw_encap_confs[RAW_ENCAP_CONFS_MAX_NUM];
451 /** Storage for struct rte_flow_action_raw_encap including external data. */
452 struct action_raw_encap_data {
453 struct rte_flow_action_raw_encap conf;
454 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
455 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
459 /** Storage for struct rte_flow_action_raw_decap. */
460 struct raw_decap_conf {
461 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
465 struct raw_decap_conf raw_decap_confs[RAW_ENCAP_CONFS_MAX_NUM];
467 /** Storage for struct rte_flow_action_raw_decap including external data. */
468 struct action_raw_decap_data {
469 struct rte_flow_action_raw_decap conf;
470 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
474 struct vxlan_encap_conf vxlan_encap_conf = {
478 .vni = "\x00\x00\x00",
480 .udp_dst = RTE_BE16(RTE_VXLAN_DEFAULT_PORT),
481 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
482 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
483 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
484 "\x00\x00\x00\x00\x00\x00\x00\x01",
485 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
486 "\x00\x00\x00\x00\x00\x00\x11\x11",
490 .eth_src = "\x00\x00\x00\x00\x00\x00",
491 .eth_dst = "\xff\xff\xff\xff\xff\xff",
494 /** Maximum number of items in struct rte_flow_action_vxlan_encap. */
495 #define ACTION_VXLAN_ENCAP_ITEMS_NUM 6
497 /** Storage for struct rte_flow_action_vxlan_encap including external data. */
498 struct action_vxlan_encap_data {
499 struct rte_flow_action_vxlan_encap conf;
500 struct rte_flow_item items[ACTION_VXLAN_ENCAP_ITEMS_NUM];
501 struct rte_flow_item_eth item_eth;
502 struct rte_flow_item_vlan item_vlan;
504 struct rte_flow_item_ipv4 item_ipv4;
505 struct rte_flow_item_ipv6 item_ipv6;
507 struct rte_flow_item_udp item_udp;
508 struct rte_flow_item_vxlan item_vxlan;
511 struct nvgre_encap_conf nvgre_encap_conf = {
514 .tni = "\x00\x00\x00",
515 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
516 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
517 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
518 "\x00\x00\x00\x00\x00\x00\x00\x01",
519 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
520 "\x00\x00\x00\x00\x00\x00\x11\x11",
522 .eth_src = "\x00\x00\x00\x00\x00\x00",
523 .eth_dst = "\xff\xff\xff\xff\xff\xff",
526 /** Maximum number of items in struct rte_flow_action_nvgre_encap. */
527 #define ACTION_NVGRE_ENCAP_ITEMS_NUM 5
529 /** Storage for struct rte_flow_action_nvgre_encap including external data. */
530 struct action_nvgre_encap_data {
531 struct rte_flow_action_nvgre_encap conf;
532 struct rte_flow_item items[ACTION_NVGRE_ENCAP_ITEMS_NUM];
533 struct rte_flow_item_eth item_eth;
534 struct rte_flow_item_vlan item_vlan;
536 struct rte_flow_item_ipv4 item_ipv4;
537 struct rte_flow_item_ipv6 item_ipv6;
539 struct rte_flow_item_nvgre item_nvgre;
542 struct l2_encap_conf l2_encap_conf;
544 struct l2_decap_conf l2_decap_conf;
546 struct mplsogre_encap_conf mplsogre_encap_conf;
548 struct mplsogre_decap_conf mplsogre_decap_conf;
550 struct mplsoudp_encap_conf mplsoudp_encap_conf;
552 struct mplsoudp_decap_conf mplsoudp_decap_conf;
554 #define ACTION_SAMPLE_ACTIONS_NUM 10
555 #define RAW_SAMPLE_CONFS_MAX_NUM 8
556 /** Storage for struct rte_flow_action_sample including external data. */
557 struct action_sample_data {
558 struct rte_flow_action_sample conf;
561 /** Storage for struct rte_flow_action_sample. */
562 struct raw_sample_conf {
563 struct rte_flow_action data[ACTION_SAMPLE_ACTIONS_NUM];
565 struct raw_sample_conf raw_sample_confs[RAW_SAMPLE_CONFS_MAX_NUM];
566 struct rte_flow_action_mark sample_mark[RAW_SAMPLE_CONFS_MAX_NUM];
567 struct rte_flow_action_queue sample_queue[RAW_SAMPLE_CONFS_MAX_NUM];
568 struct rte_flow_action_count sample_count[RAW_SAMPLE_CONFS_MAX_NUM];
569 struct rte_flow_action_port_id sample_port_id[RAW_SAMPLE_CONFS_MAX_NUM];
570 struct rte_flow_action_raw_encap sample_encap[RAW_SAMPLE_CONFS_MAX_NUM];
572 /** Maximum number of subsequent tokens and arguments on the stack. */
573 #define CTX_STACK_SIZE 16
575 /** Parser context. */
577 /** Stack of subsequent token lists to process. */
578 const enum index *next[CTX_STACK_SIZE];
579 /** Arguments for stacked tokens. */
580 const void *args[CTX_STACK_SIZE];
581 enum index curr; /**< Current token index. */
582 enum index prev; /**< Index of the last token seen. */
583 int next_num; /**< Number of entries in next[]. */
584 int args_num; /**< Number of entries in args[]. */
585 uint32_t eol:1; /**< EOL has been detected. */
586 uint32_t last:1; /**< No more arguments. */
587 portid_t port; /**< Current port ID (for completions). */
588 uint32_t objdata; /**< Object-specific data. */
589 void *object; /**< Address of current object for relative offsets. */
590 void *objmask; /**< Object a full mask must be written to. */
593 /** Token argument. */
595 uint32_t hton:1; /**< Use network byte ordering. */
596 uint32_t sign:1; /**< Value is signed. */
597 uint32_t bounded:1; /**< Value is bounded. */
598 uintmax_t min; /**< Minimum value if bounded. */
599 uintmax_t max; /**< Maximum value if bounded. */
600 uint32_t offset; /**< Relative offset from ctx->object. */
601 uint32_t size; /**< Field size. */
602 const uint8_t *mask; /**< Bit-mask to use instead of offset/size. */
605 /** Parser token definition. */
607 /** Type displayed during completion (defaults to "TOKEN"). */
609 /** Help displayed during completion (defaults to token name). */
611 /** Private data used by parser functions. */
614 * Lists of subsequent tokens to push on the stack. Each call to the
615 * parser consumes the last entry of that stack.
617 const enum index *const *next;
618 /** Arguments stack for subsequent tokens that need them. */
619 const struct arg *const *args;
621 * Token-processing callback, returns -1 in case of error, the
622 * length of the matched string otherwise. If NULL, attempts to
623 * match the token name.
625 * If buf is not NULL, the result should be stored in it according
626 * to context. An error is returned if not large enough.
628 int (*call)(struct context *ctx, const struct token *token,
629 const char *str, unsigned int len,
630 void *buf, unsigned int size);
632 * Callback that provides possible values for this token, used for
633 * completion. Returns -1 in case of error, the number of possible
634 * values otherwise. If NULL, the token name is used.
636 * If buf is not NULL, entry index ent is written to buf and the
637 * full length of the entry is returned (same behavior as
640 int (*comp)(struct context *ctx, const struct token *token,
641 unsigned int ent, char *buf, unsigned int size);
642 /** Mandatory token name, no default value. */
646 /** Static initializer for the next field. */
647 #define NEXT(...) (const enum index *const []){ __VA_ARGS__, NULL, }
649 /** Static initializer for a NEXT() entry. */
650 #define NEXT_ENTRY(...) (const enum index []){ __VA_ARGS__, ZERO, }
652 /** Static initializer for the args field. */
653 #define ARGS(...) (const struct arg *const []){ __VA_ARGS__, NULL, }
655 /** Static initializer for ARGS() to target a field. */
656 #define ARGS_ENTRY(s, f) \
657 (&(const struct arg){ \
658 .offset = offsetof(s, f), \
659 .size = sizeof(((s *)0)->f), \
662 /** Static initializer for ARGS() to target a bit-field. */
663 #define ARGS_ENTRY_BF(s, f, b) \
664 (&(const struct arg){ \
666 .mask = (const void *)&(const s){ .f = (1 << (b)) - 1 }, \
669 /** Static initializer for ARGS() to target a field with limits. */
670 #define ARGS_ENTRY_BOUNDED(s, f, i, a) \
671 (&(const struct arg){ \
675 .offset = offsetof(s, f), \
676 .size = sizeof(((s *)0)->f), \
679 /** Static initializer for ARGS() to target an arbitrary bit-mask. */
680 #define ARGS_ENTRY_MASK(s, f, m) \
681 (&(const struct arg){ \
682 .offset = offsetof(s, f), \
683 .size = sizeof(((s *)0)->f), \
684 .mask = (const void *)(m), \
687 /** Same as ARGS_ENTRY_MASK() using network byte ordering for the value. */
688 #define ARGS_ENTRY_MASK_HTON(s, f, m) \
689 (&(const struct arg){ \
691 .offset = offsetof(s, f), \
692 .size = sizeof(((s *)0)->f), \
693 .mask = (const void *)(m), \
696 /** Static initializer for ARGS() to target a pointer. */
697 #define ARGS_ENTRY_PTR(s, f) \
698 (&(const struct arg){ \
699 .size = sizeof(*((s *)0)->f), \
702 /** Static initializer for ARGS() with arbitrary offset and size. */
703 #define ARGS_ENTRY_ARB(o, s) \
704 (&(const struct arg){ \
709 /** Same as ARGS_ENTRY_ARB() with bounded values. */
710 #define ARGS_ENTRY_ARB_BOUNDED(o, s, i, a) \
711 (&(const struct arg){ \
719 /** Same as ARGS_ENTRY() using network byte ordering. */
720 #define ARGS_ENTRY_HTON(s, f) \
721 (&(const struct arg){ \
723 .offset = offsetof(s, f), \
724 .size = sizeof(((s *)0)->f), \
727 /** Same as ARGS_ENTRY_HTON() for a single argument, without structure. */
728 #define ARG_ENTRY_HTON(s) \
729 (&(const struct arg){ \
735 /** Parser output buffer layout expected by cmd_flow_parsed(). */
737 enum index command; /**< Flow command. */
738 portid_t port; /**< Affected port ID. */
742 uint32_t action_id_n;
743 } sa_destroy; /**< Shared action destroy arguments. */
746 } sa; /* Shared action query arguments */
748 struct rte_flow_attr attr;
749 struct tunnel_ops tunnel_ops;
750 struct rte_flow_item *pattern;
751 struct rte_flow_action *actions;
755 } vc; /**< Validate/create arguments. */
759 } destroy; /**< Destroy arguments. */
762 } dump; /**< Dump arguments. */
765 struct rte_flow_action action;
766 } query; /**< Query arguments. */
770 } list; /**< List arguments. */
773 } isolate; /**< Isolated mode arguments. */
776 } aged; /**< Aged arguments. */
777 } args; /**< Command arguments. */
780 /** Private data for pattern items. */
781 struct parse_item_priv {
782 enum rte_flow_item_type type; /**< Item type. */
783 uint32_t size; /**< Size of item specification structure. */
786 #define PRIV_ITEM(t, s) \
787 (&(const struct parse_item_priv){ \
788 .type = RTE_FLOW_ITEM_TYPE_ ## t, \
792 /** Private data for actions. */
793 struct parse_action_priv {
794 enum rte_flow_action_type type; /**< Action type. */
795 uint32_t size; /**< Size of action configuration structure. */
798 #define PRIV_ACTION(t, s) \
799 (&(const struct parse_action_priv){ \
800 .type = RTE_FLOW_ACTION_TYPE_ ## t, \
804 static const enum index next_sa_create_attr[] = {
805 SHARED_ACTION_CREATE_ID,
806 SHARED_ACTION_INGRESS,
807 SHARED_ACTION_EGRESS,
808 SHARED_ACTION_TRANSFER,
813 static const enum index next_sa_subcmd[] = {
814 SHARED_ACTION_CREATE,
815 SHARED_ACTION_UPDATE,
816 SHARED_ACTION_DESTROY,
821 static const enum index next_vc_attr[] = {
833 static const enum index next_destroy_attr[] = {
839 static const enum index next_dump_attr[] = {
845 static const enum index next_list_attr[] = {
851 static const enum index next_aged_attr[] = {
857 static const enum index next_sa_destroy_attr[] = {
858 SHARED_ACTION_DESTROY_ID,
863 static const enum index item_param[] = {
872 static const enum index next_item[] = {
909 ITEM_ICMP6_ND_OPT_SLA_ETH,
910 ITEM_ICMP6_ND_OPT_TLA_ETH,
929 static const enum index item_fuzzy[] = {
935 static const enum index item_any[] = {
941 static const enum index item_vf[] = {
947 static const enum index item_phy_port[] = {
953 static const enum index item_port_id[] = {
959 static const enum index item_mark[] = {
965 static const enum index item_raw[] = {
975 static const enum index item_eth[] = {
984 static const enum index item_vlan[] = {
989 ITEM_VLAN_INNER_TYPE,
990 ITEM_VLAN_HAS_MORE_VLAN,
995 static const enum index item_ipv4[] = {
997 ITEM_IPV4_FRAGMENT_OFFSET,
1006 static const enum index item_ipv6[] = {
1013 ITEM_IPV6_HAS_FRAG_EXT,
1018 static const enum index item_icmp[] = {
1027 static const enum index item_udp[] = {
1034 static const enum index item_tcp[] = {
1042 static const enum index item_sctp[] = {
1051 static const enum index item_vxlan[] = {
1057 static const enum index item_e_tag[] = {
1058 ITEM_E_TAG_GRP_ECID_B,
1063 static const enum index item_nvgre[] = {
1069 static const enum index item_mpls[] = {
1077 static const enum index item_gre[] = {
1079 ITEM_GRE_C_RSVD0_VER,
1087 static const enum index item_gre_key[] = {
1093 static const enum index item_gtp[] = {
1101 static const enum index item_geneve[] = {
1108 static const enum index item_vxlan_gpe[] = {
1114 static const enum index item_arp_eth_ipv4[] = {
1115 ITEM_ARP_ETH_IPV4_SHA,
1116 ITEM_ARP_ETH_IPV4_SPA,
1117 ITEM_ARP_ETH_IPV4_THA,
1118 ITEM_ARP_ETH_IPV4_TPA,
1123 static const enum index item_ipv6_ext[] = {
1124 ITEM_IPV6_EXT_NEXT_HDR,
1129 static const enum index item_ipv6_frag_ext[] = {
1130 ITEM_IPV6_FRAG_EXT_NEXT_HDR,
1131 ITEM_IPV6_FRAG_EXT_FRAG_DATA,
1136 static const enum index item_icmp6[] = {
1143 static const enum index item_icmp6_nd_ns[] = {
1144 ITEM_ICMP6_ND_NS_TARGET_ADDR,
1149 static const enum index item_icmp6_nd_na[] = {
1150 ITEM_ICMP6_ND_NA_TARGET_ADDR,
1155 static const enum index item_icmp6_nd_opt[] = {
1156 ITEM_ICMP6_ND_OPT_TYPE,
1161 static const enum index item_icmp6_nd_opt_sla_eth[] = {
1162 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
1167 static const enum index item_icmp6_nd_opt_tla_eth[] = {
1168 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
1173 static const enum index item_meta[] = {
1179 static const enum index item_gtp_psc[] = {
1186 static const enum index item_pppoed[] = {
1192 static const enum index item_pppoes[] = {
1198 static const enum index item_pppoe_proto_id[] = {
1203 static const enum index item_higig2[] = {
1204 ITEM_HIGIG2_CLASSIFICATION,
1210 static const enum index item_esp[] = {
1216 static const enum index item_ah[] = {
1222 static const enum index item_pfcp[] = {
1229 static const enum index next_set_raw[] = {
1235 static const enum index item_tag[] = {
1242 static const enum index item_l2tpv3oip[] = {
1243 ITEM_L2TPV3OIP_SESSION_ID,
1248 static const enum index item_ecpri[] = {
1254 static const enum index item_ecpri_common[] = {
1255 ITEM_ECPRI_COMMON_TYPE,
1259 static const enum index item_ecpri_common_type[] = {
1260 ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
1261 ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
1262 ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
1266 static const enum index item_geneve_opt[] = {
1267 ITEM_GENEVE_OPT_CLASS,
1268 ITEM_GENEVE_OPT_TYPE,
1269 ITEM_GENEVE_OPT_LENGTH,
1270 ITEM_GENEVE_OPT_DATA,
1275 static const enum index next_action[] = {
1291 ACTION_OF_SET_MPLS_TTL,
1292 ACTION_OF_DEC_MPLS_TTL,
1293 ACTION_OF_SET_NW_TTL,
1294 ACTION_OF_DEC_NW_TTL,
1295 ACTION_OF_COPY_TTL_OUT,
1296 ACTION_OF_COPY_TTL_IN,
1298 ACTION_OF_PUSH_VLAN,
1299 ACTION_OF_SET_VLAN_VID,
1300 ACTION_OF_SET_VLAN_PCP,
1302 ACTION_OF_PUSH_MPLS,
1309 ACTION_MPLSOGRE_ENCAP,
1310 ACTION_MPLSOGRE_DECAP,
1311 ACTION_MPLSOUDP_ENCAP,
1312 ACTION_MPLSOUDP_DECAP,
1313 ACTION_SET_IPV4_SRC,
1314 ACTION_SET_IPV4_DST,
1315 ACTION_SET_IPV6_SRC,
1316 ACTION_SET_IPV6_DST,
1332 ACTION_SET_IPV4_DSCP,
1333 ACTION_SET_IPV6_DSCP,
1340 static const enum index action_mark[] = {
1346 static const enum index action_queue[] = {
1352 static const enum index action_count[] = {
1354 ACTION_COUNT_SHARED,
1359 static const enum index action_rss[] = {
1370 static const enum index action_vf[] = {
1377 static const enum index action_phy_port[] = {
1378 ACTION_PHY_PORT_ORIGINAL,
1379 ACTION_PHY_PORT_INDEX,
1384 static const enum index action_port_id[] = {
1385 ACTION_PORT_ID_ORIGINAL,
1391 static const enum index action_meter[] = {
1397 static const enum index action_of_set_mpls_ttl[] = {
1398 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
1403 static const enum index action_of_set_nw_ttl[] = {
1404 ACTION_OF_SET_NW_TTL_NW_TTL,
1409 static const enum index action_of_push_vlan[] = {
1410 ACTION_OF_PUSH_VLAN_ETHERTYPE,
1415 static const enum index action_of_set_vlan_vid[] = {
1416 ACTION_OF_SET_VLAN_VID_VLAN_VID,
1421 static const enum index action_of_set_vlan_pcp[] = {
1422 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
1427 static const enum index action_of_pop_mpls[] = {
1428 ACTION_OF_POP_MPLS_ETHERTYPE,
1433 static const enum index action_of_push_mpls[] = {
1434 ACTION_OF_PUSH_MPLS_ETHERTYPE,
1439 static const enum index action_set_ipv4_src[] = {
1440 ACTION_SET_IPV4_SRC_IPV4_SRC,
1445 static const enum index action_set_mac_src[] = {
1446 ACTION_SET_MAC_SRC_MAC_SRC,
1451 static const enum index action_set_ipv4_dst[] = {
1452 ACTION_SET_IPV4_DST_IPV4_DST,
1457 static const enum index action_set_ipv6_src[] = {
1458 ACTION_SET_IPV6_SRC_IPV6_SRC,
1463 static const enum index action_set_ipv6_dst[] = {
1464 ACTION_SET_IPV6_DST_IPV6_DST,
1469 static const enum index action_set_tp_src[] = {
1470 ACTION_SET_TP_SRC_TP_SRC,
1475 static const enum index action_set_tp_dst[] = {
1476 ACTION_SET_TP_DST_TP_DST,
1481 static const enum index action_set_ttl[] = {
1487 static const enum index action_jump[] = {
1493 static const enum index action_set_mac_dst[] = {
1494 ACTION_SET_MAC_DST_MAC_DST,
1499 static const enum index action_inc_tcp_seq[] = {
1500 ACTION_INC_TCP_SEQ_VALUE,
1505 static const enum index action_dec_tcp_seq[] = {
1506 ACTION_DEC_TCP_SEQ_VALUE,
1511 static const enum index action_inc_tcp_ack[] = {
1512 ACTION_INC_TCP_ACK_VALUE,
1517 static const enum index action_dec_tcp_ack[] = {
1518 ACTION_DEC_TCP_ACK_VALUE,
1523 static const enum index action_raw_encap[] = {
1524 ACTION_RAW_ENCAP_INDEX,
1529 static const enum index action_raw_decap[] = {
1530 ACTION_RAW_DECAP_INDEX,
1535 static const enum index action_set_tag[] = {
1536 ACTION_SET_TAG_DATA,
1537 ACTION_SET_TAG_INDEX,
1538 ACTION_SET_TAG_MASK,
1543 static const enum index action_set_meta[] = {
1544 ACTION_SET_META_DATA,
1545 ACTION_SET_META_MASK,
1550 static const enum index action_set_ipv4_dscp[] = {
1551 ACTION_SET_IPV4_DSCP_VALUE,
1556 static const enum index action_set_ipv6_dscp[] = {
1557 ACTION_SET_IPV6_DSCP_VALUE,
1562 static const enum index action_age[] = {
1569 static const enum index action_sample[] = {
1571 ACTION_SAMPLE_RATIO,
1572 ACTION_SAMPLE_INDEX,
1577 static const enum index next_action_sample[] = {
1587 static int parse_set_raw_encap_decap(struct context *, const struct token *,
1588 const char *, unsigned int,
1589 void *, unsigned int);
1590 static int parse_set_sample_action(struct context *, const struct token *,
1591 const char *, unsigned int,
1592 void *, unsigned int);
1593 static int parse_set_init(struct context *, const struct token *,
1594 const char *, unsigned int,
1595 void *, unsigned int);
1596 static int parse_init(struct context *, const struct token *,
1597 const char *, unsigned int,
1598 void *, unsigned int);
1599 static int parse_vc(struct context *, const struct token *,
1600 const char *, unsigned int,
1601 void *, unsigned int);
1602 static int parse_vc_spec(struct context *, const struct token *,
1603 const char *, unsigned int, void *, unsigned int);
1604 static int parse_vc_conf(struct context *, const struct token *,
1605 const char *, unsigned int, void *, unsigned int);
1606 static int parse_vc_item_ecpri_type(struct context *, const struct token *,
1607 const char *, unsigned int,
1608 void *, unsigned int);
1609 static int parse_vc_action_rss(struct context *, const struct token *,
1610 const char *, unsigned int, void *,
1612 static int parse_vc_action_rss_func(struct context *, const struct token *,
1613 const char *, unsigned int, void *,
1615 static int parse_vc_action_rss_type(struct context *, const struct token *,
1616 const char *, unsigned int, void *,
1618 static int parse_vc_action_rss_queue(struct context *, const struct token *,
1619 const char *, unsigned int, void *,
1621 static int parse_vc_action_vxlan_encap(struct context *, const struct token *,
1622 const char *, unsigned int, void *,
1624 static int parse_vc_action_nvgre_encap(struct context *, const struct token *,
1625 const char *, unsigned int, void *,
1627 static int parse_vc_action_l2_encap(struct context *, const struct token *,
1628 const char *, unsigned int, void *,
1630 static int parse_vc_action_l2_decap(struct context *, const struct token *,
1631 const char *, unsigned int, void *,
1633 static int parse_vc_action_mplsogre_encap(struct context *,
1634 const struct token *, const char *,
1635 unsigned int, void *, unsigned int);
1636 static int parse_vc_action_mplsogre_decap(struct context *,
1637 const struct token *, const char *,
1638 unsigned int, void *, unsigned int);
1639 static int parse_vc_action_mplsoudp_encap(struct context *,
1640 const struct token *, const char *,
1641 unsigned int, void *, unsigned int);
1642 static int parse_vc_action_mplsoudp_decap(struct context *,
1643 const struct token *, const char *,
1644 unsigned int, void *, unsigned int);
1645 static int parse_vc_action_raw_encap(struct context *,
1646 const struct token *, const char *,
1647 unsigned int, void *, unsigned int);
1648 static int parse_vc_action_raw_decap(struct context *,
1649 const struct token *, const char *,
1650 unsigned int, void *, unsigned int);
1651 static int parse_vc_action_raw_encap_index(struct context *,
1652 const struct token *, const char *,
1653 unsigned int, void *, unsigned int);
1654 static int parse_vc_action_raw_decap_index(struct context *,
1655 const struct token *, const char *,
1656 unsigned int, void *, unsigned int);
1657 static int parse_vc_action_set_meta(struct context *ctx,
1658 const struct token *token, const char *str,
1659 unsigned int len, void *buf,
1661 static int parse_vc_action_sample(struct context *ctx,
1662 const struct token *token, const char *str,
1663 unsigned int len, void *buf,
1666 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
1667 const char *str, unsigned int len, void *buf,
1669 static int parse_destroy(struct context *, const struct token *,
1670 const char *, unsigned int,
1671 void *, unsigned int);
1672 static int parse_flush(struct context *, const struct token *,
1673 const char *, unsigned int,
1674 void *, unsigned int);
1675 static int parse_dump(struct context *, const struct token *,
1676 const char *, unsigned int,
1677 void *, unsigned int);
1678 static int parse_query(struct context *, const struct token *,
1679 const char *, unsigned int,
1680 void *, unsigned int);
1681 static int parse_action(struct context *, const struct token *,
1682 const char *, unsigned int,
1683 void *, unsigned int);
1684 static int parse_list(struct context *, const struct token *,
1685 const char *, unsigned int,
1686 void *, unsigned int);
1687 static int parse_aged(struct context *, const struct token *,
1688 const char *, unsigned int,
1689 void *, unsigned int);
1690 static int parse_isolate(struct context *, const struct token *,
1691 const char *, unsigned int,
1692 void *, unsigned int);
1693 static int parse_tunnel(struct context *, const struct token *,
1694 const char *, unsigned int,
1695 void *, unsigned int);
1696 static int parse_int(struct context *, const struct token *,
1697 const char *, unsigned int,
1698 void *, unsigned int);
1699 static int parse_prefix(struct context *, const struct token *,
1700 const char *, unsigned int,
1701 void *, unsigned int);
1702 static int parse_boolean(struct context *, const struct token *,
1703 const char *, unsigned int,
1704 void *, unsigned int);
1705 static int parse_string(struct context *, const struct token *,
1706 const char *, unsigned int,
1707 void *, unsigned int);
1708 static int parse_hex(struct context *ctx, const struct token *token,
1709 const char *str, unsigned int len,
1710 void *buf, unsigned int size);
1711 static int parse_string0(struct context *, const struct token *,
1712 const char *, unsigned int,
1713 void *, unsigned int);
1714 static int parse_mac_addr(struct context *, const struct token *,
1715 const char *, unsigned int,
1716 void *, unsigned int);
1717 static int parse_ipv4_addr(struct context *, const struct token *,
1718 const char *, unsigned int,
1719 void *, unsigned int);
1720 static int parse_ipv6_addr(struct context *, const struct token *,
1721 const char *, unsigned int,
1722 void *, unsigned int);
1723 static int parse_port(struct context *, const struct token *,
1724 const char *, unsigned int,
1725 void *, unsigned int);
1726 static int parse_sa(struct context *, const struct token *,
1727 const char *, unsigned int,
1728 void *, unsigned int);
1729 static int parse_sa_destroy(struct context *ctx, const struct token *token,
1730 const char *str, unsigned int len,
1731 void *buf, unsigned int size);
1732 static int parse_sa_id2ptr(struct context *ctx, const struct token *token,
1733 const char *str, unsigned int len, void *buf,
1735 static int comp_none(struct context *, const struct token *,
1736 unsigned int, char *, unsigned int);
1737 static int comp_boolean(struct context *, const struct token *,
1738 unsigned int, char *, unsigned int);
1739 static int comp_action(struct context *, const struct token *,
1740 unsigned int, char *, unsigned int);
1741 static int comp_port(struct context *, const struct token *,
1742 unsigned int, char *, unsigned int);
1743 static int comp_rule_id(struct context *, const struct token *,
1744 unsigned int, char *, unsigned int);
1745 static int comp_vc_action_rss_type(struct context *, const struct token *,
1746 unsigned int, char *, unsigned int);
1747 static int comp_vc_action_rss_queue(struct context *, const struct token *,
1748 unsigned int, char *, unsigned int);
1749 static int comp_set_raw_index(struct context *, const struct token *,
1750 unsigned int, char *, unsigned int);
1751 static int comp_set_sample_index(struct context *, const struct token *,
1752 unsigned int, char *, unsigned int);
1754 /** Token definitions. */
1755 static const struct token token_list[] = {
1756 /* Special tokens. */
1759 .help = "null entry, abused as the entry point",
1760 .next = NEXT(NEXT_ENTRY(FLOW)),
1765 .help = "command may end here",
1768 .name = "START_SET",
1769 .help = "null entry, abused as the entry point for set",
1770 .next = NEXT(NEXT_ENTRY(SET)),
1775 .help = "set command may end here",
1777 /* Common tokens. */
1781 .help = "integer value",
1786 .name = "{unsigned}",
1788 .help = "unsigned integer value",
1795 .help = "prefix length for bit-mask",
1796 .call = parse_prefix,
1800 .name = "{boolean}",
1802 .help = "any boolean value",
1803 .call = parse_boolean,
1804 .comp = comp_boolean,
1809 .help = "fixed string",
1810 .call = parse_string,
1816 .help = "fixed string",
1820 .name = "{file path}",
1822 .help = "file path",
1823 .call = parse_string0,
1827 .name = "{MAC address}",
1829 .help = "standard MAC address notation",
1830 .call = parse_mac_addr,
1834 .name = "{IPv4 address}",
1835 .type = "IPV4 ADDRESS",
1836 .help = "standard IPv4 address notation",
1837 .call = parse_ipv4_addr,
1841 .name = "{IPv6 address}",
1842 .type = "IPV6 ADDRESS",
1843 .help = "standard IPv6 address notation",
1844 .call = parse_ipv6_addr,
1848 .name = "{rule id}",
1850 .help = "rule identifier",
1852 .comp = comp_rule_id,
1855 .name = "{port_id}",
1857 .help = "port identifier",
1862 .name = "{group_id}",
1864 .help = "group identifier",
1868 [PRIORITY_LEVEL] = {
1871 .help = "priority level",
1875 [SHARED_ACTION_ID] = {
1876 .name = "{shared_action_id}",
1877 .type = "SHARED_ACTION_ID",
1878 .help = "shared action id",
1882 /* Top-level command. */
1885 .type = "{command} {port_id} [{arg} [...]]",
1886 .help = "manage ingress/egress flow rules",
1887 .next = NEXT(NEXT_ENTRY
1901 /* Top-level command. */
1903 .name = "shared_action",
1904 .type = "{command} {port_id} [{arg} [...]]",
1905 .help = "manage shared actions",
1906 .next = NEXT(next_sa_subcmd, NEXT_ENTRY(PORT_ID)),
1907 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1910 /* Sub-level commands. */
1911 [SHARED_ACTION_CREATE] = {
1913 .help = "create shared action",
1914 .next = NEXT(next_sa_create_attr),
1917 [SHARED_ACTION_UPDATE] = {
1919 .help = "update shared action",
1920 .next = NEXT(NEXT_ENTRY(SHARED_ACTION_SPEC),
1921 NEXT_ENTRY(SHARED_ACTION_ID)),
1922 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
1925 [SHARED_ACTION_DESTROY] = {
1927 .help = "destroy shared action",
1928 .next = NEXT(NEXT_ENTRY(SHARED_ACTION_DESTROY_ID)),
1929 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1930 .call = parse_sa_destroy,
1932 [SHARED_ACTION_QUERY] = {
1934 .help = "query shared action",
1935 .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(SHARED_ACTION_ID)),
1936 .args = ARGS(ARGS_ENTRY(struct buffer, args.sa.action_id)),
1941 .help = "check whether a flow rule can be created",
1942 .next = NEXT(next_vc_attr, NEXT_ENTRY(PORT_ID)),
1943 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1948 .help = "create a flow rule",
1949 .next = NEXT(next_vc_attr, NEXT_ENTRY(PORT_ID)),
1950 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1955 .help = "destroy specific flow rules",
1956 .next = NEXT(NEXT_ENTRY(DESTROY_RULE), NEXT_ENTRY(PORT_ID)),
1957 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1958 .call = parse_destroy,
1962 .help = "destroy all flow rules",
1963 .next = NEXT(NEXT_ENTRY(PORT_ID)),
1964 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1965 .call = parse_flush,
1969 .help = "dump all flow rules to file",
1970 .next = NEXT(next_dump_attr, NEXT_ENTRY(PORT_ID)),
1971 .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file),
1972 ARGS_ENTRY(struct buffer, port)),
1977 .help = "query an existing flow rule",
1978 .next = NEXT(NEXT_ENTRY(QUERY_ACTION),
1979 NEXT_ENTRY(RULE_ID),
1980 NEXT_ENTRY(PORT_ID)),
1981 .args = ARGS(ARGS_ENTRY(struct buffer, args.query.action.type),
1982 ARGS_ENTRY(struct buffer, args.query.rule),
1983 ARGS_ENTRY(struct buffer, port)),
1984 .call = parse_query,
1988 .help = "list existing flow rules",
1989 .next = NEXT(next_list_attr, NEXT_ENTRY(PORT_ID)),
1990 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1995 .help = "list and destroy aged flows",
1996 .next = NEXT(next_aged_attr, NEXT_ENTRY(PORT_ID)),
1997 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2002 .help = "restrict ingress traffic to the defined flow rules",
2003 .next = NEXT(NEXT_ENTRY(BOOLEAN),
2004 NEXT_ENTRY(PORT_ID)),
2005 .args = ARGS(ARGS_ENTRY(struct buffer, args.isolate.set),
2006 ARGS_ENTRY(struct buffer, port)),
2007 .call = parse_isolate,
2011 .help = "new tunnel API",
2012 .next = NEXT(NEXT_ENTRY
2013 (TUNNEL_CREATE, TUNNEL_LIST, TUNNEL_DESTROY)),
2014 .call = parse_tunnel,
2016 /* Tunnel arguments. */
2019 .help = "create new tunnel object",
2020 .next = NEXT(NEXT_ENTRY(TUNNEL_CREATE_TYPE),
2021 NEXT_ENTRY(PORT_ID)),
2022 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2023 .call = parse_tunnel,
2025 [TUNNEL_CREATE_TYPE] = {
2027 .help = "create new tunnel",
2028 .next = NEXT(NEXT_ENTRY(FILE_PATH)),
2029 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, type)),
2030 .call = parse_tunnel,
2032 [TUNNEL_DESTROY] = {
2034 .help = "destroy tunel",
2035 .next = NEXT(NEXT_ENTRY(TUNNEL_DESTROY_ID),
2036 NEXT_ENTRY(PORT_ID)),
2037 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2038 .call = parse_tunnel,
2040 [TUNNEL_DESTROY_ID] = {
2042 .help = "tunnel identifier to testroy",
2043 .next = NEXT(NEXT_ENTRY(UNSIGNED)),
2044 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2045 .call = parse_tunnel,
2049 .help = "list existing tunnels",
2050 .next = NEXT(NEXT_ENTRY(PORT_ID)),
2051 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2052 .call = parse_tunnel,
2054 /* Destroy arguments. */
2057 .help = "specify a rule identifier",
2058 .next = NEXT(next_destroy_attr, NEXT_ENTRY(RULE_ID)),
2059 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.destroy.rule)),
2060 .call = parse_destroy,
2062 /* Query arguments. */
2066 .help = "action to query, must be part of the rule",
2067 .call = parse_action,
2068 .comp = comp_action,
2070 /* List arguments. */
2073 .help = "specify a group",
2074 .next = NEXT(next_list_attr, NEXT_ENTRY(GROUP_ID)),
2075 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.list.group)),
2080 .help = "specify aged flows need be destroyed",
2084 /* Validate/create attributes. */
2087 .help = "specify a group",
2088 .next = NEXT(next_vc_attr, NEXT_ENTRY(GROUP_ID)),
2089 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, group)),
2094 .help = "specify a priority level",
2095 .next = NEXT(next_vc_attr, NEXT_ENTRY(PRIORITY_LEVEL)),
2096 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, priority)),
2101 .help = "affect rule to ingress",
2102 .next = NEXT(next_vc_attr),
2107 .help = "affect rule to egress",
2108 .next = NEXT(next_vc_attr),
2113 .help = "apply rule directly to endpoints found in pattern",
2114 .next = NEXT(next_vc_attr),
2118 .name = "tunnel_set",
2119 .help = "tunnel steer rule",
2120 .next = NEXT(next_vc_attr, NEXT_ENTRY(UNSIGNED)),
2121 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2125 .name = "tunnel_match",
2126 .help = "tunnel match rule",
2127 .next = NEXT(next_vc_attr, NEXT_ENTRY(UNSIGNED)),
2128 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2131 /* Validate/create pattern. */
2134 .help = "submit a list of pattern items",
2135 .next = NEXT(next_item),
2140 .help = "match value perfectly (with full bit-mask)",
2141 .call = parse_vc_spec,
2143 [ITEM_PARAM_SPEC] = {
2145 .help = "match value according to configured bit-mask",
2146 .call = parse_vc_spec,
2148 [ITEM_PARAM_LAST] = {
2150 .help = "specify upper bound to establish a range",
2151 .call = parse_vc_spec,
2153 [ITEM_PARAM_MASK] = {
2155 .help = "specify bit-mask with relevant bits set to one",
2156 .call = parse_vc_spec,
2158 [ITEM_PARAM_PREFIX] = {
2160 .help = "generate bit-mask from a prefix length",
2161 .call = parse_vc_spec,
2165 .help = "specify next pattern item",
2166 .next = NEXT(next_item),
2170 .help = "end list of pattern items",
2171 .priv = PRIV_ITEM(END, 0),
2172 .next = NEXT(NEXT_ENTRY(ACTIONS)),
2177 .help = "no-op pattern item",
2178 .priv = PRIV_ITEM(VOID, 0),
2179 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2184 .help = "perform actions when pattern does not match",
2185 .priv = PRIV_ITEM(INVERT, 0),
2186 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2191 .help = "match any protocol for the current layer",
2192 .priv = PRIV_ITEM(ANY, sizeof(struct rte_flow_item_any)),
2193 .next = NEXT(item_any),
2198 .help = "number of layers covered",
2199 .next = NEXT(item_any, NEXT_ENTRY(UNSIGNED), item_param),
2200 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_any, num)),
2204 .help = "match traffic from/to the physical function",
2205 .priv = PRIV_ITEM(PF, 0),
2206 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2211 .help = "match traffic from/to a virtual function ID",
2212 .priv = PRIV_ITEM(VF, sizeof(struct rte_flow_item_vf)),
2213 .next = NEXT(item_vf),
2219 .next = NEXT(item_vf, NEXT_ENTRY(UNSIGNED), item_param),
2220 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_vf, id)),
2224 .help = "match traffic from/to a specific physical port",
2225 .priv = PRIV_ITEM(PHY_PORT,
2226 sizeof(struct rte_flow_item_phy_port)),
2227 .next = NEXT(item_phy_port),
2230 [ITEM_PHY_PORT_INDEX] = {
2232 .help = "physical port index",
2233 .next = NEXT(item_phy_port, NEXT_ENTRY(UNSIGNED), item_param),
2234 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_phy_port, index)),
2238 .help = "match traffic from/to a given DPDK port ID",
2239 .priv = PRIV_ITEM(PORT_ID,
2240 sizeof(struct rte_flow_item_port_id)),
2241 .next = NEXT(item_port_id),
2244 [ITEM_PORT_ID_ID] = {
2246 .help = "DPDK port ID",
2247 .next = NEXT(item_port_id, NEXT_ENTRY(UNSIGNED), item_param),
2248 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port_id, id)),
2252 .help = "match traffic against value set in previously matched rule",
2253 .priv = PRIV_ITEM(MARK, sizeof(struct rte_flow_item_mark)),
2254 .next = NEXT(item_mark),
2259 .help = "Integer value to match against",
2260 .next = NEXT(item_mark, NEXT_ENTRY(UNSIGNED), item_param),
2261 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_mark, id)),
2265 .help = "match an arbitrary byte string",
2266 .priv = PRIV_ITEM(RAW, ITEM_RAW_SIZE),
2267 .next = NEXT(item_raw),
2270 [ITEM_RAW_RELATIVE] = {
2272 .help = "look for pattern after the previous item",
2273 .next = NEXT(item_raw, NEXT_ENTRY(BOOLEAN), item_param),
2274 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
2277 [ITEM_RAW_SEARCH] = {
2279 .help = "search pattern from offset (see also limit)",
2280 .next = NEXT(item_raw, NEXT_ENTRY(BOOLEAN), item_param),
2281 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
2284 [ITEM_RAW_OFFSET] = {
2286 .help = "absolute or relative offset for pattern",
2287 .next = NEXT(item_raw, NEXT_ENTRY(INTEGER), item_param),
2288 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, offset)),
2290 [ITEM_RAW_LIMIT] = {
2292 .help = "search area limit for start of pattern",
2293 .next = NEXT(item_raw, NEXT_ENTRY(UNSIGNED), item_param),
2294 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, limit)),
2296 [ITEM_RAW_PATTERN] = {
2298 .help = "byte string to look for",
2299 .next = NEXT(item_raw,
2301 NEXT_ENTRY(ITEM_PARAM_IS,
2304 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern),
2305 ARGS_ENTRY(struct rte_flow_item_raw, length),
2306 ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw),
2307 ITEM_RAW_PATTERN_SIZE)),
2311 .help = "match Ethernet header",
2312 .priv = PRIV_ITEM(ETH, sizeof(struct rte_flow_item_eth)),
2313 .next = NEXT(item_eth),
2318 .help = "destination MAC",
2319 .next = NEXT(item_eth, NEXT_ENTRY(MAC_ADDR), item_param),
2320 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, dst)),
2324 .help = "source MAC",
2325 .next = NEXT(item_eth, NEXT_ENTRY(MAC_ADDR), item_param),
2326 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, src)),
2330 .help = "EtherType",
2331 .next = NEXT(item_eth, NEXT_ENTRY(UNSIGNED), item_param),
2332 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, type)),
2334 [ITEM_ETH_HAS_VLAN] = {
2336 .help = "packet header contains VLAN",
2337 .next = NEXT(item_eth, NEXT_ENTRY(UNSIGNED), item_param),
2338 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_eth,
2343 .help = "match 802.1Q/ad VLAN tag",
2344 .priv = PRIV_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)),
2345 .next = NEXT(item_vlan),
2350 .help = "tag control information",
2351 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2352 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, tci)),
2356 .help = "priority code point",
2357 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2358 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2363 .help = "drop eligible indicator",
2364 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2365 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2370 .help = "VLAN identifier",
2371 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2372 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2375 [ITEM_VLAN_INNER_TYPE] = {
2376 .name = "inner_type",
2377 .help = "inner EtherType",
2378 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2379 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan,
2382 [ITEM_VLAN_HAS_MORE_VLAN] = {
2383 .name = "has_more_vlan",
2384 .help = "packet header contains another VLAN",
2385 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2386 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vlan,
2391 .help = "match IPv4 header",
2392 .priv = PRIV_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)),
2393 .next = NEXT(item_ipv4),
2398 .help = "type of service",
2399 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2400 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2401 hdr.type_of_service)),
2403 [ITEM_IPV4_FRAGMENT_OFFSET] = {
2404 .name = "fragment_offset",
2405 .help = "fragmentation flags and fragment offset",
2406 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2407 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2408 hdr.fragment_offset)),
2412 .help = "time to live",
2413 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2414 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2417 [ITEM_IPV4_PROTO] = {
2419 .help = "next protocol ID",
2420 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2421 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2422 hdr.next_proto_id)),
2426 .help = "source address",
2427 .next = NEXT(item_ipv4, NEXT_ENTRY(IPV4_ADDR), item_param),
2428 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2433 .help = "destination address",
2434 .next = NEXT(item_ipv4, NEXT_ENTRY(IPV4_ADDR), item_param),
2435 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2440 .help = "match IPv6 header",
2441 .priv = PRIV_ITEM(IPV6, sizeof(struct rte_flow_item_ipv6)),
2442 .next = NEXT(item_ipv6),
2447 .help = "traffic class",
2448 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2449 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2451 "\x0f\xf0\x00\x00")),
2453 [ITEM_IPV6_FLOW] = {
2455 .help = "flow label",
2456 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2457 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2459 "\x00\x0f\xff\xff")),
2461 [ITEM_IPV6_PROTO] = {
2463 .help = "protocol (next header)",
2464 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2465 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2470 .help = "hop limit",
2471 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2472 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2477 .help = "source address",
2478 .next = NEXT(item_ipv6, NEXT_ENTRY(IPV6_ADDR), item_param),
2479 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2484 .help = "destination address",
2485 .next = NEXT(item_ipv6, NEXT_ENTRY(IPV6_ADDR), item_param),
2486 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2489 [ITEM_IPV6_HAS_FRAG_EXT] = {
2490 .name = "has_frag_ext",
2491 .help = "fragment packet attribute",
2492 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2493 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_ipv6,
2498 .help = "match ICMP header",
2499 .priv = PRIV_ITEM(ICMP, sizeof(struct rte_flow_item_icmp)),
2500 .next = NEXT(item_icmp),
2503 [ITEM_ICMP_TYPE] = {
2505 .help = "ICMP packet type",
2506 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2507 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2510 [ITEM_ICMP_CODE] = {
2512 .help = "ICMP packet code",
2513 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2514 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2517 [ITEM_ICMP_IDENT] = {
2519 .help = "ICMP packet identifier",
2520 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2521 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2526 .help = "ICMP packet sequence number",
2527 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2528 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2533 .help = "match UDP header",
2534 .priv = PRIV_ITEM(UDP, sizeof(struct rte_flow_item_udp)),
2535 .next = NEXT(item_udp),
2540 .help = "UDP source port",
2541 .next = NEXT(item_udp, NEXT_ENTRY(UNSIGNED), item_param),
2542 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2547 .help = "UDP destination port",
2548 .next = NEXT(item_udp, NEXT_ENTRY(UNSIGNED), item_param),
2549 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2554 .help = "match TCP header",
2555 .priv = PRIV_ITEM(TCP, sizeof(struct rte_flow_item_tcp)),
2556 .next = NEXT(item_tcp),
2561 .help = "TCP source port",
2562 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2563 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2568 .help = "TCP destination port",
2569 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2570 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2573 [ITEM_TCP_FLAGS] = {
2575 .help = "TCP flags",
2576 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2577 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2582 .help = "match SCTP header",
2583 .priv = PRIV_ITEM(SCTP, sizeof(struct rte_flow_item_sctp)),
2584 .next = NEXT(item_sctp),
2589 .help = "SCTP source port",
2590 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2591 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2596 .help = "SCTP destination port",
2597 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2598 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2603 .help = "validation tag",
2604 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2605 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2608 [ITEM_SCTP_CKSUM] = {
2611 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2612 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2617 .help = "match VXLAN header",
2618 .priv = PRIV_ITEM(VXLAN, sizeof(struct rte_flow_item_vxlan)),
2619 .next = NEXT(item_vxlan),
2622 [ITEM_VXLAN_VNI] = {
2624 .help = "VXLAN identifier",
2625 .next = NEXT(item_vxlan, NEXT_ENTRY(UNSIGNED), item_param),
2626 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan, vni)),
2630 .help = "match E-Tag header",
2631 .priv = PRIV_ITEM(E_TAG, sizeof(struct rte_flow_item_e_tag)),
2632 .next = NEXT(item_e_tag),
2635 [ITEM_E_TAG_GRP_ECID_B] = {
2636 .name = "grp_ecid_b",
2637 .help = "GRP and E-CID base",
2638 .next = NEXT(item_e_tag, NEXT_ENTRY(UNSIGNED), item_param),
2639 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_e_tag,
2645 .help = "match NVGRE header",
2646 .priv = PRIV_ITEM(NVGRE, sizeof(struct rte_flow_item_nvgre)),
2647 .next = NEXT(item_nvgre),
2650 [ITEM_NVGRE_TNI] = {
2652 .help = "virtual subnet ID",
2653 .next = NEXT(item_nvgre, NEXT_ENTRY(UNSIGNED), item_param),
2654 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_nvgre, tni)),
2658 .help = "match MPLS header",
2659 .priv = PRIV_ITEM(MPLS, sizeof(struct rte_flow_item_mpls)),
2660 .next = NEXT(item_mpls),
2663 [ITEM_MPLS_LABEL] = {
2665 .help = "MPLS label",
2666 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2667 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2673 .help = "MPLS Traffic Class",
2674 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2675 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2681 .help = "MPLS Bottom-of-Stack",
2682 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2683 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2689 .help = "match GRE header",
2690 .priv = PRIV_ITEM(GRE, sizeof(struct rte_flow_item_gre)),
2691 .next = NEXT(item_gre),
2694 [ITEM_GRE_PROTO] = {
2696 .help = "GRE protocol type",
2697 .next = NEXT(item_gre, NEXT_ENTRY(UNSIGNED), item_param),
2698 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2701 [ITEM_GRE_C_RSVD0_VER] = {
2702 .name = "c_rsvd0_ver",
2704 "checksum (1b), undefined (1b), key bit (1b),"
2705 " sequence number (1b), reserved 0 (9b),"
2707 .next = NEXT(item_gre, NEXT_ENTRY(UNSIGNED), item_param),
2708 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2711 [ITEM_GRE_C_BIT] = {
2713 .help = "checksum bit (C)",
2714 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2715 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2717 "\x80\x00\x00\x00")),
2719 [ITEM_GRE_S_BIT] = {
2721 .help = "sequence number bit (S)",
2722 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2723 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2725 "\x10\x00\x00\x00")),
2727 [ITEM_GRE_K_BIT] = {
2729 .help = "key bit (K)",
2730 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2731 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2733 "\x20\x00\x00\x00")),
2737 .help = "fuzzy pattern match, expect faster than default",
2738 .priv = PRIV_ITEM(FUZZY,
2739 sizeof(struct rte_flow_item_fuzzy)),
2740 .next = NEXT(item_fuzzy),
2743 [ITEM_FUZZY_THRESH] = {
2745 .help = "match accuracy threshold",
2746 .next = NEXT(item_fuzzy, NEXT_ENTRY(UNSIGNED), item_param),
2747 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_fuzzy,
2752 .help = "match GTP header",
2753 .priv = PRIV_ITEM(GTP, sizeof(struct rte_flow_item_gtp)),
2754 .next = NEXT(item_gtp),
2757 [ITEM_GTP_FLAGS] = {
2758 .name = "v_pt_rsv_flags",
2759 .help = "GTP flags",
2760 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2761 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp,
2764 [ITEM_GTP_MSG_TYPE] = {
2766 .help = "GTP message type",
2767 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2768 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp, msg_type)),
2772 .help = "tunnel endpoint identifier",
2773 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2774 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp, teid)),
2778 .help = "match GTP header",
2779 .priv = PRIV_ITEM(GTPC, sizeof(struct rte_flow_item_gtp)),
2780 .next = NEXT(item_gtp),
2785 .help = "match GTP header",
2786 .priv = PRIV_ITEM(GTPU, sizeof(struct rte_flow_item_gtp)),
2787 .next = NEXT(item_gtp),
2792 .help = "match GENEVE header",
2793 .priv = PRIV_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)),
2794 .next = NEXT(item_geneve),
2797 [ITEM_GENEVE_VNI] = {
2799 .help = "virtual network identifier",
2800 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2801 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve, vni)),
2803 [ITEM_GENEVE_PROTO] = {
2805 .help = "GENEVE protocol type",
2806 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2807 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve,
2810 [ITEM_VXLAN_GPE] = {
2811 .name = "vxlan-gpe",
2812 .help = "match VXLAN-GPE header",
2813 .priv = PRIV_ITEM(VXLAN_GPE,
2814 sizeof(struct rte_flow_item_vxlan_gpe)),
2815 .next = NEXT(item_vxlan_gpe),
2818 [ITEM_VXLAN_GPE_VNI] = {
2820 .help = "VXLAN-GPE identifier",
2821 .next = NEXT(item_vxlan_gpe, NEXT_ENTRY(UNSIGNED), item_param),
2822 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
2825 [ITEM_ARP_ETH_IPV4] = {
2826 .name = "arp_eth_ipv4",
2827 .help = "match ARP header for Ethernet/IPv4",
2828 .priv = PRIV_ITEM(ARP_ETH_IPV4,
2829 sizeof(struct rte_flow_item_arp_eth_ipv4)),
2830 .next = NEXT(item_arp_eth_ipv4),
2833 [ITEM_ARP_ETH_IPV4_SHA] = {
2835 .help = "sender hardware address",
2836 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(MAC_ADDR),
2838 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2841 [ITEM_ARP_ETH_IPV4_SPA] = {
2843 .help = "sender IPv4 address",
2844 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(IPV4_ADDR),
2846 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2849 [ITEM_ARP_ETH_IPV4_THA] = {
2851 .help = "target hardware address",
2852 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(MAC_ADDR),
2854 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2857 [ITEM_ARP_ETH_IPV4_TPA] = {
2859 .help = "target IPv4 address",
2860 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(IPV4_ADDR),
2862 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2867 .help = "match presence of any IPv6 extension header",
2868 .priv = PRIV_ITEM(IPV6_EXT,
2869 sizeof(struct rte_flow_item_ipv6_ext)),
2870 .next = NEXT(item_ipv6_ext),
2873 [ITEM_IPV6_EXT_NEXT_HDR] = {
2875 .help = "next header",
2876 .next = NEXT(item_ipv6_ext, NEXT_ENTRY(UNSIGNED), item_param),
2877 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_ext,
2880 [ITEM_IPV6_FRAG_EXT] = {
2881 .name = "ipv6_frag_ext",
2882 .help = "match presence of IPv6 fragment extension header",
2883 .priv = PRIV_ITEM(IPV6_FRAG_EXT,
2884 sizeof(struct rte_flow_item_ipv6_frag_ext)),
2885 .next = NEXT(item_ipv6_frag_ext),
2888 [ITEM_IPV6_FRAG_EXT_NEXT_HDR] = {
2890 .help = "next header",
2891 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(UNSIGNED),
2893 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ipv6_frag_ext,
2896 [ITEM_IPV6_FRAG_EXT_FRAG_DATA] = {
2897 .name = "frag_data",
2898 .help = "Fragment flags and offset",
2899 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(UNSIGNED),
2901 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_frag_ext,
2906 .help = "match any ICMPv6 header",
2907 .priv = PRIV_ITEM(ICMP6, sizeof(struct rte_flow_item_icmp6)),
2908 .next = NEXT(item_icmp6),
2911 [ITEM_ICMP6_TYPE] = {
2913 .help = "ICMPv6 type",
2914 .next = NEXT(item_icmp6, NEXT_ENTRY(UNSIGNED), item_param),
2915 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
2918 [ITEM_ICMP6_CODE] = {
2920 .help = "ICMPv6 code",
2921 .next = NEXT(item_icmp6, NEXT_ENTRY(UNSIGNED), item_param),
2922 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
2925 [ITEM_ICMP6_ND_NS] = {
2926 .name = "icmp6_nd_ns",
2927 .help = "match ICMPv6 neighbor discovery solicitation",
2928 .priv = PRIV_ITEM(ICMP6_ND_NS,
2929 sizeof(struct rte_flow_item_icmp6_nd_ns)),
2930 .next = NEXT(item_icmp6_nd_ns),
2933 [ITEM_ICMP6_ND_NS_TARGET_ADDR] = {
2934 .name = "target_addr",
2935 .help = "target address",
2936 .next = NEXT(item_icmp6_nd_ns, NEXT_ENTRY(IPV6_ADDR),
2938 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_ns,
2941 [ITEM_ICMP6_ND_NA] = {
2942 .name = "icmp6_nd_na",
2943 .help = "match ICMPv6 neighbor discovery advertisement",
2944 .priv = PRIV_ITEM(ICMP6_ND_NA,
2945 sizeof(struct rte_flow_item_icmp6_nd_na)),
2946 .next = NEXT(item_icmp6_nd_na),
2949 [ITEM_ICMP6_ND_NA_TARGET_ADDR] = {
2950 .name = "target_addr",
2951 .help = "target address",
2952 .next = NEXT(item_icmp6_nd_na, NEXT_ENTRY(IPV6_ADDR),
2954 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_na,
2957 [ITEM_ICMP6_ND_OPT] = {
2958 .name = "icmp6_nd_opt",
2959 .help = "match presence of any ICMPv6 neighbor discovery"
2961 .priv = PRIV_ITEM(ICMP6_ND_OPT,
2962 sizeof(struct rte_flow_item_icmp6_nd_opt)),
2963 .next = NEXT(item_icmp6_nd_opt),
2966 [ITEM_ICMP6_ND_OPT_TYPE] = {
2968 .help = "ND option type",
2969 .next = NEXT(item_icmp6_nd_opt, NEXT_ENTRY(UNSIGNED),
2971 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_opt,
2974 [ITEM_ICMP6_ND_OPT_SLA_ETH] = {
2975 .name = "icmp6_nd_opt_sla_eth",
2976 .help = "match ICMPv6 neighbor discovery source Ethernet"
2977 " link-layer address option",
2979 (ICMP6_ND_OPT_SLA_ETH,
2980 sizeof(struct rte_flow_item_icmp6_nd_opt_sla_eth)),
2981 .next = NEXT(item_icmp6_nd_opt_sla_eth),
2984 [ITEM_ICMP6_ND_OPT_SLA_ETH_SLA] = {
2986 .help = "source Ethernet LLA",
2987 .next = NEXT(item_icmp6_nd_opt_sla_eth, NEXT_ENTRY(MAC_ADDR),
2989 .args = ARGS(ARGS_ENTRY_HTON
2990 (struct rte_flow_item_icmp6_nd_opt_sla_eth, sla)),
2992 [ITEM_ICMP6_ND_OPT_TLA_ETH] = {
2993 .name = "icmp6_nd_opt_tla_eth",
2994 .help = "match ICMPv6 neighbor discovery target Ethernet"
2995 " link-layer address option",
2997 (ICMP6_ND_OPT_TLA_ETH,
2998 sizeof(struct rte_flow_item_icmp6_nd_opt_tla_eth)),
2999 .next = NEXT(item_icmp6_nd_opt_tla_eth),
3002 [ITEM_ICMP6_ND_OPT_TLA_ETH_TLA] = {
3004 .help = "target Ethernet LLA",
3005 .next = NEXT(item_icmp6_nd_opt_tla_eth, NEXT_ENTRY(MAC_ADDR),
3007 .args = ARGS(ARGS_ENTRY_HTON
3008 (struct rte_flow_item_icmp6_nd_opt_tla_eth, tla)),
3012 .help = "match metadata header",
3013 .priv = PRIV_ITEM(META, sizeof(struct rte_flow_item_meta)),
3014 .next = NEXT(item_meta),
3017 [ITEM_META_DATA] = {
3019 .help = "metadata value",
3020 .next = NEXT(item_meta, NEXT_ENTRY(UNSIGNED), item_param),
3021 .args = ARGS(ARGS_ENTRY_MASK(struct rte_flow_item_meta,
3022 data, "\xff\xff\xff\xff")),
3026 .help = "match GRE key",
3027 .priv = PRIV_ITEM(GRE_KEY, sizeof(rte_be32_t)),
3028 .next = NEXT(item_gre_key),
3031 [ITEM_GRE_KEY_VALUE] = {
3033 .help = "key value",
3034 .next = NEXT(item_gre_key, NEXT_ENTRY(UNSIGNED), item_param),
3035 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3039 .help = "match GTP extension header with type 0x85",
3040 .priv = PRIV_ITEM(GTP_PSC,
3041 sizeof(struct rte_flow_item_gtp_psc)),
3042 .next = NEXT(item_gtp_psc),
3045 [ITEM_GTP_PSC_QFI] = {
3047 .help = "QoS flow identifier",
3048 .next = NEXT(item_gtp_psc, NEXT_ENTRY(UNSIGNED), item_param),
3049 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
3052 [ITEM_GTP_PSC_PDU_T] = {
3055 .next = NEXT(item_gtp_psc, NEXT_ENTRY(UNSIGNED), item_param),
3056 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
3061 .help = "match PPPoE session header",
3062 .priv = PRIV_ITEM(PPPOES, sizeof(struct rte_flow_item_pppoe)),
3063 .next = NEXT(item_pppoes),
3068 .help = "match PPPoE discovery header",
3069 .priv = PRIV_ITEM(PPPOED, sizeof(struct rte_flow_item_pppoe)),
3070 .next = NEXT(item_pppoed),
3073 [ITEM_PPPOE_SEID] = {
3075 .help = "session identifier",
3076 .next = NEXT(item_pppoes, NEXT_ENTRY(UNSIGNED), item_param),
3077 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pppoe,
3080 [ITEM_PPPOE_PROTO_ID] = {
3081 .name = "pppoe_proto_id",
3082 .help = "match PPPoE session protocol identifier",
3083 .priv = PRIV_ITEM(PPPOE_PROTO_ID,
3084 sizeof(struct rte_flow_item_pppoe_proto_id)),
3085 .next = NEXT(item_pppoe_proto_id, NEXT_ENTRY(UNSIGNED),
3087 .args = ARGS(ARGS_ENTRY_HTON
3088 (struct rte_flow_item_pppoe_proto_id, proto_id)),
3093 .help = "matches higig2 header",
3094 .priv = PRIV_ITEM(HIGIG2,
3095 sizeof(struct rte_flow_item_higig2_hdr)),
3096 .next = NEXT(item_higig2),
3099 [ITEM_HIGIG2_CLASSIFICATION] = {
3100 .name = "classification",
3101 .help = "matches classification of higig2 header",
3102 .next = NEXT(item_higig2, NEXT_ENTRY(UNSIGNED), item_param),
3103 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
3104 hdr.ppt1.classification)),
3106 [ITEM_HIGIG2_VID] = {
3108 .help = "matches vid of higig2 header",
3109 .next = NEXT(item_higig2, NEXT_ENTRY(UNSIGNED), item_param),
3110 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
3115 .help = "match tag value",
3116 .priv = PRIV_ITEM(TAG, sizeof(struct rte_flow_item_tag)),
3117 .next = NEXT(item_tag),
3122 .help = "tag value to match",
3123 .next = NEXT(item_tag, NEXT_ENTRY(UNSIGNED), item_param),
3124 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, data)),
3126 [ITEM_TAG_INDEX] = {
3128 .help = "index of tag array to match",
3129 .next = NEXT(item_tag, NEXT_ENTRY(UNSIGNED),
3130 NEXT_ENTRY(ITEM_PARAM_IS)),
3131 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, index)),
3133 [ITEM_L2TPV3OIP] = {
3134 .name = "l2tpv3oip",
3135 .help = "match L2TPv3 over IP header",
3136 .priv = PRIV_ITEM(L2TPV3OIP,
3137 sizeof(struct rte_flow_item_l2tpv3oip)),
3138 .next = NEXT(item_l2tpv3oip),
3141 [ITEM_L2TPV3OIP_SESSION_ID] = {
3142 .name = "session_id",
3143 .help = "session identifier",
3144 .next = NEXT(item_l2tpv3oip, NEXT_ENTRY(UNSIGNED), item_param),
3145 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv3oip,
3150 .help = "match ESP header",
3151 .priv = PRIV_ITEM(ESP, sizeof(struct rte_flow_item_esp)),
3152 .next = NEXT(item_esp),
3157 .help = "security policy index",
3158 .next = NEXT(item_esp, NEXT_ENTRY(UNSIGNED), item_param),
3159 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_esp,
3164 .help = "match AH header",
3165 .priv = PRIV_ITEM(AH, sizeof(struct rte_flow_item_ah)),
3166 .next = NEXT(item_ah),
3171 .help = "security parameters index",
3172 .next = NEXT(item_ah, NEXT_ENTRY(UNSIGNED), item_param),
3173 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ah, spi)),
3177 .help = "match pfcp header",
3178 .priv = PRIV_ITEM(PFCP, sizeof(struct rte_flow_item_pfcp)),
3179 .next = NEXT(item_pfcp),
3182 [ITEM_PFCP_S_FIELD] = {
3185 .next = NEXT(item_pfcp, NEXT_ENTRY(UNSIGNED), item_param),
3186 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp,
3189 [ITEM_PFCP_SEID] = {
3191 .help = "session endpoint identifier",
3192 .next = NEXT(item_pfcp, NEXT_ENTRY(UNSIGNED), item_param),
3193 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp, seid)),
3197 .help = "match eCPRI header",
3198 .priv = PRIV_ITEM(ECPRI, sizeof(struct rte_flow_item_ecpri)),
3199 .next = NEXT(item_ecpri),
3202 [ITEM_ECPRI_COMMON] = {
3204 .help = "eCPRI common header",
3205 .next = NEXT(item_ecpri_common),
3207 [ITEM_ECPRI_COMMON_TYPE] = {
3209 .help = "type of common header",
3210 .next = NEXT(item_ecpri_common_type),
3211 .args = ARGS(ARG_ENTRY_HTON(struct rte_flow_item_ecpri)),
3213 [ITEM_ECPRI_COMMON_TYPE_IQ_DATA] = {
3215 .help = "Type #0: IQ Data",
3216 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
3218 .call = parse_vc_item_ecpri_type,
3220 [ITEM_ECPRI_MSG_IQ_DATA_PCID] = {
3222 .help = "Physical Channel ID",
3223 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
3224 ITEM_ECPRI_COMMON, ITEM_NEXT),
3225 NEXT_ENTRY(UNSIGNED), item_param),
3226 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3229 [ITEM_ECPRI_COMMON_TYPE_RTC_CTRL] = {
3231 .help = "Type #2: Real-Time Control Data",
3232 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
3234 .call = parse_vc_item_ecpri_type,
3236 [ITEM_ECPRI_MSG_RTC_CTRL_RTCID] = {
3238 .help = "Real-Time Control Data ID",
3239 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
3240 ITEM_ECPRI_COMMON, ITEM_NEXT),
3241 NEXT_ENTRY(UNSIGNED), item_param),
3242 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3245 [ITEM_ECPRI_COMMON_TYPE_DLY_MSR] = {
3246 .name = "delay_measure",
3247 .help = "Type #5: One-Way Delay Measurement",
3248 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
3250 .call = parse_vc_item_ecpri_type,
3252 [ITEM_ECPRI_MSG_DLY_MSR_MSRID] = {
3254 .help = "Measurement ID",
3255 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
3256 ITEM_ECPRI_COMMON, ITEM_NEXT),
3257 NEXT_ENTRY(UNSIGNED), item_param),
3258 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3261 [ITEM_GENEVE_OPT] = {
3262 .name = "geneve-opt",
3263 .help = "GENEVE header option",
3264 .priv = PRIV_ITEM(GENEVE_OPT,
3265 sizeof(struct rte_flow_item_geneve_opt) +
3266 ITEM_GENEVE_OPT_DATA_SIZE),
3267 .next = NEXT(item_geneve_opt),
3270 [ITEM_GENEVE_OPT_CLASS] = {
3272 .help = "GENEVE option class",
3273 .next = NEXT(item_geneve_opt, NEXT_ENTRY(UNSIGNED), item_param),
3274 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve_opt,
3277 [ITEM_GENEVE_OPT_TYPE] = {
3279 .help = "GENEVE option type",
3280 .next = NEXT(item_geneve_opt, NEXT_ENTRY(UNSIGNED), item_param),
3281 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt,
3284 [ITEM_GENEVE_OPT_LENGTH] = {
3286 .help = "GENEVE option data length (in 32b words)",
3287 .next = NEXT(item_geneve_opt, NEXT_ENTRY(UNSIGNED), item_param),
3288 .args = ARGS(ARGS_ENTRY_BOUNDED(
3289 struct rte_flow_item_geneve_opt, option_len,
3292 [ITEM_GENEVE_OPT_DATA] = {
3294 .help = "GENEVE option data pattern",
3295 .next = NEXT(item_geneve_opt, NEXT_ENTRY(HEX), item_param),
3296 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt, data),
3297 ARGS_ENTRY_ARB(0, 0),
3299 (sizeof(struct rte_flow_item_geneve_opt),
3300 ITEM_GENEVE_OPT_DATA_SIZE)),
3302 /* Validate/create actions. */
3305 .help = "submit a list of associated actions",
3306 .next = NEXT(next_action),
3311 .help = "specify next action",
3312 .next = NEXT(next_action),
3316 .help = "end list of actions",
3317 .priv = PRIV_ACTION(END, 0),
3322 .help = "no-op action",
3323 .priv = PRIV_ACTION(VOID, 0),
3324 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3327 [ACTION_PASSTHRU] = {
3329 .help = "let subsequent rule process matched packets",
3330 .priv = PRIV_ACTION(PASSTHRU, 0),
3331 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3336 .help = "redirect traffic to a given group",
3337 .priv = PRIV_ACTION(JUMP, sizeof(struct rte_flow_action_jump)),
3338 .next = NEXT(action_jump),
3341 [ACTION_JUMP_GROUP] = {
3343 .help = "group to redirect traffic to",
3344 .next = NEXT(action_jump, NEXT_ENTRY(UNSIGNED)),
3345 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump, group)),
3346 .call = parse_vc_conf,
3350 .help = "attach 32 bit value to packets",
3351 .priv = PRIV_ACTION(MARK, sizeof(struct rte_flow_action_mark)),
3352 .next = NEXT(action_mark),
3355 [ACTION_MARK_ID] = {
3357 .help = "32 bit value to return with packets",
3358 .next = NEXT(action_mark, NEXT_ENTRY(UNSIGNED)),
3359 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_mark, id)),
3360 .call = parse_vc_conf,
3364 .help = "flag packets",
3365 .priv = PRIV_ACTION(FLAG, 0),
3366 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3371 .help = "assign packets to a given queue index",
3372 .priv = PRIV_ACTION(QUEUE,
3373 sizeof(struct rte_flow_action_queue)),
3374 .next = NEXT(action_queue),
3377 [ACTION_QUEUE_INDEX] = {
3379 .help = "queue index to use",
3380 .next = NEXT(action_queue, NEXT_ENTRY(UNSIGNED)),
3381 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_queue, index)),
3382 .call = parse_vc_conf,
3386 .help = "drop packets (note: passthru has priority)",
3387 .priv = PRIV_ACTION(DROP, 0),
3388 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3393 .help = "enable counters for this rule",
3394 .priv = PRIV_ACTION(COUNT,
3395 sizeof(struct rte_flow_action_count)),
3396 .next = NEXT(action_count),
3399 [ACTION_COUNT_ID] = {
3400 .name = "identifier",
3401 .help = "counter identifier to use",
3402 .next = NEXT(action_count, NEXT_ENTRY(UNSIGNED)),
3403 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_count, id)),
3404 .call = parse_vc_conf,
3406 [ACTION_COUNT_SHARED] = {
3408 .help = "shared counter",
3409 .next = NEXT(action_count, NEXT_ENTRY(BOOLEAN)),
3410 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_count,
3412 .call = parse_vc_conf,
3416 .help = "spread packets among several queues",
3417 .priv = PRIV_ACTION(RSS, sizeof(struct action_rss_data)),
3418 .next = NEXT(action_rss),
3419 .call = parse_vc_action_rss,
3421 [ACTION_RSS_FUNC] = {
3423 .help = "RSS hash function to apply",
3424 .next = NEXT(action_rss,
3425 NEXT_ENTRY(ACTION_RSS_FUNC_DEFAULT,
3426 ACTION_RSS_FUNC_TOEPLITZ,
3427 ACTION_RSS_FUNC_SIMPLE_XOR,
3428 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ)),
3430 [ACTION_RSS_FUNC_DEFAULT] = {
3432 .help = "default hash function",
3433 .call = parse_vc_action_rss_func,
3435 [ACTION_RSS_FUNC_TOEPLITZ] = {
3437 .help = "Toeplitz hash function",
3438 .call = parse_vc_action_rss_func,
3440 [ACTION_RSS_FUNC_SIMPLE_XOR] = {
3441 .name = "simple_xor",
3442 .help = "simple XOR hash function",
3443 .call = parse_vc_action_rss_func,
3445 [ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ] = {
3446 .name = "symmetric_toeplitz",
3447 .help = "Symmetric Toeplitz hash function",
3448 .call = parse_vc_action_rss_func,
3450 [ACTION_RSS_LEVEL] = {
3452 .help = "encapsulation level for \"types\"",
3453 .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
3454 .args = ARGS(ARGS_ENTRY_ARB
3455 (offsetof(struct action_rss_data, conf) +
3456 offsetof(struct rte_flow_action_rss, level),
3457 sizeof(((struct rte_flow_action_rss *)0)->
3460 [ACTION_RSS_TYPES] = {
3462 .help = "specific RSS hash types",
3463 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)),
3465 [ACTION_RSS_TYPE] = {
3467 .help = "RSS hash type",
3468 .call = parse_vc_action_rss_type,
3469 .comp = comp_vc_action_rss_type,
3471 [ACTION_RSS_KEY] = {
3473 .help = "RSS hash key",
3474 .next = NEXT(action_rss, NEXT_ENTRY(HEX)),
3475 .args = ARGS(ARGS_ENTRY_ARB(0, 0),
3477 (offsetof(struct action_rss_data, conf) +
3478 offsetof(struct rte_flow_action_rss, key_len),
3479 sizeof(((struct rte_flow_action_rss *)0)->
3481 ARGS_ENTRY(struct action_rss_data, key)),
3483 [ACTION_RSS_KEY_LEN] = {
3485 .help = "RSS hash key length in bytes",
3486 .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
3487 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
3488 (offsetof(struct action_rss_data, conf) +
3489 offsetof(struct rte_flow_action_rss, key_len),
3490 sizeof(((struct rte_flow_action_rss *)0)->
3493 RSS_HASH_KEY_LENGTH)),
3495 [ACTION_RSS_QUEUES] = {
3497 .help = "queue indices to use",
3498 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_QUEUE)),
3499 .call = parse_vc_conf,
3501 [ACTION_RSS_QUEUE] = {
3503 .help = "queue index",
3504 .call = parse_vc_action_rss_queue,
3505 .comp = comp_vc_action_rss_queue,
3509 .help = "direct traffic to physical function",
3510 .priv = PRIV_ACTION(PF, 0),
3511 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3516 .help = "direct traffic to a virtual function ID",
3517 .priv = PRIV_ACTION(VF, sizeof(struct rte_flow_action_vf)),
3518 .next = NEXT(action_vf),
3521 [ACTION_VF_ORIGINAL] = {
3523 .help = "use original VF ID if possible",
3524 .next = NEXT(action_vf, NEXT_ENTRY(BOOLEAN)),
3525 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_vf,
3527 .call = parse_vc_conf,
3532 .next = NEXT(action_vf, NEXT_ENTRY(UNSIGNED)),
3533 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)),
3534 .call = parse_vc_conf,
3536 [ACTION_PHY_PORT] = {
3538 .help = "direct packets to physical port index",
3539 .priv = PRIV_ACTION(PHY_PORT,
3540 sizeof(struct rte_flow_action_phy_port)),
3541 .next = NEXT(action_phy_port),
3544 [ACTION_PHY_PORT_ORIGINAL] = {
3546 .help = "use original port index if possible",
3547 .next = NEXT(action_phy_port, NEXT_ENTRY(BOOLEAN)),
3548 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_phy_port,
3550 .call = parse_vc_conf,
3552 [ACTION_PHY_PORT_INDEX] = {
3554 .help = "physical port index",
3555 .next = NEXT(action_phy_port, NEXT_ENTRY(UNSIGNED)),
3556 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_phy_port,
3558 .call = parse_vc_conf,
3560 [ACTION_PORT_ID] = {
3562 .help = "direct matching traffic to a given DPDK port ID",
3563 .priv = PRIV_ACTION(PORT_ID,
3564 sizeof(struct rte_flow_action_port_id)),
3565 .next = NEXT(action_port_id),
3568 [ACTION_PORT_ID_ORIGINAL] = {
3570 .help = "use original DPDK port ID if possible",
3571 .next = NEXT(action_port_id, NEXT_ENTRY(BOOLEAN)),
3572 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_port_id,
3574 .call = parse_vc_conf,
3576 [ACTION_PORT_ID_ID] = {
3578 .help = "DPDK port ID",
3579 .next = NEXT(action_port_id, NEXT_ENTRY(UNSIGNED)),
3580 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_port_id, id)),
3581 .call = parse_vc_conf,
3585 .help = "meter the directed packets at given id",
3586 .priv = PRIV_ACTION(METER,
3587 sizeof(struct rte_flow_action_meter)),
3588 .next = NEXT(action_meter),
3591 [ACTION_METER_ID] = {
3593 .help = "meter id to use",
3594 .next = NEXT(action_meter, NEXT_ENTRY(UNSIGNED)),
3595 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter, mtr_id)),
3596 .call = parse_vc_conf,
3598 [ACTION_OF_SET_MPLS_TTL] = {
3599 .name = "of_set_mpls_ttl",
3600 .help = "OpenFlow's OFPAT_SET_MPLS_TTL",
3603 sizeof(struct rte_flow_action_of_set_mpls_ttl)),
3604 .next = NEXT(action_of_set_mpls_ttl),
3607 [ACTION_OF_SET_MPLS_TTL_MPLS_TTL] = {
3610 .next = NEXT(action_of_set_mpls_ttl, NEXT_ENTRY(UNSIGNED)),
3611 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_mpls_ttl,
3613 .call = parse_vc_conf,
3615 [ACTION_OF_DEC_MPLS_TTL] = {
3616 .name = "of_dec_mpls_ttl",
3617 .help = "OpenFlow's OFPAT_DEC_MPLS_TTL",
3618 .priv = PRIV_ACTION(OF_DEC_MPLS_TTL, 0),
3619 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3622 [ACTION_OF_SET_NW_TTL] = {
3623 .name = "of_set_nw_ttl",
3624 .help = "OpenFlow's OFPAT_SET_NW_TTL",
3627 sizeof(struct rte_flow_action_of_set_nw_ttl)),
3628 .next = NEXT(action_of_set_nw_ttl),
3631 [ACTION_OF_SET_NW_TTL_NW_TTL] = {
3634 .next = NEXT(action_of_set_nw_ttl, NEXT_ENTRY(UNSIGNED)),
3635 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_nw_ttl,
3637 .call = parse_vc_conf,
3639 [ACTION_OF_DEC_NW_TTL] = {
3640 .name = "of_dec_nw_ttl",
3641 .help = "OpenFlow's OFPAT_DEC_NW_TTL",
3642 .priv = PRIV_ACTION(OF_DEC_NW_TTL, 0),
3643 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3646 [ACTION_OF_COPY_TTL_OUT] = {
3647 .name = "of_copy_ttl_out",
3648 .help = "OpenFlow's OFPAT_COPY_TTL_OUT",
3649 .priv = PRIV_ACTION(OF_COPY_TTL_OUT, 0),
3650 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3653 [ACTION_OF_COPY_TTL_IN] = {
3654 .name = "of_copy_ttl_in",
3655 .help = "OpenFlow's OFPAT_COPY_TTL_IN",
3656 .priv = PRIV_ACTION(OF_COPY_TTL_IN, 0),
3657 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3660 [ACTION_OF_POP_VLAN] = {
3661 .name = "of_pop_vlan",
3662 .help = "OpenFlow's OFPAT_POP_VLAN",
3663 .priv = PRIV_ACTION(OF_POP_VLAN, 0),
3664 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3667 [ACTION_OF_PUSH_VLAN] = {
3668 .name = "of_push_vlan",
3669 .help = "OpenFlow's OFPAT_PUSH_VLAN",
3672 sizeof(struct rte_flow_action_of_push_vlan)),
3673 .next = NEXT(action_of_push_vlan),
3676 [ACTION_OF_PUSH_VLAN_ETHERTYPE] = {
3677 .name = "ethertype",
3678 .help = "EtherType",
3679 .next = NEXT(action_of_push_vlan, NEXT_ENTRY(UNSIGNED)),
3680 .args = ARGS(ARGS_ENTRY_HTON
3681 (struct rte_flow_action_of_push_vlan,
3683 .call = parse_vc_conf,
3685 [ACTION_OF_SET_VLAN_VID] = {
3686 .name = "of_set_vlan_vid",
3687 .help = "OpenFlow's OFPAT_SET_VLAN_VID",
3690 sizeof(struct rte_flow_action_of_set_vlan_vid)),
3691 .next = NEXT(action_of_set_vlan_vid),
3694 [ACTION_OF_SET_VLAN_VID_VLAN_VID] = {
3697 .next = NEXT(action_of_set_vlan_vid, NEXT_ENTRY(UNSIGNED)),
3698 .args = ARGS(ARGS_ENTRY_HTON
3699 (struct rte_flow_action_of_set_vlan_vid,
3701 .call = parse_vc_conf,
3703 [ACTION_OF_SET_VLAN_PCP] = {
3704 .name = "of_set_vlan_pcp",
3705 .help = "OpenFlow's OFPAT_SET_VLAN_PCP",
3708 sizeof(struct rte_flow_action_of_set_vlan_pcp)),
3709 .next = NEXT(action_of_set_vlan_pcp),
3712 [ACTION_OF_SET_VLAN_PCP_VLAN_PCP] = {
3714 .help = "VLAN priority",
3715 .next = NEXT(action_of_set_vlan_pcp, NEXT_ENTRY(UNSIGNED)),
3716 .args = ARGS(ARGS_ENTRY_HTON
3717 (struct rte_flow_action_of_set_vlan_pcp,
3719 .call = parse_vc_conf,
3721 [ACTION_OF_POP_MPLS] = {
3722 .name = "of_pop_mpls",
3723 .help = "OpenFlow's OFPAT_POP_MPLS",
3724 .priv = PRIV_ACTION(OF_POP_MPLS,
3725 sizeof(struct rte_flow_action_of_pop_mpls)),
3726 .next = NEXT(action_of_pop_mpls),
3729 [ACTION_OF_POP_MPLS_ETHERTYPE] = {
3730 .name = "ethertype",
3731 .help = "EtherType",
3732 .next = NEXT(action_of_pop_mpls, NEXT_ENTRY(UNSIGNED)),
3733 .args = ARGS(ARGS_ENTRY_HTON
3734 (struct rte_flow_action_of_pop_mpls,
3736 .call = parse_vc_conf,
3738 [ACTION_OF_PUSH_MPLS] = {
3739 .name = "of_push_mpls",
3740 .help = "OpenFlow's OFPAT_PUSH_MPLS",
3743 sizeof(struct rte_flow_action_of_push_mpls)),
3744 .next = NEXT(action_of_push_mpls),
3747 [ACTION_OF_PUSH_MPLS_ETHERTYPE] = {
3748 .name = "ethertype",
3749 .help = "EtherType",
3750 .next = NEXT(action_of_push_mpls, NEXT_ENTRY(UNSIGNED)),
3751 .args = ARGS(ARGS_ENTRY_HTON
3752 (struct rte_flow_action_of_push_mpls,
3754 .call = parse_vc_conf,
3756 [ACTION_VXLAN_ENCAP] = {
3757 .name = "vxlan_encap",
3758 .help = "VXLAN encapsulation, uses configuration set by \"set"
3760 .priv = PRIV_ACTION(VXLAN_ENCAP,
3761 sizeof(struct action_vxlan_encap_data)),
3762 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3763 .call = parse_vc_action_vxlan_encap,
3765 [ACTION_VXLAN_DECAP] = {
3766 .name = "vxlan_decap",
3767 .help = "Performs a decapsulation action by stripping all"
3768 " headers of the VXLAN tunnel network overlay from the"
3770 .priv = PRIV_ACTION(VXLAN_DECAP, 0),
3771 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3774 [ACTION_NVGRE_ENCAP] = {
3775 .name = "nvgre_encap",
3776 .help = "NVGRE encapsulation, uses configuration set by \"set"
3778 .priv = PRIV_ACTION(NVGRE_ENCAP,
3779 sizeof(struct action_nvgre_encap_data)),
3780 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3781 .call = parse_vc_action_nvgre_encap,
3783 [ACTION_NVGRE_DECAP] = {
3784 .name = "nvgre_decap",
3785 .help = "Performs a decapsulation action by stripping all"
3786 " headers of the NVGRE tunnel network overlay from the"
3788 .priv = PRIV_ACTION(NVGRE_DECAP, 0),
3789 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3792 [ACTION_L2_ENCAP] = {
3794 .help = "l2 encap, uses configuration set by"
3795 " \"set l2_encap\"",
3796 .priv = PRIV_ACTION(RAW_ENCAP,
3797 sizeof(struct action_raw_encap_data)),
3798 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3799 .call = parse_vc_action_l2_encap,
3801 [ACTION_L2_DECAP] = {
3803 .help = "l2 decap, uses configuration set by"
3804 " \"set l2_decap\"",
3805 .priv = PRIV_ACTION(RAW_DECAP,
3806 sizeof(struct action_raw_decap_data)),
3807 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3808 .call = parse_vc_action_l2_decap,
3810 [ACTION_MPLSOGRE_ENCAP] = {
3811 .name = "mplsogre_encap",
3812 .help = "mplsogre encapsulation, uses configuration set by"
3813 " \"set mplsogre_encap\"",
3814 .priv = PRIV_ACTION(RAW_ENCAP,
3815 sizeof(struct action_raw_encap_data)),
3816 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3817 .call = parse_vc_action_mplsogre_encap,
3819 [ACTION_MPLSOGRE_DECAP] = {
3820 .name = "mplsogre_decap",
3821 .help = "mplsogre decapsulation, uses configuration set by"
3822 " \"set mplsogre_decap\"",
3823 .priv = PRIV_ACTION(RAW_DECAP,
3824 sizeof(struct action_raw_decap_data)),
3825 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3826 .call = parse_vc_action_mplsogre_decap,
3828 [ACTION_MPLSOUDP_ENCAP] = {
3829 .name = "mplsoudp_encap",
3830 .help = "mplsoudp encapsulation, uses configuration set by"
3831 " \"set mplsoudp_encap\"",
3832 .priv = PRIV_ACTION(RAW_ENCAP,
3833 sizeof(struct action_raw_encap_data)),
3834 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3835 .call = parse_vc_action_mplsoudp_encap,
3837 [ACTION_MPLSOUDP_DECAP] = {
3838 .name = "mplsoudp_decap",
3839 .help = "mplsoudp decapsulation, uses configuration set by"
3840 " \"set mplsoudp_decap\"",
3841 .priv = PRIV_ACTION(RAW_DECAP,
3842 sizeof(struct action_raw_decap_data)),
3843 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3844 .call = parse_vc_action_mplsoudp_decap,
3846 [ACTION_SET_IPV4_SRC] = {
3847 .name = "set_ipv4_src",
3848 .help = "Set a new IPv4 source address in the outermost"
3850 .priv = PRIV_ACTION(SET_IPV4_SRC,
3851 sizeof(struct rte_flow_action_set_ipv4)),
3852 .next = NEXT(action_set_ipv4_src),
3855 [ACTION_SET_IPV4_SRC_IPV4_SRC] = {
3856 .name = "ipv4_addr",
3857 .help = "new IPv4 source address to set",
3858 .next = NEXT(action_set_ipv4_src, NEXT_ENTRY(IPV4_ADDR)),
3859 .args = ARGS(ARGS_ENTRY_HTON
3860 (struct rte_flow_action_set_ipv4, ipv4_addr)),
3861 .call = parse_vc_conf,
3863 [ACTION_SET_IPV4_DST] = {
3864 .name = "set_ipv4_dst",
3865 .help = "Set a new IPv4 destination address in the outermost"
3867 .priv = PRIV_ACTION(SET_IPV4_DST,
3868 sizeof(struct rte_flow_action_set_ipv4)),
3869 .next = NEXT(action_set_ipv4_dst),
3872 [ACTION_SET_IPV4_DST_IPV4_DST] = {
3873 .name = "ipv4_addr",
3874 .help = "new IPv4 destination address to set",
3875 .next = NEXT(action_set_ipv4_dst, NEXT_ENTRY(IPV4_ADDR)),
3876 .args = ARGS(ARGS_ENTRY_HTON
3877 (struct rte_flow_action_set_ipv4, ipv4_addr)),
3878 .call = parse_vc_conf,
3880 [ACTION_SET_IPV6_SRC] = {
3881 .name = "set_ipv6_src",
3882 .help = "Set a new IPv6 source address in the outermost"
3884 .priv = PRIV_ACTION(SET_IPV6_SRC,
3885 sizeof(struct rte_flow_action_set_ipv6)),
3886 .next = NEXT(action_set_ipv6_src),
3889 [ACTION_SET_IPV6_SRC_IPV6_SRC] = {
3890 .name = "ipv6_addr",
3891 .help = "new IPv6 source address to set",
3892 .next = NEXT(action_set_ipv6_src, NEXT_ENTRY(IPV6_ADDR)),
3893 .args = ARGS(ARGS_ENTRY_HTON
3894 (struct rte_flow_action_set_ipv6, ipv6_addr)),
3895 .call = parse_vc_conf,
3897 [ACTION_SET_IPV6_DST] = {
3898 .name = "set_ipv6_dst",
3899 .help = "Set a new IPv6 destination address in the outermost"
3901 .priv = PRIV_ACTION(SET_IPV6_DST,
3902 sizeof(struct rte_flow_action_set_ipv6)),
3903 .next = NEXT(action_set_ipv6_dst),
3906 [ACTION_SET_IPV6_DST_IPV6_DST] = {
3907 .name = "ipv6_addr",
3908 .help = "new IPv6 destination address to set",
3909 .next = NEXT(action_set_ipv6_dst, NEXT_ENTRY(IPV6_ADDR)),
3910 .args = ARGS(ARGS_ENTRY_HTON
3911 (struct rte_flow_action_set_ipv6, ipv6_addr)),
3912 .call = parse_vc_conf,
3914 [ACTION_SET_TP_SRC] = {
3915 .name = "set_tp_src",
3916 .help = "set a new source port number in the outermost"
3918 .priv = PRIV_ACTION(SET_TP_SRC,
3919 sizeof(struct rte_flow_action_set_tp)),
3920 .next = NEXT(action_set_tp_src),
3923 [ACTION_SET_TP_SRC_TP_SRC] = {
3925 .help = "new source port number to set",
3926 .next = NEXT(action_set_tp_src, NEXT_ENTRY(UNSIGNED)),
3927 .args = ARGS(ARGS_ENTRY_HTON
3928 (struct rte_flow_action_set_tp, port)),
3929 .call = parse_vc_conf,
3931 [ACTION_SET_TP_DST] = {
3932 .name = "set_tp_dst",
3933 .help = "set a new destination port number in the outermost"
3935 .priv = PRIV_ACTION(SET_TP_DST,
3936 sizeof(struct rte_flow_action_set_tp)),
3937 .next = NEXT(action_set_tp_dst),
3940 [ACTION_SET_TP_DST_TP_DST] = {
3942 .help = "new destination port number to set",
3943 .next = NEXT(action_set_tp_dst, NEXT_ENTRY(UNSIGNED)),
3944 .args = ARGS(ARGS_ENTRY_HTON
3945 (struct rte_flow_action_set_tp, port)),
3946 .call = parse_vc_conf,
3948 [ACTION_MAC_SWAP] = {
3950 .help = "Swap the source and destination MAC addresses"
3951 " in the outermost Ethernet header",
3952 .priv = PRIV_ACTION(MAC_SWAP, 0),
3953 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3956 [ACTION_DEC_TTL] = {
3958 .help = "decrease network TTL if available",
3959 .priv = PRIV_ACTION(DEC_TTL, 0),
3960 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3963 [ACTION_SET_TTL] = {
3965 .help = "set ttl value",
3966 .priv = PRIV_ACTION(SET_TTL,
3967 sizeof(struct rte_flow_action_set_ttl)),
3968 .next = NEXT(action_set_ttl),
3971 [ACTION_SET_TTL_TTL] = {
3972 .name = "ttl_value",
3973 .help = "new ttl value to set",
3974 .next = NEXT(action_set_ttl, NEXT_ENTRY(UNSIGNED)),
3975 .args = ARGS(ARGS_ENTRY_HTON
3976 (struct rte_flow_action_set_ttl, ttl_value)),
3977 .call = parse_vc_conf,
3979 [ACTION_SET_MAC_SRC] = {
3980 .name = "set_mac_src",
3981 .help = "set source mac address",
3982 .priv = PRIV_ACTION(SET_MAC_SRC,
3983 sizeof(struct rte_flow_action_set_mac)),
3984 .next = NEXT(action_set_mac_src),
3987 [ACTION_SET_MAC_SRC_MAC_SRC] = {
3989 .help = "new source mac address",
3990 .next = NEXT(action_set_mac_src, NEXT_ENTRY(MAC_ADDR)),
3991 .args = ARGS(ARGS_ENTRY_HTON
3992 (struct rte_flow_action_set_mac, mac_addr)),
3993 .call = parse_vc_conf,
3995 [ACTION_SET_MAC_DST] = {
3996 .name = "set_mac_dst",
3997 .help = "set destination mac address",
3998 .priv = PRIV_ACTION(SET_MAC_DST,
3999 sizeof(struct rte_flow_action_set_mac)),
4000 .next = NEXT(action_set_mac_dst),
4003 [ACTION_SET_MAC_DST_MAC_DST] = {
4005 .help = "new destination mac address to set",
4006 .next = NEXT(action_set_mac_dst, NEXT_ENTRY(MAC_ADDR)),
4007 .args = ARGS(ARGS_ENTRY_HTON
4008 (struct rte_flow_action_set_mac, mac_addr)),
4009 .call = parse_vc_conf,
4011 [ACTION_INC_TCP_SEQ] = {
4012 .name = "inc_tcp_seq",
4013 .help = "increase TCP sequence number",
4014 .priv = PRIV_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
4015 .next = NEXT(action_inc_tcp_seq),
4018 [ACTION_INC_TCP_SEQ_VALUE] = {
4020 .help = "the value to increase TCP sequence number by",
4021 .next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(UNSIGNED)),
4022 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4023 .call = parse_vc_conf,
4025 [ACTION_DEC_TCP_SEQ] = {
4026 .name = "dec_tcp_seq",
4027 .help = "decrease TCP sequence number",
4028 .priv = PRIV_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
4029 .next = NEXT(action_dec_tcp_seq),
4032 [ACTION_DEC_TCP_SEQ_VALUE] = {
4034 .help = "the value to decrease TCP sequence number by",
4035 .next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(UNSIGNED)),
4036 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4037 .call = parse_vc_conf,
4039 [ACTION_INC_TCP_ACK] = {
4040 .name = "inc_tcp_ack",
4041 .help = "increase TCP acknowledgment number",
4042 .priv = PRIV_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
4043 .next = NEXT(action_inc_tcp_ack),
4046 [ACTION_INC_TCP_ACK_VALUE] = {
4048 .help = "the value to increase TCP acknowledgment number by",
4049 .next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(UNSIGNED)),
4050 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4051 .call = parse_vc_conf,
4053 [ACTION_DEC_TCP_ACK] = {
4054 .name = "dec_tcp_ack",
4055 .help = "decrease TCP acknowledgment number",
4056 .priv = PRIV_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
4057 .next = NEXT(action_dec_tcp_ack),
4060 [ACTION_DEC_TCP_ACK_VALUE] = {
4062 .help = "the value to decrease TCP acknowledgment number by",
4063 .next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(UNSIGNED)),
4064 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4065 .call = parse_vc_conf,
4067 [ACTION_RAW_ENCAP] = {
4068 .name = "raw_encap",
4069 .help = "encapsulation data, defined by set raw_encap",
4070 .priv = PRIV_ACTION(RAW_ENCAP,
4071 sizeof(struct action_raw_encap_data)),
4072 .next = NEXT(action_raw_encap),
4073 .call = parse_vc_action_raw_encap,
4075 [ACTION_RAW_ENCAP_INDEX] = {
4077 .help = "the index of raw_encap_confs",
4078 .next = NEXT(NEXT_ENTRY(ACTION_RAW_ENCAP_INDEX_VALUE)),
4080 [ACTION_RAW_ENCAP_INDEX_VALUE] = {
4083 .help = "unsigned integer value",
4084 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4085 .call = parse_vc_action_raw_encap_index,
4086 .comp = comp_set_raw_index,
4088 [ACTION_RAW_DECAP] = {
4089 .name = "raw_decap",
4090 .help = "decapsulation data, defined by set raw_encap",
4091 .priv = PRIV_ACTION(RAW_DECAP,
4092 sizeof(struct action_raw_decap_data)),
4093 .next = NEXT(action_raw_decap),
4094 .call = parse_vc_action_raw_decap,
4096 [ACTION_RAW_DECAP_INDEX] = {
4098 .help = "the index of raw_encap_confs",
4099 .next = NEXT(NEXT_ENTRY(ACTION_RAW_DECAP_INDEX_VALUE)),
4101 [ACTION_RAW_DECAP_INDEX_VALUE] = {
4104 .help = "unsigned integer value",
4105 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4106 .call = parse_vc_action_raw_decap_index,
4107 .comp = comp_set_raw_index,
4109 /* Top level command. */
4112 .help = "set raw encap/decap/sample data",
4113 .type = "set raw_encap|raw_decap <index> <pattern>"
4114 " or set sample_actions <index> <action>",
4115 .next = NEXT(NEXT_ENTRY
4118 SET_SAMPLE_ACTIONS)),
4119 .call = parse_set_init,
4121 /* Sub-level commands. */
4123 .name = "raw_encap",
4124 .help = "set raw encap data",
4125 .next = NEXT(next_set_raw),
4126 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4127 (offsetof(struct buffer, port),
4128 sizeof(((struct buffer *)0)->port),
4129 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
4130 .call = parse_set_raw_encap_decap,
4133 .name = "raw_decap",
4134 .help = "set raw decap data",
4135 .next = NEXT(next_set_raw),
4136 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4137 (offsetof(struct buffer, port),
4138 sizeof(((struct buffer *)0)->port),
4139 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
4140 .call = parse_set_raw_encap_decap,
4145 .help = "index of raw_encap/raw_decap data",
4146 .next = NEXT(next_item),
4149 [SET_SAMPLE_INDEX] = {
4152 .help = "index of sample actions",
4153 .next = NEXT(next_action_sample),
4156 [SET_SAMPLE_ACTIONS] = {
4157 .name = "sample_actions",
4158 .help = "set sample actions list",
4159 .next = NEXT(NEXT_ENTRY(SET_SAMPLE_INDEX)),
4160 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4161 (offsetof(struct buffer, port),
4162 sizeof(((struct buffer *)0)->port),
4163 0, RAW_SAMPLE_CONFS_MAX_NUM - 1)),
4164 .call = parse_set_sample_action,
4166 [ACTION_SET_TAG] = {
4169 .priv = PRIV_ACTION(SET_TAG,
4170 sizeof(struct rte_flow_action_set_tag)),
4171 .next = NEXT(action_set_tag),
4174 [ACTION_SET_TAG_INDEX] = {
4176 .help = "index of tag array",
4177 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
4178 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_set_tag, index)),
4179 .call = parse_vc_conf,
4181 [ACTION_SET_TAG_DATA] = {
4183 .help = "tag value",
4184 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
4185 .args = ARGS(ARGS_ENTRY
4186 (struct rte_flow_action_set_tag, data)),
4187 .call = parse_vc_conf,
4189 [ACTION_SET_TAG_MASK] = {
4191 .help = "mask for tag value",
4192 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
4193 .args = ARGS(ARGS_ENTRY
4194 (struct rte_flow_action_set_tag, mask)),
4195 .call = parse_vc_conf,
4197 [ACTION_SET_META] = {
4199 .help = "set metadata",
4200 .priv = PRIV_ACTION(SET_META,
4201 sizeof(struct rte_flow_action_set_meta)),
4202 .next = NEXT(action_set_meta),
4203 .call = parse_vc_action_set_meta,
4205 [ACTION_SET_META_DATA] = {
4207 .help = "metadata value",
4208 .next = NEXT(action_set_meta, NEXT_ENTRY(UNSIGNED)),
4209 .args = ARGS(ARGS_ENTRY
4210 (struct rte_flow_action_set_meta, data)),
4211 .call = parse_vc_conf,
4213 [ACTION_SET_META_MASK] = {
4215 .help = "mask for metadata value",
4216 .next = NEXT(action_set_meta, NEXT_ENTRY(UNSIGNED)),
4217 .args = ARGS(ARGS_ENTRY
4218 (struct rte_flow_action_set_meta, mask)),
4219 .call = parse_vc_conf,
4221 [ACTION_SET_IPV4_DSCP] = {
4222 .name = "set_ipv4_dscp",
4223 .help = "set DSCP value",
4224 .priv = PRIV_ACTION(SET_IPV4_DSCP,
4225 sizeof(struct rte_flow_action_set_dscp)),
4226 .next = NEXT(action_set_ipv4_dscp),
4229 [ACTION_SET_IPV4_DSCP_VALUE] = {
4230 .name = "dscp_value",
4231 .help = "new IPv4 DSCP value to set",
4232 .next = NEXT(action_set_ipv4_dscp, NEXT_ENTRY(UNSIGNED)),
4233 .args = ARGS(ARGS_ENTRY
4234 (struct rte_flow_action_set_dscp, dscp)),
4235 .call = parse_vc_conf,
4237 [ACTION_SET_IPV6_DSCP] = {
4238 .name = "set_ipv6_dscp",
4239 .help = "set DSCP value",
4240 .priv = PRIV_ACTION(SET_IPV6_DSCP,
4241 sizeof(struct rte_flow_action_set_dscp)),
4242 .next = NEXT(action_set_ipv6_dscp),
4245 [ACTION_SET_IPV6_DSCP_VALUE] = {
4246 .name = "dscp_value",
4247 .help = "new IPv6 DSCP value to set",
4248 .next = NEXT(action_set_ipv6_dscp, NEXT_ENTRY(UNSIGNED)),
4249 .args = ARGS(ARGS_ENTRY
4250 (struct rte_flow_action_set_dscp, dscp)),
4251 .call = parse_vc_conf,
4255 .help = "set a specific metadata header",
4256 .next = NEXT(action_age),
4257 .priv = PRIV_ACTION(AGE,
4258 sizeof(struct rte_flow_action_age)),
4261 [ACTION_AGE_TIMEOUT] = {
4263 .help = "flow age timeout value",
4264 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_age,
4266 .next = NEXT(action_age, NEXT_ENTRY(UNSIGNED)),
4267 .call = parse_vc_conf,
4271 .help = "set a sample action",
4272 .next = NEXT(action_sample),
4273 .priv = PRIV_ACTION(SAMPLE,
4274 sizeof(struct action_sample_data)),
4275 .call = parse_vc_action_sample,
4277 [ACTION_SAMPLE_RATIO] = {
4279 .help = "flow sample ratio value",
4280 .next = NEXT(action_sample, NEXT_ENTRY(UNSIGNED)),
4281 .args = ARGS(ARGS_ENTRY_ARB
4282 (offsetof(struct action_sample_data, conf) +
4283 offsetof(struct rte_flow_action_sample, ratio),
4284 sizeof(((struct rte_flow_action_sample *)0)->
4287 [ACTION_SAMPLE_INDEX] = {
4289 .help = "the index of sample actions list",
4290 .next = NEXT(NEXT_ENTRY(ACTION_SAMPLE_INDEX_VALUE)),
4292 [ACTION_SAMPLE_INDEX_VALUE] = {
4295 .help = "unsigned integer value",
4296 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4297 .call = parse_vc_action_sample_index,
4298 .comp = comp_set_sample_index,
4300 /* Shared action destroy arguments. */
4301 [SHARED_ACTION_DESTROY_ID] = {
4302 .name = "action_id",
4303 .help = "specify a shared action id to destroy",
4304 .next = NEXT(next_sa_destroy_attr,
4305 NEXT_ENTRY(SHARED_ACTION_ID)),
4306 .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
4307 args.sa_destroy.action_id)),
4308 .call = parse_sa_destroy,
4310 /* Shared action create arguments. */
4311 [SHARED_ACTION_CREATE_ID] = {
4312 .name = "action_id",
4313 .help = "specify a shared action id to create",
4314 .next = NEXT(next_sa_create_attr,
4315 NEXT_ENTRY(SHARED_ACTION_ID)),
4316 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
4320 .help = "apply shared action by id",
4321 .priv = PRIV_ACTION(SHARED, 0),
4322 .next = NEXT(NEXT_ENTRY(SHARED_ACTION_ID2PTR)),
4323 .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
4326 [SHARED_ACTION_ID2PTR] = {
4327 .name = "{action_id}",
4328 .type = "SHARED_ACTION_ID",
4329 .help = "shared action id",
4330 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4331 .call = parse_sa_id2ptr,
4334 [SHARED_ACTION_INGRESS] = {
4336 .help = "affect rule to ingress",
4337 .next = NEXT(next_sa_create_attr),
4340 [SHARED_ACTION_EGRESS] = {
4342 .help = "affect rule to egress",
4343 .next = NEXT(next_sa_create_attr),
4346 [SHARED_ACTION_TRANSFER] = {
4348 .help = "affect rule to transfer",
4349 .next = NEXT(next_sa_create_attr),
4352 [SHARED_ACTION_SPEC] = {
4354 .help = "specify action to share",
4355 .next = NEXT(next_action),
4359 /** Remove and return last entry from argument stack. */
4360 static const struct arg *
4361 pop_args(struct context *ctx)
4363 return ctx->args_num ? ctx->args[--ctx->args_num] : NULL;
4366 /** Add entry on top of the argument stack. */
4368 push_args(struct context *ctx, const struct arg *arg)
4370 if (ctx->args_num == CTX_STACK_SIZE)
4372 ctx->args[ctx->args_num++] = arg;
4376 /** Spread value into buffer according to bit-mask. */
4378 arg_entry_bf_fill(void *dst, uintmax_t val, const struct arg *arg)
4380 uint32_t i = arg->size;
4388 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
4397 unsigned int shift = 0;
4398 uint8_t *buf = (uint8_t *)dst + arg->offset + (i -= sub);
4400 for (shift = 0; arg->mask[i] >> shift; ++shift) {
4401 if (!(arg->mask[i] & (1 << shift)))
4406 *buf &= ~(1 << shift);
4407 *buf |= (val & 1) << shift;
4415 /** Compare a string with a partial one of a given length. */
4417 strcmp_partial(const char *full, const char *partial, size_t partial_len)
4419 int r = strncmp(full, partial, partial_len);
4423 if (strlen(full) <= partial_len)
4425 return full[partial_len];
4429 * Parse a prefix length and generate a bit-mask.
4431 * Last argument (ctx->args) is retrieved to determine mask size, storage
4432 * location and whether the result must use network byte ordering.
4435 parse_prefix(struct context *ctx, const struct token *token,
4436 const char *str, unsigned int len,
4437 void *buf, unsigned int size)
4439 const struct arg *arg = pop_args(ctx);
4440 static const uint8_t conv[] = "\x00\x80\xc0\xe0\xf0\xf8\xfc\xfe\xff";
4447 /* Argument is expected. */
4451 u = strtoumax(str, &end, 0);
4452 if (errno || (size_t)(end - str) != len)
4457 extra = arg_entry_bf_fill(NULL, 0, arg);
4466 if (!arg_entry_bf_fill(ctx->object, v, arg) ||
4467 !arg_entry_bf_fill(ctx->objmask, -1, arg))
4474 if (bytes > size || bytes + !!extra > size)
4478 buf = (uint8_t *)ctx->object + arg->offset;
4479 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
4481 memset((uint8_t *)buf + size - bytes, 0xff, bytes);
4482 memset(buf, 0x00, size - bytes);
4484 ((uint8_t *)buf)[size - bytes - 1] = conv[extra];
4488 memset(buf, 0xff, bytes);
4489 memset((uint8_t *)buf + bytes, 0x00, size - bytes);
4491 ((uint8_t *)buf)[bytes] = conv[extra];
4494 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
4497 push_args(ctx, arg);
4501 /** Default parsing function for token name matching. */
4503 parse_default(struct context *ctx, const struct token *token,
4504 const char *str, unsigned int len,
4505 void *buf, unsigned int size)
4510 if (strcmp_partial(token->name, str, len))
4515 /** Parse flow command, initialize output buffer for subsequent tokens. */
4517 parse_init(struct context *ctx, const struct token *token,
4518 const char *str, unsigned int len,
4519 void *buf, unsigned int size)
4521 struct buffer *out = buf;
4523 /* Token name must match. */
4524 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4526 /* Nothing else to do if there is no buffer. */
4529 /* Make sure buffer is large enough. */
4530 if (size < sizeof(*out))
4532 /* Initialize buffer. */
4533 memset(out, 0x00, sizeof(*out));
4534 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
4537 ctx->objmask = NULL;
4541 /** Parse tokens for shared action commands. */
4543 parse_sa(struct context *ctx, const struct token *token,
4544 const char *str, unsigned int len,
4545 void *buf, unsigned int size)
4547 struct buffer *out = buf;
4549 /* Token name must match. */
4550 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4552 /* Nothing else to do if there is no buffer. */
4555 if (!out->command) {
4556 if (ctx->curr != SHARED_ACTION)
4558 if (sizeof(*out) > size)
4560 out->command = ctx->curr;
4563 ctx->objmask = NULL;
4564 out->args.vc.data = (uint8_t *)out + size;
4567 switch (ctx->curr) {
4568 case SHARED_ACTION_CREATE:
4569 case SHARED_ACTION_UPDATE:
4570 out->args.vc.actions =
4571 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
4573 out->args.vc.attr.group = UINT32_MAX;
4575 case SHARED_ACTION_QUERY:
4576 out->command = ctx->curr;
4579 ctx->objmask = NULL;
4581 case SHARED_ACTION_EGRESS:
4582 out->args.vc.attr.egress = 1;
4584 case SHARED_ACTION_INGRESS:
4585 out->args.vc.attr.ingress = 1;
4587 case SHARED_ACTION_TRANSFER:
4588 out->args.vc.attr.transfer = 1;
4596 /** Parse tokens for shared action destroy command. */
4598 parse_sa_destroy(struct context *ctx, const struct token *token,
4599 const char *str, unsigned int len,
4600 void *buf, unsigned int size)
4602 struct buffer *out = buf;
4603 uint32_t *action_id;
4605 /* Token name must match. */
4606 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4608 /* Nothing else to do if there is no buffer. */
4611 if (!out->command || out->command == SHARED_ACTION) {
4612 if (ctx->curr != SHARED_ACTION_DESTROY)
4614 if (sizeof(*out) > size)
4616 out->command = ctx->curr;
4619 ctx->objmask = NULL;
4620 out->args.sa_destroy.action_id =
4621 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
4625 action_id = out->args.sa_destroy.action_id
4626 + out->args.sa_destroy.action_id_n++;
4627 if ((uint8_t *)action_id > (uint8_t *)out + size)
4630 ctx->object = action_id;
4631 ctx->objmask = NULL;
4635 /** Parse tokens for validate/create commands. */
4637 parse_vc(struct context *ctx, const struct token *token,
4638 const char *str, unsigned int len,
4639 void *buf, unsigned int size)
4641 struct buffer *out = buf;
4645 /* Token name must match. */
4646 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4648 /* Nothing else to do if there is no buffer. */
4651 if (!out->command) {
4652 if (ctx->curr != VALIDATE && ctx->curr != CREATE)
4654 if (sizeof(*out) > size)
4656 out->command = ctx->curr;
4659 ctx->objmask = NULL;
4660 out->args.vc.data = (uint8_t *)out + size;
4664 switch (ctx->curr) {
4666 ctx->object = &out->args.vc.attr;
4670 ctx->object = &out->args.vc.tunnel_ops;
4673 ctx->objmask = NULL;
4674 switch (ctx->curr) {
4679 out->args.vc.tunnel_ops.enabled = 1;
4680 out->args.vc.tunnel_ops.actions = 1;
4683 out->args.vc.tunnel_ops.enabled = 1;
4684 out->args.vc.tunnel_ops.items = 1;
4687 out->args.vc.attr.ingress = 1;
4690 out->args.vc.attr.egress = 1;
4693 out->args.vc.attr.transfer = 1;
4696 out->args.vc.pattern =
4697 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
4699 ctx->object = out->args.vc.pattern;
4700 ctx->objmask = NULL;
4703 out->args.vc.actions =
4704 (void *)RTE_ALIGN_CEIL((uintptr_t)
4705 (out->args.vc.pattern +
4706 out->args.vc.pattern_n),
4708 ctx->object = out->args.vc.actions;
4709 ctx->objmask = NULL;
4716 if (!out->args.vc.actions) {
4717 const struct parse_item_priv *priv = token->priv;
4718 struct rte_flow_item *item =
4719 out->args.vc.pattern + out->args.vc.pattern_n;
4721 data_size = priv->size * 3; /* spec, last, mask */
4722 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
4723 (out->args.vc.data - data_size),
4725 if ((uint8_t *)item + sizeof(*item) > data)
4727 *item = (struct rte_flow_item){
4730 ++out->args.vc.pattern_n;
4732 ctx->objmask = NULL;
4734 const struct parse_action_priv *priv = token->priv;
4735 struct rte_flow_action *action =
4736 out->args.vc.actions + out->args.vc.actions_n;
4738 data_size = priv->size; /* configuration */
4739 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
4740 (out->args.vc.data - data_size),
4742 if ((uint8_t *)action + sizeof(*action) > data)
4744 *action = (struct rte_flow_action){
4746 .conf = data_size ? data : NULL,
4748 ++out->args.vc.actions_n;
4749 ctx->object = action;
4750 ctx->objmask = NULL;
4752 memset(data, 0, data_size);
4753 out->args.vc.data = data;
4754 ctx->objdata = data_size;
4758 /** Parse pattern item parameter type. */
4760 parse_vc_spec(struct context *ctx, const struct token *token,
4761 const char *str, unsigned int len,
4762 void *buf, unsigned int size)
4764 struct buffer *out = buf;
4765 struct rte_flow_item *item;
4771 /* Token name must match. */
4772 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4774 /* Parse parameter types. */
4775 switch (ctx->curr) {
4776 static const enum index prefix[] = NEXT_ENTRY(PREFIX);
4782 case ITEM_PARAM_SPEC:
4785 case ITEM_PARAM_LAST:
4788 case ITEM_PARAM_PREFIX:
4789 /* Modify next token to expect a prefix. */
4790 if (ctx->next_num < 2)
4792 ctx->next[ctx->next_num - 2] = prefix;
4794 case ITEM_PARAM_MASK:
4800 /* Nothing else to do if there is no buffer. */
4803 if (!out->args.vc.pattern_n)
4805 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
4806 data_size = ctx->objdata / 3; /* spec, last, mask */
4807 /* Point to selected object. */
4808 ctx->object = out->args.vc.data + (data_size * index);
4810 ctx->objmask = out->args.vc.data + (data_size * 2); /* mask */
4811 item->mask = ctx->objmask;
4813 ctx->objmask = NULL;
4814 /* Update relevant item pointer. */
4815 *((const void **[]){ &item->spec, &item->last, &item->mask })[index] =
4820 /** Parse action configuration field. */
4822 parse_vc_conf(struct context *ctx, const struct token *token,
4823 const char *str, unsigned int len,
4824 void *buf, unsigned int size)
4826 struct buffer *out = buf;
4829 /* Token name must match. */
4830 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4832 /* Nothing else to do if there is no buffer. */
4835 /* Point to selected object. */
4836 ctx->object = out->args.vc.data;
4837 ctx->objmask = NULL;
4841 /** Parse eCPRI common header type field. */
4843 parse_vc_item_ecpri_type(struct context *ctx, const struct token *token,
4844 const char *str, unsigned int len,
4845 void *buf, unsigned int size)
4847 struct rte_flow_item_ecpri *ecpri;
4848 struct rte_flow_item_ecpri *ecpri_mask;
4849 struct rte_flow_item *item;
4852 struct buffer *out = buf;
4853 const struct arg *arg;
4856 /* Token name must match. */
4857 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4859 switch (ctx->curr) {
4860 case ITEM_ECPRI_COMMON_TYPE_IQ_DATA:
4861 msg_type = RTE_ECPRI_MSG_TYPE_IQ_DATA;
4863 case ITEM_ECPRI_COMMON_TYPE_RTC_CTRL:
4864 msg_type = RTE_ECPRI_MSG_TYPE_RTC_CTRL;
4866 case ITEM_ECPRI_COMMON_TYPE_DLY_MSR:
4867 msg_type = RTE_ECPRI_MSG_TYPE_DLY_MSR;
4874 arg = pop_args(ctx);
4877 ecpri = (struct rte_flow_item_ecpri *)out->args.vc.data;
4878 ecpri->hdr.common.type = msg_type;
4879 data_size = ctx->objdata / 3; /* spec, last, mask */
4880 ecpri_mask = (struct rte_flow_item_ecpri *)(out->args.vc.data +
4882 ecpri_mask->hdr.common.type = 0xFF;
4884 ecpri->hdr.common.u32 = rte_cpu_to_be_32(ecpri->hdr.common.u32);
4885 ecpri_mask->hdr.common.u32 =
4886 rte_cpu_to_be_32(ecpri_mask->hdr.common.u32);
4888 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
4890 item->mask = ecpri_mask;
4894 /** Parse RSS action. */
4896 parse_vc_action_rss(struct context *ctx, const struct token *token,
4897 const char *str, unsigned int len,
4898 void *buf, unsigned int size)
4900 struct buffer *out = buf;
4901 struct rte_flow_action *action;
4902 struct action_rss_data *action_rss_data;
4906 ret = parse_vc(ctx, token, str, len, buf, size);
4909 /* Nothing else to do if there is no buffer. */
4912 if (!out->args.vc.actions_n)
4914 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4915 /* Point to selected object. */
4916 ctx->object = out->args.vc.data;
4917 ctx->objmask = NULL;
4918 /* Set up default configuration. */
4919 action_rss_data = ctx->object;
4920 *action_rss_data = (struct action_rss_data){
4921 .conf = (struct rte_flow_action_rss){
4922 .func = RTE_ETH_HASH_FUNCTION_DEFAULT,
4926 .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM),
4928 .queue = action_rss_data->queue,
4932 for (i = 0; i < action_rss_data->conf.queue_num; ++i)
4933 action_rss_data->queue[i] = i;
4934 action->conf = &action_rss_data->conf;
4939 * Parse func field for RSS action.
4941 * The RTE_ETH_HASH_FUNCTION_* value to assign is derived from the
4942 * ACTION_RSS_FUNC_* index that called this function.
4945 parse_vc_action_rss_func(struct context *ctx, const struct token *token,
4946 const char *str, unsigned int len,
4947 void *buf, unsigned int size)
4949 struct action_rss_data *action_rss_data;
4950 enum rte_eth_hash_function func;
4954 /* Token name must match. */
4955 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4957 switch (ctx->curr) {
4958 case ACTION_RSS_FUNC_DEFAULT:
4959 func = RTE_ETH_HASH_FUNCTION_DEFAULT;
4961 case ACTION_RSS_FUNC_TOEPLITZ:
4962 func = RTE_ETH_HASH_FUNCTION_TOEPLITZ;
4964 case ACTION_RSS_FUNC_SIMPLE_XOR:
4965 func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
4967 case ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ:
4968 func = RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
4975 action_rss_data = ctx->object;
4976 action_rss_data->conf.func = func;
4981 * Parse type field for RSS action.
4983 * Valid tokens are type field names and the "end" token.
4986 parse_vc_action_rss_type(struct context *ctx, const struct token *token,
4987 const char *str, unsigned int len,
4988 void *buf, unsigned int size)
4990 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE);
4991 struct action_rss_data *action_rss_data;
4997 if (ctx->curr != ACTION_RSS_TYPE)
4999 if (!(ctx->objdata >> 16) && ctx->object) {
5000 action_rss_data = ctx->object;
5001 action_rss_data->conf.types = 0;
5003 if (!strcmp_partial("end", str, len)) {
5004 ctx->objdata &= 0xffff;
5007 for (i = 0; rss_type_table[i].str; ++i)
5008 if (!strcmp_partial(rss_type_table[i].str, str, len))
5010 if (!rss_type_table[i].str)
5012 ctx->objdata = 1 << 16 | (ctx->objdata & 0xffff);
5014 if (ctx->next_num == RTE_DIM(ctx->next))
5016 ctx->next[ctx->next_num++] = next;
5019 action_rss_data = ctx->object;
5020 action_rss_data->conf.types |= rss_type_table[i].rss_type;
5025 * Parse queue field for RSS action.
5027 * Valid tokens are queue indices and the "end" token.
5030 parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
5031 const char *str, unsigned int len,
5032 void *buf, unsigned int size)
5034 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE);
5035 struct action_rss_data *action_rss_data;
5036 const struct arg *arg;
5043 if (ctx->curr != ACTION_RSS_QUEUE)
5045 i = ctx->objdata >> 16;
5046 if (!strcmp_partial("end", str, len)) {
5047 ctx->objdata &= 0xffff;
5050 if (i >= ACTION_RSS_QUEUE_NUM)
5052 arg = ARGS_ENTRY_ARB(offsetof(struct action_rss_data, queue) +
5053 i * sizeof(action_rss_data->queue[i]),
5054 sizeof(action_rss_data->queue[i]));
5055 if (push_args(ctx, arg))
5057 ret = parse_int(ctx, token, str, len, NULL, 0);
5063 ctx->objdata = i << 16 | (ctx->objdata & 0xffff);
5065 if (ctx->next_num == RTE_DIM(ctx->next))
5067 ctx->next[ctx->next_num++] = next;
5071 action_rss_data = ctx->object;
5072 action_rss_data->conf.queue_num = i;
5073 action_rss_data->conf.queue = i ? action_rss_data->queue : NULL;
5077 /** Parse VXLAN encap action. */
5079 parse_vc_action_vxlan_encap(struct context *ctx, const struct token *token,
5080 const char *str, unsigned int len,
5081 void *buf, unsigned int size)
5083 struct buffer *out = buf;
5084 struct rte_flow_action *action;
5085 struct action_vxlan_encap_data *action_vxlan_encap_data;
5088 ret = parse_vc(ctx, token, str, len, buf, size);
5091 /* Nothing else to do if there is no buffer. */
5094 if (!out->args.vc.actions_n)
5096 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5097 /* Point to selected object. */
5098 ctx->object = out->args.vc.data;
5099 ctx->objmask = NULL;
5100 /* Set up default configuration. */
5101 action_vxlan_encap_data = ctx->object;
5102 *action_vxlan_encap_data = (struct action_vxlan_encap_data){
5103 .conf = (struct rte_flow_action_vxlan_encap){
5104 .definition = action_vxlan_encap_data->items,
5108 .type = RTE_FLOW_ITEM_TYPE_ETH,
5109 .spec = &action_vxlan_encap_data->item_eth,
5110 .mask = &rte_flow_item_eth_mask,
5113 .type = RTE_FLOW_ITEM_TYPE_VLAN,
5114 .spec = &action_vxlan_encap_data->item_vlan,
5115 .mask = &rte_flow_item_vlan_mask,
5118 .type = RTE_FLOW_ITEM_TYPE_IPV4,
5119 .spec = &action_vxlan_encap_data->item_ipv4,
5120 .mask = &rte_flow_item_ipv4_mask,
5123 .type = RTE_FLOW_ITEM_TYPE_UDP,
5124 .spec = &action_vxlan_encap_data->item_udp,
5125 .mask = &rte_flow_item_udp_mask,
5128 .type = RTE_FLOW_ITEM_TYPE_VXLAN,
5129 .spec = &action_vxlan_encap_data->item_vxlan,
5130 .mask = &rte_flow_item_vxlan_mask,
5133 .type = RTE_FLOW_ITEM_TYPE_END,
5138 .tci = vxlan_encap_conf.vlan_tci,
5142 .src_addr = vxlan_encap_conf.ipv4_src,
5143 .dst_addr = vxlan_encap_conf.ipv4_dst,
5146 .src_port = vxlan_encap_conf.udp_src,
5147 .dst_port = vxlan_encap_conf.udp_dst,
5149 .item_vxlan.flags = 0,
5151 memcpy(action_vxlan_encap_data->item_eth.dst.addr_bytes,
5152 vxlan_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5153 memcpy(action_vxlan_encap_data->item_eth.src.addr_bytes,
5154 vxlan_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5155 if (!vxlan_encap_conf.select_ipv4) {
5156 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.src_addr,
5157 &vxlan_encap_conf.ipv6_src,
5158 sizeof(vxlan_encap_conf.ipv6_src));
5159 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.dst_addr,
5160 &vxlan_encap_conf.ipv6_dst,
5161 sizeof(vxlan_encap_conf.ipv6_dst));
5162 action_vxlan_encap_data->items[2] = (struct rte_flow_item){
5163 .type = RTE_FLOW_ITEM_TYPE_IPV6,
5164 .spec = &action_vxlan_encap_data->item_ipv6,
5165 .mask = &rte_flow_item_ipv6_mask,
5168 if (!vxlan_encap_conf.select_vlan)
5169 action_vxlan_encap_data->items[1].type =
5170 RTE_FLOW_ITEM_TYPE_VOID;
5171 if (vxlan_encap_conf.select_tos_ttl) {
5172 if (vxlan_encap_conf.select_ipv4) {
5173 static struct rte_flow_item_ipv4 ipv4_mask_tos;
5175 memcpy(&ipv4_mask_tos, &rte_flow_item_ipv4_mask,
5176 sizeof(ipv4_mask_tos));
5177 ipv4_mask_tos.hdr.type_of_service = 0xff;
5178 ipv4_mask_tos.hdr.time_to_live = 0xff;
5179 action_vxlan_encap_data->item_ipv4.hdr.type_of_service =
5180 vxlan_encap_conf.ip_tos;
5181 action_vxlan_encap_data->item_ipv4.hdr.time_to_live =
5182 vxlan_encap_conf.ip_ttl;
5183 action_vxlan_encap_data->items[2].mask =
5186 static struct rte_flow_item_ipv6 ipv6_mask_tos;
5188 memcpy(&ipv6_mask_tos, &rte_flow_item_ipv6_mask,
5189 sizeof(ipv6_mask_tos));
5190 ipv6_mask_tos.hdr.vtc_flow |=
5191 RTE_BE32(0xfful << RTE_IPV6_HDR_TC_SHIFT);
5192 ipv6_mask_tos.hdr.hop_limits = 0xff;
5193 action_vxlan_encap_data->item_ipv6.hdr.vtc_flow |=
5195 ((uint32_t)vxlan_encap_conf.ip_tos <<
5196 RTE_IPV6_HDR_TC_SHIFT);
5197 action_vxlan_encap_data->item_ipv6.hdr.hop_limits =
5198 vxlan_encap_conf.ip_ttl;
5199 action_vxlan_encap_data->items[2].mask =
5203 memcpy(action_vxlan_encap_data->item_vxlan.vni, vxlan_encap_conf.vni,
5204 RTE_DIM(vxlan_encap_conf.vni));
5205 action->conf = &action_vxlan_encap_data->conf;
5209 /** Parse NVGRE encap action. */
5211 parse_vc_action_nvgre_encap(struct context *ctx, const struct token *token,
5212 const char *str, unsigned int len,
5213 void *buf, unsigned int size)
5215 struct buffer *out = buf;
5216 struct rte_flow_action *action;
5217 struct action_nvgre_encap_data *action_nvgre_encap_data;
5220 ret = parse_vc(ctx, token, str, len, buf, size);
5223 /* Nothing else to do if there is no buffer. */
5226 if (!out->args.vc.actions_n)
5228 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5229 /* Point to selected object. */
5230 ctx->object = out->args.vc.data;
5231 ctx->objmask = NULL;
5232 /* Set up default configuration. */
5233 action_nvgre_encap_data = ctx->object;
5234 *action_nvgre_encap_data = (struct action_nvgre_encap_data){
5235 .conf = (struct rte_flow_action_nvgre_encap){
5236 .definition = action_nvgre_encap_data->items,
5240 .type = RTE_FLOW_ITEM_TYPE_ETH,
5241 .spec = &action_nvgre_encap_data->item_eth,
5242 .mask = &rte_flow_item_eth_mask,
5245 .type = RTE_FLOW_ITEM_TYPE_VLAN,
5246 .spec = &action_nvgre_encap_data->item_vlan,
5247 .mask = &rte_flow_item_vlan_mask,
5250 .type = RTE_FLOW_ITEM_TYPE_IPV4,
5251 .spec = &action_nvgre_encap_data->item_ipv4,
5252 .mask = &rte_flow_item_ipv4_mask,
5255 .type = RTE_FLOW_ITEM_TYPE_NVGRE,
5256 .spec = &action_nvgre_encap_data->item_nvgre,
5257 .mask = &rte_flow_item_nvgre_mask,
5260 .type = RTE_FLOW_ITEM_TYPE_END,
5265 .tci = nvgre_encap_conf.vlan_tci,
5269 .src_addr = nvgre_encap_conf.ipv4_src,
5270 .dst_addr = nvgre_encap_conf.ipv4_dst,
5272 .item_nvgre.flow_id = 0,
5274 memcpy(action_nvgre_encap_data->item_eth.dst.addr_bytes,
5275 nvgre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5276 memcpy(action_nvgre_encap_data->item_eth.src.addr_bytes,
5277 nvgre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5278 if (!nvgre_encap_conf.select_ipv4) {
5279 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.src_addr,
5280 &nvgre_encap_conf.ipv6_src,
5281 sizeof(nvgre_encap_conf.ipv6_src));
5282 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.dst_addr,
5283 &nvgre_encap_conf.ipv6_dst,
5284 sizeof(nvgre_encap_conf.ipv6_dst));
5285 action_nvgre_encap_data->items[2] = (struct rte_flow_item){
5286 .type = RTE_FLOW_ITEM_TYPE_IPV6,
5287 .spec = &action_nvgre_encap_data->item_ipv6,
5288 .mask = &rte_flow_item_ipv6_mask,
5291 if (!nvgre_encap_conf.select_vlan)
5292 action_nvgre_encap_data->items[1].type =
5293 RTE_FLOW_ITEM_TYPE_VOID;
5294 memcpy(action_nvgre_encap_data->item_nvgre.tni, nvgre_encap_conf.tni,
5295 RTE_DIM(nvgre_encap_conf.tni));
5296 action->conf = &action_nvgre_encap_data->conf;
5300 /** Parse l2 encap action. */
5302 parse_vc_action_l2_encap(struct context *ctx, const struct token *token,
5303 const char *str, unsigned int len,
5304 void *buf, unsigned int size)
5306 struct buffer *out = buf;
5307 struct rte_flow_action *action;
5308 struct action_raw_encap_data *action_encap_data;
5309 struct rte_flow_item_eth eth = { .type = 0, };
5310 struct rte_flow_item_vlan vlan = {
5311 .tci = mplsoudp_encap_conf.vlan_tci,
5317 ret = parse_vc(ctx, token, str, len, buf, size);
5320 /* Nothing else to do if there is no buffer. */
5323 if (!out->args.vc.actions_n)
5325 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5326 /* Point to selected object. */
5327 ctx->object = out->args.vc.data;
5328 ctx->objmask = NULL;
5329 /* Copy the headers to the buffer. */
5330 action_encap_data = ctx->object;
5331 *action_encap_data = (struct action_raw_encap_data) {
5332 .conf = (struct rte_flow_action_raw_encap){
5333 .data = action_encap_data->data,
5337 header = action_encap_data->data;
5338 if (l2_encap_conf.select_vlan)
5339 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5340 else if (l2_encap_conf.select_ipv4)
5341 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5343 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5344 memcpy(eth.dst.addr_bytes,
5345 l2_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5346 memcpy(eth.src.addr_bytes,
5347 l2_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5348 memcpy(header, ð, sizeof(eth));
5349 header += sizeof(eth);
5350 if (l2_encap_conf.select_vlan) {
5351 if (l2_encap_conf.select_ipv4)
5352 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5354 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5355 memcpy(header, &vlan, sizeof(vlan));
5356 header += sizeof(vlan);
5358 action_encap_data->conf.size = header -
5359 action_encap_data->data;
5360 action->conf = &action_encap_data->conf;
5364 /** Parse l2 decap action. */
5366 parse_vc_action_l2_decap(struct context *ctx, const struct token *token,
5367 const char *str, unsigned int len,
5368 void *buf, unsigned int size)
5370 struct buffer *out = buf;
5371 struct rte_flow_action *action;
5372 struct action_raw_decap_data *action_decap_data;
5373 struct rte_flow_item_eth eth = { .type = 0, };
5374 struct rte_flow_item_vlan vlan = {
5375 .tci = mplsoudp_encap_conf.vlan_tci,
5381 ret = parse_vc(ctx, token, str, len, buf, size);
5384 /* Nothing else to do if there is no buffer. */
5387 if (!out->args.vc.actions_n)
5389 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5390 /* Point to selected object. */
5391 ctx->object = out->args.vc.data;
5392 ctx->objmask = NULL;
5393 /* Copy the headers to the buffer. */
5394 action_decap_data = ctx->object;
5395 *action_decap_data = (struct action_raw_decap_data) {
5396 .conf = (struct rte_flow_action_raw_decap){
5397 .data = action_decap_data->data,
5401 header = action_decap_data->data;
5402 if (l2_decap_conf.select_vlan)
5403 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5404 memcpy(header, ð, sizeof(eth));
5405 header += sizeof(eth);
5406 if (l2_decap_conf.select_vlan) {
5407 memcpy(header, &vlan, sizeof(vlan));
5408 header += sizeof(vlan);
5410 action_decap_data->conf.size = header -
5411 action_decap_data->data;
5412 action->conf = &action_decap_data->conf;
5416 #define ETHER_TYPE_MPLS_UNICAST 0x8847
5418 /** Parse MPLSOGRE encap action. */
5420 parse_vc_action_mplsogre_encap(struct context *ctx, const struct token *token,
5421 const char *str, unsigned int len,
5422 void *buf, unsigned int size)
5424 struct buffer *out = buf;
5425 struct rte_flow_action *action;
5426 struct action_raw_encap_data *action_encap_data;
5427 struct rte_flow_item_eth eth = { .type = 0, };
5428 struct rte_flow_item_vlan vlan = {
5429 .tci = mplsogre_encap_conf.vlan_tci,
5432 struct rte_flow_item_ipv4 ipv4 = {
5434 .src_addr = mplsogre_encap_conf.ipv4_src,
5435 .dst_addr = mplsogre_encap_conf.ipv4_dst,
5436 .next_proto_id = IPPROTO_GRE,
5437 .version_ihl = RTE_IPV4_VHL_DEF,
5438 .time_to_live = IPDEFTTL,
5441 struct rte_flow_item_ipv6 ipv6 = {
5443 .proto = IPPROTO_GRE,
5444 .hop_limits = IPDEFTTL,
5447 struct rte_flow_item_gre gre = {
5448 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
5450 struct rte_flow_item_mpls mpls = {
5456 ret = parse_vc(ctx, token, str, len, buf, size);
5459 /* Nothing else to do if there is no buffer. */
5462 if (!out->args.vc.actions_n)
5464 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5465 /* Point to selected object. */
5466 ctx->object = out->args.vc.data;
5467 ctx->objmask = NULL;
5468 /* Copy the headers to the buffer. */
5469 action_encap_data = ctx->object;
5470 *action_encap_data = (struct action_raw_encap_data) {
5471 .conf = (struct rte_flow_action_raw_encap){
5472 .data = action_encap_data->data,
5477 header = action_encap_data->data;
5478 if (mplsogre_encap_conf.select_vlan)
5479 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5480 else if (mplsogre_encap_conf.select_ipv4)
5481 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5483 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5484 memcpy(eth.dst.addr_bytes,
5485 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5486 memcpy(eth.src.addr_bytes,
5487 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5488 memcpy(header, ð, sizeof(eth));
5489 header += sizeof(eth);
5490 if (mplsogre_encap_conf.select_vlan) {
5491 if (mplsogre_encap_conf.select_ipv4)
5492 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5494 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5495 memcpy(header, &vlan, sizeof(vlan));
5496 header += sizeof(vlan);
5498 if (mplsogre_encap_conf.select_ipv4) {
5499 memcpy(header, &ipv4, sizeof(ipv4));
5500 header += sizeof(ipv4);
5502 memcpy(&ipv6.hdr.src_addr,
5503 &mplsogre_encap_conf.ipv6_src,
5504 sizeof(mplsogre_encap_conf.ipv6_src));
5505 memcpy(&ipv6.hdr.dst_addr,
5506 &mplsogre_encap_conf.ipv6_dst,
5507 sizeof(mplsogre_encap_conf.ipv6_dst));
5508 memcpy(header, &ipv6, sizeof(ipv6));
5509 header += sizeof(ipv6);
5511 memcpy(header, &gre, sizeof(gre));
5512 header += sizeof(gre);
5513 memcpy(mpls.label_tc_s, mplsogre_encap_conf.label,
5514 RTE_DIM(mplsogre_encap_conf.label));
5515 mpls.label_tc_s[2] |= 0x1;
5516 memcpy(header, &mpls, sizeof(mpls));
5517 header += sizeof(mpls);
5518 action_encap_data->conf.size = header -
5519 action_encap_data->data;
5520 action->conf = &action_encap_data->conf;
5524 /** Parse MPLSOGRE decap action. */
5526 parse_vc_action_mplsogre_decap(struct context *ctx, const struct token *token,
5527 const char *str, unsigned int len,
5528 void *buf, unsigned int size)
5530 struct buffer *out = buf;
5531 struct rte_flow_action *action;
5532 struct action_raw_decap_data *action_decap_data;
5533 struct rte_flow_item_eth eth = { .type = 0, };
5534 struct rte_flow_item_vlan vlan = {.tci = 0};
5535 struct rte_flow_item_ipv4 ipv4 = {
5537 .next_proto_id = IPPROTO_GRE,
5540 struct rte_flow_item_ipv6 ipv6 = {
5542 .proto = IPPROTO_GRE,
5545 struct rte_flow_item_gre gre = {
5546 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
5548 struct rte_flow_item_mpls mpls;
5552 ret = parse_vc(ctx, token, str, len, buf, size);
5555 /* Nothing else to do if there is no buffer. */
5558 if (!out->args.vc.actions_n)
5560 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5561 /* Point to selected object. */
5562 ctx->object = out->args.vc.data;
5563 ctx->objmask = NULL;
5564 /* Copy the headers to the buffer. */
5565 action_decap_data = ctx->object;
5566 *action_decap_data = (struct action_raw_decap_data) {
5567 .conf = (struct rte_flow_action_raw_decap){
5568 .data = action_decap_data->data,
5572 header = action_decap_data->data;
5573 if (mplsogre_decap_conf.select_vlan)
5574 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5575 else if (mplsogre_encap_conf.select_ipv4)
5576 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5578 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5579 memcpy(eth.dst.addr_bytes,
5580 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5581 memcpy(eth.src.addr_bytes,
5582 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5583 memcpy(header, ð, sizeof(eth));
5584 header += sizeof(eth);
5585 if (mplsogre_encap_conf.select_vlan) {
5586 if (mplsogre_encap_conf.select_ipv4)
5587 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5589 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5590 memcpy(header, &vlan, sizeof(vlan));
5591 header += sizeof(vlan);
5593 if (mplsogre_encap_conf.select_ipv4) {
5594 memcpy(header, &ipv4, sizeof(ipv4));
5595 header += sizeof(ipv4);
5597 memcpy(header, &ipv6, sizeof(ipv6));
5598 header += sizeof(ipv6);
5600 memcpy(header, &gre, sizeof(gre));
5601 header += sizeof(gre);
5602 memset(&mpls, 0, sizeof(mpls));
5603 memcpy(header, &mpls, sizeof(mpls));
5604 header += sizeof(mpls);
5605 action_decap_data->conf.size = header -
5606 action_decap_data->data;
5607 action->conf = &action_decap_data->conf;
5611 /** Parse MPLSOUDP encap action. */
5613 parse_vc_action_mplsoudp_encap(struct context *ctx, const struct token *token,
5614 const char *str, unsigned int len,
5615 void *buf, unsigned int size)
5617 struct buffer *out = buf;
5618 struct rte_flow_action *action;
5619 struct action_raw_encap_data *action_encap_data;
5620 struct rte_flow_item_eth eth = { .type = 0, };
5621 struct rte_flow_item_vlan vlan = {
5622 .tci = mplsoudp_encap_conf.vlan_tci,
5625 struct rte_flow_item_ipv4 ipv4 = {
5627 .src_addr = mplsoudp_encap_conf.ipv4_src,
5628 .dst_addr = mplsoudp_encap_conf.ipv4_dst,
5629 .next_proto_id = IPPROTO_UDP,
5630 .version_ihl = RTE_IPV4_VHL_DEF,
5631 .time_to_live = IPDEFTTL,
5634 struct rte_flow_item_ipv6 ipv6 = {
5636 .proto = IPPROTO_UDP,
5637 .hop_limits = IPDEFTTL,
5640 struct rte_flow_item_udp udp = {
5642 .src_port = mplsoudp_encap_conf.udp_src,
5643 .dst_port = mplsoudp_encap_conf.udp_dst,
5646 struct rte_flow_item_mpls mpls;
5650 ret = parse_vc(ctx, token, str, len, buf, size);
5653 /* Nothing else to do if there is no buffer. */
5656 if (!out->args.vc.actions_n)
5658 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5659 /* Point to selected object. */
5660 ctx->object = out->args.vc.data;
5661 ctx->objmask = NULL;
5662 /* Copy the headers to the buffer. */
5663 action_encap_data = ctx->object;
5664 *action_encap_data = (struct action_raw_encap_data) {
5665 .conf = (struct rte_flow_action_raw_encap){
5666 .data = action_encap_data->data,
5671 header = action_encap_data->data;
5672 if (mplsoudp_encap_conf.select_vlan)
5673 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5674 else if (mplsoudp_encap_conf.select_ipv4)
5675 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5677 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5678 memcpy(eth.dst.addr_bytes,
5679 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5680 memcpy(eth.src.addr_bytes,
5681 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5682 memcpy(header, ð, sizeof(eth));
5683 header += sizeof(eth);
5684 if (mplsoudp_encap_conf.select_vlan) {
5685 if (mplsoudp_encap_conf.select_ipv4)
5686 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5688 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5689 memcpy(header, &vlan, sizeof(vlan));
5690 header += sizeof(vlan);
5692 if (mplsoudp_encap_conf.select_ipv4) {
5693 memcpy(header, &ipv4, sizeof(ipv4));
5694 header += sizeof(ipv4);
5696 memcpy(&ipv6.hdr.src_addr,
5697 &mplsoudp_encap_conf.ipv6_src,
5698 sizeof(mplsoudp_encap_conf.ipv6_src));
5699 memcpy(&ipv6.hdr.dst_addr,
5700 &mplsoudp_encap_conf.ipv6_dst,
5701 sizeof(mplsoudp_encap_conf.ipv6_dst));
5702 memcpy(header, &ipv6, sizeof(ipv6));
5703 header += sizeof(ipv6);
5705 memcpy(header, &udp, sizeof(udp));
5706 header += sizeof(udp);
5707 memcpy(mpls.label_tc_s, mplsoudp_encap_conf.label,
5708 RTE_DIM(mplsoudp_encap_conf.label));
5709 mpls.label_tc_s[2] |= 0x1;
5710 memcpy(header, &mpls, sizeof(mpls));
5711 header += sizeof(mpls);
5712 action_encap_data->conf.size = header -
5713 action_encap_data->data;
5714 action->conf = &action_encap_data->conf;
5718 /** Parse MPLSOUDP decap action. */
5720 parse_vc_action_mplsoudp_decap(struct context *ctx, const struct token *token,
5721 const char *str, unsigned int len,
5722 void *buf, unsigned int size)
5724 struct buffer *out = buf;
5725 struct rte_flow_action *action;
5726 struct action_raw_decap_data *action_decap_data;
5727 struct rte_flow_item_eth eth = { .type = 0, };
5728 struct rte_flow_item_vlan vlan = {.tci = 0};
5729 struct rte_flow_item_ipv4 ipv4 = {
5731 .next_proto_id = IPPROTO_UDP,
5734 struct rte_flow_item_ipv6 ipv6 = {
5736 .proto = IPPROTO_UDP,
5739 struct rte_flow_item_udp udp = {
5741 .dst_port = rte_cpu_to_be_16(6635),
5744 struct rte_flow_item_mpls mpls;
5748 ret = parse_vc(ctx, token, str, len, buf, size);
5751 /* Nothing else to do if there is no buffer. */
5754 if (!out->args.vc.actions_n)
5756 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5757 /* Point to selected object. */
5758 ctx->object = out->args.vc.data;
5759 ctx->objmask = NULL;
5760 /* Copy the headers to the buffer. */
5761 action_decap_data = ctx->object;
5762 *action_decap_data = (struct action_raw_decap_data) {
5763 .conf = (struct rte_flow_action_raw_decap){
5764 .data = action_decap_data->data,
5768 header = action_decap_data->data;
5769 if (mplsoudp_decap_conf.select_vlan)
5770 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5771 else if (mplsoudp_encap_conf.select_ipv4)
5772 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5774 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5775 memcpy(eth.dst.addr_bytes,
5776 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5777 memcpy(eth.src.addr_bytes,
5778 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5779 memcpy(header, ð, sizeof(eth));
5780 header += sizeof(eth);
5781 if (mplsoudp_encap_conf.select_vlan) {
5782 if (mplsoudp_encap_conf.select_ipv4)
5783 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5785 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5786 memcpy(header, &vlan, sizeof(vlan));
5787 header += sizeof(vlan);
5789 if (mplsoudp_encap_conf.select_ipv4) {
5790 memcpy(header, &ipv4, sizeof(ipv4));
5791 header += sizeof(ipv4);
5793 memcpy(header, &ipv6, sizeof(ipv6));
5794 header += sizeof(ipv6);
5796 memcpy(header, &udp, sizeof(udp));
5797 header += sizeof(udp);
5798 memset(&mpls, 0, sizeof(mpls));
5799 memcpy(header, &mpls, sizeof(mpls));
5800 header += sizeof(mpls);
5801 action_decap_data->conf.size = header -
5802 action_decap_data->data;
5803 action->conf = &action_decap_data->conf;
5808 parse_vc_action_raw_decap_index(struct context *ctx, const struct token *token,
5809 const char *str, unsigned int len, void *buf,
5812 struct action_raw_decap_data *action_raw_decap_data;
5813 struct rte_flow_action *action;
5814 const struct arg *arg;
5815 struct buffer *out = buf;
5819 RTE_SET_USED(token);
5822 arg = ARGS_ENTRY_ARB_BOUNDED
5823 (offsetof(struct action_raw_decap_data, idx),
5824 sizeof(((struct action_raw_decap_data *)0)->idx),
5825 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
5826 if (push_args(ctx, arg))
5828 ret = parse_int(ctx, token, str, len, NULL, 0);
5835 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5836 action_raw_decap_data = ctx->object;
5837 idx = action_raw_decap_data->idx;
5838 action_raw_decap_data->conf.data = raw_decap_confs[idx].data;
5839 action_raw_decap_data->conf.size = raw_decap_confs[idx].size;
5840 action->conf = &action_raw_decap_data->conf;
5846 parse_vc_action_raw_encap_index(struct context *ctx, const struct token *token,
5847 const char *str, unsigned int len, void *buf,
5850 struct action_raw_encap_data *action_raw_encap_data;
5851 struct rte_flow_action *action;
5852 const struct arg *arg;
5853 struct buffer *out = buf;
5857 RTE_SET_USED(token);
5860 if (ctx->curr != ACTION_RAW_ENCAP_INDEX_VALUE)
5862 arg = ARGS_ENTRY_ARB_BOUNDED
5863 (offsetof(struct action_raw_encap_data, idx),
5864 sizeof(((struct action_raw_encap_data *)0)->idx),
5865 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
5866 if (push_args(ctx, arg))
5868 ret = parse_int(ctx, token, str, len, NULL, 0);
5875 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5876 action_raw_encap_data = ctx->object;
5877 idx = action_raw_encap_data->idx;
5878 action_raw_encap_data->conf.data = raw_encap_confs[idx].data;
5879 action_raw_encap_data->conf.size = raw_encap_confs[idx].size;
5880 action_raw_encap_data->conf.preserve = NULL;
5881 action->conf = &action_raw_encap_data->conf;
5886 parse_vc_action_raw_encap(struct context *ctx, const struct token *token,
5887 const char *str, unsigned int len, void *buf,
5890 struct buffer *out = buf;
5891 struct rte_flow_action *action;
5892 struct action_raw_encap_data *action_raw_encap_data = NULL;
5895 ret = parse_vc(ctx, token, str, len, buf, size);
5898 /* Nothing else to do if there is no buffer. */
5901 if (!out->args.vc.actions_n)
5903 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5904 /* Point to selected object. */
5905 ctx->object = out->args.vc.data;
5906 ctx->objmask = NULL;
5907 /* Copy the headers to the buffer. */
5908 action_raw_encap_data = ctx->object;
5909 action_raw_encap_data->conf.data = raw_encap_confs[0].data;
5910 action_raw_encap_data->conf.preserve = NULL;
5911 action_raw_encap_data->conf.size = raw_encap_confs[0].size;
5912 action->conf = &action_raw_encap_data->conf;
5917 parse_vc_action_raw_decap(struct context *ctx, const struct token *token,
5918 const char *str, unsigned int len, void *buf,
5921 struct buffer *out = buf;
5922 struct rte_flow_action *action;
5923 struct action_raw_decap_data *action_raw_decap_data = NULL;
5926 ret = parse_vc(ctx, token, str, len, buf, size);
5929 /* Nothing else to do if there is no buffer. */
5932 if (!out->args.vc.actions_n)
5934 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5935 /* Point to selected object. */
5936 ctx->object = out->args.vc.data;
5937 ctx->objmask = NULL;
5938 /* Copy the headers to the buffer. */
5939 action_raw_decap_data = ctx->object;
5940 action_raw_decap_data->conf.data = raw_decap_confs[0].data;
5941 action_raw_decap_data->conf.size = raw_decap_confs[0].size;
5942 action->conf = &action_raw_decap_data->conf;
5947 parse_vc_action_set_meta(struct context *ctx, const struct token *token,
5948 const char *str, unsigned int len, void *buf,
5953 ret = parse_vc(ctx, token, str, len, buf, size);
5956 ret = rte_flow_dynf_metadata_register();
5963 parse_vc_action_sample(struct context *ctx, const struct token *token,
5964 const char *str, unsigned int len, void *buf,
5967 struct buffer *out = buf;
5968 struct rte_flow_action *action;
5969 struct action_sample_data *action_sample_data = NULL;
5970 static struct rte_flow_action end_action = {
5971 RTE_FLOW_ACTION_TYPE_END, 0
5975 ret = parse_vc(ctx, token, str, len, buf, size);
5978 /* Nothing else to do if there is no buffer. */
5981 if (!out->args.vc.actions_n)
5983 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5984 /* Point to selected object. */
5985 ctx->object = out->args.vc.data;
5986 ctx->objmask = NULL;
5987 /* Copy the headers to the buffer. */
5988 action_sample_data = ctx->object;
5989 action_sample_data->conf.actions = &end_action;
5990 action->conf = &action_sample_data->conf;
5995 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
5996 const char *str, unsigned int len, void *buf,
5999 struct action_sample_data *action_sample_data;
6000 struct rte_flow_action *action;
6001 const struct arg *arg;
6002 struct buffer *out = buf;
6006 RTE_SET_USED(token);
6009 if (ctx->curr != ACTION_SAMPLE_INDEX_VALUE)
6011 arg = ARGS_ENTRY_ARB_BOUNDED
6012 (offsetof(struct action_sample_data, idx),
6013 sizeof(((struct action_sample_data *)0)->idx),
6014 0, RAW_SAMPLE_CONFS_MAX_NUM - 1);
6015 if (push_args(ctx, arg))
6017 ret = parse_int(ctx, token, str, len, NULL, 0);
6024 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6025 action_sample_data = ctx->object;
6026 idx = action_sample_data->idx;
6027 action_sample_data->conf.actions = raw_sample_confs[idx].data;
6028 action->conf = &action_sample_data->conf;
6032 /** Parse tokens for destroy command. */
6034 parse_destroy(struct context *ctx, const struct token *token,
6035 const char *str, unsigned int len,
6036 void *buf, unsigned int size)
6038 struct buffer *out = buf;
6040 /* Token name must match. */
6041 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6043 /* Nothing else to do if there is no buffer. */
6046 if (!out->command) {
6047 if (ctx->curr != DESTROY)
6049 if (sizeof(*out) > size)
6051 out->command = ctx->curr;
6054 ctx->objmask = NULL;
6055 out->args.destroy.rule =
6056 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6060 if (((uint8_t *)(out->args.destroy.rule + out->args.destroy.rule_n) +
6061 sizeof(*out->args.destroy.rule)) > (uint8_t *)out + size)
6064 ctx->object = out->args.destroy.rule + out->args.destroy.rule_n++;
6065 ctx->objmask = NULL;
6069 /** Parse tokens for flush command. */
6071 parse_flush(struct context *ctx, const struct token *token,
6072 const char *str, unsigned int len,
6073 void *buf, unsigned int size)
6075 struct buffer *out = buf;
6077 /* Token name must match. */
6078 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6080 /* Nothing else to do if there is no buffer. */
6083 if (!out->command) {
6084 if (ctx->curr != FLUSH)
6086 if (sizeof(*out) > size)
6088 out->command = ctx->curr;
6091 ctx->objmask = NULL;
6096 /** Parse tokens for dump command. */
6098 parse_dump(struct context *ctx, const struct token *token,
6099 const char *str, unsigned int len,
6100 void *buf, unsigned int size)
6102 struct buffer *out = buf;
6104 /* Token name must match. */
6105 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6107 /* Nothing else to do if there is no buffer. */
6110 if (!out->command) {
6111 if (ctx->curr != DUMP)
6113 if (sizeof(*out) > size)
6115 out->command = ctx->curr;
6118 ctx->objmask = NULL;
6123 /** Parse tokens for query command. */
6125 parse_query(struct context *ctx, const struct token *token,
6126 const char *str, unsigned int len,
6127 void *buf, unsigned int size)
6129 struct buffer *out = buf;
6131 /* Token name must match. */
6132 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6134 /* Nothing else to do if there is no buffer. */
6137 if (!out->command) {
6138 if (ctx->curr != QUERY)
6140 if (sizeof(*out) > size)
6142 out->command = ctx->curr;
6145 ctx->objmask = NULL;
6150 /** Parse action names. */
6152 parse_action(struct context *ctx, const struct token *token,
6153 const char *str, unsigned int len,
6154 void *buf, unsigned int size)
6156 struct buffer *out = buf;
6157 const struct arg *arg = pop_args(ctx);
6161 /* Argument is expected. */
6164 /* Parse action name. */
6165 for (i = 0; next_action[i]; ++i) {
6166 const struct parse_action_priv *priv;
6168 token = &token_list[next_action[i]];
6169 if (strcmp_partial(token->name, str, len))
6175 memcpy((uint8_t *)ctx->object + arg->offset,
6181 push_args(ctx, arg);
6185 /** Parse tokens for list command. */
6187 parse_list(struct context *ctx, const struct token *token,
6188 const char *str, unsigned int len,
6189 void *buf, unsigned int size)
6191 struct buffer *out = buf;
6193 /* Token name must match. */
6194 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6196 /* Nothing else to do if there is no buffer. */
6199 if (!out->command) {
6200 if (ctx->curr != LIST)
6202 if (sizeof(*out) > size)
6204 out->command = ctx->curr;
6207 ctx->objmask = NULL;
6208 out->args.list.group =
6209 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6213 if (((uint8_t *)(out->args.list.group + out->args.list.group_n) +
6214 sizeof(*out->args.list.group)) > (uint8_t *)out + size)
6217 ctx->object = out->args.list.group + out->args.list.group_n++;
6218 ctx->objmask = NULL;
6222 /** Parse tokens for list all aged flows command. */
6224 parse_aged(struct context *ctx, const struct token *token,
6225 const char *str, unsigned int len,
6226 void *buf, unsigned int size)
6228 struct buffer *out = buf;
6230 /* Token name must match. */
6231 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6233 /* Nothing else to do if there is no buffer. */
6236 if (!out->command) {
6237 if (ctx->curr != AGED)
6239 if (sizeof(*out) > size)
6241 out->command = ctx->curr;
6244 ctx->objmask = NULL;
6246 if (ctx->curr == AGED_DESTROY)
6247 out->args.aged.destroy = 1;
6251 /** Parse tokens for isolate command. */
6253 parse_isolate(struct context *ctx, const struct token *token,
6254 const char *str, unsigned int len,
6255 void *buf, unsigned int size)
6257 struct buffer *out = buf;
6259 /* Token name must match. */
6260 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6262 /* Nothing else to do if there is no buffer. */
6265 if (!out->command) {
6266 if (ctx->curr != ISOLATE)
6268 if (sizeof(*out) > size)
6270 out->command = ctx->curr;
6273 ctx->objmask = NULL;
6279 parse_tunnel(struct context *ctx, const struct token *token,
6280 const char *str, unsigned int len,
6281 void *buf, unsigned int size)
6283 struct buffer *out = buf;
6285 /* Token name must match. */
6286 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6288 /* Nothing else to do if there is no buffer. */
6291 if (!out->command) {
6292 if (ctx->curr != TUNNEL)
6294 if (sizeof(*out) > size)
6296 out->command = ctx->curr;
6299 ctx->objmask = NULL;
6301 switch (ctx->curr) {
6305 case TUNNEL_DESTROY:
6307 out->command = ctx->curr;
6309 case TUNNEL_CREATE_TYPE:
6310 case TUNNEL_DESTROY_ID:
6311 ctx->object = &out->args.vc.tunnel_ops;
6320 * Parse signed/unsigned integers 8 to 64-bit long.
6322 * Last argument (ctx->args) is retrieved to determine integer type and
6326 parse_int(struct context *ctx, const struct token *token,
6327 const char *str, unsigned int len,
6328 void *buf, unsigned int size)
6330 const struct arg *arg = pop_args(ctx);
6335 /* Argument is expected. */
6340 (uintmax_t)strtoimax(str, &end, 0) :
6341 strtoumax(str, &end, 0);
6342 if (errno || (size_t)(end - str) != len)
6345 ((arg->sign && ((intmax_t)u < (intmax_t)arg->min ||
6346 (intmax_t)u > (intmax_t)arg->max)) ||
6347 (!arg->sign && (u < arg->min || u > arg->max))))
6352 if (!arg_entry_bf_fill(ctx->object, u, arg) ||
6353 !arg_entry_bf_fill(ctx->objmask, -1, arg))
6357 buf = (uint8_t *)ctx->object + arg->offset;
6359 if (u > RTE_LEN2MASK(size * CHAR_BIT, uint64_t))
6363 case sizeof(uint8_t):
6364 *(uint8_t *)buf = u;
6366 case sizeof(uint16_t):
6367 *(uint16_t *)buf = arg->hton ? rte_cpu_to_be_16(u) : u;
6369 case sizeof(uint8_t [3]):
6370 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
6372 ((uint8_t *)buf)[0] = u;
6373 ((uint8_t *)buf)[1] = u >> 8;
6374 ((uint8_t *)buf)[2] = u >> 16;
6378 ((uint8_t *)buf)[0] = u >> 16;
6379 ((uint8_t *)buf)[1] = u >> 8;
6380 ((uint8_t *)buf)[2] = u;
6382 case sizeof(uint32_t):
6383 *(uint32_t *)buf = arg->hton ? rte_cpu_to_be_32(u) : u;
6385 case sizeof(uint64_t):
6386 *(uint64_t *)buf = arg->hton ? rte_cpu_to_be_64(u) : u;
6391 if (ctx->objmask && buf != (uint8_t *)ctx->objmask + arg->offset) {
6393 buf = (uint8_t *)ctx->objmask + arg->offset;
6398 push_args(ctx, arg);
6405 * Three arguments (ctx->args) are retrieved from the stack to store data,
6406 * its actual length and address (in that order).
6409 parse_string(struct context *ctx, const struct token *token,
6410 const char *str, unsigned int len,
6411 void *buf, unsigned int size)
6413 const struct arg *arg_data = pop_args(ctx);
6414 const struct arg *arg_len = pop_args(ctx);
6415 const struct arg *arg_addr = pop_args(ctx);
6416 char tmp[16]; /* Ought to be enough. */
6419 /* Arguments are expected. */
6423 push_args(ctx, arg_data);
6427 push_args(ctx, arg_len);
6428 push_args(ctx, arg_data);
6431 size = arg_data->size;
6432 /* Bit-mask fill is not supported. */
6433 if (arg_data->mask || size < len)
6437 /* Let parse_int() fill length information first. */
6438 ret = snprintf(tmp, sizeof(tmp), "%u", len);
6441 push_args(ctx, arg_len);
6442 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
6447 buf = (uint8_t *)ctx->object + arg_data->offset;
6448 /* Output buffer is not necessarily NUL-terminated. */
6449 memcpy(buf, str, len);
6450 memset((uint8_t *)buf + len, 0x00, size - len);
6452 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
6453 /* Save address if requested. */
6454 if (arg_addr->size) {
6455 memcpy((uint8_t *)ctx->object + arg_addr->offset,
6457 (uint8_t *)ctx->object + arg_data->offset
6461 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
6463 (uint8_t *)ctx->objmask + arg_data->offset
6469 push_args(ctx, arg_addr);
6470 push_args(ctx, arg_len);
6471 push_args(ctx, arg_data);
6476 parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
6482 /* Check input parameters */
6483 if ((src == NULL) ||
6489 /* Convert chars to bytes */
6490 for (i = 0, len = 0; i < *size; i += 2) {
6491 snprintf(tmp, 3, "%s", src + i);
6492 dst[len++] = strtoul(tmp, &c, 16);
6507 parse_hex(struct context *ctx, const struct token *token,
6508 const char *str, unsigned int len,
6509 void *buf, unsigned int size)
6511 const struct arg *arg_data = pop_args(ctx);
6512 const struct arg *arg_len = pop_args(ctx);
6513 const struct arg *arg_addr = pop_args(ctx);
6514 char tmp[16]; /* Ought to be enough. */
6516 unsigned int hexlen = len;
6517 unsigned int length = 256;
6518 uint8_t hex_tmp[length];
6520 /* Arguments are expected. */
6524 push_args(ctx, arg_data);
6528 push_args(ctx, arg_len);
6529 push_args(ctx, arg_data);
6532 size = arg_data->size;
6533 /* Bit-mask fill is not supported. */
6539 /* translate bytes string to array. */
6540 if (str[0] == '0' && ((str[1] == 'x') ||
6545 if (hexlen > length)
6547 ret = parse_hex_string(str, hex_tmp, &hexlen);
6550 /* Let parse_int() fill length information first. */
6551 ret = snprintf(tmp, sizeof(tmp), "%u", hexlen);
6554 /* Save length if requested. */
6555 if (arg_len->size) {
6556 push_args(ctx, arg_len);
6557 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
6563 buf = (uint8_t *)ctx->object + arg_data->offset;
6564 /* Output buffer is not necessarily NUL-terminated. */
6565 memcpy(buf, hex_tmp, hexlen);
6566 memset((uint8_t *)buf + hexlen, 0x00, size - hexlen);
6568 memset((uint8_t *)ctx->objmask + arg_data->offset,
6570 /* Save address if requested. */
6571 if (arg_addr->size) {
6572 memcpy((uint8_t *)ctx->object + arg_addr->offset,
6574 (uint8_t *)ctx->object + arg_data->offset
6578 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
6580 (uint8_t *)ctx->objmask + arg_data->offset
6586 push_args(ctx, arg_addr);
6587 push_args(ctx, arg_len);
6588 push_args(ctx, arg_data);
6594 * Parse a zero-ended string.
6597 parse_string0(struct context *ctx, const struct token *token __rte_unused,
6598 const char *str, unsigned int len,
6599 void *buf, unsigned int size)
6601 const struct arg *arg_data = pop_args(ctx);
6603 /* Arguments are expected. */
6606 size = arg_data->size;
6607 /* Bit-mask fill is not supported. */
6608 if (arg_data->mask || size < len + 1)
6612 buf = (uint8_t *)ctx->object + arg_data->offset;
6613 strncpy(buf, str, len);
6615 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
6618 push_args(ctx, arg_data);
6623 * Parse a MAC address.
6625 * Last argument (ctx->args) is retrieved to determine storage size and
6629 parse_mac_addr(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 = pop_args(ctx);
6634 struct rte_ether_addr tmp;
6638 /* Argument is expected. */
6642 /* Bit-mask fill is not supported. */
6643 if (arg->mask || size != sizeof(tmp))
6645 /* Only network endian is supported. */
6648 ret = cmdline_parse_etheraddr(NULL, str, &tmp, size);
6649 if (ret < 0 || (unsigned int)ret != len)
6653 buf = (uint8_t *)ctx->object + arg->offset;
6654 memcpy(buf, &tmp, size);
6656 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6659 push_args(ctx, arg);
6664 * Parse an IPv4 address.
6666 * Last argument (ctx->args) is retrieved to determine storage size and
6670 parse_ipv4_addr(struct context *ctx, const struct token *token,
6671 const char *str, unsigned int len,
6672 void *buf, unsigned int size)
6674 const struct arg *arg = pop_args(ctx);
6679 /* Argument is expected. */
6683 /* Bit-mask fill is not supported. */
6684 if (arg->mask || size != sizeof(tmp))
6686 /* Only network endian is supported. */
6689 memcpy(str2, str, len);
6691 ret = inet_pton(AF_INET, str2, &tmp);
6693 /* Attempt integer parsing. */
6694 push_args(ctx, arg);
6695 return parse_int(ctx, token, str, len, buf, size);
6699 buf = (uint8_t *)ctx->object + arg->offset;
6700 memcpy(buf, &tmp, size);
6702 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6705 push_args(ctx, arg);
6710 * Parse an IPv6 address.
6712 * Last argument (ctx->args) is retrieved to determine storage size and
6716 parse_ipv6_addr(struct context *ctx, const struct token *token,
6717 const char *str, unsigned int len,
6718 void *buf, unsigned int size)
6720 const struct arg *arg = pop_args(ctx);
6722 struct in6_addr tmp;
6726 /* Argument is expected. */
6730 /* Bit-mask fill is not supported. */
6731 if (arg->mask || size != sizeof(tmp))
6733 /* Only network endian is supported. */
6736 memcpy(str2, str, len);
6738 ret = inet_pton(AF_INET6, str2, &tmp);
6743 buf = (uint8_t *)ctx->object + arg->offset;
6744 memcpy(buf, &tmp, size);
6746 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6749 push_args(ctx, arg);
6753 /** Boolean values (even indices stand for false). */
6754 static const char *const boolean_name[] = {
6764 * Parse a boolean value.
6766 * Last argument (ctx->args) is retrieved to determine storage size and
6770 parse_boolean(struct context *ctx, const struct token *token,
6771 const char *str, unsigned int len,
6772 void *buf, unsigned int size)
6774 const struct arg *arg = pop_args(ctx);
6778 /* Argument is expected. */
6781 for (i = 0; boolean_name[i]; ++i)
6782 if (!strcmp_partial(boolean_name[i], str, len))
6784 /* Process token as integer. */
6785 if (boolean_name[i])
6786 str = i & 1 ? "1" : "0";
6787 push_args(ctx, arg);
6788 ret = parse_int(ctx, token, str, strlen(str), buf, size);
6789 return ret > 0 ? (int)len : ret;
6792 /** Parse port and update context. */
6794 parse_port(struct context *ctx, const struct token *token,
6795 const char *str, unsigned int len,
6796 void *buf, unsigned int size)
6798 struct buffer *out = &(struct buffer){ .port = 0 };
6806 ctx->objmask = NULL;
6807 size = sizeof(*out);
6809 ret = parse_int(ctx, token, str, len, out, size);
6811 ctx->port = out->port;
6818 parse_sa_id2ptr(struct context *ctx, const struct token *token,
6819 const char *str, unsigned int len,
6820 void *buf, unsigned int size)
6822 struct rte_flow_action *action = ctx->object;
6830 ctx->objmask = NULL;
6831 ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
6832 ctx->object = action;
6833 if (ret != (int)len)
6835 /* set shared action */
6837 action->conf = port_shared_action_get_by_id(ctx->port, id);
6838 ret = (action->conf) ? ret : -1;
6843 /** Parse set command, initialize output buffer for subsequent tokens. */
6845 parse_set_raw_encap_decap(struct context *ctx, const struct token *token,
6846 const char *str, unsigned int len,
6847 void *buf, unsigned int size)
6849 struct buffer *out = buf;
6851 /* Token name must match. */
6852 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6854 /* Nothing else to do if there is no buffer. */
6857 /* Make sure buffer is large enough. */
6858 if (size < sizeof(*out))
6861 ctx->objmask = NULL;
6865 out->command = ctx->curr;
6866 /* For encap/decap we need is pattern */
6867 out->args.vc.pattern = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6872 /** Parse set command, initialize output buffer for subsequent tokens. */
6874 parse_set_sample_action(struct context *ctx, const struct token *token,
6875 const char *str, unsigned int len,
6876 void *buf, unsigned int size)
6878 struct buffer *out = buf;
6880 /* Token name must match. */
6881 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6883 /* Nothing else to do if there is no buffer. */
6886 /* Make sure buffer is large enough. */
6887 if (size < sizeof(*out))
6890 ctx->objmask = NULL;
6894 out->command = ctx->curr;
6895 /* For sampler we need is actions */
6896 out->args.vc.actions = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6902 * Parse set raw_encap/raw_decap command,
6903 * initialize output buffer for subsequent tokens.
6906 parse_set_init(struct context *ctx, const struct token *token,
6907 const char *str, unsigned int len,
6908 void *buf, unsigned int size)
6910 struct buffer *out = buf;
6912 /* Token name must match. */
6913 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6915 /* Nothing else to do if there is no buffer. */
6918 /* Make sure buffer is large enough. */
6919 if (size < sizeof(*out))
6921 /* Initialize buffer. */
6922 memset(out, 0x00, sizeof(*out));
6923 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
6926 ctx->objmask = NULL;
6927 if (!out->command) {
6928 if (ctx->curr != SET)
6930 if (sizeof(*out) > size)
6932 out->command = ctx->curr;
6933 out->args.vc.data = (uint8_t *)out + size;
6934 ctx->object = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6940 /** No completion. */
6942 comp_none(struct context *ctx, const struct token *token,
6943 unsigned int ent, char *buf, unsigned int size)
6953 /** Complete boolean values. */
6955 comp_boolean(struct context *ctx, const struct token *token,
6956 unsigned int ent, char *buf, unsigned int size)
6962 for (i = 0; boolean_name[i]; ++i)
6963 if (buf && i == ent)
6964 return strlcpy(buf, boolean_name[i], size);
6970 /** Complete action names. */
6972 comp_action(struct context *ctx, const struct token *token,
6973 unsigned int ent, char *buf, unsigned int size)
6979 for (i = 0; next_action[i]; ++i)
6980 if (buf && i == ent)
6981 return strlcpy(buf, token_list[next_action[i]].name,
6988 /** Complete available ports. */
6990 comp_port(struct context *ctx, const struct token *token,
6991 unsigned int ent, char *buf, unsigned int size)
6998 RTE_ETH_FOREACH_DEV(p) {
6999 if (buf && i == ent)
7000 return snprintf(buf, size, "%u", p);
7008 /** Complete available rule IDs. */
7010 comp_rule_id(struct context *ctx, const struct token *token,
7011 unsigned int ent, char *buf, unsigned int size)
7014 struct rte_port *port;
7015 struct port_flow *pf;
7018 if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
7019 ctx->port == (portid_t)RTE_PORT_ALL)
7021 port = &ports[ctx->port];
7022 for (pf = port->flow_list; pf != NULL; pf = pf->next) {
7023 if (buf && i == ent)
7024 return snprintf(buf, size, "%u", pf->id);
7032 /** Complete type field for RSS action. */
7034 comp_vc_action_rss_type(struct context *ctx, const struct token *token,
7035 unsigned int ent, char *buf, unsigned int size)
7041 for (i = 0; rss_type_table[i].str; ++i)
7046 return strlcpy(buf, rss_type_table[ent].str, size);
7048 return snprintf(buf, size, "end");
7052 /** Complete queue field for RSS action. */
7054 comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
7055 unsigned int ent, char *buf, unsigned int size)
7062 return snprintf(buf, size, "%u", ent);
7064 return snprintf(buf, size, "end");
7068 /** Complete index number for set raw_encap/raw_decap commands. */
7070 comp_set_raw_index(struct context *ctx, const struct token *token,
7071 unsigned int ent, char *buf, unsigned int size)
7077 RTE_SET_USED(token);
7078 for (idx = 0; idx < RAW_ENCAP_CONFS_MAX_NUM; ++idx) {
7079 if (buf && idx == ent)
7080 return snprintf(buf, size, "%u", idx);
7086 /** Complete index number for set raw_encap/raw_decap commands. */
7088 comp_set_sample_index(struct context *ctx, const struct token *token,
7089 unsigned int ent, char *buf, unsigned int size)
7095 RTE_SET_USED(token);
7096 for (idx = 0; idx < RAW_SAMPLE_CONFS_MAX_NUM; ++idx) {
7097 if (buf && idx == ent)
7098 return snprintf(buf, size, "%u", idx);
7104 /** Internal context. */
7105 static struct context cmd_flow_context;
7107 /** Global parser instance (cmdline API). */
7108 cmdline_parse_inst_t cmd_flow;
7109 cmdline_parse_inst_t cmd_set_raw;
7111 /** Initialize context. */
7113 cmd_flow_context_init(struct context *ctx)
7115 /* A full memset() is not necessary. */
7125 ctx->objmask = NULL;
7128 /** Parse a token (cmdline API). */
7130 cmd_flow_parse(cmdline_parse_token_hdr_t *hdr, const char *src, void *result,
7133 struct context *ctx = &cmd_flow_context;
7134 const struct token *token;
7135 const enum index *list;
7140 token = &token_list[ctx->curr];
7141 /* Check argument length. */
7144 for (len = 0; src[len]; ++len)
7145 if (src[len] == '#' || isspace(src[len]))
7149 /* Last argument and EOL detection. */
7150 for (i = len; src[i]; ++i)
7151 if (src[i] == '#' || src[i] == '\r' || src[i] == '\n')
7153 else if (!isspace(src[i])) {
7158 if (src[i] == '\r' || src[i] == '\n') {
7162 /* Initialize context if necessary. */
7163 if (!ctx->next_num) {
7166 ctx->next[ctx->next_num++] = token->next[0];
7168 /* Process argument through candidates. */
7169 ctx->prev = ctx->curr;
7170 list = ctx->next[ctx->next_num - 1];
7171 for (i = 0; list[i]; ++i) {
7172 const struct token *next = &token_list[list[i]];
7175 ctx->curr = list[i];
7177 tmp = next->call(ctx, next, src, len, result, size);
7179 tmp = parse_default(ctx, next, src, len, result, size);
7180 if (tmp == -1 || tmp != len)
7188 /* Push subsequent tokens if any. */
7190 for (i = 0; token->next[i]; ++i) {
7191 if (ctx->next_num == RTE_DIM(ctx->next))
7193 ctx->next[ctx->next_num++] = token->next[i];
7195 /* Push arguments if any. */
7197 for (i = 0; token->args[i]; ++i) {
7198 if (ctx->args_num == RTE_DIM(ctx->args))
7200 ctx->args[ctx->args_num++] = token->args[i];
7205 /** Return number of completion entries (cmdline API). */
7207 cmd_flow_complete_get_nb(cmdline_parse_token_hdr_t *hdr)
7209 struct context *ctx = &cmd_flow_context;
7210 const struct token *token = &token_list[ctx->curr];
7211 const enum index *list;
7215 /* Count number of tokens in current list. */
7217 list = ctx->next[ctx->next_num - 1];
7219 list = token->next[0];
7220 for (i = 0; list[i]; ++i)
7225 * If there is a single token, use its completion callback, otherwise
7226 * return the number of entries.
7228 token = &token_list[list[0]];
7229 if (i == 1 && token->comp) {
7230 /* Save index for cmd_flow_get_help(). */
7231 ctx->prev = list[0];
7232 return token->comp(ctx, token, 0, NULL, 0);
7237 /** Return a completion entry (cmdline API). */
7239 cmd_flow_complete_get_elt(cmdline_parse_token_hdr_t *hdr, int index,
7240 char *dst, unsigned int size)
7242 struct context *ctx = &cmd_flow_context;
7243 const struct token *token = &token_list[ctx->curr];
7244 const enum index *list;
7248 /* Count number of tokens in current list. */
7250 list = ctx->next[ctx->next_num - 1];
7252 list = token->next[0];
7253 for (i = 0; list[i]; ++i)
7257 /* If there is a single token, use its completion callback. */
7258 token = &token_list[list[0]];
7259 if (i == 1 && token->comp) {
7260 /* Save index for cmd_flow_get_help(). */
7261 ctx->prev = list[0];
7262 return token->comp(ctx, token, index, dst, size) < 0 ? -1 : 0;
7264 /* Otherwise make sure the index is valid and use defaults. */
7267 token = &token_list[list[index]];
7268 strlcpy(dst, token->name, size);
7269 /* Save index for cmd_flow_get_help(). */
7270 ctx->prev = list[index];
7274 /** Populate help strings for current token (cmdline API). */
7276 cmd_flow_get_help(cmdline_parse_token_hdr_t *hdr, char *dst, unsigned int size)
7278 struct context *ctx = &cmd_flow_context;
7279 const struct token *token = &token_list[ctx->prev];
7284 /* Set token type and update global help with details. */
7285 strlcpy(dst, (token->type ? token->type : "TOKEN"), size);
7287 cmd_flow.help_str = token->help;
7289 cmd_flow.help_str = token->name;
7293 /** Token definition template (cmdline API). */
7294 static struct cmdline_token_hdr cmd_flow_token_hdr = {
7295 .ops = &(struct cmdline_token_ops){
7296 .parse = cmd_flow_parse,
7297 .complete_get_nb = cmd_flow_complete_get_nb,
7298 .complete_get_elt = cmd_flow_complete_get_elt,
7299 .get_help = cmd_flow_get_help,
7304 /** Populate the next dynamic token. */
7306 cmd_flow_tok(cmdline_parse_token_hdr_t **hdr,
7307 cmdline_parse_token_hdr_t **hdr_inst)
7309 struct context *ctx = &cmd_flow_context;
7311 /* Always reinitialize context before requesting the first token. */
7312 if (!(hdr_inst - cmd_flow.tokens))
7313 cmd_flow_context_init(ctx);
7314 /* Return NULL when no more tokens are expected. */
7315 if (!ctx->next_num && ctx->curr) {
7319 /* Determine if command should end here. */
7320 if (ctx->eol && ctx->last && ctx->next_num) {
7321 const enum index *list = ctx->next[ctx->next_num - 1];
7324 for (i = 0; list[i]; ++i) {
7331 *hdr = &cmd_flow_token_hdr;
7334 /** Dispatch parsed buffer to function calls. */
7336 cmd_flow_parsed(const struct buffer *in)
7338 switch (in->command) {
7339 case SHARED_ACTION_CREATE:
7340 port_shared_action_create(
7341 in->port, in->args.vc.attr.group,
7342 &((const struct rte_flow_shared_action_conf) {
7343 .ingress = in->args.vc.attr.ingress,
7344 .egress = in->args.vc.attr.egress,
7345 .transfer = in->args.vc.attr.transfer,
7347 in->args.vc.actions);
7349 case SHARED_ACTION_DESTROY:
7350 port_shared_action_destroy(in->port,
7351 in->args.sa_destroy.action_id_n,
7352 in->args.sa_destroy.action_id);
7354 case SHARED_ACTION_UPDATE:
7355 port_shared_action_update(in->port, in->args.vc.attr.group,
7356 in->args.vc.actions);
7358 case SHARED_ACTION_QUERY:
7359 port_shared_action_query(in->port, in->args.sa.action_id);
7362 port_flow_validate(in->port, &in->args.vc.attr,
7363 in->args.vc.pattern, in->args.vc.actions,
7364 &in->args.vc.tunnel_ops);
7367 port_flow_create(in->port, &in->args.vc.attr,
7368 in->args.vc.pattern, in->args.vc.actions,
7369 &in->args.vc.tunnel_ops);
7372 port_flow_destroy(in->port, in->args.destroy.rule_n,
7373 in->args.destroy.rule);
7376 port_flow_flush(in->port);
7379 port_flow_dump(in->port, in->args.dump.file);
7382 port_flow_query(in->port, in->args.query.rule,
7383 &in->args.query.action);
7386 port_flow_list(in->port, in->args.list.group_n,
7387 in->args.list.group);
7390 port_flow_isolate(in->port, in->args.isolate.set);
7393 port_flow_aged(in->port, in->args.aged.destroy);
7396 port_flow_tunnel_create(in->port, &in->args.vc.tunnel_ops);
7398 case TUNNEL_DESTROY:
7399 port_flow_tunnel_destroy(in->port, in->args.vc.tunnel_ops.id);
7402 port_flow_tunnel_list(in->port);
7409 /** Token generator and output processing callback (cmdline API). */
7411 cmd_flow_cb(void *arg0, struct cmdline *cl, void *arg2)
7414 cmd_flow_tok(arg0, arg2);
7416 cmd_flow_parsed(arg0);
7419 /** Global parser instance (cmdline API). */
7420 cmdline_parse_inst_t cmd_flow = {
7422 .data = NULL, /**< Unused. */
7423 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
7426 }, /**< Tokens are returned by cmd_flow_tok(). */
7429 /** set cmd facility. Reuse cmd flow's infrastructure as much as possible. */
7432 update_fields(uint8_t *buf, struct rte_flow_item *item, uint16_t next_proto)
7434 struct rte_ipv4_hdr *ipv4;
7435 struct rte_ether_hdr *eth;
7436 struct rte_ipv6_hdr *ipv6;
7437 struct rte_vxlan_hdr *vxlan;
7438 struct rte_vxlan_gpe_hdr *gpe;
7439 struct rte_flow_item_nvgre *nvgre;
7440 uint32_t ipv6_vtc_flow;
7442 switch (item->type) {
7443 case RTE_FLOW_ITEM_TYPE_ETH:
7444 eth = (struct rte_ether_hdr *)buf;
7446 eth->ether_type = rte_cpu_to_be_16(next_proto);
7448 case RTE_FLOW_ITEM_TYPE_IPV4:
7449 ipv4 = (struct rte_ipv4_hdr *)buf;
7450 ipv4->version_ihl = 0x45;
7451 if (next_proto && ipv4->next_proto_id == 0)
7452 ipv4->next_proto_id = (uint8_t)next_proto;
7454 case RTE_FLOW_ITEM_TYPE_IPV6:
7455 ipv6 = (struct rte_ipv6_hdr *)buf;
7456 if (next_proto && ipv6->proto == 0)
7457 ipv6->proto = (uint8_t)next_proto;
7458 ipv6_vtc_flow = rte_be_to_cpu_32(ipv6->vtc_flow);
7459 ipv6_vtc_flow &= 0x0FFFFFFF; /*< reset version bits. */
7460 ipv6_vtc_flow |= 0x60000000; /*< set ipv6 version. */
7461 ipv6->vtc_flow = rte_cpu_to_be_32(ipv6_vtc_flow);
7463 case RTE_FLOW_ITEM_TYPE_VXLAN:
7464 vxlan = (struct rte_vxlan_hdr *)buf;
7465 vxlan->vx_flags = 0x08;
7467 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
7468 gpe = (struct rte_vxlan_gpe_hdr *)buf;
7469 gpe->vx_flags = 0x0C;
7471 case RTE_FLOW_ITEM_TYPE_NVGRE:
7472 nvgre = (struct rte_flow_item_nvgre *)buf;
7473 nvgre->protocol = rte_cpu_to_be_16(0x6558);
7474 nvgre->c_k_s_rsvd0_ver = rte_cpu_to_be_16(0x2000);
7481 /** Helper of get item's default mask. */
7483 flow_item_default_mask(const struct rte_flow_item *item)
7485 const void *mask = NULL;
7486 static rte_be32_t gre_key_default_mask = RTE_BE32(UINT32_MAX);
7488 switch (item->type) {
7489 case RTE_FLOW_ITEM_TYPE_ANY:
7490 mask = &rte_flow_item_any_mask;
7492 case RTE_FLOW_ITEM_TYPE_VF:
7493 mask = &rte_flow_item_vf_mask;
7495 case RTE_FLOW_ITEM_TYPE_PORT_ID:
7496 mask = &rte_flow_item_port_id_mask;
7498 case RTE_FLOW_ITEM_TYPE_RAW:
7499 mask = &rte_flow_item_raw_mask;
7501 case RTE_FLOW_ITEM_TYPE_ETH:
7502 mask = &rte_flow_item_eth_mask;
7504 case RTE_FLOW_ITEM_TYPE_VLAN:
7505 mask = &rte_flow_item_vlan_mask;
7507 case RTE_FLOW_ITEM_TYPE_IPV4:
7508 mask = &rte_flow_item_ipv4_mask;
7510 case RTE_FLOW_ITEM_TYPE_IPV6:
7511 mask = &rte_flow_item_ipv6_mask;
7513 case RTE_FLOW_ITEM_TYPE_ICMP:
7514 mask = &rte_flow_item_icmp_mask;
7516 case RTE_FLOW_ITEM_TYPE_UDP:
7517 mask = &rte_flow_item_udp_mask;
7519 case RTE_FLOW_ITEM_TYPE_TCP:
7520 mask = &rte_flow_item_tcp_mask;
7522 case RTE_FLOW_ITEM_TYPE_SCTP:
7523 mask = &rte_flow_item_sctp_mask;
7525 case RTE_FLOW_ITEM_TYPE_VXLAN:
7526 mask = &rte_flow_item_vxlan_mask;
7528 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
7529 mask = &rte_flow_item_vxlan_gpe_mask;
7531 case RTE_FLOW_ITEM_TYPE_E_TAG:
7532 mask = &rte_flow_item_e_tag_mask;
7534 case RTE_FLOW_ITEM_TYPE_NVGRE:
7535 mask = &rte_flow_item_nvgre_mask;
7537 case RTE_FLOW_ITEM_TYPE_MPLS:
7538 mask = &rte_flow_item_mpls_mask;
7540 case RTE_FLOW_ITEM_TYPE_GRE:
7541 mask = &rte_flow_item_gre_mask;
7543 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
7544 mask = &gre_key_default_mask;
7546 case RTE_FLOW_ITEM_TYPE_META:
7547 mask = &rte_flow_item_meta_mask;
7549 case RTE_FLOW_ITEM_TYPE_FUZZY:
7550 mask = &rte_flow_item_fuzzy_mask;
7552 case RTE_FLOW_ITEM_TYPE_GTP:
7553 mask = &rte_flow_item_gtp_mask;
7555 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
7556 mask = &rte_flow_item_gtp_psc_mask;
7558 case RTE_FLOW_ITEM_TYPE_GENEVE:
7559 mask = &rte_flow_item_geneve_mask;
7561 case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
7562 mask = &rte_flow_item_geneve_opt_mask;
7564 case RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID:
7565 mask = &rte_flow_item_pppoe_proto_id_mask;
7567 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
7568 mask = &rte_flow_item_l2tpv3oip_mask;
7570 case RTE_FLOW_ITEM_TYPE_ESP:
7571 mask = &rte_flow_item_esp_mask;
7573 case RTE_FLOW_ITEM_TYPE_AH:
7574 mask = &rte_flow_item_ah_mask;
7576 case RTE_FLOW_ITEM_TYPE_PFCP:
7577 mask = &rte_flow_item_pfcp_mask;
7585 /** Dispatch parsed buffer to function calls. */
7587 cmd_set_raw_parsed_sample(const struct buffer *in)
7589 uint32_t n = in->args.vc.actions_n;
7591 struct rte_flow_action *action = NULL;
7592 struct rte_flow_action *data = NULL;
7594 uint16_t idx = in->port; /* We borrow port field as index */
7595 uint32_t max_size = sizeof(struct rte_flow_action) *
7596 ACTION_SAMPLE_ACTIONS_NUM;
7598 RTE_ASSERT(in->command == SET_SAMPLE_ACTIONS);
7599 data = (struct rte_flow_action *)&raw_sample_confs[idx].data;
7600 memset(data, 0x00, max_size);
7601 for (; i <= n - 1; i++) {
7602 action = in->args.vc.actions + i;
7603 if (action->type == RTE_FLOW_ACTION_TYPE_END)
7605 switch (action->type) {
7606 case RTE_FLOW_ACTION_TYPE_MARK:
7607 size = sizeof(struct rte_flow_action_mark);
7608 rte_memcpy(&sample_mark[idx],
7609 (const void *)action->conf, size);
7610 action->conf = &sample_mark[idx];
7612 case RTE_FLOW_ACTION_TYPE_COUNT:
7613 size = sizeof(struct rte_flow_action_count);
7614 rte_memcpy(&sample_count[idx],
7615 (const void *)action->conf, size);
7616 action->conf = &sample_count[idx];
7618 case RTE_FLOW_ACTION_TYPE_QUEUE:
7619 size = sizeof(struct rte_flow_action_queue);
7620 rte_memcpy(&sample_queue[idx],
7621 (const void *)action->conf, size);
7622 action->conf = &sample_queue[idx];
7624 case RTE_FLOW_ACTION_TYPE_RAW_ENCAP:
7625 size = sizeof(struct rte_flow_action_raw_encap);
7626 rte_memcpy(&sample_encap[idx],
7627 (const void *)action->conf, size);
7628 action->conf = &sample_encap[idx];
7630 case RTE_FLOW_ACTION_TYPE_PORT_ID:
7631 size = sizeof(struct rte_flow_action_port_id);
7632 rte_memcpy(&sample_port_id[idx],
7633 (const void *)action->conf, size);
7634 action->conf = &sample_port_id[idx];
7637 printf("Error - Not supported action\n");
7640 rte_memcpy(data, action, sizeof(struct rte_flow_action));
7645 /** Dispatch parsed buffer to function calls. */
7647 cmd_set_raw_parsed(const struct buffer *in)
7649 uint32_t n = in->args.vc.pattern_n;
7651 struct rte_flow_item *item = NULL;
7653 uint8_t *data = NULL;
7654 uint8_t *data_tail = NULL;
7655 size_t *total_size = NULL;
7656 uint16_t upper_layer = 0;
7658 uint16_t idx = in->port; /* We borrow port field as index */
7659 int gtp_psc = -1; /* GTP PSC option index. */
7661 if (in->command == SET_SAMPLE_ACTIONS)
7662 return cmd_set_raw_parsed_sample(in);
7663 RTE_ASSERT(in->command == SET_RAW_ENCAP ||
7664 in->command == SET_RAW_DECAP);
7665 if (in->command == SET_RAW_ENCAP) {
7666 total_size = &raw_encap_confs[idx].size;
7667 data = (uint8_t *)&raw_encap_confs[idx].data;
7669 total_size = &raw_decap_confs[idx].size;
7670 data = (uint8_t *)&raw_decap_confs[idx].data;
7673 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
7674 /* process hdr from upper layer to low layer (L3/L4 -> L2). */
7675 data_tail = data + ACTION_RAW_ENCAP_MAX_DATA;
7676 for (i = n - 1 ; i >= 0; --i) {
7677 const struct rte_flow_item_gtp *gtp;
7678 const struct rte_flow_item_geneve_opt *opt;
7680 item = in->args.vc.pattern + i;
7681 if (item->spec == NULL)
7682 item->spec = flow_item_default_mask(item);
7683 switch (item->type) {
7684 case RTE_FLOW_ITEM_TYPE_ETH:
7685 size = sizeof(struct rte_ether_hdr);
7687 case RTE_FLOW_ITEM_TYPE_VLAN:
7688 size = sizeof(struct rte_vlan_hdr);
7689 proto = RTE_ETHER_TYPE_VLAN;
7691 case RTE_FLOW_ITEM_TYPE_IPV4:
7692 size = sizeof(struct rte_ipv4_hdr);
7693 proto = RTE_ETHER_TYPE_IPV4;
7695 case RTE_FLOW_ITEM_TYPE_IPV6:
7696 size = sizeof(struct rte_ipv6_hdr);
7697 proto = RTE_ETHER_TYPE_IPV6;
7699 case RTE_FLOW_ITEM_TYPE_UDP:
7700 size = sizeof(struct rte_udp_hdr);
7703 case RTE_FLOW_ITEM_TYPE_TCP:
7704 size = sizeof(struct rte_tcp_hdr);
7707 case RTE_FLOW_ITEM_TYPE_VXLAN:
7708 size = sizeof(struct rte_vxlan_hdr);
7710 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
7711 size = sizeof(struct rte_vxlan_gpe_hdr);
7713 case RTE_FLOW_ITEM_TYPE_GRE:
7714 size = sizeof(struct rte_gre_hdr);
7717 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
7718 size = sizeof(rte_be32_t);
7721 case RTE_FLOW_ITEM_TYPE_MPLS:
7722 size = sizeof(struct rte_mpls_hdr);
7725 case RTE_FLOW_ITEM_TYPE_NVGRE:
7726 size = sizeof(struct rte_flow_item_nvgre);
7729 case RTE_FLOW_ITEM_TYPE_GENEVE:
7730 size = sizeof(struct rte_geneve_hdr);
7732 case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
7733 opt = (const struct rte_flow_item_geneve_opt *)
7735 size = offsetof(struct rte_flow_item_geneve_opt, data);
7736 if (opt->option_len && opt->data) {
7737 *total_size += opt->option_len *
7739 rte_memcpy(data_tail - (*total_size),
7741 opt->option_len * sizeof(uint32_t));
7744 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
7745 size = sizeof(rte_be32_t);
7748 case RTE_FLOW_ITEM_TYPE_ESP:
7749 size = sizeof(struct rte_esp_hdr);
7752 case RTE_FLOW_ITEM_TYPE_AH:
7753 size = sizeof(struct rte_flow_item_ah);
7756 case RTE_FLOW_ITEM_TYPE_GTP:
7758 size = sizeof(struct rte_gtp_hdr);
7761 if (gtp_psc != i + 1) {
7762 printf("Error - GTP PSC does not follow GTP\n");
7766 if ((gtp->v_pt_rsv_flags & 0x07) != 0x04) {
7767 /* Only E flag should be set. */
7768 printf("Error - GTP unsupported flags\n");
7771 struct rte_gtp_hdr_ext_word ext_word = {
7775 /* We have to add GTP header extra word. */
7776 *total_size += sizeof(ext_word);
7777 rte_memcpy(data_tail - (*total_size),
7778 &ext_word, sizeof(ext_word));
7780 size = sizeof(struct rte_gtp_hdr);
7782 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
7784 printf("Error - Multiple GTP PSC items\n");
7787 const struct rte_flow_item_gtp_psc
7796 if (opt->pdu_type & 0x0F) {
7797 /* Support the minimal option only. */
7798 printf("Error - GTP PSC option with "
7799 "extra fields not supported\n");
7802 psc.len = sizeof(psc);
7803 psc.pdu_type = opt->pdu_type;
7806 *total_size += sizeof(psc);
7807 rte_memcpy(data_tail - (*total_size),
7813 case RTE_FLOW_ITEM_TYPE_PFCP:
7814 size = sizeof(struct rte_flow_item_pfcp);
7817 printf("Error - Not supported item\n");
7820 *total_size += size;
7821 rte_memcpy(data_tail - (*total_size), item->spec, size);
7822 /* update some fields which cannot be set by cmdline */
7823 update_fields((data_tail - (*total_size)), item,
7825 upper_layer = proto;
7827 if (verbose_level & 0x1)
7828 printf("total data size is %zu\n", (*total_size));
7829 RTE_ASSERT((*total_size) <= ACTION_RAW_ENCAP_MAX_DATA);
7830 memmove(data, (data_tail - (*total_size)), *total_size);
7835 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
7838 /** Populate help strings for current token (cmdline API). */
7840 cmd_set_raw_get_help(cmdline_parse_token_hdr_t *hdr, char *dst,
7843 struct context *ctx = &cmd_flow_context;
7844 const struct token *token = &token_list[ctx->prev];
7849 /* Set token type and update global help with details. */
7850 snprintf(dst, size, "%s", (token->type ? token->type : "TOKEN"));
7852 cmd_set_raw.help_str = token->help;
7854 cmd_set_raw.help_str = token->name;
7858 /** Token definition template (cmdline API). */
7859 static struct cmdline_token_hdr cmd_set_raw_token_hdr = {
7860 .ops = &(struct cmdline_token_ops){
7861 .parse = cmd_flow_parse,
7862 .complete_get_nb = cmd_flow_complete_get_nb,
7863 .complete_get_elt = cmd_flow_complete_get_elt,
7864 .get_help = cmd_set_raw_get_help,
7869 /** Populate the next dynamic token. */
7871 cmd_set_raw_tok(cmdline_parse_token_hdr_t **hdr,
7872 cmdline_parse_token_hdr_t **hdr_inst)
7874 struct context *ctx = &cmd_flow_context;
7876 /* Always reinitialize context before requesting the first token. */
7877 if (!(hdr_inst - cmd_set_raw.tokens)) {
7878 cmd_flow_context_init(ctx);
7879 ctx->curr = START_SET;
7881 /* Return NULL when no more tokens are expected. */
7882 if (!ctx->next_num && (ctx->curr != START_SET)) {
7886 /* Determine if command should end here. */
7887 if (ctx->eol && ctx->last && ctx->next_num) {
7888 const enum index *list = ctx->next[ctx->next_num - 1];
7891 for (i = 0; list[i]; ++i) {
7898 *hdr = &cmd_set_raw_token_hdr;
7901 /** Token generator and output processing callback (cmdline API). */
7903 cmd_set_raw_cb(void *arg0, struct cmdline *cl, void *arg2)
7906 cmd_set_raw_tok(arg0, arg2);
7908 cmd_set_raw_parsed(arg0);
7911 /** Global parser instance (cmdline API). */
7912 cmdline_parse_inst_t cmd_set_raw = {
7913 .f = cmd_set_raw_cb,
7914 .data = NULL, /**< Unused. */
7915 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
7918 }, /**< Tokens are returned by cmd_flow_tok(). */
7921 /* *** display raw_encap/raw_decap buf */
7922 struct cmd_show_set_raw_result {
7923 cmdline_fixed_string_t cmd_show;
7924 cmdline_fixed_string_t cmd_what;
7925 cmdline_fixed_string_t cmd_all;
7930 cmd_show_set_raw_parsed(void *parsed_result, struct cmdline *cl, void *data)
7932 struct cmd_show_set_raw_result *res = parsed_result;
7933 uint16_t index = res->cmd_index;
7935 uint8_t *raw_data = NULL;
7936 size_t raw_size = 0;
7937 char title[16] = {0};
7941 if (!strcmp(res->cmd_all, "all")) {
7944 } else if (index >= RAW_ENCAP_CONFS_MAX_NUM) {
7945 printf("index should be 0-%u\n", RAW_ENCAP_CONFS_MAX_NUM - 1);
7949 if (!strcmp(res->cmd_what, "raw_encap")) {
7950 raw_data = (uint8_t *)&raw_encap_confs[index].data;
7951 raw_size = raw_encap_confs[index].size;
7952 snprintf(title, 16, "\nindex: %u", index);
7953 rte_hexdump(stdout, title, raw_data, raw_size);
7955 raw_data = (uint8_t *)&raw_decap_confs[index].data;
7956 raw_size = raw_decap_confs[index].size;
7957 snprintf(title, 16, "\nindex: %u", index);
7958 rte_hexdump(stdout, title, raw_data, raw_size);
7960 } while (all && ++index < RAW_ENCAP_CONFS_MAX_NUM);
7963 cmdline_parse_token_string_t cmd_show_set_raw_cmd_show =
7964 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
7966 cmdline_parse_token_string_t cmd_show_set_raw_cmd_what =
7967 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
7968 cmd_what, "raw_encap#raw_decap");
7969 cmdline_parse_token_num_t cmd_show_set_raw_cmd_index =
7970 TOKEN_NUM_INITIALIZER(struct cmd_show_set_raw_result,
7971 cmd_index, RTE_UINT16);
7972 cmdline_parse_token_string_t cmd_show_set_raw_cmd_all =
7973 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
7975 cmdline_parse_inst_t cmd_show_set_raw = {
7976 .f = cmd_show_set_raw_parsed,
7978 .help_str = "show <raw_encap|raw_decap> <index>",
7980 (void *)&cmd_show_set_raw_cmd_show,
7981 (void *)&cmd_show_set_raw_cmd_what,
7982 (void *)&cmd_show_set_raw_cmd_index,
7986 cmdline_parse_inst_t cmd_show_set_raw_all = {
7987 .f = cmd_show_set_raw_parsed,
7989 .help_str = "show <raw_encap|raw_decap> all",
7991 (void *)&cmd_show_set_raw_cmd_show,
7992 (void *)&cmd_show_set_raw_cmd_what,
7993 (void *)&cmd_show_set_raw_cmd_all,