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,
224 /* Validate/create actions. */
244 ACTION_RSS_FUNC_DEFAULT,
245 ACTION_RSS_FUNC_TOEPLITZ,
246 ACTION_RSS_FUNC_SIMPLE_XOR,
247 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ,
259 ACTION_PHY_PORT_ORIGINAL,
260 ACTION_PHY_PORT_INDEX,
262 ACTION_PORT_ID_ORIGINAL,
266 ACTION_OF_SET_MPLS_TTL,
267 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
268 ACTION_OF_DEC_MPLS_TTL,
269 ACTION_OF_SET_NW_TTL,
270 ACTION_OF_SET_NW_TTL_NW_TTL,
271 ACTION_OF_DEC_NW_TTL,
272 ACTION_OF_COPY_TTL_OUT,
273 ACTION_OF_COPY_TTL_IN,
276 ACTION_OF_PUSH_VLAN_ETHERTYPE,
277 ACTION_OF_SET_VLAN_VID,
278 ACTION_OF_SET_VLAN_VID_VLAN_VID,
279 ACTION_OF_SET_VLAN_PCP,
280 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
282 ACTION_OF_POP_MPLS_ETHERTYPE,
284 ACTION_OF_PUSH_MPLS_ETHERTYPE,
291 ACTION_MPLSOGRE_ENCAP,
292 ACTION_MPLSOGRE_DECAP,
293 ACTION_MPLSOUDP_ENCAP,
294 ACTION_MPLSOUDP_DECAP,
296 ACTION_SET_IPV4_SRC_IPV4_SRC,
298 ACTION_SET_IPV4_DST_IPV4_DST,
300 ACTION_SET_IPV6_SRC_IPV6_SRC,
302 ACTION_SET_IPV6_DST_IPV6_DST,
304 ACTION_SET_TP_SRC_TP_SRC,
306 ACTION_SET_TP_DST_TP_DST,
312 ACTION_SET_MAC_SRC_MAC_SRC,
314 ACTION_SET_MAC_DST_MAC_DST,
316 ACTION_INC_TCP_SEQ_VALUE,
318 ACTION_DEC_TCP_SEQ_VALUE,
320 ACTION_INC_TCP_ACK_VALUE,
322 ACTION_DEC_TCP_ACK_VALUE,
325 ACTION_RAW_ENCAP_INDEX,
326 ACTION_RAW_ENCAP_INDEX_VALUE,
327 ACTION_RAW_DECAP_INDEX,
328 ACTION_RAW_DECAP_INDEX_VALUE,
331 ACTION_SET_TAG_INDEX,
334 ACTION_SET_META_DATA,
335 ACTION_SET_META_MASK,
336 ACTION_SET_IPV4_DSCP,
337 ACTION_SET_IPV4_DSCP_VALUE,
338 ACTION_SET_IPV6_DSCP,
339 ACTION_SET_IPV6_DSCP_VALUE,
342 /** Maximum size for pattern in struct rte_flow_item_raw. */
343 #define ITEM_RAW_PATTERN_SIZE 40
345 /** Storage size for struct rte_flow_item_raw including pattern. */
346 #define ITEM_RAW_SIZE \
347 (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE)
349 /** Maximum number of queue indices in struct rte_flow_action_rss. */
350 #define ACTION_RSS_QUEUE_NUM 128
352 /** Storage for struct rte_flow_action_rss including external data. */
353 struct action_rss_data {
354 struct rte_flow_action_rss conf;
355 uint8_t key[RSS_HASH_KEY_LENGTH];
356 uint16_t queue[ACTION_RSS_QUEUE_NUM];
359 /** Maximum data size in struct rte_flow_action_raw_encap. */
360 #define ACTION_RAW_ENCAP_MAX_DATA 128
361 #define RAW_ENCAP_CONFS_MAX_NUM 8
363 /** Storage for struct rte_flow_action_raw_encap. */
364 struct raw_encap_conf {
365 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
366 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
370 struct raw_encap_conf raw_encap_confs[RAW_ENCAP_CONFS_MAX_NUM];
372 /** Storage for struct rte_flow_action_raw_encap including external data. */
373 struct action_raw_encap_data {
374 struct rte_flow_action_raw_encap conf;
375 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
376 uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
380 /** Storage for struct rte_flow_action_raw_decap. */
381 struct raw_decap_conf {
382 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
386 struct raw_decap_conf raw_decap_confs[RAW_ENCAP_CONFS_MAX_NUM];
388 /** Storage for struct rte_flow_action_raw_decap including external data. */
389 struct action_raw_decap_data {
390 struct rte_flow_action_raw_decap conf;
391 uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
395 struct vxlan_encap_conf vxlan_encap_conf = {
399 .vni = "\x00\x00\x00",
401 .udp_dst = RTE_BE16(4789),
402 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
403 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
404 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
405 "\x00\x00\x00\x00\x00\x00\x00\x01",
406 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
407 "\x00\x00\x00\x00\x00\x00\x11\x11",
411 .eth_src = "\x00\x00\x00\x00\x00\x00",
412 .eth_dst = "\xff\xff\xff\xff\xff\xff",
415 /** Maximum number of items in struct rte_flow_action_vxlan_encap. */
416 #define ACTION_VXLAN_ENCAP_ITEMS_NUM 6
418 /** Storage for struct rte_flow_action_vxlan_encap including external data. */
419 struct action_vxlan_encap_data {
420 struct rte_flow_action_vxlan_encap conf;
421 struct rte_flow_item items[ACTION_VXLAN_ENCAP_ITEMS_NUM];
422 struct rte_flow_item_eth item_eth;
423 struct rte_flow_item_vlan item_vlan;
425 struct rte_flow_item_ipv4 item_ipv4;
426 struct rte_flow_item_ipv6 item_ipv6;
428 struct rte_flow_item_udp item_udp;
429 struct rte_flow_item_vxlan item_vxlan;
432 struct nvgre_encap_conf nvgre_encap_conf = {
435 .tni = "\x00\x00\x00",
436 .ipv4_src = RTE_IPV4(127, 0, 0, 1),
437 .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
438 .ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
439 "\x00\x00\x00\x00\x00\x00\x00\x01",
440 .ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
441 "\x00\x00\x00\x00\x00\x00\x11\x11",
443 .eth_src = "\x00\x00\x00\x00\x00\x00",
444 .eth_dst = "\xff\xff\xff\xff\xff\xff",
447 /** Maximum number of items in struct rte_flow_action_nvgre_encap. */
448 #define ACTION_NVGRE_ENCAP_ITEMS_NUM 5
450 /** Storage for struct rte_flow_action_nvgre_encap including external data. */
451 struct action_nvgre_encap_data {
452 struct rte_flow_action_nvgre_encap conf;
453 struct rte_flow_item items[ACTION_NVGRE_ENCAP_ITEMS_NUM];
454 struct rte_flow_item_eth item_eth;
455 struct rte_flow_item_vlan item_vlan;
457 struct rte_flow_item_ipv4 item_ipv4;
458 struct rte_flow_item_ipv6 item_ipv6;
460 struct rte_flow_item_nvgre item_nvgre;
463 struct l2_encap_conf l2_encap_conf;
465 struct l2_decap_conf l2_decap_conf;
467 struct mplsogre_encap_conf mplsogre_encap_conf;
469 struct mplsogre_decap_conf mplsogre_decap_conf;
471 struct mplsoudp_encap_conf mplsoudp_encap_conf;
473 struct mplsoudp_decap_conf mplsoudp_decap_conf;
475 /** Maximum number of subsequent tokens and arguments on the stack. */
476 #define CTX_STACK_SIZE 16
478 /** Parser context. */
480 /** Stack of subsequent token lists to process. */
481 const enum index *next[CTX_STACK_SIZE];
482 /** Arguments for stacked tokens. */
483 const void *args[CTX_STACK_SIZE];
484 enum index curr; /**< Current token index. */
485 enum index prev; /**< Index of the last token seen. */
486 int next_num; /**< Number of entries in next[]. */
487 int args_num; /**< Number of entries in args[]. */
488 uint32_t eol:1; /**< EOL has been detected. */
489 uint32_t last:1; /**< No more arguments. */
490 portid_t port; /**< Current port ID (for completions). */
491 uint32_t objdata; /**< Object-specific data. */
492 void *object; /**< Address of current object for relative offsets. */
493 void *objmask; /**< Object a full mask must be written to. */
496 /** Token argument. */
498 uint32_t hton:1; /**< Use network byte ordering. */
499 uint32_t sign:1; /**< Value is signed. */
500 uint32_t bounded:1; /**< Value is bounded. */
501 uintmax_t min; /**< Minimum value if bounded. */
502 uintmax_t max; /**< Maximum value if bounded. */
503 uint32_t offset; /**< Relative offset from ctx->object. */
504 uint32_t size; /**< Field size. */
505 const uint8_t *mask; /**< Bit-mask to use instead of offset/size. */
508 /** Parser token definition. */
510 /** Type displayed during completion (defaults to "TOKEN"). */
512 /** Help displayed during completion (defaults to token name). */
514 /** Private data used by parser functions. */
517 * Lists of subsequent tokens to push on the stack. Each call to the
518 * parser consumes the last entry of that stack.
520 const enum index *const *next;
521 /** Arguments stack for subsequent tokens that need them. */
522 const struct arg *const *args;
524 * Token-processing callback, returns -1 in case of error, the
525 * length of the matched string otherwise. If NULL, attempts to
526 * match the token name.
528 * If buf is not NULL, the result should be stored in it according
529 * to context. An error is returned if not large enough.
531 int (*call)(struct context *ctx, const struct token *token,
532 const char *str, unsigned int len,
533 void *buf, unsigned int size);
535 * Callback that provides possible values for this token, used for
536 * completion. Returns -1 in case of error, the number of possible
537 * values otherwise. If NULL, the token name is used.
539 * If buf is not NULL, entry index ent is written to buf and the
540 * full length of the entry is returned (same behavior as
543 int (*comp)(struct context *ctx, const struct token *token,
544 unsigned int ent, char *buf, unsigned int size);
545 /** Mandatory token name, no default value. */
549 /** Static initializer for the next field. */
550 #define NEXT(...) (const enum index *const []){ __VA_ARGS__, NULL, }
552 /** Static initializer for a NEXT() entry. */
553 #define NEXT_ENTRY(...) (const enum index []){ __VA_ARGS__, ZERO, }
555 /** Static initializer for the args field. */
556 #define ARGS(...) (const struct arg *const []){ __VA_ARGS__, NULL, }
558 /** Static initializer for ARGS() to target a field. */
559 #define ARGS_ENTRY(s, f) \
560 (&(const struct arg){ \
561 .offset = offsetof(s, f), \
562 .size = sizeof(((s *)0)->f), \
565 /** Static initializer for ARGS() to target a bit-field. */
566 #define ARGS_ENTRY_BF(s, f, b) \
567 (&(const struct arg){ \
569 .mask = (const void *)&(const s){ .f = (1 << (b)) - 1 }, \
572 /** Static initializer for ARGS() to target an arbitrary bit-mask. */
573 #define ARGS_ENTRY_MASK(s, f, m) \
574 (&(const struct arg){ \
575 .offset = offsetof(s, f), \
576 .size = sizeof(((s *)0)->f), \
577 .mask = (const void *)(m), \
580 /** Same as ARGS_ENTRY_MASK() using network byte ordering for the value. */
581 #define ARGS_ENTRY_MASK_HTON(s, f, m) \
582 (&(const struct arg){ \
584 .offset = offsetof(s, f), \
585 .size = sizeof(((s *)0)->f), \
586 .mask = (const void *)(m), \
589 /** Static initializer for ARGS() to target a pointer. */
590 #define ARGS_ENTRY_PTR(s, f) \
591 (&(const struct arg){ \
592 .size = sizeof(*((s *)0)->f), \
595 /** Static initializer for ARGS() with arbitrary offset and size. */
596 #define ARGS_ENTRY_ARB(o, s) \
597 (&(const struct arg){ \
602 /** Same as ARGS_ENTRY_ARB() with bounded values. */
603 #define ARGS_ENTRY_ARB_BOUNDED(o, s, i, a) \
604 (&(const struct arg){ \
612 /** Same as ARGS_ENTRY() using network byte ordering. */
613 #define ARGS_ENTRY_HTON(s, f) \
614 (&(const struct arg){ \
616 .offset = offsetof(s, f), \
617 .size = sizeof(((s *)0)->f), \
620 /** Same as ARGS_ENTRY_HTON() for a single argument, without structure. */
621 #define ARG_ENTRY_HTON(s) \
622 (&(const struct arg){ \
628 /** Parser output buffer layout expected by cmd_flow_parsed(). */
630 enum index command; /**< Flow command. */
631 portid_t port; /**< Affected port ID. */
634 struct rte_flow_attr attr;
635 struct rte_flow_item *pattern;
636 struct rte_flow_action *actions;
640 } vc; /**< Validate/create arguments. */
644 } destroy; /**< Destroy arguments. */
647 } dump; /**< Dump arguments. */
650 struct rte_flow_action action;
651 } query; /**< Query arguments. */
655 } list; /**< List arguments. */
658 } isolate; /**< Isolated mode arguments. */
659 } args; /**< Command arguments. */
662 /** Private data for pattern items. */
663 struct parse_item_priv {
664 enum rte_flow_item_type type; /**< Item type. */
665 uint32_t size; /**< Size of item specification structure. */
668 #define PRIV_ITEM(t, s) \
669 (&(const struct parse_item_priv){ \
670 .type = RTE_FLOW_ITEM_TYPE_ ## t, \
674 /** Private data for actions. */
675 struct parse_action_priv {
676 enum rte_flow_action_type type; /**< Action type. */
677 uint32_t size; /**< Size of action configuration structure. */
680 #define PRIV_ACTION(t, s) \
681 (&(const struct parse_action_priv){ \
682 .type = RTE_FLOW_ACTION_TYPE_ ## t, \
686 static const enum index next_vc_attr[] = {
696 static const enum index next_destroy_attr[] = {
702 static const enum index next_dump_attr[] = {
708 static const enum index next_list_attr[] = {
714 static const enum index item_param[] = {
723 static const enum index next_item[] = {
759 ITEM_ICMP6_ND_OPT_SLA_ETH,
760 ITEM_ICMP6_ND_OPT_TLA_ETH,
775 static const enum index item_fuzzy[] = {
781 static const enum index item_any[] = {
787 static const enum index item_vf[] = {
793 static const enum index item_phy_port[] = {
799 static const enum index item_port_id[] = {
805 static const enum index item_mark[] = {
811 static const enum index item_raw[] = {
821 static const enum index item_eth[] = {
829 static const enum index item_vlan[] = {
834 ITEM_VLAN_INNER_TYPE,
839 static const enum index item_ipv4[] = {
849 static const enum index item_ipv6[] = {
860 static const enum index item_icmp[] = {
867 static const enum index item_udp[] = {
874 static const enum index item_tcp[] = {
882 static const enum index item_sctp[] = {
891 static const enum index item_vxlan[] = {
897 static const enum index item_e_tag[] = {
898 ITEM_E_TAG_GRP_ECID_B,
903 static const enum index item_nvgre[] = {
909 static const enum index item_mpls[] = {
917 static const enum index item_gre[] = {
919 ITEM_GRE_C_RSVD0_VER,
927 static const enum index item_gre_key[] = {
933 static const enum index item_gtp[] = {
940 static const enum index item_geneve[] = {
947 static const enum index item_vxlan_gpe[] = {
953 static const enum index item_arp_eth_ipv4[] = {
954 ITEM_ARP_ETH_IPV4_SHA,
955 ITEM_ARP_ETH_IPV4_SPA,
956 ITEM_ARP_ETH_IPV4_THA,
957 ITEM_ARP_ETH_IPV4_TPA,
962 static const enum index item_ipv6_ext[] = {
963 ITEM_IPV6_EXT_NEXT_HDR,
968 static const enum index item_icmp6[] = {
975 static const enum index item_icmp6_nd_ns[] = {
976 ITEM_ICMP6_ND_NS_TARGET_ADDR,
981 static const enum index item_icmp6_nd_na[] = {
982 ITEM_ICMP6_ND_NA_TARGET_ADDR,
987 static const enum index item_icmp6_nd_opt[] = {
988 ITEM_ICMP6_ND_OPT_TYPE,
993 static const enum index item_icmp6_nd_opt_sla_eth[] = {
994 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
999 static const enum index item_icmp6_nd_opt_tla_eth[] = {
1000 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
1005 static const enum index item_meta[] = {
1011 static const enum index item_gtp_psc[] = {
1018 static const enum index item_pppoed[] = {
1024 static const enum index item_pppoes[] = {
1030 static const enum index item_pppoe_proto_id[] = {
1031 ITEM_PPPOE_PROTO_ID,
1036 static const enum index item_higig2[] = {
1037 ITEM_HIGIG2_CLASSIFICATION,
1043 static const enum index item_esp[] = {
1049 static const enum index next_set_raw[] = {
1055 static const enum index item_tag[] = {
1062 static const enum index item_l2tpv3oip[] = {
1063 ITEM_L2TPV3OIP_SESSION_ID,
1068 static const enum index next_action[] = {
1084 ACTION_OF_SET_MPLS_TTL,
1085 ACTION_OF_DEC_MPLS_TTL,
1086 ACTION_OF_SET_NW_TTL,
1087 ACTION_OF_DEC_NW_TTL,
1088 ACTION_OF_COPY_TTL_OUT,
1089 ACTION_OF_COPY_TTL_IN,
1091 ACTION_OF_PUSH_VLAN,
1092 ACTION_OF_SET_VLAN_VID,
1093 ACTION_OF_SET_VLAN_PCP,
1095 ACTION_OF_PUSH_MPLS,
1102 ACTION_MPLSOGRE_ENCAP,
1103 ACTION_MPLSOGRE_DECAP,
1104 ACTION_MPLSOUDP_ENCAP,
1105 ACTION_MPLSOUDP_DECAP,
1106 ACTION_SET_IPV4_SRC,
1107 ACTION_SET_IPV4_DST,
1108 ACTION_SET_IPV6_SRC,
1109 ACTION_SET_IPV6_DST,
1125 ACTION_SET_IPV4_DSCP,
1126 ACTION_SET_IPV6_DSCP,
1130 static const enum index action_mark[] = {
1136 static const enum index action_queue[] = {
1142 static const enum index action_count[] = {
1144 ACTION_COUNT_SHARED,
1149 static const enum index action_rss[] = {
1160 static const enum index action_vf[] = {
1167 static const enum index action_phy_port[] = {
1168 ACTION_PHY_PORT_ORIGINAL,
1169 ACTION_PHY_PORT_INDEX,
1174 static const enum index action_port_id[] = {
1175 ACTION_PORT_ID_ORIGINAL,
1181 static const enum index action_meter[] = {
1187 static const enum index action_of_set_mpls_ttl[] = {
1188 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
1193 static const enum index action_of_set_nw_ttl[] = {
1194 ACTION_OF_SET_NW_TTL_NW_TTL,
1199 static const enum index action_of_push_vlan[] = {
1200 ACTION_OF_PUSH_VLAN_ETHERTYPE,
1205 static const enum index action_of_set_vlan_vid[] = {
1206 ACTION_OF_SET_VLAN_VID_VLAN_VID,
1211 static const enum index action_of_set_vlan_pcp[] = {
1212 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
1217 static const enum index action_of_pop_mpls[] = {
1218 ACTION_OF_POP_MPLS_ETHERTYPE,
1223 static const enum index action_of_push_mpls[] = {
1224 ACTION_OF_PUSH_MPLS_ETHERTYPE,
1229 static const enum index action_set_ipv4_src[] = {
1230 ACTION_SET_IPV4_SRC_IPV4_SRC,
1235 static const enum index action_set_mac_src[] = {
1236 ACTION_SET_MAC_SRC_MAC_SRC,
1241 static const enum index action_set_ipv4_dst[] = {
1242 ACTION_SET_IPV4_DST_IPV4_DST,
1247 static const enum index action_set_ipv6_src[] = {
1248 ACTION_SET_IPV6_SRC_IPV6_SRC,
1253 static const enum index action_set_ipv6_dst[] = {
1254 ACTION_SET_IPV6_DST_IPV6_DST,
1259 static const enum index action_set_tp_src[] = {
1260 ACTION_SET_TP_SRC_TP_SRC,
1265 static const enum index action_set_tp_dst[] = {
1266 ACTION_SET_TP_DST_TP_DST,
1271 static const enum index action_set_ttl[] = {
1277 static const enum index action_jump[] = {
1283 static const enum index action_set_mac_dst[] = {
1284 ACTION_SET_MAC_DST_MAC_DST,
1289 static const enum index action_inc_tcp_seq[] = {
1290 ACTION_INC_TCP_SEQ_VALUE,
1295 static const enum index action_dec_tcp_seq[] = {
1296 ACTION_DEC_TCP_SEQ_VALUE,
1301 static const enum index action_inc_tcp_ack[] = {
1302 ACTION_INC_TCP_ACK_VALUE,
1307 static const enum index action_dec_tcp_ack[] = {
1308 ACTION_DEC_TCP_ACK_VALUE,
1313 static const enum index action_raw_encap[] = {
1314 ACTION_RAW_ENCAP_INDEX,
1319 static const enum index action_raw_decap[] = {
1320 ACTION_RAW_DECAP_INDEX,
1325 static const enum index action_set_tag[] = {
1326 ACTION_SET_TAG_DATA,
1327 ACTION_SET_TAG_INDEX,
1328 ACTION_SET_TAG_MASK,
1333 static const enum index action_set_meta[] = {
1334 ACTION_SET_META_DATA,
1335 ACTION_SET_META_MASK,
1340 static const enum index action_set_ipv4_dscp[] = {
1341 ACTION_SET_IPV4_DSCP_VALUE,
1346 static const enum index action_set_ipv6_dscp[] = {
1347 ACTION_SET_IPV6_DSCP_VALUE,
1352 static int parse_set_raw_encap_decap(struct context *, const struct token *,
1353 const char *, unsigned int,
1354 void *, unsigned int);
1355 static int parse_set_init(struct context *, const struct token *,
1356 const char *, unsigned int,
1357 void *, unsigned int);
1358 static int parse_init(struct context *, const struct token *,
1359 const char *, unsigned int,
1360 void *, unsigned int);
1361 static int parse_vc(struct context *, const struct token *,
1362 const char *, unsigned int,
1363 void *, unsigned int);
1364 static int parse_vc_spec(struct context *, const struct token *,
1365 const char *, unsigned int, void *, unsigned int);
1366 static int parse_vc_conf(struct context *, const struct token *,
1367 const char *, unsigned int, void *, unsigned int);
1368 static int parse_vc_action_rss(struct context *, const struct token *,
1369 const char *, unsigned int, void *,
1371 static int parse_vc_action_rss_func(struct context *, const struct token *,
1372 const char *, unsigned int, void *,
1374 static int parse_vc_action_rss_type(struct context *, const struct token *,
1375 const char *, unsigned int, void *,
1377 static int parse_vc_action_rss_queue(struct context *, const struct token *,
1378 const char *, unsigned int, void *,
1380 static int parse_vc_action_vxlan_encap(struct context *, const struct token *,
1381 const char *, unsigned int, void *,
1383 static int parse_vc_action_nvgre_encap(struct context *, const struct token *,
1384 const char *, unsigned int, void *,
1386 static int parse_vc_action_l2_encap(struct context *, const struct token *,
1387 const char *, unsigned int, void *,
1389 static int parse_vc_action_l2_decap(struct context *, const struct token *,
1390 const char *, unsigned int, void *,
1392 static int parse_vc_action_mplsogre_encap(struct context *,
1393 const struct token *, const char *,
1394 unsigned int, void *, unsigned int);
1395 static int parse_vc_action_mplsogre_decap(struct context *,
1396 const struct token *, const char *,
1397 unsigned int, void *, unsigned int);
1398 static int parse_vc_action_mplsoudp_encap(struct context *,
1399 const struct token *, const char *,
1400 unsigned int, void *, unsigned int);
1401 static int parse_vc_action_mplsoudp_decap(struct context *,
1402 const struct token *, const char *,
1403 unsigned int, void *, unsigned int);
1404 static int parse_vc_action_raw_encap(struct context *,
1405 const struct token *, const char *,
1406 unsigned int, void *, unsigned int);
1407 static int parse_vc_action_raw_decap(struct context *,
1408 const struct token *, const char *,
1409 unsigned int, void *, unsigned int);
1410 static int parse_vc_action_raw_encap_index(struct context *,
1411 const struct token *, const char *,
1412 unsigned int, void *, unsigned int);
1413 static int parse_vc_action_raw_decap_index(struct context *,
1414 const struct token *, const char *,
1415 unsigned int, void *, unsigned int);
1416 static int parse_vc_action_set_meta(struct context *ctx,
1417 const struct token *token, const char *str,
1418 unsigned int len, void *buf,
1420 static int parse_destroy(struct context *, const struct token *,
1421 const char *, unsigned int,
1422 void *, unsigned int);
1423 static int parse_flush(struct context *, const struct token *,
1424 const char *, unsigned int,
1425 void *, unsigned int);
1426 static int parse_dump(struct context *, const struct token *,
1427 const char *, unsigned int,
1428 void *, unsigned int);
1429 static int parse_query(struct context *, const struct token *,
1430 const char *, unsigned int,
1431 void *, unsigned int);
1432 static int parse_action(struct context *, const struct token *,
1433 const char *, unsigned int,
1434 void *, unsigned int);
1435 static int parse_list(struct context *, const struct token *,
1436 const char *, unsigned int,
1437 void *, unsigned int);
1438 static int parse_isolate(struct context *, const struct token *,
1439 const char *, unsigned int,
1440 void *, unsigned int);
1441 static int parse_int(struct context *, const struct token *,
1442 const char *, unsigned int,
1443 void *, unsigned int);
1444 static int parse_prefix(struct context *, const struct token *,
1445 const char *, unsigned int,
1446 void *, unsigned int);
1447 static int parse_boolean(struct context *, const struct token *,
1448 const char *, unsigned int,
1449 void *, unsigned int);
1450 static int parse_string(struct context *, const struct token *,
1451 const char *, unsigned int,
1452 void *, unsigned int);
1453 static int parse_hex(struct context *ctx, const struct token *token,
1454 const char *str, unsigned int len,
1455 void *buf, unsigned int size);
1456 static int parse_string0(struct context *, const struct token *,
1457 const char *, unsigned int,
1458 void *, unsigned int);
1459 static int parse_mac_addr(struct context *, const struct token *,
1460 const char *, unsigned int,
1461 void *, unsigned int);
1462 static int parse_ipv4_addr(struct context *, const struct token *,
1463 const char *, unsigned int,
1464 void *, unsigned int);
1465 static int parse_ipv6_addr(struct context *, const struct token *,
1466 const char *, unsigned int,
1467 void *, unsigned int);
1468 static int parse_port(struct context *, const struct token *,
1469 const char *, unsigned int,
1470 void *, unsigned int);
1471 static int comp_none(struct context *, const struct token *,
1472 unsigned int, char *, unsigned int);
1473 static int comp_boolean(struct context *, const struct token *,
1474 unsigned int, char *, unsigned int);
1475 static int comp_action(struct context *, const struct token *,
1476 unsigned int, char *, unsigned int);
1477 static int comp_port(struct context *, const struct token *,
1478 unsigned int, char *, unsigned int);
1479 static int comp_rule_id(struct context *, const struct token *,
1480 unsigned int, char *, unsigned int);
1481 static int comp_vc_action_rss_type(struct context *, const struct token *,
1482 unsigned int, char *, unsigned int);
1483 static int comp_vc_action_rss_queue(struct context *, const struct token *,
1484 unsigned int, char *, unsigned int);
1485 static int comp_set_raw_index(struct context *, const struct token *,
1486 unsigned int, char *, unsigned int);
1488 /** Token definitions. */
1489 static const struct token token_list[] = {
1490 /* Special tokens. */
1493 .help = "null entry, abused as the entry point",
1494 .next = NEXT(NEXT_ENTRY(FLOW)),
1499 .help = "command may end here",
1502 .name = "START_SET",
1503 .help = "null entry, abused as the entry point for set",
1504 .next = NEXT(NEXT_ENTRY(SET)),
1509 .help = "set command may end here",
1511 /* Common tokens. */
1515 .help = "integer value",
1520 .name = "{unsigned}",
1522 .help = "unsigned integer value",
1529 .help = "prefix length for bit-mask",
1530 .call = parse_prefix,
1534 .name = "{boolean}",
1536 .help = "any boolean value",
1537 .call = parse_boolean,
1538 .comp = comp_boolean,
1543 .help = "fixed string",
1544 .call = parse_string,
1550 .help = "fixed string",
1554 .name = "{file path}",
1556 .help = "file path",
1557 .call = parse_string0,
1561 .name = "{MAC address}",
1563 .help = "standard MAC address notation",
1564 .call = parse_mac_addr,
1568 .name = "{IPv4 address}",
1569 .type = "IPV4 ADDRESS",
1570 .help = "standard IPv4 address notation",
1571 .call = parse_ipv4_addr,
1575 .name = "{IPv6 address}",
1576 .type = "IPV6 ADDRESS",
1577 .help = "standard IPv6 address notation",
1578 .call = parse_ipv6_addr,
1582 .name = "{rule id}",
1584 .help = "rule identifier",
1586 .comp = comp_rule_id,
1589 .name = "{port_id}",
1591 .help = "port identifier",
1596 .name = "{group_id}",
1598 .help = "group identifier",
1602 [PRIORITY_LEVEL] = {
1605 .help = "priority level",
1609 /* Top-level command. */
1612 .type = "{command} {port_id} [{arg} [...]]",
1613 .help = "manage ingress/egress flow rules",
1614 .next = NEXT(NEXT_ENTRY
1625 /* Sub-level commands. */
1628 .help = "check whether a flow rule can be created",
1629 .next = NEXT(next_vc_attr, NEXT_ENTRY(PORT_ID)),
1630 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1635 .help = "create a flow rule",
1636 .next = NEXT(next_vc_attr, NEXT_ENTRY(PORT_ID)),
1637 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1642 .help = "destroy specific flow rules",
1643 .next = NEXT(NEXT_ENTRY(DESTROY_RULE), NEXT_ENTRY(PORT_ID)),
1644 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1645 .call = parse_destroy,
1649 .help = "destroy all flow rules",
1650 .next = NEXT(NEXT_ENTRY(PORT_ID)),
1651 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1652 .call = parse_flush,
1656 .help = "dump all flow rules to file",
1657 .next = NEXT(next_dump_attr, NEXT_ENTRY(PORT_ID)),
1658 .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file),
1659 ARGS_ENTRY(struct buffer, port)),
1664 .help = "query an existing flow rule",
1665 .next = NEXT(NEXT_ENTRY(QUERY_ACTION),
1666 NEXT_ENTRY(RULE_ID),
1667 NEXT_ENTRY(PORT_ID)),
1668 .args = ARGS(ARGS_ENTRY(struct buffer, args.query.action.type),
1669 ARGS_ENTRY(struct buffer, args.query.rule),
1670 ARGS_ENTRY(struct buffer, port)),
1671 .call = parse_query,
1675 .help = "list existing flow rules",
1676 .next = NEXT(next_list_attr, NEXT_ENTRY(PORT_ID)),
1677 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1682 .help = "restrict ingress traffic to the defined flow rules",
1683 .next = NEXT(NEXT_ENTRY(BOOLEAN),
1684 NEXT_ENTRY(PORT_ID)),
1685 .args = ARGS(ARGS_ENTRY(struct buffer, args.isolate.set),
1686 ARGS_ENTRY(struct buffer, port)),
1687 .call = parse_isolate,
1689 /* Destroy arguments. */
1692 .help = "specify a rule identifier",
1693 .next = NEXT(next_destroy_attr, NEXT_ENTRY(RULE_ID)),
1694 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.destroy.rule)),
1695 .call = parse_destroy,
1697 /* Query arguments. */
1701 .help = "action to query, must be part of the rule",
1702 .call = parse_action,
1703 .comp = comp_action,
1705 /* List arguments. */
1708 .help = "specify a group",
1709 .next = NEXT(next_list_attr, NEXT_ENTRY(GROUP_ID)),
1710 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.list.group)),
1713 /* Validate/create attributes. */
1716 .help = "specify a group",
1717 .next = NEXT(next_vc_attr, NEXT_ENTRY(GROUP_ID)),
1718 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, group)),
1723 .help = "specify a priority level",
1724 .next = NEXT(next_vc_attr, NEXT_ENTRY(PRIORITY_LEVEL)),
1725 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, priority)),
1730 .help = "affect rule to ingress",
1731 .next = NEXT(next_vc_attr),
1736 .help = "affect rule to egress",
1737 .next = NEXT(next_vc_attr),
1742 .help = "apply rule directly to endpoints found in pattern",
1743 .next = NEXT(next_vc_attr),
1746 /* Validate/create pattern. */
1749 .help = "submit a list of pattern items",
1750 .next = NEXT(next_item),
1755 .help = "match value perfectly (with full bit-mask)",
1756 .call = parse_vc_spec,
1758 [ITEM_PARAM_SPEC] = {
1760 .help = "match value according to configured bit-mask",
1761 .call = parse_vc_spec,
1763 [ITEM_PARAM_LAST] = {
1765 .help = "specify upper bound to establish a range",
1766 .call = parse_vc_spec,
1768 [ITEM_PARAM_MASK] = {
1770 .help = "specify bit-mask with relevant bits set to one",
1771 .call = parse_vc_spec,
1773 [ITEM_PARAM_PREFIX] = {
1775 .help = "generate bit-mask from a prefix length",
1776 .call = parse_vc_spec,
1780 .help = "specify next pattern item",
1781 .next = NEXT(next_item),
1785 .help = "end list of pattern items",
1786 .priv = PRIV_ITEM(END, 0),
1787 .next = NEXT(NEXT_ENTRY(ACTIONS)),
1792 .help = "no-op pattern item",
1793 .priv = PRIV_ITEM(VOID, 0),
1794 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
1799 .help = "perform actions when pattern does not match",
1800 .priv = PRIV_ITEM(INVERT, 0),
1801 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
1806 .help = "match any protocol for the current layer",
1807 .priv = PRIV_ITEM(ANY, sizeof(struct rte_flow_item_any)),
1808 .next = NEXT(item_any),
1813 .help = "number of layers covered",
1814 .next = NEXT(item_any, NEXT_ENTRY(UNSIGNED), item_param),
1815 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_any, num)),
1819 .help = "match traffic from/to the physical function",
1820 .priv = PRIV_ITEM(PF, 0),
1821 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
1826 .help = "match traffic from/to a virtual function ID",
1827 .priv = PRIV_ITEM(VF, sizeof(struct rte_flow_item_vf)),
1828 .next = NEXT(item_vf),
1834 .next = NEXT(item_vf, NEXT_ENTRY(UNSIGNED), item_param),
1835 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_vf, id)),
1839 .help = "match traffic from/to a specific physical port",
1840 .priv = PRIV_ITEM(PHY_PORT,
1841 sizeof(struct rte_flow_item_phy_port)),
1842 .next = NEXT(item_phy_port),
1845 [ITEM_PHY_PORT_INDEX] = {
1847 .help = "physical port index",
1848 .next = NEXT(item_phy_port, NEXT_ENTRY(UNSIGNED), item_param),
1849 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_phy_port, index)),
1853 .help = "match traffic from/to a given DPDK port ID",
1854 .priv = PRIV_ITEM(PORT_ID,
1855 sizeof(struct rte_flow_item_port_id)),
1856 .next = NEXT(item_port_id),
1859 [ITEM_PORT_ID_ID] = {
1861 .help = "DPDK port ID",
1862 .next = NEXT(item_port_id, NEXT_ENTRY(UNSIGNED), item_param),
1863 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port_id, id)),
1867 .help = "match traffic against value set in previously matched rule",
1868 .priv = PRIV_ITEM(MARK, sizeof(struct rte_flow_item_mark)),
1869 .next = NEXT(item_mark),
1874 .help = "Integer value to match against",
1875 .next = NEXT(item_mark, NEXT_ENTRY(UNSIGNED), item_param),
1876 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_mark, id)),
1880 .help = "match an arbitrary byte string",
1881 .priv = PRIV_ITEM(RAW, ITEM_RAW_SIZE),
1882 .next = NEXT(item_raw),
1885 [ITEM_RAW_RELATIVE] = {
1887 .help = "look for pattern after the previous item",
1888 .next = NEXT(item_raw, NEXT_ENTRY(BOOLEAN), item_param),
1889 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
1892 [ITEM_RAW_SEARCH] = {
1894 .help = "search pattern from offset (see also limit)",
1895 .next = NEXT(item_raw, NEXT_ENTRY(BOOLEAN), item_param),
1896 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
1899 [ITEM_RAW_OFFSET] = {
1901 .help = "absolute or relative offset for pattern",
1902 .next = NEXT(item_raw, NEXT_ENTRY(INTEGER), item_param),
1903 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, offset)),
1905 [ITEM_RAW_LIMIT] = {
1907 .help = "search area limit for start of pattern",
1908 .next = NEXT(item_raw, NEXT_ENTRY(UNSIGNED), item_param),
1909 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, limit)),
1911 [ITEM_RAW_PATTERN] = {
1913 .help = "byte string to look for",
1914 .next = NEXT(item_raw,
1916 NEXT_ENTRY(ITEM_PARAM_IS,
1919 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern),
1920 ARGS_ENTRY(struct rte_flow_item_raw, length),
1921 ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw),
1922 ITEM_RAW_PATTERN_SIZE)),
1926 .help = "match Ethernet header",
1927 .priv = PRIV_ITEM(ETH, sizeof(struct rte_flow_item_eth)),
1928 .next = NEXT(item_eth),
1933 .help = "destination MAC",
1934 .next = NEXT(item_eth, NEXT_ENTRY(MAC_ADDR), item_param),
1935 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, dst)),
1939 .help = "source MAC",
1940 .next = NEXT(item_eth, NEXT_ENTRY(MAC_ADDR), item_param),
1941 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, src)),
1945 .help = "EtherType",
1946 .next = NEXT(item_eth, NEXT_ENTRY(UNSIGNED), item_param),
1947 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, type)),
1951 .help = "match 802.1Q/ad VLAN tag",
1952 .priv = PRIV_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)),
1953 .next = NEXT(item_vlan),
1958 .help = "tag control information",
1959 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
1960 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, tci)),
1964 .help = "priority code point",
1965 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
1966 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
1971 .help = "drop eligible indicator",
1972 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
1973 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
1978 .help = "VLAN identifier",
1979 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
1980 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
1983 [ITEM_VLAN_INNER_TYPE] = {
1984 .name = "inner_type",
1985 .help = "inner EtherType",
1986 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
1987 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan,
1992 .help = "match IPv4 header",
1993 .priv = PRIV_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)),
1994 .next = NEXT(item_ipv4),
1999 .help = "type of service",
2000 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2001 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2002 hdr.type_of_service)),
2006 .help = "time to live",
2007 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2008 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2011 [ITEM_IPV4_PROTO] = {
2013 .help = "next protocol ID",
2014 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
2015 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2016 hdr.next_proto_id)),
2020 .help = "source address",
2021 .next = NEXT(item_ipv4, NEXT_ENTRY(IPV4_ADDR), item_param),
2022 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2027 .help = "destination address",
2028 .next = NEXT(item_ipv4, NEXT_ENTRY(IPV4_ADDR), item_param),
2029 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
2034 .help = "match IPv6 header",
2035 .priv = PRIV_ITEM(IPV6, sizeof(struct rte_flow_item_ipv6)),
2036 .next = NEXT(item_ipv6),
2041 .help = "traffic class",
2042 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2043 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2045 "\x0f\xf0\x00\x00")),
2047 [ITEM_IPV6_FLOW] = {
2049 .help = "flow label",
2050 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2051 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
2053 "\x00\x0f\xff\xff")),
2055 [ITEM_IPV6_PROTO] = {
2057 .help = "protocol (next header)",
2058 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2059 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2064 .help = "hop limit",
2065 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
2066 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2071 .help = "source address",
2072 .next = NEXT(item_ipv6, NEXT_ENTRY(IPV6_ADDR), item_param),
2073 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2078 .help = "destination address",
2079 .next = NEXT(item_ipv6, NEXT_ENTRY(IPV6_ADDR), item_param),
2080 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
2085 .help = "match ICMP header",
2086 .priv = PRIV_ITEM(ICMP, sizeof(struct rte_flow_item_icmp)),
2087 .next = NEXT(item_icmp),
2090 [ITEM_ICMP_TYPE] = {
2092 .help = "ICMP packet type",
2093 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2094 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2097 [ITEM_ICMP_CODE] = {
2099 .help = "ICMP packet code",
2100 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
2101 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
2106 .help = "match UDP header",
2107 .priv = PRIV_ITEM(UDP, sizeof(struct rte_flow_item_udp)),
2108 .next = NEXT(item_udp),
2113 .help = "UDP source port",
2114 .next = NEXT(item_udp, NEXT_ENTRY(UNSIGNED), item_param),
2115 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2120 .help = "UDP destination port",
2121 .next = NEXT(item_udp, NEXT_ENTRY(UNSIGNED), item_param),
2122 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
2127 .help = "match TCP header",
2128 .priv = PRIV_ITEM(TCP, sizeof(struct rte_flow_item_tcp)),
2129 .next = NEXT(item_tcp),
2134 .help = "TCP source port",
2135 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2136 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2141 .help = "TCP destination port",
2142 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2143 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2146 [ITEM_TCP_FLAGS] = {
2148 .help = "TCP flags",
2149 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
2150 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
2155 .help = "match SCTP header",
2156 .priv = PRIV_ITEM(SCTP, sizeof(struct rte_flow_item_sctp)),
2157 .next = NEXT(item_sctp),
2162 .help = "SCTP source port",
2163 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2164 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2169 .help = "SCTP destination port",
2170 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2171 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2176 .help = "validation tag",
2177 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2178 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2181 [ITEM_SCTP_CKSUM] = {
2184 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
2185 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
2190 .help = "match VXLAN header",
2191 .priv = PRIV_ITEM(VXLAN, sizeof(struct rte_flow_item_vxlan)),
2192 .next = NEXT(item_vxlan),
2195 [ITEM_VXLAN_VNI] = {
2197 .help = "VXLAN identifier",
2198 .next = NEXT(item_vxlan, NEXT_ENTRY(UNSIGNED), item_param),
2199 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan, vni)),
2203 .help = "match E-Tag header",
2204 .priv = PRIV_ITEM(E_TAG, sizeof(struct rte_flow_item_e_tag)),
2205 .next = NEXT(item_e_tag),
2208 [ITEM_E_TAG_GRP_ECID_B] = {
2209 .name = "grp_ecid_b",
2210 .help = "GRP and E-CID base",
2211 .next = NEXT(item_e_tag, NEXT_ENTRY(UNSIGNED), item_param),
2212 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_e_tag,
2218 .help = "match NVGRE header",
2219 .priv = PRIV_ITEM(NVGRE, sizeof(struct rte_flow_item_nvgre)),
2220 .next = NEXT(item_nvgre),
2223 [ITEM_NVGRE_TNI] = {
2225 .help = "virtual subnet ID",
2226 .next = NEXT(item_nvgre, NEXT_ENTRY(UNSIGNED), item_param),
2227 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_nvgre, tni)),
2231 .help = "match MPLS header",
2232 .priv = PRIV_ITEM(MPLS, sizeof(struct rte_flow_item_mpls)),
2233 .next = NEXT(item_mpls),
2236 [ITEM_MPLS_LABEL] = {
2238 .help = "MPLS label",
2239 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2240 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2246 .help = "MPLS Traffic Class",
2247 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2248 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2254 .help = "MPLS Bottom-of-Stack",
2255 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
2256 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
2262 .help = "match GRE header",
2263 .priv = PRIV_ITEM(GRE, sizeof(struct rte_flow_item_gre)),
2264 .next = NEXT(item_gre),
2267 [ITEM_GRE_PROTO] = {
2269 .help = "GRE protocol type",
2270 .next = NEXT(item_gre, NEXT_ENTRY(UNSIGNED), item_param),
2271 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2274 [ITEM_GRE_C_RSVD0_VER] = {
2275 .name = "c_rsvd0_ver",
2277 "checksum (1b), undefined (1b), key bit (1b),"
2278 " sequence number (1b), reserved 0 (9b),"
2280 .next = NEXT(item_gre, NEXT_ENTRY(UNSIGNED), item_param),
2281 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
2284 [ITEM_GRE_C_BIT] = {
2286 .help = "checksum bit (C)",
2287 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2288 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2290 "\x80\x00\x00\x00")),
2292 [ITEM_GRE_S_BIT] = {
2294 .help = "sequence number bit (S)",
2295 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2296 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2298 "\x10\x00\x00\x00")),
2300 [ITEM_GRE_K_BIT] = {
2302 .help = "key bit (K)",
2303 .next = NEXT(item_gre, NEXT_ENTRY(BOOLEAN), item_param),
2304 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
2306 "\x20\x00\x00\x00")),
2310 .help = "fuzzy pattern match, expect faster than default",
2311 .priv = PRIV_ITEM(FUZZY,
2312 sizeof(struct rte_flow_item_fuzzy)),
2313 .next = NEXT(item_fuzzy),
2316 [ITEM_FUZZY_THRESH] = {
2318 .help = "match accuracy threshold",
2319 .next = NEXT(item_fuzzy, NEXT_ENTRY(UNSIGNED), item_param),
2320 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_fuzzy,
2325 .help = "match GTP header",
2326 .priv = PRIV_ITEM(GTP, sizeof(struct rte_flow_item_gtp)),
2327 .next = NEXT(item_gtp),
2330 [ITEM_GTP_MSG_TYPE] = {
2332 .help = "GTP message type",
2333 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2334 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp,
2339 .help = "tunnel endpoint identifier",
2340 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
2341 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp, teid)),
2345 .help = "match GTP header",
2346 .priv = PRIV_ITEM(GTPC, sizeof(struct rte_flow_item_gtp)),
2347 .next = NEXT(item_gtp),
2352 .help = "match GTP header",
2353 .priv = PRIV_ITEM(GTPU, sizeof(struct rte_flow_item_gtp)),
2354 .next = NEXT(item_gtp),
2359 .help = "match GENEVE header",
2360 .priv = PRIV_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)),
2361 .next = NEXT(item_geneve),
2364 [ITEM_GENEVE_VNI] = {
2366 .help = "virtual network identifier",
2367 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2368 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve, vni)),
2370 [ITEM_GENEVE_PROTO] = {
2372 .help = "GENEVE protocol type",
2373 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
2374 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve,
2377 [ITEM_VXLAN_GPE] = {
2378 .name = "vxlan-gpe",
2379 .help = "match VXLAN-GPE header",
2380 .priv = PRIV_ITEM(VXLAN_GPE,
2381 sizeof(struct rte_flow_item_vxlan_gpe)),
2382 .next = NEXT(item_vxlan_gpe),
2385 [ITEM_VXLAN_GPE_VNI] = {
2387 .help = "VXLAN-GPE identifier",
2388 .next = NEXT(item_vxlan_gpe, NEXT_ENTRY(UNSIGNED), item_param),
2389 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
2392 [ITEM_ARP_ETH_IPV4] = {
2393 .name = "arp_eth_ipv4",
2394 .help = "match ARP header for Ethernet/IPv4",
2395 .priv = PRIV_ITEM(ARP_ETH_IPV4,
2396 sizeof(struct rte_flow_item_arp_eth_ipv4)),
2397 .next = NEXT(item_arp_eth_ipv4),
2400 [ITEM_ARP_ETH_IPV4_SHA] = {
2402 .help = "sender hardware address",
2403 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(MAC_ADDR),
2405 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2408 [ITEM_ARP_ETH_IPV4_SPA] = {
2410 .help = "sender IPv4 address",
2411 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(IPV4_ADDR),
2413 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2416 [ITEM_ARP_ETH_IPV4_THA] = {
2418 .help = "target hardware address",
2419 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(MAC_ADDR),
2421 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2424 [ITEM_ARP_ETH_IPV4_TPA] = {
2426 .help = "target IPv4 address",
2427 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(IPV4_ADDR),
2429 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
2434 .help = "match presence of any IPv6 extension header",
2435 .priv = PRIV_ITEM(IPV6_EXT,
2436 sizeof(struct rte_flow_item_ipv6_ext)),
2437 .next = NEXT(item_ipv6_ext),
2440 [ITEM_IPV6_EXT_NEXT_HDR] = {
2442 .help = "next header",
2443 .next = NEXT(item_ipv6_ext, NEXT_ENTRY(UNSIGNED), item_param),
2444 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_ext,
2449 .help = "match any ICMPv6 header",
2450 .priv = PRIV_ITEM(ICMP6, sizeof(struct rte_flow_item_icmp6)),
2451 .next = NEXT(item_icmp6),
2454 [ITEM_ICMP6_TYPE] = {
2456 .help = "ICMPv6 type",
2457 .next = NEXT(item_icmp6, NEXT_ENTRY(UNSIGNED), item_param),
2458 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
2461 [ITEM_ICMP6_CODE] = {
2463 .help = "ICMPv6 code",
2464 .next = NEXT(item_icmp6, NEXT_ENTRY(UNSIGNED), item_param),
2465 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
2468 [ITEM_ICMP6_ND_NS] = {
2469 .name = "icmp6_nd_ns",
2470 .help = "match ICMPv6 neighbor discovery solicitation",
2471 .priv = PRIV_ITEM(ICMP6_ND_NS,
2472 sizeof(struct rte_flow_item_icmp6_nd_ns)),
2473 .next = NEXT(item_icmp6_nd_ns),
2476 [ITEM_ICMP6_ND_NS_TARGET_ADDR] = {
2477 .name = "target_addr",
2478 .help = "target address",
2479 .next = NEXT(item_icmp6_nd_ns, NEXT_ENTRY(IPV6_ADDR),
2481 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_ns,
2484 [ITEM_ICMP6_ND_NA] = {
2485 .name = "icmp6_nd_na",
2486 .help = "match ICMPv6 neighbor discovery advertisement",
2487 .priv = PRIV_ITEM(ICMP6_ND_NA,
2488 sizeof(struct rte_flow_item_icmp6_nd_na)),
2489 .next = NEXT(item_icmp6_nd_na),
2492 [ITEM_ICMP6_ND_NA_TARGET_ADDR] = {
2493 .name = "target_addr",
2494 .help = "target address",
2495 .next = NEXT(item_icmp6_nd_na, NEXT_ENTRY(IPV6_ADDR),
2497 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_na,
2500 [ITEM_ICMP6_ND_OPT] = {
2501 .name = "icmp6_nd_opt",
2502 .help = "match presence of any ICMPv6 neighbor discovery"
2504 .priv = PRIV_ITEM(ICMP6_ND_OPT,
2505 sizeof(struct rte_flow_item_icmp6_nd_opt)),
2506 .next = NEXT(item_icmp6_nd_opt),
2509 [ITEM_ICMP6_ND_OPT_TYPE] = {
2511 .help = "ND option type",
2512 .next = NEXT(item_icmp6_nd_opt, NEXT_ENTRY(UNSIGNED),
2514 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_opt,
2517 [ITEM_ICMP6_ND_OPT_SLA_ETH] = {
2518 .name = "icmp6_nd_opt_sla_eth",
2519 .help = "match ICMPv6 neighbor discovery source Ethernet"
2520 " link-layer address option",
2522 (ICMP6_ND_OPT_SLA_ETH,
2523 sizeof(struct rte_flow_item_icmp6_nd_opt_sla_eth)),
2524 .next = NEXT(item_icmp6_nd_opt_sla_eth),
2527 [ITEM_ICMP6_ND_OPT_SLA_ETH_SLA] = {
2529 .help = "source Ethernet LLA",
2530 .next = NEXT(item_icmp6_nd_opt_sla_eth, NEXT_ENTRY(MAC_ADDR),
2532 .args = ARGS(ARGS_ENTRY_HTON
2533 (struct rte_flow_item_icmp6_nd_opt_sla_eth, sla)),
2535 [ITEM_ICMP6_ND_OPT_TLA_ETH] = {
2536 .name = "icmp6_nd_opt_tla_eth",
2537 .help = "match ICMPv6 neighbor discovery target Ethernet"
2538 " link-layer address option",
2540 (ICMP6_ND_OPT_TLA_ETH,
2541 sizeof(struct rte_flow_item_icmp6_nd_opt_tla_eth)),
2542 .next = NEXT(item_icmp6_nd_opt_tla_eth),
2545 [ITEM_ICMP6_ND_OPT_TLA_ETH_TLA] = {
2547 .help = "target Ethernet LLA",
2548 .next = NEXT(item_icmp6_nd_opt_tla_eth, NEXT_ENTRY(MAC_ADDR),
2550 .args = ARGS(ARGS_ENTRY_HTON
2551 (struct rte_flow_item_icmp6_nd_opt_tla_eth, tla)),
2555 .help = "match metadata header",
2556 .priv = PRIV_ITEM(META, sizeof(struct rte_flow_item_meta)),
2557 .next = NEXT(item_meta),
2560 [ITEM_META_DATA] = {
2562 .help = "metadata value",
2563 .next = NEXT(item_meta, NEXT_ENTRY(UNSIGNED), item_param),
2564 .args = ARGS(ARGS_ENTRY_MASK(struct rte_flow_item_meta,
2565 data, "\xff\xff\xff\xff")),
2569 .help = "match GRE key",
2570 .priv = PRIV_ITEM(GRE_KEY, sizeof(rte_be32_t)),
2571 .next = NEXT(item_gre_key),
2574 [ITEM_GRE_KEY_VALUE] = {
2576 .help = "key value",
2577 .next = NEXT(item_gre_key, NEXT_ENTRY(UNSIGNED), item_param),
2578 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
2582 .help = "match GTP extension header with type 0x85",
2583 .priv = PRIV_ITEM(GTP_PSC,
2584 sizeof(struct rte_flow_item_gtp_psc)),
2585 .next = NEXT(item_gtp_psc),
2588 [ITEM_GTP_PSC_QFI] = {
2590 .help = "QoS flow identifier",
2591 .next = NEXT(item_gtp_psc, NEXT_ENTRY(UNSIGNED), item_param),
2592 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
2595 [ITEM_GTP_PSC_PDU_T] = {
2598 .next = NEXT(item_gtp_psc, NEXT_ENTRY(UNSIGNED), item_param),
2599 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
2604 .help = "match PPPoE session header",
2605 .priv = PRIV_ITEM(PPPOES, sizeof(struct rte_flow_item_pppoe)),
2606 .next = NEXT(item_pppoes),
2611 .help = "match PPPoE discovery header",
2612 .priv = PRIV_ITEM(PPPOED, sizeof(struct rte_flow_item_pppoe)),
2613 .next = NEXT(item_pppoed),
2616 [ITEM_PPPOE_SEID] = {
2618 .help = "session identifier",
2619 .next = NEXT(item_pppoes, NEXT_ENTRY(UNSIGNED), item_param),
2620 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pppoe,
2623 [ITEM_PPPOE_PROTO_ID] = {
2625 .help = "match PPPoE session protocol identifier",
2626 .priv = PRIV_ITEM(PPPOE_PROTO_ID,
2627 sizeof(struct rte_flow_item_pppoe_proto_id)),
2628 .next = NEXT(item_pppoe_proto_id),
2633 .help = "matches higig2 header",
2634 .priv = PRIV_ITEM(HIGIG2,
2635 sizeof(struct rte_flow_item_higig2_hdr)),
2636 .next = NEXT(item_higig2),
2639 [ITEM_HIGIG2_CLASSIFICATION] = {
2640 .name = "classification",
2641 .help = "matches classification of higig2 header",
2642 .next = NEXT(item_higig2, NEXT_ENTRY(UNSIGNED), item_param),
2643 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
2644 hdr.ppt1.classification)),
2646 [ITEM_HIGIG2_VID] = {
2648 .help = "matches vid of higig2 header",
2649 .next = NEXT(item_higig2, NEXT_ENTRY(UNSIGNED), item_param),
2650 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
2655 .help = "match tag value",
2656 .priv = PRIV_ITEM(TAG, sizeof(struct rte_flow_item_tag)),
2657 .next = NEXT(item_tag),
2662 .help = "tag value to match",
2663 .next = NEXT(item_tag, NEXT_ENTRY(UNSIGNED), item_param),
2664 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, data)),
2666 [ITEM_TAG_INDEX] = {
2668 .help = "index of tag array to match",
2669 .next = NEXT(item_tag, NEXT_ENTRY(UNSIGNED),
2670 NEXT_ENTRY(ITEM_PARAM_IS)),
2671 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, index)),
2673 [ITEM_L2TPV3OIP] = {
2674 .name = "l2tpv3oip",
2675 .help = "match L2TPv3 over IP header",
2676 .priv = PRIV_ITEM(L2TPV3OIP,
2677 sizeof(struct rte_flow_item_l2tpv3oip)),
2678 .next = NEXT(item_l2tpv3oip),
2681 [ITEM_L2TPV3OIP_SESSION_ID] = {
2682 .name = "session_id",
2683 .help = "session identifier",
2684 .next = NEXT(item_l2tpv3oip, NEXT_ENTRY(UNSIGNED), item_param),
2685 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv3oip,
2690 .help = "match ESP header",
2691 .priv = PRIV_ITEM(ESP, sizeof(struct rte_flow_item_esp)),
2692 .next = NEXT(item_esp),
2697 .help = "security policy index",
2698 .next = NEXT(item_esp, NEXT_ENTRY(UNSIGNED), item_param),
2699 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_esp,
2702 /* Validate/create actions. */
2705 .help = "submit a list of associated actions",
2706 .next = NEXT(next_action),
2711 .help = "specify next action",
2712 .next = NEXT(next_action),
2716 .help = "end list of actions",
2717 .priv = PRIV_ACTION(END, 0),
2722 .help = "no-op action",
2723 .priv = PRIV_ACTION(VOID, 0),
2724 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
2727 [ACTION_PASSTHRU] = {
2729 .help = "let subsequent rule process matched packets",
2730 .priv = PRIV_ACTION(PASSTHRU, 0),
2731 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
2736 .help = "redirect traffic to a given group",
2737 .priv = PRIV_ACTION(JUMP, sizeof(struct rte_flow_action_jump)),
2738 .next = NEXT(action_jump),
2741 [ACTION_JUMP_GROUP] = {
2743 .help = "group to redirect traffic to",
2744 .next = NEXT(action_jump, NEXT_ENTRY(UNSIGNED)),
2745 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump, group)),
2746 .call = parse_vc_conf,
2750 .help = "attach 32 bit value to packets",
2751 .priv = PRIV_ACTION(MARK, sizeof(struct rte_flow_action_mark)),
2752 .next = NEXT(action_mark),
2755 [ACTION_MARK_ID] = {
2757 .help = "32 bit value to return with packets",
2758 .next = NEXT(action_mark, NEXT_ENTRY(UNSIGNED)),
2759 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_mark, id)),
2760 .call = parse_vc_conf,
2764 .help = "flag packets",
2765 .priv = PRIV_ACTION(FLAG, 0),
2766 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
2771 .help = "assign packets to a given queue index",
2772 .priv = PRIV_ACTION(QUEUE,
2773 sizeof(struct rte_flow_action_queue)),
2774 .next = NEXT(action_queue),
2777 [ACTION_QUEUE_INDEX] = {
2779 .help = "queue index to use",
2780 .next = NEXT(action_queue, NEXT_ENTRY(UNSIGNED)),
2781 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_queue, index)),
2782 .call = parse_vc_conf,
2786 .help = "drop packets (note: passthru has priority)",
2787 .priv = PRIV_ACTION(DROP, 0),
2788 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
2793 .help = "enable counters for this rule",
2794 .priv = PRIV_ACTION(COUNT,
2795 sizeof(struct rte_flow_action_count)),
2796 .next = NEXT(action_count),
2799 [ACTION_COUNT_ID] = {
2800 .name = "identifier",
2801 .help = "counter identifier to use",
2802 .next = NEXT(action_count, NEXT_ENTRY(UNSIGNED)),
2803 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_count, id)),
2804 .call = parse_vc_conf,
2806 [ACTION_COUNT_SHARED] = {
2808 .help = "shared counter",
2809 .next = NEXT(action_count, NEXT_ENTRY(BOOLEAN)),
2810 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_count,
2812 .call = parse_vc_conf,
2816 .help = "spread packets among several queues",
2817 .priv = PRIV_ACTION(RSS, sizeof(struct action_rss_data)),
2818 .next = NEXT(action_rss),
2819 .call = parse_vc_action_rss,
2821 [ACTION_RSS_FUNC] = {
2823 .help = "RSS hash function to apply",
2824 .next = NEXT(action_rss,
2825 NEXT_ENTRY(ACTION_RSS_FUNC_DEFAULT,
2826 ACTION_RSS_FUNC_TOEPLITZ,
2827 ACTION_RSS_FUNC_SIMPLE_XOR,
2828 ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ)),
2830 [ACTION_RSS_FUNC_DEFAULT] = {
2832 .help = "default hash function",
2833 .call = parse_vc_action_rss_func,
2835 [ACTION_RSS_FUNC_TOEPLITZ] = {
2837 .help = "Toeplitz hash function",
2838 .call = parse_vc_action_rss_func,
2840 [ACTION_RSS_FUNC_SIMPLE_XOR] = {
2841 .name = "simple_xor",
2842 .help = "simple XOR hash function",
2843 .call = parse_vc_action_rss_func,
2845 [ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ] = {
2846 .name = "symmetric_toeplitz",
2847 .help = "Symmetric Toeplitz hash function",
2848 .call = parse_vc_action_rss_func,
2850 [ACTION_RSS_LEVEL] = {
2852 .help = "encapsulation level for \"types\"",
2853 .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
2854 .args = ARGS(ARGS_ENTRY_ARB
2855 (offsetof(struct action_rss_data, conf) +
2856 offsetof(struct rte_flow_action_rss, level),
2857 sizeof(((struct rte_flow_action_rss *)0)->
2860 [ACTION_RSS_TYPES] = {
2862 .help = "specific RSS hash types",
2863 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)),
2865 [ACTION_RSS_TYPE] = {
2867 .help = "RSS hash type",
2868 .call = parse_vc_action_rss_type,
2869 .comp = comp_vc_action_rss_type,
2871 [ACTION_RSS_KEY] = {
2873 .help = "RSS hash key",
2874 .next = NEXT(action_rss, NEXT_ENTRY(HEX)),
2875 .args = ARGS(ARGS_ENTRY_ARB(0, 0),
2877 (offsetof(struct action_rss_data, conf) +
2878 offsetof(struct rte_flow_action_rss, key_len),
2879 sizeof(((struct rte_flow_action_rss *)0)->
2881 ARGS_ENTRY(struct action_rss_data, key)),
2883 [ACTION_RSS_KEY_LEN] = {
2885 .help = "RSS hash key length in bytes",
2886 .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
2887 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
2888 (offsetof(struct action_rss_data, conf) +
2889 offsetof(struct rte_flow_action_rss, key_len),
2890 sizeof(((struct rte_flow_action_rss *)0)->
2893 RSS_HASH_KEY_LENGTH)),
2895 [ACTION_RSS_QUEUES] = {
2897 .help = "queue indices to use",
2898 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_QUEUE)),
2899 .call = parse_vc_conf,
2901 [ACTION_RSS_QUEUE] = {
2903 .help = "queue index",
2904 .call = parse_vc_action_rss_queue,
2905 .comp = comp_vc_action_rss_queue,
2909 .help = "direct traffic to physical function",
2910 .priv = PRIV_ACTION(PF, 0),
2911 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
2916 .help = "direct traffic to a virtual function ID",
2917 .priv = PRIV_ACTION(VF, sizeof(struct rte_flow_action_vf)),
2918 .next = NEXT(action_vf),
2921 [ACTION_VF_ORIGINAL] = {
2923 .help = "use original VF ID if possible",
2924 .next = NEXT(action_vf, NEXT_ENTRY(BOOLEAN)),
2925 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_vf,
2927 .call = parse_vc_conf,
2932 .next = NEXT(action_vf, NEXT_ENTRY(UNSIGNED)),
2933 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)),
2934 .call = parse_vc_conf,
2936 [ACTION_PHY_PORT] = {
2938 .help = "direct packets to physical port index",
2939 .priv = PRIV_ACTION(PHY_PORT,
2940 sizeof(struct rte_flow_action_phy_port)),
2941 .next = NEXT(action_phy_port),
2944 [ACTION_PHY_PORT_ORIGINAL] = {
2946 .help = "use original port index if possible",
2947 .next = NEXT(action_phy_port, NEXT_ENTRY(BOOLEAN)),
2948 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_phy_port,
2950 .call = parse_vc_conf,
2952 [ACTION_PHY_PORT_INDEX] = {
2954 .help = "physical port index",
2955 .next = NEXT(action_phy_port, NEXT_ENTRY(UNSIGNED)),
2956 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_phy_port,
2958 .call = parse_vc_conf,
2960 [ACTION_PORT_ID] = {
2962 .help = "direct matching traffic to a given DPDK port ID",
2963 .priv = PRIV_ACTION(PORT_ID,
2964 sizeof(struct rte_flow_action_port_id)),
2965 .next = NEXT(action_port_id),
2968 [ACTION_PORT_ID_ORIGINAL] = {
2970 .help = "use original DPDK port ID if possible",
2971 .next = NEXT(action_port_id, NEXT_ENTRY(BOOLEAN)),
2972 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_port_id,
2974 .call = parse_vc_conf,
2976 [ACTION_PORT_ID_ID] = {
2978 .help = "DPDK port ID",
2979 .next = NEXT(action_port_id, NEXT_ENTRY(UNSIGNED)),
2980 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_port_id, id)),
2981 .call = parse_vc_conf,
2985 .help = "meter the directed packets at given id",
2986 .priv = PRIV_ACTION(METER,
2987 sizeof(struct rte_flow_action_meter)),
2988 .next = NEXT(action_meter),
2991 [ACTION_METER_ID] = {
2993 .help = "meter id to use",
2994 .next = NEXT(action_meter, NEXT_ENTRY(UNSIGNED)),
2995 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter, mtr_id)),
2996 .call = parse_vc_conf,
2998 [ACTION_OF_SET_MPLS_TTL] = {
2999 .name = "of_set_mpls_ttl",
3000 .help = "OpenFlow's OFPAT_SET_MPLS_TTL",
3003 sizeof(struct rte_flow_action_of_set_mpls_ttl)),
3004 .next = NEXT(action_of_set_mpls_ttl),
3007 [ACTION_OF_SET_MPLS_TTL_MPLS_TTL] = {
3010 .next = NEXT(action_of_set_mpls_ttl, NEXT_ENTRY(UNSIGNED)),
3011 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_mpls_ttl,
3013 .call = parse_vc_conf,
3015 [ACTION_OF_DEC_MPLS_TTL] = {
3016 .name = "of_dec_mpls_ttl",
3017 .help = "OpenFlow's OFPAT_DEC_MPLS_TTL",
3018 .priv = PRIV_ACTION(OF_DEC_MPLS_TTL, 0),
3019 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3022 [ACTION_OF_SET_NW_TTL] = {
3023 .name = "of_set_nw_ttl",
3024 .help = "OpenFlow's OFPAT_SET_NW_TTL",
3027 sizeof(struct rte_flow_action_of_set_nw_ttl)),
3028 .next = NEXT(action_of_set_nw_ttl),
3031 [ACTION_OF_SET_NW_TTL_NW_TTL] = {
3034 .next = NEXT(action_of_set_nw_ttl, NEXT_ENTRY(UNSIGNED)),
3035 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_nw_ttl,
3037 .call = parse_vc_conf,
3039 [ACTION_OF_DEC_NW_TTL] = {
3040 .name = "of_dec_nw_ttl",
3041 .help = "OpenFlow's OFPAT_DEC_NW_TTL",
3042 .priv = PRIV_ACTION(OF_DEC_NW_TTL, 0),
3043 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3046 [ACTION_OF_COPY_TTL_OUT] = {
3047 .name = "of_copy_ttl_out",
3048 .help = "OpenFlow's OFPAT_COPY_TTL_OUT",
3049 .priv = PRIV_ACTION(OF_COPY_TTL_OUT, 0),
3050 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3053 [ACTION_OF_COPY_TTL_IN] = {
3054 .name = "of_copy_ttl_in",
3055 .help = "OpenFlow's OFPAT_COPY_TTL_IN",
3056 .priv = PRIV_ACTION(OF_COPY_TTL_IN, 0),
3057 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3060 [ACTION_OF_POP_VLAN] = {
3061 .name = "of_pop_vlan",
3062 .help = "OpenFlow's OFPAT_POP_VLAN",
3063 .priv = PRIV_ACTION(OF_POP_VLAN, 0),
3064 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3067 [ACTION_OF_PUSH_VLAN] = {
3068 .name = "of_push_vlan",
3069 .help = "OpenFlow's OFPAT_PUSH_VLAN",
3072 sizeof(struct rte_flow_action_of_push_vlan)),
3073 .next = NEXT(action_of_push_vlan),
3076 [ACTION_OF_PUSH_VLAN_ETHERTYPE] = {
3077 .name = "ethertype",
3078 .help = "EtherType",
3079 .next = NEXT(action_of_push_vlan, NEXT_ENTRY(UNSIGNED)),
3080 .args = ARGS(ARGS_ENTRY_HTON
3081 (struct rte_flow_action_of_push_vlan,
3083 .call = parse_vc_conf,
3085 [ACTION_OF_SET_VLAN_VID] = {
3086 .name = "of_set_vlan_vid",
3087 .help = "OpenFlow's OFPAT_SET_VLAN_VID",
3090 sizeof(struct rte_flow_action_of_set_vlan_vid)),
3091 .next = NEXT(action_of_set_vlan_vid),
3094 [ACTION_OF_SET_VLAN_VID_VLAN_VID] = {
3097 .next = NEXT(action_of_set_vlan_vid, NEXT_ENTRY(UNSIGNED)),
3098 .args = ARGS(ARGS_ENTRY_HTON
3099 (struct rte_flow_action_of_set_vlan_vid,
3101 .call = parse_vc_conf,
3103 [ACTION_OF_SET_VLAN_PCP] = {
3104 .name = "of_set_vlan_pcp",
3105 .help = "OpenFlow's OFPAT_SET_VLAN_PCP",
3108 sizeof(struct rte_flow_action_of_set_vlan_pcp)),
3109 .next = NEXT(action_of_set_vlan_pcp),
3112 [ACTION_OF_SET_VLAN_PCP_VLAN_PCP] = {
3114 .help = "VLAN priority",
3115 .next = NEXT(action_of_set_vlan_pcp, NEXT_ENTRY(UNSIGNED)),
3116 .args = ARGS(ARGS_ENTRY_HTON
3117 (struct rte_flow_action_of_set_vlan_pcp,
3119 .call = parse_vc_conf,
3121 [ACTION_OF_POP_MPLS] = {
3122 .name = "of_pop_mpls",
3123 .help = "OpenFlow's OFPAT_POP_MPLS",
3124 .priv = PRIV_ACTION(OF_POP_MPLS,
3125 sizeof(struct rte_flow_action_of_pop_mpls)),
3126 .next = NEXT(action_of_pop_mpls),
3129 [ACTION_OF_POP_MPLS_ETHERTYPE] = {
3130 .name = "ethertype",
3131 .help = "EtherType",
3132 .next = NEXT(action_of_pop_mpls, NEXT_ENTRY(UNSIGNED)),
3133 .args = ARGS(ARGS_ENTRY_HTON
3134 (struct rte_flow_action_of_pop_mpls,
3136 .call = parse_vc_conf,
3138 [ACTION_OF_PUSH_MPLS] = {
3139 .name = "of_push_mpls",
3140 .help = "OpenFlow's OFPAT_PUSH_MPLS",
3143 sizeof(struct rte_flow_action_of_push_mpls)),
3144 .next = NEXT(action_of_push_mpls),
3147 [ACTION_OF_PUSH_MPLS_ETHERTYPE] = {
3148 .name = "ethertype",
3149 .help = "EtherType",
3150 .next = NEXT(action_of_push_mpls, NEXT_ENTRY(UNSIGNED)),
3151 .args = ARGS(ARGS_ENTRY_HTON
3152 (struct rte_flow_action_of_push_mpls,
3154 .call = parse_vc_conf,
3156 [ACTION_VXLAN_ENCAP] = {
3157 .name = "vxlan_encap",
3158 .help = "VXLAN encapsulation, uses configuration set by \"set"
3160 .priv = PRIV_ACTION(VXLAN_ENCAP,
3161 sizeof(struct action_vxlan_encap_data)),
3162 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3163 .call = parse_vc_action_vxlan_encap,
3165 [ACTION_VXLAN_DECAP] = {
3166 .name = "vxlan_decap",
3167 .help = "Performs a decapsulation action by stripping all"
3168 " headers of the VXLAN tunnel network overlay from the"
3170 .priv = PRIV_ACTION(VXLAN_DECAP, 0),
3171 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3174 [ACTION_NVGRE_ENCAP] = {
3175 .name = "nvgre_encap",
3176 .help = "NVGRE encapsulation, uses configuration set by \"set"
3178 .priv = PRIV_ACTION(NVGRE_ENCAP,
3179 sizeof(struct action_nvgre_encap_data)),
3180 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3181 .call = parse_vc_action_nvgre_encap,
3183 [ACTION_NVGRE_DECAP] = {
3184 .name = "nvgre_decap",
3185 .help = "Performs a decapsulation action by stripping all"
3186 " headers of the NVGRE tunnel network overlay from the"
3188 .priv = PRIV_ACTION(NVGRE_DECAP, 0),
3189 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3192 [ACTION_L2_ENCAP] = {
3194 .help = "l2 encap, uses configuration set by"
3195 " \"set l2_encap\"",
3196 .priv = PRIV_ACTION(RAW_ENCAP,
3197 sizeof(struct action_raw_encap_data)),
3198 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3199 .call = parse_vc_action_l2_encap,
3201 [ACTION_L2_DECAP] = {
3203 .help = "l2 decap, uses configuration set by"
3204 " \"set l2_decap\"",
3205 .priv = PRIV_ACTION(RAW_DECAP,
3206 sizeof(struct action_raw_decap_data)),
3207 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3208 .call = parse_vc_action_l2_decap,
3210 [ACTION_MPLSOGRE_ENCAP] = {
3211 .name = "mplsogre_encap",
3212 .help = "mplsogre encapsulation, uses configuration set by"
3213 " \"set mplsogre_encap\"",
3214 .priv = PRIV_ACTION(RAW_ENCAP,
3215 sizeof(struct action_raw_encap_data)),
3216 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3217 .call = parse_vc_action_mplsogre_encap,
3219 [ACTION_MPLSOGRE_DECAP] = {
3220 .name = "mplsogre_decap",
3221 .help = "mplsogre decapsulation, uses configuration set by"
3222 " \"set mplsogre_decap\"",
3223 .priv = PRIV_ACTION(RAW_DECAP,
3224 sizeof(struct action_raw_decap_data)),
3225 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3226 .call = parse_vc_action_mplsogre_decap,
3228 [ACTION_MPLSOUDP_ENCAP] = {
3229 .name = "mplsoudp_encap",
3230 .help = "mplsoudp encapsulation, uses configuration set by"
3231 " \"set mplsoudp_encap\"",
3232 .priv = PRIV_ACTION(RAW_ENCAP,
3233 sizeof(struct action_raw_encap_data)),
3234 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3235 .call = parse_vc_action_mplsoudp_encap,
3237 [ACTION_MPLSOUDP_DECAP] = {
3238 .name = "mplsoudp_decap",
3239 .help = "mplsoudp decapsulation, uses configuration set by"
3240 " \"set mplsoudp_decap\"",
3241 .priv = PRIV_ACTION(RAW_DECAP,
3242 sizeof(struct action_raw_decap_data)),
3243 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3244 .call = parse_vc_action_mplsoudp_decap,
3246 [ACTION_SET_IPV4_SRC] = {
3247 .name = "set_ipv4_src",
3248 .help = "Set a new IPv4 source address in the outermost"
3250 .priv = PRIV_ACTION(SET_IPV4_SRC,
3251 sizeof(struct rte_flow_action_set_ipv4)),
3252 .next = NEXT(action_set_ipv4_src),
3255 [ACTION_SET_IPV4_SRC_IPV4_SRC] = {
3256 .name = "ipv4_addr",
3257 .help = "new IPv4 source address to set",
3258 .next = NEXT(action_set_ipv4_src, NEXT_ENTRY(IPV4_ADDR)),
3259 .args = ARGS(ARGS_ENTRY_HTON
3260 (struct rte_flow_action_set_ipv4, ipv4_addr)),
3261 .call = parse_vc_conf,
3263 [ACTION_SET_IPV4_DST] = {
3264 .name = "set_ipv4_dst",
3265 .help = "Set a new IPv4 destination address in the outermost"
3267 .priv = PRIV_ACTION(SET_IPV4_DST,
3268 sizeof(struct rte_flow_action_set_ipv4)),
3269 .next = NEXT(action_set_ipv4_dst),
3272 [ACTION_SET_IPV4_DST_IPV4_DST] = {
3273 .name = "ipv4_addr",
3274 .help = "new IPv4 destination address to set",
3275 .next = NEXT(action_set_ipv4_dst, NEXT_ENTRY(IPV4_ADDR)),
3276 .args = ARGS(ARGS_ENTRY_HTON
3277 (struct rte_flow_action_set_ipv4, ipv4_addr)),
3278 .call = parse_vc_conf,
3280 [ACTION_SET_IPV6_SRC] = {
3281 .name = "set_ipv6_src",
3282 .help = "Set a new IPv6 source address in the outermost"
3284 .priv = PRIV_ACTION(SET_IPV6_SRC,
3285 sizeof(struct rte_flow_action_set_ipv6)),
3286 .next = NEXT(action_set_ipv6_src),
3289 [ACTION_SET_IPV6_SRC_IPV6_SRC] = {
3290 .name = "ipv6_addr",
3291 .help = "new IPv6 source address to set",
3292 .next = NEXT(action_set_ipv6_src, NEXT_ENTRY(IPV6_ADDR)),
3293 .args = ARGS(ARGS_ENTRY_HTON
3294 (struct rte_flow_action_set_ipv6, ipv6_addr)),
3295 .call = parse_vc_conf,
3297 [ACTION_SET_IPV6_DST] = {
3298 .name = "set_ipv6_dst",
3299 .help = "Set a new IPv6 destination address in the outermost"
3301 .priv = PRIV_ACTION(SET_IPV6_DST,
3302 sizeof(struct rte_flow_action_set_ipv6)),
3303 .next = NEXT(action_set_ipv6_dst),
3306 [ACTION_SET_IPV6_DST_IPV6_DST] = {
3307 .name = "ipv6_addr",
3308 .help = "new IPv6 destination address to set",
3309 .next = NEXT(action_set_ipv6_dst, NEXT_ENTRY(IPV6_ADDR)),
3310 .args = ARGS(ARGS_ENTRY_HTON
3311 (struct rte_flow_action_set_ipv6, ipv6_addr)),
3312 .call = parse_vc_conf,
3314 [ACTION_SET_TP_SRC] = {
3315 .name = "set_tp_src",
3316 .help = "set a new source port number in the outermost"
3318 .priv = PRIV_ACTION(SET_TP_SRC,
3319 sizeof(struct rte_flow_action_set_tp)),
3320 .next = NEXT(action_set_tp_src),
3323 [ACTION_SET_TP_SRC_TP_SRC] = {
3325 .help = "new source port number to set",
3326 .next = NEXT(action_set_tp_src, NEXT_ENTRY(UNSIGNED)),
3327 .args = ARGS(ARGS_ENTRY_HTON
3328 (struct rte_flow_action_set_tp, port)),
3329 .call = parse_vc_conf,
3331 [ACTION_SET_TP_DST] = {
3332 .name = "set_tp_dst",
3333 .help = "set a new destination port number in the outermost"
3335 .priv = PRIV_ACTION(SET_TP_DST,
3336 sizeof(struct rte_flow_action_set_tp)),
3337 .next = NEXT(action_set_tp_dst),
3340 [ACTION_SET_TP_DST_TP_DST] = {
3342 .help = "new destination port number to set",
3343 .next = NEXT(action_set_tp_dst, NEXT_ENTRY(UNSIGNED)),
3344 .args = ARGS(ARGS_ENTRY_HTON
3345 (struct rte_flow_action_set_tp, port)),
3346 .call = parse_vc_conf,
3348 [ACTION_MAC_SWAP] = {
3350 .help = "Swap the source and destination MAC addresses"
3351 " in the outermost Ethernet header",
3352 .priv = PRIV_ACTION(MAC_SWAP, 0),
3353 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3356 [ACTION_DEC_TTL] = {
3358 .help = "decrease network TTL if available",
3359 .priv = PRIV_ACTION(DEC_TTL, 0),
3360 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3363 [ACTION_SET_TTL] = {
3365 .help = "set ttl value",
3366 .priv = PRIV_ACTION(SET_TTL,
3367 sizeof(struct rte_flow_action_set_ttl)),
3368 .next = NEXT(action_set_ttl),
3371 [ACTION_SET_TTL_TTL] = {
3372 .name = "ttl_value",
3373 .help = "new ttl value to set",
3374 .next = NEXT(action_set_ttl, NEXT_ENTRY(UNSIGNED)),
3375 .args = ARGS(ARGS_ENTRY_HTON
3376 (struct rte_flow_action_set_ttl, ttl_value)),
3377 .call = parse_vc_conf,
3379 [ACTION_SET_MAC_SRC] = {
3380 .name = "set_mac_src",
3381 .help = "set source mac address",
3382 .priv = PRIV_ACTION(SET_MAC_SRC,
3383 sizeof(struct rte_flow_action_set_mac)),
3384 .next = NEXT(action_set_mac_src),
3387 [ACTION_SET_MAC_SRC_MAC_SRC] = {
3389 .help = "new source mac address",
3390 .next = NEXT(action_set_mac_src, NEXT_ENTRY(MAC_ADDR)),
3391 .args = ARGS(ARGS_ENTRY_HTON
3392 (struct rte_flow_action_set_mac, mac_addr)),
3393 .call = parse_vc_conf,
3395 [ACTION_SET_MAC_DST] = {
3396 .name = "set_mac_dst",
3397 .help = "set destination mac address",
3398 .priv = PRIV_ACTION(SET_MAC_DST,
3399 sizeof(struct rte_flow_action_set_mac)),
3400 .next = NEXT(action_set_mac_dst),
3403 [ACTION_SET_MAC_DST_MAC_DST] = {
3405 .help = "new destination mac address to set",
3406 .next = NEXT(action_set_mac_dst, NEXT_ENTRY(MAC_ADDR)),
3407 .args = ARGS(ARGS_ENTRY_HTON
3408 (struct rte_flow_action_set_mac, mac_addr)),
3409 .call = parse_vc_conf,
3411 [ACTION_INC_TCP_SEQ] = {
3412 .name = "inc_tcp_seq",
3413 .help = "increase TCP sequence number",
3414 .priv = PRIV_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
3415 .next = NEXT(action_inc_tcp_seq),
3418 [ACTION_INC_TCP_SEQ_VALUE] = {
3420 .help = "the value to increase TCP sequence number by",
3421 .next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(UNSIGNED)),
3422 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3423 .call = parse_vc_conf,
3425 [ACTION_DEC_TCP_SEQ] = {
3426 .name = "dec_tcp_seq",
3427 .help = "decrease TCP sequence number",
3428 .priv = PRIV_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
3429 .next = NEXT(action_dec_tcp_seq),
3432 [ACTION_DEC_TCP_SEQ_VALUE] = {
3434 .help = "the value to decrease TCP sequence number by",
3435 .next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(UNSIGNED)),
3436 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3437 .call = parse_vc_conf,
3439 [ACTION_INC_TCP_ACK] = {
3440 .name = "inc_tcp_ack",
3441 .help = "increase TCP acknowledgment number",
3442 .priv = PRIV_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
3443 .next = NEXT(action_inc_tcp_ack),
3446 [ACTION_INC_TCP_ACK_VALUE] = {
3448 .help = "the value to increase TCP acknowledgment number by",
3449 .next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(UNSIGNED)),
3450 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3451 .call = parse_vc_conf,
3453 [ACTION_DEC_TCP_ACK] = {
3454 .name = "dec_tcp_ack",
3455 .help = "decrease TCP acknowledgment number",
3456 .priv = PRIV_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
3457 .next = NEXT(action_dec_tcp_ack),
3460 [ACTION_DEC_TCP_ACK_VALUE] = {
3462 .help = "the value to decrease TCP acknowledgment number by",
3463 .next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(UNSIGNED)),
3464 .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
3465 .call = parse_vc_conf,
3467 [ACTION_RAW_ENCAP] = {
3468 .name = "raw_encap",
3469 .help = "encapsulation data, defined by set raw_encap",
3470 .priv = PRIV_ACTION(RAW_ENCAP,
3471 sizeof(struct action_raw_encap_data)),
3472 .next = NEXT(action_raw_encap),
3473 .call = parse_vc_action_raw_encap,
3475 [ACTION_RAW_ENCAP_INDEX] = {
3477 .help = "the index of raw_encap_confs",
3478 .next = NEXT(NEXT_ENTRY(ACTION_RAW_ENCAP_INDEX_VALUE)),
3480 [ACTION_RAW_ENCAP_INDEX_VALUE] = {
3483 .help = "unsigned integer value",
3484 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3485 .call = parse_vc_action_raw_encap_index,
3486 .comp = comp_set_raw_index,
3488 [ACTION_RAW_DECAP] = {
3489 .name = "raw_decap",
3490 .help = "decapsulation data, defined by set raw_encap",
3491 .priv = PRIV_ACTION(RAW_DECAP,
3492 sizeof(struct action_raw_decap_data)),
3493 .next = NEXT(action_raw_decap),
3494 .call = parse_vc_action_raw_decap,
3496 [ACTION_RAW_DECAP_INDEX] = {
3498 .help = "the index of raw_encap_confs",
3499 .next = NEXT(NEXT_ENTRY(ACTION_RAW_DECAP_INDEX_VALUE)),
3501 [ACTION_RAW_DECAP_INDEX_VALUE] = {
3504 .help = "unsigned integer value",
3505 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
3506 .call = parse_vc_action_raw_decap_index,
3507 .comp = comp_set_raw_index,
3509 /* Top level command. */
3512 .help = "set raw encap/decap data",
3513 .type = "set raw_encap|raw_decap <index> <pattern>",
3514 .next = NEXT(NEXT_ENTRY
3517 .call = parse_set_init,
3519 /* Sub-level commands. */
3521 .name = "raw_encap",
3522 .help = "set raw encap data",
3523 .next = NEXT(next_set_raw),
3524 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
3525 (offsetof(struct buffer, port),
3526 sizeof(((struct buffer *)0)->port),
3527 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
3528 .call = parse_set_raw_encap_decap,
3531 .name = "raw_decap",
3532 .help = "set raw decap data",
3533 .next = NEXT(next_set_raw),
3534 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
3535 (offsetof(struct buffer, port),
3536 sizeof(((struct buffer *)0)->port),
3537 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
3538 .call = parse_set_raw_encap_decap,
3543 .help = "index of raw_encap/raw_decap data",
3544 .next = NEXT(next_item),
3547 [ACTION_SET_TAG] = {
3550 .priv = PRIV_ACTION(SET_TAG,
3551 sizeof(struct rte_flow_action_set_tag)),
3552 .next = NEXT(action_set_tag),
3555 [ACTION_SET_TAG_INDEX] = {
3557 .help = "index of tag array",
3558 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
3559 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_set_tag, index)),
3560 .call = parse_vc_conf,
3562 [ACTION_SET_TAG_DATA] = {
3564 .help = "tag value",
3565 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
3566 .args = ARGS(ARGS_ENTRY
3567 (struct rte_flow_action_set_tag, data)),
3568 .call = parse_vc_conf,
3570 [ACTION_SET_TAG_MASK] = {
3572 .help = "mask for tag value",
3573 .next = NEXT(action_set_tag, NEXT_ENTRY(UNSIGNED)),
3574 .args = ARGS(ARGS_ENTRY
3575 (struct rte_flow_action_set_tag, mask)),
3576 .call = parse_vc_conf,
3578 [ACTION_SET_META] = {
3580 .help = "set metadata",
3581 .priv = PRIV_ACTION(SET_META,
3582 sizeof(struct rte_flow_action_set_meta)),
3583 .next = NEXT(action_set_meta),
3584 .call = parse_vc_action_set_meta,
3586 [ACTION_SET_META_DATA] = {
3588 .help = "metadata value",
3589 .next = NEXT(action_set_meta, NEXT_ENTRY(UNSIGNED)),
3590 .args = ARGS(ARGS_ENTRY
3591 (struct rte_flow_action_set_meta, data)),
3592 .call = parse_vc_conf,
3594 [ACTION_SET_META_MASK] = {
3596 .help = "mask for metadata value",
3597 .next = NEXT(action_set_meta, NEXT_ENTRY(UNSIGNED)),
3598 .args = ARGS(ARGS_ENTRY
3599 (struct rte_flow_action_set_meta, mask)),
3600 .call = parse_vc_conf,
3602 [ACTION_SET_IPV4_DSCP] = {
3603 .name = "set_ipv4_dscp",
3604 .help = "set DSCP value",
3605 .priv = PRIV_ACTION(SET_IPV4_DSCP,
3606 sizeof(struct rte_flow_action_set_dscp)),
3607 .next = NEXT(action_set_ipv4_dscp),
3610 [ACTION_SET_IPV4_DSCP_VALUE] = {
3611 .name = "dscp_value",
3612 .help = "new IPv4 DSCP value to set",
3613 .next = NEXT(action_set_ipv4_dscp, NEXT_ENTRY(UNSIGNED)),
3614 .args = ARGS(ARGS_ENTRY
3615 (struct rte_flow_action_set_dscp, dscp)),
3616 .call = parse_vc_conf,
3618 [ACTION_SET_IPV6_DSCP] = {
3619 .name = "set_ipv6_dscp",
3620 .help = "set DSCP value",
3621 .priv = PRIV_ACTION(SET_IPV6_DSCP,
3622 sizeof(struct rte_flow_action_set_dscp)),
3623 .next = NEXT(action_set_ipv6_dscp),
3626 [ACTION_SET_IPV6_DSCP_VALUE] = {
3627 .name = "dscp_value",
3628 .help = "new IPv6 DSCP value to set",
3629 .next = NEXT(action_set_ipv6_dscp, NEXT_ENTRY(UNSIGNED)),
3630 .args = ARGS(ARGS_ENTRY
3631 (struct rte_flow_action_set_dscp, dscp)),
3632 .call = parse_vc_conf,
3636 /** Remove and return last entry from argument stack. */
3637 static const struct arg *
3638 pop_args(struct context *ctx)
3640 return ctx->args_num ? ctx->args[--ctx->args_num] : NULL;
3643 /** Add entry on top of the argument stack. */
3645 push_args(struct context *ctx, const struct arg *arg)
3647 if (ctx->args_num == CTX_STACK_SIZE)
3649 ctx->args[ctx->args_num++] = arg;
3653 /** Spread value into buffer according to bit-mask. */
3655 arg_entry_bf_fill(void *dst, uintmax_t val, const struct arg *arg)
3657 uint32_t i = arg->size;
3665 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
3674 unsigned int shift = 0;
3675 uint8_t *buf = (uint8_t *)dst + arg->offset + (i -= sub);
3677 for (shift = 0; arg->mask[i] >> shift; ++shift) {
3678 if (!(arg->mask[i] & (1 << shift)))
3683 *buf &= ~(1 << shift);
3684 *buf |= (val & 1) << shift;
3692 /** Compare a string with a partial one of a given length. */
3694 strcmp_partial(const char *full, const char *partial, size_t partial_len)
3696 int r = strncmp(full, partial, partial_len);
3700 if (strlen(full) <= partial_len)
3702 return full[partial_len];
3706 * Parse a prefix length and generate a bit-mask.
3708 * Last argument (ctx->args) is retrieved to determine mask size, storage
3709 * location and whether the result must use network byte ordering.
3712 parse_prefix(struct context *ctx, const struct token *token,
3713 const char *str, unsigned int len,
3714 void *buf, unsigned int size)
3716 const struct arg *arg = pop_args(ctx);
3717 static const uint8_t conv[] = "\x00\x80\xc0\xe0\xf0\xf8\xfc\xfe\xff";
3724 /* Argument is expected. */
3728 u = strtoumax(str, &end, 0);
3729 if (errno || (size_t)(end - str) != len)
3734 extra = arg_entry_bf_fill(NULL, 0, arg);
3743 if (!arg_entry_bf_fill(ctx->object, v, arg) ||
3744 !arg_entry_bf_fill(ctx->objmask, -1, arg))
3751 if (bytes > size || bytes + !!extra > size)
3755 buf = (uint8_t *)ctx->object + arg->offset;
3756 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
3758 memset((uint8_t *)buf + size - bytes, 0xff, bytes);
3759 memset(buf, 0x00, size - bytes);
3761 ((uint8_t *)buf)[size - bytes - 1] = conv[extra];
3765 memset(buf, 0xff, bytes);
3766 memset((uint8_t *)buf + bytes, 0x00, size - bytes);
3768 ((uint8_t *)buf)[bytes] = conv[extra];
3771 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
3774 push_args(ctx, arg);
3778 /** Default parsing function for token name matching. */
3780 parse_default(struct context *ctx, const struct token *token,
3781 const char *str, unsigned int len,
3782 void *buf, unsigned int size)
3787 if (strcmp_partial(token->name, str, len))
3792 /** Parse flow command, initialize output buffer for subsequent tokens. */
3794 parse_init(struct context *ctx, const struct token *token,
3795 const char *str, unsigned int len,
3796 void *buf, unsigned int size)
3798 struct buffer *out = buf;
3800 /* Token name must match. */
3801 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
3803 /* Nothing else to do if there is no buffer. */
3806 /* Make sure buffer is large enough. */
3807 if (size < sizeof(*out))
3809 /* Initialize buffer. */
3810 memset(out, 0x00, sizeof(*out));
3811 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
3814 ctx->objmask = NULL;
3818 /** Parse tokens for validate/create commands. */
3820 parse_vc(struct context *ctx, const struct token *token,
3821 const char *str, unsigned int len,
3822 void *buf, unsigned int size)
3824 struct buffer *out = buf;
3828 /* Token name must match. */
3829 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
3831 /* Nothing else to do if there is no buffer. */
3834 if (!out->command) {
3835 if (ctx->curr != VALIDATE && ctx->curr != CREATE)
3837 if (sizeof(*out) > size)
3839 out->command = ctx->curr;
3842 ctx->objmask = NULL;
3843 out->args.vc.data = (uint8_t *)out + size;
3847 ctx->object = &out->args.vc.attr;
3848 ctx->objmask = NULL;
3849 switch (ctx->curr) {
3854 out->args.vc.attr.ingress = 1;
3857 out->args.vc.attr.egress = 1;
3860 out->args.vc.attr.transfer = 1;
3863 out->args.vc.pattern =
3864 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
3866 ctx->object = out->args.vc.pattern;
3867 ctx->objmask = NULL;
3870 out->args.vc.actions =
3871 (void *)RTE_ALIGN_CEIL((uintptr_t)
3872 (out->args.vc.pattern +
3873 out->args.vc.pattern_n),
3875 ctx->object = out->args.vc.actions;
3876 ctx->objmask = NULL;
3883 if (!out->args.vc.actions) {
3884 const struct parse_item_priv *priv = token->priv;
3885 struct rte_flow_item *item =
3886 out->args.vc.pattern + out->args.vc.pattern_n;
3888 data_size = priv->size * 3; /* spec, last, mask */
3889 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
3890 (out->args.vc.data - data_size),
3892 if ((uint8_t *)item + sizeof(*item) > data)
3894 *item = (struct rte_flow_item){
3897 ++out->args.vc.pattern_n;
3899 ctx->objmask = NULL;
3901 const struct parse_action_priv *priv = token->priv;
3902 struct rte_flow_action *action =
3903 out->args.vc.actions + out->args.vc.actions_n;
3905 data_size = priv->size; /* configuration */
3906 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
3907 (out->args.vc.data - data_size),
3909 if ((uint8_t *)action + sizeof(*action) > data)
3911 *action = (struct rte_flow_action){
3913 .conf = data_size ? data : NULL,
3915 ++out->args.vc.actions_n;
3916 ctx->object = action;
3917 ctx->objmask = NULL;
3919 memset(data, 0, data_size);
3920 out->args.vc.data = data;
3921 ctx->objdata = data_size;
3925 /** Parse pattern item parameter type. */
3927 parse_vc_spec(struct context *ctx, const struct token *token,
3928 const char *str, unsigned int len,
3929 void *buf, unsigned int size)
3931 struct buffer *out = buf;
3932 struct rte_flow_item *item;
3938 /* Token name must match. */
3939 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
3941 /* Parse parameter types. */
3942 switch (ctx->curr) {
3943 static const enum index prefix[] = NEXT_ENTRY(PREFIX);
3949 case ITEM_PARAM_SPEC:
3952 case ITEM_PARAM_LAST:
3955 case ITEM_PARAM_PREFIX:
3956 /* Modify next token to expect a prefix. */
3957 if (ctx->next_num < 2)
3959 ctx->next[ctx->next_num - 2] = prefix;
3961 case ITEM_PARAM_MASK:
3967 /* Nothing else to do if there is no buffer. */
3970 if (!out->args.vc.pattern_n)
3972 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
3973 data_size = ctx->objdata / 3; /* spec, last, mask */
3974 /* Point to selected object. */
3975 ctx->object = out->args.vc.data + (data_size * index);
3977 ctx->objmask = out->args.vc.data + (data_size * 2); /* mask */
3978 item->mask = ctx->objmask;
3980 ctx->objmask = NULL;
3981 /* Update relevant item pointer. */
3982 *((const void **[]){ &item->spec, &item->last, &item->mask })[index] =
3987 /** Parse action configuration field. */
3989 parse_vc_conf(struct context *ctx, const struct token *token,
3990 const char *str, unsigned int len,
3991 void *buf, unsigned int size)
3993 struct buffer *out = buf;
3996 /* Token name must match. */
3997 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
3999 /* Nothing else to do if there is no buffer. */
4002 /* Point to selected object. */
4003 ctx->object = out->args.vc.data;
4004 ctx->objmask = NULL;
4008 /** Parse RSS action. */
4010 parse_vc_action_rss(struct context *ctx, const struct token *token,
4011 const char *str, unsigned int len,
4012 void *buf, unsigned int size)
4014 struct buffer *out = buf;
4015 struct rte_flow_action *action;
4016 struct action_rss_data *action_rss_data;
4020 ret = parse_vc(ctx, token, str, len, buf, size);
4023 /* Nothing else to do if there is no buffer. */
4026 if (!out->args.vc.actions_n)
4028 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4029 /* Point to selected object. */
4030 ctx->object = out->args.vc.data;
4031 ctx->objmask = NULL;
4032 /* Set up default configuration. */
4033 action_rss_data = ctx->object;
4034 *action_rss_data = (struct action_rss_data){
4035 .conf = (struct rte_flow_action_rss){
4036 .func = RTE_ETH_HASH_FUNCTION_DEFAULT,
4039 .key_len = sizeof(action_rss_data->key),
4040 .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM),
4041 .key = action_rss_data->key,
4042 .queue = action_rss_data->queue,
4044 .key = "testpmd's default RSS hash key, "
4045 "override it for better balancing",
4048 for (i = 0; i < action_rss_data->conf.queue_num; ++i)
4049 action_rss_data->queue[i] = i;
4050 if (!port_id_is_invalid(ctx->port, DISABLED_WARN) &&
4051 ctx->port != (portid_t)RTE_PORT_ALL) {
4052 struct rte_eth_dev_info info;
4055 ret2 = rte_eth_dev_info_get(ctx->port, &info);
4059 action_rss_data->conf.key_len =
4060 RTE_MIN(sizeof(action_rss_data->key),
4061 info.hash_key_size);
4063 action->conf = &action_rss_data->conf;
4068 * Parse func field for RSS action.
4070 * The RTE_ETH_HASH_FUNCTION_* value to assign is derived from the
4071 * ACTION_RSS_FUNC_* index that called this function.
4074 parse_vc_action_rss_func(struct context *ctx, const struct token *token,
4075 const char *str, unsigned int len,
4076 void *buf, unsigned int size)
4078 struct action_rss_data *action_rss_data;
4079 enum rte_eth_hash_function func;
4083 /* Token name must match. */
4084 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
4086 switch (ctx->curr) {
4087 case ACTION_RSS_FUNC_DEFAULT:
4088 func = RTE_ETH_HASH_FUNCTION_DEFAULT;
4090 case ACTION_RSS_FUNC_TOEPLITZ:
4091 func = RTE_ETH_HASH_FUNCTION_TOEPLITZ;
4093 case ACTION_RSS_FUNC_SIMPLE_XOR:
4094 func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
4096 case ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ:
4097 func = RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
4104 action_rss_data = ctx->object;
4105 action_rss_data->conf.func = func;
4110 * Parse type field for RSS action.
4112 * Valid tokens are type field names and the "end" token.
4115 parse_vc_action_rss_type(struct context *ctx, const struct token *token,
4116 const char *str, unsigned int len,
4117 void *buf, unsigned int size)
4119 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE);
4120 struct action_rss_data *action_rss_data;
4126 if (ctx->curr != ACTION_RSS_TYPE)
4128 if (!(ctx->objdata >> 16) && ctx->object) {
4129 action_rss_data = ctx->object;
4130 action_rss_data->conf.types = 0;
4132 if (!strcmp_partial("end", str, len)) {
4133 ctx->objdata &= 0xffff;
4136 for (i = 0; rss_type_table[i].str; ++i)
4137 if (!strcmp_partial(rss_type_table[i].str, str, len))
4139 if (!rss_type_table[i].str)
4141 ctx->objdata = 1 << 16 | (ctx->objdata & 0xffff);
4143 if (ctx->next_num == RTE_DIM(ctx->next))
4145 ctx->next[ctx->next_num++] = next;
4148 action_rss_data = ctx->object;
4149 action_rss_data->conf.types |= rss_type_table[i].rss_type;
4154 * Parse queue field for RSS action.
4156 * Valid tokens are queue indices and the "end" token.
4159 parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
4160 const char *str, unsigned int len,
4161 void *buf, unsigned int size)
4163 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE);
4164 struct action_rss_data *action_rss_data;
4165 const struct arg *arg;
4172 if (ctx->curr != ACTION_RSS_QUEUE)
4174 i = ctx->objdata >> 16;
4175 if (!strcmp_partial("end", str, len)) {
4176 ctx->objdata &= 0xffff;
4179 if (i >= ACTION_RSS_QUEUE_NUM)
4181 arg = ARGS_ENTRY_ARB(offsetof(struct action_rss_data, queue) +
4182 i * sizeof(action_rss_data->queue[i]),
4183 sizeof(action_rss_data->queue[i]));
4184 if (push_args(ctx, arg))
4186 ret = parse_int(ctx, token, str, len, NULL, 0);
4192 ctx->objdata = i << 16 | (ctx->objdata & 0xffff);
4194 if (ctx->next_num == RTE_DIM(ctx->next))
4196 ctx->next[ctx->next_num++] = next;
4200 action_rss_data = ctx->object;
4201 action_rss_data->conf.queue_num = i;
4202 action_rss_data->conf.queue = i ? action_rss_data->queue : NULL;
4206 /** Parse VXLAN encap action. */
4208 parse_vc_action_vxlan_encap(struct context *ctx, const struct token *token,
4209 const char *str, unsigned int len,
4210 void *buf, unsigned int size)
4212 struct buffer *out = buf;
4213 struct rte_flow_action *action;
4214 struct action_vxlan_encap_data *action_vxlan_encap_data;
4217 ret = parse_vc(ctx, token, str, len, buf, size);
4220 /* Nothing else to do if there is no buffer. */
4223 if (!out->args.vc.actions_n)
4225 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4226 /* Point to selected object. */
4227 ctx->object = out->args.vc.data;
4228 ctx->objmask = NULL;
4229 /* Set up default configuration. */
4230 action_vxlan_encap_data = ctx->object;
4231 *action_vxlan_encap_data = (struct action_vxlan_encap_data){
4232 .conf = (struct rte_flow_action_vxlan_encap){
4233 .definition = action_vxlan_encap_data->items,
4237 .type = RTE_FLOW_ITEM_TYPE_ETH,
4238 .spec = &action_vxlan_encap_data->item_eth,
4239 .mask = &rte_flow_item_eth_mask,
4242 .type = RTE_FLOW_ITEM_TYPE_VLAN,
4243 .spec = &action_vxlan_encap_data->item_vlan,
4244 .mask = &rte_flow_item_vlan_mask,
4247 .type = RTE_FLOW_ITEM_TYPE_IPV4,
4248 .spec = &action_vxlan_encap_data->item_ipv4,
4249 .mask = &rte_flow_item_ipv4_mask,
4252 .type = RTE_FLOW_ITEM_TYPE_UDP,
4253 .spec = &action_vxlan_encap_data->item_udp,
4254 .mask = &rte_flow_item_udp_mask,
4257 .type = RTE_FLOW_ITEM_TYPE_VXLAN,
4258 .spec = &action_vxlan_encap_data->item_vxlan,
4259 .mask = &rte_flow_item_vxlan_mask,
4262 .type = RTE_FLOW_ITEM_TYPE_END,
4267 .tci = vxlan_encap_conf.vlan_tci,
4271 .src_addr = vxlan_encap_conf.ipv4_src,
4272 .dst_addr = vxlan_encap_conf.ipv4_dst,
4275 .src_port = vxlan_encap_conf.udp_src,
4276 .dst_port = vxlan_encap_conf.udp_dst,
4278 .item_vxlan.flags = 0,
4280 memcpy(action_vxlan_encap_data->item_eth.dst.addr_bytes,
4281 vxlan_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
4282 memcpy(action_vxlan_encap_data->item_eth.src.addr_bytes,
4283 vxlan_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
4284 if (!vxlan_encap_conf.select_ipv4) {
4285 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.src_addr,
4286 &vxlan_encap_conf.ipv6_src,
4287 sizeof(vxlan_encap_conf.ipv6_src));
4288 memcpy(&action_vxlan_encap_data->item_ipv6.hdr.dst_addr,
4289 &vxlan_encap_conf.ipv6_dst,
4290 sizeof(vxlan_encap_conf.ipv6_dst));
4291 action_vxlan_encap_data->items[2] = (struct rte_flow_item){
4292 .type = RTE_FLOW_ITEM_TYPE_IPV6,
4293 .spec = &action_vxlan_encap_data->item_ipv6,
4294 .mask = &rte_flow_item_ipv6_mask,
4297 if (!vxlan_encap_conf.select_vlan)
4298 action_vxlan_encap_data->items[1].type =
4299 RTE_FLOW_ITEM_TYPE_VOID;
4300 if (vxlan_encap_conf.select_tos_ttl) {
4301 if (vxlan_encap_conf.select_ipv4) {
4302 static struct rte_flow_item_ipv4 ipv4_mask_tos;
4304 memcpy(&ipv4_mask_tos, &rte_flow_item_ipv4_mask,
4305 sizeof(ipv4_mask_tos));
4306 ipv4_mask_tos.hdr.type_of_service = 0xff;
4307 ipv4_mask_tos.hdr.time_to_live = 0xff;
4308 action_vxlan_encap_data->item_ipv4.hdr.type_of_service =
4309 vxlan_encap_conf.ip_tos;
4310 action_vxlan_encap_data->item_ipv4.hdr.time_to_live =
4311 vxlan_encap_conf.ip_ttl;
4312 action_vxlan_encap_data->items[2].mask =
4315 static struct rte_flow_item_ipv6 ipv6_mask_tos;
4317 memcpy(&ipv6_mask_tos, &rte_flow_item_ipv6_mask,
4318 sizeof(ipv6_mask_tos));
4319 ipv6_mask_tos.hdr.vtc_flow |=
4320 RTE_BE32(0xfful << RTE_IPV6_HDR_TC_SHIFT);
4321 ipv6_mask_tos.hdr.hop_limits = 0xff;
4322 action_vxlan_encap_data->item_ipv6.hdr.vtc_flow |=
4324 ((uint32_t)vxlan_encap_conf.ip_tos <<
4325 RTE_IPV6_HDR_TC_SHIFT);
4326 action_vxlan_encap_data->item_ipv6.hdr.hop_limits =
4327 vxlan_encap_conf.ip_ttl;
4328 action_vxlan_encap_data->items[2].mask =
4332 memcpy(action_vxlan_encap_data->item_vxlan.vni, vxlan_encap_conf.vni,
4333 RTE_DIM(vxlan_encap_conf.vni));
4334 action->conf = &action_vxlan_encap_data->conf;
4338 /** Parse NVGRE encap action. */
4340 parse_vc_action_nvgre_encap(struct context *ctx, const struct token *token,
4341 const char *str, unsigned int len,
4342 void *buf, unsigned int size)
4344 struct buffer *out = buf;
4345 struct rte_flow_action *action;
4346 struct action_nvgre_encap_data *action_nvgre_encap_data;
4349 ret = parse_vc(ctx, token, str, len, buf, size);
4352 /* Nothing else to do if there is no buffer. */
4355 if (!out->args.vc.actions_n)
4357 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4358 /* Point to selected object. */
4359 ctx->object = out->args.vc.data;
4360 ctx->objmask = NULL;
4361 /* Set up default configuration. */
4362 action_nvgre_encap_data = ctx->object;
4363 *action_nvgre_encap_data = (struct action_nvgre_encap_data){
4364 .conf = (struct rte_flow_action_nvgre_encap){
4365 .definition = action_nvgre_encap_data->items,
4369 .type = RTE_FLOW_ITEM_TYPE_ETH,
4370 .spec = &action_nvgre_encap_data->item_eth,
4371 .mask = &rte_flow_item_eth_mask,
4374 .type = RTE_FLOW_ITEM_TYPE_VLAN,
4375 .spec = &action_nvgre_encap_data->item_vlan,
4376 .mask = &rte_flow_item_vlan_mask,
4379 .type = RTE_FLOW_ITEM_TYPE_IPV4,
4380 .spec = &action_nvgre_encap_data->item_ipv4,
4381 .mask = &rte_flow_item_ipv4_mask,
4384 .type = RTE_FLOW_ITEM_TYPE_NVGRE,
4385 .spec = &action_nvgre_encap_data->item_nvgre,
4386 .mask = &rte_flow_item_nvgre_mask,
4389 .type = RTE_FLOW_ITEM_TYPE_END,
4394 .tci = nvgre_encap_conf.vlan_tci,
4398 .src_addr = nvgre_encap_conf.ipv4_src,
4399 .dst_addr = nvgre_encap_conf.ipv4_dst,
4401 .item_nvgre.flow_id = 0,
4403 memcpy(action_nvgre_encap_data->item_eth.dst.addr_bytes,
4404 nvgre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
4405 memcpy(action_nvgre_encap_data->item_eth.src.addr_bytes,
4406 nvgre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
4407 if (!nvgre_encap_conf.select_ipv4) {
4408 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.src_addr,
4409 &nvgre_encap_conf.ipv6_src,
4410 sizeof(nvgre_encap_conf.ipv6_src));
4411 memcpy(&action_nvgre_encap_data->item_ipv6.hdr.dst_addr,
4412 &nvgre_encap_conf.ipv6_dst,
4413 sizeof(nvgre_encap_conf.ipv6_dst));
4414 action_nvgre_encap_data->items[2] = (struct rte_flow_item){
4415 .type = RTE_FLOW_ITEM_TYPE_IPV6,
4416 .spec = &action_nvgre_encap_data->item_ipv6,
4417 .mask = &rte_flow_item_ipv6_mask,
4420 if (!nvgre_encap_conf.select_vlan)
4421 action_nvgre_encap_data->items[1].type =
4422 RTE_FLOW_ITEM_TYPE_VOID;
4423 memcpy(action_nvgre_encap_data->item_nvgre.tni, nvgre_encap_conf.tni,
4424 RTE_DIM(nvgre_encap_conf.tni));
4425 action->conf = &action_nvgre_encap_data->conf;
4429 /** Parse l2 encap action. */
4431 parse_vc_action_l2_encap(struct context *ctx, const struct token *token,
4432 const char *str, unsigned int len,
4433 void *buf, unsigned int size)
4435 struct buffer *out = buf;
4436 struct rte_flow_action *action;
4437 struct action_raw_encap_data *action_encap_data;
4438 struct rte_flow_item_eth eth = { .type = 0, };
4439 struct rte_flow_item_vlan vlan = {
4440 .tci = mplsoudp_encap_conf.vlan_tci,
4446 ret = parse_vc(ctx, token, str, len, buf, size);
4449 /* Nothing else to do if there is no buffer. */
4452 if (!out->args.vc.actions_n)
4454 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4455 /* Point to selected object. */
4456 ctx->object = out->args.vc.data;
4457 ctx->objmask = NULL;
4458 /* Copy the headers to the buffer. */
4459 action_encap_data = ctx->object;
4460 *action_encap_data = (struct action_raw_encap_data) {
4461 .conf = (struct rte_flow_action_raw_encap){
4462 .data = action_encap_data->data,
4466 header = action_encap_data->data;
4467 if (l2_encap_conf.select_vlan)
4468 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
4469 else if (l2_encap_conf.select_ipv4)
4470 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
4472 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
4473 memcpy(eth.dst.addr_bytes,
4474 l2_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
4475 memcpy(eth.src.addr_bytes,
4476 l2_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
4477 memcpy(header, ð, sizeof(eth));
4478 header += sizeof(eth);
4479 if (l2_encap_conf.select_vlan) {
4480 if (l2_encap_conf.select_ipv4)
4481 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
4483 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
4484 memcpy(header, &vlan, sizeof(vlan));
4485 header += sizeof(vlan);
4487 action_encap_data->conf.size = header -
4488 action_encap_data->data;
4489 action->conf = &action_encap_data->conf;
4493 /** Parse l2 decap action. */
4495 parse_vc_action_l2_decap(struct context *ctx, const struct token *token,
4496 const char *str, unsigned int len,
4497 void *buf, unsigned int size)
4499 struct buffer *out = buf;
4500 struct rte_flow_action *action;
4501 struct action_raw_decap_data *action_decap_data;
4502 struct rte_flow_item_eth eth = { .type = 0, };
4503 struct rte_flow_item_vlan vlan = {
4504 .tci = mplsoudp_encap_conf.vlan_tci,
4510 ret = parse_vc(ctx, token, str, len, buf, size);
4513 /* Nothing else to do if there is no buffer. */
4516 if (!out->args.vc.actions_n)
4518 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4519 /* Point to selected object. */
4520 ctx->object = out->args.vc.data;
4521 ctx->objmask = NULL;
4522 /* Copy the headers to the buffer. */
4523 action_decap_data = ctx->object;
4524 *action_decap_data = (struct action_raw_decap_data) {
4525 .conf = (struct rte_flow_action_raw_decap){
4526 .data = action_decap_data->data,
4530 header = action_decap_data->data;
4531 if (l2_decap_conf.select_vlan)
4532 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
4533 memcpy(header, ð, sizeof(eth));
4534 header += sizeof(eth);
4535 if (l2_decap_conf.select_vlan) {
4536 memcpy(header, &vlan, sizeof(vlan));
4537 header += sizeof(vlan);
4539 action_decap_data->conf.size = header -
4540 action_decap_data->data;
4541 action->conf = &action_decap_data->conf;
4545 #define ETHER_TYPE_MPLS_UNICAST 0x8847
4547 /** Parse MPLSOGRE encap action. */
4549 parse_vc_action_mplsogre_encap(struct context *ctx, const struct token *token,
4550 const char *str, unsigned int len,
4551 void *buf, unsigned int size)
4553 struct buffer *out = buf;
4554 struct rte_flow_action *action;
4555 struct action_raw_encap_data *action_encap_data;
4556 struct rte_flow_item_eth eth = { .type = 0, };
4557 struct rte_flow_item_vlan vlan = {
4558 .tci = mplsogre_encap_conf.vlan_tci,
4561 struct rte_flow_item_ipv4 ipv4 = {
4563 .src_addr = mplsogre_encap_conf.ipv4_src,
4564 .dst_addr = mplsogre_encap_conf.ipv4_dst,
4565 .next_proto_id = IPPROTO_GRE,
4566 .version_ihl = RTE_IPV4_VHL_DEF,
4567 .time_to_live = IPDEFTTL,
4570 struct rte_flow_item_ipv6 ipv6 = {
4572 .proto = IPPROTO_GRE,
4573 .hop_limits = IPDEFTTL,
4576 struct rte_flow_item_gre gre = {
4577 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
4579 struct rte_flow_item_mpls mpls = {
4585 ret = parse_vc(ctx, token, str, len, buf, size);
4588 /* Nothing else to do if there is no buffer. */
4591 if (!out->args.vc.actions_n)
4593 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4594 /* Point to selected object. */
4595 ctx->object = out->args.vc.data;
4596 ctx->objmask = NULL;
4597 /* Copy the headers to the buffer. */
4598 action_encap_data = ctx->object;
4599 *action_encap_data = (struct action_raw_encap_data) {
4600 .conf = (struct rte_flow_action_raw_encap){
4601 .data = action_encap_data->data,
4606 header = action_encap_data->data;
4607 if (mplsogre_encap_conf.select_vlan)
4608 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
4609 else if (mplsogre_encap_conf.select_ipv4)
4610 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
4612 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
4613 memcpy(eth.dst.addr_bytes,
4614 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
4615 memcpy(eth.src.addr_bytes,
4616 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
4617 memcpy(header, ð, sizeof(eth));
4618 header += sizeof(eth);
4619 if (mplsogre_encap_conf.select_vlan) {
4620 if (mplsogre_encap_conf.select_ipv4)
4621 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
4623 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
4624 memcpy(header, &vlan, sizeof(vlan));
4625 header += sizeof(vlan);
4627 if (mplsogre_encap_conf.select_ipv4) {
4628 memcpy(header, &ipv4, sizeof(ipv4));
4629 header += sizeof(ipv4);
4631 memcpy(&ipv6.hdr.src_addr,
4632 &mplsogre_encap_conf.ipv6_src,
4633 sizeof(mplsogre_encap_conf.ipv6_src));
4634 memcpy(&ipv6.hdr.dst_addr,
4635 &mplsogre_encap_conf.ipv6_dst,
4636 sizeof(mplsogre_encap_conf.ipv6_dst));
4637 memcpy(header, &ipv6, sizeof(ipv6));
4638 header += sizeof(ipv6);
4640 memcpy(header, &gre, sizeof(gre));
4641 header += sizeof(gre);
4642 memcpy(mpls.label_tc_s, mplsogre_encap_conf.label,
4643 RTE_DIM(mplsogre_encap_conf.label));
4644 mpls.label_tc_s[2] |= 0x1;
4645 memcpy(header, &mpls, sizeof(mpls));
4646 header += sizeof(mpls);
4647 action_encap_data->conf.size = header -
4648 action_encap_data->data;
4649 action->conf = &action_encap_data->conf;
4653 /** Parse MPLSOGRE decap action. */
4655 parse_vc_action_mplsogre_decap(struct context *ctx, const struct token *token,
4656 const char *str, unsigned int len,
4657 void *buf, unsigned int size)
4659 struct buffer *out = buf;
4660 struct rte_flow_action *action;
4661 struct action_raw_decap_data *action_decap_data;
4662 struct rte_flow_item_eth eth = { .type = 0, };
4663 struct rte_flow_item_vlan vlan = {.tci = 0};
4664 struct rte_flow_item_ipv4 ipv4 = {
4666 .next_proto_id = IPPROTO_GRE,
4669 struct rte_flow_item_ipv6 ipv6 = {
4671 .proto = IPPROTO_GRE,
4674 struct rte_flow_item_gre gre = {
4675 .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
4677 struct rte_flow_item_mpls mpls;
4681 ret = parse_vc(ctx, token, str, len, buf, size);
4684 /* Nothing else to do if there is no buffer. */
4687 if (!out->args.vc.actions_n)
4689 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4690 /* Point to selected object. */
4691 ctx->object = out->args.vc.data;
4692 ctx->objmask = NULL;
4693 /* Copy the headers to the buffer. */
4694 action_decap_data = ctx->object;
4695 *action_decap_data = (struct action_raw_decap_data) {
4696 .conf = (struct rte_flow_action_raw_decap){
4697 .data = action_decap_data->data,
4701 header = action_decap_data->data;
4702 if (mplsogre_decap_conf.select_vlan)
4703 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
4704 else if (mplsogre_encap_conf.select_ipv4)
4705 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
4707 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
4708 memcpy(eth.dst.addr_bytes,
4709 mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
4710 memcpy(eth.src.addr_bytes,
4711 mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
4712 memcpy(header, ð, sizeof(eth));
4713 header += sizeof(eth);
4714 if (mplsogre_encap_conf.select_vlan) {
4715 if (mplsogre_encap_conf.select_ipv4)
4716 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
4718 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
4719 memcpy(header, &vlan, sizeof(vlan));
4720 header += sizeof(vlan);
4722 if (mplsogre_encap_conf.select_ipv4) {
4723 memcpy(header, &ipv4, sizeof(ipv4));
4724 header += sizeof(ipv4);
4726 memcpy(header, &ipv6, sizeof(ipv6));
4727 header += sizeof(ipv6);
4729 memcpy(header, &gre, sizeof(gre));
4730 header += sizeof(gre);
4731 memset(&mpls, 0, sizeof(mpls));
4732 memcpy(header, &mpls, sizeof(mpls));
4733 header += sizeof(mpls);
4734 action_decap_data->conf.size = header -
4735 action_decap_data->data;
4736 action->conf = &action_decap_data->conf;
4740 /** Parse MPLSOUDP encap action. */
4742 parse_vc_action_mplsoudp_encap(struct context *ctx, const struct token *token,
4743 const char *str, unsigned int len,
4744 void *buf, unsigned int size)
4746 struct buffer *out = buf;
4747 struct rte_flow_action *action;
4748 struct action_raw_encap_data *action_encap_data;
4749 struct rte_flow_item_eth eth = { .type = 0, };
4750 struct rte_flow_item_vlan vlan = {
4751 .tci = mplsoudp_encap_conf.vlan_tci,
4754 struct rte_flow_item_ipv4 ipv4 = {
4756 .src_addr = mplsoudp_encap_conf.ipv4_src,
4757 .dst_addr = mplsoudp_encap_conf.ipv4_dst,
4758 .next_proto_id = IPPROTO_UDP,
4759 .version_ihl = RTE_IPV4_VHL_DEF,
4760 .time_to_live = IPDEFTTL,
4763 struct rte_flow_item_ipv6 ipv6 = {
4765 .proto = IPPROTO_UDP,
4766 .hop_limits = IPDEFTTL,
4769 struct rte_flow_item_udp udp = {
4771 .src_port = mplsoudp_encap_conf.udp_src,
4772 .dst_port = mplsoudp_encap_conf.udp_dst,
4775 struct rte_flow_item_mpls mpls;
4779 ret = parse_vc(ctx, token, str, len, buf, size);
4782 /* Nothing else to do if there is no buffer. */
4785 if (!out->args.vc.actions_n)
4787 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4788 /* Point to selected object. */
4789 ctx->object = out->args.vc.data;
4790 ctx->objmask = NULL;
4791 /* Copy the headers to the buffer. */
4792 action_encap_data = ctx->object;
4793 *action_encap_data = (struct action_raw_encap_data) {
4794 .conf = (struct rte_flow_action_raw_encap){
4795 .data = action_encap_data->data,
4800 header = action_encap_data->data;
4801 if (mplsoudp_encap_conf.select_vlan)
4802 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
4803 else if (mplsoudp_encap_conf.select_ipv4)
4804 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
4806 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
4807 memcpy(eth.dst.addr_bytes,
4808 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
4809 memcpy(eth.src.addr_bytes,
4810 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
4811 memcpy(header, ð, sizeof(eth));
4812 header += sizeof(eth);
4813 if (mplsoudp_encap_conf.select_vlan) {
4814 if (mplsoudp_encap_conf.select_ipv4)
4815 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
4817 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
4818 memcpy(header, &vlan, sizeof(vlan));
4819 header += sizeof(vlan);
4821 if (mplsoudp_encap_conf.select_ipv4) {
4822 memcpy(header, &ipv4, sizeof(ipv4));
4823 header += sizeof(ipv4);
4825 memcpy(&ipv6.hdr.src_addr,
4826 &mplsoudp_encap_conf.ipv6_src,
4827 sizeof(mplsoudp_encap_conf.ipv6_src));
4828 memcpy(&ipv6.hdr.dst_addr,
4829 &mplsoudp_encap_conf.ipv6_dst,
4830 sizeof(mplsoudp_encap_conf.ipv6_dst));
4831 memcpy(header, &ipv6, sizeof(ipv6));
4832 header += sizeof(ipv6);
4834 memcpy(header, &udp, sizeof(udp));
4835 header += sizeof(udp);
4836 memcpy(mpls.label_tc_s, mplsoudp_encap_conf.label,
4837 RTE_DIM(mplsoudp_encap_conf.label));
4838 mpls.label_tc_s[2] |= 0x1;
4839 memcpy(header, &mpls, sizeof(mpls));
4840 header += sizeof(mpls);
4841 action_encap_data->conf.size = header -
4842 action_encap_data->data;
4843 action->conf = &action_encap_data->conf;
4847 /** Parse MPLSOUDP decap action. */
4849 parse_vc_action_mplsoudp_decap(struct context *ctx, const struct token *token,
4850 const char *str, unsigned int len,
4851 void *buf, unsigned int size)
4853 struct buffer *out = buf;
4854 struct rte_flow_action *action;
4855 struct action_raw_decap_data *action_decap_data;
4856 struct rte_flow_item_eth eth = { .type = 0, };
4857 struct rte_flow_item_vlan vlan = {.tci = 0};
4858 struct rte_flow_item_ipv4 ipv4 = {
4860 .next_proto_id = IPPROTO_UDP,
4863 struct rte_flow_item_ipv6 ipv6 = {
4865 .proto = IPPROTO_UDP,
4868 struct rte_flow_item_udp udp = {
4870 .dst_port = rte_cpu_to_be_16(6635),
4873 struct rte_flow_item_mpls mpls;
4877 ret = parse_vc(ctx, token, str, len, buf, size);
4880 /* Nothing else to do if there is no buffer. */
4883 if (!out->args.vc.actions_n)
4885 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4886 /* Point to selected object. */
4887 ctx->object = out->args.vc.data;
4888 ctx->objmask = NULL;
4889 /* Copy the headers to the buffer. */
4890 action_decap_data = ctx->object;
4891 *action_decap_data = (struct action_raw_decap_data) {
4892 .conf = (struct rte_flow_action_raw_decap){
4893 .data = action_decap_data->data,
4897 header = action_decap_data->data;
4898 if (mplsoudp_decap_conf.select_vlan)
4899 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
4900 else if (mplsoudp_encap_conf.select_ipv4)
4901 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
4903 eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
4904 memcpy(eth.dst.addr_bytes,
4905 mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
4906 memcpy(eth.src.addr_bytes,
4907 mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
4908 memcpy(header, ð, sizeof(eth));
4909 header += sizeof(eth);
4910 if (mplsoudp_encap_conf.select_vlan) {
4911 if (mplsoudp_encap_conf.select_ipv4)
4912 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
4914 vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
4915 memcpy(header, &vlan, sizeof(vlan));
4916 header += sizeof(vlan);
4918 if (mplsoudp_encap_conf.select_ipv4) {
4919 memcpy(header, &ipv4, sizeof(ipv4));
4920 header += sizeof(ipv4);
4922 memcpy(header, &ipv6, sizeof(ipv6));
4923 header += sizeof(ipv6);
4925 memcpy(header, &udp, sizeof(udp));
4926 header += sizeof(udp);
4927 memset(&mpls, 0, sizeof(mpls));
4928 memcpy(header, &mpls, sizeof(mpls));
4929 header += sizeof(mpls);
4930 action_decap_data->conf.size = header -
4931 action_decap_data->data;
4932 action->conf = &action_decap_data->conf;
4937 parse_vc_action_raw_decap_index(struct context *ctx, const struct token *token,
4938 const char *str, unsigned int len, void *buf,
4941 struct action_raw_decap_data *action_raw_decap_data;
4942 struct rte_flow_action *action;
4943 const struct arg *arg;
4944 struct buffer *out = buf;
4948 RTE_SET_USED(token);
4951 arg = ARGS_ENTRY_ARB_BOUNDED
4952 (offsetof(struct action_raw_decap_data, idx),
4953 sizeof(((struct action_raw_decap_data *)0)->idx),
4954 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
4955 if (push_args(ctx, arg))
4957 ret = parse_int(ctx, token, str, len, NULL, 0);
4964 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
4965 action_raw_decap_data = ctx->object;
4966 idx = action_raw_decap_data->idx;
4967 action_raw_decap_data->conf.data = raw_decap_confs[idx].data;
4968 action_raw_decap_data->conf.size = raw_decap_confs[idx].size;
4969 action->conf = &action_raw_decap_data->conf;
4975 parse_vc_action_raw_encap_index(struct context *ctx, const struct token *token,
4976 const char *str, unsigned int len, void *buf,
4979 struct action_raw_encap_data *action_raw_encap_data;
4980 struct rte_flow_action *action;
4981 const struct arg *arg;
4982 struct buffer *out = buf;
4986 RTE_SET_USED(token);
4989 if (ctx->curr != ACTION_RAW_ENCAP_INDEX_VALUE)
4991 arg = ARGS_ENTRY_ARB_BOUNDED
4992 (offsetof(struct action_raw_encap_data, idx),
4993 sizeof(((struct action_raw_encap_data *)0)->idx),
4994 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
4995 if (push_args(ctx, arg))
4997 ret = parse_int(ctx, token, str, len, NULL, 0);
5004 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5005 action_raw_encap_data = ctx->object;
5006 idx = action_raw_encap_data->idx;
5007 action_raw_encap_data->conf.data = raw_encap_confs[idx].data;
5008 action_raw_encap_data->conf.size = raw_encap_confs[idx].size;
5009 action_raw_encap_data->conf.preserve = NULL;
5010 action->conf = &action_raw_encap_data->conf;
5015 parse_vc_action_raw_encap(struct context *ctx, const struct token *token,
5016 const char *str, unsigned int len, void *buf,
5019 struct buffer *out = buf;
5020 struct rte_flow_action *action;
5021 struct action_raw_encap_data *action_raw_encap_data = NULL;
5024 ret = parse_vc(ctx, token, str, len, buf, size);
5027 /* Nothing else to do if there is no buffer. */
5030 if (!out->args.vc.actions_n)
5032 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5033 /* Point to selected object. */
5034 ctx->object = out->args.vc.data;
5035 ctx->objmask = NULL;
5036 /* Copy the headers to the buffer. */
5037 action_raw_encap_data = ctx->object;
5038 action_raw_encap_data->conf.data = raw_encap_confs[0].data;
5039 action_raw_encap_data->conf.preserve = NULL;
5040 action_raw_encap_data->conf.size = raw_encap_confs[0].size;
5041 action->conf = &action_raw_encap_data->conf;
5046 parse_vc_action_raw_decap(struct context *ctx, const struct token *token,
5047 const char *str, unsigned int len, void *buf,
5050 struct buffer *out = buf;
5051 struct rte_flow_action *action;
5052 struct action_raw_decap_data *action_raw_decap_data = NULL;
5055 ret = parse_vc(ctx, token, str, len, buf, size);
5058 /* Nothing else to do if there is no buffer. */
5061 if (!out->args.vc.actions_n)
5063 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
5064 /* Point to selected object. */
5065 ctx->object = out->args.vc.data;
5066 ctx->objmask = NULL;
5067 /* Copy the headers to the buffer. */
5068 action_raw_decap_data = ctx->object;
5069 action_raw_decap_data->conf.data = raw_decap_confs[0].data;
5070 action_raw_decap_data->conf.size = raw_decap_confs[0].size;
5071 action->conf = &action_raw_decap_data->conf;
5076 parse_vc_action_set_meta(struct context *ctx, const struct token *token,
5077 const char *str, unsigned int len, void *buf,
5082 ret = parse_vc(ctx, token, str, len, buf, size);
5085 ret = rte_flow_dynf_metadata_register();
5091 /** Parse tokens for destroy command. */
5093 parse_destroy(struct context *ctx, const struct token *token,
5094 const char *str, unsigned int len,
5095 void *buf, unsigned int size)
5097 struct buffer *out = buf;
5099 /* Token name must match. */
5100 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5102 /* Nothing else to do if there is no buffer. */
5105 if (!out->command) {
5106 if (ctx->curr != DESTROY)
5108 if (sizeof(*out) > size)
5110 out->command = ctx->curr;
5113 ctx->objmask = NULL;
5114 out->args.destroy.rule =
5115 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5119 if (((uint8_t *)(out->args.destroy.rule + out->args.destroy.rule_n) +
5120 sizeof(*out->args.destroy.rule)) > (uint8_t *)out + size)
5123 ctx->object = out->args.destroy.rule + out->args.destroy.rule_n++;
5124 ctx->objmask = NULL;
5128 /** Parse tokens for flush command. */
5130 parse_flush(struct context *ctx, const struct token *token,
5131 const char *str, unsigned int len,
5132 void *buf, unsigned int size)
5134 struct buffer *out = buf;
5136 /* Token name must match. */
5137 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5139 /* Nothing else to do if there is no buffer. */
5142 if (!out->command) {
5143 if (ctx->curr != FLUSH)
5145 if (sizeof(*out) > size)
5147 out->command = ctx->curr;
5150 ctx->objmask = NULL;
5155 /** Parse tokens for dump command. */
5157 parse_dump(struct context *ctx, const struct token *token,
5158 const char *str, unsigned int len,
5159 void *buf, unsigned int size)
5161 struct buffer *out = buf;
5163 /* Token name must match. */
5164 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5166 /* Nothing else to do if there is no buffer. */
5169 if (!out->command) {
5170 if (ctx->curr != DUMP)
5172 if (sizeof(*out) > size)
5174 out->command = ctx->curr;
5177 ctx->objmask = NULL;
5182 /** Parse tokens for query command. */
5184 parse_query(struct context *ctx, const struct token *token,
5185 const char *str, unsigned int len,
5186 void *buf, unsigned int size)
5188 struct buffer *out = buf;
5190 /* Token name must match. */
5191 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5193 /* Nothing else to do if there is no buffer. */
5196 if (!out->command) {
5197 if (ctx->curr != QUERY)
5199 if (sizeof(*out) > size)
5201 out->command = ctx->curr;
5204 ctx->objmask = NULL;
5209 /** Parse action names. */
5211 parse_action(struct context *ctx, const struct token *token,
5212 const char *str, unsigned int len,
5213 void *buf, unsigned int size)
5215 struct buffer *out = buf;
5216 const struct arg *arg = pop_args(ctx);
5220 /* Argument is expected. */
5223 /* Parse action name. */
5224 for (i = 0; next_action[i]; ++i) {
5225 const struct parse_action_priv *priv;
5227 token = &token_list[next_action[i]];
5228 if (strcmp_partial(token->name, str, len))
5234 memcpy((uint8_t *)ctx->object + arg->offset,
5240 push_args(ctx, arg);
5244 /** Parse tokens for list command. */
5246 parse_list(struct context *ctx, const struct token *token,
5247 const char *str, unsigned int len,
5248 void *buf, unsigned int size)
5250 struct buffer *out = buf;
5252 /* Token name must match. */
5253 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5255 /* Nothing else to do if there is no buffer. */
5258 if (!out->command) {
5259 if (ctx->curr != LIST)
5261 if (sizeof(*out) > size)
5263 out->command = ctx->curr;
5266 ctx->objmask = NULL;
5267 out->args.list.group =
5268 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5272 if (((uint8_t *)(out->args.list.group + out->args.list.group_n) +
5273 sizeof(*out->args.list.group)) > (uint8_t *)out + size)
5276 ctx->object = out->args.list.group + out->args.list.group_n++;
5277 ctx->objmask = NULL;
5281 /** Parse tokens for isolate command. */
5283 parse_isolate(struct context *ctx, const struct token *token,
5284 const char *str, unsigned int len,
5285 void *buf, unsigned int size)
5287 struct buffer *out = buf;
5289 /* Token name must match. */
5290 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5292 /* Nothing else to do if there is no buffer. */
5295 if (!out->command) {
5296 if (ctx->curr != ISOLATE)
5298 if (sizeof(*out) > size)
5300 out->command = ctx->curr;
5303 ctx->objmask = NULL;
5309 * Parse signed/unsigned integers 8 to 64-bit long.
5311 * Last argument (ctx->args) is retrieved to determine integer type and
5315 parse_int(struct context *ctx, const struct token *token,
5316 const char *str, unsigned int len,
5317 void *buf, unsigned int size)
5319 const struct arg *arg = pop_args(ctx);
5324 /* Argument is expected. */
5329 (uintmax_t)strtoimax(str, &end, 0) :
5330 strtoumax(str, &end, 0);
5331 if (errno || (size_t)(end - str) != len)
5334 ((arg->sign && ((intmax_t)u < (intmax_t)arg->min ||
5335 (intmax_t)u > (intmax_t)arg->max)) ||
5336 (!arg->sign && (u < arg->min || u > arg->max))))
5341 if (!arg_entry_bf_fill(ctx->object, u, arg) ||
5342 !arg_entry_bf_fill(ctx->objmask, -1, arg))
5346 buf = (uint8_t *)ctx->object + arg->offset;
5348 if (u > RTE_LEN2MASK(size * CHAR_BIT, uint64_t))
5352 case sizeof(uint8_t):
5353 *(uint8_t *)buf = u;
5355 case sizeof(uint16_t):
5356 *(uint16_t *)buf = arg->hton ? rte_cpu_to_be_16(u) : u;
5358 case sizeof(uint8_t [3]):
5359 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
5361 ((uint8_t *)buf)[0] = u;
5362 ((uint8_t *)buf)[1] = u >> 8;
5363 ((uint8_t *)buf)[2] = u >> 16;
5367 ((uint8_t *)buf)[0] = u >> 16;
5368 ((uint8_t *)buf)[1] = u >> 8;
5369 ((uint8_t *)buf)[2] = u;
5371 case sizeof(uint32_t):
5372 *(uint32_t *)buf = arg->hton ? rte_cpu_to_be_32(u) : u;
5374 case sizeof(uint64_t):
5375 *(uint64_t *)buf = arg->hton ? rte_cpu_to_be_64(u) : u;
5380 if (ctx->objmask && buf != (uint8_t *)ctx->objmask + arg->offset) {
5382 buf = (uint8_t *)ctx->objmask + arg->offset;
5387 push_args(ctx, arg);
5394 * Three arguments (ctx->args) are retrieved from the stack to store data,
5395 * its actual length and address (in that order).
5398 parse_string(struct context *ctx, const struct token *token,
5399 const char *str, unsigned int len,
5400 void *buf, unsigned int size)
5402 const struct arg *arg_data = pop_args(ctx);
5403 const struct arg *arg_len = pop_args(ctx);
5404 const struct arg *arg_addr = pop_args(ctx);
5405 char tmp[16]; /* Ought to be enough. */
5408 /* Arguments are expected. */
5412 push_args(ctx, arg_data);
5416 push_args(ctx, arg_len);
5417 push_args(ctx, arg_data);
5420 size = arg_data->size;
5421 /* Bit-mask fill is not supported. */
5422 if (arg_data->mask || size < len)
5426 /* Let parse_int() fill length information first. */
5427 ret = snprintf(tmp, sizeof(tmp), "%u", len);
5430 push_args(ctx, arg_len);
5431 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
5436 buf = (uint8_t *)ctx->object + arg_data->offset;
5437 /* Output buffer is not necessarily NUL-terminated. */
5438 memcpy(buf, str, len);
5439 memset((uint8_t *)buf + len, 0x00, size - len);
5441 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
5442 /* Save address if requested. */
5443 if (arg_addr->size) {
5444 memcpy((uint8_t *)ctx->object + arg_addr->offset,
5446 (uint8_t *)ctx->object + arg_data->offset
5450 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
5452 (uint8_t *)ctx->objmask + arg_data->offset
5458 push_args(ctx, arg_addr);
5459 push_args(ctx, arg_len);
5460 push_args(ctx, arg_data);
5465 parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
5471 /* Check input parameters */
5472 if ((src == NULL) ||
5478 /* Convert chars to bytes */
5479 for (i = 0, len = 0; i < *size; i += 2) {
5480 snprintf(tmp, 3, "%s", src + i);
5481 dst[len++] = strtoul(tmp, &c, 16);
5496 parse_hex(struct context *ctx, const struct token *token,
5497 const char *str, unsigned int len,
5498 void *buf, unsigned int size)
5500 const struct arg *arg_data = pop_args(ctx);
5501 const struct arg *arg_len = pop_args(ctx);
5502 const struct arg *arg_addr = pop_args(ctx);
5503 char tmp[16]; /* Ought to be enough. */
5505 unsigned int hexlen = len;
5506 unsigned int length = 256;
5507 uint8_t hex_tmp[length];
5509 /* Arguments are expected. */
5513 push_args(ctx, arg_data);
5517 push_args(ctx, arg_len);
5518 push_args(ctx, arg_data);
5521 size = arg_data->size;
5522 /* Bit-mask fill is not supported. */
5528 /* translate bytes string to array. */
5529 if (str[0] == '0' && ((str[1] == 'x') ||
5534 if (hexlen > length)
5536 ret = parse_hex_string(str, hex_tmp, &hexlen);
5539 /* Let parse_int() fill length information first. */
5540 ret = snprintf(tmp, sizeof(tmp), "%u", hexlen);
5543 push_args(ctx, arg_len);
5544 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
5549 buf = (uint8_t *)ctx->object + arg_data->offset;
5550 /* Output buffer is not necessarily NUL-terminated. */
5551 memcpy(buf, hex_tmp, hexlen);
5552 memset((uint8_t *)buf + hexlen, 0x00, size - hexlen);
5554 memset((uint8_t *)ctx->objmask + arg_data->offset,
5556 /* Save address if requested. */
5557 if (arg_addr->size) {
5558 memcpy((uint8_t *)ctx->object + arg_addr->offset,
5560 (uint8_t *)ctx->object + arg_data->offset
5564 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
5566 (uint8_t *)ctx->objmask + arg_data->offset
5572 push_args(ctx, arg_addr);
5573 push_args(ctx, arg_len);
5574 push_args(ctx, arg_data);
5580 * Parse a zero-ended string.
5583 parse_string0(struct context *ctx, const struct token *token __rte_unused,
5584 const char *str, unsigned int len,
5585 void *buf, unsigned int size)
5587 const struct arg *arg_data = pop_args(ctx);
5589 /* Arguments are expected. */
5592 size = arg_data->size;
5593 /* Bit-mask fill is not supported. */
5594 if (arg_data->mask || size < len + 1)
5598 buf = (uint8_t *)ctx->object + arg_data->offset;
5599 strncpy(buf, str, len);
5601 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
5604 push_args(ctx, arg_data);
5609 * Parse a MAC address.
5611 * Last argument (ctx->args) is retrieved to determine storage size and
5615 parse_mac_addr(struct context *ctx, const struct token *token,
5616 const char *str, unsigned int len,
5617 void *buf, unsigned int size)
5619 const struct arg *arg = pop_args(ctx);
5620 struct rte_ether_addr tmp;
5624 /* Argument is expected. */
5628 /* Bit-mask fill is not supported. */
5629 if (arg->mask || size != sizeof(tmp))
5631 /* Only network endian is supported. */
5634 ret = cmdline_parse_etheraddr(NULL, str, &tmp, size);
5635 if (ret < 0 || (unsigned int)ret != len)
5639 buf = (uint8_t *)ctx->object + arg->offset;
5640 memcpy(buf, &tmp, size);
5642 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
5645 push_args(ctx, arg);
5650 * Parse an IPv4 address.
5652 * Last argument (ctx->args) is retrieved to determine storage size and
5656 parse_ipv4_addr(struct context *ctx, const struct token *token,
5657 const char *str, unsigned int len,
5658 void *buf, unsigned int size)
5660 const struct arg *arg = pop_args(ctx);
5665 /* Argument is expected. */
5669 /* Bit-mask fill is not supported. */
5670 if (arg->mask || size != sizeof(tmp))
5672 /* Only network endian is supported. */
5675 memcpy(str2, str, len);
5677 ret = inet_pton(AF_INET, str2, &tmp);
5679 /* Attempt integer parsing. */
5680 push_args(ctx, arg);
5681 return parse_int(ctx, token, str, len, buf, size);
5685 buf = (uint8_t *)ctx->object + arg->offset;
5686 memcpy(buf, &tmp, size);
5688 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
5691 push_args(ctx, arg);
5696 * Parse an IPv6 address.
5698 * Last argument (ctx->args) is retrieved to determine storage size and
5702 parse_ipv6_addr(struct context *ctx, const struct token *token,
5703 const char *str, unsigned int len,
5704 void *buf, unsigned int size)
5706 const struct arg *arg = pop_args(ctx);
5708 struct in6_addr tmp;
5712 /* Argument is expected. */
5716 /* Bit-mask fill is not supported. */
5717 if (arg->mask || size != sizeof(tmp))
5719 /* Only network endian is supported. */
5722 memcpy(str2, str, len);
5724 ret = inet_pton(AF_INET6, str2, &tmp);
5729 buf = (uint8_t *)ctx->object + arg->offset;
5730 memcpy(buf, &tmp, size);
5732 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
5735 push_args(ctx, arg);
5739 /** Boolean values (even indices stand for false). */
5740 static const char *const boolean_name[] = {
5750 * Parse a boolean value.
5752 * Last argument (ctx->args) is retrieved to determine storage size and
5756 parse_boolean(struct context *ctx, const struct token *token,
5757 const char *str, unsigned int len,
5758 void *buf, unsigned int size)
5760 const struct arg *arg = pop_args(ctx);
5764 /* Argument is expected. */
5767 for (i = 0; boolean_name[i]; ++i)
5768 if (!strcmp_partial(boolean_name[i], str, len))
5770 /* Process token as integer. */
5771 if (boolean_name[i])
5772 str = i & 1 ? "1" : "0";
5773 push_args(ctx, arg);
5774 ret = parse_int(ctx, token, str, strlen(str), buf, size);
5775 return ret > 0 ? (int)len : ret;
5778 /** Parse port and update context. */
5780 parse_port(struct context *ctx, const struct token *token,
5781 const char *str, unsigned int len,
5782 void *buf, unsigned int size)
5784 struct buffer *out = &(struct buffer){ .port = 0 };
5792 ctx->objmask = NULL;
5793 size = sizeof(*out);
5795 ret = parse_int(ctx, token, str, len, out, size);
5797 ctx->port = out->port;
5803 /** Parse set command, initialize output buffer for subsequent tokens. */
5805 parse_set_raw_encap_decap(struct context *ctx, const struct token *token,
5806 const char *str, unsigned int len,
5807 void *buf, unsigned int size)
5809 struct buffer *out = buf;
5811 /* Token name must match. */
5812 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5814 /* Nothing else to do if there is no buffer. */
5817 /* Make sure buffer is large enough. */
5818 if (size < sizeof(*out))
5821 ctx->objmask = NULL;
5825 out->command = ctx->curr;
5830 * Parse set raw_encap/raw_decap command,
5831 * initialize output buffer for subsequent tokens.
5834 parse_set_init(struct context *ctx, const struct token *token,
5835 const char *str, unsigned int len,
5836 void *buf, unsigned int size)
5838 struct buffer *out = buf;
5840 /* Token name must match. */
5841 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
5843 /* Nothing else to do if there is no buffer. */
5846 /* Make sure buffer is large enough. */
5847 if (size < sizeof(*out))
5849 /* Initialize buffer. */
5850 memset(out, 0x00, sizeof(*out));
5851 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
5854 ctx->objmask = NULL;
5855 if (!out->command) {
5856 if (ctx->curr != SET)
5858 if (sizeof(*out) > size)
5860 out->command = ctx->curr;
5861 out->args.vc.data = (uint8_t *)out + size;
5862 /* All we need is pattern */
5863 out->args.vc.pattern =
5864 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
5866 ctx->object = out->args.vc.pattern;
5871 /** No completion. */
5873 comp_none(struct context *ctx, const struct token *token,
5874 unsigned int ent, char *buf, unsigned int size)
5884 /** Complete boolean values. */
5886 comp_boolean(struct context *ctx, const struct token *token,
5887 unsigned int ent, char *buf, unsigned int size)
5893 for (i = 0; boolean_name[i]; ++i)
5894 if (buf && i == ent)
5895 return strlcpy(buf, boolean_name[i], size);
5901 /** Complete action names. */
5903 comp_action(struct context *ctx, const struct token *token,
5904 unsigned int ent, char *buf, unsigned int size)
5910 for (i = 0; next_action[i]; ++i)
5911 if (buf && i == ent)
5912 return strlcpy(buf, token_list[next_action[i]].name,
5919 /** Complete available ports. */
5921 comp_port(struct context *ctx, const struct token *token,
5922 unsigned int ent, char *buf, unsigned int size)
5929 RTE_ETH_FOREACH_DEV(p) {
5930 if (buf && i == ent)
5931 return snprintf(buf, size, "%u", p);
5939 /** Complete available rule IDs. */
5941 comp_rule_id(struct context *ctx, const struct token *token,
5942 unsigned int ent, char *buf, unsigned int size)
5945 struct rte_port *port;
5946 struct port_flow *pf;
5949 if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
5950 ctx->port == (portid_t)RTE_PORT_ALL)
5952 port = &ports[ctx->port];
5953 for (pf = port->flow_list; pf != NULL; pf = pf->next) {
5954 if (buf && i == ent)
5955 return snprintf(buf, size, "%u", pf->id);
5963 /** Complete type field for RSS action. */
5965 comp_vc_action_rss_type(struct context *ctx, const struct token *token,
5966 unsigned int ent, char *buf, unsigned int size)
5972 for (i = 0; rss_type_table[i].str; ++i)
5977 return strlcpy(buf, rss_type_table[ent].str, size);
5979 return snprintf(buf, size, "end");
5983 /** Complete queue field for RSS action. */
5985 comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
5986 unsigned int ent, char *buf, unsigned int size)
5993 return snprintf(buf, size, "%u", ent);
5995 return snprintf(buf, size, "end");
5999 /** Complete index number for set raw_encap/raw_decap commands. */
6001 comp_set_raw_index(struct context *ctx, const struct token *token,
6002 unsigned int ent, char *buf, unsigned int size)
6008 RTE_SET_USED(token);
6009 for (idx = 0; idx < RAW_ENCAP_CONFS_MAX_NUM; ++idx) {
6010 if (buf && idx == ent)
6011 return snprintf(buf, size, "%u", idx);
6017 /** Internal context. */
6018 static struct context cmd_flow_context;
6020 /** Global parser instance (cmdline API). */
6021 cmdline_parse_inst_t cmd_flow;
6022 cmdline_parse_inst_t cmd_set_raw;
6024 /** Initialize context. */
6026 cmd_flow_context_init(struct context *ctx)
6028 /* A full memset() is not necessary. */
6038 ctx->objmask = NULL;
6041 /** Parse a token (cmdline API). */
6043 cmd_flow_parse(cmdline_parse_token_hdr_t *hdr, const char *src, void *result,
6046 struct context *ctx = &cmd_flow_context;
6047 const struct token *token;
6048 const enum index *list;
6053 token = &token_list[ctx->curr];
6054 /* Check argument length. */
6057 for (len = 0; src[len]; ++len)
6058 if (src[len] == '#' || isspace(src[len]))
6062 /* Last argument and EOL detection. */
6063 for (i = len; src[i]; ++i)
6064 if (src[i] == '#' || src[i] == '\r' || src[i] == '\n')
6066 else if (!isspace(src[i])) {
6071 if (src[i] == '\r' || src[i] == '\n') {
6075 /* Initialize context if necessary. */
6076 if (!ctx->next_num) {
6079 ctx->next[ctx->next_num++] = token->next[0];
6081 /* Process argument through candidates. */
6082 ctx->prev = ctx->curr;
6083 list = ctx->next[ctx->next_num - 1];
6084 for (i = 0; list[i]; ++i) {
6085 const struct token *next = &token_list[list[i]];
6088 ctx->curr = list[i];
6090 tmp = next->call(ctx, next, src, len, result, size);
6092 tmp = parse_default(ctx, next, src, len, result, size);
6093 if (tmp == -1 || tmp != len)
6101 /* Push subsequent tokens if any. */
6103 for (i = 0; token->next[i]; ++i) {
6104 if (ctx->next_num == RTE_DIM(ctx->next))
6106 ctx->next[ctx->next_num++] = token->next[i];
6108 /* Push arguments if any. */
6110 for (i = 0; token->args[i]; ++i) {
6111 if (ctx->args_num == RTE_DIM(ctx->args))
6113 ctx->args[ctx->args_num++] = token->args[i];
6118 /** Return number of completion entries (cmdline API). */
6120 cmd_flow_complete_get_nb(cmdline_parse_token_hdr_t *hdr)
6122 struct context *ctx = &cmd_flow_context;
6123 const struct token *token = &token_list[ctx->curr];
6124 const enum index *list;
6128 /* Count number of tokens in current list. */
6130 list = ctx->next[ctx->next_num - 1];
6132 list = token->next[0];
6133 for (i = 0; list[i]; ++i)
6138 * If there is a single token, use its completion callback, otherwise
6139 * return the number of entries.
6141 token = &token_list[list[0]];
6142 if (i == 1 && token->comp) {
6143 /* Save index for cmd_flow_get_help(). */
6144 ctx->prev = list[0];
6145 return token->comp(ctx, token, 0, NULL, 0);
6150 /** Return a completion entry (cmdline API). */
6152 cmd_flow_complete_get_elt(cmdline_parse_token_hdr_t *hdr, int index,
6153 char *dst, unsigned int size)
6155 struct context *ctx = &cmd_flow_context;
6156 const struct token *token = &token_list[ctx->curr];
6157 const enum index *list;
6161 /* Count number of tokens in current list. */
6163 list = ctx->next[ctx->next_num - 1];
6165 list = token->next[0];
6166 for (i = 0; list[i]; ++i)
6170 /* If there is a single token, use its completion callback. */
6171 token = &token_list[list[0]];
6172 if (i == 1 && token->comp) {
6173 /* Save index for cmd_flow_get_help(). */
6174 ctx->prev = list[0];
6175 return token->comp(ctx, token, index, dst, size) < 0 ? -1 : 0;
6177 /* Otherwise make sure the index is valid and use defaults. */
6180 token = &token_list[list[index]];
6181 strlcpy(dst, token->name, size);
6182 /* Save index for cmd_flow_get_help(). */
6183 ctx->prev = list[index];
6187 /** Populate help strings for current token (cmdline API). */
6189 cmd_flow_get_help(cmdline_parse_token_hdr_t *hdr, char *dst, unsigned int size)
6191 struct context *ctx = &cmd_flow_context;
6192 const struct token *token = &token_list[ctx->prev];
6197 /* Set token type and update global help with details. */
6198 strlcpy(dst, (token->type ? token->type : "TOKEN"), size);
6200 cmd_flow.help_str = token->help;
6202 cmd_flow.help_str = token->name;
6206 /** Token definition template (cmdline API). */
6207 static struct cmdline_token_hdr cmd_flow_token_hdr = {
6208 .ops = &(struct cmdline_token_ops){
6209 .parse = cmd_flow_parse,
6210 .complete_get_nb = cmd_flow_complete_get_nb,
6211 .complete_get_elt = cmd_flow_complete_get_elt,
6212 .get_help = cmd_flow_get_help,
6217 /** Populate the next dynamic token. */
6219 cmd_flow_tok(cmdline_parse_token_hdr_t **hdr,
6220 cmdline_parse_token_hdr_t **hdr_inst)
6222 struct context *ctx = &cmd_flow_context;
6224 /* Always reinitialize context before requesting the first token. */
6225 if (!(hdr_inst - cmd_flow.tokens))
6226 cmd_flow_context_init(ctx);
6227 /* Return NULL when no more tokens are expected. */
6228 if (!ctx->next_num && ctx->curr) {
6232 /* Determine if command should end here. */
6233 if (ctx->eol && ctx->last && ctx->next_num) {
6234 const enum index *list = ctx->next[ctx->next_num - 1];
6237 for (i = 0; list[i]; ++i) {
6244 *hdr = &cmd_flow_token_hdr;
6247 /** Dispatch parsed buffer to function calls. */
6249 cmd_flow_parsed(const struct buffer *in)
6251 switch (in->command) {
6253 port_flow_validate(in->port, &in->args.vc.attr,
6254 in->args.vc.pattern, in->args.vc.actions);
6257 port_flow_create(in->port, &in->args.vc.attr,
6258 in->args.vc.pattern, in->args.vc.actions);
6261 port_flow_destroy(in->port, in->args.destroy.rule_n,
6262 in->args.destroy.rule);
6265 port_flow_flush(in->port);
6268 port_flow_dump(in->port, in->args.dump.file);
6271 port_flow_query(in->port, in->args.query.rule,
6272 &in->args.query.action);
6275 port_flow_list(in->port, in->args.list.group_n,
6276 in->args.list.group);
6279 port_flow_isolate(in->port, in->args.isolate.set);
6286 /** Token generator and output processing callback (cmdline API). */
6288 cmd_flow_cb(void *arg0, struct cmdline *cl, void *arg2)
6291 cmd_flow_tok(arg0, arg2);
6293 cmd_flow_parsed(arg0);
6296 /** Global parser instance (cmdline API). */
6297 cmdline_parse_inst_t cmd_flow = {
6299 .data = NULL, /**< Unused. */
6300 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
6303 }, /**< Tokens are returned by cmd_flow_tok(). */
6306 /** set cmd facility. Reuse cmd flow's infrastructure as much as possible. */
6309 update_fields(uint8_t *buf, struct rte_flow_item *item, uint16_t next_proto)
6311 struct rte_flow_item_ipv4 *ipv4;
6312 struct rte_flow_item_eth *eth;
6313 struct rte_flow_item_ipv6 *ipv6;
6314 struct rte_flow_item_vxlan *vxlan;
6315 struct rte_flow_item_vxlan_gpe *gpe;
6316 struct rte_flow_item_nvgre *nvgre;
6317 uint32_t ipv6_vtc_flow;
6319 switch (item->type) {
6320 case RTE_FLOW_ITEM_TYPE_ETH:
6321 eth = (struct rte_flow_item_eth *)buf;
6323 eth->type = rte_cpu_to_be_16(next_proto);
6325 case RTE_FLOW_ITEM_TYPE_IPV4:
6326 ipv4 = (struct rte_flow_item_ipv4 *)buf;
6327 ipv4->hdr.version_ihl = 0x45;
6328 if (next_proto && ipv4->hdr.next_proto_id == 0)
6329 ipv4->hdr.next_proto_id = (uint8_t)next_proto;
6331 case RTE_FLOW_ITEM_TYPE_IPV6:
6332 ipv6 = (struct rte_flow_item_ipv6 *)buf;
6333 if (next_proto && ipv6->hdr.proto == 0)
6334 ipv6->hdr.proto = (uint8_t)next_proto;
6335 ipv6_vtc_flow = rte_be_to_cpu_32(ipv6->hdr.vtc_flow);
6336 ipv6_vtc_flow &= 0x0FFFFFFF; /*< reset version bits. */
6337 ipv6_vtc_flow |= 0x60000000; /*< set ipv6 version. */
6338 ipv6->hdr.vtc_flow = rte_cpu_to_be_32(ipv6_vtc_flow);
6340 case RTE_FLOW_ITEM_TYPE_VXLAN:
6341 vxlan = (struct rte_flow_item_vxlan *)buf;
6342 vxlan->flags = 0x08;
6344 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
6345 gpe = (struct rte_flow_item_vxlan_gpe *)buf;
6348 case RTE_FLOW_ITEM_TYPE_NVGRE:
6349 nvgre = (struct rte_flow_item_nvgre *)buf;
6350 nvgre->protocol = rte_cpu_to_be_16(0x6558);
6351 nvgre->c_k_s_rsvd0_ver = rte_cpu_to_be_16(0x2000);
6358 /** Helper of get item's default mask. */
6360 flow_item_default_mask(const struct rte_flow_item *item)
6362 const void *mask = NULL;
6363 static rte_be32_t gre_key_default_mask = RTE_BE32(UINT32_MAX);
6365 switch (item->type) {
6366 case RTE_FLOW_ITEM_TYPE_ANY:
6367 mask = &rte_flow_item_any_mask;
6369 case RTE_FLOW_ITEM_TYPE_VF:
6370 mask = &rte_flow_item_vf_mask;
6372 case RTE_FLOW_ITEM_TYPE_PORT_ID:
6373 mask = &rte_flow_item_port_id_mask;
6375 case RTE_FLOW_ITEM_TYPE_RAW:
6376 mask = &rte_flow_item_raw_mask;
6378 case RTE_FLOW_ITEM_TYPE_ETH:
6379 mask = &rte_flow_item_eth_mask;
6381 case RTE_FLOW_ITEM_TYPE_VLAN:
6382 mask = &rte_flow_item_vlan_mask;
6384 case RTE_FLOW_ITEM_TYPE_IPV4:
6385 mask = &rte_flow_item_ipv4_mask;
6387 case RTE_FLOW_ITEM_TYPE_IPV6:
6388 mask = &rte_flow_item_ipv6_mask;
6390 case RTE_FLOW_ITEM_TYPE_ICMP:
6391 mask = &rte_flow_item_icmp_mask;
6393 case RTE_FLOW_ITEM_TYPE_UDP:
6394 mask = &rte_flow_item_udp_mask;
6396 case RTE_FLOW_ITEM_TYPE_TCP:
6397 mask = &rte_flow_item_tcp_mask;
6399 case RTE_FLOW_ITEM_TYPE_SCTP:
6400 mask = &rte_flow_item_sctp_mask;
6402 case RTE_FLOW_ITEM_TYPE_VXLAN:
6403 mask = &rte_flow_item_vxlan_mask;
6405 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
6406 mask = &rte_flow_item_vxlan_gpe_mask;
6408 case RTE_FLOW_ITEM_TYPE_E_TAG:
6409 mask = &rte_flow_item_e_tag_mask;
6411 case RTE_FLOW_ITEM_TYPE_NVGRE:
6412 mask = &rte_flow_item_nvgre_mask;
6414 case RTE_FLOW_ITEM_TYPE_MPLS:
6415 mask = &rte_flow_item_mpls_mask;
6417 case RTE_FLOW_ITEM_TYPE_GRE:
6418 mask = &rte_flow_item_gre_mask;
6420 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
6421 mask = &gre_key_default_mask;
6423 case RTE_FLOW_ITEM_TYPE_META:
6424 mask = &rte_flow_item_meta_mask;
6426 case RTE_FLOW_ITEM_TYPE_FUZZY:
6427 mask = &rte_flow_item_fuzzy_mask;
6429 case RTE_FLOW_ITEM_TYPE_GTP:
6430 mask = &rte_flow_item_gtp_mask;
6432 case RTE_FLOW_ITEM_TYPE_GTP_PSC:
6433 mask = &rte_flow_item_gtp_psc_mask;
6435 case RTE_FLOW_ITEM_TYPE_GENEVE:
6436 mask = &rte_flow_item_geneve_mask;
6438 case RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID:
6439 mask = &rte_flow_item_pppoe_proto_id_mask;
6441 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
6442 mask = &rte_flow_item_l2tpv3oip_mask;
6444 case RTE_FLOW_ITEM_TYPE_ESP:
6445 mask = &rte_flow_item_esp_mask;
6455 /** Dispatch parsed buffer to function calls. */
6457 cmd_set_raw_parsed(const struct buffer *in)
6459 uint32_t n = in->args.vc.pattern_n;
6461 struct rte_flow_item *item = NULL;
6463 uint8_t *data = NULL;
6464 uint8_t *data_tail = NULL;
6465 size_t *total_size = NULL;
6466 uint16_t upper_layer = 0;
6468 uint16_t idx = in->port; /* We borrow port field as index */
6470 RTE_ASSERT(in->command == SET_RAW_ENCAP ||
6471 in->command == SET_RAW_DECAP);
6472 if (in->command == SET_RAW_ENCAP) {
6473 total_size = &raw_encap_confs[idx].size;
6474 data = (uint8_t *)&raw_encap_confs[idx].data;
6476 total_size = &raw_decap_confs[idx].size;
6477 data = (uint8_t *)&raw_decap_confs[idx].data;
6480 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
6481 /* process hdr from upper layer to low layer (L3/L4 -> L2). */
6482 data_tail = data + ACTION_RAW_ENCAP_MAX_DATA;
6483 for (i = n - 1 ; i >= 0; --i) {
6484 item = in->args.vc.pattern + i;
6485 if (item->spec == NULL)
6486 item->spec = flow_item_default_mask(item);
6487 switch (item->type) {
6488 case RTE_FLOW_ITEM_TYPE_ETH:
6489 size = sizeof(struct rte_flow_item_eth);
6491 case RTE_FLOW_ITEM_TYPE_VLAN:
6492 size = sizeof(struct rte_flow_item_vlan);
6493 proto = RTE_ETHER_TYPE_VLAN;
6495 case RTE_FLOW_ITEM_TYPE_IPV4:
6496 size = sizeof(struct rte_flow_item_ipv4);
6497 proto = RTE_ETHER_TYPE_IPV4;
6499 case RTE_FLOW_ITEM_TYPE_IPV6:
6500 size = sizeof(struct rte_flow_item_ipv6);
6501 proto = RTE_ETHER_TYPE_IPV6;
6503 case RTE_FLOW_ITEM_TYPE_UDP:
6504 size = sizeof(struct rte_flow_item_udp);
6507 case RTE_FLOW_ITEM_TYPE_TCP:
6508 size = sizeof(struct rte_flow_item_tcp);
6511 case RTE_FLOW_ITEM_TYPE_VXLAN:
6512 size = sizeof(struct rte_flow_item_vxlan);
6514 case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
6515 size = sizeof(struct rte_flow_item_vxlan_gpe);
6517 case RTE_FLOW_ITEM_TYPE_GRE:
6518 size = sizeof(struct rte_flow_item_gre);
6521 case RTE_FLOW_ITEM_TYPE_GRE_KEY:
6522 size = sizeof(rte_be32_t);
6525 case RTE_FLOW_ITEM_TYPE_MPLS:
6526 size = sizeof(struct rte_flow_item_mpls);
6529 case RTE_FLOW_ITEM_TYPE_NVGRE:
6530 size = sizeof(struct rte_flow_item_nvgre);
6533 case RTE_FLOW_ITEM_TYPE_GENEVE:
6534 size = sizeof(struct rte_flow_item_geneve);
6536 case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
6537 size = sizeof(struct rte_flow_item_l2tpv3oip);
6540 case RTE_FLOW_ITEM_TYPE_ESP:
6541 size = sizeof(struct rte_flow_item_esp);
6545 printf("Error - Not supported item\n");
6547 memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
6550 *total_size += size;
6551 rte_memcpy(data_tail - (*total_size), item->spec, size);
6552 /* update some fields which cannot be set by cmdline */
6553 update_fields((data_tail - (*total_size)), item,
6555 upper_layer = proto;
6557 if (verbose_level & 0x1)
6558 printf("total data size is %zu\n", (*total_size));
6559 RTE_ASSERT((*total_size) <= ACTION_RAW_ENCAP_MAX_DATA);
6560 memmove(data, (data_tail - (*total_size)), *total_size);
6563 /** Populate help strings for current token (cmdline API). */
6565 cmd_set_raw_get_help(cmdline_parse_token_hdr_t *hdr, char *dst,
6568 struct context *ctx = &cmd_flow_context;
6569 const struct token *token = &token_list[ctx->prev];
6574 /* Set token type and update global help with details. */
6575 snprintf(dst, size, "%s", (token->type ? token->type : "TOKEN"));
6577 cmd_set_raw.help_str = token->help;
6579 cmd_set_raw.help_str = token->name;
6583 /** Token definition template (cmdline API). */
6584 static struct cmdline_token_hdr cmd_set_raw_token_hdr = {
6585 .ops = &(struct cmdline_token_ops){
6586 .parse = cmd_flow_parse,
6587 .complete_get_nb = cmd_flow_complete_get_nb,
6588 .complete_get_elt = cmd_flow_complete_get_elt,
6589 .get_help = cmd_set_raw_get_help,
6594 /** Populate the next dynamic token. */
6596 cmd_set_raw_tok(cmdline_parse_token_hdr_t **hdr,
6597 cmdline_parse_token_hdr_t **hdr_inst)
6599 struct context *ctx = &cmd_flow_context;
6601 /* Always reinitialize context before requesting the first token. */
6602 if (!(hdr_inst - cmd_set_raw.tokens)) {
6603 cmd_flow_context_init(ctx);
6604 ctx->curr = START_SET;
6606 /* Return NULL when no more tokens are expected. */
6607 if (!ctx->next_num && (ctx->curr != START_SET)) {
6611 /* Determine if command should end here. */
6612 if (ctx->eol && ctx->last && ctx->next_num) {
6613 const enum index *list = ctx->next[ctx->next_num - 1];
6616 for (i = 0; list[i]; ++i) {
6623 *hdr = &cmd_set_raw_token_hdr;
6626 /** Token generator and output processing callback (cmdline API). */
6628 cmd_set_raw_cb(void *arg0, struct cmdline *cl, void *arg2)
6631 cmd_set_raw_tok(arg0, arg2);
6633 cmd_set_raw_parsed(arg0);
6636 /** Global parser instance (cmdline API). */
6637 cmdline_parse_inst_t cmd_set_raw = {
6638 .f = cmd_set_raw_cb,
6639 .data = NULL, /**< Unused. */
6640 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
6643 }, /**< Tokens are returned by cmd_flow_tok(). */
6646 /* *** display raw_encap/raw_decap buf */
6647 struct cmd_show_set_raw_result {
6648 cmdline_fixed_string_t cmd_show;
6649 cmdline_fixed_string_t cmd_what;
6650 cmdline_fixed_string_t cmd_all;
6655 cmd_show_set_raw_parsed(void *parsed_result, struct cmdline *cl, void *data)
6657 struct cmd_show_set_raw_result *res = parsed_result;
6658 uint16_t index = res->cmd_index;
6660 uint8_t *raw_data = NULL;
6661 size_t raw_size = 0;
6662 char title[16] = {0};
6666 if (!strcmp(res->cmd_all, "all")) {
6669 } else if (index >= RAW_ENCAP_CONFS_MAX_NUM) {
6670 printf("index should be 0-%u\n", RAW_ENCAP_CONFS_MAX_NUM - 1);
6674 if (!strcmp(res->cmd_what, "raw_encap")) {
6675 raw_data = (uint8_t *)&raw_encap_confs[index].data;
6676 raw_size = raw_encap_confs[index].size;
6677 snprintf(title, 16, "\nindex: %u", index);
6678 rte_hexdump(stdout, title, raw_data, raw_size);
6680 raw_data = (uint8_t *)&raw_decap_confs[index].data;
6681 raw_size = raw_decap_confs[index].size;
6682 snprintf(title, 16, "\nindex: %u", index);
6683 rte_hexdump(stdout, title, raw_data, raw_size);
6685 } while (all && ++index < RAW_ENCAP_CONFS_MAX_NUM);
6688 cmdline_parse_token_string_t cmd_show_set_raw_cmd_show =
6689 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
6691 cmdline_parse_token_string_t cmd_show_set_raw_cmd_what =
6692 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
6693 cmd_what, "raw_encap#raw_decap");
6694 cmdline_parse_token_num_t cmd_show_set_raw_cmd_index =
6695 TOKEN_NUM_INITIALIZER(struct cmd_show_set_raw_result,
6697 cmdline_parse_token_string_t cmd_show_set_raw_cmd_all =
6698 TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
6700 cmdline_parse_inst_t cmd_show_set_raw = {
6701 .f = cmd_show_set_raw_parsed,
6703 .help_str = "show <raw_encap|raw_decap> <index>",
6705 (void *)&cmd_show_set_raw_cmd_show,
6706 (void *)&cmd_show_set_raw_cmd_what,
6707 (void *)&cmd_show_set_raw_cmd_index,
6711 cmdline_parse_inst_t cmd_show_set_raw_all = {
6712 .f = cmd_show_set_raw_parsed,
6714 .help_str = "show <raw_encap|raw_decap> all",
6716 (void *)&cmd_show_set_raw_cmd_show,
6717 (void *)&cmd_show_set_raw_cmd_what,
6718 (void *)&cmd_show_set_raw_cmd_all,