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. */
150 ITEM_VLAN_INNER_TYPE,
151 ITEM_VLAN_HAS_MORE_VLAN,
154 ITEM_IPV4_FRAGMENT_OFFSET,
166 ITEM_IPV6_HAS_FRAG_EXT,
187 ITEM_E_TAG_GRP_ECID_B,
196 ITEM_GRE_C_RSVD0_VER,
214 ITEM_ARP_ETH_IPV4_SHA,
215 ITEM_ARP_ETH_IPV4_SPA,
216 ITEM_ARP_ETH_IPV4_THA,
217 ITEM_ARP_ETH_IPV4_TPA,
219 ITEM_IPV6_EXT_NEXT_HDR,
221 ITEM_IPV6_FRAG_EXT_NEXT_HDR,
222 ITEM_IPV6_FRAG_EXT_FRAG_DATA,
227 ITEM_ICMP6_ND_NS_TARGET_ADDR,
229 ITEM_ICMP6_ND_NA_TARGET_ADDR,
231 ITEM_ICMP6_ND_OPT_TYPE,
232 ITEM_ICMP6_ND_OPT_SLA_ETH,
233 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
234 ITEM_ICMP6_ND_OPT_TLA_ETH,
235 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
248 ITEM_HIGIG2_CLASSIFICATION,
254 ITEM_L2TPV3OIP_SESSION_ID,
264 ITEM_ECPRI_COMMON_TYPE,
265 ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
266 ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
267 ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
268 ITEM_ECPRI_MSG_IQ_DATA_PCID,
269 ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
270 ITEM_ECPRI_MSG_DLY_MSR_MSRID,
272 /* Validate/create actions. */
292 ACTION_RSS_FUNC_DEFAULT,
293 ACTION_RSS_FUNC_TOEPLITZ,
294 ACTION_RSS_FUNC_SIMPLE_XOR,
295 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ,
307 ACTION_PHY_PORT_ORIGINAL,
308 ACTION_PHY_PORT_INDEX,
310 ACTION_PORT_ID_ORIGINAL,
314 ACTION_OF_SET_MPLS_TTL,
315 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
316 ACTION_OF_DEC_MPLS_TTL,
317 ACTION_OF_SET_NW_TTL,
318 ACTION_OF_SET_NW_TTL_NW_TTL,
319 ACTION_OF_DEC_NW_TTL,
320 ACTION_OF_COPY_TTL_OUT,
321 ACTION_OF_COPY_TTL_IN,
324 ACTION_OF_PUSH_VLAN_ETHERTYPE,
325 ACTION_OF_SET_VLAN_VID,
326 ACTION_OF_SET_VLAN_VID_VLAN_VID,
327 ACTION_OF_SET_VLAN_PCP,
328 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
330 ACTION_OF_POP_MPLS_ETHERTYPE,
332 ACTION_OF_PUSH_MPLS_ETHERTYPE,
339 ACTION_MPLSOGRE_ENCAP,
340 ACTION_MPLSOGRE_DECAP,
341 ACTION_MPLSOUDP_ENCAP,
342 ACTION_MPLSOUDP_DECAP,
344 ACTION_SET_IPV4_SRC_IPV4_SRC,
346 ACTION_SET_IPV4_DST_IPV4_DST,
348 ACTION_SET_IPV6_SRC_IPV6_SRC,
350 ACTION_SET_IPV6_DST_IPV6_DST,
352 ACTION_SET_TP_SRC_TP_SRC,
354 ACTION_SET_TP_DST_TP_DST,
360 ACTION_SET_MAC_SRC_MAC_SRC,
362 ACTION_SET_MAC_DST_MAC_DST,
364 ACTION_INC_TCP_SEQ_VALUE,
366 ACTION_DEC_TCP_SEQ_VALUE,
368 ACTION_INC_TCP_ACK_VALUE,
370 ACTION_DEC_TCP_ACK_VALUE,
373 ACTION_RAW_ENCAP_INDEX,
374 ACTION_RAW_ENCAP_INDEX_VALUE,
375 ACTION_RAW_DECAP_INDEX,
376 ACTION_RAW_DECAP_INDEX_VALUE,
379 ACTION_SET_TAG_INDEX,
382 ACTION_SET_META_DATA,
383 ACTION_SET_META_MASK,
384 ACTION_SET_IPV4_DSCP,
385 ACTION_SET_IPV4_DSCP_VALUE,
386 ACTION_SET_IPV6_DSCP,
387 ACTION_SET_IPV6_DSCP_VALUE,
393 ACTION_SAMPLE_INDEX_VALUE,
395 SHARED_ACTION_ID2PTR,
398 /** Maximum size for pattern in struct rte_flow_item_raw. */
399 #define ITEM_RAW_PATTERN_SIZE 40
401 /** Storage size for struct rte_flow_item_raw including pattern. */
402 #define ITEM_RAW_SIZE \
403 (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE)
405 /** Maximum number of queue indices in struct rte_flow_action_rss. */
406 #define ACTION_RSS_QUEUE_NUM 128
408 /** Storage for struct rte_flow_action_rss including external data. */
409 struct action_rss_data {
410 struct rte_flow_action_rss conf;
411 uint8_t key[RSS_HASH_KEY_LENGTH];
412 uint16_t queue[ACTION_RSS_QUEUE_NUM];
415 /** Maximum data size in struct rte_flow_action_raw_encap. */
416 #define ACTION_RAW_ENCAP_MAX_DATA 128
417 #define RAW_ENCAP_CONFS_MAX_NUM 8
419 /** Storage for struct rte_flow_action_raw_encap. */
420 struct raw_encap_conf {
421 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
422 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
426 struct raw_encap_conf raw_encap_confs[RAW_ENCAP_CONFS_MAX_NUM];
428 /** Storage for struct rte_flow_action_raw_encap including external data. */
429 struct action_raw_encap_data {
430 struct rte_flow_action_raw_encap conf;
431 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
432 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
436 /** Storage for struct rte_flow_action_raw_decap. */
437 struct raw_decap_conf {
438 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
442 struct raw_decap_conf raw_decap_confs[RAW_ENCAP_CONFS_MAX_NUM];
444 /** Storage for struct rte_flow_action_raw_decap including external data. */
445 struct action_raw_decap_data {
446 struct rte_flow_action_raw_decap conf;
447 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
451 struct vxlan_encap_conf vxlan_encap_conf = {
455 .vni = "\x00\x00\x00",
457 .udp_dst = RTE_BE16(RTE_VXLAN_DEFAULT_PORT),
458 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
459 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
460 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
461 "\x00\x00\x00\x00\x00\x00\x00\x01",
462 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
463 "\x00\x00\x00\x00\x00\x00\x11\x11",
467 .eth_src = "\x00\x00\x00\x00\x00\x00",
468 .eth_dst = "\xff\xff\xff\xff\xff\xff",
471 /** Maximum number of items in struct rte_flow_action_vxlan_encap. */
472 #define ACTION_VXLAN_ENCAP_ITEMS_NUM 6
474 /** Storage for struct rte_flow_action_vxlan_encap including external data. */
475 struct action_vxlan_encap_data {
476 struct rte_flow_action_vxlan_encap conf;
477 struct rte_flow_item items[ACTION_VXLAN_ENCAP_ITEMS_NUM];
478 struct rte_flow_item_eth item_eth;
479 struct rte_flow_item_vlan item_vlan;
481 struct rte_flow_item_ipv4 item_ipv4;
482 struct rte_flow_item_ipv6 item_ipv6;
484 struct rte_flow_item_udp item_udp;
485 struct rte_flow_item_vxlan item_vxlan;
488 struct nvgre_encap_conf nvgre_encap_conf = {
491 .tni = "\x00\x00\x00",
492 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
493 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
494 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
495 "\x00\x00\x00\x00\x00\x00\x00\x01",
496 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
497 "\x00\x00\x00\x00\x00\x00\x11\x11",
499 .eth_src = "\x00\x00\x00\x00\x00\x00",
500 .eth_dst = "\xff\xff\xff\xff\xff\xff",
503 /** Maximum number of items in struct rte_flow_action_nvgre_encap. */
504 #define ACTION_NVGRE_ENCAP_ITEMS_NUM 5
506 /** Storage for struct rte_flow_action_nvgre_encap including external data. */
507 struct action_nvgre_encap_data {
508 struct rte_flow_action_nvgre_encap conf;
509 struct rte_flow_item items[ACTION_NVGRE_ENCAP_ITEMS_NUM];
510 struct rte_flow_item_eth item_eth;
511 struct rte_flow_item_vlan item_vlan;
513 struct rte_flow_item_ipv4 item_ipv4;
514 struct rte_flow_item_ipv6 item_ipv6;
516 struct rte_flow_item_nvgre item_nvgre;
519 struct l2_encap_conf l2_encap_conf;
521 struct l2_decap_conf l2_decap_conf;
523 struct mplsogre_encap_conf mplsogre_encap_conf;
525 struct mplsogre_decap_conf mplsogre_decap_conf;
527 struct mplsoudp_encap_conf mplsoudp_encap_conf;
529 struct mplsoudp_decap_conf mplsoudp_decap_conf;
531 #define ACTION_SAMPLE_ACTIONS_NUM 10
532 #define RAW_SAMPLE_CONFS_MAX_NUM 8
533 /** Storage for struct rte_flow_action_sample including external data. */
534 struct action_sample_data {
535 struct rte_flow_action_sample conf;
538 /** Storage for struct rte_flow_action_sample. */
539 struct raw_sample_conf {
540 struct rte_flow_action data[ACTION_SAMPLE_ACTIONS_NUM];
542 struct raw_sample_conf raw_sample_confs[RAW_SAMPLE_CONFS_MAX_NUM];
543 struct rte_flow_action_mark sample_mark[RAW_SAMPLE_CONFS_MAX_NUM];
544 struct rte_flow_action_queue sample_queue[RAW_SAMPLE_CONFS_MAX_NUM];
545 struct rte_flow_action_count sample_count[RAW_SAMPLE_CONFS_MAX_NUM];
546 struct rte_flow_action_port_id sample_port_id[RAW_SAMPLE_CONFS_MAX_NUM];
547 struct rte_flow_action_raw_encap sample_encap[RAW_SAMPLE_CONFS_MAX_NUM];
549 /** Maximum number of subsequent tokens and arguments on the stack. */
550 #define CTX_STACK_SIZE 16
552 /** Parser context. */
554 /** Stack of subsequent token lists to process. */
555 const enum index *next[CTX_STACK_SIZE];
556 /** Arguments for stacked tokens. */
557 const void *args[CTX_STACK_SIZE];
558 enum index curr; /**< Current token index. */
559 enum index prev; /**< Index of the last token seen. */
560 int next_num; /**< Number of entries in next[]. */
561 int args_num; /**< Number of entries in args[]. */
562 uint32_t eol:1; /**< EOL has been detected. */
563 uint32_t last:1; /**< No more arguments. */
564 portid_t port; /**< Current port ID (for completions). */
565 uint32_t objdata; /**< Object-specific data. */
566 void *object; /**< Address of current object for relative offsets. */
567 void *objmask; /**< Object a full mask must be written to. */
570 /** Token argument. */
572 uint32_t hton:1; /**< Use network byte ordering. */
573 uint32_t sign:1; /**< Value is signed. */
574 uint32_t bounded:1; /**< Value is bounded. */
575 uintmax_t min; /**< Minimum value if bounded. */
576 uintmax_t max; /**< Maximum value if bounded. */
577 uint32_t offset; /**< Relative offset from ctx->object. */
578 uint32_t size; /**< Field size. */
579 const uint8_t *mask; /**< Bit-mask to use instead of offset/size. */
582 /** Parser token definition. */
584 /** Type displayed during completion (defaults to "TOKEN"). */
586 /** Help displayed during completion (defaults to token name). */
588 /** Private data used by parser functions. */
591 * Lists of subsequent tokens to push on the stack. Each call to the
592 * parser consumes the last entry of that stack.
594 const enum index *const *next;
595 /** Arguments stack for subsequent tokens that need them. */
596 const struct arg *const *args;
598 * Token-processing callback, returns -1 in case of error, the
599 * length of the matched string otherwise. If NULL, attempts to
600 * match the token name.
602 * If buf is not NULL, the result should be stored in it according
603 * to context. An error is returned if not large enough.
605 int (*call)(struct context *ctx, const struct token *token,
606 const char *str, unsigned int len,
607 void *buf, unsigned int size);
609 * Callback that provides possible values for this token, used for
610 * completion. Returns -1 in case of error, the number of possible
611 * values otherwise. If NULL, the token name is used.
613 * If buf is not NULL, entry index ent is written to buf and the
614 * full length of the entry is returned (same behavior as
617 int (*comp)(struct context *ctx, const struct token *token,
618 unsigned int ent, char *buf, unsigned int size);
619 /** Mandatory token name, no default value. */
623 /** Static initializer for the next field. */
624 #define NEXT(...) (const enum index *const []){ __VA_ARGS__, NULL, }
626 /** Static initializer for a NEXT() entry. */
627 #define NEXT_ENTRY(...) (const enum index []){ __VA_ARGS__, ZERO, }
629 /** Static initializer for the args field. */
630 #define ARGS(...) (const struct arg *const []){ __VA_ARGS__, NULL, }
632 /** Static initializer for ARGS() to target a field. */
633 #define ARGS_ENTRY(s, f) \
634 (&(const struct arg){ \
635 .offset = offsetof(s, f), \
636 .size = sizeof(((s *)0)->f), \
639 /** Static initializer for ARGS() to target a bit-field. */
640 #define ARGS_ENTRY_BF(s, f, b) \
641 (&(const struct arg){ \
643 .mask = (const void *)&(const s){ .f = (1 << (b)) - 1 }, \
646 /** Static initializer for ARGS() to target an arbitrary bit-mask. */
647 #define ARGS_ENTRY_MASK(s, f, m) \
648 (&(const struct arg){ \
649 .offset = offsetof(s, f), \
650 .size = sizeof(((s *)0)->f), \
651 .mask = (const void *)(m), \
654 /** Same as ARGS_ENTRY_MASK() using network byte ordering for the value. */
655 #define ARGS_ENTRY_MASK_HTON(s, f, m) \
656 (&(const struct arg){ \
658 .offset = offsetof(s, f), \
659 .size = sizeof(((s *)0)->f), \
660 .mask = (const void *)(m), \
663 /** Static initializer for ARGS() to target a pointer. */
664 #define ARGS_ENTRY_PTR(s, f) \
665 (&(const struct arg){ \
666 .size = sizeof(*((s *)0)->f), \
669 /** Static initializer for ARGS() with arbitrary offset and size. */
670 #define ARGS_ENTRY_ARB(o, s) \
671 (&(const struct arg){ \
676 /** Same as ARGS_ENTRY_ARB() with bounded values. */
677 #define ARGS_ENTRY_ARB_BOUNDED(o, s, i, a) \
678 (&(const struct arg){ \
686 /** Same as ARGS_ENTRY() using network byte ordering. */
687 #define ARGS_ENTRY_HTON(s, f) \
688 (&(const struct arg){ \
690 .offset = offsetof(s, f), \
691 .size = sizeof(((s *)0)->f), \
694 /** Same as ARGS_ENTRY_HTON() for a single argument, without structure. */
695 #define ARG_ENTRY_HTON(s) \
696 (&(const struct arg){ \
702 /** Parser output buffer layout expected by cmd_flow_parsed(). */
704 enum index command; /**< Flow command. */
705 portid_t port; /**< Affected port ID. */
709 uint32_t action_id_n;
710 } sa_destroy; /**< Shared action destroy arguments. */
713 } sa; /* Shared action query arguments */
715 struct rte_flow_attr attr;
716 struct rte_flow_item *pattern;
717 struct rte_flow_action *actions;
721 } vc; /**< Validate/create arguments. */
725 } destroy; /**< Destroy arguments. */
728 } dump; /**< Dump arguments. */
731 struct rte_flow_action action;
732 } query; /**< Query arguments. */
736 } list; /**< List arguments. */
739 } isolate; /**< Isolated mode arguments. */
742 } aged; /**< Aged arguments. */
743 } args; /**< Command arguments. */
746 /** Private data for pattern items. */
747 struct parse_item_priv {
748 enum rte_flow_item_type type; /**< Item type. */
749 uint32_t size; /**< Size of item specification structure. */
752 #define PRIV_ITEM(t, s) \
753 (&(const struct parse_item_priv){ \
754 .type = RTE_FLOW_ITEM_TYPE_ ## t, \
758 /** Private data for actions. */
759 struct parse_action_priv {
760 enum rte_flow_action_type type; /**< Action type. */
761 uint32_t size; /**< Size of action configuration structure. */
764 #define PRIV_ACTION(t, s) \
765 (&(const struct parse_action_priv){ \
766 .type = RTE_FLOW_ACTION_TYPE_ ## t, \
770 static const enum index next_sa_create_attr[] = {
771 SHARED_ACTION_CREATE_ID,
772 SHARED_ACTION_INGRESS,
773 SHARED_ACTION_EGRESS,
778 static const enum index next_sa_subcmd[] = {
779 SHARED_ACTION_CREATE,
780 SHARED_ACTION_UPDATE,
781 SHARED_ACTION_DESTROY,
786 static const enum index next_vc_attr[] = {
796 static const enum index next_destroy_attr[] = {
802 static const enum index next_dump_attr[] = {
808 static const enum index next_list_attr[] = {
814 static const enum index next_aged_attr[] = {
820 static const enum index next_sa_destroy_attr[] = {
821 SHARED_ACTION_DESTROY_ID,
826 static const enum index item_param[] = {
835 static const enum index next_item[] = {
872 ITEM_ICMP6_ND_OPT_SLA_ETH,
873 ITEM_ICMP6_ND_OPT_TLA_ETH,
891 static const enum index item_fuzzy[] = {
897 static const enum index item_any[] = {
903 static const enum index item_vf[] = {
909 static const enum index item_phy_port[] = {
915 static const enum index item_port_id[] = {
921 static const enum index item_mark[] = {
927 static const enum index item_raw[] = {
937 static const enum index item_eth[] = {
946 static const enum index item_vlan[] = {
951 ITEM_VLAN_INNER_TYPE,
952 ITEM_VLAN_HAS_MORE_VLAN,
957 static const enum index item_ipv4[] = {
959 ITEM_IPV4_FRAGMENT_OFFSET,
968 static const enum index item_ipv6[] = {
975 ITEM_IPV6_HAS_FRAG_EXT,
980 static const enum index item_icmp[] = {
989 static const enum index item_udp[] = {
996 static const enum index item_tcp[] = {
1004 static const enum index item_sctp[] = {
1013 static const enum index item_vxlan[] = {
1019 static const enum index item_e_tag[] = {
1020 ITEM_E_TAG_GRP_ECID_B,
1025 static const enum index item_nvgre[] = {
1031 static const enum index item_mpls[] = {
1039 static const enum index item_gre[] = {
1041 ITEM_GRE_C_RSVD0_VER,
1049 static const enum index item_gre_key[] = {
1055 static const enum index item_gtp[] = {
1063 static const enum index item_geneve[] = {
1070 static const enum index item_vxlan_gpe[] = {
1076 static const enum index item_arp_eth_ipv4[] = {
1077 ITEM_ARP_ETH_IPV4_SHA,
1078 ITEM_ARP_ETH_IPV4_SPA,
1079 ITEM_ARP_ETH_IPV4_THA,
1080 ITEM_ARP_ETH_IPV4_TPA,
1085 static const enum index item_ipv6_ext[] = {
1086 ITEM_IPV6_EXT_NEXT_HDR,
1091 static const enum index item_ipv6_frag_ext[] = {
1092 ITEM_IPV6_FRAG_EXT_NEXT_HDR,
1093 ITEM_IPV6_FRAG_EXT_FRAG_DATA,
1098 static const enum index item_icmp6[] = {
1105 static const enum index item_icmp6_nd_ns[] = {
1106 ITEM_ICMP6_ND_NS_TARGET_ADDR,
1111 static const enum index item_icmp6_nd_na[] = {
1112 ITEM_ICMP6_ND_NA_TARGET_ADDR,
1117 static const enum index item_icmp6_nd_opt[] = {
1118 ITEM_ICMP6_ND_OPT_TYPE,
1123 static const enum index item_icmp6_nd_opt_sla_eth[] = {
1124 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
1129 static const enum index item_icmp6_nd_opt_tla_eth[] = {
1130 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
1135 static const enum index item_meta[] = {
1141 static const enum index item_gtp_psc[] = {
1148 static const enum index item_pppoed[] = {
1154 static const enum index item_pppoes[] = {
1160 static const enum index item_pppoe_proto_id[] = {
1165 static const enum index item_higig2[] = {
1166 ITEM_HIGIG2_CLASSIFICATION,
1172 static const enum index item_esp[] = {
1178 static const enum index item_ah[] = {
1184 static const enum index item_pfcp[] = {
1191 static const enum index next_set_raw[] = {
1197 static const enum index item_tag[] = {
1204 static const enum index item_l2tpv3oip[] = {
1205 ITEM_L2TPV3OIP_SESSION_ID,
1210 static const enum index item_ecpri[] = {
1216 static const enum index item_ecpri_common[] = {
1217 ITEM_ECPRI_COMMON_TYPE,
1221 static const enum index item_ecpri_common_type[] = {
1222 ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
1223 ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
1224 ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
1228 static const enum index next_action[] = {
1244 ACTION_OF_SET_MPLS_TTL,
1245 ACTION_OF_DEC_MPLS_TTL,
1246 ACTION_OF_SET_NW_TTL,
1247 ACTION_OF_DEC_NW_TTL,
1248 ACTION_OF_COPY_TTL_OUT,
1249 ACTION_OF_COPY_TTL_IN,
1251 ACTION_OF_PUSH_VLAN,
1252 ACTION_OF_SET_VLAN_VID,
1253 ACTION_OF_SET_VLAN_PCP,
1255 ACTION_OF_PUSH_MPLS,
1262 ACTION_MPLSOGRE_ENCAP,
1263 ACTION_MPLSOGRE_DECAP,
1264 ACTION_MPLSOUDP_ENCAP,
1265 ACTION_MPLSOUDP_DECAP,
1266 ACTION_SET_IPV4_SRC,
1267 ACTION_SET_IPV4_DST,
1268 ACTION_SET_IPV6_SRC,
1269 ACTION_SET_IPV6_DST,
1285 ACTION_SET_IPV4_DSCP,
1286 ACTION_SET_IPV6_DSCP,
1293 static const enum index action_mark[] = {
1299 static const enum index action_queue[] = {
1305 static const enum index action_count[] = {
1307 ACTION_COUNT_SHARED,
1312 static const enum index action_rss[] = {
1323 static const enum index action_vf[] = {
1330 static const enum index action_phy_port[] = {
1331 ACTION_PHY_PORT_ORIGINAL,
1332 ACTION_PHY_PORT_INDEX,
1337 static const enum index action_port_id[] = {
1338 ACTION_PORT_ID_ORIGINAL,
1344 static const enum index action_meter[] = {
1350 static const enum index action_of_set_mpls_ttl[] = {
1351 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
1356 static const enum index action_of_set_nw_ttl[] = {
1357 ACTION_OF_SET_NW_TTL_NW_TTL,
1362 static const enum index action_of_push_vlan[] = {
1363 ACTION_OF_PUSH_VLAN_ETHERTYPE,
1368 static const enum index action_of_set_vlan_vid[] = {
1369 ACTION_OF_SET_VLAN_VID_VLAN_VID,
1374 static const enum index action_of_set_vlan_pcp[] = {
1375 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
1380 static const enum index action_of_pop_mpls[] = {
1381 ACTION_OF_POP_MPLS_ETHERTYPE,
1386 static const enum index action_of_push_mpls[] = {
1387 ACTION_OF_PUSH_MPLS_ETHERTYPE,
1392 static const enum index action_set_ipv4_src[] = {
1393 ACTION_SET_IPV4_SRC_IPV4_SRC,
1398 static const enum index action_set_mac_src[] = {
1399 ACTION_SET_MAC_SRC_MAC_SRC,
1404 static const enum index action_set_ipv4_dst[] = {
1405 ACTION_SET_IPV4_DST_IPV4_DST,
1410 static const enum index action_set_ipv6_src[] = {
1411 ACTION_SET_IPV6_SRC_IPV6_SRC,
1416 static const enum index action_set_ipv6_dst[] = {
1417 ACTION_SET_IPV6_DST_IPV6_DST,
1422 static const enum index action_set_tp_src[] = {
1423 ACTION_SET_TP_SRC_TP_SRC,
1428 static const enum index action_set_tp_dst[] = {
1429 ACTION_SET_TP_DST_TP_DST,
1434 static const enum index action_set_ttl[] = {
1440 static const enum index action_jump[] = {
1446 static const enum index action_set_mac_dst[] = {
1447 ACTION_SET_MAC_DST_MAC_DST,
1452 static const enum index action_inc_tcp_seq[] = {
1453 ACTION_INC_TCP_SEQ_VALUE,
1458 static const enum index action_dec_tcp_seq[] = {
1459 ACTION_DEC_TCP_SEQ_VALUE,
1464 static const enum index action_inc_tcp_ack[] = {
1465 ACTION_INC_TCP_ACK_VALUE,
1470 static const enum index action_dec_tcp_ack[] = {
1471 ACTION_DEC_TCP_ACK_VALUE,
1476 static const enum index action_raw_encap[] = {
1477 ACTION_RAW_ENCAP_INDEX,
1482 static const enum index action_raw_decap[] = {
1483 ACTION_RAW_DECAP_INDEX,
1488 static const enum index action_set_tag[] = {
1489 ACTION_SET_TAG_DATA,
1490 ACTION_SET_TAG_INDEX,
1491 ACTION_SET_TAG_MASK,
1496 static const enum index action_set_meta[] = {
1497 ACTION_SET_META_DATA,
1498 ACTION_SET_META_MASK,
1503 static const enum index action_set_ipv4_dscp[] = {
1504 ACTION_SET_IPV4_DSCP_VALUE,
1509 static const enum index action_set_ipv6_dscp[] = {
1510 ACTION_SET_IPV6_DSCP_VALUE,
1515 static const enum index action_age[] = {
1522 static const enum index action_sample[] = {
1524 ACTION_SAMPLE_RATIO,
1525 ACTION_SAMPLE_INDEX,
1530 static const enum index next_action_sample[] = {
1540 static int parse_set_raw_encap_decap(struct context *, const struct token *,
1541 const char *, unsigned int,
1542 void *, unsigned int);
1543 static int parse_set_sample_action(struct context *, const struct token *,
1544 const char *, unsigned int,
1545 void *, unsigned int);
1546 static int parse_set_init(struct context *, const struct token *,
1547 const char *, unsigned int,
1548 void *, unsigned int);
1549 static int parse_init(struct context *, const struct token *,
1550 const char *, unsigned int,
1551 void *, unsigned int);
1552 static int parse_vc(struct context *, const struct token *,
1553 const char *, unsigned int,
1554 void *, unsigned int);
1555 static int parse_vc_spec(struct context *, const struct token *,
1556 const char *, unsigned int, void *, unsigned int);
1557 static int parse_vc_conf(struct context *, const struct token *,
1558 const char *, unsigned int, void *, unsigned int);
1559 static int parse_vc_item_ecpri_type(struct context *, const struct token *,
1560 const char *, unsigned int,
1561 void *, unsigned int);
1562 static int parse_vc_action_rss(struct context *, const struct token *,
1563 const char *, unsigned int, void *,
1565 static int parse_vc_action_rss_func(struct context *, const struct token *,
1566 const char *, unsigned int, void *,
1568 static int parse_vc_action_rss_type(struct context *, const struct token *,
1569 const char *, unsigned int, void *,
1571 static int parse_vc_action_rss_queue(struct context *, const struct token *,
1572 const char *, unsigned int, void *,
1574 static int parse_vc_action_vxlan_encap(struct context *, const struct token *,
1575 const char *, unsigned int, void *,
1577 static int parse_vc_action_nvgre_encap(struct context *, const struct token *,
1578 const char *, unsigned int, void *,
1580 static int parse_vc_action_l2_encap(struct context *, const struct token *,
1581 const char *, unsigned int, void *,
1583 static int parse_vc_action_l2_decap(struct context *, const struct token *,
1584 const char *, unsigned int, void *,
1586 static int parse_vc_action_mplsogre_encap(struct context *,
1587 const struct token *, const char *,
1588 unsigned int, void *, unsigned int);
1589 static int parse_vc_action_mplsogre_decap(struct context *,
1590 const struct token *, const char *,
1591 unsigned int, void *, unsigned int);
1592 static int parse_vc_action_mplsoudp_encap(struct context *,
1593 const struct token *, const char *,
1594 unsigned int, void *, unsigned int);
1595 static int parse_vc_action_mplsoudp_decap(struct context *,
1596 const struct token *, const char *,
1597 unsigned int, void *, unsigned int);
1598 static int parse_vc_action_raw_encap(struct context *,
1599 const struct token *, const char *,
1600 unsigned int, void *, unsigned int);
1601 static int parse_vc_action_raw_decap(struct context *,
1602 const struct token *, const char *,
1603 unsigned int, void *, unsigned int);
1604 static int parse_vc_action_raw_encap_index(struct context *,
1605 const struct token *, const char *,
1606 unsigned int, void *, unsigned int);
1607 static int parse_vc_action_raw_decap_index(struct context *,
1608 const struct token *, const char *,
1609 unsigned int, void *, unsigned int);
1610 static int parse_vc_action_set_meta(struct context *ctx,
1611 const struct token *token, const char *str,
1612 unsigned int len, void *buf,
1614 static int parse_vc_action_sample(struct context *ctx,
1615 const struct token *token, const char *str,
1616 unsigned int len, void *buf,
1619 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
1620 const char *str, unsigned int len, void *buf,
1622 static int parse_destroy(struct context *, const struct token *,
1623 const char *, unsigned int,
1624 void *, unsigned int);
1625 static int parse_flush(struct context *, const struct token *,
1626 const char *, unsigned int,
1627 void *, unsigned int);
1628 static int parse_dump(struct context *, const struct token *,
1629 const char *, unsigned int,
1630 void *, unsigned int);
1631 static int parse_query(struct context *, const struct token *,
1632 const char *, unsigned int,
1633 void *, unsigned int);
1634 static int parse_action(struct context *, const struct token *,
1635 const char *, unsigned int,
1636 void *, unsigned int);
1637 static int parse_list(struct context *, const struct token *,
1638 const char *, unsigned int,
1639 void *, unsigned int);
1640 static int parse_aged(struct context *, const struct token *,
1641 const char *, unsigned int,
1642 void *, unsigned int);
1643 static int parse_isolate(struct context *, const struct token *,
1644 const char *, unsigned int,
1645 void *, unsigned int);
1646 static int parse_int(struct context *, const struct token *,
1647 const char *, unsigned int,
1648 void *, unsigned int);
1649 static int parse_prefix(struct context *, const struct token *,
1650 const char *, unsigned int,
1651 void *, unsigned int);
1652 static int parse_boolean(struct context *, const struct token *,
1653 const char *, unsigned int,
1654 void *, unsigned int);
1655 static int parse_string(struct context *, const struct token *,
1656 const char *, unsigned int,
1657 void *, unsigned int);
1658 static int parse_hex(struct context *ctx, const struct token *token,
1659 const char *str, unsigned int len,
1660 void *buf, unsigned int size);
1661 static int parse_string0(struct context *, const struct token *,
1662 const char *, unsigned int,
1663 void *, unsigned int);
1664 static int parse_mac_addr(struct context *, const struct token *,
1665 const char *, unsigned int,
1666 void *, unsigned int);
1667 static int parse_ipv4_addr(struct context *, const struct token *,
1668 const char *, unsigned int,
1669 void *, unsigned int);
1670 static int parse_ipv6_addr(struct context *, const struct token *,
1671 const char *, unsigned int,
1672 void *, unsigned int);
1673 static int parse_port(struct context *, const struct token *,
1674 const char *, unsigned int,
1675 void *, unsigned int);
1676 static int parse_sa(struct context *, const struct token *,
1677 const char *, unsigned int,
1678 void *, unsigned int);
1679 static int parse_sa_destroy(struct context *ctx, const struct token *token,
1680 const char *str, unsigned int len,
1681 void *buf, unsigned int size);
1682 static int parse_sa_id2ptr(struct context *ctx, const struct token *token,
1683 const char *str, unsigned int len, void *buf,
1685 static int comp_none(struct context *, const struct token *,
1686 unsigned int, char *, unsigned int);
1687 static int comp_boolean(struct context *, const struct token *,
1688 unsigned int, char *, unsigned int);
1689 static int comp_action(struct context *, const struct token *,
1690 unsigned int, char *, unsigned int);
1691 static int comp_port(struct context *, const struct token *,
1692 unsigned int, char *, unsigned int);
1693 static int comp_rule_id(struct context *, const struct token *,
1694 unsigned int, char *, unsigned int);
1695 static int comp_vc_action_rss_type(struct context *, const struct token *,
1696 unsigned int, char *, unsigned int);
1697 static int comp_vc_action_rss_queue(struct context *, const struct token *,
1698 unsigned int, char *, unsigned int);
1699 static int comp_set_raw_index(struct context *, const struct token *,
1700 unsigned int, char *, unsigned int);
1701 static int comp_set_sample_index(struct context *, const struct token *,
1702 unsigned int, char *, unsigned int);
1704 /** Token definitions. */
1705 static const struct token token_list[] = {
1706 /* Special tokens. */
1709 .help = "null entry, abused as the entry point",
1710 .next = NEXT(NEXT_ENTRY(FLOW)),
1715 .help = "command may end here",
1718 .name = "START_SET",
1719 .help = "null entry, abused as the entry point for set",
1720 .next = NEXT(NEXT_ENTRY(SET)),
1725 .help = "set command may end here",
1727 /* Common tokens. */
1731 .help = "integer value",
1736 .name = "{unsigned}",
1738 .help = "unsigned integer value",
1745 .help = "prefix length for bit-mask",
1746 .call = parse_prefix,
1750 .name = "{boolean}",
1752 .help = "any boolean value",
1753 .call = parse_boolean,
1754 .comp = comp_boolean,
1759 .help = "fixed string",
1760 .call = parse_string,
1766 .help = "fixed string",
1770 .name = "{file path}",
1772 .help = "file path",
1773 .call = parse_string0,
1777 .name = "{MAC address}",
1779 .help = "standard MAC address notation",
1780 .call = parse_mac_addr,
1784 .name = "{IPv4 address}",
1785 .type = "IPV4 ADDRESS",
1786 .help = "standard IPv4 address notation",
1787 .call = parse_ipv4_addr,
1791 .name = "{IPv6 address}",
1792 .type = "IPV6 ADDRESS",
1793 .help = "standard IPv6 address notation",
1794 .call = parse_ipv6_addr,
1798 .name = "{rule id}",
1800 .help = "rule identifier",
1802 .comp = comp_rule_id,
1805 .name = "{port_id}",
1807 .help = "port identifier",
1812 .name = "{group_id}",
1814 .help = "group identifier",
1818 [PRIORITY_LEVEL] = {
1821 .help = "priority level",
1825 [SHARED_ACTION_ID] = {
1826 .name = "{shared_action_id}",
1827 .type = "SHARED_ACTION_ID",
1828 .help = "shared action id",
1832 /* Top-level command. */
1835 .type = "{command} {port_id} [{arg} [...]]",
1836 .help = "manage ingress/egress flow rules",
1837 .next = NEXT(NEXT_ENTRY
1850 /* Top-level command. */
1852 .name = "shared_action",
1853 .type = "{command} {port_id} [{arg} [...]]",
1854 .help = "manage shared actions",
1855 .next = NEXT(next_sa_subcmd, NEXT_ENTRY(PORT_ID)),
1856 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1859 /* Sub-level commands. */
1860 [SHARED_ACTION_CREATE] = {
1862 .help = "create shared action",
1863 .next = NEXT(next_sa_create_attr),
1866 [SHARED_ACTION_UPDATE] = {
1868 .help = "update shared action",
1869 .next = NEXT(NEXT_ENTRY(SHARED_ACTION_SPEC),
1870 NEXT_ENTRY(SHARED_ACTION_ID)),
1871 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
1874 [SHARED_ACTION_DESTROY] = {
1876 .help = "destroy shared action",
1877 .next = NEXT(NEXT_ENTRY(SHARED_ACTION_DESTROY_ID)),
1878 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1879 .call = parse_sa_destroy,
1881 [SHARED_ACTION_QUERY] = {
1883 .help = "query shared action",
1884 .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(SHARED_ACTION_ID)),
1885 .args = ARGS(ARGS_ENTRY(struct buffer, args.sa.action_id)),
1890 .help = "check whether a flow rule can be created",
1891 .next = NEXT(next_vc_attr, NEXT_ENTRY(PORT_ID)),
1892 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1897 .help = "create a flow rule",
1898 .next = NEXT(next_vc_attr, NEXT_ENTRY(PORT_ID)),
1899 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1904 .help = "destroy specific flow rules",
1905 .next = NEXT(NEXT_ENTRY(DESTROY_RULE), NEXT_ENTRY(PORT_ID)),
1906 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1907 .call = parse_destroy,
1911 .help = "destroy all flow rules",
1912 .next = NEXT(NEXT_ENTRY(PORT_ID)),
1913 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1914 .call = parse_flush,
1918 .help = "dump all flow rules to file",
1919 .next = NEXT(next_dump_attr, NEXT_ENTRY(PORT_ID)),
1920 .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file),
1921 ARGS_ENTRY(struct buffer, port)),
1926 .help = "query an existing flow rule",
1927 .next = NEXT(NEXT_ENTRY(QUERY_ACTION),
1928 NEXT_ENTRY(RULE_ID),
1929 NEXT_ENTRY(PORT_ID)),
1930 .args = ARGS(ARGS_ENTRY(struct buffer, args.query.action.type),
1931 ARGS_ENTRY(struct buffer, args.query.rule),
1932 ARGS_ENTRY(struct buffer, port)),
1933 .call = parse_query,
1937 .help = "list existing flow rules",
1938 .next = NEXT(next_list_attr, NEXT_ENTRY(PORT_ID)),
1939 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1944 .help = "list and destroy aged flows",
1945 .next = NEXT(next_aged_attr, NEXT_ENTRY(PORT_ID)),
1946 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1951 .help = "restrict ingress traffic to the defined flow rules",
1952 .next = NEXT(NEXT_ENTRY(BOOLEAN),
1953 NEXT_ENTRY(PORT_ID)),
1954 .args = ARGS(ARGS_ENTRY(struct buffer, args.isolate.set),
1955 ARGS_ENTRY(struct buffer, port)),
1956 .call = parse_isolate,
1958 /* Destroy arguments. */
1961 .help = "specify a rule identifier",
1962 .next = NEXT(next_destroy_attr, NEXT_ENTRY(RULE_ID)),
1963 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.destroy.rule)),
1964 .call = parse_destroy,
1966 /* Query arguments. */
1970 .help = "action to query, must be part of the rule",
1971 .call = parse_action,
1972 .comp = comp_action,
1974 /* List arguments. */
1977 .help = "specify a group",
1978 .next = NEXT(next_list_attr, NEXT_ENTRY(GROUP_ID)),
1979 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.list.group)),
1984 .help = "specify aged flows need be destroyed",
1988 /* Validate/create attributes. */
1991 .help = "specify a group",
1992 .next = NEXT(next_vc_attr, NEXT_ENTRY(GROUP_ID)),
1993 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, group)),
1998 .help = "specify a priority level",
1999 .next = NEXT(next_vc_attr, NEXT_ENTRY(PRIORITY_LEVEL)),
2000 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, priority)),
2005 .help = "affect rule to ingress",
2006 .next = NEXT(next_vc_attr),
2011 .help = "affect rule to egress",
2012 .next = NEXT(next_vc_attr),
2017 .help = "apply rule directly to endpoints found in pattern",
2018 .next = NEXT(next_vc_attr),
2021 /* Validate/create pattern. */
2024 .help = "submit a list of pattern items",
2025 .next = NEXT(next_item),
2030 .help = "match value perfectly (with full bit-mask)",
2031 .call = parse_vc_spec,
2033 [ITEM_PARAM_SPEC] = {
2035 .help = "match value according to configured bit-mask",
2036 .call = parse_vc_spec,
2038 [ITEM_PARAM_LAST] = {
2040 .help = "specify upper bound to establish a range",
2041 .call = parse_vc_spec,
2043 [ITEM_PARAM_MASK] = {
2045 .help = "specify bit-mask with relevant bits set to one",
2046 .call = parse_vc_spec,
2048 [ITEM_PARAM_PREFIX] = {
2050 .help = "generate bit-mask from a prefix length",
2051 .call = parse_vc_spec,
2055 .help = "specify next pattern item",
2056 .next = NEXT(next_item),
2060 .help = "end list of pattern items",
2061 .priv = PRIV_ITEM(END, 0),
2062 .next = NEXT(NEXT_ENTRY(ACTIONS)),
2067 .help = "no-op pattern item",
2068 .priv = PRIV_ITEM(VOID, 0),
2069 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2074 .help = "perform actions when pattern does not match",
2075 .priv = PRIV_ITEM(INVERT, 0),
2076 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2081 .help = "match any protocol for the current layer",
2082 .priv = PRIV_ITEM(ANY, sizeof(struct rte_flow_item_any)),
2083 .next = NEXT(item_any),
2088 .help = "number of layers covered",
2089 .next = NEXT(item_any, NEXT_ENTRY(UNSIGNED), item_param),
2090 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_any, num)),
2094 .help = "match traffic from/to the physical function",
2095 .priv = PRIV_ITEM(PF, 0),
2096 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2101 .help = "match traffic from/to a virtual function ID",
2102 .priv = PRIV_ITEM(VF, sizeof(struct rte_flow_item_vf)),
2103 .next = NEXT(item_vf),
2109 .next = NEXT(item_vf, NEXT_ENTRY(UNSIGNED), item_param),
2110 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_vf, id)),
2114 .help = "match traffic from/to a specific physical port",
2115 .priv = PRIV_ITEM(PHY_PORT,
2116 sizeof(struct rte_flow_item_phy_port)),
2117 .next = NEXT(item_phy_port),
2120 [ITEM_PHY_PORT_INDEX] = {
2122 .help = "physical port index",
2123 .next = NEXT(item_phy_port, NEXT_ENTRY(UNSIGNED), item_param),
2124 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_phy_port, index)),
2128 .help = "match traffic from/to a given DPDK port ID",
2129 .priv = PRIV_ITEM(PORT_ID,
2130 sizeof(struct rte_flow_item_port_id)),
2131 .next = NEXT(item_port_id),
2134 [ITEM_PORT_ID_ID] = {
2136 .help = "DPDK port ID",
2137 .next = NEXT(item_port_id, NEXT_ENTRY(UNSIGNED), item_param),
2138 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port_id, id)),
2142 .help = "match traffic against value set in previously matched rule",
2143 .priv = PRIV_ITEM(MARK, sizeof(struct rte_flow_item_mark)),
2144 .next = NEXT(item_mark),
2149 .help = "Integer value to match against",
2150 .next = NEXT(item_mark, NEXT_ENTRY(UNSIGNED), item_param),
2151 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_mark, id)),
2155 .help = "match an arbitrary byte string",
2156 .priv = PRIV_ITEM(RAW, ITEM_RAW_SIZE),
2157 .next = NEXT(item_raw),
2160 [ITEM_RAW_RELATIVE] = {
2162 .help = "look for pattern after the previous item",
2163 .next = NEXT(item_raw, NEXT_ENTRY(BOOLEAN), item_param),
2164 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
2167 [ITEM_RAW_SEARCH] = {
2169 .help = "search pattern from offset (see also limit)",
2170 .next = NEXT(item_raw, NEXT_ENTRY(BOOLEAN), item_param),
2171 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
2174 [ITEM_RAW_OFFSET] = {
2176 .help = "absolute or relative offset for pattern",
2177 .next = NEXT(item_raw, NEXT_ENTRY(INTEGER), item_param),
2178 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, offset)),
2180 [ITEM_RAW_LIMIT] = {
2182 .help = "search area limit for start of pattern",
2183 .next = NEXT(item_raw, NEXT_ENTRY(UNSIGNED), item_param),
2184 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, limit)),
2186 [ITEM_RAW_PATTERN] = {
2188 .help = "byte string to look for",
2189 .next = NEXT(item_raw,
2191 NEXT_ENTRY(ITEM_PARAM_IS,
2194 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern),
2195 ARGS_ENTRY(struct rte_flow_item_raw, length),
2196 ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw),
2197 ITEM_RAW_PATTERN_SIZE)),
2201 .help = "match Ethernet header",
2202 .priv = PRIV_ITEM(ETH, sizeof(struct rte_flow_item_eth)),
2203 .next = NEXT(item_eth),
2208 .help = "destination MAC",
2209 .next = NEXT(item_eth, NEXT_ENTRY(MAC_ADDR), item_param),
2210 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, dst)),
2214 .help = "source MAC",
2215 .next = NEXT(item_eth, NEXT_ENTRY(MAC_ADDR), item_param),
2216 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, src)),
2220 .help = "EtherType",
2221 .next = NEXT(item_eth, NEXT_ENTRY(UNSIGNED), item_param),
2222 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, type)),
2224 [ITEM_ETH_HAS_VLAN] = {
2226 .help = "packet header contains VLAN",
2227 .next = NEXT(item_eth, NEXT_ENTRY(UNSIGNED), item_param),
2228 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_eth,
2233 .help = "match 802.1Q/ad VLAN tag",
2234 .priv = PRIV_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)),
2235 .next = NEXT(item_vlan),
2240 .help = "tag control information",
2241 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2242 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, tci)),
2246 .help = "priority code point",
2247 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2248 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2253 .help = "drop eligible indicator",
2254 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2255 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2260 .help = "VLAN identifier",
2261 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2262 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2265 [ITEM_VLAN_INNER_TYPE] = {
2266 .name = "inner_type",
2267 .help = "inner EtherType",
2268 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2269 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan,
2272 [ITEM_VLAN_HAS_MORE_VLAN] = {
2273 .name = "has_more_vlan",
2274 .help = "packet header contains another VLAN",
2275 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2276 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vlan,
2281 .help = "match IPv4 header",
2282 .priv = PRIV_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)),
2283 .next = NEXT(item_ipv4),
2288 .help = "type of service",
2289 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2290 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2291 hdr.type_of_service)),
2293 [ITEM_IPV4_FRAGMENT_OFFSET] = {
2294 .name = "fragment_offset",
2295 .help = "fragmentation flags and fragment offset",
2296 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2297 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2298 hdr.fragment_offset)),
2302 .help = "time to live",
2303 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2304 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2307 [ITEM_IPV4_PROTO] = {
2309 .help = "next protocol ID",
2310 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2311 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2312 hdr.next_proto_id)),
2316 .help = "source address",
2317 .next = NEXT(item_ipv4, NEXT_ENTRY(IPV4_ADDR), item_param),
2318 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2323 .help = "destination address",
2324 .next = NEXT(item_ipv4, NEXT_ENTRY(IPV4_ADDR), item_param),
2325 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2330 .help = "match IPv6 header",
2331 .priv = PRIV_ITEM(IPV6, sizeof(struct rte_flow_item_ipv6)),
2332 .next = NEXT(item_ipv6),
2337 .help = "traffic class",
2338 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2339 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2341 "\x0f\xf0\x00\x00")),
2343 [ITEM_IPV6_FLOW] = {
2345 .help = "flow label",
2346 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2347 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2349 "\x00\x0f\xff\xff")),
2351 [ITEM_IPV6_PROTO] = {
2353 .help = "protocol (next header)",
2354 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2355 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2360 .help = "hop limit",
2361 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2362 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2367 .help = "source address",
2368 .next = NEXT(item_ipv6, NEXT_ENTRY(IPV6_ADDR), item_param),
2369 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2374 .help = "destination address",
2375 .next = NEXT(item_ipv6, NEXT_ENTRY(IPV6_ADDR), item_param),
2376 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2379 [ITEM_IPV6_HAS_FRAG_EXT] = {
2380 .name = "has_frag_ext",
2381 .help = "fragment packet attribute",
2382 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2383 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_ipv6,
2388 .help = "match ICMP header",
2389 .priv = PRIV_ITEM(ICMP, sizeof(struct rte_flow_item_icmp)),
2390 .next = NEXT(item_icmp),
2393 [ITEM_ICMP_TYPE] = {
2395 .help = "ICMP packet type",
2396 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2397 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2400 [ITEM_ICMP_CODE] = {
2402 .help = "ICMP packet code",
2403 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2404 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2407 [ITEM_ICMP_IDENT] = {
2409 .help = "ICMP packet identifier",
2410 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2411 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2416 .help = "ICMP packet sequence number",
2417 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2418 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2423 .help = "match UDP header",
2424 .priv = PRIV_ITEM(UDP, sizeof(struct rte_flow_item_udp)),
2425 .next = NEXT(item_udp),
2430 .help = "UDP source port",
2431 .next = NEXT(item_udp, NEXT_ENTRY(UNSIGNED), item_param),
2432 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2437 .help = "UDP destination port",
2438 .next = NEXT(item_udp, NEXT_ENTRY(UNSIGNED), item_param),
2439 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2444 .help = "match TCP header",
2445 .priv = PRIV_ITEM(TCP, sizeof(struct rte_flow_item_tcp)),
2446 .next = NEXT(item_tcp),
2451 .help = "TCP source port",
2452 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2453 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2458 .help = "TCP destination port",
2459 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2460 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2463 [ITEM_TCP_FLAGS] = {
2465 .help = "TCP flags",
2466 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2467 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2472 .help = "match SCTP header",
2473 .priv = PRIV_ITEM(SCTP, sizeof(struct rte_flow_item_sctp)),
2474 .next = NEXT(item_sctp),
2479 .help = "SCTP source port",
2480 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2481 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2486 .help = "SCTP destination port",
2487 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2488 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2493 .help = "validation tag",
2494 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2495 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2498 [ITEM_SCTP_CKSUM] = {
2501 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2502 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2507 .help = "match VXLAN header",
2508 .priv = PRIV_ITEM(VXLAN, sizeof(struct rte_flow_item_vxlan)),
2509 .next = NEXT(item_vxlan),
2512 [ITEM_VXLAN_VNI] = {
2514 .help = "VXLAN identifier",
2515 .next = NEXT(item_vxlan, NEXT_ENTRY(UNSIGNED), item_param),
2516 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan, vni)),
2520 .help = "match E-Tag header",
2521 .priv = PRIV_ITEM(E_TAG, sizeof(struct rte_flow_item_e_tag)),
2522 .next = NEXT(item_e_tag),
2525 [ITEM_E_TAG_GRP_ECID_B] = {
2526 .name = "grp_ecid_b",
2527 .help = "GRP and E-CID base",
2528 .next = NEXT(item_e_tag, NEXT_ENTRY(UNSIGNED), item_param),
2529 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_e_tag,
2535 .help = "match NVGRE header",
2536 .priv = PRIV_ITEM(NVGRE, sizeof(struct rte_flow_item_nvgre)),
2537 .next = NEXT(item_nvgre),
2540 [ITEM_NVGRE_TNI] = {
2542 .help = "virtual subnet ID",
2543 .next = NEXT(item_nvgre, NEXT_ENTRY(UNSIGNED), item_param),
2544 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_nvgre, tni)),
2548 .help = "match MPLS header",
2549 .priv = PRIV_ITEM(MPLS, sizeof(struct rte_flow_item_mpls)),
2550 .next = NEXT(item_mpls),
2553 [ITEM_MPLS_LABEL] = {
2555 .help = "MPLS label",
2556 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2557 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2563 .help = "MPLS Traffic Class",
2564 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2565 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2571 .help = "MPLS Bottom-of-Stack",
2572 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2573 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2579 .help = "match GRE header",
2580 .priv = PRIV_ITEM(GRE, sizeof(struct rte_flow_item_gre)),
2581 .next = NEXT(item_gre),
2584 [ITEM_GRE_PROTO] = {
2586 .help = "GRE protocol type",
2587 .next = NEXT(item_gre, NEXT_ENTRY(UNSIGNED), item_param),
2588 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2591 [ITEM_GRE_C_RSVD0_VER] = {
2592 .name = "c_rsvd0_ver",
2594 "checksum (1b), undefined (1b), key bit (1b),"
2595 " sequence number (1b), reserved 0 (9b),"
2597 .next = NEXT(item_gre, NEXT_ENTRY(UNSIGNED), item_param),
2598 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2601 [ITEM_GRE_C_BIT] = {
2603 .help = "checksum bit (C)",
2604 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2605 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2607 "\x80\x00\x00\x00")),
2609 [ITEM_GRE_S_BIT] = {
2611 .help = "sequence number bit (S)",
2612 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2613 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2615 "\x10\x00\x00\x00")),
2617 [ITEM_GRE_K_BIT] = {
2619 .help = "key bit (K)",
2620 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2621 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2623 "\x20\x00\x00\x00")),
2627 .help = "fuzzy pattern match, expect faster than default",
2628 .priv = PRIV_ITEM(FUZZY,
2629 sizeof(struct rte_flow_item_fuzzy)),
2630 .next = NEXT(item_fuzzy),
2633 [ITEM_FUZZY_THRESH] = {
2635 .help = "match accuracy threshold",
2636 .next = NEXT(item_fuzzy, NEXT_ENTRY(UNSIGNED), item_param),
2637 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_fuzzy,
2642 .help = "match GTP header",
2643 .priv = PRIV_ITEM(GTP, sizeof(struct rte_flow_item_gtp)),
2644 .next = NEXT(item_gtp),
2647 [ITEM_GTP_FLAGS] = {
2648 .name = "v_pt_rsv_flags",
2649 .help = "GTP flags",
2650 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2651 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp,
2654 [ITEM_GTP_MSG_TYPE] = {
2656 .help = "GTP message type",
2657 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2658 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp, msg_type)),
2662 .help = "tunnel endpoint identifier",
2663 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2664 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp, teid)),
2668 .help = "match GTP header",
2669 .priv = PRIV_ITEM(GTPC, sizeof(struct rte_flow_item_gtp)),
2670 .next = NEXT(item_gtp),
2675 .help = "match GTP header",
2676 .priv = PRIV_ITEM(GTPU, sizeof(struct rte_flow_item_gtp)),
2677 .next = NEXT(item_gtp),
2682 .help = "match GENEVE header",
2683 .priv = PRIV_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)),
2684 .next = NEXT(item_geneve),
2687 [ITEM_GENEVE_VNI] = {
2689 .help = "virtual network identifier",
2690 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2691 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve, vni)),
2693 [ITEM_GENEVE_PROTO] = {
2695 .help = "GENEVE protocol type",
2696 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2697 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve,
2700 [ITEM_VXLAN_GPE] = {
2701 .name = "vxlan-gpe",
2702 .help = "match VXLAN-GPE header",
2703 .priv = PRIV_ITEM(VXLAN_GPE,
2704 sizeof(struct rte_flow_item_vxlan_gpe)),
2705 .next = NEXT(item_vxlan_gpe),
2708 [ITEM_VXLAN_GPE_VNI] = {
2710 .help = "VXLAN-GPE identifier",
2711 .next = NEXT(item_vxlan_gpe, NEXT_ENTRY(UNSIGNED), item_param),
2712 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
2715 [ITEM_ARP_ETH_IPV4] = {
2716 .name = "arp_eth_ipv4",
2717 .help = "match ARP header for Ethernet/IPv4",
2718 .priv = PRIV_ITEM(ARP_ETH_IPV4,
2719 sizeof(struct rte_flow_item_arp_eth_ipv4)),
2720 .next = NEXT(item_arp_eth_ipv4),
2723 [ITEM_ARP_ETH_IPV4_SHA] = {
2725 .help = "sender hardware address",
2726 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(MAC_ADDR),
2728 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2731 [ITEM_ARP_ETH_IPV4_SPA] = {
2733 .help = "sender IPv4 address",
2734 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(IPV4_ADDR),
2736 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2739 [ITEM_ARP_ETH_IPV4_THA] = {
2741 .help = "target hardware address",
2742 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(MAC_ADDR),
2744 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2747 [ITEM_ARP_ETH_IPV4_TPA] = {
2749 .help = "target IPv4 address",
2750 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(IPV4_ADDR),
2752 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2757 .help = "match presence of any IPv6 extension header",
2758 .priv = PRIV_ITEM(IPV6_EXT,
2759 sizeof(struct rte_flow_item_ipv6_ext)),
2760 .next = NEXT(item_ipv6_ext),
2763 [ITEM_IPV6_EXT_NEXT_HDR] = {
2765 .help = "next header",
2766 .next = NEXT(item_ipv6_ext, NEXT_ENTRY(UNSIGNED), item_param),
2767 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_ext,
2770 [ITEM_IPV6_FRAG_EXT] = {
2771 .name = "ipv6_frag_ext",
2772 .help = "match presence of IPv6 fragment extension header",
2773 .priv = PRIV_ITEM(IPV6_FRAG_EXT,
2774 sizeof(struct rte_flow_item_ipv6_frag_ext)),
2775 .next = NEXT(item_ipv6_frag_ext),
2778 [ITEM_IPV6_FRAG_EXT_NEXT_HDR] = {
2780 .help = "next header",
2781 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(UNSIGNED),
2783 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ipv6_frag_ext,
2786 [ITEM_IPV6_FRAG_EXT_FRAG_DATA] = {
2787 .name = "frag_data",
2788 .help = "Fragment flags and offset",
2789 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(UNSIGNED),
2791 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_frag_ext,
2796 .help = "match any ICMPv6 header",
2797 .priv = PRIV_ITEM(ICMP6, sizeof(struct rte_flow_item_icmp6)),
2798 .next = NEXT(item_icmp6),
2801 [ITEM_ICMP6_TYPE] = {
2803 .help = "ICMPv6 type",
2804 .next = NEXT(item_icmp6, NEXT_ENTRY(UNSIGNED), item_param),
2805 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
2808 [ITEM_ICMP6_CODE] = {
2810 .help = "ICMPv6 code",
2811 .next = NEXT(item_icmp6, NEXT_ENTRY(UNSIGNED), item_param),
2812 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
2815 [ITEM_ICMP6_ND_NS] = {
2816 .name = "icmp6_nd_ns",
2817 .help = "match ICMPv6 neighbor discovery solicitation",
2818 .priv = PRIV_ITEM(ICMP6_ND_NS,
2819 sizeof(struct rte_flow_item_icmp6_nd_ns)),
2820 .next = NEXT(item_icmp6_nd_ns),
2823 [ITEM_ICMP6_ND_NS_TARGET_ADDR] = {
2824 .name = "target_addr",
2825 .help = "target address",
2826 .next = NEXT(item_icmp6_nd_ns, NEXT_ENTRY(IPV6_ADDR),
2828 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_ns,
2831 [ITEM_ICMP6_ND_NA] = {
2832 .name = "icmp6_nd_na",
2833 .help = "match ICMPv6 neighbor discovery advertisement",
2834 .priv = PRIV_ITEM(ICMP6_ND_NA,
2835 sizeof(struct rte_flow_item_icmp6_nd_na)),
2836 .next = NEXT(item_icmp6_nd_na),
2839 [ITEM_ICMP6_ND_NA_TARGET_ADDR] = {
2840 .name = "target_addr",
2841 .help = "target address",
2842 .next = NEXT(item_icmp6_nd_na, NEXT_ENTRY(IPV6_ADDR),
2844 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_na,
2847 [ITEM_ICMP6_ND_OPT] = {
2848 .name = "icmp6_nd_opt",
2849 .help = "match presence of any ICMPv6 neighbor discovery"
2851 .priv = PRIV_ITEM(ICMP6_ND_OPT,
2852 sizeof(struct rte_flow_item_icmp6_nd_opt)),
2853 .next = NEXT(item_icmp6_nd_opt),
2856 [ITEM_ICMP6_ND_OPT_TYPE] = {
2858 .help = "ND option type",
2859 .next = NEXT(item_icmp6_nd_opt, NEXT_ENTRY(UNSIGNED),
2861 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_opt,
2864 [ITEM_ICMP6_ND_OPT_SLA_ETH] = {
2865 .name = "icmp6_nd_opt_sla_eth",
2866 .help = "match ICMPv6 neighbor discovery source Ethernet"
2867 " link-layer address option",
2869 (ICMP6_ND_OPT_SLA_ETH,
2870 sizeof(struct rte_flow_item_icmp6_nd_opt_sla_eth)),
2871 .next = NEXT(item_icmp6_nd_opt_sla_eth),
2874 [ITEM_ICMP6_ND_OPT_SLA_ETH_SLA] = {
2876 .help = "source Ethernet LLA",
2877 .next = NEXT(item_icmp6_nd_opt_sla_eth, NEXT_ENTRY(MAC_ADDR),
2879 .args = ARGS(ARGS_ENTRY_HTON
2880 (struct rte_flow_item_icmp6_nd_opt_sla_eth, sla)),
2882 [ITEM_ICMP6_ND_OPT_TLA_ETH] = {
2883 .name = "icmp6_nd_opt_tla_eth",
2884 .help = "match ICMPv6 neighbor discovery target Ethernet"
2885 " link-layer address option",
2887 (ICMP6_ND_OPT_TLA_ETH,
2888 sizeof(struct rte_flow_item_icmp6_nd_opt_tla_eth)),
2889 .next = NEXT(item_icmp6_nd_opt_tla_eth),
2892 [ITEM_ICMP6_ND_OPT_TLA_ETH_TLA] = {
2894 .help = "target Ethernet LLA",
2895 .next = NEXT(item_icmp6_nd_opt_tla_eth, NEXT_ENTRY(MAC_ADDR),
2897 .args = ARGS(ARGS_ENTRY_HTON
2898 (struct rte_flow_item_icmp6_nd_opt_tla_eth, tla)),
2902 .help = "match metadata header",
2903 .priv = PRIV_ITEM(META, sizeof(struct rte_flow_item_meta)),
2904 .next = NEXT(item_meta),
2907 [ITEM_META_DATA] = {
2909 .help = "metadata value",
2910 .next = NEXT(item_meta, NEXT_ENTRY(UNSIGNED), item_param),
2911 .args = ARGS(ARGS_ENTRY_MASK(struct rte_flow_item_meta,
2912 data, "\xff\xff\xff\xff")),
2916 .help = "match GRE key",
2917 .priv = PRIV_ITEM(GRE_KEY, sizeof(rte_be32_t)),
2918 .next = NEXT(item_gre_key),
2921 [ITEM_GRE_KEY_VALUE] = {
2923 .help = "key value",
2924 .next = NEXT(item_gre_key, NEXT_ENTRY(UNSIGNED), item_param),
2925 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
2929 .help = "match GTP extension header with type 0x85",
2930 .priv = PRIV_ITEM(GTP_PSC,
2931 sizeof(struct rte_flow_item_gtp_psc)),
2932 .next = NEXT(item_gtp_psc),
2935 [ITEM_GTP_PSC_QFI] = {
2937 .help = "QoS flow identifier",
2938 .next = NEXT(item_gtp_psc, NEXT_ENTRY(UNSIGNED), item_param),
2939 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
2942 [ITEM_GTP_PSC_PDU_T] = {
2945 .next = NEXT(item_gtp_psc, NEXT_ENTRY(UNSIGNED), item_param),
2946 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
2951 .help = "match PPPoE session header",
2952 .priv = PRIV_ITEM(PPPOES, sizeof(struct rte_flow_item_pppoe)),
2953 .next = NEXT(item_pppoes),
2958 .help = "match PPPoE discovery header",
2959 .priv = PRIV_ITEM(PPPOED, sizeof(struct rte_flow_item_pppoe)),
2960 .next = NEXT(item_pppoed),
2963 [ITEM_PPPOE_SEID] = {
2965 .help = "session identifier",
2966 .next = NEXT(item_pppoes, NEXT_ENTRY(UNSIGNED), item_param),
2967 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pppoe,
2970 [ITEM_PPPOE_PROTO_ID] = {
2971 .name = "pppoe_proto_id",
2972 .help = "match PPPoE session protocol identifier",
2973 .priv = PRIV_ITEM(PPPOE_PROTO_ID,
2974 sizeof(struct rte_flow_item_pppoe_proto_id)),
2975 .next = NEXT(item_pppoe_proto_id, NEXT_ENTRY(UNSIGNED),
2977 .args = ARGS(ARGS_ENTRY_HTON
2978 (struct rte_flow_item_pppoe_proto_id, proto_id)),
2983 .help = "matches higig2 header",
2984 .priv = PRIV_ITEM(HIGIG2,
2985 sizeof(struct rte_flow_item_higig2_hdr)),
2986 .next = NEXT(item_higig2),
2989 [ITEM_HIGIG2_CLASSIFICATION] = {
2990 .name = "classification",
2991 .help = "matches classification of higig2 header",
2992 .next = NEXT(item_higig2, NEXT_ENTRY(UNSIGNED), item_param),
2993 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
2994 hdr.ppt1.classification)),
2996 [ITEM_HIGIG2_VID] = {
2998 .help = "matches vid of higig2 header",
2999 .next = NEXT(item_higig2, NEXT_ENTRY(UNSIGNED), item_param),
3000 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
3005 .help = "match tag value",
3006 .priv = PRIV_ITEM(TAG, sizeof(struct rte_flow_item_tag)),
3007 .next = NEXT(item_tag),
3012 .help = "tag value to match",
3013 .next = NEXT(item_tag, NEXT_ENTRY(UNSIGNED), item_param),
3014 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, data)),
3016 [ITEM_TAG_INDEX] = {
3018 .help = "index of tag array to match",
3019 .next = NEXT(item_tag, NEXT_ENTRY(UNSIGNED),
3020 NEXT_ENTRY(ITEM_PARAM_IS)),
3021 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, index)),
3023 [ITEM_L2TPV3OIP] = {
3024 .name = "l2tpv3oip",
3025 .help = "match L2TPv3 over IP header",
3026 .priv = PRIV_ITEM(L2TPV3OIP,
3027 sizeof(struct rte_flow_item_l2tpv3oip)),
3028 .next = NEXT(item_l2tpv3oip),
3031 [ITEM_L2TPV3OIP_SESSION_ID] = {
3032 .name = "session_id",
3033 .help = "session identifier",
3034 .next = NEXT(item_l2tpv3oip, NEXT_ENTRY(UNSIGNED), item_param),
3035 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv3oip,
3040 .help = "match ESP header",
3041 .priv = PRIV_ITEM(ESP, sizeof(struct rte_flow_item_esp)),
3042 .next = NEXT(item_esp),
3047 .help = "security policy index",
3048 .next = NEXT(item_esp, NEXT_ENTRY(UNSIGNED), item_param),
3049 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_esp,
3054 .help = "match AH header",
3055 .priv = PRIV_ITEM(AH, sizeof(struct rte_flow_item_ah)),
3056 .next = NEXT(item_ah),
3061 .help = "security parameters index",
3062 .next = NEXT(item_ah, NEXT_ENTRY(UNSIGNED), item_param),
3063 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ah, spi)),
3067 .help = "match pfcp header",
3068 .priv = PRIV_ITEM(PFCP, sizeof(struct rte_flow_item_pfcp)),
3069 .next = NEXT(item_pfcp),
3072 [ITEM_PFCP_S_FIELD] = {
3075 .next = NEXT(item_pfcp, NEXT_ENTRY(UNSIGNED), item_param),
3076 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp,
3079 [ITEM_PFCP_SEID] = {
3081 .help = "session endpoint identifier",
3082 .next = NEXT(item_pfcp, NEXT_ENTRY(UNSIGNED), item_param),
3083 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp, seid)),
3087 .help = "match eCPRI header",
3088 .priv = PRIV_ITEM(ECPRI, sizeof(struct rte_flow_item_ecpri)),
3089 .next = NEXT(item_ecpri),
3092 [ITEM_ECPRI_COMMON] = {
3094 .help = "eCPRI common header",
3095 .next = NEXT(item_ecpri_common),
3097 [ITEM_ECPRI_COMMON_TYPE] = {
3099 .help = "type of common header",
3100 .next = NEXT(item_ecpri_common_type),
3101 .args = ARGS(ARG_ENTRY_HTON(struct rte_flow_item_ecpri)),
3103 [ITEM_ECPRI_COMMON_TYPE_IQ_DATA] = {
3105 .help = "Type #0: IQ Data",
3106 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
3108 .call = parse_vc_item_ecpri_type,
3110 [ITEM_ECPRI_MSG_IQ_DATA_PCID] = {
3112 .help = "Physical Channel ID",
3113 .next = NEXT(item_ecpri, NEXT_ENTRY(UNSIGNED), item_param),
3114 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3117 [ITEM_ECPRI_COMMON_TYPE_RTC_CTRL] = {
3119 .help = "Type #2: Real-Time Control Data",
3120 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
3122 .call = parse_vc_item_ecpri_type,
3124 [ITEM_ECPRI_MSG_RTC_CTRL_RTCID] = {
3126 .help = "Real-Time Control Data ID",
3127 .next = NEXT(item_ecpri, NEXT_ENTRY(UNSIGNED), item_param),
3128 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3131 [ITEM_ECPRI_COMMON_TYPE_DLY_MSR] = {
3132 .name = "delay_measure",
3133 .help = "Type #5: One-Way Delay Measurement",
3134 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
3136 .call = parse_vc_item_ecpri_type,
3138 [ITEM_ECPRI_MSG_DLY_MSR_MSRID] = {
3140 .help = "Measurement ID",
3141 .next = NEXT(item_ecpri, NEXT_ENTRY(UNSIGNED), item_param),
3142 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3145 /* Validate/create actions. */
3148 .help = "submit a list of associated actions",
3149 .next = NEXT(next_action),
3154 .help = "specify next action",
3155 .next = NEXT(next_action),
3159 .help = "end list of actions",
3160 .priv = PRIV_ACTION(END, 0),
3165 .help = "no-op action",
3166 .priv = PRIV_ACTION(VOID, 0),
3167 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3170 [ACTION_PASSTHRU] = {
3172 .help = "let subsequent rule process matched packets",
3173 .priv = PRIV_ACTION(PASSTHRU, 0),
3174 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3179 .help = "redirect traffic to a given group",
3180 .priv = PRIV_ACTION(JUMP, sizeof(struct rte_flow_action_jump)),
3181 .next = NEXT(action_jump),
3184 [ACTION_JUMP_GROUP] = {
3186 .help = "group to redirect traffic to",
3187 .next = NEXT(action_jump, NEXT_ENTRY(UNSIGNED)),
3188 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump, group)),
3189 .call = parse_vc_conf,
3193 .help = "attach 32 bit value to packets",
3194 .priv = PRIV_ACTION(MARK, sizeof(struct rte_flow_action_mark)),
3195 .next = NEXT(action_mark),
3198 [ACTION_MARK_ID] = {
3200 .help = "32 bit value to return with packets",
3201 .next = NEXT(action_mark, NEXT_ENTRY(UNSIGNED)),
3202 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_mark, id)),
3203 .call = parse_vc_conf,
3207 .help = "flag packets",
3208 .priv = PRIV_ACTION(FLAG, 0),
3209 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3214 .help = "assign packets to a given queue index",
3215 .priv = PRIV_ACTION(QUEUE,
3216 sizeof(struct rte_flow_action_queue)),
3217 .next = NEXT(action_queue),
3220 [ACTION_QUEUE_INDEX] = {
3222 .help = "queue index to use",
3223 .next = NEXT(action_queue, NEXT_ENTRY(UNSIGNED)),
3224 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_queue, index)),
3225 .call = parse_vc_conf,
3229 .help = "drop packets (note: passthru has priority)",
3230 .priv = PRIV_ACTION(DROP, 0),
3231 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3236 .help = "enable counters for this rule",
3237 .priv = PRIV_ACTION(COUNT,
3238 sizeof(struct rte_flow_action_count)),
3239 .next = NEXT(action_count),
3242 [ACTION_COUNT_ID] = {
3243 .name = "identifier",
3244 .help = "counter identifier to use",
3245 .next = NEXT(action_count, NEXT_ENTRY(UNSIGNED)),
3246 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_count, id)),
3247 .call = parse_vc_conf,
3249 [ACTION_COUNT_SHARED] = {
3251 .help = "shared counter",
3252 .next = NEXT(action_count, NEXT_ENTRY(BOOLEAN)),
3253 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_count,
3255 .call = parse_vc_conf,
3259 .help = "spread packets among several queues",
3260 .priv = PRIV_ACTION(RSS, sizeof(struct action_rss_data)),
3261 .next = NEXT(action_rss),
3262 .call = parse_vc_action_rss,
3264 [ACTION_RSS_FUNC] = {
3266 .help = "RSS hash function to apply",
3267 .next = NEXT(action_rss,
3268 NEXT_ENTRY(ACTION_RSS_FUNC_DEFAULT,
3269 ACTION_RSS_FUNC_TOEPLITZ,
3270 ACTION_RSS_FUNC_SIMPLE_XOR,
3271 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ)),
3273 [ACTION_RSS_FUNC_DEFAULT] = {
3275 .help = "default hash function",
3276 .call = parse_vc_action_rss_func,
3278 [ACTION_RSS_FUNC_TOEPLITZ] = {
3280 .help = "Toeplitz hash function",
3281 .call = parse_vc_action_rss_func,
3283 [ACTION_RSS_FUNC_SIMPLE_XOR] = {
3284 .name = "simple_xor",
3285 .help = "simple XOR hash function",
3286 .call = parse_vc_action_rss_func,
3288 [ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ] = {
3289 .name = "symmetric_toeplitz",
3290 .help = "Symmetric Toeplitz hash function",
3291 .call = parse_vc_action_rss_func,
3293 [ACTION_RSS_LEVEL] = {
3295 .help = "encapsulation level for \"types\"",
3296 .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
3297 .args = ARGS(ARGS_ENTRY_ARB
3298 (offsetof(struct action_rss_data, conf) +
3299 offsetof(struct rte_flow_action_rss, level),
3300 sizeof(((struct rte_flow_action_rss *)0)->
3303 [ACTION_RSS_TYPES] = {
3305 .help = "specific RSS hash types",
3306 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)),
3308 [ACTION_RSS_TYPE] = {
3310 .help = "RSS hash type",
3311 .call = parse_vc_action_rss_type,
3312 .comp = comp_vc_action_rss_type,
3314 [ACTION_RSS_KEY] = {
3316 .help = "RSS hash key",
3317 .next = NEXT(action_rss, NEXT_ENTRY(HEX)),
3318 .args = ARGS(ARGS_ENTRY_ARB(0, 0),
3320 (offsetof(struct action_rss_data, conf) +
3321 offsetof(struct rte_flow_action_rss, key_len),
3322 sizeof(((struct rte_flow_action_rss *)0)->
3324 ARGS_ENTRY(struct action_rss_data, key)),
3326 [ACTION_RSS_KEY_LEN] = {
3328 .help = "RSS hash key length in bytes",
3329 .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
3330 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
3331 (offsetof(struct action_rss_data, conf) +
3332 offsetof(struct rte_flow_action_rss, key_len),
3333 sizeof(((struct rte_flow_action_rss *)0)->
3336 RSS_HASH_KEY_LENGTH)),
3338 [ACTION_RSS_QUEUES] = {
3340 .help = "queue indices to use",
3341 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_QUEUE)),
3342 .call = parse_vc_conf,
3344 [ACTION_RSS_QUEUE] = {
3346 .help = "queue index",
3347 .call = parse_vc_action_rss_queue,
3348 .comp = comp_vc_action_rss_queue,
3352 .help = "direct traffic to physical function",
3353 .priv = PRIV_ACTION(PF, 0),
3354 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3359 .help = "direct traffic to a virtual function ID",
3360 .priv = PRIV_ACTION(VF, sizeof(struct rte_flow_action_vf)),
3361 .next = NEXT(action_vf),
3364 [ACTION_VF_ORIGINAL] = {
3366 .help = "use original VF ID if possible",
3367 .next = NEXT(action_vf, NEXT_ENTRY(BOOLEAN)),
3368 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_vf,
3370 .call = parse_vc_conf,
3375 .next = NEXT(action_vf, NEXT_ENTRY(UNSIGNED)),
3376 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)),
3377 .call = parse_vc_conf,
3379 [ACTION_PHY_PORT] = {
3381 .help = "direct packets to physical port index",
3382 .priv = PRIV_ACTION(PHY_PORT,
3383 sizeof(struct rte_flow_action_phy_port)),
3384 .next = NEXT(action_phy_port),
3387 [ACTION_PHY_PORT_ORIGINAL] = {
3389 .help = "use original port index if possible",
3390 .next = NEXT(action_phy_port, NEXT_ENTRY(BOOLEAN)),
3391 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_phy_port,
3393 .call = parse_vc_conf,
3395 [ACTION_PHY_PORT_INDEX] = {
3397 .help = "physical port index",
3398 .next = NEXT(action_phy_port, NEXT_ENTRY(UNSIGNED)),
3399 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_phy_port,
3401 .call = parse_vc_conf,
3403 [ACTION_PORT_ID] = {
3405 .help = "direct matching traffic to a given DPDK port ID",
3406 .priv = PRIV_ACTION(PORT_ID,
3407 sizeof(struct rte_flow_action_port_id)),
3408 .next = NEXT(action_port_id),
3411 [ACTION_PORT_ID_ORIGINAL] = {
3413 .help = "use original DPDK port ID if possible",
3414 .next = NEXT(action_port_id, NEXT_ENTRY(BOOLEAN)),
3415 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_port_id,
3417 .call = parse_vc_conf,
3419 [ACTION_PORT_ID_ID] = {
3421 .help = "DPDK port ID",
3422 .next = NEXT(action_port_id, NEXT_ENTRY(UNSIGNED)),
3423 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_port_id, id)),
3424 .call = parse_vc_conf,
3428 .help = "meter the directed packets at given id",
3429 .priv = PRIV_ACTION(METER,
3430 sizeof(struct rte_flow_action_meter)),
3431 .next = NEXT(action_meter),
3434 [ACTION_METER_ID] = {
3436 .help = "meter id to use",
3437 .next = NEXT(action_meter, NEXT_ENTRY(UNSIGNED)),
3438 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter, mtr_id)),
3439 .call = parse_vc_conf,
3441 [ACTION_OF_SET_MPLS_TTL] = {
3442 .name = "of_set_mpls_ttl",
3443 .help = "OpenFlow's OFPAT_SET_MPLS_TTL",
3446 sizeof(struct rte_flow_action_of_set_mpls_ttl)),
3447 .next = NEXT(action_of_set_mpls_ttl),
3450 [ACTION_OF_SET_MPLS_TTL_MPLS_TTL] = {
3453 .next = NEXT(action_of_set_mpls_ttl, NEXT_ENTRY(UNSIGNED)),
3454 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_mpls_ttl,
3456 .call = parse_vc_conf,
3458 [ACTION_OF_DEC_MPLS_TTL] = {
3459 .name = "of_dec_mpls_ttl",
3460 .help = "OpenFlow's OFPAT_DEC_MPLS_TTL",
3461 .priv = PRIV_ACTION(OF_DEC_MPLS_TTL, 0),
3462 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3465 [ACTION_OF_SET_NW_TTL] = {
3466 .name = "of_set_nw_ttl",
3467 .help = "OpenFlow's OFPAT_SET_NW_TTL",
3470 sizeof(struct rte_flow_action_of_set_nw_ttl)),
3471 .next = NEXT(action_of_set_nw_ttl),
3474 [ACTION_OF_SET_NW_TTL_NW_TTL] = {
3477 .next = NEXT(action_of_set_nw_ttl, NEXT_ENTRY(UNSIGNED)),
3478 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_nw_ttl,
3480 .call = parse_vc_conf,
3482 [ACTION_OF_DEC_NW_TTL] = {
3483 .name = "of_dec_nw_ttl",
3484 .help = "OpenFlow's OFPAT_DEC_NW_TTL",
3485 .priv = PRIV_ACTION(OF_DEC_NW_TTL, 0),
3486 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3489 [ACTION_OF_COPY_TTL_OUT] = {
3490 .name = "of_copy_ttl_out",
3491 .help = "OpenFlow's OFPAT_COPY_TTL_OUT",
3492 .priv = PRIV_ACTION(OF_COPY_TTL_OUT, 0),
3493 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3496 [ACTION_OF_COPY_TTL_IN] = {
3497 .name = "of_copy_ttl_in",
3498 .help = "OpenFlow's OFPAT_COPY_TTL_IN",
3499 .priv = PRIV_ACTION(OF_COPY_TTL_IN, 0),
3500 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3503 [ACTION_OF_POP_VLAN] = {
3504 .name = "of_pop_vlan",
3505 .help = "OpenFlow's OFPAT_POP_VLAN",
3506 .priv = PRIV_ACTION(OF_POP_VLAN, 0),
3507 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3510 [ACTION_OF_PUSH_VLAN] = {
3511 .name = "of_push_vlan",
3512 .help = "OpenFlow's OFPAT_PUSH_VLAN",
3515 sizeof(struct rte_flow_action_of_push_vlan)),
3516 .next = NEXT(action_of_push_vlan),
3519 [ACTION_OF_PUSH_VLAN_ETHERTYPE] = {
3520 .name = "ethertype",
3521 .help = "EtherType",
3522 .next = NEXT(action_of_push_vlan, NEXT_ENTRY(UNSIGNED)),
3523 .args = ARGS(ARGS_ENTRY_HTON
3524 (struct rte_flow_action_of_push_vlan,
3526 .call = parse_vc_conf,
3528 [ACTION_OF_SET_VLAN_VID] = {
3529 .name = "of_set_vlan_vid",
3530 .help = "OpenFlow's OFPAT_SET_VLAN_VID",
3533 sizeof(struct rte_flow_action_of_set_vlan_vid)),
3534 .next = NEXT(action_of_set_vlan_vid),
3537 [ACTION_OF_SET_VLAN_VID_VLAN_VID] = {
3540 .next = NEXT(action_of_set_vlan_vid, NEXT_ENTRY(UNSIGNED)),
3541 .args = ARGS(ARGS_ENTRY_HTON
3542 (struct rte_flow_action_of_set_vlan_vid,
3544 .call = parse_vc_conf,
3546 [ACTION_OF_SET_VLAN_PCP] = {
3547 .name = "of_set_vlan_pcp",
3548 .help = "OpenFlow's OFPAT_SET_VLAN_PCP",
3551 sizeof(struct rte_flow_action_of_set_vlan_pcp)),
3552 .next = NEXT(action_of_set_vlan_pcp),
3555 [ACTION_OF_SET_VLAN_PCP_VLAN_PCP] = {
3557 .help = "VLAN priority",
3558 .next = NEXT(action_of_set_vlan_pcp, NEXT_ENTRY(UNSIGNED)),
3559 .args = ARGS(ARGS_ENTRY_HTON
3560 (struct rte_flow_action_of_set_vlan_pcp,
3562 .call = parse_vc_conf,
3564 [ACTION_OF_POP_MPLS] = {
3565 .name = "of_pop_mpls",
3566 .help = "OpenFlow's OFPAT_POP_MPLS",
3567 .priv = PRIV_ACTION(OF_POP_MPLS,
3568 sizeof(struct rte_flow_action_of_pop_mpls)),
3569 .next = NEXT(action_of_pop_mpls),
3572 [ACTION_OF_POP_MPLS_ETHERTYPE] = {
3573 .name = "ethertype",
3574 .help = "EtherType",
3575 .next = NEXT(action_of_pop_mpls, NEXT_ENTRY(UNSIGNED)),
3576 .args = ARGS(ARGS_ENTRY_HTON
3577 (struct rte_flow_action_of_pop_mpls,
3579 .call = parse_vc_conf,
3581 [ACTION_OF_PUSH_MPLS] = {
3582 .name = "of_push_mpls",
3583 .help = "OpenFlow's OFPAT_PUSH_MPLS",
3586 sizeof(struct rte_flow_action_of_push_mpls)),
3587 .next = NEXT(action_of_push_mpls),
3590 [ACTION_OF_PUSH_MPLS_ETHERTYPE] = {
3591 .name = "ethertype",
3592 .help = "EtherType",
3593 .next = NEXT(action_of_push_mpls, NEXT_ENTRY(UNSIGNED)),
3594 .args = ARGS(ARGS_ENTRY_HTON
3595 (struct rte_flow_action_of_push_mpls,
3597 .call = parse_vc_conf,
3599 [ACTION_VXLAN_ENCAP] = {
3600 .name = "vxlan_encap",
3601 .help = "VXLAN encapsulation, uses configuration set by \"set"
3603 .priv = PRIV_ACTION(VXLAN_ENCAP,
3604 sizeof(struct action_vxlan_encap_data)),
3605 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3606 .call = parse_vc_action_vxlan_encap,
3608 [ACTION_VXLAN_DECAP] = {
3609 .name = "vxlan_decap",
3610 .help = "Performs a decapsulation action by stripping all"
3611 " headers of the VXLAN tunnel network overlay from the"
3613 .priv = PRIV_ACTION(VXLAN_DECAP, 0),
3614 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3617 [ACTION_NVGRE_ENCAP] = {
3618 .name = "nvgre_encap",
3619 .help = "NVGRE encapsulation, uses configuration set by \"set"
3621 .priv = PRIV_ACTION(NVGRE_ENCAP,
3622 sizeof(struct action_nvgre_encap_data)),
3623 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3624 .call = parse_vc_action_nvgre_encap,
3626 [ACTION_NVGRE_DECAP] = {
3627 .name = "nvgre_decap",
3628 .help = "Performs a decapsulation action by stripping all"
3629 " headers of the NVGRE tunnel network overlay from the"
3631 .priv = PRIV_ACTION(NVGRE_DECAP, 0),
3632 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3635 [ACTION_L2_ENCAP] = {
3637 .help = "l2 encap, uses configuration set by"
3638 " \"set l2_encap\"",
3639 .priv = PRIV_ACTION(RAW_ENCAP,
3640 sizeof(struct action_raw_encap_data)),
3641 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3642 .call = parse_vc_action_l2_encap,
3644 [ACTION_L2_DECAP] = {
3646 .help = "l2 decap, uses configuration set by"
3647 " \"set l2_decap\"",
3648 .priv = PRIV_ACTION(RAW_DECAP,
3649 sizeof(struct action_raw_decap_data)),
3650 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3651 .call = parse_vc_action_l2_decap,
3653 [ACTION_MPLSOGRE_ENCAP] = {
3654 .name = "mplsogre_encap",
3655 .help = "mplsogre encapsulation, uses configuration set by"
3656 " \"set mplsogre_encap\"",
3657 .priv = PRIV_ACTION(RAW_ENCAP,
3658 sizeof(struct action_raw_encap_data)),
3659 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3660 .call = parse_vc_action_mplsogre_encap,
3662 [ACTION_MPLSOGRE_DECAP] = {
3663 .name = "mplsogre_decap",
3664 .help = "mplsogre decapsulation, uses configuration set by"
3665 " \"set mplsogre_decap\"",
3666 .priv = PRIV_ACTION(RAW_DECAP,
3667 sizeof(struct action_raw_decap_data)),
3668 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3669 .call = parse_vc_action_mplsogre_decap,
3671 [ACTION_MPLSOUDP_ENCAP] = {
3672 .name = "mplsoudp_encap",
3673 .help = "mplsoudp encapsulation, uses configuration set by"
3674 " \"set mplsoudp_encap\"",
3675 .priv = PRIV_ACTION(RAW_ENCAP,
3676 sizeof(struct action_raw_encap_data)),
3677 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3678 .call = parse_vc_action_mplsoudp_encap,
3680 [ACTION_MPLSOUDP_DECAP] = {
3681 .name = "mplsoudp_decap",
3682 .help = "mplsoudp decapsulation, uses configuration set by"
3683 " \"set mplsoudp_decap\"",
3684 .priv = PRIV_ACTION(RAW_DECAP,
3685 sizeof(struct action_raw_decap_data)),
3686 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3687 .call = parse_vc_action_mplsoudp_decap,
3689 [ACTION_SET_IPV4_SRC] = {
3690 .name = "set_ipv4_src",
3691 .help = "Set a new IPv4 source address in the outermost"
3693 .priv = PRIV_ACTION(SET_IPV4_SRC,
3694 sizeof(struct rte_flow_action_set_ipv4)),
3695 .next = NEXT(action_set_ipv4_src),
3698 [ACTION_SET_IPV4_SRC_IPV4_SRC] = {
3699 .name = "ipv4_addr",
3700 .help = "new IPv4 source address to set",
3701 .next = NEXT(action_set_ipv4_src, NEXT_ENTRY(IPV4_ADDR)),
3702 .args = ARGS(ARGS_ENTRY_HTON
3703 (struct rte_flow_action_set_ipv4, ipv4_addr)),
3704 .call = parse_vc_conf,
3706 [ACTION_SET_IPV4_DST] = {
3707 .name = "set_ipv4_dst",
3708 .help = "Set a new IPv4 destination address in the outermost"
3710 .priv = PRIV_ACTION(SET_IPV4_DST,
3711 sizeof(struct rte_flow_action_set_ipv4)),
3712 .next = NEXT(action_set_ipv4_dst),
3715 [ACTION_SET_IPV4_DST_IPV4_DST] = {
3716 .name = "ipv4_addr",
3717 .help = "new IPv4 destination address to set",
3718 .next = NEXT(action_set_ipv4_dst, NEXT_ENTRY(IPV4_ADDR)),
3719 .args = ARGS(ARGS_ENTRY_HTON
3720 (struct rte_flow_action_set_ipv4, ipv4_addr)),
3721 .call = parse_vc_conf,
3723 [ACTION_SET_IPV6_SRC] = {
3724 .name = "set_ipv6_src",
3725 .help = "Set a new IPv6 source address in the outermost"
3727 .priv = PRIV_ACTION(SET_IPV6_SRC,
3728 sizeof(struct rte_flow_action_set_ipv6)),
3729 .next = NEXT(action_set_ipv6_src),
3732 [ACTION_SET_IPV6_SRC_IPV6_SRC] = {
3733 .name = "ipv6_addr",
3734 .help = "new IPv6 source address to set",
3735 .next = NEXT(action_set_ipv6_src, NEXT_ENTRY(IPV6_ADDR)),
3736 .args = ARGS(ARGS_ENTRY_HTON
3737 (struct rte_flow_action_set_ipv6, ipv6_addr)),
3738 .call = parse_vc_conf,
3740 [ACTION_SET_IPV6_DST] = {
3741 .name = "set_ipv6_dst",
3742 .help = "Set a new IPv6 destination address in the outermost"
3744 .priv = PRIV_ACTION(SET_IPV6_DST,
3745 sizeof(struct rte_flow_action_set_ipv6)),
3746 .next = NEXT(action_set_ipv6_dst),
3749 [ACTION_SET_IPV6_DST_IPV6_DST] = {
3750 .name = "ipv6_addr",
3751 .help = "new IPv6 destination address to set",
3752 .next = NEXT(action_set_ipv6_dst, NEXT_ENTRY(IPV6_ADDR)),
3753 .args = ARGS(ARGS_ENTRY_HTON
3754 (struct rte_flow_action_set_ipv6, ipv6_addr)),
3755 .call = parse_vc_conf,
3757 [ACTION_SET_TP_SRC] = {
3758 .name = "set_tp_src",
3759 .help = "set a new source port number in the outermost"
3761 .priv = PRIV_ACTION(SET_TP_SRC,
3762 sizeof(struct rte_flow_action_set_tp)),
3763 .next = NEXT(action_set_tp_src),
3766 [ACTION_SET_TP_SRC_TP_SRC] = {
3768 .help = "new source port number to set",
3769 .next = NEXT(action_set_tp_src, NEXT_ENTRY(UNSIGNED)),
3770 .args = ARGS(ARGS_ENTRY_HTON
3771 (struct rte_flow_action_set_tp, port)),
3772 .call = parse_vc_conf,
3774 [ACTION_SET_TP_DST] = {
3775 .name = "set_tp_dst",
3776 .help = "set a new destination port number in the outermost"
3778 .priv = PRIV_ACTION(SET_TP_DST,
3779 sizeof(struct rte_flow_action_set_tp)),
3780 .next = NEXT(action_set_tp_dst),
3783 [ACTION_SET_TP_DST_TP_DST] = {
3785 .help = "new destination port number to set",
3786 .next = NEXT(action_set_tp_dst, NEXT_ENTRY(UNSIGNED)),
3787 .args = ARGS(ARGS_ENTRY_HTON
3788 (struct rte_flow_action_set_tp, port)),
3789 .call = parse_vc_conf,
3791 [ACTION_MAC_SWAP] = {
3793 .help = "Swap the source and destination MAC addresses"
3794 " in the outermost Ethernet header",
3795 .priv = PRIV_ACTION(MAC_SWAP, 0),
3796 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3799 [ACTION_DEC_TTL] = {
3801 .help = "decrease network TTL if available",
3802 .priv = PRIV_ACTION(DEC_TTL, 0),
3803 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3806 [ACTION_SET_TTL] = {
3808 .help = "set ttl value",
3809 .priv = PRIV_ACTION(SET_TTL,
3810 sizeof(struct rte_flow_action_set_ttl)),
3811 .next = NEXT(action_set_ttl),
3814 [ACTION_SET_TTL_TTL] = {
3815 .name = "ttl_value",
3816 .help = "new ttl value to set",
3817 .next = NEXT(action_set_ttl, NEXT_ENTRY(UNSIGNED)),
3818 .args = ARGS(ARGS_ENTRY_HTON
3819 (struct rte_flow_action_set_ttl, ttl_value)),
3820 .call = parse_vc_conf,
3822 [ACTION_SET_MAC_SRC] = {
3823 .name = "set_mac_src",
3824 .help = "set source mac address",
3825 .priv = PRIV_ACTION(SET_MAC_SRC,
3826 sizeof(struct rte_flow_action_set_mac)),
3827 .next = NEXT(action_set_mac_src),
3830 [ACTION_SET_MAC_SRC_MAC_SRC] = {
3832 .help = "new source mac address",
3833 .next = NEXT(action_set_mac_src, NEXT_ENTRY(MAC_ADDR)),
3834 .args = ARGS(ARGS_ENTRY_HTON
3835 (struct rte_flow_action_set_mac, mac_addr)),
3836 .call = parse_vc_conf,
3838 [ACTION_SET_MAC_DST] = {
3839 .name = "set_mac_dst",
3840 .help = "set destination mac address",
3841 .priv = PRIV_ACTION(SET_MAC_DST,
3842 sizeof(struct rte_flow_action_set_mac)),
3843 .next = NEXT(action_set_mac_dst),
3846 [ACTION_SET_MAC_DST_MAC_DST] = {
3848 .help = "new destination mac address to set",
3849 .next = NEXT(action_set_mac_dst, NEXT_ENTRY(MAC_ADDR)),
3850 .args = ARGS(ARGS_ENTRY_HTON
3851 (struct rte_flow_action_set_mac, mac_addr)),
3852 .call = parse_vc_conf,
3854 [ACTION_INC_TCP_SEQ] = {
3855 .name = "inc_tcp_seq",
3856 .help = "increase TCP sequence number",
3857 .priv = PRIV_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
3858 .next = NEXT(action_inc_tcp_seq),
3861 [ACTION_INC_TCP_SEQ_VALUE] = {
3863 .help = "the value to increase TCP sequence number by",
3864 .next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(UNSIGNED)),
3865 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3866 .call = parse_vc_conf,
3868 [ACTION_DEC_TCP_SEQ] = {
3869 .name = "dec_tcp_seq",
3870 .help = "decrease TCP sequence number",
3871 .priv = PRIV_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
3872 .next = NEXT(action_dec_tcp_seq),
3875 [ACTION_DEC_TCP_SEQ_VALUE] = {
3877 .help = "the value to decrease TCP sequence number by",
3878 .next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(UNSIGNED)),
3879 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3880 .call = parse_vc_conf,
3882 [ACTION_INC_TCP_ACK] = {
3883 .name = "inc_tcp_ack",
3884 .help = "increase TCP acknowledgment number",
3885 .priv = PRIV_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
3886 .next = NEXT(action_inc_tcp_ack),
3889 [ACTION_INC_TCP_ACK_VALUE] = {
3891 .help = "the value to increase TCP acknowledgment number by",
3892 .next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(UNSIGNED)),
3893 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3894 .call = parse_vc_conf,
3896 [ACTION_DEC_TCP_ACK] = {
3897 .name = "dec_tcp_ack",
3898 .help = "decrease TCP acknowledgment number",
3899 .priv = PRIV_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
3900 .next = NEXT(action_dec_tcp_ack),
3903 [ACTION_DEC_TCP_ACK_VALUE] = {
3905 .help = "the value to decrease TCP acknowledgment number by",
3906 .next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(UNSIGNED)),
3907 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3908 .call = parse_vc_conf,
3910 [ACTION_RAW_ENCAP] = {
3911 .name = "raw_encap",
3912 .help = "encapsulation data, defined by set raw_encap",
3913 .priv = PRIV_ACTION(RAW_ENCAP,
3914 sizeof(struct action_raw_encap_data)),
3915 .next = NEXT(action_raw_encap),
3916 .call = parse_vc_action_raw_encap,
3918 [ACTION_RAW_ENCAP_INDEX] = {
3920 .help = "the index of raw_encap_confs",
3921 .next = NEXT(NEXT_ENTRY(ACTION_RAW_ENCAP_INDEX_VALUE)),
3923 [ACTION_RAW_ENCAP_INDEX_VALUE] = {
3926 .help = "unsigned integer value",
3927 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3928 .call = parse_vc_action_raw_encap_index,
3929 .comp = comp_set_raw_index,
3931 [ACTION_RAW_DECAP] = {
3932 .name = "raw_decap",
3933 .help = "decapsulation data, defined by set raw_encap",
3934 .priv = PRIV_ACTION(RAW_DECAP,
3935 sizeof(struct action_raw_decap_data)),
3936 .next = NEXT(action_raw_decap),
3937 .call = parse_vc_action_raw_decap,
3939 [ACTION_RAW_DECAP_INDEX] = {
3941 .help = "the index of raw_encap_confs",
3942 .next = NEXT(NEXT_ENTRY(ACTION_RAW_DECAP_INDEX_VALUE)),
3944 [ACTION_RAW_DECAP_INDEX_VALUE] = {
3947 .help = "unsigned integer value",
3948 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3949 .call = parse_vc_action_raw_decap_index,
3950 .comp = comp_set_raw_index,
3952 /* Top level command. */
3955 .help = "set raw encap/decap/sample data",
3956 .type = "set raw_encap|raw_decap <index> <pattern>"
3957 " or set sample_actions <index> <action>",
3958 .next = NEXT(NEXT_ENTRY
3961 SET_SAMPLE_ACTIONS)),
3962 .call = parse_set_init,
3964 /* Sub-level commands. */
3966 .name = "raw_encap",
3967 .help = "set raw encap data",
3968 .next = NEXT(next_set_raw),
3969 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
3970 (offsetof(struct buffer, port),
3971 sizeof(((struct buffer *)0)->port),
3972 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
3973 .call = parse_set_raw_encap_decap,
3976 .name = "raw_decap",
3977 .help = "set raw decap data",
3978 .next = NEXT(next_set_raw),
3979 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
3980 (offsetof(struct buffer, port),
3981 sizeof(((struct buffer *)0)->port),
3982 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
3983 .call = parse_set_raw_encap_decap,
3988 .help = "index of raw_encap/raw_decap data",
3989 .next = NEXT(next_item),
3992 [SET_SAMPLE_INDEX] = {
3995 .help = "index of sample actions",
3996 .next = NEXT(next_action_sample),
3999 [SET_SAMPLE_ACTIONS] = {
4000 .name = "sample_actions",
4001 .help = "set sample actions list",
4002 .next = NEXT(NEXT_ENTRY(SET_SAMPLE_INDEX)),
4003 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4004 (offsetof(struct buffer, port),
4005 sizeof(((struct buffer *)0)->port),
4006 0, RAW_SAMPLE_CONFS_MAX_NUM - 1)),
4007 .call = parse_set_sample_action,
4009 [ACTION_SET_TAG] = {
4012 .priv = PRIV_ACTION(SET_TAG,
4013 sizeof(struct rte_flow_action_set_tag)),
4014 .next = NEXT(action_set_tag),
4017 [ACTION_SET_TAG_INDEX] = {
4019 .help = "index of tag array",
4020 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
4021 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_set_tag, index)),
4022 .call = parse_vc_conf,
4024 [ACTION_SET_TAG_DATA] = {
4026 .help = "tag value",
4027 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
4028 .args = ARGS(ARGS_ENTRY
4029 (struct rte_flow_action_set_tag, data)),
4030 .call = parse_vc_conf,
4032 [ACTION_SET_TAG_MASK] = {
4034 .help = "mask for tag value",
4035 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
4036 .args = ARGS(ARGS_ENTRY
4037 (struct rte_flow_action_set_tag, mask)),
4038 .call = parse_vc_conf,
4040 [ACTION_SET_META] = {
4042 .help = "set metadata",
4043 .priv = PRIV_ACTION(SET_META,
4044 sizeof(struct rte_flow_action_set_meta)),
4045 .next = NEXT(action_set_meta),
4046 .call = parse_vc_action_set_meta,
4048 [ACTION_SET_META_DATA] = {
4050 .help = "metadata value",
4051 .next = NEXT(action_set_meta, NEXT_ENTRY(UNSIGNED)),
4052 .args = ARGS(ARGS_ENTRY
4053 (struct rte_flow_action_set_meta, data)),
4054 .call = parse_vc_conf,
4056 [ACTION_SET_META_MASK] = {
4058 .help = "mask for metadata value",
4059 .next = NEXT(action_set_meta, NEXT_ENTRY(UNSIGNED)),
4060 .args = ARGS(ARGS_ENTRY
4061 (struct rte_flow_action_set_meta, mask)),
4062 .call = parse_vc_conf,
4064 [ACTION_SET_IPV4_DSCP] = {
4065 .name = "set_ipv4_dscp",
4066 .help = "set DSCP value",
4067 .priv = PRIV_ACTION(SET_IPV4_DSCP,
4068 sizeof(struct rte_flow_action_set_dscp)),
4069 .next = NEXT(action_set_ipv4_dscp),
4072 [ACTION_SET_IPV4_DSCP_VALUE] = {
4073 .name = "dscp_value",
4074 .help = "new IPv4 DSCP value to set",
4075 .next = NEXT(action_set_ipv4_dscp, NEXT_ENTRY(UNSIGNED)),
4076 .args = ARGS(ARGS_ENTRY
4077 (struct rte_flow_action_set_dscp, dscp)),
4078 .call = parse_vc_conf,
4080 [ACTION_SET_IPV6_DSCP] = {
4081 .name = "set_ipv6_dscp",
4082 .help = "set DSCP value",
4083 .priv = PRIV_ACTION(SET_IPV6_DSCP,
4084 sizeof(struct rte_flow_action_set_dscp)),
4085 .next = NEXT(action_set_ipv6_dscp),
4088 [ACTION_SET_IPV6_DSCP_VALUE] = {
4089 .name = "dscp_value",
4090 .help = "new IPv6 DSCP value to set",
4091 .next = NEXT(action_set_ipv6_dscp, NEXT_ENTRY(UNSIGNED)),
4092 .args = ARGS(ARGS_ENTRY
4093 (struct rte_flow_action_set_dscp, dscp)),
4094 .call = parse_vc_conf,
4098 .help = "set a specific metadata header",
4099 .next = NEXT(action_age),
4100 .priv = PRIV_ACTION(AGE,
4101 sizeof(struct rte_flow_action_age)),
4104 [ACTION_AGE_TIMEOUT] = {
4106 .help = "flow age timeout value",
4107 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_age,
4109 .next = NEXT(action_age, NEXT_ENTRY(UNSIGNED)),
4110 .call = parse_vc_conf,
4114 .help = "set a sample action",
4115 .next = NEXT(action_sample),
4116 .priv = PRIV_ACTION(SAMPLE,
4117 sizeof(struct action_sample_data)),
4118 .call = parse_vc_action_sample,
4120 [ACTION_SAMPLE_RATIO] = {
4122 .help = "flow sample ratio value",
4123 .next = NEXT(action_sample, NEXT_ENTRY(UNSIGNED)),
4124 .args = ARGS(ARGS_ENTRY_ARB
4125 (offsetof(struct action_sample_data, conf) +
4126 offsetof(struct rte_flow_action_sample, ratio),
4127 sizeof(((struct rte_flow_action_sample *)0)->
4130 [ACTION_SAMPLE_INDEX] = {
4132 .help = "the index of sample actions list",
4133 .next = NEXT(NEXT_ENTRY(ACTION_SAMPLE_INDEX_VALUE)),
4135 [ACTION_SAMPLE_INDEX_VALUE] = {
4138 .help = "unsigned integer value",
4139 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4140 .call = parse_vc_action_sample_index,
4141 .comp = comp_set_sample_index,
4143 /* Shared action destroy arguments. */
4144 [SHARED_ACTION_DESTROY_ID] = {
4145 .name = "action_id",
4146 .help = "specify a shared action id to destroy",
4147 .next = NEXT(next_sa_destroy_attr,
4148 NEXT_ENTRY(SHARED_ACTION_ID)),
4149 .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
4150 args.sa_destroy.action_id)),
4151 .call = parse_sa_destroy,
4153 /* Shared action create arguments. */
4154 [SHARED_ACTION_CREATE_ID] = {
4155 .name = "action_id",
4156 .help = "specify a shared action id to create",
4157 .next = NEXT(next_sa_create_attr,
4158 NEXT_ENTRY(SHARED_ACTION_ID)),
4159 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
4163 .help = "apply shared action by id",
4164 .priv = PRIV_ACTION(SHARED, 0),
4165 .next = NEXT(NEXT_ENTRY(SHARED_ACTION_ID2PTR)),
4166 .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
4169 [SHARED_ACTION_ID2PTR] = {
4170 .name = "{action_id}",
4171 .type = "SHARED_ACTION_ID",
4172 .help = "shared action id",
4173 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4174 .call = parse_sa_id2ptr,
4177 [SHARED_ACTION_INGRESS] = {
4179 .help = "affect rule to ingress",
4180 .next = NEXT(next_sa_create_attr),
4183 [SHARED_ACTION_EGRESS] = {
4185 .help = "affect rule to egress",
4186 .next = NEXT(next_sa_create_attr),
4189 [SHARED_ACTION_SPEC] = {
4191 .help = "specify action to share",
4192 .next = NEXT(next_action),
4196 /** Remove and return last entry from argument stack. */
4197 static const struct arg *
4198 pop_args(struct context *ctx)
4200 return ctx->args_num ? ctx->args[--ctx->args_num] : NULL;
4203 /** Add entry on top of the argument stack. */
4205 push_args(struct context *ctx, const struct arg *arg)
4207 if (ctx->args_num == CTX_STACK_SIZE)
4209 ctx->args[ctx->args_num++] = arg;
4213 /** Spread value into buffer according to bit-mask. */
4215 arg_entry_bf_fill(void *dst, uintmax_t val, const struct arg *arg)
4217 uint32_t i = arg->size;
4225 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
4234 unsigned int shift = 0;
4235 uint8_t *buf = (uint8_t *)dst + arg->offset + (i -= sub);
4237 for (shift = 0; arg->mask[i] >> shift; ++shift) {
4238 if (!(arg->mask[i] & (1 << shift)))
4243 *buf &= ~(1 << shift);
4244 *buf |= (val & 1) << shift;
4252 /** Compare a string with a partial one of a given length. */
4254 strcmp_partial(const char *full, const char *partial, size_t partial_len)
4256 int r = strncmp(full, partial, partial_len);
4260 if (strlen(full) <= partial_len)
4262 return full[partial_len];
4266 * Parse a prefix length and generate a bit-mask.
4268 * Last argument (ctx->args) is retrieved to determine mask size, storage
4269 * location and whether the result must use network byte ordering.
4272 parse_prefix(struct context *ctx, const struct token *token,
4273 const char *str, unsigned int len,
4274 void *buf, unsigned int size)
4276 const struct arg *arg = pop_args(ctx);
4277 static const uint8_t conv[] = "\x00\x80\xc0\xe0\xf0\xf8\xfc\xfe\xff";
4284 /* Argument is expected. */
4288 u = strtoumax(str, &end, 0);
4289 if (errno || (size_t)(end - str) != len)
4294 extra = arg_entry_bf_fill(NULL, 0, arg);
4303 if (!arg_entry_bf_fill(ctx->object, v, arg) ||
4304 !arg_entry_bf_fill(ctx->objmask, -1, arg))
4311 if (bytes > size || bytes + !!extra > size)
4315 buf = (uint8_t *)ctx->object + arg->offset;
4316 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
4318 memset((uint8_t *)buf + size - bytes, 0xff, bytes);
4319 memset(buf, 0x00, size - bytes);
4321 ((uint8_t *)buf)[size - bytes - 1] = conv[extra];
4325 memset(buf, 0xff, bytes);
4326 memset((uint8_t *)buf + bytes, 0x00, size - bytes);
4328 ((uint8_t *)buf)[bytes] = conv[extra];
4331 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
4334 push_args(ctx, arg);
4338 /** Default parsing function for token name matching. */
4340 parse_default(struct context *ctx, const struct token *token,
4341 const char *str, unsigned int len,
4342 void *buf, unsigned int size)
4347 if (strcmp_partial(token->name, str, len))
4352 /** Parse flow command, initialize output buffer for subsequent tokens. */
4354 parse_init(struct context *ctx, const struct token *token,
4355 const char *str, unsigned int len,
4356 void *buf, unsigned int size)
4358 struct buffer *out = buf;
4360 /* Token name must match. */
4361 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4363 /* Nothing else to do if there is no buffer. */
4366 /* Make sure buffer is large enough. */
4367 if (size < sizeof(*out))
4369 /* Initialize buffer. */
4370 memset(out, 0x00, sizeof(*out));
4371 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
4374 ctx->objmask = NULL;
4378 /** Parse tokens for shared action commands. */
4380 parse_sa(struct context *ctx, const struct token *token,
4381 const char *str, unsigned int len,
4382 void *buf, unsigned int size)
4384 struct buffer *out = buf;
4386 /* Token name must match. */
4387 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4389 /* Nothing else to do if there is no buffer. */
4392 if (!out->command) {
4393 if (ctx->curr != SHARED_ACTION)
4395 if (sizeof(*out) > size)
4397 out->command = ctx->curr;
4400 ctx->objmask = NULL;
4401 out->args.vc.data = (uint8_t *)out + size;
4404 switch (ctx->curr) {
4405 case SHARED_ACTION_CREATE:
4406 case SHARED_ACTION_UPDATE:
4407 out->args.vc.actions =
4408 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
4410 out->args.vc.attr.group = UINT32_MAX;
4412 case SHARED_ACTION_QUERY:
4413 out->command = ctx->curr;
4416 ctx->objmask = NULL;
4418 case SHARED_ACTION_EGRESS:
4419 out->args.vc.attr.egress = 1;
4421 case SHARED_ACTION_INGRESS:
4422 out->args.vc.attr.ingress = 1;
4430 /** Parse tokens for shared action destroy command. */
4432 parse_sa_destroy(struct context *ctx, const struct token *token,
4433 const char *str, unsigned int len,
4434 void *buf, unsigned int size)
4436 struct buffer *out = buf;
4437 uint32_t *action_id;
4439 /* Token name must match. */
4440 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4442 /* Nothing else to do if there is no buffer. */
4445 if (!out->command || out->command == SHARED_ACTION) {
4446 if (ctx->curr != SHARED_ACTION_DESTROY)
4448 if (sizeof(*out) > size)
4450 out->command = ctx->curr;
4453 ctx->objmask = NULL;
4454 out->args.sa_destroy.action_id =
4455 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
4459 action_id = out->args.sa_destroy.action_id
4460 + out->args.sa_destroy.action_id_n++;
4461 if ((uint8_t *)action_id > (uint8_t *)out + size)
4464 ctx->object = action_id;
4465 ctx->objmask = NULL;
4469 /** Parse tokens for validate/create commands. */
4471 parse_vc(struct context *ctx, const struct token *token,
4472 const char *str, unsigned int len,
4473 void *buf, unsigned int size)
4475 struct buffer *out = buf;
4479 /* Token name must match. */
4480 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4482 /* Nothing else to do if there is no buffer. */
4485 if (!out->command) {
4486 if (ctx->curr != VALIDATE && ctx->curr != CREATE)
4488 if (sizeof(*out) > size)
4490 out->command = ctx->curr;
4493 ctx->objmask = NULL;
4494 out->args.vc.data = (uint8_t *)out + size;
4498 ctx->object = &out->args.vc.attr;
4499 ctx->objmask = NULL;
4500 switch (ctx->curr) {
4505 out->args.vc.attr.ingress = 1;
4508 out->args.vc.attr.egress = 1;
4511 out->args.vc.attr.transfer = 1;
4514 out->args.vc.pattern =
4515 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
4517 ctx->object = out->args.vc.pattern;
4518 ctx->objmask = NULL;
4521 out->args.vc.actions =
4522 (void *)RTE_ALIGN_CEIL((uintptr_t)
4523 (out->args.vc.pattern +
4524 out->args.vc.pattern_n),
4526 ctx->object = out->args.vc.actions;
4527 ctx->objmask = NULL;
4534 if (!out->args.vc.actions) {
4535 const struct parse_item_priv *priv = token->priv;
4536 struct rte_flow_item *item =
4537 out->args.vc.pattern + out->args.vc.pattern_n;
4539 data_size = priv->size * 3; /* spec, last, mask */
4540 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
4541 (out->args.vc.data - data_size),
4543 if ((uint8_t *)item + sizeof(*item) > data)
4545 *item = (struct rte_flow_item){
4548 ++out->args.vc.pattern_n;
4550 ctx->objmask = NULL;
4552 const struct parse_action_priv *priv = token->priv;
4553 struct rte_flow_action *action =
4554 out->args.vc.actions + out->args.vc.actions_n;
4556 data_size = priv->size; /* configuration */
4557 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
4558 (out->args.vc.data - data_size),
4560 if ((uint8_t *)action + sizeof(*action) > data)
4562 *action = (struct rte_flow_action){
4564 .conf = data_size ? data : NULL,
4566 ++out->args.vc.actions_n;
4567 ctx->object = action;
4568 ctx->objmask = NULL;
4570 memset(data, 0, data_size);
4571 out->args.vc.data = data;
4572 ctx->objdata = data_size;
4576 /** Parse pattern item parameter type. */
4578 parse_vc_spec(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;
4583 struct rte_flow_item *item;
4589 /* Token name must match. */
4590 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4592 /* Parse parameter types. */
4593 switch (ctx->curr) {
4594 static const enum index prefix[] = NEXT_ENTRY(PREFIX);
4600 case ITEM_PARAM_SPEC:
4603 case ITEM_PARAM_LAST:
4606 case ITEM_PARAM_PREFIX:
4607 /* Modify next token to expect a prefix. */
4608 if (ctx->next_num < 2)
4610 ctx->next[ctx->next_num - 2] = prefix;
4612 case ITEM_PARAM_MASK:
4618 /* Nothing else to do if there is no buffer. */
4621 if (!out->args.vc.pattern_n)
4623 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
4624 data_size = ctx->objdata / 3; /* spec, last, mask */
4625 /* Point to selected object. */
4626 ctx->object = out->args.vc.data + (data_size * index);
4628 ctx->objmask = out->args.vc.data + (data_size * 2); /* mask */
4629 item->mask = ctx->objmask;
4631 ctx->objmask = NULL;
4632 /* Update relevant item pointer. */
4633 *((const void **[]){ &item->spec, &item->last, &item->mask })[index] =
4638 /** Parse action configuration field. */
4640 parse_vc_conf(struct context *ctx, const struct token *token,
4641 const char *str, unsigned int len,
4642 void *buf, unsigned int size)
4644 struct buffer *out = buf;
4647 /* Token name must match. */
4648 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4650 /* Nothing else to do if there is no buffer. */
4653 /* Point to selected object. */
4654 ctx->object = out->args.vc.data;
4655 ctx->objmask = NULL;
4659 /** Parse eCPRI common header type field. */
4661 parse_vc_item_ecpri_type(struct context *ctx, const struct token *token,
4662 const char *str, unsigned int len,
4663 void *buf, unsigned int size)
4665 struct rte_flow_item_ecpri *ecpri;
4666 struct rte_flow_item_ecpri *ecpri_mask;
4667 struct rte_flow_item *item;
4670 struct buffer *out = buf;
4671 const struct arg *arg;
4674 /* Token name must match. */
4675 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4677 switch (ctx->curr) {
4678 case ITEM_ECPRI_COMMON_TYPE_IQ_DATA:
4679 msg_type = RTE_ECPRI_MSG_TYPE_IQ_DATA;
4681 case ITEM_ECPRI_COMMON_TYPE_RTC_CTRL:
4682 msg_type = RTE_ECPRI_MSG_TYPE_RTC_CTRL;
4684 case ITEM_ECPRI_COMMON_TYPE_DLY_MSR:
4685 msg_type = RTE_ECPRI_MSG_TYPE_DLY_MSR;
4692 arg = pop_args(ctx);
4695 ecpri = (struct rte_flow_item_ecpri *)out->args.vc.data;
4696 ecpri->hdr.common.type = msg_type;
4697 data_size = ctx->objdata / 3; /* spec, last, mask */
4698 ecpri_mask = (struct rte_flow_item_ecpri *)(out->args.vc.data +
4700 ecpri_mask->hdr.common.type = 0xFF;
4702 ecpri->hdr.common.u32 = rte_cpu_to_be_32(ecpri->hdr.common.u32);
4703 ecpri_mask->hdr.common.u32 =
4704 rte_cpu_to_be_32(ecpri_mask->hdr.common.u32);
4706 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
4708 item->mask = ecpri_mask;
4712 /** Parse RSS action. */
4714 parse_vc_action_rss(struct context *ctx, const struct token *token,
4715 const char *str, unsigned int len,
4716 void *buf, unsigned int size)
4718 struct buffer *out = buf;
4719 struct rte_flow_action *action;
4720 struct action_rss_data *action_rss_data;
4724 ret = parse_vc(ctx, token, str, len, buf, size);
4727 /* Nothing else to do if there is no buffer. */
4730 if (!out->args.vc.actions_n)
4732 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4733 /* Point to selected object. */
4734 ctx->object = out->args.vc.data;
4735 ctx->objmask = NULL;
4736 /* Set up default configuration. */
4737 action_rss_data = ctx->object;
4738 *action_rss_data = (struct action_rss_data){
4739 .conf = (struct rte_flow_action_rss){
4740 .func = RTE_ETH_HASH_FUNCTION_DEFAULT,
4743 .key_len = sizeof(action_rss_data->key),
4744 .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM),
4745 .key = action_rss_data->key,
4746 .queue = action_rss_data->queue,
4748 .key = "testpmd's default RSS hash key, "
4749 "override it for better balancing",
4752 for (i = 0; i < action_rss_data->conf.queue_num; ++i)
4753 action_rss_data->queue[i] = i;
4754 if (!port_id_is_invalid(ctx->port, DISABLED_WARN) &&
4755 ctx->port != (portid_t)RTE_PORT_ALL) {
4756 struct rte_eth_dev_info info;
4759 ret2 = rte_eth_dev_info_get(ctx->port, &info);
4763 action_rss_data->conf.key_len =
4764 RTE_MIN(sizeof(action_rss_data->key),
4765 info.hash_key_size);
4767 action->conf = &action_rss_data->conf;
4772 * Parse func field for RSS action.
4774 * The RTE_ETH_HASH_FUNCTION_* value to assign is derived from the
4775 * ACTION_RSS_FUNC_* index that called this function.
4778 parse_vc_action_rss_func(struct context *ctx, const struct token *token,
4779 const char *str, unsigned int len,
4780 void *buf, unsigned int size)
4782 struct action_rss_data *action_rss_data;
4783 enum rte_eth_hash_function func;
4787 /* Token name must match. */
4788 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4790 switch (ctx->curr) {
4791 case ACTION_RSS_FUNC_DEFAULT:
4792 func = RTE_ETH_HASH_FUNCTION_DEFAULT;
4794 case ACTION_RSS_FUNC_TOEPLITZ:
4795 func = RTE_ETH_HASH_FUNCTION_TOEPLITZ;
4797 case ACTION_RSS_FUNC_SIMPLE_XOR:
4798 func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
4800 case ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ:
4801 func = RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
4808 action_rss_data = ctx->object;
4809 action_rss_data->conf.func = func;
4814 * Parse type field for RSS action.
4816 * Valid tokens are type field names and the "end" token.
4819 parse_vc_action_rss_type(struct context *ctx, const struct token *token,
4820 const char *str, unsigned int len,
4821 void *buf, unsigned int size)
4823 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE);
4824 struct action_rss_data *action_rss_data;
4830 if (ctx->curr != ACTION_RSS_TYPE)
4832 if (!(ctx->objdata >> 16) && ctx->object) {
4833 action_rss_data = ctx->object;
4834 action_rss_data->conf.types = 0;
4836 if (!strcmp_partial("end", str, len)) {
4837 ctx->objdata &= 0xffff;
4840 for (i = 0; rss_type_table[i].str; ++i)
4841 if (!strcmp_partial(rss_type_table[i].str, str, len))
4843 if (!rss_type_table[i].str)
4845 ctx->objdata = 1 << 16 | (ctx->objdata & 0xffff);
4847 if (ctx->next_num == RTE_DIM(ctx->next))
4849 ctx->next[ctx->next_num++] = next;
4852 action_rss_data = ctx->object;
4853 action_rss_data->conf.types |= rss_type_table[i].rss_type;
4858 * Parse queue field for RSS action.
4860 * Valid tokens are queue indices and the "end" token.
4863 parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
4864 const char *str, unsigned int len,
4865 void *buf, unsigned int size)
4867 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE);
4868 struct action_rss_data *action_rss_data;
4869 const struct arg *arg;
4876 if (ctx->curr != ACTION_RSS_QUEUE)
4878 i = ctx->objdata >> 16;
4879 if (!strcmp_partial("end", str, len)) {
4880 ctx->objdata &= 0xffff;
4883 if (i >= ACTION_RSS_QUEUE_NUM)
4885 arg = ARGS_ENTRY_ARB(offsetof(struct action_rss_data, queue) +
4886 i * sizeof(action_rss_data->queue[i]),
4887 sizeof(action_rss_data->queue[i]));
4888 if (push_args(ctx, arg))
4890 ret = parse_int(ctx, token, str, len, NULL, 0);
4896 ctx->objdata = i << 16 | (ctx->objdata & 0xffff);
4898 if (ctx->next_num == RTE_DIM(ctx->next))
4900 ctx->next[ctx->next_num++] = next;
4904 action_rss_data = ctx->object;
4905 action_rss_data->conf.queue_num = i;
4906 action_rss_data->conf.queue = i ? action_rss_data->queue : NULL;
4910 /** Parse VXLAN encap action. */
4912 parse_vc_action_vxlan_encap(struct context *ctx, const struct token *token,
4913 const char *str, unsigned int len,
4914 void *buf, unsigned int size)
4916 struct buffer *out = buf;
4917 struct rte_flow_action *action;
4918 struct action_vxlan_encap_data *action_vxlan_encap_data;
4921 ret = parse_vc(ctx, token, str, len, buf, size);
4924 /* Nothing else to do if there is no buffer. */
4927 if (!out->args.vc.actions_n)
4929 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4930 /* Point to selected object. */
4931 ctx->object = out->args.vc.data;
4932 ctx->objmask = NULL;
4933 /* Set up default configuration. */
4934 action_vxlan_encap_data = ctx->object;
4935 *action_vxlan_encap_data = (struct action_vxlan_encap_data){
4936 .conf = (struct rte_flow_action_vxlan_encap){
4937 .definition = action_vxlan_encap_data->items,
4941 .type = RTE_FLOW_ITEM_TYPE_ETH,
4942 .spec = &action_vxlan_encap_data->item_eth,
4943 .mask = &rte_flow_item_eth_mask,
4946 .type = RTE_FLOW_ITEM_TYPE_VLAN,
4947 .spec = &action_vxlan_encap_data->item_vlan,
4948 .mask = &rte_flow_item_vlan_mask,
4951 .type = RTE_FLOW_ITEM_TYPE_IPV4,
4952 .spec = &action_vxlan_encap_data->item_ipv4,
4953 .mask = &rte_flow_item_ipv4_mask,
4956 .type = RTE_FLOW_ITEM_TYPE_UDP,
4957 .spec = &action_vxlan_encap_data->item_udp,
4958 .mask = &rte_flow_item_udp_mask,
4961 .type = RTE_FLOW_ITEM_TYPE_VXLAN,
4962 .spec = &action_vxlan_encap_data->item_vxlan,
4963 .mask = &rte_flow_item_vxlan_mask,
4966 .type = RTE_FLOW_ITEM_TYPE_END,
4971 .tci = vxlan_encap_conf.vlan_tci,
4975 .src_addr = vxlan_encap_conf.ipv4_src,
4976 .dst_addr = vxlan_encap_conf.ipv4_dst,
4979 .src_port = vxlan_encap_conf.udp_src,
4980 .dst_port = vxlan_encap_conf.udp_dst,
4982 .item_vxlan.flags = 0,
4984 memcpy(action_vxlan_encap_data->item_eth.dst.addr_bytes,
4985 vxlan_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
4986 memcpy(action_vxlan_encap_data->item_eth.src.addr_bytes,
4987 vxlan_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
4988 if (!vxlan_encap_conf.select_ipv4) {
4989 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.src_addr,
4990 &vxlan_encap_conf.ipv6_src,
4991 sizeof(vxlan_encap_conf.ipv6_src));
4992 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.dst_addr,
4993 &vxlan_encap_conf.ipv6_dst,
4994 sizeof(vxlan_encap_conf.ipv6_dst));
4995 action_vxlan_encap_data->items[2] = (struct rte_flow_item){
4996 .type = RTE_FLOW_ITEM_TYPE_IPV6,
4997 .spec = &action_vxlan_encap_data->item_ipv6,
4998 .mask = &rte_flow_item_ipv6_mask,
5001 if (!vxlan_encap_conf.select_vlan)
5002 action_vxlan_encap_data->items[1].type =
5003 RTE_FLOW_ITEM_TYPE_VOID;
5004 if (vxlan_encap_conf.select_tos_ttl) {
5005 if (vxlan_encap_conf.select_ipv4) {
5006 static struct rte_flow_item_ipv4 ipv4_mask_tos;
5008 memcpy(&ipv4_mask_tos, &rte_flow_item_ipv4_mask,
5009 sizeof(ipv4_mask_tos));
5010 ipv4_mask_tos.hdr.type_of_service = 0xff;
5011 ipv4_mask_tos.hdr.time_to_live = 0xff;
5012 action_vxlan_encap_data->item_ipv4.hdr.type_of_service =
5013 vxlan_encap_conf.ip_tos;
5014 action_vxlan_encap_data->item_ipv4.hdr.time_to_live =
5015 vxlan_encap_conf.ip_ttl;
5016 action_vxlan_encap_data->items[2].mask =
5019 static struct rte_flow_item_ipv6 ipv6_mask_tos;
5021 memcpy(&ipv6_mask_tos, &rte_flow_item_ipv6_mask,
5022 sizeof(ipv6_mask_tos));
5023 ipv6_mask_tos.hdr.vtc_flow |=
5024 RTE_BE32(0xfful << RTE_IPV6_HDR_TC_SHIFT);
5025 ipv6_mask_tos.hdr.hop_limits = 0xff;
5026 action_vxlan_encap_data->item_ipv6.hdr.vtc_flow |=
5028 ((uint32_t)vxlan_encap_conf.ip_tos <<
5029 RTE_IPV6_HDR_TC_SHIFT);
5030 action_vxlan_encap_data->item_ipv6.hdr.hop_limits =
5031 vxlan_encap_conf.ip_ttl;
5032 action_vxlan_encap_data->items[2].mask =
5036 memcpy(action_vxlan_encap_data->item_vxlan.vni, vxlan_encap_conf.vni,
5037 RTE_DIM(vxlan_encap_conf.vni));
5038 action->conf = &action_vxlan_encap_data->conf;
5042 /** Parse NVGRE encap action. */
5044 parse_vc_action_nvgre_encap(struct context *ctx, const struct token *token,
5045 const char *str, unsigned int len,
5046 void *buf, unsigned int size)
5048 struct buffer *out = buf;
5049 struct rte_flow_action *action;
5050 struct action_nvgre_encap_data *action_nvgre_encap_data;
5053 ret = parse_vc(ctx, token, str, len, buf, size);
5056 /* Nothing else to do if there is no buffer. */
5059 if (!out->args.vc.actions_n)
5061 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5062 /* Point to selected object. */
5063 ctx->object = out->args.vc.data;
5064 ctx->objmask = NULL;
5065 /* Set up default configuration. */
5066 action_nvgre_encap_data = ctx->object;
5067 *action_nvgre_encap_data = (struct action_nvgre_encap_data){
5068 .conf = (struct rte_flow_action_nvgre_encap){
5069 .definition = action_nvgre_encap_data->items,
5073 .type = RTE_FLOW_ITEM_TYPE_ETH,
5074 .spec = &action_nvgre_encap_data->item_eth,
5075 .mask = &rte_flow_item_eth_mask,
5078 .type = RTE_FLOW_ITEM_TYPE_VLAN,
5079 .spec = &action_nvgre_encap_data->item_vlan,
5080 .mask = &rte_flow_item_vlan_mask,
5083 .type = RTE_FLOW_ITEM_TYPE_IPV4,
5084 .spec = &action_nvgre_encap_data->item_ipv4,
5085 .mask = &rte_flow_item_ipv4_mask,
5088 .type = RTE_FLOW_ITEM_TYPE_NVGRE,
5089 .spec = &action_nvgre_encap_data->item_nvgre,
5090 .mask = &rte_flow_item_nvgre_mask,
5093 .type = RTE_FLOW_ITEM_TYPE_END,
5098 .tci = nvgre_encap_conf.vlan_tci,
5102 .src_addr = nvgre_encap_conf.ipv4_src,
5103 .dst_addr = nvgre_encap_conf.ipv4_dst,
5105 .item_nvgre.flow_id = 0,
5107 memcpy(action_nvgre_encap_data->item_eth.dst.addr_bytes,
5108 nvgre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5109 memcpy(action_nvgre_encap_data->item_eth.src.addr_bytes,
5110 nvgre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5111 if (!nvgre_encap_conf.select_ipv4) {
5112 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.src_addr,
5113 &nvgre_encap_conf.ipv6_src,
5114 sizeof(nvgre_encap_conf.ipv6_src));
5115 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.dst_addr,
5116 &nvgre_encap_conf.ipv6_dst,
5117 sizeof(nvgre_encap_conf.ipv6_dst));
5118 action_nvgre_encap_data->items[2] = (struct rte_flow_item){
5119 .type = RTE_FLOW_ITEM_TYPE_IPV6,
5120 .spec = &action_nvgre_encap_data->item_ipv6,
5121 .mask = &rte_flow_item_ipv6_mask,
5124 if (!nvgre_encap_conf.select_vlan)
5125 action_nvgre_encap_data->items[1].type =
5126 RTE_FLOW_ITEM_TYPE_VOID;
5127 memcpy(action_nvgre_encap_data->item_nvgre.tni, nvgre_encap_conf.tni,
5128 RTE_DIM(nvgre_encap_conf.tni));
5129 action->conf = &action_nvgre_encap_data->conf;
5133 /** Parse l2 encap action. */
5135 parse_vc_action_l2_encap(struct context *ctx, const struct token *token,
5136 const char *str, unsigned int len,
5137 void *buf, unsigned int size)
5139 struct buffer *out = buf;
5140 struct rte_flow_action *action;
5141 struct action_raw_encap_data *action_encap_data;
5142 struct rte_flow_item_eth eth = { .type = 0, };
5143 struct rte_flow_item_vlan vlan = {
5144 .tci = mplsoudp_encap_conf.vlan_tci,
5150 ret = parse_vc(ctx, token, str, len, buf, size);
5153 /* Nothing else to do if there is no buffer. */
5156 if (!out->args.vc.actions_n)
5158 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5159 /* Point to selected object. */
5160 ctx->object = out->args.vc.data;
5161 ctx->objmask = NULL;
5162 /* Copy the headers to the buffer. */
5163 action_encap_data = ctx->object;
5164 *action_encap_data = (struct action_raw_encap_data) {
5165 .conf = (struct rte_flow_action_raw_encap){
5166 .data = action_encap_data->data,
5170 header = action_encap_data->data;
5171 if (l2_encap_conf.select_vlan)
5172 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5173 else if (l2_encap_conf.select_ipv4)
5174 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5176 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5177 memcpy(eth.dst.addr_bytes,
5178 l2_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5179 memcpy(eth.src.addr_bytes,
5180 l2_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5181 memcpy(header, ð, sizeof(eth));
5182 header += sizeof(eth);
5183 if (l2_encap_conf.select_vlan) {
5184 if (l2_encap_conf.select_ipv4)
5185 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5187 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5188 memcpy(header, &vlan, sizeof(vlan));
5189 header += sizeof(vlan);
5191 action_encap_data->conf.size = header -
5192 action_encap_data->data;
5193 action->conf = &action_encap_data->conf;
5197 /** Parse l2 decap action. */
5199 parse_vc_action_l2_decap(struct context *ctx, const struct token *token,
5200 const char *str, unsigned int len,
5201 void *buf, unsigned int size)
5203 struct buffer *out = buf;
5204 struct rte_flow_action *action;
5205 struct action_raw_decap_data *action_decap_data;
5206 struct rte_flow_item_eth eth = { .type = 0, };
5207 struct rte_flow_item_vlan vlan = {
5208 .tci = mplsoudp_encap_conf.vlan_tci,
5214 ret = parse_vc(ctx, token, str, len, buf, size);
5217 /* Nothing else to do if there is no buffer. */
5220 if (!out->args.vc.actions_n)
5222 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5223 /* Point to selected object. */
5224 ctx->object = out->args.vc.data;
5225 ctx->objmask = NULL;
5226 /* Copy the headers to the buffer. */
5227 action_decap_data = ctx->object;
5228 *action_decap_data = (struct action_raw_decap_data) {
5229 .conf = (struct rte_flow_action_raw_decap){
5230 .data = action_decap_data->data,
5234 header = action_decap_data->data;
5235 if (l2_decap_conf.select_vlan)
5236 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5237 memcpy(header, ð, sizeof(eth));
5238 header += sizeof(eth);
5239 if (l2_decap_conf.select_vlan) {
5240 memcpy(header, &vlan, sizeof(vlan));
5241 header += sizeof(vlan);
5243 action_decap_data->conf.size = header -
5244 action_decap_data->data;
5245 action->conf = &action_decap_data->conf;
5249 #define ETHER_TYPE_MPLS_UNICAST 0x8847
5251 /** Parse MPLSOGRE encap action. */
5253 parse_vc_action_mplsogre_encap(struct context *ctx, const struct token *token,
5254 const char *str, unsigned int len,
5255 void *buf, unsigned int size)
5257 struct buffer *out = buf;
5258 struct rte_flow_action *action;
5259 struct action_raw_encap_data *action_encap_data;
5260 struct rte_flow_item_eth eth = { .type = 0, };
5261 struct rte_flow_item_vlan vlan = {
5262 .tci = mplsogre_encap_conf.vlan_tci,
5265 struct rte_flow_item_ipv4 ipv4 = {
5267 .src_addr = mplsogre_encap_conf.ipv4_src,
5268 .dst_addr = mplsogre_encap_conf.ipv4_dst,
5269 .next_proto_id = IPPROTO_GRE,
5270 .version_ihl = RTE_IPV4_VHL_DEF,
5271 .time_to_live = IPDEFTTL,
5274 struct rte_flow_item_ipv6 ipv6 = {
5276 .proto = IPPROTO_GRE,
5277 .hop_limits = IPDEFTTL,
5280 struct rte_flow_item_gre gre = {
5281 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
5283 struct rte_flow_item_mpls mpls = {
5289 ret = parse_vc(ctx, token, str, len, buf, size);
5292 /* Nothing else to do if there is no buffer. */
5295 if (!out->args.vc.actions_n)
5297 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5298 /* Point to selected object. */
5299 ctx->object = out->args.vc.data;
5300 ctx->objmask = NULL;
5301 /* Copy the headers to the buffer. */
5302 action_encap_data = ctx->object;
5303 *action_encap_data = (struct action_raw_encap_data) {
5304 .conf = (struct rte_flow_action_raw_encap){
5305 .data = action_encap_data->data,
5310 header = action_encap_data->data;
5311 if (mplsogre_encap_conf.select_vlan)
5312 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5313 else if (mplsogre_encap_conf.select_ipv4)
5314 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5316 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5317 memcpy(eth.dst.addr_bytes,
5318 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5319 memcpy(eth.src.addr_bytes,
5320 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5321 memcpy(header, ð, sizeof(eth));
5322 header += sizeof(eth);
5323 if (mplsogre_encap_conf.select_vlan) {
5324 if (mplsogre_encap_conf.select_ipv4)
5325 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5327 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5328 memcpy(header, &vlan, sizeof(vlan));
5329 header += sizeof(vlan);
5331 if (mplsogre_encap_conf.select_ipv4) {
5332 memcpy(header, &ipv4, sizeof(ipv4));
5333 header += sizeof(ipv4);
5335 memcpy(&ipv6.hdr.src_addr,
5336 &mplsogre_encap_conf.ipv6_src,
5337 sizeof(mplsogre_encap_conf.ipv6_src));
5338 memcpy(&ipv6.hdr.dst_addr,
5339 &mplsogre_encap_conf.ipv6_dst,
5340 sizeof(mplsogre_encap_conf.ipv6_dst));
5341 memcpy(header, &ipv6, sizeof(ipv6));
5342 header += sizeof(ipv6);
5344 memcpy(header, &gre, sizeof(gre));
5345 header += sizeof(gre);
5346 memcpy(mpls.label_tc_s, mplsogre_encap_conf.label,
5347 RTE_DIM(mplsogre_encap_conf.label));
5348 mpls.label_tc_s[2] |= 0x1;
5349 memcpy(header, &mpls, sizeof(mpls));
5350 header += sizeof(mpls);
5351 action_encap_data->conf.size = header -
5352 action_encap_data->data;
5353 action->conf = &action_encap_data->conf;
5357 /** Parse MPLSOGRE decap action. */
5359 parse_vc_action_mplsogre_decap(struct context *ctx, const struct token *token,
5360 const char *str, unsigned int len,
5361 void *buf, unsigned int size)
5363 struct buffer *out = buf;
5364 struct rte_flow_action *action;
5365 struct action_raw_decap_data *action_decap_data;
5366 struct rte_flow_item_eth eth = { .type = 0, };
5367 struct rte_flow_item_vlan vlan = {.tci = 0};
5368 struct rte_flow_item_ipv4 ipv4 = {
5370 .next_proto_id = IPPROTO_GRE,
5373 struct rte_flow_item_ipv6 ipv6 = {
5375 .proto = IPPROTO_GRE,
5378 struct rte_flow_item_gre gre = {
5379 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
5381 struct rte_flow_item_mpls mpls;
5385 ret = parse_vc(ctx, token, str, len, buf, size);
5388 /* Nothing else to do if there is no buffer. */
5391 if (!out->args.vc.actions_n)
5393 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5394 /* Point to selected object. */
5395 ctx->object = out->args.vc.data;
5396 ctx->objmask = NULL;
5397 /* Copy the headers to the buffer. */
5398 action_decap_data = ctx->object;
5399 *action_decap_data = (struct action_raw_decap_data) {
5400 .conf = (struct rte_flow_action_raw_decap){
5401 .data = action_decap_data->data,
5405 header = action_decap_data->data;
5406 if (mplsogre_decap_conf.select_vlan)
5407 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5408 else if (mplsogre_encap_conf.select_ipv4)
5409 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5411 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5412 memcpy(eth.dst.addr_bytes,
5413 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5414 memcpy(eth.src.addr_bytes,
5415 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5416 memcpy(header, ð, sizeof(eth));
5417 header += sizeof(eth);
5418 if (mplsogre_encap_conf.select_vlan) {
5419 if (mplsogre_encap_conf.select_ipv4)
5420 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5422 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5423 memcpy(header, &vlan, sizeof(vlan));
5424 header += sizeof(vlan);
5426 if (mplsogre_encap_conf.select_ipv4) {
5427 memcpy(header, &ipv4, sizeof(ipv4));
5428 header += sizeof(ipv4);
5430 memcpy(header, &ipv6, sizeof(ipv6));
5431 header += sizeof(ipv6);
5433 memcpy(header, &gre, sizeof(gre));
5434 header += sizeof(gre);
5435 memset(&mpls, 0, sizeof(mpls));
5436 memcpy(header, &mpls, sizeof(mpls));
5437 header += sizeof(mpls);
5438 action_decap_data->conf.size = header -
5439 action_decap_data->data;
5440 action->conf = &action_decap_data->conf;
5444 /** Parse MPLSOUDP encap action. */
5446 parse_vc_action_mplsoudp_encap(struct context *ctx, const struct token *token,
5447 const char *str, unsigned int len,
5448 void *buf, unsigned int size)
5450 struct buffer *out = buf;
5451 struct rte_flow_action *action;
5452 struct action_raw_encap_data *action_encap_data;
5453 struct rte_flow_item_eth eth = { .type = 0, };
5454 struct rte_flow_item_vlan vlan = {
5455 .tci = mplsoudp_encap_conf.vlan_tci,
5458 struct rte_flow_item_ipv4 ipv4 = {
5460 .src_addr = mplsoudp_encap_conf.ipv4_src,
5461 .dst_addr = mplsoudp_encap_conf.ipv4_dst,
5462 .next_proto_id = IPPROTO_UDP,
5463 .version_ihl = RTE_IPV4_VHL_DEF,
5464 .time_to_live = IPDEFTTL,
5467 struct rte_flow_item_ipv6 ipv6 = {
5469 .proto = IPPROTO_UDP,
5470 .hop_limits = IPDEFTTL,
5473 struct rte_flow_item_udp udp = {
5475 .src_port = mplsoudp_encap_conf.udp_src,
5476 .dst_port = mplsoudp_encap_conf.udp_dst,
5479 struct rte_flow_item_mpls mpls;
5483 ret = parse_vc(ctx, token, str, len, buf, size);
5486 /* Nothing else to do if there is no buffer. */
5489 if (!out->args.vc.actions_n)
5491 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5492 /* Point to selected object. */
5493 ctx->object = out->args.vc.data;
5494 ctx->objmask = NULL;
5495 /* Copy the headers to the buffer. */
5496 action_encap_data = ctx->object;
5497 *action_encap_data = (struct action_raw_encap_data) {
5498 .conf = (struct rte_flow_action_raw_encap){
5499 .data = action_encap_data->data,
5504 header = action_encap_data->data;
5505 if (mplsoudp_encap_conf.select_vlan)
5506 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5507 else if (mplsoudp_encap_conf.select_ipv4)
5508 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5510 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5511 memcpy(eth.dst.addr_bytes,
5512 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5513 memcpy(eth.src.addr_bytes,
5514 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5515 memcpy(header, ð, sizeof(eth));
5516 header += sizeof(eth);
5517 if (mplsoudp_encap_conf.select_vlan) {
5518 if (mplsoudp_encap_conf.select_ipv4)
5519 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5521 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5522 memcpy(header, &vlan, sizeof(vlan));
5523 header += sizeof(vlan);
5525 if (mplsoudp_encap_conf.select_ipv4) {
5526 memcpy(header, &ipv4, sizeof(ipv4));
5527 header += sizeof(ipv4);
5529 memcpy(&ipv6.hdr.src_addr,
5530 &mplsoudp_encap_conf.ipv6_src,
5531 sizeof(mplsoudp_encap_conf.ipv6_src));
5532 memcpy(&ipv6.hdr.dst_addr,
5533 &mplsoudp_encap_conf.ipv6_dst,
5534 sizeof(mplsoudp_encap_conf.ipv6_dst));
5535 memcpy(header, &ipv6, sizeof(ipv6));
5536 header += sizeof(ipv6);
5538 memcpy(header, &udp, sizeof(udp));
5539 header += sizeof(udp);
5540 memcpy(mpls.label_tc_s, mplsoudp_encap_conf.label,
5541 RTE_DIM(mplsoudp_encap_conf.label));
5542 mpls.label_tc_s[2] |= 0x1;
5543 memcpy(header, &mpls, sizeof(mpls));
5544 header += sizeof(mpls);
5545 action_encap_data->conf.size = header -
5546 action_encap_data->data;
5547 action->conf = &action_encap_data->conf;
5551 /** Parse MPLSOUDP decap action. */
5553 parse_vc_action_mplsoudp_decap(struct context *ctx, const struct token *token,
5554 const char *str, unsigned int len,
5555 void *buf, unsigned int size)
5557 struct buffer *out = buf;
5558 struct rte_flow_action *action;
5559 struct action_raw_decap_data *action_decap_data;
5560 struct rte_flow_item_eth eth = { .type = 0, };
5561 struct rte_flow_item_vlan vlan = {.tci = 0};
5562 struct rte_flow_item_ipv4 ipv4 = {
5564 .next_proto_id = IPPROTO_UDP,
5567 struct rte_flow_item_ipv6 ipv6 = {
5569 .proto = IPPROTO_UDP,
5572 struct rte_flow_item_udp udp = {
5574 .dst_port = rte_cpu_to_be_16(6635),
5577 struct rte_flow_item_mpls mpls;
5581 ret = parse_vc(ctx, token, str, len, buf, size);
5584 /* Nothing else to do if there is no buffer. */
5587 if (!out->args.vc.actions_n)
5589 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5590 /* Point to selected object. */
5591 ctx->object = out->args.vc.data;
5592 ctx->objmask = NULL;
5593 /* Copy the headers to the buffer. */
5594 action_decap_data = ctx->object;
5595 *action_decap_data = (struct action_raw_decap_data) {
5596 .conf = (struct rte_flow_action_raw_decap){
5597 .data = action_decap_data->data,
5601 header = action_decap_data->data;
5602 if (mplsoudp_decap_conf.select_vlan)
5603 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5604 else if (mplsoudp_encap_conf.select_ipv4)
5605 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5607 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5608 memcpy(eth.dst.addr_bytes,
5609 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5610 memcpy(eth.src.addr_bytes,
5611 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5612 memcpy(header, ð, sizeof(eth));
5613 header += sizeof(eth);
5614 if (mplsoudp_encap_conf.select_vlan) {
5615 if (mplsoudp_encap_conf.select_ipv4)
5616 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5618 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5619 memcpy(header, &vlan, sizeof(vlan));
5620 header += sizeof(vlan);
5622 if (mplsoudp_encap_conf.select_ipv4) {
5623 memcpy(header, &ipv4, sizeof(ipv4));
5624 header += sizeof(ipv4);
5626 memcpy(header, &ipv6, sizeof(ipv6));
5627 header += sizeof(ipv6);
5629 memcpy(header, &udp, sizeof(udp));
5630 header += sizeof(udp);
5631 memset(&mpls, 0, sizeof(mpls));
5632 memcpy(header, &mpls, sizeof(mpls));
5633 header += sizeof(mpls);
5634 action_decap_data->conf.size = header -
5635 action_decap_data->data;
5636 action->conf = &action_decap_data->conf;
5641 parse_vc_action_raw_decap_index(struct context *ctx, const struct token *token,
5642 const char *str, unsigned int len, void *buf,
5645 struct action_raw_decap_data *action_raw_decap_data;
5646 struct rte_flow_action *action;
5647 const struct arg *arg;
5648 struct buffer *out = buf;
5652 RTE_SET_USED(token);
5655 arg = ARGS_ENTRY_ARB_BOUNDED
5656 (offsetof(struct action_raw_decap_data, idx),
5657 sizeof(((struct action_raw_decap_data *)0)->idx),
5658 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
5659 if (push_args(ctx, arg))
5661 ret = parse_int(ctx, token, str, len, NULL, 0);
5668 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5669 action_raw_decap_data = ctx->object;
5670 idx = action_raw_decap_data->idx;
5671 action_raw_decap_data->conf.data = raw_decap_confs[idx].data;
5672 action_raw_decap_data->conf.size = raw_decap_confs[idx].size;
5673 action->conf = &action_raw_decap_data->conf;
5679 parse_vc_action_raw_encap_index(struct context *ctx, const struct token *token,
5680 const char *str, unsigned int len, void *buf,
5683 struct action_raw_encap_data *action_raw_encap_data;
5684 struct rte_flow_action *action;
5685 const struct arg *arg;
5686 struct buffer *out = buf;
5690 RTE_SET_USED(token);
5693 if (ctx->curr != ACTION_RAW_ENCAP_INDEX_VALUE)
5695 arg = ARGS_ENTRY_ARB_BOUNDED
5696 (offsetof(struct action_raw_encap_data, idx),
5697 sizeof(((struct action_raw_encap_data *)0)->idx),
5698 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
5699 if (push_args(ctx, arg))
5701 ret = parse_int(ctx, token, str, len, NULL, 0);
5708 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5709 action_raw_encap_data = ctx->object;
5710 idx = action_raw_encap_data->idx;
5711 action_raw_encap_data->conf.data = raw_encap_confs[idx].data;
5712 action_raw_encap_data->conf.size = raw_encap_confs[idx].size;
5713 action_raw_encap_data->conf.preserve = NULL;
5714 action->conf = &action_raw_encap_data->conf;
5719 parse_vc_action_raw_encap(struct context *ctx, const struct token *token,
5720 const char *str, unsigned int len, void *buf,
5723 struct buffer *out = buf;
5724 struct rte_flow_action *action;
5725 struct action_raw_encap_data *action_raw_encap_data = NULL;
5728 ret = parse_vc(ctx, token, str, len, buf, size);
5731 /* Nothing else to do if there is no buffer. */
5734 if (!out->args.vc.actions_n)
5736 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5737 /* Point to selected object. */
5738 ctx->object = out->args.vc.data;
5739 ctx->objmask = NULL;
5740 /* Copy the headers to the buffer. */
5741 action_raw_encap_data = ctx->object;
5742 action_raw_encap_data->conf.data = raw_encap_confs[0].data;
5743 action_raw_encap_data->conf.preserve = NULL;
5744 action_raw_encap_data->conf.size = raw_encap_confs[0].size;
5745 action->conf = &action_raw_encap_data->conf;
5750 parse_vc_action_raw_decap(struct context *ctx, const struct token *token,
5751 const char *str, unsigned int len, void *buf,
5754 struct buffer *out = buf;
5755 struct rte_flow_action *action;
5756 struct action_raw_decap_data *action_raw_decap_data = NULL;
5759 ret = parse_vc(ctx, token, str, len, buf, size);
5762 /* Nothing else to do if there is no buffer. */
5765 if (!out->args.vc.actions_n)
5767 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5768 /* Point to selected object. */
5769 ctx->object = out->args.vc.data;
5770 ctx->objmask = NULL;
5771 /* Copy the headers to the buffer. */
5772 action_raw_decap_data = ctx->object;
5773 action_raw_decap_data->conf.data = raw_decap_confs[0].data;
5774 action_raw_decap_data->conf.size = raw_decap_confs[0].size;
5775 action->conf = &action_raw_decap_data->conf;
5780 parse_vc_action_set_meta(struct context *ctx, const struct token *token,
5781 const char *str, unsigned int len, void *buf,
5786 ret = parse_vc(ctx, token, str, len, buf, size);
5789 ret = rte_flow_dynf_metadata_register();
5796 parse_vc_action_sample(struct context *ctx, const struct token *token,
5797 const char *str, unsigned int len, void *buf,
5800 struct buffer *out = buf;
5801 struct rte_flow_action *action;
5802 struct action_sample_data *action_sample_data = NULL;
5803 static struct rte_flow_action end_action = {
5804 RTE_FLOW_ACTION_TYPE_END, 0
5808 ret = parse_vc(ctx, token, str, len, buf, size);
5811 /* Nothing else to do if there is no buffer. */
5814 if (!out->args.vc.actions_n)
5816 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5817 /* Point to selected object. */
5818 ctx->object = out->args.vc.data;
5819 ctx->objmask = NULL;
5820 /* Copy the headers to the buffer. */
5821 action_sample_data = ctx->object;
5822 action_sample_data->conf.actions = &end_action;
5823 action->conf = &action_sample_data->conf;
5828 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
5829 const char *str, unsigned int len, void *buf,
5832 struct action_sample_data *action_sample_data;
5833 struct rte_flow_action *action;
5834 const struct arg *arg;
5835 struct buffer *out = buf;
5839 RTE_SET_USED(token);
5842 if (ctx->curr != ACTION_SAMPLE_INDEX_VALUE)
5844 arg = ARGS_ENTRY_ARB_BOUNDED
5845 (offsetof(struct action_sample_data, idx),
5846 sizeof(((struct action_sample_data *)0)->idx),
5847 0, RAW_SAMPLE_CONFS_MAX_NUM - 1);
5848 if (push_args(ctx, arg))
5850 ret = parse_int(ctx, token, str, len, NULL, 0);
5857 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5858 action_sample_data = ctx->object;
5859 idx = action_sample_data->idx;
5860 action_sample_data->conf.actions = raw_sample_confs[idx].data;
5861 action->conf = &action_sample_data->conf;
5865 /** Parse tokens for destroy command. */
5867 parse_destroy(struct context *ctx, const struct token *token,
5868 const char *str, unsigned int len,
5869 void *buf, unsigned int size)
5871 struct buffer *out = buf;
5873 /* Token name must match. */
5874 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5876 /* Nothing else to do if there is no buffer. */
5879 if (!out->command) {
5880 if (ctx->curr != DESTROY)
5882 if (sizeof(*out) > size)
5884 out->command = ctx->curr;
5887 ctx->objmask = NULL;
5888 out->args.destroy.rule =
5889 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5893 if (((uint8_t *)(out->args.destroy.rule + out->args.destroy.rule_n) +
5894 sizeof(*out->args.destroy.rule)) > (uint8_t *)out + size)
5897 ctx->object = out->args.destroy.rule + out->args.destroy.rule_n++;
5898 ctx->objmask = NULL;
5902 /** Parse tokens for flush command. */
5904 parse_flush(struct context *ctx, const struct token *token,
5905 const char *str, unsigned int len,
5906 void *buf, unsigned int size)
5908 struct buffer *out = buf;
5910 /* Token name must match. */
5911 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5913 /* Nothing else to do if there is no buffer. */
5916 if (!out->command) {
5917 if (ctx->curr != FLUSH)
5919 if (sizeof(*out) > size)
5921 out->command = ctx->curr;
5924 ctx->objmask = NULL;
5929 /** Parse tokens for dump command. */
5931 parse_dump(struct context *ctx, const struct token *token,
5932 const char *str, unsigned int len,
5933 void *buf, unsigned int size)
5935 struct buffer *out = buf;
5937 /* Token name must match. */
5938 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5940 /* Nothing else to do if there is no buffer. */
5943 if (!out->command) {
5944 if (ctx->curr != DUMP)
5946 if (sizeof(*out) > size)
5948 out->command = ctx->curr;
5951 ctx->objmask = NULL;
5956 /** Parse tokens for query command. */
5958 parse_query(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 != QUERY)
5973 if (sizeof(*out) > size)
5975 out->command = ctx->curr;
5978 ctx->objmask = NULL;
5983 /** Parse action names. */
5985 parse_action(struct context *ctx, const struct token *token,
5986 const char *str, unsigned int len,
5987 void *buf, unsigned int size)
5989 struct buffer *out = buf;
5990 const struct arg *arg = pop_args(ctx);
5994 /* Argument is expected. */
5997 /* Parse action name. */
5998 for (i = 0; next_action[i]; ++i) {
5999 const struct parse_action_priv *priv;
6001 token = &token_list[next_action[i]];
6002 if (strcmp_partial(token->name, str, len))
6008 memcpy((uint8_t *)ctx->object + arg->offset,
6014 push_args(ctx, arg);
6018 /** Parse tokens for list command. */
6020 parse_list(struct context *ctx, const struct token *token,
6021 const char *str, unsigned int len,
6022 void *buf, unsigned int size)
6024 struct buffer *out = buf;
6026 /* Token name must match. */
6027 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6029 /* Nothing else to do if there is no buffer. */
6032 if (!out->command) {
6033 if (ctx->curr != LIST)
6035 if (sizeof(*out) > size)
6037 out->command = ctx->curr;
6040 ctx->objmask = NULL;
6041 out->args.list.group =
6042 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6046 if (((uint8_t *)(out->args.list.group + out->args.list.group_n) +
6047 sizeof(*out->args.list.group)) > (uint8_t *)out + size)
6050 ctx->object = out->args.list.group + out->args.list.group_n++;
6051 ctx->objmask = NULL;
6055 /** Parse tokens for list all aged flows command. */
6057 parse_aged(struct context *ctx, const struct token *token,
6058 const char *str, unsigned int len,
6059 void *buf, unsigned int size)
6061 struct buffer *out = buf;
6063 /* Token name must match. */
6064 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6066 /* Nothing else to do if there is no buffer. */
6069 if (!out->command) {
6070 if (ctx->curr != AGED)
6072 if (sizeof(*out) > size)
6074 out->command = ctx->curr;
6077 ctx->objmask = NULL;
6079 if (ctx->curr == AGED_DESTROY)
6080 out->args.aged.destroy = 1;
6084 /** Parse tokens for isolate command. */
6086 parse_isolate(struct context *ctx, const struct token *token,
6087 const char *str, unsigned int len,
6088 void *buf, unsigned int size)
6090 struct buffer *out = buf;
6092 /* Token name must match. */
6093 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6095 /* Nothing else to do if there is no buffer. */
6098 if (!out->command) {
6099 if (ctx->curr != ISOLATE)
6101 if (sizeof(*out) > size)
6103 out->command = ctx->curr;
6106 ctx->objmask = NULL;
6112 * Parse signed/unsigned integers 8 to 64-bit long.
6114 * Last argument (ctx->args) is retrieved to determine integer type and
6118 parse_int(struct context *ctx, const struct token *token,
6119 const char *str, unsigned int len,
6120 void *buf, unsigned int size)
6122 const struct arg *arg = pop_args(ctx);
6127 /* Argument is expected. */
6132 (uintmax_t)strtoimax(str, &end, 0) :
6133 strtoumax(str, &end, 0);
6134 if (errno || (size_t)(end - str) != len)
6137 ((arg->sign && ((intmax_t)u < (intmax_t)arg->min ||
6138 (intmax_t)u > (intmax_t)arg->max)) ||
6139 (!arg->sign && (u < arg->min || u > arg->max))))
6144 if (!arg_entry_bf_fill(ctx->object, u, arg) ||
6145 !arg_entry_bf_fill(ctx->objmask, -1, arg))
6149 buf = (uint8_t *)ctx->object + arg->offset;
6151 if (u > RTE_LEN2MASK(size * CHAR_BIT, uint64_t))
6155 case sizeof(uint8_t):
6156 *(uint8_t *)buf = u;
6158 case sizeof(uint16_t):
6159 *(uint16_t *)buf = arg->hton ? rte_cpu_to_be_16(u) : u;
6161 case sizeof(uint8_t [3]):
6162 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
6164 ((uint8_t *)buf)[0] = u;
6165 ((uint8_t *)buf)[1] = u >> 8;
6166 ((uint8_t *)buf)[2] = u >> 16;
6170 ((uint8_t *)buf)[0] = u >> 16;
6171 ((uint8_t *)buf)[1] = u >> 8;
6172 ((uint8_t *)buf)[2] = u;
6174 case sizeof(uint32_t):
6175 *(uint32_t *)buf = arg->hton ? rte_cpu_to_be_32(u) : u;
6177 case sizeof(uint64_t):
6178 *(uint64_t *)buf = arg->hton ? rte_cpu_to_be_64(u) : u;
6183 if (ctx->objmask && buf != (uint8_t *)ctx->objmask + arg->offset) {
6185 buf = (uint8_t *)ctx->objmask + arg->offset;
6190 push_args(ctx, arg);
6197 * Three arguments (ctx->args) are retrieved from the stack to store data,
6198 * its actual length and address (in that order).
6201 parse_string(struct context *ctx, const struct token *token,
6202 const char *str, unsigned int len,
6203 void *buf, unsigned int size)
6205 const struct arg *arg_data = pop_args(ctx);
6206 const struct arg *arg_len = pop_args(ctx);
6207 const struct arg *arg_addr = pop_args(ctx);
6208 char tmp[16]; /* Ought to be enough. */
6211 /* Arguments are expected. */
6215 push_args(ctx, arg_data);
6219 push_args(ctx, arg_len);
6220 push_args(ctx, arg_data);
6223 size = arg_data->size;
6224 /* Bit-mask fill is not supported. */
6225 if (arg_data->mask || size < len)
6229 /* Let parse_int() fill length information first. */
6230 ret = snprintf(tmp, sizeof(tmp), "%u", len);
6233 push_args(ctx, arg_len);
6234 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
6239 buf = (uint8_t *)ctx->object + arg_data->offset;
6240 /* Output buffer is not necessarily NUL-terminated. */
6241 memcpy(buf, str, len);
6242 memset((uint8_t *)buf + len, 0x00, size - len);
6244 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
6245 /* Save address if requested. */
6246 if (arg_addr->size) {
6247 memcpy((uint8_t *)ctx->object + arg_addr->offset,
6249 (uint8_t *)ctx->object + arg_data->offset
6253 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
6255 (uint8_t *)ctx->objmask + arg_data->offset
6261 push_args(ctx, arg_addr);
6262 push_args(ctx, arg_len);
6263 push_args(ctx, arg_data);
6268 parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
6274 /* Check input parameters */
6275 if ((src == NULL) ||
6281 /* Convert chars to bytes */
6282 for (i = 0, len = 0; i < *size; i += 2) {
6283 snprintf(tmp, 3, "%s", src + i);
6284 dst[len++] = strtoul(tmp, &c, 16);
6299 parse_hex(struct context *ctx, const struct token *token,
6300 const char *str, unsigned int len,
6301 void *buf, unsigned int size)
6303 const struct arg *arg_data = pop_args(ctx);
6304 const struct arg *arg_len = pop_args(ctx);
6305 const struct arg *arg_addr = pop_args(ctx);
6306 char tmp[16]; /* Ought to be enough. */
6308 unsigned int hexlen = len;
6309 unsigned int length = 256;
6310 uint8_t hex_tmp[length];
6312 /* Arguments are expected. */
6316 push_args(ctx, arg_data);
6320 push_args(ctx, arg_len);
6321 push_args(ctx, arg_data);
6324 size = arg_data->size;
6325 /* Bit-mask fill is not supported. */
6331 /* translate bytes string to array. */
6332 if (str[0] == '0' && ((str[1] == 'x') ||
6337 if (hexlen > length)
6339 ret = parse_hex_string(str, hex_tmp, &hexlen);
6342 /* Let parse_int() fill length information first. */
6343 ret = snprintf(tmp, sizeof(tmp), "%u", hexlen);
6346 push_args(ctx, arg_len);
6347 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
6352 buf = (uint8_t *)ctx->object + arg_data->offset;
6353 /* Output buffer is not necessarily NUL-terminated. */
6354 memcpy(buf, hex_tmp, hexlen);
6355 memset((uint8_t *)buf + hexlen, 0x00, size - hexlen);
6357 memset((uint8_t *)ctx->objmask + arg_data->offset,
6359 /* Save address if requested. */
6360 if (arg_addr->size) {
6361 memcpy((uint8_t *)ctx->object + arg_addr->offset,
6363 (uint8_t *)ctx->object + arg_data->offset
6367 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
6369 (uint8_t *)ctx->objmask + arg_data->offset
6375 push_args(ctx, arg_addr);
6376 push_args(ctx, arg_len);
6377 push_args(ctx, arg_data);
6383 * Parse a zero-ended string.
6386 parse_string0(struct context *ctx, const struct token *token __rte_unused,
6387 const char *str, unsigned int len,
6388 void *buf, unsigned int size)
6390 const struct arg *arg_data = pop_args(ctx);
6392 /* Arguments are expected. */
6395 size = arg_data->size;
6396 /* Bit-mask fill is not supported. */
6397 if (arg_data->mask || size < len + 1)
6401 buf = (uint8_t *)ctx->object + arg_data->offset;
6402 strncpy(buf, str, len);
6404 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
6407 push_args(ctx, arg_data);
6412 * Parse a MAC address.
6414 * Last argument (ctx->args) is retrieved to determine storage size and
6418 parse_mac_addr(struct context *ctx, const struct token *token,
6419 const char *str, unsigned int len,
6420 void *buf, unsigned int size)
6422 const struct arg *arg = pop_args(ctx);
6423 struct rte_ether_addr tmp;
6427 /* Argument is expected. */
6431 /* Bit-mask fill is not supported. */
6432 if (arg->mask || size != sizeof(tmp))
6434 /* Only network endian is supported. */
6437 ret = cmdline_parse_etheraddr(NULL, str, &tmp, size);
6438 if (ret < 0 || (unsigned int)ret != len)
6442 buf = (uint8_t *)ctx->object + arg->offset;
6443 memcpy(buf, &tmp, size);
6445 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6448 push_args(ctx, arg);
6453 * Parse an IPv4 address.
6455 * Last argument (ctx->args) is retrieved to determine storage size and
6459 parse_ipv4_addr(struct context *ctx, const struct token *token,
6460 const char *str, unsigned int len,
6461 void *buf, unsigned int size)
6463 const struct arg *arg = pop_args(ctx);
6468 /* Argument is expected. */
6472 /* Bit-mask fill is not supported. */
6473 if (arg->mask || size != sizeof(tmp))
6475 /* Only network endian is supported. */
6478 memcpy(str2, str, len);
6480 ret = inet_pton(AF_INET, str2, &tmp);
6482 /* Attempt integer parsing. */
6483 push_args(ctx, arg);
6484 return parse_int(ctx, token, str, len, buf, size);
6488 buf = (uint8_t *)ctx->object + arg->offset;
6489 memcpy(buf, &tmp, size);
6491 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6494 push_args(ctx, arg);
6499 * Parse an IPv6 address.
6501 * Last argument (ctx->args) is retrieved to determine storage size and
6505 parse_ipv6_addr(struct context *ctx, const struct token *token,
6506 const char *str, unsigned int len,
6507 void *buf, unsigned int size)
6509 const struct arg *arg = pop_args(ctx);
6511 struct in6_addr tmp;
6515 /* Argument is expected. */
6519 /* Bit-mask fill is not supported. */
6520 if (arg->mask || size != sizeof(tmp))
6522 /* Only network endian is supported. */
6525 memcpy(str2, str, len);
6527 ret = inet_pton(AF_INET6, str2, &tmp);
6532 buf = (uint8_t *)ctx->object + arg->offset;
6533 memcpy(buf, &tmp, size);
6535 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6538 push_args(ctx, arg);
6542 /** Boolean values (even indices stand for false). */
6543 static const char *const boolean_name[] = {
6553 * Parse a boolean value.
6555 * Last argument (ctx->args) is retrieved to determine storage size and
6559 parse_boolean(struct context *ctx, const struct token *token,
6560 const char *str, unsigned int len,
6561 void *buf, unsigned int size)
6563 const struct arg *arg = pop_args(ctx);
6567 /* Argument is expected. */
6570 for (i = 0; boolean_name[i]; ++i)
6571 if (!strcmp_partial(boolean_name[i], str, len))
6573 /* Process token as integer. */
6574 if (boolean_name[i])
6575 str = i & 1 ? "1" : "0";
6576 push_args(ctx, arg);
6577 ret = parse_int(ctx, token, str, strlen(str), buf, size);
6578 return ret > 0 ? (int)len : ret;
6581 /** Parse port and update context. */
6583 parse_port(struct context *ctx, const struct token *token,
6584 const char *str, unsigned int len,
6585 void *buf, unsigned int size)
6587 struct buffer *out = &(struct buffer){ .port = 0 };
6595 ctx->objmask = NULL;
6596 size = sizeof(*out);
6598 ret = parse_int(ctx, token, str, len, out, size);
6600 ctx->port = out->port;
6607 parse_sa_id2ptr(struct context *ctx, const struct token *token,
6608 const char *str, unsigned int len,
6609 void *buf, unsigned int size)
6611 struct rte_flow_action *action = ctx->object;
6619 ctx->objmask = NULL;
6620 ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
6621 ctx->object = action;
6622 if (ret != (int)len)
6624 /* set shared action */
6626 action->conf = port_shared_action_get_by_id(ctx->port, id);
6627 ret = (action->conf) ? ret : -1;
6632 /** Parse set command, initialize output buffer for subsequent tokens. */
6634 parse_set_raw_encap_decap(struct context *ctx, const struct token *token,
6635 const char *str, unsigned int len,
6636 void *buf, unsigned int size)
6638 struct buffer *out = buf;
6640 /* Token name must match. */
6641 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6643 /* Nothing else to do if there is no buffer. */
6646 /* Make sure buffer is large enough. */
6647 if (size < sizeof(*out))
6650 ctx->objmask = NULL;
6654 out->command = ctx->curr;
6655 /* For encap/decap we need is pattern */
6656 out->args.vc.pattern = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6661 /** Parse set command, initialize output buffer for subsequent tokens. */
6663 parse_set_sample_action(struct context *ctx, const struct token *token,
6664 const char *str, unsigned int len,
6665 void *buf, unsigned int size)
6667 struct buffer *out = buf;
6669 /* Token name must match. */
6670 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6672 /* Nothing else to do if there is no buffer. */
6675 /* Make sure buffer is large enough. */
6676 if (size < sizeof(*out))
6679 ctx->objmask = NULL;
6683 out->command = ctx->curr;
6684 /* For sampler we need is actions */
6685 out->args.vc.actions = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6691 * Parse set raw_encap/raw_decap command,
6692 * initialize output buffer for subsequent tokens.
6695 parse_set_init(struct context *ctx, const struct token *token,
6696 const char *str, unsigned int len,
6697 void *buf, unsigned int size)
6699 struct buffer *out = buf;
6701 /* Token name must match. */
6702 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6704 /* Nothing else to do if there is no buffer. */
6707 /* Make sure buffer is large enough. */
6708 if (size < sizeof(*out))
6710 /* Initialize buffer. */
6711 memset(out, 0x00, sizeof(*out));
6712 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
6715 ctx->objmask = NULL;
6716 if (!out->command) {
6717 if (ctx->curr != SET)
6719 if (sizeof(*out) > size)
6721 out->command = ctx->curr;
6722 out->args.vc.data = (uint8_t *)out + size;
6723 ctx->object = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6729 /** No completion. */
6731 comp_none(struct context *ctx, const struct token *token,
6732 unsigned int ent, char *buf, unsigned int size)
6742 /** Complete boolean values. */
6744 comp_boolean(struct context *ctx, const struct token *token,
6745 unsigned int ent, char *buf, unsigned int size)
6751 for (i = 0; boolean_name[i]; ++i)
6752 if (buf && i == ent)
6753 return strlcpy(buf, boolean_name[i], size);
6759 /** Complete action names. */
6761 comp_action(struct context *ctx, const struct token *token,
6762 unsigned int ent, char *buf, unsigned int size)
6768 for (i = 0; next_action[i]; ++i)
6769 if (buf && i == ent)
6770 return strlcpy(buf, token_list[next_action[i]].name,
6777 /** Complete available ports. */
6779 comp_port(struct context *ctx, const struct token *token,
6780 unsigned int ent, char *buf, unsigned int size)
6787 RTE_ETH_FOREACH_DEV(p) {
6788 if (buf && i == ent)
6789 return snprintf(buf, size, "%u", p);
6797 /** Complete available rule IDs. */
6799 comp_rule_id(struct context *ctx, const struct token *token,
6800 unsigned int ent, char *buf, unsigned int size)
6803 struct rte_port *port;
6804 struct port_flow *pf;
6807 if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
6808 ctx->port == (portid_t)RTE_PORT_ALL)
6810 port = &ports[ctx->port];
6811 for (pf = port->flow_list; pf != NULL; pf = pf->next) {
6812 if (buf && i == ent)
6813 return snprintf(buf, size, "%u", pf->id);
6821 /** Complete type field for RSS action. */
6823 comp_vc_action_rss_type(struct context *ctx, const struct token *token,
6824 unsigned int ent, char *buf, unsigned int size)
6830 for (i = 0; rss_type_table[i].str; ++i)
6835 return strlcpy(buf, rss_type_table[ent].str, size);
6837 return snprintf(buf, size, "end");
6841 /** Complete queue field for RSS action. */
6843 comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
6844 unsigned int ent, char *buf, unsigned int size)
6851 return snprintf(buf, size, "%u", ent);
6853 return snprintf(buf, size, "end");
6857 /** Complete index number for set raw_encap/raw_decap commands. */
6859 comp_set_raw_index(struct context *ctx, const struct token *token,
6860 unsigned int ent, char *buf, unsigned int size)
6866 RTE_SET_USED(token);
6867 for (idx = 0; idx < RAW_ENCAP_CONFS_MAX_NUM; ++idx) {
6868 if (buf && idx == ent)
6869 return snprintf(buf, size, "%u", idx);
6875 /** Complete index number for set raw_encap/raw_decap commands. */
6877 comp_set_sample_index(struct context *ctx, const struct token *token,
6878 unsigned int ent, char *buf, unsigned int size)
6884 RTE_SET_USED(token);
6885 for (idx = 0; idx < RAW_SAMPLE_CONFS_MAX_NUM; ++idx) {
6886 if (buf && idx == ent)
6887 return snprintf(buf, size, "%u", idx);
6893 /** Internal context. */
6894 static struct context cmd_flow_context;
6896 /** Global parser instance (cmdline API). */
6897 cmdline_parse_inst_t cmd_flow;
6898 cmdline_parse_inst_t cmd_set_raw;
6900 /** Initialize context. */
6902 cmd_flow_context_init(struct context *ctx)
6904 /* A full memset() is not necessary. */
6914 ctx->objmask = NULL;
6917 /** Parse a token (cmdline API). */
6919 cmd_flow_parse(cmdline_parse_token_hdr_t *hdr, const char *src, void *result,
6922 struct context *ctx = &cmd_flow_context;
6923 const struct token *token;
6924 const enum index *list;
6929 token = &token_list[ctx->curr];
6930 /* Check argument length. */
6933 for (len = 0; src[len]; ++len)
6934 if (src[len] == '#' || isspace(src[len]))
6938 /* Last argument and EOL detection. */
6939 for (i = len; src[i]; ++i)
6940 if (src[i] == '#' || src[i] == '\r' || src[i] == '\n')
6942 else if (!isspace(src[i])) {
6947 if (src[i] == '\r' || src[i] == '\n') {
6951 /* Initialize context if necessary. */
6952 if (!ctx->next_num) {
6955 ctx->next[ctx->next_num++] = token->next[0];
6957 /* Process argument through candidates. */
6958 ctx->prev = ctx->curr;
6959 list = ctx->next[ctx->next_num - 1];
6960 for (i = 0; list[i]; ++i) {
6961 const struct token *next = &token_list[list[i]];
6964 ctx->curr = list[i];
6966 tmp = next->call(ctx, next, src, len, result, size);
6968 tmp = parse_default(ctx, next, src, len, result, size);
6969 if (tmp == -1 || tmp != len)
6977 /* Push subsequent tokens if any. */
6979 for (i = 0; token->next[i]; ++i) {
6980 if (ctx->next_num == RTE_DIM(ctx->next))
6982 ctx->next[ctx->next_num++] = token->next[i];
6984 /* Push arguments if any. */
6986 for (i = 0; token->args[i]; ++i) {
6987 if (ctx->args_num == RTE_DIM(ctx->args))
6989 ctx->args[ctx->args_num++] = token->args[i];
6994 /** Return number of completion entries (cmdline API). */
6996 cmd_flow_complete_get_nb(cmdline_parse_token_hdr_t *hdr)
6998 struct context *ctx = &cmd_flow_context;
6999 const struct token *token = &token_list[ctx->curr];
7000 const enum index *list;
7004 /* Count number of tokens in current list. */
7006 list = ctx->next[ctx->next_num - 1];
7008 list = token->next[0];
7009 for (i = 0; list[i]; ++i)
7014 * If there is a single token, use its completion callback, otherwise
7015 * return the number of entries.
7017 token = &token_list[list[0]];
7018 if (i == 1 && token->comp) {
7019 /* Save index for cmd_flow_get_help(). */
7020 ctx->prev = list[0];
7021 return token->comp(ctx, token, 0, NULL, 0);
7026 /** Return a completion entry (cmdline API). */
7028 cmd_flow_complete_get_elt(cmdline_parse_token_hdr_t *hdr, int index,
7029 char *dst, unsigned int size)
7031 struct context *ctx = &cmd_flow_context;
7032 const struct token *token = &token_list[ctx->curr];
7033 const enum index *list;
7037 /* Count number of tokens in current list. */
7039 list = ctx->next[ctx->next_num - 1];
7041 list = token->next[0];
7042 for (i = 0; list[i]; ++i)
7046 /* If there is a single token, use its completion callback. */
7047 token = &token_list[list[0]];
7048 if (i == 1 && token->comp) {
7049 /* Save index for cmd_flow_get_help(). */
7050 ctx->prev = list[0];
7051 return token->comp(ctx, token, index, dst, size) < 0 ? -1 : 0;
7053 /* Otherwise make sure the index is valid and use defaults. */
7056 token = &token_list[list[index]];
7057 strlcpy(dst, token->name, size);
7058 /* Save index for cmd_flow_get_help(). */
7059 ctx->prev = list[index];
7063 /** Populate help strings for current token (cmdline API). */
7065 cmd_flow_get_help(cmdline_parse_token_hdr_t *hdr, char *dst, unsigned int size)
7067 struct context *ctx = &cmd_flow_context;
7068 const struct token *token = &token_list[ctx->prev];
7073 /* Set token type and update global help with details. */
7074 strlcpy(dst, (token->type ? token->type : "TOKEN"), size);
7076 cmd_flow.help_str = token->help;
7078 cmd_flow.help_str = token->name;
7082 /** Token definition template (cmdline API). */
7083 static struct cmdline_token_hdr cmd_flow_token_hdr = {
7084 .ops = &(struct cmdline_token_ops){
7085 .parse = cmd_flow_parse,
7086 .complete_get_nb = cmd_flow_complete_get_nb,
7087 .complete_get_elt = cmd_flow_complete_get_elt,
7088 .get_help = cmd_flow_get_help,
7093 /** Populate the next dynamic token. */
7095 cmd_flow_tok(cmdline_parse_token_hdr_t **hdr,
7096 cmdline_parse_token_hdr_t **hdr_inst)
7098 struct context *ctx = &cmd_flow_context;
7100 /* Always reinitialize context before requesting the first token. */
7101 if (!(hdr_inst - cmd_flow.tokens))
7102 cmd_flow_context_init(ctx);
7103 /* Return NULL when no more tokens are expected. */
7104 if (!ctx->next_num && ctx->curr) {
7108 /* Determine if command should end here. */
7109 if (ctx->eol && ctx->last && ctx->next_num) {
7110 const enum index *list = ctx->next[ctx->next_num - 1];
7113 for (i = 0; list[i]; ++i) {
7120 *hdr = &cmd_flow_token_hdr;
7123 /** Dispatch parsed buffer to function calls. */
7125 cmd_flow_parsed(const struct buffer *in)
7127 switch (in->command) {
7128 case SHARED_ACTION_CREATE:
7129 port_shared_action_create(
7130 in->port, in->args.vc.attr.group,
7131 &((const struct rte_flow_shared_action_conf) {
7132 .ingress = in->args.vc.attr.ingress,
7133 .egress = in->args.vc.attr.egress,
7135 in->args.vc.actions);
7137 case SHARED_ACTION_DESTROY:
7138 port_shared_action_destroy(in->port,
7139 in->args.sa_destroy.action_id_n,
7140 in->args.sa_destroy.action_id);
7142 case SHARED_ACTION_UPDATE:
7143 port_shared_action_update(in->port, in->args.vc.attr.group,
7144 in->args.vc.actions);
7146 case SHARED_ACTION_QUERY:
7147 port_shared_action_query(in->port, in->args.sa.action_id);
7150 port_flow_validate(in->port, &in->args.vc.attr,
7151 in->args.vc.pattern, in->args.vc.actions);
7154 port_flow_create(in->port, &in->args.vc.attr,
7155 in->args.vc.pattern, in->args.vc.actions);
7158 port_flow_destroy(in->port, in->args.destroy.rule_n,
7159 in->args.destroy.rule);
7162 port_flow_flush(in->port);
7165 port_flow_dump(in->port, in->args.dump.file);
7168 port_flow_query(in->port, in->args.query.rule,
7169 &in->args.query.action);
7172 port_flow_list(in->port, in->args.list.group_n,
7173 in->args.list.group);
7176 port_flow_isolate(in->port, in->args.isolate.set);
7179 port_flow_aged(in->port, in->args.aged.destroy);
7186 /** Token generator and output processing callback (cmdline API). */
7188 cmd_flow_cb(void *arg0, struct cmdline *cl, void *arg2)
7191 cmd_flow_tok(arg0, arg2);
7193 cmd_flow_parsed(arg0);
7196 /** Global parser instance (cmdline API). */
7197 cmdline_parse_inst_t cmd_flow = {
7199 .data = NULL, /**< Unused. */
7200 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
7203 }, /**< Tokens are returned by cmd_flow_tok(). */
7206 /** set cmd facility. Reuse cmd flow's infrastructure as much as possible. */
7209 update_fields(uint8_t *buf, struct rte_flow_item *item, uint16_t next_proto)
7211 struct rte_flow_item_ipv4 *ipv4;
7212 struct rte_flow_item_eth *eth;
7213 struct rte_flow_item_ipv6 *ipv6;
7214 struct rte_flow_item_vxlan *vxlan;
7215 struct rte_flow_item_vxlan_gpe *gpe;
7216 struct rte_flow_item_nvgre *nvgre;
7217 uint32_t ipv6_vtc_flow;
7219 switch (item->type) {
7220 case RTE_FLOW_ITEM_TYPE_ETH:
7221 eth = (struct rte_flow_item_eth *)buf;
7223 eth->type = rte_cpu_to_be_16(next_proto);
7225 case RTE_FLOW_ITEM_TYPE_IPV4:
7226 ipv4 = (struct rte_flow_item_ipv4 *)buf;
7227 ipv4->hdr.version_ihl = 0x45;
7228 if (next_proto && ipv4->hdr.next_proto_id == 0)
7229 ipv4->hdr.next_proto_id = (uint8_t)next_proto;
7231 case RTE_FLOW_ITEM_TYPE_IPV6:
7232 ipv6 = (struct rte_flow_item_ipv6 *)buf;
7233 if (next_proto && ipv6->hdr.proto == 0)
7234 ipv6->hdr.proto = (uint8_t)next_proto;
7235 ipv6_vtc_flow = rte_be_to_cpu_32(ipv6->hdr.vtc_flow);
7236 ipv6_vtc_flow &= 0x0FFFFFFF; /*< reset version bits. */
7237 ipv6_vtc_flow |= 0x60000000; /*< set ipv6 version. */
7238 ipv6->hdr.vtc_flow = rte_cpu_to_be_32(ipv6_vtc_flow);
7240 case RTE_FLOW_ITEM_TYPE_VXLAN:
7241 vxlan = (struct rte_flow_item_vxlan *)buf;
7242 vxlan->flags = 0x08;
7244 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
7245 gpe = (struct rte_flow_item_vxlan_gpe *)buf;
7248 case RTE_FLOW_ITEM_TYPE_NVGRE:
7249 nvgre = (struct rte_flow_item_nvgre *)buf;
7250 nvgre->protocol = rte_cpu_to_be_16(0x6558);
7251 nvgre->c_k_s_rsvd0_ver = rte_cpu_to_be_16(0x2000);
7258 /** Helper of get item's default mask. */
7260 flow_item_default_mask(const struct rte_flow_item *item)
7262 const void *mask = NULL;
7263 static rte_be32_t gre_key_default_mask = RTE_BE32(UINT32_MAX);
7265 switch (item->type) {
7266 case RTE_FLOW_ITEM_TYPE_ANY:
7267 mask = &rte_flow_item_any_mask;
7269 case RTE_FLOW_ITEM_TYPE_VF:
7270 mask = &rte_flow_item_vf_mask;
7272 case RTE_FLOW_ITEM_TYPE_PORT_ID:
7273 mask = &rte_flow_item_port_id_mask;
7275 case RTE_FLOW_ITEM_TYPE_RAW:
7276 mask = &rte_flow_item_raw_mask;
7278 case RTE_FLOW_ITEM_TYPE_ETH:
7279 mask = &rte_flow_item_eth_mask;
7281 case RTE_FLOW_ITEM_TYPE_VLAN:
7282 mask = &rte_flow_item_vlan_mask;
7284 case RTE_FLOW_ITEM_TYPE_IPV4:
7285 mask = &rte_flow_item_ipv4_mask;
7287 case RTE_FLOW_ITEM_TYPE_IPV6:
7288 mask = &rte_flow_item_ipv6_mask;
7290 case RTE_FLOW_ITEM_TYPE_ICMP:
7291 mask = &rte_flow_item_icmp_mask;
7293 case RTE_FLOW_ITEM_TYPE_UDP:
7294 mask = &rte_flow_item_udp_mask;
7296 case RTE_FLOW_ITEM_TYPE_TCP:
7297 mask = &rte_flow_item_tcp_mask;
7299 case RTE_FLOW_ITEM_TYPE_SCTP:
7300 mask = &rte_flow_item_sctp_mask;
7302 case RTE_FLOW_ITEM_TYPE_VXLAN:
7303 mask = &rte_flow_item_vxlan_mask;
7305 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
7306 mask = &rte_flow_item_vxlan_gpe_mask;
7308 case RTE_FLOW_ITEM_TYPE_E_TAG:
7309 mask = &rte_flow_item_e_tag_mask;
7311 case RTE_FLOW_ITEM_TYPE_NVGRE:
7312 mask = &rte_flow_item_nvgre_mask;
7314 case RTE_FLOW_ITEM_TYPE_MPLS:
7315 mask = &rte_flow_item_mpls_mask;
7317 case RTE_FLOW_ITEM_TYPE_GRE:
7318 mask = &rte_flow_item_gre_mask;
7320 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
7321 mask = &gre_key_default_mask;
7323 case RTE_FLOW_ITEM_TYPE_META:
7324 mask = &rte_flow_item_meta_mask;
7326 case RTE_FLOW_ITEM_TYPE_FUZZY:
7327 mask = &rte_flow_item_fuzzy_mask;
7329 case RTE_FLOW_ITEM_TYPE_GTP:
7330 mask = &rte_flow_item_gtp_mask;
7332 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
7333 mask = &rte_flow_item_gtp_psc_mask;
7335 case RTE_FLOW_ITEM_TYPE_GENEVE:
7336 mask = &rte_flow_item_geneve_mask;
7338 case RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID:
7339 mask = &rte_flow_item_pppoe_proto_id_mask;
7341 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
7342 mask = &rte_flow_item_l2tpv3oip_mask;
7344 case RTE_FLOW_ITEM_TYPE_ESP:
7345 mask = &rte_flow_item_esp_mask;
7347 case RTE_FLOW_ITEM_TYPE_AH:
7348 mask = &rte_flow_item_ah_mask;
7350 case RTE_FLOW_ITEM_TYPE_PFCP:
7351 mask = &rte_flow_item_pfcp_mask;
7359 /** Dispatch parsed buffer to function calls. */
7361 cmd_set_raw_parsed_sample(const struct buffer *in)
7363 uint32_t n = in->args.vc.actions_n;
7365 struct rte_flow_action *action = NULL;
7366 struct rte_flow_action *data = NULL;
7368 uint16_t idx = in->port; /* We borrow port field as index */
7369 uint32_t max_size = sizeof(struct rte_flow_action) *
7370 ACTION_SAMPLE_ACTIONS_NUM;
7372 RTE_ASSERT(in->command == SET_SAMPLE_ACTIONS);
7373 data = (struct rte_flow_action *)&raw_sample_confs[idx].data;
7374 memset(data, 0x00, max_size);
7375 for (; i <= n - 1; i++) {
7376 action = in->args.vc.actions + i;
7377 if (action->type == RTE_FLOW_ACTION_TYPE_END)
7379 switch (action->type) {
7380 case RTE_FLOW_ACTION_TYPE_MARK:
7381 size = sizeof(struct rte_flow_action_mark);
7382 rte_memcpy(&sample_mark[idx],
7383 (const void *)action->conf, size);
7384 action->conf = &sample_mark[idx];
7386 case RTE_FLOW_ACTION_TYPE_COUNT:
7387 size = sizeof(struct rte_flow_action_count);
7388 rte_memcpy(&sample_count[idx],
7389 (const void *)action->conf, size);
7390 action->conf = &sample_count[idx];
7392 case RTE_FLOW_ACTION_TYPE_QUEUE:
7393 size = sizeof(struct rte_flow_action_queue);
7394 rte_memcpy(&sample_queue[idx],
7395 (const void *)action->conf, size);
7396 action->conf = &sample_queue[idx];
7398 case RTE_FLOW_ACTION_TYPE_RAW_ENCAP:
7399 size = sizeof(struct rte_flow_action_raw_encap);
7400 rte_memcpy(&sample_encap[idx],
7401 (const void *)action->conf, size);
7402 action->conf = &sample_encap[idx];
7404 case RTE_FLOW_ACTION_TYPE_PORT_ID:
7405 size = sizeof(struct rte_flow_action_port_id);
7406 rte_memcpy(&sample_port_id[idx],
7407 (const void *)action->conf, size);
7408 action->conf = &sample_port_id[idx];
7411 printf("Error - Not supported action\n");
7414 rte_memcpy(data, action, sizeof(struct rte_flow_action));
7419 /** Dispatch parsed buffer to function calls. */
7421 cmd_set_raw_parsed(const struct buffer *in)
7423 uint32_t n = in->args.vc.pattern_n;
7425 struct rte_flow_item *item = NULL;
7427 uint8_t *data = NULL;
7428 uint8_t *data_tail = NULL;
7429 size_t *total_size = NULL;
7430 uint16_t upper_layer = 0;
7432 uint16_t idx = in->port; /* We borrow port field as index */
7434 if (in->command == SET_SAMPLE_ACTIONS)
7435 return cmd_set_raw_parsed_sample(in);
7436 RTE_ASSERT(in->command == SET_RAW_ENCAP ||
7437 in->command == SET_RAW_DECAP);
7438 if (in->command == SET_RAW_ENCAP) {
7439 total_size = &raw_encap_confs[idx].size;
7440 data = (uint8_t *)&raw_encap_confs[idx].data;
7442 total_size = &raw_decap_confs[idx].size;
7443 data = (uint8_t *)&raw_decap_confs[idx].data;
7446 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
7447 /* process hdr from upper layer to low layer (L3/L4 -> L2). */
7448 data_tail = data + ACTION_RAW_ENCAP_MAX_DATA;
7449 for (i = n - 1 ; i >= 0; --i) {
7450 item = in->args.vc.pattern + i;
7451 if (item->spec == NULL)
7452 item->spec = flow_item_default_mask(item);
7453 switch (item->type) {
7454 case RTE_FLOW_ITEM_TYPE_ETH:
7455 size = sizeof(struct rte_flow_item_eth);
7457 case RTE_FLOW_ITEM_TYPE_VLAN:
7458 size = sizeof(struct rte_flow_item_vlan);
7459 proto = RTE_ETHER_TYPE_VLAN;
7461 case RTE_FLOW_ITEM_TYPE_IPV4:
7462 size = sizeof(struct rte_flow_item_ipv4);
7463 proto = RTE_ETHER_TYPE_IPV4;
7465 case RTE_FLOW_ITEM_TYPE_IPV6:
7466 size = sizeof(struct rte_flow_item_ipv6);
7467 proto = RTE_ETHER_TYPE_IPV6;
7469 case RTE_FLOW_ITEM_TYPE_UDP:
7470 size = sizeof(struct rte_flow_item_udp);
7473 case RTE_FLOW_ITEM_TYPE_TCP:
7474 size = sizeof(struct rte_flow_item_tcp);
7477 case RTE_FLOW_ITEM_TYPE_VXLAN:
7478 size = sizeof(struct rte_flow_item_vxlan);
7480 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
7481 size = sizeof(struct rte_flow_item_vxlan_gpe);
7483 case RTE_FLOW_ITEM_TYPE_GRE:
7484 size = sizeof(struct rte_flow_item_gre);
7487 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
7488 size = sizeof(rte_be32_t);
7491 case RTE_FLOW_ITEM_TYPE_MPLS:
7492 size = sizeof(struct rte_flow_item_mpls);
7495 case RTE_FLOW_ITEM_TYPE_NVGRE:
7496 size = sizeof(struct rte_flow_item_nvgre);
7499 case RTE_FLOW_ITEM_TYPE_GENEVE:
7500 size = sizeof(struct rte_flow_item_geneve);
7502 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
7503 size = sizeof(struct rte_flow_item_l2tpv3oip);
7506 case RTE_FLOW_ITEM_TYPE_ESP:
7507 size = sizeof(struct rte_flow_item_esp);
7510 case RTE_FLOW_ITEM_TYPE_AH:
7511 size = sizeof(struct rte_flow_item_ah);
7514 case RTE_FLOW_ITEM_TYPE_GTP:
7515 size = sizeof(struct rte_flow_item_gtp);
7517 case RTE_FLOW_ITEM_TYPE_PFCP:
7518 size = sizeof(struct rte_flow_item_pfcp);
7521 printf("Error - Not supported item\n");
7523 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
7526 *total_size += size;
7527 rte_memcpy(data_tail - (*total_size), item->spec, size);
7528 /* update some fields which cannot be set by cmdline */
7529 update_fields((data_tail - (*total_size)), item,
7531 upper_layer = proto;
7533 if (verbose_level & 0x1)
7534 printf("total data size is %zu\n", (*total_size));
7535 RTE_ASSERT((*total_size) <= ACTION_RAW_ENCAP_MAX_DATA);
7536 memmove(data, (data_tail - (*total_size)), *total_size);
7539 /** Populate help strings for current token (cmdline API). */
7541 cmd_set_raw_get_help(cmdline_parse_token_hdr_t *hdr, char *dst,
7544 struct context *ctx = &cmd_flow_context;
7545 const struct token *token = &token_list[ctx->prev];
7550 /* Set token type and update global help with details. */
7551 snprintf(dst, size, "%s", (token->type ? token->type : "TOKEN"));
7553 cmd_set_raw.help_str = token->help;
7555 cmd_set_raw.help_str = token->name;
7559 /** Token definition template (cmdline API). */
7560 static struct cmdline_token_hdr cmd_set_raw_token_hdr = {
7561 .ops = &(struct cmdline_token_ops){
7562 .parse = cmd_flow_parse,
7563 .complete_get_nb = cmd_flow_complete_get_nb,
7564 .complete_get_elt = cmd_flow_complete_get_elt,
7565 .get_help = cmd_set_raw_get_help,
7570 /** Populate the next dynamic token. */
7572 cmd_set_raw_tok(cmdline_parse_token_hdr_t **hdr,
7573 cmdline_parse_token_hdr_t **hdr_inst)
7575 struct context *ctx = &cmd_flow_context;
7577 /* Always reinitialize context before requesting the first token. */
7578 if (!(hdr_inst - cmd_set_raw.tokens)) {
7579 cmd_flow_context_init(ctx);
7580 ctx->curr = START_SET;
7582 /* Return NULL when no more tokens are expected. */
7583 if (!ctx->next_num && (ctx->curr != START_SET)) {
7587 /* Determine if command should end here. */
7588 if (ctx->eol && ctx->last && ctx->next_num) {
7589 const enum index *list = ctx->next[ctx->next_num - 1];
7592 for (i = 0; list[i]; ++i) {
7599 *hdr = &cmd_set_raw_token_hdr;
7602 /** Token generator and output processing callback (cmdline API). */
7604 cmd_set_raw_cb(void *arg0, struct cmdline *cl, void *arg2)
7607 cmd_set_raw_tok(arg0, arg2);
7609 cmd_set_raw_parsed(arg0);
7612 /** Global parser instance (cmdline API). */
7613 cmdline_parse_inst_t cmd_set_raw = {
7614 .f = cmd_set_raw_cb,
7615 .data = NULL, /**< Unused. */
7616 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
7619 }, /**< Tokens are returned by cmd_flow_tok(). */
7622 /* *** display raw_encap/raw_decap buf */
7623 struct cmd_show_set_raw_result {
7624 cmdline_fixed_string_t cmd_show;
7625 cmdline_fixed_string_t cmd_what;
7626 cmdline_fixed_string_t cmd_all;
7631 cmd_show_set_raw_parsed(void *parsed_result, struct cmdline *cl, void *data)
7633 struct cmd_show_set_raw_result *res = parsed_result;
7634 uint16_t index = res->cmd_index;
7636 uint8_t *raw_data = NULL;
7637 size_t raw_size = 0;
7638 char title[16] = {0};
7642 if (!strcmp(res->cmd_all, "all")) {
7645 } else if (index >= RAW_ENCAP_CONFS_MAX_NUM) {
7646 printf("index should be 0-%u\n", RAW_ENCAP_CONFS_MAX_NUM - 1);
7650 if (!strcmp(res->cmd_what, "raw_encap")) {
7651 raw_data = (uint8_t *)&raw_encap_confs[index].data;
7652 raw_size = raw_encap_confs[index].size;
7653 snprintf(title, 16, "\nindex: %u", index);
7654 rte_hexdump(stdout, title, raw_data, raw_size);
7656 raw_data = (uint8_t *)&raw_decap_confs[index].data;
7657 raw_size = raw_decap_confs[index].size;
7658 snprintf(title, 16, "\nindex: %u", index);
7659 rte_hexdump(stdout, title, raw_data, raw_size);
7661 } while (all && ++index < RAW_ENCAP_CONFS_MAX_NUM);
7664 cmdline_parse_token_string_t cmd_show_set_raw_cmd_show =
7665 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
7667 cmdline_parse_token_string_t cmd_show_set_raw_cmd_what =
7668 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
7669 cmd_what, "raw_encap#raw_decap");
7670 cmdline_parse_token_num_t cmd_show_set_raw_cmd_index =
7671 TOKEN_NUM_INITIALIZER(struct cmd_show_set_raw_result,
7673 cmdline_parse_token_string_t cmd_show_set_raw_cmd_all =
7674 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
7676 cmdline_parse_inst_t cmd_show_set_raw = {
7677 .f = cmd_show_set_raw_parsed,
7679 .help_str = "show <raw_encap|raw_decap> <index>",
7681 (void *)&cmd_show_set_raw_cmd_show,
7682 (void *)&cmd_show_set_raw_cmd_what,
7683 (void *)&cmd_show_set_raw_cmd_index,
7687 cmdline_parse_inst_t cmd_show_set_raw_all = {
7688 .f = cmd_show_set_raw_parsed,
7690 .help_str = "show <raw_encap|raw_decap> all",
7692 (void *)&cmd_show_set_raw_cmd_show,
7693 (void *)&cmd_show_set_raw_cmd_what,
7694 (void *)&cmd_show_set_raw_cmd_all,