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. */
72 /* Destroy arguments. */
75 /* Query arguments. */
81 /* Validate/create arguments. */
88 /* Validate/create pattern. */
125 ITEM_VLAN_INNER_TYPE,
157 ITEM_E_TAG_GRP_ECID_B,
166 ITEM_GRE_C_RSVD0_VER,
183 ITEM_ARP_ETH_IPV4_SHA,
184 ITEM_ARP_ETH_IPV4_SPA,
185 ITEM_ARP_ETH_IPV4_THA,
186 ITEM_ARP_ETH_IPV4_TPA,
188 ITEM_IPV6_EXT_NEXT_HDR,
193 ITEM_ICMP6_ND_NS_TARGET_ADDR,
195 ITEM_ICMP6_ND_NA_TARGET_ADDR,
197 ITEM_ICMP6_ND_OPT_TYPE,
198 ITEM_ICMP6_ND_OPT_SLA_ETH,
199 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
200 ITEM_ICMP6_ND_OPT_TLA_ETH,
201 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
214 ITEM_HIGIG2_CLASSIFICATION,
220 ITEM_L2TPV3OIP_SESSION_ID,
226 /* Validate/create actions. */
246 ACTION_RSS_FUNC_DEFAULT,
247 ACTION_RSS_FUNC_TOEPLITZ,
248 ACTION_RSS_FUNC_SIMPLE_XOR,
249 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ,
261 ACTION_PHY_PORT_ORIGINAL,
262 ACTION_PHY_PORT_INDEX,
264 ACTION_PORT_ID_ORIGINAL,
268 ACTION_OF_SET_MPLS_TTL,
269 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
270 ACTION_OF_DEC_MPLS_TTL,
271 ACTION_OF_SET_NW_TTL,
272 ACTION_OF_SET_NW_TTL_NW_TTL,
273 ACTION_OF_DEC_NW_TTL,
274 ACTION_OF_COPY_TTL_OUT,
275 ACTION_OF_COPY_TTL_IN,
278 ACTION_OF_PUSH_VLAN_ETHERTYPE,
279 ACTION_OF_SET_VLAN_VID,
280 ACTION_OF_SET_VLAN_VID_VLAN_VID,
281 ACTION_OF_SET_VLAN_PCP,
282 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
284 ACTION_OF_POP_MPLS_ETHERTYPE,
286 ACTION_OF_PUSH_MPLS_ETHERTYPE,
293 ACTION_MPLSOGRE_ENCAP,
294 ACTION_MPLSOGRE_DECAP,
295 ACTION_MPLSOUDP_ENCAP,
296 ACTION_MPLSOUDP_DECAP,
298 ACTION_SET_IPV4_SRC_IPV4_SRC,
300 ACTION_SET_IPV4_DST_IPV4_DST,
302 ACTION_SET_IPV6_SRC_IPV6_SRC,
304 ACTION_SET_IPV6_DST_IPV6_DST,
306 ACTION_SET_TP_SRC_TP_SRC,
308 ACTION_SET_TP_DST_TP_DST,
314 ACTION_SET_MAC_SRC_MAC_SRC,
316 ACTION_SET_MAC_DST_MAC_DST,
318 ACTION_INC_TCP_SEQ_VALUE,
320 ACTION_DEC_TCP_SEQ_VALUE,
322 ACTION_INC_TCP_ACK_VALUE,
324 ACTION_DEC_TCP_ACK_VALUE,
327 ACTION_RAW_ENCAP_INDEX,
328 ACTION_RAW_ENCAP_INDEX_VALUE,
329 ACTION_RAW_DECAP_INDEX,
330 ACTION_RAW_DECAP_INDEX_VALUE,
333 ACTION_SET_TAG_INDEX,
336 ACTION_SET_META_DATA,
337 ACTION_SET_META_MASK,
338 ACTION_SET_IPV4_DSCP,
339 ACTION_SET_IPV4_DSCP_VALUE,
340 ACTION_SET_IPV6_DSCP,
341 ACTION_SET_IPV6_DSCP_VALUE,
344 /** Maximum size for pattern in struct rte_flow_item_raw. */
345 #define ITEM_RAW_PATTERN_SIZE 40
347 /** Storage size for struct rte_flow_item_raw including pattern. */
348 #define ITEM_RAW_SIZE \
349 (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE)
351 /** Maximum number of queue indices in struct rte_flow_action_rss. */
352 #define ACTION_RSS_QUEUE_NUM 128
354 /** Storage for struct rte_flow_action_rss including external data. */
355 struct action_rss_data {
356 struct rte_flow_action_rss conf;
357 uint8_t key[RSS_HASH_KEY_LENGTH];
358 uint16_t queue[ACTION_RSS_QUEUE_NUM];
361 /** Maximum data size in struct rte_flow_action_raw_encap. */
362 #define ACTION_RAW_ENCAP_MAX_DATA 128
363 #define RAW_ENCAP_CONFS_MAX_NUM 8
365 /** Storage for struct rte_flow_action_raw_encap. */
366 struct raw_encap_conf {
367 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
368 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
372 struct raw_encap_conf raw_encap_confs[RAW_ENCAP_CONFS_MAX_NUM];
374 /** Storage for struct rte_flow_action_raw_encap including external data. */
375 struct action_raw_encap_data {
376 struct rte_flow_action_raw_encap conf;
377 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
378 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
382 /** Storage for struct rte_flow_action_raw_decap. */
383 struct raw_decap_conf {
384 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
388 struct raw_decap_conf raw_decap_confs[RAW_ENCAP_CONFS_MAX_NUM];
390 /** Storage for struct rte_flow_action_raw_decap including external data. */
391 struct action_raw_decap_data {
392 struct rte_flow_action_raw_decap conf;
393 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
397 struct vxlan_encap_conf vxlan_encap_conf = {
401 .vni = "\x00\x00\x00",
403 .udp_dst = RTE_BE16(4789),
404 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
405 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
406 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
407 "\x00\x00\x00\x00\x00\x00\x00\x01",
408 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
409 "\x00\x00\x00\x00\x00\x00\x11\x11",
413 .eth_src = "\x00\x00\x00\x00\x00\x00",
414 .eth_dst = "\xff\xff\xff\xff\xff\xff",
417 /** Maximum number of items in struct rte_flow_action_vxlan_encap. */
418 #define ACTION_VXLAN_ENCAP_ITEMS_NUM 6
420 /** Storage for struct rte_flow_action_vxlan_encap including external data. */
421 struct action_vxlan_encap_data {
422 struct rte_flow_action_vxlan_encap conf;
423 struct rte_flow_item items[ACTION_VXLAN_ENCAP_ITEMS_NUM];
424 struct rte_flow_item_eth item_eth;
425 struct rte_flow_item_vlan item_vlan;
427 struct rte_flow_item_ipv4 item_ipv4;
428 struct rte_flow_item_ipv6 item_ipv6;
430 struct rte_flow_item_udp item_udp;
431 struct rte_flow_item_vxlan item_vxlan;
434 struct nvgre_encap_conf nvgre_encap_conf = {
437 .tni = "\x00\x00\x00",
438 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
439 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
440 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
441 "\x00\x00\x00\x00\x00\x00\x00\x01",
442 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
443 "\x00\x00\x00\x00\x00\x00\x11\x11",
445 .eth_src = "\x00\x00\x00\x00\x00\x00",
446 .eth_dst = "\xff\xff\xff\xff\xff\xff",
449 /** Maximum number of items in struct rte_flow_action_nvgre_encap. */
450 #define ACTION_NVGRE_ENCAP_ITEMS_NUM 5
452 /** Storage for struct rte_flow_action_nvgre_encap including external data. */
453 struct action_nvgre_encap_data {
454 struct rte_flow_action_nvgre_encap conf;
455 struct rte_flow_item items[ACTION_NVGRE_ENCAP_ITEMS_NUM];
456 struct rte_flow_item_eth item_eth;
457 struct rte_flow_item_vlan item_vlan;
459 struct rte_flow_item_ipv4 item_ipv4;
460 struct rte_flow_item_ipv6 item_ipv6;
462 struct rte_flow_item_nvgre item_nvgre;
465 struct l2_encap_conf l2_encap_conf;
467 struct l2_decap_conf l2_decap_conf;
469 struct mplsogre_encap_conf mplsogre_encap_conf;
471 struct mplsogre_decap_conf mplsogre_decap_conf;
473 struct mplsoudp_encap_conf mplsoudp_encap_conf;
475 struct mplsoudp_decap_conf mplsoudp_decap_conf;
477 /** Maximum number of subsequent tokens and arguments on the stack. */
478 #define CTX_STACK_SIZE 16
480 /** Parser context. */
482 /** Stack of subsequent token lists to process. */
483 const enum index *next[CTX_STACK_SIZE];
484 /** Arguments for stacked tokens. */
485 const void *args[CTX_STACK_SIZE];
486 enum index curr; /**< Current token index. */
487 enum index prev; /**< Index of the last token seen. */
488 int next_num; /**< Number of entries in next[]. */
489 int args_num; /**< Number of entries in args[]. */
490 uint32_t eol:1; /**< EOL has been detected. */
491 uint32_t last:1; /**< No more arguments. */
492 portid_t port; /**< Current port ID (for completions). */
493 uint32_t objdata; /**< Object-specific data. */
494 void *object; /**< Address of current object for relative offsets. */
495 void *objmask; /**< Object a full mask must be written to. */
498 /** Token argument. */
500 uint32_t hton:1; /**< Use network byte ordering. */
501 uint32_t sign:1; /**< Value is signed. */
502 uint32_t bounded:1; /**< Value is bounded. */
503 uintmax_t min; /**< Minimum value if bounded. */
504 uintmax_t max; /**< Maximum value if bounded. */
505 uint32_t offset; /**< Relative offset from ctx->object. */
506 uint32_t size; /**< Field size. */
507 const uint8_t *mask; /**< Bit-mask to use instead of offset/size. */
510 /** Parser token definition. */
512 /** Type displayed during completion (defaults to "TOKEN"). */
514 /** Help displayed during completion (defaults to token name). */
516 /** Private data used by parser functions. */
519 * Lists of subsequent tokens to push on the stack. Each call to the
520 * parser consumes the last entry of that stack.
522 const enum index *const *next;
523 /** Arguments stack for subsequent tokens that need them. */
524 const struct arg *const *args;
526 * Token-processing callback, returns -1 in case of error, the
527 * length of the matched string otherwise. If NULL, attempts to
528 * match the token name.
530 * If buf is not NULL, the result should be stored in it according
531 * to context. An error is returned if not large enough.
533 int (*call)(struct context *ctx, const struct token *token,
534 const char *str, unsigned int len,
535 void *buf, unsigned int size);
537 * Callback that provides possible values for this token, used for
538 * completion. Returns -1 in case of error, the number of possible
539 * values otherwise. If NULL, the token name is used.
541 * If buf is not NULL, entry index ent is written to buf and the
542 * full length of the entry is returned (same behavior as
545 int (*comp)(struct context *ctx, const struct token *token,
546 unsigned int ent, char *buf, unsigned int size);
547 /** Mandatory token name, no default value. */
551 /** Static initializer for the next field. */
552 #define NEXT(...) (const enum index *const []){ __VA_ARGS__, NULL, }
554 /** Static initializer for a NEXT() entry. */
555 #define NEXT_ENTRY(...) (const enum index []){ __VA_ARGS__, ZERO, }
557 /** Static initializer for the args field. */
558 #define ARGS(...) (const struct arg *const []){ __VA_ARGS__, NULL, }
560 /** Static initializer for ARGS() to target a field. */
561 #define ARGS_ENTRY(s, f) \
562 (&(const struct arg){ \
563 .offset = offsetof(s, f), \
564 .size = sizeof(((s *)0)->f), \
567 /** Static initializer for ARGS() to target a bit-field. */
568 #define ARGS_ENTRY_BF(s, f, b) \
569 (&(const struct arg){ \
571 .mask = (const void *)&(const s){ .f = (1 << (b)) - 1 }, \
574 /** Static initializer for ARGS() to target an arbitrary bit-mask. */
575 #define ARGS_ENTRY_MASK(s, f, m) \
576 (&(const struct arg){ \
577 .offset = offsetof(s, f), \
578 .size = sizeof(((s *)0)->f), \
579 .mask = (const void *)(m), \
582 /** Same as ARGS_ENTRY_MASK() using network byte ordering for the value. */
583 #define ARGS_ENTRY_MASK_HTON(s, f, m) \
584 (&(const struct arg){ \
586 .offset = offsetof(s, f), \
587 .size = sizeof(((s *)0)->f), \
588 .mask = (const void *)(m), \
591 /** Static initializer for ARGS() to target a pointer. */
592 #define ARGS_ENTRY_PTR(s, f) \
593 (&(const struct arg){ \
594 .size = sizeof(*((s *)0)->f), \
597 /** Static initializer for ARGS() with arbitrary offset and size. */
598 #define ARGS_ENTRY_ARB(o, s) \
599 (&(const struct arg){ \
604 /** Same as ARGS_ENTRY_ARB() with bounded values. */
605 #define ARGS_ENTRY_ARB_BOUNDED(o, s, i, a) \
606 (&(const struct arg){ \
614 /** Same as ARGS_ENTRY() using network byte ordering. */
615 #define ARGS_ENTRY_HTON(s, f) \
616 (&(const struct arg){ \
618 .offset = offsetof(s, f), \
619 .size = sizeof(((s *)0)->f), \
622 /** Same as ARGS_ENTRY_HTON() for a single argument, without structure. */
623 #define ARG_ENTRY_HTON(s) \
624 (&(const struct arg){ \
630 /** Parser output buffer layout expected by cmd_flow_parsed(). */
632 enum index command; /**< Flow command. */
633 portid_t port; /**< Affected port ID. */
636 struct rte_flow_attr attr;
637 struct rte_flow_item *pattern;
638 struct rte_flow_action *actions;
642 } vc; /**< Validate/create arguments. */
646 } destroy; /**< Destroy arguments. */
649 } dump; /**< Dump arguments. */
652 struct rte_flow_action action;
653 } query; /**< Query arguments. */
657 } list; /**< List arguments. */
660 } isolate; /**< Isolated mode arguments. */
661 } args; /**< Command arguments. */
664 /** Private data for pattern items. */
665 struct parse_item_priv {
666 enum rte_flow_item_type type; /**< Item type. */
667 uint32_t size; /**< Size of item specification structure. */
670 #define PRIV_ITEM(t, s) \
671 (&(const struct parse_item_priv){ \
672 .type = RTE_FLOW_ITEM_TYPE_ ## t, \
676 /** Private data for actions. */
677 struct parse_action_priv {
678 enum rte_flow_action_type type; /**< Action type. */
679 uint32_t size; /**< Size of action configuration structure. */
682 #define PRIV_ACTION(t, s) \
683 (&(const struct parse_action_priv){ \
684 .type = RTE_FLOW_ACTION_TYPE_ ## t, \
688 static const enum index next_vc_attr[] = {
698 static const enum index next_destroy_attr[] = {
704 static const enum index next_dump_attr[] = {
710 static const enum index next_list_attr[] = {
716 static const enum index item_param[] = {
725 static const enum index next_item[] = {
761 ITEM_ICMP6_ND_OPT_SLA_ETH,
762 ITEM_ICMP6_ND_OPT_TLA_ETH,
778 static const enum index item_fuzzy[] = {
784 static const enum index item_any[] = {
790 static const enum index item_vf[] = {
796 static const enum index item_phy_port[] = {
802 static const enum index item_port_id[] = {
808 static const enum index item_mark[] = {
814 static const enum index item_raw[] = {
824 static const enum index item_eth[] = {
832 static const enum index item_vlan[] = {
837 ITEM_VLAN_INNER_TYPE,
842 static const enum index item_ipv4[] = {
852 static const enum index item_ipv6[] = {
863 static const enum index item_icmp[] = {
870 static const enum index item_udp[] = {
877 static const enum index item_tcp[] = {
885 static const enum index item_sctp[] = {
894 static const enum index item_vxlan[] = {
900 static const enum index item_e_tag[] = {
901 ITEM_E_TAG_GRP_ECID_B,
906 static const enum index item_nvgre[] = {
912 static const enum index item_mpls[] = {
920 static const enum index item_gre[] = {
922 ITEM_GRE_C_RSVD0_VER,
930 static const enum index item_gre_key[] = {
936 static const enum index item_gtp[] = {
943 static const enum index item_geneve[] = {
950 static const enum index item_vxlan_gpe[] = {
956 static const enum index item_arp_eth_ipv4[] = {
957 ITEM_ARP_ETH_IPV4_SHA,
958 ITEM_ARP_ETH_IPV4_SPA,
959 ITEM_ARP_ETH_IPV4_THA,
960 ITEM_ARP_ETH_IPV4_TPA,
965 static const enum index item_ipv6_ext[] = {
966 ITEM_IPV6_EXT_NEXT_HDR,
971 static const enum index item_icmp6[] = {
978 static const enum index item_icmp6_nd_ns[] = {
979 ITEM_ICMP6_ND_NS_TARGET_ADDR,
984 static const enum index item_icmp6_nd_na[] = {
985 ITEM_ICMP6_ND_NA_TARGET_ADDR,
990 static const enum index item_icmp6_nd_opt[] = {
991 ITEM_ICMP6_ND_OPT_TYPE,
996 static const enum index item_icmp6_nd_opt_sla_eth[] = {
997 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
1002 static const enum index item_icmp6_nd_opt_tla_eth[] = {
1003 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
1008 static const enum index item_meta[] = {
1014 static const enum index item_gtp_psc[] = {
1021 static const enum index item_pppoed[] = {
1027 static const enum index item_pppoes[] = {
1033 static const enum index item_pppoe_proto_id[] = {
1034 ITEM_PPPOE_PROTO_ID,
1039 static const enum index item_higig2[] = {
1040 ITEM_HIGIG2_CLASSIFICATION,
1046 static const enum index item_esp[] = {
1052 static const enum index item_ah[] = {
1058 static const enum index next_set_raw[] = {
1064 static const enum index item_tag[] = {
1071 static const enum index item_l2tpv3oip[] = {
1072 ITEM_L2TPV3OIP_SESSION_ID,
1077 static const enum index next_action[] = {
1093 ACTION_OF_SET_MPLS_TTL,
1094 ACTION_OF_DEC_MPLS_TTL,
1095 ACTION_OF_SET_NW_TTL,
1096 ACTION_OF_DEC_NW_TTL,
1097 ACTION_OF_COPY_TTL_OUT,
1098 ACTION_OF_COPY_TTL_IN,
1100 ACTION_OF_PUSH_VLAN,
1101 ACTION_OF_SET_VLAN_VID,
1102 ACTION_OF_SET_VLAN_PCP,
1104 ACTION_OF_PUSH_MPLS,
1111 ACTION_MPLSOGRE_ENCAP,
1112 ACTION_MPLSOGRE_DECAP,
1113 ACTION_MPLSOUDP_ENCAP,
1114 ACTION_MPLSOUDP_DECAP,
1115 ACTION_SET_IPV4_SRC,
1116 ACTION_SET_IPV4_DST,
1117 ACTION_SET_IPV6_SRC,
1118 ACTION_SET_IPV6_DST,
1134 ACTION_SET_IPV4_DSCP,
1135 ACTION_SET_IPV6_DSCP,
1139 static const enum index action_mark[] = {
1145 static const enum index action_queue[] = {
1151 static const enum index action_count[] = {
1153 ACTION_COUNT_SHARED,
1158 static const enum index action_rss[] = {
1169 static const enum index action_vf[] = {
1176 static const enum index action_phy_port[] = {
1177 ACTION_PHY_PORT_ORIGINAL,
1178 ACTION_PHY_PORT_INDEX,
1183 static const enum index action_port_id[] = {
1184 ACTION_PORT_ID_ORIGINAL,
1190 static const enum index action_meter[] = {
1196 static const enum index action_of_set_mpls_ttl[] = {
1197 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
1202 static const enum index action_of_set_nw_ttl[] = {
1203 ACTION_OF_SET_NW_TTL_NW_TTL,
1208 static const enum index action_of_push_vlan[] = {
1209 ACTION_OF_PUSH_VLAN_ETHERTYPE,
1214 static const enum index action_of_set_vlan_vid[] = {
1215 ACTION_OF_SET_VLAN_VID_VLAN_VID,
1220 static const enum index action_of_set_vlan_pcp[] = {
1221 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
1226 static const enum index action_of_pop_mpls[] = {
1227 ACTION_OF_POP_MPLS_ETHERTYPE,
1232 static const enum index action_of_push_mpls[] = {
1233 ACTION_OF_PUSH_MPLS_ETHERTYPE,
1238 static const enum index action_set_ipv4_src[] = {
1239 ACTION_SET_IPV4_SRC_IPV4_SRC,
1244 static const enum index action_set_mac_src[] = {
1245 ACTION_SET_MAC_SRC_MAC_SRC,
1250 static const enum index action_set_ipv4_dst[] = {
1251 ACTION_SET_IPV4_DST_IPV4_DST,
1256 static const enum index action_set_ipv6_src[] = {
1257 ACTION_SET_IPV6_SRC_IPV6_SRC,
1262 static const enum index action_set_ipv6_dst[] = {
1263 ACTION_SET_IPV6_DST_IPV6_DST,
1268 static const enum index action_set_tp_src[] = {
1269 ACTION_SET_TP_SRC_TP_SRC,
1274 static const enum index action_set_tp_dst[] = {
1275 ACTION_SET_TP_DST_TP_DST,
1280 static const enum index action_set_ttl[] = {
1286 static const enum index action_jump[] = {
1292 static const enum index action_set_mac_dst[] = {
1293 ACTION_SET_MAC_DST_MAC_DST,
1298 static const enum index action_inc_tcp_seq[] = {
1299 ACTION_INC_TCP_SEQ_VALUE,
1304 static const enum index action_dec_tcp_seq[] = {
1305 ACTION_DEC_TCP_SEQ_VALUE,
1310 static const enum index action_inc_tcp_ack[] = {
1311 ACTION_INC_TCP_ACK_VALUE,
1316 static const enum index action_dec_tcp_ack[] = {
1317 ACTION_DEC_TCP_ACK_VALUE,
1322 static const enum index action_raw_encap[] = {
1323 ACTION_RAW_ENCAP_INDEX,
1328 static const enum index action_raw_decap[] = {
1329 ACTION_RAW_DECAP_INDEX,
1334 static const enum index action_set_tag[] = {
1335 ACTION_SET_TAG_DATA,
1336 ACTION_SET_TAG_INDEX,
1337 ACTION_SET_TAG_MASK,
1342 static const enum index action_set_meta[] = {
1343 ACTION_SET_META_DATA,
1344 ACTION_SET_META_MASK,
1349 static const enum index action_set_ipv4_dscp[] = {
1350 ACTION_SET_IPV4_DSCP_VALUE,
1355 static const enum index action_set_ipv6_dscp[] = {
1356 ACTION_SET_IPV6_DSCP_VALUE,
1361 static int parse_set_raw_encap_decap(struct context *, const struct token *,
1362 const char *, unsigned int,
1363 void *, unsigned int);
1364 static int parse_set_init(struct context *, const struct token *,
1365 const char *, unsigned int,
1366 void *, unsigned int);
1367 static int parse_init(struct context *, const struct token *,
1368 const char *, unsigned int,
1369 void *, unsigned int);
1370 static int parse_vc(struct context *, const struct token *,
1371 const char *, unsigned int,
1372 void *, unsigned int);
1373 static int parse_vc_spec(struct context *, const struct token *,
1374 const char *, unsigned int, void *, unsigned int);
1375 static int parse_vc_conf(struct context *, const struct token *,
1376 const char *, unsigned int, void *, unsigned int);
1377 static int parse_vc_action_rss(struct context *, const struct token *,
1378 const char *, unsigned int, void *,
1380 static int parse_vc_action_rss_func(struct context *, const struct token *,
1381 const char *, unsigned int, void *,
1383 static int parse_vc_action_rss_type(struct context *, const struct token *,
1384 const char *, unsigned int, void *,
1386 static int parse_vc_action_rss_queue(struct context *, const struct token *,
1387 const char *, unsigned int, void *,
1389 static int parse_vc_action_vxlan_encap(struct context *, const struct token *,
1390 const char *, unsigned int, void *,
1392 static int parse_vc_action_nvgre_encap(struct context *, const struct token *,
1393 const char *, unsigned int, void *,
1395 static int parse_vc_action_l2_encap(struct context *, const struct token *,
1396 const char *, unsigned int, void *,
1398 static int parse_vc_action_l2_decap(struct context *, const struct token *,
1399 const char *, unsigned int, void *,
1401 static int parse_vc_action_mplsogre_encap(struct context *,
1402 const struct token *, const char *,
1403 unsigned int, void *, unsigned int);
1404 static int parse_vc_action_mplsogre_decap(struct context *,
1405 const struct token *, const char *,
1406 unsigned int, void *, unsigned int);
1407 static int parse_vc_action_mplsoudp_encap(struct context *,
1408 const struct token *, const char *,
1409 unsigned int, void *, unsigned int);
1410 static int parse_vc_action_mplsoudp_decap(struct context *,
1411 const struct token *, const char *,
1412 unsigned int, void *, unsigned int);
1413 static int parse_vc_action_raw_encap(struct context *,
1414 const struct token *, const char *,
1415 unsigned int, void *, unsigned int);
1416 static int parse_vc_action_raw_decap(struct context *,
1417 const struct token *, const char *,
1418 unsigned int, void *, unsigned int);
1419 static int parse_vc_action_raw_encap_index(struct context *,
1420 const struct token *, const char *,
1421 unsigned int, void *, unsigned int);
1422 static int parse_vc_action_raw_decap_index(struct context *,
1423 const struct token *, const char *,
1424 unsigned int, void *, unsigned int);
1425 static int parse_vc_action_set_meta(struct context *ctx,
1426 const struct token *token, const char *str,
1427 unsigned int len, void *buf,
1429 static int parse_destroy(struct context *, const struct token *,
1430 const char *, unsigned int,
1431 void *, unsigned int);
1432 static int parse_flush(struct context *, const struct token *,
1433 const char *, unsigned int,
1434 void *, unsigned int);
1435 static int parse_dump(struct context *, const struct token *,
1436 const char *, unsigned int,
1437 void *, unsigned int);
1438 static int parse_query(struct context *, const struct token *,
1439 const char *, unsigned int,
1440 void *, unsigned int);
1441 static int parse_action(struct context *, const struct token *,
1442 const char *, unsigned int,
1443 void *, unsigned int);
1444 static int parse_list(struct context *, const struct token *,
1445 const char *, unsigned int,
1446 void *, unsigned int);
1447 static int parse_isolate(struct context *, const struct token *,
1448 const char *, unsigned int,
1449 void *, unsigned int);
1450 static int parse_int(struct context *, const struct token *,
1451 const char *, unsigned int,
1452 void *, unsigned int);
1453 static int parse_prefix(struct context *, const struct token *,
1454 const char *, unsigned int,
1455 void *, unsigned int);
1456 static int parse_boolean(struct context *, const struct token *,
1457 const char *, unsigned int,
1458 void *, unsigned int);
1459 static int parse_string(struct context *, const struct token *,
1460 const char *, unsigned int,
1461 void *, unsigned int);
1462 static int parse_hex(struct context *ctx, const struct token *token,
1463 const char *str, unsigned int len,
1464 void *buf, unsigned int size);
1465 static int parse_string0(struct context *, const struct token *,
1466 const char *, unsigned int,
1467 void *, unsigned int);
1468 static int parse_mac_addr(struct context *, const struct token *,
1469 const char *, unsigned int,
1470 void *, unsigned int);
1471 static int parse_ipv4_addr(struct context *, const struct token *,
1472 const char *, unsigned int,
1473 void *, unsigned int);
1474 static int parse_ipv6_addr(struct context *, const struct token *,
1475 const char *, unsigned int,
1476 void *, unsigned int);
1477 static int parse_port(struct context *, const struct token *,
1478 const char *, unsigned int,
1479 void *, unsigned int);
1480 static int comp_none(struct context *, const struct token *,
1481 unsigned int, char *, unsigned int);
1482 static int comp_boolean(struct context *, const struct token *,
1483 unsigned int, char *, unsigned int);
1484 static int comp_action(struct context *, const struct token *,
1485 unsigned int, char *, unsigned int);
1486 static int comp_port(struct context *, const struct token *,
1487 unsigned int, char *, unsigned int);
1488 static int comp_rule_id(struct context *, const struct token *,
1489 unsigned int, char *, unsigned int);
1490 static int comp_vc_action_rss_type(struct context *, const struct token *,
1491 unsigned int, char *, unsigned int);
1492 static int comp_vc_action_rss_queue(struct context *, const struct token *,
1493 unsigned int, char *, unsigned int);
1494 static int comp_set_raw_index(struct context *, const struct token *,
1495 unsigned int, char *, unsigned int);
1497 /** Token definitions. */
1498 static const struct token token_list[] = {
1499 /* Special tokens. */
1502 .help = "null entry, abused as the entry point",
1503 .next = NEXT(NEXT_ENTRY(FLOW)),
1508 .help = "command may end here",
1511 .name = "START_SET",
1512 .help = "null entry, abused as the entry point for set",
1513 .next = NEXT(NEXT_ENTRY(SET)),
1518 .help = "set command may end here",
1520 /* Common tokens. */
1524 .help = "integer value",
1529 .name = "{unsigned}",
1531 .help = "unsigned integer value",
1538 .help = "prefix length for bit-mask",
1539 .call = parse_prefix,
1543 .name = "{boolean}",
1545 .help = "any boolean value",
1546 .call = parse_boolean,
1547 .comp = comp_boolean,
1552 .help = "fixed string",
1553 .call = parse_string,
1559 .help = "fixed string",
1563 .name = "{file path}",
1565 .help = "file path",
1566 .call = parse_string0,
1570 .name = "{MAC address}",
1572 .help = "standard MAC address notation",
1573 .call = parse_mac_addr,
1577 .name = "{IPv4 address}",
1578 .type = "IPV4 ADDRESS",
1579 .help = "standard IPv4 address notation",
1580 .call = parse_ipv4_addr,
1584 .name = "{IPv6 address}",
1585 .type = "IPV6 ADDRESS",
1586 .help = "standard IPv6 address notation",
1587 .call = parse_ipv6_addr,
1591 .name = "{rule id}",
1593 .help = "rule identifier",
1595 .comp = comp_rule_id,
1598 .name = "{port_id}",
1600 .help = "port identifier",
1605 .name = "{group_id}",
1607 .help = "group identifier",
1611 [PRIORITY_LEVEL] = {
1614 .help = "priority level",
1618 /* Top-level command. */
1621 .type = "{command} {port_id} [{arg} [...]]",
1622 .help = "manage ingress/egress flow rules",
1623 .next = NEXT(NEXT_ENTRY
1634 /* Sub-level commands. */
1637 .help = "check whether a flow rule can be created",
1638 .next = NEXT(next_vc_attr, NEXT_ENTRY(PORT_ID)),
1639 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1644 .help = "create a flow rule",
1645 .next = NEXT(next_vc_attr, NEXT_ENTRY(PORT_ID)),
1646 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1651 .help = "destroy specific flow rules",
1652 .next = NEXT(NEXT_ENTRY(DESTROY_RULE), NEXT_ENTRY(PORT_ID)),
1653 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1654 .call = parse_destroy,
1658 .help = "destroy all flow rules",
1659 .next = NEXT(NEXT_ENTRY(PORT_ID)),
1660 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1661 .call = parse_flush,
1665 .help = "dump all flow rules to file",
1666 .next = NEXT(next_dump_attr, NEXT_ENTRY(PORT_ID)),
1667 .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file),
1668 ARGS_ENTRY(struct buffer, port)),
1673 .help = "query an existing flow rule",
1674 .next = NEXT(NEXT_ENTRY(QUERY_ACTION),
1675 NEXT_ENTRY(RULE_ID),
1676 NEXT_ENTRY(PORT_ID)),
1677 .args = ARGS(ARGS_ENTRY(struct buffer, args.query.action.type),
1678 ARGS_ENTRY(struct buffer, args.query.rule),
1679 ARGS_ENTRY(struct buffer, port)),
1680 .call = parse_query,
1684 .help = "list existing flow rules",
1685 .next = NEXT(next_list_attr, NEXT_ENTRY(PORT_ID)),
1686 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1691 .help = "restrict ingress traffic to the defined flow rules",
1692 .next = NEXT(NEXT_ENTRY(BOOLEAN),
1693 NEXT_ENTRY(PORT_ID)),
1694 .args = ARGS(ARGS_ENTRY(struct buffer, args.isolate.set),
1695 ARGS_ENTRY(struct buffer, port)),
1696 .call = parse_isolate,
1698 /* Destroy arguments. */
1701 .help = "specify a rule identifier",
1702 .next = NEXT(next_destroy_attr, NEXT_ENTRY(RULE_ID)),
1703 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.destroy.rule)),
1704 .call = parse_destroy,
1706 /* Query arguments. */
1710 .help = "action to query, must be part of the rule",
1711 .call = parse_action,
1712 .comp = comp_action,
1714 /* List arguments. */
1717 .help = "specify a group",
1718 .next = NEXT(next_list_attr, NEXT_ENTRY(GROUP_ID)),
1719 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.list.group)),
1722 /* Validate/create attributes. */
1725 .help = "specify a group",
1726 .next = NEXT(next_vc_attr, NEXT_ENTRY(GROUP_ID)),
1727 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, group)),
1732 .help = "specify a priority level",
1733 .next = NEXT(next_vc_attr, NEXT_ENTRY(PRIORITY_LEVEL)),
1734 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, priority)),
1739 .help = "affect rule to ingress",
1740 .next = NEXT(next_vc_attr),
1745 .help = "affect rule to egress",
1746 .next = NEXT(next_vc_attr),
1751 .help = "apply rule directly to endpoints found in pattern",
1752 .next = NEXT(next_vc_attr),
1755 /* Validate/create pattern. */
1758 .help = "submit a list of pattern items",
1759 .next = NEXT(next_item),
1764 .help = "match value perfectly (with full bit-mask)",
1765 .call = parse_vc_spec,
1767 [ITEM_PARAM_SPEC] = {
1769 .help = "match value according to configured bit-mask",
1770 .call = parse_vc_spec,
1772 [ITEM_PARAM_LAST] = {
1774 .help = "specify upper bound to establish a range",
1775 .call = parse_vc_spec,
1777 [ITEM_PARAM_MASK] = {
1779 .help = "specify bit-mask with relevant bits set to one",
1780 .call = parse_vc_spec,
1782 [ITEM_PARAM_PREFIX] = {
1784 .help = "generate bit-mask from a prefix length",
1785 .call = parse_vc_spec,
1789 .help = "specify next pattern item",
1790 .next = NEXT(next_item),
1794 .help = "end list of pattern items",
1795 .priv = PRIV_ITEM(END, 0),
1796 .next = NEXT(NEXT_ENTRY(ACTIONS)),
1801 .help = "no-op pattern item",
1802 .priv = PRIV_ITEM(VOID, 0),
1803 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
1808 .help = "perform actions when pattern does not match",
1809 .priv = PRIV_ITEM(INVERT, 0),
1810 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
1815 .help = "match any protocol for the current layer",
1816 .priv = PRIV_ITEM(ANY, sizeof(struct rte_flow_item_any)),
1817 .next = NEXT(item_any),
1822 .help = "number of layers covered",
1823 .next = NEXT(item_any, NEXT_ENTRY(UNSIGNED), item_param),
1824 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_any, num)),
1828 .help = "match traffic from/to the physical function",
1829 .priv = PRIV_ITEM(PF, 0),
1830 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
1835 .help = "match traffic from/to a virtual function ID",
1836 .priv = PRIV_ITEM(VF, sizeof(struct rte_flow_item_vf)),
1837 .next = NEXT(item_vf),
1843 .next = NEXT(item_vf, NEXT_ENTRY(UNSIGNED), item_param),
1844 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_vf, id)),
1848 .help = "match traffic from/to a specific physical port",
1849 .priv = PRIV_ITEM(PHY_PORT,
1850 sizeof(struct rte_flow_item_phy_port)),
1851 .next = NEXT(item_phy_port),
1854 [ITEM_PHY_PORT_INDEX] = {
1856 .help = "physical port index",
1857 .next = NEXT(item_phy_port, NEXT_ENTRY(UNSIGNED), item_param),
1858 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_phy_port, index)),
1862 .help = "match traffic from/to a given DPDK port ID",
1863 .priv = PRIV_ITEM(PORT_ID,
1864 sizeof(struct rte_flow_item_port_id)),
1865 .next = NEXT(item_port_id),
1868 [ITEM_PORT_ID_ID] = {
1870 .help = "DPDK port ID",
1871 .next = NEXT(item_port_id, NEXT_ENTRY(UNSIGNED), item_param),
1872 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port_id, id)),
1876 .help = "match traffic against value set in previously matched rule",
1877 .priv = PRIV_ITEM(MARK, sizeof(struct rte_flow_item_mark)),
1878 .next = NEXT(item_mark),
1883 .help = "Integer value to match against",
1884 .next = NEXT(item_mark, NEXT_ENTRY(UNSIGNED), item_param),
1885 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_mark, id)),
1889 .help = "match an arbitrary byte string",
1890 .priv = PRIV_ITEM(RAW, ITEM_RAW_SIZE),
1891 .next = NEXT(item_raw),
1894 [ITEM_RAW_RELATIVE] = {
1896 .help = "look for pattern after the previous item",
1897 .next = NEXT(item_raw, NEXT_ENTRY(BOOLEAN), item_param),
1898 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
1901 [ITEM_RAW_SEARCH] = {
1903 .help = "search pattern from offset (see also limit)",
1904 .next = NEXT(item_raw, NEXT_ENTRY(BOOLEAN), item_param),
1905 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
1908 [ITEM_RAW_OFFSET] = {
1910 .help = "absolute or relative offset for pattern",
1911 .next = NEXT(item_raw, NEXT_ENTRY(INTEGER), item_param),
1912 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, offset)),
1914 [ITEM_RAW_LIMIT] = {
1916 .help = "search area limit for start of pattern",
1917 .next = NEXT(item_raw, NEXT_ENTRY(UNSIGNED), item_param),
1918 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, limit)),
1920 [ITEM_RAW_PATTERN] = {
1922 .help = "byte string to look for",
1923 .next = NEXT(item_raw,
1925 NEXT_ENTRY(ITEM_PARAM_IS,
1928 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern),
1929 ARGS_ENTRY(struct rte_flow_item_raw, length),
1930 ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw),
1931 ITEM_RAW_PATTERN_SIZE)),
1935 .help = "match Ethernet header",
1936 .priv = PRIV_ITEM(ETH, sizeof(struct rte_flow_item_eth)),
1937 .next = NEXT(item_eth),
1942 .help = "destination MAC",
1943 .next = NEXT(item_eth, NEXT_ENTRY(MAC_ADDR), item_param),
1944 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, dst)),
1948 .help = "source MAC",
1949 .next = NEXT(item_eth, NEXT_ENTRY(MAC_ADDR), item_param),
1950 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, src)),
1954 .help = "EtherType",
1955 .next = NEXT(item_eth, NEXT_ENTRY(UNSIGNED), item_param),
1956 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, type)),
1960 .help = "match 802.1Q/ad VLAN tag",
1961 .priv = PRIV_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)),
1962 .next = NEXT(item_vlan),
1967 .help = "tag control information",
1968 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
1969 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, tci)),
1973 .help = "priority code point",
1974 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
1975 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
1980 .help = "drop eligible indicator",
1981 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
1982 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
1987 .help = "VLAN identifier",
1988 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
1989 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
1992 [ITEM_VLAN_INNER_TYPE] = {
1993 .name = "inner_type",
1994 .help = "inner EtherType",
1995 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
1996 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan,
2001 .help = "match IPv4 header",
2002 .priv = PRIV_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)),
2003 .next = NEXT(item_ipv4),
2008 .help = "type of service",
2009 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2010 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2011 hdr.type_of_service)),
2015 .help = "time to live",
2016 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2017 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2020 [ITEM_IPV4_PROTO] = {
2022 .help = "next protocol ID",
2023 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2024 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2025 hdr.next_proto_id)),
2029 .help = "source address",
2030 .next = NEXT(item_ipv4, NEXT_ENTRY(IPV4_ADDR), item_param),
2031 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2036 .help = "destination address",
2037 .next = NEXT(item_ipv4, NEXT_ENTRY(IPV4_ADDR), item_param),
2038 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2043 .help = "match IPv6 header",
2044 .priv = PRIV_ITEM(IPV6, sizeof(struct rte_flow_item_ipv6)),
2045 .next = NEXT(item_ipv6),
2050 .help = "traffic class",
2051 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2052 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2054 "\x0f\xf0\x00\x00")),
2056 [ITEM_IPV6_FLOW] = {
2058 .help = "flow label",
2059 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2060 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2062 "\x00\x0f\xff\xff")),
2064 [ITEM_IPV6_PROTO] = {
2066 .help = "protocol (next header)",
2067 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2068 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2073 .help = "hop limit",
2074 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2075 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2080 .help = "source address",
2081 .next = NEXT(item_ipv6, NEXT_ENTRY(IPV6_ADDR), item_param),
2082 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2087 .help = "destination address",
2088 .next = NEXT(item_ipv6, NEXT_ENTRY(IPV6_ADDR), item_param),
2089 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2094 .help = "match ICMP header",
2095 .priv = PRIV_ITEM(ICMP, sizeof(struct rte_flow_item_icmp)),
2096 .next = NEXT(item_icmp),
2099 [ITEM_ICMP_TYPE] = {
2101 .help = "ICMP packet type",
2102 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2103 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2106 [ITEM_ICMP_CODE] = {
2108 .help = "ICMP packet code",
2109 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2110 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2115 .help = "match UDP header",
2116 .priv = PRIV_ITEM(UDP, sizeof(struct rte_flow_item_udp)),
2117 .next = NEXT(item_udp),
2122 .help = "UDP source port",
2123 .next = NEXT(item_udp, NEXT_ENTRY(UNSIGNED), item_param),
2124 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2129 .help = "UDP destination port",
2130 .next = NEXT(item_udp, NEXT_ENTRY(UNSIGNED), item_param),
2131 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2136 .help = "match TCP header",
2137 .priv = PRIV_ITEM(TCP, sizeof(struct rte_flow_item_tcp)),
2138 .next = NEXT(item_tcp),
2143 .help = "TCP source port",
2144 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2145 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2150 .help = "TCP destination port",
2151 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2152 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2155 [ITEM_TCP_FLAGS] = {
2157 .help = "TCP flags",
2158 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2159 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2164 .help = "match SCTP header",
2165 .priv = PRIV_ITEM(SCTP, sizeof(struct rte_flow_item_sctp)),
2166 .next = NEXT(item_sctp),
2171 .help = "SCTP source port",
2172 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2173 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2178 .help = "SCTP destination port",
2179 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2180 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2185 .help = "validation tag",
2186 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2187 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2190 [ITEM_SCTP_CKSUM] = {
2193 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2194 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2199 .help = "match VXLAN header",
2200 .priv = PRIV_ITEM(VXLAN, sizeof(struct rte_flow_item_vxlan)),
2201 .next = NEXT(item_vxlan),
2204 [ITEM_VXLAN_VNI] = {
2206 .help = "VXLAN identifier",
2207 .next = NEXT(item_vxlan, NEXT_ENTRY(UNSIGNED), item_param),
2208 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan, vni)),
2212 .help = "match E-Tag header",
2213 .priv = PRIV_ITEM(E_TAG, sizeof(struct rte_flow_item_e_tag)),
2214 .next = NEXT(item_e_tag),
2217 [ITEM_E_TAG_GRP_ECID_B] = {
2218 .name = "grp_ecid_b",
2219 .help = "GRP and E-CID base",
2220 .next = NEXT(item_e_tag, NEXT_ENTRY(UNSIGNED), item_param),
2221 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_e_tag,
2227 .help = "match NVGRE header",
2228 .priv = PRIV_ITEM(NVGRE, sizeof(struct rte_flow_item_nvgre)),
2229 .next = NEXT(item_nvgre),
2232 [ITEM_NVGRE_TNI] = {
2234 .help = "virtual subnet ID",
2235 .next = NEXT(item_nvgre, NEXT_ENTRY(UNSIGNED), item_param),
2236 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_nvgre, tni)),
2240 .help = "match MPLS header",
2241 .priv = PRIV_ITEM(MPLS, sizeof(struct rte_flow_item_mpls)),
2242 .next = NEXT(item_mpls),
2245 [ITEM_MPLS_LABEL] = {
2247 .help = "MPLS label",
2248 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2249 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2255 .help = "MPLS Traffic Class",
2256 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2257 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2263 .help = "MPLS Bottom-of-Stack",
2264 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2265 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2271 .help = "match GRE header",
2272 .priv = PRIV_ITEM(GRE, sizeof(struct rte_flow_item_gre)),
2273 .next = NEXT(item_gre),
2276 [ITEM_GRE_PROTO] = {
2278 .help = "GRE protocol type",
2279 .next = NEXT(item_gre, NEXT_ENTRY(UNSIGNED), item_param),
2280 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2283 [ITEM_GRE_C_RSVD0_VER] = {
2284 .name = "c_rsvd0_ver",
2286 "checksum (1b), undefined (1b), key bit (1b),"
2287 " sequence number (1b), reserved 0 (9b),"
2289 .next = NEXT(item_gre, NEXT_ENTRY(UNSIGNED), item_param),
2290 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2293 [ITEM_GRE_C_BIT] = {
2295 .help = "checksum bit (C)",
2296 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2297 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2299 "\x80\x00\x00\x00")),
2301 [ITEM_GRE_S_BIT] = {
2303 .help = "sequence number bit (S)",
2304 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2305 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2307 "\x10\x00\x00\x00")),
2309 [ITEM_GRE_K_BIT] = {
2311 .help = "key bit (K)",
2312 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2313 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2315 "\x20\x00\x00\x00")),
2319 .help = "fuzzy pattern match, expect faster than default",
2320 .priv = PRIV_ITEM(FUZZY,
2321 sizeof(struct rte_flow_item_fuzzy)),
2322 .next = NEXT(item_fuzzy),
2325 [ITEM_FUZZY_THRESH] = {
2327 .help = "match accuracy threshold",
2328 .next = NEXT(item_fuzzy, NEXT_ENTRY(UNSIGNED), item_param),
2329 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_fuzzy,
2334 .help = "match GTP header",
2335 .priv = PRIV_ITEM(GTP, sizeof(struct rte_flow_item_gtp)),
2336 .next = NEXT(item_gtp),
2339 [ITEM_GTP_MSG_TYPE] = {
2341 .help = "GTP message type",
2342 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2343 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp,
2348 .help = "tunnel endpoint identifier",
2349 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2350 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp, teid)),
2354 .help = "match GTP header",
2355 .priv = PRIV_ITEM(GTPC, sizeof(struct rte_flow_item_gtp)),
2356 .next = NEXT(item_gtp),
2361 .help = "match GTP header",
2362 .priv = PRIV_ITEM(GTPU, sizeof(struct rte_flow_item_gtp)),
2363 .next = NEXT(item_gtp),
2368 .help = "match GENEVE header",
2369 .priv = PRIV_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)),
2370 .next = NEXT(item_geneve),
2373 [ITEM_GENEVE_VNI] = {
2375 .help = "virtual network identifier",
2376 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2377 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve, vni)),
2379 [ITEM_GENEVE_PROTO] = {
2381 .help = "GENEVE protocol type",
2382 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2383 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve,
2386 [ITEM_VXLAN_GPE] = {
2387 .name = "vxlan-gpe",
2388 .help = "match VXLAN-GPE header",
2389 .priv = PRIV_ITEM(VXLAN_GPE,
2390 sizeof(struct rte_flow_item_vxlan_gpe)),
2391 .next = NEXT(item_vxlan_gpe),
2394 [ITEM_VXLAN_GPE_VNI] = {
2396 .help = "VXLAN-GPE identifier",
2397 .next = NEXT(item_vxlan_gpe, NEXT_ENTRY(UNSIGNED), item_param),
2398 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
2401 [ITEM_ARP_ETH_IPV4] = {
2402 .name = "arp_eth_ipv4",
2403 .help = "match ARP header for Ethernet/IPv4",
2404 .priv = PRIV_ITEM(ARP_ETH_IPV4,
2405 sizeof(struct rte_flow_item_arp_eth_ipv4)),
2406 .next = NEXT(item_arp_eth_ipv4),
2409 [ITEM_ARP_ETH_IPV4_SHA] = {
2411 .help = "sender hardware address",
2412 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(MAC_ADDR),
2414 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2417 [ITEM_ARP_ETH_IPV4_SPA] = {
2419 .help = "sender IPv4 address",
2420 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(IPV4_ADDR),
2422 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2425 [ITEM_ARP_ETH_IPV4_THA] = {
2427 .help = "target hardware address",
2428 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(MAC_ADDR),
2430 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2433 [ITEM_ARP_ETH_IPV4_TPA] = {
2435 .help = "target IPv4 address",
2436 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(IPV4_ADDR),
2438 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2443 .help = "match presence of any IPv6 extension header",
2444 .priv = PRIV_ITEM(IPV6_EXT,
2445 sizeof(struct rte_flow_item_ipv6_ext)),
2446 .next = NEXT(item_ipv6_ext),
2449 [ITEM_IPV6_EXT_NEXT_HDR] = {
2451 .help = "next header",
2452 .next = NEXT(item_ipv6_ext, NEXT_ENTRY(UNSIGNED), item_param),
2453 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_ext,
2458 .help = "match any ICMPv6 header",
2459 .priv = PRIV_ITEM(ICMP6, sizeof(struct rte_flow_item_icmp6)),
2460 .next = NEXT(item_icmp6),
2463 [ITEM_ICMP6_TYPE] = {
2465 .help = "ICMPv6 type",
2466 .next = NEXT(item_icmp6, NEXT_ENTRY(UNSIGNED), item_param),
2467 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
2470 [ITEM_ICMP6_CODE] = {
2472 .help = "ICMPv6 code",
2473 .next = NEXT(item_icmp6, NEXT_ENTRY(UNSIGNED), item_param),
2474 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
2477 [ITEM_ICMP6_ND_NS] = {
2478 .name = "icmp6_nd_ns",
2479 .help = "match ICMPv6 neighbor discovery solicitation",
2480 .priv = PRIV_ITEM(ICMP6_ND_NS,
2481 sizeof(struct rte_flow_item_icmp6_nd_ns)),
2482 .next = NEXT(item_icmp6_nd_ns),
2485 [ITEM_ICMP6_ND_NS_TARGET_ADDR] = {
2486 .name = "target_addr",
2487 .help = "target address",
2488 .next = NEXT(item_icmp6_nd_ns, NEXT_ENTRY(IPV6_ADDR),
2490 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_ns,
2493 [ITEM_ICMP6_ND_NA] = {
2494 .name = "icmp6_nd_na",
2495 .help = "match ICMPv6 neighbor discovery advertisement",
2496 .priv = PRIV_ITEM(ICMP6_ND_NA,
2497 sizeof(struct rte_flow_item_icmp6_nd_na)),
2498 .next = NEXT(item_icmp6_nd_na),
2501 [ITEM_ICMP6_ND_NA_TARGET_ADDR] = {
2502 .name = "target_addr",
2503 .help = "target address",
2504 .next = NEXT(item_icmp6_nd_na, NEXT_ENTRY(IPV6_ADDR),
2506 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_na,
2509 [ITEM_ICMP6_ND_OPT] = {
2510 .name = "icmp6_nd_opt",
2511 .help = "match presence of any ICMPv6 neighbor discovery"
2513 .priv = PRIV_ITEM(ICMP6_ND_OPT,
2514 sizeof(struct rte_flow_item_icmp6_nd_opt)),
2515 .next = NEXT(item_icmp6_nd_opt),
2518 [ITEM_ICMP6_ND_OPT_TYPE] = {
2520 .help = "ND option type",
2521 .next = NEXT(item_icmp6_nd_opt, NEXT_ENTRY(UNSIGNED),
2523 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_opt,
2526 [ITEM_ICMP6_ND_OPT_SLA_ETH] = {
2527 .name = "icmp6_nd_opt_sla_eth",
2528 .help = "match ICMPv6 neighbor discovery source Ethernet"
2529 " link-layer address option",
2531 (ICMP6_ND_OPT_SLA_ETH,
2532 sizeof(struct rte_flow_item_icmp6_nd_opt_sla_eth)),
2533 .next = NEXT(item_icmp6_nd_opt_sla_eth),
2536 [ITEM_ICMP6_ND_OPT_SLA_ETH_SLA] = {
2538 .help = "source Ethernet LLA",
2539 .next = NEXT(item_icmp6_nd_opt_sla_eth, NEXT_ENTRY(MAC_ADDR),
2541 .args = ARGS(ARGS_ENTRY_HTON
2542 (struct rte_flow_item_icmp6_nd_opt_sla_eth, sla)),
2544 [ITEM_ICMP6_ND_OPT_TLA_ETH] = {
2545 .name = "icmp6_nd_opt_tla_eth",
2546 .help = "match ICMPv6 neighbor discovery target Ethernet"
2547 " link-layer address option",
2549 (ICMP6_ND_OPT_TLA_ETH,
2550 sizeof(struct rte_flow_item_icmp6_nd_opt_tla_eth)),
2551 .next = NEXT(item_icmp6_nd_opt_tla_eth),
2554 [ITEM_ICMP6_ND_OPT_TLA_ETH_TLA] = {
2556 .help = "target Ethernet LLA",
2557 .next = NEXT(item_icmp6_nd_opt_tla_eth, NEXT_ENTRY(MAC_ADDR),
2559 .args = ARGS(ARGS_ENTRY_HTON
2560 (struct rte_flow_item_icmp6_nd_opt_tla_eth, tla)),
2564 .help = "match metadata header",
2565 .priv = PRIV_ITEM(META, sizeof(struct rte_flow_item_meta)),
2566 .next = NEXT(item_meta),
2569 [ITEM_META_DATA] = {
2571 .help = "metadata value",
2572 .next = NEXT(item_meta, NEXT_ENTRY(UNSIGNED), item_param),
2573 .args = ARGS(ARGS_ENTRY_MASK(struct rte_flow_item_meta,
2574 data, "\xff\xff\xff\xff")),
2578 .help = "match GRE key",
2579 .priv = PRIV_ITEM(GRE_KEY, sizeof(rte_be32_t)),
2580 .next = NEXT(item_gre_key),
2583 [ITEM_GRE_KEY_VALUE] = {
2585 .help = "key value",
2586 .next = NEXT(item_gre_key, NEXT_ENTRY(UNSIGNED), item_param),
2587 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
2591 .help = "match GTP extension header with type 0x85",
2592 .priv = PRIV_ITEM(GTP_PSC,
2593 sizeof(struct rte_flow_item_gtp_psc)),
2594 .next = NEXT(item_gtp_psc),
2597 [ITEM_GTP_PSC_QFI] = {
2599 .help = "QoS flow identifier",
2600 .next = NEXT(item_gtp_psc, NEXT_ENTRY(UNSIGNED), item_param),
2601 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
2604 [ITEM_GTP_PSC_PDU_T] = {
2607 .next = NEXT(item_gtp_psc, NEXT_ENTRY(UNSIGNED), item_param),
2608 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
2613 .help = "match PPPoE session header",
2614 .priv = PRIV_ITEM(PPPOES, sizeof(struct rte_flow_item_pppoe)),
2615 .next = NEXT(item_pppoes),
2620 .help = "match PPPoE discovery header",
2621 .priv = PRIV_ITEM(PPPOED, sizeof(struct rte_flow_item_pppoe)),
2622 .next = NEXT(item_pppoed),
2625 [ITEM_PPPOE_SEID] = {
2627 .help = "session identifier",
2628 .next = NEXT(item_pppoes, NEXT_ENTRY(UNSIGNED), item_param),
2629 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pppoe,
2632 [ITEM_PPPOE_PROTO_ID] = {
2634 .help = "match PPPoE session protocol identifier",
2635 .priv = PRIV_ITEM(PPPOE_PROTO_ID,
2636 sizeof(struct rte_flow_item_pppoe_proto_id)),
2637 .next = NEXT(item_pppoe_proto_id),
2642 .help = "matches higig2 header",
2643 .priv = PRIV_ITEM(HIGIG2,
2644 sizeof(struct rte_flow_item_higig2_hdr)),
2645 .next = NEXT(item_higig2),
2648 [ITEM_HIGIG2_CLASSIFICATION] = {
2649 .name = "classification",
2650 .help = "matches classification of higig2 header",
2651 .next = NEXT(item_higig2, NEXT_ENTRY(UNSIGNED), item_param),
2652 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
2653 hdr.ppt1.classification)),
2655 [ITEM_HIGIG2_VID] = {
2657 .help = "matches vid of higig2 header",
2658 .next = NEXT(item_higig2, NEXT_ENTRY(UNSIGNED), item_param),
2659 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
2664 .help = "match tag value",
2665 .priv = PRIV_ITEM(TAG, sizeof(struct rte_flow_item_tag)),
2666 .next = NEXT(item_tag),
2671 .help = "tag value to match",
2672 .next = NEXT(item_tag, NEXT_ENTRY(UNSIGNED), item_param),
2673 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, data)),
2675 [ITEM_TAG_INDEX] = {
2677 .help = "index of tag array to match",
2678 .next = NEXT(item_tag, NEXT_ENTRY(UNSIGNED),
2679 NEXT_ENTRY(ITEM_PARAM_IS)),
2680 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, index)),
2682 [ITEM_L2TPV3OIP] = {
2683 .name = "l2tpv3oip",
2684 .help = "match L2TPv3 over IP header",
2685 .priv = PRIV_ITEM(L2TPV3OIP,
2686 sizeof(struct rte_flow_item_l2tpv3oip)),
2687 .next = NEXT(item_l2tpv3oip),
2690 [ITEM_L2TPV3OIP_SESSION_ID] = {
2691 .name = "session_id",
2692 .help = "session identifier",
2693 .next = NEXT(item_l2tpv3oip, NEXT_ENTRY(UNSIGNED), item_param),
2694 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv3oip,
2699 .help = "match ESP header",
2700 .priv = PRIV_ITEM(ESP, sizeof(struct rte_flow_item_esp)),
2701 .next = NEXT(item_esp),
2706 .help = "security policy index",
2707 .next = NEXT(item_esp, NEXT_ENTRY(UNSIGNED), item_param),
2708 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_esp,
2713 .help = "match AH header",
2714 .priv = PRIV_ITEM(AH, sizeof(struct rte_flow_item_ah)),
2715 .next = NEXT(item_ah),
2720 .help = "security parameters index",
2721 .next = NEXT(item_ah, NEXT_ENTRY(UNSIGNED), item_param),
2722 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ah, spi)),
2724 /* Validate/create actions. */
2727 .help = "submit a list of associated actions",
2728 .next = NEXT(next_action),
2733 .help = "specify next action",
2734 .next = NEXT(next_action),
2738 .help = "end list of actions",
2739 .priv = PRIV_ACTION(END, 0),
2744 .help = "no-op action",
2745 .priv = PRIV_ACTION(VOID, 0),
2746 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
2749 [ACTION_PASSTHRU] = {
2751 .help = "let subsequent rule process matched packets",
2752 .priv = PRIV_ACTION(PASSTHRU, 0),
2753 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
2758 .help = "redirect traffic to a given group",
2759 .priv = PRIV_ACTION(JUMP, sizeof(struct rte_flow_action_jump)),
2760 .next = NEXT(action_jump),
2763 [ACTION_JUMP_GROUP] = {
2765 .help = "group to redirect traffic to",
2766 .next = NEXT(action_jump, NEXT_ENTRY(UNSIGNED)),
2767 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump, group)),
2768 .call = parse_vc_conf,
2772 .help = "attach 32 bit value to packets",
2773 .priv = PRIV_ACTION(MARK, sizeof(struct rte_flow_action_mark)),
2774 .next = NEXT(action_mark),
2777 [ACTION_MARK_ID] = {
2779 .help = "32 bit value to return with packets",
2780 .next = NEXT(action_mark, NEXT_ENTRY(UNSIGNED)),
2781 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_mark, id)),
2782 .call = parse_vc_conf,
2786 .help = "flag packets",
2787 .priv = PRIV_ACTION(FLAG, 0),
2788 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
2793 .help = "assign packets to a given queue index",
2794 .priv = PRIV_ACTION(QUEUE,
2795 sizeof(struct rte_flow_action_queue)),
2796 .next = NEXT(action_queue),
2799 [ACTION_QUEUE_INDEX] = {
2801 .help = "queue index to use",
2802 .next = NEXT(action_queue, NEXT_ENTRY(UNSIGNED)),
2803 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_queue, index)),
2804 .call = parse_vc_conf,
2808 .help = "drop packets (note: passthru has priority)",
2809 .priv = PRIV_ACTION(DROP, 0),
2810 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
2815 .help = "enable counters for this rule",
2816 .priv = PRIV_ACTION(COUNT,
2817 sizeof(struct rte_flow_action_count)),
2818 .next = NEXT(action_count),
2821 [ACTION_COUNT_ID] = {
2822 .name = "identifier",
2823 .help = "counter identifier to use",
2824 .next = NEXT(action_count, NEXT_ENTRY(UNSIGNED)),
2825 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_count, id)),
2826 .call = parse_vc_conf,
2828 [ACTION_COUNT_SHARED] = {
2830 .help = "shared counter",
2831 .next = NEXT(action_count, NEXT_ENTRY(BOOLEAN)),
2832 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_count,
2834 .call = parse_vc_conf,
2838 .help = "spread packets among several queues",
2839 .priv = PRIV_ACTION(RSS, sizeof(struct action_rss_data)),
2840 .next = NEXT(action_rss),
2841 .call = parse_vc_action_rss,
2843 [ACTION_RSS_FUNC] = {
2845 .help = "RSS hash function to apply",
2846 .next = NEXT(action_rss,
2847 NEXT_ENTRY(ACTION_RSS_FUNC_DEFAULT,
2848 ACTION_RSS_FUNC_TOEPLITZ,
2849 ACTION_RSS_FUNC_SIMPLE_XOR,
2850 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ)),
2852 [ACTION_RSS_FUNC_DEFAULT] = {
2854 .help = "default hash function",
2855 .call = parse_vc_action_rss_func,
2857 [ACTION_RSS_FUNC_TOEPLITZ] = {
2859 .help = "Toeplitz hash function",
2860 .call = parse_vc_action_rss_func,
2862 [ACTION_RSS_FUNC_SIMPLE_XOR] = {
2863 .name = "simple_xor",
2864 .help = "simple XOR hash function",
2865 .call = parse_vc_action_rss_func,
2867 [ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ] = {
2868 .name = "symmetric_toeplitz",
2869 .help = "Symmetric Toeplitz hash function",
2870 .call = parse_vc_action_rss_func,
2872 [ACTION_RSS_LEVEL] = {
2874 .help = "encapsulation level for \"types\"",
2875 .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
2876 .args = ARGS(ARGS_ENTRY_ARB
2877 (offsetof(struct action_rss_data, conf) +
2878 offsetof(struct rte_flow_action_rss, level),
2879 sizeof(((struct rte_flow_action_rss *)0)->
2882 [ACTION_RSS_TYPES] = {
2884 .help = "specific RSS hash types",
2885 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)),
2887 [ACTION_RSS_TYPE] = {
2889 .help = "RSS hash type",
2890 .call = parse_vc_action_rss_type,
2891 .comp = comp_vc_action_rss_type,
2893 [ACTION_RSS_KEY] = {
2895 .help = "RSS hash key",
2896 .next = NEXT(action_rss, NEXT_ENTRY(HEX)),
2897 .args = ARGS(ARGS_ENTRY_ARB(0, 0),
2899 (offsetof(struct action_rss_data, conf) +
2900 offsetof(struct rte_flow_action_rss, key_len),
2901 sizeof(((struct rte_flow_action_rss *)0)->
2903 ARGS_ENTRY(struct action_rss_data, key)),
2905 [ACTION_RSS_KEY_LEN] = {
2907 .help = "RSS hash key length in bytes",
2908 .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
2909 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
2910 (offsetof(struct action_rss_data, conf) +
2911 offsetof(struct rte_flow_action_rss, key_len),
2912 sizeof(((struct rte_flow_action_rss *)0)->
2915 RSS_HASH_KEY_LENGTH)),
2917 [ACTION_RSS_QUEUES] = {
2919 .help = "queue indices to use",
2920 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_QUEUE)),
2921 .call = parse_vc_conf,
2923 [ACTION_RSS_QUEUE] = {
2925 .help = "queue index",
2926 .call = parse_vc_action_rss_queue,
2927 .comp = comp_vc_action_rss_queue,
2931 .help = "direct traffic to physical function",
2932 .priv = PRIV_ACTION(PF, 0),
2933 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
2938 .help = "direct traffic to a virtual function ID",
2939 .priv = PRIV_ACTION(VF, sizeof(struct rte_flow_action_vf)),
2940 .next = NEXT(action_vf),
2943 [ACTION_VF_ORIGINAL] = {
2945 .help = "use original VF ID if possible",
2946 .next = NEXT(action_vf, NEXT_ENTRY(BOOLEAN)),
2947 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_vf,
2949 .call = parse_vc_conf,
2954 .next = NEXT(action_vf, NEXT_ENTRY(UNSIGNED)),
2955 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)),
2956 .call = parse_vc_conf,
2958 [ACTION_PHY_PORT] = {
2960 .help = "direct packets to physical port index",
2961 .priv = PRIV_ACTION(PHY_PORT,
2962 sizeof(struct rte_flow_action_phy_port)),
2963 .next = NEXT(action_phy_port),
2966 [ACTION_PHY_PORT_ORIGINAL] = {
2968 .help = "use original port index if possible",
2969 .next = NEXT(action_phy_port, NEXT_ENTRY(BOOLEAN)),
2970 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_phy_port,
2972 .call = parse_vc_conf,
2974 [ACTION_PHY_PORT_INDEX] = {
2976 .help = "physical port index",
2977 .next = NEXT(action_phy_port, NEXT_ENTRY(UNSIGNED)),
2978 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_phy_port,
2980 .call = parse_vc_conf,
2982 [ACTION_PORT_ID] = {
2984 .help = "direct matching traffic to a given DPDK port ID",
2985 .priv = PRIV_ACTION(PORT_ID,
2986 sizeof(struct rte_flow_action_port_id)),
2987 .next = NEXT(action_port_id),
2990 [ACTION_PORT_ID_ORIGINAL] = {
2992 .help = "use original DPDK port ID if possible",
2993 .next = NEXT(action_port_id, NEXT_ENTRY(BOOLEAN)),
2994 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_port_id,
2996 .call = parse_vc_conf,
2998 [ACTION_PORT_ID_ID] = {
3000 .help = "DPDK port ID",
3001 .next = NEXT(action_port_id, NEXT_ENTRY(UNSIGNED)),
3002 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_port_id, id)),
3003 .call = parse_vc_conf,
3007 .help = "meter the directed packets at given id",
3008 .priv = PRIV_ACTION(METER,
3009 sizeof(struct rte_flow_action_meter)),
3010 .next = NEXT(action_meter),
3013 [ACTION_METER_ID] = {
3015 .help = "meter id to use",
3016 .next = NEXT(action_meter, NEXT_ENTRY(UNSIGNED)),
3017 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter, mtr_id)),
3018 .call = parse_vc_conf,
3020 [ACTION_OF_SET_MPLS_TTL] = {
3021 .name = "of_set_mpls_ttl",
3022 .help = "OpenFlow's OFPAT_SET_MPLS_TTL",
3025 sizeof(struct rte_flow_action_of_set_mpls_ttl)),
3026 .next = NEXT(action_of_set_mpls_ttl),
3029 [ACTION_OF_SET_MPLS_TTL_MPLS_TTL] = {
3032 .next = NEXT(action_of_set_mpls_ttl, NEXT_ENTRY(UNSIGNED)),
3033 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_mpls_ttl,
3035 .call = parse_vc_conf,
3037 [ACTION_OF_DEC_MPLS_TTL] = {
3038 .name = "of_dec_mpls_ttl",
3039 .help = "OpenFlow's OFPAT_DEC_MPLS_TTL",
3040 .priv = PRIV_ACTION(OF_DEC_MPLS_TTL, 0),
3041 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3044 [ACTION_OF_SET_NW_TTL] = {
3045 .name = "of_set_nw_ttl",
3046 .help = "OpenFlow's OFPAT_SET_NW_TTL",
3049 sizeof(struct rte_flow_action_of_set_nw_ttl)),
3050 .next = NEXT(action_of_set_nw_ttl),
3053 [ACTION_OF_SET_NW_TTL_NW_TTL] = {
3056 .next = NEXT(action_of_set_nw_ttl, NEXT_ENTRY(UNSIGNED)),
3057 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_nw_ttl,
3059 .call = parse_vc_conf,
3061 [ACTION_OF_DEC_NW_TTL] = {
3062 .name = "of_dec_nw_ttl",
3063 .help = "OpenFlow's OFPAT_DEC_NW_TTL",
3064 .priv = PRIV_ACTION(OF_DEC_NW_TTL, 0),
3065 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3068 [ACTION_OF_COPY_TTL_OUT] = {
3069 .name = "of_copy_ttl_out",
3070 .help = "OpenFlow's OFPAT_COPY_TTL_OUT",
3071 .priv = PRIV_ACTION(OF_COPY_TTL_OUT, 0),
3072 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3075 [ACTION_OF_COPY_TTL_IN] = {
3076 .name = "of_copy_ttl_in",
3077 .help = "OpenFlow's OFPAT_COPY_TTL_IN",
3078 .priv = PRIV_ACTION(OF_COPY_TTL_IN, 0),
3079 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3082 [ACTION_OF_POP_VLAN] = {
3083 .name = "of_pop_vlan",
3084 .help = "OpenFlow's OFPAT_POP_VLAN",
3085 .priv = PRIV_ACTION(OF_POP_VLAN, 0),
3086 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3089 [ACTION_OF_PUSH_VLAN] = {
3090 .name = "of_push_vlan",
3091 .help = "OpenFlow's OFPAT_PUSH_VLAN",
3094 sizeof(struct rte_flow_action_of_push_vlan)),
3095 .next = NEXT(action_of_push_vlan),
3098 [ACTION_OF_PUSH_VLAN_ETHERTYPE] = {
3099 .name = "ethertype",
3100 .help = "EtherType",
3101 .next = NEXT(action_of_push_vlan, NEXT_ENTRY(UNSIGNED)),
3102 .args = ARGS(ARGS_ENTRY_HTON
3103 (struct rte_flow_action_of_push_vlan,
3105 .call = parse_vc_conf,
3107 [ACTION_OF_SET_VLAN_VID] = {
3108 .name = "of_set_vlan_vid",
3109 .help = "OpenFlow's OFPAT_SET_VLAN_VID",
3112 sizeof(struct rte_flow_action_of_set_vlan_vid)),
3113 .next = NEXT(action_of_set_vlan_vid),
3116 [ACTION_OF_SET_VLAN_VID_VLAN_VID] = {
3119 .next = NEXT(action_of_set_vlan_vid, NEXT_ENTRY(UNSIGNED)),
3120 .args = ARGS(ARGS_ENTRY_HTON
3121 (struct rte_flow_action_of_set_vlan_vid,
3123 .call = parse_vc_conf,
3125 [ACTION_OF_SET_VLAN_PCP] = {
3126 .name = "of_set_vlan_pcp",
3127 .help = "OpenFlow's OFPAT_SET_VLAN_PCP",
3130 sizeof(struct rte_flow_action_of_set_vlan_pcp)),
3131 .next = NEXT(action_of_set_vlan_pcp),
3134 [ACTION_OF_SET_VLAN_PCP_VLAN_PCP] = {
3136 .help = "VLAN priority",
3137 .next = NEXT(action_of_set_vlan_pcp, NEXT_ENTRY(UNSIGNED)),
3138 .args = ARGS(ARGS_ENTRY_HTON
3139 (struct rte_flow_action_of_set_vlan_pcp,
3141 .call = parse_vc_conf,
3143 [ACTION_OF_POP_MPLS] = {
3144 .name = "of_pop_mpls",
3145 .help = "OpenFlow's OFPAT_POP_MPLS",
3146 .priv = PRIV_ACTION(OF_POP_MPLS,
3147 sizeof(struct rte_flow_action_of_pop_mpls)),
3148 .next = NEXT(action_of_pop_mpls),
3151 [ACTION_OF_POP_MPLS_ETHERTYPE] = {
3152 .name = "ethertype",
3153 .help = "EtherType",
3154 .next = NEXT(action_of_pop_mpls, NEXT_ENTRY(UNSIGNED)),
3155 .args = ARGS(ARGS_ENTRY_HTON
3156 (struct rte_flow_action_of_pop_mpls,
3158 .call = parse_vc_conf,
3160 [ACTION_OF_PUSH_MPLS] = {
3161 .name = "of_push_mpls",
3162 .help = "OpenFlow's OFPAT_PUSH_MPLS",
3165 sizeof(struct rte_flow_action_of_push_mpls)),
3166 .next = NEXT(action_of_push_mpls),
3169 [ACTION_OF_PUSH_MPLS_ETHERTYPE] = {
3170 .name = "ethertype",
3171 .help = "EtherType",
3172 .next = NEXT(action_of_push_mpls, NEXT_ENTRY(UNSIGNED)),
3173 .args = ARGS(ARGS_ENTRY_HTON
3174 (struct rte_flow_action_of_push_mpls,
3176 .call = parse_vc_conf,
3178 [ACTION_VXLAN_ENCAP] = {
3179 .name = "vxlan_encap",
3180 .help = "VXLAN encapsulation, uses configuration set by \"set"
3182 .priv = PRIV_ACTION(VXLAN_ENCAP,
3183 sizeof(struct action_vxlan_encap_data)),
3184 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3185 .call = parse_vc_action_vxlan_encap,
3187 [ACTION_VXLAN_DECAP] = {
3188 .name = "vxlan_decap",
3189 .help = "Performs a decapsulation action by stripping all"
3190 " headers of the VXLAN tunnel network overlay from the"
3192 .priv = PRIV_ACTION(VXLAN_DECAP, 0),
3193 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3196 [ACTION_NVGRE_ENCAP] = {
3197 .name = "nvgre_encap",
3198 .help = "NVGRE encapsulation, uses configuration set by \"set"
3200 .priv = PRIV_ACTION(NVGRE_ENCAP,
3201 sizeof(struct action_nvgre_encap_data)),
3202 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3203 .call = parse_vc_action_nvgre_encap,
3205 [ACTION_NVGRE_DECAP] = {
3206 .name = "nvgre_decap",
3207 .help = "Performs a decapsulation action by stripping all"
3208 " headers of the NVGRE tunnel network overlay from the"
3210 .priv = PRIV_ACTION(NVGRE_DECAP, 0),
3211 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3214 [ACTION_L2_ENCAP] = {
3216 .help = "l2 encap, uses configuration set by"
3217 " \"set l2_encap\"",
3218 .priv = PRIV_ACTION(RAW_ENCAP,
3219 sizeof(struct action_raw_encap_data)),
3220 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3221 .call = parse_vc_action_l2_encap,
3223 [ACTION_L2_DECAP] = {
3225 .help = "l2 decap, uses configuration set by"
3226 " \"set l2_decap\"",
3227 .priv = PRIV_ACTION(RAW_DECAP,
3228 sizeof(struct action_raw_decap_data)),
3229 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3230 .call = parse_vc_action_l2_decap,
3232 [ACTION_MPLSOGRE_ENCAP] = {
3233 .name = "mplsogre_encap",
3234 .help = "mplsogre encapsulation, uses configuration set by"
3235 " \"set mplsogre_encap\"",
3236 .priv = PRIV_ACTION(RAW_ENCAP,
3237 sizeof(struct action_raw_encap_data)),
3238 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3239 .call = parse_vc_action_mplsogre_encap,
3241 [ACTION_MPLSOGRE_DECAP] = {
3242 .name = "mplsogre_decap",
3243 .help = "mplsogre decapsulation, uses configuration set by"
3244 " \"set mplsogre_decap\"",
3245 .priv = PRIV_ACTION(RAW_DECAP,
3246 sizeof(struct action_raw_decap_data)),
3247 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3248 .call = parse_vc_action_mplsogre_decap,
3250 [ACTION_MPLSOUDP_ENCAP] = {
3251 .name = "mplsoudp_encap",
3252 .help = "mplsoudp encapsulation, uses configuration set by"
3253 " \"set mplsoudp_encap\"",
3254 .priv = PRIV_ACTION(RAW_ENCAP,
3255 sizeof(struct action_raw_encap_data)),
3256 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3257 .call = parse_vc_action_mplsoudp_encap,
3259 [ACTION_MPLSOUDP_DECAP] = {
3260 .name = "mplsoudp_decap",
3261 .help = "mplsoudp decapsulation, uses configuration set by"
3262 " \"set mplsoudp_decap\"",
3263 .priv = PRIV_ACTION(RAW_DECAP,
3264 sizeof(struct action_raw_decap_data)),
3265 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3266 .call = parse_vc_action_mplsoudp_decap,
3268 [ACTION_SET_IPV4_SRC] = {
3269 .name = "set_ipv4_src",
3270 .help = "Set a new IPv4 source address in the outermost"
3272 .priv = PRIV_ACTION(SET_IPV4_SRC,
3273 sizeof(struct rte_flow_action_set_ipv4)),
3274 .next = NEXT(action_set_ipv4_src),
3277 [ACTION_SET_IPV4_SRC_IPV4_SRC] = {
3278 .name = "ipv4_addr",
3279 .help = "new IPv4 source address to set",
3280 .next = NEXT(action_set_ipv4_src, NEXT_ENTRY(IPV4_ADDR)),
3281 .args = ARGS(ARGS_ENTRY_HTON
3282 (struct rte_flow_action_set_ipv4, ipv4_addr)),
3283 .call = parse_vc_conf,
3285 [ACTION_SET_IPV4_DST] = {
3286 .name = "set_ipv4_dst",
3287 .help = "Set a new IPv4 destination address in the outermost"
3289 .priv = PRIV_ACTION(SET_IPV4_DST,
3290 sizeof(struct rte_flow_action_set_ipv4)),
3291 .next = NEXT(action_set_ipv4_dst),
3294 [ACTION_SET_IPV4_DST_IPV4_DST] = {
3295 .name = "ipv4_addr",
3296 .help = "new IPv4 destination address to set",
3297 .next = NEXT(action_set_ipv4_dst, NEXT_ENTRY(IPV4_ADDR)),
3298 .args = ARGS(ARGS_ENTRY_HTON
3299 (struct rte_flow_action_set_ipv4, ipv4_addr)),
3300 .call = parse_vc_conf,
3302 [ACTION_SET_IPV6_SRC] = {
3303 .name = "set_ipv6_src",
3304 .help = "Set a new IPv6 source address in the outermost"
3306 .priv = PRIV_ACTION(SET_IPV6_SRC,
3307 sizeof(struct rte_flow_action_set_ipv6)),
3308 .next = NEXT(action_set_ipv6_src),
3311 [ACTION_SET_IPV6_SRC_IPV6_SRC] = {
3312 .name = "ipv6_addr",
3313 .help = "new IPv6 source address to set",
3314 .next = NEXT(action_set_ipv6_src, NEXT_ENTRY(IPV6_ADDR)),
3315 .args = ARGS(ARGS_ENTRY_HTON
3316 (struct rte_flow_action_set_ipv6, ipv6_addr)),
3317 .call = parse_vc_conf,
3319 [ACTION_SET_IPV6_DST] = {
3320 .name = "set_ipv6_dst",
3321 .help = "Set a new IPv6 destination address in the outermost"
3323 .priv = PRIV_ACTION(SET_IPV6_DST,
3324 sizeof(struct rte_flow_action_set_ipv6)),
3325 .next = NEXT(action_set_ipv6_dst),
3328 [ACTION_SET_IPV6_DST_IPV6_DST] = {
3329 .name = "ipv6_addr",
3330 .help = "new IPv6 destination address to set",
3331 .next = NEXT(action_set_ipv6_dst, NEXT_ENTRY(IPV6_ADDR)),
3332 .args = ARGS(ARGS_ENTRY_HTON
3333 (struct rte_flow_action_set_ipv6, ipv6_addr)),
3334 .call = parse_vc_conf,
3336 [ACTION_SET_TP_SRC] = {
3337 .name = "set_tp_src",
3338 .help = "set a new source port number in the outermost"
3340 .priv = PRIV_ACTION(SET_TP_SRC,
3341 sizeof(struct rte_flow_action_set_tp)),
3342 .next = NEXT(action_set_tp_src),
3345 [ACTION_SET_TP_SRC_TP_SRC] = {
3347 .help = "new source port number to set",
3348 .next = NEXT(action_set_tp_src, NEXT_ENTRY(UNSIGNED)),
3349 .args = ARGS(ARGS_ENTRY_HTON
3350 (struct rte_flow_action_set_tp, port)),
3351 .call = parse_vc_conf,
3353 [ACTION_SET_TP_DST] = {
3354 .name = "set_tp_dst",
3355 .help = "set a new destination port number in the outermost"
3357 .priv = PRIV_ACTION(SET_TP_DST,
3358 sizeof(struct rte_flow_action_set_tp)),
3359 .next = NEXT(action_set_tp_dst),
3362 [ACTION_SET_TP_DST_TP_DST] = {
3364 .help = "new destination port number to set",
3365 .next = NEXT(action_set_tp_dst, NEXT_ENTRY(UNSIGNED)),
3366 .args = ARGS(ARGS_ENTRY_HTON
3367 (struct rte_flow_action_set_tp, port)),
3368 .call = parse_vc_conf,
3370 [ACTION_MAC_SWAP] = {
3372 .help = "Swap the source and destination MAC addresses"
3373 " in the outermost Ethernet header",
3374 .priv = PRIV_ACTION(MAC_SWAP, 0),
3375 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3378 [ACTION_DEC_TTL] = {
3380 .help = "decrease network TTL if available",
3381 .priv = PRIV_ACTION(DEC_TTL, 0),
3382 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3385 [ACTION_SET_TTL] = {
3387 .help = "set ttl value",
3388 .priv = PRIV_ACTION(SET_TTL,
3389 sizeof(struct rte_flow_action_set_ttl)),
3390 .next = NEXT(action_set_ttl),
3393 [ACTION_SET_TTL_TTL] = {
3394 .name = "ttl_value",
3395 .help = "new ttl value to set",
3396 .next = NEXT(action_set_ttl, NEXT_ENTRY(UNSIGNED)),
3397 .args = ARGS(ARGS_ENTRY_HTON
3398 (struct rte_flow_action_set_ttl, ttl_value)),
3399 .call = parse_vc_conf,
3401 [ACTION_SET_MAC_SRC] = {
3402 .name = "set_mac_src",
3403 .help = "set source mac address",
3404 .priv = PRIV_ACTION(SET_MAC_SRC,
3405 sizeof(struct rte_flow_action_set_mac)),
3406 .next = NEXT(action_set_mac_src),
3409 [ACTION_SET_MAC_SRC_MAC_SRC] = {
3411 .help = "new source mac address",
3412 .next = NEXT(action_set_mac_src, NEXT_ENTRY(MAC_ADDR)),
3413 .args = ARGS(ARGS_ENTRY_HTON
3414 (struct rte_flow_action_set_mac, mac_addr)),
3415 .call = parse_vc_conf,
3417 [ACTION_SET_MAC_DST] = {
3418 .name = "set_mac_dst",
3419 .help = "set destination mac address",
3420 .priv = PRIV_ACTION(SET_MAC_DST,
3421 sizeof(struct rte_flow_action_set_mac)),
3422 .next = NEXT(action_set_mac_dst),
3425 [ACTION_SET_MAC_DST_MAC_DST] = {
3427 .help = "new destination mac address to set",
3428 .next = NEXT(action_set_mac_dst, NEXT_ENTRY(MAC_ADDR)),
3429 .args = ARGS(ARGS_ENTRY_HTON
3430 (struct rte_flow_action_set_mac, mac_addr)),
3431 .call = parse_vc_conf,
3433 [ACTION_INC_TCP_SEQ] = {
3434 .name = "inc_tcp_seq",
3435 .help = "increase TCP sequence number",
3436 .priv = PRIV_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
3437 .next = NEXT(action_inc_tcp_seq),
3440 [ACTION_INC_TCP_SEQ_VALUE] = {
3442 .help = "the value to increase TCP sequence number by",
3443 .next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(UNSIGNED)),
3444 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3445 .call = parse_vc_conf,
3447 [ACTION_DEC_TCP_SEQ] = {
3448 .name = "dec_tcp_seq",
3449 .help = "decrease TCP sequence number",
3450 .priv = PRIV_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
3451 .next = NEXT(action_dec_tcp_seq),
3454 [ACTION_DEC_TCP_SEQ_VALUE] = {
3456 .help = "the value to decrease TCP sequence number by",
3457 .next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(UNSIGNED)),
3458 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3459 .call = parse_vc_conf,
3461 [ACTION_INC_TCP_ACK] = {
3462 .name = "inc_tcp_ack",
3463 .help = "increase TCP acknowledgment number",
3464 .priv = PRIV_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
3465 .next = NEXT(action_inc_tcp_ack),
3468 [ACTION_INC_TCP_ACK_VALUE] = {
3470 .help = "the value to increase TCP acknowledgment number by",
3471 .next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(UNSIGNED)),
3472 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3473 .call = parse_vc_conf,
3475 [ACTION_DEC_TCP_ACK] = {
3476 .name = "dec_tcp_ack",
3477 .help = "decrease TCP acknowledgment number",
3478 .priv = PRIV_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
3479 .next = NEXT(action_dec_tcp_ack),
3482 [ACTION_DEC_TCP_ACK_VALUE] = {
3484 .help = "the value to decrease TCP acknowledgment number by",
3485 .next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(UNSIGNED)),
3486 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3487 .call = parse_vc_conf,
3489 [ACTION_RAW_ENCAP] = {
3490 .name = "raw_encap",
3491 .help = "encapsulation data, defined by set raw_encap",
3492 .priv = PRIV_ACTION(RAW_ENCAP,
3493 sizeof(struct action_raw_encap_data)),
3494 .next = NEXT(action_raw_encap),
3495 .call = parse_vc_action_raw_encap,
3497 [ACTION_RAW_ENCAP_INDEX] = {
3499 .help = "the index of raw_encap_confs",
3500 .next = NEXT(NEXT_ENTRY(ACTION_RAW_ENCAP_INDEX_VALUE)),
3502 [ACTION_RAW_ENCAP_INDEX_VALUE] = {
3505 .help = "unsigned integer value",
3506 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3507 .call = parse_vc_action_raw_encap_index,
3508 .comp = comp_set_raw_index,
3510 [ACTION_RAW_DECAP] = {
3511 .name = "raw_decap",
3512 .help = "decapsulation data, defined by set raw_encap",
3513 .priv = PRIV_ACTION(RAW_DECAP,
3514 sizeof(struct action_raw_decap_data)),
3515 .next = NEXT(action_raw_decap),
3516 .call = parse_vc_action_raw_decap,
3518 [ACTION_RAW_DECAP_INDEX] = {
3520 .help = "the index of raw_encap_confs",
3521 .next = NEXT(NEXT_ENTRY(ACTION_RAW_DECAP_INDEX_VALUE)),
3523 [ACTION_RAW_DECAP_INDEX_VALUE] = {
3526 .help = "unsigned integer value",
3527 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3528 .call = parse_vc_action_raw_decap_index,
3529 .comp = comp_set_raw_index,
3531 /* Top level command. */
3534 .help = "set raw encap/decap data",
3535 .type = "set raw_encap|raw_decap <index> <pattern>",
3536 .next = NEXT(NEXT_ENTRY
3539 .call = parse_set_init,
3541 /* Sub-level commands. */
3543 .name = "raw_encap",
3544 .help = "set raw encap data",
3545 .next = NEXT(next_set_raw),
3546 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
3547 (offsetof(struct buffer, port),
3548 sizeof(((struct buffer *)0)->port),
3549 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
3550 .call = parse_set_raw_encap_decap,
3553 .name = "raw_decap",
3554 .help = "set raw decap data",
3555 .next = NEXT(next_set_raw),
3556 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
3557 (offsetof(struct buffer, port),
3558 sizeof(((struct buffer *)0)->port),
3559 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
3560 .call = parse_set_raw_encap_decap,
3565 .help = "index of raw_encap/raw_decap data",
3566 .next = NEXT(next_item),
3569 [ACTION_SET_TAG] = {
3572 .priv = PRIV_ACTION(SET_TAG,
3573 sizeof(struct rte_flow_action_set_tag)),
3574 .next = NEXT(action_set_tag),
3577 [ACTION_SET_TAG_INDEX] = {
3579 .help = "index of tag array",
3580 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
3581 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_set_tag, index)),
3582 .call = parse_vc_conf,
3584 [ACTION_SET_TAG_DATA] = {
3586 .help = "tag value",
3587 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
3588 .args = ARGS(ARGS_ENTRY
3589 (struct rte_flow_action_set_tag, data)),
3590 .call = parse_vc_conf,
3592 [ACTION_SET_TAG_MASK] = {
3594 .help = "mask for tag value",
3595 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
3596 .args = ARGS(ARGS_ENTRY
3597 (struct rte_flow_action_set_tag, mask)),
3598 .call = parse_vc_conf,
3600 [ACTION_SET_META] = {
3602 .help = "set metadata",
3603 .priv = PRIV_ACTION(SET_META,
3604 sizeof(struct rte_flow_action_set_meta)),
3605 .next = NEXT(action_set_meta),
3606 .call = parse_vc_action_set_meta,
3608 [ACTION_SET_META_DATA] = {
3610 .help = "metadata value",
3611 .next = NEXT(action_set_meta, NEXT_ENTRY(UNSIGNED)),
3612 .args = ARGS(ARGS_ENTRY
3613 (struct rte_flow_action_set_meta, data)),
3614 .call = parse_vc_conf,
3616 [ACTION_SET_META_MASK] = {
3618 .help = "mask for metadata value",
3619 .next = NEXT(action_set_meta, NEXT_ENTRY(UNSIGNED)),
3620 .args = ARGS(ARGS_ENTRY
3621 (struct rte_flow_action_set_meta, mask)),
3622 .call = parse_vc_conf,
3624 [ACTION_SET_IPV4_DSCP] = {
3625 .name = "set_ipv4_dscp",
3626 .help = "set DSCP value",
3627 .priv = PRIV_ACTION(SET_IPV4_DSCP,
3628 sizeof(struct rte_flow_action_set_dscp)),
3629 .next = NEXT(action_set_ipv4_dscp),
3632 [ACTION_SET_IPV4_DSCP_VALUE] = {
3633 .name = "dscp_value",
3634 .help = "new IPv4 DSCP value to set",
3635 .next = NEXT(action_set_ipv4_dscp, NEXT_ENTRY(UNSIGNED)),
3636 .args = ARGS(ARGS_ENTRY
3637 (struct rte_flow_action_set_dscp, dscp)),
3638 .call = parse_vc_conf,
3640 [ACTION_SET_IPV6_DSCP] = {
3641 .name = "set_ipv6_dscp",
3642 .help = "set DSCP value",
3643 .priv = PRIV_ACTION(SET_IPV6_DSCP,
3644 sizeof(struct rte_flow_action_set_dscp)),
3645 .next = NEXT(action_set_ipv6_dscp),
3648 [ACTION_SET_IPV6_DSCP_VALUE] = {
3649 .name = "dscp_value",
3650 .help = "new IPv6 DSCP value to set",
3651 .next = NEXT(action_set_ipv6_dscp, NEXT_ENTRY(UNSIGNED)),
3652 .args = ARGS(ARGS_ENTRY
3653 (struct rte_flow_action_set_dscp, dscp)),
3654 .call = parse_vc_conf,
3658 /** Remove and return last entry from argument stack. */
3659 static const struct arg *
3660 pop_args(struct context *ctx)
3662 return ctx->args_num ? ctx->args[--ctx->args_num] : NULL;
3665 /** Add entry on top of the argument stack. */
3667 push_args(struct context *ctx, const struct arg *arg)
3669 if (ctx->args_num == CTX_STACK_SIZE)
3671 ctx->args[ctx->args_num++] = arg;
3675 /** Spread value into buffer according to bit-mask. */
3677 arg_entry_bf_fill(void *dst, uintmax_t val, const struct arg *arg)
3679 uint32_t i = arg->size;
3687 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
3696 unsigned int shift = 0;
3697 uint8_t *buf = (uint8_t *)dst + arg->offset + (i -= sub);
3699 for (shift = 0; arg->mask[i] >> shift; ++shift) {
3700 if (!(arg->mask[i] & (1 << shift)))
3705 *buf &= ~(1 << shift);
3706 *buf |= (val & 1) << shift;
3714 /** Compare a string with a partial one of a given length. */
3716 strcmp_partial(const char *full, const char *partial, size_t partial_len)
3718 int r = strncmp(full, partial, partial_len);
3722 if (strlen(full) <= partial_len)
3724 return full[partial_len];
3728 * Parse a prefix length and generate a bit-mask.
3730 * Last argument (ctx->args) is retrieved to determine mask size, storage
3731 * location and whether the result must use network byte ordering.
3734 parse_prefix(struct context *ctx, const struct token *token,
3735 const char *str, unsigned int len,
3736 void *buf, unsigned int size)
3738 const struct arg *arg = pop_args(ctx);
3739 static const uint8_t conv[] = "\x00\x80\xc0\xe0\xf0\xf8\xfc\xfe\xff";
3746 /* Argument is expected. */
3750 u = strtoumax(str, &end, 0);
3751 if (errno || (size_t)(end - str) != len)
3756 extra = arg_entry_bf_fill(NULL, 0, arg);
3765 if (!arg_entry_bf_fill(ctx->object, v, arg) ||
3766 !arg_entry_bf_fill(ctx->objmask, -1, arg))
3773 if (bytes > size || bytes + !!extra > size)
3777 buf = (uint8_t *)ctx->object + arg->offset;
3778 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
3780 memset((uint8_t *)buf + size - bytes, 0xff, bytes);
3781 memset(buf, 0x00, size - bytes);
3783 ((uint8_t *)buf)[size - bytes - 1] = conv[extra];
3787 memset(buf, 0xff, bytes);
3788 memset((uint8_t *)buf + bytes, 0x00, size - bytes);
3790 ((uint8_t *)buf)[bytes] = conv[extra];
3793 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
3796 push_args(ctx, arg);
3800 /** Default parsing function for token name matching. */
3802 parse_default(struct context *ctx, const struct token *token,
3803 const char *str, unsigned int len,
3804 void *buf, unsigned int size)
3809 if (strcmp_partial(token->name, str, len))
3814 /** Parse flow command, initialize output buffer for subsequent tokens. */
3816 parse_init(struct context *ctx, const struct token *token,
3817 const char *str, unsigned int len,
3818 void *buf, unsigned int size)
3820 struct buffer *out = buf;
3822 /* Token name must match. */
3823 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
3825 /* Nothing else to do if there is no buffer. */
3828 /* Make sure buffer is large enough. */
3829 if (size < sizeof(*out))
3831 /* Initialize buffer. */
3832 memset(out, 0x00, sizeof(*out));
3833 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
3836 ctx->objmask = NULL;
3840 /** Parse tokens for validate/create commands. */
3842 parse_vc(struct context *ctx, const struct token *token,
3843 const char *str, unsigned int len,
3844 void *buf, unsigned int size)
3846 struct buffer *out = buf;
3850 /* Token name must match. */
3851 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
3853 /* Nothing else to do if there is no buffer. */
3856 if (!out->command) {
3857 if (ctx->curr != VALIDATE && ctx->curr != CREATE)
3859 if (sizeof(*out) > size)
3861 out->command = ctx->curr;
3864 ctx->objmask = NULL;
3865 out->args.vc.data = (uint8_t *)out + size;
3869 ctx->object = &out->args.vc.attr;
3870 ctx->objmask = NULL;
3871 switch (ctx->curr) {
3876 out->args.vc.attr.ingress = 1;
3879 out->args.vc.attr.egress = 1;
3882 out->args.vc.attr.transfer = 1;
3885 out->args.vc.pattern =
3886 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
3888 ctx->object = out->args.vc.pattern;
3889 ctx->objmask = NULL;
3892 out->args.vc.actions =
3893 (void *)RTE_ALIGN_CEIL((uintptr_t)
3894 (out->args.vc.pattern +
3895 out->args.vc.pattern_n),
3897 ctx->object = out->args.vc.actions;
3898 ctx->objmask = NULL;
3905 if (!out->args.vc.actions) {
3906 const struct parse_item_priv *priv = token->priv;
3907 struct rte_flow_item *item =
3908 out->args.vc.pattern + out->args.vc.pattern_n;
3910 data_size = priv->size * 3; /* spec, last, mask */
3911 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
3912 (out->args.vc.data - data_size),
3914 if ((uint8_t *)item + sizeof(*item) > data)
3916 *item = (struct rte_flow_item){
3919 ++out->args.vc.pattern_n;
3921 ctx->objmask = NULL;
3923 const struct parse_action_priv *priv = token->priv;
3924 struct rte_flow_action *action =
3925 out->args.vc.actions + out->args.vc.actions_n;
3927 data_size = priv->size; /* configuration */
3928 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
3929 (out->args.vc.data - data_size),
3931 if ((uint8_t *)action + sizeof(*action) > data)
3933 *action = (struct rte_flow_action){
3935 .conf = data_size ? data : NULL,
3937 ++out->args.vc.actions_n;
3938 ctx->object = action;
3939 ctx->objmask = NULL;
3941 memset(data, 0, data_size);
3942 out->args.vc.data = data;
3943 ctx->objdata = data_size;
3947 /** Parse pattern item parameter type. */
3949 parse_vc_spec(struct context *ctx, const struct token *token,
3950 const char *str, unsigned int len,
3951 void *buf, unsigned int size)
3953 struct buffer *out = buf;
3954 struct rte_flow_item *item;
3960 /* Token name must match. */
3961 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
3963 /* Parse parameter types. */
3964 switch (ctx->curr) {
3965 static const enum index prefix[] = NEXT_ENTRY(PREFIX);
3971 case ITEM_PARAM_SPEC:
3974 case ITEM_PARAM_LAST:
3977 case ITEM_PARAM_PREFIX:
3978 /* Modify next token to expect a prefix. */
3979 if (ctx->next_num < 2)
3981 ctx->next[ctx->next_num - 2] = prefix;
3983 case ITEM_PARAM_MASK:
3989 /* Nothing else to do if there is no buffer. */
3992 if (!out->args.vc.pattern_n)
3994 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
3995 data_size = ctx->objdata / 3; /* spec, last, mask */
3996 /* Point to selected object. */
3997 ctx->object = out->args.vc.data + (data_size * index);
3999 ctx->objmask = out->args.vc.data + (data_size * 2); /* mask */
4000 item->mask = ctx->objmask;
4002 ctx->objmask = NULL;
4003 /* Update relevant item pointer. */
4004 *((const void **[]){ &item->spec, &item->last, &item->mask })[index] =
4009 /** Parse action configuration field. */
4011 parse_vc_conf(struct context *ctx, const struct token *token,
4012 const char *str, unsigned int len,
4013 void *buf, unsigned int size)
4015 struct buffer *out = buf;
4018 /* Token name must match. */
4019 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4021 /* Nothing else to do if there is no buffer. */
4024 /* Point to selected object. */
4025 ctx->object = out->args.vc.data;
4026 ctx->objmask = NULL;
4030 /** Parse RSS action. */
4032 parse_vc_action_rss(struct context *ctx, const struct token *token,
4033 const char *str, unsigned int len,
4034 void *buf, unsigned int size)
4036 struct buffer *out = buf;
4037 struct rte_flow_action *action;
4038 struct action_rss_data *action_rss_data;
4042 ret = parse_vc(ctx, token, str, len, buf, size);
4045 /* Nothing else to do if there is no buffer. */
4048 if (!out->args.vc.actions_n)
4050 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4051 /* Point to selected object. */
4052 ctx->object = out->args.vc.data;
4053 ctx->objmask = NULL;
4054 /* Set up default configuration. */
4055 action_rss_data = ctx->object;
4056 *action_rss_data = (struct action_rss_data){
4057 .conf = (struct rte_flow_action_rss){
4058 .func = RTE_ETH_HASH_FUNCTION_DEFAULT,
4061 .key_len = sizeof(action_rss_data->key),
4062 .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM),
4063 .key = action_rss_data->key,
4064 .queue = action_rss_data->queue,
4066 .key = "testpmd's default RSS hash key, "
4067 "override it for better balancing",
4070 for (i = 0; i < action_rss_data->conf.queue_num; ++i)
4071 action_rss_data->queue[i] = i;
4072 if (!port_id_is_invalid(ctx->port, DISABLED_WARN) &&
4073 ctx->port != (portid_t)RTE_PORT_ALL) {
4074 struct rte_eth_dev_info info;
4077 ret2 = rte_eth_dev_info_get(ctx->port, &info);
4081 action_rss_data->conf.key_len =
4082 RTE_MIN(sizeof(action_rss_data->key),
4083 info.hash_key_size);
4085 action->conf = &action_rss_data->conf;
4090 * Parse func field for RSS action.
4092 * The RTE_ETH_HASH_FUNCTION_* value to assign is derived from the
4093 * ACTION_RSS_FUNC_* index that called this function.
4096 parse_vc_action_rss_func(struct context *ctx, const struct token *token,
4097 const char *str, unsigned int len,
4098 void *buf, unsigned int size)
4100 struct action_rss_data *action_rss_data;
4101 enum rte_eth_hash_function func;
4105 /* Token name must match. */
4106 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4108 switch (ctx->curr) {
4109 case ACTION_RSS_FUNC_DEFAULT:
4110 func = RTE_ETH_HASH_FUNCTION_DEFAULT;
4112 case ACTION_RSS_FUNC_TOEPLITZ:
4113 func = RTE_ETH_HASH_FUNCTION_TOEPLITZ;
4115 case ACTION_RSS_FUNC_SIMPLE_XOR:
4116 func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
4118 case ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ:
4119 func = RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
4126 action_rss_data = ctx->object;
4127 action_rss_data->conf.func = func;
4132 * Parse type field for RSS action.
4134 * Valid tokens are type field names and the "end" token.
4137 parse_vc_action_rss_type(struct context *ctx, const struct token *token,
4138 const char *str, unsigned int len,
4139 void *buf, unsigned int size)
4141 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE);
4142 struct action_rss_data *action_rss_data;
4148 if (ctx->curr != ACTION_RSS_TYPE)
4150 if (!(ctx->objdata >> 16) && ctx->object) {
4151 action_rss_data = ctx->object;
4152 action_rss_data->conf.types = 0;
4154 if (!strcmp_partial("end", str, len)) {
4155 ctx->objdata &= 0xffff;
4158 for (i = 0; rss_type_table[i].str; ++i)
4159 if (!strcmp_partial(rss_type_table[i].str, str, len))
4161 if (!rss_type_table[i].str)
4163 ctx->objdata = 1 << 16 | (ctx->objdata & 0xffff);
4165 if (ctx->next_num == RTE_DIM(ctx->next))
4167 ctx->next[ctx->next_num++] = next;
4170 action_rss_data = ctx->object;
4171 action_rss_data->conf.types |= rss_type_table[i].rss_type;
4176 * Parse queue field for RSS action.
4178 * Valid tokens are queue indices and the "end" token.
4181 parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
4182 const char *str, unsigned int len,
4183 void *buf, unsigned int size)
4185 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE);
4186 struct action_rss_data *action_rss_data;
4187 const struct arg *arg;
4194 if (ctx->curr != ACTION_RSS_QUEUE)
4196 i = ctx->objdata >> 16;
4197 if (!strcmp_partial("end", str, len)) {
4198 ctx->objdata &= 0xffff;
4201 if (i >= ACTION_RSS_QUEUE_NUM)
4203 arg = ARGS_ENTRY_ARB(offsetof(struct action_rss_data, queue) +
4204 i * sizeof(action_rss_data->queue[i]),
4205 sizeof(action_rss_data->queue[i]));
4206 if (push_args(ctx, arg))
4208 ret = parse_int(ctx, token, str, len, NULL, 0);
4214 ctx->objdata = i << 16 | (ctx->objdata & 0xffff);
4216 if (ctx->next_num == RTE_DIM(ctx->next))
4218 ctx->next[ctx->next_num++] = next;
4222 action_rss_data = ctx->object;
4223 action_rss_data->conf.queue_num = i;
4224 action_rss_data->conf.queue = i ? action_rss_data->queue : NULL;
4228 /** Parse VXLAN encap action. */
4230 parse_vc_action_vxlan_encap(struct context *ctx, const struct token *token,
4231 const char *str, unsigned int len,
4232 void *buf, unsigned int size)
4234 struct buffer *out = buf;
4235 struct rte_flow_action *action;
4236 struct action_vxlan_encap_data *action_vxlan_encap_data;
4239 ret = parse_vc(ctx, token, str, len, buf, size);
4242 /* Nothing else to do if there is no buffer. */
4245 if (!out->args.vc.actions_n)
4247 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4248 /* Point to selected object. */
4249 ctx->object = out->args.vc.data;
4250 ctx->objmask = NULL;
4251 /* Set up default configuration. */
4252 action_vxlan_encap_data = ctx->object;
4253 *action_vxlan_encap_data = (struct action_vxlan_encap_data){
4254 .conf = (struct rte_flow_action_vxlan_encap){
4255 .definition = action_vxlan_encap_data->items,
4259 .type = RTE_FLOW_ITEM_TYPE_ETH,
4260 .spec = &action_vxlan_encap_data->item_eth,
4261 .mask = &rte_flow_item_eth_mask,
4264 .type = RTE_FLOW_ITEM_TYPE_VLAN,
4265 .spec = &action_vxlan_encap_data->item_vlan,
4266 .mask = &rte_flow_item_vlan_mask,
4269 .type = RTE_FLOW_ITEM_TYPE_IPV4,
4270 .spec = &action_vxlan_encap_data->item_ipv4,
4271 .mask = &rte_flow_item_ipv4_mask,
4274 .type = RTE_FLOW_ITEM_TYPE_UDP,
4275 .spec = &action_vxlan_encap_data->item_udp,
4276 .mask = &rte_flow_item_udp_mask,
4279 .type = RTE_FLOW_ITEM_TYPE_VXLAN,
4280 .spec = &action_vxlan_encap_data->item_vxlan,
4281 .mask = &rte_flow_item_vxlan_mask,
4284 .type = RTE_FLOW_ITEM_TYPE_END,
4289 .tci = vxlan_encap_conf.vlan_tci,
4293 .src_addr = vxlan_encap_conf.ipv4_src,
4294 .dst_addr = vxlan_encap_conf.ipv4_dst,
4297 .src_port = vxlan_encap_conf.udp_src,
4298 .dst_port = vxlan_encap_conf.udp_dst,
4300 .item_vxlan.flags = 0,
4302 memcpy(action_vxlan_encap_data->item_eth.dst.addr_bytes,
4303 vxlan_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
4304 memcpy(action_vxlan_encap_data->item_eth.src.addr_bytes,
4305 vxlan_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
4306 if (!vxlan_encap_conf.select_ipv4) {
4307 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.src_addr,
4308 &vxlan_encap_conf.ipv6_src,
4309 sizeof(vxlan_encap_conf.ipv6_src));
4310 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.dst_addr,
4311 &vxlan_encap_conf.ipv6_dst,
4312 sizeof(vxlan_encap_conf.ipv6_dst));
4313 action_vxlan_encap_data->items[2] = (struct rte_flow_item){
4314 .type = RTE_FLOW_ITEM_TYPE_IPV6,
4315 .spec = &action_vxlan_encap_data->item_ipv6,
4316 .mask = &rte_flow_item_ipv6_mask,
4319 if (!vxlan_encap_conf.select_vlan)
4320 action_vxlan_encap_data->items[1].type =
4321 RTE_FLOW_ITEM_TYPE_VOID;
4322 if (vxlan_encap_conf.select_tos_ttl) {
4323 if (vxlan_encap_conf.select_ipv4) {
4324 static struct rte_flow_item_ipv4 ipv4_mask_tos;
4326 memcpy(&ipv4_mask_tos, &rte_flow_item_ipv4_mask,
4327 sizeof(ipv4_mask_tos));
4328 ipv4_mask_tos.hdr.type_of_service = 0xff;
4329 ipv4_mask_tos.hdr.time_to_live = 0xff;
4330 action_vxlan_encap_data->item_ipv4.hdr.type_of_service =
4331 vxlan_encap_conf.ip_tos;
4332 action_vxlan_encap_data->item_ipv4.hdr.time_to_live =
4333 vxlan_encap_conf.ip_ttl;
4334 action_vxlan_encap_data->items[2].mask =
4337 static struct rte_flow_item_ipv6 ipv6_mask_tos;
4339 memcpy(&ipv6_mask_tos, &rte_flow_item_ipv6_mask,
4340 sizeof(ipv6_mask_tos));
4341 ipv6_mask_tos.hdr.vtc_flow |=
4342 RTE_BE32(0xfful << RTE_IPV6_HDR_TC_SHIFT);
4343 ipv6_mask_tos.hdr.hop_limits = 0xff;
4344 action_vxlan_encap_data->item_ipv6.hdr.vtc_flow |=
4346 ((uint32_t)vxlan_encap_conf.ip_tos <<
4347 RTE_IPV6_HDR_TC_SHIFT);
4348 action_vxlan_encap_data->item_ipv6.hdr.hop_limits =
4349 vxlan_encap_conf.ip_ttl;
4350 action_vxlan_encap_data->items[2].mask =
4354 memcpy(action_vxlan_encap_data->item_vxlan.vni, vxlan_encap_conf.vni,
4355 RTE_DIM(vxlan_encap_conf.vni));
4356 action->conf = &action_vxlan_encap_data->conf;
4360 /** Parse NVGRE encap action. */
4362 parse_vc_action_nvgre_encap(struct context *ctx, const struct token *token,
4363 const char *str, unsigned int len,
4364 void *buf, unsigned int size)
4366 struct buffer *out = buf;
4367 struct rte_flow_action *action;
4368 struct action_nvgre_encap_data *action_nvgre_encap_data;
4371 ret = parse_vc(ctx, token, str, len, buf, size);
4374 /* Nothing else to do if there is no buffer. */
4377 if (!out->args.vc.actions_n)
4379 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4380 /* Point to selected object. */
4381 ctx->object = out->args.vc.data;
4382 ctx->objmask = NULL;
4383 /* Set up default configuration. */
4384 action_nvgre_encap_data = ctx->object;
4385 *action_nvgre_encap_data = (struct action_nvgre_encap_data){
4386 .conf = (struct rte_flow_action_nvgre_encap){
4387 .definition = action_nvgre_encap_data->items,
4391 .type = RTE_FLOW_ITEM_TYPE_ETH,
4392 .spec = &action_nvgre_encap_data->item_eth,
4393 .mask = &rte_flow_item_eth_mask,
4396 .type = RTE_FLOW_ITEM_TYPE_VLAN,
4397 .spec = &action_nvgre_encap_data->item_vlan,
4398 .mask = &rte_flow_item_vlan_mask,
4401 .type = RTE_FLOW_ITEM_TYPE_IPV4,
4402 .spec = &action_nvgre_encap_data->item_ipv4,
4403 .mask = &rte_flow_item_ipv4_mask,
4406 .type = RTE_FLOW_ITEM_TYPE_NVGRE,
4407 .spec = &action_nvgre_encap_data->item_nvgre,
4408 .mask = &rte_flow_item_nvgre_mask,
4411 .type = RTE_FLOW_ITEM_TYPE_END,
4416 .tci = nvgre_encap_conf.vlan_tci,
4420 .src_addr = nvgre_encap_conf.ipv4_src,
4421 .dst_addr = nvgre_encap_conf.ipv4_dst,
4423 .item_nvgre.flow_id = 0,
4425 memcpy(action_nvgre_encap_data->item_eth.dst.addr_bytes,
4426 nvgre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
4427 memcpy(action_nvgre_encap_data->item_eth.src.addr_bytes,
4428 nvgre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
4429 if (!nvgre_encap_conf.select_ipv4) {
4430 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.src_addr,
4431 &nvgre_encap_conf.ipv6_src,
4432 sizeof(nvgre_encap_conf.ipv6_src));
4433 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.dst_addr,
4434 &nvgre_encap_conf.ipv6_dst,
4435 sizeof(nvgre_encap_conf.ipv6_dst));
4436 action_nvgre_encap_data->items[2] = (struct rte_flow_item){
4437 .type = RTE_FLOW_ITEM_TYPE_IPV6,
4438 .spec = &action_nvgre_encap_data->item_ipv6,
4439 .mask = &rte_flow_item_ipv6_mask,
4442 if (!nvgre_encap_conf.select_vlan)
4443 action_nvgre_encap_data->items[1].type =
4444 RTE_FLOW_ITEM_TYPE_VOID;
4445 memcpy(action_nvgre_encap_data->item_nvgre.tni, nvgre_encap_conf.tni,
4446 RTE_DIM(nvgre_encap_conf.tni));
4447 action->conf = &action_nvgre_encap_data->conf;
4451 /** Parse l2 encap action. */
4453 parse_vc_action_l2_encap(struct context *ctx, const struct token *token,
4454 const char *str, unsigned int len,
4455 void *buf, unsigned int size)
4457 struct buffer *out = buf;
4458 struct rte_flow_action *action;
4459 struct action_raw_encap_data *action_encap_data;
4460 struct rte_flow_item_eth eth = { .type = 0, };
4461 struct rte_flow_item_vlan vlan = {
4462 .tci = mplsoudp_encap_conf.vlan_tci,
4468 ret = parse_vc(ctx, token, str, len, buf, size);
4471 /* Nothing else to do if there is no buffer. */
4474 if (!out->args.vc.actions_n)
4476 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4477 /* Point to selected object. */
4478 ctx->object = out->args.vc.data;
4479 ctx->objmask = NULL;
4480 /* Copy the headers to the buffer. */
4481 action_encap_data = ctx->object;
4482 *action_encap_data = (struct action_raw_encap_data) {
4483 .conf = (struct rte_flow_action_raw_encap){
4484 .data = action_encap_data->data,
4488 header = action_encap_data->data;
4489 if (l2_encap_conf.select_vlan)
4490 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
4491 else if (l2_encap_conf.select_ipv4)
4492 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
4494 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
4495 memcpy(eth.dst.addr_bytes,
4496 l2_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
4497 memcpy(eth.src.addr_bytes,
4498 l2_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
4499 memcpy(header, ð, sizeof(eth));
4500 header += sizeof(eth);
4501 if (l2_encap_conf.select_vlan) {
4502 if (l2_encap_conf.select_ipv4)
4503 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
4505 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
4506 memcpy(header, &vlan, sizeof(vlan));
4507 header += sizeof(vlan);
4509 action_encap_data->conf.size = header -
4510 action_encap_data->data;
4511 action->conf = &action_encap_data->conf;
4515 /** Parse l2 decap action. */
4517 parse_vc_action_l2_decap(struct context *ctx, const struct token *token,
4518 const char *str, unsigned int len,
4519 void *buf, unsigned int size)
4521 struct buffer *out = buf;
4522 struct rte_flow_action *action;
4523 struct action_raw_decap_data *action_decap_data;
4524 struct rte_flow_item_eth eth = { .type = 0, };
4525 struct rte_flow_item_vlan vlan = {
4526 .tci = mplsoudp_encap_conf.vlan_tci,
4532 ret = parse_vc(ctx, token, str, len, buf, size);
4535 /* Nothing else to do if there is no buffer. */
4538 if (!out->args.vc.actions_n)
4540 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4541 /* Point to selected object. */
4542 ctx->object = out->args.vc.data;
4543 ctx->objmask = NULL;
4544 /* Copy the headers to the buffer. */
4545 action_decap_data = ctx->object;
4546 *action_decap_data = (struct action_raw_decap_data) {
4547 .conf = (struct rte_flow_action_raw_decap){
4548 .data = action_decap_data->data,
4552 header = action_decap_data->data;
4553 if (l2_decap_conf.select_vlan)
4554 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
4555 memcpy(header, ð, sizeof(eth));
4556 header += sizeof(eth);
4557 if (l2_decap_conf.select_vlan) {
4558 memcpy(header, &vlan, sizeof(vlan));
4559 header += sizeof(vlan);
4561 action_decap_data->conf.size = header -
4562 action_decap_data->data;
4563 action->conf = &action_decap_data->conf;
4567 #define ETHER_TYPE_MPLS_UNICAST 0x8847
4569 /** Parse MPLSOGRE encap action. */
4571 parse_vc_action_mplsogre_encap(struct context *ctx, const struct token *token,
4572 const char *str, unsigned int len,
4573 void *buf, unsigned int size)
4575 struct buffer *out = buf;
4576 struct rte_flow_action *action;
4577 struct action_raw_encap_data *action_encap_data;
4578 struct rte_flow_item_eth eth = { .type = 0, };
4579 struct rte_flow_item_vlan vlan = {
4580 .tci = mplsogre_encap_conf.vlan_tci,
4583 struct rte_flow_item_ipv4 ipv4 = {
4585 .src_addr = mplsogre_encap_conf.ipv4_src,
4586 .dst_addr = mplsogre_encap_conf.ipv4_dst,
4587 .next_proto_id = IPPROTO_GRE,
4588 .version_ihl = RTE_IPV4_VHL_DEF,
4589 .time_to_live = IPDEFTTL,
4592 struct rte_flow_item_ipv6 ipv6 = {
4594 .proto = IPPROTO_GRE,
4595 .hop_limits = IPDEFTTL,
4598 struct rte_flow_item_gre gre = {
4599 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
4601 struct rte_flow_item_mpls mpls = {
4607 ret = parse_vc(ctx, token, str, len, buf, size);
4610 /* Nothing else to do if there is no buffer. */
4613 if (!out->args.vc.actions_n)
4615 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4616 /* Point to selected object. */
4617 ctx->object = out->args.vc.data;
4618 ctx->objmask = NULL;
4619 /* Copy the headers to the buffer. */
4620 action_encap_data = ctx->object;
4621 *action_encap_data = (struct action_raw_encap_data) {
4622 .conf = (struct rte_flow_action_raw_encap){
4623 .data = action_encap_data->data,
4628 header = action_encap_data->data;
4629 if (mplsogre_encap_conf.select_vlan)
4630 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
4631 else if (mplsogre_encap_conf.select_ipv4)
4632 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
4634 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
4635 memcpy(eth.dst.addr_bytes,
4636 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
4637 memcpy(eth.src.addr_bytes,
4638 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
4639 memcpy(header, ð, sizeof(eth));
4640 header += sizeof(eth);
4641 if (mplsogre_encap_conf.select_vlan) {
4642 if (mplsogre_encap_conf.select_ipv4)
4643 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
4645 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
4646 memcpy(header, &vlan, sizeof(vlan));
4647 header += sizeof(vlan);
4649 if (mplsogre_encap_conf.select_ipv4) {
4650 memcpy(header, &ipv4, sizeof(ipv4));
4651 header += sizeof(ipv4);
4653 memcpy(&ipv6.hdr.src_addr,
4654 &mplsogre_encap_conf.ipv6_src,
4655 sizeof(mplsogre_encap_conf.ipv6_src));
4656 memcpy(&ipv6.hdr.dst_addr,
4657 &mplsogre_encap_conf.ipv6_dst,
4658 sizeof(mplsogre_encap_conf.ipv6_dst));
4659 memcpy(header, &ipv6, sizeof(ipv6));
4660 header += sizeof(ipv6);
4662 memcpy(header, &gre, sizeof(gre));
4663 header += sizeof(gre);
4664 memcpy(mpls.label_tc_s, mplsogre_encap_conf.label,
4665 RTE_DIM(mplsogre_encap_conf.label));
4666 mpls.label_tc_s[2] |= 0x1;
4667 memcpy(header, &mpls, sizeof(mpls));
4668 header += sizeof(mpls);
4669 action_encap_data->conf.size = header -
4670 action_encap_data->data;
4671 action->conf = &action_encap_data->conf;
4675 /** Parse MPLSOGRE decap action. */
4677 parse_vc_action_mplsogre_decap(struct context *ctx, const struct token *token,
4678 const char *str, unsigned int len,
4679 void *buf, unsigned int size)
4681 struct buffer *out = buf;
4682 struct rte_flow_action *action;
4683 struct action_raw_decap_data *action_decap_data;
4684 struct rte_flow_item_eth eth = { .type = 0, };
4685 struct rte_flow_item_vlan vlan = {.tci = 0};
4686 struct rte_flow_item_ipv4 ipv4 = {
4688 .next_proto_id = IPPROTO_GRE,
4691 struct rte_flow_item_ipv6 ipv6 = {
4693 .proto = IPPROTO_GRE,
4696 struct rte_flow_item_gre gre = {
4697 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
4699 struct rte_flow_item_mpls mpls;
4703 ret = parse_vc(ctx, token, str, len, buf, size);
4706 /* Nothing else to do if there is no buffer. */
4709 if (!out->args.vc.actions_n)
4711 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4712 /* Point to selected object. */
4713 ctx->object = out->args.vc.data;
4714 ctx->objmask = NULL;
4715 /* Copy the headers to the buffer. */
4716 action_decap_data = ctx->object;
4717 *action_decap_data = (struct action_raw_decap_data) {
4718 .conf = (struct rte_flow_action_raw_decap){
4719 .data = action_decap_data->data,
4723 header = action_decap_data->data;
4724 if (mplsogre_decap_conf.select_vlan)
4725 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
4726 else if (mplsogre_encap_conf.select_ipv4)
4727 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
4729 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
4730 memcpy(eth.dst.addr_bytes,
4731 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
4732 memcpy(eth.src.addr_bytes,
4733 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
4734 memcpy(header, ð, sizeof(eth));
4735 header += sizeof(eth);
4736 if (mplsogre_encap_conf.select_vlan) {
4737 if (mplsogre_encap_conf.select_ipv4)
4738 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
4740 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
4741 memcpy(header, &vlan, sizeof(vlan));
4742 header += sizeof(vlan);
4744 if (mplsogre_encap_conf.select_ipv4) {
4745 memcpy(header, &ipv4, sizeof(ipv4));
4746 header += sizeof(ipv4);
4748 memcpy(header, &ipv6, sizeof(ipv6));
4749 header += sizeof(ipv6);
4751 memcpy(header, &gre, sizeof(gre));
4752 header += sizeof(gre);
4753 memset(&mpls, 0, sizeof(mpls));
4754 memcpy(header, &mpls, sizeof(mpls));
4755 header += sizeof(mpls);
4756 action_decap_data->conf.size = header -
4757 action_decap_data->data;
4758 action->conf = &action_decap_data->conf;
4762 /** Parse MPLSOUDP encap action. */
4764 parse_vc_action_mplsoudp_encap(struct context *ctx, const struct token *token,
4765 const char *str, unsigned int len,
4766 void *buf, unsigned int size)
4768 struct buffer *out = buf;
4769 struct rte_flow_action *action;
4770 struct action_raw_encap_data *action_encap_data;
4771 struct rte_flow_item_eth eth = { .type = 0, };
4772 struct rte_flow_item_vlan vlan = {
4773 .tci = mplsoudp_encap_conf.vlan_tci,
4776 struct rte_flow_item_ipv4 ipv4 = {
4778 .src_addr = mplsoudp_encap_conf.ipv4_src,
4779 .dst_addr = mplsoudp_encap_conf.ipv4_dst,
4780 .next_proto_id = IPPROTO_UDP,
4781 .version_ihl = RTE_IPV4_VHL_DEF,
4782 .time_to_live = IPDEFTTL,
4785 struct rte_flow_item_ipv6 ipv6 = {
4787 .proto = IPPROTO_UDP,
4788 .hop_limits = IPDEFTTL,
4791 struct rte_flow_item_udp udp = {
4793 .src_port = mplsoudp_encap_conf.udp_src,
4794 .dst_port = mplsoudp_encap_conf.udp_dst,
4797 struct rte_flow_item_mpls mpls;
4801 ret = parse_vc(ctx, token, str, len, buf, size);
4804 /* Nothing else to do if there is no buffer. */
4807 if (!out->args.vc.actions_n)
4809 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4810 /* Point to selected object. */
4811 ctx->object = out->args.vc.data;
4812 ctx->objmask = NULL;
4813 /* Copy the headers to the buffer. */
4814 action_encap_data = ctx->object;
4815 *action_encap_data = (struct action_raw_encap_data) {
4816 .conf = (struct rte_flow_action_raw_encap){
4817 .data = action_encap_data->data,
4822 header = action_encap_data->data;
4823 if (mplsoudp_encap_conf.select_vlan)
4824 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
4825 else if (mplsoudp_encap_conf.select_ipv4)
4826 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
4828 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
4829 memcpy(eth.dst.addr_bytes,
4830 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
4831 memcpy(eth.src.addr_bytes,
4832 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
4833 memcpy(header, ð, sizeof(eth));
4834 header += sizeof(eth);
4835 if (mplsoudp_encap_conf.select_vlan) {
4836 if (mplsoudp_encap_conf.select_ipv4)
4837 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
4839 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
4840 memcpy(header, &vlan, sizeof(vlan));
4841 header += sizeof(vlan);
4843 if (mplsoudp_encap_conf.select_ipv4) {
4844 memcpy(header, &ipv4, sizeof(ipv4));
4845 header += sizeof(ipv4);
4847 memcpy(&ipv6.hdr.src_addr,
4848 &mplsoudp_encap_conf.ipv6_src,
4849 sizeof(mplsoudp_encap_conf.ipv6_src));
4850 memcpy(&ipv6.hdr.dst_addr,
4851 &mplsoudp_encap_conf.ipv6_dst,
4852 sizeof(mplsoudp_encap_conf.ipv6_dst));
4853 memcpy(header, &ipv6, sizeof(ipv6));
4854 header += sizeof(ipv6);
4856 memcpy(header, &udp, sizeof(udp));
4857 header += sizeof(udp);
4858 memcpy(mpls.label_tc_s, mplsoudp_encap_conf.label,
4859 RTE_DIM(mplsoudp_encap_conf.label));
4860 mpls.label_tc_s[2] |= 0x1;
4861 memcpy(header, &mpls, sizeof(mpls));
4862 header += sizeof(mpls);
4863 action_encap_data->conf.size = header -
4864 action_encap_data->data;
4865 action->conf = &action_encap_data->conf;
4869 /** Parse MPLSOUDP decap action. */
4871 parse_vc_action_mplsoudp_decap(struct context *ctx, const struct token *token,
4872 const char *str, unsigned int len,
4873 void *buf, unsigned int size)
4875 struct buffer *out = buf;
4876 struct rte_flow_action *action;
4877 struct action_raw_decap_data *action_decap_data;
4878 struct rte_flow_item_eth eth = { .type = 0, };
4879 struct rte_flow_item_vlan vlan = {.tci = 0};
4880 struct rte_flow_item_ipv4 ipv4 = {
4882 .next_proto_id = IPPROTO_UDP,
4885 struct rte_flow_item_ipv6 ipv6 = {
4887 .proto = IPPROTO_UDP,
4890 struct rte_flow_item_udp udp = {
4892 .dst_port = rte_cpu_to_be_16(6635),
4895 struct rte_flow_item_mpls mpls;
4899 ret = parse_vc(ctx, token, str, len, buf, size);
4902 /* Nothing else to do if there is no buffer. */
4905 if (!out->args.vc.actions_n)
4907 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4908 /* Point to selected object. */
4909 ctx->object = out->args.vc.data;
4910 ctx->objmask = NULL;
4911 /* Copy the headers to the buffer. */
4912 action_decap_data = ctx->object;
4913 *action_decap_data = (struct action_raw_decap_data) {
4914 .conf = (struct rte_flow_action_raw_decap){
4915 .data = action_decap_data->data,
4919 header = action_decap_data->data;
4920 if (mplsoudp_decap_conf.select_vlan)
4921 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
4922 else if (mplsoudp_encap_conf.select_ipv4)
4923 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
4925 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
4926 memcpy(eth.dst.addr_bytes,
4927 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
4928 memcpy(eth.src.addr_bytes,
4929 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
4930 memcpy(header, ð, sizeof(eth));
4931 header += sizeof(eth);
4932 if (mplsoudp_encap_conf.select_vlan) {
4933 if (mplsoudp_encap_conf.select_ipv4)
4934 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
4936 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
4937 memcpy(header, &vlan, sizeof(vlan));
4938 header += sizeof(vlan);
4940 if (mplsoudp_encap_conf.select_ipv4) {
4941 memcpy(header, &ipv4, sizeof(ipv4));
4942 header += sizeof(ipv4);
4944 memcpy(header, &ipv6, sizeof(ipv6));
4945 header += sizeof(ipv6);
4947 memcpy(header, &udp, sizeof(udp));
4948 header += sizeof(udp);
4949 memset(&mpls, 0, sizeof(mpls));
4950 memcpy(header, &mpls, sizeof(mpls));
4951 header += sizeof(mpls);
4952 action_decap_data->conf.size = header -
4953 action_decap_data->data;
4954 action->conf = &action_decap_data->conf;
4959 parse_vc_action_raw_decap_index(struct context *ctx, const struct token *token,
4960 const char *str, unsigned int len, void *buf,
4963 struct action_raw_decap_data *action_raw_decap_data;
4964 struct rte_flow_action *action;
4965 const struct arg *arg;
4966 struct buffer *out = buf;
4970 RTE_SET_USED(token);
4973 arg = ARGS_ENTRY_ARB_BOUNDED
4974 (offsetof(struct action_raw_decap_data, idx),
4975 sizeof(((struct action_raw_decap_data *)0)->idx),
4976 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
4977 if (push_args(ctx, arg))
4979 ret = parse_int(ctx, token, str, len, NULL, 0);
4986 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4987 action_raw_decap_data = ctx->object;
4988 idx = action_raw_decap_data->idx;
4989 action_raw_decap_data->conf.data = raw_decap_confs[idx].data;
4990 action_raw_decap_data->conf.size = raw_decap_confs[idx].size;
4991 action->conf = &action_raw_decap_data->conf;
4997 parse_vc_action_raw_encap_index(struct context *ctx, const struct token *token,
4998 const char *str, unsigned int len, void *buf,
5001 struct action_raw_encap_data *action_raw_encap_data;
5002 struct rte_flow_action *action;
5003 const struct arg *arg;
5004 struct buffer *out = buf;
5008 RTE_SET_USED(token);
5011 if (ctx->curr != ACTION_RAW_ENCAP_INDEX_VALUE)
5013 arg = ARGS_ENTRY_ARB_BOUNDED
5014 (offsetof(struct action_raw_encap_data, idx),
5015 sizeof(((struct action_raw_encap_data *)0)->idx),
5016 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
5017 if (push_args(ctx, arg))
5019 ret = parse_int(ctx, token, str, len, NULL, 0);
5026 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5027 action_raw_encap_data = ctx->object;
5028 idx = action_raw_encap_data->idx;
5029 action_raw_encap_data->conf.data = raw_encap_confs[idx].data;
5030 action_raw_encap_data->conf.size = raw_encap_confs[idx].size;
5031 action_raw_encap_data->conf.preserve = NULL;
5032 action->conf = &action_raw_encap_data->conf;
5037 parse_vc_action_raw_encap(struct context *ctx, const struct token *token,
5038 const char *str, unsigned int len, void *buf,
5041 struct buffer *out = buf;
5042 struct rte_flow_action *action;
5043 struct action_raw_encap_data *action_raw_encap_data = NULL;
5046 ret = parse_vc(ctx, token, str, len, buf, size);
5049 /* Nothing else to do if there is no buffer. */
5052 if (!out->args.vc.actions_n)
5054 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5055 /* Point to selected object. */
5056 ctx->object = out->args.vc.data;
5057 ctx->objmask = NULL;
5058 /* Copy the headers to the buffer. */
5059 action_raw_encap_data = ctx->object;
5060 action_raw_encap_data->conf.data = raw_encap_confs[0].data;
5061 action_raw_encap_data->conf.preserve = NULL;
5062 action_raw_encap_data->conf.size = raw_encap_confs[0].size;
5063 action->conf = &action_raw_encap_data->conf;
5068 parse_vc_action_raw_decap(struct context *ctx, const struct token *token,
5069 const char *str, unsigned int len, void *buf,
5072 struct buffer *out = buf;
5073 struct rte_flow_action *action;
5074 struct action_raw_decap_data *action_raw_decap_data = NULL;
5077 ret = parse_vc(ctx, token, str, len, buf, size);
5080 /* Nothing else to do if there is no buffer. */
5083 if (!out->args.vc.actions_n)
5085 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5086 /* Point to selected object. */
5087 ctx->object = out->args.vc.data;
5088 ctx->objmask = NULL;
5089 /* Copy the headers to the buffer. */
5090 action_raw_decap_data = ctx->object;
5091 action_raw_decap_data->conf.data = raw_decap_confs[0].data;
5092 action_raw_decap_data->conf.size = raw_decap_confs[0].size;
5093 action->conf = &action_raw_decap_data->conf;
5098 parse_vc_action_set_meta(struct context *ctx, const struct token *token,
5099 const char *str, unsigned int len, void *buf,
5104 ret = parse_vc(ctx, token, str, len, buf, size);
5107 ret = rte_flow_dynf_metadata_register();
5113 /** Parse tokens for destroy command. */
5115 parse_destroy(struct context *ctx, const struct token *token,
5116 const char *str, unsigned int len,
5117 void *buf, unsigned int size)
5119 struct buffer *out = buf;
5121 /* Token name must match. */
5122 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5124 /* Nothing else to do if there is no buffer. */
5127 if (!out->command) {
5128 if (ctx->curr != DESTROY)
5130 if (sizeof(*out) > size)
5132 out->command = ctx->curr;
5135 ctx->objmask = NULL;
5136 out->args.destroy.rule =
5137 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5141 if (((uint8_t *)(out->args.destroy.rule + out->args.destroy.rule_n) +
5142 sizeof(*out->args.destroy.rule)) > (uint8_t *)out + size)
5145 ctx->object = out->args.destroy.rule + out->args.destroy.rule_n++;
5146 ctx->objmask = NULL;
5150 /** Parse tokens for flush command. */
5152 parse_flush(struct context *ctx, const struct token *token,
5153 const char *str, unsigned int len,
5154 void *buf, unsigned int size)
5156 struct buffer *out = buf;
5158 /* Token name must match. */
5159 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5161 /* Nothing else to do if there is no buffer. */
5164 if (!out->command) {
5165 if (ctx->curr != FLUSH)
5167 if (sizeof(*out) > size)
5169 out->command = ctx->curr;
5172 ctx->objmask = NULL;
5177 /** Parse tokens for dump command. */
5179 parse_dump(struct context *ctx, const struct token *token,
5180 const char *str, unsigned int len,
5181 void *buf, unsigned int size)
5183 struct buffer *out = buf;
5185 /* Token name must match. */
5186 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5188 /* Nothing else to do if there is no buffer. */
5191 if (!out->command) {
5192 if (ctx->curr != DUMP)
5194 if (sizeof(*out) > size)
5196 out->command = ctx->curr;
5199 ctx->objmask = NULL;
5204 /** Parse tokens for query command. */
5206 parse_query(struct context *ctx, const struct token *token,
5207 const char *str, unsigned int len,
5208 void *buf, unsigned int size)
5210 struct buffer *out = buf;
5212 /* Token name must match. */
5213 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5215 /* Nothing else to do if there is no buffer. */
5218 if (!out->command) {
5219 if (ctx->curr != QUERY)
5221 if (sizeof(*out) > size)
5223 out->command = ctx->curr;
5226 ctx->objmask = NULL;
5231 /** Parse action names. */
5233 parse_action(struct context *ctx, const struct token *token,
5234 const char *str, unsigned int len,
5235 void *buf, unsigned int size)
5237 struct buffer *out = buf;
5238 const struct arg *arg = pop_args(ctx);
5242 /* Argument is expected. */
5245 /* Parse action name. */
5246 for (i = 0; next_action[i]; ++i) {
5247 const struct parse_action_priv *priv;
5249 token = &token_list[next_action[i]];
5250 if (strcmp_partial(token->name, str, len))
5256 memcpy((uint8_t *)ctx->object + arg->offset,
5262 push_args(ctx, arg);
5266 /** Parse tokens for list command. */
5268 parse_list(struct context *ctx, const struct token *token,
5269 const char *str, unsigned int len,
5270 void *buf, unsigned int size)
5272 struct buffer *out = buf;
5274 /* Token name must match. */
5275 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5277 /* Nothing else to do if there is no buffer. */
5280 if (!out->command) {
5281 if (ctx->curr != LIST)
5283 if (sizeof(*out) > size)
5285 out->command = ctx->curr;
5288 ctx->objmask = NULL;
5289 out->args.list.group =
5290 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5294 if (((uint8_t *)(out->args.list.group + out->args.list.group_n) +
5295 sizeof(*out->args.list.group)) > (uint8_t *)out + size)
5298 ctx->object = out->args.list.group + out->args.list.group_n++;
5299 ctx->objmask = NULL;
5303 /** Parse tokens for isolate command. */
5305 parse_isolate(struct context *ctx, const struct token *token,
5306 const char *str, unsigned int len,
5307 void *buf, unsigned int size)
5309 struct buffer *out = buf;
5311 /* Token name must match. */
5312 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5314 /* Nothing else to do if there is no buffer. */
5317 if (!out->command) {
5318 if (ctx->curr != ISOLATE)
5320 if (sizeof(*out) > size)
5322 out->command = ctx->curr;
5325 ctx->objmask = NULL;
5331 * Parse signed/unsigned integers 8 to 64-bit long.
5333 * Last argument (ctx->args) is retrieved to determine integer type and
5337 parse_int(struct context *ctx, const struct token *token,
5338 const char *str, unsigned int len,
5339 void *buf, unsigned int size)
5341 const struct arg *arg = pop_args(ctx);
5346 /* Argument is expected. */
5351 (uintmax_t)strtoimax(str, &end, 0) :
5352 strtoumax(str, &end, 0);
5353 if (errno || (size_t)(end - str) != len)
5356 ((arg->sign && ((intmax_t)u < (intmax_t)arg->min ||
5357 (intmax_t)u > (intmax_t)arg->max)) ||
5358 (!arg->sign && (u < arg->min || u > arg->max))))
5363 if (!arg_entry_bf_fill(ctx->object, u, arg) ||
5364 !arg_entry_bf_fill(ctx->objmask, -1, arg))
5368 buf = (uint8_t *)ctx->object + arg->offset;
5370 if (u > RTE_LEN2MASK(size * CHAR_BIT, uint64_t))
5374 case sizeof(uint8_t):
5375 *(uint8_t *)buf = u;
5377 case sizeof(uint16_t):
5378 *(uint16_t *)buf = arg->hton ? rte_cpu_to_be_16(u) : u;
5380 case sizeof(uint8_t [3]):
5381 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
5383 ((uint8_t *)buf)[0] = u;
5384 ((uint8_t *)buf)[1] = u >> 8;
5385 ((uint8_t *)buf)[2] = u >> 16;
5389 ((uint8_t *)buf)[0] = u >> 16;
5390 ((uint8_t *)buf)[1] = u >> 8;
5391 ((uint8_t *)buf)[2] = u;
5393 case sizeof(uint32_t):
5394 *(uint32_t *)buf = arg->hton ? rte_cpu_to_be_32(u) : u;
5396 case sizeof(uint64_t):
5397 *(uint64_t *)buf = arg->hton ? rte_cpu_to_be_64(u) : u;
5402 if (ctx->objmask && buf != (uint8_t *)ctx->objmask + arg->offset) {
5404 buf = (uint8_t *)ctx->objmask + arg->offset;
5409 push_args(ctx, arg);
5416 * Three arguments (ctx->args) are retrieved from the stack to store data,
5417 * its actual length and address (in that order).
5420 parse_string(struct context *ctx, const struct token *token,
5421 const char *str, unsigned int len,
5422 void *buf, unsigned int size)
5424 const struct arg *arg_data = pop_args(ctx);
5425 const struct arg *arg_len = pop_args(ctx);
5426 const struct arg *arg_addr = pop_args(ctx);
5427 char tmp[16]; /* Ought to be enough. */
5430 /* Arguments are expected. */
5434 push_args(ctx, arg_data);
5438 push_args(ctx, arg_len);
5439 push_args(ctx, arg_data);
5442 size = arg_data->size;
5443 /* Bit-mask fill is not supported. */
5444 if (arg_data->mask || size < len)
5448 /* Let parse_int() fill length information first. */
5449 ret = snprintf(tmp, sizeof(tmp), "%u", len);
5452 push_args(ctx, arg_len);
5453 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
5458 buf = (uint8_t *)ctx->object + arg_data->offset;
5459 /* Output buffer is not necessarily NUL-terminated. */
5460 memcpy(buf, str, len);
5461 memset((uint8_t *)buf + len, 0x00, size - len);
5463 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
5464 /* Save address if requested. */
5465 if (arg_addr->size) {
5466 memcpy((uint8_t *)ctx->object + arg_addr->offset,
5468 (uint8_t *)ctx->object + arg_data->offset
5472 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
5474 (uint8_t *)ctx->objmask + arg_data->offset
5480 push_args(ctx, arg_addr);
5481 push_args(ctx, arg_len);
5482 push_args(ctx, arg_data);
5487 parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
5493 /* Check input parameters */
5494 if ((src == NULL) ||
5500 /* Convert chars to bytes */
5501 for (i = 0, len = 0; i < *size; i += 2) {
5502 snprintf(tmp, 3, "%s", src + i);
5503 dst[len++] = strtoul(tmp, &c, 16);
5518 parse_hex(struct context *ctx, const struct token *token,
5519 const char *str, unsigned int len,
5520 void *buf, unsigned int size)
5522 const struct arg *arg_data = pop_args(ctx);
5523 const struct arg *arg_len = pop_args(ctx);
5524 const struct arg *arg_addr = pop_args(ctx);
5525 char tmp[16]; /* Ought to be enough. */
5527 unsigned int hexlen = len;
5528 unsigned int length = 256;
5529 uint8_t hex_tmp[length];
5531 /* Arguments are expected. */
5535 push_args(ctx, arg_data);
5539 push_args(ctx, arg_len);
5540 push_args(ctx, arg_data);
5543 size = arg_data->size;
5544 /* Bit-mask fill is not supported. */
5550 /* translate bytes string to array. */
5551 if (str[0] == '0' && ((str[1] == 'x') ||
5556 if (hexlen > length)
5558 ret = parse_hex_string(str, hex_tmp, &hexlen);
5561 /* Let parse_int() fill length information first. */
5562 ret = snprintf(tmp, sizeof(tmp), "%u", hexlen);
5565 push_args(ctx, arg_len);
5566 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
5571 buf = (uint8_t *)ctx->object + arg_data->offset;
5572 /* Output buffer is not necessarily NUL-terminated. */
5573 memcpy(buf, hex_tmp, hexlen);
5574 memset((uint8_t *)buf + hexlen, 0x00, size - hexlen);
5576 memset((uint8_t *)ctx->objmask + arg_data->offset,
5578 /* Save address if requested. */
5579 if (arg_addr->size) {
5580 memcpy((uint8_t *)ctx->object + arg_addr->offset,
5582 (uint8_t *)ctx->object + arg_data->offset
5586 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
5588 (uint8_t *)ctx->objmask + arg_data->offset
5594 push_args(ctx, arg_addr);
5595 push_args(ctx, arg_len);
5596 push_args(ctx, arg_data);
5602 * Parse a zero-ended string.
5605 parse_string0(struct context *ctx, const struct token *token __rte_unused,
5606 const char *str, unsigned int len,
5607 void *buf, unsigned int size)
5609 const struct arg *arg_data = pop_args(ctx);
5611 /* Arguments are expected. */
5614 size = arg_data->size;
5615 /* Bit-mask fill is not supported. */
5616 if (arg_data->mask || size < len + 1)
5620 buf = (uint8_t *)ctx->object + arg_data->offset;
5621 strncpy(buf, str, len);
5623 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
5626 push_args(ctx, arg_data);
5631 * Parse a MAC address.
5633 * Last argument (ctx->args) is retrieved to determine storage size and
5637 parse_mac_addr(struct context *ctx, const struct token *token,
5638 const char *str, unsigned int len,
5639 void *buf, unsigned int size)
5641 const struct arg *arg = pop_args(ctx);
5642 struct rte_ether_addr tmp;
5646 /* Argument is expected. */
5650 /* Bit-mask fill is not supported. */
5651 if (arg->mask || size != sizeof(tmp))
5653 /* Only network endian is supported. */
5656 ret = cmdline_parse_etheraddr(NULL, str, &tmp, size);
5657 if (ret < 0 || (unsigned int)ret != len)
5661 buf = (uint8_t *)ctx->object + arg->offset;
5662 memcpy(buf, &tmp, size);
5664 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
5667 push_args(ctx, arg);
5672 * Parse an IPv4 address.
5674 * Last argument (ctx->args) is retrieved to determine storage size and
5678 parse_ipv4_addr(struct context *ctx, const struct token *token,
5679 const char *str, unsigned int len,
5680 void *buf, unsigned int size)
5682 const struct arg *arg = pop_args(ctx);
5687 /* Argument is expected. */
5691 /* Bit-mask fill is not supported. */
5692 if (arg->mask || size != sizeof(tmp))
5694 /* Only network endian is supported. */
5697 memcpy(str2, str, len);
5699 ret = inet_pton(AF_INET, str2, &tmp);
5701 /* Attempt integer parsing. */
5702 push_args(ctx, arg);
5703 return parse_int(ctx, token, str, len, buf, size);
5707 buf = (uint8_t *)ctx->object + arg->offset;
5708 memcpy(buf, &tmp, size);
5710 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
5713 push_args(ctx, arg);
5718 * Parse an IPv6 address.
5720 * Last argument (ctx->args) is retrieved to determine storage size and
5724 parse_ipv6_addr(struct context *ctx, const struct token *token,
5725 const char *str, unsigned int len,
5726 void *buf, unsigned int size)
5728 const struct arg *arg = pop_args(ctx);
5730 struct in6_addr tmp;
5734 /* Argument is expected. */
5738 /* Bit-mask fill is not supported. */
5739 if (arg->mask || size != sizeof(tmp))
5741 /* Only network endian is supported. */
5744 memcpy(str2, str, len);
5746 ret = inet_pton(AF_INET6, str2, &tmp);
5751 buf = (uint8_t *)ctx->object + arg->offset;
5752 memcpy(buf, &tmp, size);
5754 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
5757 push_args(ctx, arg);
5761 /** Boolean values (even indices stand for false). */
5762 static const char *const boolean_name[] = {
5772 * Parse a boolean value.
5774 * Last argument (ctx->args) is retrieved to determine storage size and
5778 parse_boolean(struct context *ctx, const struct token *token,
5779 const char *str, unsigned int len,
5780 void *buf, unsigned int size)
5782 const struct arg *arg = pop_args(ctx);
5786 /* Argument is expected. */
5789 for (i = 0; boolean_name[i]; ++i)
5790 if (!strcmp_partial(boolean_name[i], str, len))
5792 /* Process token as integer. */
5793 if (boolean_name[i])
5794 str = i & 1 ? "1" : "0";
5795 push_args(ctx, arg);
5796 ret = parse_int(ctx, token, str, strlen(str), buf, size);
5797 return ret > 0 ? (int)len : ret;
5800 /** Parse port and update context. */
5802 parse_port(struct context *ctx, const struct token *token,
5803 const char *str, unsigned int len,
5804 void *buf, unsigned int size)
5806 struct buffer *out = &(struct buffer){ .port = 0 };
5814 ctx->objmask = NULL;
5815 size = sizeof(*out);
5817 ret = parse_int(ctx, token, str, len, out, size);
5819 ctx->port = out->port;
5825 /** Parse set command, initialize output buffer for subsequent tokens. */
5827 parse_set_raw_encap_decap(struct context *ctx, const struct token *token,
5828 const char *str, unsigned int len,
5829 void *buf, unsigned int size)
5831 struct buffer *out = buf;
5833 /* Token name must match. */
5834 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5836 /* Nothing else to do if there is no buffer. */
5839 /* Make sure buffer is large enough. */
5840 if (size < sizeof(*out))
5843 ctx->objmask = NULL;
5847 out->command = ctx->curr;
5852 * Parse set raw_encap/raw_decap command,
5853 * initialize output buffer for subsequent tokens.
5856 parse_set_init(struct context *ctx, const struct token *token,
5857 const char *str, unsigned int len,
5858 void *buf, unsigned int size)
5860 struct buffer *out = buf;
5862 /* Token name must match. */
5863 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5865 /* Nothing else to do if there is no buffer. */
5868 /* Make sure buffer is large enough. */
5869 if (size < sizeof(*out))
5871 /* Initialize buffer. */
5872 memset(out, 0x00, sizeof(*out));
5873 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
5876 ctx->objmask = NULL;
5877 if (!out->command) {
5878 if (ctx->curr != SET)
5880 if (sizeof(*out) > size)
5882 out->command = ctx->curr;
5883 out->args.vc.data = (uint8_t *)out + size;
5884 /* All we need is pattern */
5885 out->args.vc.pattern =
5886 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5888 ctx->object = out->args.vc.pattern;
5893 /** No completion. */
5895 comp_none(struct context *ctx, const struct token *token,
5896 unsigned int ent, char *buf, unsigned int size)
5906 /** Complete boolean values. */
5908 comp_boolean(struct context *ctx, const struct token *token,
5909 unsigned int ent, char *buf, unsigned int size)
5915 for (i = 0; boolean_name[i]; ++i)
5916 if (buf && i == ent)
5917 return strlcpy(buf, boolean_name[i], size);
5923 /** Complete action names. */
5925 comp_action(struct context *ctx, const struct token *token,
5926 unsigned int ent, char *buf, unsigned int size)
5932 for (i = 0; next_action[i]; ++i)
5933 if (buf && i == ent)
5934 return strlcpy(buf, token_list[next_action[i]].name,
5941 /** Complete available ports. */
5943 comp_port(struct context *ctx, const struct token *token,
5944 unsigned int ent, char *buf, unsigned int size)
5951 RTE_ETH_FOREACH_DEV(p) {
5952 if (buf && i == ent)
5953 return snprintf(buf, size, "%u", p);
5961 /** Complete available rule IDs. */
5963 comp_rule_id(struct context *ctx, const struct token *token,
5964 unsigned int ent, char *buf, unsigned int size)
5967 struct rte_port *port;
5968 struct port_flow *pf;
5971 if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
5972 ctx->port == (portid_t)RTE_PORT_ALL)
5974 port = &ports[ctx->port];
5975 for (pf = port->flow_list; pf != NULL; pf = pf->next) {
5976 if (buf && i == ent)
5977 return snprintf(buf, size, "%u", pf->id);
5985 /** Complete type field for RSS action. */
5987 comp_vc_action_rss_type(struct context *ctx, const struct token *token,
5988 unsigned int ent, char *buf, unsigned int size)
5994 for (i = 0; rss_type_table[i].str; ++i)
5999 return strlcpy(buf, rss_type_table[ent].str, size);
6001 return snprintf(buf, size, "end");
6005 /** Complete queue field for RSS action. */
6007 comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
6008 unsigned int ent, char *buf, unsigned int size)
6015 return snprintf(buf, size, "%u", ent);
6017 return snprintf(buf, size, "end");
6021 /** Complete index number for set raw_encap/raw_decap commands. */
6023 comp_set_raw_index(struct context *ctx, const struct token *token,
6024 unsigned int ent, char *buf, unsigned int size)
6030 RTE_SET_USED(token);
6031 for (idx = 0; idx < RAW_ENCAP_CONFS_MAX_NUM; ++idx) {
6032 if (buf && idx == ent)
6033 return snprintf(buf, size, "%u", idx);
6039 /** Internal context. */
6040 static struct context cmd_flow_context;
6042 /** Global parser instance (cmdline API). */
6043 cmdline_parse_inst_t cmd_flow;
6044 cmdline_parse_inst_t cmd_set_raw;
6046 /** Initialize context. */
6048 cmd_flow_context_init(struct context *ctx)
6050 /* A full memset() is not necessary. */
6060 ctx->objmask = NULL;
6063 /** Parse a token (cmdline API). */
6065 cmd_flow_parse(cmdline_parse_token_hdr_t *hdr, const char *src, void *result,
6068 struct context *ctx = &cmd_flow_context;
6069 const struct token *token;
6070 const enum index *list;
6075 token = &token_list[ctx->curr];
6076 /* Check argument length. */
6079 for (len = 0; src[len]; ++len)
6080 if (src[len] == '#' || isspace(src[len]))
6084 /* Last argument and EOL detection. */
6085 for (i = len; src[i]; ++i)
6086 if (src[i] == '#' || src[i] == '\r' || src[i] == '\n')
6088 else if (!isspace(src[i])) {
6093 if (src[i] == '\r' || src[i] == '\n') {
6097 /* Initialize context if necessary. */
6098 if (!ctx->next_num) {
6101 ctx->next[ctx->next_num++] = token->next[0];
6103 /* Process argument through candidates. */
6104 ctx->prev = ctx->curr;
6105 list = ctx->next[ctx->next_num - 1];
6106 for (i = 0; list[i]; ++i) {
6107 const struct token *next = &token_list[list[i]];
6110 ctx->curr = list[i];
6112 tmp = next->call(ctx, next, src, len, result, size);
6114 tmp = parse_default(ctx, next, src, len, result, size);
6115 if (tmp == -1 || tmp != len)
6123 /* Push subsequent tokens if any. */
6125 for (i = 0; token->next[i]; ++i) {
6126 if (ctx->next_num == RTE_DIM(ctx->next))
6128 ctx->next[ctx->next_num++] = token->next[i];
6130 /* Push arguments if any. */
6132 for (i = 0; token->args[i]; ++i) {
6133 if (ctx->args_num == RTE_DIM(ctx->args))
6135 ctx->args[ctx->args_num++] = token->args[i];
6140 /** Return number of completion entries (cmdline API). */
6142 cmd_flow_complete_get_nb(cmdline_parse_token_hdr_t *hdr)
6144 struct context *ctx = &cmd_flow_context;
6145 const struct token *token = &token_list[ctx->curr];
6146 const enum index *list;
6150 /* Count number of tokens in current list. */
6152 list = ctx->next[ctx->next_num - 1];
6154 list = token->next[0];
6155 for (i = 0; list[i]; ++i)
6160 * If there is a single token, use its completion callback, otherwise
6161 * return the number of entries.
6163 token = &token_list[list[0]];
6164 if (i == 1 && token->comp) {
6165 /* Save index for cmd_flow_get_help(). */
6166 ctx->prev = list[0];
6167 return token->comp(ctx, token, 0, NULL, 0);
6172 /** Return a completion entry (cmdline API). */
6174 cmd_flow_complete_get_elt(cmdline_parse_token_hdr_t *hdr, int index,
6175 char *dst, unsigned int size)
6177 struct context *ctx = &cmd_flow_context;
6178 const struct token *token = &token_list[ctx->curr];
6179 const enum index *list;
6183 /* Count number of tokens in current list. */
6185 list = ctx->next[ctx->next_num - 1];
6187 list = token->next[0];
6188 for (i = 0; list[i]; ++i)
6192 /* If there is a single token, use its completion callback. */
6193 token = &token_list[list[0]];
6194 if (i == 1 && token->comp) {
6195 /* Save index for cmd_flow_get_help(). */
6196 ctx->prev = list[0];
6197 return token->comp(ctx, token, index, dst, size) < 0 ? -1 : 0;
6199 /* Otherwise make sure the index is valid and use defaults. */
6202 token = &token_list[list[index]];
6203 strlcpy(dst, token->name, size);
6204 /* Save index for cmd_flow_get_help(). */
6205 ctx->prev = list[index];
6209 /** Populate help strings for current token (cmdline API). */
6211 cmd_flow_get_help(cmdline_parse_token_hdr_t *hdr, char *dst, unsigned int size)
6213 struct context *ctx = &cmd_flow_context;
6214 const struct token *token = &token_list[ctx->prev];
6219 /* Set token type and update global help with details. */
6220 strlcpy(dst, (token->type ? token->type : "TOKEN"), size);
6222 cmd_flow.help_str = token->help;
6224 cmd_flow.help_str = token->name;
6228 /** Token definition template (cmdline API). */
6229 static struct cmdline_token_hdr cmd_flow_token_hdr = {
6230 .ops = &(struct cmdline_token_ops){
6231 .parse = cmd_flow_parse,
6232 .complete_get_nb = cmd_flow_complete_get_nb,
6233 .complete_get_elt = cmd_flow_complete_get_elt,
6234 .get_help = cmd_flow_get_help,
6239 /** Populate the next dynamic token. */
6241 cmd_flow_tok(cmdline_parse_token_hdr_t **hdr,
6242 cmdline_parse_token_hdr_t **hdr_inst)
6244 struct context *ctx = &cmd_flow_context;
6246 /* Always reinitialize context before requesting the first token. */
6247 if (!(hdr_inst - cmd_flow.tokens))
6248 cmd_flow_context_init(ctx);
6249 /* Return NULL when no more tokens are expected. */
6250 if (!ctx->next_num && ctx->curr) {
6254 /* Determine if command should end here. */
6255 if (ctx->eol && ctx->last && ctx->next_num) {
6256 const enum index *list = ctx->next[ctx->next_num - 1];
6259 for (i = 0; list[i]; ++i) {
6266 *hdr = &cmd_flow_token_hdr;
6269 /** Dispatch parsed buffer to function calls. */
6271 cmd_flow_parsed(const struct buffer *in)
6273 switch (in->command) {
6275 port_flow_validate(in->port, &in->args.vc.attr,
6276 in->args.vc.pattern, in->args.vc.actions);
6279 port_flow_create(in->port, &in->args.vc.attr,
6280 in->args.vc.pattern, in->args.vc.actions);
6283 port_flow_destroy(in->port, in->args.destroy.rule_n,
6284 in->args.destroy.rule);
6287 port_flow_flush(in->port);
6290 port_flow_dump(in->port, in->args.dump.file);
6293 port_flow_query(in->port, in->args.query.rule,
6294 &in->args.query.action);
6297 port_flow_list(in->port, in->args.list.group_n,
6298 in->args.list.group);
6301 port_flow_isolate(in->port, in->args.isolate.set);
6308 /** Token generator and output processing callback (cmdline API). */
6310 cmd_flow_cb(void *arg0, struct cmdline *cl, void *arg2)
6313 cmd_flow_tok(arg0, arg2);
6315 cmd_flow_parsed(arg0);
6318 /** Global parser instance (cmdline API). */
6319 cmdline_parse_inst_t cmd_flow = {
6321 .data = NULL, /**< Unused. */
6322 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
6325 }, /**< Tokens are returned by cmd_flow_tok(). */
6328 /** set cmd facility. Reuse cmd flow's infrastructure as much as possible. */
6331 update_fields(uint8_t *buf, struct rte_flow_item *item, uint16_t next_proto)
6333 struct rte_flow_item_ipv4 *ipv4;
6334 struct rte_flow_item_eth *eth;
6335 struct rte_flow_item_ipv6 *ipv6;
6336 struct rte_flow_item_vxlan *vxlan;
6337 struct rte_flow_item_vxlan_gpe *gpe;
6338 struct rte_flow_item_nvgre *nvgre;
6339 uint32_t ipv6_vtc_flow;
6341 switch (item->type) {
6342 case RTE_FLOW_ITEM_TYPE_ETH:
6343 eth = (struct rte_flow_item_eth *)buf;
6345 eth->type = rte_cpu_to_be_16(next_proto);
6347 case RTE_FLOW_ITEM_TYPE_IPV4:
6348 ipv4 = (struct rte_flow_item_ipv4 *)buf;
6349 ipv4->hdr.version_ihl = 0x45;
6350 if (next_proto && ipv4->hdr.next_proto_id == 0)
6351 ipv4->hdr.next_proto_id = (uint8_t)next_proto;
6353 case RTE_FLOW_ITEM_TYPE_IPV6:
6354 ipv6 = (struct rte_flow_item_ipv6 *)buf;
6355 if (next_proto && ipv6->hdr.proto == 0)
6356 ipv6->hdr.proto = (uint8_t)next_proto;
6357 ipv6_vtc_flow = rte_be_to_cpu_32(ipv6->hdr.vtc_flow);
6358 ipv6_vtc_flow &= 0x0FFFFFFF; /*< reset version bits. */
6359 ipv6_vtc_flow |= 0x60000000; /*< set ipv6 version. */
6360 ipv6->hdr.vtc_flow = rte_cpu_to_be_32(ipv6_vtc_flow);
6362 case RTE_FLOW_ITEM_TYPE_VXLAN:
6363 vxlan = (struct rte_flow_item_vxlan *)buf;
6364 vxlan->flags = 0x08;
6366 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
6367 gpe = (struct rte_flow_item_vxlan_gpe *)buf;
6370 case RTE_FLOW_ITEM_TYPE_NVGRE:
6371 nvgre = (struct rte_flow_item_nvgre *)buf;
6372 nvgre->protocol = rte_cpu_to_be_16(0x6558);
6373 nvgre->c_k_s_rsvd0_ver = rte_cpu_to_be_16(0x2000);
6380 /** Helper of get item's default mask. */
6382 flow_item_default_mask(const struct rte_flow_item *item)
6384 const void *mask = NULL;
6385 static rte_be32_t gre_key_default_mask = RTE_BE32(UINT32_MAX);
6387 switch (item->type) {
6388 case RTE_FLOW_ITEM_TYPE_ANY:
6389 mask = &rte_flow_item_any_mask;
6391 case RTE_FLOW_ITEM_TYPE_VF:
6392 mask = &rte_flow_item_vf_mask;
6394 case RTE_FLOW_ITEM_TYPE_PORT_ID:
6395 mask = &rte_flow_item_port_id_mask;
6397 case RTE_FLOW_ITEM_TYPE_RAW:
6398 mask = &rte_flow_item_raw_mask;
6400 case RTE_FLOW_ITEM_TYPE_ETH:
6401 mask = &rte_flow_item_eth_mask;
6403 case RTE_FLOW_ITEM_TYPE_VLAN:
6404 mask = &rte_flow_item_vlan_mask;
6406 case RTE_FLOW_ITEM_TYPE_IPV4:
6407 mask = &rte_flow_item_ipv4_mask;
6409 case RTE_FLOW_ITEM_TYPE_IPV6:
6410 mask = &rte_flow_item_ipv6_mask;
6412 case RTE_FLOW_ITEM_TYPE_ICMP:
6413 mask = &rte_flow_item_icmp_mask;
6415 case RTE_FLOW_ITEM_TYPE_UDP:
6416 mask = &rte_flow_item_udp_mask;
6418 case RTE_FLOW_ITEM_TYPE_TCP:
6419 mask = &rte_flow_item_tcp_mask;
6421 case RTE_FLOW_ITEM_TYPE_SCTP:
6422 mask = &rte_flow_item_sctp_mask;
6424 case RTE_FLOW_ITEM_TYPE_VXLAN:
6425 mask = &rte_flow_item_vxlan_mask;
6427 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
6428 mask = &rte_flow_item_vxlan_gpe_mask;
6430 case RTE_FLOW_ITEM_TYPE_E_TAG:
6431 mask = &rte_flow_item_e_tag_mask;
6433 case RTE_FLOW_ITEM_TYPE_NVGRE:
6434 mask = &rte_flow_item_nvgre_mask;
6436 case RTE_FLOW_ITEM_TYPE_MPLS:
6437 mask = &rte_flow_item_mpls_mask;
6439 case RTE_FLOW_ITEM_TYPE_GRE:
6440 mask = &rte_flow_item_gre_mask;
6442 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
6443 mask = &gre_key_default_mask;
6445 case RTE_FLOW_ITEM_TYPE_META:
6446 mask = &rte_flow_item_meta_mask;
6448 case RTE_FLOW_ITEM_TYPE_FUZZY:
6449 mask = &rte_flow_item_fuzzy_mask;
6451 case RTE_FLOW_ITEM_TYPE_GTP:
6452 mask = &rte_flow_item_gtp_mask;
6454 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
6455 mask = &rte_flow_item_gtp_psc_mask;
6457 case RTE_FLOW_ITEM_TYPE_GENEVE:
6458 mask = &rte_flow_item_geneve_mask;
6460 case RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID:
6461 mask = &rte_flow_item_pppoe_proto_id_mask;
6463 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
6464 mask = &rte_flow_item_l2tpv3oip_mask;
6466 case RTE_FLOW_ITEM_TYPE_ESP:
6467 mask = &rte_flow_item_esp_mask;
6469 case RTE_FLOW_ITEM_TYPE_AH:
6470 mask = &rte_flow_item_ah_mask;
6480 /** Dispatch parsed buffer to function calls. */
6482 cmd_set_raw_parsed(const struct buffer *in)
6484 uint32_t n = in->args.vc.pattern_n;
6486 struct rte_flow_item *item = NULL;
6488 uint8_t *data = NULL;
6489 uint8_t *data_tail = NULL;
6490 size_t *total_size = NULL;
6491 uint16_t upper_layer = 0;
6493 uint16_t idx = in->port; /* We borrow port field as index */
6495 RTE_ASSERT(in->command == SET_RAW_ENCAP ||
6496 in->command == SET_RAW_DECAP);
6497 if (in->command == SET_RAW_ENCAP) {
6498 total_size = &raw_encap_confs[idx].size;
6499 data = (uint8_t *)&raw_encap_confs[idx].data;
6501 total_size = &raw_decap_confs[idx].size;
6502 data = (uint8_t *)&raw_decap_confs[idx].data;
6505 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
6506 /* process hdr from upper layer to low layer (L3/L4 -> L2). */
6507 data_tail = data + ACTION_RAW_ENCAP_MAX_DATA;
6508 for (i = n - 1 ; i >= 0; --i) {
6509 item = in->args.vc.pattern + i;
6510 if (item->spec == NULL)
6511 item->spec = flow_item_default_mask(item);
6512 switch (item->type) {
6513 case RTE_FLOW_ITEM_TYPE_ETH:
6514 size = sizeof(struct rte_flow_item_eth);
6516 case RTE_FLOW_ITEM_TYPE_VLAN:
6517 size = sizeof(struct rte_flow_item_vlan);
6518 proto = RTE_ETHER_TYPE_VLAN;
6520 case RTE_FLOW_ITEM_TYPE_IPV4:
6521 size = sizeof(struct rte_flow_item_ipv4);
6522 proto = RTE_ETHER_TYPE_IPV4;
6524 case RTE_FLOW_ITEM_TYPE_IPV6:
6525 size = sizeof(struct rte_flow_item_ipv6);
6526 proto = RTE_ETHER_TYPE_IPV6;
6528 case RTE_FLOW_ITEM_TYPE_UDP:
6529 size = sizeof(struct rte_flow_item_udp);
6532 case RTE_FLOW_ITEM_TYPE_TCP:
6533 size = sizeof(struct rte_flow_item_tcp);
6536 case RTE_FLOW_ITEM_TYPE_VXLAN:
6537 size = sizeof(struct rte_flow_item_vxlan);
6539 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
6540 size = sizeof(struct rte_flow_item_vxlan_gpe);
6542 case RTE_FLOW_ITEM_TYPE_GRE:
6543 size = sizeof(struct rte_flow_item_gre);
6546 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
6547 size = sizeof(rte_be32_t);
6550 case RTE_FLOW_ITEM_TYPE_MPLS:
6551 size = sizeof(struct rte_flow_item_mpls);
6554 case RTE_FLOW_ITEM_TYPE_NVGRE:
6555 size = sizeof(struct rte_flow_item_nvgre);
6558 case RTE_FLOW_ITEM_TYPE_GENEVE:
6559 size = sizeof(struct rte_flow_item_geneve);
6561 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
6562 size = sizeof(struct rte_flow_item_l2tpv3oip);
6565 case RTE_FLOW_ITEM_TYPE_ESP:
6566 size = sizeof(struct rte_flow_item_esp);
6569 case RTE_FLOW_ITEM_TYPE_AH:
6570 size = sizeof(struct rte_flow_item_ah);
6574 printf("Error - Not supported item\n");
6576 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
6579 *total_size += size;
6580 rte_memcpy(data_tail - (*total_size), item->spec, size);
6581 /* update some fields which cannot be set by cmdline */
6582 update_fields((data_tail - (*total_size)), item,
6584 upper_layer = proto;
6586 if (verbose_level & 0x1)
6587 printf("total data size is %zu\n", (*total_size));
6588 RTE_ASSERT((*total_size) <= ACTION_RAW_ENCAP_MAX_DATA);
6589 memmove(data, (data_tail - (*total_size)), *total_size);
6592 /** Populate help strings for current token (cmdline API). */
6594 cmd_set_raw_get_help(cmdline_parse_token_hdr_t *hdr, char *dst,
6597 struct context *ctx = &cmd_flow_context;
6598 const struct token *token = &token_list[ctx->prev];
6603 /* Set token type and update global help with details. */
6604 snprintf(dst, size, "%s", (token->type ? token->type : "TOKEN"));
6606 cmd_set_raw.help_str = token->help;
6608 cmd_set_raw.help_str = token->name;
6612 /** Token definition template (cmdline API). */
6613 static struct cmdline_token_hdr cmd_set_raw_token_hdr = {
6614 .ops = &(struct cmdline_token_ops){
6615 .parse = cmd_flow_parse,
6616 .complete_get_nb = cmd_flow_complete_get_nb,
6617 .complete_get_elt = cmd_flow_complete_get_elt,
6618 .get_help = cmd_set_raw_get_help,
6623 /** Populate the next dynamic token. */
6625 cmd_set_raw_tok(cmdline_parse_token_hdr_t **hdr,
6626 cmdline_parse_token_hdr_t **hdr_inst)
6628 struct context *ctx = &cmd_flow_context;
6630 /* Always reinitialize context before requesting the first token. */
6631 if (!(hdr_inst - cmd_set_raw.tokens)) {
6632 cmd_flow_context_init(ctx);
6633 ctx->curr = START_SET;
6635 /* Return NULL when no more tokens are expected. */
6636 if (!ctx->next_num && (ctx->curr != START_SET)) {
6640 /* Determine if command should end here. */
6641 if (ctx->eol && ctx->last && ctx->next_num) {
6642 const enum index *list = ctx->next[ctx->next_num - 1];
6645 for (i = 0; list[i]; ++i) {
6652 *hdr = &cmd_set_raw_token_hdr;
6655 /** Token generator and output processing callback (cmdline API). */
6657 cmd_set_raw_cb(void *arg0, struct cmdline *cl, void *arg2)
6660 cmd_set_raw_tok(arg0, arg2);
6662 cmd_set_raw_parsed(arg0);
6665 /** Global parser instance (cmdline API). */
6666 cmdline_parse_inst_t cmd_set_raw = {
6667 .f = cmd_set_raw_cb,
6668 .data = NULL, /**< Unused. */
6669 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
6672 }, /**< Tokens are returned by cmd_flow_tok(). */
6675 /* *** display raw_encap/raw_decap buf */
6676 struct cmd_show_set_raw_result {
6677 cmdline_fixed_string_t cmd_show;
6678 cmdline_fixed_string_t cmd_what;
6679 cmdline_fixed_string_t cmd_all;
6684 cmd_show_set_raw_parsed(void *parsed_result, struct cmdline *cl, void *data)
6686 struct cmd_show_set_raw_result *res = parsed_result;
6687 uint16_t index = res->cmd_index;
6689 uint8_t *raw_data = NULL;
6690 size_t raw_size = 0;
6691 char title[16] = {0};
6695 if (!strcmp(res->cmd_all, "all")) {
6698 } else if (index >= RAW_ENCAP_CONFS_MAX_NUM) {
6699 printf("index should be 0-%u\n", RAW_ENCAP_CONFS_MAX_NUM - 1);
6703 if (!strcmp(res->cmd_what, "raw_encap")) {
6704 raw_data = (uint8_t *)&raw_encap_confs[index].data;
6705 raw_size = raw_encap_confs[index].size;
6706 snprintf(title, 16, "\nindex: %u", index);
6707 rte_hexdump(stdout, title, raw_data, raw_size);
6709 raw_data = (uint8_t *)&raw_decap_confs[index].data;
6710 raw_size = raw_decap_confs[index].size;
6711 snprintf(title, 16, "\nindex: %u", index);
6712 rte_hexdump(stdout, title, raw_data, raw_size);
6714 } while (all && ++index < RAW_ENCAP_CONFS_MAX_NUM);
6717 cmdline_parse_token_string_t cmd_show_set_raw_cmd_show =
6718 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
6720 cmdline_parse_token_string_t cmd_show_set_raw_cmd_what =
6721 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
6722 cmd_what, "raw_encap#raw_decap");
6723 cmdline_parse_token_num_t cmd_show_set_raw_cmd_index =
6724 TOKEN_NUM_INITIALIZER(struct cmd_show_set_raw_result,
6726 cmdline_parse_token_string_t cmd_show_set_raw_cmd_all =
6727 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
6729 cmdline_parse_inst_t cmd_show_set_raw = {
6730 .f = cmd_show_set_raw_parsed,
6732 .help_str = "show <raw_encap|raw_decap> <index>",
6734 (void *)&cmd_show_set_raw_cmd_show,
6735 (void *)&cmd_show_set_raw_cmd_what,
6736 (void *)&cmd_show_set_raw_cmd_index,
6740 cmdline_parse_inst_t cmd_show_set_raw_all = {
6741 .f = cmd_show_set_raw_parsed,
6743 .help_str = "show <raw_encap|raw_decap> all",
6745 (void *)&cmd_show_set_raw_cmd_show,
6746 (void *)&cmd_show_set_raw_cmd_what,
6747 (void *)&cmd_show_set_raw_cmd_all,