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. */
78 /* Destroy arguments. */
81 /* Query arguments. */
87 /* Destroy aged flow arguments. */
90 /* Validate/create arguments. */
97 /* Shared action arguments */
100 SHARED_ACTION_DESTROY,
103 /* Shared action create arguments */
104 SHARED_ACTION_CREATE_ID,
105 SHARED_ACTION_INGRESS,
106 SHARED_ACTION_EGRESS,
109 /* Shared action destroy arguments */
110 SHARED_ACTION_DESTROY_ID,
112 /* Validate/create pattern. */
149 ITEM_VLAN_INNER_TYPE,
152 ITEM_IPV4_FRAGMENT_OFFSET,
184 ITEM_E_TAG_GRP_ECID_B,
193 ITEM_GRE_C_RSVD0_VER,
211 ITEM_ARP_ETH_IPV4_SHA,
212 ITEM_ARP_ETH_IPV4_SPA,
213 ITEM_ARP_ETH_IPV4_THA,
214 ITEM_ARP_ETH_IPV4_TPA,
216 ITEM_IPV6_EXT_NEXT_HDR,
221 ITEM_ICMP6_ND_NS_TARGET_ADDR,
223 ITEM_ICMP6_ND_NA_TARGET_ADDR,
225 ITEM_ICMP6_ND_OPT_TYPE,
226 ITEM_ICMP6_ND_OPT_SLA_ETH,
227 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
228 ITEM_ICMP6_ND_OPT_TLA_ETH,
229 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
242 ITEM_HIGIG2_CLASSIFICATION,
248 ITEM_L2TPV3OIP_SESSION_ID,
258 ITEM_ECPRI_COMMON_TYPE,
259 ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
260 ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
261 ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
262 ITEM_ECPRI_MSG_IQ_DATA_PCID,
263 ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
264 ITEM_ECPRI_MSG_DLY_MSR_MSRID,
266 /* Validate/create actions. */
286 ACTION_RSS_FUNC_DEFAULT,
287 ACTION_RSS_FUNC_TOEPLITZ,
288 ACTION_RSS_FUNC_SIMPLE_XOR,
289 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ,
301 ACTION_PHY_PORT_ORIGINAL,
302 ACTION_PHY_PORT_INDEX,
304 ACTION_PORT_ID_ORIGINAL,
308 ACTION_OF_SET_MPLS_TTL,
309 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
310 ACTION_OF_DEC_MPLS_TTL,
311 ACTION_OF_SET_NW_TTL,
312 ACTION_OF_SET_NW_TTL_NW_TTL,
313 ACTION_OF_DEC_NW_TTL,
314 ACTION_OF_COPY_TTL_OUT,
315 ACTION_OF_COPY_TTL_IN,
318 ACTION_OF_PUSH_VLAN_ETHERTYPE,
319 ACTION_OF_SET_VLAN_VID,
320 ACTION_OF_SET_VLAN_VID_VLAN_VID,
321 ACTION_OF_SET_VLAN_PCP,
322 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
324 ACTION_OF_POP_MPLS_ETHERTYPE,
326 ACTION_OF_PUSH_MPLS_ETHERTYPE,
333 ACTION_MPLSOGRE_ENCAP,
334 ACTION_MPLSOGRE_DECAP,
335 ACTION_MPLSOUDP_ENCAP,
336 ACTION_MPLSOUDP_DECAP,
338 ACTION_SET_IPV4_SRC_IPV4_SRC,
340 ACTION_SET_IPV4_DST_IPV4_DST,
342 ACTION_SET_IPV6_SRC_IPV6_SRC,
344 ACTION_SET_IPV6_DST_IPV6_DST,
346 ACTION_SET_TP_SRC_TP_SRC,
348 ACTION_SET_TP_DST_TP_DST,
354 ACTION_SET_MAC_SRC_MAC_SRC,
356 ACTION_SET_MAC_DST_MAC_DST,
358 ACTION_INC_TCP_SEQ_VALUE,
360 ACTION_DEC_TCP_SEQ_VALUE,
362 ACTION_INC_TCP_ACK_VALUE,
364 ACTION_DEC_TCP_ACK_VALUE,
367 ACTION_RAW_ENCAP_INDEX,
368 ACTION_RAW_ENCAP_INDEX_VALUE,
369 ACTION_RAW_DECAP_INDEX,
370 ACTION_RAW_DECAP_INDEX_VALUE,
373 ACTION_SET_TAG_INDEX,
376 ACTION_SET_META_DATA,
377 ACTION_SET_META_MASK,
378 ACTION_SET_IPV4_DSCP,
379 ACTION_SET_IPV4_DSCP_VALUE,
380 ACTION_SET_IPV6_DSCP,
381 ACTION_SET_IPV6_DSCP_VALUE,
387 ACTION_SAMPLE_INDEX_VALUE,
389 SHARED_ACTION_ID2PTR,
392 /** Maximum size for pattern in struct rte_flow_item_raw. */
393 #define ITEM_RAW_PATTERN_SIZE 40
395 /** Storage size for struct rte_flow_item_raw including pattern. */
396 #define ITEM_RAW_SIZE \
397 (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE)
399 /** Maximum number of queue indices in struct rte_flow_action_rss. */
400 #define ACTION_RSS_QUEUE_NUM 128
402 /** Storage for struct rte_flow_action_rss including external data. */
403 struct action_rss_data {
404 struct rte_flow_action_rss conf;
405 uint8_t key[RSS_HASH_KEY_LENGTH];
406 uint16_t queue[ACTION_RSS_QUEUE_NUM];
409 /** Maximum data size in struct rte_flow_action_raw_encap. */
410 #define ACTION_RAW_ENCAP_MAX_DATA 128
411 #define RAW_ENCAP_CONFS_MAX_NUM 8
413 /** Storage for struct rte_flow_action_raw_encap. */
414 struct raw_encap_conf {
415 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
416 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
420 struct raw_encap_conf raw_encap_confs[RAW_ENCAP_CONFS_MAX_NUM];
422 /** Storage for struct rte_flow_action_raw_encap including external data. */
423 struct action_raw_encap_data {
424 struct rte_flow_action_raw_encap conf;
425 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
426 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
430 /** Storage for struct rte_flow_action_raw_decap. */
431 struct raw_decap_conf {
432 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
436 struct raw_decap_conf raw_decap_confs[RAW_ENCAP_CONFS_MAX_NUM];
438 /** Storage for struct rte_flow_action_raw_decap including external data. */
439 struct action_raw_decap_data {
440 struct rte_flow_action_raw_decap conf;
441 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
445 struct vxlan_encap_conf vxlan_encap_conf = {
449 .vni = "\x00\x00\x00",
451 .udp_dst = RTE_BE16(RTE_VXLAN_DEFAULT_PORT),
452 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
453 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
454 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
455 "\x00\x00\x00\x00\x00\x00\x00\x01",
456 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
457 "\x00\x00\x00\x00\x00\x00\x11\x11",
461 .eth_src = "\x00\x00\x00\x00\x00\x00",
462 .eth_dst = "\xff\xff\xff\xff\xff\xff",
465 /** Maximum number of items in struct rte_flow_action_vxlan_encap. */
466 #define ACTION_VXLAN_ENCAP_ITEMS_NUM 6
468 /** Storage for struct rte_flow_action_vxlan_encap including external data. */
469 struct action_vxlan_encap_data {
470 struct rte_flow_action_vxlan_encap conf;
471 struct rte_flow_item items[ACTION_VXLAN_ENCAP_ITEMS_NUM];
472 struct rte_flow_item_eth item_eth;
473 struct rte_flow_item_vlan item_vlan;
475 struct rte_flow_item_ipv4 item_ipv4;
476 struct rte_flow_item_ipv6 item_ipv6;
478 struct rte_flow_item_udp item_udp;
479 struct rte_flow_item_vxlan item_vxlan;
482 struct nvgre_encap_conf nvgre_encap_conf = {
485 .tni = "\x00\x00\x00",
486 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
487 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
488 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
489 "\x00\x00\x00\x00\x00\x00\x00\x01",
490 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
491 "\x00\x00\x00\x00\x00\x00\x11\x11",
493 .eth_src = "\x00\x00\x00\x00\x00\x00",
494 .eth_dst = "\xff\xff\xff\xff\xff\xff",
497 /** Maximum number of items in struct rte_flow_action_nvgre_encap. */
498 #define ACTION_NVGRE_ENCAP_ITEMS_NUM 5
500 /** Storage for struct rte_flow_action_nvgre_encap including external data. */
501 struct action_nvgre_encap_data {
502 struct rte_flow_action_nvgre_encap conf;
503 struct rte_flow_item items[ACTION_NVGRE_ENCAP_ITEMS_NUM];
504 struct rte_flow_item_eth item_eth;
505 struct rte_flow_item_vlan item_vlan;
507 struct rte_flow_item_ipv4 item_ipv4;
508 struct rte_flow_item_ipv6 item_ipv6;
510 struct rte_flow_item_nvgre item_nvgre;
513 struct l2_encap_conf l2_encap_conf;
515 struct l2_decap_conf l2_decap_conf;
517 struct mplsogre_encap_conf mplsogre_encap_conf;
519 struct mplsogre_decap_conf mplsogre_decap_conf;
521 struct mplsoudp_encap_conf mplsoudp_encap_conf;
523 struct mplsoudp_decap_conf mplsoudp_decap_conf;
525 #define ACTION_SAMPLE_ACTIONS_NUM 10
526 #define RAW_SAMPLE_CONFS_MAX_NUM 8
527 /** Storage for struct rte_flow_action_sample including external data. */
528 struct action_sample_data {
529 struct rte_flow_action_sample conf;
532 /** Storage for struct rte_flow_action_sample. */
533 struct raw_sample_conf {
534 struct rte_flow_action data[ACTION_SAMPLE_ACTIONS_NUM];
536 struct raw_sample_conf raw_sample_confs[RAW_SAMPLE_CONFS_MAX_NUM];
537 struct rte_flow_action_mark sample_mark[RAW_SAMPLE_CONFS_MAX_NUM];
538 struct rte_flow_action_queue sample_queue[RAW_SAMPLE_CONFS_MAX_NUM];
539 struct rte_flow_action_count sample_count[RAW_SAMPLE_CONFS_MAX_NUM];
540 struct rte_flow_action_port_id sample_port_id[RAW_SAMPLE_CONFS_MAX_NUM];
541 struct rte_flow_action_raw_encap sample_encap[RAW_SAMPLE_CONFS_MAX_NUM];
543 /** Maximum number of subsequent tokens and arguments on the stack. */
544 #define CTX_STACK_SIZE 16
546 /** Parser context. */
548 /** Stack of subsequent token lists to process. */
549 const enum index *next[CTX_STACK_SIZE];
550 /** Arguments for stacked tokens. */
551 const void *args[CTX_STACK_SIZE];
552 enum index curr; /**< Current token index. */
553 enum index prev; /**< Index of the last token seen. */
554 int next_num; /**< Number of entries in next[]. */
555 int args_num; /**< Number of entries in args[]. */
556 uint32_t eol:1; /**< EOL has been detected. */
557 uint32_t last:1; /**< No more arguments. */
558 portid_t port; /**< Current port ID (for completions). */
559 uint32_t objdata; /**< Object-specific data. */
560 void *object; /**< Address of current object for relative offsets. */
561 void *objmask; /**< Object a full mask must be written to. */
564 /** Token argument. */
566 uint32_t hton:1; /**< Use network byte ordering. */
567 uint32_t sign:1; /**< Value is signed. */
568 uint32_t bounded:1; /**< Value is bounded. */
569 uintmax_t min; /**< Minimum value if bounded. */
570 uintmax_t max; /**< Maximum value if bounded. */
571 uint32_t offset; /**< Relative offset from ctx->object. */
572 uint32_t size; /**< Field size. */
573 const uint8_t *mask; /**< Bit-mask to use instead of offset/size. */
576 /** Parser token definition. */
578 /** Type displayed during completion (defaults to "TOKEN"). */
580 /** Help displayed during completion (defaults to token name). */
582 /** Private data used by parser functions. */
585 * Lists of subsequent tokens to push on the stack. Each call to the
586 * parser consumes the last entry of that stack.
588 const enum index *const *next;
589 /** Arguments stack for subsequent tokens that need them. */
590 const struct arg *const *args;
592 * Token-processing callback, returns -1 in case of error, the
593 * length of the matched string otherwise. If NULL, attempts to
594 * match the token name.
596 * If buf is not NULL, the result should be stored in it according
597 * to context. An error is returned if not large enough.
599 int (*call)(struct context *ctx, const struct token *token,
600 const char *str, unsigned int len,
601 void *buf, unsigned int size);
603 * Callback that provides possible values for this token, used for
604 * completion. Returns -1 in case of error, the number of possible
605 * values otherwise. If NULL, the token name is used.
607 * If buf is not NULL, entry index ent is written to buf and the
608 * full length of the entry is returned (same behavior as
611 int (*comp)(struct context *ctx, const struct token *token,
612 unsigned int ent, char *buf, unsigned int size);
613 /** Mandatory token name, no default value. */
617 /** Static initializer for the next field. */
618 #define NEXT(...) (const enum index *const []){ __VA_ARGS__, NULL, }
620 /** Static initializer for a NEXT() entry. */
621 #define NEXT_ENTRY(...) (const enum index []){ __VA_ARGS__, ZERO, }
623 /** Static initializer for the args field. */
624 #define ARGS(...) (const struct arg *const []){ __VA_ARGS__, NULL, }
626 /** Static initializer for ARGS() to target a field. */
627 #define ARGS_ENTRY(s, f) \
628 (&(const struct arg){ \
629 .offset = offsetof(s, f), \
630 .size = sizeof(((s *)0)->f), \
633 /** Static initializer for ARGS() to target a bit-field. */
634 #define ARGS_ENTRY_BF(s, f, b) \
635 (&(const struct arg){ \
637 .mask = (const void *)&(const s){ .f = (1 << (b)) - 1 }, \
640 /** Static initializer for ARGS() to target an arbitrary bit-mask. */
641 #define ARGS_ENTRY_MASK(s, f, m) \
642 (&(const struct arg){ \
643 .offset = offsetof(s, f), \
644 .size = sizeof(((s *)0)->f), \
645 .mask = (const void *)(m), \
648 /** Same as ARGS_ENTRY_MASK() using network byte ordering for the value. */
649 #define ARGS_ENTRY_MASK_HTON(s, f, m) \
650 (&(const struct arg){ \
652 .offset = offsetof(s, f), \
653 .size = sizeof(((s *)0)->f), \
654 .mask = (const void *)(m), \
657 /** Static initializer for ARGS() to target a pointer. */
658 #define ARGS_ENTRY_PTR(s, f) \
659 (&(const struct arg){ \
660 .size = sizeof(*((s *)0)->f), \
663 /** Static initializer for ARGS() with arbitrary offset and size. */
664 #define ARGS_ENTRY_ARB(o, s) \
665 (&(const struct arg){ \
670 /** Same as ARGS_ENTRY_ARB() with bounded values. */
671 #define ARGS_ENTRY_ARB_BOUNDED(o, s, i, a) \
672 (&(const struct arg){ \
680 /** Same as ARGS_ENTRY() using network byte ordering. */
681 #define ARGS_ENTRY_HTON(s, f) \
682 (&(const struct arg){ \
684 .offset = offsetof(s, f), \
685 .size = sizeof(((s *)0)->f), \
688 /** Same as ARGS_ENTRY_HTON() for a single argument, without structure. */
689 #define ARG_ENTRY_HTON(s) \
690 (&(const struct arg){ \
696 /** Parser output buffer layout expected by cmd_flow_parsed(). */
698 enum index command; /**< Flow command. */
699 portid_t port; /**< Affected port ID. */
703 uint32_t action_id_n;
704 } sa_destroy; /**< Shared action destroy arguments. */
707 } sa; /* Shared action query arguments */
709 struct rte_flow_attr attr;
710 struct rte_flow_item *pattern;
711 struct rte_flow_action *actions;
715 } vc; /**< Validate/create arguments. */
719 } destroy; /**< Destroy arguments. */
722 } dump; /**< Dump arguments. */
725 struct rte_flow_action action;
726 } query; /**< Query arguments. */
730 } list; /**< List arguments. */
733 } isolate; /**< Isolated mode arguments. */
736 } aged; /**< Aged arguments. */
737 } args; /**< Command arguments. */
740 /** Private data for pattern items. */
741 struct parse_item_priv {
742 enum rte_flow_item_type type; /**< Item type. */
743 uint32_t size; /**< Size of item specification structure. */
746 #define PRIV_ITEM(t, s) \
747 (&(const struct parse_item_priv){ \
748 .type = RTE_FLOW_ITEM_TYPE_ ## t, \
752 /** Private data for actions. */
753 struct parse_action_priv {
754 enum rte_flow_action_type type; /**< Action type. */
755 uint32_t size; /**< Size of action configuration structure. */
758 #define PRIV_ACTION(t, s) \
759 (&(const struct parse_action_priv){ \
760 .type = RTE_FLOW_ACTION_TYPE_ ## t, \
764 static const enum index next_sa_create_attr[] = {
765 SHARED_ACTION_CREATE_ID,
766 SHARED_ACTION_INGRESS,
767 SHARED_ACTION_EGRESS,
772 static const enum index next_sa_subcmd[] = {
773 SHARED_ACTION_CREATE,
774 SHARED_ACTION_UPDATE,
775 SHARED_ACTION_DESTROY,
780 static const enum index next_vc_attr[] = {
790 static const enum index next_destroy_attr[] = {
796 static const enum index next_dump_attr[] = {
802 static const enum index next_list_attr[] = {
808 static const enum index next_aged_attr[] = {
814 static const enum index next_sa_destroy_attr[] = {
815 SHARED_ACTION_DESTROY_ID,
820 static const enum index item_param[] = {
829 static const enum index next_item[] = {
865 ITEM_ICMP6_ND_OPT_SLA_ETH,
866 ITEM_ICMP6_ND_OPT_TLA_ETH,
884 static const enum index item_fuzzy[] = {
890 static const enum index item_any[] = {
896 static const enum index item_vf[] = {
902 static const enum index item_phy_port[] = {
908 static const enum index item_port_id[] = {
914 static const enum index item_mark[] = {
920 static const enum index item_raw[] = {
930 static const enum index item_eth[] = {
938 static const enum index item_vlan[] = {
943 ITEM_VLAN_INNER_TYPE,
948 static const enum index item_ipv4[] = {
950 ITEM_IPV4_FRAGMENT_OFFSET,
959 static const enum index item_ipv6[] = {
970 static const enum index item_icmp[] = {
979 static const enum index item_udp[] = {
986 static const enum index item_tcp[] = {
994 static const enum index item_sctp[] = {
1003 static const enum index item_vxlan[] = {
1009 static const enum index item_e_tag[] = {
1010 ITEM_E_TAG_GRP_ECID_B,
1015 static const enum index item_nvgre[] = {
1021 static const enum index item_mpls[] = {
1029 static const enum index item_gre[] = {
1031 ITEM_GRE_C_RSVD0_VER,
1039 static const enum index item_gre_key[] = {
1045 static const enum index item_gtp[] = {
1053 static const enum index item_geneve[] = {
1060 static const enum index item_vxlan_gpe[] = {
1066 static const enum index item_arp_eth_ipv4[] = {
1067 ITEM_ARP_ETH_IPV4_SHA,
1068 ITEM_ARP_ETH_IPV4_SPA,
1069 ITEM_ARP_ETH_IPV4_THA,
1070 ITEM_ARP_ETH_IPV4_TPA,
1075 static const enum index item_ipv6_ext[] = {
1076 ITEM_IPV6_EXT_NEXT_HDR,
1081 static const enum index item_icmp6[] = {
1088 static const enum index item_icmp6_nd_ns[] = {
1089 ITEM_ICMP6_ND_NS_TARGET_ADDR,
1094 static const enum index item_icmp6_nd_na[] = {
1095 ITEM_ICMP6_ND_NA_TARGET_ADDR,
1100 static const enum index item_icmp6_nd_opt[] = {
1101 ITEM_ICMP6_ND_OPT_TYPE,
1106 static const enum index item_icmp6_nd_opt_sla_eth[] = {
1107 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
1112 static const enum index item_icmp6_nd_opt_tla_eth[] = {
1113 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
1118 static const enum index item_meta[] = {
1124 static const enum index item_gtp_psc[] = {
1131 static const enum index item_pppoed[] = {
1137 static const enum index item_pppoes[] = {
1143 static const enum index item_pppoe_proto_id[] = {
1148 static const enum index item_higig2[] = {
1149 ITEM_HIGIG2_CLASSIFICATION,
1155 static const enum index item_esp[] = {
1161 static const enum index item_ah[] = {
1167 static const enum index item_pfcp[] = {
1174 static const enum index next_set_raw[] = {
1180 static const enum index item_tag[] = {
1187 static const enum index item_l2tpv3oip[] = {
1188 ITEM_L2TPV3OIP_SESSION_ID,
1193 static const enum index item_ecpri[] = {
1199 static const enum index item_ecpri_common[] = {
1200 ITEM_ECPRI_COMMON_TYPE,
1204 static const enum index item_ecpri_common_type[] = {
1205 ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
1206 ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
1207 ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
1211 static const enum index next_action[] = {
1227 ACTION_OF_SET_MPLS_TTL,
1228 ACTION_OF_DEC_MPLS_TTL,
1229 ACTION_OF_SET_NW_TTL,
1230 ACTION_OF_DEC_NW_TTL,
1231 ACTION_OF_COPY_TTL_OUT,
1232 ACTION_OF_COPY_TTL_IN,
1234 ACTION_OF_PUSH_VLAN,
1235 ACTION_OF_SET_VLAN_VID,
1236 ACTION_OF_SET_VLAN_PCP,
1238 ACTION_OF_PUSH_MPLS,
1245 ACTION_MPLSOGRE_ENCAP,
1246 ACTION_MPLSOGRE_DECAP,
1247 ACTION_MPLSOUDP_ENCAP,
1248 ACTION_MPLSOUDP_DECAP,
1249 ACTION_SET_IPV4_SRC,
1250 ACTION_SET_IPV4_DST,
1251 ACTION_SET_IPV6_SRC,
1252 ACTION_SET_IPV6_DST,
1268 ACTION_SET_IPV4_DSCP,
1269 ACTION_SET_IPV6_DSCP,
1276 static const enum index action_mark[] = {
1282 static const enum index action_queue[] = {
1288 static const enum index action_count[] = {
1290 ACTION_COUNT_SHARED,
1295 static const enum index action_rss[] = {
1306 static const enum index action_vf[] = {
1313 static const enum index action_phy_port[] = {
1314 ACTION_PHY_PORT_ORIGINAL,
1315 ACTION_PHY_PORT_INDEX,
1320 static const enum index action_port_id[] = {
1321 ACTION_PORT_ID_ORIGINAL,
1327 static const enum index action_meter[] = {
1333 static const enum index action_of_set_mpls_ttl[] = {
1334 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
1339 static const enum index action_of_set_nw_ttl[] = {
1340 ACTION_OF_SET_NW_TTL_NW_TTL,
1345 static const enum index action_of_push_vlan[] = {
1346 ACTION_OF_PUSH_VLAN_ETHERTYPE,
1351 static const enum index action_of_set_vlan_vid[] = {
1352 ACTION_OF_SET_VLAN_VID_VLAN_VID,
1357 static const enum index action_of_set_vlan_pcp[] = {
1358 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
1363 static const enum index action_of_pop_mpls[] = {
1364 ACTION_OF_POP_MPLS_ETHERTYPE,
1369 static const enum index action_of_push_mpls[] = {
1370 ACTION_OF_PUSH_MPLS_ETHERTYPE,
1375 static const enum index action_set_ipv4_src[] = {
1376 ACTION_SET_IPV4_SRC_IPV4_SRC,
1381 static const enum index action_set_mac_src[] = {
1382 ACTION_SET_MAC_SRC_MAC_SRC,
1387 static const enum index action_set_ipv4_dst[] = {
1388 ACTION_SET_IPV4_DST_IPV4_DST,
1393 static const enum index action_set_ipv6_src[] = {
1394 ACTION_SET_IPV6_SRC_IPV6_SRC,
1399 static const enum index action_set_ipv6_dst[] = {
1400 ACTION_SET_IPV6_DST_IPV6_DST,
1405 static const enum index action_set_tp_src[] = {
1406 ACTION_SET_TP_SRC_TP_SRC,
1411 static const enum index action_set_tp_dst[] = {
1412 ACTION_SET_TP_DST_TP_DST,
1417 static const enum index action_set_ttl[] = {
1423 static const enum index action_jump[] = {
1429 static const enum index action_set_mac_dst[] = {
1430 ACTION_SET_MAC_DST_MAC_DST,
1435 static const enum index action_inc_tcp_seq[] = {
1436 ACTION_INC_TCP_SEQ_VALUE,
1441 static const enum index action_dec_tcp_seq[] = {
1442 ACTION_DEC_TCP_SEQ_VALUE,
1447 static const enum index action_inc_tcp_ack[] = {
1448 ACTION_INC_TCP_ACK_VALUE,
1453 static const enum index action_dec_tcp_ack[] = {
1454 ACTION_DEC_TCP_ACK_VALUE,
1459 static const enum index action_raw_encap[] = {
1460 ACTION_RAW_ENCAP_INDEX,
1465 static const enum index action_raw_decap[] = {
1466 ACTION_RAW_DECAP_INDEX,
1471 static const enum index action_set_tag[] = {
1472 ACTION_SET_TAG_DATA,
1473 ACTION_SET_TAG_INDEX,
1474 ACTION_SET_TAG_MASK,
1479 static const enum index action_set_meta[] = {
1480 ACTION_SET_META_DATA,
1481 ACTION_SET_META_MASK,
1486 static const enum index action_set_ipv4_dscp[] = {
1487 ACTION_SET_IPV4_DSCP_VALUE,
1492 static const enum index action_set_ipv6_dscp[] = {
1493 ACTION_SET_IPV6_DSCP_VALUE,
1498 static const enum index action_age[] = {
1505 static const enum index action_sample[] = {
1507 ACTION_SAMPLE_RATIO,
1508 ACTION_SAMPLE_INDEX,
1513 static const enum index next_action_sample[] = {
1523 static int parse_set_raw_encap_decap(struct context *, const struct token *,
1524 const char *, unsigned int,
1525 void *, unsigned int);
1526 static int parse_set_sample_action(struct context *, const struct token *,
1527 const char *, unsigned int,
1528 void *, unsigned int);
1529 static int parse_set_init(struct context *, const struct token *,
1530 const char *, unsigned int,
1531 void *, unsigned int);
1532 static int parse_init(struct context *, const struct token *,
1533 const char *, unsigned int,
1534 void *, unsigned int);
1535 static int parse_vc(struct context *, const struct token *,
1536 const char *, unsigned int,
1537 void *, unsigned int);
1538 static int parse_vc_spec(struct context *, const struct token *,
1539 const char *, unsigned int, void *, unsigned int);
1540 static int parse_vc_conf(struct context *, const struct token *,
1541 const char *, unsigned int, void *, unsigned int);
1542 static int parse_vc_item_ecpri_type(struct context *, const struct token *,
1543 const char *, unsigned int,
1544 void *, unsigned int);
1545 static int parse_vc_action_rss(struct context *, const struct token *,
1546 const char *, unsigned int, void *,
1548 static int parse_vc_action_rss_func(struct context *, const struct token *,
1549 const char *, unsigned int, void *,
1551 static int parse_vc_action_rss_type(struct context *, const struct token *,
1552 const char *, unsigned int, void *,
1554 static int parse_vc_action_rss_queue(struct context *, const struct token *,
1555 const char *, unsigned int, void *,
1557 static int parse_vc_action_vxlan_encap(struct context *, const struct token *,
1558 const char *, unsigned int, void *,
1560 static int parse_vc_action_nvgre_encap(struct context *, const struct token *,
1561 const char *, unsigned int, void *,
1563 static int parse_vc_action_l2_encap(struct context *, const struct token *,
1564 const char *, unsigned int, void *,
1566 static int parse_vc_action_l2_decap(struct context *, const struct token *,
1567 const char *, unsigned int, void *,
1569 static int parse_vc_action_mplsogre_encap(struct context *,
1570 const struct token *, const char *,
1571 unsigned int, void *, unsigned int);
1572 static int parse_vc_action_mplsogre_decap(struct context *,
1573 const struct token *, const char *,
1574 unsigned int, void *, unsigned int);
1575 static int parse_vc_action_mplsoudp_encap(struct context *,
1576 const struct token *, const char *,
1577 unsigned int, void *, unsigned int);
1578 static int parse_vc_action_mplsoudp_decap(struct context *,
1579 const struct token *, const char *,
1580 unsigned int, void *, unsigned int);
1581 static int parse_vc_action_raw_encap(struct context *,
1582 const struct token *, const char *,
1583 unsigned int, void *, unsigned int);
1584 static int parse_vc_action_raw_decap(struct context *,
1585 const struct token *, const char *,
1586 unsigned int, void *, unsigned int);
1587 static int parse_vc_action_raw_encap_index(struct context *,
1588 const struct token *, const char *,
1589 unsigned int, void *, unsigned int);
1590 static int parse_vc_action_raw_decap_index(struct context *,
1591 const struct token *, const char *,
1592 unsigned int, void *, unsigned int);
1593 static int parse_vc_action_set_meta(struct context *ctx,
1594 const struct token *token, const char *str,
1595 unsigned int len, void *buf,
1597 static int parse_vc_action_sample(struct context *ctx,
1598 const struct token *token, const char *str,
1599 unsigned int len, void *buf,
1602 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
1603 const char *str, unsigned int len, void *buf,
1605 static int parse_destroy(struct context *, const struct token *,
1606 const char *, unsigned int,
1607 void *, unsigned int);
1608 static int parse_flush(struct context *, const struct token *,
1609 const char *, unsigned int,
1610 void *, unsigned int);
1611 static int parse_dump(struct context *, const struct token *,
1612 const char *, unsigned int,
1613 void *, unsigned int);
1614 static int parse_query(struct context *, const struct token *,
1615 const char *, unsigned int,
1616 void *, unsigned int);
1617 static int parse_action(struct context *, const struct token *,
1618 const char *, unsigned int,
1619 void *, unsigned int);
1620 static int parse_list(struct context *, const struct token *,
1621 const char *, unsigned int,
1622 void *, unsigned int);
1623 static int parse_aged(struct context *, const struct token *,
1624 const char *, unsigned int,
1625 void *, unsigned int);
1626 static int parse_isolate(struct context *, const struct token *,
1627 const char *, unsigned int,
1628 void *, unsigned int);
1629 static int parse_int(struct context *, const struct token *,
1630 const char *, unsigned int,
1631 void *, unsigned int);
1632 static int parse_prefix(struct context *, const struct token *,
1633 const char *, unsigned int,
1634 void *, unsigned int);
1635 static int parse_boolean(struct context *, const struct token *,
1636 const char *, unsigned int,
1637 void *, unsigned int);
1638 static int parse_string(struct context *, const struct token *,
1639 const char *, unsigned int,
1640 void *, unsigned int);
1641 static int parse_hex(struct context *ctx, const struct token *token,
1642 const char *str, unsigned int len,
1643 void *buf, unsigned int size);
1644 static int parse_string0(struct context *, const struct token *,
1645 const char *, unsigned int,
1646 void *, unsigned int);
1647 static int parse_mac_addr(struct context *, const struct token *,
1648 const char *, unsigned int,
1649 void *, unsigned int);
1650 static int parse_ipv4_addr(struct context *, const struct token *,
1651 const char *, unsigned int,
1652 void *, unsigned int);
1653 static int parse_ipv6_addr(struct context *, const struct token *,
1654 const char *, unsigned int,
1655 void *, unsigned int);
1656 static int parse_port(struct context *, const struct token *,
1657 const char *, unsigned int,
1658 void *, unsigned int);
1659 static int parse_sa(struct context *, const struct token *,
1660 const char *, unsigned int,
1661 void *, unsigned int);
1662 static int parse_sa_destroy(struct context *ctx, const struct token *token,
1663 const char *str, unsigned int len,
1664 void *buf, unsigned int size);
1665 static int parse_sa_id2ptr(struct context *ctx, const struct token *token,
1666 const char *str, unsigned int len, void *buf,
1668 static int comp_none(struct context *, const struct token *,
1669 unsigned int, char *, unsigned int);
1670 static int comp_boolean(struct context *, const struct token *,
1671 unsigned int, char *, unsigned int);
1672 static int comp_action(struct context *, const struct token *,
1673 unsigned int, char *, unsigned int);
1674 static int comp_port(struct context *, const struct token *,
1675 unsigned int, char *, unsigned int);
1676 static int comp_rule_id(struct context *, const struct token *,
1677 unsigned int, char *, unsigned int);
1678 static int comp_vc_action_rss_type(struct context *, const struct token *,
1679 unsigned int, char *, unsigned int);
1680 static int comp_vc_action_rss_queue(struct context *, const struct token *,
1681 unsigned int, char *, unsigned int);
1682 static int comp_set_raw_index(struct context *, const struct token *,
1683 unsigned int, char *, unsigned int);
1684 static int comp_set_sample_index(struct context *, const struct token *,
1685 unsigned int, char *, unsigned int);
1687 /** Token definitions. */
1688 static const struct token token_list[] = {
1689 /* Special tokens. */
1692 .help = "null entry, abused as the entry point",
1693 .next = NEXT(NEXT_ENTRY(FLOW)),
1698 .help = "command may end here",
1701 .name = "START_SET",
1702 .help = "null entry, abused as the entry point for set",
1703 .next = NEXT(NEXT_ENTRY(SET)),
1708 .help = "set command may end here",
1710 /* Common tokens. */
1714 .help = "integer value",
1719 .name = "{unsigned}",
1721 .help = "unsigned integer value",
1728 .help = "prefix length for bit-mask",
1729 .call = parse_prefix,
1733 .name = "{boolean}",
1735 .help = "any boolean value",
1736 .call = parse_boolean,
1737 .comp = comp_boolean,
1742 .help = "fixed string",
1743 .call = parse_string,
1749 .help = "fixed string",
1753 .name = "{file path}",
1755 .help = "file path",
1756 .call = parse_string0,
1760 .name = "{MAC address}",
1762 .help = "standard MAC address notation",
1763 .call = parse_mac_addr,
1767 .name = "{IPv4 address}",
1768 .type = "IPV4 ADDRESS",
1769 .help = "standard IPv4 address notation",
1770 .call = parse_ipv4_addr,
1774 .name = "{IPv6 address}",
1775 .type = "IPV6 ADDRESS",
1776 .help = "standard IPv6 address notation",
1777 .call = parse_ipv6_addr,
1781 .name = "{rule id}",
1783 .help = "rule identifier",
1785 .comp = comp_rule_id,
1788 .name = "{port_id}",
1790 .help = "port identifier",
1795 .name = "{group_id}",
1797 .help = "group identifier",
1801 [PRIORITY_LEVEL] = {
1804 .help = "priority level",
1808 [SHARED_ACTION_ID] = {
1809 .name = "{shared_action_id}",
1810 .type = "SHARED_ACTION_ID",
1811 .help = "shared action id",
1815 /* Top-level command. */
1818 .type = "{command} {port_id} [{arg} [...]]",
1819 .help = "manage ingress/egress flow rules",
1820 .next = NEXT(NEXT_ENTRY
1833 /* Top-level command. */
1835 .name = "shared_action",
1836 .type = "{command} {port_id} [{arg} [...]]",
1837 .help = "manage shared actions",
1838 .next = NEXT(next_sa_subcmd, NEXT_ENTRY(PORT_ID)),
1839 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1842 /* Sub-level commands. */
1843 [SHARED_ACTION_CREATE] = {
1845 .help = "create shared action",
1846 .next = NEXT(next_sa_create_attr),
1849 [SHARED_ACTION_UPDATE] = {
1851 .help = "update shared action",
1852 .next = NEXT(NEXT_ENTRY(SHARED_ACTION_SPEC),
1853 NEXT_ENTRY(SHARED_ACTION_ID)),
1854 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
1857 [SHARED_ACTION_DESTROY] = {
1859 .help = "destroy shared action",
1860 .next = NEXT(NEXT_ENTRY(SHARED_ACTION_DESTROY_ID)),
1861 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1862 .call = parse_sa_destroy,
1864 [SHARED_ACTION_QUERY] = {
1866 .help = "query shared action",
1867 .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(SHARED_ACTION_ID)),
1868 .args = ARGS(ARGS_ENTRY(struct buffer, args.sa.action_id)),
1873 .help = "check whether a flow rule can be created",
1874 .next = NEXT(next_vc_attr, NEXT_ENTRY(PORT_ID)),
1875 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1880 .help = "create a flow rule",
1881 .next = NEXT(next_vc_attr, NEXT_ENTRY(PORT_ID)),
1882 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1887 .help = "destroy specific flow rules",
1888 .next = NEXT(NEXT_ENTRY(DESTROY_RULE), NEXT_ENTRY(PORT_ID)),
1889 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1890 .call = parse_destroy,
1894 .help = "destroy all flow rules",
1895 .next = NEXT(NEXT_ENTRY(PORT_ID)),
1896 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1897 .call = parse_flush,
1901 .help = "dump all flow rules to file",
1902 .next = NEXT(next_dump_attr, NEXT_ENTRY(PORT_ID)),
1903 .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file),
1904 ARGS_ENTRY(struct buffer, port)),
1909 .help = "query an existing flow rule",
1910 .next = NEXT(NEXT_ENTRY(QUERY_ACTION),
1911 NEXT_ENTRY(RULE_ID),
1912 NEXT_ENTRY(PORT_ID)),
1913 .args = ARGS(ARGS_ENTRY(struct buffer, args.query.action.type),
1914 ARGS_ENTRY(struct buffer, args.query.rule),
1915 ARGS_ENTRY(struct buffer, port)),
1916 .call = parse_query,
1920 .help = "list existing flow rules",
1921 .next = NEXT(next_list_attr, NEXT_ENTRY(PORT_ID)),
1922 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1927 .help = "list and destroy aged flows",
1928 .next = NEXT(next_aged_attr, NEXT_ENTRY(PORT_ID)),
1929 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1934 .help = "restrict ingress traffic to the defined flow rules",
1935 .next = NEXT(NEXT_ENTRY(BOOLEAN),
1936 NEXT_ENTRY(PORT_ID)),
1937 .args = ARGS(ARGS_ENTRY(struct buffer, args.isolate.set),
1938 ARGS_ENTRY(struct buffer, port)),
1939 .call = parse_isolate,
1941 /* Destroy arguments. */
1944 .help = "specify a rule identifier",
1945 .next = NEXT(next_destroy_attr, NEXT_ENTRY(RULE_ID)),
1946 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.destroy.rule)),
1947 .call = parse_destroy,
1949 /* Query arguments. */
1953 .help = "action to query, must be part of the rule",
1954 .call = parse_action,
1955 .comp = comp_action,
1957 /* List arguments. */
1960 .help = "specify a group",
1961 .next = NEXT(next_list_attr, NEXT_ENTRY(GROUP_ID)),
1962 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.list.group)),
1967 .help = "specify aged flows need be destroyed",
1971 /* Validate/create attributes. */
1974 .help = "specify a group",
1975 .next = NEXT(next_vc_attr, NEXT_ENTRY(GROUP_ID)),
1976 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, group)),
1981 .help = "specify a priority level",
1982 .next = NEXT(next_vc_attr, NEXT_ENTRY(PRIORITY_LEVEL)),
1983 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, priority)),
1988 .help = "affect rule to ingress",
1989 .next = NEXT(next_vc_attr),
1994 .help = "affect rule to egress",
1995 .next = NEXT(next_vc_attr),
2000 .help = "apply rule directly to endpoints found in pattern",
2001 .next = NEXT(next_vc_attr),
2004 /* Validate/create pattern. */
2007 .help = "submit a list of pattern items",
2008 .next = NEXT(next_item),
2013 .help = "match value perfectly (with full bit-mask)",
2014 .call = parse_vc_spec,
2016 [ITEM_PARAM_SPEC] = {
2018 .help = "match value according to configured bit-mask",
2019 .call = parse_vc_spec,
2021 [ITEM_PARAM_LAST] = {
2023 .help = "specify upper bound to establish a range",
2024 .call = parse_vc_spec,
2026 [ITEM_PARAM_MASK] = {
2028 .help = "specify bit-mask with relevant bits set to one",
2029 .call = parse_vc_spec,
2031 [ITEM_PARAM_PREFIX] = {
2033 .help = "generate bit-mask from a prefix length",
2034 .call = parse_vc_spec,
2038 .help = "specify next pattern item",
2039 .next = NEXT(next_item),
2043 .help = "end list of pattern items",
2044 .priv = PRIV_ITEM(END, 0),
2045 .next = NEXT(NEXT_ENTRY(ACTIONS)),
2050 .help = "no-op pattern item",
2051 .priv = PRIV_ITEM(VOID, 0),
2052 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2057 .help = "perform actions when pattern does not match",
2058 .priv = PRIV_ITEM(INVERT, 0),
2059 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2064 .help = "match any protocol for the current layer",
2065 .priv = PRIV_ITEM(ANY, sizeof(struct rte_flow_item_any)),
2066 .next = NEXT(item_any),
2071 .help = "number of layers covered",
2072 .next = NEXT(item_any, NEXT_ENTRY(UNSIGNED), item_param),
2073 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_any, num)),
2077 .help = "match traffic from/to the physical function",
2078 .priv = PRIV_ITEM(PF, 0),
2079 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2084 .help = "match traffic from/to a virtual function ID",
2085 .priv = PRIV_ITEM(VF, sizeof(struct rte_flow_item_vf)),
2086 .next = NEXT(item_vf),
2092 .next = NEXT(item_vf, NEXT_ENTRY(UNSIGNED), item_param),
2093 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_vf, id)),
2097 .help = "match traffic from/to a specific physical port",
2098 .priv = PRIV_ITEM(PHY_PORT,
2099 sizeof(struct rte_flow_item_phy_port)),
2100 .next = NEXT(item_phy_port),
2103 [ITEM_PHY_PORT_INDEX] = {
2105 .help = "physical port index",
2106 .next = NEXT(item_phy_port, NEXT_ENTRY(UNSIGNED), item_param),
2107 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_phy_port, index)),
2111 .help = "match traffic from/to a given DPDK port ID",
2112 .priv = PRIV_ITEM(PORT_ID,
2113 sizeof(struct rte_flow_item_port_id)),
2114 .next = NEXT(item_port_id),
2117 [ITEM_PORT_ID_ID] = {
2119 .help = "DPDK port ID",
2120 .next = NEXT(item_port_id, NEXT_ENTRY(UNSIGNED), item_param),
2121 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port_id, id)),
2125 .help = "match traffic against value set in previously matched rule",
2126 .priv = PRIV_ITEM(MARK, sizeof(struct rte_flow_item_mark)),
2127 .next = NEXT(item_mark),
2132 .help = "Integer value to match against",
2133 .next = NEXT(item_mark, NEXT_ENTRY(UNSIGNED), item_param),
2134 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_mark, id)),
2138 .help = "match an arbitrary byte string",
2139 .priv = PRIV_ITEM(RAW, ITEM_RAW_SIZE),
2140 .next = NEXT(item_raw),
2143 [ITEM_RAW_RELATIVE] = {
2145 .help = "look for pattern after the previous item",
2146 .next = NEXT(item_raw, NEXT_ENTRY(BOOLEAN), item_param),
2147 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
2150 [ITEM_RAW_SEARCH] = {
2152 .help = "search pattern from offset (see also limit)",
2153 .next = NEXT(item_raw, NEXT_ENTRY(BOOLEAN), item_param),
2154 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
2157 [ITEM_RAW_OFFSET] = {
2159 .help = "absolute or relative offset for pattern",
2160 .next = NEXT(item_raw, NEXT_ENTRY(INTEGER), item_param),
2161 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, offset)),
2163 [ITEM_RAW_LIMIT] = {
2165 .help = "search area limit for start of pattern",
2166 .next = NEXT(item_raw, NEXT_ENTRY(UNSIGNED), item_param),
2167 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, limit)),
2169 [ITEM_RAW_PATTERN] = {
2171 .help = "byte string to look for",
2172 .next = NEXT(item_raw,
2174 NEXT_ENTRY(ITEM_PARAM_IS,
2177 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern),
2178 ARGS_ENTRY(struct rte_flow_item_raw, length),
2179 ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw),
2180 ITEM_RAW_PATTERN_SIZE)),
2184 .help = "match Ethernet header",
2185 .priv = PRIV_ITEM(ETH, sizeof(struct rte_flow_item_eth)),
2186 .next = NEXT(item_eth),
2191 .help = "destination MAC",
2192 .next = NEXT(item_eth, NEXT_ENTRY(MAC_ADDR), item_param),
2193 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, dst)),
2197 .help = "source MAC",
2198 .next = NEXT(item_eth, NEXT_ENTRY(MAC_ADDR), item_param),
2199 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, src)),
2203 .help = "EtherType",
2204 .next = NEXT(item_eth, NEXT_ENTRY(UNSIGNED), item_param),
2205 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, type)),
2209 .help = "match 802.1Q/ad VLAN tag",
2210 .priv = PRIV_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)),
2211 .next = NEXT(item_vlan),
2216 .help = "tag control information",
2217 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2218 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, tci)),
2222 .help = "priority code point",
2223 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2224 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2229 .help = "drop eligible indicator",
2230 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2231 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2236 .help = "VLAN identifier",
2237 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2238 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2241 [ITEM_VLAN_INNER_TYPE] = {
2242 .name = "inner_type",
2243 .help = "inner EtherType",
2244 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2245 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan,
2250 .help = "match IPv4 header",
2251 .priv = PRIV_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)),
2252 .next = NEXT(item_ipv4),
2257 .help = "type of service",
2258 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2259 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2260 hdr.type_of_service)),
2262 [ITEM_IPV4_FRAGMENT_OFFSET] = {
2263 .name = "fragment_offset",
2264 .help = "fragmentation flags and fragment offset",
2265 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2266 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2267 hdr.fragment_offset)),
2271 .help = "time to live",
2272 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2273 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2276 [ITEM_IPV4_PROTO] = {
2278 .help = "next protocol ID",
2279 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2280 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2281 hdr.next_proto_id)),
2285 .help = "source address",
2286 .next = NEXT(item_ipv4, NEXT_ENTRY(IPV4_ADDR), item_param),
2287 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2292 .help = "destination address",
2293 .next = NEXT(item_ipv4, NEXT_ENTRY(IPV4_ADDR), item_param),
2294 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2299 .help = "match IPv6 header",
2300 .priv = PRIV_ITEM(IPV6, sizeof(struct rte_flow_item_ipv6)),
2301 .next = NEXT(item_ipv6),
2306 .help = "traffic class",
2307 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2308 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2310 "\x0f\xf0\x00\x00")),
2312 [ITEM_IPV6_FLOW] = {
2314 .help = "flow label",
2315 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2316 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2318 "\x00\x0f\xff\xff")),
2320 [ITEM_IPV6_PROTO] = {
2322 .help = "protocol (next header)",
2323 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2324 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2329 .help = "hop limit",
2330 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2331 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2336 .help = "source address",
2337 .next = NEXT(item_ipv6, NEXT_ENTRY(IPV6_ADDR), item_param),
2338 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2343 .help = "destination address",
2344 .next = NEXT(item_ipv6, NEXT_ENTRY(IPV6_ADDR), item_param),
2345 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2350 .help = "match ICMP header",
2351 .priv = PRIV_ITEM(ICMP, sizeof(struct rte_flow_item_icmp)),
2352 .next = NEXT(item_icmp),
2355 [ITEM_ICMP_TYPE] = {
2357 .help = "ICMP packet type",
2358 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2359 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2362 [ITEM_ICMP_CODE] = {
2364 .help = "ICMP packet code",
2365 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2366 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2369 [ITEM_ICMP_IDENT] = {
2371 .help = "ICMP packet identifier",
2372 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2373 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2378 .help = "ICMP packet sequence number",
2379 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2380 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2385 .help = "match UDP header",
2386 .priv = PRIV_ITEM(UDP, sizeof(struct rte_flow_item_udp)),
2387 .next = NEXT(item_udp),
2392 .help = "UDP source port",
2393 .next = NEXT(item_udp, NEXT_ENTRY(UNSIGNED), item_param),
2394 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2399 .help = "UDP destination port",
2400 .next = NEXT(item_udp, NEXT_ENTRY(UNSIGNED), item_param),
2401 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2406 .help = "match TCP header",
2407 .priv = PRIV_ITEM(TCP, sizeof(struct rte_flow_item_tcp)),
2408 .next = NEXT(item_tcp),
2413 .help = "TCP source port",
2414 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2415 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2420 .help = "TCP destination port",
2421 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2422 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2425 [ITEM_TCP_FLAGS] = {
2427 .help = "TCP flags",
2428 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2429 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2434 .help = "match SCTP header",
2435 .priv = PRIV_ITEM(SCTP, sizeof(struct rte_flow_item_sctp)),
2436 .next = NEXT(item_sctp),
2441 .help = "SCTP source port",
2442 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2443 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2448 .help = "SCTP destination port",
2449 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2450 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2455 .help = "validation tag",
2456 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2457 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2460 [ITEM_SCTP_CKSUM] = {
2463 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2464 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2469 .help = "match VXLAN header",
2470 .priv = PRIV_ITEM(VXLAN, sizeof(struct rte_flow_item_vxlan)),
2471 .next = NEXT(item_vxlan),
2474 [ITEM_VXLAN_VNI] = {
2476 .help = "VXLAN identifier",
2477 .next = NEXT(item_vxlan, NEXT_ENTRY(UNSIGNED), item_param),
2478 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan, vni)),
2482 .help = "match E-Tag header",
2483 .priv = PRIV_ITEM(E_TAG, sizeof(struct rte_flow_item_e_tag)),
2484 .next = NEXT(item_e_tag),
2487 [ITEM_E_TAG_GRP_ECID_B] = {
2488 .name = "grp_ecid_b",
2489 .help = "GRP and E-CID base",
2490 .next = NEXT(item_e_tag, NEXT_ENTRY(UNSIGNED), item_param),
2491 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_e_tag,
2497 .help = "match NVGRE header",
2498 .priv = PRIV_ITEM(NVGRE, sizeof(struct rte_flow_item_nvgre)),
2499 .next = NEXT(item_nvgre),
2502 [ITEM_NVGRE_TNI] = {
2504 .help = "virtual subnet ID",
2505 .next = NEXT(item_nvgre, NEXT_ENTRY(UNSIGNED), item_param),
2506 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_nvgre, tni)),
2510 .help = "match MPLS header",
2511 .priv = PRIV_ITEM(MPLS, sizeof(struct rte_flow_item_mpls)),
2512 .next = NEXT(item_mpls),
2515 [ITEM_MPLS_LABEL] = {
2517 .help = "MPLS label",
2518 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2519 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2525 .help = "MPLS Traffic Class",
2526 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2527 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2533 .help = "MPLS Bottom-of-Stack",
2534 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2535 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2541 .help = "match GRE header",
2542 .priv = PRIV_ITEM(GRE, sizeof(struct rte_flow_item_gre)),
2543 .next = NEXT(item_gre),
2546 [ITEM_GRE_PROTO] = {
2548 .help = "GRE protocol type",
2549 .next = NEXT(item_gre, NEXT_ENTRY(UNSIGNED), item_param),
2550 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2553 [ITEM_GRE_C_RSVD0_VER] = {
2554 .name = "c_rsvd0_ver",
2556 "checksum (1b), undefined (1b), key bit (1b),"
2557 " sequence number (1b), reserved 0 (9b),"
2559 .next = NEXT(item_gre, NEXT_ENTRY(UNSIGNED), item_param),
2560 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2563 [ITEM_GRE_C_BIT] = {
2565 .help = "checksum bit (C)",
2566 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2567 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2569 "\x80\x00\x00\x00")),
2571 [ITEM_GRE_S_BIT] = {
2573 .help = "sequence number bit (S)",
2574 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2575 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2577 "\x10\x00\x00\x00")),
2579 [ITEM_GRE_K_BIT] = {
2581 .help = "key bit (K)",
2582 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2583 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2585 "\x20\x00\x00\x00")),
2589 .help = "fuzzy pattern match, expect faster than default",
2590 .priv = PRIV_ITEM(FUZZY,
2591 sizeof(struct rte_flow_item_fuzzy)),
2592 .next = NEXT(item_fuzzy),
2595 [ITEM_FUZZY_THRESH] = {
2597 .help = "match accuracy threshold",
2598 .next = NEXT(item_fuzzy, NEXT_ENTRY(UNSIGNED), item_param),
2599 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_fuzzy,
2604 .help = "match GTP header",
2605 .priv = PRIV_ITEM(GTP, sizeof(struct rte_flow_item_gtp)),
2606 .next = NEXT(item_gtp),
2609 [ITEM_GTP_FLAGS] = {
2610 .name = "v_pt_rsv_flags",
2611 .help = "GTP flags",
2612 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2613 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp,
2616 [ITEM_GTP_MSG_TYPE] = {
2618 .help = "GTP message type",
2619 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2620 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp, msg_type)),
2624 .help = "tunnel endpoint identifier",
2625 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2626 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp, teid)),
2630 .help = "match GTP header",
2631 .priv = PRIV_ITEM(GTPC, sizeof(struct rte_flow_item_gtp)),
2632 .next = NEXT(item_gtp),
2637 .help = "match GTP header",
2638 .priv = PRIV_ITEM(GTPU, sizeof(struct rte_flow_item_gtp)),
2639 .next = NEXT(item_gtp),
2644 .help = "match GENEVE header",
2645 .priv = PRIV_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)),
2646 .next = NEXT(item_geneve),
2649 [ITEM_GENEVE_VNI] = {
2651 .help = "virtual network identifier",
2652 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2653 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve, vni)),
2655 [ITEM_GENEVE_PROTO] = {
2657 .help = "GENEVE protocol type",
2658 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2659 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve,
2662 [ITEM_VXLAN_GPE] = {
2663 .name = "vxlan-gpe",
2664 .help = "match VXLAN-GPE header",
2665 .priv = PRIV_ITEM(VXLAN_GPE,
2666 sizeof(struct rte_flow_item_vxlan_gpe)),
2667 .next = NEXT(item_vxlan_gpe),
2670 [ITEM_VXLAN_GPE_VNI] = {
2672 .help = "VXLAN-GPE identifier",
2673 .next = NEXT(item_vxlan_gpe, NEXT_ENTRY(UNSIGNED), item_param),
2674 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
2677 [ITEM_ARP_ETH_IPV4] = {
2678 .name = "arp_eth_ipv4",
2679 .help = "match ARP header for Ethernet/IPv4",
2680 .priv = PRIV_ITEM(ARP_ETH_IPV4,
2681 sizeof(struct rte_flow_item_arp_eth_ipv4)),
2682 .next = NEXT(item_arp_eth_ipv4),
2685 [ITEM_ARP_ETH_IPV4_SHA] = {
2687 .help = "sender hardware address",
2688 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(MAC_ADDR),
2690 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2693 [ITEM_ARP_ETH_IPV4_SPA] = {
2695 .help = "sender IPv4 address",
2696 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(IPV4_ADDR),
2698 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2701 [ITEM_ARP_ETH_IPV4_THA] = {
2703 .help = "target hardware address",
2704 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(MAC_ADDR),
2706 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2709 [ITEM_ARP_ETH_IPV4_TPA] = {
2711 .help = "target IPv4 address",
2712 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(IPV4_ADDR),
2714 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2719 .help = "match presence of any IPv6 extension header",
2720 .priv = PRIV_ITEM(IPV6_EXT,
2721 sizeof(struct rte_flow_item_ipv6_ext)),
2722 .next = NEXT(item_ipv6_ext),
2725 [ITEM_IPV6_EXT_NEXT_HDR] = {
2727 .help = "next header",
2728 .next = NEXT(item_ipv6_ext, NEXT_ENTRY(UNSIGNED), item_param),
2729 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_ext,
2734 .help = "match any ICMPv6 header",
2735 .priv = PRIV_ITEM(ICMP6, sizeof(struct rte_flow_item_icmp6)),
2736 .next = NEXT(item_icmp6),
2739 [ITEM_ICMP6_TYPE] = {
2741 .help = "ICMPv6 type",
2742 .next = NEXT(item_icmp6, NEXT_ENTRY(UNSIGNED), item_param),
2743 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
2746 [ITEM_ICMP6_CODE] = {
2748 .help = "ICMPv6 code",
2749 .next = NEXT(item_icmp6, NEXT_ENTRY(UNSIGNED), item_param),
2750 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
2753 [ITEM_ICMP6_ND_NS] = {
2754 .name = "icmp6_nd_ns",
2755 .help = "match ICMPv6 neighbor discovery solicitation",
2756 .priv = PRIV_ITEM(ICMP6_ND_NS,
2757 sizeof(struct rte_flow_item_icmp6_nd_ns)),
2758 .next = NEXT(item_icmp6_nd_ns),
2761 [ITEM_ICMP6_ND_NS_TARGET_ADDR] = {
2762 .name = "target_addr",
2763 .help = "target address",
2764 .next = NEXT(item_icmp6_nd_ns, NEXT_ENTRY(IPV6_ADDR),
2766 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_ns,
2769 [ITEM_ICMP6_ND_NA] = {
2770 .name = "icmp6_nd_na",
2771 .help = "match ICMPv6 neighbor discovery advertisement",
2772 .priv = PRIV_ITEM(ICMP6_ND_NA,
2773 sizeof(struct rte_flow_item_icmp6_nd_na)),
2774 .next = NEXT(item_icmp6_nd_na),
2777 [ITEM_ICMP6_ND_NA_TARGET_ADDR] = {
2778 .name = "target_addr",
2779 .help = "target address",
2780 .next = NEXT(item_icmp6_nd_na, NEXT_ENTRY(IPV6_ADDR),
2782 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_na,
2785 [ITEM_ICMP6_ND_OPT] = {
2786 .name = "icmp6_nd_opt",
2787 .help = "match presence of any ICMPv6 neighbor discovery"
2789 .priv = PRIV_ITEM(ICMP6_ND_OPT,
2790 sizeof(struct rte_flow_item_icmp6_nd_opt)),
2791 .next = NEXT(item_icmp6_nd_opt),
2794 [ITEM_ICMP6_ND_OPT_TYPE] = {
2796 .help = "ND option type",
2797 .next = NEXT(item_icmp6_nd_opt, NEXT_ENTRY(UNSIGNED),
2799 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_opt,
2802 [ITEM_ICMP6_ND_OPT_SLA_ETH] = {
2803 .name = "icmp6_nd_opt_sla_eth",
2804 .help = "match ICMPv6 neighbor discovery source Ethernet"
2805 " link-layer address option",
2807 (ICMP6_ND_OPT_SLA_ETH,
2808 sizeof(struct rte_flow_item_icmp6_nd_opt_sla_eth)),
2809 .next = NEXT(item_icmp6_nd_opt_sla_eth),
2812 [ITEM_ICMP6_ND_OPT_SLA_ETH_SLA] = {
2814 .help = "source Ethernet LLA",
2815 .next = NEXT(item_icmp6_nd_opt_sla_eth, NEXT_ENTRY(MAC_ADDR),
2817 .args = ARGS(ARGS_ENTRY_HTON
2818 (struct rte_flow_item_icmp6_nd_opt_sla_eth, sla)),
2820 [ITEM_ICMP6_ND_OPT_TLA_ETH] = {
2821 .name = "icmp6_nd_opt_tla_eth",
2822 .help = "match ICMPv6 neighbor discovery target Ethernet"
2823 " link-layer address option",
2825 (ICMP6_ND_OPT_TLA_ETH,
2826 sizeof(struct rte_flow_item_icmp6_nd_opt_tla_eth)),
2827 .next = NEXT(item_icmp6_nd_opt_tla_eth),
2830 [ITEM_ICMP6_ND_OPT_TLA_ETH_TLA] = {
2832 .help = "target Ethernet LLA",
2833 .next = NEXT(item_icmp6_nd_opt_tla_eth, NEXT_ENTRY(MAC_ADDR),
2835 .args = ARGS(ARGS_ENTRY_HTON
2836 (struct rte_flow_item_icmp6_nd_opt_tla_eth, tla)),
2840 .help = "match metadata header",
2841 .priv = PRIV_ITEM(META, sizeof(struct rte_flow_item_meta)),
2842 .next = NEXT(item_meta),
2845 [ITEM_META_DATA] = {
2847 .help = "metadata value",
2848 .next = NEXT(item_meta, NEXT_ENTRY(UNSIGNED), item_param),
2849 .args = ARGS(ARGS_ENTRY_MASK(struct rte_flow_item_meta,
2850 data, "\xff\xff\xff\xff")),
2854 .help = "match GRE key",
2855 .priv = PRIV_ITEM(GRE_KEY, sizeof(rte_be32_t)),
2856 .next = NEXT(item_gre_key),
2859 [ITEM_GRE_KEY_VALUE] = {
2861 .help = "key value",
2862 .next = NEXT(item_gre_key, NEXT_ENTRY(UNSIGNED), item_param),
2863 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
2867 .help = "match GTP extension header with type 0x85",
2868 .priv = PRIV_ITEM(GTP_PSC,
2869 sizeof(struct rte_flow_item_gtp_psc)),
2870 .next = NEXT(item_gtp_psc),
2873 [ITEM_GTP_PSC_QFI] = {
2875 .help = "QoS flow identifier",
2876 .next = NEXT(item_gtp_psc, NEXT_ENTRY(UNSIGNED), item_param),
2877 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
2880 [ITEM_GTP_PSC_PDU_T] = {
2883 .next = NEXT(item_gtp_psc, NEXT_ENTRY(UNSIGNED), item_param),
2884 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
2889 .help = "match PPPoE session header",
2890 .priv = PRIV_ITEM(PPPOES, sizeof(struct rte_flow_item_pppoe)),
2891 .next = NEXT(item_pppoes),
2896 .help = "match PPPoE discovery header",
2897 .priv = PRIV_ITEM(PPPOED, sizeof(struct rte_flow_item_pppoe)),
2898 .next = NEXT(item_pppoed),
2901 [ITEM_PPPOE_SEID] = {
2903 .help = "session identifier",
2904 .next = NEXT(item_pppoes, NEXT_ENTRY(UNSIGNED), item_param),
2905 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pppoe,
2908 [ITEM_PPPOE_PROTO_ID] = {
2909 .name = "pppoe_proto_id",
2910 .help = "match PPPoE session protocol identifier",
2911 .priv = PRIV_ITEM(PPPOE_PROTO_ID,
2912 sizeof(struct rte_flow_item_pppoe_proto_id)),
2913 .next = NEXT(item_pppoe_proto_id, NEXT_ENTRY(UNSIGNED),
2915 .args = ARGS(ARGS_ENTRY_HTON
2916 (struct rte_flow_item_pppoe_proto_id, proto_id)),
2921 .help = "matches higig2 header",
2922 .priv = PRIV_ITEM(HIGIG2,
2923 sizeof(struct rte_flow_item_higig2_hdr)),
2924 .next = NEXT(item_higig2),
2927 [ITEM_HIGIG2_CLASSIFICATION] = {
2928 .name = "classification",
2929 .help = "matches classification of higig2 header",
2930 .next = NEXT(item_higig2, NEXT_ENTRY(UNSIGNED), item_param),
2931 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
2932 hdr.ppt1.classification)),
2934 [ITEM_HIGIG2_VID] = {
2936 .help = "matches vid of higig2 header",
2937 .next = NEXT(item_higig2, NEXT_ENTRY(UNSIGNED), item_param),
2938 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
2943 .help = "match tag value",
2944 .priv = PRIV_ITEM(TAG, sizeof(struct rte_flow_item_tag)),
2945 .next = NEXT(item_tag),
2950 .help = "tag value to match",
2951 .next = NEXT(item_tag, NEXT_ENTRY(UNSIGNED), item_param),
2952 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, data)),
2954 [ITEM_TAG_INDEX] = {
2956 .help = "index of tag array to match",
2957 .next = NEXT(item_tag, NEXT_ENTRY(UNSIGNED),
2958 NEXT_ENTRY(ITEM_PARAM_IS)),
2959 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, index)),
2961 [ITEM_L2TPV3OIP] = {
2962 .name = "l2tpv3oip",
2963 .help = "match L2TPv3 over IP header",
2964 .priv = PRIV_ITEM(L2TPV3OIP,
2965 sizeof(struct rte_flow_item_l2tpv3oip)),
2966 .next = NEXT(item_l2tpv3oip),
2969 [ITEM_L2TPV3OIP_SESSION_ID] = {
2970 .name = "session_id",
2971 .help = "session identifier",
2972 .next = NEXT(item_l2tpv3oip, NEXT_ENTRY(UNSIGNED), item_param),
2973 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv3oip,
2978 .help = "match ESP header",
2979 .priv = PRIV_ITEM(ESP, sizeof(struct rte_flow_item_esp)),
2980 .next = NEXT(item_esp),
2985 .help = "security policy index",
2986 .next = NEXT(item_esp, NEXT_ENTRY(UNSIGNED), item_param),
2987 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_esp,
2992 .help = "match AH header",
2993 .priv = PRIV_ITEM(AH, sizeof(struct rte_flow_item_ah)),
2994 .next = NEXT(item_ah),
2999 .help = "security parameters index",
3000 .next = NEXT(item_ah, NEXT_ENTRY(UNSIGNED), item_param),
3001 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ah, spi)),
3005 .help = "match pfcp header",
3006 .priv = PRIV_ITEM(PFCP, sizeof(struct rte_flow_item_pfcp)),
3007 .next = NEXT(item_pfcp),
3010 [ITEM_PFCP_S_FIELD] = {
3013 .next = NEXT(item_pfcp, NEXT_ENTRY(UNSIGNED), item_param),
3014 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp,
3017 [ITEM_PFCP_SEID] = {
3019 .help = "session endpoint identifier",
3020 .next = NEXT(item_pfcp, NEXT_ENTRY(UNSIGNED), item_param),
3021 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp, seid)),
3025 .help = "match eCPRI header",
3026 .priv = PRIV_ITEM(ECPRI, sizeof(struct rte_flow_item_ecpri)),
3027 .next = NEXT(item_ecpri),
3030 [ITEM_ECPRI_COMMON] = {
3032 .help = "eCPRI common header",
3033 .next = NEXT(item_ecpri_common),
3035 [ITEM_ECPRI_COMMON_TYPE] = {
3037 .help = "type of common header",
3038 .next = NEXT(item_ecpri_common_type),
3039 .args = ARGS(ARG_ENTRY_HTON(struct rte_flow_item_ecpri)),
3041 [ITEM_ECPRI_COMMON_TYPE_IQ_DATA] = {
3043 .help = "Type #0: IQ Data",
3044 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
3046 .call = parse_vc_item_ecpri_type,
3048 [ITEM_ECPRI_MSG_IQ_DATA_PCID] = {
3050 .help = "Physical Channel ID",
3051 .next = NEXT(item_ecpri, NEXT_ENTRY(UNSIGNED), item_param),
3052 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3055 [ITEM_ECPRI_COMMON_TYPE_RTC_CTRL] = {
3057 .help = "Type #2: Real-Time Control Data",
3058 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
3060 .call = parse_vc_item_ecpri_type,
3062 [ITEM_ECPRI_MSG_RTC_CTRL_RTCID] = {
3064 .help = "Real-Time Control Data ID",
3065 .next = NEXT(item_ecpri, NEXT_ENTRY(UNSIGNED), item_param),
3066 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3069 [ITEM_ECPRI_COMMON_TYPE_DLY_MSR] = {
3070 .name = "delay_measure",
3071 .help = "Type #5: One-Way Delay Measurement",
3072 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
3074 .call = parse_vc_item_ecpri_type,
3076 [ITEM_ECPRI_MSG_DLY_MSR_MSRID] = {
3078 .help = "Measurement ID",
3079 .next = NEXT(item_ecpri, NEXT_ENTRY(UNSIGNED), item_param),
3080 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3083 /* Validate/create actions. */
3086 .help = "submit a list of associated actions",
3087 .next = NEXT(next_action),
3092 .help = "specify next action",
3093 .next = NEXT(next_action),
3097 .help = "end list of actions",
3098 .priv = PRIV_ACTION(END, 0),
3103 .help = "no-op action",
3104 .priv = PRIV_ACTION(VOID, 0),
3105 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3108 [ACTION_PASSTHRU] = {
3110 .help = "let subsequent rule process matched packets",
3111 .priv = PRIV_ACTION(PASSTHRU, 0),
3112 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3117 .help = "redirect traffic to a given group",
3118 .priv = PRIV_ACTION(JUMP, sizeof(struct rte_flow_action_jump)),
3119 .next = NEXT(action_jump),
3122 [ACTION_JUMP_GROUP] = {
3124 .help = "group to redirect traffic to",
3125 .next = NEXT(action_jump, NEXT_ENTRY(UNSIGNED)),
3126 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump, group)),
3127 .call = parse_vc_conf,
3131 .help = "attach 32 bit value to packets",
3132 .priv = PRIV_ACTION(MARK, sizeof(struct rte_flow_action_mark)),
3133 .next = NEXT(action_mark),
3136 [ACTION_MARK_ID] = {
3138 .help = "32 bit value to return with packets",
3139 .next = NEXT(action_mark, NEXT_ENTRY(UNSIGNED)),
3140 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_mark, id)),
3141 .call = parse_vc_conf,
3145 .help = "flag packets",
3146 .priv = PRIV_ACTION(FLAG, 0),
3147 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3152 .help = "assign packets to a given queue index",
3153 .priv = PRIV_ACTION(QUEUE,
3154 sizeof(struct rte_flow_action_queue)),
3155 .next = NEXT(action_queue),
3158 [ACTION_QUEUE_INDEX] = {
3160 .help = "queue index to use",
3161 .next = NEXT(action_queue, NEXT_ENTRY(UNSIGNED)),
3162 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_queue, index)),
3163 .call = parse_vc_conf,
3167 .help = "drop packets (note: passthru has priority)",
3168 .priv = PRIV_ACTION(DROP, 0),
3169 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3174 .help = "enable counters for this rule",
3175 .priv = PRIV_ACTION(COUNT,
3176 sizeof(struct rte_flow_action_count)),
3177 .next = NEXT(action_count),
3180 [ACTION_COUNT_ID] = {
3181 .name = "identifier",
3182 .help = "counter identifier to use",
3183 .next = NEXT(action_count, NEXT_ENTRY(UNSIGNED)),
3184 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_count, id)),
3185 .call = parse_vc_conf,
3187 [ACTION_COUNT_SHARED] = {
3189 .help = "shared counter",
3190 .next = NEXT(action_count, NEXT_ENTRY(BOOLEAN)),
3191 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_count,
3193 .call = parse_vc_conf,
3197 .help = "spread packets among several queues",
3198 .priv = PRIV_ACTION(RSS, sizeof(struct action_rss_data)),
3199 .next = NEXT(action_rss),
3200 .call = parse_vc_action_rss,
3202 [ACTION_RSS_FUNC] = {
3204 .help = "RSS hash function to apply",
3205 .next = NEXT(action_rss,
3206 NEXT_ENTRY(ACTION_RSS_FUNC_DEFAULT,
3207 ACTION_RSS_FUNC_TOEPLITZ,
3208 ACTION_RSS_FUNC_SIMPLE_XOR,
3209 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ)),
3211 [ACTION_RSS_FUNC_DEFAULT] = {
3213 .help = "default hash function",
3214 .call = parse_vc_action_rss_func,
3216 [ACTION_RSS_FUNC_TOEPLITZ] = {
3218 .help = "Toeplitz hash function",
3219 .call = parse_vc_action_rss_func,
3221 [ACTION_RSS_FUNC_SIMPLE_XOR] = {
3222 .name = "simple_xor",
3223 .help = "simple XOR hash function",
3224 .call = parse_vc_action_rss_func,
3226 [ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ] = {
3227 .name = "symmetric_toeplitz",
3228 .help = "Symmetric Toeplitz hash function",
3229 .call = parse_vc_action_rss_func,
3231 [ACTION_RSS_LEVEL] = {
3233 .help = "encapsulation level for \"types\"",
3234 .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
3235 .args = ARGS(ARGS_ENTRY_ARB
3236 (offsetof(struct action_rss_data, conf) +
3237 offsetof(struct rte_flow_action_rss, level),
3238 sizeof(((struct rte_flow_action_rss *)0)->
3241 [ACTION_RSS_TYPES] = {
3243 .help = "specific RSS hash types",
3244 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)),
3246 [ACTION_RSS_TYPE] = {
3248 .help = "RSS hash type",
3249 .call = parse_vc_action_rss_type,
3250 .comp = comp_vc_action_rss_type,
3252 [ACTION_RSS_KEY] = {
3254 .help = "RSS hash key",
3255 .next = NEXT(action_rss, NEXT_ENTRY(HEX)),
3256 .args = ARGS(ARGS_ENTRY_ARB(0, 0),
3258 (offsetof(struct action_rss_data, conf) +
3259 offsetof(struct rte_flow_action_rss, key_len),
3260 sizeof(((struct rte_flow_action_rss *)0)->
3262 ARGS_ENTRY(struct action_rss_data, key)),
3264 [ACTION_RSS_KEY_LEN] = {
3266 .help = "RSS hash key length in bytes",
3267 .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
3268 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
3269 (offsetof(struct action_rss_data, conf) +
3270 offsetof(struct rte_flow_action_rss, key_len),
3271 sizeof(((struct rte_flow_action_rss *)0)->
3274 RSS_HASH_KEY_LENGTH)),
3276 [ACTION_RSS_QUEUES] = {
3278 .help = "queue indices to use",
3279 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_QUEUE)),
3280 .call = parse_vc_conf,
3282 [ACTION_RSS_QUEUE] = {
3284 .help = "queue index",
3285 .call = parse_vc_action_rss_queue,
3286 .comp = comp_vc_action_rss_queue,
3290 .help = "direct traffic to physical function",
3291 .priv = PRIV_ACTION(PF, 0),
3292 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3297 .help = "direct traffic to a virtual function ID",
3298 .priv = PRIV_ACTION(VF, sizeof(struct rte_flow_action_vf)),
3299 .next = NEXT(action_vf),
3302 [ACTION_VF_ORIGINAL] = {
3304 .help = "use original VF ID if possible",
3305 .next = NEXT(action_vf, NEXT_ENTRY(BOOLEAN)),
3306 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_vf,
3308 .call = parse_vc_conf,
3313 .next = NEXT(action_vf, NEXT_ENTRY(UNSIGNED)),
3314 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)),
3315 .call = parse_vc_conf,
3317 [ACTION_PHY_PORT] = {
3319 .help = "direct packets to physical port index",
3320 .priv = PRIV_ACTION(PHY_PORT,
3321 sizeof(struct rte_flow_action_phy_port)),
3322 .next = NEXT(action_phy_port),
3325 [ACTION_PHY_PORT_ORIGINAL] = {
3327 .help = "use original port index if possible",
3328 .next = NEXT(action_phy_port, NEXT_ENTRY(BOOLEAN)),
3329 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_phy_port,
3331 .call = parse_vc_conf,
3333 [ACTION_PHY_PORT_INDEX] = {
3335 .help = "physical port index",
3336 .next = NEXT(action_phy_port, NEXT_ENTRY(UNSIGNED)),
3337 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_phy_port,
3339 .call = parse_vc_conf,
3341 [ACTION_PORT_ID] = {
3343 .help = "direct matching traffic to a given DPDK port ID",
3344 .priv = PRIV_ACTION(PORT_ID,
3345 sizeof(struct rte_flow_action_port_id)),
3346 .next = NEXT(action_port_id),
3349 [ACTION_PORT_ID_ORIGINAL] = {
3351 .help = "use original DPDK port ID if possible",
3352 .next = NEXT(action_port_id, NEXT_ENTRY(BOOLEAN)),
3353 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_port_id,
3355 .call = parse_vc_conf,
3357 [ACTION_PORT_ID_ID] = {
3359 .help = "DPDK port ID",
3360 .next = NEXT(action_port_id, NEXT_ENTRY(UNSIGNED)),
3361 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_port_id, id)),
3362 .call = parse_vc_conf,
3366 .help = "meter the directed packets at given id",
3367 .priv = PRIV_ACTION(METER,
3368 sizeof(struct rte_flow_action_meter)),
3369 .next = NEXT(action_meter),
3372 [ACTION_METER_ID] = {
3374 .help = "meter id to use",
3375 .next = NEXT(action_meter, NEXT_ENTRY(UNSIGNED)),
3376 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter, mtr_id)),
3377 .call = parse_vc_conf,
3379 [ACTION_OF_SET_MPLS_TTL] = {
3380 .name = "of_set_mpls_ttl",
3381 .help = "OpenFlow's OFPAT_SET_MPLS_TTL",
3384 sizeof(struct rte_flow_action_of_set_mpls_ttl)),
3385 .next = NEXT(action_of_set_mpls_ttl),
3388 [ACTION_OF_SET_MPLS_TTL_MPLS_TTL] = {
3391 .next = NEXT(action_of_set_mpls_ttl, NEXT_ENTRY(UNSIGNED)),
3392 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_mpls_ttl,
3394 .call = parse_vc_conf,
3396 [ACTION_OF_DEC_MPLS_TTL] = {
3397 .name = "of_dec_mpls_ttl",
3398 .help = "OpenFlow's OFPAT_DEC_MPLS_TTL",
3399 .priv = PRIV_ACTION(OF_DEC_MPLS_TTL, 0),
3400 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3403 [ACTION_OF_SET_NW_TTL] = {
3404 .name = "of_set_nw_ttl",
3405 .help = "OpenFlow's OFPAT_SET_NW_TTL",
3408 sizeof(struct rte_flow_action_of_set_nw_ttl)),
3409 .next = NEXT(action_of_set_nw_ttl),
3412 [ACTION_OF_SET_NW_TTL_NW_TTL] = {
3415 .next = NEXT(action_of_set_nw_ttl, NEXT_ENTRY(UNSIGNED)),
3416 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_nw_ttl,
3418 .call = parse_vc_conf,
3420 [ACTION_OF_DEC_NW_TTL] = {
3421 .name = "of_dec_nw_ttl",
3422 .help = "OpenFlow's OFPAT_DEC_NW_TTL",
3423 .priv = PRIV_ACTION(OF_DEC_NW_TTL, 0),
3424 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3427 [ACTION_OF_COPY_TTL_OUT] = {
3428 .name = "of_copy_ttl_out",
3429 .help = "OpenFlow's OFPAT_COPY_TTL_OUT",
3430 .priv = PRIV_ACTION(OF_COPY_TTL_OUT, 0),
3431 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3434 [ACTION_OF_COPY_TTL_IN] = {
3435 .name = "of_copy_ttl_in",
3436 .help = "OpenFlow's OFPAT_COPY_TTL_IN",
3437 .priv = PRIV_ACTION(OF_COPY_TTL_IN, 0),
3438 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3441 [ACTION_OF_POP_VLAN] = {
3442 .name = "of_pop_vlan",
3443 .help = "OpenFlow's OFPAT_POP_VLAN",
3444 .priv = PRIV_ACTION(OF_POP_VLAN, 0),
3445 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3448 [ACTION_OF_PUSH_VLAN] = {
3449 .name = "of_push_vlan",
3450 .help = "OpenFlow's OFPAT_PUSH_VLAN",
3453 sizeof(struct rte_flow_action_of_push_vlan)),
3454 .next = NEXT(action_of_push_vlan),
3457 [ACTION_OF_PUSH_VLAN_ETHERTYPE] = {
3458 .name = "ethertype",
3459 .help = "EtherType",
3460 .next = NEXT(action_of_push_vlan, NEXT_ENTRY(UNSIGNED)),
3461 .args = ARGS(ARGS_ENTRY_HTON
3462 (struct rte_flow_action_of_push_vlan,
3464 .call = parse_vc_conf,
3466 [ACTION_OF_SET_VLAN_VID] = {
3467 .name = "of_set_vlan_vid",
3468 .help = "OpenFlow's OFPAT_SET_VLAN_VID",
3471 sizeof(struct rte_flow_action_of_set_vlan_vid)),
3472 .next = NEXT(action_of_set_vlan_vid),
3475 [ACTION_OF_SET_VLAN_VID_VLAN_VID] = {
3478 .next = NEXT(action_of_set_vlan_vid, NEXT_ENTRY(UNSIGNED)),
3479 .args = ARGS(ARGS_ENTRY_HTON
3480 (struct rte_flow_action_of_set_vlan_vid,
3482 .call = parse_vc_conf,
3484 [ACTION_OF_SET_VLAN_PCP] = {
3485 .name = "of_set_vlan_pcp",
3486 .help = "OpenFlow's OFPAT_SET_VLAN_PCP",
3489 sizeof(struct rte_flow_action_of_set_vlan_pcp)),
3490 .next = NEXT(action_of_set_vlan_pcp),
3493 [ACTION_OF_SET_VLAN_PCP_VLAN_PCP] = {
3495 .help = "VLAN priority",
3496 .next = NEXT(action_of_set_vlan_pcp, NEXT_ENTRY(UNSIGNED)),
3497 .args = ARGS(ARGS_ENTRY_HTON
3498 (struct rte_flow_action_of_set_vlan_pcp,
3500 .call = parse_vc_conf,
3502 [ACTION_OF_POP_MPLS] = {
3503 .name = "of_pop_mpls",
3504 .help = "OpenFlow's OFPAT_POP_MPLS",
3505 .priv = PRIV_ACTION(OF_POP_MPLS,
3506 sizeof(struct rte_flow_action_of_pop_mpls)),
3507 .next = NEXT(action_of_pop_mpls),
3510 [ACTION_OF_POP_MPLS_ETHERTYPE] = {
3511 .name = "ethertype",
3512 .help = "EtherType",
3513 .next = NEXT(action_of_pop_mpls, NEXT_ENTRY(UNSIGNED)),
3514 .args = ARGS(ARGS_ENTRY_HTON
3515 (struct rte_flow_action_of_pop_mpls,
3517 .call = parse_vc_conf,
3519 [ACTION_OF_PUSH_MPLS] = {
3520 .name = "of_push_mpls",
3521 .help = "OpenFlow's OFPAT_PUSH_MPLS",
3524 sizeof(struct rte_flow_action_of_push_mpls)),
3525 .next = NEXT(action_of_push_mpls),
3528 [ACTION_OF_PUSH_MPLS_ETHERTYPE] = {
3529 .name = "ethertype",
3530 .help = "EtherType",
3531 .next = NEXT(action_of_push_mpls, NEXT_ENTRY(UNSIGNED)),
3532 .args = ARGS(ARGS_ENTRY_HTON
3533 (struct rte_flow_action_of_push_mpls,
3535 .call = parse_vc_conf,
3537 [ACTION_VXLAN_ENCAP] = {
3538 .name = "vxlan_encap",
3539 .help = "VXLAN encapsulation, uses configuration set by \"set"
3541 .priv = PRIV_ACTION(VXLAN_ENCAP,
3542 sizeof(struct action_vxlan_encap_data)),
3543 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3544 .call = parse_vc_action_vxlan_encap,
3546 [ACTION_VXLAN_DECAP] = {
3547 .name = "vxlan_decap",
3548 .help = "Performs a decapsulation action by stripping all"
3549 " headers of the VXLAN tunnel network overlay from the"
3551 .priv = PRIV_ACTION(VXLAN_DECAP, 0),
3552 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3555 [ACTION_NVGRE_ENCAP] = {
3556 .name = "nvgre_encap",
3557 .help = "NVGRE encapsulation, uses configuration set by \"set"
3559 .priv = PRIV_ACTION(NVGRE_ENCAP,
3560 sizeof(struct action_nvgre_encap_data)),
3561 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3562 .call = parse_vc_action_nvgre_encap,
3564 [ACTION_NVGRE_DECAP] = {
3565 .name = "nvgre_decap",
3566 .help = "Performs a decapsulation action by stripping all"
3567 " headers of the NVGRE tunnel network overlay from the"
3569 .priv = PRIV_ACTION(NVGRE_DECAP, 0),
3570 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3573 [ACTION_L2_ENCAP] = {
3575 .help = "l2 encap, uses configuration set by"
3576 " \"set l2_encap\"",
3577 .priv = PRIV_ACTION(RAW_ENCAP,
3578 sizeof(struct action_raw_encap_data)),
3579 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3580 .call = parse_vc_action_l2_encap,
3582 [ACTION_L2_DECAP] = {
3584 .help = "l2 decap, uses configuration set by"
3585 " \"set l2_decap\"",
3586 .priv = PRIV_ACTION(RAW_DECAP,
3587 sizeof(struct action_raw_decap_data)),
3588 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3589 .call = parse_vc_action_l2_decap,
3591 [ACTION_MPLSOGRE_ENCAP] = {
3592 .name = "mplsogre_encap",
3593 .help = "mplsogre encapsulation, uses configuration set by"
3594 " \"set mplsogre_encap\"",
3595 .priv = PRIV_ACTION(RAW_ENCAP,
3596 sizeof(struct action_raw_encap_data)),
3597 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3598 .call = parse_vc_action_mplsogre_encap,
3600 [ACTION_MPLSOGRE_DECAP] = {
3601 .name = "mplsogre_decap",
3602 .help = "mplsogre decapsulation, uses configuration set by"
3603 " \"set mplsogre_decap\"",
3604 .priv = PRIV_ACTION(RAW_DECAP,
3605 sizeof(struct action_raw_decap_data)),
3606 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3607 .call = parse_vc_action_mplsogre_decap,
3609 [ACTION_MPLSOUDP_ENCAP] = {
3610 .name = "mplsoudp_encap",
3611 .help = "mplsoudp encapsulation, uses configuration set by"
3612 " \"set mplsoudp_encap\"",
3613 .priv = PRIV_ACTION(RAW_ENCAP,
3614 sizeof(struct action_raw_encap_data)),
3615 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3616 .call = parse_vc_action_mplsoudp_encap,
3618 [ACTION_MPLSOUDP_DECAP] = {
3619 .name = "mplsoudp_decap",
3620 .help = "mplsoudp decapsulation, uses configuration set by"
3621 " \"set mplsoudp_decap\"",
3622 .priv = PRIV_ACTION(RAW_DECAP,
3623 sizeof(struct action_raw_decap_data)),
3624 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3625 .call = parse_vc_action_mplsoudp_decap,
3627 [ACTION_SET_IPV4_SRC] = {
3628 .name = "set_ipv4_src",
3629 .help = "Set a new IPv4 source address in the outermost"
3631 .priv = PRIV_ACTION(SET_IPV4_SRC,
3632 sizeof(struct rte_flow_action_set_ipv4)),
3633 .next = NEXT(action_set_ipv4_src),
3636 [ACTION_SET_IPV4_SRC_IPV4_SRC] = {
3637 .name = "ipv4_addr",
3638 .help = "new IPv4 source address to set",
3639 .next = NEXT(action_set_ipv4_src, NEXT_ENTRY(IPV4_ADDR)),
3640 .args = ARGS(ARGS_ENTRY_HTON
3641 (struct rte_flow_action_set_ipv4, ipv4_addr)),
3642 .call = parse_vc_conf,
3644 [ACTION_SET_IPV4_DST] = {
3645 .name = "set_ipv4_dst",
3646 .help = "Set a new IPv4 destination address in the outermost"
3648 .priv = PRIV_ACTION(SET_IPV4_DST,
3649 sizeof(struct rte_flow_action_set_ipv4)),
3650 .next = NEXT(action_set_ipv4_dst),
3653 [ACTION_SET_IPV4_DST_IPV4_DST] = {
3654 .name = "ipv4_addr",
3655 .help = "new IPv4 destination address to set",
3656 .next = NEXT(action_set_ipv4_dst, NEXT_ENTRY(IPV4_ADDR)),
3657 .args = ARGS(ARGS_ENTRY_HTON
3658 (struct rte_flow_action_set_ipv4, ipv4_addr)),
3659 .call = parse_vc_conf,
3661 [ACTION_SET_IPV6_SRC] = {
3662 .name = "set_ipv6_src",
3663 .help = "Set a new IPv6 source address in the outermost"
3665 .priv = PRIV_ACTION(SET_IPV6_SRC,
3666 sizeof(struct rte_flow_action_set_ipv6)),
3667 .next = NEXT(action_set_ipv6_src),
3670 [ACTION_SET_IPV6_SRC_IPV6_SRC] = {
3671 .name = "ipv6_addr",
3672 .help = "new IPv6 source address to set",
3673 .next = NEXT(action_set_ipv6_src, NEXT_ENTRY(IPV6_ADDR)),
3674 .args = ARGS(ARGS_ENTRY_HTON
3675 (struct rte_flow_action_set_ipv6, ipv6_addr)),
3676 .call = parse_vc_conf,
3678 [ACTION_SET_IPV6_DST] = {
3679 .name = "set_ipv6_dst",
3680 .help = "Set a new IPv6 destination address in the outermost"
3682 .priv = PRIV_ACTION(SET_IPV6_DST,
3683 sizeof(struct rte_flow_action_set_ipv6)),
3684 .next = NEXT(action_set_ipv6_dst),
3687 [ACTION_SET_IPV6_DST_IPV6_DST] = {
3688 .name = "ipv6_addr",
3689 .help = "new IPv6 destination address to set",
3690 .next = NEXT(action_set_ipv6_dst, NEXT_ENTRY(IPV6_ADDR)),
3691 .args = ARGS(ARGS_ENTRY_HTON
3692 (struct rte_flow_action_set_ipv6, ipv6_addr)),
3693 .call = parse_vc_conf,
3695 [ACTION_SET_TP_SRC] = {
3696 .name = "set_tp_src",
3697 .help = "set a new source port number in the outermost"
3699 .priv = PRIV_ACTION(SET_TP_SRC,
3700 sizeof(struct rte_flow_action_set_tp)),
3701 .next = NEXT(action_set_tp_src),
3704 [ACTION_SET_TP_SRC_TP_SRC] = {
3706 .help = "new source port number to set",
3707 .next = NEXT(action_set_tp_src, NEXT_ENTRY(UNSIGNED)),
3708 .args = ARGS(ARGS_ENTRY_HTON
3709 (struct rte_flow_action_set_tp, port)),
3710 .call = parse_vc_conf,
3712 [ACTION_SET_TP_DST] = {
3713 .name = "set_tp_dst",
3714 .help = "set a new destination port number in the outermost"
3716 .priv = PRIV_ACTION(SET_TP_DST,
3717 sizeof(struct rte_flow_action_set_tp)),
3718 .next = NEXT(action_set_tp_dst),
3721 [ACTION_SET_TP_DST_TP_DST] = {
3723 .help = "new destination port number to set",
3724 .next = NEXT(action_set_tp_dst, NEXT_ENTRY(UNSIGNED)),
3725 .args = ARGS(ARGS_ENTRY_HTON
3726 (struct rte_flow_action_set_tp, port)),
3727 .call = parse_vc_conf,
3729 [ACTION_MAC_SWAP] = {
3731 .help = "Swap the source and destination MAC addresses"
3732 " in the outermost Ethernet header",
3733 .priv = PRIV_ACTION(MAC_SWAP, 0),
3734 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3737 [ACTION_DEC_TTL] = {
3739 .help = "decrease network TTL if available",
3740 .priv = PRIV_ACTION(DEC_TTL, 0),
3741 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3744 [ACTION_SET_TTL] = {
3746 .help = "set ttl value",
3747 .priv = PRIV_ACTION(SET_TTL,
3748 sizeof(struct rte_flow_action_set_ttl)),
3749 .next = NEXT(action_set_ttl),
3752 [ACTION_SET_TTL_TTL] = {
3753 .name = "ttl_value",
3754 .help = "new ttl value to set",
3755 .next = NEXT(action_set_ttl, NEXT_ENTRY(UNSIGNED)),
3756 .args = ARGS(ARGS_ENTRY_HTON
3757 (struct rte_flow_action_set_ttl, ttl_value)),
3758 .call = parse_vc_conf,
3760 [ACTION_SET_MAC_SRC] = {
3761 .name = "set_mac_src",
3762 .help = "set source mac address",
3763 .priv = PRIV_ACTION(SET_MAC_SRC,
3764 sizeof(struct rte_flow_action_set_mac)),
3765 .next = NEXT(action_set_mac_src),
3768 [ACTION_SET_MAC_SRC_MAC_SRC] = {
3770 .help = "new source mac address",
3771 .next = NEXT(action_set_mac_src, NEXT_ENTRY(MAC_ADDR)),
3772 .args = ARGS(ARGS_ENTRY_HTON
3773 (struct rte_flow_action_set_mac, mac_addr)),
3774 .call = parse_vc_conf,
3776 [ACTION_SET_MAC_DST] = {
3777 .name = "set_mac_dst",
3778 .help = "set destination mac address",
3779 .priv = PRIV_ACTION(SET_MAC_DST,
3780 sizeof(struct rte_flow_action_set_mac)),
3781 .next = NEXT(action_set_mac_dst),
3784 [ACTION_SET_MAC_DST_MAC_DST] = {
3786 .help = "new destination mac address to set",
3787 .next = NEXT(action_set_mac_dst, NEXT_ENTRY(MAC_ADDR)),
3788 .args = ARGS(ARGS_ENTRY_HTON
3789 (struct rte_flow_action_set_mac, mac_addr)),
3790 .call = parse_vc_conf,
3792 [ACTION_INC_TCP_SEQ] = {
3793 .name = "inc_tcp_seq",
3794 .help = "increase TCP sequence number",
3795 .priv = PRIV_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
3796 .next = NEXT(action_inc_tcp_seq),
3799 [ACTION_INC_TCP_SEQ_VALUE] = {
3801 .help = "the value to increase TCP sequence number by",
3802 .next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(UNSIGNED)),
3803 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3804 .call = parse_vc_conf,
3806 [ACTION_DEC_TCP_SEQ] = {
3807 .name = "dec_tcp_seq",
3808 .help = "decrease TCP sequence number",
3809 .priv = PRIV_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
3810 .next = NEXT(action_dec_tcp_seq),
3813 [ACTION_DEC_TCP_SEQ_VALUE] = {
3815 .help = "the value to decrease TCP sequence number by",
3816 .next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(UNSIGNED)),
3817 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3818 .call = parse_vc_conf,
3820 [ACTION_INC_TCP_ACK] = {
3821 .name = "inc_tcp_ack",
3822 .help = "increase TCP acknowledgment number",
3823 .priv = PRIV_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
3824 .next = NEXT(action_inc_tcp_ack),
3827 [ACTION_INC_TCP_ACK_VALUE] = {
3829 .help = "the value to increase TCP acknowledgment number by",
3830 .next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(UNSIGNED)),
3831 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3832 .call = parse_vc_conf,
3834 [ACTION_DEC_TCP_ACK] = {
3835 .name = "dec_tcp_ack",
3836 .help = "decrease TCP acknowledgment number",
3837 .priv = PRIV_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
3838 .next = NEXT(action_dec_tcp_ack),
3841 [ACTION_DEC_TCP_ACK_VALUE] = {
3843 .help = "the value to decrease TCP acknowledgment number by",
3844 .next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(UNSIGNED)),
3845 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3846 .call = parse_vc_conf,
3848 [ACTION_RAW_ENCAP] = {
3849 .name = "raw_encap",
3850 .help = "encapsulation data, defined by set raw_encap",
3851 .priv = PRIV_ACTION(RAW_ENCAP,
3852 sizeof(struct action_raw_encap_data)),
3853 .next = NEXT(action_raw_encap),
3854 .call = parse_vc_action_raw_encap,
3856 [ACTION_RAW_ENCAP_INDEX] = {
3858 .help = "the index of raw_encap_confs",
3859 .next = NEXT(NEXT_ENTRY(ACTION_RAW_ENCAP_INDEX_VALUE)),
3861 [ACTION_RAW_ENCAP_INDEX_VALUE] = {
3864 .help = "unsigned integer value",
3865 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3866 .call = parse_vc_action_raw_encap_index,
3867 .comp = comp_set_raw_index,
3869 [ACTION_RAW_DECAP] = {
3870 .name = "raw_decap",
3871 .help = "decapsulation data, defined by set raw_encap",
3872 .priv = PRIV_ACTION(RAW_DECAP,
3873 sizeof(struct action_raw_decap_data)),
3874 .next = NEXT(action_raw_decap),
3875 .call = parse_vc_action_raw_decap,
3877 [ACTION_RAW_DECAP_INDEX] = {
3879 .help = "the index of raw_encap_confs",
3880 .next = NEXT(NEXT_ENTRY(ACTION_RAW_DECAP_INDEX_VALUE)),
3882 [ACTION_RAW_DECAP_INDEX_VALUE] = {
3885 .help = "unsigned integer value",
3886 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3887 .call = parse_vc_action_raw_decap_index,
3888 .comp = comp_set_raw_index,
3890 /* Top level command. */
3893 .help = "set raw encap/decap/sample data",
3894 .type = "set raw_encap|raw_decap <index> <pattern>"
3895 " or set sample_actions <index> <action>",
3896 .next = NEXT(NEXT_ENTRY
3899 SET_SAMPLE_ACTIONS)),
3900 .call = parse_set_init,
3902 /* Sub-level commands. */
3904 .name = "raw_encap",
3905 .help = "set raw encap data",
3906 .next = NEXT(next_set_raw),
3907 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
3908 (offsetof(struct buffer, port),
3909 sizeof(((struct buffer *)0)->port),
3910 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
3911 .call = parse_set_raw_encap_decap,
3914 .name = "raw_decap",
3915 .help = "set raw decap data",
3916 .next = NEXT(next_set_raw),
3917 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
3918 (offsetof(struct buffer, port),
3919 sizeof(((struct buffer *)0)->port),
3920 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
3921 .call = parse_set_raw_encap_decap,
3926 .help = "index of raw_encap/raw_decap data",
3927 .next = NEXT(next_item),
3930 [SET_SAMPLE_INDEX] = {
3933 .help = "index of sample actions",
3934 .next = NEXT(next_action_sample),
3937 [SET_SAMPLE_ACTIONS] = {
3938 .name = "sample_actions",
3939 .help = "set sample actions list",
3940 .next = NEXT(NEXT_ENTRY(SET_SAMPLE_INDEX)),
3941 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
3942 (offsetof(struct buffer, port),
3943 sizeof(((struct buffer *)0)->port),
3944 0, RAW_SAMPLE_CONFS_MAX_NUM - 1)),
3945 .call = parse_set_sample_action,
3947 [ACTION_SET_TAG] = {
3950 .priv = PRIV_ACTION(SET_TAG,
3951 sizeof(struct rte_flow_action_set_tag)),
3952 .next = NEXT(action_set_tag),
3955 [ACTION_SET_TAG_INDEX] = {
3957 .help = "index of tag array",
3958 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
3959 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_set_tag, index)),
3960 .call = parse_vc_conf,
3962 [ACTION_SET_TAG_DATA] = {
3964 .help = "tag value",
3965 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
3966 .args = ARGS(ARGS_ENTRY
3967 (struct rte_flow_action_set_tag, data)),
3968 .call = parse_vc_conf,
3970 [ACTION_SET_TAG_MASK] = {
3972 .help = "mask for tag value",
3973 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
3974 .args = ARGS(ARGS_ENTRY
3975 (struct rte_flow_action_set_tag, mask)),
3976 .call = parse_vc_conf,
3978 [ACTION_SET_META] = {
3980 .help = "set metadata",
3981 .priv = PRIV_ACTION(SET_META,
3982 sizeof(struct rte_flow_action_set_meta)),
3983 .next = NEXT(action_set_meta),
3984 .call = parse_vc_action_set_meta,
3986 [ACTION_SET_META_DATA] = {
3988 .help = "metadata value",
3989 .next = NEXT(action_set_meta, NEXT_ENTRY(UNSIGNED)),
3990 .args = ARGS(ARGS_ENTRY
3991 (struct rte_flow_action_set_meta, data)),
3992 .call = parse_vc_conf,
3994 [ACTION_SET_META_MASK] = {
3996 .help = "mask for metadata value",
3997 .next = NEXT(action_set_meta, NEXT_ENTRY(UNSIGNED)),
3998 .args = ARGS(ARGS_ENTRY
3999 (struct rte_flow_action_set_meta, mask)),
4000 .call = parse_vc_conf,
4002 [ACTION_SET_IPV4_DSCP] = {
4003 .name = "set_ipv4_dscp",
4004 .help = "set DSCP value",
4005 .priv = PRIV_ACTION(SET_IPV4_DSCP,
4006 sizeof(struct rte_flow_action_set_dscp)),
4007 .next = NEXT(action_set_ipv4_dscp),
4010 [ACTION_SET_IPV4_DSCP_VALUE] = {
4011 .name = "dscp_value",
4012 .help = "new IPv4 DSCP value to set",
4013 .next = NEXT(action_set_ipv4_dscp, NEXT_ENTRY(UNSIGNED)),
4014 .args = ARGS(ARGS_ENTRY
4015 (struct rte_flow_action_set_dscp, dscp)),
4016 .call = parse_vc_conf,
4018 [ACTION_SET_IPV6_DSCP] = {
4019 .name = "set_ipv6_dscp",
4020 .help = "set DSCP value",
4021 .priv = PRIV_ACTION(SET_IPV6_DSCP,
4022 sizeof(struct rte_flow_action_set_dscp)),
4023 .next = NEXT(action_set_ipv6_dscp),
4026 [ACTION_SET_IPV6_DSCP_VALUE] = {
4027 .name = "dscp_value",
4028 .help = "new IPv6 DSCP value to set",
4029 .next = NEXT(action_set_ipv6_dscp, NEXT_ENTRY(UNSIGNED)),
4030 .args = ARGS(ARGS_ENTRY
4031 (struct rte_flow_action_set_dscp, dscp)),
4032 .call = parse_vc_conf,
4036 .help = "set a specific metadata header",
4037 .next = NEXT(action_age),
4038 .priv = PRIV_ACTION(AGE,
4039 sizeof(struct rte_flow_action_age)),
4042 [ACTION_AGE_TIMEOUT] = {
4044 .help = "flow age timeout value",
4045 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_age,
4047 .next = NEXT(action_age, NEXT_ENTRY(UNSIGNED)),
4048 .call = parse_vc_conf,
4052 .help = "set a sample action",
4053 .next = NEXT(action_sample),
4054 .priv = PRIV_ACTION(SAMPLE,
4055 sizeof(struct action_sample_data)),
4056 .call = parse_vc_action_sample,
4058 [ACTION_SAMPLE_RATIO] = {
4060 .help = "flow sample ratio value",
4061 .next = NEXT(action_sample, NEXT_ENTRY(UNSIGNED)),
4062 .args = ARGS(ARGS_ENTRY_ARB
4063 (offsetof(struct action_sample_data, conf) +
4064 offsetof(struct rte_flow_action_sample, ratio),
4065 sizeof(((struct rte_flow_action_sample *)0)->
4068 [ACTION_SAMPLE_INDEX] = {
4070 .help = "the index of sample actions list",
4071 .next = NEXT(NEXT_ENTRY(ACTION_SAMPLE_INDEX_VALUE)),
4073 [ACTION_SAMPLE_INDEX_VALUE] = {
4076 .help = "unsigned integer value",
4077 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4078 .call = parse_vc_action_sample_index,
4079 .comp = comp_set_sample_index,
4081 /* Shared action destroy arguments. */
4082 [SHARED_ACTION_DESTROY_ID] = {
4083 .name = "action_id",
4084 .help = "specify a shared action id to destroy",
4085 .next = NEXT(next_sa_destroy_attr,
4086 NEXT_ENTRY(SHARED_ACTION_ID)),
4087 .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
4088 args.sa_destroy.action_id)),
4089 .call = parse_sa_destroy,
4091 /* Shared action create arguments. */
4092 [SHARED_ACTION_CREATE_ID] = {
4093 .name = "action_id",
4094 .help = "specify a shared action id to create",
4095 .next = NEXT(next_sa_create_attr,
4096 NEXT_ENTRY(SHARED_ACTION_ID)),
4097 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
4101 .help = "apply shared action by id",
4102 .priv = PRIV_ACTION(SHARED, 0),
4103 .next = NEXT(NEXT_ENTRY(SHARED_ACTION_ID2PTR)),
4104 .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
4107 [SHARED_ACTION_ID2PTR] = {
4108 .name = "{action_id}",
4109 .type = "SHARED_ACTION_ID",
4110 .help = "shared action id",
4111 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4112 .call = parse_sa_id2ptr,
4115 [SHARED_ACTION_INGRESS] = {
4117 .help = "affect rule to ingress",
4118 .next = NEXT(next_sa_create_attr),
4121 [SHARED_ACTION_EGRESS] = {
4123 .help = "affect rule to egress",
4124 .next = NEXT(next_sa_create_attr),
4127 [SHARED_ACTION_SPEC] = {
4129 .help = "specify action to share",
4130 .next = NEXT(next_action),
4134 /** Remove and return last entry from argument stack. */
4135 static const struct arg *
4136 pop_args(struct context *ctx)
4138 return ctx->args_num ? ctx->args[--ctx->args_num] : NULL;
4141 /** Add entry on top of the argument stack. */
4143 push_args(struct context *ctx, const struct arg *arg)
4145 if (ctx->args_num == CTX_STACK_SIZE)
4147 ctx->args[ctx->args_num++] = arg;
4151 /** Spread value into buffer according to bit-mask. */
4153 arg_entry_bf_fill(void *dst, uintmax_t val, const struct arg *arg)
4155 uint32_t i = arg->size;
4163 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
4172 unsigned int shift = 0;
4173 uint8_t *buf = (uint8_t *)dst + arg->offset + (i -= sub);
4175 for (shift = 0; arg->mask[i] >> shift; ++shift) {
4176 if (!(arg->mask[i] & (1 << shift)))
4181 *buf &= ~(1 << shift);
4182 *buf |= (val & 1) << shift;
4190 /** Compare a string with a partial one of a given length. */
4192 strcmp_partial(const char *full, const char *partial, size_t partial_len)
4194 int r = strncmp(full, partial, partial_len);
4198 if (strlen(full) <= partial_len)
4200 return full[partial_len];
4204 * Parse a prefix length and generate a bit-mask.
4206 * Last argument (ctx->args) is retrieved to determine mask size, storage
4207 * location and whether the result must use network byte ordering.
4210 parse_prefix(struct context *ctx, const struct token *token,
4211 const char *str, unsigned int len,
4212 void *buf, unsigned int size)
4214 const struct arg *arg = pop_args(ctx);
4215 static const uint8_t conv[] = "\x00\x80\xc0\xe0\xf0\xf8\xfc\xfe\xff";
4222 /* Argument is expected. */
4226 u = strtoumax(str, &end, 0);
4227 if (errno || (size_t)(end - str) != len)
4232 extra = arg_entry_bf_fill(NULL, 0, arg);
4241 if (!arg_entry_bf_fill(ctx->object, v, arg) ||
4242 !arg_entry_bf_fill(ctx->objmask, -1, arg))
4249 if (bytes > size || bytes + !!extra > size)
4253 buf = (uint8_t *)ctx->object + arg->offset;
4254 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
4256 memset((uint8_t *)buf + size - bytes, 0xff, bytes);
4257 memset(buf, 0x00, size - bytes);
4259 ((uint8_t *)buf)[size - bytes - 1] = conv[extra];
4263 memset(buf, 0xff, bytes);
4264 memset((uint8_t *)buf + bytes, 0x00, size - bytes);
4266 ((uint8_t *)buf)[bytes] = conv[extra];
4269 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
4272 push_args(ctx, arg);
4276 /** Default parsing function for token name matching. */
4278 parse_default(struct context *ctx, const struct token *token,
4279 const char *str, unsigned int len,
4280 void *buf, unsigned int size)
4285 if (strcmp_partial(token->name, str, len))
4290 /** Parse flow command, initialize output buffer for subsequent tokens. */
4292 parse_init(struct context *ctx, const struct token *token,
4293 const char *str, unsigned int len,
4294 void *buf, unsigned int size)
4296 struct buffer *out = buf;
4298 /* Token name must match. */
4299 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4301 /* Nothing else to do if there is no buffer. */
4304 /* Make sure buffer is large enough. */
4305 if (size < sizeof(*out))
4307 /* Initialize buffer. */
4308 memset(out, 0x00, sizeof(*out));
4309 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
4312 ctx->objmask = NULL;
4316 /** Parse tokens for shared action commands. */
4318 parse_sa(struct context *ctx, const struct token *token,
4319 const char *str, unsigned int len,
4320 void *buf, unsigned int size)
4322 struct buffer *out = buf;
4324 /* Token name must match. */
4325 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4327 /* Nothing else to do if there is no buffer. */
4330 if (!out->command) {
4331 if (ctx->curr != SHARED_ACTION)
4333 if (sizeof(*out) > size)
4335 out->command = ctx->curr;
4338 ctx->objmask = NULL;
4339 out->args.vc.data = (uint8_t *)out + size;
4342 switch (ctx->curr) {
4343 case SHARED_ACTION_CREATE:
4344 case SHARED_ACTION_UPDATE:
4345 out->args.vc.actions =
4346 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
4348 out->args.vc.attr.group = UINT32_MAX;
4350 case SHARED_ACTION_QUERY:
4351 out->command = ctx->curr;
4354 ctx->objmask = NULL;
4356 case SHARED_ACTION_EGRESS:
4357 out->args.vc.attr.egress = 1;
4359 case SHARED_ACTION_INGRESS:
4360 out->args.vc.attr.ingress = 1;
4368 /** Parse tokens for shared action destroy command. */
4370 parse_sa_destroy(struct context *ctx, const struct token *token,
4371 const char *str, unsigned int len,
4372 void *buf, unsigned int size)
4374 struct buffer *out = buf;
4375 uint32_t *action_id;
4377 /* Token name must match. */
4378 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4380 /* Nothing else to do if there is no buffer. */
4383 if (!out->command || out->command == SHARED_ACTION) {
4384 if (ctx->curr != SHARED_ACTION_DESTROY)
4386 if (sizeof(*out) > size)
4388 out->command = ctx->curr;
4391 ctx->objmask = NULL;
4392 out->args.sa_destroy.action_id =
4393 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
4397 action_id = out->args.sa_destroy.action_id
4398 + out->args.sa_destroy.action_id_n++;
4399 if ((uint8_t *)action_id > (uint8_t *)out + size)
4402 ctx->object = action_id;
4403 ctx->objmask = NULL;
4407 /** Parse tokens for validate/create commands. */
4409 parse_vc(struct context *ctx, const struct token *token,
4410 const char *str, unsigned int len,
4411 void *buf, unsigned int size)
4413 struct buffer *out = buf;
4417 /* Token name must match. */
4418 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4420 /* Nothing else to do if there is no buffer. */
4423 if (!out->command) {
4424 if (ctx->curr != VALIDATE && ctx->curr != CREATE)
4426 if (sizeof(*out) > size)
4428 out->command = ctx->curr;
4431 ctx->objmask = NULL;
4432 out->args.vc.data = (uint8_t *)out + size;
4436 ctx->object = &out->args.vc.attr;
4437 ctx->objmask = NULL;
4438 switch (ctx->curr) {
4443 out->args.vc.attr.ingress = 1;
4446 out->args.vc.attr.egress = 1;
4449 out->args.vc.attr.transfer = 1;
4452 out->args.vc.pattern =
4453 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
4455 ctx->object = out->args.vc.pattern;
4456 ctx->objmask = NULL;
4459 out->args.vc.actions =
4460 (void *)RTE_ALIGN_CEIL((uintptr_t)
4461 (out->args.vc.pattern +
4462 out->args.vc.pattern_n),
4464 ctx->object = out->args.vc.actions;
4465 ctx->objmask = NULL;
4472 if (!out->args.vc.actions) {
4473 const struct parse_item_priv *priv = token->priv;
4474 struct rte_flow_item *item =
4475 out->args.vc.pattern + out->args.vc.pattern_n;
4477 data_size = priv->size * 3; /* spec, last, mask */
4478 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
4479 (out->args.vc.data - data_size),
4481 if ((uint8_t *)item + sizeof(*item) > data)
4483 *item = (struct rte_flow_item){
4486 ++out->args.vc.pattern_n;
4488 ctx->objmask = NULL;
4490 const struct parse_action_priv *priv = token->priv;
4491 struct rte_flow_action *action =
4492 out->args.vc.actions + out->args.vc.actions_n;
4494 data_size = priv->size; /* configuration */
4495 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
4496 (out->args.vc.data - data_size),
4498 if ((uint8_t *)action + sizeof(*action) > data)
4500 *action = (struct rte_flow_action){
4502 .conf = data_size ? data : NULL,
4504 ++out->args.vc.actions_n;
4505 ctx->object = action;
4506 ctx->objmask = NULL;
4508 memset(data, 0, data_size);
4509 out->args.vc.data = data;
4510 ctx->objdata = data_size;
4514 /** Parse pattern item parameter type. */
4516 parse_vc_spec(struct context *ctx, const struct token *token,
4517 const char *str, unsigned int len,
4518 void *buf, unsigned int size)
4520 struct buffer *out = buf;
4521 struct rte_flow_item *item;
4527 /* Token name must match. */
4528 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4530 /* Parse parameter types. */
4531 switch (ctx->curr) {
4532 static const enum index prefix[] = NEXT_ENTRY(PREFIX);
4538 case ITEM_PARAM_SPEC:
4541 case ITEM_PARAM_LAST:
4544 case ITEM_PARAM_PREFIX:
4545 /* Modify next token to expect a prefix. */
4546 if (ctx->next_num < 2)
4548 ctx->next[ctx->next_num - 2] = prefix;
4550 case ITEM_PARAM_MASK:
4556 /* Nothing else to do if there is no buffer. */
4559 if (!out->args.vc.pattern_n)
4561 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
4562 data_size = ctx->objdata / 3; /* spec, last, mask */
4563 /* Point to selected object. */
4564 ctx->object = out->args.vc.data + (data_size * index);
4566 ctx->objmask = out->args.vc.data + (data_size * 2); /* mask */
4567 item->mask = ctx->objmask;
4569 ctx->objmask = NULL;
4570 /* Update relevant item pointer. */
4571 *((const void **[]){ &item->spec, &item->last, &item->mask })[index] =
4576 /** Parse action configuration field. */
4578 parse_vc_conf(struct context *ctx, const struct token *token,
4579 const char *str, unsigned int len,
4580 void *buf, unsigned int size)
4582 struct buffer *out = buf;
4585 /* Token name must match. */
4586 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4588 /* Nothing else to do if there is no buffer. */
4591 /* Point to selected object. */
4592 ctx->object = out->args.vc.data;
4593 ctx->objmask = NULL;
4597 /** Parse eCPRI common header type field. */
4599 parse_vc_item_ecpri_type(struct context *ctx, const struct token *token,
4600 const char *str, unsigned int len,
4601 void *buf, unsigned int size)
4603 struct rte_flow_item_ecpri *ecpri;
4604 struct rte_flow_item_ecpri *ecpri_mask;
4605 struct rte_flow_item *item;
4608 struct buffer *out = buf;
4609 const struct arg *arg;
4612 /* Token name must match. */
4613 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4615 switch (ctx->curr) {
4616 case ITEM_ECPRI_COMMON_TYPE_IQ_DATA:
4617 msg_type = RTE_ECPRI_MSG_TYPE_IQ_DATA;
4619 case ITEM_ECPRI_COMMON_TYPE_RTC_CTRL:
4620 msg_type = RTE_ECPRI_MSG_TYPE_RTC_CTRL;
4622 case ITEM_ECPRI_COMMON_TYPE_DLY_MSR:
4623 msg_type = RTE_ECPRI_MSG_TYPE_DLY_MSR;
4630 arg = pop_args(ctx);
4633 ecpri = (struct rte_flow_item_ecpri *)out->args.vc.data;
4634 ecpri->hdr.common.type = msg_type;
4635 data_size = ctx->objdata / 3; /* spec, last, mask */
4636 ecpri_mask = (struct rte_flow_item_ecpri *)(out->args.vc.data +
4638 ecpri_mask->hdr.common.type = 0xFF;
4640 ecpri->hdr.common.u32 = rte_cpu_to_be_32(ecpri->hdr.common.u32);
4641 ecpri_mask->hdr.common.u32 =
4642 rte_cpu_to_be_32(ecpri_mask->hdr.common.u32);
4644 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
4646 item->mask = ecpri_mask;
4650 /** Parse RSS action. */
4652 parse_vc_action_rss(struct context *ctx, const struct token *token,
4653 const char *str, unsigned int len,
4654 void *buf, unsigned int size)
4656 struct buffer *out = buf;
4657 struct rte_flow_action *action;
4658 struct action_rss_data *action_rss_data;
4662 ret = parse_vc(ctx, token, str, len, buf, size);
4665 /* Nothing else to do if there is no buffer. */
4668 if (!out->args.vc.actions_n)
4670 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4671 /* Point to selected object. */
4672 ctx->object = out->args.vc.data;
4673 ctx->objmask = NULL;
4674 /* Set up default configuration. */
4675 action_rss_data = ctx->object;
4676 *action_rss_data = (struct action_rss_data){
4677 .conf = (struct rte_flow_action_rss){
4678 .func = RTE_ETH_HASH_FUNCTION_DEFAULT,
4681 .key_len = sizeof(action_rss_data->key),
4682 .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM),
4683 .key = action_rss_data->key,
4684 .queue = action_rss_data->queue,
4686 .key = "testpmd's default RSS hash key, "
4687 "override it for better balancing",
4690 for (i = 0; i < action_rss_data->conf.queue_num; ++i)
4691 action_rss_data->queue[i] = i;
4692 if (!port_id_is_invalid(ctx->port, DISABLED_WARN) &&
4693 ctx->port != (portid_t)RTE_PORT_ALL) {
4694 struct rte_eth_dev_info info;
4697 ret2 = rte_eth_dev_info_get(ctx->port, &info);
4701 action_rss_data->conf.key_len =
4702 RTE_MIN(sizeof(action_rss_data->key),
4703 info.hash_key_size);
4705 action->conf = &action_rss_data->conf;
4710 * Parse func field for RSS action.
4712 * The RTE_ETH_HASH_FUNCTION_* value to assign is derived from the
4713 * ACTION_RSS_FUNC_* index that called this function.
4716 parse_vc_action_rss_func(struct context *ctx, const struct token *token,
4717 const char *str, unsigned int len,
4718 void *buf, unsigned int size)
4720 struct action_rss_data *action_rss_data;
4721 enum rte_eth_hash_function func;
4725 /* Token name must match. */
4726 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4728 switch (ctx->curr) {
4729 case ACTION_RSS_FUNC_DEFAULT:
4730 func = RTE_ETH_HASH_FUNCTION_DEFAULT;
4732 case ACTION_RSS_FUNC_TOEPLITZ:
4733 func = RTE_ETH_HASH_FUNCTION_TOEPLITZ;
4735 case ACTION_RSS_FUNC_SIMPLE_XOR:
4736 func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
4738 case ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ:
4739 func = RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
4746 action_rss_data = ctx->object;
4747 action_rss_data->conf.func = func;
4752 * Parse type field for RSS action.
4754 * Valid tokens are type field names and the "end" token.
4757 parse_vc_action_rss_type(struct context *ctx, const struct token *token,
4758 const char *str, unsigned int len,
4759 void *buf, unsigned int size)
4761 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE);
4762 struct action_rss_data *action_rss_data;
4768 if (ctx->curr != ACTION_RSS_TYPE)
4770 if (!(ctx->objdata >> 16) && ctx->object) {
4771 action_rss_data = ctx->object;
4772 action_rss_data->conf.types = 0;
4774 if (!strcmp_partial("end", str, len)) {
4775 ctx->objdata &= 0xffff;
4778 for (i = 0; rss_type_table[i].str; ++i)
4779 if (!strcmp_partial(rss_type_table[i].str, str, len))
4781 if (!rss_type_table[i].str)
4783 ctx->objdata = 1 << 16 | (ctx->objdata & 0xffff);
4785 if (ctx->next_num == RTE_DIM(ctx->next))
4787 ctx->next[ctx->next_num++] = next;
4790 action_rss_data = ctx->object;
4791 action_rss_data->conf.types |= rss_type_table[i].rss_type;
4796 * Parse queue field for RSS action.
4798 * Valid tokens are queue indices and the "end" token.
4801 parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
4802 const char *str, unsigned int len,
4803 void *buf, unsigned int size)
4805 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE);
4806 struct action_rss_data *action_rss_data;
4807 const struct arg *arg;
4814 if (ctx->curr != ACTION_RSS_QUEUE)
4816 i = ctx->objdata >> 16;
4817 if (!strcmp_partial("end", str, len)) {
4818 ctx->objdata &= 0xffff;
4821 if (i >= ACTION_RSS_QUEUE_NUM)
4823 arg = ARGS_ENTRY_ARB(offsetof(struct action_rss_data, queue) +
4824 i * sizeof(action_rss_data->queue[i]),
4825 sizeof(action_rss_data->queue[i]));
4826 if (push_args(ctx, arg))
4828 ret = parse_int(ctx, token, str, len, NULL, 0);
4834 ctx->objdata = i << 16 | (ctx->objdata & 0xffff);
4836 if (ctx->next_num == RTE_DIM(ctx->next))
4838 ctx->next[ctx->next_num++] = next;
4842 action_rss_data = ctx->object;
4843 action_rss_data->conf.queue_num = i;
4844 action_rss_data->conf.queue = i ? action_rss_data->queue : NULL;
4848 /** Parse VXLAN encap action. */
4850 parse_vc_action_vxlan_encap(struct context *ctx, const struct token *token,
4851 const char *str, unsigned int len,
4852 void *buf, unsigned int size)
4854 struct buffer *out = buf;
4855 struct rte_flow_action *action;
4856 struct action_vxlan_encap_data *action_vxlan_encap_data;
4859 ret = parse_vc(ctx, token, str, len, buf, size);
4862 /* Nothing else to do if there is no buffer. */
4865 if (!out->args.vc.actions_n)
4867 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4868 /* Point to selected object. */
4869 ctx->object = out->args.vc.data;
4870 ctx->objmask = NULL;
4871 /* Set up default configuration. */
4872 action_vxlan_encap_data = ctx->object;
4873 *action_vxlan_encap_data = (struct action_vxlan_encap_data){
4874 .conf = (struct rte_flow_action_vxlan_encap){
4875 .definition = action_vxlan_encap_data->items,
4879 .type = RTE_FLOW_ITEM_TYPE_ETH,
4880 .spec = &action_vxlan_encap_data->item_eth,
4881 .mask = &rte_flow_item_eth_mask,
4884 .type = RTE_FLOW_ITEM_TYPE_VLAN,
4885 .spec = &action_vxlan_encap_data->item_vlan,
4886 .mask = &rte_flow_item_vlan_mask,
4889 .type = RTE_FLOW_ITEM_TYPE_IPV4,
4890 .spec = &action_vxlan_encap_data->item_ipv4,
4891 .mask = &rte_flow_item_ipv4_mask,
4894 .type = RTE_FLOW_ITEM_TYPE_UDP,
4895 .spec = &action_vxlan_encap_data->item_udp,
4896 .mask = &rte_flow_item_udp_mask,
4899 .type = RTE_FLOW_ITEM_TYPE_VXLAN,
4900 .spec = &action_vxlan_encap_data->item_vxlan,
4901 .mask = &rte_flow_item_vxlan_mask,
4904 .type = RTE_FLOW_ITEM_TYPE_END,
4909 .tci = vxlan_encap_conf.vlan_tci,
4913 .src_addr = vxlan_encap_conf.ipv4_src,
4914 .dst_addr = vxlan_encap_conf.ipv4_dst,
4917 .src_port = vxlan_encap_conf.udp_src,
4918 .dst_port = vxlan_encap_conf.udp_dst,
4920 .item_vxlan.flags = 0,
4922 memcpy(action_vxlan_encap_data->item_eth.dst.addr_bytes,
4923 vxlan_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
4924 memcpy(action_vxlan_encap_data->item_eth.src.addr_bytes,
4925 vxlan_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
4926 if (!vxlan_encap_conf.select_ipv4) {
4927 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.src_addr,
4928 &vxlan_encap_conf.ipv6_src,
4929 sizeof(vxlan_encap_conf.ipv6_src));
4930 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.dst_addr,
4931 &vxlan_encap_conf.ipv6_dst,
4932 sizeof(vxlan_encap_conf.ipv6_dst));
4933 action_vxlan_encap_data->items[2] = (struct rte_flow_item){
4934 .type = RTE_FLOW_ITEM_TYPE_IPV6,
4935 .spec = &action_vxlan_encap_data->item_ipv6,
4936 .mask = &rte_flow_item_ipv6_mask,
4939 if (!vxlan_encap_conf.select_vlan)
4940 action_vxlan_encap_data->items[1].type =
4941 RTE_FLOW_ITEM_TYPE_VOID;
4942 if (vxlan_encap_conf.select_tos_ttl) {
4943 if (vxlan_encap_conf.select_ipv4) {
4944 static struct rte_flow_item_ipv4 ipv4_mask_tos;
4946 memcpy(&ipv4_mask_tos, &rte_flow_item_ipv4_mask,
4947 sizeof(ipv4_mask_tos));
4948 ipv4_mask_tos.hdr.type_of_service = 0xff;
4949 ipv4_mask_tos.hdr.time_to_live = 0xff;
4950 action_vxlan_encap_data->item_ipv4.hdr.type_of_service =
4951 vxlan_encap_conf.ip_tos;
4952 action_vxlan_encap_data->item_ipv4.hdr.time_to_live =
4953 vxlan_encap_conf.ip_ttl;
4954 action_vxlan_encap_data->items[2].mask =
4957 static struct rte_flow_item_ipv6 ipv6_mask_tos;
4959 memcpy(&ipv6_mask_tos, &rte_flow_item_ipv6_mask,
4960 sizeof(ipv6_mask_tos));
4961 ipv6_mask_tos.hdr.vtc_flow |=
4962 RTE_BE32(0xfful << RTE_IPV6_HDR_TC_SHIFT);
4963 ipv6_mask_tos.hdr.hop_limits = 0xff;
4964 action_vxlan_encap_data->item_ipv6.hdr.vtc_flow |=
4966 ((uint32_t)vxlan_encap_conf.ip_tos <<
4967 RTE_IPV6_HDR_TC_SHIFT);
4968 action_vxlan_encap_data->item_ipv6.hdr.hop_limits =
4969 vxlan_encap_conf.ip_ttl;
4970 action_vxlan_encap_data->items[2].mask =
4974 memcpy(action_vxlan_encap_data->item_vxlan.vni, vxlan_encap_conf.vni,
4975 RTE_DIM(vxlan_encap_conf.vni));
4976 action->conf = &action_vxlan_encap_data->conf;
4980 /** Parse NVGRE encap action. */
4982 parse_vc_action_nvgre_encap(struct context *ctx, const struct token *token,
4983 const char *str, unsigned int len,
4984 void *buf, unsigned int size)
4986 struct buffer *out = buf;
4987 struct rte_flow_action *action;
4988 struct action_nvgre_encap_data *action_nvgre_encap_data;
4991 ret = parse_vc(ctx, token, str, len, buf, size);
4994 /* Nothing else to do if there is no buffer. */
4997 if (!out->args.vc.actions_n)
4999 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5000 /* Point to selected object. */
5001 ctx->object = out->args.vc.data;
5002 ctx->objmask = NULL;
5003 /* Set up default configuration. */
5004 action_nvgre_encap_data = ctx->object;
5005 *action_nvgre_encap_data = (struct action_nvgre_encap_data){
5006 .conf = (struct rte_flow_action_nvgre_encap){
5007 .definition = action_nvgre_encap_data->items,
5011 .type = RTE_FLOW_ITEM_TYPE_ETH,
5012 .spec = &action_nvgre_encap_data->item_eth,
5013 .mask = &rte_flow_item_eth_mask,
5016 .type = RTE_FLOW_ITEM_TYPE_VLAN,
5017 .spec = &action_nvgre_encap_data->item_vlan,
5018 .mask = &rte_flow_item_vlan_mask,
5021 .type = RTE_FLOW_ITEM_TYPE_IPV4,
5022 .spec = &action_nvgre_encap_data->item_ipv4,
5023 .mask = &rte_flow_item_ipv4_mask,
5026 .type = RTE_FLOW_ITEM_TYPE_NVGRE,
5027 .spec = &action_nvgre_encap_data->item_nvgre,
5028 .mask = &rte_flow_item_nvgre_mask,
5031 .type = RTE_FLOW_ITEM_TYPE_END,
5036 .tci = nvgre_encap_conf.vlan_tci,
5040 .src_addr = nvgre_encap_conf.ipv4_src,
5041 .dst_addr = nvgre_encap_conf.ipv4_dst,
5043 .item_nvgre.flow_id = 0,
5045 memcpy(action_nvgre_encap_data->item_eth.dst.addr_bytes,
5046 nvgre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5047 memcpy(action_nvgre_encap_data->item_eth.src.addr_bytes,
5048 nvgre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5049 if (!nvgre_encap_conf.select_ipv4) {
5050 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.src_addr,
5051 &nvgre_encap_conf.ipv6_src,
5052 sizeof(nvgre_encap_conf.ipv6_src));
5053 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.dst_addr,
5054 &nvgre_encap_conf.ipv6_dst,
5055 sizeof(nvgre_encap_conf.ipv6_dst));
5056 action_nvgre_encap_data->items[2] = (struct rte_flow_item){
5057 .type = RTE_FLOW_ITEM_TYPE_IPV6,
5058 .spec = &action_nvgre_encap_data->item_ipv6,
5059 .mask = &rte_flow_item_ipv6_mask,
5062 if (!nvgre_encap_conf.select_vlan)
5063 action_nvgre_encap_data->items[1].type =
5064 RTE_FLOW_ITEM_TYPE_VOID;
5065 memcpy(action_nvgre_encap_data->item_nvgre.tni, nvgre_encap_conf.tni,
5066 RTE_DIM(nvgre_encap_conf.tni));
5067 action->conf = &action_nvgre_encap_data->conf;
5071 /** Parse l2 encap action. */
5073 parse_vc_action_l2_encap(struct context *ctx, const struct token *token,
5074 const char *str, unsigned int len,
5075 void *buf, unsigned int size)
5077 struct buffer *out = buf;
5078 struct rte_flow_action *action;
5079 struct action_raw_encap_data *action_encap_data;
5080 struct rte_flow_item_eth eth = { .type = 0, };
5081 struct rte_flow_item_vlan vlan = {
5082 .tci = mplsoudp_encap_conf.vlan_tci,
5088 ret = parse_vc(ctx, token, str, len, buf, size);
5091 /* Nothing else to do if there is no buffer. */
5094 if (!out->args.vc.actions_n)
5096 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5097 /* Point to selected object. */
5098 ctx->object = out->args.vc.data;
5099 ctx->objmask = NULL;
5100 /* Copy the headers to the buffer. */
5101 action_encap_data = ctx->object;
5102 *action_encap_data = (struct action_raw_encap_data) {
5103 .conf = (struct rte_flow_action_raw_encap){
5104 .data = action_encap_data->data,
5108 header = action_encap_data->data;
5109 if (l2_encap_conf.select_vlan)
5110 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5111 else if (l2_encap_conf.select_ipv4)
5112 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5114 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5115 memcpy(eth.dst.addr_bytes,
5116 l2_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5117 memcpy(eth.src.addr_bytes,
5118 l2_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5119 memcpy(header, ð, sizeof(eth));
5120 header += sizeof(eth);
5121 if (l2_encap_conf.select_vlan) {
5122 if (l2_encap_conf.select_ipv4)
5123 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5125 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5126 memcpy(header, &vlan, sizeof(vlan));
5127 header += sizeof(vlan);
5129 action_encap_data->conf.size = header -
5130 action_encap_data->data;
5131 action->conf = &action_encap_data->conf;
5135 /** Parse l2 decap action. */
5137 parse_vc_action_l2_decap(struct context *ctx, const struct token *token,
5138 const char *str, unsigned int len,
5139 void *buf, unsigned int size)
5141 struct buffer *out = buf;
5142 struct rte_flow_action *action;
5143 struct action_raw_decap_data *action_decap_data;
5144 struct rte_flow_item_eth eth = { .type = 0, };
5145 struct rte_flow_item_vlan vlan = {
5146 .tci = mplsoudp_encap_conf.vlan_tci,
5152 ret = parse_vc(ctx, token, str, len, buf, size);
5155 /* Nothing else to do if there is no buffer. */
5158 if (!out->args.vc.actions_n)
5160 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5161 /* Point to selected object. */
5162 ctx->object = out->args.vc.data;
5163 ctx->objmask = NULL;
5164 /* Copy the headers to the buffer. */
5165 action_decap_data = ctx->object;
5166 *action_decap_data = (struct action_raw_decap_data) {
5167 .conf = (struct rte_flow_action_raw_decap){
5168 .data = action_decap_data->data,
5172 header = action_decap_data->data;
5173 if (l2_decap_conf.select_vlan)
5174 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5175 memcpy(header, ð, sizeof(eth));
5176 header += sizeof(eth);
5177 if (l2_decap_conf.select_vlan) {
5178 memcpy(header, &vlan, sizeof(vlan));
5179 header += sizeof(vlan);
5181 action_decap_data->conf.size = header -
5182 action_decap_data->data;
5183 action->conf = &action_decap_data->conf;
5187 #define ETHER_TYPE_MPLS_UNICAST 0x8847
5189 /** Parse MPLSOGRE encap action. */
5191 parse_vc_action_mplsogre_encap(struct context *ctx, const struct token *token,
5192 const char *str, unsigned int len,
5193 void *buf, unsigned int size)
5195 struct buffer *out = buf;
5196 struct rte_flow_action *action;
5197 struct action_raw_encap_data *action_encap_data;
5198 struct rte_flow_item_eth eth = { .type = 0, };
5199 struct rte_flow_item_vlan vlan = {
5200 .tci = mplsogre_encap_conf.vlan_tci,
5203 struct rte_flow_item_ipv4 ipv4 = {
5205 .src_addr = mplsogre_encap_conf.ipv4_src,
5206 .dst_addr = mplsogre_encap_conf.ipv4_dst,
5207 .next_proto_id = IPPROTO_GRE,
5208 .version_ihl = RTE_IPV4_VHL_DEF,
5209 .time_to_live = IPDEFTTL,
5212 struct rte_flow_item_ipv6 ipv6 = {
5214 .proto = IPPROTO_GRE,
5215 .hop_limits = IPDEFTTL,
5218 struct rte_flow_item_gre gre = {
5219 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
5221 struct rte_flow_item_mpls mpls = {
5227 ret = parse_vc(ctx, token, str, len, buf, size);
5230 /* Nothing else to do if there is no buffer. */
5233 if (!out->args.vc.actions_n)
5235 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5236 /* Point to selected object. */
5237 ctx->object = out->args.vc.data;
5238 ctx->objmask = NULL;
5239 /* Copy the headers to the buffer. */
5240 action_encap_data = ctx->object;
5241 *action_encap_data = (struct action_raw_encap_data) {
5242 .conf = (struct rte_flow_action_raw_encap){
5243 .data = action_encap_data->data,
5248 header = action_encap_data->data;
5249 if (mplsogre_encap_conf.select_vlan)
5250 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5251 else if (mplsogre_encap_conf.select_ipv4)
5252 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5254 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5255 memcpy(eth.dst.addr_bytes,
5256 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5257 memcpy(eth.src.addr_bytes,
5258 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5259 memcpy(header, ð, sizeof(eth));
5260 header += sizeof(eth);
5261 if (mplsogre_encap_conf.select_vlan) {
5262 if (mplsogre_encap_conf.select_ipv4)
5263 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5265 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5266 memcpy(header, &vlan, sizeof(vlan));
5267 header += sizeof(vlan);
5269 if (mplsogre_encap_conf.select_ipv4) {
5270 memcpy(header, &ipv4, sizeof(ipv4));
5271 header += sizeof(ipv4);
5273 memcpy(&ipv6.hdr.src_addr,
5274 &mplsogre_encap_conf.ipv6_src,
5275 sizeof(mplsogre_encap_conf.ipv6_src));
5276 memcpy(&ipv6.hdr.dst_addr,
5277 &mplsogre_encap_conf.ipv6_dst,
5278 sizeof(mplsogre_encap_conf.ipv6_dst));
5279 memcpy(header, &ipv6, sizeof(ipv6));
5280 header += sizeof(ipv6);
5282 memcpy(header, &gre, sizeof(gre));
5283 header += sizeof(gre);
5284 memcpy(mpls.label_tc_s, mplsogre_encap_conf.label,
5285 RTE_DIM(mplsogre_encap_conf.label));
5286 mpls.label_tc_s[2] |= 0x1;
5287 memcpy(header, &mpls, sizeof(mpls));
5288 header += sizeof(mpls);
5289 action_encap_data->conf.size = header -
5290 action_encap_data->data;
5291 action->conf = &action_encap_data->conf;
5295 /** Parse MPLSOGRE decap action. */
5297 parse_vc_action_mplsogre_decap(struct context *ctx, const struct token *token,
5298 const char *str, unsigned int len,
5299 void *buf, unsigned int size)
5301 struct buffer *out = buf;
5302 struct rte_flow_action *action;
5303 struct action_raw_decap_data *action_decap_data;
5304 struct rte_flow_item_eth eth = { .type = 0, };
5305 struct rte_flow_item_vlan vlan = {.tci = 0};
5306 struct rte_flow_item_ipv4 ipv4 = {
5308 .next_proto_id = IPPROTO_GRE,
5311 struct rte_flow_item_ipv6 ipv6 = {
5313 .proto = IPPROTO_GRE,
5316 struct rte_flow_item_gre gre = {
5317 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
5319 struct rte_flow_item_mpls mpls;
5323 ret = parse_vc(ctx, token, str, len, buf, size);
5326 /* Nothing else to do if there is no buffer. */
5329 if (!out->args.vc.actions_n)
5331 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5332 /* Point to selected object. */
5333 ctx->object = out->args.vc.data;
5334 ctx->objmask = NULL;
5335 /* Copy the headers to the buffer. */
5336 action_decap_data = ctx->object;
5337 *action_decap_data = (struct action_raw_decap_data) {
5338 .conf = (struct rte_flow_action_raw_decap){
5339 .data = action_decap_data->data,
5343 header = action_decap_data->data;
5344 if (mplsogre_decap_conf.select_vlan)
5345 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5346 else if (mplsogre_encap_conf.select_ipv4)
5347 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5349 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5350 memcpy(eth.dst.addr_bytes,
5351 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5352 memcpy(eth.src.addr_bytes,
5353 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5354 memcpy(header, ð, sizeof(eth));
5355 header += sizeof(eth);
5356 if (mplsogre_encap_conf.select_vlan) {
5357 if (mplsogre_encap_conf.select_ipv4)
5358 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5360 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5361 memcpy(header, &vlan, sizeof(vlan));
5362 header += sizeof(vlan);
5364 if (mplsogre_encap_conf.select_ipv4) {
5365 memcpy(header, &ipv4, sizeof(ipv4));
5366 header += sizeof(ipv4);
5368 memcpy(header, &ipv6, sizeof(ipv6));
5369 header += sizeof(ipv6);
5371 memcpy(header, &gre, sizeof(gre));
5372 header += sizeof(gre);
5373 memset(&mpls, 0, sizeof(mpls));
5374 memcpy(header, &mpls, sizeof(mpls));
5375 header += sizeof(mpls);
5376 action_decap_data->conf.size = header -
5377 action_decap_data->data;
5378 action->conf = &action_decap_data->conf;
5382 /** Parse MPLSOUDP encap action. */
5384 parse_vc_action_mplsoudp_encap(struct context *ctx, const struct token *token,
5385 const char *str, unsigned int len,
5386 void *buf, unsigned int size)
5388 struct buffer *out = buf;
5389 struct rte_flow_action *action;
5390 struct action_raw_encap_data *action_encap_data;
5391 struct rte_flow_item_eth eth = { .type = 0, };
5392 struct rte_flow_item_vlan vlan = {
5393 .tci = mplsoudp_encap_conf.vlan_tci,
5396 struct rte_flow_item_ipv4 ipv4 = {
5398 .src_addr = mplsoudp_encap_conf.ipv4_src,
5399 .dst_addr = mplsoudp_encap_conf.ipv4_dst,
5400 .next_proto_id = IPPROTO_UDP,
5401 .version_ihl = RTE_IPV4_VHL_DEF,
5402 .time_to_live = IPDEFTTL,
5405 struct rte_flow_item_ipv6 ipv6 = {
5407 .proto = IPPROTO_UDP,
5408 .hop_limits = IPDEFTTL,
5411 struct rte_flow_item_udp udp = {
5413 .src_port = mplsoudp_encap_conf.udp_src,
5414 .dst_port = mplsoudp_encap_conf.udp_dst,
5417 struct rte_flow_item_mpls mpls;
5421 ret = parse_vc(ctx, token, str, len, buf, size);
5424 /* Nothing else to do if there is no buffer. */
5427 if (!out->args.vc.actions_n)
5429 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5430 /* Point to selected object. */
5431 ctx->object = out->args.vc.data;
5432 ctx->objmask = NULL;
5433 /* Copy the headers to the buffer. */
5434 action_encap_data = ctx->object;
5435 *action_encap_data = (struct action_raw_encap_data) {
5436 .conf = (struct rte_flow_action_raw_encap){
5437 .data = action_encap_data->data,
5442 header = action_encap_data->data;
5443 if (mplsoudp_encap_conf.select_vlan)
5444 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5445 else if (mplsoudp_encap_conf.select_ipv4)
5446 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5448 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5449 memcpy(eth.dst.addr_bytes,
5450 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5451 memcpy(eth.src.addr_bytes,
5452 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5453 memcpy(header, ð, sizeof(eth));
5454 header += sizeof(eth);
5455 if (mplsoudp_encap_conf.select_vlan) {
5456 if (mplsoudp_encap_conf.select_ipv4)
5457 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5459 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5460 memcpy(header, &vlan, sizeof(vlan));
5461 header += sizeof(vlan);
5463 if (mplsoudp_encap_conf.select_ipv4) {
5464 memcpy(header, &ipv4, sizeof(ipv4));
5465 header += sizeof(ipv4);
5467 memcpy(&ipv6.hdr.src_addr,
5468 &mplsoudp_encap_conf.ipv6_src,
5469 sizeof(mplsoudp_encap_conf.ipv6_src));
5470 memcpy(&ipv6.hdr.dst_addr,
5471 &mplsoudp_encap_conf.ipv6_dst,
5472 sizeof(mplsoudp_encap_conf.ipv6_dst));
5473 memcpy(header, &ipv6, sizeof(ipv6));
5474 header += sizeof(ipv6);
5476 memcpy(header, &udp, sizeof(udp));
5477 header += sizeof(udp);
5478 memcpy(mpls.label_tc_s, mplsoudp_encap_conf.label,
5479 RTE_DIM(mplsoudp_encap_conf.label));
5480 mpls.label_tc_s[2] |= 0x1;
5481 memcpy(header, &mpls, sizeof(mpls));
5482 header += sizeof(mpls);
5483 action_encap_data->conf.size = header -
5484 action_encap_data->data;
5485 action->conf = &action_encap_data->conf;
5489 /** Parse MPLSOUDP decap action. */
5491 parse_vc_action_mplsoudp_decap(struct context *ctx, const struct token *token,
5492 const char *str, unsigned int len,
5493 void *buf, unsigned int size)
5495 struct buffer *out = buf;
5496 struct rte_flow_action *action;
5497 struct action_raw_decap_data *action_decap_data;
5498 struct rte_flow_item_eth eth = { .type = 0, };
5499 struct rte_flow_item_vlan vlan = {.tci = 0};
5500 struct rte_flow_item_ipv4 ipv4 = {
5502 .next_proto_id = IPPROTO_UDP,
5505 struct rte_flow_item_ipv6 ipv6 = {
5507 .proto = IPPROTO_UDP,
5510 struct rte_flow_item_udp udp = {
5512 .dst_port = rte_cpu_to_be_16(6635),
5515 struct rte_flow_item_mpls mpls;
5519 ret = parse_vc(ctx, token, str, len, buf, size);
5522 /* Nothing else to do if there is no buffer. */
5525 if (!out->args.vc.actions_n)
5527 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5528 /* Point to selected object. */
5529 ctx->object = out->args.vc.data;
5530 ctx->objmask = NULL;
5531 /* Copy the headers to the buffer. */
5532 action_decap_data = ctx->object;
5533 *action_decap_data = (struct action_raw_decap_data) {
5534 .conf = (struct rte_flow_action_raw_decap){
5535 .data = action_decap_data->data,
5539 header = action_decap_data->data;
5540 if (mplsoudp_decap_conf.select_vlan)
5541 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5542 else if (mplsoudp_encap_conf.select_ipv4)
5543 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5545 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5546 memcpy(eth.dst.addr_bytes,
5547 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5548 memcpy(eth.src.addr_bytes,
5549 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5550 memcpy(header, ð, sizeof(eth));
5551 header += sizeof(eth);
5552 if (mplsoudp_encap_conf.select_vlan) {
5553 if (mplsoudp_encap_conf.select_ipv4)
5554 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5556 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5557 memcpy(header, &vlan, sizeof(vlan));
5558 header += sizeof(vlan);
5560 if (mplsoudp_encap_conf.select_ipv4) {
5561 memcpy(header, &ipv4, sizeof(ipv4));
5562 header += sizeof(ipv4);
5564 memcpy(header, &ipv6, sizeof(ipv6));
5565 header += sizeof(ipv6);
5567 memcpy(header, &udp, sizeof(udp));
5568 header += sizeof(udp);
5569 memset(&mpls, 0, sizeof(mpls));
5570 memcpy(header, &mpls, sizeof(mpls));
5571 header += sizeof(mpls);
5572 action_decap_data->conf.size = header -
5573 action_decap_data->data;
5574 action->conf = &action_decap_data->conf;
5579 parse_vc_action_raw_decap_index(struct context *ctx, const struct token *token,
5580 const char *str, unsigned int len, void *buf,
5583 struct action_raw_decap_data *action_raw_decap_data;
5584 struct rte_flow_action *action;
5585 const struct arg *arg;
5586 struct buffer *out = buf;
5590 RTE_SET_USED(token);
5593 arg = ARGS_ENTRY_ARB_BOUNDED
5594 (offsetof(struct action_raw_decap_data, idx),
5595 sizeof(((struct action_raw_decap_data *)0)->idx),
5596 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
5597 if (push_args(ctx, arg))
5599 ret = parse_int(ctx, token, str, len, NULL, 0);
5606 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5607 action_raw_decap_data = ctx->object;
5608 idx = action_raw_decap_data->idx;
5609 action_raw_decap_data->conf.data = raw_decap_confs[idx].data;
5610 action_raw_decap_data->conf.size = raw_decap_confs[idx].size;
5611 action->conf = &action_raw_decap_data->conf;
5617 parse_vc_action_raw_encap_index(struct context *ctx, const struct token *token,
5618 const char *str, unsigned int len, void *buf,
5621 struct action_raw_encap_data *action_raw_encap_data;
5622 struct rte_flow_action *action;
5623 const struct arg *arg;
5624 struct buffer *out = buf;
5628 RTE_SET_USED(token);
5631 if (ctx->curr != ACTION_RAW_ENCAP_INDEX_VALUE)
5633 arg = ARGS_ENTRY_ARB_BOUNDED
5634 (offsetof(struct action_raw_encap_data, idx),
5635 sizeof(((struct action_raw_encap_data *)0)->idx),
5636 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
5637 if (push_args(ctx, arg))
5639 ret = parse_int(ctx, token, str, len, NULL, 0);
5646 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5647 action_raw_encap_data = ctx->object;
5648 idx = action_raw_encap_data->idx;
5649 action_raw_encap_data->conf.data = raw_encap_confs[idx].data;
5650 action_raw_encap_data->conf.size = raw_encap_confs[idx].size;
5651 action_raw_encap_data->conf.preserve = NULL;
5652 action->conf = &action_raw_encap_data->conf;
5657 parse_vc_action_raw_encap(struct context *ctx, const struct token *token,
5658 const char *str, unsigned int len, void *buf,
5661 struct buffer *out = buf;
5662 struct rte_flow_action *action;
5663 struct action_raw_encap_data *action_raw_encap_data = NULL;
5666 ret = parse_vc(ctx, token, str, len, buf, size);
5669 /* Nothing else to do if there is no buffer. */
5672 if (!out->args.vc.actions_n)
5674 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5675 /* Point to selected object. */
5676 ctx->object = out->args.vc.data;
5677 ctx->objmask = NULL;
5678 /* Copy the headers to the buffer. */
5679 action_raw_encap_data = ctx->object;
5680 action_raw_encap_data->conf.data = raw_encap_confs[0].data;
5681 action_raw_encap_data->conf.preserve = NULL;
5682 action_raw_encap_data->conf.size = raw_encap_confs[0].size;
5683 action->conf = &action_raw_encap_data->conf;
5688 parse_vc_action_raw_decap(struct context *ctx, const struct token *token,
5689 const char *str, unsigned int len, void *buf,
5692 struct buffer *out = buf;
5693 struct rte_flow_action *action;
5694 struct action_raw_decap_data *action_raw_decap_data = NULL;
5697 ret = parse_vc(ctx, token, str, len, buf, size);
5700 /* Nothing else to do if there is no buffer. */
5703 if (!out->args.vc.actions_n)
5705 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5706 /* Point to selected object. */
5707 ctx->object = out->args.vc.data;
5708 ctx->objmask = NULL;
5709 /* Copy the headers to the buffer. */
5710 action_raw_decap_data = ctx->object;
5711 action_raw_decap_data->conf.data = raw_decap_confs[0].data;
5712 action_raw_decap_data->conf.size = raw_decap_confs[0].size;
5713 action->conf = &action_raw_decap_data->conf;
5718 parse_vc_action_set_meta(struct context *ctx, const struct token *token,
5719 const char *str, unsigned int len, void *buf,
5724 ret = parse_vc(ctx, token, str, len, buf, size);
5727 ret = rte_flow_dynf_metadata_register();
5734 parse_vc_action_sample(struct context *ctx, const struct token *token,
5735 const char *str, unsigned int len, void *buf,
5738 struct buffer *out = buf;
5739 struct rte_flow_action *action;
5740 struct action_sample_data *action_sample_data = NULL;
5741 static struct rte_flow_action end_action = {
5742 RTE_FLOW_ACTION_TYPE_END, 0
5746 ret = parse_vc(ctx, token, str, len, buf, size);
5749 /* Nothing else to do if there is no buffer. */
5752 if (!out->args.vc.actions_n)
5754 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5755 /* Point to selected object. */
5756 ctx->object = out->args.vc.data;
5757 ctx->objmask = NULL;
5758 /* Copy the headers to the buffer. */
5759 action_sample_data = ctx->object;
5760 action_sample_data->conf.actions = &end_action;
5761 action->conf = &action_sample_data->conf;
5766 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
5767 const char *str, unsigned int len, void *buf,
5770 struct action_sample_data *action_sample_data;
5771 struct rte_flow_action *action;
5772 const struct arg *arg;
5773 struct buffer *out = buf;
5777 RTE_SET_USED(token);
5780 if (ctx->curr != ACTION_SAMPLE_INDEX_VALUE)
5782 arg = ARGS_ENTRY_ARB_BOUNDED
5783 (offsetof(struct action_sample_data, idx),
5784 sizeof(((struct action_sample_data *)0)->idx),
5785 0, RAW_SAMPLE_CONFS_MAX_NUM - 1);
5786 if (push_args(ctx, arg))
5788 ret = parse_int(ctx, token, str, len, NULL, 0);
5795 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5796 action_sample_data = ctx->object;
5797 idx = action_sample_data->idx;
5798 action_sample_data->conf.actions = raw_sample_confs[idx].data;
5799 action->conf = &action_sample_data->conf;
5803 /** Parse tokens for destroy command. */
5805 parse_destroy(struct context *ctx, const struct token *token,
5806 const char *str, unsigned int len,
5807 void *buf, unsigned int size)
5809 struct buffer *out = buf;
5811 /* Token name must match. */
5812 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5814 /* Nothing else to do if there is no buffer. */
5817 if (!out->command) {
5818 if (ctx->curr != DESTROY)
5820 if (sizeof(*out) > size)
5822 out->command = ctx->curr;
5825 ctx->objmask = NULL;
5826 out->args.destroy.rule =
5827 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5831 if (((uint8_t *)(out->args.destroy.rule + out->args.destroy.rule_n) +
5832 sizeof(*out->args.destroy.rule)) > (uint8_t *)out + size)
5835 ctx->object = out->args.destroy.rule + out->args.destroy.rule_n++;
5836 ctx->objmask = NULL;
5840 /** Parse tokens for flush command. */
5842 parse_flush(struct context *ctx, const struct token *token,
5843 const char *str, unsigned int len,
5844 void *buf, unsigned int size)
5846 struct buffer *out = buf;
5848 /* Token name must match. */
5849 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5851 /* Nothing else to do if there is no buffer. */
5854 if (!out->command) {
5855 if (ctx->curr != FLUSH)
5857 if (sizeof(*out) > size)
5859 out->command = ctx->curr;
5862 ctx->objmask = NULL;
5867 /** Parse tokens for dump command. */
5869 parse_dump(struct context *ctx, const struct token *token,
5870 const char *str, unsigned int len,
5871 void *buf, unsigned int size)
5873 struct buffer *out = buf;
5875 /* Token name must match. */
5876 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5878 /* Nothing else to do if there is no buffer. */
5881 if (!out->command) {
5882 if (ctx->curr != DUMP)
5884 if (sizeof(*out) > size)
5886 out->command = ctx->curr;
5889 ctx->objmask = NULL;
5894 /** Parse tokens for query command. */
5896 parse_query(struct context *ctx, const struct token *token,
5897 const char *str, unsigned int len,
5898 void *buf, unsigned int size)
5900 struct buffer *out = buf;
5902 /* Token name must match. */
5903 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5905 /* Nothing else to do if there is no buffer. */
5908 if (!out->command) {
5909 if (ctx->curr != QUERY)
5911 if (sizeof(*out) > size)
5913 out->command = ctx->curr;
5916 ctx->objmask = NULL;
5921 /** Parse action names. */
5923 parse_action(struct context *ctx, const struct token *token,
5924 const char *str, unsigned int len,
5925 void *buf, unsigned int size)
5927 struct buffer *out = buf;
5928 const struct arg *arg = pop_args(ctx);
5932 /* Argument is expected. */
5935 /* Parse action name. */
5936 for (i = 0; next_action[i]; ++i) {
5937 const struct parse_action_priv *priv;
5939 token = &token_list[next_action[i]];
5940 if (strcmp_partial(token->name, str, len))
5946 memcpy((uint8_t *)ctx->object + arg->offset,
5952 push_args(ctx, arg);
5956 /** Parse tokens for list command. */
5958 parse_list(struct context *ctx, const struct token *token,
5959 const char *str, unsigned int len,
5960 void *buf, unsigned int size)
5962 struct buffer *out = buf;
5964 /* Token name must match. */
5965 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5967 /* Nothing else to do if there is no buffer. */
5970 if (!out->command) {
5971 if (ctx->curr != LIST)
5973 if (sizeof(*out) > size)
5975 out->command = ctx->curr;
5978 ctx->objmask = NULL;
5979 out->args.list.group =
5980 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5984 if (((uint8_t *)(out->args.list.group + out->args.list.group_n) +
5985 sizeof(*out->args.list.group)) > (uint8_t *)out + size)
5988 ctx->object = out->args.list.group + out->args.list.group_n++;
5989 ctx->objmask = NULL;
5993 /** Parse tokens for list all aged flows command. */
5995 parse_aged(struct context *ctx, const struct token *token,
5996 const char *str, unsigned int len,
5997 void *buf, unsigned int size)
5999 struct buffer *out = buf;
6001 /* Token name must match. */
6002 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6004 /* Nothing else to do if there is no buffer. */
6007 if (!out->command) {
6008 if (ctx->curr != AGED)
6010 if (sizeof(*out) > size)
6012 out->command = ctx->curr;
6015 ctx->objmask = NULL;
6017 if (ctx->curr == AGED_DESTROY)
6018 out->args.aged.destroy = 1;
6022 /** Parse tokens for isolate command. */
6024 parse_isolate(struct context *ctx, const struct token *token,
6025 const char *str, unsigned int len,
6026 void *buf, unsigned int size)
6028 struct buffer *out = buf;
6030 /* Token name must match. */
6031 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6033 /* Nothing else to do if there is no buffer. */
6036 if (!out->command) {
6037 if (ctx->curr != ISOLATE)
6039 if (sizeof(*out) > size)
6041 out->command = ctx->curr;
6044 ctx->objmask = NULL;
6050 * Parse signed/unsigned integers 8 to 64-bit long.
6052 * Last argument (ctx->args) is retrieved to determine integer type and
6056 parse_int(struct context *ctx, const struct token *token,
6057 const char *str, unsigned int len,
6058 void *buf, unsigned int size)
6060 const struct arg *arg = pop_args(ctx);
6065 /* Argument is expected. */
6070 (uintmax_t)strtoimax(str, &end, 0) :
6071 strtoumax(str, &end, 0);
6072 if (errno || (size_t)(end - str) != len)
6075 ((arg->sign && ((intmax_t)u < (intmax_t)arg->min ||
6076 (intmax_t)u > (intmax_t)arg->max)) ||
6077 (!arg->sign && (u < arg->min || u > arg->max))))
6082 if (!arg_entry_bf_fill(ctx->object, u, arg) ||
6083 !arg_entry_bf_fill(ctx->objmask, -1, arg))
6087 buf = (uint8_t *)ctx->object + arg->offset;
6089 if (u > RTE_LEN2MASK(size * CHAR_BIT, uint64_t))
6093 case sizeof(uint8_t):
6094 *(uint8_t *)buf = u;
6096 case sizeof(uint16_t):
6097 *(uint16_t *)buf = arg->hton ? rte_cpu_to_be_16(u) : u;
6099 case sizeof(uint8_t [3]):
6100 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
6102 ((uint8_t *)buf)[0] = u;
6103 ((uint8_t *)buf)[1] = u >> 8;
6104 ((uint8_t *)buf)[2] = u >> 16;
6108 ((uint8_t *)buf)[0] = u >> 16;
6109 ((uint8_t *)buf)[1] = u >> 8;
6110 ((uint8_t *)buf)[2] = u;
6112 case sizeof(uint32_t):
6113 *(uint32_t *)buf = arg->hton ? rte_cpu_to_be_32(u) : u;
6115 case sizeof(uint64_t):
6116 *(uint64_t *)buf = arg->hton ? rte_cpu_to_be_64(u) : u;
6121 if (ctx->objmask && buf != (uint8_t *)ctx->objmask + arg->offset) {
6123 buf = (uint8_t *)ctx->objmask + arg->offset;
6128 push_args(ctx, arg);
6135 * Three arguments (ctx->args) are retrieved from the stack to store data,
6136 * its actual length and address (in that order).
6139 parse_string(struct context *ctx, const struct token *token,
6140 const char *str, unsigned int len,
6141 void *buf, unsigned int size)
6143 const struct arg *arg_data = pop_args(ctx);
6144 const struct arg *arg_len = pop_args(ctx);
6145 const struct arg *arg_addr = pop_args(ctx);
6146 char tmp[16]; /* Ought to be enough. */
6149 /* Arguments are expected. */
6153 push_args(ctx, arg_data);
6157 push_args(ctx, arg_len);
6158 push_args(ctx, arg_data);
6161 size = arg_data->size;
6162 /* Bit-mask fill is not supported. */
6163 if (arg_data->mask || size < len)
6167 /* Let parse_int() fill length information first. */
6168 ret = snprintf(tmp, sizeof(tmp), "%u", len);
6171 push_args(ctx, arg_len);
6172 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
6177 buf = (uint8_t *)ctx->object + arg_data->offset;
6178 /* Output buffer is not necessarily NUL-terminated. */
6179 memcpy(buf, str, len);
6180 memset((uint8_t *)buf + len, 0x00, size - len);
6182 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
6183 /* Save address if requested. */
6184 if (arg_addr->size) {
6185 memcpy((uint8_t *)ctx->object + arg_addr->offset,
6187 (uint8_t *)ctx->object + arg_data->offset
6191 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
6193 (uint8_t *)ctx->objmask + arg_data->offset
6199 push_args(ctx, arg_addr);
6200 push_args(ctx, arg_len);
6201 push_args(ctx, arg_data);
6206 parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
6212 /* Check input parameters */
6213 if ((src == NULL) ||
6219 /* Convert chars to bytes */
6220 for (i = 0, len = 0; i < *size; i += 2) {
6221 snprintf(tmp, 3, "%s", src + i);
6222 dst[len++] = strtoul(tmp, &c, 16);
6237 parse_hex(struct context *ctx, const struct token *token,
6238 const char *str, unsigned int len,
6239 void *buf, unsigned int size)
6241 const struct arg *arg_data = pop_args(ctx);
6242 const struct arg *arg_len = pop_args(ctx);
6243 const struct arg *arg_addr = pop_args(ctx);
6244 char tmp[16]; /* Ought to be enough. */
6246 unsigned int hexlen = len;
6247 unsigned int length = 256;
6248 uint8_t hex_tmp[length];
6250 /* Arguments are expected. */
6254 push_args(ctx, arg_data);
6258 push_args(ctx, arg_len);
6259 push_args(ctx, arg_data);
6262 size = arg_data->size;
6263 /* Bit-mask fill is not supported. */
6269 /* translate bytes string to array. */
6270 if (str[0] == '0' && ((str[1] == 'x') ||
6275 if (hexlen > length)
6277 ret = parse_hex_string(str, hex_tmp, &hexlen);
6280 /* Let parse_int() fill length information first. */
6281 ret = snprintf(tmp, sizeof(tmp), "%u", hexlen);
6284 push_args(ctx, arg_len);
6285 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
6290 buf = (uint8_t *)ctx->object + arg_data->offset;
6291 /* Output buffer is not necessarily NUL-terminated. */
6292 memcpy(buf, hex_tmp, hexlen);
6293 memset((uint8_t *)buf + hexlen, 0x00, size - hexlen);
6295 memset((uint8_t *)ctx->objmask + arg_data->offset,
6297 /* Save address if requested. */
6298 if (arg_addr->size) {
6299 memcpy((uint8_t *)ctx->object + arg_addr->offset,
6301 (uint8_t *)ctx->object + arg_data->offset
6305 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
6307 (uint8_t *)ctx->objmask + arg_data->offset
6313 push_args(ctx, arg_addr);
6314 push_args(ctx, arg_len);
6315 push_args(ctx, arg_data);
6321 * Parse a zero-ended string.
6324 parse_string0(struct context *ctx, const struct token *token __rte_unused,
6325 const char *str, unsigned int len,
6326 void *buf, unsigned int size)
6328 const struct arg *arg_data = pop_args(ctx);
6330 /* Arguments are expected. */
6333 size = arg_data->size;
6334 /* Bit-mask fill is not supported. */
6335 if (arg_data->mask || size < len + 1)
6339 buf = (uint8_t *)ctx->object + arg_data->offset;
6340 strncpy(buf, str, len);
6342 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
6345 push_args(ctx, arg_data);
6350 * Parse a MAC address.
6352 * Last argument (ctx->args) is retrieved to determine storage size and
6356 parse_mac_addr(struct context *ctx, const struct token *token,
6357 const char *str, unsigned int len,
6358 void *buf, unsigned int size)
6360 const struct arg *arg = pop_args(ctx);
6361 struct rte_ether_addr tmp;
6365 /* Argument is expected. */
6369 /* Bit-mask fill is not supported. */
6370 if (arg->mask || size != sizeof(tmp))
6372 /* Only network endian is supported. */
6375 ret = cmdline_parse_etheraddr(NULL, str, &tmp, size);
6376 if (ret < 0 || (unsigned int)ret != len)
6380 buf = (uint8_t *)ctx->object + arg->offset;
6381 memcpy(buf, &tmp, size);
6383 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6386 push_args(ctx, arg);
6391 * Parse an IPv4 address.
6393 * Last argument (ctx->args) is retrieved to determine storage size and
6397 parse_ipv4_addr(struct context *ctx, const struct token *token,
6398 const char *str, unsigned int len,
6399 void *buf, unsigned int size)
6401 const struct arg *arg = pop_args(ctx);
6406 /* Argument is expected. */
6410 /* Bit-mask fill is not supported. */
6411 if (arg->mask || size != sizeof(tmp))
6413 /* Only network endian is supported. */
6416 memcpy(str2, str, len);
6418 ret = inet_pton(AF_INET, str2, &tmp);
6420 /* Attempt integer parsing. */
6421 push_args(ctx, arg);
6422 return parse_int(ctx, token, str, len, buf, size);
6426 buf = (uint8_t *)ctx->object + arg->offset;
6427 memcpy(buf, &tmp, size);
6429 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6432 push_args(ctx, arg);
6437 * Parse an IPv6 address.
6439 * Last argument (ctx->args) is retrieved to determine storage size and
6443 parse_ipv6_addr(struct context *ctx, const struct token *token,
6444 const char *str, unsigned int len,
6445 void *buf, unsigned int size)
6447 const struct arg *arg = pop_args(ctx);
6449 struct in6_addr tmp;
6453 /* Argument is expected. */
6457 /* Bit-mask fill is not supported. */
6458 if (arg->mask || size != sizeof(tmp))
6460 /* Only network endian is supported. */
6463 memcpy(str2, str, len);
6465 ret = inet_pton(AF_INET6, str2, &tmp);
6470 buf = (uint8_t *)ctx->object + arg->offset;
6471 memcpy(buf, &tmp, size);
6473 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6476 push_args(ctx, arg);
6480 /** Boolean values (even indices stand for false). */
6481 static const char *const boolean_name[] = {
6491 * Parse a boolean value.
6493 * Last argument (ctx->args) is retrieved to determine storage size and
6497 parse_boolean(struct context *ctx, const struct token *token,
6498 const char *str, unsigned int len,
6499 void *buf, unsigned int size)
6501 const struct arg *arg = pop_args(ctx);
6505 /* Argument is expected. */
6508 for (i = 0; boolean_name[i]; ++i)
6509 if (!strcmp_partial(boolean_name[i], str, len))
6511 /* Process token as integer. */
6512 if (boolean_name[i])
6513 str = i & 1 ? "1" : "0";
6514 push_args(ctx, arg);
6515 ret = parse_int(ctx, token, str, strlen(str), buf, size);
6516 return ret > 0 ? (int)len : ret;
6519 /** Parse port and update context. */
6521 parse_port(struct context *ctx, const struct token *token,
6522 const char *str, unsigned int len,
6523 void *buf, unsigned int size)
6525 struct buffer *out = &(struct buffer){ .port = 0 };
6533 ctx->objmask = NULL;
6534 size = sizeof(*out);
6536 ret = parse_int(ctx, token, str, len, out, size);
6538 ctx->port = out->port;
6545 parse_sa_id2ptr(struct context *ctx, const struct token *token,
6546 const char *str, unsigned int len,
6547 void *buf, unsigned int size)
6549 struct rte_flow_action *action = ctx->object;
6557 ctx->objmask = NULL;
6558 ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
6559 ctx->object = action;
6560 if (ret != (int)len)
6562 /* set shared action */
6564 action->conf = port_shared_action_get_by_id(ctx->port, id);
6565 ret = (action->conf) ? ret : -1;
6570 /** Parse set command, initialize output buffer for subsequent tokens. */
6572 parse_set_raw_encap_decap(struct context *ctx, const struct token *token,
6573 const char *str, unsigned int len,
6574 void *buf, unsigned int size)
6576 struct buffer *out = buf;
6578 /* Token name must match. */
6579 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6581 /* Nothing else to do if there is no buffer. */
6584 /* Make sure buffer is large enough. */
6585 if (size < sizeof(*out))
6588 ctx->objmask = NULL;
6592 out->command = ctx->curr;
6593 /* For encap/decap we need is pattern */
6594 out->args.vc.pattern = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6599 /** Parse set command, initialize output buffer for subsequent tokens. */
6601 parse_set_sample_action(struct context *ctx, const struct token *token,
6602 const char *str, unsigned int len,
6603 void *buf, unsigned int size)
6605 struct buffer *out = buf;
6607 /* Token name must match. */
6608 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6610 /* Nothing else to do if there is no buffer. */
6613 /* Make sure buffer is large enough. */
6614 if (size < sizeof(*out))
6617 ctx->objmask = NULL;
6621 out->command = ctx->curr;
6622 /* For sampler we need is actions */
6623 out->args.vc.actions = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6629 * Parse set raw_encap/raw_decap command,
6630 * initialize output buffer for subsequent tokens.
6633 parse_set_init(struct context *ctx, const struct token *token,
6634 const char *str, unsigned int len,
6635 void *buf, unsigned int size)
6637 struct buffer *out = buf;
6639 /* Token name must match. */
6640 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6642 /* Nothing else to do if there is no buffer. */
6645 /* Make sure buffer is large enough. */
6646 if (size < sizeof(*out))
6648 /* Initialize buffer. */
6649 memset(out, 0x00, sizeof(*out));
6650 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
6653 ctx->objmask = NULL;
6654 if (!out->command) {
6655 if (ctx->curr != SET)
6657 if (sizeof(*out) > size)
6659 out->command = ctx->curr;
6660 out->args.vc.data = (uint8_t *)out + size;
6661 ctx->object = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6667 /** No completion. */
6669 comp_none(struct context *ctx, const struct token *token,
6670 unsigned int ent, char *buf, unsigned int size)
6680 /** Complete boolean values. */
6682 comp_boolean(struct context *ctx, const struct token *token,
6683 unsigned int ent, char *buf, unsigned int size)
6689 for (i = 0; boolean_name[i]; ++i)
6690 if (buf && i == ent)
6691 return strlcpy(buf, boolean_name[i], size);
6697 /** Complete action names. */
6699 comp_action(struct context *ctx, const struct token *token,
6700 unsigned int ent, char *buf, unsigned int size)
6706 for (i = 0; next_action[i]; ++i)
6707 if (buf && i == ent)
6708 return strlcpy(buf, token_list[next_action[i]].name,
6715 /** Complete available ports. */
6717 comp_port(struct context *ctx, const struct token *token,
6718 unsigned int ent, char *buf, unsigned int size)
6725 RTE_ETH_FOREACH_DEV(p) {
6726 if (buf && i == ent)
6727 return snprintf(buf, size, "%u", p);
6735 /** Complete available rule IDs. */
6737 comp_rule_id(struct context *ctx, const struct token *token,
6738 unsigned int ent, char *buf, unsigned int size)
6741 struct rte_port *port;
6742 struct port_flow *pf;
6745 if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
6746 ctx->port == (portid_t)RTE_PORT_ALL)
6748 port = &ports[ctx->port];
6749 for (pf = port->flow_list; pf != NULL; pf = pf->next) {
6750 if (buf && i == ent)
6751 return snprintf(buf, size, "%u", pf->id);
6759 /** Complete type field for RSS action. */
6761 comp_vc_action_rss_type(struct context *ctx, const struct token *token,
6762 unsigned int ent, char *buf, unsigned int size)
6768 for (i = 0; rss_type_table[i].str; ++i)
6773 return strlcpy(buf, rss_type_table[ent].str, size);
6775 return snprintf(buf, size, "end");
6779 /** Complete queue field for RSS action. */
6781 comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
6782 unsigned int ent, char *buf, unsigned int size)
6789 return snprintf(buf, size, "%u", ent);
6791 return snprintf(buf, size, "end");
6795 /** Complete index number for set raw_encap/raw_decap commands. */
6797 comp_set_raw_index(struct context *ctx, const struct token *token,
6798 unsigned int ent, char *buf, unsigned int size)
6804 RTE_SET_USED(token);
6805 for (idx = 0; idx < RAW_ENCAP_CONFS_MAX_NUM; ++idx) {
6806 if (buf && idx == ent)
6807 return snprintf(buf, size, "%u", idx);
6813 /** Complete index number for set raw_encap/raw_decap commands. */
6815 comp_set_sample_index(struct context *ctx, const struct token *token,
6816 unsigned int ent, char *buf, unsigned int size)
6822 RTE_SET_USED(token);
6823 for (idx = 0; idx < RAW_SAMPLE_CONFS_MAX_NUM; ++idx) {
6824 if (buf && idx == ent)
6825 return snprintf(buf, size, "%u", idx);
6831 /** Internal context. */
6832 static struct context cmd_flow_context;
6834 /** Global parser instance (cmdline API). */
6835 cmdline_parse_inst_t cmd_flow;
6836 cmdline_parse_inst_t cmd_set_raw;
6838 /** Initialize context. */
6840 cmd_flow_context_init(struct context *ctx)
6842 /* A full memset() is not necessary. */
6852 ctx->objmask = NULL;
6855 /** Parse a token (cmdline API). */
6857 cmd_flow_parse(cmdline_parse_token_hdr_t *hdr, const char *src, void *result,
6860 struct context *ctx = &cmd_flow_context;
6861 const struct token *token;
6862 const enum index *list;
6867 token = &token_list[ctx->curr];
6868 /* Check argument length. */
6871 for (len = 0; src[len]; ++len)
6872 if (src[len] == '#' || isspace(src[len]))
6876 /* Last argument and EOL detection. */
6877 for (i = len; src[i]; ++i)
6878 if (src[i] == '#' || src[i] == '\r' || src[i] == '\n')
6880 else if (!isspace(src[i])) {
6885 if (src[i] == '\r' || src[i] == '\n') {
6889 /* Initialize context if necessary. */
6890 if (!ctx->next_num) {
6893 ctx->next[ctx->next_num++] = token->next[0];
6895 /* Process argument through candidates. */
6896 ctx->prev = ctx->curr;
6897 list = ctx->next[ctx->next_num - 1];
6898 for (i = 0; list[i]; ++i) {
6899 const struct token *next = &token_list[list[i]];
6902 ctx->curr = list[i];
6904 tmp = next->call(ctx, next, src, len, result, size);
6906 tmp = parse_default(ctx, next, src, len, result, size);
6907 if (tmp == -1 || tmp != len)
6915 /* Push subsequent tokens if any. */
6917 for (i = 0; token->next[i]; ++i) {
6918 if (ctx->next_num == RTE_DIM(ctx->next))
6920 ctx->next[ctx->next_num++] = token->next[i];
6922 /* Push arguments if any. */
6924 for (i = 0; token->args[i]; ++i) {
6925 if (ctx->args_num == RTE_DIM(ctx->args))
6927 ctx->args[ctx->args_num++] = token->args[i];
6932 /** Return number of completion entries (cmdline API). */
6934 cmd_flow_complete_get_nb(cmdline_parse_token_hdr_t *hdr)
6936 struct context *ctx = &cmd_flow_context;
6937 const struct token *token = &token_list[ctx->curr];
6938 const enum index *list;
6942 /* Count number of tokens in current list. */
6944 list = ctx->next[ctx->next_num - 1];
6946 list = token->next[0];
6947 for (i = 0; list[i]; ++i)
6952 * If there is a single token, use its completion callback, otherwise
6953 * return the number of entries.
6955 token = &token_list[list[0]];
6956 if (i == 1 && token->comp) {
6957 /* Save index for cmd_flow_get_help(). */
6958 ctx->prev = list[0];
6959 return token->comp(ctx, token, 0, NULL, 0);
6964 /** Return a completion entry (cmdline API). */
6966 cmd_flow_complete_get_elt(cmdline_parse_token_hdr_t *hdr, int index,
6967 char *dst, unsigned int size)
6969 struct context *ctx = &cmd_flow_context;
6970 const struct token *token = &token_list[ctx->curr];
6971 const enum index *list;
6975 /* Count number of tokens in current list. */
6977 list = ctx->next[ctx->next_num - 1];
6979 list = token->next[0];
6980 for (i = 0; list[i]; ++i)
6984 /* If there is a single token, use its completion callback. */
6985 token = &token_list[list[0]];
6986 if (i == 1 && token->comp) {
6987 /* Save index for cmd_flow_get_help(). */
6988 ctx->prev = list[0];
6989 return token->comp(ctx, token, index, dst, size) < 0 ? -1 : 0;
6991 /* Otherwise make sure the index is valid and use defaults. */
6994 token = &token_list[list[index]];
6995 strlcpy(dst, token->name, size);
6996 /* Save index for cmd_flow_get_help(). */
6997 ctx->prev = list[index];
7001 /** Populate help strings for current token (cmdline API). */
7003 cmd_flow_get_help(cmdline_parse_token_hdr_t *hdr, char *dst, unsigned int size)
7005 struct context *ctx = &cmd_flow_context;
7006 const struct token *token = &token_list[ctx->prev];
7011 /* Set token type and update global help with details. */
7012 strlcpy(dst, (token->type ? token->type : "TOKEN"), size);
7014 cmd_flow.help_str = token->help;
7016 cmd_flow.help_str = token->name;
7020 /** Token definition template (cmdline API). */
7021 static struct cmdline_token_hdr cmd_flow_token_hdr = {
7022 .ops = &(struct cmdline_token_ops){
7023 .parse = cmd_flow_parse,
7024 .complete_get_nb = cmd_flow_complete_get_nb,
7025 .complete_get_elt = cmd_flow_complete_get_elt,
7026 .get_help = cmd_flow_get_help,
7031 /** Populate the next dynamic token. */
7033 cmd_flow_tok(cmdline_parse_token_hdr_t **hdr,
7034 cmdline_parse_token_hdr_t **hdr_inst)
7036 struct context *ctx = &cmd_flow_context;
7038 /* Always reinitialize context before requesting the first token. */
7039 if (!(hdr_inst - cmd_flow.tokens))
7040 cmd_flow_context_init(ctx);
7041 /* Return NULL when no more tokens are expected. */
7042 if (!ctx->next_num && ctx->curr) {
7046 /* Determine if command should end here. */
7047 if (ctx->eol && ctx->last && ctx->next_num) {
7048 const enum index *list = ctx->next[ctx->next_num - 1];
7051 for (i = 0; list[i]; ++i) {
7058 *hdr = &cmd_flow_token_hdr;
7061 /** Dispatch parsed buffer to function calls. */
7063 cmd_flow_parsed(const struct buffer *in)
7065 switch (in->command) {
7066 case SHARED_ACTION_CREATE:
7067 port_shared_action_create(
7068 in->port, in->args.vc.attr.group,
7069 &((const struct rte_flow_shared_action_conf) {
7070 .ingress = in->args.vc.attr.ingress,
7071 .egress = in->args.vc.attr.egress,
7073 in->args.vc.actions);
7075 case SHARED_ACTION_DESTROY:
7076 port_shared_action_destroy(in->port,
7077 in->args.sa_destroy.action_id_n,
7078 in->args.sa_destroy.action_id);
7080 case SHARED_ACTION_UPDATE:
7081 port_shared_action_update(in->port, in->args.vc.attr.group,
7082 in->args.vc.actions);
7084 case SHARED_ACTION_QUERY:
7085 port_shared_action_query(in->port, in->args.sa.action_id);
7088 port_flow_validate(in->port, &in->args.vc.attr,
7089 in->args.vc.pattern, in->args.vc.actions);
7092 port_flow_create(in->port, &in->args.vc.attr,
7093 in->args.vc.pattern, in->args.vc.actions);
7096 port_flow_destroy(in->port, in->args.destroy.rule_n,
7097 in->args.destroy.rule);
7100 port_flow_flush(in->port);
7103 port_flow_dump(in->port, in->args.dump.file);
7106 port_flow_query(in->port, in->args.query.rule,
7107 &in->args.query.action);
7110 port_flow_list(in->port, in->args.list.group_n,
7111 in->args.list.group);
7114 port_flow_isolate(in->port, in->args.isolate.set);
7117 port_flow_aged(in->port, in->args.aged.destroy);
7124 /** Token generator and output processing callback (cmdline API). */
7126 cmd_flow_cb(void *arg0, struct cmdline *cl, void *arg2)
7129 cmd_flow_tok(arg0, arg2);
7131 cmd_flow_parsed(arg0);
7134 /** Global parser instance (cmdline API). */
7135 cmdline_parse_inst_t cmd_flow = {
7137 .data = NULL, /**< Unused. */
7138 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
7141 }, /**< Tokens are returned by cmd_flow_tok(). */
7144 /** set cmd facility. Reuse cmd flow's infrastructure as much as possible. */
7147 update_fields(uint8_t *buf, struct rte_flow_item *item, uint16_t next_proto)
7149 struct rte_flow_item_ipv4 *ipv4;
7150 struct rte_flow_item_eth *eth;
7151 struct rte_flow_item_ipv6 *ipv6;
7152 struct rte_flow_item_vxlan *vxlan;
7153 struct rte_flow_item_vxlan_gpe *gpe;
7154 struct rte_flow_item_nvgre *nvgre;
7155 uint32_t ipv6_vtc_flow;
7157 switch (item->type) {
7158 case RTE_FLOW_ITEM_TYPE_ETH:
7159 eth = (struct rte_flow_item_eth *)buf;
7161 eth->type = rte_cpu_to_be_16(next_proto);
7163 case RTE_FLOW_ITEM_TYPE_IPV4:
7164 ipv4 = (struct rte_flow_item_ipv4 *)buf;
7165 ipv4->hdr.version_ihl = 0x45;
7166 if (next_proto && ipv4->hdr.next_proto_id == 0)
7167 ipv4->hdr.next_proto_id = (uint8_t)next_proto;
7169 case RTE_FLOW_ITEM_TYPE_IPV6:
7170 ipv6 = (struct rte_flow_item_ipv6 *)buf;
7171 if (next_proto && ipv6->hdr.proto == 0)
7172 ipv6->hdr.proto = (uint8_t)next_proto;
7173 ipv6_vtc_flow = rte_be_to_cpu_32(ipv6->hdr.vtc_flow);
7174 ipv6_vtc_flow &= 0x0FFFFFFF; /*< reset version bits. */
7175 ipv6_vtc_flow |= 0x60000000; /*< set ipv6 version. */
7176 ipv6->hdr.vtc_flow = rte_cpu_to_be_32(ipv6_vtc_flow);
7178 case RTE_FLOW_ITEM_TYPE_VXLAN:
7179 vxlan = (struct rte_flow_item_vxlan *)buf;
7180 vxlan->flags = 0x08;
7182 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
7183 gpe = (struct rte_flow_item_vxlan_gpe *)buf;
7186 case RTE_FLOW_ITEM_TYPE_NVGRE:
7187 nvgre = (struct rte_flow_item_nvgre *)buf;
7188 nvgre->protocol = rte_cpu_to_be_16(0x6558);
7189 nvgre->c_k_s_rsvd0_ver = rte_cpu_to_be_16(0x2000);
7196 /** Helper of get item's default mask. */
7198 flow_item_default_mask(const struct rte_flow_item *item)
7200 const void *mask = NULL;
7201 static rte_be32_t gre_key_default_mask = RTE_BE32(UINT32_MAX);
7203 switch (item->type) {
7204 case RTE_FLOW_ITEM_TYPE_ANY:
7205 mask = &rte_flow_item_any_mask;
7207 case RTE_FLOW_ITEM_TYPE_VF:
7208 mask = &rte_flow_item_vf_mask;
7210 case RTE_FLOW_ITEM_TYPE_PORT_ID:
7211 mask = &rte_flow_item_port_id_mask;
7213 case RTE_FLOW_ITEM_TYPE_RAW:
7214 mask = &rte_flow_item_raw_mask;
7216 case RTE_FLOW_ITEM_TYPE_ETH:
7217 mask = &rte_flow_item_eth_mask;
7219 case RTE_FLOW_ITEM_TYPE_VLAN:
7220 mask = &rte_flow_item_vlan_mask;
7222 case RTE_FLOW_ITEM_TYPE_IPV4:
7223 mask = &rte_flow_item_ipv4_mask;
7225 case RTE_FLOW_ITEM_TYPE_IPV6:
7226 mask = &rte_flow_item_ipv6_mask;
7228 case RTE_FLOW_ITEM_TYPE_ICMP:
7229 mask = &rte_flow_item_icmp_mask;
7231 case RTE_FLOW_ITEM_TYPE_UDP:
7232 mask = &rte_flow_item_udp_mask;
7234 case RTE_FLOW_ITEM_TYPE_TCP:
7235 mask = &rte_flow_item_tcp_mask;
7237 case RTE_FLOW_ITEM_TYPE_SCTP:
7238 mask = &rte_flow_item_sctp_mask;
7240 case RTE_FLOW_ITEM_TYPE_VXLAN:
7241 mask = &rte_flow_item_vxlan_mask;
7243 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
7244 mask = &rte_flow_item_vxlan_gpe_mask;
7246 case RTE_FLOW_ITEM_TYPE_E_TAG:
7247 mask = &rte_flow_item_e_tag_mask;
7249 case RTE_FLOW_ITEM_TYPE_NVGRE:
7250 mask = &rte_flow_item_nvgre_mask;
7252 case RTE_FLOW_ITEM_TYPE_MPLS:
7253 mask = &rte_flow_item_mpls_mask;
7255 case RTE_FLOW_ITEM_TYPE_GRE:
7256 mask = &rte_flow_item_gre_mask;
7258 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
7259 mask = &gre_key_default_mask;
7261 case RTE_FLOW_ITEM_TYPE_META:
7262 mask = &rte_flow_item_meta_mask;
7264 case RTE_FLOW_ITEM_TYPE_FUZZY:
7265 mask = &rte_flow_item_fuzzy_mask;
7267 case RTE_FLOW_ITEM_TYPE_GTP:
7268 mask = &rte_flow_item_gtp_mask;
7270 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
7271 mask = &rte_flow_item_gtp_psc_mask;
7273 case RTE_FLOW_ITEM_TYPE_GENEVE:
7274 mask = &rte_flow_item_geneve_mask;
7276 case RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID:
7277 mask = &rte_flow_item_pppoe_proto_id_mask;
7279 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
7280 mask = &rte_flow_item_l2tpv3oip_mask;
7282 case RTE_FLOW_ITEM_TYPE_ESP:
7283 mask = &rte_flow_item_esp_mask;
7285 case RTE_FLOW_ITEM_TYPE_AH:
7286 mask = &rte_flow_item_ah_mask;
7288 case RTE_FLOW_ITEM_TYPE_PFCP:
7289 mask = &rte_flow_item_pfcp_mask;
7297 /** Dispatch parsed buffer to function calls. */
7299 cmd_set_raw_parsed_sample(const struct buffer *in)
7301 uint32_t n = in->args.vc.actions_n;
7303 struct rte_flow_action *action = NULL;
7304 struct rte_flow_action *data = NULL;
7306 uint16_t idx = in->port; /* We borrow port field as index */
7307 uint32_t max_size = sizeof(struct rte_flow_action) *
7308 ACTION_SAMPLE_ACTIONS_NUM;
7310 RTE_ASSERT(in->command == SET_SAMPLE_ACTIONS);
7311 data = (struct rte_flow_action *)&raw_sample_confs[idx].data;
7312 memset(data, 0x00, max_size);
7313 for (; i <= n - 1; i++) {
7314 action = in->args.vc.actions + i;
7315 if (action->type == RTE_FLOW_ACTION_TYPE_END)
7317 switch (action->type) {
7318 case RTE_FLOW_ACTION_TYPE_MARK:
7319 size = sizeof(struct rte_flow_action_mark);
7320 rte_memcpy(&sample_mark[idx],
7321 (const void *)action->conf, size);
7322 action->conf = &sample_mark[idx];
7324 case RTE_FLOW_ACTION_TYPE_COUNT:
7325 size = sizeof(struct rte_flow_action_count);
7326 rte_memcpy(&sample_count[idx],
7327 (const void *)action->conf, size);
7328 action->conf = &sample_count[idx];
7330 case RTE_FLOW_ACTION_TYPE_QUEUE:
7331 size = sizeof(struct rte_flow_action_queue);
7332 rte_memcpy(&sample_queue[idx],
7333 (const void *)action->conf, size);
7334 action->conf = &sample_queue[idx];
7336 case RTE_FLOW_ACTION_TYPE_RAW_ENCAP:
7337 size = sizeof(struct rte_flow_action_raw_encap);
7338 rte_memcpy(&sample_encap[idx],
7339 (const void *)action->conf, size);
7340 action->conf = &sample_encap[idx];
7342 case RTE_FLOW_ACTION_TYPE_PORT_ID:
7343 size = sizeof(struct rte_flow_action_port_id);
7344 rte_memcpy(&sample_port_id[idx],
7345 (const void *)action->conf, size);
7346 action->conf = &sample_port_id[idx];
7349 printf("Error - Not supported action\n");
7352 rte_memcpy(data, action, sizeof(struct rte_flow_action));
7357 /** Dispatch parsed buffer to function calls. */
7359 cmd_set_raw_parsed(const struct buffer *in)
7361 uint32_t n = in->args.vc.pattern_n;
7363 struct rte_flow_item *item = NULL;
7365 uint8_t *data = NULL;
7366 uint8_t *data_tail = NULL;
7367 size_t *total_size = NULL;
7368 uint16_t upper_layer = 0;
7370 uint16_t idx = in->port; /* We borrow port field as index */
7372 if (in->command == SET_SAMPLE_ACTIONS)
7373 return cmd_set_raw_parsed_sample(in);
7374 RTE_ASSERT(in->command == SET_RAW_ENCAP ||
7375 in->command == SET_RAW_DECAP);
7376 if (in->command == SET_RAW_ENCAP) {
7377 total_size = &raw_encap_confs[idx].size;
7378 data = (uint8_t *)&raw_encap_confs[idx].data;
7380 total_size = &raw_decap_confs[idx].size;
7381 data = (uint8_t *)&raw_decap_confs[idx].data;
7384 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
7385 /* process hdr from upper layer to low layer (L3/L4 -> L2). */
7386 data_tail = data + ACTION_RAW_ENCAP_MAX_DATA;
7387 for (i = n - 1 ; i >= 0; --i) {
7388 item = in->args.vc.pattern + i;
7389 if (item->spec == NULL)
7390 item->spec = flow_item_default_mask(item);
7391 switch (item->type) {
7392 case RTE_FLOW_ITEM_TYPE_ETH:
7393 size = sizeof(struct rte_flow_item_eth);
7395 case RTE_FLOW_ITEM_TYPE_VLAN:
7396 size = sizeof(struct rte_flow_item_vlan);
7397 proto = RTE_ETHER_TYPE_VLAN;
7399 case RTE_FLOW_ITEM_TYPE_IPV4:
7400 size = sizeof(struct rte_flow_item_ipv4);
7401 proto = RTE_ETHER_TYPE_IPV4;
7403 case RTE_FLOW_ITEM_TYPE_IPV6:
7404 size = sizeof(struct rte_flow_item_ipv6);
7405 proto = RTE_ETHER_TYPE_IPV6;
7407 case RTE_FLOW_ITEM_TYPE_UDP:
7408 size = sizeof(struct rte_flow_item_udp);
7411 case RTE_FLOW_ITEM_TYPE_TCP:
7412 size = sizeof(struct rte_flow_item_tcp);
7415 case RTE_FLOW_ITEM_TYPE_VXLAN:
7416 size = sizeof(struct rte_flow_item_vxlan);
7418 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
7419 size = sizeof(struct rte_flow_item_vxlan_gpe);
7421 case RTE_FLOW_ITEM_TYPE_GRE:
7422 size = sizeof(struct rte_flow_item_gre);
7425 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
7426 size = sizeof(rte_be32_t);
7429 case RTE_FLOW_ITEM_TYPE_MPLS:
7430 size = sizeof(struct rte_flow_item_mpls);
7433 case RTE_FLOW_ITEM_TYPE_NVGRE:
7434 size = sizeof(struct rte_flow_item_nvgre);
7437 case RTE_FLOW_ITEM_TYPE_GENEVE:
7438 size = sizeof(struct rte_flow_item_geneve);
7440 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
7441 size = sizeof(struct rte_flow_item_l2tpv3oip);
7444 case RTE_FLOW_ITEM_TYPE_ESP:
7445 size = sizeof(struct rte_flow_item_esp);
7448 case RTE_FLOW_ITEM_TYPE_AH:
7449 size = sizeof(struct rte_flow_item_ah);
7452 case RTE_FLOW_ITEM_TYPE_GTP:
7453 size = sizeof(struct rte_flow_item_gtp);
7455 case RTE_FLOW_ITEM_TYPE_PFCP:
7456 size = sizeof(struct rte_flow_item_pfcp);
7459 printf("Error - Not supported item\n");
7461 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
7464 *total_size += size;
7465 rte_memcpy(data_tail - (*total_size), item->spec, size);
7466 /* update some fields which cannot be set by cmdline */
7467 update_fields((data_tail - (*total_size)), item,
7469 upper_layer = proto;
7471 if (verbose_level & 0x1)
7472 printf("total data size is %zu\n", (*total_size));
7473 RTE_ASSERT((*total_size) <= ACTION_RAW_ENCAP_MAX_DATA);
7474 memmove(data, (data_tail - (*total_size)), *total_size);
7477 /** Populate help strings for current token (cmdline API). */
7479 cmd_set_raw_get_help(cmdline_parse_token_hdr_t *hdr, char *dst,
7482 struct context *ctx = &cmd_flow_context;
7483 const struct token *token = &token_list[ctx->prev];
7488 /* Set token type and update global help with details. */
7489 snprintf(dst, size, "%s", (token->type ? token->type : "TOKEN"));
7491 cmd_set_raw.help_str = token->help;
7493 cmd_set_raw.help_str = token->name;
7497 /** Token definition template (cmdline API). */
7498 static struct cmdline_token_hdr cmd_set_raw_token_hdr = {
7499 .ops = &(struct cmdline_token_ops){
7500 .parse = cmd_flow_parse,
7501 .complete_get_nb = cmd_flow_complete_get_nb,
7502 .complete_get_elt = cmd_flow_complete_get_elt,
7503 .get_help = cmd_set_raw_get_help,
7508 /** Populate the next dynamic token. */
7510 cmd_set_raw_tok(cmdline_parse_token_hdr_t **hdr,
7511 cmdline_parse_token_hdr_t **hdr_inst)
7513 struct context *ctx = &cmd_flow_context;
7515 /* Always reinitialize context before requesting the first token. */
7516 if (!(hdr_inst - cmd_set_raw.tokens)) {
7517 cmd_flow_context_init(ctx);
7518 ctx->curr = START_SET;
7520 /* Return NULL when no more tokens are expected. */
7521 if (!ctx->next_num && (ctx->curr != START_SET)) {
7525 /* Determine if command should end here. */
7526 if (ctx->eol && ctx->last && ctx->next_num) {
7527 const enum index *list = ctx->next[ctx->next_num - 1];
7530 for (i = 0; list[i]; ++i) {
7537 *hdr = &cmd_set_raw_token_hdr;
7540 /** Token generator and output processing callback (cmdline API). */
7542 cmd_set_raw_cb(void *arg0, struct cmdline *cl, void *arg2)
7545 cmd_set_raw_tok(arg0, arg2);
7547 cmd_set_raw_parsed(arg0);
7550 /** Global parser instance (cmdline API). */
7551 cmdline_parse_inst_t cmd_set_raw = {
7552 .f = cmd_set_raw_cb,
7553 .data = NULL, /**< Unused. */
7554 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
7557 }, /**< Tokens are returned by cmd_flow_tok(). */
7560 /* *** display raw_encap/raw_decap buf */
7561 struct cmd_show_set_raw_result {
7562 cmdline_fixed_string_t cmd_show;
7563 cmdline_fixed_string_t cmd_what;
7564 cmdline_fixed_string_t cmd_all;
7569 cmd_show_set_raw_parsed(void *parsed_result, struct cmdline *cl, void *data)
7571 struct cmd_show_set_raw_result *res = parsed_result;
7572 uint16_t index = res->cmd_index;
7574 uint8_t *raw_data = NULL;
7575 size_t raw_size = 0;
7576 char title[16] = {0};
7580 if (!strcmp(res->cmd_all, "all")) {
7583 } else if (index >= RAW_ENCAP_CONFS_MAX_NUM) {
7584 printf("index should be 0-%u\n", RAW_ENCAP_CONFS_MAX_NUM - 1);
7588 if (!strcmp(res->cmd_what, "raw_encap")) {
7589 raw_data = (uint8_t *)&raw_encap_confs[index].data;
7590 raw_size = raw_encap_confs[index].size;
7591 snprintf(title, 16, "\nindex: %u", index);
7592 rte_hexdump(stdout, title, raw_data, raw_size);
7594 raw_data = (uint8_t *)&raw_decap_confs[index].data;
7595 raw_size = raw_decap_confs[index].size;
7596 snprintf(title, 16, "\nindex: %u", index);
7597 rte_hexdump(stdout, title, raw_data, raw_size);
7599 } while (all && ++index < RAW_ENCAP_CONFS_MAX_NUM);
7602 cmdline_parse_token_string_t cmd_show_set_raw_cmd_show =
7603 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
7605 cmdline_parse_token_string_t cmd_show_set_raw_cmd_what =
7606 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
7607 cmd_what, "raw_encap#raw_decap");
7608 cmdline_parse_token_num_t cmd_show_set_raw_cmd_index =
7609 TOKEN_NUM_INITIALIZER(struct cmd_show_set_raw_result,
7611 cmdline_parse_token_string_t cmd_show_set_raw_cmd_all =
7612 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
7614 cmdline_parse_inst_t cmd_show_set_raw = {
7615 .f = cmd_show_set_raw_parsed,
7617 .help_str = "show <raw_encap|raw_decap> <index>",
7619 (void *)&cmd_show_set_raw_cmd_show,
7620 (void *)&cmd_show_set_raw_cmd_what,
7621 (void *)&cmd_show_set_raw_cmd_index,
7625 cmdline_parse_inst_t cmd_show_set_raw_all = {
7626 .f = cmd_show_set_raw_parsed,
7628 .help_str = "show <raw_encap|raw_decap> all",
7630 (void *)&cmd_show_set_raw_cmd_show,
7631 (void *)&cmd_show_set_raw_cmd_what,
7632 (void *)&cmd_show_set_raw_cmd_all,