Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright 2016 6WIND S.A.
3 : : * Copyright 2016 Mellanox Technologies, Ltd
4 : : */
5 : :
6 : : #include <stddef.h>
7 : : #include <stdint.h>
8 : : #include <stdio.h>
9 : : #include <stdlib.h>
10 : : #include <inttypes.h>
11 : : #include <errno.h>
12 : : #include <ctype.h>
13 : : #include <string.h>
14 : :
15 : : #include <rte_string_fns.h>
16 : : #include <rte_common.h>
17 : : #include <rte_ethdev.h>
18 : : #include <rte_byteorder.h>
19 : : #include <cmdline_parse.h>
20 : : #include <cmdline_parse_etheraddr.h>
21 : : #include <cmdline_parse_string.h>
22 : : #include <cmdline_parse_num.h>
23 : : #include <rte_flow.h>
24 : : #include <rte_hexdump.h>
25 : : #include <rte_vxlan.h>
26 : : #include <rte_gre.h>
27 : : #include <rte_mpls.h>
28 : : #include <rte_gtp.h>
29 : : #include <rte_geneve.h>
30 : :
31 : : #include "testpmd.h"
32 : :
33 : : /** Parser token indices. */
34 : : enum index {
35 : : /* Special tokens. */
36 : : ZERO = 0,
37 : : END,
38 : : START_SET,
39 : : END_SET,
40 : :
41 : : /* Common tokens. */
42 : : COMMON_INTEGER,
43 : : COMMON_UNSIGNED,
44 : : COMMON_PREFIX,
45 : : COMMON_BOOLEAN,
46 : : COMMON_STRING,
47 : : COMMON_HEX,
48 : : COMMON_FILE_PATH,
49 : : COMMON_MAC_ADDR,
50 : : COMMON_IPV4_ADDR,
51 : : COMMON_IPV6_ADDR,
52 : : COMMON_RULE_ID,
53 : : COMMON_PORT_ID,
54 : : COMMON_GROUP_ID,
55 : : COMMON_PRIORITY_LEVEL,
56 : : COMMON_INDIRECT_ACTION_ID,
57 : : COMMON_PROFILE_ID,
58 : : COMMON_POLICY_ID,
59 : : COMMON_FLEX_HANDLE,
60 : : COMMON_FLEX_TOKEN,
61 : : COMMON_PATTERN_TEMPLATE_ID,
62 : : COMMON_ACTIONS_TEMPLATE_ID,
63 : : COMMON_TABLE_ID,
64 : : COMMON_QUEUE_ID,
65 : : COMMON_METER_COLOR_NAME,
66 : :
67 : : /* TOP-level command. */
68 : : ADD,
69 : :
70 : : /* Top-level command. */
71 : : SET,
72 : : /* Sub-leve commands. */
73 : : SET_RAW_ENCAP,
74 : : SET_RAW_DECAP,
75 : : SET_RAW_INDEX,
76 : : SET_SAMPLE_ACTIONS,
77 : : SET_SAMPLE_INDEX,
78 : : SET_IPV6_EXT_REMOVE,
79 : : SET_IPV6_EXT_PUSH,
80 : : SET_IPV6_EXT_INDEX,
81 : :
82 : : /* Top-level command. */
83 : : FLOW,
84 : : /* Sub-level commands. */
85 : : INFO,
86 : : CONFIGURE,
87 : : PATTERN_TEMPLATE,
88 : : ACTIONS_TEMPLATE,
89 : : TABLE,
90 : : FLOW_GROUP,
91 : : INDIRECT_ACTION,
92 : : VALIDATE,
93 : : CREATE,
94 : : DESTROY,
95 : : UPDATE,
96 : : FLUSH,
97 : : DUMP,
98 : : QUERY,
99 : : LIST,
100 : : AGED,
101 : : ISOLATE,
102 : : TUNNEL,
103 : : FLEX,
104 : : QUEUE,
105 : : PUSH,
106 : : PULL,
107 : : HASH,
108 : :
109 : : /* Flex arguments */
110 : : FLEX_ITEM_CREATE,
111 : : FLEX_ITEM_DESTROY,
112 : :
113 : : /* Pattern template arguments. */
114 : : PATTERN_TEMPLATE_CREATE,
115 : : PATTERN_TEMPLATE_DESTROY,
116 : : PATTERN_TEMPLATE_CREATE_ID,
117 : : PATTERN_TEMPLATE_DESTROY_ID,
118 : : PATTERN_TEMPLATE_RELAXED_MATCHING,
119 : : PATTERN_TEMPLATE_INGRESS,
120 : : PATTERN_TEMPLATE_EGRESS,
121 : : PATTERN_TEMPLATE_TRANSFER,
122 : : PATTERN_TEMPLATE_SPEC,
123 : :
124 : : /* Actions template arguments. */
125 : : ACTIONS_TEMPLATE_CREATE,
126 : : ACTIONS_TEMPLATE_DESTROY,
127 : : ACTIONS_TEMPLATE_CREATE_ID,
128 : : ACTIONS_TEMPLATE_DESTROY_ID,
129 : : ACTIONS_TEMPLATE_INGRESS,
130 : : ACTIONS_TEMPLATE_EGRESS,
131 : : ACTIONS_TEMPLATE_TRANSFER,
132 : : ACTIONS_TEMPLATE_SPEC,
133 : : ACTIONS_TEMPLATE_MASK,
134 : :
135 : : /* Queue arguments. */
136 : : QUEUE_CREATE,
137 : : QUEUE_DESTROY,
138 : : QUEUE_FLOW_UPDATE_RESIZED,
139 : : QUEUE_UPDATE,
140 : : QUEUE_AGED,
141 : : QUEUE_INDIRECT_ACTION,
142 : :
143 : : /* Queue create arguments. */
144 : : QUEUE_CREATE_POSTPONE,
145 : : QUEUE_TEMPLATE_TABLE,
146 : : QUEUE_PATTERN_TEMPLATE,
147 : : QUEUE_ACTIONS_TEMPLATE,
148 : : QUEUE_RULE_ID,
149 : :
150 : : /* Queue destroy arguments. */
151 : : QUEUE_DESTROY_ID,
152 : : QUEUE_DESTROY_POSTPONE,
153 : :
154 : : /* Queue update arguments. */
155 : : QUEUE_UPDATE_ID,
156 : :
157 : : /* Queue indirect action arguments */
158 : : QUEUE_INDIRECT_ACTION_CREATE,
159 : : QUEUE_INDIRECT_ACTION_LIST_CREATE,
160 : : QUEUE_INDIRECT_ACTION_UPDATE,
161 : : QUEUE_INDIRECT_ACTION_DESTROY,
162 : : QUEUE_INDIRECT_ACTION_QUERY,
163 : : QUEUE_INDIRECT_ACTION_QUERY_UPDATE,
164 : :
165 : : /* Queue indirect action create arguments */
166 : : QUEUE_INDIRECT_ACTION_CREATE_ID,
167 : : QUEUE_INDIRECT_ACTION_INGRESS,
168 : : QUEUE_INDIRECT_ACTION_EGRESS,
169 : : QUEUE_INDIRECT_ACTION_TRANSFER,
170 : : QUEUE_INDIRECT_ACTION_CREATE_POSTPONE,
171 : : QUEUE_INDIRECT_ACTION_SPEC,
172 : : QUEUE_INDIRECT_ACTION_LIST,
173 : :
174 : : /* Queue indirect action update arguments */
175 : : QUEUE_INDIRECT_ACTION_UPDATE_POSTPONE,
176 : :
177 : : /* Queue indirect action destroy arguments */
178 : : QUEUE_INDIRECT_ACTION_DESTROY_ID,
179 : : QUEUE_INDIRECT_ACTION_DESTROY_POSTPONE,
180 : :
181 : : /* Queue indirect action query arguments */
182 : : QUEUE_INDIRECT_ACTION_QUERY_POSTPONE,
183 : :
184 : : /* Queue indirect action query_update arguments */
185 : : QUEUE_INDIRECT_ACTION_QU_MODE,
186 : :
187 : : /* Push arguments. */
188 : : PUSH_QUEUE,
189 : :
190 : : /* Pull arguments. */
191 : : PULL_QUEUE,
192 : :
193 : : /* Table arguments. */
194 : : TABLE_CREATE,
195 : : TABLE_DESTROY,
196 : : TABLE_RESIZE,
197 : : TABLE_RESIZE_COMPLETE,
198 : : TABLE_CREATE_ID,
199 : : TABLE_DESTROY_ID,
200 : : TABLE_RESIZE_ID,
201 : : TABLE_RESIZE_RULES_NUMBER,
202 : : TABLE_INSERTION_TYPE,
203 : : TABLE_INSERTION_TYPE_NAME,
204 : : TABLE_HASH_FUNC,
205 : : TABLE_HASH_FUNC_NAME,
206 : : TABLE_GROUP,
207 : : TABLE_PRIORITY,
208 : : TABLE_INGRESS,
209 : : TABLE_EGRESS,
210 : : TABLE_TRANSFER,
211 : : TABLE_TRANSFER_WIRE_ORIG,
212 : : TABLE_TRANSFER_VPORT_ORIG,
213 : : TABLE_RESIZABLE,
214 : : TABLE_RULES_NUMBER,
215 : : TABLE_PATTERN_TEMPLATE,
216 : : TABLE_ACTIONS_TEMPLATE,
217 : :
218 : : /* Group arguments */
219 : : GROUP_ID,
220 : : GROUP_INGRESS,
221 : : GROUP_EGRESS,
222 : : GROUP_TRANSFER,
223 : : GROUP_SET_MISS_ACTIONS,
224 : :
225 : : /* Hash calculation arguments. */
226 : : HASH_CALC_TABLE,
227 : : HASH_CALC_PATTERN_INDEX,
228 : : HASH_CALC_PATTERN,
229 : : HASH_CALC_ENCAP,
230 : : HASH_CALC_DEST,
231 : : ENCAP_HASH_FIELD_SRC_PORT,
232 : : ENCAP_HASH_FIELD_GRE_FLOW_ID,
233 : :
234 : : /* Tunnel arguments. */
235 : : TUNNEL_CREATE,
236 : : TUNNEL_CREATE_TYPE,
237 : : TUNNEL_LIST,
238 : : TUNNEL_DESTROY,
239 : : TUNNEL_DESTROY_ID,
240 : :
241 : : /* Destroy arguments. */
242 : : DESTROY_RULE,
243 : : DESTROY_IS_USER_ID,
244 : :
245 : : /* Query arguments. */
246 : : QUERY_ACTION,
247 : : QUERY_IS_USER_ID,
248 : :
249 : : /* List arguments. */
250 : : LIST_GROUP,
251 : :
252 : : /* Destroy aged flow arguments. */
253 : : AGED_DESTROY,
254 : :
255 : : /* Validate/create arguments. */
256 : : VC_GROUP,
257 : : VC_PRIORITY,
258 : : VC_INGRESS,
259 : : VC_EGRESS,
260 : : VC_TRANSFER,
261 : : VC_TUNNEL_SET,
262 : : VC_TUNNEL_MATCH,
263 : : VC_USER_ID,
264 : : VC_IS_USER_ID,
265 : :
266 : : /* Dump arguments */
267 : : DUMP_ALL,
268 : : DUMP_ONE,
269 : : DUMP_IS_USER_ID,
270 : :
271 : : /* Configure arguments */
272 : : CONFIG_QUEUES_NUMBER,
273 : : CONFIG_QUEUES_SIZE,
274 : : CONFIG_COUNTERS_NUMBER,
275 : : CONFIG_AGING_OBJECTS_NUMBER,
276 : : CONFIG_METERS_NUMBER,
277 : : CONFIG_CONN_TRACK_NUMBER,
278 : : CONFIG_QUOTAS_NUMBER,
279 : : CONFIG_FLAGS,
280 : : CONFIG_HOST_PORT,
281 : :
282 : : /* Indirect action arguments */
283 : : INDIRECT_ACTION_CREATE,
284 : : INDIRECT_ACTION_LIST_CREATE,
285 : : INDIRECT_ACTION_FLOW_CONF_CREATE,
286 : : INDIRECT_ACTION_UPDATE,
287 : : INDIRECT_ACTION_DESTROY,
288 : : INDIRECT_ACTION_QUERY,
289 : : INDIRECT_ACTION_QUERY_UPDATE,
290 : :
291 : : /* Indirect action create arguments */
292 : : INDIRECT_ACTION_CREATE_ID,
293 : : INDIRECT_ACTION_INGRESS,
294 : : INDIRECT_ACTION_EGRESS,
295 : : INDIRECT_ACTION_TRANSFER,
296 : : INDIRECT_ACTION_SPEC,
297 : : INDIRECT_ACTION_LIST,
298 : : INDIRECT_ACTION_FLOW_CONF,
299 : :
300 : : /* Indirect action destroy arguments */
301 : : INDIRECT_ACTION_DESTROY_ID,
302 : :
303 : : /* Indirect action query-and-update arguments */
304 : : INDIRECT_ACTION_QU_MODE,
305 : : INDIRECT_ACTION_QU_MODE_NAME,
306 : :
307 : : /* Validate/create pattern. */
308 : : ITEM_PATTERN,
309 : : ITEM_PARAM_IS,
310 : : ITEM_PARAM_SPEC,
311 : : ITEM_PARAM_LAST,
312 : : ITEM_PARAM_MASK,
313 : : ITEM_PARAM_PREFIX,
314 : : ITEM_NEXT,
315 : : ITEM_END,
316 : : ITEM_VOID,
317 : : ITEM_INVERT,
318 : : ITEM_ANY,
319 : : ITEM_ANY_NUM,
320 : : ITEM_PORT_ID,
321 : : ITEM_PORT_ID_ID,
322 : : ITEM_MARK,
323 : : ITEM_MARK_ID,
324 : : ITEM_RAW,
325 : : ITEM_RAW_RELATIVE,
326 : : ITEM_RAW_SEARCH,
327 : : ITEM_RAW_OFFSET,
328 : : ITEM_RAW_LIMIT,
329 : : ITEM_RAW_PATTERN,
330 : : ITEM_RAW_PATTERN_HEX,
331 : : ITEM_ETH,
332 : : ITEM_ETH_DST,
333 : : ITEM_ETH_SRC,
334 : : ITEM_ETH_TYPE,
335 : : ITEM_ETH_HAS_VLAN,
336 : : ITEM_VLAN,
337 : : ITEM_VLAN_TCI,
338 : : ITEM_VLAN_PCP,
339 : : ITEM_VLAN_DEI,
340 : : ITEM_VLAN_VID,
341 : : ITEM_VLAN_INNER_TYPE,
342 : : ITEM_VLAN_HAS_MORE_VLAN,
343 : : ITEM_IPV4,
344 : : ITEM_IPV4_VER_IHL,
345 : : ITEM_IPV4_TOS,
346 : : ITEM_IPV4_LENGTH,
347 : : ITEM_IPV4_ID,
348 : : ITEM_IPV4_FRAGMENT_OFFSET,
349 : : ITEM_IPV4_TTL,
350 : : ITEM_IPV4_PROTO,
351 : : ITEM_IPV4_SRC,
352 : : ITEM_IPV4_DST,
353 : : ITEM_IPV6,
354 : : ITEM_IPV6_TC,
355 : : ITEM_IPV6_FLOW,
356 : : ITEM_IPV6_LEN,
357 : : ITEM_IPV6_PROTO,
358 : : ITEM_IPV6_HOP,
359 : : ITEM_IPV6_SRC,
360 : : ITEM_IPV6_DST,
361 : : ITEM_IPV6_HAS_FRAG_EXT,
362 : : ITEM_IPV6_ROUTING_EXT,
363 : : ITEM_IPV6_ROUTING_EXT_TYPE,
364 : : ITEM_IPV6_ROUTING_EXT_NEXT_HDR,
365 : : ITEM_IPV6_ROUTING_EXT_SEG_LEFT,
366 : : ITEM_ICMP,
367 : : ITEM_ICMP_TYPE,
368 : : ITEM_ICMP_CODE,
369 : : ITEM_ICMP_IDENT,
370 : : ITEM_ICMP_SEQ,
371 : : ITEM_UDP,
372 : : ITEM_UDP_SRC,
373 : : ITEM_UDP_DST,
374 : : ITEM_TCP,
375 : : ITEM_TCP_SRC,
376 : : ITEM_TCP_DST,
377 : : ITEM_TCP_FLAGS,
378 : : ITEM_SCTP,
379 : : ITEM_SCTP_SRC,
380 : : ITEM_SCTP_DST,
381 : : ITEM_SCTP_TAG,
382 : : ITEM_SCTP_CKSUM,
383 : : ITEM_VXLAN,
384 : : ITEM_VXLAN_VNI,
385 : : ITEM_VXLAN_FLAG_G,
386 : : ITEM_VXLAN_FLAG_VER,
387 : : ITEM_VXLAN_FLAG_I,
388 : : ITEM_VXLAN_FLAG_P,
389 : : ITEM_VXLAN_FLAG_B,
390 : : ITEM_VXLAN_FLAG_O,
391 : : ITEM_VXLAN_FLAG_D,
392 : : ITEM_VXLAN_FLAG_A,
393 : : ITEM_VXLAN_GBP_ID,
394 : : /* Used for "struct rte_vxlan_hdr", GPE Next protocol */
395 : : ITEM_VXLAN_GPE_PROTO,
396 : : ITEM_VXLAN_FIRST_RSVD,
397 : : ITEM_VXLAN_SECND_RSVD,
398 : : ITEM_VXLAN_THIRD_RSVD,
399 : : ITEM_VXLAN_LAST_RSVD,
400 : : ITEM_E_TAG,
401 : : ITEM_E_TAG_GRP_ECID_B,
402 : : ITEM_NVGRE,
403 : : ITEM_NVGRE_TNI,
404 : : ITEM_MPLS,
405 : : ITEM_MPLS_LABEL,
406 : : ITEM_MPLS_TC,
407 : : ITEM_MPLS_S,
408 : : ITEM_MPLS_TTL,
409 : : ITEM_GRE,
410 : : ITEM_GRE_PROTO,
411 : : ITEM_GRE_C_RSVD0_VER,
412 : : ITEM_GRE_C_BIT,
413 : : ITEM_GRE_K_BIT,
414 : : ITEM_GRE_S_BIT,
415 : : ITEM_FUZZY,
416 : : ITEM_FUZZY_THRESH,
417 : : ITEM_GTP,
418 : : ITEM_GTP_FLAGS,
419 : : ITEM_GTP_MSG_TYPE,
420 : : ITEM_GTP_TEID,
421 : : ITEM_GTPC,
422 : : ITEM_GTPU,
423 : : ITEM_GENEVE,
424 : : ITEM_GENEVE_VNI,
425 : : ITEM_GENEVE_PROTO,
426 : : ITEM_GENEVE_OPTLEN,
427 : : ITEM_VXLAN_GPE,
428 : : ITEM_VXLAN_GPE_VNI,
429 : : /* Used for "struct rte_vxlan_gpe_hdr", deprecated, prefer ITEM_VXLAN_GPE_PROTO */
430 : : ITEM_VXLAN_GPE_PROTO_IN_DEPRECATED_VXLAN_GPE_HDR,
431 : : ITEM_VXLAN_GPE_FLAGS,
432 : : ITEM_VXLAN_GPE_RSVD0,
433 : : ITEM_VXLAN_GPE_RSVD1,
434 : : ITEM_ARP_ETH_IPV4,
435 : : ITEM_ARP_ETH_IPV4_SHA,
436 : : ITEM_ARP_ETH_IPV4_SPA,
437 : : ITEM_ARP_ETH_IPV4_THA,
438 : : ITEM_ARP_ETH_IPV4_TPA,
439 : : ITEM_IPV6_EXT,
440 : : ITEM_IPV6_EXT_NEXT_HDR,
441 : : ITEM_IPV6_FRAG_EXT,
442 : : ITEM_IPV6_FRAG_EXT_NEXT_HDR,
443 : : ITEM_IPV6_FRAG_EXT_FRAG_DATA,
444 : : ITEM_IPV6_FRAG_EXT_ID,
445 : : ITEM_ICMP6,
446 : : ITEM_ICMP6_TYPE,
447 : : ITEM_ICMP6_CODE,
448 : : ITEM_ICMP6_ECHO_REQUEST,
449 : : ITEM_ICMP6_ECHO_REQUEST_ID,
450 : : ITEM_ICMP6_ECHO_REQUEST_SEQ,
451 : : ITEM_ICMP6_ECHO_REPLY,
452 : : ITEM_ICMP6_ECHO_REPLY_ID,
453 : : ITEM_ICMP6_ECHO_REPLY_SEQ,
454 : : ITEM_ICMP6_ND_NS,
455 : : ITEM_ICMP6_ND_NS_TARGET_ADDR,
456 : : ITEM_ICMP6_ND_NA,
457 : : ITEM_ICMP6_ND_NA_TARGET_ADDR,
458 : : ITEM_ICMP6_ND_OPT,
459 : : ITEM_ICMP6_ND_OPT_TYPE,
460 : : ITEM_ICMP6_ND_OPT_SLA_ETH,
461 : : ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
462 : : ITEM_ICMP6_ND_OPT_TLA_ETH,
463 : : ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
464 : : ITEM_META,
465 : : ITEM_META_DATA,
466 : : ITEM_RANDOM,
467 : : ITEM_RANDOM_VALUE,
468 : : ITEM_GRE_KEY,
469 : : ITEM_GRE_KEY_VALUE,
470 : : ITEM_GRE_OPTION,
471 : : ITEM_GRE_OPTION_CHECKSUM,
472 : : ITEM_GRE_OPTION_KEY,
473 : : ITEM_GRE_OPTION_SEQUENCE,
474 : : ITEM_GTP_PSC,
475 : : ITEM_GTP_PSC_QFI,
476 : : ITEM_GTP_PSC_PDU_T,
477 : : ITEM_PPPOES,
478 : : ITEM_PPPOED,
479 : : ITEM_PPPOE_SEID,
480 : : ITEM_PPPOE_PROTO_ID,
481 : : ITEM_HIGIG2,
482 : : ITEM_HIGIG2_CLASSIFICATION,
483 : : ITEM_HIGIG2_VID,
484 : : ITEM_TAG,
485 : : ITEM_TAG_DATA,
486 : : ITEM_TAG_INDEX,
487 : : ITEM_L2TPV3OIP,
488 : : ITEM_L2TPV3OIP_SESSION_ID,
489 : : ITEM_ESP,
490 : : ITEM_ESP_SPI,
491 : : ITEM_AH,
492 : : ITEM_AH_SPI,
493 : : ITEM_PFCP,
494 : : ITEM_PFCP_S_FIELD,
495 : : ITEM_PFCP_SEID,
496 : : ITEM_ECPRI,
497 : : ITEM_ECPRI_COMMON,
498 : : ITEM_ECPRI_COMMON_TYPE,
499 : : ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
500 : : ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
501 : : ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
502 : : ITEM_ECPRI_MSG_IQ_DATA_PCID,
503 : : ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
504 : : ITEM_ECPRI_MSG_DLY_MSR_MSRID,
505 : : ITEM_GENEVE_OPT,
506 : : ITEM_GENEVE_OPT_CLASS,
507 : : ITEM_GENEVE_OPT_TYPE,
508 : : ITEM_GENEVE_OPT_LENGTH,
509 : : ITEM_GENEVE_OPT_DATA,
510 : : ITEM_INTEGRITY,
511 : : ITEM_INTEGRITY_LEVEL,
512 : : ITEM_INTEGRITY_VALUE,
513 : : ITEM_CONNTRACK,
514 : : ITEM_POL_PORT,
515 : : ITEM_POL_METER,
516 : : ITEM_POL_POLICY,
517 : : ITEM_PORT_REPRESENTOR,
518 : : ITEM_PORT_REPRESENTOR_PORT_ID,
519 : : ITEM_REPRESENTED_PORT,
520 : : ITEM_REPRESENTED_PORT_ETHDEV_PORT_ID,
521 : : ITEM_FLEX,
522 : : ITEM_FLEX_ITEM_HANDLE,
523 : : ITEM_FLEX_PATTERN_HANDLE,
524 : : ITEM_L2TPV2,
525 : : ITEM_L2TPV2_TYPE,
526 : : ITEM_L2TPV2_TYPE_DATA,
527 : : ITEM_L2TPV2_TYPE_DATA_L,
528 : : ITEM_L2TPV2_TYPE_DATA_S,
529 : : ITEM_L2TPV2_TYPE_DATA_O,
530 : : ITEM_L2TPV2_TYPE_DATA_L_S,
531 : : ITEM_L2TPV2_TYPE_CTRL,
532 : : ITEM_L2TPV2_MSG_DATA_TUNNEL_ID,
533 : : ITEM_L2TPV2_MSG_DATA_SESSION_ID,
534 : : ITEM_L2TPV2_MSG_DATA_L_LENGTH,
535 : : ITEM_L2TPV2_MSG_DATA_L_TUNNEL_ID,
536 : : ITEM_L2TPV2_MSG_DATA_L_SESSION_ID,
537 : : ITEM_L2TPV2_MSG_DATA_S_TUNNEL_ID,
538 : : ITEM_L2TPV2_MSG_DATA_S_SESSION_ID,
539 : : ITEM_L2TPV2_MSG_DATA_S_NS,
540 : : ITEM_L2TPV2_MSG_DATA_S_NR,
541 : : ITEM_L2TPV2_MSG_DATA_O_TUNNEL_ID,
542 : : ITEM_L2TPV2_MSG_DATA_O_SESSION_ID,
543 : : ITEM_L2TPV2_MSG_DATA_O_OFFSET,
544 : : ITEM_L2TPV2_MSG_DATA_L_S_LENGTH,
545 : : ITEM_L2TPV2_MSG_DATA_L_S_TUNNEL_ID,
546 : : ITEM_L2TPV2_MSG_DATA_L_S_SESSION_ID,
547 : : ITEM_L2TPV2_MSG_DATA_L_S_NS,
548 : : ITEM_L2TPV2_MSG_DATA_L_S_NR,
549 : : ITEM_L2TPV2_MSG_CTRL_LENGTH,
550 : : ITEM_L2TPV2_MSG_CTRL_TUNNEL_ID,
551 : : ITEM_L2TPV2_MSG_CTRL_SESSION_ID,
552 : : ITEM_L2TPV2_MSG_CTRL_NS,
553 : : ITEM_L2TPV2_MSG_CTRL_NR,
554 : : ITEM_PPP,
555 : : ITEM_PPP_ADDR,
556 : : ITEM_PPP_CTRL,
557 : : ITEM_PPP_PROTO_ID,
558 : : ITEM_METER,
559 : : ITEM_METER_COLOR,
560 : : ITEM_QUOTA,
561 : : ITEM_QUOTA_STATE,
562 : : ITEM_QUOTA_STATE_NAME,
563 : : ITEM_AGGR_AFFINITY,
564 : : ITEM_AGGR_AFFINITY_VALUE,
565 : : ITEM_TX_QUEUE,
566 : : ITEM_TX_QUEUE_VALUE,
567 : : ITEM_IB_BTH,
568 : : ITEM_IB_BTH_OPCODE,
569 : : ITEM_IB_BTH_PKEY,
570 : : ITEM_IB_BTH_DST_QPN,
571 : : ITEM_IB_BTH_PSN,
572 : : ITEM_IPV6_PUSH_REMOVE_EXT,
573 : : ITEM_IPV6_PUSH_REMOVE_EXT_TYPE,
574 : : ITEM_PTYPE,
575 : : ITEM_PTYPE_VALUE,
576 : : ITEM_NSH,
577 : : ITEM_COMPARE,
578 : : ITEM_COMPARE_OP,
579 : : ITEM_COMPARE_OP_VALUE,
580 : : ITEM_COMPARE_FIELD_A_TYPE,
581 : : ITEM_COMPARE_FIELD_A_TYPE_VALUE,
582 : : ITEM_COMPARE_FIELD_A_LEVEL,
583 : : ITEM_COMPARE_FIELD_A_LEVEL_VALUE,
584 : : ITEM_COMPARE_FIELD_A_TAG_INDEX,
585 : : ITEM_COMPARE_FIELD_A_TYPE_ID,
586 : : ITEM_COMPARE_FIELD_A_CLASS_ID,
587 : : ITEM_COMPARE_FIELD_A_OFFSET,
588 : : ITEM_COMPARE_FIELD_B_TYPE,
589 : : ITEM_COMPARE_FIELD_B_TYPE_VALUE,
590 : : ITEM_COMPARE_FIELD_B_LEVEL,
591 : : ITEM_COMPARE_FIELD_B_LEVEL_VALUE,
592 : : ITEM_COMPARE_FIELD_B_TAG_INDEX,
593 : : ITEM_COMPARE_FIELD_B_TYPE_ID,
594 : : ITEM_COMPARE_FIELD_B_CLASS_ID,
595 : : ITEM_COMPARE_FIELD_B_OFFSET,
596 : : ITEM_COMPARE_FIELD_B_VALUE,
597 : : ITEM_COMPARE_FIELD_B_POINTER,
598 : : ITEM_COMPARE_FIELD_WIDTH,
599 : :
600 : : /* Validate/create actions. */
601 : : ACTIONS,
602 : : ACTION_NEXT,
603 : : ACTION_END,
604 : : ACTION_VOID,
605 : : ACTION_PASSTHRU,
606 : : ACTION_SKIP_CMAN,
607 : : ACTION_JUMP,
608 : : ACTION_JUMP_GROUP,
609 : : ACTION_MARK,
610 : : ACTION_MARK_ID,
611 : : ACTION_FLAG,
612 : : ACTION_QUEUE,
613 : : ACTION_QUEUE_INDEX,
614 : : ACTION_DROP,
615 : : ACTION_COUNT,
616 : : ACTION_COUNT_ID,
617 : : ACTION_RSS,
618 : : ACTION_RSS_FUNC,
619 : : ACTION_RSS_LEVEL,
620 : : ACTION_RSS_FUNC_DEFAULT,
621 : : ACTION_RSS_FUNC_TOEPLITZ,
622 : : ACTION_RSS_FUNC_SIMPLE_XOR,
623 : : ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ,
624 : : ACTION_RSS_TYPES,
625 : : ACTION_RSS_TYPE,
626 : : ACTION_RSS_KEY,
627 : : ACTION_RSS_KEY_LEN,
628 : : ACTION_RSS_QUEUES,
629 : : ACTION_RSS_QUEUE,
630 : : ACTION_PF,
631 : : ACTION_VF,
632 : : ACTION_VF_ORIGINAL,
633 : : ACTION_VF_ID,
634 : : ACTION_PORT_ID,
635 : : ACTION_PORT_ID_ORIGINAL,
636 : : ACTION_PORT_ID_ID,
637 : : ACTION_METER,
638 : : ACTION_METER_COLOR,
639 : : ACTION_METER_COLOR_TYPE,
640 : : ACTION_METER_COLOR_GREEN,
641 : : ACTION_METER_COLOR_YELLOW,
642 : : ACTION_METER_COLOR_RED,
643 : : ACTION_METER_ID,
644 : : ACTION_METER_MARK,
645 : : ACTION_METER_MARK_CONF,
646 : : ACTION_METER_MARK_CONF_COLOR,
647 : : ACTION_METER_PROFILE,
648 : : ACTION_METER_PROFILE_ID2PTR,
649 : : ACTION_METER_POLICY,
650 : : ACTION_METER_POLICY_ID2PTR,
651 : : ACTION_METER_COLOR_MODE,
652 : : ACTION_METER_STATE,
653 : : ACTION_OF_DEC_NW_TTL,
654 : : ACTION_OF_POP_VLAN,
655 : : ACTION_OF_PUSH_VLAN,
656 : : ACTION_OF_PUSH_VLAN_ETHERTYPE,
657 : : ACTION_OF_SET_VLAN_VID,
658 : : ACTION_OF_SET_VLAN_VID_VLAN_VID,
659 : : ACTION_OF_SET_VLAN_PCP,
660 : : ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
661 : : ACTION_OF_POP_MPLS,
662 : : ACTION_OF_POP_MPLS_ETHERTYPE,
663 : : ACTION_OF_PUSH_MPLS,
664 : : ACTION_OF_PUSH_MPLS_ETHERTYPE,
665 : : ACTION_VXLAN_ENCAP,
666 : : ACTION_VXLAN_DECAP,
667 : : ACTION_NVGRE_ENCAP,
668 : : ACTION_NVGRE_DECAP,
669 : : ACTION_L2_ENCAP,
670 : : ACTION_L2_DECAP,
671 : : ACTION_MPLSOGRE_ENCAP,
672 : : ACTION_MPLSOGRE_DECAP,
673 : : ACTION_MPLSOUDP_ENCAP,
674 : : ACTION_MPLSOUDP_DECAP,
675 : : ACTION_SET_IPV4_SRC,
676 : : ACTION_SET_IPV4_SRC_IPV4_SRC,
677 : : ACTION_SET_IPV4_DST,
678 : : ACTION_SET_IPV4_DST_IPV4_DST,
679 : : ACTION_SET_IPV6_SRC,
680 : : ACTION_SET_IPV6_SRC_IPV6_SRC,
681 : : ACTION_SET_IPV6_DST,
682 : : ACTION_SET_IPV6_DST_IPV6_DST,
683 : : ACTION_SET_TP_SRC,
684 : : ACTION_SET_TP_SRC_TP_SRC,
685 : : ACTION_SET_TP_DST,
686 : : ACTION_SET_TP_DST_TP_DST,
687 : : ACTION_MAC_SWAP,
688 : : ACTION_DEC_TTL,
689 : : ACTION_SET_TTL,
690 : : ACTION_SET_TTL_TTL,
691 : : ACTION_SET_MAC_SRC,
692 : : ACTION_SET_MAC_SRC_MAC_SRC,
693 : : ACTION_SET_MAC_DST,
694 : : ACTION_SET_MAC_DST_MAC_DST,
695 : : ACTION_INC_TCP_SEQ,
696 : : ACTION_INC_TCP_SEQ_VALUE,
697 : : ACTION_DEC_TCP_SEQ,
698 : : ACTION_DEC_TCP_SEQ_VALUE,
699 : : ACTION_INC_TCP_ACK,
700 : : ACTION_INC_TCP_ACK_VALUE,
701 : : ACTION_DEC_TCP_ACK,
702 : : ACTION_DEC_TCP_ACK_VALUE,
703 : : ACTION_RAW_ENCAP,
704 : : ACTION_RAW_DECAP,
705 : : ACTION_RAW_ENCAP_SIZE,
706 : : ACTION_RAW_ENCAP_INDEX,
707 : : ACTION_RAW_ENCAP_INDEX_VALUE,
708 : : ACTION_RAW_DECAP_INDEX,
709 : : ACTION_RAW_DECAP_INDEX_VALUE,
710 : : ACTION_SET_TAG,
711 : : ACTION_SET_TAG_DATA,
712 : : ACTION_SET_TAG_INDEX,
713 : : ACTION_SET_TAG_MASK,
714 : : ACTION_SET_META,
715 : : ACTION_SET_META_DATA,
716 : : ACTION_SET_META_MASK,
717 : : ACTION_SET_IPV4_DSCP,
718 : : ACTION_SET_IPV4_DSCP_VALUE,
719 : : ACTION_SET_IPV6_DSCP,
720 : : ACTION_SET_IPV6_DSCP_VALUE,
721 : : ACTION_AGE,
722 : : ACTION_AGE_TIMEOUT,
723 : : ACTION_AGE_UPDATE,
724 : : ACTION_AGE_UPDATE_TIMEOUT,
725 : : ACTION_AGE_UPDATE_TOUCH,
726 : : ACTION_SAMPLE,
727 : : ACTION_SAMPLE_RATIO,
728 : : ACTION_SAMPLE_INDEX,
729 : : ACTION_SAMPLE_INDEX_VALUE,
730 : : ACTION_INDIRECT,
731 : : ACTION_INDIRECT_LIST,
732 : : ACTION_INDIRECT_LIST_HANDLE,
733 : : ACTION_INDIRECT_LIST_CONF,
734 : : INDIRECT_LIST_ACTION_ID2PTR_HANDLE,
735 : : INDIRECT_LIST_ACTION_ID2PTR_CONF,
736 : : ACTION_SHARED_INDIRECT,
737 : : INDIRECT_ACTION_PORT,
738 : : INDIRECT_ACTION_ID2PTR,
739 : : ACTION_MODIFY_FIELD,
740 : : ACTION_MODIFY_FIELD_OP,
741 : : ACTION_MODIFY_FIELD_OP_VALUE,
742 : : ACTION_MODIFY_FIELD_DST_TYPE,
743 : : ACTION_MODIFY_FIELD_DST_TYPE_VALUE,
744 : : ACTION_MODIFY_FIELD_DST_LEVEL,
745 : : ACTION_MODIFY_FIELD_DST_LEVEL_VALUE,
746 : : ACTION_MODIFY_FIELD_DST_TAG_INDEX,
747 : : ACTION_MODIFY_FIELD_DST_TYPE_ID,
748 : : ACTION_MODIFY_FIELD_DST_CLASS_ID,
749 : : ACTION_MODIFY_FIELD_DST_OFFSET,
750 : : ACTION_MODIFY_FIELD_SRC_TYPE,
751 : : ACTION_MODIFY_FIELD_SRC_TYPE_VALUE,
752 : : ACTION_MODIFY_FIELD_SRC_LEVEL,
753 : : ACTION_MODIFY_FIELD_SRC_LEVEL_VALUE,
754 : : ACTION_MODIFY_FIELD_SRC_TAG_INDEX,
755 : : ACTION_MODIFY_FIELD_SRC_TYPE_ID,
756 : : ACTION_MODIFY_FIELD_SRC_CLASS_ID,
757 : : ACTION_MODIFY_FIELD_SRC_OFFSET,
758 : : ACTION_MODIFY_FIELD_SRC_VALUE,
759 : : ACTION_MODIFY_FIELD_SRC_POINTER,
760 : : ACTION_MODIFY_FIELD_WIDTH,
761 : : ACTION_CONNTRACK,
762 : : ACTION_CONNTRACK_UPDATE,
763 : : ACTION_CONNTRACK_UPDATE_DIR,
764 : : ACTION_CONNTRACK_UPDATE_CTX,
765 : : ACTION_POL_G,
766 : : ACTION_POL_Y,
767 : : ACTION_POL_R,
768 : : ACTION_PORT_REPRESENTOR,
769 : : ACTION_PORT_REPRESENTOR_PORT_ID,
770 : : ACTION_REPRESENTED_PORT,
771 : : ACTION_REPRESENTED_PORT_ETHDEV_PORT_ID,
772 : : ACTION_SEND_TO_KERNEL,
773 : : ACTION_QUOTA_CREATE,
774 : : ACTION_QUOTA_CREATE_LIMIT,
775 : : ACTION_QUOTA_CREATE_MODE,
776 : : ACTION_QUOTA_CREATE_MODE_NAME,
777 : : ACTION_QUOTA_QU,
778 : : ACTION_QUOTA_QU_LIMIT,
779 : : ACTION_QUOTA_QU_UPDATE_OP,
780 : : ACTION_QUOTA_QU_UPDATE_OP_NAME,
781 : : ACTION_IPV6_EXT_REMOVE,
782 : : ACTION_IPV6_EXT_REMOVE_INDEX,
783 : : ACTION_IPV6_EXT_REMOVE_INDEX_VALUE,
784 : : ACTION_IPV6_EXT_PUSH,
785 : : ACTION_IPV6_EXT_PUSH_INDEX,
786 : : ACTION_IPV6_EXT_PUSH_INDEX_VALUE,
787 : : ACTION_NAT64,
788 : : ACTION_NAT64_MODE,
789 : : ACTION_JUMP_TO_TABLE_INDEX,
790 : : ACTION_JUMP_TO_TABLE_INDEX_TABLE,
791 : : ACTION_JUMP_TO_TABLE_INDEX_TABLE_VALUE,
792 : : ACTION_JUMP_TO_TABLE_INDEX_INDEX,
793 : : };
794 : :
795 : : /** Maximum size for pattern in struct rte_flow_item_raw. */
796 : : #define ITEM_RAW_PATTERN_SIZE 512
797 : :
798 : : /** Maximum size for GENEVE option data pattern in bytes. */
799 : : #define ITEM_GENEVE_OPT_DATA_SIZE 124
800 : :
801 : : /** Storage size for struct rte_flow_item_raw including pattern. */
802 : : #define ITEM_RAW_SIZE \
803 : : (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE)
804 : :
805 : : static const char *const compare_ops[] = {
806 : : "eq", "ne", "lt", "le", "gt", "ge", NULL
807 : : };
808 : :
809 : : /** Maximum size for external pattern in struct rte_flow_field_data. */
810 : : #define FLOW_FIELD_PATTERN_SIZE 32
811 : :
812 : : /** Storage size for struct rte_flow_action_modify_field including pattern. */
813 : : #define ACTION_MODIFY_SIZE \
814 : : (sizeof(struct rte_flow_action_modify_field) + \
815 : : FLOW_FIELD_PATTERN_SIZE)
816 : :
817 : : /** Maximum number of queue indices in struct rte_flow_action_rss. */
818 : : #define ACTION_RSS_QUEUE_NUM 128
819 : :
820 : : /** Storage for struct rte_flow_action_rss including external data. */
821 : : struct action_rss_data {
822 : : struct rte_flow_action_rss conf;
823 : : uint8_t key[RSS_HASH_KEY_LENGTH];
824 : : uint16_t queue[ACTION_RSS_QUEUE_NUM];
825 : : };
826 : :
827 : : /** Maximum data size in struct rte_flow_action_raw_encap. */
828 : : #define ACTION_RAW_ENCAP_MAX_DATA 512
829 : : #define RAW_ENCAP_CONFS_MAX_NUM 8
830 : :
831 : : /** Storage for struct rte_flow_action_raw_encap. */
832 : : struct raw_encap_conf {
833 : : uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
834 : : uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
835 : : size_t size;
836 : : };
837 : :
838 : : struct raw_encap_conf raw_encap_confs[RAW_ENCAP_CONFS_MAX_NUM];
839 : :
840 : : /** Storage for struct rte_flow_action_raw_encap including external data. */
841 : : struct action_raw_encap_data {
842 : : struct rte_flow_action_raw_encap conf;
843 : : uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
844 : : uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
845 : : uint16_t idx;
846 : : };
847 : :
848 : : /** Storage for struct rte_flow_action_raw_decap. */
849 : : struct raw_decap_conf {
850 : : uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
851 : : size_t size;
852 : : };
853 : :
854 : : struct raw_decap_conf raw_decap_confs[RAW_ENCAP_CONFS_MAX_NUM];
855 : :
856 : : /** Storage for struct rte_flow_action_raw_decap including external data. */
857 : : struct action_raw_decap_data {
858 : : struct rte_flow_action_raw_decap conf;
859 : : uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
860 : : uint16_t idx;
861 : : };
862 : :
863 : : /** Maximum data size in struct rte_flow_action_ipv6_ext_push. */
864 : : #define ACTION_IPV6_EXT_PUSH_MAX_DATA 512
865 : : #define IPV6_EXT_PUSH_CONFS_MAX_NUM 8
866 : :
867 : : /** Storage for struct rte_flow_action_ipv6_ext_push. */
868 : : struct ipv6_ext_push_conf {
869 : : uint8_t data[ACTION_IPV6_EXT_PUSH_MAX_DATA];
870 : : size_t size;
871 : : uint8_t type;
872 : : };
873 : :
874 : : struct ipv6_ext_push_conf ipv6_ext_push_confs[IPV6_EXT_PUSH_CONFS_MAX_NUM];
875 : :
876 : : /** Storage for struct rte_flow_action_ipv6_ext_push including external data. */
877 : : struct action_ipv6_ext_push_data {
878 : : struct rte_flow_action_ipv6_ext_push conf;
879 : : uint8_t data[ACTION_IPV6_EXT_PUSH_MAX_DATA];
880 : : uint8_t type;
881 : : uint16_t idx;
882 : : };
883 : :
884 : : /** Storage for struct rte_flow_action_ipv6_ext_remove. */
885 : : struct ipv6_ext_remove_conf {
886 : : struct rte_flow_action_ipv6_ext_remove conf;
887 : : uint8_t type;
888 : : };
889 : :
890 : : struct ipv6_ext_remove_conf ipv6_ext_remove_confs[IPV6_EXT_PUSH_CONFS_MAX_NUM];
891 : :
892 : : /** Storage for struct rte_flow_action_ipv6_ext_remove including external data. */
893 : : struct action_ipv6_ext_remove_data {
894 : : struct rte_flow_action_ipv6_ext_remove conf;
895 : : uint8_t type;
896 : : uint16_t idx;
897 : : };
898 : :
899 : : struct vxlan_encap_conf vxlan_encap_conf = {
900 : : .select_ipv4 = 1,
901 : : .select_vlan = 0,
902 : : .select_tos_ttl = 0,
903 : : .vni = { 0x00, 0x00, 0x00 },
904 : : .udp_src = 0,
905 : : .udp_dst = RTE_BE16(RTE_VXLAN_DEFAULT_PORT),
906 : : .ipv4_src = RTE_IPV4(127, 0, 0, 1),
907 : : .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
908 : : .ipv6_src = RTE_IPV6_ADDR_LOOPBACK,
909 : : .ipv6_dst = RTE_IPV6(0, 0, 0, 0, 0, 0, 0, 0x1111),
910 : : .vlan_tci = 0,
911 : : .ip_tos = 0,
912 : : .ip_ttl = 255,
913 : : .eth_src = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
914 : : .eth_dst = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
915 : : };
916 : :
917 : : /** Maximum number of items in struct rte_flow_action_vxlan_encap. */
918 : : #define ACTION_VXLAN_ENCAP_ITEMS_NUM 6
919 : :
920 : : /** Storage for struct rte_flow_action_vxlan_encap including external data. */
921 : : struct action_vxlan_encap_data {
922 : : struct rte_flow_action_vxlan_encap conf;
923 : : struct rte_flow_item items[ACTION_VXLAN_ENCAP_ITEMS_NUM];
924 : : struct rte_flow_item_eth item_eth;
925 : : struct rte_flow_item_vlan item_vlan;
926 : : union {
927 : : struct rte_flow_item_ipv4 item_ipv4;
928 : : struct rte_flow_item_ipv6 item_ipv6;
929 : : };
930 : : struct rte_flow_item_udp item_udp;
931 : : struct rte_flow_item_vxlan item_vxlan;
932 : : };
933 : :
934 : : struct nvgre_encap_conf nvgre_encap_conf = {
935 : : .select_ipv4 = 1,
936 : : .select_vlan = 0,
937 : : .tni = { 0x00, 0x00, 0x00 },
938 : : .ipv4_src = RTE_IPV4(127, 0, 0, 1),
939 : : .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
940 : : .ipv6_src = RTE_IPV6_ADDR_LOOPBACK,
941 : : .ipv6_dst = RTE_IPV6(0, 0, 0, 0, 0, 0, 0, 0x1111),
942 : : .vlan_tci = 0,
943 : : .eth_src = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
944 : : .eth_dst = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
945 : : };
946 : :
947 : : /** Maximum number of items in struct rte_flow_action_nvgre_encap. */
948 : : #define ACTION_NVGRE_ENCAP_ITEMS_NUM 5
949 : :
950 : : /** Storage for struct rte_flow_action_nvgre_encap including external data. */
951 : : struct action_nvgre_encap_data {
952 : : struct rte_flow_action_nvgre_encap conf;
953 : : struct rte_flow_item items[ACTION_NVGRE_ENCAP_ITEMS_NUM];
954 : : struct rte_flow_item_eth item_eth;
955 : : struct rte_flow_item_vlan item_vlan;
956 : : union {
957 : : struct rte_flow_item_ipv4 item_ipv4;
958 : : struct rte_flow_item_ipv6 item_ipv6;
959 : : };
960 : : struct rte_flow_item_nvgre item_nvgre;
961 : : };
962 : :
963 : : struct l2_encap_conf l2_encap_conf;
964 : :
965 : : struct l2_decap_conf l2_decap_conf;
966 : :
967 : : struct mplsogre_encap_conf mplsogre_encap_conf;
968 : :
969 : : struct mplsogre_decap_conf mplsogre_decap_conf;
970 : :
971 : : struct mplsoudp_encap_conf mplsoudp_encap_conf;
972 : :
973 : : struct mplsoudp_decap_conf mplsoudp_decap_conf;
974 : :
975 : : struct rte_flow_action_conntrack conntrack_context;
976 : :
977 : : #define ACTION_SAMPLE_ACTIONS_NUM 10
978 : : #define RAW_SAMPLE_CONFS_MAX_NUM 8
979 : : /** Storage for struct rte_flow_action_sample including external data. */
980 : : struct action_sample_data {
981 : : struct rte_flow_action_sample conf;
982 : : uint32_t idx;
983 : : };
984 : : /** Storage for struct rte_flow_action_sample. */
985 : : struct raw_sample_conf {
986 : : struct rte_flow_action data[ACTION_SAMPLE_ACTIONS_NUM];
987 : : };
988 : : struct raw_sample_conf raw_sample_confs[RAW_SAMPLE_CONFS_MAX_NUM];
989 : : struct rte_flow_action_mark sample_mark[RAW_SAMPLE_CONFS_MAX_NUM];
990 : : struct rte_flow_action_queue sample_queue[RAW_SAMPLE_CONFS_MAX_NUM];
991 : : struct rte_flow_action_count sample_count[RAW_SAMPLE_CONFS_MAX_NUM];
992 : : struct rte_flow_action_port_id sample_port_id[RAW_SAMPLE_CONFS_MAX_NUM];
993 : : struct rte_flow_action_raw_encap sample_encap[RAW_SAMPLE_CONFS_MAX_NUM];
994 : : struct action_vxlan_encap_data sample_vxlan_encap[RAW_SAMPLE_CONFS_MAX_NUM];
995 : : struct action_nvgre_encap_data sample_nvgre_encap[RAW_SAMPLE_CONFS_MAX_NUM];
996 : : struct action_rss_data sample_rss_data[RAW_SAMPLE_CONFS_MAX_NUM];
997 : : struct rte_flow_action_vf sample_vf[RAW_SAMPLE_CONFS_MAX_NUM];
998 : : struct rte_flow_action_ethdev sample_port_representor[RAW_SAMPLE_CONFS_MAX_NUM];
999 : : struct rte_flow_action_ethdev sample_represented_port[RAW_SAMPLE_CONFS_MAX_NUM];
1000 : :
1001 : : static const char *const modify_field_ops[] = {
1002 : : "set", "add", "sub", NULL
1003 : : };
1004 : :
1005 : : static const char *const flow_field_ids[] = {
1006 : : "start", "mac_dst", "mac_src",
1007 : : "vlan_type", "vlan_id", "mac_type",
1008 : : "ipv4_dscp", "ipv4_ttl", "ipv4_src", "ipv4_dst",
1009 : : "ipv6_dscp", "ipv6_hoplimit", "ipv6_src", "ipv6_dst",
1010 : : "tcp_port_src", "tcp_port_dst",
1011 : : "tcp_seq_num", "tcp_ack_num", "tcp_flags",
1012 : : "udp_port_src", "udp_port_dst",
1013 : : "vxlan_vni", "geneve_vni", "gtp_teid",
1014 : : "tag", "mark", "meta", "pointer", "value",
1015 : : "ipv4_ecn", "ipv6_ecn", "gtp_psc_qfi", "meter_color",
1016 : : "ipv6_proto",
1017 : : "flex_item",
1018 : : "hash_result",
1019 : : "geneve_opt_type", "geneve_opt_class", "geneve_opt_data", "mpls",
1020 : : "tcp_data_off", "ipv4_ihl", "ipv4_total_len", "ipv6_payload_len",
1021 : : "ipv4_proto",
1022 : : "ipv6_flow_label", "ipv6_traffic_class",
1023 : : "esp_spi", "esp_seq_num", "esp_proto",
1024 : : "random",
1025 : : "vxlan_last_rsvd",
1026 : : NULL
1027 : : };
1028 : :
1029 : : static const char *const meter_colors[] = {
1030 : : "green", "yellow", "red", "all", NULL
1031 : : };
1032 : :
1033 : : static const char *const table_insertion_types[] = {
1034 : : "pattern", "index", "index_with_pattern", NULL
1035 : : };
1036 : :
1037 : : static const char *const table_hash_funcs[] = {
1038 : : "default", "linear", "crc32", "crc16", NULL
1039 : : };
1040 : :
1041 : : #define RAW_IPSEC_CONFS_MAX_NUM 8
1042 : :
1043 : : /** Maximum number of subsequent tokens and arguments on the stack. */
1044 : : #define CTX_STACK_SIZE 16
1045 : :
1046 : : /** Parser context. */
1047 : : struct context {
1048 : : /** Stack of subsequent token lists to process. */
1049 : : const enum index *next[CTX_STACK_SIZE];
1050 : : /** Arguments for stacked tokens. */
1051 : : const void *args[CTX_STACK_SIZE];
1052 : : enum index curr; /**< Current token index. */
1053 : : enum index prev; /**< Index of the last token seen. */
1054 : : int next_num; /**< Number of entries in next[]. */
1055 : : int args_num; /**< Number of entries in args[]. */
1056 : : uint32_t eol:1; /**< EOL has been detected. */
1057 : : uint32_t last:1; /**< No more arguments. */
1058 : : portid_t port; /**< Current port ID (for completions). */
1059 : : uint32_t objdata; /**< Object-specific data. */
1060 : : void *object; /**< Address of current object for relative offsets. */
1061 : : void *objmask; /**< Object a full mask must be written to. */
1062 : : };
1063 : :
1064 : : /** Token argument. */
1065 : : struct arg {
1066 : : uint32_t hton:1; /**< Use network byte ordering. */
1067 : : uint32_t sign:1; /**< Value is signed. */
1068 : : uint32_t bounded:1; /**< Value is bounded. */
1069 : : uintmax_t min; /**< Minimum value if bounded. */
1070 : : uintmax_t max; /**< Maximum value if bounded. */
1071 : : uint32_t offset; /**< Relative offset from ctx->object. */
1072 : : uint32_t size; /**< Field size. */
1073 : : const uint8_t *mask; /**< Bit-mask to use instead of offset/size. */
1074 : : };
1075 : :
1076 : : /** Parser token definition. */
1077 : : struct token {
1078 : : /** Type displayed during completion (defaults to "TOKEN"). */
1079 : : const char *type;
1080 : : /** Help displayed during completion (defaults to token name). */
1081 : : const char *help;
1082 : : /** Private data used by parser functions. */
1083 : : const void *priv;
1084 : : /**
1085 : : * Lists of subsequent tokens to push on the stack. Each call to the
1086 : : * parser consumes the last entry of that stack.
1087 : : */
1088 : : const enum index *const *next;
1089 : : /** Arguments stack for subsequent tokens that need them. */
1090 : : const struct arg *const *args;
1091 : : /**
1092 : : * Token-processing callback, returns -1 in case of error, the
1093 : : * length of the matched string otherwise. If NULL, attempts to
1094 : : * match the token name.
1095 : : *
1096 : : * If buf is not NULL, the result should be stored in it according
1097 : : * to context. An error is returned if not large enough.
1098 : : */
1099 : : int (*call)(struct context *ctx, const struct token *token,
1100 : : const char *str, unsigned int len,
1101 : : void *buf, unsigned int size);
1102 : : /**
1103 : : * Callback that provides possible values for this token, used for
1104 : : * completion. Returns -1 in case of error, the number of possible
1105 : : * values otherwise. If NULL, the token name is used.
1106 : : *
1107 : : * If buf is not NULL, entry index ent is written to buf and the
1108 : : * full length of the entry is returned (same behavior as
1109 : : * snprintf()).
1110 : : */
1111 : : int (*comp)(struct context *ctx, const struct token *token,
1112 : : unsigned int ent, char *buf, unsigned int size);
1113 : : /** Mandatory token name, no default value. */
1114 : : const char *name;
1115 : : };
1116 : :
1117 : : /** Static initializer for the next field. */
1118 : : #define NEXT(...) (const enum index *const []){ __VA_ARGS__, NULL, }
1119 : :
1120 : : /** Static initializer for a NEXT() entry. */
1121 : : #define NEXT_ENTRY(...) (const enum index []){ __VA_ARGS__, ZERO, }
1122 : :
1123 : : /** Static initializer for the args field. */
1124 : : #define ARGS(...) (const struct arg *const []){ __VA_ARGS__, NULL, }
1125 : :
1126 : : /** Static initializer for ARGS() to target a field. */
1127 : : #define ARGS_ENTRY(s, f) \
1128 : : (&(const struct arg){ \
1129 : : .offset = offsetof(s, f), \
1130 : : .size = sizeof(((s *)0)->f), \
1131 : : })
1132 : :
1133 : : /** Static initializer for ARGS() to target a bit-field. */
1134 : : #define ARGS_ENTRY_BF(s, f, b) \
1135 : : (&(const struct arg){ \
1136 : : .size = sizeof(s), \
1137 : : .mask = (const void *)&(const s){ .f = (1 << (b)) - 1 }, \
1138 : : })
1139 : :
1140 : : /** Static initializer for ARGS() to target a field with limits. */
1141 : : #define ARGS_ENTRY_BOUNDED(s, f, i, a) \
1142 : : (&(const struct arg){ \
1143 : : .bounded = 1, \
1144 : : .min = (i), \
1145 : : .max = (a), \
1146 : : .offset = offsetof(s, f), \
1147 : : .size = sizeof(((s *)0)->f), \
1148 : : })
1149 : :
1150 : : /** Static initializer for ARGS() to target an arbitrary bit-mask. */
1151 : : #define ARGS_ENTRY_MASK(s, f, m) \
1152 : : (&(const struct arg){ \
1153 : : .offset = offsetof(s, f), \
1154 : : .size = sizeof(((s *)0)->f), \
1155 : : .mask = (const void *)(m), \
1156 : : })
1157 : :
1158 : : /** Same as ARGS_ENTRY_MASK() using network byte ordering for the value. */
1159 : : #define ARGS_ENTRY_MASK_HTON(s, f, m) \
1160 : : (&(const struct arg){ \
1161 : : .hton = 1, \
1162 : : .offset = offsetof(s, f), \
1163 : : .size = sizeof(((s *)0)->f), \
1164 : : .mask = (const void *)(m), \
1165 : : })
1166 : :
1167 : : /** Static initializer for ARGS() to target a pointer. */
1168 : : #define ARGS_ENTRY_PTR(s, f) \
1169 : : (&(const struct arg){ \
1170 : : .size = sizeof(*((s *)0)->f), \
1171 : : })
1172 : :
1173 : : /** Static initializer for ARGS() with arbitrary offset and size. */
1174 : : #define ARGS_ENTRY_ARB(o, s) \
1175 : : (&(const struct arg){ \
1176 : : .offset = (o), \
1177 : : .size = (s), \
1178 : : })
1179 : :
1180 : : /** Same as ARGS_ENTRY_ARB() with bounded values. */
1181 : : #define ARGS_ENTRY_ARB_BOUNDED(o, s, i, a) \
1182 : : (&(const struct arg){ \
1183 : : .bounded = 1, \
1184 : : .min = (i), \
1185 : : .max = (a), \
1186 : : .offset = (o), \
1187 : : .size = (s), \
1188 : : })
1189 : :
1190 : : /** Same as ARGS_ENTRY() using network byte ordering. */
1191 : : #define ARGS_ENTRY_HTON(s, f) \
1192 : : (&(const struct arg){ \
1193 : : .hton = 1, \
1194 : : .offset = offsetof(s, f), \
1195 : : .size = sizeof(((s *)0)->f), \
1196 : : })
1197 : :
1198 : : /** Same as ARGS_ENTRY_HTON() for a single argument, without structure. */
1199 : : #define ARG_ENTRY_HTON(s) \
1200 : : (&(const struct arg){ \
1201 : : .hton = 1, \
1202 : : .offset = 0, \
1203 : : .size = sizeof(s), \
1204 : : })
1205 : :
1206 : : /** Parser output buffer layout expected by cmd_flow_parsed(). */
1207 : : struct buffer {
1208 : : enum index command; /**< Flow command. */
1209 : : portid_t port; /**< Affected port ID. */
1210 : : queueid_t queue; /** Async queue ID. */
1211 : : bool postpone; /** Postpone async operation */
1212 : : union {
1213 : : struct {
1214 : : struct rte_flow_port_attr port_attr;
1215 : : uint32_t nb_queue;
1216 : : struct rte_flow_queue_attr queue_attr;
1217 : : } configure; /**< Configuration arguments. */
1218 : : struct {
1219 : : uint32_t *template_id;
1220 : : uint32_t template_id_n;
1221 : : } templ_destroy; /**< Template destroy arguments. */
1222 : : struct {
1223 : : uint32_t id;
1224 : : struct rte_flow_template_table_attr attr;
1225 : : uint32_t *pat_templ_id;
1226 : : uint32_t pat_templ_id_n;
1227 : : uint32_t *act_templ_id;
1228 : : uint32_t act_templ_id_n;
1229 : : } table; /**< Table arguments. */
1230 : : struct {
1231 : : uint32_t *table_id;
1232 : : uint32_t table_id_n;
1233 : : } table_destroy; /**< Template destroy arguments. */
1234 : : struct {
1235 : : uint32_t *action_id;
1236 : : uint32_t action_id_n;
1237 : : } ia_destroy; /**< Indirect action destroy arguments. */
1238 : : struct {
1239 : : uint32_t action_id;
1240 : : enum rte_flow_query_update_mode qu_mode;
1241 : : } ia; /* Indirect action query arguments */
1242 : : struct {
1243 : : uint32_t table_id;
1244 : : uint32_t pat_templ_id;
1245 : : uint32_t rule_id;
1246 : : uint32_t act_templ_id;
1247 : : struct rte_flow_attr attr;
1248 : : struct tunnel_ops tunnel_ops;
1249 : : uintptr_t user_id;
1250 : : struct rte_flow_item *pattern;
1251 : : struct rte_flow_action *actions;
1252 : : struct rte_flow_action *masks;
1253 : : uint32_t pattern_n;
1254 : : uint32_t actions_n;
1255 : : uint8_t *data;
1256 : : enum rte_flow_encap_hash_field field;
1257 : : uint8_t encap_hash;
1258 : : } vc; /**< Validate/create arguments. */
1259 : : struct {
1260 : : uint64_t *rule;
1261 : : uint64_t rule_n;
1262 : : bool is_user_id;
1263 : : } destroy; /**< Destroy arguments. */
1264 : : struct {
1265 : : char file[128];
1266 : : bool mode;
1267 : : uint64_t rule;
1268 : : bool is_user_id;
1269 : : } dump; /**< Dump arguments. */
1270 : : struct {
1271 : : uint64_t rule;
1272 : : struct rte_flow_action action;
1273 : : bool is_user_id;
1274 : : } query; /**< Query arguments. */
1275 : : struct {
1276 : : uint32_t *group;
1277 : : uint32_t group_n;
1278 : : } list; /**< List arguments. */
1279 : : struct {
1280 : : int set;
1281 : : } isolate; /**< Isolated mode arguments. */
1282 : : struct {
1283 : : int destroy;
1284 : : } aged; /**< Aged arguments. */
1285 : : struct {
1286 : : uint32_t policy_id;
1287 : : } policy;/**< Policy arguments. */
1288 : : struct {
1289 : : uint16_t token;
1290 : : uintptr_t uintptr;
1291 : : char filename[128];
1292 : : } flex; /**< Flex arguments*/
1293 : : } args; /**< Command arguments. */
1294 : : };
1295 : :
1296 : : /** Private data for pattern items. */
1297 : : struct parse_item_priv {
1298 : : enum rte_flow_item_type type; /**< Item type. */
1299 : : uint32_t size; /**< Size of item specification structure. */
1300 : : };
1301 : :
1302 : : #define PRIV_ITEM(t, s) \
1303 : : (&(const struct parse_item_priv){ \
1304 : : .type = RTE_FLOW_ITEM_TYPE_ ## t, \
1305 : : .size = s, \
1306 : : })
1307 : :
1308 : : /** Private data for actions. */
1309 : : struct parse_action_priv {
1310 : : enum rte_flow_action_type type; /**< Action type. */
1311 : : uint32_t size; /**< Size of action configuration structure. */
1312 : : };
1313 : :
1314 : : #define PRIV_ACTION(t, s) \
1315 : : (&(const struct parse_action_priv){ \
1316 : : .type = RTE_FLOW_ACTION_TYPE_ ## t, \
1317 : : .size = s, \
1318 : : })
1319 : :
1320 : : static const enum index next_flex_item[] = {
1321 : : FLEX_ITEM_CREATE,
1322 : : FLEX_ITEM_DESTROY,
1323 : : ZERO,
1324 : : };
1325 : :
1326 : : static const enum index next_config_attr[] = {
1327 : : CONFIG_QUEUES_NUMBER,
1328 : : CONFIG_QUEUES_SIZE,
1329 : : CONFIG_COUNTERS_NUMBER,
1330 : : CONFIG_AGING_OBJECTS_NUMBER,
1331 : : CONFIG_METERS_NUMBER,
1332 : : CONFIG_CONN_TRACK_NUMBER,
1333 : : CONFIG_QUOTAS_NUMBER,
1334 : : CONFIG_FLAGS,
1335 : : CONFIG_HOST_PORT,
1336 : : END,
1337 : : ZERO,
1338 : : };
1339 : :
1340 : : static const enum index next_pt_subcmd[] = {
1341 : : PATTERN_TEMPLATE_CREATE,
1342 : : PATTERN_TEMPLATE_DESTROY,
1343 : : ZERO,
1344 : : };
1345 : :
1346 : : static const enum index next_pt_attr[] = {
1347 : : PATTERN_TEMPLATE_CREATE_ID,
1348 : : PATTERN_TEMPLATE_RELAXED_MATCHING,
1349 : : PATTERN_TEMPLATE_INGRESS,
1350 : : PATTERN_TEMPLATE_EGRESS,
1351 : : PATTERN_TEMPLATE_TRANSFER,
1352 : : PATTERN_TEMPLATE_SPEC,
1353 : : ZERO,
1354 : : };
1355 : :
1356 : : static const enum index next_pt_destroy_attr[] = {
1357 : : PATTERN_TEMPLATE_DESTROY_ID,
1358 : : END,
1359 : : ZERO,
1360 : : };
1361 : :
1362 : : static const enum index next_at_subcmd[] = {
1363 : : ACTIONS_TEMPLATE_CREATE,
1364 : : ACTIONS_TEMPLATE_DESTROY,
1365 : : ZERO,
1366 : : };
1367 : :
1368 : : static const enum index next_at_attr[] = {
1369 : : ACTIONS_TEMPLATE_CREATE_ID,
1370 : : ACTIONS_TEMPLATE_INGRESS,
1371 : : ACTIONS_TEMPLATE_EGRESS,
1372 : : ACTIONS_TEMPLATE_TRANSFER,
1373 : : ACTIONS_TEMPLATE_SPEC,
1374 : : ZERO,
1375 : : };
1376 : :
1377 : : static const enum index next_at_destroy_attr[] = {
1378 : : ACTIONS_TEMPLATE_DESTROY_ID,
1379 : : END,
1380 : : ZERO,
1381 : : };
1382 : :
1383 : : static const enum index next_group_attr[] = {
1384 : : GROUP_INGRESS,
1385 : : GROUP_EGRESS,
1386 : : GROUP_TRANSFER,
1387 : : GROUP_SET_MISS_ACTIONS,
1388 : : ZERO,
1389 : : };
1390 : :
1391 : : static const enum index next_table_subcmd[] = {
1392 : : TABLE_CREATE,
1393 : : TABLE_DESTROY,
1394 : : TABLE_RESIZE,
1395 : : TABLE_RESIZE_COMPLETE,
1396 : : ZERO,
1397 : : };
1398 : :
1399 : : static const enum index next_table_attr[] = {
1400 : : TABLE_CREATE_ID,
1401 : : TABLE_GROUP,
1402 : : TABLE_INSERTION_TYPE,
1403 : : TABLE_HASH_FUNC,
1404 : : TABLE_PRIORITY,
1405 : : TABLE_INGRESS,
1406 : : TABLE_EGRESS,
1407 : : TABLE_TRANSFER,
1408 : : TABLE_TRANSFER_WIRE_ORIG,
1409 : : TABLE_TRANSFER_VPORT_ORIG,
1410 : : TABLE_RESIZABLE,
1411 : : TABLE_RULES_NUMBER,
1412 : : TABLE_PATTERN_TEMPLATE,
1413 : : TABLE_ACTIONS_TEMPLATE,
1414 : : END,
1415 : : ZERO,
1416 : : };
1417 : :
1418 : : static const enum index next_table_destroy_attr[] = {
1419 : : TABLE_DESTROY_ID,
1420 : : END,
1421 : : ZERO,
1422 : : };
1423 : :
1424 : : static const enum index next_queue_subcmd[] = {
1425 : : QUEUE_CREATE,
1426 : : QUEUE_DESTROY,
1427 : : QUEUE_FLOW_UPDATE_RESIZED,
1428 : : QUEUE_UPDATE,
1429 : : QUEUE_AGED,
1430 : : QUEUE_INDIRECT_ACTION,
1431 : : ZERO,
1432 : : };
1433 : :
1434 : : static const enum index next_queue_destroy_attr[] = {
1435 : : QUEUE_DESTROY_ID,
1436 : : END,
1437 : : ZERO,
1438 : : };
1439 : :
1440 : : static const enum index next_qia_subcmd[] = {
1441 : : QUEUE_INDIRECT_ACTION_CREATE,
1442 : : QUEUE_INDIRECT_ACTION_UPDATE,
1443 : : QUEUE_INDIRECT_ACTION_DESTROY,
1444 : : QUEUE_INDIRECT_ACTION_QUERY,
1445 : : QUEUE_INDIRECT_ACTION_QUERY_UPDATE,
1446 : : ZERO,
1447 : : };
1448 : :
1449 : : static const enum index next_qia_create_attr[] = {
1450 : : QUEUE_INDIRECT_ACTION_CREATE_ID,
1451 : : QUEUE_INDIRECT_ACTION_INGRESS,
1452 : : QUEUE_INDIRECT_ACTION_EGRESS,
1453 : : QUEUE_INDIRECT_ACTION_TRANSFER,
1454 : : QUEUE_INDIRECT_ACTION_CREATE_POSTPONE,
1455 : : QUEUE_INDIRECT_ACTION_SPEC,
1456 : : QUEUE_INDIRECT_ACTION_LIST,
1457 : : ZERO,
1458 : : };
1459 : :
1460 : : static const enum index next_qia_update_attr[] = {
1461 : : QUEUE_INDIRECT_ACTION_UPDATE_POSTPONE,
1462 : : QUEUE_INDIRECT_ACTION_SPEC,
1463 : : ZERO,
1464 : : };
1465 : :
1466 : : static const enum index next_qia_destroy_attr[] = {
1467 : : QUEUE_INDIRECT_ACTION_DESTROY_POSTPONE,
1468 : : QUEUE_INDIRECT_ACTION_DESTROY_ID,
1469 : : END,
1470 : : ZERO,
1471 : : };
1472 : :
1473 : : static const enum index next_qia_query_attr[] = {
1474 : : QUEUE_INDIRECT_ACTION_QUERY_POSTPONE,
1475 : : END,
1476 : : ZERO,
1477 : : };
1478 : :
1479 : : static const enum index next_ia_create_attr[] = {
1480 : : INDIRECT_ACTION_CREATE_ID,
1481 : : INDIRECT_ACTION_INGRESS,
1482 : : INDIRECT_ACTION_EGRESS,
1483 : : INDIRECT_ACTION_TRANSFER,
1484 : : INDIRECT_ACTION_SPEC,
1485 : : INDIRECT_ACTION_LIST,
1486 : : INDIRECT_ACTION_FLOW_CONF,
1487 : : ZERO,
1488 : : };
1489 : :
1490 : : static const enum index next_ia[] = {
1491 : : INDIRECT_ACTION_ID2PTR,
1492 : : ACTION_NEXT,
1493 : : ZERO
1494 : : };
1495 : :
1496 : : static const enum index next_ial[] = {
1497 : : ACTION_INDIRECT_LIST_HANDLE,
1498 : : ACTION_INDIRECT_LIST_CONF,
1499 : : ACTION_NEXT,
1500 : : ZERO
1501 : : };
1502 : :
1503 : : static const enum index next_qia_qu_attr[] = {
1504 : : QUEUE_INDIRECT_ACTION_QU_MODE,
1505 : : QUEUE_INDIRECT_ACTION_UPDATE_POSTPONE,
1506 : : INDIRECT_ACTION_SPEC,
1507 : : ZERO
1508 : : };
1509 : :
1510 : : static const enum index next_ia_qu_attr[] = {
1511 : : INDIRECT_ACTION_QU_MODE,
1512 : : INDIRECT_ACTION_SPEC,
1513 : : ZERO
1514 : : };
1515 : :
1516 : : static const enum index next_dump_subcmd[] = {
1517 : : DUMP_ALL,
1518 : : DUMP_ONE,
1519 : : DUMP_IS_USER_ID,
1520 : : ZERO,
1521 : : };
1522 : :
1523 : : static const enum index next_ia_subcmd[] = {
1524 : : INDIRECT_ACTION_CREATE,
1525 : : INDIRECT_ACTION_UPDATE,
1526 : : INDIRECT_ACTION_DESTROY,
1527 : : INDIRECT_ACTION_QUERY,
1528 : : INDIRECT_ACTION_QUERY_UPDATE,
1529 : : ZERO,
1530 : : };
1531 : :
1532 : : static const enum index next_vc_attr[] = {
1533 : : VC_GROUP,
1534 : : VC_PRIORITY,
1535 : : VC_INGRESS,
1536 : : VC_EGRESS,
1537 : : VC_TRANSFER,
1538 : : VC_TUNNEL_SET,
1539 : : VC_TUNNEL_MATCH,
1540 : : VC_USER_ID,
1541 : : ITEM_PATTERN,
1542 : : ZERO,
1543 : : };
1544 : :
1545 : : static const enum index next_destroy_attr[] = {
1546 : : DESTROY_RULE,
1547 : : DESTROY_IS_USER_ID,
1548 : : END,
1549 : : ZERO,
1550 : : };
1551 : :
1552 : : static const enum index next_dump_attr[] = {
1553 : : COMMON_FILE_PATH,
1554 : : END,
1555 : : ZERO,
1556 : : };
1557 : :
1558 : : static const enum index next_query_attr[] = {
1559 : : QUERY_IS_USER_ID,
1560 : : END,
1561 : : ZERO,
1562 : : };
1563 : :
1564 : : static const enum index next_list_attr[] = {
1565 : : LIST_GROUP,
1566 : : END,
1567 : : ZERO,
1568 : : };
1569 : :
1570 : : static const enum index next_aged_attr[] = {
1571 : : AGED_DESTROY,
1572 : : END,
1573 : : ZERO,
1574 : : };
1575 : :
1576 : : static const enum index next_ia_destroy_attr[] = {
1577 : : INDIRECT_ACTION_DESTROY_ID,
1578 : : END,
1579 : : ZERO,
1580 : : };
1581 : :
1582 : : static const enum index next_async_insert_subcmd[] = {
1583 : : QUEUE_PATTERN_TEMPLATE,
1584 : : QUEUE_RULE_ID,
1585 : : ZERO,
1586 : : };
1587 : :
1588 : : static const enum index next_async_pattern_subcmd[] = {
1589 : : QUEUE_PATTERN_TEMPLATE,
1590 : : QUEUE_ACTIONS_TEMPLATE,
1591 : : ZERO,
1592 : : };
1593 : :
1594 : : static const enum index item_param[] = {
1595 : : ITEM_PARAM_IS,
1596 : : ITEM_PARAM_SPEC,
1597 : : ITEM_PARAM_LAST,
1598 : : ITEM_PARAM_MASK,
1599 : : ITEM_PARAM_PREFIX,
1600 : : ZERO,
1601 : : };
1602 : :
1603 : : static const enum index next_item[] = {
1604 : : ITEM_END,
1605 : : ITEM_VOID,
1606 : : ITEM_INVERT,
1607 : : ITEM_ANY,
1608 : : ITEM_PORT_ID,
1609 : : ITEM_MARK,
1610 : : ITEM_RAW,
1611 : : ITEM_ETH,
1612 : : ITEM_VLAN,
1613 : : ITEM_IPV4,
1614 : : ITEM_IPV6,
1615 : : ITEM_ICMP,
1616 : : ITEM_UDP,
1617 : : ITEM_TCP,
1618 : : ITEM_SCTP,
1619 : : ITEM_VXLAN,
1620 : : ITEM_E_TAG,
1621 : : ITEM_NVGRE,
1622 : : ITEM_MPLS,
1623 : : ITEM_GRE,
1624 : : ITEM_FUZZY,
1625 : : ITEM_GTP,
1626 : : ITEM_GTPC,
1627 : : ITEM_GTPU,
1628 : : ITEM_GENEVE,
1629 : : ITEM_VXLAN_GPE,
1630 : : ITEM_ARP_ETH_IPV4,
1631 : : ITEM_IPV6_EXT,
1632 : : ITEM_IPV6_FRAG_EXT,
1633 : : ITEM_IPV6_ROUTING_EXT,
1634 : : ITEM_ICMP6,
1635 : : ITEM_ICMP6_ECHO_REQUEST,
1636 : : ITEM_ICMP6_ECHO_REPLY,
1637 : : ITEM_ICMP6_ND_NS,
1638 : : ITEM_ICMP6_ND_NA,
1639 : : ITEM_ICMP6_ND_OPT,
1640 : : ITEM_ICMP6_ND_OPT_SLA_ETH,
1641 : : ITEM_ICMP6_ND_OPT_TLA_ETH,
1642 : : ITEM_META,
1643 : : ITEM_RANDOM,
1644 : : ITEM_GRE_KEY,
1645 : : ITEM_GRE_OPTION,
1646 : : ITEM_GTP_PSC,
1647 : : ITEM_PPPOES,
1648 : : ITEM_PPPOED,
1649 : : ITEM_PPPOE_PROTO_ID,
1650 : : ITEM_HIGIG2,
1651 : : ITEM_TAG,
1652 : : ITEM_L2TPV3OIP,
1653 : : ITEM_ESP,
1654 : : ITEM_AH,
1655 : : ITEM_PFCP,
1656 : : ITEM_ECPRI,
1657 : : ITEM_GENEVE_OPT,
1658 : : ITEM_INTEGRITY,
1659 : : ITEM_CONNTRACK,
1660 : : ITEM_PORT_REPRESENTOR,
1661 : : ITEM_REPRESENTED_PORT,
1662 : : ITEM_FLEX,
1663 : : ITEM_L2TPV2,
1664 : : ITEM_PPP,
1665 : : ITEM_METER,
1666 : : ITEM_QUOTA,
1667 : : ITEM_AGGR_AFFINITY,
1668 : : ITEM_TX_QUEUE,
1669 : : ITEM_IB_BTH,
1670 : : ITEM_PTYPE,
1671 : : ITEM_NSH,
1672 : : ITEM_COMPARE,
1673 : : END_SET,
1674 : : ZERO,
1675 : : };
1676 : :
1677 : : static const enum index item_fuzzy[] = {
1678 : : ITEM_FUZZY_THRESH,
1679 : : ITEM_NEXT,
1680 : : ZERO,
1681 : : };
1682 : :
1683 : : static const enum index item_any[] = {
1684 : : ITEM_ANY_NUM,
1685 : : ITEM_NEXT,
1686 : : ZERO,
1687 : : };
1688 : :
1689 : : static const enum index item_port_id[] = {
1690 : : ITEM_PORT_ID_ID,
1691 : : ITEM_NEXT,
1692 : : ZERO,
1693 : : };
1694 : :
1695 : : static const enum index item_mark[] = {
1696 : : ITEM_MARK_ID,
1697 : : ITEM_NEXT,
1698 : : ZERO,
1699 : : };
1700 : :
1701 : : static const enum index item_raw[] = {
1702 : : ITEM_RAW_RELATIVE,
1703 : : ITEM_RAW_SEARCH,
1704 : : ITEM_RAW_OFFSET,
1705 : : ITEM_RAW_LIMIT,
1706 : : ITEM_RAW_PATTERN,
1707 : : ITEM_RAW_PATTERN_HEX,
1708 : : ITEM_NEXT,
1709 : : ZERO,
1710 : : };
1711 : :
1712 : : static const enum index item_eth[] = {
1713 : : ITEM_ETH_DST,
1714 : : ITEM_ETH_SRC,
1715 : : ITEM_ETH_TYPE,
1716 : : ITEM_ETH_HAS_VLAN,
1717 : : ITEM_NEXT,
1718 : : ZERO,
1719 : : };
1720 : :
1721 : : static const enum index item_vlan[] = {
1722 : : ITEM_VLAN_TCI,
1723 : : ITEM_VLAN_PCP,
1724 : : ITEM_VLAN_DEI,
1725 : : ITEM_VLAN_VID,
1726 : : ITEM_VLAN_INNER_TYPE,
1727 : : ITEM_VLAN_HAS_MORE_VLAN,
1728 : : ITEM_NEXT,
1729 : : ZERO,
1730 : : };
1731 : :
1732 : : static const enum index item_ipv4[] = {
1733 : : ITEM_IPV4_VER_IHL,
1734 : : ITEM_IPV4_TOS,
1735 : : ITEM_IPV4_LENGTH,
1736 : : ITEM_IPV4_ID,
1737 : : ITEM_IPV4_FRAGMENT_OFFSET,
1738 : : ITEM_IPV4_TTL,
1739 : : ITEM_IPV4_PROTO,
1740 : : ITEM_IPV4_SRC,
1741 : : ITEM_IPV4_DST,
1742 : : ITEM_NEXT,
1743 : : ZERO,
1744 : : };
1745 : :
1746 : : static const enum index item_ipv6[] = {
1747 : : ITEM_IPV6_TC,
1748 : : ITEM_IPV6_FLOW,
1749 : : ITEM_IPV6_LEN,
1750 : : ITEM_IPV6_PROTO,
1751 : : ITEM_IPV6_HOP,
1752 : : ITEM_IPV6_SRC,
1753 : : ITEM_IPV6_DST,
1754 : : ITEM_IPV6_HAS_FRAG_EXT,
1755 : : ITEM_IPV6_ROUTING_EXT,
1756 : : ITEM_NEXT,
1757 : : ZERO,
1758 : : };
1759 : :
1760 : : static const enum index item_ipv6_routing_ext[] = {
1761 : : ITEM_IPV6_ROUTING_EXT_TYPE,
1762 : : ITEM_IPV6_ROUTING_EXT_NEXT_HDR,
1763 : : ITEM_IPV6_ROUTING_EXT_SEG_LEFT,
1764 : : ITEM_NEXT,
1765 : : ZERO,
1766 : : };
1767 : :
1768 : : static const enum index item_icmp[] = {
1769 : : ITEM_ICMP_TYPE,
1770 : : ITEM_ICMP_CODE,
1771 : : ITEM_ICMP_IDENT,
1772 : : ITEM_ICMP_SEQ,
1773 : : ITEM_NEXT,
1774 : : ZERO,
1775 : : };
1776 : :
1777 : : static const enum index item_udp[] = {
1778 : : ITEM_UDP_SRC,
1779 : : ITEM_UDP_DST,
1780 : : ITEM_NEXT,
1781 : : ZERO,
1782 : : };
1783 : :
1784 : : static const enum index item_tcp[] = {
1785 : : ITEM_TCP_SRC,
1786 : : ITEM_TCP_DST,
1787 : : ITEM_TCP_FLAGS,
1788 : : ITEM_NEXT,
1789 : : ZERO,
1790 : : };
1791 : :
1792 : : static const enum index item_sctp[] = {
1793 : : ITEM_SCTP_SRC,
1794 : : ITEM_SCTP_DST,
1795 : : ITEM_SCTP_TAG,
1796 : : ITEM_SCTP_CKSUM,
1797 : : ITEM_NEXT,
1798 : : ZERO,
1799 : : };
1800 : :
1801 : : static const enum index item_vxlan[] = {
1802 : : ITEM_VXLAN_VNI,
1803 : : ITEM_VXLAN_FLAG_G,
1804 : : ITEM_VXLAN_FLAG_VER,
1805 : : ITEM_VXLAN_FLAG_I,
1806 : : ITEM_VXLAN_FLAG_P,
1807 : : ITEM_VXLAN_FLAG_B,
1808 : : ITEM_VXLAN_FLAG_O,
1809 : : ITEM_VXLAN_FLAG_D,
1810 : : ITEM_VXLAN_FLAG_A,
1811 : : ITEM_VXLAN_GBP_ID,
1812 : : ITEM_VXLAN_GPE_PROTO,
1813 : : ITEM_VXLAN_FIRST_RSVD,
1814 : : ITEM_VXLAN_SECND_RSVD,
1815 : : ITEM_VXLAN_THIRD_RSVD,
1816 : : ITEM_VXLAN_LAST_RSVD,
1817 : : ITEM_NEXT,
1818 : : ZERO,
1819 : : };
1820 : :
1821 : : static const enum index item_e_tag[] = {
1822 : : ITEM_E_TAG_GRP_ECID_B,
1823 : : ITEM_NEXT,
1824 : : ZERO,
1825 : : };
1826 : :
1827 : : static const enum index item_nvgre[] = {
1828 : : ITEM_NVGRE_TNI,
1829 : : ITEM_NEXT,
1830 : : ZERO,
1831 : : };
1832 : :
1833 : : static const enum index item_mpls[] = {
1834 : : ITEM_MPLS_LABEL,
1835 : : ITEM_MPLS_TC,
1836 : : ITEM_MPLS_S,
1837 : : ITEM_MPLS_TTL,
1838 : : ITEM_NEXT,
1839 : : ZERO,
1840 : : };
1841 : :
1842 : : static const enum index item_gre[] = {
1843 : : ITEM_GRE_PROTO,
1844 : : ITEM_GRE_C_RSVD0_VER,
1845 : : ITEM_GRE_C_BIT,
1846 : : ITEM_GRE_K_BIT,
1847 : : ITEM_GRE_S_BIT,
1848 : : ITEM_NEXT,
1849 : : ZERO,
1850 : : };
1851 : :
1852 : : static const enum index item_gre_key[] = {
1853 : : ITEM_GRE_KEY_VALUE,
1854 : : ITEM_NEXT,
1855 : : ZERO,
1856 : : };
1857 : :
1858 : : static const enum index item_gre_option[] = {
1859 : : ITEM_GRE_OPTION_CHECKSUM,
1860 : : ITEM_GRE_OPTION_KEY,
1861 : : ITEM_GRE_OPTION_SEQUENCE,
1862 : : ITEM_NEXT,
1863 : : ZERO,
1864 : : };
1865 : :
1866 : : static const enum index item_gtp[] = {
1867 : : ITEM_GTP_FLAGS,
1868 : : ITEM_GTP_MSG_TYPE,
1869 : : ITEM_GTP_TEID,
1870 : : ITEM_NEXT,
1871 : : ZERO,
1872 : : };
1873 : :
1874 : : static const enum index item_geneve[] = {
1875 : : ITEM_GENEVE_VNI,
1876 : : ITEM_GENEVE_PROTO,
1877 : : ITEM_GENEVE_OPTLEN,
1878 : : ITEM_NEXT,
1879 : : ZERO,
1880 : : };
1881 : :
1882 : : static const enum index item_vxlan_gpe[] = {
1883 : : ITEM_VXLAN_GPE_VNI,
1884 : : ITEM_VXLAN_GPE_PROTO_IN_DEPRECATED_VXLAN_GPE_HDR,
1885 : : ITEM_VXLAN_GPE_FLAGS,
1886 : : ITEM_VXLAN_GPE_RSVD0,
1887 : : ITEM_VXLAN_GPE_RSVD1,
1888 : : ITEM_NEXT,
1889 : : ZERO,
1890 : : };
1891 : :
1892 : : static const enum index item_arp_eth_ipv4[] = {
1893 : : ITEM_ARP_ETH_IPV4_SHA,
1894 : : ITEM_ARP_ETH_IPV4_SPA,
1895 : : ITEM_ARP_ETH_IPV4_THA,
1896 : : ITEM_ARP_ETH_IPV4_TPA,
1897 : : ITEM_NEXT,
1898 : : ZERO,
1899 : : };
1900 : :
1901 : : static const enum index item_ipv6_ext[] = {
1902 : : ITEM_IPV6_EXT_NEXT_HDR,
1903 : : ITEM_NEXT,
1904 : : ZERO,
1905 : : };
1906 : :
1907 : : static const enum index item_ipv6_frag_ext[] = {
1908 : : ITEM_IPV6_FRAG_EXT_NEXT_HDR,
1909 : : ITEM_IPV6_FRAG_EXT_FRAG_DATA,
1910 : : ITEM_IPV6_FRAG_EXT_ID,
1911 : : ITEM_NEXT,
1912 : : ZERO,
1913 : : };
1914 : :
1915 : : static const enum index item_icmp6[] = {
1916 : : ITEM_ICMP6_TYPE,
1917 : : ITEM_ICMP6_CODE,
1918 : : ITEM_NEXT,
1919 : : ZERO,
1920 : : };
1921 : :
1922 : : static const enum index item_icmp6_echo_request[] = {
1923 : : ITEM_ICMP6_ECHO_REQUEST_ID,
1924 : : ITEM_ICMP6_ECHO_REQUEST_SEQ,
1925 : : ITEM_NEXT,
1926 : : ZERO,
1927 : : };
1928 : :
1929 : : static const enum index item_icmp6_echo_reply[] = {
1930 : : ITEM_ICMP6_ECHO_REPLY_ID,
1931 : : ITEM_ICMP6_ECHO_REPLY_SEQ,
1932 : : ITEM_NEXT,
1933 : : ZERO,
1934 : : };
1935 : :
1936 : : static const enum index item_icmp6_nd_ns[] = {
1937 : : ITEM_ICMP6_ND_NS_TARGET_ADDR,
1938 : : ITEM_NEXT,
1939 : : ZERO,
1940 : : };
1941 : :
1942 : : static const enum index item_icmp6_nd_na[] = {
1943 : : ITEM_ICMP6_ND_NA_TARGET_ADDR,
1944 : : ITEM_NEXT,
1945 : : ZERO,
1946 : : };
1947 : :
1948 : : static const enum index item_icmp6_nd_opt[] = {
1949 : : ITEM_ICMP6_ND_OPT_TYPE,
1950 : : ITEM_NEXT,
1951 : : ZERO,
1952 : : };
1953 : :
1954 : : static const enum index item_icmp6_nd_opt_sla_eth[] = {
1955 : : ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
1956 : : ITEM_NEXT,
1957 : : ZERO,
1958 : : };
1959 : :
1960 : : static const enum index item_icmp6_nd_opt_tla_eth[] = {
1961 : : ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
1962 : : ITEM_NEXT,
1963 : : ZERO,
1964 : : };
1965 : :
1966 : : static const enum index item_meta[] = {
1967 : : ITEM_META_DATA,
1968 : : ITEM_NEXT,
1969 : : ZERO,
1970 : : };
1971 : :
1972 : : static const enum index item_random[] = {
1973 : : ITEM_RANDOM_VALUE,
1974 : : ITEM_NEXT,
1975 : : ZERO,
1976 : : };
1977 : :
1978 : : static const enum index item_gtp_psc[] = {
1979 : : ITEM_GTP_PSC_QFI,
1980 : : ITEM_GTP_PSC_PDU_T,
1981 : : ITEM_NEXT,
1982 : : ZERO,
1983 : : };
1984 : :
1985 : : static const enum index item_pppoed[] = {
1986 : : ITEM_PPPOE_SEID,
1987 : : ITEM_NEXT,
1988 : : ZERO,
1989 : : };
1990 : :
1991 : : static const enum index item_pppoes[] = {
1992 : : ITEM_PPPOE_SEID,
1993 : : ITEM_NEXT,
1994 : : ZERO,
1995 : : };
1996 : :
1997 : : static const enum index item_pppoe_proto_id[] = {
1998 : : ITEM_NEXT,
1999 : : ZERO,
2000 : : };
2001 : :
2002 : : static const enum index item_higig2[] = {
2003 : : ITEM_HIGIG2_CLASSIFICATION,
2004 : : ITEM_HIGIG2_VID,
2005 : : ITEM_NEXT,
2006 : : ZERO,
2007 : : };
2008 : :
2009 : : static const enum index item_esp[] = {
2010 : : ITEM_ESP_SPI,
2011 : : ITEM_NEXT,
2012 : : ZERO,
2013 : : };
2014 : :
2015 : : static const enum index item_ah[] = {
2016 : : ITEM_AH_SPI,
2017 : : ITEM_NEXT,
2018 : : ZERO,
2019 : : };
2020 : :
2021 : : static const enum index item_pfcp[] = {
2022 : : ITEM_PFCP_S_FIELD,
2023 : : ITEM_PFCP_SEID,
2024 : : ITEM_NEXT,
2025 : : ZERO,
2026 : : };
2027 : :
2028 : : static const enum index next_set_raw[] = {
2029 : : SET_RAW_INDEX,
2030 : : ITEM_ETH,
2031 : : ZERO,
2032 : : };
2033 : :
2034 : : static const enum index item_tag[] = {
2035 : : ITEM_TAG_DATA,
2036 : : ITEM_TAG_INDEX,
2037 : : ITEM_NEXT,
2038 : : ZERO,
2039 : : };
2040 : :
2041 : : static const enum index item_l2tpv3oip[] = {
2042 : : ITEM_L2TPV3OIP_SESSION_ID,
2043 : : ITEM_NEXT,
2044 : : ZERO,
2045 : : };
2046 : :
2047 : : static const enum index item_ecpri[] = {
2048 : : ITEM_ECPRI_COMMON,
2049 : : ITEM_NEXT,
2050 : : ZERO,
2051 : : };
2052 : :
2053 : : static const enum index item_ecpri_common[] = {
2054 : : ITEM_ECPRI_COMMON_TYPE,
2055 : : ZERO,
2056 : : };
2057 : :
2058 : : static const enum index item_ecpri_common_type[] = {
2059 : : ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
2060 : : ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
2061 : : ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
2062 : : ZERO,
2063 : : };
2064 : :
2065 : : static const enum index item_geneve_opt[] = {
2066 : : ITEM_GENEVE_OPT_CLASS,
2067 : : ITEM_GENEVE_OPT_TYPE,
2068 : : ITEM_GENEVE_OPT_LENGTH,
2069 : : ITEM_GENEVE_OPT_DATA,
2070 : : ITEM_NEXT,
2071 : : ZERO,
2072 : : };
2073 : :
2074 : : static const enum index item_integrity[] = {
2075 : : ITEM_INTEGRITY_LEVEL,
2076 : : ITEM_INTEGRITY_VALUE,
2077 : : ZERO,
2078 : : };
2079 : :
2080 : : static const enum index item_integrity_lv[] = {
2081 : : ITEM_INTEGRITY_LEVEL,
2082 : : ITEM_INTEGRITY_VALUE,
2083 : : ITEM_NEXT,
2084 : : ZERO,
2085 : : };
2086 : :
2087 : : static const enum index item_port_representor[] = {
2088 : : ITEM_PORT_REPRESENTOR_PORT_ID,
2089 : : ITEM_NEXT,
2090 : : ZERO,
2091 : : };
2092 : :
2093 : : static const enum index item_represented_port[] = {
2094 : : ITEM_REPRESENTED_PORT_ETHDEV_PORT_ID,
2095 : : ITEM_NEXT,
2096 : : ZERO,
2097 : : };
2098 : :
2099 : : static const enum index item_flex[] = {
2100 : : ITEM_FLEX_PATTERN_HANDLE,
2101 : : ITEM_FLEX_ITEM_HANDLE,
2102 : : ITEM_NEXT,
2103 : : ZERO,
2104 : : };
2105 : :
2106 : : static const enum index item_l2tpv2[] = {
2107 : : ITEM_L2TPV2_TYPE,
2108 : : ITEM_NEXT,
2109 : : ZERO,
2110 : : };
2111 : :
2112 : : static const enum index item_l2tpv2_type[] = {
2113 : : ITEM_L2TPV2_TYPE_DATA,
2114 : : ITEM_L2TPV2_TYPE_DATA_L,
2115 : : ITEM_L2TPV2_TYPE_DATA_S,
2116 : : ITEM_L2TPV2_TYPE_DATA_O,
2117 : : ITEM_L2TPV2_TYPE_DATA_L_S,
2118 : : ITEM_L2TPV2_TYPE_CTRL,
2119 : : ZERO,
2120 : : };
2121 : :
2122 : : static const enum index item_l2tpv2_type_data[] = {
2123 : : ITEM_L2TPV2_MSG_DATA_TUNNEL_ID,
2124 : : ITEM_L2TPV2_MSG_DATA_SESSION_ID,
2125 : : ITEM_NEXT,
2126 : : ZERO,
2127 : : };
2128 : :
2129 : : static const enum index item_l2tpv2_type_data_l[] = {
2130 : : ITEM_L2TPV2_MSG_DATA_L_LENGTH,
2131 : : ITEM_L2TPV2_MSG_DATA_L_TUNNEL_ID,
2132 : : ITEM_L2TPV2_MSG_DATA_L_SESSION_ID,
2133 : : ITEM_NEXT,
2134 : : ZERO,
2135 : : };
2136 : :
2137 : : static const enum index item_l2tpv2_type_data_s[] = {
2138 : : ITEM_L2TPV2_MSG_DATA_S_TUNNEL_ID,
2139 : : ITEM_L2TPV2_MSG_DATA_S_SESSION_ID,
2140 : : ITEM_L2TPV2_MSG_DATA_S_NS,
2141 : : ITEM_L2TPV2_MSG_DATA_S_NR,
2142 : : ITEM_NEXT,
2143 : : ZERO,
2144 : : };
2145 : :
2146 : : static const enum index item_l2tpv2_type_data_o[] = {
2147 : : ITEM_L2TPV2_MSG_DATA_O_TUNNEL_ID,
2148 : : ITEM_L2TPV2_MSG_DATA_O_SESSION_ID,
2149 : : ITEM_L2TPV2_MSG_DATA_O_OFFSET,
2150 : : ITEM_NEXT,
2151 : : ZERO,
2152 : : };
2153 : :
2154 : : static const enum index item_l2tpv2_type_data_l_s[] = {
2155 : : ITEM_L2TPV2_MSG_DATA_L_S_LENGTH,
2156 : : ITEM_L2TPV2_MSG_DATA_L_S_TUNNEL_ID,
2157 : : ITEM_L2TPV2_MSG_DATA_L_S_SESSION_ID,
2158 : : ITEM_L2TPV2_MSG_DATA_L_S_NS,
2159 : : ITEM_L2TPV2_MSG_DATA_L_S_NR,
2160 : : ITEM_NEXT,
2161 : : ZERO,
2162 : : };
2163 : :
2164 : : static const enum index item_l2tpv2_type_ctrl[] = {
2165 : : ITEM_L2TPV2_MSG_CTRL_LENGTH,
2166 : : ITEM_L2TPV2_MSG_CTRL_TUNNEL_ID,
2167 : : ITEM_L2TPV2_MSG_CTRL_SESSION_ID,
2168 : : ITEM_L2TPV2_MSG_CTRL_NS,
2169 : : ITEM_L2TPV2_MSG_CTRL_NR,
2170 : : ITEM_NEXT,
2171 : : ZERO,
2172 : : };
2173 : :
2174 : : static const enum index item_ppp[] = {
2175 : : ITEM_PPP_ADDR,
2176 : : ITEM_PPP_CTRL,
2177 : : ITEM_PPP_PROTO_ID,
2178 : : ITEM_NEXT,
2179 : : ZERO,
2180 : : };
2181 : :
2182 : : static const enum index item_meter[] = {
2183 : : ITEM_METER_COLOR,
2184 : : ITEM_NEXT,
2185 : : ZERO,
2186 : : };
2187 : :
2188 : : static const enum index item_quota[] = {
2189 : : ITEM_QUOTA_STATE,
2190 : : ITEM_NEXT,
2191 : : ZERO,
2192 : : };
2193 : :
2194 : : static const enum index item_aggr_affinity[] = {
2195 : : ITEM_AGGR_AFFINITY_VALUE,
2196 : : ITEM_NEXT,
2197 : : ZERO,
2198 : : };
2199 : :
2200 : : static const enum index item_tx_queue[] = {
2201 : : ITEM_TX_QUEUE_VALUE,
2202 : : ITEM_NEXT,
2203 : : ZERO,
2204 : : };
2205 : :
2206 : : static const enum index item_ib_bth[] = {
2207 : : ITEM_IB_BTH_OPCODE,
2208 : : ITEM_IB_BTH_PKEY,
2209 : : ITEM_IB_BTH_DST_QPN,
2210 : : ITEM_IB_BTH_PSN,
2211 : : ITEM_NEXT,
2212 : : ZERO,
2213 : : };
2214 : :
2215 : : static const enum index item_ptype[] = {
2216 : : ITEM_PTYPE_VALUE,
2217 : : ITEM_NEXT,
2218 : : ZERO,
2219 : : };
2220 : :
2221 : : static const enum index item_nsh[] = {
2222 : : ITEM_NEXT,
2223 : : ZERO,
2224 : : };
2225 : :
2226 : : static const enum index item_compare_field[] = {
2227 : : ITEM_COMPARE_OP,
2228 : : ITEM_COMPARE_FIELD_A_TYPE,
2229 : : ITEM_COMPARE_FIELD_B_TYPE,
2230 : : ITEM_NEXT,
2231 : : ZERO,
2232 : : };
2233 : :
2234 : : static const enum index compare_field_a[] = {
2235 : : ITEM_COMPARE_FIELD_A_TYPE,
2236 : : ITEM_COMPARE_FIELD_A_LEVEL,
2237 : : ITEM_COMPARE_FIELD_A_TAG_INDEX,
2238 : : ITEM_COMPARE_FIELD_A_TYPE_ID,
2239 : : ITEM_COMPARE_FIELD_A_CLASS_ID,
2240 : : ITEM_COMPARE_FIELD_A_OFFSET,
2241 : : ITEM_COMPARE_FIELD_B_TYPE,
2242 : : ZERO,
2243 : : };
2244 : :
2245 : : static const enum index compare_field_b[] = {
2246 : : ITEM_COMPARE_FIELD_B_TYPE,
2247 : : ITEM_COMPARE_FIELD_B_LEVEL,
2248 : : ITEM_COMPARE_FIELD_B_TAG_INDEX,
2249 : : ITEM_COMPARE_FIELD_B_TYPE_ID,
2250 : : ITEM_COMPARE_FIELD_B_CLASS_ID,
2251 : : ITEM_COMPARE_FIELD_B_OFFSET,
2252 : : ITEM_COMPARE_FIELD_B_VALUE,
2253 : : ITEM_COMPARE_FIELD_B_POINTER,
2254 : : ITEM_COMPARE_FIELD_WIDTH,
2255 : : ZERO,
2256 : : };
2257 : :
2258 : : static const enum index next_action[] = {
2259 : : ACTION_END,
2260 : : ACTION_VOID,
2261 : : ACTION_PASSTHRU,
2262 : : ACTION_SKIP_CMAN,
2263 : : ACTION_JUMP,
2264 : : ACTION_MARK,
2265 : : ACTION_FLAG,
2266 : : ACTION_QUEUE,
2267 : : ACTION_DROP,
2268 : : ACTION_COUNT,
2269 : : ACTION_RSS,
2270 : : ACTION_PF,
2271 : : ACTION_VF,
2272 : : ACTION_PORT_ID,
2273 : : ACTION_METER,
2274 : : ACTION_METER_COLOR,
2275 : : ACTION_METER_MARK,
2276 : : ACTION_METER_MARK_CONF,
2277 : : ACTION_OF_DEC_NW_TTL,
2278 : : ACTION_OF_POP_VLAN,
2279 : : ACTION_OF_PUSH_VLAN,
2280 : : ACTION_OF_SET_VLAN_VID,
2281 : : ACTION_OF_SET_VLAN_PCP,
2282 : : ACTION_OF_POP_MPLS,
2283 : : ACTION_OF_PUSH_MPLS,
2284 : : ACTION_VXLAN_ENCAP,
2285 : : ACTION_VXLAN_DECAP,
2286 : : ACTION_NVGRE_ENCAP,
2287 : : ACTION_NVGRE_DECAP,
2288 : : ACTION_L2_ENCAP,
2289 : : ACTION_L2_DECAP,
2290 : : ACTION_MPLSOGRE_ENCAP,
2291 : : ACTION_MPLSOGRE_DECAP,
2292 : : ACTION_MPLSOUDP_ENCAP,
2293 : : ACTION_MPLSOUDP_DECAP,
2294 : : ACTION_SET_IPV4_SRC,
2295 : : ACTION_SET_IPV4_DST,
2296 : : ACTION_SET_IPV6_SRC,
2297 : : ACTION_SET_IPV6_DST,
2298 : : ACTION_SET_TP_SRC,
2299 : : ACTION_SET_TP_DST,
2300 : : ACTION_MAC_SWAP,
2301 : : ACTION_DEC_TTL,
2302 : : ACTION_SET_TTL,
2303 : : ACTION_SET_MAC_SRC,
2304 : : ACTION_SET_MAC_DST,
2305 : : ACTION_INC_TCP_SEQ,
2306 : : ACTION_DEC_TCP_SEQ,
2307 : : ACTION_INC_TCP_ACK,
2308 : : ACTION_DEC_TCP_ACK,
2309 : : ACTION_RAW_ENCAP,
2310 : : ACTION_RAW_DECAP,
2311 : : ACTION_SET_TAG,
2312 : : ACTION_SET_META,
2313 : : ACTION_SET_IPV4_DSCP,
2314 : : ACTION_SET_IPV6_DSCP,
2315 : : ACTION_AGE,
2316 : : ACTION_AGE_UPDATE,
2317 : : ACTION_SAMPLE,
2318 : : ACTION_INDIRECT,
2319 : : ACTION_INDIRECT_LIST,
2320 : : ACTION_SHARED_INDIRECT,
2321 : : ACTION_MODIFY_FIELD,
2322 : : ACTION_CONNTRACK,
2323 : : ACTION_CONNTRACK_UPDATE,
2324 : : ACTION_PORT_REPRESENTOR,
2325 : : ACTION_REPRESENTED_PORT,
2326 : : ACTION_SEND_TO_KERNEL,
2327 : : ACTION_QUOTA_CREATE,
2328 : : ACTION_QUOTA_QU,
2329 : : ACTION_IPV6_EXT_REMOVE,
2330 : : ACTION_IPV6_EXT_PUSH,
2331 : : ACTION_NAT64,
2332 : : ACTION_JUMP_TO_TABLE_INDEX,
2333 : : ZERO,
2334 : : };
2335 : :
2336 : : static const enum index action_quota_create[] = {
2337 : : ACTION_QUOTA_CREATE_LIMIT,
2338 : : ACTION_QUOTA_CREATE_MODE,
2339 : : ACTION_NEXT,
2340 : : ZERO
2341 : : };
2342 : :
2343 : : static const enum index action_quota_update[] = {
2344 : : ACTION_QUOTA_QU_LIMIT,
2345 : : ACTION_QUOTA_QU_UPDATE_OP,
2346 : : ACTION_NEXT,
2347 : : ZERO
2348 : : };
2349 : :
2350 : : static const enum index action_mark[] = {
2351 : : ACTION_MARK_ID,
2352 : : ACTION_NEXT,
2353 : : ZERO,
2354 : : };
2355 : :
2356 : : static const enum index action_queue[] = {
2357 : : ACTION_QUEUE_INDEX,
2358 : : ACTION_NEXT,
2359 : : ZERO,
2360 : : };
2361 : :
2362 : : static const enum index action_count[] = {
2363 : : ACTION_COUNT_ID,
2364 : : ACTION_NEXT,
2365 : : ZERO,
2366 : : };
2367 : :
2368 : : static const enum index action_rss[] = {
2369 : : ACTION_RSS_FUNC,
2370 : : ACTION_RSS_LEVEL,
2371 : : ACTION_RSS_TYPES,
2372 : : ACTION_RSS_KEY,
2373 : : ACTION_RSS_KEY_LEN,
2374 : : ACTION_RSS_QUEUES,
2375 : : ACTION_NEXT,
2376 : : ZERO,
2377 : : };
2378 : :
2379 : : static const enum index action_vf[] = {
2380 : : ACTION_VF_ORIGINAL,
2381 : : ACTION_VF_ID,
2382 : : ACTION_NEXT,
2383 : : ZERO,
2384 : : };
2385 : :
2386 : : static const enum index action_port_id[] = {
2387 : : ACTION_PORT_ID_ORIGINAL,
2388 : : ACTION_PORT_ID_ID,
2389 : : ACTION_NEXT,
2390 : : ZERO,
2391 : : };
2392 : :
2393 : : static const enum index action_meter[] = {
2394 : : ACTION_METER_ID,
2395 : : ACTION_NEXT,
2396 : : ZERO,
2397 : : };
2398 : :
2399 : : static const enum index action_meter_color[] = {
2400 : : ACTION_METER_COLOR_TYPE,
2401 : : ACTION_NEXT,
2402 : : ZERO,
2403 : : };
2404 : :
2405 : : static const enum index action_meter_mark[] = {
2406 : : ACTION_METER_PROFILE,
2407 : : ACTION_METER_POLICY,
2408 : : ACTION_METER_COLOR_MODE,
2409 : : ACTION_METER_STATE,
2410 : : ACTION_NEXT,
2411 : : ZERO,
2412 : : };
2413 : :
2414 : : static const enum index action_of_push_vlan[] = {
2415 : : ACTION_OF_PUSH_VLAN_ETHERTYPE,
2416 : : ACTION_NEXT,
2417 : : ZERO,
2418 : : };
2419 : :
2420 : : static const enum index action_of_set_vlan_vid[] = {
2421 : : ACTION_OF_SET_VLAN_VID_VLAN_VID,
2422 : : ACTION_NEXT,
2423 : : ZERO,
2424 : : };
2425 : :
2426 : : static const enum index action_of_set_vlan_pcp[] = {
2427 : : ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
2428 : : ACTION_NEXT,
2429 : : ZERO,
2430 : : };
2431 : :
2432 : : static const enum index action_of_pop_mpls[] = {
2433 : : ACTION_OF_POP_MPLS_ETHERTYPE,
2434 : : ACTION_NEXT,
2435 : : ZERO,
2436 : : };
2437 : :
2438 : : static const enum index action_of_push_mpls[] = {
2439 : : ACTION_OF_PUSH_MPLS_ETHERTYPE,
2440 : : ACTION_NEXT,
2441 : : ZERO,
2442 : : };
2443 : :
2444 : : static const enum index action_set_ipv4_src[] = {
2445 : : ACTION_SET_IPV4_SRC_IPV4_SRC,
2446 : : ACTION_NEXT,
2447 : : ZERO,
2448 : : };
2449 : :
2450 : : static const enum index action_set_mac_src[] = {
2451 : : ACTION_SET_MAC_SRC_MAC_SRC,
2452 : : ACTION_NEXT,
2453 : : ZERO,
2454 : : };
2455 : :
2456 : : static const enum index action_set_ipv4_dst[] = {
2457 : : ACTION_SET_IPV4_DST_IPV4_DST,
2458 : : ACTION_NEXT,
2459 : : ZERO,
2460 : : };
2461 : :
2462 : : static const enum index action_set_ipv6_src[] = {
2463 : : ACTION_SET_IPV6_SRC_IPV6_SRC,
2464 : : ACTION_NEXT,
2465 : : ZERO,
2466 : : };
2467 : :
2468 : : static const enum index action_set_ipv6_dst[] = {
2469 : : ACTION_SET_IPV6_DST_IPV6_DST,
2470 : : ACTION_NEXT,
2471 : : ZERO,
2472 : : };
2473 : :
2474 : : static const enum index action_set_tp_src[] = {
2475 : : ACTION_SET_TP_SRC_TP_SRC,
2476 : : ACTION_NEXT,
2477 : : ZERO,
2478 : : };
2479 : :
2480 : : static const enum index action_set_tp_dst[] = {
2481 : : ACTION_SET_TP_DST_TP_DST,
2482 : : ACTION_NEXT,
2483 : : ZERO,
2484 : : };
2485 : :
2486 : : static const enum index action_set_ttl[] = {
2487 : : ACTION_SET_TTL_TTL,
2488 : : ACTION_NEXT,
2489 : : ZERO,
2490 : : };
2491 : :
2492 : : static const enum index action_jump[] = {
2493 : : ACTION_JUMP_GROUP,
2494 : : ACTION_NEXT,
2495 : : ZERO,
2496 : : };
2497 : :
2498 : : static const enum index action_set_mac_dst[] = {
2499 : : ACTION_SET_MAC_DST_MAC_DST,
2500 : : ACTION_NEXT,
2501 : : ZERO,
2502 : : };
2503 : :
2504 : : static const enum index action_inc_tcp_seq[] = {
2505 : : ACTION_INC_TCP_SEQ_VALUE,
2506 : : ACTION_NEXT,
2507 : : ZERO,
2508 : : };
2509 : :
2510 : : static const enum index action_dec_tcp_seq[] = {
2511 : : ACTION_DEC_TCP_SEQ_VALUE,
2512 : : ACTION_NEXT,
2513 : : ZERO,
2514 : : };
2515 : :
2516 : : static const enum index action_inc_tcp_ack[] = {
2517 : : ACTION_INC_TCP_ACK_VALUE,
2518 : : ACTION_NEXT,
2519 : : ZERO,
2520 : : };
2521 : :
2522 : : static const enum index action_dec_tcp_ack[] = {
2523 : : ACTION_DEC_TCP_ACK_VALUE,
2524 : : ACTION_NEXT,
2525 : : ZERO,
2526 : : };
2527 : :
2528 : : static const enum index action_raw_encap[] = {
2529 : : ACTION_RAW_ENCAP_SIZE,
2530 : : ACTION_RAW_ENCAP_INDEX,
2531 : : ACTION_NEXT,
2532 : : ZERO,
2533 : : };
2534 : :
2535 : : static const enum index action_raw_decap[] = {
2536 : : ACTION_RAW_DECAP_INDEX,
2537 : : ACTION_NEXT,
2538 : : ZERO,
2539 : : };
2540 : :
2541 : : static const enum index action_ipv6_ext_remove[] = {
2542 : : ACTION_IPV6_EXT_REMOVE_INDEX,
2543 : : ACTION_NEXT,
2544 : : ZERO,
2545 : : };
2546 : :
2547 : : static const enum index action_ipv6_ext_push[] = {
2548 : : ACTION_IPV6_EXT_PUSH_INDEX,
2549 : : ACTION_NEXT,
2550 : : ZERO,
2551 : : };
2552 : :
2553 : : static const enum index action_set_tag[] = {
2554 : : ACTION_SET_TAG_DATA,
2555 : : ACTION_SET_TAG_INDEX,
2556 : : ACTION_SET_TAG_MASK,
2557 : : ACTION_NEXT,
2558 : : ZERO,
2559 : : };
2560 : :
2561 : : static const enum index action_set_meta[] = {
2562 : : ACTION_SET_META_DATA,
2563 : : ACTION_SET_META_MASK,
2564 : : ACTION_NEXT,
2565 : : ZERO,
2566 : : };
2567 : :
2568 : : static const enum index action_set_ipv4_dscp[] = {
2569 : : ACTION_SET_IPV4_DSCP_VALUE,
2570 : : ACTION_NEXT,
2571 : : ZERO,
2572 : : };
2573 : :
2574 : : static const enum index action_set_ipv6_dscp[] = {
2575 : : ACTION_SET_IPV6_DSCP_VALUE,
2576 : : ACTION_NEXT,
2577 : : ZERO,
2578 : : };
2579 : :
2580 : : static const enum index action_age[] = {
2581 : : ACTION_AGE,
2582 : : ACTION_AGE_TIMEOUT,
2583 : : ACTION_NEXT,
2584 : : ZERO,
2585 : : };
2586 : :
2587 : : static const enum index action_age_update[] = {
2588 : : ACTION_AGE_UPDATE,
2589 : : ACTION_AGE_UPDATE_TIMEOUT,
2590 : : ACTION_AGE_UPDATE_TOUCH,
2591 : : ACTION_NEXT,
2592 : : ZERO,
2593 : : };
2594 : :
2595 : : static const enum index action_sample[] = {
2596 : : ACTION_SAMPLE,
2597 : : ACTION_SAMPLE_RATIO,
2598 : : ACTION_SAMPLE_INDEX,
2599 : : ACTION_NEXT,
2600 : : ZERO,
2601 : : };
2602 : :
2603 : : static const enum index next_action_sample[] = {
2604 : : ACTION_QUEUE,
2605 : : ACTION_RSS,
2606 : : ACTION_MARK,
2607 : : ACTION_COUNT,
2608 : : ACTION_PORT_ID,
2609 : : ACTION_RAW_ENCAP,
2610 : : ACTION_VXLAN_ENCAP,
2611 : : ACTION_NVGRE_ENCAP,
2612 : : ACTION_REPRESENTED_PORT,
2613 : : ACTION_PORT_REPRESENTOR,
2614 : : ACTION_NEXT,
2615 : : ZERO,
2616 : : };
2617 : :
2618 : : static const enum index item_ipv6_push_ext[] = {
2619 : : ITEM_IPV6_PUSH_REMOVE_EXT,
2620 : : ZERO,
2621 : : };
2622 : :
2623 : : static const enum index item_ipv6_push_ext_type[] = {
2624 : : ITEM_IPV6_PUSH_REMOVE_EXT_TYPE,
2625 : : ZERO,
2626 : : };
2627 : :
2628 : : static const enum index item_ipv6_push_ext_header[] = {
2629 : : ITEM_IPV6_ROUTING_EXT,
2630 : : ITEM_NEXT,
2631 : : ZERO,
2632 : : };
2633 : :
2634 : : static const enum index action_modify_field_dst[] = {
2635 : : ACTION_MODIFY_FIELD_DST_LEVEL,
2636 : : ACTION_MODIFY_FIELD_DST_TAG_INDEX,
2637 : : ACTION_MODIFY_FIELD_DST_TYPE_ID,
2638 : : ACTION_MODIFY_FIELD_DST_CLASS_ID,
2639 : : ACTION_MODIFY_FIELD_DST_OFFSET,
2640 : : ACTION_MODIFY_FIELD_SRC_TYPE,
2641 : : ZERO,
2642 : : };
2643 : :
2644 : : static const enum index action_modify_field_src[] = {
2645 : : ACTION_MODIFY_FIELD_SRC_LEVEL,
2646 : : ACTION_MODIFY_FIELD_SRC_TAG_INDEX,
2647 : : ACTION_MODIFY_FIELD_SRC_TYPE_ID,
2648 : : ACTION_MODIFY_FIELD_SRC_CLASS_ID,
2649 : : ACTION_MODIFY_FIELD_SRC_OFFSET,
2650 : : ACTION_MODIFY_FIELD_SRC_VALUE,
2651 : : ACTION_MODIFY_FIELD_SRC_POINTER,
2652 : : ACTION_MODIFY_FIELD_WIDTH,
2653 : : ZERO,
2654 : : };
2655 : :
2656 : : static const enum index action_update_conntrack[] = {
2657 : : ACTION_CONNTRACK_UPDATE_DIR,
2658 : : ACTION_CONNTRACK_UPDATE_CTX,
2659 : : ACTION_NEXT,
2660 : : ZERO,
2661 : : };
2662 : :
2663 : : static const enum index action_port_representor[] = {
2664 : : ACTION_PORT_REPRESENTOR_PORT_ID,
2665 : : ACTION_NEXT,
2666 : : ZERO,
2667 : : };
2668 : :
2669 : : static const enum index action_represented_port[] = {
2670 : : ACTION_REPRESENTED_PORT_ETHDEV_PORT_ID,
2671 : : ACTION_NEXT,
2672 : : ZERO,
2673 : : };
2674 : :
2675 : : static const enum index action_nat64[] = {
2676 : : ACTION_NAT64_MODE,
2677 : : ACTION_NEXT,
2678 : : ZERO,
2679 : : };
2680 : :
2681 : : static const enum index next_hash_subcmd[] = {
2682 : : HASH_CALC_TABLE,
2683 : : HASH_CALC_ENCAP,
2684 : : ZERO,
2685 : : };
2686 : :
2687 : : static const enum index next_hash_encap_dest_subcmd[] = {
2688 : : ENCAP_HASH_FIELD_SRC_PORT,
2689 : : ENCAP_HASH_FIELD_GRE_FLOW_ID,
2690 : : ZERO,
2691 : : };
2692 : :
2693 : : static const enum index action_jump_to_table_index[] = {
2694 : : ACTION_JUMP_TO_TABLE_INDEX_TABLE,
2695 : : ACTION_JUMP_TO_TABLE_INDEX_INDEX,
2696 : : ACTION_NEXT,
2697 : : ZERO,
2698 : : };
2699 : :
2700 : : static int parse_set_raw_encap_decap(struct context *, const struct token *,
2701 : : const char *, unsigned int,
2702 : : void *, unsigned int);
2703 : : static int parse_set_sample_action(struct context *, const struct token *,
2704 : : const char *, unsigned int,
2705 : : void *, unsigned int);
2706 : : static int parse_set_ipv6_ext_action(struct context *, const struct token *,
2707 : : const char *, unsigned int,
2708 : : void *, unsigned int);
2709 : : static int parse_set_init(struct context *, const struct token *,
2710 : : const char *, unsigned int,
2711 : : void *, unsigned int);
2712 : : static int
2713 : : parse_flex_handle(struct context *, const struct token *,
2714 : : const char *, unsigned int, void *, unsigned int);
2715 : : static int parse_init(struct context *, const struct token *,
2716 : : const char *, unsigned int,
2717 : : void *, unsigned int);
2718 : : static int parse_vc(struct context *, const struct token *,
2719 : : const char *, unsigned int,
2720 : : void *, unsigned int);
2721 : : static int parse_vc_spec(struct context *, const struct token *,
2722 : : const char *, unsigned int, void *, unsigned int);
2723 : : static int parse_vc_conf(struct context *, const struct token *,
2724 : : const char *, unsigned int, void *, unsigned int);
2725 : : static int parse_vc_conf_timeout(struct context *, const struct token *,
2726 : : const char *, unsigned int, void *,
2727 : : unsigned int);
2728 : : static int parse_vc_item_ecpri_type(struct context *, const struct token *,
2729 : : const char *, unsigned int,
2730 : : void *, unsigned int);
2731 : : static int parse_vc_item_l2tpv2_type(struct context *, const struct token *,
2732 : : const char *, unsigned int,
2733 : : void *, unsigned int);
2734 : : static int parse_vc_action_meter_color_type(struct context *,
2735 : : const struct token *,
2736 : : const char *, unsigned int, void *,
2737 : : unsigned int);
2738 : : static int parse_vc_action_rss(struct context *, const struct token *,
2739 : : const char *, unsigned int, void *,
2740 : : unsigned int);
2741 : : static int parse_vc_action_rss_func(struct context *, const struct token *,
2742 : : const char *, unsigned int, void *,
2743 : : unsigned int);
2744 : : static int parse_vc_action_rss_type(struct context *, const struct token *,
2745 : : const char *, unsigned int, void *,
2746 : : unsigned int);
2747 : : static int parse_vc_action_rss_queue(struct context *, const struct token *,
2748 : : const char *, unsigned int, void *,
2749 : : unsigned int);
2750 : : static int parse_vc_action_vxlan_encap(struct context *, const struct token *,
2751 : : const char *, unsigned int, void *,
2752 : : unsigned int);
2753 : : static int parse_vc_action_nvgre_encap(struct context *, const struct token *,
2754 : : const char *, unsigned int, void *,
2755 : : unsigned int);
2756 : : static int parse_vc_action_l2_encap(struct context *, const struct token *,
2757 : : const char *, unsigned int, void *,
2758 : : unsigned int);
2759 : : static int parse_vc_action_l2_decap(struct context *, const struct token *,
2760 : : const char *, unsigned int, void *,
2761 : : unsigned int);
2762 : : static int parse_vc_action_mplsogre_encap(struct context *,
2763 : : const struct token *, const char *,
2764 : : unsigned int, void *, unsigned int);
2765 : : static int parse_vc_action_mplsogre_decap(struct context *,
2766 : : const struct token *, const char *,
2767 : : unsigned int, void *, unsigned int);
2768 : : static int parse_vc_action_mplsoudp_encap(struct context *,
2769 : : const struct token *, const char *,
2770 : : unsigned int, void *, unsigned int);
2771 : : static int parse_vc_action_mplsoudp_decap(struct context *,
2772 : : const struct token *, const char *,
2773 : : unsigned int, void *, unsigned int);
2774 : : static int parse_vc_action_raw_encap(struct context *,
2775 : : const struct token *, const char *,
2776 : : unsigned int, void *, unsigned int);
2777 : : static int parse_vc_action_raw_decap(struct context *,
2778 : : const struct token *, const char *,
2779 : : unsigned int, void *, unsigned int);
2780 : : static int parse_vc_action_raw_encap_index(struct context *,
2781 : : const struct token *, const char *,
2782 : : unsigned int, void *, unsigned int);
2783 : : static int parse_vc_action_raw_decap_index(struct context *,
2784 : : const struct token *, const char *,
2785 : : unsigned int, void *, unsigned int);
2786 : : static int parse_vc_action_ipv6_ext_remove(struct context *ctx, const struct token *token,
2787 : : const char *str, unsigned int len, void *buf,
2788 : : unsigned int size);
2789 : : static int parse_vc_action_ipv6_ext_remove_index(struct context *ctx,
2790 : : const struct token *token,
2791 : : const char *str, unsigned int len,
2792 : : void *buf,
2793 : : unsigned int size);
2794 : : static int parse_vc_action_ipv6_ext_push(struct context *ctx, const struct token *token,
2795 : : const char *str, unsigned int len, void *buf,
2796 : : unsigned int size);
2797 : : static int parse_vc_action_ipv6_ext_push_index(struct context *ctx,
2798 : : const struct token *token,
2799 : : const char *str, unsigned int len,
2800 : : void *buf,
2801 : : unsigned int size);
2802 : : static int parse_vc_action_set_meta(struct context *ctx,
2803 : : const struct token *token, const char *str,
2804 : : unsigned int len, void *buf,
2805 : : unsigned int size);
2806 : : static int parse_vc_action_sample(struct context *ctx,
2807 : : const struct token *token, const char *str,
2808 : : unsigned int len, void *buf,
2809 : : unsigned int size);
2810 : : static int
2811 : : parse_vc_action_sample_index(struct context *ctx, const struct token *token,
2812 : : const char *str, unsigned int len, void *buf,
2813 : : unsigned int size);
2814 : : static int
2815 : : parse_vc_modify_field_op(struct context *ctx, const struct token *token,
2816 : : const char *str, unsigned int len, void *buf,
2817 : : unsigned int size);
2818 : : static int
2819 : : parse_vc_modify_field_id(struct context *ctx, const struct token *token,
2820 : : const char *str, unsigned int len, void *buf,
2821 : : unsigned int size);
2822 : : static int
2823 : : parse_vc_modify_field_level(struct context *ctx, const struct token *token,
2824 : : const char *str, unsigned int len, void *buf,
2825 : : unsigned int size);
2826 : : static int
2827 : : parse_vc_action_conntrack_update(struct context *ctx, const struct token *token,
2828 : : const char *str, unsigned int len, void *buf,
2829 : : unsigned int size);
2830 : : static int parse_destroy(struct context *, const struct token *,
2831 : : const char *, unsigned int,
2832 : : void *, unsigned int);
2833 : : static int parse_flush(struct context *, const struct token *,
2834 : : const char *, unsigned int,
2835 : : void *, unsigned int);
2836 : : static int parse_dump(struct context *, const struct token *,
2837 : : const char *, unsigned int,
2838 : : void *, unsigned int);
2839 : : static int parse_query(struct context *, const struct token *,
2840 : : const char *, unsigned int,
2841 : : void *, unsigned int);
2842 : : static int parse_action(struct context *, const struct token *,
2843 : : const char *, unsigned int,
2844 : : void *, unsigned int);
2845 : : static int parse_list(struct context *, const struct token *,
2846 : : const char *, unsigned int,
2847 : : void *, unsigned int);
2848 : : static int parse_aged(struct context *, const struct token *,
2849 : : const char *, unsigned int,
2850 : : void *, unsigned int);
2851 : : static int parse_isolate(struct context *, const struct token *,
2852 : : const char *, unsigned int,
2853 : : void *, unsigned int);
2854 : : static int parse_configure(struct context *, const struct token *,
2855 : : const char *, unsigned int,
2856 : : void *, unsigned int);
2857 : : static int parse_template(struct context *, const struct token *,
2858 : : const char *, unsigned int,
2859 : : void *, unsigned int);
2860 : : static int parse_template_destroy(struct context *, const struct token *,
2861 : : const char *, unsigned int,
2862 : : void *, unsigned int);
2863 : : static int parse_table(struct context *, const struct token *,
2864 : : const char *, unsigned int, void *, unsigned int);
2865 : : static int parse_table_destroy(struct context *, const struct token *,
2866 : : const char *, unsigned int,
2867 : : void *, unsigned int);
2868 : : static int parse_jump_table_id(struct context *, const struct token *,
2869 : : const char *, unsigned int,
2870 : : void *, unsigned int);
2871 : : static int parse_qo(struct context *, const struct token *,
2872 : : const char *, unsigned int,
2873 : : void *, unsigned int);
2874 : : static int parse_qo_destroy(struct context *, const struct token *,
2875 : : const char *, unsigned int,
2876 : : void *, unsigned int);
2877 : : static int parse_qia(struct context *, const struct token *,
2878 : : const char *, unsigned int,
2879 : : void *, unsigned int);
2880 : : static int parse_qia_destroy(struct context *, const struct token *,
2881 : : const char *, unsigned int,
2882 : : void *, unsigned int);
2883 : : static int parse_push(struct context *, const struct token *,
2884 : : const char *, unsigned int,
2885 : : void *, unsigned int);
2886 : : static int parse_pull(struct context *, const struct token *,
2887 : : const char *, unsigned int,
2888 : : void *, unsigned int);
2889 : : static int parse_group(struct context *, const struct token *,
2890 : : const char *, unsigned int,
2891 : : void *, unsigned int);
2892 : : static int parse_hash(struct context *, const struct token *,
2893 : : const char *, unsigned int,
2894 : : void *, unsigned int);
2895 : : static int parse_tunnel(struct context *, const struct token *,
2896 : : const char *, unsigned int,
2897 : : void *, unsigned int);
2898 : : static int parse_flex(struct context *, const struct token *,
2899 : : const char *, unsigned int, void *, unsigned int);
2900 : : static int parse_int(struct context *, const struct token *,
2901 : : const char *, unsigned int,
2902 : : void *, unsigned int);
2903 : : static int parse_prefix(struct context *, const struct token *,
2904 : : const char *, unsigned int,
2905 : : void *, unsigned int);
2906 : : static int parse_boolean(struct context *, const struct token *,
2907 : : const char *, unsigned int,
2908 : : void *, unsigned int);
2909 : : static int parse_string(struct context *, const struct token *,
2910 : : const char *, unsigned int,
2911 : : void *, unsigned int);
2912 : : static int parse_hex(struct context *ctx, const struct token *token,
2913 : : const char *str, unsigned int len,
2914 : : void *buf, unsigned int size);
2915 : : static int parse_string0(struct context *, const struct token *,
2916 : : const char *, unsigned int,
2917 : : void *, unsigned int);
2918 : : static int parse_mac_addr(struct context *, const struct token *,
2919 : : const char *, unsigned int,
2920 : : void *, unsigned int);
2921 : : static int parse_ipv4_addr(struct context *, const struct token *,
2922 : : const char *, unsigned int,
2923 : : void *, unsigned int);
2924 : : static int parse_ipv6_addr(struct context *, const struct token *,
2925 : : const char *, unsigned int,
2926 : : void *, unsigned int);
2927 : : static int parse_port(struct context *, const struct token *,
2928 : : const char *, unsigned int,
2929 : : void *, unsigned int);
2930 : : static int parse_ia(struct context *, const struct token *,
2931 : : const char *, unsigned int,
2932 : : void *, unsigned int);
2933 : : static int parse_ia_destroy(struct context *ctx, const struct token *token,
2934 : : const char *str, unsigned int len,
2935 : : void *buf, unsigned int size);
2936 : : static int parse_ia_id2ptr(struct context *ctx, const struct token *token,
2937 : : const char *str, unsigned int len, void *buf,
2938 : : unsigned int size);
2939 : :
2940 : : static int parse_indlst_id2ptr(struct context *ctx, const struct token *token,
2941 : : const char *str, unsigned int len, void *buf,
2942 : : unsigned int size);
2943 : : static int parse_ia_port(struct context *ctx, const struct token *token,
2944 : : const char *str, unsigned int len, void *buf,
2945 : : unsigned int size);
2946 : : static int parse_mp(struct context *, const struct token *,
2947 : : const char *, unsigned int,
2948 : : void *, unsigned int);
2949 : : static int parse_meter_profile_id2ptr(struct context *ctx,
2950 : : const struct token *token,
2951 : : const char *str, unsigned int len,
2952 : : void *buf, unsigned int size);
2953 : : static int parse_meter_policy_id2ptr(struct context *ctx,
2954 : : const struct token *token,
2955 : : const char *str, unsigned int len,
2956 : : void *buf, unsigned int size);
2957 : : static int parse_meter_color(struct context *ctx, const struct token *token,
2958 : : const char *str, unsigned int len, void *buf,
2959 : : unsigned int size);
2960 : : static int parse_insertion_table_type(struct context *ctx, const struct token *token,
2961 : : const char *str, unsigned int len, void *buf,
2962 : : unsigned int size);
2963 : : static int parse_hash_table_type(struct context *ctx, const struct token *token,
2964 : : const char *str, unsigned int len, void *buf,
2965 : : unsigned int size);
2966 : : static int
2967 : : parse_quota_state_name(struct context *ctx, const struct token *token,
2968 : : const char *str, unsigned int len, void *buf,
2969 : : unsigned int size);
2970 : : static int
2971 : : parse_quota_mode_name(struct context *ctx, const struct token *token,
2972 : : const char *str, unsigned int len, void *buf,
2973 : : unsigned int size);
2974 : : static int
2975 : : parse_quota_update_name(struct context *ctx, const struct token *token,
2976 : : const char *str, unsigned int len, void *buf,
2977 : : unsigned int size);
2978 : : static int
2979 : : parse_qu_mode_name(struct context *ctx, const struct token *token,
2980 : : const char *str, unsigned int len, void *buf,
2981 : : unsigned int size);
2982 : : static int comp_none(struct context *, const struct token *,
2983 : : unsigned int, char *, unsigned int);
2984 : : static int comp_boolean(struct context *, const struct token *,
2985 : : unsigned int, char *, unsigned int);
2986 : : static int comp_action(struct context *, const struct token *,
2987 : : unsigned int, char *, unsigned int);
2988 : : static int comp_port(struct context *, const struct token *,
2989 : : unsigned int, char *, unsigned int);
2990 : : static int comp_rule_id(struct context *, const struct token *,
2991 : : unsigned int, char *, unsigned int);
2992 : : static int comp_vc_action_rss_type(struct context *, const struct token *,
2993 : : unsigned int, char *, unsigned int);
2994 : : static int comp_vc_action_rss_queue(struct context *, const struct token *,
2995 : : unsigned int, char *, unsigned int);
2996 : : static int comp_set_raw_index(struct context *, const struct token *,
2997 : : unsigned int, char *, unsigned int);
2998 : : static int comp_set_sample_index(struct context *, const struct token *,
2999 : : unsigned int, char *, unsigned int);
3000 : : static int comp_set_ipv6_ext_index(struct context *ctx, const struct token *token,
3001 : : unsigned int ent, char *buf, unsigned int size);
3002 : : static int comp_set_modify_field_op(struct context *, const struct token *,
3003 : : unsigned int, char *, unsigned int);
3004 : : static int comp_set_modify_field_id(struct context *, const struct token *,
3005 : : unsigned int, char *, unsigned int);
3006 : : static int comp_pattern_template_id(struct context *, const struct token *,
3007 : : unsigned int, char *, unsigned int);
3008 : : static int comp_actions_template_id(struct context *, const struct token *,
3009 : : unsigned int, char *, unsigned int);
3010 : : static int comp_table_id(struct context *, const struct token *,
3011 : : unsigned int, char *, unsigned int);
3012 : : static int comp_queue_id(struct context *, const struct token *,
3013 : : unsigned int, char *, unsigned int);
3014 : : static int comp_meter_color(struct context *, const struct token *,
3015 : : unsigned int, char *, unsigned int);
3016 : : static int comp_insertion_table_type(struct context *, const struct token *,
3017 : : unsigned int, char *, unsigned int);
3018 : : static int comp_hash_table_type(struct context *, const struct token *,
3019 : : unsigned int, char *, unsigned int);
3020 : : static int
3021 : : comp_quota_state_name(struct context *ctx, const struct token *token,
3022 : : unsigned int ent, char *buf, unsigned int size);
3023 : : static int
3024 : : comp_quota_mode_name(struct context *ctx, const struct token *token,
3025 : : unsigned int ent, char *buf, unsigned int size);
3026 : : static int
3027 : : comp_quota_update_name(struct context *ctx, const struct token *token,
3028 : : unsigned int ent, char *buf, unsigned int size);
3029 : : static int
3030 : : comp_qu_mode_name(struct context *ctx, const struct token *token,
3031 : : unsigned int ent, char *buf, unsigned int size);
3032 : : static int
3033 : : comp_set_compare_field_id(struct context *ctx, const struct token *token,
3034 : : unsigned int ent, char *buf, unsigned int size);
3035 : : static int
3036 : : comp_set_compare_op(struct context *ctx, const struct token *token,
3037 : : unsigned int ent, char *buf, unsigned int size);
3038 : : static int
3039 : : parse_vc_compare_op(struct context *ctx, const struct token *token,
3040 : : const char *str, unsigned int len, void *buf,
3041 : : unsigned int size);
3042 : : static int
3043 : : parse_vc_compare_field_id(struct context *ctx, const struct token *token,
3044 : : const char *str, unsigned int len, void *buf,
3045 : : unsigned int size);
3046 : : static int
3047 : : parse_vc_compare_field_level(struct context *ctx, const struct token *token,
3048 : : const char *str, unsigned int len, void *buf,
3049 : : unsigned int size);
3050 : :
3051 : : struct indlst_conf {
3052 : : uint32_t id;
3053 : : uint32_t conf_num;
3054 : : struct rte_flow_action *actions;
3055 : : const void **conf;
3056 : : SLIST_ENTRY(indlst_conf) next;
3057 : : };
3058 : :
3059 : : static const struct indlst_conf *indirect_action_list_conf_get(uint32_t conf_id);
3060 : :
3061 : : /** Token definitions. */
3062 : : static const struct token token_list[] = {
3063 : : /* Special tokens. */
3064 : : [ZERO] = {
3065 : : .name = "ZERO",
3066 : : .help = "null entry, abused as the entry point",
3067 : : .next = NEXT(NEXT_ENTRY(FLOW, ADD)),
3068 : : },
3069 : : [END] = {
3070 : : .name = "",
3071 : : .type = "RETURN",
3072 : : .help = "command may end here",
3073 : : },
3074 : : [START_SET] = {
3075 : : .name = "START_SET",
3076 : : .help = "null entry, abused as the entry point for set",
3077 : : .next = NEXT(NEXT_ENTRY(SET)),
3078 : : },
3079 : : [END_SET] = {
3080 : : .name = "end_set",
3081 : : .type = "RETURN",
3082 : : .help = "set command may end here",
3083 : : },
3084 : : /* Common tokens. */
3085 : : [COMMON_INTEGER] = {
3086 : : .name = "{int}",
3087 : : .type = "INTEGER",
3088 : : .help = "integer value",
3089 : : .call = parse_int,
3090 : : .comp = comp_none,
3091 : : },
3092 : : [COMMON_UNSIGNED] = {
3093 : : .name = "{unsigned}",
3094 : : .type = "UNSIGNED",
3095 : : .help = "unsigned integer value",
3096 : : .call = parse_int,
3097 : : .comp = comp_none,
3098 : : },
3099 : : [COMMON_PREFIX] = {
3100 : : .name = "{prefix}",
3101 : : .type = "PREFIX",
3102 : : .help = "prefix length for bit-mask",
3103 : : .call = parse_prefix,
3104 : : .comp = comp_none,
3105 : : },
3106 : : [COMMON_BOOLEAN] = {
3107 : : .name = "{boolean}",
3108 : : .type = "BOOLEAN",
3109 : : .help = "any boolean value",
3110 : : .call = parse_boolean,
3111 : : .comp = comp_boolean,
3112 : : },
3113 : : [COMMON_STRING] = {
3114 : : .name = "{string}",
3115 : : .type = "STRING",
3116 : : .help = "fixed string",
3117 : : .call = parse_string,
3118 : : .comp = comp_none,
3119 : : },
3120 : : [COMMON_HEX] = {
3121 : : .name = "{hex}",
3122 : : .type = "HEX",
3123 : : .help = "fixed string",
3124 : : .call = parse_hex,
3125 : : },
3126 : : [COMMON_FILE_PATH] = {
3127 : : .name = "{file path}",
3128 : : .type = "STRING",
3129 : : .help = "file path",
3130 : : .call = parse_string0,
3131 : : .comp = comp_none,
3132 : : },
3133 : : [COMMON_MAC_ADDR] = {
3134 : : .name = "{MAC address}",
3135 : : .type = "MAC-48",
3136 : : .help = "standard MAC address notation",
3137 : : .call = parse_mac_addr,
3138 : : .comp = comp_none,
3139 : : },
3140 : : [COMMON_IPV4_ADDR] = {
3141 : : .name = "{IPv4 address}",
3142 : : .type = "IPV4 ADDRESS",
3143 : : .help = "standard IPv4 address notation",
3144 : : .call = parse_ipv4_addr,
3145 : : .comp = comp_none,
3146 : : },
3147 : : [COMMON_IPV6_ADDR] = {
3148 : : .name = "{IPv6 address}",
3149 : : .type = "IPV6 ADDRESS",
3150 : : .help = "standard IPv6 address notation",
3151 : : .call = parse_ipv6_addr,
3152 : : .comp = comp_none,
3153 : : },
3154 : : [COMMON_RULE_ID] = {
3155 : : .name = "{rule id}",
3156 : : .type = "RULE ID",
3157 : : .help = "rule identifier",
3158 : : .call = parse_int,
3159 : : .comp = comp_rule_id,
3160 : : },
3161 : : [COMMON_PORT_ID] = {
3162 : : .name = "{port_id}",
3163 : : .type = "PORT ID",
3164 : : .help = "port identifier",
3165 : : .call = parse_port,
3166 : : .comp = comp_port,
3167 : : },
3168 : : [COMMON_GROUP_ID] = {
3169 : : .name = "{group_id}",
3170 : : .type = "GROUP ID",
3171 : : .help = "group identifier",
3172 : : .call = parse_int,
3173 : : .comp = comp_none,
3174 : : },
3175 : : [COMMON_PRIORITY_LEVEL] = {
3176 : : .name = "{level}",
3177 : : .type = "PRIORITY",
3178 : : .help = "priority level",
3179 : : .call = parse_int,
3180 : : .comp = comp_none,
3181 : : },
3182 : : [COMMON_INDIRECT_ACTION_ID] = {
3183 : : .name = "{indirect_action_id}",
3184 : : .type = "INDIRECT_ACTION_ID",
3185 : : .help = "indirect action id",
3186 : : .call = parse_int,
3187 : : .comp = comp_none,
3188 : : },
3189 : : [COMMON_PROFILE_ID] = {
3190 : : .name = "{profile_id}",
3191 : : .type = "PROFILE_ID",
3192 : : .help = "profile id",
3193 : : .call = parse_int,
3194 : : .comp = comp_none,
3195 : : },
3196 : : [COMMON_POLICY_ID] = {
3197 : : .name = "{policy_id}",
3198 : : .type = "POLICY_ID",
3199 : : .help = "policy id",
3200 : : .call = parse_int,
3201 : : .comp = comp_none,
3202 : : },
3203 : : [COMMON_FLEX_TOKEN] = {
3204 : : .name = "{flex token}",
3205 : : .type = "flex token",
3206 : : .help = "flex token",
3207 : : .call = parse_int,
3208 : : .comp = comp_none,
3209 : : },
3210 : : [COMMON_FLEX_HANDLE] = {
3211 : : .name = "{flex handle}",
3212 : : .type = "FLEX HANDLE",
3213 : : .help = "fill flex item data",
3214 : : .call = parse_flex_handle,
3215 : : .comp = comp_none,
3216 : : },
3217 : : [COMMON_PATTERN_TEMPLATE_ID] = {
3218 : : .name = "{pattern_template_id}",
3219 : : .type = "PATTERN_TEMPLATE_ID",
3220 : : .help = "pattern template id",
3221 : : .call = parse_int,
3222 : : .comp = comp_pattern_template_id,
3223 : : },
3224 : : [COMMON_ACTIONS_TEMPLATE_ID] = {
3225 : : .name = "{actions_template_id}",
3226 : : .type = "ACTIONS_TEMPLATE_ID",
3227 : : .help = "actions template id",
3228 : : .call = parse_int,
3229 : : .comp = comp_actions_template_id,
3230 : : },
3231 : : [COMMON_TABLE_ID] = {
3232 : : .name = "{table_id}",
3233 : : .type = "TABLE_ID",
3234 : : .help = "table id",
3235 : : .call = parse_int,
3236 : : .comp = comp_table_id,
3237 : : },
3238 : : [COMMON_QUEUE_ID] = {
3239 : : .name = "{queue_id}",
3240 : : .type = "QUEUE_ID",
3241 : : .help = "queue id",
3242 : : .call = parse_int,
3243 : : .comp = comp_queue_id,
3244 : : },
3245 : : [COMMON_METER_COLOR_NAME] = {
3246 : : .name = "color_name",
3247 : : .help = "meter color name",
3248 : : .call = parse_meter_color,
3249 : : .comp = comp_meter_color,
3250 : : },
3251 : : /* Top-level command. */
3252 : : [FLOW] = {
3253 : : .name = "flow",
3254 : : .type = "{command} {port_id} [{arg} [...]]",
3255 : : .help = "manage ingress/egress flow rules",
3256 : : .next = NEXT(NEXT_ENTRY
3257 : : (INFO,
3258 : : CONFIGURE,
3259 : : PATTERN_TEMPLATE,
3260 : : ACTIONS_TEMPLATE,
3261 : : TABLE,
3262 : : FLOW_GROUP,
3263 : : INDIRECT_ACTION,
3264 : : VALIDATE,
3265 : : CREATE,
3266 : : DESTROY,
3267 : : UPDATE,
3268 : : FLUSH,
3269 : : DUMP,
3270 : : LIST,
3271 : : AGED,
3272 : : QUERY,
3273 : : ISOLATE,
3274 : : TUNNEL,
3275 : : FLEX,
3276 : : QUEUE,
3277 : : PUSH,
3278 : : PULL,
3279 : : HASH)),
3280 : : .call = parse_init,
3281 : : },
3282 : : /* Top-level command. */
3283 : : [INFO] = {
3284 : : .name = "info",
3285 : : .help = "get information about flow engine",
3286 : : .next = NEXT(NEXT_ENTRY(END),
3287 : : NEXT_ENTRY(COMMON_PORT_ID)),
3288 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3289 : : .call = parse_configure,
3290 : : },
3291 : : /* Top-level command. */
3292 : : [CONFIGURE] = {
3293 : : .name = "configure",
3294 : : .help = "configure flow engine",
3295 : : .next = NEXT(next_config_attr,
3296 : : NEXT_ENTRY(COMMON_PORT_ID)),
3297 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3298 : : .call = parse_configure,
3299 : : },
3300 : : /* Configure arguments. */
3301 : : [CONFIG_QUEUES_NUMBER] = {
3302 : : .name = "queues_number",
3303 : : .help = "number of queues",
3304 : : .next = NEXT(next_config_attr,
3305 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3306 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3307 : : args.configure.nb_queue)),
3308 : : },
3309 : : [CONFIG_QUEUES_SIZE] = {
3310 : : .name = "queues_size",
3311 : : .help = "number of elements in queues",
3312 : : .next = NEXT(next_config_attr,
3313 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3314 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3315 : : args.configure.queue_attr.size)),
3316 : : },
3317 : : [CONFIG_COUNTERS_NUMBER] = {
3318 : : .name = "counters_number",
3319 : : .help = "number of counters",
3320 : : .next = NEXT(next_config_attr,
3321 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3322 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3323 : : args.configure.port_attr.nb_counters)),
3324 : : },
3325 : : [CONFIG_AGING_OBJECTS_NUMBER] = {
3326 : : .name = "aging_counters_number",
3327 : : .help = "number of aging objects",
3328 : : .next = NEXT(next_config_attr,
3329 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3330 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3331 : : args.configure.port_attr.nb_aging_objects)),
3332 : : },
3333 : : [CONFIG_QUOTAS_NUMBER] = {
3334 : : .name = "quotas_number",
3335 : : .help = "number of quotas",
3336 : : .next = NEXT(next_config_attr,
3337 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3338 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3339 : : args.configure.port_attr.nb_quotas)),
3340 : : },
3341 : : [CONFIG_METERS_NUMBER] = {
3342 : : .name = "meters_number",
3343 : : .help = "number of meters",
3344 : : .next = NEXT(next_config_attr,
3345 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3346 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3347 : : args.configure.port_attr.nb_meters)),
3348 : : },
3349 : : [CONFIG_CONN_TRACK_NUMBER] = {
3350 : : .name = "conn_tracks_number",
3351 : : .help = "number of connection trackings",
3352 : : .next = NEXT(next_config_attr,
3353 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3354 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3355 : : args.configure.port_attr.nb_conn_tracks)),
3356 : : },
3357 : : [CONFIG_FLAGS] = {
3358 : : .name = "flags",
3359 : : .help = "configuration flags",
3360 : : .next = NEXT(next_config_attr,
3361 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3362 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3363 : : args.configure.port_attr.flags)),
3364 : : },
3365 : : [CONFIG_HOST_PORT] = {
3366 : : .name = "host_port",
3367 : : .help = "host port for shared objects",
3368 : : .next = NEXT(next_config_attr,
3369 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3370 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3371 : : args.configure.port_attr.host_port_id)),
3372 : : },
3373 : : /* Top-level command. */
3374 : : [PATTERN_TEMPLATE] = {
3375 : : .name = "pattern_template",
3376 : : .type = "{command} {port_id} [{arg} [...]]",
3377 : : .help = "manage pattern templates",
3378 : : .next = NEXT(next_pt_subcmd, NEXT_ENTRY(COMMON_PORT_ID)),
3379 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3380 : : .call = parse_template,
3381 : : },
3382 : : /* Sub-level commands. */
3383 : : [PATTERN_TEMPLATE_CREATE] = {
3384 : : .name = "create",
3385 : : .help = "create pattern template",
3386 : : .next = NEXT(next_pt_attr),
3387 : : .call = parse_template,
3388 : : },
3389 : : [PATTERN_TEMPLATE_DESTROY] = {
3390 : : .name = "destroy",
3391 : : .help = "destroy pattern template",
3392 : : .next = NEXT(NEXT_ENTRY(PATTERN_TEMPLATE_DESTROY_ID)),
3393 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3394 : : .call = parse_template_destroy,
3395 : : },
3396 : : /* Pattern template arguments. */
3397 : : [PATTERN_TEMPLATE_CREATE_ID] = {
3398 : : .name = "pattern_template_id",
3399 : : .help = "specify a pattern template id to create",
3400 : : .next = NEXT(next_pt_attr,
3401 : : NEXT_ENTRY(COMMON_PATTERN_TEMPLATE_ID)),
3402 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.pat_templ_id)),
3403 : : },
3404 : : [PATTERN_TEMPLATE_DESTROY_ID] = {
3405 : : .name = "pattern_template",
3406 : : .help = "specify a pattern template id to destroy",
3407 : : .next = NEXT(next_pt_destroy_attr,
3408 : : NEXT_ENTRY(COMMON_PATTERN_TEMPLATE_ID)),
3409 : : .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
3410 : : args.templ_destroy.template_id)),
3411 : : .call = parse_template_destroy,
3412 : : },
3413 : : [PATTERN_TEMPLATE_RELAXED_MATCHING] = {
3414 : : .name = "relaxed",
3415 : : .help = "is matching relaxed",
3416 : : .next = NEXT(next_pt_attr,
3417 : : NEXT_ENTRY(COMMON_BOOLEAN)),
3418 : : .args = ARGS(ARGS_ENTRY_BF(struct buffer,
3419 : : args.vc.attr.reserved, 1)),
3420 : : },
3421 : : [PATTERN_TEMPLATE_INGRESS] = {
3422 : : .name = "ingress",
3423 : : .help = "attribute pattern to ingress",
3424 : : .next = NEXT(next_pt_attr),
3425 : : .call = parse_template,
3426 : : },
3427 : : [PATTERN_TEMPLATE_EGRESS] = {
3428 : : .name = "egress",
3429 : : .help = "attribute pattern to egress",
3430 : : .next = NEXT(next_pt_attr),
3431 : : .call = parse_template,
3432 : : },
3433 : : [PATTERN_TEMPLATE_TRANSFER] = {
3434 : : .name = "transfer",
3435 : : .help = "attribute pattern to transfer",
3436 : : .next = NEXT(next_pt_attr),
3437 : : .call = parse_template,
3438 : : },
3439 : : [PATTERN_TEMPLATE_SPEC] = {
3440 : : .name = "template",
3441 : : .help = "specify item to create pattern template",
3442 : : .next = NEXT(next_item),
3443 : : },
3444 : : /* Top-level command. */
3445 : : [ACTIONS_TEMPLATE] = {
3446 : : .name = "actions_template",
3447 : : .type = "{command} {port_id} [{arg} [...]]",
3448 : : .help = "manage actions templates",
3449 : : .next = NEXT(next_at_subcmd, NEXT_ENTRY(COMMON_PORT_ID)),
3450 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3451 : : .call = parse_template,
3452 : : },
3453 : : /* Sub-level commands. */
3454 : : [ACTIONS_TEMPLATE_CREATE] = {
3455 : : .name = "create",
3456 : : .help = "create actions template",
3457 : : .next = NEXT(next_at_attr),
3458 : : .call = parse_template,
3459 : : },
3460 : : [ACTIONS_TEMPLATE_DESTROY] = {
3461 : : .name = "destroy",
3462 : : .help = "destroy actions template",
3463 : : .next = NEXT(NEXT_ENTRY(ACTIONS_TEMPLATE_DESTROY_ID)),
3464 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3465 : : .call = parse_template_destroy,
3466 : : },
3467 : : /* Actions template arguments. */
3468 : : [ACTIONS_TEMPLATE_CREATE_ID] = {
3469 : : .name = "actions_template_id",
3470 : : .help = "specify an actions template id to create",
3471 : : .next = NEXT(NEXT_ENTRY(ACTIONS_TEMPLATE_MASK),
3472 : : NEXT_ENTRY(ACTIONS_TEMPLATE_SPEC),
3473 : : NEXT_ENTRY(COMMON_ACTIONS_TEMPLATE_ID)),
3474 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.act_templ_id)),
3475 : : },
3476 : : [ACTIONS_TEMPLATE_DESTROY_ID] = {
3477 : : .name = "actions_template",
3478 : : .help = "specify an actions template id to destroy",
3479 : : .next = NEXT(next_at_destroy_attr,
3480 : : NEXT_ENTRY(COMMON_ACTIONS_TEMPLATE_ID)),
3481 : : .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
3482 : : args.templ_destroy.template_id)),
3483 : : .call = parse_template_destroy,
3484 : : },
3485 : : [ACTIONS_TEMPLATE_INGRESS] = {
3486 : : .name = "ingress",
3487 : : .help = "attribute actions to ingress",
3488 : : .next = NEXT(next_at_attr),
3489 : : .call = parse_template,
3490 : : },
3491 : : [ACTIONS_TEMPLATE_EGRESS] = {
3492 : : .name = "egress",
3493 : : .help = "attribute actions to egress",
3494 : : .next = NEXT(next_at_attr),
3495 : : .call = parse_template,
3496 : : },
3497 : : [ACTIONS_TEMPLATE_TRANSFER] = {
3498 : : .name = "transfer",
3499 : : .help = "attribute actions to transfer",
3500 : : .next = NEXT(next_at_attr),
3501 : : .call = parse_template,
3502 : : },
3503 : : [ACTIONS_TEMPLATE_SPEC] = {
3504 : : .name = "template",
3505 : : .help = "specify action to create actions template",
3506 : : .next = NEXT(next_action),
3507 : : .call = parse_template,
3508 : : },
3509 : : [ACTIONS_TEMPLATE_MASK] = {
3510 : : .name = "mask",
3511 : : .help = "specify action mask to create actions template",
3512 : : .next = NEXT(next_action),
3513 : : .call = parse_template,
3514 : : },
3515 : : /* Top-level command. */
3516 : : [TABLE] = {
3517 : : .name = "template_table",
3518 : : .type = "{command} {port_id} [{arg} [...]]",
3519 : : .help = "manage template tables",
3520 : : .next = NEXT(next_table_subcmd, NEXT_ENTRY(COMMON_PORT_ID)),
3521 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3522 : : .call = parse_table,
3523 : : },
3524 : : /* Sub-level commands. */
3525 : : [TABLE_CREATE] = {
3526 : : .name = "create",
3527 : : .help = "create template table",
3528 : : .next = NEXT(next_table_attr),
3529 : : .call = parse_table,
3530 : : },
3531 : : [TABLE_DESTROY] = {
3532 : : .name = "destroy",
3533 : : .help = "destroy template table",
3534 : : .next = NEXT(NEXT_ENTRY(TABLE_DESTROY_ID)),
3535 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3536 : : .call = parse_table_destroy,
3537 : : },
3538 : : [TABLE_RESIZE] = {
3539 : : .name = "resize",
3540 : : .help = "resize template table",
3541 : : .next = NEXT(NEXT_ENTRY(TABLE_RESIZE_ID)),
3542 : : .call = parse_table
3543 : : },
3544 : : [TABLE_RESIZE_COMPLETE] = {
3545 : : .name = "resize_complete",
3546 : : .help = "complete table resize",
3547 : : .next = NEXT(NEXT_ENTRY(TABLE_DESTROY_ID)),
3548 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3549 : : .call = parse_table_destroy,
3550 : : },
3551 : : /* Table arguments. */
3552 : : [TABLE_CREATE_ID] = {
3553 : : .name = "table_id",
3554 : : .help = "specify table id to create",
3555 : : .next = NEXT(next_table_attr,
3556 : : NEXT_ENTRY(COMMON_TABLE_ID)),
3557 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.table.id)),
3558 : : },
3559 : : [TABLE_DESTROY_ID] = {
3560 : : .name = "table",
3561 : : .help = "table id",
3562 : : .next = NEXT(next_table_destroy_attr,
3563 : : NEXT_ENTRY(COMMON_TABLE_ID)),
3564 : : .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
3565 : : args.table_destroy.table_id)),
3566 : : .call = parse_table_destroy,
3567 : : },
3568 : : [TABLE_RESIZE_ID] = {
3569 : : .name = "table_resize_id",
3570 : : .help = "table resize id",
3571 : : .next = NEXT(NEXT_ENTRY(TABLE_RESIZE_RULES_NUMBER),
3572 : : NEXT_ENTRY(COMMON_TABLE_ID)),
3573 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.table.id)),
3574 : : .call = parse_table
3575 : : },
3576 : : [TABLE_RESIZE_RULES_NUMBER] = {
3577 : : .name = "table_resize_rules_num",
3578 : : .help = "table resize rules number",
3579 : : .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(COMMON_UNSIGNED)),
3580 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3581 : : args.table.attr.nb_flows)),
3582 : : .call = parse_table
3583 : : },
3584 : : [TABLE_INSERTION_TYPE] = {
3585 : : .name = "insertion_type",
3586 : : .help = "specify insertion type",
3587 : : .next = NEXT(next_table_attr,
3588 : : NEXT_ENTRY(TABLE_INSERTION_TYPE_NAME)),
3589 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3590 : : args.table.attr.insertion_type)),
3591 : : },
3592 : : [TABLE_INSERTION_TYPE_NAME] = {
3593 : : .name = "insertion_type_name",
3594 : : .help = "insertion type name",
3595 : : .call = parse_insertion_table_type,
3596 : : .comp = comp_insertion_table_type,
3597 : : },
3598 : : [TABLE_HASH_FUNC] = {
3599 : : .name = "hash_func",
3600 : : .help = "specify hash calculation function",
3601 : : .next = NEXT(next_table_attr,
3602 : : NEXT_ENTRY(TABLE_HASH_FUNC_NAME)),
3603 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3604 : : args.table.attr.hash_func)),
3605 : : },
3606 : : [TABLE_HASH_FUNC_NAME] = {
3607 : : .name = "hash_func_name",
3608 : : .help = "hash calculation function name",
3609 : : .call = parse_hash_table_type,
3610 : : .comp = comp_hash_table_type,
3611 : : },
3612 : : [TABLE_GROUP] = {
3613 : : .name = "group",
3614 : : .help = "specify a group",
3615 : : .next = NEXT(next_table_attr, NEXT_ENTRY(COMMON_GROUP_ID)),
3616 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3617 : : args.table.attr.flow_attr.group)),
3618 : : },
3619 : : [TABLE_PRIORITY] = {
3620 : : .name = "priority",
3621 : : .help = "specify a priority level",
3622 : : .next = NEXT(next_table_attr, NEXT_ENTRY(COMMON_PRIORITY_LEVEL)),
3623 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3624 : : args.table.attr.flow_attr.priority)),
3625 : : },
3626 : : [TABLE_EGRESS] = {
3627 : : .name = "egress",
3628 : : .help = "affect rule to egress",
3629 : : .next = NEXT(next_table_attr),
3630 : : .call = parse_table,
3631 : : },
3632 : : [TABLE_INGRESS] = {
3633 : : .name = "ingress",
3634 : : .help = "affect rule to ingress",
3635 : : .next = NEXT(next_table_attr),
3636 : : .call = parse_table,
3637 : : },
3638 : : [TABLE_TRANSFER] = {
3639 : : .name = "transfer",
3640 : : .help = "affect rule to transfer",
3641 : : .next = NEXT(next_table_attr),
3642 : : .call = parse_table,
3643 : : },
3644 : : [TABLE_TRANSFER_WIRE_ORIG] = {
3645 : : .name = "wire_orig",
3646 : : .help = "affect rule direction to transfer",
3647 : : .next = NEXT(next_table_attr),
3648 : : .call = parse_table,
3649 : : },
3650 : : [TABLE_TRANSFER_VPORT_ORIG] = {
3651 : : .name = "vport_orig",
3652 : : .help = "affect rule direction to transfer",
3653 : : .next = NEXT(next_table_attr),
3654 : : .call = parse_table,
3655 : : },
3656 : : [TABLE_RESIZABLE] = {
3657 : : .name = "resizable",
3658 : : .help = "set resizable attribute",
3659 : : .next = NEXT(next_table_attr),
3660 : : .call = parse_table,
3661 : : },
3662 : : [TABLE_RULES_NUMBER] = {
3663 : : .name = "rules_number",
3664 : : .help = "number of rules in table",
3665 : : .next = NEXT(next_table_attr,
3666 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3667 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3668 : : args.table.attr.nb_flows)),
3669 : : .call = parse_table,
3670 : : },
3671 : : [TABLE_PATTERN_TEMPLATE] = {
3672 : : .name = "pattern_template",
3673 : : .help = "specify pattern template id",
3674 : : .next = NEXT(next_table_attr,
3675 : : NEXT_ENTRY(COMMON_PATTERN_TEMPLATE_ID)),
3676 : : .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
3677 : : args.table.pat_templ_id)),
3678 : : .call = parse_table,
3679 : : },
3680 : : [TABLE_ACTIONS_TEMPLATE] = {
3681 : : .name = "actions_template",
3682 : : .help = "specify actions template id",
3683 : : .next = NEXT(next_table_attr,
3684 : : NEXT_ENTRY(COMMON_ACTIONS_TEMPLATE_ID)),
3685 : : .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
3686 : : args.table.act_templ_id)),
3687 : : .call = parse_table,
3688 : : },
3689 : : /* Top-level command. */
3690 : : [FLOW_GROUP] = {
3691 : : .name = "group",
3692 : : .help = "manage flow groups",
3693 : : .next = NEXT(NEXT_ENTRY(GROUP_ID), NEXT_ENTRY(COMMON_PORT_ID)),
3694 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3695 : : .call = parse_group,
3696 : : },
3697 : : /* Sub-level commands. */
3698 : : [GROUP_SET_MISS_ACTIONS] = {
3699 : : .name = "set_miss_actions",
3700 : : .help = "set group miss actions",
3701 : : .next = NEXT(next_action),
3702 : : .call = parse_group,
3703 : : },
3704 : : /* Group arguments */
3705 : : [GROUP_ID] = {
3706 : : .name = "group_id",
3707 : : .help = "group id",
3708 : : .next = NEXT(next_group_attr, NEXT_ENTRY(COMMON_GROUP_ID)),
3709 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
3710 : : },
3711 : : [GROUP_INGRESS] = {
3712 : : .name = "ingress",
3713 : : .help = "group ingress attr",
3714 : : .next = NEXT(next_group_attr),
3715 : : .call = parse_group,
3716 : : },
3717 : : [GROUP_EGRESS] = {
3718 : : .name = "egress",
3719 : : .help = "group egress attr",
3720 : : .next = NEXT(next_group_attr),
3721 : : .call = parse_group,
3722 : : },
3723 : : [GROUP_TRANSFER] = {
3724 : : .name = "transfer",
3725 : : .help = "group transfer attr",
3726 : : .next = NEXT(next_group_attr),
3727 : : .call = parse_group,
3728 : : },
3729 : : /* Top-level command. */
3730 : : [QUEUE] = {
3731 : : .name = "queue",
3732 : : .help = "queue a flow rule operation",
3733 : : .next = NEXT(next_queue_subcmd, NEXT_ENTRY(COMMON_PORT_ID)),
3734 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3735 : : .call = parse_qo,
3736 : : },
3737 : : /* Sub-level commands. */
3738 : : [QUEUE_CREATE] = {
3739 : : .name = "create",
3740 : : .help = "create a flow rule",
3741 : : .next = NEXT(NEXT_ENTRY(QUEUE_TEMPLATE_TABLE),
3742 : : NEXT_ENTRY(COMMON_QUEUE_ID)),
3743 : : .args = ARGS(ARGS_ENTRY(struct buffer, queue)),
3744 : : .call = parse_qo,
3745 : : },
3746 : : [QUEUE_DESTROY] = {
3747 : : .name = "destroy",
3748 : : .help = "destroy a flow rule",
3749 : : .next = NEXT(NEXT_ENTRY(QUEUE_DESTROY_POSTPONE),
3750 : : NEXT_ENTRY(COMMON_QUEUE_ID)),
3751 : : .args = ARGS(ARGS_ENTRY(struct buffer, queue)),
3752 : : .call = parse_qo_destroy,
3753 : : },
3754 : : [QUEUE_FLOW_UPDATE_RESIZED] = {
3755 : : .name = "update_resized",
3756 : : .help = "update a flow after table resize",
3757 : : .next = NEXT(NEXT_ENTRY(QUEUE_DESTROY_ID),
3758 : : NEXT_ENTRY(COMMON_QUEUE_ID)),
3759 : : .args = ARGS(ARGS_ENTRY(struct buffer, queue)),
3760 : : .call = parse_qo_destroy,
3761 : : },
3762 : : [QUEUE_UPDATE] = {
3763 : : .name = "update",
3764 : : .help = "update a flow rule",
3765 : : .next = NEXT(NEXT_ENTRY(QUEUE_UPDATE_ID),
3766 : : NEXT_ENTRY(COMMON_QUEUE_ID)),
3767 : : .args = ARGS(ARGS_ENTRY(struct buffer, queue)),
3768 : : .call = parse_qo,
3769 : : },
3770 : : [QUEUE_AGED] = {
3771 : : .name = "aged",
3772 : : .help = "list and destroy aged flows",
3773 : : .next = NEXT(next_aged_attr, NEXT_ENTRY(COMMON_QUEUE_ID)),
3774 : : .args = ARGS(ARGS_ENTRY(struct buffer, queue)),
3775 : : .call = parse_aged,
3776 : : },
3777 : : [QUEUE_INDIRECT_ACTION] = {
3778 : : .name = "indirect_action",
3779 : : .help = "queue indirect actions",
3780 : : .next = NEXT(next_qia_subcmd, NEXT_ENTRY(COMMON_QUEUE_ID)),
3781 : : .args = ARGS(ARGS_ENTRY(struct buffer, queue)),
3782 : : .call = parse_qia,
3783 : : },
3784 : : /* Queue arguments. */
3785 : : [QUEUE_TEMPLATE_TABLE] = {
3786 : : .name = "template_table",
3787 : : .help = "specify table id",
3788 : : .next = NEXT(next_async_insert_subcmd,
3789 : : NEXT_ENTRY(COMMON_TABLE_ID)),
3790 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3791 : : args.vc.table_id)),
3792 : : .call = parse_qo,
3793 : : },
3794 : : [QUEUE_PATTERN_TEMPLATE] = {
3795 : : .name = "pattern_template",
3796 : : .help = "specify pattern template index",
3797 : : .next = NEXT(NEXT_ENTRY(QUEUE_ACTIONS_TEMPLATE),
3798 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3799 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3800 : : args.vc.pat_templ_id)),
3801 : : .call = parse_qo,
3802 : : },
3803 : : [QUEUE_ACTIONS_TEMPLATE] = {
3804 : : .name = "actions_template",
3805 : : .help = "specify actions template index",
3806 : : .next = NEXT(NEXT_ENTRY(QUEUE_CREATE_POSTPONE),
3807 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3808 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3809 : : args.vc.act_templ_id)),
3810 : : .call = parse_qo,
3811 : : },
3812 : : [QUEUE_RULE_ID] = {
3813 : : .name = "rule_index",
3814 : : .help = "specify flow rule index",
3815 : : .next = NEXT(next_async_pattern_subcmd,
3816 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3817 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3818 : : args.vc.rule_id)),
3819 : : .call = parse_qo,
3820 : : },
3821 : : [QUEUE_CREATE_POSTPONE] = {
3822 : : .name = "postpone",
3823 : : .help = "postpone create operation",
3824 : : .next = NEXT(NEXT_ENTRY(ITEM_PATTERN),
3825 : : NEXT_ENTRY(COMMON_BOOLEAN)),
3826 : : .args = ARGS(ARGS_ENTRY(struct buffer, postpone)),
3827 : : .call = parse_qo,
3828 : : },
3829 : : [QUEUE_DESTROY_POSTPONE] = {
3830 : : .name = "postpone",
3831 : : .help = "postpone destroy operation",
3832 : : .next = NEXT(NEXT_ENTRY(QUEUE_DESTROY_ID),
3833 : : NEXT_ENTRY(COMMON_BOOLEAN)),
3834 : : .args = ARGS(ARGS_ENTRY(struct buffer, postpone)),
3835 : : .call = parse_qo_destroy,
3836 : : },
3837 : : [QUEUE_DESTROY_ID] = {
3838 : : .name = "rule",
3839 : : .help = "specify rule id to destroy",
3840 : : .next = NEXT(next_queue_destroy_attr,
3841 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3842 : : .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
3843 : : args.destroy.rule)),
3844 : : .call = parse_qo_destroy,
3845 : : },
3846 : : [QUEUE_UPDATE_ID] = {
3847 : : .name = "rule",
3848 : : .help = "specify rule id to update",
3849 : : .next = NEXT(NEXT_ENTRY(QUEUE_ACTIONS_TEMPLATE),
3850 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3851 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3852 : : args.vc.rule_id)),
3853 : : .call = parse_qo,
3854 : : },
3855 : : /* Queue indirect action arguments */
3856 : : [QUEUE_INDIRECT_ACTION_CREATE] = {
3857 : : .name = "create",
3858 : : .help = "create indirect action",
3859 : : .next = NEXT(next_qia_create_attr),
3860 : : .call = parse_qia,
3861 : : },
3862 : : [QUEUE_INDIRECT_ACTION_UPDATE] = {
3863 : : .name = "update",
3864 : : .help = "update indirect action",
3865 : : .next = NEXT(next_qia_update_attr,
3866 : : NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
3867 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
3868 : : .call = parse_qia,
3869 : : },
3870 : : [QUEUE_INDIRECT_ACTION_DESTROY] = {
3871 : : .name = "destroy",
3872 : : .help = "destroy indirect action",
3873 : : .next = NEXT(next_qia_destroy_attr),
3874 : : .call = parse_qia_destroy,
3875 : : },
3876 : : [QUEUE_INDIRECT_ACTION_QUERY] = {
3877 : : .name = "query",
3878 : : .help = "query indirect action",
3879 : : .next = NEXT(next_qia_query_attr,
3880 : : NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
3881 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.ia.action_id)),
3882 : : .call = parse_qia,
3883 : : },
3884 : : /* Indirect action destroy arguments. */
3885 : : [QUEUE_INDIRECT_ACTION_DESTROY_POSTPONE] = {
3886 : : .name = "postpone",
3887 : : .help = "postpone destroy operation",
3888 : : .next = NEXT(next_qia_destroy_attr,
3889 : : NEXT_ENTRY(COMMON_BOOLEAN)),
3890 : : .args = ARGS(ARGS_ENTRY(struct buffer, postpone)),
3891 : : },
3892 : : [QUEUE_INDIRECT_ACTION_DESTROY_ID] = {
3893 : : .name = "action_id",
3894 : : .help = "specify a indirect action id to destroy",
3895 : : .next = NEXT(next_qia_destroy_attr,
3896 : : NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
3897 : : .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
3898 : : args.ia_destroy.action_id)),
3899 : : .call = parse_qia_destroy,
3900 : : },
3901 : : [QUEUE_INDIRECT_ACTION_QUERY_UPDATE] = {
3902 : : .name = "query_update",
3903 : : .help = "indirect query [and|or] update action",
3904 : : .next = NEXT(next_qia_qu_attr, NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
3905 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.ia.action_id)),
3906 : : .call = parse_qia
3907 : : },
3908 : : [QUEUE_INDIRECT_ACTION_QU_MODE] = {
3909 : : .name = "mode",
3910 : : .help = "indirect query [and|or] update action",
3911 : : .next = NEXT(next_qia_qu_attr,
3912 : : NEXT_ENTRY(INDIRECT_ACTION_QU_MODE_NAME)),
3913 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.ia.qu_mode)),
3914 : : .call = parse_qia
3915 : : },
3916 : : /* Indirect action update arguments. */
3917 : : [QUEUE_INDIRECT_ACTION_UPDATE_POSTPONE] = {
3918 : : .name = "postpone",
3919 : : .help = "postpone update operation",
3920 : : .next = NEXT(next_qia_update_attr,
3921 : : NEXT_ENTRY(COMMON_BOOLEAN)),
3922 : : .args = ARGS(ARGS_ENTRY(struct buffer, postpone)),
3923 : : },
3924 : : /* Indirect action update arguments. */
3925 : : [QUEUE_INDIRECT_ACTION_QUERY_POSTPONE] = {
3926 : : .name = "postpone",
3927 : : .help = "postpone query operation",
3928 : : .next = NEXT(next_qia_query_attr,
3929 : : NEXT_ENTRY(COMMON_BOOLEAN)),
3930 : : .args = ARGS(ARGS_ENTRY(struct buffer, postpone)),
3931 : : },
3932 : : /* Indirect action create arguments. */
3933 : : [QUEUE_INDIRECT_ACTION_CREATE_ID] = {
3934 : : .name = "action_id",
3935 : : .help = "specify a indirect action id to create",
3936 : : .next = NEXT(next_qia_create_attr,
3937 : : NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
3938 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
3939 : : },
3940 : : [QUEUE_INDIRECT_ACTION_INGRESS] = {
3941 : : .name = "ingress",
3942 : : .help = "affect rule to ingress",
3943 : : .next = NEXT(next_qia_create_attr),
3944 : : .call = parse_qia,
3945 : : },
3946 : : [QUEUE_INDIRECT_ACTION_EGRESS] = {
3947 : : .name = "egress",
3948 : : .help = "affect rule to egress",
3949 : : .next = NEXT(next_qia_create_attr),
3950 : : .call = parse_qia,
3951 : : },
3952 : : [QUEUE_INDIRECT_ACTION_TRANSFER] = {
3953 : : .name = "transfer",
3954 : : .help = "affect rule to transfer",
3955 : : .next = NEXT(next_qia_create_attr),
3956 : : .call = parse_qia,
3957 : : },
3958 : : [QUEUE_INDIRECT_ACTION_CREATE_POSTPONE] = {
3959 : : .name = "postpone",
3960 : : .help = "postpone create operation",
3961 : : .next = NEXT(next_qia_create_attr,
3962 : : NEXT_ENTRY(COMMON_BOOLEAN)),
3963 : : .args = ARGS(ARGS_ENTRY(struct buffer, postpone)),
3964 : : },
3965 : : [QUEUE_INDIRECT_ACTION_SPEC] = {
3966 : : .name = "action",
3967 : : .help = "specify action to create indirect handle",
3968 : : .next = NEXT(next_action),
3969 : : },
3970 : : [QUEUE_INDIRECT_ACTION_LIST] = {
3971 : : .name = "list",
3972 : : .help = "specify actions for indirect handle list",
3973 : : .next = NEXT(NEXT_ENTRY(ACTIONS, END)),
3974 : : .call = parse_qia,
3975 : : },
3976 : : /* Top-level command. */
3977 : : [PUSH] = {
3978 : : .name = "push",
3979 : : .help = "push enqueued operations",
3980 : : .next = NEXT(NEXT_ENTRY(PUSH_QUEUE), NEXT_ENTRY(COMMON_PORT_ID)),
3981 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3982 : : .call = parse_push,
3983 : : },
3984 : : /* Sub-level commands. */
3985 : : [PUSH_QUEUE] = {
3986 : : .name = "queue",
3987 : : .help = "specify queue id",
3988 : : .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(COMMON_QUEUE_ID)),
3989 : : .args = ARGS(ARGS_ENTRY(struct buffer, queue)),
3990 : : },
3991 : : /* Top-level command. */
3992 : : [PULL] = {
3993 : : .name = "pull",
3994 : : .help = "pull flow operations results",
3995 : : .next = NEXT(NEXT_ENTRY(PULL_QUEUE), NEXT_ENTRY(COMMON_PORT_ID)),
3996 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3997 : : .call = parse_pull,
3998 : : },
3999 : : /* Sub-level commands. */
4000 : : [PULL_QUEUE] = {
4001 : : .name = "queue",
4002 : : .help = "specify queue id",
4003 : : .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(COMMON_QUEUE_ID)),
4004 : : .args = ARGS(ARGS_ENTRY(struct buffer, queue)),
4005 : : },
4006 : : /* Top-level command. */
4007 : : [HASH] = {
4008 : : .name = "hash",
4009 : : .help = "calculate hash for a given pattern in a given template table",
4010 : : .next = NEXT(next_hash_subcmd, NEXT_ENTRY(COMMON_PORT_ID)),
4011 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
4012 : : .call = parse_hash,
4013 : : },
4014 : : /* Sub-level commands. */
4015 : : [HASH_CALC_TABLE] = {
4016 : : .name = "template_table",
4017 : : .help = "specify table id",
4018 : : .next = NEXT(NEXT_ENTRY(HASH_CALC_PATTERN_INDEX),
4019 : : NEXT_ENTRY(COMMON_TABLE_ID)),
4020 : : .args = ARGS(ARGS_ENTRY(struct buffer,
4021 : : args.vc.table_id)),
4022 : : .call = parse_hash,
4023 : : },
4024 : : [HASH_CALC_ENCAP] = {
4025 : : .name = "encap",
4026 : : .help = "calculates encap hash",
4027 : : .next = NEXT(next_hash_encap_dest_subcmd),
4028 : : .call = parse_hash,
4029 : : },
4030 : : [HASH_CALC_PATTERN_INDEX] = {
4031 : : .name = "pattern_template",
4032 : : .help = "specify pattern template id",
4033 : : .next = NEXT(NEXT_ENTRY(ITEM_PATTERN),
4034 : : NEXT_ENTRY(COMMON_UNSIGNED)),
4035 : : .args = ARGS(ARGS_ENTRY(struct buffer,
4036 : : args.vc.pat_templ_id)),
4037 : : .call = parse_hash,
4038 : : },
4039 : : [ENCAP_HASH_FIELD_SRC_PORT] = {
4040 : : .name = "hash_field_sport",
4041 : : .help = "the encap hash field is src port",
4042 : : .next = NEXT(NEXT_ENTRY(ITEM_PATTERN)),
4043 : : .call = parse_hash,
4044 : : },
4045 : : [ENCAP_HASH_FIELD_GRE_FLOW_ID] = {
4046 : : .name = "hash_field_flow_id",
4047 : : .help = "the encap hash field is NVGRE flow id",
4048 : : .next = NEXT(NEXT_ENTRY(ITEM_PATTERN)),
4049 : : .call = parse_hash,
4050 : : },
4051 : : /* Top-level command. */
4052 : : [INDIRECT_ACTION] = {
4053 : : .name = "indirect_action",
4054 : : .type = "{command} {port_id} [{arg} [...]]",
4055 : : .help = "manage indirect actions",
4056 : : .next = NEXT(next_ia_subcmd, NEXT_ENTRY(COMMON_PORT_ID)),
4057 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
4058 : : .call = parse_ia,
4059 : : },
4060 : : /* Sub-level commands. */
4061 : : [INDIRECT_ACTION_CREATE] = {
4062 : : .name = "create",
4063 : : .help = "create indirect action",
4064 : : .next = NEXT(next_ia_create_attr),
4065 : : .call = parse_ia,
4066 : : },
4067 : : [INDIRECT_ACTION_UPDATE] = {
4068 : : .name = "update",
4069 : : .help = "update indirect action",
4070 : : .next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_SPEC),
4071 : : NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
4072 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
4073 : : .call = parse_ia,
4074 : : },
4075 : : [INDIRECT_ACTION_DESTROY] = {
4076 : : .name = "destroy",
4077 : : .help = "destroy indirect action",
4078 : : .next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_DESTROY_ID)),
4079 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
4080 : : .call = parse_ia_destroy,
4081 : : },
4082 : : [INDIRECT_ACTION_QUERY] = {
4083 : : .name = "query",
4084 : : .help = "query indirect action",
4085 : : .next = NEXT(NEXT_ENTRY(END),
4086 : : NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
4087 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.ia.action_id)),
4088 : : .call = parse_ia,
4089 : : },
4090 : : [INDIRECT_ACTION_QUERY_UPDATE] = {
4091 : : .name = "query_update",
4092 : : .help = "query [and|or] update",
4093 : : .next = NEXT(next_ia_qu_attr, NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
4094 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.ia.action_id)),
4095 : : .call = parse_ia
4096 : : },
4097 : : [INDIRECT_ACTION_QU_MODE] = {
4098 : : .name = "mode",
4099 : : .help = "query_update mode",
4100 : : .next = NEXT(next_ia_qu_attr,
4101 : : NEXT_ENTRY(INDIRECT_ACTION_QU_MODE_NAME)),
4102 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.ia.qu_mode)),
4103 : : .call = parse_ia,
4104 : : },
4105 : : [INDIRECT_ACTION_QU_MODE_NAME] = {
4106 : : .name = "mode_name",
4107 : : .help = "query-update mode name",
4108 : : .call = parse_qu_mode_name,
4109 : : .comp = comp_qu_mode_name,
4110 : : },
4111 : : [VALIDATE] = {
4112 : : .name = "validate",
4113 : : .help = "check whether a flow rule can be created",
4114 : : .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_PORT_ID)),
4115 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
4116 : : .call = parse_vc,
4117 : : },
4118 : : [CREATE] = {
4119 : : .name = "create",
4120 : : .help = "create a flow rule",
4121 : : .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_PORT_ID)),
4122 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
4123 : : .call = parse_vc,
4124 : : },
4125 : : [DESTROY] = {
4126 : : .name = "destroy",
4127 : : .help = "destroy specific flow rules",
4128 : : .next = NEXT(next_destroy_attr,
4129 : : NEXT_ENTRY(COMMON_PORT_ID)),
4130 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
4131 : : .call = parse_destroy,
4132 : : },
4133 : : [UPDATE] = {
4134 : : .name = "update",
4135 : : .help = "update a flow rule with new actions",
4136 : : .next = NEXT(NEXT_ENTRY(VC_IS_USER_ID, END),
4137 : : NEXT_ENTRY(ACTIONS),
4138 : : NEXT_ENTRY(COMMON_RULE_ID),
4139 : : NEXT_ENTRY(COMMON_PORT_ID)),
4140 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.rule_id),
4141 : : ARGS_ENTRY(struct buffer, port)),
4142 : : .call = parse_vc,
4143 : : },
4144 : : [FLUSH] = {
4145 : : .name = "flush",
4146 : : .help = "destroy all flow rules",
4147 : : .next = NEXT(NEXT_ENTRY(COMMON_PORT_ID)),
4148 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
4149 : : .call = parse_flush,
4150 : : },
4151 : : [DUMP] = {
4152 : : .name = "dump",
4153 : : .help = "dump single/all flow rules to file",
4154 : : .next = NEXT(next_dump_subcmd, NEXT_ENTRY(COMMON_PORT_ID)),
4155 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
4156 : : .call = parse_dump,
4157 : : },
4158 : : [QUERY] = {
4159 : : .name = "query",
4160 : : .help = "query an existing flow rule",
4161 : : .next = NEXT(next_query_attr, NEXT_ENTRY(QUERY_ACTION),
4162 : : NEXT_ENTRY(COMMON_RULE_ID),
4163 : : NEXT_ENTRY(COMMON_PORT_ID)),
4164 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.query.action.type),
4165 : : ARGS_ENTRY(struct buffer, args.query.rule),
4166 : : ARGS_ENTRY(struct buffer, port)),
4167 : : .call = parse_query,
4168 : : },
4169 : : [LIST] = {
4170 : : .name = "list",
4171 : : .help = "list existing flow rules",
4172 : : .next = NEXT(next_list_attr, NEXT_ENTRY(COMMON_PORT_ID)),
4173 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
4174 : : .call = parse_list,
4175 : : },
4176 : : [AGED] = {
4177 : : .name = "aged",
4178 : : .help = "list and destroy aged flows",
4179 : : .next = NEXT(next_aged_attr, NEXT_ENTRY(COMMON_PORT_ID)),
4180 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
4181 : : .call = parse_aged,
4182 : : },
4183 : : [ISOLATE] = {
4184 : : .name = "isolate",
4185 : : .help = "restrict ingress traffic to the defined flow rules",
4186 : : .next = NEXT(NEXT_ENTRY(COMMON_BOOLEAN),
4187 : : NEXT_ENTRY(COMMON_PORT_ID)),
4188 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.isolate.set),
4189 : : ARGS_ENTRY(struct buffer, port)),
4190 : : .call = parse_isolate,
4191 : : },
4192 : : [FLEX] = {
4193 : : .name = "flex_item",
4194 : : .help = "flex item API",
4195 : : .next = NEXT(next_flex_item),
4196 : : .call = parse_flex,
4197 : : },
4198 : : [FLEX_ITEM_CREATE] = {
4199 : : .name = "create",
4200 : : .help = "flex item create",
4201 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.flex.filename),
4202 : : ARGS_ENTRY(struct buffer, args.flex.token),
4203 : : ARGS_ENTRY(struct buffer, port)),
4204 : : .next = NEXT(NEXT_ENTRY(COMMON_FILE_PATH),
4205 : : NEXT_ENTRY(COMMON_FLEX_TOKEN),
4206 : : NEXT_ENTRY(COMMON_PORT_ID)),
4207 : : .call = parse_flex
4208 : : },
4209 : : [FLEX_ITEM_DESTROY] = {
4210 : : .name = "destroy",
4211 : : .help = "flex item destroy",
4212 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.flex.token),
4213 : : ARGS_ENTRY(struct buffer, port)),
4214 : : .next = NEXT(NEXT_ENTRY(COMMON_FLEX_TOKEN),
4215 : : NEXT_ENTRY(COMMON_PORT_ID)),
4216 : : .call = parse_flex
4217 : : },
4218 : : [TUNNEL] = {
4219 : : .name = "tunnel",
4220 : : .help = "new tunnel API",
4221 : : .next = NEXT(NEXT_ENTRY
4222 : : (TUNNEL_CREATE, TUNNEL_LIST, TUNNEL_DESTROY)),
4223 : : .call = parse_tunnel,
4224 : : },
4225 : : /* Tunnel arguments. */
4226 : : [TUNNEL_CREATE] = {
4227 : : .name = "create",
4228 : : .help = "create new tunnel object",
4229 : : .next = NEXT(NEXT_ENTRY(TUNNEL_CREATE_TYPE),
4230 : : NEXT_ENTRY(COMMON_PORT_ID)),
4231 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
4232 : : .call = parse_tunnel,
4233 : : },
4234 : : [TUNNEL_CREATE_TYPE] = {
4235 : : .name = "type",
4236 : : .help = "create new tunnel",
4237 : : .next = NEXT(NEXT_ENTRY(COMMON_FILE_PATH)),
4238 : : .args = ARGS(ARGS_ENTRY(struct tunnel_ops, type)),
4239 : : .call = parse_tunnel,
4240 : : },
4241 : : [TUNNEL_DESTROY] = {
4242 : : .name = "destroy",
4243 : : .help = "destroy tunnel",
4244 : : .next = NEXT(NEXT_ENTRY(TUNNEL_DESTROY_ID),
4245 : : NEXT_ENTRY(COMMON_PORT_ID)),
4246 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
4247 : : .call = parse_tunnel,
4248 : : },
4249 : : [TUNNEL_DESTROY_ID] = {
4250 : : .name = "id",
4251 : : .help = "tunnel identifier to destroy",
4252 : : .next = NEXT(NEXT_ENTRY(COMMON_UNSIGNED)),
4253 : : .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
4254 : : .call = parse_tunnel,
4255 : : },
4256 : : [TUNNEL_LIST] = {
4257 : : .name = "list",
4258 : : .help = "list existing tunnels",
4259 : : .next = NEXT(NEXT_ENTRY(COMMON_PORT_ID)),
4260 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
4261 : : .call = parse_tunnel,
4262 : : },
4263 : : /* Destroy arguments. */
4264 : : [DESTROY_RULE] = {
4265 : : .name = "rule",
4266 : : .help = "specify a rule identifier",
4267 : : .next = NEXT(next_destroy_attr, NEXT_ENTRY(COMMON_RULE_ID)),
4268 : : .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.destroy.rule)),
4269 : : .call = parse_destroy,
4270 : : },
4271 : : [DESTROY_IS_USER_ID] = {
4272 : : .name = "user_id",
4273 : : .help = "rule identifier is user-id",
4274 : : .next = NEXT(next_destroy_attr),
4275 : : .call = parse_destroy,
4276 : : },
4277 : : /* Dump arguments. */
4278 : : [DUMP_ALL] = {
4279 : : .name = "all",
4280 : : .help = "dump all",
4281 : : .next = NEXT(next_dump_attr),
4282 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file)),
4283 : : .call = parse_dump,
4284 : : },
4285 : : [DUMP_ONE] = {
4286 : : .name = "rule",
4287 : : .help = "dump one rule",
4288 : : .next = NEXT(next_dump_attr, NEXT_ENTRY(COMMON_RULE_ID)),
4289 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file),
4290 : : ARGS_ENTRY(struct buffer, args.dump.rule)),
4291 : : .call = parse_dump,
4292 : : },
4293 : : [DUMP_IS_USER_ID] = {
4294 : : .name = "user_id",
4295 : : .help = "rule identifier is user-id",
4296 : : .next = NEXT(next_dump_subcmd),
4297 : : .call = parse_dump,
4298 : : },
4299 : : /* Query arguments. */
4300 : : [QUERY_ACTION] = {
4301 : : .name = "{action}",
4302 : : .type = "ACTION",
4303 : : .help = "action to query, must be part of the rule",
4304 : : .call = parse_action,
4305 : : .comp = comp_action,
4306 : : },
4307 : : [QUERY_IS_USER_ID] = {
4308 : : .name = "user_id",
4309 : : .help = "rule identifier is user-id",
4310 : : .next = NEXT(next_query_attr),
4311 : : .call = parse_query,
4312 : : },
4313 : : /* List arguments. */
4314 : : [LIST_GROUP] = {
4315 : : .name = "group",
4316 : : .help = "specify a group",
4317 : : .next = NEXT(next_list_attr, NEXT_ENTRY(COMMON_GROUP_ID)),
4318 : : .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.list.group)),
4319 : : .call = parse_list,
4320 : : },
4321 : : [AGED_DESTROY] = {
4322 : : .name = "destroy",
4323 : : .help = "specify aged flows need be destroyed",
4324 : : .call = parse_aged,
4325 : : .comp = comp_none,
4326 : : },
4327 : : /* Validate/create attributes. */
4328 : : [VC_GROUP] = {
4329 : : .name = "group",
4330 : : .help = "specify a group",
4331 : : .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_GROUP_ID)),
4332 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, group)),
4333 : : .call = parse_vc,
4334 : : },
4335 : : [VC_PRIORITY] = {
4336 : : .name = "priority",
4337 : : .help = "specify a priority level",
4338 : : .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_PRIORITY_LEVEL)),
4339 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, priority)),
4340 : : .call = parse_vc,
4341 : : },
4342 : : [VC_INGRESS] = {
4343 : : .name = "ingress",
4344 : : .help = "affect rule to ingress",
4345 : : .next = NEXT(next_vc_attr),
4346 : : .call = parse_vc,
4347 : : },
4348 : : [VC_EGRESS] = {
4349 : : .name = "egress",
4350 : : .help = "affect rule to egress",
4351 : : .next = NEXT(next_vc_attr),
4352 : : .call = parse_vc,
4353 : : },
4354 : : [VC_TRANSFER] = {
4355 : : .name = "transfer",
4356 : : .help = "apply rule directly to endpoints found in pattern",
4357 : : .next = NEXT(next_vc_attr),
4358 : : .call = parse_vc,
4359 : : },
4360 : : [VC_TUNNEL_SET] = {
4361 : : .name = "tunnel_set",
4362 : : .help = "tunnel steer rule",
4363 : : .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_UNSIGNED)),
4364 : : .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
4365 : : .call = parse_vc,
4366 : : },
4367 : : [VC_TUNNEL_MATCH] = {
4368 : : .name = "tunnel_match",
4369 : : .help = "tunnel match rule",
4370 : : .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_UNSIGNED)),
4371 : : .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
4372 : : .call = parse_vc,
4373 : : },
4374 : : [VC_USER_ID] = {
4375 : : .name = "user_id",
4376 : : .help = "specify a user id to create",
4377 : : .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_UNSIGNED)),
4378 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.user_id)),
4379 : : .call = parse_vc,
4380 : : },
4381 : : [VC_IS_USER_ID] = {
4382 : : .name = "user_id",
4383 : : .help = "rule identifier is user-id",
4384 : : .call = parse_vc,
4385 : : },
4386 : : /* Validate/create pattern. */
4387 : : [ITEM_PATTERN] = {
4388 : : .name = "pattern",
4389 : : .help = "submit a list of pattern items",
4390 : : .next = NEXT(next_item),
4391 : : .call = parse_vc,
4392 : : },
4393 : : [ITEM_PARAM_IS] = {
4394 : : .name = "is",
4395 : : .help = "match value perfectly (with full bit-mask)",
4396 : : .call = parse_vc_spec,
4397 : : },
4398 : : [ITEM_PARAM_SPEC] = {
4399 : : .name = "spec",
4400 : : .help = "match value according to configured bit-mask",
4401 : : .call = parse_vc_spec,
4402 : : },
4403 : : [ITEM_PARAM_LAST] = {
4404 : : .name = "last",
4405 : : .help = "specify upper bound to establish a range",
4406 : : .call = parse_vc_spec,
4407 : : },
4408 : : [ITEM_PARAM_MASK] = {
4409 : : .name = "mask",
4410 : : .help = "specify bit-mask with relevant bits set to one",
4411 : : .call = parse_vc_spec,
4412 : : },
4413 : : [ITEM_PARAM_PREFIX] = {
4414 : : .name = "prefix",
4415 : : .help = "generate bit-mask from a prefix length",
4416 : : .call = parse_vc_spec,
4417 : : },
4418 : : [ITEM_NEXT] = {
4419 : : .name = "/",
4420 : : .help = "specify next pattern item",
4421 : : .next = NEXT(next_item),
4422 : : },
4423 : : [ITEM_END] = {
4424 : : .name = "end",
4425 : : .help = "end list of pattern items",
4426 : : .priv = PRIV_ITEM(END, 0),
4427 : : .next = NEXT(NEXT_ENTRY(ACTIONS, END)),
4428 : : .call = parse_vc,
4429 : : },
4430 : : [ITEM_VOID] = {
4431 : : .name = "void",
4432 : : .help = "no-op pattern item",
4433 : : .priv = PRIV_ITEM(VOID, 0),
4434 : : .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
4435 : : .call = parse_vc,
4436 : : },
4437 : : [ITEM_INVERT] = {
4438 : : .name = "invert",
4439 : : .help = "perform actions when pattern does not match",
4440 : : .priv = PRIV_ITEM(INVERT, 0),
4441 : : .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
4442 : : .call = parse_vc,
4443 : : },
4444 : : [ITEM_ANY] = {
4445 : : .name = "any",
4446 : : .help = "match any protocol for the current layer",
4447 : : .priv = PRIV_ITEM(ANY, sizeof(struct rte_flow_item_any)),
4448 : : .next = NEXT(item_any),
4449 : : .call = parse_vc,
4450 : : },
4451 : : [ITEM_ANY_NUM] = {
4452 : : .name = "num",
4453 : : .help = "number of layers covered",
4454 : : .next = NEXT(item_any, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
4455 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_any, num)),
4456 : : },
4457 : : [ITEM_PORT_ID] = {
4458 : : .name = "port_id",
4459 : : .help = "match traffic from/to a given DPDK port ID",
4460 : : .priv = PRIV_ITEM(PORT_ID,
4461 : : sizeof(struct rte_flow_item_port_id)),
4462 : : .next = NEXT(item_port_id),
4463 : : .call = parse_vc,
4464 : : },
4465 : : [ITEM_PORT_ID_ID] = {
4466 : : .name = "id",
4467 : : .help = "DPDK port ID",
4468 : : .next = NEXT(item_port_id, NEXT_ENTRY(COMMON_UNSIGNED),
4469 : : item_param),
4470 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port_id, id)),
4471 : : },
4472 : : [ITEM_MARK] = {
4473 : : .name = "mark",
4474 : : .help = "match traffic against value set in previously matched rule",
4475 : : .priv = PRIV_ITEM(MARK, sizeof(struct rte_flow_item_mark)),
4476 : : .next = NEXT(item_mark),
4477 : : .call = parse_vc,
4478 : : },
4479 : : [ITEM_MARK_ID] = {
4480 : : .name = "id",
4481 : : .help = "Integer value to match against",
4482 : : .next = NEXT(item_mark, NEXT_ENTRY(COMMON_UNSIGNED),
4483 : : item_param),
4484 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_mark, id)),
4485 : : },
4486 : : [ITEM_RAW] = {
4487 : : .name = "raw",
4488 : : .help = "match an arbitrary byte string",
4489 : : .priv = PRIV_ITEM(RAW, ITEM_RAW_SIZE),
4490 : : .next = NEXT(item_raw),
4491 : : .call = parse_vc,
4492 : : },
4493 : : [ITEM_RAW_RELATIVE] = {
4494 : : .name = "relative",
4495 : : .help = "look for pattern after the previous item",
4496 : : .next = NEXT(item_raw, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
4497 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
4498 : : relative, 1)),
4499 : : },
4500 : : [ITEM_RAW_SEARCH] = {
4501 : : .name = "search",
4502 : : .help = "search pattern from offset (see also limit)",
4503 : : .next = NEXT(item_raw, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
4504 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
4505 : : search, 1)),
4506 : : },
4507 : : [ITEM_RAW_OFFSET] = {
4508 : : .name = "offset",
4509 : : .help = "absolute or relative offset for pattern",
4510 : : .next = NEXT(item_raw, NEXT_ENTRY(COMMON_INTEGER), item_param),
4511 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, offset)),
4512 : : },
4513 : : [ITEM_RAW_LIMIT] = {
4514 : : .name = "limit",
4515 : : .help = "search area limit for start of pattern",
4516 : : .next = NEXT(item_raw, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
4517 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, limit)),
4518 : : },
4519 : : [ITEM_RAW_PATTERN] = {
4520 : : .name = "pattern",
4521 : : .help = "byte string to look for",
4522 : : .next = NEXT(item_raw,
4523 : : NEXT_ENTRY(COMMON_STRING),
4524 : : NEXT_ENTRY(ITEM_PARAM_IS,
4525 : : ITEM_PARAM_SPEC,
4526 : : ITEM_PARAM_MASK)),
4527 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern),
4528 : : ARGS_ENTRY(struct rte_flow_item_raw, length),
4529 : : ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw),
4530 : : ITEM_RAW_PATTERN_SIZE)),
4531 : : },
4532 : : [ITEM_RAW_PATTERN_HEX] = {
4533 : : .name = "pattern_hex",
4534 : : .help = "hex string to look for",
4535 : : .next = NEXT(item_raw,
4536 : : NEXT_ENTRY(COMMON_HEX),
4537 : : NEXT_ENTRY(ITEM_PARAM_IS,
4538 : : ITEM_PARAM_SPEC,
4539 : : ITEM_PARAM_MASK)),
4540 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern),
4541 : : ARGS_ENTRY(struct rte_flow_item_raw, length),
4542 : : ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw),
4543 : : ITEM_RAW_PATTERN_SIZE)),
4544 : : },
4545 : : [ITEM_ETH] = {
4546 : : .name = "eth",
4547 : : .help = "match Ethernet header",
4548 : : .priv = PRIV_ITEM(ETH, sizeof(struct rte_flow_item_eth)),
4549 : : .next = NEXT(item_eth),
4550 : : .call = parse_vc,
4551 : : },
4552 : : [ITEM_ETH_DST] = {
4553 : : .name = "dst",
4554 : : .help = "destination MAC",
4555 : : .next = NEXT(item_eth, NEXT_ENTRY(COMMON_MAC_ADDR), item_param),
4556 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, hdr.dst_addr)),
4557 : : },
4558 : : [ITEM_ETH_SRC] = {
4559 : : .name = "src",
4560 : : .help = "source MAC",
4561 : : .next = NEXT(item_eth, NEXT_ENTRY(COMMON_MAC_ADDR), item_param),
4562 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, hdr.src_addr)),
4563 : : },
4564 : : [ITEM_ETH_TYPE] = {
4565 : : .name = "type",
4566 : : .help = "EtherType",
4567 : : .next = NEXT(item_eth, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
4568 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, hdr.ether_type)),
4569 : : },
4570 : : [ITEM_ETH_HAS_VLAN] = {
4571 : : .name = "has_vlan",
4572 : : .help = "packet header contains VLAN",
4573 : : .next = NEXT(item_eth, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
4574 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_eth,
4575 : : has_vlan, 1)),
4576 : : },
4577 : : [ITEM_VLAN] = {
4578 : : .name = "vlan",
4579 : : .help = "match 802.1Q/ad VLAN tag",
4580 : : .priv = PRIV_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)),
4581 : : .next = NEXT(item_vlan),
4582 : : .call = parse_vc,
4583 : : },
4584 : : [ITEM_VLAN_TCI] = {
4585 : : .name = "tci",
4586 : : .help = "tag control information",
4587 : : .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
4588 : : item_param),
4589 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, hdr.vlan_tci)),
4590 : : },
4591 : : [ITEM_VLAN_PCP] = {
4592 : : .name = "pcp",
4593 : : .help = "priority code point",
4594 : : .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
4595 : : item_param),
4596 : : .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
4597 : : hdr.vlan_tci, "\xe0\x00")),
4598 : : },
4599 : : [ITEM_VLAN_DEI] = {
4600 : : .name = "dei",
4601 : : .help = "drop eligible indicator",
4602 : : .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
4603 : : item_param),
4604 : : .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
4605 : : hdr.vlan_tci, "\x10\x00")),
4606 : : },
4607 : : [ITEM_VLAN_VID] = {
4608 : : .name = "vid",
4609 : : .help = "VLAN identifier",
4610 : : .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
4611 : : item_param),
4612 : : .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
4613 : : hdr.vlan_tci, "\x0f\xff")),
4614 : : },
4615 : : [ITEM_VLAN_INNER_TYPE] = {
4616 : : .name = "inner_type",
4617 : : .help = "inner EtherType",
4618 : : .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
4619 : : item_param),
4620 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan,
4621 : : hdr.eth_proto)),
4622 : : },
4623 : : [ITEM_VLAN_HAS_MORE_VLAN] = {
4624 : : .name = "has_more_vlan",
4625 : : .help = "packet header contains another VLAN",
4626 : : .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
4627 : : item_param),
4628 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vlan,
4629 : : has_more_vlan, 1)),
4630 : : },
4631 : : [ITEM_IPV4] = {
4632 : : .name = "ipv4",
4633 : : .help = "match IPv4 header",
4634 : : .priv = PRIV_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)),
4635 : : .next = NEXT(item_ipv4),
4636 : : .call = parse_vc,
4637 : : },
4638 : : [ITEM_IPV4_VER_IHL] = {
4639 : : .name = "version_ihl",
4640 : : .help = "match header length",
4641 : : .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
4642 : : item_param),
4643 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ipv4,
4644 : : hdr.version_ihl)),
4645 : : },
4646 : : [ITEM_IPV4_TOS] = {
4647 : : .name = "tos",
4648 : : .help = "type of service",
4649 : : .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
4650 : : item_param),
4651 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
4652 : : hdr.type_of_service)),
4653 : : },
4654 : : [ITEM_IPV4_LENGTH] = {
4655 : : .name = "length",
4656 : : .help = "total length",
4657 : : .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
4658 : : item_param),
4659 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
4660 : : hdr.total_length)),
4661 : : },
4662 : : [ITEM_IPV4_ID] = {
4663 : : .name = "packet_id",
4664 : : .help = "fragment packet id",
4665 : : .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
4666 : : item_param),
4667 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
4668 : : hdr.packet_id)),
4669 : : },
4670 : : [ITEM_IPV4_FRAGMENT_OFFSET] = {
4671 : : .name = "fragment_offset",
4672 : : .help = "fragmentation flags and fragment offset",
4673 : : .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
4674 : : item_param),
4675 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
4676 : : hdr.fragment_offset)),
4677 : : },
4678 : : [ITEM_IPV4_TTL] = {
4679 : : .name = "ttl",
4680 : : .help = "time to live",
4681 : : .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
4682 : : item_param),
4683 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
4684 : : hdr.time_to_live)),
4685 : : },
4686 : : [ITEM_IPV4_PROTO] = {
4687 : : .name = "proto",
4688 : : .help = "next protocol ID",
4689 : : .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
4690 : : item_param),
4691 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
4692 : : hdr.next_proto_id)),
4693 : : },
4694 : : [ITEM_IPV4_SRC] = {
4695 : : .name = "src",
4696 : : .help = "source address",
4697 : : .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
4698 : : item_param),
4699 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
4700 : : hdr.src_addr)),
4701 : : },
4702 : : [ITEM_IPV4_DST] = {
4703 : : .name = "dst",
4704 : : .help = "destination address",
4705 : : .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
4706 : : item_param),
4707 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
4708 : : hdr.dst_addr)),
4709 : : },
4710 : : [ITEM_IPV6] = {
4711 : : .name = "ipv6",
4712 : : .help = "match IPv6 header",
4713 : : .priv = PRIV_ITEM(IPV6, sizeof(struct rte_flow_item_ipv6)),
4714 : : .next = NEXT(item_ipv6),
4715 : : .call = parse_vc,
4716 : : },
4717 : : [ITEM_IPV6_TC] = {
4718 : : .name = "tc",
4719 : : .help = "traffic class",
4720 : : .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
4721 : : item_param),
4722 : : .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
4723 : : hdr.vtc_flow,
4724 : : "\x0f\xf0\x00\x00")),
4725 : : },
4726 : : [ITEM_IPV6_FLOW] = {
4727 : : .name = "flow",
4728 : : .help = "flow label",
4729 : : .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
4730 : : item_param),
4731 : : .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
4732 : : hdr.vtc_flow,
4733 : : "\x00\x0f\xff\xff")),
4734 : : },
4735 : : [ITEM_IPV6_LEN] = {
4736 : : .name = "length",
4737 : : .help = "payload length",
4738 : : .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
4739 : : item_param),
4740 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
4741 : : hdr.payload_len)),
4742 : : },
4743 : : [ITEM_IPV6_PROTO] = {
4744 : : .name = "proto",
4745 : : .help = "protocol (next header)",
4746 : : .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
4747 : : item_param),
4748 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
4749 : : hdr.proto)),
4750 : : },
4751 : : [ITEM_IPV6_HOP] = {
4752 : : .name = "hop",
4753 : : .help = "hop limit",
4754 : : .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
4755 : : item_param),
4756 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
4757 : : hdr.hop_limits)),
4758 : : },
4759 : : [ITEM_IPV6_SRC] = {
4760 : : .name = "src",
4761 : : .help = "source address",
4762 : : .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_IPV6_ADDR),
4763 : : item_param),
4764 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
4765 : : hdr.src_addr)),
4766 : : },
4767 : : [ITEM_IPV6_DST] = {
4768 : : .name = "dst",
4769 : : .help = "destination address",
4770 : : .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_IPV6_ADDR),
4771 : : item_param),
4772 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
4773 : : hdr.dst_addr)),
4774 : : },
4775 : : [ITEM_IPV6_HAS_FRAG_EXT] = {
4776 : : .name = "has_frag_ext",
4777 : : .help = "fragment packet attribute",
4778 : : .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
4779 : : item_param),
4780 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_ipv6,
4781 : : has_frag_ext, 1)),
4782 : : },
4783 : : [ITEM_IPV6_ROUTING_EXT] = {
4784 : : .name = "ipv6_routing_ext",
4785 : : .help = "match IPv6 routing extension header",
4786 : : .priv = PRIV_ITEM(IPV6_ROUTING_EXT,
4787 : : sizeof(struct rte_flow_item_ipv6_routing_ext)),
4788 : : .next = NEXT(item_ipv6_routing_ext),
4789 : : .call = parse_vc,
4790 : : },
4791 : : [ITEM_IPV6_ROUTING_EXT_TYPE] = {
4792 : : .name = "ext_type",
4793 : : .help = "match IPv6 routing extension header type",
4794 : : .next = NEXT(item_ipv6_routing_ext, NEXT_ENTRY(COMMON_UNSIGNED),
4795 : : item_param),
4796 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_routing_ext,
4797 : : hdr.type)),
4798 : : },
4799 : : [ITEM_IPV6_ROUTING_EXT_NEXT_HDR] = {
4800 : : .name = "ext_next_hdr",
4801 : : .help = "match IPv6 routing extension header next header type",
4802 : : .next = NEXT(item_ipv6_routing_ext, NEXT_ENTRY(COMMON_UNSIGNED),
4803 : : item_param),
4804 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_routing_ext,
4805 : : hdr.next_hdr)),
4806 : : },
4807 : : [ITEM_IPV6_ROUTING_EXT_SEG_LEFT] = {
4808 : : .name = "ext_seg_left",
4809 : : .help = "match IPv6 routing extension header segment left",
4810 : : .next = NEXT(item_ipv6_routing_ext, NEXT_ENTRY(COMMON_UNSIGNED),
4811 : : item_param),
4812 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_routing_ext,
4813 : : hdr.segments_left)),
4814 : : },
4815 : : [ITEM_ICMP] = {
4816 : : .name = "icmp",
4817 : : .help = "match ICMP header",
4818 : : .priv = PRIV_ITEM(ICMP, sizeof(struct rte_flow_item_icmp)),
4819 : : .next = NEXT(item_icmp),
4820 : : .call = parse_vc,
4821 : : },
4822 : : [ITEM_ICMP_TYPE] = {
4823 : : .name = "type",
4824 : : .help = "ICMP packet type",
4825 : : .next = NEXT(item_icmp, NEXT_ENTRY(COMMON_UNSIGNED),
4826 : : item_param),
4827 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
4828 : : hdr.icmp_type)),
4829 : : },
4830 : : [ITEM_ICMP_CODE] = {
4831 : : .name = "code",
4832 : : .help = "ICMP packet code",
4833 : : .next = NEXT(item_icmp, NEXT_ENTRY(COMMON_UNSIGNED),
4834 : : item_param),
4835 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
4836 : : hdr.icmp_code)),
4837 : : },
4838 : : [ITEM_ICMP_IDENT] = {
4839 : : .name = "ident",
4840 : : .help = "ICMP packet identifier",
4841 : : .next = NEXT(item_icmp, NEXT_ENTRY(COMMON_UNSIGNED),
4842 : : item_param),
4843 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
4844 : : hdr.icmp_ident)),
4845 : : },
4846 : : [ITEM_ICMP_SEQ] = {
4847 : : .name = "seq",
4848 : : .help = "ICMP packet sequence number",
4849 : : .next = NEXT(item_icmp, NEXT_ENTRY(COMMON_UNSIGNED),
4850 : : item_param),
4851 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
4852 : : hdr.icmp_seq_nb)),
4853 : : },
4854 : : [ITEM_UDP] = {
4855 : : .name = "udp",
4856 : : .help = "match UDP header",
4857 : : .priv = PRIV_ITEM(UDP, sizeof(struct rte_flow_item_udp)),
4858 : : .next = NEXT(item_udp),
4859 : : .call = parse_vc,
4860 : : },
4861 : : [ITEM_UDP_SRC] = {
4862 : : .name = "src",
4863 : : .help = "UDP source port",
4864 : : .next = NEXT(item_udp, NEXT_ENTRY(COMMON_UNSIGNED),
4865 : : item_param),
4866 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
4867 : : hdr.src_port)),
4868 : : },
4869 : : [ITEM_UDP_DST] = {
4870 : : .name = "dst",
4871 : : .help = "UDP destination port",
4872 : : .next = NEXT(item_udp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
4873 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
4874 : : hdr.dst_port)),
4875 : : },
4876 : : [ITEM_TCP] = {
4877 : : .name = "tcp",
4878 : : .help = "match TCP header",
4879 : : .priv = PRIV_ITEM(TCP, sizeof(struct rte_flow_item_tcp)),
4880 : : .next = NEXT(item_tcp),
4881 : : .call = parse_vc,
4882 : : },
4883 : : [ITEM_TCP_SRC] = {
4884 : : .name = "src",
4885 : : .help = "TCP source port",
4886 : : .next = NEXT(item_tcp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
4887 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
4888 : : hdr.src_port)),
4889 : : },
4890 : : [ITEM_TCP_DST] = {
4891 : : .name = "dst",
4892 : : .help = "TCP destination port",
4893 : : .next = NEXT(item_tcp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
4894 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
4895 : : hdr.dst_port)),
4896 : : },
4897 : : [ITEM_TCP_FLAGS] = {
4898 : : .name = "flags",
4899 : : .help = "TCP flags",
4900 : : .next = NEXT(item_tcp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
4901 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
4902 : : hdr.tcp_flags)),
4903 : : },
4904 : : [ITEM_SCTP] = {
4905 : : .name = "sctp",
4906 : : .help = "match SCTP header",
4907 : : .priv = PRIV_ITEM(SCTP, sizeof(struct rte_flow_item_sctp)),
4908 : : .next = NEXT(item_sctp),
4909 : : .call = parse_vc,
4910 : : },
4911 : : [ITEM_SCTP_SRC] = {
4912 : : .name = "src",
4913 : : .help = "SCTP source port",
4914 : : .next = NEXT(item_sctp, NEXT_ENTRY(COMMON_UNSIGNED),
4915 : : item_param),
4916 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
4917 : : hdr.src_port)),
4918 : : },
4919 : : [ITEM_SCTP_DST] = {
4920 : : .name = "dst",
4921 : : .help = "SCTP destination port",
4922 : : .next = NEXT(item_sctp, NEXT_ENTRY(COMMON_UNSIGNED),
4923 : : item_param),
4924 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
4925 : : hdr.dst_port)),
4926 : : },
4927 : : [ITEM_SCTP_TAG] = {
4928 : : .name = "tag",
4929 : : .help = "validation tag",
4930 : : .next = NEXT(item_sctp, NEXT_ENTRY(COMMON_UNSIGNED),
4931 : : item_param),
4932 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
4933 : : hdr.tag)),
4934 : : },
4935 : : [ITEM_SCTP_CKSUM] = {
4936 : : .name = "cksum",
4937 : : .help = "checksum",
4938 : : .next = NEXT(item_sctp, NEXT_ENTRY(COMMON_UNSIGNED),
4939 : : item_param),
4940 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
4941 : : hdr.cksum)),
4942 : : },
4943 : : [ITEM_VXLAN] = {
4944 : : .name = "vxlan",
4945 : : .help = "match VXLAN header",
4946 : : .priv = PRIV_ITEM(VXLAN, sizeof(struct rte_flow_item_vxlan)),
4947 : : .next = NEXT(item_vxlan),
4948 : : .call = parse_vc,
4949 : : },
4950 : : [ITEM_VXLAN_VNI] = {
4951 : : .name = "vni",
4952 : : .help = "VXLAN identifier",
4953 : : .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
4954 : : item_param),
4955 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan, hdr.vni)),
4956 : : },
4957 : : [ITEM_VXLAN_FLAG_G] = {
4958 : : .name = "flag_g",
4959 : : .help = "VXLAN GBP bit",
4960 : : .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
4961 : : item_param),
4962 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vxlan,
4963 : : hdr.flag_g, 1)),
4964 : : },
4965 : : [ITEM_VXLAN_FLAG_VER] = {
4966 : : .name = "flag_ver",
4967 : : .help = "VXLAN GPE version",
4968 : : .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
4969 : : item_param),
4970 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vxlan,
4971 : : hdr.flag_ver, 2)),
4972 : : },
4973 : : [ITEM_VXLAN_FLAG_I] = {
4974 : : .name = "flag_i",
4975 : : .help = "VXLAN Instance bit",
4976 : : .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
4977 : : item_param),
4978 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vxlan,
4979 : : hdr.flag_i, 1)),
4980 : : },
4981 : : [ITEM_VXLAN_FLAG_P] = {
4982 : : .name = "flag_p",
4983 : : .help = "VXLAN GPE Next Protocol bit",
4984 : : .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
4985 : : item_param),
4986 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vxlan,
4987 : : hdr.flag_p, 1)),
4988 : : },
4989 : : [ITEM_VXLAN_FLAG_B] = {
4990 : : .name = "flag_b",
4991 : : .help = "VXLAN GPE Ingress-Replicated BUM",
4992 : : .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
4993 : : item_param),
4994 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vxlan,
4995 : : hdr.flag_b, 1)),
4996 : : },
4997 : : [ITEM_VXLAN_FLAG_O] = {
4998 : : .name = "flag_o",
4999 : : .help = "VXLAN GPE OAM Packet bit",
5000 : : .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
5001 : : item_param),
5002 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vxlan,
5003 : : hdr.flag_o, 1)),
5004 : : },
5005 : : [ITEM_VXLAN_FLAG_D] = {
5006 : : .name = "flag_d",
5007 : : .help = "VXLAN GBP Don't Learn bit",
5008 : : .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
5009 : : item_param),
5010 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vxlan,
5011 : : hdr.flag_d, 1)),
5012 : : },
5013 : : [ITEM_VXLAN_FLAG_A] = {
5014 : : .name = "flag_a",
5015 : : .help = "VXLAN GBP Applied bit",
5016 : : .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
5017 : : item_param),
5018 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vxlan,
5019 : : hdr.flag_a, 1)),
5020 : : },
5021 : : [ITEM_VXLAN_GBP_ID] = {
5022 : : .name = "group_policy_id",
5023 : : .help = "VXLAN GBP ID",
5024 : : .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
5025 : : item_param),
5026 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan,
5027 : : hdr.policy_id)),
5028 : : },
5029 : : [ITEM_VXLAN_GPE_PROTO] = {
5030 : : .name = "protocol",
5031 : : .help = "VXLAN GPE next protocol",
5032 : : .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
5033 : : item_param),
5034 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan,
5035 : : hdr.proto)),
5036 : : },
5037 : : [ITEM_VXLAN_FIRST_RSVD] = {
5038 : : .name = "first_rsvd",
5039 : : .help = "VXLAN rsvd0 first byte",
5040 : : .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
5041 : : item_param),
5042 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan,
5043 : : hdr.rsvd0[0])),
5044 : : },
5045 : : [ITEM_VXLAN_SECND_RSVD] = {
5046 : : .name = "second_rsvd",
5047 : : .help = "VXLAN rsvd0 second byte",
5048 : : .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
5049 : : item_param),
5050 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan,
5051 : : hdr.rsvd0[1])),
5052 : : },
5053 : : [ITEM_VXLAN_THIRD_RSVD] = {
5054 : : .name = "third_rsvd",
5055 : : .help = "VXLAN rsvd0 third byte",
5056 : : .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
5057 : : item_param),
5058 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan,
5059 : : hdr.rsvd0[2])),
5060 : : },
5061 : : [ITEM_VXLAN_LAST_RSVD] = {
5062 : : .name = "last_rsvd",
5063 : : .help = "VXLAN last reserved byte",
5064 : : .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
5065 : : item_param),
5066 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan,
5067 : : hdr.last_rsvd)),
5068 : : },
5069 : : [ITEM_E_TAG] = {
5070 : : .name = "e_tag",
5071 : : .help = "match E-Tag header",
5072 : : .priv = PRIV_ITEM(E_TAG, sizeof(struct rte_flow_item_e_tag)),
5073 : : .next = NEXT(item_e_tag),
5074 : : .call = parse_vc,
5075 : : },
5076 : : [ITEM_E_TAG_GRP_ECID_B] = {
5077 : : .name = "grp_ecid_b",
5078 : : .help = "GRP and E-CID base",
5079 : : .next = NEXT(item_e_tag, NEXT_ENTRY(COMMON_UNSIGNED),
5080 : : item_param),
5081 : : .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_e_tag,
5082 : : rsvd_grp_ecid_b,
5083 : : "\x3f\xff")),
5084 : : },
5085 : : [ITEM_NVGRE] = {
5086 : : .name = "nvgre",
5087 : : .help = "match NVGRE header",
5088 : : .priv = PRIV_ITEM(NVGRE, sizeof(struct rte_flow_item_nvgre)),
5089 : : .next = NEXT(item_nvgre),
5090 : : .call = parse_vc,
5091 : : },
5092 : : [ITEM_NVGRE_TNI] = {
5093 : : .name = "tni",
5094 : : .help = "virtual subnet ID",
5095 : : .next = NEXT(item_nvgre, NEXT_ENTRY(COMMON_UNSIGNED),
5096 : : item_param),
5097 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_nvgre, tni)),
5098 : : },
5099 : : [ITEM_MPLS] = {
5100 : : .name = "mpls",
5101 : : .help = "match MPLS header",
5102 : : .priv = PRIV_ITEM(MPLS, sizeof(struct rte_flow_item_mpls)),
5103 : : .next = NEXT(item_mpls),
5104 : : .call = parse_vc,
5105 : : },
5106 : : [ITEM_MPLS_LABEL] = {
5107 : : .name = "label",
5108 : : .help = "MPLS label",
5109 : : .next = NEXT(item_mpls, NEXT_ENTRY(COMMON_UNSIGNED),
5110 : : item_param),
5111 : : .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
5112 : : label_tc_s,
5113 : : "\xff\xff\xf0")),
5114 : : },
5115 : : [ITEM_MPLS_TC] = {
5116 : : .name = "tc",
5117 : : .help = "MPLS Traffic Class",
5118 : : .next = NEXT(item_mpls, NEXT_ENTRY(COMMON_UNSIGNED),
5119 : : item_param),
5120 : : .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
5121 : : label_tc_s,
5122 : : "\x00\x00\x0e")),
5123 : : },
5124 : : [ITEM_MPLS_S] = {
5125 : : .name = "s",
5126 : : .help = "MPLS Bottom-of-Stack",
5127 : : .next = NEXT(item_mpls, NEXT_ENTRY(COMMON_UNSIGNED),
5128 : : item_param),
5129 : : .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
5130 : : label_tc_s,
5131 : : "\x00\x00\x01")),
5132 : : },
5133 : : [ITEM_MPLS_TTL] = {
5134 : : .name = "ttl",
5135 : : .help = "MPLS Time-to-Live",
5136 : : .next = NEXT(item_mpls, NEXT_ENTRY(COMMON_UNSIGNED),
5137 : : item_param),
5138 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_mpls, ttl)),
5139 : : },
5140 : : [ITEM_GRE] = {
5141 : : .name = "gre",
5142 : : .help = "match GRE header",
5143 : : .priv = PRIV_ITEM(GRE, sizeof(struct rte_flow_item_gre)),
5144 : : .next = NEXT(item_gre),
5145 : : .call = parse_vc,
5146 : : },
5147 : : [ITEM_GRE_PROTO] = {
5148 : : .name = "protocol",
5149 : : .help = "GRE protocol type",
5150 : : .next = NEXT(item_gre, NEXT_ENTRY(COMMON_UNSIGNED),
5151 : : item_param),
5152 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
5153 : : protocol)),
5154 : : },
5155 : : [ITEM_GRE_C_RSVD0_VER] = {
5156 : : .name = "c_rsvd0_ver",
5157 : : .help =
5158 : : "checksum (1b), undefined (1b), key bit (1b),"
5159 : : " sequence number (1b), reserved 0 (9b),"
5160 : : " version (3b)",
5161 : : .next = NEXT(item_gre, NEXT_ENTRY(COMMON_UNSIGNED),
5162 : : item_param),
5163 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
5164 : : c_rsvd0_ver)),
5165 : : },
5166 : : [ITEM_GRE_C_BIT] = {
5167 : : .name = "c_bit",
5168 : : .help = "checksum bit (C)",
5169 : : .next = NEXT(item_gre, NEXT_ENTRY(COMMON_BOOLEAN),
5170 : : item_param),
5171 : : .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
5172 : : c_rsvd0_ver,
5173 : : "\x80\x00\x00\x00")),
5174 : : },
5175 : : [ITEM_GRE_S_BIT] = {
5176 : : .name = "s_bit",
5177 : : .help = "sequence number bit (S)",
5178 : : .next = NEXT(item_gre, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
5179 : : .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
5180 : : c_rsvd0_ver,
5181 : : "\x10\x00\x00\x00")),
5182 : : },
5183 : : [ITEM_GRE_K_BIT] = {
5184 : : .name = "k_bit",
5185 : : .help = "key bit (K)",
5186 : : .next = NEXT(item_gre, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
5187 : : .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
5188 : : c_rsvd0_ver,
5189 : : "\x20\x00\x00\x00")),
5190 : : },
5191 : : [ITEM_FUZZY] = {
5192 : : .name = "fuzzy",
5193 : : .help = "fuzzy pattern match, expect faster than default",
5194 : : .priv = PRIV_ITEM(FUZZY,
5195 : : sizeof(struct rte_flow_item_fuzzy)),
5196 : : .next = NEXT(item_fuzzy),
5197 : : .call = parse_vc,
5198 : : },
5199 : : [ITEM_FUZZY_THRESH] = {
5200 : : .name = "thresh",
5201 : : .help = "match accuracy threshold",
5202 : : .next = NEXT(item_fuzzy, NEXT_ENTRY(COMMON_UNSIGNED),
5203 : : item_param),
5204 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_fuzzy,
5205 : : thresh)),
5206 : : },
5207 : : [ITEM_GTP] = {
5208 : : .name = "gtp",
5209 : : .help = "match GTP header",
5210 : : .priv = PRIV_ITEM(GTP, sizeof(struct rte_flow_item_gtp)),
5211 : : .next = NEXT(item_gtp),
5212 : : .call = parse_vc,
5213 : : },
5214 : : [ITEM_GTP_FLAGS] = {
5215 : : .name = "v_pt_rsv_flags",
5216 : : .help = "GTP flags",
5217 : : .next = NEXT(item_gtp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
5218 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp,
5219 : : hdr.gtp_hdr_info)),
5220 : : },
5221 : : [ITEM_GTP_MSG_TYPE] = {
5222 : : .name = "msg_type",
5223 : : .help = "GTP message type",
5224 : : .next = NEXT(item_gtp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
5225 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp, hdr.msg_type)),
5226 : : },
5227 : : [ITEM_GTP_TEID] = {
5228 : : .name = "teid",
5229 : : .help = "tunnel endpoint identifier",
5230 : : .next = NEXT(item_gtp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
5231 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp, hdr.teid)),
5232 : : },
5233 : : [ITEM_GTPC] = {
5234 : : .name = "gtpc",
5235 : : .help = "match GTP header",
5236 : : .priv = PRIV_ITEM(GTPC, sizeof(struct rte_flow_item_gtp)),
5237 : : .next = NEXT(item_gtp),
5238 : : .call = parse_vc,
5239 : : },
5240 : : [ITEM_GTPU] = {
5241 : : .name = "gtpu",
5242 : : .help = "match GTP header",
5243 : : .priv = PRIV_ITEM(GTPU, sizeof(struct rte_flow_item_gtp)),
5244 : : .next = NEXT(item_gtp),
5245 : : .call = parse_vc,
5246 : : },
5247 : : [ITEM_GENEVE] = {
5248 : : .name = "geneve",
5249 : : .help = "match GENEVE header",
5250 : : .priv = PRIV_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)),
5251 : : .next = NEXT(item_geneve),
5252 : : .call = parse_vc,
5253 : : },
5254 : : [ITEM_GENEVE_VNI] = {
5255 : : .name = "vni",
5256 : : .help = "virtual network identifier",
5257 : : .next = NEXT(item_geneve, NEXT_ENTRY(COMMON_UNSIGNED),
5258 : : item_param),
5259 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve, vni)),
5260 : : },
5261 : : [ITEM_GENEVE_PROTO] = {
5262 : : .name = "protocol",
5263 : : .help = "GENEVE protocol type",
5264 : : .next = NEXT(item_geneve, NEXT_ENTRY(COMMON_UNSIGNED),
5265 : : item_param),
5266 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve,
5267 : : protocol)),
5268 : : },
5269 : : [ITEM_GENEVE_OPTLEN] = {
5270 : : .name = "optlen",
5271 : : .help = "GENEVE options length in dwords",
5272 : : .next = NEXT(item_geneve, NEXT_ENTRY(COMMON_UNSIGNED),
5273 : : item_param),
5274 : : .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_geneve,
5275 : : ver_opt_len_o_c_rsvd0,
5276 : : "\x3f\x00")),
5277 : : },
5278 : : [ITEM_VXLAN_GPE] = {
5279 : : .name = "vxlan-gpe",
5280 : : .help = "match VXLAN-GPE header",
5281 : : .priv = PRIV_ITEM(VXLAN_GPE,
5282 : : sizeof(struct rte_flow_item_vxlan_gpe)),
5283 : : .next = NEXT(item_vxlan_gpe),
5284 : : .call = parse_vc,
5285 : : },
5286 : : [ITEM_VXLAN_GPE_VNI] = {
5287 : : .name = "vni",
5288 : : .help = "VXLAN-GPE identifier",
5289 : : .next = NEXT(item_vxlan_gpe, NEXT_ENTRY(COMMON_UNSIGNED),
5290 : : item_param),
5291 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
5292 : : hdr.vni)),
5293 : : },
5294 : : [ITEM_VXLAN_GPE_PROTO_IN_DEPRECATED_VXLAN_GPE_HDR] = {
5295 : : .name = "protocol",
5296 : : .help = "VXLAN-GPE next protocol",
5297 : : .next = NEXT(item_vxlan_gpe, NEXT_ENTRY(COMMON_UNSIGNED),
5298 : : item_param),
5299 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
5300 : : protocol)),
5301 : : },
5302 : : [ITEM_VXLAN_GPE_FLAGS] = {
5303 : : .name = "flags",
5304 : : .help = "VXLAN-GPE flags",
5305 : : .next = NEXT(item_vxlan_gpe, NEXT_ENTRY(COMMON_UNSIGNED),
5306 : : item_param),
5307 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
5308 : : flags)),
5309 : : },
5310 : : [ITEM_VXLAN_GPE_RSVD0] = {
5311 : : .name = "rsvd0",
5312 : : .help = "VXLAN-GPE rsvd0",
5313 : : .next = NEXT(item_vxlan_gpe, NEXT_ENTRY(COMMON_UNSIGNED),
5314 : : item_param),
5315 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
5316 : : rsvd0)),
5317 : : },
5318 : : [ITEM_VXLAN_GPE_RSVD1] = {
5319 : : .name = "rsvd1",
5320 : : .help = "VXLAN-GPE rsvd1",
5321 : : .next = NEXT(item_vxlan_gpe, NEXT_ENTRY(COMMON_UNSIGNED),
5322 : : item_param),
5323 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
5324 : : rsvd1)),
5325 : : },
5326 : : [ITEM_ARP_ETH_IPV4] = {
5327 : : .name = "arp_eth_ipv4",
5328 : : .help = "match ARP header for Ethernet/IPv4",
5329 : : .priv = PRIV_ITEM(ARP_ETH_IPV4,
5330 : : sizeof(struct rte_flow_item_arp_eth_ipv4)),
5331 : : .next = NEXT(item_arp_eth_ipv4),
5332 : : .call = parse_vc,
5333 : : },
5334 : : [ITEM_ARP_ETH_IPV4_SHA] = {
5335 : : .name = "sha",
5336 : : .help = "sender hardware address",
5337 : : .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_MAC_ADDR),
5338 : : item_param),
5339 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
5340 : : hdr.arp_data.arp_sha)),
5341 : : },
5342 : : [ITEM_ARP_ETH_IPV4_SPA] = {
5343 : : .name = "spa",
5344 : : .help = "sender IPv4 address",
5345 : : .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
5346 : : item_param),
5347 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
5348 : : hdr.arp_data.arp_sip)),
5349 : : },
5350 : : [ITEM_ARP_ETH_IPV4_THA] = {
5351 : : .name = "tha",
5352 : : .help = "target hardware address",
5353 : : .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_MAC_ADDR),
5354 : : item_param),
5355 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
5356 : : hdr.arp_data.arp_tha)),
5357 : : },
5358 : : [ITEM_ARP_ETH_IPV4_TPA] = {
5359 : : .name = "tpa",
5360 : : .help = "target IPv4 address",
5361 : : .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
5362 : : item_param),
5363 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
5364 : : hdr.arp_data.arp_tip)),
5365 : : },
5366 : : [ITEM_IPV6_EXT] = {
5367 : : .name = "ipv6_ext",
5368 : : .help = "match presence of any IPv6 extension header",
5369 : : .priv = PRIV_ITEM(IPV6_EXT,
5370 : : sizeof(struct rte_flow_item_ipv6_ext)),
5371 : : .next = NEXT(item_ipv6_ext),
5372 : : .call = parse_vc,
5373 : : },
5374 : : [ITEM_IPV6_EXT_NEXT_HDR] = {
5375 : : .name = "next_hdr",
5376 : : .help = "next header",
5377 : : .next = NEXT(item_ipv6_ext, NEXT_ENTRY(COMMON_UNSIGNED),
5378 : : item_param),
5379 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_ext,
5380 : : next_hdr)),
5381 : : },
5382 : : [ITEM_IPV6_FRAG_EXT] = {
5383 : : .name = "ipv6_frag_ext",
5384 : : .help = "match presence of IPv6 fragment extension header",
5385 : : .priv = PRIV_ITEM(IPV6_FRAG_EXT,
5386 : : sizeof(struct rte_flow_item_ipv6_frag_ext)),
5387 : : .next = NEXT(item_ipv6_frag_ext),
5388 : : .call = parse_vc,
5389 : : },
5390 : : [ITEM_IPV6_FRAG_EXT_NEXT_HDR] = {
5391 : : .name = "next_hdr",
5392 : : .help = "next header",
5393 : : .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(COMMON_UNSIGNED),
5394 : : item_param),
5395 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ipv6_frag_ext,
5396 : : hdr.next_header)),
5397 : : },
5398 : : [ITEM_IPV6_FRAG_EXT_FRAG_DATA] = {
5399 : : .name = "frag_data",
5400 : : .help = "fragment flags and offset",
5401 : : .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(COMMON_UNSIGNED),
5402 : : item_param),
5403 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_frag_ext,
5404 : : hdr.frag_data)),
5405 : : },
5406 : : [ITEM_IPV6_FRAG_EXT_ID] = {
5407 : : .name = "packet_id",
5408 : : .help = "fragment packet id",
5409 : : .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(COMMON_UNSIGNED),
5410 : : item_param),
5411 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_frag_ext,
5412 : : hdr.id)),
5413 : : },
5414 : : [ITEM_ICMP6] = {
5415 : : .name = "icmp6",
5416 : : .help = "match any ICMPv6 header",
5417 : : .priv = PRIV_ITEM(ICMP6, sizeof(struct rte_flow_item_icmp6)),
5418 : : .next = NEXT(item_icmp6),
5419 : : .call = parse_vc,
5420 : : },
5421 : : [ITEM_ICMP6_TYPE] = {
5422 : : .name = "type",
5423 : : .help = "ICMPv6 type",
5424 : : .next = NEXT(item_icmp6, NEXT_ENTRY(COMMON_UNSIGNED),
5425 : : item_param),
5426 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
5427 : : type)),
5428 : : },
5429 : : [ITEM_ICMP6_CODE] = {
5430 : : .name = "code",
5431 : : .help = "ICMPv6 code",
5432 : : .next = NEXT(item_icmp6, NEXT_ENTRY(COMMON_UNSIGNED),
5433 : : item_param),
5434 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
5435 : : code)),
5436 : : },
5437 : : [ITEM_ICMP6_ECHO_REQUEST] = {
5438 : : .name = "icmp6_echo_request",
5439 : : .help = "match ICMPv6 echo request",
5440 : : .priv = PRIV_ITEM(ICMP6_ECHO_REQUEST,
5441 : : sizeof(struct rte_flow_item_icmp6_echo)),
5442 : : .next = NEXT(item_icmp6_echo_request),
5443 : : .call = parse_vc,
5444 : : },
5445 : : [ITEM_ICMP6_ECHO_REQUEST_ID] = {
5446 : : .name = "ident",
5447 : : .help = "ICMPv6 echo request identifier",
5448 : : .next = NEXT(item_icmp6_echo_request, NEXT_ENTRY(COMMON_UNSIGNED),
5449 : : item_param),
5450 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_echo,
5451 : : hdr.identifier)),
5452 : : },
5453 : : [ITEM_ICMP6_ECHO_REQUEST_SEQ] = {
5454 : : .name = "seq",
5455 : : .help = "ICMPv6 echo request sequence",
5456 : : .next = NEXT(item_icmp6_echo_request, NEXT_ENTRY(COMMON_UNSIGNED),
5457 : : item_param),
5458 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_echo,
5459 : : hdr.sequence)),
5460 : : },
5461 : : [ITEM_ICMP6_ECHO_REPLY] = {
5462 : : .name = "icmp6_echo_reply",
5463 : : .help = "match ICMPv6 echo reply",
5464 : : .priv = PRIV_ITEM(ICMP6_ECHO_REPLY,
5465 : : sizeof(struct rte_flow_item_icmp6_echo)),
5466 : : .next = NEXT(item_icmp6_echo_reply),
5467 : : .call = parse_vc,
5468 : : },
5469 : : [ITEM_ICMP6_ECHO_REPLY_ID] = {
5470 : : .name = "ident",
5471 : : .help = "ICMPv6 echo reply identifier",
5472 : : .next = NEXT(item_icmp6_echo_reply, NEXT_ENTRY(COMMON_UNSIGNED),
5473 : : item_param),
5474 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_echo,
5475 : : hdr.identifier)),
5476 : : },
5477 : : [ITEM_ICMP6_ECHO_REPLY_SEQ] = {
5478 : : .name = "seq",
5479 : : .help = "ICMPv6 echo reply sequence",
5480 : : .next = NEXT(item_icmp6_echo_reply, NEXT_ENTRY(COMMON_UNSIGNED),
5481 : : item_param),
5482 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_echo,
5483 : : hdr.sequence)),
5484 : : },
5485 : : [ITEM_ICMP6_ND_NS] = {
5486 : : .name = "icmp6_nd_ns",
5487 : : .help = "match ICMPv6 neighbor discovery solicitation",
5488 : : .priv = PRIV_ITEM(ICMP6_ND_NS,
5489 : : sizeof(struct rte_flow_item_icmp6_nd_ns)),
5490 : : .next = NEXT(item_icmp6_nd_ns),
5491 : : .call = parse_vc,
5492 : : },
5493 : : [ITEM_ICMP6_ND_NS_TARGET_ADDR] = {
5494 : : .name = "target_addr",
5495 : : .help = "target address",
5496 : : .next = NEXT(item_icmp6_nd_ns, NEXT_ENTRY(COMMON_IPV6_ADDR),
5497 : : item_param),
5498 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_ns,
5499 : : target_addr)),
5500 : : },
5501 : : [ITEM_ICMP6_ND_NA] = {
5502 : : .name = "icmp6_nd_na",
5503 : : .help = "match ICMPv6 neighbor discovery advertisement",
5504 : : .priv = PRIV_ITEM(ICMP6_ND_NA,
5505 : : sizeof(struct rte_flow_item_icmp6_nd_na)),
5506 : : .next = NEXT(item_icmp6_nd_na),
5507 : : .call = parse_vc,
5508 : : },
5509 : : [ITEM_ICMP6_ND_NA_TARGET_ADDR] = {
5510 : : .name = "target_addr",
5511 : : .help = "target address",
5512 : : .next = NEXT(item_icmp6_nd_na, NEXT_ENTRY(COMMON_IPV6_ADDR),
5513 : : item_param),
5514 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_na,
5515 : : target_addr)),
5516 : : },
5517 : : [ITEM_ICMP6_ND_OPT] = {
5518 : : .name = "icmp6_nd_opt",
5519 : : .help = "match presence of any ICMPv6 neighbor discovery"
5520 : : " option",
5521 : : .priv = PRIV_ITEM(ICMP6_ND_OPT,
5522 : : sizeof(struct rte_flow_item_icmp6_nd_opt)),
5523 : : .next = NEXT(item_icmp6_nd_opt),
5524 : : .call = parse_vc,
5525 : : },
5526 : : [ITEM_ICMP6_ND_OPT_TYPE] = {
5527 : : .name = "type",
5528 : : .help = "ND option type",
5529 : : .next = NEXT(item_icmp6_nd_opt, NEXT_ENTRY(COMMON_UNSIGNED),
5530 : : item_param),
5531 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_opt,
5532 : : type)),
5533 : : },
5534 : : [ITEM_ICMP6_ND_OPT_SLA_ETH] = {
5535 : : .name = "icmp6_nd_opt_sla_eth",
5536 : : .help = "match ICMPv6 neighbor discovery source Ethernet"
5537 : : " link-layer address option",
5538 : : .priv = PRIV_ITEM
5539 : : (ICMP6_ND_OPT_SLA_ETH,
5540 : : sizeof(struct rte_flow_item_icmp6_nd_opt_sla_eth)),
5541 : : .next = NEXT(item_icmp6_nd_opt_sla_eth),
5542 : : .call = parse_vc,
5543 : : },
5544 : : [ITEM_ICMP6_ND_OPT_SLA_ETH_SLA] = {
5545 : : .name = "sla",
5546 : : .help = "source Ethernet LLA",
5547 : : .next = NEXT(item_icmp6_nd_opt_sla_eth,
5548 : : NEXT_ENTRY(COMMON_MAC_ADDR), item_param),
5549 : : .args = ARGS(ARGS_ENTRY_HTON
5550 : : (struct rte_flow_item_icmp6_nd_opt_sla_eth, sla)),
5551 : : },
5552 : : [ITEM_ICMP6_ND_OPT_TLA_ETH] = {
5553 : : .name = "icmp6_nd_opt_tla_eth",
5554 : : .help = "match ICMPv6 neighbor discovery target Ethernet"
5555 : : " link-layer address option",
5556 : : .priv = PRIV_ITEM
5557 : : (ICMP6_ND_OPT_TLA_ETH,
5558 : : sizeof(struct rte_flow_item_icmp6_nd_opt_tla_eth)),
5559 : : .next = NEXT(item_icmp6_nd_opt_tla_eth),
5560 : : .call = parse_vc,
5561 : : },
5562 : : [ITEM_ICMP6_ND_OPT_TLA_ETH_TLA] = {
5563 : : .name = "tla",
5564 : : .help = "target Ethernet LLA",
5565 : : .next = NEXT(item_icmp6_nd_opt_tla_eth,
5566 : : NEXT_ENTRY(COMMON_MAC_ADDR), item_param),
5567 : : .args = ARGS(ARGS_ENTRY_HTON
5568 : : (struct rte_flow_item_icmp6_nd_opt_tla_eth, tla)),
5569 : : },
5570 : : [ITEM_META] = {
5571 : : .name = "meta",
5572 : : .help = "match metadata header",
5573 : : .priv = PRIV_ITEM(META, sizeof(struct rte_flow_item_meta)),
5574 : : .next = NEXT(item_meta),
5575 : : .call = parse_vc,
5576 : : },
5577 : : [ITEM_META_DATA] = {
5578 : : .name = "data",
5579 : : .help = "metadata value",
5580 : : .next = NEXT(item_meta, NEXT_ENTRY(COMMON_UNSIGNED),
5581 : : item_param),
5582 : : .args = ARGS(ARGS_ENTRY_MASK(struct rte_flow_item_meta,
5583 : : data, "\xff\xff\xff\xff")),
5584 : : },
5585 : : [ITEM_RANDOM] = {
5586 : : .name = "random",
5587 : : .help = "match random value",
5588 : : .priv = PRIV_ITEM(RANDOM, sizeof(struct rte_flow_item_random)),
5589 : : .next = NEXT(item_random),
5590 : : .call = parse_vc,
5591 : : },
5592 : : [ITEM_RANDOM_VALUE] = {
5593 : : .name = "value",
5594 : : .help = "random value",
5595 : : .next = NEXT(item_random, NEXT_ENTRY(COMMON_UNSIGNED),
5596 : : item_param),
5597 : : .args = ARGS(ARGS_ENTRY_MASK(struct rte_flow_item_random,
5598 : : value, "\xff\xff\xff\xff")),
5599 : : },
5600 : : [ITEM_GRE_KEY] = {
5601 : : .name = "gre_key",
5602 : : .help = "match GRE key",
5603 : : .priv = PRIV_ITEM(GRE_KEY, sizeof(rte_be32_t)),
5604 : : .next = NEXT(item_gre_key),
5605 : : .call = parse_vc,
5606 : : },
5607 : : [ITEM_GRE_KEY_VALUE] = {
5608 : : .name = "value",
5609 : : .help = "key value",
5610 : : .next = NEXT(item_gre_key, NEXT_ENTRY(COMMON_UNSIGNED),
5611 : : item_param),
5612 : : .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
5613 : : },
5614 : : [ITEM_GRE_OPTION] = {
5615 : : .name = "gre_option",
5616 : : .help = "match GRE optional fields",
5617 : : .priv = PRIV_ITEM(GRE_OPTION,
5618 : : sizeof(struct rte_flow_item_gre_opt)),
5619 : : .next = NEXT(item_gre_option),
5620 : : .call = parse_vc,
5621 : : },
5622 : : [ITEM_GRE_OPTION_CHECKSUM] = {
5623 : : .name = "checksum",
5624 : : .help = "match GRE checksum",
5625 : : .next = NEXT(item_gre_option, NEXT_ENTRY(COMMON_UNSIGNED),
5626 : : item_param),
5627 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre_opt,
5628 : : checksum_rsvd.checksum)),
5629 : : },
5630 : : [ITEM_GRE_OPTION_KEY] = {
5631 : : .name = "key",
5632 : : .help = "match GRE key",
5633 : : .next = NEXT(item_gre_option, NEXT_ENTRY(COMMON_UNSIGNED),
5634 : : item_param),
5635 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre_opt,
5636 : : key.key)),
5637 : : },
5638 : : [ITEM_GRE_OPTION_SEQUENCE] = {
5639 : : .name = "sequence",
5640 : : .help = "match GRE sequence",
5641 : : .next = NEXT(item_gre_option, NEXT_ENTRY(COMMON_UNSIGNED),
5642 : : item_param),
5643 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre_opt,
5644 : : sequence.sequence)),
5645 : : },
5646 : : [ITEM_GTP_PSC] = {
5647 : : .name = "gtp_psc",
5648 : : .help = "match GTP extension header with type 0x85",
5649 : : .priv = PRIV_ITEM(GTP_PSC,
5650 : : sizeof(struct rte_flow_item_gtp_psc)),
5651 : : .next = NEXT(item_gtp_psc),
5652 : : .call = parse_vc,
5653 : : },
5654 : : [ITEM_GTP_PSC_QFI] = {
5655 : : .name = "qfi",
5656 : : .help = "QoS flow identifier",
5657 : : .next = NEXT(item_gtp_psc, NEXT_ENTRY(COMMON_UNSIGNED),
5658 : : item_param),
5659 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_gtp_psc,
5660 : : hdr.qfi, 6)),
5661 : : },
5662 : : [ITEM_GTP_PSC_PDU_T] = {
5663 : : .name = "pdu_t",
5664 : : .help = "PDU type",
5665 : : .next = NEXT(item_gtp_psc, NEXT_ENTRY(COMMON_UNSIGNED),
5666 : : item_param),
5667 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_gtp_psc,
5668 : : hdr.type, 4)),
5669 : : },
5670 : : [ITEM_PPPOES] = {
5671 : : .name = "pppoes",
5672 : : .help = "match PPPoE session header",
5673 : : .priv = PRIV_ITEM(PPPOES, sizeof(struct rte_flow_item_pppoe)),
5674 : : .next = NEXT(item_pppoes),
5675 : : .call = parse_vc,
5676 : : },
5677 : : [ITEM_PPPOED] = {
5678 : : .name = "pppoed",
5679 : : .help = "match PPPoE discovery header",
5680 : : .priv = PRIV_ITEM(PPPOED, sizeof(struct rte_flow_item_pppoe)),
5681 : : .next = NEXT(item_pppoed),
5682 : : .call = parse_vc,
5683 : : },
5684 : : [ITEM_PPPOE_SEID] = {
5685 : : .name = "seid",
5686 : : .help = "session identifier",
5687 : : .next = NEXT(item_pppoes, NEXT_ENTRY(COMMON_UNSIGNED),
5688 : : item_param),
5689 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pppoe,
5690 : : session_id)),
5691 : : },
5692 : : [ITEM_PPPOE_PROTO_ID] = {
5693 : : .name = "pppoe_proto_id",
5694 : : .help = "match PPPoE session protocol identifier",
5695 : : .priv = PRIV_ITEM(PPPOE_PROTO_ID,
5696 : : sizeof(struct rte_flow_item_pppoe_proto_id)),
5697 : : .next = NEXT(item_pppoe_proto_id, NEXT_ENTRY(COMMON_UNSIGNED),
5698 : : item_param),
5699 : : .args = ARGS(ARGS_ENTRY_HTON
5700 : : (struct rte_flow_item_pppoe_proto_id, proto_id)),
5701 : : .call = parse_vc,
5702 : : },
5703 : : [ITEM_HIGIG2] = {
5704 : : .name = "higig2",
5705 : : .help = "matches higig2 header",
5706 : : .priv = PRIV_ITEM(HIGIG2,
5707 : : sizeof(struct rte_flow_item_higig2_hdr)),
5708 : : .next = NEXT(item_higig2),
5709 : : .call = parse_vc,
5710 : : },
5711 : : [ITEM_HIGIG2_CLASSIFICATION] = {
5712 : : .name = "classification",
5713 : : .help = "matches classification of higig2 header",
5714 : : .next = NEXT(item_higig2, NEXT_ENTRY(COMMON_UNSIGNED),
5715 : : item_param),
5716 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
5717 : : hdr.ppt1.classification)),
5718 : : },
5719 : : [ITEM_HIGIG2_VID] = {
5720 : : .name = "vid",
5721 : : .help = "matches vid of higig2 header",
5722 : : .next = NEXT(item_higig2, NEXT_ENTRY(COMMON_UNSIGNED),
5723 : : item_param),
5724 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
5725 : : hdr.ppt1.vid)),
5726 : : },
5727 : : [ITEM_TAG] = {
5728 : : .name = "tag",
5729 : : .help = "match tag value",
5730 : : .priv = PRIV_ITEM(TAG, sizeof(struct rte_flow_item_tag)),
5731 : : .next = NEXT(item_tag),
5732 : : .call = parse_vc,
5733 : : },
5734 : : [ITEM_TAG_DATA] = {
5735 : : .name = "data",
5736 : : .help = "tag value to match",
5737 : : .next = NEXT(item_tag, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
5738 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, data)),
5739 : : },
5740 : : [ITEM_TAG_INDEX] = {
5741 : : .name = "index",
5742 : : .help = "index of tag array to match",
5743 : : .next = NEXT(item_tag, NEXT_ENTRY(COMMON_UNSIGNED),
5744 : : NEXT_ENTRY(ITEM_PARAM_IS)),
5745 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, index)),
5746 : : },
5747 : : [ITEM_L2TPV3OIP] = {
5748 : : .name = "l2tpv3oip",
5749 : : .help = "match L2TPv3 over IP header",
5750 : : .priv = PRIV_ITEM(L2TPV3OIP,
5751 : : sizeof(struct rte_flow_item_l2tpv3oip)),
5752 : : .next = NEXT(item_l2tpv3oip),
5753 : : .call = parse_vc,
5754 : : },
5755 : : [ITEM_L2TPV3OIP_SESSION_ID] = {
5756 : : .name = "session_id",
5757 : : .help = "session identifier",
5758 : : .next = NEXT(item_l2tpv3oip, NEXT_ENTRY(COMMON_UNSIGNED),
5759 : : item_param),
5760 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv3oip,
5761 : : session_id)),
5762 : : },
5763 : : [ITEM_ESP] = {
5764 : : .name = "esp",
5765 : : .help = "match ESP header",
5766 : : .priv = PRIV_ITEM(ESP, sizeof(struct rte_flow_item_esp)),
5767 : : .next = NEXT(item_esp),
5768 : : .call = parse_vc,
5769 : : },
5770 : : [ITEM_ESP_SPI] = {
5771 : : .name = "spi",
5772 : : .help = "security policy index",
5773 : : .next = NEXT(item_esp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
5774 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_esp,
5775 : : hdr.spi)),
5776 : : },
5777 : : [ITEM_AH] = {
5778 : : .name = "ah",
5779 : : .help = "match AH header",
5780 : : .priv = PRIV_ITEM(AH, sizeof(struct rte_flow_item_ah)),
5781 : : .next = NEXT(item_ah),
5782 : : .call = parse_vc,
5783 : : },
5784 : : [ITEM_AH_SPI] = {
5785 : : .name = "spi",
5786 : : .help = "security parameters index",
5787 : : .next = NEXT(item_ah, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
5788 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ah, spi)),
5789 : : },
5790 : : [ITEM_PFCP] = {
5791 : : .name = "pfcp",
5792 : : .help = "match pfcp header",
5793 : : .priv = PRIV_ITEM(PFCP, sizeof(struct rte_flow_item_pfcp)),
5794 : : .next = NEXT(item_pfcp),
5795 : : .call = parse_vc,
5796 : : },
5797 : : [ITEM_PFCP_S_FIELD] = {
5798 : : .name = "s_field",
5799 : : .help = "S field",
5800 : : .next = NEXT(item_pfcp, NEXT_ENTRY(COMMON_UNSIGNED),
5801 : : item_param),
5802 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp,
5803 : : s_field)),
5804 : : },
5805 : : [ITEM_PFCP_SEID] = {
5806 : : .name = "seid",
5807 : : .help = "session endpoint identifier",
5808 : : .next = NEXT(item_pfcp, NEXT_ENTRY(COMMON_UNSIGNED),
5809 : : item_param),
5810 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp, seid)),
5811 : : },
5812 : : [ITEM_ECPRI] = {
5813 : : .name = "ecpri",
5814 : : .help = "match eCPRI header",
5815 : : .priv = PRIV_ITEM(ECPRI, sizeof(struct rte_flow_item_ecpri)),
5816 : : .next = NEXT(item_ecpri),
5817 : : .call = parse_vc,
5818 : : },
5819 : : [ITEM_ECPRI_COMMON] = {
5820 : : .name = "common",
5821 : : .help = "eCPRI common header",
5822 : : .next = NEXT(item_ecpri_common),
5823 : : },
5824 : : [ITEM_ECPRI_COMMON_TYPE] = {
5825 : : .name = "type",
5826 : : .help = "type of common header",
5827 : : .next = NEXT(item_ecpri_common_type),
5828 : : .args = ARGS(ARG_ENTRY_HTON(struct rte_flow_item_ecpri)),
5829 : : },
5830 : : [ITEM_ECPRI_COMMON_TYPE_IQ_DATA] = {
5831 : : .name = "iq_data",
5832 : : .help = "Type #0: IQ Data",
5833 : : .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
5834 : : ITEM_NEXT)),
5835 : : .call = parse_vc_item_ecpri_type,
5836 : : },
5837 : : [ITEM_ECPRI_MSG_IQ_DATA_PCID] = {
5838 : : .name = "pc_id",
5839 : : .help = "Physical Channel ID",
5840 : : .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
5841 : : ITEM_ECPRI_COMMON, ITEM_NEXT),
5842 : : NEXT_ENTRY(COMMON_UNSIGNED), item_param),
5843 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
5844 : : hdr.type0.pc_id)),
5845 : : },
5846 : : [ITEM_ECPRI_COMMON_TYPE_RTC_CTRL] = {
5847 : : .name = "rtc_ctrl",
5848 : : .help = "Type #2: Real-Time Control Data",
5849 : : .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
5850 : : ITEM_NEXT)),
5851 : : .call = parse_vc_item_ecpri_type,
5852 : : },
5853 : : [ITEM_ECPRI_MSG_RTC_CTRL_RTCID] = {
5854 : : .name = "rtc_id",
5855 : : .help = "Real-Time Control Data ID",
5856 : : .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
5857 : : ITEM_ECPRI_COMMON, ITEM_NEXT),
5858 : : NEXT_ENTRY(COMMON_UNSIGNED), item_param),
5859 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
5860 : : hdr.type2.rtc_id)),
5861 : : },
5862 : : [ITEM_ECPRI_COMMON_TYPE_DLY_MSR] = {
5863 : : .name = "delay_measure",
5864 : : .help = "Type #5: One-Way Delay Measurement",
5865 : : .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
5866 : : ITEM_NEXT)),
5867 : : .call = parse_vc_item_ecpri_type,
5868 : : },
5869 : : [ITEM_ECPRI_MSG_DLY_MSR_MSRID] = {
5870 : : .name = "msr_id",
5871 : : .help = "Measurement ID",
5872 : : .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
5873 : : ITEM_ECPRI_COMMON, ITEM_NEXT),
5874 : : NEXT_ENTRY(COMMON_UNSIGNED), item_param),
5875 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
5876 : : hdr.type5.msr_id)),
5877 : : },
5878 : : [ITEM_GENEVE_OPT] = {
5879 : : .name = "geneve-opt",
5880 : : .help = "GENEVE header option",
5881 : : .priv = PRIV_ITEM(GENEVE_OPT,
5882 : : sizeof(struct rte_flow_item_geneve_opt) +
5883 : : ITEM_GENEVE_OPT_DATA_SIZE),
5884 : : .next = NEXT(item_geneve_opt),
5885 : : .call = parse_vc,
5886 : : },
5887 : : [ITEM_GENEVE_OPT_CLASS] = {
5888 : : .name = "class",
5889 : : .help = "GENEVE option class",
5890 : : .next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_UNSIGNED),
5891 : : item_param),
5892 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve_opt,
5893 : : option_class)),
5894 : : },
5895 : : [ITEM_GENEVE_OPT_TYPE] = {
5896 : : .name = "type",
5897 : : .help = "GENEVE option type",
5898 : : .next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_UNSIGNED),
5899 : : item_param),
5900 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt,
5901 : : option_type)),
5902 : : },
5903 : : [ITEM_GENEVE_OPT_LENGTH] = {
5904 : : .name = "length",
5905 : : .help = "GENEVE option data length (in 32b words)",
5906 : : .next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_UNSIGNED),
5907 : : item_param),
5908 : : .args = ARGS(ARGS_ENTRY_BOUNDED(
5909 : : struct rte_flow_item_geneve_opt, option_len,
5910 : : 0, 31)),
5911 : : },
5912 : : [ITEM_GENEVE_OPT_DATA] = {
5913 : : .name = "data",
5914 : : .help = "GENEVE option data pattern",
5915 : : .next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_HEX),
5916 : : item_param),
5917 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt, data),
5918 : : ARGS_ENTRY_ARB(0, 0),
5919 : : ARGS_ENTRY_ARB
5920 : : (sizeof(struct rte_flow_item_geneve_opt),
5921 : : ITEM_GENEVE_OPT_DATA_SIZE)),
5922 : : },
5923 : : [ITEM_INTEGRITY] = {
5924 : : .name = "integrity",
5925 : : .help = "match packet integrity",
5926 : : .priv = PRIV_ITEM(INTEGRITY,
5927 : : sizeof(struct rte_flow_item_integrity)),
5928 : : .next = NEXT(item_integrity),
5929 : : .call = parse_vc,
5930 : : },
5931 : : [ITEM_INTEGRITY_LEVEL] = {
5932 : : .name = "level",
5933 : : .help = "integrity level",
5934 : : .next = NEXT(item_integrity_lv, NEXT_ENTRY(COMMON_UNSIGNED),
5935 : : item_param),
5936 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_integrity, level)),
5937 : : },
5938 : : [ITEM_INTEGRITY_VALUE] = {
5939 : : .name = "value",
5940 : : .help = "integrity value",
5941 : : .next = NEXT(item_integrity_lv, NEXT_ENTRY(COMMON_UNSIGNED),
5942 : : item_param),
5943 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_integrity, value)),
5944 : : },
5945 : : [ITEM_CONNTRACK] = {
5946 : : .name = "conntrack",
5947 : : .help = "conntrack state",
5948 : : .priv = PRIV_ITEM(CONNTRACK,
5949 : : sizeof(struct rte_flow_item_conntrack)),
5950 : : .next = NEXT(NEXT_ENTRY(ITEM_NEXT), NEXT_ENTRY(COMMON_UNSIGNED),
5951 : : item_param),
5952 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_conntrack, flags)),
5953 : : .call = parse_vc,
5954 : : },
5955 : : [ITEM_PORT_REPRESENTOR] = {
5956 : : .name = "port_representor",
5957 : : .help = "match traffic entering the embedded switch from the given ethdev",
5958 : : .priv = PRIV_ITEM(PORT_REPRESENTOR,
5959 : : sizeof(struct rte_flow_item_ethdev)),
5960 : : .next = NEXT(item_port_representor),
5961 : : .call = parse_vc,
5962 : : },
5963 : : [ITEM_PORT_REPRESENTOR_PORT_ID] = {
5964 : : .name = "port_id",
5965 : : .help = "ethdev port ID",
5966 : : .next = NEXT(item_port_representor, NEXT_ENTRY(COMMON_UNSIGNED),
5967 : : item_param),
5968 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ethdev, port_id)),
5969 : : },
5970 : : [ITEM_REPRESENTED_PORT] = {
5971 : : .name = "represented_port",
5972 : : .help = "match traffic entering the embedded switch from the entity represented by the given ethdev",
5973 : : .priv = PRIV_ITEM(REPRESENTED_PORT,
5974 : : sizeof(struct rte_flow_item_ethdev)),
5975 : : .next = NEXT(item_represented_port),
5976 : : .call = parse_vc,
5977 : : },
5978 : : [ITEM_REPRESENTED_PORT_ETHDEV_PORT_ID] = {
5979 : : .name = "ethdev_port_id",
5980 : : .help = "ethdev port ID",
5981 : : .next = NEXT(item_represented_port, NEXT_ENTRY(COMMON_UNSIGNED),
5982 : : item_param),
5983 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ethdev, port_id)),
5984 : : },
5985 : : [ITEM_FLEX] = {
5986 : : .name = "flex",
5987 : : .help = "match flex header",
5988 : : .priv = PRIV_ITEM(FLEX, sizeof(struct rte_flow_item_flex)),
5989 : : .next = NEXT(item_flex),
5990 : : .call = parse_vc,
5991 : : },
5992 : : [ITEM_FLEX_ITEM_HANDLE] = {
5993 : : .name = "item",
5994 : : .help = "flex item handle",
5995 : : .next = NEXT(item_flex, NEXT_ENTRY(COMMON_FLEX_HANDLE),
5996 : : NEXT_ENTRY(ITEM_PARAM_IS)),
5997 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_flex, handle)),
5998 : : },
5999 : : [ITEM_FLEX_PATTERN_HANDLE] = {
6000 : : .name = "pattern",
6001 : : .help = "flex pattern handle",
6002 : : .next = NEXT(item_flex, NEXT_ENTRY(COMMON_FLEX_HANDLE),
6003 : : NEXT_ENTRY(ITEM_PARAM_IS)),
6004 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_flex, pattern)),
6005 : : },
6006 : : [ITEM_L2TPV2] = {
6007 : : .name = "l2tpv2",
6008 : : .help = "match L2TPv2 header",
6009 : : .priv = PRIV_ITEM(L2TPV2, sizeof(struct rte_flow_item_l2tpv2)),
6010 : : .next = NEXT(item_l2tpv2),
6011 : : .call = parse_vc,
6012 : : },
6013 : : [ITEM_L2TPV2_TYPE] = {
6014 : : .name = "type",
6015 : : .help = "type of l2tpv2",
6016 : : .next = NEXT(item_l2tpv2_type),
6017 : : .args = ARGS(ARG_ENTRY_HTON(struct rte_flow_item_l2tpv2)),
6018 : : },
6019 : : [ITEM_L2TPV2_TYPE_DATA] = {
6020 : : .name = "data",
6021 : : .help = "Type #7: data message without any options",
6022 : : .next = NEXT(item_l2tpv2_type_data),
6023 : : .call = parse_vc_item_l2tpv2_type,
6024 : : },
6025 : : [ITEM_L2TPV2_MSG_DATA_TUNNEL_ID] = {
6026 : : .name = "tunnel_id",
6027 : : .help = "tunnel identifier",
6028 : : .next = NEXT(item_l2tpv2_type_data,
6029 : : NEXT_ENTRY(COMMON_UNSIGNED),
6030 : : item_param),
6031 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6032 : : hdr.type7.tunnel_id)),
6033 : : },
6034 : : [ITEM_L2TPV2_MSG_DATA_SESSION_ID] = {
6035 : : .name = "session_id",
6036 : : .help = "session identifier",
6037 : : .next = NEXT(item_l2tpv2_type_data,
6038 : : NEXT_ENTRY(COMMON_UNSIGNED),
6039 : : item_param),
6040 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6041 : : hdr.type7.session_id)),
6042 : : },
6043 : : [ITEM_L2TPV2_TYPE_DATA_L] = {
6044 : : .name = "data_l",
6045 : : .help = "Type #6: data message with length option",
6046 : : .next = NEXT(item_l2tpv2_type_data_l),
6047 : : .call = parse_vc_item_l2tpv2_type,
6048 : : },
6049 : : [ITEM_L2TPV2_MSG_DATA_L_LENGTH] = {
6050 : : .name = "length",
6051 : : .help = "message length",
6052 : : .next = NEXT(item_l2tpv2_type_data_l,
6053 : : NEXT_ENTRY(COMMON_UNSIGNED),
6054 : : item_param),
6055 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6056 : : hdr.type6.length)),
6057 : : },
6058 : : [ITEM_L2TPV2_MSG_DATA_L_TUNNEL_ID] = {
6059 : : .name = "tunnel_id",
6060 : : .help = "tunnel identifier",
6061 : : .next = NEXT(item_l2tpv2_type_data_l,
6062 : : NEXT_ENTRY(COMMON_UNSIGNED),
6063 : : item_param),
6064 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6065 : : hdr.type6.tunnel_id)),
6066 : : },
6067 : : [ITEM_L2TPV2_MSG_DATA_L_SESSION_ID] = {
6068 : : .name = "session_id",
6069 : : .help = "session identifier",
6070 : : .next = NEXT(item_l2tpv2_type_data_l,
6071 : : NEXT_ENTRY(COMMON_UNSIGNED),
6072 : : item_param),
6073 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6074 : : hdr.type6.session_id)),
6075 : : },
6076 : : [ITEM_L2TPV2_TYPE_DATA_S] = {
6077 : : .name = "data_s",
6078 : : .help = "Type #5: data message with ns, nr option",
6079 : : .next = NEXT(item_l2tpv2_type_data_s),
6080 : : .call = parse_vc_item_l2tpv2_type,
6081 : : },
6082 : : [ITEM_L2TPV2_MSG_DATA_S_TUNNEL_ID] = {
6083 : : .name = "tunnel_id",
6084 : : .help = "tunnel identifier",
6085 : : .next = NEXT(item_l2tpv2_type_data_s,
6086 : : NEXT_ENTRY(COMMON_UNSIGNED),
6087 : : item_param),
6088 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6089 : : hdr.type5.tunnel_id)),
6090 : : },
6091 : : [ITEM_L2TPV2_MSG_DATA_S_SESSION_ID] = {
6092 : : .name = "session_id",
6093 : : .help = "session identifier",
6094 : : .next = NEXT(item_l2tpv2_type_data_s,
6095 : : NEXT_ENTRY(COMMON_UNSIGNED),
6096 : : item_param),
6097 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6098 : : hdr.type5.session_id)),
6099 : : },
6100 : : [ITEM_L2TPV2_MSG_DATA_S_NS] = {
6101 : : .name = "ns",
6102 : : .help = "sequence number for message",
6103 : : .next = NEXT(item_l2tpv2_type_data_s,
6104 : : NEXT_ENTRY(COMMON_UNSIGNED),
6105 : : item_param),
6106 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6107 : : hdr.type5.ns)),
6108 : : },
6109 : : [ITEM_L2TPV2_MSG_DATA_S_NR] = {
6110 : : .name = "nr",
6111 : : .help = "sequence number for next receive message",
6112 : : .next = NEXT(item_l2tpv2_type_data_s,
6113 : : NEXT_ENTRY(COMMON_UNSIGNED),
6114 : : item_param),
6115 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6116 : : hdr.type5.nr)),
6117 : : },
6118 : : [ITEM_L2TPV2_TYPE_DATA_O] = {
6119 : : .name = "data_o",
6120 : : .help = "Type #4: data message with offset option",
6121 : : .next = NEXT(item_l2tpv2_type_data_o),
6122 : : .call = parse_vc_item_l2tpv2_type,
6123 : : },
6124 : : [ITEM_L2TPV2_MSG_DATA_O_TUNNEL_ID] = {
6125 : : .name = "tunnel_id",
6126 : : .help = "tunnel identifier",
6127 : : .next = NEXT(item_l2tpv2_type_data_o,
6128 : : NEXT_ENTRY(COMMON_UNSIGNED),
6129 : : item_param),
6130 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6131 : : hdr.type4.tunnel_id)),
6132 : : },
6133 : : [ITEM_L2TPV2_MSG_DATA_O_SESSION_ID] = {
6134 : : .name = "session_id",
6135 : : .help = "session identifier",
6136 : : .next = NEXT(item_l2tpv2_type_data_o,
6137 : : NEXT_ENTRY(COMMON_UNSIGNED),
6138 : : item_param),
6139 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6140 : : hdr.type5.session_id)),
6141 : : },
6142 : : [ITEM_L2TPV2_MSG_DATA_O_OFFSET] = {
6143 : : .name = "offset_size",
6144 : : .help = "the size of offset padding",
6145 : : .next = NEXT(item_l2tpv2_type_data_o,
6146 : : NEXT_ENTRY(COMMON_UNSIGNED),
6147 : : item_param),
6148 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6149 : : hdr.type4.offset_size)),
6150 : : },
6151 : : [ITEM_L2TPV2_TYPE_DATA_L_S] = {
6152 : : .name = "data_l_s",
6153 : : .help = "Type #3: data message contains length, ns, nr "
6154 : : "options",
6155 : : .next = NEXT(item_l2tpv2_type_data_l_s),
6156 : : .call = parse_vc_item_l2tpv2_type,
6157 : : },
6158 : : [ITEM_L2TPV2_MSG_DATA_L_S_LENGTH] = {
6159 : : .name = "length",
6160 : : .help = "message length",
6161 : : .next = NEXT(item_l2tpv2_type_data_l_s,
6162 : : NEXT_ENTRY(COMMON_UNSIGNED),
6163 : : item_param),
6164 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6165 : : hdr.type3.length)),
6166 : : },
6167 : : [ITEM_L2TPV2_MSG_DATA_L_S_TUNNEL_ID] = {
6168 : : .name = "tunnel_id",
6169 : : .help = "tunnel identifier",
6170 : : .next = NEXT(item_l2tpv2_type_data_l_s,
6171 : : NEXT_ENTRY(COMMON_UNSIGNED),
6172 : : item_param),
6173 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6174 : : hdr.type3.tunnel_id)),
6175 : : },
6176 : : [ITEM_L2TPV2_MSG_DATA_L_S_SESSION_ID] = {
6177 : : .name = "session_id",
6178 : : .help = "session identifier",
6179 : : .next = NEXT(item_l2tpv2_type_data_l_s,
6180 : : NEXT_ENTRY(COMMON_UNSIGNED),
6181 : : item_param),
6182 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6183 : : hdr.type3.session_id)),
6184 : : },
6185 : : [ITEM_L2TPV2_MSG_DATA_L_S_NS] = {
6186 : : .name = "ns",
6187 : : .help = "sequence number for message",
6188 : : .next = NEXT(item_l2tpv2_type_data_l_s,
6189 : : NEXT_ENTRY(COMMON_UNSIGNED),
6190 : : item_param),
6191 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6192 : : hdr.type3.ns)),
6193 : : },
6194 : : [ITEM_L2TPV2_MSG_DATA_L_S_NR] = {
6195 : : .name = "nr",
6196 : : .help = "sequence number for next receive message",
6197 : : .next = NEXT(item_l2tpv2_type_data_l_s,
6198 : : NEXT_ENTRY(COMMON_UNSIGNED),
6199 : : item_param),
6200 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6201 : : hdr.type3.nr)),
6202 : : },
6203 : : [ITEM_L2TPV2_TYPE_CTRL] = {
6204 : : .name = "control",
6205 : : .help = "Type #3: conrtol message contains length, ns, nr "
6206 : : "options",
6207 : : .next = NEXT(item_l2tpv2_type_ctrl),
6208 : : .call = parse_vc_item_l2tpv2_type,
6209 : : },
6210 : : [ITEM_L2TPV2_MSG_CTRL_LENGTH] = {
6211 : : .name = "length",
6212 : : .help = "message length",
6213 : : .next = NEXT(item_l2tpv2_type_ctrl,
6214 : : NEXT_ENTRY(COMMON_UNSIGNED),
6215 : : item_param),
6216 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6217 : : hdr.type3.length)),
6218 : : },
6219 : : [ITEM_L2TPV2_MSG_CTRL_TUNNEL_ID] = {
6220 : : .name = "tunnel_id",
6221 : : .help = "tunnel identifier",
6222 : : .next = NEXT(item_l2tpv2_type_ctrl,
6223 : : NEXT_ENTRY(COMMON_UNSIGNED),
6224 : : item_param),
6225 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6226 : : hdr.type3.tunnel_id)),
6227 : : },
6228 : : [ITEM_L2TPV2_MSG_CTRL_SESSION_ID] = {
6229 : : .name = "session_id",
6230 : : .help = "session identifier",
6231 : : .next = NEXT(item_l2tpv2_type_ctrl,
6232 : : NEXT_ENTRY(COMMON_UNSIGNED),
6233 : : item_param),
6234 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6235 : : hdr.type3.session_id)),
6236 : : },
6237 : : [ITEM_L2TPV2_MSG_CTRL_NS] = {
6238 : : .name = "ns",
6239 : : .help = "sequence number for message",
6240 : : .next = NEXT(item_l2tpv2_type_ctrl,
6241 : : NEXT_ENTRY(COMMON_UNSIGNED),
6242 : : item_param),
6243 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6244 : : hdr.type3.ns)),
6245 : : },
6246 : : [ITEM_L2TPV2_MSG_CTRL_NR] = {
6247 : : .name = "nr",
6248 : : .help = "sequence number for next receive message",
6249 : : .next = NEXT(item_l2tpv2_type_ctrl,
6250 : : NEXT_ENTRY(COMMON_UNSIGNED),
6251 : : item_param),
6252 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6253 : : hdr.type3.nr)),
6254 : : },
6255 : : [ITEM_PPP] = {
6256 : : .name = "ppp",
6257 : : .help = "match PPP header",
6258 : : .priv = PRIV_ITEM(PPP, sizeof(struct rte_flow_item_ppp)),
6259 : : .next = NEXT(item_ppp),
6260 : : .call = parse_vc,
6261 : : },
6262 : : [ITEM_PPP_ADDR] = {
6263 : : .name = "addr",
6264 : : .help = "PPP address",
6265 : : .next = NEXT(item_ppp, NEXT_ENTRY(COMMON_UNSIGNED),
6266 : : item_param),
6267 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ppp, hdr.addr)),
6268 : : },
6269 : : [ITEM_PPP_CTRL] = {
6270 : : .name = "ctrl",
6271 : : .help = "PPP control",
6272 : : .next = NEXT(item_ppp, NEXT_ENTRY(COMMON_UNSIGNED),
6273 : : item_param),
6274 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ppp, hdr.ctrl)),
6275 : : },
6276 : : [ITEM_PPP_PROTO_ID] = {
6277 : : .name = "proto_id",
6278 : : .help = "PPP protocol identifier",
6279 : : .next = NEXT(item_ppp, NEXT_ENTRY(COMMON_UNSIGNED),
6280 : : item_param),
6281 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ppp,
6282 : : hdr.proto_id)),
6283 : : },
6284 : : [ITEM_METER] = {
6285 : : .name = "meter",
6286 : : .help = "match meter color",
6287 : : .priv = PRIV_ITEM(METER_COLOR,
6288 : : sizeof(struct rte_flow_item_meter_color)),
6289 : : .next = NEXT(item_meter),
6290 : : .call = parse_vc,
6291 : : },
6292 : : [ITEM_METER_COLOR] = {
6293 : : .name = "color",
6294 : : .help = "meter color",
6295 : : .next = NEXT(item_meter,
6296 : : NEXT_ENTRY(COMMON_METER_COLOR_NAME),
6297 : : item_param),
6298 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_meter_color,
6299 : : color)),
6300 : : },
6301 : : [ITEM_QUOTA] = {
6302 : : .name = "quota",
6303 : : .help = "match quota",
6304 : : .priv = PRIV_ITEM(QUOTA, sizeof(struct rte_flow_item_quota)),
6305 : : .next = NEXT(item_quota),
6306 : : .call = parse_vc
6307 : : },
6308 : : [ITEM_QUOTA_STATE] = {
6309 : : .name = "quota_state",
6310 : : .help = "quota state",
6311 : : .next = NEXT(item_quota, NEXT_ENTRY(ITEM_QUOTA_STATE_NAME),
6312 : : NEXT_ENTRY(ITEM_PARAM_SPEC, ITEM_PARAM_MASK)),
6313 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_quota, state))
6314 : : },
6315 : : [ITEM_QUOTA_STATE_NAME] = {
6316 : : .name = "state_name",
6317 : : .help = "quota state name",
6318 : : .call = parse_quota_state_name,
6319 : : .comp = comp_quota_state_name
6320 : : },
6321 : : [ITEM_IB_BTH] = {
6322 : : .name = "ib_bth",
6323 : : .help = "match ib bth fields",
6324 : : .priv = PRIV_ITEM(IB_BTH,
6325 : : sizeof(struct rte_flow_item_ib_bth)),
6326 : : .next = NEXT(item_ib_bth),
6327 : : .call = parse_vc,
6328 : : },
6329 : : [ITEM_IB_BTH_OPCODE] = {
6330 : : .name = "opcode",
6331 : : .help = "match ib bth opcode",
6332 : : .next = NEXT(item_ib_bth, NEXT_ENTRY(COMMON_UNSIGNED),
6333 : : item_param),
6334 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ib_bth,
6335 : : hdr.opcode)),
6336 : : },
6337 : : [ITEM_IB_BTH_PKEY] = {
6338 : : .name = "pkey",
6339 : : .help = "partition key",
6340 : : .next = NEXT(item_ib_bth, NEXT_ENTRY(COMMON_UNSIGNED),
6341 : : item_param),
6342 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ib_bth,
6343 : : hdr.pkey)),
6344 : : },
6345 : : [ITEM_IB_BTH_DST_QPN] = {
6346 : : .name = "dst_qp",
6347 : : .help = "destination qp",
6348 : : .next = NEXT(item_ib_bth, NEXT_ENTRY(COMMON_UNSIGNED),
6349 : : item_param),
6350 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ib_bth,
6351 : : hdr.dst_qp)),
6352 : : },
6353 : : [ITEM_IB_BTH_PSN] = {
6354 : : .name = "psn",
6355 : : .help = "packet sequence number",
6356 : : .next = NEXT(item_ib_bth, NEXT_ENTRY(COMMON_UNSIGNED),
6357 : : item_param),
6358 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ib_bth,
6359 : : hdr.psn)),
6360 : : },
6361 : : [ITEM_PTYPE] = {
6362 : : .name = "ptype",
6363 : : .help = "match L2/L3/L4 and tunnel information",
6364 : : .priv = PRIV_ITEM(PTYPE,
6365 : : sizeof(struct rte_flow_item_ptype)),
6366 : : .next = NEXT(item_ptype),
6367 : : .call = parse_vc,
6368 : : },
6369 : : [ITEM_PTYPE_VALUE] = {
6370 : : .name = "packet_type",
6371 : : .help = "packet type as defined in rte_mbuf_ptype",
6372 : : .next = NEXT(item_ptype, NEXT_ENTRY(COMMON_UNSIGNED),
6373 : : item_param),
6374 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ptype, packet_type)),
6375 : : },
6376 : : [ITEM_NSH] = {
6377 : : .name = "nsh",
6378 : : .help = "match NSH header",
6379 : : .priv = PRIV_ITEM(NSH,
6380 : : sizeof(struct rte_flow_item_nsh)),
6381 : : .next = NEXT(item_nsh),
6382 : : .call = parse_vc,
6383 : : },
6384 : : [ITEM_COMPARE] = {
6385 : : .name = "compare",
6386 : : .help = "match with the comparison result",
6387 : : .priv = PRIV_ITEM(COMPARE, sizeof(struct rte_flow_item_compare)),
6388 : : .next = NEXT(NEXT_ENTRY(ITEM_COMPARE_OP)),
6389 : : .call = parse_vc,
6390 : : },
6391 : : [ITEM_COMPARE_OP] = {
6392 : : .name = "op",
6393 : : .help = "operation type",
6394 : : .next = NEXT(item_compare_field,
6395 : : NEXT_ENTRY(ITEM_COMPARE_OP_VALUE), item_param),
6396 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, operation)),
6397 : : },
6398 : : [ITEM_COMPARE_OP_VALUE] = {
6399 : : .name = "{operation}",
6400 : : .help = "operation type value",
6401 : : .call = parse_vc_compare_op,
6402 : : .comp = comp_set_compare_op,
6403 : : },
6404 : : [ITEM_COMPARE_FIELD_A_TYPE] = {
6405 : : .name = "a_type",
6406 : : .help = "compared field type",
6407 : : .next = NEXT(compare_field_a,
6408 : : NEXT_ENTRY(ITEM_COMPARE_FIELD_A_TYPE_VALUE), item_param),
6409 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, a.field)),
6410 : : },
6411 : : [ITEM_COMPARE_FIELD_A_TYPE_VALUE] = {
6412 : : .name = "{a_type}",
6413 : : .help = "compared field type value",
6414 : : .call = parse_vc_compare_field_id,
6415 : : .comp = comp_set_compare_field_id,
6416 : : },
6417 : : [ITEM_COMPARE_FIELD_A_LEVEL] = {
6418 : : .name = "a_level",
6419 : : .help = "compared field level",
6420 : : .next = NEXT(compare_field_a,
6421 : : NEXT_ENTRY(ITEM_COMPARE_FIELD_A_LEVEL_VALUE), item_param),
6422 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, a.level)),
6423 : : },
6424 : : [ITEM_COMPARE_FIELD_A_LEVEL_VALUE] = {
6425 : : .name = "{a_level}",
6426 : : .help = "compared field level value",
6427 : : .call = parse_vc_compare_field_level,
6428 : : .comp = comp_none,
6429 : : },
6430 : : [ITEM_COMPARE_FIELD_A_TAG_INDEX] = {
6431 : : .name = "a_tag_index",
6432 : : .help = "compared field tag array",
6433 : : .next = NEXT(compare_field_a,
6434 : : NEXT_ENTRY(COMMON_UNSIGNED), item_param),
6435 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare,
6436 : : a.tag_index)),
6437 : : },
6438 : : [ITEM_COMPARE_FIELD_A_TYPE_ID] = {
6439 : : .name = "a_type_id",
6440 : : .help = "compared field type ID",
6441 : : .next = NEXT(compare_field_a,
6442 : : NEXT_ENTRY(COMMON_UNSIGNED), item_param),
6443 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare,
6444 : : a.type)),
6445 : : },
6446 : : [ITEM_COMPARE_FIELD_A_CLASS_ID] = {
6447 : : .name = "a_class",
6448 : : .help = "compared field class ID",
6449 : : .next = NEXT(compare_field_a,
6450 : : NEXT_ENTRY(COMMON_UNSIGNED), item_param),
6451 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_compare,
6452 : : a.class_id)),
6453 : : },
6454 : : [ITEM_COMPARE_FIELD_A_OFFSET] = {
6455 : : .name = "a_offset",
6456 : : .help = "compared field bit offset",
6457 : : .next = NEXT(compare_field_a,
6458 : : NEXT_ENTRY(COMMON_UNSIGNED), item_param),
6459 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare,
6460 : : a.offset)),
6461 : : },
6462 : : [ITEM_COMPARE_FIELD_B_TYPE] = {
6463 : : .name = "b_type",
6464 : : .help = "comparator field type",
6465 : : .next = NEXT(compare_field_b,
6466 : : NEXT_ENTRY(ITEM_COMPARE_FIELD_B_TYPE_VALUE), item_param),
6467 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare,
6468 : : b.field)),
6469 : : },
6470 : : [ITEM_COMPARE_FIELD_B_TYPE_VALUE] = {
6471 : : .name = "{b_type}",
6472 : : .help = "comparator field type value",
6473 : : .call = parse_vc_compare_field_id,
6474 : : .comp = comp_set_compare_field_id,
6475 : : },
6476 : : [ITEM_COMPARE_FIELD_B_LEVEL] = {
6477 : : .name = "b_level",
6478 : : .help = "comparator field level",
6479 : : .next = NEXT(compare_field_b,
6480 : : NEXT_ENTRY(ITEM_COMPARE_FIELD_B_LEVEL_VALUE), item_param),
6481 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare,
6482 : : b.level)),
6483 : : },
6484 : : [ITEM_COMPARE_FIELD_B_LEVEL_VALUE] = {
6485 : : .name = "{b_level}",
6486 : : .help = "comparator field level value",
6487 : : .call = parse_vc_compare_field_level,
6488 : : .comp = comp_none,
6489 : : },
6490 : : [ITEM_COMPARE_FIELD_B_TAG_INDEX] = {
6491 : : .name = "b_tag_index",
6492 : : .help = "comparator field tag array",
6493 : : .next = NEXT(compare_field_b,
6494 : : NEXT_ENTRY(COMMON_UNSIGNED), item_param),
6495 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare,
6496 : : b.tag_index)),
6497 : : },
6498 : : [ITEM_COMPARE_FIELD_B_TYPE_ID] = {
6499 : : .name = "b_type_id",
6500 : : .help = "comparator field type ID",
6501 : : .next = NEXT(compare_field_b,
6502 : : NEXT_ENTRY(COMMON_UNSIGNED), item_param),
6503 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare,
6504 : : b.type)),
6505 : : },
6506 : : [ITEM_COMPARE_FIELD_B_CLASS_ID] = {
6507 : : .name = "b_class",
6508 : : .help = "comparator field class ID",
6509 : : .next = NEXT(compare_field_b,
6510 : : NEXT_ENTRY(COMMON_UNSIGNED), item_param),
6511 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_compare,
6512 : : b.class_id)),
6513 : : },
6514 : : [ITEM_COMPARE_FIELD_B_OFFSET] = {
6515 : : .name = "b_offset",
6516 : : .help = "comparator field bit offset",
6517 : : .next = NEXT(compare_field_b,
6518 : : NEXT_ENTRY(COMMON_UNSIGNED), item_param),
6519 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare,
6520 : : b.offset)),
6521 : : },
6522 : : [ITEM_COMPARE_FIELD_B_VALUE] = {
6523 : : .name = "b_value",
6524 : : .help = "comparator immediate value",
6525 : : .next = NEXT(compare_field_b,
6526 : : NEXT_ENTRY(COMMON_HEX), item_param),
6527 : : .args = ARGS(ARGS_ENTRY_ARB(0, 0),
6528 : : ARGS_ENTRY_ARB(0, 0),
6529 : : ARGS_ENTRY(struct rte_flow_item_compare,
6530 : : b.value)),
6531 : : },
6532 : : [ITEM_COMPARE_FIELD_B_POINTER] = {
6533 : : .name = "b_ptr",
6534 : : .help = "pointer to comparator immediate value",
6535 : : .next = NEXT(compare_field_b,
6536 : : NEXT_ENTRY(COMMON_HEX), item_param),
6537 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare,
6538 : : b.pvalue),
6539 : : ARGS_ENTRY_ARB(0, 0),
6540 : : ARGS_ENTRY_ARB
6541 : : (sizeof(struct rte_flow_item_compare),
6542 : : FLOW_FIELD_PATTERN_SIZE)),
6543 : : },
6544 : : [ITEM_COMPARE_FIELD_WIDTH] = {
6545 : : .name = "width",
6546 : : .help = "number of bits to compare",
6547 : : .next = NEXT(item_compare_field,
6548 : : NEXT_ENTRY(COMMON_UNSIGNED), item_param),
6549 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare,
6550 : : width)),
6551 : : },
6552 : :
6553 : : /* Validate/create actions. */
6554 : : [ACTIONS] = {
6555 : : .name = "actions",
6556 : : .help = "submit a list of associated actions",
6557 : : .next = NEXT(next_action),
6558 : : .call = parse_vc,
6559 : : },
6560 : : [ACTION_NEXT] = {
6561 : : .name = "/",
6562 : : .help = "specify next action",
6563 : : .next = NEXT(next_action),
6564 : : },
6565 : : [ACTION_END] = {
6566 : : .name = "end",
6567 : : .help = "end list of actions",
6568 : : .priv = PRIV_ACTION(END, 0),
6569 : : .call = parse_vc,
6570 : : },
6571 : : [ACTION_VOID] = {
6572 : : .name = "void",
6573 : : .help = "no-op action",
6574 : : .priv = PRIV_ACTION(VOID, 0),
6575 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
6576 : : .call = parse_vc,
6577 : : },
6578 : : [ACTION_PASSTHRU] = {
6579 : : .name = "passthru",
6580 : : .help = "let subsequent rule process matched packets",
6581 : : .priv = PRIV_ACTION(PASSTHRU, 0),
6582 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
6583 : : .call = parse_vc,
6584 : : },
6585 : : [ACTION_SKIP_CMAN] = {
6586 : : .name = "skip_cman",
6587 : : .help = "bypass cman on received packets",
6588 : : .priv = PRIV_ACTION(SKIP_CMAN, 0),
6589 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
6590 : : .call = parse_vc,
6591 : : },
6592 : : [ACTION_JUMP] = {
6593 : : .name = "jump",
6594 : : .help = "redirect traffic to a given group",
6595 : : .priv = PRIV_ACTION(JUMP, sizeof(struct rte_flow_action_jump)),
6596 : : .next = NEXT(action_jump),
6597 : : .call = parse_vc,
6598 : : },
6599 : : [ACTION_JUMP_GROUP] = {
6600 : : .name = "group",
6601 : : .help = "group to redirect traffic to",
6602 : : .next = NEXT(action_jump, NEXT_ENTRY(COMMON_UNSIGNED)),
6603 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump, group)),
6604 : : .call = parse_vc_conf,
6605 : : },
6606 : : [ACTION_MARK] = {
6607 : : .name = "mark",
6608 : : .help = "attach 32 bit value to packets",
6609 : : .priv = PRIV_ACTION(MARK, sizeof(struct rte_flow_action_mark)),
6610 : : .next = NEXT(action_mark),
6611 : : .call = parse_vc,
6612 : : },
6613 : : [ACTION_MARK_ID] = {
6614 : : .name = "id",
6615 : : .help = "32 bit value to return with packets",
6616 : : .next = NEXT(action_mark, NEXT_ENTRY(COMMON_UNSIGNED)),
6617 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_mark, id)),
6618 : : .call = parse_vc_conf,
6619 : : },
6620 : : [ACTION_FLAG] = {
6621 : : .name = "flag",
6622 : : .help = "flag packets",
6623 : : .priv = PRIV_ACTION(FLAG, 0),
6624 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
6625 : : .call = parse_vc,
6626 : : },
6627 : : [ACTION_QUEUE] = {
6628 : : .name = "queue",
6629 : : .help = "assign packets to a given queue index",
6630 : : .priv = PRIV_ACTION(QUEUE,
6631 : : sizeof(struct rte_flow_action_queue)),
6632 : : .next = NEXT(action_queue),
6633 : : .call = parse_vc,
6634 : : },
6635 : : [ACTION_QUEUE_INDEX] = {
6636 : : .name = "index",
6637 : : .help = "queue index to use",
6638 : : .next = NEXT(action_queue, NEXT_ENTRY(COMMON_UNSIGNED)),
6639 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_queue, index)),
6640 : : .call = parse_vc_conf,
6641 : : },
6642 : : [ACTION_DROP] = {
6643 : : .name = "drop",
6644 : : .help = "drop packets (note: passthru has priority)",
6645 : : .priv = PRIV_ACTION(DROP, 0),
6646 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
6647 : : .call = parse_vc,
6648 : : },
6649 : : [ACTION_COUNT] = {
6650 : : .name = "count",
6651 : : .help = "enable counters for this rule",
6652 : : .priv = PRIV_ACTION(COUNT,
6653 : : sizeof(struct rte_flow_action_count)),
6654 : : .next = NEXT(action_count),
6655 : : .call = parse_vc,
6656 : : },
6657 : : [ACTION_COUNT_ID] = {
6658 : : .name = "identifier",
6659 : : .help = "counter identifier to use",
6660 : : .next = NEXT(action_count, NEXT_ENTRY(COMMON_UNSIGNED)),
6661 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_count, id)),
6662 : : .call = parse_vc_conf,
6663 : : },
6664 : : [ACTION_RSS] = {
6665 : : .name = "rss",
6666 : : .help = "spread packets among several queues",
6667 : : .priv = PRIV_ACTION(RSS, sizeof(struct action_rss_data)),
6668 : : .next = NEXT(action_rss),
6669 : : .call = parse_vc_action_rss,
6670 : : },
6671 : : [ACTION_RSS_FUNC] = {
6672 : : .name = "func",
6673 : : .help = "RSS hash function to apply",
6674 : : .next = NEXT(action_rss,
6675 : : NEXT_ENTRY(ACTION_RSS_FUNC_DEFAULT,
6676 : : ACTION_RSS_FUNC_TOEPLITZ,
6677 : : ACTION_RSS_FUNC_SIMPLE_XOR,
6678 : : ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ)),
6679 : : },
6680 : : [ACTION_RSS_FUNC_DEFAULT] = {
6681 : : .name = "default",
6682 : : .help = "default hash function",
6683 : : .call = parse_vc_action_rss_func,
6684 : : },
6685 : : [ACTION_RSS_FUNC_TOEPLITZ] = {
6686 : : .name = "toeplitz",
6687 : : .help = "Toeplitz hash function",
6688 : : .call = parse_vc_action_rss_func,
6689 : : },
6690 : : [ACTION_RSS_FUNC_SIMPLE_XOR] = {
6691 : : .name = "simple_xor",
6692 : : .help = "simple XOR hash function",
6693 : : .call = parse_vc_action_rss_func,
6694 : : },
6695 : : [ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ] = {
6696 : : .name = "symmetric_toeplitz",
6697 : : .help = "Symmetric Toeplitz hash function",
6698 : : .call = parse_vc_action_rss_func,
6699 : : },
6700 : : [ACTION_RSS_LEVEL] = {
6701 : : .name = "level",
6702 : : .help = "encapsulation level for \"types\"",
6703 : : .next = NEXT(action_rss, NEXT_ENTRY(COMMON_UNSIGNED)),
6704 : : .args = ARGS(ARGS_ENTRY_ARB
6705 : : (offsetof(struct action_rss_data, conf) +
6706 : : offsetof(struct rte_flow_action_rss, level),
6707 : : sizeof(((struct rte_flow_action_rss *)0)->
6708 : : level))),
6709 : : },
6710 : : [ACTION_RSS_TYPES] = {
6711 : : .name = "types",
6712 : : .help = "specific RSS hash types",
6713 : : .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)),
6714 : : },
6715 : : [ACTION_RSS_TYPE] = {
6716 : : .name = "{type}",
6717 : : .help = "RSS hash type",
6718 : : .call = parse_vc_action_rss_type,
6719 : : .comp = comp_vc_action_rss_type,
6720 : : },
6721 : : [ACTION_RSS_KEY] = {
6722 : : .name = "key",
6723 : : .help = "RSS hash key",
6724 : : .next = NEXT(action_rss, NEXT_ENTRY(COMMON_HEX)),
6725 : : .args = ARGS(ARGS_ENTRY_ARB
6726 : : (offsetof(struct action_rss_data, conf) +
6727 : : offsetof(struct rte_flow_action_rss, key),
6728 : : sizeof(((struct rte_flow_action_rss *)0)->key)),
6729 : : ARGS_ENTRY_ARB
6730 : : (offsetof(struct action_rss_data, conf) +
6731 : : offsetof(struct rte_flow_action_rss, key_len),
6732 : : sizeof(((struct rte_flow_action_rss *)0)->
6733 : : key_len)),
6734 : : ARGS_ENTRY(struct action_rss_data, key)),
6735 : : },
6736 : : [ACTION_RSS_KEY_LEN] = {
6737 : : .name = "key_len",
6738 : : .help = "RSS hash key length in bytes",
6739 : : .next = NEXT(action_rss, NEXT_ENTRY(COMMON_UNSIGNED)),
6740 : : .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
6741 : : (offsetof(struct action_rss_data, conf) +
6742 : : offsetof(struct rte_flow_action_rss, key_len),
6743 : : sizeof(((struct rte_flow_action_rss *)0)->
6744 : : key_len),
6745 : : 0,
6746 : : RSS_HASH_KEY_LENGTH)),
6747 : : },
6748 : : [ACTION_RSS_QUEUES] = {
6749 : : .name = "queues",
6750 : : .help = "queue indices to use",
6751 : : .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_QUEUE)),
6752 : : .call = parse_vc_conf,
6753 : : },
6754 : : [ACTION_RSS_QUEUE] = {
6755 : : .name = "{queue}",
6756 : : .help = "queue index",
6757 : : .call = parse_vc_action_rss_queue,
6758 : : .comp = comp_vc_action_rss_queue,
6759 : : },
6760 : : [ACTION_PF] = {
6761 : : .name = "pf",
6762 : : .help = "direct traffic to physical function",
6763 : : .priv = PRIV_ACTION(PF, 0),
6764 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
6765 : : .call = parse_vc,
6766 : : },
6767 : : [ACTION_VF] = {
6768 : : .name = "vf",
6769 : : .help = "direct traffic to a virtual function ID",
6770 : : .priv = PRIV_ACTION(VF, sizeof(struct rte_flow_action_vf)),
6771 : : .next = NEXT(action_vf),
6772 : : .call = parse_vc,
6773 : : },
6774 : : [ACTION_VF_ORIGINAL] = {
6775 : : .name = "original",
6776 : : .help = "use original VF ID if possible",
6777 : : .next = NEXT(action_vf, NEXT_ENTRY(COMMON_BOOLEAN)),
6778 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_vf,
6779 : : original, 1)),
6780 : : .call = parse_vc_conf,
6781 : : },
6782 : : [ACTION_VF_ID] = {
6783 : : .name = "id",
6784 : : .help = "VF ID",
6785 : : .next = NEXT(action_vf, NEXT_ENTRY(COMMON_UNSIGNED)),
6786 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)),
6787 : : .call = parse_vc_conf,
6788 : : },
6789 : : [ACTION_PORT_ID] = {
6790 : : .name = "port_id",
6791 : : .help = "direct matching traffic to a given DPDK port ID",
6792 : : .priv = PRIV_ACTION(PORT_ID,
6793 : : sizeof(struct rte_flow_action_port_id)),
6794 : : .next = NEXT(action_port_id),
6795 : : .call = parse_vc,
6796 : : },
6797 : : [ACTION_PORT_ID_ORIGINAL] = {
6798 : : .name = "original",
6799 : : .help = "use original DPDK port ID if possible",
6800 : : .next = NEXT(action_port_id, NEXT_ENTRY(COMMON_BOOLEAN)),
6801 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_port_id,
6802 : : original, 1)),
6803 : : .call = parse_vc_conf,
6804 : : },
6805 : : [ACTION_PORT_ID_ID] = {
6806 : : .name = "id",
6807 : : .help = "DPDK port ID",
6808 : : .next = NEXT(action_port_id, NEXT_ENTRY(COMMON_UNSIGNED)),
6809 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_port_id, id)),
6810 : : .call = parse_vc_conf,
6811 : : },
6812 : : [ACTION_METER] = {
6813 : : .name = "meter",
6814 : : .help = "meter the directed packets at given id",
6815 : : .priv = PRIV_ACTION(METER,
6816 : : sizeof(struct rte_flow_action_meter)),
6817 : : .next = NEXT(action_meter),
6818 : : .call = parse_vc,
6819 : : },
6820 : : [ACTION_METER_COLOR] = {
6821 : : .name = "color",
6822 : : .help = "meter color for the packets",
6823 : : .priv = PRIV_ACTION(METER_COLOR,
6824 : : sizeof(struct rte_flow_action_meter_color)),
6825 : : .next = NEXT(action_meter_color),
6826 : : .call = parse_vc,
6827 : : },
6828 : : [ACTION_METER_COLOR_TYPE] = {
6829 : : .name = "type",
6830 : : .help = "specific meter color",
6831 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT),
6832 : : NEXT_ENTRY(ACTION_METER_COLOR_GREEN,
6833 : : ACTION_METER_COLOR_YELLOW,
6834 : : ACTION_METER_COLOR_RED)),
6835 : : },
6836 : : [ACTION_METER_COLOR_GREEN] = {
6837 : : .name = "green",
6838 : : .help = "meter color green",
6839 : : .call = parse_vc_action_meter_color_type,
6840 : : },
6841 : : [ACTION_METER_COLOR_YELLOW] = {
6842 : : .name = "yellow",
6843 : : .help = "meter color yellow",
6844 : : .call = parse_vc_action_meter_color_type,
6845 : : },
6846 : : [ACTION_METER_COLOR_RED] = {
6847 : : .name = "red",
6848 : : .help = "meter color red",
6849 : : .call = parse_vc_action_meter_color_type,
6850 : : },
6851 : : [ACTION_METER_ID] = {
6852 : : .name = "mtr_id",
6853 : : .help = "meter id to use",
6854 : : .next = NEXT(action_meter, NEXT_ENTRY(COMMON_UNSIGNED)),
6855 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter, mtr_id)),
6856 : : .call = parse_vc_conf,
6857 : : },
6858 : : [ACTION_METER_MARK] = {
6859 : : .name = "meter_mark",
6860 : : .help = "meter the directed packets using profile and policy",
6861 : : .priv = PRIV_ACTION(METER_MARK,
6862 : : sizeof(struct rte_flow_action_meter_mark)),
6863 : : .next = NEXT(action_meter_mark),
6864 : : .call = parse_vc,
6865 : : },
6866 : : [ACTION_METER_MARK_CONF] = {
6867 : : .name = "meter_mark_conf",
6868 : : .help = "meter mark configuration",
6869 : : .priv = PRIV_ACTION(METER_MARK,
6870 : : sizeof(struct rte_flow_action_meter_mark)),
6871 : : .next = NEXT(NEXT_ENTRY(ACTION_METER_MARK_CONF_COLOR)),
6872 : : .call = parse_vc,
6873 : : },
6874 : : [ACTION_METER_MARK_CONF_COLOR] = {
6875 : : .name = "mtr_update_init_color",
6876 : : .help = "meter update init color",
6877 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT),
6878 : : NEXT_ENTRY(COMMON_METER_COLOR_NAME)),
6879 : : .args = ARGS(ARGS_ENTRY
6880 : : (struct rte_flow_indirect_update_flow_meter_mark,
6881 : : init_color)),
6882 : : },
6883 : : [ACTION_METER_PROFILE] = {
6884 : : .name = "mtr_profile",
6885 : : .help = "meter profile id to use",
6886 : : .next = NEXT(NEXT_ENTRY(ACTION_METER_PROFILE_ID2PTR)),
6887 : : .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
6888 : : },
6889 : : [ACTION_METER_PROFILE_ID2PTR] = {
6890 : : .name = "{mtr_profile_id}",
6891 : : .type = "PROFILE_ID",
6892 : : .help = "meter profile id",
6893 : : .next = NEXT(action_meter_mark),
6894 : : .call = parse_meter_profile_id2ptr,
6895 : : .comp = comp_none,
6896 : : },
6897 : : [ACTION_METER_POLICY] = {
6898 : : .name = "mtr_policy",
6899 : : .help = "meter policy id to use",
6900 : : .next = NEXT(NEXT_ENTRY(ACTION_METER_POLICY_ID2PTR)),
6901 : : ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
6902 : : },
6903 : : [ACTION_METER_POLICY_ID2PTR] = {
6904 : : .name = "{mtr_policy_id}",
6905 : : .type = "POLICY_ID",
6906 : : .help = "meter policy id",
6907 : : .next = NEXT(action_meter_mark),
6908 : : .call = parse_meter_policy_id2ptr,
6909 : : .comp = comp_none,
6910 : : },
6911 : : [ACTION_METER_COLOR_MODE] = {
6912 : : .name = "mtr_color_mode",
6913 : : .help = "meter color awareness mode",
6914 : : .next = NEXT(action_meter_mark, NEXT_ENTRY(COMMON_UNSIGNED)),
6915 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter_mark, color_mode)),
6916 : : .call = parse_vc_conf,
6917 : : },
6918 : : [ACTION_METER_STATE] = {
6919 : : .name = "mtr_state",
6920 : : .help = "meter state",
6921 : : .next = NEXT(action_meter_mark, NEXT_ENTRY(COMMON_UNSIGNED)),
6922 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter_mark, state)),
6923 : : .call = parse_vc_conf,
6924 : : },
6925 : : [ACTION_OF_DEC_NW_TTL] = {
6926 : : .name = "of_dec_nw_ttl",
6927 : : .help = "OpenFlow's OFPAT_DEC_NW_TTL",
6928 : : .priv = PRIV_ACTION(OF_DEC_NW_TTL, 0),
6929 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
6930 : : .call = parse_vc,
6931 : : },
6932 : : [ACTION_OF_POP_VLAN] = {
6933 : : .name = "of_pop_vlan",
6934 : : .help = "OpenFlow's OFPAT_POP_VLAN",
6935 : : .priv = PRIV_ACTION(OF_POP_VLAN, 0),
6936 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
6937 : : .call = parse_vc,
6938 : : },
6939 : : [ACTION_OF_PUSH_VLAN] = {
6940 : : .name = "of_push_vlan",
6941 : : .help = "OpenFlow's OFPAT_PUSH_VLAN",
6942 : : .priv = PRIV_ACTION
6943 : : (OF_PUSH_VLAN,
6944 : : sizeof(struct rte_flow_action_of_push_vlan)),
6945 : : .next = NEXT(action_of_push_vlan),
6946 : : .call = parse_vc,
6947 : : },
6948 : : [ACTION_OF_PUSH_VLAN_ETHERTYPE] = {
6949 : : .name = "ethertype",
6950 : : .help = "EtherType",
6951 : : .next = NEXT(action_of_push_vlan, NEXT_ENTRY(COMMON_UNSIGNED)),
6952 : : .args = ARGS(ARGS_ENTRY_HTON
6953 : : (struct rte_flow_action_of_push_vlan,
6954 : : ethertype)),
6955 : : .call = parse_vc_conf,
6956 : : },
6957 : : [ACTION_OF_SET_VLAN_VID] = {
6958 : : .name = "of_set_vlan_vid",
6959 : : .help = "OpenFlow's OFPAT_SET_VLAN_VID",
6960 : : .priv = PRIV_ACTION
6961 : : (OF_SET_VLAN_VID,
6962 : : sizeof(struct rte_flow_action_of_set_vlan_vid)),
6963 : : .next = NEXT(action_of_set_vlan_vid),
6964 : : .call = parse_vc,
6965 : : },
6966 : : [ACTION_OF_SET_VLAN_VID_VLAN_VID] = {
6967 : : .name = "vlan_vid",
6968 : : .help = "VLAN id",
6969 : : .next = NEXT(action_of_set_vlan_vid,
6970 : : NEXT_ENTRY(COMMON_UNSIGNED)),
6971 : : .args = ARGS(ARGS_ENTRY_HTON
6972 : : (struct rte_flow_action_of_set_vlan_vid,
6973 : : vlan_vid)),
6974 : : .call = parse_vc_conf,
6975 : : },
6976 : : [ACTION_OF_SET_VLAN_PCP] = {
6977 : : .name = "of_set_vlan_pcp",
6978 : : .help = "OpenFlow's OFPAT_SET_VLAN_PCP",
6979 : : .priv = PRIV_ACTION
6980 : : (OF_SET_VLAN_PCP,
6981 : : sizeof(struct rte_flow_action_of_set_vlan_pcp)),
6982 : : .next = NEXT(action_of_set_vlan_pcp),
6983 : : .call = parse_vc,
6984 : : },
6985 : : [ACTION_OF_SET_VLAN_PCP_VLAN_PCP] = {
6986 : : .name = "vlan_pcp",
6987 : : .help = "VLAN priority",
6988 : : .next = NEXT(action_of_set_vlan_pcp,
6989 : : NEXT_ENTRY(COMMON_UNSIGNED)),
6990 : : .args = ARGS(ARGS_ENTRY_HTON
6991 : : (struct rte_flow_action_of_set_vlan_pcp,
6992 : : vlan_pcp)),
6993 : : .call = parse_vc_conf,
6994 : : },
6995 : : [ACTION_OF_POP_MPLS] = {
6996 : : .name = "of_pop_mpls",
6997 : : .help = "OpenFlow's OFPAT_POP_MPLS",
6998 : : .priv = PRIV_ACTION(OF_POP_MPLS,
6999 : : sizeof(struct rte_flow_action_of_pop_mpls)),
7000 : : .next = NEXT(action_of_pop_mpls),
7001 : : .call = parse_vc,
7002 : : },
7003 : : [ACTION_OF_POP_MPLS_ETHERTYPE] = {
7004 : : .name = "ethertype",
7005 : : .help = "EtherType",
7006 : : .next = NEXT(action_of_pop_mpls, NEXT_ENTRY(COMMON_UNSIGNED)),
7007 : : .args = ARGS(ARGS_ENTRY_HTON
7008 : : (struct rte_flow_action_of_pop_mpls,
7009 : : ethertype)),
7010 : : .call = parse_vc_conf,
7011 : : },
7012 : : [ACTION_OF_PUSH_MPLS] = {
7013 : : .name = "of_push_mpls",
7014 : : .help = "OpenFlow's OFPAT_PUSH_MPLS",
7015 : : .priv = PRIV_ACTION
7016 : : (OF_PUSH_MPLS,
7017 : : sizeof(struct rte_flow_action_of_push_mpls)),
7018 : : .next = NEXT(action_of_push_mpls),
7019 : : .call = parse_vc,
7020 : : },
7021 : : [ACTION_OF_PUSH_MPLS_ETHERTYPE] = {
7022 : : .name = "ethertype",
7023 : : .help = "EtherType",
7024 : : .next = NEXT(action_of_push_mpls, NEXT_ENTRY(COMMON_UNSIGNED)),
7025 : : .args = ARGS(ARGS_ENTRY_HTON
7026 : : (struct rte_flow_action_of_push_mpls,
7027 : : ethertype)),
7028 : : .call = parse_vc_conf,
7029 : : },
7030 : : [ACTION_VXLAN_ENCAP] = {
7031 : : .name = "vxlan_encap",
7032 : : .help = "VXLAN encapsulation, uses configuration set by \"set"
7033 : : " vxlan\"",
7034 : : .priv = PRIV_ACTION(VXLAN_ENCAP,
7035 : : sizeof(struct action_vxlan_encap_data)),
7036 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7037 : : .call = parse_vc_action_vxlan_encap,
7038 : : },
7039 : : [ACTION_VXLAN_DECAP] = {
7040 : : .name = "vxlan_decap",
7041 : : .help = "Performs a decapsulation action by stripping all"
7042 : : " headers of the VXLAN tunnel network overlay from the"
7043 : : " matched flow.",
7044 : : .priv = PRIV_ACTION(VXLAN_DECAP, 0),
7045 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7046 : : .call = parse_vc,
7047 : : },
7048 : : [ACTION_NVGRE_ENCAP] = {
7049 : : .name = "nvgre_encap",
7050 : : .help = "NVGRE encapsulation, uses configuration set by \"set"
7051 : : " nvgre\"",
7052 : : .priv = PRIV_ACTION(NVGRE_ENCAP,
7053 : : sizeof(struct action_nvgre_encap_data)),
7054 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7055 : : .call = parse_vc_action_nvgre_encap,
7056 : : },
7057 : : [ACTION_NVGRE_DECAP] = {
7058 : : .name = "nvgre_decap",
7059 : : .help = "Performs a decapsulation action by stripping all"
7060 : : " headers of the NVGRE tunnel network overlay from the"
7061 : : " matched flow.",
7062 : : .priv = PRIV_ACTION(NVGRE_DECAP, 0),
7063 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7064 : : .call = parse_vc,
7065 : : },
7066 : : [ACTION_L2_ENCAP] = {
7067 : : .name = "l2_encap",
7068 : : .help = "l2 encap, uses configuration set by"
7069 : : " \"set l2_encap\"",
7070 : : .priv = PRIV_ACTION(RAW_ENCAP,
7071 : : sizeof(struct action_raw_encap_data)),
7072 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7073 : : .call = parse_vc_action_l2_encap,
7074 : : },
7075 : : [ACTION_L2_DECAP] = {
7076 : : .name = "l2_decap",
7077 : : .help = "l2 decap, uses configuration set by"
7078 : : " \"set l2_decap\"",
7079 : : .priv = PRIV_ACTION(RAW_DECAP,
7080 : : sizeof(struct action_raw_decap_data)),
7081 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7082 : : .call = parse_vc_action_l2_decap,
7083 : : },
7084 : : [ACTION_MPLSOGRE_ENCAP] = {
7085 : : .name = "mplsogre_encap",
7086 : : .help = "mplsogre encapsulation, uses configuration set by"
7087 : : " \"set mplsogre_encap\"",
7088 : : .priv = PRIV_ACTION(RAW_ENCAP,
7089 : : sizeof(struct action_raw_encap_data)),
7090 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7091 : : .call = parse_vc_action_mplsogre_encap,
7092 : : },
7093 : : [ACTION_MPLSOGRE_DECAP] = {
7094 : : .name = "mplsogre_decap",
7095 : : .help = "mplsogre decapsulation, uses configuration set by"
7096 : : " \"set mplsogre_decap\"",
7097 : : .priv = PRIV_ACTION(RAW_DECAP,
7098 : : sizeof(struct action_raw_decap_data)),
7099 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7100 : : .call = parse_vc_action_mplsogre_decap,
7101 : : },
7102 : : [ACTION_MPLSOUDP_ENCAP] = {
7103 : : .name = "mplsoudp_encap",
7104 : : .help = "mplsoudp encapsulation, uses configuration set by"
7105 : : " \"set mplsoudp_encap\"",
7106 : : .priv = PRIV_ACTION(RAW_ENCAP,
7107 : : sizeof(struct action_raw_encap_data)),
7108 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7109 : : .call = parse_vc_action_mplsoudp_encap,
7110 : : },
7111 : : [ACTION_MPLSOUDP_DECAP] = {
7112 : : .name = "mplsoudp_decap",
7113 : : .help = "mplsoudp decapsulation, uses configuration set by"
7114 : : " \"set mplsoudp_decap\"",
7115 : : .priv = PRIV_ACTION(RAW_DECAP,
7116 : : sizeof(struct action_raw_decap_data)),
7117 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7118 : : .call = parse_vc_action_mplsoudp_decap,
7119 : : },
7120 : : [ACTION_SET_IPV4_SRC] = {
7121 : : .name = "set_ipv4_src",
7122 : : .help = "Set a new IPv4 source address in the outermost"
7123 : : " IPv4 header",
7124 : : .priv = PRIV_ACTION(SET_IPV4_SRC,
7125 : : sizeof(struct rte_flow_action_set_ipv4)),
7126 : : .next = NEXT(action_set_ipv4_src),
7127 : : .call = parse_vc,
7128 : : },
7129 : : [ACTION_SET_IPV4_SRC_IPV4_SRC] = {
7130 : : .name = "ipv4_addr",
7131 : : .help = "new IPv4 source address to set",
7132 : : .next = NEXT(action_set_ipv4_src, NEXT_ENTRY(COMMON_IPV4_ADDR)),
7133 : : .args = ARGS(ARGS_ENTRY_HTON
7134 : : (struct rte_flow_action_set_ipv4, ipv4_addr)),
7135 : : .call = parse_vc_conf,
7136 : : },
7137 : : [ACTION_SET_IPV4_DST] = {
7138 : : .name = "set_ipv4_dst",
7139 : : .help = "Set a new IPv4 destination address in the outermost"
7140 : : " IPv4 header",
7141 : : .priv = PRIV_ACTION(SET_IPV4_DST,
7142 : : sizeof(struct rte_flow_action_set_ipv4)),
7143 : : .next = NEXT(action_set_ipv4_dst),
7144 : : .call = parse_vc,
7145 : : },
7146 : : [ACTION_SET_IPV4_DST_IPV4_DST] = {
7147 : : .name = "ipv4_addr",
7148 : : .help = "new IPv4 destination address to set",
7149 : : .next = NEXT(action_set_ipv4_dst, NEXT_ENTRY(COMMON_IPV4_ADDR)),
7150 : : .args = ARGS(ARGS_ENTRY_HTON
7151 : : (struct rte_flow_action_set_ipv4, ipv4_addr)),
7152 : : .call = parse_vc_conf,
7153 : : },
7154 : : [ACTION_SET_IPV6_SRC] = {
7155 : : .name = "set_ipv6_src",
7156 : : .help = "Set a new IPv6 source address in the outermost"
7157 : : " IPv6 header",
7158 : : .priv = PRIV_ACTION(SET_IPV6_SRC,
7159 : : sizeof(struct rte_flow_action_set_ipv6)),
7160 : : .next = NEXT(action_set_ipv6_src),
7161 : : .call = parse_vc,
7162 : : },
7163 : : [ACTION_SET_IPV6_SRC_IPV6_SRC] = {
7164 : : .name = "ipv6_addr",
7165 : : .help = "new IPv6 source address to set",
7166 : : .next = NEXT(action_set_ipv6_src, NEXT_ENTRY(COMMON_IPV6_ADDR)),
7167 : : .args = ARGS(ARGS_ENTRY_HTON
7168 : : (struct rte_flow_action_set_ipv6, ipv6_addr)),
7169 : : .call = parse_vc_conf,
7170 : : },
7171 : : [ACTION_SET_IPV6_DST] = {
7172 : : .name = "set_ipv6_dst",
7173 : : .help = "Set a new IPv6 destination address in the outermost"
7174 : : " IPv6 header",
7175 : : .priv = PRIV_ACTION(SET_IPV6_DST,
7176 : : sizeof(struct rte_flow_action_set_ipv6)),
7177 : : .next = NEXT(action_set_ipv6_dst),
7178 : : .call = parse_vc,
7179 : : },
7180 : : [ACTION_SET_IPV6_DST_IPV6_DST] = {
7181 : : .name = "ipv6_addr",
7182 : : .help = "new IPv6 destination address to set",
7183 : : .next = NEXT(action_set_ipv6_dst, NEXT_ENTRY(COMMON_IPV6_ADDR)),
7184 : : .args = ARGS(ARGS_ENTRY_HTON
7185 : : (struct rte_flow_action_set_ipv6, ipv6_addr)),
7186 : : .call = parse_vc_conf,
7187 : : },
7188 : : [ACTION_SET_TP_SRC] = {
7189 : : .name = "set_tp_src",
7190 : : .help = "set a new source port number in the outermost"
7191 : : " TCP/UDP header",
7192 : : .priv = PRIV_ACTION(SET_TP_SRC,
7193 : : sizeof(struct rte_flow_action_set_tp)),
7194 : : .next = NEXT(action_set_tp_src),
7195 : : .call = parse_vc,
7196 : : },
7197 : : [ACTION_SET_TP_SRC_TP_SRC] = {
7198 : : .name = "port",
7199 : : .help = "new source port number to set",
7200 : : .next = NEXT(action_set_tp_src, NEXT_ENTRY(COMMON_UNSIGNED)),
7201 : : .args = ARGS(ARGS_ENTRY_HTON
7202 : : (struct rte_flow_action_set_tp, port)),
7203 : : .call = parse_vc_conf,
7204 : : },
7205 : : [ACTION_SET_TP_DST] = {
7206 : : .name = "set_tp_dst",
7207 : : .help = "set a new destination port number in the outermost"
7208 : : " TCP/UDP header",
7209 : : .priv = PRIV_ACTION(SET_TP_DST,
7210 : : sizeof(struct rte_flow_action_set_tp)),
7211 : : .next = NEXT(action_set_tp_dst),
7212 : : .call = parse_vc,
7213 : : },
7214 : : [ACTION_SET_TP_DST_TP_DST] = {
7215 : : .name = "port",
7216 : : .help = "new destination port number to set",
7217 : : .next = NEXT(action_set_tp_dst, NEXT_ENTRY(COMMON_UNSIGNED)),
7218 : : .args = ARGS(ARGS_ENTRY_HTON
7219 : : (struct rte_flow_action_set_tp, port)),
7220 : : .call = parse_vc_conf,
7221 : : },
7222 : : [ACTION_MAC_SWAP] = {
7223 : : .name = "mac_swap",
7224 : : .help = "Swap the source and destination MAC addresses"
7225 : : " in the outermost Ethernet header",
7226 : : .priv = PRIV_ACTION(MAC_SWAP, 0),
7227 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7228 : : .call = parse_vc,
7229 : : },
7230 : : [ACTION_DEC_TTL] = {
7231 : : .name = "dec_ttl",
7232 : : .help = "decrease network TTL if available",
7233 : : .priv = PRIV_ACTION(DEC_TTL, 0),
7234 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7235 : : .call = parse_vc,
7236 : : },
7237 : : [ACTION_SET_TTL] = {
7238 : : .name = "set_ttl",
7239 : : .help = "set ttl value",
7240 : : .priv = PRIV_ACTION(SET_TTL,
7241 : : sizeof(struct rte_flow_action_set_ttl)),
7242 : : .next = NEXT(action_set_ttl),
7243 : : .call = parse_vc,
7244 : : },
7245 : : [ACTION_SET_TTL_TTL] = {
7246 : : .name = "ttl_value",
7247 : : .help = "new ttl value to set",
7248 : : .next = NEXT(action_set_ttl, NEXT_ENTRY(COMMON_UNSIGNED)),
7249 : : .args = ARGS(ARGS_ENTRY_HTON
7250 : : (struct rte_flow_action_set_ttl, ttl_value)),
7251 : : .call = parse_vc_conf,
7252 : : },
7253 : : [ACTION_SET_MAC_SRC] = {
7254 : : .name = "set_mac_src",
7255 : : .help = "set source mac address",
7256 : : .priv = PRIV_ACTION(SET_MAC_SRC,
7257 : : sizeof(struct rte_flow_action_set_mac)),
7258 : : .next = NEXT(action_set_mac_src),
7259 : : .call = parse_vc,
7260 : : },
7261 : : [ACTION_SET_MAC_SRC_MAC_SRC] = {
7262 : : .name = "mac_addr",
7263 : : .help = "new source mac address",
7264 : : .next = NEXT(action_set_mac_src, NEXT_ENTRY(COMMON_MAC_ADDR)),
7265 : : .args = ARGS(ARGS_ENTRY_HTON
7266 : : (struct rte_flow_action_set_mac, mac_addr)),
7267 : : .call = parse_vc_conf,
7268 : : },
7269 : : [ACTION_SET_MAC_DST] = {
7270 : : .name = "set_mac_dst",
7271 : : .help = "set destination mac address",
7272 : : .priv = PRIV_ACTION(SET_MAC_DST,
7273 : : sizeof(struct rte_flow_action_set_mac)),
7274 : : .next = NEXT(action_set_mac_dst),
7275 : : .call = parse_vc,
7276 : : },
7277 : : [ACTION_SET_MAC_DST_MAC_DST] = {
7278 : : .name = "mac_addr",
7279 : : .help = "new destination mac address to set",
7280 : : .next = NEXT(action_set_mac_dst, NEXT_ENTRY(COMMON_MAC_ADDR)),
7281 : : .args = ARGS(ARGS_ENTRY_HTON
7282 : : (struct rte_flow_action_set_mac, mac_addr)),
7283 : : .call = parse_vc_conf,
7284 : : },
7285 : : [ACTION_INC_TCP_SEQ] = {
7286 : : .name = "inc_tcp_seq",
7287 : : .help = "increase TCP sequence number",
7288 : : .priv = PRIV_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
7289 : : .next = NEXT(action_inc_tcp_seq),
7290 : : .call = parse_vc,
7291 : : },
7292 : : [ACTION_INC_TCP_SEQ_VALUE] = {
7293 : : .name = "value",
7294 : : .help = "the value to increase TCP sequence number by",
7295 : : .next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(COMMON_UNSIGNED)),
7296 : : .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
7297 : : .call = parse_vc_conf,
7298 : : },
7299 : : [ACTION_DEC_TCP_SEQ] = {
7300 : : .name = "dec_tcp_seq",
7301 : : .help = "decrease TCP sequence number",
7302 : : .priv = PRIV_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
7303 : : .next = NEXT(action_dec_tcp_seq),
7304 : : .call = parse_vc,
7305 : : },
7306 : : [ACTION_DEC_TCP_SEQ_VALUE] = {
7307 : : .name = "value",
7308 : : .help = "the value to decrease TCP sequence number by",
7309 : : .next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(COMMON_UNSIGNED)),
7310 : : .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
7311 : : .call = parse_vc_conf,
7312 : : },
7313 : : [ACTION_INC_TCP_ACK] = {
7314 : : .name = "inc_tcp_ack",
7315 : : .help = "increase TCP acknowledgment number",
7316 : : .priv = PRIV_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
7317 : : .next = NEXT(action_inc_tcp_ack),
7318 : : .call = parse_vc,
7319 : : },
7320 : : [ACTION_INC_TCP_ACK_VALUE] = {
7321 : : .name = "value",
7322 : : .help = "the value to increase TCP acknowledgment number by",
7323 : : .next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(COMMON_UNSIGNED)),
7324 : : .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
7325 : : .call = parse_vc_conf,
7326 : : },
7327 : : [ACTION_DEC_TCP_ACK] = {
7328 : : .name = "dec_tcp_ack",
7329 : : .help = "decrease TCP acknowledgment number",
7330 : : .priv = PRIV_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
7331 : : .next = NEXT(action_dec_tcp_ack),
7332 : : .call = parse_vc,
7333 : : },
7334 : : [ACTION_DEC_TCP_ACK_VALUE] = {
7335 : : .name = "value",
7336 : : .help = "the value to decrease TCP acknowledgment number by",
7337 : : .next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(COMMON_UNSIGNED)),
7338 : : .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
7339 : : .call = parse_vc_conf,
7340 : : },
7341 : : [ACTION_RAW_ENCAP] = {
7342 : : .name = "raw_encap",
7343 : : .help = "encapsulation data, defined by set raw_encap",
7344 : : .priv = PRIV_ACTION(RAW_ENCAP,
7345 : : sizeof(struct action_raw_encap_data)),
7346 : : .next = NEXT(action_raw_encap),
7347 : : .call = parse_vc_action_raw_encap,
7348 : : },
7349 : : [ACTION_RAW_ENCAP_SIZE] = {
7350 : : .name = "size",
7351 : : .help = "raw encap size",
7352 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT),
7353 : : NEXT_ENTRY(COMMON_UNSIGNED)),
7354 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_raw_encap, size)),
7355 : : .call = parse_vc_conf,
7356 : : },
7357 : : [ACTION_RAW_ENCAP_INDEX] = {
7358 : : .name = "index",
7359 : : .help = "the index of raw_encap_confs",
7360 : : .next = NEXT(NEXT_ENTRY(ACTION_RAW_ENCAP_INDEX_VALUE)),
7361 : : },
7362 : : [ACTION_RAW_ENCAP_INDEX_VALUE] = {
7363 : : .name = "{index}",
7364 : : .type = "UNSIGNED",
7365 : : .help = "unsigned integer value",
7366 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7367 : : .call = parse_vc_action_raw_encap_index,
7368 : : .comp = comp_set_raw_index,
7369 : : },
7370 : : [ACTION_RAW_DECAP] = {
7371 : : .name = "raw_decap",
7372 : : .help = "decapsulation data, defined by set raw_encap",
7373 : : .priv = PRIV_ACTION(RAW_DECAP,
7374 : : sizeof(struct action_raw_decap_data)),
7375 : : .next = NEXT(action_raw_decap),
7376 : : .call = parse_vc_action_raw_decap,
7377 : : },
7378 : : [ACTION_RAW_DECAP_INDEX] = {
7379 : : .name = "index",
7380 : : .help = "the index of raw_encap_confs",
7381 : : .next = NEXT(NEXT_ENTRY(ACTION_RAW_DECAP_INDEX_VALUE)),
7382 : : },
7383 : : [ACTION_RAW_DECAP_INDEX_VALUE] = {
7384 : : .name = "{index}",
7385 : : .type = "UNSIGNED",
7386 : : .help = "unsigned integer value",
7387 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7388 : : .call = parse_vc_action_raw_decap_index,
7389 : : .comp = comp_set_raw_index,
7390 : : },
7391 : : [ACTION_MODIFY_FIELD] = {
7392 : : .name = "modify_field",
7393 : : .help = "modify destination field with data from source field",
7394 : : .priv = PRIV_ACTION(MODIFY_FIELD, ACTION_MODIFY_SIZE),
7395 : : .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_OP)),
7396 : : .call = parse_vc,
7397 : : },
7398 : : [ACTION_MODIFY_FIELD_OP] = {
7399 : : .name = "op",
7400 : : .help = "operation type",
7401 : : .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_TYPE),
7402 : : NEXT_ENTRY(ACTION_MODIFY_FIELD_OP_VALUE)),
7403 : : .call = parse_vc_conf,
7404 : : },
7405 : : [ACTION_MODIFY_FIELD_OP_VALUE] = {
7406 : : .name = "{operation}",
7407 : : .help = "operation type value",
7408 : : .call = parse_vc_modify_field_op,
7409 : : .comp = comp_set_modify_field_op,
7410 : : },
7411 : : [ACTION_MODIFY_FIELD_DST_TYPE] = {
7412 : : .name = "dst_type",
7413 : : .help = "destination field type",
7414 : : .next = NEXT(action_modify_field_dst,
7415 : : NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_TYPE_VALUE)),
7416 : : .call = parse_vc_conf,
7417 : : },
7418 : : [ACTION_MODIFY_FIELD_DST_TYPE_VALUE] = {
7419 : : .name = "{dst_type}",
7420 : : .help = "destination field type value",
7421 : : .call = parse_vc_modify_field_id,
7422 : : .comp = comp_set_modify_field_id,
7423 : : },
7424 : : [ACTION_MODIFY_FIELD_DST_LEVEL] = {
7425 : : .name = "dst_level",
7426 : : .help = "destination field level",
7427 : : .next = NEXT(action_modify_field_dst,
7428 : : NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_LEVEL_VALUE)),
7429 : : .call = parse_vc_conf,
7430 : : },
7431 : : [ACTION_MODIFY_FIELD_DST_LEVEL_VALUE] = {
7432 : : .name = "{dst_level}",
7433 : : .help = "destination field level value",
7434 : : .call = parse_vc_modify_field_level,
7435 : : .comp = comp_none,
7436 : : },
7437 : : [ACTION_MODIFY_FIELD_DST_TAG_INDEX] = {
7438 : : .name = "dst_tag_index",
7439 : : .help = "destination field tag array",
7440 : : .next = NEXT(action_modify_field_dst,
7441 : : NEXT_ENTRY(COMMON_UNSIGNED)),
7442 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
7443 : : dst.tag_index)),
7444 : : .call = parse_vc_conf,
7445 : : },
7446 : : [ACTION_MODIFY_FIELD_DST_TYPE_ID] = {
7447 : : .name = "dst_type_id",
7448 : : .help = "destination field type ID",
7449 : : .next = NEXT(action_modify_field_dst,
7450 : : NEXT_ENTRY(COMMON_UNSIGNED)),
7451 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
7452 : : dst.type)),
7453 : : .call = parse_vc_conf,
7454 : : },
7455 : : [ACTION_MODIFY_FIELD_DST_CLASS_ID] = {
7456 : : .name = "dst_class",
7457 : : .help = "destination field class ID",
7458 : : .next = NEXT(action_modify_field_dst,
7459 : : NEXT_ENTRY(COMMON_UNSIGNED)),
7460 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_action_modify_field,
7461 : : dst.class_id)),
7462 : : .call = parse_vc_conf,
7463 : : },
7464 : : [ACTION_MODIFY_FIELD_DST_OFFSET] = {
7465 : : .name = "dst_offset",
7466 : : .help = "destination field bit offset",
7467 : : .next = NEXT(action_modify_field_dst,
7468 : : NEXT_ENTRY(COMMON_UNSIGNED)),
7469 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
7470 : : dst.offset)),
7471 : : .call = parse_vc_conf,
7472 : : },
7473 : : [ACTION_MODIFY_FIELD_SRC_TYPE] = {
7474 : : .name = "src_type",
7475 : : .help = "source field type",
7476 : : .next = NEXT(action_modify_field_src,
7477 : : NEXT_ENTRY(ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)),
7478 : : .call = parse_vc_conf,
7479 : : },
7480 : : [ACTION_MODIFY_FIELD_SRC_TYPE_VALUE] = {
7481 : : .name = "{src_type}",
7482 : : .help = "source field type value",
7483 : : .call = parse_vc_modify_field_id,
7484 : : .comp = comp_set_modify_field_id,
7485 : : },
7486 : : [ACTION_MODIFY_FIELD_SRC_LEVEL] = {
7487 : : .name = "src_level",
7488 : : .help = "source field level",
7489 : : .next = NEXT(action_modify_field_src,
7490 : : NEXT_ENTRY(ACTION_MODIFY_FIELD_SRC_LEVEL_VALUE)),
7491 : : .call = parse_vc_conf,
7492 : : },
7493 : : [ACTION_MODIFY_FIELD_SRC_LEVEL_VALUE] = {
7494 : : .name = "{src_level}",
7495 : : .help = "source field level value",
7496 : : .call = parse_vc_modify_field_level,
7497 : : .comp = comp_none,
7498 : : },
7499 : : [ACTION_MODIFY_FIELD_SRC_TAG_INDEX] = {
7500 : : .name = "src_tag_index",
7501 : : .help = "source field tag array",
7502 : : .next = NEXT(action_modify_field_src,
7503 : : NEXT_ENTRY(COMMON_UNSIGNED)),
7504 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
7505 : : src.tag_index)),
7506 : : .call = parse_vc_conf,
7507 : : },
7508 : : [ACTION_MODIFY_FIELD_SRC_TYPE_ID] = {
7509 : : .name = "src_type_id",
7510 : : .help = "source field type ID",
7511 : : .next = NEXT(action_modify_field_src,
7512 : : NEXT_ENTRY(COMMON_UNSIGNED)),
7513 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
7514 : : src.type)),
7515 : : .call = parse_vc_conf,
7516 : : },
7517 : : [ACTION_MODIFY_FIELD_SRC_CLASS_ID] = {
7518 : : .name = "src_class",
7519 : : .help = "source field class ID",
7520 : : .next = NEXT(action_modify_field_src,
7521 : : NEXT_ENTRY(COMMON_UNSIGNED)),
7522 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_action_modify_field,
7523 : : src.class_id)),
7524 : : .call = parse_vc_conf,
7525 : : },
7526 : : [ACTION_MODIFY_FIELD_SRC_OFFSET] = {
7527 : : .name = "src_offset",
7528 : : .help = "source field bit offset",
7529 : : .next = NEXT(action_modify_field_src,
7530 : : NEXT_ENTRY(COMMON_UNSIGNED)),
7531 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
7532 : : src.offset)),
7533 : : .call = parse_vc_conf,
7534 : : },
7535 : : [ACTION_MODIFY_FIELD_SRC_VALUE] = {
7536 : : .name = "src_value",
7537 : : .help = "source immediate value",
7538 : : .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_WIDTH),
7539 : : NEXT_ENTRY(COMMON_HEX)),
7540 : : .args = ARGS(ARGS_ENTRY_ARB(0, 0),
7541 : : ARGS_ENTRY_ARB(0, 0),
7542 : : ARGS_ENTRY(struct rte_flow_action_modify_field,
7543 : : src.value)),
7544 : : .call = parse_vc_conf,
7545 : : },
7546 : : [ACTION_MODIFY_FIELD_SRC_POINTER] = {
7547 : : .name = "src_ptr",
7548 : : .help = "pointer to source immediate value",
7549 : : .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_WIDTH),
7550 : : NEXT_ENTRY(COMMON_HEX)),
7551 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
7552 : : src.pvalue),
7553 : : ARGS_ENTRY_ARB(0, 0),
7554 : : ARGS_ENTRY_ARB
7555 : : (sizeof(struct rte_flow_action_modify_field),
7556 : : FLOW_FIELD_PATTERN_SIZE)),
7557 : : .call = parse_vc_conf,
7558 : : },
7559 : : [ACTION_MODIFY_FIELD_WIDTH] = {
7560 : : .name = "width",
7561 : : .help = "number of bits to copy",
7562 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT),
7563 : : NEXT_ENTRY(COMMON_UNSIGNED)),
7564 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
7565 : : width)),
7566 : : .call = parse_vc_conf,
7567 : : },
7568 : : [ACTION_SEND_TO_KERNEL] = {
7569 : : .name = "send_to_kernel",
7570 : : .help = "send packets to kernel",
7571 : : .priv = PRIV_ACTION(SEND_TO_KERNEL, 0),
7572 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7573 : : .call = parse_vc,
7574 : : },
7575 : : [ACTION_IPV6_EXT_REMOVE] = {
7576 : : .name = "ipv6_ext_remove",
7577 : : .help = "IPv6 extension type, defined by set ipv6_ext_remove",
7578 : : .priv = PRIV_ACTION(IPV6_EXT_REMOVE,
7579 : : sizeof(struct action_ipv6_ext_remove_data)),
7580 : : .next = NEXT(action_ipv6_ext_remove),
7581 : : .call = parse_vc_action_ipv6_ext_remove,
7582 : : },
7583 : : [ACTION_IPV6_EXT_REMOVE_INDEX] = {
7584 : : .name = "index",
7585 : : .help = "the index of ipv6_ext_remove",
7586 : : .next = NEXT(NEXT_ENTRY(ACTION_IPV6_EXT_REMOVE_INDEX_VALUE)),
7587 : : },
7588 : : [ACTION_IPV6_EXT_REMOVE_INDEX_VALUE] = {
7589 : : .name = "{index}",
7590 : : .type = "UNSIGNED",
7591 : : .help = "unsigned integer value",
7592 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7593 : : .call = parse_vc_action_ipv6_ext_remove_index,
7594 : : .comp = comp_set_ipv6_ext_index,
7595 : : },
7596 : : [ACTION_IPV6_EXT_PUSH] = {
7597 : : .name = "ipv6_ext_push",
7598 : : .help = "IPv6 extension data, defined by set ipv6_ext_push",
7599 : : .priv = PRIV_ACTION(IPV6_EXT_PUSH,
7600 : : sizeof(struct action_ipv6_ext_push_data)),
7601 : : .next = NEXT(action_ipv6_ext_push),
7602 : : .call = parse_vc_action_ipv6_ext_push,
7603 : : },
7604 : : [ACTION_IPV6_EXT_PUSH_INDEX] = {
7605 : : .name = "index",
7606 : : .help = "the index of ipv6_ext_push",
7607 : : .next = NEXT(NEXT_ENTRY(ACTION_IPV6_EXT_PUSH_INDEX_VALUE)),
7608 : : },
7609 : : [ACTION_IPV6_EXT_PUSH_INDEX_VALUE] = {
7610 : : .name = "{index}",
7611 : : .type = "UNSIGNED",
7612 : : .help = "unsigned integer value",
7613 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7614 : : .call = parse_vc_action_ipv6_ext_push_index,
7615 : : .comp = comp_set_ipv6_ext_index,
7616 : : },
7617 : : [ACTION_NAT64] = {
7618 : : .name = "nat64",
7619 : : .help = "NAT64 IP headers translation",
7620 : : .priv = PRIV_ACTION(NAT64, sizeof(struct rte_flow_action_nat64)),
7621 : : .next = NEXT(action_nat64),
7622 : : .call = parse_vc,
7623 : : },
7624 : : [ACTION_NAT64_MODE] = {
7625 : : .name = "type",
7626 : : .help = "NAT64 translation type",
7627 : : .next = NEXT(action_nat64, NEXT_ENTRY(COMMON_UNSIGNED)),
7628 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_nat64, type)),
7629 : : .call = parse_vc_conf,
7630 : : },
7631 : : [ACTION_JUMP_TO_TABLE_INDEX] = {
7632 : : .name = "jump_to_table_index",
7633 : : .help = "Jump to table index",
7634 : : .priv = PRIV_ACTION(JUMP_TO_TABLE_INDEX,
7635 : : sizeof(struct rte_flow_action_jump_to_table_index)),
7636 : : .next = NEXT(action_jump_to_table_index),
7637 : : .call = parse_vc,
7638 : : },
7639 : : [ACTION_JUMP_TO_TABLE_INDEX_TABLE] = {
7640 : : .name = "table",
7641 : : .help = "table id to redirect traffic to",
7642 : : .next = NEXT(action_jump_to_table_index,
7643 : : NEXT_ENTRY(ACTION_JUMP_TO_TABLE_INDEX_TABLE_VALUE)),
7644 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump_to_table_index, table)),
7645 : : .call = parse_vc_conf,
7646 : : },
7647 : : [ACTION_JUMP_TO_TABLE_INDEX_TABLE_VALUE] = {
7648 : : .name = "{table_id}",
7649 : : .type = "TABLE_ID",
7650 : : .help = "table id for jump action",
7651 : : .call = parse_jump_table_id,
7652 : : .comp = comp_table_id,
7653 : : },
7654 : : [ACTION_JUMP_TO_TABLE_INDEX_INDEX] = {
7655 : : .name = "index",
7656 : : .help = "rule index to redirect traffic to",
7657 : : .next = NEXT(action_jump_to_table_index, NEXT_ENTRY(COMMON_UNSIGNED)),
7658 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump_to_table_index, index)),
7659 : : .call = parse_vc_conf,
7660 : : },
7661 : :
7662 : : /* Top level command. */
7663 : : [SET] = {
7664 : : .name = "set",
7665 : : .help = "set raw encap/decap/sample data",
7666 : : .type = "set raw_encap|raw_decap <index> <pattern>"
7667 : : " or set sample_actions <index> <action>",
7668 : : .next = NEXT(NEXT_ENTRY
7669 : : (SET_RAW_ENCAP,
7670 : : SET_RAW_DECAP,
7671 : : SET_SAMPLE_ACTIONS,
7672 : : SET_IPV6_EXT_REMOVE,
7673 : : SET_IPV6_EXT_PUSH)),
7674 : : .call = parse_set_init,
7675 : : },
7676 : : /* Sub-level commands. */
7677 : : [SET_RAW_ENCAP] = {
7678 : : .name = "raw_encap",
7679 : : .help = "set raw encap data",
7680 : : .next = NEXT(next_set_raw),
7681 : : .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
7682 : : (offsetof(struct buffer, port),
7683 : : sizeof(((struct buffer *)0)->port),
7684 : : 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
7685 : : .call = parse_set_raw_encap_decap,
7686 : : },
7687 : : [SET_RAW_DECAP] = {
7688 : : .name = "raw_decap",
7689 : : .help = "set raw decap data",
7690 : : .next = NEXT(next_set_raw),
7691 : : .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
7692 : : (offsetof(struct buffer, port),
7693 : : sizeof(((struct buffer *)0)->port),
7694 : : 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
7695 : : .call = parse_set_raw_encap_decap,
7696 : : },
7697 : : [SET_RAW_INDEX] = {
7698 : : .name = "{index}",
7699 : : .type = "COMMON_UNSIGNED",
7700 : : .help = "index of raw_encap/raw_decap data",
7701 : : .next = NEXT(next_item),
7702 : : .call = parse_port,
7703 : : },
7704 : : [SET_SAMPLE_INDEX] = {
7705 : : .name = "{index}",
7706 : : .type = "UNSIGNED",
7707 : : .help = "index of sample actions",
7708 : : .next = NEXT(next_action_sample),
7709 : : .call = parse_port,
7710 : : },
7711 : : [SET_SAMPLE_ACTIONS] = {
7712 : : .name = "sample_actions",
7713 : : .help = "set sample actions list",
7714 : : .next = NEXT(NEXT_ENTRY(SET_SAMPLE_INDEX)),
7715 : : .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
7716 : : (offsetof(struct buffer, port),
7717 : : sizeof(((struct buffer *)0)->port),
7718 : : 0, RAW_SAMPLE_CONFS_MAX_NUM - 1)),
7719 : : .call = parse_set_sample_action,
7720 : : },
7721 : : [SET_IPV6_EXT_PUSH] = {
7722 : : .name = "ipv6_ext_push",
7723 : : .help = "set IPv6 extension header",
7724 : : .next = NEXT(NEXT_ENTRY(SET_IPV6_EXT_INDEX)),
7725 : : .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
7726 : : (offsetof(struct buffer, port),
7727 : : sizeof(((struct buffer *)0)->port),
7728 : : 0, IPV6_EXT_PUSH_CONFS_MAX_NUM - 1)),
7729 : : .call = parse_set_ipv6_ext_action,
7730 : : },
7731 : : [SET_IPV6_EXT_REMOVE] = {
7732 : : .name = "ipv6_ext_remove",
7733 : : .help = "set IPv6 extension header",
7734 : : .next = NEXT(NEXT_ENTRY(SET_IPV6_EXT_INDEX)),
7735 : : .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
7736 : : (offsetof(struct buffer, port),
7737 : : sizeof(((struct buffer *)0)->port),
7738 : : 0, IPV6_EXT_PUSH_CONFS_MAX_NUM - 1)),
7739 : : .call = parse_set_ipv6_ext_action,
7740 : : },
7741 : : [SET_IPV6_EXT_INDEX] = {
7742 : : .name = "{index}",
7743 : : .type = "UNSIGNED",
7744 : : .help = "index of ipv6 extension push/remove actions",
7745 : : .next = NEXT(item_ipv6_push_ext),
7746 : : .call = parse_port,
7747 : : },
7748 : : [ITEM_IPV6_PUSH_REMOVE_EXT] = {
7749 : : .name = "ipv6_ext",
7750 : : .help = "set IPv6 extension header",
7751 : : .priv = PRIV_ITEM(IPV6_EXT,
7752 : : sizeof(struct rte_flow_item_ipv6_ext)),
7753 : : .next = NEXT(item_ipv6_push_ext_type),
7754 : : .call = parse_vc,
7755 : : },
7756 : : [ITEM_IPV6_PUSH_REMOVE_EXT_TYPE] = {
7757 : : .name = "type",
7758 : : .help = "set IPv6 extension type",
7759 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_ext,
7760 : : next_hdr)),
7761 : : .next = NEXT(item_ipv6_push_ext_header, NEXT_ENTRY(COMMON_UNSIGNED),
7762 : : item_param),
7763 : : },
7764 : : [ACTION_SET_TAG] = {
7765 : : .name = "set_tag",
7766 : : .help = "set tag",
7767 : : .priv = PRIV_ACTION(SET_TAG,
7768 : : sizeof(struct rte_flow_action_set_tag)),
7769 : : .next = NEXT(action_set_tag),
7770 : : .call = parse_vc,
7771 : : },
7772 : : [ACTION_SET_TAG_INDEX] = {
7773 : : .name = "index",
7774 : : .help = "index of tag array",
7775 : : .next = NEXT(action_set_tag, NEXT_ENTRY(COMMON_UNSIGNED)),
7776 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_set_tag, index)),
7777 : : .call = parse_vc_conf,
7778 : : },
7779 : : [ACTION_SET_TAG_DATA] = {
7780 : : .name = "data",
7781 : : .help = "tag value",
7782 : : .next = NEXT(action_set_tag, NEXT_ENTRY(COMMON_UNSIGNED)),
7783 : : .args = ARGS(ARGS_ENTRY
7784 : : (struct rte_flow_action_set_tag, data)),
7785 : : .call = parse_vc_conf,
7786 : : },
7787 : : [ACTION_SET_TAG_MASK] = {
7788 : : .name = "mask",
7789 : : .help = "mask for tag value",
7790 : : .next = NEXT(action_set_tag, NEXT_ENTRY(COMMON_UNSIGNED)),
7791 : : .args = ARGS(ARGS_ENTRY
7792 : : (struct rte_flow_action_set_tag, mask)),
7793 : : .call = parse_vc_conf,
7794 : : },
7795 : : [ACTION_SET_META] = {
7796 : : .name = "set_meta",
7797 : : .help = "set metadata",
7798 : : .priv = PRIV_ACTION(SET_META,
7799 : : sizeof(struct rte_flow_action_set_meta)),
7800 : : .next = NEXT(action_set_meta),
7801 : : .call = parse_vc_action_set_meta,
7802 : : },
7803 : : [ACTION_SET_META_DATA] = {
7804 : : .name = "data",
7805 : : .help = "metadata value",
7806 : : .next = NEXT(action_set_meta, NEXT_ENTRY(COMMON_UNSIGNED)),
7807 : : .args = ARGS(ARGS_ENTRY
7808 : : (struct rte_flow_action_set_meta, data)),
7809 : : .call = parse_vc_conf,
7810 : : },
7811 : : [ACTION_SET_META_MASK] = {
7812 : : .name = "mask",
7813 : : .help = "mask for metadata value",
7814 : : .next = NEXT(action_set_meta, NEXT_ENTRY(COMMON_UNSIGNED)),
7815 : : .args = ARGS(ARGS_ENTRY
7816 : : (struct rte_flow_action_set_meta, mask)),
7817 : : .call = parse_vc_conf,
7818 : : },
7819 : : [ACTION_SET_IPV4_DSCP] = {
7820 : : .name = "set_ipv4_dscp",
7821 : : .help = "set DSCP value",
7822 : : .priv = PRIV_ACTION(SET_IPV4_DSCP,
7823 : : sizeof(struct rte_flow_action_set_dscp)),
7824 : : .next = NEXT(action_set_ipv4_dscp),
7825 : : .call = parse_vc,
7826 : : },
7827 : : [ACTION_SET_IPV4_DSCP_VALUE] = {
7828 : : .name = "dscp_value",
7829 : : .help = "new IPv4 DSCP value to set",
7830 : : .next = NEXT(action_set_ipv4_dscp, NEXT_ENTRY(COMMON_UNSIGNED)),
7831 : : .args = ARGS(ARGS_ENTRY
7832 : : (struct rte_flow_action_set_dscp, dscp)),
7833 : : .call = parse_vc_conf,
7834 : : },
7835 : : [ACTION_SET_IPV6_DSCP] = {
7836 : : .name = "set_ipv6_dscp",
7837 : : .help = "set DSCP value",
7838 : : .priv = PRIV_ACTION(SET_IPV6_DSCP,
7839 : : sizeof(struct rte_flow_action_set_dscp)),
7840 : : .next = NEXT(action_set_ipv6_dscp),
7841 : : .call = parse_vc,
7842 : : },
7843 : : [ACTION_SET_IPV6_DSCP_VALUE] = {
7844 : : .name = "dscp_value",
7845 : : .help = "new IPv6 DSCP value to set",
7846 : : .next = NEXT(action_set_ipv6_dscp, NEXT_ENTRY(COMMON_UNSIGNED)),
7847 : : .args = ARGS(ARGS_ENTRY
7848 : : (struct rte_flow_action_set_dscp, dscp)),
7849 : : .call = parse_vc_conf,
7850 : : },
7851 : : [ACTION_AGE] = {
7852 : : .name = "age",
7853 : : .help = "set a specific metadata header",
7854 : : .next = NEXT(action_age),
7855 : : .priv = PRIV_ACTION(AGE,
7856 : : sizeof(struct rte_flow_action_age)),
7857 : : .call = parse_vc,
7858 : : },
7859 : : [ACTION_AGE_TIMEOUT] = {
7860 : : .name = "timeout",
7861 : : .help = "flow age timeout value",
7862 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_age,
7863 : : timeout, 24)),
7864 : : .next = NEXT(action_age, NEXT_ENTRY(COMMON_UNSIGNED)),
7865 : : .call = parse_vc_conf,
7866 : : },
7867 : : [ACTION_AGE_UPDATE] = {
7868 : : .name = "age_update",
7869 : : .help = "update aging parameter",
7870 : : .next = NEXT(action_age_update),
7871 : : .priv = PRIV_ACTION(AGE,
7872 : : sizeof(struct rte_flow_update_age)),
7873 : : .call = parse_vc,
7874 : : },
7875 : : [ACTION_AGE_UPDATE_TIMEOUT] = {
7876 : : .name = "timeout",
7877 : : .help = "age timeout update value",
7878 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_update_age,
7879 : : timeout, 24)),
7880 : : .next = NEXT(action_age_update, NEXT_ENTRY(COMMON_UNSIGNED)),
7881 : : .call = parse_vc_conf_timeout,
7882 : : },
7883 : : [ACTION_AGE_UPDATE_TOUCH] = {
7884 : : .name = "touch",
7885 : : .help = "this flow is touched",
7886 : : .next = NEXT(action_age_update, NEXT_ENTRY(COMMON_BOOLEAN)),
7887 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_update_age,
7888 : : touch, 1)),
7889 : : .call = parse_vc_conf,
7890 : : },
7891 : : [ACTION_SAMPLE] = {
7892 : : .name = "sample",
7893 : : .help = "set a sample action",
7894 : : .next = NEXT(action_sample),
7895 : : .priv = PRIV_ACTION(SAMPLE,
7896 : : sizeof(struct action_sample_data)),
7897 : : .call = parse_vc_action_sample,
7898 : : },
7899 : : [ACTION_SAMPLE_RATIO] = {
7900 : : .name = "ratio",
7901 : : .help = "flow sample ratio value",
7902 : : .next = NEXT(action_sample, NEXT_ENTRY(COMMON_UNSIGNED)),
7903 : : .args = ARGS(ARGS_ENTRY_ARB
7904 : : (offsetof(struct action_sample_data, conf) +
7905 : : offsetof(struct rte_flow_action_sample, ratio),
7906 : : sizeof(((struct rte_flow_action_sample *)0)->
7907 : : ratio))),
7908 : : },
7909 : : [ACTION_SAMPLE_INDEX] = {
7910 : : .name = "index",
7911 : : .help = "the index of sample actions list",
7912 : : .next = NEXT(NEXT_ENTRY(ACTION_SAMPLE_INDEX_VALUE)),
7913 : : },
7914 : : [ACTION_SAMPLE_INDEX_VALUE] = {
7915 : : .name = "{index}",
7916 : : .type = "COMMON_UNSIGNED",
7917 : : .help = "unsigned integer value",
7918 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7919 : : .call = parse_vc_action_sample_index,
7920 : : .comp = comp_set_sample_index,
7921 : : },
7922 : : [ACTION_CONNTRACK] = {
7923 : : .name = "conntrack",
7924 : : .help = "create a conntrack object",
7925 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7926 : : .priv = PRIV_ACTION(CONNTRACK,
7927 : : sizeof(struct rte_flow_action_conntrack)),
7928 : : .call = parse_vc,
7929 : : },
7930 : : [ACTION_CONNTRACK_UPDATE] = {
7931 : : .name = "conntrack_update",
7932 : : .help = "update a conntrack object",
7933 : : .next = NEXT(action_update_conntrack),
7934 : : .priv = PRIV_ACTION(CONNTRACK,
7935 : : sizeof(struct rte_flow_modify_conntrack)),
7936 : : .call = parse_vc,
7937 : : },
7938 : : [ACTION_CONNTRACK_UPDATE_DIR] = {
7939 : : .name = "dir",
7940 : : .help = "update a conntrack object direction",
7941 : : .next = NEXT(action_update_conntrack),
7942 : : .call = parse_vc_action_conntrack_update,
7943 : : },
7944 : : [ACTION_CONNTRACK_UPDATE_CTX] = {
7945 : : .name = "ctx",
7946 : : .help = "update a conntrack object context",
7947 : : .next = NEXT(action_update_conntrack),
7948 : : .call = parse_vc_action_conntrack_update,
7949 : : },
7950 : : [ACTION_PORT_REPRESENTOR] = {
7951 : : .name = "port_representor",
7952 : : .help = "at embedded switch level, send matching traffic to the given ethdev",
7953 : : .priv = PRIV_ACTION(PORT_REPRESENTOR,
7954 : : sizeof(struct rte_flow_action_ethdev)),
7955 : : .next = NEXT(action_port_representor),
7956 : : .call = parse_vc,
7957 : : },
7958 : : [ACTION_PORT_REPRESENTOR_PORT_ID] = {
7959 : : .name = "port_id",
7960 : : .help = "ethdev port ID",
7961 : : .next = NEXT(action_port_representor,
7962 : : NEXT_ENTRY(COMMON_UNSIGNED)),
7963 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_ethdev,
7964 : : port_id)),
7965 : : .call = parse_vc_conf,
7966 : : },
7967 : : [ACTION_REPRESENTED_PORT] = {
7968 : : .name = "represented_port",
7969 : : .help = "at embedded switch level, send matching traffic to the entity represented by the given ethdev",
7970 : : .priv = PRIV_ACTION(REPRESENTED_PORT,
7971 : : sizeof(struct rte_flow_action_ethdev)),
7972 : : .next = NEXT(action_represented_port),
7973 : : .call = parse_vc,
7974 : : },
7975 : : [ACTION_REPRESENTED_PORT_ETHDEV_PORT_ID] = {
7976 : : .name = "ethdev_port_id",
7977 : : .help = "ethdev port ID",
7978 : : .next = NEXT(action_represented_port,
7979 : : NEXT_ENTRY(COMMON_UNSIGNED)),
7980 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_ethdev,
7981 : : port_id)),
7982 : : .call = parse_vc_conf,
7983 : : },
7984 : : /* Indirect action destroy arguments. */
7985 : : [INDIRECT_ACTION_DESTROY_ID] = {
7986 : : .name = "action_id",
7987 : : .help = "specify a indirect action id to destroy",
7988 : : .next = NEXT(next_ia_destroy_attr,
7989 : : NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
7990 : : .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
7991 : : args.ia_destroy.action_id)),
7992 : : .call = parse_ia_destroy,
7993 : : },
7994 : : /* Indirect action create arguments. */
7995 : : [INDIRECT_ACTION_CREATE_ID] = {
7996 : : .name = "action_id",
7997 : : .help = "specify a indirect action id to create",
7998 : : .next = NEXT(next_ia_create_attr,
7999 : : NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
8000 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
8001 : : },
8002 : : [ACTION_INDIRECT] = {
8003 : : .name = "indirect",
8004 : : .help = "apply indirect action by id",
8005 : : .priv = PRIV_ACTION(INDIRECT, 0),
8006 : : .next = NEXT(next_ia),
8007 : : .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
8008 : : .call = parse_vc,
8009 : : },
8010 : : [ACTION_INDIRECT_LIST] = {
8011 : : .name = "indirect_list",
8012 : : .help = "apply indirect list action by id",
8013 : : .priv = PRIV_ACTION(INDIRECT_LIST,
8014 : : sizeof(struct
8015 : : rte_flow_action_indirect_list)),
8016 : : .next = NEXT(next_ial),
8017 : : .call = parse_vc,
8018 : : },
8019 : : [ACTION_INDIRECT_LIST_HANDLE] = {
8020 : : .name = "handle",
8021 : : .help = "indirect list handle",
8022 : : .next = NEXT(next_ial, NEXT_ENTRY(INDIRECT_LIST_ACTION_ID2PTR_HANDLE)),
8023 : : .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
8024 : : },
8025 : : [ACTION_INDIRECT_LIST_CONF] = {
8026 : : .name = "conf",
8027 : : .help = "indirect list configuration",
8028 : : .next = NEXT(next_ial, NEXT_ENTRY(INDIRECT_LIST_ACTION_ID2PTR_CONF)),
8029 : : .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
8030 : : },
8031 : : [INDIRECT_LIST_ACTION_ID2PTR_HANDLE] = {
8032 : : .type = "UNSIGNED",
8033 : : .help = "unsigned integer value",
8034 : : .call = parse_indlst_id2ptr,
8035 : : .comp = comp_none,
8036 : : },
8037 : : [INDIRECT_LIST_ACTION_ID2PTR_CONF] = {
8038 : : .type = "UNSIGNED",
8039 : : .help = "unsigned integer value",
8040 : : .call = parse_indlst_id2ptr,
8041 : : .comp = comp_none,
8042 : : },
8043 : : [ACTION_SHARED_INDIRECT] = {
8044 : : .name = "shared_indirect",
8045 : : .help = "apply indirect action by id and port",
8046 : : .priv = PRIV_ACTION(INDIRECT, 0),
8047 : : .next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_PORT)),
8048 : : .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t)),
8049 : : ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
8050 : : .call = parse_vc,
8051 : : },
8052 : : [INDIRECT_ACTION_PORT] = {
8053 : : .name = "{indirect_action_port}",
8054 : : .type = "INDIRECT_ACTION_PORT",
8055 : : .help = "indirect action port",
8056 : : .next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_ID2PTR)),
8057 : : .call = parse_ia_port,
8058 : : .comp = comp_none,
8059 : : },
8060 : : [INDIRECT_ACTION_ID2PTR] = {
8061 : : .name = "{action_id}",
8062 : : .type = "INDIRECT_ACTION_ID",
8063 : : .help = "indirect action id",
8064 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
8065 : : .call = parse_ia_id2ptr,
8066 : : .comp = comp_none,
8067 : : },
8068 : : [INDIRECT_ACTION_INGRESS] = {
8069 : : .name = "ingress",
8070 : : .help = "affect rule to ingress",
8071 : : .next = NEXT(next_ia_create_attr),
8072 : : .call = parse_ia,
8073 : : },
8074 : : [INDIRECT_ACTION_EGRESS] = {
8075 : : .name = "egress",
8076 : : .help = "affect rule to egress",
8077 : : .next = NEXT(next_ia_create_attr),
8078 : : .call = parse_ia,
8079 : : },
8080 : : [INDIRECT_ACTION_TRANSFER] = {
8081 : : .name = "transfer",
8082 : : .help = "affect rule to transfer",
8083 : : .next = NEXT(next_ia_create_attr),
8084 : : .call = parse_ia,
8085 : : },
8086 : : [INDIRECT_ACTION_SPEC] = {
8087 : : .name = "action",
8088 : : .help = "specify action to create indirect handle",
8089 : : .next = NEXT(next_action),
8090 : : },
8091 : : [INDIRECT_ACTION_LIST] = {
8092 : : .name = "list",
8093 : : .help = "specify actions for indirect handle list",
8094 : : .next = NEXT(NEXT_ENTRY(ACTIONS, END)),
8095 : : .call = parse_ia,
8096 : : },
8097 : : [INDIRECT_ACTION_FLOW_CONF] = {
8098 : : .name = "flow_conf",
8099 : : .help = "specify actions configuration for indirect handle list",
8100 : : .next = NEXT(NEXT_ENTRY(ACTIONS, END)),
8101 : : .call = parse_ia,
8102 : : },
8103 : : [ACTION_POL_G] = {
8104 : : .name = "g_actions",
8105 : : .help = "submit a list of associated actions for green",
8106 : : .next = NEXT(next_action),
8107 : : .call = parse_mp,
8108 : : },
8109 : : [ACTION_POL_Y] = {
8110 : : .name = "y_actions",
8111 : : .help = "submit a list of associated actions for yellow",
8112 : : .next = NEXT(next_action),
8113 : : },
8114 : : [ACTION_POL_R] = {
8115 : : .name = "r_actions",
8116 : : .help = "submit a list of associated actions for red",
8117 : : .next = NEXT(next_action),
8118 : : },
8119 : : [ACTION_QUOTA_CREATE] = {
8120 : : .name = "quota_create",
8121 : : .help = "create quota action",
8122 : : .priv = PRIV_ACTION(QUOTA,
8123 : : sizeof(struct rte_flow_action_quota)),
8124 : : .next = NEXT(action_quota_create),
8125 : : .call = parse_vc
8126 : : },
8127 : : [ACTION_QUOTA_CREATE_LIMIT] = {
8128 : : .name = "limit",
8129 : : .help = "quota limit",
8130 : : .next = NEXT(action_quota_create, NEXT_ENTRY(COMMON_UNSIGNED)),
8131 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_quota, quota)),
8132 : : .call = parse_vc_conf
8133 : : },
8134 : : [ACTION_QUOTA_CREATE_MODE] = {
8135 : : .name = "mode",
8136 : : .help = "quota mode",
8137 : : .next = NEXT(action_quota_create,
8138 : : NEXT_ENTRY(ACTION_QUOTA_CREATE_MODE_NAME)),
8139 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_quota, mode)),
8140 : : .call = parse_vc_conf
8141 : : },
8142 : : [ACTION_QUOTA_CREATE_MODE_NAME] = {
8143 : : .name = "mode_name",
8144 : : .help = "quota mode name",
8145 : : .call = parse_quota_mode_name,
8146 : : .comp = comp_quota_mode_name
8147 : : },
8148 : : [ACTION_QUOTA_QU] = {
8149 : : .name = "quota_update",
8150 : : .help = "update quota action",
8151 : : .priv = PRIV_ACTION(QUOTA,
8152 : : sizeof(struct rte_flow_update_quota)),
8153 : : .next = NEXT(action_quota_update),
8154 : : .call = parse_vc
8155 : : },
8156 : : [ACTION_QUOTA_QU_LIMIT] = {
8157 : : .name = "limit",
8158 : : .help = "quota limit",
8159 : : .next = NEXT(action_quota_update, NEXT_ENTRY(COMMON_UNSIGNED)),
8160 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_update_quota, quota)),
8161 : : .call = parse_vc_conf
8162 : : },
8163 : : [ACTION_QUOTA_QU_UPDATE_OP] = {
8164 : : .name = "update_op",
8165 : : .help = "query update op SET|ADD",
8166 : : .next = NEXT(action_quota_update,
8167 : : NEXT_ENTRY(ACTION_QUOTA_QU_UPDATE_OP_NAME)),
8168 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_update_quota, op)),
8169 : : .call = parse_vc_conf
8170 : : },
8171 : : [ACTION_QUOTA_QU_UPDATE_OP_NAME] = {
8172 : : .name = "update_op_name",
8173 : : .help = "quota update op name",
8174 : : .call = parse_quota_update_name,
8175 : : .comp = comp_quota_update_name
8176 : : },
8177 : :
8178 : : /* Top-level command. */
8179 : : [ADD] = {
8180 : : .name = "add",
8181 : : .type = "port meter policy {port_id} {arg}",
8182 : : .help = "add port meter policy",
8183 : : .next = NEXT(NEXT_ENTRY(ITEM_POL_PORT)),
8184 : : .call = parse_init,
8185 : : },
8186 : : /* Sub-level commands. */
8187 : : [ITEM_POL_PORT] = {
8188 : : .name = "port",
8189 : : .help = "add port meter policy",
8190 : : .next = NEXT(NEXT_ENTRY(ITEM_POL_METER)),
8191 : : },
8192 : : [ITEM_POL_METER] = {
8193 : : .name = "meter",
8194 : : .help = "add port meter policy",
8195 : : .next = NEXT(NEXT_ENTRY(ITEM_POL_POLICY)),
8196 : : },
8197 : : [ITEM_POL_POLICY] = {
8198 : : .name = "policy",
8199 : : .help = "add port meter policy",
8200 : : .next = NEXT(NEXT_ENTRY(ACTION_POL_R),
8201 : : NEXT_ENTRY(ACTION_POL_Y),
8202 : : NEXT_ENTRY(ACTION_POL_G),
8203 : : NEXT_ENTRY(COMMON_POLICY_ID),
8204 : : NEXT_ENTRY(COMMON_PORT_ID)),
8205 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.policy.policy_id),
8206 : : ARGS_ENTRY(struct buffer, port)),
8207 : : .call = parse_mp,
8208 : : },
8209 : : [ITEM_AGGR_AFFINITY] = {
8210 : : .name = "aggr_affinity",
8211 : : .help = "match on the aggregated port receiving the packets",
8212 : : .priv = PRIV_ITEM(AGGR_AFFINITY,
8213 : : sizeof(struct rte_flow_item_aggr_affinity)),
8214 : : .next = NEXT(item_aggr_affinity),
8215 : : .call = parse_vc,
8216 : : },
8217 : : [ITEM_AGGR_AFFINITY_VALUE] = {
8218 : : .name = "affinity",
8219 : : .help = "aggregated affinity value",
8220 : : .next = NEXT(item_aggr_affinity, NEXT_ENTRY(COMMON_UNSIGNED),
8221 : : item_param),
8222 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_aggr_affinity,
8223 : : affinity)),
8224 : : },
8225 : : [ITEM_TX_QUEUE] = {
8226 : : .name = "tx_queue",
8227 : : .help = "match on the tx queue of send packet",
8228 : : .priv = PRIV_ITEM(TX_QUEUE,
8229 : : sizeof(struct rte_flow_item_tx_queue)),
8230 : : .next = NEXT(item_tx_queue),
8231 : : .call = parse_vc,
8232 : : },
8233 : : [ITEM_TX_QUEUE_VALUE] = {
8234 : : .name = "tx_queue_value",
8235 : : .help = "tx queue value",
8236 : : .next = NEXT(item_tx_queue, NEXT_ENTRY(COMMON_UNSIGNED),
8237 : : item_param),
8238 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tx_queue,
8239 : : tx_queue)),
8240 : : },
8241 : : };
8242 : :
8243 : : /** Remove and return last entry from argument stack. */
8244 : : static const struct arg *
8245 : : pop_args(struct context *ctx)
8246 : : {
8247 : 0 : return ctx->args_num ? ctx->args[--ctx->args_num] : NULL;
8248 : : }
8249 : :
8250 : : /** Add entry on top of the argument stack. */
8251 : : static int
8252 : : push_args(struct context *ctx, const struct arg *arg)
8253 : : {
8254 : 0 : if (ctx->args_num == CTX_STACK_SIZE)
8255 : : return -1;
8256 : 0 : ctx->args[ctx->args_num++] = arg;
8257 : 0 : return 0;
8258 : : }
8259 : :
8260 : : /** Spread value into buffer according to bit-mask. */
8261 : : static size_t
8262 : 0 : arg_entry_bf_fill(void *dst, uintmax_t val, const struct arg *arg)
8263 : : {
8264 : 0 : uint32_t i = arg->size;
8265 : : uint32_t end = 0;
8266 : : int sub = 1;
8267 : : int add = 0;
8268 : : size_t len = 0;
8269 : :
8270 : 0 : if (!arg->mask)
8271 : : return 0;
8272 : : #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
8273 : 0 : if (!arg->hton) {
8274 : : i = 0;
8275 : : end = arg->size;
8276 : : sub = 0;
8277 : : add = 1;
8278 : : }
8279 : : #endif
8280 : 0 : while (i != end) {
8281 : : unsigned int shift = 0;
8282 : 0 : uint8_t *buf = (uint8_t *)dst + arg->offset + (i -= sub);
8283 : :
8284 : 0 : for (shift = 0; arg->mask[i] >> shift; ++shift) {
8285 : 0 : if (!(arg->mask[i] & (1 << shift)))
8286 : 0 : continue;
8287 : 0 : ++len;
8288 : 0 : if (!dst)
8289 : 0 : continue;
8290 : 0 : *buf &= ~(1 << shift);
8291 : 0 : *buf |= (val & 1) << shift;
8292 : 0 : val >>= 1;
8293 : : }
8294 : 0 : i += add;
8295 : : }
8296 : : return len;
8297 : : }
8298 : :
8299 : : /** Compare a string with a partial one of a given length. */
8300 : : static int
8301 : 0 : strcmp_partial(const char *full, const char *partial, size_t partial_len)
8302 : : {
8303 : 0 : int r = strncmp(full, partial, partial_len);
8304 : :
8305 : 0 : if (r)
8306 : : return r;
8307 : 0 : if (strlen(full) <= partial_len)
8308 : : return 0;
8309 : 0 : return full[partial_len];
8310 : : }
8311 : :
8312 : : /**
8313 : : * Parse a prefix length and generate a bit-mask.
8314 : : *
8315 : : * Last argument (ctx->args) is retrieved to determine mask size, storage
8316 : : * location and whether the result must use network byte ordering.
8317 : : */
8318 : : static int
8319 : 0 : parse_prefix(struct context *ctx, const struct token *token,
8320 : : const char *str, unsigned int len,
8321 : : void *buf, unsigned int size)
8322 : : {
8323 : : const struct arg *arg = pop_args(ctx);
8324 : : static const uint8_t conv[] = { 0x00, 0x80, 0xc0, 0xe0, 0xf0,
8325 : : 0xf8, 0xfc, 0xfe, 0xff };
8326 : : char *end;
8327 : : uintmax_t u;
8328 : : unsigned int bytes;
8329 : : unsigned int extra;
8330 : :
8331 : : (void)token;
8332 : : /* Argument is expected. */
8333 : 0 : if (!arg)
8334 : 0 : return -1;
8335 : 0 : errno = 0;
8336 : 0 : u = strtoumax(str, &end, 0);
8337 : 0 : if (errno || (size_t)(end - str) != len)
8338 : 0 : goto error;
8339 : 0 : if (arg->mask) {
8340 : : uintmax_t v = 0;
8341 : :
8342 : 0 : extra = arg_entry_bf_fill(NULL, 0, arg);
8343 : 0 : if (u > extra)
8344 : 0 : goto error;
8345 : 0 : if (!ctx->object)
8346 : 0 : return len;
8347 : 0 : extra -= u;
8348 : 0 : while (u--) {
8349 : 0 : v <<= 1;
8350 : 0 : v |= 1;
8351 : : }
8352 : 0 : v <<= extra;
8353 : 0 : if (!arg_entry_bf_fill(ctx->object, v, arg) ||
8354 : 0 : !arg_entry_bf_fill(ctx->objmask, -1, arg))
8355 : 0 : goto error;
8356 : 0 : return len;
8357 : : }
8358 : 0 : bytes = u / 8;
8359 : 0 : extra = u % 8;
8360 : 0 : size = arg->size;
8361 : 0 : if (bytes > size || bytes + !!extra > size)
8362 : 0 : goto error;
8363 : 0 : if (!ctx->object)
8364 : 0 : return len;
8365 : 0 : buf = (uint8_t *)ctx->object + arg->offset;
8366 : : #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
8367 : 0 : if (!arg->hton) {
8368 : 0 : memset((uint8_t *)buf + size - bytes, 0xff, bytes);
8369 : 0 : memset(buf, 0x00, size - bytes);
8370 : 0 : if (extra)
8371 : 0 : ((uint8_t *)buf)[size - bytes - 1] = conv[extra];
8372 : : } else
8373 : : #endif
8374 : : {
8375 : : memset(buf, 0xff, bytes);
8376 : 0 : memset((uint8_t *)buf + bytes, 0x00, size - bytes);
8377 : 0 : if (extra)
8378 : 0 : ((uint8_t *)buf)[bytes] = conv[extra];
8379 : : }
8380 : 0 : if (ctx->objmask)
8381 : 0 : memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
8382 : 0 : return len;
8383 : 0 : error:
8384 : : push_args(ctx, arg);
8385 : : return -1;
8386 : : }
8387 : :
8388 : : /** Default parsing function for token name matching. */
8389 : : static int
8390 : : parse_default(struct context *ctx, const struct token *token,
8391 : : const char *str, unsigned int len,
8392 : : void *buf, unsigned int size)
8393 : : {
8394 : : (void)ctx;
8395 : : (void)buf;
8396 : : (void)size;
8397 : 0 : if (strcmp_partial(token->name, str, len))
8398 : : return -1;
8399 : 0 : return len;
8400 : : }
8401 : :
8402 : : /** Parse flow command, initialize output buffer for subsequent tokens. */
8403 : : static int
8404 : 0 : parse_init(struct context *ctx, const struct token *token,
8405 : : const char *str, unsigned int len,
8406 : : void *buf, unsigned int size)
8407 : : {
8408 : : struct buffer *out = buf;
8409 : :
8410 : : /* Token name must match. */
8411 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8412 : : return -1;
8413 : : /* Nothing else to do if there is no buffer. */
8414 : 0 : if (!out)
8415 : : return len;
8416 : : /* Make sure buffer is large enough. */
8417 : 0 : if (size < sizeof(*out))
8418 : : return -1;
8419 : : /* Initialize buffer. */
8420 : : memset(out, 0x00, sizeof(*out));
8421 : 0 : memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
8422 : 0 : ctx->objdata = 0;
8423 : 0 : ctx->object = out;
8424 : 0 : ctx->objmask = NULL;
8425 : 0 : return len;
8426 : : }
8427 : :
8428 : : /** Parse tokens for indirect action commands. */
8429 : : static int
8430 : 0 : parse_ia(struct context *ctx, const struct token *token,
8431 : : const char *str, unsigned int len,
8432 : : void *buf, unsigned int size)
8433 : : {
8434 : : struct buffer *out = buf;
8435 : :
8436 : : /* Token name must match. */
8437 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8438 : : return -1;
8439 : : /* Nothing else to do if there is no buffer. */
8440 : 0 : if (!out)
8441 : : return len;
8442 : 0 : if (!out->command) {
8443 : 0 : if (ctx->curr != INDIRECT_ACTION)
8444 : : return -1;
8445 : 0 : if (sizeof(*out) > size)
8446 : : return -1;
8447 : 0 : out->command = ctx->curr;
8448 : 0 : ctx->objdata = 0;
8449 : 0 : ctx->object = out;
8450 : 0 : ctx->objmask = NULL;
8451 : 0 : out->args.vc.data = (uint8_t *)out + size;
8452 : 0 : return len;
8453 : : }
8454 : 0 : switch (ctx->curr) {
8455 : 0 : case INDIRECT_ACTION_CREATE:
8456 : : case INDIRECT_ACTION_UPDATE:
8457 : : case INDIRECT_ACTION_QUERY_UPDATE:
8458 : 0 : out->args.vc.actions =
8459 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8460 : : sizeof(double));
8461 : 0 : out->args.vc.attr.group = UINT32_MAX;
8462 : : /* fallthrough */
8463 : 0 : case INDIRECT_ACTION_QUERY:
8464 : 0 : out->command = ctx->curr;
8465 : 0 : ctx->objdata = 0;
8466 : 0 : ctx->object = out;
8467 : 0 : ctx->objmask = NULL;
8468 : 0 : return len;
8469 : 0 : case INDIRECT_ACTION_EGRESS:
8470 : 0 : out->args.vc.attr.egress = 1;
8471 : 0 : return len;
8472 : 0 : case INDIRECT_ACTION_INGRESS:
8473 : 0 : out->args.vc.attr.ingress = 1;
8474 : 0 : return len;
8475 : 0 : case INDIRECT_ACTION_TRANSFER:
8476 : 0 : out->args.vc.attr.transfer = 1;
8477 : 0 : return len;
8478 : 0 : case INDIRECT_ACTION_QU_MODE:
8479 : 0 : return len;
8480 : 0 : case INDIRECT_ACTION_LIST:
8481 : 0 : out->command = INDIRECT_ACTION_LIST_CREATE;
8482 : 0 : return len;
8483 : 0 : case INDIRECT_ACTION_FLOW_CONF:
8484 : 0 : out->command = INDIRECT_ACTION_FLOW_CONF_CREATE;
8485 : 0 : return len;
8486 : : default:
8487 : : return -1;
8488 : : }
8489 : : }
8490 : :
8491 : :
8492 : : /** Parse tokens for indirect action destroy command. */
8493 : : static int
8494 : 0 : parse_ia_destroy(struct context *ctx, const struct token *token,
8495 : : const char *str, unsigned int len,
8496 : : void *buf, unsigned int size)
8497 : : {
8498 : : struct buffer *out = buf;
8499 : : uint32_t *action_id;
8500 : :
8501 : : /* Token name must match. */
8502 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8503 : : return -1;
8504 : : /* Nothing else to do if there is no buffer. */
8505 : 0 : if (!out)
8506 : : return len;
8507 : 0 : if (!out->command || out->command == INDIRECT_ACTION) {
8508 : 0 : if (ctx->curr != INDIRECT_ACTION_DESTROY)
8509 : : return -1;
8510 : 0 : if (sizeof(*out) > size)
8511 : : return -1;
8512 : 0 : out->command = ctx->curr;
8513 : 0 : ctx->objdata = 0;
8514 : 0 : ctx->object = out;
8515 : 0 : ctx->objmask = NULL;
8516 : 0 : out->args.ia_destroy.action_id =
8517 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8518 : : sizeof(double));
8519 : 0 : return len;
8520 : : }
8521 : 0 : action_id = out->args.ia_destroy.action_id
8522 : 0 : + out->args.ia_destroy.action_id_n++;
8523 : 0 : if ((uint8_t *)action_id > (uint8_t *)out + size)
8524 : : return -1;
8525 : 0 : ctx->objdata = 0;
8526 : 0 : ctx->object = action_id;
8527 : 0 : ctx->objmask = NULL;
8528 : 0 : return len;
8529 : : }
8530 : :
8531 : : /** Parse tokens for indirect action commands. */
8532 : : static int
8533 : 0 : parse_qia(struct context *ctx, const struct token *token,
8534 : : const char *str, unsigned int len,
8535 : : void *buf, unsigned int size)
8536 : : {
8537 : : struct buffer *out = buf;
8538 : :
8539 : : /* Token name must match. */
8540 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8541 : : return -1;
8542 : : /* Nothing else to do if there is no buffer. */
8543 : 0 : if (!out)
8544 : : return len;
8545 : 0 : if (!out->command) {
8546 : 0 : if (ctx->curr != QUEUE)
8547 : : return -1;
8548 : 0 : if (sizeof(*out) > size)
8549 : : return -1;
8550 : 0 : out->args.vc.data = (uint8_t *)out + size;
8551 : 0 : return len;
8552 : : }
8553 : 0 : switch (ctx->curr) {
8554 : 0 : case QUEUE_INDIRECT_ACTION:
8555 : 0 : return len;
8556 : 0 : case QUEUE_INDIRECT_ACTION_CREATE:
8557 : : case QUEUE_INDIRECT_ACTION_UPDATE:
8558 : : case QUEUE_INDIRECT_ACTION_QUERY_UPDATE:
8559 : 0 : out->args.vc.actions =
8560 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8561 : : sizeof(double));
8562 : 0 : out->args.vc.attr.group = UINT32_MAX;
8563 : : /* fallthrough */
8564 : 0 : case QUEUE_INDIRECT_ACTION_QUERY:
8565 : 0 : out->command = ctx->curr;
8566 : 0 : ctx->objdata = 0;
8567 : 0 : ctx->object = out;
8568 : 0 : ctx->objmask = NULL;
8569 : 0 : return len;
8570 : 0 : case QUEUE_INDIRECT_ACTION_EGRESS:
8571 : 0 : out->args.vc.attr.egress = 1;
8572 : 0 : return len;
8573 : 0 : case QUEUE_INDIRECT_ACTION_INGRESS:
8574 : 0 : out->args.vc.attr.ingress = 1;
8575 : 0 : return len;
8576 : 0 : case QUEUE_INDIRECT_ACTION_TRANSFER:
8577 : 0 : out->args.vc.attr.transfer = 1;
8578 : 0 : return len;
8579 : 0 : case QUEUE_INDIRECT_ACTION_CREATE_POSTPONE:
8580 : 0 : return len;
8581 : 0 : case QUEUE_INDIRECT_ACTION_QU_MODE:
8582 : 0 : return len;
8583 : 0 : case QUEUE_INDIRECT_ACTION_LIST:
8584 : 0 : out->command = QUEUE_INDIRECT_ACTION_LIST_CREATE;
8585 : 0 : return len;
8586 : : default:
8587 : : return -1;
8588 : : }
8589 : : }
8590 : :
8591 : : /** Parse tokens for indirect action destroy command. */
8592 : : static int
8593 : 0 : parse_qia_destroy(struct context *ctx, const struct token *token,
8594 : : const char *str, unsigned int len,
8595 : : void *buf, unsigned int size)
8596 : : {
8597 : : struct buffer *out = buf;
8598 : : uint32_t *action_id;
8599 : :
8600 : : /* Token name must match. */
8601 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8602 : : return -1;
8603 : : /* Nothing else to do if there is no buffer. */
8604 : 0 : if (!out)
8605 : : return len;
8606 : 0 : if (!out->command || out->command == QUEUE) {
8607 : 0 : if (ctx->curr != QUEUE_INDIRECT_ACTION_DESTROY)
8608 : : return -1;
8609 : 0 : if (sizeof(*out) > size)
8610 : : return -1;
8611 : 0 : out->command = ctx->curr;
8612 : 0 : ctx->objdata = 0;
8613 : 0 : ctx->object = out;
8614 : 0 : ctx->objmask = NULL;
8615 : 0 : out->args.ia_destroy.action_id =
8616 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8617 : : sizeof(double));
8618 : 0 : return len;
8619 : : }
8620 : 0 : switch (ctx->curr) {
8621 : 0 : case QUEUE_INDIRECT_ACTION:
8622 : 0 : out->command = ctx->curr;
8623 : 0 : ctx->objdata = 0;
8624 : 0 : ctx->object = out;
8625 : 0 : ctx->objmask = NULL;
8626 : 0 : return len;
8627 : 0 : case QUEUE_INDIRECT_ACTION_DESTROY_ID:
8628 : 0 : action_id = out->args.ia_destroy.action_id
8629 : 0 : + out->args.ia_destroy.action_id_n++;
8630 : 0 : if ((uint8_t *)action_id > (uint8_t *)out + size)
8631 : : return -1;
8632 : 0 : ctx->objdata = 0;
8633 : 0 : ctx->object = action_id;
8634 : 0 : ctx->objmask = NULL;
8635 : 0 : return len;
8636 : 0 : case QUEUE_INDIRECT_ACTION_DESTROY_POSTPONE:
8637 : 0 : return len;
8638 : : default:
8639 : : return -1;
8640 : : }
8641 : : }
8642 : :
8643 : : /** Parse tokens for meter policy action commands. */
8644 : : static int
8645 : 0 : parse_mp(struct context *ctx, const struct token *token,
8646 : : const char *str, unsigned int len,
8647 : : void *buf, unsigned int size)
8648 : : {
8649 : : struct buffer *out = buf;
8650 : :
8651 : : /* Token name must match. */
8652 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8653 : : return -1;
8654 : : /* Nothing else to do if there is no buffer. */
8655 : 0 : if (!out)
8656 : : return len;
8657 : 0 : if (!out->command) {
8658 : 0 : if (ctx->curr != ITEM_POL_POLICY)
8659 : : return -1;
8660 : 0 : if (sizeof(*out) > size)
8661 : : return -1;
8662 : 0 : out->command = ctx->curr;
8663 : 0 : ctx->objdata = 0;
8664 : 0 : ctx->object = out;
8665 : 0 : ctx->objmask = NULL;
8666 : 0 : out->args.vc.data = (uint8_t *)out + size;
8667 : 0 : return len;
8668 : : }
8669 : 0 : switch (ctx->curr) {
8670 : 0 : case ACTION_POL_G:
8671 : 0 : out->args.vc.actions =
8672 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8673 : : sizeof(double));
8674 : 0 : out->command = ctx->curr;
8675 : 0 : ctx->objdata = 0;
8676 : 0 : ctx->object = out;
8677 : 0 : ctx->objmask = NULL;
8678 : 0 : return len;
8679 : : default:
8680 : : return -1;
8681 : : }
8682 : : }
8683 : :
8684 : : /** Parse tokens for validate/create commands. */
8685 : : static int
8686 : 0 : parse_vc(struct context *ctx, const struct token *token,
8687 : : const char *str, unsigned int len,
8688 : : void *buf, unsigned int size)
8689 : : {
8690 : : struct buffer *out = buf;
8691 : : uint8_t *data;
8692 : : uint32_t data_size;
8693 : :
8694 : : /* Token name must match. */
8695 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8696 : : return -1;
8697 : : /* Nothing else to do if there is no buffer. */
8698 : 0 : if (!out)
8699 : : return len;
8700 : 0 : if (!out->command) {
8701 : 0 : if (ctx->curr != VALIDATE && ctx->curr != CREATE &&
8702 : 0 : ctx->curr != PATTERN_TEMPLATE_CREATE &&
8703 : 0 : ctx->curr != ACTIONS_TEMPLATE_CREATE &&
8704 : : ctx->curr != UPDATE)
8705 : : return -1;
8706 : 0 : if (ctx->curr == UPDATE)
8707 : 0 : out->args.vc.pattern =
8708 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8709 : : sizeof(double));
8710 : 0 : if (sizeof(*out) > size)
8711 : : return -1;
8712 : 0 : out->command = ctx->curr;
8713 : 0 : ctx->objdata = 0;
8714 : 0 : ctx->object = out;
8715 : 0 : ctx->objmask = NULL;
8716 : 0 : out->args.vc.data = (uint8_t *)out + size;
8717 : 0 : return len;
8718 : : }
8719 : 0 : ctx->objdata = 0;
8720 : 0 : switch (ctx->curr) {
8721 : 0 : default:
8722 : 0 : ctx->object = &out->args.vc.attr;
8723 : 0 : break;
8724 : 0 : case VC_TUNNEL_SET:
8725 : : case VC_TUNNEL_MATCH:
8726 : 0 : ctx->object = &out->args.vc.tunnel_ops;
8727 : 0 : break;
8728 : 0 : case VC_USER_ID:
8729 : 0 : ctx->object = out;
8730 : 0 : break;
8731 : : }
8732 : 0 : ctx->objmask = NULL;
8733 : 0 : switch (ctx->curr) {
8734 : : case VC_GROUP:
8735 : : case VC_PRIORITY:
8736 : : case VC_USER_ID:
8737 : : return len;
8738 : 0 : case VC_TUNNEL_SET:
8739 : 0 : out->args.vc.tunnel_ops.enabled = 1;
8740 : 0 : out->args.vc.tunnel_ops.actions = 1;
8741 : 0 : return len;
8742 : 0 : case VC_TUNNEL_MATCH:
8743 : 0 : out->args.vc.tunnel_ops.enabled = 1;
8744 : 0 : out->args.vc.tunnel_ops.items = 1;
8745 : 0 : return len;
8746 : 0 : case VC_INGRESS:
8747 : 0 : out->args.vc.attr.ingress = 1;
8748 : 0 : return len;
8749 : 0 : case VC_EGRESS:
8750 : 0 : out->args.vc.attr.egress = 1;
8751 : 0 : return len;
8752 : 0 : case VC_TRANSFER:
8753 : 0 : out->args.vc.attr.transfer = 1;
8754 : 0 : return len;
8755 : 0 : case ITEM_PATTERN:
8756 : 0 : out->args.vc.pattern =
8757 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8758 : : sizeof(double));
8759 : 0 : ctx->object = out->args.vc.pattern;
8760 : 0 : ctx->objmask = NULL;
8761 : 0 : return len;
8762 : 0 : case ITEM_END:
8763 : 0 : if ((out->command == VALIDATE || out->command == CREATE) &&
8764 : : ctx->last)
8765 : : return -1;
8766 : 0 : if (out->command == PATTERN_TEMPLATE_CREATE &&
8767 : 0 : !ctx->last)
8768 : : return -1;
8769 : : break;
8770 : 0 : case ACTIONS:
8771 : 0 : out->args.vc.actions = out->args.vc.pattern ?
8772 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)
8773 : : (out->args.vc.pattern +
8774 : : out->args.vc.pattern_n),
8775 : 0 : sizeof(double)) :
8776 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8777 : : sizeof(double));
8778 : 0 : ctx->object = out->args.vc.actions;
8779 : 0 : ctx->objmask = NULL;
8780 : 0 : return len;
8781 : 0 : case VC_IS_USER_ID:
8782 : 0 : out->args.vc.user_id = true;
8783 : 0 : return len;
8784 : 0 : default:
8785 : 0 : if (!token->priv)
8786 : : return -1;
8787 : : break;
8788 : : }
8789 : 0 : if (!out->args.vc.actions) {
8790 : 0 : const struct parse_item_priv *priv = token->priv;
8791 : 0 : struct rte_flow_item *item =
8792 : 0 : out->args.vc.pattern + out->args.vc.pattern_n;
8793 : :
8794 : 0 : data_size = priv->size * 3; /* spec, last, mask */
8795 : 0 : data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
8796 : : (out->args.vc.data - data_size),
8797 : : sizeof(double));
8798 : 0 : if ((uint8_t *)item + sizeof(*item) > data)
8799 : : return -1;
8800 : 0 : *item = (struct rte_flow_item){
8801 : 0 : .type = priv->type,
8802 : : };
8803 : 0 : ++out->args.vc.pattern_n;
8804 : 0 : ctx->object = item;
8805 : 0 : ctx->objmask = NULL;
8806 : : } else {
8807 : 0 : const struct parse_action_priv *priv = token->priv;
8808 : 0 : struct rte_flow_action *action =
8809 : 0 : out->args.vc.actions + out->args.vc.actions_n;
8810 : :
8811 : 0 : data_size = priv->size; /* configuration */
8812 : 0 : data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
8813 : : (out->args.vc.data - data_size),
8814 : : sizeof(double));
8815 : 0 : if ((uint8_t *)action + sizeof(*action) > data)
8816 : : return -1;
8817 : 0 : *action = (struct rte_flow_action){
8818 : 0 : .type = priv->type,
8819 : 0 : .conf = data_size ? data : NULL,
8820 : : };
8821 : 0 : ++out->args.vc.actions_n;
8822 : 0 : ctx->object = action;
8823 : 0 : ctx->objmask = NULL;
8824 : : }
8825 : 0 : memset(data, 0, data_size);
8826 : 0 : out->args.vc.data = data;
8827 : 0 : ctx->objdata = data_size;
8828 : 0 : return len;
8829 : : }
8830 : :
8831 : : /** Parse pattern item parameter type. */
8832 : : static int
8833 : 0 : parse_vc_spec(struct context *ctx, const struct token *token,
8834 : : const char *str, unsigned int len,
8835 : : void *buf, unsigned int size)
8836 : : {
8837 : : struct buffer *out = buf;
8838 : : struct rte_flow_item *item;
8839 : : uint32_t data_size;
8840 : : int index;
8841 : : int objmask = 0;
8842 : :
8843 : : (void)size;
8844 : : /* Token name must match. */
8845 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8846 : : return -1;
8847 : : /* Parse parameter types. */
8848 : 0 : switch (ctx->curr) {
8849 : : case ITEM_PARAM_IS:
8850 : : index = 0;
8851 : : objmask = 1;
8852 : 0 : break;
8853 : 0 : case ITEM_PARAM_SPEC:
8854 : : index = 0;
8855 : 0 : break;
8856 : 0 : case ITEM_PARAM_LAST:
8857 : : index = 1;
8858 : 0 : break;
8859 : 0 : case ITEM_PARAM_PREFIX:
8860 : : /* Modify next token to expect a prefix. */
8861 : 0 : if (ctx->next_num < 2)
8862 : 0 : return -1;
8863 : 0 : ctx->next[ctx->next_num - 2] = NEXT_ENTRY(COMMON_PREFIX);
8864 : : /* Fall through. */
8865 : : case ITEM_PARAM_MASK:
8866 : : index = 2;
8867 : : break;
8868 : : default:
8869 : : return -1;
8870 : : }
8871 : : /* Nothing else to do if there is no buffer. */
8872 : 0 : if (!out)
8873 : : return len;
8874 : 0 : if (!out->args.vc.pattern_n)
8875 : : return -1;
8876 : 0 : item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
8877 : 0 : data_size = ctx->objdata / 3; /* spec, last, mask */
8878 : : /* Point to selected object. */
8879 : 0 : ctx->object = out->args.vc.data + (data_size * index);
8880 : 0 : if (objmask) {
8881 : 0 : ctx->objmask = out->args.vc.data + (data_size * 2); /* mask */
8882 : 0 : item->mask = ctx->objmask;
8883 : : } else
8884 : 0 : ctx->objmask = NULL;
8885 : : /* Update relevant item pointer. */
8886 : 0 : *((const void **[]){ &item->spec, &item->last, &item->mask })[index] =
8887 : : ctx->object;
8888 : 0 : return len;
8889 : : }
8890 : :
8891 : : /** Parse action configuration field. */
8892 : : static int
8893 : 0 : parse_vc_conf(struct context *ctx, const struct token *token,
8894 : : const char *str, unsigned int len,
8895 : : void *buf, unsigned int size)
8896 : : {
8897 : : struct buffer *out = buf;
8898 : :
8899 : : (void)size;
8900 : : /* Token name must match. */
8901 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8902 : : return -1;
8903 : : /* Nothing else to do if there is no buffer. */
8904 : 0 : if (!out)
8905 : : return len;
8906 : : /* Point to selected object. */
8907 : 0 : ctx->object = out->args.vc.data;
8908 : 0 : ctx->objmask = NULL;
8909 : 0 : return len;
8910 : : }
8911 : :
8912 : : /** Parse action configuration field. */
8913 : : static int
8914 : 0 : parse_vc_conf_timeout(struct context *ctx, const struct token *token,
8915 : : const char *str, unsigned int len,
8916 : : void *buf, unsigned int size)
8917 : : {
8918 : : struct buffer *out = buf;
8919 : : struct rte_flow_update_age *update;
8920 : :
8921 : : (void)size;
8922 : 0 : if (ctx->curr != ACTION_AGE_UPDATE_TIMEOUT)
8923 : : return -1;
8924 : : /* Token name must match. */
8925 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8926 : : return -1;
8927 : : /* Nothing else to do if there is no buffer. */
8928 : 0 : if (!out)
8929 : : return len;
8930 : : /* Point to selected object. */
8931 : 0 : ctx->object = out->args.vc.data;
8932 : 0 : ctx->objmask = NULL;
8933 : : /* Update the timeout is valid. */
8934 : : update = (struct rte_flow_update_age *)out->args.vc.data;
8935 : 0 : update->timeout_valid = 1;
8936 : 0 : return len;
8937 : : }
8938 : :
8939 : : /** Parse eCPRI common header type field. */
8940 : : static int
8941 : 0 : parse_vc_item_ecpri_type(struct context *ctx, const struct token *token,
8942 : : const char *str, unsigned int len,
8943 : : void *buf, unsigned int size)
8944 : : {
8945 : : struct rte_flow_item_ecpri *ecpri;
8946 : : struct rte_flow_item_ecpri *ecpri_mask;
8947 : : struct rte_flow_item *item;
8948 : : uint32_t data_size;
8949 : : uint8_t msg_type;
8950 : : struct buffer *out = buf;
8951 : : const struct arg *arg;
8952 : :
8953 : : (void)size;
8954 : : /* Token name must match. */
8955 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8956 : : return -1;
8957 : 0 : switch (ctx->curr) {
8958 : : case ITEM_ECPRI_COMMON_TYPE_IQ_DATA:
8959 : : msg_type = RTE_ECPRI_MSG_TYPE_IQ_DATA;
8960 : : break;
8961 : : case ITEM_ECPRI_COMMON_TYPE_RTC_CTRL:
8962 : : msg_type = RTE_ECPRI_MSG_TYPE_RTC_CTRL;
8963 : : break;
8964 : : case ITEM_ECPRI_COMMON_TYPE_DLY_MSR:
8965 : : msg_type = RTE_ECPRI_MSG_TYPE_DLY_MSR;
8966 : : break;
8967 : : default:
8968 : : return -1;
8969 : : }
8970 : 0 : if (!ctx->object)
8971 : : return len;
8972 : : arg = pop_args(ctx);
8973 : 0 : if (!arg)
8974 : 0 : return -1;
8975 : 0 : ecpri = (struct rte_flow_item_ecpri *)out->args.vc.data;
8976 : 0 : ecpri->hdr.common.type = msg_type;
8977 : 0 : data_size = ctx->objdata / 3; /* spec, last, mask */
8978 : 0 : ecpri_mask = (struct rte_flow_item_ecpri *)(out->args.vc.data +
8979 : 0 : (data_size * 2));
8980 : 0 : ecpri_mask->hdr.common.type = 0xFF;
8981 : 0 : if (arg->hton) {
8982 : 0 : ecpri->hdr.common.u32 = rte_cpu_to_be_32(ecpri->hdr.common.u32);
8983 : 0 : ecpri_mask->hdr.common.u32 =
8984 : 0 : rte_cpu_to_be_32(ecpri_mask->hdr.common.u32);
8985 : : }
8986 : 0 : item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
8987 : 0 : item->spec = ecpri;
8988 : 0 : item->mask = ecpri_mask;
8989 : 0 : return len;
8990 : : }
8991 : :
8992 : : /** Parse L2TPv2 common header type field. */
8993 : : static int
8994 : 0 : parse_vc_item_l2tpv2_type(struct context *ctx, const struct token *token,
8995 : : const char *str, unsigned int len,
8996 : : void *buf, unsigned int size)
8997 : : {
8998 : : struct rte_flow_item_l2tpv2 *l2tpv2;
8999 : : struct rte_flow_item_l2tpv2 *l2tpv2_mask;
9000 : : struct rte_flow_item *item;
9001 : : uint32_t data_size;
9002 : : uint16_t msg_type = 0;
9003 : : struct buffer *out = buf;
9004 : : const struct arg *arg;
9005 : :
9006 : : (void)size;
9007 : : /* Token name must match. */
9008 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
9009 : : return -1;
9010 : 0 : switch (ctx->curr) {
9011 : : case ITEM_L2TPV2_TYPE_DATA:
9012 : : msg_type |= RTE_L2TPV2_MSG_TYPE_DATA;
9013 : : break;
9014 : : case ITEM_L2TPV2_TYPE_DATA_L:
9015 : : msg_type |= RTE_L2TPV2_MSG_TYPE_DATA_L;
9016 : : break;
9017 : : case ITEM_L2TPV2_TYPE_DATA_S:
9018 : : msg_type |= RTE_L2TPV2_MSG_TYPE_DATA_S;
9019 : : break;
9020 : : case ITEM_L2TPV2_TYPE_DATA_O:
9021 : : msg_type |= RTE_L2TPV2_MSG_TYPE_DATA_O;
9022 : : break;
9023 : : case ITEM_L2TPV2_TYPE_DATA_L_S:
9024 : : msg_type |= RTE_L2TPV2_MSG_TYPE_DATA_L_S;
9025 : : break;
9026 : : case ITEM_L2TPV2_TYPE_CTRL:
9027 : : msg_type |= RTE_L2TPV2_MSG_TYPE_CONTROL;
9028 : : break;
9029 : : default:
9030 : : return -1;
9031 : : }
9032 : 0 : if (!ctx->object)
9033 : : return len;
9034 : : arg = pop_args(ctx);
9035 : 0 : if (!arg)
9036 : 0 : return -1;
9037 : 0 : l2tpv2 = (struct rte_flow_item_l2tpv2 *)out->args.vc.data;
9038 : 0 : l2tpv2->hdr.common.flags_version |= msg_type;
9039 : 0 : data_size = ctx->objdata / 3; /* spec, last, mask */
9040 : 0 : l2tpv2_mask = (struct rte_flow_item_l2tpv2 *)(out->args.vc.data +
9041 : 0 : (data_size * 2));
9042 : 0 : l2tpv2_mask->hdr.common.flags_version = 0xFFFF;
9043 : 0 : if (arg->hton) {
9044 : 0 : l2tpv2->hdr.common.flags_version =
9045 : 0 : rte_cpu_to_be_16(l2tpv2->hdr.common.flags_version);
9046 : 0 : l2tpv2_mask->hdr.common.flags_version =
9047 : 0 : rte_cpu_to_be_16(l2tpv2_mask->hdr.common.flags_version);
9048 : : }
9049 : 0 : item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
9050 : 0 : item->spec = l2tpv2;
9051 : 0 : item->mask = l2tpv2_mask;
9052 : 0 : return len;
9053 : : }
9054 : :
9055 : : /** Parse operation for compare match item. */
9056 : : static int
9057 : 0 : parse_vc_compare_op(struct context *ctx, const struct token *token,
9058 : : const char *str, unsigned int len, void *buf,
9059 : : unsigned int size)
9060 : : {
9061 : : struct rte_flow_item_compare *compare_item;
9062 : : unsigned int i;
9063 : :
9064 : : (void)token;
9065 : : (void)buf;
9066 : : (void)size;
9067 : 0 : if (ctx->curr != ITEM_COMPARE_OP_VALUE)
9068 : : return -1;
9069 : 0 : for (i = 0; compare_ops[i]; ++i)
9070 : 0 : if (!strcmp_partial(compare_ops[i], str, len))
9071 : : break;
9072 : 0 : if (!compare_ops[i])
9073 : : return -1;
9074 : 0 : if (!ctx->object)
9075 : 0 : return len;
9076 : : compare_item = ctx->object;
9077 : 0 : compare_item->operation = (enum rte_flow_item_compare_op)i;
9078 : 0 : return len;
9079 : : }
9080 : :
9081 : : /** Parse id for compare match item. */
9082 : : static int
9083 : 0 : parse_vc_compare_field_id(struct context *ctx, const struct token *token,
9084 : : const char *str, unsigned int len, void *buf,
9085 : : unsigned int size)
9086 : : {
9087 : : struct rte_flow_item_compare *compare_item;
9088 : : unsigned int i;
9089 : :
9090 : : (void)token;
9091 : : (void)buf;
9092 : : (void)size;
9093 : 0 : if (ctx->curr != ITEM_COMPARE_FIELD_A_TYPE_VALUE &&
9094 : : ctx->curr != ITEM_COMPARE_FIELD_B_TYPE_VALUE)
9095 : : return -1;
9096 : 0 : for (i = 0; flow_field_ids[i]; ++i)
9097 : 0 : if (!strcmp_partial(flow_field_ids[i], str, len))
9098 : : break;
9099 : 0 : if (!flow_field_ids[i])
9100 : : return -1;
9101 : 0 : if (!ctx->object)
9102 : 0 : return len;
9103 : : compare_item = ctx->object;
9104 : 0 : if (ctx->curr == ITEM_COMPARE_FIELD_A_TYPE_VALUE)
9105 : 0 : compare_item->a.field = (enum rte_flow_field_id)i;
9106 : : else
9107 : 0 : compare_item->b.field = (enum rte_flow_field_id)i;
9108 : 0 : return len;
9109 : : }
9110 : :
9111 : : /** Parse level for compare match item. */
9112 : : static int
9113 : 0 : parse_vc_compare_field_level(struct context *ctx, const struct token *token,
9114 : : const char *str, unsigned int len, void *buf,
9115 : : unsigned int size)
9116 : : {
9117 : : struct rte_flow_item_compare *compare_item;
9118 : : struct flex_item *fp = NULL;
9119 : : uint32_t val;
9120 : : struct buffer *out = buf;
9121 : : char *end;
9122 : :
9123 : : (void)token;
9124 : : (void)size;
9125 : 0 : if (ctx->curr != ITEM_COMPARE_FIELD_A_LEVEL_VALUE &&
9126 : : ctx->curr != ITEM_COMPARE_FIELD_B_LEVEL_VALUE)
9127 : : return -1;
9128 : 0 : if (!ctx->object)
9129 : 0 : return len;
9130 : : compare_item = ctx->object;
9131 : 0 : errno = 0;
9132 : 0 : val = strtoumax(str, &end, 0);
9133 : 0 : if (errno || (size_t)(end - str) != len)
9134 : : return -1;
9135 : : /* No need to validate action template mask value */
9136 : 0 : if (out->args.vc.masks) {
9137 : 0 : if (ctx->curr == ITEM_COMPARE_FIELD_A_LEVEL_VALUE)
9138 : 0 : compare_item->a.level = val;
9139 : : else
9140 : 0 : compare_item->b.level = val;
9141 : 0 : return len;
9142 : : }
9143 : 0 : if ((ctx->curr == ITEM_COMPARE_FIELD_A_LEVEL_VALUE &&
9144 : 0 : compare_item->a.field == RTE_FLOW_FIELD_FLEX_ITEM) ||
9145 : 0 : (ctx->curr == ITEM_COMPARE_FIELD_B_LEVEL_VALUE &&
9146 : 0 : compare_item->b.field == RTE_FLOW_FIELD_FLEX_ITEM)) {
9147 : 0 : if (val >= FLEX_MAX_PARSERS_NUM) {
9148 : : printf("Bad flex item handle\n");
9149 : 0 : return -1;
9150 : : }
9151 : 0 : fp = flex_items[ctx->port][val];
9152 : 0 : if (!fp) {
9153 : : printf("Bad flex item handle\n");
9154 : 0 : return -1;
9155 : : }
9156 : : }
9157 : 0 : if (ctx->curr == ITEM_COMPARE_FIELD_A_LEVEL_VALUE) {
9158 : 0 : if (compare_item->a.field != RTE_FLOW_FIELD_FLEX_ITEM)
9159 : 0 : compare_item->a.level = val;
9160 : : else
9161 : 0 : compare_item->a.flex_handle = fp->flex_handle;
9162 : 0 : } else if (ctx->curr == ITEM_COMPARE_FIELD_B_LEVEL_VALUE) {
9163 : 0 : if (compare_item->b.field != RTE_FLOW_FIELD_FLEX_ITEM)
9164 : 0 : compare_item->b.level = val;
9165 : : else
9166 : 0 : compare_item->b.flex_handle = fp->flex_handle;
9167 : : }
9168 : 0 : return len;
9169 : : }
9170 : :
9171 : : /** Parse meter color action type. */
9172 : : static int
9173 : 0 : parse_vc_action_meter_color_type(struct context *ctx, const struct token *token,
9174 : : const char *str, unsigned int len,
9175 : : void *buf, unsigned int size)
9176 : : {
9177 : : struct rte_flow_action *action_data;
9178 : : struct rte_flow_action_meter_color *conf;
9179 : : enum rte_color color;
9180 : :
9181 : : (void)buf;
9182 : : (void)size;
9183 : : /* Token name must match. */
9184 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
9185 : : return -1;
9186 : 0 : switch (ctx->curr) {
9187 : : case ACTION_METER_COLOR_GREEN:
9188 : : color = RTE_COLOR_GREEN;
9189 : : break;
9190 : : case ACTION_METER_COLOR_YELLOW:
9191 : : color = RTE_COLOR_YELLOW;
9192 : : break;
9193 : : case ACTION_METER_COLOR_RED:
9194 : : color = RTE_COLOR_RED;
9195 : : break;
9196 : : default:
9197 : : return -1;
9198 : : }
9199 : :
9200 : 0 : if (!ctx->object)
9201 : : return len;
9202 : : action_data = ctx->object;
9203 : 0 : conf = (struct rte_flow_action_meter_color *)
9204 : : (uintptr_t)(action_data->conf);
9205 : 0 : conf->color = color;
9206 : 0 : return len;
9207 : : }
9208 : :
9209 : : /** Parse RSS action. */
9210 : : static int
9211 : 0 : parse_vc_action_rss(struct context *ctx, const struct token *token,
9212 : : const char *str, unsigned int len,
9213 : : void *buf, unsigned int size)
9214 : : {
9215 : : struct buffer *out = buf;
9216 : : struct rte_flow_action *action;
9217 : : struct action_rss_data *action_rss_data;
9218 : : unsigned int i;
9219 : : int ret;
9220 : :
9221 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
9222 : 0 : if (ret < 0)
9223 : : return ret;
9224 : : /* Nothing else to do if there is no buffer. */
9225 : 0 : if (!out)
9226 : : return ret;
9227 : 0 : if (!out->args.vc.actions_n)
9228 : : return -1;
9229 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
9230 : : /* Point to selected object. */
9231 : 0 : ctx->object = out->args.vc.data;
9232 : 0 : ctx->objmask = NULL;
9233 : : /* Set up default configuration. */
9234 : : action_rss_data = ctx->object;
9235 : 0 : *action_rss_data = (struct action_rss_data){
9236 : : .conf = (struct rte_flow_action_rss){
9237 : : .func = RTE_ETH_HASH_FUNCTION_DEFAULT,
9238 : : .level = 0,
9239 : : .types = rss_hf,
9240 : : .key_len = 0,
9241 : 0 : .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM),
9242 : : .key = NULL,
9243 : 0 : .queue = action_rss_data->queue,
9244 : : },
9245 : : .queue = { 0 },
9246 : : };
9247 : 0 : for (i = 0; i < action_rss_data->conf.queue_num; ++i)
9248 : 0 : action_rss_data->queue[i] = i;
9249 : 0 : action->conf = &action_rss_data->conf;
9250 : 0 : return ret;
9251 : : }
9252 : :
9253 : : /**
9254 : : * Parse func field for RSS action.
9255 : : *
9256 : : * The RTE_ETH_HASH_FUNCTION_* value to assign is derived from the
9257 : : * ACTION_RSS_FUNC_* index that called this function.
9258 : : */
9259 : : static int
9260 : 0 : parse_vc_action_rss_func(struct context *ctx, const struct token *token,
9261 : : const char *str, unsigned int len,
9262 : : void *buf, unsigned int size)
9263 : : {
9264 : : struct action_rss_data *action_rss_data;
9265 : : enum rte_eth_hash_function func;
9266 : :
9267 : : (void)buf;
9268 : : (void)size;
9269 : : /* Token name must match. */
9270 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
9271 : : return -1;
9272 : 0 : switch (ctx->curr) {
9273 : : case ACTION_RSS_FUNC_DEFAULT:
9274 : : func = RTE_ETH_HASH_FUNCTION_DEFAULT;
9275 : : break;
9276 : : case ACTION_RSS_FUNC_TOEPLITZ:
9277 : : func = RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9278 : : break;
9279 : : case ACTION_RSS_FUNC_SIMPLE_XOR:
9280 : : func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9281 : : break;
9282 : : case ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ:
9283 : : func = RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
9284 : : break;
9285 : : default:
9286 : : return -1;
9287 : : }
9288 : 0 : if (!ctx->object)
9289 : : return len;
9290 : : action_rss_data = ctx->object;
9291 : 0 : action_rss_data->conf.func = func;
9292 : 0 : return len;
9293 : : }
9294 : :
9295 : : /**
9296 : : * Parse type field for RSS action.
9297 : : *
9298 : : * Valid tokens are type field names and the "end" token.
9299 : : */
9300 : : static int
9301 : 0 : parse_vc_action_rss_type(struct context *ctx, const struct token *token,
9302 : : const char *str, unsigned int len,
9303 : : void *buf, unsigned int size)
9304 : : {
9305 : : struct action_rss_data *action_rss_data;
9306 : : unsigned int i;
9307 : :
9308 : : (void)token;
9309 : : (void)buf;
9310 : : (void)size;
9311 : 0 : if (ctx->curr != ACTION_RSS_TYPE)
9312 : : return -1;
9313 : 0 : if (!(ctx->objdata >> 16) && ctx->object) {
9314 : : action_rss_data = ctx->object;
9315 : 0 : action_rss_data->conf.types = 0;
9316 : : }
9317 : 0 : if (!strcmp_partial("end", str, len)) {
9318 : 0 : ctx->objdata &= 0xffff;
9319 : 0 : return len;
9320 : : }
9321 : 0 : for (i = 0; rss_type_table[i].str; ++i)
9322 : 0 : if (!strcmp_partial(rss_type_table[i].str, str, len))
9323 : : break;
9324 : 0 : if (!rss_type_table[i].str)
9325 : : return -1;
9326 : 0 : ctx->objdata = 1 << 16 | (ctx->objdata & 0xffff);
9327 : : /* Repeat token. */
9328 : 0 : if (ctx->next_num == RTE_DIM(ctx->next))
9329 : : return -1;
9330 : 0 : ctx->next[ctx->next_num++] = NEXT_ENTRY(ACTION_RSS_TYPE);
9331 : 0 : if (!ctx->object)
9332 : 0 : return len;
9333 : : action_rss_data = ctx->object;
9334 : 0 : action_rss_data->conf.types |= rss_type_table[i].rss_type;
9335 : 0 : return len;
9336 : : }
9337 : :
9338 : : /**
9339 : : * Parse queue field for RSS action.
9340 : : *
9341 : : * Valid tokens are queue indices and the "end" token.
9342 : : */
9343 : : static int
9344 : 0 : parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
9345 : : const char *str, unsigned int len,
9346 : : void *buf, unsigned int size)
9347 : : {
9348 : : struct action_rss_data *action_rss_data;
9349 : : const struct arg *arg;
9350 : : int ret;
9351 : : int i;
9352 : :
9353 : : (void)token;
9354 : : (void)buf;
9355 : : (void)size;
9356 : 0 : if (ctx->curr != ACTION_RSS_QUEUE)
9357 : : return -1;
9358 : 0 : i = ctx->objdata >> 16;
9359 : 0 : if (!strcmp_partial("end", str, len)) {
9360 : 0 : ctx->objdata &= 0xffff;
9361 : 0 : goto end;
9362 : : }
9363 : 0 : if (i >= ACTION_RSS_QUEUE_NUM)
9364 : : return -1;
9365 : 0 : arg = ARGS_ENTRY_ARB(offsetof(struct action_rss_data, queue) +
9366 : : i * sizeof(action_rss_data->queue[i]),
9367 : : sizeof(action_rss_data->queue[i]));
9368 : : if (push_args(ctx, arg))
9369 : : return -1;
9370 : 0 : ret = parse_int(ctx, token, str, len, NULL, 0);
9371 : 0 : if (ret < 0) {
9372 : : pop_args(ctx);
9373 : 0 : return -1;
9374 : : }
9375 : 0 : ++i;
9376 : 0 : ctx->objdata = i << 16 | (ctx->objdata & 0xffff);
9377 : : /* Repeat token. */
9378 : 0 : if (ctx->next_num == RTE_DIM(ctx->next))
9379 : : return -1;
9380 : 0 : ctx->next[ctx->next_num++] = NEXT_ENTRY(ACTION_RSS_QUEUE);
9381 : 0 : end:
9382 : 0 : if (!ctx->object)
9383 : 0 : return len;
9384 : : action_rss_data = ctx->object;
9385 : 0 : action_rss_data->conf.queue_num = i;
9386 : 0 : action_rss_data->conf.queue = i ? action_rss_data->queue : NULL;
9387 : 0 : return len;
9388 : : }
9389 : :
9390 : : /** Setup VXLAN encap configuration. */
9391 : : static int
9392 : 0 : parse_setup_vxlan_encap_data(struct action_vxlan_encap_data *action_vxlan_encap_data)
9393 : : {
9394 : : /* Set up default configuration. */
9395 : 0 : *action_vxlan_encap_data = (struct action_vxlan_encap_data){
9396 : : .conf = (struct rte_flow_action_vxlan_encap){
9397 : 0 : .definition = action_vxlan_encap_data->items,
9398 : : },
9399 : : .items = {
9400 : : {
9401 : : .type = RTE_FLOW_ITEM_TYPE_ETH,
9402 : 0 : .spec = &action_vxlan_encap_data->item_eth,
9403 : : .mask = &rte_flow_item_eth_mask,
9404 : : },
9405 : : {
9406 : : .type = RTE_FLOW_ITEM_TYPE_VLAN,
9407 : 0 : .spec = &action_vxlan_encap_data->item_vlan,
9408 : : .mask = &rte_flow_item_vlan_mask,
9409 : : },
9410 : : {
9411 : : .type = RTE_FLOW_ITEM_TYPE_IPV4,
9412 : 0 : .spec = &action_vxlan_encap_data->item_ipv4,
9413 : : .mask = &rte_flow_item_ipv4_mask,
9414 : : },
9415 : : {
9416 : : .type = RTE_FLOW_ITEM_TYPE_UDP,
9417 : 0 : .spec = &action_vxlan_encap_data->item_udp,
9418 : : .mask = &rte_flow_item_udp_mask,
9419 : : },
9420 : : {
9421 : : .type = RTE_FLOW_ITEM_TYPE_VXLAN,
9422 : 0 : .spec = &action_vxlan_encap_data->item_vxlan,
9423 : : .mask = &rte_flow_item_vxlan_mask,
9424 : : },
9425 : : {
9426 : : .type = RTE_FLOW_ITEM_TYPE_END,
9427 : : },
9428 : : },
9429 : : .item_eth.hdr.ether_type = 0,
9430 : : .item_vlan = {
9431 : 0 : .hdr.vlan_tci = vxlan_encap_conf.vlan_tci,
9432 : : .hdr.eth_proto = 0,
9433 : : },
9434 : : .item_ipv4.hdr = {
9435 : 0 : .src_addr = vxlan_encap_conf.ipv4_src,
9436 : 0 : .dst_addr = vxlan_encap_conf.ipv4_dst,
9437 : : },
9438 : : .item_udp.hdr = {
9439 : 0 : .src_port = vxlan_encap_conf.udp_src,
9440 : 0 : .dst_port = vxlan_encap_conf.udp_dst,
9441 : : },
9442 : : .item_vxlan.hdr.flags = 0,
9443 : : };
9444 : 0 : memcpy(action_vxlan_encap_data->item_eth.hdr.dst_addr.addr_bytes,
9445 : : vxlan_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
9446 : 0 : memcpy(action_vxlan_encap_data->item_eth.hdr.src_addr.addr_bytes,
9447 : : vxlan_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
9448 : 0 : if (!vxlan_encap_conf.select_ipv4) {
9449 : 0 : memcpy(&action_vxlan_encap_data->item_ipv6.hdr.src_addr,
9450 : : &vxlan_encap_conf.ipv6_src,
9451 : : sizeof(vxlan_encap_conf.ipv6_src));
9452 : 0 : memcpy(&action_vxlan_encap_data->item_ipv6.hdr.dst_addr,
9453 : : &vxlan_encap_conf.ipv6_dst,
9454 : : sizeof(vxlan_encap_conf.ipv6_dst));
9455 : 0 : action_vxlan_encap_data->items[2] = (struct rte_flow_item){
9456 : : .type = RTE_FLOW_ITEM_TYPE_IPV6,
9457 : 0 : .spec = &action_vxlan_encap_data->item_ipv6,
9458 : : .mask = &rte_flow_item_ipv6_mask,
9459 : : };
9460 : : }
9461 : 0 : if (!vxlan_encap_conf.select_vlan)
9462 : 0 : action_vxlan_encap_data->items[1].type =
9463 : : RTE_FLOW_ITEM_TYPE_VOID;
9464 : 0 : if (vxlan_encap_conf.select_tos_ttl) {
9465 : 0 : if (vxlan_encap_conf.select_ipv4) {
9466 : : static struct rte_flow_item_ipv4 ipv4_mask_tos;
9467 : :
9468 : : memcpy(&ipv4_mask_tos, &rte_flow_item_ipv4_mask,
9469 : : sizeof(ipv4_mask_tos));
9470 : 0 : ipv4_mask_tos.hdr.type_of_service = 0xff;
9471 : 0 : ipv4_mask_tos.hdr.time_to_live = 0xff;
9472 : 0 : action_vxlan_encap_data->item_ipv4.hdr.type_of_service =
9473 : 0 : vxlan_encap_conf.ip_tos;
9474 : 0 : action_vxlan_encap_data->item_ipv4.hdr.time_to_live =
9475 : 0 : vxlan_encap_conf.ip_ttl;
9476 : 0 : action_vxlan_encap_data->items[2].mask =
9477 : : &ipv4_mask_tos;
9478 : : } else {
9479 : : static struct rte_flow_item_ipv6 ipv6_mask_tos;
9480 : :
9481 : : memcpy(&ipv6_mask_tos, &rte_flow_item_ipv6_mask,
9482 : : sizeof(ipv6_mask_tos));
9483 : 0 : ipv6_mask_tos.hdr.vtc_flow |=
9484 : : RTE_BE32(0xfful << RTE_IPV6_HDR_TC_SHIFT);
9485 : 0 : ipv6_mask_tos.hdr.hop_limits = 0xff;
9486 : 0 : action_vxlan_encap_data->item_ipv6.hdr.vtc_flow |=
9487 : 0 : rte_cpu_to_be_32
9488 : : ((uint32_t)vxlan_encap_conf.ip_tos <<
9489 : : RTE_IPV6_HDR_TC_SHIFT);
9490 : 0 : action_vxlan_encap_data->item_ipv6.hdr.hop_limits =
9491 : 0 : vxlan_encap_conf.ip_ttl;
9492 : 0 : action_vxlan_encap_data->items[2].mask =
9493 : : &ipv6_mask_tos;
9494 : : }
9495 : : }
9496 : 0 : memcpy(action_vxlan_encap_data->item_vxlan.hdr.vni, vxlan_encap_conf.vni,
9497 : : RTE_DIM(vxlan_encap_conf.vni));
9498 : 0 : return 0;
9499 : : }
9500 : :
9501 : : /** Parse VXLAN encap action. */
9502 : : static int
9503 : 0 : parse_vc_action_vxlan_encap(struct context *ctx, const struct token *token,
9504 : : const char *str, unsigned int len,
9505 : : void *buf, unsigned int size)
9506 : : {
9507 : : struct buffer *out = buf;
9508 : : struct rte_flow_action *action;
9509 : : struct action_vxlan_encap_data *action_vxlan_encap_data;
9510 : : int ret;
9511 : :
9512 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
9513 : 0 : if (ret < 0)
9514 : : return ret;
9515 : : /* Nothing else to do if there is no buffer. */
9516 : 0 : if (!out)
9517 : : return ret;
9518 : 0 : if (!out->args.vc.actions_n)
9519 : : return -1;
9520 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
9521 : : /* Point to selected object. */
9522 : 0 : ctx->object = out->args.vc.data;
9523 : 0 : ctx->objmask = NULL;
9524 : : action_vxlan_encap_data = ctx->object;
9525 : 0 : parse_setup_vxlan_encap_data(action_vxlan_encap_data);
9526 : 0 : action->conf = &action_vxlan_encap_data->conf;
9527 : 0 : return ret;
9528 : : }
9529 : :
9530 : : /** Setup NVGRE encap configuration. */
9531 : : static int
9532 : 0 : parse_setup_nvgre_encap_data(struct action_nvgre_encap_data *action_nvgre_encap_data)
9533 : : {
9534 : : /* Set up default configuration. */
9535 : 0 : *action_nvgre_encap_data = (struct action_nvgre_encap_data){
9536 : : .conf = (struct rte_flow_action_nvgre_encap){
9537 : 0 : .definition = action_nvgre_encap_data->items,
9538 : : },
9539 : : .items = {
9540 : : {
9541 : : .type = RTE_FLOW_ITEM_TYPE_ETH,
9542 : 0 : .spec = &action_nvgre_encap_data->item_eth,
9543 : : .mask = &rte_flow_item_eth_mask,
9544 : : },
9545 : : {
9546 : : .type = RTE_FLOW_ITEM_TYPE_VLAN,
9547 : 0 : .spec = &action_nvgre_encap_data->item_vlan,
9548 : : .mask = &rte_flow_item_vlan_mask,
9549 : : },
9550 : : {
9551 : : .type = RTE_FLOW_ITEM_TYPE_IPV4,
9552 : 0 : .spec = &action_nvgre_encap_data->item_ipv4,
9553 : : .mask = &rte_flow_item_ipv4_mask,
9554 : : },
9555 : : {
9556 : : .type = RTE_FLOW_ITEM_TYPE_NVGRE,
9557 : 0 : .spec = &action_nvgre_encap_data->item_nvgre,
9558 : : .mask = &rte_flow_item_nvgre_mask,
9559 : : },
9560 : : {
9561 : : .type = RTE_FLOW_ITEM_TYPE_END,
9562 : : },
9563 : : },
9564 : : .item_eth.hdr.ether_type = 0,
9565 : : .item_vlan = {
9566 : 0 : .hdr.vlan_tci = nvgre_encap_conf.vlan_tci,
9567 : : .hdr.eth_proto = 0,
9568 : : },
9569 : : .item_ipv4.hdr = {
9570 : 0 : .src_addr = nvgre_encap_conf.ipv4_src,
9571 : 0 : .dst_addr = nvgre_encap_conf.ipv4_dst,
9572 : : },
9573 : : .item_nvgre.c_k_s_rsvd0_ver = RTE_BE16(0x2000),
9574 : : .item_nvgre.protocol = RTE_BE16(RTE_ETHER_TYPE_TEB),
9575 : : .item_nvgre.flow_id = 0,
9576 : : };
9577 : 0 : memcpy(action_nvgre_encap_data->item_eth.hdr.dst_addr.addr_bytes,
9578 : : nvgre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
9579 : 0 : memcpy(action_nvgre_encap_data->item_eth.hdr.src_addr.addr_bytes,
9580 : : nvgre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
9581 : 0 : if (!nvgre_encap_conf.select_ipv4) {
9582 : 0 : memcpy(&action_nvgre_encap_data->item_ipv6.hdr.src_addr,
9583 : : &nvgre_encap_conf.ipv6_src,
9584 : : sizeof(nvgre_encap_conf.ipv6_src));
9585 : 0 : memcpy(&action_nvgre_encap_data->item_ipv6.hdr.dst_addr,
9586 : : &nvgre_encap_conf.ipv6_dst,
9587 : : sizeof(nvgre_encap_conf.ipv6_dst));
9588 : 0 : action_nvgre_encap_data->items[2] = (struct rte_flow_item){
9589 : : .type = RTE_FLOW_ITEM_TYPE_IPV6,
9590 : 0 : .spec = &action_nvgre_encap_data->item_ipv6,
9591 : : .mask = &rte_flow_item_ipv6_mask,
9592 : : };
9593 : : }
9594 : 0 : if (!nvgre_encap_conf.select_vlan)
9595 : 0 : action_nvgre_encap_data->items[1].type =
9596 : : RTE_FLOW_ITEM_TYPE_VOID;
9597 : 0 : memcpy(action_nvgre_encap_data->item_nvgre.tni, nvgre_encap_conf.tni,
9598 : : RTE_DIM(nvgre_encap_conf.tni));
9599 : 0 : return 0;
9600 : : }
9601 : :
9602 : : /** Parse NVGRE encap action. */
9603 : : static int
9604 : 0 : parse_vc_action_nvgre_encap(struct context *ctx, const struct token *token,
9605 : : const char *str, unsigned int len,
9606 : : void *buf, unsigned int size)
9607 : : {
9608 : : struct buffer *out = buf;
9609 : : struct rte_flow_action *action;
9610 : : struct action_nvgre_encap_data *action_nvgre_encap_data;
9611 : : int ret;
9612 : :
9613 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
9614 : 0 : if (ret < 0)
9615 : : return ret;
9616 : : /* Nothing else to do if there is no buffer. */
9617 : 0 : if (!out)
9618 : : return ret;
9619 : 0 : if (!out->args.vc.actions_n)
9620 : : return -1;
9621 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
9622 : : /* Point to selected object. */
9623 : 0 : ctx->object = out->args.vc.data;
9624 : 0 : ctx->objmask = NULL;
9625 : : action_nvgre_encap_data = ctx->object;
9626 : 0 : parse_setup_nvgre_encap_data(action_nvgre_encap_data);
9627 : 0 : action->conf = &action_nvgre_encap_data->conf;
9628 : 0 : return ret;
9629 : : }
9630 : :
9631 : : /** Parse l2 encap action. */
9632 : : static int
9633 : 0 : parse_vc_action_l2_encap(struct context *ctx, const struct token *token,
9634 : : const char *str, unsigned int len,
9635 : : void *buf, unsigned int size)
9636 : : {
9637 : : struct buffer *out = buf;
9638 : : struct rte_flow_action *action;
9639 : : struct action_raw_encap_data *action_encap_data;
9640 : 0 : struct rte_flow_item_eth eth = { .hdr.ether_type = 0, };
9641 : 0 : struct rte_flow_item_vlan vlan = {
9642 : 0 : .hdr.vlan_tci = mplsoudp_encap_conf.vlan_tci,
9643 : : .hdr.eth_proto = 0,
9644 : : };
9645 : : uint8_t *header;
9646 : : int ret;
9647 : :
9648 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
9649 : 0 : if (ret < 0)
9650 : : return ret;
9651 : : /* Nothing else to do if there is no buffer. */
9652 : 0 : if (!out)
9653 : : return ret;
9654 : 0 : if (!out->args.vc.actions_n)
9655 : : return -1;
9656 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
9657 : : /* Point to selected object. */
9658 : 0 : ctx->object = out->args.vc.data;
9659 : 0 : ctx->objmask = NULL;
9660 : : /* Copy the headers to the buffer. */
9661 : : action_encap_data = ctx->object;
9662 : 0 : *action_encap_data = (struct action_raw_encap_data) {
9663 : : .conf = (struct rte_flow_action_raw_encap){
9664 : 0 : .data = action_encap_data->data,
9665 : : },
9666 : : .data = {},
9667 : : };
9668 : : header = action_encap_data->data;
9669 : 0 : if (l2_encap_conf.select_vlan)
9670 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
9671 : 0 : else if (l2_encap_conf.select_ipv4)
9672 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
9673 : : else
9674 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
9675 : : memcpy(eth.hdr.dst_addr.addr_bytes,
9676 : : l2_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
9677 : : memcpy(eth.hdr.src_addr.addr_bytes,
9678 : : l2_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
9679 : : memcpy(header, ð.hdr, sizeof(struct rte_ether_hdr));
9680 : 0 : header += sizeof(struct rte_ether_hdr);
9681 : 0 : if (l2_encap_conf.select_vlan) {
9682 : 0 : if (l2_encap_conf.select_ipv4)
9683 : 0 : vlan.hdr.eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
9684 : : else
9685 : 0 : vlan.hdr.eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
9686 : : memcpy(header, &vlan.hdr, sizeof(struct rte_vlan_hdr));
9687 : 0 : header += sizeof(struct rte_vlan_hdr);
9688 : : }
9689 : 0 : action_encap_data->conf.size = header -
9690 : : action_encap_data->data;
9691 : 0 : action->conf = &action_encap_data->conf;
9692 : 0 : return ret;
9693 : : }
9694 : :
9695 : : /** Parse l2 decap action. */
9696 : : static int
9697 : 0 : parse_vc_action_l2_decap(struct context *ctx, const struct token *token,
9698 : : const char *str, unsigned int len,
9699 : : void *buf, unsigned int size)
9700 : : {
9701 : : struct buffer *out = buf;
9702 : : struct rte_flow_action *action;
9703 : : struct action_raw_decap_data *action_decap_data;
9704 : 0 : struct rte_flow_item_eth eth = { .hdr.ether_type = 0, };
9705 : 0 : struct rte_flow_item_vlan vlan = {
9706 : 0 : .hdr.vlan_tci = mplsoudp_encap_conf.vlan_tci,
9707 : : .hdr.eth_proto = 0,
9708 : : };
9709 : : uint8_t *header;
9710 : : int ret;
9711 : :
9712 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
9713 : 0 : if (ret < 0)
9714 : : return ret;
9715 : : /* Nothing else to do if there is no buffer. */
9716 : 0 : if (!out)
9717 : : return ret;
9718 : 0 : if (!out->args.vc.actions_n)
9719 : : return -1;
9720 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
9721 : : /* Point to selected object. */
9722 : 0 : ctx->object = out->args.vc.data;
9723 : 0 : ctx->objmask = NULL;
9724 : : /* Copy the headers to the buffer. */
9725 : : action_decap_data = ctx->object;
9726 : 0 : *action_decap_data = (struct action_raw_decap_data) {
9727 : : .conf = (struct rte_flow_action_raw_decap){
9728 : 0 : .data = action_decap_data->data,
9729 : : },
9730 : : .data = {},
9731 : : };
9732 : : header = action_decap_data->data;
9733 : 0 : if (l2_decap_conf.select_vlan)
9734 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
9735 : : memcpy(header, ð.hdr, sizeof(struct rte_ether_hdr));
9736 : 0 : header += sizeof(struct rte_ether_hdr);
9737 : 0 : if (l2_decap_conf.select_vlan) {
9738 : : memcpy(header, &vlan.hdr, sizeof(struct rte_vlan_hdr));
9739 : 0 : header += sizeof(struct rte_vlan_hdr);
9740 : : }
9741 : 0 : action_decap_data->conf.size = header -
9742 : : action_decap_data->data;
9743 : 0 : action->conf = &action_decap_data->conf;
9744 : 0 : return ret;
9745 : : }
9746 : :
9747 : : #define ETHER_TYPE_MPLS_UNICAST 0x8847
9748 : :
9749 : : /** Parse MPLSOGRE encap action. */
9750 : : static int
9751 : 0 : parse_vc_action_mplsogre_encap(struct context *ctx, const struct token *token,
9752 : : const char *str, unsigned int len,
9753 : : void *buf, unsigned int size)
9754 : : {
9755 : : struct buffer *out = buf;
9756 : : struct rte_flow_action *action;
9757 : : struct action_raw_encap_data *action_encap_data;
9758 : 0 : struct rte_flow_item_eth eth = { .hdr.ether_type = 0, };
9759 : 0 : struct rte_flow_item_vlan vlan = {
9760 : 0 : .hdr.vlan_tci = mplsogre_encap_conf.vlan_tci,
9761 : : .hdr.eth_proto = 0,
9762 : : };
9763 : 0 : struct rte_flow_item_ipv4 ipv4 = {
9764 : : .hdr = {
9765 : 0 : .src_addr = mplsogre_encap_conf.ipv4_src,
9766 : 0 : .dst_addr = mplsogre_encap_conf.ipv4_dst,
9767 : : .next_proto_id = IPPROTO_GRE,
9768 : : .version_ihl = RTE_IPV4_VHL_DEF,
9769 : : .time_to_live = IPDEFTTL,
9770 : : },
9771 : : };
9772 : 0 : struct rte_flow_item_ipv6 ipv6 = {
9773 : : .hdr = {
9774 : : .proto = IPPROTO_GRE,
9775 : : .hop_limits = IPDEFTTL,
9776 : : },
9777 : : };
9778 : 0 : struct rte_flow_item_gre gre = {
9779 : : .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
9780 : : };
9781 : 0 : struct rte_flow_item_mpls mpls = {
9782 : : .ttl = 0,
9783 : : };
9784 : : uint8_t *header;
9785 : : int ret;
9786 : :
9787 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
9788 : 0 : if (ret < 0)
9789 : : return ret;
9790 : : /* Nothing else to do if there is no buffer. */
9791 : 0 : if (!out)
9792 : : return ret;
9793 : 0 : if (!out->args.vc.actions_n)
9794 : : return -1;
9795 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
9796 : : /* Point to selected object. */
9797 : 0 : ctx->object = out->args.vc.data;
9798 : 0 : ctx->objmask = NULL;
9799 : : /* Copy the headers to the buffer. */
9800 : : action_encap_data = ctx->object;
9801 : 0 : *action_encap_data = (struct action_raw_encap_data) {
9802 : : .conf = (struct rte_flow_action_raw_encap){
9803 : 0 : .data = action_encap_data->data,
9804 : : },
9805 : : .data = {},
9806 : : .preserve = {},
9807 : : };
9808 : : header = action_encap_data->data;
9809 : 0 : if (mplsogre_encap_conf.select_vlan)
9810 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
9811 : 0 : else if (mplsogre_encap_conf.select_ipv4)
9812 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
9813 : : else
9814 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
9815 : : memcpy(eth.hdr.dst_addr.addr_bytes,
9816 : : mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
9817 : : memcpy(eth.hdr.src_addr.addr_bytes,
9818 : : mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
9819 : : memcpy(header, ð.hdr, sizeof(struct rte_ether_hdr));
9820 : 0 : header += sizeof(struct rte_ether_hdr);
9821 : 0 : if (mplsogre_encap_conf.select_vlan) {
9822 : 0 : if (mplsogre_encap_conf.select_ipv4)
9823 : 0 : vlan.hdr.eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
9824 : : else
9825 : 0 : vlan.hdr.eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
9826 : : memcpy(header, &vlan.hdr, sizeof(struct rte_vlan_hdr));
9827 : 0 : header += sizeof(struct rte_vlan_hdr);
9828 : : }
9829 : 0 : if (mplsogre_encap_conf.select_ipv4) {
9830 : : memcpy(header, &ipv4, sizeof(ipv4));
9831 : 0 : header += sizeof(ipv4);
9832 : : } else {
9833 : : memcpy(&ipv6.hdr.src_addr,
9834 : : &mplsogre_encap_conf.ipv6_src,
9835 : : sizeof(mplsogre_encap_conf.ipv6_src));
9836 : : memcpy(&ipv6.hdr.dst_addr,
9837 : : &mplsogre_encap_conf.ipv6_dst,
9838 : : sizeof(mplsogre_encap_conf.ipv6_dst));
9839 : : memcpy(header, &ipv6, sizeof(ipv6));
9840 : 0 : header += sizeof(ipv6);
9841 : : }
9842 : : memcpy(header, &gre, sizeof(gre));
9843 : 0 : header += sizeof(gre);
9844 : : memcpy(mpls.label_tc_s, mplsogre_encap_conf.label,
9845 : : RTE_DIM(mplsogre_encap_conf.label));
9846 : 0 : mpls.label_tc_s[2] |= 0x1;
9847 : : memcpy(header, &mpls, sizeof(mpls));
9848 : 0 : header += sizeof(mpls);
9849 : 0 : action_encap_data->conf.size = header -
9850 : : action_encap_data->data;
9851 : 0 : action->conf = &action_encap_data->conf;
9852 : 0 : return ret;
9853 : : }
9854 : :
9855 : : /** Parse MPLSOGRE decap action. */
9856 : : static int
9857 : 0 : parse_vc_action_mplsogre_decap(struct context *ctx, const struct token *token,
9858 : : const char *str, unsigned int len,
9859 : : void *buf, unsigned int size)
9860 : : {
9861 : : struct buffer *out = buf;
9862 : : struct rte_flow_action *action;
9863 : : struct action_raw_decap_data *action_decap_data;
9864 : 0 : struct rte_flow_item_eth eth = { .hdr.ether_type = 0, };
9865 : 0 : struct rte_flow_item_vlan vlan = {.hdr.vlan_tci = 0};
9866 : 0 : struct rte_flow_item_ipv4 ipv4 = {
9867 : : .hdr = {
9868 : : .next_proto_id = IPPROTO_GRE,
9869 : : },
9870 : : };
9871 : 0 : struct rte_flow_item_ipv6 ipv6 = {
9872 : : .hdr = {
9873 : : .proto = IPPROTO_GRE,
9874 : : },
9875 : : };
9876 : 0 : struct rte_flow_item_gre gre = {
9877 : : .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
9878 : : };
9879 : : struct rte_flow_item_mpls mpls;
9880 : : uint8_t *header;
9881 : : int ret;
9882 : :
9883 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
9884 : 0 : if (ret < 0)
9885 : : return ret;
9886 : : /* Nothing else to do if there is no buffer. */
9887 : 0 : if (!out)
9888 : : return ret;
9889 : 0 : if (!out->args.vc.actions_n)
9890 : : return -1;
9891 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
9892 : : /* Point to selected object. */
9893 : 0 : ctx->object = out->args.vc.data;
9894 : 0 : ctx->objmask = NULL;
9895 : : /* Copy the headers to the buffer. */
9896 : : action_decap_data = ctx->object;
9897 : 0 : *action_decap_data = (struct action_raw_decap_data) {
9898 : : .conf = (struct rte_flow_action_raw_decap){
9899 : 0 : .data = action_decap_data->data,
9900 : : },
9901 : : .data = {},
9902 : : };
9903 : : header = action_decap_data->data;
9904 : 0 : if (mplsogre_decap_conf.select_vlan)
9905 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
9906 : 0 : else if (mplsogre_encap_conf.select_ipv4)
9907 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
9908 : : else
9909 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
9910 : : memcpy(eth.hdr.dst_addr.addr_bytes,
9911 : : mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
9912 : : memcpy(eth.hdr.src_addr.addr_bytes,
9913 : : mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
9914 : : memcpy(header, ð.hdr, sizeof(struct rte_ether_hdr));
9915 : 0 : header += sizeof(struct rte_ether_hdr);
9916 : 0 : if (mplsogre_encap_conf.select_vlan) {
9917 : 0 : if (mplsogre_encap_conf.select_ipv4)
9918 : 0 : vlan.hdr.eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
9919 : : else
9920 : 0 : vlan.hdr.eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
9921 : : memcpy(header, &vlan.hdr, sizeof(struct rte_vlan_hdr));
9922 : 0 : header += sizeof(struct rte_vlan_hdr);
9923 : : }
9924 : 0 : if (mplsogre_encap_conf.select_ipv4) {
9925 : : memcpy(header, &ipv4, sizeof(ipv4));
9926 : 0 : header += sizeof(ipv4);
9927 : : } else {
9928 : : memcpy(header, &ipv6, sizeof(ipv6));
9929 : 0 : header += sizeof(ipv6);
9930 : : }
9931 : : memcpy(header, &gre, sizeof(gre));
9932 : 0 : header += sizeof(gre);
9933 : : memset(&mpls, 0, sizeof(mpls));
9934 : : memcpy(header, &mpls, sizeof(mpls));
9935 : 0 : header += sizeof(mpls);
9936 : 0 : action_decap_data->conf.size = header -
9937 : : action_decap_data->data;
9938 : 0 : action->conf = &action_decap_data->conf;
9939 : 0 : return ret;
9940 : : }
9941 : :
9942 : : /** Parse MPLSOUDP encap action. */
9943 : : static int
9944 : 0 : parse_vc_action_mplsoudp_encap(struct context *ctx, const struct token *token,
9945 : : const char *str, unsigned int len,
9946 : : void *buf, unsigned int size)
9947 : : {
9948 : : struct buffer *out = buf;
9949 : : struct rte_flow_action *action;
9950 : : struct action_raw_encap_data *action_encap_data;
9951 : 0 : struct rte_flow_item_eth eth = { .hdr.ether_type = 0, };
9952 : 0 : struct rte_flow_item_vlan vlan = {
9953 : 0 : .hdr.vlan_tci = mplsoudp_encap_conf.vlan_tci,
9954 : : .hdr.eth_proto = 0,
9955 : : };
9956 : 0 : struct rte_flow_item_ipv4 ipv4 = {
9957 : : .hdr = {
9958 : 0 : .src_addr = mplsoudp_encap_conf.ipv4_src,
9959 : 0 : .dst_addr = mplsoudp_encap_conf.ipv4_dst,
9960 : : .next_proto_id = IPPROTO_UDP,
9961 : : .version_ihl = RTE_IPV4_VHL_DEF,
9962 : : .time_to_live = IPDEFTTL,
9963 : : },
9964 : : };
9965 : 0 : struct rte_flow_item_ipv6 ipv6 = {
9966 : : .hdr = {
9967 : : .proto = IPPROTO_UDP,
9968 : : .hop_limits = IPDEFTTL,
9969 : : },
9970 : : };
9971 : 0 : struct rte_flow_item_udp udp = {
9972 : : .hdr = {
9973 : 0 : .src_port = mplsoudp_encap_conf.udp_src,
9974 : 0 : .dst_port = mplsoudp_encap_conf.udp_dst,
9975 : : },
9976 : : };
9977 : : struct rte_flow_item_mpls mpls;
9978 : : uint8_t *header;
9979 : : int ret;
9980 : :
9981 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
9982 : 0 : if (ret < 0)
9983 : : return ret;
9984 : : /* Nothing else to do if there is no buffer. */
9985 : 0 : if (!out)
9986 : : return ret;
9987 : 0 : if (!out->args.vc.actions_n)
9988 : : return -1;
9989 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
9990 : : /* Point to selected object. */
9991 : 0 : ctx->object = out->args.vc.data;
9992 : 0 : ctx->objmask = NULL;
9993 : : /* Copy the headers to the buffer. */
9994 : : action_encap_data = ctx->object;
9995 : 0 : *action_encap_data = (struct action_raw_encap_data) {
9996 : : .conf = (struct rte_flow_action_raw_encap){
9997 : 0 : .data = action_encap_data->data,
9998 : : },
9999 : : .data = {},
10000 : : .preserve = {},
10001 : : };
10002 : : header = action_encap_data->data;
10003 : 0 : if (mplsoudp_encap_conf.select_vlan)
10004 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
10005 : 0 : else if (mplsoudp_encap_conf.select_ipv4)
10006 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
10007 : : else
10008 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
10009 : : memcpy(eth.hdr.dst_addr.addr_bytes,
10010 : : mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
10011 : : memcpy(eth.hdr.src_addr.addr_bytes,
10012 : : mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
10013 : : memcpy(header, ð.hdr, sizeof(struct rte_ether_hdr));
10014 : 0 : header += sizeof(struct rte_ether_hdr);
10015 : 0 : if (mplsoudp_encap_conf.select_vlan) {
10016 : 0 : if (mplsoudp_encap_conf.select_ipv4)
10017 : 0 : vlan.hdr.eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
10018 : : else
10019 : 0 : vlan.hdr.eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
10020 : : memcpy(header, &vlan.hdr, sizeof(struct rte_vlan_hdr));
10021 : 0 : header += sizeof(struct rte_vlan_hdr);
10022 : : }
10023 : 0 : if (mplsoudp_encap_conf.select_ipv4) {
10024 : : memcpy(header, &ipv4, sizeof(ipv4));
10025 : 0 : header += sizeof(ipv4);
10026 : : } else {
10027 : : memcpy(&ipv6.hdr.src_addr,
10028 : : &mplsoudp_encap_conf.ipv6_src,
10029 : : sizeof(mplsoudp_encap_conf.ipv6_src));
10030 : : memcpy(&ipv6.hdr.dst_addr,
10031 : : &mplsoudp_encap_conf.ipv6_dst,
10032 : : sizeof(mplsoudp_encap_conf.ipv6_dst));
10033 : : memcpy(header, &ipv6, sizeof(ipv6));
10034 : 0 : header += sizeof(ipv6);
10035 : : }
10036 : : memcpy(header, &udp, sizeof(udp));
10037 : 0 : header += sizeof(udp);
10038 : : memcpy(mpls.label_tc_s, mplsoudp_encap_conf.label,
10039 : : RTE_DIM(mplsoudp_encap_conf.label));
10040 : 0 : mpls.label_tc_s[2] |= 0x1;
10041 : : memcpy(header, &mpls, sizeof(mpls));
10042 : 0 : header += sizeof(mpls);
10043 : 0 : action_encap_data->conf.size = header -
10044 : : action_encap_data->data;
10045 : 0 : action->conf = &action_encap_data->conf;
10046 : 0 : return ret;
10047 : : }
10048 : :
10049 : : /** Parse MPLSOUDP decap action. */
10050 : : static int
10051 : 0 : parse_vc_action_mplsoudp_decap(struct context *ctx, const struct token *token,
10052 : : const char *str, unsigned int len,
10053 : : void *buf, unsigned int size)
10054 : : {
10055 : : struct buffer *out = buf;
10056 : : struct rte_flow_action *action;
10057 : : struct action_raw_decap_data *action_decap_data;
10058 : 0 : struct rte_flow_item_eth eth = { .hdr.ether_type = 0, };
10059 : 0 : struct rte_flow_item_vlan vlan = {.hdr.vlan_tci = 0};
10060 : 0 : struct rte_flow_item_ipv4 ipv4 = {
10061 : : .hdr = {
10062 : : .next_proto_id = IPPROTO_UDP,
10063 : : },
10064 : : };
10065 : 0 : struct rte_flow_item_ipv6 ipv6 = {
10066 : : .hdr = {
10067 : : .proto = IPPROTO_UDP,
10068 : : },
10069 : : };
10070 : 0 : struct rte_flow_item_udp udp = {
10071 : : .hdr = {
10072 : : .dst_port = rte_cpu_to_be_16(6635),
10073 : : },
10074 : : };
10075 : : struct rte_flow_item_mpls mpls;
10076 : : uint8_t *header;
10077 : : int ret;
10078 : :
10079 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
10080 : 0 : if (ret < 0)
10081 : : return ret;
10082 : : /* Nothing else to do if there is no buffer. */
10083 : 0 : if (!out)
10084 : : return ret;
10085 : 0 : if (!out->args.vc.actions_n)
10086 : : return -1;
10087 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
10088 : : /* Point to selected object. */
10089 : 0 : ctx->object = out->args.vc.data;
10090 : 0 : ctx->objmask = NULL;
10091 : : /* Copy the headers to the buffer. */
10092 : : action_decap_data = ctx->object;
10093 : 0 : *action_decap_data = (struct action_raw_decap_data) {
10094 : : .conf = (struct rte_flow_action_raw_decap){
10095 : 0 : .data = action_decap_data->data,
10096 : : },
10097 : : .data = {},
10098 : : };
10099 : : header = action_decap_data->data;
10100 : 0 : if (mplsoudp_decap_conf.select_vlan)
10101 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
10102 : 0 : else if (mplsoudp_encap_conf.select_ipv4)
10103 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
10104 : : else
10105 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
10106 : : memcpy(eth.hdr.dst_addr.addr_bytes,
10107 : : mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
10108 : : memcpy(eth.hdr.src_addr.addr_bytes,
10109 : : mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
10110 : : memcpy(header, ð.hdr, sizeof(struct rte_ether_hdr));
10111 : 0 : header += sizeof(struct rte_ether_hdr);
10112 : 0 : if (mplsoudp_encap_conf.select_vlan) {
10113 : 0 : if (mplsoudp_encap_conf.select_ipv4)
10114 : 0 : vlan.hdr.eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
10115 : : else
10116 : 0 : vlan.hdr.eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
10117 : : memcpy(header, &vlan.hdr, sizeof(struct rte_vlan_hdr));
10118 : 0 : header += sizeof(struct rte_vlan_hdr);
10119 : : }
10120 : 0 : if (mplsoudp_encap_conf.select_ipv4) {
10121 : : memcpy(header, &ipv4, sizeof(ipv4));
10122 : 0 : header += sizeof(ipv4);
10123 : : } else {
10124 : : memcpy(header, &ipv6, sizeof(ipv6));
10125 : 0 : header += sizeof(ipv6);
10126 : : }
10127 : : memcpy(header, &udp, sizeof(udp));
10128 : 0 : header += sizeof(udp);
10129 : : memset(&mpls, 0, sizeof(mpls));
10130 : : memcpy(header, &mpls, sizeof(mpls));
10131 : 0 : header += sizeof(mpls);
10132 : 0 : action_decap_data->conf.size = header -
10133 : : action_decap_data->data;
10134 : 0 : action->conf = &action_decap_data->conf;
10135 : 0 : return ret;
10136 : : }
10137 : :
10138 : : static int
10139 : 0 : parse_vc_action_raw_decap_index(struct context *ctx, const struct token *token,
10140 : : const char *str, unsigned int len, void *buf,
10141 : : unsigned int size)
10142 : : {
10143 : : struct action_raw_decap_data *action_raw_decap_data;
10144 : : struct rte_flow_action *action;
10145 : : const struct arg *arg;
10146 : : struct buffer *out = buf;
10147 : : int ret;
10148 : : uint16_t idx;
10149 : :
10150 : : RTE_SET_USED(token);
10151 : : RTE_SET_USED(buf);
10152 : : RTE_SET_USED(size);
10153 : 0 : arg = ARGS_ENTRY_ARB_BOUNDED
10154 : : (offsetof(struct action_raw_decap_data, idx),
10155 : : sizeof(((struct action_raw_decap_data *)0)->idx),
10156 : : 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
10157 : : if (push_args(ctx, arg))
10158 : : return -1;
10159 : 0 : ret = parse_int(ctx, token, str, len, NULL, 0);
10160 : 0 : if (ret < 0) {
10161 : : pop_args(ctx);
10162 : 0 : return -1;
10163 : : }
10164 : 0 : if (!ctx->object)
10165 : 0 : return len;
10166 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
10167 : : action_raw_decap_data = ctx->object;
10168 : 0 : idx = action_raw_decap_data->idx;
10169 : 0 : action_raw_decap_data->conf.data = raw_decap_confs[idx].data;
10170 : 0 : action_raw_decap_data->conf.size = raw_decap_confs[idx].size;
10171 : 0 : action->conf = &action_raw_decap_data->conf;
10172 : 0 : return len;
10173 : : }
10174 : :
10175 : :
10176 : : static int
10177 : 0 : parse_vc_action_raw_encap_index(struct context *ctx, const struct token *token,
10178 : : const char *str, unsigned int len, void *buf,
10179 : : unsigned int size)
10180 : : {
10181 : : struct action_raw_encap_data *action_raw_encap_data;
10182 : : struct rte_flow_action *action;
10183 : : const struct arg *arg;
10184 : : struct buffer *out = buf;
10185 : : int ret;
10186 : : uint16_t idx;
10187 : :
10188 : : RTE_SET_USED(token);
10189 : : RTE_SET_USED(buf);
10190 : : RTE_SET_USED(size);
10191 : 0 : if (ctx->curr != ACTION_RAW_ENCAP_INDEX_VALUE)
10192 : : return -1;
10193 : 0 : arg = ARGS_ENTRY_ARB_BOUNDED
10194 : : (offsetof(struct action_raw_encap_data, idx),
10195 : : sizeof(((struct action_raw_encap_data *)0)->idx),
10196 : : 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
10197 : : if (push_args(ctx, arg))
10198 : : return -1;
10199 : 0 : ret = parse_int(ctx, token, str, len, NULL, 0);
10200 : 0 : if (ret < 0) {
10201 : : pop_args(ctx);
10202 : 0 : return -1;
10203 : : }
10204 : 0 : if (!ctx->object)
10205 : 0 : return len;
10206 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
10207 : : action_raw_encap_data = ctx->object;
10208 : 0 : idx = action_raw_encap_data->idx;
10209 : 0 : action_raw_encap_data->conf.data = raw_encap_confs[idx].data;
10210 : 0 : action_raw_encap_data->conf.size = raw_encap_confs[idx].size;
10211 : 0 : action_raw_encap_data->conf.preserve = NULL;
10212 : 0 : action->conf = &action_raw_encap_data->conf;
10213 : 0 : return len;
10214 : : }
10215 : :
10216 : : static int
10217 : 0 : parse_vc_action_raw_encap(struct context *ctx, const struct token *token,
10218 : : const char *str, unsigned int len, void *buf,
10219 : : unsigned int size)
10220 : : {
10221 : : struct buffer *out = buf;
10222 : : int ret;
10223 : :
10224 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
10225 : 0 : if (ret < 0)
10226 : : return ret;
10227 : : /* Nothing else to do if there is no buffer. */
10228 : 0 : if (!out)
10229 : : return ret;
10230 : 0 : if (!out->args.vc.actions_n)
10231 : : return -1;
10232 : : /* Point to selected object. */
10233 : 0 : ctx->object = out->args.vc.data;
10234 : 0 : ctx->objmask = NULL;
10235 : 0 : return ret;
10236 : : }
10237 : :
10238 : : static int
10239 : 0 : parse_vc_action_raw_decap(struct context *ctx, const struct token *token,
10240 : : const char *str, unsigned int len, void *buf,
10241 : : unsigned int size)
10242 : : {
10243 : : struct buffer *out = buf;
10244 : : struct rte_flow_action *action;
10245 : : struct action_raw_decap_data *action_raw_decap_data = NULL;
10246 : : int ret;
10247 : :
10248 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
10249 : 0 : if (ret < 0)
10250 : : return ret;
10251 : : /* Nothing else to do if there is no buffer. */
10252 : 0 : if (!out)
10253 : : return ret;
10254 : 0 : if (!out->args.vc.actions_n)
10255 : : return -1;
10256 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
10257 : : /* Point to selected object. */
10258 : 0 : ctx->object = out->args.vc.data;
10259 : 0 : ctx->objmask = NULL;
10260 : : /* Copy the headers to the buffer. */
10261 : : action_raw_decap_data = ctx->object;
10262 : 0 : action_raw_decap_data->conf.data = raw_decap_confs[0].data;
10263 : 0 : action_raw_decap_data->conf.size = raw_decap_confs[0].size;
10264 : 0 : action->conf = &action_raw_decap_data->conf;
10265 : 0 : return ret;
10266 : : }
10267 : :
10268 : : static int
10269 : 0 : parse_vc_action_ipv6_ext_remove(struct context *ctx, const struct token *token,
10270 : : const char *str, unsigned int len, void *buf,
10271 : : unsigned int size)
10272 : : {
10273 : : struct buffer *out = buf;
10274 : : struct rte_flow_action *action;
10275 : : struct action_ipv6_ext_remove_data *ipv6_ext_remove_data = NULL;
10276 : : int ret;
10277 : :
10278 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
10279 : 0 : if (ret < 0)
10280 : : return ret;
10281 : : /* Nothing else to do if there is no buffer. */
10282 : 0 : if (!out)
10283 : : return ret;
10284 : 0 : if (!out->args.vc.actions_n)
10285 : : return -1;
10286 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
10287 : : /* Point to selected object. */
10288 : 0 : ctx->object = out->args.vc.data;
10289 : 0 : ctx->objmask = NULL;
10290 : : /* Copy the headers to the buffer. */
10291 : : ipv6_ext_remove_data = ctx->object;
10292 : 0 : ipv6_ext_remove_data->conf.type = ipv6_ext_remove_confs[0].type;
10293 : 0 : action->conf = &ipv6_ext_remove_data->conf;
10294 : 0 : return ret;
10295 : : }
10296 : :
10297 : : static int
10298 : 0 : parse_vc_action_ipv6_ext_remove_index(struct context *ctx, const struct token *token,
10299 : : const char *str, unsigned int len, void *buf,
10300 : : unsigned int size)
10301 : : {
10302 : : struct action_ipv6_ext_remove_data *action_ipv6_ext_remove_data;
10303 : : struct rte_flow_action *action;
10304 : : const struct arg *arg;
10305 : : struct buffer *out = buf;
10306 : : int ret;
10307 : : uint16_t idx;
10308 : :
10309 : : RTE_SET_USED(token);
10310 : : RTE_SET_USED(buf);
10311 : : RTE_SET_USED(size);
10312 : 0 : arg = ARGS_ENTRY_ARB_BOUNDED
10313 : : (offsetof(struct action_ipv6_ext_remove_data, idx),
10314 : : sizeof(((struct action_ipv6_ext_remove_data *)0)->idx),
10315 : : 0, IPV6_EXT_PUSH_CONFS_MAX_NUM - 1);
10316 : : if (push_args(ctx, arg))
10317 : : return -1;
10318 : 0 : ret = parse_int(ctx, token, str, len, NULL, 0);
10319 : 0 : if (ret < 0) {
10320 : : pop_args(ctx);
10321 : 0 : return -1;
10322 : : }
10323 : 0 : if (!ctx->object)
10324 : 0 : return len;
10325 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
10326 : : action_ipv6_ext_remove_data = ctx->object;
10327 : 0 : idx = action_ipv6_ext_remove_data->idx;
10328 : 0 : action_ipv6_ext_remove_data->conf.type = ipv6_ext_remove_confs[idx].type;
10329 : 0 : action->conf = &action_ipv6_ext_remove_data->conf;
10330 : 0 : return len;
10331 : : }
10332 : :
10333 : : static int
10334 : 0 : parse_vc_action_ipv6_ext_push(struct context *ctx, const struct token *token,
10335 : : const char *str, unsigned int len, void *buf,
10336 : : unsigned int size)
10337 : : {
10338 : : struct buffer *out = buf;
10339 : : struct rte_flow_action *action;
10340 : : struct action_ipv6_ext_push_data *ipv6_ext_push_data = NULL;
10341 : : int ret;
10342 : :
10343 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
10344 : 0 : if (ret < 0)
10345 : : return ret;
10346 : : /* Nothing else to do if there is no buffer. */
10347 : 0 : if (!out)
10348 : : return ret;
10349 : 0 : if (!out->args.vc.actions_n)
10350 : : return -1;
10351 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
10352 : : /* Point to selected object. */
10353 : 0 : ctx->object = out->args.vc.data;
10354 : 0 : ctx->objmask = NULL;
10355 : : /* Copy the headers to the buffer. */
10356 : : ipv6_ext_push_data = ctx->object;
10357 : 0 : ipv6_ext_push_data->conf.type = ipv6_ext_push_confs[0].type;
10358 : 0 : ipv6_ext_push_data->conf.data = ipv6_ext_push_confs[0].data;
10359 : 0 : ipv6_ext_push_data->conf.size = ipv6_ext_push_confs[0].size;
10360 : 0 : action->conf = &ipv6_ext_push_data->conf;
10361 : 0 : return ret;
10362 : : }
10363 : :
10364 : : static int
10365 : 0 : parse_vc_action_ipv6_ext_push_index(struct context *ctx, const struct token *token,
10366 : : const char *str, unsigned int len, void *buf,
10367 : : unsigned int size)
10368 : : {
10369 : : struct action_ipv6_ext_push_data *action_ipv6_ext_push_data;
10370 : : struct rte_flow_action *action;
10371 : : const struct arg *arg;
10372 : : struct buffer *out = buf;
10373 : : int ret;
10374 : : uint16_t idx;
10375 : :
10376 : : RTE_SET_USED(token);
10377 : : RTE_SET_USED(buf);
10378 : : RTE_SET_USED(size);
10379 : 0 : arg = ARGS_ENTRY_ARB_BOUNDED
10380 : : (offsetof(struct action_ipv6_ext_push_data, idx),
10381 : : sizeof(((struct action_ipv6_ext_push_data *)0)->idx),
10382 : : 0, IPV6_EXT_PUSH_CONFS_MAX_NUM - 1);
10383 : : if (push_args(ctx, arg))
10384 : : return -1;
10385 : 0 : ret = parse_int(ctx, token, str, len, NULL, 0);
10386 : 0 : if (ret < 0) {
10387 : : pop_args(ctx);
10388 : 0 : return -1;
10389 : : }
10390 : 0 : if (!ctx->object)
10391 : 0 : return len;
10392 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
10393 : : action_ipv6_ext_push_data = ctx->object;
10394 : 0 : idx = action_ipv6_ext_push_data->idx;
10395 : 0 : action_ipv6_ext_push_data->conf.type = ipv6_ext_push_confs[idx].type;
10396 : 0 : action_ipv6_ext_push_data->conf.size = ipv6_ext_push_confs[idx].size;
10397 : 0 : action_ipv6_ext_push_data->conf.data = ipv6_ext_push_confs[idx].data;
10398 : 0 : action->conf = &action_ipv6_ext_push_data->conf;
10399 : 0 : return len;
10400 : : }
10401 : :
10402 : : static int
10403 : 0 : parse_vc_action_set_meta(struct context *ctx, const struct token *token,
10404 : : const char *str, unsigned int len, void *buf,
10405 : : unsigned int size)
10406 : : {
10407 : : int ret;
10408 : :
10409 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
10410 : 0 : if (ret < 0)
10411 : : return ret;
10412 : 0 : ret = rte_flow_dynf_metadata_register();
10413 : 0 : if (ret < 0)
10414 : : return -1;
10415 : 0 : return len;
10416 : : }
10417 : :
10418 : : static int
10419 : 0 : parse_vc_action_sample(struct context *ctx, const struct token *token,
10420 : : const char *str, unsigned int len, void *buf,
10421 : : unsigned int size)
10422 : : {
10423 : : struct buffer *out = buf;
10424 : : struct rte_flow_action *action;
10425 : : struct action_sample_data *action_sample_data = NULL;
10426 : : static struct rte_flow_action end_action = {
10427 : : RTE_FLOW_ACTION_TYPE_END, 0
10428 : : };
10429 : : int ret;
10430 : :
10431 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
10432 : 0 : if (ret < 0)
10433 : : return ret;
10434 : : /* Nothing else to do if there is no buffer. */
10435 : 0 : if (!out)
10436 : : return ret;
10437 : 0 : if (!out->args.vc.actions_n)
10438 : : return -1;
10439 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
10440 : : /* Point to selected object. */
10441 : 0 : ctx->object = out->args.vc.data;
10442 : 0 : ctx->objmask = NULL;
10443 : : /* Copy the headers to the buffer. */
10444 : : action_sample_data = ctx->object;
10445 : 0 : action_sample_data->conf.actions = &end_action;
10446 : 0 : action->conf = &action_sample_data->conf;
10447 : 0 : return ret;
10448 : : }
10449 : :
10450 : : static int
10451 : 0 : parse_vc_action_sample_index(struct context *ctx, const struct token *token,
10452 : : const char *str, unsigned int len, void *buf,
10453 : : unsigned int size)
10454 : : {
10455 : : struct action_sample_data *action_sample_data;
10456 : : struct rte_flow_action *action;
10457 : : const struct arg *arg;
10458 : : struct buffer *out = buf;
10459 : : int ret;
10460 : : uint16_t idx;
10461 : :
10462 : : RTE_SET_USED(token);
10463 : : RTE_SET_USED(buf);
10464 : : RTE_SET_USED(size);
10465 : 0 : if (ctx->curr != ACTION_SAMPLE_INDEX_VALUE)
10466 : : return -1;
10467 : 0 : arg = ARGS_ENTRY_ARB_BOUNDED
10468 : : (offsetof(struct action_sample_data, idx),
10469 : : sizeof(((struct action_sample_data *)0)->idx),
10470 : : 0, RAW_SAMPLE_CONFS_MAX_NUM - 1);
10471 : : if (push_args(ctx, arg))
10472 : : return -1;
10473 : 0 : ret = parse_int(ctx, token, str, len, NULL, 0);
10474 : 0 : if (ret < 0) {
10475 : : pop_args(ctx);
10476 : 0 : return -1;
10477 : : }
10478 : 0 : if (!ctx->object)
10479 : 0 : return len;
10480 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
10481 : : action_sample_data = ctx->object;
10482 : 0 : idx = action_sample_data->idx;
10483 : 0 : action_sample_data->conf.actions = raw_sample_confs[idx].data;
10484 : 0 : action->conf = &action_sample_data->conf;
10485 : 0 : return len;
10486 : : }
10487 : :
10488 : : /** Parse operation for modify_field command. */
10489 : : static int
10490 : 0 : parse_vc_modify_field_op(struct context *ctx, const struct token *token,
10491 : : const char *str, unsigned int len, void *buf,
10492 : : unsigned int size)
10493 : : {
10494 : : struct rte_flow_action_modify_field *action_modify_field;
10495 : : unsigned int i;
10496 : :
10497 : : (void)token;
10498 : : (void)buf;
10499 : : (void)size;
10500 : 0 : if (ctx->curr != ACTION_MODIFY_FIELD_OP_VALUE)
10501 : : return -1;
10502 : 0 : for (i = 0; modify_field_ops[i]; ++i)
10503 : 0 : if (!strcmp_partial(modify_field_ops[i], str, len))
10504 : : break;
10505 : 0 : if (!modify_field_ops[i])
10506 : : return -1;
10507 : 0 : if (!ctx->object)
10508 : 0 : return len;
10509 : : action_modify_field = ctx->object;
10510 : 0 : action_modify_field->operation = (enum rte_flow_modify_op)i;
10511 : 0 : return len;
10512 : : }
10513 : :
10514 : : /** Parse id for modify_field command. */
10515 : : static int
10516 : 0 : parse_vc_modify_field_id(struct context *ctx, const struct token *token,
10517 : : const char *str, unsigned int len, void *buf,
10518 : : unsigned int size)
10519 : : {
10520 : : struct rte_flow_action_modify_field *action_modify_field;
10521 : : unsigned int i;
10522 : :
10523 : : (void)token;
10524 : : (void)buf;
10525 : : (void)size;
10526 : 0 : if (ctx->curr != ACTION_MODIFY_FIELD_DST_TYPE_VALUE &&
10527 : : ctx->curr != ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)
10528 : : return -1;
10529 : 0 : for (i = 0; flow_field_ids[i]; ++i)
10530 : 0 : if (!strcmp_partial(flow_field_ids[i], str, len))
10531 : : break;
10532 : 0 : if (!flow_field_ids[i])
10533 : : return -1;
10534 : 0 : if (!ctx->object)
10535 : 0 : return len;
10536 : : action_modify_field = ctx->object;
10537 : 0 : if (ctx->curr == ACTION_MODIFY_FIELD_DST_TYPE_VALUE)
10538 : 0 : action_modify_field->dst.field = (enum rte_flow_field_id)i;
10539 : : else
10540 : 0 : action_modify_field->src.field = (enum rte_flow_field_id)i;
10541 : 0 : return len;
10542 : : }
10543 : :
10544 : : /** Parse level for modify_field command. */
10545 : : static int
10546 : 0 : parse_vc_modify_field_level(struct context *ctx, const struct token *token,
10547 : : const char *str, unsigned int len, void *buf,
10548 : : unsigned int size)
10549 : : {
10550 : : struct rte_flow_action_modify_field *action;
10551 : : struct flex_item *fp = NULL;
10552 : : uint32_t val;
10553 : : struct buffer *out = buf;
10554 : : char *end;
10555 : :
10556 : : (void)token;
10557 : : (void)size;
10558 : 0 : if (ctx->curr != ACTION_MODIFY_FIELD_DST_LEVEL_VALUE &&
10559 : : ctx->curr != ACTION_MODIFY_FIELD_SRC_LEVEL_VALUE)
10560 : : return -1;
10561 : 0 : if (!ctx->object)
10562 : 0 : return len;
10563 : : action = ctx->object;
10564 : 0 : errno = 0;
10565 : 0 : val = strtoumax(str, &end, 0);
10566 : 0 : if (errno || (size_t)(end - str) != len)
10567 : : return -1;
10568 : : /* No need to validate action template mask value */
10569 : 0 : if (out->args.vc.masks) {
10570 : 0 : if (ctx->curr == ACTION_MODIFY_FIELD_DST_LEVEL_VALUE)
10571 : 0 : action->dst.level = val;
10572 : : else
10573 : 0 : action->src.level = val;
10574 : 0 : return len;
10575 : : }
10576 : 0 : if ((ctx->curr == ACTION_MODIFY_FIELD_DST_LEVEL_VALUE &&
10577 : 0 : action->dst.field == RTE_FLOW_FIELD_FLEX_ITEM) ||
10578 : 0 : (ctx->curr == ACTION_MODIFY_FIELD_SRC_LEVEL_VALUE &&
10579 : 0 : action->src.field == RTE_FLOW_FIELD_FLEX_ITEM)) {
10580 : 0 : if (val >= FLEX_MAX_PARSERS_NUM) {
10581 : : printf("Bad flex item handle\n");
10582 : 0 : return -1;
10583 : : }
10584 : 0 : fp = flex_items[ctx->port][val];
10585 : 0 : if (!fp) {
10586 : : printf("Bad flex item handle\n");
10587 : 0 : return -1;
10588 : : }
10589 : : }
10590 : 0 : if (ctx->curr == ACTION_MODIFY_FIELD_DST_LEVEL_VALUE) {
10591 : 0 : if (action->dst.field != RTE_FLOW_FIELD_FLEX_ITEM)
10592 : 0 : action->dst.level = val;
10593 : : else
10594 : 0 : action->dst.flex_handle = fp->flex_handle;
10595 : 0 : } else if (ctx->curr == ACTION_MODIFY_FIELD_SRC_LEVEL_VALUE) {
10596 : 0 : if (action->src.field != RTE_FLOW_FIELD_FLEX_ITEM)
10597 : 0 : action->src.level = val;
10598 : : else
10599 : 0 : action->src.flex_handle = fp->flex_handle;
10600 : : }
10601 : 0 : return len;
10602 : : }
10603 : :
10604 : : /** Parse the conntrack update, not a rte_flow_action. */
10605 : : static int
10606 : 0 : parse_vc_action_conntrack_update(struct context *ctx, const struct token *token,
10607 : : const char *str, unsigned int len, void *buf,
10608 : : unsigned int size)
10609 : : {
10610 : : struct buffer *out = buf;
10611 : : struct rte_flow_modify_conntrack *ct_modify = NULL;
10612 : :
10613 : : (void)size;
10614 : 0 : if (ctx->curr != ACTION_CONNTRACK_UPDATE_CTX &&
10615 : : ctx->curr != ACTION_CONNTRACK_UPDATE_DIR)
10616 : : return -1;
10617 : : /* Token name must match. */
10618 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
10619 : : return -1;
10620 : : /* Nothing else to do if there is no buffer. */
10621 : 0 : if (!out)
10622 : : return len;
10623 : 0 : ct_modify = (struct rte_flow_modify_conntrack *)out->args.vc.data;
10624 : 0 : if (ctx->curr == ACTION_CONNTRACK_UPDATE_DIR) {
10625 : 0 : ct_modify->new_ct.is_original_dir =
10626 : 0 : conntrack_context.is_original_dir;
10627 : 0 : ct_modify->direction = 1;
10628 : : } else {
10629 : : uint32_t old_dir;
10630 : :
10631 : 0 : old_dir = ct_modify->new_ct.is_original_dir;
10632 : 0 : memcpy(&ct_modify->new_ct, &conntrack_context,
10633 : : sizeof(conntrack_context));
10634 : 0 : ct_modify->new_ct.is_original_dir = old_dir;
10635 : 0 : ct_modify->state = 1;
10636 : : }
10637 : : return len;
10638 : : }
10639 : :
10640 : : /** Parse tokens for destroy command. */
10641 : : static int
10642 : 0 : parse_destroy(struct context *ctx, const struct token *token,
10643 : : const char *str, unsigned int len,
10644 : : void *buf, unsigned int size)
10645 : : {
10646 : : struct buffer *out = buf;
10647 : :
10648 : : /* Token name must match. */
10649 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
10650 : : return -1;
10651 : : /* Nothing else to do if there is no buffer. */
10652 : 0 : if (!out)
10653 : : return len;
10654 : 0 : if (!out->command) {
10655 : 0 : if (ctx->curr != DESTROY)
10656 : : return -1;
10657 : 0 : if (sizeof(*out) > size)
10658 : : return -1;
10659 : 0 : out->command = ctx->curr;
10660 : 0 : ctx->objdata = 0;
10661 : 0 : ctx->object = out;
10662 : 0 : ctx->objmask = NULL;
10663 : 0 : out->args.destroy.rule =
10664 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
10665 : : sizeof(double));
10666 : 0 : return len;
10667 : : }
10668 : 0 : if (ctx->curr == DESTROY_IS_USER_ID) {
10669 : 0 : out->args.destroy.is_user_id = true;
10670 : 0 : return len;
10671 : : }
10672 : 0 : if (((uint8_t *)(out->args.destroy.rule + out->args.destroy.rule_n) +
10673 : 0 : sizeof(*out->args.destroy.rule)) > (uint8_t *)out + size)
10674 : : return -1;
10675 : 0 : ctx->objdata = 0;
10676 : 0 : ctx->object = out->args.destroy.rule + out->args.destroy.rule_n++;
10677 : 0 : ctx->objmask = NULL;
10678 : 0 : return len;
10679 : : }
10680 : :
10681 : : /** Parse tokens for flush command. */
10682 : : static int
10683 : 0 : parse_flush(struct context *ctx, const struct token *token,
10684 : : const char *str, unsigned int len,
10685 : : void *buf, unsigned int size)
10686 : : {
10687 : : struct buffer *out = buf;
10688 : :
10689 : : /* Token name must match. */
10690 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
10691 : : return -1;
10692 : : /* Nothing else to do if there is no buffer. */
10693 : 0 : if (!out)
10694 : : return len;
10695 : 0 : if (!out->command) {
10696 : 0 : if (ctx->curr != FLUSH)
10697 : : return -1;
10698 : 0 : if (sizeof(*out) > size)
10699 : : return -1;
10700 : 0 : out->command = ctx->curr;
10701 : 0 : ctx->objdata = 0;
10702 : 0 : ctx->object = out;
10703 : 0 : ctx->objmask = NULL;
10704 : : }
10705 : : return len;
10706 : : }
10707 : :
10708 : : /** Parse tokens for dump command. */
10709 : : static int
10710 : 0 : parse_dump(struct context *ctx, const struct token *token,
10711 : : const char *str, unsigned int len,
10712 : : void *buf, unsigned int size)
10713 : : {
10714 : : struct buffer *out = buf;
10715 : :
10716 : : /* Token name must match. */
10717 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
10718 : : return -1;
10719 : : /* Nothing else to do if there is no buffer. */
10720 : 0 : if (!out)
10721 : : return len;
10722 : 0 : if (!out->command) {
10723 : 0 : if (ctx->curr != DUMP)
10724 : : return -1;
10725 : 0 : if (sizeof(*out) > size)
10726 : : return -1;
10727 : 0 : out->command = ctx->curr;
10728 : 0 : ctx->objdata = 0;
10729 : 0 : ctx->object = out;
10730 : 0 : ctx->objmask = NULL;
10731 : 0 : return len;
10732 : : }
10733 : 0 : switch (ctx->curr) {
10734 : 0 : case DUMP_ALL:
10735 : : case DUMP_ONE:
10736 : 0 : out->args.dump.mode = (ctx->curr == DUMP_ALL) ? true : false;
10737 : 0 : out->command = ctx->curr;
10738 : 0 : ctx->objdata = 0;
10739 : 0 : ctx->object = out;
10740 : 0 : ctx->objmask = NULL;
10741 : 0 : return len;
10742 : 0 : case DUMP_IS_USER_ID:
10743 : 0 : out->args.dump.is_user_id = true;
10744 : 0 : return len;
10745 : : default:
10746 : : return -1;
10747 : : }
10748 : : }
10749 : :
10750 : : /** Parse tokens for query command. */
10751 : : static int
10752 : 0 : parse_query(struct context *ctx, const struct token *token,
10753 : : const char *str, unsigned int len,
10754 : : void *buf, unsigned int size)
10755 : : {
10756 : : struct buffer *out = buf;
10757 : :
10758 : : /* Token name must match. */
10759 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
10760 : : return -1;
10761 : : /* Nothing else to do if there is no buffer. */
10762 : 0 : if (!out)
10763 : : return len;
10764 : 0 : if (!out->command) {
10765 : 0 : if (ctx->curr != QUERY)
10766 : : return -1;
10767 : 0 : if (sizeof(*out) > size)
10768 : : return -1;
10769 : 0 : out->command = ctx->curr;
10770 : 0 : ctx->objdata = 0;
10771 : 0 : ctx->object = out;
10772 : 0 : ctx->objmask = NULL;
10773 : : }
10774 : 0 : if (ctx->curr == QUERY_IS_USER_ID) {
10775 : 0 : out->args.query.is_user_id = true;
10776 : 0 : return len;
10777 : : }
10778 : : return len;
10779 : : }
10780 : :
10781 : : /** Parse action names. */
10782 : : static int
10783 : 0 : parse_action(struct context *ctx, const struct token *token,
10784 : : const char *str, unsigned int len,
10785 : : void *buf, unsigned int size)
10786 : : {
10787 : : struct buffer *out = buf;
10788 : : const struct arg *arg = pop_args(ctx);
10789 : : unsigned int i;
10790 : :
10791 : : (void)size;
10792 : : /* Argument is expected. */
10793 : 0 : if (!arg)
10794 : 0 : return -1;
10795 : : /* Parse action name. */
10796 : 0 : for (i = 0; next_action[i]; ++i) {
10797 : : const struct parse_action_priv *priv;
10798 : :
10799 : : token = &token_list[next_action[i]];
10800 : 0 : if (strcmp_partial(token->name, str, len))
10801 : : continue;
10802 : 0 : priv = token->priv;
10803 : 0 : if (!priv)
10804 : 0 : goto error;
10805 : 0 : if (out)
10806 : 0 : memcpy((uint8_t *)ctx->object + arg->offset,
10807 : 0 : &priv->type,
10808 : 0 : arg->size);
10809 : 0 : return len;
10810 : : }
10811 : 0 : error:
10812 : : push_args(ctx, arg);
10813 : : return -1;
10814 : : }
10815 : :
10816 : : /** Parse tokens for list command. */
10817 : : static int
10818 : 0 : parse_list(struct context *ctx, const struct token *token,
10819 : : const char *str, unsigned int len,
10820 : : void *buf, unsigned int size)
10821 : : {
10822 : : struct buffer *out = buf;
10823 : :
10824 : : /* Token name must match. */
10825 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
10826 : : return -1;
10827 : : /* Nothing else to do if there is no buffer. */
10828 : 0 : if (!out)
10829 : : return len;
10830 : 0 : if (!out->command) {
10831 : 0 : if (ctx->curr != LIST)
10832 : : return -1;
10833 : 0 : if (sizeof(*out) > size)
10834 : : return -1;
10835 : 0 : out->command = ctx->curr;
10836 : 0 : ctx->objdata = 0;
10837 : 0 : ctx->object = out;
10838 : 0 : ctx->objmask = NULL;
10839 : 0 : out->args.list.group =
10840 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
10841 : : sizeof(double));
10842 : 0 : return len;
10843 : : }
10844 : 0 : if (((uint8_t *)(out->args.list.group + out->args.list.group_n) +
10845 : 0 : sizeof(*out->args.list.group)) > (uint8_t *)out + size)
10846 : : return -1;
10847 : 0 : ctx->objdata = 0;
10848 : 0 : ctx->object = out->args.list.group + out->args.list.group_n++;
10849 : 0 : ctx->objmask = NULL;
10850 : 0 : return len;
10851 : : }
10852 : :
10853 : : /** Parse tokens for list all aged flows command. */
10854 : : static int
10855 : 0 : parse_aged(struct context *ctx, const struct token *token,
10856 : : const char *str, unsigned int len,
10857 : : void *buf, unsigned int size)
10858 : : {
10859 : : struct buffer *out = buf;
10860 : :
10861 : : /* Token name must match. */
10862 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
10863 : : return -1;
10864 : : /* Nothing else to do if there is no buffer. */
10865 : 0 : if (!out)
10866 : : return len;
10867 : 0 : if (!out->command || out->command == QUEUE) {
10868 : 0 : if (ctx->curr != AGED && ctx->curr != QUEUE_AGED)
10869 : : return -1;
10870 : 0 : if (sizeof(*out) > size)
10871 : : return -1;
10872 : 0 : out->command = ctx->curr;
10873 : 0 : ctx->objdata = 0;
10874 : 0 : ctx->object = out;
10875 : 0 : ctx->objmask = NULL;
10876 : : }
10877 : 0 : if (ctx->curr == AGED_DESTROY)
10878 : 0 : out->args.aged.destroy = 1;
10879 : : return len;
10880 : : }
10881 : :
10882 : : /** Parse tokens for isolate command. */
10883 : : static int
10884 : 0 : parse_isolate(struct context *ctx, const struct token *token,
10885 : : const char *str, unsigned int len,
10886 : : void *buf, unsigned int size)
10887 : : {
10888 : : struct buffer *out = buf;
10889 : :
10890 : : /* Token name must match. */
10891 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
10892 : : return -1;
10893 : : /* Nothing else to do if there is no buffer. */
10894 : 0 : if (!out)
10895 : : return len;
10896 : 0 : if (!out->command) {
10897 : 0 : if (ctx->curr != ISOLATE)
10898 : : return -1;
10899 : 0 : if (sizeof(*out) > size)
10900 : : return -1;
10901 : 0 : out->command = ctx->curr;
10902 : 0 : ctx->objdata = 0;
10903 : 0 : ctx->object = out;
10904 : 0 : ctx->objmask = NULL;
10905 : : }
10906 : : return len;
10907 : : }
10908 : :
10909 : : /** Parse tokens for info/configure command. */
10910 : : static int
10911 : 0 : parse_configure(struct context *ctx, const struct token *token,
10912 : : const char *str, unsigned int len,
10913 : : void *buf, unsigned int size)
10914 : : {
10915 : : struct buffer *out = buf;
10916 : :
10917 : : /* Token name must match. */
10918 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
10919 : : return -1;
10920 : : /* Nothing else to do if there is no buffer. */
10921 : 0 : if (!out)
10922 : : return len;
10923 : 0 : if (!out->command) {
10924 : 0 : if (ctx->curr != INFO && ctx->curr != CONFIGURE)
10925 : : return -1;
10926 : 0 : if (sizeof(*out) > size)
10927 : : return -1;
10928 : 0 : out->command = ctx->curr;
10929 : 0 : ctx->objdata = 0;
10930 : 0 : ctx->object = out;
10931 : 0 : ctx->objmask = NULL;
10932 : : }
10933 : : return len;
10934 : : }
10935 : :
10936 : : /** Parse tokens for template create command. */
10937 : : static int
10938 : 0 : parse_template(struct context *ctx, const struct token *token,
10939 : : const char *str, unsigned int len,
10940 : : void *buf, unsigned int size)
10941 : : {
10942 : : struct buffer *out = buf;
10943 : :
10944 : : /* Token name must match. */
10945 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
10946 : : return -1;
10947 : : /* Nothing else to do if there is no buffer. */
10948 : 0 : if (!out)
10949 : : return len;
10950 : 0 : if (!out->command) {
10951 : 0 : if (ctx->curr != PATTERN_TEMPLATE &&
10952 : : ctx->curr != ACTIONS_TEMPLATE)
10953 : : return -1;
10954 : 0 : if (sizeof(*out) > size)
10955 : : return -1;
10956 : 0 : out->command = ctx->curr;
10957 : 0 : ctx->objdata = 0;
10958 : 0 : ctx->object = out;
10959 : 0 : ctx->objmask = NULL;
10960 : 0 : out->args.vc.data = (uint8_t *)out + size;
10961 : 0 : return len;
10962 : : }
10963 : 0 : switch (ctx->curr) {
10964 : 0 : case PATTERN_TEMPLATE_CREATE:
10965 : 0 : out->args.vc.pattern =
10966 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
10967 : : sizeof(double));
10968 : 0 : out->args.vc.pat_templ_id = UINT32_MAX;
10969 : 0 : out->command = ctx->curr;
10970 : 0 : ctx->objdata = 0;
10971 : 0 : ctx->object = out;
10972 : 0 : ctx->objmask = NULL;
10973 : 0 : return len;
10974 : 0 : case PATTERN_TEMPLATE_EGRESS:
10975 : 0 : out->args.vc.attr.egress = 1;
10976 : 0 : return len;
10977 : 0 : case PATTERN_TEMPLATE_INGRESS:
10978 : 0 : out->args.vc.attr.ingress = 1;
10979 : 0 : return len;
10980 : 0 : case PATTERN_TEMPLATE_TRANSFER:
10981 : 0 : out->args.vc.attr.transfer = 1;
10982 : 0 : return len;
10983 : 0 : case ACTIONS_TEMPLATE_CREATE:
10984 : 0 : out->args.vc.act_templ_id = UINT32_MAX;
10985 : 0 : out->command = ctx->curr;
10986 : 0 : ctx->objdata = 0;
10987 : 0 : ctx->object = out;
10988 : 0 : ctx->objmask = NULL;
10989 : 0 : return len;
10990 : 0 : case ACTIONS_TEMPLATE_SPEC:
10991 : 0 : out->args.vc.actions =
10992 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
10993 : : sizeof(double));
10994 : 0 : ctx->object = out->args.vc.actions;
10995 : 0 : ctx->objmask = NULL;
10996 : 0 : return len;
10997 : 0 : case ACTIONS_TEMPLATE_MASK:
10998 : 0 : out->args.vc.masks =
10999 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)
11000 : : (out->args.vc.actions +
11001 : : out->args.vc.actions_n),
11002 : : sizeof(double));
11003 : 0 : ctx->object = out->args.vc.masks;
11004 : 0 : ctx->objmask = NULL;
11005 : 0 : return len;
11006 : 0 : case ACTIONS_TEMPLATE_EGRESS:
11007 : 0 : out->args.vc.attr.egress = 1;
11008 : 0 : return len;
11009 : 0 : case ACTIONS_TEMPLATE_INGRESS:
11010 : 0 : out->args.vc.attr.ingress = 1;
11011 : 0 : return len;
11012 : 0 : case ACTIONS_TEMPLATE_TRANSFER:
11013 : 0 : out->args.vc.attr.transfer = 1;
11014 : 0 : return len;
11015 : : default:
11016 : : return -1;
11017 : : }
11018 : : }
11019 : :
11020 : : /** Parse tokens for template destroy command. */
11021 : : static int
11022 : 0 : parse_template_destroy(struct context *ctx, const struct token *token,
11023 : : const char *str, unsigned int len,
11024 : : void *buf, unsigned int size)
11025 : : {
11026 : : struct buffer *out = buf;
11027 : : uint32_t *template_id;
11028 : :
11029 : : /* Token name must match. */
11030 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
11031 : : return -1;
11032 : : /* Nothing else to do if there is no buffer. */
11033 : 0 : if (!out)
11034 : : return len;
11035 : 0 : if (!out->command ||
11036 : 0 : out->command == PATTERN_TEMPLATE ||
11037 : : out->command == ACTIONS_TEMPLATE) {
11038 : 0 : if (ctx->curr != PATTERN_TEMPLATE_DESTROY &&
11039 : : ctx->curr != ACTIONS_TEMPLATE_DESTROY)
11040 : : return -1;
11041 : 0 : if (sizeof(*out) > size)
11042 : : return -1;
11043 : 0 : out->command = ctx->curr;
11044 : 0 : ctx->objdata = 0;
11045 : 0 : ctx->object = out;
11046 : 0 : ctx->objmask = NULL;
11047 : 0 : out->args.templ_destroy.template_id =
11048 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
11049 : : sizeof(double));
11050 : 0 : return len;
11051 : : }
11052 : 0 : template_id = out->args.templ_destroy.template_id
11053 : 0 : + out->args.templ_destroy.template_id_n++;
11054 : 0 : if ((uint8_t *)template_id > (uint8_t *)out + size)
11055 : : return -1;
11056 : 0 : ctx->objdata = 0;
11057 : 0 : ctx->object = template_id;
11058 : 0 : ctx->objmask = NULL;
11059 : 0 : return len;
11060 : : }
11061 : :
11062 : : /** Parse tokens for table create command. */
11063 : : static int
11064 : 0 : parse_table(struct context *ctx, const struct token *token,
11065 : : const char *str, unsigned int len,
11066 : : void *buf, unsigned int size)
11067 : : {
11068 : : struct buffer *out = buf;
11069 : : uint32_t *template_id;
11070 : :
11071 : : /* Token name must match. */
11072 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
11073 : : return -1;
11074 : : /* Nothing else to do if there is no buffer. */
11075 : 0 : if (!out)
11076 : : return len;
11077 : 0 : if (!out->command) {
11078 : 0 : if (ctx->curr != TABLE)
11079 : : return -1;
11080 : 0 : if (sizeof(*out) > size)
11081 : : return -1;
11082 : 0 : out->command = ctx->curr;
11083 : 0 : ctx->objdata = 0;
11084 : 0 : ctx->object = out;
11085 : 0 : ctx->objmask = NULL;
11086 : 0 : return len;
11087 : : }
11088 : 0 : switch (ctx->curr) {
11089 : 0 : case TABLE_CREATE:
11090 : : case TABLE_RESIZE:
11091 : 0 : out->command = ctx->curr;
11092 : 0 : ctx->objdata = 0;
11093 : 0 : ctx->object = out;
11094 : 0 : ctx->objmask = NULL;
11095 : 0 : out->args.table.id = UINT32_MAX;
11096 : 0 : return len;
11097 : 0 : case TABLE_PATTERN_TEMPLATE:
11098 : 0 : out->args.table.pat_templ_id =
11099 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
11100 : : sizeof(double));
11101 : 0 : template_id = out->args.table.pat_templ_id
11102 : 0 : + out->args.table.pat_templ_id_n++;
11103 : 0 : if ((uint8_t *)template_id > (uint8_t *)out + size)
11104 : : return -1;
11105 : 0 : ctx->objdata = 0;
11106 : 0 : ctx->object = template_id;
11107 : 0 : ctx->objmask = NULL;
11108 : 0 : return len;
11109 : 0 : case TABLE_ACTIONS_TEMPLATE:
11110 : 0 : out->args.table.act_templ_id =
11111 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)
11112 : : (out->args.table.pat_templ_id +
11113 : : out->args.table.pat_templ_id_n),
11114 : : sizeof(double));
11115 : 0 : template_id = out->args.table.act_templ_id
11116 : 0 : + out->args.table.act_templ_id_n++;
11117 : 0 : if ((uint8_t *)template_id > (uint8_t *)out + size)
11118 : : return -1;
11119 : 0 : ctx->objdata = 0;
11120 : 0 : ctx->object = template_id;
11121 : 0 : ctx->objmask = NULL;
11122 : 0 : return len;
11123 : 0 : case TABLE_INGRESS:
11124 : 0 : out->args.table.attr.flow_attr.ingress = 1;
11125 : 0 : return len;
11126 : 0 : case TABLE_EGRESS:
11127 : 0 : out->args.table.attr.flow_attr.egress = 1;
11128 : 0 : return len;
11129 : 0 : case TABLE_TRANSFER:
11130 : 0 : out->args.table.attr.flow_attr.transfer = 1;
11131 : 0 : return len;
11132 : 0 : case TABLE_TRANSFER_WIRE_ORIG:
11133 : 0 : if (!out->args.table.attr.flow_attr.transfer)
11134 : : return -1;
11135 : 0 : out->args.table.attr.specialize |= RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_WIRE_ORIG;
11136 : 0 : return len;
11137 : 0 : case TABLE_TRANSFER_VPORT_ORIG:
11138 : 0 : if (!out->args.table.attr.flow_attr.transfer)
11139 : : return -1;
11140 : 0 : out->args.table.attr.specialize |= RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_VPORT_ORIG;
11141 : 0 : return len;
11142 : 0 : case TABLE_RESIZABLE:
11143 : 0 : out->args.table.attr.specialize |=
11144 : : RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE;
11145 : 0 : return len;
11146 : 0 : case TABLE_RULES_NUMBER:
11147 : 0 : ctx->objdata = 0;
11148 : 0 : ctx->object = out;
11149 : 0 : ctx->objmask = NULL;
11150 : 0 : return len;
11151 : 0 : case TABLE_RESIZE_ID:
11152 : : case TABLE_RESIZE_RULES_NUMBER:
11153 : 0 : return len;
11154 : : default:
11155 : : return -1;
11156 : : }
11157 : : }
11158 : :
11159 : : /** Parse tokens for table destroy command. */
11160 : : static int
11161 : 0 : parse_table_destroy(struct context *ctx, const struct token *token,
11162 : : const char *str, unsigned int len,
11163 : : void *buf, unsigned int size)
11164 : : {
11165 : : struct buffer *out = buf;
11166 : : uint32_t *table_id;
11167 : :
11168 : : /* Token name must match. */
11169 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
11170 : : return -1;
11171 : : /* Nothing else to do if there is no buffer. */
11172 : 0 : if (!out)
11173 : : return len;
11174 : 0 : if (!out->command || out->command == TABLE) {
11175 : 0 : if (ctx->curr != TABLE_DESTROY &&
11176 : : ctx->curr != TABLE_RESIZE_COMPLETE)
11177 : : return -1;
11178 : 0 : if (sizeof(*out) > size)
11179 : : return -1;
11180 : 0 : out->command = ctx->curr;
11181 : 0 : ctx->objdata = 0;
11182 : 0 : ctx->object = out;
11183 : 0 : ctx->objmask = NULL;
11184 : 0 : out->args.table_destroy.table_id =
11185 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
11186 : : sizeof(double));
11187 : 0 : return len;
11188 : : }
11189 : 0 : table_id = out->args.table_destroy.table_id
11190 : 0 : + out->args.table_destroy.table_id_n++;
11191 : 0 : if ((uint8_t *)table_id > (uint8_t *)out + size)
11192 : : return -1;
11193 : 0 : ctx->objdata = 0;
11194 : 0 : ctx->object = table_id;
11195 : 0 : ctx->objmask = NULL;
11196 : 0 : return len;
11197 : : }
11198 : :
11199 : : /** Parse table id and convert to table pointer for jump_to_table_index action. */
11200 : : static int
11201 : 0 : parse_jump_table_id(struct context *ctx, const struct token *token,
11202 : : const char *str, unsigned int len,
11203 : : void *buf, unsigned int size)
11204 : : {
11205 : : struct buffer *out = buf;
11206 : : struct rte_port *port;
11207 : : struct port_table *pt;
11208 : : uint32_t table_id;
11209 : : const struct arg *arg;
11210 : : void *entry_ptr;
11211 : :
11212 : : /* Get the arg before parse_int consumes it */
11213 : : arg = pop_args(ctx);
11214 : 0 : if (!arg)
11215 : 0 : return -1;
11216 : : /* Push it back and do the standard integer parsing */
11217 : : if (push_args(ctx, arg) < 0)
11218 : : return -1;
11219 : 0 : if (parse_int(ctx, token, str, len, buf, size) < 0)
11220 : : return -1;
11221 : : /* Nothing else to do if there is no buffer */
11222 : 0 : if (!out || !ctx->object)
11223 : 0 : return len;
11224 : : /* Get the parsed table ID from where parse_int stored it */
11225 : 0 : entry_ptr = (uint8_t *)ctx->object + arg->offset;
11226 : : memcpy(&table_id, entry_ptr, sizeof(uint32_t));
11227 : : /* Look up the table using table ID */
11228 : 0 : port = &ports[ctx->port];
11229 : 0 : for (pt = port->table_list; pt != NULL; pt = pt->next) {
11230 : 0 : if (pt->id == table_id)
11231 : : break;
11232 : : }
11233 : 0 : if (!pt || !pt->table) {
11234 : 0 : printf("Table #%u not found on port %u\n", table_id, ctx->port);
11235 : 0 : return -1;
11236 : : }
11237 : : /* Replace the table ID with the table pointer */
11238 : 0 : memcpy(entry_ptr, &pt->table, sizeof(struct rte_flow_template_table *));
11239 : 0 : return len;
11240 : : }
11241 : :
11242 : : /** Parse tokens for queue create commands. */
11243 : : static int
11244 : 0 : parse_qo(struct context *ctx, const struct token *token,
11245 : : const char *str, unsigned int len,
11246 : : void *buf, unsigned int size)
11247 : : {
11248 : : struct buffer *out = buf;
11249 : :
11250 : : /* Token name must match. */
11251 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
11252 : : return -1;
11253 : : /* Nothing else to do if there is no buffer. */
11254 : 0 : if (!out)
11255 : : return len;
11256 : 0 : if (!out->command) {
11257 : 0 : if (ctx->curr != QUEUE)
11258 : : return -1;
11259 : 0 : if (sizeof(*out) > size)
11260 : : return -1;
11261 : 0 : out->command = ctx->curr;
11262 : 0 : ctx->objdata = 0;
11263 : 0 : ctx->object = out;
11264 : 0 : ctx->objmask = NULL;
11265 : 0 : out->args.vc.data = (uint8_t *)out + size;
11266 : 0 : return len;
11267 : : }
11268 : 0 : switch (ctx->curr) {
11269 : 0 : case QUEUE_CREATE:
11270 : : case QUEUE_UPDATE:
11271 : 0 : out->command = ctx->curr;
11272 : 0 : ctx->objdata = 0;
11273 : 0 : ctx->object = out;
11274 : 0 : ctx->objmask = NULL;
11275 : 0 : out->args.vc.rule_id = UINT32_MAX;
11276 : 0 : return len;
11277 : 0 : case QUEUE_TEMPLATE_TABLE:
11278 : : case QUEUE_PATTERN_TEMPLATE:
11279 : : case QUEUE_ACTIONS_TEMPLATE:
11280 : : case QUEUE_CREATE_POSTPONE:
11281 : : case QUEUE_RULE_ID:
11282 : : case QUEUE_UPDATE_ID:
11283 : 0 : return len;
11284 : 0 : case ITEM_PATTERN:
11285 : 0 : out->args.vc.pattern =
11286 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
11287 : : sizeof(double));
11288 : 0 : ctx->object = out->args.vc.pattern;
11289 : 0 : ctx->objmask = NULL;
11290 : 0 : return len;
11291 : 0 : case ACTIONS:
11292 : 0 : out->args.vc.actions =
11293 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)
11294 : : (out->args.vc.pattern +
11295 : : out->args.vc.pattern_n),
11296 : : sizeof(double));
11297 : 0 : ctx->object = out->args.vc.actions;
11298 : 0 : ctx->objmask = NULL;
11299 : 0 : return len;
11300 : : default:
11301 : : return -1;
11302 : : }
11303 : : }
11304 : :
11305 : : /** Parse tokens for queue destroy command. */
11306 : : static int
11307 : 0 : parse_qo_destroy(struct context *ctx, const struct token *token,
11308 : : const char *str, unsigned int len,
11309 : : void *buf, unsigned int size)
11310 : : {
11311 : : struct buffer *out = buf;
11312 : : uint64_t *flow_id;
11313 : :
11314 : : /* Token name must match. */
11315 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
11316 : : return -1;
11317 : : /* Nothing else to do if there is no buffer. */
11318 : 0 : if (!out)
11319 : : return len;
11320 : 0 : if (!out->command || out->command == QUEUE) {
11321 : 0 : if (ctx->curr != QUEUE_DESTROY &&
11322 : : ctx->curr != QUEUE_FLOW_UPDATE_RESIZED)
11323 : : return -1;
11324 : 0 : if (sizeof(*out) > size)
11325 : : return -1;
11326 : 0 : out->command = ctx->curr;
11327 : 0 : ctx->objdata = 0;
11328 : 0 : ctx->object = out;
11329 : 0 : ctx->objmask = NULL;
11330 : 0 : out->args.destroy.rule =
11331 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
11332 : : sizeof(double));
11333 : 0 : return len;
11334 : : }
11335 : 0 : switch (ctx->curr) {
11336 : 0 : case QUEUE_DESTROY_ID:
11337 : 0 : flow_id = out->args.destroy.rule
11338 : 0 : + out->args.destroy.rule_n++;
11339 : 0 : if ((uint8_t *)flow_id > (uint8_t *)out + size)
11340 : : return -1;
11341 : 0 : ctx->objdata = 0;
11342 : 0 : ctx->object = flow_id;
11343 : 0 : ctx->objmask = NULL;
11344 : 0 : return len;
11345 : 0 : case QUEUE_DESTROY_POSTPONE:
11346 : 0 : return len;
11347 : : default:
11348 : : return -1;
11349 : : }
11350 : : }
11351 : :
11352 : : /** Parse tokens for push queue command. */
11353 : : static int
11354 : 0 : parse_push(struct context *ctx, const struct token *token,
11355 : : const char *str, unsigned int len,
11356 : : void *buf, unsigned int size)
11357 : : {
11358 : : struct buffer *out = buf;
11359 : :
11360 : : /* Token name must match. */
11361 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
11362 : : return -1;
11363 : : /* Nothing else to do if there is no buffer. */
11364 : 0 : if (!out)
11365 : : return len;
11366 : 0 : if (!out->command) {
11367 : 0 : if (ctx->curr != PUSH)
11368 : : return -1;
11369 : 0 : if (sizeof(*out) > size)
11370 : : return -1;
11371 : 0 : out->command = ctx->curr;
11372 : 0 : ctx->objdata = 0;
11373 : 0 : ctx->object = out;
11374 : 0 : ctx->objmask = NULL;
11375 : 0 : out->args.vc.data = (uint8_t *)out + size;
11376 : : }
11377 : : return len;
11378 : : }
11379 : :
11380 : : /** Parse tokens for pull command. */
11381 : : static int
11382 : 0 : parse_pull(struct context *ctx, const struct token *token,
11383 : : const char *str, unsigned int len,
11384 : : void *buf, unsigned int size)
11385 : : {
11386 : : struct buffer *out = buf;
11387 : :
11388 : : /* Token name must match. */
11389 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
11390 : : return -1;
11391 : : /* Nothing else to do if there is no buffer. */
11392 : 0 : if (!out)
11393 : : return len;
11394 : 0 : if (!out->command) {
11395 : 0 : if (ctx->curr != PULL)
11396 : : return -1;
11397 : 0 : if (sizeof(*out) > size)
11398 : : return -1;
11399 : 0 : out->command = ctx->curr;
11400 : 0 : ctx->objdata = 0;
11401 : 0 : ctx->object = out;
11402 : 0 : ctx->objmask = NULL;
11403 : 0 : out->args.vc.data = (uint8_t *)out + size;
11404 : : }
11405 : : return len;
11406 : : }
11407 : :
11408 : : /** Parse tokens for hash calculation commands. */
11409 : : static int
11410 : 0 : parse_hash(struct context *ctx, const struct token *token,
11411 : : const char *str, unsigned int len,
11412 : : void *buf, unsigned int size)
11413 : : {
11414 : : struct buffer *out = buf;
11415 : :
11416 : : /* Token name must match. */
11417 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
11418 : : return -1;
11419 : : /* Nothing else to do if there is no buffer. */
11420 : 0 : if (!out)
11421 : : return len;
11422 : 0 : if (!out->command) {
11423 : 0 : if (ctx->curr != HASH)
11424 : : return -1;
11425 : 0 : if (sizeof(*out) > size)
11426 : : return -1;
11427 : 0 : out->command = ctx->curr;
11428 : 0 : ctx->objdata = 0;
11429 : 0 : ctx->object = out;
11430 : 0 : ctx->objmask = NULL;
11431 : 0 : out->args.vc.data = (uint8_t *)out + size;
11432 : 0 : return len;
11433 : : }
11434 : 0 : switch (ctx->curr) {
11435 : 0 : case HASH_CALC_TABLE:
11436 : : case HASH_CALC_PATTERN_INDEX:
11437 : 0 : return len;
11438 : 0 : case ITEM_PATTERN:
11439 : 0 : out->args.vc.pattern =
11440 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
11441 : : sizeof(double));
11442 : 0 : ctx->object = out->args.vc.pattern;
11443 : 0 : ctx->objmask = NULL;
11444 : 0 : return len;
11445 : 0 : case HASH_CALC_ENCAP:
11446 : 0 : out->args.vc.encap_hash = 1;
11447 : 0 : return len;
11448 : 0 : case ENCAP_HASH_FIELD_SRC_PORT:
11449 : 0 : out->args.vc.field = RTE_FLOW_ENCAP_HASH_FIELD_SRC_PORT;
11450 : 0 : return len;
11451 : 0 : case ENCAP_HASH_FIELD_GRE_FLOW_ID:
11452 : 0 : out->args.vc.field = RTE_FLOW_ENCAP_HASH_FIELD_NVGRE_FLOW_ID;
11453 : 0 : return len;
11454 : : default:
11455 : : return -1;
11456 : : }
11457 : : }
11458 : :
11459 : : static int
11460 : 0 : parse_group(struct context *ctx, const struct token *token,
11461 : : const char *str, unsigned int len,
11462 : : void *buf, unsigned int size)
11463 : : {
11464 : : struct buffer *out = buf;
11465 : :
11466 : : /* Token name must match. */
11467 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
11468 : : return -1;
11469 : : /* Nothing else to do if there is no buffer. */
11470 : 0 : if (!out)
11471 : : return len;
11472 : 0 : if (!out->command) {
11473 : 0 : if (ctx->curr != FLOW_GROUP)
11474 : : return -1;
11475 : 0 : if (sizeof(*out) > size)
11476 : : return -1;
11477 : 0 : out->command = ctx->curr;
11478 : 0 : ctx->objdata = 0;
11479 : 0 : ctx->object = out;
11480 : 0 : ctx->objmask = NULL;
11481 : 0 : out->args.vc.data = (uint8_t *)out + size;
11482 : 0 : return len;
11483 : : }
11484 : 0 : switch (ctx->curr) {
11485 : 0 : case GROUP_INGRESS:
11486 : 0 : out->args.vc.attr.ingress = 1;
11487 : 0 : return len;
11488 : 0 : case GROUP_EGRESS:
11489 : 0 : out->args.vc.attr.egress = 1;
11490 : 0 : return len;
11491 : 0 : case GROUP_TRANSFER:
11492 : 0 : out->args.vc.attr.transfer = 1;
11493 : 0 : return len;
11494 : 0 : case GROUP_SET_MISS_ACTIONS:
11495 : 0 : out->command = ctx->curr;
11496 : 0 : ctx->objdata = 0;
11497 : 0 : ctx->object = out;
11498 : 0 : ctx->objmask = NULL;
11499 : 0 : out->args.vc.actions = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
11500 : : sizeof(double));
11501 : 0 : return len;
11502 : : default:
11503 : : return -1;
11504 : : }
11505 : : }
11506 : :
11507 : : static int
11508 : 0 : parse_flex(struct context *ctx, const struct token *token,
11509 : : const char *str, unsigned int len,
11510 : : void *buf, unsigned int size)
11511 : : {
11512 : : struct buffer *out = buf;
11513 : :
11514 : : /* Token name must match. */
11515 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
11516 : : return -1;
11517 : : /* Nothing else to do if there is no buffer. */
11518 : 0 : if (!out)
11519 : : return len;
11520 : 0 : if (out->command == ZERO) {
11521 : 0 : if (ctx->curr != FLEX)
11522 : : return -1;
11523 : 0 : if (sizeof(*out) > size)
11524 : : return -1;
11525 : 0 : out->command = ctx->curr;
11526 : 0 : ctx->objdata = 0;
11527 : 0 : ctx->object = out;
11528 : 0 : ctx->objmask = NULL;
11529 : : } else {
11530 : 0 : switch (ctx->curr) {
11531 : : default:
11532 : : break;
11533 : 0 : case FLEX_ITEM_CREATE:
11534 : : case FLEX_ITEM_DESTROY:
11535 : 0 : out->command = ctx->curr;
11536 : 0 : break;
11537 : : }
11538 : : }
11539 : :
11540 : : return len;
11541 : : }
11542 : :
11543 : : static int
11544 : 0 : parse_tunnel(struct context *ctx, const struct token *token,
11545 : : const char *str, unsigned int len,
11546 : : void *buf, unsigned int size)
11547 : : {
11548 : : struct buffer *out = buf;
11549 : :
11550 : : /* Token name must match. */
11551 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
11552 : : return -1;
11553 : : /* Nothing else to do if there is no buffer. */
11554 : 0 : if (!out)
11555 : : return len;
11556 : 0 : if (!out->command) {
11557 : 0 : if (ctx->curr != TUNNEL)
11558 : : return -1;
11559 : 0 : if (sizeof(*out) > size)
11560 : : return -1;
11561 : 0 : out->command = ctx->curr;
11562 : 0 : ctx->objdata = 0;
11563 : 0 : ctx->object = out;
11564 : 0 : ctx->objmask = NULL;
11565 : : } else {
11566 : 0 : switch (ctx->curr) {
11567 : : default:
11568 : : break;
11569 : 0 : case TUNNEL_CREATE:
11570 : : case TUNNEL_DESTROY:
11571 : : case TUNNEL_LIST:
11572 : 0 : out->command = ctx->curr;
11573 : 0 : break;
11574 : 0 : case TUNNEL_CREATE_TYPE:
11575 : : case TUNNEL_DESTROY_ID:
11576 : 0 : ctx->object = &out->args.vc.tunnel_ops;
11577 : 0 : break;
11578 : : }
11579 : : }
11580 : :
11581 : : return len;
11582 : : }
11583 : :
11584 : : /**
11585 : : * Parse signed/unsigned integers 8 to 64-bit long.
11586 : : *
11587 : : * Last argument (ctx->args) is retrieved to determine integer type and
11588 : : * storage location.
11589 : : */
11590 : : static int
11591 : 0 : parse_int(struct context *ctx, const struct token *token,
11592 : : const char *str, unsigned int len,
11593 : : void *buf, unsigned int size)
11594 : : {
11595 : : const struct arg *arg = pop_args(ctx);
11596 : : uintmax_t u;
11597 : : char *end;
11598 : :
11599 : : (void)token;
11600 : : /* Argument is expected. */
11601 : 0 : if (!arg)
11602 : 0 : return -1;
11603 : 0 : errno = 0;
11604 : 0 : u = arg->sign ?
11605 : 0 : (uintmax_t)strtoimax(str, &end, 0) :
11606 : 0 : strtoumax(str, &end, 0);
11607 : 0 : if (errno || (size_t)(end - str) != len)
11608 : 0 : goto error;
11609 : 0 : if (arg->bounded &&
11610 : 0 : ((arg->sign && ((intmax_t)u < (intmax_t)arg->min ||
11611 : 0 : (intmax_t)u > (intmax_t)arg->max)) ||
11612 : 0 : (!arg->sign && (u < arg->min || u > arg->max))))
11613 : 0 : goto error;
11614 : 0 : if (!ctx->object)
11615 : 0 : return len;
11616 : 0 : if (arg->mask) {
11617 : 0 : if (!arg_entry_bf_fill(ctx->object, u, arg) ||
11618 : 0 : !arg_entry_bf_fill(ctx->objmask, -1, arg))
11619 : 0 : goto error;
11620 : 0 : return len;
11621 : : }
11622 : 0 : buf = (uint8_t *)ctx->object + arg->offset;
11623 : 0 : size = arg->size;
11624 : 0 : if (u > RTE_LEN2MASK(size * CHAR_BIT, uint64_t))
11625 : : return -1;
11626 : 0 : objmask:
11627 : 0 : switch (size) {
11628 : 0 : case sizeof(uint8_t):
11629 : 0 : *(uint8_t *)buf = u;
11630 : 0 : break;
11631 : 0 : case sizeof(uint16_t):
11632 : 0 : *(uint16_t *)buf = arg->hton ? rte_cpu_to_be_16(u) : u;
11633 : 0 : break;
11634 : 0 : case sizeof(uint8_t [3]):
11635 : : #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
11636 : 0 : if (!arg->hton) {
11637 : 0 : ((uint8_t *)buf)[0] = u;
11638 : 0 : ((uint8_t *)buf)[1] = u >> 8;
11639 : 0 : ((uint8_t *)buf)[2] = u >> 16;
11640 : 0 : break;
11641 : : }
11642 : : #endif
11643 : 0 : ((uint8_t *)buf)[0] = u >> 16;
11644 : 0 : ((uint8_t *)buf)[1] = u >> 8;
11645 : 0 : ((uint8_t *)buf)[2] = u;
11646 : 0 : break;
11647 : 0 : case sizeof(uint32_t):
11648 : 0 : *(uint32_t *)buf = arg->hton ? rte_cpu_to_be_32(u) : u;
11649 : 0 : break;
11650 : 0 : case sizeof(uint64_t):
11651 : 0 : *(uint64_t *)buf = arg->hton ? rte_cpu_to_be_64(u) : u;
11652 : 0 : break;
11653 : 0 : default:
11654 : 0 : goto error;
11655 : : }
11656 : 0 : if (ctx->objmask && buf != (uint8_t *)ctx->objmask + arg->offset) {
11657 : : u = -1;
11658 : : buf = (uint8_t *)ctx->objmask + arg->offset;
11659 : 0 : goto objmask;
11660 : : }
11661 : 0 : return len;
11662 : 0 : error:
11663 : : push_args(ctx, arg);
11664 : : return -1;
11665 : : }
11666 : :
11667 : : /**
11668 : : * Parse a string.
11669 : : *
11670 : : * Three arguments (ctx->args) are retrieved from the stack to store data,
11671 : : * its actual length and address (in that order).
11672 : : */
11673 : : static int
11674 : 0 : parse_string(struct context *ctx, const struct token *token,
11675 : : const char *str, unsigned int len,
11676 : : void *buf, unsigned int size)
11677 : : {
11678 : : const struct arg *arg_data = pop_args(ctx);
11679 : : const struct arg *arg_len = pop_args(ctx);
11680 : : const struct arg *arg_addr = pop_args(ctx);
11681 : : char tmp[16]; /* Ought to be enough. */
11682 : : int ret;
11683 : :
11684 : : /* Arguments are expected. */
11685 : 0 : if (!arg_data)
11686 : : return -1;
11687 : 0 : if (!arg_len) {
11688 : : push_args(ctx, arg_data);
11689 : 0 : return -1;
11690 : : }
11691 : 0 : if (!arg_addr) {
11692 : : push_args(ctx, arg_len);
11693 : : push_args(ctx, arg_data);
11694 : 0 : return -1;
11695 : : }
11696 : 0 : size = arg_data->size;
11697 : : /* Bit-mask fill is not supported. */
11698 : 0 : if (arg_data->mask || size < len)
11699 : 0 : goto error;
11700 : 0 : if (!ctx->object)
11701 : 0 : return len;
11702 : : /* Let parse_int() fill length information first. */
11703 : : ret = snprintf(tmp, sizeof(tmp), "%u", len);
11704 : 0 : if (ret < 0)
11705 : 0 : goto error;
11706 : : push_args(ctx, arg_len);
11707 : 0 : ret = parse_int(ctx, token, tmp, ret, NULL, 0);
11708 : 0 : if (ret < 0) {
11709 : : pop_args(ctx);
11710 : 0 : goto error;
11711 : : }
11712 : 0 : buf = (uint8_t *)ctx->object + arg_data->offset;
11713 : : /* Output buffer is not necessarily NUL-terminated. */
11714 : 0 : memcpy(buf, str, len);
11715 : 0 : memset((uint8_t *)buf + len, 0x00, size - len);
11716 : 0 : if (ctx->objmask)
11717 : 0 : memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
11718 : : /* Save address if requested. */
11719 : 0 : if (arg_addr->size) {
11720 : 0 : memcpy((uint8_t *)ctx->object + arg_addr->offset,
11721 : 0 : (void *[]){
11722 : 0 : (uint8_t *)ctx->object + arg_data->offset
11723 : : },
11724 : : arg_addr->size);
11725 : 0 : if (ctx->objmask)
11726 : 0 : memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
11727 : 0 : (void *[]){
11728 : 0 : (uint8_t *)ctx->objmask + arg_data->offset
11729 : : },
11730 : 0 : arg_addr->size);
11731 : : }
11732 : 0 : return len;
11733 : 0 : error:
11734 : : push_args(ctx, arg_addr);
11735 : : push_args(ctx, arg_len);
11736 : : push_args(ctx, arg_data);
11737 : : return -1;
11738 : : }
11739 : :
11740 : : static int
11741 : 0 : parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
11742 : : {
11743 : : const uint8_t *head = dst;
11744 : : uint32_t left;
11745 : :
11746 : 0 : if (*size == 0)
11747 : : return -1;
11748 : :
11749 : : left = *size;
11750 : :
11751 : : /* Convert chars to bytes */
11752 : 0 : while (left) {
11753 : 0 : char tmp[3], *end = tmp;
11754 : 0 : uint32_t read_lim = left & 1 ? 1 : 2;
11755 : :
11756 : 0 : snprintf(tmp, read_lim + 1, "%s", src);
11757 : 0 : *dst = strtoul(tmp, &end, 16);
11758 : 0 : if (*end) {
11759 : 0 : *dst = 0;
11760 : 0 : *size = (uint32_t)(dst - head);
11761 : 0 : return -1;
11762 : : }
11763 : 0 : left -= read_lim;
11764 : 0 : src += read_lim;
11765 : 0 : dst++;
11766 : : }
11767 : 0 : *dst = 0;
11768 : 0 : *size = (uint32_t)(dst - head);
11769 : 0 : return 0;
11770 : : }
11771 : :
11772 : : static int
11773 : 0 : parse_hex(struct context *ctx, const struct token *token,
11774 : : const char *str, unsigned int len,
11775 : : void *buf, unsigned int size)
11776 : : {
11777 : : const struct arg *arg_data = pop_args(ctx);
11778 : : const struct arg *arg_len = pop_args(ctx);
11779 : : const struct arg *arg_addr = pop_args(ctx);
11780 : : char tmp[16]; /* Ought to be enough. */
11781 : : int ret;
11782 : 0 : unsigned int hexlen = len;
11783 : : uint8_t hex_tmp[256];
11784 : :
11785 : : /* Arguments are expected. */
11786 : 0 : if (!arg_data)
11787 : : return -1;
11788 : 0 : if (!arg_len) {
11789 : : push_args(ctx, arg_data);
11790 : 0 : return -1;
11791 : : }
11792 : 0 : if (!arg_addr) {
11793 : : push_args(ctx, arg_len);
11794 : : push_args(ctx, arg_data);
11795 : 0 : return -1;
11796 : : }
11797 : 0 : size = arg_data->size;
11798 : : /* Bit-mask fill is not supported. */
11799 : 0 : if (arg_data->mask)
11800 : 0 : goto error;
11801 : 0 : if (!ctx->object)
11802 : 0 : return len;
11803 : :
11804 : : /* translate bytes string to array. */
11805 : 0 : if (str[0] == '0' && ((str[1] == 'x') ||
11806 : : (str[1] == 'X'))) {
11807 : 0 : str += 2;
11808 : 0 : hexlen -= 2;
11809 : : }
11810 : 0 : if (hexlen > RTE_DIM(hex_tmp))
11811 : 0 : goto error;
11812 : 0 : ret = parse_hex_string(str, hex_tmp, &hexlen);
11813 : 0 : if (ret < 0)
11814 : 0 : goto error;
11815 : : /* Check the converted binary fits into data buffer. */
11816 : 0 : if (hexlen > size)
11817 : 0 : goto error;
11818 : : /* Let parse_int() fill length information first. */
11819 : : ret = snprintf(tmp, sizeof(tmp), "%u", hexlen);
11820 : 0 : if (ret < 0)
11821 : 0 : goto error;
11822 : : /* Save length if requested. */
11823 : 0 : if (arg_len->size) {
11824 : : push_args(ctx, arg_len);
11825 : 0 : ret = parse_int(ctx, token, tmp, ret, NULL, 0);
11826 : 0 : if (ret < 0) {
11827 : : pop_args(ctx);
11828 : 0 : goto error;
11829 : : }
11830 : : }
11831 : 0 : buf = (uint8_t *)ctx->object + arg_data->offset;
11832 : : /* Output buffer is not necessarily NUL-terminated. */
11833 : 0 : memcpy(buf, hex_tmp, hexlen);
11834 : 0 : memset((uint8_t *)buf + hexlen, 0x00, size - hexlen);
11835 : 0 : if (ctx->objmask)
11836 : 0 : memset((uint8_t *)ctx->objmask + arg_data->offset,
11837 : : 0xff, hexlen);
11838 : : /* Save address if requested. */
11839 : 0 : if (arg_addr->size) {
11840 : 0 : memcpy((uint8_t *)ctx->object + arg_addr->offset,
11841 : 0 : (void *[]){
11842 : 0 : (uint8_t *)ctx->object + arg_data->offset
11843 : : },
11844 : : arg_addr->size);
11845 : 0 : if (ctx->objmask)
11846 : 0 : memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
11847 : 0 : (void *[]){
11848 : 0 : (uint8_t *)ctx->objmask + arg_data->offset
11849 : : },
11850 : 0 : arg_addr->size);
11851 : : }
11852 : 0 : return len;
11853 : 0 : error:
11854 : : push_args(ctx, arg_addr);
11855 : : push_args(ctx, arg_len);
11856 : : push_args(ctx, arg_data);
11857 : : return -1;
11858 : :
11859 : : }
11860 : :
11861 : : /**
11862 : : * Parse a zero-ended string.
11863 : : */
11864 : : static int
11865 : 0 : parse_string0(struct context *ctx, const struct token *token __rte_unused,
11866 : : const char *str, unsigned int len,
11867 : : void *buf, unsigned int size)
11868 : : {
11869 : : const struct arg *arg_data = pop_args(ctx);
11870 : :
11871 : : /* Arguments are expected. */
11872 : 0 : if (!arg_data)
11873 : 0 : return -1;
11874 : 0 : size = arg_data->size;
11875 : : /* Bit-mask fill is not supported. */
11876 : 0 : if (arg_data->mask || size < len + 1)
11877 : 0 : goto error;
11878 : 0 : if (!ctx->object)
11879 : 0 : return len;
11880 : 0 : buf = (uint8_t *)ctx->object + arg_data->offset;
11881 : 0 : strncpy(buf, str, len);
11882 : 0 : if (ctx->objmask)
11883 : 0 : memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
11884 : 0 : return len;
11885 : : error:
11886 : : push_args(ctx, arg_data);
11887 : : return -1;
11888 : : }
11889 : :
11890 : : /**
11891 : : * Parse a MAC address.
11892 : : *
11893 : : * Last argument (ctx->args) is retrieved to determine storage size and
11894 : : * location.
11895 : : */
11896 : : static int
11897 : 0 : parse_mac_addr(struct context *ctx, const struct token *token,
11898 : : const char *str, unsigned int len,
11899 : : void *buf, unsigned int size)
11900 : : {
11901 : : const struct arg *arg = pop_args(ctx);
11902 : : struct rte_ether_addr tmp;
11903 : : int ret;
11904 : :
11905 : : (void)token;
11906 : : /* Argument is expected. */
11907 : 0 : if (!arg)
11908 : 0 : return -1;
11909 : 0 : size = arg->size;
11910 : : /* Bit-mask fill is not supported. */
11911 : 0 : if (arg->mask || size != sizeof(tmp))
11912 : 0 : goto error;
11913 : : /* Only network endian is supported. */
11914 : 0 : if (!arg->hton)
11915 : 0 : goto error;
11916 : 0 : ret = cmdline_parse_etheraddr(NULL, str, &tmp, size);
11917 : 0 : if (ret < 0 || (unsigned int)ret != len)
11918 : 0 : goto error;
11919 : 0 : if (!ctx->object)
11920 : 0 : return len;
11921 : 0 : buf = (uint8_t *)ctx->object + arg->offset;
11922 : : memcpy(buf, &tmp, size);
11923 : 0 : if (ctx->objmask)
11924 : 0 : memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
11925 : 0 : return len;
11926 : 0 : error:
11927 : : push_args(ctx, arg);
11928 : : return -1;
11929 : : }
11930 : :
11931 : : /**
11932 : : * Parse an IPv4 address.
11933 : : *
11934 : : * Last argument (ctx->args) is retrieved to determine storage size and
11935 : : * location.
11936 : : */
11937 : : static int
11938 : 0 : parse_ipv4_addr(struct context *ctx, const struct token *token,
11939 : : const char *str, unsigned int len,
11940 : : void *buf, unsigned int size)
11941 : : {
11942 : : const struct arg *arg = pop_args(ctx);
11943 : : char str2[INET_ADDRSTRLEN];
11944 : : struct in_addr tmp;
11945 : : int ret;
11946 : :
11947 : : /* Length is longer than the max length an IPv4 address can have. */
11948 : 0 : if (len >= INET_ADDRSTRLEN)
11949 : : return -1;
11950 : : /* Argument is expected. */
11951 : 0 : if (!arg)
11952 : : return -1;
11953 : 0 : size = arg->size;
11954 : : /* Bit-mask fill is not supported. */
11955 : 0 : if (arg->mask || size != sizeof(tmp))
11956 : 0 : goto error;
11957 : : /* Only network endian is supported. */
11958 : 0 : if (!arg->hton)
11959 : 0 : goto error;
11960 : 0 : memcpy(str2, str, len);
11961 : 0 : str2[len] = '\0';
11962 : 0 : ret = inet_pton(AF_INET, str2, &tmp);
11963 : 0 : if (ret != 1) {
11964 : : /* Attempt integer parsing. */
11965 : : push_args(ctx, arg);
11966 : 0 : return parse_int(ctx, token, str, len, buf, size);
11967 : : }
11968 : 0 : if (!ctx->object)
11969 : 0 : return len;
11970 : 0 : buf = (uint8_t *)ctx->object + arg->offset;
11971 : : memcpy(buf, &tmp, size);
11972 : 0 : if (ctx->objmask)
11973 : 0 : memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
11974 : 0 : return len;
11975 : 0 : error:
11976 : : push_args(ctx, arg);
11977 : : return -1;
11978 : : }
11979 : :
11980 : : /**
11981 : : * Parse an IPv6 address.
11982 : : *
11983 : : * Last argument (ctx->args) is retrieved to determine storage size and
11984 : : * location.
11985 : : */
11986 : : static int
11987 : 0 : parse_ipv6_addr(struct context *ctx, const struct token *token,
11988 : : const char *str, unsigned int len,
11989 : : void *buf, unsigned int size)
11990 : : {
11991 : : const struct arg *arg = pop_args(ctx);
11992 : : char str2[INET6_ADDRSTRLEN];
11993 : : struct rte_ipv6_addr tmp;
11994 : : int ret;
11995 : :
11996 : : (void)token;
11997 : : /* Length is longer than the max length an IPv6 address can have. */
11998 : 0 : if (len >= INET6_ADDRSTRLEN)
11999 : : return -1;
12000 : : /* Argument is expected. */
12001 : 0 : if (!arg)
12002 : : return -1;
12003 : 0 : size = arg->size;
12004 : : /* Bit-mask fill is not supported. */
12005 : 0 : if (arg->mask || size != sizeof(tmp))
12006 : 0 : goto error;
12007 : : /* Only network endian is supported. */
12008 : 0 : if (!arg->hton)
12009 : 0 : goto error;
12010 : 0 : memcpy(str2, str, len);
12011 : 0 : str2[len] = '\0';
12012 : 0 : ret = inet_pton(AF_INET6, str2, &tmp);
12013 : 0 : if (ret != 1)
12014 : 0 : goto error;
12015 : 0 : if (!ctx->object)
12016 : 0 : return len;
12017 : 0 : buf = (uint8_t *)ctx->object + arg->offset;
12018 : : memcpy(buf, &tmp, size);
12019 : 0 : if (ctx->objmask)
12020 : 0 : memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
12021 : 0 : return len;
12022 : 0 : error:
12023 : : push_args(ctx, arg);
12024 : : return -1;
12025 : : }
12026 : :
12027 : : /** Boolean values (even indices stand for false). */
12028 : : static const char *const boolean_name[] = {
12029 : : "0", "1",
12030 : : "false", "true",
12031 : : "no", "yes",
12032 : : "N", "Y",
12033 : : "off", "on",
12034 : : NULL,
12035 : : };
12036 : :
12037 : : /**
12038 : : * Parse a boolean value.
12039 : : *
12040 : : * Last argument (ctx->args) is retrieved to determine storage size and
12041 : : * location.
12042 : : */
12043 : : static int
12044 : 0 : parse_boolean(struct context *ctx, const struct token *token,
12045 : : const char *str, unsigned int len,
12046 : : void *buf, unsigned int size)
12047 : : {
12048 : : const struct arg *arg = pop_args(ctx);
12049 : : unsigned int i;
12050 : : int ret;
12051 : :
12052 : : /* Argument is expected. */
12053 : 0 : if (!arg)
12054 : 0 : return -1;
12055 : 0 : for (i = 0; boolean_name[i]; ++i)
12056 : 0 : if (!strcmp_partial(boolean_name[i], str, len))
12057 : : break;
12058 : : /* Process token as integer. */
12059 : 0 : if (boolean_name[i])
12060 : 0 : str = i & 1 ? "1" : "0";
12061 : : push_args(ctx, arg);
12062 : 0 : ret = parse_int(ctx, token, str, strlen(str), buf, size);
12063 : 0 : return ret > 0 ? (int)len : ret;
12064 : : }
12065 : :
12066 : : /** Parse port and update context. */
12067 : : static int
12068 : 0 : parse_port(struct context *ctx, const struct token *token,
12069 : : const char *str, unsigned int len,
12070 : : void *buf, unsigned int size)
12071 : : {
12072 : 0 : struct buffer *out = &(struct buffer){ .port = 0 };
12073 : : int ret;
12074 : :
12075 : 0 : if (buf)
12076 : : out = buf;
12077 : : else {
12078 : 0 : ctx->objdata = 0;
12079 : 0 : ctx->object = out;
12080 : 0 : ctx->objmask = NULL;
12081 : : size = sizeof(*out);
12082 : : }
12083 : 0 : ret = parse_int(ctx, token, str, len, out, size);
12084 : 0 : if (ret >= 0)
12085 : 0 : ctx->port = out->port;
12086 : 0 : if (!buf)
12087 : 0 : ctx->object = NULL;
12088 : 0 : return ret;
12089 : : }
12090 : :
12091 : : /** Parse tokens for shared indirect actions. */
12092 : : static int
12093 : 0 : parse_ia_port(struct context *ctx, const struct token *token,
12094 : : const char *str, unsigned int len,
12095 : : void *buf, unsigned int size)
12096 : : {
12097 : 0 : struct rte_flow_action *action = ctx->object;
12098 : : uint32_t id;
12099 : : int ret;
12100 : :
12101 : : (void)buf;
12102 : : (void)size;
12103 : 0 : ctx->objdata = 0;
12104 : 0 : ctx->object = &id;
12105 : 0 : ctx->objmask = NULL;
12106 : 0 : ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
12107 : 0 : ctx->object = action;
12108 : 0 : if (ret != (int)len)
12109 : : return ret;
12110 : : /* set indirect action */
12111 : 0 : if (action)
12112 : 0 : action->conf = (void *)(uintptr_t)id;
12113 : : return ret;
12114 : : }
12115 : :
12116 : : static int
12117 : 0 : parse_ia_id2ptr(struct context *ctx, const struct token *token,
12118 : : const char *str, unsigned int len,
12119 : : void *buf, unsigned int size)
12120 : : {
12121 : 0 : struct rte_flow_action *action = ctx->object;
12122 : : uint32_t id;
12123 : : int ret;
12124 : :
12125 : : (void)buf;
12126 : : (void)size;
12127 : 0 : ctx->objdata = 0;
12128 : 0 : ctx->object = &id;
12129 : 0 : ctx->objmask = NULL;
12130 : 0 : ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
12131 : 0 : ctx->object = action;
12132 : 0 : if (ret != (int)len)
12133 : : return ret;
12134 : : /* set indirect action */
12135 : 0 : if (action) {
12136 : 0 : portid_t port_id = ctx->port;
12137 : 0 : if (ctx->prev == INDIRECT_ACTION_PORT)
12138 : 0 : port_id = (portid_t)(uintptr_t)action->conf;
12139 : 0 : action->conf = port_action_handle_get_by_id(port_id, id);
12140 : 0 : ret = (action->conf) ? ret : -1;
12141 : : }
12142 : : return ret;
12143 : : }
12144 : :
12145 : : static int
12146 : 0 : parse_indlst_id2ptr(struct context *ctx, const struct token *token,
12147 : : const char *str, unsigned int len,
12148 : : __rte_unused void *buf, __rte_unused unsigned int size)
12149 : : {
12150 : 0 : struct rte_flow_action *action = ctx->object;
12151 : : struct rte_flow_action_indirect_list *action_conf;
12152 : : const struct indlst_conf *indlst_conf;
12153 : : uint32_t id;
12154 : : int ret;
12155 : :
12156 : 0 : ctx->objdata = 0;
12157 : 0 : ctx->object = &id;
12158 : 0 : ctx->objmask = NULL;
12159 : 0 : ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
12160 : 0 : ctx->object = action;
12161 : 0 : if (ret != (int)len)
12162 : : return ret;
12163 : :
12164 : : /* set handle and conf */
12165 : 0 : if (action) {
12166 : 0 : action_conf = (void *)(uintptr_t)action->conf;
12167 : 0 : action_conf->conf = NULL;
12168 : 0 : switch (ctx->curr) {
12169 : 0 : case INDIRECT_LIST_ACTION_ID2PTR_HANDLE:
12170 : 0 : action_conf->handle = (typeof(action_conf->handle))
12171 : 0 : port_action_handle_get_by_id(ctx->port, id);
12172 : 0 : if (!action_conf->handle) {
12173 : 0 : printf("no indirect list handle for id %u\n", id);
12174 : 0 : return -1;
12175 : : }
12176 : : break;
12177 : 0 : case INDIRECT_LIST_ACTION_ID2PTR_CONF:
12178 : 0 : indlst_conf = indirect_action_list_conf_get(id);
12179 : 0 : if (!indlst_conf)
12180 : : return -1;
12181 : 0 : action_conf->conf = (const void **)indlst_conf->conf;
12182 : 0 : break;
12183 : : default:
12184 : : break;
12185 : : }
12186 : : }
12187 : : return ret;
12188 : : }
12189 : :
12190 : : static int
12191 : 0 : parse_meter_profile_id2ptr(struct context *ctx, const struct token *token,
12192 : : const char *str, unsigned int len,
12193 : : void *buf, unsigned int size)
12194 : : {
12195 : 0 : struct rte_flow_action *action = ctx->object;
12196 : : struct rte_flow_action_meter_mark *meter;
12197 : : struct rte_flow_meter_profile *profile = NULL;
12198 : 0 : uint32_t id = 0;
12199 : : int ret;
12200 : :
12201 : : (void)buf;
12202 : : (void)size;
12203 : 0 : ctx->objdata = 0;
12204 : 0 : ctx->object = &id;
12205 : 0 : ctx->objmask = NULL;
12206 : 0 : ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
12207 : 0 : ctx->object = action;
12208 : 0 : if (ret != (int)len)
12209 : : return ret;
12210 : : /* set meter profile */
12211 : 0 : if (action) {
12212 : 0 : meter = (struct rte_flow_action_meter_mark *)
12213 : : (uintptr_t)(action->conf);
12214 : 0 : profile = port_meter_profile_get_by_id(ctx->port, id);
12215 : 0 : meter->profile = profile;
12216 : 0 : ret = (profile) ? ret : -1;
12217 : : }
12218 : : return ret;
12219 : : }
12220 : :
12221 : : static int
12222 : 0 : parse_meter_policy_id2ptr(struct context *ctx, const struct token *token,
12223 : : const char *str, unsigned int len,
12224 : : void *buf, unsigned int size)
12225 : : {
12226 : 0 : struct rte_flow_action *action = ctx->object;
12227 : : struct rte_flow_action_meter_mark *meter;
12228 : : struct rte_flow_meter_policy *policy = NULL;
12229 : 0 : uint32_t id = 0;
12230 : : int ret;
12231 : :
12232 : : (void)buf;
12233 : : (void)size;
12234 : 0 : ctx->objdata = 0;
12235 : 0 : ctx->object = &id;
12236 : 0 : ctx->objmask = NULL;
12237 : 0 : ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
12238 : 0 : ctx->object = action;
12239 : 0 : if (ret != (int)len)
12240 : : return ret;
12241 : : /* set meter policy */
12242 : 0 : if (action) {
12243 : 0 : meter = (struct rte_flow_action_meter_mark *)
12244 : : (uintptr_t)(action->conf);
12245 : 0 : policy = port_meter_policy_get_by_id(ctx->port, id);
12246 : 0 : meter->policy = policy;
12247 : 0 : ret = (policy) ? ret : -1;
12248 : : }
12249 : : return ret;
12250 : : }
12251 : :
12252 : : /** Parse set command, initialize output buffer for subsequent tokens. */
12253 : : static int
12254 : 0 : parse_set_raw_encap_decap(struct context *ctx, const struct token *token,
12255 : : const char *str, unsigned int len,
12256 : : void *buf, unsigned int size)
12257 : : {
12258 : : struct buffer *out = buf;
12259 : :
12260 : : /* Token name must match. */
12261 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
12262 : : return -1;
12263 : : /* Nothing else to do if there is no buffer. */
12264 : 0 : if (!out)
12265 : : return len;
12266 : : /* Make sure buffer is large enough. */
12267 : 0 : if (size < sizeof(*out))
12268 : : return -1;
12269 : 0 : ctx->objdata = 0;
12270 : 0 : ctx->objmask = NULL;
12271 : 0 : ctx->object = out;
12272 : 0 : if (!out->command)
12273 : : return -1;
12274 : 0 : out->command = ctx->curr;
12275 : : /* For encap/decap we need is pattern */
12276 : 0 : out->args.vc.pattern = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
12277 : : sizeof(double));
12278 : 0 : return len;
12279 : : }
12280 : :
12281 : : /** Parse set command, initialize output buffer for subsequent tokens. */
12282 : : static int
12283 : 0 : parse_set_sample_action(struct context *ctx, const struct token *token,
12284 : : const char *str, unsigned int len,
12285 : : void *buf, unsigned int size)
12286 : : {
12287 : : struct buffer *out = buf;
12288 : :
12289 : : /* Token name must match. */
12290 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
12291 : : return -1;
12292 : : /* Nothing else to do if there is no buffer. */
12293 : 0 : if (!out)
12294 : : return len;
12295 : : /* Make sure buffer is large enough. */
12296 : 0 : if (size < sizeof(*out))
12297 : : return -1;
12298 : 0 : ctx->objdata = 0;
12299 : 0 : ctx->objmask = NULL;
12300 : 0 : ctx->object = out;
12301 : 0 : if (!out->command)
12302 : : return -1;
12303 : 0 : out->command = ctx->curr;
12304 : : /* For sampler we need is actions */
12305 : 0 : out->args.vc.actions = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
12306 : : sizeof(double));
12307 : 0 : return len;
12308 : : }
12309 : :
12310 : : /** Parse set command, initialize output buffer for subsequent tokens. */
12311 : : static int
12312 : 0 : parse_set_ipv6_ext_action(struct context *ctx, const struct token *token,
12313 : : const char *str, unsigned int len,
12314 : : void *buf, unsigned int size)
12315 : : {
12316 : : struct buffer *out = buf;
12317 : :
12318 : : /* Token name must match. */
12319 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
12320 : : return -1;
12321 : : /* Nothing else to do if there is no buffer. */
12322 : 0 : if (!out)
12323 : : return len;
12324 : : /* Make sure buffer is large enough. */
12325 : 0 : if (size < sizeof(*out))
12326 : : return -1;
12327 : 0 : ctx->objdata = 0;
12328 : 0 : ctx->objmask = NULL;
12329 : 0 : ctx->object = out;
12330 : 0 : if (!out->command)
12331 : : return -1;
12332 : 0 : out->command = ctx->curr;
12333 : : /* For ipv6_ext_push/remove we need is pattern */
12334 : 0 : out->args.vc.pattern = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
12335 : : sizeof(double));
12336 : 0 : return len;
12337 : : }
12338 : :
12339 : : /**
12340 : : * Parse set raw_encap/raw_decap command,
12341 : : * initialize output buffer for subsequent tokens.
12342 : : */
12343 : : static int
12344 : 0 : parse_set_init(struct context *ctx, const struct token *token,
12345 : : const char *str, unsigned int len,
12346 : : void *buf, unsigned int size)
12347 : : {
12348 : : struct buffer *out = buf;
12349 : :
12350 : : /* Token name must match. */
12351 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
12352 : : return -1;
12353 : : /* Nothing else to do if there is no buffer. */
12354 : 0 : if (!out)
12355 : : return len;
12356 : : /* Make sure buffer is large enough. */
12357 : 0 : if (size < sizeof(*out))
12358 : : return -1;
12359 : : /* Initialize buffer. */
12360 : : memset(out, 0x00, sizeof(*out));
12361 : 0 : memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
12362 : 0 : ctx->objdata = 0;
12363 : 0 : ctx->object = out;
12364 : 0 : ctx->objmask = NULL;
12365 : : if (!out->command) {
12366 : 0 : if (ctx->curr != SET)
12367 : : return -1;
12368 : : if (sizeof(*out) > size)
12369 : : return -1;
12370 : 0 : out->command = ctx->curr;
12371 : 0 : out->args.vc.data = (uint8_t *)out + size;
12372 : 0 : ctx->object = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
12373 : : sizeof(double));
12374 : : }
12375 : 0 : return len;
12376 : : }
12377 : :
12378 : : /*
12379 : : * Replace testpmd handles in a flex flow item with real values.
12380 : : */
12381 : : static int
12382 : 0 : parse_flex_handle(struct context *ctx, const struct token *token,
12383 : : const char *str, unsigned int len,
12384 : : void *buf, unsigned int size)
12385 : : {
12386 : : struct rte_flow_item_flex *spec, *mask;
12387 : : const struct rte_flow_item_flex *src_spec, *src_mask;
12388 : : const struct arg *arg = pop_args(ctx);
12389 : : uint32_t offset;
12390 : : uint16_t handle;
12391 : : int ret;
12392 : :
12393 : 0 : if (!arg) {
12394 : : printf("Bad environment\n");
12395 : 0 : return -1;
12396 : : }
12397 : 0 : offset = arg->offset;
12398 : : push_args(ctx, arg);
12399 : 0 : ret = parse_int(ctx, token, str, len, buf, size);
12400 : 0 : if (ret <= 0 || !ctx->object)
12401 : : return ret;
12402 : 0 : if (ctx->port >= RTE_MAX_ETHPORTS) {
12403 : : printf("Bad port\n");
12404 : 0 : return -1;
12405 : : }
12406 : 0 : if (offset == offsetof(struct rte_flow_item_flex, handle)) {
12407 : : const struct flex_item *fp;
12408 : : spec = ctx->object;
12409 : 0 : handle = (uint16_t)(uintptr_t)spec->handle;
12410 : 0 : if (handle >= FLEX_MAX_PARSERS_NUM) {
12411 : : printf("Bad flex item handle\n");
12412 : 0 : return -1;
12413 : : }
12414 : 0 : fp = flex_items[ctx->port][handle];
12415 : 0 : if (!fp) {
12416 : : printf("Bad flex item handle\n");
12417 : 0 : return -1;
12418 : : }
12419 : 0 : spec->handle = fp->flex_handle;
12420 : : mask = spec + 2; /* spec, last, mask */
12421 : 0 : mask->handle = fp->flex_handle;
12422 : 0 : } else if (offset == offsetof(struct rte_flow_item_flex, pattern)) {
12423 : 0 : handle = (uint16_t)(uintptr_t)
12424 : 0 : ((struct rte_flow_item_flex *)ctx->object)->pattern;
12425 : 0 : if (handle >= FLEX_MAX_PATTERNS_NUM) {
12426 : : printf("Bad pattern handle\n");
12427 : 0 : return -1;
12428 : : }
12429 : 0 : src_spec = &flex_patterns[handle].spec;
12430 : : src_mask = &flex_patterns[handle].mask;
12431 : : spec = ctx->object;
12432 : : mask = spec + 2; /* spec, last, mask */
12433 : : /* fill flow rule spec and mask parameters */
12434 : 0 : spec->length = src_spec->length;
12435 : 0 : spec->pattern = src_spec->pattern;
12436 : 0 : mask->length = src_mask->length;
12437 : 0 : mask->pattern = src_mask->pattern;
12438 : : } else {
12439 : : printf("Bad arguments - unknown flex item offset\n");
12440 : 0 : return -1;
12441 : : }
12442 : : return ret;
12443 : : }
12444 : :
12445 : : /** Parse Meter color name */
12446 : : static int
12447 : 0 : parse_meter_color(struct context *ctx, const struct token *token,
12448 : : const char *str, unsigned int len, void *buf,
12449 : : unsigned int size)
12450 : : {
12451 : : unsigned int i;
12452 : : struct buffer *out = buf;
12453 : :
12454 : : (void)token;
12455 : : (void)buf;
12456 : : (void)size;
12457 : 0 : for (i = 0; meter_colors[i]; ++i)
12458 : 0 : if (!strcmp_partial(meter_colors[i], str, len))
12459 : : break;
12460 : 0 : if (!meter_colors[i])
12461 : : return -1;
12462 : 0 : if (!ctx->object)
12463 : 0 : return len;
12464 : 0 : if (ctx->prev == ACTION_METER_MARK_CONF_COLOR) {
12465 : 0 : struct rte_flow_action *action =
12466 : 0 : out->args.vc.actions + out->args.vc.actions_n - 1;
12467 : : const struct arg *arg = pop_args(ctx);
12468 : :
12469 : 0 : if (!arg)
12470 : 0 : return -1;
12471 : 0 : *(int *)RTE_PTR_ADD(action->conf, arg->offset) = i;
12472 : : } else {
12473 : : ((struct rte_flow_item_meter_color *)
12474 : 0 : ctx->object)->color = (enum rte_color)i;
12475 : : }
12476 : 0 : return len;
12477 : : }
12478 : :
12479 : : /** Parse Insertion Table Type name */
12480 : : static int
12481 : 0 : parse_insertion_table_type(struct context *ctx, const struct token *token,
12482 : : const char *str, unsigned int len, void *buf,
12483 : : unsigned int size)
12484 : : {
12485 : : const struct arg *arg = pop_args(ctx);
12486 : : unsigned int i;
12487 : : char tmp[2];
12488 : : int ret;
12489 : :
12490 : : (void)size;
12491 : : /* Argument is expected. */
12492 : 0 : if (!arg)
12493 : 0 : return -1;
12494 : 0 : for (i = 0; table_insertion_types[i]; ++i)
12495 : 0 : if (!strcmp_partial(table_insertion_types[i], str, len))
12496 : : break;
12497 : 0 : if (!table_insertion_types[i])
12498 : : return -1;
12499 : : push_args(ctx, arg);
12500 : : snprintf(tmp, sizeof(tmp), "%u", i);
12501 : 0 : ret = parse_int(ctx, token, tmp, strlen(tmp), buf, sizeof(i));
12502 : 0 : return ret > 0 ? (int)len : ret;
12503 : : }
12504 : :
12505 : : /** Parse Hash Calculation Table Type name */
12506 : : static int
12507 : 0 : parse_hash_table_type(struct context *ctx, const struct token *token,
12508 : : const char *str, unsigned int len, void *buf,
12509 : : unsigned int size)
12510 : : {
12511 : : const struct arg *arg = pop_args(ctx);
12512 : : unsigned int i;
12513 : : char tmp[2];
12514 : : int ret;
12515 : :
12516 : : (void)size;
12517 : : /* Argument is expected. */
12518 : 0 : if (!arg)
12519 : 0 : return -1;
12520 : 0 : for (i = 0; table_hash_funcs[i]; ++i)
12521 : 0 : if (!strcmp_partial(table_hash_funcs[i], str, len))
12522 : : break;
12523 : 0 : if (!table_hash_funcs[i])
12524 : : return -1;
12525 : : push_args(ctx, arg);
12526 : : snprintf(tmp, sizeof(tmp), "%u", i);
12527 : 0 : ret = parse_int(ctx, token, tmp, strlen(tmp), buf, sizeof(i));
12528 : 0 : return ret > 0 ? (int)len : ret;
12529 : : }
12530 : :
12531 : : static int
12532 : 0 : parse_name_to_index(struct context *ctx, const struct token *token,
12533 : : const char *str, unsigned int len, void *buf,
12534 : : unsigned int size,
12535 : : const char *const names[], size_t names_size, uint32_t *dst)
12536 : : {
12537 : : int ret;
12538 : : uint32_t i;
12539 : :
12540 : : RTE_SET_USED(token);
12541 : : RTE_SET_USED(buf);
12542 : : RTE_SET_USED(size);
12543 : 0 : if (!ctx->object)
12544 : 0 : return len;
12545 : 0 : for (i = 0; i < names_size; i++) {
12546 : 0 : if (!names[i])
12547 : 0 : continue;
12548 : 0 : ret = strcmp_partial(names[i], str,
12549 : 0 : RTE_MIN(len, strlen(names[i])));
12550 : 0 : if (!ret) {
12551 : 0 : *dst = i;
12552 : 0 : return len;
12553 : : }
12554 : : }
12555 : : return -1;
12556 : : }
12557 : :
12558 : : static const char *const quota_mode_names[] = {
12559 : : NULL,
12560 : : [RTE_FLOW_QUOTA_MODE_PACKET] = "packet",
12561 : : [RTE_FLOW_QUOTA_MODE_L2] = "l2",
12562 : : [RTE_FLOW_QUOTA_MODE_L3] = "l3"
12563 : : };
12564 : :
12565 : : static const char *const quota_state_names[] = {
12566 : : [RTE_FLOW_QUOTA_STATE_PASS] = "pass",
12567 : : [RTE_FLOW_QUOTA_STATE_BLOCK] = "block"
12568 : : };
12569 : :
12570 : : static const char *const quota_update_names[] = {
12571 : : [RTE_FLOW_UPDATE_QUOTA_SET] = "set",
12572 : : [RTE_FLOW_UPDATE_QUOTA_ADD] = "add"
12573 : : };
12574 : :
12575 : : static const char *const query_update_mode_names[] = {
12576 : : [RTE_FLOW_QU_QUERY_FIRST] = "query_first",
12577 : : [RTE_FLOW_QU_UPDATE_FIRST] = "update_first"
12578 : : };
12579 : :
12580 : : static int
12581 : 0 : parse_quota_state_name(struct context *ctx, const struct token *token,
12582 : : const char *str, unsigned int len, void *buf,
12583 : : unsigned int size)
12584 : : {
12585 : 0 : struct rte_flow_item_quota *quota = ctx->object;
12586 : :
12587 : 0 : return parse_name_to_index(ctx, token, str, len, buf, size,
12588 : : quota_state_names,
12589 : : RTE_DIM(quota_state_names),
12590 : 0 : (uint32_t *)"a->state);
12591 : : }
12592 : :
12593 : : static int
12594 : 0 : parse_quota_mode_name(struct context *ctx, const struct token *token,
12595 : : const char *str, unsigned int len, void *buf,
12596 : : unsigned int size)
12597 : : {
12598 : 0 : struct rte_flow_action_quota *quota = ctx->object;
12599 : :
12600 : 0 : return parse_name_to_index(ctx, token, str, len, buf, size,
12601 : : quota_mode_names,
12602 : : RTE_DIM(quota_mode_names),
12603 : 0 : (uint32_t *)"a->mode);
12604 : : }
12605 : :
12606 : : static int
12607 : 0 : parse_quota_update_name(struct context *ctx, const struct token *token,
12608 : : const char *str, unsigned int len, void *buf,
12609 : : unsigned int size)
12610 : : {
12611 : 0 : struct rte_flow_update_quota *update = ctx->object;
12612 : :
12613 : 0 : return parse_name_to_index(ctx, token, str, len, buf, size,
12614 : : quota_update_names,
12615 : : RTE_DIM(quota_update_names),
12616 : 0 : (uint32_t *)&update->op);
12617 : : }
12618 : :
12619 : : static int
12620 : 0 : parse_qu_mode_name(struct context *ctx, const struct token *token,
12621 : : const char *str, unsigned int len, void *buf,
12622 : : unsigned int size)
12623 : : {
12624 : 0 : struct buffer *out = ctx->object;
12625 : :
12626 : 0 : return parse_name_to_index(ctx, token, str, len, buf, size,
12627 : : query_update_mode_names,
12628 : : RTE_DIM(query_update_mode_names),
12629 : 0 : (uint32_t *)&out->args.ia.qu_mode);
12630 : : }
12631 : :
12632 : : /** No completion. */
12633 : : static int
12634 : 0 : comp_none(struct context *ctx, const struct token *token,
12635 : : unsigned int ent, char *buf, unsigned int size)
12636 : : {
12637 : : (void)ctx;
12638 : : (void)token;
12639 : : (void)ent;
12640 : : (void)buf;
12641 : : (void)size;
12642 : 0 : return 0;
12643 : : }
12644 : :
12645 : : /** Complete boolean values. */
12646 : : static int
12647 : 0 : comp_boolean(struct context *ctx, const struct token *token,
12648 : : unsigned int ent, char *buf, unsigned int size)
12649 : : {
12650 : : unsigned int i;
12651 : :
12652 : : (void)ctx;
12653 : : (void)token;
12654 : 0 : for (i = 0; boolean_name[i]; ++i)
12655 : 0 : if (buf && i == ent)
12656 : 0 : return strlcpy(buf, boolean_name[i], size);
12657 : 0 : if (buf)
12658 : : return -1;
12659 : 0 : return i;
12660 : : }
12661 : :
12662 : : /** Complete action names. */
12663 : : static int
12664 : 0 : comp_action(struct context *ctx, const struct token *token,
12665 : : unsigned int ent, char *buf, unsigned int size)
12666 : : {
12667 : : unsigned int i;
12668 : :
12669 : : (void)ctx;
12670 : : (void)token;
12671 : 0 : for (i = 0; next_action[i]; ++i)
12672 : 0 : if (buf && i == ent)
12673 : 0 : return strlcpy(buf, token_list[next_action[i]].name,
12674 : : size);
12675 : 0 : if (buf)
12676 : : return -1;
12677 : 0 : return i;
12678 : : }
12679 : :
12680 : : /** Complete available ports. */
12681 : : static int
12682 : 0 : comp_port(struct context *ctx, const struct token *token,
12683 : : unsigned int ent, char *buf, unsigned int size)
12684 : : {
12685 : : unsigned int i = 0;
12686 : : portid_t p;
12687 : :
12688 : : (void)ctx;
12689 : : (void)token;
12690 : 0 : RTE_ETH_FOREACH_DEV(p) {
12691 : 0 : if (buf && i == ent)
12692 : 0 : return snprintf(buf, size, "%u", p);
12693 : 0 : ++i;
12694 : : }
12695 : 0 : if (buf)
12696 : : return -1;
12697 : 0 : return i;
12698 : : }
12699 : :
12700 : : /** Complete available rule IDs. */
12701 : : static int
12702 : 0 : comp_rule_id(struct context *ctx, const struct token *token,
12703 : : unsigned int ent, char *buf, unsigned int size)
12704 : : {
12705 : : unsigned int i = 0;
12706 : : struct rte_port *port;
12707 : : struct port_flow *pf;
12708 : :
12709 : : (void)token;
12710 : 0 : if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
12711 : 0 : ctx->port == (portid_t)RTE_PORT_ALL)
12712 : : return -1;
12713 : 0 : port = &ports[ctx->port];
12714 : 0 : for (pf = port->flow_list; pf != NULL; pf = pf->next) {
12715 : 0 : if (buf && i == ent)
12716 : 0 : return snprintf(buf, size, "%"PRIu64, pf->id);
12717 : 0 : ++i;
12718 : : }
12719 : 0 : if (buf)
12720 : : return -1;
12721 : 0 : return i;
12722 : : }
12723 : :
12724 : : /** Complete operation for compare match item. */
12725 : : static int
12726 : 0 : comp_set_compare_op(struct context *ctx, const struct token *token,
12727 : : unsigned int ent, char *buf, unsigned int size)
12728 : : {
12729 : : RTE_SET_USED(ctx);
12730 : : RTE_SET_USED(token);
12731 : 0 : if (!buf)
12732 : : return RTE_DIM(compare_ops);
12733 : 0 : if (ent < RTE_DIM(compare_ops) - 1)
12734 : 0 : return strlcpy(buf, compare_ops[ent], size);
12735 : : return -1;
12736 : : }
12737 : :
12738 : : /** Complete field id for compare match item. */
12739 : : static int
12740 : 0 : comp_set_compare_field_id(struct context *ctx, const struct token *token,
12741 : : unsigned int ent, char *buf, unsigned int size)
12742 : : {
12743 : : const char *name;
12744 : :
12745 : : RTE_SET_USED(token);
12746 : 0 : if (!buf)
12747 : : return RTE_DIM(flow_field_ids);
12748 : 0 : if (ent >= RTE_DIM(flow_field_ids) - 1)
12749 : : return -1;
12750 : 0 : name = flow_field_ids[ent];
12751 : 0 : if (ctx->curr == ITEM_COMPARE_FIELD_B_TYPE ||
12752 : 0 : (strcmp(name, "pointer") && strcmp(name, "value")))
12753 : 0 : return strlcpy(buf, name, size);
12754 : : return -1;
12755 : : }
12756 : :
12757 : : /** Complete type field for RSS action. */
12758 : : static int
12759 : 0 : comp_vc_action_rss_type(struct context *ctx, const struct token *token,
12760 : : unsigned int ent, char *buf, unsigned int size)
12761 : : {
12762 : : unsigned int i;
12763 : :
12764 : : (void)ctx;
12765 : : (void)token;
12766 : 0 : for (i = 0; rss_type_table[i].str; ++i)
12767 : : ;
12768 : 0 : if (!buf)
12769 : 0 : return i + 1;
12770 : 0 : if (ent < i)
12771 : 0 : return strlcpy(buf, rss_type_table[ent].str, size);
12772 : 0 : if (ent == i)
12773 : 0 : return snprintf(buf, size, "end");
12774 : : return -1;
12775 : : }
12776 : :
12777 : : /** Complete queue field for RSS action. */
12778 : : static int
12779 : 0 : comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
12780 : : unsigned int ent, char *buf, unsigned int size)
12781 : : {
12782 : : (void)ctx;
12783 : : (void)token;
12784 : 0 : if (!buf)
12785 : 0 : return nb_rxq + 1;
12786 : 0 : if (ent < nb_rxq)
12787 : 0 : return snprintf(buf, size, "%u", ent);
12788 : 0 : if (ent == nb_rxq)
12789 : 0 : return snprintf(buf, size, "end");
12790 : : return -1;
12791 : : }
12792 : :
12793 : : /** Complete index number for set raw_encap/raw_decap commands. */
12794 : : static int
12795 : 0 : comp_set_raw_index(struct context *ctx, const struct token *token,
12796 : : unsigned int ent, char *buf, unsigned int size)
12797 : : {
12798 : : uint16_t idx = 0;
12799 : : uint16_t nb = 0;
12800 : :
12801 : : RTE_SET_USED(ctx);
12802 : : RTE_SET_USED(token);
12803 : 0 : for (idx = 0; idx < RAW_ENCAP_CONFS_MAX_NUM; ++idx) {
12804 : 0 : if (buf && idx == ent)
12805 : 0 : return snprintf(buf, size, "%u", idx);
12806 : 0 : ++nb;
12807 : : }
12808 : : return nb;
12809 : : }
12810 : :
12811 : : /** Complete index number for set raw_ipv6_ext_push/ipv6_ext_remove commands. */
12812 : : static int
12813 : 0 : comp_set_ipv6_ext_index(struct context *ctx, const struct token *token,
12814 : : unsigned int ent, char *buf, unsigned int size)
12815 : : {
12816 : : uint16_t idx = 0;
12817 : : uint16_t nb = 0;
12818 : :
12819 : : RTE_SET_USED(ctx);
12820 : : RTE_SET_USED(token);
12821 : 0 : for (idx = 0; idx < IPV6_EXT_PUSH_CONFS_MAX_NUM; ++idx) {
12822 : 0 : if (buf && idx == ent)
12823 : 0 : return snprintf(buf, size, "%u", idx);
12824 : 0 : ++nb;
12825 : : }
12826 : : return nb;
12827 : : }
12828 : :
12829 : : /** Complete index number for set raw_encap/raw_decap commands. */
12830 : : static int
12831 : 0 : comp_set_sample_index(struct context *ctx, const struct token *token,
12832 : : unsigned int ent, char *buf, unsigned int size)
12833 : : {
12834 : : uint16_t idx = 0;
12835 : : uint16_t nb = 0;
12836 : :
12837 : : RTE_SET_USED(ctx);
12838 : : RTE_SET_USED(token);
12839 : 0 : for (idx = 0; idx < RAW_SAMPLE_CONFS_MAX_NUM; ++idx) {
12840 : 0 : if (buf && idx == ent)
12841 : 0 : return snprintf(buf, size, "%u", idx);
12842 : 0 : ++nb;
12843 : : }
12844 : : return nb;
12845 : : }
12846 : :
12847 : : /** Complete operation for modify_field command. */
12848 : : static int
12849 : 0 : comp_set_modify_field_op(struct context *ctx, const struct token *token,
12850 : : unsigned int ent, char *buf, unsigned int size)
12851 : : {
12852 : : RTE_SET_USED(ctx);
12853 : : RTE_SET_USED(token);
12854 : 0 : if (!buf)
12855 : : return RTE_DIM(modify_field_ops);
12856 : 0 : if (ent < RTE_DIM(modify_field_ops) - 1)
12857 : 0 : return strlcpy(buf, modify_field_ops[ent], size);
12858 : : return -1;
12859 : : }
12860 : :
12861 : : /** Complete field id for modify_field command. */
12862 : : static int
12863 : 0 : comp_set_modify_field_id(struct context *ctx, const struct token *token,
12864 : : unsigned int ent, char *buf, unsigned int size)
12865 : : {
12866 : : const char *name;
12867 : :
12868 : : RTE_SET_USED(token);
12869 : 0 : if (!buf)
12870 : : return RTE_DIM(flow_field_ids);
12871 : 0 : if (ent >= RTE_DIM(flow_field_ids) - 1)
12872 : : return -1;
12873 : 0 : name = flow_field_ids[ent];
12874 : 0 : if (ctx->curr == ACTION_MODIFY_FIELD_SRC_TYPE ||
12875 : 0 : (strcmp(name, "pointer") && strcmp(name, "value")))
12876 : 0 : return strlcpy(buf, name, size);
12877 : : return -1;
12878 : : }
12879 : :
12880 : : /** Complete available pattern template IDs. */
12881 : : static int
12882 : 0 : comp_pattern_template_id(struct context *ctx, const struct token *token,
12883 : : unsigned int ent, char *buf, unsigned int size)
12884 : : {
12885 : : unsigned int i = 0;
12886 : : struct rte_port *port;
12887 : : struct port_template *pt;
12888 : :
12889 : : (void)token;
12890 : 0 : if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
12891 : 0 : ctx->port == (portid_t)RTE_PORT_ALL)
12892 : : return -1;
12893 : 0 : port = &ports[ctx->port];
12894 : 0 : for (pt = port->pattern_templ_list; pt != NULL; pt = pt->next) {
12895 : 0 : if (buf && i == ent)
12896 : 0 : return snprintf(buf, size, "%u", pt->id);
12897 : 0 : ++i;
12898 : : }
12899 : 0 : if (buf)
12900 : : return -1;
12901 : 0 : return i;
12902 : : }
12903 : :
12904 : : /** Complete available actions template IDs. */
12905 : : static int
12906 : 0 : comp_actions_template_id(struct context *ctx, const struct token *token,
12907 : : unsigned int ent, char *buf, unsigned int size)
12908 : : {
12909 : : unsigned int i = 0;
12910 : : struct rte_port *port;
12911 : : struct port_template *pt;
12912 : :
12913 : : (void)token;
12914 : 0 : if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
12915 : 0 : ctx->port == (portid_t)RTE_PORT_ALL)
12916 : : return -1;
12917 : 0 : port = &ports[ctx->port];
12918 : 0 : for (pt = port->actions_templ_list; pt != NULL; pt = pt->next) {
12919 : 0 : if (buf && i == ent)
12920 : 0 : return snprintf(buf, size, "%u", pt->id);
12921 : 0 : ++i;
12922 : : }
12923 : 0 : if (buf)
12924 : : return -1;
12925 : 0 : return i;
12926 : : }
12927 : :
12928 : : /** Complete available table IDs. */
12929 : : static int
12930 : 0 : comp_table_id(struct context *ctx, const struct token *token,
12931 : : unsigned int ent, char *buf, unsigned int size)
12932 : : {
12933 : : unsigned int i = 0;
12934 : : struct rte_port *port;
12935 : : struct port_table *pt;
12936 : :
12937 : : (void)token;
12938 : 0 : if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
12939 : 0 : ctx->port == (portid_t)RTE_PORT_ALL)
12940 : : return -1;
12941 : 0 : port = &ports[ctx->port];
12942 : 0 : for (pt = port->table_list; pt != NULL; pt = pt->next) {
12943 : 0 : if (buf && i == ent)
12944 : 0 : return snprintf(buf, size, "%u", pt->id);
12945 : 0 : ++i;
12946 : : }
12947 : 0 : if (buf)
12948 : : return -1;
12949 : 0 : return i;
12950 : : }
12951 : :
12952 : : /** Complete available queue IDs. */
12953 : : static int
12954 : 0 : comp_queue_id(struct context *ctx, const struct token *token,
12955 : : unsigned int ent, char *buf, unsigned int size)
12956 : : {
12957 : : unsigned int i = 0;
12958 : : struct rte_port *port;
12959 : :
12960 : : (void)token;
12961 : 0 : if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
12962 : 0 : ctx->port == (portid_t)RTE_PORT_ALL)
12963 : : return -1;
12964 : 0 : port = &ports[ctx->port];
12965 : 0 : for (i = 0; i < port->queue_nb; i++) {
12966 : 0 : if (buf && i == ent)
12967 : 0 : return snprintf(buf, size, "%u", i);
12968 : : }
12969 : 0 : if (buf)
12970 : : return -1;
12971 : 0 : return i;
12972 : : }
12973 : :
12974 : : static int
12975 : : comp_names_to_index(struct context *ctx, const struct token *token,
12976 : : unsigned int ent, char *buf, unsigned int size,
12977 : : const char *const names[], size_t names_size)
12978 : : {
12979 : : RTE_SET_USED(ctx);
12980 : : RTE_SET_USED(token);
12981 : 0 : if (!buf)
12982 : : return names_size;
12983 : 0 : if (ent < names_size && names[ent] != NULL)
12984 : 0 : return rte_strscpy(buf, names[ent], size);
12985 : : return -1;
12986 : :
12987 : : }
12988 : :
12989 : : /** Complete available Meter colors. */
12990 : : static int
12991 : 0 : comp_meter_color(struct context *ctx, const struct token *token,
12992 : : unsigned int ent, char *buf, unsigned int size)
12993 : : {
12994 : : RTE_SET_USED(ctx);
12995 : : RTE_SET_USED(token);
12996 : 0 : if (!buf)
12997 : : return RTE_DIM(meter_colors);
12998 : 0 : if (ent < RTE_DIM(meter_colors) - 1)
12999 : 0 : return strlcpy(buf, meter_colors[ent], size);
13000 : : return -1;
13001 : : }
13002 : :
13003 : : /** Complete available Insertion Table types. */
13004 : : static int
13005 : 0 : comp_insertion_table_type(struct context *ctx, const struct token *token,
13006 : : unsigned int ent, char *buf, unsigned int size)
13007 : : {
13008 : : RTE_SET_USED(ctx);
13009 : : RTE_SET_USED(token);
13010 : 0 : if (!buf)
13011 : : return RTE_DIM(table_insertion_types);
13012 : 0 : if (ent < RTE_DIM(table_insertion_types) - 1)
13013 : 0 : return rte_strscpy(buf, table_insertion_types[ent], size);
13014 : : return -1;
13015 : : }
13016 : :
13017 : : /** Complete available Hash Calculation Table types. */
13018 : : static int
13019 : 0 : comp_hash_table_type(struct context *ctx, const struct token *token,
13020 : : unsigned int ent, char *buf, unsigned int size)
13021 : : {
13022 : : RTE_SET_USED(ctx);
13023 : : RTE_SET_USED(token);
13024 : 0 : if (!buf)
13025 : : return RTE_DIM(table_hash_funcs);
13026 : 0 : if (ent < RTE_DIM(table_hash_funcs) - 1)
13027 : 0 : return rte_strscpy(buf, table_hash_funcs[ent], size);
13028 : : return -1;
13029 : : }
13030 : :
13031 : : static int
13032 : 0 : comp_quota_state_name(struct context *ctx, const struct token *token,
13033 : : unsigned int ent, char *buf, unsigned int size)
13034 : : {
13035 : 0 : return comp_names_to_index(ctx, token, ent, buf, size,
13036 : : quota_state_names,
13037 : : RTE_DIM(quota_state_names));
13038 : : }
13039 : :
13040 : : static int
13041 : 0 : comp_quota_mode_name(struct context *ctx, const struct token *token,
13042 : : unsigned int ent, char *buf, unsigned int size)
13043 : : {
13044 : 0 : return comp_names_to_index(ctx, token, ent, buf, size,
13045 : : quota_mode_names,
13046 : : RTE_DIM(quota_mode_names));
13047 : : }
13048 : :
13049 : : static int
13050 : 0 : comp_quota_update_name(struct context *ctx, const struct token *token,
13051 : : unsigned int ent, char *buf, unsigned int size)
13052 : : {
13053 : 0 : return comp_names_to_index(ctx, token, ent, buf, size,
13054 : : quota_update_names,
13055 : : RTE_DIM(quota_update_names));
13056 : : }
13057 : :
13058 : : static int
13059 : 0 : comp_qu_mode_name(struct context *ctx, const struct token *token,
13060 : : unsigned int ent, char *buf, unsigned int size)
13061 : : {
13062 : 0 : return comp_names_to_index(ctx, token, ent, buf, size,
13063 : : query_update_mode_names,
13064 : : RTE_DIM(query_update_mode_names));
13065 : : }
13066 : :
13067 : : /** Internal context. */
13068 : : static struct context cmd_flow_context;
13069 : :
13070 : : /** Global parser instance (cmdline API). */
13071 : : cmdline_parse_inst_t cmd_flow;
13072 : : cmdline_parse_inst_t cmd_set_raw;
13073 : :
13074 : : /** Initialize context. */
13075 : : static void
13076 : : cmd_flow_context_init(struct context *ctx)
13077 : : {
13078 : : /* A full memset() is not necessary. */
13079 : 0 : ctx->curr = ZERO;
13080 : 0 : ctx->prev = ZERO;
13081 : 0 : ctx->next_num = 0;
13082 : 0 : ctx->args_num = 0;
13083 : 0 : ctx->eol = 0;
13084 : 0 : ctx->last = 0;
13085 : 0 : ctx->port = 0;
13086 : 0 : ctx->objdata = 0;
13087 : 0 : ctx->object = NULL;
13088 : 0 : ctx->objmask = NULL;
13089 : 0 : }
13090 : :
13091 : : /** Parse a token (cmdline API). */
13092 : : static int
13093 : 0 : cmd_flow_parse(cmdline_parse_token_hdr_t *hdr, const char *src, void *result,
13094 : : unsigned int size)
13095 : : {
13096 : : struct context *ctx = &cmd_flow_context;
13097 : : const struct token *token;
13098 : : const enum index *list;
13099 : : int len;
13100 : : int i;
13101 : :
13102 : : (void)hdr;
13103 : 0 : token = &token_list[ctx->curr];
13104 : : /* Check argument length. */
13105 : 0 : ctx->eol = 0;
13106 : 0 : ctx->last = 1;
13107 : 0 : for (len = 0; src[len]; ++len)
13108 : 0 : if (src[len] == '#' || isspace(src[len]))
13109 : : break;
13110 : 0 : if (!len)
13111 : : return -1;
13112 : : /* Last argument and EOL detection. */
13113 : 0 : for (i = len; src[i]; ++i)
13114 : 0 : if (src[i] == '#' || src[i] == '\r' || src[i] == '\n')
13115 : : break;
13116 : 0 : else if (!isspace(src[i])) {
13117 : 0 : ctx->last = 0;
13118 : 0 : break;
13119 : : }
13120 : 0 : for (; src[i]; ++i)
13121 : 0 : if (src[i] == '\r' || src[i] == '\n') {
13122 : 0 : ctx->eol = 1;
13123 : 0 : break;
13124 : : }
13125 : : /* Initialize context if necessary. */
13126 : 0 : if (!ctx->next_num) {
13127 : 0 : if (!token->next)
13128 : : return 0;
13129 : 0 : ctx->next[ctx->next_num++] = token->next[0];
13130 : : }
13131 : : /* Process argument through candidates. */
13132 : 0 : ctx->prev = ctx->curr;
13133 : 0 : list = ctx->next[ctx->next_num - 1];
13134 : 0 : for (i = 0; list[i]; ++i) {
13135 : 0 : const struct token *next = &token_list[list[i]];
13136 : : int tmp;
13137 : :
13138 : 0 : ctx->curr = list[i];
13139 : 0 : if (next->call)
13140 : 0 : tmp = next->call(ctx, next, src, len, result, size);
13141 : : else
13142 : : tmp = parse_default(ctx, next, src, len, result, size);
13143 : 0 : if (tmp == -1 || tmp != len)
13144 : : continue;
13145 : : token = next;
13146 : : break;
13147 : : }
13148 : 0 : if (!list[i])
13149 : : return -1;
13150 : 0 : --ctx->next_num;
13151 : : /* Push subsequent tokens if any. */
13152 : 0 : if (token->next)
13153 : 0 : for (i = 0; token->next[i]; ++i) {
13154 : 0 : if (ctx->next_num == RTE_DIM(ctx->next))
13155 : : return -1;
13156 : 0 : ctx->next[ctx->next_num++] = token->next[i];
13157 : : }
13158 : : /* Push arguments if any. */
13159 : 0 : if (token->args)
13160 : 0 : for (i = 0; token->args[i]; ++i) {
13161 : 0 : if (ctx->args_num == RTE_DIM(ctx->args))
13162 : : return -1;
13163 : 0 : ctx->args[ctx->args_num++] = token->args[i];
13164 : : }
13165 : : return len;
13166 : : }
13167 : :
13168 : : int
13169 : 0 : flow_parse(const char *src, void *result, unsigned int size,
13170 : : struct rte_flow_attr **attr,
13171 : : struct rte_flow_item **pattern, struct rte_flow_action **actions)
13172 : : {
13173 : : int ret;
13174 : 0 : struct context saved_flow_ctx = cmd_flow_context;
13175 : :
13176 : : cmd_flow_context_init(&cmd_flow_context);
13177 : : do {
13178 : 0 : ret = cmd_flow_parse(NULL, src, result, size);
13179 : 0 : if (ret > 0) {
13180 : 0 : src += ret;
13181 : 0 : while (isspace(*src))
13182 : 0 : src++;
13183 : : }
13184 : 0 : } while (ret > 0 && strlen(src));
13185 : 0 : cmd_flow_context = saved_flow_ctx;
13186 : 0 : *attr = &((struct buffer *)result)->args.vc.attr;
13187 : 0 : *pattern = ((struct buffer *)result)->args.vc.pattern;
13188 : 0 : *actions = ((struct buffer *)result)->args.vc.actions;
13189 : 0 : return (ret >= 0 && !strlen(src)) ? 0 : -1;
13190 : : }
13191 : :
13192 : : /** Return number of completion entries (cmdline API). */
13193 : : static int
13194 : 0 : cmd_flow_complete_get_nb(cmdline_parse_token_hdr_t *hdr)
13195 : : {
13196 : : struct context *ctx = &cmd_flow_context;
13197 : 0 : const struct token *token = &token_list[ctx->curr];
13198 : : const enum index *list;
13199 : : int i;
13200 : :
13201 : : (void)hdr;
13202 : : /* Count number of tokens in current list. */
13203 : 0 : if (ctx->next_num)
13204 : 0 : list = ctx->next[ctx->next_num - 1];
13205 : : else
13206 : 0 : list = token->next[0];
13207 : 0 : for (i = 0; list[i]; ++i)
13208 : : ;
13209 : 0 : if (!i)
13210 : : return 0;
13211 : : /*
13212 : : * If there is a single token, use its completion callback, otherwise
13213 : : * return the number of entries.
13214 : : */
13215 : 0 : token = &token_list[list[0]];
13216 : 0 : if (i == 1 && token->comp) {
13217 : : /* Save index for cmd_flow_get_help(). */
13218 : 0 : ctx->prev = list[0];
13219 : 0 : return token->comp(ctx, token, 0, NULL, 0);
13220 : : }
13221 : : return i;
13222 : : }
13223 : :
13224 : : /** Return a completion entry (cmdline API). */
13225 : : static int
13226 : 0 : cmd_flow_complete_get_elt(cmdline_parse_token_hdr_t *hdr, int index,
13227 : : char *dst, unsigned int size)
13228 : : {
13229 : : struct context *ctx = &cmd_flow_context;
13230 : 0 : const struct token *token = &token_list[ctx->curr];
13231 : : const enum index *list;
13232 : : int i;
13233 : :
13234 : : (void)hdr;
13235 : : /* Count number of tokens in current list. */
13236 : 0 : if (ctx->next_num)
13237 : 0 : list = ctx->next[ctx->next_num - 1];
13238 : : else
13239 : 0 : list = token->next[0];
13240 : 0 : for (i = 0; list[i]; ++i)
13241 : : ;
13242 : 0 : if (!i)
13243 : : return -1;
13244 : : /* If there is a single token, use its completion callback. */
13245 : 0 : token = &token_list[list[0]];
13246 : 0 : if (i == 1 && token->comp) {
13247 : : /* Save index for cmd_flow_get_help(). */
13248 : 0 : ctx->prev = list[0];
13249 : 0 : return token->comp(ctx, token, index, dst, size) < 0 ? -1 : 0;
13250 : : }
13251 : : /* Otherwise make sure the index is valid and use defaults. */
13252 : 0 : if (index >= i)
13253 : : return -1;
13254 : 0 : token = &token_list[list[index]];
13255 : 0 : strlcpy(dst, token->name, size);
13256 : : /* Save index for cmd_flow_get_help(). */
13257 : 0 : ctx->prev = list[index];
13258 : 0 : return 0;
13259 : : }
13260 : :
13261 : : /** Populate help strings for current token (cmdline API). */
13262 : : static int
13263 : 0 : cmd_flow_get_help(cmdline_parse_token_hdr_t *hdr, char *dst, unsigned int size)
13264 : : {
13265 : : struct context *ctx = &cmd_flow_context;
13266 : 0 : const struct token *token = &token_list[ctx->prev];
13267 : :
13268 : : (void)hdr;
13269 : 0 : if (!size)
13270 : : return -1;
13271 : : /* Set token type and update global help with details. */
13272 : 0 : strlcpy(dst, (token->type ? token->type : "TOKEN"), size);
13273 : 0 : if (token->help)
13274 : 0 : cmd_flow.help_str = token->help;
13275 : : else
13276 : 0 : cmd_flow.help_str = token->name;
13277 : : return 0;
13278 : : }
13279 : :
13280 : : /** Token definition template (cmdline API). */
13281 : : static struct cmdline_token_hdr cmd_flow_token_hdr = {
13282 : : .ops = &(struct cmdline_token_ops){
13283 : : .parse = cmd_flow_parse,
13284 : : .complete_get_nb = cmd_flow_complete_get_nb,
13285 : : .complete_get_elt = cmd_flow_complete_get_elt,
13286 : : .get_help = cmd_flow_get_help,
13287 : : },
13288 : : .offset = 0,
13289 : : };
13290 : :
13291 : : /** Populate the next dynamic token. */
13292 : : static void
13293 : 0 : cmd_flow_tok(cmdline_parse_token_hdr_t **hdr,
13294 : : cmdline_parse_token_hdr_t **hdr_inst)
13295 : : {
13296 : : struct context *ctx = &cmd_flow_context;
13297 : :
13298 : : /* Always reinitialize context before requesting the first token. */
13299 : 0 : if (!(hdr_inst - cmd_flow.tokens))
13300 : : cmd_flow_context_init(ctx);
13301 : : /* Return NULL when no more tokens are expected. */
13302 : 0 : if (!ctx->next_num && ctx->curr) {
13303 : 0 : *hdr = NULL;
13304 : 0 : return;
13305 : : }
13306 : : /* Determine if command should end here. */
13307 : 0 : if (ctx->eol && ctx->last && ctx->next_num) {
13308 : 0 : const enum index *list = ctx->next[ctx->next_num - 1];
13309 : : int i;
13310 : :
13311 : 0 : for (i = 0; list[i]; ++i) {
13312 : 0 : if (list[i] != END)
13313 : : continue;
13314 : 0 : *hdr = NULL;
13315 : 0 : return;
13316 : : }
13317 : : }
13318 : 0 : *hdr = &cmd_flow_token_hdr;
13319 : : }
13320 : :
13321 : : static SLIST_HEAD(, indlst_conf) indlst_conf_head =
13322 : : SLIST_HEAD_INITIALIZER();
13323 : :
13324 : : static void
13325 : 0 : indirect_action_flow_conf_create(const struct buffer *in)
13326 : : {
13327 : : int len, ret;
13328 : : uint32_t i;
13329 : : struct indlst_conf *indlst_conf = NULL;
13330 : : size_t base = RTE_ALIGN(sizeof(*indlst_conf), 8);
13331 : 0 : struct rte_flow_action *src = in->args.vc.actions;
13332 : :
13333 : 0 : if (!in->args.vc.actions_n)
13334 : 0 : goto end;
13335 : 0 : len = rte_flow_conv(RTE_FLOW_CONV_OP_ACTIONS, NULL, 0, src, NULL);
13336 : 0 : if (len <= 0)
13337 : 0 : goto end;
13338 : 0 : len = RTE_ALIGN(len, 16);
13339 : :
13340 : 0 : indlst_conf = calloc(1, base + len +
13341 : 0 : in->args.vc.actions_n * sizeof(uintptr_t));
13342 : 0 : if (!indlst_conf)
13343 : 0 : goto end;
13344 : 0 : indlst_conf->id = in->args.vc.attr.group;
13345 : 0 : indlst_conf->conf_num = in->args.vc.actions_n - 1;
13346 : 0 : indlst_conf->actions = RTE_PTR_ADD(indlst_conf, base);
13347 : 0 : ret = rte_flow_conv(RTE_FLOW_CONV_OP_ACTIONS, indlst_conf->actions,
13348 : : len, src, NULL);
13349 : 0 : if (ret <= 0) {
13350 : 0 : free(indlst_conf);
13351 : : indlst_conf = NULL;
13352 : 0 : goto end;
13353 : : }
13354 : 0 : indlst_conf->conf = RTE_PTR_ADD(indlst_conf, base + len);
13355 : 0 : for (i = 0; i < indlst_conf->conf_num; i++)
13356 : 0 : indlst_conf->conf[i] = indlst_conf->actions[i].conf;
13357 : 0 : SLIST_INSERT_HEAD(&indlst_conf_head, indlst_conf, next);
13358 : 0 : end:
13359 : 0 : if (indlst_conf)
13360 : : printf("created indirect action list configuration %u\n",
13361 : 0 : in->args.vc.attr.group);
13362 : : else
13363 : : printf("cannot create indirect action list configuration %u\n",
13364 : 0 : in->args.vc.attr.group);
13365 : 0 : }
13366 : :
13367 : : static const struct indlst_conf *
13368 : : indirect_action_list_conf_get(uint32_t conf_id)
13369 : : {
13370 : : const struct indlst_conf *conf;
13371 : :
13372 : 0 : SLIST_FOREACH(conf, &indlst_conf_head, next) {
13373 : 0 : if (conf->id == conf_id)
13374 : : return conf;
13375 : : }
13376 : : return NULL;
13377 : : }
13378 : :
13379 : : /** Dispatch parsed buffer to function calls. */
13380 : : static void
13381 : 0 : cmd_flow_parsed(const struct buffer *in)
13382 : : {
13383 : 0 : switch (in->command) {
13384 : 0 : case INFO:
13385 : 0 : port_flow_get_info(in->port);
13386 : 0 : break;
13387 : 0 : case CONFIGURE:
13388 : 0 : port_flow_configure(in->port,
13389 : : &in->args.configure.port_attr,
13390 : 0 : in->args.configure.nb_queue,
13391 : : &in->args.configure.queue_attr);
13392 : 0 : break;
13393 : 0 : case PATTERN_TEMPLATE_CREATE:
13394 : 0 : port_flow_pattern_template_create(in->port,
13395 : 0 : in->args.vc.pat_templ_id,
13396 : 0 : &((const struct rte_flow_pattern_template_attr) {
13397 : 0 : .relaxed_matching = in->args.vc.attr.reserved,
13398 : 0 : .ingress = in->args.vc.attr.ingress,
13399 : 0 : .egress = in->args.vc.attr.egress,
13400 : 0 : .transfer = in->args.vc.attr.transfer,
13401 : : }),
13402 : 0 : in->args.vc.pattern);
13403 : 0 : break;
13404 : 0 : case PATTERN_TEMPLATE_DESTROY:
13405 : 0 : port_flow_pattern_template_destroy(in->port,
13406 : 0 : in->args.templ_destroy.template_id_n,
13407 : 0 : in->args.templ_destroy.template_id);
13408 : 0 : break;
13409 : 0 : case ACTIONS_TEMPLATE_CREATE:
13410 : 0 : port_flow_actions_template_create(in->port,
13411 : 0 : in->args.vc.act_templ_id,
13412 : 0 : &((const struct rte_flow_actions_template_attr) {
13413 : 0 : .ingress = in->args.vc.attr.ingress,
13414 : 0 : .egress = in->args.vc.attr.egress,
13415 : 0 : .transfer = in->args.vc.attr.transfer,
13416 : : }),
13417 : 0 : in->args.vc.actions,
13418 : 0 : in->args.vc.masks);
13419 : 0 : break;
13420 : 0 : case ACTIONS_TEMPLATE_DESTROY:
13421 : 0 : port_flow_actions_template_destroy(in->port,
13422 : 0 : in->args.templ_destroy.template_id_n,
13423 : 0 : in->args.templ_destroy.template_id);
13424 : 0 : break;
13425 : 0 : case TABLE_CREATE:
13426 : 0 : port_flow_template_table_create(in->port, in->args.table.id,
13427 : 0 : &in->args.table.attr, in->args.table.pat_templ_id_n,
13428 : 0 : in->args.table.pat_templ_id, in->args.table.act_templ_id_n,
13429 : 0 : in->args.table.act_templ_id);
13430 : 0 : break;
13431 : 0 : case TABLE_DESTROY:
13432 : 0 : port_flow_template_table_destroy(in->port,
13433 : 0 : in->args.table_destroy.table_id_n,
13434 : 0 : in->args.table_destroy.table_id);
13435 : 0 : break;
13436 : 0 : case TABLE_RESIZE_COMPLETE:
13437 : 0 : port_flow_template_table_resize_complete
13438 : 0 : (in->port, in->args.table_destroy.table_id[0]);
13439 : 0 : break;
13440 : 0 : case GROUP_SET_MISS_ACTIONS:
13441 : 0 : port_queue_group_set_miss_actions(in->port, &in->args.vc.attr,
13442 : 0 : in->args.vc.actions);
13443 : 0 : break;
13444 : 0 : case TABLE_RESIZE:
13445 : 0 : port_flow_template_table_resize(in->port, in->args.table.id,
13446 : 0 : in->args.table.attr.nb_flows);
13447 : 0 : break;
13448 : 0 : case QUEUE_CREATE:
13449 : 0 : port_queue_flow_create(in->port, in->queue, in->postpone,
13450 : 0 : in->args.vc.table_id, in->args.vc.rule_id,
13451 : 0 : in->args.vc.pat_templ_id, in->args.vc.act_templ_id,
13452 : 0 : in->args.vc.pattern, in->args.vc.actions);
13453 : 0 : break;
13454 : 0 : case QUEUE_DESTROY:
13455 : 0 : port_queue_flow_destroy(in->port, in->queue, in->postpone,
13456 : 0 : in->args.destroy.rule_n,
13457 : 0 : in->args.destroy.rule);
13458 : 0 : break;
13459 : 0 : case QUEUE_FLOW_UPDATE_RESIZED:
13460 : 0 : port_queue_flow_update_resized(in->port, in->queue,
13461 : 0 : in->postpone,
13462 : 0 : in->args.destroy.rule[0]);
13463 : 0 : break;
13464 : 0 : case QUEUE_UPDATE:
13465 : 0 : port_queue_flow_update(in->port, in->queue, in->postpone,
13466 : 0 : in->args.vc.rule_id, in->args.vc.act_templ_id,
13467 : 0 : in->args.vc.actions);
13468 : 0 : break;
13469 : 0 : case PUSH:
13470 : 0 : port_queue_flow_push(in->port, in->queue);
13471 : 0 : break;
13472 : 0 : case PULL:
13473 : 0 : port_queue_flow_pull(in->port, in->queue);
13474 : 0 : break;
13475 : 0 : case HASH:
13476 : 0 : if (!in->args.vc.encap_hash)
13477 : 0 : port_flow_hash_calc(in->port, in->args.vc.table_id,
13478 : 0 : in->args.vc.pat_templ_id,
13479 : 0 : in->args.vc.pattern);
13480 : : else
13481 : 0 : port_flow_hash_calc_encap(in->port, in->args.vc.field,
13482 : 0 : in->args.vc.pattern);
13483 : : break;
13484 : 0 : case QUEUE_AGED:
13485 : 0 : port_queue_flow_aged(in->port, in->queue,
13486 : 0 : in->args.aged.destroy);
13487 : 0 : break;
13488 : 0 : case QUEUE_INDIRECT_ACTION_CREATE:
13489 : : case QUEUE_INDIRECT_ACTION_LIST_CREATE:
13490 : 0 : port_queue_action_handle_create(
13491 : 0 : in->port, in->queue, in->postpone,
13492 : 0 : in->args.vc.attr.group,
13493 : : in->command == QUEUE_INDIRECT_ACTION_LIST_CREATE,
13494 : 0 : &((const struct rte_flow_indir_action_conf) {
13495 : 0 : .ingress = in->args.vc.attr.ingress,
13496 : 0 : .egress = in->args.vc.attr.egress,
13497 : 0 : .transfer = in->args.vc.attr.transfer,
13498 : : }),
13499 : 0 : in->args.vc.actions);
13500 : 0 : break;
13501 : 0 : case QUEUE_INDIRECT_ACTION_DESTROY:
13502 : 0 : port_queue_action_handle_destroy(in->port,
13503 : 0 : in->queue, in->postpone,
13504 : 0 : in->args.ia_destroy.action_id_n,
13505 : 0 : in->args.ia_destroy.action_id);
13506 : 0 : break;
13507 : 0 : case QUEUE_INDIRECT_ACTION_UPDATE:
13508 : 0 : port_queue_action_handle_update(in->port,
13509 : 0 : in->queue, in->postpone,
13510 : 0 : in->args.vc.attr.group,
13511 : 0 : in->args.vc.actions);
13512 : 0 : break;
13513 : 0 : case QUEUE_INDIRECT_ACTION_QUERY:
13514 : 0 : port_queue_action_handle_query(in->port,
13515 : 0 : in->queue, in->postpone,
13516 : 0 : in->args.ia.action_id);
13517 : 0 : break;
13518 : 0 : case QUEUE_INDIRECT_ACTION_QUERY_UPDATE:
13519 : 0 : port_queue_action_handle_query_update(in->port, in->queue,
13520 : 0 : in->postpone,
13521 : 0 : in->args.ia.action_id,
13522 : 0 : in->args.ia.qu_mode,
13523 : 0 : in->args.vc.actions);
13524 : 0 : break;
13525 : 0 : case INDIRECT_ACTION_CREATE:
13526 : : case INDIRECT_ACTION_LIST_CREATE:
13527 : 0 : port_action_handle_create(
13528 : 0 : in->port, in->args.vc.attr.group,
13529 : : in->command == INDIRECT_ACTION_LIST_CREATE,
13530 : 0 : &((const struct rte_flow_indir_action_conf) {
13531 : 0 : .ingress = in->args.vc.attr.ingress,
13532 : 0 : .egress = in->args.vc.attr.egress,
13533 : 0 : .transfer = in->args.vc.attr.transfer,
13534 : : }),
13535 : 0 : in->args.vc.actions);
13536 : 0 : break;
13537 : 0 : case INDIRECT_ACTION_FLOW_CONF_CREATE:
13538 : 0 : indirect_action_flow_conf_create(in);
13539 : 0 : break;
13540 : 0 : case INDIRECT_ACTION_DESTROY:
13541 : 0 : port_action_handle_destroy(in->port,
13542 : 0 : in->args.ia_destroy.action_id_n,
13543 : 0 : in->args.ia_destroy.action_id);
13544 : 0 : break;
13545 : 0 : case INDIRECT_ACTION_UPDATE:
13546 : 0 : port_action_handle_update(in->port, in->args.vc.attr.group,
13547 : 0 : in->args.vc.actions);
13548 : 0 : break;
13549 : 0 : case INDIRECT_ACTION_QUERY:
13550 : 0 : port_action_handle_query(in->port, in->args.ia.action_id);
13551 : 0 : break;
13552 : 0 : case INDIRECT_ACTION_QUERY_UPDATE:
13553 : 0 : port_action_handle_query_update(in->port,
13554 : 0 : in->args.ia.action_id,
13555 : 0 : in->args.ia.qu_mode,
13556 : 0 : in->args.vc.actions);
13557 : 0 : break;
13558 : 0 : case VALIDATE:
13559 : 0 : port_flow_validate(in->port, &in->args.vc.attr,
13560 : 0 : in->args.vc.pattern, in->args.vc.actions,
13561 : : &in->args.vc.tunnel_ops);
13562 : 0 : break;
13563 : 0 : case CREATE:
13564 : 0 : port_flow_create(in->port, &in->args.vc.attr,
13565 : 0 : in->args.vc.pattern, in->args.vc.actions,
13566 : 0 : &in->args.vc.tunnel_ops, in->args.vc.user_id);
13567 : 0 : break;
13568 : 0 : case DESTROY:
13569 : 0 : port_flow_destroy(in->port, in->args.destroy.rule_n,
13570 : 0 : in->args.destroy.rule,
13571 : 0 : in->args.destroy.is_user_id);
13572 : 0 : break;
13573 : 0 : case UPDATE:
13574 : 0 : port_flow_update(in->port, in->args.vc.rule_id,
13575 : 0 : in->args.vc.actions, in->args.vc.user_id);
13576 : 0 : break;
13577 : 0 : case FLUSH:
13578 : 0 : port_flow_flush(in->port);
13579 : 0 : break;
13580 : 0 : case DUMP_ONE:
13581 : : case DUMP_ALL:
13582 : 0 : port_flow_dump(in->port, in->args.dump.mode,
13583 : 0 : in->args.dump.rule, in->args.dump.file,
13584 : 0 : in->args.dump.is_user_id);
13585 : 0 : break;
13586 : 0 : case QUERY:
13587 : 0 : port_flow_query(in->port, in->args.query.rule,
13588 : : &in->args.query.action,
13589 : 0 : in->args.query.is_user_id);
13590 : 0 : break;
13591 : 0 : case LIST:
13592 : 0 : port_flow_list(in->port, in->args.list.group_n,
13593 : 0 : in->args.list.group);
13594 : 0 : break;
13595 : 0 : case ISOLATE:
13596 : 0 : port_flow_isolate(in->port, in->args.isolate.set);
13597 : 0 : break;
13598 : 0 : case AGED:
13599 : 0 : port_flow_aged(in->port, in->args.aged.destroy);
13600 : 0 : break;
13601 : 0 : case TUNNEL_CREATE:
13602 : 0 : port_flow_tunnel_create(in->port, &in->args.vc.tunnel_ops);
13603 : 0 : break;
13604 : 0 : case TUNNEL_DESTROY:
13605 : 0 : port_flow_tunnel_destroy(in->port, in->args.vc.tunnel_ops.id);
13606 : 0 : break;
13607 : 0 : case TUNNEL_LIST:
13608 : 0 : port_flow_tunnel_list(in->port);
13609 : 0 : break;
13610 : 0 : case ACTION_POL_G:
13611 : 0 : port_meter_policy_add(in->port, in->args.policy.policy_id,
13612 : 0 : in->args.vc.actions);
13613 : 0 : break;
13614 : 0 : case FLEX_ITEM_CREATE:
13615 : 0 : flex_item_create(in->port, in->args.flex.token,
13616 : 0 : in->args.flex.filename);
13617 : 0 : break;
13618 : 0 : case FLEX_ITEM_DESTROY:
13619 : 0 : flex_item_destroy(in->port, in->args.flex.token);
13620 : 0 : break;
13621 : : default:
13622 : : break;
13623 : : }
13624 : 0 : fflush(stdout);
13625 : 0 : }
13626 : :
13627 : : /** Token generator and output processing callback (cmdline API). */
13628 : : static void
13629 : 0 : cmd_flow_cb(void *arg0, struct cmdline *cl, void *arg2)
13630 : : {
13631 : 0 : if (cl == NULL)
13632 : 0 : cmd_flow_tok(arg0, arg2);
13633 : : else
13634 : 0 : cmd_flow_parsed(arg0);
13635 : 0 : }
13636 : :
13637 : : /** Global parser instance (cmdline API). */
13638 : : cmdline_parse_inst_t cmd_flow = {
13639 : : .f = cmd_flow_cb,
13640 : : .data = NULL, /**< Unused. */
13641 : : .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
13642 : : .tokens = {
13643 : : NULL,
13644 : : }, /**< Tokens are returned by cmd_flow_tok(). */
13645 : : };
13646 : :
13647 : : /** set cmd facility. Reuse cmd flow's infrastructure as much as possible. */
13648 : :
13649 : : static void
13650 : 0 : update_fields(uint8_t *buf, struct rte_flow_item *item, uint16_t next_proto)
13651 : : {
13652 : : struct rte_ipv4_hdr *ipv4;
13653 : : struct rte_ether_hdr *eth;
13654 : : struct rte_ipv6_hdr *ipv6;
13655 : : struct rte_vxlan_hdr *vxlan;
13656 : : struct rte_vxlan_gpe_hdr *gpe;
13657 : : struct rte_flow_item_nvgre *nvgre;
13658 : : uint32_t ipv6_vtc_flow;
13659 : :
13660 : 0 : switch (item->type) {
13661 : 0 : case RTE_FLOW_ITEM_TYPE_ETH:
13662 : : eth = (struct rte_ether_hdr *)buf;
13663 : 0 : if (next_proto)
13664 : 0 : eth->ether_type = rte_cpu_to_be_16(next_proto);
13665 : : break;
13666 : 0 : case RTE_FLOW_ITEM_TYPE_IPV4:
13667 : : ipv4 = (struct rte_ipv4_hdr *)buf;
13668 : 0 : if (!ipv4->version_ihl)
13669 : 0 : ipv4->version_ihl = RTE_IPV4_VHL_DEF;
13670 : 0 : if (next_proto && ipv4->next_proto_id == 0)
13671 : 0 : ipv4->next_proto_id = (uint8_t)next_proto;
13672 : : break;
13673 : 0 : case RTE_FLOW_ITEM_TYPE_IPV6:
13674 : : ipv6 = (struct rte_ipv6_hdr *)buf;
13675 : 0 : if (next_proto && ipv6->proto == 0)
13676 : 0 : ipv6->proto = (uint8_t)next_proto;
13677 : 0 : ipv6_vtc_flow = rte_be_to_cpu_32(ipv6->vtc_flow);
13678 : 0 : ipv6_vtc_flow &= 0x0FFFFFFF; /*< reset version bits. */
13679 : 0 : ipv6_vtc_flow |= 0x60000000; /*< set ipv6 version. */
13680 : 0 : ipv6->vtc_flow = rte_cpu_to_be_32(ipv6_vtc_flow);
13681 : 0 : break;
13682 : 0 : case RTE_FLOW_ITEM_TYPE_VXLAN:
13683 : : vxlan = (struct rte_vxlan_hdr *)buf;
13684 : 0 : if (!vxlan->flags)
13685 : 0 : vxlan->flags = 0x08;
13686 : : break;
13687 : 0 : case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
13688 : : gpe = (struct rte_vxlan_gpe_hdr *)buf;
13689 : 0 : gpe->vx_flags = 0x0C;
13690 : 0 : break;
13691 : 0 : case RTE_FLOW_ITEM_TYPE_NVGRE:
13692 : : nvgre = (struct rte_flow_item_nvgre *)buf;
13693 : 0 : nvgre->protocol = rte_cpu_to_be_16(0x6558);
13694 : 0 : nvgre->c_k_s_rsvd0_ver = rte_cpu_to_be_16(0x2000);
13695 : 0 : break;
13696 : : default:
13697 : : break;
13698 : : }
13699 : 0 : }
13700 : :
13701 : : /** Helper of get item's default mask. */
13702 : : static const void *
13703 : 0 : flow_item_default_mask(const struct rte_flow_item *item)
13704 : : {
13705 : : const void *mask = NULL;
13706 : : static rte_be32_t gre_key_default_mask = RTE_BE32(UINT32_MAX);
13707 : : static struct rte_flow_item_ipv6_routing_ext ipv6_routing_ext_default_mask = {
13708 : : .hdr = {
13709 : : .next_hdr = 0xff,
13710 : : .type = 0xff,
13711 : : .segments_left = 0xff,
13712 : : },
13713 : : };
13714 : :
13715 : 0 : switch (item->type) {
13716 : 0 : case RTE_FLOW_ITEM_TYPE_ANY:
13717 : : mask = &rte_flow_item_any_mask;
13718 : 0 : break;
13719 : 0 : case RTE_FLOW_ITEM_TYPE_PORT_ID:
13720 : : mask = &rte_flow_item_port_id_mask;
13721 : 0 : break;
13722 : 0 : case RTE_FLOW_ITEM_TYPE_RAW:
13723 : : mask = &rte_flow_item_raw_mask;
13724 : 0 : break;
13725 : 0 : case RTE_FLOW_ITEM_TYPE_ETH:
13726 : : mask = &rte_flow_item_eth_mask;
13727 : 0 : break;
13728 : 0 : case RTE_FLOW_ITEM_TYPE_VLAN:
13729 : : mask = &rte_flow_item_vlan_mask;
13730 : 0 : break;
13731 : 0 : case RTE_FLOW_ITEM_TYPE_IPV4:
13732 : : mask = &rte_flow_item_ipv4_mask;
13733 : 0 : break;
13734 : 0 : case RTE_FLOW_ITEM_TYPE_IPV6:
13735 : : mask = &rte_flow_item_ipv6_mask;
13736 : 0 : break;
13737 : 0 : case RTE_FLOW_ITEM_TYPE_ICMP:
13738 : : mask = &rte_flow_item_icmp_mask;
13739 : 0 : break;
13740 : 0 : case RTE_FLOW_ITEM_TYPE_UDP:
13741 : : mask = &rte_flow_item_udp_mask;
13742 : 0 : break;
13743 : 0 : case RTE_FLOW_ITEM_TYPE_TCP:
13744 : : mask = &rte_flow_item_tcp_mask;
13745 : 0 : break;
13746 : 0 : case RTE_FLOW_ITEM_TYPE_SCTP:
13747 : : mask = &rte_flow_item_sctp_mask;
13748 : 0 : break;
13749 : 0 : case RTE_FLOW_ITEM_TYPE_VXLAN:
13750 : : mask = &rte_flow_item_vxlan_mask;
13751 : 0 : break;
13752 : 0 : case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
13753 : : mask = &rte_flow_item_vxlan_gpe_mask;
13754 : 0 : break;
13755 : 0 : case RTE_FLOW_ITEM_TYPE_E_TAG:
13756 : : mask = &rte_flow_item_e_tag_mask;
13757 : 0 : break;
13758 : 0 : case RTE_FLOW_ITEM_TYPE_NVGRE:
13759 : : mask = &rte_flow_item_nvgre_mask;
13760 : 0 : break;
13761 : 0 : case RTE_FLOW_ITEM_TYPE_MPLS:
13762 : : mask = &rte_flow_item_mpls_mask;
13763 : 0 : break;
13764 : 0 : case RTE_FLOW_ITEM_TYPE_GRE:
13765 : : mask = &rte_flow_item_gre_mask;
13766 : 0 : break;
13767 : 0 : case RTE_FLOW_ITEM_TYPE_GRE_KEY:
13768 : : mask = &gre_key_default_mask;
13769 : 0 : break;
13770 : 0 : case RTE_FLOW_ITEM_TYPE_META:
13771 : : mask = &rte_flow_item_meta_mask;
13772 : 0 : break;
13773 : 0 : case RTE_FLOW_ITEM_TYPE_RANDOM:
13774 : : mask = &rte_flow_item_random_mask;
13775 : 0 : break;
13776 : 0 : case RTE_FLOW_ITEM_TYPE_FUZZY:
13777 : : mask = &rte_flow_item_fuzzy_mask;
13778 : 0 : break;
13779 : 0 : case RTE_FLOW_ITEM_TYPE_GTP:
13780 : : mask = &rte_flow_item_gtp_mask;
13781 : 0 : break;
13782 : 0 : case RTE_FLOW_ITEM_TYPE_GTP_PSC:
13783 : : mask = &rte_flow_item_gtp_psc_mask;
13784 : 0 : break;
13785 : 0 : case RTE_FLOW_ITEM_TYPE_GENEVE:
13786 : : mask = &rte_flow_item_geneve_mask;
13787 : 0 : break;
13788 : 0 : case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
13789 : : mask = &rte_flow_item_geneve_opt_mask;
13790 : 0 : break;
13791 : 0 : case RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID:
13792 : : mask = &rte_flow_item_pppoe_proto_id_mask;
13793 : 0 : break;
13794 : 0 : case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
13795 : : mask = &rte_flow_item_l2tpv3oip_mask;
13796 : 0 : break;
13797 : 0 : case RTE_FLOW_ITEM_TYPE_ESP:
13798 : : mask = &rte_flow_item_esp_mask;
13799 : 0 : break;
13800 : 0 : case RTE_FLOW_ITEM_TYPE_AH:
13801 : : mask = &rte_flow_item_ah_mask;
13802 : 0 : break;
13803 : 0 : case RTE_FLOW_ITEM_TYPE_PFCP:
13804 : : mask = &rte_flow_item_pfcp_mask;
13805 : 0 : break;
13806 : 0 : case RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR:
13807 : : case RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT:
13808 : : mask = &rte_flow_item_ethdev_mask;
13809 : 0 : break;
13810 : 0 : case RTE_FLOW_ITEM_TYPE_L2TPV2:
13811 : : mask = &rte_flow_item_l2tpv2_mask;
13812 : 0 : break;
13813 : 0 : case RTE_FLOW_ITEM_TYPE_PPP:
13814 : : mask = &rte_flow_item_ppp_mask;
13815 : 0 : break;
13816 : 0 : case RTE_FLOW_ITEM_TYPE_METER_COLOR:
13817 : : mask = &rte_flow_item_meter_color_mask;
13818 : 0 : break;
13819 : 0 : case RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT:
13820 : : mask = &ipv6_routing_ext_default_mask;
13821 : 0 : break;
13822 : 0 : case RTE_FLOW_ITEM_TYPE_AGGR_AFFINITY:
13823 : : mask = &rte_flow_item_aggr_affinity_mask;
13824 : 0 : break;
13825 : 0 : case RTE_FLOW_ITEM_TYPE_TX_QUEUE:
13826 : : mask = &rte_flow_item_tx_queue_mask;
13827 : 0 : break;
13828 : 0 : case RTE_FLOW_ITEM_TYPE_IB_BTH:
13829 : : mask = &rte_flow_item_ib_bth_mask;
13830 : 0 : break;
13831 : 0 : case RTE_FLOW_ITEM_TYPE_PTYPE:
13832 : : mask = &rte_flow_item_ptype_mask;
13833 : 0 : break;
13834 : : default:
13835 : : break;
13836 : : }
13837 : 0 : return mask;
13838 : : }
13839 : :
13840 : : /** Dispatch parsed buffer to function calls. */
13841 : : static void
13842 : 0 : cmd_set_ipv6_ext_parsed(const struct buffer *in)
13843 : : {
13844 : 0 : uint32_t n = in->args.vc.pattern_n;
13845 : : int i = 0;
13846 : : struct rte_flow_item *item = NULL;
13847 : : size_t size = 0;
13848 : : uint8_t *data = NULL;
13849 : : uint8_t *type = NULL;
13850 : : size_t *total_size = NULL;
13851 : 0 : uint16_t idx = in->port; /* We borrow port field as index */
13852 : : struct rte_flow_item_ipv6_routing_ext *ext;
13853 : : const struct rte_flow_item_ipv6_ext *ipv6_ext;
13854 : :
13855 : : RTE_ASSERT(in->command == SET_IPV6_EXT_PUSH ||
13856 : : in->command == SET_IPV6_EXT_REMOVE);
13857 : :
13858 : 0 : if (in->command == SET_IPV6_EXT_REMOVE) {
13859 : 0 : if (n != 1 || in->args.vc.pattern->type !=
13860 : : RTE_FLOW_ITEM_TYPE_IPV6_EXT) {
13861 : 0 : fprintf(stderr, "Error - Not supported item\n");
13862 : 0 : return;
13863 : : }
13864 : 0 : type = (uint8_t *)&ipv6_ext_remove_confs[idx].type;
13865 : : item = in->args.vc.pattern;
13866 : 0 : ipv6_ext = item->spec;
13867 : 0 : *type = ipv6_ext->next_hdr;
13868 : 0 : return;
13869 : : }
13870 : :
13871 : 0 : total_size = &ipv6_ext_push_confs[idx].size;
13872 : 0 : data = (uint8_t *)&ipv6_ext_push_confs[idx].data;
13873 : : type = (uint8_t *)&ipv6_ext_push_confs[idx].type;
13874 : :
13875 : 0 : *total_size = 0;
13876 : : memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
13877 : 0 : for (i = n - 1 ; i >= 0; --i) {
13878 : 0 : item = in->args.vc.pattern + i;
13879 : 0 : switch (item->type) {
13880 : 0 : case RTE_FLOW_ITEM_TYPE_IPV6_EXT:
13881 : 0 : ipv6_ext = item->spec;
13882 : 0 : *type = ipv6_ext->next_hdr;
13883 : 0 : break;
13884 : 0 : case RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT:
13885 : 0 : ext = (struct rte_flow_item_ipv6_routing_ext *)(uintptr_t)item->spec;
13886 : 0 : if (!ext->hdr.hdr_len) {
13887 : 0 : size = sizeof(struct rte_ipv6_routing_ext) +
13888 : 0 : (ext->hdr.segments_left << 4);
13889 : 0 : ext->hdr.hdr_len = ext->hdr.segments_left << 1;
13890 : : /* Indicate no TLV once SRH. */
13891 : 0 : if (ext->hdr.type == 4)
13892 : 0 : ext->hdr.last_entry = ext->hdr.segments_left - 1;
13893 : : } else {
13894 : 0 : size = sizeof(struct rte_ipv6_routing_ext) +
13895 : 0 : (ext->hdr.hdr_len << 3);
13896 : : }
13897 : 0 : *total_size += size;
13898 : : memcpy(data, ext, size);
13899 : : break;
13900 : 0 : default:
13901 : 0 : fprintf(stderr, "Error - Not supported item\n");
13902 : 0 : goto error;
13903 : : }
13904 : : }
13905 : : RTE_ASSERT((*total_size) <= ACTION_IPV6_EXT_PUSH_MAX_DATA);
13906 : : return;
13907 : : error:
13908 : 0 : *total_size = 0;
13909 : : memset(data, 0x00, ACTION_IPV6_EXT_PUSH_MAX_DATA);
13910 : : }
13911 : :
13912 : : /** Dispatch parsed buffer to function calls. */
13913 : : static void
13914 : 0 : cmd_set_raw_parsed_sample(const struct buffer *in)
13915 : : {
13916 : 0 : uint32_t n = in->args.vc.actions_n;
13917 : : uint32_t i = 0;
13918 : : struct rte_flow_action *action = NULL;
13919 : : struct rte_flow_action *data = NULL;
13920 : : const struct rte_flow_action_rss *rss = NULL;
13921 : : size_t size = 0;
13922 : 0 : uint16_t idx = in->port; /* We borrow port field as index */
13923 : : uint32_t max_size = sizeof(struct rte_flow_action) *
13924 : : ACTION_SAMPLE_ACTIONS_NUM;
13925 : :
13926 : : RTE_ASSERT(in->command == SET_SAMPLE_ACTIONS);
13927 : 0 : data = (struct rte_flow_action *)&raw_sample_confs[idx].data;
13928 : : memset(data, 0x00, max_size);
13929 : 0 : for (; i <= n - 1; i++) {
13930 : 0 : action = in->args.vc.actions + i;
13931 : 0 : if (action->type == RTE_FLOW_ACTION_TYPE_END)
13932 : : break;
13933 : 0 : switch (action->type) {
13934 : 0 : case RTE_FLOW_ACTION_TYPE_MARK:
13935 : : size = sizeof(struct rte_flow_action_mark);
13936 : 0 : rte_memcpy(&sample_mark[idx],
13937 : : (const void *)action->conf, size);
13938 : 0 : action->conf = &sample_mark[idx];
13939 : 0 : break;
13940 : 0 : case RTE_FLOW_ACTION_TYPE_COUNT:
13941 : : size = sizeof(struct rte_flow_action_count);
13942 : 0 : rte_memcpy(&sample_count[idx],
13943 : : (const void *)action->conf, size);
13944 : 0 : action->conf = &sample_count[idx];
13945 : 0 : break;
13946 : 0 : case RTE_FLOW_ACTION_TYPE_QUEUE:
13947 : : size = sizeof(struct rte_flow_action_queue);
13948 : 0 : rte_memcpy(&sample_queue[idx],
13949 : : (const void *)action->conf, size);
13950 : 0 : action->conf = &sample_queue[idx];
13951 : 0 : break;
13952 : 0 : case RTE_FLOW_ACTION_TYPE_RSS:
13953 : : size = sizeof(struct rte_flow_action_rss);
13954 : 0 : rss = action->conf;
13955 : 0 : rte_memcpy(&sample_rss_data[idx].conf,
13956 : : (const void *)rss, size);
13957 : 0 : if (rss->key_len && rss->key) {
13958 : 0 : sample_rss_data[idx].conf.key =
13959 : 0 : sample_rss_data[idx].key;
13960 : 0 : rte_memcpy((void *)((uintptr_t)
13961 : : sample_rss_data[idx].conf.key),
13962 : 0 : (const void *)rss->key,
13963 : : sizeof(uint8_t) * rss->key_len);
13964 : : }
13965 : 0 : if (rss->queue_num && rss->queue) {
13966 : 0 : sample_rss_data[idx].conf.queue =
13967 : 0 : sample_rss_data[idx].queue;
13968 : 0 : rte_memcpy((void *)((uintptr_t)
13969 : : sample_rss_data[idx].conf.queue),
13970 : 0 : (const void *)rss->queue,
13971 : 0 : sizeof(uint16_t) * rss->queue_num);
13972 : : }
13973 : 0 : action->conf = &sample_rss_data[idx].conf;
13974 : 0 : break;
13975 : 0 : case RTE_FLOW_ACTION_TYPE_RAW_ENCAP:
13976 : : size = sizeof(struct rte_flow_action_raw_encap);
13977 : 0 : rte_memcpy(&sample_encap[idx],
13978 : : (const void *)action->conf, size);
13979 : 0 : action->conf = &sample_encap[idx];
13980 : 0 : break;
13981 : 0 : case RTE_FLOW_ACTION_TYPE_PORT_ID:
13982 : : size = sizeof(struct rte_flow_action_port_id);
13983 : 0 : rte_memcpy(&sample_port_id[idx],
13984 : : (const void *)action->conf, size);
13985 : 0 : action->conf = &sample_port_id[idx];
13986 : 0 : break;
13987 : : case RTE_FLOW_ACTION_TYPE_PF:
13988 : : break;
13989 : 0 : case RTE_FLOW_ACTION_TYPE_VF:
13990 : : size = sizeof(struct rte_flow_action_vf);
13991 : 0 : rte_memcpy(&sample_vf[idx],
13992 : : (const void *)action->conf, size);
13993 : 0 : action->conf = &sample_vf[idx];
13994 : 0 : break;
13995 : 0 : case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP:
13996 : : size = sizeof(struct rte_flow_action_vxlan_encap);
13997 : 0 : parse_setup_vxlan_encap_data(&sample_vxlan_encap[idx]);
13998 : 0 : action->conf = &sample_vxlan_encap[idx].conf;
13999 : 0 : break;
14000 : 0 : case RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP:
14001 : : size = sizeof(struct rte_flow_action_nvgre_encap);
14002 : 0 : parse_setup_nvgre_encap_data(&sample_nvgre_encap[idx]);
14003 : 0 : action->conf = &sample_nvgre_encap[idx];
14004 : 0 : break;
14005 : 0 : case RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR:
14006 : : size = sizeof(struct rte_flow_action_ethdev);
14007 : 0 : rte_memcpy(&sample_port_representor[idx],
14008 : : (const void *)action->conf, size);
14009 : 0 : action->conf = &sample_port_representor[idx];
14010 : 0 : break;
14011 : 0 : case RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT:
14012 : : size = sizeof(struct rte_flow_action_ethdev);
14013 : 0 : rte_memcpy(&sample_represented_port[idx],
14014 : : (const void *)action->conf, size);
14015 : 0 : action->conf = &sample_represented_port[idx];
14016 : 0 : break;
14017 : 0 : default:
14018 : 0 : fprintf(stderr, "Error - Not supported action\n");
14019 : : return;
14020 : : }
14021 : 0 : *data = *action;
14022 : 0 : data++;
14023 : : }
14024 : : }
14025 : :
14026 : : /** Dispatch parsed buffer to function calls. */
14027 : : static void
14028 : 0 : cmd_set_raw_parsed(const struct buffer *in)
14029 : : {
14030 : 0 : uint32_t n = in->args.vc.pattern_n;
14031 : : int i = 0;
14032 : : struct rte_flow_item *item = NULL;
14033 : : size_t size = 0;
14034 : : uint8_t *data = NULL;
14035 : : uint8_t *data_tail = NULL;
14036 : : size_t *total_size = NULL;
14037 : : uint16_t upper_layer = 0;
14038 : : uint16_t proto = 0;
14039 : 0 : uint16_t idx = in->port; /* We borrow port field as index */
14040 : : int gtp_psc = -1; /* GTP PSC option index. */
14041 : : const void *src_spec;
14042 : :
14043 : 0 : if (in->command == SET_SAMPLE_ACTIONS) {
14044 : 0 : cmd_set_raw_parsed_sample(in);
14045 : 0 : return;
14046 : : }
14047 : 0 : else if (in->command == SET_IPV6_EXT_PUSH ||
14048 : : in->command == SET_IPV6_EXT_REMOVE) {
14049 : 0 : cmd_set_ipv6_ext_parsed(in);
14050 : 0 : return;
14051 : : }
14052 : : RTE_ASSERT(in->command == SET_RAW_ENCAP ||
14053 : : in->command == SET_RAW_DECAP);
14054 : 0 : if (in->command == SET_RAW_ENCAP) {
14055 : 0 : total_size = &raw_encap_confs[idx].size;
14056 : 0 : data = (uint8_t *)&raw_encap_confs[idx].data;
14057 : : } else {
14058 : 0 : total_size = &raw_decap_confs[idx].size;
14059 : 0 : data = (uint8_t *)&raw_decap_confs[idx].data;
14060 : : }
14061 : 0 : *total_size = 0;
14062 : : memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
14063 : : /* process hdr from upper layer to low layer (L3/L4 -> L2). */
14064 : 0 : data_tail = data + ACTION_RAW_ENCAP_MAX_DATA;
14065 : 0 : for (i = n - 1 ; i >= 0; --i) {
14066 : : const struct rte_flow_item_gtp *gtp;
14067 : : const struct rte_flow_item_geneve_opt *opt;
14068 : : struct rte_flow_item_ipv6_routing_ext *ext;
14069 : :
14070 : 0 : item = in->args.vc.pattern + i;
14071 : 0 : if (item->spec == NULL)
14072 : 0 : item->spec = flow_item_default_mask(item);
14073 : 0 : src_spec = item->spec;
14074 : 0 : switch (item->type) {
14075 : : case RTE_FLOW_ITEM_TYPE_ETH:
14076 : : size = sizeof(struct rte_ether_hdr);
14077 : : break;
14078 : 0 : case RTE_FLOW_ITEM_TYPE_VLAN:
14079 : : size = sizeof(struct rte_vlan_hdr);
14080 : : proto = RTE_ETHER_TYPE_VLAN;
14081 : 0 : break;
14082 : 0 : case RTE_FLOW_ITEM_TYPE_IPV4:
14083 : : size = sizeof(struct rte_ipv4_hdr);
14084 : : proto = RTE_ETHER_TYPE_IPV4;
14085 : 0 : break;
14086 : 0 : case RTE_FLOW_ITEM_TYPE_IPV6:
14087 : : size = sizeof(struct rte_ipv6_hdr);
14088 : : proto = RTE_ETHER_TYPE_IPV6;
14089 : 0 : break;
14090 : 0 : case RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT:
14091 : : ext = (struct rte_flow_item_ipv6_routing_ext *)(uintptr_t)item->spec;
14092 : 0 : if (!ext->hdr.hdr_len) {
14093 : 0 : size = sizeof(struct rte_ipv6_routing_ext) +
14094 : 0 : (ext->hdr.segments_left << 4);
14095 : 0 : ext->hdr.hdr_len = ext->hdr.segments_left << 1;
14096 : : /* SRv6 without TLV. */
14097 : 0 : if (ext->hdr.type == RTE_IPV6_SRCRT_TYPE_4)
14098 : 0 : ext->hdr.last_entry = ext->hdr.segments_left - 1;
14099 : : } else {
14100 : 0 : size = sizeof(struct rte_ipv6_routing_ext) +
14101 : 0 : (ext->hdr.hdr_len << 3);
14102 : : }
14103 : : proto = IPPROTO_ROUTING;
14104 : : break;
14105 : 0 : case RTE_FLOW_ITEM_TYPE_UDP:
14106 : : size = sizeof(struct rte_udp_hdr);
14107 : : proto = 0x11;
14108 : 0 : break;
14109 : 0 : case RTE_FLOW_ITEM_TYPE_TCP:
14110 : : size = sizeof(struct rte_tcp_hdr);
14111 : : proto = 0x06;
14112 : 0 : break;
14113 : 0 : case RTE_FLOW_ITEM_TYPE_VXLAN:
14114 : : size = sizeof(struct rte_vxlan_hdr);
14115 : 0 : break;
14116 : 0 : case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
14117 : : size = sizeof(struct rte_vxlan_gpe_hdr);
14118 : 0 : break;
14119 : 0 : case RTE_FLOW_ITEM_TYPE_GRE:
14120 : : size = sizeof(struct rte_gre_hdr);
14121 : : proto = 0x2F;
14122 : 0 : break;
14123 : 0 : case RTE_FLOW_ITEM_TYPE_GRE_KEY:
14124 : : size = sizeof(rte_be32_t);
14125 : : proto = 0x0;
14126 : 0 : break;
14127 : 0 : case RTE_FLOW_ITEM_TYPE_MPLS:
14128 : : size = sizeof(struct rte_mpls_hdr);
14129 : : proto = 0x0;
14130 : 0 : break;
14131 : 0 : case RTE_FLOW_ITEM_TYPE_NVGRE:
14132 : : size = sizeof(struct rte_flow_item_nvgre);
14133 : : proto = 0x2F;
14134 : 0 : break;
14135 : 0 : case RTE_FLOW_ITEM_TYPE_GENEVE:
14136 : : size = sizeof(struct rte_geneve_hdr);
14137 : 0 : break;
14138 : 0 : case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
14139 : : opt = (const struct rte_flow_item_geneve_opt *)
14140 : : item->spec;
14141 : : size = offsetof(struct rte_flow_item_geneve_opt,
14142 : : option_len) + sizeof(uint8_t);
14143 : 0 : if (opt->option_len && opt->data) {
14144 : 0 : *total_size += opt->option_len *
14145 : : sizeof(uint32_t);
14146 : 0 : rte_memcpy(data_tail - (*total_size),
14147 : : opt->data,
14148 : : opt->option_len * sizeof(uint32_t));
14149 : : }
14150 : : break;
14151 : 0 : case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
14152 : : size = sizeof(rte_be32_t);
14153 : : proto = 0x73;
14154 : 0 : break;
14155 : 0 : case RTE_FLOW_ITEM_TYPE_ESP:
14156 : : size = sizeof(struct rte_esp_hdr);
14157 : : proto = 0x32;
14158 : 0 : break;
14159 : 0 : case RTE_FLOW_ITEM_TYPE_AH:
14160 : : size = sizeof(struct rte_flow_item_ah);
14161 : : proto = 0x33;
14162 : 0 : break;
14163 : 0 : case RTE_FLOW_ITEM_TYPE_GTP:
14164 : 0 : if (gtp_psc < 0) {
14165 : : size = sizeof(struct rte_gtp_hdr);
14166 : : break;
14167 : : }
14168 : 0 : if (gtp_psc != i + 1) {
14169 : 0 : fprintf(stderr,
14170 : : "Error - GTP PSC does not follow GTP\n");
14171 : 0 : goto error;
14172 : : }
14173 : : gtp = item->spec;
14174 : 0 : if (gtp->hdr.s == 1 || gtp->hdr.pn == 1) {
14175 : : /* Only E flag should be set. */
14176 : 0 : fprintf(stderr,
14177 : : "Error - GTP unsupported flags\n");
14178 : 0 : goto error;
14179 : : } else {
14180 : 0 : struct rte_gtp_hdr_ext_word ext_word = {
14181 : : .next_ext = 0x85
14182 : : };
14183 : :
14184 : : /* We have to add GTP header extra word. */
14185 : 0 : *total_size += sizeof(ext_word);
14186 : 0 : rte_memcpy(data_tail - (*total_size),
14187 : : &ext_word, sizeof(ext_word));
14188 : : }
14189 : : size = sizeof(struct rte_gtp_hdr);
14190 : 0 : break;
14191 : 0 : case RTE_FLOW_ITEM_TYPE_GTP_PSC:
14192 : 0 : if (gtp_psc >= 0) {
14193 : 0 : fprintf(stderr,
14194 : : "Error - Multiple GTP PSC items\n");
14195 : 0 : goto error;
14196 : : } else {
14197 : : const struct rte_flow_item_gtp_psc
14198 : : *opt = item->spec;
14199 : : struct rte_gtp_psc_generic_hdr *hdr;
14200 : : size_t hdr_size = RTE_ALIGN(sizeof(*hdr),
14201 : : sizeof(int32_t));
14202 : :
14203 : 0 : *total_size += hdr_size;
14204 : 0 : hdr = (typeof(hdr))(data_tail - (*total_size));
14205 : : memset(hdr, 0, hdr_size);
14206 : 0 : *hdr = opt->hdr;
14207 : 0 : hdr->ext_hdr_len = 1;
14208 : : gtp_psc = i;
14209 : : size = 0;
14210 : : }
14211 : 0 : break;
14212 : 0 : case RTE_FLOW_ITEM_TYPE_PFCP:
14213 : : size = sizeof(struct rte_flow_item_pfcp);
14214 : 0 : break;
14215 : 0 : case RTE_FLOW_ITEM_TYPE_FLEX:
14216 : 0 : if (item->spec != NULL) {
14217 : 0 : size = ((const struct rte_flow_item_flex *)item->spec)->length;
14218 : 0 : src_spec = ((const struct rte_flow_item_flex *)item->spec)->pattern;
14219 : : } else {
14220 : : size = 0;
14221 : : src_spec = NULL;
14222 : : }
14223 : : break;
14224 : 0 : case RTE_FLOW_ITEM_TYPE_GRE_OPTION:
14225 : : size = 0;
14226 : 0 : if (item->spec) {
14227 : : const struct rte_flow_item_gre_opt
14228 : : *opt = item->spec;
14229 : 0 : if (opt->checksum_rsvd.checksum) {
14230 : 0 : *total_size +=
14231 : : sizeof(opt->checksum_rsvd);
14232 : 0 : rte_memcpy(data_tail - (*total_size),
14233 : 0 : &opt->checksum_rsvd,
14234 : : sizeof(opt->checksum_rsvd));
14235 : : }
14236 : 0 : if (opt->key.key) {
14237 : 0 : *total_size += sizeof(opt->key.key);
14238 : 0 : rte_memcpy(data_tail - (*total_size),
14239 : 0 : &opt->key.key,
14240 : : sizeof(opt->key.key));
14241 : : }
14242 : 0 : if (opt->sequence.sequence) {
14243 : 0 : *total_size += sizeof(opt->sequence.sequence);
14244 : 0 : rte_memcpy(data_tail - (*total_size),
14245 : 0 : &opt->sequence.sequence,
14246 : : sizeof(opt->sequence.sequence));
14247 : : }
14248 : : }
14249 : : proto = 0x2F;
14250 : : break;
14251 : 0 : default:
14252 : 0 : fprintf(stderr, "Error - Not supported item\n");
14253 : 0 : goto error;
14254 : : }
14255 : 0 : if (size) {
14256 : 0 : *total_size += size;
14257 : 0 : rte_memcpy(data_tail - (*total_size), src_spec, size);
14258 : : /* update some fields which cannot be set by cmdline */
14259 : 0 : update_fields((data_tail - (*total_size)), item,
14260 : : upper_layer);
14261 : : upper_layer = proto;
14262 : : }
14263 : : }
14264 : 0 : if (verbose_level & 0x1)
14265 : 0 : printf("total data size is %zu\n", (*total_size));
14266 : : RTE_ASSERT((*total_size) <= ACTION_RAW_ENCAP_MAX_DATA);
14267 : 0 : memmove(data, (data_tail - (*total_size)), *total_size);
14268 : : return;
14269 : :
14270 : 0 : error:
14271 : 0 : *total_size = 0;
14272 : : memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
14273 : : }
14274 : :
14275 : : /** Populate help strings for current token (cmdline API). */
14276 : : static int
14277 : 0 : cmd_set_raw_get_help(cmdline_parse_token_hdr_t *hdr, char *dst,
14278 : : unsigned int size)
14279 : : {
14280 : : struct context *ctx = &cmd_flow_context;
14281 : 0 : const struct token *token = &token_list[ctx->prev];
14282 : :
14283 : : (void)hdr;
14284 : 0 : if (!size)
14285 : : return -1;
14286 : : /* Set token type and update global help with details. */
14287 : 0 : snprintf(dst, size, "%s", (token->type ? token->type : "TOKEN"));
14288 : 0 : if (token->help)
14289 : 0 : cmd_set_raw.help_str = token->help;
14290 : : else
14291 : 0 : cmd_set_raw.help_str = token->name;
14292 : : return 0;
14293 : : }
14294 : :
14295 : : /** Token definition template (cmdline API). */
14296 : : static struct cmdline_token_hdr cmd_set_raw_token_hdr = {
14297 : : .ops = &(struct cmdline_token_ops){
14298 : : .parse = cmd_flow_parse,
14299 : : .complete_get_nb = cmd_flow_complete_get_nb,
14300 : : .complete_get_elt = cmd_flow_complete_get_elt,
14301 : : .get_help = cmd_set_raw_get_help,
14302 : : },
14303 : : .offset = 0,
14304 : : };
14305 : :
14306 : : /** Populate the next dynamic token. */
14307 : : static void
14308 : 0 : cmd_set_raw_tok(cmdline_parse_token_hdr_t **hdr,
14309 : : cmdline_parse_token_hdr_t **hdr_inst)
14310 : : {
14311 : : struct context *ctx = &cmd_flow_context;
14312 : :
14313 : : /* Always reinitialize context before requesting the first token. */
14314 : 0 : if (!(hdr_inst - cmd_set_raw.tokens)) {
14315 : : cmd_flow_context_init(ctx);
14316 : 0 : ctx->curr = START_SET;
14317 : : }
14318 : : /* Return NULL when no more tokens are expected. */
14319 : 0 : if (!ctx->next_num && (ctx->curr != START_SET)) {
14320 : 0 : *hdr = NULL;
14321 : 0 : return;
14322 : : }
14323 : : /* Determine if command should end here. */
14324 : 0 : if (ctx->eol && ctx->last && ctx->next_num) {
14325 : 0 : const enum index *list = ctx->next[ctx->next_num - 1];
14326 : : int i;
14327 : :
14328 : 0 : for (i = 0; list[i]; ++i) {
14329 : 0 : if (list[i] != END)
14330 : : continue;
14331 : 0 : *hdr = NULL;
14332 : 0 : return;
14333 : : }
14334 : : }
14335 : 0 : *hdr = &cmd_set_raw_token_hdr;
14336 : : }
14337 : :
14338 : : /** Token generator and output processing callback (cmdline API). */
14339 : : static void
14340 : 0 : cmd_set_raw_cb(void *arg0, struct cmdline *cl, void *arg2)
14341 : : {
14342 : 0 : if (cl == NULL)
14343 : 0 : cmd_set_raw_tok(arg0, arg2);
14344 : : else
14345 : 0 : cmd_set_raw_parsed(arg0);
14346 : 0 : }
14347 : :
14348 : : /** Global parser instance (cmdline API). */
14349 : : cmdline_parse_inst_t cmd_set_raw = {
14350 : : .f = cmd_set_raw_cb,
14351 : : .data = NULL, /**< Unused. */
14352 : : .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
14353 : : .tokens = {
14354 : : NULL,
14355 : : }, /**< Tokens are returned by cmd_flow_tok(). */
14356 : : };
14357 : :
14358 : : /* *** display raw_encap/raw_decap buf */
14359 : : struct cmd_show_set_raw_result {
14360 : : cmdline_fixed_string_t cmd_show;
14361 : : cmdline_fixed_string_t cmd_what;
14362 : : cmdline_fixed_string_t cmd_all;
14363 : : uint16_t cmd_index;
14364 : : };
14365 : :
14366 : : static void
14367 : 0 : cmd_show_set_raw_parsed(void *parsed_result, struct cmdline *cl, void *data)
14368 : : {
14369 : : struct cmd_show_set_raw_result *res = parsed_result;
14370 : 0 : uint16_t index = res->cmd_index;
14371 : : uint8_t all = 0;
14372 : : uint8_t *raw_data = NULL;
14373 : : size_t raw_size = 0;
14374 : 0 : char title[16] = {0};
14375 : :
14376 : : RTE_SET_USED(cl);
14377 : : RTE_SET_USED(data);
14378 : 0 : if (!strcmp(res->cmd_all, "all")) {
14379 : : all = 1;
14380 : : index = 0;
14381 : 0 : } else if (index >= RAW_ENCAP_CONFS_MAX_NUM) {
14382 : 0 : fprintf(stderr, "index should be 0-%u\n",
14383 : : RAW_ENCAP_CONFS_MAX_NUM - 1);
14384 : 0 : return;
14385 : : }
14386 : : do {
14387 : 0 : if (!strcmp(res->cmd_what, "raw_encap")) {
14388 : 0 : raw_data = (uint8_t *)&raw_encap_confs[index].data;
14389 : 0 : raw_size = raw_encap_confs[index].size;
14390 : : snprintf(title, 16, "\nindex: %u", index);
14391 : 0 : rte_hexdump(stdout, title, raw_data, raw_size);
14392 : : } else {
14393 : 0 : raw_data = (uint8_t *)&raw_decap_confs[index].data;
14394 : 0 : raw_size = raw_decap_confs[index].size;
14395 : : snprintf(title, 16, "\nindex: %u", index);
14396 : 0 : rte_hexdump(stdout, title, raw_data, raw_size);
14397 : : }
14398 : 0 : } while (all && ++index < RAW_ENCAP_CONFS_MAX_NUM);
14399 : : }
14400 : :
14401 : : static cmdline_parse_token_string_t cmd_show_set_raw_cmd_show =
14402 : : TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
14403 : : cmd_show, "show");
14404 : : static cmdline_parse_token_string_t cmd_show_set_raw_cmd_what =
14405 : : TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
14406 : : cmd_what, "raw_encap#raw_decap");
14407 : : static cmdline_parse_token_num_t cmd_show_set_raw_cmd_index =
14408 : : TOKEN_NUM_INITIALIZER(struct cmd_show_set_raw_result,
14409 : : cmd_index, RTE_UINT16);
14410 : : static cmdline_parse_token_string_t cmd_show_set_raw_cmd_all =
14411 : : TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
14412 : : cmd_all, "all");
14413 : : cmdline_parse_inst_t cmd_show_set_raw = {
14414 : : .f = cmd_show_set_raw_parsed,
14415 : : .data = NULL,
14416 : : .help_str = "show <raw_encap|raw_decap> <index>",
14417 : : .tokens = {
14418 : : (void *)&cmd_show_set_raw_cmd_show,
14419 : : (void *)&cmd_show_set_raw_cmd_what,
14420 : : (void *)&cmd_show_set_raw_cmd_index,
14421 : : NULL,
14422 : : },
14423 : : };
14424 : : cmdline_parse_inst_t cmd_show_set_raw_all = {
14425 : : .f = cmd_show_set_raw_parsed,
14426 : : .data = NULL,
14427 : : .help_str = "show <raw_encap|raw_decap> all",
14428 : : .tokens = {
14429 : : (void *)&cmd_show_set_raw_cmd_show,
14430 : : (void *)&cmd_show_set_raw_cmd_what,
14431 : : (void *)&cmd_show_set_raw_cmd_all,
14432 : : NULL,
14433 : : },
14434 : : };
|