1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2016 6WIND S.A.
3 * Copyright 2016 Mellanox Technologies, Ltd
13 #include <arpa/inet.h>
14 #include <sys/socket.h>
16 #include <rte_string_fns.h>
17 #include <rte_common.h>
18 #include <rte_ethdev.h>
19 #include <rte_byteorder.h>
20 #include <cmdline_parse.h>
21 #include <cmdline_parse_etheraddr.h>
22 #include <cmdline_parse_string.h>
23 #include <cmdline_parse_num.h>
25 #include <rte_hexdump.h>
26 #include <rte_vxlan.h>
30 #include <rte_geneve.h>
34 /** Parser token indices. */
59 /* Top-level command. */
61 /* Sub-leve commands. */
68 /* Top-level command. */
70 /* Sub-level commands. */
83 /* Tunnel arguments. */
90 /* Destroy arguments. */
93 /* Query arguments. */
99 /* Destroy aged flow arguments. */
102 /* Validate/create arguments. */
111 /* Shared action arguments */
112 SHARED_ACTION_CREATE,
113 SHARED_ACTION_UPDATE,
114 SHARED_ACTION_DESTROY,
117 /* Shared action create arguments */
118 SHARED_ACTION_CREATE_ID,
119 SHARED_ACTION_INGRESS,
120 SHARED_ACTION_EGRESS,
121 SHARED_ACTION_TRANSFER,
124 /* Shared action destroy arguments */
125 SHARED_ACTION_DESTROY_ID,
127 /* Validate/create pattern. */
165 ITEM_VLAN_INNER_TYPE,
166 ITEM_VLAN_HAS_MORE_VLAN,
169 ITEM_IPV4_FRAGMENT_OFFSET,
181 ITEM_IPV6_HAS_FRAG_EXT,
202 ITEM_E_TAG_GRP_ECID_B,
211 ITEM_GRE_C_RSVD0_VER,
230 ITEM_ARP_ETH_IPV4_SHA,
231 ITEM_ARP_ETH_IPV4_SPA,
232 ITEM_ARP_ETH_IPV4_THA,
233 ITEM_ARP_ETH_IPV4_TPA,
235 ITEM_IPV6_EXT_NEXT_HDR,
237 ITEM_IPV6_FRAG_EXT_NEXT_HDR,
238 ITEM_IPV6_FRAG_EXT_FRAG_DATA,
243 ITEM_ICMP6_ND_NS_TARGET_ADDR,
245 ITEM_ICMP6_ND_NA_TARGET_ADDR,
247 ITEM_ICMP6_ND_OPT_TYPE,
248 ITEM_ICMP6_ND_OPT_SLA_ETH,
249 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
250 ITEM_ICMP6_ND_OPT_TLA_ETH,
251 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
264 ITEM_HIGIG2_CLASSIFICATION,
270 ITEM_L2TPV3OIP_SESSION_ID,
280 ITEM_ECPRI_COMMON_TYPE,
281 ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
282 ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
283 ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
284 ITEM_ECPRI_MSG_IQ_DATA_PCID,
285 ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
286 ITEM_ECPRI_MSG_DLY_MSR_MSRID,
288 ITEM_GENEVE_OPT_CLASS,
289 ITEM_GENEVE_OPT_TYPE,
290 ITEM_GENEVE_OPT_LENGTH,
291 ITEM_GENEVE_OPT_DATA,
293 /* Validate/create actions. */
313 ACTION_RSS_FUNC_DEFAULT,
314 ACTION_RSS_FUNC_TOEPLITZ,
315 ACTION_RSS_FUNC_SIMPLE_XOR,
316 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ,
328 ACTION_PHY_PORT_ORIGINAL,
329 ACTION_PHY_PORT_INDEX,
331 ACTION_PORT_ID_ORIGINAL,
335 ACTION_OF_SET_MPLS_TTL,
336 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
337 ACTION_OF_DEC_MPLS_TTL,
338 ACTION_OF_SET_NW_TTL,
339 ACTION_OF_SET_NW_TTL_NW_TTL,
340 ACTION_OF_DEC_NW_TTL,
341 ACTION_OF_COPY_TTL_OUT,
342 ACTION_OF_COPY_TTL_IN,
345 ACTION_OF_PUSH_VLAN_ETHERTYPE,
346 ACTION_OF_SET_VLAN_VID,
347 ACTION_OF_SET_VLAN_VID_VLAN_VID,
348 ACTION_OF_SET_VLAN_PCP,
349 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
351 ACTION_OF_POP_MPLS_ETHERTYPE,
353 ACTION_OF_PUSH_MPLS_ETHERTYPE,
360 ACTION_MPLSOGRE_ENCAP,
361 ACTION_MPLSOGRE_DECAP,
362 ACTION_MPLSOUDP_ENCAP,
363 ACTION_MPLSOUDP_DECAP,
365 ACTION_SET_IPV4_SRC_IPV4_SRC,
367 ACTION_SET_IPV4_DST_IPV4_DST,
369 ACTION_SET_IPV6_SRC_IPV6_SRC,
371 ACTION_SET_IPV6_DST_IPV6_DST,
373 ACTION_SET_TP_SRC_TP_SRC,
375 ACTION_SET_TP_DST_TP_DST,
381 ACTION_SET_MAC_SRC_MAC_SRC,
383 ACTION_SET_MAC_DST_MAC_DST,
385 ACTION_INC_TCP_SEQ_VALUE,
387 ACTION_DEC_TCP_SEQ_VALUE,
389 ACTION_INC_TCP_ACK_VALUE,
391 ACTION_DEC_TCP_ACK_VALUE,
394 ACTION_RAW_ENCAP_INDEX,
395 ACTION_RAW_ENCAP_INDEX_VALUE,
396 ACTION_RAW_DECAP_INDEX,
397 ACTION_RAW_DECAP_INDEX_VALUE,
400 ACTION_SET_TAG_INDEX,
403 ACTION_SET_META_DATA,
404 ACTION_SET_META_MASK,
405 ACTION_SET_IPV4_DSCP,
406 ACTION_SET_IPV4_DSCP_VALUE,
407 ACTION_SET_IPV6_DSCP,
408 ACTION_SET_IPV6_DSCP_VALUE,
414 ACTION_SAMPLE_INDEX_VALUE,
416 SHARED_ACTION_ID2PTR,
418 ACTION_MODIFY_FIELD_OP,
419 ACTION_MODIFY_FIELD_OP_VALUE,
420 ACTION_MODIFY_FIELD_DST_TYPE,
421 ACTION_MODIFY_FIELD_DST_TYPE_VALUE,
422 ACTION_MODIFY_FIELD_DST_LEVEL,
423 ACTION_MODIFY_FIELD_DST_OFFSET,
424 ACTION_MODIFY_FIELD_SRC_TYPE,
425 ACTION_MODIFY_FIELD_SRC_TYPE_VALUE,
426 ACTION_MODIFY_FIELD_SRC_LEVEL,
427 ACTION_MODIFY_FIELD_SRC_OFFSET,
428 ACTION_MODIFY_FIELD_SRC_VALUE,
429 ACTION_MODIFY_FIELD_WIDTH,
432 /** Maximum size for pattern in struct rte_flow_item_raw. */
433 #define ITEM_RAW_PATTERN_SIZE 40
435 /** Maximum size for GENEVE option data pattern in bytes. */
436 #define ITEM_GENEVE_OPT_DATA_SIZE 124
438 /** Storage size for struct rte_flow_item_raw including pattern. */
439 #define ITEM_RAW_SIZE \
440 (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE)
442 /** Maximum number of queue indices in struct rte_flow_action_rss. */
443 #define ACTION_RSS_QUEUE_NUM 128
445 /** Storage for struct rte_flow_action_rss including external data. */
446 struct action_rss_data {
447 struct rte_flow_action_rss conf;
448 uint8_t key[RSS_HASH_KEY_LENGTH];
449 uint16_t queue[ACTION_RSS_QUEUE_NUM];
452 /** Maximum data size in struct rte_flow_action_raw_encap. */
453 #define ACTION_RAW_ENCAP_MAX_DATA 512
454 #define RAW_ENCAP_CONFS_MAX_NUM 8
456 /** Storage for struct rte_flow_action_raw_encap. */
457 struct raw_encap_conf {
458 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
459 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
463 struct raw_encap_conf raw_encap_confs[RAW_ENCAP_CONFS_MAX_NUM];
465 /** Storage for struct rte_flow_action_raw_encap including external data. */
466 struct action_raw_encap_data {
467 struct rte_flow_action_raw_encap conf;
468 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
469 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
473 /** Storage for struct rte_flow_action_raw_decap. */
474 struct raw_decap_conf {
475 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
479 struct raw_decap_conf raw_decap_confs[RAW_ENCAP_CONFS_MAX_NUM];
481 /** Storage for struct rte_flow_action_raw_decap including external data. */
482 struct action_raw_decap_data {
483 struct rte_flow_action_raw_decap conf;
484 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
488 struct vxlan_encap_conf vxlan_encap_conf = {
492 .vni = "\x00\x00\x00",
494 .udp_dst = RTE_BE16(RTE_VXLAN_DEFAULT_PORT),
495 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
496 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
497 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
498 "\x00\x00\x00\x00\x00\x00\x00\x01",
499 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
500 "\x00\x00\x00\x00\x00\x00\x11\x11",
504 .eth_src = "\x00\x00\x00\x00\x00\x00",
505 .eth_dst = "\xff\xff\xff\xff\xff\xff",
508 /** Maximum number of items in struct rte_flow_action_vxlan_encap. */
509 #define ACTION_VXLAN_ENCAP_ITEMS_NUM 6
511 /** Storage for struct rte_flow_action_vxlan_encap including external data. */
512 struct action_vxlan_encap_data {
513 struct rte_flow_action_vxlan_encap conf;
514 struct rte_flow_item items[ACTION_VXLAN_ENCAP_ITEMS_NUM];
515 struct rte_flow_item_eth item_eth;
516 struct rte_flow_item_vlan item_vlan;
518 struct rte_flow_item_ipv4 item_ipv4;
519 struct rte_flow_item_ipv6 item_ipv6;
521 struct rte_flow_item_udp item_udp;
522 struct rte_flow_item_vxlan item_vxlan;
525 struct nvgre_encap_conf nvgre_encap_conf = {
528 .tni = "\x00\x00\x00",
529 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
530 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
531 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
532 "\x00\x00\x00\x00\x00\x00\x00\x01",
533 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
534 "\x00\x00\x00\x00\x00\x00\x11\x11",
536 .eth_src = "\x00\x00\x00\x00\x00\x00",
537 .eth_dst = "\xff\xff\xff\xff\xff\xff",
540 /** Maximum number of items in struct rte_flow_action_nvgre_encap. */
541 #define ACTION_NVGRE_ENCAP_ITEMS_NUM 5
543 /** Storage for struct rte_flow_action_nvgre_encap including external data. */
544 struct action_nvgre_encap_data {
545 struct rte_flow_action_nvgre_encap conf;
546 struct rte_flow_item items[ACTION_NVGRE_ENCAP_ITEMS_NUM];
547 struct rte_flow_item_eth item_eth;
548 struct rte_flow_item_vlan item_vlan;
550 struct rte_flow_item_ipv4 item_ipv4;
551 struct rte_flow_item_ipv6 item_ipv6;
553 struct rte_flow_item_nvgre item_nvgre;
556 struct l2_encap_conf l2_encap_conf;
558 struct l2_decap_conf l2_decap_conf;
560 struct mplsogre_encap_conf mplsogre_encap_conf;
562 struct mplsogre_decap_conf mplsogre_decap_conf;
564 struct mplsoudp_encap_conf mplsoudp_encap_conf;
566 struct mplsoudp_decap_conf mplsoudp_decap_conf;
568 #define ACTION_SAMPLE_ACTIONS_NUM 10
569 #define RAW_SAMPLE_CONFS_MAX_NUM 8
570 /** Storage for struct rte_flow_action_sample including external data. */
571 struct action_sample_data {
572 struct rte_flow_action_sample conf;
575 /** Storage for struct rte_flow_action_sample. */
576 struct raw_sample_conf {
577 struct rte_flow_action data[ACTION_SAMPLE_ACTIONS_NUM];
579 struct raw_sample_conf raw_sample_confs[RAW_SAMPLE_CONFS_MAX_NUM];
580 struct rte_flow_action_mark sample_mark[RAW_SAMPLE_CONFS_MAX_NUM];
581 struct rte_flow_action_queue sample_queue[RAW_SAMPLE_CONFS_MAX_NUM];
582 struct rte_flow_action_count sample_count[RAW_SAMPLE_CONFS_MAX_NUM];
583 struct rte_flow_action_port_id sample_port_id[RAW_SAMPLE_CONFS_MAX_NUM];
584 struct rte_flow_action_raw_encap sample_encap[RAW_SAMPLE_CONFS_MAX_NUM];
585 struct action_vxlan_encap_data sample_vxlan_encap[RAW_SAMPLE_CONFS_MAX_NUM];
586 struct action_nvgre_encap_data sample_nvgre_encap[RAW_SAMPLE_CONFS_MAX_NUM];
587 struct action_rss_data sample_rss_data[RAW_SAMPLE_CONFS_MAX_NUM];
588 struct rte_flow_action_vf sample_vf[RAW_SAMPLE_CONFS_MAX_NUM];
590 static const char *const modify_field_ops[] = {
591 "set", "add", "sub", NULL
594 static const char *const modify_field_ids[] = {
595 "start", "mac_dst", "mac_src",
596 "vlan_type", "vlan_id", "mac_type",
597 "ipv4_dscp", "ipv4_ttl", "ipv4_src", "ipv4_dst",
598 "ipv6_dscp", "ipv6_hoplimit", "ipv6_src", "ipv6_dst",
599 "tcp_port_src", "tcp_port_dst",
600 "tcp_seq_num", "tcp_ack_num", "tcp_flags",
601 "udp_port_src", "udp_port_dst",
602 "vxlan_vni", "geneve_vni", "gtp_teid",
603 "tag", "mark", "meta", "pointer", "value", NULL
606 /** Maximum number of subsequent tokens and arguments on the stack. */
607 #define CTX_STACK_SIZE 16
609 /** Parser context. */
611 /** Stack of subsequent token lists to process. */
612 const enum index *next[CTX_STACK_SIZE];
613 /** Arguments for stacked tokens. */
614 const void *args[CTX_STACK_SIZE];
615 enum index curr; /**< Current token index. */
616 enum index prev; /**< Index of the last token seen. */
617 int next_num; /**< Number of entries in next[]. */
618 int args_num; /**< Number of entries in args[]. */
619 uint32_t eol:1; /**< EOL has been detected. */
620 uint32_t last:1; /**< No more arguments. */
621 portid_t port; /**< Current port ID (for completions). */
622 uint32_t objdata; /**< Object-specific data. */
623 void *object; /**< Address of current object for relative offsets. */
624 void *objmask; /**< Object a full mask must be written to. */
627 /** Token argument. */
629 uint32_t hton:1; /**< Use network byte ordering. */
630 uint32_t sign:1; /**< Value is signed. */
631 uint32_t bounded:1; /**< Value is bounded. */
632 uintmax_t min; /**< Minimum value if bounded. */
633 uintmax_t max; /**< Maximum value if bounded. */
634 uint32_t offset; /**< Relative offset from ctx->object. */
635 uint32_t size; /**< Field size. */
636 const uint8_t *mask; /**< Bit-mask to use instead of offset/size. */
639 /** Parser token definition. */
641 /** Type displayed during completion (defaults to "TOKEN"). */
643 /** Help displayed during completion (defaults to token name). */
645 /** Private data used by parser functions. */
648 * Lists of subsequent tokens to push on the stack. Each call to the
649 * parser consumes the last entry of that stack.
651 const enum index *const *next;
652 /** Arguments stack for subsequent tokens that need them. */
653 const struct arg *const *args;
655 * Token-processing callback, returns -1 in case of error, the
656 * length of the matched string otherwise. If NULL, attempts to
657 * match the token name.
659 * If buf is not NULL, the result should be stored in it according
660 * to context. An error is returned if not large enough.
662 int (*call)(struct context *ctx, const struct token *token,
663 const char *str, unsigned int len,
664 void *buf, unsigned int size);
666 * Callback that provides possible values for this token, used for
667 * completion. Returns -1 in case of error, the number of possible
668 * values otherwise. If NULL, the token name is used.
670 * If buf is not NULL, entry index ent is written to buf and the
671 * full length of the entry is returned (same behavior as
674 int (*comp)(struct context *ctx, const struct token *token,
675 unsigned int ent, char *buf, unsigned int size);
676 /** Mandatory token name, no default value. */
680 /** Static initializer for the next field. */
681 #define NEXT(...) (const enum index *const []){ __VA_ARGS__, NULL, }
683 /** Static initializer for a NEXT() entry. */
684 #define NEXT_ENTRY(...) (const enum index []){ __VA_ARGS__, ZERO, }
686 /** Static initializer for the args field. */
687 #define ARGS(...) (const struct arg *const []){ __VA_ARGS__, NULL, }
689 /** Static initializer for ARGS() to target a field. */
690 #define ARGS_ENTRY(s, f) \
691 (&(const struct arg){ \
692 .offset = offsetof(s, f), \
693 .size = sizeof(((s *)0)->f), \
696 /** Static initializer for ARGS() to target a bit-field. */
697 #define ARGS_ENTRY_BF(s, f, b) \
698 (&(const struct arg){ \
700 .mask = (const void *)&(const s){ .f = (1 << (b)) - 1 }, \
703 /** Static initializer for ARGS() to target a field with limits. */
704 #define ARGS_ENTRY_BOUNDED(s, f, i, a) \
705 (&(const struct arg){ \
709 .offset = offsetof(s, f), \
710 .size = sizeof(((s *)0)->f), \
713 /** Static initializer for ARGS() to target an arbitrary bit-mask. */
714 #define ARGS_ENTRY_MASK(s, f, m) \
715 (&(const struct arg){ \
716 .offset = offsetof(s, f), \
717 .size = sizeof(((s *)0)->f), \
718 .mask = (const void *)(m), \
721 /** Same as ARGS_ENTRY_MASK() using network byte ordering for the value. */
722 #define ARGS_ENTRY_MASK_HTON(s, f, m) \
723 (&(const struct arg){ \
725 .offset = offsetof(s, f), \
726 .size = sizeof(((s *)0)->f), \
727 .mask = (const void *)(m), \
730 /** Static initializer for ARGS() to target a pointer. */
731 #define ARGS_ENTRY_PTR(s, f) \
732 (&(const struct arg){ \
733 .size = sizeof(*((s *)0)->f), \
736 /** Static initializer for ARGS() with arbitrary offset and size. */
737 #define ARGS_ENTRY_ARB(o, s) \
738 (&(const struct arg){ \
743 /** Same as ARGS_ENTRY_ARB() with bounded values. */
744 #define ARGS_ENTRY_ARB_BOUNDED(o, s, i, a) \
745 (&(const struct arg){ \
753 /** Same as ARGS_ENTRY() using network byte ordering. */
754 #define ARGS_ENTRY_HTON(s, f) \
755 (&(const struct arg){ \
757 .offset = offsetof(s, f), \
758 .size = sizeof(((s *)0)->f), \
761 /** Same as ARGS_ENTRY_HTON() for a single argument, without structure. */
762 #define ARG_ENTRY_HTON(s) \
763 (&(const struct arg){ \
769 /** Parser output buffer layout expected by cmd_flow_parsed(). */
771 enum index command; /**< Flow command. */
772 portid_t port; /**< Affected port ID. */
776 uint32_t action_id_n;
777 } sa_destroy; /**< Shared action destroy arguments. */
780 } sa; /* Shared action query arguments */
782 struct rte_flow_attr attr;
783 struct tunnel_ops tunnel_ops;
784 struct rte_flow_item *pattern;
785 struct rte_flow_action *actions;
789 } vc; /**< Validate/create arguments. */
793 } destroy; /**< Destroy arguments. */
796 } dump; /**< Dump arguments. */
799 struct rte_flow_action action;
800 } query; /**< Query arguments. */
804 } list; /**< List arguments. */
807 } isolate; /**< Isolated mode arguments. */
810 } aged; /**< Aged arguments. */
811 } args; /**< Command arguments. */
814 /** Private data for pattern items. */
815 struct parse_item_priv {
816 enum rte_flow_item_type type; /**< Item type. */
817 uint32_t size; /**< Size of item specification structure. */
820 #define PRIV_ITEM(t, s) \
821 (&(const struct parse_item_priv){ \
822 .type = RTE_FLOW_ITEM_TYPE_ ## t, \
826 /** Private data for actions. */
827 struct parse_action_priv {
828 enum rte_flow_action_type type; /**< Action type. */
829 uint32_t size; /**< Size of action configuration structure. */
832 #define PRIV_ACTION(t, s) \
833 (&(const struct parse_action_priv){ \
834 .type = RTE_FLOW_ACTION_TYPE_ ## t, \
838 static const enum index next_sa_create_attr[] = {
839 SHARED_ACTION_CREATE_ID,
840 SHARED_ACTION_INGRESS,
841 SHARED_ACTION_EGRESS,
842 SHARED_ACTION_TRANSFER,
847 static const enum index next_sa_subcmd[] = {
848 SHARED_ACTION_CREATE,
849 SHARED_ACTION_UPDATE,
850 SHARED_ACTION_DESTROY,
855 static const enum index next_vc_attr[] = {
867 static const enum index next_destroy_attr[] = {
873 static const enum index next_dump_attr[] = {
879 static const enum index next_list_attr[] = {
885 static const enum index next_aged_attr[] = {
891 static const enum index next_sa_destroy_attr[] = {
892 SHARED_ACTION_DESTROY_ID,
897 static const enum index item_param[] = {
906 static const enum index next_item[] = {
943 ITEM_ICMP6_ND_OPT_SLA_ETH,
944 ITEM_ICMP6_ND_OPT_TLA_ETH,
963 static const enum index item_fuzzy[] = {
969 static const enum index item_any[] = {
975 static const enum index item_vf[] = {
981 static const enum index item_phy_port[] = {
987 static const enum index item_port_id[] = {
993 static const enum index item_mark[] = {
999 static const enum index item_raw[] = {
1009 static const enum index item_eth[] = {
1018 static const enum index item_vlan[] = {
1023 ITEM_VLAN_INNER_TYPE,
1024 ITEM_VLAN_HAS_MORE_VLAN,
1029 static const enum index item_ipv4[] = {
1031 ITEM_IPV4_FRAGMENT_OFFSET,
1040 static const enum index item_ipv6[] = {
1047 ITEM_IPV6_HAS_FRAG_EXT,
1052 static const enum index item_icmp[] = {
1061 static const enum index item_udp[] = {
1068 static const enum index item_tcp[] = {
1076 static const enum index item_sctp[] = {
1085 static const enum index item_vxlan[] = {
1091 static const enum index item_e_tag[] = {
1092 ITEM_E_TAG_GRP_ECID_B,
1097 static const enum index item_nvgre[] = {
1103 static const enum index item_mpls[] = {
1111 static const enum index item_gre[] = {
1113 ITEM_GRE_C_RSVD0_VER,
1121 static const enum index item_gre_key[] = {
1127 static const enum index item_gtp[] = {
1135 static const enum index item_geneve[] = {
1143 static const enum index item_vxlan_gpe[] = {
1149 static const enum index item_arp_eth_ipv4[] = {
1150 ITEM_ARP_ETH_IPV4_SHA,
1151 ITEM_ARP_ETH_IPV4_SPA,
1152 ITEM_ARP_ETH_IPV4_THA,
1153 ITEM_ARP_ETH_IPV4_TPA,
1158 static const enum index item_ipv6_ext[] = {
1159 ITEM_IPV6_EXT_NEXT_HDR,
1164 static const enum index item_ipv6_frag_ext[] = {
1165 ITEM_IPV6_FRAG_EXT_NEXT_HDR,
1166 ITEM_IPV6_FRAG_EXT_FRAG_DATA,
1171 static const enum index item_icmp6[] = {
1178 static const enum index item_icmp6_nd_ns[] = {
1179 ITEM_ICMP6_ND_NS_TARGET_ADDR,
1184 static const enum index item_icmp6_nd_na[] = {
1185 ITEM_ICMP6_ND_NA_TARGET_ADDR,
1190 static const enum index item_icmp6_nd_opt[] = {
1191 ITEM_ICMP6_ND_OPT_TYPE,
1196 static const enum index item_icmp6_nd_opt_sla_eth[] = {
1197 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
1202 static const enum index item_icmp6_nd_opt_tla_eth[] = {
1203 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
1208 static const enum index item_meta[] = {
1214 static const enum index item_gtp_psc[] = {
1221 static const enum index item_pppoed[] = {
1227 static const enum index item_pppoes[] = {
1233 static const enum index item_pppoe_proto_id[] = {
1238 static const enum index item_higig2[] = {
1239 ITEM_HIGIG2_CLASSIFICATION,
1245 static const enum index item_esp[] = {
1251 static const enum index item_ah[] = {
1257 static const enum index item_pfcp[] = {
1264 static const enum index next_set_raw[] = {
1270 static const enum index item_tag[] = {
1277 static const enum index item_l2tpv3oip[] = {
1278 ITEM_L2TPV3OIP_SESSION_ID,
1283 static const enum index item_ecpri[] = {
1289 static const enum index item_ecpri_common[] = {
1290 ITEM_ECPRI_COMMON_TYPE,
1294 static const enum index item_ecpri_common_type[] = {
1295 ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
1296 ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
1297 ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
1301 static const enum index item_geneve_opt[] = {
1302 ITEM_GENEVE_OPT_CLASS,
1303 ITEM_GENEVE_OPT_TYPE,
1304 ITEM_GENEVE_OPT_LENGTH,
1305 ITEM_GENEVE_OPT_DATA,
1310 static const enum index next_action[] = {
1326 ACTION_OF_SET_MPLS_TTL,
1327 ACTION_OF_DEC_MPLS_TTL,
1328 ACTION_OF_SET_NW_TTL,
1329 ACTION_OF_DEC_NW_TTL,
1330 ACTION_OF_COPY_TTL_OUT,
1331 ACTION_OF_COPY_TTL_IN,
1333 ACTION_OF_PUSH_VLAN,
1334 ACTION_OF_SET_VLAN_VID,
1335 ACTION_OF_SET_VLAN_PCP,
1337 ACTION_OF_PUSH_MPLS,
1344 ACTION_MPLSOGRE_ENCAP,
1345 ACTION_MPLSOGRE_DECAP,
1346 ACTION_MPLSOUDP_ENCAP,
1347 ACTION_MPLSOUDP_DECAP,
1348 ACTION_SET_IPV4_SRC,
1349 ACTION_SET_IPV4_DST,
1350 ACTION_SET_IPV6_SRC,
1351 ACTION_SET_IPV6_DST,
1367 ACTION_SET_IPV4_DSCP,
1368 ACTION_SET_IPV6_DSCP,
1372 ACTION_MODIFY_FIELD,
1376 static const enum index action_mark[] = {
1382 static const enum index action_queue[] = {
1388 static const enum index action_count[] = {
1390 ACTION_COUNT_SHARED,
1395 static const enum index action_rss[] = {
1406 static const enum index action_vf[] = {
1413 static const enum index action_phy_port[] = {
1414 ACTION_PHY_PORT_ORIGINAL,
1415 ACTION_PHY_PORT_INDEX,
1420 static const enum index action_port_id[] = {
1421 ACTION_PORT_ID_ORIGINAL,
1427 static const enum index action_meter[] = {
1433 static const enum index action_of_set_mpls_ttl[] = {
1434 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
1439 static const enum index action_of_set_nw_ttl[] = {
1440 ACTION_OF_SET_NW_TTL_NW_TTL,
1445 static const enum index action_of_push_vlan[] = {
1446 ACTION_OF_PUSH_VLAN_ETHERTYPE,
1451 static const enum index action_of_set_vlan_vid[] = {
1452 ACTION_OF_SET_VLAN_VID_VLAN_VID,
1457 static const enum index action_of_set_vlan_pcp[] = {
1458 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
1463 static const enum index action_of_pop_mpls[] = {
1464 ACTION_OF_POP_MPLS_ETHERTYPE,
1469 static const enum index action_of_push_mpls[] = {
1470 ACTION_OF_PUSH_MPLS_ETHERTYPE,
1475 static const enum index action_set_ipv4_src[] = {
1476 ACTION_SET_IPV4_SRC_IPV4_SRC,
1481 static const enum index action_set_mac_src[] = {
1482 ACTION_SET_MAC_SRC_MAC_SRC,
1487 static const enum index action_set_ipv4_dst[] = {
1488 ACTION_SET_IPV4_DST_IPV4_DST,
1493 static const enum index action_set_ipv6_src[] = {
1494 ACTION_SET_IPV6_SRC_IPV6_SRC,
1499 static const enum index action_set_ipv6_dst[] = {
1500 ACTION_SET_IPV6_DST_IPV6_DST,
1505 static const enum index action_set_tp_src[] = {
1506 ACTION_SET_TP_SRC_TP_SRC,
1511 static const enum index action_set_tp_dst[] = {
1512 ACTION_SET_TP_DST_TP_DST,
1517 static const enum index action_set_ttl[] = {
1523 static const enum index action_jump[] = {
1529 static const enum index action_set_mac_dst[] = {
1530 ACTION_SET_MAC_DST_MAC_DST,
1535 static const enum index action_inc_tcp_seq[] = {
1536 ACTION_INC_TCP_SEQ_VALUE,
1541 static const enum index action_dec_tcp_seq[] = {
1542 ACTION_DEC_TCP_SEQ_VALUE,
1547 static const enum index action_inc_tcp_ack[] = {
1548 ACTION_INC_TCP_ACK_VALUE,
1553 static const enum index action_dec_tcp_ack[] = {
1554 ACTION_DEC_TCP_ACK_VALUE,
1559 static const enum index action_raw_encap[] = {
1560 ACTION_RAW_ENCAP_INDEX,
1565 static const enum index action_raw_decap[] = {
1566 ACTION_RAW_DECAP_INDEX,
1571 static const enum index action_set_tag[] = {
1572 ACTION_SET_TAG_DATA,
1573 ACTION_SET_TAG_INDEX,
1574 ACTION_SET_TAG_MASK,
1579 static const enum index action_set_meta[] = {
1580 ACTION_SET_META_DATA,
1581 ACTION_SET_META_MASK,
1586 static const enum index action_set_ipv4_dscp[] = {
1587 ACTION_SET_IPV4_DSCP_VALUE,
1592 static const enum index action_set_ipv6_dscp[] = {
1593 ACTION_SET_IPV6_DSCP_VALUE,
1598 static const enum index action_age[] = {
1605 static const enum index action_sample[] = {
1607 ACTION_SAMPLE_RATIO,
1608 ACTION_SAMPLE_INDEX,
1613 static const enum index next_action_sample[] = {
1626 static const enum index action_modify_field_dst[] = {
1627 ACTION_MODIFY_FIELD_DST_LEVEL,
1628 ACTION_MODIFY_FIELD_DST_OFFSET,
1629 ACTION_MODIFY_FIELD_SRC_TYPE,
1633 static const enum index action_modify_field_src[] = {
1634 ACTION_MODIFY_FIELD_SRC_LEVEL,
1635 ACTION_MODIFY_FIELD_SRC_OFFSET,
1636 ACTION_MODIFY_FIELD_SRC_VALUE,
1637 ACTION_MODIFY_FIELD_WIDTH,
1641 static int parse_set_raw_encap_decap(struct context *, const struct token *,
1642 const char *, unsigned int,
1643 void *, unsigned int);
1644 static int parse_set_sample_action(struct context *, const struct token *,
1645 const char *, unsigned int,
1646 void *, unsigned int);
1647 static int parse_set_init(struct context *, const struct token *,
1648 const char *, unsigned int,
1649 void *, unsigned int);
1650 static int parse_init(struct context *, const struct token *,
1651 const char *, unsigned int,
1652 void *, unsigned int);
1653 static int parse_vc(struct context *, const struct token *,
1654 const char *, unsigned int,
1655 void *, unsigned int);
1656 static int parse_vc_spec(struct context *, const struct token *,
1657 const char *, unsigned int, void *, unsigned int);
1658 static int parse_vc_conf(struct context *, const struct token *,
1659 const char *, unsigned int, void *, unsigned int);
1660 static int parse_vc_item_ecpri_type(struct context *, const struct token *,
1661 const char *, unsigned int,
1662 void *, unsigned int);
1663 static int parse_vc_action_rss(struct context *, const struct token *,
1664 const char *, unsigned int, void *,
1666 static int parse_vc_action_rss_func(struct context *, const struct token *,
1667 const char *, unsigned int, void *,
1669 static int parse_vc_action_rss_type(struct context *, const struct token *,
1670 const char *, unsigned int, void *,
1672 static int parse_vc_action_rss_queue(struct context *, const struct token *,
1673 const char *, unsigned int, void *,
1675 static int parse_vc_action_vxlan_encap(struct context *, const struct token *,
1676 const char *, unsigned int, void *,
1678 static int parse_vc_action_nvgre_encap(struct context *, const struct token *,
1679 const char *, unsigned int, void *,
1681 static int parse_vc_action_l2_encap(struct context *, const struct token *,
1682 const char *, unsigned int, void *,
1684 static int parse_vc_action_l2_decap(struct context *, const struct token *,
1685 const char *, unsigned int, void *,
1687 static int parse_vc_action_mplsogre_encap(struct context *,
1688 const struct token *, const char *,
1689 unsigned int, void *, unsigned int);
1690 static int parse_vc_action_mplsogre_decap(struct context *,
1691 const struct token *, const char *,
1692 unsigned int, void *, unsigned int);
1693 static int parse_vc_action_mplsoudp_encap(struct context *,
1694 const struct token *, const char *,
1695 unsigned int, void *, unsigned int);
1696 static int parse_vc_action_mplsoudp_decap(struct context *,
1697 const struct token *, const char *,
1698 unsigned int, void *, unsigned int);
1699 static int parse_vc_action_raw_encap(struct context *,
1700 const struct token *, const char *,
1701 unsigned int, void *, unsigned int);
1702 static int parse_vc_action_raw_decap(struct context *,
1703 const struct token *, const char *,
1704 unsigned int, void *, unsigned int);
1705 static int parse_vc_action_raw_encap_index(struct context *,
1706 const struct token *, const char *,
1707 unsigned int, void *, unsigned int);
1708 static int parse_vc_action_raw_decap_index(struct context *,
1709 const struct token *, const char *,
1710 unsigned int, void *, unsigned int);
1711 static int parse_vc_action_set_meta(struct context *ctx,
1712 const struct token *token, const char *str,
1713 unsigned int len, void *buf,
1715 static int parse_vc_action_sample(struct context *ctx,
1716 const struct token *token, const char *str,
1717 unsigned int len, void *buf,
1720 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
1721 const char *str, unsigned int len, void *buf,
1724 parse_vc_modify_field_op(struct context *ctx, const struct token *token,
1725 const char *str, unsigned int len, void *buf,
1728 parse_vc_modify_field_id(struct context *ctx, const struct token *token,
1729 const char *str, unsigned int len, void *buf,
1731 static int parse_destroy(struct context *, const struct token *,
1732 const char *, unsigned int,
1733 void *, unsigned int);
1734 static int parse_flush(struct context *, const struct token *,
1735 const char *, unsigned int,
1736 void *, unsigned int);
1737 static int parse_dump(struct context *, const struct token *,
1738 const char *, unsigned int,
1739 void *, unsigned int);
1740 static int parse_query(struct context *, const struct token *,
1741 const char *, unsigned int,
1742 void *, unsigned int);
1743 static int parse_action(struct context *, const struct token *,
1744 const char *, unsigned int,
1745 void *, unsigned int);
1746 static int parse_list(struct context *, const struct token *,
1747 const char *, unsigned int,
1748 void *, unsigned int);
1749 static int parse_aged(struct context *, const struct token *,
1750 const char *, unsigned int,
1751 void *, unsigned int);
1752 static int parse_isolate(struct context *, const struct token *,
1753 const char *, unsigned int,
1754 void *, unsigned int);
1755 static int parse_tunnel(struct context *, const struct token *,
1756 const char *, unsigned int,
1757 void *, unsigned int);
1758 static int parse_int(struct context *, const struct token *,
1759 const char *, unsigned int,
1760 void *, unsigned int);
1761 static int parse_prefix(struct context *, const struct token *,
1762 const char *, unsigned int,
1763 void *, unsigned int);
1764 static int parse_boolean(struct context *, const struct token *,
1765 const char *, unsigned int,
1766 void *, unsigned int);
1767 static int parse_string(struct context *, const struct token *,
1768 const char *, unsigned int,
1769 void *, unsigned int);
1770 static int parse_hex(struct context *ctx, const struct token *token,
1771 const char *str, unsigned int len,
1772 void *buf, unsigned int size);
1773 static int parse_string0(struct context *, const struct token *,
1774 const char *, unsigned int,
1775 void *, unsigned int);
1776 static int parse_mac_addr(struct context *, const struct token *,
1777 const char *, unsigned int,
1778 void *, unsigned int);
1779 static int parse_ipv4_addr(struct context *, const struct token *,
1780 const char *, unsigned int,
1781 void *, unsigned int);
1782 static int parse_ipv6_addr(struct context *, const struct token *,
1783 const char *, unsigned int,
1784 void *, unsigned int);
1785 static int parse_port(struct context *, const struct token *,
1786 const char *, unsigned int,
1787 void *, unsigned int);
1788 static int parse_sa(struct context *, const struct token *,
1789 const char *, unsigned int,
1790 void *, unsigned int);
1791 static int parse_sa_destroy(struct context *ctx, const struct token *token,
1792 const char *str, unsigned int len,
1793 void *buf, unsigned int size);
1794 static int parse_sa_id2ptr(struct context *ctx, const struct token *token,
1795 const char *str, unsigned int len, void *buf,
1797 static int comp_none(struct context *, const struct token *,
1798 unsigned int, char *, unsigned int);
1799 static int comp_boolean(struct context *, const struct token *,
1800 unsigned int, char *, unsigned int);
1801 static int comp_action(struct context *, const struct token *,
1802 unsigned int, char *, unsigned int);
1803 static int comp_port(struct context *, const struct token *,
1804 unsigned int, char *, unsigned int);
1805 static int comp_rule_id(struct context *, const struct token *,
1806 unsigned int, char *, unsigned int);
1807 static int comp_vc_action_rss_type(struct context *, const struct token *,
1808 unsigned int, char *, unsigned int);
1809 static int comp_vc_action_rss_queue(struct context *, const struct token *,
1810 unsigned int, char *, unsigned int);
1811 static int comp_set_raw_index(struct context *, const struct token *,
1812 unsigned int, char *, unsigned int);
1813 static int comp_set_sample_index(struct context *, const struct token *,
1814 unsigned int, char *, unsigned int);
1815 static int comp_set_modify_field_op(struct context *, const struct token *,
1816 unsigned int, char *, unsigned int);
1817 static int comp_set_modify_field_id(struct context *, const struct token *,
1818 unsigned int, char *, unsigned int);
1820 /** Token definitions. */
1821 static const struct token token_list[] = {
1822 /* Special tokens. */
1825 .help = "null entry, abused as the entry point",
1826 .next = NEXT(NEXT_ENTRY(FLOW)),
1831 .help = "command may end here",
1834 .name = "START_SET",
1835 .help = "null entry, abused as the entry point for set",
1836 .next = NEXT(NEXT_ENTRY(SET)),
1841 .help = "set command may end here",
1843 /* Common tokens. */
1847 .help = "integer value",
1852 .name = "{unsigned}",
1854 .help = "unsigned integer value",
1861 .help = "prefix length for bit-mask",
1862 .call = parse_prefix,
1866 .name = "{boolean}",
1868 .help = "any boolean value",
1869 .call = parse_boolean,
1870 .comp = comp_boolean,
1875 .help = "fixed string",
1876 .call = parse_string,
1882 .help = "fixed string",
1886 .name = "{file path}",
1888 .help = "file path",
1889 .call = parse_string0,
1893 .name = "{MAC address}",
1895 .help = "standard MAC address notation",
1896 .call = parse_mac_addr,
1900 .name = "{IPv4 address}",
1901 .type = "IPV4 ADDRESS",
1902 .help = "standard IPv4 address notation",
1903 .call = parse_ipv4_addr,
1907 .name = "{IPv6 address}",
1908 .type = "IPV6 ADDRESS",
1909 .help = "standard IPv6 address notation",
1910 .call = parse_ipv6_addr,
1914 .name = "{rule id}",
1916 .help = "rule identifier",
1918 .comp = comp_rule_id,
1921 .name = "{port_id}",
1923 .help = "port identifier",
1928 .name = "{group_id}",
1930 .help = "group identifier",
1934 [PRIORITY_LEVEL] = {
1937 .help = "priority level",
1941 [SHARED_ACTION_ID] = {
1942 .name = "{shared_action_id}",
1943 .type = "SHARED_ACTION_ID",
1944 .help = "shared action id",
1948 /* Top-level command. */
1951 .type = "{command} {port_id} [{arg} [...]]",
1952 .help = "manage ingress/egress flow rules",
1953 .next = NEXT(NEXT_ENTRY
1967 /* Top-level command. */
1969 .name = "shared_action",
1970 .type = "{command} {port_id} [{arg} [...]]",
1971 .help = "manage shared actions",
1972 .next = NEXT(next_sa_subcmd, NEXT_ENTRY(PORT_ID)),
1973 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1976 /* Sub-level commands. */
1977 [SHARED_ACTION_CREATE] = {
1979 .help = "create shared action",
1980 .next = NEXT(next_sa_create_attr),
1983 [SHARED_ACTION_UPDATE] = {
1985 .help = "update shared action",
1986 .next = NEXT(NEXT_ENTRY(SHARED_ACTION_SPEC),
1987 NEXT_ENTRY(SHARED_ACTION_ID)),
1988 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
1991 [SHARED_ACTION_DESTROY] = {
1993 .help = "destroy shared action",
1994 .next = NEXT(NEXT_ENTRY(SHARED_ACTION_DESTROY_ID)),
1995 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1996 .call = parse_sa_destroy,
1998 [SHARED_ACTION_QUERY] = {
2000 .help = "query shared action",
2001 .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(SHARED_ACTION_ID)),
2002 .args = ARGS(ARGS_ENTRY(struct buffer, args.sa.action_id)),
2007 .help = "check whether a flow rule can be created",
2008 .next = NEXT(next_vc_attr, NEXT_ENTRY(PORT_ID)),
2009 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2014 .help = "create a flow rule",
2015 .next = NEXT(next_vc_attr, NEXT_ENTRY(PORT_ID)),
2016 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2021 .help = "destroy specific flow rules",
2022 .next = NEXT(NEXT_ENTRY(DESTROY_RULE), NEXT_ENTRY(PORT_ID)),
2023 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2024 .call = parse_destroy,
2028 .help = "destroy all flow rules",
2029 .next = NEXT(NEXT_ENTRY(PORT_ID)),
2030 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2031 .call = parse_flush,
2035 .help = "dump all flow rules to file",
2036 .next = NEXT(next_dump_attr, NEXT_ENTRY(PORT_ID)),
2037 .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file),
2038 ARGS_ENTRY(struct buffer, port)),
2043 .help = "query an existing flow rule",
2044 .next = NEXT(NEXT_ENTRY(QUERY_ACTION),
2045 NEXT_ENTRY(RULE_ID),
2046 NEXT_ENTRY(PORT_ID)),
2047 .args = ARGS(ARGS_ENTRY(struct buffer, args.query.action.type),
2048 ARGS_ENTRY(struct buffer, args.query.rule),
2049 ARGS_ENTRY(struct buffer, port)),
2050 .call = parse_query,
2054 .help = "list existing flow rules",
2055 .next = NEXT(next_list_attr, NEXT_ENTRY(PORT_ID)),
2056 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2061 .help = "list and destroy aged flows",
2062 .next = NEXT(next_aged_attr, NEXT_ENTRY(PORT_ID)),
2063 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2068 .help = "restrict ingress traffic to the defined flow rules",
2069 .next = NEXT(NEXT_ENTRY(BOOLEAN),
2070 NEXT_ENTRY(PORT_ID)),
2071 .args = ARGS(ARGS_ENTRY(struct buffer, args.isolate.set),
2072 ARGS_ENTRY(struct buffer, port)),
2073 .call = parse_isolate,
2077 .help = "new tunnel API",
2078 .next = NEXT(NEXT_ENTRY
2079 (TUNNEL_CREATE, TUNNEL_LIST, TUNNEL_DESTROY)),
2080 .call = parse_tunnel,
2082 /* Tunnel arguments. */
2085 .help = "create new tunnel object",
2086 .next = NEXT(NEXT_ENTRY(TUNNEL_CREATE_TYPE),
2087 NEXT_ENTRY(PORT_ID)),
2088 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2089 .call = parse_tunnel,
2091 [TUNNEL_CREATE_TYPE] = {
2093 .help = "create new tunnel",
2094 .next = NEXT(NEXT_ENTRY(FILE_PATH)),
2095 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, type)),
2096 .call = parse_tunnel,
2098 [TUNNEL_DESTROY] = {
2100 .help = "destroy tunel",
2101 .next = NEXT(NEXT_ENTRY(TUNNEL_DESTROY_ID),
2102 NEXT_ENTRY(PORT_ID)),
2103 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2104 .call = parse_tunnel,
2106 [TUNNEL_DESTROY_ID] = {
2108 .help = "tunnel identifier to testroy",
2109 .next = NEXT(NEXT_ENTRY(UNSIGNED)),
2110 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2111 .call = parse_tunnel,
2115 .help = "list existing tunnels",
2116 .next = NEXT(NEXT_ENTRY(PORT_ID)),
2117 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2118 .call = parse_tunnel,
2120 /* Destroy arguments. */
2123 .help = "specify a rule identifier",
2124 .next = NEXT(next_destroy_attr, NEXT_ENTRY(RULE_ID)),
2125 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.destroy.rule)),
2126 .call = parse_destroy,
2128 /* Query arguments. */
2132 .help = "action to query, must be part of the rule",
2133 .call = parse_action,
2134 .comp = comp_action,
2136 /* List arguments. */
2139 .help = "specify a group",
2140 .next = NEXT(next_list_attr, NEXT_ENTRY(GROUP_ID)),
2141 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.list.group)),
2146 .help = "specify aged flows need be destroyed",
2150 /* Validate/create attributes. */
2153 .help = "specify a group",
2154 .next = NEXT(next_vc_attr, NEXT_ENTRY(GROUP_ID)),
2155 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, group)),
2160 .help = "specify a priority level",
2161 .next = NEXT(next_vc_attr, NEXT_ENTRY(PRIORITY_LEVEL)),
2162 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, priority)),
2167 .help = "affect rule to ingress",
2168 .next = NEXT(next_vc_attr),
2173 .help = "affect rule to egress",
2174 .next = NEXT(next_vc_attr),
2179 .help = "apply rule directly to endpoints found in pattern",
2180 .next = NEXT(next_vc_attr),
2184 .name = "tunnel_set",
2185 .help = "tunnel steer rule",
2186 .next = NEXT(next_vc_attr, NEXT_ENTRY(UNSIGNED)),
2187 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2191 .name = "tunnel_match",
2192 .help = "tunnel match rule",
2193 .next = NEXT(next_vc_attr, NEXT_ENTRY(UNSIGNED)),
2194 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2197 /* Validate/create pattern. */
2200 .help = "submit a list of pattern items",
2201 .next = NEXT(next_item),
2206 .help = "match value perfectly (with full bit-mask)",
2207 .call = parse_vc_spec,
2209 [ITEM_PARAM_SPEC] = {
2211 .help = "match value according to configured bit-mask",
2212 .call = parse_vc_spec,
2214 [ITEM_PARAM_LAST] = {
2216 .help = "specify upper bound to establish a range",
2217 .call = parse_vc_spec,
2219 [ITEM_PARAM_MASK] = {
2221 .help = "specify bit-mask with relevant bits set to one",
2222 .call = parse_vc_spec,
2224 [ITEM_PARAM_PREFIX] = {
2226 .help = "generate bit-mask from a prefix length",
2227 .call = parse_vc_spec,
2231 .help = "specify next pattern item",
2232 .next = NEXT(next_item),
2236 .help = "end list of pattern items",
2237 .priv = PRIV_ITEM(END, 0),
2238 .next = NEXT(NEXT_ENTRY(ACTIONS)),
2243 .help = "no-op pattern item",
2244 .priv = PRIV_ITEM(VOID, 0),
2245 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2250 .help = "perform actions when pattern does not match",
2251 .priv = PRIV_ITEM(INVERT, 0),
2252 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2257 .help = "match any protocol for the current layer",
2258 .priv = PRIV_ITEM(ANY, sizeof(struct rte_flow_item_any)),
2259 .next = NEXT(item_any),
2264 .help = "number of layers covered",
2265 .next = NEXT(item_any, NEXT_ENTRY(UNSIGNED), item_param),
2266 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_any, num)),
2270 .help = "match traffic from/to the physical function",
2271 .priv = PRIV_ITEM(PF, 0),
2272 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2277 .help = "match traffic from/to a virtual function ID",
2278 .priv = PRIV_ITEM(VF, sizeof(struct rte_flow_item_vf)),
2279 .next = NEXT(item_vf),
2285 .next = NEXT(item_vf, NEXT_ENTRY(UNSIGNED), item_param),
2286 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_vf, id)),
2290 .help = "match traffic from/to a specific physical port",
2291 .priv = PRIV_ITEM(PHY_PORT,
2292 sizeof(struct rte_flow_item_phy_port)),
2293 .next = NEXT(item_phy_port),
2296 [ITEM_PHY_PORT_INDEX] = {
2298 .help = "physical port index",
2299 .next = NEXT(item_phy_port, NEXT_ENTRY(UNSIGNED), item_param),
2300 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_phy_port, index)),
2304 .help = "match traffic from/to a given DPDK port ID",
2305 .priv = PRIV_ITEM(PORT_ID,
2306 sizeof(struct rte_flow_item_port_id)),
2307 .next = NEXT(item_port_id),
2310 [ITEM_PORT_ID_ID] = {
2312 .help = "DPDK port ID",
2313 .next = NEXT(item_port_id, NEXT_ENTRY(UNSIGNED), item_param),
2314 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port_id, id)),
2318 .help = "match traffic against value set in previously matched rule",
2319 .priv = PRIV_ITEM(MARK, sizeof(struct rte_flow_item_mark)),
2320 .next = NEXT(item_mark),
2325 .help = "Integer value to match against",
2326 .next = NEXT(item_mark, NEXT_ENTRY(UNSIGNED), item_param),
2327 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_mark, id)),
2331 .help = "match an arbitrary byte string",
2332 .priv = PRIV_ITEM(RAW, ITEM_RAW_SIZE),
2333 .next = NEXT(item_raw),
2336 [ITEM_RAW_RELATIVE] = {
2338 .help = "look for pattern after the previous item",
2339 .next = NEXT(item_raw, NEXT_ENTRY(BOOLEAN), item_param),
2340 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
2343 [ITEM_RAW_SEARCH] = {
2345 .help = "search pattern from offset (see also limit)",
2346 .next = NEXT(item_raw, NEXT_ENTRY(BOOLEAN), item_param),
2347 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
2350 [ITEM_RAW_OFFSET] = {
2352 .help = "absolute or relative offset for pattern",
2353 .next = NEXT(item_raw, NEXT_ENTRY(INTEGER), item_param),
2354 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, offset)),
2356 [ITEM_RAW_LIMIT] = {
2358 .help = "search area limit for start of pattern",
2359 .next = NEXT(item_raw, NEXT_ENTRY(UNSIGNED), item_param),
2360 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, limit)),
2362 [ITEM_RAW_PATTERN] = {
2364 .help = "byte string to look for",
2365 .next = NEXT(item_raw,
2367 NEXT_ENTRY(ITEM_PARAM_IS,
2370 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern),
2371 ARGS_ENTRY(struct rte_flow_item_raw, length),
2372 ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw),
2373 ITEM_RAW_PATTERN_SIZE)),
2377 .help = "match Ethernet header",
2378 .priv = PRIV_ITEM(ETH, sizeof(struct rte_flow_item_eth)),
2379 .next = NEXT(item_eth),
2384 .help = "destination MAC",
2385 .next = NEXT(item_eth, NEXT_ENTRY(MAC_ADDR), item_param),
2386 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, dst)),
2390 .help = "source MAC",
2391 .next = NEXT(item_eth, NEXT_ENTRY(MAC_ADDR), item_param),
2392 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, src)),
2396 .help = "EtherType",
2397 .next = NEXT(item_eth, NEXT_ENTRY(UNSIGNED), item_param),
2398 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, type)),
2400 [ITEM_ETH_HAS_VLAN] = {
2402 .help = "packet header contains VLAN",
2403 .next = NEXT(item_eth, NEXT_ENTRY(UNSIGNED), item_param),
2404 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_eth,
2409 .help = "match 802.1Q/ad VLAN tag",
2410 .priv = PRIV_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)),
2411 .next = NEXT(item_vlan),
2416 .help = "tag control information",
2417 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2418 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, tci)),
2422 .help = "priority code point",
2423 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2424 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2429 .help = "drop eligible indicator",
2430 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2431 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2436 .help = "VLAN identifier",
2437 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2438 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2441 [ITEM_VLAN_INNER_TYPE] = {
2442 .name = "inner_type",
2443 .help = "inner EtherType",
2444 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2445 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan,
2448 [ITEM_VLAN_HAS_MORE_VLAN] = {
2449 .name = "has_more_vlan",
2450 .help = "packet header contains another VLAN",
2451 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2452 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vlan,
2457 .help = "match IPv4 header",
2458 .priv = PRIV_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)),
2459 .next = NEXT(item_ipv4),
2464 .help = "type of service",
2465 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2466 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2467 hdr.type_of_service)),
2469 [ITEM_IPV4_FRAGMENT_OFFSET] = {
2470 .name = "fragment_offset",
2471 .help = "fragmentation flags and fragment offset",
2472 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2473 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2474 hdr.fragment_offset)),
2478 .help = "time to live",
2479 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2480 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2483 [ITEM_IPV4_PROTO] = {
2485 .help = "next protocol ID",
2486 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2487 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2488 hdr.next_proto_id)),
2492 .help = "source address",
2493 .next = NEXT(item_ipv4, NEXT_ENTRY(IPV4_ADDR), item_param),
2494 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2499 .help = "destination address",
2500 .next = NEXT(item_ipv4, NEXT_ENTRY(IPV4_ADDR), item_param),
2501 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2506 .help = "match IPv6 header",
2507 .priv = PRIV_ITEM(IPV6, sizeof(struct rte_flow_item_ipv6)),
2508 .next = NEXT(item_ipv6),
2513 .help = "traffic class",
2514 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2515 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2517 "\x0f\xf0\x00\x00")),
2519 [ITEM_IPV6_FLOW] = {
2521 .help = "flow label",
2522 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2523 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2525 "\x00\x0f\xff\xff")),
2527 [ITEM_IPV6_PROTO] = {
2529 .help = "protocol (next header)",
2530 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2531 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2536 .help = "hop limit",
2537 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2538 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2543 .help = "source address",
2544 .next = NEXT(item_ipv6, NEXT_ENTRY(IPV6_ADDR), item_param),
2545 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2550 .help = "destination address",
2551 .next = NEXT(item_ipv6, NEXT_ENTRY(IPV6_ADDR), item_param),
2552 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2555 [ITEM_IPV6_HAS_FRAG_EXT] = {
2556 .name = "has_frag_ext",
2557 .help = "fragment packet attribute",
2558 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2559 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_ipv6,
2564 .help = "match ICMP header",
2565 .priv = PRIV_ITEM(ICMP, sizeof(struct rte_flow_item_icmp)),
2566 .next = NEXT(item_icmp),
2569 [ITEM_ICMP_TYPE] = {
2571 .help = "ICMP packet type",
2572 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2573 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2576 [ITEM_ICMP_CODE] = {
2578 .help = "ICMP packet code",
2579 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2580 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2583 [ITEM_ICMP_IDENT] = {
2585 .help = "ICMP packet identifier",
2586 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2587 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2592 .help = "ICMP packet sequence number",
2593 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2594 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2599 .help = "match UDP header",
2600 .priv = PRIV_ITEM(UDP, sizeof(struct rte_flow_item_udp)),
2601 .next = NEXT(item_udp),
2606 .help = "UDP source port",
2607 .next = NEXT(item_udp, NEXT_ENTRY(UNSIGNED), item_param),
2608 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2613 .help = "UDP destination port",
2614 .next = NEXT(item_udp, NEXT_ENTRY(UNSIGNED), item_param),
2615 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2620 .help = "match TCP header",
2621 .priv = PRIV_ITEM(TCP, sizeof(struct rte_flow_item_tcp)),
2622 .next = NEXT(item_tcp),
2627 .help = "TCP source port",
2628 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2629 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2634 .help = "TCP destination port",
2635 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2636 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2639 [ITEM_TCP_FLAGS] = {
2641 .help = "TCP flags",
2642 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2643 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2648 .help = "match SCTP header",
2649 .priv = PRIV_ITEM(SCTP, sizeof(struct rte_flow_item_sctp)),
2650 .next = NEXT(item_sctp),
2655 .help = "SCTP source port",
2656 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2657 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2662 .help = "SCTP destination port",
2663 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2664 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2669 .help = "validation tag",
2670 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2671 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2674 [ITEM_SCTP_CKSUM] = {
2677 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2678 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2683 .help = "match VXLAN header",
2684 .priv = PRIV_ITEM(VXLAN, sizeof(struct rte_flow_item_vxlan)),
2685 .next = NEXT(item_vxlan),
2688 [ITEM_VXLAN_VNI] = {
2690 .help = "VXLAN identifier",
2691 .next = NEXT(item_vxlan, NEXT_ENTRY(UNSIGNED), item_param),
2692 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan, vni)),
2696 .help = "match E-Tag header",
2697 .priv = PRIV_ITEM(E_TAG, sizeof(struct rte_flow_item_e_tag)),
2698 .next = NEXT(item_e_tag),
2701 [ITEM_E_TAG_GRP_ECID_B] = {
2702 .name = "grp_ecid_b",
2703 .help = "GRP and E-CID base",
2704 .next = NEXT(item_e_tag, NEXT_ENTRY(UNSIGNED), item_param),
2705 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_e_tag,
2711 .help = "match NVGRE header",
2712 .priv = PRIV_ITEM(NVGRE, sizeof(struct rte_flow_item_nvgre)),
2713 .next = NEXT(item_nvgre),
2716 [ITEM_NVGRE_TNI] = {
2718 .help = "virtual subnet ID",
2719 .next = NEXT(item_nvgre, NEXT_ENTRY(UNSIGNED), item_param),
2720 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_nvgre, tni)),
2724 .help = "match MPLS header",
2725 .priv = PRIV_ITEM(MPLS, sizeof(struct rte_flow_item_mpls)),
2726 .next = NEXT(item_mpls),
2729 [ITEM_MPLS_LABEL] = {
2731 .help = "MPLS label",
2732 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2733 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2739 .help = "MPLS Traffic Class",
2740 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2741 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2747 .help = "MPLS Bottom-of-Stack",
2748 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2749 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2755 .help = "match GRE header",
2756 .priv = PRIV_ITEM(GRE, sizeof(struct rte_flow_item_gre)),
2757 .next = NEXT(item_gre),
2760 [ITEM_GRE_PROTO] = {
2762 .help = "GRE protocol type",
2763 .next = NEXT(item_gre, NEXT_ENTRY(UNSIGNED), item_param),
2764 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2767 [ITEM_GRE_C_RSVD0_VER] = {
2768 .name = "c_rsvd0_ver",
2770 "checksum (1b), undefined (1b), key bit (1b),"
2771 " sequence number (1b), reserved 0 (9b),"
2773 .next = NEXT(item_gre, NEXT_ENTRY(UNSIGNED), item_param),
2774 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2777 [ITEM_GRE_C_BIT] = {
2779 .help = "checksum bit (C)",
2780 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2781 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2783 "\x80\x00\x00\x00")),
2785 [ITEM_GRE_S_BIT] = {
2787 .help = "sequence number bit (S)",
2788 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2789 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2791 "\x10\x00\x00\x00")),
2793 [ITEM_GRE_K_BIT] = {
2795 .help = "key bit (K)",
2796 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2797 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2799 "\x20\x00\x00\x00")),
2803 .help = "fuzzy pattern match, expect faster than default",
2804 .priv = PRIV_ITEM(FUZZY,
2805 sizeof(struct rte_flow_item_fuzzy)),
2806 .next = NEXT(item_fuzzy),
2809 [ITEM_FUZZY_THRESH] = {
2811 .help = "match accuracy threshold",
2812 .next = NEXT(item_fuzzy, NEXT_ENTRY(UNSIGNED), item_param),
2813 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_fuzzy,
2818 .help = "match GTP header",
2819 .priv = PRIV_ITEM(GTP, sizeof(struct rte_flow_item_gtp)),
2820 .next = NEXT(item_gtp),
2823 [ITEM_GTP_FLAGS] = {
2824 .name = "v_pt_rsv_flags",
2825 .help = "GTP flags",
2826 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2827 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp,
2830 [ITEM_GTP_MSG_TYPE] = {
2832 .help = "GTP message type",
2833 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2834 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp, msg_type)),
2838 .help = "tunnel endpoint identifier",
2839 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2840 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp, teid)),
2844 .help = "match GTP header",
2845 .priv = PRIV_ITEM(GTPC, sizeof(struct rte_flow_item_gtp)),
2846 .next = NEXT(item_gtp),
2851 .help = "match GTP header",
2852 .priv = PRIV_ITEM(GTPU, sizeof(struct rte_flow_item_gtp)),
2853 .next = NEXT(item_gtp),
2858 .help = "match GENEVE header",
2859 .priv = PRIV_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)),
2860 .next = NEXT(item_geneve),
2863 [ITEM_GENEVE_VNI] = {
2865 .help = "virtual network identifier",
2866 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2867 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve, vni)),
2869 [ITEM_GENEVE_PROTO] = {
2871 .help = "GENEVE protocol type",
2872 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2873 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve,
2876 [ITEM_GENEVE_OPTLEN] = {
2878 .help = "GENEVE options length in dwords",
2879 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2880 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_geneve,
2881 ver_opt_len_o_c_rsvd0,
2884 [ITEM_VXLAN_GPE] = {
2885 .name = "vxlan-gpe",
2886 .help = "match VXLAN-GPE header",
2887 .priv = PRIV_ITEM(VXLAN_GPE,
2888 sizeof(struct rte_flow_item_vxlan_gpe)),
2889 .next = NEXT(item_vxlan_gpe),
2892 [ITEM_VXLAN_GPE_VNI] = {
2894 .help = "VXLAN-GPE identifier",
2895 .next = NEXT(item_vxlan_gpe, NEXT_ENTRY(UNSIGNED), item_param),
2896 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
2899 [ITEM_ARP_ETH_IPV4] = {
2900 .name = "arp_eth_ipv4",
2901 .help = "match ARP header for Ethernet/IPv4",
2902 .priv = PRIV_ITEM(ARP_ETH_IPV4,
2903 sizeof(struct rte_flow_item_arp_eth_ipv4)),
2904 .next = NEXT(item_arp_eth_ipv4),
2907 [ITEM_ARP_ETH_IPV4_SHA] = {
2909 .help = "sender hardware address",
2910 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(MAC_ADDR),
2912 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2915 [ITEM_ARP_ETH_IPV4_SPA] = {
2917 .help = "sender IPv4 address",
2918 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(IPV4_ADDR),
2920 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2923 [ITEM_ARP_ETH_IPV4_THA] = {
2925 .help = "target hardware address",
2926 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(MAC_ADDR),
2928 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2931 [ITEM_ARP_ETH_IPV4_TPA] = {
2933 .help = "target IPv4 address",
2934 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(IPV4_ADDR),
2936 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2941 .help = "match presence of any IPv6 extension header",
2942 .priv = PRIV_ITEM(IPV6_EXT,
2943 sizeof(struct rte_flow_item_ipv6_ext)),
2944 .next = NEXT(item_ipv6_ext),
2947 [ITEM_IPV6_EXT_NEXT_HDR] = {
2949 .help = "next header",
2950 .next = NEXT(item_ipv6_ext, NEXT_ENTRY(UNSIGNED), item_param),
2951 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_ext,
2954 [ITEM_IPV6_FRAG_EXT] = {
2955 .name = "ipv6_frag_ext",
2956 .help = "match presence of IPv6 fragment extension header",
2957 .priv = PRIV_ITEM(IPV6_FRAG_EXT,
2958 sizeof(struct rte_flow_item_ipv6_frag_ext)),
2959 .next = NEXT(item_ipv6_frag_ext),
2962 [ITEM_IPV6_FRAG_EXT_NEXT_HDR] = {
2964 .help = "next header",
2965 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(UNSIGNED),
2967 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ipv6_frag_ext,
2970 [ITEM_IPV6_FRAG_EXT_FRAG_DATA] = {
2971 .name = "frag_data",
2972 .help = "Fragment flags and offset",
2973 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(UNSIGNED),
2975 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_frag_ext,
2980 .help = "match any ICMPv6 header",
2981 .priv = PRIV_ITEM(ICMP6, sizeof(struct rte_flow_item_icmp6)),
2982 .next = NEXT(item_icmp6),
2985 [ITEM_ICMP6_TYPE] = {
2987 .help = "ICMPv6 type",
2988 .next = NEXT(item_icmp6, NEXT_ENTRY(UNSIGNED), item_param),
2989 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
2992 [ITEM_ICMP6_CODE] = {
2994 .help = "ICMPv6 code",
2995 .next = NEXT(item_icmp6, NEXT_ENTRY(UNSIGNED), item_param),
2996 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
2999 [ITEM_ICMP6_ND_NS] = {
3000 .name = "icmp6_nd_ns",
3001 .help = "match ICMPv6 neighbor discovery solicitation",
3002 .priv = PRIV_ITEM(ICMP6_ND_NS,
3003 sizeof(struct rte_flow_item_icmp6_nd_ns)),
3004 .next = NEXT(item_icmp6_nd_ns),
3007 [ITEM_ICMP6_ND_NS_TARGET_ADDR] = {
3008 .name = "target_addr",
3009 .help = "target address",
3010 .next = NEXT(item_icmp6_nd_ns, NEXT_ENTRY(IPV6_ADDR),
3012 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_ns,
3015 [ITEM_ICMP6_ND_NA] = {
3016 .name = "icmp6_nd_na",
3017 .help = "match ICMPv6 neighbor discovery advertisement",
3018 .priv = PRIV_ITEM(ICMP6_ND_NA,
3019 sizeof(struct rte_flow_item_icmp6_nd_na)),
3020 .next = NEXT(item_icmp6_nd_na),
3023 [ITEM_ICMP6_ND_NA_TARGET_ADDR] = {
3024 .name = "target_addr",
3025 .help = "target address",
3026 .next = NEXT(item_icmp6_nd_na, NEXT_ENTRY(IPV6_ADDR),
3028 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_na,
3031 [ITEM_ICMP6_ND_OPT] = {
3032 .name = "icmp6_nd_opt",
3033 .help = "match presence of any ICMPv6 neighbor discovery"
3035 .priv = PRIV_ITEM(ICMP6_ND_OPT,
3036 sizeof(struct rte_flow_item_icmp6_nd_opt)),
3037 .next = NEXT(item_icmp6_nd_opt),
3040 [ITEM_ICMP6_ND_OPT_TYPE] = {
3042 .help = "ND option type",
3043 .next = NEXT(item_icmp6_nd_opt, NEXT_ENTRY(UNSIGNED),
3045 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_opt,
3048 [ITEM_ICMP6_ND_OPT_SLA_ETH] = {
3049 .name = "icmp6_nd_opt_sla_eth",
3050 .help = "match ICMPv6 neighbor discovery source Ethernet"
3051 " link-layer address option",
3053 (ICMP6_ND_OPT_SLA_ETH,
3054 sizeof(struct rte_flow_item_icmp6_nd_opt_sla_eth)),
3055 .next = NEXT(item_icmp6_nd_opt_sla_eth),
3058 [ITEM_ICMP6_ND_OPT_SLA_ETH_SLA] = {
3060 .help = "source Ethernet LLA",
3061 .next = NEXT(item_icmp6_nd_opt_sla_eth, NEXT_ENTRY(MAC_ADDR),
3063 .args = ARGS(ARGS_ENTRY_HTON
3064 (struct rte_flow_item_icmp6_nd_opt_sla_eth, sla)),
3066 [ITEM_ICMP6_ND_OPT_TLA_ETH] = {
3067 .name = "icmp6_nd_opt_tla_eth",
3068 .help = "match ICMPv6 neighbor discovery target Ethernet"
3069 " link-layer address option",
3071 (ICMP6_ND_OPT_TLA_ETH,
3072 sizeof(struct rte_flow_item_icmp6_nd_opt_tla_eth)),
3073 .next = NEXT(item_icmp6_nd_opt_tla_eth),
3076 [ITEM_ICMP6_ND_OPT_TLA_ETH_TLA] = {
3078 .help = "target Ethernet LLA",
3079 .next = NEXT(item_icmp6_nd_opt_tla_eth, NEXT_ENTRY(MAC_ADDR),
3081 .args = ARGS(ARGS_ENTRY_HTON
3082 (struct rte_flow_item_icmp6_nd_opt_tla_eth, tla)),
3086 .help = "match metadata header",
3087 .priv = PRIV_ITEM(META, sizeof(struct rte_flow_item_meta)),
3088 .next = NEXT(item_meta),
3091 [ITEM_META_DATA] = {
3093 .help = "metadata value",
3094 .next = NEXT(item_meta, NEXT_ENTRY(UNSIGNED), item_param),
3095 .args = ARGS(ARGS_ENTRY_MASK(struct rte_flow_item_meta,
3096 data, "\xff\xff\xff\xff")),
3100 .help = "match GRE key",
3101 .priv = PRIV_ITEM(GRE_KEY, sizeof(rte_be32_t)),
3102 .next = NEXT(item_gre_key),
3105 [ITEM_GRE_KEY_VALUE] = {
3107 .help = "key value",
3108 .next = NEXT(item_gre_key, NEXT_ENTRY(UNSIGNED), item_param),
3109 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3113 .help = "match GTP extension header with type 0x85",
3114 .priv = PRIV_ITEM(GTP_PSC,
3115 sizeof(struct rte_flow_item_gtp_psc)),
3116 .next = NEXT(item_gtp_psc),
3119 [ITEM_GTP_PSC_QFI] = {
3121 .help = "QoS flow identifier",
3122 .next = NEXT(item_gtp_psc, NEXT_ENTRY(UNSIGNED), item_param),
3123 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
3126 [ITEM_GTP_PSC_PDU_T] = {
3129 .next = NEXT(item_gtp_psc, NEXT_ENTRY(UNSIGNED), item_param),
3130 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
3135 .help = "match PPPoE session header",
3136 .priv = PRIV_ITEM(PPPOES, sizeof(struct rte_flow_item_pppoe)),
3137 .next = NEXT(item_pppoes),
3142 .help = "match PPPoE discovery header",
3143 .priv = PRIV_ITEM(PPPOED, sizeof(struct rte_flow_item_pppoe)),
3144 .next = NEXT(item_pppoed),
3147 [ITEM_PPPOE_SEID] = {
3149 .help = "session identifier",
3150 .next = NEXT(item_pppoes, NEXT_ENTRY(UNSIGNED), item_param),
3151 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pppoe,
3154 [ITEM_PPPOE_PROTO_ID] = {
3155 .name = "pppoe_proto_id",
3156 .help = "match PPPoE session protocol identifier",
3157 .priv = PRIV_ITEM(PPPOE_PROTO_ID,
3158 sizeof(struct rte_flow_item_pppoe_proto_id)),
3159 .next = NEXT(item_pppoe_proto_id, NEXT_ENTRY(UNSIGNED),
3161 .args = ARGS(ARGS_ENTRY_HTON
3162 (struct rte_flow_item_pppoe_proto_id, proto_id)),
3167 .help = "matches higig2 header",
3168 .priv = PRIV_ITEM(HIGIG2,
3169 sizeof(struct rte_flow_item_higig2_hdr)),
3170 .next = NEXT(item_higig2),
3173 [ITEM_HIGIG2_CLASSIFICATION] = {
3174 .name = "classification",
3175 .help = "matches classification of higig2 header",
3176 .next = NEXT(item_higig2, NEXT_ENTRY(UNSIGNED), item_param),
3177 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
3178 hdr.ppt1.classification)),
3180 [ITEM_HIGIG2_VID] = {
3182 .help = "matches vid of higig2 header",
3183 .next = NEXT(item_higig2, NEXT_ENTRY(UNSIGNED), item_param),
3184 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
3189 .help = "match tag value",
3190 .priv = PRIV_ITEM(TAG, sizeof(struct rte_flow_item_tag)),
3191 .next = NEXT(item_tag),
3196 .help = "tag value to match",
3197 .next = NEXT(item_tag, NEXT_ENTRY(UNSIGNED), item_param),
3198 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, data)),
3200 [ITEM_TAG_INDEX] = {
3202 .help = "index of tag array to match",
3203 .next = NEXT(item_tag, NEXT_ENTRY(UNSIGNED),
3204 NEXT_ENTRY(ITEM_PARAM_IS)),
3205 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, index)),
3207 [ITEM_L2TPV3OIP] = {
3208 .name = "l2tpv3oip",
3209 .help = "match L2TPv3 over IP header",
3210 .priv = PRIV_ITEM(L2TPV3OIP,
3211 sizeof(struct rte_flow_item_l2tpv3oip)),
3212 .next = NEXT(item_l2tpv3oip),
3215 [ITEM_L2TPV3OIP_SESSION_ID] = {
3216 .name = "session_id",
3217 .help = "session identifier",
3218 .next = NEXT(item_l2tpv3oip, NEXT_ENTRY(UNSIGNED), item_param),
3219 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv3oip,
3224 .help = "match ESP header",
3225 .priv = PRIV_ITEM(ESP, sizeof(struct rte_flow_item_esp)),
3226 .next = NEXT(item_esp),
3231 .help = "security policy index",
3232 .next = NEXT(item_esp, NEXT_ENTRY(UNSIGNED), item_param),
3233 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_esp,
3238 .help = "match AH header",
3239 .priv = PRIV_ITEM(AH, sizeof(struct rte_flow_item_ah)),
3240 .next = NEXT(item_ah),
3245 .help = "security parameters index",
3246 .next = NEXT(item_ah, NEXT_ENTRY(UNSIGNED), item_param),
3247 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ah, spi)),
3251 .help = "match pfcp header",
3252 .priv = PRIV_ITEM(PFCP, sizeof(struct rte_flow_item_pfcp)),
3253 .next = NEXT(item_pfcp),
3256 [ITEM_PFCP_S_FIELD] = {
3259 .next = NEXT(item_pfcp, NEXT_ENTRY(UNSIGNED), item_param),
3260 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp,
3263 [ITEM_PFCP_SEID] = {
3265 .help = "session endpoint identifier",
3266 .next = NEXT(item_pfcp, NEXT_ENTRY(UNSIGNED), item_param),
3267 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp, seid)),
3271 .help = "match eCPRI header",
3272 .priv = PRIV_ITEM(ECPRI, sizeof(struct rte_flow_item_ecpri)),
3273 .next = NEXT(item_ecpri),
3276 [ITEM_ECPRI_COMMON] = {
3278 .help = "eCPRI common header",
3279 .next = NEXT(item_ecpri_common),
3281 [ITEM_ECPRI_COMMON_TYPE] = {
3283 .help = "type of common header",
3284 .next = NEXT(item_ecpri_common_type),
3285 .args = ARGS(ARG_ENTRY_HTON(struct rte_flow_item_ecpri)),
3287 [ITEM_ECPRI_COMMON_TYPE_IQ_DATA] = {
3289 .help = "Type #0: IQ Data",
3290 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
3292 .call = parse_vc_item_ecpri_type,
3294 [ITEM_ECPRI_MSG_IQ_DATA_PCID] = {
3296 .help = "Physical Channel ID",
3297 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
3298 ITEM_ECPRI_COMMON, ITEM_NEXT),
3299 NEXT_ENTRY(UNSIGNED), item_param),
3300 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3303 [ITEM_ECPRI_COMMON_TYPE_RTC_CTRL] = {
3305 .help = "Type #2: Real-Time Control Data",
3306 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
3308 .call = parse_vc_item_ecpri_type,
3310 [ITEM_ECPRI_MSG_RTC_CTRL_RTCID] = {
3312 .help = "Real-Time Control Data ID",
3313 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
3314 ITEM_ECPRI_COMMON, ITEM_NEXT),
3315 NEXT_ENTRY(UNSIGNED), item_param),
3316 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3319 [ITEM_ECPRI_COMMON_TYPE_DLY_MSR] = {
3320 .name = "delay_measure",
3321 .help = "Type #5: One-Way Delay Measurement",
3322 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
3324 .call = parse_vc_item_ecpri_type,
3326 [ITEM_ECPRI_MSG_DLY_MSR_MSRID] = {
3328 .help = "Measurement ID",
3329 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
3330 ITEM_ECPRI_COMMON, ITEM_NEXT),
3331 NEXT_ENTRY(UNSIGNED), item_param),
3332 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3335 [ITEM_GENEVE_OPT] = {
3336 .name = "geneve-opt",
3337 .help = "GENEVE header option",
3338 .priv = PRIV_ITEM(GENEVE_OPT,
3339 sizeof(struct rte_flow_item_geneve_opt) +
3340 ITEM_GENEVE_OPT_DATA_SIZE),
3341 .next = NEXT(item_geneve_opt),
3344 [ITEM_GENEVE_OPT_CLASS] = {
3346 .help = "GENEVE option class",
3347 .next = NEXT(item_geneve_opt, NEXT_ENTRY(UNSIGNED), item_param),
3348 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve_opt,
3351 [ITEM_GENEVE_OPT_TYPE] = {
3353 .help = "GENEVE option type",
3354 .next = NEXT(item_geneve_opt, NEXT_ENTRY(UNSIGNED), item_param),
3355 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt,
3358 [ITEM_GENEVE_OPT_LENGTH] = {
3360 .help = "GENEVE option data length (in 32b words)",
3361 .next = NEXT(item_geneve_opt, NEXT_ENTRY(UNSIGNED), item_param),
3362 .args = ARGS(ARGS_ENTRY_BOUNDED(
3363 struct rte_flow_item_geneve_opt, option_len,
3366 [ITEM_GENEVE_OPT_DATA] = {
3368 .help = "GENEVE option data pattern",
3369 .next = NEXT(item_geneve_opt, NEXT_ENTRY(HEX), item_param),
3370 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt, data),
3371 ARGS_ENTRY_ARB(0, 0),
3373 (sizeof(struct rte_flow_item_geneve_opt),
3374 ITEM_GENEVE_OPT_DATA_SIZE)),
3376 /* Validate/create actions. */
3379 .help = "submit a list of associated actions",
3380 .next = NEXT(next_action),
3385 .help = "specify next action",
3386 .next = NEXT(next_action),
3390 .help = "end list of actions",
3391 .priv = PRIV_ACTION(END, 0),
3396 .help = "no-op action",
3397 .priv = PRIV_ACTION(VOID, 0),
3398 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3401 [ACTION_PASSTHRU] = {
3403 .help = "let subsequent rule process matched packets",
3404 .priv = PRIV_ACTION(PASSTHRU, 0),
3405 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3410 .help = "redirect traffic to a given group",
3411 .priv = PRIV_ACTION(JUMP, sizeof(struct rte_flow_action_jump)),
3412 .next = NEXT(action_jump),
3415 [ACTION_JUMP_GROUP] = {
3417 .help = "group to redirect traffic to",
3418 .next = NEXT(action_jump, NEXT_ENTRY(UNSIGNED)),
3419 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump, group)),
3420 .call = parse_vc_conf,
3424 .help = "attach 32 bit value to packets",
3425 .priv = PRIV_ACTION(MARK, sizeof(struct rte_flow_action_mark)),
3426 .next = NEXT(action_mark),
3429 [ACTION_MARK_ID] = {
3431 .help = "32 bit value to return with packets",
3432 .next = NEXT(action_mark, NEXT_ENTRY(UNSIGNED)),
3433 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_mark, id)),
3434 .call = parse_vc_conf,
3438 .help = "flag packets",
3439 .priv = PRIV_ACTION(FLAG, 0),
3440 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3445 .help = "assign packets to a given queue index",
3446 .priv = PRIV_ACTION(QUEUE,
3447 sizeof(struct rte_flow_action_queue)),
3448 .next = NEXT(action_queue),
3451 [ACTION_QUEUE_INDEX] = {
3453 .help = "queue index to use",
3454 .next = NEXT(action_queue, NEXT_ENTRY(UNSIGNED)),
3455 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_queue, index)),
3456 .call = parse_vc_conf,
3460 .help = "drop packets (note: passthru has priority)",
3461 .priv = PRIV_ACTION(DROP, 0),
3462 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3467 .help = "enable counters for this rule",
3468 .priv = PRIV_ACTION(COUNT,
3469 sizeof(struct rte_flow_action_count)),
3470 .next = NEXT(action_count),
3473 [ACTION_COUNT_ID] = {
3474 .name = "identifier",
3475 .help = "counter identifier to use",
3476 .next = NEXT(action_count, NEXT_ENTRY(UNSIGNED)),
3477 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_count, id)),
3478 .call = parse_vc_conf,
3480 [ACTION_COUNT_SHARED] = {
3482 .help = "shared counter",
3483 .next = NEXT(action_count, NEXT_ENTRY(BOOLEAN)),
3484 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_count,
3486 .call = parse_vc_conf,
3490 .help = "spread packets among several queues",
3491 .priv = PRIV_ACTION(RSS, sizeof(struct action_rss_data)),
3492 .next = NEXT(action_rss),
3493 .call = parse_vc_action_rss,
3495 [ACTION_RSS_FUNC] = {
3497 .help = "RSS hash function to apply",
3498 .next = NEXT(action_rss,
3499 NEXT_ENTRY(ACTION_RSS_FUNC_DEFAULT,
3500 ACTION_RSS_FUNC_TOEPLITZ,
3501 ACTION_RSS_FUNC_SIMPLE_XOR,
3502 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ)),
3504 [ACTION_RSS_FUNC_DEFAULT] = {
3506 .help = "default hash function",
3507 .call = parse_vc_action_rss_func,
3509 [ACTION_RSS_FUNC_TOEPLITZ] = {
3511 .help = "Toeplitz hash function",
3512 .call = parse_vc_action_rss_func,
3514 [ACTION_RSS_FUNC_SIMPLE_XOR] = {
3515 .name = "simple_xor",
3516 .help = "simple XOR hash function",
3517 .call = parse_vc_action_rss_func,
3519 [ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ] = {
3520 .name = "symmetric_toeplitz",
3521 .help = "Symmetric Toeplitz hash function",
3522 .call = parse_vc_action_rss_func,
3524 [ACTION_RSS_LEVEL] = {
3526 .help = "encapsulation level for \"types\"",
3527 .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
3528 .args = ARGS(ARGS_ENTRY_ARB
3529 (offsetof(struct action_rss_data, conf) +
3530 offsetof(struct rte_flow_action_rss, level),
3531 sizeof(((struct rte_flow_action_rss *)0)->
3534 [ACTION_RSS_TYPES] = {
3536 .help = "specific RSS hash types",
3537 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)),
3539 [ACTION_RSS_TYPE] = {
3541 .help = "RSS hash type",
3542 .call = parse_vc_action_rss_type,
3543 .comp = comp_vc_action_rss_type,
3545 [ACTION_RSS_KEY] = {
3547 .help = "RSS hash key",
3548 .next = NEXT(action_rss, NEXT_ENTRY(HEX)),
3549 .args = ARGS(ARGS_ENTRY_ARB
3550 (offsetof(struct action_rss_data, conf) +
3551 offsetof(struct rte_flow_action_rss, key),
3552 sizeof(((struct rte_flow_action_rss *)0)->key)),
3554 (offsetof(struct action_rss_data, conf) +
3555 offsetof(struct rte_flow_action_rss, key_len),
3556 sizeof(((struct rte_flow_action_rss *)0)->
3558 ARGS_ENTRY(struct action_rss_data, key)),
3560 [ACTION_RSS_KEY_LEN] = {
3562 .help = "RSS hash key length in bytes",
3563 .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
3564 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
3565 (offsetof(struct action_rss_data, conf) +
3566 offsetof(struct rte_flow_action_rss, key_len),
3567 sizeof(((struct rte_flow_action_rss *)0)->
3570 RSS_HASH_KEY_LENGTH)),
3572 [ACTION_RSS_QUEUES] = {
3574 .help = "queue indices to use",
3575 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_QUEUE)),
3576 .call = parse_vc_conf,
3578 [ACTION_RSS_QUEUE] = {
3580 .help = "queue index",
3581 .call = parse_vc_action_rss_queue,
3582 .comp = comp_vc_action_rss_queue,
3586 .help = "direct traffic to physical function",
3587 .priv = PRIV_ACTION(PF, 0),
3588 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3593 .help = "direct traffic to a virtual function ID",
3594 .priv = PRIV_ACTION(VF, sizeof(struct rte_flow_action_vf)),
3595 .next = NEXT(action_vf),
3598 [ACTION_VF_ORIGINAL] = {
3600 .help = "use original VF ID if possible",
3601 .next = NEXT(action_vf, NEXT_ENTRY(BOOLEAN)),
3602 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_vf,
3604 .call = parse_vc_conf,
3609 .next = NEXT(action_vf, NEXT_ENTRY(UNSIGNED)),
3610 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)),
3611 .call = parse_vc_conf,
3613 [ACTION_PHY_PORT] = {
3615 .help = "direct packets to physical port index",
3616 .priv = PRIV_ACTION(PHY_PORT,
3617 sizeof(struct rte_flow_action_phy_port)),
3618 .next = NEXT(action_phy_port),
3621 [ACTION_PHY_PORT_ORIGINAL] = {
3623 .help = "use original port index if possible",
3624 .next = NEXT(action_phy_port, NEXT_ENTRY(BOOLEAN)),
3625 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_phy_port,
3627 .call = parse_vc_conf,
3629 [ACTION_PHY_PORT_INDEX] = {
3631 .help = "physical port index",
3632 .next = NEXT(action_phy_port, NEXT_ENTRY(UNSIGNED)),
3633 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_phy_port,
3635 .call = parse_vc_conf,
3637 [ACTION_PORT_ID] = {
3639 .help = "direct matching traffic to a given DPDK port ID",
3640 .priv = PRIV_ACTION(PORT_ID,
3641 sizeof(struct rte_flow_action_port_id)),
3642 .next = NEXT(action_port_id),
3645 [ACTION_PORT_ID_ORIGINAL] = {
3647 .help = "use original DPDK port ID if possible",
3648 .next = NEXT(action_port_id, NEXT_ENTRY(BOOLEAN)),
3649 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_port_id,
3651 .call = parse_vc_conf,
3653 [ACTION_PORT_ID_ID] = {
3655 .help = "DPDK port ID",
3656 .next = NEXT(action_port_id, NEXT_ENTRY(UNSIGNED)),
3657 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_port_id, id)),
3658 .call = parse_vc_conf,
3662 .help = "meter the directed packets at given id",
3663 .priv = PRIV_ACTION(METER,
3664 sizeof(struct rte_flow_action_meter)),
3665 .next = NEXT(action_meter),
3668 [ACTION_METER_ID] = {
3670 .help = "meter id to use",
3671 .next = NEXT(action_meter, NEXT_ENTRY(UNSIGNED)),
3672 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter, mtr_id)),
3673 .call = parse_vc_conf,
3675 [ACTION_OF_SET_MPLS_TTL] = {
3676 .name = "of_set_mpls_ttl",
3677 .help = "OpenFlow's OFPAT_SET_MPLS_TTL",
3680 sizeof(struct rte_flow_action_of_set_mpls_ttl)),
3681 .next = NEXT(action_of_set_mpls_ttl),
3684 [ACTION_OF_SET_MPLS_TTL_MPLS_TTL] = {
3687 .next = NEXT(action_of_set_mpls_ttl, NEXT_ENTRY(UNSIGNED)),
3688 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_mpls_ttl,
3690 .call = parse_vc_conf,
3692 [ACTION_OF_DEC_MPLS_TTL] = {
3693 .name = "of_dec_mpls_ttl",
3694 .help = "OpenFlow's OFPAT_DEC_MPLS_TTL",
3695 .priv = PRIV_ACTION(OF_DEC_MPLS_TTL, 0),
3696 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3699 [ACTION_OF_SET_NW_TTL] = {
3700 .name = "of_set_nw_ttl",
3701 .help = "OpenFlow's OFPAT_SET_NW_TTL",
3704 sizeof(struct rte_flow_action_of_set_nw_ttl)),
3705 .next = NEXT(action_of_set_nw_ttl),
3708 [ACTION_OF_SET_NW_TTL_NW_TTL] = {
3711 .next = NEXT(action_of_set_nw_ttl, NEXT_ENTRY(UNSIGNED)),
3712 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_nw_ttl,
3714 .call = parse_vc_conf,
3716 [ACTION_OF_DEC_NW_TTL] = {
3717 .name = "of_dec_nw_ttl",
3718 .help = "OpenFlow's OFPAT_DEC_NW_TTL",
3719 .priv = PRIV_ACTION(OF_DEC_NW_TTL, 0),
3720 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3723 [ACTION_OF_COPY_TTL_OUT] = {
3724 .name = "of_copy_ttl_out",
3725 .help = "OpenFlow's OFPAT_COPY_TTL_OUT",
3726 .priv = PRIV_ACTION(OF_COPY_TTL_OUT, 0),
3727 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3730 [ACTION_OF_COPY_TTL_IN] = {
3731 .name = "of_copy_ttl_in",
3732 .help = "OpenFlow's OFPAT_COPY_TTL_IN",
3733 .priv = PRIV_ACTION(OF_COPY_TTL_IN, 0),
3734 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3737 [ACTION_OF_POP_VLAN] = {
3738 .name = "of_pop_vlan",
3739 .help = "OpenFlow's OFPAT_POP_VLAN",
3740 .priv = PRIV_ACTION(OF_POP_VLAN, 0),
3741 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3744 [ACTION_OF_PUSH_VLAN] = {
3745 .name = "of_push_vlan",
3746 .help = "OpenFlow's OFPAT_PUSH_VLAN",
3749 sizeof(struct rte_flow_action_of_push_vlan)),
3750 .next = NEXT(action_of_push_vlan),
3753 [ACTION_OF_PUSH_VLAN_ETHERTYPE] = {
3754 .name = "ethertype",
3755 .help = "EtherType",
3756 .next = NEXT(action_of_push_vlan, NEXT_ENTRY(UNSIGNED)),
3757 .args = ARGS(ARGS_ENTRY_HTON
3758 (struct rte_flow_action_of_push_vlan,
3760 .call = parse_vc_conf,
3762 [ACTION_OF_SET_VLAN_VID] = {
3763 .name = "of_set_vlan_vid",
3764 .help = "OpenFlow's OFPAT_SET_VLAN_VID",
3767 sizeof(struct rte_flow_action_of_set_vlan_vid)),
3768 .next = NEXT(action_of_set_vlan_vid),
3771 [ACTION_OF_SET_VLAN_VID_VLAN_VID] = {
3774 .next = NEXT(action_of_set_vlan_vid, NEXT_ENTRY(UNSIGNED)),
3775 .args = ARGS(ARGS_ENTRY_HTON
3776 (struct rte_flow_action_of_set_vlan_vid,
3778 .call = parse_vc_conf,
3780 [ACTION_OF_SET_VLAN_PCP] = {
3781 .name = "of_set_vlan_pcp",
3782 .help = "OpenFlow's OFPAT_SET_VLAN_PCP",
3785 sizeof(struct rte_flow_action_of_set_vlan_pcp)),
3786 .next = NEXT(action_of_set_vlan_pcp),
3789 [ACTION_OF_SET_VLAN_PCP_VLAN_PCP] = {
3791 .help = "VLAN priority",
3792 .next = NEXT(action_of_set_vlan_pcp, NEXT_ENTRY(UNSIGNED)),
3793 .args = ARGS(ARGS_ENTRY_HTON
3794 (struct rte_flow_action_of_set_vlan_pcp,
3796 .call = parse_vc_conf,
3798 [ACTION_OF_POP_MPLS] = {
3799 .name = "of_pop_mpls",
3800 .help = "OpenFlow's OFPAT_POP_MPLS",
3801 .priv = PRIV_ACTION(OF_POP_MPLS,
3802 sizeof(struct rte_flow_action_of_pop_mpls)),
3803 .next = NEXT(action_of_pop_mpls),
3806 [ACTION_OF_POP_MPLS_ETHERTYPE] = {
3807 .name = "ethertype",
3808 .help = "EtherType",
3809 .next = NEXT(action_of_pop_mpls, NEXT_ENTRY(UNSIGNED)),
3810 .args = ARGS(ARGS_ENTRY_HTON
3811 (struct rte_flow_action_of_pop_mpls,
3813 .call = parse_vc_conf,
3815 [ACTION_OF_PUSH_MPLS] = {
3816 .name = "of_push_mpls",
3817 .help = "OpenFlow's OFPAT_PUSH_MPLS",
3820 sizeof(struct rte_flow_action_of_push_mpls)),
3821 .next = NEXT(action_of_push_mpls),
3824 [ACTION_OF_PUSH_MPLS_ETHERTYPE] = {
3825 .name = "ethertype",
3826 .help = "EtherType",
3827 .next = NEXT(action_of_push_mpls, NEXT_ENTRY(UNSIGNED)),
3828 .args = ARGS(ARGS_ENTRY_HTON
3829 (struct rte_flow_action_of_push_mpls,
3831 .call = parse_vc_conf,
3833 [ACTION_VXLAN_ENCAP] = {
3834 .name = "vxlan_encap",
3835 .help = "VXLAN encapsulation, uses configuration set by \"set"
3837 .priv = PRIV_ACTION(VXLAN_ENCAP,
3838 sizeof(struct action_vxlan_encap_data)),
3839 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3840 .call = parse_vc_action_vxlan_encap,
3842 [ACTION_VXLAN_DECAP] = {
3843 .name = "vxlan_decap",
3844 .help = "Performs a decapsulation action by stripping all"
3845 " headers of the VXLAN tunnel network overlay from the"
3847 .priv = PRIV_ACTION(VXLAN_DECAP, 0),
3848 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3851 [ACTION_NVGRE_ENCAP] = {
3852 .name = "nvgre_encap",
3853 .help = "NVGRE encapsulation, uses configuration set by \"set"
3855 .priv = PRIV_ACTION(NVGRE_ENCAP,
3856 sizeof(struct action_nvgre_encap_data)),
3857 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3858 .call = parse_vc_action_nvgre_encap,
3860 [ACTION_NVGRE_DECAP] = {
3861 .name = "nvgre_decap",
3862 .help = "Performs a decapsulation action by stripping all"
3863 " headers of the NVGRE tunnel network overlay from the"
3865 .priv = PRIV_ACTION(NVGRE_DECAP, 0),
3866 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3869 [ACTION_L2_ENCAP] = {
3871 .help = "l2 encap, uses configuration set by"
3872 " \"set l2_encap\"",
3873 .priv = PRIV_ACTION(RAW_ENCAP,
3874 sizeof(struct action_raw_encap_data)),
3875 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3876 .call = parse_vc_action_l2_encap,
3878 [ACTION_L2_DECAP] = {
3880 .help = "l2 decap, uses configuration set by"
3881 " \"set l2_decap\"",
3882 .priv = PRIV_ACTION(RAW_DECAP,
3883 sizeof(struct action_raw_decap_data)),
3884 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3885 .call = parse_vc_action_l2_decap,
3887 [ACTION_MPLSOGRE_ENCAP] = {
3888 .name = "mplsogre_encap",
3889 .help = "mplsogre encapsulation, uses configuration set by"
3890 " \"set mplsogre_encap\"",
3891 .priv = PRIV_ACTION(RAW_ENCAP,
3892 sizeof(struct action_raw_encap_data)),
3893 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3894 .call = parse_vc_action_mplsogre_encap,
3896 [ACTION_MPLSOGRE_DECAP] = {
3897 .name = "mplsogre_decap",
3898 .help = "mplsogre decapsulation, uses configuration set by"
3899 " \"set mplsogre_decap\"",
3900 .priv = PRIV_ACTION(RAW_DECAP,
3901 sizeof(struct action_raw_decap_data)),
3902 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3903 .call = parse_vc_action_mplsogre_decap,
3905 [ACTION_MPLSOUDP_ENCAP] = {
3906 .name = "mplsoudp_encap",
3907 .help = "mplsoudp encapsulation, uses configuration set by"
3908 " \"set mplsoudp_encap\"",
3909 .priv = PRIV_ACTION(RAW_ENCAP,
3910 sizeof(struct action_raw_encap_data)),
3911 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3912 .call = parse_vc_action_mplsoudp_encap,
3914 [ACTION_MPLSOUDP_DECAP] = {
3915 .name = "mplsoudp_decap",
3916 .help = "mplsoudp decapsulation, uses configuration set by"
3917 " \"set mplsoudp_decap\"",
3918 .priv = PRIV_ACTION(RAW_DECAP,
3919 sizeof(struct action_raw_decap_data)),
3920 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3921 .call = parse_vc_action_mplsoudp_decap,
3923 [ACTION_SET_IPV4_SRC] = {
3924 .name = "set_ipv4_src",
3925 .help = "Set a new IPv4 source address in the outermost"
3927 .priv = PRIV_ACTION(SET_IPV4_SRC,
3928 sizeof(struct rte_flow_action_set_ipv4)),
3929 .next = NEXT(action_set_ipv4_src),
3932 [ACTION_SET_IPV4_SRC_IPV4_SRC] = {
3933 .name = "ipv4_addr",
3934 .help = "new IPv4 source address to set",
3935 .next = NEXT(action_set_ipv4_src, NEXT_ENTRY(IPV4_ADDR)),
3936 .args = ARGS(ARGS_ENTRY_HTON
3937 (struct rte_flow_action_set_ipv4, ipv4_addr)),
3938 .call = parse_vc_conf,
3940 [ACTION_SET_IPV4_DST] = {
3941 .name = "set_ipv4_dst",
3942 .help = "Set a new IPv4 destination address in the outermost"
3944 .priv = PRIV_ACTION(SET_IPV4_DST,
3945 sizeof(struct rte_flow_action_set_ipv4)),
3946 .next = NEXT(action_set_ipv4_dst),
3949 [ACTION_SET_IPV4_DST_IPV4_DST] = {
3950 .name = "ipv4_addr",
3951 .help = "new IPv4 destination address to set",
3952 .next = NEXT(action_set_ipv4_dst, NEXT_ENTRY(IPV4_ADDR)),
3953 .args = ARGS(ARGS_ENTRY_HTON
3954 (struct rte_flow_action_set_ipv4, ipv4_addr)),
3955 .call = parse_vc_conf,
3957 [ACTION_SET_IPV6_SRC] = {
3958 .name = "set_ipv6_src",
3959 .help = "Set a new IPv6 source address in the outermost"
3961 .priv = PRIV_ACTION(SET_IPV6_SRC,
3962 sizeof(struct rte_flow_action_set_ipv6)),
3963 .next = NEXT(action_set_ipv6_src),
3966 [ACTION_SET_IPV6_SRC_IPV6_SRC] = {
3967 .name = "ipv6_addr",
3968 .help = "new IPv6 source address to set",
3969 .next = NEXT(action_set_ipv6_src, NEXT_ENTRY(IPV6_ADDR)),
3970 .args = ARGS(ARGS_ENTRY_HTON
3971 (struct rte_flow_action_set_ipv6, ipv6_addr)),
3972 .call = parse_vc_conf,
3974 [ACTION_SET_IPV6_DST] = {
3975 .name = "set_ipv6_dst",
3976 .help = "Set a new IPv6 destination address in the outermost"
3978 .priv = PRIV_ACTION(SET_IPV6_DST,
3979 sizeof(struct rte_flow_action_set_ipv6)),
3980 .next = NEXT(action_set_ipv6_dst),
3983 [ACTION_SET_IPV6_DST_IPV6_DST] = {
3984 .name = "ipv6_addr",
3985 .help = "new IPv6 destination address to set",
3986 .next = NEXT(action_set_ipv6_dst, NEXT_ENTRY(IPV6_ADDR)),
3987 .args = ARGS(ARGS_ENTRY_HTON
3988 (struct rte_flow_action_set_ipv6, ipv6_addr)),
3989 .call = parse_vc_conf,
3991 [ACTION_SET_TP_SRC] = {
3992 .name = "set_tp_src",
3993 .help = "set a new source port number in the outermost"
3995 .priv = PRIV_ACTION(SET_TP_SRC,
3996 sizeof(struct rte_flow_action_set_tp)),
3997 .next = NEXT(action_set_tp_src),
4000 [ACTION_SET_TP_SRC_TP_SRC] = {
4002 .help = "new source port number to set",
4003 .next = NEXT(action_set_tp_src, NEXT_ENTRY(UNSIGNED)),
4004 .args = ARGS(ARGS_ENTRY_HTON
4005 (struct rte_flow_action_set_tp, port)),
4006 .call = parse_vc_conf,
4008 [ACTION_SET_TP_DST] = {
4009 .name = "set_tp_dst",
4010 .help = "set a new destination port number in the outermost"
4012 .priv = PRIV_ACTION(SET_TP_DST,
4013 sizeof(struct rte_flow_action_set_tp)),
4014 .next = NEXT(action_set_tp_dst),
4017 [ACTION_SET_TP_DST_TP_DST] = {
4019 .help = "new destination port number to set",
4020 .next = NEXT(action_set_tp_dst, NEXT_ENTRY(UNSIGNED)),
4021 .args = ARGS(ARGS_ENTRY_HTON
4022 (struct rte_flow_action_set_tp, port)),
4023 .call = parse_vc_conf,
4025 [ACTION_MAC_SWAP] = {
4027 .help = "Swap the source and destination MAC addresses"
4028 " in the outermost Ethernet header",
4029 .priv = PRIV_ACTION(MAC_SWAP, 0),
4030 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4033 [ACTION_DEC_TTL] = {
4035 .help = "decrease network TTL if available",
4036 .priv = PRIV_ACTION(DEC_TTL, 0),
4037 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4040 [ACTION_SET_TTL] = {
4042 .help = "set ttl value",
4043 .priv = PRIV_ACTION(SET_TTL,
4044 sizeof(struct rte_flow_action_set_ttl)),
4045 .next = NEXT(action_set_ttl),
4048 [ACTION_SET_TTL_TTL] = {
4049 .name = "ttl_value",
4050 .help = "new ttl value to set",
4051 .next = NEXT(action_set_ttl, NEXT_ENTRY(UNSIGNED)),
4052 .args = ARGS(ARGS_ENTRY_HTON
4053 (struct rte_flow_action_set_ttl, ttl_value)),
4054 .call = parse_vc_conf,
4056 [ACTION_SET_MAC_SRC] = {
4057 .name = "set_mac_src",
4058 .help = "set source mac address",
4059 .priv = PRIV_ACTION(SET_MAC_SRC,
4060 sizeof(struct rte_flow_action_set_mac)),
4061 .next = NEXT(action_set_mac_src),
4064 [ACTION_SET_MAC_SRC_MAC_SRC] = {
4066 .help = "new source mac address",
4067 .next = NEXT(action_set_mac_src, NEXT_ENTRY(MAC_ADDR)),
4068 .args = ARGS(ARGS_ENTRY_HTON
4069 (struct rte_flow_action_set_mac, mac_addr)),
4070 .call = parse_vc_conf,
4072 [ACTION_SET_MAC_DST] = {
4073 .name = "set_mac_dst",
4074 .help = "set destination mac address",
4075 .priv = PRIV_ACTION(SET_MAC_DST,
4076 sizeof(struct rte_flow_action_set_mac)),
4077 .next = NEXT(action_set_mac_dst),
4080 [ACTION_SET_MAC_DST_MAC_DST] = {
4082 .help = "new destination mac address to set",
4083 .next = NEXT(action_set_mac_dst, NEXT_ENTRY(MAC_ADDR)),
4084 .args = ARGS(ARGS_ENTRY_HTON
4085 (struct rte_flow_action_set_mac, mac_addr)),
4086 .call = parse_vc_conf,
4088 [ACTION_INC_TCP_SEQ] = {
4089 .name = "inc_tcp_seq",
4090 .help = "increase TCP sequence number",
4091 .priv = PRIV_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
4092 .next = NEXT(action_inc_tcp_seq),
4095 [ACTION_INC_TCP_SEQ_VALUE] = {
4097 .help = "the value to increase TCP sequence number by",
4098 .next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(UNSIGNED)),
4099 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4100 .call = parse_vc_conf,
4102 [ACTION_DEC_TCP_SEQ] = {
4103 .name = "dec_tcp_seq",
4104 .help = "decrease TCP sequence number",
4105 .priv = PRIV_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
4106 .next = NEXT(action_dec_tcp_seq),
4109 [ACTION_DEC_TCP_SEQ_VALUE] = {
4111 .help = "the value to decrease TCP sequence number by",
4112 .next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(UNSIGNED)),
4113 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4114 .call = parse_vc_conf,
4116 [ACTION_INC_TCP_ACK] = {
4117 .name = "inc_tcp_ack",
4118 .help = "increase TCP acknowledgment number",
4119 .priv = PRIV_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
4120 .next = NEXT(action_inc_tcp_ack),
4123 [ACTION_INC_TCP_ACK_VALUE] = {
4125 .help = "the value to increase TCP acknowledgment number by",
4126 .next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(UNSIGNED)),
4127 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4128 .call = parse_vc_conf,
4130 [ACTION_DEC_TCP_ACK] = {
4131 .name = "dec_tcp_ack",
4132 .help = "decrease TCP acknowledgment number",
4133 .priv = PRIV_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
4134 .next = NEXT(action_dec_tcp_ack),
4137 [ACTION_DEC_TCP_ACK_VALUE] = {
4139 .help = "the value to decrease TCP acknowledgment number by",
4140 .next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(UNSIGNED)),
4141 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4142 .call = parse_vc_conf,
4144 [ACTION_RAW_ENCAP] = {
4145 .name = "raw_encap",
4146 .help = "encapsulation data, defined by set raw_encap",
4147 .priv = PRIV_ACTION(RAW_ENCAP,
4148 sizeof(struct action_raw_encap_data)),
4149 .next = NEXT(action_raw_encap),
4150 .call = parse_vc_action_raw_encap,
4152 [ACTION_RAW_ENCAP_INDEX] = {
4154 .help = "the index of raw_encap_confs",
4155 .next = NEXT(NEXT_ENTRY(ACTION_RAW_ENCAP_INDEX_VALUE)),
4157 [ACTION_RAW_ENCAP_INDEX_VALUE] = {
4160 .help = "unsigned integer value",
4161 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4162 .call = parse_vc_action_raw_encap_index,
4163 .comp = comp_set_raw_index,
4165 [ACTION_RAW_DECAP] = {
4166 .name = "raw_decap",
4167 .help = "decapsulation data, defined by set raw_encap",
4168 .priv = PRIV_ACTION(RAW_DECAP,
4169 sizeof(struct action_raw_decap_data)),
4170 .next = NEXT(action_raw_decap),
4171 .call = parse_vc_action_raw_decap,
4173 [ACTION_RAW_DECAP_INDEX] = {
4175 .help = "the index of raw_encap_confs",
4176 .next = NEXT(NEXT_ENTRY(ACTION_RAW_DECAP_INDEX_VALUE)),
4178 [ACTION_RAW_DECAP_INDEX_VALUE] = {
4181 .help = "unsigned integer value",
4182 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4183 .call = parse_vc_action_raw_decap_index,
4184 .comp = comp_set_raw_index,
4186 [ACTION_MODIFY_FIELD] = {
4187 .name = "modify_field",
4188 .help = "modify destination field with data from source field",
4189 .priv = PRIV_ACTION(MODIFY_FIELD,
4190 sizeof(struct rte_flow_action_modify_field)),
4191 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_OP)),
4194 [ACTION_MODIFY_FIELD_OP] = {
4196 .help = "operation type",
4197 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_TYPE),
4198 NEXT_ENTRY(ACTION_MODIFY_FIELD_OP_VALUE)),
4199 .call = parse_vc_conf,
4201 [ACTION_MODIFY_FIELD_OP_VALUE] = {
4202 .name = "{operation}",
4203 .help = "operation type value",
4204 .call = parse_vc_modify_field_op,
4205 .comp = comp_set_modify_field_op,
4207 [ACTION_MODIFY_FIELD_DST_TYPE] = {
4209 .help = "destination field type",
4210 .next = NEXT(action_modify_field_dst,
4211 NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_TYPE_VALUE)),
4212 .call = parse_vc_conf,
4214 [ACTION_MODIFY_FIELD_DST_TYPE_VALUE] = {
4215 .name = "{dst_type}",
4216 .help = "destination field type value",
4217 .call = parse_vc_modify_field_id,
4218 .comp = comp_set_modify_field_id,
4220 [ACTION_MODIFY_FIELD_DST_LEVEL] = {
4221 .name = "dst_level",
4222 .help = "destination field level",
4223 .next = NEXT(action_modify_field_dst, NEXT_ENTRY(UNSIGNED)),
4224 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4226 .call = parse_vc_conf,
4228 [ACTION_MODIFY_FIELD_DST_OFFSET] = {
4229 .name = "dst_offset",
4230 .help = "destination field bit offset",
4231 .next = NEXT(action_modify_field_dst, NEXT_ENTRY(UNSIGNED)),
4232 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4234 .call = parse_vc_conf,
4236 [ACTION_MODIFY_FIELD_SRC_TYPE] = {
4238 .help = "source field type",
4239 .next = NEXT(action_modify_field_src,
4240 NEXT_ENTRY(ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)),
4241 .call = parse_vc_conf,
4243 [ACTION_MODIFY_FIELD_SRC_TYPE_VALUE] = {
4244 .name = "{src_type}",
4245 .help = "source field type value",
4246 .call = parse_vc_modify_field_id,
4247 .comp = comp_set_modify_field_id,
4249 [ACTION_MODIFY_FIELD_SRC_LEVEL] = {
4250 .name = "src_level",
4251 .help = "source field level",
4252 .next = NEXT(action_modify_field_src, NEXT_ENTRY(UNSIGNED)),
4253 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4255 .call = parse_vc_conf,
4257 [ACTION_MODIFY_FIELD_SRC_OFFSET] = {
4258 .name = "src_offset",
4259 .help = "source field bit offset",
4260 .next = NEXT(action_modify_field_src, NEXT_ENTRY(UNSIGNED)),
4261 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4263 .call = parse_vc_conf,
4265 [ACTION_MODIFY_FIELD_SRC_VALUE] = {
4266 .name = "src_value",
4267 .help = "source immediate value",
4268 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_WIDTH),
4269 NEXT_ENTRY(UNSIGNED)),
4270 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4272 .call = parse_vc_conf,
4274 [ACTION_MODIFY_FIELD_WIDTH] = {
4276 .help = "number of bits to copy",
4277 .next = NEXT(NEXT_ENTRY(ACTION_NEXT),
4278 NEXT_ENTRY(UNSIGNED)),
4279 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4281 .call = parse_vc_conf,
4283 /* Top level command. */
4286 .help = "set raw encap/decap/sample data",
4287 .type = "set raw_encap|raw_decap <index> <pattern>"
4288 " or set sample_actions <index> <action>",
4289 .next = NEXT(NEXT_ENTRY
4292 SET_SAMPLE_ACTIONS)),
4293 .call = parse_set_init,
4295 /* Sub-level commands. */
4297 .name = "raw_encap",
4298 .help = "set raw encap data",
4299 .next = NEXT(next_set_raw),
4300 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4301 (offsetof(struct buffer, port),
4302 sizeof(((struct buffer *)0)->port),
4303 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
4304 .call = parse_set_raw_encap_decap,
4307 .name = "raw_decap",
4308 .help = "set raw decap data",
4309 .next = NEXT(next_set_raw),
4310 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4311 (offsetof(struct buffer, port),
4312 sizeof(((struct buffer *)0)->port),
4313 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
4314 .call = parse_set_raw_encap_decap,
4319 .help = "index of raw_encap/raw_decap data",
4320 .next = NEXT(next_item),
4323 [SET_SAMPLE_INDEX] = {
4326 .help = "index of sample actions",
4327 .next = NEXT(next_action_sample),
4330 [SET_SAMPLE_ACTIONS] = {
4331 .name = "sample_actions",
4332 .help = "set sample actions list",
4333 .next = NEXT(NEXT_ENTRY(SET_SAMPLE_INDEX)),
4334 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4335 (offsetof(struct buffer, port),
4336 sizeof(((struct buffer *)0)->port),
4337 0, RAW_SAMPLE_CONFS_MAX_NUM - 1)),
4338 .call = parse_set_sample_action,
4340 [ACTION_SET_TAG] = {
4343 .priv = PRIV_ACTION(SET_TAG,
4344 sizeof(struct rte_flow_action_set_tag)),
4345 .next = NEXT(action_set_tag),
4348 [ACTION_SET_TAG_INDEX] = {
4350 .help = "index of tag array",
4351 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
4352 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_set_tag, index)),
4353 .call = parse_vc_conf,
4355 [ACTION_SET_TAG_DATA] = {
4357 .help = "tag value",
4358 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
4359 .args = ARGS(ARGS_ENTRY
4360 (struct rte_flow_action_set_tag, data)),
4361 .call = parse_vc_conf,
4363 [ACTION_SET_TAG_MASK] = {
4365 .help = "mask for tag value",
4366 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
4367 .args = ARGS(ARGS_ENTRY
4368 (struct rte_flow_action_set_tag, mask)),
4369 .call = parse_vc_conf,
4371 [ACTION_SET_META] = {
4373 .help = "set metadata",
4374 .priv = PRIV_ACTION(SET_META,
4375 sizeof(struct rte_flow_action_set_meta)),
4376 .next = NEXT(action_set_meta),
4377 .call = parse_vc_action_set_meta,
4379 [ACTION_SET_META_DATA] = {
4381 .help = "metadata value",
4382 .next = NEXT(action_set_meta, NEXT_ENTRY(UNSIGNED)),
4383 .args = ARGS(ARGS_ENTRY
4384 (struct rte_flow_action_set_meta, data)),
4385 .call = parse_vc_conf,
4387 [ACTION_SET_META_MASK] = {
4389 .help = "mask for metadata value",
4390 .next = NEXT(action_set_meta, NEXT_ENTRY(UNSIGNED)),
4391 .args = ARGS(ARGS_ENTRY
4392 (struct rte_flow_action_set_meta, mask)),
4393 .call = parse_vc_conf,
4395 [ACTION_SET_IPV4_DSCP] = {
4396 .name = "set_ipv4_dscp",
4397 .help = "set DSCP value",
4398 .priv = PRIV_ACTION(SET_IPV4_DSCP,
4399 sizeof(struct rte_flow_action_set_dscp)),
4400 .next = NEXT(action_set_ipv4_dscp),
4403 [ACTION_SET_IPV4_DSCP_VALUE] = {
4404 .name = "dscp_value",
4405 .help = "new IPv4 DSCP value to set",
4406 .next = NEXT(action_set_ipv4_dscp, NEXT_ENTRY(UNSIGNED)),
4407 .args = ARGS(ARGS_ENTRY
4408 (struct rte_flow_action_set_dscp, dscp)),
4409 .call = parse_vc_conf,
4411 [ACTION_SET_IPV6_DSCP] = {
4412 .name = "set_ipv6_dscp",
4413 .help = "set DSCP value",
4414 .priv = PRIV_ACTION(SET_IPV6_DSCP,
4415 sizeof(struct rte_flow_action_set_dscp)),
4416 .next = NEXT(action_set_ipv6_dscp),
4419 [ACTION_SET_IPV6_DSCP_VALUE] = {
4420 .name = "dscp_value",
4421 .help = "new IPv6 DSCP value to set",
4422 .next = NEXT(action_set_ipv6_dscp, NEXT_ENTRY(UNSIGNED)),
4423 .args = ARGS(ARGS_ENTRY
4424 (struct rte_flow_action_set_dscp, dscp)),
4425 .call = parse_vc_conf,
4429 .help = "set a specific metadata header",
4430 .next = NEXT(action_age),
4431 .priv = PRIV_ACTION(AGE,
4432 sizeof(struct rte_flow_action_age)),
4435 [ACTION_AGE_TIMEOUT] = {
4437 .help = "flow age timeout value",
4438 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_age,
4440 .next = NEXT(action_age, NEXT_ENTRY(UNSIGNED)),
4441 .call = parse_vc_conf,
4445 .help = "set a sample action",
4446 .next = NEXT(action_sample),
4447 .priv = PRIV_ACTION(SAMPLE,
4448 sizeof(struct action_sample_data)),
4449 .call = parse_vc_action_sample,
4451 [ACTION_SAMPLE_RATIO] = {
4453 .help = "flow sample ratio value",
4454 .next = NEXT(action_sample, NEXT_ENTRY(UNSIGNED)),
4455 .args = ARGS(ARGS_ENTRY_ARB
4456 (offsetof(struct action_sample_data, conf) +
4457 offsetof(struct rte_flow_action_sample, ratio),
4458 sizeof(((struct rte_flow_action_sample *)0)->
4461 [ACTION_SAMPLE_INDEX] = {
4463 .help = "the index of sample actions list",
4464 .next = NEXT(NEXT_ENTRY(ACTION_SAMPLE_INDEX_VALUE)),
4466 [ACTION_SAMPLE_INDEX_VALUE] = {
4469 .help = "unsigned integer value",
4470 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4471 .call = parse_vc_action_sample_index,
4472 .comp = comp_set_sample_index,
4474 /* Shared action destroy arguments. */
4475 [SHARED_ACTION_DESTROY_ID] = {
4476 .name = "action_id",
4477 .help = "specify a shared action id to destroy",
4478 .next = NEXT(next_sa_destroy_attr,
4479 NEXT_ENTRY(SHARED_ACTION_ID)),
4480 .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
4481 args.sa_destroy.action_id)),
4482 .call = parse_sa_destroy,
4484 /* Shared action create arguments. */
4485 [SHARED_ACTION_CREATE_ID] = {
4486 .name = "action_id",
4487 .help = "specify a shared action id to create",
4488 .next = NEXT(next_sa_create_attr,
4489 NEXT_ENTRY(SHARED_ACTION_ID)),
4490 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
4494 .help = "apply shared action by id",
4495 .priv = PRIV_ACTION(SHARED, 0),
4496 .next = NEXT(NEXT_ENTRY(SHARED_ACTION_ID2PTR)),
4497 .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
4500 [SHARED_ACTION_ID2PTR] = {
4501 .name = "{action_id}",
4502 .type = "SHARED_ACTION_ID",
4503 .help = "shared action id",
4504 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4505 .call = parse_sa_id2ptr,
4508 [SHARED_ACTION_INGRESS] = {
4510 .help = "affect rule to ingress",
4511 .next = NEXT(next_sa_create_attr),
4514 [SHARED_ACTION_EGRESS] = {
4516 .help = "affect rule to egress",
4517 .next = NEXT(next_sa_create_attr),
4520 [SHARED_ACTION_TRANSFER] = {
4522 .help = "affect rule to transfer",
4523 .next = NEXT(next_sa_create_attr),
4526 [SHARED_ACTION_SPEC] = {
4528 .help = "specify action to share",
4529 .next = NEXT(next_action),
4533 /** Remove and return last entry from argument stack. */
4534 static const struct arg *
4535 pop_args(struct context *ctx)
4537 return ctx->args_num ? ctx->args[--ctx->args_num] : NULL;
4540 /** Add entry on top of the argument stack. */
4542 push_args(struct context *ctx, const struct arg *arg)
4544 if (ctx->args_num == CTX_STACK_SIZE)
4546 ctx->args[ctx->args_num++] = arg;
4550 /** Spread value into buffer according to bit-mask. */
4552 arg_entry_bf_fill(void *dst, uintmax_t val, const struct arg *arg)
4554 uint32_t i = arg->size;
4562 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
4571 unsigned int shift = 0;
4572 uint8_t *buf = (uint8_t *)dst + arg->offset + (i -= sub);
4574 for (shift = 0; arg->mask[i] >> shift; ++shift) {
4575 if (!(arg->mask[i] & (1 << shift)))
4580 *buf &= ~(1 << shift);
4581 *buf |= (val & 1) << shift;
4589 /** Compare a string with a partial one of a given length. */
4591 strcmp_partial(const char *full, const char *partial, size_t partial_len)
4593 int r = strncmp(full, partial, partial_len);
4597 if (strlen(full) <= partial_len)
4599 return full[partial_len];
4603 * Parse a prefix length and generate a bit-mask.
4605 * Last argument (ctx->args) is retrieved to determine mask size, storage
4606 * location and whether the result must use network byte ordering.
4609 parse_prefix(struct context *ctx, const struct token *token,
4610 const char *str, unsigned int len,
4611 void *buf, unsigned int size)
4613 const struct arg *arg = pop_args(ctx);
4614 static const uint8_t conv[] = "\x00\x80\xc0\xe0\xf0\xf8\xfc\xfe\xff";
4621 /* Argument is expected. */
4625 u = strtoumax(str, &end, 0);
4626 if (errno || (size_t)(end - str) != len)
4631 extra = arg_entry_bf_fill(NULL, 0, arg);
4640 if (!arg_entry_bf_fill(ctx->object, v, arg) ||
4641 !arg_entry_bf_fill(ctx->objmask, -1, arg))
4648 if (bytes > size || bytes + !!extra > size)
4652 buf = (uint8_t *)ctx->object + arg->offset;
4653 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
4655 memset((uint8_t *)buf + size - bytes, 0xff, bytes);
4656 memset(buf, 0x00, size - bytes);
4658 ((uint8_t *)buf)[size - bytes - 1] = conv[extra];
4662 memset(buf, 0xff, bytes);
4663 memset((uint8_t *)buf + bytes, 0x00, size - bytes);
4665 ((uint8_t *)buf)[bytes] = conv[extra];
4668 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
4671 push_args(ctx, arg);
4675 /** Default parsing function for token name matching. */
4677 parse_default(struct context *ctx, const struct token *token,
4678 const char *str, unsigned int len,
4679 void *buf, unsigned int size)
4684 if (strcmp_partial(token->name, str, len))
4689 /** Parse flow command, initialize output buffer for subsequent tokens. */
4691 parse_init(struct context *ctx, const struct token *token,
4692 const char *str, unsigned int len,
4693 void *buf, unsigned int size)
4695 struct buffer *out = buf;
4697 /* Token name must match. */
4698 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4700 /* Nothing else to do if there is no buffer. */
4703 /* Make sure buffer is large enough. */
4704 if (size < sizeof(*out))
4706 /* Initialize buffer. */
4707 memset(out, 0x00, sizeof(*out));
4708 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
4711 ctx->objmask = NULL;
4715 /** Parse tokens for shared action commands. */
4717 parse_sa(struct context *ctx, const struct token *token,
4718 const char *str, unsigned int len,
4719 void *buf, unsigned int size)
4721 struct buffer *out = buf;
4723 /* Token name must match. */
4724 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4726 /* Nothing else to do if there is no buffer. */
4729 if (!out->command) {
4730 if (ctx->curr != SHARED_ACTION)
4732 if (sizeof(*out) > size)
4734 out->command = ctx->curr;
4737 ctx->objmask = NULL;
4738 out->args.vc.data = (uint8_t *)out + size;
4741 switch (ctx->curr) {
4742 case SHARED_ACTION_CREATE:
4743 case SHARED_ACTION_UPDATE:
4744 out->args.vc.actions =
4745 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
4747 out->args.vc.attr.group = UINT32_MAX;
4749 case SHARED_ACTION_QUERY:
4750 out->command = ctx->curr;
4753 ctx->objmask = NULL;
4755 case SHARED_ACTION_EGRESS:
4756 out->args.vc.attr.egress = 1;
4758 case SHARED_ACTION_INGRESS:
4759 out->args.vc.attr.ingress = 1;
4761 case SHARED_ACTION_TRANSFER:
4762 out->args.vc.attr.transfer = 1;
4770 /** Parse tokens for shared action destroy command. */
4772 parse_sa_destroy(struct context *ctx, const struct token *token,
4773 const char *str, unsigned int len,
4774 void *buf, unsigned int size)
4776 struct buffer *out = buf;
4777 uint32_t *action_id;
4779 /* Token name must match. */
4780 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4782 /* Nothing else to do if there is no buffer. */
4785 if (!out->command || out->command == SHARED_ACTION) {
4786 if (ctx->curr != SHARED_ACTION_DESTROY)
4788 if (sizeof(*out) > size)
4790 out->command = ctx->curr;
4793 ctx->objmask = NULL;
4794 out->args.sa_destroy.action_id =
4795 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
4799 action_id = out->args.sa_destroy.action_id
4800 + out->args.sa_destroy.action_id_n++;
4801 if ((uint8_t *)action_id > (uint8_t *)out + size)
4804 ctx->object = action_id;
4805 ctx->objmask = NULL;
4809 /** Parse tokens for validate/create commands. */
4811 parse_vc(struct context *ctx, const struct token *token,
4812 const char *str, unsigned int len,
4813 void *buf, unsigned int size)
4815 struct buffer *out = buf;
4819 /* Token name must match. */
4820 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4822 /* Nothing else to do if there is no buffer. */
4825 if (!out->command) {
4826 if (ctx->curr != VALIDATE && ctx->curr != CREATE)
4828 if (sizeof(*out) > size)
4830 out->command = ctx->curr;
4833 ctx->objmask = NULL;
4834 out->args.vc.data = (uint8_t *)out + size;
4838 switch (ctx->curr) {
4840 ctx->object = &out->args.vc.attr;
4844 ctx->object = &out->args.vc.tunnel_ops;
4847 ctx->objmask = NULL;
4848 switch (ctx->curr) {
4853 out->args.vc.tunnel_ops.enabled = 1;
4854 out->args.vc.tunnel_ops.actions = 1;
4857 out->args.vc.tunnel_ops.enabled = 1;
4858 out->args.vc.tunnel_ops.items = 1;
4861 out->args.vc.attr.ingress = 1;
4864 out->args.vc.attr.egress = 1;
4867 out->args.vc.attr.transfer = 1;
4870 out->args.vc.pattern =
4871 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
4873 ctx->object = out->args.vc.pattern;
4874 ctx->objmask = NULL;
4877 out->args.vc.actions =
4878 (void *)RTE_ALIGN_CEIL((uintptr_t)
4879 (out->args.vc.pattern +
4880 out->args.vc.pattern_n),
4882 ctx->object = out->args.vc.actions;
4883 ctx->objmask = NULL;
4890 if (!out->args.vc.actions) {
4891 const struct parse_item_priv *priv = token->priv;
4892 struct rte_flow_item *item =
4893 out->args.vc.pattern + out->args.vc.pattern_n;
4895 data_size = priv->size * 3; /* spec, last, mask */
4896 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
4897 (out->args.vc.data - data_size),
4899 if ((uint8_t *)item + sizeof(*item) > data)
4901 *item = (struct rte_flow_item){
4904 ++out->args.vc.pattern_n;
4906 ctx->objmask = NULL;
4908 const struct parse_action_priv *priv = token->priv;
4909 struct rte_flow_action *action =
4910 out->args.vc.actions + out->args.vc.actions_n;
4912 data_size = priv->size; /* configuration */
4913 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
4914 (out->args.vc.data - data_size),
4916 if ((uint8_t *)action + sizeof(*action) > data)
4918 *action = (struct rte_flow_action){
4920 .conf = data_size ? data : NULL,
4922 ++out->args.vc.actions_n;
4923 ctx->object = action;
4924 ctx->objmask = NULL;
4926 memset(data, 0, data_size);
4927 out->args.vc.data = data;
4928 ctx->objdata = data_size;
4932 /** Parse pattern item parameter type. */
4934 parse_vc_spec(struct context *ctx, const struct token *token,
4935 const char *str, unsigned int len,
4936 void *buf, unsigned int size)
4938 struct buffer *out = buf;
4939 struct rte_flow_item *item;
4945 /* Token name must match. */
4946 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4948 /* Parse parameter types. */
4949 switch (ctx->curr) {
4950 static const enum index prefix[] = NEXT_ENTRY(PREFIX);
4956 case ITEM_PARAM_SPEC:
4959 case ITEM_PARAM_LAST:
4962 case ITEM_PARAM_PREFIX:
4963 /* Modify next token to expect a prefix. */
4964 if (ctx->next_num < 2)
4966 ctx->next[ctx->next_num - 2] = prefix;
4968 case ITEM_PARAM_MASK:
4974 /* Nothing else to do if there is no buffer. */
4977 if (!out->args.vc.pattern_n)
4979 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
4980 data_size = ctx->objdata / 3; /* spec, last, mask */
4981 /* Point to selected object. */
4982 ctx->object = out->args.vc.data + (data_size * index);
4984 ctx->objmask = out->args.vc.data + (data_size * 2); /* mask */
4985 item->mask = ctx->objmask;
4987 ctx->objmask = NULL;
4988 /* Update relevant item pointer. */
4989 *((const void **[]){ &item->spec, &item->last, &item->mask })[index] =
4994 /** Parse action configuration field. */
4996 parse_vc_conf(struct context *ctx, const struct token *token,
4997 const char *str, unsigned int len,
4998 void *buf, unsigned int size)
5000 struct buffer *out = buf;
5003 /* Token name must match. */
5004 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5006 /* Nothing else to do if there is no buffer. */
5009 /* Point to selected object. */
5010 ctx->object = out->args.vc.data;
5011 ctx->objmask = NULL;
5015 /** Parse eCPRI common header type field. */
5017 parse_vc_item_ecpri_type(struct context *ctx, const struct token *token,
5018 const char *str, unsigned int len,
5019 void *buf, unsigned int size)
5021 struct rte_flow_item_ecpri *ecpri;
5022 struct rte_flow_item_ecpri *ecpri_mask;
5023 struct rte_flow_item *item;
5026 struct buffer *out = buf;
5027 const struct arg *arg;
5030 /* Token name must match. */
5031 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5033 switch (ctx->curr) {
5034 case ITEM_ECPRI_COMMON_TYPE_IQ_DATA:
5035 msg_type = RTE_ECPRI_MSG_TYPE_IQ_DATA;
5037 case ITEM_ECPRI_COMMON_TYPE_RTC_CTRL:
5038 msg_type = RTE_ECPRI_MSG_TYPE_RTC_CTRL;
5040 case ITEM_ECPRI_COMMON_TYPE_DLY_MSR:
5041 msg_type = RTE_ECPRI_MSG_TYPE_DLY_MSR;
5048 arg = pop_args(ctx);
5051 ecpri = (struct rte_flow_item_ecpri *)out->args.vc.data;
5052 ecpri->hdr.common.type = msg_type;
5053 data_size = ctx->objdata / 3; /* spec, last, mask */
5054 ecpri_mask = (struct rte_flow_item_ecpri *)(out->args.vc.data +
5056 ecpri_mask->hdr.common.type = 0xFF;
5058 ecpri->hdr.common.u32 = rte_cpu_to_be_32(ecpri->hdr.common.u32);
5059 ecpri_mask->hdr.common.u32 =
5060 rte_cpu_to_be_32(ecpri_mask->hdr.common.u32);
5062 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
5064 item->mask = ecpri_mask;
5068 /** Parse RSS action. */
5070 parse_vc_action_rss(struct context *ctx, const struct token *token,
5071 const char *str, unsigned int len,
5072 void *buf, unsigned int size)
5074 struct buffer *out = buf;
5075 struct rte_flow_action *action;
5076 struct action_rss_data *action_rss_data;
5080 ret = parse_vc(ctx, token, str, len, buf, size);
5083 /* Nothing else to do if there is no buffer. */
5086 if (!out->args.vc.actions_n)
5088 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5089 /* Point to selected object. */
5090 ctx->object = out->args.vc.data;
5091 ctx->objmask = NULL;
5092 /* Set up default configuration. */
5093 action_rss_data = ctx->object;
5094 *action_rss_data = (struct action_rss_data){
5095 .conf = (struct rte_flow_action_rss){
5096 .func = RTE_ETH_HASH_FUNCTION_DEFAULT,
5100 .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM),
5102 .queue = action_rss_data->queue,
5106 for (i = 0; i < action_rss_data->conf.queue_num; ++i)
5107 action_rss_data->queue[i] = i;
5108 action->conf = &action_rss_data->conf;
5113 * Parse func field for RSS action.
5115 * The RTE_ETH_HASH_FUNCTION_* value to assign is derived from the
5116 * ACTION_RSS_FUNC_* index that called this function.
5119 parse_vc_action_rss_func(struct context *ctx, const struct token *token,
5120 const char *str, unsigned int len,
5121 void *buf, unsigned int size)
5123 struct action_rss_data *action_rss_data;
5124 enum rte_eth_hash_function func;
5128 /* Token name must match. */
5129 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5131 switch (ctx->curr) {
5132 case ACTION_RSS_FUNC_DEFAULT:
5133 func = RTE_ETH_HASH_FUNCTION_DEFAULT;
5135 case ACTION_RSS_FUNC_TOEPLITZ:
5136 func = RTE_ETH_HASH_FUNCTION_TOEPLITZ;
5138 case ACTION_RSS_FUNC_SIMPLE_XOR:
5139 func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
5141 case ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ:
5142 func = RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
5149 action_rss_data = ctx->object;
5150 action_rss_data->conf.func = func;
5155 * Parse type field for RSS action.
5157 * Valid tokens are type field names and the "end" token.
5160 parse_vc_action_rss_type(struct context *ctx, const struct token *token,
5161 const char *str, unsigned int len,
5162 void *buf, unsigned int size)
5164 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE);
5165 struct action_rss_data *action_rss_data;
5171 if (ctx->curr != ACTION_RSS_TYPE)
5173 if (!(ctx->objdata >> 16) && ctx->object) {
5174 action_rss_data = ctx->object;
5175 action_rss_data->conf.types = 0;
5177 if (!strcmp_partial("end", str, len)) {
5178 ctx->objdata &= 0xffff;
5181 for (i = 0; rss_type_table[i].str; ++i)
5182 if (!strcmp_partial(rss_type_table[i].str, str, len))
5184 if (!rss_type_table[i].str)
5186 ctx->objdata = 1 << 16 | (ctx->objdata & 0xffff);
5188 if (ctx->next_num == RTE_DIM(ctx->next))
5190 ctx->next[ctx->next_num++] = next;
5193 action_rss_data = ctx->object;
5194 action_rss_data->conf.types |= rss_type_table[i].rss_type;
5199 * Parse queue field for RSS action.
5201 * Valid tokens are queue indices and the "end" token.
5204 parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
5205 const char *str, unsigned int len,
5206 void *buf, unsigned int size)
5208 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE);
5209 struct action_rss_data *action_rss_data;
5210 const struct arg *arg;
5217 if (ctx->curr != ACTION_RSS_QUEUE)
5219 i = ctx->objdata >> 16;
5220 if (!strcmp_partial("end", str, len)) {
5221 ctx->objdata &= 0xffff;
5224 if (i >= ACTION_RSS_QUEUE_NUM)
5226 arg = ARGS_ENTRY_ARB(offsetof(struct action_rss_data, queue) +
5227 i * sizeof(action_rss_data->queue[i]),
5228 sizeof(action_rss_data->queue[i]));
5229 if (push_args(ctx, arg))
5231 ret = parse_int(ctx, token, str, len, NULL, 0);
5237 ctx->objdata = i << 16 | (ctx->objdata & 0xffff);
5239 if (ctx->next_num == RTE_DIM(ctx->next))
5241 ctx->next[ctx->next_num++] = next;
5245 action_rss_data = ctx->object;
5246 action_rss_data->conf.queue_num = i;
5247 action_rss_data->conf.queue = i ? action_rss_data->queue : NULL;
5251 /** Setup VXLAN encap configuration. */
5253 parse_setup_vxlan_encap_data(struct action_vxlan_encap_data *action_vxlan_encap_data)
5255 /* Set up default configuration. */
5256 *action_vxlan_encap_data = (struct action_vxlan_encap_data){
5257 .conf = (struct rte_flow_action_vxlan_encap){
5258 .definition = action_vxlan_encap_data->items,
5262 .type = RTE_FLOW_ITEM_TYPE_ETH,
5263 .spec = &action_vxlan_encap_data->item_eth,
5264 .mask = &rte_flow_item_eth_mask,
5267 .type = RTE_FLOW_ITEM_TYPE_VLAN,
5268 .spec = &action_vxlan_encap_data->item_vlan,
5269 .mask = &rte_flow_item_vlan_mask,
5272 .type = RTE_FLOW_ITEM_TYPE_IPV4,
5273 .spec = &action_vxlan_encap_data->item_ipv4,
5274 .mask = &rte_flow_item_ipv4_mask,
5277 .type = RTE_FLOW_ITEM_TYPE_UDP,
5278 .spec = &action_vxlan_encap_data->item_udp,
5279 .mask = &rte_flow_item_udp_mask,
5282 .type = RTE_FLOW_ITEM_TYPE_VXLAN,
5283 .spec = &action_vxlan_encap_data->item_vxlan,
5284 .mask = &rte_flow_item_vxlan_mask,
5287 .type = RTE_FLOW_ITEM_TYPE_END,
5292 .tci = vxlan_encap_conf.vlan_tci,
5296 .src_addr = vxlan_encap_conf.ipv4_src,
5297 .dst_addr = vxlan_encap_conf.ipv4_dst,
5300 .src_port = vxlan_encap_conf.udp_src,
5301 .dst_port = vxlan_encap_conf.udp_dst,
5303 .item_vxlan.flags = 0,
5305 memcpy(action_vxlan_encap_data->item_eth.dst.addr_bytes,
5306 vxlan_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5307 memcpy(action_vxlan_encap_data->item_eth.src.addr_bytes,
5308 vxlan_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5309 if (!vxlan_encap_conf.select_ipv4) {
5310 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.src_addr,
5311 &vxlan_encap_conf.ipv6_src,
5312 sizeof(vxlan_encap_conf.ipv6_src));
5313 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.dst_addr,
5314 &vxlan_encap_conf.ipv6_dst,
5315 sizeof(vxlan_encap_conf.ipv6_dst));
5316 action_vxlan_encap_data->items[2] = (struct rte_flow_item){
5317 .type = RTE_FLOW_ITEM_TYPE_IPV6,
5318 .spec = &action_vxlan_encap_data->item_ipv6,
5319 .mask = &rte_flow_item_ipv6_mask,
5322 if (!vxlan_encap_conf.select_vlan)
5323 action_vxlan_encap_data->items[1].type =
5324 RTE_FLOW_ITEM_TYPE_VOID;
5325 if (vxlan_encap_conf.select_tos_ttl) {
5326 if (vxlan_encap_conf.select_ipv4) {
5327 static struct rte_flow_item_ipv4 ipv4_mask_tos;
5329 memcpy(&ipv4_mask_tos, &rte_flow_item_ipv4_mask,
5330 sizeof(ipv4_mask_tos));
5331 ipv4_mask_tos.hdr.type_of_service = 0xff;
5332 ipv4_mask_tos.hdr.time_to_live = 0xff;
5333 action_vxlan_encap_data->item_ipv4.hdr.type_of_service =
5334 vxlan_encap_conf.ip_tos;
5335 action_vxlan_encap_data->item_ipv4.hdr.time_to_live =
5336 vxlan_encap_conf.ip_ttl;
5337 action_vxlan_encap_data->items[2].mask =
5340 static struct rte_flow_item_ipv6 ipv6_mask_tos;
5342 memcpy(&ipv6_mask_tos, &rte_flow_item_ipv6_mask,
5343 sizeof(ipv6_mask_tos));
5344 ipv6_mask_tos.hdr.vtc_flow |=
5345 RTE_BE32(0xfful << RTE_IPV6_HDR_TC_SHIFT);
5346 ipv6_mask_tos.hdr.hop_limits = 0xff;
5347 action_vxlan_encap_data->item_ipv6.hdr.vtc_flow |=
5349 ((uint32_t)vxlan_encap_conf.ip_tos <<
5350 RTE_IPV6_HDR_TC_SHIFT);
5351 action_vxlan_encap_data->item_ipv6.hdr.hop_limits =
5352 vxlan_encap_conf.ip_ttl;
5353 action_vxlan_encap_data->items[2].mask =
5357 memcpy(action_vxlan_encap_data->item_vxlan.vni, vxlan_encap_conf.vni,
5358 RTE_DIM(vxlan_encap_conf.vni));
5362 /** Parse VXLAN encap action. */
5364 parse_vc_action_vxlan_encap(struct context *ctx, const struct token *token,
5365 const char *str, unsigned int len,
5366 void *buf, unsigned int size)
5368 struct buffer *out = buf;
5369 struct rte_flow_action *action;
5370 struct action_vxlan_encap_data *action_vxlan_encap_data;
5373 ret = parse_vc(ctx, token, str, len, buf, size);
5376 /* Nothing else to do if there is no buffer. */
5379 if (!out->args.vc.actions_n)
5381 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5382 /* Point to selected object. */
5383 ctx->object = out->args.vc.data;
5384 ctx->objmask = NULL;
5385 action_vxlan_encap_data = ctx->object;
5386 parse_setup_vxlan_encap_data(action_vxlan_encap_data);
5387 action->conf = &action_vxlan_encap_data->conf;
5391 /** Setup NVGRE encap configuration. */
5393 parse_setup_nvgre_encap_data(struct action_nvgre_encap_data *action_nvgre_encap_data)
5395 /* Set up default configuration. */
5396 *action_nvgre_encap_data = (struct action_nvgre_encap_data){
5397 .conf = (struct rte_flow_action_nvgre_encap){
5398 .definition = action_nvgre_encap_data->items,
5402 .type = RTE_FLOW_ITEM_TYPE_ETH,
5403 .spec = &action_nvgre_encap_data->item_eth,
5404 .mask = &rte_flow_item_eth_mask,
5407 .type = RTE_FLOW_ITEM_TYPE_VLAN,
5408 .spec = &action_nvgre_encap_data->item_vlan,
5409 .mask = &rte_flow_item_vlan_mask,
5412 .type = RTE_FLOW_ITEM_TYPE_IPV4,
5413 .spec = &action_nvgre_encap_data->item_ipv4,
5414 .mask = &rte_flow_item_ipv4_mask,
5417 .type = RTE_FLOW_ITEM_TYPE_NVGRE,
5418 .spec = &action_nvgre_encap_data->item_nvgre,
5419 .mask = &rte_flow_item_nvgre_mask,
5422 .type = RTE_FLOW_ITEM_TYPE_END,
5427 .tci = nvgre_encap_conf.vlan_tci,
5431 .src_addr = nvgre_encap_conf.ipv4_src,
5432 .dst_addr = nvgre_encap_conf.ipv4_dst,
5434 .item_nvgre.c_k_s_rsvd0_ver = RTE_BE16(0x2000),
5435 .item_nvgre.protocol = RTE_BE16(RTE_ETHER_TYPE_TEB),
5436 .item_nvgre.flow_id = 0,
5438 memcpy(action_nvgre_encap_data->item_eth.dst.addr_bytes,
5439 nvgre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5440 memcpy(action_nvgre_encap_data->item_eth.src.addr_bytes,
5441 nvgre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5442 if (!nvgre_encap_conf.select_ipv4) {
5443 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.src_addr,
5444 &nvgre_encap_conf.ipv6_src,
5445 sizeof(nvgre_encap_conf.ipv6_src));
5446 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.dst_addr,
5447 &nvgre_encap_conf.ipv6_dst,
5448 sizeof(nvgre_encap_conf.ipv6_dst));
5449 action_nvgre_encap_data->items[2] = (struct rte_flow_item){
5450 .type = RTE_FLOW_ITEM_TYPE_IPV6,
5451 .spec = &action_nvgre_encap_data->item_ipv6,
5452 .mask = &rte_flow_item_ipv6_mask,
5455 if (!nvgre_encap_conf.select_vlan)
5456 action_nvgre_encap_data->items[1].type =
5457 RTE_FLOW_ITEM_TYPE_VOID;
5458 memcpy(action_nvgre_encap_data->item_nvgre.tni, nvgre_encap_conf.tni,
5459 RTE_DIM(nvgre_encap_conf.tni));
5463 /** Parse NVGRE encap action. */
5465 parse_vc_action_nvgre_encap(struct context *ctx, const struct token *token,
5466 const char *str, unsigned int len,
5467 void *buf, unsigned int size)
5469 struct buffer *out = buf;
5470 struct rte_flow_action *action;
5471 struct action_nvgre_encap_data *action_nvgre_encap_data;
5474 ret = parse_vc(ctx, token, str, len, buf, size);
5477 /* Nothing else to do if there is no buffer. */
5480 if (!out->args.vc.actions_n)
5482 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5483 /* Point to selected object. */
5484 ctx->object = out->args.vc.data;
5485 ctx->objmask = NULL;
5486 action_nvgre_encap_data = ctx->object;
5487 parse_setup_nvgre_encap_data(action_nvgre_encap_data);
5488 action->conf = &action_nvgre_encap_data->conf;
5492 /** Parse l2 encap action. */
5494 parse_vc_action_l2_encap(struct context *ctx, const struct token *token,
5495 const char *str, unsigned int len,
5496 void *buf, unsigned int size)
5498 struct buffer *out = buf;
5499 struct rte_flow_action *action;
5500 struct action_raw_encap_data *action_encap_data;
5501 struct rte_flow_item_eth eth = { .type = 0, };
5502 struct rte_flow_item_vlan vlan = {
5503 .tci = mplsoudp_encap_conf.vlan_tci,
5509 ret = parse_vc(ctx, token, str, len, buf, size);
5512 /* Nothing else to do if there is no buffer. */
5515 if (!out->args.vc.actions_n)
5517 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5518 /* Point to selected object. */
5519 ctx->object = out->args.vc.data;
5520 ctx->objmask = NULL;
5521 /* Copy the headers to the buffer. */
5522 action_encap_data = ctx->object;
5523 *action_encap_data = (struct action_raw_encap_data) {
5524 .conf = (struct rte_flow_action_raw_encap){
5525 .data = action_encap_data->data,
5529 header = action_encap_data->data;
5530 if (l2_encap_conf.select_vlan)
5531 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5532 else if (l2_encap_conf.select_ipv4)
5533 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5535 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5536 memcpy(eth.dst.addr_bytes,
5537 l2_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5538 memcpy(eth.src.addr_bytes,
5539 l2_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5540 memcpy(header, ð, sizeof(eth));
5541 header += sizeof(eth);
5542 if (l2_encap_conf.select_vlan) {
5543 if (l2_encap_conf.select_ipv4)
5544 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5546 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5547 memcpy(header, &vlan, sizeof(vlan));
5548 header += sizeof(vlan);
5550 action_encap_data->conf.size = header -
5551 action_encap_data->data;
5552 action->conf = &action_encap_data->conf;
5556 /** Parse l2 decap action. */
5558 parse_vc_action_l2_decap(struct context *ctx, const struct token *token,
5559 const char *str, unsigned int len,
5560 void *buf, unsigned int size)
5562 struct buffer *out = buf;
5563 struct rte_flow_action *action;
5564 struct action_raw_decap_data *action_decap_data;
5565 struct rte_flow_item_eth eth = { .type = 0, };
5566 struct rte_flow_item_vlan vlan = {
5567 .tci = mplsoudp_encap_conf.vlan_tci,
5573 ret = parse_vc(ctx, token, str, len, buf, size);
5576 /* Nothing else to do if there is no buffer. */
5579 if (!out->args.vc.actions_n)
5581 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5582 /* Point to selected object. */
5583 ctx->object = out->args.vc.data;
5584 ctx->objmask = NULL;
5585 /* Copy the headers to the buffer. */
5586 action_decap_data = ctx->object;
5587 *action_decap_data = (struct action_raw_decap_data) {
5588 .conf = (struct rte_flow_action_raw_decap){
5589 .data = action_decap_data->data,
5593 header = action_decap_data->data;
5594 if (l2_decap_conf.select_vlan)
5595 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5596 memcpy(header, ð, sizeof(eth));
5597 header += sizeof(eth);
5598 if (l2_decap_conf.select_vlan) {
5599 memcpy(header, &vlan, sizeof(vlan));
5600 header += sizeof(vlan);
5602 action_decap_data->conf.size = header -
5603 action_decap_data->data;
5604 action->conf = &action_decap_data->conf;
5608 #define ETHER_TYPE_MPLS_UNICAST 0x8847
5610 /** Parse MPLSOGRE encap action. */
5612 parse_vc_action_mplsogre_encap(struct context *ctx, const struct token *token,
5613 const char *str, unsigned int len,
5614 void *buf, unsigned int size)
5616 struct buffer *out = buf;
5617 struct rte_flow_action *action;
5618 struct action_raw_encap_data *action_encap_data;
5619 struct rte_flow_item_eth eth = { .type = 0, };
5620 struct rte_flow_item_vlan vlan = {
5621 .tci = mplsogre_encap_conf.vlan_tci,
5624 struct rte_flow_item_ipv4 ipv4 = {
5626 .src_addr = mplsogre_encap_conf.ipv4_src,
5627 .dst_addr = mplsogre_encap_conf.ipv4_dst,
5628 .next_proto_id = IPPROTO_GRE,
5629 .version_ihl = RTE_IPV4_VHL_DEF,
5630 .time_to_live = IPDEFTTL,
5633 struct rte_flow_item_ipv6 ipv6 = {
5635 .proto = IPPROTO_GRE,
5636 .hop_limits = IPDEFTTL,
5639 struct rte_flow_item_gre gre = {
5640 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
5642 struct rte_flow_item_mpls mpls = {
5648 ret = parse_vc(ctx, token, str, len, buf, size);
5651 /* Nothing else to do if there is no buffer. */
5654 if (!out->args.vc.actions_n)
5656 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5657 /* Point to selected object. */
5658 ctx->object = out->args.vc.data;
5659 ctx->objmask = NULL;
5660 /* Copy the headers to the buffer. */
5661 action_encap_data = ctx->object;
5662 *action_encap_data = (struct action_raw_encap_data) {
5663 .conf = (struct rte_flow_action_raw_encap){
5664 .data = action_encap_data->data,
5669 header = action_encap_data->data;
5670 if (mplsogre_encap_conf.select_vlan)
5671 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5672 else if (mplsogre_encap_conf.select_ipv4)
5673 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5675 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5676 memcpy(eth.dst.addr_bytes,
5677 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5678 memcpy(eth.src.addr_bytes,
5679 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5680 memcpy(header, ð, sizeof(eth));
5681 header += sizeof(eth);
5682 if (mplsogre_encap_conf.select_vlan) {
5683 if (mplsogre_encap_conf.select_ipv4)
5684 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5686 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5687 memcpy(header, &vlan, sizeof(vlan));
5688 header += sizeof(vlan);
5690 if (mplsogre_encap_conf.select_ipv4) {
5691 memcpy(header, &ipv4, sizeof(ipv4));
5692 header += sizeof(ipv4);
5694 memcpy(&ipv6.hdr.src_addr,
5695 &mplsogre_encap_conf.ipv6_src,
5696 sizeof(mplsogre_encap_conf.ipv6_src));
5697 memcpy(&ipv6.hdr.dst_addr,
5698 &mplsogre_encap_conf.ipv6_dst,
5699 sizeof(mplsogre_encap_conf.ipv6_dst));
5700 memcpy(header, &ipv6, sizeof(ipv6));
5701 header += sizeof(ipv6);
5703 memcpy(header, &gre, sizeof(gre));
5704 header += sizeof(gre);
5705 memcpy(mpls.label_tc_s, mplsogre_encap_conf.label,
5706 RTE_DIM(mplsogre_encap_conf.label));
5707 mpls.label_tc_s[2] |= 0x1;
5708 memcpy(header, &mpls, sizeof(mpls));
5709 header += sizeof(mpls);
5710 action_encap_data->conf.size = header -
5711 action_encap_data->data;
5712 action->conf = &action_encap_data->conf;
5716 /** Parse MPLSOGRE decap action. */
5718 parse_vc_action_mplsogre_decap(struct context *ctx, const struct token *token,
5719 const char *str, unsigned int len,
5720 void *buf, unsigned int size)
5722 struct buffer *out = buf;
5723 struct rte_flow_action *action;
5724 struct action_raw_decap_data *action_decap_data;
5725 struct rte_flow_item_eth eth = { .type = 0, };
5726 struct rte_flow_item_vlan vlan = {.tci = 0};
5727 struct rte_flow_item_ipv4 ipv4 = {
5729 .next_proto_id = IPPROTO_GRE,
5732 struct rte_flow_item_ipv6 ipv6 = {
5734 .proto = IPPROTO_GRE,
5737 struct rte_flow_item_gre gre = {
5738 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
5740 struct rte_flow_item_mpls mpls;
5744 ret = parse_vc(ctx, token, str, len, buf, size);
5747 /* Nothing else to do if there is no buffer. */
5750 if (!out->args.vc.actions_n)
5752 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5753 /* Point to selected object. */
5754 ctx->object = out->args.vc.data;
5755 ctx->objmask = NULL;
5756 /* Copy the headers to the buffer. */
5757 action_decap_data = ctx->object;
5758 *action_decap_data = (struct action_raw_decap_data) {
5759 .conf = (struct rte_flow_action_raw_decap){
5760 .data = action_decap_data->data,
5764 header = action_decap_data->data;
5765 if (mplsogre_decap_conf.select_vlan)
5766 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5767 else if (mplsogre_encap_conf.select_ipv4)
5768 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5770 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5771 memcpy(eth.dst.addr_bytes,
5772 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5773 memcpy(eth.src.addr_bytes,
5774 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5775 memcpy(header, ð, sizeof(eth));
5776 header += sizeof(eth);
5777 if (mplsogre_encap_conf.select_vlan) {
5778 if (mplsogre_encap_conf.select_ipv4)
5779 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5781 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5782 memcpy(header, &vlan, sizeof(vlan));
5783 header += sizeof(vlan);
5785 if (mplsogre_encap_conf.select_ipv4) {
5786 memcpy(header, &ipv4, sizeof(ipv4));
5787 header += sizeof(ipv4);
5789 memcpy(header, &ipv6, sizeof(ipv6));
5790 header += sizeof(ipv6);
5792 memcpy(header, &gre, sizeof(gre));
5793 header += sizeof(gre);
5794 memset(&mpls, 0, sizeof(mpls));
5795 memcpy(header, &mpls, sizeof(mpls));
5796 header += sizeof(mpls);
5797 action_decap_data->conf.size = header -
5798 action_decap_data->data;
5799 action->conf = &action_decap_data->conf;
5803 /** Parse MPLSOUDP encap action. */
5805 parse_vc_action_mplsoudp_encap(struct context *ctx, const struct token *token,
5806 const char *str, unsigned int len,
5807 void *buf, unsigned int size)
5809 struct buffer *out = buf;
5810 struct rte_flow_action *action;
5811 struct action_raw_encap_data *action_encap_data;
5812 struct rte_flow_item_eth eth = { .type = 0, };
5813 struct rte_flow_item_vlan vlan = {
5814 .tci = mplsoudp_encap_conf.vlan_tci,
5817 struct rte_flow_item_ipv4 ipv4 = {
5819 .src_addr = mplsoudp_encap_conf.ipv4_src,
5820 .dst_addr = mplsoudp_encap_conf.ipv4_dst,
5821 .next_proto_id = IPPROTO_UDP,
5822 .version_ihl = RTE_IPV4_VHL_DEF,
5823 .time_to_live = IPDEFTTL,
5826 struct rte_flow_item_ipv6 ipv6 = {
5828 .proto = IPPROTO_UDP,
5829 .hop_limits = IPDEFTTL,
5832 struct rte_flow_item_udp udp = {
5834 .src_port = mplsoudp_encap_conf.udp_src,
5835 .dst_port = mplsoudp_encap_conf.udp_dst,
5838 struct rte_flow_item_mpls mpls;
5842 ret = parse_vc(ctx, token, str, len, buf, size);
5845 /* Nothing else to do if there is no buffer. */
5848 if (!out->args.vc.actions_n)
5850 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5851 /* Point to selected object. */
5852 ctx->object = out->args.vc.data;
5853 ctx->objmask = NULL;
5854 /* Copy the headers to the buffer. */
5855 action_encap_data = ctx->object;
5856 *action_encap_data = (struct action_raw_encap_data) {
5857 .conf = (struct rte_flow_action_raw_encap){
5858 .data = action_encap_data->data,
5863 header = action_encap_data->data;
5864 if (mplsoudp_encap_conf.select_vlan)
5865 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5866 else if (mplsoudp_encap_conf.select_ipv4)
5867 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5869 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5870 memcpy(eth.dst.addr_bytes,
5871 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5872 memcpy(eth.src.addr_bytes,
5873 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5874 memcpy(header, ð, sizeof(eth));
5875 header += sizeof(eth);
5876 if (mplsoudp_encap_conf.select_vlan) {
5877 if (mplsoudp_encap_conf.select_ipv4)
5878 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5880 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5881 memcpy(header, &vlan, sizeof(vlan));
5882 header += sizeof(vlan);
5884 if (mplsoudp_encap_conf.select_ipv4) {
5885 memcpy(header, &ipv4, sizeof(ipv4));
5886 header += sizeof(ipv4);
5888 memcpy(&ipv6.hdr.src_addr,
5889 &mplsoudp_encap_conf.ipv6_src,
5890 sizeof(mplsoudp_encap_conf.ipv6_src));
5891 memcpy(&ipv6.hdr.dst_addr,
5892 &mplsoudp_encap_conf.ipv6_dst,
5893 sizeof(mplsoudp_encap_conf.ipv6_dst));
5894 memcpy(header, &ipv6, sizeof(ipv6));
5895 header += sizeof(ipv6);
5897 memcpy(header, &udp, sizeof(udp));
5898 header += sizeof(udp);
5899 memcpy(mpls.label_tc_s, mplsoudp_encap_conf.label,
5900 RTE_DIM(mplsoudp_encap_conf.label));
5901 mpls.label_tc_s[2] |= 0x1;
5902 memcpy(header, &mpls, sizeof(mpls));
5903 header += sizeof(mpls);
5904 action_encap_data->conf.size = header -
5905 action_encap_data->data;
5906 action->conf = &action_encap_data->conf;
5910 /** Parse MPLSOUDP decap action. */
5912 parse_vc_action_mplsoudp_decap(struct context *ctx, const struct token *token,
5913 const char *str, unsigned int len,
5914 void *buf, unsigned int size)
5916 struct buffer *out = buf;
5917 struct rte_flow_action *action;
5918 struct action_raw_decap_data *action_decap_data;
5919 struct rte_flow_item_eth eth = { .type = 0, };
5920 struct rte_flow_item_vlan vlan = {.tci = 0};
5921 struct rte_flow_item_ipv4 ipv4 = {
5923 .next_proto_id = IPPROTO_UDP,
5926 struct rte_flow_item_ipv6 ipv6 = {
5928 .proto = IPPROTO_UDP,
5931 struct rte_flow_item_udp udp = {
5933 .dst_port = rte_cpu_to_be_16(6635),
5936 struct rte_flow_item_mpls mpls;
5940 ret = parse_vc(ctx, token, str, len, buf, size);
5943 /* Nothing else to do if there is no buffer. */
5946 if (!out->args.vc.actions_n)
5948 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5949 /* Point to selected object. */
5950 ctx->object = out->args.vc.data;
5951 ctx->objmask = NULL;
5952 /* Copy the headers to the buffer. */
5953 action_decap_data = ctx->object;
5954 *action_decap_data = (struct action_raw_decap_data) {
5955 .conf = (struct rte_flow_action_raw_decap){
5956 .data = action_decap_data->data,
5960 header = action_decap_data->data;
5961 if (mplsoudp_decap_conf.select_vlan)
5962 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5963 else if (mplsoudp_encap_conf.select_ipv4)
5964 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5966 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5967 memcpy(eth.dst.addr_bytes,
5968 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5969 memcpy(eth.src.addr_bytes,
5970 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5971 memcpy(header, ð, sizeof(eth));
5972 header += sizeof(eth);
5973 if (mplsoudp_encap_conf.select_vlan) {
5974 if (mplsoudp_encap_conf.select_ipv4)
5975 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5977 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5978 memcpy(header, &vlan, sizeof(vlan));
5979 header += sizeof(vlan);
5981 if (mplsoudp_encap_conf.select_ipv4) {
5982 memcpy(header, &ipv4, sizeof(ipv4));
5983 header += sizeof(ipv4);
5985 memcpy(header, &ipv6, sizeof(ipv6));
5986 header += sizeof(ipv6);
5988 memcpy(header, &udp, sizeof(udp));
5989 header += sizeof(udp);
5990 memset(&mpls, 0, sizeof(mpls));
5991 memcpy(header, &mpls, sizeof(mpls));
5992 header += sizeof(mpls);
5993 action_decap_data->conf.size = header -
5994 action_decap_data->data;
5995 action->conf = &action_decap_data->conf;
6000 parse_vc_action_raw_decap_index(struct context *ctx, const struct token *token,
6001 const char *str, unsigned int len, void *buf,
6004 struct action_raw_decap_data *action_raw_decap_data;
6005 struct rte_flow_action *action;
6006 const struct arg *arg;
6007 struct buffer *out = buf;
6011 RTE_SET_USED(token);
6014 arg = ARGS_ENTRY_ARB_BOUNDED
6015 (offsetof(struct action_raw_decap_data, idx),
6016 sizeof(((struct action_raw_decap_data *)0)->idx),
6017 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
6018 if (push_args(ctx, arg))
6020 ret = parse_int(ctx, token, str, len, NULL, 0);
6027 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6028 action_raw_decap_data = ctx->object;
6029 idx = action_raw_decap_data->idx;
6030 action_raw_decap_data->conf.data = raw_decap_confs[idx].data;
6031 action_raw_decap_data->conf.size = raw_decap_confs[idx].size;
6032 action->conf = &action_raw_decap_data->conf;
6038 parse_vc_action_raw_encap_index(struct context *ctx, const struct token *token,
6039 const char *str, unsigned int len, void *buf,
6042 struct action_raw_encap_data *action_raw_encap_data;
6043 struct rte_flow_action *action;
6044 const struct arg *arg;
6045 struct buffer *out = buf;
6049 RTE_SET_USED(token);
6052 if (ctx->curr != ACTION_RAW_ENCAP_INDEX_VALUE)
6054 arg = ARGS_ENTRY_ARB_BOUNDED
6055 (offsetof(struct action_raw_encap_data, idx),
6056 sizeof(((struct action_raw_encap_data *)0)->idx),
6057 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
6058 if (push_args(ctx, arg))
6060 ret = parse_int(ctx, token, str, len, NULL, 0);
6067 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6068 action_raw_encap_data = ctx->object;
6069 idx = action_raw_encap_data->idx;
6070 action_raw_encap_data->conf.data = raw_encap_confs[idx].data;
6071 action_raw_encap_data->conf.size = raw_encap_confs[idx].size;
6072 action_raw_encap_data->conf.preserve = NULL;
6073 action->conf = &action_raw_encap_data->conf;
6078 parse_vc_action_raw_encap(struct context *ctx, const struct token *token,
6079 const char *str, unsigned int len, void *buf,
6082 struct buffer *out = buf;
6083 struct rte_flow_action *action;
6084 struct action_raw_encap_data *action_raw_encap_data = NULL;
6087 ret = parse_vc(ctx, token, str, len, buf, size);
6090 /* Nothing else to do if there is no buffer. */
6093 if (!out->args.vc.actions_n)
6095 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6096 /* Point to selected object. */
6097 ctx->object = out->args.vc.data;
6098 ctx->objmask = NULL;
6099 /* Copy the headers to the buffer. */
6100 action_raw_encap_data = ctx->object;
6101 action_raw_encap_data->conf.data = raw_encap_confs[0].data;
6102 action_raw_encap_data->conf.preserve = NULL;
6103 action_raw_encap_data->conf.size = raw_encap_confs[0].size;
6104 action->conf = &action_raw_encap_data->conf;
6109 parse_vc_action_raw_decap(struct context *ctx, const struct token *token,
6110 const char *str, unsigned int len, void *buf,
6113 struct buffer *out = buf;
6114 struct rte_flow_action *action;
6115 struct action_raw_decap_data *action_raw_decap_data = NULL;
6118 ret = parse_vc(ctx, token, str, len, buf, size);
6121 /* Nothing else to do if there is no buffer. */
6124 if (!out->args.vc.actions_n)
6126 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6127 /* Point to selected object. */
6128 ctx->object = out->args.vc.data;
6129 ctx->objmask = NULL;
6130 /* Copy the headers to the buffer. */
6131 action_raw_decap_data = ctx->object;
6132 action_raw_decap_data->conf.data = raw_decap_confs[0].data;
6133 action_raw_decap_data->conf.size = raw_decap_confs[0].size;
6134 action->conf = &action_raw_decap_data->conf;
6139 parse_vc_action_set_meta(struct context *ctx, const struct token *token,
6140 const char *str, unsigned int len, void *buf,
6145 ret = parse_vc(ctx, token, str, len, buf, size);
6148 ret = rte_flow_dynf_metadata_register();
6155 parse_vc_action_sample(struct context *ctx, const struct token *token,
6156 const char *str, unsigned int len, void *buf,
6159 struct buffer *out = buf;
6160 struct rte_flow_action *action;
6161 struct action_sample_data *action_sample_data = NULL;
6162 static struct rte_flow_action end_action = {
6163 RTE_FLOW_ACTION_TYPE_END, 0
6167 ret = parse_vc(ctx, token, str, len, buf, size);
6170 /* Nothing else to do if there is no buffer. */
6173 if (!out->args.vc.actions_n)
6175 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6176 /* Point to selected object. */
6177 ctx->object = out->args.vc.data;
6178 ctx->objmask = NULL;
6179 /* Copy the headers to the buffer. */
6180 action_sample_data = ctx->object;
6181 action_sample_data->conf.actions = &end_action;
6182 action->conf = &action_sample_data->conf;
6187 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
6188 const char *str, unsigned int len, void *buf,
6191 struct action_sample_data *action_sample_data;
6192 struct rte_flow_action *action;
6193 const struct arg *arg;
6194 struct buffer *out = buf;
6198 RTE_SET_USED(token);
6201 if (ctx->curr != ACTION_SAMPLE_INDEX_VALUE)
6203 arg = ARGS_ENTRY_ARB_BOUNDED
6204 (offsetof(struct action_sample_data, idx),
6205 sizeof(((struct action_sample_data *)0)->idx),
6206 0, RAW_SAMPLE_CONFS_MAX_NUM - 1);
6207 if (push_args(ctx, arg))
6209 ret = parse_int(ctx, token, str, len, NULL, 0);
6216 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6217 action_sample_data = ctx->object;
6218 idx = action_sample_data->idx;
6219 action_sample_data->conf.actions = raw_sample_confs[idx].data;
6220 action->conf = &action_sample_data->conf;
6224 /** Parse operation for modify_field command. */
6226 parse_vc_modify_field_op(struct context *ctx, const struct token *token,
6227 const char *str, unsigned int len, void *buf,
6230 struct rte_flow_action_modify_field *action_modify_field;
6236 if (ctx->curr != ACTION_MODIFY_FIELD_OP_VALUE)
6238 for (i = 0; modify_field_ops[i]; ++i)
6239 if (!strcmp_partial(modify_field_ops[i], str, len))
6241 if (!modify_field_ops[i])
6245 action_modify_field = ctx->object;
6246 action_modify_field->operation = (enum rte_flow_modify_op)i;
6250 /** Parse id for modify_field command. */
6252 parse_vc_modify_field_id(struct context *ctx, const struct token *token,
6253 const char *str, unsigned int len, void *buf,
6256 struct rte_flow_action_modify_field *action_modify_field;
6262 if (ctx->curr != ACTION_MODIFY_FIELD_DST_TYPE_VALUE &&
6263 ctx->curr != ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)
6265 for (i = 0; modify_field_ids[i]; ++i)
6266 if (!strcmp_partial(modify_field_ids[i], str, len))
6268 if (!modify_field_ids[i])
6272 action_modify_field = ctx->object;
6273 if (ctx->curr == ACTION_MODIFY_FIELD_DST_TYPE_VALUE)
6274 action_modify_field->dst.field = (enum rte_flow_field_id)i;
6276 action_modify_field->src.field = (enum rte_flow_field_id)i;
6280 /** Parse tokens for destroy command. */
6282 parse_destroy(struct context *ctx, const struct token *token,
6283 const char *str, unsigned int len,
6284 void *buf, unsigned int size)
6286 struct buffer *out = buf;
6288 /* Token name must match. */
6289 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6291 /* Nothing else to do if there is no buffer. */
6294 if (!out->command) {
6295 if (ctx->curr != DESTROY)
6297 if (sizeof(*out) > size)
6299 out->command = ctx->curr;
6302 ctx->objmask = NULL;
6303 out->args.destroy.rule =
6304 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6308 if (((uint8_t *)(out->args.destroy.rule + out->args.destroy.rule_n) +
6309 sizeof(*out->args.destroy.rule)) > (uint8_t *)out + size)
6312 ctx->object = out->args.destroy.rule + out->args.destroy.rule_n++;
6313 ctx->objmask = NULL;
6317 /** Parse tokens for flush command. */
6319 parse_flush(struct context *ctx, const struct token *token,
6320 const char *str, unsigned int len,
6321 void *buf, unsigned int size)
6323 struct buffer *out = buf;
6325 /* Token name must match. */
6326 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6328 /* Nothing else to do if there is no buffer. */
6331 if (!out->command) {
6332 if (ctx->curr != FLUSH)
6334 if (sizeof(*out) > size)
6336 out->command = ctx->curr;
6339 ctx->objmask = NULL;
6344 /** Parse tokens for dump command. */
6346 parse_dump(struct context *ctx, const struct token *token,
6347 const char *str, unsigned int len,
6348 void *buf, unsigned int size)
6350 struct buffer *out = buf;
6352 /* Token name must match. */
6353 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6355 /* Nothing else to do if there is no buffer. */
6358 if (!out->command) {
6359 if (ctx->curr != DUMP)
6361 if (sizeof(*out) > size)
6363 out->command = ctx->curr;
6366 ctx->objmask = NULL;
6371 /** Parse tokens for query command. */
6373 parse_query(struct context *ctx, const struct token *token,
6374 const char *str, unsigned int len,
6375 void *buf, unsigned int size)
6377 struct buffer *out = buf;
6379 /* Token name must match. */
6380 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6382 /* Nothing else to do if there is no buffer. */
6385 if (!out->command) {
6386 if (ctx->curr != QUERY)
6388 if (sizeof(*out) > size)
6390 out->command = ctx->curr;
6393 ctx->objmask = NULL;
6398 /** Parse action names. */
6400 parse_action(struct context *ctx, const struct token *token,
6401 const char *str, unsigned int len,
6402 void *buf, unsigned int size)
6404 struct buffer *out = buf;
6405 const struct arg *arg = pop_args(ctx);
6409 /* Argument is expected. */
6412 /* Parse action name. */
6413 for (i = 0; next_action[i]; ++i) {
6414 const struct parse_action_priv *priv;
6416 token = &token_list[next_action[i]];
6417 if (strcmp_partial(token->name, str, len))
6423 memcpy((uint8_t *)ctx->object + arg->offset,
6429 push_args(ctx, arg);
6433 /** Parse tokens for list command. */
6435 parse_list(struct context *ctx, const struct token *token,
6436 const char *str, unsigned int len,
6437 void *buf, unsigned int size)
6439 struct buffer *out = buf;
6441 /* Token name must match. */
6442 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6444 /* Nothing else to do if there is no buffer. */
6447 if (!out->command) {
6448 if (ctx->curr != LIST)
6450 if (sizeof(*out) > size)
6452 out->command = ctx->curr;
6455 ctx->objmask = NULL;
6456 out->args.list.group =
6457 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6461 if (((uint8_t *)(out->args.list.group + out->args.list.group_n) +
6462 sizeof(*out->args.list.group)) > (uint8_t *)out + size)
6465 ctx->object = out->args.list.group + out->args.list.group_n++;
6466 ctx->objmask = NULL;
6470 /** Parse tokens for list all aged flows command. */
6472 parse_aged(struct context *ctx, const struct token *token,
6473 const char *str, unsigned int len,
6474 void *buf, unsigned int size)
6476 struct buffer *out = buf;
6478 /* Token name must match. */
6479 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6481 /* Nothing else to do if there is no buffer. */
6484 if (!out->command) {
6485 if (ctx->curr != AGED)
6487 if (sizeof(*out) > size)
6489 out->command = ctx->curr;
6492 ctx->objmask = NULL;
6494 if (ctx->curr == AGED_DESTROY)
6495 out->args.aged.destroy = 1;
6499 /** Parse tokens for isolate command. */
6501 parse_isolate(struct context *ctx, const struct token *token,
6502 const char *str, unsigned int len,
6503 void *buf, unsigned int size)
6505 struct buffer *out = buf;
6507 /* Token name must match. */
6508 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6510 /* Nothing else to do if there is no buffer. */
6513 if (!out->command) {
6514 if (ctx->curr != ISOLATE)
6516 if (sizeof(*out) > size)
6518 out->command = ctx->curr;
6521 ctx->objmask = NULL;
6527 parse_tunnel(struct context *ctx, const struct token *token,
6528 const char *str, unsigned int len,
6529 void *buf, unsigned int size)
6531 struct buffer *out = buf;
6533 /* Token name must match. */
6534 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6536 /* Nothing else to do if there is no buffer. */
6539 if (!out->command) {
6540 if (ctx->curr != TUNNEL)
6542 if (sizeof(*out) > size)
6544 out->command = ctx->curr;
6547 ctx->objmask = NULL;
6549 switch (ctx->curr) {
6553 case TUNNEL_DESTROY:
6555 out->command = ctx->curr;
6557 case TUNNEL_CREATE_TYPE:
6558 case TUNNEL_DESTROY_ID:
6559 ctx->object = &out->args.vc.tunnel_ops;
6568 * Parse signed/unsigned integers 8 to 64-bit long.
6570 * Last argument (ctx->args) is retrieved to determine integer type and
6574 parse_int(struct context *ctx, const struct token *token,
6575 const char *str, unsigned int len,
6576 void *buf, unsigned int size)
6578 const struct arg *arg = pop_args(ctx);
6583 /* Argument is expected. */
6588 (uintmax_t)strtoimax(str, &end, 0) :
6589 strtoumax(str, &end, 0);
6590 if (errno || (size_t)(end - str) != len)
6593 ((arg->sign && ((intmax_t)u < (intmax_t)arg->min ||
6594 (intmax_t)u > (intmax_t)arg->max)) ||
6595 (!arg->sign && (u < arg->min || u > arg->max))))
6600 if (!arg_entry_bf_fill(ctx->object, u, arg) ||
6601 !arg_entry_bf_fill(ctx->objmask, -1, arg))
6605 buf = (uint8_t *)ctx->object + arg->offset;
6607 if (u > RTE_LEN2MASK(size * CHAR_BIT, uint64_t))
6611 case sizeof(uint8_t):
6612 *(uint8_t *)buf = u;
6614 case sizeof(uint16_t):
6615 *(uint16_t *)buf = arg->hton ? rte_cpu_to_be_16(u) : u;
6617 case sizeof(uint8_t [3]):
6618 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
6620 ((uint8_t *)buf)[0] = u;
6621 ((uint8_t *)buf)[1] = u >> 8;
6622 ((uint8_t *)buf)[2] = u >> 16;
6626 ((uint8_t *)buf)[0] = u >> 16;
6627 ((uint8_t *)buf)[1] = u >> 8;
6628 ((uint8_t *)buf)[2] = u;
6630 case sizeof(uint32_t):
6631 *(uint32_t *)buf = arg->hton ? rte_cpu_to_be_32(u) : u;
6633 case sizeof(uint64_t):
6634 *(uint64_t *)buf = arg->hton ? rte_cpu_to_be_64(u) : u;
6639 if (ctx->objmask && buf != (uint8_t *)ctx->objmask + arg->offset) {
6641 buf = (uint8_t *)ctx->objmask + arg->offset;
6646 push_args(ctx, arg);
6653 * Three arguments (ctx->args) are retrieved from the stack to store data,
6654 * its actual length and address (in that order).
6657 parse_string(struct context *ctx, const struct token *token,
6658 const char *str, unsigned int len,
6659 void *buf, unsigned int size)
6661 const struct arg *arg_data = pop_args(ctx);
6662 const struct arg *arg_len = pop_args(ctx);
6663 const struct arg *arg_addr = pop_args(ctx);
6664 char tmp[16]; /* Ought to be enough. */
6667 /* Arguments are expected. */
6671 push_args(ctx, arg_data);
6675 push_args(ctx, arg_len);
6676 push_args(ctx, arg_data);
6679 size = arg_data->size;
6680 /* Bit-mask fill is not supported. */
6681 if (arg_data->mask || size < len)
6685 /* Let parse_int() fill length information first. */
6686 ret = snprintf(tmp, sizeof(tmp), "%u", len);
6689 push_args(ctx, arg_len);
6690 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
6695 buf = (uint8_t *)ctx->object + arg_data->offset;
6696 /* Output buffer is not necessarily NUL-terminated. */
6697 memcpy(buf, str, len);
6698 memset((uint8_t *)buf + len, 0x00, size - len);
6700 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
6701 /* Save address if requested. */
6702 if (arg_addr->size) {
6703 memcpy((uint8_t *)ctx->object + arg_addr->offset,
6705 (uint8_t *)ctx->object + arg_data->offset
6709 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
6711 (uint8_t *)ctx->objmask + arg_data->offset
6717 push_args(ctx, arg_addr);
6718 push_args(ctx, arg_len);
6719 push_args(ctx, arg_data);
6724 parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
6730 /* Check input parameters */
6731 if ((src == NULL) ||
6737 /* Convert chars to bytes */
6738 for (i = 0, len = 0; i < *size; i += 2) {
6739 snprintf(tmp, 3, "%s", src + i);
6740 dst[len++] = strtoul(tmp, &c, 16);
6755 parse_hex(struct context *ctx, const struct token *token,
6756 const char *str, unsigned int len,
6757 void *buf, unsigned int size)
6759 const struct arg *arg_data = pop_args(ctx);
6760 const struct arg *arg_len = pop_args(ctx);
6761 const struct arg *arg_addr = pop_args(ctx);
6762 char tmp[16]; /* Ought to be enough. */
6764 unsigned int hexlen = len;
6765 unsigned int length = 256;
6766 uint8_t hex_tmp[length];
6768 /* Arguments are expected. */
6772 push_args(ctx, arg_data);
6776 push_args(ctx, arg_len);
6777 push_args(ctx, arg_data);
6780 size = arg_data->size;
6781 /* Bit-mask fill is not supported. */
6787 /* translate bytes string to array. */
6788 if (str[0] == '0' && ((str[1] == 'x') ||
6793 if (hexlen > length)
6795 ret = parse_hex_string(str, hex_tmp, &hexlen);
6798 /* Let parse_int() fill length information first. */
6799 ret = snprintf(tmp, sizeof(tmp), "%u", hexlen);
6802 /* Save length if requested. */
6803 if (arg_len->size) {
6804 push_args(ctx, arg_len);
6805 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
6811 buf = (uint8_t *)ctx->object + arg_data->offset;
6812 /* Output buffer is not necessarily NUL-terminated. */
6813 memcpy(buf, hex_tmp, hexlen);
6814 memset((uint8_t *)buf + hexlen, 0x00, size - hexlen);
6816 memset((uint8_t *)ctx->objmask + arg_data->offset,
6818 /* Save address if requested. */
6819 if (arg_addr->size) {
6820 memcpy((uint8_t *)ctx->object + arg_addr->offset,
6822 (uint8_t *)ctx->object + arg_data->offset
6826 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
6828 (uint8_t *)ctx->objmask + arg_data->offset
6834 push_args(ctx, arg_addr);
6835 push_args(ctx, arg_len);
6836 push_args(ctx, arg_data);
6842 * Parse a zero-ended string.
6845 parse_string0(struct context *ctx, const struct token *token __rte_unused,
6846 const char *str, unsigned int len,
6847 void *buf, unsigned int size)
6849 const struct arg *arg_data = pop_args(ctx);
6851 /* Arguments are expected. */
6854 size = arg_data->size;
6855 /* Bit-mask fill is not supported. */
6856 if (arg_data->mask || size < len + 1)
6860 buf = (uint8_t *)ctx->object + arg_data->offset;
6861 strncpy(buf, str, len);
6863 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
6866 push_args(ctx, arg_data);
6871 * Parse a MAC address.
6873 * Last argument (ctx->args) is retrieved to determine storage size and
6877 parse_mac_addr(struct context *ctx, const struct token *token,
6878 const char *str, unsigned int len,
6879 void *buf, unsigned int size)
6881 const struct arg *arg = pop_args(ctx);
6882 struct rte_ether_addr tmp;
6886 /* Argument is expected. */
6890 /* Bit-mask fill is not supported. */
6891 if (arg->mask || size != sizeof(tmp))
6893 /* Only network endian is supported. */
6896 ret = cmdline_parse_etheraddr(NULL, str, &tmp, size);
6897 if (ret < 0 || (unsigned int)ret != len)
6901 buf = (uint8_t *)ctx->object + arg->offset;
6902 memcpy(buf, &tmp, size);
6904 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6907 push_args(ctx, arg);
6912 * Parse an IPv4 address.
6914 * Last argument (ctx->args) is retrieved to determine storage size and
6918 parse_ipv4_addr(struct context *ctx, const struct token *token,
6919 const char *str, unsigned int len,
6920 void *buf, unsigned int size)
6922 const struct arg *arg = pop_args(ctx);
6927 /* Argument is expected. */
6931 /* Bit-mask fill is not supported. */
6932 if (arg->mask || size != sizeof(tmp))
6934 /* Only network endian is supported. */
6937 memcpy(str2, str, len);
6939 ret = inet_pton(AF_INET, str2, &tmp);
6941 /* Attempt integer parsing. */
6942 push_args(ctx, arg);
6943 return parse_int(ctx, token, str, len, buf, size);
6947 buf = (uint8_t *)ctx->object + arg->offset;
6948 memcpy(buf, &tmp, size);
6950 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6953 push_args(ctx, arg);
6958 * Parse an IPv6 address.
6960 * Last argument (ctx->args) is retrieved to determine storage size and
6964 parse_ipv6_addr(struct context *ctx, const struct token *token,
6965 const char *str, unsigned int len,
6966 void *buf, unsigned int size)
6968 const struct arg *arg = pop_args(ctx);
6970 struct in6_addr tmp;
6974 /* Argument is expected. */
6978 /* Bit-mask fill is not supported. */
6979 if (arg->mask || size != sizeof(tmp))
6981 /* Only network endian is supported. */
6984 memcpy(str2, str, len);
6986 ret = inet_pton(AF_INET6, str2, &tmp);
6991 buf = (uint8_t *)ctx->object + arg->offset;
6992 memcpy(buf, &tmp, size);
6994 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6997 push_args(ctx, arg);
7001 /** Boolean values (even indices stand for false). */
7002 static const char *const boolean_name[] = {
7012 * Parse a boolean value.
7014 * Last argument (ctx->args) is retrieved to determine storage size and
7018 parse_boolean(struct context *ctx, const struct token *token,
7019 const char *str, unsigned int len,
7020 void *buf, unsigned int size)
7022 const struct arg *arg = pop_args(ctx);
7026 /* Argument is expected. */
7029 for (i = 0; boolean_name[i]; ++i)
7030 if (!strcmp_partial(boolean_name[i], str, len))
7032 /* Process token as integer. */
7033 if (boolean_name[i])
7034 str = i & 1 ? "1" : "0";
7035 push_args(ctx, arg);
7036 ret = parse_int(ctx, token, str, strlen(str), buf, size);
7037 return ret > 0 ? (int)len : ret;
7040 /** Parse port and update context. */
7042 parse_port(struct context *ctx, const struct token *token,
7043 const char *str, unsigned int len,
7044 void *buf, unsigned int size)
7046 struct buffer *out = &(struct buffer){ .port = 0 };
7054 ctx->objmask = NULL;
7055 size = sizeof(*out);
7057 ret = parse_int(ctx, token, str, len, out, size);
7059 ctx->port = out->port;
7066 parse_sa_id2ptr(struct context *ctx, const struct token *token,
7067 const char *str, unsigned int len,
7068 void *buf, unsigned int size)
7070 struct rte_flow_action *action = ctx->object;
7078 ctx->objmask = NULL;
7079 ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
7080 ctx->object = action;
7081 if (ret != (int)len)
7083 /* set shared action */
7085 action->conf = port_shared_action_get_by_id(ctx->port, id);
7086 ret = (action->conf) ? ret : -1;
7091 /** Parse set command, initialize output buffer for subsequent tokens. */
7093 parse_set_raw_encap_decap(struct context *ctx, const struct token *token,
7094 const char *str, unsigned int len,
7095 void *buf, unsigned int size)
7097 struct buffer *out = buf;
7099 /* Token name must match. */
7100 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7102 /* Nothing else to do if there is no buffer. */
7105 /* Make sure buffer is large enough. */
7106 if (size < sizeof(*out))
7109 ctx->objmask = NULL;
7113 out->command = ctx->curr;
7114 /* For encap/decap we need is pattern */
7115 out->args.vc.pattern = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7120 /** Parse set command, initialize output buffer for subsequent tokens. */
7122 parse_set_sample_action(struct context *ctx, const struct token *token,
7123 const char *str, unsigned int len,
7124 void *buf, unsigned int size)
7126 struct buffer *out = buf;
7128 /* Token name must match. */
7129 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7131 /* Nothing else to do if there is no buffer. */
7134 /* Make sure buffer is large enough. */
7135 if (size < sizeof(*out))
7138 ctx->objmask = NULL;
7142 out->command = ctx->curr;
7143 /* For sampler we need is actions */
7144 out->args.vc.actions = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7150 * Parse set raw_encap/raw_decap command,
7151 * initialize output buffer for subsequent tokens.
7154 parse_set_init(struct context *ctx, const struct token *token,
7155 const char *str, unsigned int len,
7156 void *buf, unsigned int size)
7158 struct buffer *out = buf;
7160 /* Token name must match. */
7161 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7163 /* Nothing else to do if there is no buffer. */
7166 /* Make sure buffer is large enough. */
7167 if (size < sizeof(*out))
7169 /* Initialize buffer. */
7170 memset(out, 0x00, sizeof(*out));
7171 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
7174 ctx->objmask = NULL;
7175 if (!out->command) {
7176 if (ctx->curr != SET)
7178 if (sizeof(*out) > size)
7180 out->command = ctx->curr;
7181 out->args.vc.data = (uint8_t *)out + size;
7182 ctx->object = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7188 /** No completion. */
7190 comp_none(struct context *ctx, const struct token *token,
7191 unsigned int ent, char *buf, unsigned int size)
7201 /** Complete boolean values. */
7203 comp_boolean(struct context *ctx, const struct token *token,
7204 unsigned int ent, char *buf, unsigned int size)
7210 for (i = 0; boolean_name[i]; ++i)
7211 if (buf && i == ent)
7212 return strlcpy(buf, boolean_name[i], size);
7218 /** Complete action names. */
7220 comp_action(struct context *ctx, const struct token *token,
7221 unsigned int ent, char *buf, unsigned int size)
7227 for (i = 0; next_action[i]; ++i)
7228 if (buf && i == ent)
7229 return strlcpy(buf, token_list[next_action[i]].name,
7236 /** Complete available ports. */
7238 comp_port(struct context *ctx, const struct token *token,
7239 unsigned int ent, char *buf, unsigned int size)
7246 RTE_ETH_FOREACH_DEV(p) {
7247 if (buf && i == ent)
7248 return snprintf(buf, size, "%u", p);
7256 /** Complete available rule IDs. */
7258 comp_rule_id(struct context *ctx, const struct token *token,
7259 unsigned int ent, char *buf, unsigned int size)
7262 struct rte_port *port;
7263 struct port_flow *pf;
7266 if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
7267 ctx->port == (portid_t)RTE_PORT_ALL)
7269 port = &ports[ctx->port];
7270 for (pf = port->flow_list; pf != NULL; pf = pf->next) {
7271 if (buf && i == ent)
7272 return snprintf(buf, size, "%u", pf->id);
7280 /** Complete type field for RSS action. */
7282 comp_vc_action_rss_type(struct context *ctx, const struct token *token,
7283 unsigned int ent, char *buf, unsigned int size)
7289 for (i = 0; rss_type_table[i].str; ++i)
7294 return strlcpy(buf, rss_type_table[ent].str, size);
7296 return snprintf(buf, size, "end");
7300 /** Complete queue field for RSS action. */
7302 comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
7303 unsigned int ent, char *buf, unsigned int size)
7310 return snprintf(buf, size, "%u", ent);
7312 return snprintf(buf, size, "end");
7316 /** Complete index number for set raw_encap/raw_decap commands. */
7318 comp_set_raw_index(struct context *ctx, const struct token *token,
7319 unsigned int ent, char *buf, unsigned int size)
7325 RTE_SET_USED(token);
7326 for (idx = 0; idx < RAW_ENCAP_CONFS_MAX_NUM; ++idx) {
7327 if (buf && idx == ent)
7328 return snprintf(buf, size, "%u", idx);
7334 /** Complete index number for set raw_encap/raw_decap commands. */
7336 comp_set_sample_index(struct context *ctx, const struct token *token,
7337 unsigned int ent, char *buf, unsigned int size)
7343 RTE_SET_USED(token);
7344 for (idx = 0; idx < RAW_SAMPLE_CONFS_MAX_NUM; ++idx) {
7345 if (buf && idx == ent)
7346 return snprintf(buf, size, "%u", idx);
7352 /** Complete operation for modify_field command. */
7354 comp_set_modify_field_op(struct context *ctx, const struct token *token,
7355 unsigned int ent, char *buf, unsigned int size)
7360 RTE_SET_USED(token);
7361 for (idx = 0; modify_field_ops[idx]; ++idx)
7366 return strlcpy(buf, modify_field_ops[ent], size);
7370 /** Complete field id for modify_field command. */
7372 comp_set_modify_field_id(struct context *ctx, const struct token *token,
7373 unsigned int ent, char *buf, unsigned int size)
7378 RTE_SET_USED(token);
7379 for (idx = 0; modify_field_ids[idx]; ++idx)
7384 return strlcpy(buf, modify_field_ids[ent], size);
7388 /** Internal context. */
7389 static struct context cmd_flow_context;
7391 /** Global parser instance (cmdline API). */
7392 cmdline_parse_inst_t cmd_flow;
7393 cmdline_parse_inst_t cmd_set_raw;
7395 /** Initialize context. */
7397 cmd_flow_context_init(struct context *ctx)
7399 /* A full memset() is not necessary. */
7409 ctx->objmask = NULL;
7412 /** Parse a token (cmdline API). */
7414 cmd_flow_parse(cmdline_parse_token_hdr_t *hdr, const char *src, void *result,
7417 struct context *ctx = &cmd_flow_context;
7418 const struct token *token;
7419 const enum index *list;
7424 token = &token_list[ctx->curr];
7425 /* Check argument length. */
7428 for (len = 0; src[len]; ++len)
7429 if (src[len] == '#' || isspace(src[len]))
7433 /* Last argument and EOL detection. */
7434 for (i = len; src[i]; ++i)
7435 if (src[i] == '#' || src[i] == '\r' || src[i] == '\n')
7437 else if (!isspace(src[i])) {
7442 if (src[i] == '\r' || src[i] == '\n') {
7446 /* Initialize context if necessary. */
7447 if (!ctx->next_num) {
7450 ctx->next[ctx->next_num++] = token->next[0];
7452 /* Process argument through candidates. */
7453 ctx->prev = ctx->curr;
7454 list = ctx->next[ctx->next_num - 1];
7455 for (i = 0; list[i]; ++i) {
7456 const struct token *next = &token_list[list[i]];
7459 ctx->curr = list[i];
7461 tmp = next->call(ctx, next, src, len, result, size);
7463 tmp = parse_default(ctx, next, src, len, result, size);
7464 if (tmp == -1 || tmp != len)
7472 /* Push subsequent tokens if any. */
7474 for (i = 0; token->next[i]; ++i) {
7475 if (ctx->next_num == RTE_DIM(ctx->next))
7477 ctx->next[ctx->next_num++] = token->next[i];
7479 /* Push arguments if any. */
7481 for (i = 0; token->args[i]; ++i) {
7482 if (ctx->args_num == RTE_DIM(ctx->args))
7484 ctx->args[ctx->args_num++] = token->args[i];
7489 /** Return number of completion entries (cmdline API). */
7491 cmd_flow_complete_get_nb(cmdline_parse_token_hdr_t *hdr)
7493 struct context *ctx = &cmd_flow_context;
7494 const struct token *token = &token_list[ctx->curr];
7495 const enum index *list;
7499 /* Count number of tokens in current list. */
7501 list = ctx->next[ctx->next_num - 1];
7503 list = token->next[0];
7504 for (i = 0; list[i]; ++i)
7509 * If there is a single token, use its completion callback, otherwise
7510 * return the number of entries.
7512 token = &token_list[list[0]];
7513 if (i == 1 && token->comp) {
7514 /* Save index for cmd_flow_get_help(). */
7515 ctx->prev = list[0];
7516 return token->comp(ctx, token, 0, NULL, 0);
7521 /** Return a completion entry (cmdline API). */
7523 cmd_flow_complete_get_elt(cmdline_parse_token_hdr_t *hdr, int index,
7524 char *dst, unsigned int size)
7526 struct context *ctx = &cmd_flow_context;
7527 const struct token *token = &token_list[ctx->curr];
7528 const enum index *list;
7532 /* Count number of tokens in current list. */
7534 list = ctx->next[ctx->next_num - 1];
7536 list = token->next[0];
7537 for (i = 0; list[i]; ++i)
7541 /* If there is a single token, use its completion callback. */
7542 token = &token_list[list[0]];
7543 if (i == 1 && token->comp) {
7544 /* Save index for cmd_flow_get_help(). */
7545 ctx->prev = list[0];
7546 return token->comp(ctx, token, index, dst, size) < 0 ? -1 : 0;
7548 /* Otherwise make sure the index is valid and use defaults. */
7551 token = &token_list[list[index]];
7552 strlcpy(dst, token->name, size);
7553 /* Save index for cmd_flow_get_help(). */
7554 ctx->prev = list[index];
7558 /** Populate help strings for current token (cmdline API). */
7560 cmd_flow_get_help(cmdline_parse_token_hdr_t *hdr, char *dst, unsigned int size)
7562 struct context *ctx = &cmd_flow_context;
7563 const struct token *token = &token_list[ctx->prev];
7568 /* Set token type and update global help with details. */
7569 strlcpy(dst, (token->type ? token->type : "TOKEN"), size);
7571 cmd_flow.help_str = token->help;
7573 cmd_flow.help_str = token->name;
7577 /** Token definition template (cmdline API). */
7578 static struct cmdline_token_hdr cmd_flow_token_hdr = {
7579 .ops = &(struct cmdline_token_ops){
7580 .parse = cmd_flow_parse,
7581 .complete_get_nb = cmd_flow_complete_get_nb,
7582 .complete_get_elt = cmd_flow_complete_get_elt,
7583 .get_help = cmd_flow_get_help,
7588 /** Populate the next dynamic token. */
7590 cmd_flow_tok(cmdline_parse_token_hdr_t **hdr,
7591 cmdline_parse_token_hdr_t **hdr_inst)
7593 struct context *ctx = &cmd_flow_context;
7595 /* Always reinitialize context before requesting the first token. */
7596 if (!(hdr_inst - cmd_flow.tokens))
7597 cmd_flow_context_init(ctx);
7598 /* Return NULL when no more tokens are expected. */
7599 if (!ctx->next_num && ctx->curr) {
7603 /* Determine if command should end here. */
7604 if (ctx->eol && ctx->last && ctx->next_num) {
7605 const enum index *list = ctx->next[ctx->next_num - 1];
7608 for (i = 0; list[i]; ++i) {
7615 *hdr = &cmd_flow_token_hdr;
7618 /** Dispatch parsed buffer to function calls. */
7620 cmd_flow_parsed(const struct buffer *in)
7622 switch (in->command) {
7623 case SHARED_ACTION_CREATE:
7624 port_shared_action_create(
7625 in->port, in->args.vc.attr.group,
7626 &((const struct rte_flow_shared_action_conf) {
7627 .ingress = in->args.vc.attr.ingress,
7628 .egress = in->args.vc.attr.egress,
7629 .transfer = in->args.vc.attr.transfer,
7631 in->args.vc.actions);
7633 case SHARED_ACTION_DESTROY:
7634 port_shared_action_destroy(in->port,
7635 in->args.sa_destroy.action_id_n,
7636 in->args.sa_destroy.action_id);
7638 case SHARED_ACTION_UPDATE:
7639 port_shared_action_update(in->port, in->args.vc.attr.group,
7640 in->args.vc.actions);
7642 case SHARED_ACTION_QUERY:
7643 port_shared_action_query(in->port, in->args.sa.action_id);
7646 port_flow_validate(in->port, &in->args.vc.attr,
7647 in->args.vc.pattern, in->args.vc.actions,
7648 &in->args.vc.tunnel_ops);
7651 port_flow_create(in->port, &in->args.vc.attr,
7652 in->args.vc.pattern, in->args.vc.actions,
7653 &in->args.vc.tunnel_ops);
7656 port_flow_destroy(in->port, in->args.destroy.rule_n,
7657 in->args.destroy.rule);
7660 port_flow_flush(in->port);
7663 port_flow_dump(in->port, in->args.dump.file);
7666 port_flow_query(in->port, in->args.query.rule,
7667 &in->args.query.action);
7670 port_flow_list(in->port, in->args.list.group_n,
7671 in->args.list.group);
7674 port_flow_isolate(in->port, in->args.isolate.set);
7677 port_flow_aged(in->port, in->args.aged.destroy);
7680 port_flow_tunnel_create(in->port, &in->args.vc.tunnel_ops);
7682 case TUNNEL_DESTROY:
7683 port_flow_tunnel_destroy(in->port, in->args.vc.tunnel_ops.id);
7686 port_flow_tunnel_list(in->port);
7693 /** Token generator and output processing callback (cmdline API). */
7695 cmd_flow_cb(void *arg0, struct cmdline *cl, void *arg2)
7698 cmd_flow_tok(arg0, arg2);
7700 cmd_flow_parsed(arg0);
7703 /** Global parser instance (cmdline API). */
7704 cmdline_parse_inst_t cmd_flow = {
7706 .data = NULL, /**< Unused. */
7707 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
7710 }, /**< Tokens are returned by cmd_flow_tok(). */
7713 /** set cmd facility. Reuse cmd flow's infrastructure as much as possible. */
7716 update_fields(uint8_t *buf, struct rte_flow_item *item, uint16_t next_proto)
7718 struct rte_ipv4_hdr *ipv4;
7719 struct rte_ether_hdr *eth;
7720 struct rte_ipv6_hdr *ipv6;
7721 struct rte_vxlan_hdr *vxlan;
7722 struct rte_vxlan_gpe_hdr *gpe;
7723 struct rte_flow_item_nvgre *nvgre;
7724 uint32_t ipv6_vtc_flow;
7726 switch (item->type) {
7727 case RTE_FLOW_ITEM_TYPE_ETH:
7728 eth = (struct rte_ether_hdr *)buf;
7730 eth->ether_type = rte_cpu_to_be_16(next_proto);
7732 case RTE_FLOW_ITEM_TYPE_IPV4:
7733 ipv4 = (struct rte_ipv4_hdr *)buf;
7734 ipv4->version_ihl = 0x45;
7735 if (next_proto && ipv4->next_proto_id == 0)
7736 ipv4->next_proto_id = (uint8_t)next_proto;
7738 case RTE_FLOW_ITEM_TYPE_IPV6:
7739 ipv6 = (struct rte_ipv6_hdr *)buf;
7740 if (next_proto && ipv6->proto == 0)
7741 ipv6->proto = (uint8_t)next_proto;
7742 ipv6_vtc_flow = rte_be_to_cpu_32(ipv6->vtc_flow);
7743 ipv6_vtc_flow &= 0x0FFFFFFF; /*< reset version bits. */
7744 ipv6_vtc_flow |= 0x60000000; /*< set ipv6 version. */
7745 ipv6->vtc_flow = rte_cpu_to_be_32(ipv6_vtc_flow);
7747 case RTE_FLOW_ITEM_TYPE_VXLAN:
7748 vxlan = (struct rte_vxlan_hdr *)buf;
7749 vxlan->vx_flags = 0x08;
7751 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
7752 gpe = (struct rte_vxlan_gpe_hdr *)buf;
7753 gpe->vx_flags = 0x0C;
7755 case RTE_FLOW_ITEM_TYPE_NVGRE:
7756 nvgre = (struct rte_flow_item_nvgre *)buf;
7757 nvgre->protocol = rte_cpu_to_be_16(0x6558);
7758 nvgre->c_k_s_rsvd0_ver = rte_cpu_to_be_16(0x2000);
7765 /** Helper of get item's default mask. */
7767 flow_item_default_mask(const struct rte_flow_item *item)
7769 const void *mask = NULL;
7770 static rte_be32_t gre_key_default_mask = RTE_BE32(UINT32_MAX);
7772 switch (item->type) {
7773 case RTE_FLOW_ITEM_TYPE_ANY:
7774 mask = &rte_flow_item_any_mask;
7776 case RTE_FLOW_ITEM_TYPE_VF:
7777 mask = &rte_flow_item_vf_mask;
7779 case RTE_FLOW_ITEM_TYPE_PORT_ID:
7780 mask = &rte_flow_item_port_id_mask;
7782 case RTE_FLOW_ITEM_TYPE_RAW:
7783 mask = &rte_flow_item_raw_mask;
7785 case RTE_FLOW_ITEM_TYPE_ETH:
7786 mask = &rte_flow_item_eth_mask;
7788 case RTE_FLOW_ITEM_TYPE_VLAN:
7789 mask = &rte_flow_item_vlan_mask;
7791 case RTE_FLOW_ITEM_TYPE_IPV4:
7792 mask = &rte_flow_item_ipv4_mask;
7794 case RTE_FLOW_ITEM_TYPE_IPV6:
7795 mask = &rte_flow_item_ipv6_mask;
7797 case RTE_FLOW_ITEM_TYPE_ICMP:
7798 mask = &rte_flow_item_icmp_mask;
7800 case RTE_FLOW_ITEM_TYPE_UDP:
7801 mask = &rte_flow_item_udp_mask;
7803 case RTE_FLOW_ITEM_TYPE_TCP:
7804 mask = &rte_flow_item_tcp_mask;
7806 case RTE_FLOW_ITEM_TYPE_SCTP:
7807 mask = &rte_flow_item_sctp_mask;
7809 case RTE_FLOW_ITEM_TYPE_VXLAN:
7810 mask = &rte_flow_item_vxlan_mask;
7812 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
7813 mask = &rte_flow_item_vxlan_gpe_mask;
7815 case RTE_FLOW_ITEM_TYPE_E_TAG:
7816 mask = &rte_flow_item_e_tag_mask;
7818 case RTE_FLOW_ITEM_TYPE_NVGRE:
7819 mask = &rte_flow_item_nvgre_mask;
7821 case RTE_FLOW_ITEM_TYPE_MPLS:
7822 mask = &rte_flow_item_mpls_mask;
7824 case RTE_FLOW_ITEM_TYPE_GRE:
7825 mask = &rte_flow_item_gre_mask;
7827 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
7828 mask = &gre_key_default_mask;
7830 case RTE_FLOW_ITEM_TYPE_META:
7831 mask = &rte_flow_item_meta_mask;
7833 case RTE_FLOW_ITEM_TYPE_FUZZY:
7834 mask = &rte_flow_item_fuzzy_mask;
7836 case RTE_FLOW_ITEM_TYPE_GTP:
7837 mask = &rte_flow_item_gtp_mask;
7839 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
7840 mask = &rte_flow_item_gtp_psc_mask;
7842 case RTE_FLOW_ITEM_TYPE_GENEVE:
7843 mask = &rte_flow_item_geneve_mask;
7845 case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
7846 mask = &rte_flow_item_geneve_opt_mask;
7848 case RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID:
7849 mask = &rte_flow_item_pppoe_proto_id_mask;
7851 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
7852 mask = &rte_flow_item_l2tpv3oip_mask;
7854 case RTE_FLOW_ITEM_TYPE_ESP:
7855 mask = &rte_flow_item_esp_mask;
7857 case RTE_FLOW_ITEM_TYPE_AH:
7858 mask = &rte_flow_item_ah_mask;
7860 case RTE_FLOW_ITEM_TYPE_PFCP:
7861 mask = &rte_flow_item_pfcp_mask;
7869 /** Dispatch parsed buffer to function calls. */
7871 cmd_set_raw_parsed_sample(const struct buffer *in)
7873 uint32_t n = in->args.vc.actions_n;
7875 struct rte_flow_action *action = NULL;
7876 struct rte_flow_action *data = NULL;
7877 const struct rte_flow_action_rss *rss = NULL;
7879 uint16_t idx = in->port; /* We borrow port field as index */
7880 uint32_t max_size = sizeof(struct rte_flow_action) *
7881 ACTION_SAMPLE_ACTIONS_NUM;
7883 RTE_ASSERT(in->command == SET_SAMPLE_ACTIONS);
7884 data = (struct rte_flow_action *)&raw_sample_confs[idx].data;
7885 memset(data, 0x00, max_size);
7886 for (; i <= n - 1; i++) {
7887 action = in->args.vc.actions + i;
7888 if (action->type == RTE_FLOW_ACTION_TYPE_END)
7890 switch (action->type) {
7891 case RTE_FLOW_ACTION_TYPE_MARK:
7892 size = sizeof(struct rte_flow_action_mark);
7893 rte_memcpy(&sample_mark[idx],
7894 (const void *)action->conf, size);
7895 action->conf = &sample_mark[idx];
7897 case RTE_FLOW_ACTION_TYPE_COUNT:
7898 size = sizeof(struct rte_flow_action_count);
7899 rte_memcpy(&sample_count[idx],
7900 (const void *)action->conf, size);
7901 action->conf = &sample_count[idx];
7903 case RTE_FLOW_ACTION_TYPE_QUEUE:
7904 size = sizeof(struct rte_flow_action_queue);
7905 rte_memcpy(&sample_queue[idx],
7906 (const void *)action->conf, size);
7907 action->conf = &sample_queue[idx];
7909 case RTE_FLOW_ACTION_TYPE_RSS:
7910 size = sizeof(struct rte_flow_action_rss);
7912 rte_memcpy(&sample_rss_data[idx].conf,
7913 (const void *)rss, size);
7914 if (rss->key_len && rss->key) {
7915 sample_rss_data[idx].conf.key =
7916 sample_rss_data[idx].key;
7917 rte_memcpy((void *)((uintptr_t)
7918 sample_rss_data[idx].conf.key),
7919 (const void *)rss->key,
7920 sizeof(uint8_t) * rss->key_len);
7922 if (rss->queue_num && rss->queue) {
7923 sample_rss_data[idx].conf.queue =
7924 sample_rss_data[idx].queue;
7925 rte_memcpy((void *)((uintptr_t)
7926 sample_rss_data[idx].conf.queue),
7927 (const void *)rss->queue,
7928 sizeof(uint16_t) * rss->queue_num);
7930 action->conf = &sample_rss_data[idx].conf;
7932 case RTE_FLOW_ACTION_TYPE_RAW_ENCAP:
7933 size = sizeof(struct rte_flow_action_raw_encap);
7934 rte_memcpy(&sample_encap[idx],
7935 (const void *)action->conf, size);
7936 action->conf = &sample_encap[idx];
7938 case RTE_FLOW_ACTION_TYPE_PORT_ID:
7939 size = sizeof(struct rte_flow_action_port_id);
7940 rte_memcpy(&sample_port_id[idx],
7941 (const void *)action->conf, size);
7942 action->conf = &sample_port_id[idx];
7944 case RTE_FLOW_ACTION_TYPE_PF:
7946 case RTE_FLOW_ACTION_TYPE_VF:
7947 size = sizeof(struct rte_flow_action_vf);
7948 rte_memcpy(&sample_vf[idx],
7949 (const void *)action->conf, size);
7950 action->conf = &sample_vf[idx];
7952 case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP:
7953 size = sizeof(struct rte_flow_action_vxlan_encap);
7954 parse_setup_vxlan_encap_data(&sample_vxlan_encap[idx]);
7955 action->conf = &sample_vxlan_encap[idx].conf;
7957 case RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP:
7958 size = sizeof(struct rte_flow_action_nvgre_encap);
7959 parse_setup_nvgre_encap_data(&sample_nvgre_encap[idx]);
7960 action->conf = &sample_nvgre_encap[idx];
7963 printf("Error - Not supported action\n");
7966 rte_memcpy(data, action, sizeof(struct rte_flow_action));
7971 /** Dispatch parsed buffer to function calls. */
7973 cmd_set_raw_parsed(const struct buffer *in)
7975 uint32_t n = in->args.vc.pattern_n;
7977 struct rte_flow_item *item = NULL;
7979 uint8_t *data = NULL;
7980 uint8_t *data_tail = NULL;
7981 size_t *total_size = NULL;
7982 uint16_t upper_layer = 0;
7984 uint16_t idx = in->port; /* We borrow port field as index */
7985 int gtp_psc = -1; /* GTP PSC option index. */
7987 if (in->command == SET_SAMPLE_ACTIONS)
7988 return cmd_set_raw_parsed_sample(in);
7989 RTE_ASSERT(in->command == SET_RAW_ENCAP ||
7990 in->command == SET_RAW_DECAP);
7991 if (in->command == SET_RAW_ENCAP) {
7992 total_size = &raw_encap_confs[idx].size;
7993 data = (uint8_t *)&raw_encap_confs[idx].data;
7995 total_size = &raw_decap_confs[idx].size;
7996 data = (uint8_t *)&raw_decap_confs[idx].data;
7999 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
8000 /* process hdr from upper layer to low layer (L3/L4 -> L2). */
8001 data_tail = data + ACTION_RAW_ENCAP_MAX_DATA;
8002 for (i = n - 1 ; i >= 0; --i) {
8003 const struct rte_flow_item_gtp *gtp;
8004 const struct rte_flow_item_geneve_opt *opt;
8006 item = in->args.vc.pattern + i;
8007 if (item->spec == NULL)
8008 item->spec = flow_item_default_mask(item);
8009 switch (item->type) {
8010 case RTE_FLOW_ITEM_TYPE_ETH:
8011 size = sizeof(struct rte_ether_hdr);
8013 case RTE_FLOW_ITEM_TYPE_VLAN:
8014 size = sizeof(struct rte_vlan_hdr);
8015 proto = RTE_ETHER_TYPE_VLAN;
8017 case RTE_FLOW_ITEM_TYPE_IPV4:
8018 size = sizeof(struct rte_ipv4_hdr);
8019 proto = RTE_ETHER_TYPE_IPV4;
8021 case RTE_FLOW_ITEM_TYPE_IPV6:
8022 size = sizeof(struct rte_ipv6_hdr);
8023 proto = RTE_ETHER_TYPE_IPV6;
8025 case RTE_FLOW_ITEM_TYPE_UDP:
8026 size = sizeof(struct rte_udp_hdr);
8029 case RTE_FLOW_ITEM_TYPE_TCP:
8030 size = sizeof(struct rte_tcp_hdr);
8033 case RTE_FLOW_ITEM_TYPE_VXLAN:
8034 size = sizeof(struct rte_vxlan_hdr);
8036 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
8037 size = sizeof(struct rte_vxlan_gpe_hdr);
8039 case RTE_FLOW_ITEM_TYPE_GRE:
8040 size = sizeof(struct rte_gre_hdr);
8043 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
8044 size = sizeof(rte_be32_t);
8047 case RTE_FLOW_ITEM_TYPE_MPLS:
8048 size = sizeof(struct rte_mpls_hdr);
8051 case RTE_FLOW_ITEM_TYPE_NVGRE:
8052 size = sizeof(struct rte_flow_item_nvgre);
8055 case RTE_FLOW_ITEM_TYPE_GENEVE:
8056 size = sizeof(struct rte_geneve_hdr);
8058 case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
8059 opt = (const struct rte_flow_item_geneve_opt *)
8061 size = offsetof(struct rte_flow_item_geneve_opt, data);
8062 if (opt->option_len && opt->data) {
8063 *total_size += opt->option_len *
8065 rte_memcpy(data_tail - (*total_size),
8067 opt->option_len * sizeof(uint32_t));
8070 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
8071 size = sizeof(rte_be32_t);
8074 case RTE_FLOW_ITEM_TYPE_ESP:
8075 size = sizeof(struct rte_esp_hdr);
8078 case RTE_FLOW_ITEM_TYPE_AH:
8079 size = sizeof(struct rte_flow_item_ah);
8082 case RTE_FLOW_ITEM_TYPE_GTP:
8084 size = sizeof(struct rte_gtp_hdr);
8087 if (gtp_psc != i + 1) {
8088 printf("Error - GTP PSC does not follow GTP\n");
8092 if ((gtp->v_pt_rsv_flags & 0x07) != 0x04) {
8093 /* Only E flag should be set. */
8094 printf("Error - GTP unsupported flags\n");
8097 struct rte_gtp_hdr_ext_word ext_word = {
8101 /* We have to add GTP header extra word. */
8102 *total_size += sizeof(ext_word);
8103 rte_memcpy(data_tail - (*total_size),
8104 &ext_word, sizeof(ext_word));
8106 size = sizeof(struct rte_gtp_hdr);
8108 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
8110 printf("Error - Multiple GTP PSC items\n");
8113 const struct rte_flow_item_gtp_psc
8122 if (opt->pdu_type & 0x0F) {
8123 /* Support the minimal option only. */
8124 printf("Error - GTP PSC option with "
8125 "extra fields not supported\n");
8128 psc.len = sizeof(psc);
8129 psc.pdu_type = opt->pdu_type;
8132 *total_size += sizeof(psc);
8133 rte_memcpy(data_tail - (*total_size),
8139 case RTE_FLOW_ITEM_TYPE_PFCP:
8140 size = sizeof(struct rte_flow_item_pfcp);
8143 printf("Error - Not supported item\n");
8146 *total_size += size;
8147 rte_memcpy(data_tail - (*total_size), item->spec, size);
8148 /* update some fields which cannot be set by cmdline */
8149 update_fields((data_tail - (*total_size)), item,
8151 upper_layer = proto;
8153 if (verbose_level & 0x1)
8154 printf("total data size is %zu\n", (*total_size));
8155 RTE_ASSERT((*total_size) <= ACTION_RAW_ENCAP_MAX_DATA);
8156 memmove(data, (data_tail - (*total_size)), *total_size);
8161 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
8164 /** Populate help strings for current token (cmdline API). */
8166 cmd_set_raw_get_help(cmdline_parse_token_hdr_t *hdr, char *dst,
8169 struct context *ctx = &cmd_flow_context;
8170 const struct token *token = &token_list[ctx->prev];
8175 /* Set token type and update global help with details. */
8176 snprintf(dst, size, "%s", (token->type ? token->type : "TOKEN"));
8178 cmd_set_raw.help_str = token->help;
8180 cmd_set_raw.help_str = token->name;
8184 /** Token definition template (cmdline API). */
8185 static struct cmdline_token_hdr cmd_set_raw_token_hdr = {
8186 .ops = &(struct cmdline_token_ops){
8187 .parse = cmd_flow_parse,
8188 .complete_get_nb = cmd_flow_complete_get_nb,
8189 .complete_get_elt = cmd_flow_complete_get_elt,
8190 .get_help = cmd_set_raw_get_help,
8195 /** Populate the next dynamic token. */
8197 cmd_set_raw_tok(cmdline_parse_token_hdr_t **hdr,
8198 cmdline_parse_token_hdr_t **hdr_inst)
8200 struct context *ctx = &cmd_flow_context;
8202 /* Always reinitialize context before requesting the first token. */
8203 if (!(hdr_inst - cmd_set_raw.tokens)) {
8204 cmd_flow_context_init(ctx);
8205 ctx->curr = START_SET;
8207 /* Return NULL when no more tokens are expected. */
8208 if (!ctx->next_num && (ctx->curr != START_SET)) {
8212 /* Determine if command should end here. */
8213 if (ctx->eol && ctx->last && ctx->next_num) {
8214 const enum index *list = ctx->next[ctx->next_num - 1];
8217 for (i = 0; list[i]; ++i) {
8224 *hdr = &cmd_set_raw_token_hdr;
8227 /** Token generator and output processing callback (cmdline API). */
8229 cmd_set_raw_cb(void *arg0, struct cmdline *cl, void *arg2)
8232 cmd_set_raw_tok(arg0, arg2);
8234 cmd_set_raw_parsed(arg0);
8237 /** Global parser instance (cmdline API). */
8238 cmdline_parse_inst_t cmd_set_raw = {
8239 .f = cmd_set_raw_cb,
8240 .data = NULL, /**< Unused. */
8241 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
8244 }, /**< Tokens are returned by cmd_flow_tok(). */
8247 /* *** display raw_encap/raw_decap buf */
8248 struct cmd_show_set_raw_result {
8249 cmdline_fixed_string_t cmd_show;
8250 cmdline_fixed_string_t cmd_what;
8251 cmdline_fixed_string_t cmd_all;
8256 cmd_show_set_raw_parsed(void *parsed_result, struct cmdline *cl, void *data)
8258 struct cmd_show_set_raw_result *res = parsed_result;
8259 uint16_t index = res->cmd_index;
8261 uint8_t *raw_data = NULL;
8262 size_t raw_size = 0;
8263 char title[16] = {0};
8267 if (!strcmp(res->cmd_all, "all")) {
8270 } else if (index >= RAW_ENCAP_CONFS_MAX_NUM) {
8271 printf("index should be 0-%u\n", RAW_ENCAP_CONFS_MAX_NUM - 1);
8275 if (!strcmp(res->cmd_what, "raw_encap")) {
8276 raw_data = (uint8_t *)&raw_encap_confs[index].data;
8277 raw_size = raw_encap_confs[index].size;
8278 snprintf(title, 16, "\nindex: %u", index);
8279 rte_hexdump(stdout, title, raw_data, raw_size);
8281 raw_data = (uint8_t *)&raw_decap_confs[index].data;
8282 raw_size = raw_decap_confs[index].size;
8283 snprintf(title, 16, "\nindex: %u", index);
8284 rte_hexdump(stdout, title, raw_data, raw_size);
8286 } while (all && ++index < RAW_ENCAP_CONFS_MAX_NUM);
8289 cmdline_parse_token_string_t cmd_show_set_raw_cmd_show =
8290 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
8292 cmdline_parse_token_string_t cmd_show_set_raw_cmd_what =
8293 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
8294 cmd_what, "raw_encap#raw_decap");
8295 cmdline_parse_token_num_t cmd_show_set_raw_cmd_index =
8296 TOKEN_NUM_INITIALIZER(struct cmd_show_set_raw_result,
8297 cmd_index, RTE_UINT16);
8298 cmdline_parse_token_string_t cmd_show_set_raw_cmd_all =
8299 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
8301 cmdline_parse_inst_t cmd_show_set_raw = {
8302 .f = cmd_show_set_raw_parsed,
8304 .help_str = "show <raw_encap|raw_decap> <index>",
8306 (void *)&cmd_show_set_raw_cmd_show,
8307 (void *)&cmd_show_set_raw_cmd_what,
8308 (void *)&cmd_show_set_raw_cmd_index,
8312 cmdline_parse_inst_t cmd_show_set_raw_all = {
8313 .f = cmd_show_set_raw_parsed,
8315 .help_str = "show <raw_encap|raw_decap> all",
8317 (void *)&cmd_show_set_raw_cmd_show,
8318 (void *)&cmd_show_set_raw_cmd_what,
8319 (void *)&cmd_show_set_raw_cmd_all,