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 : : DUMP_FILE_PATH,
271 : :
272 : : DUMP_WRITE,
273 : : DUMP_APPEND,
274 : : /* Configure arguments */
275 : : CONFIG_QUEUES_NUMBER,
276 : : CONFIG_QUEUES_SIZE,
277 : : CONFIG_COUNTERS_NUMBER,
278 : : CONFIG_AGING_OBJECTS_NUMBER,
279 : : CONFIG_METERS_NUMBER,
280 : : CONFIG_CONN_TRACK_NUMBER,
281 : : CONFIG_QUOTAS_NUMBER,
282 : : CONFIG_FLAGS,
283 : : CONFIG_HOST_PORT,
284 : :
285 : : /* Indirect action arguments */
286 : : INDIRECT_ACTION_CREATE,
287 : : INDIRECT_ACTION_LIST_CREATE,
288 : : INDIRECT_ACTION_FLOW_CONF_CREATE,
289 : : INDIRECT_ACTION_UPDATE,
290 : : INDIRECT_ACTION_DESTROY,
291 : : INDIRECT_ACTION_QUERY,
292 : : INDIRECT_ACTION_QUERY_UPDATE,
293 : :
294 : : /* Indirect action create arguments */
295 : : INDIRECT_ACTION_CREATE_ID,
296 : : INDIRECT_ACTION_INGRESS,
297 : : INDIRECT_ACTION_EGRESS,
298 : : INDIRECT_ACTION_TRANSFER,
299 : : INDIRECT_ACTION_SPEC,
300 : : INDIRECT_ACTION_LIST,
301 : : INDIRECT_ACTION_FLOW_CONF,
302 : :
303 : : /* Indirect action destroy arguments */
304 : : INDIRECT_ACTION_DESTROY_ID,
305 : :
306 : : /* Indirect action query-and-update arguments */
307 : : INDIRECT_ACTION_QU_MODE,
308 : : INDIRECT_ACTION_QU_MODE_NAME,
309 : :
310 : : /* Validate/create pattern. */
311 : : ITEM_PATTERN,
312 : : ITEM_PARAM_IS,
313 : : ITEM_PARAM_SPEC,
314 : : ITEM_PARAM_LAST,
315 : : ITEM_PARAM_MASK,
316 : : ITEM_PARAM_PREFIX,
317 : : ITEM_NEXT,
318 : : ITEM_END,
319 : : ITEM_VOID,
320 : : ITEM_INVERT,
321 : : ITEM_ANY,
322 : : ITEM_ANY_NUM,
323 : : ITEM_PORT_ID,
324 : : ITEM_PORT_ID_ID,
325 : : ITEM_MARK,
326 : : ITEM_MARK_ID,
327 : : ITEM_RAW,
328 : : ITEM_RAW_RELATIVE,
329 : : ITEM_RAW_SEARCH,
330 : : ITEM_RAW_OFFSET,
331 : : ITEM_RAW_LIMIT,
332 : : ITEM_RAW_PATTERN,
333 : : ITEM_RAW_PATTERN_HEX,
334 : : ITEM_ETH,
335 : : ITEM_ETH_DST,
336 : : ITEM_ETH_SRC,
337 : : ITEM_ETH_TYPE,
338 : : ITEM_ETH_HAS_VLAN,
339 : : ITEM_VLAN,
340 : : ITEM_VLAN_TCI,
341 : : ITEM_VLAN_PCP,
342 : : ITEM_VLAN_DEI,
343 : : ITEM_VLAN_VID,
344 : : ITEM_VLAN_INNER_TYPE,
345 : : ITEM_VLAN_HAS_MORE_VLAN,
346 : : ITEM_IPV4,
347 : : ITEM_IPV4_VER_IHL,
348 : : ITEM_IPV4_TOS,
349 : : ITEM_IPV4_LENGTH,
350 : : ITEM_IPV4_ID,
351 : : ITEM_IPV4_FRAGMENT_OFFSET,
352 : : ITEM_IPV4_TTL,
353 : : ITEM_IPV4_PROTO,
354 : : ITEM_IPV4_SRC,
355 : : ITEM_IPV4_DST,
356 : : ITEM_IPV6,
357 : : ITEM_IPV6_TC,
358 : : ITEM_IPV6_FLOW,
359 : : ITEM_IPV6_LEN,
360 : : ITEM_IPV6_PROTO,
361 : : ITEM_IPV6_HOP,
362 : : ITEM_IPV6_SRC,
363 : : ITEM_IPV6_DST,
364 : : ITEM_IPV6_HAS_FRAG_EXT,
365 : : ITEM_IPV6_ROUTING_EXT,
366 : : ITEM_IPV6_ROUTING_EXT_TYPE,
367 : : ITEM_IPV6_ROUTING_EXT_NEXT_HDR,
368 : : ITEM_IPV6_ROUTING_EXT_SEG_LEFT,
369 : : ITEM_ICMP,
370 : : ITEM_ICMP_TYPE,
371 : : ITEM_ICMP_CODE,
372 : : ITEM_ICMP_IDENT,
373 : : ITEM_ICMP_SEQ,
374 : : ITEM_UDP,
375 : : ITEM_UDP_SRC,
376 : : ITEM_UDP_DST,
377 : : ITEM_TCP,
378 : : ITEM_TCP_SRC,
379 : : ITEM_TCP_DST,
380 : : ITEM_TCP_FLAGS,
381 : : ITEM_SCTP,
382 : : ITEM_SCTP_SRC,
383 : : ITEM_SCTP_DST,
384 : : ITEM_SCTP_TAG,
385 : : ITEM_SCTP_CKSUM,
386 : : ITEM_VXLAN,
387 : : ITEM_VXLAN_VNI,
388 : : ITEM_VXLAN_FLAG_G,
389 : : ITEM_VXLAN_FLAG_VER,
390 : : ITEM_VXLAN_FLAG_I,
391 : : ITEM_VXLAN_FLAG_P,
392 : : ITEM_VXLAN_FLAG_B,
393 : : ITEM_VXLAN_FLAG_O,
394 : : ITEM_VXLAN_FLAG_D,
395 : : ITEM_VXLAN_FLAG_A,
396 : : ITEM_VXLAN_GBP_ID,
397 : : /* Used for "struct rte_vxlan_hdr", GPE Next protocol */
398 : : ITEM_VXLAN_GPE_PROTO,
399 : : ITEM_VXLAN_FIRST_RSVD,
400 : : ITEM_VXLAN_SECND_RSVD,
401 : : ITEM_VXLAN_THIRD_RSVD,
402 : : ITEM_VXLAN_LAST_RSVD,
403 : : ITEM_E_TAG,
404 : : ITEM_E_TAG_GRP_ECID_B,
405 : : ITEM_NVGRE,
406 : : ITEM_NVGRE_TNI,
407 : : ITEM_MPLS,
408 : : ITEM_MPLS_LABEL,
409 : : ITEM_MPLS_TC,
410 : : ITEM_MPLS_S,
411 : : ITEM_MPLS_TTL,
412 : : ITEM_GRE,
413 : : ITEM_GRE_PROTO,
414 : : ITEM_GRE_C_RSVD0_VER,
415 : : ITEM_GRE_C_BIT,
416 : : ITEM_GRE_K_BIT,
417 : : ITEM_GRE_S_BIT,
418 : : ITEM_FUZZY,
419 : : ITEM_FUZZY_THRESH,
420 : : ITEM_GTP,
421 : : ITEM_GTP_FLAGS,
422 : : ITEM_GTP_MSG_TYPE,
423 : : ITEM_GTP_TEID,
424 : : ITEM_GTPC,
425 : : ITEM_GTPU,
426 : : ITEM_GENEVE,
427 : : ITEM_GENEVE_VNI,
428 : : ITEM_GENEVE_PROTO,
429 : : ITEM_GENEVE_OPTLEN,
430 : : ITEM_VXLAN_GPE,
431 : : ITEM_VXLAN_GPE_VNI,
432 : : /* Used for "struct rte_vxlan_gpe_hdr", deprecated, prefer ITEM_VXLAN_GPE_PROTO */
433 : : ITEM_VXLAN_GPE_PROTO_IN_DEPRECATED_VXLAN_GPE_HDR,
434 : : ITEM_VXLAN_GPE_FLAGS,
435 : : ITEM_VXLAN_GPE_RSVD0,
436 : : ITEM_VXLAN_GPE_RSVD1,
437 : : ITEM_ARP_ETH_IPV4,
438 : : ITEM_ARP_ETH_IPV4_SHA,
439 : : ITEM_ARP_ETH_IPV4_SPA,
440 : : ITEM_ARP_ETH_IPV4_THA,
441 : : ITEM_ARP_ETH_IPV4_TPA,
442 : : ITEM_IPV6_EXT,
443 : : ITEM_IPV6_EXT_NEXT_HDR,
444 : : ITEM_IPV6_FRAG_EXT,
445 : : ITEM_IPV6_FRAG_EXT_NEXT_HDR,
446 : : ITEM_IPV6_FRAG_EXT_FRAG_DATA,
447 : : ITEM_IPV6_FRAG_EXT_ID,
448 : : ITEM_ICMP6,
449 : : ITEM_ICMP6_TYPE,
450 : : ITEM_ICMP6_CODE,
451 : : ITEM_ICMP6_ECHO_REQUEST,
452 : : ITEM_ICMP6_ECHO_REQUEST_ID,
453 : : ITEM_ICMP6_ECHO_REQUEST_SEQ,
454 : : ITEM_ICMP6_ECHO_REPLY,
455 : : ITEM_ICMP6_ECHO_REPLY_ID,
456 : : ITEM_ICMP6_ECHO_REPLY_SEQ,
457 : : ITEM_ICMP6_ND_NS,
458 : : ITEM_ICMP6_ND_NS_TARGET_ADDR,
459 : : ITEM_ICMP6_ND_NA,
460 : : ITEM_ICMP6_ND_NA_TARGET_ADDR,
461 : : ITEM_ICMP6_ND_OPT,
462 : : ITEM_ICMP6_ND_OPT_TYPE,
463 : : ITEM_ICMP6_ND_OPT_SLA_ETH,
464 : : ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
465 : : ITEM_ICMP6_ND_OPT_TLA_ETH,
466 : : ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
467 : : ITEM_META,
468 : : ITEM_META_DATA,
469 : : ITEM_RANDOM,
470 : : ITEM_RANDOM_VALUE,
471 : : ITEM_GRE_KEY,
472 : : ITEM_GRE_KEY_VALUE,
473 : : ITEM_GRE_OPTION,
474 : : ITEM_GRE_OPTION_CHECKSUM,
475 : : ITEM_GRE_OPTION_KEY,
476 : : ITEM_GRE_OPTION_SEQUENCE,
477 : : ITEM_GTP_PSC,
478 : : ITEM_GTP_PSC_QFI,
479 : : ITEM_GTP_PSC_PDU_T,
480 : : ITEM_PPPOES,
481 : : ITEM_PPPOED,
482 : : ITEM_PPPOE_SEID,
483 : : ITEM_PPPOE_PROTO_ID,
484 : : ITEM_HIGIG2,
485 : : ITEM_HIGIG2_CLASSIFICATION,
486 : : ITEM_HIGIG2_VID,
487 : : ITEM_TAG,
488 : : ITEM_TAG_DATA,
489 : : ITEM_TAG_INDEX,
490 : : ITEM_L2TPV3OIP,
491 : : ITEM_L2TPV3OIP_SESSION_ID,
492 : : ITEM_ESP,
493 : : ITEM_ESP_SPI,
494 : : ITEM_AH,
495 : : ITEM_AH_SPI,
496 : : ITEM_PFCP,
497 : : ITEM_PFCP_S_FIELD,
498 : : ITEM_PFCP_SEID,
499 : : ITEM_ECPRI,
500 : : ITEM_ECPRI_COMMON,
501 : : ITEM_ECPRI_COMMON_TYPE,
502 : : ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
503 : : ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
504 : : ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
505 : : ITEM_ECPRI_MSG_IQ_DATA_PCID,
506 : : ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
507 : : ITEM_ECPRI_MSG_DLY_MSR_MSRID,
508 : : ITEM_GENEVE_OPT,
509 : : ITEM_GENEVE_OPT_CLASS,
510 : : ITEM_GENEVE_OPT_TYPE,
511 : : ITEM_GENEVE_OPT_LENGTH,
512 : : ITEM_GENEVE_OPT_DATA,
513 : : ITEM_INTEGRITY,
514 : : ITEM_INTEGRITY_LEVEL,
515 : : ITEM_INTEGRITY_VALUE,
516 : : ITEM_CONNTRACK,
517 : : ITEM_POL_PORT,
518 : : ITEM_POL_METER,
519 : : ITEM_POL_POLICY,
520 : : ITEM_PORT_REPRESENTOR,
521 : : ITEM_PORT_REPRESENTOR_PORT_ID,
522 : : ITEM_REPRESENTED_PORT,
523 : : ITEM_REPRESENTED_PORT_ETHDEV_PORT_ID,
524 : : ITEM_FLEX,
525 : : ITEM_FLEX_ITEM_HANDLE,
526 : : ITEM_FLEX_PATTERN_HANDLE,
527 : : ITEM_L2TPV2,
528 : : ITEM_L2TPV2_TYPE,
529 : : ITEM_L2TPV2_TYPE_DATA,
530 : : ITEM_L2TPV2_TYPE_DATA_L,
531 : : ITEM_L2TPV2_TYPE_DATA_S,
532 : : ITEM_L2TPV2_TYPE_DATA_O,
533 : : ITEM_L2TPV2_TYPE_DATA_L_S,
534 : : ITEM_L2TPV2_TYPE_CTRL,
535 : : ITEM_L2TPV2_MSG_DATA_TUNNEL_ID,
536 : : ITEM_L2TPV2_MSG_DATA_SESSION_ID,
537 : : ITEM_L2TPV2_MSG_DATA_L_LENGTH,
538 : : ITEM_L2TPV2_MSG_DATA_L_TUNNEL_ID,
539 : : ITEM_L2TPV2_MSG_DATA_L_SESSION_ID,
540 : : ITEM_L2TPV2_MSG_DATA_S_TUNNEL_ID,
541 : : ITEM_L2TPV2_MSG_DATA_S_SESSION_ID,
542 : : ITEM_L2TPV2_MSG_DATA_S_NS,
543 : : ITEM_L2TPV2_MSG_DATA_S_NR,
544 : : ITEM_L2TPV2_MSG_DATA_O_TUNNEL_ID,
545 : : ITEM_L2TPV2_MSG_DATA_O_SESSION_ID,
546 : : ITEM_L2TPV2_MSG_DATA_O_OFFSET,
547 : : ITEM_L2TPV2_MSG_DATA_L_S_LENGTH,
548 : : ITEM_L2TPV2_MSG_DATA_L_S_TUNNEL_ID,
549 : : ITEM_L2TPV2_MSG_DATA_L_S_SESSION_ID,
550 : : ITEM_L2TPV2_MSG_DATA_L_S_NS,
551 : : ITEM_L2TPV2_MSG_DATA_L_S_NR,
552 : : ITEM_L2TPV2_MSG_CTRL_LENGTH,
553 : : ITEM_L2TPV2_MSG_CTRL_TUNNEL_ID,
554 : : ITEM_L2TPV2_MSG_CTRL_SESSION_ID,
555 : : ITEM_L2TPV2_MSG_CTRL_NS,
556 : : ITEM_L2TPV2_MSG_CTRL_NR,
557 : : ITEM_PPP,
558 : : ITEM_PPP_ADDR,
559 : : ITEM_PPP_CTRL,
560 : : ITEM_PPP_PROTO_ID,
561 : : ITEM_METER,
562 : : ITEM_METER_COLOR,
563 : : ITEM_QUOTA,
564 : : ITEM_QUOTA_STATE,
565 : : ITEM_QUOTA_STATE_NAME,
566 : : ITEM_AGGR_AFFINITY,
567 : : ITEM_AGGR_AFFINITY_VALUE,
568 : : ITEM_TX_QUEUE,
569 : : ITEM_TX_QUEUE_VALUE,
570 : : ITEM_IB_BTH,
571 : : ITEM_IB_BTH_OPCODE,
572 : : ITEM_IB_BTH_PKEY,
573 : : ITEM_IB_BTH_DST_QPN,
574 : : ITEM_IB_BTH_PSN,
575 : : ITEM_IPV6_PUSH_REMOVE_EXT,
576 : : ITEM_IPV6_PUSH_REMOVE_EXT_TYPE,
577 : : ITEM_PTYPE,
578 : : ITEM_PTYPE_VALUE,
579 : : ITEM_NSH,
580 : : ITEM_COMPARE,
581 : : ITEM_COMPARE_OP,
582 : : ITEM_COMPARE_OP_VALUE,
583 : : ITEM_COMPARE_FIELD_A_TYPE,
584 : : ITEM_COMPARE_FIELD_A_TYPE_VALUE,
585 : : ITEM_COMPARE_FIELD_A_LEVEL,
586 : : ITEM_COMPARE_FIELD_A_LEVEL_VALUE,
587 : : ITEM_COMPARE_FIELD_A_TAG_INDEX,
588 : : ITEM_COMPARE_FIELD_A_TYPE_ID,
589 : : ITEM_COMPARE_FIELD_A_CLASS_ID,
590 : : ITEM_COMPARE_FIELD_A_OFFSET,
591 : : ITEM_COMPARE_FIELD_B_TYPE,
592 : : ITEM_COMPARE_FIELD_B_TYPE_VALUE,
593 : : ITEM_COMPARE_FIELD_B_LEVEL,
594 : : ITEM_COMPARE_FIELD_B_LEVEL_VALUE,
595 : : ITEM_COMPARE_FIELD_B_TAG_INDEX,
596 : : ITEM_COMPARE_FIELD_B_TYPE_ID,
597 : : ITEM_COMPARE_FIELD_B_CLASS_ID,
598 : : ITEM_COMPARE_FIELD_B_OFFSET,
599 : : ITEM_COMPARE_FIELD_B_VALUE,
600 : : ITEM_COMPARE_FIELD_B_POINTER,
601 : : ITEM_COMPARE_FIELD_WIDTH,
602 : :
603 : : /* Validate/create actions. */
604 : : ACTIONS,
605 : : ACTION_NEXT,
606 : : ACTION_END,
607 : : ACTION_VOID,
608 : : ACTION_PASSTHRU,
609 : : ACTION_SKIP_CMAN,
610 : : ACTION_JUMP,
611 : : ACTION_JUMP_GROUP,
612 : : ACTION_MARK,
613 : : ACTION_MARK_ID,
614 : : ACTION_FLAG,
615 : : ACTION_QUEUE,
616 : : ACTION_QUEUE_INDEX,
617 : : ACTION_DROP,
618 : : ACTION_COUNT,
619 : : ACTION_COUNT_ID,
620 : : ACTION_RSS,
621 : : ACTION_RSS_FUNC,
622 : : ACTION_RSS_LEVEL,
623 : : ACTION_RSS_FUNC_DEFAULT,
624 : : ACTION_RSS_FUNC_TOEPLITZ,
625 : : ACTION_RSS_FUNC_SIMPLE_XOR,
626 : : ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ,
627 : : ACTION_RSS_TYPES,
628 : : ACTION_RSS_TYPE,
629 : : ACTION_RSS_KEY,
630 : : ACTION_RSS_KEY_LEN,
631 : : ACTION_RSS_QUEUES,
632 : : ACTION_RSS_QUEUE,
633 : : ACTION_PF,
634 : : ACTION_VF,
635 : : ACTION_VF_ORIGINAL,
636 : : ACTION_VF_ID,
637 : : ACTION_PORT_ID,
638 : : ACTION_PORT_ID_ORIGINAL,
639 : : ACTION_PORT_ID_ID,
640 : : ACTION_METER,
641 : : ACTION_METER_COLOR,
642 : : ACTION_METER_COLOR_TYPE,
643 : : ACTION_METER_COLOR_GREEN,
644 : : ACTION_METER_COLOR_YELLOW,
645 : : ACTION_METER_COLOR_RED,
646 : : ACTION_METER_ID,
647 : : ACTION_METER_MARK,
648 : : ACTION_METER_MARK_CONF,
649 : : ACTION_METER_MARK_CONF_COLOR,
650 : : ACTION_METER_PROFILE,
651 : : ACTION_METER_PROFILE_ID2PTR,
652 : : ACTION_METER_POLICY,
653 : : ACTION_METER_POLICY_ID2PTR,
654 : : ACTION_METER_COLOR_MODE,
655 : : ACTION_METER_STATE,
656 : : ACTION_OF_DEC_NW_TTL,
657 : : ACTION_OF_POP_VLAN,
658 : : ACTION_OF_PUSH_VLAN,
659 : : ACTION_OF_PUSH_VLAN_ETHERTYPE,
660 : : ACTION_OF_SET_VLAN_VID,
661 : : ACTION_OF_SET_VLAN_VID_VLAN_VID,
662 : : ACTION_OF_SET_VLAN_PCP,
663 : : ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
664 : : ACTION_OF_POP_MPLS,
665 : : ACTION_OF_POP_MPLS_ETHERTYPE,
666 : : ACTION_OF_PUSH_MPLS,
667 : : ACTION_OF_PUSH_MPLS_ETHERTYPE,
668 : : ACTION_VXLAN_ENCAP,
669 : : ACTION_VXLAN_DECAP,
670 : : ACTION_NVGRE_ENCAP,
671 : : ACTION_NVGRE_DECAP,
672 : : ACTION_L2_ENCAP,
673 : : ACTION_L2_DECAP,
674 : : ACTION_MPLSOGRE_ENCAP,
675 : : ACTION_MPLSOGRE_DECAP,
676 : : ACTION_MPLSOUDP_ENCAP,
677 : : ACTION_MPLSOUDP_DECAP,
678 : : ACTION_SET_IPV4_SRC,
679 : : ACTION_SET_IPV4_SRC_IPV4_SRC,
680 : : ACTION_SET_IPV4_DST,
681 : : ACTION_SET_IPV4_DST_IPV4_DST,
682 : : ACTION_SET_IPV6_SRC,
683 : : ACTION_SET_IPV6_SRC_IPV6_SRC,
684 : : ACTION_SET_IPV6_DST,
685 : : ACTION_SET_IPV6_DST_IPV6_DST,
686 : : ACTION_SET_TP_SRC,
687 : : ACTION_SET_TP_SRC_TP_SRC,
688 : : ACTION_SET_TP_DST,
689 : : ACTION_SET_TP_DST_TP_DST,
690 : : ACTION_MAC_SWAP,
691 : : ACTION_DEC_TTL,
692 : : ACTION_SET_TTL,
693 : : ACTION_SET_TTL_TTL,
694 : : ACTION_SET_MAC_SRC,
695 : : ACTION_SET_MAC_SRC_MAC_SRC,
696 : : ACTION_SET_MAC_DST,
697 : : ACTION_SET_MAC_DST_MAC_DST,
698 : : ACTION_INC_TCP_SEQ,
699 : : ACTION_INC_TCP_SEQ_VALUE,
700 : : ACTION_DEC_TCP_SEQ,
701 : : ACTION_DEC_TCP_SEQ_VALUE,
702 : : ACTION_INC_TCP_ACK,
703 : : ACTION_INC_TCP_ACK_VALUE,
704 : : ACTION_DEC_TCP_ACK,
705 : : ACTION_DEC_TCP_ACK_VALUE,
706 : : ACTION_RAW_ENCAP,
707 : : ACTION_RAW_DECAP,
708 : : ACTION_RAW_ENCAP_SIZE,
709 : : ACTION_RAW_ENCAP_INDEX,
710 : : ACTION_RAW_ENCAP_INDEX_VALUE,
711 : : ACTION_RAW_DECAP_INDEX,
712 : : ACTION_RAW_DECAP_INDEX_VALUE,
713 : : ACTION_SET_TAG,
714 : : ACTION_SET_TAG_DATA,
715 : : ACTION_SET_TAG_INDEX,
716 : : ACTION_SET_TAG_MASK,
717 : : ACTION_SET_META,
718 : : ACTION_SET_META_DATA,
719 : : ACTION_SET_META_MASK,
720 : : ACTION_SET_IPV4_DSCP,
721 : : ACTION_SET_IPV4_DSCP_VALUE,
722 : : ACTION_SET_IPV6_DSCP,
723 : : ACTION_SET_IPV6_DSCP_VALUE,
724 : : ACTION_AGE,
725 : : ACTION_AGE_TIMEOUT,
726 : : ACTION_AGE_UPDATE,
727 : : ACTION_AGE_UPDATE_TIMEOUT,
728 : : ACTION_AGE_UPDATE_TOUCH,
729 : : ACTION_SAMPLE,
730 : : ACTION_SAMPLE_RATIO,
731 : : ACTION_SAMPLE_INDEX,
732 : : ACTION_SAMPLE_INDEX_VALUE,
733 : : ACTION_INDIRECT,
734 : : ACTION_INDIRECT_LIST,
735 : : ACTION_INDIRECT_LIST_HANDLE,
736 : : ACTION_INDIRECT_LIST_CONF,
737 : : INDIRECT_LIST_ACTION_ID2PTR_HANDLE,
738 : : INDIRECT_LIST_ACTION_ID2PTR_CONF,
739 : : ACTION_SHARED_INDIRECT,
740 : : INDIRECT_ACTION_PORT,
741 : : INDIRECT_ACTION_ID2PTR,
742 : : ACTION_MODIFY_FIELD,
743 : : ACTION_MODIFY_FIELD_OP,
744 : : ACTION_MODIFY_FIELD_OP_VALUE,
745 : : ACTION_MODIFY_FIELD_DST_TYPE,
746 : : ACTION_MODIFY_FIELD_DST_TYPE_VALUE,
747 : : ACTION_MODIFY_FIELD_DST_LEVEL,
748 : : ACTION_MODIFY_FIELD_DST_LEVEL_VALUE,
749 : : ACTION_MODIFY_FIELD_DST_TAG_INDEX,
750 : : ACTION_MODIFY_FIELD_DST_TYPE_ID,
751 : : ACTION_MODIFY_FIELD_DST_CLASS_ID,
752 : : ACTION_MODIFY_FIELD_DST_OFFSET,
753 : : ACTION_MODIFY_FIELD_SRC_TYPE,
754 : : ACTION_MODIFY_FIELD_SRC_TYPE_VALUE,
755 : : ACTION_MODIFY_FIELD_SRC_LEVEL,
756 : : ACTION_MODIFY_FIELD_SRC_LEVEL_VALUE,
757 : : ACTION_MODIFY_FIELD_SRC_TAG_INDEX,
758 : : ACTION_MODIFY_FIELD_SRC_TYPE_ID,
759 : : ACTION_MODIFY_FIELD_SRC_CLASS_ID,
760 : : ACTION_MODIFY_FIELD_SRC_OFFSET,
761 : : ACTION_MODIFY_FIELD_SRC_VALUE,
762 : : ACTION_MODIFY_FIELD_SRC_POINTER,
763 : : ACTION_MODIFY_FIELD_WIDTH,
764 : : ACTION_CONNTRACK,
765 : : ACTION_CONNTRACK_UPDATE,
766 : : ACTION_CONNTRACK_UPDATE_DIR,
767 : : ACTION_CONNTRACK_UPDATE_CTX,
768 : : ACTION_POL_G,
769 : : ACTION_POL_Y,
770 : : ACTION_POL_R,
771 : : ACTION_PORT_REPRESENTOR,
772 : : ACTION_PORT_REPRESENTOR_PORT_ID,
773 : : ACTION_REPRESENTED_PORT,
774 : : ACTION_REPRESENTED_PORT_ETHDEV_PORT_ID,
775 : : ACTION_SEND_TO_KERNEL,
776 : : ACTION_QUOTA_CREATE,
777 : : ACTION_QUOTA_CREATE_LIMIT,
778 : : ACTION_QUOTA_CREATE_MODE,
779 : : ACTION_QUOTA_CREATE_MODE_NAME,
780 : : ACTION_QUOTA_QU,
781 : : ACTION_QUOTA_QU_LIMIT,
782 : : ACTION_QUOTA_QU_UPDATE_OP,
783 : : ACTION_QUOTA_QU_UPDATE_OP_NAME,
784 : : ACTION_IPV6_EXT_REMOVE,
785 : : ACTION_IPV6_EXT_REMOVE_INDEX,
786 : : ACTION_IPV6_EXT_REMOVE_INDEX_VALUE,
787 : : ACTION_IPV6_EXT_PUSH,
788 : : ACTION_IPV6_EXT_PUSH_INDEX,
789 : : ACTION_IPV6_EXT_PUSH_INDEX_VALUE,
790 : : ACTION_NAT64,
791 : : ACTION_NAT64_MODE,
792 : : ACTION_JUMP_TO_TABLE_INDEX,
793 : : ACTION_JUMP_TO_TABLE_INDEX_TABLE,
794 : : ACTION_JUMP_TO_TABLE_INDEX_TABLE_VALUE,
795 : : ACTION_JUMP_TO_TABLE_INDEX_INDEX,
796 : : };
797 : :
798 : : /** Maximum size for pattern in struct rte_flow_item_raw. */
799 : : #define ITEM_RAW_PATTERN_SIZE 512
800 : :
801 : : /** Maximum size for GENEVE option data pattern in bytes. */
802 : : #define ITEM_GENEVE_OPT_DATA_SIZE 124
803 : :
804 : : /** Storage size for struct rte_flow_item_raw including pattern. */
805 : : #define ITEM_RAW_SIZE \
806 : : (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE)
807 : :
808 : : static const char *const compare_ops[] = {
809 : : "eq", "ne", "lt", "le", "gt", "ge", NULL
810 : : };
811 : :
812 : : /** Maximum size for external pattern in struct rte_flow_field_data. */
813 : : #define FLOW_FIELD_PATTERN_SIZE 32
814 : :
815 : : /** Storage size for struct rte_flow_action_modify_field including pattern. */
816 : : #define ACTION_MODIFY_SIZE \
817 : : (sizeof(struct rte_flow_action_modify_field) + \
818 : : FLOW_FIELD_PATTERN_SIZE)
819 : :
820 : : /** Maximum number of queue indices in struct rte_flow_action_rss. */
821 : : #define ACTION_RSS_QUEUE_NUM 128
822 : :
823 : : /** Storage for struct rte_flow_action_rss including external data. */
824 : : struct action_rss_data {
825 : : struct rte_flow_action_rss conf;
826 : : uint8_t key[RSS_HASH_KEY_LENGTH];
827 : : uint16_t queue[ACTION_RSS_QUEUE_NUM];
828 : : };
829 : :
830 : : /** Maximum data size in struct rte_flow_action_raw_encap. */
831 : : #define ACTION_RAW_ENCAP_MAX_DATA 512
832 : : #define RAW_ENCAP_CONFS_MAX_NUM 8
833 : :
834 : : /** Storage for struct rte_flow_action_raw_encap. */
835 : : struct raw_encap_conf {
836 : : uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
837 : : uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
838 : : size_t size;
839 : : };
840 : :
841 : : struct raw_encap_conf raw_encap_confs[RAW_ENCAP_CONFS_MAX_NUM];
842 : :
843 : : /** Storage for struct rte_flow_action_raw_encap including external data. */
844 : : struct action_raw_encap_data {
845 : : struct rte_flow_action_raw_encap conf;
846 : : uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
847 : : uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
848 : : uint16_t idx;
849 : : };
850 : :
851 : : /** Storage for struct rte_flow_action_raw_decap. */
852 : : struct raw_decap_conf {
853 : : uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
854 : : size_t size;
855 : : };
856 : :
857 : : struct raw_decap_conf raw_decap_confs[RAW_ENCAP_CONFS_MAX_NUM];
858 : :
859 : : /** Storage for struct rte_flow_action_raw_decap including external data. */
860 : : struct action_raw_decap_data {
861 : : struct rte_flow_action_raw_decap conf;
862 : : uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
863 : : uint16_t idx;
864 : : };
865 : :
866 : : /** Maximum data size in struct rte_flow_action_ipv6_ext_push. */
867 : : #define ACTION_IPV6_EXT_PUSH_MAX_DATA 512
868 : : #define IPV6_EXT_PUSH_CONFS_MAX_NUM 8
869 : :
870 : : /** Storage for struct rte_flow_action_ipv6_ext_push. */
871 : : struct ipv6_ext_push_conf {
872 : : uint8_t data[ACTION_IPV6_EXT_PUSH_MAX_DATA];
873 : : size_t size;
874 : : uint8_t type;
875 : : };
876 : :
877 : : struct ipv6_ext_push_conf ipv6_ext_push_confs[IPV6_EXT_PUSH_CONFS_MAX_NUM];
878 : :
879 : : /** Storage for struct rte_flow_action_ipv6_ext_push including external data. */
880 : : struct action_ipv6_ext_push_data {
881 : : struct rte_flow_action_ipv6_ext_push conf;
882 : : uint8_t data[ACTION_IPV6_EXT_PUSH_MAX_DATA];
883 : : uint8_t type;
884 : : uint16_t idx;
885 : : };
886 : :
887 : : /** Storage for struct rte_flow_action_ipv6_ext_remove. */
888 : : struct ipv6_ext_remove_conf {
889 : : struct rte_flow_action_ipv6_ext_remove conf;
890 : : uint8_t type;
891 : : };
892 : :
893 : : struct ipv6_ext_remove_conf ipv6_ext_remove_confs[IPV6_EXT_PUSH_CONFS_MAX_NUM];
894 : :
895 : : /** Storage for struct rte_flow_action_ipv6_ext_remove including external data. */
896 : : struct action_ipv6_ext_remove_data {
897 : : struct rte_flow_action_ipv6_ext_remove conf;
898 : : uint8_t type;
899 : : uint16_t idx;
900 : : };
901 : :
902 : : struct vxlan_encap_conf vxlan_encap_conf = {
903 : : .select_ipv4 = 1,
904 : : .select_vlan = 0,
905 : : .select_tos_ttl = 0,
906 : : .vni = { 0x00, 0x00, 0x00 },
907 : : .udp_src = 0,
908 : : .udp_dst = RTE_BE16(RTE_VXLAN_DEFAULT_PORT),
909 : : .ipv4_src = RTE_IPV4(127, 0, 0, 1),
910 : : .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
911 : : .ipv6_src = RTE_IPV6_ADDR_LOOPBACK,
912 : : .ipv6_dst = RTE_IPV6(0, 0, 0, 0, 0, 0, 0, 0x1111),
913 : : .vlan_tci = 0,
914 : : .ip_tos = 0,
915 : : .ip_ttl = 255,
916 : : .eth_src = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
917 : : .eth_dst = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
918 : : };
919 : :
920 : : /** Maximum number of items in struct rte_flow_action_vxlan_encap. */
921 : : #define ACTION_VXLAN_ENCAP_ITEMS_NUM 6
922 : :
923 : : /** Storage for struct rte_flow_action_vxlan_encap including external data. */
924 : : struct action_vxlan_encap_data {
925 : : struct rte_flow_action_vxlan_encap conf;
926 : : struct rte_flow_item items[ACTION_VXLAN_ENCAP_ITEMS_NUM];
927 : : struct rte_flow_item_eth item_eth;
928 : : struct rte_flow_item_vlan item_vlan;
929 : : union {
930 : : struct rte_flow_item_ipv4 item_ipv4;
931 : : struct rte_flow_item_ipv6 item_ipv6;
932 : : };
933 : : struct rte_flow_item_udp item_udp;
934 : : struct rte_flow_item_vxlan item_vxlan;
935 : : };
936 : :
937 : : struct nvgre_encap_conf nvgre_encap_conf = {
938 : : .select_ipv4 = 1,
939 : : .select_vlan = 0,
940 : : .tni = { 0x00, 0x00, 0x00 },
941 : : .ipv4_src = RTE_IPV4(127, 0, 0, 1),
942 : : .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
943 : : .ipv6_src = RTE_IPV6_ADDR_LOOPBACK,
944 : : .ipv6_dst = RTE_IPV6(0, 0, 0, 0, 0, 0, 0, 0x1111),
945 : : .vlan_tci = 0,
946 : : .eth_src = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
947 : : .eth_dst = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
948 : : };
949 : :
950 : : /** Maximum number of items in struct rte_flow_action_nvgre_encap. */
951 : : #define ACTION_NVGRE_ENCAP_ITEMS_NUM 5
952 : :
953 : : /** Storage for struct rte_flow_action_nvgre_encap including external data. */
954 : : struct action_nvgre_encap_data {
955 : : struct rte_flow_action_nvgre_encap conf;
956 : : struct rte_flow_item items[ACTION_NVGRE_ENCAP_ITEMS_NUM];
957 : : struct rte_flow_item_eth item_eth;
958 : : struct rte_flow_item_vlan item_vlan;
959 : : union {
960 : : struct rte_flow_item_ipv4 item_ipv4;
961 : : struct rte_flow_item_ipv6 item_ipv6;
962 : : };
963 : : struct rte_flow_item_nvgre item_nvgre;
964 : : };
965 : :
966 : : struct l2_encap_conf l2_encap_conf;
967 : :
968 : : struct l2_decap_conf l2_decap_conf;
969 : :
970 : : struct mplsogre_encap_conf mplsogre_encap_conf;
971 : :
972 : : struct mplsogre_decap_conf mplsogre_decap_conf;
973 : :
974 : : struct mplsoudp_encap_conf mplsoudp_encap_conf;
975 : :
976 : : struct mplsoudp_decap_conf mplsoudp_decap_conf;
977 : :
978 : : struct rte_flow_action_conntrack conntrack_context;
979 : :
980 : : #define ACTION_SAMPLE_ACTIONS_NUM 10
981 : : #define RAW_SAMPLE_CONFS_MAX_NUM 8
982 : : /** Storage for struct rte_flow_action_sample including external data. */
983 : : struct action_sample_data {
984 : : struct rte_flow_action_sample conf;
985 : : uint32_t idx;
986 : : };
987 : : /** Storage for struct rte_flow_action_sample. */
988 : : struct raw_sample_conf {
989 : : struct rte_flow_action data[ACTION_SAMPLE_ACTIONS_NUM];
990 : : };
991 : : struct raw_sample_conf raw_sample_confs[RAW_SAMPLE_CONFS_MAX_NUM];
992 : : struct rte_flow_action_mark sample_mark[RAW_SAMPLE_CONFS_MAX_NUM];
993 : : struct rte_flow_action_queue sample_queue[RAW_SAMPLE_CONFS_MAX_NUM];
994 : : struct rte_flow_action_count sample_count[RAW_SAMPLE_CONFS_MAX_NUM];
995 : : struct rte_flow_action_port_id sample_port_id[RAW_SAMPLE_CONFS_MAX_NUM];
996 : : struct rte_flow_action_raw_encap sample_encap[RAW_SAMPLE_CONFS_MAX_NUM];
997 : : struct action_vxlan_encap_data sample_vxlan_encap[RAW_SAMPLE_CONFS_MAX_NUM];
998 : : struct action_nvgre_encap_data sample_nvgre_encap[RAW_SAMPLE_CONFS_MAX_NUM];
999 : : struct action_rss_data sample_rss_data[RAW_SAMPLE_CONFS_MAX_NUM];
1000 : : struct rte_flow_action_vf sample_vf[RAW_SAMPLE_CONFS_MAX_NUM];
1001 : : struct rte_flow_action_ethdev sample_port_representor[RAW_SAMPLE_CONFS_MAX_NUM];
1002 : : struct rte_flow_action_ethdev sample_represented_port[RAW_SAMPLE_CONFS_MAX_NUM];
1003 : :
1004 : : static const char *const modify_field_ops[] = {
1005 : : "set", "add", "sub", NULL
1006 : : };
1007 : :
1008 : : static const char *const flow_field_ids[] = {
1009 : : "start", "mac_dst", "mac_src",
1010 : : "vlan_type", "vlan_id", "mac_type",
1011 : : "ipv4_dscp", "ipv4_ttl", "ipv4_src", "ipv4_dst",
1012 : : "ipv6_dscp", "ipv6_hoplimit", "ipv6_src", "ipv6_dst",
1013 : : "tcp_port_src", "tcp_port_dst",
1014 : : "tcp_seq_num", "tcp_ack_num", "tcp_flags",
1015 : : "udp_port_src", "udp_port_dst",
1016 : : "vxlan_vni", "geneve_vni", "gtp_teid",
1017 : : "tag", "mark", "meta", "pointer", "value",
1018 : : "ipv4_ecn", "ipv6_ecn", "gtp_psc_qfi", "meter_color",
1019 : : "ipv6_proto",
1020 : : "flex_item",
1021 : : "hash_result",
1022 : : "geneve_opt_type", "geneve_opt_class", "geneve_opt_data", "mpls",
1023 : : "tcp_data_off", "ipv4_ihl", "ipv4_total_len", "ipv6_payload_len",
1024 : : "ipv4_proto",
1025 : : "ipv6_flow_label", "ipv6_traffic_class",
1026 : : "esp_spi", "esp_seq_num", "esp_proto",
1027 : : "random",
1028 : : "vxlan_last_rsvd",
1029 : : NULL
1030 : : };
1031 : :
1032 : : static const char *const meter_colors[] = {
1033 : : "green", "yellow", "red", "all", NULL
1034 : : };
1035 : :
1036 : : static const char *const table_insertion_types[] = {
1037 : : "pattern", "index", "index_with_pattern", NULL
1038 : : };
1039 : :
1040 : : static const char *const table_hash_funcs[] = {
1041 : : "default", "linear", "crc32", "crc16", NULL
1042 : : };
1043 : :
1044 : : #define RAW_IPSEC_CONFS_MAX_NUM 8
1045 : :
1046 : : /** Maximum number of subsequent tokens and arguments on the stack. */
1047 : : #define CTX_STACK_SIZE 16
1048 : :
1049 : : /** Parser context. */
1050 : : struct context {
1051 : : /** Stack of subsequent token lists to process. */
1052 : : const enum index *next[CTX_STACK_SIZE];
1053 : : /** Arguments for stacked tokens. */
1054 : : const void *args[CTX_STACK_SIZE];
1055 : : enum index curr; /**< Current token index. */
1056 : : enum index prev; /**< Index of the last token seen. */
1057 : : int next_num; /**< Number of entries in next[]. */
1058 : : int args_num; /**< Number of entries in args[]. */
1059 : : uint32_t eol:1; /**< EOL has been detected. */
1060 : : uint32_t last:1; /**< No more arguments. */
1061 : : portid_t port; /**< Current port ID (for completions). */
1062 : : uint32_t objdata; /**< Object-specific data. */
1063 : : void *object; /**< Address of current object for relative offsets. */
1064 : : void *objmask; /**< Object a full mask must be written to. */
1065 : : };
1066 : :
1067 : : /** Token argument. */
1068 : : struct arg {
1069 : : uint32_t hton:1; /**< Use network byte ordering. */
1070 : : uint32_t sign:1; /**< Value is signed. */
1071 : : uint32_t bounded:1; /**< Value is bounded. */
1072 : : uintmax_t min; /**< Minimum value if bounded. */
1073 : : uintmax_t max; /**< Maximum value if bounded. */
1074 : : uint32_t offset; /**< Relative offset from ctx->object. */
1075 : : uint32_t size; /**< Field size. */
1076 : : const uint8_t *mask; /**< Bit-mask to use instead of offset/size. */
1077 : : };
1078 : :
1079 : : /** Parser token definition. */
1080 : : struct token {
1081 : : /** Type displayed during completion (defaults to "TOKEN"). */
1082 : : const char *type;
1083 : : /** Help displayed during completion (defaults to token name). */
1084 : : const char *help;
1085 : : /** Private data used by parser functions. */
1086 : : const void *priv;
1087 : : /**
1088 : : * Lists of subsequent tokens to push on the stack. Each call to the
1089 : : * parser consumes the last entry of that stack.
1090 : : */
1091 : : const enum index *const *next;
1092 : : /** Arguments stack for subsequent tokens that need them. */
1093 : : const struct arg *const *args;
1094 : : /**
1095 : : * Token-processing callback, returns -1 in case of error, the
1096 : : * length of the matched string otherwise. If NULL, attempts to
1097 : : * match the token name.
1098 : : *
1099 : : * If buf is not NULL, the result should be stored in it according
1100 : : * to context. An error is returned if not large enough.
1101 : : */
1102 : : int (*call)(struct context *ctx, const struct token *token,
1103 : : const char *str, unsigned int len,
1104 : : void *buf, unsigned int size);
1105 : : /**
1106 : : * Callback that provides possible values for this token, used for
1107 : : * completion. Returns -1 in case of error, the number of possible
1108 : : * values otherwise. If NULL, the token name is used.
1109 : : *
1110 : : * If buf is not NULL, entry index ent is written to buf and the
1111 : : * full length of the entry is returned (same behavior as
1112 : : * snprintf()).
1113 : : */
1114 : : int (*comp)(struct context *ctx, const struct token *token,
1115 : : unsigned int ent, char *buf, unsigned int size);
1116 : : /** Mandatory token name, no default value. */
1117 : : const char *name;
1118 : : };
1119 : :
1120 : : /** Static initializer for the next field. */
1121 : : #define NEXT(...) (const enum index *const []){ __VA_ARGS__, NULL, }
1122 : :
1123 : : /** Static initializer for a NEXT() entry. */
1124 : : #define NEXT_ENTRY(...) (const enum index []){ __VA_ARGS__, ZERO, }
1125 : :
1126 : : /** Static initializer for the args field. */
1127 : : #define ARGS(...) (const struct arg *const []){ __VA_ARGS__, NULL, }
1128 : :
1129 : : /** Static initializer for ARGS() to target a field. */
1130 : : #define ARGS_ENTRY(s, f) \
1131 : : (&(const struct arg){ \
1132 : : .offset = offsetof(s, f), \
1133 : : .size = sizeof(((s *)0)->f), \
1134 : : })
1135 : :
1136 : : /** Static initializer for ARGS() to target a bit-field. */
1137 : : #define ARGS_ENTRY_BF(s, f, b) \
1138 : : (&(const struct arg){ \
1139 : : .size = sizeof(s), \
1140 : : .mask = (const void *)&(const s){ .f = (1 << (b)) - 1 }, \
1141 : : })
1142 : :
1143 : : /** Static initializer for ARGS() to target a field with limits. */
1144 : : #define ARGS_ENTRY_BOUNDED(s, f, i, a) \
1145 : : (&(const struct arg){ \
1146 : : .bounded = 1, \
1147 : : .min = (i), \
1148 : : .max = (a), \
1149 : : .offset = offsetof(s, f), \
1150 : : .size = sizeof(((s *)0)->f), \
1151 : : })
1152 : :
1153 : : /** Static initializer for ARGS() to target an arbitrary bit-mask. */
1154 : : #define ARGS_ENTRY_MASK(s, f, m) \
1155 : : (&(const struct arg){ \
1156 : : .offset = offsetof(s, f), \
1157 : : .size = sizeof(((s *)0)->f), \
1158 : : .mask = (const void *)(m), \
1159 : : })
1160 : :
1161 : : /** Same as ARGS_ENTRY_MASK() using network byte ordering for the value. */
1162 : : #define ARGS_ENTRY_MASK_HTON(s, f, m) \
1163 : : (&(const struct arg){ \
1164 : : .hton = 1, \
1165 : : .offset = offsetof(s, f), \
1166 : : .size = sizeof(((s *)0)->f), \
1167 : : .mask = (const void *)(m), \
1168 : : })
1169 : :
1170 : : /** Static initializer for ARGS() to target a pointer. */
1171 : : #define ARGS_ENTRY_PTR(s, f) \
1172 : : (&(const struct arg){ \
1173 : : .size = sizeof(*((s *)0)->f), \
1174 : : })
1175 : :
1176 : : /** Static initializer for ARGS() with arbitrary offset and size. */
1177 : : #define ARGS_ENTRY_ARB(o, s) \
1178 : : (&(const struct arg){ \
1179 : : .offset = (o), \
1180 : : .size = (s), \
1181 : : })
1182 : :
1183 : : /** Same as ARGS_ENTRY_ARB() with bounded values. */
1184 : : #define ARGS_ENTRY_ARB_BOUNDED(o, s, i, a) \
1185 : : (&(const struct arg){ \
1186 : : .bounded = 1, \
1187 : : .min = (i), \
1188 : : .max = (a), \
1189 : : .offset = (o), \
1190 : : .size = (s), \
1191 : : })
1192 : :
1193 : : /** Same as ARGS_ENTRY() using network byte ordering. */
1194 : : #define ARGS_ENTRY_HTON(s, f) \
1195 : : (&(const struct arg){ \
1196 : : .hton = 1, \
1197 : : .offset = offsetof(s, f), \
1198 : : .size = sizeof(((s *)0)->f), \
1199 : : })
1200 : :
1201 : : /** Same as ARGS_ENTRY_HTON() for a single argument, without structure. */
1202 : : #define ARG_ENTRY_HTON(s) \
1203 : : (&(const struct arg){ \
1204 : : .hton = 1, \
1205 : : .offset = 0, \
1206 : : .size = sizeof(s), \
1207 : : })
1208 : :
1209 : : /** Parser output buffer layout expected by cmd_flow_parsed(). */
1210 : : struct buffer {
1211 : : enum index command; /**< Flow command. */
1212 : : portid_t port; /**< Affected port ID. */
1213 : : queueid_t queue; /** Async queue ID. */
1214 : : bool postpone; /** Postpone async operation */
1215 : : union {
1216 : : struct {
1217 : : struct rte_flow_port_attr port_attr;
1218 : : uint32_t nb_queue;
1219 : : struct rte_flow_queue_attr queue_attr;
1220 : : } configure; /**< Configuration arguments. */
1221 : : struct {
1222 : : uint32_t *template_id;
1223 : : uint32_t template_id_n;
1224 : : } templ_destroy; /**< Template destroy arguments. */
1225 : : struct {
1226 : : uint32_t id;
1227 : : struct rte_flow_template_table_attr attr;
1228 : : uint32_t *pat_templ_id;
1229 : : uint32_t pat_templ_id_n;
1230 : : uint32_t *act_templ_id;
1231 : : uint32_t act_templ_id_n;
1232 : : } table; /**< Table arguments. */
1233 : : struct {
1234 : : uint32_t *table_id;
1235 : : uint32_t table_id_n;
1236 : : } table_destroy; /**< Template destroy arguments. */
1237 : : struct {
1238 : : uint32_t *action_id;
1239 : : uint32_t action_id_n;
1240 : : } ia_destroy; /**< Indirect action destroy arguments. */
1241 : : struct {
1242 : : uint32_t action_id;
1243 : : enum rte_flow_query_update_mode qu_mode;
1244 : : } ia; /* Indirect action query arguments */
1245 : : struct {
1246 : : uint32_t table_id;
1247 : : uint32_t pat_templ_id;
1248 : : uint32_t rule_id;
1249 : : uint32_t act_templ_id;
1250 : : struct rte_flow_attr attr;
1251 : : struct tunnel_ops tunnel_ops;
1252 : : uintptr_t user_id;
1253 : : struct rte_flow_item *pattern;
1254 : : struct rte_flow_action *actions;
1255 : : struct rte_flow_action *masks;
1256 : : uint32_t pattern_n;
1257 : : uint32_t actions_n;
1258 : : uint8_t *data;
1259 : : enum rte_flow_encap_hash_field field;
1260 : : uint8_t encap_hash;
1261 : : } vc; /**< Validate/create arguments. */
1262 : : struct {
1263 : : uint64_t *rule;
1264 : : uint64_t rule_n;
1265 : : bool is_user_id;
1266 : : } destroy; /**< Destroy arguments. */
1267 : : struct {
1268 : : char file[128];
1269 : : bool dump_all;
1270 : : uint64_t rule;
1271 : : bool append_to_file;
1272 : : bool is_user_id;
1273 : : } dump; /**< Dump arguments. */
1274 : : struct {
1275 : : uint64_t rule;
1276 : : struct rte_flow_action action;
1277 : : bool is_user_id;
1278 : : } query; /**< Query arguments. */
1279 : : struct {
1280 : : uint32_t *group;
1281 : : uint32_t group_n;
1282 : : } list; /**< List arguments. */
1283 : : struct {
1284 : : int set;
1285 : : } isolate; /**< Isolated mode arguments. */
1286 : : struct {
1287 : : int destroy;
1288 : : } aged; /**< Aged arguments. */
1289 : : struct {
1290 : : uint32_t policy_id;
1291 : : } policy;/**< Policy arguments. */
1292 : : struct {
1293 : : uint16_t token;
1294 : : uintptr_t uintptr;
1295 : : char filename[128];
1296 : : } flex; /**< Flex arguments*/
1297 : : } args; /**< Command arguments. */
1298 : : };
1299 : :
1300 : : /** Private data for pattern items. */
1301 : : struct parse_item_priv {
1302 : : enum rte_flow_item_type type; /**< Item type. */
1303 : : uint32_t size; /**< Size of item specification structure. */
1304 : : };
1305 : :
1306 : : #define PRIV_ITEM(t, s) \
1307 : : (&(const struct parse_item_priv){ \
1308 : : .type = RTE_FLOW_ITEM_TYPE_ ## t, \
1309 : : .size = s, \
1310 : : })
1311 : :
1312 : : /** Private data for actions. */
1313 : : struct parse_action_priv {
1314 : : enum rte_flow_action_type type; /**< Action type. */
1315 : : uint32_t size; /**< Size of action configuration structure. */
1316 : : };
1317 : :
1318 : : #define PRIV_ACTION(t, s) \
1319 : : (&(const struct parse_action_priv){ \
1320 : : .type = RTE_FLOW_ACTION_TYPE_ ## t, \
1321 : : .size = s, \
1322 : : })
1323 : :
1324 : : static const enum index next_flex_item[] = {
1325 : : FLEX_ITEM_CREATE,
1326 : : FLEX_ITEM_DESTROY,
1327 : : ZERO,
1328 : : };
1329 : :
1330 : : static const enum index next_config_attr[] = {
1331 : : CONFIG_QUEUES_NUMBER,
1332 : : CONFIG_QUEUES_SIZE,
1333 : : CONFIG_COUNTERS_NUMBER,
1334 : : CONFIG_AGING_OBJECTS_NUMBER,
1335 : : CONFIG_METERS_NUMBER,
1336 : : CONFIG_CONN_TRACK_NUMBER,
1337 : : CONFIG_QUOTAS_NUMBER,
1338 : : CONFIG_FLAGS,
1339 : : CONFIG_HOST_PORT,
1340 : : END,
1341 : : ZERO,
1342 : : };
1343 : :
1344 : : static const enum index next_pt_subcmd[] = {
1345 : : PATTERN_TEMPLATE_CREATE,
1346 : : PATTERN_TEMPLATE_DESTROY,
1347 : : ZERO,
1348 : : };
1349 : :
1350 : : static const enum index next_pt_attr[] = {
1351 : : PATTERN_TEMPLATE_CREATE_ID,
1352 : : PATTERN_TEMPLATE_RELAXED_MATCHING,
1353 : : PATTERN_TEMPLATE_INGRESS,
1354 : : PATTERN_TEMPLATE_EGRESS,
1355 : : PATTERN_TEMPLATE_TRANSFER,
1356 : : PATTERN_TEMPLATE_SPEC,
1357 : : ZERO,
1358 : : };
1359 : :
1360 : : static const enum index next_pt_destroy_attr[] = {
1361 : : PATTERN_TEMPLATE_DESTROY_ID,
1362 : : END,
1363 : : ZERO,
1364 : : };
1365 : :
1366 : : static const enum index next_at_subcmd[] = {
1367 : : ACTIONS_TEMPLATE_CREATE,
1368 : : ACTIONS_TEMPLATE_DESTROY,
1369 : : ZERO,
1370 : : };
1371 : :
1372 : : static const enum index next_at_attr[] = {
1373 : : ACTIONS_TEMPLATE_CREATE_ID,
1374 : : ACTIONS_TEMPLATE_INGRESS,
1375 : : ACTIONS_TEMPLATE_EGRESS,
1376 : : ACTIONS_TEMPLATE_TRANSFER,
1377 : : ACTIONS_TEMPLATE_SPEC,
1378 : : ZERO,
1379 : : };
1380 : :
1381 : : static const enum index next_at_destroy_attr[] = {
1382 : : ACTIONS_TEMPLATE_DESTROY_ID,
1383 : : END,
1384 : : ZERO,
1385 : : };
1386 : :
1387 : : static const enum index next_group_attr[] = {
1388 : : GROUP_INGRESS,
1389 : : GROUP_EGRESS,
1390 : : GROUP_TRANSFER,
1391 : : GROUP_SET_MISS_ACTIONS,
1392 : : ZERO,
1393 : : };
1394 : :
1395 : : static const enum index next_table_subcmd[] = {
1396 : : TABLE_CREATE,
1397 : : TABLE_DESTROY,
1398 : : TABLE_RESIZE,
1399 : : TABLE_RESIZE_COMPLETE,
1400 : : ZERO,
1401 : : };
1402 : :
1403 : : static const enum index next_table_attr[] = {
1404 : : TABLE_CREATE_ID,
1405 : : TABLE_GROUP,
1406 : : TABLE_INSERTION_TYPE,
1407 : : TABLE_HASH_FUNC,
1408 : : TABLE_PRIORITY,
1409 : : TABLE_INGRESS,
1410 : : TABLE_EGRESS,
1411 : : TABLE_TRANSFER,
1412 : : TABLE_TRANSFER_WIRE_ORIG,
1413 : : TABLE_TRANSFER_VPORT_ORIG,
1414 : : TABLE_RESIZABLE,
1415 : : TABLE_RULES_NUMBER,
1416 : : TABLE_PATTERN_TEMPLATE,
1417 : : TABLE_ACTIONS_TEMPLATE,
1418 : : END,
1419 : : ZERO,
1420 : : };
1421 : :
1422 : : static const enum index next_table_destroy_attr[] = {
1423 : : TABLE_DESTROY_ID,
1424 : : END,
1425 : : ZERO,
1426 : : };
1427 : :
1428 : : static const enum index next_queue_subcmd[] = {
1429 : : QUEUE_CREATE,
1430 : : QUEUE_DESTROY,
1431 : : QUEUE_FLOW_UPDATE_RESIZED,
1432 : : QUEUE_UPDATE,
1433 : : QUEUE_AGED,
1434 : : QUEUE_INDIRECT_ACTION,
1435 : : ZERO,
1436 : : };
1437 : :
1438 : : static const enum index next_queue_destroy_attr[] = {
1439 : : QUEUE_DESTROY_ID,
1440 : : END,
1441 : : ZERO,
1442 : : };
1443 : :
1444 : : static const enum index next_qia_subcmd[] = {
1445 : : QUEUE_INDIRECT_ACTION_CREATE,
1446 : : QUEUE_INDIRECT_ACTION_UPDATE,
1447 : : QUEUE_INDIRECT_ACTION_DESTROY,
1448 : : QUEUE_INDIRECT_ACTION_QUERY,
1449 : : QUEUE_INDIRECT_ACTION_QUERY_UPDATE,
1450 : : ZERO,
1451 : : };
1452 : :
1453 : : static const enum index next_qia_create_attr[] = {
1454 : : QUEUE_INDIRECT_ACTION_CREATE_ID,
1455 : : QUEUE_INDIRECT_ACTION_INGRESS,
1456 : : QUEUE_INDIRECT_ACTION_EGRESS,
1457 : : QUEUE_INDIRECT_ACTION_TRANSFER,
1458 : : QUEUE_INDIRECT_ACTION_CREATE_POSTPONE,
1459 : : QUEUE_INDIRECT_ACTION_SPEC,
1460 : : QUEUE_INDIRECT_ACTION_LIST,
1461 : : ZERO,
1462 : : };
1463 : :
1464 : : static const enum index next_qia_update_attr[] = {
1465 : : QUEUE_INDIRECT_ACTION_UPDATE_POSTPONE,
1466 : : QUEUE_INDIRECT_ACTION_SPEC,
1467 : : ZERO,
1468 : : };
1469 : :
1470 : : static const enum index next_qia_destroy_attr[] = {
1471 : : QUEUE_INDIRECT_ACTION_DESTROY_POSTPONE,
1472 : : QUEUE_INDIRECT_ACTION_DESTROY_ID,
1473 : : END,
1474 : : ZERO,
1475 : : };
1476 : :
1477 : : static const enum index next_qia_query_attr[] = {
1478 : : QUEUE_INDIRECT_ACTION_QUERY_POSTPONE,
1479 : : END,
1480 : : ZERO,
1481 : : };
1482 : :
1483 : : static const enum index next_ia_create_attr[] = {
1484 : : INDIRECT_ACTION_CREATE_ID,
1485 : : INDIRECT_ACTION_INGRESS,
1486 : : INDIRECT_ACTION_EGRESS,
1487 : : INDIRECT_ACTION_TRANSFER,
1488 : : INDIRECT_ACTION_SPEC,
1489 : : INDIRECT_ACTION_LIST,
1490 : : INDIRECT_ACTION_FLOW_CONF,
1491 : : ZERO,
1492 : : };
1493 : :
1494 : : static const enum index next_ia[] = {
1495 : : INDIRECT_ACTION_ID2PTR,
1496 : : ACTION_NEXT,
1497 : : ZERO
1498 : : };
1499 : :
1500 : : static const enum index next_ial[] = {
1501 : : ACTION_INDIRECT_LIST_HANDLE,
1502 : : ACTION_INDIRECT_LIST_CONF,
1503 : : ACTION_NEXT,
1504 : : ZERO
1505 : : };
1506 : :
1507 : : static const enum index next_qia_qu_attr[] = {
1508 : : QUEUE_INDIRECT_ACTION_QU_MODE,
1509 : : QUEUE_INDIRECT_ACTION_UPDATE_POSTPONE,
1510 : : INDIRECT_ACTION_SPEC,
1511 : : ZERO
1512 : : };
1513 : :
1514 : : static const enum index next_ia_qu_attr[] = {
1515 : : INDIRECT_ACTION_QU_MODE,
1516 : : INDIRECT_ACTION_SPEC,
1517 : : ZERO
1518 : : };
1519 : :
1520 : : static const enum index next_dump_subcmd[] = {
1521 : : DUMP_ALL,
1522 : : DUMP_ONE,
1523 : : DUMP_IS_USER_ID,
1524 : : ZERO,
1525 : : };
1526 : :
1527 : : static const enum index next_ia_subcmd[] = {
1528 : : INDIRECT_ACTION_CREATE,
1529 : : INDIRECT_ACTION_UPDATE,
1530 : : INDIRECT_ACTION_DESTROY,
1531 : : INDIRECT_ACTION_QUERY,
1532 : : INDIRECT_ACTION_QUERY_UPDATE,
1533 : : ZERO,
1534 : : };
1535 : :
1536 : : static const enum index next_vc_attr[] = {
1537 : : VC_GROUP,
1538 : : VC_PRIORITY,
1539 : : VC_INGRESS,
1540 : : VC_EGRESS,
1541 : : VC_TRANSFER,
1542 : : VC_TUNNEL_SET,
1543 : : VC_TUNNEL_MATCH,
1544 : : VC_USER_ID,
1545 : : ITEM_PATTERN,
1546 : : ZERO,
1547 : : };
1548 : :
1549 : : static const enum index next_destroy_attr[] = {
1550 : : DESTROY_RULE,
1551 : : DESTROY_IS_USER_ID,
1552 : : END,
1553 : : ZERO,
1554 : : };
1555 : :
1556 : : static const enum index next_dump_attr[] = {
1557 : : DUMP_FILE_PATH,
1558 : : ZERO,
1559 : : };
1560 : :
1561 : : static const enum index next_query_attr[] = {
1562 : : QUERY_IS_USER_ID,
1563 : : END,
1564 : : ZERO,
1565 : : };
1566 : :
1567 : : static const enum index next_list_attr[] = {
1568 : : LIST_GROUP,
1569 : : END,
1570 : : ZERO,
1571 : : };
1572 : :
1573 : : static const enum index next_aged_attr[] = {
1574 : : AGED_DESTROY,
1575 : : END,
1576 : : ZERO,
1577 : : };
1578 : :
1579 : : static const enum index next_ia_destroy_attr[] = {
1580 : : INDIRECT_ACTION_DESTROY_ID,
1581 : : END,
1582 : : ZERO,
1583 : : };
1584 : :
1585 : : static const enum index next_async_insert_subcmd[] = {
1586 : : QUEUE_PATTERN_TEMPLATE,
1587 : : QUEUE_RULE_ID,
1588 : : ZERO,
1589 : : };
1590 : :
1591 : : static const enum index next_async_pattern_subcmd[] = {
1592 : : QUEUE_PATTERN_TEMPLATE,
1593 : : QUEUE_ACTIONS_TEMPLATE,
1594 : : ZERO,
1595 : : };
1596 : :
1597 : : static const enum index item_param[] = {
1598 : : ITEM_PARAM_IS,
1599 : : ITEM_PARAM_SPEC,
1600 : : ITEM_PARAM_LAST,
1601 : : ITEM_PARAM_MASK,
1602 : : ITEM_PARAM_PREFIX,
1603 : : ZERO,
1604 : : };
1605 : :
1606 : : static const enum index next_item[] = {
1607 : : ITEM_END,
1608 : : ITEM_VOID,
1609 : : ITEM_INVERT,
1610 : : ITEM_ANY,
1611 : : ITEM_PORT_ID,
1612 : : ITEM_MARK,
1613 : : ITEM_RAW,
1614 : : ITEM_ETH,
1615 : : ITEM_VLAN,
1616 : : ITEM_IPV4,
1617 : : ITEM_IPV6,
1618 : : ITEM_ICMP,
1619 : : ITEM_UDP,
1620 : : ITEM_TCP,
1621 : : ITEM_SCTP,
1622 : : ITEM_VXLAN,
1623 : : ITEM_E_TAG,
1624 : : ITEM_NVGRE,
1625 : : ITEM_MPLS,
1626 : : ITEM_GRE,
1627 : : ITEM_FUZZY,
1628 : : ITEM_GTP,
1629 : : ITEM_GTPC,
1630 : : ITEM_GTPU,
1631 : : ITEM_GENEVE,
1632 : : ITEM_VXLAN_GPE,
1633 : : ITEM_ARP_ETH_IPV4,
1634 : : ITEM_IPV6_EXT,
1635 : : ITEM_IPV6_FRAG_EXT,
1636 : : ITEM_IPV6_ROUTING_EXT,
1637 : : ITEM_ICMP6,
1638 : : ITEM_ICMP6_ECHO_REQUEST,
1639 : : ITEM_ICMP6_ECHO_REPLY,
1640 : : ITEM_ICMP6_ND_NS,
1641 : : ITEM_ICMP6_ND_NA,
1642 : : ITEM_ICMP6_ND_OPT,
1643 : : ITEM_ICMP6_ND_OPT_SLA_ETH,
1644 : : ITEM_ICMP6_ND_OPT_TLA_ETH,
1645 : : ITEM_META,
1646 : : ITEM_RANDOM,
1647 : : ITEM_GRE_KEY,
1648 : : ITEM_GRE_OPTION,
1649 : : ITEM_GTP_PSC,
1650 : : ITEM_PPPOES,
1651 : : ITEM_PPPOED,
1652 : : ITEM_PPPOE_PROTO_ID,
1653 : : ITEM_HIGIG2,
1654 : : ITEM_TAG,
1655 : : ITEM_L2TPV3OIP,
1656 : : ITEM_ESP,
1657 : : ITEM_AH,
1658 : : ITEM_PFCP,
1659 : : ITEM_ECPRI,
1660 : : ITEM_GENEVE_OPT,
1661 : : ITEM_INTEGRITY,
1662 : : ITEM_CONNTRACK,
1663 : : ITEM_PORT_REPRESENTOR,
1664 : : ITEM_REPRESENTED_PORT,
1665 : : ITEM_FLEX,
1666 : : ITEM_L2TPV2,
1667 : : ITEM_PPP,
1668 : : ITEM_METER,
1669 : : ITEM_QUOTA,
1670 : : ITEM_AGGR_AFFINITY,
1671 : : ITEM_TX_QUEUE,
1672 : : ITEM_IB_BTH,
1673 : : ITEM_PTYPE,
1674 : : ITEM_NSH,
1675 : : ITEM_COMPARE,
1676 : : END_SET,
1677 : : ZERO,
1678 : : };
1679 : :
1680 : : static const enum index item_fuzzy[] = {
1681 : : ITEM_FUZZY_THRESH,
1682 : : ITEM_NEXT,
1683 : : ZERO,
1684 : : };
1685 : :
1686 : : static const enum index item_any[] = {
1687 : : ITEM_ANY_NUM,
1688 : : ITEM_NEXT,
1689 : : ZERO,
1690 : : };
1691 : :
1692 : : static const enum index item_port_id[] = {
1693 : : ITEM_PORT_ID_ID,
1694 : : ITEM_NEXT,
1695 : : ZERO,
1696 : : };
1697 : :
1698 : : static const enum index item_mark[] = {
1699 : : ITEM_MARK_ID,
1700 : : ITEM_NEXT,
1701 : : ZERO,
1702 : : };
1703 : :
1704 : : static const enum index item_raw[] = {
1705 : : ITEM_RAW_RELATIVE,
1706 : : ITEM_RAW_SEARCH,
1707 : : ITEM_RAW_OFFSET,
1708 : : ITEM_RAW_LIMIT,
1709 : : ITEM_RAW_PATTERN,
1710 : : ITEM_RAW_PATTERN_HEX,
1711 : : ITEM_NEXT,
1712 : : ZERO,
1713 : : };
1714 : :
1715 : : static const enum index item_eth[] = {
1716 : : ITEM_ETH_DST,
1717 : : ITEM_ETH_SRC,
1718 : : ITEM_ETH_TYPE,
1719 : : ITEM_ETH_HAS_VLAN,
1720 : : ITEM_NEXT,
1721 : : ZERO,
1722 : : };
1723 : :
1724 : : static const enum index item_vlan[] = {
1725 : : ITEM_VLAN_TCI,
1726 : : ITEM_VLAN_PCP,
1727 : : ITEM_VLAN_DEI,
1728 : : ITEM_VLAN_VID,
1729 : : ITEM_VLAN_INNER_TYPE,
1730 : : ITEM_VLAN_HAS_MORE_VLAN,
1731 : : ITEM_NEXT,
1732 : : ZERO,
1733 : : };
1734 : :
1735 : : static const enum index item_ipv4[] = {
1736 : : ITEM_IPV4_VER_IHL,
1737 : : ITEM_IPV4_TOS,
1738 : : ITEM_IPV4_LENGTH,
1739 : : ITEM_IPV4_ID,
1740 : : ITEM_IPV4_FRAGMENT_OFFSET,
1741 : : ITEM_IPV4_TTL,
1742 : : ITEM_IPV4_PROTO,
1743 : : ITEM_IPV4_SRC,
1744 : : ITEM_IPV4_DST,
1745 : : ITEM_NEXT,
1746 : : ZERO,
1747 : : };
1748 : :
1749 : : static const enum index item_ipv6[] = {
1750 : : ITEM_IPV6_TC,
1751 : : ITEM_IPV6_FLOW,
1752 : : ITEM_IPV6_LEN,
1753 : : ITEM_IPV6_PROTO,
1754 : : ITEM_IPV6_HOP,
1755 : : ITEM_IPV6_SRC,
1756 : : ITEM_IPV6_DST,
1757 : : ITEM_IPV6_HAS_FRAG_EXT,
1758 : : ITEM_IPV6_ROUTING_EXT,
1759 : : ITEM_NEXT,
1760 : : ZERO,
1761 : : };
1762 : :
1763 : : static const enum index item_ipv6_routing_ext[] = {
1764 : : ITEM_IPV6_ROUTING_EXT_TYPE,
1765 : : ITEM_IPV6_ROUTING_EXT_NEXT_HDR,
1766 : : ITEM_IPV6_ROUTING_EXT_SEG_LEFT,
1767 : : ITEM_NEXT,
1768 : : ZERO,
1769 : : };
1770 : :
1771 : : static const enum index item_icmp[] = {
1772 : : ITEM_ICMP_TYPE,
1773 : : ITEM_ICMP_CODE,
1774 : : ITEM_ICMP_IDENT,
1775 : : ITEM_ICMP_SEQ,
1776 : : ITEM_NEXT,
1777 : : ZERO,
1778 : : };
1779 : :
1780 : : static const enum index item_udp[] = {
1781 : : ITEM_UDP_SRC,
1782 : : ITEM_UDP_DST,
1783 : : ITEM_NEXT,
1784 : : ZERO,
1785 : : };
1786 : :
1787 : : static const enum index item_tcp[] = {
1788 : : ITEM_TCP_SRC,
1789 : : ITEM_TCP_DST,
1790 : : ITEM_TCP_FLAGS,
1791 : : ITEM_NEXT,
1792 : : ZERO,
1793 : : };
1794 : :
1795 : : static const enum index item_sctp[] = {
1796 : : ITEM_SCTP_SRC,
1797 : : ITEM_SCTP_DST,
1798 : : ITEM_SCTP_TAG,
1799 : : ITEM_SCTP_CKSUM,
1800 : : ITEM_NEXT,
1801 : : ZERO,
1802 : : };
1803 : :
1804 : : static const enum index item_vxlan[] = {
1805 : : ITEM_VXLAN_VNI,
1806 : : ITEM_VXLAN_FLAG_G,
1807 : : ITEM_VXLAN_FLAG_VER,
1808 : : ITEM_VXLAN_FLAG_I,
1809 : : ITEM_VXLAN_FLAG_P,
1810 : : ITEM_VXLAN_FLAG_B,
1811 : : ITEM_VXLAN_FLAG_O,
1812 : : ITEM_VXLAN_FLAG_D,
1813 : : ITEM_VXLAN_FLAG_A,
1814 : : ITEM_VXLAN_GBP_ID,
1815 : : ITEM_VXLAN_GPE_PROTO,
1816 : : ITEM_VXLAN_FIRST_RSVD,
1817 : : ITEM_VXLAN_SECND_RSVD,
1818 : : ITEM_VXLAN_THIRD_RSVD,
1819 : : ITEM_VXLAN_LAST_RSVD,
1820 : : ITEM_NEXT,
1821 : : ZERO,
1822 : : };
1823 : :
1824 : : static const enum index item_e_tag[] = {
1825 : : ITEM_E_TAG_GRP_ECID_B,
1826 : : ITEM_NEXT,
1827 : : ZERO,
1828 : : };
1829 : :
1830 : : static const enum index item_nvgre[] = {
1831 : : ITEM_NVGRE_TNI,
1832 : : ITEM_NEXT,
1833 : : ZERO,
1834 : : };
1835 : :
1836 : : static const enum index item_mpls[] = {
1837 : : ITEM_MPLS_LABEL,
1838 : : ITEM_MPLS_TC,
1839 : : ITEM_MPLS_S,
1840 : : ITEM_MPLS_TTL,
1841 : : ITEM_NEXT,
1842 : : ZERO,
1843 : : };
1844 : :
1845 : : static const enum index item_gre[] = {
1846 : : ITEM_GRE_PROTO,
1847 : : ITEM_GRE_C_RSVD0_VER,
1848 : : ITEM_GRE_C_BIT,
1849 : : ITEM_GRE_K_BIT,
1850 : : ITEM_GRE_S_BIT,
1851 : : ITEM_NEXT,
1852 : : ZERO,
1853 : : };
1854 : :
1855 : : static const enum index item_gre_key[] = {
1856 : : ITEM_GRE_KEY_VALUE,
1857 : : ITEM_NEXT,
1858 : : ZERO,
1859 : : };
1860 : :
1861 : : static const enum index item_gre_option[] = {
1862 : : ITEM_GRE_OPTION_CHECKSUM,
1863 : : ITEM_GRE_OPTION_KEY,
1864 : : ITEM_GRE_OPTION_SEQUENCE,
1865 : : ITEM_NEXT,
1866 : : ZERO,
1867 : : };
1868 : :
1869 : : static const enum index item_gtp[] = {
1870 : : ITEM_GTP_FLAGS,
1871 : : ITEM_GTP_MSG_TYPE,
1872 : : ITEM_GTP_TEID,
1873 : : ITEM_NEXT,
1874 : : ZERO,
1875 : : };
1876 : :
1877 : : static const enum index item_geneve[] = {
1878 : : ITEM_GENEVE_VNI,
1879 : : ITEM_GENEVE_PROTO,
1880 : : ITEM_GENEVE_OPTLEN,
1881 : : ITEM_NEXT,
1882 : : ZERO,
1883 : : };
1884 : :
1885 : : static const enum index item_vxlan_gpe[] = {
1886 : : ITEM_VXLAN_GPE_VNI,
1887 : : ITEM_VXLAN_GPE_PROTO_IN_DEPRECATED_VXLAN_GPE_HDR,
1888 : : ITEM_VXLAN_GPE_FLAGS,
1889 : : ITEM_VXLAN_GPE_RSVD0,
1890 : : ITEM_VXLAN_GPE_RSVD1,
1891 : : ITEM_NEXT,
1892 : : ZERO,
1893 : : };
1894 : :
1895 : : static const enum index item_arp_eth_ipv4[] = {
1896 : : ITEM_ARP_ETH_IPV4_SHA,
1897 : : ITEM_ARP_ETH_IPV4_SPA,
1898 : : ITEM_ARP_ETH_IPV4_THA,
1899 : : ITEM_ARP_ETH_IPV4_TPA,
1900 : : ITEM_NEXT,
1901 : : ZERO,
1902 : : };
1903 : :
1904 : : static const enum index item_ipv6_ext[] = {
1905 : : ITEM_IPV6_EXT_NEXT_HDR,
1906 : : ITEM_NEXT,
1907 : : ZERO,
1908 : : };
1909 : :
1910 : : static const enum index item_ipv6_frag_ext[] = {
1911 : : ITEM_IPV6_FRAG_EXT_NEXT_HDR,
1912 : : ITEM_IPV6_FRAG_EXT_FRAG_DATA,
1913 : : ITEM_IPV6_FRAG_EXT_ID,
1914 : : ITEM_NEXT,
1915 : : ZERO,
1916 : : };
1917 : :
1918 : : static const enum index item_icmp6[] = {
1919 : : ITEM_ICMP6_TYPE,
1920 : : ITEM_ICMP6_CODE,
1921 : : ITEM_NEXT,
1922 : : ZERO,
1923 : : };
1924 : :
1925 : : static const enum index item_icmp6_echo_request[] = {
1926 : : ITEM_ICMP6_ECHO_REQUEST_ID,
1927 : : ITEM_ICMP6_ECHO_REQUEST_SEQ,
1928 : : ITEM_NEXT,
1929 : : ZERO,
1930 : : };
1931 : :
1932 : : static const enum index item_icmp6_echo_reply[] = {
1933 : : ITEM_ICMP6_ECHO_REPLY_ID,
1934 : : ITEM_ICMP6_ECHO_REPLY_SEQ,
1935 : : ITEM_NEXT,
1936 : : ZERO,
1937 : : };
1938 : :
1939 : : static const enum index item_icmp6_nd_ns[] = {
1940 : : ITEM_ICMP6_ND_NS_TARGET_ADDR,
1941 : : ITEM_NEXT,
1942 : : ZERO,
1943 : : };
1944 : :
1945 : : static const enum index item_icmp6_nd_na[] = {
1946 : : ITEM_ICMP6_ND_NA_TARGET_ADDR,
1947 : : ITEM_NEXT,
1948 : : ZERO,
1949 : : };
1950 : :
1951 : : static const enum index item_icmp6_nd_opt[] = {
1952 : : ITEM_ICMP6_ND_OPT_TYPE,
1953 : : ITEM_NEXT,
1954 : : ZERO,
1955 : : };
1956 : :
1957 : : static const enum index item_icmp6_nd_opt_sla_eth[] = {
1958 : : ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
1959 : : ITEM_NEXT,
1960 : : ZERO,
1961 : : };
1962 : :
1963 : : static const enum index item_icmp6_nd_opt_tla_eth[] = {
1964 : : ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
1965 : : ITEM_NEXT,
1966 : : ZERO,
1967 : : };
1968 : :
1969 : : static const enum index item_meta[] = {
1970 : : ITEM_META_DATA,
1971 : : ITEM_NEXT,
1972 : : ZERO,
1973 : : };
1974 : :
1975 : : static const enum index item_random[] = {
1976 : : ITEM_RANDOM_VALUE,
1977 : : ITEM_NEXT,
1978 : : ZERO,
1979 : : };
1980 : :
1981 : : static const enum index item_gtp_psc[] = {
1982 : : ITEM_GTP_PSC_QFI,
1983 : : ITEM_GTP_PSC_PDU_T,
1984 : : ITEM_NEXT,
1985 : : ZERO,
1986 : : };
1987 : :
1988 : : static const enum index item_pppoed[] = {
1989 : : ITEM_PPPOE_SEID,
1990 : : ITEM_NEXT,
1991 : : ZERO,
1992 : : };
1993 : :
1994 : : static const enum index item_pppoes[] = {
1995 : : ITEM_PPPOE_SEID,
1996 : : ITEM_NEXT,
1997 : : ZERO,
1998 : : };
1999 : :
2000 : : static const enum index item_pppoe_proto_id[] = {
2001 : : ITEM_NEXT,
2002 : : ZERO,
2003 : : };
2004 : :
2005 : : static const enum index item_higig2[] = {
2006 : : ITEM_HIGIG2_CLASSIFICATION,
2007 : : ITEM_HIGIG2_VID,
2008 : : ITEM_NEXT,
2009 : : ZERO,
2010 : : };
2011 : :
2012 : : static const enum index item_esp[] = {
2013 : : ITEM_ESP_SPI,
2014 : : ITEM_NEXT,
2015 : : ZERO,
2016 : : };
2017 : :
2018 : : static const enum index item_ah[] = {
2019 : : ITEM_AH_SPI,
2020 : : ITEM_NEXT,
2021 : : ZERO,
2022 : : };
2023 : :
2024 : : static const enum index item_pfcp[] = {
2025 : : ITEM_PFCP_S_FIELD,
2026 : : ITEM_PFCP_SEID,
2027 : : ITEM_NEXT,
2028 : : ZERO,
2029 : : };
2030 : :
2031 : : static const enum index next_set_raw[] = {
2032 : : SET_RAW_INDEX,
2033 : : ITEM_ETH,
2034 : : ZERO,
2035 : : };
2036 : :
2037 : : static const enum index item_tag[] = {
2038 : : ITEM_TAG_DATA,
2039 : : ITEM_TAG_INDEX,
2040 : : ITEM_NEXT,
2041 : : ZERO,
2042 : : };
2043 : :
2044 : : static const enum index item_l2tpv3oip[] = {
2045 : : ITEM_L2TPV3OIP_SESSION_ID,
2046 : : ITEM_NEXT,
2047 : : ZERO,
2048 : : };
2049 : :
2050 : : static const enum index item_ecpri[] = {
2051 : : ITEM_ECPRI_COMMON,
2052 : : ITEM_NEXT,
2053 : : ZERO,
2054 : : };
2055 : :
2056 : : static const enum index item_ecpri_common[] = {
2057 : : ITEM_ECPRI_COMMON_TYPE,
2058 : : ZERO,
2059 : : };
2060 : :
2061 : : static const enum index item_ecpri_common_type[] = {
2062 : : ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
2063 : : ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
2064 : : ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
2065 : : ZERO,
2066 : : };
2067 : :
2068 : : static const enum index item_geneve_opt[] = {
2069 : : ITEM_GENEVE_OPT_CLASS,
2070 : : ITEM_GENEVE_OPT_TYPE,
2071 : : ITEM_GENEVE_OPT_LENGTH,
2072 : : ITEM_GENEVE_OPT_DATA,
2073 : : ITEM_NEXT,
2074 : : ZERO,
2075 : : };
2076 : :
2077 : : static const enum index item_integrity[] = {
2078 : : ITEM_INTEGRITY_LEVEL,
2079 : : ITEM_INTEGRITY_VALUE,
2080 : : ZERO,
2081 : : };
2082 : :
2083 : : static const enum index item_integrity_lv[] = {
2084 : : ITEM_INTEGRITY_LEVEL,
2085 : : ITEM_INTEGRITY_VALUE,
2086 : : ITEM_NEXT,
2087 : : ZERO,
2088 : : };
2089 : :
2090 : : static const enum index item_port_representor[] = {
2091 : : ITEM_PORT_REPRESENTOR_PORT_ID,
2092 : : ITEM_NEXT,
2093 : : ZERO,
2094 : : };
2095 : :
2096 : : static const enum index item_represented_port[] = {
2097 : : ITEM_REPRESENTED_PORT_ETHDEV_PORT_ID,
2098 : : ITEM_NEXT,
2099 : : ZERO,
2100 : : };
2101 : :
2102 : : static const enum index item_flex[] = {
2103 : : ITEM_FLEX_PATTERN_HANDLE,
2104 : : ITEM_FLEX_ITEM_HANDLE,
2105 : : ITEM_NEXT,
2106 : : ZERO,
2107 : : };
2108 : :
2109 : : static const enum index item_l2tpv2[] = {
2110 : : ITEM_L2TPV2_TYPE,
2111 : : ITEM_NEXT,
2112 : : ZERO,
2113 : : };
2114 : :
2115 : : static const enum index item_l2tpv2_type[] = {
2116 : : ITEM_L2TPV2_TYPE_DATA,
2117 : : ITEM_L2TPV2_TYPE_DATA_L,
2118 : : ITEM_L2TPV2_TYPE_DATA_S,
2119 : : ITEM_L2TPV2_TYPE_DATA_O,
2120 : : ITEM_L2TPV2_TYPE_DATA_L_S,
2121 : : ITEM_L2TPV2_TYPE_CTRL,
2122 : : ZERO,
2123 : : };
2124 : :
2125 : : static const enum index item_l2tpv2_type_data[] = {
2126 : : ITEM_L2TPV2_MSG_DATA_TUNNEL_ID,
2127 : : ITEM_L2TPV2_MSG_DATA_SESSION_ID,
2128 : : ITEM_NEXT,
2129 : : ZERO,
2130 : : };
2131 : :
2132 : : static const enum index item_l2tpv2_type_data_l[] = {
2133 : : ITEM_L2TPV2_MSG_DATA_L_LENGTH,
2134 : : ITEM_L2TPV2_MSG_DATA_L_TUNNEL_ID,
2135 : : ITEM_L2TPV2_MSG_DATA_L_SESSION_ID,
2136 : : ITEM_NEXT,
2137 : : ZERO,
2138 : : };
2139 : :
2140 : : static const enum index item_l2tpv2_type_data_s[] = {
2141 : : ITEM_L2TPV2_MSG_DATA_S_TUNNEL_ID,
2142 : : ITEM_L2TPV2_MSG_DATA_S_SESSION_ID,
2143 : : ITEM_L2TPV2_MSG_DATA_S_NS,
2144 : : ITEM_L2TPV2_MSG_DATA_S_NR,
2145 : : ITEM_NEXT,
2146 : : ZERO,
2147 : : };
2148 : :
2149 : : static const enum index item_l2tpv2_type_data_o[] = {
2150 : : ITEM_L2TPV2_MSG_DATA_O_TUNNEL_ID,
2151 : : ITEM_L2TPV2_MSG_DATA_O_SESSION_ID,
2152 : : ITEM_L2TPV2_MSG_DATA_O_OFFSET,
2153 : : ITEM_NEXT,
2154 : : ZERO,
2155 : : };
2156 : :
2157 : : static const enum index item_l2tpv2_type_data_l_s[] = {
2158 : : ITEM_L2TPV2_MSG_DATA_L_S_LENGTH,
2159 : : ITEM_L2TPV2_MSG_DATA_L_S_TUNNEL_ID,
2160 : : ITEM_L2TPV2_MSG_DATA_L_S_SESSION_ID,
2161 : : ITEM_L2TPV2_MSG_DATA_L_S_NS,
2162 : : ITEM_L2TPV2_MSG_DATA_L_S_NR,
2163 : : ITEM_NEXT,
2164 : : ZERO,
2165 : : };
2166 : :
2167 : : static const enum index item_l2tpv2_type_ctrl[] = {
2168 : : ITEM_L2TPV2_MSG_CTRL_LENGTH,
2169 : : ITEM_L2TPV2_MSG_CTRL_TUNNEL_ID,
2170 : : ITEM_L2TPV2_MSG_CTRL_SESSION_ID,
2171 : : ITEM_L2TPV2_MSG_CTRL_NS,
2172 : : ITEM_L2TPV2_MSG_CTRL_NR,
2173 : : ITEM_NEXT,
2174 : : ZERO,
2175 : : };
2176 : :
2177 : : static const enum index item_ppp[] = {
2178 : : ITEM_PPP_ADDR,
2179 : : ITEM_PPP_CTRL,
2180 : : ITEM_PPP_PROTO_ID,
2181 : : ITEM_NEXT,
2182 : : ZERO,
2183 : : };
2184 : :
2185 : : static const enum index item_meter[] = {
2186 : : ITEM_METER_COLOR,
2187 : : ITEM_NEXT,
2188 : : ZERO,
2189 : : };
2190 : :
2191 : : static const enum index item_quota[] = {
2192 : : ITEM_QUOTA_STATE,
2193 : : ITEM_NEXT,
2194 : : ZERO,
2195 : : };
2196 : :
2197 : : static const enum index item_aggr_affinity[] = {
2198 : : ITEM_AGGR_AFFINITY_VALUE,
2199 : : ITEM_NEXT,
2200 : : ZERO,
2201 : : };
2202 : :
2203 : : static const enum index item_tx_queue[] = {
2204 : : ITEM_TX_QUEUE_VALUE,
2205 : : ITEM_NEXT,
2206 : : ZERO,
2207 : : };
2208 : :
2209 : : static const enum index item_ib_bth[] = {
2210 : : ITEM_IB_BTH_OPCODE,
2211 : : ITEM_IB_BTH_PKEY,
2212 : : ITEM_IB_BTH_DST_QPN,
2213 : : ITEM_IB_BTH_PSN,
2214 : : ITEM_NEXT,
2215 : : ZERO,
2216 : : };
2217 : :
2218 : : static const enum index item_ptype[] = {
2219 : : ITEM_PTYPE_VALUE,
2220 : : ITEM_NEXT,
2221 : : ZERO,
2222 : : };
2223 : :
2224 : : static const enum index item_nsh[] = {
2225 : : ITEM_NEXT,
2226 : : ZERO,
2227 : : };
2228 : :
2229 : : static const enum index item_compare_field[] = {
2230 : : ITEM_COMPARE_OP,
2231 : : ITEM_COMPARE_FIELD_A_TYPE,
2232 : : ITEM_COMPARE_FIELD_B_TYPE,
2233 : : ITEM_NEXT,
2234 : : ZERO,
2235 : : };
2236 : :
2237 : : static const enum index compare_field_a[] = {
2238 : : ITEM_COMPARE_FIELD_A_TYPE,
2239 : : ITEM_COMPARE_FIELD_A_LEVEL,
2240 : : ITEM_COMPARE_FIELD_A_TAG_INDEX,
2241 : : ITEM_COMPARE_FIELD_A_TYPE_ID,
2242 : : ITEM_COMPARE_FIELD_A_CLASS_ID,
2243 : : ITEM_COMPARE_FIELD_A_OFFSET,
2244 : : ITEM_COMPARE_FIELD_B_TYPE,
2245 : : ZERO,
2246 : : };
2247 : :
2248 : : static const enum index compare_field_b[] = {
2249 : : ITEM_COMPARE_FIELD_B_TYPE,
2250 : : ITEM_COMPARE_FIELD_B_LEVEL,
2251 : : ITEM_COMPARE_FIELD_B_TAG_INDEX,
2252 : : ITEM_COMPARE_FIELD_B_TYPE_ID,
2253 : : ITEM_COMPARE_FIELD_B_CLASS_ID,
2254 : : ITEM_COMPARE_FIELD_B_OFFSET,
2255 : : ITEM_COMPARE_FIELD_B_VALUE,
2256 : : ITEM_COMPARE_FIELD_B_POINTER,
2257 : : ITEM_COMPARE_FIELD_WIDTH,
2258 : : ZERO,
2259 : : };
2260 : :
2261 : : static const enum index next_action[] = {
2262 : : ACTION_END,
2263 : : ACTION_VOID,
2264 : : ACTION_PASSTHRU,
2265 : : ACTION_SKIP_CMAN,
2266 : : ACTION_JUMP,
2267 : : ACTION_MARK,
2268 : : ACTION_FLAG,
2269 : : ACTION_QUEUE,
2270 : : ACTION_DROP,
2271 : : ACTION_COUNT,
2272 : : ACTION_RSS,
2273 : : ACTION_PF,
2274 : : ACTION_VF,
2275 : : ACTION_PORT_ID,
2276 : : ACTION_METER,
2277 : : ACTION_METER_COLOR,
2278 : : ACTION_METER_MARK,
2279 : : ACTION_METER_MARK_CONF,
2280 : : ACTION_OF_DEC_NW_TTL,
2281 : : ACTION_OF_POP_VLAN,
2282 : : ACTION_OF_PUSH_VLAN,
2283 : : ACTION_OF_SET_VLAN_VID,
2284 : : ACTION_OF_SET_VLAN_PCP,
2285 : : ACTION_OF_POP_MPLS,
2286 : : ACTION_OF_PUSH_MPLS,
2287 : : ACTION_VXLAN_ENCAP,
2288 : : ACTION_VXLAN_DECAP,
2289 : : ACTION_NVGRE_ENCAP,
2290 : : ACTION_NVGRE_DECAP,
2291 : : ACTION_L2_ENCAP,
2292 : : ACTION_L2_DECAP,
2293 : : ACTION_MPLSOGRE_ENCAP,
2294 : : ACTION_MPLSOGRE_DECAP,
2295 : : ACTION_MPLSOUDP_ENCAP,
2296 : : ACTION_MPLSOUDP_DECAP,
2297 : : ACTION_SET_IPV4_SRC,
2298 : : ACTION_SET_IPV4_DST,
2299 : : ACTION_SET_IPV6_SRC,
2300 : : ACTION_SET_IPV6_DST,
2301 : : ACTION_SET_TP_SRC,
2302 : : ACTION_SET_TP_DST,
2303 : : ACTION_MAC_SWAP,
2304 : : ACTION_DEC_TTL,
2305 : : ACTION_SET_TTL,
2306 : : ACTION_SET_MAC_SRC,
2307 : : ACTION_SET_MAC_DST,
2308 : : ACTION_INC_TCP_SEQ,
2309 : : ACTION_DEC_TCP_SEQ,
2310 : : ACTION_INC_TCP_ACK,
2311 : : ACTION_DEC_TCP_ACK,
2312 : : ACTION_RAW_ENCAP,
2313 : : ACTION_RAW_DECAP,
2314 : : ACTION_SET_TAG,
2315 : : ACTION_SET_META,
2316 : : ACTION_SET_IPV4_DSCP,
2317 : : ACTION_SET_IPV6_DSCP,
2318 : : ACTION_AGE,
2319 : : ACTION_AGE_UPDATE,
2320 : : ACTION_SAMPLE,
2321 : : ACTION_INDIRECT,
2322 : : ACTION_INDIRECT_LIST,
2323 : : ACTION_SHARED_INDIRECT,
2324 : : ACTION_MODIFY_FIELD,
2325 : : ACTION_CONNTRACK,
2326 : : ACTION_CONNTRACK_UPDATE,
2327 : : ACTION_PORT_REPRESENTOR,
2328 : : ACTION_REPRESENTED_PORT,
2329 : : ACTION_SEND_TO_KERNEL,
2330 : : ACTION_QUOTA_CREATE,
2331 : : ACTION_QUOTA_QU,
2332 : : ACTION_IPV6_EXT_REMOVE,
2333 : : ACTION_IPV6_EXT_PUSH,
2334 : : ACTION_NAT64,
2335 : : ACTION_JUMP_TO_TABLE_INDEX,
2336 : : ZERO,
2337 : : };
2338 : :
2339 : : static const enum index action_quota_create[] = {
2340 : : ACTION_QUOTA_CREATE_LIMIT,
2341 : : ACTION_QUOTA_CREATE_MODE,
2342 : : ACTION_NEXT,
2343 : : ZERO
2344 : : };
2345 : :
2346 : : static const enum index action_quota_update[] = {
2347 : : ACTION_QUOTA_QU_LIMIT,
2348 : : ACTION_QUOTA_QU_UPDATE_OP,
2349 : : ACTION_NEXT,
2350 : : ZERO
2351 : : };
2352 : :
2353 : : static const enum index action_mark[] = {
2354 : : ACTION_MARK_ID,
2355 : : ACTION_NEXT,
2356 : : ZERO,
2357 : : };
2358 : :
2359 : : static const enum index action_queue[] = {
2360 : : ACTION_QUEUE_INDEX,
2361 : : ACTION_NEXT,
2362 : : ZERO,
2363 : : };
2364 : :
2365 : : static const enum index action_count[] = {
2366 : : ACTION_COUNT_ID,
2367 : : ACTION_NEXT,
2368 : : ZERO,
2369 : : };
2370 : :
2371 : : static const enum index action_rss[] = {
2372 : : ACTION_RSS_FUNC,
2373 : : ACTION_RSS_LEVEL,
2374 : : ACTION_RSS_TYPES,
2375 : : ACTION_RSS_KEY,
2376 : : ACTION_RSS_KEY_LEN,
2377 : : ACTION_RSS_QUEUES,
2378 : : ACTION_NEXT,
2379 : : ZERO,
2380 : : };
2381 : :
2382 : : static const enum index action_vf[] = {
2383 : : ACTION_VF_ORIGINAL,
2384 : : ACTION_VF_ID,
2385 : : ACTION_NEXT,
2386 : : ZERO,
2387 : : };
2388 : :
2389 : : static const enum index action_port_id[] = {
2390 : : ACTION_PORT_ID_ORIGINAL,
2391 : : ACTION_PORT_ID_ID,
2392 : : ACTION_NEXT,
2393 : : ZERO,
2394 : : };
2395 : :
2396 : : static const enum index action_meter[] = {
2397 : : ACTION_METER_ID,
2398 : : ACTION_NEXT,
2399 : : ZERO,
2400 : : };
2401 : :
2402 : : static const enum index action_meter_color[] = {
2403 : : ACTION_METER_COLOR_TYPE,
2404 : : ACTION_NEXT,
2405 : : ZERO,
2406 : : };
2407 : :
2408 : : static const enum index action_meter_mark[] = {
2409 : : ACTION_METER_PROFILE,
2410 : : ACTION_METER_POLICY,
2411 : : ACTION_METER_COLOR_MODE,
2412 : : ACTION_METER_STATE,
2413 : : ACTION_NEXT,
2414 : : ZERO,
2415 : : };
2416 : :
2417 : : static const enum index action_of_push_vlan[] = {
2418 : : ACTION_OF_PUSH_VLAN_ETHERTYPE,
2419 : : ACTION_NEXT,
2420 : : ZERO,
2421 : : };
2422 : :
2423 : : static const enum index action_of_set_vlan_vid[] = {
2424 : : ACTION_OF_SET_VLAN_VID_VLAN_VID,
2425 : : ACTION_NEXT,
2426 : : ZERO,
2427 : : };
2428 : :
2429 : : static const enum index action_of_set_vlan_pcp[] = {
2430 : : ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
2431 : : ACTION_NEXT,
2432 : : ZERO,
2433 : : };
2434 : :
2435 : : static const enum index action_of_pop_mpls[] = {
2436 : : ACTION_OF_POP_MPLS_ETHERTYPE,
2437 : : ACTION_NEXT,
2438 : : ZERO,
2439 : : };
2440 : :
2441 : : static const enum index action_of_push_mpls[] = {
2442 : : ACTION_OF_PUSH_MPLS_ETHERTYPE,
2443 : : ACTION_NEXT,
2444 : : ZERO,
2445 : : };
2446 : :
2447 : : static const enum index action_set_ipv4_src[] = {
2448 : : ACTION_SET_IPV4_SRC_IPV4_SRC,
2449 : : ACTION_NEXT,
2450 : : ZERO,
2451 : : };
2452 : :
2453 : : static const enum index action_set_mac_src[] = {
2454 : : ACTION_SET_MAC_SRC_MAC_SRC,
2455 : : ACTION_NEXT,
2456 : : ZERO,
2457 : : };
2458 : :
2459 : : static const enum index action_set_ipv4_dst[] = {
2460 : : ACTION_SET_IPV4_DST_IPV4_DST,
2461 : : ACTION_NEXT,
2462 : : ZERO,
2463 : : };
2464 : :
2465 : : static const enum index action_set_ipv6_src[] = {
2466 : : ACTION_SET_IPV6_SRC_IPV6_SRC,
2467 : : ACTION_NEXT,
2468 : : ZERO,
2469 : : };
2470 : :
2471 : : static const enum index action_set_ipv6_dst[] = {
2472 : : ACTION_SET_IPV6_DST_IPV6_DST,
2473 : : ACTION_NEXT,
2474 : : ZERO,
2475 : : };
2476 : :
2477 : : static const enum index action_set_tp_src[] = {
2478 : : ACTION_SET_TP_SRC_TP_SRC,
2479 : : ACTION_NEXT,
2480 : : ZERO,
2481 : : };
2482 : :
2483 : : static const enum index action_set_tp_dst[] = {
2484 : : ACTION_SET_TP_DST_TP_DST,
2485 : : ACTION_NEXT,
2486 : : ZERO,
2487 : : };
2488 : :
2489 : : static const enum index action_set_ttl[] = {
2490 : : ACTION_SET_TTL_TTL,
2491 : : ACTION_NEXT,
2492 : : ZERO,
2493 : : };
2494 : :
2495 : : static const enum index action_jump[] = {
2496 : : ACTION_JUMP_GROUP,
2497 : : ACTION_NEXT,
2498 : : ZERO,
2499 : : };
2500 : :
2501 : : static const enum index action_set_mac_dst[] = {
2502 : : ACTION_SET_MAC_DST_MAC_DST,
2503 : : ACTION_NEXT,
2504 : : ZERO,
2505 : : };
2506 : :
2507 : : static const enum index action_inc_tcp_seq[] = {
2508 : : ACTION_INC_TCP_SEQ_VALUE,
2509 : : ACTION_NEXT,
2510 : : ZERO,
2511 : : };
2512 : :
2513 : : static const enum index action_dec_tcp_seq[] = {
2514 : : ACTION_DEC_TCP_SEQ_VALUE,
2515 : : ACTION_NEXT,
2516 : : ZERO,
2517 : : };
2518 : :
2519 : : static const enum index action_inc_tcp_ack[] = {
2520 : : ACTION_INC_TCP_ACK_VALUE,
2521 : : ACTION_NEXT,
2522 : : ZERO,
2523 : : };
2524 : :
2525 : : static const enum index action_dec_tcp_ack[] = {
2526 : : ACTION_DEC_TCP_ACK_VALUE,
2527 : : ACTION_NEXT,
2528 : : ZERO,
2529 : : };
2530 : :
2531 : : static const enum index action_raw_encap[] = {
2532 : : ACTION_RAW_ENCAP_SIZE,
2533 : : ACTION_RAW_ENCAP_INDEX,
2534 : : ACTION_NEXT,
2535 : : ZERO,
2536 : : };
2537 : :
2538 : : static const enum index action_raw_decap[] = {
2539 : : ACTION_RAW_DECAP_INDEX,
2540 : : ACTION_NEXT,
2541 : : ZERO,
2542 : : };
2543 : :
2544 : : static const enum index action_ipv6_ext_remove[] = {
2545 : : ACTION_IPV6_EXT_REMOVE_INDEX,
2546 : : ACTION_NEXT,
2547 : : ZERO,
2548 : : };
2549 : :
2550 : : static const enum index action_ipv6_ext_push[] = {
2551 : : ACTION_IPV6_EXT_PUSH_INDEX,
2552 : : ACTION_NEXT,
2553 : : ZERO,
2554 : : };
2555 : :
2556 : : static const enum index action_set_tag[] = {
2557 : : ACTION_SET_TAG_DATA,
2558 : : ACTION_SET_TAG_INDEX,
2559 : : ACTION_SET_TAG_MASK,
2560 : : ACTION_NEXT,
2561 : : ZERO,
2562 : : };
2563 : :
2564 : : static const enum index action_set_meta[] = {
2565 : : ACTION_SET_META_DATA,
2566 : : ACTION_SET_META_MASK,
2567 : : ACTION_NEXT,
2568 : : ZERO,
2569 : : };
2570 : :
2571 : : static const enum index action_set_ipv4_dscp[] = {
2572 : : ACTION_SET_IPV4_DSCP_VALUE,
2573 : : ACTION_NEXT,
2574 : : ZERO,
2575 : : };
2576 : :
2577 : : static const enum index action_set_ipv6_dscp[] = {
2578 : : ACTION_SET_IPV6_DSCP_VALUE,
2579 : : ACTION_NEXT,
2580 : : ZERO,
2581 : : };
2582 : :
2583 : : static const enum index action_age[] = {
2584 : : ACTION_AGE,
2585 : : ACTION_AGE_TIMEOUT,
2586 : : ACTION_NEXT,
2587 : : ZERO,
2588 : : };
2589 : :
2590 : : static const enum index action_age_update[] = {
2591 : : ACTION_AGE_UPDATE,
2592 : : ACTION_AGE_UPDATE_TIMEOUT,
2593 : : ACTION_AGE_UPDATE_TOUCH,
2594 : : ACTION_NEXT,
2595 : : ZERO,
2596 : : };
2597 : :
2598 : : static const enum index action_sample[] = {
2599 : : ACTION_SAMPLE,
2600 : : ACTION_SAMPLE_RATIO,
2601 : : ACTION_SAMPLE_INDEX,
2602 : : ACTION_NEXT,
2603 : : ZERO,
2604 : : };
2605 : :
2606 : : static const enum index next_action_sample[] = {
2607 : : ACTION_QUEUE,
2608 : : ACTION_RSS,
2609 : : ACTION_MARK,
2610 : : ACTION_COUNT,
2611 : : ACTION_PORT_ID,
2612 : : ACTION_RAW_ENCAP,
2613 : : ACTION_VXLAN_ENCAP,
2614 : : ACTION_NVGRE_ENCAP,
2615 : : ACTION_REPRESENTED_PORT,
2616 : : ACTION_PORT_REPRESENTOR,
2617 : : ACTION_NEXT,
2618 : : ZERO,
2619 : : };
2620 : :
2621 : : static const enum index item_ipv6_push_ext[] = {
2622 : : ITEM_IPV6_PUSH_REMOVE_EXT,
2623 : : ZERO,
2624 : : };
2625 : :
2626 : : static const enum index item_ipv6_push_ext_type[] = {
2627 : : ITEM_IPV6_PUSH_REMOVE_EXT_TYPE,
2628 : : ZERO,
2629 : : };
2630 : :
2631 : : static const enum index item_ipv6_push_ext_header[] = {
2632 : : ITEM_IPV6_ROUTING_EXT,
2633 : : ITEM_NEXT,
2634 : : ZERO,
2635 : : };
2636 : :
2637 : : static const enum index action_modify_field_dst[] = {
2638 : : ACTION_MODIFY_FIELD_DST_LEVEL,
2639 : : ACTION_MODIFY_FIELD_DST_TAG_INDEX,
2640 : : ACTION_MODIFY_FIELD_DST_TYPE_ID,
2641 : : ACTION_MODIFY_FIELD_DST_CLASS_ID,
2642 : : ACTION_MODIFY_FIELD_DST_OFFSET,
2643 : : ACTION_MODIFY_FIELD_SRC_TYPE,
2644 : : ZERO,
2645 : : };
2646 : :
2647 : : static const enum index action_modify_field_src[] = {
2648 : : ACTION_MODIFY_FIELD_SRC_LEVEL,
2649 : : ACTION_MODIFY_FIELD_SRC_TAG_INDEX,
2650 : : ACTION_MODIFY_FIELD_SRC_TYPE_ID,
2651 : : ACTION_MODIFY_FIELD_SRC_CLASS_ID,
2652 : : ACTION_MODIFY_FIELD_SRC_OFFSET,
2653 : : ACTION_MODIFY_FIELD_SRC_VALUE,
2654 : : ACTION_MODIFY_FIELD_SRC_POINTER,
2655 : : ACTION_MODIFY_FIELD_WIDTH,
2656 : : ZERO,
2657 : : };
2658 : :
2659 : : static const enum index action_update_conntrack[] = {
2660 : : ACTION_CONNTRACK_UPDATE_DIR,
2661 : : ACTION_CONNTRACK_UPDATE_CTX,
2662 : : ACTION_NEXT,
2663 : : ZERO,
2664 : : };
2665 : :
2666 : : static const enum index action_port_representor[] = {
2667 : : ACTION_PORT_REPRESENTOR_PORT_ID,
2668 : : ACTION_NEXT,
2669 : : ZERO,
2670 : : };
2671 : :
2672 : : static const enum index action_represented_port[] = {
2673 : : ACTION_REPRESENTED_PORT_ETHDEV_PORT_ID,
2674 : : ACTION_NEXT,
2675 : : ZERO,
2676 : : };
2677 : :
2678 : : static const enum index action_nat64[] = {
2679 : : ACTION_NAT64_MODE,
2680 : : ACTION_NEXT,
2681 : : ZERO,
2682 : : };
2683 : :
2684 : : static const enum index next_hash_subcmd[] = {
2685 : : HASH_CALC_TABLE,
2686 : : HASH_CALC_ENCAP,
2687 : : ZERO,
2688 : : };
2689 : :
2690 : : static const enum index next_hash_encap_dest_subcmd[] = {
2691 : : ENCAP_HASH_FIELD_SRC_PORT,
2692 : : ENCAP_HASH_FIELD_GRE_FLOW_ID,
2693 : : ZERO,
2694 : : };
2695 : :
2696 : : static const enum index action_jump_to_table_index[] = {
2697 : : ACTION_JUMP_TO_TABLE_INDEX_TABLE,
2698 : : ACTION_JUMP_TO_TABLE_INDEX_INDEX,
2699 : : ACTION_NEXT,
2700 : : ZERO,
2701 : : };
2702 : :
2703 : : static int parse_set_raw_encap_decap(struct context *, const struct token *,
2704 : : const char *, unsigned int,
2705 : : void *, unsigned int);
2706 : : static int parse_set_sample_action(struct context *, const struct token *,
2707 : : const char *, unsigned int,
2708 : : void *, unsigned int);
2709 : : static int parse_set_ipv6_ext_action(struct context *, const struct token *,
2710 : : const char *, unsigned int,
2711 : : void *, unsigned int);
2712 : : static int parse_set_init(struct context *, const struct token *,
2713 : : const char *, unsigned int,
2714 : : void *, unsigned int);
2715 : : static int
2716 : : parse_flex_handle(struct context *, const struct token *,
2717 : : const char *, unsigned int, void *, unsigned int);
2718 : : static int parse_init(struct context *, const struct token *,
2719 : : const char *, unsigned int,
2720 : : void *, unsigned int);
2721 : : static int parse_vc(struct context *, const struct token *,
2722 : : const char *, unsigned int,
2723 : : void *, unsigned int);
2724 : : static int parse_vc_spec(struct context *, const struct token *,
2725 : : const char *, unsigned int, void *, unsigned int);
2726 : : static int parse_vc_conf(struct context *, const struct token *,
2727 : : const char *, unsigned int, void *, unsigned int);
2728 : : static int parse_vc_conf_timeout(struct context *, const struct token *,
2729 : : const char *, unsigned int, void *,
2730 : : unsigned int);
2731 : : static int parse_vc_item_ecpri_type(struct context *, const struct token *,
2732 : : const char *, unsigned int,
2733 : : void *, unsigned int);
2734 : : static int parse_vc_item_l2tpv2_type(struct context *, const struct token *,
2735 : : const char *, unsigned int,
2736 : : void *, unsigned int);
2737 : : static int parse_vc_action_meter_color_type(struct context *,
2738 : : const struct token *,
2739 : : const char *, unsigned int, void *,
2740 : : unsigned int);
2741 : : static int parse_vc_action_rss(struct context *, const struct token *,
2742 : : const char *, unsigned int, void *,
2743 : : unsigned int);
2744 : : static int parse_vc_action_rss_func(struct context *, const struct token *,
2745 : : const char *, unsigned int, void *,
2746 : : unsigned int);
2747 : : static int parse_vc_action_rss_type(struct context *, const struct token *,
2748 : : const char *, unsigned int, void *,
2749 : : unsigned int);
2750 : : static int parse_vc_action_rss_queue(struct context *, const struct token *,
2751 : : const char *, unsigned int, void *,
2752 : : unsigned int);
2753 : : static int parse_vc_action_vxlan_encap(struct context *, const struct token *,
2754 : : const char *, unsigned int, void *,
2755 : : unsigned int);
2756 : : static int parse_vc_action_nvgre_encap(struct context *, const struct token *,
2757 : : const char *, unsigned int, void *,
2758 : : unsigned int);
2759 : : static int parse_vc_action_l2_encap(struct context *, const struct token *,
2760 : : const char *, unsigned int, void *,
2761 : : unsigned int);
2762 : : static int parse_vc_action_l2_decap(struct context *, const struct token *,
2763 : : const char *, unsigned int, void *,
2764 : : unsigned int);
2765 : : static int parse_vc_action_mplsogre_encap(struct context *,
2766 : : const struct token *, const char *,
2767 : : unsigned int, void *, unsigned int);
2768 : : static int parse_vc_action_mplsogre_decap(struct context *,
2769 : : const struct token *, const char *,
2770 : : unsigned int, void *, unsigned int);
2771 : : static int parse_vc_action_mplsoudp_encap(struct context *,
2772 : : const struct token *, const char *,
2773 : : unsigned int, void *, unsigned int);
2774 : : static int parse_vc_action_mplsoudp_decap(struct context *,
2775 : : const struct token *, const char *,
2776 : : unsigned int, void *, unsigned int);
2777 : : static int parse_vc_action_raw_encap(struct context *,
2778 : : const struct token *, const char *,
2779 : : unsigned int, void *, unsigned int);
2780 : : static int parse_vc_action_raw_decap(struct context *,
2781 : : const struct token *, const char *,
2782 : : unsigned int, void *, unsigned int);
2783 : : static int parse_vc_action_raw_encap_index(struct context *,
2784 : : const struct token *, const char *,
2785 : : unsigned int, void *, unsigned int);
2786 : : static int parse_vc_action_raw_decap_index(struct context *,
2787 : : const struct token *, const char *,
2788 : : unsigned int, void *, unsigned int);
2789 : : static int parse_vc_action_ipv6_ext_remove(struct context *ctx, const struct token *token,
2790 : : const char *str, unsigned int len, void *buf,
2791 : : unsigned int size);
2792 : : static int parse_vc_action_ipv6_ext_remove_index(struct context *ctx,
2793 : : const struct token *token,
2794 : : const char *str, unsigned int len,
2795 : : void *buf,
2796 : : unsigned int size);
2797 : : static int parse_vc_action_ipv6_ext_push(struct context *ctx, const struct token *token,
2798 : : const char *str, unsigned int len, void *buf,
2799 : : unsigned int size);
2800 : : static int parse_vc_action_ipv6_ext_push_index(struct context *ctx,
2801 : : const struct token *token,
2802 : : const char *str, unsigned int len,
2803 : : void *buf,
2804 : : unsigned int size);
2805 : : static int parse_vc_action_set_meta(struct context *ctx,
2806 : : const struct token *token, const char *str,
2807 : : unsigned int len, void *buf,
2808 : : unsigned int size);
2809 : : static int parse_vc_action_sample(struct context *ctx,
2810 : : const struct token *token, const char *str,
2811 : : unsigned int len, void *buf,
2812 : : unsigned int size);
2813 : : static int
2814 : : parse_vc_action_sample_index(struct context *ctx, const struct token *token,
2815 : : const char *str, unsigned int len, void *buf,
2816 : : unsigned int size);
2817 : : static int
2818 : : parse_vc_modify_field_op(struct context *ctx, const struct token *token,
2819 : : const char *str, unsigned int len, void *buf,
2820 : : unsigned int size);
2821 : : static int
2822 : : parse_vc_modify_field_id(struct context *ctx, const struct token *token,
2823 : : const char *str, unsigned int len, void *buf,
2824 : : unsigned int size);
2825 : : static int
2826 : : parse_vc_modify_field_level(struct context *ctx, const struct token *token,
2827 : : const char *str, unsigned int len, void *buf,
2828 : : unsigned int size);
2829 : : static int
2830 : : parse_vc_action_conntrack_update(struct context *ctx, const struct token *token,
2831 : : const char *str, unsigned int len, void *buf,
2832 : : unsigned int size);
2833 : : static int parse_destroy(struct context *, const struct token *,
2834 : : const char *, unsigned int,
2835 : : void *, unsigned int);
2836 : : static int parse_flush(struct context *, const struct token *,
2837 : : const char *, unsigned int,
2838 : : void *, unsigned int);
2839 : : static int parse_dump(struct context *, const struct token *,
2840 : : const char *, unsigned int,
2841 : : void *, unsigned int);
2842 : : static int parse_query(struct context *, const struct token *,
2843 : : const char *, unsigned int,
2844 : : void *, unsigned int);
2845 : : static int parse_action(struct context *, const struct token *,
2846 : : const char *, unsigned int,
2847 : : void *, unsigned int);
2848 : : static int parse_list(struct context *, const struct token *,
2849 : : const char *, unsigned int,
2850 : : void *, unsigned int);
2851 : : static int parse_aged(struct context *, const struct token *,
2852 : : const char *, unsigned int,
2853 : : void *, unsigned int);
2854 : : static int parse_isolate(struct context *, const struct token *,
2855 : : const char *, unsigned int,
2856 : : void *, unsigned int);
2857 : : static int parse_configure(struct context *, const struct token *,
2858 : : const char *, unsigned int,
2859 : : void *, unsigned int);
2860 : : static int parse_template(struct context *, const struct token *,
2861 : : const char *, unsigned int,
2862 : : void *, unsigned int);
2863 : : static int parse_template_destroy(struct context *, const struct token *,
2864 : : const char *, unsigned int,
2865 : : void *, unsigned int);
2866 : : static int parse_table(struct context *, const struct token *,
2867 : : const char *, unsigned int, void *, unsigned int);
2868 : : static int parse_table_destroy(struct context *, const struct token *,
2869 : : const char *, unsigned int,
2870 : : void *, unsigned int);
2871 : : static int parse_jump_table_id(struct context *, const struct token *,
2872 : : const char *, unsigned int,
2873 : : void *, unsigned int);
2874 : : static int parse_qo(struct context *, const struct token *,
2875 : : const char *, unsigned int,
2876 : : void *, unsigned int);
2877 : : static int parse_qo_destroy(struct context *, const struct token *,
2878 : : const char *, unsigned int,
2879 : : void *, unsigned int);
2880 : : static int parse_qia(struct context *, const struct token *,
2881 : : const char *, unsigned int,
2882 : : void *, unsigned int);
2883 : : static int parse_qia_destroy(struct context *, const struct token *,
2884 : : const char *, unsigned int,
2885 : : void *, unsigned int);
2886 : : static int parse_push(struct context *, const struct token *,
2887 : : const char *, unsigned int,
2888 : : void *, unsigned int);
2889 : : static int parse_pull(struct context *, const struct token *,
2890 : : const char *, unsigned int,
2891 : : void *, unsigned int);
2892 : : static int parse_group(struct context *, const struct token *,
2893 : : const char *, unsigned int,
2894 : : void *, unsigned int);
2895 : : static int parse_hash(struct context *, const struct token *,
2896 : : const char *, unsigned int,
2897 : : void *, unsigned int);
2898 : : static int parse_tunnel(struct context *, const struct token *,
2899 : : const char *, unsigned int,
2900 : : void *, unsigned int);
2901 : : static int parse_flex(struct context *, const struct token *,
2902 : : const char *, unsigned int, void *, unsigned int);
2903 : : static int parse_int(struct context *, const struct token *,
2904 : : const char *, unsigned int,
2905 : : void *, unsigned int);
2906 : : static int parse_prefix(struct context *, const struct token *,
2907 : : const char *, unsigned int,
2908 : : void *, unsigned int);
2909 : : static int parse_boolean(struct context *, const struct token *,
2910 : : const char *, unsigned int,
2911 : : void *, unsigned int);
2912 : : static int parse_string(struct context *, const struct token *,
2913 : : const char *, unsigned int,
2914 : : void *, unsigned int);
2915 : : static int parse_hex(struct context *ctx, const struct token *token,
2916 : : const char *str, unsigned int len,
2917 : : void *buf, unsigned int size);
2918 : : static int parse_string0(struct context *, const struct token *,
2919 : : const char *, unsigned int,
2920 : : void *, unsigned int);
2921 : : static int parse_mac_addr(struct context *, const struct token *,
2922 : : const char *, unsigned int,
2923 : : void *, unsigned int);
2924 : : static int parse_ipv4_addr(struct context *, const struct token *,
2925 : : const char *, unsigned int,
2926 : : void *, unsigned int);
2927 : : static int parse_ipv6_addr(struct context *, const struct token *,
2928 : : const char *, unsigned int,
2929 : : void *, unsigned int);
2930 : : static int parse_port(struct context *, const struct token *,
2931 : : const char *, unsigned int,
2932 : : void *, unsigned int);
2933 : : static int parse_ia(struct context *, const struct token *,
2934 : : const char *, unsigned int,
2935 : : void *, unsigned int);
2936 : : static int parse_ia_destroy(struct context *ctx, const struct token *token,
2937 : : const char *str, unsigned int len,
2938 : : void *buf, unsigned int size);
2939 : : static int parse_ia_id2ptr(struct context *ctx, const struct token *token,
2940 : : const char *str, unsigned int len, void *buf,
2941 : : unsigned int size);
2942 : :
2943 : : static int parse_indlst_id2ptr(struct context *ctx, const struct token *token,
2944 : : const char *str, unsigned int len, void *buf,
2945 : : unsigned int size);
2946 : : static int parse_ia_port(struct context *ctx, const struct token *token,
2947 : : const char *str, unsigned int len, void *buf,
2948 : : unsigned int size);
2949 : : static int parse_mp(struct context *, const struct token *,
2950 : : const char *, unsigned int,
2951 : : void *, unsigned int);
2952 : : static int parse_meter_profile_id2ptr(struct context *ctx,
2953 : : const struct token *token,
2954 : : const char *str, unsigned int len,
2955 : : void *buf, unsigned int size);
2956 : : static int parse_meter_policy_id2ptr(struct context *ctx,
2957 : : const struct token *token,
2958 : : const char *str, unsigned int len,
2959 : : void *buf, unsigned int size);
2960 : : static int parse_meter_color(struct context *ctx, const struct token *token,
2961 : : const char *str, unsigned int len, void *buf,
2962 : : unsigned int size);
2963 : : static int parse_insertion_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 parse_hash_table_type(struct context *ctx, const struct token *token,
2967 : : const char *str, unsigned int len, void *buf,
2968 : : unsigned int size);
2969 : : static int
2970 : : parse_quota_state_name(struct context *ctx, const struct token *token,
2971 : : const char *str, unsigned int len, void *buf,
2972 : : unsigned int size);
2973 : : static int
2974 : : parse_quota_mode_name(struct context *ctx, const struct token *token,
2975 : : const char *str, unsigned int len, void *buf,
2976 : : unsigned int size);
2977 : : static int
2978 : : parse_quota_update_name(struct context *ctx, const struct token *token,
2979 : : const char *str, unsigned int len, void *buf,
2980 : : unsigned int size);
2981 : : static int
2982 : : parse_qu_mode_name(struct context *ctx, const struct token *token,
2983 : : const char *str, unsigned int len, void *buf,
2984 : : unsigned int size);
2985 : : static int comp_none(struct context *, const struct token *,
2986 : : unsigned int, char *, unsigned int);
2987 : : static int comp_boolean(struct context *, const struct token *,
2988 : : unsigned int, char *, unsigned int);
2989 : : static int comp_action(struct context *, const struct token *,
2990 : : unsigned int, char *, unsigned int);
2991 : : static int comp_port(struct context *, const struct token *,
2992 : : unsigned int, char *, unsigned int);
2993 : : static int comp_rule_id(struct context *, const struct token *,
2994 : : unsigned int, char *, unsigned int);
2995 : : static int comp_vc_action_rss_type(struct context *, const struct token *,
2996 : : unsigned int, char *, unsigned int);
2997 : : static int comp_vc_action_rss_queue(struct context *, const struct token *,
2998 : : unsigned int, char *, unsigned int);
2999 : : static int comp_set_raw_index(struct context *, const struct token *,
3000 : : unsigned int, char *, unsigned int);
3001 : : static int comp_set_sample_index(struct context *, const struct token *,
3002 : : unsigned int, char *, unsigned int);
3003 : : static int comp_set_ipv6_ext_index(struct context *ctx, const struct token *token,
3004 : : unsigned int ent, char *buf, unsigned int size);
3005 : : static int comp_set_modify_field_op(struct context *, const struct token *,
3006 : : unsigned int, char *, unsigned int);
3007 : : static int comp_set_modify_field_id(struct context *, const struct token *,
3008 : : unsigned int, char *, unsigned int);
3009 : : static int comp_pattern_template_id(struct context *, const struct token *,
3010 : : unsigned int, char *, unsigned int);
3011 : : static int comp_actions_template_id(struct context *, const struct token *,
3012 : : unsigned int, char *, unsigned int);
3013 : : static int comp_table_id(struct context *, const struct token *,
3014 : : unsigned int, char *, unsigned int);
3015 : : static int comp_queue_id(struct context *, const struct token *,
3016 : : unsigned int, char *, unsigned int);
3017 : : static int comp_meter_color(struct context *, const struct token *,
3018 : : unsigned int, char *, unsigned int);
3019 : : static int comp_insertion_table_type(struct context *, const struct token *,
3020 : : unsigned int, char *, unsigned int);
3021 : : static int comp_hash_table_type(struct context *, const struct token *,
3022 : : unsigned int, char *, unsigned int);
3023 : : static int
3024 : : comp_quota_state_name(struct context *ctx, const struct token *token,
3025 : : unsigned int ent, char *buf, unsigned int size);
3026 : : static int
3027 : : comp_quota_mode_name(struct context *ctx, const struct token *token,
3028 : : unsigned int ent, char *buf, unsigned int size);
3029 : : static int
3030 : : comp_quota_update_name(struct context *ctx, const struct token *token,
3031 : : unsigned int ent, char *buf, unsigned int size);
3032 : : static int
3033 : : comp_qu_mode_name(struct context *ctx, const struct token *token,
3034 : : unsigned int ent, char *buf, unsigned int size);
3035 : : static int
3036 : : comp_set_compare_field_id(struct context *ctx, const struct token *token,
3037 : : unsigned int ent, char *buf, unsigned int size);
3038 : : static int
3039 : : comp_set_compare_op(struct context *ctx, const struct token *token,
3040 : : unsigned int ent, char *buf, unsigned int size);
3041 : : static int
3042 : : parse_vc_compare_op(struct context *ctx, const struct token *token,
3043 : : const char *str, unsigned int len, void *buf,
3044 : : unsigned int size);
3045 : : static int
3046 : : parse_vc_compare_field_id(struct context *ctx, const struct token *token,
3047 : : const char *str, unsigned int len, void *buf,
3048 : : unsigned int size);
3049 : : static int
3050 : : parse_vc_compare_field_level(struct context *ctx, const struct token *token,
3051 : : const char *str, unsigned int len, void *buf,
3052 : : unsigned int size);
3053 : :
3054 : : struct indlst_conf {
3055 : : uint32_t id;
3056 : : uint32_t conf_num;
3057 : : struct rte_flow_action *actions;
3058 : : const void **conf;
3059 : : SLIST_ENTRY(indlst_conf) next;
3060 : : };
3061 : :
3062 : : static const struct indlst_conf *indirect_action_list_conf_get(uint32_t conf_id);
3063 : :
3064 : : /** Token definitions. */
3065 : : static const struct token token_list[] = {
3066 : : /* Special tokens. */
3067 : : [ZERO] = {
3068 : : .name = "ZERO",
3069 : : .help = "null entry, abused as the entry point",
3070 : : .next = NEXT(NEXT_ENTRY(FLOW, ADD)),
3071 : : },
3072 : : [END] = {
3073 : : .name = "",
3074 : : .type = "RETURN",
3075 : : .help = "command may end here",
3076 : : },
3077 : : [START_SET] = {
3078 : : .name = "START_SET",
3079 : : .help = "null entry, abused as the entry point for set",
3080 : : .next = NEXT(NEXT_ENTRY(SET)),
3081 : : },
3082 : : [END_SET] = {
3083 : : .name = "end_set",
3084 : : .type = "RETURN",
3085 : : .help = "set command may end here",
3086 : : },
3087 : : /* Common tokens. */
3088 : : [COMMON_INTEGER] = {
3089 : : .name = "{int}",
3090 : : .type = "INTEGER",
3091 : : .help = "integer value",
3092 : : .call = parse_int,
3093 : : .comp = comp_none,
3094 : : },
3095 : : [COMMON_UNSIGNED] = {
3096 : : .name = "{unsigned}",
3097 : : .type = "UNSIGNED",
3098 : : .help = "unsigned integer value",
3099 : : .call = parse_int,
3100 : : .comp = comp_none,
3101 : : },
3102 : : [COMMON_PREFIX] = {
3103 : : .name = "{prefix}",
3104 : : .type = "PREFIX",
3105 : : .help = "prefix length for bit-mask",
3106 : : .call = parse_prefix,
3107 : : .comp = comp_none,
3108 : : },
3109 : : [COMMON_BOOLEAN] = {
3110 : : .name = "{boolean}",
3111 : : .type = "BOOLEAN",
3112 : : .help = "any boolean value",
3113 : : .call = parse_boolean,
3114 : : .comp = comp_boolean,
3115 : : },
3116 : : [COMMON_STRING] = {
3117 : : .name = "{string}",
3118 : : .type = "STRING",
3119 : : .help = "fixed string",
3120 : : .call = parse_string,
3121 : : .comp = comp_none,
3122 : : },
3123 : : [COMMON_HEX] = {
3124 : : .name = "{hex}",
3125 : : .type = "HEX",
3126 : : .help = "fixed string",
3127 : : .call = parse_hex,
3128 : : },
3129 : : [COMMON_FILE_PATH] = {
3130 : : .name = "{file path}",
3131 : : .type = "STRING",
3132 : : .help = "file path",
3133 : : .call = parse_string0,
3134 : : .comp = comp_none,
3135 : : },
3136 : : [COMMON_MAC_ADDR] = {
3137 : : .name = "{MAC address}",
3138 : : .type = "MAC-48",
3139 : : .help = "standard MAC address notation",
3140 : : .call = parse_mac_addr,
3141 : : .comp = comp_none,
3142 : : },
3143 : : [COMMON_IPV4_ADDR] = {
3144 : : .name = "{IPv4 address}",
3145 : : .type = "IPV4 ADDRESS",
3146 : : .help = "standard IPv4 address notation",
3147 : : .call = parse_ipv4_addr,
3148 : : .comp = comp_none,
3149 : : },
3150 : : [COMMON_IPV6_ADDR] = {
3151 : : .name = "{IPv6 address}",
3152 : : .type = "IPV6 ADDRESS",
3153 : : .help = "standard IPv6 address notation",
3154 : : .call = parse_ipv6_addr,
3155 : : .comp = comp_none,
3156 : : },
3157 : : [COMMON_RULE_ID] = {
3158 : : .name = "{rule id}",
3159 : : .type = "RULE ID",
3160 : : .help = "rule identifier",
3161 : : .call = parse_int,
3162 : : .comp = comp_rule_id,
3163 : : },
3164 : : [COMMON_PORT_ID] = {
3165 : : .name = "{port_id}",
3166 : : .type = "PORT ID",
3167 : : .help = "port identifier",
3168 : : .call = parse_port,
3169 : : .comp = comp_port,
3170 : : },
3171 : : [COMMON_GROUP_ID] = {
3172 : : .name = "{group_id}",
3173 : : .type = "GROUP ID",
3174 : : .help = "group identifier",
3175 : : .call = parse_int,
3176 : : .comp = comp_none,
3177 : : },
3178 : : [COMMON_PRIORITY_LEVEL] = {
3179 : : .name = "{level}",
3180 : : .type = "PRIORITY",
3181 : : .help = "priority level",
3182 : : .call = parse_int,
3183 : : .comp = comp_none,
3184 : : },
3185 : : [COMMON_INDIRECT_ACTION_ID] = {
3186 : : .name = "{indirect_action_id}",
3187 : : .type = "INDIRECT_ACTION_ID",
3188 : : .help = "indirect action id",
3189 : : .call = parse_int,
3190 : : .comp = comp_none,
3191 : : },
3192 : : [COMMON_PROFILE_ID] = {
3193 : : .name = "{profile_id}",
3194 : : .type = "PROFILE_ID",
3195 : : .help = "profile id",
3196 : : .call = parse_int,
3197 : : .comp = comp_none,
3198 : : },
3199 : : [COMMON_POLICY_ID] = {
3200 : : .name = "{policy_id}",
3201 : : .type = "POLICY_ID",
3202 : : .help = "policy id",
3203 : : .call = parse_int,
3204 : : .comp = comp_none,
3205 : : },
3206 : : [COMMON_FLEX_TOKEN] = {
3207 : : .name = "{flex token}",
3208 : : .type = "flex token",
3209 : : .help = "flex token",
3210 : : .call = parse_int,
3211 : : .comp = comp_none,
3212 : : },
3213 : : [COMMON_FLEX_HANDLE] = {
3214 : : .name = "{flex handle}",
3215 : : .type = "FLEX HANDLE",
3216 : : .help = "fill flex item data",
3217 : : .call = parse_flex_handle,
3218 : : .comp = comp_none,
3219 : : },
3220 : : [COMMON_PATTERN_TEMPLATE_ID] = {
3221 : : .name = "{pattern_template_id}",
3222 : : .type = "PATTERN_TEMPLATE_ID",
3223 : : .help = "pattern template id",
3224 : : .call = parse_int,
3225 : : .comp = comp_pattern_template_id,
3226 : : },
3227 : : [COMMON_ACTIONS_TEMPLATE_ID] = {
3228 : : .name = "{actions_template_id}",
3229 : : .type = "ACTIONS_TEMPLATE_ID",
3230 : : .help = "actions template id",
3231 : : .call = parse_int,
3232 : : .comp = comp_actions_template_id,
3233 : : },
3234 : : [COMMON_TABLE_ID] = {
3235 : : .name = "{table_id}",
3236 : : .type = "TABLE_ID",
3237 : : .help = "table id",
3238 : : .call = parse_int,
3239 : : .comp = comp_table_id,
3240 : : },
3241 : : [COMMON_QUEUE_ID] = {
3242 : : .name = "{queue_id}",
3243 : : .type = "QUEUE_ID",
3244 : : .help = "queue id",
3245 : : .call = parse_int,
3246 : : .comp = comp_queue_id,
3247 : : },
3248 : : [COMMON_METER_COLOR_NAME] = {
3249 : : .name = "color_name",
3250 : : .help = "meter color name",
3251 : : .call = parse_meter_color,
3252 : : .comp = comp_meter_color,
3253 : : },
3254 : : /* Top-level command. */
3255 : : [FLOW] = {
3256 : : .name = "flow",
3257 : : .type = "{command} {port_id} [{arg} [...]]",
3258 : : .help = "manage ingress/egress flow rules",
3259 : : .next = NEXT(NEXT_ENTRY
3260 : : (INFO,
3261 : : CONFIGURE,
3262 : : PATTERN_TEMPLATE,
3263 : : ACTIONS_TEMPLATE,
3264 : : TABLE,
3265 : : FLOW_GROUP,
3266 : : INDIRECT_ACTION,
3267 : : VALIDATE,
3268 : : CREATE,
3269 : : DESTROY,
3270 : : UPDATE,
3271 : : FLUSH,
3272 : : DUMP,
3273 : : LIST,
3274 : : AGED,
3275 : : QUERY,
3276 : : ISOLATE,
3277 : : TUNNEL,
3278 : : FLEX,
3279 : : QUEUE,
3280 : : PUSH,
3281 : : PULL,
3282 : : HASH)),
3283 : : .call = parse_init,
3284 : : },
3285 : : /* Top-level command. */
3286 : : [INFO] = {
3287 : : .name = "info",
3288 : : .help = "get information about flow engine",
3289 : : .next = NEXT(NEXT_ENTRY(END),
3290 : : NEXT_ENTRY(COMMON_PORT_ID)),
3291 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3292 : : .call = parse_configure,
3293 : : },
3294 : : /* Top-level command. */
3295 : : [CONFIGURE] = {
3296 : : .name = "configure",
3297 : : .help = "configure flow engine",
3298 : : .next = NEXT(next_config_attr,
3299 : : NEXT_ENTRY(COMMON_PORT_ID)),
3300 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3301 : : .call = parse_configure,
3302 : : },
3303 : : /* Configure arguments. */
3304 : : [CONFIG_QUEUES_NUMBER] = {
3305 : : .name = "queues_number",
3306 : : .help = "number of queues",
3307 : : .next = NEXT(next_config_attr,
3308 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3309 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3310 : : args.configure.nb_queue)),
3311 : : },
3312 : : [CONFIG_QUEUES_SIZE] = {
3313 : : .name = "queues_size",
3314 : : .help = "number of elements in queues",
3315 : : .next = NEXT(next_config_attr,
3316 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3317 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3318 : : args.configure.queue_attr.size)),
3319 : : },
3320 : : [CONFIG_COUNTERS_NUMBER] = {
3321 : : .name = "counters_number",
3322 : : .help = "number of counters",
3323 : : .next = NEXT(next_config_attr,
3324 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3325 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3326 : : args.configure.port_attr.nb_counters)),
3327 : : },
3328 : : [CONFIG_AGING_OBJECTS_NUMBER] = {
3329 : : .name = "aging_counters_number",
3330 : : .help = "number of aging objects",
3331 : : .next = NEXT(next_config_attr,
3332 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3333 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3334 : : args.configure.port_attr.nb_aging_objects)),
3335 : : },
3336 : : [CONFIG_QUOTAS_NUMBER] = {
3337 : : .name = "quotas_number",
3338 : : .help = "number of quotas",
3339 : : .next = NEXT(next_config_attr,
3340 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3341 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3342 : : args.configure.port_attr.nb_quotas)),
3343 : : },
3344 : : [CONFIG_METERS_NUMBER] = {
3345 : : .name = "meters_number",
3346 : : .help = "number of meters",
3347 : : .next = NEXT(next_config_attr,
3348 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3349 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3350 : : args.configure.port_attr.nb_meters)),
3351 : : },
3352 : : [CONFIG_CONN_TRACK_NUMBER] = {
3353 : : .name = "conn_tracks_number",
3354 : : .help = "number of connection trackings",
3355 : : .next = NEXT(next_config_attr,
3356 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3357 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3358 : : args.configure.port_attr.nb_conn_tracks)),
3359 : : },
3360 : : [CONFIG_FLAGS] = {
3361 : : .name = "flags",
3362 : : .help = "configuration flags",
3363 : : .next = NEXT(next_config_attr,
3364 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3365 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3366 : : args.configure.port_attr.flags)),
3367 : : },
3368 : : [CONFIG_HOST_PORT] = {
3369 : : .name = "host_port",
3370 : : .help = "host port for shared objects",
3371 : : .next = NEXT(next_config_attr,
3372 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3373 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3374 : : args.configure.port_attr.host_port_id)),
3375 : : },
3376 : : /* Top-level command. */
3377 : : [PATTERN_TEMPLATE] = {
3378 : : .name = "pattern_template",
3379 : : .type = "{command} {port_id} [{arg} [...]]",
3380 : : .help = "manage pattern templates",
3381 : : .next = NEXT(next_pt_subcmd, NEXT_ENTRY(COMMON_PORT_ID)),
3382 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3383 : : .call = parse_template,
3384 : : },
3385 : : /* Sub-level commands. */
3386 : : [PATTERN_TEMPLATE_CREATE] = {
3387 : : .name = "create",
3388 : : .help = "create pattern template",
3389 : : .next = NEXT(next_pt_attr),
3390 : : .call = parse_template,
3391 : : },
3392 : : [PATTERN_TEMPLATE_DESTROY] = {
3393 : : .name = "destroy",
3394 : : .help = "destroy pattern template",
3395 : : .next = NEXT(NEXT_ENTRY(PATTERN_TEMPLATE_DESTROY_ID)),
3396 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3397 : : .call = parse_template_destroy,
3398 : : },
3399 : : /* Pattern template arguments. */
3400 : : [PATTERN_TEMPLATE_CREATE_ID] = {
3401 : : .name = "pattern_template_id",
3402 : : .help = "specify a pattern template id to create",
3403 : : .next = NEXT(next_pt_attr,
3404 : : NEXT_ENTRY(COMMON_PATTERN_TEMPLATE_ID)),
3405 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.pat_templ_id)),
3406 : : },
3407 : : [PATTERN_TEMPLATE_DESTROY_ID] = {
3408 : : .name = "pattern_template",
3409 : : .help = "specify a pattern template id to destroy",
3410 : : .next = NEXT(next_pt_destroy_attr,
3411 : : NEXT_ENTRY(COMMON_PATTERN_TEMPLATE_ID)),
3412 : : .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
3413 : : args.templ_destroy.template_id)),
3414 : : .call = parse_template_destroy,
3415 : : },
3416 : : [PATTERN_TEMPLATE_RELAXED_MATCHING] = {
3417 : : .name = "relaxed",
3418 : : .help = "is matching relaxed",
3419 : : .next = NEXT(next_pt_attr,
3420 : : NEXT_ENTRY(COMMON_BOOLEAN)),
3421 : : .args = ARGS(ARGS_ENTRY_BF(struct buffer,
3422 : : args.vc.attr.reserved, 1)),
3423 : : },
3424 : : [PATTERN_TEMPLATE_INGRESS] = {
3425 : : .name = "ingress",
3426 : : .help = "attribute pattern to ingress",
3427 : : .next = NEXT(next_pt_attr),
3428 : : .call = parse_template,
3429 : : },
3430 : : [PATTERN_TEMPLATE_EGRESS] = {
3431 : : .name = "egress",
3432 : : .help = "attribute pattern to egress",
3433 : : .next = NEXT(next_pt_attr),
3434 : : .call = parse_template,
3435 : : },
3436 : : [PATTERN_TEMPLATE_TRANSFER] = {
3437 : : .name = "transfer",
3438 : : .help = "attribute pattern to transfer",
3439 : : .next = NEXT(next_pt_attr),
3440 : : .call = parse_template,
3441 : : },
3442 : : [PATTERN_TEMPLATE_SPEC] = {
3443 : : .name = "template",
3444 : : .help = "specify item to create pattern template",
3445 : : .next = NEXT(next_item),
3446 : : },
3447 : : /* Top-level command. */
3448 : : [ACTIONS_TEMPLATE] = {
3449 : : .name = "actions_template",
3450 : : .type = "{command} {port_id} [{arg} [...]]",
3451 : : .help = "manage actions templates",
3452 : : .next = NEXT(next_at_subcmd, NEXT_ENTRY(COMMON_PORT_ID)),
3453 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3454 : : .call = parse_template,
3455 : : },
3456 : : /* Sub-level commands. */
3457 : : [ACTIONS_TEMPLATE_CREATE] = {
3458 : : .name = "create",
3459 : : .help = "create actions template",
3460 : : .next = NEXT(next_at_attr),
3461 : : .call = parse_template,
3462 : : },
3463 : : [ACTIONS_TEMPLATE_DESTROY] = {
3464 : : .name = "destroy",
3465 : : .help = "destroy actions template",
3466 : : .next = NEXT(NEXT_ENTRY(ACTIONS_TEMPLATE_DESTROY_ID)),
3467 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3468 : : .call = parse_template_destroy,
3469 : : },
3470 : : /* Actions template arguments. */
3471 : : [ACTIONS_TEMPLATE_CREATE_ID] = {
3472 : : .name = "actions_template_id",
3473 : : .help = "specify an actions template id to create",
3474 : : .next = NEXT(NEXT_ENTRY(ACTIONS_TEMPLATE_MASK),
3475 : : NEXT_ENTRY(ACTIONS_TEMPLATE_SPEC),
3476 : : NEXT_ENTRY(COMMON_ACTIONS_TEMPLATE_ID)),
3477 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.act_templ_id)),
3478 : : },
3479 : : [ACTIONS_TEMPLATE_DESTROY_ID] = {
3480 : : .name = "actions_template",
3481 : : .help = "specify an actions template id to destroy",
3482 : : .next = NEXT(next_at_destroy_attr,
3483 : : NEXT_ENTRY(COMMON_ACTIONS_TEMPLATE_ID)),
3484 : : .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
3485 : : args.templ_destroy.template_id)),
3486 : : .call = parse_template_destroy,
3487 : : },
3488 : : [ACTIONS_TEMPLATE_INGRESS] = {
3489 : : .name = "ingress",
3490 : : .help = "attribute actions to ingress",
3491 : : .next = NEXT(next_at_attr),
3492 : : .call = parse_template,
3493 : : },
3494 : : [ACTIONS_TEMPLATE_EGRESS] = {
3495 : : .name = "egress",
3496 : : .help = "attribute actions to egress",
3497 : : .next = NEXT(next_at_attr),
3498 : : .call = parse_template,
3499 : : },
3500 : : [ACTIONS_TEMPLATE_TRANSFER] = {
3501 : : .name = "transfer",
3502 : : .help = "attribute actions to transfer",
3503 : : .next = NEXT(next_at_attr),
3504 : : .call = parse_template,
3505 : : },
3506 : : [ACTIONS_TEMPLATE_SPEC] = {
3507 : : .name = "template",
3508 : : .help = "specify action to create actions template",
3509 : : .next = NEXT(next_action),
3510 : : .call = parse_template,
3511 : : },
3512 : : [ACTIONS_TEMPLATE_MASK] = {
3513 : : .name = "mask",
3514 : : .help = "specify action mask to create actions template",
3515 : : .next = NEXT(next_action),
3516 : : .call = parse_template,
3517 : : },
3518 : : /* Top-level command. */
3519 : : [TABLE] = {
3520 : : .name = "template_table",
3521 : : .type = "{command} {port_id} [{arg} [...]]",
3522 : : .help = "manage template tables",
3523 : : .next = NEXT(next_table_subcmd, NEXT_ENTRY(COMMON_PORT_ID)),
3524 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3525 : : .call = parse_table,
3526 : : },
3527 : : /* Sub-level commands. */
3528 : : [TABLE_CREATE] = {
3529 : : .name = "create",
3530 : : .help = "create template table",
3531 : : .next = NEXT(next_table_attr),
3532 : : .call = parse_table,
3533 : : },
3534 : : [TABLE_DESTROY] = {
3535 : : .name = "destroy",
3536 : : .help = "destroy template table",
3537 : : .next = NEXT(NEXT_ENTRY(TABLE_DESTROY_ID)),
3538 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3539 : : .call = parse_table_destroy,
3540 : : },
3541 : : [TABLE_RESIZE] = {
3542 : : .name = "resize",
3543 : : .help = "resize template table",
3544 : : .next = NEXT(NEXT_ENTRY(TABLE_RESIZE_ID)),
3545 : : .call = parse_table
3546 : : },
3547 : : [TABLE_RESIZE_COMPLETE] = {
3548 : : .name = "resize_complete",
3549 : : .help = "complete table resize",
3550 : : .next = NEXT(NEXT_ENTRY(TABLE_DESTROY_ID)),
3551 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3552 : : .call = parse_table_destroy,
3553 : : },
3554 : : /* Table arguments. */
3555 : : [TABLE_CREATE_ID] = {
3556 : : .name = "table_id",
3557 : : .help = "specify table id to create",
3558 : : .next = NEXT(next_table_attr,
3559 : : NEXT_ENTRY(COMMON_TABLE_ID)),
3560 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.table.id)),
3561 : : },
3562 : : [TABLE_DESTROY_ID] = {
3563 : : .name = "table",
3564 : : .help = "table id",
3565 : : .next = NEXT(next_table_destroy_attr,
3566 : : NEXT_ENTRY(COMMON_TABLE_ID)),
3567 : : .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
3568 : : args.table_destroy.table_id)),
3569 : : .call = parse_table_destroy,
3570 : : },
3571 : : [TABLE_RESIZE_ID] = {
3572 : : .name = "table_resize_id",
3573 : : .help = "table resize id",
3574 : : .next = NEXT(NEXT_ENTRY(TABLE_RESIZE_RULES_NUMBER),
3575 : : NEXT_ENTRY(COMMON_TABLE_ID)),
3576 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.table.id)),
3577 : : .call = parse_table
3578 : : },
3579 : : [TABLE_RESIZE_RULES_NUMBER] = {
3580 : : .name = "table_resize_rules_num",
3581 : : .help = "table resize rules number",
3582 : : .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(COMMON_UNSIGNED)),
3583 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3584 : : args.table.attr.nb_flows)),
3585 : : .call = parse_table
3586 : : },
3587 : : [TABLE_INSERTION_TYPE] = {
3588 : : .name = "insertion_type",
3589 : : .help = "specify insertion type",
3590 : : .next = NEXT(next_table_attr,
3591 : : NEXT_ENTRY(TABLE_INSERTION_TYPE_NAME)),
3592 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3593 : : args.table.attr.insertion_type)),
3594 : : },
3595 : : [TABLE_INSERTION_TYPE_NAME] = {
3596 : : .name = "insertion_type_name",
3597 : : .help = "insertion type name",
3598 : : .call = parse_insertion_table_type,
3599 : : .comp = comp_insertion_table_type,
3600 : : },
3601 : : [TABLE_HASH_FUNC] = {
3602 : : .name = "hash_func",
3603 : : .help = "specify hash calculation function",
3604 : : .next = NEXT(next_table_attr,
3605 : : NEXT_ENTRY(TABLE_HASH_FUNC_NAME)),
3606 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3607 : : args.table.attr.hash_func)),
3608 : : },
3609 : : [TABLE_HASH_FUNC_NAME] = {
3610 : : .name = "hash_func_name",
3611 : : .help = "hash calculation function name",
3612 : : .call = parse_hash_table_type,
3613 : : .comp = comp_hash_table_type,
3614 : : },
3615 : : [TABLE_GROUP] = {
3616 : : .name = "group",
3617 : : .help = "specify a group",
3618 : : .next = NEXT(next_table_attr, NEXT_ENTRY(COMMON_GROUP_ID)),
3619 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3620 : : args.table.attr.flow_attr.group)),
3621 : : },
3622 : : [TABLE_PRIORITY] = {
3623 : : .name = "priority",
3624 : : .help = "specify a priority level",
3625 : : .next = NEXT(next_table_attr, NEXT_ENTRY(COMMON_PRIORITY_LEVEL)),
3626 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3627 : : args.table.attr.flow_attr.priority)),
3628 : : },
3629 : : [TABLE_EGRESS] = {
3630 : : .name = "egress",
3631 : : .help = "affect rule to egress",
3632 : : .next = NEXT(next_table_attr),
3633 : : .call = parse_table,
3634 : : },
3635 : : [TABLE_INGRESS] = {
3636 : : .name = "ingress",
3637 : : .help = "affect rule to ingress",
3638 : : .next = NEXT(next_table_attr),
3639 : : .call = parse_table,
3640 : : },
3641 : : [TABLE_TRANSFER] = {
3642 : : .name = "transfer",
3643 : : .help = "affect rule to transfer",
3644 : : .next = NEXT(next_table_attr),
3645 : : .call = parse_table,
3646 : : },
3647 : : [TABLE_TRANSFER_WIRE_ORIG] = {
3648 : : .name = "wire_orig",
3649 : : .help = "affect rule direction to transfer",
3650 : : .next = NEXT(next_table_attr),
3651 : : .call = parse_table,
3652 : : },
3653 : : [TABLE_TRANSFER_VPORT_ORIG] = {
3654 : : .name = "vport_orig",
3655 : : .help = "affect rule direction to transfer",
3656 : : .next = NEXT(next_table_attr),
3657 : : .call = parse_table,
3658 : : },
3659 : : [TABLE_RESIZABLE] = {
3660 : : .name = "resizable",
3661 : : .help = "set resizable attribute",
3662 : : .next = NEXT(next_table_attr),
3663 : : .call = parse_table,
3664 : : },
3665 : : [TABLE_RULES_NUMBER] = {
3666 : : .name = "rules_number",
3667 : : .help = "number of rules in table",
3668 : : .next = NEXT(next_table_attr,
3669 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3670 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3671 : : args.table.attr.nb_flows)),
3672 : : .call = parse_table,
3673 : : },
3674 : : [TABLE_PATTERN_TEMPLATE] = {
3675 : : .name = "pattern_template",
3676 : : .help = "specify pattern template id",
3677 : : .next = NEXT(next_table_attr,
3678 : : NEXT_ENTRY(COMMON_PATTERN_TEMPLATE_ID)),
3679 : : .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
3680 : : args.table.pat_templ_id)),
3681 : : .call = parse_table,
3682 : : },
3683 : : [TABLE_ACTIONS_TEMPLATE] = {
3684 : : .name = "actions_template",
3685 : : .help = "specify actions template id",
3686 : : .next = NEXT(next_table_attr,
3687 : : NEXT_ENTRY(COMMON_ACTIONS_TEMPLATE_ID)),
3688 : : .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
3689 : : args.table.act_templ_id)),
3690 : : .call = parse_table,
3691 : : },
3692 : : /* Top-level command. */
3693 : : [FLOW_GROUP] = {
3694 : : .name = "group",
3695 : : .help = "manage flow groups",
3696 : : .next = NEXT(NEXT_ENTRY(GROUP_ID), NEXT_ENTRY(COMMON_PORT_ID)),
3697 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3698 : : .call = parse_group,
3699 : : },
3700 : : /* Sub-level commands. */
3701 : : [GROUP_SET_MISS_ACTIONS] = {
3702 : : .name = "set_miss_actions",
3703 : : .help = "set group miss actions",
3704 : : .next = NEXT(next_action),
3705 : : .call = parse_group,
3706 : : },
3707 : : /* Group arguments */
3708 : : [GROUP_ID] = {
3709 : : .name = "group_id",
3710 : : .help = "group id",
3711 : : .next = NEXT(next_group_attr, NEXT_ENTRY(COMMON_GROUP_ID)),
3712 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
3713 : : },
3714 : : [GROUP_INGRESS] = {
3715 : : .name = "ingress",
3716 : : .help = "group ingress attr",
3717 : : .next = NEXT(next_group_attr),
3718 : : .call = parse_group,
3719 : : },
3720 : : [GROUP_EGRESS] = {
3721 : : .name = "egress",
3722 : : .help = "group egress attr",
3723 : : .next = NEXT(next_group_attr),
3724 : : .call = parse_group,
3725 : : },
3726 : : [GROUP_TRANSFER] = {
3727 : : .name = "transfer",
3728 : : .help = "group transfer attr",
3729 : : .next = NEXT(next_group_attr),
3730 : : .call = parse_group,
3731 : : },
3732 : : /* Top-level command. */
3733 : : [QUEUE] = {
3734 : : .name = "queue",
3735 : : .help = "queue a flow rule operation",
3736 : : .next = NEXT(next_queue_subcmd, NEXT_ENTRY(COMMON_PORT_ID)),
3737 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3738 : : .call = parse_qo,
3739 : : },
3740 : : /* Sub-level commands. */
3741 : : [QUEUE_CREATE] = {
3742 : : .name = "create",
3743 : : .help = "create a flow rule",
3744 : : .next = NEXT(NEXT_ENTRY(QUEUE_TEMPLATE_TABLE),
3745 : : NEXT_ENTRY(COMMON_QUEUE_ID)),
3746 : : .args = ARGS(ARGS_ENTRY(struct buffer, queue)),
3747 : : .call = parse_qo,
3748 : : },
3749 : : [QUEUE_DESTROY] = {
3750 : : .name = "destroy",
3751 : : .help = "destroy a flow rule",
3752 : : .next = NEXT(NEXT_ENTRY(QUEUE_DESTROY_POSTPONE),
3753 : : NEXT_ENTRY(COMMON_QUEUE_ID)),
3754 : : .args = ARGS(ARGS_ENTRY(struct buffer, queue)),
3755 : : .call = parse_qo_destroy,
3756 : : },
3757 : : [QUEUE_FLOW_UPDATE_RESIZED] = {
3758 : : .name = "update_resized",
3759 : : .help = "update a flow after table resize",
3760 : : .next = NEXT(NEXT_ENTRY(QUEUE_DESTROY_ID),
3761 : : NEXT_ENTRY(COMMON_QUEUE_ID)),
3762 : : .args = ARGS(ARGS_ENTRY(struct buffer, queue)),
3763 : : .call = parse_qo_destroy,
3764 : : },
3765 : : [QUEUE_UPDATE] = {
3766 : : .name = "update",
3767 : : .help = "update a flow rule",
3768 : : .next = NEXT(NEXT_ENTRY(QUEUE_UPDATE_ID),
3769 : : NEXT_ENTRY(COMMON_QUEUE_ID)),
3770 : : .args = ARGS(ARGS_ENTRY(struct buffer, queue)),
3771 : : .call = parse_qo,
3772 : : },
3773 : : [QUEUE_AGED] = {
3774 : : .name = "aged",
3775 : : .help = "list and destroy aged flows",
3776 : : .next = NEXT(next_aged_attr, NEXT_ENTRY(COMMON_QUEUE_ID)),
3777 : : .args = ARGS(ARGS_ENTRY(struct buffer, queue)),
3778 : : .call = parse_aged,
3779 : : },
3780 : : [QUEUE_INDIRECT_ACTION] = {
3781 : : .name = "indirect_action",
3782 : : .help = "queue indirect actions",
3783 : : .next = NEXT(next_qia_subcmd, NEXT_ENTRY(COMMON_QUEUE_ID)),
3784 : : .args = ARGS(ARGS_ENTRY(struct buffer, queue)),
3785 : : .call = parse_qia,
3786 : : },
3787 : : /* Queue arguments. */
3788 : : [QUEUE_TEMPLATE_TABLE] = {
3789 : : .name = "template_table",
3790 : : .help = "specify table id",
3791 : : .next = NEXT(next_async_insert_subcmd,
3792 : : NEXT_ENTRY(COMMON_TABLE_ID)),
3793 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3794 : : args.vc.table_id)),
3795 : : .call = parse_qo,
3796 : : },
3797 : : [QUEUE_PATTERN_TEMPLATE] = {
3798 : : .name = "pattern_template",
3799 : : .help = "specify pattern template index",
3800 : : .next = NEXT(NEXT_ENTRY(QUEUE_ACTIONS_TEMPLATE),
3801 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3802 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3803 : : args.vc.pat_templ_id)),
3804 : : .call = parse_qo,
3805 : : },
3806 : : [QUEUE_ACTIONS_TEMPLATE] = {
3807 : : .name = "actions_template",
3808 : : .help = "specify actions template index",
3809 : : .next = NEXT(NEXT_ENTRY(QUEUE_CREATE_POSTPONE),
3810 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3811 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3812 : : args.vc.act_templ_id)),
3813 : : .call = parse_qo,
3814 : : },
3815 : : [QUEUE_RULE_ID] = {
3816 : : .name = "rule_index",
3817 : : .help = "specify flow rule index",
3818 : : .next = NEXT(next_async_pattern_subcmd,
3819 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3820 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3821 : : args.vc.rule_id)),
3822 : : .call = parse_qo,
3823 : : },
3824 : : [QUEUE_CREATE_POSTPONE] = {
3825 : : .name = "postpone",
3826 : : .help = "postpone create operation",
3827 : : .next = NEXT(NEXT_ENTRY(ITEM_PATTERN),
3828 : : NEXT_ENTRY(COMMON_BOOLEAN)),
3829 : : .args = ARGS(ARGS_ENTRY(struct buffer, postpone)),
3830 : : .call = parse_qo,
3831 : : },
3832 : : [QUEUE_DESTROY_POSTPONE] = {
3833 : : .name = "postpone",
3834 : : .help = "postpone destroy operation",
3835 : : .next = NEXT(NEXT_ENTRY(QUEUE_DESTROY_ID),
3836 : : NEXT_ENTRY(COMMON_BOOLEAN)),
3837 : : .args = ARGS(ARGS_ENTRY(struct buffer, postpone)),
3838 : : .call = parse_qo_destroy,
3839 : : },
3840 : : [QUEUE_DESTROY_ID] = {
3841 : : .name = "rule",
3842 : : .help = "specify rule id to destroy",
3843 : : .next = NEXT(next_queue_destroy_attr,
3844 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3845 : : .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
3846 : : args.destroy.rule)),
3847 : : .call = parse_qo_destroy,
3848 : : },
3849 : : [QUEUE_UPDATE_ID] = {
3850 : : .name = "rule",
3851 : : .help = "specify rule id to update",
3852 : : .next = NEXT(NEXT_ENTRY(QUEUE_ACTIONS_TEMPLATE),
3853 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3854 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3855 : : args.vc.rule_id)),
3856 : : .call = parse_qo,
3857 : : },
3858 : : /* Queue indirect action arguments */
3859 : : [QUEUE_INDIRECT_ACTION_CREATE] = {
3860 : : .name = "create",
3861 : : .help = "create indirect action",
3862 : : .next = NEXT(next_qia_create_attr),
3863 : : .call = parse_qia,
3864 : : },
3865 : : [QUEUE_INDIRECT_ACTION_UPDATE] = {
3866 : : .name = "update",
3867 : : .help = "update indirect action",
3868 : : .next = NEXT(next_qia_update_attr,
3869 : : NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
3870 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
3871 : : .call = parse_qia,
3872 : : },
3873 : : [QUEUE_INDIRECT_ACTION_DESTROY] = {
3874 : : .name = "destroy",
3875 : : .help = "destroy indirect action",
3876 : : .next = NEXT(next_qia_destroy_attr),
3877 : : .call = parse_qia_destroy,
3878 : : },
3879 : : [QUEUE_INDIRECT_ACTION_QUERY] = {
3880 : : .name = "query",
3881 : : .help = "query indirect action",
3882 : : .next = NEXT(next_qia_query_attr,
3883 : : NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
3884 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.ia.action_id)),
3885 : : .call = parse_qia,
3886 : : },
3887 : : /* Indirect action destroy arguments. */
3888 : : [QUEUE_INDIRECT_ACTION_DESTROY_POSTPONE] = {
3889 : : .name = "postpone",
3890 : : .help = "postpone destroy operation",
3891 : : .next = NEXT(next_qia_destroy_attr,
3892 : : NEXT_ENTRY(COMMON_BOOLEAN)),
3893 : : .args = ARGS(ARGS_ENTRY(struct buffer, postpone)),
3894 : : },
3895 : : [QUEUE_INDIRECT_ACTION_DESTROY_ID] = {
3896 : : .name = "action_id",
3897 : : .help = "specify a indirect action id to destroy",
3898 : : .next = NEXT(next_qia_destroy_attr,
3899 : : NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
3900 : : .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
3901 : : args.ia_destroy.action_id)),
3902 : : .call = parse_qia_destroy,
3903 : : },
3904 : : [QUEUE_INDIRECT_ACTION_QUERY_UPDATE] = {
3905 : : .name = "query_update",
3906 : : .help = "indirect query [and|or] update action",
3907 : : .next = NEXT(next_qia_qu_attr, NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
3908 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.ia.action_id)),
3909 : : .call = parse_qia
3910 : : },
3911 : : [QUEUE_INDIRECT_ACTION_QU_MODE] = {
3912 : : .name = "mode",
3913 : : .help = "indirect query [and|or] update action",
3914 : : .next = NEXT(next_qia_qu_attr,
3915 : : NEXT_ENTRY(INDIRECT_ACTION_QU_MODE_NAME)),
3916 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.ia.qu_mode)),
3917 : : .call = parse_qia
3918 : : },
3919 : : /* Indirect action update arguments. */
3920 : : [QUEUE_INDIRECT_ACTION_UPDATE_POSTPONE] = {
3921 : : .name = "postpone",
3922 : : .help = "postpone update operation",
3923 : : .next = NEXT(next_qia_update_attr,
3924 : : NEXT_ENTRY(COMMON_BOOLEAN)),
3925 : : .args = ARGS(ARGS_ENTRY(struct buffer, postpone)),
3926 : : },
3927 : : /* Indirect action update arguments. */
3928 : : [QUEUE_INDIRECT_ACTION_QUERY_POSTPONE] = {
3929 : : .name = "postpone",
3930 : : .help = "postpone query operation",
3931 : : .next = NEXT(next_qia_query_attr,
3932 : : NEXT_ENTRY(COMMON_BOOLEAN)),
3933 : : .args = ARGS(ARGS_ENTRY(struct buffer, postpone)),
3934 : : },
3935 : : /* Indirect action create arguments. */
3936 : : [QUEUE_INDIRECT_ACTION_CREATE_ID] = {
3937 : : .name = "action_id",
3938 : : .help = "specify a indirect action id to create",
3939 : : .next = NEXT(next_qia_create_attr,
3940 : : NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
3941 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
3942 : : },
3943 : : [QUEUE_INDIRECT_ACTION_INGRESS] = {
3944 : : .name = "ingress",
3945 : : .help = "affect rule to ingress",
3946 : : .next = NEXT(next_qia_create_attr),
3947 : : .call = parse_qia,
3948 : : },
3949 : : [QUEUE_INDIRECT_ACTION_EGRESS] = {
3950 : : .name = "egress",
3951 : : .help = "affect rule to egress",
3952 : : .next = NEXT(next_qia_create_attr),
3953 : : .call = parse_qia,
3954 : : },
3955 : : [QUEUE_INDIRECT_ACTION_TRANSFER] = {
3956 : : .name = "transfer",
3957 : : .help = "affect rule to transfer",
3958 : : .next = NEXT(next_qia_create_attr),
3959 : : .call = parse_qia,
3960 : : },
3961 : : [QUEUE_INDIRECT_ACTION_CREATE_POSTPONE] = {
3962 : : .name = "postpone",
3963 : : .help = "postpone create operation",
3964 : : .next = NEXT(next_qia_create_attr,
3965 : : NEXT_ENTRY(COMMON_BOOLEAN)),
3966 : : .args = ARGS(ARGS_ENTRY(struct buffer, postpone)),
3967 : : },
3968 : : [QUEUE_INDIRECT_ACTION_SPEC] = {
3969 : : .name = "action",
3970 : : .help = "specify action to create indirect handle",
3971 : : .next = NEXT(next_action),
3972 : : },
3973 : : [QUEUE_INDIRECT_ACTION_LIST] = {
3974 : : .name = "list",
3975 : : .help = "specify actions for indirect handle list",
3976 : : .next = NEXT(NEXT_ENTRY(ACTIONS, END)),
3977 : : .call = parse_qia,
3978 : : },
3979 : : /* Top-level command. */
3980 : : [PUSH] = {
3981 : : .name = "push",
3982 : : .help = "push enqueued operations",
3983 : : .next = NEXT(NEXT_ENTRY(PUSH_QUEUE), NEXT_ENTRY(COMMON_PORT_ID)),
3984 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3985 : : .call = parse_push,
3986 : : },
3987 : : /* Sub-level commands. */
3988 : : [PUSH_QUEUE] = {
3989 : : .name = "queue",
3990 : : .help = "specify queue id",
3991 : : .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(COMMON_QUEUE_ID)),
3992 : : .args = ARGS(ARGS_ENTRY(struct buffer, queue)),
3993 : : },
3994 : : /* Top-level command. */
3995 : : [PULL] = {
3996 : : .name = "pull",
3997 : : .help = "pull flow operations results",
3998 : : .next = NEXT(NEXT_ENTRY(PULL_QUEUE), NEXT_ENTRY(COMMON_PORT_ID)),
3999 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
4000 : : .call = parse_pull,
4001 : : },
4002 : : /* Sub-level commands. */
4003 : : [PULL_QUEUE] = {
4004 : : .name = "queue",
4005 : : .help = "specify queue id",
4006 : : .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(COMMON_QUEUE_ID)),
4007 : : .args = ARGS(ARGS_ENTRY(struct buffer, queue)),
4008 : : },
4009 : : /* Top-level command. */
4010 : : [HASH] = {
4011 : : .name = "hash",
4012 : : .help = "calculate hash for a given pattern in a given template table",
4013 : : .next = NEXT(next_hash_subcmd, NEXT_ENTRY(COMMON_PORT_ID)),
4014 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
4015 : : .call = parse_hash,
4016 : : },
4017 : : /* Sub-level commands. */
4018 : : [HASH_CALC_TABLE] = {
4019 : : .name = "template_table",
4020 : : .help = "specify table id",
4021 : : .next = NEXT(NEXT_ENTRY(HASH_CALC_PATTERN_INDEX),
4022 : : NEXT_ENTRY(COMMON_TABLE_ID)),
4023 : : .args = ARGS(ARGS_ENTRY(struct buffer,
4024 : : args.vc.table_id)),
4025 : : .call = parse_hash,
4026 : : },
4027 : : [HASH_CALC_ENCAP] = {
4028 : : .name = "encap",
4029 : : .help = "calculates encap hash",
4030 : : .next = NEXT(next_hash_encap_dest_subcmd),
4031 : : .call = parse_hash,
4032 : : },
4033 : : [HASH_CALC_PATTERN_INDEX] = {
4034 : : .name = "pattern_template",
4035 : : .help = "specify pattern template id",
4036 : : .next = NEXT(NEXT_ENTRY(ITEM_PATTERN),
4037 : : NEXT_ENTRY(COMMON_UNSIGNED)),
4038 : : .args = ARGS(ARGS_ENTRY(struct buffer,
4039 : : args.vc.pat_templ_id)),
4040 : : .call = parse_hash,
4041 : : },
4042 : : [ENCAP_HASH_FIELD_SRC_PORT] = {
4043 : : .name = "hash_field_sport",
4044 : : .help = "the encap hash field is src port",
4045 : : .next = NEXT(NEXT_ENTRY(ITEM_PATTERN)),
4046 : : .call = parse_hash,
4047 : : },
4048 : : [ENCAP_HASH_FIELD_GRE_FLOW_ID] = {
4049 : : .name = "hash_field_flow_id",
4050 : : .help = "the encap hash field is NVGRE flow id",
4051 : : .next = NEXT(NEXT_ENTRY(ITEM_PATTERN)),
4052 : : .call = parse_hash,
4053 : : },
4054 : : /* Top-level command. */
4055 : : [INDIRECT_ACTION] = {
4056 : : .name = "indirect_action",
4057 : : .type = "{command} {port_id} [{arg} [...]]",
4058 : : .help = "manage indirect actions",
4059 : : .next = NEXT(next_ia_subcmd, NEXT_ENTRY(COMMON_PORT_ID)),
4060 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
4061 : : .call = parse_ia,
4062 : : },
4063 : : /* Sub-level commands. */
4064 : : [INDIRECT_ACTION_CREATE] = {
4065 : : .name = "create",
4066 : : .help = "create indirect action",
4067 : : .next = NEXT(next_ia_create_attr),
4068 : : .call = parse_ia,
4069 : : },
4070 : : [INDIRECT_ACTION_UPDATE] = {
4071 : : .name = "update",
4072 : : .help = "update indirect action",
4073 : : .next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_SPEC),
4074 : : NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
4075 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
4076 : : .call = parse_ia,
4077 : : },
4078 : : [INDIRECT_ACTION_DESTROY] = {
4079 : : .name = "destroy",
4080 : : .help = "destroy indirect action",
4081 : : .next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_DESTROY_ID)),
4082 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
4083 : : .call = parse_ia_destroy,
4084 : : },
4085 : : [INDIRECT_ACTION_QUERY] = {
4086 : : .name = "query",
4087 : : .help = "query indirect action",
4088 : : .next = NEXT(NEXT_ENTRY(END),
4089 : : NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
4090 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.ia.action_id)),
4091 : : .call = parse_ia,
4092 : : },
4093 : : [INDIRECT_ACTION_QUERY_UPDATE] = {
4094 : : .name = "query_update",
4095 : : .help = "query [and|or] update",
4096 : : .next = NEXT(next_ia_qu_attr, NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
4097 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.ia.action_id)),
4098 : : .call = parse_ia
4099 : : },
4100 : : [INDIRECT_ACTION_QU_MODE] = {
4101 : : .name = "mode",
4102 : : .help = "query_update mode",
4103 : : .next = NEXT(next_ia_qu_attr,
4104 : : NEXT_ENTRY(INDIRECT_ACTION_QU_MODE_NAME)),
4105 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.ia.qu_mode)),
4106 : : .call = parse_ia,
4107 : : },
4108 : : [INDIRECT_ACTION_QU_MODE_NAME] = {
4109 : : .name = "mode_name",
4110 : : .help = "query-update mode name",
4111 : : .call = parse_qu_mode_name,
4112 : : .comp = comp_qu_mode_name,
4113 : : },
4114 : : [VALIDATE] = {
4115 : : .name = "validate",
4116 : : .help = "check whether a flow rule can be created",
4117 : : .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_PORT_ID)),
4118 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
4119 : : .call = parse_vc,
4120 : : },
4121 : : [CREATE] = {
4122 : : .name = "create",
4123 : : .help = "create a flow rule",
4124 : : .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_PORT_ID)),
4125 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
4126 : : .call = parse_vc,
4127 : : },
4128 : : [DESTROY] = {
4129 : : .name = "destroy",
4130 : : .help = "destroy specific flow rules",
4131 : : .next = NEXT(next_destroy_attr,
4132 : : NEXT_ENTRY(COMMON_PORT_ID)),
4133 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
4134 : : .call = parse_destroy,
4135 : : },
4136 : : [UPDATE] = {
4137 : : .name = "update",
4138 : : .help = "update a flow rule with new actions",
4139 : : .next = NEXT(NEXT_ENTRY(VC_IS_USER_ID, END),
4140 : : NEXT_ENTRY(ACTIONS),
4141 : : NEXT_ENTRY(COMMON_RULE_ID),
4142 : : NEXT_ENTRY(COMMON_PORT_ID)),
4143 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.rule_id),
4144 : : ARGS_ENTRY(struct buffer, port)),
4145 : : .call = parse_vc,
4146 : : },
4147 : : [FLUSH] = {
4148 : : .name = "flush",
4149 : : .help = "destroy all flow rules",
4150 : : .next = NEXT(NEXT_ENTRY(COMMON_PORT_ID)),
4151 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
4152 : : .call = parse_flush,
4153 : : },
4154 : : [DUMP] = {
4155 : : .name = "dump",
4156 : : .help = "dump single/all flow rules to file",
4157 : : .next = NEXT(next_dump_subcmd, NEXT_ENTRY(COMMON_PORT_ID)),
4158 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
4159 : : .call = parse_dump,
4160 : : },
4161 : : [QUERY] = {
4162 : : .name = "query",
4163 : : .help = "query an existing flow rule",
4164 : : .next = NEXT(next_query_attr, NEXT_ENTRY(QUERY_ACTION),
4165 : : NEXT_ENTRY(COMMON_RULE_ID),
4166 : : NEXT_ENTRY(COMMON_PORT_ID)),
4167 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.query.action.type),
4168 : : ARGS_ENTRY(struct buffer, args.query.rule),
4169 : : ARGS_ENTRY(struct buffer, port)),
4170 : : .call = parse_query,
4171 : : },
4172 : : [LIST] = {
4173 : : .name = "list",
4174 : : .help = "list existing flow rules",
4175 : : .next = NEXT(next_list_attr, NEXT_ENTRY(COMMON_PORT_ID)),
4176 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
4177 : : .call = parse_list,
4178 : : },
4179 : : [AGED] = {
4180 : : .name = "aged",
4181 : : .help = "list and destroy aged flows",
4182 : : .next = NEXT(next_aged_attr, NEXT_ENTRY(COMMON_PORT_ID)),
4183 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
4184 : : .call = parse_aged,
4185 : : },
4186 : : [ISOLATE] = {
4187 : : .name = "isolate",
4188 : : .help = "restrict ingress traffic to the defined flow rules",
4189 : : .next = NEXT(NEXT_ENTRY(COMMON_BOOLEAN),
4190 : : NEXT_ENTRY(COMMON_PORT_ID)),
4191 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.isolate.set),
4192 : : ARGS_ENTRY(struct buffer, port)),
4193 : : .call = parse_isolate,
4194 : : },
4195 : : [FLEX] = {
4196 : : .name = "flex_item",
4197 : : .help = "flex item API",
4198 : : .next = NEXT(next_flex_item),
4199 : : .call = parse_flex,
4200 : : },
4201 : : [FLEX_ITEM_CREATE] = {
4202 : : .name = "create",
4203 : : .help = "flex item create",
4204 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.flex.filename),
4205 : : ARGS_ENTRY(struct buffer, args.flex.token),
4206 : : ARGS_ENTRY(struct buffer, port)),
4207 : : .next = NEXT(NEXT_ENTRY(COMMON_FILE_PATH),
4208 : : NEXT_ENTRY(COMMON_FLEX_TOKEN),
4209 : : NEXT_ENTRY(COMMON_PORT_ID)),
4210 : : .call = parse_flex
4211 : : },
4212 : : [FLEX_ITEM_DESTROY] = {
4213 : : .name = "destroy",
4214 : : .help = "flex item destroy",
4215 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.flex.token),
4216 : : ARGS_ENTRY(struct buffer, port)),
4217 : : .next = NEXT(NEXT_ENTRY(COMMON_FLEX_TOKEN),
4218 : : NEXT_ENTRY(COMMON_PORT_ID)),
4219 : : .call = parse_flex
4220 : : },
4221 : : [TUNNEL] = {
4222 : : .name = "tunnel",
4223 : : .help = "new tunnel API",
4224 : : .next = NEXT(NEXT_ENTRY
4225 : : (TUNNEL_CREATE, TUNNEL_LIST, TUNNEL_DESTROY)),
4226 : : .call = parse_tunnel,
4227 : : },
4228 : : /* Tunnel arguments. */
4229 : : [TUNNEL_CREATE] = {
4230 : : .name = "create",
4231 : : .help = "create new tunnel object",
4232 : : .next = NEXT(NEXT_ENTRY(TUNNEL_CREATE_TYPE),
4233 : : NEXT_ENTRY(COMMON_PORT_ID)),
4234 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
4235 : : .call = parse_tunnel,
4236 : : },
4237 : : [TUNNEL_CREATE_TYPE] = {
4238 : : .name = "type",
4239 : : .help = "create new tunnel",
4240 : : .next = NEXT(NEXT_ENTRY(COMMON_FILE_PATH)),
4241 : : .args = ARGS(ARGS_ENTRY(struct tunnel_ops, type)),
4242 : : .call = parse_tunnel,
4243 : : },
4244 : : [TUNNEL_DESTROY] = {
4245 : : .name = "destroy",
4246 : : .help = "destroy tunnel",
4247 : : .next = NEXT(NEXT_ENTRY(TUNNEL_DESTROY_ID),
4248 : : NEXT_ENTRY(COMMON_PORT_ID)),
4249 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
4250 : : .call = parse_tunnel,
4251 : : },
4252 : : [TUNNEL_DESTROY_ID] = {
4253 : : .name = "id",
4254 : : .help = "tunnel identifier to destroy",
4255 : : .next = NEXT(NEXT_ENTRY(COMMON_UNSIGNED)),
4256 : : .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
4257 : : .call = parse_tunnel,
4258 : : },
4259 : : [TUNNEL_LIST] = {
4260 : : .name = "list",
4261 : : .help = "list existing tunnels",
4262 : : .next = NEXT(NEXT_ENTRY(COMMON_PORT_ID)),
4263 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
4264 : : .call = parse_tunnel,
4265 : : },
4266 : : /* Destroy arguments. */
4267 : : [DESTROY_RULE] = {
4268 : : .name = "rule",
4269 : : .help = "specify a rule identifier",
4270 : : .next = NEXT(next_destroy_attr, NEXT_ENTRY(COMMON_RULE_ID)),
4271 : : .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.destroy.rule)),
4272 : : .call = parse_destroy,
4273 : : },
4274 : : [DESTROY_IS_USER_ID] = {
4275 : : .name = "user_id",
4276 : : .help = "rule identifier is user-id",
4277 : : .next = NEXT(next_destroy_attr),
4278 : : .call = parse_destroy,
4279 : : },
4280 : : /* Dump arguments. */
4281 : : [DUMP_ALL] = {
4282 : : .name = "all",
4283 : : .help = "dump all",
4284 : : .next = NEXT(next_dump_attr),
4285 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file)),
4286 : : .call = parse_dump,
4287 : : },
4288 : : [DUMP_ONE] = {
4289 : : .name = "rule",
4290 : : .help = "dump one rule",
4291 : : .next = NEXT(next_dump_attr, NEXT_ENTRY(COMMON_RULE_ID)),
4292 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file),
4293 : : ARGS_ENTRY(struct buffer, args.dump.rule)),
4294 : : .call = parse_dump,
4295 : : },
4296 : : [DUMP_IS_USER_ID] = {
4297 : : .name = "user_id",
4298 : : .help = "rule identifier is user-id",
4299 : : .next = NEXT(next_dump_subcmd),
4300 : : .call = parse_dump,
4301 : : },
4302 : : [DUMP_FILE_PATH] = {
4303 : : .name = "{file path}",
4304 : : .type = "STRING",
4305 : : .help = "file path",
4306 : : .next = NEXT(NEXT_ENTRY(DUMP_WRITE, DUMP_APPEND, END)),
4307 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file)),
4308 : : .call = parse_string0,
4309 : : .comp = comp_none,
4310 : : },
4311 : : [DUMP_WRITE] = {
4312 : : .name = "write",
4313 : : .help = "open file in write mode (default)",
4314 : : .next = NEXT(NEXT_ENTRY(END)),
4315 : : .call = parse_dump,
4316 : : },
4317 : : [DUMP_APPEND] = {
4318 : : .name = "append",
4319 : : .help = "open file in append mode",
4320 : : .next = NEXT(NEXT_ENTRY(END)),
4321 : : .call = parse_dump,
4322 : : },
4323 : : /* Query arguments. */
4324 : : [QUERY_ACTION] = {
4325 : : .name = "{action}",
4326 : : .type = "ACTION",
4327 : : .help = "action to query, must be part of the rule",
4328 : : .call = parse_action,
4329 : : .comp = comp_action,
4330 : : },
4331 : : [QUERY_IS_USER_ID] = {
4332 : : .name = "user_id",
4333 : : .help = "rule identifier is user-id",
4334 : : .next = NEXT(next_query_attr),
4335 : : .call = parse_query,
4336 : : },
4337 : : /* List arguments. */
4338 : : [LIST_GROUP] = {
4339 : : .name = "group",
4340 : : .help = "specify a group",
4341 : : .next = NEXT(next_list_attr, NEXT_ENTRY(COMMON_GROUP_ID)),
4342 : : .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.list.group)),
4343 : : .call = parse_list,
4344 : : },
4345 : : [AGED_DESTROY] = {
4346 : : .name = "destroy",
4347 : : .help = "specify aged flows need be destroyed",
4348 : : .call = parse_aged,
4349 : : .comp = comp_none,
4350 : : },
4351 : : /* Validate/create attributes. */
4352 : : [VC_GROUP] = {
4353 : : .name = "group",
4354 : : .help = "specify a group",
4355 : : .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_GROUP_ID)),
4356 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, group)),
4357 : : .call = parse_vc,
4358 : : },
4359 : : [VC_PRIORITY] = {
4360 : : .name = "priority",
4361 : : .help = "specify a priority level",
4362 : : .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_PRIORITY_LEVEL)),
4363 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, priority)),
4364 : : .call = parse_vc,
4365 : : },
4366 : : [VC_INGRESS] = {
4367 : : .name = "ingress",
4368 : : .help = "affect rule to ingress",
4369 : : .next = NEXT(next_vc_attr),
4370 : : .call = parse_vc,
4371 : : },
4372 : : [VC_EGRESS] = {
4373 : : .name = "egress",
4374 : : .help = "affect rule to egress",
4375 : : .next = NEXT(next_vc_attr),
4376 : : .call = parse_vc,
4377 : : },
4378 : : [VC_TRANSFER] = {
4379 : : .name = "transfer",
4380 : : .help = "apply rule directly to endpoints found in pattern",
4381 : : .next = NEXT(next_vc_attr),
4382 : : .call = parse_vc,
4383 : : },
4384 : : [VC_TUNNEL_SET] = {
4385 : : .name = "tunnel_set",
4386 : : .help = "tunnel steer rule",
4387 : : .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_UNSIGNED)),
4388 : : .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
4389 : : .call = parse_vc,
4390 : : },
4391 : : [VC_TUNNEL_MATCH] = {
4392 : : .name = "tunnel_match",
4393 : : .help = "tunnel match rule",
4394 : : .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_UNSIGNED)),
4395 : : .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
4396 : : .call = parse_vc,
4397 : : },
4398 : : [VC_USER_ID] = {
4399 : : .name = "user_id",
4400 : : .help = "specify a user id to create",
4401 : : .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_UNSIGNED)),
4402 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.user_id)),
4403 : : .call = parse_vc,
4404 : : },
4405 : : [VC_IS_USER_ID] = {
4406 : : .name = "user_id",
4407 : : .help = "rule identifier is user-id",
4408 : : .call = parse_vc,
4409 : : },
4410 : : /* Validate/create pattern. */
4411 : : [ITEM_PATTERN] = {
4412 : : .name = "pattern",
4413 : : .help = "submit a list of pattern items",
4414 : : .next = NEXT(next_item),
4415 : : .call = parse_vc,
4416 : : },
4417 : : [ITEM_PARAM_IS] = {
4418 : : .name = "is",
4419 : : .help = "match value perfectly (with full bit-mask)",
4420 : : .call = parse_vc_spec,
4421 : : },
4422 : : [ITEM_PARAM_SPEC] = {
4423 : : .name = "spec",
4424 : : .help = "match value according to configured bit-mask",
4425 : : .call = parse_vc_spec,
4426 : : },
4427 : : [ITEM_PARAM_LAST] = {
4428 : : .name = "last",
4429 : : .help = "specify upper bound to establish a range",
4430 : : .call = parse_vc_spec,
4431 : : },
4432 : : [ITEM_PARAM_MASK] = {
4433 : : .name = "mask",
4434 : : .help = "specify bit-mask with relevant bits set to one",
4435 : : .call = parse_vc_spec,
4436 : : },
4437 : : [ITEM_PARAM_PREFIX] = {
4438 : : .name = "prefix",
4439 : : .help = "generate bit-mask from a prefix length",
4440 : : .call = parse_vc_spec,
4441 : : },
4442 : : [ITEM_NEXT] = {
4443 : : .name = "/",
4444 : : .help = "specify next pattern item",
4445 : : .next = NEXT(next_item),
4446 : : },
4447 : : [ITEM_END] = {
4448 : : .name = "end",
4449 : : .help = "end list of pattern items",
4450 : : .priv = PRIV_ITEM(END, 0),
4451 : : .next = NEXT(NEXT_ENTRY(ACTIONS, END)),
4452 : : .call = parse_vc,
4453 : : },
4454 : : [ITEM_VOID] = {
4455 : : .name = "void",
4456 : : .help = "no-op pattern item",
4457 : : .priv = PRIV_ITEM(VOID, 0),
4458 : : .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
4459 : : .call = parse_vc,
4460 : : },
4461 : : [ITEM_INVERT] = {
4462 : : .name = "invert",
4463 : : .help = "perform actions when pattern does not match",
4464 : : .priv = PRIV_ITEM(INVERT, 0),
4465 : : .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
4466 : : .call = parse_vc,
4467 : : },
4468 : : [ITEM_ANY] = {
4469 : : .name = "any",
4470 : : .help = "match any protocol for the current layer",
4471 : : .priv = PRIV_ITEM(ANY, sizeof(struct rte_flow_item_any)),
4472 : : .next = NEXT(item_any),
4473 : : .call = parse_vc,
4474 : : },
4475 : : [ITEM_ANY_NUM] = {
4476 : : .name = "num",
4477 : : .help = "number of layers covered",
4478 : : .next = NEXT(item_any, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
4479 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_any, num)),
4480 : : },
4481 : : [ITEM_PORT_ID] = {
4482 : : .name = "port_id",
4483 : : .help = "match traffic from/to a given DPDK port ID",
4484 : : .priv = PRIV_ITEM(PORT_ID,
4485 : : sizeof(struct rte_flow_item_port_id)),
4486 : : .next = NEXT(item_port_id),
4487 : : .call = parse_vc,
4488 : : },
4489 : : [ITEM_PORT_ID_ID] = {
4490 : : .name = "id",
4491 : : .help = "DPDK port ID",
4492 : : .next = NEXT(item_port_id, NEXT_ENTRY(COMMON_UNSIGNED),
4493 : : item_param),
4494 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port_id, id)),
4495 : : },
4496 : : [ITEM_MARK] = {
4497 : : .name = "mark",
4498 : : .help = "match traffic against value set in previously matched rule",
4499 : : .priv = PRIV_ITEM(MARK, sizeof(struct rte_flow_item_mark)),
4500 : : .next = NEXT(item_mark),
4501 : : .call = parse_vc,
4502 : : },
4503 : : [ITEM_MARK_ID] = {
4504 : : .name = "id",
4505 : : .help = "Integer value to match against",
4506 : : .next = NEXT(item_mark, NEXT_ENTRY(COMMON_UNSIGNED),
4507 : : item_param),
4508 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_mark, id)),
4509 : : },
4510 : : [ITEM_RAW] = {
4511 : : .name = "raw",
4512 : : .help = "match an arbitrary byte string",
4513 : : .priv = PRIV_ITEM(RAW, ITEM_RAW_SIZE),
4514 : : .next = NEXT(item_raw),
4515 : : .call = parse_vc,
4516 : : },
4517 : : [ITEM_RAW_RELATIVE] = {
4518 : : .name = "relative",
4519 : : .help = "look for pattern after the previous item",
4520 : : .next = NEXT(item_raw, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
4521 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
4522 : : relative, 1)),
4523 : : },
4524 : : [ITEM_RAW_SEARCH] = {
4525 : : .name = "search",
4526 : : .help = "search pattern from offset (see also limit)",
4527 : : .next = NEXT(item_raw, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
4528 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
4529 : : search, 1)),
4530 : : },
4531 : : [ITEM_RAW_OFFSET] = {
4532 : : .name = "offset",
4533 : : .help = "absolute or relative offset for pattern",
4534 : : .next = NEXT(item_raw, NEXT_ENTRY(COMMON_INTEGER), item_param),
4535 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, offset)),
4536 : : },
4537 : : [ITEM_RAW_LIMIT] = {
4538 : : .name = "limit",
4539 : : .help = "search area limit for start of pattern",
4540 : : .next = NEXT(item_raw, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
4541 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, limit)),
4542 : : },
4543 : : [ITEM_RAW_PATTERN] = {
4544 : : .name = "pattern",
4545 : : .help = "byte string to look for",
4546 : : .next = NEXT(item_raw,
4547 : : NEXT_ENTRY(COMMON_STRING),
4548 : : NEXT_ENTRY(ITEM_PARAM_IS,
4549 : : ITEM_PARAM_SPEC,
4550 : : ITEM_PARAM_MASK)),
4551 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern),
4552 : : ARGS_ENTRY(struct rte_flow_item_raw, length),
4553 : : ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw),
4554 : : ITEM_RAW_PATTERN_SIZE)),
4555 : : },
4556 : : [ITEM_RAW_PATTERN_HEX] = {
4557 : : .name = "pattern_hex",
4558 : : .help = "hex string to look for",
4559 : : .next = NEXT(item_raw,
4560 : : NEXT_ENTRY(COMMON_HEX),
4561 : : NEXT_ENTRY(ITEM_PARAM_IS,
4562 : : ITEM_PARAM_SPEC,
4563 : : ITEM_PARAM_MASK)),
4564 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern),
4565 : : ARGS_ENTRY(struct rte_flow_item_raw, length),
4566 : : ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw),
4567 : : ITEM_RAW_PATTERN_SIZE)),
4568 : : },
4569 : : [ITEM_ETH] = {
4570 : : .name = "eth",
4571 : : .help = "match Ethernet header",
4572 : : .priv = PRIV_ITEM(ETH, sizeof(struct rte_flow_item_eth)),
4573 : : .next = NEXT(item_eth),
4574 : : .call = parse_vc,
4575 : : },
4576 : : [ITEM_ETH_DST] = {
4577 : : .name = "dst",
4578 : : .help = "destination MAC",
4579 : : .next = NEXT(item_eth, NEXT_ENTRY(COMMON_MAC_ADDR), item_param),
4580 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, hdr.dst_addr)),
4581 : : },
4582 : : [ITEM_ETH_SRC] = {
4583 : : .name = "src",
4584 : : .help = "source MAC",
4585 : : .next = NEXT(item_eth, NEXT_ENTRY(COMMON_MAC_ADDR), item_param),
4586 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, hdr.src_addr)),
4587 : : },
4588 : : [ITEM_ETH_TYPE] = {
4589 : : .name = "type",
4590 : : .help = "EtherType",
4591 : : .next = NEXT(item_eth, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
4592 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, hdr.ether_type)),
4593 : : },
4594 : : [ITEM_ETH_HAS_VLAN] = {
4595 : : .name = "has_vlan",
4596 : : .help = "packet header contains VLAN",
4597 : : .next = NEXT(item_eth, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
4598 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_eth,
4599 : : has_vlan, 1)),
4600 : : },
4601 : : [ITEM_VLAN] = {
4602 : : .name = "vlan",
4603 : : .help = "match 802.1Q/ad VLAN tag",
4604 : : .priv = PRIV_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)),
4605 : : .next = NEXT(item_vlan),
4606 : : .call = parse_vc,
4607 : : },
4608 : : [ITEM_VLAN_TCI] = {
4609 : : .name = "tci",
4610 : : .help = "tag control information",
4611 : : .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
4612 : : item_param),
4613 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, hdr.vlan_tci)),
4614 : : },
4615 : : [ITEM_VLAN_PCP] = {
4616 : : .name = "pcp",
4617 : : .help = "priority code point",
4618 : : .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
4619 : : item_param),
4620 : : .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
4621 : : hdr.vlan_tci, "\xe0\x00")),
4622 : : },
4623 : : [ITEM_VLAN_DEI] = {
4624 : : .name = "dei",
4625 : : .help = "drop eligible indicator",
4626 : : .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
4627 : : item_param),
4628 : : .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
4629 : : hdr.vlan_tci, "\x10\x00")),
4630 : : },
4631 : : [ITEM_VLAN_VID] = {
4632 : : .name = "vid",
4633 : : .help = "VLAN identifier",
4634 : : .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
4635 : : item_param),
4636 : : .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
4637 : : hdr.vlan_tci, "\x0f\xff")),
4638 : : },
4639 : : [ITEM_VLAN_INNER_TYPE] = {
4640 : : .name = "inner_type",
4641 : : .help = "inner EtherType",
4642 : : .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
4643 : : item_param),
4644 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan,
4645 : : hdr.eth_proto)),
4646 : : },
4647 : : [ITEM_VLAN_HAS_MORE_VLAN] = {
4648 : : .name = "has_more_vlan",
4649 : : .help = "packet header contains another VLAN",
4650 : : .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
4651 : : item_param),
4652 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vlan,
4653 : : has_more_vlan, 1)),
4654 : : },
4655 : : [ITEM_IPV4] = {
4656 : : .name = "ipv4",
4657 : : .help = "match IPv4 header",
4658 : : .priv = PRIV_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)),
4659 : : .next = NEXT(item_ipv4),
4660 : : .call = parse_vc,
4661 : : },
4662 : : [ITEM_IPV4_VER_IHL] = {
4663 : : .name = "version_ihl",
4664 : : .help = "match header length",
4665 : : .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
4666 : : item_param),
4667 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ipv4,
4668 : : hdr.version_ihl)),
4669 : : },
4670 : : [ITEM_IPV4_TOS] = {
4671 : : .name = "tos",
4672 : : .help = "type of service",
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.type_of_service)),
4677 : : },
4678 : : [ITEM_IPV4_LENGTH] = {
4679 : : .name = "length",
4680 : : .help = "total length",
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.total_length)),
4685 : : },
4686 : : [ITEM_IPV4_ID] = {
4687 : : .name = "packet_id",
4688 : : .help = "fragment packet 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.packet_id)),
4693 : : },
4694 : : [ITEM_IPV4_FRAGMENT_OFFSET] = {
4695 : : .name = "fragment_offset",
4696 : : .help = "fragmentation flags and fragment offset",
4697 : : .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
4698 : : item_param),
4699 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
4700 : : hdr.fragment_offset)),
4701 : : },
4702 : : [ITEM_IPV4_TTL] = {
4703 : : .name = "ttl",
4704 : : .help = "time to live",
4705 : : .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
4706 : : item_param),
4707 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
4708 : : hdr.time_to_live)),
4709 : : },
4710 : : [ITEM_IPV4_PROTO] = {
4711 : : .name = "proto",
4712 : : .help = "next protocol ID",
4713 : : .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
4714 : : item_param),
4715 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
4716 : : hdr.next_proto_id)),
4717 : : },
4718 : : [ITEM_IPV4_SRC] = {
4719 : : .name = "src",
4720 : : .help = "source address",
4721 : : .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
4722 : : item_param),
4723 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
4724 : : hdr.src_addr)),
4725 : : },
4726 : : [ITEM_IPV4_DST] = {
4727 : : .name = "dst",
4728 : : .help = "destination address",
4729 : : .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
4730 : : item_param),
4731 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
4732 : : hdr.dst_addr)),
4733 : : },
4734 : : [ITEM_IPV6] = {
4735 : : .name = "ipv6",
4736 : : .help = "match IPv6 header",
4737 : : .priv = PRIV_ITEM(IPV6, sizeof(struct rte_flow_item_ipv6)),
4738 : : .next = NEXT(item_ipv6),
4739 : : .call = parse_vc,
4740 : : },
4741 : : [ITEM_IPV6_TC] = {
4742 : : .name = "tc",
4743 : : .help = "traffic class",
4744 : : .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
4745 : : item_param),
4746 : : .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
4747 : : hdr.vtc_flow,
4748 : : "\x0f\xf0\x00\x00")),
4749 : : },
4750 : : [ITEM_IPV6_FLOW] = {
4751 : : .name = "flow",
4752 : : .help = "flow label",
4753 : : .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
4754 : : item_param),
4755 : : .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
4756 : : hdr.vtc_flow,
4757 : : "\x00\x0f\xff\xff")),
4758 : : },
4759 : : [ITEM_IPV6_LEN] = {
4760 : : .name = "length",
4761 : : .help = "payload length",
4762 : : .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
4763 : : item_param),
4764 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
4765 : : hdr.payload_len)),
4766 : : },
4767 : : [ITEM_IPV6_PROTO] = {
4768 : : .name = "proto",
4769 : : .help = "protocol (next header)",
4770 : : .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
4771 : : item_param),
4772 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
4773 : : hdr.proto)),
4774 : : },
4775 : : [ITEM_IPV6_HOP] = {
4776 : : .name = "hop",
4777 : : .help = "hop limit",
4778 : : .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
4779 : : item_param),
4780 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
4781 : : hdr.hop_limits)),
4782 : : },
4783 : : [ITEM_IPV6_SRC] = {
4784 : : .name = "src",
4785 : : .help = "source address",
4786 : : .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_IPV6_ADDR),
4787 : : item_param),
4788 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
4789 : : hdr.src_addr)),
4790 : : },
4791 : : [ITEM_IPV6_DST] = {
4792 : : .name = "dst",
4793 : : .help = "destination address",
4794 : : .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_IPV6_ADDR),
4795 : : item_param),
4796 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
4797 : : hdr.dst_addr)),
4798 : : },
4799 : : [ITEM_IPV6_HAS_FRAG_EXT] = {
4800 : : .name = "has_frag_ext",
4801 : : .help = "fragment packet attribute",
4802 : : .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
4803 : : item_param),
4804 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_ipv6,
4805 : : has_frag_ext, 1)),
4806 : : },
4807 : : [ITEM_IPV6_ROUTING_EXT] = {
4808 : : .name = "ipv6_routing_ext",
4809 : : .help = "match IPv6 routing extension header",
4810 : : .priv = PRIV_ITEM(IPV6_ROUTING_EXT,
4811 : : sizeof(struct rte_flow_item_ipv6_routing_ext)),
4812 : : .next = NEXT(item_ipv6_routing_ext),
4813 : : .call = parse_vc,
4814 : : },
4815 : : [ITEM_IPV6_ROUTING_EXT_TYPE] = {
4816 : : .name = "ext_type",
4817 : : .help = "match IPv6 routing extension header type",
4818 : : .next = NEXT(item_ipv6_routing_ext, NEXT_ENTRY(COMMON_UNSIGNED),
4819 : : item_param),
4820 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_routing_ext,
4821 : : hdr.type)),
4822 : : },
4823 : : [ITEM_IPV6_ROUTING_EXT_NEXT_HDR] = {
4824 : : .name = "ext_next_hdr",
4825 : : .help = "match IPv6 routing extension header next header type",
4826 : : .next = NEXT(item_ipv6_routing_ext, NEXT_ENTRY(COMMON_UNSIGNED),
4827 : : item_param),
4828 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_routing_ext,
4829 : : hdr.next_hdr)),
4830 : : },
4831 : : [ITEM_IPV6_ROUTING_EXT_SEG_LEFT] = {
4832 : : .name = "ext_seg_left",
4833 : : .help = "match IPv6 routing extension header segment left",
4834 : : .next = NEXT(item_ipv6_routing_ext, NEXT_ENTRY(COMMON_UNSIGNED),
4835 : : item_param),
4836 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_routing_ext,
4837 : : hdr.segments_left)),
4838 : : },
4839 : : [ITEM_ICMP] = {
4840 : : .name = "icmp",
4841 : : .help = "match ICMP header",
4842 : : .priv = PRIV_ITEM(ICMP, sizeof(struct rte_flow_item_icmp)),
4843 : : .next = NEXT(item_icmp),
4844 : : .call = parse_vc,
4845 : : },
4846 : : [ITEM_ICMP_TYPE] = {
4847 : : .name = "type",
4848 : : .help = "ICMP packet type",
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_type)),
4853 : : },
4854 : : [ITEM_ICMP_CODE] = {
4855 : : .name = "code",
4856 : : .help = "ICMP packet code",
4857 : : .next = NEXT(item_icmp, NEXT_ENTRY(COMMON_UNSIGNED),
4858 : : item_param),
4859 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
4860 : : hdr.icmp_code)),
4861 : : },
4862 : : [ITEM_ICMP_IDENT] = {
4863 : : .name = "ident",
4864 : : .help = "ICMP packet identifier",
4865 : : .next = NEXT(item_icmp, NEXT_ENTRY(COMMON_UNSIGNED),
4866 : : item_param),
4867 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
4868 : : hdr.icmp_ident)),
4869 : : },
4870 : : [ITEM_ICMP_SEQ] = {
4871 : : .name = "seq",
4872 : : .help = "ICMP packet sequence number",
4873 : : .next = NEXT(item_icmp, NEXT_ENTRY(COMMON_UNSIGNED),
4874 : : item_param),
4875 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
4876 : : hdr.icmp_seq_nb)),
4877 : : },
4878 : : [ITEM_UDP] = {
4879 : : .name = "udp",
4880 : : .help = "match UDP header",
4881 : : .priv = PRIV_ITEM(UDP, sizeof(struct rte_flow_item_udp)),
4882 : : .next = NEXT(item_udp),
4883 : : .call = parse_vc,
4884 : : },
4885 : : [ITEM_UDP_SRC] = {
4886 : : .name = "src",
4887 : : .help = "UDP source port",
4888 : : .next = NEXT(item_udp, NEXT_ENTRY(COMMON_UNSIGNED),
4889 : : item_param),
4890 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
4891 : : hdr.src_port)),
4892 : : },
4893 : : [ITEM_UDP_DST] = {
4894 : : .name = "dst",
4895 : : .help = "UDP destination port",
4896 : : .next = NEXT(item_udp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
4897 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
4898 : : hdr.dst_port)),
4899 : : },
4900 : : [ITEM_TCP] = {
4901 : : .name = "tcp",
4902 : : .help = "match TCP header",
4903 : : .priv = PRIV_ITEM(TCP, sizeof(struct rte_flow_item_tcp)),
4904 : : .next = NEXT(item_tcp),
4905 : : .call = parse_vc,
4906 : : },
4907 : : [ITEM_TCP_SRC] = {
4908 : : .name = "src",
4909 : : .help = "TCP source port",
4910 : : .next = NEXT(item_tcp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
4911 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
4912 : : hdr.src_port)),
4913 : : },
4914 : : [ITEM_TCP_DST] = {
4915 : : .name = "dst",
4916 : : .help = "TCP destination port",
4917 : : .next = NEXT(item_tcp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
4918 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
4919 : : hdr.dst_port)),
4920 : : },
4921 : : [ITEM_TCP_FLAGS] = {
4922 : : .name = "flags",
4923 : : .help = "TCP flags",
4924 : : .next = NEXT(item_tcp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
4925 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
4926 : : hdr.tcp_flags)),
4927 : : },
4928 : : [ITEM_SCTP] = {
4929 : : .name = "sctp",
4930 : : .help = "match SCTP header",
4931 : : .priv = PRIV_ITEM(SCTP, sizeof(struct rte_flow_item_sctp)),
4932 : : .next = NEXT(item_sctp),
4933 : : .call = parse_vc,
4934 : : },
4935 : : [ITEM_SCTP_SRC] = {
4936 : : .name = "src",
4937 : : .help = "SCTP source port",
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.src_port)),
4942 : : },
4943 : : [ITEM_SCTP_DST] = {
4944 : : .name = "dst",
4945 : : .help = "SCTP destination port",
4946 : : .next = NEXT(item_sctp, NEXT_ENTRY(COMMON_UNSIGNED),
4947 : : item_param),
4948 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
4949 : : hdr.dst_port)),
4950 : : },
4951 : : [ITEM_SCTP_TAG] = {
4952 : : .name = "tag",
4953 : : .help = "validation tag",
4954 : : .next = NEXT(item_sctp, NEXT_ENTRY(COMMON_UNSIGNED),
4955 : : item_param),
4956 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
4957 : : hdr.tag)),
4958 : : },
4959 : : [ITEM_SCTP_CKSUM] = {
4960 : : .name = "cksum",
4961 : : .help = "checksum",
4962 : : .next = NEXT(item_sctp, NEXT_ENTRY(COMMON_UNSIGNED),
4963 : : item_param),
4964 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
4965 : : hdr.cksum)),
4966 : : },
4967 : : [ITEM_VXLAN] = {
4968 : : .name = "vxlan",
4969 : : .help = "match VXLAN header",
4970 : : .priv = PRIV_ITEM(VXLAN, sizeof(struct rte_flow_item_vxlan)),
4971 : : .next = NEXT(item_vxlan),
4972 : : .call = parse_vc,
4973 : : },
4974 : : [ITEM_VXLAN_VNI] = {
4975 : : .name = "vni",
4976 : : .help = "VXLAN identifier",
4977 : : .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
4978 : : item_param),
4979 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan, hdr.vni)),
4980 : : },
4981 : : [ITEM_VXLAN_FLAG_G] = {
4982 : : .name = "flag_g",
4983 : : .help = "VXLAN GBP 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_g, 1)),
4988 : : },
4989 : : [ITEM_VXLAN_FLAG_VER] = {
4990 : : .name = "flag_ver",
4991 : : .help = "VXLAN GPE version",
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_ver, 2)),
4996 : : },
4997 : : [ITEM_VXLAN_FLAG_I] = {
4998 : : .name = "flag_i",
4999 : : .help = "VXLAN Instance 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_i, 1)),
5004 : : },
5005 : : [ITEM_VXLAN_FLAG_P] = {
5006 : : .name = "flag_p",
5007 : : .help = "VXLAN GPE Next Protocol 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_p, 1)),
5012 : : },
5013 : : [ITEM_VXLAN_FLAG_B] = {
5014 : : .name = "flag_b",
5015 : : .help = "VXLAN GPE Ingress-Replicated BUM",
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_b, 1)),
5020 : : },
5021 : : [ITEM_VXLAN_FLAG_O] = {
5022 : : .name = "flag_o",
5023 : : .help = "VXLAN GPE OAM Packet bit",
5024 : : .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
5025 : : item_param),
5026 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vxlan,
5027 : : hdr.flag_o, 1)),
5028 : : },
5029 : : [ITEM_VXLAN_FLAG_D] = {
5030 : : .name = "flag_d",
5031 : : .help = "VXLAN GBP Don't Learn bit",
5032 : : .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
5033 : : item_param),
5034 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vxlan,
5035 : : hdr.flag_d, 1)),
5036 : : },
5037 : : [ITEM_VXLAN_FLAG_A] = {
5038 : : .name = "flag_a",
5039 : : .help = "VXLAN GBP Applied bit",
5040 : : .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
5041 : : item_param),
5042 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vxlan,
5043 : : hdr.flag_a, 1)),
5044 : : },
5045 : : [ITEM_VXLAN_GBP_ID] = {
5046 : : .name = "group_policy_id",
5047 : : .help = "VXLAN GBP ID",
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.policy_id)),
5052 : : },
5053 : : [ITEM_VXLAN_GPE_PROTO] = {
5054 : : .name = "protocol",
5055 : : .help = "VXLAN GPE next protocol",
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.proto)),
5060 : : },
5061 : : [ITEM_VXLAN_FIRST_RSVD] = {
5062 : : .name = "first_rsvd",
5063 : : .help = "VXLAN rsvd0 first 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.rsvd0[0])),
5068 : : },
5069 : : [ITEM_VXLAN_SECND_RSVD] = {
5070 : : .name = "second_rsvd",
5071 : : .help = "VXLAN rsvd0 second byte",
5072 : : .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
5073 : : item_param),
5074 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan,
5075 : : hdr.rsvd0[1])),
5076 : : },
5077 : : [ITEM_VXLAN_THIRD_RSVD] = {
5078 : : .name = "third_rsvd",
5079 : : .help = "VXLAN rsvd0 third byte",
5080 : : .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
5081 : : item_param),
5082 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan,
5083 : : hdr.rsvd0[2])),
5084 : : },
5085 : : [ITEM_VXLAN_LAST_RSVD] = {
5086 : : .name = "last_rsvd",
5087 : : .help = "VXLAN last reserved byte",
5088 : : .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
5089 : : item_param),
5090 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan,
5091 : : hdr.last_rsvd)),
5092 : : },
5093 : : [ITEM_E_TAG] = {
5094 : : .name = "e_tag",
5095 : : .help = "match E-Tag header",
5096 : : .priv = PRIV_ITEM(E_TAG, sizeof(struct rte_flow_item_e_tag)),
5097 : : .next = NEXT(item_e_tag),
5098 : : .call = parse_vc,
5099 : : },
5100 : : [ITEM_E_TAG_GRP_ECID_B] = {
5101 : : .name = "grp_ecid_b",
5102 : : .help = "GRP and E-CID base",
5103 : : .next = NEXT(item_e_tag, NEXT_ENTRY(COMMON_UNSIGNED),
5104 : : item_param),
5105 : : .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_e_tag,
5106 : : rsvd_grp_ecid_b,
5107 : : "\x3f\xff")),
5108 : : },
5109 : : [ITEM_NVGRE] = {
5110 : : .name = "nvgre",
5111 : : .help = "match NVGRE header",
5112 : : .priv = PRIV_ITEM(NVGRE, sizeof(struct rte_flow_item_nvgre)),
5113 : : .next = NEXT(item_nvgre),
5114 : : .call = parse_vc,
5115 : : },
5116 : : [ITEM_NVGRE_TNI] = {
5117 : : .name = "tni",
5118 : : .help = "virtual subnet ID",
5119 : : .next = NEXT(item_nvgre, NEXT_ENTRY(COMMON_UNSIGNED),
5120 : : item_param),
5121 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_nvgre, tni)),
5122 : : },
5123 : : [ITEM_MPLS] = {
5124 : : .name = "mpls",
5125 : : .help = "match MPLS header",
5126 : : .priv = PRIV_ITEM(MPLS, sizeof(struct rte_flow_item_mpls)),
5127 : : .next = NEXT(item_mpls),
5128 : : .call = parse_vc,
5129 : : },
5130 : : [ITEM_MPLS_LABEL] = {
5131 : : .name = "label",
5132 : : .help = "MPLS label",
5133 : : .next = NEXT(item_mpls, NEXT_ENTRY(COMMON_UNSIGNED),
5134 : : item_param),
5135 : : .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
5136 : : label_tc_s,
5137 : : "\xff\xff\xf0")),
5138 : : },
5139 : : [ITEM_MPLS_TC] = {
5140 : : .name = "tc",
5141 : : .help = "MPLS Traffic Class",
5142 : : .next = NEXT(item_mpls, NEXT_ENTRY(COMMON_UNSIGNED),
5143 : : item_param),
5144 : : .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
5145 : : label_tc_s,
5146 : : "\x00\x00\x0e")),
5147 : : },
5148 : : [ITEM_MPLS_S] = {
5149 : : .name = "s",
5150 : : .help = "MPLS Bottom-of-Stack",
5151 : : .next = NEXT(item_mpls, NEXT_ENTRY(COMMON_UNSIGNED),
5152 : : item_param),
5153 : : .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
5154 : : label_tc_s,
5155 : : "\x00\x00\x01")),
5156 : : },
5157 : : [ITEM_MPLS_TTL] = {
5158 : : .name = "ttl",
5159 : : .help = "MPLS Time-to-Live",
5160 : : .next = NEXT(item_mpls, NEXT_ENTRY(COMMON_UNSIGNED),
5161 : : item_param),
5162 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_mpls, ttl)),
5163 : : },
5164 : : [ITEM_GRE] = {
5165 : : .name = "gre",
5166 : : .help = "match GRE header",
5167 : : .priv = PRIV_ITEM(GRE, sizeof(struct rte_flow_item_gre)),
5168 : : .next = NEXT(item_gre),
5169 : : .call = parse_vc,
5170 : : },
5171 : : [ITEM_GRE_PROTO] = {
5172 : : .name = "protocol",
5173 : : .help = "GRE protocol type",
5174 : : .next = NEXT(item_gre, NEXT_ENTRY(COMMON_UNSIGNED),
5175 : : item_param),
5176 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
5177 : : protocol)),
5178 : : },
5179 : : [ITEM_GRE_C_RSVD0_VER] = {
5180 : : .name = "c_rsvd0_ver",
5181 : : .help =
5182 : : "checksum (1b), undefined (1b), key bit (1b),"
5183 : : " sequence number (1b), reserved 0 (9b),"
5184 : : " version (3b)",
5185 : : .next = NEXT(item_gre, NEXT_ENTRY(COMMON_UNSIGNED),
5186 : : item_param),
5187 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
5188 : : c_rsvd0_ver)),
5189 : : },
5190 : : [ITEM_GRE_C_BIT] = {
5191 : : .name = "c_bit",
5192 : : .help = "checksum bit (C)",
5193 : : .next = NEXT(item_gre, NEXT_ENTRY(COMMON_BOOLEAN),
5194 : : item_param),
5195 : : .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
5196 : : c_rsvd0_ver,
5197 : : "\x80\x00\x00\x00")),
5198 : : },
5199 : : [ITEM_GRE_S_BIT] = {
5200 : : .name = "s_bit",
5201 : : .help = "sequence number bit (S)",
5202 : : .next = NEXT(item_gre, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
5203 : : .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
5204 : : c_rsvd0_ver,
5205 : : "\x10\x00\x00\x00")),
5206 : : },
5207 : : [ITEM_GRE_K_BIT] = {
5208 : : .name = "k_bit",
5209 : : .help = "key bit (K)",
5210 : : .next = NEXT(item_gre, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
5211 : : .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
5212 : : c_rsvd0_ver,
5213 : : "\x20\x00\x00\x00")),
5214 : : },
5215 : : [ITEM_FUZZY] = {
5216 : : .name = "fuzzy",
5217 : : .help = "fuzzy pattern match, expect faster than default",
5218 : : .priv = PRIV_ITEM(FUZZY,
5219 : : sizeof(struct rte_flow_item_fuzzy)),
5220 : : .next = NEXT(item_fuzzy),
5221 : : .call = parse_vc,
5222 : : },
5223 : : [ITEM_FUZZY_THRESH] = {
5224 : : .name = "thresh",
5225 : : .help = "match accuracy threshold",
5226 : : .next = NEXT(item_fuzzy, NEXT_ENTRY(COMMON_UNSIGNED),
5227 : : item_param),
5228 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_fuzzy,
5229 : : thresh)),
5230 : : },
5231 : : [ITEM_GTP] = {
5232 : : .name = "gtp",
5233 : : .help = "match GTP header",
5234 : : .priv = PRIV_ITEM(GTP, sizeof(struct rte_flow_item_gtp)),
5235 : : .next = NEXT(item_gtp),
5236 : : .call = parse_vc,
5237 : : },
5238 : : [ITEM_GTP_FLAGS] = {
5239 : : .name = "v_pt_rsv_flags",
5240 : : .help = "GTP flags",
5241 : : .next = NEXT(item_gtp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
5242 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp,
5243 : : hdr.gtp_hdr_info)),
5244 : : },
5245 : : [ITEM_GTP_MSG_TYPE] = {
5246 : : .name = "msg_type",
5247 : : .help = "GTP message type",
5248 : : .next = NEXT(item_gtp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
5249 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp, hdr.msg_type)),
5250 : : },
5251 : : [ITEM_GTP_TEID] = {
5252 : : .name = "teid",
5253 : : .help = "tunnel endpoint identifier",
5254 : : .next = NEXT(item_gtp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
5255 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp, hdr.teid)),
5256 : : },
5257 : : [ITEM_GTPC] = {
5258 : : .name = "gtpc",
5259 : : .help = "match GTP header",
5260 : : .priv = PRIV_ITEM(GTPC, sizeof(struct rte_flow_item_gtp)),
5261 : : .next = NEXT(item_gtp),
5262 : : .call = parse_vc,
5263 : : },
5264 : : [ITEM_GTPU] = {
5265 : : .name = "gtpu",
5266 : : .help = "match GTP header",
5267 : : .priv = PRIV_ITEM(GTPU, sizeof(struct rte_flow_item_gtp)),
5268 : : .next = NEXT(item_gtp),
5269 : : .call = parse_vc,
5270 : : },
5271 : : [ITEM_GENEVE] = {
5272 : : .name = "geneve",
5273 : : .help = "match GENEVE header",
5274 : : .priv = PRIV_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)),
5275 : : .next = NEXT(item_geneve),
5276 : : .call = parse_vc,
5277 : : },
5278 : : [ITEM_GENEVE_VNI] = {
5279 : : .name = "vni",
5280 : : .help = "virtual network identifier",
5281 : : .next = NEXT(item_geneve, NEXT_ENTRY(COMMON_UNSIGNED),
5282 : : item_param),
5283 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve, vni)),
5284 : : },
5285 : : [ITEM_GENEVE_PROTO] = {
5286 : : .name = "protocol",
5287 : : .help = "GENEVE protocol type",
5288 : : .next = NEXT(item_geneve, NEXT_ENTRY(COMMON_UNSIGNED),
5289 : : item_param),
5290 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve,
5291 : : protocol)),
5292 : : },
5293 : : [ITEM_GENEVE_OPTLEN] = {
5294 : : .name = "optlen",
5295 : : .help = "GENEVE options length in dwords",
5296 : : .next = NEXT(item_geneve, NEXT_ENTRY(COMMON_UNSIGNED),
5297 : : item_param),
5298 : : .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_geneve,
5299 : : ver_opt_len_o_c_rsvd0,
5300 : : "\x3f\x00")),
5301 : : },
5302 : : [ITEM_VXLAN_GPE] = {
5303 : : .name = "vxlan-gpe",
5304 : : .help = "match VXLAN-GPE header",
5305 : : .priv = PRIV_ITEM(VXLAN_GPE,
5306 : : sizeof(struct rte_flow_item_vxlan_gpe)),
5307 : : .next = NEXT(item_vxlan_gpe),
5308 : : .call = parse_vc,
5309 : : },
5310 : : [ITEM_VXLAN_GPE_VNI] = {
5311 : : .name = "vni",
5312 : : .help = "VXLAN-GPE identifier",
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 : : hdr.vni)),
5317 : : },
5318 : : [ITEM_VXLAN_GPE_PROTO_IN_DEPRECATED_VXLAN_GPE_HDR] = {
5319 : : .name = "protocol",
5320 : : .help = "VXLAN-GPE next protocol",
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 : : protocol)),
5325 : : },
5326 : : [ITEM_VXLAN_GPE_FLAGS] = {
5327 : : .name = "flags",
5328 : : .help = "VXLAN-GPE flags",
5329 : : .next = NEXT(item_vxlan_gpe, NEXT_ENTRY(COMMON_UNSIGNED),
5330 : : item_param),
5331 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
5332 : : flags)),
5333 : : },
5334 : : [ITEM_VXLAN_GPE_RSVD0] = {
5335 : : .name = "rsvd0",
5336 : : .help = "VXLAN-GPE rsvd0",
5337 : : .next = NEXT(item_vxlan_gpe, NEXT_ENTRY(COMMON_UNSIGNED),
5338 : : item_param),
5339 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
5340 : : rsvd0)),
5341 : : },
5342 : : [ITEM_VXLAN_GPE_RSVD1] = {
5343 : : .name = "rsvd1",
5344 : : .help = "VXLAN-GPE rsvd1",
5345 : : .next = NEXT(item_vxlan_gpe, NEXT_ENTRY(COMMON_UNSIGNED),
5346 : : item_param),
5347 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
5348 : : rsvd1)),
5349 : : },
5350 : : [ITEM_ARP_ETH_IPV4] = {
5351 : : .name = "arp_eth_ipv4",
5352 : : .help = "match ARP header for Ethernet/IPv4",
5353 : : .priv = PRIV_ITEM(ARP_ETH_IPV4,
5354 : : sizeof(struct rte_flow_item_arp_eth_ipv4)),
5355 : : .next = NEXT(item_arp_eth_ipv4),
5356 : : .call = parse_vc,
5357 : : },
5358 : : [ITEM_ARP_ETH_IPV4_SHA] = {
5359 : : .name = "sha",
5360 : : .help = "sender hardware address",
5361 : : .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_MAC_ADDR),
5362 : : item_param),
5363 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
5364 : : hdr.arp_data.arp_sha)),
5365 : : },
5366 : : [ITEM_ARP_ETH_IPV4_SPA] = {
5367 : : .name = "spa",
5368 : : .help = "sender IPv4 address",
5369 : : .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
5370 : : item_param),
5371 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
5372 : : hdr.arp_data.arp_sip)),
5373 : : },
5374 : : [ITEM_ARP_ETH_IPV4_THA] = {
5375 : : .name = "tha",
5376 : : .help = "target hardware address",
5377 : : .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_MAC_ADDR),
5378 : : item_param),
5379 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
5380 : : hdr.arp_data.arp_tha)),
5381 : : },
5382 : : [ITEM_ARP_ETH_IPV4_TPA] = {
5383 : : .name = "tpa",
5384 : : .help = "target IPv4 address",
5385 : : .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
5386 : : item_param),
5387 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
5388 : : hdr.arp_data.arp_tip)),
5389 : : },
5390 : : [ITEM_IPV6_EXT] = {
5391 : : .name = "ipv6_ext",
5392 : : .help = "match presence of any IPv6 extension header",
5393 : : .priv = PRIV_ITEM(IPV6_EXT,
5394 : : sizeof(struct rte_flow_item_ipv6_ext)),
5395 : : .next = NEXT(item_ipv6_ext),
5396 : : .call = parse_vc,
5397 : : },
5398 : : [ITEM_IPV6_EXT_NEXT_HDR] = {
5399 : : .name = "next_hdr",
5400 : : .help = "next header",
5401 : : .next = NEXT(item_ipv6_ext, NEXT_ENTRY(COMMON_UNSIGNED),
5402 : : item_param),
5403 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_ext,
5404 : : next_hdr)),
5405 : : },
5406 : : [ITEM_IPV6_FRAG_EXT] = {
5407 : : .name = "ipv6_frag_ext",
5408 : : .help = "match presence of IPv6 fragment extension header",
5409 : : .priv = PRIV_ITEM(IPV6_FRAG_EXT,
5410 : : sizeof(struct rte_flow_item_ipv6_frag_ext)),
5411 : : .next = NEXT(item_ipv6_frag_ext),
5412 : : .call = parse_vc,
5413 : : },
5414 : : [ITEM_IPV6_FRAG_EXT_NEXT_HDR] = {
5415 : : .name = "next_hdr",
5416 : : .help = "next header",
5417 : : .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(COMMON_UNSIGNED),
5418 : : item_param),
5419 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ipv6_frag_ext,
5420 : : hdr.next_header)),
5421 : : },
5422 : : [ITEM_IPV6_FRAG_EXT_FRAG_DATA] = {
5423 : : .name = "frag_data",
5424 : : .help = "fragment flags and offset",
5425 : : .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(COMMON_UNSIGNED),
5426 : : item_param),
5427 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_frag_ext,
5428 : : hdr.frag_data)),
5429 : : },
5430 : : [ITEM_IPV6_FRAG_EXT_ID] = {
5431 : : .name = "packet_id",
5432 : : .help = "fragment packet id",
5433 : : .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(COMMON_UNSIGNED),
5434 : : item_param),
5435 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_frag_ext,
5436 : : hdr.id)),
5437 : : },
5438 : : [ITEM_ICMP6] = {
5439 : : .name = "icmp6",
5440 : : .help = "match any ICMPv6 header",
5441 : : .priv = PRIV_ITEM(ICMP6, sizeof(struct rte_flow_item_icmp6)),
5442 : : .next = NEXT(item_icmp6),
5443 : : .call = parse_vc,
5444 : : },
5445 : : [ITEM_ICMP6_TYPE] = {
5446 : : .name = "type",
5447 : : .help = "ICMPv6 type",
5448 : : .next = NEXT(item_icmp6, NEXT_ENTRY(COMMON_UNSIGNED),
5449 : : item_param),
5450 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
5451 : : type)),
5452 : : },
5453 : : [ITEM_ICMP6_CODE] = {
5454 : : .name = "code",
5455 : : .help = "ICMPv6 code",
5456 : : .next = NEXT(item_icmp6, NEXT_ENTRY(COMMON_UNSIGNED),
5457 : : item_param),
5458 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
5459 : : code)),
5460 : : },
5461 : : [ITEM_ICMP6_ECHO_REQUEST] = {
5462 : : .name = "icmp6_echo_request",
5463 : : .help = "match ICMPv6 echo request",
5464 : : .priv = PRIV_ITEM(ICMP6_ECHO_REQUEST,
5465 : : sizeof(struct rte_flow_item_icmp6_echo)),
5466 : : .next = NEXT(item_icmp6_echo_request),
5467 : : .call = parse_vc,
5468 : : },
5469 : : [ITEM_ICMP6_ECHO_REQUEST_ID] = {
5470 : : .name = "ident",
5471 : : .help = "ICMPv6 echo request identifier",
5472 : : .next = NEXT(item_icmp6_echo_request, 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_REQUEST_SEQ] = {
5478 : : .name = "seq",
5479 : : .help = "ICMPv6 echo request sequence",
5480 : : .next = NEXT(item_icmp6_echo_request, 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_ECHO_REPLY] = {
5486 : : .name = "icmp6_echo_reply",
5487 : : .help = "match ICMPv6 echo reply",
5488 : : .priv = PRIV_ITEM(ICMP6_ECHO_REPLY,
5489 : : sizeof(struct rte_flow_item_icmp6_echo)),
5490 : : .next = NEXT(item_icmp6_echo_reply),
5491 : : .call = parse_vc,
5492 : : },
5493 : : [ITEM_ICMP6_ECHO_REPLY_ID] = {
5494 : : .name = "ident",
5495 : : .help = "ICMPv6 echo reply identifier",
5496 : : .next = NEXT(item_icmp6_echo_reply, NEXT_ENTRY(COMMON_UNSIGNED),
5497 : : item_param),
5498 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_echo,
5499 : : hdr.identifier)),
5500 : : },
5501 : : [ITEM_ICMP6_ECHO_REPLY_SEQ] = {
5502 : : .name = "seq",
5503 : : .help = "ICMPv6 echo reply sequence",
5504 : : .next = NEXT(item_icmp6_echo_reply, NEXT_ENTRY(COMMON_UNSIGNED),
5505 : : item_param),
5506 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_echo,
5507 : : hdr.sequence)),
5508 : : },
5509 : : [ITEM_ICMP6_ND_NS] = {
5510 : : .name = "icmp6_nd_ns",
5511 : : .help = "match ICMPv6 neighbor discovery solicitation",
5512 : : .priv = PRIV_ITEM(ICMP6_ND_NS,
5513 : : sizeof(struct rte_flow_item_icmp6_nd_ns)),
5514 : : .next = NEXT(item_icmp6_nd_ns),
5515 : : .call = parse_vc,
5516 : : },
5517 : : [ITEM_ICMP6_ND_NS_TARGET_ADDR] = {
5518 : : .name = "target_addr",
5519 : : .help = "target address",
5520 : : .next = NEXT(item_icmp6_nd_ns, NEXT_ENTRY(COMMON_IPV6_ADDR),
5521 : : item_param),
5522 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_ns,
5523 : : target_addr)),
5524 : : },
5525 : : [ITEM_ICMP6_ND_NA] = {
5526 : : .name = "icmp6_nd_na",
5527 : : .help = "match ICMPv6 neighbor discovery advertisement",
5528 : : .priv = PRIV_ITEM(ICMP6_ND_NA,
5529 : : sizeof(struct rte_flow_item_icmp6_nd_na)),
5530 : : .next = NEXT(item_icmp6_nd_na),
5531 : : .call = parse_vc,
5532 : : },
5533 : : [ITEM_ICMP6_ND_NA_TARGET_ADDR] = {
5534 : : .name = "target_addr",
5535 : : .help = "target address",
5536 : : .next = NEXT(item_icmp6_nd_na, NEXT_ENTRY(COMMON_IPV6_ADDR),
5537 : : item_param),
5538 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_na,
5539 : : target_addr)),
5540 : : },
5541 : : [ITEM_ICMP6_ND_OPT] = {
5542 : : .name = "icmp6_nd_opt",
5543 : : .help = "match presence of any ICMPv6 neighbor discovery"
5544 : : " option",
5545 : : .priv = PRIV_ITEM(ICMP6_ND_OPT,
5546 : : sizeof(struct rte_flow_item_icmp6_nd_opt)),
5547 : : .next = NEXT(item_icmp6_nd_opt),
5548 : : .call = parse_vc,
5549 : : },
5550 : : [ITEM_ICMP6_ND_OPT_TYPE] = {
5551 : : .name = "type",
5552 : : .help = "ND option type",
5553 : : .next = NEXT(item_icmp6_nd_opt, NEXT_ENTRY(COMMON_UNSIGNED),
5554 : : item_param),
5555 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_opt,
5556 : : type)),
5557 : : },
5558 : : [ITEM_ICMP6_ND_OPT_SLA_ETH] = {
5559 : : .name = "icmp6_nd_opt_sla_eth",
5560 : : .help = "match ICMPv6 neighbor discovery source Ethernet"
5561 : : " link-layer address option",
5562 : : .priv = PRIV_ITEM
5563 : : (ICMP6_ND_OPT_SLA_ETH,
5564 : : sizeof(struct rte_flow_item_icmp6_nd_opt_sla_eth)),
5565 : : .next = NEXT(item_icmp6_nd_opt_sla_eth),
5566 : : .call = parse_vc,
5567 : : },
5568 : : [ITEM_ICMP6_ND_OPT_SLA_ETH_SLA] = {
5569 : : .name = "sla",
5570 : : .help = "source Ethernet LLA",
5571 : : .next = NEXT(item_icmp6_nd_opt_sla_eth,
5572 : : NEXT_ENTRY(COMMON_MAC_ADDR), item_param),
5573 : : .args = ARGS(ARGS_ENTRY_HTON
5574 : : (struct rte_flow_item_icmp6_nd_opt_sla_eth, sla)),
5575 : : },
5576 : : [ITEM_ICMP6_ND_OPT_TLA_ETH] = {
5577 : : .name = "icmp6_nd_opt_tla_eth",
5578 : : .help = "match ICMPv6 neighbor discovery target Ethernet"
5579 : : " link-layer address option",
5580 : : .priv = PRIV_ITEM
5581 : : (ICMP6_ND_OPT_TLA_ETH,
5582 : : sizeof(struct rte_flow_item_icmp6_nd_opt_tla_eth)),
5583 : : .next = NEXT(item_icmp6_nd_opt_tla_eth),
5584 : : .call = parse_vc,
5585 : : },
5586 : : [ITEM_ICMP6_ND_OPT_TLA_ETH_TLA] = {
5587 : : .name = "tla",
5588 : : .help = "target Ethernet LLA",
5589 : : .next = NEXT(item_icmp6_nd_opt_tla_eth,
5590 : : NEXT_ENTRY(COMMON_MAC_ADDR), item_param),
5591 : : .args = ARGS(ARGS_ENTRY_HTON
5592 : : (struct rte_flow_item_icmp6_nd_opt_tla_eth, tla)),
5593 : : },
5594 : : [ITEM_META] = {
5595 : : .name = "meta",
5596 : : .help = "match metadata header",
5597 : : .priv = PRIV_ITEM(META, sizeof(struct rte_flow_item_meta)),
5598 : : .next = NEXT(item_meta),
5599 : : .call = parse_vc,
5600 : : },
5601 : : [ITEM_META_DATA] = {
5602 : : .name = "data",
5603 : : .help = "metadata value",
5604 : : .next = NEXT(item_meta, NEXT_ENTRY(COMMON_UNSIGNED),
5605 : : item_param),
5606 : : .args = ARGS(ARGS_ENTRY_MASK(struct rte_flow_item_meta,
5607 : : data, "\xff\xff\xff\xff")),
5608 : : },
5609 : : [ITEM_RANDOM] = {
5610 : : .name = "random",
5611 : : .help = "match random value",
5612 : : .priv = PRIV_ITEM(RANDOM, sizeof(struct rte_flow_item_random)),
5613 : : .next = NEXT(item_random),
5614 : : .call = parse_vc,
5615 : : },
5616 : : [ITEM_RANDOM_VALUE] = {
5617 : : .name = "value",
5618 : : .help = "random value",
5619 : : .next = NEXT(item_random, NEXT_ENTRY(COMMON_UNSIGNED),
5620 : : item_param),
5621 : : .args = ARGS(ARGS_ENTRY_MASK(struct rte_flow_item_random,
5622 : : value, "\xff\xff\xff\xff")),
5623 : : },
5624 : : [ITEM_GRE_KEY] = {
5625 : : .name = "gre_key",
5626 : : .help = "match GRE key",
5627 : : .priv = PRIV_ITEM(GRE_KEY, sizeof(rte_be32_t)),
5628 : : .next = NEXT(item_gre_key),
5629 : : .call = parse_vc,
5630 : : },
5631 : : [ITEM_GRE_KEY_VALUE] = {
5632 : : .name = "value",
5633 : : .help = "key value",
5634 : : .next = NEXT(item_gre_key, NEXT_ENTRY(COMMON_UNSIGNED),
5635 : : item_param),
5636 : : .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
5637 : : },
5638 : : [ITEM_GRE_OPTION] = {
5639 : : .name = "gre_option",
5640 : : .help = "match GRE optional fields",
5641 : : .priv = PRIV_ITEM(GRE_OPTION,
5642 : : sizeof(struct rte_flow_item_gre_opt)),
5643 : : .next = NEXT(item_gre_option),
5644 : : .call = parse_vc,
5645 : : },
5646 : : [ITEM_GRE_OPTION_CHECKSUM] = {
5647 : : .name = "checksum",
5648 : : .help = "match GRE checksum",
5649 : : .next = NEXT(item_gre_option, NEXT_ENTRY(COMMON_UNSIGNED),
5650 : : item_param),
5651 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre_opt,
5652 : : checksum_rsvd.checksum)),
5653 : : },
5654 : : [ITEM_GRE_OPTION_KEY] = {
5655 : : .name = "key",
5656 : : .help = "match GRE key",
5657 : : .next = NEXT(item_gre_option, NEXT_ENTRY(COMMON_UNSIGNED),
5658 : : item_param),
5659 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre_opt,
5660 : : key.key)),
5661 : : },
5662 : : [ITEM_GRE_OPTION_SEQUENCE] = {
5663 : : .name = "sequence",
5664 : : .help = "match GRE sequence",
5665 : : .next = NEXT(item_gre_option, NEXT_ENTRY(COMMON_UNSIGNED),
5666 : : item_param),
5667 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre_opt,
5668 : : sequence.sequence)),
5669 : : },
5670 : : [ITEM_GTP_PSC] = {
5671 : : .name = "gtp_psc",
5672 : : .help = "match GTP extension header with type 0x85",
5673 : : .priv = PRIV_ITEM(GTP_PSC,
5674 : : sizeof(struct rte_flow_item_gtp_psc)),
5675 : : .next = NEXT(item_gtp_psc),
5676 : : .call = parse_vc,
5677 : : },
5678 : : [ITEM_GTP_PSC_QFI] = {
5679 : : .name = "qfi",
5680 : : .help = "QoS flow identifier",
5681 : : .next = NEXT(item_gtp_psc, NEXT_ENTRY(COMMON_UNSIGNED),
5682 : : item_param),
5683 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_gtp_psc,
5684 : : hdr.qfi, 6)),
5685 : : },
5686 : : [ITEM_GTP_PSC_PDU_T] = {
5687 : : .name = "pdu_t",
5688 : : .help = "PDU type",
5689 : : .next = NEXT(item_gtp_psc, NEXT_ENTRY(COMMON_UNSIGNED),
5690 : : item_param),
5691 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_gtp_psc,
5692 : : hdr.type, 4)),
5693 : : },
5694 : : [ITEM_PPPOES] = {
5695 : : .name = "pppoes",
5696 : : .help = "match PPPoE session header",
5697 : : .priv = PRIV_ITEM(PPPOES, sizeof(struct rte_flow_item_pppoe)),
5698 : : .next = NEXT(item_pppoes),
5699 : : .call = parse_vc,
5700 : : },
5701 : : [ITEM_PPPOED] = {
5702 : : .name = "pppoed",
5703 : : .help = "match PPPoE discovery header",
5704 : : .priv = PRIV_ITEM(PPPOED, sizeof(struct rte_flow_item_pppoe)),
5705 : : .next = NEXT(item_pppoed),
5706 : : .call = parse_vc,
5707 : : },
5708 : : [ITEM_PPPOE_SEID] = {
5709 : : .name = "seid",
5710 : : .help = "session identifier",
5711 : : .next = NEXT(item_pppoes, NEXT_ENTRY(COMMON_UNSIGNED),
5712 : : item_param),
5713 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pppoe,
5714 : : session_id)),
5715 : : },
5716 : : [ITEM_PPPOE_PROTO_ID] = {
5717 : : .name = "pppoe_proto_id",
5718 : : .help = "match PPPoE session protocol identifier",
5719 : : .priv = PRIV_ITEM(PPPOE_PROTO_ID,
5720 : : sizeof(struct rte_flow_item_pppoe_proto_id)),
5721 : : .next = NEXT(item_pppoe_proto_id, NEXT_ENTRY(COMMON_UNSIGNED),
5722 : : item_param),
5723 : : .args = ARGS(ARGS_ENTRY_HTON
5724 : : (struct rte_flow_item_pppoe_proto_id, proto_id)),
5725 : : .call = parse_vc,
5726 : : },
5727 : : [ITEM_HIGIG2] = {
5728 : : .name = "higig2",
5729 : : .help = "matches higig2 header",
5730 : : .priv = PRIV_ITEM(HIGIG2,
5731 : : sizeof(struct rte_flow_item_higig2_hdr)),
5732 : : .next = NEXT(item_higig2),
5733 : : .call = parse_vc,
5734 : : },
5735 : : [ITEM_HIGIG2_CLASSIFICATION] = {
5736 : : .name = "classification",
5737 : : .help = "matches classification of higig2 header",
5738 : : .next = NEXT(item_higig2, NEXT_ENTRY(COMMON_UNSIGNED),
5739 : : item_param),
5740 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
5741 : : hdr.ppt1.classification)),
5742 : : },
5743 : : [ITEM_HIGIG2_VID] = {
5744 : : .name = "vid",
5745 : : .help = "matches vid of higig2 header",
5746 : : .next = NEXT(item_higig2, NEXT_ENTRY(COMMON_UNSIGNED),
5747 : : item_param),
5748 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
5749 : : hdr.ppt1.vid)),
5750 : : },
5751 : : [ITEM_TAG] = {
5752 : : .name = "tag",
5753 : : .help = "match tag value",
5754 : : .priv = PRIV_ITEM(TAG, sizeof(struct rte_flow_item_tag)),
5755 : : .next = NEXT(item_tag),
5756 : : .call = parse_vc,
5757 : : },
5758 : : [ITEM_TAG_DATA] = {
5759 : : .name = "data",
5760 : : .help = "tag value to match",
5761 : : .next = NEXT(item_tag, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
5762 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, data)),
5763 : : },
5764 : : [ITEM_TAG_INDEX] = {
5765 : : .name = "index",
5766 : : .help = "index of tag array to match",
5767 : : .next = NEXT(item_tag, NEXT_ENTRY(COMMON_UNSIGNED),
5768 : : NEXT_ENTRY(ITEM_PARAM_IS)),
5769 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, index)),
5770 : : },
5771 : : [ITEM_L2TPV3OIP] = {
5772 : : .name = "l2tpv3oip",
5773 : : .help = "match L2TPv3 over IP header",
5774 : : .priv = PRIV_ITEM(L2TPV3OIP,
5775 : : sizeof(struct rte_flow_item_l2tpv3oip)),
5776 : : .next = NEXT(item_l2tpv3oip),
5777 : : .call = parse_vc,
5778 : : },
5779 : : [ITEM_L2TPV3OIP_SESSION_ID] = {
5780 : : .name = "session_id",
5781 : : .help = "session identifier",
5782 : : .next = NEXT(item_l2tpv3oip, NEXT_ENTRY(COMMON_UNSIGNED),
5783 : : item_param),
5784 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv3oip,
5785 : : session_id)),
5786 : : },
5787 : : [ITEM_ESP] = {
5788 : : .name = "esp",
5789 : : .help = "match ESP header",
5790 : : .priv = PRIV_ITEM(ESP, sizeof(struct rte_flow_item_esp)),
5791 : : .next = NEXT(item_esp),
5792 : : .call = parse_vc,
5793 : : },
5794 : : [ITEM_ESP_SPI] = {
5795 : : .name = "spi",
5796 : : .help = "security policy index",
5797 : : .next = NEXT(item_esp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
5798 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_esp,
5799 : : hdr.spi)),
5800 : : },
5801 : : [ITEM_AH] = {
5802 : : .name = "ah",
5803 : : .help = "match AH header",
5804 : : .priv = PRIV_ITEM(AH, sizeof(struct rte_flow_item_ah)),
5805 : : .next = NEXT(item_ah),
5806 : : .call = parse_vc,
5807 : : },
5808 : : [ITEM_AH_SPI] = {
5809 : : .name = "spi",
5810 : : .help = "security parameters index",
5811 : : .next = NEXT(item_ah, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
5812 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ah, spi)),
5813 : : },
5814 : : [ITEM_PFCP] = {
5815 : : .name = "pfcp",
5816 : : .help = "match pfcp header",
5817 : : .priv = PRIV_ITEM(PFCP, sizeof(struct rte_flow_item_pfcp)),
5818 : : .next = NEXT(item_pfcp),
5819 : : .call = parse_vc,
5820 : : },
5821 : : [ITEM_PFCP_S_FIELD] = {
5822 : : .name = "s_field",
5823 : : .help = "S field",
5824 : : .next = NEXT(item_pfcp, NEXT_ENTRY(COMMON_UNSIGNED),
5825 : : item_param),
5826 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp,
5827 : : s_field)),
5828 : : },
5829 : : [ITEM_PFCP_SEID] = {
5830 : : .name = "seid",
5831 : : .help = "session endpoint identifier",
5832 : : .next = NEXT(item_pfcp, NEXT_ENTRY(COMMON_UNSIGNED),
5833 : : item_param),
5834 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp, seid)),
5835 : : },
5836 : : [ITEM_ECPRI] = {
5837 : : .name = "ecpri",
5838 : : .help = "match eCPRI header",
5839 : : .priv = PRIV_ITEM(ECPRI, sizeof(struct rte_flow_item_ecpri)),
5840 : : .next = NEXT(item_ecpri),
5841 : : .call = parse_vc,
5842 : : },
5843 : : [ITEM_ECPRI_COMMON] = {
5844 : : .name = "common",
5845 : : .help = "eCPRI common header",
5846 : : .next = NEXT(item_ecpri_common),
5847 : : },
5848 : : [ITEM_ECPRI_COMMON_TYPE] = {
5849 : : .name = "type",
5850 : : .help = "type of common header",
5851 : : .next = NEXT(item_ecpri_common_type),
5852 : : .args = ARGS(ARG_ENTRY_HTON(struct rte_flow_item_ecpri)),
5853 : : },
5854 : : [ITEM_ECPRI_COMMON_TYPE_IQ_DATA] = {
5855 : : .name = "iq_data",
5856 : : .help = "Type #0: IQ Data",
5857 : : .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
5858 : : ITEM_NEXT)),
5859 : : .call = parse_vc_item_ecpri_type,
5860 : : },
5861 : : [ITEM_ECPRI_MSG_IQ_DATA_PCID] = {
5862 : : .name = "pc_id",
5863 : : .help = "Physical Channel ID",
5864 : : .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
5865 : : ITEM_ECPRI_COMMON, ITEM_NEXT),
5866 : : NEXT_ENTRY(COMMON_UNSIGNED), item_param),
5867 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
5868 : : hdr.type0.pc_id)),
5869 : : },
5870 : : [ITEM_ECPRI_COMMON_TYPE_RTC_CTRL] = {
5871 : : .name = "rtc_ctrl",
5872 : : .help = "Type #2: Real-Time Control Data",
5873 : : .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
5874 : : ITEM_NEXT)),
5875 : : .call = parse_vc_item_ecpri_type,
5876 : : },
5877 : : [ITEM_ECPRI_MSG_RTC_CTRL_RTCID] = {
5878 : : .name = "rtc_id",
5879 : : .help = "Real-Time Control Data ID",
5880 : : .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
5881 : : ITEM_ECPRI_COMMON, ITEM_NEXT),
5882 : : NEXT_ENTRY(COMMON_UNSIGNED), item_param),
5883 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
5884 : : hdr.type2.rtc_id)),
5885 : : },
5886 : : [ITEM_ECPRI_COMMON_TYPE_DLY_MSR] = {
5887 : : .name = "delay_measure",
5888 : : .help = "Type #5: One-Way Delay Measurement",
5889 : : .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
5890 : : ITEM_NEXT)),
5891 : : .call = parse_vc_item_ecpri_type,
5892 : : },
5893 : : [ITEM_ECPRI_MSG_DLY_MSR_MSRID] = {
5894 : : .name = "msr_id",
5895 : : .help = "Measurement ID",
5896 : : .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
5897 : : ITEM_ECPRI_COMMON, ITEM_NEXT),
5898 : : NEXT_ENTRY(COMMON_UNSIGNED), item_param),
5899 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
5900 : : hdr.type5.msr_id)),
5901 : : },
5902 : : [ITEM_GENEVE_OPT] = {
5903 : : .name = "geneve-opt",
5904 : : .help = "GENEVE header option",
5905 : : .priv = PRIV_ITEM(GENEVE_OPT,
5906 : : sizeof(struct rte_flow_item_geneve_opt) +
5907 : : ITEM_GENEVE_OPT_DATA_SIZE),
5908 : : .next = NEXT(item_geneve_opt),
5909 : : .call = parse_vc,
5910 : : },
5911 : : [ITEM_GENEVE_OPT_CLASS] = {
5912 : : .name = "class",
5913 : : .help = "GENEVE option class",
5914 : : .next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_UNSIGNED),
5915 : : item_param),
5916 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve_opt,
5917 : : option_class)),
5918 : : },
5919 : : [ITEM_GENEVE_OPT_TYPE] = {
5920 : : .name = "type",
5921 : : .help = "GENEVE option type",
5922 : : .next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_UNSIGNED),
5923 : : item_param),
5924 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt,
5925 : : option_type)),
5926 : : },
5927 : : [ITEM_GENEVE_OPT_LENGTH] = {
5928 : : .name = "length",
5929 : : .help = "GENEVE option data length (in 32b words)",
5930 : : .next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_UNSIGNED),
5931 : : item_param),
5932 : : .args = ARGS(ARGS_ENTRY_BOUNDED(
5933 : : struct rte_flow_item_geneve_opt, option_len,
5934 : : 0, 31)),
5935 : : },
5936 : : [ITEM_GENEVE_OPT_DATA] = {
5937 : : .name = "data",
5938 : : .help = "GENEVE option data pattern",
5939 : : .next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_HEX),
5940 : : item_param),
5941 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt, data),
5942 : : ARGS_ENTRY_ARB(0, 0),
5943 : : ARGS_ENTRY_ARB
5944 : : (sizeof(struct rte_flow_item_geneve_opt),
5945 : : ITEM_GENEVE_OPT_DATA_SIZE)),
5946 : : },
5947 : : [ITEM_INTEGRITY] = {
5948 : : .name = "integrity",
5949 : : .help = "match packet integrity",
5950 : : .priv = PRIV_ITEM(INTEGRITY,
5951 : : sizeof(struct rte_flow_item_integrity)),
5952 : : .next = NEXT(item_integrity),
5953 : : .call = parse_vc,
5954 : : },
5955 : : [ITEM_INTEGRITY_LEVEL] = {
5956 : : .name = "level",
5957 : : .help = "integrity level",
5958 : : .next = NEXT(item_integrity_lv, NEXT_ENTRY(COMMON_UNSIGNED),
5959 : : item_param),
5960 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_integrity, level)),
5961 : : },
5962 : : [ITEM_INTEGRITY_VALUE] = {
5963 : : .name = "value",
5964 : : .help = "integrity value",
5965 : : .next = NEXT(item_integrity_lv, NEXT_ENTRY(COMMON_UNSIGNED),
5966 : : item_param),
5967 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_integrity, value)),
5968 : : },
5969 : : [ITEM_CONNTRACK] = {
5970 : : .name = "conntrack",
5971 : : .help = "conntrack state",
5972 : : .priv = PRIV_ITEM(CONNTRACK,
5973 : : sizeof(struct rte_flow_item_conntrack)),
5974 : : .next = NEXT(NEXT_ENTRY(ITEM_NEXT), NEXT_ENTRY(COMMON_UNSIGNED),
5975 : : item_param),
5976 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_conntrack, flags)),
5977 : : .call = parse_vc,
5978 : : },
5979 : : [ITEM_PORT_REPRESENTOR] = {
5980 : : .name = "port_representor",
5981 : : .help = "match traffic entering the embedded switch from the given ethdev",
5982 : : .priv = PRIV_ITEM(PORT_REPRESENTOR,
5983 : : sizeof(struct rte_flow_item_ethdev)),
5984 : : .next = NEXT(item_port_representor),
5985 : : .call = parse_vc,
5986 : : },
5987 : : [ITEM_PORT_REPRESENTOR_PORT_ID] = {
5988 : : .name = "port_id",
5989 : : .help = "ethdev port ID",
5990 : : .next = NEXT(item_port_representor, NEXT_ENTRY(COMMON_UNSIGNED),
5991 : : item_param),
5992 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ethdev, port_id)),
5993 : : },
5994 : : [ITEM_REPRESENTED_PORT] = {
5995 : : .name = "represented_port",
5996 : : .help = "match traffic entering the embedded switch from the entity represented by the given ethdev",
5997 : : .priv = PRIV_ITEM(REPRESENTED_PORT,
5998 : : sizeof(struct rte_flow_item_ethdev)),
5999 : : .next = NEXT(item_represented_port),
6000 : : .call = parse_vc,
6001 : : },
6002 : : [ITEM_REPRESENTED_PORT_ETHDEV_PORT_ID] = {
6003 : : .name = "ethdev_port_id",
6004 : : .help = "ethdev port ID",
6005 : : .next = NEXT(item_represented_port, NEXT_ENTRY(COMMON_UNSIGNED),
6006 : : item_param),
6007 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ethdev, port_id)),
6008 : : },
6009 : : [ITEM_FLEX] = {
6010 : : .name = "flex",
6011 : : .help = "match flex header",
6012 : : .priv = PRIV_ITEM(FLEX, sizeof(struct rte_flow_item_flex)),
6013 : : .next = NEXT(item_flex),
6014 : : .call = parse_vc,
6015 : : },
6016 : : [ITEM_FLEX_ITEM_HANDLE] = {
6017 : : .name = "item",
6018 : : .help = "flex item handle",
6019 : : .next = NEXT(item_flex, NEXT_ENTRY(COMMON_FLEX_HANDLE),
6020 : : NEXT_ENTRY(ITEM_PARAM_IS)),
6021 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_flex, handle)),
6022 : : },
6023 : : [ITEM_FLEX_PATTERN_HANDLE] = {
6024 : : .name = "pattern",
6025 : : .help = "flex pattern handle",
6026 : : .next = NEXT(item_flex, NEXT_ENTRY(COMMON_FLEX_HANDLE),
6027 : : NEXT_ENTRY(ITEM_PARAM_IS)),
6028 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_flex, pattern)),
6029 : : },
6030 : : [ITEM_L2TPV2] = {
6031 : : .name = "l2tpv2",
6032 : : .help = "match L2TPv2 header",
6033 : : .priv = PRIV_ITEM(L2TPV2, sizeof(struct rte_flow_item_l2tpv2)),
6034 : : .next = NEXT(item_l2tpv2),
6035 : : .call = parse_vc,
6036 : : },
6037 : : [ITEM_L2TPV2_TYPE] = {
6038 : : .name = "type",
6039 : : .help = "type of l2tpv2",
6040 : : .next = NEXT(item_l2tpv2_type),
6041 : : .args = ARGS(ARG_ENTRY_HTON(struct rte_flow_item_l2tpv2)),
6042 : : },
6043 : : [ITEM_L2TPV2_TYPE_DATA] = {
6044 : : .name = "data",
6045 : : .help = "Type #7: data message without any options",
6046 : : .next = NEXT(item_l2tpv2_type_data),
6047 : : .call = parse_vc_item_l2tpv2_type,
6048 : : },
6049 : : [ITEM_L2TPV2_MSG_DATA_TUNNEL_ID] = {
6050 : : .name = "tunnel_id",
6051 : : .help = "tunnel identifier",
6052 : : .next = NEXT(item_l2tpv2_type_data,
6053 : : NEXT_ENTRY(COMMON_UNSIGNED),
6054 : : item_param),
6055 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6056 : : hdr.type7.tunnel_id)),
6057 : : },
6058 : : [ITEM_L2TPV2_MSG_DATA_SESSION_ID] = {
6059 : : .name = "session_id",
6060 : : .help = "session identifier",
6061 : : .next = NEXT(item_l2tpv2_type_data,
6062 : : NEXT_ENTRY(COMMON_UNSIGNED),
6063 : : item_param),
6064 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6065 : : hdr.type7.session_id)),
6066 : : },
6067 : : [ITEM_L2TPV2_TYPE_DATA_L] = {
6068 : : .name = "data_l",
6069 : : .help = "Type #6: data message with length option",
6070 : : .next = NEXT(item_l2tpv2_type_data_l),
6071 : : .call = parse_vc_item_l2tpv2_type,
6072 : : },
6073 : : [ITEM_L2TPV2_MSG_DATA_L_LENGTH] = {
6074 : : .name = "length",
6075 : : .help = "message length",
6076 : : .next = NEXT(item_l2tpv2_type_data_l,
6077 : : NEXT_ENTRY(COMMON_UNSIGNED),
6078 : : item_param),
6079 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6080 : : hdr.type6.length)),
6081 : : },
6082 : : [ITEM_L2TPV2_MSG_DATA_L_TUNNEL_ID] = {
6083 : : .name = "tunnel_id",
6084 : : .help = "tunnel identifier",
6085 : : .next = NEXT(item_l2tpv2_type_data_l,
6086 : : NEXT_ENTRY(COMMON_UNSIGNED),
6087 : : item_param),
6088 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6089 : : hdr.type6.tunnel_id)),
6090 : : },
6091 : : [ITEM_L2TPV2_MSG_DATA_L_SESSION_ID] = {
6092 : : .name = "session_id",
6093 : : .help = "session identifier",
6094 : : .next = NEXT(item_l2tpv2_type_data_l,
6095 : : NEXT_ENTRY(COMMON_UNSIGNED),
6096 : : item_param),
6097 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6098 : : hdr.type6.session_id)),
6099 : : },
6100 : : [ITEM_L2TPV2_TYPE_DATA_S] = {
6101 : : .name = "data_s",
6102 : : .help = "Type #5: data message with ns, nr option",
6103 : : .next = NEXT(item_l2tpv2_type_data_s),
6104 : : .call = parse_vc_item_l2tpv2_type,
6105 : : },
6106 : : [ITEM_L2TPV2_MSG_DATA_S_TUNNEL_ID] = {
6107 : : .name = "tunnel_id",
6108 : : .help = "tunnel identifier",
6109 : : .next = NEXT(item_l2tpv2_type_data_s,
6110 : : NEXT_ENTRY(COMMON_UNSIGNED),
6111 : : item_param),
6112 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6113 : : hdr.type5.tunnel_id)),
6114 : : },
6115 : : [ITEM_L2TPV2_MSG_DATA_S_SESSION_ID] = {
6116 : : .name = "session_id",
6117 : : .help = "session identifier",
6118 : : .next = NEXT(item_l2tpv2_type_data_s,
6119 : : NEXT_ENTRY(COMMON_UNSIGNED),
6120 : : item_param),
6121 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6122 : : hdr.type5.session_id)),
6123 : : },
6124 : : [ITEM_L2TPV2_MSG_DATA_S_NS] = {
6125 : : .name = "ns",
6126 : : .help = "sequence number for message",
6127 : : .next = NEXT(item_l2tpv2_type_data_s,
6128 : : NEXT_ENTRY(COMMON_UNSIGNED),
6129 : : item_param),
6130 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6131 : : hdr.type5.ns)),
6132 : : },
6133 : : [ITEM_L2TPV2_MSG_DATA_S_NR] = {
6134 : : .name = "nr",
6135 : : .help = "sequence number for next receive message",
6136 : : .next = NEXT(item_l2tpv2_type_data_s,
6137 : : NEXT_ENTRY(COMMON_UNSIGNED),
6138 : : item_param),
6139 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6140 : : hdr.type5.nr)),
6141 : : },
6142 : : [ITEM_L2TPV2_TYPE_DATA_O] = {
6143 : : .name = "data_o",
6144 : : .help = "Type #4: data message with offset option",
6145 : : .next = NEXT(item_l2tpv2_type_data_o),
6146 : : .call = parse_vc_item_l2tpv2_type,
6147 : : },
6148 : : [ITEM_L2TPV2_MSG_DATA_O_TUNNEL_ID] = {
6149 : : .name = "tunnel_id",
6150 : : .help = "tunnel identifier",
6151 : : .next = NEXT(item_l2tpv2_type_data_o,
6152 : : NEXT_ENTRY(COMMON_UNSIGNED),
6153 : : item_param),
6154 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6155 : : hdr.type4.tunnel_id)),
6156 : : },
6157 : : [ITEM_L2TPV2_MSG_DATA_O_SESSION_ID] = {
6158 : : .name = "session_id",
6159 : : .help = "session identifier",
6160 : : .next = NEXT(item_l2tpv2_type_data_o,
6161 : : NEXT_ENTRY(COMMON_UNSIGNED),
6162 : : item_param),
6163 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6164 : : hdr.type5.session_id)),
6165 : : },
6166 : : [ITEM_L2TPV2_MSG_DATA_O_OFFSET] = {
6167 : : .name = "offset_size",
6168 : : .help = "the size of offset padding",
6169 : : .next = NEXT(item_l2tpv2_type_data_o,
6170 : : NEXT_ENTRY(COMMON_UNSIGNED),
6171 : : item_param),
6172 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6173 : : hdr.type4.offset_size)),
6174 : : },
6175 : : [ITEM_L2TPV2_TYPE_DATA_L_S] = {
6176 : : .name = "data_l_s",
6177 : : .help = "Type #3: data message contains length, ns, nr "
6178 : : "options",
6179 : : .next = NEXT(item_l2tpv2_type_data_l_s),
6180 : : .call = parse_vc_item_l2tpv2_type,
6181 : : },
6182 : : [ITEM_L2TPV2_MSG_DATA_L_S_LENGTH] = {
6183 : : .name = "length",
6184 : : .help = "message length",
6185 : : .next = NEXT(item_l2tpv2_type_data_l_s,
6186 : : NEXT_ENTRY(COMMON_UNSIGNED),
6187 : : item_param),
6188 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6189 : : hdr.type3.length)),
6190 : : },
6191 : : [ITEM_L2TPV2_MSG_DATA_L_S_TUNNEL_ID] = {
6192 : : .name = "tunnel_id",
6193 : : .help = "tunnel identifier",
6194 : : .next = NEXT(item_l2tpv2_type_data_l_s,
6195 : : NEXT_ENTRY(COMMON_UNSIGNED),
6196 : : item_param),
6197 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6198 : : hdr.type3.tunnel_id)),
6199 : : },
6200 : : [ITEM_L2TPV2_MSG_DATA_L_S_SESSION_ID] = {
6201 : : .name = "session_id",
6202 : : .help = "session identifier",
6203 : : .next = NEXT(item_l2tpv2_type_data_l_s,
6204 : : NEXT_ENTRY(COMMON_UNSIGNED),
6205 : : item_param),
6206 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6207 : : hdr.type3.session_id)),
6208 : : },
6209 : : [ITEM_L2TPV2_MSG_DATA_L_S_NS] = {
6210 : : .name = "ns",
6211 : : .help = "sequence number for message",
6212 : : .next = NEXT(item_l2tpv2_type_data_l_s,
6213 : : NEXT_ENTRY(COMMON_UNSIGNED),
6214 : : item_param),
6215 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6216 : : hdr.type3.ns)),
6217 : : },
6218 : : [ITEM_L2TPV2_MSG_DATA_L_S_NR] = {
6219 : : .name = "nr",
6220 : : .help = "sequence number for next receive message",
6221 : : .next = NEXT(item_l2tpv2_type_data_l_s,
6222 : : NEXT_ENTRY(COMMON_UNSIGNED),
6223 : : item_param),
6224 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6225 : : hdr.type3.nr)),
6226 : : },
6227 : : [ITEM_L2TPV2_TYPE_CTRL] = {
6228 : : .name = "control",
6229 : : .help = "Type #3: conrtol message contains length, ns, nr "
6230 : : "options",
6231 : : .next = NEXT(item_l2tpv2_type_ctrl),
6232 : : .call = parse_vc_item_l2tpv2_type,
6233 : : },
6234 : : [ITEM_L2TPV2_MSG_CTRL_LENGTH] = {
6235 : : .name = "length",
6236 : : .help = "message length",
6237 : : .next = NEXT(item_l2tpv2_type_ctrl,
6238 : : NEXT_ENTRY(COMMON_UNSIGNED),
6239 : : item_param),
6240 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6241 : : hdr.type3.length)),
6242 : : },
6243 : : [ITEM_L2TPV2_MSG_CTRL_TUNNEL_ID] = {
6244 : : .name = "tunnel_id",
6245 : : .help = "tunnel identifier",
6246 : : .next = NEXT(item_l2tpv2_type_ctrl,
6247 : : NEXT_ENTRY(COMMON_UNSIGNED),
6248 : : item_param),
6249 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6250 : : hdr.type3.tunnel_id)),
6251 : : },
6252 : : [ITEM_L2TPV2_MSG_CTRL_SESSION_ID] = {
6253 : : .name = "session_id",
6254 : : .help = "session identifier",
6255 : : .next = NEXT(item_l2tpv2_type_ctrl,
6256 : : NEXT_ENTRY(COMMON_UNSIGNED),
6257 : : item_param),
6258 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6259 : : hdr.type3.session_id)),
6260 : : },
6261 : : [ITEM_L2TPV2_MSG_CTRL_NS] = {
6262 : : .name = "ns",
6263 : : .help = "sequence number for message",
6264 : : .next = NEXT(item_l2tpv2_type_ctrl,
6265 : : NEXT_ENTRY(COMMON_UNSIGNED),
6266 : : item_param),
6267 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6268 : : hdr.type3.ns)),
6269 : : },
6270 : : [ITEM_L2TPV2_MSG_CTRL_NR] = {
6271 : : .name = "nr",
6272 : : .help = "sequence number for next receive message",
6273 : : .next = NEXT(item_l2tpv2_type_ctrl,
6274 : : NEXT_ENTRY(COMMON_UNSIGNED),
6275 : : item_param),
6276 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6277 : : hdr.type3.nr)),
6278 : : },
6279 : : [ITEM_PPP] = {
6280 : : .name = "ppp",
6281 : : .help = "match PPP header",
6282 : : .priv = PRIV_ITEM(PPP, sizeof(struct rte_flow_item_ppp)),
6283 : : .next = NEXT(item_ppp),
6284 : : .call = parse_vc,
6285 : : },
6286 : : [ITEM_PPP_ADDR] = {
6287 : : .name = "addr",
6288 : : .help = "PPP address",
6289 : : .next = NEXT(item_ppp, NEXT_ENTRY(COMMON_UNSIGNED),
6290 : : item_param),
6291 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ppp, hdr.addr)),
6292 : : },
6293 : : [ITEM_PPP_CTRL] = {
6294 : : .name = "ctrl",
6295 : : .help = "PPP control",
6296 : : .next = NEXT(item_ppp, NEXT_ENTRY(COMMON_UNSIGNED),
6297 : : item_param),
6298 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ppp, hdr.ctrl)),
6299 : : },
6300 : : [ITEM_PPP_PROTO_ID] = {
6301 : : .name = "proto_id",
6302 : : .help = "PPP protocol identifier",
6303 : : .next = NEXT(item_ppp, NEXT_ENTRY(COMMON_UNSIGNED),
6304 : : item_param),
6305 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ppp,
6306 : : hdr.proto_id)),
6307 : : },
6308 : : [ITEM_METER] = {
6309 : : .name = "meter",
6310 : : .help = "match meter color",
6311 : : .priv = PRIV_ITEM(METER_COLOR,
6312 : : sizeof(struct rte_flow_item_meter_color)),
6313 : : .next = NEXT(item_meter),
6314 : : .call = parse_vc,
6315 : : },
6316 : : [ITEM_METER_COLOR] = {
6317 : : .name = "color",
6318 : : .help = "meter color",
6319 : : .next = NEXT(item_meter,
6320 : : NEXT_ENTRY(COMMON_METER_COLOR_NAME),
6321 : : item_param),
6322 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_meter_color,
6323 : : color)),
6324 : : },
6325 : : [ITEM_QUOTA] = {
6326 : : .name = "quota",
6327 : : .help = "match quota",
6328 : : .priv = PRIV_ITEM(QUOTA, sizeof(struct rte_flow_item_quota)),
6329 : : .next = NEXT(item_quota),
6330 : : .call = parse_vc
6331 : : },
6332 : : [ITEM_QUOTA_STATE] = {
6333 : : .name = "quota_state",
6334 : : .help = "quota state",
6335 : : .next = NEXT(item_quota, NEXT_ENTRY(ITEM_QUOTA_STATE_NAME),
6336 : : NEXT_ENTRY(ITEM_PARAM_SPEC, ITEM_PARAM_MASK)),
6337 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_quota, state))
6338 : : },
6339 : : [ITEM_QUOTA_STATE_NAME] = {
6340 : : .name = "state_name",
6341 : : .help = "quota state name",
6342 : : .call = parse_quota_state_name,
6343 : : .comp = comp_quota_state_name
6344 : : },
6345 : : [ITEM_IB_BTH] = {
6346 : : .name = "ib_bth",
6347 : : .help = "match ib bth fields",
6348 : : .priv = PRIV_ITEM(IB_BTH,
6349 : : sizeof(struct rte_flow_item_ib_bth)),
6350 : : .next = NEXT(item_ib_bth),
6351 : : .call = parse_vc,
6352 : : },
6353 : : [ITEM_IB_BTH_OPCODE] = {
6354 : : .name = "opcode",
6355 : : .help = "match ib bth opcode",
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.opcode)),
6360 : : },
6361 : : [ITEM_IB_BTH_PKEY] = {
6362 : : .name = "pkey",
6363 : : .help = "partition key",
6364 : : .next = NEXT(item_ib_bth, NEXT_ENTRY(COMMON_UNSIGNED),
6365 : : item_param),
6366 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ib_bth,
6367 : : hdr.pkey)),
6368 : : },
6369 : : [ITEM_IB_BTH_DST_QPN] = {
6370 : : .name = "dst_qp",
6371 : : .help = "destination qp",
6372 : : .next = NEXT(item_ib_bth, NEXT_ENTRY(COMMON_UNSIGNED),
6373 : : item_param),
6374 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ib_bth,
6375 : : hdr.dst_qp)),
6376 : : },
6377 : : [ITEM_IB_BTH_PSN] = {
6378 : : .name = "psn",
6379 : : .help = "packet sequence number",
6380 : : .next = NEXT(item_ib_bth, NEXT_ENTRY(COMMON_UNSIGNED),
6381 : : item_param),
6382 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ib_bth,
6383 : : hdr.psn)),
6384 : : },
6385 : : [ITEM_PTYPE] = {
6386 : : .name = "ptype",
6387 : : .help = "match L2/L3/L4 and tunnel information",
6388 : : .priv = PRIV_ITEM(PTYPE,
6389 : : sizeof(struct rte_flow_item_ptype)),
6390 : : .next = NEXT(item_ptype),
6391 : : .call = parse_vc,
6392 : : },
6393 : : [ITEM_PTYPE_VALUE] = {
6394 : : .name = "packet_type",
6395 : : .help = "packet type as defined in rte_mbuf_ptype",
6396 : : .next = NEXT(item_ptype, NEXT_ENTRY(COMMON_UNSIGNED),
6397 : : item_param),
6398 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ptype, packet_type)),
6399 : : },
6400 : : [ITEM_NSH] = {
6401 : : .name = "nsh",
6402 : : .help = "match NSH header",
6403 : : .priv = PRIV_ITEM(NSH,
6404 : : sizeof(struct rte_flow_item_nsh)),
6405 : : .next = NEXT(item_nsh),
6406 : : .call = parse_vc,
6407 : : },
6408 : : [ITEM_COMPARE] = {
6409 : : .name = "compare",
6410 : : .help = "match with the comparison result",
6411 : : .priv = PRIV_ITEM(COMPARE, sizeof(struct rte_flow_item_compare)),
6412 : : .next = NEXT(NEXT_ENTRY(ITEM_COMPARE_OP)),
6413 : : .call = parse_vc,
6414 : : },
6415 : : [ITEM_COMPARE_OP] = {
6416 : : .name = "op",
6417 : : .help = "operation type",
6418 : : .next = NEXT(item_compare_field,
6419 : : NEXT_ENTRY(ITEM_COMPARE_OP_VALUE), item_param),
6420 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, operation)),
6421 : : },
6422 : : [ITEM_COMPARE_OP_VALUE] = {
6423 : : .name = "{operation}",
6424 : : .help = "operation type value",
6425 : : .call = parse_vc_compare_op,
6426 : : .comp = comp_set_compare_op,
6427 : : },
6428 : : [ITEM_COMPARE_FIELD_A_TYPE] = {
6429 : : .name = "a_type",
6430 : : .help = "compared field type",
6431 : : .next = NEXT(compare_field_a,
6432 : : NEXT_ENTRY(ITEM_COMPARE_FIELD_A_TYPE_VALUE), item_param),
6433 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, a.field)),
6434 : : },
6435 : : [ITEM_COMPARE_FIELD_A_TYPE_VALUE] = {
6436 : : .name = "{a_type}",
6437 : : .help = "compared field type value",
6438 : : .call = parse_vc_compare_field_id,
6439 : : .comp = comp_set_compare_field_id,
6440 : : },
6441 : : [ITEM_COMPARE_FIELD_A_LEVEL] = {
6442 : : .name = "a_level",
6443 : : .help = "compared field level",
6444 : : .next = NEXT(compare_field_a,
6445 : : NEXT_ENTRY(ITEM_COMPARE_FIELD_A_LEVEL_VALUE), item_param),
6446 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, a.level)),
6447 : : },
6448 : : [ITEM_COMPARE_FIELD_A_LEVEL_VALUE] = {
6449 : : .name = "{a_level}",
6450 : : .help = "compared field level value",
6451 : : .call = parse_vc_compare_field_level,
6452 : : .comp = comp_none,
6453 : : },
6454 : : [ITEM_COMPARE_FIELD_A_TAG_INDEX] = {
6455 : : .name = "a_tag_index",
6456 : : .help = "compared field tag array",
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.tag_index)),
6461 : : },
6462 : : [ITEM_COMPARE_FIELD_A_TYPE_ID] = {
6463 : : .name = "a_type_id",
6464 : : .help = "compared field type ID",
6465 : : .next = NEXT(compare_field_a,
6466 : : NEXT_ENTRY(COMMON_UNSIGNED), item_param),
6467 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare,
6468 : : a.type)),
6469 : : },
6470 : : [ITEM_COMPARE_FIELD_A_CLASS_ID] = {
6471 : : .name = "a_class",
6472 : : .help = "compared field class ID",
6473 : : .next = NEXT(compare_field_a,
6474 : : NEXT_ENTRY(COMMON_UNSIGNED), item_param),
6475 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_compare,
6476 : : a.class_id)),
6477 : : },
6478 : : [ITEM_COMPARE_FIELD_A_OFFSET] = {
6479 : : .name = "a_offset",
6480 : : .help = "compared field bit offset",
6481 : : .next = NEXT(compare_field_a,
6482 : : NEXT_ENTRY(COMMON_UNSIGNED), item_param),
6483 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare,
6484 : : a.offset)),
6485 : : },
6486 : : [ITEM_COMPARE_FIELD_B_TYPE] = {
6487 : : .name = "b_type",
6488 : : .help = "comparator field type",
6489 : : .next = NEXT(compare_field_b,
6490 : : NEXT_ENTRY(ITEM_COMPARE_FIELD_B_TYPE_VALUE), item_param),
6491 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare,
6492 : : b.field)),
6493 : : },
6494 : : [ITEM_COMPARE_FIELD_B_TYPE_VALUE] = {
6495 : : .name = "{b_type}",
6496 : : .help = "comparator field type value",
6497 : : .call = parse_vc_compare_field_id,
6498 : : .comp = comp_set_compare_field_id,
6499 : : },
6500 : : [ITEM_COMPARE_FIELD_B_LEVEL] = {
6501 : : .name = "b_level",
6502 : : .help = "comparator field level",
6503 : : .next = NEXT(compare_field_b,
6504 : : NEXT_ENTRY(ITEM_COMPARE_FIELD_B_LEVEL_VALUE), item_param),
6505 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare,
6506 : : b.level)),
6507 : : },
6508 : : [ITEM_COMPARE_FIELD_B_LEVEL_VALUE] = {
6509 : : .name = "{b_level}",
6510 : : .help = "comparator field level value",
6511 : : .call = parse_vc_compare_field_level,
6512 : : .comp = comp_none,
6513 : : },
6514 : : [ITEM_COMPARE_FIELD_B_TAG_INDEX] = {
6515 : : .name = "b_tag_index",
6516 : : .help = "comparator field tag array",
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.tag_index)),
6521 : : },
6522 : : [ITEM_COMPARE_FIELD_B_TYPE_ID] = {
6523 : : .name = "b_type_id",
6524 : : .help = "comparator field type ID",
6525 : : .next = NEXT(compare_field_b,
6526 : : NEXT_ENTRY(COMMON_UNSIGNED), item_param),
6527 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare,
6528 : : b.type)),
6529 : : },
6530 : : [ITEM_COMPARE_FIELD_B_CLASS_ID] = {
6531 : : .name = "b_class",
6532 : : .help = "comparator field class ID",
6533 : : .next = NEXT(compare_field_b,
6534 : : NEXT_ENTRY(COMMON_UNSIGNED), item_param),
6535 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_compare,
6536 : : b.class_id)),
6537 : : },
6538 : : [ITEM_COMPARE_FIELD_B_OFFSET] = {
6539 : : .name = "b_offset",
6540 : : .help = "comparator field bit offset",
6541 : : .next = NEXT(compare_field_b,
6542 : : NEXT_ENTRY(COMMON_UNSIGNED), item_param),
6543 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare,
6544 : : b.offset)),
6545 : : },
6546 : : [ITEM_COMPARE_FIELD_B_VALUE] = {
6547 : : .name = "b_value",
6548 : : .help = "comparator immediate value",
6549 : : .next = NEXT(compare_field_b,
6550 : : NEXT_ENTRY(COMMON_HEX), item_param),
6551 : : .args = ARGS(ARGS_ENTRY_ARB(0, 0),
6552 : : ARGS_ENTRY_ARB(0, 0),
6553 : : ARGS_ENTRY(struct rte_flow_item_compare,
6554 : : b.value)),
6555 : : },
6556 : : [ITEM_COMPARE_FIELD_B_POINTER] = {
6557 : : .name = "b_ptr",
6558 : : .help = "pointer to comparator immediate value",
6559 : : .next = NEXT(compare_field_b,
6560 : : NEXT_ENTRY(COMMON_HEX), item_param),
6561 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare,
6562 : : b.pvalue),
6563 : : ARGS_ENTRY_ARB(0, 0),
6564 : : ARGS_ENTRY_ARB
6565 : : (sizeof(struct rte_flow_item_compare),
6566 : : FLOW_FIELD_PATTERN_SIZE)),
6567 : : },
6568 : : [ITEM_COMPARE_FIELD_WIDTH] = {
6569 : : .name = "width",
6570 : : .help = "number of bits to compare",
6571 : : .next = NEXT(item_compare_field,
6572 : : NEXT_ENTRY(COMMON_UNSIGNED), item_param),
6573 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare,
6574 : : width)),
6575 : : },
6576 : :
6577 : : /* Validate/create actions. */
6578 : : [ACTIONS] = {
6579 : : .name = "actions",
6580 : : .help = "submit a list of associated actions",
6581 : : .next = NEXT(next_action),
6582 : : .call = parse_vc,
6583 : : },
6584 : : [ACTION_NEXT] = {
6585 : : .name = "/",
6586 : : .help = "specify next action",
6587 : : .next = NEXT(next_action),
6588 : : },
6589 : : [ACTION_END] = {
6590 : : .name = "end",
6591 : : .help = "end list of actions",
6592 : : .priv = PRIV_ACTION(END, 0),
6593 : : .call = parse_vc,
6594 : : },
6595 : : [ACTION_VOID] = {
6596 : : .name = "void",
6597 : : .help = "no-op action",
6598 : : .priv = PRIV_ACTION(VOID, 0),
6599 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
6600 : : .call = parse_vc,
6601 : : },
6602 : : [ACTION_PASSTHRU] = {
6603 : : .name = "passthru",
6604 : : .help = "let subsequent rule process matched packets",
6605 : : .priv = PRIV_ACTION(PASSTHRU, 0),
6606 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
6607 : : .call = parse_vc,
6608 : : },
6609 : : [ACTION_SKIP_CMAN] = {
6610 : : .name = "skip_cman",
6611 : : .help = "bypass cman on received packets",
6612 : : .priv = PRIV_ACTION(SKIP_CMAN, 0),
6613 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
6614 : : .call = parse_vc,
6615 : : },
6616 : : [ACTION_JUMP] = {
6617 : : .name = "jump",
6618 : : .help = "redirect traffic to a given group",
6619 : : .priv = PRIV_ACTION(JUMP, sizeof(struct rte_flow_action_jump)),
6620 : : .next = NEXT(action_jump),
6621 : : .call = parse_vc,
6622 : : },
6623 : : [ACTION_JUMP_GROUP] = {
6624 : : .name = "group",
6625 : : .help = "group to redirect traffic to",
6626 : : .next = NEXT(action_jump, NEXT_ENTRY(COMMON_UNSIGNED)),
6627 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump, group)),
6628 : : .call = parse_vc_conf,
6629 : : },
6630 : : [ACTION_MARK] = {
6631 : : .name = "mark",
6632 : : .help = "attach 32 bit value to packets",
6633 : : .priv = PRIV_ACTION(MARK, sizeof(struct rte_flow_action_mark)),
6634 : : .next = NEXT(action_mark),
6635 : : .call = parse_vc,
6636 : : },
6637 : : [ACTION_MARK_ID] = {
6638 : : .name = "id",
6639 : : .help = "32 bit value to return with packets",
6640 : : .next = NEXT(action_mark, NEXT_ENTRY(COMMON_UNSIGNED)),
6641 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_mark, id)),
6642 : : .call = parse_vc_conf,
6643 : : },
6644 : : [ACTION_FLAG] = {
6645 : : .name = "flag",
6646 : : .help = "flag packets",
6647 : : .priv = PRIV_ACTION(FLAG, 0),
6648 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
6649 : : .call = parse_vc,
6650 : : },
6651 : : [ACTION_QUEUE] = {
6652 : : .name = "queue",
6653 : : .help = "assign packets to a given queue index",
6654 : : .priv = PRIV_ACTION(QUEUE,
6655 : : sizeof(struct rte_flow_action_queue)),
6656 : : .next = NEXT(action_queue),
6657 : : .call = parse_vc,
6658 : : },
6659 : : [ACTION_QUEUE_INDEX] = {
6660 : : .name = "index",
6661 : : .help = "queue index to use",
6662 : : .next = NEXT(action_queue, NEXT_ENTRY(COMMON_UNSIGNED)),
6663 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_queue, index)),
6664 : : .call = parse_vc_conf,
6665 : : },
6666 : : [ACTION_DROP] = {
6667 : : .name = "drop",
6668 : : .help = "drop packets (note: passthru has priority)",
6669 : : .priv = PRIV_ACTION(DROP, 0),
6670 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
6671 : : .call = parse_vc,
6672 : : },
6673 : : [ACTION_COUNT] = {
6674 : : .name = "count",
6675 : : .help = "enable counters for this rule",
6676 : : .priv = PRIV_ACTION(COUNT,
6677 : : sizeof(struct rte_flow_action_count)),
6678 : : .next = NEXT(action_count),
6679 : : .call = parse_vc,
6680 : : },
6681 : : [ACTION_COUNT_ID] = {
6682 : : .name = "identifier",
6683 : : .help = "counter identifier to use",
6684 : : .next = NEXT(action_count, NEXT_ENTRY(COMMON_UNSIGNED)),
6685 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_count, id)),
6686 : : .call = parse_vc_conf,
6687 : : },
6688 : : [ACTION_RSS] = {
6689 : : .name = "rss",
6690 : : .help = "spread packets among several queues",
6691 : : .priv = PRIV_ACTION(RSS, sizeof(struct action_rss_data)),
6692 : : .next = NEXT(action_rss),
6693 : : .call = parse_vc_action_rss,
6694 : : },
6695 : : [ACTION_RSS_FUNC] = {
6696 : : .name = "func",
6697 : : .help = "RSS hash function to apply",
6698 : : .next = NEXT(action_rss,
6699 : : NEXT_ENTRY(ACTION_RSS_FUNC_DEFAULT,
6700 : : ACTION_RSS_FUNC_TOEPLITZ,
6701 : : ACTION_RSS_FUNC_SIMPLE_XOR,
6702 : : ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ)),
6703 : : },
6704 : : [ACTION_RSS_FUNC_DEFAULT] = {
6705 : : .name = "default",
6706 : : .help = "default hash function",
6707 : : .call = parse_vc_action_rss_func,
6708 : : },
6709 : : [ACTION_RSS_FUNC_TOEPLITZ] = {
6710 : : .name = "toeplitz",
6711 : : .help = "Toeplitz hash function",
6712 : : .call = parse_vc_action_rss_func,
6713 : : },
6714 : : [ACTION_RSS_FUNC_SIMPLE_XOR] = {
6715 : : .name = "simple_xor",
6716 : : .help = "simple XOR hash function",
6717 : : .call = parse_vc_action_rss_func,
6718 : : },
6719 : : [ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ] = {
6720 : : .name = "symmetric_toeplitz",
6721 : : .help = "Symmetric Toeplitz hash function",
6722 : : .call = parse_vc_action_rss_func,
6723 : : },
6724 : : [ACTION_RSS_LEVEL] = {
6725 : : .name = "level",
6726 : : .help = "encapsulation level for \"types\"",
6727 : : .next = NEXT(action_rss, NEXT_ENTRY(COMMON_UNSIGNED)),
6728 : : .args = ARGS(ARGS_ENTRY_ARB
6729 : : (offsetof(struct action_rss_data, conf) +
6730 : : offsetof(struct rte_flow_action_rss, level),
6731 : : sizeof(((struct rte_flow_action_rss *)0)->
6732 : : level))),
6733 : : },
6734 : : [ACTION_RSS_TYPES] = {
6735 : : .name = "types",
6736 : : .help = "specific RSS hash types",
6737 : : .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)),
6738 : : },
6739 : : [ACTION_RSS_TYPE] = {
6740 : : .name = "{type}",
6741 : : .help = "RSS hash type",
6742 : : .call = parse_vc_action_rss_type,
6743 : : .comp = comp_vc_action_rss_type,
6744 : : },
6745 : : [ACTION_RSS_KEY] = {
6746 : : .name = "key",
6747 : : .help = "RSS hash key",
6748 : : .next = NEXT(action_rss, NEXT_ENTRY(COMMON_HEX)),
6749 : : .args = ARGS(ARGS_ENTRY_ARB
6750 : : (offsetof(struct action_rss_data, conf) +
6751 : : offsetof(struct rte_flow_action_rss, key),
6752 : : sizeof(((struct rte_flow_action_rss *)0)->key)),
6753 : : ARGS_ENTRY_ARB
6754 : : (offsetof(struct action_rss_data, conf) +
6755 : : offsetof(struct rte_flow_action_rss, key_len),
6756 : : sizeof(((struct rte_flow_action_rss *)0)->
6757 : : key_len)),
6758 : : ARGS_ENTRY(struct action_rss_data, key)),
6759 : : },
6760 : : [ACTION_RSS_KEY_LEN] = {
6761 : : .name = "key_len",
6762 : : .help = "RSS hash key length in bytes",
6763 : : .next = NEXT(action_rss, NEXT_ENTRY(COMMON_UNSIGNED)),
6764 : : .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
6765 : : (offsetof(struct action_rss_data, conf) +
6766 : : offsetof(struct rte_flow_action_rss, key_len),
6767 : : sizeof(((struct rte_flow_action_rss *)0)->
6768 : : key_len),
6769 : : 0,
6770 : : RSS_HASH_KEY_LENGTH)),
6771 : : },
6772 : : [ACTION_RSS_QUEUES] = {
6773 : : .name = "queues",
6774 : : .help = "queue indices to use",
6775 : : .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_QUEUE)),
6776 : : .call = parse_vc_conf,
6777 : : },
6778 : : [ACTION_RSS_QUEUE] = {
6779 : : .name = "{queue}",
6780 : : .help = "queue index",
6781 : : .call = parse_vc_action_rss_queue,
6782 : : .comp = comp_vc_action_rss_queue,
6783 : : },
6784 : : [ACTION_PF] = {
6785 : : .name = "pf",
6786 : : .help = "direct traffic to physical function",
6787 : : .priv = PRIV_ACTION(PF, 0),
6788 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
6789 : : .call = parse_vc,
6790 : : },
6791 : : [ACTION_VF] = {
6792 : : .name = "vf",
6793 : : .help = "direct traffic to a virtual function ID",
6794 : : .priv = PRIV_ACTION(VF, sizeof(struct rte_flow_action_vf)),
6795 : : .next = NEXT(action_vf),
6796 : : .call = parse_vc,
6797 : : },
6798 : : [ACTION_VF_ORIGINAL] = {
6799 : : .name = "original",
6800 : : .help = "use original VF ID if possible",
6801 : : .next = NEXT(action_vf, NEXT_ENTRY(COMMON_BOOLEAN)),
6802 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_vf,
6803 : : original, 1)),
6804 : : .call = parse_vc_conf,
6805 : : },
6806 : : [ACTION_VF_ID] = {
6807 : : .name = "id",
6808 : : .help = "VF ID",
6809 : : .next = NEXT(action_vf, NEXT_ENTRY(COMMON_UNSIGNED)),
6810 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)),
6811 : : .call = parse_vc_conf,
6812 : : },
6813 : : [ACTION_PORT_ID] = {
6814 : : .name = "port_id",
6815 : : .help = "direct matching traffic to a given DPDK port ID",
6816 : : .priv = PRIV_ACTION(PORT_ID,
6817 : : sizeof(struct rte_flow_action_port_id)),
6818 : : .next = NEXT(action_port_id),
6819 : : .call = parse_vc,
6820 : : },
6821 : : [ACTION_PORT_ID_ORIGINAL] = {
6822 : : .name = "original",
6823 : : .help = "use original DPDK port ID if possible",
6824 : : .next = NEXT(action_port_id, NEXT_ENTRY(COMMON_BOOLEAN)),
6825 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_port_id,
6826 : : original, 1)),
6827 : : .call = parse_vc_conf,
6828 : : },
6829 : : [ACTION_PORT_ID_ID] = {
6830 : : .name = "id",
6831 : : .help = "DPDK port ID",
6832 : : .next = NEXT(action_port_id, NEXT_ENTRY(COMMON_UNSIGNED)),
6833 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_port_id, id)),
6834 : : .call = parse_vc_conf,
6835 : : },
6836 : : [ACTION_METER] = {
6837 : : .name = "meter",
6838 : : .help = "meter the directed packets at given id",
6839 : : .priv = PRIV_ACTION(METER,
6840 : : sizeof(struct rte_flow_action_meter)),
6841 : : .next = NEXT(action_meter),
6842 : : .call = parse_vc,
6843 : : },
6844 : : [ACTION_METER_COLOR] = {
6845 : : .name = "color",
6846 : : .help = "meter color for the packets",
6847 : : .priv = PRIV_ACTION(METER_COLOR,
6848 : : sizeof(struct rte_flow_action_meter_color)),
6849 : : .next = NEXT(action_meter_color),
6850 : : .call = parse_vc,
6851 : : },
6852 : : [ACTION_METER_COLOR_TYPE] = {
6853 : : .name = "type",
6854 : : .help = "specific meter color",
6855 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT),
6856 : : NEXT_ENTRY(ACTION_METER_COLOR_GREEN,
6857 : : ACTION_METER_COLOR_YELLOW,
6858 : : ACTION_METER_COLOR_RED)),
6859 : : },
6860 : : [ACTION_METER_COLOR_GREEN] = {
6861 : : .name = "green",
6862 : : .help = "meter color green",
6863 : : .call = parse_vc_action_meter_color_type,
6864 : : },
6865 : : [ACTION_METER_COLOR_YELLOW] = {
6866 : : .name = "yellow",
6867 : : .help = "meter color yellow",
6868 : : .call = parse_vc_action_meter_color_type,
6869 : : },
6870 : : [ACTION_METER_COLOR_RED] = {
6871 : : .name = "red",
6872 : : .help = "meter color red",
6873 : : .call = parse_vc_action_meter_color_type,
6874 : : },
6875 : : [ACTION_METER_ID] = {
6876 : : .name = "mtr_id",
6877 : : .help = "meter id to use",
6878 : : .next = NEXT(action_meter, NEXT_ENTRY(COMMON_UNSIGNED)),
6879 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter, mtr_id)),
6880 : : .call = parse_vc_conf,
6881 : : },
6882 : : [ACTION_METER_MARK] = {
6883 : : .name = "meter_mark",
6884 : : .help = "meter the directed packets using profile and policy",
6885 : : .priv = PRIV_ACTION(METER_MARK,
6886 : : sizeof(struct rte_flow_action_meter_mark)),
6887 : : .next = NEXT(action_meter_mark),
6888 : : .call = parse_vc,
6889 : : },
6890 : : [ACTION_METER_MARK_CONF] = {
6891 : : .name = "meter_mark_conf",
6892 : : .help = "meter mark configuration",
6893 : : .priv = PRIV_ACTION(METER_MARK,
6894 : : sizeof(struct rte_flow_action_meter_mark)),
6895 : : .next = NEXT(NEXT_ENTRY(ACTION_METER_MARK_CONF_COLOR)),
6896 : : .call = parse_vc,
6897 : : },
6898 : : [ACTION_METER_MARK_CONF_COLOR] = {
6899 : : .name = "mtr_update_init_color",
6900 : : .help = "meter update init color",
6901 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT),
6902 : : NEXT_ENTRY(COMMON_METER_COLOR_NAME)),
6903 : : .args = ARGS(ARGS_ENTRY
6904 : : (struct rte_flow_indirect_update_flow_meter_mark,
6905 : : init_color)),
6906 : : },
6907 : : [ACTION_METER_PROFILE] = {
6908 : : .name = "mtr_profile",
6909 : : .help = "meter profile id to use",
6910 : : .next = NEXT(NEXT_ENTRY(ACTION_METER_PROFILE_ID2PTR)),
6911 : : .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
6912 : : },
6913 : : [ACTION_METER_PROFILE_ID2PTR] = {
6914 : : .name = "{mtr_profile_id}",
6915 : : .type = "PROFILE_ID",
6916 : : .help = "meter profile id",
6917 : : .next = NEXT(action_meter_mark),
6918 : : .call = parse_meter_profile_id2ptr,
6919 : : .comp = comp_none,
6920 : : },
6921 : : [ACTION_METER_POLICY] = {
6922 : : .name = "mtr_policy",
6923 : : .help = "meter policy id to use",
6924 : : .next = NEXT(NEXT_ENTRY(ACTION_METER_POLICY_ID2PTR)),
6925 : : ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
6926 : : },
6927 : : [ACTION_METER_POLICY_ID2PTR] = {
6928 : : .name = "{mtr_policy_id}",
6929 : : .type = "POLICY_ID",
6930 : : .help = "meter policy id",
6931 : : .next = NEXT(action_meter_mark),
6932 : : .call = parse_meter_policy_id2ptr,
6933 : : .comp = comp_none,
6934 : : },
6935 : : [ACTION_METER_COLOR_MODE] = {
6936 : : .name = "mtr_color_mode",
6937 : : .help = "meter color awareness mode",
6938 : : .next = NEXT(action_meter_mark, NEXT_ENTRY(COMMON_UNSIGNED)),
6939 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter_mark, color_mode)),
6940 : : .call = parse_vc_conf,
6941 : : },
6942 : : [ACTION_METER_STATE] = {
6943 : : .name = "mtr_state",
6944 : : .help = "meter state",
6945 : : .next = NEXT(action_meter_mark, NEXT_ENTRY(COMMON_UNSIGNED)),
6946 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter_mark, state)),
6947 : : .call = parse_vc_conf,
6948 : : },
6949 : : [ACTION_OF_DEC_NW_TTL] = {
6950 : : .name = "of_dec_nw_ttl",
6951 : : .help = "OpenFlow's OFPAT_DEC_NW_TTL",
6952 : : .priv = PRIV_ACTION(OF_DEC_NW_TTL, 0),
6953 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
6954 : : .call = parse_vc,
6955 : : },
6956 : : [ACTION_OF_POP_VLAN] = {
6957 : : .name = "of_pop_vlan",
6958 : : .help = "OpenFlow's OFPAT_POP_VLAN",
6959 : : .priv = PRIV_ACTION(OF_POP_VLAN, 0),
6960 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
6961 : : .call = parse_vc,
6962 : : },
6963 : : [ACTION_OF_PUSH_VLAN] = {
6964 : : .name = "of_push_vlan",
6965 : : .help = "OpenFlow's OFPAT_PUSH_VLAN",
6966 : : .priv = PRIV_ACTION
6967 : : (OF_PUSH_VLAN,
6968 : : sizeof(struct rte_flow_action_of_push_vlan)),
6969 : : .next = NEXT(action_of_push_vlan),
6970 : : .call = parse_vc,
6971 : : },
6972 : : [ACTION_OF_PUSH_VLAN_ETHERTYPE] = {
6973 : : .name = "ethertype",
6974 : : .help = "EtherType",
6975 : : .next = NEXT(action_of_push_vlan, NEXT_ENTRY(COMMON_UNSIGNED)),
6976 : : .args = ARGS(ARGS_ENTRY_HTON
6977 : : (struct rte_flow_action_of_push_vlan,
6978 : : ethertype)),
6979 : : .call = parse_vc_conf,
6980 : : },
6981 : : [ACTION_OF_SET_VLAN_VID] = {
6982 : : .name = "of_set_vlan_vid",
6983 : : .help = "OpenFlow's OFPAT_SET_VLAN_VID",
6984 : : .priv = PRIV_ACTION
6985 : : (OF_SET_VLAN_VID,
6986 : : sizeof(struct rte_flow_action_of_set_vlan_vid)),
6987 : : .next = NEXT(action_of_set_vlan_vid),
6988 : : .call = parse_vc,
6989 : : },
6990 : : [ACTION_OF_SET_VLAN_VID_VLAN_VID] = {
6991 : : .name = "vlan_vid",
6992 : : .help = "VLAN id",
6993 : : .next = NEXT(action_of_set_vlan_vid,
6994 : : NEXT_ENTRY(COMMON_UNSIGNED)),
6995 : : .args = ARGS(ARGS_ENTRY_HTON
6996 : : (struct rte_flow_action_of_set_vlan_vid,
6997 : : vlan_vid)),
6998 : : .call = parse_vc_conf,
6999 : : },
7000 : : [ACTION_OF_SET_VLAN_PCP] = {
7001 : : .name = "of_set_vlan_pcp",
7002 : : .help = "OpenFlow's OFPAT_SET_VLAN_PCP",
7003 : : .priv = PRIV_ACTION
7004 : : (OF_SET_VLAN_PCP,
7005 : : sizeof(struct rte_flow_action_of_set_vlan_pcp)),
7006 : : .next = NEXT(action_of_set_vlan_pcp),
7007 : : .call = parse_vc,
7008 : : },
7009 : : [ACTION_OF_SET_VLAN_PCP_VLAN_PCP] = {
7010 : : .name = "vlan_pcp",
7011 : : .help = "VLAN priority",
7012 : : .next = NEXT(action_of_set_vlan_pcp,
7013 : : NEXT_ENTRY(COMMON_UNSIGNED)),
7014 : : .args = ARGS(ARGS_ENTRY_HTON
7015 : : (struct rte_flow_action_of_set_vlan_pcp,
7016 : : vlan_pcp)),
7017 : : .call = parse_vc_conf,
7018 : : },
7019 : : [ACTION_OF_POP_MPLS] = {
7020 : : .name = "of_pop_mpls",
7021 : : .help = "OpenFlow's OFPAT_POP_MPLS",
7022 : : .priv = PRIV_ACTION(OF_POP_MPLS,
7023 : : sizeof(struct rte_flow_action_of_pop_mpls)),
7024 : : .next = NEXT(action_of_pop_mpls),
7025 : : .call = parse_vc,
7026 : : },
7027 : : [ACTION_OF_POP_MPLS_ETHERTYPE] = {
7028 : : .name = "ethertype",
7029 : : .help = "EtherType",
7030 : : .next = NEXT(action_of_pop_mpls, NEXT_ENTRY(COMMON_UNSIGNED)),
7031 : : .args = ARGS(ARGS_ENTRY_HTON
7032 : : (struct rte_flow_action_of_pop_mpls,
7033 : : ethertype)),
7034 : : .call = parse_vc_conf,
7035 : : },
7036 : : [ACTION_OF_PUSH_MPLS] = {
7037 : : .name = "of_push_mpls",
7038 : : .help = "OpenFlow's OFPAT_PUSH_MPLS",
7039 : : .priv = PRIV_ACTION
7040 : : (OF_PUSH_MPLS,
7041 : : sizeof(struct rte_flow_action_of_push_mpls)),
7042 : : .next = NEXT(action_of_push_mpls),
7043 : : .call = parse_vc,
7044 : : },
7045 : : [ACTION_OF_PUSH_MPLS_ETHERTYPE] = {
7046 : : .name = "ethertype",
7047 : : .help = "EtherType",
7048 : : .next = NEXT(action_of_push_mpls, NEXT_ENTRY(COMMON_UNSIGNED)),
7049 : : .args = ARGS(ARGS_ENTRY_HTON
7050 : : (struct rte_flow_action_of_push_mpls,
7051 : : ethertype)),
7052 : : .call = parse_vc_conf,
7053 : : },
7054 : : [ACTION_VXLAN_ENCAP] = {
7055 : : .name = "vxlan_encap",
7056 : : .help = "VXLAN encapsulation, uses configuration set by \"set"
7057 : : " vxlan\"",
7058 : : .priv = PRIV_ACTION(VXLAN_ENCAP,
7059 : : sizeof(struct action_vxlan_encap_data)),
7060 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7061 : : .call = parse_vc_action_vxlan_encap,
7062 : : },
7063 : : [ACTION_VXLAN_DECAP] = {
7064 : : .name = "vxlan_decap",
7065 : : .help = "Performs a decapsulation action by stripping all"
7066 : : " headers of the VXLAN tunnel network overlay from the"
7067 : : " matched flow.",
7068 : : .priv = PRIV_ACTION(VXLAN_DECAP, 0),
7069 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7070 : : .call = parse_vc,
7071 : : },
7072 : : [ACTION_NVGRE_ENCAP] = {
7073 : : .name = "nvgre_encap",
7074 : : .help = "NVGRE encapsulation, uses configuration set by \"set"
7075 : : " nvgre\"",
7076 : : .priv = PRIV_ACTION(NVGRE_ENCAP,
7077 : : sizeof(struct action_nvgre_encap_data)),
7078 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7079 : : .call = parse_vc_action_nvgre_encap,
7080 : : },
7081 : : [ACTION_NVGRE_DECAP] = {
7082 : : .name = "nvgre_decap",
7083 : : .help = "Performs a decapsulation action by stripping all"
7084 : : " headers of the NVGRE tunnel network overlay from the"
7085 : : " matched flow.",
7086 : : .priv = PRIV_ACTION(NVGRE_DECAP, 0),
7087 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7088 : : .call = parse_vc,
7089 : : },
7090 : : [ACTION_L2_ENCAP] = {
7091 : : .name = "l2_encap",
7092 : : .help = "l2 encap, uses configuration set by"
7093 : : " \"set l2_encap\"",
7094 : : .priv = PRIV_ACTION(RAW_ENCAP,
7095 : : sizeof(struct action_raw_encap_data)),
7096 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7097 : : .call = parse_vc_action_l2_encap,
7098 : : },
7099 : : [ACTION_L2_DECAP] = {
7100 : : .name = "l2_decap",
7101 : : .help = "l2 decap, uses configuration set by"
7102 : : " \"set l2_decap\"",
7103 : : .priv = PRIV_ACTION(RAW_DECAP,
7104 : : sizeof(struct action_raw_decap_data)),
7105 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7106 : : .call = parse_vc_action_l2_decap,
7107 : : },
7108 : : [ACTION_MPLSOGRE_ENCAP] = {
7109 : : .name = "mplsogre_encap",
7110 : : .help = "mplsogre encapsulation, uses configuration set by"
7111 : : " \"set mplsogre_encap\"",
7112 : : .priv = PRIV_ACTION(RAW_ENCAP,
7113 : : sizeof(struct action_raw_encap_data)),
7114 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7115 : : .call = parse_vc_action_mplsogre_encap,
7116 : : },
7117 : : [ACTION_MPLSOGRE_DECAP] = {
7118 : : .name = "mplsogre_decap",
7119 : : .help = "mplsogre decapsulation, uses configuration set by"
7120 : : " \"set mplsogre_decap\"",
7121 : : .priv = PRIV_ACTION(RAW_DECAP,
7122 : : sizeof(struct action_raw_decap_data)),
7123 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7124 : : .call = parse_vc_action_mplsogre_decap,
7125 : : },
7126 : : [ACTION_MPLSOUDP_ENCAP] = {
7127 : : .name = "mplsoudp_encap",
7128 : : .help = "mplsoudp encapsulation, uses configuration set by"
7129 : : " \"set mplsoudp_encap\"",
7130 : : .priv = PRIV_ACTION(RAW_ENCAP,
7131 : : sizeof(struct action_raw_encap_data)),
7132 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7133 : : .call = parse_vc_action_mplsoudp_encap,
7134 : : },
7135 : : [ACTION_MPLSOUDP_DECAP] = {
7136 : : .name = "mplsoudp_decap",
7137 : : .help = "mplsoudp decapsulation, uses configuration set by"
7138 : : " \"set mplsoudp_decap\"",
7139 : : .priv = PRIV_ACTION(RAW_DECAP,
7140 : : sizeof(struct action_raw_decap_data)),
7141 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7142 : : .call = parse_vc_action_mplsoudp_decap,
7143 : : },
7144 : : [ACTION_SET_IPV4_SRC] = {
7145 : : .name = "set_ipv4_src",
7146 : : .help = "Set a new IPv4 source address in the outermost"
7147 : : " IPv4 header",
7148 : : .priv = PRIV_ACTION(SET_IPV4_SRC,
7149 : : sizeof(struct rte_flow_action_set_ipv4)),
7150 : : .next = NEXT(action_set_ipv4_src),
7151 : : .call = parse_vc,
7152 : : },
7153 : : [ACTION_SET_IPV4_SRC_IPV4_SRC] = {
7154 : : .name = "ipv4_addr",
7155 : : .help = "new IPv4 source address to set",
7156 : : .next = NEXT(action_set_ipv4_src, NEXT_ENTRY(COMMON_IPV4_ADDR)),
7157 : : .args = ARGS(ARGS_ENTRY_HTON
7158 : : (struct rte_flow_action_set_ipv4, ipv4_addr)),
7159 : : .call = parse_vc_conf,
7160 : : },
7161 : : [ACTION_SET_IPV4_DST] = {
7162 : : .name = "set_ipv4_dst",
7163 : : .help = "Set a new IPv4 destination address in the outermost"
7164 : : " IPv4 header",
7165 : : .priv = PRIV_ACTION(SET_IPV4_DST,
7166 : : sizeof(struct rte_flow_action_set_ipv4)),
7167 : : .next = NEXT(action_set_ipv4_dst),
7168 : : .call = parse_vc,
7169 : : },
7170 : : [ACTION_SET_IPV4_DST_IPV4_DST] = {
7171 : : .name = "ipv4_addr",
7172 : : .help = "new IPv4 destination address to set",
7173 : : .next = NEXT(action_set_ipv4_dst, NEXT_ENTRY(COMMON_IPV4_ADDR)),
7174 : : .args = ARGS(ARGS_ENTRY_HTON
7175 : : (struct rte_flow_action_set_ipv4, ipv4_addr)),
7176 : : .call = parse_vc_conf,
7177 : : },
7178 : : [ACTION_SET_IPV6_SRC] = {
7179 : : .name = "set_ipv6_src",
7180 : : .help = "Set a new IPv6 source address in the outermost"
7181 : : " IPv6 header",
7182 : : .priv = PRIV_ACTION(SET_IPV6_SRC,
7183 : : sizeof(struct rte_flow_action_set_ipv6)),
7184 : : .next = NEXT(action_set_ipv6_src),
7185 : : .call = parse_vc,
7186 : : },
7187 : : [ACTION_SET_IPV6_SRC_IPV6_SRC] = {
7188 : : .name = "ipv6_addr",
7189 : : .help = "new IPv6 source address to set",
7190 : : .next = NEXT(action_set_ipv6_src, NEXT_ENTRY(COMMON_IPV6_ADDR)),
7191 : : .args = ARGS(ARGS_ENTRY_HTON
7192 : : (struct rte_flow_action_set_ipv6, ipv6_addr)),
7193 : : .call = parse_vc_conf,
7194 : : },
7195 : : [ACTION_SET_IPV6_DST] = {
7196 : : .name = "set_ipv6_dst",
7197 : : .help = "Set a new IPv6 destination address in the outermost"
7198 : : " IPv6 header",
7199 : : .priv = PRIV_ACTION(SET_IPV6_DST,
7200 : : sizeof(struct rte_flow_action_set_ipv6)),
7201 : : .next = NEXT(action_set_ipv6_dst),
7202 : : .call = parse_vc,
7203 : : },
7204 : : [ACTION_SET_IPV6_DST_IPV6_DST] = {
7205 : : .name = "ipv6_addr",
7206 : : .help = "new IPv6 destination address to set",
7207 : : .next = NEXT(action_set_ipv6_dst, NEXT_ENTRY(COMMON_IPV6_ADDR)),
7208 : : .args = ARGS(ARGS_ENTRY_HTON
7209 : : (struct rte_flow_action_set_ipv6, ipv6_addr)),
7210 : : .call = parse_vc_conf,
7211 : : },
7212 : : [ACTION_SET_TP_SRC] = {
7213 : : .name = "set_tp_src",
7214 : : .help = "set a new source port number in the outermost"
7215 : : " TCP/UDP header",
7216 : : .priv = PRIV_ACTION(SET_TP_SRC,
7217 : : sizeof(struct rte_flow_action_set_tp)),
7218 : : .next = NEXT(action_set_tp_src),
7219 : : .call = parse_vc,
7220 : : },
7221 : : [ACTION_SET_TP_SRC_TP_SRC] = {
7222 : : .name = "port",
7223 : : .help = "new source port number to set",
7224 : : .next = NEXT(action_set_tp_src, NEXT_ENTRY(COMMON_UNSIGNED)),
7225 : : .args = ARGS(ARGS_ENTRY_HTON
7226 : : (struct rte_flow_action_set_tp, port)),
7227 : : .call = parse_vc_conf,
7228 : : },
7229 : : [ACTION_SET_TP_DST] = {
7230 : : .name = "set_tp_dst",
7231 : : .help = "set a new destination port number in the outermost"
7232 : : " TCP/UDP header",
7233 : : .priv = PRIV_ACTION(SET_TP_DST,
7234 : : sizeof(struct rte_flow_action_set_tp)),
7235 : : .next = NEXT(action_set_tp_dst),
7236 : : .call = parse_vc,
7237 : : },
7238 : : [ACTION_SET_TP_DST_TP_DST] = {
7239 : : .name = "port",
7240 : : .help = "new destination port number to set",
7241 : : .next = NEXT(action_set_tp_dst, NEXT_ENTRY(COMMON_UNSIGNED)),
7242 : : .args = ARGS(ARGS_ENTRY_HTON
7243 : : (struct rte_flow_action_set_tp, port)),
7244 : : .call = parse_vc_conf,
7245 : : },
7246 : : [ACTION_MAC_SWAP] = {
7247 : : .name = "mac_swap",
7248 : : .help = "Swap the source and destination MAC addresses"
7249 : : " in the outermost Ethernet header",
7250 : : .priv = PRIV_ACTION(MAC_SWAP, 0),
7251 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7252 : : .call = parse_vc,
7253 : : },
7254 : : [ACTION_DEC_TTL] = {
7255 : : .name = "dec_ttl",
7256 : : .help = "decrease network TTL if available",
7257 : : .priv = PRIV_ACTION(DEC_TTL, 0),
7258 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7259 : : .call = parse_vc,
7260 : : },
7261 : : [ACTION_SET_TTL] = {
7262 : : .name = "set_ttl",
7263 : : .help = "set ttl value",
7264 : : .priv = PRIV_ACTION(SET_TTL,
7265 : : sizeof(struct rte_flow_action_set_ttl)),
7266 : : .next = NEXT(action_set_ttl),
7267 : : .call = parse_vc,
7268 : : },
7269 : : [ACTION_SET_TTL_TTL] = {
7270 : : .name = "ttl_value",
7271 : : .help = "new ttl value to set",
7272 : : .next = NEXT(action_set_ttl, NEXT_ENTRY(COMMON_UNSIGNED)),
7273 : : .args = ARGS(ARGS_ENTRY_HTON
7274 : : (struct rte_flow_action_set_ttl, ttl_value)),
7275 : : .call = parse_vc_conf,
7276 : : },
7277 : : [ACTION_SET_MAC_SRC] = {
7278 : : .name = "set_mac_src",
7279 : : .help = "set source mac address",
7280 : : .priv = PRIV_ACTION(SET_MAC_SRC,
7281 : : sizeof(struct rte_flow_action_set_mac)),
7282 : : .next = NEXT(action_set_mac_src),
7283 : : .call = parse_vc,
7284 : : },
7285 : : [ACTION_SET_MAC_SRC_MAC_SRC] = {
7286 : : .name = "mac_addr",
7287 : : .help = "new source mac address",
7288 : : .next = NEXT(action_set_mac_src, NEXT_ENTRY(COMMON_MAC_ADDR)),
7289 : : .args = ARGS(ARGS_ENTRY_HTON
7290 : : (struct rte_flow_action_set_mac, mac_addr)),
7291 : : .call = parse_vc_conf,
7292 : : },
7293 : : [ACTION_SET_MAC_DST] = {
7294 : : .name = "set_mac_dst",
7295 : : .help = "set destination mac address",
7296 : : .priv = PRIV_ACTION(SET_MAC_DST,
7297 : : sizeof(struct rte_flow_action_set_mac)),
7298 : : .next = NEXT(action_set_mac_dst),
7299 : : .call = parse_vc,
7300 : : },
7301 : : [ACTION_SET_MAC_DST_MAC_DST] = {
7302 : : .name = "mac_addr",
7303 : : .help = "new destination mac address to set",
7304 : : .next = NEXT(action_set_mac_dst, NEXT_ENTRY(COMMON_MAC_ADDR)),
7305 : : .args = ARGS(ARGS_ENTRY_HTON
7306 : : (struct rte_flow_action_set_mac, mac_addr)),
7307 : : .call = parse_vc_conf,
7308 : : },
7309 : : [ACTION_INC_TCP_SEQ] = {
7310 : : .name = "inc_tcp_seq",
7311 : : .help = "increase TCP sequence number",
7312 : : .priv = PRIV_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
7313 : : .next = NEXT(action_inc_tcp_seq),
7314 : : .call = parse_vc,
7315 : : },
7316 : : [ACTION_INC_TCP_SEQ_VALUE] = {
7317 : : .name = "value",
7318 : : .help = "the value to increase TCP sequence number by",
7319 : : .next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(COMMON_UNSIGNED)),
7320 : : .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
7321 : : .call = parse_vc_conf,
7322 : : },
7323 : : [ACTION_DEC_TCP_SEQ] = {
7324 : : .name = "dec_tcp_seq",
7325 : : .help = "decrease TCP sequence number",
7326 : : .priv = PRIV_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
7327 : : .next = NEXT(action_dec_tcp_seq),
7328 : : .call = parse_vc,
7329 : : },
7330 : : [ACTION_DEC_TCP_SEQ_VALUE] = {
7331 : : .name = "value",
7332 : : .help = "the value to decrease TCP sequence number by",
7333 : : .next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(COMMON_UNSIGNED)),
7334 : : .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
7335 : : .call = parse_vc_conf,
7336 : : },
7337 : : [ACTION_INC_TCP_ACK] = {
7338 : : .name = "inc_tcp_ack",
7339 : : .help = "increase TCP acknowledgment number",
7340 : : .priv = PRIV_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
7341 : : .next = NEXT(action_inc_tcp_ack),
7342 : : .call = parse_vc,
7343 : : },
7344 : : [ACTION_INC_TCP_ACK_VALUE] = {
7345 : : .name = "value",
7346 : : .help = "the value to increase TCP acknowledgment number by",
7347 : : .next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(COMMON_UNSIGNED)),
7348 : : .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
7349 : : .call = parse_vc_conf,
7350 : : },
7351 : : [ACTION_DEC_TCP_ACK] = {
7352 : : .name = "dec_tcp_ack",
7353 : : .help = "decrease TCP acknowledgment number",
7354 : : .priv = PRIV_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
7355 : : .next = NEXT(action_dec_tcp_ack),
7356 : : .call = parse_vc,
7357 : : },
7358 : : [ACTION_DEC_TCP_ACK_VALUE] = {
7359 : : .name = "value",
7360 : : .help = "the value to decrease TCP acknowledgment number by",
7361 : : .next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(COMMON_UNSIGNED)),
7362 : : .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
7363 : : .call = parse_vc_conf,
7364 : : },
7365 : : [ACTION_RAW_ENCAP] = {
7366 : : .name = "raw_encap",
7367 : : .help = "encapsulation data, defined by set raw_encap",
7368 : : .priv = PRIV_ACTION(RAW_ENCAP,
7369 : : sizeof(struct action_raw_encap_data)),
7370 : : .next = NEXT(action_raw_encap),
7371 : : .call = parse_vc_action_raw_encap,
7372 : : },
7373 : : [ACTION_RAW_ENCAP_SIZE] = {
7374 : : .name = "size",
7375 : : .help = "raw encap size",
7376 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT),
7377 : : NEXT_ENTRY(COMMON_UNSIGNED)),
7378 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_raw_encap, size)),
7379 : : .call = parse_vc_conf,
7380 : : },
7381 : : [ACTION_RAW_ENCAP_INDEX] = {
7382 : : .name = "index",
7383 : : .help = "the index of raw_encap_confs",
7384 : : .next = NEXT(NEXT_ENTRY(ACTION_RAW_ENCAP_INDEX_VALUE)),
7385 : : },
7386 : : [ACTION_RAW_ENCAP_INDEX_VALUE] = {
7387 : : .name = "{index}",
7388 : : .type = "UNSIGNED",
7389 : : .help = "unsigned integer value",
7390 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7391 : : .call = parse_vc_action_raw_encap_index,
7392 : : .comp = comp_set_raw_index,
7393 : : },
7394 : : [ACTION_RAW_DECAP] = {
7395 : : .name = "raw_decap",
7396 : : .help = "decapsulation data, defined by set raw_encap",
7397 : : .priv = PRIV_ACTION(RAW_DECAP,
7398 : : sizeof(struct action_raw_decap_data)),
7399 : : .next = NEXT(action_raw_decap),
7400 : : .call = parse_vc_action_raw_decap,
7401 : : },
7402 : : [ACTION_RAW_DECAP_INDEX] = {
7403 : : .name = "index",
7404 : : .help = "the index of raw_encap_confs",
7405 : : .next = NEXT(NEXT_ENTRY(ACTION_RAW_DECAP_INDEX_VALUE)),
7406 : : },
7407 : : [ACTION_RAW_DECAP_INDEX_VALUE] = {
7408 : : .name = "{index}",
7409 : : .type = "UNSIGNED",
7410 : : .help = "unsigned integer value",
7411 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7412 : : .call = parse_vc_action_raw_decap_index,
7413 : : .comp = comp_set_raw_index,
7414 : : },
7415 : : [ACTION_MODIFY_FIELD] = {
7416 : : .name = "modify_field",
7417 : : .help = "modify destination field with data from source field",
7418 : : .priv = PRIV_ACTION(MODIFY_FIELD, ACTION_MODIFY_SIZE),
7419 : : .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_OP)),
7420 : : .call = parse_vc,
7421 : : },
7422 : : [ACTION_MODIFY_FIELD_OP] = {
7423 : : .name = "op",
7424 : : .help = "operation type",
7425 : : .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_TYPE),
7426 : : NEXT_ENTRY(ACTION_MODIFY_FIELD_OP_VALUE)),
7427 : : .call = parse_vc_conf,
7428 : : },
7429 : : [ACTION_MODIFY_FIELD_OP_VALUE] = {
7430 : : .name = "{operation}",
7431 : : .help = "operation type value",
7432 : : .call = parse_vc_modify_field_op,
7433 : : .comp = comp_set_modify_field_op,
7434 : : },
7435 : : [ACTION_MODIFY_FIELD_DST_TYPE] = {
7436 : : .name = "dst_type",
7437 : : .help = "destination field type",
7438 : : .next = NEXT(action_modify_field_dst,
7439 : : NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_TYPE_VALUE)),
7440 : : .call = parse_vc_conf,
7441 : : },
7442 : : [ACTION_MODIFY_FIELD_DST_TYPE_VALUE] = {
7443 : : .name = "{dst_type}",
7444 : : .help = "destination field type value",
7445 : : .call = parse_vc_modify_field_id,
7446 : : .comp = comp_set_modify_field_id,
7447 : : },
7448 : : [ACTION_MODIFY_FIELD_DST_LEVEL] = {
7449 : : .name = "dst_level",
7450 : : .help = "destination field level",
7451 : : .next = NEXT(action_modify_field_dst,
7452 : : NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_LEVEL_VALUE)),
7453 : : .call = parse_vc_conf,
7454 : : },
7455 : : [ACTION_MODIFY_FIELD_DST_LEVEL_VALUE] = {
7456 : : .name = "{dst_level}",
7457 : : .help = "destination field level value",
7458 : : .call = parse_vc_modify_field_level,
7459 : : .comp = comp_none,
7460 : : },
7461 : : [ACTION_MODIFY_FIELD_DST_TAG_INDEX] = {
7462 : : .name = "dst_tag_index",
7463 : : .help = "destination field tag array",
7464 : : .next = NEXT(action_modify_field_dst,
7465 : : NEXT_ENTRY(COMMON_UNSIGNED)),
7466 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
7467 : : dst.tag_index)),
7468 : : .call = parse_vc_conf,
7469 : : },
7470 : : [ACTION_MODIFY_FIELD_DST_TYPE_ID] = {
7471 : : .name = "dst_type_id",
7472 : : .help = "destination field type ID",
7473 : : .next = NEXT(action_modify_field_dst,
7474 : : NEXT_ENTRY(COMMON_UNSIGNED)),
7475 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
7476 : : dst.type)),
7477 : : .call = parse_vc_conf,
7478 : : },
7479 : : [ACTION_MODIFY_FIELD_DST_CLASS_ID] = {
7480 : : .name = "dst_class",
7481 : : .help = "destination field class ID",
7482 : : .next = NEXT(action_modify_field_dst,
7483 : : NEXT_ENTRY(COMMON_UNSIGNED)),
7484 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_action_modify_field,
7485 : : dst.class_id)),
7486 : : .call = parse_vc_conf,
7487 : : },
7488 : : [ACTION_MODIFY_FIELD_DST_OFFSET] = {
7489 : : .name = "dst_offset",
7490 : : .help = "destination field bit offset",
7491 : : .next = NEXT(action_modify_field_dst,
7492 : : NEXT_ENTRY(COMMON_UNSIGNED)),
7493 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
7494 : : dst.offset)),
7495 : : .call = parse_vc_conf,
7496 : : },
7497 : : [ACTION_MODIFY_FIELD_SRC_TYPE] = {
7498 : : .name = "src_type",
7499 : : .help = "source field type",
7500 : : .next = NEXT(action_modify_field_src,
7501 : : NEXT_ENTRY(ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)),
7502 : : .call = parse_vc_conf,
7503 : : },
7504 : : [ACTION_MODIFY_FIELD_SRC_TYPE_VALUE] = {
7505 : : .name = "{src_type}",
7506 : : .help = "source field type value",
7507 : : .call = parse_vc_modify_field_id,
7508 : : .comp = comp_set_modify_field_id,
7509 : : },
7510 : : [ACTION_MODIFY_FIELD_SRC_LEVEL] = {
7511 : : .name = "src_level",
7512 : : .help = "source field level",
7513 : : .next = NEXT(action_modify_field_src,
7514 : : NEXT_ENTRY(ACTION_MODIFY_FIELD_SRC_LEVEL_VALUE)),
7515 : : .call = parse_vc_conf,
7516 : : },
7517 : : [ACTION_MODIFY_FIELD_SRC_LEVEL_VALUE] = {
7518 : : .name = "{src_level}",
7519 : : .help = "source field level value",
7520 : : .call = parse_vc_modify_field_level,
7521 : : .comp = comp_none,
7522 : : },
7523 : : [ACTION_MODIFY_FIELD_SRC_TAG_INDEX] = {
7524 : : .name = "src_tag_index",
7525 : : .help = "source field tag array",
7526 : : .next = NEXT(action_modify_field_src,
7527 : : NEXT_ENTRY(COMMON_UNSIGNED)),
7528 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
7529 : : src.tag_index)),
7530 : : .call = parse_vc_conf,
7531 : : },
7532 : : [ACTION_MODIFY_FIELD_SRC_TYPE_ID] = {
7533 : : .name = "src_type_id",
7534 : : .help = "source field type ID",
7535 : : .next = NEXT(action_modify_field_src,
7536 : : NEXT_ENTRY(COMMON_UNSIGNED)),
7537 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
7538 : : src.type)),
7539 : : .call = parse_vc_conf,
7540 : : },
7541 : : [ACTION_MODIFY_FIELD_SRC_CLASS_ID] = {
7542 : : .name = "src_class",
7543 : : .help = "source field class ID",
7544 : : .next = NEXT(action_modify_field_src,
7545 : : NEXT_ENTRY(COMMON_UNSIGNED)),
7546 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_action_modify_field,
7547 : : src.class_id)),
7548 : : .call = parse_vc_conf,
7549 : : },
7550 : : [ACTION_MODIFY_FIELD_SRC_OFFSET] = {
7551 : : .name = "src_offset",
7552 : : .help = "source field bit offset",
7553 : : .next = NEXT(action_modify_field_src,
7554 : : NEXT_ENTRY(COMMON_UNSIGNED)),
7555 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
7556 : : src.offset)),
7557 : : .call = parse_vc_conf,
7558 : : },
7559 : : [ACTION_MODIFY_FIELD_SRC_VALUE] = {
7560 : : .name = "src_value",
7561 : : .help = "source immediate value",
7562 : : .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_WIDTH),
7563 : : NEXT_ENTRY(COMMON_HEX)),
7564 : : .args = ARGS(ARGS_ENTRY_ARB(0, 0),
7565 : : ARGS_ENTRY_ARB(0, 0),
7566 : : ARGS_ENTRY(struct rte_flow_action_modify_field,
7567 : : src.value)),
7568 : : .call = parse_vc_conf,
7569 : : },
7570 : : [ACTION_MODIFY_FIELD_SRC_POINTER] = {
7571 : : .name = "src_ptr",
7572 : : .help = "pointer to source immediate value",
7573 : : .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_WIDTH),
7574 : : NEXT_ENTRY(COMMON_HEX)),
7575 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
7576 : : src.pvalue),
7577 : : ARGS_ENTRY_ARB(0, 0),
7578 : : ARGS_ENTRY_ARB
7579 : : (sizeof(struct rte_flow_action_modify_field),
7580 : : FLOW_FIELD_PATTERN_SIZE)),
7581 : : .call = parse_vc_conf,
7582 : : },
7583 : : [ACTION_MODIFY_FIELD_WIDTH] = {
7584 : : .name = "width",
7585 : : .help = "number of bits to copy",
7586 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT),
7587 : : NEXT_ENTRY(COMMON_UNSIGNED)),
7588 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
7589 : : width)),
7590 : : .call = parse_vc_conf,
7591 : : },
7592 : : [ACTION_SEND_TO_KERNEL] = {
7593 : : .name = "send_to_kernel",
7594 : : .help = "send packets to kernel",
7595 : : .priv = PRIV_ACTION(SEND_TO_KERNEL, 0),
7596 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7597 : : .call = parse_vc,
7598 : : },
7599 : : [ACTION_IPV6_EXT_REMOVE] = {
7600 : : .name = "ipv6_ext_remove",
7601 : : .help = "IPv6 extension type, defined by set ipv6_ext_remove",
7602 : : .priv = PRIV_ACTION(IPV6_EXT_REMOVE,
7603 : : sizeof(struct action_ipv6_ext_remove_data)),
7604 : : .next = NEXT(action_ipv6_ext_remove),
7605 : : .call = parse_vc_action_ipv6_ext_remove,
7606 : : },
7607 : : [ACTION_IPV6_EXT_REMOVE_INDEX] = {
7608 : : .name = "index",
7609 : : .help = "the index of ipv6_ext_remove",
7610 : : .next = NEXT(NEXT_ENTRY(ACTION_IPV6_EXT_REMOVE_INDEX_VALUE)),
7611 : : },
7612 : : [ACTION_IPV6_EXT_REMOVE_INDEX_VALUE] = {
7613 : : .name = "{index}",
7614 : : .type = "UNSIGNED",
7615 : : .help = "unsigned integer value",
7616 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7617 : : .call = parse_vc_action_ipv6_ext_remove_index,
7618 : : .comp = comp_set_ipv6_ext_index,
7619 : : },
7620 : : [ACTION_IPV6_EXT_PUSH] = {
7621 : : .name = "ipv6_ext_push",
7622 : : .help = "IPv6 extension data, defined by set ipv6_ext_push",
7623 : : .priv = PRIV_ACTION(IPV6_EXT_PUSH,
7624 : : sizeof(struct action_ipv6_ext_push_data)),
7625 : : .next = NEXT(action_ipv6_ext_push),
7626 : : .call = parse_vc_action_ipv6_ext_push,
7627 : : },
7628 : : [ACTION_IPV6_EXT_PUSH_INDEX] = {
7629 : : .name = "index",
7630 : : .help = "the index of ipv6_ext_push",
7631 : : .next = NEXT(NEXT_ENTRY(ACTION_IPV6_EXT_PUSH_INDEX_VALUE)),
7632 : : },
7633 : : [ACTION_IPV6_EXT_PUSH_INDEX_VALUE] = {
7634 : : .name = "{index}",
7635 : : .type = "UNSIGNED",
7636 : : .help = "unsigned integer value",
7637 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7638 : : .call = parse_vc_action_ipv6_ext_push_index,
7639 : : .comp = comp_set_ipv6_ext_index,
7640 : : },
7641 : : [ACTION_NAT64] = {
7642 : : .name = "nat64",
7643 : : .help = "NAT64 IP headers translation",
7644 : : .priv = PRIV_ACTION(NAT64, sizeof(struct rte_flow_action_nat64)),
7645 : : .next = NEXT(action_nat64),
7646 : : .call = parse_vc,
7647 : : },
7648 : : [ACTION_NAT64_MODE] = {
7649 : : .name = "type",
7650 : : .help = "NAT64 translation type",
7651 : : .next = NEXT(action_nat64, NEXT_ENTRY(COMMON_UNSIGNED)),
7652 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_nat64, type)),
7653 : : .call = parse_vc_conf,
7654 : : },
7655 : : [ACTION_JUMP_TO_TABLE_INDEX] = {
7656 : : .name = "jump_to_table_index",
7657 : : .help = "Jump to table index",
7658 : : .priv = PRIV_ACTION(JUMP_TO_TABLE_INDEX,
7659 : : sizeof(struct rte_flow_action_jump_to_table_index)),
7660 : : .next = NEXT(action_jump_to_table_index),
7661 : : .call = parse_vc,
7662 : : },
7663 : : [ACTION_JUMP_TO_TABLE_INDEX_TABLE] = {
7664 : : .name = "table",
7665 : : .help = "table id to redirect traffic to",
7666 : : .next = NEXT(action_jump_to_table_index,
7667 : : NEXT_ENTRY(ACTION_JUMP_TO_TABLE_INDEX_TABLE_VALUE)),
7668 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump_to_table_index, table)),
7669 : : .call = parse_vc_conf,
7670 : : },
7671 : : [ACTION_JUMP_TO_TABLE_INDEX_TABLE_VALUE] = {
7672 : : .name = "{table_id}",
7673 : : .type = "TABLE_ID",
7674 : : .help = "table id for jump action",
7675 : : .call = parse_jump_table_id,
7676 : : .comp = comp_table_id,
7677 : : },
7678 : : [ACTION_JUMP_TO_TABLE_INDEX_INDEX] = {
7679 : : .name = "index",
7680 : : .help = "rule index to redirect traffic to",
7681 : : .next = NEXT(action_jump_to_table_index, NEXT_ENTRY(COMMON_UNSIGNED)),
7682 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump_to_table_index, index)),
7683 : : .call = parse_vc_conf,
7684 : : },
7685 : :
7686 : : /* Top level command. */
7687 : : [SET] = {
7688 : : .name = "set",
7689 : : .help = "set raw encap/decap/sample data",
7690 : : .type = "set raw_encap|raw_decap <index> <pattern>"
7691 : : " or set sample_actions <index> <action>",
7692 : : .next = NEXT(NEXT_ENTRY
7693 : : (SET_RAW_ENCAP,
7694 : : SET_RAW_DECAP,
7695 : : SET_SAMPLE_ACTIONS,
7696 : : SET_IPV6_EXT_REMOVE,
7697 : : SET_IPV6_EXT_PUSH)),
7698 : : .call = parse_set_init,
7699 : : },
7700 : : /* Sub-level commands. */
7701 : : [SET_RAW_ENCAP] = {
7702 : : .name = "raw_encap",
7703 : : .help = "set raw encap data",
7704 : : .next = NEXT(next_set_raw),
7705 : : .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
7706 : : (offsetof(struct buffer, port),
7707 : : sizeof(((struct buffer *)0)->port),
7708 : : 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
7709 : : .call = parse_set_raw_encap_decap,
7710 : : },
7711 : : [SET_RAW_DECAP] = {
7712 : : .name = "raw_decap",
7713 : : .help = "set raw decap data",
7714 : : .next = NEXT(next_set_raw),
7715 : : .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
7716 : : (offsetof(struct buffer, port),
7717 : : sizeof(((struct buffer *)0)->port),
7718 : : 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
7719 : : .call = parse_set_raw_encap_decap,
7720 : : },
7721 : : [SET_RAW_INDEX] = {
7722 : : .name = "{index}",
7723 : : .type = "COMMON_UNSIGNED",
7724 : : .help = "index of raw_encap/raw_decap data",
7725 : : .next = NEXT(next_item),
7726 : : .call = parse_port,
7727 : : },
7728 : : [SET_SAMPLE_INDEX] = {
7729 : : .name = "{index}",
7730 : : .type = "UNSIGNED",
7731 : : .help = "index of sample actions",
7732 : : .next = NEXT(next_action_sample),
7733 : : .call = parse_port,
7734 : : },
7735 : : [SET_SAMPLE_ACTIONS] = {
7736 : : .name = "sample_actions",
7737 : : .help = "set sample actions list",
7738 : : .next = NEXT(NEXT_ENTRY(SET_SAMPLE_INDEX)),
7739 : : .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
7740 : : (offsetof(struct buffer, port),
7741 : : sizeof(((struct buffer *)0)->port),
7742 : : 0, RAW_SAMPLE_CONFS_MAX_NUM - 1)),
7743 : : .call = parse_set_sample_action,
7744 : : },
7745 : : [SET_IPV6_EXT_PUSH] = {
7746 : : .name = "ipv6_ext_push",
7747 : : .help = "set IPv6 extension header",
7748 : : .next = NEXT(NEXT_ENTRY(SET_IPV6_EXT_INDEX)),
7749 : : .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
7750 : : (offsetof(struct buffer, port),
7751 : : sizeof(((struct buffer *)0)->port),
7752 : : 0, IPV6_EXT_PUSH_CONFS_MAX_NUM - 1)),
7753 : : .call = parse_set_ipv6_ext_action,
7754 : : },
7755 : : [SET_IPV6_EXT_REMOVE] = {
7756 : : .name = "ipv6_ext_remove",
7757 : : .help = "set IPv6 extension header",
7758 : : .next = NEXT(NEXT_ENTRY(SET_IPV6_EXT_INDEX)),
7759 : : .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
7760 : : (offsetof(struct buffer, port),
7761 : : sizeof(((struct buffer *)0)->port),
7762 : : 0, IPV6_EXT_PUSH_CONFS_MAX_NUM - 1)),
7763 : : .call = parse_set_ipv6_ext_action,
7764 : : },
7765 : : [SET_IPV6_EXT_INDEX] = {
7766 : : .name = "{index}",
7767 : : .type = "UNSIGNED",
7768 : : .help = "index of ipv6 extension push/remove actions",
7769 : : .next = NEXT(item_ipv6_push_ext),
7770 : : .call = parse_port,
7771 : : },
7772 : : [ITEM_IPV6_PUSH_REMOVE_EXT] = {
7773 : : .name = "ipv6_ext",
7774 : : .help = "set IPv6 extension header",
7775 : : .priv = PRIV_ITEM(IPV6_EXT,
7776 : : sizeof(struct rte_flow_item_ipv6_ext)),
7777 : : .next = NEXT(item_ipv6_push_ext_type),
7778 : : .call = parse_vc,
7779 : : },
7780 : : [ITEM_IPV6_PUSH_REMOVE_EXT_TYPE] = {
7781 : : .name = "type",
7782 : : .help = "set IPv6 extension type",
7783 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_ext,
7784 : : next_hdr)),
7785 : : .next = NEXT(item_ipv6_push_ext_header, NEXT_ENTRY(COMMON_UNSIGNED),
7786 : : item_param),
7787 : : },
7788 : : [ACTION_SET_TAG] = {
7789 : : .name = "set_tag",
7790 : : .help = "set tag",
7791 : : .priv = PRIV_ACTION(SET_TAG,
7792 : : sizeof(struct rte_flow_action_set_tag)),
7793 : : .next = NEXT(action_set_tag),
7794 : : .call = parse_vc,
7795 : : },
7796 : : [ACTION_SET_TAG_INDEX] = {
7797 : : .name = "index",
7798 : : .help = "index of tag array",
7799 : : .next = NEXT(action_set_tag, NEXT_ENTRY(COMMON_UNSIGNED)),
7800 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_set_tag, index)),
7801 : : .call = parse_vc_conf,
7802 : : },
7803 : : [ACTION_SET_TAG_DATA] = {
7804 : : .name = "data",
7805 : : .help = "tag value",
7806 : : .next = NEXT(action_set_tag, NEXT_ENTRY(COMMON_UNSIGNED)),
7807 : : .args = ARGS(ARGS_ENTRY
7808 : : (struct rte_flow_action_set_tag, data)),
7809 : : .call = parse_vc_conf,
7810 : : },
7811 : : [ACTION_SET_TAG_MASK] = {
7812 : : .name = "mask",
7813 : : .help = "mask for tag value",
7814 : : .next = NEXT(action_set_tag, NEXT_ENTRY(COMMON_UNSIGNED)),
7815 : : .args = ARGS(ARGS_ENTRY
7816 : : (struct rte_flow_action_set_tag, mask)),
7817 : : .call = parse_vc_conf,
7818 : : },
7819 : : [ACTION_SET_META] = {
7820 : : .name = "set_meta",
7821 : : .help = "set metadata",
7822 : : .priv = PRIV_ACTION(SET_META,
7823 : : sizeof(struct rte_flow_action_set_meta)),
7824 : : .next = NEXT(action_set_meta),
7825 : : .call = parse_vc_action_set_meta,
7826 : : },
7827 : : [ACTION_SET_META_DATA] = {
7828 : : .name = "data",
7829 : : .help = "metadata value",
7830 : : .next = NEXT(action_set_meta, NEXT_ENTRY(COMMON_UNSIGNED)),
7831 : : .args = ARGS(ARGS_ENTRY
7832 : : (struct rte_flow_action_set_meta, data)),
7833 : : .call = parse_vc_conf,
7834 : : },
7835 : : [ACTION_SET_META_MASK] = {
7836 : : .name = "mask",
7837 : : .help = "mask for metadata value",
7838 : : .next = NEXT(action_set_meta, NEXT_ENTRY(COMMON_UNSIGNED)),
7839 : : .args = ARGS(ARGS_ENTRY
7840 : : (struct rte_flow_action_set_meta, mask)),
7841 : : .call = parse_vc_conf,
7842 : : },
7843 : : [ACTION_SET_IPV4_DSCP] = {
7844 : : .name = "set_ipv4_dscp",
7845 : : .help = "set DSCP value",
7846 : : .priv = PRIV_ACTION(SET_IPV4_DSCP,
7847 : : sizeof(struct rte_flow_action_set_dscp)),
7848 : : .next = NEXT(action_set_ipv4_dscp),
7849 : : .call = parse_vc,
7850 : : },
7851 : : [ACTION_SET_IPV4_DSCP_VALUE] = {
7852 : : .name = "dscp_value",
7853 : : .help = "new IPv4 DSCP value to set",
7854 : : .next = NEXT(action_set_ipv4_dscp, NEXT_ENTRY(COMMON_UNSIGNED)),
7855 : : .args = ARGS(ARGS_ENTRY
7856 : : (struct rte_flow_action_set_dscp, dscp)),
7857 : : .call = parse_vc_conf,
7858 : : },
7859 : : [ACTION_SET_IPV6_DSCP] = {
7860 : : .name = "set_ipv6_dscp",
7861 : : .help = "set DSCP value",
7862 : : .priv = PRIV_ACTION(SET_IPV6_DSCP,
7863 : : sizeof(struct rte_flow_action_set_dscp)),
7864 : : .next = NEXT(action_set_ipv6_dscp),
7865 : : .call = parse_vc,
7866 : : },
7867 : : [ACTION_SET_IPV6_DSCP_VALUE] = {
7868 : : .name = "dscp_value",
7869 : : .help = "new IPv6 DSCP value to set",
7870 : : .next = NEXT(action_set_ipv6_dscp, NEXT_ENTRY(COMMON_UNSIGNED)),
7871 : : .args = ARGS(ARGS_ENTRY
7872 : : (struct rte_flow_action_set_dscp, dscp)),
7873 : : .call = parse_vc_conf,
7874 : : },
7875 : : [ACTION_AGE] = {
7876 : : .name = "age",
7877 : : .help = "set a specific metadata header",
7878 : : .next = NEXT(action_age),
7879 : : .priv = PRIV_ACTION(AGE,
7880 : : sizeof(struct rte_flow_action_age)),
7881 : : .call = parse_vc,
7882 : : },
7883 : : [ACTION_AGE_TIMEOUT] = {
7884 : : .name = "timeout",
7885 : : .help = "flow age timeout value",
7886 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_age,
7887 : : timeout, 24)),
7888 : : .next = NEXT(action_age, NEXT_ENTRY(COMMON_UNSIGNED)),
7889 : : .call = parse_vc_conf,
7890 : : },
7891 : : [ACTION_AGE_UPDATE] = {
7892 : : .name = "age_update",
7893 : : .help = "update aging parameter",
7894 : : .next = NEXT(action_age_update),
7895 : : .priv = PRIV_ACTION(AGE,
7896 : : sizeof(struct rte_flow_update_age)),
7897 : : .call = parse_vc,
7898 : : },
7899 : : [ACTION_AGE_UPDATE_TIMEOUT] = {
7900 : : .name = "timeout",
7901 : : .help = "age timeout update value",
7902 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_update_age,
7903 : : timeout, 24)),
7904 : : .next = NEXT(action_age_update, NEXT_ENTRY(COMMON_UNSIGNED)),
7905 : : .call = parse_vc_conf_timeout,
7906 : : },
7907 : : [ACTION_AGE_UPDATE_TOUCH] = {
7908 : : .name = "touch",
7909 : : .help = "this flow is touched",
7910 : : .next = NEXT(action_age_update, NEXT_ENTRY(COMMON_BOOLEAN)),
7911 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_update_age,
7912 : : touch, 1)),
7913 : : .call = parse_vc_conf,
7914 : : },
7915 : : [ACTION_SAMPLE] = {
7916 : : .name = "sample",
7917 : : .help = "set a sample action",
7918 : : .next = NEXT(action_sample),
7919 : : .priv = PRIV_ACTION(SAMPLE,
7920 : : sizeof(struct action_sample_data)),
7921 : : .call = parse_vc_action_sample,
7922 : : },
7923 : : [ACTION_SAMPLE_RATIO] = {
7924 : : .name = "ratio",
7925 : : .help = "flow sample ratio value",
7926 : : .next = NEXT(action_sample, NEXT_ENTRY(COMMON_UNSIGNED)),
7927 : : .args = ARGS(ARGS_ENTRY_ARB
7928 : : (offsetof(struct action_sample_data, conf) +
7929 : : offsetof(struct rte_flow_action_sample, ratio),
7930 : : sizeof(((struct rte_flow_action_sample *)0)->
7931 : : ratio))),
7932 : : },
7933 : : [ACTION_SAMPLE_INDEX] = {
7934 : : .name = "index",
7935 : : .help = "the index of sample actions list",
7936 : : .next = NEXT(NEXT_ENTRY(ACTION_SAMPLE_INDEX_VALUE)),
7937 : : },
7938 : : [ACTION_SAMPLE_INDEX_VALUE] = {
7939 : : .name = "{index}",
7940 : : .type = "COMMON_UNSIGNED",
7941 : : .help = "unsigned integer value",
7942 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7943 : : .call = parse_vc_action_sample_index,
7944 : : .comp = comp_set_sample_index,
7945 : : },
7946 : : [ACTION_CONNTRACK] = {
7947 : : .name = "conntrack",
7948 : : .help = "create a conntrack object",
7949 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7950 : : .priv = PRIV_ACTION(CONNTRACK,
7951 : : sizeof(struct rte_flow_action_conntrack)),
7952 : : .call = parse_vc,
7953 : : },
7954 : : [ACTION_CONNTRACK_UPDATE] = {
7955 : : .name = "conntrack_update",
7956 : : .help = "update a conntrack object",
7957 : : .next = NEXT(action_update_conntrack),
7958 : : .priv = PRIV_ACTION(CONNTRACK,
7959 : : sizeof(struct rte_flow_modify_conntrack)),
7960 : : .call = parse_vc,
7961 : : },
7962 : : [ACTION_CONNTRACK_UPDATE_DIR] = {
7963 : : .name = "dir",
7964 : : .help = "update a conntrack object direction",
7965 : : .next = NEXT(action_update_conntrack),
7966 : : .call = parse_vc_action_conntrack_update,
7967 : : },
7968 : : [ACTION_CONNTRACK_UPDATE_CTX] = {
7969 : : .name = "ctx",
7970 : : .help = "update a conntrack object context",
7971 : : .next = NEXT(action_update_conntrack),
7972 : : .call = parse_vc_action_conntrack_update,
7973 : : },
7974 : : [ACTION_PORT_REPRESENTOR] = {
7975 : : .name = "port_representor",
7976 : : .help = "at embedded switch level, send matching traffic to the given ethdev",
7977 : : .priv = PRIV_ACTION(PORT_REPRESENTOR,
7978 : : sizeof(struct rte_flow_action_ethdev)),
7979 : : .next = NEXT(action_port_representor),
7980 : : .call = parse_vc,
7981 : : },
7982 : : [ACTION_PORT_REPRESENTOR_PORT_ID] = {
7983 : : .name = "port_id",
7984 : : .help = "ethdev port ID",
7985 : : .next = NEXT(action_port_representor,
7986 : : NEXT_ENTRY(COMMON_UNSIGNED)),
7987 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_ethdev,
7988 : : port_id)),
7989 : : .call = parse_vc_conf,
7990 : : },
7991 : : [ACTION_REPRESENTED_PORT] = {
7992 : : .name = "represented_port",
7993 : : .help = "at embedded switch level, send matching traffic to the entity represented by the given ethdev",
7994 : : .priv = PRIV_ACTION(REPRESENTED_PORT,
7995 : : sizeof(struct rte_flow_action_ethdev)),
7996 : : .next = NEXT(action_represented_port),
7997 : : .call = parse_vc,
7998 : : },
7999 : : [ACTION_REPRESENTED_PORT_ETHDEV_PORT_ID] = {
8000 : : .name = "ethdev_port_id",
8001 : : .help = "ethdev port ID",
8002 : : .next = NEXT(action_represented_port,
8003 : : NEXT_ENTRY(COMMON_UNSIGNED)),
8004 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_ethdev,
8005 : : port_id)),
8006 : : .call = parse_vc_conf,
8007 : : },
8008 : : /* Indirect action destroy arguments. */
8009 : : [INDIRECT_ACTION_DESTROY_ID] = {
8010 : : .name = "action_id",
8011 : : .help = "specify a indirect action id to destroy",
8012 : : .next = NEXT(next_ia_destroy_attr,
8013 : : NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
8014 : : .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
8015 : : args.ia_destroy.action_id)),
8016 : : .call = parse_ia_destroy,
8017 : : },
8018 : : /* Indirect action create arguments. */
8019 : : [INDIRECT_ACTION_CREATE_ID] = {
8020 : : .name = "action_id",
8021 : : .help = "specify a indirect action id to create",
8022 : : .next = NEXT(next_ia_create_attr,
8023 : : NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
8024 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
8025 : : },
8026 : : [ACTION_INDIRECT] = {
8027 : : .name = "indirect",
8028 : : .help = "apply indirect action by id",
8029 : : .priv = PRIV_ACTION(INDIRECT, 0),
8030 : : .next = NEXT(next_ia),
8031 : : .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
8032 : : .call = parse_vc,
8033 : : },
8034 : : [ACTION_INDIRECT_LIST] = {
8035 : : .name = "indirect_list",
8036 : : .help = "apply indirect list action by id",
8037 : : .priv = PRIV_ACTION(INDIRECT_LIST,
8038 : : sizeof(struct
8039 : : rte_flow_action_indirect_list)),
8040 : : .next = NEXT(next_ial),
8041 : : .call = parse_vc,
8042 : : },
8043 : : [ACTION_INDIRECT_LIST_HANDLE] = {
8044 : : .name = "handle",
8045 : : .help = "indirect list handle",
8046 : : .next = NEXT(next_ial, NEXT_ENTRY(INDIRECT_LIST_ACTION_ID2PTR_HANDLE)),
8047 : : .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
8048 : : },
8049 : : [ACTION_INDIRECT_LIST_CONF] = {
8050 : : .name = "conf",
8051 : : .help = "indirect list configuration",
8052 : : .next = NEXT(next_ial, NEXT_ENTRY(INDIRECT_LIST_ACTION_ID2PTR_CONF)),
8053 : : .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
8054 : : },
8055 : : [INDIRECT_LIST_ACTION_ID2PTR_HANDLE] = {
8056 : : .type = "UNSIGNED",
8057 : : .help = "unsigned integer value",
8058 : : .call = parse_indlst_id2ptr,
8059 : : .comp = comp_none,
8060 : : },
8061 : : [INDIRECT_LIST_ACTION_ID2PTR_CONF] = {
8062 : : .type = "UNSIGNED",
8063 : : .help = "unsigned integer value",
8064 : : .call = parse_indlst_id2ptr,
8065 : : .comp = comp_none,
8066 : : },
8067 : : [ACTION_SHARED_INDIRECT] = {
8068 : : .name = "shared_indirect",
8069 : : .help = "apply indirect action by id and port",
8070 : : .priv = PRIV_ACTION(INDIRECT, 0),
8071 : : .next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_PORT)),
8072 : : .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t)),
8073 : : ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
8074 : : .call = parse_vc,
8075 : : },
8076 : : [INDIRECT_ACTION_PORT] = {
8077 : : .name = "{indirect_action_port}",
8078 : : .type = "INDIRECT_ACTION_PORT",
8079 : : .help = "indirect action port",
8080 : : .next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_ID2PTR)),
8081 : : .call = parse_ia_port,
8082 : : .comp = comp_none,
8083 : : },
8084 : : [INDIRECT_ACTION_ID2PTR] = {
8085 : : .name = "{action_id}",
8086 : : .type = "INDIRECT_ACTION_ID",
8087 : : .help = "indirect action id",
8088 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
8089 : : .call = parse_ia_id2ptr,
8090 : : .comp = comp_none,
8091 : : },
8092 : : [INDIRECT_ACTION_INGRESS] = {
8093 : : .name = "ingress",
8094 : : .help = "affect rule to ingress",
8095 : : .next = NEXT(next_ia_create_attr),
8096 : : .call = parse_ia,
8097 : : },
8098 : : [INDIRECT_ACTION_EGRESS] = {
8099 : : .name = "egress",
8100 : : .help = "affect rule to egress",
8101 : : .next = NEXT(next_ia_create_attr),
8102 : : .call = parse_ia,
8103 : : },
8104 : : [INDIRECT_ACTION_TRANSFER] = {
8105 : : .name = "transfer",
8106 : : .help = "affect rule to transfer",
8107 : : .next = NEXT(next_ia_create_attr),
8108 : : .call = parse_ia,
8109 : : },
8110 : : [INDIRECT_ACTION_SPEC] = {
8111 : : .name = "action",
8112 : : .help = "specify action to create indirect handle",
8113 : : .next = NEXT(next_action),
8114 : : },
8115 : : [INDIRECT_ACTION_LIST] = {
8116 : : .name = "list",
8117 : : .help = "specify actions for indirect handle list",
8118 : : .next = NEXT(NEXT_ENTRY(ACTIONS, END)),
8119 : : .call = parse_ia,
8120 : : },
8121 : : [INDIRECT_ACTION_FLOW_CONF] = {
8122 : : .name = "flow_conf",
8123 : : .help = "specify actions configuration for indirect handle list",
8124 : : .next = NEXT(NEXT_ENTRY(ACTIONS, END)),
8125 : : .call = parse_ia,
8126 : : },
8127 : : [ACTION_POL_G] = {
8128 : : .name = "g_actions",
8129 : : .help = "submit a list of associated actions for green",
8130 : : .next = NEXT(next_action),
8131 : : .call = parse_mp,
8132 : : },
8133 : : [ACTION_POL_Y] = {
8134 : : .name = "y_actions",
8135 : : .help = "submit a list of associated actions for yellow",
8136 : : .next = NEXT(next_action),
8137 : : },
8138 : : [ACTION_POL_R] = {
8139 : : .name = "r_actions",
8140 : : .help = "submit a list of associated actions for red",
8141 : : .next = NEXT(next_action),
8142 : : },
8143 : : [ACTION_QUOTA_CREATE] = {
8144 : : .name = "quota_create",
8145 : : .help = "create quota action",
8146 : : .priv = PRIV_ACTION(QUOTA,
8147 : : sizeof(struct rte_flow_action_quota)),
8148 : : .next = NEXT(action_quota_create),
8149 : : .call = parse_vc
8150 : : },
8151 : : [ACTION_QUOTA_CREATE_LIMIT] = {
8152 : : .name = "limit",
8153 : : .help = "quota limit",
8154 : : .next = NEXT(action_quota_create, NEXT_ENTRY(COMMON_UNSIGNED)),
8155 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_quota, quota)),
8156 : : .call = parse_vc_conf
8157 : : },
8158 : : [ACTION_QUOTA_CREATE_MODE] = {
8159 : : .name = "mode",
8160 : : .help = "quota mode",
8161 : : .next = NEXT(action_quota_create,
8162 : : NEXT_ENTRY(ACTION_QUOTA_CREATE_MODE_NAME)),
8163 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_quota, mode)),
8164 : : .call = parse_vc_conf
8165 : : },
8166 : : [ACTION_QUOTA_CREATE_MODE_NAME] = {
8167 : : .name = "mode_name",
8168 : : .help = "quota mode name",
8169 : : .call = parse_quota_mode_name,
8170 : : .comp = comp_quota_mode_name
8171 : : },
8172 : : [ACTION_QUOTA_QU] = {
8173 : : .name = "quota_update",
8174 : : .help = "update quota action",
8175 : : .priv = PRIV_ACTION(QUOTA,
8176 : : sizeof(struct rte_flow_update_quota)),
8177 : : .next = NEXT(action_quota_update),
8178 : : .call = parse_vc
8179 : : },
8180 : : [ACTION_QUOTA_QU_LIMIT] = {
8181 : : .name = "limit",
8182 : : .help = "quota limit",
8183 : : .next = NEXT(action_quota_update, NEXT_ENTRY(COMMON_UNSIGNED)),
8184 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_update_quota, quota)),
8185 : : .call = parse_vc_conf
8186 : : },
8187 : : [ACTION_QUOTA_QU_UPDATE_OP] = {
8188 : : .name = "update_op",
8189 : : .help = "query update op SET|ADD",
8190 : : .next = NEXT(action_quota_update,
8191 : : NEXT_ENTRY(ACTION_QUOTA_QU_UPDATE_OP_NAME)),
8192 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_update_quota, op)),
8193 : : .call = parse_vc_conf
8194 : : },
8195 : : [ACTION_QUOTA_QU_UPDATE_OP_NAME] = {
8196 : : .name = "update_op_name",
8197 : : .help = "quota update op name",
8198 : : .call = parse_quota_update_name,
8199 : : .comp = comp_quota_update_name
8200 : : },
8201 : :
8202 : : /* Top-level command. */
8203 : : [ADD] = {
8204 : : .name = "add",
8205 : : .type = "port meter policy {port_id} {arg}",
8206 : : .help = "add port meter policy",
8207 : : .next = NEXT(NEXT_ENTRY(ITEM_POL_PORT)),
8208 : : .call = parse_init,
8209 : : },
8210 : : /* Sub-level commands. */
8211 : : [ITEM_POL_PORT] = {
8212 : : .name = "port",
8213 : : .help = "add port meter policy",
8214 : : .next = NEXT(NEXT_ENTRY(ITEM_POL_METER)),
8215 : : },
8216 : : [ITEM_POL_METER] = {
8217 : : .name = "meter",
8218 : : .help = "add port meter policy",
8219 : : .next = NEXT(NEXT_ENTRY(ITEM_POL_POLICY)),
8220 : : },
8221 : : [ITEM_POL_POLICY] = {
8222 : : .name = "policy",
8223 : : .help = "add port meter policy",
8224 : : .next = NEXT(NEXT_ENTRY(ACTION_POL_R),
8225 : : NEXT_ENTRY(ACTION_POL_Y),
8226 : : NEXT_ENTRY(ACTION_POL_G),
8227 : : NEXT_ENTRY(COMMON_POLICY_ID),
8228 : : NEXT_ENTRY(COMMON_PORT_ID)),
8229 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.policy.policy_id),
8230 : : ARGS_ENTRY(struct buffer, port)),
8231 : : .call = parse_mp,
8232 : : },
8233 : : [ITEM_AGGR_AFFINITY] = {
8234 : : .name = "aggr_affinity",
8235 : : .help = "match on the aggregated port receiving the packets",
8236 : : .priv = PRIV_ITEM(AGGR_AFFINITY,
8237 : : sizeof(struct rte_flow_item_aggr_affinity)),
8238 : : .next = NEXT(item_aggr_affinity),
8239 : : .call = parse_vc,
8240 : : },
8241 : : [ITEM_AGGR_AFFINITY_VALUE] = {
8242 : : .name = "affinity",
8243 : : .help = "aggregated affinity value",
8244 : : .next = NEXT(item_aggr_affinity, NEXT_ENTRY(COMMON_UNSIGNED),
8245 : : item_param),
8246 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_aggr_affinity,
8247 : : affinity)),
8248 : : },
8249 : : [ITEM_TX_QUEUE] = {
8250 : : .name = "tx_queue",
8251 : : .help = "match on the tx queue of send packet",
8252 : : .priv = PRIV_ITEM(TX_QUEUE,
8253 : : sizeof(struct rte_flow_item_tx_queue)),
8254 : : .next = NEXT(item_tx_queue),
8255 : : .call = parse_vc,
8256 : : },
8257 : : [ITEM_TX_QUEUE_VALUE] = {
8258 : : .name = "tx_queue_value",
8259 : : .help = "tx queue value",
8260 : : .next = NEXT(item_tx_queue, NEXT_ENTRY(COMMON_UNSIGNED),
8261 : : item_param),
8262 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tx_queue,
8263 : : tx_queue)),
8264 : : },
8265 : : };
8266 : :
8267 : : /** Remove and return last entry from argument stack. */
8268 : : static const struct arg *
8269 : : pop_args(struct context *ctx)
8270 : : {
8271 : 0 : return ctx->args_num ? ctx->args[--ctx->args_num] : NULL;
8272 : : }
8273 : :
8274 : : /** Add entry on top of the argument stack. */
8275 : : static int
8276 : : push_args(struct context *ctx, const struct arg *arg)
8277 : : {
8278 : 0 : if (ctx->args_num == CTX_STACK_SIZE)
8279 : : return -1;
8280 : 0 : ctx->args[ctx->args_num++] = arg;
8281 : 0 : return 0;
8282 : : }
8283 : :
8284 : : /** Spread value into buffer according to bit-mask. */
8285 : : static size_t
8286 : 0 : arg_entry_bf_fill(void *dst, uintmax_t val, const struct arg *arg)
8287 : : {
8288 : 0 : uint32_t i = arg->size;
8289 : : uint32_t end = 0;
8290 : : int sub = 1;
8291 : : int add = 0;
8292 : : size_t len = 0;
8293 : :
8294 : 0 : if (!arg->mask)
8295 : : return 0;
8296 : : #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
8297 : 0 : if (!arg->hton) {
8298 : : i = 0;
8299 : : end = arg->size;
8300 : : sub = 0;
8301 : : add = 1;
8302 : : }
8303 : : #endif
8304 : 0 : while (i != end) {
8305 : : unsigned int shift = 0;
8306 : 0 : uint8_t *buf = (uint8_t *)dst + arg->offset + (i -= sub);
8307 : :
8308 : 0 : for (shift = 0; arg->mask[i] >> shift; ++shift) {
8309 : 0 : if (!(arg->mask[i] & (1 << shift)))
8310 : 0 : continue;
8311 : 0 : ++len;
8312 : 0 : if (!dst)
8313 : 0 : continue;
8314 : 0 : *buf &= ~(1 << shift);
8315 : 0 : *buf |= (val & 1) << shift;
8316 : 0 : val >>= 1;
8317 : : }
8318 : 0 : i += add;
8319 : : }
8320 : : return len;
8321 : : }
8322 : :
8323 : : /** Compare a string with a partial one of a given length. */
8324 : : static int
8325 : 0 : strcmp_partial(const char *full, const char *partial, size_t partial_len)
8326 : : {
8327 : 0 : int r = strncmp(full, partial, partial_len);
8328 : :
8329 : 0 : if (r)
8330 : : return r;
8331 : 0 : if (strlen(full) <= partial_len)
8332 : : return 0;
8333 : 0 : return full[partial_len];
8334 : : }
8335 : :
8336 : : /**
8337 : : * Parse a prefix length and generate a bit-mask.
8338 : : *
8339 : : * Last argument (ctx->args) is retrieved to determine mask size, storage
8340 : : * location and whether the result must use network byte ordering.
8341 : : */
8342 : : static int
8343 : 0 : parse_prefix(struct context *ctx, const struct token *token,
8344 : : const char *str, unsigned int len,
8345 : : void *buf, unsigned int size)
8346 : : {
8347 : : const struct arg *arg = pop_args(ctx);
8348 : : static const uint8_t conv[] = { 0x00, 0x80, 0xc0, 0xe0, 0xf0,
8349 : : 0xf8, 0xfc, 0xfe, 0xff };
8350 : : char *end;
8351 : : uintmax_t u;
8352 : : unsigned int bytes;
8353 : : unsigned int extra;
8354 : :
8355 : : (void)token;
8356 : : /* Argument is expected. */
8357 : 0 : if (!arg)
8358 : 0 : return -1;
8359 : 0 : errno = 0;
8360 : 0 : u = strtoumax(str, &end, 0);
8361 : 0 : if (errno || (size_t)(end - str) != len)
8362 : 0 : goto error;
8363 : 0 : if (arg->mask) {
8364 : : uintmax_t v = 0;
8365 : :
8366 : 0 : extra = arg_entry_bf_fill(NULL, 0, arg);
8367 : 0 : if (u > extra)
8368 : 0 : goto error;
8369 : 0 : if (!ctx->object)
8370 : 0 : return len;
8371 : 0 : extra -= u;
8372 : 0 : while (u--) {
8373 : 0 : v <<= 1;
8374 : 0 : v |= 1;
8375 : : }
8376 : 0 : v <<= extra;
8377 : 0 : if (!arg_entry_bf_fill(ctx->object, v, arg) ||
8378 : 0 : !arg_entry_bf_fill(ctx->objmask, -1, arg))
8379 : 0 : goto error;
8380 : 0 : return len;
8381 : : }
8382 : 0 : bytes = u / 8;
8383 : 0 : extra = u % 8;
8384 : 0 : size = arg->size;
8385 : 0 : if (bytes > size || bytes + !!extra > size)
8386 : 0 : goto error;
8387 : 0 : if (!ctx->object)
8388 : 0 : return len;
8389 : 0 : buf = (uint8_t *)ctx->object + arg->offset;
8390 : : #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
8391 : 0 : if (!arg->hton) {
8392 : 0 : memset((uint8_t *)buf + size - bytes, 0xff, bytes);
8393 : 0 : memset(buf, 0x00, size - bytes);
8394 : 0 : if (extra)
8395 : 0 : ((uint8_t *)buf)[size - bytes - 1] = conv[extra];
8396 : : } else
8397 : : #endif
8398 : : {
8399 : : memset(buf, 0xff, bytes);
8400 : 0 : memset((uint8_t *)buf + bytes, 0x00, size - bytes);
8401 : 0 : if (extra)
8402 : 0 : ((uint8_t *)buf)[bytes] = conv[extra];
8403 : : }
8404 : 0 : if (ctx->objmask)
8405 : 0 : memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
8406 : 0 : return len;
8407 : 0 : error:
8408 : : push_args(ctx, arg);
8409 : : return -1;
8410 : : }
8411 : :
8412 : : /** Default parsing function for token name matching. */
8413 : : static int
8414 : : parse_default(struct context *ctx, const struct token *token,
8415 : : const char *str, unsigned int len,
8416 : : void *buf, unsigned int size)
8417 : : {
8418 : : (void)ctx;
8419 : : (void)buf;
8420 : : (void)size;
8421 : 0 : if (strcmp_partial(token->name, str, len))
8422 : : return -1;
8423 : 0 : return len;
8424 : : }
8425 : :
8426 : : /** Parse flow command, initialize output buffer for subsequent tokens. */
8427 : : static int
8428 : 0 : parse_init(struct context *ctx, const struct token *token,
8429 : : const char *str, unsigned int len,
8430 : : void *buf, unsigned int size)
8431 : : {
8432 : : struct buffer *out = buf;
8433 : :
8434 : : /* Token name must match. */
8435 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8436 : : return -1;
8437 : : /* Nothing else to do if there is no buffer. */
8438 : 0 : if (!out)
8439 : : return len;
8440 : : /* Make sure buffer is large enough. */
8441 : 0 : if (size < sizeof(*out))
8442 : : return -1;
8443 : : /* Initialize buffer. */
8444 : : memset(out, 0x00, sizeof(*out));
8445 : 0 : memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
8446 : 0 : ctx->objdata = 0;
8447 : 0 : ctx->object = out;
8448 : 0 : ctx->objmask = NULL;
8449 : 0 : return len;
8450 : : }
8451 : :
8452 : : /** Parse tokens for indirect action commands. */
8453 : : static int
8454 : 0 : parse_ia(struct context *ctx, const struct token *token,
8455 : : const char *str, unsigned int len,
8456 : : void *buf, unsigned int size)
8457 : : {
8458 : : struct buffer *out = buf;
8459 : :
8460 : : /* Token name must match. */
8461 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8462 : : return -1;
8463 : : /* Nothing else to do if there is no buffer. */
8464 : 0 : if (!out)
8465 : : return len;
8466 : 0 : if (!out->command) {
8467 : 0 : if (ctx->curr != INDIRECT_ACTION)
8468 : : return -1;
8469 : 0 : if (sizeof(*out) > size)
8470 : : return -1;
8471 : 0 : out->command = ctx->curr;
8472 : 0 : ctx->objdata = 0;
8473 : 0 : ctx->object = out;
8474 : 0 : ctx->objmask = NULL;
8475 : 0 : out->args.vc.data = (uint8_t *)out + size;
8476 : 0 : return len;
8477 : : }
8478 : 0 : switch (ctx->curr) {
8479 : 0 : case INDIRECT_ACTION_CREATE:
8480 : : case INDIRECT_ACTION_UPDATE:
8481 : : case INDIRECT_ACTION_QUERY_UPDATE:
8482 : 0 : out->args.vc.actions =
8483 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8484 : : sizeof(double));
8485 : 0 : out->args.vc.attr.group = UINT32_MAX;
8486 : : /* fallthrough */
8487 : 0 : case INDIRECT_ACTION_QUERY:
8488 : 0 : out->command = ctx->curr;
8489 : 0 : ctx->objdata = 0;
8490 : 0 : ctx->object = out;
8491 : 0 : ctx->objmask = NULL;
8492 : 0 : return len;
8493 : 0 : case INDIRECT_ACTION_EGRESS:
8494 : 0 : out->args.vc.attr.egress = 1;
8495 : 0 : return len;
8496 : 0 : case INDIRECT_ACTION_INGRESS:
8497 : 0 : out->args.vc.attr.ingress = 1;
8498 : 0 : return len;
8499 : 0 : case INDIRECT_ACTION_TRANSFER:
8500 : 0 : out->args.vc.attr.transfer = 1;
8501 : 0 : return len;
8502 : 0 : case INDIRECT_ACTION_QU_MODE:
8503 : 0 : return len;
8504 : 0 : case INDIRECT_ACTION_LIST:
8505 : 0 : out->command = INDIRECT_ACTION_LIST_CREATE;
8506 : 0 : return len;
8507 : 0 : case INDIRECT_ACTION_FLOW_CONF:
8508 : 0 : out->command = INDIRECT_ACTION_FLOW_CONF_CREATE;
8509 : 0 : return len;
8510 : : default:
8511 : : return -1;
8512 : : }
8513 : : }
8514 : :
8515 : :
8516 : : /** Parse tokens for indirect action destroy command. */
8517 : : static int
8518 : 0 : parse_ia_destroy(struct context *ctx, const struct token *token,
8519 : : const char *str, unsigned int len,
8520 : : void *buf, unsigned int size)
8521 : : {
8522 : : struct buffer *out = buf;
8523 : : uint32_t *action_id;
8524 : :
8525 : : /* Token name must match. */
8526 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8527 : : return -1;
8528 : : /* Nothing else to do if there is no buffer. */
8529 : 0 : if (!out)
8530 : : return len;
8531 : 0 : if (!out->command || out->command == INDIRECT_ACTION) {
8532 : 0 : if (ctx->curr != INDIRECT_ACTION_DESTROY)
8533 : : return -1;
8534 : 0 : if (sizeof(*out) > size)
8535 : : return -1;
8536 : 0 : out->command = ctx->curr;
8537 : 0 : ctx->objdata = 0;
8538 : 0 : ctx->object = out;
8539 : 0 : ctx->objmask = NULL;
8540 : 0 : out->args.ia_destroy.action_id =
8541 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8542 : : sizeof(double));
8543 : 0 : return len;
8544 : : }
8545 : 0 : action_id = out->args.ia_destroy.action_id
8546 : 0 : + out->args.ia_destroy.action_id_n++;
8547 : 0 : if ((uint8_t *)action_id > (uint8_t *)out + size)
8548 : : return -1;
8549 : 0 : ctx->objdata = 0;
8550 : 0 : ctx->object = action_id;
8551 : 0 : ctx->objmask = NULL;
8552 : 0 : return len;
8553 : : }
8554 : :
8555 : : /** Parse tokens for indirect action commands. */
8556 : : static int
8557 : 0 : parse_qia(struct context *ctx, const struct token *token,
8558 : : const char *str, unsigned int len,
8559 : : void *buf, unsigned int size)
8560 : : {
8561 : : struct buffer *out = buf;
8562 : :
8563 : : /* Token name must match. */
8564 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8565 : : return -1;
8566 : : /* Nothing else to do if there is no buffer. */
8567 : 0 : if (!out)
8568 : : return len;
8569 : 0 : if (!out->command) {
8570 : 0 : if (ctx->curr != QUEUE)
8571 : : return -1;
8572 : 0 : if (sizeof(*out) > size)
8573 : : return -1;
8574 : 0 : out->args.vc.data = (uint8_t *)out + size;
8575 : 0 : return len;
8576 : : }
8577 : 0 : switch (ctx->curr) {
8578 : 0 : case QUEUE_INDIRECT_ACTION:
8579 : 0 : return len;
8580 : 0 : case QUEUE_INDIRECT_ACTION_CREATE:
8581 : : case QUEUE_INDIRECT_ACTION_UPDATE:
8582 : : case QUEUE_INDIRECT_ACTION_QUERY_UPDATE:
8583 : 0 : out->args.vc.actions =
8584 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8585 : : sizeof(double));
8586 : 0 : out->args.vc.attr.group = UINT32_MAX;
8587 : : /* fallthrough */
8588 : 0 : case QUEUE_INDIRECT_ACTION_QUERY:
8589 : 0 : out->command = ctx->curr;
8590 : 0 : ctx->objdata = 0;
8591 : 0 : ctx->object = out;
8592 : 0 : ctx->objmask = NULL;
8593 : 0 : return len;
8594 : 0 : case QUEUE_INDIRECT_ACTION_EGRESS:
8595 : 0 : out->args.vc.attr.egress = 1;
8596 : 0 : return len;
8597 : 0 : case QUEUE_INDIRECT_ACTION_INGRESS:
8598 : 0 : out->args.vc.attr.ingress = 1;
8599 : 0 : return len;
8600 : 0 : case QUEUE_INDIRECT_ACTION_TRANSFER:
8601 : 0 : out->args.vc.attr.transfer = 1;
8602 : 0 : return len;
8603 : 0 : case QUEUE_INDIRECT_ACTION_CREATE_POSTPONE:
8604 : 0 : return len;
8605 : 0 : case QUEUE_INDIRECT_ACTION_QU_MODE:
8606 : 0 : return len;
8607 : 0 : case QUEUE_INDIRECT_ACTION_LIST:
8608 : 0 : out->command = QUEUE_INDIRECT_ACTION_LIST_CREATE;
8609 : 0 : return len;
8610 : : default:
8611 : : return -1;
8612 : : }
8613 : : }
8614 : :
8615 : : /** Parse tokens for indirect action destroy command. */
8616 : : static int
8617 : 0 : parse_qia_destroy(struct context *ctx, const struct token *token,
8618 : : const char *str, unsigned int len,
8619 : : void *buf, unsigned int size)
8620 : : {
8621 : : struct buffer *out = buf;
8622 : : uint32_t *action_id;
8623 : :
8624 : : /* Token name must match. */
8625 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8626 : : return -1;
8627 : : /* Nothing else to do if there is no buffer. */
8628 : 0 : if (!out)
8629 : : return len;
8630 : 0 : if (!out->command || out->command == QUEUE) {
8631 : 0 : if (ctx->curr != QUEUE_INDIRECT_ACTION_DESTROY)
8632 : : return -1;
8633 : 0 : if (sizeof(*out) > size)
8634 : : return -1;
8635 : 0 : out->command = ctx->curr;
8636 : 0 : ctx->objdata = 0;
8637 : 0 : ctx->object = out;
8638 : 0 : ctx->objmask = NULL;
8639 : 0 : out->args.ia_destroy.action_id =
8640 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8641 : : sizeof(double));
8642 : 0 : return len;
8643 : : }
8644 : 0 : switch (ctx->curr) {
8645 : 0 : case QUEUE_INDIRECT_ACTION:
8646 : 0 : out->command = ctx->curr;
8647 : 0 : ctx->objdata = 0;
8648 : 0 : ctx->object = out;
8649 : 0 : ctx->objmask = NULL;
8650 : 0 : return len;
8651 : 0 : case QUEUE_INDIRECT_ACTION_DESTROY_ID:
8652 : 0 : action_id = out->args.ia_destroy.action_id
8653 : 0 : + out->args.ia_destroy.action_id_n++;
8654 : 0 : if ((uint8_t *)action_id > (uint8_t *)out + size)
8655 : : return -1;
8656 : 0 : ctx->objdata = 0;
8657 : 0 : ctx->object = action_id;
8658 : 0 : ctx->objmask = NULL;
8659 : 0 : return len;
8660 : 0 : case QUEUE_INDIRECT_ACTION_DESTROY_POSTPONE:
8661 : 0 : return len;
8662 : : default:
8663 : : return -1;
8664 : : }
8665 : : }
8666 : :
8667 : : /** Parse tokens for meter policy action commands. */
8668 : : static int
8669 : 0 : parse_mp(struct context *ctx, const struct token *token,
8670 : : const char *str, unsigned int len,
8671 : : void *buf, unsigned int size)
8672 : : {
8673 : : struct buffer *out = buf;
8674 : :
8675 : : /* Token name must match. */
8676 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8677 : : return -1;
8678 : : /* Nothing else to do if there is no buffer. */
8679 : 0 : if (!out)
8680 : : return len;
8681 : 0 : if (!out->command) {
8682 : 0 : if (ctx->curr != ITEM_POL_POLICY)
8683 : : return -1;
8684 : 0 : if (sizeof(*out) > size)
8685 : : return -1;
8686 : 0 : out->command = ctx->curr;
8687 : 0 : ctx->objdata = 0;
8688 : 0 : ctx->object = out;
8689 : 0 : ctx->objmask = NULL;
8690 : 0 : out->args.vc.data = (uint8_t *)out + size;
8691 : 0 : return len;
8692 : : }
8693 : 0 : switch (ctx->curr) {
8694 : 0 : case ACTION_POL_G:
8695 : 0 : out->args.vc.actions =
8696 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8697 : : sizeof(double));
8698 : 0 : out->command = ctx->curr;
8699 : 0 : ctx->objdata = 0;
8700 : 0 : ctx->object = out;
8701 : 0 : ctx->objmask = NULL;
8702 : 0 : return len;
8703 : : default:
8704 : : return -1;
8705 : : }
8706 : : }
8707 : :
8708 : : /** Parse tokens for validate/create commands. */
8709 : : static int
8710 : 0 : parse_vc(struct context *ctx, const struct token *token,
8711 : : const char *str, unsigned int len,
8712 : : void *buf, unsigned int size)
8713 : : {
8714 : : struct buffer *out = buf;
8715 : : uint8_t *data;
8716 : : uint32_t data_size;
8717 : :
8718 : : /* Token name must match. */
8719 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8720 : : return -1;
8721 : : /* Nothing else to do if there is no buffer. */
8722 : 0 : if (!out)
8723 : : return len;
8724 : 0 : if (!out->command) {
8725 : 0 : if (ctx->curr != VALIDATE && ctx->curr != CREATE &&
8726 : 0 : ctx->curr != PATTERN_TEMPLATE_CREATE &&
8727 : 0 : ctx->curr != ACTIONS_TEMPLATE_CREATE &&
8728 : : ctx->curr != UPDATE)
8729 : : return -1;
8730 : 0 : if (ctx->curr == UPDATE)
8731 : 0 : out->args.vc.pattern =
8732 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8733 : : sizeof(double));
8734 : 0 : if (sizeof(*out) > size)
8735 : : return -1;
8736 : 0 : out->command = ctx->curr;
8737 : 0 : ctx->objdata = 0;
8738 : 0 : ctx->object = out;
8739 : 0 : ctx->objmask = NULL;
8740 : 0 : out->args.vc.data = (uint8_t *)out + size;
8741 : 0 : return len;
8742 : : }
8743 : 0 : ctx->objdata = 0;
8744 : 0 : switch (ctx->curr) {
8745 : 0 : default:
8746 : 0 : ctx->object = &out->args.vc.attr;
8747 : 0 : break;
8748 : 0 : case VC_TUNNEL_SET:
8749 : : case VC_TUNNEL_MATCH:
8750 : 0 : ctx->object = &out->args.vc.tunnel_ops;
8751 : 0 : break;
8752 : 0 : case VC_USER_ID:
8753 : 0 : ctx->object = out;
8754 : 0 : break;
8755 : : }
8756 : 0 : ctx->objmask = NULL;
8757 : 0 : switch (ctx->curr) {
8758 : : case VC_GROUP:
8759 : : case VC_PRIORITY:
8760 : : case VC_USER_ID:
8761 : : return len;
8762 : 0 : case VC_TUNNEL_SET:
8763 : 0 : out->args.vc.tunnel_ops.enabled = 1;
8764 : 0 : out->args.vc.tunnel_ops.actions = 1;
8765 : 0 : return len;
8766 : 0 : case VC_TUNNEL_MATCH:
8767 : 0 : out->args.vc.tunnel_ops.enabled = 1;
8768 : 0 : out->args.vc.tunnel_ops.items = 1;
8769 : 0 : return len;
8770 : 0 : case VC_INGRESS:
8771 : 0 : out->args.vc.attr.ingress = 1;
8772 : 0 : return len;
8773 : 0 : case VC_EGRESS:
8774 : 0 : out->args.vc.attr.egress = 1;
8775 : 0 : return len;
8776 : 0 : case VC_TRANSFER:
8777 : 0 : out->args.vc.attr.transfer = 1;
8778 : 0 : return len;
8779 : 0 : case ITEM_PATTERN:
8780 : 0 : out->args.vc.pattern =
8781 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8782 : : sizeof(double));
8783 : 0 : ctx->object = out->args.vc.pattern;
8784 : 0 : ctx->objmask = NULL;
8785 : 0 : return len;
8786 : 0 : case ITEM_END:
8787 : 0 : if ((out->command == VALIDATE || out->command == CREATE) &&
8788 : : ctx->last)
8789 : : return -1;
8790 : 0 : if (out->command == PATTERN_TEMPLATE_CREATE &&
8791 : 0 : !ctx->last)
8792 : : return -1;
8793 : : break;
8794 : 0 : case ACTIONS:
8795 : 0 : out->args.vc.actions = out->args.vc.pattern ?
8796 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)
8797 : : (out->args.vc.pattern +
8798 : : out->args.vc.pattern_n),
8799 : 0 : sizeof(double)) :
8800 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8801 : : sizeof(double));
8802 : 0 : ctx->object = out->args.vc.actions;
8803 : 0 : ctx->objmask = NULL;
8804 : 0 : return len;
8805 : 0 : case VC_IS_USER_ID:
8806 : 0 : out->args.vc.user_id = true;
8807 : 0 : return len;
8808 : 0 : default:
8809 : 0 : if (!token->priv)
8810 : : return -1;
8811 : : break;
8812 : : }
8813 : 0 : if (!out->args.vc.actions) {
8814 : 0 : const struct parse_item_priv *priv = token->priv;
8815 : 0 : struct rte_flow_item *item =
8816 : 0 : out->args.vc.pattern + out->args.vc.pattern_n;
8817 : :
8818 : 0 : data_size = priv->size * 3; /* spec, last, mask */
8819 : 0 : data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
8820 : : (out->args.vc.data - data_size),
8821 : : sizeof(double));
8822 : 0 : if ((uint8_t *)item + sizeof(*item) > data)
8823 : : return -1;
8824 : 0 : *item = (struct rte_flow_item){
8825 : 0 : .type = priv->type,
8826 : : };
8827 : 0 : ++out->args.vc.pattern_n;
8828 : 0 : ctx->object = item;
8829 : 0 : ctx->objmask = NULL;
8830 : : } else {
8831 : 0 : const struct parse_action_priv *priv = token->priv;
8832 : 0 : struct rte_flow_action *action =
8833 : 0 : out->args.vc.actions + out->args.vc.actions_n;
8834 : :
8835 : 0 : data_size = priv->size; /* configuration */
8836 : 0 : data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
8837 : : (out->args.vc.data - data_size),
8838 : : sizeof(double));
8839 : 0 : if ((uint8_t *)action + sizeof(*action) > data)
8840 : : return -1;
8841 : 0 : *action = (struct rte_flow_action){
8842 : 0 : .type = priv->type,
8843 : 0 : .conf = data_size ? data : NULL,
8844 : : };
8845 : 0 : ++out->args.vc.actions_n;
8846 : 0 : ctx->object = action;
8847 : 0 : ctx->objmask = NULL;
8848 : : }
8849 : 0 : memset(data, 0, data_size);
8850 : 0 : out->args.vc.data = data;
8851 : 0 : ctx->objdata = data_size;
8852 : 0 : return len;
8853 : : }
8854 : :
8855 : : /** Parse pattern item parameter type. */
8856 : : static int
8857 : 0 : parse_vc_spec(struct context *ctx, const struct token *token,
8858 : : const char *str, unsigned int len,
8859 : : void *buf, unsigned int size)
8860 : : {
8861 : : struct buffer *out = buf;
8862 : : struct rte_flow_item *item;
8863 : : uint32_t data_size;
8864 : : int index;
8865 : : int objmask = 0;
8866 : :
8867 : : (void)size;
8868 : : /* Token name must match. */
8869 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8870 : : return -1;
8871 : : /* Parse parameter types. */
8872 : 0 : switch (ctx->curr) {
8873 : : case ITEM_PARAM_IS:
8874 : : index = 0;
8875 : : objmask = 1;
8876 : 0 : break;
8877 : 0 : case ITEM_PARAM_SPEC:
8878 : : index = 0;
8879 : 0 : break;
8880 : 0 : case ITEM_PARAM_LAST:
8881 : : index = 1;
8882 : 0 : break;
8883 : 0 : case ITEM_PARAM_PREFIX:
8884 : : /* Modify next token to expect a prefix. */
8885 : 0 : if (ctx->next_num < 2)
8886 : 0 : return -1;
8887 : 0 : ctx->next[ctx->next_num - 2] = NEXT_ENTRY(COMMON_PREFIX);
8888 : : /* Fall through. */
8889 : : case ITEM_PARAM_MASK:
8890 : : index = 2;
8891 : : break;
8892 : : default:
8893 : : return -1;
8894 : : }
8895 : : /* Nothing else to do if there is no buffer. */
8896 : 0 : if (!out)
8897 : : return len;
8898 : 0 : if (!out->args.vc.pattern_n)
8899 : : return -1;
8900 : 0 : item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
8901 : 0 : data_size = ctx->objdata / 3; /* spec, last, mask */
8902 : : /* Point to selected object. */
8903 : 0 : ctx->object = out->args.vc.data + (data_size * index);
8904 : 0 : if (objmask) {
8905 : 0 : ctx->objmask = out->args.vc.data + (data_size * 2); /* mask */
8906 : 0 : item->mask = ctx->objmask;
8907 : : } else
8908 : 0 : ctx->objmask = NULL;
8909 : : /* Update relevant item pointer. */
8910 : 0 : *((const void **[]){ &item->spec, &item->last, &item->mask })[index] =
8911 : : ctx->object;
8912 : 0 : return len;
8913 : : }
8914 : :
8915 : : /** Parse action configuration field. */
8916 : : static int
8917 : 0 : parse_vc_conf(struct context *ctx, const struct token *token,
8918 : : const char *str, unsigned int len,
8919 : : void *buf, unsigned int size)
8920 : : {
8921 : : struct buffer *out = buf;
8922 : :
8923 : : (void)size;
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 : 0 : return len;
8934 : : }
8935 : :
8936 : : /** Parse action configuration field. */
8937 : : static int
8938 : 0 : parse_vc_conf_timeout(struct context *ctx, const struct token *token,
8939 : : const char *str, unsigned int len,
8940 : : void *buf, unsigned int size)
8941 : : {
8942 : : struct buffer *out = buf;
8943 : : struct rte_flow_update_age *update;
8944 : :
8945 : : (void)size;
8946 : 0 : if (ctx->curr != ACTION_AGE_UPDATE_TIMEOUT)
8947 : : return -1;
8948 : : /* Token name must match. */
8949 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8950 : : return -1;
8951 : : /* Nothing else to do if there is no buffer. */
8952 : 0 : if (!out)
8953 : : return len;
8954 : : /* Point to selected object. */
8955 : 0 : ctx->object = out->args.vc.data;
8956 : 0 : ctx->objmask = NULL;
8957 : : /* Update the timeout is valid. */
8958 : : update = (struct rte_flow_update_age *)out->args.vc.data;
8959 : 0 : update->timeout_valid = 1;
8960 : 0 : return len;
8961 : : }
8962 : :
8963 : : /** Parse eCPRI common header type field. */
8964 : : static int
8965 : 0 : parse_vc_item_ecpri_type(struct context *ctx, const struct token *token,
8966 : : const char *str, unsigned int len,
8967 : : void *buf, unsigned int size)
8968 : : {
8969 : : struct rte_flow_item_ecpri *ecpri;
8970 : : struct rte_flow_item_ecpri *ecpri_mask;
8971 : : struct rte_flow_item *item;
8972 : : uint32_t data_size;
8973 : : uint8_t msg_type;
8974 : : struct buffer *out = buf;
8975 : : const struct arg *arg;
8976 : :
8977 : : (void)size;
8978 : : /* Token name must match. */
8979 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8980 : : return -1;
8981 : 0 : switch (ctx->curr) {
8982 : : case ITEM_ECPRI_COMMON_TYPE_IQ_DATA:
8983 : : msg_type = RTE_ECPRI_MSG_TYPE_IQ_DATA;
8984 : : break;
8985 : : case ITEM_ECPRI_COMMON_TYPE_RTC_CTRL:
8986 : : msg_type = RTE_ECPRI_MSG_TYPE_RTC_CTRL;
8987 : : break;
8988 : : case ITEM_ECPRI_COMMON_TYPE_DLY_MSR:
8989 : : msg_type = RTE_ECPRI_MSG_TYPE_DLY_MSR;
8990 : : break;
8991 : : default:
8992 : : return -1;
8993 : : }
8994 : 0 : if (!ctx->object)
8995 : : return len;
8996 : : arg = pop_args(ctx);
8997 : 0 : if (!arg)
8998 : 0 : return -1;
8999 : 0 : ecpri = (struct rte_flow_item_ecpri *)out->args.vc.data;
9000 : 0 : ecpri->hdr.common.type = msg_type;
9001 : 0 : data_size = ctx->objdata / 3; /* spec, last, mask */
9002 : 0 : ecpri_mask = (struct rte_flow_item_ecpri *)(out->args.vc.data +
9003 : 0 : (data_size * 2));
9004 : 0 : ecpri_mask->hdr.common.type = 0xFF;
9005 : 0 : if (arg->hton) {
9006 : 0 : ecpri->hdr.common.u32 = rte_cpu_to_be_32(ecpri->hdr.common.u32);
9007 : 0 : ecpri_mask->hdr.common.u32 =
9008 : 0 : rte_cpu_to_be_32(ecpri_mask->hdr.common.u32);
9009 : : }
9010 : 0 : item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
9011 : 0 : item->spec = ecpri;
9012 : 0 : item->mask = ecpri_mask;
9013 : 0 : return len;
9014 : : }
9015 : :
9016 : : /** Parse L2TPv2 common header type field. */
9017 : : static int
9018 : 0 : parse_vc_item_l2tpv2_type(struct context *ctx, const struct token *token,
9019 : : const char *str, unsigned int len,
9020 : : void *buf, unsigned int size)
9021 : : {
9022 : : struct rte_flow_item_l2tpv2 *l2tpv2;
9023 : : struct rte_flow_item_l2tpv2 *l2tpv2_mask;
9024 : : struct rte_flow_item *item;
9025 : : uint32_t data_size;
9026 : : uint16_t msg_type = 0;
9027 : : struct buffer *out = buf;
9028 : : const struct arg *arg;
9029 : :
9030 : : (void)size;
9031 : : /* Token name must match. */
9032 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
9033 : : return -1;
9034 : 0 : switch (ctx->curr) {
9035 : : case ITEM_L2TPV2_TYPE_DATA:
9036 : : msg_type |= RTE_L2TPV2_MSG_TYPE_DATA;
9037 : : break;
9038 : : case ITEM_L2TPV2_TYPE_DATA_L:
9039 : : msg_type |= RTE_L2TPV2_MSG_TYPE_DATA_L;
9040 : : break;
9041 : : case ITEM_L2TPV2_TYPE_DATA_S:
9042 : : msg_type |= RTE_L2TPV2_MSG_TYPE_DATA_S;
9043 : : break;
9044 : : case ITEM_L2TPV2_TYPE_DATA_O:
9045 : : msg_type |= RTE_L2TPV2_MSG_TYPE_DATA_O;
9046 : : break;
9047 : : case ITEM_L2TPV2_TYPE_DATA_L_S:
9048 : : msg_type |= RTE_L2TPV2_MSG_TYPE_DATA_L_S;
9049 : : break;
9050 : : case ITEM_L2TPV2_TYPE_CTRL:
9051 : : msg_type |= RTE_L2TPV2_MSG_TYPE_CONTROL;
9052 : : break;
9053 : : default:
9054 : : return -1;
9055 : : }
9056 : 0 : if (!ctx->object)
9057 : : return len;
9058 : : arg = pop_args(ctx);
9059 : 0 : if (!arg)
9060 : 0 : return -1;
9061 : 0 : l2tpv2 = (struct rte_flow_item_l2tpv2 *)out->args.vc.data;
9062 : 0 : l2tpv2->hdr.common.flags_version |= msg_type;
9063 : 0 : data_size = ctx->objdata / 3; /* spec, last, mask */
9064 : 0 : l2tpv2_mask = (struct rte_flow_item_l2tpv2 *)(out->args.vc.data +
9065 : 0 : (data_size * 2));
9066 : 0 : l2tpv2_mask->hdr.common.flags_version = 0xFFFF;
9067 : 0 : if (arg->hton) {
9068 : 0 : l2tpv2->hdr.common.flags_version =
9069 : 0 : rte_cpu_to_be_16(l2tpv2->hdr.common.flags_version);
9070 : 0 : l2tpv2_mask->hdr.common.flags_version =
9071 : 0 : rte_cpu_to_be_16(l2tpv2_mask->hdr.common.flags_version);
9072 : : }
9073 : 0 : item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
9074 : 0 : item->spec = l2tpv2;
9075 : 0 : item->mask = l2tpv2_mask;
9076 : 0 : return len;
9077 : : }
9078 : :
9079 : : /** Parse operation for compare match item. */
9080 : : static int
9081 : 0 : parse_vc_compare_op(struct context *ctx, const struct token *token,
9082 : : const char *str, unsigned int len, void *buf,
9083 : : unsigned int size)
9084 : : {
9085 : : struct rte_flow_item_compare *compare_item;
9086 : : unsigned int i;
9087 : :
9088 : : (void)token;
9089 : : (void)buf;
9090 : : (void)size;
9091 : 0 : if (ctx->curr != ITEM_COMPARE_OP_VALUE)
9092 : : return -1;
9093 : 0 : for (i = 0; compare_ops[i]; ++i)
9094 : 0 : if (!strcmp_partial(compare_ops[i], str, len))
9095 : : break;
9096 : 0 : if (!compare_ops[i])
9097 : : return -1;
9098 : 0 : if (!ctx->object)
9099 : 0 : return len;
9100 : : compare_item = ctx->object;
9101 : 0 : compare_item->operation = (enum rte_flow_item_compare_op)i;
9102 : 0 : return len;
9103 : : }
9104 : :
9105 : : /** Parse id for compare match item. */
9106 : : static int
9107 : 0 : parse_vc_compare_field_id(struct context *ctx, const struct token *token,
9108 : : const char *str, unsigned int len, void *buf,
9109 : : unsigned int size)
9110 : : {
9111 : : struct rte_flow_item_compare *compare_item;
9112 : : unsigned int i;
9113 : :
9114 : : (void)token;
9115 : : (void)buf;
9116 : : (void)size;
9117 : 0 : if (ctx->curr != ITEM_COMPARE_FIELD_A_TYPE_VALUE &&
9118 : : ctx->curr != ITEM_COMPARE_FIELD_B_TYPE_VALUE)
9119 : : return -1;
9120 : 0 : for (i = 0; flow_field_ids[i]; ++i)
9121 : 0 : if (!strcmp_partial(flow_field_ids[i], str, len))
9122 : : break;
9123 : 0 : if (!flow_field_ids[i])
9124 : : return -1;
9125 : 0 : if (!ctx->object)
9126 : 0 : return len;
9127 : : compare_item = ctx->object;
9128 : 0 : if (ctx->curr == ITEM_COMPARE_FIELD_A_TYPE_VALUE)
9129 : 0 : compare_item->a.field = (enum rte_flow_field_id)i;
9130 : : else
9131 : 0 : compare_item->b.field = (enum rte_flow_field_id)i;
9132 : 0 : return len;
9133 : : }
9134 : :
9135 : : /** Parse level for compare match item. */
9136 : : static int
9137 : 0 : parse_vc_compare_field_level(struct context *ctx, const struct token *token,
9138 : : const char *str, unsigned int len, void *buf,
9139 : : unsigned int size)
9140 : : {
9141 : : struct rte_flow_item_compare *compare_item;
9142 : : struct flex_item *fp = NULL;
9143 : : uint32_t val;
9144 : : struct buffer *out = buf;
9145 : : char *end;
9146 : :
9147 : : (void)token;
9148 : : (void)size;
9149 : 0 : if (ctx->curr != ITEM_COMPARE_FIELD_A_LEVEL_VALUE &&
9150 : : ctx->curr != ITEM_COMPARE_FIELD_B_LEVEL_VALUE)
9151 : : return -1;
9152 : 0 : if (!ctx->object)
9153 : 0 : return len;
9154 : : compare_item = ctx->object;
9155 : 0 : errno = 0;
9156 : 0 : val = strtoumax(str, &end, 0);
9157 : 0 : if (errno || (size_t)(end - str) != len)
9158 : : return -1;
9159 : : /* No need to validate action template mask value */
9160 : 0 : if (out->args.vc.masks) {
9161 : 0 : if (ctx->curr == ITEM_COMPARE_FIELD_A_LEVEL_VALUE)
9162 : 0 : compare_item->a.level = val;
9163 : : else
9164 : 0 : compare_item->b.level = val;
9165 : 0 : return len;
9166 : : }
9167 : 0 : if ((ctx->curr == ITEM_COMPARE_FIELD_A_LEVEL_VALUE &&
9168 : 0 : compare_item->a.field == RTE_FLOW_FIELD_FLEX_ITEM) ||
9169 : 0 : (ctx->curr == ITEM_COMPARE_FIELD_B_LEVEL_VALUE &&
9170 : 0 : compare_item->b.field == RTE_FLOW_FIELD_FLEX_ITEM)) {
9171 : 0 : if (val >= FLEX_MAX_PARSERS_NUM) {
9172 : : printf("Bad flex item handle\n");
9173 : 0 : return -1;
9174 : : }
9175 : 0 : fp = flex_items[ctx->port][val];
9176 : 0 : if (!fp) {
9177 : : printf("Bad flex item handle\n");
9178 : 0 : return -1;
9179 : : }
9180 : : }
9181 : 0 : if (ctx->curr == ITEM_COMPARE_FIELD_A_LEVEL_VALUE) {
9182 : 0 : if (compare_item->a.field != RTE_FLOW_FIELD_FLEX_ITEM)
9183 : 0 : compare_item->a.level = val;
9184 : : else
9185 : 0 : compare_item->a.flex_handle = fp->flex_handle;
9186 : 0 : } else if (ctx->curr == ITEM_COMPARE_FIELD_B_LEVEL_VALUE) {
9187 : 0 : if (compare_item->b.field != RTE_FLOW_FIELD_FLEX_ITEM)
9188 : 0 : compare_item->b.level = val;
9189 : : else
9190 : 0 : compare_item->b.flex_handle = fp->flex_handle;
9191 : : }
9192 : 0 : return len;
9193 : : }
9194 : :
9195 : : /** Parse meter color action type. */
9196 : : static int
9197 : 0 : parse_vc_action_meter_color_type(struct context *ctx, const struct token *token,
9198 : : const char *str, unsigned int len,
9199 : : void *buf, unsigned int size)
9200 : : {
9201 : : struct rte_flow_action *action_data;
9202 : : struct rte_flow_action_meter_color *conf;
9203 : : enum rte_color color;
9204 : :
9205 : : (void)buf;
9206 : : (void)size;
9207 : : /* Token name must match. */
9208 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
9209 : : return -1;
9210 : 0 : switch (ctx->curr) {
9211 : : case ACTION_METER_COLOR_GREEN:
9212 : : color = RTE_COLOR_GREEN;
9213 : : break;
9214 : : case ACTION_METER_COLOR_YELLOW:
9215 : : color = RTE_COLOR_YELLOW;
9216 : : break;
9217 : : case ACTION_METER_COLOR_RED:
9218 : : color = RTE_COLOR_RED;
9219 : : break;
9220 : : default:
9221 : : return -1;
9222 : : }
9223 : :
9224 : 0 : if (!ctx->object)
9225 : : return len;
9226 : : action_data = ctx->object;
9227 : 0 : conf = (struct rte_flow_action_meter_color *)
9228 : : (uintptr_t)(action_data->conf);
9229 : 0 : conf->color = color;
9230 : 0 : return len;
9231 : : }
9232 : :
9233 : : /** Parse RSS action. */
9234 : : static int
9235 : 0 : parse_vc_action_rss(struct context *ctx, const struct token *token,
9236 : : const char *str, unsigned int len,
9237 : : void *buf, unsigned int size)
9238 : : {
9239 : : struct buffer *out = buf;
9240 : : struct rte_flow_action *action;
9241 : : struct action_rss_data *action_rss_data;
9242 : : unsigned int i;
9243 : : int ret;
9244 : :
9245 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
9246 : 0 : if (ret < 0)
9247 : : return ret;
9248 : : /* Nothing else to do if there is no buffer. */
9249 : 0 : if (!out)
9250 : : return ret;
9251 : 0 : if (!out->args.vc.actions_n)
9252 : : return -1;
9253 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
9254 : : /* Point to selected object. */
9255 : 0 : ctx->object = out->args.vc.data;
9256 : 0 : ctx->objmask = NULL;
9257 : : /* Set up default configuration. */
9258 : : action_rss_data = ctx->object;
9259 : 0 : *action_rss_data = (struct action_rss_data){
9260 : : .conf = (struct rte_flow_action_rss){
9261 : : .func = RTE_ETH_HASH_FUNCTION_DEFAULT,
9262 : : .level = 0,
9263 : : .types = rss_hf,
9264 : : .key_len = 0,
9265 : 0 : .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM),
9266 : : .key = NULL,
9267 : 0 : .queue = action_rss_data->queue,
9268 : : },
9269 : : .queue = { 0 },
9270 : : };
9271 : 0 : for (i = 0; i < action_rss_data->conf.queue_num; ++i)
9272 : 0 : action_rss_data->queue[i] = i;
9273 : 0 : action->conf = &action_rss_data->conf;
9274 : 0 : return ret;
9275 : : }
9276 : :
9277 : : /**
9278 : : * Parse func field for RSS action.
9279 : : *
9280 : : * The RTE_ETH_HASH_FUNCTION_* value to assign is derived from the
9281 : : * ACTION_RSS_FUNC_* index that called this function.
9282 : : */
9283 : : static int
9284 : 0 : parse_vc_action_rss_func(struct context *ctx, const struct token *token,
9285 : : const char *str, unsigned int len,
9286 : : void *buf, unsigned int size)
9287 : : {
9288 : : struct action_rss_data *action_rss_data;
9289 : : enum rte_eth_hash_function func;
9290 : :
9291 : : (void)buf;
9292 : : (void)size;
9293 : : /* Token name must match. */
9294 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
9295 : : return -1;
9296 : 0 : switch (ctx->curr) {
9297 : : case ACTION_RSS_FUNC_DEFAULT:
9298 : : func = RTE_ETH_HASH_FUNCTION_DEFAULT;
9299 : : break;
9300 : : case ACTION_RSS_FUNC_TOEPLITZ:
9301 : : func = RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9302 : : break;
9303 : : case ACTION_RSS_FUNC_SIMPLE_XOR:
9304 : : func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9305 : : break;
9306 : : case ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ:
9307 : : func = RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
9308 : : break;
9309 : : default:
9310 : : return -1;
9311 : : }
9312 : 0 : if (!ctx->object)
9313 : : return len;
9314 : : action_rss_data = ctx->object;
9315 : 0 : action_rss_data->conf.func = func;
9316 : 0 : return len;
9317 : : }
9318 : :
9319 : : /**
9320 : : * Parse type field for RSS action.
9321 : : *
9322 : : * Valid tokens are type field names and the "end" token.
9323 : : */
9324 : : static int
9325 : 0 : parse_vc_action_rss_type(struct context *ctx, const struct token *token,
9326 : : const char *str, unsigned int len,
9327 : : void *buf, unsigned int size)
9328 : : {
9329 : : struct action_rss_data *action_rss_data;
9330 : : unsigned int i;
9331 : :
9332 : : (void)token;
9333 : : (void)buf;
9334 : : (void)size;
9335 : 0 : if (ctx->curr != ACTION_RSS_TYPE)
9336 : : return -1;
9337 : 0 : if (!(ctx->objdata >> 16) && ctx->object) {
9338 : : action_rss_data = ctx->object;
9339 : 0 : action_rss_data->conf.types = 0;
9340 : : }
9341 : 0 : if (!strcmp_partial("end", str, len)) {
9342 : 0 : ctx->objdata &= 0xffff;
9343 : 0 : return len;
9344 : : }
9345 : 0 : for (i = 0; rss_type_table[i].str; ++i)
9346 : 0 : if (!strcmp_partial(rss_type_table[i].str, str, len))
9347 : : break;
9348 : 0 : if (!rss_type_table[i].str)
9349 : : return -1;
9350 : 0 : ctx->objdata = 1 << 16 | (ctx->objdata & 0xffff);
9351 : : /* Repeat token. */
9352 : 0 : if (ctx->next_num == RTE_DIM(ctx->next))
9353 : : return -1;
9354 : 0 : ctx->next[ctx->next_num++] = NEXT_ENTRY(ACTION_RSS_TYPE);
9355 : 0 : if (!ctx->object)
9356 : 0 : return len;
9357 : : action_rss_data = ctx->object;
9358 : 0 : action_rss_data->conf.types |= rss_type_table[i].rss_type;
9359 : 0 : return len;
9360 : : }
9361 : :
9362 : : /**
9363 : : * Parse queue field for RSS action.
9364 : : *
9365 : : * Valid tokens are queue indices and the "end" token.
9366 : : */
9367 : : static int
9368 : 0 : parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
9369 : : const char *str, unsigned int len,
9370 : : void *buf, unsigned int size)
9371 : : {
9372 : : struct action_rss_data *action_rss_data;
9373 : : const struct arg *arg;
9374 : : int ret;
9375 : : int i;
9376 : :
9377 : : (void)token;
9378 : : (void)buf;
9379 : : (void)size;
9380 : 0 : if (ctx->curr != ACTION_RSS_QUEUE)
9381 : : return -1;
9382 : 0 : i = ctx->objdata >> 16;
9383 : 0 : if (!strcmp_partial("end", str, len)) {
9384 : 0 : ctx->objdata &= 0xffff;
9385 : 0 : goto end;
9386 : : }
9387 : 0 : if (i >= ACTION_RSS_QUEUE_NUM)
9388 : : return -1;
9389 : 0 : arg = ARGS_ENTRY_ARB(offsetof(struct action_rss_data, queue) +
9390 : : i * sizeof(action_rss_data->queue[i]),
9391 : : sizeof(action_rss_data->queue[i]));
9392 : : if (push_args(ctx, arg))
9393 : : return -1;
9394 : 0 : ret = parse_int(ctx, token, str, len, NULL, 0);
9395 : 0 : if (ret < 0) {
9396 : : pop_args(ctx);
9397 : 0 : return -1;
9398 : : }
9399 : 0 : ++i;
9400 : 0 : ctx->objdata = i << 16 | (ctx->objdata & 0xffff);
9401 : : /* Repeat token. */
9402 : 0 : if (ctx->next_num == RTE_DIM(ctx->next))
9403 : : return -1;
9404 : 0 : ctx->next[ctx->next_num++] = NEXT_ENTRY(ACTION_RSS_QUEUE);
9405 : 0 : end:
9406 : 0 : if (!ctx->object)
9407 : 0 : return len;
9408 : : action_rss_data = ctx->object;
9409 : 0 : action_rss_data->conf.queue_num = i;
9410 : 0 : action_rss_data->conf.queue = i ? action_rss_data->queue : NULL;
9411 : 0 : return len;
9412 : : }
9413 : :
9414 : : /** Setup VXLAN encap configuration. */
9415 : : static int
9416 : 0 : parse_setup_vxlan_encap_data(struct action_vxlan_encap_data *action_vxlan_encap_data)
9417 : : {
9418 : : /* Set up default configuration. */
9419 : 0 : *action_vxlan_encap_data = (struct action_vxlan_encap_data){
9420 : : .conf = (struct rte_flow_action_vxlan_encap){
9421 : 0 : .definition = action_vxlan_encap_data->items,
9422 : : },
9423 : : .items = {
9424 : : {
9425 : : .type = RTE_FLOW_ITEM_TYPE_ETH,
9426 : 0 : .spec = &action_vxlan_encap_data->item_eth,
9427 : : .mask = &rte_flow_item_eth_mask,
9428 : : },
9429 : : {
9430 : : .type = RTE_FLOW_ITEM_TYPE_VLAN,
9431 : 0 : .spec = &action_vxlan_encap_data->item_vlan,
9432 : : .mask = &rte_flow_item_vlan_mask,
9433 : : },
9434 : : {
9435 : : .type = RTE_FLOW_ITEM_TYPE_IPV4,
9436 : 0 : .spec = &action_vxlan_encap_data->item_ipv4,
9437 : : .mask = &rte_flow_item_ipv4_mask,
9438 : : },
9439 : : {
9440 : : .type = RTE_FLOW_ITEM_TYPE_UDP,
9441 : 0 : .spec = &action_vxlan_encap_data->item_udp,
9442 : : .mask = &rte_flow_item_udp_mask,
9443 : : },
9444 : : {
9445 : : .type = RTE_FLOW_ITEM_TYPE_VXLAN,
9446 : 0 : .spec = &action_vxlan_encap_data->item_vxlan,
9447 : : .mask = &rte_flow_item_vxlan_mask,
9448 : : },
9449 : : {
9450 : : .type = RTE_FLOW_ITEM_TYPE_END,
9451 : : },
9452 : : },
9453 : : .item_eth.hdr.ether_type = 0,
9454 : : .item_vlan = {
9455 : 0 : .hdr.vlan_tci = vxlan_encap_conf.vlan_tci,
9456 : : .hdr.eth_proto = 0,
9457 : : },
9458 : : .item_ipv4.hdr = {
9459 : 0 : .src_addr = vxlan_encap_conf.ipv4_src,
9460 : 0 : .dst_addr = vxlan_encap_conf.ipv4_dst,
9461 : : },
9462 : : .item_udp.hdr = {
9463 : 0 : .src_port = vxlan_encap_conf.udp_src,
9464 : 0 : .dst_port = vxlan_encap_conf.udp_dst,
9465 : : },
9466 : : .item_vxlan.hdr.flags = 0,
9467 : : };
9468 : 0 : memcpy(action_vxlan_encap_data->item_eth.hdr.dst_addr.addr_bytes,
9469 : : vxlan_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
9470 : 0 : memcpy(action_vxlan_encap_data->item_eth.hdr.src_addr.addr_bytes,
9471 : : vxlan_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
9472 : 0 : if (!vxlan_encap_conf.select_ipv4) {
9473 : 0 : memcpy(&action_vxlan_encap_data->item_ipv6.hdr.src_addr,
9474 : : &vxlan_encap_conf.ipv6_src,
9475 : : sizeof(vxlan_encap_conf.ipv6_src));
9476 : 0 : memcpy(&action_vxlan_encap_data->item_ipv6.hdr.dst_addr,
9477 : : &vxlan_encap_conf.ipv6_dst,
9478 : : sizeof(vxlan_encap_conf.ipv6_dst));
9479 : 0 : action_vxlan_encap_data->items[2] = (struct rte_flow_item){
9480 : : .type = RTE_FLOW_ITEM_TYPE_IPV6,
9481 : 0 : .spec = &action_vxlan_encap_data->item_ipv6,
9482 : : .mask = &rte_flow_item_ipv6_mask,
9483 : : };
9484 : : }
9485 : 0 : if (!vxlan_encap_conf.select_vlan)
9486 : 0 : action_vxlan_encap_data->items[1].type =
9487 : : RTE_FLOW_ITEM_TYPE_VOID;
9488 : 0 : if (vxlan_encap_conf.select_tos_ttl) {
9489 : 0 : if (vxlan_encap_conf.select_ipv4) {
9490 : : static struct rte_flow_item_ipv4 ipv4_mask_tos;
9491 : :
9492 : : memcpy(&ipv4_mask_tos, &rte_flow_item_ipv4_mask,
9493 : : sizeof(ipv4_mask_tos));
9494 : 0 : ipv4_mask_tos.hdr.type_of_service = 0xff;
9495 : 0 : ipv4_mask_tos.hdr.time_to_live = 0xff;
9496 : 0 : action_vxlan_encap_data->item_ipv4.hdr.type_of_service =
9497 : 0 : vxlan_encap_conf.ip_tos;
9498 : 0 : action_vxlan_encap_data->item_ipv4.hdr.time_to_live =
9499 : 0 : vxlan_encap_conf.ip_ttl;
9500 : 0 : action_vxlan_encap_data->items[2].mask =
9501 : : &ipv4_mask_tos;
9502 : : } else {
9503 : : static struct rte_flow_item_ipv6 ipv6_mask_tos;
9504 : :
9505 : : memcpy(&ipv6_mask_tos, &rte_flow_item_ipv6_mask,
9506 : : sizeof(ipv6_mask_tos));
9507 : 0 : ipv6_mask_tos.hdr.vtc_flow |=
9508 : : RTE_BE32(0xfful << RTE_IPV6_HDR_TC_SHIFT);
9509 : 0 : ipv6_mask_tos.hdr.hop_limits = 0xff;
9510 : 0 : action_vxlan_encap_data->item_ipv6.hdr.vtc_flow |=
9511 : 0 : rte_cpu_to_be_32
9512 : : ((uint32_t)vxlan_encap_conf.ip_tos <<
9513 : : RTE_IPV6_HDR_TC_SHIFT);
9514 : 0 : action_vxlan_encap_data->item_ipv6.hdr.hop_limits =
9515 : 0 : vxlan_encap_conf.ip_ttl;
9516 : 0 : action_vxlan_encap_data->items[2].mask =
9517 : : &ipv6_mask_tos;
9518 : : }
9519 : : }
9520 : 0 : memcpy(action_vxlan_encap_data->item_vxlan.hdr.vni, vxlan_encap_conf.vni,
9521 : : RTE_DIM(vxlan_encap_conf.vni));
9522 : 0 : return 0;
9523 : : }
9524 : :
9525 : : /** Parse VXLAN encap action. */
9526 : : static int
9527 : 0 : parse_vc_action_vxlan_encap(struct context *ctx, const struct token *token,
9528 : : const char *str, unsigned int len,
9529 : : void *buf, unsigned int size)
9530 : : {
9531 : : struct buffer *out = buf;
9532 : : struct rte_flow_action *action;
9533 : : struct action_vxlan_encap_data *action_vxlan_encap_data;
9534 : : int ret;
9535 : :
9536 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
9537 : 0 : if (ret < 0)
9538 : : return ret;
9539 : : /* Nothing else to do if there is no buffer. */
9540 : 0 : if (!out)
9541 : : return ret;
9542 : 0 : if (!out->args.vc.actions_n)
9543 : : return -1;
9544 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
9545 : : /* Point to selected object. */
9546 : 0 : ctx->object = out->args.vc.data;
9547 : 0 : ctx->objmask = NULL;
9548 : : action_vxlan_encap_data = ctx->object;
9549 : 0 : parse_setup_vxlan_encap_data(action_vxlan_encap_data);
9550 : 0 : action->conf = &action_vxlan_encap_data->conf;
9551 : 0 : return ret;
9552 : : }
9553 : :
9554 : : /** Setup NVGRE encap configuration. */
9555 : : static int
9556 : 0 : parse_setup_nvgre_encap_data(struct action_nvgre_encap_data *action_nvgre_encap_data)
9557 : : {
9558 : : /* Set up default configuration. */
9559 : 0 : *action_nvgre_encap_data = (struct action_nvgre_encap_data){
9560 : : .conf = (struct rte_flow_action_nvgre_encap){
9561 : 0 : .definition = action_nvgre_encap_data->items,
9562 : : },
9563 : : .items = {
9564 : : {
9565 : : .type = RTE_FLOW_ITEM_TYPE_ETH,
9566 : 0 : .spec = &action_nvgre_encap_data->item_eth,
9567 : : .mask = &rte_flow_item_eth_mask,
9568 : : },
9569 : : {
9570 : : .type = RTE_FLOW_ITEM_TYPE_VLAN,
9571 : 0 : .spec = &action_nvgre_encap_data->item_vlan,
9572 : : .mask = &rte_flow_item_vlan_mask,
9573 : : },
9574 : : {
9575 : : .type = RTE_FLOW_ITEM_TYPE_IPV4,
9576 : 0 : .spec = &action_nvgre_encap_data->item_ipv4,
9577 : : .mask = &rte_flow_item_ipv4_mask,
9578 : : },
9579 : : {
9580 : : .type = RTE_FLOW_ITEM_TYPE_NVGRE,
9581 : 0 : .spec = &action_nvgre_encap_data->item_nvgre,
9582 : : .mask = &rte_flow_item_nvgre_mask,
9583 : : },
9584 : : {
9585 : : .type = RTE_FLOW_ITEM_TYPE_END,
9586 : : },
9587 : : },
9588 : : .item_eth.hdr.ether_type = 0,
9589 : : .item_vlan = {
9590 : 0 : .hdr.vlan_tci = nvgre_encap_conf.vlan_tci,
9591 : : .hdr.eth_proto = 0,
9592 : : },
9593 : : .item_ipv4.hdr = {
9594 : 0 : .src_addr = nvgre_encap_conf.ipv4_src,
9595 : 0 : .dst_addr = nvgre_encap_conf.ipv4_dst,
9596 : : },
9597 : : .item_nvgre.c_k_s_rsvd0_ver = RTE_BE16(0x2000),
9598 : : .item_nvgre.protocol = RTE_BE16(RTE_ETHER_TYPE_TEB),
9599 : : .item_nvgre.flow_id = 0,
9600 : : };
9601 : 0 : memcpy(action_nvgre_encap_data->item_eth.hdr.dst_addr.addr_bytes,
9602 : : nvgre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
9603 : 0 : memcpy(action_nvgre_encap_data->item_eth.hdr.src_addr.addr_bytes,
9604 : : nvgre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
9605 : 0 : if (!nvgre_encap_conf.select_ipv4) {
9606 : 0 : memcpy(&action_nvgre_encap_data->item_ipv6.hdr.src_addr,
9607 : : &nvgre_encap_conf.ipv6_src,
9608 : : sizeof(nvgre_encap_conf.ipv6_src));
9609 : 0 : memcpy(&action_nvgre_encap_data->item_ipv6.hdr.dst_addr,
9610 : : &nvgre_encap_conf.ipv6_dst,
9611 : : sizeof(nvgre_encap_conf.ipv6_dst));
9612 : 0 : action_nvgre_encap_data->items[2] = (struct rte_flow_item){
9613 : : .type = RTE_FLOW_ITEM_TYPE_IPV6,
9614 : 0 : .spec = &action_nvgre_encap_data->item_ipv6,
9615 : : .mask = &rte_flow_item_ipv6_mask,
9616 : : };
9617 : : }
9618 : 0 : if (!nvgre_encap_conf.select_vlan)
9619 : 0 : action_nvgre_encap_data->items[1].type =
9620 : : RTE_FLOW_ITEM_TYPE_VOID;
9621 : 0 : memcpy(action_nvgre_encap_data->item_nvgre.tni, nvgre_encap_conf.tni,
9622 : : RTE_DIM(nvgre_encap_conf.tni));
9623 : 0 : return 0;
9624 : : }
9625 : :
9626 : : /** Parse NVGRE encap action. */
9627 : : static int
9628 : 0 : parse_vc_action_nvgre_encap(struct context *ctx, const struct token *token,
9629 : : const char *str, unsigned int len,
9630 : : void *buf, unsigned int size)
9631 : : {
9632 : : struct buffer *out = buf;
9633 : : struct rte_flow_action *action;
9634 : : struct action_nvgre_encap_data *action_nvgre_encap_data;
9635 : : int ret;
9636 : :
9637 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
9638 : 0 : if (ret < 0)
9639 : : return ret;
9640 : : /* Nothing else to do if there is no buffer. */
9641 : 0 : if (!out)
9642 : : return ret;
9643 : 0 : if (!out->args.vc.actions_n)
9644 : : return -1;
9645 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
9646 : : /* Point to selected object. */
9647 : 0 : ctx->object = out->args.vc.data;
9648 : 0 : ctx->objmask = NULL;
9649 : : action_nvgre_encap_data = ctx->object;
9650 : 0 : parse_setup_nvgre_encap_data(action_nvgre_encap_data);
9651 : 0 : action->conf = &action_nvgre_encap_data->conf;
9652 : 0 : return ret;
9653 : : }
9654 : :
9655 : : /** Parse l2 encap action. */
9656 : : static int
9657 : 0 : parse_vc_action_l2_encap(struct context *ctx, const struct token *token,
9658 : : const char *str, unsigned int len,
9659 : : void *buf, unsigned int size)
9660 : : {
9661 : : struct buffer *out = buf;
9662 : : struct rte_flow_action *action;
9663 : : struct action_raw_encap_data *action_encap_data;
9664 : 0 : struct rte_flow_item_eth eth = { .hdr.ether_type = 0, };
9665 : 0 : struct rte_flow_item_vlan vlan = {
9666 : 0 : .hdr.vlan_tci = mplsoudp_encap_conf.vlan_tci,
9667 : : .hdr.eth_proto = 0,
9668 : : };
9669 : : uint8_t *header;
9670 : : int ret;
9671 : :
9672 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
9673 : 0 : if (ret < 0)
9674 : : return ret;
9675 : : /* Nothing else to do if there is no buffer. */
9676 : 0 : if (!out)
9677 : : return ret;
9678 : 0 : if (!out->args.vc.actions_n)
9679 : : return -1;
9680 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
9681 : : /* Point to selected object. */
9682 : 0 : ctx->object = out->args.vc.data;
9683 : 0 : ctx->objmask = NULL;
9684 : : /* Copy the headers to the buffer. */
9685 : : action_encap_data = ctx->object;
9686 : 0 : *action_encap_data = (struct action_raw_encap_data) {
9687 : : .conf = (struct rte_flow_action_raw_encap){
9688 : 0 : .data = action_encap_data->data,
9689 : : },
9690 : : .data = {},
9691 : : };
9692 : : header = action_encap_data->data;
9693 : 0 : if (l2_encap_conf.select_vlan)
9694 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
9695 : 0 : else if (l2_encap_conf.select_ipv4)
9696 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
9697 : : else
9698 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
9699 : : memcpy(eth.hdr.dst_addr.addr_bytes,
9700 : : l2_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
9701 : : memcpy(eth.hdr.src_addr.addr_bytes,
9702 : : l2_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
9703 : : memcpy(header, ð.hdr, sizeof(struct rte_ether_hdr));
9704 : 0 : header += sizeof(struct rte_ether_hdr);
9705 : 0 : if (l2_encap_conf.select_vlan) {
9706 : 0 : if (l2_encap_conf.select_ipv4)
9707 : 0 : vlan.hdr.eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
9708 : : else
9709 : 0 : vlan.hdr.eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
9710 : : memcpy(header, &vlan.hdr, sizeof(struct rte_vlan_hdr));
9711 : 0 : header += sizeof(struct rte_vlan_hdr);
9712 : : }
9713 : 0 : action_encap_data->conf.size = header -
9714 : : action_encap_data->data;
9715 : 0 : action->conf = &action_encap_data->conf;
9716 : 0 : return ret;
9717 : : }
9718 : :
9719 : : /** Parse l2 decap action. */
9720 : : static int
9721 : 0 : parse_vc_action_l2_decap(struct context *ctx, const struct token *token,
9722 : : const char *str, unsigned int len,
9723 : : void *buf, unsigned int size)
9724 : : {
9725 : : struct buffer *out = buf;
9726 : : struct rte_flow_action *action;
9727 : : struct action_raw_decap_data *action_decap_data;
9728 : 0 : struct rte_flow_item_eth eth = { .hdr.ether_type = 0, };
9729 : 0 : struct rte_flow_item_vlan vlan = {
9730 : 0 : .hdr.vlan_tci = mplsoudp_encap_conf.vlan_tci,
9731 : : .hdr.eth_proto = 0,
9732 : : };
9733 : : uint8_t *header;
9734 : : int ret;
9735 : :
9736 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
9737 : 0 : if (ret < 0)
9738 : : return ret;
9739 : : /* Nothing else to do if there is no buffer. */
9740 : 0 : if (!out)
9741 : : return ret;
9742 : 0 : if (!out->args.vc.actions_n)
9743 : : return -1;
9744 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
9745 : : /* Point to selected object. */
9746 : 0 : ctx->object = out->args.vc.data;
9747 : 0 : ctx->objmask = NULL;
9748 : : /* Copy the headers to the buffer. */
9749 : : action_decap_data = ctx->object;
9750 : 0 : *action_decap_data = (struct action_raw_decap_data) {
9751 : : .conf = (struct rte_flow_action_raw_decap){
9752 : 0 : .data = action_decap_data->data,
9753 : : },
9754 : : .data = {},
9755 : : };
9756 : : header = action_decap_data->data;
9757 : 0 : if (l2_decap_conf.select_vlan)
9758 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
9759 : : memcpy(header, ð.hdr, sizeof(struct rte_ether_hdr));
9760 : 0 : header += sizeof(struct rte_ether_hdr);
9761 : 0 : if (l2_decap_conf.select_vlan) {
9762 : : memcpy(header, &vlan.hdr, sizeof(struct rte_vlan_hdr));
9763 : 0 : header += sizeof(struct rte_vlan_hdr);
9764 : : }
9765 : 0 : action_decap_data->conf.size = header -
9766 : : action_decap_data->data;
9767 : 0 : action->conf = &action_decap_data->conf;
9768 : 0 : return ret;
9769 : : }
9770 : :
9771 : : #define ETHER_TYPE_MPLS_UNICAST 0x8847
9772 : :
9773 : : /** Parse MPLSOGRE encap action. */
9774 : : static int
9775 : 0 : parse_vc_action_mplsogre_encap(struct context *ctx, const struct token *token,
9776 : : const char *str, unsigned int len,
9777 : : void *buf, unsigned int size)
9778 : : {
9779 : : struct buffer *out = buf;
9780 : : struct rte_flow_action *action;
9781 : : struct action_raw_encap_data *action_encap_data;
9782 : 0 : struct rte_flow_item_eth eth = { .hdr.ether_type = 0, };
9783 : 0 : struct rte_flow_item_vlan vlan = {
9784 : 0 : .hdr.vlan_tci = mplsogre_encap_conf.vlan_tci,
9785 : : .hdr.eth_proto = 0,
9786 : : };
9787 : 0 : struct rte_flow_item_ipv4 ipv4 = {
9788 : : .hdr = {
9789 : 0 : .src_addr = mplsogre_encap_conf.ipv4_src,
9790 : 0 : .dst_addr = mplsogre_encap_conf.ipv4_dst,
9791 : : .next_proto_id = IPPROTO_GRE,
9792 : : .version_ihl = RTE_IPV4_VHL_DEF,
9793 : : .time_to_live = IPDEFTTL,
9794 : : },
9795 : : };
9796 : 0 : struct rte_flow_item_ipv6 ipv6 = {
9797 : : .hdr = {
9798 : : .proto = IPPROTO_GRE,
9799 : : .hop_limits = IPDEFTTL,
9800 : : },
9801 : : };
9802 : 0 : struct rte_flow_item_gre gre = {
9803 : : .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
9804 : : };
9805 : 0 : struct rte_flow_item_mpls mpls = {
9806 : : .ttl = 0,
9807 : : };
9808 : : uint8_t *header;
9809 : : int ret;
9810 : :
9811 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
9812 : 0 : if (ret < 0)
9813 : : return ret;
9814 : : /* Nothing else to do if there is no buffer. */
9815 : 0 : if (!out)
9816 : : return ret;
9817 : 0 : if (!out->args.vc.actions_n)
9818 : : return -1;
9819 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
9820 : : /* Point to selected object. */
9821 : 0 : ctx->object = out->args.vc.data;
9822 : 0 : ctx->objmask = NULL;
9823 : : /* Copy the headers to the buffer. */
9824 : : action_encap_data = ctx->object;
9825 : 0 : *action_encap_data = (struct action_raw_encap_data) {
9826 : : .conf = (struct rte_flow_action_raw_encap){
9827 : 0 : .data = action_encap_data->data,
9828 : : },
9829 : : .data = {},
9830 : : .preserve = {},
9831 : : };
9832 : : header = action_encap_data->data;
9833 : 0 : if (mplsogre_encap_conf.select_vlan)
9834 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
9835 : 0 : else if (mplsogre_encap_conf.select_ipv4)
9836 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
9837 : : else
9838 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
9839 : : memcpy(eth.hdr.dst_addr.addr_bytes,
9840 : : mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
9841 : : memcpy(eth.hdr.src_addr.addr_bytes,
9842 : : mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
9843 : : memcpy(header, ð.hdr, sizeof(struct rte_ether_hdr));
9844 : 0 : header += sizeof(struct rte_ether_hdr);
9845 : 0 : if (mplsogre_encap_conf.select_vlan) {
9846 : 0 : if (mplsogre_encap_conf.select_ipv4)
9847 : 0 : vlan.hdr.eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
9848 : : else
9849 : 0 : vlan.hdr.eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
9850 : : memcpy(header, &vlan.hdr, sizeof(struct rte_vlan_hdr));
9851 : 0 : header += sizeof(struct rte_vlan_hdr);
9852 : : }
9853 : 0 : if (mplsogre_encap_conf.select_ipv4) {
9854 : : memcpy(header, &ipv4, sizeof(ipv4));
9855 : 0 : header += sizeof(ipv4);
9856 : : } else {
9857 : : memcpy(&ipv6.hdr.src_addr,
9858 : : &mplsogre_encap_conf.ipv6_src,
9859 : : sizeof(mplsogre_encap_conf.ipv6_src));
9860 : : memcpy(&ipv6.hdr.dst_addr,
9861 : : &mplsogre_encap_conf.ipv6_dst,
9862 : : sizeof(mplsogre_encap_conf.ipv6_dst));
9863 : : memcpy(header, &ipv6, sizeof(ipv6));
9864 : 0 : header += sizeof(ipv6);
9865 : : }
9866 : : memcpy(header, &gre, sizeof(gre));
9867 : 0 : header += sizeof(gre);
9868 : : memcpy(mpls.label_tc_s, mplsogre_encap_conf.label,
9869 : : RTE_DIM(mplsogre_encap_conf.label));
9870 : 0 : mpls.label_tc_s[2] |= 0x1;
9871 : : memcpy(header, &mpls, sizeof(mpls));
9872 : 0 : header += sizeof(mpls);
9873 : 0 : action_encap_data->conf.size = header -
9874 : : action_encap_data->data;
9875 : 0 : action->conf = &action_encap_data->conf;
9876 : 0 : return ret;
9877 : : }
9878 : :
9879 : : /** Parse MPLSOGRE decap action. */
9880 : : static int
9881 : 0 : parse_vc_action_mplsogre_decap(struct context *ctx, const struct token *token,
9882 : : const char *str, unsigned int len,
9883 : : void *buf, unsigned int size)
9884 : : {
9885 : : struct buffer *out = buf;
9886 : : struct rte_flow_action *action;
9887 : : struct action_raw_decap_data *action_decap_data;
9888 : 0 : struct rte_flow_item_eth eth = { .hdr.ether_type = 0, };
9889 : 0 : struct rte_flow_item_vlan vlan = {.hdr.vlan_tci = 0};
9890 : 0 : struct rte_flow_item_ipv4 ipv4 = {
9891 : : .hdr = {
9892 : : .next_proto_id = IPPROTO_GRE,
9893 : : },
9894 : : };
9895 : 0 : struct rte_flow_item_ipv6 ipv6 = {
9896 : : .hdr = {
9897 : : .proto = IPPROTO_GRE,
9898 : : },
9899 : : };
9900 : 0 : struct rte_flow_item_gre gre = {
9901 : : .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
9902 : : };
9903 : : struct rte_flow_item_mpls mpls;
9904 : : uint8_t *header;
9905 : : int ret;
9906 : :
9907 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
9908 : 0 : if (ret < 0)
9909 : : return ret;
9910 : : /* Nothing else to do if there is no buffer. */
9911 : 0 : if (!out)
9912 : : return ret;
9913 : 0 : if (!out->args.vc.actions_n)
9914 : : return -1;
9915 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
9916 : : /* Point to selected object. */
9917 : 0 : ctx->object = out->args.vc.data;
9918 : 0 : ctx->objmask = NULL;
9919 : : /* Copy the headers to the buffer. */
9920 : : action_decap_data = ctx->object;
9921 : 0 : *action_decap_data = (struct action_raw_decap_data) {
9922 : : .conf = (struct rte_flow_action_raw_decap){
9923 : 0 : .data = action_decap_data->data,
9924 : : },
9925 : : .data = {},
9926 : : };
9927 : : header = action_decap_data->data;
9928 : 0 : if (mplsogre_decap_conf.select_vlan)
9929 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
9930 : 0 : else if (mplsogre_encap_conf.select_ipv4)
9931 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
9932 : : else
9933 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
9934 : : memcpy(eth.hdr.dst_addr.addr_bytes,
9935 : : mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
9936 : : memcpy(eth.hdr.src_addr.addr_bytes,
9937 : : mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
9938 : : memcpy(header, ð.hdr, sizeof(struct rte_ether_hdr));
9939 : 0 : header += sizeof(struct rte_ether_hdr);
9940 : 0 : if (mplsogre_encap_conf.select_vlan) {
9941 : 0 : if (mplsogre_encap_conf.select_ipv4)
9942 : 0 : vlan.hdr.eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
9943 : : else
9944 : 0 : vlan.hdr.eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
9945 : : memcpy(header, &vlan.hdr, sizeof(struct rte_vlan_hdr));
9946 : 0 : header += sizeof(struct rte_vlan_hdr);
9947 : : }
9948 : 0 : if (mplsogre_encap_conf.select_ipv4) {
9949 : : memcpy(header, &ipv4, sizeof(ipv4));
9950 : 0 : header += sizeof(ipv4);
9951 : : } else {
9952 : : memcpy(header, &ipv6, sizeof(ipv6));
9953 : 0 : header += sizeof(ipv6);
9954 : : }
9955 : : memcpy(header, &gre, sizeof(gre));
9956 : 0 : header += sizeof(gre);
9957 : : memset(&mpls, 0, sizeof(mpls));
9958 : : memcpy(header, &mpls, sizeof(mpls));
9959 : 0 : header += sizeof(mpls);
9960 : 0 : action_decap_data->conf.size = header -
9961 : : action_decap_data->data;
9962 : 0 : action->conf = &action_decap_data->conf;
9963 : 0 : return ret;
9964 : : }
9965 : :
9966 : : /** Parse MPLSOUDP encap action. */
9967 : : static int
9968 : 0 : parse_vc_action_mplsoudp_encap(struct context *ctx, const struct token *token,
9969 : : const char *str, unsigned int len,
9970 : : void *buf, unsigned int size)
9971 : : {
9972 : : struct buffer *out = buf;
9973 : : struct rte_flow_action *action;
9974 : : struct action_raw_encap_data *action_encap_data;
9975 : 0 : struct rte_flow_item_eth eth = { .hdr.ether_type = 0, };
9976 : 0 : struct rte_flow_item_vlan vlan = {
9977 : 0 : .hdr.vlan_tci = mplsoudp_encap_conf.vlan_tci,
9978 : : .hdr.eth_proto = 0,
9979 : : };
9980 : 0 : struct rte_flow_item_ipv4 ipv4 = {
9981 : : .hdr = {
9982 : 0 : .src_addr = mplsoudp_encap_conf.ipv4_src,
9983 : 0 : .dst_addr = mplsoudp_encap_conf.ipv4_dst,
9984 : : .next_proto_id = IPPROTO_UDP,
9985 : : .version_ihl = RTE_IPV4_VHL_DEF,
9986 : : .time_to_live = IPDEFTTL,
9987 : : },
9988 : : };
9989 : 0 : struct rte_flow_item_ipv6 ipv6 = {
9990 : : .hdr = {
9991 : : .proto = IPPROTO_UDP,
9992 : : .hop_limits = IPDEFTTL,
9993 : : },
9994 : : };
9995 : 0 : struct rte_flow_item_udp udp = {
9996 : : .hdr = {
9997 : 0 : .src_port = mplsoudp_encap_conf.udp_src,
9998 : 0 : .dst_port = mplsoudp_encap_conf.udp_dst,
9999 : : },
10000 : : };
10001 : : struct rte_flow_item_mpls mpls;
10002 : : uint8_t *header;
10003 : : int ret;
10004 : :
10005 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
10006 : 0 : if (ret < 0)
10007 : : return ret;
10008 : : /* Nothing else to do if there is no buffer. */
10009 : 0 : if (!out)
10010 : : return ret;
10011 : 0 : if (!out->args.vc.actions_n)
10012 : : return -1;
10013 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
10014 : : /* Point to selected object. */
10015 : 0 : ctx->object = out->args.vc.data;
10016 : 0 : ctx->objmask = NULL;
10017 : : /* Copy the headers to the buffer. */
10018 : : action_encap_data = ctx->object;
10019 : 0 : *action_encap_data = (struct action_raw_encap_data) {
10020 : : .conf = (struct rte_flow_action_raw_encap){
10021 : 0 : .data = action_encap_data->data,
10022 : : },
10023 : : .data = {},
10024 : : .preserve = {},
10025 : : };
10026 : : header = action_encap_data->data;
10027 : 0 : if (mplsoudp_encap_conf.select_vlan)
10028 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
10029 : 0 : else if (mplsoudp_encap_conf.select_ipv4)
10030 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
10031 : : else
10032 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
10033 : : memcpy(eth.hdr.dst_addr.addr_bytes,
10034 : : mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
10035 : : memcpy(eth.hdr.src_addr.addr_bytes,
10036 : : mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
10037 : : memcpy(header, ð.hdr, sizeof(struct rte_ether_hdr));
10038 : 0 : header += sizeof(struct rte_ether_hdr);
10039 : 0 : if (mplsoudp_encap_conf.select_vlan) {
10040 : 0 : if (mplsoudp_encap_conf.select_ipv4)
10041 : 0 : vlan.hdr.eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
10042 : : else
10043 : 0 : vlan.hdr.eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
10044 : : memcpy(header, &vlan.hdr, sizeof(struct rte_vlan_hdr));
10045 : 0 : header += sizeof(struct rte_vlan_hdr);
10046 : : }
10047 : 0 : if (mplsoudp_encap_conf.select_ipv4) {
10048 : : memcpy(header, &ipv4, sizeof(ipv4));
10049 : 0 : header += sizeof(ipv4);
10050 : : } else {
10051 : : memcpy(&ipv6.hdr.src_addr,
10052 : : &mplsoudp_encap_conf.ipv6_src,
10053 : : sizeof(mplsoudp_encap_conf.ipv6_src));
10054 : : memcpy(&ipv6.hdr.dst_addr,
10055 : : &mplsoudp_encap_conf.ipv6_dst,
10056 : : sizeof(mplsoudp_encap_conf.ipv6_dst));
10057 : : memcpy(header, &ipv6, sizeof(ipv6));
10058 : 0 : header += sizeof(ipv6);
10059 : : }
10060 : : memcpy(header, &udp, sizeof(udp));
10061 : 0 : header += sizeof(udp);
10062 : : memcpy(mpls.label_tc_s, mplsoudp_encap_conf.label,
10063 : : RTE_DIM(mplsoudp_encap_conf.label));
10064 : 0 : mpls.label_tc_s[2] |= 0x1;
10065 : : memcpy(header, &mpls, sizeof(mpls));
10066 : 0 : header += sizeof(mpls);
10067 : 0 : action_encap_data->conf.size = header -
10068 : : action_encap_data->data;
10069 : 0 : action->conf = &action_encap_data->conf;
10070 : 0 : return ret;
10071 : : }
10072 : :
10073 : : /** Parse MPLSOUDP decap action. */
10074 : : static int
10075 : 0 : parse_vc_action_mplsoudp_decap(struct context *ctx, const struct token *token,
10076 : : const char *str, unsigned int len,
10077 : : void *buf, unsigned int size)
10078 : : {
10079 : : struct buffer *out = buf;
10080 : : struct rte_flow_action *action;
10081 : : struct action_raw_decap_data *action_decap_data;
10082 : 0 : struct rte_flow_item_eth eth = { .hdr.ether_type = 0, };
10083 : 0 : struct rte_flow_item_vlan vlan = {.hdr.vlan_tci = 0};
10084 : 0 : struct rte_flow_item_ipv4 ipv4 = {
10085 : : .hdr = {
10086 : : .next_proto_id = IPPROTO_UDP,
10087 : : },
10088 : : };
10089 : 0 : struct rte_flow_item_ipv6 ipv6 = {
10090 : : .hdr = {
10091 : : .proto = IPPROTO_UDP,
10092 : : },
10093 : : };
10094 : 0 : struct rte_flow_item_udp udp = {
10095 : : .hdr = {
10096 : : .dst_port = rte_cpu_to_be_16(6635),
10097 : : },
10098 : : };
10099 : : struct rte_flow_item_mpls mpls;
10100 : : uint8_t *header;
10101 : : int ret;
10102 : :
10103 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
10104 : 0 : if (ret < 0)
10105 : : return ret;
10106 : : /* Nothing else to do if there is no buffer. */
10107 : 0 : if (!out)
10108 : : return ret;
10109 : 0 : if (!out->args.vc.actions_n)
10110 : : return -1;
10111 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
10112 : : /* Point to selected object. */
10113 : 0 : ctx->object = out->args.vc.data;
10114 : 0 : ctx->objmask = NULL;
10115 : : /* Copy the headers to the buffer. */
10116 : : action_decap_data = ctx->object;
10117 : 0 : *action_decap_data = (struct action_raw_decap_data) {
10118 : : .conf = (struct rte_flow_action_raw_decap){
10119 : 0 : .data = action_decap_data->data,
10120 : : },
10121 : : .data = {},
10122 : : };
10123 : : header = action_decap_data->data;
10124 : 0 : if (mplsoudp_decap_conf.select_vlan)
10125 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
10126 : 0 : else if (mplsoudp_encap_conf.select_ipv4)
10127 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
10128 : : else
10129 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
10130 : : memcpy(eth.hdr.dst_addr.addr_bytes,
10131 : : mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
10132 : : memcpy(eth.hdr.src_addr.addr_bytes,
10133 : : mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
10134 : : memcpy(header, ð.hdr, sizeof(struct rte_ether_hdr));
10135 : 0 : header += sizeof(struct rte_ether_hdr);
10136 : 0 : if (mplsoudp_encap_conf.select_vlan) {
10137 : 0 : if (mplsoudp_encap_conf.select_ipv4)
10138 : 0 : vlan.hdr.eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
10139 : : else
10140 : 0 : vlan.hdr.eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
10141 : : memcpy(header, &vlan.hdr, sizeof(struct rte_vlan_hdr));
10142 : 0 : header += sizeof(struct rte_vlan_hdr);
10143 : : }
10144 : 0 : if (mplsoudp_encap_conf.select_ipv4) {
10145 : : memcpy(header, &ipv4, sizeof(ipv4));
10146 : 0 : header += sizeof(ipv4);
10147 : : } else {
10148 : : memcpy(header, &ipv6, sizeof(ipv6));
10149 : 0 : header += sizeof(ipv6);
10150 : : }
10151 : : memcpy(header, &udp, sizeof(udp));
10152 : 0 : header += sizeof(udp);
10153 : : memset(&mpls, 0, sizeof(mpls));
10154 : : memcpy(header, &mpls, sizeof(mpls));
10155 : 0 : header += sizeof(mpls);
10156 : 0 : action_decap_data->conf.size = header -
10157 : : action_decap_data->data;
10158 : 0 : action->conf = &action_decap_data->conf;
10159 : 0 : return ret;
10160 : : }
10161 : :
10162 : : static int
10163 : 0 : parse_vc_action_raw_decap_index(struct context *ctx, const struct token *token,
10164 : : const char *str, unsigned int len, void *buf,
10165 : : unsigned int size)
10166 : : {
10167 : : struct action_raw_decap_data *action_raw_decap_data;
10168 : : struct rte_flow_action *action;
10169 : : const struct arg *arg;
10170 : : struct buffer *out = buf;
10171 : : int ret;
10172 : : uint16_t idx;
10173 : :
10174 : : RTE_SET_USED(token);
10175 : : RTE_SET_USED(buf);
10176 : : RTE_SET_USED(size);
10177 : 0 : arg = ARGS_ENTRY_ARB_BOUNDED
10178 : : (offsetof(struct action_raw_decap_data, idx),
10179 : : sizeof(((struct action_raw_decap_data *)0)->idx),
10180 : : 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
10181 : : if (push_args(ctx, arg))
10182 : : return -1;
10183 : 0 : ret = parse_int(ctx, token, str, len, NULL, 0);
10184 : 0 : if (ret < 0) {
10185 : : pop_args(ctx);
10186 : 0 : return -1;
10187 : : }
10188 : 0 : if (!ctx->object)
10189 : 0 : return len;
10190 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
10191 : : action_raw_decap_data = ctx->object;
10192 : 0 : idx = action_raw_decap_data->idx;
10193 : 0 : action_raw_decap_data->conf.data = raw_decap_confs[idx].data;
10194 : 0 : action_raw_decap_data->conf.size = raw_decap_confs[idx].size;
10195 : 0 : action->conf = &action_raw_decap_data->conf;
10196 : 0 : return len;
10197 : : }
10198 : :
10199 : :
10200 : : static int
10201 : 0 : parse_vc_action_raw_encap_index(struct context *ctx, const struct token *token,
10202 : : const char *str, unsigned int len, void *buf,
10203 : : unsigned int size)
10204 : : {
10205 : : struct action_raw_encap_data *action_raw_encap_data;
10206 : : struct rte_flow_action *action;
10207 : : const struct arg *arg;
10208 : : struct buffer *out = buf;
10209 : : int ret;
10210 : : uint16_t idx;
10211 : :
10212 : : RTE_SET_USED(token);
10213 : : RTE_SET_USED(buf);
10214 : : RTE_SET_USED(size);
10215 : 0 : if (ctx->curr != ACTION_RAW_ENCAP_INDEX_VALUE)
10216 : : return -1;
10217 : 0 : arg = ARGS_ENTRY_ARB_BOUNDED
10218 : : (offsetof(struct action_raw_encap_data, idx),
10219 : : sizeof(((struct action_raw_encap_data *)0)->idx),
10220 : : 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
10221 : : if (push_args(ctx, arg))
10222 : : return -1;
10223 : 0 : ret = parse_int(ctx, token, str, len, NULL, 0);
10224 : 0 : if (ret < 0) {
10225 : : pop_args(ctx);
10226 : 0 : return -1;
10227 : : }
10228 : 0 : if (!ctx->object)
10229 : 0 : return len;
10230 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
10231 : : action_raw_encap_data = ctx->object;
10232 : 0 : idx = action_raw_encap_data->idx;
10233 : 0 : action_raw_encap_data->conf.data = raw_encap_confs[idx].data;
10234 : 0 : action_raw_encap_data->conf.size = raw_encap_confs[idx].size;
10235 : 0 : action_raw_encap_data->conf.preserve = NULL;
10236 : 0 : action->conf = &action_raw_encap_data->conf;
10237 : 0 : return len;
10238 : : }
10239 : :
10240 : : static int
10241 : 0 : parse_vc_action_raw_encap(struct context *ctx, const struct token *token,
10242 : : const char *str, unsigned int len, void *buf,
10243 : : unsigned int size)
10244 : : {
10245 : : struct buffer *out = buf;
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 : : /* Point to selected object. */
10257 : 0 : ctx->object = out->args.vc.data;
10258 : 0 : ctx->objmask = NULL;
10259 : 0 : return ret;
10260 : : }
10261 : :
10262 : : static int
10263 : 0 : parse_vc_action_raw_decap(struct context *ctx, const struct token *token,
10264 : : const char *str, unsigned int len, void *buf,
10265 : : unsigned int size)
10266 : : {
10267 : : struct buffer *out = buf;
10268 : : struct rte_flow_action *action;
10269 : : struct action_raw_decap_data *action_raw_decap_data = NULL;
10270 : : int ret;
10271 : :
10272 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
10273 : 0 : if (ret < 0)
10274 : : return ret;
10275 : : /* Nothing else to do if there is no buffer. */
10276 : 0 : if (!out)
10277 : : return ret;
10278 : 0 : if (!out->args.vc.actions_n)
10279 : : return -1;
10280 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
10281 : : /* Point to selected object. */
10282 : 0 : ctx->object = out->args.vc.data;
10283 : 0 : ctx->objmask = NULL;
10284 : : /* Copy the headers to the buffer. */
10285 : : action_raw_decap_data = ctx->object;
10286 : 0 : action_raw_decap_data->conf.data = raw_decap_confs[0].data;
10287 : 0 : action_raw_decap_data->conf.size = raw_decap_confs[0].size;
10288 : 0 : action->conf = &action_raw_decap_data->conf;
10289 : 0 : return ret;
10290 : : }
10291 : :
10292 : : static int
10293 : 0 : parse_vc_action_ipv6_ext_remove(struct context *ctx, const struct token *token,
10294 : : const char *str, unsigned int len, void *buf,
10295 : : unsigned int size)
10296 : : {
10297 : : struct buffer *out = buf;
10298 : : struct rte_flow_action *action;
10299 : : struct action_ipv6_ext_remove_data *ipv6_ext_remove_data = NULL;
10300 : : int ret;
10301 : :
10302 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
10303 : 0 : if (ret < 0)
10304 : : return ret;
10305 : : /* Nothing else to do if there is no buffer. */
10306 : 0 : if (!out)
10307 : : return ret;
10308 : 0 : if (!out->args.vc.actions_n)
10309 : : return -1;
10310 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
10311 : : /* Point to selected object. */
10312 : 0 : ctx->object = out->args.vc.data;
10313 : 0 : ctx->objmask = NULL;
10314 : : /* Copy the headers to the buffer. */
10315 : : ipv6_ext_remove_data = ctx->object;
10316 : 0 : ipv6_ext_remove_data->conf.type = ipv6_ext_remove_confs[0].type;
10317 : 0 : action->conf = &ipv6_ext_remove_data->conf;
10318 : 0 : return ret;
10319 : : }
10320 : :
10321 : : static int
10322 : 0 : parse_vc_action_ipv6_ext_remove_index(struct context *ctx, const struct token *token,
10323 : : const char *str, unsigned int len, void *buf,
10324 : : unsigned int size)
10325 : : {
10326 : : struct action_ipv6_ext_remove_data *action_ipv6_ext_remove_data;
10327 : : struct rte_flow_action *action;
10328 : : const struct arg *arg;
10329 : : struct buffer *out = buf;
10330 : : int ret;
10331 : : uint16_t idx;
10332 : :
10333 : : RTE_SET_USED(token);
10334 : : RTE_SET_USED(buf);
10335 : : RTE_SET_USED(size);
10336 : 0 : arg = ARGS_ENTRY_ARB_BOUNDED
10337 : : (offsetof(struct action_ipv6_ext_remove_data, idx),
10338 : : sizeof(((struct action_ipv6_ext_remove_data *)0)->idx),
10339 : : 0, IPV6_EXT_PUSH_CONFS_MAX_NUM - 1);
10340 : : if (push_args(ctx, arg))
10341 : : return -1;
10342 : 0 : ret = parse_int(ctx, token, str, len, NULL, 0);
10343 : 0 : if (ret < 0) {
10344 : : pop_args(ctx);
10345 : 0 : return -1;
10346 : : }
10347 : 0 : if (!ctx->object)
10348 : 0 : return len;
10349 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
10350 : : action_ipv6_ext_remove_data = ctx->object;
10351 : 0 : idx = action_ipv6_ext_remove_data->idx;
10352 : 0 : action_ipv6_ext_remove_data->conf.type = ipv6_ext_remove_confs[idx].type;
10353 : 0 : action->conf = &action_ipv6_ext_remove_data->conf;
10354 : 0 : return len;
10355 : : }
10356 : :
10357 : : static int
10358 : 0 : parse_vc_action_ipv6_ext_push(struct context *ctx, const struct token *token,
10359 : : const char *str, unsigned int len, void *buf,
10360 : : unsigned int size)
10361 : : {
10362 : : struct buffer *out = buf;
10363 : : struct rte_flow_action *action;
10364 : : struct action_ipv6_ext_push_data *ipv6_ext_push_data = NULL;
10365 : : int ret;
10366 : :
10367 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
10368 : 0 : if (ret < 0)
10369 : : return ret;
10370 : : /* Nothing else to do if there is no buffer. */
10371 : 0 : if (!out)
10372 : : return ret;
10373 : 0 : if (!out->args.vc.actions_n)
10374 : : return -1;
10375 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
10376 : : /* Point to selected object. */
10377 : 0 : ctx->object = out->args.vc.data;
10378 : 0 : ctx->objmask = NULL;
10379 : : /* Copy the headers to the buffer. */
10380 : : ipv6_ext_push_data = ctx->object;
10381 : 0 : ipv6_ext_push_data->conf.type = ipv6_ext_push_confs[0].type;
10382 : 0 : ipv6_ext_push_data->conf.data = ipv6_ext_push_confs[0].data;
10383 : 0 : ipv6_ext_push_data->conf.size = ipv6_ext_push_confs[0].size;
10384 : 0 : action->conf = &ipv6_ext_push_data->conf;
10385 : 0 : return ret;
10386 : : }
10387 : :
10388 : : static int
10389 : 0 : parse_vc_action_ipv6_ext_push_index(struct context *ctx, const struct token *token,
10390 : : const char *str, unsigned int len, void *buf,
10391 : : unsigned int size)
10392 : : {
10393 : : struct action_ipv6_ext_push_data *action_ipv6_ext_push_data;
10394 : : struct rte_flow_action *action;
10395 : : const struct arg *arg;
10396 : : struct buffer *out = buf;
10397 : : int ret;
10398 : : uint16_t idx;
10399 : :
10400 : : RTE_SET_USED(token);
10401 : : RTE_SET_USED(buf);
10402 : : RTE_SET_USED(size);
10403 : 0 : arg = ARGS_ENTRY_ARB_BOUNDED
10404 : : (offsetof(struct action_ipv6_ext_push_data, idx),
10405 : : sizeof(((struct action_ipv6_ext_push_data *)0)->idx),
10406 : : 0, IPV6_EXT_PUSH_CONFS_MAX_NUM - 1);
10407 : : if (push_args(ctx, arg))
10408 : : return -1;
10409 : 0 : ret = parse_int(ctx, token, str, len, NULL, 0);
10410 : 0 : if (ret < 0) {
10411 : : pop_args(ctx);
10412 : 0 : return -1;
10413 : : }
10414 : 0 : if (!ctx->object)
10415 : 0 : return len;
10416 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
10417 : : action_ipv6_ext_push_data = ctx->object;
10418 : 0 : idx = action_ipv6_ext_push_data->idx;
10419 : 0 : action_ipv6_ext_push_data->conf.type = ipv6_ext_push_confs[idx].type;
10420 : 0 : action_ipv6_ext_push_data->conf.size = ipv6_ext_push_confs[idx].size;
10421 : 0 : action_ipv6_ext_push_data->conf.data = ipv6_ext_push_confs[idx].data;
10422 : 0 : action->conf = &action_ipv6_ext_push_data->conf;
10423 : 0 : return len;
10424 : : }
10425 : :
10426 : : static int
10427 : 0 : parse_vc_action_set_meta(struct context *ctx, const struct token *token,
10428 : : const char *str, unsigned int len, void *buf,
10429 : : unsigned int size)
10430 : : {
10431 : : int ret;
10432 : :
10433 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
10434 : 0 : if (ret < 0)
10435 : : return ret;
10436 : 0 : ret = rte_flow_dynf_metadata_register();
10437 : 0 : if (ret < 0)
10438 : : return -1;
10439 : 0 : return len;
10440 : : }
10441 : :
10442 : : static int
10443 : 0 : parse_vc_action_sample(struct context *ctx, const struct token *token,
10444 : : const char *str, unsigned int len, void *buf,
10445 : : unsigned int size)
10446 : : {
10447 : : struct buffer *out = buf;
10448 : : struct rte_flow_action *action;
10449 : : struct action_sample_data *action_sample_data = NULL;
10450 : : static struct rte_flow_action end_action = {
10451 : : RTE_FLOW_ACTION_TYPE_END, 0
10452 : : };
10453 : : int ret;
10454 : :
10455 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
10456 : 0 : if (ret < 0)
10457 : : return ret;
10458 : : /* Nothing else to do if there is no buffer. */
10459 : 0 : if (!out)
10460 : : return ret;
10461 : 0 : if (!out->args.vc.actions_n)
10462 : : return -1;
10463 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
10464 : : /* Point to selected object. */
10465 : 0 : ctx->object = out->args.vc.data;
10466 : 0 : ctx->objmask = NULL;
10467 : : /* Copy the headers to the buffer. */
10468 : : action_sample_data = ctx->object;
10469 : 0 : action_sample_data->conf.actions = &end_action;
10470 : 0 : action->conf = &action_sample_data->conf;
10471 : 0 : return ret;
10472 : : }
10473 : :
10474 : : static int
10475 : 0 : parse_vc_action_sample_index(struct context *ctx, const struct token *token,
10476 : : const char *str, unsigned int len, void *buf,
10477 : : unsigned int size)
10478 : : {
10479 : : struct action_sample_data *action_sample_data;
10480 : : struct rte_flow_action *action;
10481 : : const struct arg *arg;
10482 : : struct buffer *out = buf;
10483 : : int ret;
10484 : : uint16_t idx;
10485 : :
10486 : : RTE_SET_USED(token);
10487 : : RTE_SET_USED(buf);
10488 : : RTE_SET_USED(size);
10489 : 0 : if (ctx->curr != ACTION_SAMPLE_INDEX_VALUE)
10490 : : return -1;
10491 : 0 : arg = ARGS_ENTRY_ARB_BOUNDED
10492 : : (offsetof(struct action_sample_data, idx),
10493 : : sizeof(((struct action_sample_data *)0)->idx),
10494 : : 0, RAW_SAMPLE_CONFS_MAX_NUM - 1);
10495 : : if (push_args(ctx, arg))
10496 : : return -1;
10497 : 0 : ret = parse_int(ctx, token, str, len, NULL, 0);
10498 : 0 : if (ret < 0) {
10499 : : pop_args(ctx);
10500 : 0 : return -1;
10501 : : }
10502 : 0 : if (!ctx->object)
10503 : 0 : return len;
10504 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
10505 : : action_sample_data = ctx->object;
10506 : 0 : idx = action_sample_data->idx;
10507 : 0 : action_sample_data->conf.actions = raw_sample_confs[idx].data;
10508 : 0 : action->conf = &action_sample_data->conf;
10509 : 0 : return len;
10510 : : }
10511 : :
10512 : : /** Parse operation for modify_field command. */
10513 : : static int
10514 : 0 : parse_vc_modify_field_op(struct context *ctx, const struct token *token,
10515 : : const char *str, unsigned int len, void *buf,
10516 : : unsigned int size)
10517 : : {
10518 : : struct rte_flow_action_modify_field *action_modify_field;
10519 : : unsigned int i;
10520 : :
10521 : : (void)token;
10522 : : (void)buf;
10523 : : (void)size;
10524 : 0 : if (ctx->curr != ACTION_MODIFY_FIELD_OP_VALUE)
10525 : : return -1;
10526 : 0 : for (i = 0; modify_field_ops[i]; ++i)
10527 : 0 : if (!strcmp_partial(modify_field_ops[i], str, len))
10528 : : break;
10529 : 0 : if (!modify_field_ops[i])
10530 : : return -1;
10531 : 0 : if (!ctx->object)
10532 : 0 : return len;
10533 : : action_modify_field = ctx->object;
10534 : 0 : action_modify_field->operation = (enum rte_flow_modify_op)i;
10535 : 0 : return len;
10536 : : }
10537 : :
10538 : : /** Parse id for modify_field command. */
10539 : : static int
10540 : 0 : parse_vc_modify_field_id(struct context *ctx, const struct token *token,
10541 : : const char *str, unsigned int len, void *buf,
10542 : : unsigned int size)
10543 : : {
10544 : : struct rte_flow_action_modify_field *action_modify_field;
10545 : : unsigned int i;
10546 : :
10547 : : (void)token;
10548 : : (void)buf;
10549 : : (void)size;
10550 : 0 : if (ctx->curr != ACTION_MODIFY_FIELD_DST_TYPE_VALUE &&
10551 : : ctx->curr != ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)
10552 : : return -1;
10553 : 0 : for (i = 0; flow_field_ids[i]; ++i)
10554 : 0 : if (!strcmp_partial(flow_field_ids[i], str, len))
10555 : : break;
10556 : 0 : if (!flow_field_ids[i])
10557 : : return -1;
10558 : 0 : if (!ctx->object)
10559 : 0 : return len;
10560 : : action_modify_field = ctx->object;
10561 : 0 : if (ctx->curr == ACTION_MODIFY_FIELD_DST_TYPE_VALUE)
10562 : 0 : action_modify_field->dst.field = (enum rte_flow_field_id)i;
10563 : : else
10564 : 0 : action_modify_field->src.field = (enum rte_flow_field_id)i;
10565 : 0 : return len;
10566 : : }
10567 : :
10568 : : /** Parse level for modify_field command. */
10569 : : static int
10570 : 0 : parse_vc_modify_field_level(struct context *ctx, const struct token *token,
10571 : : const char *str, unsigned int len, void *buf,
10572 : : unsigned int size)
10573 : : {
10574 : : struct rte_flow_action_modify_field *action;
10575 : : struct flex_item *fp = NULL;
10576 : : uint32_t val;
10577 : : struct buffer *out = buf;
10578 : : char *end;
10579 : :
10580 : : (void)token;
10581 : : (void)size;
10582 : 0 : if (ctx->curr != ACTION_MODIFY_FIELD_DST_LEVEL_VALUE &&
10583 : : ctx->curr != ACTION_MODIFY_FIELD_SRC_LEVEL_VALUE)
10584 : : return -1;
10585 : 0 : if (!ctx->object)
10586 : 0 : return len;
10587 : : action = ctx->object;
10588 : 0 : errno = 0;
10589 : 0 : val = strtoumax(str, &end, 0);
10590 : 0 : if (errno || (size_t)(end - str) != len)
10591 : : return -1;
10592 : : /* No need to validate action template mask value */
10593 : 0 : if (out->args.vc.masks) {
10594 : 0 : if (ctx->curr == ACTION_MODIFY_FIELD_DST_LEVEL_VALUE)
10595 : 0 : action->dst.level = val;
10596 : : else
10597 : 0 : action->src.level = val;
10598 : 0 : return len;
10599 : : }
10600 : 0 : if ((ctx->curr == ACTION_MODIFY_FIELD_DST_LEVEL_VALUE &&
10601 : 0 : action->dst.field == RTE_FLOW_FIELD_FLEX_ITEM) ||
10602 : 0 : (ctx->curr == ACTION_MODIFY_FIELD_SRC_LEVEL_VALUE &&
10603 : 0 : action->src.field == RTE_FLOW_FIELD_FLEX_ITEM)) {
10604 : 0 : if (val >= FLEX_MAX_PARSERS_NUM) {
10605 : : printf("Bad flex item handle\n");
10606 : 0 : return -1;
10607 : : }
10608 : 0 : fp = flex_items[ctx->port][val];
10609 : 0 : if (!fp) {
10610 : : printf("Bad flex item handle\n");
10611 : 0 : return -1;
10612 : : }
10613 : : }
10614 : 0 : if (ctx->curr == ACTION_MODIFY_FIELD_DST_LEVEL_VALUE) {
10615 : 0 : if (action->dst.field != RTE_FLOW_FIELD_FLEX_ITEM)
10616 : 0 : action->dst.level = val;
10617 : : else
10618 : 0 : action->dst.flex_handle = fp->flex_handle;
10619 : 0 : } else if (ctx->curr == ACTION_MODIFY_FIELD_SRC_LEVEL_VALUE) {
10620 : 0 : if (action->src.field != RTE_FLOW_FIELD_FLEX_ITEM)
10621 : 0 : action->src.level = val;
10622 : : else
10623 : 0 : action->src.flex_handle = fp->flex_handle;
10624 : : }
10625 : 0 : return len;
10626 : : }
10627 : :
10628 : : /** Parse the conntrack update, not a rte_flow_action. */
10629 : : static int
10630 : 0 : parse_vc_action_conntrack_update(struct context *ctx, const struct token *token,
10631 : : const char *str, unsigned int len, void *buf,
10632 : : unsigned int size)
10633 : : {
10634 : : struct buffer *out = buf;
10635 : : struct rte_flow_modify_conntrack *ct_modify = NULL;
10636 : :
10637 : : (void)size;
10638 : 0 : if (ctx->curr != ACTION_CONNTRACK_UPDATE_CTX &&
10639 : : ctx->curr != ACTION_CONNTRACK_UPDATE_DIR)
10640 : : return -1;
10641 : : /* Token name must match. */
10642 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
10643 : : return -1;
10644 : : /* Nothing else to do if there is no buffer. */
10645 : 0 : if (!out)
10646 : : return len;
10647 : 0 : ct_modify = (struct rte_flow_modify_conntrack *)out->args.vc.data;
10648 : 0 : if (ctx->curr == ACTION_CONNTRACK_UPDATE_DIR) {
10649 : 0 : ct_modify->new_ct.is_original_dir =
10650 : 0 : conntrack_context.is_original_dir;
10651 : 0 : ct_modify->direction = 1;
10652 : : } else {
10653 : : uint32_t old_dir;
10654 : :
10655 : 0 : old_dir = ct_modify->new_ct.is_original_dir;
10656 : 0 : memcpy(&ct_modify->new_ct, &conntrack_context,
10657 : : sizeof(conntrack_context));
10658 : 0 : ct_modify->new_ct.is_original_dir = old_dir;
10659 : 0 : ct_modify->state = 1;
10660 : : }
10661 : : return len;
10662 : : }
10663 : :
10664 : : /** Parse tokens for destroy command. */
10665 : : static int
10666 : 0 : parse_destroy(struct context *ctx, const struct token *token,
10667 : : const char *str, unsigned int len,
10668 : : void *buf, unsigned int size)
10669 : : {
10670 : : struct buffer *out = buf;
10671 : :
10672 : : /* Token name must match. */
10673 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
10674 : : return -1;
10675 : : /* Nothing else to do if there is no buffer. */
10676 : 0 : if (!out)
10677 : : return len;
10678 : 0 : if (!out->command) {
10679 : 0 : if (ctx->curr != DESTROY)
10680 : : return -1;
10681 : 0 : if (sizeof(*out) > size)
10682 : : return -1;
10683 : 0 : out->command = ctx->curr;
10684 : 0 : ctx->objdata = 0;
10685 : 0 : ctx->object = out;
10686 : 0 : ctx->objmask = NULL;
10687 : 0 : out->args.destroy.rule =
10688 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
10689 : : sizeof(double));
10690 : 0 : return len;
10691 : : }
10692 : 0 : if (ctx->curr == DESTROY_IS_USER_ID) {
10693 : 0 : out->args.destroy.is_user_id = true;
10694 : 0 : return len;
10695 : : }
10696 : 0 : if (((uint8_t *)(out->args.destroy.rule + out->args.destroy.rule_n) +
10697 : 0 : sizeof(*out->args.destroy.rule)) > (uint8_t *)out + size)
10698 : : return -1;
10699 : 0 : ctx->objdata = 0;
10700 : 0 : ctx->object = out->args.destroy.rule + out->args.destroy.rule_n++;
10701 : 0 : ctx->objmask = NULL;
10702 : 0 : return len;
10703 : : }
10704 : :
10705 : : /** Parse tokens for flush command. */
10706 : : static int
10707 : 0 : parse_flush(struct context *ctx, const struct token *token,
10708 : : const char *str, unsigned int len,
10709 : : void *buf, unsigned int size)
10710 : : {
10711 : : struct buffer *out = buf;
10712 : :
10713 : : /* Token name must match. */
10714 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
10715 : : return -1;
10716 : : /* Nothing else to do if there is no buffer. */
10717 : 0 : if (!out)
10718 : : return len;
10719 : 0 : if (!out->command) {
10720 : 0 : if (ctx->curr != FLUSH)
10721 : : return -1;
10722 : 0 : if (sizeof(*out) > size)
10723 : : return -1;
10724 : 0 : out->command = ctx->curr;
10725 : 0 : ctx->objdata = 0;
10726 : 0 : ctx->object = out;
10727 : 0 : ctx->objmask = NULL;
10728 : : }
10729 : : return len;
10730 : : }
10731 : :
10732 : : /** Parse tokens for dump command. */
10733 : : static int
10734 : 0 : parse_dump(struct context *ctx, const struct token *token,
10735 : : const char *str, unsigned int len,
10736 : : void *buf, unsigned int size)
10737 : : {
10738 : : struct buffer *out = buf;
10739 : :
10740 : : /* Token name must match. */
10741 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
10742 : : return -1;
10743 : : /* Nothing else to do if there is no buffer. */
10744 : 0 : if (!out)
10745 : : return len;
10746 : 0 : if (!out->command) {
10747 : 0 : if (ctx->curr != DUMP)
10748 : : return -1;
10749 : 0 : if (sizeof(*out) > size)
10750 : : return -1;
10751 : 0 : out->command = ctx->curr;
10752 : 0 : ctx->objdata = 0;
10753 : 0 : ctx->object = out;
10754 : 0 : ctx->objmask = NULL;
10755 : 0 : return len;
10756 : : }
10757 : 0 : switch (ctx->curr) {
10758 : 0 : case DUMP_ALL:
10759 : : case DUMP_ONE:
10760 : 0 : out->args.dump.dump_all = (ctx->curr == DUMP_ALL) ? true : false;
10761 : : /* don't append to file by default */
10762 : 0 : out->args.dump.append_to_file = false;
10763 : 0 : out->command = ctx->curr;
10764 : 0 : ctx->objdata = 0;
10765 : 0 : ctx->object = out;
10766 : 0 : ctx->objmask = NULL;
10767 : 0 : return len;
10768 : 0 : case DUMP_IS_USER_ID:
10769 : 0 : out->args.dump.is_user_id = true;
10770 : 0 : return len;
10771 : 0 : case DUMP_WRITE:
10772 : 0 : out->args.dump.append_to_file = false;
10773 : 0 : return len;
10774 : 0 : case DUMP_APPEND:
10775 : 0 : out->args.dump.append_to_file = true;
10776 : 0 : return len;
10777 : : default:
10778 : : return -1;
10779 : : }
10780 : : }
10781 : :
10782 : : /** Parse tokens for query command. */
10783 : : static int
10784 : 0 : parse_query(struct context *ctx, const struct token *token,
10785 : : const char *str, unsigned int len,
10786 : : void *buf, unsigned int size)
10787 : : {
10788 : : struct buffer *out = buf;
10789 : :
10790 : : /* Token name must match. */
10791 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
10792 : : return -1;
10793 : : /* Nothing else to do if there is no buffer. */
10794 : 0 : if (!out)
10795 : : return len;
10796 : 0 : if (!out->command) {
10797 : 0 : if (ctx->curr != QUERY)
10798 : : return -1;
10799 : 0 : if (sizeof(*out) > size)
10800 : : return -1;
10801 : 0 : out->command = ctx->curr;
10802 : 0 : ctx->objdata = 0;
10803 : 0 : ctx->object = out;
10804 : 0 : ctx->objmask = NULL;
10805 : : }
10806 : 0 : if (ctx->curr == QUERY_IS_USER_ID) {
10807 : 0 : out->args.query.is_user_id = true;
10808 : 0 : return len;
10809 : : }
10810 : : return len;
10811 : : }
10812 : :
10813 : : /** Parse action names. */
10814 : : static int
10815 : 0 : parse_action(struct context *ctx, const struct token *token,
10816 : : const char *str, unsigned int len,
10817 : : void *buf, unsigned int size)
10818 : : {
10819 : : struct buffer *out = buf;
10820 : : const struct arg *arg = pop_args(ctx);
10821 : : unsigned int i;
10822 : :
10823 : : (void)size;
10824 : : /* Argument is expected. */
10825 : 0 : if (!arg)
10826 : 0 : return -1;
10827 : : /* Parse action name. */
10828 : 0 : for (i = 0; next_action[i]; ++i) {
10829 : : const struct parse_action_priv *priv;
10830 : :
10831 : : token = &token_list[next_action[i]];
10832 : 0 : if (strcmp_partial(token->name, str, len))
10833 : : continue;
10834 : 0 : priv = token->priv;
10835 : 0 : if (!priv)
10836 : 0 : goto error;
10837 : 0 : if (out)
10838 : 0 : memcpy((uint8_t *)ctx->object + arg->offset,
10839 : 0 : &priv->type,
10840 : 0 : arg->size);
10841 : 0 : return len;
10842 : : }
10843 : 0 : error:
10844 : : push_args(ctx, arg);
10845 : : return -1;
10846 : : }
10847 : :
10848 : : /** Parse tokens for list command. */
10849 : : static int
10850 : 0 : parse_list(struct context *ctx, const struct token *token,
10851 : : const char *str, unsigned int len,
10852 : : void *buf, unsigned int size)
10853 : : {
10854 : : struct buffer *out = buf;
10855 : :
10856 : : /* Token name must match. */
10857 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
10858 : : return -1;
10859 : : /* Nothing else to do if there is no buffer. */
10860 : 0 : if (!out)
10861 : : return len;
10862 : 0 : if (!out->command) {
10863 : 0 : if (ctx->curr != LIST)
10864 : : return -1;
10865 : 0 : if (sizeof(*out) > size)
10866 : : return -1;
10867 : 0 : out->command = ctx->curr;
10868 : 0 : ctx->objdata = 0;
10869 : 0 : ctx->object = out;
10870 : 0 : ctx->objmask = NULL;
10871 : 0 : out->args.list.group =
10872 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
10873 : : sizeof(double));
10874 : 0 : return len;
10875 : : }
10876 : 0 : if (((uint8_t *)(out->args.list.group + out->args.list.group_n) +
10877 : 0 : sizeof(*out->args.list.group)) > (uint8_t *)out + size)
10878 : : return -1;
10879 : 0 : ctx->objdata = 0;
10880 : 0 : ctx->object = out->args.list.group + out->args.list.group_n++;
10881 : 0 : ctx->objmask = NULL;
10882 : 0 : return len;
10883 : : }
10884 : :
10885 : : /** Parse tokens for list all aged flows command. */
10886 : : static int
10887 : 0 : parse_aged(struct context *ctx, const struct token *token,
10888 : : const char *str, unsigned int len,
10889 : : void *buf, unsigned int size)
10890 : : {
10891 : : struct buffer *out = buf;
10892 : :
10893 : : /* Token name must match. */
10894 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
10895 : : return -1;
10896 : : /* Nothing else to do if there is no buffer. */
10897 : 0 : if (!out)
10898 : : return len;
10899 : 0 : if (!out->command || out->command == QUEUE) {
10900 : 0 : if (ctx->curr != AGED && ctx->curr != QUEUE_AGED)
10901 : : return -1;
10902 : 0 : if (sizeof(*out) > size)
10903 : : return -1;
10904 : 0 : out->command = ctx->curr;
10905 : 0 : ctx->objdata = 0;
10906 : 0 : ctx->object = out;
10907 : 0 : ctx->objmask = NULL;
10908 : : }
10909 : 0 : if (ctx->curr == AGED_DESTROY)
10910 : 0 : out->args.aged.destroy = 1;
10911 : : return len;
10912 : : }
10913 : :
10914 : : /** Parse tokens for isolate command. */
10915 : : static int
10916 : 0 : parse_isolate(struct context *ctx, const struct token *token,
10917 : : const char *str, unsigned int len,
10918 : : void *buf, unsigned int size)
10919 : : {
10920 : : struct buffer *out = buf;
10921 : :
10922 : : /* Token name must match. */
10923 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
10924 : : return -1;
10925 : : /* Nothing else to do if there is no buffer. */
10926 : 0 : if (!out)
10927 : : return len;
10928 : 0 : if (!out->command) {
10929 : 0 : if (ctx->curr != ISOLATE)
10930 : : return -1;
10931 : 0 : if (sizeof(*out) > size)
10932 : : return -1;
10933 : 0 : out->command = ctx->curr;
10934 : 0 : ctx->objdata = 0;
10935 : 0 : ctx->object = out;
10936 : 0 : ctx->objmask = NULL;
10937 : : }
10938 : : return len;
10939 : : }
10940 : :
10941 : : /** Parse tokens for info/configure command. */
10942 : : static int
10943 : 0 : parse_configure(struct context *ctx, const struct token *token,
10944 : : const char *str, unsigned int len,
10945 : : void *buf, unsigned int size)
10946 : : {
10947 : : struct buffer *out = buf;
10948 : :
10949 : : /* Token name must match. */
10950 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
10951 : : return -1;
10952 : : /* Nothing else to do if there is no buffer. */
10953 : 0 : if (!out)
10954 : : return len;
10955 : 0 : if (!out->command) {
10956 : 0 : if (ctx->curr != INFO && ctx->curr != CONFIGURE)
10957 : : return -1;
10958 : 0 : if (sizeof(*out) > size)
10959 : : return -1;
10960 : 0 : out->command = ctx->curr;
10961 : 0 : ctx->objdata = 0;
10962 : 0 : ctx->object = out;
10963 : 0 : ctx->objmask = NULL;
10964 : : }
10965 : : return len;
10966 : : }
10967 : :
10968 : : /** Parse tokens for template create command. */
10969 : : static int
10970 : 0 : parse_template(struct context *ctx, const struct token *token,
10971 : : const char *str, unsigned int len,
10972 : : void *buf, unsigned int size)
10973 : : {
10974 : : struct buffer *out = buf;
10975 : :
10976 : : /* Token name must match. */
10977 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
10978 : : return -1;
10979 : : /* Nothing else to do if there is no buffer. */
10980 : 0 : if (!out)
10981 : : return len;
10982 : 0 : if (!out->command) {
10983 : 0 : if (ctx->curr != PATTERN_TEMPLATE &&
10984 : : ctx->curr != ACTIONS_TEMPLATE)
10985 : : return -1;
10986 : 0 : if (sizeof(*out) > size)
10987 : : return -1;
10988 : 0 : out->command = ctx->curr;
10989 : 0 : ctx->objdata = 0;
10990 : 0 : ctx->object = out;
10991 : 0 : ctx->objmask = NULL;
10992 : 0 : out->args.vc.data = (uint8_t *)out + size;
10993 : 0 : return len;
10994 : : }
10995 : 0 : switch (ctx->curr) {
10996 : 0 : case PATTERN_TEMPLATE_CREATE:
10997 : 0 : out->args.vc.pattern =
10998 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
10999 : : sizeof(double));
11000 : 0 : out->args.vc.pat_templ_id = UINT32_MAX;
11001 : 0 : out->command = ctx->curr;
11002 : 0 : ctx->objdata = 0;
11003 : 0 : ctx->object = out;
11004 : 0 : ctx->objmask = NULL;
11005 : 0 : return len;
11006 : 0 : case PATTERN_TEMPLATE_EGRESS:
11007 : 0 : out->args.vc.attr.egress = 1;
11008 : 0 : return len;
11009 : 0 : case PATTERN_TEMPLATE_INGRESS:
11010 : 0 : out->args.vc.attr.ingress = 1;
11011 : 0 : return len;
11012 : 0 : case PATTERN_TEMPLATE_TRANSFER:
11013 : 0 : out->args.vc.attr.transfer = 1;
11014 : 0 : return len;
11015 : 0 : case ACTIONS_TEMPLATE_CREATE:
11016 : 0 : out->args.vc.act_templ_id = UINT32_MAX;
11017 : 0 : out->command = ctx->curr;
11018 : 0 : ctx->objdata = 0;
11019 : 0 : ctx->object = out;
11020 : 0 : ctx->objmask = NULL;
11021 : 0 : return len;
11022 : 0 : case ACTIONS_TEMPLATE_SPEC:
11023 : 0 : out->args.vc.actions =
11024 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
11025 : : sizeof(double));
11026 : 0 : ctx->object = out->args.vc.actions;
11027 : 0 : ctx->objmask = NULL;
11028 : 0 : return len;
11029 : 0 : case ACTIONS_TEMPLATE_MASK:
11030 : 0 : out->args.vc.masks =
11031 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)
11032 : : (out->args.vc.actions +
11033 : : out->args.vc.actions_n),
11034 : : sizeof(double));
11035 : 0 : ctx->object = out->args.vc.masks;
11036 : 0 : ctx->objmask = NULL;
11037 : 0 : return len;
11038 : 0 : case ACTIONS_TEMPLATE_EGRESS:
11039 : 0 : out->args.vc.attr.egress = 1;
11040 : 0 : return len;
11041 : 0 : case ACTIONS_TEMPLATE_INGRESS:
11042 : 0 : out->args.vc.attr.ingress = 1;
11043 : 0 : return len;
11044 : 0 : case ACTIONS_TEMPLATE_TRANSFER:
11045 : 0 : out->args.vc.attr.transfer = 1;
11046 : 0 : return len;
11047 : : default:
11048 : : return -1;
11049 : : }
11050 : : }
11051 : :
11052 : : /** Parse tokens for template destroy command. */
11053 : : static int
11054 : 0 : parse_template_destroy(struct context *ctx, const struct token *token,
11055 : : const char *str, unsigned int len,
11056 : : void *buf, unsigned int size)
11057 : : {
11058 : : struct buffer *out = buf;
11059 : : uint32_t *template_id;
11060 : :
11061 : : /* Token name must match. */
11062 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
11063 : : return -1;
11064 : : /* Nothing else to do if there is no buffer. */
11065 : 0 : if (!out)
11066 : : return len;
11067 : 0 : if (!out->command ||
11068 : 0 : out->command == PATTERN_TEMPLATE ||
11069 : : out->command == ACTIONS_TEMPLATE) {
11070 : 0 : if (ctx->curr != PATTERN_TEMPLATE_DESTROY &&
11071 : : ctx->curr != ACTIONS_TEMPLATE_DESTROY)
11072 : : return -1;
11073 : 0 : if (sizeof(*out) > size)
11074 : : return -1;
11075 : 0 : out->command = ctx->curr;
11076 : 0 : ctx->objdata = 0;
11077 : 0 : ctx->object = out;
11078 : 0 : ctx->objmask = NULL;
11079 : 0 : out->args.templ_destroy.template_id =
11080 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
11081 : : sizeof(double));
11082 : 0 : return len;
11083 : : }
11084 : 0 : template_id = out->args.templ_destroy.template_id
11085 : 0 : + out->args.templ_destroy.template_id_n++;
11086 : 0 : if ((uint8_t *)template_id > (uint8_t *)out + size)
11087 : : return -1;
11088 : 0 : ctx->objdata = 0;
11089 : 0 : ctx->object = template_id;
11090 : 0 : ctx->objmask = NULL;
11091 : 0 : return len;
11092 : : }
11093 : :
11094 : : /** Parse tokens for table create command. */
11095 : : static int
11096 : 0 : parse_table(struct context *ctx, const struct token *token,
11097 : : const char *str, unsigned int len,
11098 : : void *buf, unsigned int size)
11099 : : {
11100 : : struct buffer *out = buf;
11101 : : uint32_t *template_id;
11102 : :
11103 : : /* Token name must match. */
11104 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
11105 : : return -1;
11106 : : /* Nothing else to do if there is no buffer. */
11107 : 0 : if (!out)
11108 : : return len;
11109 : 0 : if (!out->command) {
11110 : 0 : if (ctx->curr != TABLE)
11111 : : return -1;
11112 : 0 : if (sizeof(*out) > size)
11113 : : return -1;
11114 : 0 : out->command = ctx->curr;
11115 : 0 : ctx->objdata = 0;
11116 : 0 : ctx->object = out;
11117 : 0 : ctx->objmask = NULL;
11118 : 0 : return len;
11119 : : }
11120 : 0 : switch (ctx->curr) {
11121 : 0 : case TABLE_CREATE:
11122 : : case TABLE_RESIZE:
11123 : 0 : out->command = ctx->curr;
11124 : 0 : ctx->objdata = 0;
11125 : 0 : ctx->object = out;
11126 : 0 : ctx->objmask = NULL;
11127 : 0 : out->args.table.id = UINT32_MAX;
11128 : 0 : return len;
11129 : 0 : case TABLE_PATTERN_TEMPLATE:
11130 : 0 : out->args.table.pat_templ_id =
11131 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
11132 : : sizeof(double));
11133 : 0 : template_id = out->args.table.pat_templ_id
11134 : 0 : + out->args.table.pat_templ_id_n++;
11135 : 0 : if ((uint8_t *)template_id > (uint8_t *)out + size)
11136 : : return -1;
11137 : 0 : ctx->objdata = 0;
11138 : 0 : ctx->object = template_id;
11139 : 0 : ctx->objmask = NULL;
11140 : 0 : return len;
11141 : 0 : case TABLE_ACTIONS_TEMPLATE:
11142 : 0 : out->args.table.act_templ_id =
11143 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)
11144 : : (out->args.table.pat_templ_id +
11145 : : out->args.table.pat_templ_id_n),
11146 : : sizeof(double));
11147 : 0 : template_id = out->args.table.act_templ_id
11148 : 0 : + out->args.table.act_templ_id_n++;
11149 : 0 : if ((uint8_t *)template_id > (uint8_t *)out + size)
11150 : : return -1;
11151 : 0 : ctx->objdata = 0;
11152 : 0 : ctx->object = template_id;
11153 : 0 : ctx->objmask = NULL;
11154 : 0 : return len;
11155 : 0 : case TABLE_INGRESS:
11156 : 0 : out->args.table.attr.flow_attr.ingress = 1;
11157 : 0 : return len;
11158 : 0 : case TABLE_EGRESS:
11159 : 0 : out->args.table.attr.flow_attr.egress = 1;
11160 : 0 : return len;
11161 : 0 : case TABLE_TRANSFER:
11162 : 0 : out->args.table.attr.flow_attr.transfer = 1;
11163 : 0 : return len;
11164 : 0 : case TABLE_TRANSFER_WIRE_ORIG:
11165 : 0 : if (!out->args.table.attr.flow_attr.transfer)
11166 : : return -1;
11167 : 0 : out->args.table.attr.specialize |= RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_WIRE_ORIG;
11168 : 0 : return len;
11169 : 0 : case TABLE_TRANSFER_VPORT_ORIG:
11170 : 0 : if (!out->args.table.attr.flow_attr.transfer)
11171 : : return -1;
11172 : 0 : out->args.table.attr.specialize |= RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_VPORT_ORIG;
11173 : 0 : return len;
11174 : 0 : case TABLE_RESIZABLE:
11175 : 0 : out->args.table.attr.specialize |=
11176 : : RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE;
11177 : 0 : return len;
11178 : 0 : case TABLE_RULES_NUMBER:
11179 : 0 : ctx->objdata = 0;
11180 : 0 : ctx->object = out;
11181 : 0 : ctx->objmask = NULL;
11182 : 0 : return len;
11183 : 0 : case TABLE_RESIZE_ID:
11184 : : case TABLE_RESIZE_RULES_NUMBER:
11185 : 0 : return len;
11186 : : default:
11187 : : return -1;
11188 : : }
11189 : : }
11190 : :
11191 : : /** Parse tokens for table destroy command. */
11192 : : static int
11193 : 0 : parse_table_destroy(struct context *ctx, const struct token *token,
11194 : : const char *str, unsigned int len,
11195 : : void *buf, unsigned int size)
11196 : : {
11197 : : struct buffer *out = buf;
11198 : : uint32_t *table_id;
11199 : :
11200 : : /* Token name must match. */
11201 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
11202 : : return -1;
11203 : : /* Nothing else to do if there is no buffer. */
11204 : 0 : if (!out)
11205 : : return len;
11206 : 0 : if (!out->command || out->command == TABLE) {
11207 : 0 : if (ctx->curr != TABLE_DESTROY &&
11208 : : ctx->curr != TABLE_RESIZE_COMPLETE)
11209 : : return -1;
11210 : 0 : if (sizeof(*out) > size)
11211 : : return -1;
11212 : 0 : out->command = ctx->curr;
11213 : 0 : ctx->objdata = 0;
11214 : 0 : ctx->object = out;
11215 : 0 : ctx->objmask = NULL;
11216 : 0 : out->args.table_destroy.table_id =
11217 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
11218 : : sizeof(double));
11219 : 0 : return len;
11220 : : }
11221 : 0 : table_id = out->args.table_destroy.table_id
11222 : 0 : + out->args.table_destroy.table_id_n++;
11223 : 0 : if ((uint8_t *)table_id > (uint8_t *)out + size)
11224 : : return -1;
11225 : 0 : ctx->objdata = 0;
11226 : 0 : ctx->object = table_id;
11227 : 0 : ctx->objmask = NULL;
11228 : 0 : return len;
11229 : : }
11230 : :
11231 : : /** Parse table id and convert to table pointer for jump_to_table_index action. */
11232 : : static int
11233 : 0 : parse_jump_table_id(struct context *ctx, const struct token *token,
11234 : : const char *str, unsigned int len,
11235 : : void *buf, unsigned int size)
11236 : : {
11237 : : struct buffer *out = buf;
11238 : : struct rte_port *port;
11239 : : struct port_table *pt;
11240 : : uint32_t table_id;
11241 : : const struct arg *arg;
11242 : : void *entry_ptr;
11243 : :
11244 : : /* Get the arg before parse_int consumes it */
11245 : : arg = pop_args(ctx);
11246 : 0 : if (!arg)
11247 : 0 : return -1;
11248 : : /* Push it back and do the standard integer parsing */
11249 : : if (push_args(ctx, arg) < 0)
11250 : : return -1;
11251 : 0 : if (parse_int(ctx, token, str, len, buf, size) < 0)
11252 : : return -1;
11253 : : /* Nothing else to do if there is no buffer */
11254 : 0 : if (!out || !ctx->object)
11255 : 0 : return len;
11256 : : /* Get the parsed table ID from where parse_int stored it */
11257 : 0 : entry_ptr = (uint8_t *)ctx->object + arg->offset;
11258 : : memcpy(&table_id, entry_ptr, sizeof(uint32_t));
11259 : : /* Look up the table using table ID */
11260 : 0 : port = &ports[ctx->port];
11261 : 0 : for (pt = port->table_list; pt != NULL; pt = pt->next) {
11262 : 0 : if (pt->id == table_id)
11263 : : break;
11264 : : }
11265 : 0 : if (!pt || !pt->table) {
11266 : 0 : printf("Table #%u not found on port %u\n", table_id, ctx->port);
11267 : 0 : return -1;
11268 : : }
11269 : : /* Replace the table ID with the table pointer */
11270 : 0 : memcpy(entry_ptr, &pt->table, sizeof(struct rte_flow_template_table *));
11271 : 0 : return len;
11272 : : }
11273 : :
11274 : : /** Parse tokens for queue create commands. */
11275 : : static int
11276 : 0 : parse_qo(struct context *ctx, const struct token *token,
11277 : : const char *str, unsigned int len,
11278 : : void *buf, unsigned int size)
11279 : : {
11280 : : struct buffer *out = buf;
11281 : :
11282 : : /* Token name must match. */
11283 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
11284 : : return -1;
11285 : : /* Nothing else to do if there is no buffer. */
11286 : 0 : if (!out)
11287 : : return len;
11288 : 0 : if (!out->command) {
11289 : 0 : if (ctx->curr != QUEUE)
11290 : : return -1;
11291 : 0 : if (sizeof(*out) > size)
11292 : : return -1;
11293 : 0 : out->command = ctx->curr;
11294 : 0 : ctx->objdata = 0;
11295 : 0 : ctx->object = out;
11296 : 0 : ctx->objmask = NULL;
11297 : 0 : out->args.vc.data = (uint8_t *)out + size;
11298 : 0 : return len;
11299 : : }
11300 : 0 : switch (ctx->curr) {
11301 : 0 : case QUEUE_CREATE:
11302 : : case QUEUE_UPDATE:
11303 : 0 : out->command = ctx->curr;
11304 : 0 : ctx->objdata = 0;
11305 : 0 : ctx->object = out;
11306 : 0 : ctx->objmask = NULL;
11307 : 0 : out->args.vc.rule_id = UINT32_MAX;
11308 : 0 : return len;
11309 : 0 : case QUEUE_TEMPLATE_TABLE:
11310 : : case QUEUE_PATTERN_TEMPLATE:
11311 : : case QUEUE_ACTIONS_TEMPLATE:
11312 : : case QUEUE_CREATE_POSTPONE:
11313 : : case QUEUE_RULE_ID:
11314 : : case QUEUE_UPDATE_ID:
11315 : 0 : return len;
11316 : 0 : case ITEM_PATTERN:
11317 : 0 : out->args.vc.pattern =
11318 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
11319 : : sizeof(double));
11320 : 0 : ctx->object = out->args.vc.pattern;
11321 : 0 : ctx->objmask = NULL;
11322 : 0 : return len;
11323 : 0 : case ACTIONS:
11324 : 0 : out->args.vc.actions =
11325 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)
11326 : : (out->args.vc.pattern +
11327 : : out->args.vc.pattern_n),
11328 : : sizeof(double));
11329 : 0 : ctx->object = out->args.vc.actions;
11330 : 0 : ctx->objmask = NULL;
11331 : 0 : return len;
11332 : : default:
11333 : : return -1;
11334 : : }
11335 : : }
11336 : :
11337 : : /** Parse tokens for queue destroy command. */
11338 : : static int
11339 : 0 : parse_qo_destroy(struct context *ctx, const struct token *token,
11340 : : const char *str, unsigned int len,
11341 : : void *buf, unsigned int size)
11342 : : {
11343 : : struct buffer *out = buf;
11344 : : uint64_t *flow_id;
11345 : :
11346 : : /* Token name must match. */
11347 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
11348 : : return -1;
11349 : : /* Nothing else to do if there is no buffer. */
11350 : 0 : if (!out)
11351 : : return len;
11352 : 0 : if (!out->command || out->command == QUEUE) {
11353 : 0 : if (ctx->curr != QUEUE_DESTROY &&
11354 : : ctx->curr != QUEUE_FLOW_UPDATE_RESIZED)
11355 : : return -1;
11356 : 0 : if (sizeof(*out) > size)
11357 : : return -1;
11358 : 0 : out->command = ctx->curr;
11359 : 0 : ctx->objdata = 0;
11360 : 0 : ctx->object = out;
11361 : 0 : ctx->objmask = NULL;
11362 : 0 : out->args.destroy.rule =
11363 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
11364 : : sizeof(double));
11365 : 0 : return len;
11366 : : }
11367 : 0 : switch (ctx->curr) {
11368 : 0 : case QUEUE_DESTROY_ID:
11369 : 0 : flow_id = out->args.destroy.rule
11370 : 0 : + out->args.destroy.rule_n++;
11371 : 0 : if ((uint8_t *)flow_id > (uint8_t *)out + size)
11372 : : return -1;
11373 : 0 : ctx->objdata = 0;
11374 : 0 : ctx->object = flow_id;
11375 : 0 : ctx->objmask = NULL;
11376 : 0 : return len;
11377 : 0 : case QUEUE_DESTROY_POSTPONE:
11378 : 0 : return len;
11379 : : default:
11380 : : return -1;
11381 : : }
11382 : : }
11383 : :
11384 : : /** Parse tokens for push queue command. */
11385 : : static int
11386 : 0 : parse_push(struct context *ctx, const struct token *token,
11387 : : const char *str, unsigned int len,
11388 : : void *buf, unsigned int size)
11389 : : {
11390 : : struct buffer *out = buf;
11391 : :
11392 : : /* Token name must match. */
11393 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
11394 : : return -1;
11395 : : /* Nothing else to do if there is no buffer. */
11396 : 0 : if (!out)
11397 : : return len;
11398 : 0 : if (!out->command) {
11399 : 0 : if (ctx->curr != PUSH)
11400 : : return -1;
11401 : 0 : if (sizeof(*out) > size)
11402 : : return -1;
11403 : 0 : out->command = ctx->curr;
11404 : 0 : ctx->objdata = 0;
11405 : 0 : ctx->object = out;
11406 : 0 : ctx->objmask = NULL;
11407 : 0 : out->args.vc.data = (uint8_t *)out + size;
11408 : : }
11409 : : return len;
11410 : : }
11411 : :
11412 : : /** Parse tokens for pull command. */
11413 : : static int
11414 : 0 : parse_pull(struct context *ctx, const struct token *token,
11415 : : const char *str, unsigned int len,
11416 : : void *buf, unsigned int size)
11417 : : {
11418 : : struct buffer *out = buf;
11419 : :
11420 : : /* Token name must match. */
11421 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
11422 : : return -1;
11423 : : /* Nothing else to do if there is no buffer. */
11424 : 0 : if (!out)
11425 : : return len;
11426 : 0 : if (!out->command) {
11427 : 0 : if (ctx->curr != PULL)
11428 : : return -1;
11429 : 0 : if (sizeof(*out) > size)
11430 : : return -1;
11431 : 0 : out->command = ctx->curr;
11432 : 0 : ctx->objdata = 0;
11433 : 0 : ctx->object = out;
11434 : 0 : ctx->objmask = NULL;
11435 : 0 : out->args.vc.data = (uint8_t *)out + size;
11436 : : }
11437 : : return len;
11438 : : }
11439 : :
11440 : : /** Parse tokens for hash calculation commands. */
11441 : : static int
11442 : 0 : parse_hash(struct context *ctx, const struct token *token,
11443 : : const char *str, unsigned int len,
11444 : : void *buf, unsigned int size)
11445 : : {
11446 : : struct buffer *out = buf;
11447 : :
11448 : : /* Token name must match. */
11449 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
11450 : : return -1;
11451 : : /* Nothing else to do if there is no buffer. */
11452 : 0 : if (!out)
11453 : : return len;
11454 : 0 : if (!out->command) {
11455 : 0 : if (ctx->curr != HASH)
11456 : : return -1;
11457 : 0 : if (sizeof(*out) > size)
11458 : : return -1;
11459 : 0 : out->command = ctx->curr;
11460 : 0 : ctx->objdata = 0;
11461 : 0 : ctx->object = out;
11462 : 0 : ctx->objmask = NULL;
11463 : 0 : out->args.vc.data = (uint8_t *)out + size;
11464 : 0 : return len;
11465 : : }
11466 : 0 : switch (ctx->curr) {
11467 : 0 : case HASH_CALC_TABLE:
11468 : : case HASH_CALC_PATTERN_INDEX:
11469 : 0 : return len;
11470 : 0 : case ITEM_PATTERN:
11471 : 0 : out->args.vc.pattern =
11472 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
11473 : : sizeof(double));
11474 : 0 : ctx->object = out->args.vc.pattern;
11475 : 0 : ctx->objmask = NULL;
11476 : 0 : return len;
11477 : 0 : case HASH_CALC_ENCAP:
11478 : 0 : out->args.vc.encap_hash = 1;
11479 : 0 : return len;
11480 : 0 : case ENCAP_HASH_FIELD_SRC_PORT:
11481 : 0 : out->args.vc.field = RTE_FLOW_ENCAP_HASH_FIELD_SRC_PORT;
11482 : 0 : return len;
11483 : 0 : case ENCAP_HASH_FIELD_GRE_FLOW_ID:
11484 : 0 : out->args.vc.field = RTE_FLOW_ENCAP_HASH_FIELD_NVGRE_FLOW_ID;
11485 : 0 : return len;
11486 : : default:
11487 : : return -1;
11488 : : }
11489 : : }
11490 : :
11491 : : static int
11492 : 0 : parse_group(struct context *ctx, const struct token *token,
11493 : : const char *str, unsigned int len,
11494 : : void *buf, unsigned int size)
11495 : : {
11496 : : struct buffer *out = buf;
11497 : :
11498 : : /* Token name must match. */
11499 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
11500 : : return -1;
11501 : : /* Nothing else to do if there is no buffer. */
11502 : 0 : if (!out)
11503 : : return len;
11504 : 0 : if (!out->command) {
11505 : 0 : if (ctx->curr != FLOW_GROUP)
11506 : : return -1;
11507 : 0 : if (sizeof(*out) > size)
11508 : : return -1;
11509 : 0 : out->command = ctx->curr;
11510 : 0 : ctx->objdata = 0;
11511 : 0 : ctx->object = out;
11512 : 0 : ctx->objmask = NULL;
11513 : 0 : out->args.vc.data = (uint8_t *)out + size;
11514 : 0 : return len;
11515 : : }
11516 : 0 : switch (ctx->curr) {
11517 : 0 : case GROUP_INGRESS:
11518 : 0 : out->args.vc.attr.ingress = 1;
11519 : 0 : return len;
11520 : 0 : case GROUP_EGRESS:
11521 : 0 : out->args.vc.attr.egress = 1;
11522 : 0 : return len;
11523 : 0 : case GROUP_TRANSFER:
11524 : 0 : out->args.vc.attr.transfer = 1;
11525 : 0 : return len;
11526 : 0 : case GROUP_SET_MISS_ACTIONS:
11527 : 0 : out->command = ctx->curr;
11528 : 0 : ctx->objdata = 0;
11529 : 0 : ctx->object = out;
11530 : 0 : ctx->objmask = NULL;
11531 : 0 : out->args.vc.actions = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
11532 : : sizeof(double));
11533 : 0 : return len;
11534 : : default:
11535 : : return -1;
11536 : : }
11537 : : }
11538 : :
11539 : : static int
11540 : 0 : parse_flex(struct context *ctx, const struct token *token,
11541 : : const char *str, unsigned int len,
11542 : : void *buf, unsigned int size)
11543 : : {
11544 : : struct buffer *out = buf;
11545 : :
11546 : : /* Token name must match. */
11547 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
11548 : : return -1;
11549 : : /* Nothing else to do if there is no buffer. */
11550 : 0 : if (!out)
11551 : : return len;
11552 : 0 : if (out->command == ZERO) {
11553 : 0 : if (ctx->curr != FLEX)
11554 : : return -1;
11555 : 0 : if (sizeof(*out) > size)
11556 : : return -1;
11557 : 0 : out->command = ctx->curr;
11558 : 0 : ctx->objdata = 0;
11559 : 0 : ctx->object = out;
11560 : 0 : ctx->objmask = NULL;
11561 : : } else {
11562 : 0 : switch (ctx->curr) {
11563 : : default:
11564 : : break;
11565 : 0 : case FLEX_ITEM_CREATE:
11566 : : case FLEX_ITEM_DESTROY:
11567 : 0 : out->command = ctx->curr;
11568 : 0 : break;
11569 : : }
11570 : : }
11571 : :
11572 : : return len;
11573 : : }
11574 : :
11575 : : static int
11576 : 0 : parse_tunnel(struct context *ctx, const struct token *token,
11577 : : const char *str, unsigned int len,
11578 : : void *buf, unsigned int size)
11579 : : {
11580 : : struct buffer *out = buf;
11581 : :
11582 : : /* Token name must match. */
11583 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
11584 : : return -1;
11585 : : /* Nothing else to do if there is no buffer. */
11586 : 0 : if (!out)
11587 : : return len;
11588 : 0 : if (!out->command) {
11589 : 0 : if (ctx->curr != TUNNEL)
11590 : : return -1;
11591 : 0 : if (sizeof(*out) > size)
11592 : : return -1;
11593 : 0 : out->command = ctx->curr;
11594 : 0 : ctx->objdata = 0;
11595 : 0 : ctx->object = out;
11596 : 0 : ctx->objmask = NULL;
11597 : : } else {
11598 : 0 : switch (ctx->curr) {
11599 : : default:
11600 : : break;
11601 : 0 : case TUNNEL_CREATE:
11602 : : case TUNNEL_DESTROY:
11603 : : case TUNNEL_LIST:
11604 : 0 : out->command = ctx->curr;
11605 : 0 : break;
11606 : 0 : case TUNNEL_CREATE_TYPE:
11607 : : case TUNNEL_DESTROY_ID:
11608 : 0 : ctx->object = &out->args.vc.tunnel_ops;
11609 : 0 : break;
11610 : : }
11611 : : }
11612 : :
11613 : : return len;
11614 : : }
11615 : :
11616 : : /**
11617 : : * Parse signed/unsigned integers 8 to 64-bit long.
11618 : : *
11619 : : * Last argument (ctx->args) is retrieved to determine integer type and
11620 : : * storage location.
11621 : : */
11622 : : static int
11623 : 0 : parse_int(struct context *ctx, const struct token *token,
11624 : : const char *str, unsigned int len,
11625 : : void *buf, unsigned int size)
11626 : : {
11627 : : const struct arg *arg = pop_args(ctx);
11628 : : uintmax_t u;
11629 : : char *end;
11630 : :
11631 : : (void)token;
11632 : : /* Argument is expected. */
11633 : 0 : if (!arg)
11634 : 0 : return -1;
11635 : 0 : errno = 0;
11636 : 0 : u = arg->sign ?
11637 : 0 : (uintmax_t)strtoimax(str, &end, 0) :
11638 : 0 : strtoumax(str, &end, 0);
11639 : 0 : if (errno || (size_t)(end - str) != len)
11640 : 0 : goto error;
11641 : 0 : if (arg->bounded &&
11642 : 0 : ((arg->sign && ((intmax_t)u < (intmax_t)arg->min ||
11643 : 0 : (intmax_t)u > (intmax_t)arg->max)) ||
11644 : 0 : (!arg->sign && (u < arg->min || u > arg->max))))
11645 : 0 : goto error;
11646 : 0 : if (!ctx->object)
11647 : 0 : return len;
11648 : 0 : if (arg->mask) {
11649 : 0 : if (!arg_entry_bf_fill(ctx->object, u, arg) ||
11650 : 0 : !arg_entry_bf_fill(ctx->objmask, -1, arg))
11651 : 0 : goto error;
11652 : 0 : return len;
11653 : : }
11654 : 0 : buf = (uint8_t *)ctx->object + arg->offset;
11655 : 0 : size = arg->size;
11656 : 0 : if (u > RTE_LEN2MASK(size * CHAR_BIT, uint64_t))
11657 : : return -1;
11658 : 0 : objmask:
11659 : 0 : switch (size) {
11660 : 0 : case sizeof(uint8_t):
11661 : 0 : *(uint8_t *)buf = u;
11662 : 0 : break;
11663 : 0 : case sizeof(uint16_t):
11664 : 0 : *(uint16_t *)buf = arg->hton ? rte_cpu_to_be_16(u) : u;
11665 : 0 : break;
11666 : 0 : case sizeof(uint8_t [3]):
11667 : : #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
11668 : 0 : if (!arg->hton) {
11669 : 0 : ((uint8_t *)buf)[0] = u;
11670 : 0 : ((uint8_t *)buf)[1] = u >> 8;
11671 : 0 : ((uint8_t *)buf)[2] = u >> 16;
11672 : 0 : break;
11673 : : }
11674 : : #endif
11675 : 0 : ((uint8_t *)buf)[0] = u >> 16;
11676 : 0 : ((uint8_t *)buf)[1] = u >> 8;
11677 : 0 : ((uint8_t *)buf)[2] = u;
11678 : 0 : break;
11679 : 0 : case sizeof(uint32_t):
11680 : 0 : *(uint32_t *)buf = arg->hton ? rte_cpu_to_be_32(u) : u;
11681 : 0 : break;
11682 : 0 : case sizeof(uint64_t):
11683 : 0 : *(uint64_t *)buf = arg->hton ? rte_cpu_to_be_64(u) : u;
11684 : 0 : break;
11685 : 0 : default:
11686 : 0 : goto error;
11687 : : }
11688 : 0 : if (ctx->objmask && buf != (uint8_t *)ctx->objmask + arg->offset) {
11689 : : u = -1;
11690 : : buf = (uint8_t *)ctx->objmask + arg->offset;
11691 : 0 : goto objmask;
11692 : : }
11693 : 0 : return len;
11694 : 0 : error:
11695 : : push_args(ctx, arg);
11696 : : return -1;
11697 : : }
11698 : :
11699 : : /**
11700 : : * Parse a string.
11701 : : *
11702 : : * Three arguments (ctx->args) are retrieved from the stack to store data,
11703 : : * its actual length and address (in that order).
11704 : : */
11705 : : static int
11706 : 0 : parse_string(struct context *ctx, const struct token *token,
11707 : : const char *str, unsigned int len,
11708 : : void *buf, unsigned int size)
11709 : : {
11710 : : const struct arg *arg_data = pop_args(ctx);
11711 : : const struct arg *arg_len = pop_args(ctx);
11712 : : const struct arg *arg_addr = pop_args(ctx);
11713 : : char tmp[16]; /* Ought to be enough. */
11714 : : int ret;
11715 : :
11716 : : /* Arguments are expected. */
11717 : 0 : if (!arg_data)
11718 : : return -1;
11719 : 0 : if (!arg_len) {
11720 : : push_args(ctx, arg_data);
11721 : 0 : return -1;
11722 : : }
11723 : 0 : if (!arg_addr) {
11724 : : push_args(ctx, arg_len);
11725 : : push_args(ctx, arg_data);
11726 : 0 : return -1;
11727 : : }
11728 : 0 : size = arg_data->size;
11729 : : /* Bit-mask fill is not supported. */
11730 : 0 : if (arg_data->mask || size < len)
11731 : 0 : goto error;
11732 : 0 : if (!ctx->object)
11733 : 0 : return len;
11734 : : /* Let parse_int() fill length information first. */
11735 : : ret = snprintf(tmp, sizeof(tmp), "%u", len);
11736 : 0 : if (ret < 0)
11737 : 0 : goto error;
11738 : : push_args(ctx, arg_len);
11739 : 0 : ret = parse_int(ctx, token, tmp, ret, NULL, 0);
11740 : 0 : if (ret < 0) {
11741 : : pop_args(ctx);
11742 : 0 : goto error;
11743 : : }
11744 : 0 : buf = (uint8_t *)ctx->object + arg_data->offset;
11745 : : /* Output buffer is not necessarily NUL-terminated. */
11746 : 0 : memcpy(buf, str, len);
11747 : 0 : memset((uint8_t *)buf + len, 0x00, size - len);
11748 : 0 : if (ctx->objmask)
11749 : 0 : memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
11750 : : /* Save address if requested. */
11751 : 0 : if (arg_addr->size) {
11752 : 0 : memcpy((uint8_t *)ctx->object + arg_addr->offset,
11753 : 0 : (void *[]){
11754 : 0 : (uint8_t *)ctx->object + arg_data->offset
11755 : : },
11756 : : arg_addr->size);
11757 : 0 : if (ctx->objmask)
11758 : 0 : memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
11759 : 0 : (void *[]){
11760 : 0 : (uint8_t *)ctx->objmask + arg_data->offset
11761 : : },
11762 : 0 : arg_addr->size);
11763 : : }
11764 : 0 : return len;
11765 : 0 : error:
11766 : : push_args(ctx, arg_addr);
11767 : : push_args(ctx, arg_len);
11768 : : push_args(ctx, arg_data);
11769 : : return -1;
11770 : : }
11771 : :
11772 : : static int
11773 : 0 : parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
11774 : : {
11775 : : const uint8_t *head = dst;
11776 : : uint32_t left;
11777 : :
11778 : 0 : if (*size == 0)
11779 : : return -1;
11780 : :
11781 : : left = *size;
11782 : :
11783 : : /* Convert chars to bytes */
11784 : 0 : while (left) {
11785 : 0 : char tmp[3], *end = tmp;
11786 : 0 : uint32_t read_lim = left & 1 ? 1 : 2;
11787 : :
11788 : 0 : snprintf(tmp, read_lim + 1, "%s", src);
11789 : 0 : *dst = strtoul(tmp, &end, 16);
11790 : 0 : if (*end) {
11791 : 0 : *dst = 0;
11792 : 0 : *size = (uint32_t)(dst - head);
11793 : 0 : return -1;
11794 : : }
11795 : 0 : left -= read_lim;
11796 : 0 : src += read_lim;
11797 : 0 : dst++;
11798 : : }
11799 : 0 : *dst = 0;
11800 : 0 : *size = (uint32_t)(dst - head);
11801 : 0 : return 0;
11802 : : }
11803 : :
11804 : : static int
11805 : 0 : parse_hex(struct context *ctx, const struct token *token,
11806 : : const char *str, unsigned int len,
11807 : : void *buf, unsigned int size)
11808 : : {
11809 : : const struct arg *arg_data = pop_args(ctx);
11810 : : const struct arg *arg_len = pop_args(ctx);
11811 : : const struct arg *arg_addr = pop_args(ctx);
11812 : : char tmp[16]; /* Ought to be enough. */
11813 : : int ret;
11814 : 0 : unsigned int hexlen = len;
11815 : : uint8_t hex_tmp[256];
11816 : :
11817 : : /* Arguments are expected. */
11818 : 0 : if (!arg_data)
11819 : : return -1;
11820 : 0 : if (!arg_len) {
11821 : : push_args(ctx, arg_data);
11822 : 0 : return -1;
11823 : : }
11824 : 0 : if (!arg_addr) {
11825 : : push_args(ctx, arg_len);
11826 : : push_args(ctx, arg_data);
11827 : 0 : return -1;
11828 : : }
11829 : 0 : size = arg_data->size;
11830 : : /* Bit-mask fill is not supported. */
11831 : 0 : if (arg_data->mask)
11832 : 0 : goto error;
11833 : 0 : if (!ctx->object)
11834 : 0 : return len;
11835 : :
11836 : : /* translate bytes string to array. */
11837 : 0 : if (str[0] == '0' && ((str[1] == 'x') ||
11838 : : (str[1] == 'X'))) {
11839 : 0 : str += 2;
11840 : 0 : hexlen -= 2;
11841 : : }
11842 : 0 : if (hexlen > RTE_DIM(hex_tmp))
11843 : 0 : goto error;
11844 : 0 : ret = parse_hex_string(str, hex_tmp, &hexlen);
11845 : 0 : if (ret < 0)
11846 : 0 : goto error;
11847 : : /* Check the converted binary fits into data buffer. */
11848 : 0 : if (hexlen > size)
11849 : 0 : goto error;
11850 : : /* Let parse_int() fill length information first. */
11851 : : ret = snprintf(tmp, sizeof(tmp), "%u", hexlen);
11852 : 0 : if (ret < 0)
11853 : 0 : goto error;
11854 : : /* Save length if requested. */
11855 : 0 : if (arg_len->size) {
11856 : : push_args(ctx, arg_len);
11857 : 0 : ret = parse_int(ctx, token, tmp, ret, NULL, 0);
11858 : 0 : if (ret < 0) {
11859 : : pop_args(ctx);
11860 : 0 : goto error;
11861 : : }
11862 : : }
11863 : 0 : buf = (uint8_t *)ctx->object + arg_data->offset;
11864 : : /* Output buffer is not necessarily NUL-terminated. */
11865 : 0 : memcpy(buf, hex_tmp, hexlen);
11866 : 0 : memset((uint8_t *)buf + hexlen, 0x00, size - hexlen);
11867 : 0 : if (ctx->objmask)
11868 : 0 : memset((uint8_t *)ctx->objmask + arg_data->offset,
11869 : : 0xff, hexlen);
11870 : : /* Save address if requested. */
11871 : 0 : if (arg_addr->size) {
11872 : 0 : memcpy((uint8_t *)ctx->object + arg_addr->offset,
11873 : 0 : (void *[]){
11874 : 0 : (uint8_t *)ctx->object + arg_data->offset
11875 : : },
11876 : : arg_addr->size);
11877 : 0 : if (ctx->objmask)
11878 : 0 : memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
11879 : 0 : (void *[]){
11880 : 0 : (uint8_t *)ctx->objmask + arg_data->offset
11881 : : },
11882 : 0 : arg_addr->size);
11883 : : }
11884 : 0 : return len;
11885 : 0 : error:
11886 : : push_args(ctx, arg_addr);
11887 : : push_args(ctx, arg_len);
11888 : : push_args(ctx, arg_data);
11889 : : return -1;
11890 : :
11891 : : }
11892 : :
11893 : : /**
11894 : : * Parse a zero-ended string.
11895 : : */
11896 : : static int
11897 : 0 : parse_string0(struct context *ctx, const struct token *token __rte_unused,
11898 : : const char *str, unsigned int len,
11899 : : void *buf, unsigned int size)
11900 : : {
11901 : : const struct arg *arg_data = pop_args(ctx);
11902 : :
11903 : : /* Arguments are expected. */
11904 : 0 : if (!arg_data)
11905 : 0 : return -1;
11906 : 0 : size = arg_data->size;
11907 : : /* Bit-mask fill is not supported. */
11908 : 0 : if (arg_data->mask || size < len + 1)
11909 : 0 : goto error;
11910 : 0 : if (!ctx->object)
11911 : 0 : return len;
11912 : 0 : buf = (uint8_t *)ctx->object + arg_data->offset;
11913 : 0 : strncpy(buf, str, len);
11914 : 0 : if (ctx->objmask)
11915 : 0 : memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
11916 : 0 : return len;
11917 : : error:
11918 : : push_args(ctx, arg_data);
11919 : : return -1;
11920 : : }
11921 : :
11922 : : /**
11923 : : * Parse a MAC address.
11924 : : *
11925 : : * Last argument (ctx->args) is retrieved to determine storage size and
11926 : : * location.
11927 : : */
11928 : : static int
11929 : 0 : parse_mac_addr(struct context *ctx, const struct token *token,
11930 : : const char *str, unsigned int len,
11931 : : void *buf, unsigned int size)
11932 : : {
11933 : : const struct arg *arg = pop_args(ctx);
11934 : : struct rte_ether_addr tmp;
11935 : : int ret;
11936 : :
11937 : : (void)token;
11938 : : /* Argument is expected. */
11939 : 0 : if (!arg)
11940 : 0 : return -1;
11941 : 0 : size = arg->size;
11942 : : /* Bit-mask fill is not supported. */
11943 : 0 : if (arg->mask || size != sizeof(tmp))
11944 : 0 : goto error;
11945 : : /* Only network endian is supported. */
11946 : 0 : if (!arg->hton)
11947 : 0 : goto error;
11948 : 0 : ret = cmdline_parse_etheraddr(NULL, str, &tmp, size);
11949 : 0 : if (ret < 0 || (unsigned int)ret != len)
11950 : 0 : goto error;
11951 : 0 : if (!ctx->object)
11952 : 0 : return len;
11953 : 0 : buf = (uint8_t *)ctx->object + arg->offset;
11954 : : memcpy(buf, &tmp, size);
11955 : 0 : if (ctx->objmask)
11956 : 0 : memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
11957 : 0 : return len;
11958 : 0 : error:
11959 : : push_args(ctx, arg);
11960 : : return -1;
11961 : : }
11962 : :
11963 : : /**
11964 : : * Parse an IPv4 address.
11965 : : *
11966 : : * Last argument (ctx->args) is retrieved to determine storage size and
11967 : : * location.
11968 : : */
11969 : : static int
11970 : 0 : parse_ipv4_addr(struct context *ctx, const struct token *token,
11971 : : const char *str, unsigned int len,
11972 : : void *buf, unsigned int size)
11973 : : {
11974 : : const struct arg *arg = pop_args(ctx);
11975 : : char str2[INET_ADDRSTRLEN];
11976 : : struct in_addr tmp;
11977 : : int ret;
11978 : :
11979 : : /* Length is longer than the max length an IPv4 address can have. */
11980 : 0 : if (len >= INET_ADDRSTRLEN)
11981 : : return -1;
11982 : : /* Argument is expected. */
11983 : 0 : if (!arg)
11984 : : return -1;
11985 : 0 : size = arg->size;
11986 : : /* Bit-mask fill is not supported. */
11987 : 0 : if (arg->mask || size != sizeof(tmp))
11988 : 0 : goto error;
11989 : : /* Only network endian is supported. */
11990 : 0 : if (!arg->hton)
11991 : 0 : goto error;
11992 : 0 : memcpy(str2, str, len);
11993 : 0 : str2[len] = '\0';
11994 : 0 : ret = inet_pton(AF_INET, str2, &tmp);
11995 : 0 : if (ret != 1) {
11996 : : /* Attempt integer parsing. */
11997 : : push_args(ctx, arg);
11998 : 0 : return parse_int(ctx, token, str, len, buf, size);
11999 : : }
12000 : 0 : if (!ctx->object)
12001 : 0 : return len;
12002 : 0 : buf = (uint8_t *)ctx->object + arg->offset;
12003 : : memcpy(buf, &tmp, size);
12004 : 0 : if (ctx->objmask)
12005 : 0 : memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
12006 : 0 : return len;
12007 : 0 : error:
12008 : : push_args(ctx, arg);
12009 : : return -1;
12010 : : }
12011 : :
12012 : : /**
12013 : : * Parse an IPv6 address.
12014 : : *
12015 : : * Last argument (ctx->args) is retrieved to determine storage size and
12016 : : * location.
12017 : : */
12018 : : static int
12019 : 0 : parse_ipv6_addr(struct context *ctx, const struct token *token,
12020 : : const char *str, unsigned int len,
12021 : : void *buf, unsigned int size)
12022 : : {
12023 : : const struct arg *arg = pop_args(ctx);
12024 : : char str2[INET6_ADDRSTRLEN];
12025 : : struct rte_ipv6_addr tmp;
12026 : : int ret;
12027 : :
12028 : : (void)token;
12029 : : /* Length is longer than the max length an IPv6 address can have. */
12030 : 0 : if (len >= INET6_ADDRSTRLEN)
12031 : : return -1;
12032 : : /* Argument is expected. */
12033 : 0 : if (!arg)
12034 : : return -1;
12035 : 0 : size = arg->size;
12036 : : /* Bit-mask fill is not supported. */
12037 : 0 : if (arg->mask || size != sizeof(tmp))
12038 : 0 : goto error;
12039 : : /* Only network endian is supported. */
12040 : 0 : if (!arg->hton)
12041 : 0 : goto error;
12042 : 0 : memcpy(str2, str, len);
12043 : 0 : str2[len] = '\0';
12044 : 0 : ret = inet_pton(AF_INET6, str2, &tmp);
12045 : 0 : if (ret != 1)
12046 : 0 : goto error;
12047 : 0 : if (!ctx->object)
12048 : 0 : return len;
12049 : 0 : buf = (uint8_t *)ctx->object + arg->offset;
12050 : : memcpy(buf, &tmp, size);
12051 : 0 : if (ctx->objmask)
12052 : 0 : memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
12053 : 0 : return len;
12054 : 0 : error:
12055 : : push_args(ctx, arg);
12056 : : return -1;
12057 : : }
12058 : :
12059 : : /** Boolean values (even indices stand for false). */
12060 : : static const char *const boolean_name[] = {
12061 : : "0", "1",
12062 : : "false", "true",
12063 : : "no", "yes",
12064 : : "N", "Y",
12065 : : "off", "on",
12066 : : NULL,
12067 : : };
12068 : :
12069 : : /**
12070 : : * Parse a boolean value.
12071 : : *
12072 : : * Last argument (ctx->args) is retrieved to determine storage size and
12073 : : * location.
12074 : : */
12075 : : static int
12076 : 0 : parse_boolean(struct context *ctx, const struct token *token,
12077 : : const char *str, unsigned int len,
12078 : : void *buf, unsigned int size)
12079 : : {
12080 : : const struct arg *arg = pop_args(ctx);
12081 : : unsigned int i;
12082 : : int ret;
12083 : :
12084 : : /* Argument is expected. */
12085 : 0 : if (!arg)
12086 : 0 : return -1;
12087 : 0 : for (i = 0; boolean_name[i]; ++i)
12088 : 0 : if (!strcmp_partial(boolean_name[i], str, len))
12089 : : break;
12090 : : /* Process token as integer. */
12091 : 0 : if (boolean_name[i])
12092 : 0 : str = i & 1 ? "1" : "0";
12093 : : push_args(ctx, arg);
12094 : 0 : ret = parse_int(ctx, token, str, strlen(str), buf, size);
12095 : 0 : return ret > 0 ? (int)len : ret;
12096 : : }
12097 : :
12098 : : /** Parse port and update context. */
12099 : : static int
12100 : 0 : parse_port(struct context *ctx, const struct token *token,
12101 : : const char *str, unsigned int len,
12102 : : void *buf, unsigned int size)
12103 : : {
12104 : 0 : struct buffer *out = &(struct buffer){ .port = 0 };
12105 : : int ret;
12106 : :
12107 : 0 : if (buf)
12108 : : out = buf;
12109 : : else {
12110 : 0 : ctx->objdata = 0;
12111 : 0 : ctx->object = out;
12112 : 0 : ctx->objmask = NULL;
12113 : : size = sizeof(*out);
12114 : : }
12115 : 0 : ret = parse_int(ctx, token, str, len, out, size);
12116 : 0 : if (ret >= 0)
12117 : 0 : ctx->port = out->port;
12118 : 0 : if (!buf)
12119 : 0 : ctx->object = NULL;
12120 : 0 : return ret;
12121 : : }
12122 : :
12123 : : /** Parse tokens for shared indirect actions. */
12124 : : static int
12125 : 0 : parse_ia_port(struct context *ctx, const struct token *token,
12126 : : const char *str, unsigned int len,
12127 : : void *buf, unsigned int size)
12128 : : {
12129 : 0 : struct rte_flow_action *action = ctx->object;
12130 : : uint32_t id;
12131 : : int ret;
12132 : :
12133 : : (void)buf;
12134 : : (void)size;
12135 : 0 : ctx->objdata = 0;
12136 : 0 : ctx->object = &id;
12137 : 0 : ctx->objmask = NULL;
12138 : 0 : ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
12139 : 0 : ctx->object = action;
12140 : 0 : if (ret != (int)len)
12141 : : return ret;
12142 : : /* set indirect action */
12143 : 0 : if (action)
12144 : 0 : action->conf = (void *)(uintptr_t)id;
12145 : : return ret;
12146 : : }
12147 : :
12148 : : static int
12149 : 0 : parse_ia_id2ptr(struct context *ctx, const struct token *token,
12150 : : const char *str, unsigned int len,
12151 : : void *buf, unsigned int size)
12152 : : {
12153 : 0 : struct rte_flow_action *action = ctx->object;
12154 : : uint32_t id;
12155 : : int ret;
12156 : :
12157 : : (void)buf;
12158 : : (void)size;
12159 : 0 : ctx->objdata = 0;
12160 : 0 : ctx->object = &id;
12161 : 0 : ctx->objmask = NULL;
12162 : 0 : ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
12163 : 0 : ctx->object = action;
12164 : 0 : if (ret != (int)len)
12165 : : return ret;
12166 : : /* set indirect action */
12167 : 0 : if (action) {
12168 : 0 : portid_t port_id = ctx->port;
12169 : 0 : if (ctx->prev == INDIRECT_ACTION_PORT)
12170 : 0 : port_id = (portid_t)(uintptr_t)action->conf;
12171 : 0 : action->conf = port_action_handle_get_by_id(port_id, id);
12172 : 0 : ret = (action->conf) ? ret : -1;
12173 : : }
12174 : : return ret;
12175 : : }
12176 : :
12177 : : static int
12178 : 0 : parse_indlst_id2ptr(struct context *ctx, const struct token *token,
12179 : : const char *str, unsigned int len,
12180 : : __rte_unused void *buf, __rte_unused unsigned int size)
12181 : : {
12182 : 0 : struct rte_flow_action *action = ctx->object;
12183 : : struct rte_flow_action_indirect_list *action_conf;
12184 : : const struct indlst_conf *indlst_conf;
12185 : : uint32_t id;
12186 : : int ret;
12187 : :
12188 : 0 : ctx->objdata = 0;
12189 : 0 : ctx->object = &id;
12190 : 0 : ctx->objmask = NULL;
12191 : 0 : ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
12192 : 0 : ctx->object = action;
12193 : 0 : if (ret != (int)len)
12194 : : return ret;
12195 : :
12196 : : /* set handle and conf */
12197 : 0 : if (action) {
12198 : 0 : action_conf = (void *)(uintptr_t)action->conf;
12199 : 0 : action_conf->conf = NULL;
12200 : 0 : switch (ctx->curr) {
12201 : 0 : case INDIRECT_LIST_ACTION_ID2PTR_HANDLE:
12202 : 0 : action_conf->handle = (typeof(action_conf->handle))
12203 : 0 : port_action_handle_get_by_id(ctx->port, id);
12204 : 0 : if (!action_conf->handle) {
12205 : 0 : printf("no indirect list handle for id %u\n", id);
12206 : 0 : return -1;
12207 : : }
12208 : : break;
12209 : 0 : case INDIRECT_LIST_ACTION_ID2PTR_CONF:
12210 : 0 : indlst_conf = indirect_action_list_conf_get(id);
12211 : 0 : if (!indlst_conf)
12212 : : return -1;
12213 : 0 : action_conf->conf = (const void **)indlst_conf->conf;
12214 : 0 : break;
12215 : : default:
12216 : : break;
12217 : : }
12218 : : }
12219 : : return ret;
12220 : : }
12221 : :
12222 : : static int
12223 : 0 : parse_meter_profile_id2ptr(struct context *ctx, const struct token *token,
12224 : : const char *str, unsigned int len,
12225 : : void *buf, unsigned int size)
12226 : : {
12227 : 0 : struct rte_flow_action *action = ctx->object;
12228 : : struct rte_flow_action_meter_mark *meter;
12229 : : struct rte_flow_meter_profile *profile = NULL;
12230 : 0 : uint32_t id = 0;
12231 : : int ret;
12232 : :
12233 : : (void)buf;
12234 : : (void)size;
12235 : 0 : ctx->objdata = 0;
12236 : 0 : ctx->object = &id;
12237 : 0 : ctx->objmask = NULL;
12238 : 0 : ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
12239 : 0 : ctx->object = action;
12240 : 0 : if (ret != (int)len)
12241 : : return ret;
12242 : : /* set meter profile */
12243 : 0 : if (action) {
12244 : 0 : meter = (struct rte_flow_action_meter_mark *)
12245 : : (uintptr_t)(action->conf);
12246 : 0 : profile = port_meter_profile_get_by_id(ctx->port, id);
12247 : 0 : meter->profile = profile;
12248 : 0 : ret = (profile) ? ret : -1;
12249 : : }
12250 : : return ret;
12251 : : }
12252 : :
12253 : : static int
12254 : 0 : parse_meter_policy_id2ptr(struct context *ctx, const struct token *token,
12255 : : const char *str, unsigned int len,
12256 : : void *buf, unsigned int size)
12257 : : {
12258 : 0 : struct rte_flow_action *action = ctx->object;
12259 : : struct rte_flow_action_meter_mark *meter;
12260 : : struct rte_flow_meter_policy *policy = NULL;
12261 : 0 : uint32_t id = 0;
12262 : : int ret;
12263 : :
12264 : : (void)buf;
12265 : : (void)size;
12266 : 0 : ctx->objdata = 0;
12267 : 0 : ctx->object = &id;
12268 : 0 : ctx->objmask = NULL;
12269 : 0 : ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
12270 : 0 : ctx->object = action;
12271 : 0 : if (ret != (int)len)
12272 : : return ret;
12273 : : /* set meter policy */
12274 : 0 : if (action) {
12275 : 0 : meter = (struct rte_flow_action_meter_mark *)
12276 : : (uintptr_t)(action->conf);
12277 : 0 : policy = port_meter_policy_get_by_id(ctx->port, id);
12278 : 0 : meter->policy = policy;
12279 : 0 : ret = (policy) ? ret : -1;
12280 : : }
12281 : : return ret;
12282 : : }
12283 : :
12284 : : /** Parse set command, initialize output buffer for subsequent tokens. */
12285 : : static int
12286 : 0 : parse_set_raw_encap_decap(struct context *ctx, const struct token *token,
12287 : : const char *str, unsigned int len,
12288 : : void *buf, unsigned int size)
12289 : : {
12290 : : struct buffer *out = buf;
12291 : :
12292 : : /* Token name must match. */
12293 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
12294 : : return -1;
12295 : : /* Nothing else to do if there is no buffer. */
12296 : 0 : if (!out)
12297 : : return len;
12298 : : /* Make sure buffer is large enough. */
12299 : 0 : if (size < sizeof(*out))
12300 : : return -1;
12301 : 0 : ctx->objdata = 0;
12302 : 0 : ctx->objmask = NULL;
12303 : 0 : ctx->object = out;
12304 : 0 : if (!out->command)
12305 : : return -1;
12306 : 0 : out->command = ctx->curr;
12307 : : /* For encap/decap we need is pattern */
12308 : 0 : out->args.vc.pattern = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
12309 : : sizeof(double));
12310 : 0 : return len;
12311 : : }
12312 : :
12313 : : /** Parse set command, initialize output buffer for subsequent tokens. */
12314 : : static int
12315 : 0 : parse_set_sample_action(struct context *ctx, const struct token *token,
12316 : : const char *str, unsigned int len,
12317 : : void *buf, unsigned int size)
12318 : : {
12319 : : struct buffer *out = buf;
12320 : :
12321 : : /* Token name must match. */
12322 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
12323 : : return -1;
12324 : : /* Nothing else to do if there is no buffer. */
12325 : 0 : if (!out)
12326 : : return len;
12327 : : /* Make sure buffer is large enough. */
12328 : 0 : if (size < sizeof(*out))
12329 : : return -1;
12330 : 0 : ctx->objdata = 0;
12331 : 0 : ctx->objmask = NULL;
12332 : 0 : ctx->object = out;
12333 : 0 : if (!out->command)
12334 : : return -1;
12335 : 0 : out->command = ctx->curr;
12336 : : /* For sampler we need is actions */
12337 : 0 : out->args.vc.actions = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
12338 : : sizeof(double));
12339 : 0 : return len;
12340 : : }
12341 : :
12342 : : /** Parse set command, initialize output buffer for subsequent tokens. */
12343 : : static int
12344 : 0 : parse_set_ipv6_ext_action(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 : 0 : ctx->objdata = 0;
12360 : 0 : ctx->objmask = NULL;
12361 : 0 : ctx->object = out;
12362 : 0 : if (!out->command)
12363 : : return -1;
12364 : 0 : out->command = ctx->curr;
12365 : : /* For ipv6_ext_push/remove we need is pattern */
12366 : 0 : out->args.vc.pattern = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
12367 : : sizeof(double));
12368 : 0 : return len;
12369 : : }
12370 : :
12371 : : /**
12372 : : * Parse set raw_encap/raw_decap command,
12373 : : * initialize output buffer for subsequent tokens.
12374 : : */
12375 : : static int
12376 : 0 : parse_set_init(struct context *ctx, const struct token *token,
12377 : : const char *str, unsigned int len,
12378 : : void *buf, unsigned int size)
12379 : : {
12380 : : struct buffer *out = buf;
12381 : :
12382 : : /* Token name must match. */
12383 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
12384 : : return -1;
12385 : : /* Nothing else to do if there is no buffer. */
12386 : 0 : if (!out)
12387 : : return len;
12388 : : /* Make sure buffer is large enough. */
12389 : 0 : if (size < sizeof(*out))
12390 : : return -1;
12391 : : /* Initialize buffer. */
12392 : : memset(out, 0x00, sizeof(*out));
12393 : 0 : memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
12394 : 0 : ctx->objdata = 0;
12395 : 0 : ctx->object = out;
12396 : 0 : ctx->objmask = NULL;
12397 : : if (!out->command) {
12398 : 0 : if (ctx->curr != SET)
12399 : : return -1;
12400 : : if (sizeof(*out) > size)
12401 : : return -1;
12402 : 0 : out->command = ctx->curr;
12403 : 0 : out->args.vc.data = (uint8_t *)out + size;
12404 : 0 : ctx->object = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
12405 : : sizeof(double));
12406 : : }
12407 : 0 : return len;
12408 : : }
12409 : :
12410 : : /*
12411 : : * Replace testpmd handles in a flex flow item with real values.
12412 : : */
12413 : : static int
12414 : 0 : parse_flex_handle(struct context *ctx, const struct token *token,
12415 : : const char *str, unsigned int len,
12416 : : void *buf, unsigned int size)
12417 : : {
12418 : : struct rte_flow_item_flex *spec, *mask;
12419 : : const struct rte_flow_item_flex *src_spec, *src_mask;
12420 : : const struct arg *arg = pop_args(ctx);
12421 : : uint32_t offset;
12422 : : uint16_t handle;
12423 : : int ret;
12424 : :
12425 : 0 : if (!arg) {
12426 : : printf("Bad environment\n");
12427 : 0 : return -1;
12428 : : }
12429 : 0 : offset = arg->offset;
12430 : : push_args(ctx, arg);
12431 : 0 : ret = parse_int(ctx, token, str, len, buf, size);
12432 : 0 : if (ret <= 0 || !ctx->object)
12433 : : return ret;
12434 : 0 : if (ctx->port >= RTE_MAX_ETHPORTS) {
12435 : : printf("Bad port\n");
12436 : 0 : return -1;
12437 : : }
12438 : 0 : if (offset == offsetof(struct rte_flow_item_flex, handle)) {
12439 : : const struct flex_item *fp;
12440 : : spec = ctx->object;
12441 : 0 : handle = (uint16_t)(uintptr_t)spec->handle;
12442 : 0 : if (handle >= FLEX_MAX_PARSERS_NUM) {
12443 : : printf("Bad flex item handle\n");
12444 : 0 : return -1;
12445 : : }
12446 : 0 : fp = flex_items[ctx->port][handle];
12447 : 0 : if (!fp) {
12448 : : printf("Bad flex item handle\n");
12449 : 0 : return -1;
12450 : : }
12451 : 0 : spec->handle = fp->flex_handle;
12452 : : mask = spec + 2; /* spec, last, mask */
12453 : 0 : mask->handle = fp->flex_handle;
12454 : 0 : } else if (offset == offsetof(struct rte_flow_item_flex, pattern)) {
12455 : 0 : handle = (uint16_t)(uintptr_t)
12456 : 0 : ((struct rte_flow_item_flex *)ctx->object)->pattern;
12457 : 0 : if (handle >= FLEX_MAX_PATTERNS_NUM) {
12458 : : printf("Bad pattern handle\n");
12459 : 0 : return -1;
12460 : : }
12461 : 0 : src_spec = &flex_patterns[handle].spec;
12462 : : src_mask = &flex_patterns[handle].mask;
12463 : : spec = ctx->object;
12464 : : mask = spec + 2; /* spec, last, mask */
12465 : : /* fill flow rule spec and mask parameters */
12466 : 0 : spec->length = src_spec->length;
12467 : 0 : spec->pattern = src_spec->pattern;
12468 : 0 : mask->length = src_mask->length;
12469 : 0 : mask->pattern = src_mask->pattern;
12470 : : } else {
12471 : : printf("Bad arguments - unknown flex item offset\n");
12472 : 0 : return -1;
12473 : : }
12474 : : return ret;
12475 : : }
12476 : :
12477 : : /** Parse Meter color name */
12478 : : static int
12479 : 0 : parse_meter_color(struct context *ctx, const struct token *token,
12480 : : const char *str, unsigned int len, void *buf,
12481 : : unsigned int size)
12482 : : {
12483 : : unsigned int i;
12484 : : struct buffer *out = buf;
12485 : :
12486 : : (void)token;
12487 : : (void)buf;
12488 : : (void)size;
12489 : 0 : for (i = 0; meter_colors[i]; ++i)
12490 : 0 : if (!strcmp_partial(meter_colors[i], str, len))
12491 : : break;
12492 : 0 : if (!meter_colors[i])
12493 : : return -1;
12494 : 0 : if (!ctx->object)
12495 : 0 : return len;
12496 : 0 : if (ctx->prev == ACTION_METER_MARK_CONF_COLOR) {
12497 : 0 : struct rte_flow_action *action =
12498 : 0 : out->args.vc.actions + out->args.vc.actions_n - 1;
12499 : : const struct arg *arg = pop_args(ctx);
12500 : :
12501 : 0 : if (!arg)
12502 : 0 : return -1;
12503 : 0 : *(int *)RTE_PTR_ADD(action->conf, arg->offset) = i;
12504 : : } else {
12505 : : ((struct rte_flow_item_meter_color *)
12506 : 0 : ctx->object)->color = (enum rte_color)i;
12507 : : }
12508 : 0 : return len;
12509 : : }
12510 : :
12511 : : /** Parse Insertion Table Type name */
12512 : : static int
12513 : 0 : parse_insertion_table_type(struct context *ctx, const struct token *token,
12514 : : const char *str, unsigned int len, void *buf,
12515 : : unsigned int size)
12516 : : {
12517 : : const struct arg *arg = pop_args(ctx);
12518 : : unsigned int i;
12519 : : char tmp[2];
12520 : : int ret;
12521 : :
12522 : : (void)size;
12523 : : /* Argument is expected. */
12524 : 0 : if (!arg)
12525 : 0 : return -1;
12526 : 0 : for (i = 0; table_insertion_types[i]; ++i)
12527 : 0 : if (!strcmp_partial(table_insertion_types[i], str, len))
12528 : : break;
12529 : 0 : if (!table_insertion_types[i])
12530 : : return -1;
12531 : : push_args(ctx, arg);
12532 : : snprintf(tmp, sizeof(tmp), "%u", i);
12533 : 0 : ret = parse_int(ctx, token, tmp, strlen(tmp), buf, sizeof(i));
12534 : 0 : return ret > 0 ? (int)len : ret;
12535 : : }
12536 : :
12537 : : /** Parse Hash Calculation Table Type name */
12538 : : static int
12539 : 0 : parse_hash_table_type(struct context *ctx, const struct token *token,
12540 : : const char *str, unsigned int len, void *buf,
12541 : : unsigned int size)
12542 : : {
12543 : : const struct arg *arg = pop_args(ctx);
12544 : : unsigned int i;
12545 : : char tmp[2];
12546 : : int ret;
12547 : :
12548 : : (void)size;
12549 : : /* Argument is expected. */
12550 : 0 : if (!arg)
12551 : 0 : return -1;
12552 : 0 : for (i = 0; table_hash_funcs[i]; ++i)
12553 : 0 : if (!strcmp_partial(table_hash_funcs[i], str, len))
12554 : : break;
12555 : 0 : if (!table_hash_funcs[i])
12556 : : return -1;
12557 : : push_args(ctx, arg);
12558 : : snprintf(tmp, sizeof(tmp), "%u", i);
12559 : 0 : ret = parse_int(ctx, token, tmp, strlen(tmp), buf, sizeof(i));
12560 : 0 : return ret > 0 ? (int)len : ret;
12561 : : }
12562 : :
12563 : : static int
12564 : 0 : parse_name_to_index(struct context *ctx, const struct token *token,
12565 : : const char *str, unsigned int len, void *buf,
12566 : : unsigned int size,
12567 : : const char *const names[], size_t names_size, uint32_t *dst)
12568 : : {
12569 : : int ret;
12570 : : uint32_t i;
12571 : :
12572 : : RTE_SET_USED(token);
12573 : : RTE_SET_USED(buf);
12574 : : RTE_SET_USED(size);
12575 : 0 : if (!ctx->object)
12576 : 0 : return len;
12577 : 0 : for (i = 0; i < names_size; i++) {
12578 : 0 : if (!names[i])
12579 : 0 : continue;
12580 : 0 : ret = strcmp_partial(names[i], str,
12581 : 0 : RTE_MIN(len, strlen(names[i])));
12582 : 0 : if (!ret) {
12583 : 0 : *dst = i;
12584 : 0 : return len;
12585 : : }
12586 : : }
12587 : : return -1;
12588 : : }
12589 : :
12590 : : static const char *const quota_mode_names[] = {
12591 : : NULL,
12592 : : [RTE_FLOW_QUOTA_MODE_PACKET] = "packet",
12593 : : [RTE_FLOW_QUOTA_MODE_L2] = "l2",
12594 : : [RTE_FLOW_QUOTA_MODE_L3] = "l3"
12595 : : };
12596 : :
12597 : : static const char *const quota_state_names[] = {
12598 : : [RTE_FLOW_QUOTA_STATE_PASS] = "pass",
12599 : : [RTE_FLOW_QUOTA_STATE_BLOCK] = "block"
12600 : : };
12601 : :
12602 : : static const char *const quota_update_names[] = {
12603 : : [RTE_FLOW_UPDATE_QUOTA_SET] = "set",
12604 : : [RTE_FLOW_UPDATE_QUOTA_ADD] = "add"
12605 : : };
12606 : :
12607 : : static const char *const query_update_mode_names[] = {
12608 : : [RTE_FLOW_QU_QUERY_FIRST] = "query_first",
12609 : : [RTE_FLOW_QU_UPDATE_FIRST] = "update_first"
12610 : : };
12611 : :
12612 : : static int
12613 : 0 : parse_quota_state_name(struct context *ctx, const struct token *token,
12614 : : const char *str, unsigned int len, void *buf,
12615 : : unsigned int size)
12616 : : {
12617 : 0 : struct rte_flow_item_quota *quota = ctx->object;
12618 : :
12619 : 0 : return parse_name_to_index(ctx, token, str, len, buf, size,
12620 : : quota_state_names,
12621 : : RTE_DIM(quota_state_names),
12622 : 0 : (uint32_t *)"a->state);
12623 : : }
12624 : :
12625 : : static int
12626 : 0 : parse_quota_mode_name(struct context *ctx, const struct token *token,
12627 : : const char *str, unsigned int len, void *buf,
12628 : : unsigned int size)
12629 : : {
12630 : 0 : struct rte_flow_action_quota *quota = ctx->object;
12631 : :
12632 : 0 : return parse_name_to_index(ctx, token, str, len, buf, size,
12633 : : quota_mode_names,
12634 : : RTE_DIM(quota_mode_names),
12635 : 0 : (uint32_t *)"a->mode);
12636 : : }
12637 : :
12638 : : static int
12639 : 0 : parse_quota_update_name(struct context *ctx, const struct token *token,
12640 : : const char *str, unsigned int len, void *buf,
12641 : : unsigned int size)
12642 : : {
12643 : 0 : struct rte_flow_update_quota *update = ctx->object;
12644 : :
12645 : 0 : return parse_name_to_index(ctx, token, str, len, buf, size,
12646 : : quota_update_names,
12647 : : RTE_DIM(quota_update_names),
12648 : 0 : (uint32_t *)&update->op);
12649 : : }
12650 : :
12651 : : static int
12652 : 0 : parse_qu_mode_name(struct context *ctx, const struct token *token,
12653 : : const char *str, unsigned int len, void *buf,
12654 : : unsigned int size)
12655 : : {
12656 : 0 : struct buffer *out = ctx->object;
12657 : :
12658 : 0 : return parse_name_to_index(ctx, token, str, len, buf, size,
12659 : : query_update_mode_names,
12660 : : RTE_DIM(query_update_mode_names),
12661 : 0 : (uint32_t *)&out->args.ia.qu_mode);
12662 : : }
12663 : :
12664 : : /** No completion. */
12665 : : static int
12666 : 0 : comp_none(struct context *ctx, const struct token *token,
12667 : : unsigned int ent, char *buf, unsigned int size)
12668 : : {
12669 : : (void)ctx;
12670 : : (void)token;
12671 : : (void)ent;
12672 : : (void)buf;
12673 : : (void)size;
12674 : 0 : return 0;
12675 : : }
12676 : :
12677 : : /** Complete boolean values. */
12678 : : static int
12679 : 0 : comp_boolean(struct context *ctx, const struct token *token,
12680 : : unsigned int ent, char *buf, unsigned int size)
12681 : : {
12682 : : unsigned int i;
12683 : :
12684 : : (void)ctx;
12685 : : (void)token;
12686 : 0 : for (i = 0; boolean_name[i]; ++i)
12687 : 0 : if (buf && i == ent)
12688 : 0 : return strlcpy(buf, boolean_name[i], size);
12689 : 0 : if (buf)
12690 : : return -1;
12691 : 0 : return i;
12692 : : }
12693 : :
12694 : : /** Complete action names. */
12695 : : static int
12696 : 0 : comp_action(struct context *ctx, const struct token *token,
12697 : : unsigned int ent, char *buf, unsigned int size)
12698 : : {
12699 : : unsigned int i;
12700 : :
12701 : : (void)ctx;
12702 : : (void)token;
12703 : 0 : for (i = 0; next_action[i]; ++i)
12704 : 0 : if (buf && i == ent)
12705 : 0 : return strlcpy(buf, token_list[next_action[i]].name,
12706 : : size);
12707 : 0 : if (buf)
12708 : : return -1;
12709 : 0 : return i;
12710 : : }
12711 : :
12712 : : /** Complete available ports. */
12713 : : static int
12714 : 0 : comp_port(struct context *ctx, const struct token *token,
12715 : : unsigned int ent, char *buf, unsigned int size)
12716 : : {
12717 : : unsigned int i = 0;
12718 : : portid_t p;
12719 : :
12720 : : (void)ctx;
12721 : : (void)token;
12722 : 0 : RTE_ETH_FOREACH_DEV(p) {
12723 : 0 : if (buf && i == ent)
12724 : 0 : return snprintf(buf, size, "%u", p);
12725 : 0 : ++i;
12726 : : }
12727 : 0 : if (buf)
12728 : : return -1;
12729 : 0 : return i;
12730 : : }
12731 : :
12732 : : /** Complete available rule IDs. */
12733 : : static int
12734 : 0 : comp_rule_id(struct context *ctx, const struct token *token,
12735 : : unsigned int ent, char *buf, unsigned int size)
12736 : : {
12737 : : unsigned int i = 0;
12738 : : struct rte_port *port;
12739 : : struct port_flow *pf;
12740 : :
12741 : : (void)token;
12742 : 0 : if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
12743 : 0 : ctx->port == (portid_t)RTE_PORT_ALL)
12744 : : return -1;
12745 : 0 : port = &ports[ctx->port];
12746 : 0 : for (pf = port->flow_list; pf != NULL; pf = pf->next) {
12747 : 0 : if (buf && i == ent)
12748 : 0 : return snprintf(buf, size, "%"PRIu64, pf->id);
12749 : 0 : ++i;
12750 : : }
12751 : 0 : if (buf)
12752 : : return -1;
12753 : 0 : return i;
12754 : : }
12755 : :
12756 : : /** Complete operation for compare match item. */
12757 : : static int
12758 : 0 : comp_set_compare_op(struct context *ctx, const struct token *token,
12759 : : unsigned int ent, char *buf, unsigned int size)
12760 : : {
12761 : : RTE_SET_USED(ctx);
12762 : : RTE_SET_USED(token);
12763 : 0 : if (!buf)
12764 : : return RTE_DIM(compare_ops);
12765 : 0 : if (ent < RTE_DIM(compare_ops) - 1)
12766 : 0 : return strlcpy(buf, compare_ops[ent], size);
12767 : : return -1;
12768 : : }
12769 : :
12770 : : /** Complete field id for compare match item. */
12771 : : static int
12772 : 0 : comp_set_compare_field_id(struct context *ctx, const struct token *token,
12773 : : unsigned int ent, char *buf, unsigned int size)
12774 : : {
12775 : : const char *name;
12776 : :
12777 : : RTE_SET_USED(token);
12778 : 0 : if (!buf)
12779 : : return RTE_DIM(flow_field_ids);
12780 : 0 : if (ent >= RTE_DIM(flow_field_ids) - 1)
12781 : : return -1;
12782 : 0 : name = flow_field_ids[ent];
12783 : 0 : if (ctx->curr == ITEM_COMPARE_FIELD_B_TYPE ||
12784 : 0 : (strcmp(name, "pointer") && strcmp(name, "value")))
12785 : 0 : return strlcpy(buf, name, size);
12786 : : return -1;
12787 : : }
12788 : :
12789 : : /** Complete type field for RSS action. */
12790 : : static int
12791 : 0 : comp_vc_action_rss_type(struct context *ctx, const struct token *token,
12792 : : unsigned int ent, char *buf, unsigned int size)
12793 : : {
12794 : : unsigned int i;
12795 : :
12796 : : (void)ctx;
12797 : : (void)token;
12798 : 0 : for (i = 0; rss_type_table[i].str; ++i)
12799 : : ;
12800 : 0 : if (!buf)
12801 : 0 : return i + 1;
12802 : 0 : if (ent < i)
12803 : 0 : return strlcpy(buf, rss_type_table[ent].str, size);
12804 : 0 : if (ent == i)
12805 : 0 : return snprintf(buf, size, "end");
12806 : : return -1;
12807 : : }
12808 : :
12809 : : /** Complete queue field for RSS action. */
12810 : : static int
12811 : 0 : comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
12812 : : unsigned int ent, char *buf, unsigned int size)
12813 : : {
12814 : : (void)ctx;
12815 : : (void)token;
12816 : 0 : if (!buf)
12817 : 0 : return nb_rxq + 1;
12818 : 0 : if (ent < nb_rxq)
12819 : 0 : return snprintf(buf, size, "%u", ent);
12820 : 0 : if (ent == nb_rxq)
12821 : 0 : return snprintf(buf, size, "end");
12822 : : return -1;
12823 : : }
12824 : :
12825 : : /** Complete index number for set raw_encap/raw_decap commands. */
12826 : : static int
12827 : 0 : comp_set_raw_index(struct context *ctx, const struct token *token,
12828 : : unsigned int ent, char *buf, unsigned int size)
12829 : : {
12830 : : uint16_t idx = 0;
12831 : : uint16_t nb = 0;
12832 : :
12833 : : RTE_SET_USED(ctx);
12834 : : RTE_SET_USED(token);
12835 : 0 : for (idx = 0; idx < RAW_ENCAP_CONFS_MAX_NUM; ++idx) {
12836 : 0 : if (buf && idx == ent)
12837 : 0 : return snprintf(buf, size, "%u", idx);
12838 : 0 : ++nb;
12839 : : }
12840 : : return nb;
12841 : : }
12842 : :
12843 : : /** Complete index number for set raw_ipv6_ext_push/ipv6_ext_remove commands. */
12844 : : static int
12845 : 0 : comp_set_ipv6_ext_index(struct context *ctx, const struct token *token,
12846 : : unsigned int ent, char *buf, unsigned int size)
12847 : : {
12848 : : uint16_t idx = 0;
12849 : : uint16_t nb = 0;
12850 : :
12851 : : RTE_SET_USED(ctx);
12852 : : RTE_SET_USED(token);
12853 : 0 : for (idx = 0; idx < IPV6_EXT_PUSH_CONFS_MAX_NUM; ++idx) {
12854 : 0 : if (buf && idx == ent)
12855 : 0 : return snprintf(buf, size, "%u", idx);
12856 : 0 : ++nb;
12857 : : }
12858 : : return nb;
12859 : : }
12860 : :
12861 : : /** Complete index number for set raw_encap/raw_decap commands. */
12862 : : static int
12863 : 0 : comp_set_sample_index(struct context *ctx, const struct token *token,
12864 : : unsigned int ent, char *buf, unsigned int size)
12865 : : {
12866 : : uint16_t idx = 0;
12867 : : uint16_t nb = 0;
12868 : :
12869 : : RTE_SET_USED(ctx);
12870 : : RTE_SET_USED(token);
12871 : 0 : for (idx = 0; idx < RAW_SAMPLE_CONFS_MAX_NUM; ++idx) {
12872 : 0 : if (buf && idx == ent)
12873 : 0 : return snprintf(buf, size, "%u", idx);
12874 : 0 : ++nb;
12875 : : }
12876 : : return nb;
12877 : : }
12878 : :
12879 : : /** Complete operation for modify_field command. */
12880 : : static int
12881 : 0 : comp_set_modify_field_op(struct context *ctx, const struct token *token,
12882 : : unsigned int ent, char *buf, unsigned int size)
12883 : : {
12884 : : RTE_SET_USED(ctx);
12885 : : RTE_SET_USED(token);
12886 : 0 : if (!buf)
12887 : : return RTE_DIM(modify_field_ops);
12888 : 0 : if (ent < RTE_DIM(modify_field_ops) - 1)
12889 : 0 : return strlcpy(buf, modify_field_ops[ent], size);
12890 : : return -1;
12891 : : }
12892 : :
12893 : : /** Complete field id for modify_field command. */
12894 : : static int
12895 : 0 : comp_set_modify_field_id(struct context *ctx, const struct token *token,
12896 : : unsigned int ent, char *buf, unsigned int size)
12897 : : {
12898 : : const char *name;
12899 : :
12900 : : RTE_SET_USED(token);
12901 : 0 : if (!buf)
12902 : : return RTE_DIM(flow_field_ids);
12903 : 0 : if (ent >= RTE_DIM(flow_field_ids) - 1)
12904 : : return -1;
12905 : 0 : name = flow_field_ids[ent];
12906 : 0 : if (ctx->curr == ACTION_MODIFY_FIELD_SRC_TYPE ||
12907 : 0 : (strcmp(name, "pointer") && strcmp(name, "value")))
12908 : 0 : return strlcpy(buf, name, size);
12909 : : return -1;
12910 : : }
12911 : :
12912 : : /** Complete available pattern template IDs. */
12913 : : static int
12914 : 0 : comp_pattern_template_id(struct context *ctx, const struct token *token,
12915 : : unsigned int ent, char *buf, unsigned int size)
12916 : : {
12917 : : unsigned int i = 0;
12918 : : struct rte_port *port;
12919 : : struct port_template *pt;
12920 : :
12921 : : (void)token;
12922 : 0 : if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
12923 : 0 : ctx->port == (portid_t)RTE_PORT_ALL)
12924 : : return -1;
12925 : 0 : port = &ports[ctx->port];
12926 : 0 : for (pt = port->pattern_templ_list; pt != NULL; pt = pt->next) {
12927 : 0 : if (buf && i == ent)
12928 : 0 : return snprintf(buf, size, "%u", pt->id);
12929 : 0 : ++i;
12930 : : }
12931 : 0 : if (buf)
12932 : : return -1;
12933 : 0 : return i;
12934 : : }
12935 : :
12936 : : /** Complete available actions template IDs. */
12937 : : static int
12938 : 0 : comp_actions_template_id(struct context *ctx, const struct token *token,
12939 : : unsigned int ent, char *buf, unsigned int size)
12940 : : {
12941 : : unsigned int i = 0;
12942 : : struct rte_port *port;
12943 : : struct port_template *pt;
12944 : :
12945 : : (void)token;
12946 : 0 : if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
12947 : 0 : ctx->port == (portid_t)RTE_PORT_ALL)
12948 : : return -1;
12949 : 0 : port = &ports[ctx->port];
12950 : 0 : for (pt = port->actions_templ_list; pt != NULL; pt = pt->next) {
12951 : 0 : if (buf && i == ent)
12952 : 0 : return snprintf(buf, size, "%u", pt->id);
12953 : 0 : ++i;
12954 : : }
12955 : 0 : if (buf)
12956 : : return -1;
12957 : 0 : return i;
12958 : : }
12959 : :
12960 : : /** Complete available table IDs. */
12961 : : static int
12962 : 0 : comp_table_id(struct context *ctx, const struct token *token,
12963 : : unsigned int ent, char *buf, unsigned int size)
12964 : : {
12965 : : unsigned int i = 0;
12966 : : struct rte_port *port;
12967 : : struct port_table *pt;
12968 : :
12969 : : (void)token;
12970 : 0 : if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
12971 : 0 : ctx->port == (portid_t)RTE_PORT_ALL)
12972 : : return -1;
12973 : 0 : port = &ports[ctx->port];
12974 : 0 : for (pt = port->table_list; pt != NULL; pt = pt->next) {
12975 : 0 : if (buf && i == ent)
12976 : 0 : return snprintf(buf, size, "%u", pt->id);
12977 : 0 : ++i;
12978 : : }
12979 : 0 : if (buf)
12980 : : return -1;
12981 : 0 : return i;
12982 : : }
12983 : :
12984 : : /** Complete available queue IDs. */
12985 : : static int
12986 : 0 : comp_queue_id(struct context *ctx, const struct token *token,
12987 : : unsigned int ent, char *buf, unsigned int size)
12988 : : {
12989 : : unsigned int i = 0;
12990 : : struct rte_port *port;
12991 : :
12992 : : (void)token;
12993 : 0 : if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
12994 : 0 : ctx->port == (portid_t)RTE_PORT_ALL)
12995 : : return -1;
12996 : 0 : port = &ports[ctx->port];
12997 : 0 : for (i = 0; i < port->queue_nb; i++) {
12998 : 0 : if (buf && i == ent)
12999 : 0 : return snprintf(buf, size, "%u", i);
13000 : : }
13001 : 0 : if (buf)
13002 : : return -1;
13003 : 0 : return i;
13004 : : }
13005 : :
13006 : : static int
13007 : : comp_names_to_index(struct context *ctx, const struct token *token,
13008 : : unsigned int ent, char *buf, unsigned int size,
13009 : : const char *const names[], size_t names_size)
13010 : : {
13011 : : RTE_SET_USED(ctx);
13012 : : RTE_SET_USED(token);
13013 : 0 : if (!buf)
13014 : : return names_size;
13015 : 0 : if (ent < names_size && names[ent] != NULL)
13016 : 0 : return rte_strscpy(buf, names[ent], size);
13017 : : return -1;
13018 : :
13019 : : }
13020 : :
13021 : : /** Complete available Meter colors. */
13022 : : static int
13023 : 0 : comp_meter_color(struct context *ctx, const struct token *token,
13024 : : unsigned int ent, char *buf, unsigned int size)
13025 : : {
13026 : : RTE_SET_USED(ctx);
13027 : : RTE_SET_USED(token);
13028 : 0 : if (!buf)
13029 : : return RTE_DIM(meter_colors);
13030 : 0 : if (ent < RTE_DIM(meter_colors) - 1)
13031 : 0 : return strlcpy(buf, meter_colors[ent], size);
13032 : : return -1;
13033 : : }
13034 : :
13035 : : /** Complete available Insertion Table types. */
13036 : : static int
13037 : 0 : comp_insertion_table_type(struct context *ctx, const struct token *token,
13038 : : unsigned int ent, char *buf, unsigned int size)
13039 : : {
13040 : : RTE_SET_USED(ctx);
13041 : : RTE_SET_USED(token);
13042 : 0 : if (!buf)
13043 : : return RTE_DIM(table_insertion_types);
13044 : 0 : if (ent < RTE_DIM(table_insertion_types) - 1)
13045 : 0 : return rte_strscpy(buf, table_insertion_types[ent], size);
13046 : : return -1;
13047 : : }
13048 : :
13049 : : /** Complete available Hash Calculation Table types. */
13050 : : static int
13051 : 0 : comp_hash_table_type(struct context *ctx, const struct token *token,
13052 : : unsigned int ent, char *buf, unsigned int size)
13053 : : {
13054 : : RTE_SET_USED(ctx);
13055 : : RTE_SET_USED(token);
13056 : 0 : if (!buf)
13057 : : return RTE_DIM(table_hash_funcs);
13058 : 0 : if (ent < RTE_DIM(table_hash_funcs) - 1)
13059 : 0 : return rte_strscpy(buf, table_hash_funcs[ent], size);
13060 : : return -1;
13061 : : }
13062 : :
13063 : : static int
13064 : 0 : comp_quota_state_name(struct context *ctx, const struct token *token,
13065 : : unsigned int ent, char *buf, unsigned int size)
13066 : : {
13067 : 0 : return comp_names_to_index(ctx, token, ent, buf, size,
13068 : : quota_state_names,
13069 : : RTE_DIM(quota_state_names));
13070 : : }
13071 : :
13072 : : static int
13073 : 0 : comp_quota_mode_name(struct context *ctx, const struct token *token,
13074 : : unsigned int ent, char *buf, unsigned int size)
13075 : : {
13076 : 0 : return comp_names_to_index(ctx, token, ent, buf, size,
13077 : : quota_mode_names,
13078 : : RTE_DIM(quota_mode_names));
13079 : : }
13080 : :
13081 : : static int
13082 : 0 : comp_quota_update_name(struct context *ctx, const struct token *token,
13083 : : unsigned int ent, char *buf, unsigned int size)
13084 : : {
13085 : 0 : return comp_names_to_index(ctx, token, ent, buf, size,
13086 : : quota_update_names,
13087 : : RTE_DIM(quota_update_names));
13088 : : }
13089 : :
13090 : : static int
13091 : 0 : comp_qu_mode_name(struct context *ctx, const struct token *token,
13092 : : unsigned int ent, char *buf, unsigned int size)
13093 : : {
13094 : 0 : return comp_names_to_index(ctx, token, ent, buf, size,
13095 : : query_update_mode_names,
13096 : : RTE_DIM(query_update_mode_names));
13097 : : }
13098 : :
13099 : : /** Internal context. */
13100 : : static struct context cmd_flow_context;
13101 : :
13102 : : /** Global parser instance (cmdline API). */
13103 : : cmdline_parse_inst_t cmd_flow;
13104 : : cmdline_parse_inst_t cmd_set_raw;
13105 : :
13106 : : /** Initialize context. */
13107 : : static void
13108 : : cmd_flow_context_init(struct context *ctx)
13109 : : {
13110 : : /* A full memset() is not necessary. */
13111 : 0 : ctx->curr = ZERO;
13112 : 0 : ctx->prev = ZERO;
13113 : 0 : ctx->next_num = 0;
13114 : 0 : ctx->args_num = 0;
13115 : 0 : ctx->eol = 0;
13116 : 0 : ctx->last = 0;
13117 : 0 : ctx->port = 0;
13118 : 0 : ctx->objdata = 0;
13119 : 0 : ctx->object = NULL;
13120 : 0 : ctx->objmask = NULL;
13121 : 0 : }
13122 : :
13123 : : /** Parse a token (cmdline API). */
13124 : : static int
13125 : 0 : cmd_flow_parse(cmdline_parse_token_hdr_t *hdr, const char *src, void *result,
13126 : : unsigned int size)
13127 : : {
13128 : : struct context *ctx = &cmd_flow_context;
13129 : : const struct token *token;
13130 : : const enum index *list;
13131 : : int len;
13132 : : int i;
13133 : :
13134 : : (void)hdr;
13135 : 0 : token = &token_list[ctx->curr];
13136 : : /* Check argument length. */
13137 : 0 : ctx->eol = 0;
13138 : 0 : ctx->last = 1;
13139 : 0 : for (len = 0; src[len]; ++len)
13140 : 0 : if (src[len] == '#' || isspace(src[len]))
13141 : : break;
13142 : 0 : if (!len)
13143 : : return -1;
13144 : : /* Last argument and EOL detection. */
13145 : 0 : for (i = len; src[i]; ++i)
13146 : 0 : if (src[i] == '#' || src[i] == '\r' || src[i] == '\n')
13147 : : break;
13148 : 0 : else if (!isspace(src[i])) {
13149 : 0 : ctx->last = 0;
13150 : 0 : break;
13151 : : }
13152 : 0 : for (; src[i]; ++i)
13153 : 0 : if (src[i] == '\r' || src[i] == '\n') {
13154 : 0 : ctx->eol = 1;
13155 : 0 : break;
13156 : : }
13157 : : /* Initialize context if necessary. */
13158 : 0 : if (!ctx->next_num) {
13159 : 0 : if (!token->next)
13160 : : return 0;
13161 : 0 : ctx->next[ctx->next_num++] = token->next[0];
13162 : : }
13163 : : /* Process argument through candidates. */
13164 : 0 : ctx->prev = ctx->curr;
13165 : 0 : list = ctx->next[ctx->next_num - 1];
13166 : 0 : for (i = 0; list[i]; ++i) {
13167 : 0 : const struct token *next = &token_list[list[i]];
13168 : : int tmp;
13169 : :
13170 : 0 : ctx->curr = list[i];
13171 : 0 : if (next->call)
13172 : 0 : tmp = next->call(ctx, next, src, len, result, size);
13173 : : else
13174 : : tmp = parse_default(ctx, next, src, len, result, size);
13175 : 0 : if (tmp == -1 || tmp != len)
13176 : : continue;
13177 : : token = next;
13178 : : break;
13179 : : }
13180 : 0 : if (!list[i])
13181 : : return -1;
13182 : 0 : --ctx->next_num;
13183 : : /* Push subsequent tokens if any. */
13184 : 0 : if (token->next)
13185 : 0 : for (i = 0; token->next[i]; ++i) {
13186 : 0 : if (ctx->next_num == RTE_DIM(ctx->next))
13187 : : return -1;
13188 : 0 : ctx->next[ctx->next_num++] = token->next[i];
13189 : : }
13190 : : /* Push arguments if any. */
13191 : 0 : if (token->args)
13192 : 0 : for (i = 0; token->args[i]; ++i) {
13193 : 0 : if (ctx->args_num == RTE_DIM(ctx->args))
13194 : : return -1;
13195 : 0 : ctx->args[ctx->args_num++] = token->args[i];
13196 : : }
13197 : : return len;
13198 : : }
13199 : :
13200 : : int
13201 : 0 : flow_parse(const char *src, void *result, unsigned int size,
13202 : : struct rte_flow_attr **attr,
13203 : : struct rte_flow_item **pattern, struct rte_flow_action **actions)
13204 : : {
13205 : : int ret;
13206 : 0 : struct context saved_flow_ctx = cmd_flow_context;
13207 : :
13208 : : cmd_flow_context_init(&cmd_flow_context);
13209 : : do {
13210 : 0 : ret = cmd_flow_parse(NULL, src, result, size);
13211 : 0 : if (ret > 0) {
13212 : 0 : src += ret;
13213 : 0 : while (isspace(*src))
13214 : 0 : src++;
13215 : : }
13216 : 0 : } while (ret > 0 && strlen(src));
13217 : 0 : cmd_flow_context = saved_flow_ctx;
13218 : 0 : *attr = &((struct buffer *)result)->args.vc.attr;
13219 : 0 : *pattern = ((struct buffer *)result)->args.vc.pattern;
13220 : 0 : *actions = ((struct buffer *)result)->args.vc.actions;
13221 : 0 : return (ret >= 0 && !strlen(src)) ? 0 : -1;
13222 : : }
13223 : :
13224 : : /** Return number of completion entries (cmdline API). */
13225 : : static int
13226 : 0 : cmd_flow_complete_get_nb(cmdline_parse_token_hdr_t *hdr)
13227 : : {
13228 : : struct context *ctx = &cmd_flow_context;
13229 : 0 : const struct token *token = &token_list[ctx->curr];
13230 : : const enum index *list;
13231 : : int i;
13232 : :
13233 : : (void)hdr;
13234 : : /* Count number of tokens in current list. */
13235 : 0 : if (ctx->next_num)
13236 : 0 : list = ctx->next[ctx->next_num - 1];
13237 : : else
13238 : 0 : list = token->next[0];
13239 : 0 : for (i = 0; list[i]; ++i)
13240 : : ;
13241 : 0 : if (!i)
13242 : : return 0;
13243 : : /*
13244 : : * If there is a single token, use its completion callback, otherwise
13245 : : * return the number of entries.
13246 : : */
13247 : 0 : token = &token_list[list[0]];
13248 : 0 : if (i == 1 && token->comp) {
13249 : : /* Save index for cmd_flow_get_help(). */
13250 : 0 : ctx->prev = list[0];
13251 : 0 : return token->comp(ctx, token, 0, NULL, 0);
13252 : : }
13253 : : return i;
13254 : : }
13255 : :
13256 : : /** Return a completion entry (cmdline API). */
13257 : : static int
13258 : 0 : cmd_flow_complete_get_elt(cmdline_parse_token_hdr_t *hdr, int index,
13259 : : char *dst, unsigned int size)
13260 : : {
13261 : : struct context *ctx = &cmd_flow_context;
13262 : 0 : const struct token *token = &token_list[ctx->curr];
13263 : : const enum index *list;
13264 : : int i;
13265 : :
13266 : : (void)hdr;
13267 : : /* Count number of tokens in current list. */
13268 : 0 : if (ctx->next_num)
13269 : 0 : list = ctx->next[ctx->next_num - 1];
13270 : : else
13271 : 0 : list = token->next[0];
13272 : 0 : for (i = 0; list[i]; ++i)
13273 : : ;
13274 : 0 : if (!i)
13275 : : return -1;
13276 : : /* If there is a single token, use its completion callback. */
13277 : 0 : token = &token_list[list[0]];
13278 : 0 : if (i == 1 && token->comp) {
13279 : : /* Save index for cmd_flow_get_help(). */
13280 : 0 : ctx->prev = list[0];
13281 : 0 : return token->comp(ctx, token, index, dst, size) < 0 ? -1 : 0;
13282 : : }
13283 : : /* Otherwise make sure the index is valid and use defaults. */
13284 : 0 : if (index >= i)
13285 : : return -1;
13286 : 0 : token = &token_list[list[index]];
13287 : 0 : strlcpy(dst, token->name, size);
13288 : : /* Save index for cmd_flow_get_help(). */
13289 : 0 : ctx->prev = list[index];
13290 : 0 : return 0;
13291 : : }
13292 : :
13293 : : /** Populate help strings for current token (cmdline API). */
13294 : : static int
13295 : 0 : cmd_flow_get_help(cmdline_parse_token_hdr_t *hdr, char *dst, unsigned int size)
13296 : : {
13297 : : struct context *ctx = &cmd_flow_context;
13298 : 0 : const struct token *token = &token_list[ctx->prev];
13299 : :
13300 : : (void)hdr;
13301 : 0 : if (!size)
13302 : : return -1;
13303 : : /* Set token type and update global help with details. */
13304 : 0 : strlcpy(dst, (token->type ? token->type : "TOKEN"), size);
13305 : 0 : if (token->help)
13306 : 0 : cmd_flow.help_str = token->help;
13307 : : else
13308 : 0 : cmd_flow.help_str = token->name;
13309 : : return 0;
13310 : : }
13311 : :
13312 : : /** Token definition template (cmdline API). */
13313 : : static struct cmdline_token_hdr cmd_flow_token_hdr = {
13314 : : .ops = &(struct cmdline_token_ops){
13315 : : .parse = cmd_flow_parse,
13316 : : .complete_get_nb = cmd_flow_complete_get_nb,
13317 : : .complete_get_elt = cmd_flow_complete_get_elt,
13318 : : .get_help = cmd_flow_get_help,
13319 : : },
13320 : : .offset = 0,
13321 : : };
13322 : :
13323 : : /** Populate the next dynamic token. */
13324 : : static void
13325 : 0 : cmd_flow_tok(cmdline_parse_token_hdr_t **hdr,
13326 : : cmdline_parse_token_hdr_t **hdr_inst)
13327 : : {
13328 : : struct context *ctx = &cmd_flow_context;
13329 : :
13330 : : /* Always reinitialize context before requesting the first token. */
13331 : 0 : if (!(hdr_inst - cmd_flow.tokens))
13332 : : cmd_flow_context_init(ctx);
13333 : : /* Return NULL when no more tokens are expected. */
13334 : 0 : if (!ctx->next_num && ctx->curr) {
13335 : 0 : *hdr = NULL;
13336 : 0 : return;
13337 : : }
13338 : : /* Determine if command should end here. */
13339 : 0 : if (ctx->eol && ctx->last && ctx->next_num) {
13340 : 0 : const enum index *list = ctx->next[ctx->next_num - 1];
13341 : : int i;
13342 : :
13343 : 0 : for (i = 0; list[i]; ++i) {
13344 : 0 : if (list[i] != END)
13345 : : continue;
13346 : 0 : *hdr = NULL;
13347 : 0 : return;
13348 : : }
13349 : : }
13350 : 0 : *hdr = &cmd_flow_token_hdr;
13351 : : }
13352 : :
13353 : : static SLIST_HEAD(, indlst_conf) indlst_conf_head =
13354 : : SLIST_HEAD_INITIALIZER();
13355 : :
13356 : : static void
13357 : 0 : indirect_action_flow_conf_create(const struct buffer *in)
13358 : : {
13359 : : int len, ret;
13360 : : uint32_t i;
13361 : : struct indlst_conf *indlst_conf = NULL;
13362 : : size_t base = RTE_ALIGN(sizeof(*indlst_conf), 8);
13363 : 0 : struct rte_flow_action *src = in->args.vc.actions;
13364 : :
13365 : 0 : if (!in->args.vc.actions_n)
13366 : 0 : goto end;
13367 : 0 : len = rte_flow_conv(RTE_FLOW_CONV_OP_ACTIONS, NULL, 0, src, NULL);
13368 : 0 : if (len <= 0)
13369 : 0 : goto end;
13370 : 0 : len = RTE_ALIGN(len, 16);
13371 : :
13372 : 0 : indlst_conf = calloc(1, base + len +
13373 : 0 : in->args.vc.actions_n * sizeof(uintptr_t));
13374 : 0 : if (!indlst_conf)
13375 : 0 : goto end;
13376 : 0 : indlst_conf->id = in->args.vc.attr.group;
13377 : 0 : indlst_conf->conf_num = in->args.vc.actions_n - 1;
13378 : 0 : indlst_conf->actions = RTE_PTR_ADD(indlst_conf, base);
13379 : 0 : ret = rte_flow_conv(RTE_FLOW_CONV_OP_ACTIONS, indlst_conf->actions,
13380 : : len, src, NULL);
13381 : 0 : if (ret <= 0) {
13382 : 0 : free(indlst_conf);
13383 : : indlst_conf = NULL;
13384 : 0 : goto end;
13385 : : }
13386 : 0 : indlst_conf->conf = RTE_PTR_ADD(indlst_conf, base + len);
13387 : 0 : for (i = 0; i < indlst_conf->conf_num; i++)
13388 : 0 : indlst_conf->conf[i] = indlst_conf->actions[i].conf;
13389 : 0 : SLIST_INSERT_HEAD(&indlst_conf_head, indlst_conf, next);
13390 : 0 : end:
13391 : 0 : if (indlst_conf)
13392 : : printf("created indirect action list configuration %u\n",
13393 : 0 : in->args.vc.attr.group);
13394 : : else
13395 : : printf("cannot create indirect action list configuration %u\n",
13396 : 0 : in->args.vc.attr.group);
13397 : 0 : }
13398 : :
13399 : : static const struct indlst_conf *
13400 : : indirect_action_list_conf_get(uint32_t conf_id)
13401 : : {
13402 : : const struct indlst_conf *conf;
13403 : :
13404 : 0 : SLIST_FOREACH(conf, &indlst_conf_head, next) {
13405 : 0 : if (conf->id == conf_id)
13406 : : return conf;
13407 : : }
13408 : : return NULL;
13409 : : }
13410 : :
13411 : : /** Dispatch parsed buffer to function calls. */
13412 : : static void
13413 : 0 : cmd_flow_parsed(const struct buffer *in)
13414 : : {
13415 : 0 : switch (in->command) {
13416 : 0 : case INFO:
13417 : 0 : port_flow_get_info(in->port);
13418 : 0 : break;
13419 : 0 : case CONFIGURE:
13420 : 0 : port_flow_configure(in->port,
13421 : : &in->args.configure.port_attr,
13422 : 0 : in->args.configure.nb_queue,
13423 : : &in->args.configure.queue_attr);
13424 : 0 : break;
13425 : 0 : case PATTERN_TEMPLATE_CREATE:
13426 : 0 : port_flow_pattern_template_create(in->port,
13427 : 0 : in->args.vc.pat_templ_id,
13428 : 0 : &((const struct rte_flow_pattern_template_attr) {
13429 : 0 : .relaxed_matching = in->args.vc.attr.reserved,
13430 : 0 : .ingress = in->args.vc.attr.ingress,
13431 : 0 : .egress = in->args.vc.attr.egress,
13432 : 0 : .transfer = in->args.vc.attr.transfer,
13433 : : }),
13434 : 0 : in->args.vc.pattern);
13435 : 0 : break;
13436 : 0 : case PATTERN_TEMPLATE_DESTROY:
13437 : 0 : port_flow_pattern_template_destroy(in->port,
13438 : 0 : in->args.templ_destroy.template_id_n,
13439 : 0 : in->args.templ_destroy.template_id);
13440 : 0 : break;
13441 : 0 : case ACTIONS_TEMPLATE_CREATE:
13442 : 0 : port_flow_actions_template_create(in->port,
13443 : 0 : in->args.vc.act_templ_id,
13444 : 0 : &((const struct rte_flow_actions_template_attr) {
13445 : 0 : .ingress = in->args.vc.attr.ingress,
13446 : 0 : .egress = in->args.vc.attr.egress,
13447 : 0 : .transfer = in->args.vc.attr.transfer,
13448 : : }),
13449 : 0 : in->args.vc.actions,
13450 : 0 : in->args.vc.masks);
13451 : 0 : break;
13452 : 0 : case ACTIONS_TEMPLATE_DESTROY:
13453 : 0 : port_flow_actions_template_destroy(in->port,
13454 : 0 : in->args.templ_destroy.template_id_n,
13455 : 0 : in->args.templ_destroy.template_id);
13456 : 0 : break;
13457 : 0 : case TABLE_CREATE:
13458 : 0 : port_flow_template_table_create(in->port, in->args.table.id,
13459 : 0 : &in->args.table.attr, in->args.table.pat_templ_id_n,
13460 : 0 : in->args.table.pat_templ_id, in->args.table.act_templ_id_n,
13461 : 0 : in->args.table.act_templ_id);
13462 : 0 : break;
13463 : 0 : case TABLE_DESTROY:
13464 : 0 : port_flow_template_table_destroy(in->port,
13465 : 0 : in->args.table_destroy.table_id_n,
13466 : 0 : in->args.table_destroy.table_id);
13467 : 0 : break;
13468 : 0 : case TABLE_RESIZE_COMPLETE:
13469 : 0 : port_flow_template_table_resize_complete
13470 : 0 : (in->port, in->args.table_destroy.table_id[0]);
13471 : 0 : break;
13472 : 0 : case GROUP_SET_MISS_ACTIONS:
13473 : 0 : port_queue_group_set_miss_actions(in->port, &in->args.vc.attr,
13474 : 0 : in->args.vc.actions);
13475 : 0 : break;
13476 : 0 : case TABLE_RESIZE:
13477 : 0 : port_flow_template_table_resize(in->port, in->args.table.id,
13478 : 0 : in->args.table.attr.nb_flows);
13479 : 0 : break;
13480 : 0 : case QUEUE_CREATE:
13481 : 0 : port_queue_flow_create(in->port, in->queue, in->postpone,
13482 : 0 : in->args.vc.table_id, in->args.vc.rule_id,
13483 : 0 : in->args.vc.pat_templ_id, in->args.vc.act_templ_id,
13484 : 0 : in->args.vc.pattern, in->args.vc.actions);
13485 : 0 : break;
13486 : 0 : case QUEUE_DESTROY:
13487 : 0 : port_queue_flow_destroy(in->port, in->queue, in->postpone,
13488 : 0 : in->args.destroy.rule_n,
13489 : 0 : in->args.destroy.rule);
13490 : 0 : break;
13491 : 0 : case QUEUE_FLOW_UPDATE_RESIZED:
13492 : 0 : port_queue_flow_update_resized(in->port, in->queue,
13493 : 0 : in->postpone,
13494 : 0 : in->args.destroy.rule[0]);
13495 : 0 : break;
13496 : 0 : case QUEUE_UPDATE:
13497 : 0 : port_queue_flow_update(in->port, in->queue, in->postpone,
13498 : 0 : in->args.vc.rule_id, in->args.vc.act_templ_id,
13499 : 0 : in->args.vc.actions);
13500 : 0 : break;
13501 : 0 : case PUSH:
13502 : 0 : port_queue_flow_push(in->port, in->queue);
13503 : 0 : break;
13504 : 0 : case PULL:
13505 : 0 : port_queue_flow_pull(in->port, in->queue);
13506 : 0 : break;
13507 : 0 : case HASH:
13508 : 0 : if (!in->args.vc.encap_hash)
13509 : 0 : port_flow_hash_calc(in->port, in->args.vc.table_id,
13510 : 0 : in->args.vc.pat_templ_id,
13511 : 0 : in->args.vc.pattern);
13512 : : else
13513 : 0 : port_flow_hash_calc_encap(in->port, in->args.vc.field,
13514 : 0 : in->args.vc.pattern);
13515 : : break;
13516 : 0 : case QUEUE_AGED:
13517 : 0 : port_queue_flow_aged(in->port, in->queue,
13518 : 0 : in->args.aged.destroy);
13519 : 0 : break;
13520 : 0 : case QUEUE_INDIRECT_ACTION_CREATE:
13521 : : case QUEUE_INDIRECT_ACTION_LIST_CREATE:
13522 : 0 : port_queue_action_handle_create(
13523 : 0 : in->port, in->queue, in->postpone,
13524 : 0 : in->args.vc.attr.group,
13525 : : in->command == QUEUE_INDIRECT_ACTION_LIST_CREATE,
13526 : 0 : &((const struct rte_flow_indir_action_conf) {
13527 : 0 : .ingress = in->args.vc.attr.ingress,
13528 : 0 : .egress = in->args.vc.attr.egress,
13529 : 0 : .transfer = in->args.vc.attr.transfer,
13530 : : }),
13531 : 0 : in->args.vc.actions);
13532 : 0 : break;
13533 : 0 : case QUEUE_INDIRECT_ACTION_DESTROY:
13534 : 0 : port_queue_action_handle_destroy(in->port,
13535 : 0 : in->queue, in->postpone,
13536 : 0 : in->args.ia_destroy.action_id_n,
13537 : 0 : in->args.ia_destroy.action_id);
13538 : 0 : break;
13539 : 0 : case QUEUE_INDIRECT_ACTION_UPDATE:
13540 : 0 : port_queue_action_handle_update(in->port,
13541 : 0 : in->queue, in->postpone,
13542 : 0 : in->args.vc.attr.group,
13543 : 0 : in->args.vc.actions);
13544 : 0 : break;
13545 : 0 : case QUEUE_INDIRECT_ACTION_QUERY:
13546 : 0 : port_queue_action_handle_query(in->port,
13547 : 0 : in->queue, in->postpone,
13548 : 0 : in->args.ia.action_id);
13549 : 0 : break;
13550 : 0 : case QUEUE_INDIRECT_ACTION_QUERY_UPDATE:
13551 : 0 : port_queue_action_handle_query_update(in->port, in->queue,
13552 : 0 : in->postpone,
13553 : 0 : in->args.ia.action_id,
13554 : 0 : in->args.ia.qu_mode,
13555 : 0 : in->args.vc.actions);
13556 : 0 : break;
13557 : 0 : case INDIRECT_ACTION_CREATE:
13558 : : case INDIRECT_ACTION_LIST_CREATE:
13559 : 0 : port_action_handle_create(
13560 : 0 : in->port, in->args.vc.attr.group,
13561 : : in->command == INDIRECT_ACTION_LIST_CREATE,
13562 : 0 : &((const struct rte_flow_indir_action_conf) {
13563 : 0 : .ingress = in->args.vc.attr.ingress,
13564 : 0 : .egress = in->args.vc.attr.egress,
13565 : 0 : .transfer = in->args.vc.attr.transfer,
13566 : : }),
13567 : 0 : in->args.vc.actions);
13568 : 0 : break;
13569 : 0 : case INDIRECT_ACTION_FLOW_CONF_CREATE:
13570 : 0 : indirect_action_flow_conf_create(in);
13571 : 0 : break;
13572 : 0 : case INDIRECT_ACTION_DESTROY:
13573 : 0 : port_action_handle_destroy(in->port,
13574 : 0 : in->args.ia_destroy.action_id_n,
13575 : 0 : in->args.ia_destroy.action_id);
13576 : 0 : break;
13577 : 0 : case INDIRECT_ACTION_UPDATE:
13578 : 0 : port_action_handle_update(in->port, in->args.vc.attr.group,
13579 : 0 : in->args.vc.actions);
13580 : 0 : break;
13581 : 0 : case INDIRECT_ACTION_QUERY:
13582 : 0 : port_action_handle_query(in->port, in->args.ia.action_id);
13583 : 0 : break;
13584 : 0 : case INDIRECT_ACTION_QUERY_UPDATE:
13585 : 0 : port_action_handle_query_update(in->port,
13586 : 0 : in->args.ia.action_id,
13587 : 0 : in->args.ia.qu_mode,
13588 : 0 : in->args.vc.actions);
13589 : 0 : break;
13590 : 0 : case VALIDATE:
13591 : 0 : port_flow_validate(in->port, &in->args.vc.attr,
13592 : 0 : in->args.vc.pattern, in->args.vc.actions,
13593 : : &in->args.vc.tunnel_ops);
13594 : 0 : break;
13595 : 0 : case CREATE:
13596 : 0 : port_flow_create(in->port, &in->args.vc.attr,
13597 : 0 : in->args.vc.pattern, in->args.vc.actions,
13598 : 0 : &in->args.vc.tunnel_ops, in->args.vc.user_id);
13599 : 0 : break;
13600 : 0 : case DESTROY:
13601 : 0 : port_flow_destroy(in->port, in->args.destroy.rule_n,
13602 : 0 : in->args.destroy.rule,
13603 : 0 : in->args.destroy.is_user_id);
13604 : 0 : break;
13605 : 0 : case UPDATE:
13606 : 0 : port_flow_update(in->port, in->args.vc.rule_id,
13607 : 0 : in->args.vc.actions, in->args.vc.user_id);
13608 : 0 : break;
13609 : 0 : case FLUSH:
13610 : 0 : port_flow_flush(in->port);
13611 : 0 : break;
13612 : 0 : case DUMP_ONE:
13613 : : case DUMP_ALL:
13614 : 0 : port_flow_dump(in->port, in->args.dump.dump_all,
13615 : 0 : in->args.dump.rule, in->args.dump.file,
13616 : 0 : in->args.dump.is_user_id,
13617 : 0 : in->args.dump.append_to_file);
13618 : 0 : break;
13619 : 0 : case QUERY:
13620 : 0 : port_flow_query(in->port, in->args.query.rule,
13621 : : &in->args.query.action,
13622 : 0 : in->args.query.is_user_id);
13623 : 0 : break;
13624 : 0 : case LIST:
13625 : 0 : port_flow_list(in->port, in->args.list.group_n,
13626 : 0 : in->args.list.group);
13627 : 0 : break;
13628 : 0 : case ISOLATE:
13629 : 0 : port_flow_isolate(in->port, in->args.isolate.set);
13630 : 0 : break;
13631 : 0 : case AGED:
13632 : 0 : port_flow_aged(in->port, in->args.aged.destroy);
13633 : 0 : break;
13634 : 0 : case TUNNEL_CREATE:
13635 : 0 : port_flow_tunnel_create(in->port, &in->args.vc.tunnel_ops);
13636 : 0 : break;
13637 : 0 : case TUNNEL_DESTROY:
13638 : 0 : port_flow_tunnel_destroy(in->port, in->args.vc.tunnel_ops.id);
13639 : 0 : break;
13640 : 0 : case TUNNEL_LIST:
13641 : 0 : port_flow_tunnel_list(in->port);
13642 : 0 : break;
13643 : 0 : case ACTION_POL_G:
13644 : 0 : port_meter_policy_add(in->port, in->args.policy.policy_id,
13645 : 0 : in->args.vc.actions);
13646 : 0 : break;
13647 : 0 : case FLEX_ITEM_CREATE:
13648 : 0 : flex_item_create(in->port, in->args.flex.token,
13649 : 0 : in->args.flex.filename);
13650 : 0 : break;
13651 : 0 : case FLEX_ITEM_DESTROY:
13652 : 0 : flex_item_destroy(in->port, in->args.flex.token);
13653 : 0 : break;
13654 : : default:
13655 : : break;
13656 : : }
13657 : 0 : fflush(stdout);
13658 : 0 : }
13659 : :
13660 : : /** Token generator and output processing callback (cmdline API). */
13661 : : static void
13662 : 0 : cmd_flow_cb(void *arg0, struct cmdline *cl, void *arg2)
13663 : : {
13664 : 0 : if (cl == NULL)
13665 : 0 : cmd_flow_tok(arg0, arg2);
13666 : : else
13667 : 0 : cmd_flow_parsed(arg0);
13668 : 0 : }
13669 : :
13670 : : /** Global parser instance (cmdline API). */
13671 : : cmdline_parse_inst_t cmd_flow = {
13672 : : .f = cmd_flow_cb,
13673 : : .data = NULL, /**< Unused. */
13674 : : .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
13675 : : .tokens = {
13676 : : NULL,
13677 : : }, /**< Tokens are returned by cmd_flow_tok(). */
13678 : : };
13679 : :
13680 : : /** set cmd facility. Reuse cmd flow's infrastructure as much as possible. */
13681 : :
13682 : : static void
13683 : 0 : update_fields(uint8_t *buf, struct rte_flow_item *item, uint16_t next_proto)
13684 : : {
13685 : : struct rte_ipv4_hdr *ipv4;
13686 : : struct rte_ether_hdr *eth;
13687 : : struct rte_ipv6_hdr *ipv6;
13688 : : struct rte_vxlan_hdr *vxlan;
13689 : : struct rte_vxlan_gpe_hdr *gpe;
13690 : : struct rte_flow_item_nvgre *nvgre;
13691 : : uint32_t ipv6_vtc_flow;
13692 : :
13693 : 0 : switch (item->type) {
13694 : 0 : case RTE_FLOW_ITEM_TYPE_ETH:
13695 : : eth = (struct rte_ether_hdr *)buf;
13696 : 0 : if (next_proto)
13697 : 0 : eth->ether_type = rte_cpu_to_be_16(next_proto);
13698 : : break;
13699 : 0 : case RTE_FLOW_ITEM_TYPE_IPV4:
13700 : : ipv4 = (struct rte_ipv4_hdr *)buf;
13701 : 0 : if (!ipv4->version_ihl)
13702 : 0 : ipv4->version_ihl = RTE_IPV4_VHL_DEF;
13703 : 0 : if (next_proto && ipv4->next_proto_id == 0)
13704 : 0 : ipv4->next_proto_id = (uint8_t)next_proto;
13705 : : break;
13706 : 0 : case RTE_FLOW_ITEM_TYPE_IPV6:
13707 : : ipv6 = (struct rte_ipv6_hdr *)buf;
13708 : 0 : if (next_proto && ipv6->proto == 0)
13709 : 0 : ipv6->proto = (uint8_t)next_proto;
13710 : 0 : ipv6_vtc_flow = rte_be_to_cpu_32(ipv6->vtc_flow);
13711 : 0 : ipv6_vtc_flow &= 0x0FFFFFFF; /* reset version bits. */
13712 : 0 : ipv6_vtc_flow |= 0x60000000; /* set ipv6 version. */
13713 : 0 : ipv6->vtc_flow = rte_cpu_to_be_32(ipv6_vtc_flow);
13714 : 0 : break;
13715 : 0 : case RTE_FLOW_ITEM_TYPE_VXLAN:
13716 : : vxlan = (struct rte_vxlan_hdr *)buf;
13717 : 0 : if (!vxlan->flags)
13718 : 0 : vxlan->flags = 0x08;
13719 : : break;
13720 : 0 : case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
13721 : : gpe = (struct rte_vxlan_gpe_hdr *)buf;
13722 : 0 : gpe->vx_flags = 0x0C;
13723 : 0 : break;
13724 : 0 : case RTE_FLOW_ITEM_TYPE_NVGRE:
13725 : : nvgre = (struct rte_flow_item_nvgre *)buf;
13726 : 0 : nvgre->protocol = rte_cpu_to_be_16(0x6558);
13727 : 0 : nvgre->c_k_s_rsvd0_ver = rte_cpu_to_be_16(0x2000);
13728 : 0 : break;
13729 : : default:
13730 : : break;
13731 : : }
13732 : 0 : }
13733 : :
13734 : : /** Helper of get item's default mask. */
13735 : : static const void *
13736 : 0 : flow_item_default_mask(const struct rte_flow_item *item)
13737 : : {
13738 : : const void *mask = NULL;
13739 : : static rte_be32_t gre_key_default_mask = RTE_BE32(UINT32_MAX);
13740 : : static struct rte_flow_item_ipv6_routing_ext ipv6_routing_ext_default_mask = {
13741 : : .hdr = {
13742 : : .next_hdr = 0xff,
13743 : : .type = 0xff,
13744 : : .segments_left = 0xff,
13745 : : },
13746 : : };
13747 : :
13748 : 0 : switch (item->type) {
13749 : 0 : case RTE_FLOW_ITEM_TYPE_ANY:
13750 : : mask = &rte_flow_item_any_mask;
13751 : 0 : break;
13752 : 0 : case RTE_FLOW_ITEM_TYPE_PORT_ID:
13753 : : mask = &rte_flow_item_port_id_mask;
13754 : 0 : break;
13755 : 0 : case RTE_FLOW_ITEM_TYPE_RAW:
13756 : : mask = &rte_flow_item_raw_mask;
13757 : 0 : break;
13758 : 0 : case RTE_FLOW_ITEM_TYPE_ETH:
13759 : : mask = &rte_flow_item_eth_mask;
13760 : 0 : break;
13761 : 0 : case RTE_FLOW_ITEM_TYPE_VLAN:
13762 : : mask = &rte_flow_item_vlan_mask;
13763 : 0 : break;
13764 : 0 : case RTE_FLOW_ITEM_TYPE_IPV4:
13765 : : mask = &rte_flow_item_ipv4_mask;
13766 : 0 : break;
13767 : 0 : case RTE_FLOW_ITEM_TYPE_IPV6:
13768 : : mask = &rte_flow_item_ipv6_mask;
13769 : 0 : break;
13770 : 0 : case RTE_FLOW_ITEM_TYPE_ICMP:
13771 : : mask = &rte_flow_item_icmp_mask;
13772 : 0 : break;
13773 : 0 : case RTE_FLOW_ITEM_TYPE_UDP:
13774 : : mask = &rte_flow_item_udp_mask;
13775 : 0 : break;
13776 : 0 : case RTE_FLOW_ITEM_TYPE_TCP:
13777 : : mask = &rte_flow_item_tcp_mask;
13778 : 0 : break;
13779 : 0 : case RTE_FLOW_ITEM_TYPE_SCTP:
13780 : : mask = &rte_flow_item_sctp_mask;
13781 : 0 : break;
13782 : 0 : case RTE_FLOW_ITEM_TYPE_VXLAN:
13783 : : mask = &rte_flow_item_vxlan_mask;
13784 : 0 : break;
13785 : 0 : case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
13786 : : mask = &rte_flow_item_vxlan_gpe_mask;
13787 : 0 : break;
13788 : 0 : case RTE_FLOW_ITEM_TYPE_E_TAG:
13789 : : mask = &rte_flow_item_e_tag_mask;
13790 : 0 : break;
13791 : 0 : case RTE_FLOW_ITEM_TYPE_NVGRE:
13792 : : mask = &rte_flow_item_nvgre_mask;
13793 : 0 : break;
13794 : 0 : case RTE_FLOW_ITEM_TYPE_MPLS:
13795 : : mask = &rte_flow_item_mpls_mask;
13796 : 0 : break;
13797 : 0 : case RTE_FLOW_ITEM_TYPE_GRE:
13798 : : mask = &rte_flow_item_gre_mask;
13799 : 0 : break;
13800 : 0 : case RTE_FLOW_ITEM_TYPE_GRE_KEY:
13801 : : mask = &gre_key_default_mask;
13802 : 0 : break;
13803 : 0 : case RTE_FLOW_ITEM_TYPE_META:
13804 : : mask = &rte_flow_item_meta_mask;
13805 : 0 : break;
13806 : 0 : case RTE_FLOW_ITEM_TYPE_RANDOM:
13807 : : mask = &rte_flow_item_random_mask;
13808 : 0 : break;
13809 : 0 : case RTE_FLOW_ITEM_TYPE_FUZZY:
13810 : : mask = &rte_flow_item_fuzzy_mask;
13811 : 0 : break;
13812 : 0 : case RTE_FLOW_ITEM_TYPE_GTP:
13813 : : mask = &rte_flow_item_gtp_mask;
13814 : 0 : break;
13815 : 0 : case RTE_FLOW_ITEM_TYPE_GTP_PSC:
13816 : : mask = &rte_flow_item_gtp_psc_mask;
13817 : 0 : break;
13818 : 0 : case RTE_FLOW_ITEM_TYPE_GENEVE:
13819 : : mask = &rte_flow_item_geneve_mask;
13820 : 0 : break;
13821 : 0 : case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
13822 : : mask = &rte_flow_item_geneve_opt_mask;
13823 : 0 : break;
13824 : 0 : case RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID:
13825 : : mask = &rte_flow_item_pppoe_proto_id_mask;
13826 : 0 : break;
13827 : 0 : case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
13828 : : mask = &rte_flow_item_l2tpv3oip_mask;
13829 : 0 : break;
13830 : 0 : case RTE_FLOW_ITEM_TYPE_ESP:
13831 : : mask = &rte_flow_item_esp_mask;
13832 : 0 : break;
13833 : 0 : case RTE_FLOW_ITEM_TYPE_AH:
13834 : : mask = &rte_flow_item_ah_mask;
13835 : 0 : break;
13836 : 0 : case RTE_FLOW_ITEM_TYPE_PFCP:
13837 : : mask = &rte_flow_item_pfcp_mask;
13838 : 0 : break;
13839 : 0 : case RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR:
13840 : : case RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT:
13841 : : mask = &rte_flow_item_ethdev_mask;
13842 : 0 : break;
13843 : 0 : case RTE_FLOW_ITEM_TYPE_L2TPV2:
13844 : : mask = &rte_flow_item_l2tpv2_mask;
13845 : 0 : break;
13846 : 0 : case RTE_FLOW_ITEM_TYPE_PPP:
13847 : : mask = &rte_flow_item_ppp_mask;
13848 : 0 : break;
13849 : 0 : case RTE_FLOW_ITEM_TYPE_METER_COLOR:
13850 : : mask = &rte_flow_item_meter_color_mask;
13851 : 0 : break;
13852 : 0 : case RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT:
13853 : : mask = &ipv6_routing_ext_default_mask;
13854 : 0 : break;
13855 : 0 : case RTE_FLOW_ITEM_TYPE_AGGR_AFFINITY:
13856 : : mask = &rte_flow_item_aggr_affinity_mask;
13857 : 0 : break;
13858 : 0 : case RTE_FLOW_ITEM_TYPE_TX_QUEUE:
13859 : : mask = &rte_flow_item_tx_queue_mask;
13860 : 0 : break;
13861 : 0 : case RTE_FLOW_ITEM_TYPE_IB_BTH:
13862 : : mask = &rte_flow_item_ib_bth_mask;
13863 : 0 : break;
13864 : 0 : case RTE_FLOW_ITEM_TYPE_PTYPE:
13865 : : mask = &rte_flow_item_ptype_mask;
13866 : 0 : break;
13867 : : default:
13868 : : break;
13869 : : }
13870 : 0 : return mask;
13871 : : }
13872 : :
13873 : : /** Dispatch parsed buffer to function calls. */
13874 : : static void
13875 : 0 : cmd_set_ipv6_ext_parsed(const struct buffer *in)
13876 : : {
13877 : 0 : uint32_t n = in->args.vc.pattern_n;
13878 : : int i = 0;
13879 : : struct rte_flow_item *item = NULL;
13880 : : size_t size = 0;
13881 : : uint8_t *data = NULL;
13882 : : uint8_t *type = NULL;
13883 : : size_t *total_size = NULL;
13884 : 0 : uint16_t idx = in->port; /* We borrow port field as index */
13885 : : struct rte_flow_item_ipv6_routing_ext *ext;
13886 : : const struct rte_flow_item_ipv6_ext *ipv6_ext;
13887 : :
13888 : : RTE_ASSERT(in->command == SET_IPV6_EXT_PUSH ||
13889 : : in->command == SET_IPV6_EXT_REMOVE);
13890 : :
13891 : 0 : if (in->command == SET_IPV6_EXT_REMOVE) {
13892 : 0 : if (n != 1 || in->args.vc.pattern->type !=
13893 : : RTE_FLOW_ITEM_TYPE_IPV6_EXT) {
13894 : 0 : fprintf(stderr, "Error - Not supported item\n");
13895 : 0 : return;
13896 : : }
13897 : 0 : type = (uint8_t *)&ipv6_ext_remove_confs[idx].type;
13898 : : item = in->args.vc.pattern;
13899 : 0 : ipv6_ext = item->spec;
13900 : 0 : *type = ipv6_ext->next_hdr;
13901 : 0 : return;
13902 : : }
13903 : :
13904 : 0 : total_size = &ipv6_ext_push_confs[idx].size;
13905 : 0 : data = (uint8_t *)&ipv6_ext_push_confs[idx].data;
13906 : : type = (uint8_t *)&ipv6_ext_push_confs[idx].type;
13907 : :
13908 : 0 : *total_size = 0;
13909 : : memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
13910 : 0 : for (i = n - 1 ; i >= 0; --i) {
13911 : 0 : item = in->args.vc.pattern + i;
13912 : 0 : switch (item->type) {
13913 : 0 : case RTE_FLOW_ITEM_TYPE_IPV6_EXT:
13914 : 0 : ipv6_ext = item->spec;
13915 : 0 : *type = ipv6_ext->next_hdr;
13916 : 0 : break;
13917 : 0 : case RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT:
13918 : 0 : ext = (struct rte_flow_item_ipv6_routing_ext *)(uintptr_t)item->spec;
13919 : 0 : if (!ext->hdr.hdr_len) {
13920 : 0 : size = sizeof(struct rte_ipv6_routing_ext) +
13921 : 0 : (ext->hdr.segments_left << 4);
13922 : 0 : ext->hdr.hdr_len = ext->hdr.segments_left << 1;
13923 : : /* Indicate no TLV once SRH. */
13924 : 0 : if (ext->hdr.type == 4)
13925 : 0 : ext->hdr.last_entry = ext->hdr.segments_left - 1;
13926 : : } else {
13927 : 0 : size = sizeof(struct rte_ipv6_routing_ext) +
13928 : 0 : (ext->hdr.hdr_len << 3);
13929 : : }
13930 : 0 : *total_size += size;
13931 : : memcpy(data, ext, size);
13932 : : break;
13933 : 0 : default:
13934 : 0 : fprintf(stderr, "Error - Not supported item\n");
13935 : 0 : goto error;
13936 : : }
13937 : : }
13938 : : RTE_ASSERT((*total_size) <= ACTION_IPV6_EXT_PUSH_MAX_DATA);
13939 : : return;
13940 : : error:
13941 : 0 : *total_size = 0;
13942 : : memset(data, 0x00, ACTION_IPV6_EXT_PUSH_MAX_DATA);
13943 : : }
13944 : :
13945 : : /** Dispatch parsed buffer to function calls. */
13946 : : static void
13947 : 0 : cmd_set_raw_parsed_sample(const struct buffer *in)
13948 : : {
13949 : 0 : uint32_t n = in->args.vc.actions_n;
13950 : : uint32_t i = 0;
13951 : : struct rte_flow_action *action = NULL;
13952 : : struct rte_flow_action *data = NULL;
13953 : : const struct rte_flow_action_rss *rss = NULL;
13954 : : size_t size = 0;
13955 : 0 : uint16_t idx = in->port; /* We borrow port field as index */
13956 : : uint32_t max_size = sizeof(struct rte_flow_action) *
13957 : : ACTION_SAMPLE_ACTIONS_NUM;
13958 : :
13959 : : RTE_ASSERT(in->command == SET_SAMPLE_ACTIONS);
13960 : 0 : data = (struct rte_flow_action *)&raw_sample_confs[idx].data;
13961 : : memset(data, 0x00, max_size);
13962 : 0 : for (; i <= n - 1; i++) {
13963 : 0 : action = in->args.vc.actions + i;
13964 : 0 : if (action->type == RTE_FLOW_ACTION_TYPE_END)
13965 : : break;
13966 : 0 : switch (action->type) {
13967 : 0 : case RTE_FLOW_ACTION_TYPE_MARK:
13968 : : size = sizeof(struct rte_flow_action_mark);
13969 : 0 : rte_memcpy(&sample_mark[idx],
13970 : : (const void *)action->conf, size);
13971 : 0 : action->conf = &sample_mark[idx];
13972 : 0 : break;
13973 : 0 : case RTE_FLOW_ACTION_TYPE_COUNT:
13974 : : size = sizeof(struct rte_flow_action_count);
13975 : 0 : rte_memcpy(&sample_count[idx],
13976 : : (const void *)action->conf, size);
13977 : 0 : action->conf = &sample_count[idx];
13978 : 0 : break;
13979 : 0 : case RTE_FLOW_ACTION_TYPE_QUEUE:
13980 : : size = sizeof(struct rte_flow_action_queue);
13981 : 0 : rte_memcpy(&sample_queue[idx],
13982 : : (const void *)action->conf, size);
13983 : 0 : action->conf = &sample_queue[idx];
13984 : 0 : break;
13985 : 0 : case RTE_FLOW_ACTION_TYPE_RSS:
13986 : : size = sizeof(struct rte_flow_action_rss);
13987 : 0 : rss = action->conf;
13988 : 0 : rte_memcpy(&sample_rss_data[idx].conf,
13989 : : (const void *)rss, size);
13990 : 0 : if (rss->key_len && rss->key) {
13991 : 0 : sample_rss_data[idx].conf.key =
13992 : 0 : sample_rss_data[idx].key;
13993 : 0 : rte_memcpy((void *)((uintptr_t)
13994 : : sample_rss_data[idx].conf.key),
13995 : 0 : (const void *)rss->key,
13996 : : sizeof(uint8_t) * rss->key_len);
13997 : : }
13998 : 0 : if (rss->queue_num && rss->queue) {
13999 : 0 : sample_rss_data[idx].conf.queue =
14000 : 0 : sample_rss_data[idx].queue;
14001 : 0 : rte_memcpy((void *)((uintptr_t)
14002 : : sample_rss_data[idx].conf.queue),
14003 : 0 : (const void *)rss->queue,
14004 : 0 : sizeof(uint16_t) * rss->queue_num);
14005 : : }
14006 : 0 : action->conf = &sample_rss_data[idx].conf;
14007 : 0 : break;
14008 : 0 : case RTE_FLOW_ACTION_TYPE_RAW_ENCAP:
14009 : : size = sizeof(struct rte_flow_action_raw_encap);
14010 : 0 : rte_memcpy(&sample_encap[idx],
14011 : : (const void *)action->conf, size);
14012 : 0 : action->conf = &sample_encap[idx];
14013 : 0 : break;
14014 : 0 : case RTE_FLOW_ACTION_TYPE_PORT_ID:
14015 : : size = sizeof(struct rte_flow_action_port_id);
14016 : 0 : rte_memcpy(&sample_port_id[idx],
14017 : : (const void *)action->conf, size);
14018 : 0 : action->conf = &sample_port_id[idx];
14019 : 0 : break;
14020 : : case RTE_FLOW_ACTION_TYPE_PF:
14021 : : break;
14022 : 0 : case RTE_FLOW_ACTION_TYPE_VF:
14023 : : size = sizeof(struct rte_flow_action_vf);
14024 : 0 : rte_memcpy(&sample_vf[idx],
14025 : : (const void *)action->conf, size);
14026 : 0 : action->conf = &sample_vf[idx];
14027 : 0 : break;
14028 : 0 : case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP:
14029 : : size = sizeof(struct rte_flow_action_vxlan_encap);
14030 : 0 : parse_setup_vxlan_encap_data(&sample_vxlan_encap[idx]);
14031 : 0 : action->conf = &sample_vxlan_encap[idx].conf;
14032 : 0 : break;
14033 : 0 : case RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP:
14034 : : size = sizeof(struct rte_flow_action_nvgre_encap);
14035 : 0 : parse_setup_nvgre_encap_data(&sample_nvgre_encap[idx]);
14036 : 0 : action->conf = &sample_nvgre_encap[idx];
14037 : 0 : break;
14038 : 0 : case RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR:
14039 : : size = sizeof(struct rte_flow_action_ethdev);
14040 : 0 : rte_memcpy(&sample_port_representor[idx],
14041 : : (const void *)action->conf, size);
14042 : 0 : action->conf = &sample_port_representor[idx];
14043 : 0 : break;
14044 : 0 : case RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT:
14045 : : size = sizeof(struct rte_flow_action_ethdev);
14046 : 0 : rte_memcpy(&sample_represented_port[idx],
14047 : : (const void *)action->conf, size);
14048 : 0 : action->conf = &sample_represented_port[idx];
14049 : 0 : break;
14050 : 0 : default:
14051 : 0 : fprintf(stderr, "Error - Not supported action\n");
14052 : : return;
14053 : : }
14054 : 0 : *data = *action;
14055 : 0 : data++;
14056 : : }
14057 : : }
14058 : :
14059 : : /** Dispatch parsed buffer to function calls. */
14060 : : static void
14061 : 0 : cmd_set_raw_parsed(const struct buffer *in)
14062 : : {
14063 : 0 : uint32_t n = in->args.vc.pattern_n;
14064 : : int i = 0;
14065 : : struct rte_flow_item *item = NULL;
14066 : : size_t size = 0;
14067 : : uint8_t *data = NULL;
14068 : : uint8_t *data_tail = NULL;
14069 : : size_t *total_size = NULL;
14070 : : uint16_t upper_layer = 0;
14071 : : uint16_t proto = 0;
14072 : 0 : uint16_t idx = in->port; /* We borrow port field as index */
14073 : : int gtp_psc = -1; /* GTP PSC option index. */
14074 : : const void *src_spec;
14075 : :
14076 : 0 : if (in->command == SET_SAMPLE_ACTIONS) {
14077 : 0 : cmd_set_raw_parsed_sample(in);
14078 : 0 : return;
14079 : : }
14080 : 0 : else if (in->command == SET_IPV6_EXT_PUSH ||
14081 : : in->command == SET_IPV6_EXT_REMOVE) {
14082 : 0 : cmd_set_ipv6_ext_parsed(in);
14083 : 0 : return;
14084 : : }
14085 : : RTE_ASSERT(in->command == SET_RAW_ENCAP ||
14086 : : in->command == SET_RAW_DECAP);
14087 : 0 : if (in->command == SET_RAW_ENCAP) {
14088 : 0 : total_size = &raw_encap_confs[idx].size;
14089 : 0 : data = (uint8_t *)&raw_encap_confs[idx].data;
14090 : : } else {
14091 : 0 : total_size = &raw_decap_confs[idx].size;
14092 : 0 : data = (uint8_t *)&raw_decap_confs[idx].data;
14093 : : }
14094 : 0 : *total_size = 0;
14095 : : memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
14096 : : /* process hdr from upper layer to low layer (L3/L4 -> L2). */
14097 : 0 : data_tail = data + ACTION_RAW_ENCAP_MAX_DATA;
14098 : 0 : for (i = n - 1 ; i >= 0; --i) {
14099 : : const struct rte_flow_item_gtp *gtp;
14100 : : const struct rte_flow_item_geneve_opt *geneve_opt;
14101 : : struct rte_flow_item_ipv6_routing_ext *ext;
14102 : :
14103 : 0 : item = in->args.vc.pattern + i;
14104 : 0 : if (item->spec == NULL)
14105 : 0 : item->spec = flow_item_default_mask(item);
14106 : 0 : src_spec = item->spec;
14107 : 0 : switch (item->type) {
14108 : : case RTE_FLOW_ITEM_TYPE_ETH:
14109 : : size = sizeof(struct rte_ether_hdr);
14110 : : break;
14111 : 0 : case RTE_FLOW_ITEM_TYPE_VLAN:
14112 : : size = sizeof(struct rte_vlan_hdr);
14113 : : proto = RTE_ETHER_TYPE_VLAN;
14114 : 0 : break;
14115 : 0 : case RTE_FLOW_ITEM_TYPE_IPV4:
14116 : : size = sizeof(struct rte_ipv4_hdr);
14117 : : proto = RTE_ETHER_TYPE_IPV4;
14118 : 0 : break;
14119 : 0 : case RTE_FLOW_ITEM_TYPE_IPV6:
14120 : : size = sizeof(struct rte_ipv6_hdr);
14121 : : proto = RTE_ETHER_TYPE_IPV6;
14122 : 0 : break;
14123 : 0 : case RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT:
14124 : : ext = (struct rte_flow_item_ipv6_routing_ext *)(uintptr_t)item->spec;
14125 : 0 : if (!ext->hdr.hdr_len) {
14126 : 0 : size = sizeof(struct rte_ipv6_routing_ext) +
14127 : 0 : (ext->hdr.segments_left << 4);
14128 : 0 : ext->hdr.hdr_len = ext->hdr.segments_left << 1;
14129 : : /* SRv6 without TLV. */
14130 : 0 : if (ext->hdr.type == RTE_IPV6_SRCRT_TYPE_4)
14131 : 0 : ext->hdr.last_entry = ext->hdr.segments_left - 1;
14132 : : } else {
14133 : 0 : size = sizeof(struct rte_ipv6_routing_ext) +
14134 : 0 : (ext->hdr.hdr_len << 3);
14135 : : }
14136 : : proto = IPPROTO_ROUTING;
14137 : : break;
14138 : 0 : case RTE_FLOW_ITEM_TYPE_UDP:
14139 : : size = sizeof(struct rte_udp_hdr);
14140 : : proto = 0x11;
14141 : 0 : break;
14142 : 0 : case RTE_FLOW_ITEM_TYPE_TCP:
14143 : : size = sizeof(struct rte_tcp_hdr);
14144 : : proto = 0x06;
14145 : 0 : break;
14146 : 0 : case RTE_FLOW_ITEM_TYPE_VXLAN:
14147 : : size = sizeof(struct rte_vxlan_hdr);
14148 : 0 : break;
14149 : 0 : case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
14150 : : size = sizeof(struct rte_vxlan_gpe_hdr);
14151 : 0 : break;
14152 : 0 : case RTE_FLOW_ITEM_TYPE_GRE:
14153 : : size = sizeof(struct rte_gre_hdr);
14154 : : proto = 0x2F;
14155 : 0 : break;
14156 : 0 : case RTE_FLOW_ITEM_TYPE_GRE_KEY:
14157 : : size = sizeof(rte_be32_t);
14158 : : proto = 0x0;
14159 : 0 : break;
14160 : 0 : case RTE_FLOW_ITEM_TYPE_MPLS:
14161 : : size = sizeof(struct rte_mpls_hdr);
14162 : : proto = 0x0;
14163 : 0 : break;
14164 : 0 : case RTE_FLOW_ITEM_TYPE_NVGRE:
14165 : : size = sizeof(struct rte_flow_item_nvgre);
14166 : : proto = 0x2F;
14167 : 0 : break;
14168 : 0 : case RTE_FLOW_ITEM_TYPE_GENEVE:
14169 : : size = sizeof(struct rte_geneve_hdr);
14170 : 0 : break;
14171 : 0 : case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
14172 : : geneve_opt = (const struct rte_flow_item_geneve_opt *)
14173 : : item->spec;
14174 : : size = offsetof(struct rte_flow_item_geneve_opt,
14175 : : option_len) + sizeof(uint8_t);
14176 : 0 : if (geneve_opt->option_len && geneve_opt->data) {
14177 : 0 : *total_size += geneve_opt->option_len *
14178 : : sizeof(uint32_t);
14179 : 0 : rte_memcpy(data_tail - (*total_size),
14180 : : geneve_opt->data,
14181 : : geneve_opt->option_len * sizeof(uint32_t));
14182 : : }
14183 : : break;
14184 : 0 : case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
14185 : : size = sizeof(rte_be32_t);
14186 : : proto = 0x73;
14187 : 0 : break;
14188 : 0 : case RTE_FLOW_ITEM_TYPE_ESP:
14189 : : size = sizeof(struct rte_esp_hdr);
14190 : : proto = 0x32;
14191 : 0 : break;
14192 : 0 : case RTE_FLOW_ITEM_TYPE_AH:
14193 : : size = sizeof(struct rte_flow_item_ah);
14194 : : proto = 0x33;
14195 : 0 : break;
14196 : 0 : case RTE_FLOW_ITEM_TYPE_GTP:
14197 : 0 : if (gtp_psc < 0) {
14198 : : size = sizeof(struct rte_gtp_hdr);
14199 : : break;
14200 : : }
14201 : 0 : if (gtp_psc != i + 1) {
14202 : 0 : fprintf(stderr,
14203 : : "Error - GTP PSC does not follow GTP\n");
14204 : 0 : goto error;
14205 : : }
14206 : : gtp = item->spec;
14207 : 0 : if (gtp->hdr.s == 1 || gtp->hdr.pn == 1) {
14208 : : /* Only E flag should be set. */
14209 : 0 : fprintf(stderr,
14210 : : "Error - GTP unsupported flags\n");
14211 : 0 : goto error;
14212 : : } else {
14213 : 0 : struct rte_gtp_hdr_ext_word ext_word = {
14214 : : .next_ext = 0x85
14215 : : };
14216 : :
14217 : : /* We have to add GTP header extra word. */
14218 : 0 : *total_size += sizeof(ext_word);
14219 : 0 : rte_memcpy(data_tail - (*total_size),
14220 : : &ext_word, sizeof(ext_word));
14221 : : }
14222 : : size = sizeof(struct rte_gtp_hdr);
14223 : 0 : break;
14224 : 0 : case RTE_FLOW_ITEM_TYPE_GTP_PSC:
14225 : 0 : if (gtp_psc >= 0) {
14226 : 0 : fprintf(stderr,
14227 : : "Error - Multiple GTP PSC items\n");
14228 : 0 : goto error;
14229 : : } else {
14230 : : const struct rte_flow_item_gtp_psc
14231 : : *gtp_opt = item->spec;
14232 : : struct rte_gtp_psc_generic_hdr *hdr;
14233 : : size_t hdr_size = RTE_ALIGN(sizeof(*hdr),
14234 : : sizeof(int32_t));
14235 : :
14236 : 0 : *total_size += hdr_size;
14237 : 0 : hdr = (typeof(hdr))(data_tail - (*total_size));
14238 : : memset(hdr, 0, hdr_size);
14239 : 0 : *hdr = gtp_opt->hdr;
14240 : 0 : hdr->ext_hdr_len = 1;
14241 : : gtp_psc = i;
14242 : : size = 0;
14243 : : }
14244 : 0 : break;
14245 : 0 : case RTE_FLOW_ITEM_TYPE_PFCP:
14246 : : size = sizeof(struct rte_flow_item_pfcp);
14247 : 0 : break;
14248 : 0 : case RTE_FLOW_ITEM_TYPE_FLEX:
14249 : 0 : if (item->spec != NULL) {
14250 : 0 : size = ((const struct rte_flow_item_flex *)item->spec)->length;
14251 : 0 : src_spec = ((const struct rte_flow_item_flex *)item->spec)->pattern;
14252 : : } else {
14253 : : size = 0;
14254 : : src_spec = NULL;
14255 : : }
14256 : : break;
14257 : 0 : case RTE_FLOW_ITEM_TYPE_GRE_OPTION:
14258 : : size = 0;
14259 : 0 : if (item->spec) {
14260 : : const struct rte_flow_item_gre_opt
14261 : : *gre_opt = item->spec;
14262 : 0 : if (gre_opt->checksum_rsvd.checksum) {
14263 : 0 : *total_size +=
14264 : : sizeof(gre_opt->checksum_rsvd);
14265 : 0 : rte_memcpy(data_tail - (*total_size),
14266 : 0 : &gre_opt->checksum_rsvd,
14267 : : sizeof(gre_opt->checksum_rsvd));
14268 : : }
14269 : 0 : if (gre_opt->key.key) {
14270 : 0 : *total_size += sizeof(gre_opt->key.key);
14271 : 0 : rte_memcpy(data_tail - (*total_size),
14272 : 0 : &gre_opt->key.key,
14273 : : sizeof(gre_opt->key.key));
14274 : : }
14275 : 0 : if (gre_opt->sequence.sequence) {
14276 : 0 : *total_size += sizeof(gre_opt->sequence.sequence);
14277 : 0 : rte_memcpy(data_tail - (*total_size),
14278 : 0 : &gre_opt->sequence.sequence,
14279 : : sizeof(gre_opt->sequence.sequence));
14280 : : }
14281 : : }
14282 : : proto = 0x2F;
14283 : : break;
14284 : 0 : default:
14285 : 0 : fprintf(stderr, "Error - Not supported item\n");
14286 : 0 : goto error;
14287 : : }
14288 : 0 : if (size) {
14289 : 0 : *total_size += size;
14290 : 0 : rte_memcpy(data_tail - (*total_size), src_spec, size);
14291 : : /* update some fields which cannot be set by cmdline */
14292 : 0 : update_fields((data_tail - (*total_size)), item,
14293 : : upper_layer);
14294 : : upper_layer = proto;
14295 : : }
14296 : : }
14297 : 0 : if (verbose_level & 0x1)
14298 : 0 : printf("total data size is %zu\n", (*total_size));
14299 : : RTE_ASSERT((*total_size) <= ACTION_RAW_ENCAP_MAX_DATA);
14300 : 0 : memmove(data, (data_tail - (*total_size)), *total_size);
14301 : : return;
14302 : :
14303 : 0 : error:
14304 : 0 : *total_size = 0;
14305 : : memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
14306 : : }
14307 : :
14308 : : /** Populate help strings for current token (cmdline API). */
14309 : : static int
14310 : 0 : cmd_set_raw_get_help(cmdline_parse_token_hdr_t *hdr, char *dst,
14311 : : unsigned int size)
14312 : : {
14313 : : struct context *ctx = &cmd_flow_context;
14314 : 0 : const struct token *token = &token_list[ctx->prev];
14315 : :
14316 : : (void)hdr;
14317 : 0 : if (!size)
14318 : : return -1;
14319 : : /* Set token type and update global help with details. */
14320 : 0 : snprintf(dst, size, "%s", (token->type ? token->type : "TOKEN"));
14321 : 0 : if (token->help)
14322 : 0 : cmd_set_raw.help_str = token->help;
14323 : : else
14324 : 0 : cmd_set_raw.help_str = token->name;
14325 : : return 0;
14326 : : }
14327 : :
14328 : : /** Token definition template (cmdline API). */
14329 : : static struct cmdline_token_hdr cmd_set_raw_token_hdr = {
14330 : : .ops = &(struct cmdline_token_ops){
14331 : : .parse = cmd_flow_parse,
14332 : : .complete_get_nb = cmd_flow_complete_get_nb,
14333 : : .complete_get_elt = cmd_flow_complete_get_elt,
14334 : : .get_help = cmd_set_raw_get_help,
14335 : : },
14336 : : .offset = 0,
14337 : : };
14338 : :
14339 : : /** Populate the next dynamic token. */
14340 : : static void
14341 : 0 : cmd_set_raw_tok(cmdline_parse_token_hdr_t **hdr,
14342 : : cmdline_parse_token_hdr_t **hdr_inst)
14343 : : {
14344 : : struct context *ctx = &cmd_flow_context;
14345 : :
14346 : : /* Always reinitialize context before requesting the first token. */
14347 : 0 : if (!(hdr_inst - cmd_set_raw.tokens)) {
14348 : : cmd_flow_context_init(ctx);
14349 : 0 : ctx->curr = START_SET;
14350 : : }
14351 : : /* Return NULL when no more tokens are expected. */
14352 : 0 : if (!ctx->next_num && (ctx->curr != START_SET)) {
14353 : 0 : *hdr = NULL;
14354 : 0 : return;
14355 : : }
14356 : : /* Determine if command should end here. */
14357 : 0 : if (ctx->eol && ctx->last && ctx->next_num) {
14358 : 0 : const enum index *list = ctx->next[ctx->next_num - 1];
14359 : : int i;
14360 : :
14361 : 0 : for (i = 0; list[i]; ++i) {
14362 : 0 : if (list[i] != END)
14363 : : continue;
14364 : 0 : *hdr = NULL;
14365 : 0 : return;
14366 : : }
14367 : : }
14368 : 0 : *hdr = &cmd_set_raw_token_hdr;
14369 : : }
14370 : :
14371 : : /** Token generator and output processing callback (cmdline API). */
14372 : : static void
14373 : 0 : cmd_set_raw_cb(void *arg0, struct cmdline *cl, void *arg2)
14374 : : {
14375 : 0 : if (cl == NULL)
14376 : 0 : cmd_set_raw_tok(arg0, arg2);
14377 : : else
14378 : 0 : cmd_set_raw_parsed(arg0);
14379 : 0 : }
14380 : :
14381 : : /** Global parser instance (cmdline API). */
14382 : : cmdline_parse_inst_t cmd_set_raw = {
14383 : : .f = cmd_set_raw_cb,
14384 : : .data = NULL, /**< Unused. */
14385 : : .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
14386 : : .tokens = {
14387 : : NULL,
14388 : : }, /**< Tokens are returned by cmd_flow_tok(). */
14389 : : };
14390 : :
14391 : : /* *** display raw_encap/raw_decap buf */
14392 : : struct cmd_show_set_raw_result {
14393 : : cmdline_fixed_string_t cmd_show;
14394 : : cmdline_fixed_string_t cmd_what;
14395 : : cmdline_fixed_string_t cmd_all;
14396 : : uint16_t cmd_index;
14397 : : };
14398 : :
14399 : : static void
14400 : 0 : cmd_show_set_raw_parsed(void *parsed_result, struct cmdline *cl, void *data)
14401 : : {
14402 : : struct cmd_show_set_raw_result *res = parsed_result;
14403 : 0 : uint16_t index = res->cmd_index;
14404 : : uint8_t all = 0;
14405 : : uint8_t *raw_data = NULL;
14406 : : size_t raw_size = 0;
14407 : 0 : char title[16] = {0};
14408 : :
14409 : : RTE_SET_USED(cl);
14410 : : RTE_SET_USED(data);
14411 : 0 : if (!strcmp(res->cmd_all, "all")) {
14412 : : all = 1;
14413 : : index = 0;
14414 : 0 : } else if (index >= RAW_ENCAP_CONFS_MAX_NUM) {
14415 : 0 : fprintf(stderr, "index should be 0-%u\n",
14416 : : RAW_ENCAP_CONFS_MAX_NUM - 1);
14417 : 0 : return;
14418 : : }
14419 : : do {
14420 : 0 : if (!strcmp(res->cmd_what, "raw_encap")) {
14421 : 0 : raw_data = (uint8_t *)&raw_encap_confs[index].data;
14422 : 0 : raw_size = raw_encap_confs[index].size;
14423 : : snprintf(title, 16, "\nindex: %u", index);
14424 : 0 : rte_hexdump(stdout, title, raw_data, raw_size);
14425 : : } else {
14426 : 0 : raw_data = (uint8_t *)&raw_decap_confs[index].data;
14427 : 0 : raw_size = raw_decap_confs[index].size;
14428 : : snprintf(title, 16, "\nindex: %u", index);
14429 : 0 : rte_hexdump(stdout, title, raw_data, raw_size);
14430 : : }
14431 : 0 : } while (all && ++index < RAW_ENCAP_CONFS_MAX_NUM);
14432 : : }
14433 : :
14434 : : static cmdline_parse_token_string_t cmd_show_set_raw_cmd_show =
14435 : : TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
14436 : : cmd_show, "show");
14437 : : static cmdline_parse_token_string_t cmd_show_set_raw_cmd_what =
14438 : : TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
14439 : : cmd_what, "raw_encap#raw_decap");
14440 : : static cmdline_parse_token_num_t cmd_show_set_raw_cmd_index =
14441 : : TOKEN_NUM_INITIALIZER(struct cmd_show_set_raw_result,
14442 : : cmd_index, RTE_UINT16);
14443 : : static cmdline_parse_token_string_t cmd_show_set_raw_cmd_all =
14444 : : TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
14445 : : cmd_all, "all");
14446 : : cmdline_parse_inst_t cmd_show_set_raw = {
14447 : : .f = cmd_show_set_raw_parsed,
14448 : : .data = NULL,
14449 : : .help_str = "show <raw_encap|raw_decap> <index>",
14450 : : .tokens = {
14451 : : (void *)&cmd_show_set_raw_cmd_show,
14452 : : (void *)&cmd_show_set_raw_cmd_what,
14453 : : (void *)&cmd_show_set_raw_cmd_index,
14454 : : NULL,
14455 : : },
14456 : : };
14457 : : cmdline_parse_inst_t cmd_show_set_raw_all = {
14458 : : .f = cmd_show_set_raw_parsed,
14459 : : .data = NULL,
14460 : : .help_str = "show <raw_encap|raw_decap> all",
14461 : : .tokens = {
14462 : : (void *)&cmd_show_set_raw_cmd_show,
14463 : : (void *)&cmd_show_set_raw_cmd_what,
14464 : : (void *)&cmd_show_set_raw_cmd_all,
14465 : : NULL,
14466 : : },
14467 : : };
|