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_common.h>
17 #include <rte_eth_ctrl.h>
18 #include <rte_ethdev.h>
19 #include <rte_byteorder.h>
20 #include <cmdline_parse.h>
21 #include <cmdline_parse_etheraddr.h>
26 /** Parser token indices. */
46 /* Top-level command. */
49 /* Sub-level commands. */
58 /* Destroy arguments. */
61 /* Query arguments. */
67 /* Validate/create arguments. */
74 /* Validate/create pattern. */
109 ITEM_VLAN_INNER_TYPE,
141 ITEM_E_TAG_GRP_ECID_B,
160 ITEM_ARP_ETH_IPV4_SHA,
161 ITEM_ARP_ETH_IPV4_SPA,
162 ITEM_ARP_ETH_IPV4_THA,
163 ITEM_ARP_ETH_IPV4_TPA,
165 ITEM_IPV6_EXT_NEXT_HDR,
170 ITEM_ICMP6_ND_NS_TARGET_ADDR,
172 ITEM_ICMP6_ND_NA_TARGET_ADDR,
174 ITEM_ICMP6_ND_OPT_TYPE,
175 ITEM_ICMP6_ND_OPT_SLA_ETH,
176 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
177 ITEM_ICMP6_ND_OPT_TLA_ETH,
178 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
180 /* Validate/create actions. */
196 ACTION_RSS_FUNC_DEFAULT,
197 ACTION_RSS_FUNC_TOEPLITZ,
198 ACTION_RSS_FUNC_SIMPLE_XOR,
210 ACTION_PHY_PORT_ORIGINAL,
211 ACTION_PHY_PORT_INDEX,
213 ACTION_PORT_ID_ORIGINAL,
217 ACTION_OF_SET_MPLS_TTL,
218 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
219 ACTION_OF_DEC_MPLS_TTL,
220 ACTION_OF_SET_NW_TTL,
221 ACTION_OF_SET_NW_TTL_NW_TTL,
222 ACTION_OF_DEC_NW_TTL,
223 ACTION_OF_COPY_TTL_OUT,
224 ACTION_OF_COPY_TTL_IN,
227 ACTION_OF_PUSH_VLAN_ETHERTYPE,
228 ACTION_OF_SET_VLAN_VID,
229 ACTION_OF_SET_VLAN_VID_VLAN_VID,
230 ACTION_OF_SET_VLAN_PCP,
231 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
233 ACTION_OF_POP_MPLS_ETHERTYPE,
235 ACTION_OF_PUSH_MPLS_ETHERTYPE,
238 /** Maximum size for pattern in struct rte_flow_item_raw. */
239 #define ITEM_RAW_PATTERN_SIZE 40
241 /** Storage size for struct rte_flow_item_raw including pattern. */
242 #define ITEM_RAW_SIZE \
243 (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE)
245 /** Maximum number of queue indices in struct rte_flow_action_rss. */
246 #define ACTION_RSS_QUEUE_NUM 32
248 /** Storage for struct rte_flow_action_rss including external data. */
249 struct action_rss_data {
250 struct rte_flow_action_rss conf;
251 uint8_t key[RSS_HASH_KEY_LENGTH];
252 uint16_t queue[ACTION_RSS_QUEUE_NUM];
255 /** Maximum number of subsequent tokens and arguments on the stack. */
256 #define CTX_STACK_SIZE 16
258 /** Parser context. */
260 /** Stack of subsequent token lists to process. */
261 const enum index *next[CTX_STACK_SIZE];
262 /** Arguments for stacked tokens. */
263 const void *args[CTX_STACK_SIZE];
264 enum index curr; /**< Current token index. */
265 enum index prev; /**< Index of the last token seen. */
266 int next_num; /**< Number of entries in next[]. */
267 int args_num; /**< Number of entries in args[]. */
268 uint32_t eol:1; /**< EOL has been detected. */
269 uint32_t last:1; /**< No more arguments. */
270 portid_t port; /**< Current port ID (for completions). */
271 uint32_t objdata; /**< Object-specific data. */
272 void *object; /**< Address of current object for relative offsets. */
273 void *objmask; /**< Object a full mask must be written to. */
276 /** Token argument. */
278 uint32_t hton:1; /**< Use network byte ordering. */
279 uint32_t sign:1; /**< Value is signed. */
280 uint32_t bounded:1; /**< Value is bounded. */
281 uintmax_t min; /**< Minimum value if bounded. */
282 uintmax_t max; /**< Maximum value if bounded. */
283 uint32_t offset; /**< Relative offset from ctx->object. */
284 uint32_t size; /**< Field size. */
285 const uint8_t *mask; /**< Bit-mask to use instead of offset/size. */
288 /** Parser token definition. */
290 /** Type displayed during completion (defaults to "TOKEN"). */
292 /** Help displayed during completion (defaults to token name). */
294 /** Private data used by parser functions. */
297 * Lists of subsequent tokens to push on the stack. Each call to the
298 * parser consumes the last entry of that stack.
300 const enum index *const *next;
301 /** Arguments stack for subsequent tokens that need them. */
302 const struct arg *const *args;
304 * Token-processing callback, returns -1 in case of error, the
305 * length of the matched string otherwise. If NULL, attempts to
306 * match the token name.
308 * If buf is not NULL, the result should be stored in it according
309 * to context. An error is returned if not large enough.
311 int (*call)(struct context *ctx, const struct token *token,
312 const char *str, unsigned int len,
313 void *buf, unsigned int size);
315 * Callback that provides possible values for this token, used for
316 * completion. Returns -1 in case of error, the number of possible
317 * values otherwise. If NULL, the token name is used.
319 * If buf is not NULL, entry index ent is written to buf and the
320 * full length of the entry is returned (same behavior as
323 int (*comp)(struct context *ctx, const struct token *token,
324 unsigned int ent, char *buf, unsigned int size);
325 /** Mandatory token name, no default value. */
329 /** Static initializer for the next field. */
330 #define NEXT(...) (const enum index *const []){ __VA_ARGS__, NULL, }
332 /** Static initializer for a NEXT() entry. */
333 #define NEXT_ENTRY(...) (const enum index []){ __VA_ARGS__, ZERO, }
335 /** Static initializer for the args field. */
336 #define ARGS(...) (const struct arg *const []){ __VA_ARGS__, NULL, }
338 /** Static initializer for ARGS() to target a field. */
339 #define ARGS_ENTRY(s, f) \
340 (&(const struct arg){ \
341 .offset = offsetof(s, f), \
342 .size = sizeof(((s *)0)->f), \
345 /** Static initializer for ARGS() to target a bit-field. */
346 #define ARGS_ENTRY_BF(s, f, b) \
347 (&(const struct arg){ \
349 .mask = (const void *)&(const s){ .f = (1 << (b)) - 1 }, \
352 /** Static initializer for ARGS() to target an arbitrary bit-mask. */
353 #define ARGS_ENTRY_MASK(s, f, m) \
354 (&(const struct arg){ \
355 .offset = offsetof(s, f), \
356 .size = sizeof(((s *)0)->f), \
357 .mask = (const void *)(m), \
360 /** Same as ARGS_ENTRY_MASK() using network byte ordering for the value. */
361 #define ARGS_ENTRY_MASK_HTON(s, f, m) \
362 (&(const struct arg){ \
364 .offset = offsetof(s, f), \
365 .size = sizeof(((s *)0)->f), \
366 .mask = (const void *)(m), \
369 /** Static initializer for ARGS() to target a pointer. */
370 #define ARGS_ENTRY_PTR(s, f) \
371 (&(const struct arg){ \
372 .size = sizeof(*((s *)0)->f), \
375 /** Static initializer for ARGS() with arbitrary offset and size. */
376 #define ARGS_ENTRY_ARB(o, s) \
377 (&(const struct arg){ \
382 /** Same as ARGS_ENTRY_ARB() with bounded values. */
383 #define ARGS_ENTRY_ARB_BOUNDED(o, s, i, a) \
384 (&(const struct arg){ \
392 /** Same as ARGS_ENTRY() using network byte ordering. */
393 #define ARGS_ENTRY_HTON(s, f) \
394 (&(const struct arg){ \
396 .offset = offsetof(s, f), \
397 .size = sizeof(((s *)0)->f), \
400 /** Parser output buffer layout expected by cmd_flow_parsed(). */
402 enum index command; /**< Flow command. */
403 portid_t port; /**< Affected port ID. */
406 struct rte_flow_attr attr;
407 struct rte_flow_item *pattern;
408 struct rte_flow_action *actions;
412 } vc; /**< Validate/create arguments. */
416 } destroy; /**< Destroy arguments. */
419 enum rte_flow_action_type action;
420 } query; /**< Query arguments. */
424 } list; /**< List arguments. */
427 } isolate; /**< Isolated mode arguments. */
428 } args; /**< Command arguments. */
431 /** Private data for pattern items. */
432 struct parse_item_priv {
433 enum rte_flow_item_type type; /**< Item type. */
434 uint32_t size; /**< Size of item specification structure. */
437 #define PRIV_ITEM(t, s) \
438 (&(const struct parse_item_priv){ \
439 .type = RTE_FLOW_ITEM_TYPE_ ## t, \
443 /** Private data for actions. */
444 struct parse_action_priv {
445 enum rte_flow_action_type type; /**< Action type. */
446 uint32_t size; /**< Size of action configuration structure. */
449 #define PRIV_ACTION(t, s) \
450 (&(const struct parse_action_priv){ \
451 .type = RTE_FLOW_ACTION_TYPE_ ## t, \
455 static const enum index next_vc_attr[] = {
465 static const enum index next_destroy_attr[] = {
471 static const enum index next_list_attr[] = {
477 static const enum index item_param[] = {
486 static const enum index next_item[] = {
521 ITEM_ICMP6_ND_OPT_SLA_ETH,
522 ITEM_ICMP6_ND_OPT_TLA_ETH,
526 static const enum index item_fuzzy[] = {
532 static const enum index item_any[] = {
538 static const enum index item_vf[] = {
544 static const enum index item_phy_port[] = {
550 static const enum index item_port_id[] = {
556 static const enum index item_raw[] = {
566 static const enum index item_eth[] = {
574 static const enum index item_vlan[] = {
579 ITEM_VLAN_INNER_TYPE,
584 static const enum index item_ipv4[] = {
594 static const enum index item_ipv6[] = {
605 static const enum index item_icmp[] = {
612 static const enum index item_udp[] = {
619 static const enum index item_tcp[] = {
627 static const enum index item_sctp[] = {
636 static const enum index item_vxlan[] = {
642 static const enum index item_e_tag[] = {
643 ITEM_E_TAG_GRP_ECID_B,
648 static const enum index item_nvgre[] = {
654 static const enum index item_mpls[] = {
660 static const enum index item_gre[] = {
666 static const enum index item_gtp[] = {
672 static const enum index item_geneve[] = {
679 static const enum index item_vxlan_gpe[] = {
685 static const enum index item_arp_eth_ipv4[] = {
686 ITEM_ARP_ETH_IPV4_SHA,
687 ITEM_ARP_ETH_IPV4_SPA,
688 ITEM_ARP_ETH_IPV4_THA,
689 ITEM_ARP_ETH_IPV4_TPA,
694 static const enum index item_ipv6_ext[] = {
695 ITEM_IPV6_EXT_NEXT_HDR,
700 static const enum index item_icmp6[] = {
707 static const enum index item_icmp6_nd_ns[] = {
708 ITEM_ICMP6_ND_NS_TARGET_ADDR,
713 static const enum index item_icmp6_nd_na[] = {
714 ITEM_ICMP6_ND_NA_TARGET_ADDR,
719 static const enum index item_icmp6_nd_opt[] = {
720 ITEM_ICMP6_ND_OPT_TYPE,
725 static const enum index item_icmp6_nd_opt_sla_eth[] = {
726 ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
731 static const enum index item_icmp6_nd_opt_tla_eth[] = {
732 ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
737 static const enum index next_action[] = {
752 ACTION_OF_SET_MPLS_TTL,
753 ACTION_OF_DEC_MPLS_TTL,
754 ACTION_OF_SET_NW_TTL,
755 ACTION_OF_DEC_NW_TTL,
756 ACTION_OF_COPY_TTL_OUT,
757 ACTION_OF_COPY_TTL_IN,
760 ACTION_OF_SET_VLAN_VID,
761 ACTION_OF_SET_VLAN_PCP,
767 static const enum index action_mark[] = {
773 static const enum index action_queue[] = {
779 static const enum index action_rss[] = {
790 static const enum index action_vf[] = {
797 static const enum index action_phy_port[] = {
798 ACTION_PHY_PORT_ORIGINAL,
799 ACTION_PHY_PORT_INDEX,
804 static const enum index action_port_id[] = {
805 ACTION_PORT_ID_ORIGINAL,
811 static const enum index action_meter[] = {
817 static const enum index action_of_set_mpls_ttl[] = {
818 ACTION_OF_SET_MPLS_TTL_MPLS_TTL,
823 static const enum index action_of_set_nw_ttl[] = {
824 ACTION_OF_SET_NW_TTL_NW_TTL,
829 static const enum index action_of_push_vlan[] = {
830 ACTION_OF_PUSH_VLAN_ETHERTYPE,
835 static const enum index action_of_set_vlan_vid[] = {
836 ACTION_OF_SET_VLAN_VID_VLAN_VID,
841 static const enum index action_of_set_vlan_pcp[] = {
842 ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
847 static const enum index action_of_pop_mpls[] = {
848 ACTION_OF_POP_MPLS_ETHERTYPE,
853 static const enum index action_of_push_mpls[] = {
854 ACTION_OF_PUSH_MPLS_ETHERTYPE,
859 static int parse_init(struct context *, const struct token *,
860 const char *, unsigned int,
861 void *, unsigned int);
862 static int parse_vc(struct context *, const struct token *,
863 const char *, unsigned int,
864 void *, unsigned int);
865 static int parse_vc_spec(struct context *, const struct token *,
866 const char *, unsigned int, void *, unsigned int);
867 static int parse_vc_conf(struct context *, const struct token *,
868 const char *, unsigned int, void *, unsigned int);
869 static int parse_vc_action_rss(struct context *, const struct token *,
870 const char *, unsigned int, void *,
872 static int parse_vc_action_rss_func(struct context *, const struct token *,
873 const char *, unsigned int, void *,
875 static int parse_vc_action_rss_type(struct context *, const struct token *,
876 const char *, unsigned int, void *,
878 static int parse_vc_action_rss_queue(struct context *, const struct token *,
879 const char *, unsigned int, void *,
881 static int parse_destroy(struct context *, const struct token *,
882 const char *, unsigned int,
883 void *, unsigned int);
884 static int parse_flush(struct context *, const struct token *,
885 const char *, unsigned int,
886 void *, unsigned int);
887 static int parse_query(struct context *, const struct token *,
888 const char *, unsigned int,
889 void *, unsigned int);
890 static int parse_action(struct context *, const struct token *,
891 const char *, unsigned int,
892 void *, unsigned int);
893 static int parse_list(struct context *, const struct token *,
894 const char *, unsigned int,
895 void *, unsigned int);
896 static int parse_isolate(struct context *, const struct token *,
897 const char *, unsigned int,
898 void *, unsigned int);
899 static int parse_int(struct context *, const struct token *,
900 const char *, unsigned int,
901 void *, unsigned int);
902 static int parse_prefix(struct context *, const struct token *,
903 const char *, unsigned int,
904 void *, unsigned int);
905 static int parse_boolean(struct context *, const struct token *,
906 const char *, unsigned int,
907 void *, unsigned int);
908 static int parse_string(struct context *, const struct token *,
909 const char *, unsigned int,
910 void *, unsigned int);
911 static int parse_mac_addr(struct context *, const struct token *,
912 const char *, unsigned int,
913 void *, unsigned int);
914 static int parse_ipv4_addr(struct context *, const struct token *,
915 const char *, unsigned int,
916 void *, unsigned int);
917 static int parse_ipv6_addr(struct context *, const struct token *,
918 const char *, unsigned int,
919 void *, unsigned int);
920 static int parse_port(struct context *, const struct token *,
921 const char *, unsigned int,
922 void *, unsigned int);
923 static int comp_none(struct context *, const struct token *,
924 unsigned int, char *, unsigned int);
925 static int comp_boolean(struct context *, const struct token *,
926 unsigned int, char *, unsigned int);
927 static int comp_action(struct context *, const struct token *,
928 unsigned int, char *, unsigned int);
929 static int comp_port(struct context *, const struct token *,
930 unsigned int, char *, unsigned int);
931 static int comp_rule_id(struct context *, const struct token *,
932 unsigned int, char *, unsigned int);
933 static int comp_vc_action_rss_type(struct context *, const struct token *,
934 unsigned int, char *, unsigned int);
935 static int comp_vc_action_rss_queue(struct context *, const struct token *,
936 unsigned int, char *, unsigned int);
938 /** Token definitions. */
939 static const struct token token_list[] = {
940 /* Special tokens. */
943 .help = "null entry, abused as the entry point",
944 .next = NEXT(NEXT_ENTRY(FLOW)),
949 .help = "command may end here",
955 .help = "integer value",
960 .name = "{unsigned}",
962 .help = "unsigned integer value",
969 .help = "prefix length for bit-mask",
970 .call = parse_prefix,
976 .help = "any boolean value",
977 .call = parse_boolean,
978 .comp = comp_boolean,
983 .help = "fixed string",
984 .call = parse_string,
988 .name = "{MAC address}",
990 .help = "standard MAC address notation",
991 .call = parse_mac_addr,
995 .name = "{IPv4 address}",
996 .type = "IPV4 ADDRESS",
997 .help = "standard IPv4 address notation",
998 .call = parse_ipv4_addr,
1002 .name = "{IPv6 address}",
1003 .type = "IPV6 ADDRESS",
1004 .help = "standard IPv6 address notation",
1005 .call = parse_ipv6_addr,
1009 .name = "{rule id}",
1011 .help = "rule identifier",
1013 .comp = comp_rule_id,
1016 .name = "{port_id}",
1018 .help = "port identifier",
1023 .name = "{group_id}",
1025 .help = "group identifier",
1029 [PRIORITY_LEVEL] = {
1032 .help = "priority level",
1036 /* Top-level command. */
1039 .type = "{command} {port_id} [{arg} [...]]",
1040 .help = "manage ingress/egress flow rules",
1041 .next = NEXT(NEXT_ENTRY
1051 /* Sub-level commands. */
1054 .help = "check whether a flow rule can be created",
1055 .next = NEXT(next_vc_attr, NEXT_ENTRY(PORT_ID)),
1056 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1061 .help = "create a flow rule",
1062 .next = NEXT(next_vc_attr, NEXT_ENTRY(PORT_ID)),
1063 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1068 .help = "destroy specific flow rules",
1069 .next = NEXT(NEXT_ENTRY(DESTROY_RULE), NEXT_ENTRY(PORT_ID)),
1070 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1071 .call = parse_destroy,
1075 .help = "destroy all flow rules",
1076 .next = NEXT(NEXT_ENTRY(PORT_ID)),
1077 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1078 .call = parse_flush,
1082 .help = "query an existing flow rule",
1083 .next = NEXT(NEXT_ENTRY(QUERY_ACTION),
1084 NEXT_ENTRY(RULE_ID),
1085 NEXT_ENTRY(PORT_ID)),
1086 .args = ARGS(ARGS_ENTRY(struct buffer, args.query.action),
1087 ARGS_ENTRY(struct buffer, args.query.rule),
1088 ARGS_ENTRY(struct buffer, port)),
1089 .call = parse_query,
1093 .help = "list existing flow rules",
1094 .next = NEXT(next_list_attr, NEXT_ENTRY(PORT_ID)),
1095 .args = ARGS(ARGS_ENTRY(struct buffer, port)),
1100 .help = "restrict ingress traffic to the defined flow rules",
1101 .next = NEXT(NEXT_ENTRY(BOOLEAN),
1102 NEXT_ENTRY(PORT_ID)),
1103 .args = ARGS(ARGS_ENTRY(struct buffer, args.isolate.set),
1104 ARGS_ENTRY(struct buffer, port)),
1105 .call = parse_isolate,
1107 /* Destroy arguments. */
1110 .help = "specify a rule identifier",
1111 .next = NEXT(next_destroy_attr, NEXT_ENTRY(RULE_ID)),
1112 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.destroy.rule)),
1113 .call = parse_destroy,
1115 /* Query arguments. */
1119 .help = "action to query, must be part of the rule",
1120 .call = parse_action,
1121 .comp = comp_action,
1123 /* List arguments. */
1126 .help = "specify a group",
1127 .next = NEXT(next_list_attr, NEXT_ENTRY(GROUP_ID)),
1128 .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.list.group)),
1131 /* Validate/create attributes. */
1134 .help = "specify a group",
1135 .next = NEXT(next_vc_attr, NEXT_ENTRY(GROUP_ID)),
1136 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, group)),
1141 .help = "specify a priority level",
1142 .next = NEXT(next_vc_attr, NEXT_ENTRY(PRIORITY_LEVEL)),
1143 .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, priority)),
1148 .help = "affect rule to ingress",
1149 .next = NEXT(next_vc_attr),
1154 .help = "affect rule to egress",
1155 .next = NEXT(next_vc_attr),
1160 .help = "apply rule directly to endpoints found in pattern",
1161 .next = NEXT(next_vc_attr),
1164 /* Validate/create pattern. */
1167 .help = "submit a list of pattern items",
1168 .next = NEXT(next_item),
1173 .help = "match value perfectly (with full bit-mask)",
1174 .call = parse_vc_spec,
1176 [ITEM_PARAM_SPEC] = {
1178 .help = "match value according to configured bit-mask",
1179 .call = parse_vc_spec,
1181 [ITEM_PARAM_LAST] = {
1183 .help = "specify upper bound to establish a range",
1184 .call = parse_vc_spec,
1186 [ITEM_PARAM_MASK] = {
1188 .help = "specify bit-mask with relevant bits set to one",
1189 .call = parse_vc_spec,
1191 [ITEM_PARAM_PREFIX] = {
1193 .help = "generate bit-mask from a prefix length",
1194 .call = parse_vc_spec,
1198 .help = "specify next pattern item",
1199 .next = NEXT(next_item),
1203 .help = "end list of pattern items",
1204 .priv = PRIV_ITEM(END, 0),
1205 .next = NEXT(NEXT_ENTRY(ACTIONS)),
1210 .help = "no-op pattern item",
1211 .priv = PRIV_ITEM(VOID, 0),
1212 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
1217 .help = "perform actions when pattern does not match",
1218 .priv = PRIV_ITEM(INVERT, 0),
1219 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
1224 .help = "match any protocol for the current layer",
1225 .priv = PRIV_ITEM(ANY, sizeof(struct rte_flow_item_any)),
1226 .next = NEXT(item_any),
1231 .help = "number of layers covered",
1232 .next = NEXT(item_any, NEXT_ENTRY(UNSIGNED), item_param),
1233 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_any, num)),
1237 .help = "match traffic from/to the physical function",
1238 .priv = PRIV_ITEM(PF, 0),
1239 .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
1244 .help = "match traffic from/to a virtual function ID",
1245 .priv = PRIV_ITEM(VF, sizeof(struct rte_flow_item_vf)),
1246 .next = NEXT(item_vf),
1252 .next = NEXT(item_vf, NEXT_ENTRY(UNSIGNED), item_param),
1253 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_vf, id)),
1257 .help = "match traffic from/to a specific physical port",
1258 .priv = PRIV_ITEM(PHY_PORT,
1259 sizeof(struct rte_flow_item_phy_port)),
1260 .next = NEXT(item_phy_port),
1263 [ITEM_PHY_PORT_INDEX] = {
1265 .help = "physical port index",
1266 .next = NEXT(item_phy_port, NEXT_ENTRY(UNSIGNED), item_param),
1267 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_phy_port, index)),
1271 .help = "match traffic from/to a given DPDK port ID",
1272 .priv = PRIV_ITEM(PORT_ID,
1273 sizeof(struct rte_flow_item_port_id)),
1274 .next = NEXT(item_port_id),
1277 [ITEM_PORT_ID_ID] = {
1279 .help = "DPDK port ID",
1280 .next = NEXT(item_port_id, NEXT_ENTRY(UNSIGNED), item_param),
1281 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port_id, id)),
1285 .help = "match an arbitrary byte string",
1286 .priv = PRIV_ITEM(RAW, ITEM_RAW_SIZE),
1287 .next = NEXT(item_raw),
1290 [ITEM_RAW_RELATIVE] = {
1292 .help = "look for pattern after the previous item",
1293 .next = NEXT(item_raw, NEXT_ENTRY(BOOLEAN), item_param),
1294 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
1297 [ITEM_RAW_SEARCH] = {
1299 .help = "search pattern from offset (see also limit)",
1300 .next = NEXT(item_raw, NEXT_ENTRY(BOOLEAN), item_param),
1301 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
1304 [ITEM_RAW_OFFSET] = {
1306 .help = "absolute or relative offset for pattern",
1307 .next = NEXT(item_raw, NEXT_ENTRY(INTEGER), item_param),
1308 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, offset)),
1310 [ITEM_RAW_LIMIT] = {
1312 .help = "search area limit for start of pattern",
1313 .next = NEXT(item_raw, NEXT_ENTRY(UNSIGNED), item_param),
1314 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, limit)),
1316 [ITEM_RAW_PATTERN] = {
1318 .help = "byte string to look for",
1319 .next = NEXT(item_raw,
1321 NEXT_ENTRY(ITEM_PARAM_IS,
1324 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern),
1325 ARGS_ENTRY(struct rte_flow_item_raw, length),
1326 ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw),
1327 ITEM_RAW_PATTERN_SIZE)),
1331 .help = "match Ethernet header",
1332 .priv = PRIV_ITEM(ETH, sizeof(struct rte_flow_item_eth)),
1333 .next = NEXT(item_eth),
1338 .help = "destination MAC",
1339 .next = NEXT(item_eth, NEXT_ENTRY(MAC_ADDR), item_param),
1340 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, dst)),
1344 .help = "source MAC",
1345 .next = NEXT(item_eth, NEXT_ENTRY(MAC_ADDR), item_param),
1346 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, src)),
1350 .help = "EtherType",
1351 .next = NEXT(item_eth, NEXT_ENTRY(UNSIGNED), item_param),
1352 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, type)),
1356 .help = "match 802.1Q/ad VLAN tag",
1357 .priv = PRIV_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)),
1358 .next = NEXT(item_vlan),
1363 .help = "tag control information",
1364 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
1365 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, tci)),
1369 .help = "priority code point",
1370 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
1371 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
1376 .help = "drop eligible indicator",
1377 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
1378 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
1383 .help = "VLAN identifier",
1384 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
1385 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
1388 [ITEM_VLAN_INNER_TYPE] = {
1389 .name = "inner_type",
1390 .help = "inner EtherType",
1391 .next = NEXT(item_vlan, NEXT_ENTRY(UNSIGNED), item_param),
1392 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan,
1397 .help = "match IPv4 header",
1398 .priv = PRIV_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)),
1399 .next = NEXT(item_ipv4),
1404 .help = "type of service",
1405 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
1406 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
1407 hdr.type_of_service)),
1411 .help = "time to live",
1412 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
1413 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
1416 [ITEM_IPV4_PROTO] = {
1418 .help = "next protocol ID",
1419 .next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
1420 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
1421 hdr.next_proto_id)),
1425 .help = "source address",
1426 .next = NEXT(item_ipv4, NEXT_ENTRY(IPV4_ADDR), item_param),
1427 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
1432 .help = "destination address",
1433 .next = NEXT(item_ipv4, NEXT_ENTRY(IPV4_ADDR), item_param),
1434 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
1439 .help = "match IPv6 header",
1440 .priv = PRIV_ITEM(IPV6, sizeof(struct rte_flow_item_ipv6)),
1441 .next = NEXT(item_ipv6),
1446 .help = "traffic class",
1447 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
1448 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
1450 "\x0f\xf0\x00\x00")),
1452 [ITEM_IPV6_FLOW] = {
1454 .help = "flow label",
1455 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
1456 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
1458 "\x00\x0f\xff\xff")),
1460 [ITEM_IPV6_PROTO] = {
1462 .help = "protocol (next header)",
1463 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
1464 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
1469 .help = "hop limit",
1470 .next = NEXT(item_ipv6, NEXT_ENTRY(UNSIGNED), item_param),
1471 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
1476 .help = "source address",
1477 .next = NEXT(item_ipv6, NEXT_ENTRY(IPV6_ADDR), item_param),
1478 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
1483 .help = "destination address",
1484 .next = NEXT(item_ipv6, NEXT_ENTRY(IPV6_ADDR), item_param),
1485 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
1490 .help = "match ICMP header",
1491 .priv = PRIV_ITEM(ICMP, sizeof(struct rte_flow_item_icmp)),
1492 .next = NEXT(item_icmp),
1495 [ITEM_ICMP_TYPE] = {
1497 .help = "ICMP packet type",
1498 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
1499 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
1502 [ITEM_ICMP_CODE] = {
1504 .help = "ICMP packet code",
1505 .next = NEXT(item_icmp, NEXT_ENTRY(UNSIGNED), item_param),
1506 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
1511 .help = "match UDP header",
1512 .priv = PRIV_ITEM(UDP, sizeof(struct rte_flow_item_udp)),
1513 .next = NEXT(item_udp),
1518 .help = "UDP source port",
1519 .next = NEXT(item_udp, NEXT_ENTRY(UNSIGNED), item_param),
1520 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
1525 .help = "UDP destination port",
1526 .next = NEXT(item_udp, NEXT_ENTRY(UNSIGNED), item_param),
1527 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
1532 .help = "match TCP header",
1533 .priv = PRIV_ITEM(TCP, sizeof(struct rte_flow_item_tcp)),
1534 .next = NEXT(item_tcp),
1539 .help = "TCP source port",
1540 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
1541 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
1546 .help = "TCP destination port",
1547 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
1548 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
1551 [ITEM_TCP_FLAGS] = {
1553 .help = "TCP flags",
1554 .next = NEXT(item_tcp, NEXT_ENTRY(UNSIGNED), item_param),
1555 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
1560 .help = "match SCTP header",
1561 .priv = PRIV_ITEM(SCTP, sizeof(struct rte_flow_item_sctp)),
1562 .next = NEXT(item_sctp),
1567 .help = "SCTP source port",
1568 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
1569 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
1574 .help = "SCTP destination port",
1575 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
1576 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
1581 .help = "validation tag",
1582 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
1583 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
1586 [ITEM_SCTP_CKSUM] = {
1589 .next = NEXT(item_sctp, NEXT_ENTRY(UNSIGNED), item_param),
1590 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
1595 .help = "match VXLAN header",
1596 .priv = PRIV_ITEM(VXLAN, sizeof(struct rte_flow_item_vxlan)),
1597 .next = NEXT(item_vxlan),
1600 [ITEM_VXLAN_VNI] = {
1602 .help = "VXLAN identifier",
1603 .next = NEXT(item_vxlan, NEXT_ENTRY(UNSIGNED), item_param),
1604 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan, vni)),
1608 .help = "match E-Tag header",
1609 .priv = PRIV_ITEM(E_TAG, sizeof(struct rte_flow_item_e_tag)),
1610 .next = NEXT(item_e_tag),
1613 [ITEM_E_TAG_GRP_ECID_B] = {
1614 .name = "grp_ecid_b",
1615 .help = "GRP and E-CID base",
1616 .next = NEXT(item_e_tag, NEXT_ENTRY(UNSIGNED), item_param),
1617 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_e_tag,
1623 .help = "match NVGRE header",
1624 .priv = PRIV_ITEM(NVGRE, sizeof(struct rte_flow_item_nvgre)),
1625 .next = NEXT(item_nvgre),
1628 [ITEM_NVGRE_TNI] = {
1630 .help = "virtual subnet ID",
1631 .next = NEXT(item_nvgre, NEXT_ENTRY(UNSIGNED), item_param),
1632 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_nvgre, tni)),
1636 .help = "match MPLS header",
1637 .priv = PRIV_ITEM(MPLS, sizeof(struct rte_flow_item_mpls)),
1638 .next = NEXT(item_mpls),
1641 [ITEM_MPLS_LABEL] = {
1643 .help = "MPLS label",
1644 .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
1645 .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
1651 .help = "match GRE header",
1652 .priv = PRIV_ITEM(GRE, sizeof(struct rte_flow_item_gre)),
1653 .next = NEXT(item_gre),
1656 [ITEM_GRE_PROTO] = {
1658 .help = "GRE protocol type",
1659 .next = NEXT(item_gre, NEXT_ENTRY(UNSIGNED), item_param),
1660 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
1665 .help = "fuzzy pattern match, expect faster than default",
1666 .priv = PRIV_ITEM(FUZZY,
1667 sizeof(struct rte_flow_item_fuzzy)),
1668 .next = NEXT(item_fuzzy),
1671 [ITEM_FUZZY_THRESH] = {
1673 .help = "match accuracy threshold",
1674 .next = NEXT(item_fuzzy, NEXT_ENTRY(UNSIGNED), item_param),
1675 .args = ARGS(ARGS_ENTRY(struct rte_flow_item_fuzzy,
1680 .help = "match GTP header",
1681 .priv = PRIV_ITEM(GTP, sizeof(struct rte_flow_item_gtp)),
1682 .next = NEXT(item_gtp),
1687 .help = "tunnel endpoint identifier",
1688 .next = NEXT(item_gtp, NEXT_ENTRY(UNSIGNED), item_param),
1689 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp, teid)),
1693 .help = "match GTP header",
1694 .priv = PRIV_ITEM(GTPC, sizeof(struct rte_flow_item_gtp)),
1695 .next = NEXT(item_gtp),
1700 .help = "match GTP header",
1701 .priv = PRIV_ITEM(GTPU, sizeof(struct rte_flow_item_gtp)),
1702 .next = NEXT(item_gtp),
1707 .help = "match GENEVE header",
1708 .priv = PRIV_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)),
1709 .next = NEXT(item_geneve),
1712 [ITEM_GENEVE_VNI] = {
1714 .help = "virtual network identifier",
1715 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
1716 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve, vni)),
1718 [ITEM_GENEVE_PROTO] = {
1720 .help = "GENEVE protocol type",
1721 .next = NEXT(item_geneve, NEXT_ENTRY(UNSIGNED), item_param),
1722 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve,
1725 [ITEM_VXLAN_GPE] = {
1726 .name = "vxlan-gpe",
1727 .help = "match VXLAN-GPE header",
1728 .priv = PRIV_ITEM(VXLAN_GPE,
1729 sizeof(struct rte_flow_item_vxlan_gpe)),
1730 .next = NEXT(item_vxlan_gpe),
1733 [ITEM_VXLAN_GPE_VNI] = {
1735 .help = "VXLAN-GPE identifier",
1736 .next = NEXT(item_vxlan_gpe, NEXT_ENTRY(UNSIGNED), item_param),
1737 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
1740 [ITEM_ARP_ETH_IPV4] = {
1741 .name = "arp_eth_ipv4",
1742 .help = "match ARP header for Ethernet/IPv4",
1743 .priv = PRIV_ITEM(ARP_ETH_IPV4,
1744 sizeof(struct rte_flow_item_arp_eth_ipv4)),
1745 .next = NEXT(item_arp_eth_ipv4),
1748 [ITEM_ARP_ETH_IPV4_SHA] = {
1750 .help = "sender hardware address",
1751 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(MAC_ADDR),
1753 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
1756 [ITEM_ARP_ETH_IPV4_SPA] = {
1758 .help = "sender IPv4 address",
1759 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(IPV4_ADDR),
1761 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
1764 [ITEM_ARP_ETH_IPV4_THA] = {
1766 .help = "target hardware address",
1767 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(MAC_ADDR),
1769 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
1772 [ITEM_ARP_ETH_IPV4_TPA] = {
1774 .help = "target IPv4 address",
1775 .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(IPV4_ADDR),
1777 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
1782 .help = "match presence of any IPv6 extension header",
1783 .priv = PRIV_ITEM(IPV6_EXT,
1784 sizeof(struct rte_flow_item_ipv6_ext)),
1785 .next = NEXT(item_ipv6_ext),
1788 [ITEM_IPV6_EXT_NEXT_HDR] = {
1790 .help = "next header",
1791 .next = NEXT(item_ipv6_ext, NEXT_ENTRY(UNSIGNED), item_param),
1792 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_ext,
1797 .help = "match any ICMPv6 header",
1798 .priv = PRIV_ITEM(ICMP6, sizeof(struct rte_flow_item_icmp6)),
1799 .next = NEXT(item_icmp6),
1802 [ITEM_ICMP6_TYPE] = {
1804 .help = "ICMPv6 type",
1805 .next = NEXT(item_icmp6, NEXT_ENTRY(UNSIGNED), item_param),
1806 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
1809 [ITEM_ICMP6_CODE] = {
1811 .help = "ICMPv6 code",
1812 .next = NEXT(item_icmp6, NEXT_ENTRY(UNSIGNED), item_param),
1813 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
1816 [ITEM_ICMP6_ND_NS] = {
1817 .name = "icmp6_nd_ns",
1818 .help = "match ICMPv6 neighbor discovery solicitation",
1819 .priv = PRIV_ITEM(ICMP6_ND_NS,
1820 sizeof(struct rte_flow_item_icmp6_nd_ns)),
1821 .next = NEXT(item_icmp6_nd_ns),
1824 [ITEM_ICMP6_ND_NS_TARGET_ADDR] = {
1825 .name = "target_addr",
1826 .help = "target address",
1827 .next = NEXT(item_icmp6_nd_ns, NEXT_ENTRY(IPV6_ADDR),
1829 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_ns,
1832 [ITEM_ICMP6_ND_NA] = {
1833 .name = "icmp6_nd_na",
1834 .help = "match ICMPv6 neighbor discovery advertisement",
1835 .priv = PRIV_ITEM(ICMP6_ND_NA,
1836 sizeof(struct rte_flow_item_icmp6_nd_na)),
1837 .next = NEXT(item_icmp6_nd_na),
1840 [ITEM_ICMP6_ND_NA_TARGET_ADDR] = {
1841 .name = "target_addr",
1842 .help = "target address",
1843 .next = NEXT(item_icmp6_nd_na, NEXT_ENTRY(IPV6_ADDR),
1845 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_na,
1848 [ITEM_ICMP6_ND_OPT] = {
1849 .name = "icmp6_nd_opt",
1850 .help = "match presence of any ICMPv6 neighbor discovery"
1852 .priv = PRIV_ITEM(ICMP6_ND_OPT,
1853 sizeof(struct rte_flow_item_icmp6_nd_opt)),
1854 .next = NEXT(item_icmp6_nd_opt),
1857 [ITEM_ICMP6_ND_OPT_TYPE] = {
1859 .help = "ND option type",
1860 .next = NEXT(item_icmp6_nd_opt, NEXT_ENTRY(UNSIGNED),
1862 .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_opt,
1865 [ITEM_ICMP6_ND_OPT_SLA_ETH] = {
1866 .name = "icmp6_nd_opt_sla_eth",
1867 .help = "match ICMPv6 neighbor discovery source Ethernet"
1868 " link-layer address option",
1870 (ICMP6_ND_OPT_SLA_ETH,
1871 sizeof(struct rte_flow_item_icmp6_nd_opt_sla_eth)),
1872 .next = NEXT(item_icmp6_nd_opt_sla_eth),
1875 [ITEM_ICMP6_ND_OPT_SLA_ETH_SLA] = {
1877 .help = "source Ethernet LLA",
1878 .next = NEXT(item_icmp6_nd_opt_sla_eth, NEXT_ENTRY(MAC_ADDR),
1880 .args = ARGS(ARGS_ENTRY_HTON
1881 (struct rte_flow_item_icmp6_nd_opt_sla_eth, sla)),
1883 [ITEM_ICMP6_ND_OPT_TLA_ETH] = {
1884 .name = "icmp6_nd_opt_tla_eth",
1885 .help = "match ICMPv6 neighbor discovery target Ethernet"
1886 " link-layer address option",
1888 (ICMP6_ND_OPT_TLA_ETH,
1889 sizeof(struct rte_flow_item_icmp6_nd_opt_tla_eth)),
1890 .next = NEXT(item_icmp6_nd_opt_tla_eth),
1893 [ITEM_ICMP6_ND_OPT_TLA_ETH_TLA] = {
1895 .help = "target Ethernet LLA",
1896 .next = NEXT(item_icmp6_nd_opt_tla_eth, NEXT_ENTRY(MAC_ADDR),
1898 .args = ARGS(ARGS_ENTRY_HTON
1899 (struct rte_flow_item_icmp6_nd_opt_tla_eth, tla)),
1902 /* Validate/create actions. */
1905 .help = "submit a list of associated actions",
1906 .next = NEXT(next_action),
1911 .help = "specify next action",
1912 .next = NEXT(next_action),
1916 .help = "end list of actions",
1917 .priv = PRIV_ACTION(END, 0),
1922 .help = "no-op action",
1923 .priv = PRIV_ACTION(VOID, 0),
1924 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
1927 [ACTION_PASSTHRU] = {
1929 .help = "let subsequent rule process matched packets",
1930 .priv = PRIV_ACTION(PASSTHRU, 0),
1931 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
1936 .help = "attach 32 bit value to packets",
1937 .priv = PRIV_ACTION(MARK, sizeof(struct rte_flow_action_mark)),
1938 .next = NEXT(action_mark),
1941 [ACTION_MARK_ID] = {
1943 .help = "32 bit value to return with packets",
1944 .next = NEXT(action_mark, NEXT_ENTRY(UNSIGNED)),
1945 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_mark, id)),
1946 .call = parse_vc_conf,
1950 .help = "flag packets",
1951 .priv = PRIV_ACTION(FLAG, 0),
1952 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
1957 .help = "assign packets to a given queue index",
1958 .priv = PRIV_ACTION(QUEUE,
1959 sizeof(struct rte_flow_action_queue)),
1960 .next = NEXT(action_queue),
1963 [ACTION_QUEUE_INDEX] = {
1965 .help = "queue index to use",
1966 .next = NEXT(action_queue, NEXT_ENTRY(UNSIGNED)),
1967 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_queue, index)),
1968 .call = parse_vc_conf,
1972 .help = "drop packets (note: passthru has priority)",
1973 .priv = PRIV_ACTION(DROP, 0),
1974 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
1979 .help = "enable counters for this rule",
1980 .priv = PRIV_ACTION(COUNT, 0),
1981 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
1986 .help = "spread packets among several queues",
1987 .priv = PRIV_ACTION(RSS, sizeof(struct action_rss_data)),
1988 .next = NEXT(action_rss),
1989 .call = parse_vc_action_rss,
1991 [ACTION_RSS_FUNC] = {
1993 .help = "RSS hash function to apply",
1994 .next = NEXT(action_rss,
1995 NEXT_ENTRY(ACTION_RSS_FUNC_DEFAULT,
1996 ACTION_RSS_FUNC_TOEPLITZ,
1997 ACTION_RSS_FUNC_SIMPLE_XOR)),
1999 [ACTION_RSS_FUNC_DEFAULT] = {
2001 .help = "default hash function",
2002 .call = parse_vc_action_rss_func,
2004 [ACTION_RSS_FUNC_TOEPLITZ] = {
2006 .help = "Toeplitz hash function",
2007 .call = parse_vc_action_rss_func,
2009 [ACTION_RSS_FUNC_SIMPLE_XOR] = {
2010 .name = "simple_xor",
2011 .help = "simple XOR hash function",
2012 .call = parse_vc_action_rss_func,
2014 [ACTION_RSS_LEVEL] = {
2016 .help = "encapsulation level for \"types\"",
2017 .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
2018 .args = ARGS(ARGS_ENTRY_ARB
2019 (offsetof(struct action_rss_data, conf) +
2020 offsetof(struct rte_flow_action_rss, level),
2021 sizeof(((struct rte_flow_action_rss *)0)->
2024 [ACTION_RSS_TYPES] = {
2026 .help = "specific RSS hash types",
2027 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)),
2029 [ACTION_RSS_TYPE] = {
2031 .help = "RSS hash type",
2032 .call = parse_vc_action_rss_type,
2033 .comp = comp_vc_action_rss_type,
2035 [ACTION_RSS_KEY] = {
2037 .help = "RSS hash key",
2038 .next = NEXT(action_rss, NEXT_ENTRY(STRING)),
2039 .args = ARGS(ARGS_ENTRY_ARB(0, 0),
2041 (offsetof(struct action_rss_data, conf) +
2042 offsetof(struct rte_flow_action_rss, key_len),
2043 sizeof(((struct rte_flow_action_rss *)0)->
2045 ARGS_ENTRY(struct action_rss_data, key)),
2047 [ACTION_RSS_KEY_LEN] = {
2049 .help = "RSS hash key length in bytes",
2050 .next = NEXT(action_rss, NEXT_ENTRY(UNSIGNED)),
2051 .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
2052 (offsetof(struct action_rss_data, conf) +
2053 offsetof(struct rte_flow_action_rss, key_len),
2054 sizeof(((struct rte_flow_action_rss *)0)->
2057 RSS_HASH_KEY_LENGTH)),
2059 [ACTION_RSS_QUEUES] = {
2061 .help = "queue indices to use",
2062 .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_QUEUE)),
2063 .call = parse_vc_conf,
2065 [ACTION_RSS_QUEUE] = {
2067 .help = "queue index",
2068 .call = parse_vc_action_rss_queue,
2069 .comp = comp_vc_action_rss_queue,
2073 .help = "direct traffic to physical function",
2074 .priv = PRIV_ACTION(PF, 0),
2075 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
2080 .help = "direct traffic to a virtual function ID",
2081 .priv = PRIV_ACTION(VF, sizeof(struct rte_flow_action_vf)),
2082 .next = NEXT(action_vf),
2085 [ACTION_VF_ORIGINAL] = {
2087 .help = "use original VF ID if possible",
2088 .next = NEXT(action_vf, NEXT_ENTRY(BOOLEAN)),
2089 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_vf,
2091 .call = parse_vc_conf,
2096 .next = NEXT(action_vf, NEXT_ENTRY(UNSIGNED)),
2097 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)),
2098 .call = parse_vc_conf,
2100 [ACTION_PHY_PORT] = {
2102 .help = "direct packets to physical port index",
2103 .priv = PRIV_ACTION(PHY_PORT,
2104 sizeof(struct rte_flow_action_phy_port)),
2105 .next = NEXT(action_phy_port),
2108 [ACTION_PHY_PORT_ORIGINAL] = {
2110 .help = "use original port index if possible",
2111 .next = NEXT(action_phy_port, NEXT_ENTRY(BOOLEAN)),
2112 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_phy_port,
2114 .call = parse_vc_conf,
2116 [ACTION_PHY_PORT_INDEX] = {
2118 .help = "physical port index",
2119 .next = NEXT(action_phy_port, NEXT_ENTRY(UNSIGNED)),
2120 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_phy_port,
2122 .call = parse_vc_conf,
2124 [ACTION_PORT_ID] = {
2126 .help = "direct matching traffic to a given DPDK port ID",
2127 .priv = PRIV_ACTION(PORT_ID,
2128 sizeof(struct rte_flow_action_port_id)),
2129 .next = NEXT(action_port_id),
2132 [ACTION_PORT_ID_ORIGINAL] = {
2134 .help = "use original DPDK port ID if possible",
2135 .next = NEXT(action_port_id, NEXT_ENTRY(BOOLEAN)),
2136 .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_port_id,
2138 .call = parse_vc_conf,
2140 [ACTION_PORT_ID_ID] = {
2142 .help = "DPDK port ID",
2143 .next = NEXT(action_port_id, NEXT_ENTRY(UNSIGNED)),
2144 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_port_id, id)),
2145 .call = parse_vc_conf,
2149 .help = "meter the directed packets at given id",
2150 .priv = PRIV_ACTION(METER,
2151 sizeof(struct rte_flow_action_meter)),
2152 .next = NEXT(action_meter),
2155 [ACTION_METER_ID] = {
2157 .help = "meter id to use",
2158 .next = NEXT(action_meter, NEXT_ENTRY(UNSIGNED)),
2159 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter, mtr_id)),
2160 .call = parse_vc_conf,
2162 [ACTION_OF_SET_MPLS_TTL] = {
2163 .name = "of_set_mpls_ttl",
2164 .help = "OpenFlow's OFPAT_SET_MPLS_TTL",
2167 sizeof(struct rte_flow_action_of_set_mpls_ttl)),
2168 .next = NEXT(action_of_set_mpls_ttl),
2171 [ACTION_OF_SET_MPLS_TTL_MPLS_TTL] = {
2174 .next = NEXT(action_of_set_mpls_ttl, NEXT_ENTRY(UNSIGNED)),
2175 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_mpls_ttl,
2177 .call = parse_vc_conf,
2179 [ACTION_OF_DEC_MPLS_TTL] = {
2180 .name = "of_dec_mpls_ttl",
2181 .help = "OpenFlow's OFPAT_DEC_MPLS_TTL",
2182 .priv = PRIV_ACTION(OF_DEC_MPLS_TTL, 0),
2183 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
2186 [ACTION_OF_SET_NW_TTL] = {
2187 .name = "of_set_nw_ttl",
2188 .help = "OpenFlow's OFPAT_SET_NW_TTL",
2191 sizeof(struct rte_flow_action_of_set_nw_ttl)),
2192 .next = NEXT(action_of_set_nw_ttl),
2195 [ACTION_OF_SET_NW_TTL_NW_TTL] = {
2198 .next = NEXT(action_of_set_nw_ttl, NEXT_ENTRY(UNSIGNED)),
2199 .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_nw_ttl,
2201 .call = parse_vc_conf,
2203 [ACTION_OF_DEC_NW_TTL] = {
2204 .name = "of_dec_nw_ttl",
2205 .help = "OpenFlow's OFPAT_DEC_NW_TTL",
2206 .priv = PRIV_ACTION(OF_DEC_NW_TTL, 0),
2207 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
2210 [ACTION_OF_COPY_TTL_OUT] = {
2211 .name = "of_copy_ttl_out",
2212 .help = "OpenFlow's OFPAT_COPY_TTL_OUT",
2213 .priv = PRIV_ACTION(OF_COPY_TTL_OUT, 0),
2214 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
2217 [ACTION_OF_COPY_TTL_IN] = {
2218 .name = "of_copy_ttl_in",
2219 .help = "OpenFlow's OFPAT_COPY_TTL_IN",
2220 .priv = PRIV_ACTION(OF_COPY_TTL_IN, 0),
2221 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
2224 [ACTION_OF_POP_VLAN] = {
2225 .name = "of_pop_vlan",
2226 .help = "OpenFlow's OFPAT_POP_VLAN",
2227 .priv = PRIV_ACTION(OF_POP_VLAN, 0),
2228 .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
2231 [ACTION_OF_PUSH_VLAN] = {
2232 .name = "of_push_vlan",
2233 .help = "OpenFlow's OFPAT_PUSH_VLAN",
2236 sizeof(struct rte_flow_action_of_push_vlan)),
2237 .next = NEXT(action_of_push_vlan),
2240 [ACTION_OF_PUSH_VLAN_ETHERTYPE] = {
2241 .name = "ethertype",
2242 .help = "EtherType",
2243 .next = NEXT(action_of_push_vlan, NEXT_ENTRY(UNSIGNED)),
2244 .args = ARGS(ARGS_ENTRY_HTON
2245 (struct rte_flow_action_of_push_vlan,
2247 .call = parse_vc_conf,
2249 [ACTION_OF_SET_VLAN_VID] = {
2250 .name = "of_set_vlan_vid",
2251 .help = "OpenFlow's OFPAT_SET_VLAN_VID",
2254 sizeof(struct rte_flow_action_of_set_vlan_vid)),
2255 .next = NEXT(action_of_set_vlan_vid),
2258 [ACTION_OF_SET_VLAN_VID_VLAN_VID] = {
2261 .next = NEXT(action_of_set_vlan_vid, NEXT_ENTRY(UNSIGNED)),
2262 .args = ARGS(ARGS_ENTRY_HTON
2263 (struct rte_flow_action_of_set_vlan_vid,
2265 .call = parse_vc_conf,
2267 [ACTION_OF_SET_VLAN_PCP] = {
2268 .name = "of_set_vlan_pcp",
2269 .help = "OpenFlow's OFPAT_SET_VLAN_PCP",
2272 sizeof(struct rte_flow_action_of_set_vlan_pcp)),
2273 .next = NEXT(action_of_set_vlan_pcp),
2276 [ACTION_OF_SET_VLAN_PCP_VLAN_PCP] = {
2278 .help = "VLAN priority",
2279 .next = NEXT(action_of_set_vlan_pcp, NEXT_ENTRY(UNSIGNED)),
2280 .args = ARGS(ARGS_ENTRY_HTON
2281 (struct rte_flow_action_of_set_vlan_pcp,
2283 .call = parse_vc_conf,
2285 [ACTION_OF_POP_MPLS] = {
2286 .name = "of_pop_mpls",
2287 .help = "OpenFlow's OFPAT_POP_MPLS",
2288 .priv = PRIV_ACTION(OF_POP_MPLS,
2289 sizeof(struct rte_flow_action_of_pop_mpls)),
2290 .next = NEXT(action_of_pop_mpls),
2293 [ACTION_OF_POP_MPLS_ETHERTYPE] = {
2294 .name = "ethertype",
2295 .help = "EtherType",
2296 .next = NEXT(action_of_pop_mpls, NEXT_ENTRY(UNSIGNED)),
2297 .args = ARGS(ARGS_ENTRY_HTON
2298 (struct rte_flow_action_of_pop_mpls,
2300 .call = parse_vc_conf,
2302 [ACTION_OF_PUSH_MPLS] = {
2303 .name = "of_push_mpls",
2304 .help = "OpenFlow's OFPAT_PUSH_MPLS",
2307 sizeof(struct rte_flow_action_of_push_mpls)),
2308 .next = NEXT(action_of_push_mpls),
2311 [ACTION_OF_PUSH_MPLS_ETHERTYPE] = {
2312 .name = "ethertype",
2313 .help = "EtherType",
2314 .next = NEXT(action_of_push_mpls, NEXT_ENTRY(UNSIGNED)),
2315 .args = ARGS(ARGS_ENTRY_HTON
2316 (struct rte_flow_action_of_push_mpls,
2318 .call = parse_vc_conf,
2322 /** Remove and return last entry from argument stack. */
2323 static const struct arg *
2324 pop_args(struct context *ctx)
2326 return ctx->args_num ? ctx->args[--ctx->args_num] : NULL;
2329 /** Add entry on top of the argument stack. */
2331 push_args(struct context *ctx, const struct arg *arg)
2333 if (ctx->args_num == CTX_STACK_SIZE)
2335 ctx->args[ctx->args_num++] = arg;
2339 /** Spread value into buffer according to bit-mask. */
2341 arg_entry_bf_fill(void *dst, uintmax_t val, const struct arg *arg)
2343 uint32_t i = arg->size;
2351 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
2360 unsigned int shift = 0;
2361 uint8_t *buf = (uint8_t *)dst + arg->offset + (i -= sub);
2363 for (shift = 0; arg->mask[i] >> shift; ++shift) {
2364 if (!(arg->mask[i] & (1 << shift)))
2369 *buf &= ~(1 << shift);
2370 *buf |= (val & 1) << shift;
2378 /** Compare a string with a partial one of a given length. */
2380 strcmp_partial(const char *full, const char *partial, size_t partial_len)
2382 int r = strncmp(full, partial, partial_len);
2386 if (strlen(full) <= partial_len)
2388 return full[partial_len];
2392 * Parse a prefix length and generate a bit-mask.
2394 * Last argument (ctx->args) is retrieved to determine mask size, storage
2395 * location and whether the result must use network byte ordering.
2398 parse_prefix(struct context *ctx, const struct token *token,
2399 const char *str, unsigned int len,
2400 void *buf, unsigned int size)
2402 const struct arg *arg = pop_args(ctx);
2403 static const uint8_t conv[] = "\x00\x80\xc0\xe0\xf0\xf8\xfc\xfe\xff";
2410 /* Argument is expected. */
2414 u = strtoumax(str, &end, 0);
2415 if (errno || (size_t)(end - str) != len)
2420 extra = arg_entry_bf_fill(NULL, 0, arg);
2429 if (!arg_entry_bf_fill(ctx->object, v, arg) ||
2430 !arg_entry_bf_fill(ctx->objmask, -1, arg))
2437 if (bytes > size || bytes + !!extra > size)
2441 buf = (uint8_t *)ctx->object + arg->offset;
2442 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
2444 memset((uint8_t *)buf + size - bytes, 0xff, bytes);
2445 memset(buf, 0x00, size - bytes);
2447 ((uint8_t *)buf)[size - bytes - 1] = conv[extra];
2451 memset(buf, 0xff, bytes);
2452 memset((uint8_t *)buf + bytes, 0x00, size - bytes);
2454 ((uint8_t *)buf)[bytes] = conv[extra];
2457 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
2460 push_args(ctx, arg);
2464 /** Default parsing function for token name matching. */
2466 parse_default(struct context *ctx, const struct token *token,
2467 const char *str, unsigned int len,
2468 void *buf, unsigned int size)
2473 if (strcmp_partial(token->name, str, len))
2478 /** Parse flow command, initialize output buffer for subsequent tokens. */
2480 parse_init(struct context *ctx, const struct token *token,
2481 const char *str, unsigned int len,
2482 void *buf, unsigned int size)
2484 struct buffer *out = buf;
2486 /* Token name must match. */
2487 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
2489 /* Nothing else to do if there is no buffer. */
2492 /* Make sure buffer is large enough. */
2493 if (size < sizeof(*out))
2495 /* Initialize buffer. */
2496 memset(out, 0x00, sizeof(*out));
2497 memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
2500 ctx->objmask = NULL;
2504 /** Parse tokens for validate/create commands. */
2506 parse_vc(struct context *ctx, const struct token *token,
2507 const char *str, unsigned int len,
2508 void *buf, unsigned int size)
2510 struct buffer *out = buf;
2514 /* Token name must match. */
2515 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
2517 /* Nothing else to do if there is no buffer. */
2520 if (!out->command) {
2521 if (ctx->curr != VALIDATE && ctx->curr != CREATE)
2523 if (sizeof(*out) > size)
2525 out->command = ctx->curr;
2528 ctx->objmask = NULL;
2529 out->args.vc.data = (uint8_t *)out + size;
2533 ctx->object = &out->args.vc.attr;
2534 ctx->objmask = NULL;
2535 switch (ctx->curr) {
2540 out->args.vc.attr.ingress = 1;
2543 out->args.vc.attr.egress = 1;
2546 out->args.vc.attr.transfer = 1;
2549 out->args.vc.pattern =
2550 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
2552 ctx->object = out->args.vc.pattern;
2553 ctx->objmask = NULL;
2556 out->args.vc.actions =
2557 (void *)RTE_ALIGN_CEIL((uintptr_t)
2558 (out->args.vc.pattern +
2559 out->args.vc.pattern_n),
2561 ctx->object = out->args.vc.actions;
2562 ctx->objmask = NULL;
2569 if (!out->args.vc.actions) {
2570 const struct parse_item_priv *priv = token->priv;
2571 struct rte_flow_item *item =
2572 out->args.vc.pattern + out->args.vc.pattern_n;
2574 data_size = priv->size * 3; /* spec, last, mask */
2575 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
2576 (out->args.vc.data - data_size),
2578 if ((uint8_t *)item + sizeof(*item) > data)
2580 *item = (struct rte_flow_item){
2583 ++out->args.vc.pattern_n;
2585 ctx->objmask = NULL;
2587 const struct parse_action_priv *priv = token->priv;
2588 struct rte_flow_action *action =
2589 out->args.vc.actions + out->args.vc.actions_n;
2591 data_size = priv->size; /* configuration */
2592 data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
2593 (out->args.vc.data - data_size),
2595 if ((uint8_t *)action + sizeof(*action) > data)
2597 *action = (struct rte_flow_action){
2599 .conf = data_size ? data : NULL,
2601 ++out->args.vc.actions_n;
2602 ctx->object = action;
2603 ctx->objmask = NULL;
2605 memset(data, 0, data_size);
2606 out->args.vc.data = data;
2607 ctx->objdata = data_size;
2611 /** Parse pattern item parameter type. */
2613 parse_vc_spec(struct context *ctx, const struct token *token,
2614 const char *str, unsigned int len,
2615 void *buf, unsigned int size)
2617 struct buffer *out = buf;
2618 struct rte_flow_item *item;
2624 /* Token name must match. */
2625 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
2627 /* Parse parameter types. */
2628 switch (ctx->curr) {
2629 static const enum index prefix[] = NEXT_ENTRY(PREFIX);
2635 case ITEM_PARAM_SPEC:
2638 case ITEM_PARAM_LAST:
2641 case ITEM_PARAM_PREFIX:
2642 /* Modify next token to expect a prefix. */
2643 if (ctx->next_num < 2)
2645 ctx->next[ctx->next_num - 2] = prefix;
2647 case ITEM_PARAM_MASK:
2653 /* Nothing else to do if there is no buffer. */
2656 if (!out->args.vc.pattern_n)
2658 item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
2659 data_size = ctx->objdata / 3; /* spec, last, mask */
2660 /* Point to selected object. */
2661 ctx->object = out->args.vc.data + (data_size * index);
2663 ctx->objmask = out->args.vc.data + (data_size * 2); /* mask */
2664 item->mask = ctx->objmask;
2666 ctx->objmask = NULL;
2667 /* Update relevant item pointer. */
2668 *((const void **[]){ &item->spec, &item->last, &item->mask })[index] =
2673 /** Parse action configuration field. */
2675 parse_vc_conf(struct context *ctx, const struct token *token,
2676 const char *str, unsigned int len,
2677 void *buf, unsigned int size)
2679 struct buffer *out = buf;
2682 /* Token name must match. */
2683 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
2685 /* Nothing else to do if there is no buffer. */
2688 /* Point to selected object. */
2689 ctx->object = out->args.vc.data;
2690 ctx->objmask = NULL;
2694 /** Parse RSS action. */
2696 parse_vc_action_rss(struct context *ctx, const struct token *token,
2697 const char *str, unsigned int len,
2698 void *buf, unsigned int size)
2700 struct buffer *out = buf;
2701 struct rte_flow_action *action;
2702 struct action_rss_data *action_rss_data;
2706 ret = parse_vc(ctx, token, str, len, buf, size);
2709 /* Nothing else to do if there is no buffer. */
2712 if (!out->args.vc.actions_n)
2714 action = &out->args.vc.actions[out->args.vc.actions_n - 1];
2715 /* Point to selected object. */
2716 ctx->object = out->args.vc.data;
2717 ctx->objmask = NULL;
2718 /* Set up default configuration. */
2719 action_rss_data = ctx->object;
2720 *action_rss_data = (struct action_rss_data){
2721 .conf = (struct rte_flow_action_rss){
2722 .func = RTE_ETH_HASH_FUNCTION_DEFAULT,
2725 .key_len = sizeof(action_rss_data->key),
2726 .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM),
2727 .key = action_rss_data->key,
2728 .queue = action_rss_data->queue,
2730 .key = "testpmd's default RSS hash key",
2733 for (i = 0; i < action_rss_data->conf.queue_num; ++i)
2734 action_rss_data->queue[i] = i;
2735 if (!port_id_is_invalid(ctx->port, DISABLED_WARN) &&
2736 ctx->port != (portid_t)RTE_PORT_ALL) {
2737 struct rte_eth_dev_info info;
2739 rte_eth_dev_info_get(ctx->port, &info);
2740 action_rss_data->conf.key_len =
2741 RTE_MIN(sizeof(action_rss_data->key),
2742 info.hash_key_size);
2744 action->conf = &action_rss_data->conf;
2749 * Parse func field for RSS action.
2751 * The RTE_ETH_HASH_FUNCTION_* value to assign is derived from the
2752 * ACTION_RSS_FUNC_* index that called this function.
2755 parse_vc_action_rss_func(struct context *ctx, const struct token *token,
2756 const char *str, unsigned int len,
2757 void *buf, unsigned int size)
2759 struct action_rss_data *action_rss_data;
2760 enum rte_eth_hash_function func;
2764 /* Token name must match. */
2765 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
2767 switch (ctx->curr) {
2768 case ACTION_RSS_FUNC_DEFAULT:
2769 func = RTE_ETH_HASH_FUNCTION_DEFAULT;
2771 case ACTION_RSS_FUNC_TOEPLITZ:
2772 func = RTE_ETH_HASH_FUNCTION_TOEPLITZ;
2774 case ACTION_RSS_FUNC_SIMPLE_XOR:
2775 func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
2782 action_rss_data = ctx->object;
2783 action_rss_data->conf.func = func;
2788 * Parse type field for RSS action.
2790 * Valid tokens are type field names and the "end" token.
2793 parse_vc_action_rss_type(struct context *ctx, const struct token *token,
2794 const char *str, unsigned int len,
2795 void *buf, unsigned int size)
2797 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE);
2798 struct action_rss_data *action_rss_data;
2804 if (ctx->curr != ACTION_RSS_TYPE)
2806 if (!(ctx->objdata >> 16) && ctx->object) {
2807 action_rss_data = ctx->object;
2808 action_rss_data->conf.types = 0;
2810 if (!strcmp_partial("end", str, len)) {
2811 ctx->objdata &= 0xffff;
2814 for (i = 0; rss_type_table[i].str; ++i)
2815 if (!strcmp_partial(rss_type_table[i].str, str, len))
2817 if (!rss_type_table[i].str)
2819 ctx->objdata = 1 << 16 | (ctx->objdata & 0xffff);
2821 if (ctx->next_num == RTE_DIM(ctx->next))
2823 ctx->next[ctx->next_num++] = next;
2826 action_rss_data = ctx->object;
2827 action_rss_data->conf.types |= rss_type_table[i].rss_type;
2832 * Parse queue field for RSS action.
2834 * Valid tokens are queue indices and the "end" token.
2837 parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
2838 const char *str, unsigned int len,
2839 void *buf, unsigned int size)
2841 static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE);
2842 struct action_rss_data *action_rss_data;
2849 if (ctx->curr != ACTION_RSS_QUEUE)
2851 i = ctx->objdata >> 16;
2852 if (!strcmp_partial("end", str, len)) {
2853 ctx->objdata &= 0xffff;
2856 if (i >= ACTION_RSS_QUEUE_NUM)
2859 ARGS_ENTRY_ARB(offsetof(struct action_rss_data, queue) +
2860 i * sizeof(action_rss_data->queue[i]),
2861 sizeof(action_rss_data->queue[i]))))
2863 ret = parse_int(ctx, token, str, len, NULL, 0);
2869 ctx->objdata = i << 16 | (ctx->objdata & 0xffff);
2871 if (ctx->next_num == RTE_DIM(ctx->next))
2873 ctx->next[ctx->next_num++] = next;
2876 action_rss_data = ctx->object;
2877 action_rss_data->conf.queue_num = i;
2878 action_rss_data->conf.queue = i ? action_rss_data->queue : NULL;
2882 /** Parse tokens for destroy command. */
2884 parse_destroy(struct context *ctx, const struct token *token,
2885 const char *str, unsigned int len,
2886 void *buf, unsigned int size)
2888 struct buffer *out = buf;
2890 /* Token name must match. */
2891 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
2893 /* Nothing else to do if there is no buffer. */
2896 if (!out->command) {
2897 if (ctx->curr != DESTROY)
2899 if (sizeof(*out) > size)
2901 out->command = ctx->curr;
2904 ctx->objmask = NULL;
2905 out->args.destroy.rule =
2906 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
2910 if (((uint8_t *)(out->args.destroy.rule + out->args.destroy.rule_n) +
2911 sizeof(*out->args.destroy.rule)) > (uint8_t *)out + size)
2914 ctx->object = out->args.destroy.rule + out->args.destroy.rule_n++;
2915 ctx->objmask = NULL;
2919 /** Parse tokens for flush command. */
2921 parse_flush(struct context *ctx, const struct token *token,
2922 const char *str, unsigned int len,
2923 void *buf, unsigned int size)
2925 struct buffer *out = buf;
2927 /* Token name must match. */
2928 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
2930 /* Nothing else to do if there is no buffer. */
2933 if (!out->command) {
2934 if (ctx->curr != FLUSH)
2936 if (sizeof(*out) > size)
2938 out->command = ctx->curr;
2941 ctx->objmask = NULL;
2946 /** Parse tokens for query command. */
2948 parse_query(struct context *ctx, const struct token *token,
2949 const char *str, unsigned int len,
2950 void *buf, unsigned int size)
2952 struct buffer *out = buf;
2954 /* Token name must match. */
2955 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
2957 /* Nothing else to do if there is no buffer. */
2960 if (!out->command) {
2961 if (ctx->curr != QUERY)
2963 if (sizeof(*out) > size)
2965 out->command = ctx->curr;
2968 ctx->objmask = NULL;
2973 /** Parse action names. */
2975 parse_action(struct context *ctx, const struct token *token,
2976 const char *str, unsigned int len,
2977 void *buf, unsigned int size)
2979 struct buffer *out = buf;
2980 const struct arg *arg = pop_args(ctx);
2984 /* Argument is expected. */
2987 /* Parse action name. */
2988 for (i = 0; next_action[i]; ++i) {
2989 const struct parse_action_priv *priv;
2991 token = &token_list[next_action[i]];
2992 if (strcmp_partial(token->name, str, len))
2998 memcpy((uint8_t *)ctx->object + arg->offset,
3004 push_args(ctx, arg);
3008 /** Parse tokens for list command. */
3010 parse_list(struct context *ctx, const struct token *token,
3011 const char *str, unsigned int len,
3012 void *buf, unsigned int size)
3014 struct buffer *out = buf;
3016 /* Token name must match. */
3017 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
3019 /* Nothing else to do if there is no buffer. */
3022 if (!out->command) {
3023 if (ctx->curr != LIST)
3025 if (sizeof(*out) > size)
3027 out->command = ctx->curr;
3030 ctx->objmask = NULL;
3031 out->args.list.group =
3032 (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
3036 if (((uint8_t *)(out->args.list.group + out->args.list.group_n) +
3037 sizeof(*out->args.list.group)) > (uint8_t *)out + size)
3040 ctx->object = out->args.list.group + out->args.list.group_n++;
3041 ctx->objmask = NULL;
3045 /** Parse tokens for isolate command. */
3047 parse_isolate(struct context *ctx, const struct token *token,
3048 const char *str, unsigned int len,
3049 void *buf, unsigned int size)
3051 struct buffer *out = buf;
3053 /* Token name must match. */
3054 if (parse_default(ctx, token, str, len, NULL, 0) < 0)
3056 /* Nothing else to do if there is no buffer. */
3059 if (!out->command) {
3060 if (ctx->curr != ISOLATE)
3062 if (sizeof(*out) > size)
3064 out->command = ctx->curr;
3067 ctx->objmask = NULL;
3073 * Parse signed/unsigned integers 8 to 64-bit long.
3075 * Last argument (ctx->args) is retrieved to determine integer type and
3079 parse_int(struct context *ctx, const struct token *token,
3080 const char *str, unsigned int len,
3081 void *buf, unsigned int size)
3083 const struct arg *arg = pop_args(ctx);
3088 /* Argument is expected. */
3093 (uintmax_t)strtoimax(str, &end, 0) :
3094 strtoumax(str, &end, 0);
3095 if (errno || (size_t)(end - str) != len)
3098 ((arg->sign && ((intmax_t)u < (intmax_t)arg->min ||
3099 (intmax_t)u > (intmax_t)arg->max)) ||
3100 (!arg->sign && (u < arg->min || u > arg->max))))
3105 if (!arg_entry_bf_fill(ctx->object, u, arg) ||
3106 !arg_entry_bf_fill(ctx->objmask, -1, arg))
3110 buf = (uint8_t *)ctx->object + arg->offset;
3114 case sizeof(uint8_t):
3115 *(uint8_t *)buf = u;
3117 case sizeof(uint16_t):
3118 *(uint16_t *)buf = arg->hton ? rte_cpu_to_be_16(u) : u;
3120 case sizeof(uint8_t [3]):
3121 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
3123 ((uint8_t *)buf)[0] = u;
3124 ((uint8_t *)buf)[1] = u >> 8;
3125 ((uint8_t *)buf)[2] = u >> 16;
3129 ((uint8_t *)buf)[0] = u >> 16;
3130 ((uint8_t *)buf)[1] = u >> 8;
3131 ((uint8_t *)buf)[2] = u;
3133 case sizeof(uint32_t):
3134 *(uint32_t *)buf = arg->hton ? rte_cpu_to_be_32(u) : u;
3136 case sizeof(uint64_t):
3137 *(uint64_t *)buf = arg->hton ? rte_cpu_to_be_64(u) : u;
3142 if (ctx->objmask && buf != (uint8_t *)ctx->objmask + arg->offset) {
3144 buf = (uint8_t *)ctx->objmask + arg->offset;
3149 push_args(ctx, arg);
3156 * Three arguments (ctx->args) are retrieved from the stack to store data,
3157 * its actual length and address (in that order).
3160 parse_string(struct context *ctx, const struct token *token,
3161 const char *str, unsigned int len,
3162 void *buf, unsigned int size)
3164 const struct arg *arg_data = pop_args(ctx);
3165 const struct arg *arg_len = pop_args(ctx);
3166 const struct arg *arg_addr = pop_args(ctx);
3167 char tmp[16]; /* Ought to be enough. */
3170 /* Arguments are expected. */
3174 push_args(ctx, arg_data);
3178 push_args(ctx, arg_len);
3179 push_args(ctx, arg_data);
3182 size = arg_data->size;
3183 /* Bit-mask fill is not supported. */
3184 if (arg_data->mask || size < len)
3188 /* Let parse_int() fill length information first. */
3189 ret = snprintf(tmp, sizeof(tmp), "%u", len);
3192 push_args(ctx, arg_len);
3193 ret = parse_int(ctx, token, tmp, ret, NULL, 0);
3198 buf = (uint8_t *)ctx->object + arg_data->offset;
3199 /* Output buffer is not necessarily NUL-terminated. */
3200 memcpy(buf, str, len);
3201 memset((uint8_t *)buf + len, 0x00, size - len);
3203 memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
3204 /* Save address if requested. */
3205 if (arg_addr->size) {
3206 memcpy((uint8_t *)ctx->object + arg_addr->offset,
3208 (uint8_t *)ctx->object + arg_data->offset
3212 memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
3214 (uint8_t *)ctx->objmask + arg_data->offset
3220 push_args(ctx, arg_addr);
3221 push_args(ctx, arg_len);
3222 push_args(ctx, arg_data);
3227 * Parse a MAC address.
3229 * Last argument (ctx->args) is retrieved to determine storage size and
3233 parse_mac_addr(struct context *ctx, const struct token *token,
3234 const char *str, unsigned int len,
3235 void *buf, unsigned int size)
3237 const struct arg *arg = pop_args(ctx);
3238 struct ether_addr tmp;
3242 /* Argument is expected. */
3246 /* Bit-mask fill is not supported. */
3247 if (arg->mask || size != sizeof(tmp))
3249 /* Only network endian is supported. */
3252 ret = cmdline_parse_etheraddr(NULL, str, &tmp, size);
3253 if (ret < 0 || (unsigned int)ret != len)
3257 buf = (uint8_t *)ctx->object + arg->offset;
3258 memcpy(buf, &tmp, size);
3260 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
3263 push_args(ctx, arg);
3268 * Parse an IPv4 address.
3270 * Last argument (ctx->args) is retrieved to determine storage size and
3274 parse_ipv4_addr(struct context *ctx, const struct token *token,
3275 const char *str, unsigned int len,
3276 void *buf, unsigned int size)
3278 const struct arg *arg = pop_args(ctx);
3283 /* Argument is expected. */
3287 /* Bit-mask fill is not supported. */
3288 if (arg->mask || size != sizeof(tmp))
3290 /* Only network endian is supported. */
3293 memcpy(str2, str, len);
3295 ret = inet_pton(AF_INET, str2, &tmp);
3297 /* Attempt integer parsing. */
3298 push_args(ctx, arg);
3299 return parse_int(ctx, token, str, len, buf, size);
3303 buf = (uint8_t *)ctx->object + arg->offset;
3304 memcpy(buf, &tmp, size);
3306 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
3309 push_args(ctx, arg);
3314 * Parse an IPv6 address.
3316 * Last argument (ctx->args) is retrieved to determine storage size and
3320 parse_ipv6_addr(struct context *ctx, const struct token *token,
3321 const char *str, unsigned int len,
3322 void *buf, unsigned int size)
3324 const struct arg *arg = pop_args(ctx);
3326 struct in6_addr tmp;
3330 /* Argument is expected. */
3334 /* Bit-mask fill is not supported. */
3335 if (arg->mask || size != sizeof(tmp))
3337 /* Only network endian is supported. */
3340 memcpy(str2, str, len);
3342 ret = inet_pton(AF_INET6, str2, &tmp);
3347 buf = (uint8_t *)ctx->object + arg->offset;
3348 memcpy(buf, &tmp, size);
3350 memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
3353 push_args(ctx, arg);
3357 /** Boolean values (even indices stand for false). */
3358 static const char *const boolean_name[] = {
3368 * Parse a boolean value.
3370 * Last argument (ctx->args) is retrieved to determine storage size and
3374 parse_boolean(struct context *ctx, const struct token *token,
3375 const char *str, unsigned int len,
3376 void *buf, unsigned int size)
3378 const struct arg *arg = pop_args(ctx);
3382 /* Argument is expected. */
3385 for (i = 0; boolean_name[i]; ++i)
3386 if (!strcmp_partial(boolean_name[i], str, len))
3388 /* Process token as integer. */
3389 if (boolean_name[i])
3390 str = i & 1 ? "1" : "0";
3391 push_args(ctx, arg);
3392 ret = parse_int(ctx, token, str, strlen(str), buf, size);
3393 return ret > 0 ? (int)len : ret;
3396 /** Parse port and update context. */
3398 parse_port(struct context *ctx, const struct token *token,
3399 const char *str, unsigned int len,
3400 void *buf, unsigned int size)
3402 struct buffer *out = &(struct buffer){ .port = 0 };
3410 ctx->objmask = NULL;
3411 size = sizeof(*out);
3413 ret = parse_int(ctx, token, str, len, out, size);
3415 ctx->port = out->port;
3421 /** No completion. */
3423 comp_none(struct context *ctx, const struct token *token,
3424 unsigned int ent, char *buf, unsigned int size)
3434 /** Complete boolean values. */
3436 comp_boolean(struct context *ctx, const struct token *token,
3437 unsigned int ent, char *buf, unsigned int size)
3443 for (i = 0; boolean_name[i]; ++i)
3444 if (buf && i == ent)
3445 return snprintf(buf, size, "%s", boolean_name[i]);
3451 /** Complete action names. */
3453 comp_action(struct context *ctx, const struct token *token,
3454 unsigned int ent, char *buf, unsigned int size)
3460 for (i = 0; next_action[i]; ++i)
3461 if (buf && i == ent)
3462 return snprintf(buf, size, "%s",
3463 token_list[next_action[i]].name);
3469 /** Complete available ports. */
3471 comp_port(struct context *ctx, const struct token *token,
3472 unsigned int ent, char *buf, unsigned int size)
3479 RTE_ETH_FOREACH_DEV(p) {
3480 if (buf && i == ent)
3481 return snprintf(buf, size, "%u", p);
3489 /** Complete available rule IDs. */
3491 comp_rule_id(struct context *ctx, const struct token *token,
3492 unsigned int ent, char *buf, unsigned int size)
3495 struct rte_port *port;
3496 struct port_flow *pf;
3499 if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
3500 ctx->port == (portid_t)RTE_PORT_ALL)
3502 port = &ports[ctx->port];
3503 for (pf = port->flow_list; pf != NULL; pf = pf->next) {
3504 if (buf && i == ent)
3505 return snprintf(buf, size, "%u", pf->id);
3513 /** Complete type field for RSS action. */
3515 comp_vc_action_rss_type(struct context *ctx, const struct token *token,
3516 unsigned int ent, char *buf, unsigned int size)
3522 for (i = 0; rss_type_table[i].str; ++i)
3527 return snprintf(buf, size, "%s", rss_type_table[ent].str);
3529 return snprintf(buf, size, "end");
3533 /** Complete queue field for RSS action. */
3535 comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
3536 unsigned int ent, char *buf, unsigned int size)
3543 return snprintf(buf, size, "%u", ent);
3545 return snprintf(buf, size, "end");
3549 /** Internal context. */
3550 static struct context cmd_flow_context;
3552 /** Global parser instance (cmdline API). */
3553 cmdline_parse_inst_t cmd_flow;
3555 /** Initialize context. */
3557 cmd_flow_context_init(struct context *ctx)
3559 /* A full memset() is not necessary. */
3569 ctx->objmask = NULL;
3572 /** Parse a token (cmdline API). */
3574 cmd_flow_parse(cmdline_parse_token_hdr_t *hdr, const char *src, void *result,
3577 struct context *ctx = &cmd_flow_context;
3578 const struct token *token;
3579 const enum index *list;
3584 token = &token_list[ctx->curr];
3585 /* Check argument length. */
3588 for (len = 0; src[len]; ++len)
3589 if (src[len] == '#' || isspace(src[len]))
3593 /* Last argument and EOL detection. */
3594 for (i = len; src[i]; ++i)
3595 if (src[i] == '#' || src[i] == '\r' || src[i] == '\n')
3597 else if (!isspace(src[i])) {
3602 if (src[i] == '\r' || src[i] == '\n') {
3606 /* Initialize context if necessary. */
3607 if (!ctx->next_num) {
3610 ctx->next[ctx->next_num++] = token->next[0];
3612 /* Process argument through candidates. */
3613 ctx->prev = ctx->curr;
3614 list = ctx->next[ctx->next_num - 1];
3615 for (i = 0; list[i]; ++i) {
3616 const struct token *next = &token_list[list[i]];
3619 ctx->curr = list[i];
3621 tmp = next->call(ctx, next, src, len, result, size);
3623 tmp = parse_default(ctx, next, src, len, result, size);
3624 if (tmp == -1 || tmp != len)
3632 /* Push subsequent tokens if any. */
3634 for (i = 0; token->next[i]; ++i) {
3635 if (ctx->next_num == RTE_DIM(ctx->next))
3637 ctx->next[ctx->next_num++] = token->next[i];
3639 /* Push arguments if any. */
3641 for (i = 0; token->args[i]; ++i) {
3642 if (ctx->args_num == RTE_DIM(ctx->args))
3644 ctx->args[ctx->args_num++] = token->args[i];
3649 /** Return number of completion entries (cmdline API). */
3651 cmd_flow_complete_get_nb(cmdline_parse_token_hdr_t *hdr)
3653 struct context *ctx = &cmd_flow_context;
3654 const struct token *token = &token_list[ctx->curr];
3655 const enum index *list;
3659 /* Count number of tokens in current list. */
3661 list = ctx->next[ctx->next_num - 1];
3663 list = token->next[0];
3664 for (i = 0; list[i]; ++i)
3669 * If there is a single token, use its completion callback, otherwise
3670 * return the number of entries.
3672 token = &token_list[list[0]];
3673 if (i == 1 && token->comp) {
3674 /* Save index for cmd_flow_get_help(). */
3675 ctx->prev = list[0];
3676 return token->comp(ctx, token, 0, NULL, 0);
3681 /** Return a completion entry (cmdline API). */
3683 cmd_flow_complete_get_elt(cmdline_parse_token_hdr_t *hdr, int index,
3684 char *dst, unsigned int size)
3686 struct context *ctx = &cmd_flow_context;
3687 const struct token *token = &token_list[ctx->curr];
3688 const enum index *list;
3692 /* Count number of tokens in current list. */
3694 list = ctx->next[ctx->next_num - 1];
3696 list = token->next[0];
3697 for (i = 0; list[i]; ++i)
3701 /* If there is a single token, use its completion callback. */
3702 token = &token_list[list[0]];
3703 if (i == 1 && token->comp) {
3704 /* Save index for cmd_flow_get_help(). */
3705 ctx->prev = list[0];
3706 return token->comp(ctx, token, index, dst, size) < 0 ? -1 : 0;
3708 /* Otherwise make sure the index is valid and use defaults. */
3711 token = &token_list[list[index]];
3712 snprintf(dst, size, "%s", token->name);
3713 /* Save index for cmd_flow_get_help(). */
3714 ctx->prev = list[index];
3718 /** Populate help strings for current token (cmdline API). */
3720 cmd_flow_get_help(cmdline_parse_token_hdr_t *hdr, char *dst, unsigned int size)
3722 struct context *ctx = &cmd_flow_context;
3723 const struct token *token = &token_list[ctx->prev];
3728 /* Set token type and update global help with details. */
3729 snprintf(dst, size, "%s", (token->type ? token->type : "TOKEN"));
3731 cmd_flow.help_str = token->help;
3733 cmd_flow.help_str = token->name;
3737 /** Token definition template (cmdline API). */
3738 static struct cmdline_token_hdr cmd_flow_token_hdr = {
3739 .ops = &(struct cmdline_token_ops){
3740 .parse = cmd_flow_parse,
3741 .complete_get_nb = cmd_flow_complete_get_nb,
3742 .complete_get_elt = cmd_flow_complete_get_elt,
3743 .get_help = cmd_flow_get_help,
3748 /** Populate the next dynamic token. */
3750 cmd_flow_tok(cmdline_parse_token_hdr_t **hdr,
3751 cmdline_parse_token_hdr_t **hdr_inst)
3753 struct context *ctx = &cmd_flow_context;
3755 /* Always reinitialize context before requesting the first token. */
3756 if (!(hdr_inst - cmd_flow.tokens))
3757 cmd_flow_context_init(ctx);
3758 /* Return NULL when no more tokens are expected. */
3759 if (!ctx->next_num && ctx->curr) {
3763 /* Determine if command should end here. */
3764 if (ctx->eol && ctx->last && ctx->next_num) {
3765 const enum index *list = ctx->next[ctx->next_num - 1];
3768 for (i = 0; list[i]; ++i) {
3775 *hdr = &cmd_flow_token_hdr;
3778 /** Dispatch parsed buffer to function calls. */
3780 cmd_flow_parsed(const struct buffer *in)
3782 switch (in->command) {
3784 port_flow_validate(in->port, &in->args.vc.attr,
3785 in->args.vc.pattern, in->args.vc.actions);
3788 port_flow_create(in->port, &in->args.vc.attr,
3789 in->args.vc.pattern, in->args.vc.actions);
3792 port_flow_destroy(in->port, in->args.destroy.rule_n,
3793 in->args.destroy.rule);
3796 port_flow_flush(in->port);
3799 port_flow_query(in->port, in->args.query.rule,
3800 in->args.query.action);
3803 port_flow_list(in->port, in->args.list.group_n,
3804 in->args.list.group);
3807 port_flow_isolate(in->port, in->args.isolate.set);
3814 /** Token generator and output processing callback (cmdline API). */
3816 cmd_flow_cb(void *arg0, struct cmdline *cl, void *arg2)
3819 cmd_flow_tok(arg0, arg2);
3821 cmd_flow_parsed(arg0);
3824 /** Global parser instance (cmdline API). */
3825 cmdline_parse_inst_t cmd_flow = {
3827 .data = NULL, /**< Unused. */
3828 .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
3831 }, /**< Tokens are returned by cmd_flow_tok(). */