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>
29 /** Parser token indices. */
53 /* Top-level command. */
55 /* Sub-leve commands. */
60 /* Top-level command. */
62 /* Sub-level commands. */
73 /* Destroy arguments. */
76 /* Query arguments. */
82 /* Destroy aged flow arguments. */
85 /* Validate/create arguments. */
92 /* Validate/create pattern. */
129 ITEM_VLAN_INNER_TYPE,
163 ITEM_E_TAG_GRP_ECID_B,
172 ITEM_GRE_C_RSVD0_VER,
190 ITEM_ARP_ETH_IPV4_SHA,
191 ITEM_ARP_ETH_IPV4_SPA,
192 ITEM_ARP_ETH_IPV4_THA,
193 ITEM_ARP_ETH_IPV4_TPA,
195 ITEM_IPV6_EXT_NEXT_HDR,
200 ITEM_ICMP6_ND_NS_TARGET_ADDR,
202 ITEM_ICMP6_ND_NA_TARGET_ADDR,
204 ITEM_ICMP6_ND_OPT_TYPE,
205 ITEM_ICMP6_ND_OPT_SLA_ETH,
206 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
207 ITEM_ICMP6_ND_OPT_TLA_ETH,
208 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
221 ITEM_HIGIG2_CLASSIFICATION,
227 ITEM_L2TPV3OIP_SESSION_ID,
237 ITEM_ECPRI_COMMON_TYPE,
238 ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
239 ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
240 ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
241 ITEM_ECPRI_MSG_IQ_DATA_PCID,
242 ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
243 ITEM_ECPRI_MSG_DLY_MSR_MSRID,
245 /* Validate/create actions. */
265 ACTION_RSS_FUNC_DEFAULT,
266 ACTION_RSS_FUNC_TOEPLITZ,
267 ACTION_RSS_FUNC_SIMPLE_XOR,
268 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ,
280 ACTION_PHY_PORT_ORIGINAL,
281 ACTION_PHY_PORT_INDEX,
283 ACTION_PORT_ID_ORIGINAL,
287 ACTION_OF_SET_MPLS_TTL,
288 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
289 ACTION_OF_DEC_MPLS_TTL,
290 ACTION_OF_SET_NW_TTL,
291 ACTION_OF_SET_NW_TTL_NW_TTL,
292 ACTION_OF_DEC_NW_TTL,
293 ACTION_OF_COPY_TTL_OUT,
294 ACTION_OF_COPY_TTL_IN,
297 ACTION_OF_PUSH_VLAN_ETHERTYPE,
298 ACTION_OF_SET_VLAN_VID,
299 ACTION_OF_SET_VLAN_VID_VLAN_VID,
300 ACTION_OF_SET_VLAN_PCP,
301 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
303 ACTION_OF_POP_MPLS_ETHERTYPE,
305 ACTION_OF_PUSH_MPLS_ETHERTYPE,
312 ACTION_MPLSOGRE_ENCAP,
313 ACTION_MPLSOGRE_DECAP,
314 ACTION_MPLSOUDP_ENCAP,
315 ACTION_MPLSOUDP_DECAP,
317 ACTION_SET_IPV4_SRC_IPV4_SRC,
319 ACTION_SET_IPV4_DST_IPV4_DST,
321 ACTION_SET_IPV6_SRC_IPV6_SRC,
323 ACTION_SET_IPV6_DST_IPV6_DST,
325 ACTION_SET_TP_SRC_TP_SRC,
327 ACTION_SET_TP_DST_TP_DST,
333 ACTION_SET_MAC_SRC_MAC_SRC,
335 ACTION_SET_MAC_DST_MAC_DST,
337 ACTION_INC_TCP_SEQ_VALUE,
339 ACTION_DEC_TCP_SEQ_VALUE,
341 ACTION_INC_TCP_ACK_VALUE,
343 ACTION_DEC_TCP_ACK_VALUE,
346 ACTION_RAW_ENCAP_INDEX,
347 ACTION_RAW_ENCAP_INDEX_VALUE,
348 ACTION_RAW_DECAP_INDEX,
349 ACTION_RAW_DECAP_INDEX_VALUE,
352 ACTION_SET_TAG_INDEX,
355 ACTION_SET_META_DATA,
356 ACTION_SET_META_MASK,
357 ACTION_SET_IPV4_DSCP,
358 ACTION_SET_IPV4_DSCP_VALUE,
359 ACTION_SET_IPV6_DSCP,
360 ACTION_SET_IPV6_DSCP_VALUE,
365 /** Maximum size for pattern in struct rte_flow_item_raw. */
366 #define ITEM_RAW_PATTERN_SIZE 40
368 /** Storage size for struct rte_flow_item_raw including pattern. */
369 #define ITEM_RAW_SIZE \
370 (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE)
372 /** Maximum number of queue indices in struct rte_flow_action_rss. */
373 #define ACTION_RSS_QUEUE_NUM 128
375 /** Storage for struct rte_flow_action_rss including external data. */
376 struct action_rss_data {
377 struct rte_flow_action_rss conf;
378 uint8_t key[RSS_HASH_KEY_LENGTH];
379 uint16_t queue[ACTION_RSS_QUEUE_NUM];
382 /** Maximum data size in struct rte_flow_action_raw_encap. */
383 #define ACTION_RAW_ENCAP_MAX_DATA 128
384 #define RAW_ENCAP_CONFS_MAX_NUM 8
386 /** Storage for struct rte_flow_action_raw_encap. */
387 struct raw_encap_conf {
388 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
389 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
393 struct raw_encap_conf raw_encap_confs[RAW_ENCAP_CONFS_MAX_NUM];
395 /** Storage for struct rte_flow_action_raw_encap including external data. */
396 struct action_raw_encap_data {
397 struct rte_flow_action_raw_encap conf;
398 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
399 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
403 /** Storage for struct rte_flow_action_raw_decap. */
404 struct raw_decap_conf {
405 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
409 struct raw_decap_conf raw_decap_confs[RAW_ENCAP_CONFS_MAX_NUM];
411 /** Storage for struct rte_flow_action_raw_decap including external data. */
412 struct action_raw_decap_data {
413 struct rte_flow_action_raw_decap conf;
414 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
418 struct vxlan_encap_conf vxlan_encap_conf = {
422 .vni = "\x00\x00\x00",
424 .udp_dst = RTE_BE16(4789),
425 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
426 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
427 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
428 "\x00\x00\x00\x00\x00\x00\x00\x01",
429 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
430 "\x00\x00\x00\x00\x00\x00\x11\x11",
434 .eth_src = "\x00\x00\x00\x00\x00\x00",
435 .eth_dst = "\xff\xff\xff\xff\xff\xff",
438 /** Maximum number of items in struct rte_flow_action_vxlan_encap. */
439 #define ACTION_VXLAN_ENCAP_ITEMS_NUM 6
441 /** Storage for struct rte_flow_action_vxlan_encap including external data. */
442 struct action_vxlan_encap_data {
443 struct rte_flow_action_vxlan_encap conf;
444 struct rte_flow_item items[ACTION_VXLAN_ENCAP_ITEMS_NUM];
445 struct rte_flow_item_eth item_eth;
446 struct rte_flow_item_vlan item_vlan;
448 struct rte_flow_item_ipv4 item_ipv4;
449 struct rte_flow_item_ipv6 item_ipv6;
451 struct rte_flow_item_udp item_udp;
452 struct rte_flow_item_vxlan item_vxlan;
455 struct nvgre_encap_conf nvgre_encap_conf = {
458 .tni = "\x00\x00\x00",
459 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
460 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
461 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
462 "\x00\x00\x00\x00\x00\x00\x00\x01",
463 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
464 "\x00\x00\x00\x00\x00\x00\x11\x11",
466 .eth_src = "\x00\x00\x00\x00\x00\x00",
467 .eth_dst = "\xff\xff\xff\xff\xff\xff",
470 /** Maximum number of items in struct rte_flow_action_nvgre_encap. */
471 #define ACTION_NVGRE_ENCAP_ITEMS_NUM 5
473 /** Storage for struct rte_flow_action_nvgre_encap including external data. */
474 struct action_nvgre_encap_data {
475 struct rte_flow_action_nvgre_encap conf;
476 struct rte_flow_item items[ACTION_NVGRE_ENCAP_ITEMS_NUM];
477 struct rte_flow_item_eth item_eth;
478 struct rte_flow_item_vlan item_vlan;
480 struct rte_flow_item_ipv4 item_ipv4;
481 struct rte_flow_item_ipv6 item_ipv6;
483 struct rte_flow_item_nvgre item_nvgre;
486 struct l2_encap_conf l2_encap_conf;
488 struct l2_decap_conf l2_decap_conf;
490 struct mplsogre_encap_conf mplsogre_encap_conf;
492 struct mplsogre_decap_conf mplsogre_decap_conf;
494 struct mplsoudp_encap_conf mplsoudp_encap_conf;
496 struct mplsoudp_decap_conf mplsoudp_decap_conf;
498 /** Maximum number of subsequent tokens and arguments on the stack. */
499 #define CTX_STACK_SIZE 16
501 /** Parser context. */
503 /** Stack of subsequent token lists to process. */
504 const enum index *next[CTX_STACK_SIZE];
505 /** Arguments for stacked tokens. */
506 const void *args[CTX_STACK_SIZE];
507 enum index curr; /**< Current token index. */
508 enum index prev; /**< Index of the last token seen. */
509 int next_num; /**< Number of entries in next[]. */
510 int args_num; /**< Number of entries in args[]. */
511 uint32_t eol:1; /**< EOL has been detected. */
512 uint32_t last:1; /**< No more arguments. */
513 portid_t port; /**< Current port ID (for completions). */
514 uint32_t objdata; /**< Object-specific data. */
515 void *object; /**< Address of current object for relative offsets. */
516 void *objmask; /**< Object a full mask must be written to. */
519 /** Token argument. */
521 uint32_t hton:1; /**< Use network byte ordering. */
522 uint32_t sign:1; /**< Value is signed. */
523 uint32_t bounded:1; /**< Value is bounded. */
524 uintmax_t min; /**< Minimum value if bounded. */
525 uintmax_t max; /**< Maximum value if bounded. */
526 uint32_t offset; /**< Relative offset from ctx->object. */
527 uint32_t size; /**< Field size. */
528 const uint8_t *mask; /**< Bit-mask to use instead of offset/size. */
531 /** Parser token definition. */
533 /** Type displayed during completion (defaults to "TOKEN"). */
535 /** Help displayed during completion (defaults to token name). */
537 /** Private data used by parser functions. */
540 * Lists of subsequent tokens to push on the stack. Each call to the
541 * parser consumes the last entry of that stack.
543 const enum index *const *next;
544 /** Arguments stack for subsequent tokens that need them. */
545 const struct arg *const *args;
547 * Token-processing callback, returns -1 in case of error, the
548 * length of the matched string otherwise. If NULL, attempts to
549 * match the token name.
551 * If buf is not NULL, the result should be stored in it according
552 * to context. An error is returned if not large enough.
554 int (*call)(struct context *ctx, const struct token *token,
555 const char *str, unsigned int len,
556 void *buf, unsigned int size);
558 * Callback that provides possible values for this token, used for
559 * completion. Returns -1 in case of error, the number of possible
560 * values otherwise. If NULL, the token name is used.
562 * If buf is not NULL, entry index ent is written to buf and the
563 * full length of the entry is returned (same behavior as
566 int (*comp)(struct context *ctx, const struct token *token,
567 unsigned int ent, char *buf, unsigned int size);
568 /** Mandatory token name, no default value. */
572 /** Static initializer for the next field. */
573 #define NEXT(...) (const enum index *const []){ __VA_ARGS__, NULL, }
575 /** Static initializer for a NEXT() entry. */
576 #define NEXT_ENTRY(...) (const enum index []){ __VA_ARGS__, ZERO, }
578 /** Static initializer for the args field. */
579 #define ARGS(...) (const struct arg *const []){ __VA_ARGS__, NULL, }
581 /** Static initializer for ARGS() to target a field. */
582 #define ARGS_ENTRY(s, f) \
583 (&(const struct arg){ \
584 .offset = offsetof(s, f), \
585 .size = sizeof(((s *)0)->f), \
588 /** Static initializer for ARGS() to target a bit-field. */
589 #define ARGS_ENTRY_BF(s, f, b) \
590 (&(const struct arg){ \
592 .mask = (const void *)&(const s){ .f = (1 << (b)) - 1 }, \
595 /** Static initializer for ARGS() to target an arbitrary bit-mask. */
596 #define ARGS_ENTRY_MASK(s, f, m) \
597 (&(const struct arg){ \
598 .offset = offsetof(s, f), \
599 .size = sizeof(((s *)0)->f), \
600 .mask = (const void *)(m), \
603 /** Same as ARGS_ENTRY_MASK() using network byte ordering for the value. */
604 #define ARGS_ENTRY_MASK_HTON(s, f, m) \
605 (&(const struct arg){ \
607 .offset = offsetof(s, f), \
608 .size = sizeof(((s *)0)->f), \
609 .mask = (const void *)(m), \
612 /** Static initializer for ARGS() to target a pointer. */
613 #define ARGS_ENTRY_PTR(s, f) \
614 (&(const struct arg){ \
615 .size = sizeof(*((s *)0)->f), \
618 /** Static initializer for ARGS() with arbitrary offset and size. */
619 #define ARGS_ENTRY_ARB(o, s) \
620 (&(const struct arg){ \
625 /** Same as ARGS_ENTRY_ARB() with bounded values. */
626 #define ARGS_ENTRY_ARB_BOUNDED(o, s, i, a) \
627 (&(const struct arg){ \
635 /** Same as ARGS_ENTRY() using network byte ordering. */
636 #define ARGS_ENTRY_HTON(s, f) \
637 (&(const struct arg){ \
639 .offset = offsetof(s, f), \
640 .size = sizeof(((s *)0)->f), \
643 /** Same as ARGS_ENTRY_HTON() for a single argument, without structure. */
644 #define ARG_ENTRY_HTON(s) \
645 (&(const struct arg){ \
651 /** Parser output buffer layout expected by cmd_flow_parsed(). */
653 enum index command; /**< Flow command. */
654 portid_t port; /**< Affected port ID. */
657 struct rte_flow_attr attr;
658 struct rte_flow_item *pattern;
659 struct rte_flow_action *actions;
663 } vc; /**< Validate/create arguments. */
667 } destroy; /**< Destroy arguments. */
670 } dump; /**< Dump arguments. */
673 struct rte_flow_action action;
674 } query; /**< Query arguments. */
678 } list; /**< List arguments. */
681 } isolate; /**< Isolated mode arguments. */
684 } aged; /**< Aged arguments. */
685 } args; /**< Command arguments. */
688 /** Private data for pattern items. */
689 struct parse_item_priv {
690 enum rte_flow_item_type type; /**< Item type. */
691 uint32_t size; /**< Size of item specification structure. */
694 #define PRIV_ITEM(t, s) \
695 (&(const struct parse_item_priv){ \
696 .type = RTE_FLOW_ITEM_TYPE_ ## t, \
700 /** Private data for actions. */
701 struct parse_action_priv {
702 enum rte_flow_action_type type; /**< Action type. */
703 uint32_t size; /**< Size of action configuration structure. */
706 #define PRIV_ACTION(t, s) \
707 (&(const struct parse_action_priv){ \
708 .type = RTE_FLOW_ACTION_TYPE_ ## t, \
712 static const enum index next_vc_attr[] = {
722 static const enum index next_destroy_attr[] = {
728 static const enum index next_dump_attr[] = {
734 static const enum index next_list_attr[] = {
740 static const enum index next_aged_attr[] = {
746 static const enum index item_param[] = {
755 static const enum index next_item[] = {
791 ITEM_ICMP6_ND_OPT_SLA_ETH,
792 ITEM_ICMP6_ND_OPT_TLA_ETH,
810 static const enum index item_fuzzy[] = {
816 static const enum index item_any[] = {
822 static const enum index item_vf[] = {
828 static const enum index item_phy_port[] = {
834 static const enum index item_port_id[] = {
840 static const enum index item_mark[] = {
846 static const enum index item_raw[] = {
856 static const enum index item_eth[] = {
864 static const enum index item_vlan[] = {
869 ITEM_VLAN_INNER_TYPE,
874 static const enum index item_ipv4[] = {
884 static const enum index item_ipv6[] = {
895 static const enum index item_icmp[] = {
904 static const enum index item_udp[] = {
911 static const enum index item_tcp[] = {
919 static const enum index item_sctp[] = {
928 static const enum index item_vxlan[] = {
934 static const enum index item_e_tag[] = {
935 ITEM_E_TAG_GRP_ECID_B,
940 static const enum index item_nvgre[] = {
946 static const enum index item_mpls[] = {
954 static const enum index item_gre[] = {
956 ITEM_GRE_C_RSVD0_VER,
964 static const enum index item_gre_key[] = {
970 static const enum index item_gtp[] = {
978 static const enum index item_geneve[] = {
985 static const enum index item_vxlan_gpe[] = {
991 static const enum index item_arp_eth_ipv4[] = {
992 ITEM_ARP_ETH_IPV4_SHA,
993 ITEM_ARP_ETH_IPV4_SPA,
994 ITEM_ARP_ETH_IPV4_THA,
995 ITEM_ARP_ETH_IPV4_TPA,
1000 static const enum index item_ipv6_ext[] = {
1001 ITEM_IPV6_EXT_NEXT_HDR,
1006 static const enum index item_icmp6[] = {
1013 static const enum index item_icmp6_nd_ns[] = {
1014 ITEM_ICMP6_ND_NS_TARGET_ADDR,
1019 static const enum index item_icmp6_nd_na[] = {
1020 ITEM_ICMP6_ND_NA_TARGET_ADDR,
1025 static const enum index item_icmp6_nd_opt[] = {
1026 ITEM_ICMP6_ND_OPT_TYPE,
1031 static const enum index item_icmp6_nd_opt_sla_eth[] = {
1032 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
1037 static const enum index item_icmp6_nd_opt_tla_eth[] = {
1038 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
1043 static const enum index item_meta[] = {
1049 static const enum index item_gtp_psc[] = {
1056 static const enum index item_pppoed[] = {
1062 static const enum index item_pppoes[] = {
1068 static const enum index item_pppoe_proto_id[] = {
1073 static const enum index item_higig2[] = {
1074 ITEM_HIGIG2_CLASSIFICATION,
1080 static const enum index item_esp[] = {
1086 static const enum index item_ah[] = {
1092 static const enum index item_pfcp[] = {
1099 static const enum index next_set_raw[] = {
1105 static const enum index item_tag[] = {
1112 static const enum index item_l2tpv3oip[] = {
1113 ITEM_L2TPV3OIP_SESSION_ID,
1118 static const enum index item_ecpri[] = {
1124 static const enum index item_ecpri_common[] = {
1125 ITEM_ECPRI_COMMON_TYPE,
1129 static const enum index item_ecpri_common_type[] = {
1130 ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
1131 ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
1132 ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
1136 static const enum index next_action[] = {
1152 ACTION_OF_SET_MPLS_TTL,
1153 ACTION_OF_DEC_MPLS_TTL,
1154 ACTION_OF_SET_NW_TTL,
1155 ACTION_OF_DEC_NW_TTL,
1156 ACTION_OF_COPY_TTL_OUT,
1157 ACTION_OF_COPY_TTL_IN,
1159 ACTION_OF_PUSH_VLAN,
1160 ACTION_OF_SET_VLAN_VID,
1161 ACTION_OF_SET_VLAN_PCP,
1163 ACTION_OF_PUSH_MPLS,
1170 ACTION_MPLSOGRE_ENCAP,
1171 ACTION_MPLSOGRE_DECAP,
1172 ACTION_MPLSOUDP_ENCAP,
1173 ACTION_MPLSOUDP_DECAP,
1174 ACTION_SET_IPV4_SRC,
1175 ACTION_SET_IPV4_DST,
1176 ACTION_SET_IPV6_SRC,
1177 ACTION_SET_IPV6_DST,
1193 ACTION_SET_IPV4_DSCP,
1194 ACTION_SET_IPV6_DSCP,
1199 static const enum index action_mark[] = {
1205 static const enum index action_queue[] = {
1211 static const enum index action_count[] = {
1213 ACTION_COUNT_SHARED,
1218 static const enum index action_rss[] = {
1229 static const enum index action_vf[] = {
1236 static const enum index action_phy_port[] = {
1237 ACTION_PHY_PORT_ORIGINAL,
1238 ACTION_PHY_PORT_INDEX,
1243 static const enum index action_port_id[] = {
1244 ACTION_PORT_ID_ORIGINAL,
1250 static const enum index action_meter[] = {
1256 static const enum index action_of_set_mpls_ttl[] = {
1257 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
1262 static const enum index action_of_set_nw_ttl[] = {
1263 ACTION_OF_SET_NW_TTL_NW_TTL,
1268 static const enum index action_of_push_vlan[] = {
1269 ACTION_OF_PUSH_VLAN_ETHERTYPE,
1274 static const enum index action_of_set_vlan_vid[] = {
1275 ACTION_OF_SET_VLAN_VID_VLAN_VID,
1280 static const enum index action_of_set_vlan_pcp[] = {
1281 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
1286 static const enum index action_of_pop_mpls[] = {
1287 ACTION_OF_POP_MPLS_ETHERTYPE,
1292 static const enum index action_of_push_mpls[] = {
1293 ACTION_OF_PUSH_MPLS_ETHERTYPE,
1298 static const enum index action_set_ipv4_src[] = {
1299 ACTION_SET_IPV4_SRC_IPV4_SRC,
1304 static const enum index action_set_mac_src[] = {
1305 ACTION_SET_MAC_SRC_MAC_SRC,
1310 static const enum index action_set_ipv4_dst[] = {
1311 ACTION_SET_IPV4_DST_IPV4_DST,
1316 static const enum index action_set_ipv6_src[] = {
1317 ACTION_SET_IPV6_SRC_IPV6_SRC,
1322 static const enum index action_set_ipv6_dst[] = {
1323 ACTION_SET_IPV6_DST_IPV6_DST,
1328 static const enum index action_set_tp_src[] = {
1329 ACTION_SET_TP_SRC_TP_SRC,
1334 static const enum index action_set_tp_dst[] = {
1335 ACTION_SET_TP_DST_TP_DST,
1340 static const enum index action_set_ttl[] = {
1346 static const enum index action_jump[] = {
1352 static const enum index action_set_mac_dst[] = {
1353 ACTION_SET_MAC_DST_MAC_DST,
1358 static const enum index action_inc_tcp_seq[] = {
1359 ACTION_INC_TCP_SEQ_VALUE,
1364 static const enum index action_dec_tcp_seq[] = {
1365 ACTION_DEC_TCP_SEQ_VALUE,
1370 static const enum index action_inc_tcp_ack[] = {
1371 ACTION_INC_TCP_ACK_VALUE,
1376 static const enum index action_dec_tcp_ack[] = {
1377 ACTION_DEC_TCP_ACK_VALUE,
1382 static const enum index action_raw_encap[] = {
1383 ACTION_RAW_ENCAP_INDEX,
1388 static const enum index action_raw_decap[] = {
1389 ACTION_RAW_DECAP_INDEX,
1394 static const enum index action_set_tag[] = {
1395 ACTION_SET_TAG_DATA,
1396 ACTION_SET_TAG_INDEX,
1397 ACTION_SET_TAG_MASK,
1402 static const enum index action_set_meta[] = {
1403 ACTION_SET_META_DATA,
1404 ACTION_SET_META_MASK,
1409 static const enum index action_set_ipv4_dscp[] = {
1410 ACTION_SET_IPV4_DSCP_VALUE,
1415 static const enum index action_set_ipv6_dscp[] = {
1416 ACTION_SET_IPV6_DSCP_VALUE,
1421 static const enum index action_age[] = {
1428 static int parse_set_raw_encap_decap(struct context *, const struct token *,
1429 const char *, unsigned int,
1430 void *, unsigned int);
1431 static int parse_set_init(struct context *, const struct token *,
1432 const char *, unsigned int,
1433 void *, unsigned int);
1434 static int parse_init(struct context *, const struct token *,
1435 const char *, unsigned int,
1436 void *, unsigned int);
1437 static int parse_vc(struct context *, const struct token *,
1438 const char *, unsigned int,
1439 void *, unsigned int);
1440 static int parse_vc_spec(struct context *, const struct token *,
1441 const char *, unsigned int, void *, unsigned int);
1442 static int parse_vc_conf(struct context *, const struct token *,
1443 const char *, unsigned int, void *, unsigned int);
1444 static int parse_vc_item_ecpri_type(struct context *, const struct token *,
1445 const char *, unsigned int,
1446 void *, unsigned int);
1447 static int parse_vc_action_rss(struct context *, const struct token *,
1448 const char *, unsigned int, void *,
1450 static int parse_vc_action_rss_func(struct context *, const struct token *,
1451 const char *, unsigned int, void *,
1453 static int parse_vc_action_rss_type(struct context *, const struct token *,
1454 const char *, unsigned int, void *,
1456 static int parse_vc_action_rss_queue(struct context *, const struct token *,
1457 const char *, unsigned int, void *,
1459 static int parse_vc_action_vxlan_encap(struct context *, const struct token *,
1460 const char *, unsigned int, void *,
1462 static int parse_vc_action_nvgre_encap(struct context *, const struct token *,
1463 const char *, unsigned int, void *,
1465 static int parse_vc_action_l2_encap(struct context *, const struct token *,
1466 const char *, unsigned int, void *,
1468 static int parse_vc_action_l2_decap(struct context *, const struct token *,
1469 const char *, unsigned int, void *,
1471 static int parse_vc_action_mplsogre_encap(struct context *,
1472 const struct token *, const char *,
1473 unsigned int, void *, unsigned int);
1474 static int parse_vc_action_mplsogre_decap(struct context *,
1475 const struct token *, const char *,
1476 unsigned int, void *, unsigned int);
1477 static int parse_vc_action_mplsoudp_encap(struct context *,
1478 const struct token *, const char *,
1479 unsigned int, void *, unsigned int);
1480 static int parse_vc_action_mplsoudp_decap(struct context *,
1481 const struct token *, const char *,
1482 unsigned int, void *, unsigned int);
1483 static int parse_vc_action_raw_encap(struct context *,
1484 const struct token *, const char *,
1485 unsigned int, void *, unsigned int);
1486 static int parse_vc_action_raw_decap(struct context *,
1487 const struct token *, const char *,
1488 unsigned int, void *, unsigned int);
1489 static int parse_vc_action_raw_encap_index(struct context *,
1490 const struct token *, const char *,
1491 unsigned int, void *, unsigned int);
1492 static int parse_vc_action_raw_decap_index(struct context *,
1493 const struct token *, const char *,
1494 unsigned int, void *, unsigned int);
1495 static int parse_vc_action_set_meta(struct context *ctx,
1496 const struct token *token, const char *str,
1497 unsigned int len, void *buf,
1499 static int parse_destroy(struct context *, const struct token *,
1500 const char *, unsigned int,
1501 void *, unsigned int);
1502 static int parse_flush(struct context *, const struct token *,
1503 const char *, unsigned int,
1504 void *, unsigned int);
1505 static int parse_dump(struct context *, const struct token *,
1506 const char *, unsigned int,
1507 void *, unsigned int);
1508 static int parse_query(struct context *, const struct token *,
1509 const char *, unsigned int,
1510 void *, unsigned int);
1511 static int parse_action(struct context *, const struct token *,
1512 const char *, unsigned int,
1513 void *, unsigned int);
1514 static int parse_list(struct context *, const struct token *,
1515 const char *, unsigned int,
1516 void *, unsigned int);
1517 static int parse_aged(struct context *, const struct token *,
1518 const char *, unsigned int,
1519 void *, unsigned int);
1520 static int parse_isolate(struct context *, const struct token *,
1521 const char *, unsigned int,
1522 void *, unsigned int);
1523 static int parse_int(struct context *, const struct token *,
1524 const char *, unsigned int,
1525 void *, unsigned int);
1526 static int parse_prefix(struct context *, const struct token *,
1527 const char *, unsigned int,
1528 void *, unsigned int);
1529 static int parse_boolean(struct context *, const struct token *,
1530 const char *, unsigned int,
1531 void *, unsigned int);
1532 static int parse_string(struct context *, const struct token *,
1533 const char *, unsigned int,
1534 void *, unsigned int);
1535 static int parse_hex(struct context *ctx, const struct token *token,
1536 const char *str, unsigned int len,
1537 void *buf, unsigned int size);
1538 static int parse_string0(struct context *, const struct token *,
1539 const char *, unsigned int,
1540 void *, unsigned int);
1541 static int parse_mac_addr(struct context *, const struct token *,
1542 const char *, unsigned int,
1543 void *, unsigned int);
1544 static int parse_ipv4_addr(struct context *, const struct token *,
1545 const char *, unsigned int,
1546 void *, unsigned int);
1547 static int parse_ipv6_addr(struct context *, const struct token *,
1548 const char *, unsigned int,
1549 void *, unsigned int);
1550 static int parse_port(struct context *, const struct token *,
1551 const char *, unsigned int,
1552 void *, unsigned int);
1553 static int comp_none(struct context *, const struct token *,
1554 unsigned int, char *, unsigned int);
1555 static int comp_boolean(struct context *, const struct token *,
1556 unsigned int, char *, unsigned int);
1557 static int comp_action(struct context *, const struct token *,
1558 unsigned int, char *, unsigned int);
1559 static int comp_port(struct context *, const struct token *,
1560 unsigned int, char *, unsigned int);
1561 static int comp_rule_id(struct context *, const struct token *,
1562 unsigned int, char *, unsigned int);
1563 static int comp_vc_action_rss_type(struct context *, const struct token *,
1564 unsigned int, char *, unsigned int);
1565 static int comp_vc_action_rss_queue(struct context *, const struct token *,
1566 unsigned int, char *, unsigned int);
1567 static int comp_set_raw_index(struct context *, const struct token *,
1568 unsigned int, char *, unsigned int);
1570 /** Token definitions. */
1571 static const struct token token_list[] = {
1572 /* Special tokens. */
1575 .help = "null entry, abused as the entry point",
1576 .next = NEXT(NEXT_ENTRY(FLOW)),
1581 .help = "command may end here",
1584 .name = "START_SET",
1585 .help = "null entry, abused as the entry point for set",
1586 .next = NEXT(NEXT_ENTRY(SET)),
1591 .help = "set command may end here",
1593 /* Common tokens. */
1597 .help = "integer value",
1602 .name = "{unsigned}",
1604 .help = "unsigned integer value",
1611 .help = "prefix length for bit-mask",
1612 .call = parse_prefix,
1616 .name = "{boolean}",
1618 .help = "any boolean value",
1619 .call = parse_boolean,
1620 .comp = comp_boolean,
1625 .help = "fixed string",
1626 .call = parse_string,
1632 .help = "fixed string",
1636 .name = "{file path}",
1638 .help = "file path",
1639 .call = parse_string0,
1643 .name = "{MAC address}",
1645 .help = "standard MAC address notation",
1646 .call = parse_mac_addr,
1650 .name = "{IPv4 address}",
1651 .type = "IPV4 ADDRESS",
1652 .help = "standard IPv4 address notation",
1653 .call = parse_ipv4_addr,
1657 .name = "{IPv6 address}",
1658 .type = "IPV6 ADDRESS",
1659 .help = "standard IPv6 address notation",
1660 .call = parse_ipv6_addr,
1664 .name = "{rule id}",
1666 .help = "rule identifier",
1668 .comp = comp_rule_id,
1671 .name = "{port_id}",
1673 .help = "port identifier",
1678 .name = "{group_id}",
1680 .help = "group identifier",
1684 [PRIORITY_LEVEL] = {
1687 .help = "priority level",
1691 /* Top-level command. */
1694 .type = "{command} {port_id} [{arg} [...]]",
1695 .help = "manage ingress/egress flow rules",
1696 .next = NEXT(NEXT_ENTRY
1708 /* Sub-level commands. */
1711 .help = "check whether a flow rule can be created",
1712 .next = NEXT(next_vc_attr, NEXT_ENTRY(PORT_ID)),
1713 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1718 .help = "create a flow rule",
1719 .next = NEXT(next_vc_attr, NEXT_ENTRY(PORT_ID)),
1720 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1725 .help = "destroy specific flow rules",
1726 .next = NEXT(NEXT_ENTRY(DESTROY_RULE), NEXT_ENTRY(PORT_ID)),
1727 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1728 .call = parse_destroy,
1732 .help = "destroy all flow rules",
1733 .next = NEXT(NEXT_ENTRY(PORT_ID)),
1734 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1735 .call = parse_flush,
1739 .help = "dump all flow rules to file",
1740 .next = NEXT(next_dump_attr, NEXT_ENTRY(PORT_ID)),
1741 .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file),
1742 ARGS_ENTRY(struct buffer, port)),
1747 .help = "query an existing flow rule",
1748 .next = NEXT(NEXT_ENTRY(QUERY_ACTION),
1749 NEXT_ENTRY(RULE_ID),
1750 NEXT_ENTRY(PORT_ID)),
1751 .args = ARGS(ARGS_ENTRY(struct buffer, args.query.action.type),
1752 ARGS_ENTRY(struct buffer, args.query.rule),
1753 ARGS_ENTRY(struct buffer, port)),
1754 .call = parse_query,
1758 .help = "list existing flow rules",
1759 .next = NEXT(next_list_attr, NEXT_ENTRY(PORT_ID)),
1760 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1765 .help = "list and destroy aged flows",
1766 .next = NEXT(next_aged_attr, NEXT_ENTRY(PORT_ID)),
1767 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1772 .help = "restrict ingress traffic to the defined flow rules",
1773 .next = NEXT(NEXT_ENTRY(BOOLEAN),
1774 NEXT_ENTRY(PORT_ID)),
1775 .args = ARGS(ARGS_ENTRY(struct buffer, args.isolate.set),
1776 ARGS_ENTRY(struct buffer, port)),
1777 .call = parse_isolate,
1779 /* Destroy arguments. */
1782 .help = "specify a rule identifier",
1783 .next = NEXT(next_destroy_attr, NEXT_ENTRY(RULE_ID)),
1784 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.destroy.rule)),
1785 .call = parse_destroy,
1787 /* Query arguments. */
1791 .help = "action to query, must be part of the rule",
1792 .call = parse_action,
1793 .comp = comp_action,
1795 /* List arguments. */
1798 .help = "specify a group",
1799 .next = NEXT(next_list_attr, NEXT_ENTRY(GROUP_ID)),
1800 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.list.group)),
1805 .help = "specify aged flows need be destroyed",
1809 /* Validate/create attributes. */
1812 .help = "specify a group",
1813 .next = NEXT(next_vc_attr, NEXT_ENTRY(GROUP_ID)),
1814 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, group)),
1819 .help = "specify a priority level",
1820 .next = NEXT(next_vc_attr, NEXT_ENTRY(PRIORITY_LEVEL)),
1821 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, priority)),
1826 .help = "affect rule to ingress",
1827 .next = NEXT(next_vc_attr),
1832 .help = "affect rule to egress",
1833 .next = NEXT(next_vc_attr),
1838 .help = "apply rule directly to endpoints found in pattern",
1839 .next = NEXT(next_vc_attr),
1842 /* Validate/create pattern. */
1845 .help = "submit a list of pattern items",
1846 .next = NEXT(next_item),
1851 .help = "match value perfectly (with full bit-mask)",
1852 .call = parse_vc_spec,
1854 [ITEM_PARAM_SPEC] = {
1856 .help = "match value according to configured bit-mask",
1857 .call = parse_vc_spec,
1859 [ITEM_PARAM_LAST] = {
1861 .help = "specify upper bound to establish a range",
1862 .call = parse_vc_spec,
1864 [ITEM_PARAM_MASK] = {
1866 .help = "specify bit-mask with relevant bits set to one",
1867 .call = parse_vc_spec,
1869 [ITEM_PARAM_PREFIX] = {
1871 .help = "generate bit-mask from a prefix length",
1872 .call = parse_vc_spec,
1876 .help = "specify next pattern item",
1877 .next = NEXT(next_item),
1881 .help = "end list of pattern items",
1882 .priv = PRIV_ITEM(END, 0),
1883 .next = NEXT(NEXT_ENTRY(ACTIONS)),
1888 .help = "no-op pattern item",
1889 .priv = PRIV_ITEM(VOID, 0),
1890 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
1895 .help = "perform actions when pattern does not match",
1896 .priv = PRIV_ITEM(INVERT, 0),
1897 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
1902 .help = "match any protocol for the current layer",
1903 .priv = PRIV_ITEM(ANY, sizeof(struct rte_flow_item_any)),
1904 .next = NEXT(item_any),
1909 .help = "number of layers covered",
1910 .next = NEXT(item_any, NEXT_ENTRY(UNSIGNED), item_param),
1911 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_any, num)),
1915 .help = "match traffic from/to the physical function",
1916 .priv = PRIV_ITEM(PF, 0),
1917 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
1922 .help = "match traffic from/to a virtual function ID",
1923 .priv = PRIV_ITEM(VF, sizeof(struct rte_flow_item_vf)),
1924 .next = NEXT(item_vf),
1930 .next = NEXT(item_vf, NEXT_ENTRY(UNSIGNED), item_param),
1931 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_vf, id)),
1935 .help = "match traffic from/to a specific physical port",
1936 .priv = PRIV_ITEM(PHY_PORT,
1937 sizeof(struct rte_flow_item_phy_port)),
1938 .next = NEXT(item_phy_port),
1941 [ITEM_PHY_PORT_INDEX] = {
1943 .help = "physical port index",
1944 .next = NEXT(item_phy_port, NEXT_ENTRY(UNSIGNED), item_param),
1945 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_phy_port, index)),
1949 .help = "match traffic from/to a given DPDK port ID",
1950 .priv = PRIV_ITEM(PORT_ID,
1951 sizeof(struct rte_flow_item_port_id)),
1952 .next = NEXT(item_port_id),
1955 [ITEM_PORT_ID_ID] = {
1957 .help = "DPDK port ID",
1958 .next = NEXT(item_port_id, NEXT_ENTRY(UNSIGNED), item_param),
1959 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port_id, id)),
1963 .help = "match traffic against value set in previously matched rule",
1964 .priv = PRIV_ITEM(MARK, sizeof(struct rte_flow_item_mark)),
1965 .next = NEXT(item_mark),
1970 .help = "Integer value to match against",
1971 .next = NEXT(item_mark, NEXT_ENTRY(UNSIGNED), item_param),
1972 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_mark, id)),
1976 .help = "match an arbitrary byte string",
1977 .priv = PRIV_ITEM(RAW, ITEM_RAW_SIZE),
1978 .next = NEXT(item_raw),
1981 [ITEM_RAW_RELATIVE] = {
1983 .help = "look for pattern after the previous item",
1984 .next = NEXT(item_raw, NEXT_ENTRY(BOOLEAN), item_param),
1985 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
1988 [ITEM_RAW_SEARCH] = {
1990 .help = "search pattern from offset (see also limit)",
1991 .next = NEXT(item_raw, NEXT_ENTRY(BOOLEAN), item_param),
1992 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
1995 [ITEM_RAW_OFFSET] = {
1997 .help = "absolute or relative offset for pattern",
1998 .next = NEXT(item_raw, NEXT_ENTRY(INTEGER), item_param),
1999 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, offset)),
2001 [ITEM_RAW_LIMIT] = {
2003 .help = "search area limit for start of pattern",
2004 .next = NEXT(item_raw, NEXT_ENTRY(UNSIGNED), item_param),
2005 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, limit)),
2007 [ITEM_RAW_PATTERN] = {
2009 .help = "byte string to look for",
2010 .next = NEXT(item_raw,
2012 NEXT_ENTRY(ITEM_PARAM_IS,
2015 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern),
2016 ARGS_ENTRY(struct rte_flow_item_raw, length),
2017 ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw),
2018 ITEM_RAW_PATTERN_SIZE)),
2022 .help = "match Ethernet header",
2023 .priv = PRIV_ITEM(ETH, sizeof(struct rte_flow_item_eth)),
2024 .next = NEXT(item_eth),
2029 .help = "destination MAC",
2030 .next = NEXT(item_eth, NEXT_ENTRY(MAC_ADDR), item_param),
2031 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, dst)),
2035 .help = "source MAC",
2036 .next = NEXT(item_eth, NEXT_ENTRY(MAC_ADDR), item_param),
2037 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, src)),
2041 .help = "EtherType",
2042 .next = NEXT(item_eth, NEXT_ENTRY(UNSIGNED), item_param),
2043 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, type)),
2047 .help = "match 802.1Q/ad VLAN tag",
2048 .priv = PRIV_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)),
2049 .next = NEXT(item_vlan),
2054 .help = "tag control information",
2055 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2056 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, tci)),
2060 .help = "priority code point",
2061 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2062 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2067 .help = "drop eligible indicator",
2068 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2069 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2074 .help = "VLAN identifier",
2075 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2076 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
2079 [ITEM_VLAN_INNER_TYPE] = {
2080 .name = "inner_type",
2081 .help = "inner EtherType",
2082 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
2083 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan,
2088 .help = "match IPv4 header",
2089 .priv = PRIV_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)),
2090 .next = NEXT(item_ipv4),
2095 .help = "type of service",
2096 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2097 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2098 hdr.type_of_service)),
2102 .help = "time to live",
2103 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2104 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2107 [ITEM_IPV4_PROTO] = {
2109 .help = "next protocol ID",
2110 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2111 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2112 hdr.next_proto_id)),
2116 .help = "source address",
2117 .next = NEXT(item_ipv4, NEXT_ENTRY(IPV4_ADDR), item_param),
2118 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2123 .help = "destination address",
2124 .next = NEXT(item_ipv4, NEXT_ENTRY(IPV4_ADDR), item_param),
2125 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2130 .help = "match IPv6 header",
2131 .priv = PRIV_ITEM(IPV6, sizeof(struct rte_flow_item_ipv6)),
2132 .next = NEXT(item_ipv6),
2137 .help = "traffic class",
2138 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2139 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2141 "\x0f\xf0\x00\x00")),
2143 [ITEM_IPV6_FLOW] = {
2145 .help = "flow label",
2146 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2147 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2149 "\x00\x0f\xff\xff")),
2151 [ITEM_IPV6_PROTO] = {
2153 .help = "protocol (next header)",
2154 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2155 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2160 .help = "hop limit",
2161 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2162 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2167 .help = "source address",
2168 .next = NEXT(item_ipv6, NEXT_ENTRY(IPV6_ADDR), item_param),
2169 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2174 .help = "destination address",
2175 .next = NEXT(item_ipv6, NEXT_ENTRY(IPV6_ADDR), item_param),
2176 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2181 .help = "match ICMP header",
2182 .priv = PRIV_ITEM(ICMP, sizeof(struct rte_flow_item_icmp)),
2183 .next = NEXT(item_icmp),
2186 [ITEM_ICMP_TYPE] = {
2188 .help = "ICMP packet type",
2189 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2190 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2193 [ITEM_ICMP_CODE] = {
2195 .help = "ICMP packet code",
2196 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2197 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2200 [ITEM_ICMP_IDENT] = {
2202 .help = "ICMP packet identifier",
2203 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2204 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2209 .help = "ICMP packet sequence number",
2210 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2211 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2216 .help = "match UDP header",
2217 .priv = PRIV_ITEM(UDP, sizeof(struct rte_flow_item_udp)),
2218 .next = NEXT(item_udp),
2223 .help = "UDP source port",
2224 .next = NEXT(item_udp, NEXT_ENTRY(UNSIGNED), item_param),
2225 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2230 .help = "UDP destination port",
2231 .next = NEXT(item_udp, NEXT_ENTRY(UNSIGNED), item_param),
2232 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2237 .help = "match TCP header",
2238 .priv = PRIV_ITEM(TCP, sizeof(struct rte_flow_item_tcp)),
2239 .next = NEXT(item_tcp),
2244 .help = "TCP source port",
2245 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2246 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2251 .help = "TCP destination port",
2252 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2253 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2256 [ITEM_TCP_FLAGS] = {
2258 .help = "TCP flags",
2259 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2260 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2265 .help = "match SCTP header",
2266 .priv = PRIV_ITEM(SCTP, sizeof(struct rte_flow_item_sctp)),
2267 .next = NEXT(item_sctp),
2272 .help = "SCTP source port",
2273 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2274 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2279 .help = "SCTP destination port",
2280 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2281 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2286 .help = "validation tag",
2287 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2288 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2291 [ITEM_SCTP_CKSUM] = {
2294 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2295 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2300 .help = "match VXLAN header",
2301 .priv = PRIV_ITEM(VXLAN, sizeof(struct rte_flow_item_vxlan)),
2302 .next = NEXT(item_vxlan),
2305 [ITEM_VXLAN_VNI] = {
2307 .help = "VXLAN identifier",
2308 .next = NEXT(item_vxlan, NEXT_ENTRY(UNSIGNED), item_param),
2309 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan, vni)),
2313 .help = "match E-Tag header",
2314 .priv = PRIV_ITEM(E_TAG, sizeof(struct rte_flow_item_e_tag)),
2315 .next = NEXT(item_e_tag),
2318 [ITEM_E_TAG_GRP_ECID_B] = {
2319 .name = "grp_ecid_b",
2320 .help = "GRP and E-CID base",
2321 .next = NEXT(item_e_tag, NEXT_ENTRY(UNSIGNED), item_param),
2322 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_e_tag,
2328 .help = "match NVGRE header",
2329 .priv = PRIV_ITEM(NVGRE, sizeof(struct rte_flow_item_nvgre)),
2330 .next = NEXT(item_nvgre),
2333 [ITEM_NVGRE_TNI] = {
2335 .help = "virtual subnet ID",
2336 .next = NEXT(item_nvgre, NEXT_ENTRY(UNSIGNED), item_param),
2337 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_nvgre, tni)),
2341 .help = "match MPLS header",
2342 .priv = PRIV_ITEM(MPLS, sizeof(struct rte_flow_item_mpls)),
2343 .next = NEXT(item_mpls),
2346 [ITEM_MPLS_LABEL] = {
2348 .help = "MPLS label",
2349 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2350 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2356 .help = "MPLS Traffic Class",
2357 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2358 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2364 .help = "MPLS Bottom-of-Stack",
2365 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2366 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2372 .help = "match GRE header",
2373 .priv = PRIV_ITEM(GRE, sizeof(struct rte_flow_item_gre)),
2374 .next = NEXT(item_gre),
2377 [ITEM_GRE_PROTO] = {
2379 .help = "GRE protocol type",
2380 .next = NEXT(item_gre, NEXT_ENTRY(UNSIGNED), item_param),
2381 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2384 [ITEM_GRE_C_RSVD0_VER] = {
2385 .name = "c_rsvd0_ver",
2387 "checksum (1b), undefined (1b), key bit (1b),"
2388 " sequence number (1b), reserved 0 (9b),"
2390 .next = NEXT(item_gre, NEXT_ENTRY(UNSIGNED), item_param),
2391 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2394 [ITEM_GRE_C_BIT] = {
2396 .help = "checksum bit (C)",
2397 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2398 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2400 "\x80\x00\x00\x00")),
2402 [ITEM_GRE_S_BIT] = {
2404 .help = "sequence number bit (S)",
2405 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2406 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2408 "\x10\x00\x00\x00")),
2410 [ITEM_GRE_K_BIT] = {
2412 .help = "key bit (K)",
2413 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2414 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2416 "\x20\x00\x00\x00")),
2420 .help = "fuzzy pattern match, expect faster than default",
2421 .priv = PRIV_ITEM(FUZZY,
2422 sizeof(struct rte_flow_item_fuzzy)),
2423 .next = NEXT(item_fuzzy),
2426 [ITEM_FUZZY_THRESH] = {
2428 .help = "match accuracy threshold",
2429 .next = NEXT(item_fuzzy, NEXT_ENTRY(UNSIGNED), item_param),
2430 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_fuzzy,
2435 .help = "match GTP header",
2436 .priv = PRIV_ITEM(GTP, sizeof(struct rte_flow_item_gtp)),
2437 .next = NEXT(item_gtp),
2440 [ITEM_GTP_FLAGS] = {
2441 .name = "v_pt_rsv_flags",
2442 .help = "GTP flags",
2443 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2444 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp,
2447 [ITEM_GTP_MSG_TYPE] = {
2449 .help = "GTP message type",
2450 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2451 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp, msg_type)),
2455 .help = "tunnel endpoint identifier",
2456 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2457 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp, teid)),
2461 .help = "match GTP header",
2462 .priv = PRIV_ITEM(GTPC, sizeof(struct rte_flow_item_gtp)),
2463 .next = NEXT(item_gtp),
2468 .help = "match GTP header",
2469 .priv = PRIV_ITEM(GTPU, sizeof(struct rte_flow_item_gtp)),
2470 .next = NEXT(item_gtp),
2475 .help = "match GENEVE header",
2476 .priv = PRIV_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)),
2477 .next = NEXT(item_geneve),
2480 [ITEM_GENEVE_VNI] = {
2482 .help = "virtual network identifier",
2483 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2484 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve, vni)),
2486 [ITEM_GENEVE_PROTO] = {
2488 .help = "GENEVE protocol type",
2489 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2490 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve,
2493 [ITEM_VXLAN_GPE] = {
2494 .name = "vxlan-gpe",
2495 .help = "match VXLAN-GPE header",
2496 .priv = PRIV_ITEM(VXLAN_GPE,
2497 sizeof(struct rte_flow_item_vxlan_gpe)),
2498 .next = NEXT(item_vxlan_gpe),
2501 [ITEM_VXLAN_GPE_VNI] = {
2503 .help = "VXLAN-GPE identifier",
2504 .next = NEXT(item_vxlan_gpe, NEXT_ENTRY(UNSIGNED), item_param),
2505 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
2508 [ITEM_ARP_ETH_IPV4] = {
2509 .name = "arp_eth_ipv4",
2510 .help = "match ARP header for Ethernet/IPv4",
2511 .priv = PRIV_ITEM(ARP_ETH_IPV4,
2512 sizeof(struct rte_flow_item_arp_eth_ipv4)),
2513 .next = NEXT(item_arp_eth_ipv4),
2516 [ITEM_ARP_ETH_IPV4_SHA] = {
2518 .help = "sender hardware address",
2519 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(MAC_ADDR),
2521 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2524 [ITEM_ARP_ETH_IPV4_SPA] = {
2526 .help = "sender IPv4 address",
2527 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(IPV4_ADDR),
2529 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2532 [ITEM_ARP_ETH_IPV4_THA] = {
2534 .help = "target hardware address",
2535 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(MAC_ADDR),
2537 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2540 [ITEM_ARP_ETH_IPV4_TPA] = {
2542 .help = "target IPv4 address",
2543 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(IPV4_ADDR),
2545 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2550 .help = "match presence of any IPv6 extension header",
2551 .priv = PRIV_ITEM(IPV6_EXT,
2552 sizeof(struct rte_flow_item_ipv6_ext)),
2553 .next = NEXT(item_ipv6_ext),
2556 [ITEM_IPV6_EXT_NEXT_HDR] = {
2558 .help = "next header",
2559 .next = NEXT(item_ipv6_ext, NEXT_ENTRY(UNSIGNED), item_param),
2560 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_ext,
2565 .help = "match any ICMPv6 header",
2566 .priv = PRIV_ITEM(ICMP6, sizeof(struct rte_flow_item_icmp6)),
2567 .next = NEXT(item_icmp6),
2570 [ITEM_ICMP6_TYPE] = {
2572 .help = "ICMPv6 type",
2573 .next = NEXT(item_icmp6, NEXT_ENTRY(UNSIGNED), item_param),
2574 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
2577 [ITEM_ICMP6_CODE] = {
2579 .help = "ICMPv6 code",
2580 .next = NEXT(item_icmp6, NEXT_ENTRY(UNSIGNED), item_param),
2581 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
2584 [ITEM_ICMP6_ND_NS] = {
2585 .name = "icmp6_nd_ns",
2586 .help = "match ICMPv6 neighbor discovery solicitation",
2587 .priv = PRIV_ITEM(ICMP6_ND_NS,
2588 sizeof(struct rte_flow_item_icmp6_nd_ns)),
2589 .next = NEXT(item_icmp6_nd_ns),
2592 [ITEM_ICMP6_ND_NS_TARGET_ADDR] = {
2593 .name = "target_addr",
2594 .help = "target address",
2595 .next = NEXT(item_icmp6_nd_ns, NEXT_ENTRY(IPV6_ADDR),
2597 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_ns,
2600 [ITEM_ICMP6_ND_NA] = {
2601 .name = "icmp6_nd_na",
2602 .help = "match ICMPv6 neighbor discovery advertisement",
2603 .priv = PRIV_ITEM(ICMP6_ND_NA,
2604 sizeof(struct rte_flow_item_icmp6_nd_na)),
2605 .next = NEXT(item_icmp6_nd_na),
2608 [ITEM_ICMP6_ND_NA_TARGET_ADDR] = {
2609 .name = "target_addr",
2610 .help = "target address",
2611 .next = NEXT(item_icmp6_nd_na, NEXT_ENTRY(IPV6_ADDR),
2613 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_na,
2616 [ITEM_ICMP6_ND_OPT] = {
2617 .name = "icmp6_nd_opt",
2618 .help = "match presence of any ICMPv6 neighbor discovery"
2620 .priv = PRIV_ITEM(ICMP6_ND_OPT,
2621 sizeof(struct rte_flow_item_icmp6_nd_opt)),
2622 .next = NEXT(item_icmp6_nd_opt),
2625 [ITEM_ICMP6_ND_OPT_TYPE] = {
2627 .help = "ND option type",
2628 .next = NEXT(item_icmp6_nd_opt, NEXT_ENTRY(UNSIGNED),
2630 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_opt,
2633 [ITEM_ICMP6_ND_OPT_SLA_ETH] = {
2634 .name = "icmp6_nd_opt_sla_eth",
2635 .help = "match ICMPv6 neighbor discovery source Ethernet"
2636 " link-layer address option",
2638 (ICMP6_ND_OPT_SLA_ETH,
2639 sizeof(struct rte_flow_item_icmp6_nd_opt_sla_eth)),
2640 .next = NEXT(item_icmp6_nd_opt_sla_eth),
2643 [ITEM_ICMP6_ND_OPT_SLA_ETH_SLA] = {
2645 .help = "source Ethernet LLA",
2646 .next = NEXT(item_icmp6_nd_opt_sla_eth, NEXT_ENTRY(MAC_ADDR),
2648 .args = ARGS(ARGS_ENTRY_HTON
2649 (struct rte_flow_item_icmp6_nd_opt_sla_eth, sla)),
2651 [ITEM_ICMP6_ND_OPT_TLA_ETH] = {
2652 .name = "icmp6_nd_opt_tla_eth",
2653 .help = "match ICMPv6 neighbor discovery target Ethernet"
2654 " link-layer address option",
2656 (ICMP6_ND_OPT_TLA_ETH,
2657 sizeof(struct rte_flow_item_icmp6_nd_opt_tla_eth)),
2658 .next = NEXT(item_icmp6_nd_opt_tla_eth),
2661 [ITEM_ICMP6_ND_OPT_TLA_ETH_TLA] = {
2663 .help = "target Ethernet LLA",
2664 .next = NEXT(item_icmp6_nd_opt_tla_eth, NEXT_ENTRY(MAC_ADDR),
2666 .args = ARGS(ARGS_ENTRY_HTON
2667 (struct rte_flow_item_icmp6_nd_opt_tla_eth, tla)),
2671 .help = "match metadata header",
2672 .priv = PRIV_ITEM(META, sizeof(struct rte_flow_item_meta)),
2673 .next = NEXT(item_meta),
2676 [ITEM_META_DATA] = {
2678 .help = "metadata value",
2679 .next = NEXT(item_meta, NEXT_ENTRY(UNSIGNED), item_param),
2680 .args = ARGS(ARGS_ENTRY_MASK(struct rte_flow_item_meta,
2681 data, "\xff\xff\xff\xff")),
2685 .help = "match GRE key",
2686 .priv = PRIV_ITEM(GRE_KEY, sizeof(rte_be32_t)),
2687 .next = NEXT(item_gre_key),
2690 [ITEM_GRE_KEY_VALUE] = {
2692 .help = "key value",
2693 .next = NEXT(item_gre_key, NEXT_ENTRY(UNSIGNED), item_param),
2694 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
2698 .help = "match GTP extension header with type 0x85",
2699 .priv = PRIV_ITEM(GTP_PSC,
2700 sizeof(struct rte_flow_item_gtp_psc)),
2701 .next = NEXT(item_gtp_psc),
2704 [ITEM_GTP_PSC_QFI] = {
2706 .help = "QoS flow identifier",
2707 .next = NEXT(item_gtp_psc, NEXT_ENTRY(UNSIGNED), item_param),
2708 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
2711 [ITEM_GTP_PSC_PDU_T] = {
2714 .next = NEXT(item_gtp_psc, NEXT_ENTRY(UNSIGNED), item_param),
2715 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
2720 .help = "match PPPoE session header",
2721 .priv = PRIV_ITEM(PPPOES, sizeof(struct rte_flow_item_pppoe)),
2722 .next = NEXT(item_pppoes),
2727 .help = "match PPPoE discovery header",
2728 .priv = PRIV_ITEM(PPPOED, sizeof(struct rte_flow_item_pppoe)),
2729 .next = NEXT(item_pppoed),
2732 [ITEM_PPPOE_SEID] = {
2734 .help = "session identifier",
2735 .next = NEXT(item_pppoes, NEXT_ENTRY(UNSIGNED), item_param),
2736 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pppoe,
2739 [ITEM_PPPOE_PROTO_ID] = {
2740 .name = "pppoe_proto_id",
2741 .help = "match PPPoE session protocol identifier",
2742 .priv = PRIV_ITEM(PPPOE_PROTO_ID,
2743 sizeof(struct rte_flow_item_pppoe_proto_id)),
2744 .next = NEXT(item_pppoe_proto_id, NEXT_ENTRY(UNSIGNED),
2746 .args = ARGS(ARGS_ENTRY_HTON
2747 (struct rte_flow_item_pppoe_proto_id, proto_id)),
2752 .help = "matches higig2 header",
2753 .priv = PRIV_ITEM(HIGIG2,
2754 sizeof(struct rte_flow_item_higig2_hdr)),
2755 .next = NEXT(item_higig2),
2758 [ITEM_HIGIG2_CLASSIFICATION] = {
2759 .name = "classification",
2760 .help = "matches classification of higig2 header",
2761 .next = NEXT(item_higig2, NEXT_ENTRY(UNSIGNED), item_param),
2762 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
2763 hdr.ppt1.classification)),
2765 [ITEM_HIGIG2_VID] = {
2767 .help = "matches vid of higig2 header",
2768 .next = NEXT(item_higig2, NEXT_ENTRY(UNSIGNED), item_param),
2769 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
2774 .help = "match tag value",
2775 .priv = PRIV_ITEM(TAG, sizeof(struct rte_flow_item_tag)),
2776 .next = NEXT(item_tag),
2781 .help = "tag value to match",
2782 .next = NEXT(item_tag, NEXT_ENTRY(UNSIGNED), item_param),
2783 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, data)),
2785 [ITEM_TAG_INDEX] = {
2787 .help = "index of tag array to match",
2788 .next = NEXT(item_tag, NEXT_ENTRY(UNSIGNED),
2789 NEXT_ENTRY(ITEM_PARAM_IS)),
2790 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, index)),
2792 [ITEM_L2TPV3OIP] = {
2793 .name = "l2tpv3oip",
2794 .help = "match L2TPv3 over IP header",
2795 .priv = PRIV_ITEM(L2TPV3OIP,
2796 sizeof(struct rte_flow_item_l2tpv3oip)),
2797 .next = NEXT(item_l2tpv3oip),
2800 [ITEM_L2TPV3OIP_SESSION_ID] = {
2801 .name = "session_id",
2802 .help = "session identifier",
2803 .next = NEXT(item_l2tpv3oip, NEXT_ENTRY(UNSIGNED), item_param),
2804 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv3oip,
2809 .help = "match ESP header",
2810 .priv = PRIV_ITEM(ESP, sizeof(struct rte_flow_item_esp)),
2811 .next = NEXT(item_esp),
2816 .help = "security policy index",
2817 .next = NEXT(item_esp, NEXT_ENTRY(UNSIGNED), item_param),
2818 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_esp,
2823 .help = "match AH header",
2824 .priv = PRIV_ITEM(AH, sizeof(struct rte_flow_item_ah)),
2825 .next = NEXT(item_ah),
2830 .help = "security parameters index",
2831 .next = NEXT(item_ah, NEXT_ENTRY(UNSIGNED), item_param),
2832 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ah, spi)),
2836 .help = "match pfcp header",
2837 .priv = PRIV_ITEM(PFCP, sizeof(struct rte_flow_item_pfcp)),
2838 .next = NEXT(item_pfcp),
2841 [ITEM_PFCP_S_FIELD] = {
2844 .next = NEXT(item_pfcp, NEXT_ENTRY(UNSIGNED), item_param),
2845 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp,
2848 [ITEM_PFCP_SEID] = {
2850 .help = "session endpoint identifier",
2851 .next = NEXT(item_pfcp, NEXT_ENTRY(UNSIGNED), item_param),
2852 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp, seid)),
2856 .help = "match eCPRI header",
2857 .priv = PRIV_ITEM(ECPRI, sizeof(struct rte_flow_item_ecpri)),
2858 .next = NEXT(item_ecpri),
2861 [ITEM_ECPRI_COMMON] = {
2863 .help = "eCPRI common header",
2864 .next = NEXT(item_ecpri_common),
2866 [ITEM_ECPRI_COMMON_TYPE] = {
2868 .help = "type of common header",
2869 .next = NEXT(item_ecpri_common_type),
2870 .args = ARGS(ARG_ENTRY_HTON(struct rte_flow_item_ecpri)),
2872 [ITEM_ECPRI_COMMON_TYPE_IQ_DATA] = {
2874 .help = "Type #0: IQ Data",
2875 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
2877 .call = parse_vc_item_ecpri_type,
2879 [ITEM_ECPRI_MSG_IQ_DATA_PCID] = {
2881 .help = "Physical Channel ID",
2882 .next = NEXT(item_ecpri, NEXT_ENTRY(UNSIGNED), item_param),
2883 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
2886 [ITEM_ECPRI_COMMON_TYPE_RTC_CTRL] = {
2888 .help = "Type #2: Real-Time Control Data",
2889 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
2891 .call = parse_vc_item_ecpri_type,
2893 [ITEM_ECPRI_MSG_RTC_CTRL_RTCID] = {
2895 .help = "Real-Time Control Data ID",
2896 .next = NEXT(item_ecpri, NEXT_ENTRY(UNSIGNED), item_param),
2897 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
2900 [ITEM_ECPRI_COMMON_TYPE_DLY_MSR] = {
2901 .name = "delay_measure",
2902 .help = "Type #5: One-Way Delay Measurement",
2903 .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
2905 .call = parse_vc_item_ecpri_type,
2907 [ITEM_ECPRI_MSG_DLY_MSR_MSRID] = {
2909 .help = "Measurement ID",
2910 .next = NEXT(item_ecpri, NEXT_ENTRY(UNSIGNED), item_param),
2911 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
2914 /* Validate/create actions. */
2917 .help = "submit a list of associated actions",
2918 .next = NEXT(next_action),
2923 .help = "specify next action",
2924 .next = NEXT(next_action),
2928 .help = "end list of actions",
2929 .priv = PRIV_ACTION(END, 0),
2934 .help = "no-op action",
2935 .priv = PRIV_ACTION(VOID, 0),
2936 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
2939 [ACTION_PASSTHRU] = {
2941 .help = "let subsequent rule process matched packets",
2942 .priv = PRIV_ACTION(PASSTHRU, 0),
2943 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
2948 .help = "redirect traffic to a given group",
2949 .priv = PRIV_ACTION(JUMP, sizeof(struct rte_flow_action_jump)),
2950 .next = NEXT(action_jump),
2953 [ACTION_JUMP_GROUP] = {
2955 .help = "group to redirect traffic to",
2956 .next = NEXT(action_jump, NEXT_ENTRY(UNSIGNED)),
2957 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump, group)),
2958 .call = parse_vc_conf,
2962 .help = "attach 32 bit value to packets",
2963 .priv = PRIV_ACTION(MARK, sizeof(struct rte_flow_action_mark)),
2964 .next = NEXT(action_mark),
2967 [ACTION_MARK_ID] = {
2969 .help = "32 bit value to return with packets",
2970 .next = NEXT(action_mark, NEXT_ENTRY(UNSIGNED)),
2971 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_mark, id)),
2972 .call = parse_vc_conf,
2976 .help = "flag packets",
2977 .priv = PRIV_ACTION(FLAG, 0),
2978 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
2983 .help = "assign packets to a given queue index",
2984 .priv = PRIV_ACTION(QUEUE,
2985 sizeof(struct rte_flow_action_queue)),
2986 .next = NEXT(action_queue),
2989 [ACTION_QUEUE_INDEX] = {
2991 .help = "queue index to use",
2992 .next = NEXT(action_queue, NEXT_ENTRY(UNSIGNED)),
2993 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_queue, index)),
2994 .call = parse_vc_conf,
2998 .help = "drop packets (note: passthru has priority)",
2999 .priv = PRIV_ACTION(DROP, 0),
3000 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3005 .help = "enable counters for this rule",
3006 .priv = PRIV_ACTION(COUNT,
3007 sizeof(struct rte_flow_action_count)),
3008 .next = NEXT(action_count),
3011 [ACTION_COUNT_ID] = {
3012 .name = "identifier",
3013 .help = "counter identifier to use",
3014 .next = NEXT(action_count, NEXT_ENTRY(UNSIGNED)),
3015 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_count, id)),
3016 .call = parse_vc_conf,
3018 [ACTION_COUNT_SHARED] = {
3020 .help = "shared counter",
3021 .next = NEXT(action_count, NEXT_ENTRY(BOOLEAN)),
3022 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_count,
3024 .call = parse_vc_conf,
3028 .help = "spread packets among several queues",
3029 .priv = PRIV_ACTION(RSS, sizeof(struct action_rss_data)),
3030 .next = NEXT(action_rss),
3031 .call = parse_vc_action_rss,
3033 [ACTION_RSS_FUNC] = {
3035 .help = "RSS hash function to apply",
3036 .next = NEXT(action_rss,
3037 NEXT_ENTRY(ACTION_RSS_FUNC_DEFAULT,
3038 ACTION_RSS_FUNC_TOEPLITZ,
3039 ACTION_RSS_FUNC_SIMPLE_XOR,
3040 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ)),
3042 [ACTION_RSS_FUNC_DEFAULT] = {
3044 .help = "default hash function",
3045 .call = parse_vc_action_rss_func,
3047 [ACTION_RSS_FUNC_TOEPLITZ] = {
3049 .help = "Toeplitz hash function",
3050 .call = parse_vc_action_rss_func,
3052 [ACTION_RSS_FUNC_SIMPLE_XOR] = {
3053 .name = "simple_xor",
3054 .help = "simple XOR hash function",
3055 .call = parse_vc_action_rss_func,
3057 [ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ] = {
3058 .name = "symmetric_toeplitz",
3059 .help = "Symmetric Toeplitz hash function",
3060 .call = parse_vc_action_rss_func,
3062 [ACTION_RSS_LEVEL] = {
3064 .help = "encapsulation level for \"types\"",
3065 .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
3066 .args = ARGS(ARGS_ENTRY_ARB
3067 (offsetof(struct action_rss_data, conf) +
3068 offsetof(struct rte_flow_action_rss, level),
3069 sizeof(((struct rte_flow_action_rss *)0)->
3072 [ACTION_RSS_TYPES] = {
3074 .help = "specific RSS hash types",
3075 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)),
3077 [ACTION_RSS_TYPE] = {
3079 .help = "RSS hash type",
3080 .call = parse_vc_action_rss_type,
3081 .comp = comp_vc_action_rss_type,
3083 [ACTION_RSS_KEY] = {
3085 .help = "RSS hash key",
3086 .next = NEXT(action_rss, NEXT_ENTRY(HEX)),
3087 .args = ARGS(ARGS_ENTRY_ARB(0, 0),
3089 (offsetof(struct action_rss_data, conf) +
3090 offsetof(struct rte_flow_action_rss, key_len),
3091 sizeof(((struct rte_flow_action_rss *)0)->
3093 ARGS_ENTRY(struct action_rss_data, key)),
3095 [ACTION_RSS_KEY_LEN] = {
3097 .help = "RSS hash key length in bytes",
3098 .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
3099 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
3100 (offsetof(struct action_rss_data, conf) +
3101 offsetof(struct rte_flow_action_rss, key_len),
3102 sizeof(((struct rte_flow_action_rss *)0)->
3105 RSS_HASH_KEY_LENGTH)),
3107 [ACTION_RSS_QUEUES] = {
3109 .help = "queue indices to use",
3110 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_QUEUE)),
3111 .call = parse_vc_conf,
3113 [ACTION_RSS_QUEUE] = {
3115 .help = "queue index",
3116 .call = parse_vc_action_rss_queue,
3117 .comp = comp_vc_action_rss_queue,
3121 .help = "direct traffic to physical function",
3122 .priv = PRIV_ACTION(PF, 0),
3123 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3128 .help = "direct traffic to a virtual function ID",
3129 .priv = PRIV_ACTION(VF, sizeof(struct rte_flow_action_vf)),
3130 .next = NEXT(action_vf),
3133 [ACTION_VF_ORIGINAL] = {
3135 .help = "use original VF ID if possible",
3136 .next = NEXT(action_vf, NEXT_ENTRY(BOOLEAN)),
3137 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_vf,
3139 .call = parse_vc_conf,
3144 .next = NEXT(action_vf, NEXT_ENTRY(UNSIGNED)),
3145 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)),
3146 .call = parse_vc_conf,
3148 [ACTION_PHY_PORT] = {
3150 .help = "direct packets to physical port index",
3151 .priv = PRIV_ACTION(PHY_PORT,
3152 sizeof(struct rte_flow_action_phy_port)),
3153 .next = NEXT(action_phy_port),
3156 [ACTION_PHY_PORT_ORIGINAL] = {
3158 .help = "use original port index if possible",
3159 .next = NEXT(action_phy_port, NEXT_ENTRY(BOOLEAN)),
3160 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_phy_port,
3162 .call = parse_vc_conf,
3164 [ACTION_PHY_PORT_INDEX] = {
3166 .help = "physical port index",
3167 .next = NEXT(action_phy_port, NEXT_ENTRY(UNSIGNED)),
3168 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_phy_port,
3170 .call = parse_vc_conf,
3172 [ACTION_PORT_ID] = {
3174 .help = "direct matching traffic to a given DPDK port ID",
3175 .priv = PRIV_ACTION(PORT_ID,
3176 sizeof(struct rte_flow_action_port_id)),
3177 .next = NEXT(action_port_id),
3180 [ACTION_PORT_ID_ORIGINAL] = {
3182 .help = "use original DPDK port ID if possible",
3183 .next = NEXT(action_port_id, NEXT_ENTRY(BOOLEAN)),
3184 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_port_id,
3186 .call = parse_vc_conf,
3188 [ACTION_PORT_ID_ID] = {
3190 .help = "DPDK port ID",
3191 .next = NEXT(action_port_id, NEXT_ENTRY(UNSIGNED)),
3192 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_port_id, id)),
3193 .call = parse_vc_conf,
3197 .help = "meter the directed packets at given id",
3198 .priv = PRIV_ACTION(METER,
3199 sizeof(struct rte_flow_action_meter)),
3200 .next = NEXT(action_meter),
3203 [ACTION_METER_ID] = {
3205 .help = "meter id to use",
3206 .next = NEXT(action_meter, NEXT_ENTRY(UNSIGNED)),
3207 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter, mtr_id)),
3208 .call = parse_vc_conf,
3210 [ACTION_OF_SET_MPLS_TTL] = {
3211 .name = "of_set_mpls_ttl",
3212 .help = "OpenFlow's OFPAT_SET_MPLS_TTL",
3215 sizeof(struct rte_flow_action_of_set_mpls_ttl)),
3216 .next = NEXT(action_of_set_mpls_ttl),
3219 [ACTION_OF_SET_MPLS_TTL_MPLS_TTL] = {
3222 .next = NEXT(action_of_set_mpls_ttl, NEXT_ENTRY(UNSIGNED)),
3223 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_mpls_ttl,
3225 .call = parse_vc_conf,
3227 [ACTION_OF_DEC_MPLS_TTL] = {
3228 .name = "of_dec_mpls_ttl",
3229 .help = "OpenFlow's OFPAT_DEC_MPLS_TTL",
3230 .priv = PRIV_ACTION(OF_DEC_MPLS_TTL, 0),
3231 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3234 [ACTION_OF_SET_NW_TTL] = {
3235 .name = "of_set_nw_ttl",
3236 .help = "OpenFlow's OFPAT_SET_NW_TTL",
3239 sizeof(struct rte_flow_action_of_set_nw_ttl)),
3240 .next = NEXT(action_of_set_nw_ttl),
3243 [ACTION_OF_SET_NW_TTL_NW_TTL] = {
3246 .next = NEXT(action_of_set_nw_ttl, NEXT_ENTRY(UNSIGNED)),
3247 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_nw_ttl,
3249 .call = parse_vc_conf,
3251 [ACTION_OF_DEC_NW_TTL] = {
3252 .name = "of_dec_nw_ttl",
3253 .help = "OpenFlow's OFPAT_DEC_NW_TTL",
3254 .priv = PRIV_ACTION(OF_DEC_NW_TTL, 0),
3255 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3258 [ACTION_OF_COPY_TTL_OUT] = {
3259 .name = "of_copy_ttl_out",
3260 .help = "OpenFlow's OFPAT_COPY_TTL_OUT",
3261 .priv = PRIV_ACTION(OF_COPY_TTL_OUT, 0),
3262 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3265 [ACTION_OF_COPY_TTL_IN] = {
3266 .name = "of_copy_ttl_in",
3267 .help = "OpenFlow's OFPAT_COPY_TTL_IN",
3268 .priv = PRIV_ACTION(OF_COPY_TTL_IN, 0),
3269 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3272 [ACTION_OF_POP_VLAN] = {
3273 .name = "of_pop_vlan",
3274 .help = "OpenFlow's OFPAT_POP_VLAN",
3275 .priv = PRIV_ACTION(OF_POP_VLAN, 0),
3276 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3279 [ACTION_OF_PUSH_VLAN] = {
3280 .name = "of_push_vlan",
3281 .help = "OpenFlow's OFPAT_PUSH_VLAN",
3284 sizeof(struct rte_flow_action_of_push_vlan)),
3285 .next = NEXT(action_of_push_vlan),
3288 [ACTION_OF_PUSH_VLAN_ETHERTYPE] = {
3289 .name = "ethertype",
3290 .help = "EtherType",
3291 .next = NEXT(action_of_push_vlan, NEXT_ENTRY(UNSIGNED)),
3292 .args = ARGS(ARGS_ENTRY_HTON
3293 (struct rte_flow_action_of_push_vlan,
3295 .call = parse_vc_conf,
3297 [ACTION_OF_SET_VLAN_VID] = {
3298 .name = "of_set_vlan_vid",
3299 .help = "OpenFlow's OFPAT_SET_VLAN_VID",
3302 sizeof(struct rte_flow_action_of_set_vlan_vid)),
3303 .next = NEXT(action_of_set_vlan_vid),
3306 [ACTION_OF_SET_VLAN_VID_VLAN_VID] = {
3309 .next = NEXT(action_of_set_vlan_vid, NEXT_ENTRY(UNSIGNED)),
3310 .args = ARGS(ARGS_ENTRY_HTON
3311 (struct rte_flow_action_of_set_vlan_vid,
3313 .call = parse_vc_conf,
3315 [ACTION_OF_SET_VLAN_PCP] = {
3316 .name = "of_set_vlan_pcp",
3317 .help = "OpenFlow's OFPAT_SET_VLAN_PCP",
3320 sizeof(struct rte_flow_action_of_set_vlan_pcp)),
3321 .next = NEXT(action_of_set_vlan_pcp),
3324 [ACTION_OF_SET_VLAN_PCP_VLAN_PCP] = {
3326 .help = "VLAN priority",
3327 .next = NEXT(action_of_set_vlan_pcp, NEXT_ENTRY(UNSIGNED)),
3328 .args = ARGS(ARGS_ENTRY_HTON
3329 (struct rte_flow_action_of_set_vlan_pcp,
3331 .call = parse_vc_conf,
3333 [ACTION_OF_POP_MPLS] = {
3334 .name = "of_pop_mpls",
3335 .help = "OpenFlow's OFPAT_POP_MPLS",
3336 .priv = PRIV_ACTION(OF_POP_MPLS,
3337 sizeof(struct rte_flow_action_of_pop_mpls)),
3338 .next = NEXT(action_of_pop_mpls),
3341 [ACTION_OF_POP_MPLS_ETHERTYPE] = {
3342 .name = "ethertype",
3343 .help = "EtherType",
3344 .next = NEXT(action_of_pop_mpls, NEXT_ENTRY(UNSIGNED)),
3345 .args = ARGS(ARGS_ENTRY_HTON
3346 (struct rte_flow_action_of_pop_mpls,
3348 .call = parse_vc_conf,
3350 [ACTION_OF_PUSH_MPLS] = {
3351 .name = "of_push_mpls",
3352 .help = "OpenFlow's OFPAT_PUSH_MPLS",
3355 sizeof(struct rte_flow_action_of_push_mpls)),
3356 .next = NEXT(action_of_push_mpls),
3359 [ACTION_OF_PUSH_MPLS_ETHERTYPE] = {
3360 .name = "ethertype",
3361 .help = "EtherType",
3362 .next = NEXT(action_of_push_mpls, NEXT_ENTRY(UNSIGNED)),
3363 .args = ARGS(ARGS_ENTRY_HTON
3364 (struct rte_flow_action_of_push_mpls,
3366 .call = parse_vc_conf,
3368 [ACTION_VXLAN_ENCAP] = {
3369 .name = "vxlan_encap",
3370 .help = "VXLAN encapsulation, uses configuration set by \"set"
3372 .priv = PRIV_ACTION(VXLAN_ENCAP,
3373 sizeof(struct action_vxlan_encap_data)),
3374 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3375 .call = parse_vc_action_vxlan_encap,
3377 [ACTION_VXLAN_DECAP] = {
3378 .name = "vxlan_decap",
3379 .help = "Performs a decapsulation action by stripping all"
3380 " headers of the VXLAN tunnel network overlay from the"
3382 .priv = PRIV_ACTION(VXLAN_DECAP, 0),
3383 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3386 [ACTION_NVGRE_ENCAP] = {
3387 .name = "nvgre_encap",
3388 .help = "NVGRE encapsulation, uses configuration set by \"set"
3390 .priv = PRIV_ACTION(NVGRE_ENCAP,
3391 sizeof(struct action_nvgre_encap_data)),
3392 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3393 .call = parse_vc_action_nvgre_encap,
3395 [ACTION_NVGRE_DECAP] = {
3396 .name = "nvgre_decap",
3397 .help = "Performs a decapsulation action by stripping all"
3398 " headers of the NVGRE tunnel network overlay from the"
3400 .priv = PRIV_ACTION(NVGRE_DECAP, 0),
3401 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3404 [ACTION_L2_ENCAP] = {
3406 .help = "l2 encap, uses configuration set by"
3407 " \"set l2_encap\"",
3408 .priv = PRIV_ACTION(RAW_ENCAP,
3409 sizeof(struct action_raw_encap_data)),
3410 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3411 .call = parse_vc_action_l2_encap,
3413 [ACTION_L2_DECAP] = {
3415 .help = "l2 decap, uses configuration set by"
3416 " \"set l2_decap\"",
3417 .priv = PRIV_ACTION(RAW_DECAP,
3418 sizeof(struct action_raw_decap_data)),
3419 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3420 .call = parse_vc_action_l2_decap,
3422 [ACTION_MPLSOGRE_ENCAP] = {
3423 .name = "mplsogre_encap",
3424 .help = "mplsogre encapsulation, uses configuration set by"
3425 " \"set mplsogre_encap\"",
3426 .priv = PRIV_ACTION(RAW_ENCAP,
3427 sizeof(struct action_raw_encap_data)),
3428 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3429 .call = parse_vc_action_mplsogre_encap,
3431 [ACTION_MPLSOGRE_DECAP] = {
3432 .name = "mplsogre_decap",
3433 .help = "mplsogre decapsulation, uses configuration set by"
3434 " \"set mplsogre_decap\"",
3435 .priv = PRIV_ACTION(RAW_DECAP,
3436 sizeof(struct action_raw_decap_data)),
3437 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3438 .call = parse_vc_action_mplsogre_decap,
3440 [ACTION_MPLSOUDP_ENCAP] = {
3441 .name = "mplsoudp_encap",
3442 .help = "mplsoudp encapsulation, uses configuration set by"
3443 " \"set mplsoudp_encap\"",
3444 .priv = PRIV_ACTION(RAW_ENCAP,
3445 sizeof(struct action_raw_encap_data)),
3446 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3447 .call = parse_vc_action_mplsoudp_encap,
3449 [ACTION_MPLSOUDP_DECAP] = {
3450 .name = "mplsoudp_decap",
3451 .help = "mplsoudp decapsulation, uses configuration set by"
3452 " \"set mplsoudp_decap\"",
3453 .priv = PRIV_ACTION(RAW_DECAP,
3454 sizeof(struct action_raw_decap_data)),
3455 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3456 .call = parse_vc_action_mplsoudp_decap,
3458 [ACTION_SET_IPV4_SRC] = {
3459 .name = "set_ipv4_src",
3460 .help = "Set a new IPv4 source address in the outermost"
3462 .priv = PRIV_ACTION(SET_IPV4_SRC,
3463 sizeof(struct rte_flow_action_set_ipv4)),
3464 .next = NEXT(action_set_ipv4_src),
3467 [ACTION_SET_IPV4_SRC_IPV4_SRC] = {
3468 .name = "ipv4_addr",
3469 .help = "new IPv4 source address to set",
3470 .next = NEXT(action_set_ipv4_src, NEXT_ENTRY(IPV4_ADDR)),
3471 .args = ARGS(ARGS_ENTRY_HTON
3472 (struct rte_flow_action_set_ipv4, ipv4_addr)),
3473 .call = parse_vc_conf,
3475 [ACTION_SET_IPV4_DST] = {
3476 .name = "set_ipv4_dst",
3477 .help = "Set a new IPv4 destination address in the outermost"
3479 .priv = PRIV_ACTION(SET_IPV4_DST,
3480 sizeof(struct rte_flow_action_set_ipv4)),
3481 .next = NEXT(action_set_ipv4_dst),
3484 [ACTION_SET_IPV4_DST_IPV4_DST] = {
3485 .name = "ipv4_addr",
3486 .help = "new IPv4 destination address to set",
3487 .next = NEXT(action_set_ipv4_dst, NEXT_ENTRY(IPV4_ADDR)),
3488 .args = ARGS(ARGS_ENTRY_HTON
3489 (struct rte_flow_action_set_ipv4, ipv4_addr)),
3490 .call = parse_vc_conf,
3492 [ACTION_SET_IPV6_SRC] = {
3493 .name = "set_ipv6_src",
3494 .help = "Set a new IPv6 source address in the outermost"
3496 .priv = PRIV_ACTION(SET_IPV6_SRC,
3497 sizeof(struct rte_flow_action_set_ipv6)),
3498 .next = NEXT(action_set_ipv6_src),
3501 [ACTION_SET_IPV6_SRC_IPV6_SRC] = {
3502 .name = "ipv6_addr",
3503 .help = "new IPv6 source address to set",
3504 .next = NEXT(action_set_ipv6_src, NEXT_ENTRY(IPV6_ADDR)),
3505 .args = ARGS(ARGS_ENTRY_HTON
3506 (struct rte_flow_action_set_ipv6, ipv6_addr)),
3507 .call = parse_vc_conf,
3509 [ACTION_SET_IPV6_DST] = {
3510 .name = "set_ipv6_dst",
3511 .help = "Set a new IPv6 destination address in the outermost"
3513 .priv = PRIV_ACTION(SET_IPV6_DST,
3514 sizeof(struct rte_flow_action_set_ipv6)),
3515 .next = NEXT(action_set_ipv6_dst),
3518 [ACTION_SET_IPV6_DST_IPV6_DST] = {
3519 .name = "ipv6_addr",
3520 .help = "new IPv6 destination address to set",
3521 .next = NEXT(action_set_ipv6_dst, NEXT_ENTRY(IPV6_ADDR)),
3522 .args = ARGS(ARGS_ENTRY_HTON
3523 (struct rte_flow_action_set_ipv6, ipv6_addr)),
3524 .call = parse_vc_conf,
3526 [ACTION_SET_TP_SRC] = {
3527 .name = "set_tp_src",
3528 .help = "set a new source port number in the outermost"
3530 .priv = PRIV_ACTION(SET_TP_SRC,
3531 sizeof(struct rte_flow_action_set_tp)),
3532 .next = NEXT(action_set_tp_src),
3535 [ACTION_SET_TP_SRC_TP_SRC] = {
3537 .help = "new source port number to set",
3538 .next = NEXT(action_set_tp_src, NEXT_ENTRY(UNSIGNED)),
3539 .args = ARGS(ARGS_ENTRY_HTON
3540 (struct rte_flow_action_set_tp, port)),
3541 .call = parse_vc_conf,
3543 [ACTION_SET_TP_DST] = {
3544 .name = "set_tp_dst",
3545 .help = "set a new destination port number in the outermost"
3547 .priv = PRIV_ACTION(SET_TP_DST,
3548 sizeof(struct rte_flow_action_set_tp)),
3549 .next = NEXT(action_set_tp_dst),
3552 [ACTION_SET_TP_DST_TP_DST] = {
3554 .help = "new destination port number to set",
3555 .next = NEXT(action_set_tp_dst, NEXT_ENTRY(UNSIGNED)),
3556 .args = ARGS(ARGS_ENTRY_HTON
3557 (struct rte_flow_action_set_tp, port)),
3558 .call = parse_vc_conf,
3560 [ACTION_MAC_SWAP] = {
3562 .help = "Swap the source and destination MAC addresses"
3563 " in the outermost Ethernet header",
3564 .priv = PRIV_ACTION(MAC_SWAP, 0),
3565 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3568 [ACTION_DEC_TTL] = {
3570 .help = "decrease network TTL if available",
3571 .priv = PRIV_ACTION(DEC_TTL, 0),
3572 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3575 [ACTION_SET_TTL] = {
3577 .help = "set ttl value",
3578 .priv = PRIV_ACTION(SET_TTL,
3579 sizeof(struct rte_flow_action_set_ttl)),
3580 .next = NEXT(action_set_ttl),
3583 [ACTION_SET_TTL_TTL] = {
3584 .name = "ttl_value",
3585 .help = "new ttl value to set",
3586 .next = NEXT(action_set_ttl, NEXT_ENTRY(UNSIGNED)),
3587 .args = ARGS(ARGS_ENTRY_HTON
3588 (struct rte_flow_action_set_ttl, ttl_value)),
3589 .call = parse_vc_conf,
3591 [ACTION_SET_MAC_SRC] = {
3592 .name = "set_mac_src",
3593 .help = "set source mac address",
3594 .priv = PRIV_ACTION(SET_MAC_SRC,
3595 sizeof(struct rte_flow_action_set_mac)),
3596 .next = NEXT(action_set_mac_src),
3599 [ACTION_SET_MAC_SRC_MAC_SRC] = {
3601 .help = "new source mac address",
3602 .next = NEXT(action_set_mac_src, NEXT_ENTRY(MAC_ADDR)),
3603 .args = ARGS(ARGS_ENTRY_HTON
3604 (struct rte_flow_action_set_mac, mac_addr)),
3605 .call = parse_vc_conf,
3607 [ACTION_SET_MAC_DST] = {
3608 .name = "set_mac_dst",
3609 .help = "set destination mac address",
3610 .priv = PRIV_ACTION(SET_MAC_DST,
3611 sizeof(struct rte_flow_action_set_mac)),
3612 .next = NEXT(action_set_mac_dst),
3615 [ACTION_SET_MAC_DST_MAC_DST] = {
3617 .help = "new destination mac address to set",
3618 .next = NEXT(action_set_mac_dst, NEXT_ENTRY(MAC_ADDR)),
3619 .args = ARGS(ARGS_ENTRY_HTON
3620 (struct rte_flow_action_set_mac, mac_addr)),
3621 .call = parse_vc_conf,
3623 [ACTION_INC_TCP_SEQ] = {
3624 .name = "inc_tcp_seq",
3625 .help = "increase TCP sequence number",
3626 .priv = PRIV_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
3627 .next = NEXT(action_inc_tcp_seq),
3630 [ACTION_INC_TCP_SEQ_VALUE] = {
3632 .help = "the value to increase TCP sequence number by",
3633 .next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(UNSIGNED)),
3634 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3635 .call = parse_vc_conf,
3637 [ACTION_DEC_TCP_SEQ] = {
3638 .name = "dec_tcp_seq",
3639 .help = "decrease TCP sequence number",
3640 .priv = PRIV_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
3641 .next = NEXT(action_dec_tcp_seq),
3644 [ACTION_DEC_TCP_SEQ_VALUE] = {
3646 .help = "the value to decrease TCP sequence number by",
3647 .next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(UNSIGNED)),
3648 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3649 .call = parse_vc_conf,
3651 [ACTION_INC_TCP_ACK] = {
3652 .name = "inc_tcp_ack",
3653 .help = "increase TCP acknowledgment number",
3654 .priv = PRIV_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
3655 .next = NEXT(action_inc_tcp_ack),
3658 [ACTION_INC_TCP_ACK_VALUE] = {
3660 .help = "the value to increase TCP acknowledgment number by",
3661 .next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(UNSIGNED)),
3662 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3663 .call = parse_vc_conf,
3665 [ACTION_DEC_TCP_ACK] = {
3666 .name = "dec_tcp_ack",
3667 .help = "decrease TCP acknowledgment number",
3668 .priv = PRIV_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
3669 .next = NEXT(action_dec_tcp_ack),
3672 [ACTION_DEC_TCP_ACK_VALUE] = {
3674 .help = "the value to decrease TCP acknowledgment number by",
3675 .next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(UNSIGNED)),
3676 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3677 .call = parse_vc_conf,
3679 [ACTION_RAW_ENCAP] = {
3680 .name = "raw_encap",
3681 .help = "encapsulation data, defined by set raw_encap",
3682 .priv = PRIV_ACTION(RAW_ENCAP,
3683 sizeof(struct action_raw_encap_data)),
3684 .next = NEXT(action_raw_encap),
3685 .call = parse_vc_action_raw_encap,
3687 [ACTION_RAW_ENCAP_INDEX] = {
3689 .help = "the index of raw_encap_confs",
3690 .next = NEXT(NEXT_ENTRY(ACTION_RAW_ENCAP_INDEX_VALUE)),
3692 [ACTION_RAW_ENCAP_INDEX_VALUE] = {
3695 .help = "unsigned integer value",
3696 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3697 .call = parse_vc_action_raw_encap_index,
3698 .comp = comp_set_raw_index,
3700 [ACTION_RAW_DECAP] = {
3701 .name = "raw_decap",
3702 .help = "decapsulation data, defined by set raw_encap",
3703 .priv = PRIV_ACTION(RAW_DECAP,
3704 sizeof(struct action_raw_decap_data)),
3705 .next = NEXT(action_raw_decap),
3706 .call = parse_vc_action_raw_decap,
3708 [ACTION_RAW_DECAP_INDEX] = {
3710 .help = "the index of raw_encap_confs",
3711 .next = NEXT(NEXT_ENTRY(ACTION_RAW_DECAP_INDEX_VALUE)),
3713 [ACTION_RAW_DECAP_INDEX_VALUE] = {
3716 .help = "unsigned integer value",
3717 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3718 .call = parse_vc_action_raw_decap_index,
3719 .comp = comp_set_raw_index,
3721 /* Top level command. */
3724 .help = "set raw encap/decap data",
3725 .type = "set raw_encap|raw_decap <index> <pattern>",
3726 .next = NEXT(NEXT_ENTRY
3729 .call = parse_set_init,
3731 /* Sub-level commands. */
3733 .name = "raw_encap",
3734 .help = "set raw encap data",
3735 .next = NEXT(next_set_raw),
3736 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
3737 (offsetof(struct buffer, port),
3738 sizeof(((struct buffer *)0)->port),
3739 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
3740 .call = parse_set_raw_encap_decap,
3743 .name = "raw_decap",
3744 .help = "set raw decap data",
3745 .next = NEXT(next_set_raw),
3746 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
3747 (offsetof(struct buffer, port),
3748 sizeof(((struct buffer *)0)->port),
3749 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
3750 .call = parse_set_raw_encap_decap,
3755 .help = "index of raw_encap/raw_decap data",
3756 .next = NEXT(next_item),
3759 [ACTION_SET_TAG] = {
3762 .priv = PRIV_ACTION(SET_TAG,
3763 sizeof(struct rte_flow_action_set_tag)),
3764 .next = NEXT(action_set_tag),
3767 [ACTION_SET_TAG_INDEX] = {
3769 .help = "index of tag array",
3770 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
3771 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_set_tag, index)),
3772 .call = parse_vc_conf,
3774 [ACTION_SET_TAG_DATA] = {
3776 .help = "tag value",
3777 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
3778 .args = ARGS(ARGS_ENTRY
3779 (struct rte_flow_action_set_tag, data)),
3780 .call = parse_vc_conf,
3782 [ACTION_SET_TAG_MASK] = {
3784 .help = "mask for tag value",
3785 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
3786 .args = ARGS(ARGS_ENTRY
3787 (struct rte_flow_action_set_tag, mask)),
3788 .call = parse_vc_conf,
3790 [ACTION_SET_META] = {
3792 .help = "set metadata",
3793 .priv = PRIV_ACTION(SET_META,
3794 sizeof(struct rte_flow_action_set_meta)),
3795 .next = NEXT(action_set_meta),
3796 .call = parse_vc_action_set_meta,
3798 [ACTION_SET_META_DATA] = {
3800 .help = "metadata value",
3801 .next = NEXT(action_set_meta, NEXT_ENTRY(UNSIGNED)),
3802 .args = ARGS(ARGS_ENTRY
3803 (struct rte_flow_action_set_meta, data)),
3804 .call = parse_vc_conf,
3806 [ACTION_SET_META_MASK] = {
3808 .help = "mask for metadata value",
3809 .next = NEXT(action_set_meta, NEXT_ENTRY(UNSIGNED)),
3810 .args = ARGS(ARGS_ENTRY
3811 (struct rte_flow_action_set_meta, mask)),
3812 .call = parse_vc_conf,
3814 [ACTION_SET_IPV4_DSCP] = {
3815 .name = "set_ipv4_dscp",
3816 .help = "set DSCP value",
3817 .priv = PRIV_ACTION(SET_IPV4_DSCP,
3818 sizeof(struct rte_flow_action_set_dscp)),
3819 .next = NEXT(action_set_ipv4_dscp),
3822 [ACTION_SET_IPV4_DSCP_VALUE] = {
3823 .name = "dscp_value",
3824 .help = "new IPv4 DSCP value to set",
3825 .next = NEXT(action_set_ipv4_dscp, NEXT_ENTRY(UNSIGNED)),
3826 .args = ARGS(ARGS_ENTRY
3827 (struct rte_flow_action_set_dscp, dscp)),
3828 .call = parse_vc_conf,
3830 [ACTION_SET_IPV6_DSCP] = {
3831 .name = "set_ipv6_dscp",
3832 .help = "set DSCP value",
3833 .priv = PRIV_ACTION(SET_IPV6_DSCP,
3834 sizeof(struct rte_flow_action_set_dscp)),
3835 .next = NEXT(action_set_ipv6_dscp),
3838 [ACTION_SET_IPV6_DSCP_VALUE] = {
3839 .name = "dscp_value",
3840 .help = "new IPv6 DSCP value to set",
3841 .next = NEXT(action_set_ipv6_dscp, NEXT_ENTRY(UNSIGNED)),
3842 .args = ARGS(ARGS_ENTRY
3843 (struct rte_flow_action_set_dscp, dscp)),
3844 .call = parse_vc_conf,
3848 .help = "set a specific metadata header",
3849 .next = NEXT(action_age),
3850 .priv = PRIV_ACTION(AGE,
3851 sizeof(struct rte_flow_action_age)),
3854 [ACTION_AGE_TIMEOUT] = {
3856 .help = "flow age timeout value",
3857 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_age,
3859 .next = NEXT(action_age, NEXT_ENTRY(UNSIGNED)),
3860 .call = parse_vc_conf,
3864 /** Remove and return last entry from argument stack. */
3865 static const struct arg *
3866 pop_args(struct context *ctx)
3868 return ctx->args_num ? ctx->args[--ctx->args_num] : NULL;
3871 /** Add entry on top of the argument stack. */
3873 push_args(struct context *ctx, const struct arg *arg)
3875 if (ctx->args_num == CTX_STACK_SIZE)
3877 ctx->args[ctx->args_num++] = arg;
3881 /** Spread value into buffer according to bit-mask. */
3883 arg_entry_bf_fill(void *dst, uintmax_t val, const struct arg *arg)
3885 uint32_t i = arg->size;
3893 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
3902 unsigned int shift = 0;
3903 uint8_t *buf = (uint8_t *)dst + arg->offset + (i -= sub);
3905 for (shift = 0; arg->mask[i] >> shift; ++shift) {
3906 if (!(arg->mask[i] & (1 << shift)))
3911 *buf &= ~(1 << shift);
3912 *buf |= (val & 1) << shift;
3920 /** Compare a string with a partial one of a given length. */
3922 strcmp_partial(const char *full, const char *partial, size_t partial_len)
3924 int r = strncmp(full, partial, partial_len);
3928 if (strlen(full) <= partial_len)
3930 return full[partial_len];
3934 * Parse a prefix length and generate a bit-mask.
3936 * Last argument (ctx->args) is retrieved to determine mask size, storage
3937 * location and whether the result must use network byte ordering.
3940 parse_prefix(struct context *ctx, const struct token *token,
3941 const char *str, unsigned int len,
3942 void *buf, unsigned int size)
3944 const struct arg *arg = pop_args(ctx);
3945 static const uint8_t conv[] = "\x00\x80\xc0\xe0\xf0\xf8\xfc\xfe\xff";
3952 /* Argument is expected. */
3956 u = strtoumax(str, &end, 0);
3957 if (errno || (size_t)(end - str) != len)
3962 extra = arg_entry_bf_fill(NULL, 0, arg);
3971 if (!arg_entry_bf_fill(ctx->object, v, arg) ||
3972 !arg_entry_bf_fill(ctx->objmask, -1, arg))
3979 if (bytes > size || bytes + !!extra > size)
3983 buf = (uint8_t *)ctx->object + arg->offset;
3984 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
3986 memset((uint8_t *)buf + size - bytes, 0xff, bytes);
3987 memset(buf, 0x00, size - bytes);
3989 ((uint8_t *)buf)[size - bytes - 1] = conv[extra];
3993 memset(buf, 0xff, bytes);
3994 memset((uint8_t *)buf + bytes, 0x00, size - bytes);
3996 ((uint8_t *)buf)[bytes] = conv[extra];
3999 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
4002 push_args(ctx, arg);
4006 /** Default parsing function for token name matching. */
4008 parse_default(struct context *ctx, const struct token *token,
4009 const char *str, unsigned int len,
4010 void *buf, unsigned int size)
4015 if (strcmp_partial(token->name, str, len))
4020 /** Parse flow command, initialize output buffer for subsequent tokens. */
4022 parse_init(struct context *ctx, const struct token *token,
4023 const char *str, unsigned int len,
4024 void *buf, unsigned int size)
4026 struct buffer *out = buf;
4028 /* Token name must match. */
4029 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4031 /* Nothing else to do if there is no buffer. */
4034 /* Make sure buffer is large enough. */
4035 if (size < sizeof(*out))
4037 /* Initialize buffer. */
4038 memset(out, 0x00, sizeof(*out));
4039 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
4042 ctx->objmask = NULL;
4046 /** Parse tokens for validate/create commands. */
4048 parse_vc(struct context *ctx, const struct token *token,
4049 const char *str, unsigned int len,
4050 void *buf, unsigned int size)
4052 struct buffer *out = buf;
4056 /* Token name must match. */
4057 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4059 /* Nothing else to do if there is no buffer. */
4062 if (!out->command) {
4063 if (ctx->curr != VALIDATE && ctx->curr != CREATE)
4065 if (sizeof(*out) > size)
4067 out->command = ctx->curr;
4070 ctx->objmask = NULL;
4071 out->args.vc.data = (uint8_t *)out + size;
4075 ctx->object = &out->args.vc.attr;
4076 ctx->objmask = NULL;
4077 switch (ctx->curr) {
4082 out->args.vc.attr.ingress = 1;
4085 out->args.vc.attr.egress = 1;
4088 out->args.vc.attr.transfer = 1;
4091 out->args.vc.pattern =
4092 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
4094 ctx->object = out->args.vc.pattern;
4095 ctx->objmask = NULL;
4098 out->args.vc.actions =
4099 (void *)RTE_ALIGN_CEIL((uintptr_t)
4100 (out->args.vc.pattern +
4101 out->args.vc.pattern_n),
4103 ctx->object = out->args.vc.actions;
4104 ctx->objmask = NULL;
4111 if (!out->args.vc.actions) {
4112 const struct parse_item_priv *priv = token->priv;
4113 struct rte_flow_item *item =
4114 out->args.vc.pattern + out->args.vc.pattern_n;
4116 data_size = priv->size * 3; /* spec, last, mask */
4117 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
4118 (out->args.vc.data - data_size),
4120 if ((uint8_t *)item + sizeof(*item) > data)
4122 *item = (struct rte_flow_item){
4125 ++out->args.vc.pattern_n;
4127 ctx->objmask = NULL;
4129 const struct parse_action_priv *priv = token->priv;
4130 struct rte_flow_action *action =
4131 out->args.vc.actions + out->args.vc.actions_n;
4133 data_size = priv->size; /* configuration */
4134 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
4135 (out->args.vc.data - data_size),
4137 if ((uint8_t *)action + sizeof(*action) > data)
4139 *action = (struct rte_flow_action){
4141 .conf = data_size ? data : NULL,
4143 ++out->args.vc.actions_n;
4144 ctx->object = action;
4145 ctx->objmask = NULL;
4147 memset(data, 0, data_size);
4148 out->args.vc.data = data;
4149 ctx->objdata = data_size;
4153 /** Parse pattern item parameter type. */
4155 parse_vc_spec(struct context *ctx, const struct token *token,
4156 const char *str, unsigned int len,
4157 void *buf, unsigned int size)
4159 struct buffer *out = buf;
4160 struct rte_flow_item *item;
4166 /* Token name must match. */
4167 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4169 /* Parse parameter types. */
4170 switch (ctx->curr) {
4171 static const enum index prefix[] = NEXT_ENTRY(PREFIX);
4177 case ITEM_PARAM_SPEC:
4180 case ITEM_PARAM_LAST:
4183 case ITEM_PARAM_PREFIX:
4184 /* Modify next token to expect a prefix. */
4185 if (ctx->next_num < 2)
4187 ctx->next[ctx->next_num - 2] = prefix;
4189 case ITEM_PARAM_MASK:
4195 /* Nothing else to do if there is no buffer. */
4198 if (!out->args.vc.pattern_n)
4200 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
4201 data_size = ctx->objdata / 3; /* spec, last, mask */
4202 /* Point to selected object. */
4203 ctx->object = out->args.vc.data + (data_size * index);
4205 ctx->objmask = out->args.vc.data + (data_size * 2); /* mask */
4206 item->mask = ctx->objmask;
4208 ctx->objmask = NULL;
4209 /* Update relevant item pointer. */
4210 *((const void **[]){ &item->spec, &item->last, &item->mask })[index] =
4215 /** Parse action configuration field. */
4217 parse_vc_conf(struct context *ctx, const struct token *token,
4218 const char *str, unsigned int len,
4219 void *buf, unsigned int size)
4221 struct buffer *out = buf;
4224 /* Token name must match. */
4225 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4227 /* Nothing else to do if there is no buffer. */
4230 /* Point to selected object. */
4231 ctx->object = out->args.vc.data;
4232 ctx->objmask = NULL;
4236 /** Parse eCPRI common header type field. */
4238 parse_vc_item_ecpri_type(struct context *ctx, const struct token *token,
4239 const char *str, unsigned int len,
4240 void *buf, unsigned int size)
4242 struct rte_flow_item_ecpri *ecpri;
4243 struct rte_flow_item_ecpri *ecpri_mask;
4244 struct rte_flow_item *item;
4247 struct buffer *out = buf;
4248 const struct arg *arg;
4251 /* Token name must match. */
4252 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4254 switch (ctx->curr) {
4255 case ITEM_ECPRI_COMMON_TYPE_IQ_DATA:
4256 msg_type = RTE_ECPRI_MSG_TYPE_IQ_DATA;
4258 case ITEM_ECPRI_COMMON_TYPE_RTC_CTRL:
4259 msg_type = RTE_ECPRI_MSG_TYPE_RTC_CTRL;
4261 case ITEM_ECPRI_COMMON_TYPE_DLY_MSR:
4262 msg_type = RTE_ECPRI_MSG_TYPE_DLY_MSR;
4269 arg = pop_args(ctx);
4272 ecpri = (struct rte_flow_item_ecpri *)out->args.vc.data;
4273 ecpri->hdr.common.type = msg_type;
4274 data_size = ctx->objdata / 3; /* spec, last, mask */
4275 ecpri_mask = (struct rte_flow_item_ecpri *)(out->args.vc.data +
4277 ecpri_mask->hdr.common.type = 0xFF;
4279 ecpri->hdr.common.u32 = rte_cpu_to_be_32(ecpri->hdr.common.u32);
4280 ecpri_mask->hdr.common.u32 =
4281 rte_cpu_to_be_32(ecpri_mask->hdr.common.u32);
4283 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
4285 item->mask = ecpri_mask;
4289 /** Parse RSS action. */
4291 parse_vc_action_rss(struct context *ctx, const struct token *token,
4292 const char *str, unsigned int len,
4293 void *buf, unsigned int size)
4295 struct buffer *out = buf;
4296 struct rte_flow_action *action;
4297 struct action_rss_data *action_rss_data;
4301 ret = parse_vc(ctx, token, str, len, buf, size);
4304 /* Nothing else to do if there is no buffer. */
4307 if (!out->args.vc.actions_n)
4309 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4310 /* Point to selected object. */
4311 ctx->object = out->args.vc.data;
4312 ctx->objmask = NULL;
4313 /* Set up default configuration. */
4314 action_rss_data = ctx->object;
4315 *action_rss_data = (struct action_rss_data){
4316 .conf = (struct rte_flow_action_rss){
4317 .func = RTE_ETH_HASH_FUNCTION_DEFAULT,
4320 .key_len = sizeof(action_rss_data->key),
4321 .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM),
4322 .key = action_rss_data->key,
4323 .queue = action_rss_data->queue,
4325 .key = "testpmd's default RSS hash key, "
4326 "override it for better balancing",
4329 for (i = 0; i < action_rss_data->conf.queue_num; ++i)
4330 action_rss_data->queue[i] = i;
4331 if (!port_id_is_invalid(ctx->port, DISABLED_WARN) &&
4332 ctx->port != (portid_t)RTE_PORT_ALL) {
4333 struct rte_eth_dev_info info;
4336 ret2 = rte_eth_dev_info_get(ctx->port, &info);
4340 action_rss_data->conf.key_len =
4341 RTE_MIN(sizeof(action_rss_data->key),
4342 info.hash_key_size);
4344 action->conf = &action_rss_data->conf;
4349 * Parse func field for RSS action.
4351 * The RTE_ETH_HASH_FUNCTION_* value to assign is derived from the
4352 * ACTION_RSS_FUNC_* index that called this function.
4355 parse_vc_action_rss_func(struct context *ctx, const struct token *token,
4356 const char *str, unsigned int len,
4357 void *buf, unsigned int size)
4359 struct action_rss_data *action_rss_data;
4360 enum rte_eth_hash_function func;
4364 /* Token name must match. */
4365 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4367 switch (ctx->curr) {
4368 case ACTION_RSS_FUNC_DEFAULT:
4369 func = RTE_ETH_HASH_FUNCTION_DEFAULT;
4371 case ACTION_RSS_FUNC_TOEPLITZ:
4372 func = RTE_ETH_HASH_FUNCTION_TOEPLITZ;
4374 case ACTION_RSS_FUNC_SIMPLE_XOR:
4375 func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
4377 case ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ:
4378 func = RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
4385 action_rss_data = ctx->object;
4386 action_rss_data->conf.func = func;
4391 * Parse type field for RSS action.
4393 * Valid tokens are type field names and the "end" token.
4396 parse_vc_action_rss_type(struct context *ctx, const struct token *token,
4397 const char *str, unsigned int len,
4398 void *buf, unsigned int size)
4400 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE);
4401 struct action_rss_data *action_rss_data;
4407 if (ctx->curr != ACTION_RSS_TYPE)
4409 if (!(ctx->objdata >> 16) && ctx->object) {
4410 action_rss_data = ctx->object;
4411 action_rss_data->conf.types = 0;
4413 if (!strcmp_partial("end", str, len)) {
4414 ctx->objdata &= 0xffff;
4417 for (i = 0; rss_type_table[i].str; ++i)
4418 if (!strcmp_partial(rss_type_table[i].str, str, len))
4420 if (!rss_type_table[i].str)
4422 ctx->objdata = 1 << 16 | (ctx->objdata & 0xffff);
4424 if (ctx->next_num == RTE_DIM(ctx->next))
4426 ctx->next[ctx->next_num++] = next;
4429 action_rss_data = ctx->object;
4430 action_rss_data->conf.types |= rss_type_table[i].rss_type;
4435 * Parse queue field for RSS action.
4437 * Valid tokens are queue indices and the "end" token.
4440 parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
4441 const char *str, unsigned int len,
4442 void *buf, unsigned int size)
4444 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE);
4445 struct action_rss_data *action_rss_data;
4446 const struct arg *arg;
4453 if (ctx->curr != ACTION_RSS_QUEUE)
4455 i = ctx->objdata >> 16;
4456 if (!strcmp_partial("end", str, len)) {
4457 ctx->objdata &= 0xffff;
4460 if (i >= ACTION_RSS_QUEUE_NUM)
4462 arg = ARGS_ENTRY_ARB(offsetof(struct action_rss_data, queue) +
4463 i * sizeof(action_rss_data->queue[i]),
4464 sizeof(action_rss_data->queue[i]));
4465 if (push_args(ctx, arg))
4467 ret = parse_int(ctx, token, str, len, NULL, 0);
4473 ctx->objdata = i << 16 | (ctx->objdata & 0xffff);
4475 if (ctx->next_num == RTE_DIM(ctx->next))
4477 ctx->next[ctx->next_num++] = next;
4481 action_rss_data = ctx->object;
4482 action_rss_data->conf.queue_num = i;
4483 action_rss_data->conf.queue = i ? action_rss_data->queue : NULL;
4487 /** Parse VXLAN encap action. */
4489 parse_vc_action_vxlan_encap(struct context *ctx, const struct token *token,
4490 const char *str, unsigned int len,
4491 void *buf, unsigned int size)
4493 struct buffer *out = buf;
4494 struct rte_flow_action *action;
4495 struct action_vxlan_encap_data *action_vxlan_encap_data;
4498 ret = parse_vc(ctx, token, str, len, buf, size);
4501 /* Nothing else to do if there is no buffer. */
4504 if (!out->args.vc.actions_n)
4506 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4507 /* Point to selected object. */
4508 ctx->object = out->args.vc.data;
4509 ctx->objmask = NULL;
4510 /* Set up default configuration. */
4511 action_vxlan_encap_data = ctx->object;
4512 *action_vxlan_encap_data = (struct action_vxlan_encap_data){
4513 .conf = (struct rte_flow_action_vxlan_encap){
4514 .definition = action_vxlan_encap_data->items,
4518 .type = RTE_FLOW_ITEM_TYPE_ETH,
4519 .spec = &action_vxlan_encap_data->item_eth,
4520 .mask = &rte_flow_item_eth_mask,
4523 .type = RTE_FLOW_ITEM_TYPE_VLAN,
4524 .spec = &action_vxlan_encap_data->item_vlan,
4525 .mask = &rte_flow_item_vlan_mask,
4528 .type = RTE_FLOW_ITEM_TYPE_IPV4,
4529 .spec = &action_vxlan_encap_data->item_ipv4,
4530 .mask = &rte_flow_item_ipv4_mask,
4533 .type = RTE_FLOW_ITEM_TYPE_UDP,
4534 .spec = &action_vxlan_encap_data->item_udp,
4535 .mask = &rte_flow_item_udp_mask,
4538 .type = RTE_FLOW_ITEM_TYPE_VXLAN,
4539 .spec = &action_vxlan_encap_data->item_vxlan,
4540 .mask = &rte_flow_item_vxlan_mask,
4543 .type = RTE_FLOW_ITEM_TYPE_END,
4548 .tci = vxlan_encap_conf.vlan_tci,
4552 .src_addr = vxlan_encap_conf.ipv4_src,
4553 .dst_addr = vxlan_encap_conf.ipv4_dst,
4556 .src_port = vxlan_encap_conf.udp_src,
4557 .dst_port = vxlan_encap_conf.udp_dst,
4559 .item_vxlan.flags = 0,
4561 memcpy(action_vxlan_encap_data->item_eth.dst.addr_bytes,
4562 vxlan_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
4563 memcpy(action_vxlan_encap_data->item_eth.src.addr_bytes,
4564 vxlan_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
4565 if (!vxlan_encap_conf.select_ipv4) {
4566 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.src_addr,
4567 &vxlan_encap_conf.ipv6_src,
4568 sizeof(vxlan_encap_conf.ipv6_src));
4569 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.dst_addr,
4570 &vxlan_encap_conf.ipv6_dst,
4571 sizeof(vxlan_encap_conf.ipv6_dst));
4572 action_vxlan_encap_data->items[2] = (struct rte_flow_item){
4573 .type = RTE_FLOW_ITEM_TYPE_IPV6,
4574 .spec = &action_vxlan_encap_data->item_ipv6,
4575 .mask = &rte_flow_item_ipv6_mask,
4578 if (!vxlan_encap_conf.select_vlan)
4579 action_vxlan_encap_data->items[1].type =
4580 RTE_FLOW_ITEM_TYPE_VOID;
4581 if (vxlan_encap_conf.select_tos_ttl) {
4582 if (vxlan_encap_conf.select_ipv4) {
4583 static struct rte_flow_item_ipv4 ipv4_mask_tos;
4585 memcpy(&ipv4_mask_tos, &rte_flow_item_ipv4_mask,
4586 sizeof(ipv4_mask_tos));
4587 ipv4_mask_tos.hdr.type_of_service = 0xff;
4588 ipv4_mask_tos.hdr.time_to_live = 0xff;
4589 action_vxlan_encap_data->item_ipv4.hdr.type_of_service =
4590 vxlan_encap_conf.ip_tos;
4591 action_vxlan_encap_data->item_ipv4.hdr.time_to_live =
4592 vxlan_encap_conf.ip_ttl;
4593 action_vxlan_encap_data->items[2].mask =
4596 static struct rte_flow_item_ipv6 ipv6_mask_tos;
4598 memcpy(&ipv6_mask_tos, &rte_flow_item_ipv6_mask,
4599 sizeof(ipv6_mask_tos));
4600 ipv6_mask_tos.hdr.vtc_flow |=
4601 RTE_BE32(0xfful << RTE_IPV6_HDR_TC_SHIFT);
4602 ipv6_mask_tos.hdr.hop_limits = 0xff;
4603 action_vxlan_encap_data->item_ipv6.hdr.vtc_flow |=
4605 ((uint32_t)vxlan_encap_conf.ip_tos <<
4606 RTE_IPV6_HDR_TC_SHIFT);
4607 action_vxlan_encap_data->item_ipv6.hdr.hop_limits =
4608 vxlan_encap_conf.ip_ttl;
4609 action_vxlan_encap_data->items[2].mask =
4613 memcpy(action_vxlan_encap_data->item_vxlan.vni, vxlan_encap_conf.vni,
4614 RTE_DIM(vxlan_encap_conf.vni));
4615 action->conf = &action_vxlan_encap_data->conf;
4619 /** Parse NVGRE encap action. */
4621 parse_vc_action_nvgre_encap(struct context *ctx, const struct token *token,
4622 const char *str, unsigned int len,
4623 void *buf, unsigned int size)
4625 struct buffer *out = buf;
4626 struct rte_flow_action *action;
4627 struct action_nvgre_encap_data *action_nvgre_encap_data;
4630 ret = parse_vc(ctx, token, str, len, buf, size);
4633 /* Nothing else to do if there is no buffer. */
4636 if (!out->args.vc.actions_n)
4638 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4639 /* Point to selected object. */
4640 ctx->object = out->args.vc.data;
4641 ctx->objmask = NULL;
4642 /* Set up default configuration. */
4643 action_nvgre_encap_data = ctx->object;
4644 *action_nvgre_encap_data = (struct action_nvgre_encap_data){
4645 .conf = (struct rte_flow_action_nvgre_encap){
4646 .definition = action_nvgre_encap_data->items,
4650 .type = RTE_FLOW_ITEM_TYPE_ETH,
4651 .spec = &action_nvgre_encap_data->item_eth,
4652 .mask = &rte_flow_item_eth_mask,
4655 .type = RTE_FLOW_ITEM_TYPE_VLAN,
4656 .spec = &action_nvgre_encap_data->item_vlan,
4657 .mask = &rte_flow_item_vlan_mask,
4660 .type = RTE_FLOW_ITEM_TYPE_IPV4,
4661 .spec = &action_nvgre_encap_data->item_ipv4,
4662 .mask = &rte_flow_item_ipv4_mask,
4665 .type = RTE_FLOW_ITEM_TYPE_NVGRE,
4666 .spec = &action_nvgre_encap_data->item_nvgre,
4667 .mask = &rte_flow_item_nvgre_mask,
4670 .type = RTE_FLOW_ITEM_TYPE_END,
4675 .tci = nvgre_encap_conf.vlan_tci,
4679 .src_addr = nvgre_encap_conf.ipv4_src,
4680 .dst_addr = nvgre_encap_conf.ipv4_dst,
4682 .item_nvgre.flow_id = 0,
4684 memcpy(action_nvgre_encap_data->item_eth.dst.addr_bytes,
4685 nvgre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
4686 memcpy(action_nvgre_encap_data->item_eth.src.addr_bytes,
4687 nvgre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
4688 if (!nvgre_encap_conf.select_ipv4) {
4689 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.src_addr,
4690 &nvgre_encap_conf.ipv6_src,
4691 sizeof(nvgre_encap_conf.ipv6_src));
4692 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.dst_addr,
4693 &nvgre_encap_conf.ipv6_dst,
4694 sizeof(nvgre_encap_conf.ipv6_dst));
4695 action_nvgre_encap_data->items[2] = (struct rte_flow_item){
4696 .type = RTE_FLOW_ITEM_TYPE_IPV6,
4697 .spec = &action_nvgre_encap_data->item_ipv6,
4698 .mask = &rte_flow_item_ipv6_mask,
4701 if (!nvgre_encap_conf.select_vlan)
4702 action_nvgre_encap_data->items[1].type =
4703 RTE_FLOW_ITEM_TYPE_VOID;
4704 memcpy(action_nvgre_encap_data->item_nvgre.tni, nvgre_encap_conf.tni,
4705 RTE_DIM(nvgre_encap_conf.tni));
4706 action->conf = &action_nvgre_encap_data->conf;
4710 /** Parse l2 encap action. */
4712 parse_vc_action_l2_encap(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;
4717 struct rte_flow_action *action;
4718 struct action_raw_encap_data *action_encap_data;
4719 struct rte_flow_item_eth eth = { .type = 0, };
4720 struct rte_flow_item_vlan vlan = {
4721 .tci = mplsoudp_encap_conf.vlan_tci,
4727 ret = parse_vc(ctx, token, str, len, buf, size);
4730 /* Nothing else to do if there is no buffer. */
4733 if (!out->args.vc.actions_n)
4735 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4736 /* Point to selected object. */
4737 ctx->object = out->args.vc.data;
4738 ctx->objmask = NULL;
4739 /* Copy the headers to the buffer. */
4740 action_encap_data = ctx->object;
4741 *action_encap_data = (struct action_raw_encap_data) {
4742 .conf = (struct rte_flow_action_raw_encap){
4743 .data = action_encap_data->data,
4747 header = action_encap_data->data;
4748 if (l2_encap_conf.select_vlan)
4749 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
4750 else if (l2_encap_conf.select_ipv4)
4751 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
4753 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
4754 memcpy(eth.dst.addr_bytes,
4755 l2_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
4756 memcpy(eth.src.addr_bytes,
4757 l2_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
4758 memcpy(header, ð, sizeof(eth));
4759 header += sizeof(eth);
4760 if (l2_encap_conf.select_vlan) {
4761 if (l2_encap_conf.select_ipv4)
4762 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
4764 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
4765 memcpy(header, &vlan, sizeof(vlan));
4766 header += sizeof(vlan);
4768 action_encap_data->conf.size = header -
4769 action_encap_data->data;
4770 action->conf = &action_encap_data->conf;
4774 /** Parse l2 decap action. */
4776 parse_vc_action_l2_decap(struct context *ctx, const struct token *token,
4777 const char *str, unsigned int len,
4778 void *buf, unsigned int size)
4780 struct buffer *out = buf;
4781 struct rte_flow_action *action;
4782 struct action_raw_decap_data *action_decap_data;
4783 struct rte_flow_item_eth eth = { .type = 0, };
4784 struct rte_flow_item_vlan vlan = {
4785 .tci = mplsoudp_encap_conf.vlan_tci,
4791 ret = parse_vc(ctx, token, str, len, buf, size);
4794 /* Nothing else to do if there is no buffer. */
4797 if (!out->args.vc.actions_n)
4799 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4800 /* Point to selected object. */
4801 ctx->object = out->args.vc.data;
4802 ctx->objmask = NULL;
4803 /* Copy the headers to the buffer. */
4804 action_decap_data = ctx->object;
4805 *action_decap_data = (struct action_raw_decap_data) {
4806 .conf = (struct rte_flow_action_raw_decap){
4807 .data = action_decap_data->data,
4811 header = action_decap_data->data;
4812 if (l2_decap_conf.select_vlan)
4813 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
4814 memcpy(header, ð, sizeof(eth));
4815 header += sizeof(eth);
4816 if (l2_decap_conf.select_vlan) {
4817 memcpy(header, &vlan, sizeof(vlan));
4818 header += sizeof(vlan);
4820 action_decap_data->conf.size = header -
4821 action_decap_data->data;
4822 action->conf = &action_decap_data->conf;
4826 #define ETHER_TYPE_MPLS_UNICAST 0x8847
4828 /** Parse MPLSOGRE encap action. */
4830 parse_vc_action_mplsogre_encap(struct context *ctx, const struct token *token,
4831 const char *str, unsigned int len,
4832 void *buf, unsigned int size)
4834 struct buffer *out = buf;
4835 struct rte_flow_action *action;
4836 struct action_raw_encap_data *action_encap_data;
4837 struct rte_flow_item_eth eth = { .type = 0, };
4838 struct rte_flow_item_vlan vlan = {
4839 .tci = mplsogre_encap_conf.vlan_tci,
4842 struct rte_flow_item_ipv4 ipv4 = {
4844 .src_addr = mplsogre_encap_conf.ipv4_src,
4845 .dst_addr = mplsogre_encap_conf.ipv4_dst,
4846 .next_proto_id = IPPROTO_GRE,
4847 .version_ihl = RTE_IPV4_VHL_DEF,
4848 .time_to_live = IPDEFTTL,
4851 struct rte_flow_item_ipv6 ipv6 = {
4853 .proto = IPPROTO_GRE,
4854 .hop_limits = IPDEFTTL,
4857 struct rte_flow_item_gre gre = {
4858 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
4860 struct rte_flow_item_mpls mpls = {
4866 ret = parse_vc(ctx, token, str, len, buf, size);
4869 /* Nothing else to do if there is no buffer. */
4872 if (!out->args.vc.actions_n)
4874 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4875 /* Point to selected object. */
4876 ctx->object = out->args.vc.data;
4877 ctx->objmask = NULL;
4878 /* Copy the headers to the buffer. */
4879 action_encap_data = ctx->object;
4880 *action_encap_data = (struct action_raw_encap_data) {
4881 .conf = (struct rte_flow_action_raw_encap){
4882 .data = action_encap_data->data,
4887 header = action_encap_data->data;
4888 if (mplsogre_encap_conf.select_vlan)
4889 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
4890 else if (mplsogre_encap_conf.select_ipv4)
4891 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
4893 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
4894 memcpy(eth.dst.addr_bytes,
4895 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
4896 memcpy(eth.src.addr_bytes,
4897 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
4898 memcpy(header, ð, sizeof(eth));
4899 header += sizeof(eth);
4900 if (mplsogre_encap_conf.select_vlan) {
4901 if (mplsogre_encap_conf.select_ipv4)
4902 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
4904 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
4905 memcpy(header, &vlan, sizeof(vlan));
4906 header += sizeof(vlan);
4908 if (mplsogre_encap_conf.select_ipv4) {
4909 memcpy(header, &ipv4, sizeof(ipv4));
4910 header += sizeof(ipv4);
4912 memcpy(&ipv6.hdr.src_addr,
4913 &mplsogre_encap_conf.ipv6_src,
4914 sizeof(mplsogre_encap_conf.ipv6_src));
4915 memcpy(&ipv6.hdr.dst_addr,
4916 &mplsogre_encap_conf.ipv6_dst,
4917 sizeof(mplsogre_encap_conf.ipv6_dst));
4918 memcpy(header, &ipv6, sizeof(ipv6));
4919 header += sizeof(ipv6);
4921 memcpy(header, &gre, sizeof(gre));
4922 header += sizeof(gre);
4923 memcpy(mpls.label_tc_s, mplsogre_encap_conf.label,
4924 RTE_DIM(mplsogre_encap_conf.label));
4925 mpls.label_tc_s[2] |= 0x1;
4926 memcpy(header, &mpls, sizeof(mpls));
4927 header += sizeof(mpls);
4928 action_encap_data->conf.size = header -
4929 action_encap_data->data;
4930 action->conf = &action_encap_data->conf;
4934 /** Parse MPLSOGRE decap action. */
4936 parse_vc_action_mplsogre_decap(struct context *ctx, const struct token *token,
4937 const char *str, unsigned int len,
4938 void *buf, unsigned int size)
4940 struct buffer *out = buf;
4941 struct rte_flow_action *action;
4942 struct action_raw_decap_data *action_decap_data;
4943 struct rte_flow_item_eth eth = { .type = 0, };
4944 struct rte_flow_item_vlan vlan = {.tci = 0};
4945 struct rte_flow_item_ipv4 ipv4 = {
4947 .next_proto_id = IPPROTO_GRE,
4950 struct rte_flow_item_ipv6 ipv6 = {
4952 .proto = IPPROTO_GRE,
4955 struct rte_flow_item_gre gre = {
4956 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
4958 struct rte_flow_item_mpls mpls;
4962 ret = parse_vc(ctx, token, str, len, buf, size);
4965 /* Nothing else to do if there is no buffer. */
4968 if (!out->args.vc.actions_n)
4970 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4971 /* Point to selected object. */
4972 ctx->object = out->args.vc.data;
4973 ctx->objmask = NULL;
4974 /* Copy the headers to the buffer. */
4975 action_decap_data = ctx->object;
4976 *action_decap_data = (struct action_raw_decap_data) {
4977 .conf = (struct rte_flow_action_raw_decap){
4978 .data = action_decap_data->data,
4982 header = action_decap_data->data;
4983 if (mplsogre_decap_conf.select_vlan)
4984 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
4985 else if (mplsogre_encap_conf.select_ipv4)
4986 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
4988 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
4989 memcpy(eth.dst.addr_bytes,
4990 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
4991 memcpy(eth.src.addr_bytes,
4992 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
4993 memcpy(header, ð, sizeof(eth));
4994 header += sizeof(eth);
4995 if (mplsogre_encap_conf.select_vlan) {
4996 if (mplsogre_encap_conf.select_ipv4)
4997 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
4999 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5000 memcpy(header, &vlan, sizeof(vlan));
5001 header += sizeof(vlan);
5003 if (mplsogre_encap_conf.select_ipv4) {
5004 memcpy(header, &ipv4, sizeof(ipv4));
5005 header += sizeof(ipv4);
5007 memcpy(header, &ipv6, sizeof(ipv6));
5008 header += sizeof(ipv6);
5010 memcpy(header, &gre, sizeof(gre));
5011 header += sizeof(gre);
5012 memset(&mpls, 0, sizeof(mpls));
5013 memcpy(header, &mpls, sizeof(mpls));
5014 header += sizeof(mpls);
5015 action_decap_data->conf.size = header -
5016 action_decap_data->data;
5017 action->conf = &action_decap_data->conf;
5021 /** Parse MPLSOUDP encap action. */
5023 parse_vc_action_mplsoudp_encap(struct context *ctx, const struct token *token,
5024 const char *str, unsigned int len,
5025 void *buf, unsigned int size)
5027 struct buffer *out = buf;
5028 struct rte_flow_action *action;
5029 struct action_raw_encap_data *action_encap_data;
5030 struct rte_flow_item_eth eth = { .type = 0, };
5031 struct rte_flow_item_vlan vlan = {
5032 .tci = mplsoudp_encap_conf.vlan_tci,
5035 struct rte_flow_item_ipv4 ipv4 = {
5037 .src_addr = mplsoudp_encap_conf.ipv4_src,
5038 .dst_addr = mplsoudp_encap_conf.ipv4_dst,
5039 .next_proto_id = IPPROTO_UDP,
5040 .version_ihl = RTE_IPV4_VHL_DEF,
5041 .time_to_live = IPDEFTTL,
5044 struct rte_flow_item_ipv6 ipv6 = {
5046 .proto = IPPROTO_UDP,
5047 .hop_limits = IPDEFTTL,
5050 struct rte_flow_item_udp udp = {
5052 .src_port = mplsoudp_encap_conf.udp_src,
5053 .dst_port = mplsoudp_encap_conf.udp_dst,
5056 struct rte_flow_item_mpls mpls;
5060 ret = parse_vc(ctx, token, str, len, buf, size);
5063 /* Nothing else to do if there is no buffer. */
5066 if (!out->args.vc.actions_n)
5068 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5069 /* Point to selected object. */
5070 ctx->object = out->args.vc.data;
5071 ctx->objmask = NULL;
5072 /* Copy the headers to the buffer. */
5073 action_encap_data = ctx->object;
5074 *action_encap_data = (struct action_raw_encap_data) {
5075 .conf = (struct rte_flow_action_raw_encap){
5076 .data = action_encap_data->data,
5081 header = action_encap_data->data;
5082 if (mplsoudp_encap_conf.select_vlan)
5083 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5084 else if (mplsoudp_encap_conf.select_ipv4)
5085 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5087 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5088 memcpy(eth.dst.addr_bytes,
5089 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5090 memcpy(eth.src.addr_bytes,
5091 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5092 memcpy(header, ð, sizeof(eth));
5093 header += sizeof(eth);
5094 if (mplsoudp_encap_conf.select_vlan) {
5095 if (mplsoudp_encap_conf.select_ipv4)
5096 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5098 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5099 memcpy(header, &vlan, sizeof(vlan));
5100 header += sizeof(vlan);
5102 if (mplsoudp_encap_conf.select_ipv4) {
5103 memcpy(header, &ipv4, sizeof(ipv4));
5104 header += sizeof(ipv4);
5106 memcpy(&ipv6.hdr.src_addr,
5107 &mplsoudp_encap_conf.ipv6_src,
5108 sizeof(mplsoudp_encap_conf.ipv6_src));
5109 memcpy(&ipv6.hdr.dst_addr,
5110 &mplsoudp_encap_conf.ipv6_dst,
5111 sizeof(mplsoudp_encap_conf.ipv6_dst));
5112 memcpy(header, &ipv6, sizeof(ipv6));
5113 header += sizeof(ipv6);
5115 memcpy(header, &udp, sizeof(udp));
5116 header += sizeof(udp);
5117 memcpy(mpls.label_tc_s, mplsoudp_encap_conf.label,
5118 RTE_DIM(mplsoudp_encap_conf.label));
5119 mpls.label_tc_s[2] |= 0x1;
5120 memcpy(header, &mpls, sizeof(mpls));
5121 header += sizeof(mpls);
5122 action_encap_data->conf.size = header -
5123 action_encap_data->data;
5124 action->conf = &action_encap_data->conf;
5128 /** Parse MPLSOUDP decap action. */
5130 parse_vc_action_mplsoudp_decap(struct context *ctx, const struct token *token,
5131 const char *str, unsigned int len,
5132 void *buf, unsigned int size)
5134 struct buffer *out = buf;
5135 struct rte_flow_action *action;
5136 struct action_raw_decap_data *action_decap_data;
5137 struct rte_flow_item_eth eth = { .type = 0, };
5138 struct rte_flow_item_vlan vlan = {.tci = 0};
5139 struct rte_flow_item_ipv4 ipv4 = {
5141 .next_proto_id = IPPROTO_UDP,
5144 struct rte_flow_item_ipv6 ipv6 = {
5146 .proto = IPPROTO_UDP,
5149 struct rte_flow_item_udp udp = {
5151 .dst_port = rte_cpu_to_be_16(6635),
5154 struct rte_flow_item_mpls mpls;
5158 ret = parse_vc(ctx, token, str, len, buf, size);
5161 /* Nothing else to do if there is no buffer. */
5164 if (!out->args.vc.actions_n)
5166 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5167 /* Point to selected object. */
5168 ctx->object = out->args.vc.data;
5169 ctx->objmask = NULL;
5170 /* Copy the headers to the buffer. */
5171 action_decap_data = ctx->object;
5172 *action_decap_data = (struct action_raw_decap_data) {
5173 .conf = (struct rte_flow_action_raw_decap){
5174 .data = action_decap_data->data,
5178 header = action_decap_data->data;
5179 if (mplsoudp_decap_conf.select_vlan)
5180 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
5181 else if (mplsoudp_encap_conf.select_ipv4)
5182 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5184 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5185 memcpy(eth.dst.addr_bytes,
5186 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
5187 memcpy(eth.src.addr_bytes,
5188 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
5189 memcpy(header, ð, sizeof(eth));
5190 header += sizeof(eth);
5191 if (mplsoudp_encap_conf.select_vlan) {
5192 if (mplsoudp_encap_conf.select_ipv4)
5193 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
5195 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
5196 memcpy(header, &vlan, sizeof(vlan));
5197 header += sizeof(vlan);
5199 if (mplsoudp_encap_conf.select_ipv4) {
5200 memcpy(header, &ipv4, sizeof(ipv4));
5201 header += sizeof(ipv4);
5203 memcpy(header, &ipv6, sizeof(ipv6));
5204 header += sizeof(ipv6);
5206 memcpy(header, &udp, sizeof(udp));
5207 header += sizeof(udp);
5208 memset(&mpls, 0, sizeof(mpls));
5209 memcpy(header, &mpls, sizeof(mpls));
5210 header += sizeof(mpls);
5211 action_decap_data->conf.size = header -
5212 action_decap_data->data;
5213 action->conf = &action_decap_data->conf;
5218 parse_vc_action_raw_decap_index(struct context *ctx, const struct token *token,
5219 const char *str, unsigned int len, void *buf,
5222 struct action_raw_decap_data *action_raw_decap_data;
5223 struct rte_flow_action *action;
5224 const struct arg *arg;
5225 struct buffer *out = buf;
5229 RTE_SET_USED(token);
5232 arg = ARGS_ENTRY_ARB_BOUNDED
5233 (offsetof(struct action_raw_decap_data, idx),
5234 sizeof(((struct action_raw_decap_data *)0)->idx),
5235 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
5236 if (push_args(ctx, arg))
5238 ret = parse_int(ctx, token, str, len, NULL, 0);
5245 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5246 action_raw_decap_data = ctx->object;
5247 idx = action_raw_decap_data->idx;
5248 action_raw_decap_data->conf.data = raw_decap_confs[idx].data;
5249 action_raw_decap_data->conf.size = raw_decap_confs[idx].size;
5250 action->conf = &action_raw_decap_data->conf;
5256 parse_vc_action_raw_encap_index(struct context *ctx, const struct token *token,
5257 const char *str, unsigned int len, void *buf,
5260 struct action_raw_encap_data *action_raw_encap_data;
5261 struct rte_flow_action *action;
5262 const struct arg *arg;
5263 struct buffer *out = buf;
5267 RTE_SET_USED(token);
5270 if (ctx->curr != ACTION_RAW_ENCAP_INDEX_VALUE)
5272 arg = ARGS_ENTRY_ARB_BOUNDED
5273 (offsetof(struct action_raw_encap_data, idx),
5274 sizeof(((struct action_raw_encap_data *)0)->idx),
5275 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
5276 if (push_args(ctx, arg))
5278 ret = parse_int(ctx, token, str, len, NULL, 0);
5285 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5286 action_raw_encap_data = ctx->object;
5287 idx = action_raw_encap_data->idx;
5288 action_raw_encap_data->conf.data = raw_encap_confs[idx].data;
5289 action_raw_encap_data->conf.size = raw_encap_confs[idx].size;
5290 action_raw_encap_data->conf.preserve = NULL;
5291 action->conf = &action_raw_encap_data->conf;
5296 parse_vc_action_raw_encap(struct context *ctx, const struct token *token,
5297 const char *str, unsigned int len, void *buf,
5300 struct buffer *out = buf;
5301 struct rte_flow_action *action;
5302 struct action_raw_encap_data *action_raw_encap_data = NULL;
5305 ret = parse_vc(ctx, token, str, len, buf, size);
5308 /* Nothing else to do if there is no buffer. */
5311 if (!out->args.vc.actions_n)
5313 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5314 /* Point to selected object. */
5315 ctx->object = out->args.vc.data;
5316 ctx->objmask = NULL;
5317 /* Copy the headers to the buffer. */
5318 action_raw_encap_data = ctx->object;
5319 action_raw_encap_data->conf.data = raw_encap_confs[0].data;
5320 action_raw_encap_data->conf.preserve = NULL;
5321 action_raw_encap_data->conf.size = raw_encap_confs[0].size;
5322 action->conf = &action_raw_encap_data->conf;
5327 parse_vc_action_raw_decap(struct context *ctx, const struct token *token,
5328 const char *str, unsigned int len, void *buf,
5331 struct buffer *out = buf;
5332 struct rte_flow_action *action;
5333 struct action_raw_decap_data *action_raw_decap_data = NULL;
5336 ret = parse_vc(ctx, token, str, len, buf, size);
5339 /* Nothing else to do if there is no buffer. */
5342 if (!out->args.vc.actions_n)
5344 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5345 /* Point to selected object. */
5346 ctx->object = out->args.vc.data;
5347 ctx->objmask = NULL;
5348 /* Copy the headers to the buffer. */
5349 action_raw_decap_data = ctx->object;
5350 action_raw_decap_data->conf.data = raw_decap_confs[0].data;
5351 action_raw_decap_data->conf.size = raw_decap_confs[0].size;
5352 action->conf = &action_raw_decap_data->conf;
5357 parse_vc_action_set_meta(struct context *ctx, const struct token *token,
5358 const char *str, unsigned int len, void *buf,
5363 ret = parse_vc(ctx, token, str, len, buf, size);
5366 ret = rte_flow_dynf_metadata_register();
5372 /** Parse tokens for destroy command. */
5374 parse_destroy(struct context *ctx, const struct token *token,
5375 const char *str, unsigned int len,
5376 void *buf, unsigned int size)
5378 struct buffer *out = buf;
5380 /* Token name must match. */
5381 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5383 /* Nothing else to do if there is no buffer. */
5386 if (!out->command) {
5387 if (ctx->curr != DESTROY)
5389 if (sizeof(*out) > size)
5391 out->command = ctx->curr;
5394 ctx->objmask = NULL;
5395 out->args.destroy.rule =
5396 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5400 if (((uint8_t *)(out->args.destroy.rule + out->args.destroy.rule_n) +
5401 sizeof(*out->args.destroy.rule)) > (uint8_t *)out + size)
5404 ctx->object = out->args.destroy.rule + out->args.destroy.rule_n++;
5405 ctx->objmask = NULL;
5409 /** Parse tokens for flush command. */
5411 parse_flush(struct context *ctx, const struct token *token,
5412 const char *str, unsigned int len,
5413 void *buf, unsigned int size)
5415 struct buffer *out = buf;
5417 /* Token name must match. */
5418 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5420 /* Nothing else to do if there is no buffer. */
5423 if (!out->command) {
5424 if (ctx->curr != FLUSH)
5426 if (sizeof(*out) > size)
5428 out->command = ctx->curr;
5431 ctx->objmask = NULL;
5436 /** Parse tokens for dump command. */
5438 parse_dump(struct context *ctx, const struct token *token,
5439 const char *str, unsigned int len,
5440 void *buf, unsigned int size)
5442 struct buffer *out = buf;
5444 /* Token name must match. */
5445 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5447 /* Nothing else to do if there is no buffer. */
5450 if (!out->command) {
5451 if (ctx->curr != DUMP)
5453 if (sizeof(*out) > size)
5455 out->command = ctx->curr;
5458 ctx->objmask = NULL;
5463 /** Parse tokens for query command. */
5465 parse_query(struct context *ctx, const struct token *token,
5466 const char *str, unsigned int len,
5467 void *buf, unsigned int size)
5469 struct buffer *out = buf;
5471 /* Token name must match. */
5472 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5474 /* Nothing else to do if there is no buffer. */
5477 if (!out->command) {
5478 if (ctx->curr != QUERY)
5480 if (sizeof(*out) > size)
5482 out->command = ctx->curr;
5485 ctx->objmask = NULL;
5490 /** Parse action names. */
5492 parse_action(struct context *ctx, const struct token *token,
5493 const char *str, unsigned int len,
5494 void *buf, unsigned int size)
5496 struct buffer *out = buf;
5497 const struct arg *arg = pop_args(ctx);
5501 /* Argument is expected. */
5504 /* Parse action name. */
5505 for (i = 0; next_action[i]; ++i) {
5506 const struct parse_action_priv *priv;
5508 token = &token_list[next_action[i]];
5509 if (strcmp_partial(token->name, str, len))
5515 memcpy((uint8_t *)ctx->object + arg->offset,
5521 push_args(ctx, arg);
5525 /** Parse tokens for list command. */
5527 parse_list(struct context *ctx, const struct token *token,
5528 const char *str, unsigned int len,
5529 void *buf, unsigned int size)
5531 struct buffer *out = buf;
5533 /* Token name must match. */
5534 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5536 /* Nothing else to do if there is no buffer. */
5539 if (!out->command) {
5540 if (ctx->curr != LIST)
5542 if (sizeof(*out) > size)
5544 out->command = ctx->curr;
5547 ctx->objmask = NULL;
5548 out->args.list.group =
5549 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5553 if (((uint8_t *)(out->args.list.group + out->args.list.group_n) +
5554 sizeof(*out->args.list.group)) > (uint8_t *)out + size)
5557 ctx->object = out->args.list.group + out->args.list.group_n++;
5558 ctx->objmask = NULL;
5562 /** Parse tokens for list all aged flows command. */
5564 parse_aged(struct context *ctx, const struct token *token,
5565 const char *str, unsigned int len,
5566 void *buf, unsigned int size)
5568 struct buffer *out = buf;
5570 /* Token name must match. */
5571 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5573 /* Nothing else to do if there is no buffer. */
5576 if (!out->command) {
5577 if (ctx->curr != AGED)
5579 if (sizeof(*out) > size)
5581 out->command = ctx->curr;
5584 ctx->objmask = NULL;
5586 if (ctx->curr == AGED_DESTROY)
5587 out->args.aged.destroy = 1;
5591 /** Parse tokens for isolate command. */
5593 parse_isolate(struct context *ctx, const struct token *token,
5594 const char *str, unsigned int len,
5595 void *buf, unsigned int size)
5597 struct buffer *out = buf;
5599 /* Token name must match. */
5600 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5602 /* Nothing else to do if there is no buffer. */
5605 if (!out->command) {
5606 if (ctx->curr != ISOLATE)
5608 if (sizeof(*out) > size)
5610 out->command = ctx->curr;
5613 ctx->objmask = NULL;
5619 * Parse signed/unsigned integers 8 to 64-bit long.
5621 * Last argument (ctx->args) is retrieved to determine integer type and
5625 parse_int(struct context *ctx, const struct token *token,
5626 const char *str, unsigned int len,
5627 void *buf, unsigned int size)
5629 const struct arg *arg = pop_args(ctx);
5634 /* Argument is expected. */
5639 (uintmax_t)strtoimax(str, &end, 0) :
5640 strtoumax(str, &end, 0);
5641 if (errno || (size_t)(end - str) != len)
5644 ((arg->sign && ((intmax_t)u < (intmax_t)arg->min ||
5645 (intmax_t)u > (intmax_t)arg->max)) ||
5646 (!arg->sign && (u < arg->min || u > arg->max))))
5651 if (!arg_entry_bf_fill(ctx->object, u, arg) ||
5652 !arg_entry_bf_fill(ctx->objmask, -1, arg))
5656 buf = (uint8_t *)ctx->object + arg->offset;
5658 if (u > RTE_LEN2MASK(size * CHAR_BIT, uint64_t))
5662 case sizeof(uint8_t):
5663 *(uint8_t *)buf = u;
5665 case sizeof(uint16_t):
5666 *(uint16_t *)buf = arg->hton ? rte_cpu_to_be_16(u) : u;
5668 case sizeof(uint8_t [3]):
5669 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
5671 ((uint8_t *)buf)[0] = u;
5672 ((uint8_t *)buf)[1] = u >> 8;
5673 ((uint8_t *)buf)[2] = u >> 16;
5677 ((uint8_t *)buf)[0] = u >> 16;
5678 ((uint8_t *)buf)[1] = u >> 8;
5679 ((uint8_t *)buf)[2] = u;
5681 case sizeof(uint32_t):
5682 *(uint32_t *)buf = arg->hton ? rte_cpu_to_be_32(u) : u;
5684 case sizeof(uint64_t):
5685 *(uint64_t *)buf = arg->hton ? rte_cpu_to_be_64(u) : u;
5690 if (ctx->objmask && buf != (uint8_t *)ctx->objmask + arg->offset) {
5692 buf = (uint8_t *)ctx->objmask + arg->offset;
5697 push_args(ctx, arg);
5704 * Three arguments (ctx->args) are retrieved from the stack to store data,
5705 * its actual length and address (in that order).
5708 parse_string(struct context *ctx, const struct token *token,
5709 const char *str, unsigned int len,
5710 void *buf, unsigned int size)
5712 const struct arg *arg_data = pop_args(ctx);
5713 const struct arg *arg_len = pop_args(ctx);
5714 const struct arg *arg_addr = pop_args(ctx);
5715 char tmp[16]; /* Ought to be enough. */
5718 /* Arguments are expected. */
5722 push_args(ctx, arg_data);
5726 push_args(ctx, arg_len);
5727 push_args(ctx, arg_data);
5730 size = arg_data->size;
5731 /* Bit-mask fill is not supported. */
5732 if (arg_data->mask || size < len)
5736 /* Let parse_int() fill length information first. */
5737 ret = snprintf(tmp, sizeof(tmp), "%u", len);
5740 push_args(ctx, arg_len);
5741 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
5746 buf = (uint8_t *)ctx->object + arg_data->offset;
5747 /* Output buffer is not necessarily NUL-terminated. */
5748 memcpy(buf, str, len);
5749 memset((uint8_t *)buf + len, 0x00, size - len);
5751 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
5752 /* Save address if requested. */
5753 if (arg_addr->size) {
5754 memcpy((uint8_t *)ctx->object + arg_addr->offset,
5756 (uint8_t *)ctx->object + arg_data->offset
5760 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
5762 (uint8_t *)ctx->objmask + arg_data->offset
5768 push_args(ctx, arg_addr);
5769 push_args(ctx, arg_len);
5770 push_args(ctx, arg_data);
5775 parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
5781 /* Check input parameters */
5782 if ((src == NULL) ||
5788 /* Convert chars to bytes */
5789 for (i = 0, len = 0; i < *size; i += 2) {
5790 snprintf(tmp, 3, "%s", src + i);
5791 dst[len++] = strtoul(tmp, &c, 16);
5806 parse_hex(struct context *ctx, const struct token *token,
5807 const char *str, unsigned int len,
5808 void *buf, unsigned int size)
5810 const struct arg *arg_data = pop_args(ctx);
5811 const struct arg *arg_len = pop_args(ctx);
5812 const struct arg *arg_addr = pop_args(ctx);
5813 char tmp[16]; /* Ought to be enough. */
5815 unsigned int hexlen = len;
5816 unsigned int length = 256;
5817 uint8_t hex_tmp[length];
5819 /* Arguments are expected. */
5823 push_args(ctx, arg_data);
5827 push_args(ctx, arg_len);
5828 push_args(ctx, arg_data);
5831 size = arg_data->size;
5832 /* Bit-mask fill is not supported. */
5838 /* translate bytes string to array. */
5839 if (str[0] == '0' && ((str[1] == 'x') ||
5844 if (hexlen > length)
5846 ret = parse_hex_string(str, hex_tmp, &hexlen);
5849 /* Let parse_int() fill length information first. */
5850 ret = snprintf(tmp, sizeof(tmp), "%u", hexlen);
5853 push_args(ctx, arg_len);
5854 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
5859 buf = (uint8_t *)ctx->object + arg_data->offset;
5860 /* Output buffer is not necessarily NUL-terminated. */
5861 memcpy(buf, hex_tmp, hexlen);
5862 memset((uint8_t *)buf + hexlen, 0x00, size - hexlen);
5864 memset((uint8_t *)ctx->objmask + arg_data->offset,
5866 /* Save address if requested. */
5867 if (arg_addr->size) {
5868 memcpy((uint8_t *)ctx->object + arg_addr->offset,
5870 (uint8_t *)ctx->object + arg_data->offset
5874 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
5876 (uint8_t *)ctx->objmask + arg_data->offset
5882 push_args(ctx, arg_addr);
5883 push_args(ctx, arg_len);
5884 push_args(ctx, arg_data);
5890 * Parse a zero-ended string.
5893 parse_string0(struct context *ctx, const struct token *token __rte_unused,
5894 const char *str, unsigned int len,
5895 void *buf, unsigned int size)
5897 const struct arg *arg_data = pop_args(ctx);
5899 /* Arguments are expected. */
5902 size = arg_data->size;
5903 /* Bit-mask fill is not supported. */
5904 if (arg_data->mask || size < len + 1)
5908 buf = (uint8_t *)ctx->object + arg_data->offset;
5909 strncpy(buf, str, len);
5911 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
5914 push_args(ctx, arg_data);
5919 * Parse a MAC address.
5921 * Last argument (ctx->args) is retrieved to determine storage size and
5925 parse_mac_addr(struct context *ctx, const struct token *token,
5926 const char *str, unsigned int len,
5927 void *buf, unsigned int size)
5929 const struct arg *arg = pop_args(ctx);
5930 struct rte_ether_addr tmp;
5934 /* Argument is expected. */
5938 /* Bit-mask fill is not supported. */
5939 if (arg->mask || size != sizeof(tmp))
5941 /* Only network endian is supported. */
5944 ret = cmdline_parse_etheraddr(NULL, str, &tmp, size);
5945 if (ret < 0 || (unsigned int)ret != len)
5949 buf = (uint8_t *)ctx->object + arg->offset;
5950 memcpy(buf, &tmp, size);
5952 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
5955 push_args(ctx, arg);
5960 * Parse an IPv4 address.
5962 * Last argument (ctx->args) is retrieved to determine storage size and
5966 parse_ipv4_addr(struct context *ctx, const struct token *token,
5967 const char *str, unsigned int len,
5968 void *buf, unsigned int size)
5970 const struct arg *arg = pop_args(ctx);
5975 /* Argument is expected. */
5979 /* Bit-mask fill is not supported. */
5980 if (arg->mask || size != sizeof(tmp))
5982 /* Only network endian is supported. */
5985 memcpy(str2, str, len);
5987 ret = inet_pton(AF_INET, str2, &tmp);
5989 /* Attempt integer parsing. */
5990 push_args(ctx, arg);
5991 return parse_int(ctx, token, str, len, buf, size);
5995 buf = (uint8_t *)ctx->object + arg->offset;
5996 memcpy(buf, &tmp, size);
5998 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6001 push_args(ctx, arg);
6006 * Parse an IPv6 address.
6008 * Last argument (ctx->args) is retrieved to determine storage size and
6012 parse_ipv6_addr(struct context *ctx, const struct token *token,
6013 const char *str, unsigned int len,
6014 void *buf, unsigned int size)
6016 const struct arg *arg = pop_args(ctx);
6018 struct in6_addr tmp;
6022 /* Argument is expected. */
6026 /* Bit-mask fill is not supported. */
6027 if (arg->mask || size != sizeof(tmp))
6029 /* Only network endian is supported. */
6032 memcpy(str2, str, len);
6034 ret = inet_pton(AF_INET6, str2, &tmp);
6039 buf = (uint8_t *)ctx->object + arg->offset;
6040 memcpy(buf, &tmp, size);
6042 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
6045 push_args(ctx, arg);
6049 /** Boolean values (even indices stand for false). */
6050 static const char *const boolean_name[] = {
6060 * Parse a boolean value.
6062 * Last argument (ctx->args) is retrieved to determine storage size and
6066 parse_boolean(struct context *ctx, const struct token *token,
6067 const char *str, unsigned int len,
6068 void *buf, unsigned int size)
6070 const struct arg *arg = pop_args(ctx);
6074 /* Argument is expected. */
6077 for (i = 0; boolean_name[i]; ++i)
6078 if (!strcmp_partial(boolean_name[i], str, len))
6080 /* Process token as integer. */
6081 if (boolean_name[i])
6082 str = i & 1 ? "1" : "0";
6083 push_args(ctx, arg);
6084 ret = parse_int(ctx, token, str, strlen(str), buf, size);
6085 return ret > 0 ? (int)len : ret;
6088 /** Parse port and update context. */
6090 parse_port(struct context *ctx, const struct token *token,
6091 const char *str, unsigned int len,
6092 void *buf, unsigned int size)
6094 struct buffer *out = &(struct buffer){ .port = 0 };
6102 ctx->objmask = NULL;
6103 size = sizeof(*out);
6105 ret = parse_int(ctx, token, str, len, out, size);
6107 ctx->port = out->port;
6113 /** Parse set command, initialize output buffer for subsequent tokens. */
6115 parse_set_raw_encap_decap(struct context *ctx, const struct token *token,
6116 const char *str, unsigned int len,
6117 void *buf, unsigned int size)
6119 struct buffer *out = buf;
6121 /* Token name must match. */
6122 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6124 /* Nothing else to do if there is no buffer. */
6127 /* Make sure buffer is large enough. */
6128 if (size < sizeof(*out))
6131 ctx->objmask = NULL;
6135 out->command = ctx->curr;
6140 * Parse set raw_encap/raw_decap command,
6141 * initialize output buffer for subsequent tokens.
6144 parse_set_init(struct context *ctx, const struct token *token,
6145 const char *str, unsigned int len,
6146 void *buf, unsigned int size)
6148 struct buffer *out = buf;
6150 /* Token name must match. */
6151 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
6153 /* Nothing else to do if there is no buffer. */
6156 /* Make sure buffer is large enough. */
6157 if (size < sizeof(*out))
6159 /* Initialize buffer. */
6160 memset(out, 0x00, sizeof(*out));
6161 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
6164 ctx->objmask = NULL;
6165 if (!out->command) {
6166 if (ctx->curr != SET)
6168 if (sizeof(*out) > size)
6170 out->command = ctx->curr;
6171 out->args.vc.data = (uint8_t *)out + size;
6172 /* All we need is pattern */
6173 out->args.vc.pattern =
6174 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
6176 ctx->object = out->args.vc.pattern;
6181 /** No completion. */
6183 comp_none(struct context *ctx, const struct token *token,
6184 unsigned int ent, char *buf, unsigned int size)
6194 /** Complete boolean values. */
6196 comp_boolean(struct context *ctx, const struct token *token,
6197 unsigned int ent, char *buf, unsigned int size)
6203 for (i = 0; boolean_name[i]; ++i)
6204 if (buf && i == ent)
6205 return strlcpy(buf, boolean_name[i], size);
6211 /** Complete action names. */
6213 comp_action(struct context *ctx, const struct token *token,
6214 unsigned int ent, char *buf, unsigned int size)
6220 for (i = 0; next_action[i]; ++i)
6221 if (buf && i == ent)
6222 return strlcpy(buf, token_list[next_action[i]].name,
6229 /** Complete available ports. */
6231 comp_port(struct context *ctx, const struct token *token,
6232 unsigned int ent, char *buf, unsigned int size)
6239 RTE_ETH_FOREACH_DEV(p) {
6240 if (buf && i == ent)
6241 return snprintf(buf, size, "%u", p);
6249 /** Complete available rule IDs. */
6251 comp_rule_id(struct context *ctx, const struct token *token,
6252 unsigned int ent, char *buf, unsigned int size)
6255 struct rte_port *port;
6256 struct port_flow *pf;
6259 if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
6260 ctx->port == (portid_t)RTE_PORT_ALL)
6262 port = &ports[ctx->port];
6263 for (pf = port->flow_list; pf != NULL; pf = pf->next) {
6264 if (buf && i == ent)
6265 return snprintf(buf, size, "%u", pf->id);
6273 /** Complete type field for RSS action. */
6275 comp_vc_action_rss_type(struct context *ctx, const struct token *token,
6276 unsigned int ent, char *buf, unsigned int size)
6282 for (i = 0; rss_type_table[i].str; ++i)
6287 return strlcpy(buf, rss_type_table[ent].str, size);
6289 return snprintf(buf, size, "end");
6293 /** Complete queue field for RSS action. */
6295 comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
6296 unsigned int ent, char *buf, unsigned int size)
6303 return snprintf(buf, size, "%u", ent);
6305 return snprintf(buf, size, "end");
6309 /** Complete index number for set raw_encap/raw_decap commands. */
6311 comp_set_raw_index(struct context *ctx, const struct token *token,
6312 unsigned int ent, char *buf, unsigned int size)
6318 RTE_SET_USED(token);
6319 for (idx = 0; idx < RAW_ENCAP_CONFS_MAX_NUM; ++idx) {
6320 if (buf && idx == ent)
6321 return snprintf(buf, size, "%u", idx);
6327 /** Internal context. */
6328 static struct context cmd_flow_context;
6330 /** Global parser instance (cmdline API). */
6331 cmdline_parse_inst_t cmd_flow;
6332 cmdline_parse_inst_t cmd_set_raw;
6334 /** Initialize context. */
6336 cmd_flow_context_init(struct context *ctx)
6338 /* A full memset() is not necessary. */
6348 ctx->objmask = NULL;
6351 /** Parse a token (cmdline API). */
6353 cmd_flow_parse(cmdline_parse_token_hdr_t *hdr, const char *src, void *result,
6356 struct context *ctx = &cmd_flow_context;
6357 const struct token *token;
6358 const enum index *list;
6363 token = &token_list[ctx->curr];
6364 /* Check argument length. */
6367 for (len = 0; src[len]; ++len)
6368 if (src[len] == '#' || isspace(src[len]))
6372 /* Last argument and EOL detection. */
6373 for (i = len; src[i]; ++i)
6374 if (src[i] == '#' || src[i] == '\r' || src[i] == '\n')
6376 else if (!isspace(src[i])) {
6381 if (src[i] == '\r' || src[i] == '\n') {
6385 /* Initialize context if necessary. */
6386 if (!ctx->next_num) {
6389 ctx->next[ctx->next_num++] = token->next[0];
6391 /* Process argument through candidates. */
6392 ctx->prev = ctx->curr;
6393 list = ctx->next[ctx->next_num - 1];
6394 for (i = 0; list[i]; ++i) {
6395 const struct token *next = &token_list[list[i]];
6398 ctx->curr = list[i];
6400 tmp = next->call(ctx, next, src, len, result, size);
6402 tmp = parse_default(ctx, next, src, len, result, size);
6403 if (tmp == -1 || tmp != len)
6411 /* Push subsequent tokens if any. */
6413 for (i = 0; token->next[i]; ++i) {
6414 if (ctx->next_num == RTE_DIM(ctx->next))
6416 ctx->next[ctx->next_num++] = token->next[i];
6418 /* Push arguments if any. */
6420 for (i = 0; token->args[i]; ++i) {
6421 if (ctx->args_num == RTE_DIM(ctx->args))
6423 ctx->args[ctx->args_num++] = token->args[i];
6428 /** Return number of completion entries (cmdline API). */
6430 cmd_flow_complete_get_nb(cmdline_parse_token_hdr_t *hdr)
6432 struct context *ctx = &cmd_flow_context;
6433 const struct token *token = &token_list[ctx->curr];
6434 const enum index *list;
6438 /* Count number of tokens in current list. */
6440 list = ctx->next[ctx->next_num - 1];
6442 list = token->next[0];
6443 for (i = 0; list[i]; ++i)
6448 * If there is a single token, use its completion callback, otherwise
6449 * return the number of entries.
6451 token = &token_list[list[0]];
6452 if (i == 1 && token->comp) {
6453 /* Save index for cmd_flow_get_help(). */
6454 ctx->prev = list[0];
6455 return token->comp(ctx, token, 0, NULL, 0);
6460 /** Return a completion entry (cmdline API). */
6462 cmd_flow_complete_get_elt(cmdline_parse_token_hdr_t *hdr, int index,
6463 char *dst, unsigned int size)
6465 struct context *ctx = &cmd_flow_context;
6466 const struct token *token = &token_list[ctx->curr];
6467 const enum index *list;
6471 /* Count number of tokens in current list. */
6473 list = ctx->next[ctx->next_num - 1];
6475 list = token->next[0];
6476 for (i = 0; list[i]; ++i)
6480 /* If there is a single token, use its completion callback. */
6481 token = &token_list[list[0]];
6482 if (i == 1 && token->comp) {
6483 /* Save index for cmd_flow_get_help(). */
6484 ctx->prev = list[0];
6485 return token->comp(ctx, token, index, dst, size) < 0 ? -1 : 0;
6487 /* Otherwise make sure the index is valid and use defaults. */
6490 token = &token_list[list[index]];
6491 strlcpy(dst, token->name, size);
6492 /* Save index for cmd_flow_get_help(). */
6493 ctx->prev = list[index];
6497 /** Populate help strings for current token (cmdline API). */
6499 cmd_flow_get_help(cmdline_parse_token_hdr_t *hdr, char *dst, unsigned int size)
6501 struct context *ctx = &cmd_flow_context;
6502 const struct token *token = &token_list[ctx->prev];
6507 /* Set token type and update global help with details. */
6508 strlcpy(dst, (token->type ? token->type : "TOKEN"), size);
6510 cmd_flow.help_str = token->help;
6512 cmd_flow.help_str = token->name;
6516 /** Token definition template (cmdline API). */
6517 static struct cmdline_token_hdr cmd_flow_token_hdr = {
6518 .ops = &(struct cmdline_token_ops){
6519 .parse = cmd_flow_parse,
6520 .complete_get_nb = cmd_flow_complete_get_nb,
6521 .complete_get_elt = cmd_flow_complete_get_elt,
6522 .get_help = cmd_flow_get_help,
6527 /** Populate the next dynamic token. */
6529 cmd_flow_tok(cmdline_parse_token_hdr_t **hdr,
6530 cmdline_parse_token_hdr_t **hdr_inst)
6532 struct context *ctx = &cmd_flow_context;
6534 /* Always reinitialize context before requesting the first token. */
6535 if (!(hdr_inst - cmd_flow.tokens))
6536 cmd_flow_context_init(ctx);
6537 /* Return NULL when no more tokens are expected. */
6538 if (!ctx->next_num && ctx->curr) {
6542 /* Determine if command should end here. */
6543 if (ctx->eol && ctx->last && ctx->next_num) {
6544 const enum index *list = ctx->next[ctx->next_num - 1];
6547 for (i = 0; list[i]; ++i) {
6554 *hdr = &cmd_flow_token_hdr;
6557 /** Dispatch parsed buffer to function calls. */
6559 cmd_flow_parsed(const struct buffer *in)
6561 switch (in->command) {
6563 port_flow_validate(in->port, &in->args.vc.attr,
6564 in->args.vc.pattern, in->args.vc.actions);
6567 port_flow_create(in->port, &in->args.vc.attr,
6568 in->args.vc.pattern, in->args.vc.actions);
6571 port_flow_destroy(in->port, in->args.destroy.rule_n,
6572 in->args.destroy.rule);
6575 port_flow_flush(in->port);
6578 port_flow_dump(in->port, in->args.dump.file);
6581 port_flow_query(in->port, in->args.query.rule,
6582 &in->args.query.action);
6585 port_flow_list(in->port, in->args.list.group_n,
6586 in->args.list.group);
6589 port_flow_isolate(in->port, in->args.isolate.set);
6592 port_flow_aged(in->port, in->args.aged.destroy);
6599 /** Token generator and output processing callback (cmdline API). */
6601 cmd_flow_cb(void *arg0, struct cmdline *cl, void *arg2)
6604 cmd_flow_tok(arg0, arg2);
6606 cmd_flow_parsed(arg0);
6609 /** Global parser instance (cmdline API). */
6610 cmdline_parse_inst_t cmd_flow = {
6612 .data = NULL, /**< Unused. */
6613 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
6616 }, /**< Tokens are returned by cmd_flow_tok(). */
6619 /** set cmd facility. Reuse cmd flow's infrastructure as much as possible. */
6622 update_fields(uint8_t *buf, struct rte_flow_item *item, uint16_t next_proto)
6624 struct rte_flow_item_ipv4 *ipv4;
6625 struct rte_flow_item_eth *eth;
6626 struct rte_flow_item_ipv6 *ipv6;
6627 struct rte_flow_item_vxlan *vxlan;
6628 struct rte_flow_item_vxlan_gpe *gpe;
6629 struct rte_flow_item_nvgre *nvgre;
6630 uint32_t ipv6_vtc_flow;
6632 switch (item->type) {
6633 case RTE_FLOW_ITEM_TYPE_ETH:
6634 eth = (struct rte_flow_item_eth *)buf;
6636 eth->type = rte_cpu_to_be_16(next_proto);
6638 case RTE_FLOW_ITEM_TYPE_IPV4:
6639 ipv4 = (struct rte_flow_item_ipv4 *)buf;
6640 ipv4->hdr.version_ihl = 0x45;
6641 if (next_proto && ipv4->hdr.next_proto_id == 0)
6642 ipv4->hdr.next_proto_id = (uint8_t)next_proto;
6644 case RTE_FLOW_ITEM_TYPE_IPV6:
6645 ipv6 = (struct rte_flow_item_ipv6 *)buf;
6646 if (next_proto && ipv6->hdr.proto == 0)
6647 ipv6->hdr.proto = (uint8_t)next_proto;
6648 ipv6_vtc_flow = rte_be_to_cpu_32(ipv6->hdr.vtc_flow);
6649 ipv6_vtc_flow &= 0x0FFFFFFF; /*< reset version bits. */
6650 ipv6_vtc_flow |= 0x60000000; /*< set ipv6 version. */
6651 ipv6->hdr.vtc_flow = rte_cpu_to_be_32(ipv6_vtc_flow);
6653 case RTE_FLOW_ITEM_TYPE_VXLAN:
6654 vxlan = (struct rte_flow_item_vxlan *)buf;
6655 vxlan->flags = 0x08;
6657 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
6658 gpe = (struct rte_flow_item_vxlan_gpe *)buf;
6661 case RTE_FLOW_ITEM_TYPE_NVGRE:
6662 nvgre = (struct rte_flow_item_nvgre *)buf;
6663 nvgre->protocol = rte_cpu_to_be_16(0x6558);
6664 nvgre->c_k_s_rsvd0_ver = rte_cpu_to_be_16(0x2000);
6671 /** Helper of get item's default mask. */
6673 flow_item_default_mask(const struct rte_flow_item *item)
6675 const void *mask = NULL;
6676 static rte_be32_t gre_key_default_mask = RTE_BE32(UINT32_MAX);
6678 switch (item->type) {
6679 case RTE_FLOW_ITEM_TYPE_ANY:
6680 mask = &rte_flow_item_any_mask;
6682 case RTE_FLOW_ITEM_TYPE_VF:
6683 mask = &rte_flow_item_vf_mask;
6685 case RTE_FLOW_ITEM_TYPE_PORT_ID:
6686 mask = &rte_flow_item_port_id_mask;
6688 case RTE_FLOW_ITEM_TYPE_RAW:
6689 mask = &rte_flow_item_raw_mask;
6691 case RTE_FLOW_ITEM_TYPE_ETH:
6692 mask = &rte_flow_item_eth_mask;
6694 case RTE_FLOW_ITEM_TYPE_VLAN:
6695 mask = &rte_flow_item_vlan_mask;
6697 case RTE_FLOW_ITEM_TYPE_IPV4:
6698 mask = &rte_flow_item_ipv4_mask;
6700 case RTE_FLOW_ITEM_TYPE_IPV6:
6701 mask = &rte_flow_item_ipv6_mask;
6703 case RTE_FLOW_ITEM_TYPE_ICMP:
6704 mask = &rte_flow_item_icmp_mask;
6706 case RTE_FLOW_ITEM_TYPE_UDP:
6707 mask = &rte_flow_item_udp_mask;
6709 case RTE_FLOW_ITEM_TYPE_TCP:
6710 mask = &rte_flow_item_tcp_mask;
6712 case RTE_FLOW_ITEM_TYPE_SCTP:
6713 mask = &rte_flow_item_sctp_mask;
6715 case RTE_FLOW_ITEM_TYPE_VXLAN:
6716 mask = &rte_flow_item_vxlan_mask;
6718 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
6719 mask = &rte_flow_item_vxlan_gpe_mask;
6721 case RTE_FLOW_ITEM_TYPE_E_TAG:
6722 mask = &rte_flow_item_e_tag_mask;
6724 case RTE_FLOW_ITEM_TYPE_NVGRE:
6725 mask = &rte_flow_item_nvgre_mask;
6727 case RTE_FLOW_ITEM_TYPE_MPLS:
6728 mask = &rte_flow_item_mpls_mask;
6730 case RTE_FLOW_ITEM_TYPE_GRE:
6731 mask = &rte_flow_item_gre_mask;
6733 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
6734 mask = &gre_key_default_mask;
6736 case RTE_FLOW_ITEM_TYPE_META:
6737 mask = &rte_flow_item_meta_mask;
6739 case RTE_FLOW_ITEM_TYPE_FUZZY:
6740 mask = &rte_flow_item_fuzzy_mask;
6742 case RTE_FLOW_ITEM_TYPE_GTP:
6743 mask = &rte_flow_item_gtp_mask;
6745 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
6746 mask = &rte_flow_item_gtp_psc_mask;
6748 case RTE_FLOW_ITEM_TYPE_GENEVE:
6749 mask = &rte_flow_item_geneve_mask;
6751 case RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID:
6752 mask = &rte_flow_item_pppoe_proto_id_mask;
6754 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
6755 mask = &rte_flow_item_l2tpv3oip_mask;
6757 case RTE_FLOW_ITEM_TYPE_ESP:
6758 mask = &rte_flow_item_esp_mask;
6760 case RTE_FLOW_ITEM_TYPE_AH:
6761 mask = &rte_flow_item_ah_mask;
6763 case RTE_FLOW_ITEM_TYPE_PFCP:
6764 mask = &rte_flow_item_pfcp_mask;
6774 /** Dispatch parsed buffer to function calls. */
6776 cmd_set_raw_parsed(const struct buffer *in)
6778 uint32_t n = in->args.vc.pattern_n;
6780 struct rte_flow_item *item = NULL;
6782 uint8_t *data = NULL;
6783 uint8_t *data_tail = NULL;
6784 size_t *total_size = NULL;
6785 uint16_t upper_layer = 0;
6787 uint16_t idx = in->port; /* We borrow port field as index */
6789 RTE_ASSERT(in->command == SET_RAW_ENCAP ||
6790 in->command == SET_RAW_DECAP);
6791 if (in->command == SET_RAW_ENCAP) {
6792 total_size = &raw_encap_confs[idx].size;
6793 data = (uint8_t *)&raw_encap_confs[idx].data;
6795 total_size = &raw_decap_confs[idx].size;
6796 data = (uint8_t *)&raw_decap_confs[idx].data;
6799 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
6800 /* process hdr from upper layer to low layer (L3/L4 -> L2). */
6801 data_tail = data + ACTION_RAW_ENCAP_MAX_DATA;
6802 for (i = n - 1 ; i >= 0; --i) {
6803 item = in->args.vc.pattern + i;
6804 if (item->spec == NULL)
6805 item->spec = flow_item_default_mask(item);
6806 switch (item->type) {
6807 case RTE_FLOW_ITEM_TYPE_ETH:
6808 size = sizeof(struct rte_flow_item_eth);
6810 case RTE_FLOW_ITEM_TYPE_VLAN:
6811 size = sizeof(struct rte_flow_item_vlan);
6812 proto = RTE_ETHER_TYPE_VLAN;
6814 case RTE_FLOW_ITEM_TYPE_IPV4:
6815 size = sizeof(struct rte_flow_item_ipv4);
6816 proto = RTE_ETHER_TYPE_IPV4;
6818 case RTE_FLOW_ITEM_TYPE_IPV6:
6819 size = sizeof(struct rte_flow_item_ipv6);
6820 proto = RTE_ETHER_TYPE_IPV6;
6822 case RTE_FLOW_ITEM_TYPE_UDP:
6823 size = sizeof(struct rte_flow_item_udp);
6826 case RTE_FLOW_ITEM_TYPE_TCP:
6827 size = sizeof(struct rte_flow_item_tcp);
6830 case RTE_FLOW_ITEM_TYPE_VXLAN:
6831 size = sizeof(struct rte_flow_item_vxlan);
6833 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
6834 size = sizeof(struct rte_flow_item_vxlan_gpe);
6836 case RTE_FLOW_ITEM_TYPE_GRE:
6837 size = sizeof(struct rte_flow_item_gre);
6840 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
6841 size = sizeof(rte_be32_t);
6844 case RTE_FLOW_ITEM_TYPE_MPLS:
6845 size = sizeof(struct rte_flow_item_mpls);
6848 case RTE_FLOW_ITEM_TYPE_NVGRE:
6849 size = sizeof(struct rte_flow_item_nvgre);
6852 case RTE_FLOW_ITEM_TYPE_GENEVE:
6853 size = sizeof(struct rte_flow_item_geneve);
6855 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
6856 size = sizeof(struct rte_flow_item_l2tpv3oip);
6859 case RTE_FLOW_ITEM_TYPE_ESP:
6860 size = sizeof(struct rte_flow_item_esp);
6863 case RTE_FLOW_ITEM_TYPE_AH:
6864 size = sizeof(struct rte_flow_item_ah);
6867 case RTE_FLOW_ITEM_TYPE_GTP:
6868 size = sizeof(struct rte_flow_item_gtp);
6870 case RTE_FLOW_ITEM_TYPE_PFCP:
6871 size = sizeof(struct rte_flow_item_pfcp);
6874 printf("Error - Not supported item\n");
6876 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
6879 *total_size += size;
6880 rte_memcpy(data_tail - (*total_size), item->spec, size);
6881 /* update some fields which cannot be set by cmdline */
6882 update_fields((data_tail - (*total_size)), item,
6884 upper_layer = proto;
6886 if (verbose_level & 0x1)
6887 printf("total data size is %zu\n", (*total_size));
6888 RTE_ASSERT((*total_size) <= ACTION_RAW_ENCAP_MAX_DATA);
6889 memmove(data, (data_tail - (*total_size)), *total_size);
6892 /** Populate help strings for current token (cmdline API). */
6894 cmd_set_raw_get_help(cmdline_parse_token_hdr_t *hdr, char *dst,
6897 struct context *ctx = &cmd_flow_context;
6898 const struct token *token = &token_list[ctx->prev];
6903 /* Set token type and update global help with details. */
6904 snprintf(dst, size, "%s", (token->type ? token->type : "TOKEN"));
6906 cmd_set_raw.help_str = token->help;
6908 cmd_set_raw.help_str = token->name;
6912 /** Token definition template (cmdline API). */
6913 static struct cmdline_token_hdr cmd_set_raw_token_hdr = {
6914 .ops = &(struct cmdline_token_ops){
6915 .parse = cmd_flow_parse,
6916 .complete_get_nb = cmd_flow_complete_get_nb,
6917 .complete_get_elt = cmd_flow_complete_get_elt,
6918 .get_help = cmd_set_raw_get_help,
6923 /** Populate the next dynamic token. */
6925 cmd_set_raw_tok(cmdline_parse_token_hdr_t **hdr,
6926 cmdline_parse_token_hdr_t **hdr_inst)
6928 struct context *ctx = &cmd_flow_context;
6930 /* Always reinitialize context before requesting the first token. */
6931 if (!(hdr_inst - cmd_set_raw.tokens)) {
6932 cmd_flow_context_init(ctx);
6933 ctx->curr = START_SET;
6935 /* Return NULL when no more tokens are expected. */
6936 if (!ctx->next_num && (ctx->curr != START_SET)) {
6940 /* Determine if command should end here. */
6941 if (ctx->eol && ctx->last && ctx->next_num) {
6942 const enum index *list = ctx->next[ctx->next_num - 1];
6945 for (i = 0; list[i]; ++i) {
6952 *hdr = &cmd_set_raw_token_hdr;
6955 /** Token generator and output processing callback (cmdline API). */
6957 cmd_set_raw_cb(void *arg0, struct cmdline *cl, void *arg2)
6960 cmd_set_raw_tok(arg0, arg2);
6962 cmd_set_raw_parsed(arg0);
6965 /** Global parser instance (cmdline API). */
6966 cmdline_parse_inst_t cmd_set_raw = {
6967 .f = cmd_set_raw_cb,
6968 .data = NULL, /**< Unused. */
6969 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
6972 }, /**< Tokens are returned by cmd_flow_tok(). */
6975 /* *** display raw_encap/raw_decap buf */
6976 struct cmd_show_set_raw_result {
6977 cmdline_fixed_string_t cmd_show;
6978 cmdline_fixed_string_t cmd_what;
6979 cmdline_fixed_string_t cmd_all;
6984 cmd_show_set_raw_parsed(void *parsed_result, struct cmdline *cl, void *data)
6986 struct cmd_show_set_raw_result *res = parsed_result;
6987 uint16_t index = res->cmd_index;
6989 uint8_t *raw_data = NULL;
6990 size_t raw_size = 0;
6991 char title[16] = {0};
6995 if (!strcmp(res->cmd_all, "all")) {
6998 } else if (index >= RAW_ENCAP_CONFS_MAX_NUM) {
6999 printf("index should be 0-%u\n", RAW_ENCAP_CONFS_MAX_NUM - 1);
7003 if (!strcmp(res->cmd_what, "raw_encap")) {
7004 raw_data = (uint8_t *)&raw_encap_confs[index].data;
7005 raw_size = raw_encap_confs[index].size;
7006 snprintf(title, 16, "\nindex: %u", index);
7007 rte_hexdump(stdout, title, raw_data, raw_size);
7009 raw_data = (uint8_t *)&raw_decap_confs[index].data;
7010 raw_size = raw_decap_confs[index].size;
7011 snprintf(title, 16, "\nindex: %u", index);
7012 rte_hexdump(stdout, title, raw_data, raw_size);
7014 } while (all && ++index < RAW_ENCAP_CONFS_MAX_NUM);
7017 cmdline_parse_token_string_t cmd_show_set_raw_cmd_show =
7018 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
7020 cmdline_parse_token_string_t cmd_show_set_raw_cmd_what =
7021 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
7022 cmd_what, "raw_encap#raw_decap");
7023 cmdline_parse_token_num_t cmd_show_set_raw_cmd_index =
7024 TOKEN_NUM_INITIALIZER(struct cmd_show_set_raw_result,
7026 cmdline_parse_token_string_t cmd_show_set_raw_cmd_all =
7027 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
7029 cmdline_parse_inst_t cmd_show_set_raw = {
7030 .f = cmd_show_set_raw_parsed,
7032 .help_str = "show <raw_encap|raw_decap> <index>",
7034 (void *)&cmd_show_set_raw_cmd_show,
7035 (void *)&cmd_show_set_raw_cmd_what,
7036 (void *)&cmd_show_set_raw_cmd_index,
7040 cmdline_parse_inst_t cmd_show_set_raw_all = {
7041 .f = cmd_show_set_raw_parsed,
7043 .help_str = "show <raw_encap|raw_decap> all",
7045 (void *)&cmd_show_set_raw_cmd_show,
7046 (void *)&cmd_show_set_raw_cmd_what,
7047 (void *)&cmd_show_set_raw_cmd_all,