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_rss_data sample_rss_data[RAW_SAMPLE_CONFS_MAX_NUM];
587 static const char *const modify_field_ops[] = {
588 "set", "add", "sub", NULL
591 static const char *const modify_field_ids[] = {
592 "start", "mac_dst", "mac_src",
593 "vlan_type", "vlan_id", "mac_type",
594 "ipv4_dscp", "ipv4_ttl", "ipv4_src", "ipv4_dst",
595 "ipv6_dscp", "ipv6_hoplimit", "ipv6_src", "ipv6_dst",
596 "tcp_port_src", "tcp_port_dst",
597 "tcp_seq_num", "tcp_ack_num", "tcp_flags",
598 "udp_port_src", "udp_port_dst",
599 "vxlan_vni", "geneve_vni", "gtp_teid",
600 "tag", "mark", "meta", "pointer", "value", NULL
603 /** Maximum number of subsequent tokens and arguments on the stack. */
604 #define CTX_STACK_SIZE 16
606 /** Parser context. */
608 /** Stack of subsequent token lists to process. */
609 const enum index *next[CTX_STACK_SIZE];
610 /** Arguments for stacked tokens. */
611 const void *args[CTX_STACK_SIZE];
612 enum index curr; /**< Current token index. */
613 enum index prev; /**< Index of the last token seen. */
614 int next_num; /**< Number of entries in next[]. */
615 int args_num; /**< Number of entries in args[]. */
616 uint32_t eol:1; /**< EOL has been detected. */
617 uint32_t last:1; /**< No more arguments. */
618 portid_t port; /**< Current port ID (for completions). */
619 uint32_t objdata; /**< Object-specific data. */
620 void *object; /**< Address of current object for relative offsets. */
621 void *objmask; /**< Object a full mask must be written to. */
624 /** Token argument. */
626 uint32_t hton:1; /**< Use network byte ordering. */
627 uint32_t sign:1; /**< Value is signed. */
628 uint32_t bounded:1; /**< Value is bounded. */
629 uintmax_t min; /**< Minimum value if bounded. */
630 uintmax_t max; /**< Maximum value if bounded. */
631 uint32_t offset; /**< Relative offset from ctx->object. */
632 uint32_t size; /**< Field size. */
633 const uint8_t *mask; /**< Bit-mask to use instead of offset/size. */
636 /** Parser token definition. */
638 /** Type displayed during completion (defaults to "TOKEN"). */
640 /** Help displayed during completion (defaults to token name). */
642 /** Private data used by parser functions. */
645 * Lists of subsequent tokens to push on the stack. Each call to the
646 * parser consumes the last entry of that stack.
648 const enum index *const *next;
649 /** Arguments stack for subsequent tokens that need them. */
650 const struct arg *const *args;
652 * Token-processing callback, returns -1 in case of error, the
653 * length of the matched string otherwise. If NULL, attempts to
654 * match the token name.
656 * If buf is not NULL, the result should be stored in it according
657 * to context. An error is returned if not large enough.
659 int (*call)(struct context *ctx, const struct token *token,
660 const char *str, unsigned int len,
661 void *buf, unsigned int size);
663 * Callback that provides possible values for this token, used for
664 * completion. Returns -1 in case of error, the number of possible
665 * values otherwise. If NULL, the token name is used.
667 * If buf is not NULL, entry index ent is written to buf and the
668 * full length of the entry is returned (same behavior as
671 int (*comp)(struct context *ctx, const struct token *token,
672 unsigned int ent, char *buf, unsigned int size);
673 /** Mandatory token name, no default value. */
677 /** Static initializer for the next field. */
678 #define NEXT(...) (const enum index *const []){ __VA_ARGS__, NULL, }
680 /** Static initializer for a NEXT() entry. */
681 #define NEXT_ENTRY(...) (const enum index []){ __VA_ARGS__, ZERO, }
683 /** Static initializer for the args field. */
684 #define ARGS(...) (const struct arg *const []){ __VA_ARGS__, NULL, }
686 /** Static initializer for ARGS() to target a field. */
687 #define ARGS_ENTRY(s, f) \
688 (&(const struct arg){ \
689 .offset = offsetof(s, f), \
690 .size = sizeof(((s *)0)->f), \
693 /** Static initializer for ARGS() to target a bit-field. */
694 #define ARGS_ENTRY_BF(s, f, b) \
695 (&(const struct arg){ \
697 .mask = (const void *)&(const s){ .f = (1 << (b)) - 1 }, \
700 /** Static initializer for ARGS() to target a field with limits. */
701 #define ARGS_ENTRY_BOUNDED(s, f, i, a) \
702 (&(const struct arg){ \
706 .offset = offsetof(s, f), \
707 .size = sizeof(((s *)0)->f), \
710 /** Static initializer for ARGS() to target an arbitrary bit-mask. */
711 #define ARGS_ENTRY_MASK(s, f, m) \
712 (&(const struct arg){ \
713 .offset = offsetof(s, f), \
714 .size = sizeof(((s *)0)->f), \
715 .mask = (const void *)(m), \
718 /** Same as ARGS_ENTRY_MASK() using network byte ordering for the value. */
719 #define ARGS_ENTRY_MASK_HTON(s, f, m) \
720 (&(const struct arg){ \
722 .offset = offsetof(s, f), \
723 .size = sizeof(((s *)0)->f), \
724 .mask = (const void *)(m), \
727 /** Static initializer for ARGS() to target a pointer. */
728 #define ARGS_ENTRY_PTR(s, f) \
729 (&(const struct arg){ \
730 .size = sizeof(*((s *)0)->f), \
733 /** Static initializer for ARGS() with arbitrary offset and size. */
734 #define ARGS_ENTRY_ARB(o, s) \
735 (&(const struct arg){ \
740 /** Same as ARGS_ENTRY_ARB() with bounded values. */
741 #define ARGS_ENTRY_ARB_BOUNDED(o, s, i, a) \
742 (&(const struct arg){ \
750 /** Same as ARGS_ENTRY() using network byte ordering. */
751 #define ARGS_ENTRY_HTON(s, f) \
752 (&(const struct arg){ \
754 .offset = offsetof(s, f), \
755 .size = sizeof(((s *)0)->f), \
758 /** Same as ARGS_ENTRY_HTON() for a single argument, without structure. */
759 #define ARG_ENTRY_HTON(s) \
760 (&(const struct arg){ \
766 /** Parser output buffer layout expected by cmd_flow_parsed(). */
768 enum index command; /**< Flow command. */
769 portid_t port; /**< Affected port ID. */
773 uint32_t action_id_n;
774 } sa_destroy; /**< Shared action destroy arguments. */
777 } sa; /* Shared action query arguments */
779 struct rte_flow_attr attr;
780 struct tunnel_ops tunnel_ops;
781 struct rte_flow_item *pattern;
782 struct rte_flow_action *actions;
786 } vc; /**< Validate/create arguments. */
790 } destroy; /**< Destroy arguments. */
793 } dump; /**< Dump arguments. */
796 struct rte_flow_action action;
797 } query; /**< Query arguments. */
801 } list; /**< List arguments. */
804 } isolate; /**< Isolated mode arguments. */
807 } aged; /**< Aged arguments. */
808 } args; /**< Command arguments. */
811 /** Private data for pattern items. */
812 struct parse_item_priv {
813 enum rte_flow_item_type type; /**< Item type. */
814 uint32_t size; /**< Size of item specification structure. */
817 #define PRIV_ITEM(t, s) \
818 (&(const struct parse_item_priv){ \
819 .type = RTE_FLOW_ITEM_TYPE_ ## t, \
823 /** Private data for actions. */
824 struct parse_action_priv {
825 enum rte_flow_action_type type; /**< Action type. */
826 uint32_t size; /**< Size of action configuration structure. */
829 #define PRIV_ACTION(t, s) \
830 (&(const struct parse_action_priv){ \
831 .type = RTE_FLOW_ACTION_TYPE_ ## t, \
835 static const enum index next_sa_create_attr[] = {
836 SHARED_ACTION_CREATE_ID,
837 SHARED_ACTION_INGRESS,
838 SHARED_ACTION_EGRESS,
839 SHARED_ACTION_TRANSFER,
844 static const enum index next_sa_subcmd[] = {
845 SHARED_ACTION_CREATE,
846 SHARED_ACTION_UPDATE,
847 SHARED_ACTION_DESTROY,
852 static const enum index next_vc_attr[] = {
864 static const enum index next_destroy_attr[] = {
870 static const enum index next_dump_attr[] = {
876 static const enum index next_list_attr[] = {
882 static const enum index next_aged_attr[] = {
888 static const enum index next_sa_destroy_attr[] = {
889 SHARED_ACTION_DESTROY_ID,
894 static const enum index item_param[] = {
903 static const enum index next_item[] = {
940 ITEM_ICMP6_ND_OPT_SLA_ETH,
941 ITEM_ICMP6_ND_OPT_TLA_ETH,
960 static const enum index item_fuzzy[] = {
966 static const enum index item_any[] = {
972 static const enum index item_vf[] = {
978 static const enum index item_phy_port[] = {
984 static const enum index item_port_id[] = {
990 static const enum index item_mark[] = {
996 static const enum index item_raw[] = {
1006 static const enum index item_eth[] = {
1015 static const enum index item_vlan[] = {
1020 ITEM_VLAN_INNER_TYPE,
1021 ITEM_VLAN_HAS_MORE_VLAN,
1026 static const enum index item_ipv4[] = {
1028 ITEM_IPV4_FRAGMENT_OFFSET,
1037 static const enum index item_ipv6[] = {
1044 ITEM_IPV6_HAS_FRAG_EXT,
1049 static const enum index item_icmp[] = {
1058 static const enum index item_udp[] = {
1065 static const enum index item_tcp[] = {
1073 static const enum index item_sctp[] = {
1082 static const enum index item_vxlan[] = {
1088 static const enum index item_e_tag[] = {
1089 ITEM_E_TAG_GRP_ECID_B,
1094 static const enum index item_nvgre[] = {
1100 static const enum index item_mpls[] = {
1108 static const enum index item_gre[] = {
1110 ITEM_GRE_C_RSVD0_VER,
1118 static const enum index item_gre_key[] = {
1124 static const enum index item_gtp[] = {
1132 static const enum index item_geneve[] = {
1140 static const enum index item_vxlan_gpe[] = {
1146 static const enum index item_arp_eth_ipv4[] = {
1147 ITEM_ARP_ETH_IPV4_SHA,
1148 ITEM_ARP_ETH_IPV4_SPA,
1149 ITEM_ARP_ETH_IPV4_THA,
1150 ITEM_ARP_ETH_IPV4_TPA,
1155 static const enum index item_ipv6_ext[] = {
1156 ITEM_IPV6_EXT_NEXT_HDR,
1161 static const enum index item_ipv6_frag_ext[] = {
1162 ITEM_IPV6_FRAG_EXT_NEXT_HDR,
1163 ITEM_IPV6_FRAG_EXT_FRAG_DATA,
1168 static const enum index item_icmp6[] = {
1175 static const enum index item_icmp6_nd_ns[] = {
1176 ITEM_ICMP6_ND_NS_TARGET_ADDR,
1181 static const enum index item_icmp6_nd_na[] = {
1182 ITEM_ICMP6_ND_NA_TARGET_ADDR,
1187 static const enum index item_icmp6_nd_opt[] = {
1188 ITEM_ICMP6_ND_OPT_TYPE,
1193 static const enum index item_icmp6_nd_opt_sla_eth[] = {
1194 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
1199 static const enum index item_icmp6_nd_opt_tla_eth[] = {
1200 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
1205 static const enum index item_meta[] = {
1211 static const enum index item_gtp_psc[] = {
1218 static const enum index item_pppoed[] = {
1224 static const enum index item_pppoes[] = {
1230 static const enum index item_pppoe_proto_id[] = {
1235 static const enum index item_higig2[] = {
1236 ITEM_HIGIG2_CLASSIFICATION,
1242 static const enum index item_esp[] = {
1248 static const enum index item_ah[] = {
1254 static const enum index item_pfcp[] = {
1261 static const enum index next_set_raw[] = {
1267 static const enum index item_tag[] = {
1274 static const enum index item_l2tpv3oip[] = {
1275 ITEM_L2TPV3OIP_SESSION_ID,
1280 static const enum index item_ecpri[] = {
1286 static const enum index item_ecpri_common[] = {
1287 ITEM_ECPRI_COMMON_TYPE,
1291 static const enum index item_ecpri_common_type[] = {
1292 ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
1293 ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
1294 ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
1298 static const enum index item_geneve_opt[] = {
1299 ITEM_GENEVE_OPT_CLASS,
1300 ITEM_GENEVE_OPT_TYPE,
1301 ITEM_GENEVE_OPT_LENGTH,
1302 ITEM_GENEVE_OPT_DATA,
1307 static const enum index next_action[] = {
1323 ACTION_OF_SET_MPLS_TTL,
1324 ACTION_OF_DEC_MPLS_TTL,
1325 ACTION_OF_SET_NW_TTL,
1326 ACTION_OF_DEC_NW_TTL,
1327 ACTION_OF_COPY_TTL_OUT,
1328 ACTION_OF_COPY_TTL_IN,
1330 ACTION_OF_PUSH_VLAN,
1331 ACTION_OF_SET_VLAN_VID,
1332 ACTION_OF_SET_VLAN_PCP,
1334 ACTION_OF_PUSH_MPLS,
1341 ACTION_MPLSOGRE_ENCAP,
1342 ACTION_MPLSOGRE_DECAP,
1343 ACTION_MPLSOUDP_ENCAP,
1344 ACTION_MPLSOUDP_DECAP,
1345 ACTION_SET_IPV4_SRC,
1346 ACTION_SET_IPV4_DST,
1347 ACTION_SET_IPV6_SRC,
1348 ACTION_SET_IPV6_DST,
1364 ACTION_SET_IPV4_DSCP,
1365 ACTION_SET_IPV6_DSCP,
1369 ACTION_MODIFY_FIELD,
1373 static const enum index action_mark[] = {
1379 static const enum index action_queue[] = {
1385 static const enum index action_count[] = {
1387 ACTION_COUNT_SHARED,
1392 static const enum index action_rss[] = {
1403 static const enum index action_vf[] = {
1410 static const enum index action_phy_port[] = {
1411 ACTION_PHY_PORT_ORIGINAL,
1412 ACTION_PHY_PORT_INDEX,
1417 static const enum index action_port_id[] = {
1418 ACTION_PORT_ID_ORIGINAL,
1424 static const enum index action_meter[] = {
1430 static const enum index action_of_set_mpls_ttl[] = {
1431 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
1436 static const enum index action_of_set_nw_ttl[] = {
1437 ACTION_OF_SET_NW_TTL_NW_TTL,
1442 static const enum index action_of_push_vlan[] = {
1443 ACTION_OF_PUSH_VLAN_ETHERTYPE,
1448 static const enum index action_of_set_vlan_vid[] = {
1449 ACTION_OF_SET_VLAN_VID_VLAN_VID,
1454 static const enum index action_of_set_vlan_pcp[] = {
1455 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
1460 static const enum index action_of_pop_mpls[] = {
1461 ACTION_OF_POP_MPLS_ETHERTYPE,
1466 static const enum index action_of_push_mpls[] = {
1467 ACTION_OF_PUSH_MPLS_ETHERTYPE,
1472 static const enum index action_set_ipv4_src[] = {
1473 ACTION_SET_IPV4_SRC_IPV4_SRC,
1478 static const enum index action_set_mac_src[] = {
1479 ACTION_SET_MAC_SRC_MAC_SRC,
1484 static const enum index action_set_ipv4_dst[] = {
1485 ACTION_SET_IPV4_DST_IPV4_DST,
1490 static const enum index action_set_ipv6_src[] = {
1491 ACTION_SET_IPV6_SRC_IPV6_SRC,
1496 static const enum index action_set_ipv6_dst[] = {
1497 ACTION_SET_IPV6_DST_IPV6_DST,
1502 static const enum index action_set_tp_src[] = {
1503 ACTION_SET_TP_SRC_TP_SRC,
1508 static const enum index action_set_tp_dst[] = {
1509 ACTION_SET_TP_DST_TP_DST,
1514 static const enum index action_set_ttl[] = {
1520 static const enum index action_jump[] = {
1526 static const enum index action_set_mac_dst[] = {
1527 ACTION_SET_MAC_DST_MAC_DST,
1532 static const enum index action_inc_tcp_seq[] = {
1533 ACTION_INC_TCP_SEQ_VALUE,
1538 static const enum index action_dec_tcp_seq[] = {
1539 ACTION_DEC_TCP_SEQ_VALUE,
1544 static const enum index action_inc_tcp_ack[] = {
1545 ACTION_INC_TCP_ACK_VALUE,
1550 static const enum index action_dec_tcp_ack[] = {
1551 ACTION_DEC_TCP_ACK_VALUE,
1556 static const enum index action_raw_encap[] = {
1557 ACTION_RAW_ENCAP_INDEX,
1562 static const enum index action_raw_decap[] = {
1563 ACTION_RAW_DECAP_INDEX,
1568 static const enum index action_set_tag[] = {
1569 ACTION_SET_TAG_DATA,
1570 ACTION_SET_TAG_INDEX,
1571 ACTION_SET_TAG_MASK,
1576 static const enum index action_set_meta[] = {
1577 ACTION_SET_META_DATA,
1578 ACTION_SET_META_MASK,
1583 static const enum index action_set_ipv4_dscp[] = {
1584 ACTION_SET_IPV4_DSCP_VALUE,
1589 static const enum index action_set_ipv6_dscp[] = {
1590 ACTION_SET_IPV6_DSCP_VALUE,
1595 static const enum index action_age[] = {
1602 static const enum index action_sample[] = {
1604 ACTION_SAMPLE_RATIO,
1605 ACTION_SAMPLE_INDEX,
1610 static const enum index next_action_sample[] = {
1621 static const enum index action_modify_field_dst[] = {
1622 ACTION_MODIFY_FIELD_DST_LEVEL,
1623 ACTION_MODIFY_FIELD_DST_OFFSET,
1624 ACTION_MODIFY_FIELD_SRC_TYPE,
1628 static const enum index action_modify_field_src[] = {
1629 ACTION_MODIFY_FIELD_SRC_LEVEL,
1630 ACTION_MODIFY_FIELD_SRC_OFFSET,
1631 ACTION_MODIFY_FIELD_SRC_VALUE,
1632 ACTION_MODIFY_FIELD_WIDTH,
1636 static int parse_set_raw_encap_decap(struct context *, const struct token *,
1637 const char *, unsigned int,
1638 void *, unsigned int);
1639 static int parse_set_sample_action(struct context *, const struct token *,
1640 const char *, unsigned int,
1641 void *, unsigned int);
1642 static int parse_set_init(struct context *, const struct token *,
1643 const char *, unsigned int,
1644 void *, unsigned int);
1645 static int parse_init(struct context *, const struct token *,
1646 const char *, unsigned int,
1647 void *, unsigned int);
1648 static int parse_vc(struct context *, const struct token *,
1649 const char *, unsigned int,
1650 void *, unsigned int);
1651 static int parse_vc_spec(struct context *, const struct token *,
1652 const char *, unsigned int, void *, unsigned int);
1653 static int parse_vc_conf(struct context *, const struct token *,
1654 const char *, unsigned int, void *, unsigned int);
1655 static int parse_vc_item_ecpri_type(struct context *, const struct token *,
1656 const char *, unsigned int,
1657 void *, unsigned int);
1658 static int parse_vc_action_rss(struct context *, const struct token *,
1659 const char *, unsigned int, void *,
1661 static int parse_vc_action_rss_func(struct context *, const struct token *,
1662 const char *, unsigned int, void *,
1664 static int parse_vc_action_rss_type(struct context *, const struct token *,
1665 const char *, unsigned int, void *,
1667 static int parse_vc_action_rss_queue(struct context *, const struct token *,
1668 const char *, unsigned int, void *,
1670 static int parse_vc_action_vxlan_encap(struct context *, const struct token *,
1671 const char *, unsigned int, void *,
1673 static int parse_vc_action_nvgre_encap(struct context *, const struct token *,
1674 const char *, unsigned int, void *,
1676 static int parse_vc_action_l2_encap(struct context *, const struct token *,
1677 const char *, unsigned int, void *,
1679 static int parse_vc_action_l2_decap(struct context *, const struct token *,
1680 const char *, unsigned int, void *,
1682 static int parse_vc_action_mplsogre_encap(struct context *,
1683 const struct token *, const char *,
1684 unsigned int, void *, unsigned int);
1685 static int parse_vc_action_mplsogre_decap(struct context *,
1686 const struct token *, const char *,
1687 unsigned int, void *, unsigned int);
1688 static int parse_vc_action_mplsoudp_encap(struct context *,
1689 const struct token *, const char *,
1690 unsigned int, void *, unsigned int);
1691 static int parse_vc_action_mplsoudp_decap(struct context *,
1692 const struct token *, const char *,
1693 unsigned int, void *, unsigned int);
1694 static int parse_vc_action_raw_encap(struct context *,
1695 const struct token *, const char *,
1696 unsigned int, void *, unsigned int);
1697 static int parse_vc_action_raw_decap(struct context *,
1698 const struct token *, const char *,
1699 unsigned int, void *, unsigned int);
1700 static int parse_vc_action_raw_encap_index(struct context *,
1701 const struct token *, const char *,
1702 unsigned int, void *, unsigned int);
1703 static int parse_vc_action_raw_decap_index(struct context *,
1704 const struct token *, const char *,
1705 unsigned int, void *, unsigned int);
1706 static int parse_vc_action_set_meta(struct context *ctx,
1707 const struct token *token, const char *str,
1708 unsigned int len, void *buf,
1710 static int parse_vc_action_sample(struct context *ctx,
1711 const struct token *token, const char *str,
1712 unsigned int len, void *buf,
1715 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
1716 const char *str, unsigned int len, void *buf,
1719 parse_vc_modify_field_op(struct context *ctx, const struct token *token,
1720 const char *str, unsigned int len, void *buf,
1723 parse_vc_modify_field_id(struct context *ctx, const struct token *token,
1724 const char *str, unsigned int len, void *buf,
1726 static int parse_destroy(struct context *, const struct token *,
1727 const char *, unsigned int,
1728 void *, unsigned int);
1729 static int parse_flush(struct context *, const struct token *,
1730 const char *, unsigned int,
1731 void *, unsigned int);
1732 static int parse_dump(struct context *, const struct token *,
1733 const char *, unsigned int,
1734 void *, unsigned int);
1735 static int parse_query(struct context *, const struct token *,
1736 const char *, unsigned int,
1737 void *, unsigned int);
1738 static int parse_action(struct context *, const struct token *,
1739 const char *, unsigned int,
1740 void *, unsigned int);
1741 static int parse_list(struct context *, const struct token *,
1742 const char *, unsigned int,
1743 void *, unsigned int);
1744 static int parse_aged(struct context *, const struct token *,
1745 const char *, unsigned int,
1746 void *, unsigned int);
1747 static int parse_isolate(struct context *, const struct token *,
1748 const char *, unsigned int,
1749 void *, unsigned int);
1750 static int parse_tunnel(struct context *, const struct token *,
1751 const char *, unsigned int,
1752 void *, unsigned int);
1753 static int parse_int(struct context *, const struct token *,
1754 const char *, unsigned int,
1755 void *, unsigned int);
1756 static int parse_prefix(struct context *, const struct token *,
1757 const char *, unsigned int,
1758 void *, unsigned int);
1759 static int parse_boolean(struct context *, const struct token *,
1760 const char *, unsigned int,
1761 void *, unsigned int);
1762 static int parse_string(struct context *, const struct token *,
1763 const char *, unsigned int,
1764 void *, unsigned int);
1765 static int parse_hex(struct context *ctx, const struct token *token,
1766 const char *str, unsigned int len,
1767 void *buf, unsigned int size);
1768 static int parse_string0(struct context *, const struct token *,
1769 const char *, unsigned int,
1770 void *, unsigned int);
1771 static int parse_mac_addr(struct context *, const struct token *,
1772 const char *, unsigned int,
1773 void *, unsigned int);
1774 static int parse_ipv4_addr(struct context *, const struct token *,
1775 const char *, unsigned int,
1776 void *, unsigned int);
1777 static int parse_ipv6_addr(struct context *, const struct token *,
1778 const char *, unsigned int,
1779 void *, unsigned int);
1780 static int parse_port(struct context *, const struct token *,
1781 const char *, unsigned int,
1782 void *, unsigned int);
1783 static int parse_sa(struct context *, const struct token *,
1784 const char *, unsigned int,
1785 void *, unsigned int);
1786 static int parse_sa_destroy(struct context *ctx, const struct token *token,
1787 const char *str, unsigned int len,
1788 void *buf, unsigned int size);
1789 static int parse_sa_id2ptr(struct context *ctx, const struct token *token,
1790 const char *str, unsigned int len, void *buf,
1792 static int comp_none(struct context *, const struct token *,
1793 unsigned int, char *, unsigned int);
1794 static int comp_boolean(struct context *, const struct token *,
1795 unsigned int, char *, unsigned int);
1796 static int comp_action(struct context *, const struct token *,
1797 unsigned int, char *, unsigned int);
1798 static int comp_port(struct context *, const struct token *,
1799 unsigned int, char *, unsigned int);
1800 static int comp_rule_id(struct context *, const struct token *,
1801 unsigned int, char *, unsigned int);
1802 static int comp_vc_action_rss_type(struct context *, const struct token *,
1803 unsigned int, char *, unsigned int);
1804 static int comp_vc_action_rss_queue(struct context *, const struct token *,
1805 unsigned int, char *, unsigned int);
1806 static int comp_set_raw_index(struct context *, const struct token *,
1807 unsigned int, char *, unsigned int);
1808 static int comp_set_sample_index(struct context *, const struct token *,
1809 unsigned int, char *, unsigned int);
1810 static int comp_set_modify_field_op(struct context *, const struct token *,
1811 unsigned int, char *, unsigned int);
1812 static int comp_set_modify_field_id(struct context *, const struct token *,
1813 unsigned int, char *, unsigned int);
1815 /** Token definitions. */
1816 static const struct token token_list[] = {
1817 /* Special tokens. */
1820 .help = "null entry, abused as the entry point",
1821 .next = NEXT(NEXT_ENTRY(FLOW)),
1826 .help = "command may end here",
1829 .name = "START_SET",
1830 .help = "null entry, abused as the entry point for set",
1831 .next = NEXT(NEXT_ENTRY(SET)),
1836 .help = "set command may end here",
1838 /* Common tokens. */
1842 .help = "integer value",
1847 .name = "{unsigned}",
1849 .help = "unsigned integer value",
1856 .help = "prefix length for bit-mask",
1857 .call = parse_prefix,
1861 .name = "{boolean}",
1863 .help = "any boolean value",
1864 .call = parse_boolean,
1865 .comp = comp_boolean,
1870 .help = "fixed string",
1871 .call = parse_string,
1877 .help = "fixed string",
1881 .name = "{file path}",
1883 .help = "file path",
1884 .call = parse_string0,
1888 .name = "{MAC address}",
1890 .help = "standard MAC address notation",
1891 .call = parse_mac_addr,
1895 .name = "{IPv4 address}",
1896 .type = "IPV4 ADDRESS",
1897 .help = "standard IPv4 address notation",
1898 .call = parse_ipv4_addr,
1902 .name = "{IPv6 address}",
1903 .type = "IPV6 ADDRESS",
1904 .help = "standard IPv6 address notation",
1905 .call = parse_ipv6_addr,
1909 .name = "{rule id}",
1911 .help = "rule identifier",
1913 .comp = comp_rule_id,
1916 .name = "{port_id}",
1918 .help = "port identifier",
1923 .name = "{group_id}",
1925 .help = "group identifier",
1929 [PRIORITY_LEVEL] = {
1932 .help = "priority level",
1936 [SHARED_ACTION_ID] = {
1937 .name = "{shared_action_id}",
1938 .type = "SHARED_ACTION_ID",
1939 .help = "shared action id",
1943 /* Top-level command. */
1946 .type = "{command} {port_id} [{arg} [...]]",
1947 .help = "manage ingress/egress flow rules",
1948 .next = NEXT(NEXT_ENTRY
1962 /* Top-level command. */
1964 .name = "shared_action",
1965 .type = "{command} {port_id} [{arg} [...]]",
1966 .help = "manage shared actions",
1967 .next = NEXT(next_sa_subcmd, NEXT_ENTRY(PORT_ID)),
1968 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1971 /* Sub-level commands. */
1972 [SHARED_ACTION_CREATE] = {
1974 .help = "create shared action",
1975 .next = NEXT(next_sa_create_attr),
1978 [SHARED_ACTION_UPDATE] = {
1980 .help = "update shared action",
1981 .next = NEXT(NEXT_ENTRY(SHARED_ACTION_SPEC),
1982 NEXT_ENTRY(SHARED_ACTION_ID)),
1983 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
1986 [SHARED_ACTION_DESTROY] = {
1988 .help = "destroy shared action",
1989 .next = NEXT(NEXT_ENTRY(SHARED_ACTION_DESTROY_ID)),
1990 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1991 .call = parse_sa_destroy,
1993 [SHARED_ACTION_QUERY] = {
1995 .help = "query shared action",
1996 .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(SHARED_ACTION_ID)),
1997 .args = ARGS(ARGS_ENTRY(struct buffer, args.sa.action_id)),
2002 .help = "check whether a flow rule can be created",
2003 .next = NEXT(next_vc_attr, NEXT_ENTRY(PORT_ID)),
2004 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2009 .help = "create a flow rule",
2010 .next = NEXT(next_vc_attr, NEXT_ENTRY(PORT_ID)),
2011 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2016 .help = "destroy specific flow rules",
2017 .next = NEXT(NEXT_ENTRY(DESTROY_RULE), NEXT_ENTRY(PORT_ID)),
2018 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2019 .call = parse_destroy,
2023 .help = "destroy all flow rules",
2024 .next = NEXT(NEXT_ENTRY(PORT_ID)),
2025 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2026 .call = parse_flush,
2030 .help = "dump all flow rules to file",
2031 .next = NEXT(next_dump_attr, NEXT_ENTRY(PORT_ID)),
2032 .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file),
2033 ARGS_ENTRY(struct buffer, port)),
2038 .help = "query an existing flow rule",
2039 .next = NEXT(NEXT_ENTRY(QUERY_ACTION),
2040 NEXT_ENTRY(RULE_ID),
2041 NEXT_ENTRY(PORT_ID)),
2042 .args = ARGS(ARGS_ENTRY(struct buffer, args.query.action.type),
2043 ARGS_ENTRY(struct buffer, args.query.rule),
2044 ARGS_ENTRY(struct buffer, port)),
2045 .call = parse_query,
2049 .help = "list existing flow rules",
2050 .next = NEXT(next_list_attr, NEXT_ENTRY(PORT_ID)),
2051 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2056 .help = "list and destroy aged flows",
2057 .next = NEXT(next_aged_attr, NEXT_ENTRY(PORT_ID)),
2058 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2063 .help = "restrict ingress traffic to the defined flow rules",
2064 .next = NEXT(NEXT_ENTRY(BOOLEAN),
2065 NEXT_ENTRY(PORT_ID)),
2066 .args = ARGS(ARGS_ENTRY(struct buffer, args.isolate.set),
2067 ARGS_ENTRY(struct buffer, port)),
2068 .call = parse_isolate,
2072 .help = "new tunnel API",
2073 .next = NEXT(NEXT_ENTRY
2074 (TUNNEL_CREATE, TUNNEL_LIST, TUNNEL_DESTROY)),
2075 .call = parse_tunnel,
2077 /* Tunnel arguments. */
2080 .help = "create new tunnel object",
2081 .next = NEXT(NEXT_ENTRY(TUNNEL_CREATE_TYPE),
2082 NEXT_ENTRY(PORT_ID)),
2083 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2084 .call = parse_tunnel,
2086 [TUNNEL_CREATE_TYPE] = {
2088 .help = "create new tunnel",
2089 .next = NEXT(NEXT_ENTRY(FILE_PATH)),
2090 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, type)),
2091 .call = parse_tunnel,
2093 [TUNNEL_DESTROY] = {
2095 .help = "destroy tunel",
2096 .next = NEXT(NEXT_ENTRY(TUNNEL_DESTROY_ID),
2097 NEXT_ENTRY(PORT_ID)),
2098 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2099 .call = parse_tunnel,
2101 [TUNNEL_DESTROY_ID] = {
2103 .help = "tunnel identifier to testroy",
2104 .next = NEXT(NEXT_ENTRY(UNSIGNED)),
2105 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2106 .call = parse_tunnel,
2110 .help = "list existing tunnels",
2111 .next = NEXT(NEXT_ENTRY(PORT_ID)),
2112 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
2113 .call = parse_tunnel,
2115 /* Destroy arguments. */
2118 .help = "specify a rule identifier",
2119 .next = NEXT(next_destroy_attr, NEXT_ENTRY(RULE_ID)),
2120 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.destroy.rule)),
2121 .call = parse_destroy,
2123 /* Query arguments. */
2127 .help = "action to query, must be part of the rule",
2128 .call = parse_action,
2129 .comp = comp_action,
2131 /* List arguments. */
2134 .help = "specify a group",
2135 .next = NEXT(next_list_attr, NEXT_ENTRY(GROUP_ID)),
2136 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.list.group)),
2141 .help = "specify aged flows need be destroyed",
2145 /* Validate/create attributes. */
2148 .help = "specify a group",
2149 .next = NEXT(next_vc_attr, NEXT_ENTRY(GROUP_ID)),
2150 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, group)),
2155 .help = "specify a priority level",
2156 .next = NEXT(next_vc_attr, NEXT_ENTRY(PRIORITY_LEVEL)),
2157 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, priority)),
2162 .help = "affect rule to ingress",
2163 .next = NEXT(next_vc_attr),
2168 .help = "affect rule to egress",
2169 .next = NEXT(next_vc_attr),
2174 .help = "apply rule directly to endpoints found in pattern",
2175 .next = NEXT(next_vc_attr),
2179 .name = "tunnel_set",
2180 .help = "tunnel steer rule",
2181 .next = NEXT(next_vc_attr, NEXT_ENTRY(UNSIGNED)),
2182 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2186 .name = "tunnel_match",
2187 .help = "tunnel match rule",
2188 .next = NEXT(next_vc_attr, NEXT_ENTRY(UNSIGNED)),
2189 .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
2192 /* Validate/create pattern. */
2195 .help = "submit a list of pattern items",
2196 .next = NEXT(next_item),
2201 .help = "match value perfectly (with full bit-mask)",
2202 .call = parse_vc_spec,
2204 [ITEM_PARAM_SPEC] = {
2206 .help = "match value according to configured bit-mask",
2207 .call = parse_vc_spec,
2209 [ITEM_PARAM_LAST] = {
2211 .help = "specify upper bound to establish a range",
2212 .call = parse_vc_spec,
2214 [ITEM_PARAM_MASK] = {
2216 .help = "specify bit-mask with relevant bits set to one",
2217 .call = parse_vc_spec,
2219 [ITEM_PARAM_PREFIX] = {
2221 .help = "generate bit-mask from a prefix length",
2222 .call = parse_vc_spec,
2226 .help = "specify next pattern item",
2227 .next = NEXT(next_item),
2231 .help = "end list of pattern items",
2232 .priv = PRIV_ITEM(END, 0),
2233 .next = NEXT(NEXT_ENTRY(ACTIONS)),
2238 .help = "no-op pattern item",
2239 .priv = PRIV_ITEM(VOID, 0),
2240 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2245 .help = "perform actions when pattern does not match",
2246 .priv = PRIV_ITEM(INVERT, 0),
2247 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2252 .help = "match any protocol for the current layer",
2253 .priv = PRIV_ITEM(ANY, sizeof(struct rte_flow_item_any)),
2254 .next = NEXT(item_any),
2259 .help = "number of layers covered",
2260 .next = NEXT(item_any, NEXT_ENTRY(UNSIGNED), item_param),
2261 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_any, num)),
2265 .help = "match traffic from/to the physical function",
2266 .priv = PRIV_ITEM(PF, 0),
2267 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
2272 .help = "match traffic from/to a virtual function ID",
2273 .priv = PRIV_ITEM(VF, sizeof(struct rte_flow_item_vf)),
2274 .next = NEXT(item_vf),
2280 .next = NEXT(item_vf, NEXT_ENTRY(UNSIGNED), item_param),
2281 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_vf, id)),
2285 .help = "match traffic from/to a specific physical port",
2286 .priv = PRIV_ITEM(PHY_PORT,
2287 sizeof(struct rte_flow_item_phy_port)),
2288 .next = NEXT(item_phy_port),
2291 [ITEM_PHY_PORT_INDEX] = {
2293 .help = "physical port index",
2294 .next = NEXT(item_phy_port, NEXT_ENTRY(UNSIGNED), item_param),
2295 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_phy_port, index)),
2299 .help = "match traffic from/to a given DPDK port ID",
2300 .priv = PRIV_ITEM(PORT_ID,
2301 sizeof(struct rte_flow_item_port_id)),
2302 .next = NEXT(item_port_id),
2305 [ITEM_PORT_ID_ID] = {
2307 .help = "DPDK port ID",
2308 .next = NEXT(item_port_id, NEXT_ENTRY(UNSIGNED), item_param),
2309 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port_id, id)),
2313 .help = "match traffic against value set in previously matched rule",
2314 .priv = PRIV_ITEM(MARK, sizeof(struct rte_flow_item_mark)),
2315 .next = NEXT(item_mark),
2320 .help = "Integer value to match against",
2321 .next = NEXT(item_mark, NEXT_ENTRY(UNSIGNED), item_param),
2322 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_mark, id)),
2326 .help = "match an arbitrary byte string",
2327 .priv = PRIV_ITEM(RAW, ITEM_RAW_SIZE),
2328 .next = NEXT(item_raw),
2331 [ITEM_RAW_RELATIVE] = {
2333 .help = "look for pattern after the previous item",
2334 .next = NEXT(item_raw, NEXT_ENTRY(BOOLEAN), item_param),
2335 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
2338 [ITEM_RAW_SEARCH] = {
2340 .help = "search pattern from offset (see also limit)",
2341 .next = NEXT(item_raw, NEXT_ENTRY(BOOLEAN), item_param),
2342 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
2345 [ITEM_RAW_OFFSET] = {
2347 .help = "absolute or relative offset for pattern",
2348 .next = NEXT(item_raw, NEXT_ENTRY(INTEGER), item_param),
2349 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, offset)),
2351 [ITEM_RAW_LIMIT] = {
2353 .help = "search area limit for start of pattern",
2354 .next = NEXT(item_raw, NEXT_ENTRY(UNSIGNED), item_param),
2355 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, limit)),
2357 [ITEM_RAW_PATTERN] = {
2359 .help = "byte string to look for",
2360 .next = NEXT(item_raw,
2362 NEXT_ENTRY(ITEM_PARAM_IS,
2365 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern),
2366 ARGS_ENTRY(struct rte_flow_item_raw, length),
2367 ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw),
2368 ITEM_RAW_PATTERN_SIZE)),
2372 .help = "match Ethernet header",
2373 .priv = PRIV_ITEM(ETH, sizeof(struct rte_flow_item_eth)),
2374 .next = NEXT(item_eth),
2379 .help = "destination MAC",
2380 .next = NEXT(item_eth, NEXT_ENTRY(MAC_ADDR), item_param),
2381 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, dst)),
2385 .help = "source MAC",
2386 .next = NEXT(item_eth, NEXT_ENTRY(MAC_ADDR), item_param),
2387 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, src)),
2391 .help = "EtherType",
2392 .next = NEXT(item_eth, NEXT_ENTRY(UNSIGNED), item_param),
2393 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, type)),
2395 [ITEM_ETH_HAS_VLAN] = {
2397 .help = "packet header contains VLAN",
2398 .next = NEXT(item_eth, NEXT_ENTRY(UNSIGNED), item_param),
2399 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_eth,
2404 .help = "match 802.1Q/ad VLAN tag",
2405 .priv = PRIV_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)),
2406 .next = NEXT(item_vlan),
2411 .help = "tag control information",
2412 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2413 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, tci)),
2417 .help = "priority code point",
2418 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2419 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2424 .help = "drop eligible indicator",
2425 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2426 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2431 .help = "VLAN identifier",
2432 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2433 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2436 [ITEM_VLAN_INNER_TYPE] = {
2437 .name = "inner_type",
2438 .help = "inner EtherType",
2439 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2440 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan,
2443 [ITEM_VLAN_HAS_MORE_VLAN] = {
2444 .name = "has_more_vlan",
2445 .help = "packet header contains another VLAN",
2446 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2447 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vlan,
2452 .help = "match IPv4 header",
2453 .priv = PRIV_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)),
2454 .next = NEXT(item_ipv4),
2459 .help = "type of service",
2460 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2461 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2462 hdr.type_of_service)),
2464 [ITEM_IPV4_FRAGMENT_OFFSET] = {
2465 .name = "fragment_offset",
2466 .help = "fragmentation flags and fragment offset",
2467 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2468 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2469 hdr.fragment_offset)),
2473 .help = "time to live",
2474 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2475 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2478 [ITEM_IPV4_PROTO] = {
2480 .help = "next protocol ID",
2481 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2482 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2483 hdr.next_proto_id)),
2487 .help = "source address",
2488 .next = NEXT(item_ipv4, NEXT_ENTRY(IPV4_ADDR), item_param),
2489 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2494 .help = "destination address",
2495 .next = NEXT(item_ipv4, NEXT_ENTRY(IPV4_ADDR), item_param),
2496 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2501 .help = "match IPv6 header",
2502 .priv = PRIV_ITEM(IPV6, sizeof(struct rte_flow_item_ipv6)),
2503 .next = NEXT(item_ipv6),
2508 .help = "traffic class",
2509 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2510 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2512 "\x0f\xf0\x00\x00")),
2514 [ITEM_IPV6_FLOW] = {
2516 .help = "flow label",
2517 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2518 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2520 "\x00\x0f\xff\xff")),
2522 [ITEM_IPV6_PROTO] = {
2524 .help = "protocol (next header)",
2525 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2526 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2531 .help = "hop limit",
2532 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2533 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2538 .help = "source address",
2539 .next = NEXT(item_ipv6, NEXT_ENTRY(IPV6_ADDR), item_param),
2540 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2545 .help = "destination address",
2546 .next = NEXT(item_ipv6, NEXT_ENTRY(IPV6_ADDR), item_param),
2547 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2550 [ITEM_IPV6_HAS_FRAG_EXT] = {
2551 .name = "has_frag_ext",
2552 .help = "fragment packet attribute",
2553 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2554 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_ipv6,
2559 .help = "match ICMP header",
2560 .priv = PRIV_ITEM(ICMP, sizeof(struct rte_flow_item_icmp)),
2561 .next = NEXT(item_icmp),
2564 [ITEM_ICMP_TYPE] = {
2566 .help = "ICMP packet type",
2567 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2568 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2571 [ITEM_ICMP_CODE] = {
2573 .help = "ICMP packet code",
2574 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2575 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2578 [ITEM_ICMP_IDENT] = {
2580 .help = "ICMP packet identifier",
2581 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2582 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2587 .help = "ICMP packet sequence number",
2588 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2589 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2594 .help = "match UDP header",
2595 .priv = PRIV_ITEM(UDP, sizeof(struct rte_flow_item_udp)),
2596 .next = NEXT(item_udp),
2601 .help = "UDP source port",
2602 .next = NEXT(item_udp, NEXT_ENTRY(UNSIGNED), item_param),
2603 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2608 .help = "UDP destination port",
2609 .next = NEXT(item_udp, NEXT_ENTRY(UNSIGNED), item_param),
2610 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2615 .help = "match TCP header",
2616 .priv = PRIV_ITEM(TCP, sizeof(struct rte_flow_item_tcp)),
2617 .next = NEXT(item_tcp),
2622 .help = "TCP source port",
2623 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2624 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2629 .help = "TCP destination port",
2630 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2631 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2634 [ITEM_TCP_FLAGS] = {
2636 .help = "TCP flags",
2637 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2638 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2643 .help = "match SCTP header",
2644 .priv = PRIV_ITEM(SCTP, sizeof(struct rte_flow_item_sctp)),
2645 .next = NEXT(item_sctp),
2650 .help = "SCTP source port",
2651 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2652 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2657 .help = "SCTP destination port",
2658 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2659 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2664 .help = "validation tag",
2665 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2666 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2669 [ITEM_SCTP_CKSUM] = {
2672 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2673 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2678 .help = "match VXLAN header",
2679 .priv = PRIV_ITEM(VXLAN, sizeof(struct rte_flow_item_vxlan)),
2680 .next = NEXT(item_vxlan),
2683 [ITEM_VXLAN_VNI] = {
2685 .help = "VXLAN identifier",
2686 .next = NEXT(item_vxlan, NEXT_ENTRY(UNSIGNED), item_param),
2687 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan, vni)),
2691 .help = "match E-Tag header",
2692 .priv = PRIV_ITEM(E_TAG, sizeof(struct rte_flow_item_e_tag)),
2693 .next = NEXT(item_e_tag),
2696 [ITEM_E_TAG_GRP_ECID_B] = {
2697 .name = "grp_ecid_b",
2698 .help = "GRP and E-CID base",
2699 .next = NEXT(item_e_tag, NEXT_ENTRY(UNSIGNED), item_param),
2700 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_e_tag,
2706 .help = "match NVGRE header",
2707 .priv = PRIV_ITEM(NVGRE, sizeof(struct rte_flow_item_nvgre)),
2708 .next = NEXT(item_nvgre),
2711 [ITEM_NVGRE_TNI] = {
2713 .help = "virtual subnet ID",
2714 .next = NEXT(item_nvgre, NEXT_ENTRY(UNSIGNED), item_param),
2715 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_nvgre, tni)),
2719 .help = "match MPLS header",
2720 .priv = PRIV_ITEM(MPLS, sizeof(struct rte_flow_item_mpls)),
2721 .next = NEXT(item_mpls),
2724 [ITEM_MPLS_LABEL] = {
2726 .help = "MPLS label",
2727 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2728 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2734 .help = "MPLS Traffic Class",
2735 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2736 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2742 .help = "MPLS Bottom-of-Stack",
2743 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2744 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2750 .help = "match GRE header",
2751 .priv = PRIV_ITEM(GRE, sizeof(struct rte_flow_item_gre)),
2752 .next = NEXT(item_gre),
2755 [ITEM_GRE_PROTO] = {
2757 .help = "GRE protocol type",
2758 .next = NEXT(item_gre, NEXT_ENTRY(UNSIGNED), item_param),
2759 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2762 [ITEM_GRE_C_RSVD0_VER] = {
2763 .name = "c_rsvd0_ver",
2765 "checksum (1b), undefined (1b), key bit (1b),"
2766 " sequence number (1b), reserved 0 (9b),"
2768 .next = NEXT(item_gre, NEXT_ENTRY(UNSIGNED), item_param),
2769 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2772 [ITEM_GRE_C_BIT] = {
2774 .help = "checksum bit (C)",
2775 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2776 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2778 "\x80\x00\x00\x00")),
2780 [ITEM_GRE_S_BIT] = {
2782 .help = "sequence number bit (S)",
2783 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2784 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2786 "\x10\x00\x00\x00")),
2788 [ITEM_GRE_K_BIT] = {
2790 .help = "key bit (K)",
2791 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2792 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2794 "\x20\x00\x00\x00")),
2798 .help = "fuzzy pattern match, expect faster than default",
2799 .priv = PRIV_ITEM(FUZZY,
2800 sizeof(struct rte_flow_item_fuzzy)),
2801 .next = NEXT(item_fuzzy),
2804 [ITEM_FUZZY_THRESH] = {
2806 .help = "match accuracy threshold",
2807 .next = NEXT(item_fuzzy, NEXT_ENTRY(UNSIGNED), item_param),
2808 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_fuzzy,
2813 .help = "match GTP header",
2814 .priv = PRIV_ITEM(GTP, sizeof(struct rte_flow_item_gtp)),
2815 .next = NEXT(item_gtp),
2818 [ITEM_GTP_FLAGS] = {
2819 .name = "v_pt_rsv_flags",
2820 .help = "GTP flags",
2821 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2822 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp,
2825 [ITEM_GTP_MSG_TYPE] = {
2827 .help = "GTP message type",
2828 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2829 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp, msg_type)),
2833 .help = "tunnel endpoint identifier",
2834 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2835 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp, teid)),
2839 .help = "match GTP header",
2840 .priv = PRIV_ITEM(GTPC, sizeof(struct rte_flow_item_gtp)),
2841 .next = NEXT(item_gtp),
2846 .help = "match GTP header",
2847 .priv = PRIV_ITEM(GTPU, sizeof(struct rte_flow_item_gtp)),
2848 .next = NEXT(item_gtp),
2853 .help = "match GENEVE header",
2854 .priv = PRIV_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)),
2855 .next = NEXT(item_geneve),
2858 [ITEM_GENEVE_VNI] = {
2860 .help = "virtual network identifier",
2861 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2862 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve, vni)),
2864 [ITEM_GENEVE_PROTO] = {
2866 .help = "GENEVE protocol type",
2867 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2868 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve,
2871 [ITEM_GENEVE_OPTLEN] = {
2873 .help = "GENEVE options length in dwords",
2874 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2875 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_geneve,
2876 ver_opt_len_o_c_rsvd0,
2879 [ITEM_VXLAN_GPE] = {
2880 .name = "vxlan-gpe",
2881 .help = "match VXLAN-GPE header",
2882 .priv = PRIV_ITEM(VXLAN_GPE,
2883 sizeof(struct rte_flow_item_vxlan_gpe)),
2884 .next = NEXT(item_vxlan_gpe),
2887 [ITEM_VXLAN_GPE_VNI] = {
2889 .help = "VXLAN-GPE identifier",
2890 .next = NEXT(item_vxlan_gpe, NEXT_ENTRY(UNSIGNED), item_param),
2891 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
2894 [ITEM_ARP_ETH_IPV4] = {
2895 .name = "arp_eth_ipv4",
2896 .help = "match ARP header for Ethernet/IPv4",
2897 .priv = PRIV_ITEM(ARP_ETH_IPV4,
2898 sizeof(struct rte_flow_item_arp_eth_ipv4)),
2899 .next = NEXT(item_arp_eth_ipv4),
2902 [ITEM_ARP_ETH_IPV4_SHA] = {
2904 .help = "sender hardware address",
2905 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(MAC_ADDR),
2907 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2910 [ITEM_ARP_ETH_IPV4_SPA] = {
2912 .help = "sender IPv4 address",
2913 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(IPV4_ADDR),
2915 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2918 [ITEM_ARP_ETH_IPV4_THA] = {
2920 .help = "target hardware address",
2921 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(MAC_ADDR),
2923 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2926 [ITEM_ARP_ETH_IPV4_TPA] = {
2928 .help = "target IPv4 address",
2929 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(IPV4_ADDR),
2931 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2936 .help = "match presence of any IPv6 extension header",
2937 .priv = PRIV_ITEM(IPV6_EXT,
2938 sizeof(struct rte_flow_item_ipv6_ext)),
2939 .next = NEXT(item_ipv6_ext),
2942 [ITEM_IPV6_EXT_NEXT_HDR] = {
2944 .help = "next header",
2945 .next = NEXT(item_ipv6_ext, NEXT_ENTRY(UNSIGNED), item_param),
2946 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_ext,
2949 [ITEM_IPV6_FRAG_EXT] = {
2950 .name = "ipv6_frag_ext",
2951 .help = "match presence of IPv6 fragment extension header",
2952 .priv = PRIV_ITEM(IPV6_FRAG_EXT,
2953 sizeof(struct rte_flow_item_ipv6_frag_ext)),
2954 .next = NEXT(item_ipv6_frag_ext),
2957 [ITEM_IPV6_FRAG_EXT_NEXT_HDR] = {
2959 .help = "next header",
2960 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(UNSIGNED),
2962 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ipv6_frag_ext,
2965 [ITEM_IPV6_FRAG_EXT_FRAG_DATA] = {
2966 .name = "frag_data",
2967 .help = "Fragment flags and offset",
2968 .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(UNSIGNED),
2970 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_frag_ext,
2975 .help = "match any ICMPv6 header",
2976 .priv = PRIV_ITEM(ICMP6, sizeof(struct rte_flow_item_icmp6)),
2977 .next = NEXT(item_icmp6),
2980 [ITEM_ICMP6_TYPE] = {
2982 .help = "ICMPv6 type",
2983 .next = NEXT(item_icmp6, NEXT_ENTRY(UNSIGNED), item_param),
2984 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
2987 [ITEM_ICMP6_CODE] = {
2989 .help = "ICMPv6 code",
2990 .next = NEXT(item_icmp6, NEXT_ENTRY(UNSIGNED), item_param),
2991 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
2994 [ITEM_ICMP6_ND_NS] = {
2995 .name = "icmp6_nd_ns",
2996 .help = "match ICMPv6 neighbor discovery solicitation",
2997 .priv = PRIV_ITEM(ICMP6_ND_NS,
2998 sizeof(struct rte_flow_item_icmp6_nd_ns)),
2999 .next = NEXT(item_icmp6_nd_ns),
3002 [ITEM_ICMP6_ND_NS_TARGET_ADDR] = {
3003 .name = "target_addr",
3004 .help = "target address",
3005 .next = NEXT(item_icmp6_nd_ns, NEXT_ENTRY(IPV6_ADDR),
3007 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_ns,
3010 [ITEM_ICMP6_ND_NA] = {
3011 .name = "icmp6_nd_na",
3012 .help = "match ICMPv6 neighbor discovery advertisement",
3013 .priv = PRIV_ITEM(ICMP6_ND_NA,
3014 sizeof(struct rte_flow_item_icmp6_nd_na)),
3015 .next = NEXT(item_icmp6_nd_na),
3018 [ITEM_ICMP6_ND_NA_TARGET_ADDR] = {
3019 .name = "target_addr",
3020 .help = "target address",
3021 .next = NEXT(item_icmp6_nd_na, NEXT_ENTRY(IPV6_ADDR),
3023 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_na,
3026 [ITEM_ICMP6_ND_OPT] = {
3027 .name = "icmp6_nd_opt",
3028 .help = "match presence of any ICMPv6 neighbor discovery"
3030 .priv = PRIV_ITEM(ICMP6_ND_OPT,
3031 sizeof(struct rte_flow_item_icmp6_nd_opt)),
3032 .next = NEXT(item_icmp6_nd_opt),
3035 [ITEM_ICMP6_ND_OPT_TYPE] = {
3037 .help = "ND option type",
3038 .next = NEXT(item_icmp6_nd_opt, NEXT_ENTRY(UNSIGNED),
3040 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_opt,
3043 [ITEM_ICMP6_ND_OPT_SLA_ETH] = {
3044 .name = "icmp6_nd_opt_sla_eth",
3045 .help = "match ICMPv6 neighbor discovery source Ethernet"
3046 " link-layer address option",
3048 (ICMP6_ND_OPT_SLA_ETH,
3049 sizeof(struct rte_flow_item_icmp6_nd_opt_sla_eth)),
3050 .next = NEXT(item_icmp6_nd_opt_sla_eth),
3053 [ITEM_ICMP6_ND_OPT_SLA_ETH_SLA] = {
3055 .help = "source Ethernet LLA",
3056 .next = NEXT(item_icmp6_nd_opt_sla_eth, NEXT_ENTRY(MAC_ADDR),
3058 .args = ARGS(ARGS_ENTRY_HTON
3059 (struct rte_flow_item_icmp6_nd_opt_sla_eth, sla)),
3061 [ITEM_ICMP6_ND_OPT_TLA_ETH] = {
3062 .name = "icmp6_nd_opt_tla_eth",
3063 .help = "match ICMPv6 neighbor discovery target Ethernet"
3064 " link-layer address option",
3066 (ICMP6_ND_OPT_TLA_ETH,
3067 sizeof(struct rte_flow_item_icmp6_nd_opt_tla_eth)),
3068 .next = NEXT(item_icmp6_nd_opt_tla_eth),
3071 [ITEM_ICMP6_ND_OPT_TLA_ETH_TLA] = {
3073 .help = "target Ethernet LLA",
3074 .next = NEXT(item_icmp6_nd_opt_tla_eth, NEXT_ENTRY(MAC_ADDR),
3076 .args = ARGS(ARGS_ENTRY_HTON
3077 (struct rte_flow_item_icmp6_nd_opt_tla_eth, tla)),
3081 .help = "match metadata header",
3082 .priv = PRIV_ITEM(META, sizeof(struct rte_flow_item_meta)),
3083 .next = NEXT(item_meta),
3086 [ITEM_META_DATA] = {
3088 .help = "metadata value",
3089 .next = NEXT(item_meta, NEXT_ENTRY(UNSIGNED), item_param),
3090 .args = ARGS(ARGS_ENTRY_MASK(struct rte_flow_item_meta,
3091 data, "\xff\xff\xff\xff")),
3095 .help = "match GRE key",
3096 .priv = PRIV_ITEM(GRE_KEY, sizeof(rte_be32_t)),
3097 .next = NEXT(item_gre_key),
3100 [ITEM_GRE_KEY_VALUE] = {
3102 .help = "key value",
3103 .next = NEXT(item_gre_key, NEXT_ENTRY(UNSIGNED), item_param),
3104 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3108 .help = "match GTP extension header with type 0x85",
3109 .priv = PRIV_ITEM(GTP_PSC,
3110 sizeof(struct rte_flow_item_gtp_psc)),
3111 .next = NEXT(item_gtp_psc),
3114 [ITEM_GTP_PSC_QFI] = {
3116 .help = "QoS flow identifier",
3117 .next = NEXT(item_gtp_psc, NEXT_ENTRY(UNSIGNED), item_param),
3118 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
3121 [ITEM_GTP_PSC_PDU_T] = {
3124 .next = NEXT(item_gtp_psc, NEXT_ENTRY(UNSIGNED), item_param),
3125 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
3130 .help = "match PPPoE session header",
3131 .priv = PRIV_ITEM(PPPOES, sizeof(struct rte_flow_item_pppoe)),
3132 .next = NEXT(item_pppoes),
3137 .help = "match PPPoE discovery header",
3138 .priv = PRIV_ITEM(PPPOED, sizeof(struct rte_flow_item_pppoe)),
3139 .next = NEXT(item_pppoed),
3142 [ITEM_PPPOE_SEID] = {
3144 .help = "session identifier",
3145 .next = NEXT(item_pppoes, NEXT_ENTRY(UNSIGNED), item_param),
3146 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pppoe,
3149 [ITEM_PPPOE_PROTO_ID] = {
3150 .name = "pppoe_proto_id",
3151 .help = "match PPPoE session protocol identifier",
3152 .priv = PRIV_ITEM(PPPOE_PROTO_ID,
3153 sizeof(struct rte_flow_item_pppoe_proto_id)),
3154 .next = NEXT(item_pppoe_proto_id, NEXT_ENTRY(UNSIGNED),
3156 .args = ARGS(ARGS_ENTRY_HTON
3157 (struct rte_flow_item_pppoe_proto_id, proto_id)),
3162 .help = "matches higig2 header",
3163 .priv = PRIV_ITEM(HIGIG2,
3164 sizeof(struct rte_flow_item_higig2_hdr)),
3165 .next = NEXT(item_higig2),
3168 [ITEM_HIGIG2_CLASSIFICATION] = {
3169 .name = "classification",
3170 .help = "matches classification of higig2 header",
3171 .next = NEXT(item_higig2, NEXT_ENTRY(UNSIGNED), item_param),
3172 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
3173 hdr.ppt1.classification)),
3175 [ITEM_HIGIG2_VID] = {
3177 .help = "matches vid of higig2 header",
3178 .next = NEXT(item_higig2, NEXT_ENTRY(UNSIGNED), item_param),
3179 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
3184 .help = "match tag value",
3185 .priv = PRIV_ITEM(TAG, sizeof(struct rte_flow_item_tag)),
3186 .next = NEXT(item_tag),
3191 .help = "tag value to match",
3192 .next = NEXT(item_tag, NEXT_ENTRY(UNSIGNED), item_param),
3193 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, data)),
3195 [ITEM_TAG_INDEX] = {
3197 .help = "index of tag array to match",
3198 .next = NEXT(item_tag, NEXT_ENTRY(UNSIGNED),
3199 NEXT_ENTRY(ITEM_PARAM_IS)),
3200 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, index)),
3202 [ITEM_L2TPV3OIP] = {
3203 .name = "l2tpv3oip",
3204 .help = "match L2TPv3 over IP header",
3205 .priv = PRIV_ITEM(L2TPV3OIP,
3206 sizeof(struct rte_flow_item_l2tpv3oip)),
3207 .next = NEXT(item_l2tpv3oip),
3210 [ITEM_L2TPV3OIP_SESSION_ID] = {
3211 .name = "session_id",
3212 .help = "session identifier",
3213 .next = NEXT(item_l2tpv3oip, NEXT_ENTRY(UNSIGNED), item_param),
3214 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv3oip,
3219 .help = "match ESP header",
3220 .priv = PRIV_ITEM(ESP, sizeof(struct rte_flow_item_esp)),
3221 .next = NEXT(item_esp),
3226 .help = "security policy index",
3227 .next = NEXT(item_esp, NEXT_ENTRY(UNSIGNED), item_param),
3228 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_esp,
3233 .help = "match AH header",
3234 .priv = PRIV_ITEM(AH, sizeof(struct rte_flow_item_ah)),
3235 .next = NEXT(item_ah),
3240 .help = "security parameters index",
3241 .next = NEXT(item_ah, NEXT_ENTRY(UNSIGNED), item_param),
3242 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ah, spi)),
3246 .help = "match pfcp header",
3247 .priv = PRIV_ITEM(PFCP, sizeof(struct rte_flow_item_pfcp)),
3248 .next = NEXT(item_pfcp),
3251 [ITEM_PFCP_S_FIELD] = {
3254 .next = NEXT(item_pfcp, NEXT_ENTRY(UNSIGNED), item_param),
3255 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp,
3258 [ITEM_PFCP_SEID] = {
3260 .help = "session endpoint identifier",
3261 .next = NEXT(item_pfcp, NEXT_ENTRY(UNSIGNED), item_param),
3262 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp, seid)),
3266 .help = "match eCPRI header",
3267 .priv = PRIV_ITEM(ECPRI, sizeof(struct rte_flow_item_ecpri)),
3268 .next = NEXT(item_ecpri),
3271 [ITEM_ECPRI_COMMON] = {
3273 .help = "eCPRI common header",
3274 .next = NEXT(item_ecpri_common),
3276 [ITEM_ECPRI_COMMON_TYPE] = {
3278 .help = "type of common header",
3279 .next = NEXT(item_ecpri_common_type),
3280 .args = ARGS(ARG_ENTRY_HTON(struct rte_flow_item_ecpri)),
3282 [ITEM_ECPRI_COMMON_TYPE_IQ_DATA] = {
3284 .help = "Type #0: IQ Data",
3285 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
3287 .call = parse_vc_item_ecpri_type,
3289 [ITEM_ECPRI_MSG_IQ_DATA_PCID] = {
3291 .help = "Physical Channel ID",
3292 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
3293 ITEM_ECPRI_COMMON, ITEM_NEXT),
3294 NEXT_ENTRY(UNSIGNED), item_param),
3295 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3298 [ITEM_ECPRI_COMMON_TYPE_RTC_CTRL] = {
3300 .help = "Type #2: Real-Time Control Data",
3301 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
3303 .call = parse_vc_item_ecpri_type,
3305 [ITEM_ECPRI_MSG_RTC_CTRL_RTCID] = {
3307 .help = "Real-Time Control Data ID",
3308 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
3309 ITEM_ECPRI_COMMON, ITEM_NEXT),
3310 NEXT_ENTRY(UNSIGNED), item_param),
3311 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3314 [ITEM_ECPRI_COMMON_TYPE_DLY_MSR] = {
3315 .name = "delay_measure",
3316 .help = "Type #5: One-Way Delay Measurement",
3317 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
3319 .call = parse_vc_item_ecpri_type,
3321 [ITEM_ECPRI_MSG_DLY_MSR_MSRID] = {
3323 .help = "Measurement ID",
3324 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
3325 ITEM_ECPRI_COMMON, ITEM_NEXT),
3326 NEXT_ENTRY(UNSIGNED), item_param),
3327 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
3330 [ITEM_GENEVE_OPT] = {
3331 .name = "geneve-opt",
3332 .help = "GENEVE header option",
3333 .priv = PRIV_ITEM(GENEVE_OPT,
3334 sizeof(struct rte_flow_item_geneve_opt) +
3335 ITEM_GENEVE_OPT_DATA_SIZE),
3336 .next = NEXT(item_geneve_opt),
3339 [ITEM_GENEVE_OPT_CLASS] = {
3341 .help = "GENEVE option class",
3342 .next = NEXT(item_geneve_opt, NEXT_ENTRY(UNSIGNED), item_param),
3343 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve_opt,
3346 [ITEM_GENEVE_OPT_TYPE] = {
3348 .help = "GENEVE option type",
3349 .next = NEXT(item_geneve_opt, NEXT_ENTRY(UNSIGNED), item_param),
3350 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt,
3353 [ITEM_GENEVE_OPT_LENGTH] = {
3355 .help = "GENEVE option data length (in 32b words)",
3356 .next = NEXT(item_geneve_opt, NEXT_ENTRY(UNSIGNED), item_param),
3357 .args = ARGS(ARGS_ENTRY_BOUNDED(
3358 struct rte_flow_item_geneve_opt, option_len,
3361 [ITEM_GENEVE_OPT_DATA] = {
3363 .help = "GENEVE option data pattern",
3364 .next = NEXT(item_geneve_opt, NEXT_ENTRY(HEX), item_param),
3365 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt, data),
3366 ARGS_ENTRY_ARB(0, 0),
3368 (sizeof(struct rte_flow_item_geneve_opt),
3369 ITEM_GENEVE_OPT_DATA_SIZE)),
3371 /* Validate/create actions. */
3374 .help = "submit a list of associated actions",
3375 .next = NEXT(next_action),
3380 .help = "specify next action",
3381 .next = NEXT(next_action),
3385 .help = "end list of actions",
3386 .priv = PRIV_ACTION(END, 0),
3391 .help = "no-op action",
3392 .priv = PRIV_ACTION(VOID, 0),
3393 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3396 [ACTION_PASSTHRU] = {
3398 .help = "let subsequent rule process matched packets",
3399 .priv = PRIV_ACTION(PASSTHRU, 0),
3400 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3405 .help = "redirect traffic to a given group",
3406 .priv = PRIV_ACTION(JUMP, sizeof(struct rte_flow_action_jump)),
3407 .next = NEXT(action_jump),
3410 [ACTION_JUMP_GROUP] = {
3412 .help = "group to redirect traffic to",
3413 .next = NEXT(action_jump, NEXT_ENTRY(UNSIGNED)),
3414 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump, group)),
3415 .call = parse_vc_conf,
3419 .help = "attach 32 bit value to packets",
3420 .priv = PRIV_ACTION(MARK, sizeof(struct rte_flow_action_mark)),
3421 .next = NEXT(action_mark),
3424 [ACTION_MARK_ID] = {
3426 .help = "32 bit value to return with packets",
3427 .next = NEXT(action_mark, NEXT_ENTRY(UNSIGNED)),
3428 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_mark, id)),
3429 .call = parse_vc_conf,
3433 .help = "flag packets",
3434 .priv = PRIV_ACTION(FLAG, 0),
3435 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3440 .help = "assign packets to a given queue index",
3441 .priv = PRIV_ACTION(QUEUE,
3442 sizeof(struct rte_flow_action_queue)),
3443 .next = NEXT(action_queue),
3446 [ACTION_QUEUE_INDEX] = {
3448 .help = "queue index to use",
3449 .next = NEXT(action_queue, NEXT_ENTRY(UNSIGNED)),
3450 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_queue, index)),
3451 .call = parse_vc_conf,
3455 .help = "drop packets (note: passthru has priority)",
3456 .priv = PRIV_ACTION(DROP, 0),
3457 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3462 .help = "enable counters for this rule",
3463 .priv = PRIV_ACTION(COUNT,
3464 sizeof(struct rte_flow_action_count)),
3465 .next = NEXT(action_count),
3468 [ACTION_COUNT_ID] = {
3469 .name = "identifier",
3470 .help = "counter identifier to use",
3471 .next = NEXT(action_count, NEXT_ENTRY(UNSIGNED)),
3472 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_count, id)),
3473 .call = parse_vc_conf,
3475 [ACTION_COUNT_SHARED] = {
3477 .help = "shared counter",
3478 .next = NEXT(action_count, NEXT_ENTRY(BOOLEAN)),
3479 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_count,
3481 .call = parse_vc_conf,
3485 .help = "spread packets among several queues",
3486 .priv = PRIV_ACTION(RSS, sizeof(struct action_rss_data)),
3487 .next = NEXT(action_rss),
3488 .call = parse_vc_action_rss,
3490 [ACTION_RSS_FUNC] = {
3492 .help = "RSS hash function to apply",
3493 .next = NEXT(action_rss,
3494 NEXT_ENTRY(ACTION_RSS_FUNC_DEFAULT,
3495 ACTION_RSS_FUNC_TOEPLITZ,
3496 ACTION_RSS_FUNC_SIMPLE_XOR,
3497 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ)),
3499 [ACTION_RSS_FUNC_DEFAULT] = {
3501 .help = "default hash function",
3502 .call = parse_vc_action_rss_func,
3504 [ACTION_RSS_FUNC_TOEPLITZ] = {
3506 .help = "Toeplitz hash function",
3507 .call = parse_vc_action_rss_func,
3509 [ACTION_RSS_FUNC_SIMPLE_XOR] = {
3510 .name = "simple_xor",
3511 .help = "simple XOR hash function",
3512 .call = parse_vc_action_rss_func,
3514 [ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ] = {
3515 .name = "symmetric_toeplitz",
3516 .help = "Symmetric Toeplitz hash function",
3517 .call = parse_vc_action_rss_func,
3519 [ACTION_RSS_LEVEL] = {
3521 .help = "encapsulation level for \"types\"",
3522 .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
3523 .args = ARGS(ARGS_ENTRY_ARB
3524 (offsetof(struct action_rss_data, conf) +
3525 offsetof(struct rte_flow_action_rss, level),
3526 sizeof(((struct rte_flow_action_rss *)0)->
3529 [ACTION_RSS_TYPES] = {
3531 .help = "specific RSS hash types",
3532 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)),
3534 [ACTION_RSS_TYPE] = {
3536 .help = "RSS hash type",
3537 .call = parse_vc_action_rss_type,
3538 .comp = comp_vc_action_rss_type,
3540 [ACTION_RSS_KEY] = {
3542 .help = "RSS hash key",
3543 .next = NEXT(action_rss, NEXT_ENTRY(HEX)),
3544 .args = ARGS(ARGS_ENTRY_ARB
3545 (offsetof(struct action_rss_data, conf) +
3546 offsetof(struct rte_flow_action_rss, key),
3547 sizeof(((struct rte_flow_action_rss *)0)->key)),
3549 (offsetof(struct action_rss_data, conf) +
3550 offsetof(struct rte_flow_action_rss, key_len),
3551 sizeof(((struct rte_flow_action_rss *)0)->
3553 ARGS_ENTRY(struct action_rss_data, key)),
3555 [ACTION_RSS_KEY_LEN] = {
3557 .help = "RSS hash key length in bytes",
3558 .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
3559 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
3560 (offsetof(struct action_rss_data, conf) +
3561 offsetof(struct rte_flow_action_rss, key_len),
3562 sizeof(((struct rte_flow_action_rss *)0)->
3565 RSS_HASH_KEY_LENGTH)),
3567 [ACTION_RSS_QUEUES] = {
3569 .help = "queue indices to use",
3570 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_QUEUE)),
3571 .call = parse_vc_conf,
3573 [ACTION_RSS_QUEUE] = {
3575 .help = "queue index",
3576 .call = parse_vc_action_rss_queue,
3577 .comp = comp_vc_action_rss_queue,
3581 .help = "direct traffic to physical function",
3582 .priv = PRIV_ACTION(PF, 0),
3583 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3588 .help = "direct traffic to a virtual function ID",
3589 .priv = PRIV_ACTION(VF, sizeof(struct rte_flow_action_vf)),
3590 .next = NEXT(action_vf),
3593 [ACTION_VF_ORIGINAL] = {
3595 .help = "use original VF ID if possible",
3596 .next = NEXT(action_vf, NEXT_ENTRY(BOOLEAN)),
3597 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_vf,
3599 .call = parse_vc_conf,
3604 .next = NEXT(action_vf, NEXT_ENTRY(UNSIGNED)),
3605 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)),
3606 .call = parse_vc_conf,
3608 [ACTION_PHY_PORT] = {
3610 .help = "direct packets to physical port index",
3611 .priv = PRIV_ACTION(PHY_PORT,
3612 sizeof(struct rte_flow_action_phy_port)),
3613 .next = NEXT(action_phy_port),
3616 [ACTION_PHY_PORT_ORIGINAL] = {
3618 .help = "use original port index if possible",
3619 .next = NEXT(action_phy_port, NEXT_ENTRY(BOOLEAN)),
3620 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_phy_port,
3622 .call = parse_vc_conf,
3624 [ACTION_PHY_PORT_INDEX] = {
3626 .help = "physical port index",
3627 .next = NEXT(action_phy_port, NEXT_ENTRY(UNSIGNED)),
3628 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_phy_port,
3630 .call = parse_vc_conf,
3632 [ACTION_PORT_ID] = {
3634 .help = "direct matching traffic to a given DPDK port ID",
3635 .priv = PRIV_ACTION(PORT_ID,
3636 sizeof(struct rte_flow_action_port_id)),
3637 .next = NEXT(action_port_id),
3640 [ACTION_PORT_ID_ORIGINAL] = {
3642 .help = "use original DPDK port ID if possible",
3643 .next = NEXT(action_port_id, NEXT_ENTRY(BOOLEAN)),
3644 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_port_id,
3646 .call = parse_vc_conf,
3648 [ACTION_PORT_ID_ID] = {
3650 .help = "DPDK port ID",
3651 .next = NEXT(action_port_id, NEXT_ENTRY(UNSIGNED)),
3652 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_port_id, id)),
3653 .call = parse_vc_conf,
3657 .help = "meter the directed packets at given id",
3658 .priv = PRIV_ACTION(METER,
3659 sizeof(struct rte_flow_action_meter)),
3660 .next = NEXT(action_meter),
3663 [ACTION_METER_ID] = {
3665 .help = "meter id to use",
3666 .next = NEXT(action_meter, NEXT_ENTRY(UNSIGNED)),
3667 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter, mtr_id)),
3668 .call = parse_vc_conf,
3670 [ACTION_OF_SET_MPLS_TTL] = {
3671 .name = "of_set_mpls_ttl",
3672 .help = "OpenFlow's OFPAT_SET_MPLS_TTL",
3675 sizeof(struct rte_flow_action_of_set_mpls_ttl)),
3676 .next = NEXT(action_of_set_mpls_ttl),
3679 [ACTION_OF_SET_MPLS_TTL_MPLS_TTL] = {
3682 .next = NEXT(action_of_set_mpls_ttl, NEXT_ENTRY(UNSIGNED)),
3683 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_mpls_ttl,
3685 .call = parse_vc_conf,
3687 [ACTION_OF_DEC_MPLS_TTL] = {
3688 .name = "of_dec_mpls_ttl",
3689 .help = "OpenFlow's OFPAT_DEC_MPLS_TTL",
3690 .priv = PRIV_ACTION(OF_DEC_MPLS_TTL, 0),
3691 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3694 [ACTION_OF_SET_NW_TTL] = {
3695 .name = "of_set_nw_ttl",
3696 .help = "OpenFlow's OFPAT_SET_NW_TTL",
3699 sizeof(struct rte_flow_action_of_set_nw_ttl)),
3700 .next = NEXT(action_of_set_nw_ttl),
3703 [ACTION_OF_SET_NW_TTL_NW_TTL] = {
3706 .next = NEXT(action_of_set_nw_ttl, NEXT_ENTRY(UNSIGNED)),
3707 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_nw_ttl,
3709 .call = parse_vc_conf,
3711 [ACTION_OF_DEC_NW_TTL] = {
3712 .name = "of_dec_nw_ttl",
3713 .help = "OpenFlow's OFPAT_DEC_NW_TTL",
3714 .priv = PRIV_ACTION(OF_DEC_NW_TTL, 0),
3715 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3718 [ACTION_OF_COPY_TTL_OUT] = {
3719 .name = "of_copy_ttl_out",
3720 .help = "OpenFlow's OFPAT_COPY_TTL_OUT",
3721 .priv = PRIV_ACTION(OF_COPY_TTL_OUT, 0),
3722 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3725 [ACTION_OF_COPY_TTL_IN] = {
3726 .name = "of_copy_ttl_in",
3727 .help = "OpenFlow's OFPAT_COPY_TTL_IN",
3728 .priv = PRIV_ACTION(OF_COPY_TTL_IN, 0),
3729 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3732 [ACTION_OF_POP_VLAN] = {
3733 .name = "of_pop_vlan",
3734 .help = "OpenFlow's OFPAT_POP_VLAN",
3735 .priv = PRIV_ACTION(OF_POP_VLAN, 0),
3736 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3739 [ACTION_OF_PUSH_VLAN] = {
3740 .name = "of_push_vlan",
3741 .help = "OpenFlow's OFPAT_PUSH_VLAN",
3744 sizeof(struct rte_flow_action_of_push_vlan)),
3745 .next = NEXT(action_of_push_vlan),
3748 [ACTION_OF_PUSH_VLAN_ETHERTYPE] = {
3749 .name = "ethertype",
3750 .help = "EtherType",
3751 .next = NEXT(action_of_push_vlan, NEXT_ENTRY(UNSIGNED)),
3752 .args = ARGS(ARGS_ENTRY_HTON
3753 (struct rte_flow_action_of_push_vlan,
3755 .call = parse_vc_conf,
3757 [ACTION_OF_SET_VLAN_VID] = {
3758 .name = "of_set_vlan_vid",
3759 .help = "OpenFlow's OFPAT_SET_VLAN_VID",
3762 sizeof(struct rte_flow_action_of_set_vlan_vid)),
3763 .next = NEXT(action_of_set_vlan_vid),
3766 [ACTION_OF_SET_VLAN_VID_VLAN_VID] = {
3769 .next = NEXT(action_of_set_vlan_vid, NEXT_ENTRY(UNSIGNED)),
3770 .args = ARGS(ARGS_ENTRY_HTON
3771 (struct rte_flow_action_of_set_vlan_vid,
3773 .call = parse_vc_conf,
3775 [ACTION_OF_SET_VLAN_PCP] = {
3776 .name = "of_set_vlan_pcp",
3777 .help = "OpenFlow's OFPAT_SET_VLAN_PCP",
3780 sizeof(struct rte_flow_action_of_set_vlan_pcp)),
3781 .next = NEXT(action_of_set_vlan_pcp),
3784 [ACTION_OF_SET_VLAN_PCP_VLAN_PCP] = {
3786 .help = "VLAN priority",
3787 .next = NEXT(action_of_set_vlan_pcp, NEXT_ENTRY(UNSIGNED)),
3788 .args = ARGS(ARGS_ENTRY_HTON
3789 (struct rte_flow_action_of_set_vlan_pcp,
3791 .call = parse_vc_conf,
3793 [ACTION_OF_POP_MPLS] = {
3794 .name = "of_pop_mpls",
3795 .help = "OpenFlow's OFPAT_POP_MPLS",
3796 .priv = PRIV_ACTION(OF_POP_MPLS,
3797 sizeof(struct rte_flow_action_of_pop_mpls)),
3798 .next = NEXT(action_of_pop_mpls),
3801 [ACTION_OF_POP_MPLS_ETHERTYPE] = {
3802 .name = "ethertype",
3803 .help = "EtherType",
3804 .next = NEXT(action_of_pop_mpls, NEXT_ENTRY(UNSIGNED)),
3805 .args = ARGS(ARGS_ENTRY_HTON
3806 (struct rte_flow_action_of_pop_mpls,
3808 .call = parse_vc_conf,
3810 [ACTION_OF_PUSH_MPLS] = {
3811 .name = "of_push_mpls",
3812 .help = "OpenFlow's OFPAT_PUSH_MPLS",
3815 sizeof(struct rte_flow_action_of_push_mpls)),
3816 .next = NEXT(action_of_push_mpls),
3819 [ACTION_OF_PUSH_MPLS_ETHERTYPE] = {
3820 .name = "ethertype",
3821 .help = "EtherType",
3822 .next = NEXT(action_of_push_mpls, NEXT_ENTRY(UNSIGNED)),
3823 .args = ARGS(ARGS_ENTRY_HTON
3824 (struct rte_flow_action_of_push_mpls,
3826 .call = parse_vc_conf,
3828 [ACTION_VXLAN_ENCAP] = {
3829 .name = "vxlan_encap",
3830 .help = "VXLAN encapsulation, uses configuration set by \"set"
3832 .priv = PRIV_ACTION(VXLAN_ENCAP,
3833 sizeof(struct action_vxlan_encap_data)),
3834 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3835 .call = parse_vc_action_vxlan_encap,
3837 [ACTION_VXLAN_DECAP] = {
3838 .name = "vxlan_decap",
3839 .help = "Performs a decapsulation action by stripping all"
3840 " headers of the VXLAN tunnel network overlay from the"
3842 .priv = PRIV_ACTION(VXLAN_DECAP, 0),
3843 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3846 [ACTION_NVGRE_ENCAP] = {
3847 .name = "nvgre_encap",
3848 .help = "NVGRE encapsulation, uses configuration set by \"set"
3850 .priv = PRIV_ACTION(NVGRE_ENCAP,
3851 sizeof(struct action_nvgre_encap_data)),
3852 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3853 .call = parse_vc_action_nvgre_encap,
3855 [ACTION_NVGRE_DECAP] = {
3856 .name = "nvgre_decap",
3857 .help = "Performs a decapsulation action by stripping all"
3858 " headers of the NVGRE tunnel network overlay from the"
3860 .priv = PRIV_ACTION(NVGRE_DECAP, 0),
3861 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3864 [ACTION_L2_ENCAP] = {
3866 .help = "l2 encap, uses configuration set by"
3867 " \"set l2_encap\"",
3868 .priv = PRIV_ACTION(RAW_ENCAP,
3869 sizeof(struct action_raw_encap_data)),
3870 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3871 .call = parse_vc_action_l2_encap,
3873 [ACTION_L2_DECAP] = {
3875 .help = "l2 decap, uses configuration set by"
3876 " \"set l2_decap\"",
3877 .priv = PRIV_ACTION(RAW_DECAP,
3878 sizeof(struct action_raw_decap_data)),
3879 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3880 .call = parse_vc_action_l2_decap,
3882 [ACTION_MPLSOGRE_ENCAP] = {
3883 .name = "mplsogre_encap",
3884 .help = "mplsogre encapsulation, uses configuration set by"
3885 " \"set mplsogre_encap\"",
3886 .priv = PRIV_ACTION(RAW_ENCAP,
3887 sizeof(struct action_raw_encap_data)),
3888 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3889 .call = parse_vc_action_mplsogre_encap,
3891 [ACTION_MPLSOGRE_DECAP] = {
3892 .name = "mplsogre_decap",
3893 .help = "mplsogre decapsulation, uses configuration set by"
3894 " \"set mplsogre_decap\"",
3895 .priv = PRIV_ACTION(RAW_DECAP,
3896 sizeof(struct action_raw_decap_data)),
3897 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3898 .call = parse_vc_action_mplsogre_decap,
3900 [ACTION_MPLSOUDP_ENCAP] = {
3901 .name = "mplsoudp_encap",
3902 .help = "mplsoudp encapsulation, uses configuration set by"
3903 " \"set mplsoudp_encap\"",
3904 .priv = PRIV_ACTION(RAW_ENCAP,
3905 sizeof(struct action_raw_encap_data)),
3906 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3907 .call = parse_vc_action_mplsoudp_encap,
3909 [ACTION_MPLSOUDP_DECAP] = {
3910 .name = "mplsoudp_decap",
3911 .help = "mplsoudp decapsulation, uses configuration set by"
3912 " \"set mplsoudp_decap\"",
3913 .priv = PRIV_ACTION(RAW_DECAP,
3914 sizeof(struct action_raw_decap_data)),
3915 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3916 .call = parse_vc_action_mplsoudp_decap,
3918 [ACTION_SET_IPV4_SRC] = {
3919 .name = "set_ipv4_src",
3920 .help = "Set a new IPv4 source address in the outermost"
3922 .priv = PRIV_ACTION(SET_IPV4_SRC,
3923 sizeof(struct rte_flow_action_set_ipv4)),
3924 .next = NEXT(action_set_ipv4_src),
3927 [ACTION_SET_IPV4_SRC_IPV4_SRC] = {
3928 .name = "ipv4_addr",
3929 .help = "new IPv4 source address to set",
3930 .next = NEXT(action_set_ipv4_src, NEXT_ENTRY(IPV4_ADDR)),
3931 .args = ARGS(ARGS_ENTRY_HTON
3932 (struct rte_flow_action_set_ipv4, ipv4_addr)),
3933 .call = parse_vc_conf,
3935 [ACTION_SET_IPV4_DST] = {
3936 .name = "set_ipv4_dst",
3937 .help = "Set a new IPv4 destination address in the outermost"
3939 .priv = PRIV_ACTION(SET_IPV4_DST,
3940 sizeof(struct rte_flow_action_set_ipv4)),
3941 .next = NEXT(action_set_ipv4_dst),
3944 [ACTION_SET_IPV4_DST_IPV4_DST] = {
3945 .name = "ipv4_addr",
3946 .help = "new IPv4 destination address to set",
3947 .next = NEXT(action_set_ipv4_dst, NEXT_ENTRY(IPV4_ADDR)),
3948 .args = ARGS(ARGS_ENTRY_HTON
3949 (struct rte_flow_action_set_ipv4, ipv4_addr)),
3950 .call = parse_vc_conf,
3952 [ACTION_SET_IPV6_SRC] = {
3953 .name = "set_ipv6_src",
3954 .help = "Set a new IPv6 source address in the outermost"
3956 .priv = PRIV_ACTION(SET_IPV6_SRC,
3957 sizeof(struct rte_flow_action_set_ipv6)),
3958 .next = NEXT(action_set_ipv6_src),
3961 [ACTION_SET_IPV6_SRC_IPV6_SRC] = {
3962 .name = "ipv6_addr",
3963 .help = "new IPv6 source address to set",
3964 .next = NEXT(action_set_ipv6_src, NEXT_ENTRY(IPV6_ADDR)),
3965 .args = ARGS(ARGS_ENTRY_HTON
3966 (struct rte_flow_action_set_ipv6, ipv6_addr)),
3967 .call = parse_vc_conf,
3969 [ACTION_SET_IPV6_DST] = {
3970 .name = "set_ipv6_dst",
3971 .help = "Set a new IPv6 destination address in the outermost"
3973 .priv = PRIV_ACTION(SET_IPV6_DST,
3974 sizeof(struct rte_flow_action_set_ipv6)),
3975 .next = NEXT(action_set_ipv6_dst),
3978 [ACTION_SET_IPV6_DST_IPV6_DST] = {
3979 .name = "ipv6_addr",
3980 .help = "new IPv6 destination address to set",
3981 .next = NEXT(action_set_ipv6_dst, NEXT_ENTRY(IPV6_ADDR)),
3982 .args = ARGS(ARGS_ENTRY_HTON
3983 (struct rte_flow_action_set_ipv6, ipv6_addr)),
3984 .call = parse_vc_conf,
3986 [ACTION_SET_TP_SRC] = {
3987 .name = "set_tp_src",
3988 .help = "set a new source port number in the outermost"
3990 .priv = PRIV_ACTION(SET_TP_SRC,
3991 sizeof(struct rte_flow_action_set_tp)),
3992 .next = NEXT(action_set_tp_src),
3995 [ACTION_SET_TP_SRC_TP_SRC] = {
3997 .help = "new source port number to set",
3998 .next = NEXT(action_set_tp_src, NEXT_ENTRY(UNSIGNED)),
3999 .args = ARGS(ARGS_ENTRY_HTON
4000 (struct rte_flow_action_set_tp, port)),
4001 .call = parse_vc_conf,
4003 [ACTION_SET_TP_DST] = {
4004 .name = "set_tp_dst",
4005 .help = "set a new destination port number in the outermost"
4007 .priv = PRIV_ACTION(SET_TP_DST,
4008 sizeof(struct rte_flow_action_set_tp)),
4009 .next = NEXT(action_set_tp_dst),
4012 [ACTION_SET_TP_DST_TP_DST] = {
4014 .help = "new destination port number to set",
4015 .next = NEXT(action_set_tp_dst, NEXT_ENTRY(UNSIGNED)),
4016 .args = ARGS(ARGS_ENTRY_HTON
4017 (struct rte_flow_action_set_tp, port)),
4018 .call = parse_vc_conf,
4020 [ACTION_MAC_SWAP] = {
4022 .help = "Swap the source and destination MAC addresses"
4023 " in the outermost Ethernet header",
4024 .priv = PRIV_ACTION(MAC_SWAP, 0),
4025 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4028 [ACTION_DEC_TTL] = {
4030 .help = "decrease network TTL if available",
4031 .priv = PRIV_ACTION(DEC_TTL, 0),
4032 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4035 [ACTION_SET_TTL] = {
4037 .help = "set ttl value",
4038 .priv = PRIV_ACTION(SET_TTL,
4039 sizeof(struct rte_flow_action_set_ttl)),
4040 .next = NEXT(action_set_ttl),
4043 [ACTION_SET_TTL_TTL] = {
4044 .name = "ttl_value",
4045 .help = "new ttl value to set",
4046 .next = NEXT(action_set_ttl, NEXT_ENTRY(UNSIGNED)),
4047 .args = ARGS(ARGS_ENTRY_HTON
4048 (struct rte_flow_action_set_ttl, ttl_value)),
4049 .call = parse_vc_conf,
4051 [ACTION_SET_MAC_SRC] = {
4052 .name = "set_mac_src",
4053 .help = "set source mac address",
4054 .priv = PRIV_ACTION(SET_MAC_SRC,
4055 sizeof(struct rte_flow_action_set_mac)),
4056 .next = NEXT(action_set_mac_src),
4059 [ACTION_SET_MAC_SRC_MAC_SRC] = {
4061 .help = "new source mac address",
4062 .next = NEXT(action_set_mac_src, NEXT_ENTRY(MAC_ADDR)),
4063 .args = ARGS(ARGS_ENTRY_HTON
4064 (struct rte_flow_action_set_mac, mac_addr)),
4065 .call = parse_vc_conf,
4067 [ACTION_SET_MAC_DST] = {
4068 .name = "set_mac_dst",
4069 .help = "set destination mac address",
4070 .priv = PRIV_ACTION(SET_MAC_DST,
4071 sizeof(struct rte_flow_action_set_mac)),
4072 .next = NEXT(action_set_mac_dst),
4075 [ACTION_SET_MAC_DST_MAC_DST] = {
4077 .help = "new destination mac address to set",
4078 .next = NEXT(action_set_mac_dst, NEXT_ENTRY(MAC_ADDR)),
4079 .args = ARGS(ARGS_ENTRY_HTON
4080 (struct rte_flow_action_set_mac, mac_addr)),
4081 .call = parse_vc_conf,
4083 [ACTION_INC_TCP_SEQ] = {
4084 .name = "inc_tcp_seq",
4085 .help = "increase TCP sequence number",
4086 .priv = PRIV_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
4087 .next = NEXT(action_inc_tcp_seq),
4090 [ACTION_INC_TCP_SEQ_VALUE] = {
4092 .help = "the value to increase TCP sequence number by",
4093 .next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(UNSIGNED)),
4094 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4095 .call = parse_vc_conf,
4097 [ACTION_DEC_TCP_SEQ] = {
4098 .name = "dec_tcp_seq",
4099 .help = "decrease TCP sequence number",
4100 .priv = PRIV_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
4101 .next = NEXT(action_dec_tcp_seq),
4104 [ACTION_DEC_TCP_SEQ_VALUE] = {
4106 .help = "the value to decrease TCP sequence number by",
4107 .next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(UNSIGNED)),
4108 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4109 .call = parse_vc_conf,
4111 [ACTION_INC_TCP_ACK] = {
4112 .name = "inc_tcp_ack",
4113 .help = "increase TCP acknowledgment number",
4114 .priv = PRIV_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
4115 .next = NEXT(action_inc_tcp_ack),
4118 [ACTION_INC_TCP_ACK_VALUE] = {
4120 .help = "the value to increase TCP acknowledgment number by",
4121 .next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(UNSIGNED)),
4122 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4123 .call = parse_vc_conf,
4125 [ACTION_DEC_TCP_ACK] = {
4126 .name = "dec_tcp_ack",
4127 .help = "decrease TCP acknowledgment number",
4128 .priv = PRIV_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
4129 .next = NEXT(action_dec_tcp_ack),
4132 [ACTION_DEC_TCP_ACK_VALUE] = {
4134 .help = "the value to decrease TCP acknowledgment number by",
4135 .next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(UNSIGNED)),
4136 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
4137 .call = parse_vc_conf,
4139 [ACTION_RAW_ENCAP] = {
4140 .name = "raw_encap",
4141 .help = "encapsulation data, defined by set raw_encap",
4142 .priv = PRIV_ACTION(RAW_ENCAP,
4143 sizeof(struct action_raw_encap_data)),
4144 .next = NEXT(action_raw_encap),
4145 .call = parse_vc_action_raw_encap,
4147 [ACTION_RAW_ENCAP_INDEX] = {
4149 .help = "the index of raw_encap_confs",
4150 .next = NEXT(NEXT_ENTRY(ACTION_RAW_ENCAP_INDEX_VALUE)),
4152 [ACTION_RAW_ENCAP_INDEX_VALUE] = {
4155 .help = "unsigned integer value",
4156 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4157 .call = parse_vc_action_raw_encap_index,
4158 .comp = comp_set_raw_index,
4160 [ACTION_RAW_DECAP] = {
4161 .name = "raw_decap",
4162 .help = "decapsulation data, defined by set raw_encap",
4163 .priv = PRIV_ACTION(RAW_DECAP,
4164 sizeof(struct action_raw_decap_data)),
4165 .next = NEXT(action_raw_decap),
4166 .call = parse_vc_action_raw_decap,
4168 [ACTION_RAW_DECAP_INDEX] = {
4170 .help = "the index of raw_encap_confs",
4171 .next = NEXT(NEXT_ENTRY(ACTION_RAW_DECAP_INDEX_VALUE)),
4173 [ACTION_RAW_DECAP_INDEX_VALUE] = {
4176 .help = "unsigned integer value",
4177 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4178 .call = parse_vc_action_raw_decap_index,
4179 .comp = comp_set_raw_index,
4181 [ACTION_MODIFY_FIELD] = {
4182 .name = "modify_field",
4183 .help = "modify destination field with data from source field",
4184 .priv = PRIV_ACTION(MODIFY_FIELD,
4185 sizeof(struct rte_flow_action_modify_field)),
4186 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_OP)),
4189 [ACTION_MODIFY_FIELD_OP] = {
4191 .help = "operation type",
4192 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_TYPE),
4193 NEXT_ENTRY(ACTION_MODIFY_FIELD_OP_VALUE)),
4194 .call = parse_vc_conf,
4196 [ACTION_MODIFY_FIELD_OP_VALUE] = {
4197 .name = "{operation}",
4198 .help = "operation type value",
4199 .call = parse_vc_modify_field_op,
4200 .comp = comp_set_modify_field_op,
4202 [ACTION_MODIFY_FIELD_DST_TYPE] = {
4204 .help = "destination field type",
4205 .next = NEXT(action_modify_field_dst,
4206 NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_TYPE_VALUE)),
4207 .call = parse_vc_conf,
4209 [ACTION_MODIFY_FIELD_DST_TYPE_VALUE] = {
4210 .name = "{dst_type}",
4211 .help = "destination field type value",
4212 .call = parse_vc_modify_field_id,
4213 .comp = comp_set_modify_field_id,
4215 [ACTION_MODIFY_FIELD_DST_LEVEL] = {
4216 .name = "dst_level",
4217 .help = "destination field level",
4218 .next = NEXT(action_modify_field_dst, NEXT_ENTRY(UNSIGNED)),
4219 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4221 .call = parse_vc_conf,
4223 [ACTION_MODIFY_FIELD_DST_OFFSET] = {
4224 .name = "dst_offset",
4225 .help = "destination field bit offset",
4226 .next = NEXT(action_modify_field_dst, NEXT_ENTRY(UNSIGNED)),
4227 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4229 .call = parse_vc_conf,
4231 [ACTION_MODIFY_FIELD_SRC_TYPE] = {
4233 .help = "source field type",
4234 .next = NEXT(action_modify_field_src,
4235 NEXT_ENTRY(ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)),
4236 .call = parse_vc_conf,
4238 [ACTION_MODIFY_FIELD_SRC_TYPE_VALUE] = {
4239 .name = "{src_type}",
4240 .help = "source field type value",
4241 .call = parse_vc_modify_field_id,
4242 .comp = comp_set_modify_field_id,
4244 [ACTION_MODIFY_FIELD_SRC_LEVEL] = {
4245 .name = "src_level",
4246 .help = "source field level",
4247 .next = NEXT(action_modify_field_src, NEXT_ENTRY(UNSIGNED)),
4248 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4250 .call = parse_vc_conf,
4252 [ACTION_MODIFY_FIELD_SRC_OFFSET] = {
4253 .name = "src_offset",
4254 .help = "source field bit offset",
4255 .next = NEXT(action_modify_field_src, NEXT_ENTRY(UNSIGNED)),
4256 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4258 .call = parse_vc_conf,
4260 [ACTION_MODIFY_FIELD_SRC_VALUE] = {
4261 .name = "src_value",
4262 .help = "source immediate value",
4263 .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_WIDTH),
4264 NEXT_ENTRY(UNSIGNED)),
4265 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4267 .call = parse_vc_conf,
4269 [ACTION_MODIFY_FIELD_WIDTH] = {
4271 .help = "number of bits to copy",
4272 .next = NEXT(NEXT_ENTRY(ACTION_NEXT),
4273 NEXT_ENTRY(UNSIGNED)),
4274 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
4276 .call = parse_vc_conf,
4278 /* Top level command. */
4281 .help = "set raw encap/decap/sample data",
4282 .type = "set raw_encap|raw_decap <index> <pattern>"
4283 " or set sample_actions <index> <action>",
4284 .next = NEXT(NEXT_ENTRY
4287 SET_SAMPLE_ACTIONS)),
4288 .call = parse_set_init,
4290 /* Sub-level commands. */
4292 .name = "raw_encap",
4293 .help = "set raw encap data",
4294 .next = NEXT(next_set_raw),
4295 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4296 (offsetof(struct buffer, port),
4297 sizeof(((struct buffer *)0)->port),
4298 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
4299 .call = parse_set_raw_encap_decap,
4302 .name = "raw_decap",
4303 .help = "set raw decap data",
4304 .next = NEXT(next_set_raw),
4305 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4306 (offsetof(struct buffer, port),
4307 sizeof(((struct buffer *)0)->port),
4308 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
4309 .call = parse_set_raw_encap_decap,
4314 .help = "index of raw_encap/raw_decap data",
4315 .next = NEXT(next_item),
4318 [SET_SAMPLE_INDEX] = {
4321 .help = "index of sample actions",
4322 .next = NEXT(next_action_sample),
4325 [SET_SAMPLE_ACTIONS] = {
4326 .name = "sample_actions",
4327 .help = "set sample actions list",
4328 .next = NEXT(NEXT_ENTRY(SET_SAMPLE_INDEX)),
4329 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
4330 (offsetof(struct buffer, port),
4331 sizeof(((struct buffer *)0)->port),
4332 0, RAW_SAMPLE_CONFS_MAX_NUM - 1)),
4333 .call = parse_set_sample_action,
4335 [ACTION_SET_TAG] = {
4338 .priv = PRIV_ACTION(SET_TAG,
4339 sizeof(struct rte_flow_action_set_tag)),
4340 .next = NEXT(action_set_tag),
4343 [ACTION_SET_TAG_INDEX] = {
4345 .help = "index of tag array",
4346 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
4347 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_set_tag, index)),
4348 .call = parse_vc_conf,
4350 [ACTION_SET_TAG_DATA] = {
4352 .help = "tag value",
4353 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
4354 .args = ARGS(ARGS_ENTRY
4355 (struct rte_flow_action_set_tag, data)),
4356 .call = parse_vc_conf,
4358 [ACTION_SET_TAG_MASK] = {
4360 .help = "mask for tag value",
4361 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
4362 .args = ARGS(ARGS_ENTRY
4363 (struct rte_flow_action_set_tag, mask)),
4364 .call = parse_vc_conf,
4366 [ACTION_SET_META] = {
4368 .help = "set metadata",
4369 .priv = PRIV_ACTION(SET_META,
4370 sizeof(struct rte_flow_action_set_meta)),
4371 .next = NEXT(action_set_meta),
4372 .call = parse_vc_action_set_meta,
4374 [ACTION_SET_META_DATA] = {
4376 .help = "metadata value",
4377 .next = NEXT(action_set_meta, NEXT_ENTRY(UNSIGNED)),
4378 .args = ARGS(ARGS_ENTRY
4379 (struct rte_flow_action_set_meta, data)),
4380 .call = parse_vc_conf,
4382 [ACTION_SET_META_MASK] = {
4384 .help = "mask for metadata value",
4385 .next = NEXT(action_set_meta, NEXT_ENTRY(UNSIGNED)),
4386 .args = ARGS(ARGS_ENTRY
4387 (struct rte_flow_action_set_meta, mask)),
4388 .call = parse_vc_conf,
4390 [ACTION_SET_IPV4_DSCP] = {
4391 .name = "set_ipv4_dscp",
4392 .help = "set DSCP value",
4393 .priv = PRIV_ACTION(SET_IPV4_DSCP,
4394 sizeof(struct rte_flow_action_set_dscp)),
4395 .next = NEXT(action_set_ipv4_dscp),
4398 [ACTION_SET_IPV4_DSCP_VALUE] = {
4399 .name = "dscp_value",
4400 .help = "new IPv4 DSCP value to set",
4401 .next = NEXT(action_set_ipv4_dscp, NEXT_ENTRY(UNSIGNED)),
4402 .args = ARGS(ARGS_ENTRY
4403 (struct rte_flow_action_set_dscp, dscp)),
4404 .call = parse_vc_conf,
4406 [ACTION_SET_IPV6_DSCP] = {
4407 .name = "set_ipv6_dscp",
4408 .help = "set DSCP value",
4409 .priv = PRIV_ACTION(SET_IPV6_DSCP,
4410 sizeof(struct rte_flow_action_set_dscp)),
4411 .next = NEXT(action_set_ipv6_dscp),
4414 [ACTION_SET_IPV6_DSCP_VALUE] = {
4415 .name = "dscp_value",
4416 .help = "new IPv6 DSCP value to set",
4417 .next = NEXT(action_set_ipv6_dscp, NEXT_ENTRY(UNSIGNED)),
4418 .args = ARGS(ARGS_ENTRY
4419 (struct rte_flow_action_set_dscp, dscp)),
4420 .call = parse_vc_conf,
4424 .help = "set a specific metadata header",
4425 .next = NEXT(action_age),
4426 .priv = PRIV_ACTION(AGE,
4427 sizeof(struct rte_flow_action_age)),
4430 [ACTION_AGE_TIMEOUT] = {
4432 .help = "flow age timeout value",
4433 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_age,
4435 .next = NEXT(action_age, NEXT_ENTRY(UNSIGNED)),
4436 .call = parse_vc_conf,
4440 .help = "set a sample action",
4441 .next = NEXT(action_sample),
4442 .priv = PRIV_ACTION(SAMPLE,
4443 sizeof(struct action_sample_data)),
4444 .call = parse_vc_action_sample,
4446 [ACTION_SAMPLE_RATIO] = {
4448 .help = "flow sample ratio value",
4449 .next = NEXT(action_sample, NEXT_ENTRY(UNSIGNED)),
4450 .args = ARGS(ARGS_ENTRY_ARB
4451 (offsetof(struct action_sample_data, conf) +
4452 offsetof(struct rte_flow_action_sample, ratio),
4453 sizeof(((struct rte_flow_action_sample *)0)->
4456 [ACTION_SAMPLE_INDEX] = {
4458 .help = "the index of sample actions list",
4459 .next = NEXT(NEXT_ENTRY(ACTION_SAMPLE_INDEX_VALUE)),
4461 [ACTION_SAMPLE_INDEX_VALUE] = {
4464 .help = "unsigned integer value",
4465 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4466 .call = parse_vc_action_sample_index,
4467 .comp = comp_set_sample_index,
4469 /* Shared action destroy arguments. */
4470 [SHARED_ACTION_DESTROY_ID] = {
4471 .name = "action_id",
4472 .help = "specify a shared action id to destroy",
4473 .next = NEXT(next_sa_destroy_attr,
4474 NEXT_ENTRY(SHARED_ACTION_ID)),
4475 .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
4476 args.sa_destroy.action_id)),
4477 .call = parse_sa_destroy,
4479 /* Shared action create arguments. */
4480 [SHARED_ACTION_CREATE_ID] = {
4481 .name = "action_id",
4482 .help = "specify a shared action id to create",
4483 .next = NEXT(next_sa_create_attr,
4484 NEXT_ENTRY(SHARED_ACTION_ID)),
4485 .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
4489 .help = "apply shared action by id",
4490 .priv = PRIV_ACTION(SHARED, 0),
4491 .next = NEXT(NEXT_ENTRY(SHARED_ACTION_ID2PTR)),
4492 .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
4495 [SHARED_ACTION_ID2PTR] = {
4496 .name = "{action_id}",
4497 .type = "SHARED_ACTION_ID",
4498 .help = "shared action id",
4499 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
4500 .call = parse_sa_id2ptr,
4503 [SHARED_ACTION_INGRESS] = {
4505 .help = "affect rule to ingress",
4506 .next = NEXT(next_sa_create_attr),
4509 [SHARED_ACTION_EGRESS] = {
4511 .help = "affect rule to egress",
4512 .next = NEXT(next_sa_create_attr),
4515 [SHARED_ACTION_TRANSFER] = {
4517 .help = "affect rule to transfer",
4518 .next = NEXT(next_sa_create_attr),
4521 [SHARED_ACTION_SPEC] = {
4523 .help = "specify action to share",
4524 .next = NEXT(next_action),
4528 /** Remove and return last entry from argument stack. */
4529 static const struct arg *
4530 pop_args(struct context *ctx)
4532 return ctx->args_num ? ctx->args[--ctx->args_num] : NULL;
4535 /** Add entry on top of the argument stack. */
4537 push_args(struct context *ctx, const struct arg *arg)
4539 if (ctx->args_num == CTX_STACK_SIZE)
4541 ctx->args[ctx->args_num++] = arg;
4545 /** Spread value into buffer according to bit-mask. */
4547 arg_entry_bf_fill(void *dst, uintmax_t val, const struct arg *arg)
4549 uint32_t i = arg->size;
4557 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
4566 unsigned int shift = 0;
4567 uint8_t *buf = (uint8_t *)dst + arg->offset + (i -= sub);
4569 for (shift = 0; arg->mask[i] >> shift; ++shift) {
4570 if (!(arg->mask[i] & (1 << shift)))
4575 *buf &= ~(1 << shift);
4576 *buf |= (val & 1) << shift;
4584 /** Compare a string with a partial one of a given length. */
4586 strcmp_partial(const char *full, const char *partial, size_t partial_len)
4588 int r = strncmp(full, partial, partial_len);
4592 if (strlen(full) <= partial_len)
4594 return full[partial_len];
4598 * Parse a prefix length and generate a bit-mask.
4600 * Last argument (ctx->args) is retrieved to determine mask size, storage
4601 * location and whether the result must use network byte ordering.
4604 parse_prefix(struct context *ctx, const struct token *token,
4605 const char *str, unsigned int len,
4606 void *buf, unsigned int size)
4608 const struct arg *arg = pop_args(ctx);
4609 static const uint8_t conv[] = "\x00\x80\xc0\xe0\xf0\xf8\xfc\xfe\xff";
4616 /* Argument is expected. */
4620 u = strtoumax(str, &end, 0);
4621 if (errno || (size_t)(end - str) != len)
4626 extra = arg_entry_bf_fill(NULL, 0, arg);
4635 if (!arg_entry_bf_fill(ctx->object, v, arg) ||
4636 !arg_entry_bf_fill(ctx->objmask, -1, arg))
4643 if (bytes > size || bytes + !!extra > size)
4647 buf = (uint8_t *)ctx->object + arg->offset;
4648 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
4650 memset((uint8_t *)buf + size - bytes, 0xff, bytes);
4651 memset(buf, 0x00, size - bytes);
4653 ((uint8_t *)buf)[size - bytes - 1] = conv[extra];
4657 memset(buf, 0xff, bytes);
4658 memset((uint8_t *)buf + bytes, 0x00, size - bytes);
4660 ((uint8_t *)buf)[bytes] = conv[extra];
4663 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
4666 push_args(ctx, arg);
4670 /** Default parsing function for token name matching. */
4672 parse_default(struct context *ctx, const struct token *token,
4673 const char *str, unsigned int len,
4674 void *buf, unsigned int size)
4679 if (strcmp_partial(token->name, str, len))
4684 /** Parse flow command, initialize output buffer for subsequent tokens. */
4686 parse_init(struct context *ctx, const struct token *token,
4687 const char *str, unsigned int len,
4688 void *buf, unsigned int size)
4690 struct buffer *out = buf;
4692 /* Token name must match. */
4693 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4695 /* Nothing else to do if there is no buffer. */
4698 /* Make sure buffer is large enough. */
4699 if (size < sizeof(*out))
4701 /* Initialize buffer. */
4702 memset(out, 0x00, sizeof(*out));
4703 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
4706 ctx->objmask = NULL;
4710 /** Parse tokens for shared action commands. */
4712 parse_sa(struct context *ctx, const struct token *token,
4713 const char *str, unsigned int len,
4714 void *buf, unsigned int size)
4716 struct buffer *out = buf;
4718 /* Token name must match. */
4719 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4721 /* Nothing else to do if there is no buffer. */
4724 if (!out->command) {
4725 if (ctx->curr != SHARED_ACTION)
4727 if (sizeof(*out) > size)
4729 out->command = ctx->curr;
4732 ctx->objmask = NULL;
4733 out->args.vc.data = (uint8_t *)out + size;
4736 switch (ctx->curr) {
4737 case SHARED_ACTION_CREATE:
4738 case SHARED_ACTION_UPDATE:
4739 out->args.vc.actions =
4740 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
4742 out->args.vc.attr.group = UINT32_MAX;
4744 case SHARED_ACTION_QUERY:
4745 out->command = ctx->curr;
4748 ctx->objmask = NULL;
4750 case SHARED_ACTION_EGRESS:
4751 out->args.vc.attr.egress = 1;
4753 case SHARED_ACTION_INGRESS:
4754 out->args.vc.attr.ingress = 1;
4756 case SHARED_ACTION_TRANSFER:
4757 out->args.vc.attr.transfer = 1;
4765 /** Parse tokens for shared action destroy command. */
4767 parse_sa_destroy(struct context *ctx, const struct token *token,
4768 const char *str, unsigned int len,
4769 void *buf, unsigned int size)
4771 struct buffer *out = buf;
4772 uint32_t *action_id;
4774 /* Token name must match. */
4775 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4777 /* Nothing else to do if there is no buffer. */
4780 if (!out->command || out->command == SHARED_ACTION) {
4781 if (ctx->curr != SHARED_ACTION_DESTROY)
4783 if (sizeof(*out) > size)
4785 out->command = ctx->curr;
4788 ctx->objmask = NULL;
4789 out->args.sa_destroy.action_id =
4790 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
4794 action_id = out->args.sa_destroy.action_id
4795 + out->args.sa_destroy.action_id_n++;
4796 if ((uint8_t *)action_id > (uint8_t *)out + size)
4799 ctx->object = action_id;
4800 ctx->objmask = NULL;
4804 /** Parse tokens for validate/create commands. */
4806 parse_vc(struct context *ctx, const struct token *token,
4807 const char *str, unsigned int len,
4808 void *buf, unsigned int size)
4810 struct buffer *out = buf;
4814 /* Token name must match. */
4815 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4817 /* Nothing else to do if there is no buffer. */
4820 if (!out->command) {
4821 if (ctx->curr != VALIDATE && ctx->curr != CREATE)
4823 if (sizeof(*out) > size)
4825 out->command = ctx->curr;
4828 ctx->objmask = NULL;
4829 out->args.vc.data = (uint8_t *)out + size;
4833 switch (ctx->curr) {
4835 ctx->object = &out->args.vc.attr;
4839 ctx->object = &out->args.vc.tunnel_ops;
4842 ctx->objmask = NULL;
4843 switch (ctx->curr) {
4848 out->args.vc.tunnel_ops.enabled = 1;
4849 out->args.vc.tunnel_ops.actions = 1;
4852 out->args.vc.tunnel_ops.enabled = 1;
4853 out->args.vc.tunnel_ops.items = 1;
4856 out->args.vc.attr.ingress = 1;
4859 out->args.vc.attr.egress = 1;
4862 out->args.vc.attr.transfer = 1;
4865 out->args.vc.pattern =
4866 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
4868 ctx->object = out->args.vc.pattern;
4869 ctx->objmask = NULL;
4872 out->args.vc.actions =
4873 (void *)RTE_ALIGN_CEIL((uintptr_t)
4874 (out->args.vc.pattern +
4875 out->args.vc.pattern_n),
4877 ctx->object = out->args.vc.actions;
4878 ctx->objmask = NULL;
4885 if (!out->args.vc.actions) {
4886 const struct parse_item_priv *priv = token->priv;
4887 struct rte_flow_item *item =
4888 out->args.vc.pattern + out->args.vc.pattern_n;
4890 data_size = priv->size * 3; /* spec, last, mask */
4891 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
4892 (out->args.vc.data - data_size),
4894 if ((uint8_t *)item + sizeof(*item) > data)
4896 *item = (struct rte_flow_item){
4899 ++out->args.vc.pattern_n;
4901 ctx->objmask = NULL;
4903 const struct parse_action_priv *priv = token->priv;
4904 struct rte_flow_action *action =
4905 out->args.vc.actions + out->args.vc.actions_n;
4907 data_size = priv->size; /* configuration */
4908 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
4909 (out->args.vc.data - data_size),
4911 if ((uint8_t *)action + sizeof(*action) > data)
4913 *action = (struct rte_flow_action){
4915 .conf = data_size ? data : NULL,
4917 ++out->args.vc.actions_n;
4918 ctx->object = action;
4919 ctx->objmask = NULL;
4921 memset(data, 0, data_size);
4922 out->args.vc.data = data;
4923 ctx->objdata = data_size;
4927 /** Parse pattern item parameter type. */
4929 parse_vc_spec(struct context *ctx, const struct token *token,
4930 const char *str, unsigned int len,
4931 void *buf, unsigned int size)
4933 struct buffer *out = buf;
4934 struct rte_flow_item *item;
4940 /* Token name must match. */
4941 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4943 /* Parse parameter types. */
4944 switch (ctx->curr) {
4945 static const enum index prefix[] = NEXT_ENTRY(PREFIX);
4951 case ITEM_PARAM_SPEC:
4954 case ITEM_PARAM_LAST:
4957 case ITEM_PARAM_PREFIX:
4958 /* Modify next token to expect a prefix. */
4959 if (ctx->next_num < 2)
4961 ctx->next[ctx->next_num - 2] = prefix;
4963 case ITEM_PARAM_MASK:
4969 /* Nothing else to do if there is no buffer. */
4972 if (!out->args.vc.pattern_n)
4974 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
4975 data_size = ctx->objdata / 3; /* spec, last, mask */
4976 /* Point to selected object. */
4977 ctx->object = out->args.vc.data + (data_size * index);
4979 ctx->objmask = out->args.vc.data + (data_size * 2); /* mask */
4980 item->mask = ctx->objmask;
4982 ctx->objmask = NULL;
4983 /* Update relevant item pointer. */
4984 *((const void **[]){ &item->spec, &item->last, &item->mask })[index] =
4989 /** Parse action configuration field. */
4991 parse_vc_conf(struct context *ctx, const struct token *token,
4992 const char *str, unsigned int len,
4993 void *buf, unsigned int size)
4995 struct buffer *out = buf;
4998 /* Token name must match. */
4999 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5001 /* Nothing else to do if there is no buffer. */
5004 /* Point to selected object. */
5005 ctx->object = out->args.vc.data;
5006 ctx->objmask = NULL;
5010 /** Parse eCPRI common header type field. */
5012 parse_vc_item_ecpri_type(struct context *ctx, const struct token *token,
5013 const char *str, unsigned int len,
5014 void *buf, unsigned int size)
5016 struct rte_flow_item_ecpri *ecpri;
5017 struct rte_flow_item_ecpri *ecpri_mask;
5018 struct rte_flow_item *item;
5021 struct buffer *out = buf;
5022 const struct arg *arg;
5025 /* Token name must match. */
5026 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5028 switch (ctx->curr) {
5029 case ITEM_ECPRI_COMMON_TYPE_IQ_DATA:
5030 msg_type = RTE_ECPRI_MSG_TYPE_IQ_DATA;
5032 case ITEM_ECPRI_COMMON_TYPE_RTC_CTRL:
5033 msg_type = RTE_ECPRI_MSG_TYPE_RTC_CTRL;
5035 case ITEM_ECPRI_COMMON_TYPE_DLY_MSR:
5036 msg_type = RTE_ECPRI_MSG_TYPE_DLY_MSR;
5043 arg = pop_args(ctx);
5046 ecpri = (struct rte_flow_item_ecpri *)out->args.vc.data;
5047 ecpri->hdr.common.type = msg_type;
5048 data_size = ctx->objdata / 3; /* spec, last, mask */
5049 ecpri_mask = (struct rte_flow_item_ecpri *)(out->args.vc.data +
5051 ecpri_mask->hdr.common.type = 0xFF;
5053 ecpri->hdr.common.u32 = rte_cpu_to_be_32(ecpri->hdr.common.u32);
5054 ecpri_mask->hdr.common.u32 =
5055 rte_cpu_to_be_32(ecpri_mask->hdr.common.u32);
5057 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
5059 item->mask = ecpri_mask;
5063 /** Parse RSS action. */
5065 parse_vc_action_rss(struct context *ctx, const struct token *token,
5066 const char *str, unsigned int len,
5067 void *buf, unsigned int size)
5069 struct buffer *out = buf;
5070 struct rte_flow_action *action;
5071 struct action_rss_data *action_rss_data;
5075 ret = parse_vc(ctx, token, str, len, buf, size);
5078 /* Nothing else to do if there is no buffer. */
5081 if (!out->args.vc.actions_n)
5083 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5084 /* Point to selected object. */
5085 ctx->object = out->args.vc.data;
5086 ctx->objmask = NULL;
5087 /* Set up default configuration. */
5088 action_rss_data = ctx->object;
5089 *action_rss_data = (struct action_rss_data){
5090 .conf = (struct rte_flow_action_rss){
5091 .func = RTE_ETH_HASH_FUNCTION_DEFAULT,
5095 .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM),
5097 .queue = action_rss_data->queue,
5101 for (i = 0; i < action_rss_data->conf.queue_num; ++i)
5102 action_rss_data->queue[i] = i;
5103 action->conf = &action_rss_data->conf;
5108 * Parse func field for RSS action.
5110 * The RTE_ETH_HASH_FUNCTION_* value to assign is derived from the
5111 * ACTION_RSS_FUNC_* index that called this function.
5114 parse_vc_action_rss_func(struct context *ctx, const struct token *token,
5115 const char *str, unsigned int len,
5116 void *buf, unsigned int size)
5118 struct action_rss_data *action_rss_data;
5119 enum rte_eth_hash_function func;
5123 /* Token name must match. */
5124 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5126 switch (ctx->curr) {
5127 case ACTION_RSS_FUNC_DEFAULT:
5128 func = RTE_ETH_HASH_FUNCTION_DEFAULT;
5130 case ACTION_RSS_FUNC_TOEPLITZ:
5131 func = RTE_ETH_HASH_FUNCTION_TOEPLITZ;
5133 case ACTION_RSS_FUNC_SIMPLE_XOR:
5134 func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
5136 case ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ:
5137 func = RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
5144 action_rss_data = ctx->object;
5145 action_rss_data->conf.func = func;
5150 * Parse type field for RSS action.
5152 * Valid tokens are type field names and the "end" token.
5155 parse_vc_action_rss_type(struct context *ctx, const struct token *token,
5156 const char *str, unsigned int len,
5157 void *buf, unsigned int size)
5159 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE);
5160 struct action_rss_data *action_rss_data;
5166 if (ctx->curr != ACTION_RSS_TYPE)
5168 if (!(ctx->objdata >> 16) && ctx->object) {
5169 action_rss_data = ctx->object;
5170 action_rss_data->conf.types = 0;
5172 if (!strcmp_partial("end", str, len)) {
5173 ctx->objdata &= 0xffff;
5176 for (i = 0; rss_type_table[i].str; ++i)
5177 if (!strcmp_partial(rss_type_table[i].str, str, len))
5179 if (!rss_type_table[i].str)
5181 ctx->objdata = 1 << 16 | (ctx->objdata & 0xffff);
5183 if (ctx->next_num == RTE_DIM(ctx->next))
5185 ctx->next[ctx->next_num++] = next;
5188 action_rss_data = ctx->object;
5189 action_rss_data->conf.types |= rss_type_table[i].rss_type;
5194 * Parse queue field for RSS action.
5196 * Valid tokens are queue indices and the "end" token.
5199 parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
5200 const char *str, unsigned int len,
5201 void *buf, unsigned int size)
5203 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE);
5204 struct action_rss_data *action_rss_data;
5205 const struct arg *arg;
5212 if (ctx->curr != ACTION_RSS_QUEUE)
5214 i = ctx->objdata >> 16;
5215 if (!strcmp_partial("end", str, len)) {
5216 ctx->objdata &= 0xffff;
5219 if (i >= ACTION_RSS_QUEUE_NUM)
5221 arg = ARGS_ENTRY_ARB(offsetof(struct action_rss_data, queue) +
5222 i * sizeof(action_rss_data->queue[i]),
5223 sizeof(action_rss_data->queue[i]));
5224 if (push_args(ctx, arg))
5226 ret = parse_int(ctx, token, str, len, NULL, 0);
5232 ctx->objdata = i << 16 | (ctx->objdata & 0xffff);
5234 if (ctx->next_num == RTE_DIM(ctx->next))
5236 ctx->next[ctx->next_num++] = next;
5240 action_rss_data = ctx->object;
5241 action_rss_data->conf.queue_num = i;
5242 action_rss_data->conf.queue = i ? action_rss_data->queue : NULL;
5246 /** Parse VXLAN encap action. */
5248 parse_vc_action_vxlan_encap(struct context *ctx, const struct token *token,
5249 const char *str, unsigned int len,
5250 void *buf, unsigned int size)
5252 struct buffer *out = buf;
5253 struct rte_flow_action *action;
5254 struct action_vxlan_encap_data *action_vxlan_encap_data;
5257 ret = parse_vc(ctx, token, str, len, buf, size);
5260 /* Nothing else to do if there is no buffer. */
5263 if (!out->args.vc.actions_n)
5265 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5266 /* Point to selected object. */
5267 ctx->object = out->args.vc.data;
5268 ctx->objmask = NULL;
5269 /* Set up default configuration. */
5270 action_vxlan_encap_data = ctx->object;
5271 *action_vxlan_encap_data = (struct action_vxlan_encap_data){
5272 .conf = (struct rte_flow_action_vxlan_encap){
5273 .definition = action_vxlan_encap_data->items,
5277 .type = RTE_FLOW_ITEM_TYPE_ETH,
5278 .spec = &action_vxlan_encap_data->item_eth,
5279 .mask = &rte_flow_item_eth_mask,
5282 .type = RTE_FLOW_ITEM_TYPE_VLAN,
5283 .spec = &action_vxlan_encap_data->item_vlan,
5284 .mask = &rte_flow_item_vlan_mask,
5287 .type = RTE_FLOW_ITEM_TYPE_IPV4,
5288 .spec = &action_vxlan_encap_data->item_ipv4,
5289 .mask = &rte_flow_item_ipv4_mask,
5292 .type = RTE_FLOW_ITEM_TYPE_UDP,
5293 .spec = &action_vxlan_encap_data->item_udp,
5294 .mask = &rte_flow_item_udp_mask,
5297 .type = RTE_FLOW_ITEM_TYPE_VXLAN,
5298 .spec = &action_vxlan_encap_data->item_vxlan,
5299 .mask = &rte_flow_item_vxlan_mask,
5302 .type = RTE_FLOW_ITEM_TYPE_END,
5307 .tci = vxlan_encap_conf.vlan_tci,
5311 .src_addr = vxlan_encap_conf.ipv4_src,
5312 .dst_addr = vxlan_encap_conf.ipv4_dst,
5315 .src_port = vxlan_encap_conf.udp_src,
5316 .dst_port = vxlan_encap_conf.udp_dst,
5318 .item_vxlan.flags = 0,
5320 memcpy(action_vxlan_encap_data->item_eth.dst.addr_bytes,
5321 vxlan_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5322 memcpy(action_vxlan_encap_data->item_eth.src.addr_bytes,
5323 vxlan_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5324 if (!vxlan_encap_conf.select_ipv4) {
5325 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.src_addr,
5326 &vxlan_encap_conf.ipv6_src,
5327 sizeof(vxlan_encap_conf.ipv6_src));
5328 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.dst_addr,
5329 &vxlan_encap_conf.ipv6_dst,
5330 sizeof(vxlan_encap_conf.ipv6_dst));
5331 action_vxlan_encap_data->items[2] = (struct rte_flow_item){
5332 .type = RTE_FLOW_ITEM_TYPE_IPV6,
5333 .spec = &action_vxlan_encap_data->item_ipv6,
5334 .mask = &rte_flow_item_ipv6_mask,
5337 if (!vxlan_encap_conf.select_vlan)
5338 action_vxlan_encap_data->items[1].type =
5339 RTE_FLOW_ITEM_TYPE_VOID;
5340 if (vxlan_encap_conf.select_tos_ttl) {
5341 if (vxlan_encap_conf.select_ipv4) {
5342 static struct rte_flow_item_ipv4 ipv4_mask_tos;
5344 memcpy(&ipv4_mask_tos, &rte_flow_item_ipv4_mask,
5345 sizeof(ipv4_mask_tos));
5346 ipv4_mask_tos.hdr.type_of_service = 0xff;
5347 ipv4_mask_tos.hdr.time_to_live = 0xff;
5348 action_vxlan_encap_data->item_ipv4.hdr.type_of_service =
5349 vxlan_encap_conf.ip_tos;
5350 action_vxlan_encap_data->item_ipv4.hdr.time_to_live =
5351 vxlan_encap_conf.ip_ttl;
5352 action_vxlan_encap_data->items[2].mask =
5355 static struct rte_flow_item_ipv6 ipv6_mask_tos;
5357 memcpy(&ipv6_mask_tos, &rte_flow_item_ipv6_mask,
5358 sizeof(ipv6_mask_tos));
5359 ipv6_mask_tos.hdr.vtc_flow |=
5360 RTE_BE32(0xfful << RTE_IPV6_HDR_TC_SHIFT);
5361 ipv6_mask_tos.hdr.hop_limits = 0xff;
5362 action_vxlan_encap_data->item_ipv6.hdr.vtc_flow |=
5364 ((uint32_t)vxlan_encap_conf.ip_tos <<
5365 RTE_IPV6_HDR_TC_SHIFT);
5366 action_vxlan_encap_data->item_ipv6.hdr.hop_limits =
5367 vxlan_encap_conf.ip_ttl;
5368 action_vxlan_encap_data->items[2].mask =
5372 memcpy(action_vxlan_encap_data->item_vxlan.vni, vxlan_encap_conf.vni,
5373 RTE_DIM(vxlan_encap_conf.vni));
5374 action->conf = &action_vxlan_encap_data->conf;
5378 /** Parse NVGRE encap action. */
5380 parse_vc_action_nvgre_encap(struct context *ctx, const struct token *token,
5381 const char *str, unsigned int len,
5382 void *buf, unsigned int size)
5384 struct buffer *out = buf;
5385 struct rte_flow_action *action;
5386 struct action_nvgre_encap_data *action_nvgre_encap_data;
5389 ret = parse_vc(ctx, token, str, len, buf, size);
5392 /* Nothing else to do if there is no buffer. */
5395 if (!out->args.vc.actions_n)
5397 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5398 /* Point to selected object. */
5399 ctx->object = out->args.vc.data;
5400 ctx->objmask = NULL;
5401 /* Set up default configuration. */
5402 action_nvgre_encap_data = ctx->object;
5403 *action_nvgre_encap_data = (struct action_nvgre_encap_data){
5404 .conf = (struct rte_flow_action_nvgre_encap){
5405 .definition = action_nvgre_encap_data->items,
5409 .type = RTE_FLOW_ITEM_TYPE_ETH,
5410 .spec = &action_nvgre_encap_data->item_eth,
5411 .mask = &rte_flow_item_eth_mask,
5414 .type = RTE_FLOW_ITEM_TYPE_VLAN,
5415 .spec = &action_nvgre_encap_data->item_vlan,
5416 .mask = &rte_flow_item_vlan_mask,
5419 .type = RTE_FLOW_ITEM_TYPE_IPV4,
5420 .spec = &action_nvgre_encap_data->item_ipv4,
5421 .mask = &rte_flow_item_ipv4_mask,
5424 .type = RTE_FLOW_ITEM_TYPE_NVGRE,
5425 .spec = &action_nvgre_encap_data->item_nvgre,
5426 .mask = &rte_flow_item_nvgre_mask,
5429 .type = RTE_FLOW_ITEM_TYPE_END,
5434 .tci = nvgre_encap_conf.vlan_tci,
5438 .src_addr = nvgre_encap_conf.ipv4_src,
5439 .dst_addr = nvgre_encap_conf.ipv4_dst,
5441 .item_nvgre.flow_id = 0,
5443 memcpy(action_nvgre_encap_data->item_eth.dst.addr_bytes,
5444 nvgre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5445 memcpy(action_nvgre_encap_data->item_eth.src.addr_bytes,
5446 nvgre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5447 if (!nvgre_encap_conf.select_ipv4) {
5448 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.src_addr,
5449 &nvgre_encap_conf.ipv6_src,
5450 sizeof(nvgre_encap_conf.ipv6_src));
5451 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.dst_addr,
5452 &nvgre_encap_conf.ipv6_dst,
5453 sizeof(nvgre_encap_conf.ipv6_dst));
5454 action_nvgre_encap_data->items[2] = (struct rte_flow_item){
5455 .type = RTE_FLOW_ITEM_TYPE_IPV6,
5456 .spec = &action_nvgre_encap_data->item_ipv6,
5457 .mask = &rte_flow_item_ipv6_mask,
5460 if (!nvgre_encap_conf.select_vlan)
5461 action_nvgre_encap_data->items[1].type =
5462 RTE_FLOW_ITEM_TYPE_VOID;
5463 memcpy(action_nvgre_encap_data->item_nvgre.tni, nvgre_encap_conf.tni,
5464 RTE_DIM(nvgre_encap_conf.tni));
5465 action->conf = &action_nvgre_encap_data->conf;
5469 /** Parse l2 encap action. */
5471 parse_vc_action_l2_encap(struct context *ctx, const struct token *token,
5472 const char *str, unsigned int len,
5473 void *buf, unsigned int size)
5475 struct buffer *out = buf;
5476 struct rte_flow_action *action;
5477 struct action_raw_encap_data *action_encap_data;
5478 struct rte_flow_item_eth eth = { .type = 0, };
5479 struct rte_flow_item_vlan vlan = {
5480 .tci = mplsoudp_encap_conf.vlan_tci,
5486 ret = parse_vc(ctx, token, str, len, buf, size);
5489 /* Nothing else to do if there is no buffer. */
5492 if (!out->args.vc.actions_n)
5494 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5495 /* Point to selected object. */
5496 ctx->object = out->args.vc.data;
5497 ctx->objmask = NULL;
5498 /* Copy the headers to the buffer. */
5499 action_encap_data = ctx->object;
5500 *action_encap_data = (struct action_raw_encap_data) {
5501 .conf = (struct rte_flow_action_raw_encap){
5502 .data = action_encap_data->data,
5506 header = action_encap_data->data;
5507 if (l2_encap_conf.select_vlan)
5508 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5509 else if (l2_encap_conf.select_ipv4)
5510 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5512 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5513 memcpy(eth.dst.addr_bytes,
5514 l2_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5515 memcpy(eth.src.addr_bytes,
5516 l2_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5517 memcpy(header, ð, sizeof(eth));
5518 header += sizeof(eth);
5519 if (l2_encap_conf.select_vlan) {
5520 if (l2_encap_conf.select_ipv4)
5521 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5523 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5524 memcpy(header, &vlan, sizeof(vlan));
5525 header += sizeof(vlan);
5527 action_encap_data->conf.size = header -
5528 action_encap_data->data;
5529 action->conf = &action_encap_data->conf;
5533 /** Parse l2 decap action. */
5535 parse_vc_action_l2_decap(struct context *ctx, const struct token *token,
5536 const char *str, unsigned int len,
5537 void *buf, unsigned int size)
5539 struct buffer *out = buf;
5540 struct rte_flow_action *action;
5541 struct action_raw_decap_data *action_decap_data;
5542 struct rte_flow_item_eth eth = { .type = 0, };
5543 struct rte_flow_item_vlan vlan = {
5544 .tci = mplsoudp_encap_conf.vlan_tci,
5550 ret = parse_vc(ctx, token, str, len, buf, size);
5553 /* Nothing else to do if there is no buffer. */
5556 if (!out->args.vc.actions_n)
5558 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5559 /* Point to selected object. */
5560 ctx->object = out->args.vc.data;
5561 ctx->objmask = NULL;
5562 /* Copy the headers to the buffer. */
5563 action_decap_data = ctx->object;
5564 *action_decap_data = (struct action_raw_decap_data) {
5565 .conf = (struct rte_flow_action_raw_decap){
5566 .data = action_decap_data->data,
5570 header = action_decap_data->data;
5571 if (l2_decap_conf.select_vlan)
5572 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5573 memcpy(header, ð, sizeof(eth));
5574 header += sizeof(eth);
5575 if (l2_decap_conf.select_vlan) {
5576 memcpy(header, &vlan, sizeof(vlan));
5577 header += sizeof(vlan);
5579 action_decap_data->conf.size = header -
5580 action_decap_data->data;
5581 action->conf = &action_decap_data->conf;
5585 #define ETHER_TYPE_MPLS_UNICAST 0x8847
5587 /** Parse MPLSOGRE encap action. */
5589 parse_vc_action_mplsogre_encap(struct context *ctx, const struct token *token,
5590 const char *str, unsigned int len,
5591 void *buf, unsigned int size)
5593 struct buffer *out = buf;
5594 struct rte_flow_action *action;
5595 struct action_raw_encap_data *action_encap_data;
5596 struct rte_flow_item_eth eth = { .type = 0, };
5597 struct rte_flow_item_vlan vlan = {
5598 .tci = mplsogre_encap_conf.vlan_tci,
5601 struct rte_flow_item_ipv4 ipv4 = {
5603 .src_addr = mplsogre_encap_conf.ipv4_src,
5604 .dst_addr = mplsogre_encap_conf.ipv4_dst,
5605 .next_proto_id = IPPROTO_GRE,
5606 .version_ihl = RTE_IPV4_VHL_DEF,
5607 .time_to_live = IPDEFTTL,
5610 struct rte_flow_item_ipv6 ipv6 = {
5612 .proto = IPPROTO_GRE,
5613 .hop_limits = IPDEFTTL,
5616 struct rte_flow_item_gre gre = {
5617 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
5619 struct rte_flow_item_mpls mpls = {
5625 ret = parse_vc(ctx, token, str, len, buf, size);
5628 /* Nothing else to do if there is no buffer. */
5631 if (!out->args.vc.actions_n)
5633 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5634 /* Point to selected object. */
5635 ctx->object = out->args.vc.data;
5636 ctx->objmask = NULL;
5637 /* Copy the headers to the buffer. */
5638 action_encap_data = ctx->object;
5639 *action_encap_data = (struct action_raw_encap_data) {
5640 .conf = (struct rte_flow_action_raw_encap){
5641 .data = action_encap_data->data,
5646 header = action_encap_data->data;
5647 if (mplsogre_encap_conf.select_vlan)
5648 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5649 else if (mplsogre_encap_conf.select_ipv4)
5650 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5652 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5653 memcpy(eth.dst.addr_bytes,
5654 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5655 memcpy(eth.src.addr_bytes,
5656 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5657 memcpy(header, ð, sizeof(eth));
5658 header += sizeof(eth);
5659 if (mplsogre_encap_conf.select_vlan) {
5660 if (mplsogre_encap_conf.select_ipv4)
5661 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5663 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5664 memcpy(header, &vlan, sizeof(vlan));
5665 header += sizeof(vlan);
5667 if (mplsogre_encap_conf.select_ipv4) {
5668 memcpy(header, &ipv4, sizeof(ipv4));
5669 header += sizeof(ipv4);
5671 memcpy(&ipv6.hdr.src_addr,
5672 &mplsogre_encap_conf.ipv6_src,
5673 sizeof(mplsogre_encap_conf.ipv6_src));
5674 memcpy(&ipv6.hdr.dst_addr,
5675 &mplsogre_encap_conf.ipv6_dst,
5676 sizeof(mplsogre_encap_conf.ipv6_dst));
5677 memcpy(header, &ipv6, sizeof(ipv6));
5678 header += sizeof(ipv6);
5680 memcpy(header, &gre, sizeof(gre));
5681 header += sizeof(gre);
5682 memcpy(mpls.label_tc_s, mplsogre_encap_conf.label,
5683 RTE_DIM(mplsogre_encap_conf.label));
5684 mpls.label_tc_s[2] |= 0x1;
5685 memcpy(header, &mpls, sizeof(mpls));
5686 header += sizeof(mpls);
5687 action_encap_data->conf.size = header -
5688 action_encap_data->data;
5689 action->conf = &action_encap_data->conf;
5693 /** Parse MPLSOGRE decap action. */
5695 parse_vc_action_mplsogre_decap(struct context *ctx, const struct token *token,
5696 const char *str, unsigned int len,
5697 void *buf, unsigned int size)
5699 struct buffer *out = buf;
5700 struct rte_flow_action *action;
5701 struct action_raw_decap_data *action_decap_data;
5702 struct rte_flow_item_eth eth = { .type = 0, };
5703 struct rte_flow_item_vlan vlan = {.tci = 0};
5704 struct rte_flow_item_ipv4 ipv4 = {
5706 .next_proto_id = IPPROTO_GRE,
5709 struct rte_flow_item_ipv6 ipv6 = {
5711 .proto = IPPROTO_GRE,
5714 struct rte_flow_item_gre gre = {
5715 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
5717 struct rte_flow_item_mpls mpls;
5721 ret = parse_vc(ctx, token, str, len, buf, size);
5724 /* Nothing else to do if there is no buffer. */
5727 if (!out->args.vc.actions_n)
5729 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5730 /* Point to selected object. */
5731 ctx->object = out->args.vc.data;
5732 ctx->objmask = NULL;
5733 /* Copy the headers to the buffer. */
5734 action_decap_data = ctx->object;
5735 *action_decap_data = (struct action_raw_decap_data) {
5736 .conf = (struct rte_flow_action_raw_decap){
5737 .data = action_decap_data->data,
5741 header = action_decap_data->data;
5742 if (mplsogre_decap_conf.select_vlan)
5743 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5744 else if (mplsogre_encap_conf.select_ipv4)
5745 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5747 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5748 memcpy(eth.dst.addr_bytes,
5749 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5750 memcpy(eth.src.addr_bytes,
5751 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5752 memcpy(header, ð, sizeof(eth));
5753 header += sizeof(eth);
5754 if (mplsogre_encap_conf.select_vlan) {
5755 if (mplsogre_encap_conf.select_ipv4)
5756 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5758 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5759 memcpy(header, &vlan, sizeof(vlan));
5760 header += sizeof(vlan);
5762 if (mplsogre_encap_conf.select_ipv4) {
5763 memcpy(header, &ipv4, sizeof(ipv4));
5764 header += sizeof(ipv4);
5766 memcpy(header, &ipv6, sizeof(ipv6));
5767 header += sizeof(ipv6);
5769 memcpy(header, &gre, sizeof(gre));
5770 header += sizeof(gre);
5771 memset(&mpls, 0, sizeof(mpls));
5772 memcpy(header, &mpls, sizeof(mpls));
5773 header += sizeof(mpls);
5774 action_decap_data->conf.size = header -
5775 action_decap_data->data;
5776 action->conf = &action_decap_data->conf;
5780 /** Parse MPLSOUDP encap action. */
5782 parse_vc_action_mplsoudp_encap(struct context *ctx, const struct token *token,
5783 const char *str, unsigned int len,
5784 void *buf, unsigned int size)
5786 struct buffer *out = buf;
5787 struct rte_flow_action *action;
5788 struct action_raw_encap_data *action_encap_data;
5789 struct rte_flow_item_eth eth = { .type = 0, };
5790 struct rte_flow_item_vlan vlan = {
5791 .tci = mplsoudp_encap_conf.vlan_tci,
5794 struct rte_flow_item_ipv4 ipv4 = {
5796 .src_addr = mplsoudp_encap_conf.ipv4_src,
5797 .dst_addr = mplsoudp_encap_conf.ipv4_dst,
5798 .next_proto_id = IPPROTO_UDP,
5799 .version_ihl = RTE_IPV4_VHL_DEF,
5800 .time_to_live = IPDEFTTL,
5803 struct rte_flow_item_ipv6 ipv6 = {
5805 .proto = IPPROTO_UDP,
5806 .hop_limits = IPDEFTTL,
5809 struct rte_flow_item_udp udp = {
5811 .src_port = mplsoudp_encap_conf.udp_src,
5812 .dst_port = mplsoudp_encap_conf.udp_dst,
5815 struct rte_flow_item_mpls mpls;
5819 ret = parse_vc(ctx, token, str, len, buf, size);
5822 /* Nothing else to do if there is no buffer. */
5825 if (!out->args.vc.actions_n)
5827 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5828 /* Point to selected object. */
5829 ctx->object = out->args.vc.data;
5830 ctx->objmask = NULL;
5831 /* Copy the headers to the buffer. */
5832 action_encap_data = ctx->object;
5833 *action_encap_data = (struct action_raw_encap_data) {
5834 .conf = (struct rte_flow_action_raw_encap){
5835 .data = action_encap_data->data,
5840 header = action_encap_data->data;
5841 if (mplsoudp_encap_conf.select_vlan)
5842 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5843 else if (mplsoudp_encap_conf.select_ipv4)
5844 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5846 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5847 memcpy(eth.dst.addr_bytes,
5848 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5849 memcpy(eth.src.addr_bytes,
5850 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5851 memcpy(header, ð, sizeof(eth));
5852 header += sizeof(eth);
5853 if (mplsoudp_encap_conf.select_vlan) {
5854 if (mplsoudp_encap_conf.select_ipv4)
5855 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5857 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5858 memcpy(header, &vlan, sizeof(vlan));
5859 header += sizeof(vlan);
5861 if (mplsoudp_encap_conf.select_ipv4) {
5862 memcpy(header, &ipv4, sizeof(ipv4));
5863 header += sizeof(ipv4);
5865 memcpy(&ipv6.hdr.src_addr,
5866 &mplsoudp_encap_conf.ipv6_src,
5867 sizeof(mplsoudp_encap_conf.ipv6_src));
5868 memcpy(&ipv6.hdr.dst_addr,
5869 &mplsoudp_encap_conf.ipv6_dst,
5870 sizeof(mplsoudp_encap_conf.ipv6_dst));
5871 memcpy(header, &ipv6, sizeof(ipv6));
5872 header += sizeof(ipv6);
5874 memcpy(header, &udp, sizeof(udp));
5875 header += sizeof(udp);
5876 memcpy(mpls.label_tc_s, mplsoudp_encap_conf.label,
5877 RTE_DIM(mplsoudp_encap_conf.label));
5878 mpls.label_tc_s[2] |= 0x1;
5879 memcpy(header, &mpls, sizeof(mpls));
5880 header += sizeof(mpls);
5881 action_encap_data->conf.size = header -
5882 action_encap_data->data;
5883 action->conf = &action_encap_data->conf;
5887 /** Parse MPLSOUDP decap action. */
5889 parse_vc_action_mplsoudp_decap(struct context *ctx, const struct token *token,
5890 const char *str, unsigned int len,
5891 void *buf, unsigned int size)
5893 struct buffer *out = buf;
5894 struct rte_flow_action *action;
5895 struct action_raw_decap_data *action_decap_data;
5896 struct rte_flow_item_eth eth = { .type = 0, };
5897 struct rte_flow_item_vlan vlan = {.tci = 0};
5898 struct rte_flow_item_ipv4 ipv4 = {
5900 .next_proto_id = IPPROTO_UDP,
5903 struct rte_flow_item_ipv6 ipv6 = {
5905 .proto = IPPROTO_UDP,
5908 struct rte_flow_item_udp udp = {
5910 .dst_port = rte_cpu_to_be_16(6635),
5913 struct rte_flow_item_mpls mpls;
5917 ret = parse_vc(ctx, token, str, len, buf, size);
5920 /* Nothing else to do if there is no buffer. */
5923 if (!out->args.vc.actions_n)
5925 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5926 /* Point to selected object. */
5927 ctx->object = out->args.vc.data;
5928 ctx->objmask = NULL;
5929 /* Copy the headers to the buffer. */
5930 action_decap_data = ctx->object;
5931 *action_decap_data = (struct action_raw_decap_data) {
5932 .conf = (struct rte_flow_action_raw_decap){
5933 .data = action_decap_data->data,
5937 header = action_decap_data->data;
5938 if (mplsoudp_decap_conf.select_vlan)
5939 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5940 else if (mplsoudp_encap_conf.select_ipv4)
5941 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5943 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5944 memcpy(eth.dst.addr_bytes,
5945 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5946 memcpy(eth.src.addr_bytes,
5947 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5948 memcpy(header, ð, sizeof(eth));
5949 header += sizeof(eth);
5950 if (mplsoudp_encap_conf.select_vlan) {
5951 if (mplsoudp_encap_conf.select_ipv4)
5952 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5954 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5955 memcpy(header, &vlan, sizeof(vlan));
5956 header += sizeof(vlan);
5958 if (mplsoudp_encap_conf.select_ipv4) {
5959 memcpy(header, &ipv4, sizeof(ipv4));
5960 header += sizeof(ipv4);
5962 memcpy(header, &ipv6, sizeof(ipv6));
5963 header += sizeof(ipv6);
5965 memcpy(header, &udp, sizeof(udp));
5966 header += sizeof(udp);
5967 memset(&mpls, 0, sizeof(mpls));
5968 memcpy(header, &mpls, sizeof(mpls));
5969 header += sizeof(mpls);
5970 action_decap_data->conf.size = header -
5971 action_decap_data->data;
5972 action->conf = &action_decap_data->conf;
5977 parse_vc_action_raw_decap_index(struct context *ctx, const struct token *token,
5978 const char *str, unsigned int len, void *buf,
5981 struct action_raw_decap_data *action_raw_decap_data;
5982 struct rte_flow_action *action;
5983 const struct arg *arg;
5984 struct buffer *out = buf;
5988 RTE_SET_USED(token);
5991 arg = ARGS_ENTRY_ARB_BOUNDED
5992 (offsetof(struct action_raw_decap_data, idx),
5993 sizeof(((struct action_raw_decap_data *)0)->idx),
5994 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
5995 if (push_args(ctx, arg))
5997 ret = parse_int(ctx, token, str, len, NULL, 0);
6004 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6005 action_raw_decap_data = ctx->object;
6006 idx = action_raw_decap_data->idx;
6007 action_raw_decap_data->conf.data = raw_decap_confs[idx].data;
6008 action_raw_decap_data->conf.size = raw_decap_confs[idx].size;
6009 action->conf = &action_raw_decap_data->conf;
6015 parse_vc_action_raw_encap_index(struct context *ctx, const struct token *token,
6016 const char *str, unsigned int len, void *buf,
6019 struct action_raw_encap_data *action_raw_encap_data;
6020 struct rte_flow_action *action;
6021 const struct arg *arg;
6022 struct buffer *out = buf;
6026 RTE_SET_USED(token);
6029 if (ctx->curr != ACTION_RAW_ENCAP_INDEX_VALUE)
6031 arg = ARGS_ENTRY_ARB_BOUNDED
6032 (offsetof(struct action_raw_encap_data, idx),
6033 sizeof(((struct action_raw_encap_data *)0)->idx),
6034 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
6035 if (push_args(ctx, arg))
6037 ret = parse_int(ctx, token, str, len, NULL, 0);
6044 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6045 action_raw_encap_data = ctx->object;
6046 idx = action_raw_encap_data->idx;
6047 action_raw_encap_data->conf.data = raw_encap_confs[idx].data;
6048 action_raw_encap_data->conf.size = raw_encap_confs[idx].size;
6049 action_raw_encap_data->conf.preserve = NULL;
6050 action->conf = &action_raw_encap_data->conf;
6055 parse_vc_action_raw_encap(struct context *ctx, const struct token *token,
6056 const char *str, unsigned int len, void *buf,
6059 struct buffer *out = buf;
6060 struct rte_flow_action *action;
6061 struct action_raw_encap_data *action_raw_encap_data = NULL;
6064 ret = parse_vc(ctx, token, str, len, buf, size);
6067 /* Nothing else to do if there is no buffer. */
6070 if (!out->args.vc.actions_n)
6072 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6073 /* Point to selected object. */
6074 ctx->object = out->args.vc.data;
6075 ctx->objmask = NULL;
6076 /* Copy the headers to the buffer. */
6077 action_raw_encap_data = ctx->object;
6078 action_raw_encap_data->conf.data = raw_encap_confs[0].data;
6079 action_raw_encap_data->conf.preserve = NULL;
6080 action_raw_encap_data->conf.size = raw_encap_confs[0].size;
6081 action->conf = &action_raw_encap_data->conf;
6086 parse_vc_action_raw_decap(struct context *ctx, const struct token *token,
6087 const char *str, unsigned int len, void *buf,
6090 struct buffer *out = buf;
6091 struct rte_flow_action *action;
6092 struct action_raw_decap_data *action_raw_decap_data = NULL;
6095 ret = parse_vc(ctx, token, str, len, buf, size);
6098 /* Nothing else to do if there is no buffer. */
6101 if (!out->args.vc.actions_n)
6103 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6104 /* Point to selected object. */
6105 ctx->object = out->args.vc.data;
6106 ctx->objmask = NULL;
6107 /* Copy the headers to the buffer. */
6108 action_raw_decap_data = ctx->object;
6109 action_raw_decap_data->conf.data = raw_decap_confs[0].data;
6110 action_raw_decap_data->conf.size = raw_decap_confs[0].size;
6111 action->conf = &action_raw_decap_data->conf;
6116 parse_vc_action_set_meta(struct context *ctx, const struct token *token,
6117 const char *str, unsigned int len, void *buf,
6122 ret = parse_vc(ctx, token, str, len, buf, size);
6125 ret = rte_flow_dynf_metadata_register();
6132 parse_vc_action_sample(struct context *ctx, const struct token *token,
6133 const char *str, unsigned int len, void *buf,
6136 struct buffer *out = buf;
6137 struct rte_flow_action *action;
6138 struct action_sample_data *action_sample_data = NULL;
6139 static struct rte_flow_action end_action = {
6140 RTE_FLOW_ACTION_TYPE_END, 0
6144 ret = parse_vc(ctx, token, str, len, buf, size);
6147 /* Nothing else to do if there is no buffer. */
6150 if (!out->args.vc.actions_n)
6152 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6153 /* Point to selected object. */
6154 ctx->object = out->args.vc.data;
6155 ctx->objmask = NULL;
6156 /* Copy the headers to the buffer. */
6157 action_sample_data = ctx->object;
6158 action_sample_data->conf.actions = &end_action;
6159 action->conf = &action_sample_data->conf;
6164 parse_vc_action_sample_index(struct context *ctx, const struct token *token,
6165 const char *str, unsigned int len, void *buf,
6168 struct action_sample_data *action_sample_data;
6169 struct rte_flow_action *action;
6170 const struct arg *arg;
6171 struct buffer *out = buf;
6175 RTE_SET_USED(token);
6178 if (ctx->curr != ACTION_SAMPLE_INDEX_VALUE)
6180 arg = ARGS_ENTRY_ARB_BOUNDED
6181 (offsetof(struct action_sample_data, idx),
6182 sizeof(((struct action_sample_data *)0)->idx),
6183 0, RAW_SAMPLE_CONFS_MAX_NUM - 1);
6184 if (push_args(ctx, arg))
6186 ret = parse_int(ctx, token, str, len, NULL, 0);
6193 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
6194 action_sample_data = ctx->object;
6195 idx = action_sample_data->idx;
6196 action_sample_data->conf.actions = raw_sample_confs[idx].data;
6197 action->conf = &action_sample_data->conf;
6201 /** Parse operation for modify_field command. */
6203 parse_vc_modify_field_op(struct context *ctx, const struct token *token,
6204 const char *str, unsigned int len, void *buf,
6207 struct rte_flow_action_modify_field *action_modify_field;
6213 if (ctx->curr != ACTION_MODIFY_FIELD_OP_VALUE)
6215 for (i = 0; modify_field_ops[i]; ++i)
6216 if (!strcmp_partial(modify_field_ops[i], str, len))
6218 if (!modify_field_ops[i])
6222 action_modify_field = ctx->object;
6223 action_modify_field->operation = (enum rte_flow_modify_op)i;
6227 /** Parse id for modify_field command. */
6229 parse_vc_modify_field_id(struct context *ctx, const struct token *token,
6230 const char *str, unsigned int len, void *buf,
6233 struct rte_flow_action_modify_field *action_modify_field;
6239 if (ctx->curr != ACTION_MODIFY_FIELD_DST_TYPE_VALUE &&
6240 ctx->curr != ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)
6242 for (i = 0; modify_field_ids[i]; ++i)
6243 if (!strcmp_partial(modify_field_ids[i], str, len))
6245 if (!modify_field_ids[i])
6249 action_modify_field = ctx->object;
6250 if (ctx->curr == ACTION_MODIFY_FIELD_DST_TYPE_VALUE)
6251 action_modify_field->dst.field = (enum rte_flow_field_id)i;
6253 action_modify_field->src.field = (enum rte_flow_field_id)i;
6257 /** Parse tokens for destroy command. */
6259 parse_destroy(struct context *ctx, const struct token *token,
6260 const char *str, unsigned int len,
6261 void *buf, unsigned int size)
6263 struct buffer *out = buf;
6265 /* Token name must match. */
6266 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6268 /* Nothing else to do if there is no buffer. */
6271 if (!out->command) {
6272 if (ctx->curr != DESTROY)
6274 if (sizeof(*out) > size)
6276 out->command = ctx->curr;
6279 ctx->objmask = NULL;
6280 out->args.destroy.rule =
6281 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6285 if (((uint8_t *)(out->args.destroy.rule + out->args.destroy.rule_n) +
6286 sizeof(*out->args.destroy.rule)) > (uint8_t *)out + size)
6289 ctx->object = out->args.destroy.rule + out->args.destroy.rule_n++;
6290 ctx->objmask = NULL;
6294 /** Parse tokens for flush command. */
6296 parse_flush(struct context *ctx, const struct token *token,
6297 const char *str, unsigned int len,
6298 void *buf, unsigned int size)
6300 struct buffer *out = buf;
6302 /* Token name must match. */
6303 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6305 /* Nothing else to do if there is no buffer. */
6308 if (!out->command) {
6309 if (ctx->curr != FLUSH)
6311 if (sizeof(*out) > size)
6313 out->command = ctx->curr;
6316 ctx->objmask = NULL;
6321 /** Parse tokens for dump command. */
6323 parse_dump(struct context *ctx, const struct token *token,
6324 const char *str, unsigned int len,
6325 void *buf, unsigned int size)
6327 struct buffer *out = buf;
6329 /* Token name must match. */
6330 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6332 /* Nothing else to do if there is no buffer. */
6335 if (!out->command) {
6336 if (ctx->curr != DUMP)
6338 if (sizeof(*out) > size)
6340 out->command = ctx->curr;
6343 ctx->objmask = NULL;
6348 /** Parse tokens for query command. */
6350 parse_query(struct context *ctx, const struct token *token,
6351 const char *str, unsigned int len,
6352 void *buf, unsigned int size)
6354 struct buffer *out = buf;
6356 /* Token name must match. */
6357 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6359 /* Nothing else to do if there is no buffer. */
6362 if (!out->command) {
6363 if (ctx->curr != QUERY)
6365 if (sizeof(*out) > size)
6367 out->command = ctx->curr;
6370 ctx->objmask = NULL;
6375 /** Parse action names. */
6377 parse_action(struct context *ctx, const struct token *token,
6378 const char *str, unsigned int len,
6379 void *buf, unsigned int size)
6381 struct buffer *out = buf;
6382 const struct arg *arg = pop_args(ctx);
6386 /* Argument is expected. */
6389 /* Parse action name. */
6390 for (i = 0; next_action[i]; ++i) {
6391 const struct parse_action_priv *priv;
6393 token = &token_list[next_action[i]];
6394 if (strcmp_partial(token->name, str, len))
6400 memcpy((uint8_t *)ctx->object + arg->offset,
6406 push_args(ctx, arg);
6410 /** Parse tokens for list command. */
6412 parse_list(struct context *ctx, const struct token *token,
6413 const char *str, unsigned int len,
6414 void *buf, unsigned int size)
6416 struct buffer *out = buf;
6418 /* Token name must match. */
6419 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6421 /* Nothing else to do if there is no buffer. */
6424 if (!out->command) {
6425 if (ctx->curr != LIST)
6427 if (sizeof(*out) > size)
6429 out->command = ctx->curr;
6432 ctx->objmask = NULL;
6433 out->args.list.group =
6434 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6438 if (((uint8_t *)(out->args.list.group + out->args.list.group_n) +
6439 sizeof(*out->args.list.group)) > (uint8_t *)out + size)
6442 ctx->object = out->args.list.group + out->args.list.group_n++;
6443 ctx->objmask = NULL;
6447 /** Parse tokens for list all aged flows command. */
6449 parse_aged(struct context *ctx, const struct token *token,
6450 const char *str, unsigned int len,
6451 void *buf, unsigned int size)
6453 struct buffer *out = buf;
6455 /* Token name must match. */
6456 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6458 /* Nothing else to do if there is no buffer. */
6461 if (!out->command) {
6462 if (ctx->curr != AGED)
6464 if (sizeof(*out) > size)
6466 out->command = ctx->curr;
6469 ctx->objmask = NULL;
6471 if (ctx->curr == AGED_DESTROY)
6472 out->args.aged.destroy = 1;
6476 /** Parse tokens for isolate command. */
6478 parse_isolate(struct context *ctx, const struct token *token,
6479 const char *str, unsigned int len,
6480 void *buf, unsigned int size)
6482 struct buffer *out = buf;
6484 /* Token name must match. */
6485 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6487 /* Nothing else to do if there is no buffer. */
6490 if (!out->command) {
6491 if (ctx->curr != ISOLATE)
6493 if (sizeof(*out) > size)
6495 out->command = ctx->curr;
6498 ctx->objmask = NULL;
6504 parse_tunnel(struct context *ctx, const struct token *token,
6505 const char *str, unsigned int len,
6506 void *buf, unsigned int size)
6508 struct buffer *out = buf;
6510 /* Token name must match. */
6511 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6513 /* Nothing else to do if there is no buffer. */
6516 if (!out->command) {
6517 if (ctx->curr != TUNNEL)
6519 if (sizeof(*out) > size)
6521 out->command = ctx->curr;
6524 ctx->objmask = NULL;
6526 switch (ctx->curr) {
6530 case TUNNEL_DESTROY:
6532 out->command = ctx->curr;
6534 case TUNNEL_CREATE_TYPE:
6535 case TUNNEL_DESTROY_ID:
6536 ctx->object = &out->args.vc.tunnel_ops;
6545 * Parse signed/unsigned integers 8 to 64-bit long.
6547 * Last argument (ctx->args) is retrieved to determine integer type and
6551 parse_int(struct context *ctx, const struct token *token,
6552 const char *str, unsigned int len,
6553 void *buf, unsigned int size)
6555 const struct arg *arg = pop_args(ctx);
6560 /* Argument is expected. */
6565 (uintmax_t)strtoimax(str, &end, 0) :
6566 strtoumax(str, &end, 0);
6567 if (errno || (size_t)(end - str) != len)
6570 ((arg->sign && ((intmax_t)u < (intmax_t)arg->min ||
6571 (intmax_t)u > (intmax_t)arg->max)) ||
6572 (!arg->sign && (u < arg->min || u > arg->max))))
6577 if (!arg_entry_bf_fill(ctx->object, u, arg) ||
6578 !arg_entry_bf_fill(ctx->objmask, -1, arg))
6582 buf = (uint8_t *)ctx->object + arg->offset;
6584 if (u > RTE_LEN2MASK(size * CHAR_BIT, uint64_t))
6588 case sizeof(uint8_t):
6589 *(uint8_t *)buf = u;
6591 case sizeof(uint16_t):
6592 *(uint16_t *)buf = arg->hton ? rte_cpu_to_be_16(u) : u;
6594 case sizeof(uint8_t [3]):
6595 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
6597 ((uint8_t *)buf)[0] = u;
6598 ((uint8_t *)buf)[1] = u >> 8;
6599 ((uint8_t *)buf)[2] = u >> 16;
6603 ((uint8_t *)buf)[0] = u >> 16;
6604 ((uint8_t *)buf)[1] = u >> 8;
6605 ((uint8_t *)buf)[2] = u;
6607 case sizeof(uint32_t):
6608 *(uint32_t *)buf = arg->hton ? rte_cpu_to_be_32(u) : u;
6610 case sizeof(uint64_t):
6611 *(uint64_t *)buf = arg->hton ? rte_cpu_to_be_64(u) : u;
6616 if (ctx->objmask && buf != (uint8_t *)ctx->objmask + arg->offset) {
6618 buf = (uint8_t *)ctx->objmask + arg->offset;
6623 push_args(ctx, arg);
6630 * Three arguments (ctx->args) are retrieved from the stack to store data,
6631 * its actual length and address (in that order).
6634 parse_string(struct context *ctx, const struct token *token,
6635 const char *str, unsigned int len,
6636 void *buf, unsigned int size)
6638 const struct arg *arg_data = pop_args(ctx);
6639 const struct arg *arg_len = pop_args(ctx);
6640 const struct arg *arg_addr = pop_args(ctx);
6641 char tmp[16]; /* Ought to be enough. */
6644 /* Arguments are expected. */
6648 push_args(ctx, arg_data);
6652 push_args(ctx, arg_len);
6653 push_args(ctx, arg_data);
6656 size = arg_data->size;
6657 /* Bit-mask fill is not supported. */
6658 if (arg_data->mask || size < len)
6662 /* Let parse_int() fill length information first. */
6663 ret = snprintf(tmp, sizeof(tmp), "%u", len);
6666 push_args(ctx, arg_len);
6667 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
6672 buf = (uint8_t *)ctx->object + arg_data->offset;
6673 /* Output buffer is not necessarily NUL-terminated. */
6674 memcpy(buf, str, len);
6675 memset((uint8_t *)buf + len, 0x00, size - len);
6677 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
6678 /* Save address if requested. */
6679 if (arg_addr->size) {
6680 memcpy((uint8_t *)ctx->object + arg_addr->offset,
6682 (uint8_t *)ctx->object + arg_data->offset
6686 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
6688 (uint8_t *)ctx->objmask + arg_data->offset
6694 push_args(ctx, arg_addr);
6695 push_args(ctx, arg_len);
6696 push_args(ctx, arg_data);
6701 parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
6707 /* Check input parameters */
6708 if ((src == NULL) ||
6714 /* Convert chars to bytes */
6715 for (i = 0, len = 0; i < *size; i += 2) {
6716 snprintf(tmp, 3, "%s", src + i);
6717 dst[len++] = strtoul(tmp, &c, 16);
6732 parse_hex(struct context *ctx, const struct token *token,
6733 const char *str, unsigned int len,
6734 void *buf, unsigned int size)
6736 const struct arg *arg_data = pop_args(ctx);
6737 const struct arg *arg_len = pop_args(ctx);
6738 const struct arg *arg_addr = pop_args(ctx);
6739 char tmp[16]; /* Ought to be enough. */
6741 unsigned int hexlen = len;
6742 unsigned int length = 256;
6743 uint8_t hex_tmp[length];
6745 /* Arguments are expected. */
6749 push_args(ctx, arg_data);
6753 push_args(ctx, arg_len);
6754 push_args(ctx, arg_data);
6757 size = arg_data->size;
6758 /* Bit-mask fill is not supported. */
6764 /* translate bytes string to array. */
6765 if (str[0] == '0' && ((str[1] == 'x') ||
6770 if (hexlen > length)
6772 ret = parse_hex_string(str, hex_tmp, &hexlen);
6775 /* Let parse_int() fill length information first. */
6776 ret = snprintf(tmp, sizeof(tmp), "%u", hexlen);
6779 /* Save length if requested. */
6780 if (arg_len->size) {
6781 push_args(ctx, arg_len);
6782 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
6788 buf = (uint8_t *)ctx->object + arg_data->offset;
6789 /* Output buffer is not necessarily NUL-terminated. */
6790 memcpy(buf, hex_tmp, hexlen);
6791 memset((uint8_t *)buf + hexlen, 0x00, size - hexlen);
6793 memset((uint8_t *)ctx->objmask + arg_data->offset,
6795 /* Save address if requested. */
6796 if (arg_addr->size) {
6797 memcpy((uint8_t *)ctx->object + arg_addr->offset,
6799 (uint8_t *)ctx->object + arg_data->offset
6803 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
6805 (uint8_t *)ctx->objmask + arg_data->offset
6811 push_args(ctx, arg_addr);
6812 push_args(ctx, arg_len);
6813 push_args(ctx, arg_data);
6819 * Parse a zero-ended string.
6822 parse_string0(struct context *ctx, const struct token *token __rte_unused,
6823 const char *str, unsigned int len,
6824 void *buf, unsigned int size)
6826 const struct arg *arg_data = pop_args(ctx);
6828 /* Arguments are expected. */
6831 size = arg_data->size;
6832 /* Bit-mask fill is not supported. */
6833 if (arg_data->mask || size < len + 1)
6837 buf = (uint8_t *)ctx->object + arg_data->offset;
6838 strncpy(buf, str, len);
6840 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
6843 push_args(ctx, arg_data);
6848 * Parse a MAC address.
6850 * Last argument (ctx->args) is retrieved to determine storage size and
6854 parse_mac_addr(struct context *ctx, const struct token *token,
6855 const char *str, unsigned int len,
6856 void *buf, unsigned int size)
6858 const struct arg *arg = pop_args(ctx);
6859 struct rte_ether_addr tmp;
6863 /* Argument is expected. */
6867 /* Bit-mask fill is not supported. */
6868 if (arg->mask || size != sizeof(tmp))
6870 /* Only network endian is supported. */
6873 ret = cmdline_parse_etheraddr(NULL, str, &tmp, size);
6874 if (ret < 0 || (unsigned int)ret != len)
6878 buf = (uint8_t *)ctx->object + arg->offset;
6879 memcpy(buf, &tmp, size);
6881 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6884 push_args(ctx, arg);
6889 * Parse an IPv4 address.
6891 * Last argument (ctx->args) is retrieved to determine storage size and
6895 parse_ipv4_addr(struct context *ctx, const struct token *token,
6896 const char *str, unsigned int len,
6897 void *buf, unsigned int size)
6899 const struct arg *arg = pop_args(ctx);
6904 /* Argument is expected. */
6908 /* Bit-mask fill is not supported. */
6909 if (arg->mask || size != sizeof(tmp))
6911 /* Only network endian is supported. */
6914 memcpy(str2, str, len);
6916 ret = inet_pton(AF_INET, str2, &tmp);
6918 /* Attempt integer parsing. */
6919 push_args(ctx, arg);
6920 return parse_int(ctx, token, str, len, buf, size);
6924 buf = (uint8_t *)ctx->object + arg->offset;
6925 memcpy(buf, &tmp, size);
6927 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6930 push_args(ctx, arg);
6935 * Parse an IPv6 address.
6937 * Last argument (ctx->args) is retrieved to determine storage size and
6941 parse_ipv6_addr(struct context *ctx, const struct token *token,
6942 const char *str, unsigned int len,
6943 void *buf, unsigned int size)
6945 const struct arg *arg = pop_args(ctx);
6947 struct in6_addr tmp;
6951 /* Argument is expected. */
6955 /* Bit-mask fill is not supported. */
6956 if (arg->mask || size != sizeof(tmp))
6958 /* Only network endian is supported. */
6961 memcpy(str2, str, len);
6963 ret = inet_pton(AF_INET6, str2, &tmp);
6968 buf = (uint8_t *)ctx->object + arg->offset;
6969 memcpy(buf, &tmp, size);
6971 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6974 push_args(ctx, arg);
6978 /** Boolean values (even indices stand for false). */
6979 static const char *const boolean_name[] = {
6989 * Parse a boolean value.
6991 * Last argument (ctx->args) is retrieved to determine storage size and
6995 parse_boolean(struct context *ctx, const struct token *token,
6996 const char *str, unsigned int len,
6997 void *buf, unsigned int size)
6999 const struct arg *arg = pop_args(ctx);
7003 /* Argument is expected. */
7006 for (i = 0; boolean_name[i]; ++i)
7007 if (!strcmp_partial(boolean_name[i], str, len))
7009 /* Process token as integer. */
7010 if (boolean_name[i])
7011 str = i & 1 ? "1" : "0";
7012 push_args(ctx, arg);
7013 ret = parse_int(ctx, token, str, strlen(str), buf, size);
7014 return ret > 0 ? (int)len : ret;
7017 /** Parse port and update context. */
7019 parse_port(struct context *ctx, const struct token *token,
7020 const char *str, unsigned int len,
7021 void *buf, unsigned int size)
7023 struct buffer *out = &(struct buffer){ .port = 0 };
7031 ctx->objmask = NULL;
7032 size = sizeof(*out);
7034 ret = parse_int(ctx, token, str, len, out, size);
7036 ctx->port = out->port;
7043 parse_sa_id2ptr(struct context *ctx, const struct token *token,
7044 const char *str, unsigned int len,
7045 void *buf, unsigned int size)
7047 struct rte_flow_action *action = ctx->object;
7055 ctx->objmask = NULL;
7056 ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
7057 ctx->object = action;
7058 if (ret != (int)len)
7060 /* set shared action */
7062 action->conf = port_shared_action_get_by_id(ctx->port, id);
7063 ret = (action->conf) ? ret : -1;
7068 /** Parse set command, initialize output buffer for subsequent tokens. */
7070 parse_set_raw_encap_decap(struct context *ctx, const struct token *token,
7071 const char *str, unsigned int len,
7072 void *buf, unsigned int size)
7074 struct buffer *out = buf;
7076 /* Token name must match. */
7077 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7079 /* Nothing else to do if there is no buffer. */
7082 /* Make sure buffer is large enough. */
7083 if (size < sizeof(*out))
7086 ctx->objmask = NULL;
7090 out->command = ctx->curr;
7091 /* For encap/decap we need is pattern */
7092 out->args.vc.pattern = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7097 /** Parse set command, initialize output buffer for subsequent tokens. */
7099 parse_set_sample_action(struct context *ctx, const struct token *token,
7100 const char *str, unsigned int len,
7101 void *buf, unsigned int size)
7103 struct buffer *out = buf;
7105 /* Token name must match. */
7106 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7108 /* Nothing else to do if there is no buffer. */
7111 /* Make sure buffer is large enough. */
7112 if (size < sizeof(*out))
7115 ctx->objmask = NULL;
7119 out->command = ctx->curr;
7120 /* For sampler we need is actions */
7121 out->args.vc.actions = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7127 * Parse set raw_encap/raw_decap command,
7128 * initialize output buffer for subsequent tokens.
7131 parse_set_init(struct context *ctx, const struct token *token,
7132 const char *str, unsigned int len,
7133 void *buf, unsigned int size)
7135 struct buffer *out = buf;
7137 /* Token name must match. */
7138 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
7140 /* Nothing else to do if there is no buffer. */
7143 /* Make sure buffer is large enough. */
7144 if (size < sizeof(*out))
7146 /* Initialize buffer. */
7147 memset(out, 0x00, sizeof(*out));
7148 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
7151 ctx->objmask = NULL;
7152 if (!out->command) {
7153 if (ctx->curr != SET)
7155 if (sizeof(*out) > size)
7157 out->command = ctx->curr;
7158 out->args.vc.data = (uint8_t *)out + size;
7159 ctx->object = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
7165 /** No completion. */
7167 comp_none(struct context *ctx, const struct token *token,
7168 unsigned int ent, char *buf, unsigned int size)
7178 /** Complete boolean values. */
7180 comp_boolean(struct context *ctx, const struct token *token,
7181 unsigned int ent, char *buf, unsigned int size)
7187 for (i = 0; boolean_name[i]; ++i)
7188 if (buf && i == ent)
7189 return strlcpy(buf, boolean_name[i], size);
7195 /** Complete action names. */
7197 comp_action(struct context *ctx, const struct token *token,
7198 unsigned int ent, char *buf, unsigned int size)
7204 for (i = 0; next_action[i]; ++i)
7205 if (buf && i == ent)
7206 return strlcpy(buf, token_list[next_action[i]].name,
7213 /** Complete available ports. */
7215 comp_port(struct context *ctx, const struct token *token,
7216 unsigned int ent, char *buf, unsigned int size)
7223 RTE_ETH_FOREACH_DEV(p) {
7224 if (buf && i == ent)
7225 return snprintf(buf, size, "%u", p);
7233 /** Complete available rule IDs. */
7235 comp_rule_id(struct context *ctx, const struct token *token,
7236 unsigned int ent, char *buf, unsigned int size)
7239 struct rte_port *port;
7240 struct port_flow *pf;
7243 if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
7244 ctx->port == (portid_t)RTE_PORT_ALL)
7246 port = &ports[ctx->port];
7247 for (pf = port->flow_list; pf != NULL; pf = pf->next) {
7248 if (buf && i == ent)
7249 return snprintf(buf, size, "%u", pf->id);
7257 /** Complete type field for RSS action. */
7259 comp_vc_action_rss_type(struct context *ctx, const struct token *token,
7260 unsigned int ent, char *buf, unsigned int size)
7266 for (i = 0; rss_type_table[i].str; ++i)
7271 return strlcpy(buf, rss_type_table[ent].str, size);
7273 return snprintf(buf, size, "end");
7277 /** Complete queue field for RSS action. */
7279 comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
7280 unsigned int ent, char *buf, unsigned int size)
7287 return snprintf(buf, size, "%u", ent);
7289 return snprintf(buf, size, "end");
7293 /** Complete index number for set raw_encap/raw_decap commands. */
7295 comp_set_raw_index(struct context *ctx, const struct token *token,
7296 unsigned int ent, char *buf, unsigned int size)
7302 RTE_SET_USED(token);
7303 for (idx = 0; idx < RAW_ENCAP_CONFS_MAX_NUM; ++idx) {
7304 if (buf && idx == ent)
7305 return snprintf(buf, size, "%u", idx);
7311 /** Complete index number for set raw_encap/raw_decap commands. */
7313 comp_set_sample_index(struct context *ctx, const struct token *token,
7314 unsigned int ent, char *buf, unsigned int size)
7320 RTE_SET_USED(token);
7321 for (idx = 0; idx < RAW_SAMPLE_CONFS_MAX_NUM; ++idx) {
7322 if (buf && idx == ent)
7323 return snprintf(buf, size, "%u", idx);
7329 /** Complete operation for modify_field command. */
7331 comp_set_modify_field_op(struct context *ctx, const struct token *token,
7332 unsigned int ent, char *buf, unsigned int size)
7337 RTE_SET_USED(token);
7338 for (idx = 0; modify_field_ops[idx]; ++idx)
7343 return strlcpy(buf, modify_field_ops[ent], size);
7347 /** Complete field id for modify_field command. */
7349 comp_set_modify_field_id(struct context *ctx, const struct token *token,
7350 unsigned int ent, char *buf, unsigned int size)
7355 RTE_SET_USED(token);
7356 for (idx = 0; modify_field_ids[idx]; ++idx)
7361 return strlcpy(buf, modify_field_ids[ent], size);
7365 /** Internal context. */
7366 static struct context cmd_flow_context;
7368 /** Global parser instance (cmdline API). */
7369 cmdline_parse_inst_t cmd_flow;
7370 cmdline_parse_inst_t cmd_set_raw;
7372 /** Initialize context. */
7374 cmd_flow_context_init(struct context *ctx)
7376 /* A full memset() is not necessary. */
7386 ctx->objmask = NULL;
7389 /** Parse a token (cmdline API). */
7391 cmd_flow_parse(cmdline_parse_token_hdr_t *hdr, const char *src, void *result,
7394 struct context *ctx = &cmd_flow_context;
7395 const struct token *token;
7396 const enum index *list;
7401 token = &token_list[ctx->curr];
7402 /* Check argument length. */
7405 for (len = 0; src[len]; ++len)
7406 if (src[len] == '#' || isspace(src[len]))
7410 /* Last argument and EOL detection. */
7411 for (i = len; src[i]; ++i)
7412 if (src[i] == '#' || src[i] == '\r' || src[i] == '\n')
7414 else if (!isspace(src[i])) {
7419 if (src[i] == '\r' || src[i] == '\n') {
7423 /* Initialize context if necessary. */
7424 if (!ctx->next_num) {
7427 ctx->next[ctx->next_num++] = token->next[0];
7429 /* Process argument through candidates. */
7430 ctx->prev = ctx->curr;
7431 list = ctx->next[ctx->next_num - 1];
7432 for (i = 0; list[i]; ++i) {
7433 const struct token *next = &token_list[list[i]];
7436 ctx->curr = list[i];
7438 tmp = next->call(ctx, next, src, len, result, size);
7440 tmp = parse_default(ctx, next, src, len, result, size);
7441 if (tmp == -1 || tmp != len)
7449 /* Push subsequent tokens if any. */
7451 for (i = 0; token->next[i]; ++i) {
7452 if (ctx->next_num == RTE_DIM(ctx->next))
7454 ctx->next[ctx->next_num++] = token->next[i];
7456 /* Push arguments if any. */
7458 for (i = 0; token->args[i]; ++i) {
7459 if (ctx->args_num == RTE_DIM(ctx->args))
7461 ctx->args[ctx->args_num++] = token->args[i];
7466 /** Return number of completion entries (cmdline API). */
7468 cmd_flow_complete_get_nb(cmdline_parse_token_hdr_t *hdr)
7470 struct context *ctx = &cmd_flow_context;
7471 const struct token *token = &token_list[ctx->curr];
7472 const enum index *list;
7476 /* Count number of tokens in current list. */
7478 list = ctx->next[ctx->next_num - 1];
7480 list = token->next[0];
7481 for (i = 0; list[i]; ++i)
7486 * If there is a single token, use its completion callback, otherwise
7487 * return the number of entries.
7489 token = &token_list[list[0]];
7490 if (i == 1 && token->comp) {
7491 /* Save index for cmd_flow_get_help(). */
7492 ctx->prev = list[0];
7493 return token->comp(ctx, token, 0, NULL, 0);
7498 /** Return a completion entry (cmdline API). */
7500 cmd_flow_complete_get_elt(cmdline_parse_token_hdr_t *hdr, int index,
7501 char *dst, unsigned int size)
7503 struct context *ctx = &cmd_flow_context;
7504 const struct token *token = &token_list[ctx->curr];
7505 const enum index *list;
7509 /* Count number of tokens in current list. */
7511 list = ctx->next[ctx->next_num - 1];
7513 list = token->next[0];
7514 for (i = 0; list[i]; ++i)
7518 /* If there is a single token, use its completion callback. */
7519 token = &token_list[list[0]];
7520 if (i == 1 && token->comp) {
7521 /* Save index for cmd_flow_get_help(). */
7522 ctx->prev = list[0];
7523 return token->comp(ctx, token, index, dst, size) < 0 ? -1 : 0;
7525 /* Otherwise make sure the index is valid and use defaults. */
7528 token = &token_list[list[index]];
7529 strlcpy(dst, token->name, size);
7530 /* Save index for cmd_flow_get_help(). */
7531 ctx->prev = list[index];
7535 /** Populate help strings for current token (cmdline API). */
7537 cmd_flow_get_help(cmdline_parse_token_hdr_t *hdr, char *dst, unsigned int size)
7539 struct context *ctx = &cmd_flow_context;
7540 const struct token *token = &token_list[ctx->prev];
7545 /* Set token type and update global help with details. */
7546 strlcpy(dst, (token->type ? token->type : "TOKEN"), size);
7548 cmd_flow.help_str = token->help;
7550 cmd_flow.help_str = token->name;
7554 /** Token definition template (cmdline API). */
7555 static struct cmdline_token_hdr cmd_flow_token_hdr = {
7556 .ops = &(struct cmdline_token_ops){
7557 .parse = cmd_flow_parse,
7558 .complete_get_nb = cmd_flow_complete_get_nb,
7559 .complete_get_elt = cmd_flow_complete_get_elt,
7560 .get_help = cmd_flow_get_help,
7565 /** Populate the next dynamic token. */
7567 cmd_flow_tok(cmdline_parse_token_hdr_t **hdr,
7568 cmdline_parse_token_hdr_t **hdr_inst)
7570 struct context *ctx = &cmd_flow_context;
7572 /* Always reinitialize context before requesting the first token. */
7573 if (!(hdr_inst - cmd_flow.tokens))
7574 cmd_flow_context_init(ctx);
7575 /* Return NULL when no more tokens are expected. */
7576 if (!ctx->next_num && ctx->curr) {
7580 /* Determine if command should end here. */
7581 if (ctx->eol && ctx->last && ctx->next_num) {
7582 const enum index *list = ctx->next[ctx->next_num - 1];
7585 for (i = 0; list[i]; ++i) {
7592 *hdr = &cmd_flow_token_hdr;
7595 /** Dispatch parsed buffer to function calls. */
7597 cmd_flow_parsed(const struct buffer *in)
7599 switch (in->command) {
7600 case SHARED_ACTION_CREATE:
7601 port_shared_action_create(
7602 in->port, in->args.vc.attr.group,
7603 &((const struct rte_flow_shared_action_conf) {
7604 .ingress = in->args.vc.attr.ingress,
7605 .egress = in->args.vc.attr.egress,
7606 .transfer = in->args.vc.attr.transfer,
7608 in->args.vc.actions);
7610 case SHARED_ACTION_DESTROY:
7611 port_shared_action_destroy(in->port,
7612 in->args.sa_destroy.action_id_n,
7613 in->args.sa_destroy.action_id);
7615 case SHARED_ACTION_UPDATE:
7616 port_shared_action_update(in->port, in->args.vc.attr.group,
7617 in->args.vc.actions);
7619 case SHARED_ACTION_QUERY:
7620 port_shared_action_query(in->port, in->args.sa.action_id);
7623 port_flow_validate(in->port, &in->args.vc.attr,
7624 in->args.vc.pattern, in->args.vc.actions,
7625 &in->args.vc.tunnel_ops);
7628 port_flow_create(in->port, &in->args.vc.attr,
7629 in->args.vc.pattern, in->args.vc.actions,
7630 &in->args.vc.tunnel_ops);
7633 port_flow_destroy(in->port, in->args.destroy.rule_n,
7634 in->args.destroy.rule);
7637 port_flow_flush(in->port);
7640 port_flow_dump(in->port, in->args.dump.file);
7643 port_flow_query(in->port, in->args.query.rule,
7644 &in->args.query.action);
7647 port_flow_list(in->port, in->args.list.group_n,
7648 in->args.list.group);
7651 port_flow_isolate(in->port, in->args.isolate.set);
7654 port_flow_aged(in->port, in->args.aged.destroy);
7657 port_flow_tunnel_create(in->port, &in->args.vc.tunnel_ops);
7659 case TUNNEL_DESTROY:
7660 port_flow_tunnel_destroy(in->port, in->args.vc.tunnel_ops.id);
7663 port_flow_tunnel_list(in->port);
7670 /** Token generator and output processing callback (cmdline API). */
7672 cmd_flow_cb(void *arg0, struct cmdline *cl, void *arg2)
7675 cmd_flow_tok(arg0, arg2);
7677 cmd_flow_parsed(arg0);
7680 /** Global parser instance (cmdline API). */
7681 cmdline_parse_inst_t cmd_flow = {
7683 .data = NULL, /**< Unused. */
7684 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
7687 }, /**< Tokens are returned by cmd_flow_tok(). */
7690 /** set cmd facility. Reuse cmd flow's infrastructure as much as possible. */
7693 update_fields(uint8_t *buf, struct rte_flow_item *item, uint16_t next_proto)
7695 struct rte_ipv4_hdr *ipv4;
7696 struct rte_ether_hdr *eth;
7697 struct rte_ipv6_hdr *ipv6;
7698 struct rte_vxlan_hdr *vxlan;
7699 struct rte_vxlan_gpe_hdr *gpe;
7700 struct rte_flow_item_nvgre *nvgre;
7701 uint32_t ipv6_vtc_flow;
7703 switch (item->type) {
7704 case RTE_FLOW_ITEM_TYPE_ETH:
7705 eth = (struct rte_ether_hdr *)buf;
7707 eth->ether_type = rte_cpu_to_be_16(next_proto);
7709 case RTE_FLOW_ITEM_TYPE_IPV4:
7710 ipv4 = (struct rte_ipv4_hdr *)buf;
7711 ipv4->version_ihl = 0x45;
7712 if (next_proto && ipv4->next_proto_id == 0)
7713 ipv4->next_proto_id = (uint8_t)next_proto;
7715 case RTE_FLOW_ITEM_TYPE_IPV6:
7716 ipv6 = (struct rte_ipv6_hdr *)buf;
7717 if (next_proto && ipv6->proto == 0)
7718 ipv6->proto = (uint8_t)next_proto;
7719 ipv6_vtc_flow = rte_be_to_cpu_32(ipv6->vtc_flow);
7720 ipv6_vtc_flow &= 0x0FFFFFFF; /*< reset version bits. */
7721 ipv6_vtc_flow |= 0x60000000; /*< set ipv6 version. */
7722 ipv6->vtc_flow = rte_cpu_to_be_32(ipv6_vtc_flow);
7724 case RTE_FLOW_ITEM_TYPE_VXLAN:
7725 vxlan = (struct rte_vxlan_hdr *)buf;
7726 vxlan->vx_flags = 0x08;
7728 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
7729 gpe = (struct rte_vxlan_gpe_hdr *)buf;
7730 gpe->vx_flags = 0x0C;
7732 case RTE_FLOW_ITEM_TYPE_NVGRE:
7733 nvgre = (struct rte_flow_item_nvgre *)buf;
7734 nvgre->protocol = rte_cpu_to_be_16(0x6558);
7735 nvgre->c_k_s_rsvd0_ver = rte_cpu_to_be_16(0x2000);
7742 /** Helper of get item's default mask. */
7744 flow_item_default_mask(const struct rte_flow_item *item)
7746 const void *mask = NULL;
7747 static rte_be32_t gre_key_default_mask = RTE_BE32(UINT32_MAX);
7749 switch (item->type) {
7750 case RTE_FLOW_ITEM_TYPE_ANY:
7751 mask = &rte_flow_item_any_mask;
7753 case RTE_FLOW_ITEM_TYPE_VF:
7754 mask = &rte_flow_item_vf_mask;
7756 case RTE_FLOW_ITEM_TYPE_PORT_ID:
7757 mask = &rte_flow_item_port_id_mask;
7759 case RTE_FLOW_ITEM_TYPE_RAW:
7760 mask = &rte_flow_item_raw_mask;
7762 case RTE_FLOW_ITEM_TYPE_ETH:
7763 mask = &rte_flow_item_eth_mask;
7765 case RTE_FLOW_ITEM_TYPE_VLAN:
7766 mask = &rte_flow_item_vlan_mask;
7768 case RTE_FLOW_ITEM_TYPE_IPV4:
7769 mask = &rte_flow_item_ipv4_mask;
7771 case RTE_FLOW_ITEM_TYPE_IPV6:
7772 mask = &rte_flow_item_ipv6_mask;
7774 case RTE_FLOW_ITEM_TYPE_ICMP:
7775 mask = &rte_flow_item_icmp_mask;
7777 case RTE_FLOW_ITEM_TYPE_UDP:
7778 mask = &rte_flow_item_udp_mask;
7780 case RTE_FLOW_ITEM_TYPE_TCP:
7781 mask = &rte_flow_item_tcp_mask;
7783 case RTE_FLOW_ITEM_TYPE_SCTP:
7784 mask = &rte_flow_item_sctp_mask;
7786 case RTE_FLOW_ITEM_TYPE_VXLAN:
7787 mask = &rte_flow_item_vxlan_mask;
7789 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
7790 mask = &rte_flow_item_vxlan_gpe_mask;
7792 case RTE_FLOW_ITEM_TYPE_E_TAG:
7793 mask = &rte_flow_item_e_tag_mask;
7795 case RTE_FLOW_ITEM_TYPE_NVGRE:
7796 mask = &rte_flow_item_nvgre_mask;
7798 case RTE_FLOW_ITEM_TYPE_MPLS:
7799 mask = &rte_flow_item_mpls_mask;
7801 case RTE_FLOW_ITEM_TYPE_GRE:
7802 mask = &rte_flow_item_gre_mask;
7804 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
7805 mask = &gre_key_default_mask;
7807 case RTE_FLOW_ITEM_TYPE_META:
7808 mask = &rte_flow_item_meta_mask;
7810 case RTE_FLOW_ITEM_TYPE_FUZZY:
7811 mask = &rte_flow_item_fuzzy_mask;
7813 case RTE_FLOW_ITEM_TYPE_GTP:
7814 mask = &rte_flow_item_gtp_mask;
7816 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
7817 mask = &rte_flow_item_gtp_psc_mask;
7819 case RTE_FLOW_ITEM_TYPE_GENEVE:
7820 mask = &rte_flow_item_geneve_mask;
7822 case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
7823 mask = &rte_flow_item_geneve_opt_mask;
7825 case RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID:
7826 mask = &rte_flow_item_pppoe_proto_id_mask;
7828 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
7829 mask = &rte_flow_item_l2tpv3oip_mask;
7831 case RTE_FLOW_ITEM_TYPE_ESP:
7832 mask = &rte_flow_item_esp_mask;
7834 case RTE_FLOW_ITEM_TYPE_AH:
7835 mask = &rte_flow_item_ah_mask;
7837 case RTE_FLOW_ITEM_TYPE_PFCP:
7838 mask = &rte_flow_item_pfcp_mask;
7846 /** Dispatch parsed buffer to function calls. */
7848 cmd_set_raw_parsed_sample(const struct buffer *in)
7850 uint32_t n = in->args.vc.actions_n;
7852 struct rte_flow_action *action = NULL;
7853 struct rte_flow_action *data = NULL;
7854 const struct rte_flow_action_rss *rss = NULL;
7856 uint16_t idx = in->port; /* We borrow port field as index */
7857 uint32_t max_size = sizeof(struct rte_flow_action) *
7858 ACTION_SAMPLE_ACTIONS_NUM;
7860 RTE_ASSERT(in->command == SET_SAMPLE_ACTIONS);
7861 data = (struct rte_flow_action *)&raw_sample_confs[idx].data;
7862 memset(data, 0x00, max_size);
7863 for (; i <= n - 1; i++) {
7864 action = in->args.vc.actions + i;
7865 if (action->type == RTE_FLOW_ACTION_TYPE_END)
7867 switch (action->type) {
7868 case RTE_FLOW_ACTION_TYPE_MARK:
7869 size = sizeof(struct rte_flow_action_mark);
7870 rte_memcpy(&sample_mark[idx],
7871 (const void *)action->conf, size);
7872 action->conf = &sample_mark[idx];
7874 case RTE_FLOW_ACTION_TYPE_COUNT:
7875 size = sizeof(struct rte_flow_action_count);
7876 rte_memcpy(&sample_count[idx],
7877 (const void *)action->conf, size);
7878 action->conf = &sample_count[idx];
7880 case RTE_FLOW_ACTION_TYPE_QUEUE:
7881 size = sizeof(struct rte_flow_action_queue);
7882 rte_memcpy(&sample_queue[idx],
7883 (const void *)action->conf, size);
7884 action->conf = &sample_queue[idx];
7886 case RTE_FLOW_ACTION_TYPE_RSS:
7887 size = sizeof(struct rte_flow_action_rss);
7889 rte_memcpy(&sample_rss_data[idx].conf,
7890 (const void *)rss, size);
7892 sample_rss_data[idx].conf.key =
7893 sample_rss_data[idx].key;
7894 rte_memcpy((void *)((uintptr_t)
7895 sample_rss_data[idx].conf.key),
7896 (const void *)rss->key,
7897 sizeof(uint8_t) * rss->key_len);
7899 if (rss->queue_num) {
7900 sample_rss_data[idx].conf.queue =
7901 sample_rss_data[idx].queue;
7902 rte_memcpy((void *)((uintptr_t)
7903 sample_rss_data[idx].conf.queue),
7904 (const void *)rss->queue,
7905 sizeof(uint16_t) * rss->queue_num);
7907 action->conf = &sample_rss_data[idx].conf;
7909 case RTE_FLOW_ACTION_TYPE_RAW_ENCAP:
7910 size = sizeof(struct rte_flow_action_raw_encap);
7911 rte_memcpy(&sample_encap[idx],
7912 (const void *)action->conf, size);
7913 action->conf = &sample_encap[idx];
7915 case RTE_FLOW_ACTION_TYPE_PORT_ID:
7916 size = sizeof(struct rte_flow_action_port_id);
7917 rte_memcpy(&sample_port_id[idx],
7918 (const void *)action->conf, size);
7919 action->conf = &sample_port_id[idx];
7922 printf("Error - Not supported action\n");
7925 rte_memcpy(data, action, sizeof(struct rte_flow_action));
7930 /** Dispatch parsed buffer to function calls. */
7932 cmd_set_raw_parsed(const struct buffer *in)
7934 uint32_t n = in->args.vc.pattern_n;
7936 struct rte_flow_item *item = NULL;
7938 uint8_t *data = NULL;
7939 uint8_t *data_tail = NULL;
7940 size_t *total_size = NULL;
7941 uint16_t upper_layer = 0;
7943 uint16_t idx = in->port; /* We borrow port field as index */
7944 int gtp_psc = -1; /* GTP PSC option index. */
7946 if (in->command == SET_SAMPLE_ACTIONS)
7947 return cmd_set_raw_parsed_sample(in);
7948 RTE_ASSERT(in->command == SET_RAW_ENCAP ||
7949 in->command == SET_RAW_DECAP);
7950 if (in->command == SET_RAW_ENCAP) {
7951 total_size = &raw_encap_confs[idx].size;
7952 data = (uint8_t *)&raw_encap_confs[idx].data;
7954 total_size = &raw_decap_confs[idx].size;
7955 data = (uint8_t *)&raw_decap_confs[idx].data;
7958 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
7959 /* process hdr from upper layer to low layer (L3/L4 -> L2). */
7960 data_tail = data + ACTION_RAW_ENCAP_MAX_DATA;
7961 for (i = n - 1 ; i >= 0; --i) {
7962 const struct rte_flow_item_gtp *gtp;
7963 const struct rte_flow_item_geneve_opt *opt;
7965 item = in->args.vc.pattern + i;
7966 if (item->spec == NULL)
7967 item->spec = flow_item_default_mask(item);
7968 switch (item->type) {
7969 case RTE_FLOW_ITEM_TYPE_ETH:
7970 size = sizeof(struct rte_ether_hdr);
7972 case RTE_FLOW_ITEM_TYPE_VLAN:
7973 size = sizeof(struct rte_vlan_hdr);
7974 proto = RTE_ETHER_TYPE_VLAN;
7976 case RTE_FLOW_ITEM_TYPE_IPV4:
7977 size = sizeof(struct rte_ipv4_hdr);
7978 proto = RTE_ETHER_TYPE_IPV4;
7980 case RTE_FLOW_ITEM_TYPE_IPV6:
7981 size = sizeof(struct rte_ipv6_hdr);
7982 proto = RTE_ETHER_TYPE_IPV6;
7984 case RTE_FLOW_ITEM_TYPE_UDP:
7985 size = sizeof(struct rte_udp_hdr);
7988 case RTE_FLOW_ITEM_TYPE_TCP:
7989 size = sizeof(struct rte_tcp_hdr);
7992 case RTE_FLOW_ITEM_TYPE_VXLAN:
7993 size = sizeof(struct rte_vxlan_hdr);
7995 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
7996 size = sizeof(struct rte_vxlan_gpe_hdr);
7998 case RTE_FLOW_ITEM_TYPE_GRE:
7999 size = sizeof(struct rte_gre_hdr);
8002 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
8003 size = sizeof(rte_be32_t);
8006 case RTE_FLOW_ITEM_TYPE_MPLS:
8007 size = sizeof(struct rte_mpls_hdr);
8010 case RTE_FLOW_ITEM_TYPE_NVGRE:
8011 size = sizeof(struct rte_flow_item_nvgre);
8014 case RTE_FLOW_ITEM_TYPE_GENEVE:
8015 size = sizeof(struct rte_geneve_hdr);
8017 case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
8018 opt = (const struct rte_flow_item_geneve_opt *)
8020 size = offsetof(struct rte_flow_item_geneve_opt, data);
8021 if (opt->option_len && opt->data) {
8022 *total_size += opt->option_len *
8024 rte_memcpy(data_tail - (*total_size),
8026 opt->option_len * sizeof(uint32_t));
8029 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
8030 size = sizeof(rte_be32_t);
8033 case RTE_FLOW_ITEM_TYPE_ESP:
8034 size = sizeof(struct rte_esp_hdr);
8037 case RTE_FLOW_ITEM_TYPE_AH:
8038 size = sizeof(struct rte_flow_item_ah);
8041 case RTE_FLOW_ITEM_TYPE_GTP:
8043 size = sizeof(struct rte_gtp_hdr);
8046 if (gtp_psc != i + 1) {
8047 printf("Error - GTP PSC does not follow GTP\n");
8051 if ((gtp->v_pt_rsv_flags & 0x07) != 0x04) {
8052 /* Only E flag should be set. */
8053 printf("Error - GTP unsupported flags\n");
8056 struct rte_gtp_hdr_ext_word ext_word = {
8060 /* We have to add GTP header extra word. */
8061 *total_size += sizeof(ext_word);
8062 rte_memcpy(data_tail - (*total_size),
8063 &ext_word, sizeof(ext_word));
8065 size = sizeof(struct rte_gtp_hdr);
8067 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
8069 printf("Error - Multiple GTP PSC items\n");
8072 const struct rte_flow_item_gtp_psc
8081 if (opt->pdu_type & 0x0F) {
8082 /* Support the minimal option only. */
8083 printf("Error - GTP PSC option with "
8084 "extra fields not supported\n");
8087 psc.len = sizeof(psc);
8088 psc.pdu_type = opt->pdu_type;
8091 *total_size += sizeof(psc);
8092 rte_memcpy(data_tail - (*total_size),
8098 case RTE_FLOW_ITEM_TYPE_PFCP:
8099 size = sizeof(struct rte_flow_item_pfcp);
8102 printf("Error - Not supported item\n");
8105 *total_size += size;
8106 rte_memcpy(data_tail - (*total_size), item->spec, size);
8107 /* update some fields which cannot be set by cmdline */
8108 update_fields((data_tail - (*total_size)), item,
8110 upper_layer = proto;
8112 if (verbose_level & 0x1)
8113 printf("total data size is %zu\n", (*total_size));
8114 RTE_ASSERT((*total_size) <= ACTION_RAW_ENCAP_MAX_DATA);
8115 memmove(data, (data_tail - (*total_size)), *total_size);
8120 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
8123 /** Populate help strings for current token (cmdline API). */
8125 cmd_set_raw_get_help(cmdline_parse_token_hdr_t *hdr, char *dst,
8128 struct context *ctx = &cmd_flow_context;
8129 const struct token *token = &token_list[ctx->prev];
8134 /* Set token type and update global help with details. */
8135 snprintf(dst, size, "%s", (token->type ? token->type : "TOKEN"));
8137 cmd_set_raw.help_str = token->help;
8139 cmd_set_raw.help_str = token->name;
8143 /** Token definition template (cmdline API). */
8144 static struct cmdline_token_hdr cmd_set_raw_token_hdr = {
8145 .ops = &(struct cmdline_token_ops){
8146 .parse = cmd_flow_parse,
8147 .complete_get_nb = cmd_flow_complete_get_nb,
8148 .complete_get_elt = cmd_flow_complete_get_elt,
8149 .get_help = cmd_set_raw_get_help,
8154 /** Populate the next dynamic token. */
8156 cmd_set_raw_tok(cmdline_parse_token_hdr_t **hdr,
8157 cmdline_parse_token_hdr_t **hdr_inst)
8159 struct context *ctx = &cmd_flow_context;
8161 /* Always reinitialize context before requesting the first token. */
8162 if (!(hdr_inst - cmd_set_raw.tokens)) {
8163 cmd_flow_context_init(ctx);
8164 ctx->curr = START_SET;
8166 /* Return NULL when no more tokens are expected. */
8167 if (!ctx->next_num && (ctx->curr != START_SET)) {
8171 /* Determine if command should end here. */
8172 if (ctx->eol && ctx->last && ctx->next_num) {
8173 const enum index *list = ctx->next[ctx->next_num - 1];
8176 for (i = 0; list[i]; ++i) {
8183 *hdr = &cmd_set_raw_token_hdr;
8186 /** Token generator and output processing callback (cmdline API). */
8188 cmd_set_raw_cb(void *arg0, struct cmdline *cl, void *arg2)
8191 cmd_set_raw_tok(arg0, arg2);
8193 cmd_set_raw_parsed(arg0);
8196 /** Global parser instance (cmdline API). */
8197 cmdline_parse_inst_t cmd_set_raw = {
8198 .f = cmd_set_raw_cb,
8199 .data = NULL, /**< Unused. */
8200 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
8203 }, /**< Tokens are returned by cmd_flow_tok(). */
8206 /* *** display raw_encap/raw_decap buf */
8207 struct cmd_show_set_raw_result {
8208 cmdline_fixed_string_t cmd_show;
8209 cmdline_fixed_string_t cmd_what;
8210 cmdline_fixed_string_t cmd_all;
8215 cmd_show_set_raw_parsed(void *parsed_result, struct cmdline *cl, void *data)
8217 struct cmd_show_set_raw_result *res = parsed_result;
8218 uint16_t index = res->cmd_index;
8220 uint8_t *raw_data = NULL;
8221 size_t raw_size = 0;
8222 char title[16] = {0};
8226 if (!strcmp(res->cmd_all, "all")) {
8229 } else if (index >= RAW_ENCAP_CONFS_MAX_NUM) {
8230 printf("index should be 0-%u\n", RAW_ENCAP_CONFS_MAX_NUM - 1);
8234 if (!strcmp(res->cmd_what, "raw_encap")) {
8235 raw_data = (uint8_t *)&raw_encap_confs[index].data;
8236 raw_size = raw_encap_confs[index].size;
8237 snprintf(title, 16, "\nindex: %u", index);
8238 rte_hexdump(stdout, title, raw_data, raw_size);
8240 raw_data = (uint8_t *)&raw_decap_confs[index].data;
8241 raw_size = raw_decap_confs[index].size;
8242 snprintf(title, 16, "\nindex: %u", index);
8243 rte_hexdump(stdout, title, raw_data, raw_size);
8245 } while (all && ++index < RAW_ENCAP_CONFS_MAX_NUM);
8248 cmdline_parse_token_string_t cmd_show_set_raw_cmd_show =
8249 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
8251 cmdline_parse_token_string_t cmd_show_set_raw_cmd_what =
8252 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
8253 cmd_what, "raw_encap#raw_decap");
8254 cmdline_parse_token_num_t cmd_show_set_raw_cmd_index =
8255 TOKEN_NUM_INITIALIZER(struct cmd_show_set_raw_result,
8256 cmd_index, RTE_UINT16);
8257 cmdline_parse_token_string_t cmd_show_set_raw_cmd_all =
8258 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
8260 cmdline_parse_inst_t cmd_show_set_raw = {
8261 .f = cmd_show_set_raw_parsed,
8263 .help_str = "show <raw_encap|raw_decap> <index>",
8265 (void *)&cmd_show_set_raw_cmd_show,
8266 (void *)&cmd_show_set_raw_cmd_what,
8267 (void *)&cmd_show_set_raw_cmd_index,
8271 cmdline_parse_inst_t cmd_show_set_raw_all = {
8272 .f = cmd_show_set_raw_parsed,
8274 .help_str = "show <raw_encap|raw_decap> all",
8276 (void *)&cmd_show_set_raw_cmd_show,
8277 (void *)&cmd_show_set_raw_cmd_what,
8278 (void *)&cmd_show_set_raw_cmd_all,