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 /** Parser token indices. */
55 /* Top-level command. */
57 /* Sub-leve commands. */
64 /* Top-level command. */
66 /* Sub-level commands. */
79 /* Tunnel arguments. */
86 /* Destroy arguments. */
89 /* Query arguments. */
95 /* Destroy aged flow arguments. */
98 /* Validate/create arguments. */
107 /* Shared action arguments */
108 SHARED_ACTION_CREATE,
109 SHARED_ACTION_UPDATE,
110 SHARED_ACTION_DESTROY,
113 /* Shared action create arguments */
114 SHARED_ACTION_CREATE_ID,
115 SHARED_ACTION_INGRESS,
116 SHARED_ACTION_EGRESS,
119 /* Shared action destroy arguments */
120 SHARED_ACTION_DESTROY_ID,
122 /* Validate/create pattern. */
160 ITEM_VLAN_INNER_TYPE,
161 ITEM_VLAN_HAS_MORE_VLAN,
164 ITEM_IPV4_FRAGMENT_OFFSET,
176 ITEM_IPV6_HAS_FRAG_EXT,
197 ITEM_E_TAG_GRP_ECID_B,
206 ITEM_GRE_C_RSVD0_VER,
224 ITEM_ARP_ETH_IPV4_SHA,
225 ITEM_ARP_ETH_IPV4_SPA,
226 ITEM_ARP_ETH_IPV4_THA,
227 ITEM_ARP_ETH_IPV4_TPA,
229 ITEM_IPV6_EXT_NEXT_HDR,
231 ITEM_IPV6_FRAG_EXT_NEXT_HDR,
232 ITEM_IPV6_FRAG_EXT_FRAG_DATA,
237 ITEM_ICMP6_ND_NS_TARGET_ADDR,
239 ITEM_ICMP6_ND_NA_TARGET_ADDR,
241 ITEM_ICMP6_ND_OPT_TYPE,
242 ITEM_ICMP6_ND_OPT_SLA_ETH,
243 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
244 ITEM_ICMP6_ND_OPT_TLA_ETH,
245 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
258 ITEM_HIGIG2_CLASSIFICATION,
264 ITEM_L2TPV3OIP_SESSION_ID,
274 ITEM_ECPRI_COMMON_TYPE,
275 ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
276 ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
277 ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
278 ITEM_ECPRI_MSG_IQ_DATA_PCID,
279 ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
280 ITEM_ECPRI_MSG_DLY_MSR_MSRID,
282 /* Validate/create actions. */
302 ACTION_RSS_FUNC_DEFAULT,
303 ACTION_RSS_FUNC_TOEPLITZ,
304 ACTION_RSS_FUNC_SIMPLE_XOR,
305 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ,
317 ACTION_PHY_PORT_ORIGINAL,
318 ACTION_PHY_PORT_INDEX,
320 ACTION_PORT_ID_ORIGINAL,
324 ACTION_OF_SET_MPLS_TTL,
325 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
326 ACTION_OF_DEC_MPLS_TTL,
327 ACTION_OF_SET_NW_TTL,
328 ACTION_OF_SET_NW_TTL_NW_TTL,
329 ACTION_OF_DEC_NW_TTL,
330 ACTION_OF_COPY_TTL_OUT,
331 ACTION_OF_COPY_TTL_IN,
334 ACTION_OF_PUSH_VLAN_ETHERTYPE,
335 ACTION_OF_SET_VLAN_VID,
336 ACTION_OF_SET_VLAN_VID_VLAN_VID,
337 ACTION_OF_SET_VLAN_PCP,
338 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
340 ACTION_OF_POP_MPLS_ETHERTYPE,
342 ACTION_OF_PUSH_MPLS_ETHERTYPE,
349 ACTION_MPLSOGRE_ENCAP,
350 ACTION_MPLSOGRE_DECAP,
351 ACTION_MPLSOUDP_ENCAP,
352 ACTION_MPLSOUDP_DECAP,
354 ACTION_SET_IPV4_SRC_IPV4_SRC,
356 ACTION_SET_IPV4_DST_IPV4_DST,
358 ACTION_SET_IPV6_SRC_IPV6_SRC,
360 ACTION_SET_IPV6_DST_IPV6_DST,
362 ACTION_SET_TP_SRC_TP_SRC,
364 ACTION_SET_TP_DST_TP_DST,
370 ACTION_SET_MAC_SRC_MAC_SRC,
372 ACTION_SET_MAC_DST_MAC_DST,
374 ACTION_INC_TCP_SEQ_VALUE,
376 ACTION_DEC_TCP_SEQ_VALUE,
378 ACTION_INC_TCP_ACK_VALUE,
380 ACTION_DEC_TCP_ACK_VALUE,
383 ACTION_RAW_ENCAP_INDEX,
384 ACTION_RAW_ENCAP_INDEX_VALUE,
385 ACTION_RAW_DECAP_INDEX,
386 ACTION_RAW_DECAP_INDEX_VALUE,
389 ACTION_SET_TAG_INDEX,
392 ACTION_SET_META_DATA,
393 ACTION_SET_META_MASK,
394 ACTION_SET_IPV4_DSCP,
395 ACTION_SET_IPV4_DSCP_VALUE,
396 ACTION_SET_IPV6_DSCP,
397 ACTION_SET_IPV6_DSCP_VALUE,
403 ACTION_SAMPLE_INDEX_VALUE,
405 SHARED_ACTION_ID2PTR,
408 /** Maximum size for pattern in struct rte_flow_item_raw. */
409 #define ITEM_RAW_PATTERN_SIZE 40
411 /** Storage size for struct rte_flow_item_raw including pattern. */
412 #define ITEM_RAW_SIZE \
413 (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE)
415 /** Maximum number of queue indices in struct rte_flow_action_rss. */
416 #define ACTION_RSS_QUEUE_NUM 128
418 /** Storage for struct rte_flow_action_rss including external data. */
419 struct action_rss_data {
420 struct rte_flow_action_rss conf;
421 uint8_t key[RSS_HASH_KEY_LENGTH];
422 uint16_t queue[ACTION_RSS_QUEUE_NUM];
425 /** Maximum data size in struct rte_flow_action_raw_encap. */
426 #define ACTION_RAW_ENCAP_MAX_DATA 128
427 #define RAW_ENCAP_CONFS_MAX_NUM 8
429 /** Storage for struct rte_flow_action_raw_encap. */
430 struct raw_encap_conf {
431 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
432 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
436 struct raw_encap_conf raw_encap_confs[RAW_ENCAP_CONFS_MAX_NUM];
438 /** Storage for struct rte_flow_action_raw_encap including external data. */
439 struct action_raw_encap_data {
440 struct rte_flow_action_raw_encap conf;
441 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
442 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
446 /** Storage for struct rte_flow_action_raw_decap. */
447 struct raw_decap_conf {
448 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
452 struct raw_decap_conf raw_decap_confs[RAW_ENCAP_CONFS_MAX_NUM];
454 /** Storage for struct rte_flow_action_raw_decap including external data. */
455 struct action_raw_decap_data {
456 struct rte_flow_action_raw_decap conf;
457 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
461 struct vxlan_encap_conf vxlan_encap_conf = {
465 .vni = "\x00\x00\x00",
467 .udp_dst = RTE_BE16(RTE_VXLAN_DEFAULT_PORT),
468 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
469 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
470 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
471 "\x00\x00\x00\x00\x00\x00\x00\x01",
472 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
473 "\x00\x00\x00\x00\x00\x00\x11\x11",
477 .eth_src = "\x00\x00\x00\x00\x00\x00",
478 .eth_dst = "\xff\xff\xff\xff\xff\xff",
481 /** Maximum number of items in struct rte_flow_action_vxlan_encap. */
482 #define ACTION_VXLAN_ENCAP_ITEMS_NUM 6
484 /** Storage for struct rte_flow_action_vxlan_encap including external data. */
485 struct action_vxlan_encap_data {
486 struct rte_flow_action_vxlan_encap conf;
487 struct rte_flow_item items[ACTION_VXLAN_ENCAP_ITEMS_NUM];
488 struct rte_flow_item_eth item_eth;
489 struct rte_flow_item_vlan item_vlan;
491 struct rte_flow_item_ipv4 item_ipv4;
492 struct rte_flow_item_ipv6 item_ipv6;
494 struct rte_flow_item_udp item_udp;
495 struct rte_flow_item_vxlan item_vxlan;
498 struct nvgre_encap_conf nvgre_encap_conf = {
501 .tni = "\x00\x00\x00",
502 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
503 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
504 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
505 "\x00\x00\x00\x00\x00\x00\x00\x01",
506 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
507 "\x00\x00\x00\x00\x00\x00\x11\x11",
509 .eth_src = "\x00\x00\x00\x00\x00\x00",
510 .eth_dst = "\xff\xff\xff\xff\xff\xff",
513 /** Maximum number of items in struct rte_flow_action_nvgre_encap. */
514 #define ACTION_NVGRE_ENCAP_ITEMS_NUM 5
516 /** Storage for struct rte_flow_action_nvgre_encap including external data. */
517 struct action_nvgre_encap_data {
518 struct rte_flow_action_nvgre_encap conf;
519 struct rte_flow_item items[ACTION_NVGRE_ENCAP_ITEMS_NUM];
520 struct rte_flow_item_eth item_eth;
521 struct rte_flow_item_vlan item_vlan;
523 struct rte_flow_item_ipv4 item_ipv4;
524 struct rte_flow_item_ipv6 item_ipv6;
526 struct rte_flow_item_nvgre item_nvgre;
529 struct l2_encap_conf l2_encap_conf;
531 struct l2_decap_conf l2_decap_conf;
533 struct mplsogre_encap_conf mplsogre_encap_conf;
535 struct mplsogre_decap_conf mplsogre_decap_conf;
537 struct mplsoudp_encap_conf mplsoudp_encap_conf;
539 struct mplsoudp_decap_conf mplsoudp_decap_conf;
541 #define ACTION_SAMPLE_ACTIONS_NUM 10
542 #define RAW_SAMPLE_CONFS_MAX_NUM 8
543 /** Storage for struct rte_flow_action_sample including external data. */
544 struct action_sample_data {
545 struct rte_flow_action_sample conf;
548 /** Storage for struct rte_flow_action_sample. */
549 struct raw_sample_conf {
550 struct rte_flow_action data[ACTION_SAMPLE_ACTIONS_NUM];
552 struct raw_sample_conf raw_sample_confs[RAW_SAMPLE_CONFS_MAX_NUM];
553 struct rte_flow_action_mark sample_mark[RAW_SAMPLE_CONFS_MAX_NUM];
554 struct rte_flow_action_queue sample_queue[RAW_SAMPLE_CONFS_MAX_NUM];
555 struct rte_flow_action_count sample_count[RAW_SAMPLE_CONFS_MAX_NUM];
556 struct rte_flow_action_port_id sample_port_id[RAW_SAMPLE_CONFS_MAX_NUM];
557 struct rte_flow_action_raw_encap sample_encap[RAW_SAMPLE_CONFS_MAX_NUM];
559 /** Maximum number of subsequent tokens and arguments on the stack. */
560 #define CTX_STACK_SIZE 16
562 /** Parser context. */
564 /** Stack of subsequent token lists to process. */
565 const enum index *next[CTX_STACK_SIZE];
566 /** Arguments for stacked tokens. */
567 const void *args[CTX_STACK_SIZE];
568 enum index curr; /**< Current token index. */
569 enum index prev; /**< Index of the last token seen. */
570 int next_num; /**< Number of entries in next[]. */
571 int args_num; /**< Number of entries in args[]. */
572 uint32_t eol:1; /**< EOL has been detected. */
573 uint32_t last:1; /**< No more arguments. */
574 portid_t port; /**< Current port ID (for completions). */
575 uint32_t objdata; /**< Object-specific data. */
576 void *object; /**< Address of current object for relative offsets. */
577 void *objmask; /**< Object a full mask must be written to. */
580 /** Token argument. */
582 uint32_t hton:1; /**< Use network byte ordering. */
583 uint32_t sign:1; /**< Value is signed. */
584 uint32_t bounded:1; /**< Value is bounded. */
585 uintmax_t min; /**< Minimum value if bounded. */
586 uintmax_t max; /**< Maximum value if bounded. */
587 uint32_t offset; /**< Relative offset from ctx->object. */
588 uint32_t size; /**< Field size. */
589 const uint8_t *mask; /**< Bit-mask to use instead of offset/size. */
592 /** Parser token definition. */
594 /** Type displayed during completion (defaults to "TOKEN"). */
596 /** Help displayed during completion (defaults to token name). */
598 /** Private data used by parser functions. */
601 * Lists of subsequent tokens to push on the stack. Each call to the
602 * parser consumes the last entry of that stack.
604 const enum index *const *next;
605 /** Arguments stack for subsequent tokens that need them. */
606 const struct arg *const *args;
608 * Token-processing callback, returns -1 in case of error, the
609 * length of the matched string otherwise. If NULL, attempts to
610 * match the token name.
612 * If buf is not NULL, the result should be stored in it according
613 * to context. An error is returned if not large enough.
615 int (*call)(struct context *ctx, const struct token *token,
616 const char *str, unsigned int len,
617 void *buf, unsigned int size);
619 * Callback that provides possible values for this token, used for
620 * completion. Returns -1 in case of error, the number of possible
621 * values otherwise. If NULL, the token name is used.
623 * If buf is not NULL, entry index ent is written to buf and the
624 * full length of the entry is returned (same behavior as
627 int (*comp)(struct context *ctx, const struct token *token,
628 unsigned int ent, char *buf, unsigned int size);
629 /** Mandatory token name, no default value. */
633 /** Static initializer for the next field. */
634 #define NEXT(...) (const enum index *const []){ __VA_ARGS__, NULL, }
636 /** Static initializer for a NEXT() entry. */
637 #define NEXT_ENTRY(...) (const enum index []){ __VA_ARGS__, ZERO, }
639 /** Static initializer for the args field. */
640 #define ARGS(...) (const struct arg *const []){ __VA_ARGS__, NULL, }
642 /** Static initializer for ARGS() to target a field. */
643 #define ARGS_ENTRY(s, f) \
644 (&(const struct arg){ \
645 .offset = offsetof(s, f), \
646 .size = sizeof(((s *)0)->f), \
649 /** Static initializer for ARGS() to target a bit-field. */
650 #define ARGS_ENTRY_BF(s, f, b) \
651 (&(const struct arg){ \
653 .mask = (const void *)&(const s){ .f = (1 << (b)) - 1 }, \
656 /** Static initializer for ARGS() to target an arbitrary bit-mask. */
657 #define ARGS_ENTRY_MASK(s, f, m) \
658 (&(const struct arg){ \
659 .offset = offsetof(s, f), \
660 .size = sizeof(((s *)0)->f), \
661 .mask = (const void *)(m), \
664 /** Same as ARGS_ENTRY_MASK() using network byte ordering for the value. */
665 #define ARGS_ENTRY_MASK_HTON(s, f, m) \
666 (&(const struct arg){ \
668 .offset = offsetof(s, f), \
669 .size = sizeof(((s *)0)->f), \
670 .mask = (const void *)(m), \
673 /** Static initializer for ARGS() to target a pointer. */
674 #define ARGS_ENTRY_PTR(s, f) \
675 (&(const struct arg){ \
676 .size = sizeof(*((s *)0)->f), \
679 /** Static initializer for ARGS() with arbitrary offset and size. */
680 #define ARGS_ENTRY_ARB(o, s) \
681 (&(const struct arg){ \
686 /** Same as ARGS_ENTRY_ARB() with bounded values. */
687 #define ARGS_ENTRY_ARB_BOUNDED(o, s, i, a) \
688 (&(const struct arg){ \
696 /** Same as ARGS_ENTRY() using network byte ordering. */
697 #define ARGS_ENTRY_HTON(s, f) \
698 (&(const struct arg){ \
700 .offset = offsetof(s, f), \
701 .size = sizeof(((s *)0)->f), \
704 /** Same as ARGS_ENTRY_HTON() for a single argument, without structure. */
705 #define ARG_ENTRY_HTON(s) \
706 (&(const struct arg){ \
712 /** Parser output buffer layout expected by cmd_flow_parsed(). */
714 enum index command; /**< Flow command. */
715 portid_t port; /**< Affected port ID. */
719 uint32_t action_id_n;
720 } sa_destroy; /**< Shared action destroy arguments. */
723 } sa; /* Shared action query arguments */
725 struct rte_flow_attr attr;
726 struct tunnel_ops tunnel_ops;
727 struct rte_flow_item *pattern;
728 struct rte_flow_action *actions;
732 } vc; /**< Validate/create arguments. */
736 } destroy; /**< Destroy arguments. */
739 } dump; /**< Dump arguments. */
742 struct rte_flow_action action;
743 } query; /**< Query arguments. */
747 } list; /**< List arguments. */
750 } isolate; /**< Isolated mode arguments. */
753 } aged; /**< Aged arguments. */
754 } args; /**< Command arguments. */
757 /** Private data for pattern items. */
758 struct parse_item_priv {
759 enum rte_flow_item_type type; /**< Item type. */
760 uint32_t size; /**< Size of item specification structure. */
763 #define PRIV_ITEM(t, s) \
764 (&(const struct parse_item_priv){ \
765 .type = RTE_FLOW_ITEM_TYPE_ ## t, \
769 /** Private data for actions. */
770 struct parse_action_priv {
771 enum rte_flow_action_type type; /**< Action type. */
772 uint32_t size; /**< Size of action configuration structure. */
775 #define PRIV_ACTION(t, s) \
776 (&(const struct parse_action_priv){ \
777 .type = RTE_FLOW_ACTION_TYPE_ ## t, \
781 static const enum index next_sa_create_attr[] = {
782 SHARED_ACTION_CREATE_ID,
783 SHARED_ACTION_INGRESS,
784 SHARED_ACTION_EGRESS,
789 static const enum index next_sa_subcmd[] = {
790 SHARED_ACTION_CREATE,
791 SHARED_ACTION_UPDATE,
792 SHARED_ACTION_DESTROY,
797 static const enum index next_vc_attr[] = {
809 static const enum index tunnel_create_attr[] = {
816 static const enum index tunnel_destroy_attr[] = {
823 static const enum index tunnel_list_attr[] = {
829 static const enum index next_destroy_attr[] = {
835 static const enum index next_dump_attr[] = {
841 static const enum index next_list_attr[] = {
847 static const enum index next_aged_attr[] = {
853 static const enum index next_sa_destroy_attr[] = {
854 SHARED_ACTION_DESTROY_ID,
859 static const enum index item_param[] = {
868 static const enum index next_item[] = {
905 ITEM_ICMP6_ND_OPT_SLA_ETH,
906 ITEM_ICMP6_ND_OPT_TLA_ETH,
924 static const enum index item_fuzzy[] = {
930 static const enum index item_any[] = {
936 static const enum index item_vf[] = {
942 static const enum index item_phy_port[] = {
948 static const enum index item_port_id[] = {
954 static const enum index item_mark[] = {
960 static const enum index item_raw[] = {
970 static const enum index item_eth[] = {
979 static const enum index item_vlan[] = {
984 ITEM_VLAN_INNER_TYPE,
985 ITEM_VLAN_HAS_MORE_VLAN,
990 static const enum index item_ipv4[] = {
992 ITEM_IPV4_FRAGMENT_OFFSET,
1001 static const enum index item_ipv6[] = {
1008 ITEM_IPV6_HAS_FRAG_EXT,
1013 static const enum index item_icmp[] = {
1022 static const enum index item_udp[] = {
1029 static const enum index item_tcp[] = {
1037 static const enum index item_sctp[] = {
1046 static const enum index item_vxlan[] = {
1052 static const enum index item_e_tag[] = {
1053 ITEM_E_TAG_GRP_ECID_B,
1058 static const enum index item_nvgre[] = {
1064 static const enum index item_mpls[] = {
1072 static const enum index item_gre[] = {
1074 ITEM_GRE_C_RSVD0_VER,
1082 static const enum index item_gre_key[] = {
1088 static const enum index item_gtp[] = {
1096 static const enum index item_geneve[] = {
1103 static const enum index item_vxlan_gpe[] = {
1109 static const enum index item_arp_eth_ipv4[] = {
1110 ITEM_ARP_ETH_IPV4_SHA,
1111 ITEM_ARP_ETH_IPV4_SPA,
1112 ITEM_ARP_ETH_IPV4_THA,
1113 ITEM_ARP_ETH_IPV4_TPA,
1118 static const enum index item_ipv6_ext[] = {
1119 ITEM_IPV6_EXT_NEXT_HDR,
1124 static const enum index item_ipv6_frag_ext[] = {
1125 ITEM_IPV6_FRAG_EXT_NEXT_HDR,
1126 ITEM_IPV6_FRAG_EXT_FRAG_DATA,
1131 static const enum index item_icmp6[] = {
1138 static const enum index item_icmp6_nd_ns[] = {
1139 ITEM_ICMP6_ND_NS_TARGET_ADDR,
1144 static const enum index item_icmp6_nd_na[] = {
1145 ITEM_ICMP6_ND_NA_TARGET_ADDR,
1150 static const enum index item_icmp6_nd_opt[] = {
1151 ITEM_ICMP6_ND_OPT_TYPE,
1156 static const enum index item_icmp6_nd_opt_sla_eth[] = {
1157 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
1162 static const enum index item_icmp6_nd_opt_tla_eth[] = {
1163 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
1168 static const enum index item_meta[] = {
1174 static const enum index item_gtp_psc[] = {
1181 static const enum index item_pppoed[] = {
1187 static const enum index item_pppoes[] = {
1193 static const enum index item_pppoe_proto_id[] = {
1198 static const enum index item_higig2[] = {
1199 ITEM_HIGIG2_CLASSIFICATION,
1205 static const enum index item_esp[] = {
1211 static const enum index item_ah[] = {
1217 static const enum index item_pfcp[] = {
1224 static const enum index next_set_raw[] = {
1230 static const enum index item_tag[] = {
1237 static const enum index item_l2tpv3oip[] = {
1238 ITEM_L2TPV3OIP_SESSION_ID,
1243 static const enum index item_ecpri[] = {
1249 static const enum index item_ecpri_common[] = {
1250 ITEM_ECPRI_COMMON_TYPE,
1254 static const enum index item_ecpri_common_type[] = {
1255 ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
1256 ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
1257 ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
1261 static const enum index next_action[] = {
1277 ACTION_OF_SET_MPLS_TTL,
1278 ACTION_OF_DEC_MPLS_TTL,
1279 ACTION_OF_SET_NW_TTL,
1280 ACTION_OF_DEC_NW_TTL,
1281 ACTION_OF_COPY_TTL_OUT,
1282 ACTION_OF_COPY_TTL_IN,
1284 ACTION_OF_PUSH_VLAN,
1285 ACTION_OF_SET_VLAN_VID,
1286 ACTION_OF_SET_VLAN_PCP,
1288 ACTION_OF_PUSH_MPLS,
1295 ACTION_MPLSOGRE_ENCAP,
1296 ACTION_MPLSOGRE_DECAP,
1297 ACTION_MPLSOUDP_ENCAP,
1298 ACTION_MPLSOUDP_DECAP,
1299 ACTION_SET_IPV4_SRC,
1300 ACTION_SET_IPV4_DST,
1301 ACTION_SET_IPV6_SRC,
1302 ACTION_SET_IPV6_DST,
1318 ACTION_SET_IPV4_DSCP,
1319 ACTION_SET_IPV6_DSCP,
1326 static const enum index action_mark[] = {
1332 static const enum index action_queue[] = {
1338 static const enum index action_count[] = {
1340 ACTION_COUNT_SHARED,
1345 static const enum index action_rss[] = {
1356 static const enum index action_vf[] = {
1363 static const enum index action_phy_port[] = {
1364 ACTION_PHY_PORT_ORIGINAL,
1365 ACTION_PHY_PORT_INDEX,
1370 static const enum index action_port_id[] = {
1371 ACTION_PORT_ID_ORIGINAL,
1377 static const enum index action_meter[] = {
1383 static const enum index action_of_set_mpls_ttl[] = {
1384 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
1389 static const enum index action_of_set_nw_ttl[] = {
1390 ACTION_OF_SET_NW_TTL_NW_TTL,
1395 static const enum index action_of_push_vlan[] = {
1396 ACTION_OF_PUSH_VLAN_ETHERTYPE,
1401 static const enum index action_of_set_vlan_vid[] = {
1402 ACTION_OF_SET_VLAN_VID_VLAN_VID,
1407 static const enum index action_of_set_vlan_pcp[] = {
1408 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
1413 static const enum index action_of_pop_mpls[] = {
1414 ACTION_OF_POP_MPLS_ETHERTYPE,
1419 static const enum index action_of_push_mpls[] = {
1420 ACTION_OF_PUSH_MPLS_ETHERTYPE,
1425 static const enum index action_set_ipv4_src[] = {
1426 ACTION_SET_IPV4_SRC_IPV4_SRC,
1431 static const enum index action_set_mac_src[] = {
1432 ACTION_SET_MAC_SRC_MAC_SRC,
1437 static const enum index action_set_ipv4_dst[] = {
1438 ACTION_SET_IPV4_DST_IPV4_DST,
1443 static const enum index action_set_ipv6_src[] = {
1444 ACTION_SET_IPV6_SRC_IPV6_SRC,
1449 static const enum index action_set_ipv6_dst[] = {
1450 ACTION_SET_IPV6_DST_IPV6_DST,
1455 static const enum index action_set_tp_src[] = {
1456 ACTION_SET_TP_SRC_TP_SRC,
1461 static const enum index action_set_tp_dst[] = {
1462 ACTION_SET_TP_DST_TP_DST,
1467 static const enum index action_set_ttl[] = {
1473 static const enum index action_jump[] = {
1479 static const enum index action_set_mac_dst[] = {
1480 ACTION_SET_MAC_DST_MAC_DST,
1485 static const enum index action_inc_tcp_seq[] = {
1486 ACTION_INC_TCP_SEQ_VALUE,
1491 static const enum index action_dec_tcp_seq[] = {
1492 ACTION_DEC_TCP_SEQ_VALUE,
1497 static const enum index action_inc_tcp_ack[] = {
1498 ACTION_INC_TCP_ACK_VALUE,
1503 static const enum index action_dec_tcp_ack[] = {
1504 ACTION_DEC_TCP_ACK_VALUE,
1509 static const enum index action_raw_encap[] = {
1510 ACTION_RAW_ENCAP_INDEX,
1515 static const enum index action_raw_decap[] = {
1516 ACTION_RAW_DECAP_INDEX,
1521 static const enum index action_set_tag[] = {
1522 ACTION_SET_TAG_DATA,
1523 ACTION_SET_TAG_INDEX,
1524 ACTION_SET_TAG_MASK,
1529 static const enum index action_set_meta[] = {
1530 ACTION_SET_META_DATA,
1531 ACTION_SET_META_MASK,
1536 static const enum index action_set_ipv4_dscp[] = {
1537 ACTION_SET_IPV4_DSCP_VALUE,
1542 static const enum index action_set_ipv6_dscp[] = {
1543 ACTION_SET_IPV6_DSCP_VALUE,
1548 static const enum index action_age[] = {
1555 static const enum index action_sample[] = {
1557 ACTION_SAMPLE_RATIO,
1558 ACTION_SAMPLE_INDEX,
1563 static const enum index next_action_sample[] = {
1573 static int parse_set_raw_encap_decap(struct context *, const struct token *,
1574 const char *, unsigned int,
1575 void *, unsigned int);
1576 static int parse_set_sample_action(struct context *, const struct token *,
1577 const char *, unsigned int,
1578 void *, unsigned int);
1579 static int parse_set_init(struct context *, const struct token *,
1580 const char *, unsigned int,
1581 void *, unsigned int);
1582 static int parse_init(struct context *, const struct token *,
1583 const char *, unsigned int,
1584 void *, unsigned int);
1585 static int parse_vc(struct context *, const struct token *,
1586 const char *, unsigned int,
1587 void *, unsigned int);
1588 static int parse_vc_spec(struct context *, const struct token *,
1589 const char *, unsigned int, void *, unsigned int);
1590 static int parse_vc_conf(struct context *, const struct token *,
1591 const char *, unsigned int, void *, unsigned int);
1592 static int parse_vc_item_ecpri_type(struct context *, const struct token *,
1593 const char *, unsigned int,
1594 void *, unsigned int);
1595 static int parse_vc_action_rss(struct context *, const struct token *,
1596 const char *, unsigned int, void *,
1598 static int parse_vc_action_rss_func(struct context *, const struct token *,
1599 const char *, unsigned int, void *,
1601 static int parse_vc_action_rss_type(struct context *, const struct token *,
1602 const char *, unsigned int, void *,
1604 static int parse_vc_action_rss_queue(struct context *, const struct token *,
1605 const char *, unsigned int, void *,
1607 static int parse_vc_action_vxlan_encap(struct context *, const struct token *,
1608 const char *, unsigned int, void *,
1610 static int parse_vc_action_nvgre_encap(struct context *, const struct token *,
1611 const char *, unsigned int, void *,
1613 static int parse_vc_action_l2_encap(struct context *, const struct token *,
1614 const char *, unsigned int, void *,
1616 static int parse_vc_action_l2_decap(struct context *, const struct token *,
1617 const char *, unsigned int, void *,
1619 static int parse_vc_action_mplsogre_encap(struct context *,
1620 const struct token *, const char *,
1621 unsigned int, void *, unsigned int);
1622 static int parse_vc_action_mplsogre_decap(struct context *,
1623 const struct token *, const char *,
1624 unsigned int, void *, unsigned int);
1625 static int parse_vc_action_mplsoudp_encap(struct context *,
1626 const struct token *, const char *,
1627 unsigned int, void *, unsigned int);
1628 static int parse_vc_action_mplsoudp_decap(struct context *,
1629 const struct token *, const char *,
1630 unsigned int, void *, unsigned int);
1631 static int parse_vc_action_raw_encap(struct context *,
1632 const struct token *, const char *,
1633 unsigned int, void *, unsigned int);
1634 static int parse_vc_action_raw_decap(struct context *,
1635 const struct token *, const char *,
1636 unsigned int, void *, unsigned int);
1637 static int parse_vc_action_raw_encap_index(struct context *,
1638 const struct token *, const char *,
1639 unsigned int, void *, unsigned int);
1640 static int parse_vc_action_raw_decap_index(struct context *,
1641 const struct token *, const char *,
1642 unsigned int, void *, unsigned int);
1643 static int parse_vc_action_set_meta(struct context *ctx,
1644 const struct token *token, const char *str,
1645 unsigned int len, void *buf,
1647 static int parse_vc_action_sample(struct context *ctx,
1648 const struct token *token, const char *str,
1649 unsigned int len, void *buf,
1652 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
1653 const char *str, unsigned int len, void *buf,
1655 static int parse_destroy(struct context *, const struct token *,
1656 const char *, unsigned int,
1657 void *, unsigned int);
1658 static int parse_flush(struct context *, const struct token *,
1659 const char *, unsigned int,
1660 void *, unsigned int);
1661 static int parse_dump(struct context *, const struct token *,
1662 const char *, unsigned int,
1663 void *, unsigned int);
1664 static int parse_query(struct context *, const struct token *,
1665 const char *, unsigned int,
1666 void *, unsigned int);
1667 static int parse_action(struct context *, const struct token *,
1668 const char *, unsigned int,
1669 void *, unsigned int);
1670 static int parse_list(struct context *, const struct token *,
1671 const char *, unsigned int,
1672 void *, unsigned int);
1673 static int parse_aged(struct context *, const struct token *,
1674 const char *, unsigned int,
1675 void *, unsigned int);
1676 static int parse_isolate(struct context *, const struct token *,
1677 const char *, unsigned int,
1678 void *, unsigned int);
1679 static int parse_tunnel(struct context *, const struct token *,
1680 const char *, unsigned int,
1681 void *, unsigned int);
1682 static int parse_int(struct context *, const struct token *,
1683 const char *, unsigned int,
1684 void *, unsigned int);
1685 static int parse_prefix(struct context *, const struct token *,
1686 const char *, unsigned int,
1687 void *, unsigned int);
1688 static int parse_boolean(struct context *, const struct token *,
1689 const char *, unsigned int,
1690 void *, unsigned int);
1691 static int parse_string(struct context *, const struct token *,
1692 const char *, unsigned int,
1693 void *, unsigned int);
1694 static int parse_hex(struct context *ctx, const struct token *token,
1695 const char *str, unsigned int len,
1696 void *buf, unsigned int size);
1697 static int parse_string0(struct context *, const struct token *,
1698 const char *, unsigned int,
1699 void *, unsigned int);
1700 static int parse_mac_addr(struct context *, const struct token *,
1701 const char *, unsigned int,
1702 void *, unsigned int);
1703 static int parse_ipv4_addr(struct context *, const struct token *,
1704 const char *, unsigned int,
1705 void *, unsigned int);
1706 static int parse_ipv6_addr(struct context *, const struct token *,
1707 const char *, unsigned int,
1708 void *, unsigned int);
1709 static int parse_port(struct context *, const struct token *,
1710 const char *, unsigned int,
1711 void *, unsigned int);
1712 static int parse_sa(struct context *, const struct token *,
1713 const char *, unsigned int,
1714 void *, unsigned int);
1715 static int parse_sa_destroy(struct context *ctx, const struct token *token,
1716 const char *str, unsigned int len,
1717 void *buf, unsigned int size);
1718 static int parse_sa_id2ptr(struct context *ctx, const struct token *token,
1719 const char *str, unsigned int len, void *buf,
1721 static int comp_none(struct context *, const struct token *,
1722 unsigned int, char *, unsigned int);
1723 static int comp_boolean(struct context *, const struct token *,
1724 unsigned int, char *, unsigned int);
1725 static int comp_action(struct context *, const struct token *,
1726 unsigned int, char *, unsigned int);
1727 static int comp_port(struct context *, const struct token *,
1728 unsigned int, char *, unsigned int);
1729 static int comp_rule_id(struct context *, const struct token *,
1730 unsigned int, char *, unsigned int);
1731 static int comp_vc_action_rss_type(struct context *, const struct token *,
1732 unsigned int, char *, unsigned int);
1733 static int comp_vc_action_rss_queue(struct context *, const struct token *,
1734 unsigned int, char *, unsigned int);
1735 static int comp_set_raw_index(struct context *, const struct token *,
1736 unsigned int, char *, unsigned int);
1737 static int comp_set_sample_index(struct context *, const struct token *,
1738 unsigned int, char *, unsigned int);
1740 /** Token definitions. */
1741 static const struct token token_list[] = {
1742 /* Special tokens. */
1745 .help = "null entry, abused as the entry point",
1746 .next = NEXT(NEXT_ENTRY(FLOW)),
1751 .help = "command may end here",
1754 .name = "START_SET",
1755 .help = "null entry, abused as the entry point for set",
1756 .next = NEXT(NEXT_ENTRY(SET)),
1761 .help = "set command may end here",
1763 /* Common tokens. */
1767 .help = "integer value",
1772 .name = "{unsigned}",
1774 .help = "unsigned integer value",
1781 .help = "prefix length for bit-mask",
1782 .call = parse_prefix,
1786 .name = "{boolean}",
1788 .help = "any boolean value",
1789 .call = parse_boolean,
1790 .comp = comp_boolean,
1795 .help = "fixed string",
1796 .call = parse_string,
1802 .help = "fixed string",
1806 .name = "{file path}",
1808 .help = "file path",
1809 .call = parse_string0,
1813 .name = "{MAC address}",
1815 .help = "standard MAC address notation",
1816 .call = parse_mac_addr,
1820 .name = "{IPv4 address}",
1821 .type = "IPV4 ADDRESS",
1822 .help = "standard IPv4 address notation",
1823 .call = parse_ipv4_addr,
1827 .name = "{IPv6 address}",
1828 .type = "IPV6 ADDRESS",
1829 .help = "standard IPv6 address notation",
1830 .call = parse_ipv6_addr,
1834 .name = "{rule id}",
1836 .help = "rule identifier",
1838 .comp = comp_rule_id,
1841 .name = "{port_id}",
1843 .help = "port identifier",
1848 .name = "{group_id}",
1850 .help = "group identifier",
1854 [PRIORITY_LEVEL] = {
1857 .help = "priority level",
1861 [SHARED_ACTION_ID] = {
1862 .name = "{shared_action_id}",
1863 .type = "SHARED_ACTION_ID",
1864 .help = "shared action id",
1868 /* Top-level command. */
1871 .type = "{command} {port_id} [{arg} [...]]",
1872 .help = "manage ingress/egress flow rules",
1873 .next = NEXT(NEXT_ENTRY
1887 /* Top-level command. */
1889 .name = "shared_action",
1890 .type = "{command} {port_id} [{arg} [...]]",
1891 .help = "manage shared actions",
1892 .next = NEXT(next_sa_subcmd, NEXT_ENTRY(PORT_ID)),
1893 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1896 /* Sub-level commands. */
1897 [SHARED_ACTION_CREATE] = {
1899 .help = "create shared action",
1900 .next = NEXT(next_sa_create_attr),
1903 [SHARED_ACTION_UPDATE] = {
1905 .help = "update shared action",
1906 .next = NEXT(NEXT_ENTRY(SHARED_ACTION_SPEC),
1907 NEXT_ENTRY(SHARED_ACTION_ID)),
1908 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
1911 [SHARED_ACTION_DESTROY] = {
1913 .help = "destroy shared action",
1914 .next = NEXT(NEXT_ENTRY(SHARED_ACTION_DESTROY_ID)),
1915 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1916 .call = parse_sa_destroy,
1918 [SHARED_ACTION_QUERY] = {
1920 .help = "query shared action",
1921 .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(SHARED_ACTION_ID)),
1922 .args = ARGS(ARGS_ENTRY(struct buffer, args.sa.action_id)),
1927 .help = "check whether a flow rule can be created",
1928 .next = NEXT(next_vc_attr, NEXT_ENTRY(PORT_ID)),
1929 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1934 .help = "create a flow rule",
1935 .next = NEXT(next_vc_attr, NEXT_ENTRY(PORT_ID)),
1936 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1941 .help = "destroy specific flow rules",
1942 .next = NEXT(NEXT_ENTRY(DESTROY_RULE), NEXT_ENTRY(PORT_ID)),
1943 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1944 .call = parse_destroy,
1948 .help = "destroy all flow rules",
1949 .next = NEXT(NEXT_ENTRY(PORT_ID)),
1950 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1951 .call = parse_flush,
1955 .help = "dump all flow rules to file",
1956 .next = NEXT(next_dump_attr, NEXT_ENTRY(PORT_ID)),
1957 .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file),
1958 ARGS_ENTRY(struct buffer, port)),
1963 .help = "query an existing flow rule",
1964 .next = NEXT(NEXT_ENTRY(QUERY_ACTION),
1965 NEXT_ENTRY(RULE_ID),
1966 NEXT_ENTRY(PORT_ID)),
1967 .args = ARGS(ARGS_ENTRY(struct buffer, args.query.action.type),
1968 ARGS_ENTRY(struct buffer, args.query.rule),
1969 ARGS_ENTRY(struct buffer, port)),
1970 .call = parse_query,
1974 .help = "list existing flow rules",
1975 .next = NEXT(next_list_attr, NEXT_ENTRY(PORT_ID)),
1976 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1981 .help = "list and destroy aged flows",
1982 .next = NEXT(next_aged_attr, NEXT_ENTRY(PORT_ID)),
1983 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1988 .help = "restrict ingress traffic to the defined flow rules",
1989 .next = NEXT(NEXT_ENTRY(BOOLEAN),
1990 NEXT_ENTRY(PORT_ID)),
1991 .args = ARGS(ARGS_ENTRY(struct buffer, args.isolate.set),
1992 ARGS_ENTRY(struct buffer, port)),
1993 .call = parse_isolate,
1997 .help = "new tunnel API",
1998 .next = NEXT(NEXT_ENTRY
1999 (TUNNEL_CREATE, TUNNEL_LIST, TUNNEL_DESTROY)),
2000 .call = parse_tunnel,
2002 /* Tunnel arguments. */
2005 .help = "create new tunnel object",
2006 .next = NEXT(tunnel_create_attr, NEXT_ENTRY(PORT_ID)),
2007 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2008 .call = parse_tunnel,
2010 [TUNNEL_CREATE_TYPE] = {
2012 .help = "create new tunnel",
2013 .next = NEXT(tunnel_create_attr, NEXT_ENTRY(FILE_PATH)),
2014 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, type)),
2015 .call = parse_tunnel,
2017 [TUNNEL_DESTROY] = {
2019 .help = "destroy tunel",
2020 .next = NEXT(tunnel_destroy_attr, NEXT_ENTRY(PORT_ID)),
2021 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2022 .call = parse_tunnel,
2024 [TUNNEL_DESTROY_ID] = {
2026 .help = "tunnel identifier to testroy",
2027 .next = NEXT(tunnel_destroy_attr, NEXT_ENTRY(UNSIGNED)),
2028 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2029 .call = parse_tunnel,
2033 .help = "list existing tunnels",
2034 .next = NEXT(tunnel_list_attr, NEXT_ENTRY(PORT_ID)),
2035 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2036 .call = parse_tunnel,
2038 /* Destroy arguments. */
2041 .help = "specify a rule identifier",
2042 .next = NEXT(next_destroy_attr, NEXT_ENTRY(RULE_ID)),
2043 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.destroy.rule)),
2044 .call = parse_destroy,
2046 /* Query arguments. */
2050 .help = "action to query, must be part of the rule",
2051 .call = parse_action,
2052 .comp = comp_action,
2054 /* List arguments. */
2057 .help = "specify a group",
2058 .next = NEXT(next_list_attr, NEXT_ENTRY(GROUP_ID)),
2059 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.list.group)),
2064 .help = "specify aged flows need be destroyed",
2068 /* Validate/create attributes. */
2071 .help = "specify a group",
2072 .next = NEXT(next_vc_attr, NEXT_ENTRY(GROUP_ID)),
2073 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, group)),
2078 .help = "specify a priority level",
2079 .next = NEXT(next_vc_attr, NEXT_ENTRY(PRIORITY_LEVEL)),
2080 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, priority)),
2085 .help = "affect rule to ingress",
2086 .next = NEXT(next_vc_attr),
2091 .help = "affect rule to egress",
2092 .next = NEXT(next_vc_attr),
2097 .help = "apply rule directly to endpoints found in pattern",
2098 .next = NEXT(next_vc_attr),
2102 .name = "tunnel_set",
2103 .help = "tunnel steer rule",
2104 .next = NEXT(next_vc_attr, NEXT_ENTRY(UNSIGNED)),
2105 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2109 .name = "tunnel_match",
2110 .help = "tunnel match rule",
2111 .next = NEXT(next_vc_attr, NEXT_ENTRY(UNSIGNED)),
2112 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2115 /* Validate/create pattern. */
2118 .help = "submit a list of pattern items",
2119 .next = NEXT(next_item),
2124 .help = "match value perfectly (with full bit-mask)",
2125 .call = parse_vc_spec,
2127 [ITEM_PARAM_SPEC] = {
2129 .help = "match value according to configured bit-mask",
2130 .call = parse_vc_spec,
2132 [ITEM_PARAM_LAST] = {
2134 .help = "specify upper bound to establish a range",
2135 .call = parse_vc_spec,
2137 [ITEM_PARAM_MASK] = {
2139 .help = "specify bit-mask with relevant bits set to one",
2140 .call = parse_vc_spec,
2142 [ITEM_PARAM_PREFIX] = {
2144 .help = "generate bit-mask from a prefix length",
2145 .call = parse_vc_spec,
2149 .help = "specify next pattern item",
2150 .next = NEXT(next_item),
2154 .help = "end list of pattern items",
2155 .priv = PRIV_ITEM(END, 0),
2156 .next = NEXT(NEXT_ENTRY(ACTIONS)),
2161 .help = "no-op pattern item",
2162 .priv = PRIV_ITEM(VOID, 0),
2163 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2168 .help = "perform actions when pattern does not match",
2169 .priv = PRIV_ITEM(INVERT, 0),
2170 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2175 .help = "match any protocol for the current layer",
2176 .priv = PRIV_ITEM(ANY, sizeof(struct rte_flow_item_any)),
2177 .next = NEXT(item_any),
2182 .help = "number of layers covered",
2183 .next = NEXT(item_any, NEXT_ENTRY(UNSIGNED), item_param),
2184 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_any, num)),
2188 .help = "match traffic from/to the physical function",
2189 .priv = PRIV_ITEM(PF, 0),
2190 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2195 .help = "match traffic from/to a virtual function ID",
2196 .priv = PRIV_ITEM(VF, sizeof(struct rte_flow_item_vf)),
2197 .next = NEXT(item_vf),
2203 .next = NEXT(item_vf, NEXT_ENTRY(UNSIGNED), item_param),
2204 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_vf, id)),
2208 .help = "match traffic from/to a specific physical port",
2209 .priv = PRIV_ITEM(PHY_PORT,
2210 sizeof(struct rte_flow_item_phy_port)),
2211 .next = NEXT(item_phy_port),
2214 [ITEM_PHY_PORT_INDEX] = {
2216 .help = "physical port index",
2217 .next = NEXT(item_phy_port, NEXT_ENTRY(UNSIGNED), item_param),
2218 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_phy_port, index)),
2222 .help = "match traffic from/to a given DPDK port ID",
2223 .priv = PRIV_ITEM(PORT_ID,
2224 sizeof(struct rte_flow_item_port_id)),
2225 .next = NEXT(item_port_id),
2228 [ITEM_PORT_ID_ID] = {
2230 .help = "DPDK port ID",
2231 .next = NEXT(item_port_id, NEXT_ENTRY(UNSIGNED), item_param),
2232 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port_id, id)),
2236 .help = "match traffic against value set in previously matched rule",
2237 .priv = PRIV_ITEM(MARK, sizeof(struct rte_flow_item_mark)),
2238 .next = NEXT(item_mark),
2243 .help = "Integer value to match against",
2244 .next = NEXT(item_mark, NEXT_ENTRY(UNSIGNED), item_param),
2245 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_mark, id)),
2249 .help = "match an arbitrary byte string",
2250 .priv = PRIV_ITEM(RAW, ITEM_RAW_SIZE),
2251 .next = NEXT(item_raw),
2254 [ITEM_RAW_RELATIVE] = {
2256 .help = "look for pattern after the previous item",
2257 .next = NEXT(item_raw, NEXT_ENTRY(BOOLEAN), item_param),
2258 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
2261 [ITEM_RAW_SEARCH] = {
2263 .help = "search pattern from offset (see also limit)",
2264 .next = NEXT(item_raw, NEXT_ENTRY(BOOLEAN), item_param),
2265 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
2268 [ITEM_RAW_OFFSET] = {
2270 .help = "absolute or relative offset for pattern",
2271 .next = NEXT(item_raw, NEXT_ENTRY(INTEGER), item_param),
2272 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, offset)),
2274 [ITEM_RAW_LIMIT] = {
2276 .help = "search area limit for start of pattern",
2277 .next = NEXT(item_raw, NEXT_ENTRY(UNSIGNED), item_param),
2278 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, limit)),
2280 [ITEM_RAW_PATTERN] = {
2282 .help = "byte string to look for",
2283 .next = NEXT(item_raw,
2285 NEXT_ENTRY(ITEM_PARAM_IS,
2288 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern),
2289 ARGS_ENTRY(struct rte_flow_item_raw, length),
2290 ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw),
2291 ITEM_RAW_PATTERN_SIZE)),
2295 .help = "match Ethernet header",
2296 .priv = PRIV_ITEM(ETH, sizeof(struct rte_flow_item_eth)),
2297 .next = NEXT(item_eth),
2302 .help = "destination MAC",
2303 .next = NEXT(item_eth, NEXT_ENTRY(MAC_ADDR), item_param),
2304 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, dst)),
2308 .help = "source MAC",
2309 .next = NEXT(item_eth, NEXT_ENTRY(MAC_ADDR), item_param),
2310 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, src)),
2314 .help = "EtherType",
2315 .next = NEXT(item_eth, NEXT_ENTRY(UNSIGNED), item_param),
2316 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, type)),
2318 [ITEM_ETH_HAS_VLAN] = {
2320 .help = "packet header contains VLAN",
2321 .next = NEXT(item_eth, NEXT_ENTRY(UNSIGNED), item_param),
2322 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_eth,
2327 .help = "match 802.1Q/ad VLAN tag",
2328 .priv = PRIV_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)),
2329 .next = NEXT(item_vlan),
2334 .help = "tag control information",
2335 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2336 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, tci)),
2340 .help = "priority code point",
2341 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2342 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2347 .help = "drop eligible indicator",
2348 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2349 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2354 .help = "VLAN identifier",
2355 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2356 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2359 [ITEM_VLAN_INNER_TYPE] = {
2360 .name = "inner_type",
2361 .help = "inner EtherType",
2362 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2363 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan,
2366 [ITEM_VLAN_HAS_MORE_VLAN] = {
2367 .name = "has_more_vlan",
2368 .help = "packet header contains another VLAN",
2369 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2370 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vlan,
2375 .help = "match IPv4 header",
2376 .priv = PRIV_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)),
2377 .next = NEXT(item_ipv4),
2382 .help = "type of service",
2383 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2384 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2385 hdr.type_of_service)),
2387 [ITEM_IPV4_FRAGMENT_OFFSET] = {
2388 .name = "fragment_offset",
2389 .help = "fragmentation flags and fragment offset",
2390 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2391 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2392 hdr.fragment_offset)),
2396 .help = "time to live",
2397 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2398 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2401 [ITEM_IPV4_PROTO] = {
2403 .help = "next protocol ID",
2404 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2405 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2406 hdr.next_proto_id)),
2410 .help = "source address",
2411 .next = NEXT(item_ipv4, NEXT_ENTRY(IPV4_ADDR), item_param),
2412 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2417 .help = "destination address",
2418 .next = NEXT(item_ipv4, NEXT_ENTRY(IPV4_ADDR), item_param),
2419 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2424 .help = "match IPv6 header",
2425 .priv = PRIV_ITEM(IPV6, sizeof(struct rte_flow_item_ipv6)),
2426 .next = NEXT(item_ipv6),
2431 .help = "traffic class",
2432 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2433 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2435 "\x0f\xf0\x00\x00")),
2437 [ITEM_IPV6_FLOW] = {
2439 .help = "flow label",
2440 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2441 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2443 "\x00\x0f\xff\xff")),
2445 [ITEM_IPV6_PROTO] = {
2447 .help = "protocol (next header)",
2448 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2449 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2454 .help = "hop limit",
2455 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2456 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2461 .help = "source address",
2462 .next = NEXT(item_ipv6, NEXT_ENTRY(IPV6_ADDR), item_param),
2463 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2468 .help = "destination address",
2469 .next = NEXT(item_ipv6, NEXT_ENTRY(IPV6_ADDR), item_param),
2470 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2473 [ITEM_IPV6_HAS_FRAG_EXT] = {
2474 .name = "has_frag_ext",
2475 .help = "fragment packet attribute",
2476 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2477 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_ipv6,
2482 .help = "match ICMP header",
2483 .priv = PRIV_ITEM(ICMP, sizeof(struct rte_flow_item_icmp)),
2484 .next = NEXT(item_icmp),
2487 [ITEM_ICMP_TYPE] = {
2489 .help = "ICMP packet type",
2490 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2491 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2494 [ITEM_ICMP_CODE] = {
2496 .help = "ICMP packet code",
2497 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2498 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2501 [ITEM_ICMP_IDENT] = {
2503 .help = "ICMP packet identifier",
2504 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2505 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2510 .help = "ICMP packet sequence number",
2511 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2512 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2517 .help = "match UDP header",
2518 .priv = PRIV_ITEM(UDP, sizeof(struct rte_flow_item_udp)),
2519 .next = NEXT(item_udp),
2524 .help = "UDP source port",
2525 .next = NEXT(item_udp, NEXT_ENTRY(UNSIGNED), item_param),
2526 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2531 .help = "UDP destination port",
2532 .next = NEXT(item_udp, NEXT_ENTRY(UNSIGNED), item_param),
2533 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2538 .help = "match TCP header",
2539 .priv = PRIV_ITEM(TCP, sizeof(struct rte_flow_item_tcp)),
2540 .next = NEXT(item_tcp),
2545 .help = "TCP source port",
2546 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2547 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2552 .help = "TCP destination port",
2553 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2554 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2557 [ITEM_TCP_FLAGS] = {
2559 .help = "TCP flags",
2560 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2561 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2566 .help = "match SCTP header",
2567 .priv = PRIV_ITEM(SCTP, sizeof(struct rte_flow_item_sctp)),
2568 .next = NEXT(item_sctp),
2573 .help = "SCTP source port",
2574 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2575 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2580 .help = "SCTP destination port",
2581 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2582 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2587 .help = "validation tag",
2588 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2589 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2592 [ITEM_SCTP_CKSUM] = {
2595 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2596 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2601 .help = "match VXLAN header",
2602 .priv = PRIV_ITEM(VXLAN, sizeof(struct rte_flow_item_vxlan)),
2603 .next = NEXT(item_vxlan),
2606 [ITEM_VXLAN_VNI] = {
2608 .help = "VXLAN identifier",
2609 .next = NEXT(item_vxlan, NEXT_ENTRY(UNSIGNED), item_param),
2610 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan, vni)),
2614 .help = "match E-Tag header",
2615 .priv = PRIV_ITEM(E_TAG, sizeof(struct rte_flow_item_e_tag)),
2616 .next = NEXT(item_e_tag),
2619 [ITEM_E_TAG_GRP_ECID_B] = {
2620 .name = "grp_ecid_b",
2621 .help = "GRP and E-CID base",
2622 .next = NEXT(item_e_tag, NEXT_ENTRY(UNSIGNED), item_param),
2623 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_e_tag,
2629 .help = "match NVGRE header",
2630 .priv = PRIV_ITEM(NVGRE, sizeof(struct rte_flow_item_nvgre)),
2631 .next = NEXT(item_nvgre),
2634 [ITEM_NVGRE_TNI] = {
2636 .help = "virtual subnet ID",
2637 .next = NEXT(item_nvgre, NEXT_ENTRY(UNSIGNED), item_param),
2638 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_nvgre, tni)),
2642 .help = "match MPLS header",
2643 .priv = PRIV_ITEM(MPLS, sizeof(struct rte_flow_item_mpls)),
2644 .next = NEXT(item_mpls),
2647 [ITEM_MPLS_LABEL] = {
2649 .help = "MPLS label",
2650 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2651 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2657 .help = "MPLS Traffic Class",
2658 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2659 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2665 .help = "MPLS Bottom-of-Stack",
2666 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2667 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2673 .help = "match GRE header",
2674 .priv = PRIV_ITEM(GRE, sizeof(struct rte_flow_item_gre)),
2675 .next = NEXT(item_gre),
2678 [ITEM_GRE_PROTO] = {
2680 .help = "GRE protocol type",
2681 .next = NEXT(item_gre, NEXT_ENTRY(UNSIGNED), item_param),
2682 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2685 [ITEM_GRE_C_RSVD0_VER] = {
2686 .name = "c_rsvd0_ver",
2688 "checksum (1b), undefined (1b), key bit (1b),"
2689 " sequence number (1b), reserved 0 (9b),"
2691 .next = NEXT(item_gre, NEXT_ENTRY(UNSIGNED), item_param),
2692 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2695 [ITEM_GRE_C_BIT] = {
2697 .help = "checksum bit (C)",
2698 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2699 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2701 "\x80\x00\x00\x00")),
2703 [ITEM_GRE_S_BIT] = {
2705 .help = "sequence number bit (S)",
2706 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2707 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2709 "\x10\x00\x00\x00")),
2711 [ITEM_GRE_K_BIT] = {
2713 .help = "key bit (K)",
2714 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2715 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2717 "\x20\x00\x00\x00")),
2721 .help = "fuzzy pattern match, expect faster than default",
2722 .priv = PRIV_ITEM(FUZZY,
2723 sizeof(struct rte_flow_item_fuzzy)),
2724 .next = NEXT(item_fuzzy),
2727 [ITEM_FUZZY_THRESH] = {
2729 .help = "match accuracy threshold",
2730 .next = NEXT(item_fuzzy, NEXT_ENTRY(UNSIGNED), item_param),
2731 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_fuzzy,
2736 .help = "match GTP header",
2737 .priv = PRIV_ITEM(GTP, sizeof(struct rte_flow_item_gtp)),
2738 .next = NEXT(item_gtp),
2741 [ITEM_GTP_FLAGS] = {
2742 .name = "v_pt_rsv_flags",
2743 .help = "GTP flags",
2744 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2745 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp,
2748 [ITEM_GTP_MSG_TYPE] = {
2750 .help = "GTP message type",
2751 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2752 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp, msg_type)),
2756 .help = "tunnel endpoint identifier",
2757 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2758 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp, teid)),
2762 .help = "match GTP header",
2763 .priv = PRIV_ITEM(GTPC, sizeof(struct rte_flow_item_gtp)),
2764 .next = NEXT(item_gtp),
2769 .help = "match GTP header",
2770 .priv = PRIV_ITEM(GTPU, sizeof(struct rte_flow_item_gtp)),
2771 .next = NEXT(item_gtp),
2776 .help = "match GENEVE header",
2777 .priv = PRIV_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)),
2778 .next = NEXT(item_geneve),
2781 [ITEM_GENEVE_VNI] = {
2783 .help = "virtual network identifier",
2784 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2785 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve, vni)),
2787 [ITEM_GENEVE_PROTO] = {
2789 .help = "GENEVE protocol type",
2790 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2791 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve,
2794 [ITEM_VXLAN_GPE] = {
2795 .name = "vxlan-gpe",
2796 .help = "match VXLAN-GPE header",
2797 .priv = PRIV_ITEM(VXLAN_GPE,
2798 sizeof(struct rte_flow_item_vxlan_gpe)),
2799 .next = NEXT(item_vxlan_gpe),
2802 [ITEM_VXLAN_GPE_VNI] = {
2804 .help = "VXLAN-GPE identifier",
2805 .next = NEXT(item_vxlan_gpe, NEXT_ENTRY(UNSIGNED), item_param),
2806 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
2809 [ITEM_ARP_ETH_IPV4] = {
2810 .name = "arp_eth_ipv4",
2811 .help = "match ARP header for Ethernet/IPv4",
2812 .priv = PRIV_ITEM(ARP_ETH_IPV4,
2813 sizeof(struct rte_flow_item_arp_eth_ipv4)),
2814 .next = NEXT(item_arp_eth_ipv4),
2817 [ITEM_ARP_ETH_IPV4_SHA] = {
2819 .help = "sender hardware address",
2820 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(MAC_ADDR),
2822 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2825 [ITEM_ARP_ETH_IPV4_SPA] = {
2827 .help = "sender IPv4 address",
2828 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(IPV4_ADDR),
2830 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2833 [ITEM_ARP_ETH_IPV4_THA] = {
2835 .help = "target hardware address",
2836 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(MAC_ADDR),
2838 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2841 [ITEM_ARP_ETH_IPV4_TPA] = {
2843 .help = "target IPv4 address",
2844 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(IPV4_ADDR),
2846 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2851 .help = "match presence of any IPv6 extension header",
2852 .priv = PRIV_ITEM(IPV6_EXT,
2853 sizeof(struct rte_flow_item_ipv6_ext)),
2854 .next = NEXT(item_ipv6_ext),
2857 [ITEM_IPV6_EXT_NEXT_HDR] = {
2859 .help = "next header",
2860 .next = NEXT(item_ipv6_ext, NEXT_ENTRY(UNSIGNED), item_param),
2861 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_ext,
2864 [ITEM_IPV6_FRAG_EXT] = {
2865 .name = "ipv6_frag_ext",
2866 .help = "match presence of IPv6 fragment extension header",
2867 .priv = PRIV_ITEM(IPV6_FRAG_EXT,
2868 sizeof(struct rte_flow_item_ipv6_frag_ext)),
2869 .next = NEXT(item_ipv6_frag_ext),
2872 [ITEM_IPV6_FRAG_EXT_NEXT_HDR] = {
2874 .help = "next header",
2875 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(UNSIGNED),
2877 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ipv6_frag_ext,
2880 [ITEM_IPV6_FRAG_EXT_FRAG_DATA] = {
2881 .name = "frag_data",
2882 .help = "Fragment flags and offset",
2883 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(UNSIGNED),
2885 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_frag_ext,
2890 .help = "match any ICMPv6 header",
2891 .priv = PRIV_ITEM(ICMP6, sizeof(struct rte_flow_item_icmp6)),
2892 .next = NEXT(item_icmp6),
2895 [ITEM_ICMP6_TYPE] = {
2897 .help = "ICMPv6 type",
2898 .next = NEXT(item_icmp6, NEXT_ENTRY(UNSIGNED), item_param),
2899 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
2902 [ITEM_ICMP6_CODE] = {
2904 .help = "ICMPv6 code",
2905 .next = NEXT(item_icmp6, NEXT_ENTRY(UNSIGNED), item_param),
2906 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
2909 [ITEM_ICMP6_ND_NS] = {
2910 .name = "icmp6_nd_ns",
2911 .help = "match ICMPv6 neighbor discovery solicitation",
2912 .priv = PRIV_ITEM(ICMP6_ND_NS,
2913 sizeof(struct rte_flow_item_icmp6_nd_ns)),
2914 .next = NEXT(item_icmp6_nd_ns),
2917 [ITEM_ICMP6_ND_NS_TARGET_ADDR] = {
2918 .name = "target_addr",
2919 .help = "target address",
2920 .next = NEXT(item_icmp6_nd_ns, NEXT_ENTRY(IPV6_ADDR),
2922 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_ns,
2925 [ITEM_ICMP6_ND_NA] = {
2926 .name = "icmp6_nd_na",
2927 .help = "match ICMPv6 neighbor discovery advertisement",
2928 .priv = PRIV_ITEM(ICMP6_ND_NA,
2929 sizeof(struct rte_flow_item_icmp6_nd_na)),
2930 .next = NEXT(item_icmp6_nd_na),
2933 [ITEM_ICMP6_ND_NA_TARGET_ADDR] = {
2934 .name = "target_addr",
2935 .help = "target address",
2936 .next = NEXT(item_icmp6_nd_na, NEXT_ENTRY(IPV6_ADDR),
2938 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_na,
2941 [ITEM_ICMP6_ND_OPT] = {
2942 .name = "icmp6_nd_opt",
2943 .help = "match presence of any ICMPv6 neighbor discovery"
2945 .priv = PRIV_ITEM(ICMP6_ND_OPT,
2946 sizeof(struct rte_flow_item_icmp6_nd_opt)),
2947 .next = NEXT(item_icmp6_nd_opt),
2950 [ITEM_ICMP6_ND_OPT_TYPE] = {
2952 .help = "ND option type",
2953 .next = NEXT(item_icmp6_nd_opt, NEXT_ENTRY(UNSIGNED),
2955 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_opt,
2958 [ITEM_ICMP6_ND_OPT_SLA_ETH] = {
2959 .name = "icmp6_nd_opt_sla_eth",
2960 .help = "match ICMPv6 neighbor discovery source Ethernet"
2961 " link-layer address option",
2963 (ICMP6_ND_OPT_SLA_ETH,
2964 sizeof(struct rte_flow_item_icmp6_nd_opt_sla_eth)),
2965 .next = NEXT(item_icmp6_nd_opt_sla_eth),
2968 [ITEM_ICMP6_ND_OPT_SLA_ETH_SLA] = {
2970 .help = "source Ethernet LLA",
2971 .next = NEXT(item_icmp6_nd_opt_sla_eth, NEXT_ENTRY(MAC_ADDR),
2973 .args = ARGS(ARGS_ENTRY_HTON
2974 (struct rte_flow_item_icmp6_nd_opt_sla_eth, sla)),
2976 [ITEM_ICMP6_ND_OPT_TLA_ETH] = {
2977 .name = "icmp6_nd_opt_tla_eth",
2978 .help = "match ICMPv6 neighbor discovery target Ethernet"
2979 " link-layer address option",
2981 (ICMP6_ND_OPT_TLA_ETH,
2982 sizeof(struct rte_flow_item_icmp6_nd_opt_tla_eth)),
2983 .next = NEXT(item_icmp6_nd_opt_tla_eth),
2986 [ITEM_ICMP6_ND_OPT_TLA_ETH_TLA] = {
2988 .help = "target Ethernet LLA",
2989 .next = NEXT(item_icmp6_nd_opt_tla_eth, NEXT_ENTRY(MAC_ADDR),
2991 .args = ARGS(ARGS_ENTRY_HTON
2992 (struct rte_flow_item_icmp6_nd_opt_tla_eth, tla)),
2996 .help = "match metadata header",
2997 .priv = PRIV_ITEM(META, sizeof(struct rte_flow_item_meta)),
2998 .next = NEXT(item_meta),
3001 [ITEM_META_DATA] = {
3003 .help = "metadata value",
3004 .next = NEXT(item_meta, NEXT_ENTRY(UNSIGNED), item_param),
3005 .args = ARGS(ARGS_ENTRY_MASK(struct rte_flow_item_meta,
3006 data, "\xff\xff\xff\xff")),
3010 .help = "match GRE key",
3011 .priv = PRIV_ITEM(GRE_KEY, sizeof(rte_be32_t)),
3012 .next = NEXT(item_gre_key),
3015 [ITEM_GRE_KEY_VALUE] = {
3017 .help = "key value",
3018 .next = NEXT(item_gre_key, NEXT_ENTRY(UNSIGNED), item_param),
3019 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3023 .help = "match GTP extension header with type 0x85",
3024 .priv = PRIV_ITEM(GTP_PSC,
3025 sizeof(struct rte_flow_item_gtp_psc)),
3026 .next = NEXT(item_gtp_psc),
3029 [ITEM_GTP_PSC_QFI] = {
3031 .help = "QoS flow identifier",
3032 .next = NEXT(item_gtp_psc, NEXT_ENTRY(UNSIGNED), item_param),
3033 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
3036 [ITEM_GTP_PSC_PDU_T] = {
3039 .next = NEXT(item_gtp_psc, NEXT_ENTRY(UNSIGNED), item_param),
3040 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
3045 .help = "match PPPoE session header",
3046 .priv = PRIV_ITEM(PPPOES, sizeof(struct rte_flow_item_pppoe)),
3047 .next = NEXT(item_pppoes),
3052 .help = "match PPPoE discovery header",
3053 .priv = PRIV_ITEM(PPPOED, sizeof(struct rte_flow_item_pppoe)),
3054 .next = NEXT(item_pppoed),
3057 [ITEM_PPPOE_SEID] = {
3059 .help = "session identifier",
3060 .next = NEXT(item_pppoes, NEXT_ENTRY(UNSIGNED), item_param),
3061 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pppoe,
3064 [ITEM_PPPOE_PROTO_ID] = {
3065 .name = "pppoe_proto_id",
3066 .help = "match PPPoE session protocol identifier",
3067 .priv = PRIV_ITEM(PPPOE_PROTO_ID,
3068 sizeof(struct rte_flow_item_pppoe_proto_id)),
3069 .next = NEXT(item_pppoe_proto_id, NEXT_ENTRY(UNSIGNED),
3071 .args = ARGS(ARGS_ENTRY_HTON
3072 (struct rte_flow_item_pppoe_proto_id, proto_id)),
3077 .help = "matches higig2 header",
3078 .priv = PRIV_ITEM(HIGIG2,
3079 sizeof(struct rte_flow_item_higig2_hdr)),
3080 .next = NEXT(item_higig2),
3083 [ITEM_HIGIG2_CLASSIFICATION] = {
3084 .name = "classification",
3085 .help = "matches classification of higig2 header",
3086 .next = NEXT(item_higig2, NEXT_ENTRY(UNSIGNED), item_param),
3087 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
3088 hdr.ppt1.classification)),
3090 [ITEM_HIGIG2_VID] = {
3092 .help = "matches vid of higig2 header",
3093 .next = NEXT(item_higig2, NEXT_ENTRY(UNSIGNED), item_param),
3094 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
3099 .help = "match tag value",
3100 .priv = PRIV_ITEM(TAG, sizeof(struct rte_flow_item_tag)),
3101 .next = NEXT(item_tag),
3106 .help = "tag value to match",
3107 .next = NEXT(item_tag, NEXT_ENTRY(UNSIGNED), item_param),
3108 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, data)),
3110 [ITEM_TAG_INDEX] = {
3112 .help = "index of tag array to match",
3113 .next = NEXT(item_tag, NEXT_ENTRY(UNSIGNED),
3114 NEXT_ENTRY(ITEM_PARAM_IS)),
3115 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, index)),
3117 [ITEM_L2TPV3OIP] = {
3118 .name = "l2tpv3oip",
3119 .help = "match L2TPv3 over IP header",
3120 .priv = PRIV_ITEM(L2TPV3OIP,
3121 sizeof(struct rte_flow_item_l2tpv3oip)),
3122 .next = NEXT(item_l2tpv3oip),
3125 [ITEM_L2TPV3OIP_SESSION_ID] = {
3126 .name = "session_id",
3127 .help = "session identifier",
3128 .next = NEXT(item_l2tpv3oip, NEXT_ENTRY(UNSIGNED), item_param),
3129 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv3oip,
3134 .help = "match ESP header",
3135 .priv = PRIV_ITEM(ESP, sizeof(struct rte_flow_item_esp)),
3136 .next = NEXT(item_esp),
3141 .help = "security policy index",
3142 .next = NEXT(item_esp, NEXT_ENTRY(UNSIGNED), item_param),
3143 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_esp,
3148 .help = "match AH header",
3149 .priv = PRIV_ITEM(AH, sizeof(struct rte_flow_item_ah)),
3150 .next = NEXT(item_ah),
3155 .help = "security parameters index",
3156 .next = NEXT(item_ah, NEXT_ENTRY(UNSIGNED), item_param),
3157 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ah, spi)),
3161 .help = "match pfcp header",
3162 .priv = PRIV_ITEM(PFCP, sizeof(struct rte_flow_item_pfcp)),
3163 .next = NEXT(item_pfcp),
3166 [ITEM_PFCP_S_FIELD] = {
3169 .next = NEXT(item_pfcp, NEXT_ENTRY(UNSIGNED), item_param),
3170 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp,
3173 [ITEM_PFCP_SEID] = {
3175 .help = "session endpoint identifier",
3176 .next = NEXT(item_pfcp, NEXT_ENTRY(UNSIGNED), item_param),
3177 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp, seid)),
3181 .help = "match eCPRI header",
3182 .priv = PRIV_ITEM(ECPRI, sizeof(struct rte_flow_item_ecpri)),
3183 .next = NEXT(item_ecpri),
3186 [ITEM_ECPRI_COMMON] = {
3188 .help = "eCPRI common header",
3189 .next = NEXT(item_ecpri_common),
3191 [ITEM_ECPRI_COMMON_TYPE] = {
3193 .help = "type of common header",
3194 .next = NEXT(item_ecpri_common_type),
3195 .args = ARGS(ARG_ENTRY_HTON(struct rte_flow_item_ecpri)),
3197 [ITEM_ECPRI_COMMON_TYPE_IQ_DATA] = {
3199 .help = "Type #0: IQ Data",
3200 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
3202 .call = parse_vc_item_ecpri_type,
3204 [ITEM_ECPRI_MSG_IQ_DATA_PCID] = {
3206 .help = "Physical Channel ID",
3207 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
3208 ITEM_ECPRI_COMMON, ITEM_NEXT),
3209 NEXT_ENTRY(UNSIGNED), item_param),
3210 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3213 [ITEM_ECPRI_COMMON_TYPE_RTC_CTRL] = {
3215 .help = "Type #2: Real-Time Control Data",
3216 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
3218 .call = parse_vc_item_ecpri_type,
3220 [ITEM_ECPRI_MSG_RTC_CTRL_RTCID] = {
3222 .help = "Real-Time Control Data ID",
3223 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
3224 ITEM_ECPRI_COMMON, ITEM_NEXT),
3225 NEXT_ENTRY(UNSIGNED), item_param),
3226 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3229 [ITEM_ECPRI_COMMON_TYPE_DLY_MSR] = {
3230 .name = "delay_measure",
3231 .help = "Type #5: One-Way Delay Measurement",
3232 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
3234 .call = parse_vc_item_ecpri_type,
3236 [ITEM_ECPRI_MSG_DLY_MSR_MSRID] = {
3238 .help = "Measurement ID",
3239 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
3240 ITEM_ECPRI_COMMON, ITEM_NEXT),
3241 NEXT_ENTRY(UNSIGNED), item_param),
3242 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3245 /* Validate/create actions. */
3248 .help = "submit a list of associated actions",
3249 .next = NEXT(next_action),
3254 .help = "specify next action",
3255 .next = NEXT(next_action),
3259 .help = "end list of actions",
3260 .priv = PRIV_ACTION(END, 0),
3265 .help = "no-op action",
3266 .priv = PRIV_ACTION(VOID, 0),
3267 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3270 [ACTION_PASSTHRU] = {
3272 .help = "let subsequent rule process matched packets",
3273 .priv = PRIV_ACTION(PASSTHRU, 0),
3274 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3279 .help = "redirect traffic to a given group",
3280 .priv = PRIV_ACTION(JUMP, sizeof(struct rte_flow_action_jump)),
3281 .next = NEXT(action_jump),
3284 [ACTION_JUMP_GROUP] = {
3286 .help = "group to redirect traffic to",
3287 .next = NEXT(action_jump, NEXT_ENTRY(UNSIGNED)),
3288 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump, group)),
3289 .call = parse_vc_conf,
3293 .help = "attach 32 bit value to packets",
3294 .priv = PRIV_ACTION(MARK, sizeof(struct rte_flow_action_mark)),
3295 .next = NEXT(action_mark),
3298 [ACTION_MARK_ID] = {
3300 .help = "32 bit value to return with packets",
3301 .next = NEXT(action_mark, NEXT_ENTRY(UNSIGNED)),
3302 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_mark, id)),
3303 .call = parse_vc_conf,
3307 .help = "flag packets",
3308 .priv = PRIV_ACTION(FLAG, 0),
3309 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3314 .help = "assign packets to a given queue index",
3315 .priv = PRIV_ACTION(QUEUE,
3316 sizeof(struct rte_flow_action_queue)),
3317 .next = NEXT(action_queue),
3320 [ACTION_QUEUE_INDEX] = {
3322 .help = "queue index to use",
3323 .next = NEXT(action_queue, NEXT_ENTRY(UNSIGNED)),
3324 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_queue, index)),
3325 .call = parse_vc_conf,
3329 .help = "drop packets (note: passthru has priority)",
3330 .priv = PRIV_ACTION(DROP, 0),
3331 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3336 .help = "enable counters for this rule",
3337 .priv = PRIV_ACTION(COUNT,
3338 sizeof(struct rte_flow_action_count)),
3339 .next = NEXT(action_count),
3342 [ACTION_COUNT_ID] = {
3343 .name = "identifier",
3344 .help = "counter identifier to use",
3345 .next = NEXT(action_count, NEXT_ENTRY(UNSIGNED)),
3346 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_count, id)),
3347 .call = parse_vc_conf,
3349 [ACTION_COUNT_SHARED] = {
3351 .help = "shared counter",
3352 .next = NEXT(action_count, NEXT_ENTRY(BOOLEAN)),
3353 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_count,
3355 .call = parse_vc_conf,
3359 .help = "spread packets among several queues",
3360 .priv = PRIV_ACTION(RSS, sizeof(struct action_rss_data)),
3361 .next = NEXT(action_rss),
3362 .call = parse_vc_action_rss,
3364 [ACTION_RSS_FUNC] = {
3366 .help = "RSS hash function to apply",
3367 .next = NEXT(action_rss,
3368 NEXT_ENTRY(ACTION_RSS_FUNC_DEFAULT,
3369 ACTION_RSS_FUNC_TOEPLITZ,
3370 ACTION_RSS_FUNC_SIMPLE_XOR,
3371 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ)),
3373 [ACTION_RSS_FUNC_DEFAULT] = {
3375 .help = "default hash function",
3376 .call = parse_vc_action_rss_func,
3378 [ACTION_RSS_FUNC_TOEPLITZ] = {
3380 .help = "Toeplitz hash function",
3381 .call = parse_vc_action_rss_func,
3383 [ACTION_RSS_FUNC_SIMPLE_XOR] = {
3384 .name = "simple_xor",
3385 .help = "simple XOR hash function",
3386 .call = parse_vc_action_rss_func,
3388 [ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ] = {
3389 .name = "symmetric_toeplitz",
3390 .help = "Symmetric Toeplitz hash function",
3391 .call = parse_vc_action_rss_func,
3393 [ACTION_RSS_LEVEL] = {
3395 .help = "encapsulation level for \"types\"",
3396 .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
3397 .args = ARGS(ARGS_ENTRY_ARB
3398 (offsetof(struct action_rss_data, conf) +
3399 offsetof(struct rte_flow_action_rss, level),
3400 sizeof(((struct rte_flow_action_rss *)0)->
3403 [ACTION_RSS_TYPES] = {
3405 .help = "specific RSS hash types",
3406 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)),
3408 [ACTION_RSS_TYPE] = {
3410 .help = "RSS hash type",
3411 .call = parse_vc_action_rss_type,
3412 .comp = comp_vc_action_rss_type,
3414 [ACTION_RSS_KEY] = {
3416 .help = "RSS hash key",
3417 .next = NEXT(action_rss, NEXT_ENTRY(HEX)),
3418 .args = ARGS(ARGS_ENTRY_ARB(0, 0),
3420 (offsetof(struct action_rss_data, conf) +
3421 offsetof(struct rte_flow_action_rss, key_len),
3422 sizeof(((struct rte_flow_action_rss *)0)->
3424 ARGS_ENTRY(struct action_rss_data, key)),
3426 [ACTION_RSS_KEY_LEN] = {
3428 .help = "RSS hash key length in bytes",
3429 .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
3430 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
3431 (offsetof(struct action_rss_data, conf) +
3432 offsetof(struct rte_flow_action_rss, key_len),
3433 sizeof(((struct rte_flow_action_rss *)0)->
3436 RSS_HASH_KEY_LENGTH)),
3438 [ACTION_RSS_QUEUES] = {
3440 .help = "queue indices to use",
3441 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_QUEUE)),
3442 .call = parse_vc_conf,
3444 [ACTION_RSS_QUEUE] = {
3446 .help = "queue index",
3447 .call = parse_vc_action_rss_queue,
3448 .comp = comp_vc_action_rss_queue,
3452 .help = "direct traffic to physical function",
3453 .priv = PRIV_ACTION(PF, 0),
3454 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3459 .help = "direct traffic to a virtual function ID",
3460 .priv = PRIV_ACTION(VF, sizeof(struct rte_flow_action_vf)),
3461 .next = NEXT(action_vf),
3464 [ACTION_VF_ORIGINAL] = {
3466 .help = "use original VF ID if possible",
3467 .next = NEXT(action_vf, NEXT_ENTRY(BOOLEAN)),
3468 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_vf,
3470 .call = parse_vc_conf,
3475 .next = NEXT(action_vf, NEXT_ENTRY(UNSIGNED)),
3476 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)),
3477 .call = parse_vc_conf,
3479 [ACTION_PHY_PORT] = {
3481 .help = "direct packets to physical port index",
3482 .priv = PRIV_ACTION(PHY_PORT,
3483 sizeof(struct rte_flow_action_phy_port)),
3484 .next = NEXT(action_phy_port),
3487 [ACTION_PHY_PORT_ORIGINAL] = {
3489 .help = "use original port index if possible",
3490 .next = NEXT(action_phy_port, NEXT_ENTRY(BOOLEAN)),
3491 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_phy_port,
3493 .call = parse_vc_conf,
3495 [ACTION_PHY_PORT_INDEX] = {
3497 .help = "physical port index",
3498 .next = NEXT(action_phy_port, NEXT_ENTRY(UNSIGNED)),
3499 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_phy_port,
3501 .call = parse_vc_conf,
3503 [ACTION_PORT_ID] = {
3505 .help = "direct matching traffic to a given DPDK port ID",
3506 .priv = PRIV_ACTION(PORT_ID,
3507 sizeof(struct rte_flow_action_port_id)),
3508 .next = NEXT(action_port_id),
3511 [ACTION_PORT_ID_ORIGINAL] = {
3513 .help = "use original DPDK port ID if possible",
3514 .next = NEXT(action_port_id, NEXT_ENTRY(BOOLEAN)),
3515 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_port_id,
3517 .call = parse_vc_conf,
3519 [ACTION_PORT_ID_ID] = {
3521 .help = "DPDK port ID",
3522 .next = NEXT(action_port_id, NEXT_ENTRY(UNSIGNED)),
3523 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_port_id, id)),
3524 .call = parse_vc_conf,
3528 .help = "meter the directed packets at given id",
3529 .priv = PRIV_ACTION(METER,
3530 sizeof(struct rte_flow_action_meter)),
3531 .next = NEXT(action_meter),
3534 [ACTION_METER_ID] = {
3536 .help = "meter id to use",
3537 .next = NEXT(action_meter, NEXT_ENTRY(UNSIGNED)),
3538 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter, mtr_id)),
3539 .call = parse_vc_conf,
3541 [ACTION_OF_SET_MPLS_TTL] = {
3542 .name = "of_set_mpls_ttl",
3543 .help = "OpenFlow's OFPAT_SET_MPLS_TTL",
3546 sizeof(struct rte_flow_action_of_set_mpls_ttl)),
3547 .next = NEXT(action_of_set_mpls_ttl),
3550 [ACTION_OF_SET_MPLS_TTL_MPLS_TTL] = {
3553 .next = NEXT(action_of_set_mpls_ttl, NEXT_ENTRY(UNSIGNED)),
3554 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_mpls_ttl,
3556 .call = parse_vc_conf,
3558 [ACTION_OF_DEC_MPLS_TTL] = {
3559 .name = "of_dec_mpls_ttl",
3560 .help = "OpenFlow's OFPAT_DEC_MPLS_TTL",
3561 .priv = PRIV_ACTION(OF_DEC_MPLS_TTL, 0),
3562 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3565 [ACTION_OF_SET_NW_TTL] = {
3566 .name = "of_set_nw_ttl",
3567 .help = "OpenFlow's OFPAT_SET_NW_TTL",
3570 sizeof(struct rte_flow_action_of_set_nw_ttl)),
3571 .next = NEXT(action_of_set_nw_ttl),
3574 [ACTION_OF_SET_NW_TTL_NW_TTL] = {
3577 .next = NEXT(action_of_set_nw_ttl, NEXT_ENTRY(UNSIGNED)),
3578 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_nw_ttl,
3580 .call = parse_vc_conf,
3582 [ACTION_OF_DEC_NW_TTL] = {
3583 .name = "of_dec_nw_ttl",
3584 .help = "OpenFlow's OFPAT_DEC_NW_TTL",
3585 .priv = PRIV_ACTION(OF_DEC_NW_TTL, 0),
3586 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3589 [ACTION_OF_COPY_TTL_OUT] = {
3590 .name = "of_copy_ttl_out",
3591 .help = "OpenFlow's OFPAT_COPY_TTL_OUT",
3592 .priv = PRIV_ACTION(OF_COPY_TTL_OUT, 0),
3593 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3596 [ACTION_OF_COPY_TTL_IN] = {
3597 .name = "of_copy_ttl_in",
3598 .help = "OpenFlow's OFPAT_COPY_TTL_IN",
3599 .priv = PRIV_ACTION(OF_COPY_TTL_IN, 0),
3600 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3603 [ACTION_OF_POP_VLAN] = {
3604 .name = "of_pop_vlan",
3605 .help = "OpenFlow's OFPAT_POP_VLAN",
3606 .priv = PRIV_ACTION(OF_POP_VLAN, 0),
3607 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3610 [ACTION_OF_PUSH_VLAN] = {
3611 .name = "of_push_vlan",
3612 .help = "OpenFlow's OFPAT_PUSH_VLAN",
3615 sizeof(struct rte_flow_action_of_push_vlan)),
3616 .next = NEXT(action_of_push_vlan),
3619 [ACTION_OF_PUSH_VLAN_ETHERTYPE] = {
3620 .name = "ethertype",
3621 .help = "EtherType",
3622 .next = NEXT(action_of_push_vlan, NEXT_ENTRY(UNSIGNED)),
3623 .args = ARGS(ARGS_ENTRY_HTON
3624 (struct rte_flow_action_of_push_vlan,
3626 .call = parse_vc_conf,
3628 [ACTION_OF_SET_VLAN_VID] = {
3629 .name = "of_set_vlan_vid",
3630 .help = "OpenFlow's OFPAT_SET_VLAN_VID",
3633 sizeof(struct rte_flow_action_of_set_vlan_vid)),
3634 .next = NEXT(action_of_set_vlan_vid),
3637 [ACTION_OF_SET_VLAN_VID_VLAN_VID] = {
3640 .next = NEXT(action_of_set_vlan_vid, NEXT_ENTRY(UNSIGNED)),
3641 .args = ARGS(ARGS_ENTRY_HTON
3642 (struct rte_flow_action_of_set_vlan_vid,
3644 .call = parse_vc_conf,
3646 [ACTION_OF_SET_VLAN_PCP] = {
3647 .name = "of_set_vlan_pcp",
3648 .help = "OpenFlow's OFPAT_SET_VLAN_PCP",
3651 sizeof(struct rte_flow_action_of_set_vlan_pcp)),
3652 .next = NEXT(action_of_set_vlan_pcp),
3655 [ACTION_OF_SET_VLAN_PCP_VLAN_PCP] = {
3657 .help = "VLAN priority",
3658 .next = NEXT(action_of_set_vlan_pcp, NEXT_ENTRY(UNSIGNED)),
3659 .args = ARGS(ARGS_ENTRY_HTON
3660 (struct rte_flow_action_of_set_vlan_pcp,
3662 .call = parse_vc_conf,
3664 [ACTION_OF_POP_MPLS] = {
3665 .name = "of_pop_mpls",
3666 .help = "OpenFlow's OFPAT_POP_MPLS",
3667 .priv = PRIV_ACTION(OF_POP_MPLS,
3668 sizeof(struct rte_flow_action_of_pop_mpls)),
3669 .next = NEXT(action_of_pop_mpls),
3672 [ACTION_OF_POP_MPLS_ETHERTYPE] = {
3673 .name = "ethertype",
3674 .help = "EtherType",
3675 .next = NEXT(action_of_pop_mpls, NEXT_ENTRY(UNSIGNED)),
3676 .args = ARGS(ARGS_ENTRY_HTON
3677 (struct rte_flow_action_of_pop_mpls,
3679 .call = parse_vc_conf,
3681 [ACTION_OF_PUSH_MPLS] = {
3682 .name = "of_push_mpls",
3683 .help = "OpenFlow's OFPAT_PUSH_MPLS",
3686 sizeof(struct rte_flow_action_of_push_mpls)),
3687 .next = NEXT(action_of_push_mpls),
3690 [ACTION_OF_PUSH_MPLS_ETHERTYPE] = {
3691 .name = "ethertype",
3692 .help = "EtherType",
3693 .next = NEXT(action_of_push_mpls, NEXT_ENTRY(UNSIGNED)),
3694 .args = ARGS(ARGS_ENTRY_HTON
3695 (struct rte_flow_action_of_push_mpls,
3697 .call = parse_vc_conf,
3699 [ACTION_VXLAN_ENCAP] = {
3700 .name = "vxlan_encap",
3701 .help = "VXLAN encapsulation, uses configuration set by \"set"
3703 .priv = PRIV_ACTION(VXLAN_ENCAP,
3704 sizeof(struct action_vxlan_encap_data)),
3705 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3706 .call = parse_vc_action_vxlan_encap,
3708 [ACTION_VXLAN_DECAP] = {
3709 .name = "vxlan_decap",
3710 .help = "Performs a decapsulation action by stripping all"
3711 " headers of the VXLAN tunnel network overlay from the"
3713 .priv = PRIV_ACTION(VXLAN_DECAP, 0),
3714 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3717 [ACTION_NVGRE_ENCAP] = {
3718 .name = "nvgre_encap",
3719 .help = "NVGRE encapsulation, uses configuration set by \"set"
3721 .priv = PRIV_ACTION(NVGRE_ENCAP,
3722 sizeof(struct action_nvgre_encap_data)),
3723 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3724 .call = parse_vc_action_nvgre_encap,
3726 [ACTION_NVGRE_DECAP] = {
3727 .name = "nvgre_decap",
3728 .help = "Performs a decapsulation action by stripping all"
3729 " headers of the NVGRE tunnel network overlay from the"
3731 .priv = PRIV_ACTION(NVGRE_DECAP, 0),
3732 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3735 [ACTION_L2_ENCAP] = {
3737 .help = "l2 encap, uses configuration set by"
3738 " \"set l2_encap\"",
3739 .priv = PRIV_ACTION(RAW_ENCAP,
3740 sizeof(struct action_raw_encap_data)),
3741 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3742 .call = parse_vc_action_l2_encap,
3744 [ACTION_L2_DECAP] = {
3746 .help = "l2 decap, uses configuration set by"
3747 " \"set l2_decap\"",
3748 .priv = PRIV_ACTION(RAW_DECAP,
3749 sizeof(struct action_raw_decap_data)),
3750 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3751 .call = parse_vc_action_l2_decap,
3753 [ACTION_MPLSOGRE_ENCAP] = {
3754 .name = "mplsogre_encap",
3755 .help = "mplsogre encapsulation, uses configuration set by"
3756 " \"set mplsogre_encap\"",
3757 .priv = PRIV_ACTION(RAW_ENCAP,
3758 sizeof(struct action_raw_encap_data)),
3759 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3760 .call = parse_vc_action_mplsogre_encap,
3762 [ACTION_MPLSOGRE_DECAP] = {
3763 .name = "mplsogre_decap",
3764 .help = "mplsogre decapsulation, uses configuration set by"
3765 " \"set mplsogre_decap\"",
3766 .priv = PRIV_ACTION(RAW_DECAP,
3767 sizeof(struct action_raw_decap_data)),
3768 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3769 .call = parse_vc_action_mplsogre_decap,
3771 [ACTION_MPLSOUDP_ENCAP] = {
3772 .name = "mplsoudp_encap",
3773 .help = "mplsoudp encapsulation, uses configuration set by"
3774 " \"set mplsoudp_encap\"",
3775 .priv = PRIV_ACTION(RAW_ENCAP,
3776 sizeof(struct action_raw_encap_data)),
3777 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3778 .call = parse_vc_action_mplsoudp_encap,
3780 [ACTION_MPLSOUDP_DECAP] = {
3781 .name = "mplsoudp_decap",
3782 .help = "mplsoudp decapsulation, uses configuration set by"
3783 " \"set mplsoudp_decap\"",
3784 .priv = PRIV_ACTION(RAW_DECAP,
3785 sizeof(struct action_raw_decap_data)),
3786 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3787 .call = parse_vc_action_mplsoudp_decap,
3789 [ACTION_SET_IPV4_SRC] = {
3790 .name = "set_ipv4_src",
3791 .help = "Set a new IPv4 source address in the outermost"
3793 .priv = PRIV_ACTION(SET_IPV4_SRC,
3794 sizeof(struct rte_flow_action_set_ipv4)),
3795 .next = NEXT(action_set_ipv4_src),
3798 [ACTION_SET_IPV4_SRC_IPV4_SRC] = {
3799 .name = "ipv4_addr",
3800 .help = "new IPv4 source address to set",
3801 .next = NEXT(action_set_ipv4_src, NEXT_ENTRY(IPV4_ADDR)),
3802 .args = ARGS(ARGS_ENTRY_HTON
3803 (struct rte_flow_action_set_ipv4, ipv4_addr)),
3804 .call = parse_vc_conf,
3806 [ACTION_SET_IPV4_DST] = {
3807 .name = "set_ipv4_dst",
3808 .help = "Set a new IPv4 destination address in the outermost"
3810 .priv = PRIV_ACTION(SET_IPV4_DST,
3811 sizeof(struct rte_flow_action_set_ipv4)),
3812 .next = NEXT(action_set_ipv4_dst),
3815 [ACTION_SET_IPV4_DST_IPV4_DST] = {
3816 .name = "ipv4_addr",
3817 .help = "new IPv4 destination address to set",
3818 .next = NEXT(action_set_ipv4_dst, NEXT_ENTRY(IPV4_ADDR)),
3819 .args = ARGS(ARGS_ENTRY_HTON
3820 (struct rte_flow_action_set_ipv4, ipv4_addr)),
3821 .call = parse_vc_conf,
3823 [ACTION_SET_IPV6_SRC] = {
3824 .name = "set_ipv6_src",
3825 .help = "Set a new IPv6 source address in the outermost"
3827 .priv = PRIV_ACTION(SET_IPV6_SRC,
3828 sizeof(struct rte_flow_action_set_ipv6)),
3829 .next = NEXT(action_set_ipv6_src),
3832 [ACTION_SET_IPV6_SRC_IPV6_SRC] = {
3833 .name = "ipv6_addr",
3834 .help = "new IPv6 source address to set",
3835 .next = NEXT(action_set_ipv6_src, NEXT_ENTRY(IPV6_ADDR)),
3836 .args = ARGS(ARGS_ENTRY_HTON
3837 (struct rte_flow_action_set_ipv6, ipv6_addr)),
3838 .call = parse_vc_conf,
3840 [ACTION_SET_IPV6_DST] = {
3841 .name = "set_ipv6_dst",
3842 .help = "Set a new IPv6 destination address in the outermost"
3844 .priv = PRIV_ACTION(SET_IPV6_DST,
3845 sizeof(struct rte_flow_action_set_ipv6)),
3846 .next = NEXT(action_set_ipv6_dst),
3849 [ACTION_SET_IPV6_DST_IPV6_DST] = {
3850 .name = "ipv6_addr",
3851 .help = "new IPv6 destination address to set",
3852 .next = NEXT(action_set_ipv6_dst, NEXT_ENTRY(IPV6_ADDR)),
3853 .args = ARGS(ARGS_ENTRY_HTON
3854 (struct rte_flow_action_set_ipv6, ipv6_addr)),
3855 .call = parse_vc_conf,
3857 [ACTION_SET_TP_SRC] = {
3858 .name = "set_tp_src",
3859 .help = "set a new source port number in the outermost"
3861 .priv = PRIV_ACTION(SET_TP_SRC,
3862 sizeof(struct rte_flow_action_set_tp)),
3863 .next = NEXT(action_set_tp_src),
3866 [ACTION_SET_TP_SRC_TP_SRC] = {
3868 .help = "new source port number to set",
3869 .next = NEXT(action_set_tp_src, NEXT_ENTRY(UNSIGNED)),
3870 .args = ARGS(ARGS_ENTRY_HTON
3871 (struct rte_flow_action_set_tp, port)),
3872 .call = parse_vc_conf,
3874 [ACTION_SET_TP_DST] = {
3875 .name = "set_tp_dst",
3876 .help = "set a new destination port number in the outermost"
3878 .priv = PRIV_ACTION(SET_TP_DST,
3879 sizeof(struct rte_flow_action_set_tp)),
3880 .next = NEXT(action_set_tp_dst),
3883 [ACTION_SET_TP_DST_TP_DST] = {
3885 .help = "new destination port number to set",
3886 .next = NEXT(action_set_tp_dst, NEXT_ENTRY(UNSIGNED)),
3887 .args = ARGS(ARGS_ENTRY_HTON
3888 (struct rte_flow_action_set_tp, port)),
3889 .call = parse_vc_conf,
3891 [ACTION_MAC_SWAP] = {
3893 .help = "Swap the source and destination MAC addresses"
3894 " in the outermost Ethernet header",
3895 .priv = PRIV_ACTION(MAC_SWAP, 0),
3896 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3899 [ACTION_DEC_TTL] = {
3901 .help = "decrease network TTL if available",
3902 .priv = PRIV_ACTION(DEC_TTL, 0),
3903 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3906 [ACTION_SET_TTL] = {
3908 .help = "set ttl value",
3909 .priv = PRIV_ACTION(SET_TTL,
3910 sizeof(struct rte_flow_action_set_ttl)),
3911 .next = NEXT(action_set_ttl),
3914 [ACTION_SET_TTL_TTL] = {
3915 .name = "ttl_value",
3916 .help = "new ttl value to set",
3917 .next = NEXT(action_set_ttl, NEXT_ENTRY(UNSIGNED)),
3918 .args = ARGS(ARGS_ENTRY_HTON
3919 (struct rte_flow_action_set_ttl, ttl_value)),
3920 .call = parse_vc_conf,
3922 [ACTION_SET_MAC_SRC] = {
3923 .name = "set_mac_src",
3924 .help = "set source mac address",
3925 .priv = PRIV_ACTION(SET_MAC_SRC,
3926 sizeof(struct rte_flow_action_set_mac)),
3927 .next = NEXT(action_set_mac_src),
3930 [ACTION_SET_MAC_SRC_MAC_SRC] = {
3932 .help = "new source mac address",
3933 .next = NEXT(action_set_mac_src, NEXT_ENTRY(MAC_ADDR)),
3934 .args = ARGS(ARGS_ENTRY_HTON
3935 (struct rte_flow_action_set_mac, mac_addr)),
3936 .call = parse_vc_conf,
3938 [ACTION_SET_MAC_DST] = {
3939 .name = "set_mac_dst",
3940 .help = "set destination mac address",
3941 .priv = PRIV_ACTION(SET_MAC_DST,
3942 sizeof(struct rte_flow_action_set_mac)),
3943 .next = NEXT(action_set_mac_dst),
3946 [ACTION_SET_MAC_DST_MAC_DST] = {
3948 .help = "new destination mac address to set",
3949 .next = NEXT(action_set_mac_dst, NEXT_ENTRY(MAC_ADDR)),
3950 .args = ARGS(ARGS_ENTRY_HTON
3951 (struct rte_flow_action_set_mac, mac_addr)),
3952 .call = parse_vc_conf,
3954 [ACTION_INC_TCP_SEQ] = {
3955 .name = "inc_tcp_seq",
3956 .help = "increase TCP sequence number",
3957 .priv = PRIV_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
3958 .next = NEXT(action_inc_tcp_seq),
3961 [ACTION_INC_TCP_SEQ_VALUE] = {
3963 .help = "the value to increase TCP sequence number by",
3964 .next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(UNSIGNED)),
3965 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3966 .call = parse_vc_conf,
3968 [ACTION_DEC_TCP_SEQ] = {
3969 .name = "dec_tcp_seq",
3970 .help = "decrease TCP sequence number",
3971 .priv = PRIV_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
3972 .next = NEXT(action_dec_tcp_seq),
3975 [ACTION_DEC_TCP_SEQ_VALUE] = {
3977 .help = "the value to decrease TCP sequence number by",
3978 .next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(UNSIGNED)),
3979 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3980 .call = parse_vc_conf,
3982 [ACTION_INC_TCP_ACK] = {
3983 .name = "inc_tcp_ack",
3984 .help = "increase TCP acknowledgment number",
3985 .priv = PRIV_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
3986 .next = NEXT(action_inc_tcp_ack),
3989 [ACTION_INC_TCP_ACK_VALUE] = {
3991 .help = "the value to increase TCP acknowledgment number by",
3992 .next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(UNSIGNED)),
3993 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3994 .call = parse_vc_conf,
3996 [ACTION_DEC_TCP_ACK] = {
3997 .name = "dec_tcp_ack",
3998 .help = "decrease TCP acknowledgment number",
3999 .priv = PRIV_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
4000 .next = NEXT(action_dec_tcp_ack),
4003 [ACTION_DEC_TCP_ACK_VALUE] = {
4005 .help = "the value to decrease TCP acknowledgment number by",
4006 .next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(UNSIGNED)),
4007 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4008 .call = parse_vc_conf,
4010 [ACTION_RAW_ENCAP] = {
4011 .name = "raw_encap",
4012 .help = "encapsulation data, defined by set raw_encap",
4013 .priv = PRIV_ACTION(RAW_ENCAP,
4014 sizeof(struct action_raw_encap_data)),
4015 .next = NEXT(action_raw_encap),
4016 .call = parse_vc_action_raw_encap,
4018 [ACTION_RAW_ENCAP_INDEX] = {
4020 .help = "the index of raw_encap_confs",
4021 .next = NEXT(NEXT_ENTRY(ACTION_RAW_ENCAP_INDEX_VALUE)),
4023 [ACTION_RAW_ENCAP_INDEX_VALUE] = {
4026 .help = "unsigned integer value",
4027 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4028 .call = parse_vc_action_raw_encap_index,
4029 .comp = comp_set_raw_index,
4031 [ACTION_RAW_DECAP] = {
4032 .name = "raw_decap",
4033 .help = "decapsulation data, defined by set raw_encap",
4034 .priv = PRIV_ACTION(RAW_DECAP,
4035 sizeof(struct action_raw_decap_data)),
4036 .next = NEXT(action_raw_decap),
4037 .call = parse_vc_action_raw_decap,
4039 [ACTION_RAW_DECAP_INDEX] = {
4041 .help = "the index of raw_encap_confs",
4042 .next = NEXT(NEXT_ENTRY(ACTION_RAW_DECAP_INDEX_VALUE)),
4044 [ACTION_RAW_DECAP_INDEX_VALUE] = {
4047 .help = "unsigned integer value",
4048 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4049 .call = parse_vc_action_raw_decap_index,
4050 .comp = comp_set_raw_index,
4052 /* Top level command. */
4055 .help = "set raw encap/decap/sample data",
4056 .type = "set raw_encap|raw_decap <index> <pattern>"
4057 " or set sample_actions <index> <action>",
4058 .next = NEXT(NEXT_ENTRY
4061 SET_SAMPLE_ACTIONS)),
4062 .call = parse_set_init,
4064 /* Sub-level commands. */
4066 .name = "raw_encap",
4067 .help = "set raw encap data",
4068 .next = NEXT(next_set_raw),
4069 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4070 (offsetof(struct buffer, port),
4071 sizeof(((struct buffer *)0)->port),
4072 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
4073 .call = parse_set_raw_encap_decap,
4076 .name = "raw_decap",
4077 .help = "set raw decap data",
4078 .next = NEXT(next_set_raw),
4079 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4080 (offsetof(struct buffer, port),
4081 sizeof(((struct buffer *)0)->port),
4082 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
4083 .call = parse_set_raw_encap_decap,
4088 .help = "index of raw_encap/raw_decap data",
4089 .next = NEXT(next_item),
4092 [SET_SAMPLE_INDEX] = {
4095 .help = "index of sample actions",
4096 .next = NEXT(next_action_sample),
4099 [SET_SAMPLE_ACTIONS] = {
4100 .name = "sample_actions",
4101 .help = "set sample actions list",
4102 .next = NEXT(NEXT_ENTRY(SET_SAMPLE_INDEX)),
4103 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4104 (offsetof(struct buffer, port),
4105 sizeof(((struct buffer *)0)->port),
4106 0, RAW_SAMPLE_CONFS_MAX_NUM - 1)),
4107 .call = parse_set_sample_action,
4109 [ACTION_SET_TAG] = {
4112 .priv = PRIV_ACTION(SET_TAG,
4113 sizeof(struct rte_flow_action_set_tag)),
4114 .next = NEXT(action_set_tag),
4117 [ACTION_SET_TAG_INDEX] = {
4119 .help = "index of tag array",
4120 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
4121 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_set_tag, index)),
4122 .call = parse_vc_conf,
4124 [ACTION_SET_TAG_DATA] = {
4126 .help = "tag value",
4127 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
4128 .args = ARGS(ARGS_ENTRY
4129 (struct rte_flow_action_set_tag, data)),
4130 .call = parse_vc_conf,
4132 [ACTION_SET_TAG_MASK] = {
4134 .help = "mask for tag value",
4135 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
4136 .args = ARGS(ARGS_ENTRY
4137 (struct rte_flow_action_set_tag, mask)),
4138 .call = parse_vc_conf,
4140 [ACTION_SET_META] = {
4142 .help = "set metadata",
4143 .priv = PRIV_ACTION(SET_META,
4144 sizeof(struct rte_flow_action_set_meta)),
4145 .next = NEXT(action_set_meta),
4146 .call = parse_vc_action_set_meta,
4148 [ACTION_SET_META_DATA] = {
4150 .help = "metadata value",
4151 .next = NEXT(action_set_meta, NEXT_ENTRY(UNSIGNED)),
4152 .args = ARGS(ARGS_ENTRY
4153 (struct rte_flow_action_set_meta, data)),
4154 .call = parse_vc_conf,
4156 [ACTION_SET_META_MASK] = {
4158 .help = "mask for metadata value",
4159 .next = NEXT(action_set_meta, NEXT_ENTRY(UNSIGNED)),
4160 .args = ARGS(ARGS_ENTRY
4161 (struct rte_flow_action_set_meta, mask)),
4162 .call = parse_vc_conf,
4164 [ACTION_SET_IPV4_DSCP] = {
4165 .name = "set_ipv4_dscp",
4166 .help = "set DSCP value",
4167 .priv = PRIV_ACTION(SET_IPV4_DSCP,
4168 sizeof(struct rte_flow_action_set_dscp)),
4169 .next = NEXT(action_set_ipv4_dscp),
4172 [ACTION_SET_IPV4_DSCP_VALUE] = {
4173 .name = "dscp_value",
4174 .help = "new IPv4 DSCP value to set",
4175 .next = NEXT(action_set_ipv4_dscp, NEXT_ENTRY(UNSIGNED)),
4176 .args = ARGS(ARGS_ENTRY
4177 (struct rte_flow_action_set_dscp, dscp)),
4178 .call = parse_vc_conf,
4180 [ACTION_SET_IPV6_DSCP] = {
4181 .name = "set_ipv6_dscp",
4182 .help = "set DSCP value",
4183 .priv = PRIV_ACTION(SET_IPV6_DSCP,
4184 sizeof(struct rte_flow_action_set_dscp)),
4185 .next = NEXT(action_set_ipv6_dscp),
4188 [ACTION_SET_IPV6_DSCP_VALUE] = {
4189 .name = "dscp_value",
4190 .help = "new IPv6 DSCP value to set",
4191 .next = NEXT(action_set_ipv6_dscp, NEXT_ENTRY(UNSIGNED)),
4192 .args = ARGS(ARGS_ENTRY
4193 (struct rte_flow_action_set_dscp, dscp)),
4194 .call = parse_vc_conf,
4198 .help = "set a specific metadata header",
4199 .next = NEXT(action_age),
4200 .priv = PRIV_ACTION(AGE,
4201 sizeof(struct rte_flow_action_age)),
4204 [ACTION_AGE_TIMEOUT] = {
4206 .help = "flow age timeout value",
4207 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_age,
4209 .next = NEXT(action_age, NEXT_ENTRY(UNSIGNED)),
4210 .call = parse_vc_conf,
4214 .help = "set a sample action",
4215 .next = NEXT(action_sample),
4216 .priv = PRIV_ACTION(SAMPLE,
4217 sizeof(struct action_sample_data)),
4218 .call = parse_vc_action_sample,
4220 [ACTION_SAMPLE_RATIO] = {
4222 .help = "flow sample ratio value",
4223 .next = NEXT(action_sample, NEXT_ENTRY(UNSIGNED)),
4224 .args = ARGS(ARGS_ENTRY_ARB
4225 (offsetof(struct action_sample_data, conf) +
4226 offsetof(struct rte_flow_action_sample, ratio),
4227 sizeof(((struct rte_flow_action_sample *)0)->
4230 [ACTION_SAMPLE_INDEX] = {
4232 .help = "the index of sample actions list",
4233 .next = NEXT(NEXT_ENTRY(ACTION_SAMPLE_INDEX_VALUE)),
4235 [ACTION_SAMPLE_INDEX_VALUE] = {
4238 .help = "unsigned integer value",
4239 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4240 .call = parse_vc_action_sample_index,
4241 .comp = comp_set_sample_index,
4243 /* Shared action destroy arguments. */
4244 [SHARED_ACTION_DESTROY_ID] = {
4245 .name = "action_id",
4246 .help = "specify a shared action id to destroy",
4247 .next = NEXT(next_sa_destroy_attr,
4248 NEXT_ENTRY(SHARED_ACTION_ID)),
4249 .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
4250 args.sa_destroy.action_id)),
4251 .call = parse_sa_destroy,
4253 /* Shared action create arguments. */
4254 [SHARED_ACTION_CREATE_ID] = {
4255 .name = "action_id",
4256 .help = "specify a shared action id to create",
4257 .next = NEXT(next_sa_create_attr,
4258 NEXT_ENTRY(SHARED_ACTION_ID)),
4259 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
4263 .help = "apply shared action by id",
4264 .priv = PRIV_ACTION(SHARED, 0),
4265 .next = NEXT(NEXT_ENTRY(SHARED_ACTION_ID2PTR)),
4266 .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
4269 [SHARED_ACTION_ID2PTR] = {
4270 .name = "{action_id}",
4271 .type = "SHARED_ACTION_ID",
4272 .help = "shared action id",
4273 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4274 .call = parse_sa_id2ptr,
4277 [SHARED_ACTION_INGRESS] = {
4279 .help = "affect rule to ingress",
4280 .next = NEXT(next_sa_create_attr),
4283 [SHARED_ACTION_EGRESS] = {
4285 .help = "affect rule to egress",
4286 .next = NEXT(next_sa_create_attr),
4289 [SHARED_ACTION_SPEC] = {
4291 .help = "specify action to share",
4292 .next = NEXT(next_action),
4296 /** Remove and return last entry from argument stack. */
4297 static const struct arg *
4298 pop_args(struct context *ctx)
4300 return ctx->args_num ? ctx->args[--ctx->args_num] : NULL;
4303 /** Add entry on top of the argument stack. */
4305 push_args(struct context *ctx, const struct arg *arg)
4307 if (ctx->args_num == CTX_STACK_SIZE)
4309 ctx->args[ctx->args_num++] = arg;
4313 /** Spread value into buffer according to bit-mask. */
4315 arg_entry_bf_fill(void *dst, uintmax_t val, const struct arg *arg)
4317 uint32_t i = arg->size;
4325 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
4334 unsigned int shift = 0;
4335 uint8_t *buf = (uint8_t *)dst + arg->offset + (i -= sub);
4337 for (shift = 0; arg->mask[i] >> shift; ++shift) {
4338 if (!(arg->mask[i] & (1 << shift)))
4343 *buf &= ~(1 << shift);
4344 *buf |= (val & 1) << shift;
4352 /** Compare a string with a partial one of a given length. */
4354 strcmp_partial(const char *full, const char *partial, size_t partial_len)
4356 int r = strncmp(full, partial, partial_len);
4360 if (strlen(full) <= partial_len)
4362 return full[partial_len];
4366 * Parse a prefix length and generate a bit-mask.
4368 * Last argument (ctx->args) is retrieved to determine mask size, storage
4369 * location and whether the result must use network byte ordering.
4372 parse_prefix(struct context *ctx, const struct token *token,
4373 const char *str, unsigned int len,
4374 void *buf, unsigned int size)
4376 const struct arg *arg = pop_args(ctx);
4377 static const uint8_t conv[] = "\x00\x80\xc0\xe0\xf0\xf8\xfc\xfe\xff";
4384 /* Argument is expected. */
4388 u = strtoumax(str, &end, 0);
4389 if (errno || (size_t)(end - str) != len)
4394 extra = arg_entry_bf_fill(NULL, 0, arg);
4403 if (!arg_entry_bf_fill(ctx->object, v, arg) ||
4404 !arg_entry_bf_fill(ctx->objmask, -1, arg))
4411 if (bytes > size || bytes + !!extra > size)
4415 buf = (uint8_t *)ctx->object + arg->offset;
4416 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
4418 memset((uint8_t *)buf + size - bytes, 0xff, bytes);
4419 memset(buf, 0x00, size - bytes);
4421 ((uint8_t *)buf)[size - bytes - 1] = conv[extra];
4425 memset(buf, 0xff, bytes);
4426 memset((uint8_t *)buf + bytes, 0x00, size - bytes);
4428 ((uint8_t *)buf)[bytes] = conv[extra];
4431 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
4434 push_args(ctx, arg);
4438 /** Default parsing function for token name matching. */
4440 parse_default(struct context *ctx, const struct token *token,
4441 const char *str, unsigned int len,
4442 void *buf, unsigned int size)
4447 if (strcmp_partial(token->name, str, len))
4452 /** Parse flow command, initialize output buffer for subsequent tokens. */
4454 parse_init(struct context *ctx, const struct token *token,
4455 const char *str, unsigned int len,
4456 void *buf, unsigned int size)
4458 struct buffer *out = buf;
4460 /* Token name must match. */
4461 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4463 /* Nothing else to do if there is no buffer. */
4466 /* Make sure buffer is large enough. */
4467 if (size < sizeof(*out))
4469 /* Initialize buffer. */
4470 memset(out, 0x00, sizeof(*out));
4471 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
4474 ctx->objmask = NULL;
4478 /** Parse tokens for shared action commands. */
4480 parse_sa(struct context *ctx, const struct token *token,
4481 const char *str, unsigned int len,
4482 void *buf, unsigned int size)
4484 struct buffer *out = buf;
4486 /* Token name must match. */
4487 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4489 /* Nothing else to do if there is no buffer. */
4492 if (!out->command) {
4493 if (ctx->curr != SHARED_ACTION)
4495 if (sizeof(*out) > size)
4497 out->command = ctx->curr;
4500 ctx->objmask = NULL;
4501 out->args.vc.data = (uint8_t *)out + size;
4504 switch (ctx->curr) {
4505 case SHARED_ACTION_CREATE:
4506 case SHARED_ACTION_UPDATE:
4507 out->args.vc.actions =
4508 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
4510 out->args.vc.attr.group = UINT32_MAX;
4512 case SHARED_ACTION_QUERY:
4513 out->command = ctx->curr;
4516 ctx->objmask = NULL;
4518 case SHARED_ACTION_EGRESS:
4519 out->args.vc.attr.egress = 1;
4521 case SHARED_ACTION_INGRESS:
4522 out->args.vc.attr.ingress = 1;
4530 /** Parse tokens for shared action destroy command. */
4532 parse_sa_destroy(struct context *ctx, const struct token *token,
4533 const char *str, unsigned int len,
4534 void *buf, unsigned int size)
4536 struct buffer *out = buf;
4537 uint32_t *action_id;
4539 /* Token name must match. */
4540 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4542 /* Nothing else to do if there is no buffer. */
4545 if (!out->command || out->command == SHARED_ACTION) {
4546 if (ctx->curr != SHARED_ACTION_DESTROY)
4548 if (sizeof(*out) > size)
4550 out->command = ctx->curr;
4553 ctx->objmask = NULL;
4554 out->args.sa_destroy.action_id =
4555 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
4559 action_id = out->args.sa_destroy.action_id
4560 + out->args.sa_destroy.action_id_n++;
4561 if ((uint8_t *)action_id > (uint8_t *)out + size)
4564 ctx->object = action_id;
4565 ctx->objmask = NULL;
4569 /** Parse tokens for validate/create commands. */
4571 parse_vc(struct context *ctx, const struct token *token,
4572 const char *str, unsigned int len,
4573 void *buf, unsigned int size)
4575 struct buffer *out = buf;
4579 /* Token name must match. */
4580 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4582 /* Nothing else to do if there is no buffer. */
4585 if (!out->command) {
4586 if (ctx->curr != VALIDATE && ctx->curr != CREATE)
4588 if (sizeof(*out) > size)
4590 out->command = ctx->curr;
4593 ctx->objmask = NULL;
4594 out->args.vc.data = (uint8_t *)out + size;
4598 switch (ctx->curr) {
4600 ctx->object = &out->args.vc.attr;
4604 ctx->object = &out->args.vc.tunnel_ops;
4607 ctx->objmask = NULL;
4608 switch (ctx->curr) {
4613 out->args.vc.tunnel_ops.enabled = 1;
4614 out->args.vc.tunnel_ops.actions = 1;
4617 out->args.vc.tunnel_ops.enabled = 1;
4618 out->args.vc.tunnel_ops.items = 1;
4621 out->args.vc.attr.ingress = 1;
4624 out->args.vc.attr.egress = 1;
4627 out->args.vc.attr.transfer = 1;
4630 out->args.vc.pattern =
4631 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
4633 ctx->object = out->args.vc.pattern;
4634 ctx->objmask = NULL;
4637 out->args.vc.actions =
4638 (void *)RTE_ALIGN_CEIL((uintptr_t)
4639 (out->args.vc.pattern +
4640 out->args.vc.pattern_n),
4642 ctx->object = out->args.vc.actions;
4643 ctx->objmask = NULL;
4650 if (!out->args.vc.actions) {
4651 const struct parse_item_priv *priv = token->priv;
4652 struct rte_flow_item *item =
4653 out->args.vc.pattern + out->args.vc.pattern_n;
4655 data_size = priv->size * 3; /* spec, last, mask */
4656 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
4657 (out->args.vc.data - data_size),
4659 if ((uint8_t *)item + sizeof(*item) > data)
4661 *item = (struct rte_flow_item){
4664 ++out->args.vc.pattern_n;
4666 ctx->objmask = NULL;
4668 const struct parse_action_priv *priv = token->priv;
4669 struct rte_flow_action *action =
4670 out->args.vc.actions + out->args.vc.actions_n;
4672 data_size = priv->size; /* configuration */
4673 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
4674 (out->args.vc.data - data_size),
4676 if ((uint8_t *)action + sizeof(*action) > data)
4678 *action = (struct rte_flow_action){
4680 .conf = data_size ? data : NULL,
4682 ++out->args.vc.actions_n;
4683 ctx->object = action;
4684 ctx->objmask = NULL;
4686 memset(data, 0, data_size);
4687 out->args.vc.data = data;
4688 ctx->objdata = data_size;
4692 /** Parse pattern item parameter type. */
4694 parse_vc_spec(struct context *ctx, const struct token *token,
4695 const char *str, unsigned int len,
4696 void *buf, unsigned int size)
4698 struct buffer *out = buf;
4699 struct rte_flow_item *item;
4705 /* Token name must match. */
4706 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4708 /* Parse parameter types. */
4709 switch (ctx->curr) {
4710 static const enum index prefix[] = NEXT_ENTRY(PREFIX);
4716 case ITEM_PARAM_SPEC:
4719 case ITEM_PARAM_LAST:
4722 case ITEM_PARAM_PREFIX:
4723 /* Modify next token to expect a prefix. */
4724 if (ctx->next_num < 2)
4726 ctx->next[ctx->next_num - 2] = prefix;
4728 case ITEM_PARAM_MASK:
4734 /* Nothing else to do if there is no buffer. */
4737 if (!out->args.vc.pattern_n)
4739 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
4740 data_size = ctx->objdata / 3; /* spec, last, mask */
4741 /* Point to selected object. */
4742 ctx->object = out->args.vc.data + (data_size * index);
4744 ctx->objmask = out->args.vc.data + (data_size * 2); /* mask */
4745 item->mask = ctx->objmask;
4747 ctx->objmask = NULL;
4748 /* Update relevant item pointer. */
4749 *((const void **[]){ &item->spec, &item->last, &item->mask })[index] =
4754 /** Parse action configuration field. */
4756 parse_vc_conf(struct context *ctx, const struct token *token,
4757 const char *str, unsigned int len,
4758 void *buf, unsigned int size)
4760 struct buffer *out = buf;
4763 /* Token name must match. */
4764 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4766 /* Nothing else to do if there is no buffer. */
4769 /* Point to selected object. */
4770 ctx->object = out->args.vc.data;
4771 ctx->objmask = NULL;
4775 /** Parse eCPRI common header type field. */
4777 parse_vc_item_ecpri_type(struct context *ctx, const struct token *token,
4778 const char *str, unsigned int len,
4779 void *buf, unsigned int size)
4781 struct rte_flow_item_ecpri *ecpri;
4782 struct rte_flow_item_ecpri *ecpri_mask;
4783 struct rte_flow_item *item;
4786 struct buffer *out = buf;
4787 const struct arg *arg;
4790 /* Token name must match. */
4791 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4793 switch (ctx->curr) {
4794 case ITEM_ECPRI_COMMON_TYPE_IQ_DATA:
4795 msg_type = RTE_ECPRI_MSG_TYPE_IQ_DATA;
4797 case ITEM_ECPRI_COMMON_TYPE_RTC_CTRL:
4798 msg_type = RTE_ECPRI_MSG_TYPE_RTC_CTRL;
4800 case ITEM_ECPRI_COMMON_TYPE_DLY_MSR:
4801 msg_type = RTE_ECPRI_MSG_TYPE_DLY_MSR;
4808 arg = pop_args(ctx);
4811 ecpri = (struct rte_flow_item_ecpri *)out->args.vc.data;
4812 ecpri->hdr.common.type = msg_type;
4813 data_size = ctx->objdata / 3; /* spec, last, mask */
4814 ecpri_mask = (struct rte_flow_item_ecpri *)(out->args.vc.data +
4816 ecpri_mask->hdr.common.type = 0xFF;
4818 ecpri->hdr.common.u32 = rte_cpu_to_be_32(ecpri->hdr.common.u32);
4819 ecpri_mask->hdr.common.u32 =
4820 rte_cpu_to_be_32(ecpri_mask->hdr.common.u32);
4822 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
4824 item->mask = ecpri_mask;
4828 /** Parse RSS action. */
4830 parse_vc_action_rss(struct context *ctx, const struct token *token,
4831 const char *str, unsigned int len,
4832 void *buf, unsigned int size)
4834 struct buffer *out = buf;
4835 struct rte_flow_action *action;
4836 struct action_rss_data *action_rss_data;
4840 ret = parse_vc(ctx, token, str, len, buf, size);
4843 /* Nothing else to do if there is no buffer. */
4846 if (!out->args.vc.actions_n)
4848 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4849 /* Point to selected object. */
4850 ctx->object = out->args.vc.data;
4851 ctx->objmask = NULL;
4852 /* Set up default configuration. */
4853 action_rss_data = ctx->object;
4854 *action_rss_data = (struct action_rss_data){
4855 .conf = (struct rte_flow_action_rss){
4856 .func = RTE_ETH_HASH_FUNCTION_DEFAULT,
4860 .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM),
4862 .queue = action_rss_data->queue,
4866 for (i = 0; i < action_rss_data->conf.queue_num; ++i)
4867 action_rss_data->queue[i] = i;
4868 action->conf = &action_rss_data->conf;
4873 * Parse func field for RSS action.
4875 * The RTE_ETH_HASH_FUNCTION_* value to assign is derived from the
4876 * ACTION_RSS_FUNC_* index that called this function.
4879 parse_vc_action_rss_func(struct context *ctx, const struct token *token,
4880 const char *str, unsigned int len,
4881 void *buf, unsigned int size)
4883 struct action_rss_data *action_rss_data;
4884 enum rte_eth_hash_function func;
4888 /* Token name must match. */
4889 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4891 switch (ctx->curr) {
4892 case ACTION_RSS_FUNC_DEFAULT:
4893 func = RTE_ETH_HASH_FUNCTION_DEFAULT;
4895 case ACTION_RSS_FUNC_TOEPLITZ:
4896 func = RTE_ETH_HASH_FUNCTION_TOEPLITZ;
4898 case ACTION_RSS_FUNC_SIMPLE_XOR:
4899 func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
4901 case ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ:
4902 func = RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
4909 action_rss_data = ctx->object;
4910 action_rss_data->conf.func = func;
4915 * Parse type field for RSS action.
4917 * Valid tokens are type field names and the "end" token.
4920 parse_vc_action_rss_type(struct context *ctx, const struct token *token,
4921 const char *str, unsigned int len,
4922 void *buf, unsigned int size)
4924 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE);
4925 struct action_rss_data *action_rss_data;
4931 if (ctx->curr != ACTION_RSS_TYPE)
4933 if (!(ctx->objdata >> 16) && ctx->object) {
4934 action_rss_data = ctx->object;
4935 action_rss_data->conf.types = 0;
4937 if (!strcmp_partial("end", str, len)) {
4938 ctx->objdata &= 0xffff;
4941 for (i = 0; rss_type_table[i].str; ++i)
4942 if (!strcmp_partial(rss_type_table[i].str, str, len))
4944 if (!rss_type_table[i].str)
4946 ctx->objdata = 1 << 16 | (ctx->objdata & 0xffff);
4948 if (ctx->next_num == RTE_DIM(ctx->next))
4950 ctx->next[ctx->next_num++] = next;
4953 action_rss_data = ctx->object;
4954 action_rss_data->conf.types |= rss_type_table[i].rss_type;
4959 * Parse queue field for RSS action.
4961 * Valid tokens are queue indices and the "end" token.
4964 parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
4965 const char *str, unsigned int len,
4966 void *buf, unsigned int size)
4968 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE);
4969 struct action_rss_data *action_rss_data;
4970 const struct arg *arg;
4977 if (ctx->curr != ACTION_RSS_QUEUE)
4979 i = ctx->objdata >> 16;
4980 if (!strcmp_partial("end", str, len)) {
4981 ctx->objdata &= 0xffff;
4984 if (i >= ACTION_RSS_QUEUE_NUM)
4986 arg = ARGS_ENTRY_ARB(offsetof(struct action_rss_data, queue) +
4987 i * sizeof(action_rss_data->queue[i]),
4988 sizeof(action_rss_data->queue[i]));
4989 if (push_args(ctx, arg))
4991 ret = parse_int(ctx, token, str, len, NULL, 0);
4997 ctx->objdata = i << 16 | (ctx->objdata & 0xffff);
4999 if (ctx->next_num == RTE_DIM(ctx->next))
5001 ctx->next[ctx->next_num++] = next;
5005 action_rss_data = ctx->object;
5006 action_rss_data->conf.queue_num = i;
5007 action_rss_data->conf.queue = i ? action_rss_data->queue : NULL;
5011 /** Parse VXLAN encap action. */
5013 parse_vc_action_vxlan_encap(struct context *ctx, const struct token *token,
5014 const char *str, unsigned int len,
5015 void *buf, unsigned int size)
5017 struct buffer *out = buf;
5018 struct rte_flow_action *action;
5019 struct action_vxlan_encap_data *action_vxlan_encap_data;
5022 ret = parse_vc(ctx, token, str, len, buf, size);
5025 /* Nothing else to do if there is no buffer. */
5028 if (!out->args.vc.actions_n)
5030 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5031 /* Point to selected object. */
5032 ctx->object = out->args.vc.data;
5033 ctx->objmask = NULL;
5034 /* Set up default configuration. */
5035 action_vxlan_encap_data = ctx->object;
5036 *action_vxlan_encap_data = (struct action_vxlan_encap_data){
5037 .conf = (struct rte_flow_action_vxlan_encap){
5038 .definition = action_vxlan_encap_data->items,
5042 .type = RTE_FLOW_ITEM_TYPE_ETH,
5043 .spec = &action_vxlan_encap_data->item_eth,
5044 .mask = &rte_flow_item_eth_mask,
5047 .type = RTE_FLOW_ITEM_TYPE_VLAN,
5048 .spec = &action_vxlan_encap_data->item_vlan,
5049 .mask = &rte_flow_item_vlan_mask,
5052 .type = RTE_FLOW_ITEM_TYPE_IPV4,
5053 .spec = &action_vxlan_encap_data->item_ipv4,
5054 .mask = &rte_flow_item_ipv4_mask,
5057 .type = RTE_FLOW_ITEM_TYPE_UDP,
5058 .spec = &action_vxlan_encap_data->item_udp,
5059 .mask = &rte_flow_item_udp_mask,
5062 .type = RTE_FLOW_ITEM_TYPE_VXLAN,
5063 .spec = &action_vxlan_encap_data->item_vxlan,
5064 .mask = &rte_flow_item_vxlan_mask,
5067 .type = RTE_FLOW_ITEM_TYPE_END,
5072 .tci = vxlan_encap_conf.vlan_tci,
5076 .src_addr = vxlan_encap_conf.ipv4_src,
5077 .dst_addr = vxlan_encap_conf.ipv4_dst,
5080 .src_port = vxlan_encap_conf.udp_src,
5081 .dst_port = vxlan_encap_conf.udp_dst,
5083 .item_vxlan.flags = 0,
5085 memcpy(action_vxlan_encap_data->item_eth.dst.addr_bytes,
5086 vxlan_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5087 memcpy(action_vxlan_encap_data->item_eth.src.addr_bytes,
5088 vxlan_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5089 if (!vxlan_encap_conf.select_ipv4) {
5090 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.src_addr,
5091 &vxlan_encap_conf.ipv6_src,
5092 sizeof(vxlan_encap_conf.ipv6_src));
5093 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.dst_addr,
5094 &vxlan_encap_conf.ipv6_dst,
5095 sizeof(vxlan_encap_conf.ipv6_dst));
5096 action_vxlan_encap_data->items[2] = (struct rte_flow_item){
5097 .type = RTE_FLOW_ITEM_TYPE_IPV6,
5098 .spec = &action_vxlan_encap_data->item_ipv6,
5099 .mask = &rte_flow_item_ipv6_mask,
5102 if (!vxlan_encap_conf.select_vlan)
5103 action_vxlan_encap_data->items[1].type =
5104 RTE_FLOW_ITEM_TYPE_VOID;
5105 if (vxlan_encap_conf.select_tos_ttl) {
5106 if (vxlan_encap_conf.select_ipv4) {
5107 static struct rte_flow_item_ipv4 ipv4_mask_tos;
5109 memcpy(&ipv4_mask_tos, &rte_flow_item_ipv4_mask,
5110 sizeof(ipv4_mask_tos));
5111 ipv4_mask_tos.hdr.type_of_service = 0xff;
5112 ipv4_mask_tos.hdr.time_to_live = 0xff;
5113 action_vxlan_encap_data->item_ipv4.hdr.type_of_service =
5114 vxlan_encap_conf.ip_tos;
5115 action_vxlan_encap_data->item_ipv4.hdr.time_to_live =
5116 vxlan_encap_conf.ip_ttl;
5117 action_vxlan_encap_data->items[2].mask =
5120 static struct rte_flow_item_ipv6 ipv6_mask_tos;
5122 memcpy(&ipv6_mask_tos, &rte_flow_item_ipv6_mask,
5123 sizeof(ipv6_mask_tos));
5124 ipv6_mask_tos.hdr.vtc_flow |=
5125 RTE_BE32(0xfful << RTE_IPV6_HDR_TC_SHIFT);
5126 ipv6_mask_tos.hdr.hop_limits = 0xff;
5127 action_vxlan_encap_data->item_ipv6.hdr.vtc_flow |=
5129 ((uint32_t)vxlan_encap_conf.ip_tos <<
5130 RTE_IPV6_HDR_TC_SHIFT);
5131 action_vxlan_encap_data->item_ipv6.hdr.hop_limits =
5132 vxlan_encap_conf.ip_ttl;
5133 action_vxlan_encap_data->items[2].mask =
5137 memcpy(action_vxlan_encap_data->item_vxlan.vni, vxlan_encap_conf.vni,
5138 RTE_DIM(vxlan_encap_conf.vni));
5139 action->conf = &action_vxlan_encap_data->conf;
5143 /** Parse NVGRE encap action. */
5145 parse_vc_action_nvgre_encap(struct context *ctx, const struct token *token,
5146 const char *str, unsigned int len,
5147 void *buf, unsigned int size)
5149 struct buffer *out = buf;
5150 struct rte_flow_action *action;
5151 struct action_nvgre_encap_data *action_nvgre_encap_data;
5154 ret = parse_vc(ctx, token, str, len, buf, size);
5157 /* Nothing else to do if there is no buffer. */
5160 if (!out->args.vc.actions_n)
5162 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5163 /* Point to selected object. */
5164 ctx->object = out->args.vc.data;
5165 ctx->objmask = NULL;
5166 /* Set up default configuration. */
5167 action_nvgre_encap_data = ctx->object;
5168 *action_nvgre_encap_data = (struct action_nvgre_encap_data){
5169 .conf = (struct rte_flow_action_nvgre_encap){
5170 .definition = action_nvgre_encap_data->items,
5174 .type = RTE_FLOW_ITEM_TYPE_ETH,
5175 .spec = &action_nvgre_encap_data->item_eth,
5176 .mask = &rte_flow_item_eth_mask,
5179 .type = RTE_FLOW_ITEM_TYPE_VLAN,
5180 .spec = &action_nvgre_encap_data->item_vlan,
5181 .mask = &rte_flow_item_vlan_mask,
5184 .type = RTE_FLOW_ITEM_TYPE_IPV4,
5185 .spec = &action_nvgre_encap_data->item_ipv4,
5186 .mask = &rte_flow_item_ipv4_mask,
5189 .type = RTE_FLOW_ITEM_TYPE_NVGRE,
5190 .spec = &action_nvgre_encap_data->item_nvgre,
5191 .mask = &rte_flow_item_nvgre_mask,
5194 .type = RTE_FLOW_ITEM_TYPE_END,
5199 .tci = nvgre_encap_conf.vlan_tci,
5203 .src_addr = nvgre_encap_conf.ipv4_src,
5204 .dst_addr = nvgre_encap_conf.ipv4_dst,
5206 .item_nvgre.flow_id = 0,
5208 memcpy(action_nvgre_encap_data->item_eth.dst.addr_bytes,
5209 nvgre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5210 memcpy(action_nvgre_encap_data->item_eth.src.addr_bytes,
5211 nvgre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5212 if (!nvgre_encap_conf.select_ipv4) {
5213 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.src_addr,
5214 &nvgre_encap_conf.ipv6_src,
5215 sizeof(nvgre_encap_conf.ipv6_src));
5216 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.dst_addr,
5217 &nvgre_encap_conf.ipv6_dst,
5218 sizeof(nvgre_encap_conf.ipv6_dst));
5219 action_nvgre_encap_data->items[2] = (struct rte_flow_item){
5220 .type = RTE_FLOW_ITEM_TYPE_IPV6,
5221 .spec = &action_nvgre_encap_data->item_ipv6,
5222 .mask = &rte_flow_item_ipv6_mask,
5225 if (!nvgre_encap_conf.select_vlan)
5226 action_nvgre_encap_data->items[1].type =
5227 RTE_FLOW_ITEM_TYPE_VOID;
5228 memcpy(action_nvgre_encap_data->item_nvgre.tni, nvgre_encap_conf.tni,
5229 RTE_DIM(nvgre_encap_conf.tni));
5230 action->conf = &action_nvgre_encap_data->conf;
5234 /** Parse l2 encap action. */
5236 parse_vc_action_l2_encap(struct context *ctx, const struct token *token,
5237 const char *str, unsigned int len,
5238 void *buf, unsigned int size)
5240 struct buffer *out = buf;
5241 struct rte_flow_action *action;
5242 struct action_raw_encap_data *action_encap_data;
5243 struct rte_flow_item_eth eth = { .type = 0, };
5244 struct rte_flow_item_vlan vlan = {
5245 .tci = mplsoudp_encap_conf.vlan_tci,
5251 ret = parse_vc(ctx, token, str, len, buf, size);
5254 /* Nothing else to do if there is no buffer. */
5257 if (!out->args.vc.actions_n)
5259 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5260 /* Point to selected object. */
5261 ctx->object = out->args.vc.data;
5262 ctx->objmask = NULL;
5263 /* Copy the headers to the buffer. */
5264 action_encap_data = ctx->object;
5265 *action_encap_data = (struct action_raw_encap_data) {
5266 .conf = (struct rte_flow_action_raw_encap){
5267 .data = action_encap_data->data,
5271 header = action_encap_data->data;
5272 if (l2_encap_conf.select_vlan)
5273 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5274 else if (l2_encap_conf.select_ipv4)
5275 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5277 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5278 memcpy(eth.dst.addr_bytes,
5279 l2_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5280 memcpy(eth.src.addr_bytes,
5281 l2_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5282 memcpy(header, ð, sizeof(eth));
5283 header += sizeof(eth);
5284 if (l2_encap_conf.select_vlan) {
5285 if (l2_encap_conf.select_ipv4)
5286 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5288 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5289 memcpy(header, &vlan, sizeof(vlan));
5290 header += sizeof(vlan);
5292 action_encap_data->conf.size = header -
5293 action_encap_data->data;
5294 action->conf = &action_encap_data->conf;
5298 /** Parse l2 decap action. */
5300 parse_vc_action_l2_decap(struct context *ctx, const struct token *token,
5301 const char *str, unsigned int len,
5302 void *buf, unsigned int size)
5304 struct buffer *out = buf;
5305 struct rte_flow_action *action;
5306 struct action_raw_decap_data *action_decap_data;
5307 struct rte_flow_item_eth eth = { .type = 0, };
5308 struct rte_flow_item_vlan vlan = {
5309 .tci = mplsoudp_encap_conf.vlan_tci,
5315 ret = parse_vc(ctx, token, str, len, buf, size);
5318 /* Nothing else to do if there is no buffer. */
5321 if (!out->args.vc.actions_n)
5323 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5324 /* Point to selected object. */
5325 ctx->object = out->args.vc.data;
5326 ctx->objmask = NULL;
5327 /* Copy the headers to the buffer. */
5328 action_decap_data = ctx->object;
5329 *action_decap_data = (struct action_raw_decap_data) {
5330 .conf = (struct rte_flow_action_raw_decap){
5331 .data = action_decap_data->data,
5335 header = action_decap_data->data;
5336 if (l2_decap_conf.select_vlan)
5337 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5338 memcpy(header, ð, sizeof(eth));
5339 header += sizeof(eth);
5340 if (l2_decap_conf.select_vlan) {
5341 memcpy(header, &vlan, sizeof(vlan));
5342 header += sizeof(vlan);
5344 action_decap_data->conf.size = header -
5345 action_decap_data->data;
5346 action->conf = &action_decap_data->conf;
5350 #define ETHER_TYPE_MPLS_UNICAST 0x8847
5352 /** Parse MPLSOGRE encap action. */
5354 parse_vc_action_mplsogre_encap(struct context *ctx, const struct token *token,
5355 const char *str, unsigned int len,
5356 void *buf, unsigned int size)
5358 struct buffer *out = buf;
5359 struct rte_flow_action *action;
5360 struct action_raw_encap_data *action_encap_data;
5361 struct rte_flow_item_eth eth = { .type = 0, };
5362 struct rte_flow_item_vlan vlan = {
5363 .tci = mplsogre_encap_conf.vlan_tci,
5366 struct rte_flow_item_ipv4 ipv4 = {
5368 .src_addr = mplsogre_encap_conf.ipv4_src,
5369 .dst_addr = mplsogre_encap_conf.ipv4_dst,
5370 .next_proto_id = IPPROTO_GRE,
5371 .version_ihl = RTE_IPV4_VHL_DEF,
5372 .time_to_live = IPDEFTTL,
5375 struct rte_flow_item_ipv6 ipv6 = {
5377 .proto = IPPROTO_GRE,
5378 .hop_limits = IPDEFTTL,
5381 struct rte_flow_item_gre gre = {
5382 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
5384 struct rte_flow_item_mpls mpls = {
5390 ret = parse_vc(ctx, token, str, len, buf, size);
5393 /* Nothing else to do if there is no buffer. */
5396 if (!out->args.vc.actions_n)
5398 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5399 /* Point to selected object. */
5400 ctx->object = out->args.vc.data;
5401 ctx->objmask = NULL;
5402 /* Copy the headers to the buffer. */
5403 action_encap_data = ctx->object;
5404 *action_encap_data = (struct action_raw_encap_data) {
5405 .conf = (struct rte_flow_action_raw_encap){
5406 .data = action_encap_data->data,
5411 header = action_encap_data->data;
5412 if (mplsogre_encap_conf.select_vlan)
5413 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5414 else if (mplsogre_encap_conf.select_ipv4)
5415 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5417 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5418 memcpy(eth.dst.addr_bytes,
5419 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5420 memcpy(eth.src.addr_bytes,
5421 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5422 memcpy(header, ð, sizeof(eth));
5423 header += sizeof(eth);
5424 if (mplsogre_encap_conf.select_vlan) {
5425 if (mplsogre_encap_conf.select_ipv4)
5426 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5428 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5429 memcpy(header, &vlan, sizeof(vlan));
5430 header += sizeof(vlan);
5432 if (mplsogre_encap_conf.select_ipv4) {
5433 memcpy(header, &ipv4, sizeof(ipv4));
5434 header += sizeof(ipv4);
5436 memcpy(&ipv6.hdr.src_addr,
5437 &mplsogre_encap_conf.ipv6_src,
5438 sizeof(mplsogre_encap_conf.ipv6_src));
5439 memcpy(&ipv6.hdr.dst_addr,
5440 &mplsogre_encap_conf.ipv6_dst,
5441 sizeof(mplsogre_encap_conf.ipv6_dst));
5442 memcpy(header, &ipv6, sizeof(ipv6));
5443 header += sizeof(ipv6);
5445 memcpy(header, &gre, sizeof(gre));
5446 header += sizeof(gre);
5447 memcpy(mpls.label_tc_s, mplsogre_encap_conf.label,
5448 RTE_DIM(mplsogre_encap_conf.label));
5449 mpls.label_tc_s[2] |= 0x1;
5450 memcpy(header, &mpls, sizeof(mpls));
5451 header += sizeof(mpls);
5452 action_encap_data->conf.size = header -
5453 action_encap_data->data;
5454 action->conf = &action_encap_data->conf;
5458 /** Parse MPLSOGRE decap action. */
5460 parse_vc_action_mplsogre_decap(struct context *ctx, const struct token *token,
5461 const char *str, unsigned int len,
5462 void *buf, unsigned int size)
5464 struct buffer *out = buf;
5465 struct rte_flow_action *action;
5466 struct action_raw_decap_data *action_decap_data;
5467 struct rte_flow_item_eth eth = { .type = 0, };
5468 struct rte_flow_item_vlan vlan = {.tci = 0};
5469 struct rte_flow_item_ipv4 ipv4 = {
5471 .next_proto_id = IPPROTO_GRE,
5474 struct rte_flow_item_ipv6 ipv6 = {
5476 .proto = IPPROTO_GRE,
5479 struct rte_flow_item_gre gre = {
5480 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
5482 struct rte_flow_item_mpls mpls;
5486 ret = parse_vc(ctx, token, str, len, buf, size);
5489 /* Nothing else to do if there is no buffer. */
5492 if (!out->args.vc.actions_n)
5494 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5495 /* Point to selected object. */
5496 ctx->object = out->args.vc.data;
5497 ctx->objmask = NULL;
5498 /* Copy the headers to the buffer. */
5499 action_decap_data = ctx->object;
5500 *action_decap_data = (struct action_raw_decap_data) {
5501 .conf = (struct rte_flow_action_raw_decap){
5502 .data = action_decap_data->data,
5506 header = action_decap_data->data;
5507 if (mplsogre_decap_conf.select_vlan)
5508 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5509 else if (mplsogre_encap_conf.select_ipv4)
5510 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5512 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5513 memcpy(eth.dst.addr_bytes,
5514 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5515 memcpy(eth.src.addr_bytes,
5516 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5517 memcpy(header, ð, sizeof(eth));
5518 header += sizeof(eth);
5519 if (mplsogre_encap_conf.select_vlan) {
5520 if (mplsogre_encap_conf.select_ipv4)
5521 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5523 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5524 memcpy(header, &vlan, sizeof(vlan));
5525 header += sizeof(vlan);
5527 if (mplsogre_encap_conf.select_ipv4) {
5528 memcpy(header, &ipv4, sizeof(ipv4));
5529 header += sizeof(ipv4);
5531 memcpy(header, &ipv6, sizeof(ipv6));
5532 header += sizeof(ipv6);
5534 memcpy(header, &gre, sizeof(gre));
5535 header += sizeof(gre);
5536 memset(&mpls, 0, sizeof(mpls));
5537 memcpy(header, &mpls, sizeof(mpls));
5538 header += sizeof(mpls);
5539 action_decap_data->conf.size = header -
5540 action_decap_data->data;
5541 action->conf = &action_decap_data->conf;
5545 /** Parse MPLSOUDP encap action. */
5547 parse_vc_action_mplsoudp_encap(struct context *ctx, const struct token *token,
5548 const char *str, unsigned int len,
5549 void *buf, unsigned int size)
5551 struct buffer *out = buf;
5552 struct rte_flow_action *action;
5553 struct action_raw_encap_data *action_encap_data;
5554 struct rte_flow_item_eth eth = { .type = 0, };
5555 struct rte_flow_item_vlan vlan = {
5556 .tci = mplsoudp_encap_conf.vlan_tci,
5559 struct rte_flow_item_ipv4 ipv4 = {
5561 .src_addr = mplsoudp_encap_conf.ipv4_src,
5562 .dst_addr = mplsoudp_encap_conf.ipv4_dst,
5563 .next_proto_id = IPPROTO_UDP,
5564 .version_ihl = RTE_IPV4_VHL_DEF,
5565 .time_to_live = IPDEFTTL,
5568 struct rte_flow_item_ipv6 ipv6 = {
5570 .proto = IPPROTO_UDP,
5571 .hop_limits = IPDEFTTL,
5574 struct rte_flow_item_udp udp = {
5576 .src_port = mplsoudp_encap_conf.udp_src,
5577 .dst_port = mplsoudp_encap_conf.udp_dst,
5580 struct rte_flow_item_mpls mpls;
5584 ret = parse_vc(ctx, token, str, len, buf, size);
5587 /* Nothing else to do if there is no buffer. */
5590 if (!out->args.vc.actions_n)
5592 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5593 /* Point to selected object. */
5594 ctx->object = out->args.vc.data;
5595 ctx->objmask = NULL;
5596 /* Copy the headers to the buffer. */
5597 action_encap_data = ctx->object;
5598 *action_encap_data = (struct action_raw_encap_data) {
5599 .conf = (struct rte_flow_action_raw_encap){
5600 .data = action_encap_data->data,
5605 header = action_encap_data->data;
5606 if (mplsoudp_encap_conf.select_vlan)
5607 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5608 else if (mplsoudp_encap_conf.select_ipv4)
5609 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5611 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5612 memcpy(eth.dst.addr_bytes,
5613 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5614 memcpy(eth.src.addr_bytes,
5615 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5616 memcpy(header, ð, sizeof(eth));
5617 header += sizeof(eth);
5618 if (mplsoudp_encap_conf.select_vlan) {
5619 if (mplsoudp_encap_conf.select_ipv4)
5620 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5622 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5623 memcpy(header, &vlan, sizeof(vlan));
5624 header += sizeof(vlan);
5626 if (mplsoudp_encap_conf.select_ipv4) {
5627 memcpy(header, &ipv4, sizeof(ipv4));
5628 header += sizeof(ipv4);
5630 memcpy(&ipv6.hdr.src_addr,
5631 &mplsoudp_encap_conf.ipv6_src,
5632 sizeof(mplsoudp_encap_conf.ipv6_src));
5633 memcpy(&ipv6.hdr.dst_addr,
5634 &mplsoudp_encap_conf.ipv6_dst,
5635 sizeof(mplsoudp_encap_conf.ipv6_dst));
5636 memcpy(header, &ipv6, sizeof(ipv6));
5637 header += sizeof(ipv6);
5639 memcpy(header, &udp, sizeof(udp));
5640 header += sizeof(udp);
5641 memcpy(mpls.label_tc_s, mplsoudp_encap_conf.label,
5642 RTE_DIM(mplsoudp_encap_conf.label));
5643 mpls.label_tc_s[2] |= 0x1;
5644 memcpy(header, &mpls, sizeof(mpls));
5645 header += sizeof(mpls);
5646 action_encap_data->conf.size = header -
5647 action_encap_data->data;
5648 action->conf = &action_encap_data->conf;
5652 /** Parse MPLSOUDP decap action. */
5654 parse_vc_action_mplsoudp_decap(struct context *ctx, const struct token *token,
5655 const char *str, unsigned int len,
5656 void *buf, unsigned int size)
5658 struct buffer *out = buf;
5659 struct rte_flow_action *action;
5660 struct action_raw_decap_data *action_decap_data;
5661 struct rte_flow_item_eth eth = { .type = 0, };
5662 struct rte_flow_item_vlan vlan = {.tci = 0};
5663 struct rte_flow_item_ipv4 ipv4 = {
5665 .next_proto_id = IPPROTO_UDP,
5668 struct rte_flow_item_ipv6 ipv6 = {
5670 .proto = IPPROTO_UDP,
5673 struct rte_flow_item_udp udp = {
5675 .dst_port = rte_cpu_to_be_16(6635),
5678 struct rte_flow_item_mpls mpls;
5682 ret = parse_vc(ctx, token, str, len, buf, size);
5685 /* Nothing else to do if there is no buffer. */
5688 if (!out->args.vc.actions_n)
5690 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5691 /* Point to selected object. */
5692 ctx->object = out->args.vc.data;
5693 ctx->objmask = NULL;
5694 /* Copy the headers to the buffer. */
5695 action_decap_data = ctx->object;
5696 *action_decap_data = (struct action_raw_decap_data) {
5697 .conf = (struct rte_flow_action_raw_decap){
5698 .data = action_decap_data->data,
5702 header = action_decap_data->data;
5703 if (mplsoudp_decap_conf.select_vlan)
5704 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5705 else if (mplsoudp_encap_conf.select_ipv4)
5706 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5708 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5709 memcpy(eth.dst.addr_bytes,
5710 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5711 memcpy(eth.src.addr_bytes,
5712 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5713 memcpy(header, ð, sizeof(eth));
5714 header += sizeof(eth);
5715 if (mplsoudp_encap_conf.select_vlan) {
5716 if (mplsoudp_encap_conf.select_ipv4)
5717 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5719 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5720 memcpy(header, &vlan, sizeof(vlan));
5721 header += sizeof(vlan);
5723 if (mplsoudp_encap_conf.select_ipv4) {
5724 memcpy(header, &ipv4, sizeof(ipv4));
5725 header += sizeof(ipv4);
5727 memcpy(header, &ipv6, sizeof(ipv6));
5728 header += sizeof(ipv6);
5730 memcpy(header, &udp, sizeof(udp));
5731 header += sizeof(udp);
5732 memset(&mpls, 0, sizeof(mpls));
5733 memcpy(header, &mpls, sizeof(mpls));
5734 header += sizeof(mpls);
5735 action_decap_data->conf.size = header -
5736 action_decap_data->data;
5737 action->conf = &action_decap_data->conf;
5742 parse_vc_action_raw_decap_index(struct context *ctx, const struct token *token,
5743 const char *str, unsigned int len, void *buf,
5746 struct action_raw_decap_data *action_raw_decap_data;
5747 struct rte_flow_action *action;
5748 const struct arg *arg;
5749 struct buffer *out = buf;
5753 RTE_SET_USED(token);
5756 arg = ARGS_ENTRY_ARB_BOUNDED
5757 (offsetof(struct action_raw_decap_data, idx),
5758 sizeof(((struct action_raw_decap_data *)0)->idx),
5759 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
5760 if (push_args(ctx, arg))
5762 ret = parse_int(ctx, token, str, len, NULL, 0);
5769 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5770 action_raw_decap_data = ctx->object;
5771 idx = action_raw_decap_data->idx;
5772 action_raw_decap_data->conf.data = raw_decap_confs[idx].data;
5773 action_raw_decap_data->conf.size = raw_decap_confs[idx].size;
5774 action->conf = &action_raw_decap_data->conf;
5780 parse_vc_action_raw_encap_index(struct context *ctx, const struct token *token,
5781 const char *str, unsigned int len, void *buf,
5784 struct action_raw_encap_data *action_raw_encap_data;
5785 struct rte_flow_action *action;
5786 const struct arg *arg;
5787 struct buffer *out = buf;
5791 RTE_SET_USED(token);
5794 if (ctx->curr != ACTION_RAW_ENCAP_INDEX_VALUE)
5796 arg = ARGS_ENTRY_ARB_BOUNDED
5797 (offsetof(struct action_raw_encap_data, idx),
5798 sizeof(((struct action_raw_encap_data *)0)->idx),
5799 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
5800 if (push_args(ctx, arg))
5802 ret = parse_int(ctx, token, str, len, NULL, 0);
5809 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5810 action_raw_encap_data = ctx->object;
5811 idx = action_raw_encap_data->idx;
5812 action_raw_encap_data->conf.data = raw_encap_confs[idx].data;
5813 action_raw_encap_data->conf.size = raw_encap_confs[idx].size;
5814 action_raw_encap_data->conf.preserve = NULL;
5815 action->conf = &action_raw_encap_data->conf;
5820 parse_vc_action_raw_encap(struct context *ctx, const struct token *token,
5821 const char *str, unsigned int len, void *buf,
5824 struct buffer *out = buf;
5825 struct rte_flow_action *action;
5826 struct action_raw_encap_data *action_raw_encap_data = NULL;
5829 ret = parse_vc(ctx, token, str, len, buf, size);
5832 /* Nothing else to do if there is no buffer. */
5835 if (!out->args.vc.actions_n)
5837 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5838 /* Point to selected object. */
5839 ctx->object = out->args.vc.data;
5840 ctx->objmask = NULL;
5841 /* Copy the headers to the buffer. */
5842 action_raw_encap_data = ctx->object;
5843 action_raw_encap_data->conf.data = raw_encap_confs[0].data;
5844 action_raw_encap_data->conf.preserve = NULL;
5845 action_raw_encap_data->conf.size = raw_encap_confs[0].size;
5846 action->conf = &action_raw_encap_data->conf;
5851 parse_vc_action_raw_decap(struct context *ctx, const struct token *token,
5852 const char *str, unsigned int len, void *buf,
5855 struct buffer *out = buf;
5856 struct rte_flow_action *action;
5857 struct action_raw_decap_data *action_raw_decap_data = NULL;
5860 ret = parse_vc(ctx, token, str, len, buf, size);
5863 /* Nothing else to do if there is no buffer. */
5866 if (!out->args.vc.actions_n)
5868 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5869 /* Point to selected object. */
5870 ctx->object = out->args.vc.data;
5871 ctx->objmask = NULL;
5872 /* Copy the headers to the buffer. */
5873 action_raw_decap_data = ctx->object;
5874 action_raw_decap_data->conf.data = raw_decap_confs[0].data;
5875 action_raw_decap_data->conf.size = raw_decap_confs[0].size;
5876 action->conf = &action_raw_decap_data->conf;
5881 parse_vc_action_set_meta(struct context *ctx, const struct token *token,
5882 const char *str, unsigned int len, void *buf,
5887 ret = parse_vc(ctx, token, str, len, buf, size);
5890 ret = rte_flow_dynf_metadata_register();
5897 parse_vc_action_sample(struct context *ctx, const struct token *token,
5898 const char *str, unsigned int len, void *buf,
5901 struct buffer *out = buf;
5902 struct rte_flow_action *action;
5903 struct action_sample_data *action_sample_data = NULL;
5904 static struct rte_flow_action end_action = {
5905 RTE_FLOW_ACTION_TYPE_END, 0
5909 ret = parse_vc(ctx, token, str, len, buf, size);
5912 /* Nothing else to do if there is no buffer. */
5915 if (!out->args.vc.actions_n)
5917 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5918 /* Point to selected object. */
5919 ctx->object = out->args.vc.data;
5920 ctx->objmask = NULL;
5921 /* Copy the headers to the buffer. */
5922 action_sample_data = ctx->object;
5923 action_sample_data->conf.actions = &end_action;
5924 action->conf = &action_sample_data->conf;
5929 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
5930 const char *str, unsigned int len, void *buf,
5933 struct action_sample_data *action_sample_data;
5934 struct rte_flow_action *action;
5935 const struct arg *arg;
5936 struct buffer *out = buf;
5940 RTE_SET_USED(token);
5943 if (ctx->curr != ACTION_SAMPLE_INDEX_VALUE)
5945 arg = ARGS_ENTRY_ARB_BOUNDED
5946 (offsetof(struct action_sample_data, idx),
5947 sizeof(((struct action_sample_data *)0)->idx),
5948 0, RAW_SAMPLE_CONFS_MAX_NUM - 1);
5949 if (push_args(ctx, arg))
5951 ret = parse_int(ctx, token, str, len, NULL, 0);
5958 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5959 action_sample_data = ctx->object;
5960 idx = action_sample_data->idx;
5961 action_sample_data->conf.actions = raw_sample_confs[idx].data;
5962 action->conf = &action_sample_data->conf;
5966 /** Parse tokens for destroy command. */
5968 parse_destroy(struct context *ctx, const struct token *token,
5969 const char *str, unsigned int len,
5970 void *buf, unsigned int size)
5972 struct buffer *out = buf;
5974 /* Token name must match. */
5975 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5977 /* Nothing else to do if there is no buffer. */
5980 if (!out->command) {
5981 if (ctx->curr != DESTROY)
5983 if (sizeof(*out) > size)
5985 out->command = ctx->curr;
5988 ctx->objmask = NULL;
5989 out->args.destroy.rule =
5990 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5994 if (((uint8_t *)(out->args.destroy.rule + out->args.destroy.rule_n) +
5995 sizeof(*out->args.destroy.rule)) > (uint8_t *)out + size)
5998 ctx->object = out->args.destroy.rule + out->args.destroy.rule_n++;
5999 ctx->objmask = NULL;
6003 /** Parse tokens for flush command. */
6005 parse_flush(struct context *ctx, const struct token *token,
6006 const char *str, unsigned int len,
6007 void *buf, unsigned int size)
6009 struct buffer *out = buf;
6011 /* Token name must match. */
6012 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6014 /* Nothing else to do if there is no buffer. */
6017 if (!out->command) {
6018 if (ctx->curr != FLUSH)
6020 if (sizeof(*out) > size)
6022 out->command = ctx->curr;
6025 ctx->objmask = NULL;
6030 /** Parse tokens for dump command. */
6032 parse_dump(struct context *ctx, const struct token *token,
6033 const char *str, unsigned int len,
6034 void *buf, unsigned int size)
6036 struct buffer *out = buf;
6038 /* Token name must match. */
6039 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6041 /* Nothing else to do if there is no buffer. */
6044 if (!out->command) {
6045 if (ctx->curr != DUMP)
6047 if (sizeof(*out) > size)
6049 out->command = ctx->curr;
6052 ctx->objmask = NULL;
6057 /** Parse tokens for query command. */
6059 parse_query(struct context *ctx, const struct token *token,
6060 const char *str, unsigned int len,
6061 void *buf, unsigned int size)
6063 struct buffer *out = buf;
6065 /* Token name must match. */
6066 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6068 /* Nothing else to do if there is no buffer. */
6071 if (!out->command) {
6072 if (ctx->curr != QUERY)
6074 if (sizeof(*out) > size)
6076 out->command = ctx->curr;
6079 ctx->objmask = NULL;
6084 /** Parse action names. */
6086 parse_action(struct context *ctx, const struct token *token,
6087 const char *str, unsigned int len,
6088 void *buf, unsigned int size)
6090 struct buffer *out = buf;
6091 const struct arg *arg = pop_args(ctx);
6095 /* Argument is expected. */
6098 /* Parse action name. */
6099 for (i = 0; next_action[i]; ++i) {
6100 const struct parse_action_priv *priv;
6102 token = &token_list[next_action[i]];
6103 if (strcmp_partial(token->name, str, len))
6109 memcpy((uint8_t *)ctx->object + arg->offset,
6115 push_args(ctx, arg);
6119 /** Parse tokens for list command. */
6121 parse_list(struct context *ctx, const struct token *token,
6122 const char *str, unsigned int len,
6123 void *buf, unsigned int size)
6125 struct buffer *out = buf;
6127 /* Token name must match. */
6128 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6130 /* Nothing else to do if there is no buffer. */
6133 if (!out->command) {
6134 if (ctx->curr != LIST)
6136 if (sizeof(*out) > size)
6138 out->command = ctx->curr;
6141 ctx->objmask = NULL;
6142 out->args.list.group =
6143 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6147 if (((uint8_t *)(out->args.list.group + out->args.list.group_n) +
6148 sizeof(*out->args.list.group)) > (uint8_t *)out + size)
6151 ctx->object = out->args.list.group + out->args.list.group_n++;
6152 ctx->objmask = NULL;
6156 /** Parse tokens for list all aged flows command. */
6158 parse_aged(struct context *ctx, const struct token *token,
6159 const char *str, unsigned int len,
6160 void *buf, unsigned int size)
6162 struct buffer *out = buf;
6164 /* Token name must match. */
6165 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6167 /* Nothing else to do if there is no buffer. */
6170 if (!out->command) {
6171 if (ctx->curr != AGED)
6173 if (sizeof(*out) > size)
6175 out->command = ctx->curr;
6178 ctx->objmask = NULL;
6180 if (ctx->curr == AGED_DESTROY)
6181 out->args.aged.destroy = 1;
6185 /** Parse tokens for isolate command. */
6187 parse_isolate(struct context *ctx, const struct token *token,
6188 const char *str, unsigned int len,
6189 void *buf, unsigned int size)
6191 struct buffer *out = buf;
6193 /* Token name must match. */
6194 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6196 /* Nothing else to do if there is no buffer. */
6199 if (!out->command) {
6200 if (ctx->curr != ISOLATE)
6202 if (sizeof(*out) > size)
6204 out->command = ctx->curr;
6207 ctx->objmask = NULL;
6213 parse_tunnel(struct context *ctx, const struct token *token,
6214 const char *str, unsigned int len,
6215 void *buf, unsigned int size)
6217 struct buffer *out = buf;
6219 /* Token name must match. */
6220 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6222 /* Nothing else to do if there is no buffer. */
6225 if (!out->command) {
6226 if (ctx->curr != TUNNEL)
6228 if (sizeof(*out) > size)
6230 out->command = ctx->curr;
6233 ctx->objmask = NULL;
6235 switch (ctx->curr) {
6239 case TUNNEL_DESTROY:
6241 out->command = ctx->curr;
6243 case TUNNEL_CREATE_TYPE:
6244 case TUNNEL_DESTROY_ID:
6245 ctx->object = &out->args.vc.tunnel_ops;
6254 * Parse signed/unsigned integers 8 to 64-bit long.
6256 * Last argument (ctx->args) is retrieved to determine integer type and
6260 parse_int(struct context *ctx, const struct token *token,
6261 const char *str, unsigned int len,
6262 void *buf, unsigned int size)
6264 const struct arg *arg = pop_args(ctx);
6269 /* Argument is expected. */
6274 (uintmax_t)strtoimax(str, &end, 0) :
6275 strtoumax(str, &end, 0);
6276 if (errno || (size_t)(end - str) != len)
6279 ((arg->sign && ((intmax_t)u < (intmax_t)arg->min ||
6280 (intmax_t)u > (intmax_t)arg->max)) ||
6281 (!arg->sign && (u < arg->min || u > arg->max))))
6286 if (!arg_entry_bf_fill(ctx->object, u, arg) ||
6287 !arg_entry_bf_fill(ctx->objmask, -1, arg))
6291 buf = (uint8_t *)ctx->object + arg->offset;
6293 if (u > RTE_LEN2MASK(size * CHAR_BIT, uint64_t))
6297 case sizeof(uint8_t):
6298 *(uint8_t *)buf = u;
6300 case sizeof(uint16_t):
6301 *(uint16_t *)buf = arg->hton ? rte_cpu_to_be_16(u) : u;
6303 case sizeof(uint8_t [3]):
6304 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
6306 ((uint8_t *)buf)[0] = u;
6307 ((uint8_t *)buf)[1] = u >> 8;
6308 ((uint8_t *)buf)[2] = u >> 16;
6312 ((uint8_t *)buf)[0] = u >> 16;
6313 ((uint8_t *)buf)[1] = u >> 8;
6314 ((uint8_t *)buf)[2] = u;
6316 case sizeof(uint32_t):
6317 *(uint32_t *)buf = arg->hton ? rte_cpu_to_be_32(u) : u;
6319 case sizeof(uint64_t):
6320 *(uint64_t *)buf = arg->hton ? rte_cpu_to_be_64(u) : u;
6325 if (ctx->objmask && buf != (uint8_t *)ctx->objmask + arg->offset) {
6327 buf = (uint8_t *)ctx->objmask + arg->offset;
6332 push_args(ctx, arg);
6339 * Three arguments (ctx->args) are retrieved from the stack to store data,
6340 * its actual length and address (in that order).
6343 parse_string(struct context *ctx, const struct token *token,
6344 const char *str, unsigned int len,
6345 void *buf, unsigned int size)
6347 const struct arg *arg_data = pop_args(ctx);
6348 const struct arg *arg_len = pop_args(ctx);
6349 const struct arg *arg_addr = pop_args(ctx);
6350 char tmp[16]; /* Ought to be enough. */
6353 /* Arguments are expected. */
6357 push_args(ctx, arg_data);
6361 push_args(ctx, arg_len);
6362 push_args(ctx, arg_data);
6365 size = arg_data->size;
6366 /* Bit-mask fill is not supported. */
6367 if (arg_data->mask || size < len)
6371 /* Let parse_int() fill length information first. */
6372 ret = snprintf(tmp, sizeof(tmp), "%u", len);
6375 push_args(ctx, arg_len);
6376 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
6381 buf = (uint8_t *)ctx->object + arg_data->offset;
6382 /* Output buffer is not necessarily NUL-terminated. */
6383 memcpy(buf, str, len);
6384 memset((uint8_t *)buf + len, 0x00, size - len);
6386 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
6387 /* Save address if requested. */
6388 if (arg_addr->size) {
6389 memcpy((uint8_t *)ctx->object + arg_addr->offset,
6391 (uint8_t *)ctx->object + arg_data->offset
6395 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
6397 (uint8_t *)ctx->objmask + arg_data->offset
6403 push_args(ctx, arg_addr);
6404 push_args(ctx, arg_len);
6405 push_args(ctx, arg_data);
6410 parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
6416 /* Check input parameters */
6417 if ((src == NULL) ||
6423 /* Convert chars to bytes */
6424 for (i = 0, len = 0; i < *size; i += 2) {
6425 snprintf(tmp, 3, "%s", src + i);
6426 dst[len++] = strtoul(tmp, &c, 16);
6441 parse_hex(struct context *ctx, const struct token *token,
6442 const char *str, unsigned int len,
6443 void *buf, unsigned int size)
6445 const struct arg *arg_data = pop_args(ctx);
6446 const struct arg *arg_len = pop_args(ctx);
6447 const struct arg *arg_addr = pop_args(ctx);
6448 char tmp[16]; /* Ought to be enough. */
6450 unsigned int hexlen = len;
6451 unsigned int length = 256;
6452 uint8_t hex_tmp[length];
6454 /* Arguments are expected. */
6458 push_args(ctx, arg_data);
6462 push_args(ctx, arg_len);
6463 push_args(ctx, arg_data);
6466 size = arg_data->size;
6467 /* Bit-mask fill is not supported. */
6473 /* translate bytes string to array. */
6474 if (str[0] == '0' && ((str[1] == 'x') ||
6479 if (hexlen > length)
6481 ret = parse_hex_string(str, hex_tmp, &hexlen);
6484 /* Let parse_int() fill length information first. */
6485 ret = snprintf(tmp, sizeof(tmp), "%u", hexlen);
6488 push_args(ctx, arg_len);
6489 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
6494 buf = (uint8_t *)ctx->object + arg_data->offset;
6495 /* Output buffer is not necessarily NUL-terminated. */
6496 memcpy(buf, hex_tmp, hexlen);
6497 memset((uint8_t *)buf + hexlen, 0x00, size - hexlen);
6499 memset((uint8_t *)ctx->objmask + arg_data->offset,
6501 /* Save address if requested. */
6502 if (arg_addr->size) {
6503 memcpy((uint8_t *)ctx->object + arg_addr->offset,
6505 (uint8_t *)ctx->object + arg_data->offset
6509 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
6511 (uint8_t *)ctx->objmask + arg_data->offset
6517 push_args(ctx, arg_addr);
6518 push_args(ctx, arg_len);
6519 push_args(ctx, arg_data);
6525 * Parse a zero-ended string.
6528 parse_string0(struct context *ctx, const struct token *token __rte_unused,
6529 const char *str, unsigned int len,
6530 void *buf, unsigned int size)
6532 const struct arg *arg_data = pop_args(ctx);
6534 /* Arguments are expected. */
6537 size = arg_data->size;
6538 /* Bit-mask fill is not supported. */
6539 if (arg_data->mask || size < len + 1)
6543 buf = (uint8_t *)ctx->object + arg_data->offset;
6544 strncpy(buf, str, len);
6546 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
6549 push_args(ctx, arg_data);
6554 * Parse a MAC address.
6556 * Last argument (ctx->args) is retrieved to determine storage size and
6560 parse_mac_addr(struct context *ctx, const struct token *token,
6561 const char *str, unsigned int len,
6562 void *buf, unsigned int size)
6564 const struct arg *arg = pop_args(ctx);
6565 struct rte_ether_addr tmp;
6569 /* Argument is expected. */
6573 /* Bit-mask fill is not supported. */
6574 if (arg->mask || size != sizeof(tmp))
6576 /* Only network endian is supported. */
6579 ret = cmdline_parse_etheraddr(NULL, str, &tmp, size);
6580 if (ret < 0 || (unsigned int)ret != len)
6584 buf = (uint8_t *)ctx->object + arg->offset;
6585 memcpy(buf, &tmp, size);
6587 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6590 push_args(ctx, arg);
6595 * Parse an IPv4 address.
6597 * Last argument (ctx->args) is retrieved to determine storage size and
6601 parse_ipv4_addr(struct context *ctx, const struct token *token,
6602 const char *str, unsigned int len,
6603 void *buf, unsigned int size)
6605 const struct arg *arg = pop_args(ctx);
6610 /* Argument is expected. */
6614 /* Bit-mask fill is not supported. */
6615 if (arg->mask || size != sizeof(tmp))
6617 /* Only network endian is supported. */
6620 memcpy(str2, str, len);
6622 ret = inet_pton(AF_INET, str2, &tmp);
6624 /* Attempt integer parsing. */
6625 push_args(ctx, arg);
6626 return parse_int(ctx, token, str, len, buf, size);
6630 buf = (uint8_t *)ctx->object + arg->offset;
6631 memcpy(buf, &tmp, size);
6633 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6636 push_args(ctx, arg);
6641 * Parse an IPv6 address.
6643 * Last argument (ctx->args) is retrieved to determine storage size and
6647 parse_ipv6_addr(struct context *ctx, const struct token *token,
6648 const char *str, unsigned int len,
6649 void *buf, unsigned int size)
6651 const struct arg *arg = pop_args(ctx);
6653 struct in6_addr tmp;
6657 /* Argument is expected. */
6661 /* Bit-mask fill is not supported. */
6662 if (arg->mask || size != sizeof(tmp))
6664 /* Only network endian is supported. */
6667 memcpy(str2, str, len);
6669 ret = inet_pton(AF_INET6, str2, &tmp);
6674 buf = (uint8_t *)ctx->object + arg->offset;
6675 memcpy(buf, &tmp, size);
6677 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6680 push_args(ctx, arg);
6684 /** Boolean values (even indices stand for false). */
6685 static const char *const boolean_name[] = {
6695 * Parse a boolean value.
6697 * Last argument (ctx->args) is retrieved to determine storage size and
6701 parse_boolean(struct context *ctx, const struct token *token,
6702 const char *str, unsigned int len,
6703 void *buf, unsigned int size)
6705 const struct arg *arg = pop_args(ctx);
6709 /* Argument is expected. */
6712 for (i = 0; boolean_name[i]; ++i)
6713 if (!strcmp_partial(boolean_name[i], str, len))
6715 /* Process token as integer. */
6716 if (boolean_name[i])
6717 str = i & 1 ? "1" : "0";
6718 push_args(ctx, arg);
6719 ret = parse_int(ctx, token, str, strlen(str), buf, size);
6720 return ret > 0 ? (int)len : ret;
6723 /** Parse port and update context. */
6725 parse_port(struct context *ctx, const struct token *token,
6726 const char *str, unsigned int len,
6727 void *buf, unsigned int size)
6729 struct buffer *out = &(struct buffer){ .port = 0 };
6737 ctx->objmask = NULL;
6738 size = sizeof(*out);
6740 ret = parse_int(ctx, token, str, len, out, size);
6742 ctx->port = out->port;
6749 parse_sa_id2ptr(struct context *ctx, const struct token *token,
6750 const char *str, unsigned int len,
6751 void *buf, unsigned int size)
6753 struct rte_flow_action *action = ctx->object;
6761 ctx->objmask = NULL;
6762 ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
6763 ctx->object = action;
6764 if (ret != (int)len)
6766 /* set shared action */
6768 action->conf = port_shared_action_get_by_id(ctx->port, id);
6769 ret = (action->conf) ? ret : -1;
6774 /** Parse set command, initialize output buffer for subsequent tokens. */
6776 parse_set_raw_encap_decap(struct context *ctx, const struct token *token,
6777 const char *str, unsigned int len,
6778 void *buf, unsigned int size)
6780 struct buffer *out = buf;
6782 /* Token name must match. */
6783 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6785 /* Nothing else to do if there is no buffer. */
6788 /* Make sure buffer is large enough. */
6789 if (size < sizeof(*out))
6792 ctx->objmask = NULL;
6796 out->command = ctx->curr;
6797 /* For encap/decap we need is pattern */
6798 out->args.vc.pattern = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6803 /** Parse set command, initialize output buffer for subsequent tokens. */
6805 parse_set_sample_action(struct context *ctx, const struct token *token,
6806 const char *str, unsigned int len,
6807 void *buf, unsigned int size)
6809 struct buffer *out = buf;
6811 /* Token name must match. */
6812 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6814 /* Nothing else to do if there is no buffer. */
6817 /* Make sure buffer is large enough. */
6818 if (size < sizeof(*out))
6821 ctx->objmask = NULL;
6825 out->command = ctx->curr;
6826 /* For sampler we need is actions */
6827 out->args.vc.actions = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6833 * Parse set raw_encap/raw_decap command,
6834 * initialize output buffer for subsequent tokens.
6837 parse_set_init(struct context *ctx, const struct token *token,
6838 const char *str, unsigned int len,
6839 void *buf, unsigned int size)
6841 struct buffer *out = buf;
6843 /* Token name must match. */
6844 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6846 /* Nothing else to do if there is no buffer. */
6849 /* Make sure buffer is large enough. */
6850 if (size < sizeof(*out))
6852 /* Initialize buffer. */
6853 memset(out, 0x00, sizeof(*out));
6854 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
6857 ctx->objmask = NULL;
6858 if (!out->command) {
6859 if (ctx->curr != SET)
6861 if (sizeof(*out) > size)
6863 out->command = ctx->curr;
6864 out->args.vc.data = (uint8_t *)out + size;
6865 ctx->object = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6871 /** No completion. */
6873 comp_none(struct context *ctx, const struct token *token,
6874 unsigned int ent, char *buf, unsigned int size)
6884 /** Complete boolean values. */
6886 comp_boolean(struct context *ctx, const struct token *token,
6887 unsigned int ent, char *buf, unsigned int size)
6893 for (i = 0; boolean_name[i]; ++i)
6894 if (buf && i == ent)
6895 return strlcpy(buf, boolean_name[i], size);
6901 /** Complete action names. */
6903 comp_action(struct context *ctx, const struct token *token,
6904 unsigned int ent, char *buf, unsigned int size)
6910 for (i = 0; next_action[i]; ++i)
6911 if (buf && i == ent)
6912 return strlcpy(buf, token_list[next_action[i]].name,
6919 /** Complete available ports. */
6921 comp_port(struct context *ctx, const struct token *token,
6922 unsigned int ent, char *buf, unsigned int size)
6929 RTE_ETH_FOREACH_DEV(p) {
6930 if (buf && i == ent)
6931 return snprintf(buf, size, "%u", p);
6939 /** Complete available rule IDs. */
6941 comp_rule_id(struct context *ctx, const struct token *token,
6942 unsigned int ent, char *buf, unsigned int size)
6945 struct rte_port *port;
6946 struct port_flow *pf;
6949 if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
6950 ctx->port == (portid_t)RTE_PORT_ALL)
6952 port = &ports[ctx->port];
6953 for (pf = port->flow_list; pf != NULL; pf = pf->next) {
6954 if (buf && i == ent)
6955 return snprintf(buf, size, "%u", pf->id);
6963 /** Complete type field for RSS action. */
6965 comp_vc_action_rss_type(struct context *ctx, const struct token *token,
6966 unsigned int ent, char *buf, unsigned int size)
6972 for (i = 0; rss_type_table[i].str; ++i)
6977 return strlcpy(buf, rss_type_table[ent].str, size);
6979 return snprintf(buf, size, "end");
6983 /** Complete queue field for RSS action. */
6985 comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
6986 unsigned int ent, char *buf, unsigned int size)
6993 return snprintf(buf, size, "%u", ent);
6995 return snprintf(buf, size, "end");
6999 /** Complete index number for set raw_encap/raw_decap commands. */
7001 comp_set_raw_index(struct context *ctx, const struct token *token,
7002 unsigned int ent, char *buf, unsigned int size)
7008 RTE_SET_USED(token);
7009 for (idx = 0; idx < RAW_ENCAP_CONFS_MAX_NUM; ++idx) {
7010 if (buf && idx == ent)
7011 return snprintf(buf, size, "%u", idx);
7017 /** Complete index number for set raw_encap/raw_decap commands. */
7019 comp_set_sample_index(struct context *ctx, const struct token *token,
7020 unsigned int ent, char *buf, unsigned int size)
7026 RTE_SET_USED(token);
7027 for (idx = 0; idx < RAW_SAMPLE_CONFS_MAX_NUM; ++idx) {
7028 if (buf && idx == ent)
7029 return snprintf(buf, size, "%u", idx);
7035 /** Internal context. */
7036 static struct context cmd_flow_context;
7038 /** Global parser instance (cmdline API). */
7039 cmdline_parse_inst_t cmd_flow;
7040 cmdline_parse_inst_t cmd_set_raw;
7042 /** Initialize context. */
7044 cmd_flow_context_init(struct context *ctx)
7046 /* A full memset() is not necessary. */
7056 ctx->objmask = NULL;
7059 /** Parse a token (cmdline API). */
7061 cmd_flow_parse(cmdline_parse_token_hdr_t *hdr, const char *src, void *result,
7064 struct context *ctx = &cmd_flow_context;
7065 const struct token *token;
7066 const enum index *list;
7071 token = &token_list[ctx->curr];
7072 /* Check argument length. */
7075 for (len = 0; src[len]; ++len)
7076 if (src[len] == '#' || isspace(src[len]))
7080 /* Last argument and EOL detection. */
7081 for (i = len; src[i]; ++i)
7082 if (src[i] == '#' || src[i] == '\r' || src[i] == '\n')
7084 else if (!isspace(src[i])) {
7089 if (src[i] == '\r' || src[i] == '\n') {
7093 /* Initialize context if necessary. */
7094 if (!ctx->next_num) {
7097 ctx->next[ctx->next_num++] = token->next[0];
7099 /* Process argument through candidates. */
7100 ctx->prev = ctx->curr;
7101 list = ctx->next[ctx->next_num - 1];
7102 for (i = 0; list[i]; ++i) {
7103 const struct token *next = &token_list[list[i]];
7106 ctx->curr = list[i];
7108 tmp = next->call(ctx, next, src, len, result, size);
7110 tmp = parse_default(ctx, next, src, len, result, size);
7111 if (tmp == -1 || tmp != len)
7119 /* Push subsequent tokens if any. */
7121 for (i = 0; token->next[i]; ++i) {
7122 if (ctx->next_num == RTE_DIM(ctx->next))
7124 ctx->next[ctx->next_num++] = token->next[i];
7126 /* Push arguments if any. */
7128 for (i = 0; token->args[i]; ++i) {
7129 if (ctx->args_num == RTE_DIM(ctx->args))
7131 ctx->args[ctx->args_num++] = token->args[i];
7136 /** Return number of completion entries (cmdline API). */
7138 cmd_flow_complete_get_nb(cmdline_parse_token_hdr_t *hdr)
7140 struct context *ctx = &cmd_flow_context;
7141 const struct token *token = &token_list[ctx->curr];
7142 const enum index *list;
7146 /* Count number of tokens in current list. */
7148 list = ctx->next[ctx->next_num - 1];
7150 list = token->next[0];
7151 for (i = 0; list[i]; ++i)
7156 * If there is a single token, use its completion callback, otherwise
7157 * return the number of entries.
7159 token = &token_list[list[0]];
7160 if (i == 1 && token->comp) {
7161 /* Save index for cmd_flow_get_help(). */
7162 ctx->prev = list[0];
7163 return token->comp(ctx, token, 0, NULL, 0);
7168 /** Return a completion entry (cmdline API). */
7170 cmd_flow_complete_get_elt(cmdline_parse_token_hdr_t *hdr, int index,
7171 char *dst, unsigned int size)
7173 struct context *ctx = &cmd_flow_context;
7174 const struct token *token = &token_list[ctx->curr];
7175 const enum index *list;
7179 /* Count number of tokens in current list. */
7181 list = ctx->next[ctx->next_num - 1];
7183 list = token->next[0];
7184 for (i = 0; list[i]; ++i)
7188 /* If there is a single token, use its completion callback. */
7189 token = &token_list[list[0]];
7190 if (i == 1 && token->comp) {
7191 /* Save index for cmd_flow_get_help(). */
7192 ctx->prev = list[0];
7193 return token->comp(ctx, token, index, dst, size) < 0 ? -1 : 0;
7195 /* Otherwise make sure the index is valid and use defaults. */
7198 token = &token_list[list[index]];
7199 strlcpy(dst, token->name, size);
7200 /* Save index for cmd_flow_get_help(). */
7201 ctx->prev = list[index];
7205 /** Populate help strings for current token (cmdline API). */
7207 cmd_flow_get_help(cmdline_parse_token_hdr_t *hdr, char *dst, unsigned int size)
7209 struct context *ctx = &cmd_flow_context;
7210 const struct token *token = &token_list[ctx->prev];
7215 /* Set token type and update global help with details. */
7216 strlcpy(dst, (token->type ? token->type : "TOKEN"), size);
7218 cmd_flow.help_str = token->help;
7220 cmd_flow.help_str = token->name;
7224 /** Token definition template (cmdline API). */
7225 static struct cmdline_token_hdr cmd_flow_token_hdr = {
7226 .ops = &(struct cmdline_token_ops){
7227 .parse = cmd_flow_parse,
7228 .complete_get_nb = cmd_flow_complete_get_nb,
7229 .complete_get_elt = cmd_flow_complete_get_elt,
7230 .get_help = cmd_flow_get_help,
7235 /** Populate the next dynamic token. */
7237 cmd_flow_tok(cmdline_parse_token_hdr_t **hdr,
7238 cmdline_parse_token_hdr_t **hdr_inst)
7240 struct context *ctx = &cmd_flow_context;
7242 /* Always reinitialize context before requesting the first token. */
7243 if (!(hdr_inst - cmd_flow.tokens))
7244 cmd_flow_context_init(ctx);
7245 /* Return NULL when no more tokens are expected. */
7246 if (!ctx->next_num && ctx->curr) {
7250 /* Determine if command should end here. */
7251 if (ctx->eol && ctx->last && ctx->next_num) {
7252 const enum index *list = ctx->next[ctx->next_num - 1];
7255 for (i = 0; list[i]; ++i) {
7262 *hdr = &cmd_flow_token_hdr;
7265 /** Dispatch parsed buffer to function calls. */
7267 cmd_flow_parsed(const struct buffer *in)
7269 switch (in->command) {
7270 case SHARED_ACTION_CREATE:
7271 port_shared_action_create(
7272 in->port, in->args.vc.attr.group,
7273 &((const struct rte_flow_shared_action_conf) {
7274 .ingress = in->args.vc.attr.ingress,
7275 .egress = in->args.vc.attr.egress,
7277 in->args.vc.actions);
7279 case SHARED_ACTION_DESTROY:
7280 port_shared_action_destroy(in->port,
7281 in->args.sa_destroy.action_id_n,
7282 in->args.sa_destroy.action_id);
7284 case SHARED_ACTION_UPDATE:
7285 port_shared_action_update(in->port, in->args.vc.attr.group,
7286 in->args.vc.actions);
7288 case SHARED_ACTION_QUERY:
7289 port_shared_action_query(in->port, in->args.sa.action_id);
7292 port_flow_validate(in->port, &in->args.vc.attr,
7293 in->args.vc.pattern, in->args.vc.actions,
7294 &in->args.vc.tunnel_ops);
7297 port_flow_create(in->port, &in->args.vc.attr,
7298 in->args.vc.pattern, in->args.vc.actions,
7299 &in->args.vc.tunnel_ops);
7302 port_flow_destroy(in->port, in->args.destroy.rule_n,
7303 in->args.destroy.rule);
7306 port_flow_flush(in->port);
7309 port_flow_dump(in->port, in->args.dump.file);
7312 port_flow_query(in->port, in->args.query.rule,
7313 &in->args.query.action);
7316 port_flow_list(in->port, in->args.list.group_n,
7317 in->args.list.group);
7320 port_flow_isolate(in->port, in->args.isolate.set);
7323 port_flow_aged(in->port, in->args.aged.destroy);
7326 port_flow_tunnel_create(in->port, &in->args.vc.tunnel_ops);
7328 case TUNNEL_DESTROY:
7329 port_flow_tunnel_destroy(in->port, in->args.vc.tunnel_ops.id);
7332 port_flow_tunnel_list(in->port);
7339 /** Token generator and output processing callback (cmdline API). */
7341 cmd_flow_cb(void *arg0, struct cmdline *cl, void *arg2)
7344 cmd_flow_tok(arg0, arg2);
7346 cmd_flow_parsed(arg0);
7349 /** Global parser instance (cmdline API). */
7350 cmdline_parse_inst_t cmd_flow = {
7352 .data = NULL, /**< Unused. */
7353 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
7356 }, /**< Tokens are returned by cmd_flow_tok(). */
7359 /** set cmd facility. Reuse cmd flow's infrastructure as much as possible. */
7362 update_fields(uint8_t *buf, struct rte_flow_item *item, uint16_t next_proto)
7364 struct rte_flow_item_ipv4 *ipv4;
7365 struct rte_flow_item_eth *eth;
7366 struct rte_flow_item_ipv6 *ipv6;
7367 struct rte_flow_item_vxlan *vxlan;
7368 struct rte_flow_item_vxlan_gpe *gpe;
7369 struct rte_flow_item_nvgre *nvgre;
7370 uint32_t ipv6_vtc_flow;
7372 switch (item->type) {
7373 case RTE_FLOW_ITEM_TYPE_ETH:
7374 eth = (struct rte_flow_item_eth *)buf;
7376 eth->type = rte_cpu_to_be_16(next_proto);
7378 case RTE_FLOW_ITEM_TYPE_IPV4:
7379 ipv4 = (struct rte_flow_item_ipv4 *)buf;
7380 ipv4->hdr.version_ihl = 0x45;
7381 if (next_proto && ipv4->hdr.next_proto_id == 0)
7382 ipv4->hdr.next_proto_id = (uint8_t)next_proto;
7384 case RTE_FLOW_ITEM_TYPE_IPV6:
7385 ipv6 = (struct rte_flow_item_ipv6 *)buf;
7386 if (next_proto && ipv6->hdr.proto == 0)
7387 ipv6->hdr.proto = (uint8_t)next_proto;
7388 ipv6_vtc_flow = rte_be_to_cpu_32(ipv6->hdr.vtc_flow);
7389 ipv6_vtc_flow &= 0x0FFFFFFF; /*< reset version bits. */
7390 ipv6_vtc_flow |= 0x60000000; /*< set ipv6 version. */
7391 ipv6->hdr.vtc_flow = rte_cpu_to_be_32(ipv6_vtc_flow);
7393 case RTE_FLOW_ITEM_TYPE_VXLAN:
7394 vxlan = (struct rte_flow_item_vxlan *)buf;
7395 vxlan->flags = 0x08;
7397 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
7398 gpe = (struct rte_flow_item_vxlan_gpe *)buf;
7401 case RTE_FLOW_ITEM_TYPE_NVGRE:
7402 nvgre = (struct rte_flow_item_nvgre *)buf;
7403 nvgre->protocol = rte_cpu_to_be_16(0x6558);
7404 nvgre->c_k_s_rsvd0_ver = rte_cpu_to_be_16(0x2000);
7411 /** Helper of get item's default mask. */
7413 flow_item_default_mask(const struct rte_flow_item *item)
7415 const void *mask = NULL;
7416 static rte_be32_t gre_key_default_mask = RTE_BE32(UINT32_MAX);
7418 switch (item->type) {
7419 case RTE_FLOW_ITEM_TYPE_ANY:
7420 mask = &rte_flow_item_any_mask;
7422 case RTE_FLOW_ITEM_TYPE_VF:
7423 mask = &rte_flow_item_vf_mask;
7425 case RTE_FLOW_ITEM_TYPE_PORT_ID:
7426 mask = &rte_flow_item_port_id_mask;
7428 case RTE_FLOW_ITEM_TYPE_RAW:
7429 mask = &rte_flow_item_raw_mask;
7431 case RTE_FLOW_ITEM_TYPE_ETH:
7432 mask = &rte_flow_item_eth_mask;
7434 case RTE_FLOW_ITEM_TYPE_VLAN:
7435 mask = &rte_flow_item_vlan_mask;
7437 case RTE_FLOW_ITEM_TYPE_IPV4:
7438 mask = &rte_flow_item_ipv4_mask;
7440 case RTE_FLOW_ITEM_TYPE_IPV6:
7441 mask = &rte_flow_item_ipv6_mask;
7443 case RTE_FLOW_ITEM_TYPE_ICMP:
7444 mask = &rte_flow_item_icmp_mask;
7446 case RTE_FLOW_ITEM_TYPE_UDP:
7447 mask = &rte_flow_item_udp_mask;
7449 case RTE_FLOW_ITEM_TYPE_TCP:
7450 mask = &rte_flow_item_tcp_mask;
7452 case RTE_FLOW_ITEM_TYPE_SCTP:
7453 mask = &rte_flow_item_sctp_mask;
7455 case RTE_FLOW_ITEM_TYPE_VXLAN:
7456 mask = &rte_flow_item_vxlan_mask;
7458 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
7459 mask = &rte_flow_item_vxlan_gpe_mask;
7461 case RTE_FLOW_ITEM_TYPE_E_TAG:
7462 mask = &rte_flow_item_e_tag_mask;
7464 case RTE_FLOW_ITEM_TYPE_NVGRE:
7465 mask = &rte_flow_item_nvgre_mask;
7467 case RTE_FLOW_ITEM_TYPE_MPLS:
7468 mask = &rte_flow_item_mpls_mask;
7470 case RTE_FLOW_ITEM_TYPE_GRE:
7471 mask = &rte_flow_item_gre_mask;
7473 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
7474 mask = &gre_key_default_mask;
7476 case RTE_FLOW_ITEM_TYPE_META:
7477 mask = &rte_flow_item_meta_mask;
7479 case RTE_FLOW_ITEM_TYPE_FUZZY:
7480 mask = &rte_flow_item_fuzzy_mask;
7482 case RTE_FLOW_ITEM_TYPE_GTP:
7483 mask = &rte_flow_item_gtp_mask;
7485 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
7486 mask = &rte_flow_item_gtp_psc_mask;
7488 case RTE_FLOW_ITEM_TYPE_GENEVE:
7489 mask = &rte_flow_item_geneve_mask;
7491 case RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID:
7492 mask = &rte_flow_item_pppoe_proto_id_mask;
7494 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
7495 mask = &rte_flow_item_l2tpv3oip_mask;
7497 case RTE_FLOW_ITEM_TYPE_ESP:
7498 mask = &rte_flow_item_esp_mask;
7500 case RTE_FLOW_ITEM_TYPE_AH:
7501 mask = &rte_flow_item_ah_mask;
7503 case RTE_FLOW_ITEM_TYPE_PFCP:
7504 mask = &rte_flow_item_pfcp_mask;
7512 /** Dispatch parsed buffer to function calls. */
7514 cmd_set_raw_parsed_sample(const struct buffer *in)
7516 uint32_t n = in->args.vc.actions_n;
7518 struct rte_flow_action *action = NULL;
7519 struct rte_flow_action *data = NULL;
7521 uint16_t idx = in->port; /* We borrow port field as index */
7522 uint32_t max_size = sizeof(struct rte_flow_action) *
7523 ACTION_SAMPLE_ACTIONS_NUM;
7525 RTE_ASSERT(in->command == SET_SAMPLE_ACTIONS);
7526 data = (struct rte_flow_action *)&raw_sample_confs[idx].data;
7527 memset(data, 0x00, max_size);
7528 for (; i <= n - 1; i++) {
7529 action = in->args.vc.actions + i;
7530 if (action->type == RTE_FLOW_ACTION_TYPE_END)
7532 switch (action->type) {
7533 case RTE_FLOW_ACTION_TYPE_MARK:
7534 size = sizeof(struct rte_flow_action_mark);
7535 rte_memcpy(&sample_mark[idx],
7536 (const void *)action->conf, size);
7537 action->conf = &sample_mark[idx];
7539 case RTE_FLOW_ACTION_TYPE_COUNT:
7540 size = sizeof(struct rte_flow_action_count);
7541 rte_memcpy(&sample_count[idx],
7542 (const void *)action->conf, size);
7543 action->conf = &sample_count[idx];
7545 case RTE_FLOW_ACTION_TYPE_QUEUE:
7546 size = sizeof(struct rte_flow_action_queue);
7547 rte_memcpy(&sample_queue[idx],
7548 (const void *)action->conf, size);
7549 action->conf = &sample_queue[idx];
7551 case RTE_FLOW_ACTION_TYPE_RAW_ENCAP:
7552 size = sizeof(struct rte_flow_action_raw_encap);
7553 rte_memcpy(&sample_encap[idx],
7554 (const void *)action->conf, size);
7555 action->conf = &sample_encap[idx];
7557 case RTE_FLOW_ACTION_TYPE_PORT_ID:
7558 size = sizeof(struct rte_flow_action_port_id);
7559 rte_memcpy(&sample_port_id[idx],
7560 (const void *)action->conf, size);
7561 action->conf = &sample_port_id[idx];
7564 printf("Error - Not supported action\n");
7567 rte_memcpy(data, action, sizeof(struct rte_flow_action));
7572 /** Dispatch parsed buffer to function calls. */
7574 cmd_set_raw_parsed(const struct buffer *in)
7576 uint32_t n = in->args.vc.pattern_n;
7578 struct rte_flow_item *item = NULL;
7580 uint8_t *data = NULL;
7581 uint8_t *data_tail = NULL;
7582 size_t *total_size = NULL;
7583 uint16_t upper_layer = 0;
7585 uint16_t idx = in->port; /* We borrow port field as index */
7587 if (in->command == SET_SAMPLE_ACTIONS)
7588 return cmd_set_raw_parsed_sample(in);
7589 RTE_ASSERT(in->command == SET_RAW_ENCAP ||
7590 in->command == SET_RAW_DECAP);
7591 if (in->command == SET_RAW_ENCAP) {
7592 total_size = &raw_encap_confs[idx].size;
7593 data = (uint8_t *)&raw_encap_confs[idx].data;
7595 total_size = &raw_decap_confs[idx].size;
7596 data = (uint8_t *)&raw_decap_confs[idx].data;
7599 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
7600 /* process hdr from upper layer to low layer (L3/L4 -> L2). */
7601 data_tail = data + ACTION_RAW_ENCAP_MAX_DATA;
7602 for (i = n - 1 ; i >= 0; --i) {
7603 item = in->args.vc.pattern + i;
7604 if (item->spec == NULL)
7605 item->spec = flow_item_default_mask(item);
7606 switch (item->type) {
7607 case RTE_FLOW_ITEM_TYPE_ETH:
7608 size = sizeof(struct rte_flow_item_eth);
7610 case RTE_FLOW_ITEM_TYPE_VLAN:
7611 size = sizeof(struct rte_flow_item_vlan);
7612 proto = RTE_ETHER_TYPE_VLAN;
7614 case RTE_FLOW_ITEM_TYPE_IPV4:
7615 size = sizeof(struct rte_flow_item_ipv4);
7616 proto = RTE_ETHER_TYPE_IPV4;
7618 case RTE_FLOW_ITEM_TYPE_IPV6:
7619 size = sizeof(struct rte_flow_item_ipv6);
7620 proto = RTE_ETHER_TYPE_IPV6;
7622 case RTE_FLOW_ITEM_TYPE_UDP:
7623 size = sizeof(struct rte_flow_item_udp);
7626 case RTE_FLOW_ITEM_TYPE_TCP:
7627 size = sizeof(struct rte_flow_item_tcp);
7630 case RTE_FLOW_ITEM_TYPE_VXLAN:
7631 size = sizeof(struct rte_flow_item_vxlan);
7633 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
7634 size = sizeof(struct rte_flow_item_vxlan_gpe);
7636 case RTE_FLOW_ITEM_TYPE_GRE:
7637 size = sizeof(struct rte_flow_item_gre);
7640 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
7641 size = sizeof(rte_be32_t);
7644 case RTE_FLOW_ITEM_TYPE_MPLS:
7645 size = sizeof(struct rte_flow_item_mpls);
7648 case RTE_FLOW_ITEM_TYPE_NVGRE:
7649 size = sizeof(struct rte_flow_item_nvgre);
7652 case RTE_FLOW_ITEM_TYPE_GENEVE:
7653 size = sizeof(struct rte_flow_item_geneve);
7655 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
7656 size = sizeof(struct rte_flow_item_l2tpv3oip);
7659 case RTE_FLOW_ITEM_TYPE_ESP:
7660 size = sizeof(struct rte_flow_item_esp);
7663 case RTE_FLOW_ITEM_TYPE_AH:
7664 size = sizeof(struct rte_flow_item_ah);
7667 case RTE_FLOW_ITEM_TYPE_GTP:
7668 size = sizeof(struct rte_flow_item_gtp);
7670 case RTE_FLOW_ITEM_TYPE_PFCP:
7671 size = sizeof(struct rte_flow_item_pfcp);
7674 printf("Error - Not supported item\n");
7676 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
7679 *total_size += size;
7680 rte_memcpy(data_tail - (*total_size), item->spec, size);
7681 /* update some fields which cannot be set by cmdline */
7682 update_fields((data_tail - (*total_size)), item,
7684 upper_layer = proto;
7686 if (verbose_level & 0x1)
7687 printf("total data size is %zu\n", (*total_size));
7688 RTE_ASSERT((*total_size) <= ACTION_RAW_ENCAP_MAX_DATA);
7689 memmove(data, (data_tail - (*total_size)), *total_size);
7692 /** Populate help strings for current token (cmdline API). */
7694 cmd_set_raw_get_help(cmdline_parse_token_hdr_t *hdr, char *dst,
7697 struct context *ctx = &cmd_flow_context;
7698 const struct token *token = &token_list[ctx->prev];
7703 /* Set token type and update global help with details. */
7704 snprintf(dst, size, "%s", (token->type ? token->type : "TOKEN"));
7706 cmd_set_raw.help_str = token->help;
7708 cmd_set_raw.help_str = token->name;
7712 /** Token definition template (cmdline API). */
7713 static struct cmdline_token_hdr cmd_set_raw_token_hdr = {
7714 .ops = &(struct cmdline_token_ops){
7715 .parse = cmd_flow_parse,
7716 .complete_get_nb = cmd_flow_complete_get_nb,
7717 .complete_get_elt = cmd_flow_complete_get_elt,
7718 .get_help = cmd_set_raw_get_help,
7723 /** Populate the next dynamic token. */
7725 cmd_set_raw_tok(cmdline_parse_token_hdr_t **hdr,
7726 cmdline_parse_token_hdr_t **hdr_inst)
7728 struct context *ctx = &cmd_flow_context;
7730 /* Always reinitialize context before requesting the first token. */
7731 if (!(hdr_inst - cmd_set_raw.tokens)) {
7732 cmd_flow_context_init(ctx);
7733 ctx->curr = START_SET;
7735 /* Return NULL when no more tokens are expected. */
7736 if (!ctx->next_num && (ctx->curr != START_SET)) {
7740 /* Determine if command should end here. */
7741 if (ctx->eol && ctx->last && ctx->next_num) {
7742 const enum index *list = ctx->next[ctx->next_num - 1];
7745 for (i = 0; list[i]; ++i) {
7752 *hdr = &cmd_set_raw_token_hdr;
7755 /** Token generator and output processing callback (cmdline API). */
7757 cmd_set_raw_cb(void *arg0, struct cmdline *cl, void *arg2)
7760 cmd_set_raw_tok(arg0, arg2);
7762 cmd_set_raw_parsed(arg0);
7765 /** Global parser instance (cmdline API). */
7766 cmdline_parse_inst_t cmd_set_raw = {
7767 .f = cmd_set_raw_cb,
7768 .data = NULL, /**< Unused. */
7769 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
7772 }, /**< Tokens are returned by cmd_flow_tok(). */
7775 /* *** display raw_encap/raw_decap buf */
7776 struct cmd_show_set_raw_result {
7777 cmdline_fixed_string_t cmd_show;
7778 cmdline_fixed_string_t cmd_what;
7779 cmdline_fixed_string_t cmd_all;
7784 cmd_show_set_raw_parsed(void *parsed_result, struct cmdline *cl, void *data)
7786 struct cmd_show_set_raw_result *res = parsed_result;
7787 uint16_t index = res->cmd_index;
7789 uint8_t *raw_data = NULL;
7790 size_t raw_size = 0;
7791 char title[16] = {0};
7795 if (!strcmp(res->cmd_all, "all")) {
7798 } else if (index >= RAW_ENCAP_CONFS_MAX_NUM) {
7799 printf("index should be 0-%u\n", RAW_ENCAP_CONFS_MAX_NUM - 1);
7803 if (!strcmp(res->cmd_what, "raw_encap")) {
7804 raw_data = (uint8_t *)&raw_encap_confs[index].data;
7805 raw_size = raw_encap_confs[index].size;
7806 snprintf(title, 16, "\nindex: %u", index);
7807 rte_hexdump(stdout, title, raw_data, raw_size);
7809 raw_data = (uint8_t *)&raw_decap_confs[index].data;
7810 raw_size = raw_decap_confs[index].size;
7811 snprintf(title, 16, "\nindex: %u", index);
7812 rte_hexdump(stdout, title, raw_data, raw_size);
7814 } while (all && ++index < RAW_ENCAP_CONFS_MAX_NUM);
7817 cmdline_parse_token_string_t cmd_show_set_raw_cmd_show =
7818 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
7820 cmdline_parse_token_string_t cmd_show_set_raw_cmd_what =
7821 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
7822 cmd_what, "raw_encap#raw_decap");
7823 cmdline_parse_token_num_t cmd_show_set_raw_cmd_index =
7824 TOKEN_NUM_INITIALIZER(struct cmd_show_set_raw_result,
7826 cmdline_parse_token_string_t cmd_show_set_raw_cmd_all =
7827 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
7829 cmdline_parse_inst_t cmd_show_set_raw = {
7830 .f = cmd_show_set_raw_parsed,
7832 .help_str = "show <raw_encap|raw_decap> <index>",
7834 (void *)&cmd_show_set_raw_cmd_show,
7835 (void *)&cmd_show_set_raw_cmd_what,
7836 (void *)&cmd_show_set_raw_cmd_index,
7840 cmdline_parse_inst_t cmd_show_set_raw_all = {
7841 .f = cmd_show_set_raw_parsed,
7843 .help_str = "show <raw_encap|raw_decap> all",
7845 (void *)&cmd_show_set_raw_cmd_show,
7846 (void *)&cmd_show_set_raw_cmd_what,
7847 (void *)&cmd_show_set_raw_cmd_all,