1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2016 6WIND S.A.
3 * Copyright 2016 Mellanox Technologies, Ltd
13 #include <arpa/inet.h>
14 #include <sys/socket.h>
16 #include <rte_string_fns.h>
17 #include <rte_common.h>
18 #include <rte_ethdev.h>
19 #include <rte_byteorder.h>
20 #include <cmdline_parse.h>
21 #include <cmdline_parse_etheraddr.h>
22 #include <cmdline_parse_string.h>
23 #include <cmdline_parse_num.h>
25 #include <rte_hexdump.h>
26 #include <rte_vxlan.h>
30 #include <rte_geneve.h>
34 /** Parser token indices. */
59 /* Top-level command. */
61 /* Sub-leve commands. */
68 /* Top-level command. */
70 /* Sub-level commands. */
83 /* Tunnel arguments. */
90 /* Destroy arguments. */
93 /* Query arguments. */
99 /* Destroy aged flow arguments. */
102 /* Validate/create arguments. */
111 /* Shared action arguments */
112 SHARED_ACTION_CREATE,
113 SHARED_ACTION_UPDATE,
114 SHARED_ACTION_DESTROY,
117 /* Shared action create arguments */
118 SHARED_ACTION_CREATE_ID,
119 SHARED_ACTION_INGRESS,
120 SHARED_ACTION_EGRESS,
121 SHARED_ACTION_TRANSFER,
124 /* Shared action destroy arguments */
125 SHARED_ACTION_DESTROY_ID,
127 /* Validate/create pattern. */
165 ITEM_VLAN_INNER_TYPE,
166 ITEM_VLAN_HAS_MORE_VLAN,
169 ITEM_IPV4_FRAGMENT_OFFSET,
181 ITEM_IPV6_HAS_FRAG_EXT,
202 ITEM_E_TAG_GRP_ECID_B,
211 ITEM_GRE_C_RSVD0_VER,
230 ITEM_ARP_ETH_IPV4_SHA,
231 ITEM_ARP_ETH_IPV4_SPA,
232 ITEM_ARP_ETH_IPV4_THA,
233 ITEM_ARP_ETH_IPV4_TPA,
235 ITEM_IPV6_EXT_NEXT_HDR,
237 ITEM_IPV6_FRAG_EXT_NEXT_HDR,
238 ITEM_IPV6_FRAG_EXT_FRAG_DATA,
243 ITEM_ICMP6_ND_NS_TARGET_ADDR,
245 ITEM_ICMP6_ND_NA_TARGET_ADDR,
247 ITEM_ICMP6_ND_OPT_TYPE,
248 ITEM_ICMP6_ND_OPT_SLA_ETH,
249 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
250 ITEM_ICMP6_ND_OPT_TLA_ETH,
251 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
264 ITEM_HIGIG2_CLASSIFICATION,
270 ITEM_L2TPV3OIP_SESSION_ID,
280 ITEM_ECPRI_COMMON_TYPE,
281 ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
282 ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
283 ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
284 ITEM_ECPRI_MSG_IQ_DATA_PCID,
285 ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
286 ITEM_ECPRI_MSG_DLY_MSR_MSRID,
288 ITEM_GENEVE_OPT_CLASS,
289 ITEM_GENEVE_OPT_TYPE,
290 ITEM_GENEVE_OPT_LENGTH,
291 ITEM_GENEVE_OPT_DATA,
293 /* Validate/create actions. */
313 ACTION_RSS_FUNC_DEFAULT,
314 ACTION_RSS_FUNC_TOEPLITZ,
315 ACTION_RSS_FUNC_SIMPLE_XOR,
316 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ,
328 ACTION_PHY_PORT_ORIGINAL,
329 ACTION_PHY_PORT_INDEX,
331 ACTION_PORT_ID_ORIGINAL,
335 ACTION_OF_SET_MPLS_TTL,
336 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
337 ACTION_OF_DEC_MPLS_TTL,
338 ACTION_OF_SET_NW_TTL,
339 ACTION_OF_SET_NW_TTL_NW_TTL,
340 ACTION_OF_DEC_NW_TTL,
341 ACTION_OF_COPY_TTL_OUT,
342 ACTION_OF_COPY_TTL_IN,
345 ACTION_OF_PUSH_VLAN_ETHERTYPE,
346 ACTION_OF_SET_VLAN_VID,
347 ACTION_OF_SET_VLAN_VID_VLAN_VID,
348 ACTION_OF_SET_VLAN_PCP,
349 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
351 ACTION_OF_POP_MPLS_ETHERTYPE,
353 ACTION_OF_PUSH_MPLS_ETHERTYPE,
360 ACTION_MPLSOGRE_ENCAP,
361 ACTION_MPLSOGRE_DECAP,
362 ACTION_MPLSOUDP_ENCAP,
363 ACTION_MPLSOUDP_DECAP,
365 ACTION_SET_IPV4_SRC_IPV4_SRC,
367 ACTION_SET_IPV4_DST_IPV4_DST,
369 ACTION_SET_IPV6_SRC_IPV6_SRC,
371 ACTION_SET_IPV6_DST_IPV6_DST,
373 ACTION_SET_TP_SRC_TP_SRC,
375 ACTION_SET_TP_DST_TP_DST,
381 ACTION_SET_MAC_SRC_MAC_SRC,
383 ACTION_SET_MAC_DST_MAC_DST,
385 ACTION_INC_TCP_SEQ_VALUE,
387 ACTION_DEC_TCP_SEQ_VALUE,
389 ACTION_INC_TCP_ACK_VALUE,
391 ACTION_DEC_TCP_ACK_VALUE,
394 ACTION_RAW_ENCAP_INDEX,
395 ACTION_RAW_ENCAP_INDEX_VALUE,
396 ACTION_RAW_DECAP_INDEX,
397 ACTION_RAW_DECAP_INDEX_VALUE,
400 ACTION_SET_TAG_INDEX,
403 ACTION_SET_META_DATA,
404 ACTION_SET_META_MASK,
405 ACTION_SET_IPV4_DSCP,
406 ACTION_SET_IPV4_DSCP_VALUE,
407 ACTION_SET_IPV6_DSCP,
408 ACTION_SET_IPV6_DSCP_VALUE,
414 ACTION_SAMPLE_INDEX_VALUE,
416 SHARED_ACTION_ID2PTR,
419 /** Maximum size for pattern in struct rte_flow_item_raw. */
420 #define ITEM_RAW_PATTERN_SIZE 40
422 /** Maximum size for GENEVE option data pattern in bytes. */
423 #define ITEM_GENEVE_OPT_DATA_SIZE 124
425 /** Storage size for struct rte_flow_item_raw including pattern. */
426 #define ITEM_RAW_SIZE \
427 (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE)
429 /** Maximum number of queue indices in struct rte_flow_action_rss. */
430 #define ACTION_RSS_QUEUE_NUM 128
432 /** Storage for struct rte_flow_action_rss including external data. */
433 struct action_rss_data {
434 struct rte_flow_action_rss conf;
435 uint8_t key[RSS_HASH_KEY_LENGTH];
436 uint16_t queue[ACTION_RSS_QUEUE_NUM];
439 /** Maximum data size in struct rte_flow_action_raw_encap. */
440 #define ACTION_RAW_ENCAP_MAX_DATA 512
441 #define RAW_ENCAP_CONFS_MAX_NUM 8
443 /** Storage for struct rte_flow_action_raw_encap. */
444 struct raw_encap_conf {
445 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
446 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
450 struct raw_encap_conf raw_encap_confs[RAW_ENCAP_CONFS_MAX_NUM];
452 /** Storage for struct rte_flow_action_raw_encap including external data. */
453 struct action_raw_encap_data {
454 struct rte_flow_action_raw_encap conf;
455 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
456 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
460 /** Storage for struct rte_flow_action_raw_decap. */
461 struct raw_decap_conf {
462 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
466 struct raw_decap_conf raw_decap_confs[RAW_ENCAP_CONFS_MAX_NUM];
468 /** Storage for struct rte_flow_action_raw_decap including external data. */
469 struct action_raw_decap_data {
470 struct rte_flow_action_raw_decap conf;
471 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
475 struct vxlan_encap_conf vxlan_encap_conf = {
479 .vni = "\x00\x00\x00",
481 .udp_dst = RTE_BE16(RTE_VXLAN_DEFAULT_PORT),
482 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
483 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
484 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
485 "\x00\x00\x00\x00\x00\x00\x00\x01",
486 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
487 "\x00\x00\x00\x00\x00\x00\x11\x11",
491 .eth_src = "\x00\x00\x00\x00\x00\x00",
492 .eth_dst = "\xff\xff\xff\xff\xff\xff",
495 /** Maximum number of items in struct rte_flow_action_vxlan_encap. */
496 #define ACTION_VXLAN_ENCAP_ITEMS_NUM 6
498 /** Storage for struct rte_flow_action_vxlan_encap including external data. */
499 struct action_vxlan_encap_data {
500 struct rte_flow_action_vxlan_encap conf;
501 struct rte_flow_item items[ACTION_VXLAN_ENCAP_ITEMS_NUM];
502 struct rte_flow_item_eth item_eth;
503 struct rte_flow_item_vlan item_vlan;
505 struct rte_flow_item_ipv4 item_ipv4;
506 struct rte_flow_item_ipv6 item_ipv6;
508 struct rte_flow_item_udp item_udp;
509 struct rte_flow_item_vxlan item_vxlan;
512 struct nvgre_encap_conf nvgre_encap_conf = {
515 .tni = "\x00\x00\x00",
516 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
517 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
518 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
519 "\x00\x00\x00\x00\x00\x00\x00\x01",
520 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
521 "\x00\x00\x00\x00\x00\x00\x11\x11",
523 .eth_src = "\x00\x00\x00\x00\x00\x00",
524 .eth_dst = "\xff\xff\xff\xff\xff\xff",
527 /** Maximum number of items in struct rte_flow_action_nvgre_encap. */
528 #define ACTION_NVGRE_ENCAP_ITEMS_NUM 5
530 /** Storage for struct rte_flow_action_nvgre_encap including external data. */
531 struct action_nvgre_encap_data {
532 struct rte_flow_action_nvgre_encap conf;
533 struct rte_flow_item items[ACTION_NVGRE_ENCAP_ITEMS_NUM];
534 struct rte_flow_item_eth item_eth;
535 struct rte_flow_item_vlan item_vlan;
537 struct rte_flow_item_ipv4 item_ipv4;
538 struct rte_flow_item_ipv6 item_ipv6;
540 struct rte_flow_item_nvgre item_nvgre;
543 struct l2_encap_conf l2_encap_conf;
545 struct l2_decap_conf l2_decap_conf;
547 struct mplsogre_encap_conf mplsogre_encap_conf;
549 struct mplsogre_decap_conf mplsogre_decap_conf;
551 struct mplsoudp_encap_conf mplsoudp_encap_conf;
553 struct mplsoudp_decap_conf mplsoudp_decap_conf;
555 #define ACTION_SAMPLE_ACTIONS_NUM 10
556 #define RAW_SAMPLE_CONFS_MAX_NUM 8
557 /** Storage for struct rte_flow_action_sample including external data. */
558 struct action_sample_data {
559 struct rte_flow_action_sample conf;
562 /** Storage for struct rte_flow_action_sample. */
563 struct raw_sample_conf {
564 struct rte_flow_action data[ACTION_SAMPLE_ACTIONS_NUM];
566 struct raw_sample_conf raw_sample_confs[RAW_SAMPLE_CONFS_MAX_NUM];
567 struct rte_flow_action_mark sample_mark[RAW_SAMPLE_CONFS_MAX_NUM];
568 struct rte_flow_action_queue sample_queue[RAW_SAMPLE_CONFS_MAX_NUM];
569 struct rte_flow_action_count sample_count[RAW_SAMPLE_CONFS_MAX_NUM];
570 struct rte_flow_action_port_id sample_port_id[RAW_SAMPLE_CONFS_MAX_NUM];
571 struct rte_flow_action_raw_encap sample_encap[RAW_SAMPLE_CONFS_MAX_NUM];
573 /** Maximum number of subsequent tokens and arguments on the stack. */
574 #define CTX_STACK_SIZE 16
576 /** Parser context. */
578 /** Stack of subsequent token lists to process. */
579 const enum index *next[CTX_STACK_SIZE];
580 /** Arguments for stacked tokens. */
581 const void *args[CTX_STACK_SIZE];
582 enum index curr; /**< Current token index. */
583 enum index prev; /**< Index of the last token seen. */
584 int next_num; /**< Number of entries in next[]. */
585 int args_num; /**< Number of entries in args[]. */
586 uint32_t eol:1; /**< EOL has been detected. */
587 uint32_t last:1; /**< No more arguments. */
588 portid_t port; /**< Current port ID (for completions). */
589 uint32_t objdata; /**< Object-specific data. */
590 void *object; /**< Address of current object for relative offsets. */
591 void *objmask; /**< Object a full mask must be written to. */
594 /** Token argument. */
596 uint32_t hton:1; /**< Use network byte ordering. */
597 uint32_t sign:1; /**< Value is signed. */
598 uint32_t bounded:1; /**< Value is bounded. */
599 uintmax_t min; /**< Minimum value if bounded. */
600 uintmax_t max; /**< Maximum value if bounded. */
601 uint32_t offset; /**< Relative offset from ctx->object. */
602 uint32_t size; /**< Field size. */
603 const uint8_t *mask; /**< Bit-mask to use instead of offset/size. */
606 /** Parser token definition. */
608 /** Type displayed during completion (defaults to "TOKEN"). */
610 /** Help displayed during completion (defaults to token name). */
612 /** Private data used by parser functions. */
615 * Lists of subsequent tokens to push on the stack. Each call to the
616 * parser consumes the last entry of that stack.
618 const enum index *const *next;
619 /** Arguments stack for subsequent tokens that need them. */
620 const struct arg *const *args;
622 * Token-processing callback, returns -1 in case of error, the
623 * length of the matched string otherwise. If NULL, attempts to
624 * match the token name.
626 * If buf is not NULL, the result should be stored in it according
627 * to context. An error is returned if not large enough.
629 int (*call)(struct context *ctx, const struct token *token,
630 const char *str, unsigned int len,
631 void *buf, unsigned int size);
633 * Callback that provides possible values for this token, used for
634 * completion. Returns -1 in case of error, the number of possible
635 * values otherwise. If NULL, the token name is used.
637 * If buf is not NULL, entry index ent is written to buf and the
638 * full length of the entry is returned (same behavior as
641 int (*comp)(struct context *ctx, const struct token *token,
642 unsigned int ent, char *buf, unsigned int size);
643 /** Mandatory token name, no default value. */
647 /** Static initializer for the next field. */
648 #define NEXT(...) (const enum index *const []){ __VA_ARGS__, NULL, }
650 /** Static initializer for a NEXT() entry. */
651 #define NEXT_ENTRY(...) (const enum index []){ __VA_ARGS__, ZERO, }
653 /** Static initializer for the args field. */
654 #define ARGS(...) (const struct arg *const []){ __VA_ARGS__, NULL, }
656 /** Static initializer for ARGS() to target a field. */
657 #define ARGS_ENTRY(s, f) \
658 (&(const struct arg){ \
659 .offset = offsetof(s, f), \
660 .size = sizeof(((s *)0)->f), \
663 /** Static initializer for ARGS() to target a bit-field. */
664 #define ARGS_ENTRY_BF(s, f, b) \
665 (&(const struct arg){ \
667 .mask = (const void *)&(const s){ .f = (1 << (b)) - 1 }, \
670 /** Static initializer for ARGS() to target a field with limits. */
671 #define ARGS_ENTRY_BOUNDED(s, f, i, a) \
672 (&(const struct arg){ \
676 .offset = offsetof(s, f), \
677 .size = sizeof(((s *)0)->f), \
680 /** Static initializer for ARGS() to target an arbitrary bit-mask. */
681 #define ARGS_ENTRY_MASK(s, f, m) \
682 (&(const struct arg){ \
683 .offset = offsetof(s, f), \
684 .size = sizeof(((s *)0)->f), \
685 .mask = (const void *)(m), \
688 /** Same as ARGS_ENTRY_MASK() using network byte ordering for the value. */
689 #define ARGS_ENTRY_MASK_HTON(s, f, m) \
690 (&(const struct arg){ \
692 .offset = offsetof(s, f), \
693 .size = sizeof(((s *)0)->f), \
694 .mask = (const void *)(m), \
697 /** Static initializer for ARGS() to target a pointer. */
698 #define ARGS_ENTRY_PTR(s, f) \
699 (&(const struct arg){ \
700 .size = sizeof(*((s *)0)->f), \
703 /** Static initializer for ARGS() with arbitrary offset and size. */
704 #define ARGS_ENTRY_ARB(o, s) \
705 (&(const struct arg){ \
710 /** Same as ARGS_ENTRY_ARB() with bounded values. */
711 #define ARGS_ENTRY_ARB_BOUNDED(o, s, i, a) \
712 (&(const struct arg){ \
720 /** Same as ARGS_ENTRY() using network byte ordering. */
721 #define ARGS_ENTRY_HTON(s, f) \
722 (&(const struct arg){ \
724 .offset = offsetof(s, f), \
725 .size = sizeof(((s *)0)->f), \
728 /** Same as ARGS_ENTRY_HTON() for a single argument, without structure. */
729 #define ARG_ENTRY_HTON(s) \
730 (&(const struct arg){ \
736 /** Parser output buffer layout expected by cmd_flow_parsed(). */
738 enum index command; /**< Flow command. */
739 portid_t port; /**< Affected port ID. */
743 uint32_t action_id_n;
744 } sa_destroy; /**< Shared action destroy arguments. */
747 } sa; /* Shared action query arguments */
749 struct rte_flow_attr attr;
750 struct tunnel_ops tunnel_ops;
751 struct rte_flow_item *pattern;
752 struct rte_flow_action *actions;
756 } vc; /**< Validate/create arguments. */
760 } destroy; /**< Destroy arguments. */
763 } dump; /**< Dump arguments. */
766 struct rte_flow_action action;
767 } query; /**< Query arguments. */
771 } list; /**< List arguments. */
774 } isolate; /**< Isolated mode arguments. */
777 } aged; /**< Aged arguments. */
778 } args; /**< Command arguments. */
781 /** Private data for pattern items. */
782 struct parse_item_priv {
783 enum rte_flow_item_type type; /**< Item type. */
784 uint32_t size; /**< Size of item specification structure. */
787 #define PRIV_ITEM(t, s) \
788 (&(const struct parse_item_priv){ \
789 .type = RTE_FLOW_ITEM_TYPE_ ## t, \
793 /** Private data for actions. */
794 struct parse_action_priv {
795 enum rte_flow_action_type type; /**< Action type. */
796 uint32_t size; /**< Size of action configuration structure. */
799 #define PRIV_ACTION(t, s) \
800 (&(const struct parse_action_priv){ \
801 .type = RTE_FLOW_ACTION_TYPE_ ## t, \
805 static const enum index next_sa_create_attr[] = {
806 SHARED_ACTION_CREATE_ID,
807 SHARED_ACTION_INGRESS,
808 SHARED_ACTION_EGRESS,
809 SHARED_ACTION_TRANSFER,
814 static const enum index next_sa_subcmd[] = {
815 SHARED_ACTION_CREATE,
816 SHARED_ACTION_UPDATE,
817 SHARED_ACTION_DESTROY,
822 static const enum index next_vc_attr[] = {
834 static const enum index next_destroy_attr[] = {
840 static const enum index next_dump_attr[] = {
846 static const enum index next_list_attr[] = {
852 static const enum index next_aged_attr[] = {
858 static const enum index next_sa_destroy_attr[] = {
859 SHARED_ACTION_DESTROY_ID,
864 static const enum index item_param[] = {
873 static const enum index next_item[] = {
910 ITEM_ICMP6_ND_OPT_SLA_ETH,
911 ITEM_ICMP6_ND_OPT_TLA_ETH,
930 static const enum index item_fuzzy[] = {
936 static const enum index item_any[] = {
942 static const enum index item_vf[] = {
948 static const enum index item_phy_port[] = {
954 static const enum index item_port_id[] = {
960 static const enum index item_mark[] = {
966 static const enum index item_raw[] = {
976 static const enum index item_eth[] = {
985 static const enum index item_vlan[] = {
990 ITEM_VLAN_INNER_TYPE,
991 ITEM_VLAN_HAS_MORE_VLAN,
996 static const enum index item_ipv4[] = {
998 ITEM_IPV4_FRAGMENT_OFFSET,
1007 static const enum index item_ipv6[] = {
1014 ITEM_IPV6_HAS_FRAG_EXT,
1019 static const enum index item_icmp[] = {
1028 static const enum index item_udp[] = {
1035 static const enum index item_tcp[] = {
1043 static const enum index item_sctp[] = {
1052 static const enum index item_vxlan[] = {
1058 static const enum index item_e_tag[] = {
1059 ITEM_E_TAG_GRP_ECID_B,
1064 static const enum index item_nvgre[] = {
1070 static const enum index item_mpls[] = {
1078 static const enum index item_gre[] = {
1080 ITEM_GRE_C_RSVD0_VER,
1088 static const enum index item_gre_key[] = {
1094 static const enum index item_gtp[] = {
1102 static const enum index item_geneve[] = {
1110 static const enum index item_vxlan_gpe[] = {
1116 static const enum index item_arp_eth_ipv4[] = {
1117 ITEM_ARP_ETH_IPV4_SHA,
1118 ITEM_ARP_ETH_IPV4_SPA,
1119 ITEM_ARP_ETH_IPV4_THA,
1120 ITEM_ARP_ETH_IPV4_TPA,
1125 static const enum index item_ipv6_ext[] = {
1126 ITEM_IPV6_EXT_NEXT_HDR,
1131 static const enum index item_ipv6_frag_ext[] = {
1132 ITEM_IPV6_FRAG_EXT_NEXT_HDR,
1133 ITEM_IPV6_FRAG_EXT_FRAG_DATA,
1138 static const enum index item_icmp6[] = {
1145 static const enum index item_icmp6_nd_ns[] = {
1146 ITEM_ICMP6_ND_NS_TARGET_ADDR,
1151 static const enum index item_icmp6_nd_na[] = {
1152 ITEM_ICMP6_ND_NA_TARGET_ADDR,
1157 static const enum index item_icmp6_nd_opt[] = {
1158 ITEM_ICMP6_ND_OPT_TYPE,
1163 static const enum index item_icmp6_nd_opt_sla_eth[] = {
1164 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
1169 static const enum index item_icmp6_nd_opt_tla_eth[] = {
1170 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
1175 static const enum index item_meta[] = {
1181 static const enum index item_gtp_psc[] = {
1188 static const enum index item_pppoed[] = {
1194 static const enum index item_pppoes[] = {
1200 static const enum index item_pppoe_proto_id[] = {
1205 static const enum index item_higig2[] = {
1206 ITEM_HIGIG2_CLASSIFICATION,
1212 static const enum index item_esp[] = {
1218 static const enum index item_ah[] = {
1224 static const enum index item_pfcp[] = {
1231 static const enum index next_set_raw[] = {
1237 static const enum index item_tag[] = {
1244 static const enum index item_l2tpv3oip[] = {
1245 ITEM_L2TPV3OIP_SESSION_ID,
1250 static const enum index item_ecpri[] = {
1256 static const enum index item_ecpri_common[] = {
1257 ITEM_ECPRI_COMMON_TYPE,
1261 static const enum index item_ecpri_common_type[] = {
1262 ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
1263 ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
1264 ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
1268 static const enum index item_geneve_opt[] = {
1269 ITEM_GENEVE_OPT_CLASS,
1270 ITEM_GENEVE_OPT_TYPE,
1271 ITEM_GENEVE_OPT_LENGTH,
1272 ITEM_GENEVE_OPT_DATA,
1277 static const enum index next_action[] = {
1293 ACTION_OF_SET_MPLS_TTL,
1294 ACTION_OF_DEC_MPLS_TTL,
1295 ACTION_OF_SET_NW_TTL,
1296 ACTION_OF_DEC_NW_TTL,
1297 ACTION_OF_COPY_TTL_OUT,
1298 ACTION_OF_COPY_TTL_IN,
1300 ACTION_OF_PUSH_VLAN,
1301 ACTION_OF_SET_VLAN_VID,
1302 ACTION_OF_SET_VLAN_PCP,
1304 ACTION_OF_PUSH_MPLS,
1311 ACTION_MPLSOGRE_ENCAP,
1312 ACTION_MPLSOGRE_DECAP,
1313 ACTION_MPLSOUDP_ENCAP,
1314 ACTION_MPLSOUDP_DECAP,
1315 ACTION_SET_IPV4_SRC,
1316 ACTION_SET_IPV4_DST,
1317 ACTION_SET_IPV6_SRC,
1318 ACTION_SET_IPV6_DST,
1334 ACTION_SET_IPV4_DSCP,
1335 ACTION_SET_IPV6_DSCP,
1342 static const enum index action_mark[] = {
1348 static const enum index action_queue[] = {
1354 static const enum index action_count[] = {
1356 ACTION_COUNT_SHARED,
1361 static const enum index action_rss[] = {
1372 static const enum index action_vf[] = {
1379 static const enum index action_phy_port[] = {
1380 ACTION_PHY_PORT_ORIGINAL,
1381 ACTION_PHY_PORT_INDEX,
1386 static const enum index action_port_id[] = {
1387 ACTION_PORT_ID_ORIGINAL,
1393 static const enum index action_meter[] = {
1399 static const enum index action_of_set_mpls_ttl[] = {
1400 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
1405 static const enum index action_of_set_nw_ttl[] = {
1406 ACTION_OF_SET_NW_TTL_NW_TTL,
1411 static const enum index action_of_push_vlan[] = {
1412 ACTION_OF_PUSH_VLAN_ETHERTYPE,
1417 static const enum index action_of_set_vlan_vid[] = {
1418 ACTION_OF_SET_VLAN_VID_VLAN_VID,
1423 static const enum index action_of_set_vlan_pcp[] = {
1424 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
1429 static const enum index action_of_pop_mpls[] = {
1430 ACTION_OF_POP_MPLS_ETHERTYPE,
1435 static const enum index action_of_push_mpls[] = {
1436 ACTION_OF_PUSH_MPLS_ETHERTYPE,
1441 static const enum index action_set_ipv4_src[] = {
1442 ACTION_SET_IPV4_SRC_IPV4_SRC,
1447 static const enum index action_set_mac_src[] = {
1448 ACTION_SET_MAC_SRC_MAC_SRC,
1453 static const enum index action_set_ipv4_dst[] = {
1454 ACTION_SET_IPV4_DST_IPV4_DST,
1459 static const enum index action_set_ipv6_src[] = {
1460 ACTION_SET_IPV6_SRC_IPV6_SRC,
1465 static const enum index action_set_ipv6_dst[] = {
1466 ACTION_SET_IPV6_DST_IPV6_DST,
1471 static const enum index action_set_tp_src[] = {
1472 ACTION_SET_TP_SRC_TP_SRC,
1477 static const enum index action_set_tp_dst[] = {
1478 ACTION_SET_TP_DST_TP_DST,
1483 static const enum index action_set_ttl[] = {
1489 static const enum index action_jump[] = {
1495 static const enum index action_set_mac_dst[] = {
1496 ACTION_SET_MAC_DST_MAC_DST,
1501 static const enum index action_inc_tcp_seq[] = {
1502 ACTION_INC_TCP_SEQ_VALUE,
1507 static const enum index action_dec_tcp_seq[] = {
1508 ACTION_DEC_TCP_SEQ_VALUE,
1513 static const enum index action_inc_tcp_ack[] = {
1514 ACTION_INC_TCP_ACK_VALUE,
1519 static const enum index action_dec_tcp_ack[] = {
1520 ACTION_DEC_TCP_ACK_VALUE,
1525 static const enum index action_raw_encap[] = {
1526 ACTION_RAW_ENCAP_INDEX,
1531 static const enum index action_raw_decap[] = {
1532 ACTION_RAW_DECAP_INDEX,
1537 static const enum index action_set_tag[] = {
1538 ACTION_SET_TAG_DATA,
1539 ACTION_SET_TAG_INDEX,
1540 ACTION_SET_TAG_MASK,
1545 static const enum index action_set_meta[] = {
1546 ACTION_SET_META_DATA,
1547 ACTION_SET_META_MASK,
1552 static const enum index action_set_ipv4_dscp[] = {
1553 ACTION_SET_IPV4_DSCP_VALUE,
1558 static const enum index action_set_ipv6_dscp[] = {
1559 ACTION_SET_IPV6_DSCP_VALUE,
1564 static const enum index action_age[] = {
1571 static const enum index action_sample[] = {
1573 ACTION_SAMPLE_RATIO,
1574 ACTION_SAMPLE_INDEX,
1579 static const enum index next_action_sample[] = {
1589 static int parse_set_raw_encap_decap(struct context *, const struct token *,
1590 const char *, unsigned int,
1591 void *, unsigned int);
1592 static int parse_set_sample_action(struct context *, const struct token *,
1593 const char *, unsigned int,
1594 void *, unsigned int);
1595 static int parse_set_init(struct context *, const struct token *,
1596 const char *, unsigned int,
1597 void *, unsigned int);
1598 static int parse_init(struct context *, const struct token *,
1599 const char *, unsigned int,
1600 void *, unsigned int);
1601 static int parse_vc(struct context *, const struct token *,
1602 const char *, unsigned int,
1603 void *, unsigned int);
1604 static int parse_vc_spec(struct context *, const struct token *,
1605 const char *, unsigned int, void *, unsigned int);
1606 static int parse_vc_conf(struct context *, const struct token *,
1607 const char *, unsigned int, void *, unsigned int);
1608 static int parse_vc_item_ecpri_type(struct context *, const struct token *,
1609 const char *, unsigned int,
1610 void *, unsigned int);
1611 static int parse_vc_action_rss(struct context *, const struct token *,
1612 const char *, unsigned int, void *,
1614 static int parse_vc_action_rss_func(struct context *, const struct token *,
1615 const char *, unsigned int, void *,
1617 static int parse_vc_action_rss_type(struct context *, const struct token *,
1618 const char *, unsigned int, void *,
1620 static int parse_vc_action_rss_queue(struct context *, const struct token *,
1621 const char *, unsigned int, void *,
1623 static int parse_vc_action_vxlan_encap(struct context *, const struct token *,
1624 const char *, unsigned int, void *,
1626 static int parse_vc_action_nvgre_encap(struct context *, const struct token *,
1627 const char *, unsigned int, void *,
1629 static int parse_vc_action_l2_encap(struct context *, const struct token *,
1630 const char *, unsigned int, void *,
1632 static int parse_vc_action_l2_decap(struct context *, const struct token *,
1633 const char *, unsigned int, void *,
1635 static int parse_vc_action_mplsogre_encap(struct context *,
1636 const struct token *, const char *,
1637 unsigned int, void *, unsigned int);
1638 static int parse_vc_action_mplsogre_decap(struct context *,
1639 const struct token *, const char *,
1640 unsigned int, void *, unsigned int);
1641 static int parse_vc_action_mplsoudp_encap(struct context *,
1642 const struct token *, const char *,
1643 unsigned int, void *, unsigned int);
1644 static int parse_vc_action_mplsoudp_decap(struct context *,
1645 const struct token *, const char *,
1646 unsigned int, void *, unsigned int);
1647 static int parse_vc_action_raw_encap(struct context *,
1648 const struct token *, const char *,
1649 unsigned int, void *, unsigned int);
1650 static int parse_vc_action_raw_decap(struct context *,
1651 const struct token *, const char *,
1652 unsigned int, void *, unsigned int);
1653 static int parse_vc_action_raw_encap_index(struct context *,
1654 const struct token *, const char *,
1655 unsigned int, void *, unsigned int);
1656 static int parse_vc_action_raw_decap_index(struct context *,
1657 const struct token *, const char *,
1658 unsigned int, void *, unsigned int);
1659 static int parse_vc_action_set_meta(struct context *ctx,
1660 const struct token *token, const char *str,
1661 unsigned int len, void *buf,
1663 static int parse_vc_action_sample(struct context *ctx,
1664 const struct token *token, const char *str,
1665 unsigned int len, void *buf,
1668 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
1669 const char *str, unsigned int len, void *buf,
1671 static int parse_destroy(struct context *, const struct token *,
1672 const char *, unsigned int,
1673 void *, unsigned int);
1674 static int parse_flush(struct context *, const struct token *,
1675 const char *, unsigned int,
1676 void *, unsigned int);
1677 static int parse_dump(struct context *, const struct token *,
1678 const char *, unsigned int,
1679 void *, unsigned int);
1680 static int parse_query(struct context *, const struct token *,
1681 const char *, unsigned int,
1682 void *, unsigned int);
1683 static int parse_action(struct context *, const struct token *,
1684 const char *, unsigned int,
1685 void *, unsigned int);
1686 static int parse_list(struct context *, const struct token *,
1687 const char *, unsigned int,
1688 void *, unsigned int);
1689 static int parse_aged(struct context *, const struct token *,
1690 const char *, unsigned int,
1691 void *, unsigned int);
1692 static int parse_isolate(struct context *, const struct token *,
1693 const char *, unsigned int,
1694 void *, unsigned int);
1695 static int parse_tunnel(struct context *, const struct token *,
1696 const char *, unsigned int,
1697 void *, unsigned int);
1698 static int parse_int(struct context *, const struct token *,
1699 const char *, unsigned int,
1700 void *, unsigned int);
1701 static int parse_prefix(struct context *, const struct token *,
1702 const char *, unsigned int,
1703 void *, unsigned int);
1704 static int parse_boolean(struct context *, const struct token *,
1705 const char *, unsigned int,
1706 void *, unsigned int);
1707 static int parse_string(struct context *, const struct token *,
1708 const char *, unsigned int,
1709 void *, unsigned int);
1710 static int parse_hex(struct context *ctx, const struct token *token,
1711 const char *str, unsigned int len,
1712 void *buf, unsigned int size);
1713 static int parse_string0(struct context *, const struct token *,
1714 const char *, unsigned int,
1715 void *, unsigned int);
1716 static int parse_mac_addr(struct context *, const struct token *,
1717 const char *, unsigned int,
1718 void *, unsigned int);
1719 static int parse_ipv4_addr(struct context *, const struct token *,
1720 const char *, unsigned int,
1721 void *, unsigned int);
1722 static int parse_ipv6_addr(struct context *, const struct token *,
1723 const char *, unsigned int,
1724 void *, unsigned int);
1725 static int parse_port(struct context *, const struct token *,
1726 const char *, unsigned int,
1727 void *, unsigned int);
1728 static int parse_sa(struct context *, const struct token *,
1729 const char *, unsigned int,
1730 void *, unsigned int);
1731 static int parse_sa_destroy(struct context *ctx, const struct token *token,
1732 const char *str, unsigned int len,
1733 void *buf, unsigned int size);
1734 static int parse_sa_id2ptr(struct context *ctx, const struct token *token,
1735 const char *str, unsigned int len, void *buf,
1737 static int comp_none(struct context *, const struct token *,
1738 unsigned int, char *, unsigned int);
1739 static int comp_boolean(struct context *, const struct token *,
1740 unsigned int, char *, unsigned int);
1741 static int comp_action(struct context *, const struct token *,
1742 unsigned int, char *, unsigned int);
1743 static int comp_port(struct context *, const struct token *,
1744 unsigned int, char *, unsigned int);
1745 static int comp_rule_id(struct context *, const struct token *,
1746 unsigned int, char *, unsigned int);
1747 static int comp_vc_action_rss_type(struct context *, const struct token *,
1748 unsigned int, char *, unsigned int);
1749 static int comp_vc_action_rss_queue(struct context *, const struct token *,
1750 unsigned int, char *, unsigned int);
1751 static int comp_set_raw_index(struct context *, const struct token *,
1752 unsigned int, char *, unsigned int);
1753 static int comp_set_sample_index(struct context *, const struct token *,
1754 unsigned int, char *, unsigned int);
1756 /** Token definitions. */
1757 static const struct token token_list[] = {
1758 /* Special tokens. */
1761 .help = "null entry, abused as the entry point",
1762 .next = NEXT(NEXT_ENTRY(FLOW)),
1767 .help = "command may end here",
1770 .name = "START_SET",
1771 .help = "null entry, abused as the entry point for set",
1772 .next = NEXT(NEXT_ENTRY(SET)),
1777 .help = "set command may end here",
1779 /* Common tokens. */
1783 .help = "integer value",
1788 .name = "{unsigned}",
1790 .help = "unsigned integer value",
1797 .help = "prefix length for bit-mask",
1798 .call = parse_prefix,
1802 .name = "{boolean}",
1804 .help = "any boolean value",
1805 .call = parse_boolean,
1806 .comp = comp_boolean,
1811 .help = "fixed string",
1812 .call = parse_string,
1818 .help = "fixed string",
1822 .name = "{file path}",
1824 .help = "file path",
1825 .call = parse_string0,
1829 .name = "{MAC address}",
1831 .help = "standard MAC address notation",
1832 .call = parse_mac_addr,
1836 .name = "{IPv4 address}",
1837 .type = "IPV4 ADDRESS",
1838 .help = "standard IPv4 address notation",
1839 .call = parse_ipv4_addr,
1843 .name = "{IPv6 address}",
1844 .type = "IPV6 ADDRESS",
1845 .help = "standard IPv6 address notation",
1846 .call = parse_ipv6_addr,
1850 .name = "{rule id}",
1852 .help = "rule identifier",
1854 .comp = comp_rule_id,
1857 .name = "{port_id}",
1859 .help = "port identifier",
1864 .name = "{group_id}",
1866 .help = "group identifier",
1870 [PRIORITY_LEVEL] = {
1873 .help = "priority level",
1877 [SHARED_ACTION_ID] = {
1878 .name = "{shared_action_id}",
1879 .type = "SHARED_ACTION_ID",
1880 .help = "shared action id",
1884 /* Top-level command. */
1887 .type = "{command} {port_id} [{arg} [...]]",
1888 .help = "manage ingress/egress flow rules",
1889 .next = NEXT(NEXT_ENTRY
1903 /* Top-level command. */
1905 .name = "shared_action",
1906 .type = "{command} {port_id} [{arg} [...]]",
1907 .help = "manage shared actions",
1908 .next = NEXT(next_sa_subcmd, NEXT_ENTRY(PORT_ID)),
1909 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1912 /* Sub-level commands. */
1913 [SHARED_ACTION_CREATE] = {
1915 .help = "create shared action",
1916 .next = NEXT(next_sa_create_attr),
1919 [SHARED_ACTION_UPDATE] = {
1921 .help = "update shared action",
1922 .next = NEXT(NEXT_ENTRY(SHARED_ACTION_SPEC),
1923 NEXT_ENTRY(SHARED_ACTION_ID)),
1924 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
1927 [SHARED_ACTION_DESTROY] = {
1929 .help = "destroy shared action",
1930 .next = NEXT(NEXT_ENTRY(SHARED_ACTION_DESTROY_ID)),
1931 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1932 .call = parse_sa_destroy,
1934 [SHARED_ACTION_QUERY] = {
1936 .help = "query shared action",
1937 .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(SHARED_ACTION_ID)),
1938 .args = ARGS(ARGS_ENTRY(struct buffer, args.sa.action_id)),
1943 .help = "check whether a flow rule can be created",
1944 .next = NEXT(next_vc_attr, NEXT_ENTRY(PORT_ID)),
1945 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1950 .help = "create a flow rule",
1951 .next = NEXT(next_vc_attr, NEXT_ENTRY(PORT_ID)),
1952 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1957 .help = "destroy specific flow rules",
1958 .next = NEXT(NEXT_ENTRY(DESTROY_RULE), NEXT_ENTRY(PORT_ID)),
1959 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1960 .call = parse_destroy,
1964 .help = "destroy all flow rules",
1965 .next = NEXT(NEXT_ENTRY(PORT_ID)),
1966 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1967 .call = parse_flush,
1971 .help = "dump all flow rules to file",
1972 .next = NEXT(next_dump_attr, NEXT_ENTRY(PORT_ID)),
1973 .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file),
1974 ARGS_ENTRY(struct buffer, port)),
1979 .help = "query an existing flow rule",
1980 .next = NEXT(NEXT_ENTRY(QUERY_ACTION),
1981 NEXT_ENTRY(RULE_ID),
1982 NEXT_ENTRY(PORT_ID)),
1983 .args = ARGS(ARGS_ENTRY(struct buffer, args.query.action.type),
1984 ARGS_ENTRY(struct buffer, args.query.rule),
1985 ARGS_ENTRY(struct buffer, port)),
1986 .call = parse_query,
1990 .help = "list existing flow rules",
1991 .next = NEXT(next_list_attr, NEXT_ENTRY(PORT_ID)),
1992 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1997 .help = "list and destroy aged flows",
1998 .next = NEXT(next_aged_attr, NEXT_ENTRY(PORT_ID)),
1999 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2004 .help = "restrict ingress traffic to the defined flow rules",
2005 .next = NEXT(NEXT_ENTRY(BOOLEAN),
2006 NEXT_ENTRY(PORT_ID)),
2007 .args = ARGS(ARGS_ENTRY(struct buffer, args.isolate.set),
2008 ARGS_ENTRY(struct buffer, port)),
2009 .call = parse_isolate,
2013 .help = "new tunnel API",
2014 .next = NEXT(NEXT_ENTRY
2015 (TUNNEL_CREATE, TUNNEL_LIST, TUNNEL_DESTROY)),
2016 .call = parse_tunnel,
2018 /* Tunnel arguments. */
2021 .help = "create new tunnel object",
2022 .next = NEXT(NEXT_ENTRY(TUNNEL_CREATE_TYPE),
2023 NEXT_ENTRY(PORT_ID)),
2024 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2025 .call = parse_tunnel,
2027 [TUNNEL_CREATE_TYPE] = {
2029 .help = "create new tunnel",
2030 .next = NEXT(NEXT_ENTRY(FILE_PATH)),
2031 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, type)),
2032 .call = parse_tunnel,
2034 [TUNNEL_DESTROY] = {
2036 .help = "destroy tunel",
2037 .next = NEXT(NEXT_ENTRY(TUNNEL_DESTROY_ID),
2038 NEXT_ENTRY(PORT_ID)),
2039 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2040 .call = parse_tunnel,
2042 [TUNNEL_DESTROY_ID] = {
2044 .help = "tunnel identifier to testroy",
2045 .next = NEXT(NEXT_ENTRY(UNSIGNED)),
2046 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2047 .call = parse_tunnel,
2051 .help = "list existing tunnels",
2052 .next = NEXT(NEXT_ENTRY(PORT_ID)),
2053 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2054 .call = parse_tunnel,
2056 /* Destroy arguments. */
2059 .help = "specify a rule identifier",
2060 .next = NEXT(next_destroy_attr, NEXT_ENTRY(RULE_ID)),
2061 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.destroy.rule)),
2062 .call = parse_destroy,
2064 /* Query arguments. */
2068 .help = "action to query, must be part of the rule",
2069 .call = parse_action,
2070 .comp = comp_action,
2072 /* List arguments. */
2075 .help = "specify a group",
2076 .next = NEXT(next_list_attr, NEXT_ENTRY(GROUP_ID)),
2077 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.list.group)),
2082 .help = "specify aged flows need be destroyed",
2086 /* Validate/create attributes. */
2089 .help = "specify a group",
2090 .next = NEXT(next_vc_attr, NEXT_ENTRY(GROUP_ID)),
2091 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, group)),
2096 .help = "specify a priority level",
2097 .next = NEXT(next_vc_attr, NEXT_ENTRY(PRIORITY_LEVEL)),
2098 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, priority)),
2103 .help = "affect rule to ingress",
2104 .next = NEXT(next_vc_attr),
2109 .help = "affect rule to egress",
2110 .next = NEXT(next_vc_attr),
2115 .help = "apply rule directly to endpoints found in pattern",
2116 .next = NEXT(next_vc_attr),
2120 .name = "tunnel_set",
2121 .help = "tunnel steer rule",
2122 .next = NEXT(next_vc_attr, NEXT_ENTRY(UNSIGNED)),
2123 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2127 .name = "tunnel_match",
2128 .help = "tunnel match rule",
2129 .next = NEXT(next_vc_attr, NEXT_ENTRY(UNSIGNED)),
2130 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2133 /* Validate/create pattern. */
2136 .help = "submit a list of pattern items",
2137 .next = NEXT(next_item),
2142 .help = "match value perfectly (with full bit-mask)",
2143 .call = parse_vc_spec,
2145 [ITEM_PARAM_SPEC] = {
2147 .help = "match value according to configured bit-mask",
2148 .call = parse_vc_spec,
2150 [ITEM_PARAM_LAST] = {
2152 .help = "specify upper bound to establish a range",
2153 .call = parse_vc_spec,
2155 [ITEM_PARAM_MASK] = {
2157 .help = "specify bit-mask with relevant bits set to one",
2158 .call = parse_vc_spec,
2160 [ITEM_PARAM_PREFIX] = {
2162 .help = "generate bit-mask from a prefix length",
2163 .call = parse_vc_spec,
2167 .help = "specify next pattern item",
2168 .next = NEXT(next_item),
2172 .help = "end list of pattern items",
2173 .priv = PRIV_ITEM(END, 0),
2174 .next = NEXT(NEXT_ENTRY(ACTIONS)),
2179 .help = "no-op pattern item",
2180 .priv = PRIV_ITEM(VOID, 0),
2181 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2186 .help = "perform actions when pattern does not match",
2187 .priv = PRIV_ITEM(INVERT, 0),
2188 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2193 .help = "match any protocol for the current layer",
2194 .priv = PRIV_ITEM(ANY, sizeof(struct rte_flow_item_any)),
2195 .next = NEXT(item_any),
2200 .help = "number of layers covered",
2201 .next = NEXT(item_any, NEXT_ENTRY(UNSIGNED), item_param),
2202 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_any, num)),
2206 .help = "match traffic from/to the physical function",
2207 .priv = PRIV_ITEM(PF, 0),
2208 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2213 .help = "match traffic from/to a virtual function ID",
2214 .priv = PRIV_ITEM(VF, sizeof(struct rte_flow_item_vf)),
2215 .next = NEXT(item_vf),
2221 .next = NEXT(item_vf, NEXT_ENTRY(UNSIGNED), item_param),
2222 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_vf, id)),
2226 .help = "match traffic from/to a specific physical port",
2227 .priv = PRIV_ITEM(PHY_PORT,
2228 sizeof(struct rte_flow_item_phy_port)),
2229 .next = NEXT(item_phy_port),
2232 [ITEM_PHY_PORT_INDEX] = {
2234 .help = "physical port index",
2235 .next = NEXT(item_phy_port, NEXT_ENTRY(UNSIGNED), item_param),
2236 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_phy_port, index)),
2240 .help = "match traffic from/to a given DPDK port ID",
2241 .priv = PRIV_ITEM(PORT_ID,
2242 sizeof(struct rte_flow_item_port_id)),
2243 .next = NEXT(item_port_id),
2246 [ITEM_PORT_ID_ID] = {
2248 .help = "DPDK port ID",
2249 .next = NEXT(item_port_id, NEXT_ENTRY(UNSIGNED), item_param),
2250 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port_id, id)),
2254 .help = "match traffic against value set in previously matched rule",
2255 .priv = PRIV_ITEM(MARK, sizeof(struct rte_flow_item_mark)),
2256 .next = NEXT(item_mark),
2261 .help = "Integer value to match against",
2262 .next = NEXT(item_mark, NEXT_ENTRY(UNSIGNED), item_param),
2263 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_mark, id)),
2267 .help = "match an arbitrary byte string",
2268 .priv = PRIV_ITEM(RAW, ITEM_RAW_SIZE),
2269 .next = NEXT(item_raw),
2272 [ITEM_RAW_RELATIVE] = {
2274 .help = "look for pattern after the previous item",
2275 .next = NEXT(item_raw, NEXT_ENTRY(BOOLEAN), item_param),
2276 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
2279 [ITEM_RAW_SEARCH] = {
2281 .help = "search pattern from offset (see also limit)",
2282 .next = NEXT(item_raw, NEXT_ENTRY(BOOLEAN), item_param),
2283 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
2286 [ITEM_RAW_OFFSET] = {
2288 .help = "absolute or relative offset for pattern",
2289 .next = NEXT(item_raw, NEXT_ENTRY(INTEGER), item_param),
2290 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, offset)),
2292 [ITEM_RAW_LIMIT] = {
2294 .help = "search area limit for start of pattern",
2295 .next = NEXT(item_raw, NEXT_ENTRY(UNSIGNED), item_param),
2296 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, limit)),
2298 [ITEM_RAW_PATTERN] = {
2300 .help = "byte string to look for",
2301 .next = NEXT(item_raw,
2303 NEXT_ENTRY(ITEM_PARAM_IS,
2306 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern),
2307 ARGS_ENTRY(struct rte_flow_item_raw, length),
2308 ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw),
2309 ITEM_RAW_PATTERN_SIZE)),
2313 .help = "match Ethernet header",
2314 .priv = PRIV_ITEM(ETH, sizeof(struct rte_flow_item_eth)),
2315 .next = NEXT(item_eth),
2320 .help = "destination MAC",
2321 .next = NEXT(item_eth, NEXT_ENTRY(MAC_ADDR), item_param),
2322 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, dst)),
2326 .help = "source MAC",
2327 .next = NEXT(item_eth, NEXT_ENTRY(MAC_ADDR), item_param),
2328 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, src)),
2332 .help = "EtherType",
2333 .next = NEXT(item_eth, NEXT_ENTRY(UNSIGNED), item_param),
2334 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, type)),
2336 [ITEM_ETH_HAS_VLAN] = {
2338 .help = "packet header contains VLAN",
2339 .next = NEXT(item_eth, NEXT_ENTRY(UNSIGNED), item_param),
2340 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_eth,
2345 .help = "match 802.1Q/ad VLAN tag",
2346 .priv = PRIV_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)),
2347 .next = NEXT(item_vlan),
2352 .help = "tag control information",
2353 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2354 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, tci)),
2358 .help = "priority code point",
2359 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2360 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2365 .help = "drop eligible indicator",
2366 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2367 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2372 .help = "VLAN identifier",
2373 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2374 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2377 [ITEM_VLAN_INNER_TYPE] = {
2378 .name = "inner_type",
2379 .help = "inner EtherType",
2380 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2381 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan,
2384 [ITEM_VLAN_HAS_MORE_VLAN] = {
2385 .name = "has_more_vlan",
2386 .help = "packet header contains another VLAN",
2387 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2388 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vlan,
2393 .help = "match IPv4 header",
2394 .priv = PRIV_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)),
2395 .next = NEXT(item_ipv4),
2400 .help = "type of service",
2401 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2402 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2403 hdr.type_of_service)),
2405 [ITEM_IPV4_FRAGMENT_OFFSET] = {
2406 .name = "fragment_offset",
2407 .help = "fragmentation flags and fragment offset",
2408 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2409 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2410 hdr.fragment_offset)),
2414 .help = "time to live",
2415 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2416 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2419 [ITEM_IPV4_PROTO] = {
2421 .help = "next protocol ID",
2422 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2423 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2424 hdr.next_proto_id)),
2428 .help = "source address",
2429 .next = NEXT(item_ipv4, NEXT_ENTRY(IPV4_ADDR), item_param),
2430 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2435 .help = "destination address",
2436 .next = NEXT(item_ipv4, NEXT_ENTRY(IPV4_ADDR), item_param),
2437 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2442 .help = "match IPv6 header",
2443 .priv = PRIV_ITEM(IPV6, sizeof(struct rte_flow_item_ipv6)),
2444 .next = NEXT(item_ipv6),
2449 .help = "traffic class",
2450 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2451 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2453 "\x0f\xf0\x00\x00")),
2455 [ITEM_IPV6_FLOW] = {
2457 .help = "flow label",
2458 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2459 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2461 "\x00\x0f\xff\xff")),
2463 [ITEM_IPV6_PROTO] = {
2465 .help = "protocol (next header)",
2466 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2467 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2472 .help = "hop limit",
2473 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2474 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2479 .help = "source address",
2480 .next = NEXT(item_ipv6, NEXT_ENTRY(IPV6_ADDR), item_param),
2481 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2486 .help = "destination address",
2487 .next = NEXT(item_ipv6, NEXT_ENTRY(IPV6_ADDR), item_param),
2488 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2491 [ITEM_IPV6_HAS_FRAG_EXT] = {
2492 .name = "has_frag_ext",
2493 .help = "fragment packet attribute",
2494 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2495 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_ipv6,
2500 .help = "match ICMP header",
2501 .priv = PRIV_ITEM(ICMP, sizeof(struct rte_flow_item_icmp)),
2502 .next = NEXT(item_icmp),
2505 [ITEM_ICMP_TYPE] = {
2507 .help = "ICMP packet type",
2508 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2509 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2512 [ITEM_ICMP_CODE] = {
2514 .help = "ICMP packet code",
2515 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2516 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2519 [ITEM_ICMP_IDENT] = {
2521 .help = "ICMP packet identifier",
2522 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2523 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2528 .help = "ICMP packet sequence number",
2529 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2530 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2535 .help = "match UDP header",
2536 .priv = PRIV_ITEM(UDP, sizeof(struct rte_flow_item_udp)),
2537 .next = NEXT(item_udp),
2542 .help = "UDP source port",
2543 .next = NEXT(item_udp, NEXT_ENTRY(UNSIGNED), item_param),
2544 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2549 .help = "UDP destination port",
2550 .next = NEXT(item_udp, NEXT_ENTRY(UNSIGNED), item_param),
2551 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2556 .help = "match TCP header",
2557 .priv = PRIV_ITEM(TCP, sizeof(struct rte_flow_item_tcp)),
2558 .next = NEXT(item_tcp),
2563 .help = "TCP source port",
2564 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2565 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2570 .help = "TCP destination port",
2571 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2572 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2575 [ITEM_TCP_FLAGS] = {
2577 .help = "TCP flags",
2578 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2579 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2584 .help = "match SCTP header",
2585 .priv = PRIV_ITEM(SCTP, sizeof(struct rte_flow_item_sctp)),
2586 .next = NEXT(item_sctp),
2591 .help = "SCTP source port",
2592 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2593 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2598 .help = "SCTP destination port",
2599 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2600 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2605 .help = "validation tag",
2606 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2607 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2610 [ITEM_SCTP_CKSUM] = {
2613 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2614 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2619 .help = "match VXLAN header",
2620 .priv = PRIV_ITEM(VXLAN, sizeof(struct rte_flow_item_vxlan)),
2621 .next = NEXT(item_vxlan),
2624 [ITEM_VXLAN_VNI] = {
2626 .help = "VXLAN identifier",
2627 .next = NEXT(item_vxlan, NEXT_ENTRY(UNSIGNED), item_param),
2628 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan, vni)),
2632 .help = "match E-Tag header",
2633 .priv = PRIV_ITEM(E_TAG, sizeof(struct rte_flow_item_e_tag)),
2634 .next = NEXT(item_e_tag),
2637 [ITEM_E_TAG_GRP_ECID_B] = {
2638 .name = "grp_ecid_b",
2639 .help = "GRP and E-CID base",
2640 .next = NEXT(item_e_tag, NEXT_ENTRY(UNSIGNED), item_param),
2641 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_e_tag,
2647 .help = "match NVGRE header",
2648 .priv = PRIV_ITEM(NVGRE, sizeof(struct rte_flow_item_nvgre)),
2649 .next = NEXT(item_nvgre),
2652 [ITEM_NVGRE_TNI] = {
2654 .help = "virtual subnet ID",
2655 .next = NEXT(item_nvgre, NEXT_ENTRY(UNSIGNED), item_param),
2656 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_nvgre, tni)),
2660 .help = "match MPLS header",
2661 .priv = PRIV_ITEM(MPLS, sizeof(struct rte_flow_item_mpls)),
2662 .next = NEXT(item_mpls),
2665 [ITEM_MPLS_LABEL] = {
2667 .help = "MPLS label",
2668 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2669 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2675 .help = "MPLS Traffic Class",
2676 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2677 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2683 .help = "MPLS Bottom-of-Stack",
2684 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2685 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2691 .help = "match GRE header",
2692 .priv = PRIV_ITEM(GRE, sizeof(struct rte_flow_item_gre)),
2693 .next = NEXT(item_gre),
2696 [ITEM_GRE_PROTO] = {
2698 .help = "GRE protocol type",
2699 .next = NEXT(item_gre, NEXT_ENTRY(UNSIGNED), item_param),
2700 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2703 [ITEM_GRE_C_RSVD0_VER] = {
2704 .name = "c_rsvd0_ver",
2706 "checksum (1b), undefined (1b), key bit (1b),"
2707 " sequence number (1b), reserved 0 (9b),"
2709 .next = NEXT(item_gre, NEXT_ENTRY(UNSIGNED), item_param),
2710 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2713 [ITEM_GRE_C_BIT] = {
2715 .help = "checksum bit (C)",
2716 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2717 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2719 "\x80\x00\x00\x00")),
2721 [ITEM_GRE_S_BIT] = {
2723 .help = "sequence number bit (S)",
2724 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2725 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2727 "\x10\x00\x00\x00")),
2729 [ITEM_GRE_K_BIT] = {
2731 .help = "key bit (K)",
2732 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2733 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2735 "\x20\x00\x00\x00")),
2739 .help = "fuzzy pattern match, expect faster than default",
2740 .priv = PRIV_ITEM(FUZZY,
2741 sizeof(struct rte_flow_item_fuzzy)),
2742 .next = NEXT(item_fuzzy),
2745 [ITEM_FUZZY_THRESH] = {
2747 .help = "match accuracy threshold",
2748 .next = NEXT(item_fuzzy, NEXT_ENTRY(UNSIGNED), item_param),
2749 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_fuzzy,
2754 .help = "match GTP header",
2755 .priv = PRIV_ITEM(GTP, sizeof(struct rte_flow_item_gtp)),
2756 .next = NEXT(item_gtp),
2759 [ITEM_GTP_FLAGS] = {
2760 .name = "v_pt_rsv_flags",
2761 .help = "GTP flags",
2762 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2763 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp,
2766 [ITEM_GTP_MSG_TYPE] = {
2768 .help = "GTP message type",
2769 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2770 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp, msg_type)),
2774 .help = "tunnel endpoint identifier",
2775 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2776 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp, teid)),
2780 .help = "match GTP header",
2781 .priv = PRIV_ITEM(GTPC, sizeof(struct rte_flow_item_gtp)),
2782 .next = NEXT(item_gtp),
2787 .help = "match GTP header",
2788 .priv = PRIV_ITEM(GTPU, sizeof(struct rte_flow_item_gtp)),
2789 .next = NEXT(item_gtp),
2794 .help = "match GENEVE header",
2795 .priv = PRIV_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)),
2796 .next = NEXT(item_geneve),
2799 [ITEM_GENEVE_VNI] = {
2801 .help = "virtual network identifier",
2802 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2803 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve, vni)),
2805 [ITEM_GENEVE_PROTO] = {
2807 .help = "GENEVE protocol type",
2808 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2809 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve,
2812 [ITEM_GENEVE_OPTLEN] = {
2814 .help = "GENEVE options length in dwords",
2815 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2816 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_geneve,
2817 ver_opt_len_o_c_rsvd0,
2820 [ITEM_VXLAN_GPE] = {
2821 .name = "vxlan-gpe",
2822 .help = "match VXLAN-GPE header",
2823 .priv = PRIV_ITEM(VXLAN_GPE,
2824 sizeof(struct rte_flow_item_vxlan_gpe)),
2825 .next = NEXT(item_vxlan_gpe),
2828 [ITEM_VXLAN_GPE_VNI] = {
2830 .help = "VXLAN-GPE identifier",
2831 .next = NEXT(item_vxlan_gpe, NEXT_ENTRY(UNSIGNED), item_param),
2832 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
2835 [ITEM_ARP_ETH_IPV4] = {
2836 .name = "arp_eth_ipv4",
2837 .help = "match ARP header for Ethernet/IPv4",
2838 .priv = PRIV_ITEM(ARP_ETH_IPV4,
2839 sizeof(struct rte_flow_item_arp_eth_ipv4)),
2840 .next = NEXT(item_arp_eth_ipv4),
2843 [ITEM_ARP_ETH_IPV4_SHA] = {
2845 .help = "sender hardware address",
2846 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(MAC_ADDR),
2848 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2851 [ITEM_ARP_ETH_IPV4_SPA] = {
2853 .help = "sender IPv4 address",
2854 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(IPV4_ADDR),
2856 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2859 [ITEM_ARP_ETH_IPV4_THA] = {
2861 .help = "target hardware address",
2862 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(MAC_ADDR),
2864 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2867 [ITEM_ARP_ETH_IPV4_TPA] = {
2869 .help = "target IPv4 address",
2870 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(IPV4_ADDR),
2872 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2877 .help = "match presence of any IPv6 extension header",
2878 .priv = PRIV_ITEM(IPV6_EXT,
2879 sizeof(struct rte_flow_item_ipv6_ext)),
2880 .next = NEXT(item_ipv6_ext),
2883 [ITEM_IPV6_EXT_NEXT_HDR] = {
2885 .help = "next header",
2886 .next = NEXT(item_ipv6_ext, NEXT_ENTRY(UNSIGNED), item_param),
2887 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_ext,
2890 [ITEM_IPV6_FRAG_EXT] = {
2891 .name = "ipv6_frag_ext",
2892 .help = "match presence of IPv6 fragment extension header",
2893 .priv = PRIV_ITEM(IPV6_FRAG_EXT,
2894 sizeof(struct rte_flow_item_ipv6_frag_ext)),
2895 .next = NEXT(item_ipv6_frag_ext),
2898 [ITEM_IPV6_FRAG_EXT_NEXT_HDR] = {
2900 .help = "next header",
2901 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(UNSIGNED),
2903 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ipv6_frag_ext,
2906 [ITEM_IPV6_FRAG_EXT_FRAG_DATA] = {
2907 .name = "frag_data",
2908 .help = "Fragment flags and offset",
2909 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(UNSIGNED),
2911 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_frag_ext,
2916 .help = "match any ICMPv6 header",
2917 .priv = PRIV_ITEM(ICMP6, sizeof(struct rte_flow_item_icmp6)),
2918 .next = NEXT(item_icmp6),
2921 [ITEM_ICMP6_TYPE] = {
2923 .help = "ICMPv6 type",
2924 .next = NEXT(item_icmp6, NEXT_ENTRY(UNSIGNED), item_param),
2925 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
2928 [ITEM_ICMP6_CODE] = {
2930 .help = "ICMPv6 code",
2931 .next = NEXT(item_icmp6, NEXT_ENTRY(UNSIGNED), item_param),
2932 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
2935 [ITEM_ICMP6_ND_NS] = {
2936 .name = "icmp6_nd_ns",
2937 .help = "match ICMPv6 neighbor discovery solicitation",
2938 .priv = PRIV_ITEM(ICMP6_ND_NS,
2939 sizeof(struct rte_flow_item_icmp6_nd_ns)),
2940 .next = NEXT(item_icmp6_nd_ns),
2943 [ITEM_ICMP6_ND_NS_TARGET_ADDR] = {
2944 .name = "target_addr",
2945 .help = "target address",
2946 .next = NEXT(item_icmp6_nd_ns, NEXT_ENTRY(IPV6_ADDR),
2948 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_ns,
2951 [ITEM_ICMP6_ND_NA] = {
2952 .name = "icmp6_nd_na",
2953 .help = "match ICMPv6 neighbor discovery advertisement",
2954 .priv = PRIV_ITEM(ICMP6_ND_NA,
2955 sizeof(struct rte_flow_item_icmp6_nd_na)),
2956 .next = NEXT(item_icmp6_nd_na),
2959 [ITEM_ICMP6_ND_NA_TARGET_ADDR] = {
2960 .name = "target_addr",
2961 .help = "target address",
2962 .next = NEXT(item_icmp6_nd_na, NEXT_ENTRY(IPV6_ADDR),
2964 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_na,
2967 [ITEM_ICMP6_ND_OPT] = {
2968 .name = "icmp6_nd_opt",
2969 .help = "match presence of any ICMPv6 neighbor discovery"
2971 .priv = PRIV_ITEM(ICMP6_ND_OPT,
2972 sizeof(struct rte_flow_item_icmp6_nd_opt)),
2973 .next = NEXT(item_icmp6_nd_opt),
2976 [ITEM_ICMP6_ND_OPT_TYPE] = {
2978 .help = "ND option type",
2979 .next = NEXT(item_icmp6_nd_opt, NEXT_ENTRY(UNSIGNED),
2981 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_opt,
2984 [ITEM_ICMP6_ND_OPT_SLA_ETH] = {
2985 .name = "icmp6_nd_opt_sla_eth",
2986 .help = "match ICMPv6 neighbor discovery source Ethernet"
2987 " link-layer address option",
2989 (ICMP6_ND_OPT_SLA_ETH,
2990 sizeof(struct rte_flow_item_icmp6_nd_opt_sla_eth)),
2991 .next = NEXT(item_icmp6_nd_opt_sla_eth),
2994 [ITEM_ICMP6_ND_OPT_SLA_ETH_SLA] = {
2996 .help = "source Ethernet LLA",
2997 .next = NEXT(item_icmp6_nd_opt_sla_eth, NEXT_ENTRY(MAC_ADDR),
2999 .args = ARGS(ARGS_ENTRY_HTON
3000 (struct rte_flow_item_icmp6_nd_opt_sla_eth, sla)),
3002 [ITEM_ICMP6_ND_OPT_TLA_ETH] = {
3003 .name = "icmp6_nd_opt_tla_eth",
3004 .help = "match ICMPv6 neighbor discovery target Ethernet"
3005 " link-layer address option",
3007 (ICMP6_ND_OPT_TLA_ETH,
3008 sizeof(struct rte_flow_item_icmp6_nd_opt_tla_eth)),
3009 .next = NEXT(item_icmp6_nd_opt_tla_eth),
3012 [ITEM_ICMP6_ND_OPT_TLA_ETH_TLA] = {
3014 .help = "target Ethernet LLA",
3015 .next = NEXT(item_icmp6_nd_opt_tla_eth, NEXT_ENTRY(MAC_ADDR),
3017 .args = ARGS(ARGS_ENTRY_HTON
3018 (struct rte_flow_item_icmp6_nd_opt_tla_eth, tla)),
3022 .help = "match metadata header",
3023 .priv = PRIV_ITEM(META, sizeof(struct rte_flow_item_meta)),
3024 .next = NEXT(item_meta),
3027 [ITEM_META_DATA] = {
3029 .help = "metadata value",
3030 .next = NEXT(item_meta, NEXT_ENTRY(UNSIGNED), item_param),
3031 .args = ARGS(ARGS_ENTRY_MASK(struct rte_flow_item_meta,
3032 data, "\xff\xff\xff\xff")),
3036 .help = "match GRE key",
3037 .priv = PRIV_ITEM(GRE_KEY, sizeof(rte_be32_t)),
3038 .next = NEXT(item_gre_key),
3041 [ITEM_GRE_KEY_VALUE] = {
3043 .help = "key value",
3044 .next = NEXT(item_gre_key, NEXT_ENTRY(UNSIGNED), item_param),
3045 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3049 .help = "match GTP extension header with type 0x85",
3050 .priv = PRIV_ITEM(GTP_PSC,
3051 sizeof(struct rte_flow_item_gtp_psc)),
3052 .next = NEXT(item_gtp_psc),
3055 [ITEM_GTP_PSC_QFI] = {
3057 .help = "QoS flow identifier",
3058 .next = NEXT(item_gtp_psc, NEXT_ENTRY(UNSIGNED), item_param),
3059 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
3062 [ITEM_GTP_PSC_PDU_T] = {
3065 .next = NEXT(item_gtp_psc, NEXT_ENTRY(UNSIGNED), item_param),
3066 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
3071 .help = "match PPPoE session header",
3072 .priv = PRIV_ITEM(PPPOES, sizeof(struct rte_flow_item_pppoe)),
3073 .next = NEXT(item_pppoes),
3078 .help = "match PPPoE discovery header",
3079 .priv = PRIV_ITEM(PPPOED, sizeof(struct rte_flow_item_pppoe)),
3080 .next = NEXT(item_pppoed),
3083 [ITEM_PPPOE_SEID] = {
3085 .help = "session identifier",
3086 .next = NEXT(item_pppoes, NEXT_ENTRY(UNSIGNED), item_param),
3087 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pppoe,
3090 [ITEM_PPPOE_PROTO_ID] = {
3091 .name = "pppoe_proto_id",
3092 .help = "match PPPoE session protocol identifier",
3093 .priv = PRIV_ITEM(PPPOE_PROTO_ID,
3094 sizeof(struct rte_flow_item_pppoe_proto_id)),
3095 .next = NEXT(item_pppoe_proto_id, NEXT_ENTRY(UNSIGNED),
3097 .args = ARGS(ARGS_ENTRY_HTON
3098 (struct rte_flow_item_pppoe_proto_id, proto_id)),
3103 .help = "matches higig2 header",
3104 .priv = PRIV_ITEM(HIGIG2,
3105 sizeof(struct rte_flow_item_higig2_hdr)),
3106 .next = NEXT(item_higig2),
3109 [ITEM_HIGIG2_CLASSIFICATION] = {
3110 .name = "classification",
3111 .help = "matches classification of higig2 header",
3112 .next = NEXT(item_higig2, NEXT_ENTRY(UNSIGNED), item_param),
3113 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
3114 hdr.ppt1.classification)),
3116 [ITEM_HIGIG2_VID] = {
3118 .help = "matches vid of higig2 header",
3119 .next = NEXT(item_higig2, NEXT_ENTRY(UNSIGNED), item_param),
3120 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
3125 .help = "match tag value",
3126 .priv = PRIV_ITEM(TAG, sizeof(struct rte_flow_item_tag)),
3127 .next = NEXT(item_tag),
3132 .help = "tag value to match",
3133 .next = NEXT(item_tag, NEXT_ENTRY(UNSIGNED), item_param),
3134 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, data)),
3136 [ITEM_TAG_INDEX] = {
3138 .help = "index of tag array to match",
3139 .next = NEXT(item_tag, NEXT_ENTRY(UNSIGNED),
3140 NEXT_ENTRY(ITEM_PARAM_IS)),
3141 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, index)),
3143 [ITEM_L2TPV3OIP] = {
3144 .name = "l2tpv3oip",
3145 .help = "match L2TPv3 over IP header",
3146 .priv = PRIV_ITEM(L2TPV3OIP,
3147 sizeof(struct rte_flow_item_l2tpv3oip)),
3148 .next = NEXT(item_l2tpv3oip),
3151 [ITEM_L2TPV3OIP_SESSION_ID] = {
3152 .name = "session_id",
3153 .help = "session identifier",
3154 .next = NEXT(item_l2tpv3oip, NEXT_ENTRY(UNSIGNED), item_param),
3155 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv3oip,
3160 .help = "match ESP header",
3161 .priv = PRIV_ITEM(ESP, sizeof(struct rte_flow_item_esp)),
3162 .next = NEXT(item_esp),
3167 .help = "security policy index",
3168 .next = NEXT(item_esp, NEXT_ENTRY(UNSIGNED), item_param),
3169 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_esp,
3174 .help = "match AH header",
3175 .priv = PRIV_ITEM(AH, sizeof(struct rte_flow_item_ah)),
3176 .next = NEXT(item_ah),
3181 .help = "security parameters index",
3182 .next = NEXT(item_ah, NEXT_ENTRY(UNSIGNED), item_param),
3183 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ah, spi)),
3187 .help = "match pfcp header",
3188 .priv = PRIV_ITEM(PFCP, sizeof(struct rte_flow_item_pfcp)),
3189 .next = NEXT(item_pfcp),
3192 [ITEM_PFCP_S_FIELD] = {
3195 .next = NEXT(item_pfcp, NEXT_ENTRY(UNSIGNED), item_param),
3196 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp,
3199 [ITEM_PFCP_SEID] = {
3201 .help = "session endpoint identifier",
3202 .next = NEXT(item_pfcp, NEXT_ENTRY(UNSIGNED), item_param),
3203 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp, seid)),
3207 .help = "match eCPRI header",
3208 .priv = PRIV_ITEM(ECPRI, sizeof(struct rte_flow_item_ecpri)),
3209 .next = NEXT(item_ecpri),
3212 [ITEM_ECPRI_COMMON] = {
3214 .help = "eCPRI common header",
3215 .next = NEXT(item_ecpri_common),
3217 [ITEM_ECPRI_COMMON_TYPE] = {
3219 .help = "type of common header",
3220 .next = NEXT(item_ecpri_common_type),
3221 .args = ARGS(ARG_ENTRY_HTON(struct rte_flow_item_ecpri)),
3223 [ITEM_ECPRI_COMMON_TYPE_IQ_DATA] = {
3225 .help = "Type #0: IQ Data",
3226 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
3228 .call = parse_vc_item_ecpri_type,
3230 [ITEM_ECPRI_MSG_IQ_DATA_PCID] = {
3232 .help = "Physical Channel ID",
3233 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
3234 ITEM_ECPRI_COMMON, ITEM_NEXT),
3235 NEXT_ENTRY(UNSIGNED), item_param),
3236 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3239 [ITEM_ECPRI_COMMON_TYPE_RTC_CTRL] = {
3241 .help = "Type #2: Real-Time Control Data",
3242 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
3244 .call = parse_vc_item_ecpri_type,
3246 [ITEM_ECPRI_MSG_RTC_CTRL_RTCID] = {
3248 .help = "Real-Time Control Data ID",
3249 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
3250 ITEM_ECPRI_COMMON, ITEM_NEXT),
3251 NEXT_ENTRY(UNSIGNED), item_param),
3252 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3255 [ITEM_ECPRI_COMMON_TYPE_DLY_MSR] = {
3256 .name = "delay_measure",
3257 .help = "Type #5: One-Way Delay Measurement",
3258 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
3260 .call = parse_vc_item_ecpri_type,
3262 [ITEM_ECPRI_MSG_DLY_MSR_MSRID] = {
3264 .help = "Measurement ID",
3265 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
3266 ITEM_ECPRI_COMMON, ITEM_NEXT),
3267 NEXT_ENTRY(UNSIGNED), item_param),
3268 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3271 [ITEM_GENEVE_OPT] = {
3272 .name = "geneve-opt",
3273 .help = "GENEVE header option",
3274 .priv = PRIV_ITEM(GENEVE_OPT,
3275 sizeof(struct rte_flow_item_geneve_opt) +
3276 ITEM_GENEVE_OPT_DATA_SIZE),
3277 .next = NEXT(item_geneve_opt),
3280 [ITEM_GENEVE_OPT_CLASS] = {
3282 .help = "GENEVE option class",
3283 .next = NEXT(item_geneve_opt, NEXT_ENTRY(UNSIGNED), item_param),
3284 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve_opt,
3287 [ITEM_GENEVE_OPT_TYPE] = {
3289 .help = "GENEVE option type",
3290 .next = NEXT(item_geneve_opt, NEXT_ENTRY(UNSIGNED), item_param),
3291 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt,
3294 [ITEM_GENEVE_OPT_LENGTH] = {
3296 .help = "GENEVE option data length (in 32b words)",
3297 .next = NEXT(item_geneve_opt, NEXT_ENTRY(UNSIGNED), item_param),
3298 .args = ARGS(ARGS_ENTRY_BOUNDED(
3299 struct rte_flow_item_geneve_opt, option_len,
3302 [ITEM_GENEVE_OPT_DATA] = {
3304 .help = "GENEVE option data pattern",
3305 .next = NEXT(item_geneve_opt, NEXT_ENTRY(HEX), item_param),
3306 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt, data),
3307 ARGS_ENTRY_ARB(0, 0),
3309 (sizeof(struct rte_flow_item_geneve_opt),
3310 ITEM_GENEVE_OPT_DATA_SIZE)),
3312 /* Validate/create actions. */
3315 .help = "submit a list of associated actions",
3316 .next = NEXT(next_action),
3321 .help = "specify next action",
3322 .next = NEXT(next_action),
3326 .help = "end list of actions",
3327 .priv = PRIV_ACTION(END, 0),
3332 .help = "no-op action",
3333 .priv = PRIV_ACTION(VOID, 0),
3334 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3337 [ACTION_PASSTHRU] = {
3339 .help = "let subsequent rule process matched packets",
3340 .priv = PRIV_ACTION(PASSTHRU, 0),
3341 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3346 .help = "redirect traffic to a given group",
3347 .priv = PRIV_ACTION(JUMP, sizeof(struct rte_flow_action_jump)),
3348 .next = NEXT(action_jump),
3351 [ACTION_JUMP_GROUP] = {
3353 .help = "group to redirect traffic to",
3354 .next = NEXT(action_jump, NEXT_ENTRY(UNSIGNED)),
3355 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump, group)),
3356 .call = parse_vc_conf,
3360 .help = "attach 32 bit value to packets",
3361 .priv = PRIV_ACTION(MARK, sizeof(struct rte_flow_action_mark)),
3362 .next = NEXT(action_mark),
3365 [ACTION_MARK_ID] = {
3367 .help = "32 bit value to return with packets",
3368 .next = NEXT(action_mark, NEXT_ENTRY(UNSIGNED)),
3369 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_mark, id)),
3370 .call = parse_vc_conf,
3374 .help = "flag packets",
3375 .priv = PRIV_ACTION(FLAG, 0),
3376 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3381 .help = "assign packets to a given queue index",
3382 .priv = PRIV_ACTION(QUEUE,
3383 sizeof(struct rte_flow_action_queue)),
3384 .next = NEXT(action_queue),
3387 [ACTION_QUEUE_INDEX] = {
3389 .help = "queue index to use",
3390 .next = NEXT(action_queue, NEXT_ENTRY(UNSIGNED)),
3391 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_queue, index)),
3392 .call = parse_vc_conf,
3396 .help = "drop packets (note: passthru has priority)",
3397 .priv = PRIV_ACTION(DROP, 0),
3398 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3403 .help = "enable counters for this rule",
3404 .priv = PRIV_ACTION(COUNT,
3405 sizeof(struct rte_flow_action_count)),
3406 .next = NEXT(action_count),
3409 [ACTION_COUNT_ID] = {
3410 .name = "identifier",
3411 .help = "counter identifier to use",
3412 .next = NEXT(action_count, NEXT_ENTRY(UNSIGNED)),
3413 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_count, id)),
3414 .call = parse_vc_conf,
3416 [ACTION_COUNT_SHARED] = {
3418 .help = "shared counter",
3419 .next = NEXT(action_count, NEXT_ENTRY(BOOLEAN)),
3420 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_count,
3422 .call = parse_vc_conf,
3426 .help = "spread packets among several queues",
3427 .priv = PRIV_ACTION(RSS, sizeof(struct action_rss_data)),
3428 .next = NEXT(action_rss),
3429 .call = parse_vc_action_rss,
3431 [ACTION_RSS_FUNC] = {
3433 .help = "RSS hash function to apply",
3434 .next = NEXT(action_rss,
3435 NEXT_ENTRY(ACTION_RSS_FUNC_DEFAULT,
3436 ACTION_RSS_FUNC_TOEPLITZ,
3437 ACTION_RSS_FUNC_SIMPLE_XOR,
3438 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ)),
3440 [ACTION_RSS_FUNC_DEFAULT] = {
3442 .help = "default hash function",
3443 .call = parse_vc_action_rss_func,
3445 [ACTION_RSS_FUNC_TOEPLITZ] = {
3447 .help = "Toeplitz hash function",
3448 .call = parse_vc_action_rss_func,
3450 [ACTION_RSS_FUNC_SIMPLE_XOR] = {
3451 .name = "simple_xor",
3452 .help = "simple XOR hash function",
3453 .call = parse_vc_action_rss_func,
3455 [ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ] = {
3456 .name = "symmetric_toeplitz",
3457 .help = "Symmetric Toeplitz hash function",
3458 .call = parse_vc_action_rss_func,
3460 [ACTION_RSS_LEVEL] = {
3462 .help = "encapsulation level for \"types\"",
3463 .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
3464 .args = ARGS(ARGS_ENTRY_ARB
3465 (offsetof(struct action_rss_data, conf) +
3466 offsetof(struct rte_flow_action_rss, level),
3467 sizeof(((struct rte_flow_action_rss *)0)->
3470 [ACTION_RSS_TYPES] = {
3472 .help = "specific RSS hash types",
3473 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)),
3475 [ACTION_RSS_TYPE] = {
3477 .help = "RSS hash type",
3478 .call = parse_vc_action_rss_type,
3479 .comp = comp_vc_action_rss_type,
3481 [ACTION_RSS_KEY] = {
3483 .help = "RSS hash key",
3484 .next = NEXT(action_rss, NEXT_ENTRY(HEX)),
3485 .args = ARGS(ARGS_ENTRY_ARB(0, 0),
3487 (offsetof(struct action_rss_data, conf) +
3488 offsetof(struct rte_flow_action_rss, key_len),
3489 sizeof(((struct rte_flow_action_rss *)0)->
3491 ARGS_ENTRY(struct action_rss_data, key)),
3493 [ACTION_RSS_KEY_LEN] = {
3495 .help = "RSS hash key length in bytes",
3496 .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
3497 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
3498 (offsetof(struct action_rss_data, conf) +
3499 offsetof(struct rte_flow_action_rss, key_len),
3500 sizeof(((struct rte_flow_action_rss *)0)->
3503 RSS_HASH_KEY_LENGTH)),
3505 [ACTION_RSS_QUEUES] = {
3507 .help = "queue indices to use",
3508 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_QUEUE)),
3509 .call = parse_vc_conf,
3511 [ACTION_RSS_QUEUE] = {
3513 .help = "queue index",
3514 .call = parse_vc_action_rss_queue,
3515 .comp = comp_vc_action_rss_queue,
3519 .help = "direct traffic to physical function",
3520 .priv = PRIV_ACTION(PF, 0),
3521 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3526 .help = "direct traffic to a virtual function ID",
3527 .priv = PRIV_ACTION(VF, sizeof(struct rte_flow_action_vf)),
3528 .next = NEXT(action_vf),
3531 [ACTION_VF_ORIGINAL] = {
3533 .help = "use original VF ID if possible",
3534 .next = NEXT(action_vf, NEXT_ENTRY(BOOLEAN)),
3535 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_vf,
3537 .call = parse_vc_conf,
3542 .next = NEXT(action_vf, NEXT_ENTRY(UNSIGNED)),
3543 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)),
3544 .call = parse_vc_conf,
3546 [ACTION_PHY_PORT] = {
3548 .help = "direct packets to physical port index",
3549 .priv = PRIV_ACTION(PHY_PORT,
3550 sizeof(struct rte_flow_action_phy_port)),
3551 .next = NEXT(action_phy_port),
3554 [ACTION_PHY_PORT_ORIGINAL] = {
3556 .help = "use original port index if possible",
3557 .next = NEXT(action_phy_port, NEXT_ENTRY(BOOLEAN)),
3558 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_phy_port,
3560 .call = parse_vc_conf,
3562 [ACTION_PHY_PORT_INDEX] = {
3564 .help = "physical port index",
3565 .next = NEXT(action_phy_port, NEXT_ENTRY(UNSIGNED)),
3566 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_phy_port,
3568 .call = parse_vc_conf,
3570 [ACTION_PORT_ID] = {
3572 .help = "direct matching traffic to a given DPDK port ID",
3573 .priv = PRIV_ACTION(PORT_ID,
3574 sizeof(struct rte_flow_action_port_id)),
3575 .next = NEXT(action_port_id),
3578 [ACTION_PORT_ID_ORIGINAL] = {
3580 .help = "use original DPDK port ID if possible",
3581 .next = NEXT(action_port_id, NEXT_ENTRY(BOOLEAN)),
3582 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_port_id,
3584 .call = parse_vc_conf,
3586 [ACTION_PORT_ID_ID] = {
3588 .help = "DPDK port ID",
3589 .next = NEXT(action_port_id, NEXT_ENTRY(UNSIGNED)),
3590 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_port_id, id)),
3591 .call = parse_vc_conf,
3595 .help = "meter the directed packets at given id",
3596 .priv = PRIV_ACTION(METER,
3597 sizeof(struct rte_flow_action_meter)),
3598 .next = NEXT(action_meter),
3601 [ACTION_METER_ID] = {
3603 .help = "meter id to use",
3604 .next = NEXT(action_meter, NEXT_ENTRY(UNSIGNED)),
3605 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter, mtr_id)),
3606 .call = parse_vc_conf,
3608 [ACTION_OF_SET_MPLS_TTL] = {
3609 .name = "of_set_mpls_ttl",
3610 .help = "OpenFlow's OFPAT_SET_MPLS_TTL",
3613 sizeof(struct rte_flow_action_of_set_mpls_ttl)),
3614 .next = NEXT(action_of_set_mpls_ttl),
3617 [ACTION_OF_SET_MPLS_TTL_MPLS_TTL] = {
3620 .next = NEXT(action_of_set_mpls_ttl, NEXT_ENTRY(UNSIGNED)),
3621 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_mpls_ttl,
3623 .call = parse_vc_conf,
3625 [ACTION_OF_DEC_MPLS_TTL] = {
3626 .name = "of_dec_mpls_ttl",
3627 .help = "OpenFlow's OFPAT_DEC_MPLS_TTL",
3628 .priv = PRIV_ACTION(OF_DEC_MPLS_TTL, 0),
3629 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3632 [ACTION_OF_SET_NW_TTL] = {
3633 .name = "of_set_nw_ttl",
3634 .help = "OpenFlow's OFPAT_SET_NW_TTL",
3637 sizeof(struct rte_flow_action_of_set_nw_ttl)),
3638 .next = NEXT(action_of_set_nw_ttl),
3641 [ACTION_OF_SET_NW_TTL_NW_TTL] = {
3644 .next = NEXT(action_of_set_nw_ttl, NEXT_ENTRY(UNSIGNED)),
3645 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_nw_ttl,
3647 .call = parse_vc_conf,
3649 [ACTION_OF_DEC_NW_TTL] = {
3650 .name = "of_dec_nw_ttl",
3651 .help = "OpenFlow's OFPAT_DEC_NW_TTL",
3652 .priv = PRIV_ACTION(OF_DEC_NW_TTL, 0),
3653 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3656 [ACTION_OF_COPY_TTL_OUT] = {
3657 .name = "of_copy_ttl_out",
3658 .help = "OpenFlow's OFPAT_COPY_TTL_OUT",
3659 .priv = PRIV_ACTION(OF_COPY_TTL_OUT, 0),
3660 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3663 [ACTION_OF_COPY_TTL_IN] = {
3664 .name = "of_copy_ttl_in",
3665 .help = "OpenFlow's OFPAT_COPY_TTL_IN",
3666 .priv = PRIV_ACTION(OF_COPY_TTL_IN, 0),
3667 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3670 [ACTION_OF_POP_VLAN] = {
3671 .name = "of_pop_vlan",
3672 .help = "OpenFlow's OFPAT_POP_VLAN",
3673 .priv = PRIV_ACTION(OF_POP_VLAN, 0),
3674 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3677 [ACTION_OF_PUSH_VLAN] = {
3678 .name = "of_push_vlan",
3679 .help = "OpenFlow's OFPAT_PUSH_VLAN",
3682 sizeof(struct rte_flow_action_of_push_vlan)),
3683 .next = NEXT(action_of_push_vlan),
3686 [ACTION_OF_PUSH_VLAN_ETHERTYPE] = {
3687 .name = "ethertype",
3688 .help = "EtherType",
3689 .next = NEXT(action_of_push_vlan, NEXT_ENTRY(UNSIGNED)),
3690 .args = ARGS(ARGS_ENTRY_HTON
3691 (struct rte_flow_action_of_push_vlan,
3693 .call = parse_vc_conf,
3695 [ACTION_OF_SET_VLAN_VID] = {
3696 .name = "of_set_vlan_vid",
3697 .help = "OpenFlow's OFPAT_SET_VLAN_VID",
3700 sizeof(struct rte_flow_action_of_set_vlan_vid)),
3701 .next = NEXT(action_of_set_vlan_vid),
3704 [ACTION_OF_SET_VLAN_VID_VLAN_VID] = {
3707 .next = NEXT(action_of_set_vlan_vid, NEXT_ENTRY(UNSIGNED)),
3708 .args = ARGS(ARGS_ENTRY_HTON
3709 (struct rte_flow_action_of_set_vlan_vid,
3711 .call = parse_vc_conf,
3713 [ACTION_OF_SET_VLAN_PCP] = {
3714 .name = "of_set_vlan_pcp",
3715 .help = "OpenFlow's OFPAT_SET_VLAN_PCP",
3718 sizeof(struct rte_flow_action_of_set_vlan_pcp)),
3719 .next = NEXT(action_of_set_vlan_pcp),
3722 [ACTION_OF_SET_VLAN_PCP_VLAN_PCP] = {
3724 .help = "VLAN priority",
3725 .next = NEXT(action_of_set_vlan_pcp, NEXT_ENTRY(UNSIGNED)),
3726 .args = ARGS(ARGS_ENTRY_HTON
3727 (struct rte_flow_action_of_set_vlan_pcp,
3729 .call = parse_vc_conf,
3731 [ACTION_OF_POP_MPLS] = {
3732 .name = "of_pop_mpls",
3733 .help = "OpenFlow's OFPAT_POP_MPLS",
3734 .priv = PRIV_ACTION(OF_POP_MPLS,
3735 sizeof(struct rte_flow_action_of_pop_mpls)),
3736 .next = NEXT(action_of_pop_mpls),
3739 [ACTION_OF_POP_MPLS_ETHERTYPE] = {
3740 .name = "ethertype",
3741 .help = "EtherType",
3742 .next = NEXT(action_of_pop_mpls, NEXT_ENTRY(UNSIGNED)),
3743 .args = ARGS(ARGS_ENTRY_HTON
3744 (struct rte_flow_action_of_pop_mpls,
3746 .call = parse_vc_conf,
3748 [ACTION_OF_PUSH_MPLS] = {
3749 .name = "of_push_mpls",
3750 .help = "OpenFlow's OFPAT_PUSH_MPLS",
3753 sizeof(struct rte_flow_action_of_push_mpls)),
3754 .next = NEXT(action_of_push_mpls),
3757 [ACTION_OF_PUSH_MPLS_ETHERTYPE] = {
3758 .name = "ethertype",
3759 .help = "EtherType",
3760 .next = NEXT(action_of_push_mpls, NEXT_ENTRY(UNSIGNED)),
3761 .args = ARGS(ARGS_ENTRY_HTON
3762 (struct rte_flow_action_of_push_mpls,
3764 .call = parse_vc_conf,
3766 [ACTION_VXLAN_ENCAP] = {
3767 .name = "vxlan_encap",
3768 .help = "VXLAN encapsulation, uses configuration set by \"set"
3770 .priv = PRIV_ACTION(VXLAN_ENCAP,
3771 sizeof(struct action_vxlan_encap_data)),
3772 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3773 .call = parse_vc_action_vxlan_encap,
3775 [ACTION_VXLAN_DECAP] = {
3776 .name = "vxlan_decap",
3777 .help = "Performs a decapsulation action by stripping all"
3778 " headers of the VXLAN tunnel network overlay from the"
3780 .priv = PRIV_ACTION(VXLAN_DECAP, 0),
3781 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3784 [ACTION_NVGRE_ENCAP] = {
3785 .name = "nvgre_encap",
3786 .help = "NVGRE encapsulation, uses configuration set by \"set"
3788 .priv = PRIV_ACTION(NVGRE_ENCAP,
3789 sizeof(struct action_nvgre_encap_data)),
3790 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3791 .call = parse_vc_action_nvgre_encap,
3793 [ACTION_NVGRE_DECAP] = {
3794 .name = "nvgre_decap",
3795 .help = "Performs a decapsulation action by stripping all"
3796 " headers of the NVGRE tunnel network overlay from the"
3798 .priv = PRIV_ACTION(NVGRE_DECAP, 0),
3799 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3802 [ACTION_L2_ENCAP] = {
3804 .help = "l2 encap, uses configuration set by"
3805 " \"set l2_encap\"",
3806 .priv = PRIV_ACTION(RAW_ENCAP,
3807 sizeof(struct action_raw_encap_data)),
3808 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3809 .call = parse_vc_action_l2_encap,
3811 [ACTION_L2_DECAP] = {
3813 .help = "l2 decap, uses configuration set by"
3814 " \"set l2_decap\"",
3815 .priv = PRIV_ACTION(RAW_DECAP,
3816 sizeof(struct action_raw_decap_data)),
3817 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3818 .call = parse_vc_action_l2_decap,
3820 [ACTION_MPLSOGRE_ENCAP] = {
3821 .name = "mplsogre_encap",
3822 .help = "mplsogre encapsulation, uses configuration set by"
3823 " \"set mplsogre_encap\"",
3824 .priv = PRIV_ACTION(RAW_ENCAP,
3825 sizeof(struct action_raw_encap_data)),
3826 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3827 .call = parse_vc_action_mplsogre_encap,
3829 [ACTION_MPLSOGRE_DECAP] = {
3830 .name = "mplsogre_decap",
3831 .help = "mplsogre decapsulation, uses configuration set by"
3832 " \"set mplsogre_decap\"",
3833 .priv = PRIV_ACTION(RAW_DECAP,
3834 sizeof(struct action_raw_decap_data)),
3835 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3836 .call = parse_vc_action_mplsogre_decap,
3838 [ACTION_MPLSOUDP_ENCAP] = {
3839 .name = "mplsoudp_encap",
3840 .help = "mplsoudp encapsulation, uses configuration set by"
3841 " \"set mplsoudp_encap\"",
3842 .priv = PRIV_ACTION(RAW_ENCAP,
3843 sizeof(struct action_raw_encap_data)),
3844 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3845 .call = parse_vc_action_mplsoudp_encap,
3847 [ACTION_MPLSOUDP_DECAP] = {
3848 .name = "mplsoudp_decap",
3849 .help = "mplsoudp decapsulation, uses configuration set by"
3850 " \"set mplsoudp_decap\"",
3851 .priv = PRIV_ACTION(RAW_DECAP,
3852 sizeof(struct action_raw_decap_data)),
3853 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3854 .call = parse_vc_action_mplsoudp_decap,
3856 [ACTION_SET_IPV4_SRC] = {
3857 .name = "set_ipv4_src",
3858 .help = "Set a new IPv4 source address in the outermost"
3860 .priv = PRIV_ACTION(SET_IPV4_SRC,
3861 sizeof(struct rte_flow_action_set_ipv4)),
3862 .next = NEXT(action_set_ipv4_src),
3865 [ACTION_SET_IPV4_SRC_IPV4_SRC] = {
3866 .name = "ipv4_addr",
3867 .help = "new IPv4 source address to set",
3868 .next = NEXT(action_set_ipv4_src, NEXT_ENTRY(IPV4_ADDR)),
3869 .args = ARGS(ARGS_ENTRY_HTON
3870 (struct rte_flow_action_set_ipv4, ipv4_addr)),
3871 .call = parse_vc_conf,
3873 [ACTION_SET_IPV4_DST] = {
3874 .name = "set_ipv4_dst",
3875 .help = "Set a new IPv4 destination address in the outermost"
3877 .priv = PRIV_ACTION(SET_IPV4_DST,
3878 sizeof(struct rte_flow_action_set_ipv4)),
3879 .next = NEXT(action_set_ipv4_dst),
3882 [ACTION_SET_IPV4_DST_IPV4_DST] = {
3883 .name = "ipv4_addr",
3884 .help = "new IPv4 destination address to set",
3885 .next = NEXT(action_set_ipv4_dst, NEXT_ENTRY(IPV4_ADDR)),
3886 .args = ARGS(ARGS_ENTRY_HTON
3887 (struct rte_flow_action_set_ipv4, ipv4_addr)),
3888 .call = parse_vc_conf,
3890 [ACTION_SET_IPV6_SRC] = {
3891 .name = "set_ipv6_src",
3892 .help = "Set a new IPv6 source address in the outermost"
3894 .priv = PRIV_ACTION(SET_IPV6_SRC,
3895 sizeof(struct rte_flow_action_set_ipv6)),
3896 .next = NEXT(action_set_ipv6_src),
3899 [ACTION_SET_IPV6_SRC_IPV6_SRC] = {
3900 .name = "ipv6_addr",
3901 .help = "new IPv6 source address to set",
3902 .next = NEXT(action_set_ipv6_src, NEXT_ENTRY(IPV6_ADDR)),
3903 .args = ARGS(ARGS_ENTRY_HTON
3904 (struct rte_flow_action_set_ipv6, ipv6_addr)),
3905 .call = parse_vc_conf,
3907 [ACTION_SET_IPV6_DST] = {
3908 .name = "set_ipv6_dst",
3909 .help = "Set a new IPv6 destination address in the outermost"
3911 .priv = PRIV_ACTION(SET_IPV6_DST,
3912 sizeof(struct rte_flow_action_set_ipv6)),
3913 .next = NEXT(action_set_ipv6_dst),
3916 [ACTION_SET_IPV6_DST_IPV6_DST] = {
3917 .name = "ipv6_addr",
3918 .help = "new IPv6 destination address to set",
3919 .next = NEXT(action_set_ipv6_dst, NEXT_ENTRY(IPV6_ADDR)),
3920 .args = ARGS(ARGS_ENTRY_HTON
3921 (struct rte_flow_action_set_ipv6, ipv6_addr)),
3922 .call = parse_vc_conf,
3924 [ACTION_SET_TP_SRC] = {
3925 .name = "set_tp_src",
3926 .help = "set a new source port number in the outermost"
3928 .priv = PRIV_ACTION(SET_TP_SRC,
3929 sizeof(struct rte_flow_action_set_tp)),
3930 .next = NEXT(action_set_tp_src),
3933 [ACTION_SET_TP_SRC_TP_SRC] = {
3935 .help = "new source port number to set",
3936 .next = NEXT(action_set_tp_src, NEXT_ENTRY(UNSIGNED)),
3937 .args = ARGS(ARGS_ENTRY_HTON
3938 (struct rte_flow_action_set_tp, port)),
3939 .call = parse_vc_conf,
3941 [ACTION_SET_TP_DST] = {
3942 .name = "set_tp_dst",
3943 .help = "set a new destination port number in the outermost"
3945 .priv = PRIV_ACTION(SET_TP_DST,
3946 sizeof(struct rte_flow_action_set_tp)),
3947 .next = NEXT(action_set_tp_dst),
3950 [ACTION_SET_TP_DST_TP_DST] = {
3952 .help = "new destination port number to set",
3953 .next = NEXT(action_set_tp_dst, NEXT_ENTRY(UNSIGNED)),
3954 .args = ARGS(ARGS_ENTRY_HTON
3955 (struct rte_flow_action_set_tp, port)),
3956 .call = parse_vc_conf,
3958 [ACTION_MAC_SWAP] = {
3960 .help = "Swap the source and destination MAC addresses"
3961 " in the outermost Ethernet header",
3962 .priv = PRIV_ACTION(MAC_SWAP, 0),
3963 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3966 [ACTION_DEC_TTL] = {
3968 .help = "decrease network TTL if available",
3969 .priv = PRIV_ACTION(DEC_TTL, 0),
3970 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3973 [ACTION_SET_TTL] = {
3975 .help = "set ttl value",
3976 .priv = PRIV_ACTION(SET_TTL,
3977 sizeof(struct rte_flow_action_set_ttl)),
3978 .next = NEXT(action_set_ttl),
3981 [ACTION_SET_TTL_TTL] = {
3982 .name = "ttl_value",
3983 .help = "new ttl value to set",
3984 .next = NEXT(action_set_ttl, NEXT_ENTRY(UNSIGNED)),
3985 .args = ARGS(ARGS_ENTRY_HTON
3986 (struct rte_flow_action_set_ttl, ttl_value)),
3987 .call = parse_vc_conf,
3989 [ACTION_SET_MAC_SRC] = {
3990 .name = "set_mac_src",
3991 .help = "set source mac address",
3992 .priv = PRIV_ACTION(SET_MAC_SRC,
3993 sizeof(struct rte_flow_action_set_mac)),
3994 .next = NEXT(action_set_mac_src),
3997 [ACTION_SET_MAC_SRC_MAC_SRC] = {
3999 .help = "new source mac address",
4000 .next = NEXT(action_set_mac_src, NEXT_ENTRY(MAC_ADDR)),
4001 .args = ARGS(ARGS_ENTRY_HTON
4002 (struct rte_flow_action_set_mac, mac_addr)),
4003 .call = parse_vc_conf,
4005 [ACTION_SET_MAC_DST] = {
4006 .name = "set_mac_dst",
4007 .help = "set destination mac address",
4008 .priv = PRIV_ACTION(SET_MAC_DST,
4009 sizeof(struct rte_flow_action_set_mac)),
4010 .next = NEXT(action_set_mac_dst),
4013 [ACTION_SET_MAC_DST_MAC_DST] = {
4015 .help = "new destination mac address to set",
4016 .next = NEXT(action_set_mac_dst, NEXT_ENTRY(MAC_ADDR)),
4017 .args = ARGS(ARGS_ENTRY_HTON
4018 (struct rte_flow_action_set_mac, mac_addr)),
4019 .call = parse_vc_conf,
4021 [ACTION_INC_TCP_SEQ] = {
4022 .name = "inc_tcp_seq",
4023 .help = "increase TCP sequence number",
4024 .priv = PRIV_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
4025 .next = NEXT(action_inc_tcp_seq),
4028 [ACTION_INC_TCP_SEQ_VALUE] = {
4030 .help = "the value to increase TCP sequence number by",
4031 .next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(UNSIGNED)),
4032 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4033 .call = parse_vc_conf,
4035 [ACTION_DEC_TCP_SEQ] = {
4036 .name = "dec_tcp_seq",
4037 .help = "decrease TCP sequence number",
4038 .priv = PRIV_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
4039 .next = NEXT(action_dec_tcp_seq),
4042 [ACTION_DEC_TCP_SEQ_VALUE] = {
4044 .help = "the value to decrease TCP sequence number by",
4045 .next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(UNSIGNED)),
4046 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4047 .call = parse_vc_conf,
4049 [ACTION_INC_TCP_ACK] = {
4050 .name = "inc_tcp_ack",
4051 .help = "increase TCP acknowledgment number",
4052 .priv = PRIV_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
4053 .next = NEXT(action_inc_tcp_ack),
4056 [ACTION_INC_TCP_ACK_VALUE] = {
4058 .help = "the value to increase TCP acknowledgment number by",
4059 .next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(UNSIGNED)),
4060 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4061 .call = parse_vc_conf,
4063 [ACTION_DEC_TCP_ACK] = {
4064 .name = "dec_tcp_ack",
4065 .help = "decrease TCP acknowledgment number",
4066 .priv = PRIV_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
4067 .next = NEXT(action_dec_tcp_ack),
4070 [ACTION_DEC_TCP_ACK_VALUE] = {
4072 .help = "the value to decrease TCP acknowledgment number by",
4073 .next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(UNSIGNED)),
4074 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4075 .call = parse_vc_conf,
4077 [ACTION_RAW_ENCAP] = {
4078 .name = "raw_encap",
4079 .help = "encapsulation data, defined by set raw_encap",
4080 .priv = PRIV_ACTION(RAW_ENCAP,
4081 sizeof(struct action_raw_encap_data)),
4082 .next = NEXT(action_raw_encap),
4083 .call = parse_vc_action_raw_encap,
4085 [ACTION_RAW_ENCAP_INDEX] = {
4087 .help = "the index of raw_encap_confs",
4088 .next = NEXT(NEXT_ENTRY(ACTION_RAW_ENCAP_INDEX_VALUE)),
4090 [ACTION_RAW_ENCAP_INDEX_VALUE] = {
4093 .help = "unsigned integer value",
4094 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4095 .call = parse_vc_action_raw_encap_index,
4096 .comp = comp_set_raw_index,
4098 [ACTION_RAW_DECAP] = {
4099 .name = "raw_decap",
4100 .help = "decapsulation data, defined by set raw_encap",
4101 .priv = PRIV_ACTION(RAW_DECAP,
4102 sizeof(struct action_raw_decap_data)),
4103 .next = NEXT(action_raw_decap),
4104 .call = parse_vc_action_raw_decap,
4106 [ACTION_RAW_DECAP_INDEX] = {
4108 .help = "the index of raw_encap_confs",
4109 .next = NEXT(NEXT_ENTRY(ACTION_RAW_DECAP_INDEX_VALUE)),
4111 [ACTION_RAW_DECAP_INDEX_VALUE] = {
4114 .help = "unsigned integer value",
4115 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4116 .call = parse_vc_action_raw_decap_index,
4117 .comp = comp_set_raw_index,
4119 /* Top level command. */
4122 .help = "set raw encap/decap/sample data",
4123 .type = "set raw_encap|raw_decap <index> <pattern>"
4124 " or set sample_actions <index> <action>",
4125 .next = NEXT(NEXT_ENTRY
4128 SET_SAMPLE_ACTIONS)),
4129 .call = parse_set_init,
4131 /* Sub-level commands. */
4133 .name = "raw_encap",
4134 .help = "set raw encap 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,
4143 .name = "raw_decap",
4144 .help = "set raw decap data",
4145 .next = NEXT(next_set_raw),
4146 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4147 (offsetof(struct buffer, port),
4148 sizeof(((struct buffer *)0)->port),
4149 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
4150 .call = parse_set_raw_encap_decap,
4155 .help = "index of raw_encap/raw_decap data",
4156 .next = NEXT(next_item),
4159 [SET_SAMPLE_INDEX] = {
4162 .help = "index of sample actions",
4163 .next = NEXT(next_action_sample),
4166 [SET_SAMPLE_ACTIONS] = {
4167 .name = "sample_actions",
4168 .help = "set sample actions list",
4169 .next = NEXT(NEXT_ENTRY(SET_SAMPLE_INDEX)),
4170 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4171 (offsetof(struct buffer, port),
4172 sizeof(((struct buffer *)0)->port),
4173 0, RAW_SAMPLE_CONFS_MAX_NUM - 1)),
4174 .call = parse_set_sample_action,
4176 [ACTION_SET_TAG] = {
4179 .priv = PRIV_ACTION(SET_TAG,
4180 sizeof(struct rte_flow_action_set_tag)),
4181 .next = NEXT(action_set_tag),
4184 [ACTION_SET_TAG_INDEX] = {
4186 .help = "index of tag array",
4187 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
4188 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_set_tag, index)),
4189 .call = parse_vc_conf,
4191 [ACTION_SET_TAG_DATA] = {
4193 .help = "tag value",
4194 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
4195 .args = ARGS(ARGS_ENTRY
4196 (struct rte_flow_action_set_tag, data)),
4197 .call = parse_vc_conf,
4199 [ACTION_SET_TAG_MASK] = {
4201 .help = "mask for tag value",
4202 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
4203 .args = ARGS(ARGS_ENTRY
4204 (struct rte_flow_action_set_tag, mask)),
4205 .call = parse_vc_conf,
4207 [ACTION_SET_META] = {
4209 .help = "set metadata",
4210 .priv = PRIV_ACTION(SET_META,
4211 sizeof(struct rte_flow_action_set_meta)),
4212 .next = NEXT(action_set_meta),
4213 .call = parse_vc_action_set_meta,
4215 [ACTION_SET_META_DATA] = {
4217 .help = "metadata value",
4218 .next = NEXT(action_set_meta, NEXT_ENTRY(UNSIGNED)),
4219 .args = ARGS(ARGS_ENTRY
4220 (struct rte_flow_action_set_meta, data)),
4221 .call = parse_vc_conf,
4223 [ACTION_SET_META_MASK] = {
4225 .help = "mask for metadata value",
4226 .next = NEXT(action_set_meta, NEXT_ENTRY(UNSIGNED)),
4227 .args = ARGS(ARGS_ENTRY
4228 (struct rte_flow_action_set_meta, mask)),
4229 .call = parse_vc_conf,
4231 [ACTION_SET_IPV4_DSCP] = {
4232 .name = "set_ipv4_dscp",
4233 .help = "set DSCP value",
4234 .priv = PRIV_ACTION(SET_IPV4_DSCP,
4235 sizeof(struct rte_flow_action_set_dscp)),
4236 .next = NEXT(action_set_ipv4_dscp),
4239 [ACTION_SET_IPV4_DSCP_VALUE] = {
4240 .name = "dscp_value",
4241 .help = "new IPv4 DSCP value to set",
4242 .next = NEXT(action_set_ipv4_dscp, NEXT_ENTRY(UNSIGNED)),
4243 .args = ARGS(ARGS_ENTRY
4244 (struct rte_flow_action_set_dscp, dscp)),
4245 .call = parse_vc_conf,
4247 [ACTION_SET_IPV6_DSCP] = {
4248 .name = "set_ipv6_dscp",
4249 .help = "set DSCP value",
4250 .priv = PRIV_ACTION(SET_IPV6_DSCP,
4251 sizeof(struct rte_flow_action_set_dscp)),
4252 .next = NEXT(action_set_ipv6_dscp),
4255 [ACTION_SET_IPV6_DSCP_VALUE] = {
4256 .name = "dscp_value",
4257 .help = "new IPv6 DSCP value to set",
4258 .next = NEXT(action_set_ipv6_dscp, NEXT_ENTRY(UNSIGNED)),
4259 .args = ARGS(ARGS_ENTRY
4260 (struct rte_flow_action_set_dscp, dscp)),
4261 .call = parse_vc_conf,
4265 .help = "set a specific metadata header",
4266 .next = NEXT(action_age),
4267 .priv = PRIV_ACTION(AGE,
4268 sizeof(struct rte_flow_action_age)),
4271 [ACTION_AGE_TIMEOUT] = {
4273 .help = "flow age timeout value",
4274 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_age,
4276 .next = NEXT(action_age, NEXT_ENTRY(UNSIGNED)),
4277 .call = parse_vc_conf,
4281 .help = "set a sample action",
4282 .next = NEXT(action_sample),
4283 .priv = PRIV_ACTION(SAMPLE,
4284 sizeof(struct action_sample_data)),
4285 .call = parse_vc_action_sample,
4287 [ACTION_SAMPLE_RATIO] = {
4289 .help = "flow sample ratio value",
4290 .next = NEXT(action_sample, NEXT_ENTRY(UNSIGNED)),
4291 .args = ARGS(ARGS_ENTRY_ARB
4292 (offsetof(struct action_sample_data, conf) +
4293 offsetof(struct rte_flow_action_sample, ratio),
4294 sizeof(((struct rte_flow_action_sample *)0)->
4297 [ACTION_SAMPLE_INDEX] = {
4299 .help = "the index of sample actions list",
4300 .next = NEXT(NEXT_ENTRY(ACTION_SAMPLE_INDEX_VALUE)),
4302 [ACTION_SAMPLE_INDEX_VALUE] = {
4305 .help = "unsigned integer value",
4306 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4307 .call = parse_vc_action_sample_index,
4308 .comp = comp_set_sample_index,
4310 /* Shared action destroy arguments. */
4311 [SHARED_ACTION_DESTROY_ID] = {
4312 .name = "action_id",
4313 .help = "specify a shared action id to destroy",
4314 .next = NEXT(next_sa_destroy_attr,
4315 NEXT_ENTRY(SHARED_ACTION_ID)),
4316 .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
4317 args.sa_destroy.action_id)),
4318 .call = parse_sa_destroy,
4320 /* Shared action create arguments. */
4321 [SHARED_ACTION_CREATE_ID] = {
4322 .name = "action_id",
4323 .help = "specify a shared action id to create",
4324 .next = NEXT(next_sa_create_attr,
4325 NEXT_ENTRY(SHARED_ACTION_ID)),
4326 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
4330 .help = "apply shared action by id",
4331 .priv = PRIV_ACTION(SHARED, 0),
4332 .next = NEXT(NEXT_ENTRY(SHARED_ACTION_ID2PTR)),
4333 .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
4336 [SHARED_ACTION_ID2PTR] = {
4337 .name = "{action_id}",
4338 .type = "SHARED_ACTION_ID",
4339 .help = "shared action id",
4340 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4341 .call = parse_sa_id2ptr,
4344 [SHARED_ACTION_INGRESS] = {
4346 .help = "affect rule to ingress",
4347 .next = NEXT(next_sa_create_attr),
4350 [SHARED_ACTION_EGRESS] = {
4352 .help = "affect rule to egress",
4353 .next = NEXT(next_sa_create_attr),
4356 [SHARED_ACTION_TRANSFER] = {
4358 .help = "affect rule to transfer",
4359 .next = NEXT(next_sa_create_attr),
4362 [SHARED_ACTION_SPEC] = {
4364 .help = "specify action to share",
4365 .next = NEXT(next_action),
4369 /** Remove and return last entry from argument stack. */
4370 static const struct arg *
4371 pop_args(struct context *ctx)
4373 return ctx->args_num ? ctx->args[--ctx->args_num] : NULL;
4376 /** Add entry on top of the argument stack. */
4378 push_args(struct context *ctx, const struct arg *arg)
4380 if (ctx->args_num == CTX_STACK_SIZE)
4382 ctx->args[ctx->args_num++] = arg;
4386 /** Spread value into buffer according to bit-mask. */
4388 arg_entry_bf_fill(void *dst, uintmax_t val, const struct arg *arg)
4390 uint32_t i = arg->size;
4398 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
4407 unsigned int shift = 0;
4408 uint8_t *buf = (uint8_t *)dst + arg->offset + (i -= sub);
4410 for (shift = 0; arg->mask[i] >> shift; ++shift) {
4411 if (!(arg->mask[i] & (1 << shift)))
4416 *buf &= ~(1 << shift);
4417 *buf |= (val & 1) << shift;
4425 /** Compare a string with a partial one of a given length. */
4427 strcmp_partial(const char *full, const char *partial, size_t partial_len)
4429 int r = strncmp(full, partial, partial_len);
4433 if (strlen(full) <= partial_len)
4435 return full[partial_len];
4439 * Parse a prefix length and generate a bit-mask.
4441 * Last argument (ctx->args) is retrieved to determine mask size, storage
4442 * location and whether the result must use network byte ordering.
4445 parse_prefix(struct context *ctx, const struct token *token,
4446 const char *str, unsigned int len,
4447 void *buf, unsigned int size)
4449 const struct arg *arg = pop_args(ctx);
4450 static const uint8_t conv[] = "\x00\x80\xc0\xe0\xf0\xf8\xfc\xfe\xff";
4457 /* Argument is expected. */
4461 u = strtoumax(str, &end, 0);
4462 if (errno || (size_t)(end - str) != len)
4467 extra = arg_entry_bf_fill(NULL, 0, arg);
4476 if (!arg_entry_bf_fill(ctx->object, v, arg) ||
4477 !arg_entry_bf_fill(ctx->objmask, -1, arg))
4484 if (bytes > size || bytes + !!extra > size)
4488 buf = (uint8_t *)ctx->object + arg->offset;
4489 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
4491 memset((uint8_t *)buf + size - bytes, 0xff, bytes);
4492 memset(buf, 0x00, size - bytes);
4494 ((uint8_t *)buf)[size - bytes - 1] = conv[extra];
4498 memset(buf, 0xff, bytes);
4499 memset((uint8_t *)buf + bytes, 0x00, size - bytes);
4501 ((uint8_t *)buf)[bytes] = conv[extra];
4504 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
4507 push_args(ctx, arg);
4511 /** Default parsing function for token name matching. */
4513 parse_default(struct context *ctx, const struct token *token,
4514 const char *str, unsigned int len,
4515 void *buf, unsigned int size)
4520 if (strcmp_partial(token->name, str, len))
4525 /** Parse flow command, initialize output buffer for subsequent tokens. */
4527 parse_init(struct context *ctx, const struct token *token,
4528 const char *str, unsigned int len,
4529 void *buf, unsigned int size)
4531 struct buffer *out = buf;
4533 /* Token name must match. */
4534 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4536 /* Nothing else to do if there is no buffer. */
4539 /* Make sure buffer is large enough. */
4540 if (size < sizeof(*out))
4542 /* Initialize buffer. */
4543 memset(out, 0x00, sizeof(*out));
4544 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
4547 ctx->objmask = NULL;
4551 /** Parse tokens for shared action commands. */
4553 parse_sa(struct context *ctx, const struct token *token,
4554 const char *str, unsigned int len,
4555 void *buf, unsigned int size)
4557 struct buffer *out = buf;
4559 /* Token name must match. */
4560 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4562 /* Nothing else to do if there is no buffer. */
4565 if (!out->command) {
4566 if (ctx->curr != SHARED_ACTION)
4568 if (sizeof(*out) > size)
4570 out->command = ctx->curr;
4573 ctx->objmask = NULL;
4574 out->args.vc.data = (uint8_t *)out + size;
4577 switch (ctx->curr) {
4578 case SHARED_ACTION_CREATE:
4579 case SHARED_ACTION_UPDATE:
4580 out->args.vc.actions =
4581 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
4583 out->args.vc.attr.group = UINT32_MAX;
4585 case SHARED_ACTION_QUERY:
4586 out->command = ctx->curr;
4589 ctx->objmask = NULL;
4591 case SHARED_ACTION_EGRESS:
4592 out->args.vc.attr.egress = 1;
4594 case SHARED_ACTION_INGRESS:
4595 out->args.vc.attr.ingress = 1;
4597 case SHARED_ACTION_TRANSFER:
4598 out->args.vc.attr.transfer = 1;
4606 /** Parse tokens for shared action destroy command. */
4608 parse_sa_destroy(struct context *ctx, const struct token *token,
4609 const char *str, unsigned int len,
4610 void *buf, unsigned int size)
4612 struct buffer *out = buf;
4613 uint32_t *action_id;
4615 /* Token name must match. */
4616 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4618 /* Nothing else to do if there is no buffer. */
4621 if (!out->command || out->command == SHARED_ACTION) {
4622 if (ctx->curr != SHARED_ACTION_DESTROY)
4624 if (sizeof(*out) > size)
4626 out->command = ctx->curr;
4629 ctx->objmask = NULL;
4630 out->args.sa_destroy.action_id =
4631 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
4635 action_id = out->args.sa_destroy.action_id
4636 + out->args.sa_destroy.action_id_n++;
4637 if ((uint8_t *)action_id > (uint8_t *)out + size)
4640 ctx->object = action_id;
4641 ctx->objmask = NULL;
4645 /** Parse tokens for validate/create commands. */
4647 parse_vc(struct context *ctx, const struct token *token,
4648 const char *str, unsigned int len,
4649 void *buf, unsigned int size)
4651 struct buffer *out = buf;
4655 /* Token name must match. */
4656 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4658 /* Nothing else to do if there is no buffer. */
4661 if (!out->command) {
4662 if (ctx->curr != VALIDATE && ctx->curr != CREATE)
4664 if (sizeof(*out) > size)
4666 out->command = ctx->curr;
4669 ctx->objmask = NULL;
4670 out->args.vc.data = (uint8_t *)out + size;
4674 switch (ctx->curr) {
4676 ctx->object = &out->args.vc.attr;
4680 ctx->object = &out->args.vc.tunnel_ops;
4683 ctx->objmask = NULL;
4684 switch (ctx->curr) {
4689 out->args.vc.tunnel_ops.enabled = 1;
4690 out->args.vc.tunnel_ops.actions = 1;
4693 out->args.vc.tunnel_ops.enabled = 1;
4694 out->args.vc.tunnel_ops.items = 1;
4697 out->args.vc.attr.ingress = 1;
4700 out->args.vc.attr.egress = 1;
4703 out->args.vc.attr.transfer = 1;
4706 out->args.vc.pattern =
4707 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
4709 ctx->object = out->args.vc.pattern;
4710 ctx->objmask = NULL;
4713 out->args.vc.actions =
4714 (void *)RTE_ALIGN_CEIL((uintptr_t)
4715 (out->args.vc.pattern +
4716 out->args.vc.pattern_n),
4718 ctx->object = out->args.vc.actions;
4719 ctx->objmask = NULL;
4726 if (!out->args.vc.actions) {
4727 const struct parse_item_priv *priv = token->priv;
4728 struct rte_flow_item *item =
4729 out->args.vc.pattern + out->args.vc.pattern_n;
4731 data_size = priv->size * 3; /* spec, last, mask */
4732 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
4733 (out->args.vc.data - data_size),
4735 if ((uint8_t *)item + sizeof(*item) > data)
4737 *item = (struct rte_flow_item){
4740 ++out->args.vc.pattern_n;
4742 ctx->objmask = NULL;
4744 const struct parse_action_priv *priv = token->priv;
4745 struct rte_flow_action *action =
4746 out->args.vc.actions + out->args.vc.actions_n;
4748 data_size = priv->size; /* configuration */
4749 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
4750 (out->args.vc.data - data_size),
4752 if ((uint8_t *)action + sizeof(*action) > data)
4754 *action = (struct rte_flow_action){
4756 .conf = data_size ? data : NULL,
4758 ++out->args.vc.actions_n;
4759 ctx->object = action;
4760 ctx->objmask = NULL;
4762 memset(data, 0, data_size);
4763 out->args.vc.data = data;
4764 ctx->objdata = data_size;
4768 /** Parse pattern item parameter type. */
4770 parse_vc_spec(struct context *ctx, const struct token *token,
4771 const char *str, unsigned int len,
4772 void *buf, unsigned int size)
4774 struct buffer *out = buf;
4775 struct rte_flow_item *item;
4781 /* Token name must match. */
4782 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4784 /* Parse parameter types. */
4785 switch (ctx->curr) {
4786 static const enum index prefix[] = NEXT_ENTRY(PREFIX);
4792 case ITEM_PARAM_SPEC:
4795 case ITEM_PARAM_LAST:
4798 case ITEM_PARAM_PREFIX:
4799 /* Modify next token to expect a prefix. */
4800 if (ctx->next_num < 2)
4802 ctx->next[ctx->next_num - 2] = prefix;
4804 case ITEM_PARAM_MASK:
4810 /* Nothing else to do if there is no buffer. */
4813 if (!out->args.vc.pattern_n)
4815 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
4816 data_size = ctx->objdata / 3; /* spec, last, mask */
4817 /* Point to selected object. */
4818 ctx->object = out->args.vc.data + (data_size * index);
4820 ctx->objmask = out->args.vc.data + (data_size * 2); /* mask */
4821 item->mask = ctx->objmask;
4823 ctx->objmask = NULL;
4824 /* Update relevant item pointer. */
4825 *((const void **[]){ &item->spec, &item->last, &item->mask })[index] =
4830 /** Parse action configuration field. */
4832 parse_vc_conf(struct context *ctx, const struct token *token,
4833 const char *str, unsigned int len,
4834 void *buf, unsigned int size)
4836 struct buffer *out = buf;
4839 /* Token name must match. */
4840 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4842 /* Nothing else to do if there is no buffer. */
4845 /* Point to selected object. */
4846 ctx->object = out->args.vc.data;
4847 ctx->objmask = NULL;
4851 /** Parse eCPRI common header type field. */
4853 parse_vc_item_ecpri_type(struct context *ctx, const struct token *token,
4854 const char *str, unsigned int len,
4855 void *buf, unsigned int size)
4857 struct rte_flow_item_ecpri *ecpri;
4858 struct rte_flow_item_ecpri *ecpri_mask;
4859 struct rte_flow_item *item;
4862 struct buffer *out = buf;
4863 const struct arg *arg;
4866 /* Token name must match. */
4867 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4869 switch (ctx->curr) {
4870 case ITEM_ECPRI_COMMON_TYPE_IQ_DATA:
4871 msg_type = RTE_ECPRI_MSG_TYPE_IQ_DATA;
4873 case ITEM_ECPRI_COMMON_TYPE_RTC_CTRL:
4874 msg_type = RTE_ECPRI_MSG_TYPE_RTC_CTRL;
4876 case ITEM_ECPRI_COMMON_TYPE_DLY_MSR:
4877 msg_type = RTE_ECPRI_MSG_TYPE_DLY_MSR;
4884 arg = pop_args(ctx);
4887 ecpri = (struct rte_flow_item_ecpri *)out->args.vc.data;
4888 ecpri->hdr.common.type = msg_type;
4889 data_size = ctx->objdata / 3; /* spec, last, mask */
4890 ecpri_mask = (struct rte_flow_item_ecpri *)(out->args.vc.data +
4892 ecpri_mask->hdr.common.type = 0xFF;
4894 ecpri->hdr.common.u32 = rte_cpu_to_be_32(ecpri->hdr.common.u32);
4895 ecpri_mask->hdr.common.u32 =
4896 rte_cpu_to_be_32(ecpri_mask->hdr.common.u32);
4898 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
4900 item->mask = ecpri_mask;
4904 /** Parse RSS action. */
4906 parse_vc_action_rss(struct context *ctx, const struct token *token,
4907 const char *str, unsigned int len,
4908 void *buf, unsigned int size)
4910 struct buffer *out = buf;
4911 struct rte_flow_action *action;
4912 struct action_rss_data *action_rss_data;
4916 ret = parse_vc(ctx, token, str, len, buf, size);
4919 /* Nothing else to do if there is no buffer. */
4922 if (!out->args.vc.actions_n)
4924 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4925 /* Point to selected object. */
4926 ctx->object = out->args.vc.data;
4927 ctx->objmask = NULL;
4928 /* Set up default configuration. */
4929 action_rss_data = ctx->object;
4930 *action_rss_data = (struct action_rss_data){
4931 .conf = (struct rte_flow_action_rss){
4932 .func = RTE_ETH_HASH_FUNCTION_DEFAULT,
4936 .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM),
4938 .queue = action_rss_data->queue,
4942 for (i = 0; i < action_rss_data->conf.queue_num; ++i)
4943 action_rss_data->queue[i] = i;
4944 action->conf = &action_rss_data->conf;
4949 * Parse func field for RSS action.
4951 * The RTE_ETH_HASH_FUNCTION_* value to assign is derived from the
4952 * ACTION_RSS_FUNC_* index that called this function.
4955 parse_vc_action_rss_func(struct context *ctx, const struct token *token,
4956 const char *str, unsigned int len,
4957 void *buf, unsigned int size)
4959 struct action_rss_data *action_rss_data;
4960 enum rte_eth_hash_function func;
4964 /* Token name must match. */
4965 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4967 switch (ctx->curr) {
4968 case ACTION_RSS_FUNC_DEFAULT:
4969 func = RTE_ETH_HASH_FUNCTION_DEFAULT;
4971 case ACTION_RSS_FUNC_TOEPLITZ:
4972 func = RTE_ETH_HASH_FUNCTION_TOEPLITZ;
4974 case ACTION_RSS_FUNC_SIMPLE_XOR:
4975 func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
4977 case ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ:
4978 func = RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
4985 action_rss_data = ctx->object;
4986 action_rss_data->conf.func = func;
4991 * Parse type field for RSS action.
4993 * Valid tokens are type field names and the "end" token.
4996 parse_vc_action_rss_type(struct context *ctx, const struct token *token,
4997 const char *str, unsigned int len,
4998 void *buf, unsigned int size)
5000 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE);
5001 struct action_rss_data *action_rss_data;
5007 if (ctx->curr != ACTION_RSS_TYPE)
5009 if (!(ctx->objdata >> 16) && ctx->object) {
5010 action_rss_data = ctx->object;
5011 action_rss_data->conf.types = 0;
5013 if (!strcmp_partial("end", str, len)) {
5014 ctx->objdata &= 0xffff;
5017 for (i = 0; rss_type_table[i].str; ++i)
5018 if (!strcmp_partial(rss_type_table[i].str, str, len))
5020 if (!rss_type_table[i].str)
5022 ctx->objdata = 1 << 16 | (ctx->objdata & 0xffff);
5024 if (ctx->next_num == RTE_DIM(ctx->next))
5026 ctx->next[ctx->next_num++] = next;
5029 action_rss_data = ctx->object;
5030 action_rss_data->conf.types |= rss_type_table[i].rss_type;
5035 * Parse queue field for RSS action.
5037 * Valid tokens are queue indices and the "end" token.
5040 parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
5041 const char *str, unsigned int len,
5042 void *buf, unsigned int size)
5044 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE);
5045 struct action_rss_data *action_rss_data;
5046 const struct arg *arg;
5053 if (ctx->curr != ACTION_RSS_QUEUE)
5055 i = ctx->objdata >> 16;
5056 if (!strcmp_partial("end", str, len)) {
5057 ctx->objdata &= 0xffff;
5060 if (i >= ACTION_RSS_QUEUE_NUM)
5062 arg = ARGS_ENTRY_ARB(offsetof(struct action_rss_data, queue) +
5063 i * sizeof(action_rss_data->queue[i]),
5064 sizeof(action_rss_data->queue[i]));
5065 if (push_args(ctx, arg))
5067 ret = parse_int(ctx, token, str, len, NULL, 0);
5073 ctx->objdata = i << 16 | (ctx->objdata & 0xffff);
5075 if (ctx->next_num == RTE_DIM(ctx->next))
5077 ctx->next[ctx->next_num++] = next;
5081 action_rss_data = ctx->object;
5082 action_rss_data->conf.queue_num = i;
5083 action_rss_data->conf.queue = i ? action_rss_data->queue : NULL;
5087 /** Parse VXLAN encap action. */
5089 parse_vc_action_vxlan_encap(struct context *ctx, const struct token *token,
5090 const char *str, unsigned int len,
5091 void *buf, unsigned int size)
5093 struct buffer *out = buf;
5094 struct rte_flow_action *action;
5095 struct action_vxlan_encap_data *action_vxlan_encap_data;
5098 ret = parse_vc(ctx, token, str, len, buf, size);
5101 /* Nothing else to do if there is no buffer. */
5104 if (!out->args.vc.actions_n)
5106 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5107 /* Point to selected object. */
5108 ctx->object = out->args.vc.data;
5109 ctx->objmask = NULL;
5110 /* Set up default configuration. */
5111 action_vxlan_encap_data = ctx->object;
5112 *action_vxlan_encap_data = (struct action_vxlan_encap_data){
5113 .conf = (struct rte_flow_action_vxlan_encap){
5114 .definition = action_vxlan_encap_data->items,
5118 .type = RTE_FLOW_ITEM_TYPE_ETH,
5119 .spec = &action_vxlan_encap_data->item_eth,
5120 .mask = &rte_flow_item_eth_mask,
5123 .type = RTE_FLOW_ITEM_TYPE_VLAN,
5124 .spec = &action_vxlan_encap_data->item_vlan,
5125 .mask = &rte_flow_item_vlan_mask,
5128 .type = RTE_FLOW_ITEM_TYPE_IPV4,
5129 .spec = &action_vxlan_encap_data->item_ipv4,
5130 .mask = &rte_flow_item_ipv4_mask,
5133 .type = RTE_FLOW_ITEM_TYPE_UDP,
5134 .spec = &action_vxlan_encap_data->item_udp,
5135 .mask = &rte_flow_item_udp_mask,
5138 .type = RTE_FLOW_ITEM_TYPE_VXLAN,
5139 .spec = &action_vxlan_encap_data->item_vxlan,
5140 .mask = &rte_flow_item_vxlan_mask,
5143 .type = RTE_FLOW_ITEM_TYPE_END,
5148 .tci = vxlan_encap_conf.vlan_tci,
5152 .src_addr = vxlan_encap_conf.ipv4_src,
5153 .dst_addr = vxlan_encap_conf.ipv4_dst,
5156 .src_port = vxlan_encap_conf.udp_src,
5157 .dst_port = vxlan_encap_conf.udp_dst,
5159 .item_vxlan.flags = 0,
5161 memcpy(action_vxlan_encap_data->item_eth.dst.addr_bytes,
5162 vxlan_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5163 memcpy(action_vxlan_encap_data->item_eth.src.addr_bytes,
5164 vxlan_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5165 if (!vxlan_encap_conf.select_ipv4) {
5166 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.src_addr,
5167 &vxlan_encap_conf.ipv6_src,
5168 sizeof(vxlan_encap_conf.ipv6_src));
5169 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.dst_addr,
5170 &vxlan_encap_conf.ipv6_dst,
5171 sizeof(vxlan_encap_conf.ipv6_dst));
5172 action_vxlan_encap_data->items[2] = (struct rte_flow_item){
5173 .type = RTE_FLOW_ITEM_TYPE_IPV6,
5174 .spec = &action_vxlan_encap_data->item_ipv6,
5175 .mask = &rte_flow_item_ipv6_mask,
5178 if (!vxlan_encap_conf.select_vlan)
5179 action_vxlan_encap_data->items[1].type =
5180 RTE_FLOW_ITEM_TYPE_VOID;
5181 if (vxlan_encap_conf.select_tos_ttl) {
5182 if (vxlan_encap_conf.select_ipv4) {
5183 static struct rte_flow_item_ipv4 ipv4_mask_tos;
5185 memcpy(&ipv4_mask_tos, &rte_flow_item_ipv4_mask,
5186 sizeof(ipv4_mask_tos));
5187 ipv4_mask_tos.hdr.type_of_service = 0xff;
5188 ipv4_mask_tos.hdr.time_to_live = 0xff;
5189 action_vxlan_encap_data->item_ipv4.hdr.type_of_service =
5190 vxlan_encap_conf.ip_tos;
5191 action_vxlan_encap_data->item_ipv4.hdr.time_to_live =
5192 vxlan_encap_conf.ip_ttl;
5193 action_vxlan_encap_data->items[2].mask =
5196 static struct rte_flow_item_ipv6 ipv6_mask_tos;
5198 memcpy(&ipv6_mask_tos, &rte_flow_item_ipv6_mask,
5199 sizeof(ipv6_mask_tos));
5200 ipv6_mask_tos.hdr.vtc_flow |=
5201 RTE_BE32(0xfful << RTE_IPV6_HDR_TC_SHIFT);
5202 ipv6_mask_tos.hdr.hop_limits = 0xff;
5203 action_vxlan_encap_data->item_ipv6.hdr.vtc_flow |=
5205 ((uint32_t)vxlan_encap_conf.ip_tos <<
5206 RTE_IPV6_HDR_TC_SHIFT);
5207 action_vxlan_encap_data->item_ipv6.hdr.hop_limits =
5208 vxlan_encap_conf.ip_ttl;
5209 action_vxlan_encap_data->items[2].mask =
5213 memcpy(action_vxlan_encap_data->item_vxlan.vni, vxlan_encap_conf.vni,
5214 RTE_DIM(vxlan_encap_conf.vni));
5215 action->conf = &action_vxlan_encap_data->conf;
5219 /** Parse NVGRE encap action. */
5221 parse_vc_action_nvgre_encap(struct context *ctx, const struct token *token,
5222 const char *str, unsigned int len,
5223 void *buf, unsigned int size)
5225 struct buffer *out = buf;
5226 struct rte_flow_action *action;
5227 struct action_nvgre_encap_data *action_nvgre_encap_data;
5230 ret = parse_vc(ctx, token, str, len, buf, size);
5233 /* Nothing else to do if there is no buffer. */
5236 if (!out->args.vc.actions_n)
5238 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5239 /* Point to selected object. */
5240 ctx->object = out->args.vc.data;
5241 ctx->objmask = NULL;
5242 /* Set up default configuration. */
5243 action_nvgre_encap_data = ctx->object;
5244 *action_nvgre_encap_data = (struct action_nvgre_encap_data){
5245 .conf = (struct rte_flow_action_nvgre_encap){
5246 .definition = action_nvgre_encap_data->items,
5250 .type = RTE_FLOW_ITEM_TYPE_ETH,
5251 .spec = &action_nvgre_encap_data->item_eth,
5252 .mask = &rte_flow_item_eth_mask,
5255 .type = RTE_FLOW_ITEM_TYPE_VLAN,
5256 .spec = &action_nvgre_encap_data->item_vlan,
5257 .mask = &rte_flow_item_vlan_mask,
5260 .type = RTE_FLOW_ITEM_TYPE_IPV4,
5261 .spec = &action_nvgre_encap_data->item_ipv4,
5262 .mask = &rte_flow_item_ipv4_mask,
5265 .type = RTE_FLOW_ITEM_TYPE_NVGRE,
5266 .spec = &action_nvgre_encap_data->item_nvgre,
5267 .mask = &rte_flow_item_nvgre_mask,
5270 .type = RTE_FLOW_ITEM_TYPE_END,
5275 .tci = nvgre_encap_conf.vlan_tci,
5279 .src_addr = nvgre_encap_conf.ipv4_src,
5280 .dst_addr = nvgre_encap_conf.ipv4_dst,
5282 .item_nvgre.flow_id = 0,
5284 memcpy(action_nvgre_encap_data->item_eth.dst.addr_bytes,
5285 nvgre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5286 memcpy(action_nvgre_encap_data->item_eth.src.addr_bytes,
5287 nvgre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5288 if (!nvgre_encap_conf.select_ipv4) {
5289 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.src_addr,
5290 &nvgre_encap_conf.ipv6_src,
5291 sizeof(nvgre_encap_conf.ipv6_src));
5292 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.dst_addr,
5293 &nvgre_encap_conf.ipv6_dst,
5294 sizeof(nvgre_encap_conf.ipv6_dst));
5295 action_nvgre_encap_data->items[2] = (struct rte_flow_item){
5296 .type = RTE_FLOW_ITEM_TYPE_IPV6,
5297 .spec = &action_nvgre_encap_data->item_ipv6,
5298 .mask = &rte_flow_item_ipv6_mask,
5301 if (!nvgre_encap_conf.select_vlan)
5302 action_nvgre_encap_data->items[1].type =
5303 RTE_FLOW_ITEM_TYPE_VOID;
5304 memcpy(action_nvgre_encap_data->item_nvgre.tni, nvgre_encap_conf.tni,
5305 RTE_DIM(nvgre_encap_conf.tni));
5306 action->conf = &action_nvgre_encap_data->conf;
5310 /** Parse l2 encap action. */
5312 parse_vc_action_l2_encap(struct context *ctx, const struct token *token,
5313 const char *str, unsigned int len,
5314 void *buf, unsigned int size)
5316 struct buffer *out = buf;
5317 struct rte_flow_action *action;
5318 struct action_raw_encap_data *action_encap_data;
5319 struct rte_flow_item_eth eth = { .type = 0, };
5320 struct rte_flow_item_vlan vlan = {
5321 .tci = mplsoudp_encap_conf.vlan_tci,
5327 ret = parse_vc(ctx, token, str, len, buf, size);
5330 /* Nothing else to do if there is no buffer. */
5333 if (!out->args.vc.actions_n)
5335 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5336 /* Point to selected object. */
5337 ctx->object = out->args.vc.data;
5338 ctx->objmask = NULL;
5339 /* Copy the headers to the buffer. */
5340 action_encap_data = ctx->object;
5341 *action_encap_data = (struct action_raw_encap_data) {
5342 .conf = (struct rte_flow_action_raw_encap){
5343 .data = action_encap_data->data,
5347 header = action_encap_data->data;
5348 if (l2_encap_conf.select_vlan)
5349 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5350 else if (l2_encap_conf.select_ipv4)
5351 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5353 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5354 memcpy(eth.dst.addr_bytes,
5355 l2_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5356 memcpy(eth.src.addr_bytes,
5357 l2_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5358 memcpy(header, ð, sizeof(eth));
5359 header += sizeof(eth);
5360 if (l2_encap_conf.select_vlan) {
5361 if (l2_encap_conf.select_ipv4)
5362 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5364 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5365 memcpy(header, &vlan, sizeof(vlan));
5366 header += sizeof(vlan);
5368 action_encap_data->conf.size = header -
5369 action_encap_data->data;
5370 action->conf = &action_encap_data->conf;
5374 /** Parse l2 decap action. */
5376 parse_vc_action_l2_decap(struct context *ctx, const struct token *token,
5377 const char *str, unsigned int len,
5378 void *buf, unsigned int size)
5380 struct buffer *out = buf;
5381 struct rte_flow_action *action;
5382 struct action_raw_decap_data *action_decap_data;
5383 struct rte_flow_item_eth eth = { .type = 0, };
5384 struct rte_flow_item_vlan vlan = {
5385 .tci = mplsoudp_encap_conf.vlan_tci,
5391 ret = parse_vc(ctx, token, str, len, buf, size);
5394 /* Nothing else to do if there is no buffer. */
5397 if (!out->args.vc.actions_n)
5399 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5400 /* Point to selected object. */
5401 ctx->object = out->args.vc.data;
5402 ctx->objmask = NULL;
5403 /* Copy the headers to the buffer. */
5404 action_decap_data = ctx->object;
5405 *action_decap_data = (struct action_raw_decap_data) {
5406 .conf = (struct rte_flow_action_raw_decap){
5407 .data = action_decap_data->data,
5411 header = action_decap_data->data;
5412 if (l2_decap_conf.select_vlan)
5413 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5414 memcpy(header, ð, sizeof(eth));
5415 header += sizeof(eth);
5416 if (l2_decap_conf.select_vlan) {
5417 memcpy(header, &vlan, sizeof(vlan));
5418 header += sizeof(vlan);
5420 action_decap_data->conf.size = header -
5421 action_decap_data->data;
5422 action->conf = &action_decap_data->conf;
5426 #define ETHER_TYPE_MPLS_UNICAST 0x8847
5428 /** Parse MPLSOGRE encap action. */
5430 parse_vc_action_mplsogre_encap(struct context *ctx, const struct token *token,
5431 const char *str, unsigned int len,
5432 void *buf, unsigned int size)
5434 struct buffer *out = buf;
5435 struct rte_flow_action *action;
5436 struct action_raw_encap_data *action_encap_data;
5437 struct rte_flow_item_eth eth = { .type = 0, };
5438 struct rte_flow_item_vlan vlan = {
5439 .tci = mplsogre_encap_conf.vlan_tci,
5442 struct rte_flow_item_ipv4 ipv4 = {
5444 .src_addr = mplsogre_encap_conf.ipv4_src,
5445 .dst_addr = mplsogre_encap_conf.ipv4_dst,
5446 .next_proto_id = IPPROTO_GRE,
5447 .version_ihl = RTE_IPV4_VHL_DEF,
5448 .time_to_live = IPDEFTTL,
5451 struct rte_flow_item_ipv6 ipv6 = {
5453 .proto = IPPROTO_GRE,
5454 .hop_limits = IPDEFTTL,
5457 struct rte_flow_item_gre gre = {
5458 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
5460 struct rte_flow_item_mpls mpls = {
5466 ret = parse_vc(ctx, token, str, len, buf, size);
5469 /* Nothing else to do if there is no buffer. */
5472 if (!out->args.vc.actions_n)
5474 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5475 /* Point to selected object. */
5476 ctx->object = out->args.vc.data;
5477 ctx->objmask = NULL;
5478 /* Copy the headers to the buffer. */
5479 action_encap_data = ctx->object;
5480 *action_encap_data = (struct action_raw_encap_data) {
5481 .conf = (struct rte_flow_action_raw_encap){
5482 .data = action_encap_data->data,
5487 header = action_encap_data->data;
5488 if (mplsogre_encap_conf.select_vlan)
5489 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5490 else if (mplsogre_encap_conf.select_ipv4)
5491 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5493 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5494 memcpy(eth.dst.addr_bytes,
5495 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5496 memcpy(eth.src.addr_bytes,
5497 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5498 memcpy(header, ð, sizeof(eth));
5499 header += sizeof(eth);
5500 if (mplsogre_encap_conf.select_vlan) {
5501 if (mplsogre_encap_conf.select_ipv4)
5502 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5504 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5505 memcpy(header, &vlan, sizeof(vlan));
5506 header += sizeof(vlan);
5508 if (mplsogre_encap_conf.select_ipv4) {
5509 memcpy(header, &ipv4, sizeof(ipv4));
5510 header += sizeof(ipv4);
5512 memcpy(&ipv6.hdr.src_addr,
5513 &mplsogre_encap_conf.ipv6_src,
5514 sizeof(mplsogre_encap_conf.ipv6_src));
5515 memcpy(&ipv6.hdr.dst_addr,
5516 &mplsogre_encap_conf.ipv6_dst,
5517 sizeof(mplsogre_encap_conf.ipv6_dst));
5518 memcpy(header, &ipv6, sizeof(ipv6));
5519 header += sizeof(ipv6);
5521 memcpy(header, &gre, sizeof(gre));
5522 header += sizeof(gre);
5523 memcpy(mpls.label_tc_s, mplsogre_encap_conf.label,
5524 RTE_DIM(mplsogre_encap_conf.label));
5525 mpls.label_tc_s[2] |= 0x1;
5526 memcpy(header, &mpls, sizeof(mpls));
5527 header += sizeof(mpls);
5528 action_encap_data->conf.size = header -
5529 action_encap_data->data;
5530 action->conf = &action_encap_data->conf;
5534 /** Parse MPLSOGRE decap action. */
5536 parse_vc_action_mplsogre_decap(struct context *ctx, const struct token *token,
5537 const char *str, unsigned int len,
5538 void *buf, unsigned int size)
5540 struct buffer *out = buf;
5541 struct rte_flow_action *action;
5542 struct action_raw_decap_data *action_decap_data;
5543 struct rte_flow_item_eth eth = { .type = 0, };
5544 struct rte_flow_item_vlan vlan = {.tci = 0};
5545 struct rte_flow_item_ipv4 ipv4 = {
5547 .next_proto_id = IPPROTO_GRE,
5550 struct rte_flow_item_ipv6 ipv6 = {
5552 .proto = IPPROTO_GRE,
5555 struct rte_flow_item_gre gre = {
5556 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
5558 struct rte_flow_item_mpls mpls;
5562 ret = parse_vc(ctx, token, str, len, buf, size);
5565 /* Nothing else to do if there is no buffer. */
5568 if (!out->args.vc.actions_n)
5570 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5571 /* Point to selected object. */
5572 ctx->object = out->args.vc.data;
5573 ctx->objmask = NULL;
5574 /* Copy the headers to the buffer. */
5575 action_decap_data = ctx->object;
5576 *action_decap_data = (struct action_raw_decap_data) {
5577 .conf = (struct rte_flow_action_raw_decap){
5578 .data = action_decap_data->data,
5582 header = action_decap_data->data;
5583 if (mplsogre_decap_conf.select_vlan)
5584 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5585 else if (mplsogre_encap_conf.select_ipv4)
5586 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5588 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5589 memcpy(eth.dst.addr_bytes,
5590 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5591 memcpy(eth.src.addr_bytes,
5592 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5593 memcpy(header, ð, sizeof(eth));
5594 header += sizeof(eth);
5595 if (mplsogre_encap_conf.select_vlan) {
5596 if (mplsogre_encap_conf.select_ipv4)
5597 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5599 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5600 memcpy(header, &vlan, sizeof(vlan));
5601 header += sizeof(vlan);
5603 if (mplsogre_encap_conf.select_ipv4) {
5604 memcpy(header, &ipv4, sizeof(ipv4));
5605 header += sizeof(ipv4);
5607 memcpy(header, &ipv6, sizeof(ipv6));
5608 header += sizeof(ipv6);
5610 memcpy(header, &gre, sizeof(gre));
5611 header += sizeof(gre);
5612 memset(&mpls, 0, sizeof(mpls));
5613 memcpy(header, &mpls, sizeof(mpls));
5614 header += sizeof(mpls);
5615 action_decap_data->conf.size = header -
5616 action_decap_data->data;
5617 action->conf = &action_decap_data->conf;
5621 /** Parse MPLSOUDP encap action. */
5623 parse_vc_action_mplsoudp_encap(struct context *ctx, const struct token *token,
5624 const char *str, unsigned int len,
5625 void *buf, unsigned int size)
5627 struct buffer *out = buf;
5628 struct rte_flow_action *action;
5629 struct action_raw_encap_data *action_encap_data;
5630 struct rte_flow_item_eth eth = { .type = 0, };
5631 struct rte_flow_item_vlan vlan = {
5632 .tci = mplsoudp_encap_conf.vlan_tci,
5635 struct rte_flow_item_ipv4 ipv4 = {
5637 .src_addr = mplsoudp_encap_conf.ipv4_src,
5638 .dst_addr = mplsoudp_encap_conf.ipv4_dst,
5639 .next_proto_id = IPPROTO_UDP,
5640 .version_ihl = RTE_IPV4_VHL_DEF,
5641 .time_to_live = IPDEFTTL,
5644 struct rte_flow_item_ipv6 ipv6 = {
5646 .proto = IPPROTO_UDP,
5647 .hop_limits = IPDEFTTL,
5650 struct rte_flow_item_udp udp = {
5652 .src_port = mplsoudp_encap_conf.udp_src,
5653 .dst_port = mplsoudp_encap_conf.udp_dst,
5656 struct rte_flow_item_mpls mpls;
5660 ret = parse_vc(ctx, token, str, len, buf, size);
5663 /* Nothing else to do if there is no buffer. */
5666 if (!out->args.vc.actions_n)
5668 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5669 /* Point to selected object. */
5670 ctx->object = out->args.vc.data;
5671 ctx->objmask = NULL;
5672 /* Copy the headers to the buffer. */
5673 action_encap_data = ctx->object;
5674 *action_encap_data = (struct action_raw_encap_data) {
5675 .conf = (struct rte_flow_action_raw_encap){
5676 .data = action_encap_data->data,
5681 header = action_encap_data->data;
5682 if (mplsoudp_encap_conf.select_vlan)
5683 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5684 else if (mplsoudp_encap_conf.select_ipv4)
5685 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5687 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5688 memcpy(eth.dst.addr_bytes,
5689 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5690 memcpy(eth.src.addr_bytes,
5691 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5692 memcpy(header, ð, sizeof(eth));
5693 header += sizeof(eth);
5694 if (mplsoudp_encap_conf.select_vlan) {
5695 if (mplsoudp_encap_conf.select_ipv4)
5696 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5698 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5699 memcpy(header, &vlan, sizeof(vlan));
5700 header += sizeof(vlan);
5702 if (mplsoudp_encap_conf.select_ipv4) {
5703 memcpy(header, &ipv4, sizeof(ipv4));
5704 header += sizeof(ipv4);
5706 memcpy(&ipv6.hdr.src_addr,
5707 &mplsoudp_encap_conf.ipv6_src,
5708 sizeof(mplsoudp_encap_conf.ipv6_src));
5709 memcpy(&ipv6.hdr.dst_addr,
5710 &mplsoudp_encap_conf.ipv6_dst,
5711 sizeof(mplsoudp_encap_conf.ipv6_dst));
5712 memcpy(header, &ipv6, sizeof(ipv6));
5713 header += sizeof(ipv6);
5715 memcpy(header, &udp, sizeof(udp));
5716 header += sizeof(udp);
5717 memcpy(mpls.label_tc_s, mplsoudp_encap_conf.label,
5718 RTE_DIM(mplsoudp_encap_conf.label));
5719 mpls.label_tc_s[2] |= 0x1;
5720 memcpy(header, &mpls, sizeof(mpls));
5721 header += sizeof(mpls);
5722 action_encap_data->conf.size = header -
5723 action_encap_data->data;
5724 action->conf = &action_encap_data->conf;
5728 /** Parse MPLSOUDP decap action. */
5730 parse_vc_action_mplsoudp_decap(struct context *ctx, const struct token *token,
5731 const char *str, unsigned int len,
5732 void *buf, unsigned int size)
5734 struct buffer *out = buf;
5735 struct rte_flow_action *action;
5736 struct action_raw_decap_data *action_decap_data;
5737 struct rte_flow_item_eth eth = { .type = 0, };
5738 struct rte_flow_item_vlan vlan = {.tci = 0};
5739 struct rte_flow_item_ipv4 ipv4 = {
5741 .next_proto_id = IPPROTO_UDP,
5744 struct rte_flow_item_ipv6 ipv6 = {
5746 .proto = IPPROTO_UDP,
5749 struct rte_flow_item_udp udp = {
5751 .dst_port = rte_cpu_to_be_16(6635),
5754 struct rte_flow_item_mpls mpls;
5758 ret = parse_vc(ctx, token, str, len, buf, size);
5761 /* Nothing else to do if there is no buffer. */
5764 if (!out->args.vc.actions_n)
5766 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5767 /* Point to selected object. */
5768 ctx->object = out->args.vc.data;
5769 ctx->objmask = NULL;
5770 /* Copy the headers to the buffer. */
5771 action_decap_data = ctx->object;
5772 *action_decap_data = (struct action_raw_decap_data) {
5773 .conf = (struct rte_flow_action_raw_decap){
5774 .data = action_decap_data->data,
5778 header = action_decap_data->data;
5779 if (mplsoudp_decap_conf.select_vlan)
5780 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5781 else if (mplsoudp_encap_conf.select_ipv4)
5782 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5784 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5785 memcpy(eth.dst.addr_bytes,
5786 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5787 memcpy(eth.src.addr_bytes,
5788 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5789 memcpy(header, ð, sizeof(eth));
5790 header += sizeof(eth);
5791 if (mplsoudp_encap_conf.select_vlan) {
5792 if (mplsoudp_encap_conf.select_ipv4)
5793 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5795 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5796 memcpy(header, &vlan, sizeof(vlan));
5797 header += sizeof(vlan);
5799 if (mplsoudp_encap_conf.select_ipv4) {
5800 memcpy(header, &ipv4, sizeof(ipv4));
5801 header += sizeof(ipv4);
5803 memcpy(header, &ipv6, sizeof(ipv6));
5804 header += sizeof(ipv6);
5806 memcpy(header, &udp, sizeof(udp));
5807 header += sizeof(udp);
5808 memset(&mpls, 0, sizeof(mpls));
5809 memcpy(header, &mpls, sizeof(mpls));
5810 header += sizeof(mpls);
5811 action_decap_data->conf.size = header -
5812 action_decap_data->data;
5813 action->conf = &action_decap_data->conf;
5818 parse_vc_action_raw_decap_index(struct context *ctx, const struct token *token,
5819 const char *str, unsigned int len, void *buf,
5822 struct action_raw_decap_data *action_raw_decap_data;
5823 struct rte_flow_action *action;
5824 const struct arg *arg;
5825 struct buffer *out = buf;
5829 RTE_SET_USED(token);
5832 arg = ARGS_ENTRY_ARB_BOUNDED
5833 (offsetof(struct action_raw_decap_data, idx),
5834 sizeof(((struct action_raw_decap_data *)0)->idx),
5835 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
5836 if (push_args(ctx, arg))
5838 ret = parse_int(ctx, token, str, len, NULL, 0);
5845 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5846 action_raw_decap_data = ctx->object;
5847 idx = action_raw_decap_data->idx;
5848 action_raw_decap_data->conf.data = raw_decap_confs[idx].data;
5849 action_raw_decap_data->conf.size = raw_decap_confs[idx].size;
5850 action->conf = &action_raw_decap_data->conf;
5856 parse_vc_action_raw_encap_index(struct context *ctx, const struct token *token,
5857 const char *str, unsigned int len, void *buf,
5860 struct action_raw_encap_data *action_raw_encap_data;
5861 struct rte_flow_action *action;
5862 const struct arg *arg;
5863 struct buffer *out = buf;
5867 RTE_SET_USED(token);
5870 if (ctx->curr != ACTION_RAW_ENCAP_INDEX_VALUE)
5872 arg = ARGS_ENTRY_ARB_BOUNDED
5873 (offsetof(struct action_raw_encap_data, idx),
5874 sizeof(((struct action_raw_encap_data *)0)->idx),
5875 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
5876 if (push_args(ctx, arg))
5878 ret = parse_int(ctx, token, str, len, NULL, 0);
5885 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5886 action_raw_encap_data = ctx->object;
5887 idx = action_raw_encap_data->idx;
5888 action_raw_encap_data->conf.data = raw_encap_confs[idx].data;
5889 action_raw_encap_data->conf.size = raw_encap_confs[idx].size;
5890 action_raw_encap_data->conf.preserve = NULL;
5891 action->conf = &action_raw_encap_data->conf;
5896 parse_vc_action_raw_encap(struct context *ctx, const struct token *token,
5897 const char *str, unsigned int len, void *buf,
5900 struct buffer *out = buf;
5901 struct rte_flow_action *action;
5902 struct action_raw_encap_data *action_raw_encap_data = NULL;
5905 ret = parse_vc(ctx, token, str, len, buf, size);
5908 /* Nothing else to do if there is no buffer. */
5911 if (!out->args.vc.actions_n)
5913 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5914 /* Point to selected object. */
5915 ctx->object = out->args.vc.data;
5916 ctx->objmask = NULL;
5917 /* Copy the headers to the buffer. */
5918 action_raw_encap_data = ctx->object;
5919 action_raw_encap_data->conf.data = raw_encap_confs[0].data;
5920 action_raw_encap_data->conf.preserve = NULL;
5921 action_raw_encap_data->conf.size = raw_encap_confs[0].size;
5922 action->conf = &action_raw_encap_data->conf;
5927 parse_vc_action_raw_decap(struct context *ctx, const struct token *token,
5928 const char *str, unsigned int len, void *buf,
5931 struct buffer *out = buf;
5932 struct rte_flow_action *action;
5933 struct action_raw_decap_data *action_raw_decap_data = NULL;
5936 ret = parse_vc(ctx, token, str, len, buf, size);
5939 /* Nothing else to do if there is no buffer. */
5942 if (!out->args.vc.actions_n)
5944 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5945 /* Point to selected object. */
5946 ctx->object = out->args.vc.data;
5947 ctx->objmask = NULL;
5948 /* Copy the headers to the buffer. */
5949 action_raw_decap_data = ctx->object;
5950 action_raw_decap_data->conf.data = raw_decap_confs[0].data;
5951 action_raw_decap_data->conf.size = raw_decap_confs[0].size;
5952 action->conf = &action_raw_decap_data->conf;
5957 parse_vc_action_set_meta(struct context *ctx, const struct token *token,
5958 const char *str, unsigned int len, void *buf,
5963 ret = parse_vc(ctx, token, str, len, buf, size);
5966 ret = rte_flow_dynf_metadata_register();
5973 parse_vc_action_sample(struct context *ctx, const struct token *token,
5974 const char *str, unsigned int len, void *buf,
5977 struct buffer *out = buf;
5978 struct rte_flow_action *action;
5979 struct action_sample_data *action_sample_data = NULL;
5980 static struct rte_flow_action end_action = {
5981 RTE_FLOW_ACTION_TYPE_END, 0
5985 ret = parse_vc(ctx, token, str, len, buf, size);
5988 /* Nothing else to do if there is no buffer. */
5991 if (!out->args.vc.actions_n)
5993 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5994 /* Point to selected object. */
5995 ctx->object = out->args.vc.data;
5996 ctx->objmask = NULL;
5997 /* Copy the headers to the buffer. */
5998 action_sample_data = ctx->object;
5999 action_sample_data->conf.actions = &end_action;
6000 action->conf = &action_sample_data->conf;
6005 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
6006 const char *str, unsigned int len, void *buf,
6009 struct action_sample_data *action_sample_data;
6010 struct rte_flow_action *action;
6011 const struct arg *arg;
6012 struct buffer *out = buf;
6016 RTE_SET_USED(token);
6019 if (ctx->curr != ACTION_SAMPLE_INDEX_VALUE)
6021 arg = ARGS_ENTRY_ARB_BOUNDED
6022 (offsetof(struct action_sample_data, idx),
6023 sizeof(((struct action_sample_data *)0)->idx),
6024 0, RAW_SAMPLE_CONFS_MAX_NUM - 1);
6025 if (push_args(ctx, arg))
6027 ret = parse_int(ctx, token, str, len, NULL, 0);
6034 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6035 action_sample_data = ctx->object;
6036 idx = action_sample_data->idx;
6037 action_sample_data->conf.actions = raw_sample_confs[idx].data;
6038 action->conf = &action_sample_data->conf;
6042 /** Parse tokens for destroy command. */
6044 parse_destroy(struct context *ctx, const struct token *token,
6045 const char *str, unsigned int len,
6046 void *buf, unsigned int size)
6048 struct buffer *out = buf;
6050 /* Token name must match. */
6051 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6053 /* Nothing else to do if there is no buffer. */
6056 if (!out->command) {
6057 if (ctx->curr != DESTROY)
6059 if (sizeof(*out) > size)
6061 out->command = ctx->curr;
6064 ctx->objmask = NULL;
6065 out->args.destroy.rule =
6066 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6070 if (((uint8_t *)(out->args.destroy.rule + out->args.destroy.rule_n) +
6071 sizeof(*out->args.destroy.rule)) > (uint8_t *)out + size)
6074 ctx->object = out->args.destroy.rule + out->args.destroy.rule_n++;
6075 ctx->objmask = NULL;
6079 /** Parse tokens for flush command. */
6081 parse_flush(struct context *ctx, const struct token *token,
6082 const char *str, unsigned int len,
6083 void *buf, unsigned int size)
6085 struct buffer *out = buf;
6087 /* Token name must match. */
6088 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6090 /* Nothing else to do if there is no buffer. */
6093 if (!out->command) {
6094 if (ctx->curr != FLUSH)
6096 if (sizeof(*out) > size)
6098 out->command = ctx->curr;
6101 ctx->objmask = NULL;
6106 /** Parse tokens for dump command. */
6108 parse_dump(struct context *ctx, const struct token *token,
6109 const char *str, unsigned int len,
6110 void *buf, unsigned int size)
6112 struct buffer *out = buf;
6114 /* Token name must match. */
6115 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6117 /* Nothing else to do if there is no buffer. */
6120 if (!out->command) {
6121 if (ctx->curr != DUMP)
6123 if (sizeof(*out) > size)
6125 out->command = ctx->curr;
6128 ctx->objmask = NULL;
6133 /** Parse tokens for query command. */
6135 parse_query(struct context *ctx, const struct token *token,
6136 const char *str, unsigned int len,
6137 void *buf, unsigned int size)
6139 struct buffer *out = buf;
6141 /* Token name must match. */
6142 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6144 /* Nothing else to do if there is no buffer. */
6147 if (!out->command) {
6148 if (ctx->curr != QUERY)
6150 if (sizeof(*out) > size)
6152 out->command = ctx->curr;
6155 ctx->objmask = NULL;
6160 /** Parse action names. */
6162 parse_action(struct context *ctx, const struct token *token,
6163 const char *str, unsigned int len,
6164 void *buf, unsigned int size)
6166 struct buffer *out = buf;
6167 const struct arg *arg = pop_args(ctx);
6171 /* Argument is expected. */
6174 /* Parse action name. */
6175 for (i = 0; next_action[i]; ++i) {
6176 const struct parse_action_priv *priv;
6178 token = &token_list[next_action[i]];
6179 if (strcmp_partial(token->name, str, len))
6185 memcpy((uint8_t *)ctx->object + arg->offset,
6191 push_args(ctx, arg);
6195 /** Parse tokens for list command. */
6197 parse_list(struct context *ctx, const struct token *token,
6198 const char *str, unsigned int len,
6199 void *buf, unsigned int size)
6201 struct buffer *out = buf;
6203 /* Token name must match. */
6204 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6206 /* Nothing else to do if there is no buffer. */
6209 if (!out->command) {
6210 if (ctx->curr != LIST)
6212 if (sizeof(*out) > size)
6214 out->command = ctx->curr;
6217 ctx->objmask = NULL;
6218 out->args.list.group =
6219 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6223 if (((uint8_t *)(out->args.list.group + out->args.list.group_n) +
6224 sizeof(*out->args.list.group)) > (uint8_t *)out + size)
6227 ctx->object = out->args.list.group + out->args.list.group_n++;
6228 ctx->objmask = NULL;
6232 /** Parse tokens for list all aged flows command. */
6234 parse_aged(struct context *ctx, const struct token *token,
6235 const char *str, unsigned int len,
6236 void *buf, unsigned int size)
6238 struct buffer *out = buf;
6240 /* Token name must match. */
6241 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6243 /* Nothing else to do if there is no buffer. */
6246 if (!out->command) {
6247 if (ctx->curr != AGED)
6249 if (sizeof(*out) > size)
6251 out->command = ctx->curr;
6254 ctx->objmask = NULL;
6256 if (ctx->curr == AGED_DESTROY)
6257 out->args.aged.destroy = 1;
6261 /** Parse tokens for isolate command. */
6263 parse_isolate(struct context *ctx, const struct token *token,
6264 const char *str, unsigned int len,
6265 void *buf, unsigned int size)
6267 struct buffer *out = buf;
6269 /* Token name must match. */
6270 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6272 /* Nothing else to do if there is no buffer. */
6275 if (!out->command) {
6276 if (ctx->curr != ISOLATE)
6278 if (sizeof(*out) > size)
6280 out->command = ctx->curr;
6283 ctx->objmask = NULL;
6289 parse_tunnel(struct context *ctx, const struct token *token,
6290 const char *str, unsigned int len,
6291 void *buf, unsigned int size)
6293 struct buffer *out = buf;
6295 /* Token name must match. */
6296 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6298 /* Nothing else to do if there is no buffer. */
6301 if (!out->command) {
6302 if (ctx->curr != TUNNEL)
6304 if (sizeof(*out) > size)
6306 out->command = ctx->curr;
6309 ctx->objmask = NULL;
6311 switch (ctx->curr) {
6315 case TUNNEL_DESTROY:
6317 out->command = ctx->curr;
6319 case TUNNEL_CREATE_TYPE:
6320 case TUNNEL_DESTROY_ID:
6321 ctx->object = &out->args.vc.tunnel_ops;
6330 * Parse signed/unsigned integers 8 to 64-bit long.
6332 * Last argument (ctx->args) is retrieved to determine integer type and
6336 parse_int(struct context *ctx, const struct token *token,
6337 const char *str, unsigned int len,
6338 void *buf, unsigned int size)
6340 const struct arg *arg = pop_args(ctx);
6345 /* Argument is expected. */
6350 (uintmax_t)strtoimax(str, &end, 0) :
6351 strtoumax(str, &end, 0);
6352 if (errno || (size_t)(end - str) != len)
6355 ((arg->sign && ((intmax_t)u < (intmax_t)arg->min ||
6356 (intmax_t)u > (intmax_t)arg->max)) ||
6357 (!arg->sign && (u < arg->min || u > arg->max))))
6362 if (!arg_entry_bf_fill(ctx->object, u, arg) ||
6363 !arg_entry_bf_fill(ctx->objmask, -1, arg))
6367 buf = (uint8_t *)ctx->object + arg->offset;
6369 if (u > RTE_LEN2MASK(size * CHAR_BIT, uint64_t))
6373 case sizeof(uint8_t):
6374 *(uint8_t *)buf = u;
6376 case sizeof(uint16_t):
6377 *(uint16_t *)buf = arg->hton ? rte_cpu_to_be_16(u) : u;
6379 case sizeof(uint8_t [3]):
6380 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
6382 ((uint8_t *)buf)[0] = u;
6383 ((uint8_t *)buf)[1] = u >> 8;
6384 ((uint8_t *)buf)[2] = u >> 16;
6388 ((uint8_t *)buf)[0] = u >> 16;
6389 ((uint8_t *)buf)[1] = u >> 8;
6390 ((uint8_t *)buf)[2] = u;
6392 case sizeof(uint32_t):
6393 *(uint32_t *)buf = arg->hton ? rte_cpu_to_be_32(u) : u;
6395 case sizeof(uint64_t):
6396 *(uint64_t *)buf = arg->hton ? rte_cpu_to_be_64(u) : u;
6401 if (ctx->objmask && buf != (uint8_t *)ctx->objmask + arg->offset) {
6403 buf = (uint8_t *)ctx->objmask + arg->offset;
6408 push_args(ctx, arg);
6415 * Three arguments (ctx->args) are retrieved from the stack to store data,
6416 * its actual length and address (in that order).
6419 parse_string(struct context *ctx, const struct token *token,
6420 const char *str, unsigned int len,
6421 void *buf, unsigned int size)
6423 const struct arg *arg_data = pop_args(ctx);
6424 const struct arg *arg_len = pop_args(ctx);
6425 const struct arg *arg_addr = pop_args(ctx);
6426 char tmp[16]; /* Ought to be enough. */
6429 /* Arguments are expected. */
6433 push_args(ctx, arg_data);
6437 push_args(ctx, arg_len);
6438 push_args(ctx, arg_data);
6441 size = arg_data->size;
6442 /* Bit-mask fill is not supported. */
6443 if (arg_data->mask || size < len)
6447 /* Let parse_int() fill length information first. */
6448 ret = snprintf(tmp, sizeof(tmp), "%u", len);
6451 push_args(ctx, arg_len);
6452 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
6457 buf = (uint8_t *)ctx->object + arg_data->offset;
6458 /* Output buffer is not necessarily NUL-terminated. */
6459 memcpy(buf, str, len);
6460 memset((uint8_t *)buf + len, 0x00, size - len);
6462 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
6463 /* Save address if requested. */
6464 if (arg_addr->size) {
6465 memcpy((uint8_t *)ctx->object + arg_addr->offset,
6467 (uint8_t *)ctx->object + arg_data->offset
6471 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
6473 (uint8_t *)ctx->objmask + arg_data->offset
6479 push_args(ctx, arg_addr);
6480 push_args(ctx, arg_len);
6481 push_args(ctx, arg_data);
6486 parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
6492 /* Check input parameters */
6493 if ((src == NULL) ||
6499 /* Convert chars to bytes */
6500 for (i = 0, len = 0; i < *size; i += 2) {
6501 snprintf(tmp, 3, "%s", src + i);
6502 dst[len++] = strtoul(tmp, &c, 16);
6517 parse_hex(struct context *ctx, const struct token *token,
6518 const char *str, unsigned int len,
6519 void *buf, unsigned int size)
6521 const struct arg *arg_data = pop_args(ctx);
6522 const struct arg *arg_len = pop_args(ctx);
6523 const struct arg *arg_addr = pop_args(ctx);
6524 char tmp[16]; /* Ought to be enough. */
6526 unsigned int hexlen = len;
6527 unsigned int length = 256;
6528 uint8_t hex_tmp[length];
6530 /* Arguments are expected. */
6534 push_args(ctx, arg_data);
6538 push_args(ctx, arg_len);
6539 push_args(ctx, arg_data);
6542 size = arg_data->size;
6543 /* Bit-mask fill is not supported. */
6549 /* translate bytes string to array. */
6550 if (str[0] == '0' && ((str[1] == 'x') ||
6555 if (hexlen > length)
6557 ret = parse_hex_string(str, hex_tmp, &hexlen);
6560 /* Let parse_int() fill length information first. */
6561 ret = snprintf(tmp, sizeof(tmp), "%u", hexlen);
6564 /* Save length if requested. */
6565 if (arg_len->size) {
6566 push_args(ctx, arg_len);
6567 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
6573 buf = (uint8_t *)ctx->object + arg_data->offset;
6574 /* Output buffer is not necessarily NUL-terminated. */
6575 memcpy(buf, hex_tmp, hexlen);
6576 memset((uint8_t *)buf + hexlen, 0x00, size - hexlen);
6578 memset((uint8_t *)ctx->objmask + arg_data->offset,
6580 /* Save address if requested. */
6581 if (arg_addr->size) {
6582 memcpy((uint8_t *)ctx->object + arg_addr->offset,
6584 (uint8_t *)ctx->object + arg_data->offset
6588 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
6590 (uint8_t *)ctx->objmask + arg_data->offset
6596 push_args(ctx, arg_addr);
6597 push_args(ctx, arg_len);
6598 push_args(ctx, arg_data);
6604 * Parse a zero-ended string.
6607 parse_string0(struct context *ctx, const struct token *token __rte_unused,
6608 const char *str, unsigned int len,
6609 void *buf, unsigned int size)
6611 const struct arg *arg_data = pop_args(ctx);
6613 /* Arguments are expected. */
6616 size = arg_data->size;
6617 /* Bit-mask fill is not supported. */
6618 if (arg_data->mask || size < len + 1)
6622 buf = (uint8_t *)ctx->object + arg_data->offset;
6623 strncpy(buf, str, len);
6625 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
6628 push_args(ctx, arg_data);
6633 * Parse a MAC address.
6635 * Last argument (ctx->args) is retrieved to determine storage size and
6639 parse_mac_addr(struct context *ctx, const struct token *token,
6640 const char *str, unsigned int len,
6641 void *buf, unsigned int size)
6643 const struct arg *arg = pop_args(ctx);
6644 struct rte_ether_addr tmp;
6648 /* Argument is expected. */
6652 /* Bit-mask fill is not supported. */
6653 if (arg->mask || size != sizeof(tmp))
6655 /* Only network endian is supported. */
6658 ret = cmdline_parse_etheraddr(NULL, str, &tmp, size);
6659 if (ret < 0 || (unsigned int)ret != len)
6663 buf = (uint8_t *)ctx->object + arg->offset;
6664 memcpy(buf, &tmp, size);
6666 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6669 push_args(ctx, arg);
6674 * Parse an IPv4 address.
6676 * Last argument (ctx->args) is retrieved to determine storage size and
6680 parse_ipv4_addr(struct context *ctx, const struct token *token,
6681 const char *str, unsigned int len,
6682 void *buf, unsigned int size)
6684 const struct arg *arg = pop_args(ctx);
6689 /* Argument is expected. */
6693 /* Bit-mask fill is not supported. */
6694 if (arg->mask || size != sizeof(tmp))
6696 /* Only network endian is supported. */
6699 memcpy(str2, str, len);
6701 ret = inet_pton(AF_INET, str2, &tmp);
6703 /* Attempt integer parsing. */
6704 push_args(ctx, arg);
6705 return parse_int(ctx, token, str, len, buf, size);
6709 buf = (uint8_t *)ctx->object + arg->offset;
6710 memcpy(buf, &tmp, size);
6712 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6715 push_args(ctx, arg);
6720 * Parse an IPv6 address.
6722 * Last argument (ctx->args) is retrieved to determine storage size and
6726 parse_ipv6_addr(struct context *ctx, const struct token *token,
6727 const char *str, unsigned int len,
6728 void *buf, unsigned int size)
6730 const struct arg *arg = pop_args(ctx);
6732 struct in6_addr tmp;
6736 /* Argument is expected. */
6740 /* Bit-mask fill is not supported. */
6741 if (arg->mask || size != sizeof(tmp))
6743 /* Only network endian is supported. */
6746 memcpy(str2, str, len);
6748 ret = inet_pton(AF_INET6, str2, &tmp);
6753 buf = (uint8_t *)ctx->object + arg->offset;
6754 memcpy(buf, &tmp, size);
6756 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6759 push_args(ctx, arg);
6763 /** Boolean values (even indices stand for false). */
6764 static const char *const boolean_name[] = {
6774 * Parse a boolean value.
6776 * Last argument (ctx->args) is retrieved to determine storage size and
6780 parse_boolean(struct context *ctx, const struct token *token,
6781 const char *str, unsigned int len,
6782 void *buf, unsigned int size)
6784 const struct arg *arg = pop_args(ctx);
6788 /* Argument is expected. */
6791 for (i = 0; boolean_name[i]; ++i)
6792 if (!strcmp_partial(boolean_name[i], str, len))
6794 /* Process token as integer. */
6795 if (boolean_name[i])
6796 str = i & 1 ? "1" : "0";
6797 push_args(ctx, arg);
6798 ret = parse_int(ctx, token, str, strlen(str), buf, size);
6799 return ret > 0 ? (int)len : ret;
6802 /** Parse port and update context. */
6804 parse_port(struct context *ctx, const struct token *token,
6805 const char *str, unsigned int len,
6806 void *buf, unsigned int size)
6808 struct buffer *out = &(struct buffer){ .port = 0 };
6816 ctx->objmask = NULL;
6817 size = sizeof(*out);
6819 ret = parse_int(ctx, token, str, len, out, size);
6821 ctx->port = out->port;
6828 parse_sa_id2ptr(struct context *ctx, const struct token *token,
6829 const char *str, unsigned int len,
6830 void *buf, unsigned int size)
6832 struct rte_flow_action *action = ctx->object;
6840 ctx->objmask = NULL;
6841 ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
6842 ctx->object = action;
6843 if (ret != (int)len)
6845 /* set shared action */
6847 action->conf = port_shared_action_get_by_id(ctx->port, id);
6848 ret = (action->conf) ? ret : -1;
6853 /** Parse set command, initialize output buffer for subsequent tokens. */
6855 parse_set_raw_encap_decap(struct context *ctx, const struct token *token,
6856 const char *str, unsigned int len,
6857 void *buf, unsigned int size)
6859 struct buffer *out = buf;
6861 /* Token name must match. */
6862 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6864 /* Nothing else to do if there is no buffer. */
6867 /* Make sure buffer is large enough. */
6868 if (size < sizeof(*out))
6871 ctx->objmask = NULL;
6875 out->command = ctx->curr;
6876 /* For encap/decap we need is pattern */
6877 out->args.vc.pattern = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6882 /** Parse set command, initialize output buffer for subsequent tokens. */
6884 parse_set_sample_action(struct context *ctx, const struct token *token,
6885 const char *str, unsigned int len,
6886 void *buf, unsigned int size)
6888 struct buffer *out = buf;
6890 /* Token name must match. */
6891 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6893 /* Nothing else to do if there is no buffer. */
6896 /* Make sure buffer is large enough. */
6897 if (size < sizeof(*out))
6900 ctx->objmask = NULL;
6904 out->command = ctx->curr;
6905 /* For sampler we need is actions */
6906 out->args.vc.actions = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6912 * Parse set raw_encap/raw_decap command,
6913 * initialize output buffer for subsequent tokens.
6916 parse_set_init(struct context *ctx, const struct token *token,
6917 const char *str, unsigned int len,
6918 void *buf, unsigned int size)
6920 struct buffer *out = buf;
6922 /* Token name must match. */
6923 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6925 /* Nothing else to do if there is no buffer. */
6928 /* Make sure buffer is large enough. */
6929 if (size < sizeof(*out))
6931 /* Initialize buffer. */
6932 memset(out, 0x00, sizeof(*out));
6933 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
6936 ctx->objmask = NULL;
6937 if (!out->command) {
6938 if (ctx->curr != SET)
6940 if (sizeof(*out) > size)
6942 out->command = ctx->curr;
6943 out->args.vc.data = (uint8_t *)out + size;
6944 ctx->object = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6950 /** No completion. */
6952 comp_none(struct context *ctx, const struct token *token,
6953 unsigned int ent, char *buf, unsigned int size)
6963 /** Complete boolean values. */
6965 comp_boolean(struct context *ctx, const struct token *token,
6966 unsigned int ent, char *buf, unsigned int size)
6972 for (i = 0; boolean_name[i]; ++i)
6973 if (buf && i == ent)
6974 return strlcpy(buf, boolean_name[i], size);
6980 /** Complete action names. */
6982 comp_action(struct context *ctx, const struct token *token,
6983 unsigned int ent, char *buf, unsigned int size)
6989 for (i = 0; next_action[i]; ++i)
6990 if (buf && i == ent)
6991 return strlcpy(buf, token_list[next_action[i]].name,
6998 /** Complete available ports. */
7000 comp_port(struct context *ctx, const struct token *token,
7001 unsigned int ent, char *buf, unsigned int size)
7008 RTE_ETH_FOREACH_DEV(p) {
7009 if (buf && i == ent)
7010 return snprintf(buf, size, "%u", p);
7018 /** Complete available rule IDs. */
7020 comp_rule_id(struct context *ctx, const struct token *token,
7021 unsigned int ent, char *buf, unsigned int size)
7024 struct rte_port *port;
7025 struct port_flow *pf;
7028 if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
7029 ctx->port == (portid_t)RTE_PORT_ALL)
7031 port = &ports[ctx->port];
7032 for (pf = port->flow_list; pf != NULL; pf = pf->next) {
7033 if (buf && i == ent)
7034 return snprintf(buf, size, "%u", pf->id);
7042 /** Complete type field for RSS action. */
7044 comp_vc_action_rss_type(struct context *ctx, const struct token *token,
7045 unsigned int ent, char *buf, unsigned int size)
7051 for (i = 0; rss_type_table[i].str; ++i)
7056 return strlcpy(buf, rss_type_table[ent].str, size);
7058 return snprintf(buf, size, "end");
7062 /** Complete queue field for RSS action. */
7064 comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
7065 unsigned int ent, char *buf, unsigned int size)
7072 return snprintf(buf, size, "%u", ent);
7074 return snprintf(buf, size, "end");
7078 /** Complete index number for set raw_encap/raw_decap commands. */
7080 comp_set_raw_index(struct context *ctx, const struct token *token,
7081 unsigned int ent, char *buf, unsigned int size)
7087 RTE_SET_USED(token);
7088 for (idx = 0; idx < RAW_ENCAP_CONFS_MAX_NUM; ++idx) {
7089 if (buf && idx == ent)
7090 return snprintf(buf, size, "%u", idx);
7096 /** Complete index number for set raw_encap/raw_decap commands. */
7098 comp_set_sample_index(struct context *ctx, const struct token *token,
7099 unsigned int ent, char *buf, unsigned int size)
7105 RTE_SET_USED(token);
7106 for (idx = 0; idx < RAW_SAMPLE_CONFS_MAX_NUM; ++idx) {
7107 if (buf && idx == ent)
7108 return snprintf(buf, size, "%u", idx);
7114 /** Internal context. */
7115 static struct context cmd_flow_context;
7117 /** Global parser instance (cmdline API). */
7118 cmdline_parse_inst_t cmd_flow;
7119 cmdline_parse_inst_t cmd_set_raw;
7121 /** Initialize context. */
7123 cmd_flow_context_init(struct context *ctx)
7125 /* A full memset() is not necessary. */
7135 ctx->objmask = NULL;
7138 /** Parse a token (cmdline API). */
7140 cmd_flow_parse(cmdline_parse_token_hdr_t *hdr, const char *src, void *result,
7143 struct context *ctx = &cmd_flow_context;
7144 const struct token *token;
7145 const enum index *list;
7150 token = &token_list[ctx->curr];
7151 /* Check argument length. */
7154 for (len = 0; src[len]; ++len)
7155 if (src[len] == '#' || isspace(src[len]))
7159 /* Last argument and EOL detection. */
7160 for (i = len; src[i]; ++i)
7161 if (src[i] == '#' || src[i] == '\r' || src[i] == '\n')
7163 else if (!isspace(src[i])) {
7168 if (src[i] == '\r' || src[i] == '\n') {
7172 /* Initialize context if necessary. */
7173 if (!ctx->next_num) {
7176 ctx->next[ctx->next_num++] = token->next[0];
7178 /* Process argument through candidates. */
7179 ctx->prev = ctx->curr;
7180 list = ctx->next[ctx->next_num - 1];
7181 for (i = 0; list[i]; ++i) {
7182 const struct token *next = &token_list[list[i]];
7185 ctx->curr = list[i];
7187 tmp = next->call(ctx, next, src, len, result, size);
7189 tmp = parse_default(ctx, next, src, len, result, size);
7190 if (tmp == -1 || tmp != len)
7198 /* Push subsequent tokens if any. */
7200 for (i = 0; token->next[i]; ++i) {
7201 if (ctx->next_num == RTE_DIM(ctx->next))
7203 ctx->next[ctx->next_num++] = token->next[i];
7205 /* Push arguments if any. */
7207 for (i = 0; token->args[i]; ++i) {
7208 if (ctx->args_num == RTE_DIM(ctx->args))
7210 ctx->args[ctx->args_num++] = token->args[i];
7215 /** Return number of completion entries (cmdline API). */
7217 cmd_flow_complete_get_nb(cmdline_parse_token_hdr_t *hdr)
7219 struct context *ctx = &cmd_flow_context;
7220 const struct token *token = &token_list[ctx->curr];
7221 const enum index *list;
7225 /* Count number of tokens in current list. */
7227 list = ctx->next[ctx->next_num - 1];
7229 list = token->next[0];
7230 for (i = 0; list[i]; ++i)
7235 * If there is a single token, use its completion callback, otherwise
7236 * return the number of entries.
7238 token = &token_list[list[0]];
7239 if (i == 1 && token->comp) {
7240 /* Save index for cmd_flow_get_help(). */
7241 ctx->prev = list[0];
7242 return token->comp(ctx, token, 0, NULL, 0);
7247 /** Return a completion entry (cmdline API). */
7249 cmd_flow_complete_get_elt(cmdline_parse_token_hdr_t *hdr, int index,
7250 char *dst, unsigned int size)
7252 struct context *ctx = &cmd_flow_context;
7253 const struct token *token = &token_list[ctx->curr];
7254 const enum index *list;
7258 /* Count number of tokens in current list. */
7260 list = ctx->next[ctx->next_num - 1];
7262 list = token->next[0];
7263 for (i = 0; list[i]; ++i)
7267 /* If there is a single token, use its completion callback. */
7268 token = &token_list[list[0]];
7269 if (i == 1 && token->comp) {
7270 /* Save index for cmd_flow_get_help(). */
7271 ctx->prev = list[0];
7272 return token->comp(ctx, token, index, dst, size) < 0 ? -1 : 0;
7274 /* Otherwise make sure the index is valid and use defaults. */
7277 token = &token_list[list[index]];
7278 strlcpy(dst, token->name, size);
7279 /* Save index for cmd_flow_get_help(). */
7280 ctx->prev = list[index];
7284 /** Populate help strings for current token (cmdline API). */
7286 cmd_flow_get_help(cmdline_parse_token_hdr_t *hdr, char *dst, unsigned int size)
7288 struct context *ctx = &cmd_flow_context;
7289 const struct token *token = &token_list[ctx->prev];
7294 /* Set token type and update global help with details. */
7295 strlcpy(dst, (token->type ? token->type : "TOKEN"), size);
7297 cmd_flow.help_str = token->help;
7299 cmd_flow.help_str = token->name;
7303 /** Token definition template (cmdline API). */
7304 static struct cmdline_token_hdr cmd_flow_token_hdr = {
7305 .ops = &(struct cmdline_token_ops){
7306 .parse = cmd_flow_parse,
7307 .complete_get_nb = cmd_flow_complete_get_nb,
7308 .complete_get_elt = cmd_flow_complete_get_elt,
7309 .get_help = cmd_flow_get_help,
7314 /** Populate the next dynamic token. */
7316 cmd_flow_tok(cmdline_parse_token_hdr_t **hdr,
7317 cmdline_parse_token_hdr_t **hdr_inst)
7319 struct context *ctx = &cmd_flow_context;
7321 /* Always reinitialize context before requesting the first token. */
7322 if (!(hdr_inst - cmd_flow.tokens))
7323 cmd_flow_context_init(ctx);
7324 /* Return NULL when no more tokens are expected. */
7325 if (!ctx->next_num && ctx->curr) {
7329 /* Determine if command should end here. */
7330 if (ctx->eol && ctx->last && ctx->next_num) {
7331 const enum index *list = ctx->next[ctx->next_num - 1];
7334 for (i = 0; list[i]; ++i) {
7341 *hdr = &cmd_flow_token_hdr;
7344 /** Dispatch parsed buffer to function calls. */
7346 cmd_flow_parsed(const struct buffer *in)
7348 switch (in->command) {
7349 case SHARED_ACTION_CREATE:
7350 port_shared_action_create(
7351 in->port, in->args.vc.attr.group,
7352 &((const struct rte_flow_shared_action_conf) {
7353 .ingress = in->args.vc.attr.ingress,
7354 .egress = in->args.vc.attr.egress,
7355 .transfer = in->args.vc.attr.transfer,
7357 in->args.vc.actions);
7359 case SHARED_ACTION_DESTROY:
7360 port_shared_action_destroy(in->port,
7361 in->args.sa_destroy.action_id_n,
7362 in->args.sa_destroy.action_id);
7364 case SHARED_ACTION_UPDATE:
7365 port_shared_action_update(in->port, in->args.vc.attr.group,
7366 in->args.vc.actions);
7368 case SHARED_ACTION_QUERY:
7369 port_shared_action_query(in->port, in->args.sa.action_id);
7372 port_flow_validate(in->port, &in->args.vc.attr,
7373 in->args.vc.pattern, in->args.vc.actions,
7374 &in->args.vc.tunnel_ops);
7377 port_flow_create(in->port, &in->args.vc.attr,
7378 in->args.vc.pattern, in->args.vc.actions,
7379 &in->args.vc.tunnel_ops);
7382 port_flow_destroy(in->port, in->args.destroy.rule_n,
7383 in->args.destroy.rule);
7386 port_flow_flush(in->port);
7389 port_flow_dump(in->port, in->args.dump.file);
7392 port_flow_query(in->port, in->args.query.rule,
7393 &in->args.query.action);
7396 port_flow_list(in->port, in->args.list.group_n,
7397 in->args.list.group);
7400 port_flow_isolate(in->port, in->args.isolate.set);
7403 port_flow_aged(in->port, in->args.aged.destroy);
7406 port_flow_tunnel_create(in->port, &in->args.vc.tunnel_ops);
7408 case TUNNEL_DESTROY:
7409 port_flow_tunnel_destroy(in->port, in->args.vc.tunnel_ops.id);
7412 port_flow_tunnel_list(in->port);
7419 /** Token generator and output processing callback (cmdline API). */
7421 cmd_flow_cb(void *arg0, struct cmdline *cl, void *arg2)
7424 cmd_flow_tok(arg0, arg2);
7426 cmd_flow_parsed(arg0);
7429 /** Global parser instance (cmdline API). */
7430 cmdline_parse_inst_t cmd_flow = {
7432 .data = NULL, /**< Unused. */
7433 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
7436 }, /**< Tokens are returned by cmd_flow_tok(). */
7439 /** set cmd facility. Reuse cmd flow's infrastructure as much as possible. */
7442 update_fields(uint8_t *buf, struct rte_flow_item *item, uint16_t next_proto)
7444 struct rte_ipv4_hdr *ipv4;
7445 struct rte_ether_hdr *eth;
7446 struct rte_ipv6_hdr *ipv6;
7447 struct rte_vxlan_hdr *vxlan;
7448 struct rte_vxlan_gpe_hdr *gpe;
7449 struct rte_flow_item_nvgre *nvgre;
7450 uint32_t ipv6_vtc_flow;
7452 switch (item->type) {
7453 case RTE_FLOW_ITEM_TYPE_ETH:
7454 eth = (struct rte_ether_hdr *)buf;
7456 eth->ether_type = rte_cpu_to_be_16(next_proto);
7458 case RTE_FLOW_ITEM_TYPE_IPV4:
7459 ipv4 = (struct rte_ipv4_hdr *)buf;
7460 ipv4->version_ihl = 0x45;
7461 if (next_proto && ipv4->next_proto_id == 0)
7462 ipv4->next_proto_id = (uint8_t)next_proto;
7464 case RTE_FLOW_ITEM_TYPE_IPV6:
7465 ipv6 = (struct rte_ipv6_hdr *)buf;
7466 if (next_proto && ipv6->proto == 0)
7467 ipv6->proto = (uint8_t)next_proto;
7468 ipv6_vtc_flow = rte_be_to_cpu_32(ipv6->vtc_flow);
7469 ipv6_vtc_flow &= 0x0FFFFFFF; /*< reset version bits. */
7470 ipv6_vtc_flow |= 0x60000000; /*< set ipv6 version. */
7471 ipv6->vtc_flow = rte_cpu_to_be_32(ipv6_vtc_flow);
7473 case RTE_FLOW_ITEM_TYPE_VXLAN:
7474 vxlan = (struct rte_vxlan_hdr *)buf;
7475 vxlan->vx_flags = 0x08;
7477 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
7478 gpe = (struct rte_vxlan_gpe_hdr *)buf;
7479 gpe->vx_flags = 0x0C;
7481 case RTE_FLOW_ITEM_TYPE_NVGRE:
7482 nvgre = (struct rte_flow_item_nvgre *)buf;
7483 nvgre->protocol = rte_cpu_to_be_16(0x6558);
7484 nvgre->c_k_s_rsvd0_ver = rte_cpu_to_be_16(0x2000);
7491 /** Helper of get item's default mask. */
7493 flow_item_default_mask(const struct rte_flow_item *item)
7495 const void *mask = NULL;
7496 static rte_be32_t gre_key_default_mask = RTE_BE32(UINT32_MAX);
7498 switch (item->type) {
7499 case RTE_FLOW_ITEM_TYPE_ANY:
7500 mask = &rte_flow_item_any_mask;
7502 case RTE_FLOW_ITEM_TYPE_VF:
7503 mask = &rte_flow_item_vf_mask;
7505 case RTE_FLOW_ITEM_TYPE_PORT_ID:
7506 mask = &rte_flow_item_port_id_mask;
7508 case RTE_FLOW_ITEM_TYPE_RAW:
7509 mask = &rte_flow_item_raw_mask;
7511 case RTE_FLOW_ITEM_TYPE_ETH:
7512 mask = &rte_flow_item_eth_mask;
7514 case RTE_FLOW_ITEM_TYPE_VLAN:
7515 mask = &rte_flow_item_vlan_mask;
7517 case RTE_FLOW_ITEM_TYPE_IPV4:
7518 mask = &rte_flow_item_ipv4_mask;
7520 case RTE_FLOW_ITEM_TYPE_IPV6:
7521 mask = &rte_flow_item_ipv6_mask;
7523 case RTE_FLOW_ITEM_TYPE_ICMP:
7524 mask = &rte_flow_item_icmp_mask;
7526 case RTE_FLOW_ITEM_TYPE_UDP:
7527 mask = &rte_flow_item_udp_mask;
7529 case RTE_FLOW_ITEM_TYPE_TCP:
7530 mask = &rte_flow_item_tcp_mask;
7532 case RTE_FLOW_ITEM_TYPE_SCTP:
7533 mask = &rte_flow_item_sctp_mask;
7535 case RTE_FLOW_ITEM_TYPE_VXLAN:
7536 mask = &rte_flow_item_vxlan_mask;
7538 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
7539 mask = &rte_flow_item_vxlan_gpe_mask;
7541 case RTE_FLOW_ITEM_TYPE_E_TAG:
7542 mask = &rte_flow_item_e_tag_mask;
7544 case RTE_FLOW_ITEM_TYPE_NVGRE:
7545 mask = &rte_flow_item_nvgre_mask;
7547 case RTE_FLOW_ITEM_TYPE_MPLS:
7548 mask = &rte_flow_item_mpls_mask;
7550 case RTE_FLOW_ITEM_TYPE_GRE:
7551 mask = &rte_flow_item_gre_mask;
7553 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
7554 mask = &gre_key_default_mask;
7556 case RTE_FLOW_ITEM_TYPE_META:
7557 mask = &rte_flow_item_meta_mask;
7559 case RTE_FLOW_ITEM_TYPE_FUZZY:
7560 mask = &rte_flow_item_fuzzy_mask;
7562 case RTE_FLOW_ITEM_TYPE_GTP:
7563 mask = &rte_flow_item_gtp_mask;
7565 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
7566 mask = &rte_flow_item_gtp_psc_mask;
7568 case RTE_FLOW_ITEM_TYPE_GENEVE:
7569 mask = &rte_flow_item_geneve_mask;
7571 case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
7572 mask = &rte_flow_item_geneve_opt_mask;
7574 case RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID:
7575 mask = &rte_flow_item_pppoe_proto_id_mask;
7577 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
7578 mask = &rte_flow_item_l2tpv3oip_mask;
7580 case RTE_FLOW_ITEM_TYPE_ESP:
7581 mask = &rte_flow_item_esp_mask;
7583 case RTE_FLOW_ITEM_TYPE_AH:
7584 mask = &rte_flow_item_ah_mask;
7586 case RTE_FLOW_ITEM_TYPE_PFCP:
7587 mask = &rte_flow_item_pfcp_mask;
7595 /** Dispatch parsed buffer to function calls. */
7597 cmd_set_raw_parsed_sample(const struct buffer *in)
7599 uint32_t n = in->args.vc.actions_n;
7601 struct rte_flow_action *action = NULL;
7602 struct rte_flow_action *data = NULL;
7604 uint16_t idx = in->port; /* We borrow port field as index */
7605 uint32_t max_size = sizeof(struct rte_flow_action) *
7606 ACTION_SAMPLE_ACTIONS_NUM;
7608 RTE_ASSERT(in->command == SET_SAMPLE_ACTIONS);
7609 data = (struct rte_flow_action *)&raw_sample_confs[idx].data;
7610 memset(data, 0x00, max_size);
7611 for (; i <= n - 1; i++) {
7612 action = in->args.vc.actions + i;
7613 if (action->type == RTE_FLOW_ACTION_TYPE_END)
7615 switch (action->type) {
7616 case RTE_FLOW_ACTION_TYPE_MARK:
7617 size = sizeof(struct rte_flow_action_mark);
7618 rte_memcpy(&sample_mark[idx],
7619 (const void *)action->conf, size);
7620 action->conf = &sample_mark[idx];
7622 case RTE_FLOW_ACTION_TYPE_COUNT:
7623 size = sizeof(struct rte_flow_action_count);
7624 rte_memcpy(&sample_count[idx],
7625 (const void *)action->conf, size);
7626 action->conf = &sample_count[idx];
7628 case RTE_FLOW_ACTION_TYPE_QUEUE:
7629 size = sizeof(struct rte_flow_action_queue);
7630 rte_memcpy(&sample_queue[idx],
7631 (const void *)action->conf, size);
7632 action->conf = &sample_queue[idx];
7634 case RTE_FLOW_ACTION_TYPE_RAW_ENCAP:
7635 size = sizeof(struct rte_flow_action_raw_encap);
7636 rte_memcpy(&sample_encap[idx],
7637 (const void *)action->conf, size);
7638 action->conf = &sample_encap[idx];
7640 case RTE_FLOW_ACTION_TYPE_PORT_ID:
7641 size = sizeof(struct rte_flow_action_port_id);
7642 rte_memcpy(&sample_port_id[idx],
7643 (const void *)action->conf, size);
7644 action->conf = &sample_port_id[idx];
7647 printf("Error - Not supported action\n");
7650 rte_memcpy(data, action, sizeof(struct rte_flow_action));
7655 /** Dispatch parsed buffer to function calls. */
7657 cmd_set_raw_parsed(const struct buffer *in)
7659 uint32_t n = in->args.vc.pattern_n;
7661 struct rte_flow_item *item = NULL;
7663 uint8_t *data = NULL;
7664 uint8_t *data_tail = NULL;
7665 size_t *total_size = NULL;
7666 uint16_t upper_layer = 0;
7668 uint16_t idx = in->port; /* We borrow port field as index */
7669 int gtp_psc = -1; /* GTP PSC option index. */
7671 if (in->command == SET_SAMPLE_ACTIONS)
7672 return cmd_set_raw_parsed_sample(in);
7673 RTE_ASSERT(in->command == SET_RAW_ENCAP ||
7674 in->command == SET_RAW_DECAP);
7675 if (in->command == SET_RAW_ENCAP) {
7676 total_size = &raw_encap_confs[idx].size;
7677 data = (uint8_t *)&raw_encap_confs[idx].data;
7679 total_size = &raw_decap_confs[idx].size;
7680 data = (uint8_t *)&raw_decap_confs[idx].data;
7683 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
7684 /* process hdr from upper layer to low layer (L3/L4 -> L2). */
7685 data_tail = data + ACTION_RAW_ENCAP_MAX_DATA;
7686 for (i = n - 1 ; i >= 0; --i) {
7687 const struct rte_flow_item_gtp *gtp;
7688 const struct rte_flow_item_geneve_opt *opt;
7690 item = in->args.vc.pattern + i;
7691 if (item->spec == NULL)
7692 item->spec = flow_item_default_mask(item);
7693 switch (item->type) {
7694 case RTE_FLOW_ITEM_TYPE_ETH:
7695 size = sizeof(struct rte_ether_hdr);
7697 case RTE_FLOW_ITEM_TYPE_VLAN:
7698 size = sizeof(struct rte_vlan_hdr);
7699 proto = RTE_ETHER_TYPE_VLAN;
7701 case RTE_FLOW_ITEM_TYPE_IPV4:
7702 size = sizeof(struct rte_ipv4_hdr);
7703 proto = RTE_ETHER_TYPE_IPV4;
7705 case RTE_FLOW_ITEM_TYPE_IPV6:
7706 size = sizeof(struct rte_ipv6_hdr);
7707 proto = RTE_ETHER_TYPE_IPV6;
7709 case RTE_FLOW_ITEM_TYPE_UDP:
7710 size = sizeof(struct rte_udp_hdr);
7713 case RTE_FLOW_ITEM_TYPE_TCP:
7714 size = sizeof(struct rte_tcp_hdr);
7717 case RTE_FLOW_ITEM_TYPE_VXLAN:
7718 size = sizeof(struct rte_vxlan_hdr);
7720 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
7721 size = sizeof(struct rte_vxlan_gpe_hdr);
7723 case RTE_FLOW_ITEM_TYPE_GRE:
7724 size = sizeof(struct rte_gre_hdr);
7727 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
7728 size = sizeof(rte_be32_t);
7731 case RTE_FLOW_ITEM_TYPE_MPLS:
7732 size = sizeof(struct rte_mpls_hdr);
7735 case RTE_FLOW_ITEM_TYPE_NVGRE:
7736 size = sizeof(struct rte_flow_item_nvgre);
7739 case RTE_FLOW_ITEM_TYPE_GENEVE:
7740 size = sizeof(struct rte_geneve_hdr);
7742 case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
7743 opt = (const struct rte_flow_item_geneve_opt *)
7745 size = offsetof(struct rte_flow_item_geneve_opt, data);
7746 if (opt->option_len && opt->data) {
7747 *total_size += opt->option_len *
7749 rte_memcpy(data_tail - (*total_size),
7751 opt->option_len * sizeof(uint32_t));
7754 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
7755 size = sizeof(rte_be32_t);
7758 case RTE_FLOW_ITEM_TYPE_ESP:
7759 size = sizeof(struct rte_esp_hdr);
7762 case RTE_FLOW_ITEM_TYPE_AH:
7763 size = sizeof(struct rte_flow_item_ah);
7766 case RTE_FLOW_ITEM_TYPE_GTP:
7768 size = sizeof(struct rte_gtp_hdr);
7771 if (gtp_psc != i + 1) {
7772 printf("Error - GTP PSC does not follow GTP\n");
7776 if ((gtp->v_pt_rsv_flags & 0x07) != 0x04) {
7777 /* Only E flag should be set. */
7778 printf("Error - GTP unsupported flags\n");
7781 struct rte_gtp_hdr_ext_word ext_word = {
7785 /* We have to add GTP header extra word. */
7786 *total_size += sizeof(ext_word);
7787 rte_memcpy(data_tail - (*total_size),
7788 &ext_word, sizeof(ext_word));
7790 size = sizeof(struct rte_gtp_hdr);
7792 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
7794 printf("Error - Multiple GTP PSC items\n");
7797 const struct rte_flow_item_gtp_psc
7806 if (opt->pdu_type & 0x0F) {
7807 /* Support the minimal option only. */
7808 printf("Error - GTP PSC option with "
7809 "extra fields not supported\n");
7812 psc.len = sizeof(psc);
7813 psc.pdu_type = opt->pdu_type;
7816 *total_size += sizeof(psc);
7817 rte_memcpy(data_tail - (*total_size),
7823 case RTE_FLOW_ITEM_TYPE_PFCP:
7824 size = sizeof(struct rte_flow_item_pfcp);
7827 printf("Error - Not supported item\n");
7830 *total_size += size;
7831 rte_memcpy(data_tail - (*total_size), item->spec, size);
7832 /* update some fields which cannot be set by cmdline */
7833 update_fields((data_tail - (*total_size)), item,
7835 upper_layer = proto;
7837 if (verbose_level & 0x1)
7838 printf("total data size is %zu\n", (*total_size));
7839 RTE_ASSERT((*total_size) <= ACTION_RAW_ENCAP_MAX_DATA);
7840 memmove(data, (data_tail - (*total_size)), *total_size);
7845 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
7848 /** Populate help strings for current token (cmdline API). */
7850 cmd_set_raw_get_help(cmdline_parse_token_hdr_t *hdr, char *dst,
7853 struct context *ctx = &cmd_flow_context;
7854 const struct token *token = &token_list[ctx->prev];
7859 /* Set token type and update global help with details. */
7860 snprintf(dst, size, "%s", (token->type ? token->type : "TOKEN"));
7862 cmd_set_raw.help_str = token->help;
7864 cmd_set_raw.help_str = token->name;
7868 /** Token definition template (cmdline API). */
7869 static struct cmdline_token_hdr cmd_set_raw_token_hdr = {
7870 .ops = &(struct cmdline_token_ops){
7871 .parse = cmd_flow_parse,
7872 .complete_get_nb = cmd_flow_complete_get_nb,
7873 .complete_get_elt = cmd_flow_complete_get_elt,
7874 .get_help = cmd_set_raw_get_help,
7879 /** Populate the next dynamic token. */
7881 cmd_set_raw_tok(cmdline_parse_token_hdr_t **hdr,
7882 cmdline_parse_token_hdr_t **hdr_inst)
7884 struct context *ctx = &cmd_flow_context;
7886 /* Always reinitialize context before requesting the first token. */
7887 if (!(hdr_inst - cmd_set_raw.tokens)) {
7888 cmd_flow_context_init(ctx);
7889 ctx->curr = START_SET;
7891 /* Return NULL when no more tokens are expected. */
7892 if (!ctx->next_num && (ctx->curr != START_SET)) {
7896 /* Determine if command should end here. */
7897 if (ctx->eol && ctx->last && ctx->next_num) {
7898 const enum index *list = ctx->next[ctx->next_num - 1];
7901 for (i = 0; list[i]; ++i) {
7908 *hdr = &cmd_set_raw_token_hdr;
7911 /** Token generator and output processing callback (cmdline API). */
7913 cmd_set_raw_cb(void *arg0, struct cmdline *cl, void *arg2)
7916 cmd_set_raw_tok(arg0, arg2);
7918 cmd_set_raw_parsed(arg0);
7921 /** Global parser instance (cmdline API). */
7922 cmdline_parse_inst_t cmd_set_raw = {
7923 .f = cmd_set_raw_cb,
7924 .data = NULL, /**< Unused. */
7925 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
7928 }, /**< Tokens are returned by cmd_flow_tok(). */
7931 /* *** display raw_encap/raw_decap buf */
7932 struct cmd_show_set_raw_result {
7933 cmdline_fixed_string_t cmd_show;
7934 cmdline_fixed_string_t cmd_what;
7935 cmdline_fixed_string_t cmd_all;
7940 cmd_show_set_raw_parsed(void *parsed_result, struct cmdline *cl, void *data)
7942 struct cmd_show_set_raw_result *res = parsed_result;
7943 uint16_t index = res->cmd_index;
7945 uint8_t *raw_data = NULL;
7946 size_t raw_size = 0;
7947 char title[16] = {0};
7951 if (!strcmp(res->cmd_all, "all")) {
7954 } else if (index >= RAW_ENCAP_CONFS_MAX_NUM) {
7955 printf("index should be 0-%u\n", RAW_ENCAP_CONFS_MAX_NUM - 1);
7959 if (!strcmp(res->cmd_what, "raw_encap")) {
7960 raw_data = (uint8_t *)&raw_encap_confs[index].data;
7961 raw_size = raw_encap_confs[index].size;
7962 snprintf(title, 16, "\nindex: %u", index);
7963 rte_hexdump(stdout, title, raw_data, raw_size);
7965 raw_data = (uint8_t *)&raw_decap_confs[index].data;
7966 raw_size = raw_decap_confs[index].size;
7967 snprintf(title, 16, "\nindex: %u", index);
7968 rte_hexdump(stdout, title, raw_data, raw_size);
7970 } while (all && ++index < RAW_ENCAP_CONFS_MAX_NUM);
7973 cmdline_parse_token_string_t cmd_show_set_raw_cmd_show =
7974 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
7976 cmdline_parse_token_string_t cmd_show_set_raw_cmd_what =
7977 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
7978 cmd_what, "raw_encap#raw_decap");
7979 cmdline_parse_token_num_t cmd_show_set_raw_cmd_index =
7980 TOKEN_NUM_INITIALIZER(struct cmd_show_set_raw_result,
7981 cmd_index, RTE_UINT16);
7982 cmdline_parse_token_string_t cmd_show_set_raw_cmd_all =
7983 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
7985 cmdline_parse_inst_t cmd_show_set_raw = {
7986 .f = cmd_show_set_raw_parsed,
7988 .help_str = "show <raw_encap|raw_decap> <index>",
7990 (void *)&cmd_show_set_raw_cmd_show,
7991 (void *)&cmd_show_set_raw_cmd_what,
7992 (void *)&cmd_show_set_raw_cmd_index,
7996 cmdline_parse_inst_t cmd_show_set_raw_all = {
7997 .f = cmd_show_set_raw_parsed,
7999 .help_str = "show <raw_encap|raw_decap> all",
8001 (void *)&cmd_show_set_raw_cmd_show,
8002 (void *)&cmd_show_set_raw_cmd_what,
8003 (void *)&cmd_show_set_raw_cmd_all,