Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright 2016 6WIND S.A.
3 : : * Copyright 2016 Mellanox Technologies, Ltd
4 : : */
5 : :
6 : : #include <stddef.h>
7 : : #include <stdint.h>
8 : : #include <stdio.h>
9 : : #include <stdlib.h>
10 : : #include <inttypes.h>
11 : : #include <errno.h>
12 : : #include <ctype.h>
13 : : #include <string.h>
14 : :
15 : : #include <rte_string_fns.h>
16 : : #include <rte_common.h>
17 : : #include <rte_ethdev.h>
18 : : #include <rte_byteorder.h>
19 : : #include <cmdline_parse.h>
20 : : #include <cmdline_parse_etheraddr.h>
21 : : #include <cmdline_parse_string.h>
22 : : #include <cmdline_parse_num.h>
23 : : #include <rte_flow.h>
24 : : #include <rte_hexdump.h>
25 : : #include <rte_vxlan.h>
26 : : #include <rte_gre.h>
27 : : #include <rte_mpls.h>
28 : : #include <rte_gtp.h>
29 : : #include <rte_geneve.h>
30 : :
31 : : #include "testpmd.h"
32 : :
33 : : /** Parser token indices. */
34 : : enum index {
35 : : /* Special tokens. */
36 : : ZERO = 0,
37 : : END,
38 : : START_SET,
39 : : END_SET,
40 : :
41 : : /* Common tokens. */
42 : : COMMON_INTEGER,
43 : : COMMON_UNSIGNED,
44 : : COMMON_PREFIX,
45 : : COMMON_BOOLEAN,
46 : : COMMON_STRING,
47 : : COMMON_HEX,
48 : : COMMON_FILE_PATH,
49 : : COMMON_MAC_ADDR,
50 : : COMMON_IPV4_ADDR,
51 : : COMMON_IPV6_ADDR,
52 : : COMMON_RULE_ID,
53 : : COMMON_PORT_ID,
54 : : COMMON_GROUP_ID,
55 : : COMMON_PRIORITY_LEVEL,
56 : : COMMON_INDIRECT_ACTION_ID,
57 : : COMMON_PROFILE_ID,
58 : : COMMON_POLICY_ID,
59 : : COMMON_FLEX_HANDLE,
60 : : COMMON_FLEX_TOKEN,
61 : : COMMON_PATTERN_TEMPLATE_ID,
62 : : COMMON_ACTIONS_TEMPLATE_ID,
63 : : COMMON_TABLE_ID,
64 : : COMMON_QUEUE_ID,
65 : : COMMON_METER_COLOR_NAME,
66 : :
67 : : /* TOP-level command. */
68 : : ADD,
69 : :
70 : : /* Top-level command. */
71 : : SET,
72 : : /* Sub-leve commands. */
73 : : SET_RAW_ENCAP,
74 : : SET_RAW_DECAP,
75 : : SET_RAW_INDEX,
76 : : SET_SAMPLE_ACTIONS,
77 : : SET_SAMPLE_INDEX,
78 : : SET_IPV6_EXT_REMOVE,
79 : : SET_IPV6_EXT_PUSH,
80 : : SET_IPV6_EXT_INDEX,
81 : :
82 : : /* Top-level command. */
83 : : FLOW,
84 : : /* Sub-level commands. */
85 : : INFO,
86 : : CONFIGURE,
87 : : PATTERN_TEMPLATE,
88 : : ACTIONS_TEMPLATE,
89 : : TABLE,
90 : : FLOW_GROUP,
91 : : INDIRECT_ACTION,
92 : : VALIDATE,
93 : : CREATE,
94 : : DESTROY,
95 : : UPDATE,
96 : : FLUSH,
97 : : DUMP,
98 : : QUERY,
99 : : LIST,
100 : : AGED,
101 : : ISOLATE,
102 : : TUNNEL,
103 : : FLEX,
104 : : QUEUE,
105 : : PUSH,
106 : : PULL,
107 : : HASH,
108 : :
109 : : /* Flex arguments */
110 : : FLEX_ITEM_CREATE,
111 : : FLEX_ITEM_DESTROY,
112 : :
113 : : /* Pattern template arguments. */
114 : : PATTERN_TEMPLATE_CREATE,
115 : : PATTERN_TEMPLATE_DESTROY,
116 : : PATTERN_TEMPLATE_CREATE_ID,
117 : : PATTERN_TEMPLATE_DESTROY_ID,
118 : : PATTERN_TEMPLATE_RELAXED_MATCHING,
119 : : PATTERN_TEMPLATE_INGRESS,
120 : : PATTERN_TEMPLATE_EGRESS,
121 : : PATTERN_TEMPLATE_TRANSFER,
122 : : PATTERN_TEMPLATE_SPEC,
123 : :
124 : : /* Actions template arguments. */
125 : : ACTIONS_TEMPLATE_CREATE,
126 : : ACTIONS_TEMPLATE_DESTROY,
127 : : ACTIONS_TEMPLATE_CREATE_ID,
128 : : ACTIONS_TEMPLATE_DESTROY_ID,
129 : : ACTIONS_TEMPLATE_INGRESS,
130 : : ACTIONS_TEMPLATE_EGRESS,
131 : : ACTIONS_TEMPLATE_TRANSFER,
132 : : ACTIONS_TEMPLATE_SPEC,
133 : : ACTIONS_TEMPLATE_MASK,
134 : :
135 : : /* Queue arguments. */
136 : : QUEUE_CREATE,
137 : : QUEUE_DESTROY,
138 : : QUEUE_FLOW_UPDATE_RESIZED,
139 : : QUEUE_UPDATE,
140 : : QUEUE_AGED,
141 : : QUEUE_INDIRECT_ACTION,
142 : :
143 : : /* Queue create arguments. */
144 : : QUEUE_CREATE_POSTPONE,
145 : : QUEUE_TEMPLATE_TABLE,
146 : : QUEUE_PATTERN_TEMPLATE,
147 : : QUEUE_ACTIONS_TEMPLATE,
148 : : QUEUE_RULE_ID,
149 : :
150 : : /* Queue destroy arguments. */
151 : : QUEUE_DESTROY_ID,
152 : : QUEUE_DESTROY_POSTPONE,
153 : :
154 : : /* Queue update arguments. */
155 : : QUEUE_UPDATE_ID,
156 : :
157 : : /* Queue indirect action arguments */
158 : : QUEUE_INDIRECT_ACTION_CREATE,
159 : : QUEUE_INDIRECT_ACTION_LIST_CREATE,
160 : : QUEUE_INDIRECT_ACTION_UPDATE,
161 : : QUEUE_INDIRECT_ACTION_DESTROY,
162 : : QUEUE_INDIRECT_ACTION_QUERY,
163 : : QUEUE_INDIRECT_ACTION_QUERY_UPDATE,
164 : :
165 : : /* Queue indirect action create arguments */
166 : : QUEUE_INDIRECT_ACTION_CREATE_ID,
167 : : QUEUE_INDIRECT_ACTION_INGRESS,
168 : : QUEUE_INDIRECT_ACTION_EGRESS,
169 : : QUEUE_INDIRECT_ACTION_TRANSFER,
170 : : QUEUE_INDIRECT_ACTION_CREATE_POSTPONE,
171 : : QUEUE_INDIRECT_ACTION_SPEC,
172 : : QUEUE_INDIRECT_ACTION_LIST,
173 : :
174 : : /* Queue indirect action update arguments */
175 : : QUEUE_INDIRECT_ACTION_UPDATE_POSTPONE,
176 : :
177 : : /* Queue indirect action destroy arguments */
178 : : QUEUE_INDIRECT_ACTION_DESTROY_ID,
179 : : QUEUE_INDIRECT_ACTION_DESTROY_POSTPONE,
180 : :
181 : : /* Queue indirect action query arguments */
182 : : QUEUE_INDIRECT_ACTION_QUERY_POSTPONE,
183 : :
184 : : /* Queue indirect action query_update arguments */
185 : : QUEUE_INDIRECT_ACTION_QU_MODE,
186 : :
187 : : /* Push arguments. */
188 : : PUSH_QUEUE,
189 : :
190 : : /* Pull arguments. */
191 : : PULL_QUEUE,
192 : :
193 : : /* Table arguments. */
194 : : TABLE_CREATE,
195 : : TABLE_DESTROY,
196 : : TABLE_RESIZE,
197 : : TABLE_RESIZE_COMPLETE,
198 : : TABLE_CREATE_ID,
199 : : TABLE_DESTROY_ID,
200 : : TABLE_RESIZE_ID,
201 : : TABLE_RESIZE_RULES_NUMBER,
202 : : TABLE_INSERTION_TYPE,
203 : : TABLE_INSERTION_TYPE_NAME,
204 : : TABLE_HASH_FUNC,
205 : : TABLE_HASH_FUNC_NAME,
206 : : TABLE_GROUP,
207 : : TABLE_PRIORITY,
208 : : TABLE_INGRESS,
209 : : TABLE_EGRESS,
210 : : TABLE_TRANSFER,
211 : : TABLE_TRANSFER_WIRE_ORIG,
212 : : TABLE_TRANSFER_VPORT_ORIG,
213 : : TABLE_RESIZABLE,
214 : : TABLE_RULES_NUMBER,
215 : : TABLE_PATTERN_TEMPLATE,
216 : : TABLE_ACTIONS_TEMPLATE,
217 : :
218 : : /* Group arguments */
219 : : GROUP_ID,
220 : : GROUP_INGRESS,
221 : : GROUP_EGRESS,
222 : : GROUP_TRANSFER,
223 : : GROUP_SET_MISS_ACTIONS,
224 : :
225 : : /* Hash calculation arguments. */
226 : : HASH_CALC_TABLE,
227 : : HASH_CALC_PATTERN_INDEX,
228 : : HASH_CALC_PATTERN,
229 : : HASH_CALC_ENCAP,
230 : : HASH_CALC_DEST,
231 : : ENCAP_HASH_FIELD_SRC_PORT,
232 : : ENCAP_HASH_FIELD_GRE_FLOW_ID,
233 : :
234 : : /* Tunnel arguments. */
235 : : TUNNEL_CREATE,
236 : : TUNNEL_CREATE_TYPE,
237 : : TUNNEL_LIST,
238 : : TUNNEL_DESTROY,
239 : : TUNNEL_DESTROY_ID,
240 : :
241 : : /* Destroy arguments. */
242 : : DESTROY_RULE,
243 : : DESTROY_IS_USER_ID,
244 : :
245 : : /* Query arguments. */
246 : : QUERY_ACTION,
247 : : QUERY_IS_USER_ID,
248 : :
249 : : /* List arguments. */
250 : : LIST_GROUP,
251 : :
252 : : /* Destroy aged flow arguments. */
253 : : AGED_DESTROY,
254 : :
255 : : /* Validate/create arguments. */
256 : : VC_GROUP,
257 : : VC_PRIORITY,
258 : : VC_INGRESS,
259 : : VC_EGRESS,
260 : : VC_TRANSFER,
261 : : VC_TUNNEL_SET,
262 : : VC_TUNNEL_MATCH,
263 : : VC_USER_ID,
264 : : VC_IS_USER_ID,
265 : :
266 : : /* Dump arguments */
267 : : DUMP_ALL,
268 : : DUMP_ONE,
269 : : DUMP_IS_USER_ID,
270 : :
271 : : /* Configure arguments */
272 : : CONFIG_QUEUES_NUMBER,
273 : : CONFIG_QUEUES_SIZE,
274 : : CONFIG_COUNTERS_NUMBER,
275 : : CONFIG_AGING_OBJECTS_NUMBER,
276 : : CONFIG_METERS_NUMBER,
277 : : CONFIG_CONN_TRACK_NUMBER,
278 : : CONFIG_QUOTAS_NUMBER,
279 : : CONFIG_FLAGS,
280 : : CONFIG_HOST_PORT,
281 : :
282 : : /* Indirect action arguments */
283 : : INDIRECT_ACTION_CREATE,
284 : : INDIRECT_ACTION_LIST_CREATE,
285 : : INDIRECT_ACTION_FLOW_CONF_CREATE,
286 : : INDIRECT_ACTION_UPDATE,
287 : : INDIRECT_ACTION_DESTROY,
288 : : INDIRECT_ACTION_QUERY,
289 : : INDIRECT_ACTION_QUERY_UPDATE,
290 : :
291 : : /* Indirect action create arguments */
292 : : INDIRECT_ACTION_CREATE_ID,
293 : : INDIRECT_ACTION_INGRESS,
294 : : INDIRECT_ACTION_EGRESS,
295 : : INDIRECT_ACTION_TRANSFER,
296 : : INDIRECT_ACTION_SPEC,
297 : : INDIRECT_ACTION_LIST,
298 : : INDIRECT_ACTION_FLOW_CONF,
299 : :
300 : : /* Indirect action destroy arguments */
301 : : INDIRECT_ACTION_DESTROY_ID,
302 : :
303 : : /* Indirect action query-and-update arguments */
304 : : INDIRECT_ACTION_QU_MODE,
305 : : INDIRECT_ACTION_QU_MODE_NAME,
306 : :
307 : : /* Validate/create pattern. */
308 : : ITEM_PATTERN,
309 : : ITEM_PARAM_IS,
310 : : ITEM_PARAM_SPEC,
311 : : ITEM_PARAM_LAST,
312 : : ITEM_PARAM_MASK,
313 : : ITEM_PARAM_PREFIX,
314 : : ITEM_NEXT,
315 : : ITEM_END,
316 : : ITEM_VOID,
317 : : ITEM_INVERT,
318 : : ITEM_ANY,
319 : : ITEM_ANY_NUM,
320 : : ITEM_PORT_ID,
321 : : ITEM_PORT_ID_ID,
322 : : ITEM_MARK,
323 : : ITEM_MARK_ID,
324 : : ITEM_RAW,
325 : : ITEM_RAW_RELATIVE,
326 : : ITEM_RAW_SEARCH,
327 : : ITEM_RAW_OFFSET,
328 : : ITEM_RAW_LIMIT,
329 : : ITEM_RAW_PATTERN,
330 : : ITEM_RAW_PATTERN_HEX,
331 : : ITEM_ETH,
332 : : ITEM_ETH_DST,
333 : : ITEM_ETH_SRC,
334 : : ITEM_ETH_TYPE,
335 : : ITEM_ETH_HAS_VLAN,
336 : : ITEM_VLAN,
337 : : ITEM_VLAN_TCI,
338 : : ITEM_VLAN_PCP,
339 : : ITEM_VLAN_DEI,
340 : : ITEM_VLAN_VID,
341 : : ITEM_VLAN_INNER_TYPE,
342 : : ITEM_VLAN_HAS_MORE_VLAN,
343 : : ITEM_IPV4,
344 : : ITEM_IPV4_VER_IHL,
345 : : ITEM_IPV4_TOS,
346 : : ITEM_IPV4_LENGTH,
347 : : ITEM_IPV4_ID,
348 : : ITEM_IPV4_FRAGMENT_OFFSET,
349 : : ITEM_IPV4_TTL,
350 : : ITEM_IPV4_PROTO,
351 : : ITEM_IPV4_SRC,
352 : : ITEM_IPV4_DST,
353 : : ITEM_IPV6,
354 : : ITEM_IPV6_TC,
355 : : ITEM_IPV6_FLOW,
356 : : ITEM_IPV6_LEN,
357 : : ITEM_IPV6_PROTO,
358 : : ITEM_IPV6_HOP,
359 : : ITEM_IPV6_SRC,
360 : : ITEM_IPV6_DST,
361 : : ITEM_IPV6_HAS_FRAG_EXT,
362 : : ITEM_IPV6_ROUTING_EXT,
363 : : ITEM_IPV6_ROUTING_EXT_TYPE,
364 : : ITEM_IPV6_ROUTING_EXT_NEXT_HDR,
365 : : ITEM_IPV6_ROUTING_EXT_SEG_LEFT,
366 : : ITEM_ICMP,
367 : : ITEM_ICMP_TYPE,
368 : : ITEM_ICMP_CODE,
369 : : ITEM_ICMP_IDENT,
370 : : ITEM_ICMP_SEQ,
371 : : ITEM_UDP,
372 : : ITEM_UDP_SRC,
373 : : ITEM_UDP_DST,
374 : : ITEM_TCP,
375 : : ITEM_TCP_SRC,
376 : : ITEM_TCP_DST,
377 : : ITEM_TCP_FLAGS,
378 : : ITEM_SCTP,
379 : : ITEM_SCTP_SRC,
380 : : ITEM_SCTP_DST,
381 : : ITEM_SCTP_TAG,
382 : : ITEM_SCTP_CKSUM,
383 : : ITEM_VXLAN,
384 : : ITEM_VXLAN_VNI,
385 : : ITEM_VXLAN_FLAG_G,
386 : : ITEM_VXLAN_FLAG_VER,
387 : : ITEM_VXLAN_FLAG_I,
388 : : ITEM_VXLAN_FLAG_P,
389 : : ITEM_VXLAN_FLAG_B,
390 : : ITEM_VXLAN_FLAG_O,
391 : : ITEM_VXLAN_FLAG_D,
392 : : ITEM_VXLAN_FLAG_A,
393 : : ITEM_VXLAN_GBP_ID,
394 : : /* Used for "struct rte_vxlan_hdr", GPE Next protocol */
395 : : ITEM_VXLAN_GPE_PROTO,
396 : : ITEM_VXLAN_FIRST_RSVD,
397 : : ITEM_VXLAN_SECND_RSVD,
398 : : ITEM_VXLAN_THIRD_RSVD,
399 : : ITEM_VXLAN_LAST_RSVD,
400 : : ITEM_E_TAG,
401 : : ITEM_E_TAG_GRP_ECID_B,
402 : : ITEM_NVGRE,
403 : : ITEM_NVGRE_TNI,
404 : : ITEM_MPLS,
405 : : ITEM_MPLS_LABEL,
406 : : ITEM_MPLS_TC,
407 : : ITEM_MPLS_S,
408 : : ITEM_MPLS_TTL,
409 : : ITEM_GRE,
410 : : ITEM_GRE_PROTO,
411 : : ITEM_GRE_C_RSVD0_VER,
412 : : ITEM_GRE_C_BIT,
413 : : ITEM_GRE_K_BIT,
414 : : ITEM_GRE_S_BIT,
415 : : ITEM_FUZZY,
416 : : ITEM_FUZZY_THRESH,
417 : : ITEM_GTP,
418 : : ITEM_GTP_FLAGS,
419 : : ITEM_GTP_MSG_TYPE,
420 : : ITEM_GTP_TEID,
421 : : ITEM_GTPC,
422 : : ITEM_GTPU,
423 : : ITEM_GENEVE,
424 : : ITEM_GENEVE_VNI,
425 : : ITEM_GENEVE_PROTO,
426 : : ITEM_GENEVE_OPTLEN,
427 : : ITEM_VXLAN_GPE,
428 : : ITEM_VXLAN_GPE_VNI,
429 : : /* Used for "struct rte_vxlan_gpe_hdr", deprecated, prefer ITEM_VXLAN_GPE_PROTO */
430 : : ITEM_VXLAN_GPE_PROTO_IN_DEPRECATED_VXLAN_GPE_HDR,
431 : : ITEM_VXLAN_GPE_FLAGS,
432 : : ITEM_VXLAN_GPE_RSVD0,
433 : : ITEM_VXLAN_GPE_RSVD1,
434 : : ITEM_ARP_ETH_IPV4,
435 : : ITEM_ARP_ETH_IPV4_SHA,
436 : : ITEM_ARP_ETH_IPV4_SPA,
437 : : ITEM_ARP_ETH_IPV4_THA,
438 : : ITEM_ARP_ETH_IPV4_TPA,
439 : : ITEM_IPV6_EXT,
440 : : ITEM_IPV6_EXT_NEXT_HDR,
441 : : ITEM_IPV6_FRAG_EXT,
442 : : ITEM_IPV6_FRAG_EXT_NEXT_HDR,
443 : : ITEM_IPV6_FRAG_EXT_FRAG_DATA,
444 : : ITEM_IPV6_FRAG_EXT_ID,
445 : : ITEM_ICMP6,
446 : : ITEM_ICMP6_TYPE,
447 : : ITEM_ICMP6_CODE,
448 : : ITEM_ICMP6_ECHO_REQUEST,
449 : : ITEM_ICMP6_ECHO_REQUEST_ID,
450 : : ITEM_ICMP6_ECHO_REQUEST_SEQ,
451 : : ITEM_ICMP6_ECHO_REPLY,
452 : : ITEM_ICMP6_ECHO_REPLY_ID,
453 : : ITEM_ICMP6_ECHO_REPLY_SEQ,
454 : : ITEM_ICMP6_ND_NS,
455 : : ITEM_ICMP6_ND_NS_TARGET_ADDR,
456 : : ITEM_ICMP6_ND_NA,
457 : : ITEM_ICMP6_ND_NA_TARGET_ADDR,
458 : : ITEM_ICMP6_ND_OPT,
459 : : ITEM_ICMP6_ND_OPT_TYPE,
460 : : ITEM_ICMP6_ND_OPT_SLA_ETH,
461 : : ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
462 : : ITEM_ICMP6_ND_OPT_TLA_ETH,
463 : : ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
464 : : ITEM_META,
465 : : ITEM_META_DATA,
466 : : ITEM_RANDOM,
467 : : ITEM_RANDOM_VALUE,
468 : : ITEM_GRE_KEY,
469 : : ITEM_GRE_KEY_VALUE,
470 : : ITEM_GRE_OPTION,
471 : : ITEM_GRE_OPTION_CHECKSUM,
472 : : ITEM_GRE_OPTION_KEY,
473 : : ITEM_GRE_OPTION_SEQUENCE,
474 : : ITEM_GTP_PSC,
475 : : ITEM_GTP_PSC_QFI,
476 : : ITEM_GTP_PSC_PDU_T,
477 : : ITEM_PPPOES,
478 : : ITEM_PPPOED,
479 : : ITEM_PPPOE_SEID,
480 : : ITEM_PPPOE_PROTO_ID,
481 : : ITEM_HIGIG2,
482 : : ITEM_HIGIG2_CLASSIFICATION,
483 : : ITEM_HIGIG2_VID,
484 : : ITEM_TAG,
485 : : ITEM_TAG_DATA,
486 : : ITEM_TAG_INDEX,
487 : : ITEM_L2TPV3OIP,
488 : : ITEM_L2TPV3OIP_SESSION_ID,
489 : : ITEM_ESP,
490 : : ITEM_ESP_SPI,
491 : : ITEM_AH,
492 : : ITEM_AH_SPI,
493 : : ITEM_PFCP,
494 : : ITEM_PFCP_S_FIELD,
495 : : ITEM_PFCP_SEID,
496 : : ITEM_ECPRI,
497 : : ITEM_ECPRI_COMMON,
498 : : ITEM_ECPRI_COMMON_TYPE,
499 : : ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
500 : : ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
501 : : ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
502 : : ITEM_ECPRI_MSG_IQ_DATA_PCID,
503 : : ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
504 : : ITEM_ECPRI_MSG_DLY_MSR_MSRID,
505 : : ITEM_GENEVE_OPT,
506 : : ITEM_GENEVE_OPT_CLASS,
507 : : ITEM_GENEVE_OPT_TYPE,
508 : : ITEM_GENEVE_OPT_LENGTH,
509 : : ITEM_GENEVE_OPT_DATA,
510 : : ITEM_INTEGRITY,
511 : : ITEM_INTEGRITY_LEVEL,
512 : : ITEM_INTEGRITY_VALUE,
513 : : ITEM_CONNTRACK,
514 : : ITEM_POL_PORT,
515 : : ITEM_POL_METER,
516 : : ITEM_POL_POLICY,
517 : : ITEM_PORT_REPRESENTOR,
518 : : ITEM_PORT_REPRESENTOR_PORT_ID,
519 : : ITEM_REPRESENTED_PORT,
520 : : ITEM_REPRESENTED_PORT_ETHDEV_PORT_ID,
521 : : ITEM_FLEX,
522 : : ITEM_FLEX_ITEM_HANDLE,
523 : : ITEM_FLEX_PATTERN_HANDLE,
524 : : ITEM_L2TPV2,
525 : : ITEM_L2TPV2_TYPE,
526 : : ITEM_L2TPV2_TYPE_DATA,
527 : : ITEM_L2TPV2_TYPE_DATA_L,
528 : : ITEM_L2TPV2_TYPE_DATA_S,
529 : : ITEM_L2TPV2_TYPE_DATA_O,
530 : : ITEM_L2TPV2_TYPE_DATA_L_S,
531 : : ITEM_L2TPV2_TYPE_CTRL,
532 : : ITEM_L2TPV2_MSG_DATA_TUNNEL_ID,
533 : : ITEM_L2TPV2_MSG_DATA_SESSION_ID,
534 : : ITEM_L2TPV2_MSG_DATA_L_LENGTH,
535 : : ITEM_L2TPV2_MSG_DATA_L_TUNNEL_ID,
536 : : ITEM_L2TPV2_MSG_DATA_L_SESSION_ID,
537 : : ITEM_L2TPV2_MSG_DATA_S_TUNNEL_ID,
538 : : ITEM_L2TPV2_MSG_DATA_S_SESSION_ID,
539 : : ITEM_L2TPV2_MSG_DATA_S_NS,
540 : : ITEM_L2TPV2_MSG_DATA_S_NR,
541 : : ITEM_L2TPV2_MSG_DATA_O_TUNNEL_ID,
542 : : ITEM_L2TPV2_MSG_DATA_O_SESSION_ID,
543 : : ITEM_L2TPV2_MSG_DATA_O_OFFSET,
544 : : ITEM_L2TPV2_MSG_DATA_L_S_LENGTH,
545 : : ITEM_L2TPV2_MSG_DATA_L_S_TUNNEL_ID,
546 : : ITEM_L2TPV2_MSG_DATA_L_S_SESSION_ID,
547 : : ITEM_L2TPV2_MSG_DATA_L_S_NS,
548 : : ITEM_L2TPV2_MSG_DATA_L_S_NR,
549 : : ITEM_L2TPV2_MSG_CTRL_LENGTH,
550 : : ITEM_L2TPV2_MSG_CTRL_TUNNEL_ID,
551 : : ITEM_L2TPV2_MSG_CTRL_SESSION_ID,
552 : : ITEM_L2TPV2_MSG_CTRL_NS,
553 : : ITEM_L2TPV2_MSG_CTRL_NR,
554 : : ITEM_PPP,
555 : : ITEM_PPP_ADDR,
556 : : ITEM_PPP_CTRL,
557 : : ITEM_PPP_PROTO_ID,
558 : : ITEM_METER,
559 : : ITEM_METER_COLOR,
560 : : ITEM_QUOTA,
561 : : ITEM_QUOTA_STATE,
562 : : ITEM_QUOTA_STATE_NAME,
563 : : ITEM_AGGR_AFFINITY,
564 : : ITEM_AGGR_AFFINITY_VALUE,
565 : : ITEM_TX_QUEUE,
566 : : ITEM_TX_QUEUE_VALUE,
567 : : ITEM_IB_BTH,
568 : : ITEM_IB_BTH_OPCODE,
569 : : ITEM_IB_BTH_PKEY,
570 : : ITEM_IB_BTH_DST_QPN,
571 : : ITEM_IB_BTH_PSN,
572 : : ITEM_IPV6_PUSH_REMOVE_EXT,
573 : : ITEM_IPV6_PUSH_REMOVE_EXT_TYPE,
574 : : ITEM_PTYPE,
575 : : ITEM_PTYPE_VALUE,
576 : : ITEM_NSH,
577 : : ITEM_COMPARE,
578 : : ITEM_COMPARE_OP,
579 : : ITEM_COMPARE_OP_VALUE,
580 : : ITEM_COMPARE_FIELD_A_TYPE,
581 : : ITEM_COMPARE_FIELD_A_TYPE_VALUE,
582 : : ITEM_COMPARE_FIELD_A_LEVEL,
583 : : ITEM_COMPARE_FIELD_A_LEVEL_VALUE,
584 : : ITEM_COMPARE_FIELD_A_TAG_INDEX,
585 : : ITEM_COMPARE_FIELD_A_TYPE_ID,
586 : : ITEM_COMPARE_FIELD_A_CLASS_ID,
587 : : ITEM_COMPARE_FIELD_A_OFFSET,
588 : : ITEM_COMPARE_FIELD_B_TYPE,
589 : : ITEM_COMPARE_FIELD_B_TYPE_VALUE,
590 : : ITEM_COMPARE_FIELD_B_LEVEL,
591 : : ITEM_COMPARE_FIELD_B_LEVEL_VALUE,
592 : : ITEM_COMPARE_FIELD_B_TAG_INDEX,
593 : : ITEM_COMPARE_FIELD_B_TYPE_ID,
594 : : ITEM_COMPARE_FIELD_B_CLASS_ID,
595 : : ITEM_COMPARE_FIELD_B_OFFSET,
596 : : ITEM_COMPARE_FIELD_B_VALUE,
597 : : ITEM_COMPARE_FIELD_B_POINTER,
598 : : ITEM_COMPARE_FIELD_WIDTH,
599 : :
600 : : /* Validate/create actions. */
601 : : ACTIONS,
602 : : ACTION_NEXT,
603 : : ACTION_END,
604 : : ACTION_VOID,
605 : : ACTION_PASSTHRU,
606 : : ACTION_SKIP_CMAN,
607 : : ACTION_JUMP,
608 : : ACTION_JUMP_GROUP,
609 : : ACTION_MARK,
610 : : ACTION_MARK_ID,
611 : : ACTION_FLAG,
612 : : ACTION_QUEUE,
613 : : ACTION_QUEUE_INDEX,
614 : : ACTION_DROP,
615 : : ACTION_COUNT,
616 : : ACTION_COUNT_ID,
617 : : ACTION_RSS,
618 : : ACTION_RSS_FUNC,
619 : : ACTION_RSS_LEVEL,
620 : : ACTION_RSS_FUNC_DEFAULT,
621 : : ACTION_RSS_FUNC_TOEPLITZ,
622 : : ACTION_RSS_FUNC_SIMPLE_XOR,
623 : : ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ,
624 : : ACTION_RSS_TYPES,
625 : : ACTION_RSS_TYPE,
626 : : ACTION_RSS_KEY,
627 : : ACTION_RSS_KEY_LEN,
628 : : ACTION_RSS_QUEUES,
629 : : ACTION_RSS_QUEUE,
630 : : ACTION_PF,
631 : : ACTION_VF,
632 : : ACTION_VF_ORIGINAL,
633 : : ACTION_VF_ID,
634 : : ACTION_PORT_ID,
635 : : ACTION_PORT_ID_ORIGINAL,
636 : : ACTION_PORT_ID_ID,
637 : : ACTION_METER,
638 : : ACTION_METER_COLOR,
639 : : ACTION_METER_COLOR_TYPE,
640 : : ACTION_METER_COLOR_GREEN,
641 : : ACTION_METER_COLOR_YELLOW,
642 : : ACTION_METER_COLOR_RED,
643 : : ACTION_METER_ID,
644 : : ACTION_METER_MARK,
645 : : ACTION_METER_MARK_CONF,
646 : : ACTION_METER_MARK_CONF_COLOR,
647 : : ACTION_METER_PROFILE,
648 : : ACTION_METER_PROFILE_ID2PTR,
649 : : ACTION_METER_POLICY,
650 : : ACTION_METER_POLICY_ID2PTR,
651 : : ACTION_METER_COLOR_MODE,
652 : : ACTION_METER_STATE,
653 : : ACTION_OF_DEC_NW_TTL,
654 : : ACTION_OF_POP_VLAN,
655 : : ACTION_OF_PUSH_VLAN,
656 : : ACTION_OF_PUSH_VLAN_ETHERTYPE,
657 : : ACTION_OF_SET_VLAN_VID,
658 : : ACTION_OF_SET_VLAN_VID_VLAN_VID,
659 : : ACTION_OF_SET_VLAN_PCP,
660 : : ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
661 : : ACTION_OF_POP_MPLS,
662 : : ACTION_OF_POP_MPLS_ETHERTYPE,
663 : : ACTION_OF_PUSH_MPLS,
664 : : ACTION_OF_PUSH_MPLS_ETHERTYPE,
665 : : ACTION_VXLAN_ENCAP,
666 : : ACTION_VXLAN_DECAP,
667 : : ACTION_NVGRE_ENCAP,
668 : : ACTION_NVGRE_DECAP,
669 : : ACTION_L2_ENCAP,
670 : : ACTION_L2_DECAP,
671 : : ACTION_MPLSOGRE_ENCAP,
672 : : ACTION_MPLSOGRE_DECAP,
673 : : ACTION_MPLSOUDP_ENCAP,
674 : : ACTION_MPLSOUDP_DECAP,
675 : : ACTION_SET_IPV4_SRC,
676 : : ACTION_SET_IPV4_SRC_IPV4_SRC,
677 : : ACTION_SET_IPV4_DST,
678 : : ACTION_SET_IPV4_DST_IPV4_DST,
679 : : ACTION_SET_IPV6_SRC,
680 : : ACTION_SET_IPV6_SRC_IPV6_SRC,
681 : : ACTION_SET_IPV6_DST,
682 : : ACTION_SET_IPV6_DST_IPV6_DST,
683 : : ACTION_SET_TP_SRC,
684 : : ACTION_SET_TP_SRC_TP_SRC,
685 : : ACTION_SET_TP_DST,
686 : : ACTION_SET_TP_DST_TP_DST,
687 : : ACTION_MAC_SWAP,
688 : : ACTION_DEC_TTL,
689 : : ACTION_SET_TTL,
690 : : ACTION_SET_TTL_TTL,
691 : : ACTION_SET_MAC_SRC,
692 : : ACTION_SET_MAC_SRC_MAC_SRC,
693 : : ACTION_SET_MAC_DST,
694 : : ACTION_SET_MAC_DST_MAC_DST,
695 : : ACTION_INC_TCP_SEQ,
696 : : ACTION_INC_TCP_SEQ_VALUE,
697 : : ACTION_DEC_TCP_SEQ,
698 : : ACTION_DEC_TCP_SEQ_VALUE,
699 : : ACTION_INC_TCP_ACK,
700 : : ACTION_INC_TCP_ACK_VALUE,
701 : : ACTION_DEC_TCP_ACK,
702 : : ACTION_DEC_TCP_ACK_VALUE,
703 : : ACTION_RAW_ENCAP,
704 : : ACTION_RAW_DECAP,
705 : : ACTION_RAW_ENCAP_SIZE,
706 : : ACTION_RAW_ENCAP_INDEX,
707 : : ACTION_RAW_ENCAP_INDEX_VALUE,
708 : : ACTION_RAW_DECAP_INDEX,
709 : : ACTION_RAW_DECAP_INDEX_VALUE,
710 : : ACTION_SET_TAG,
711 : : ACTION_SET_TAG_DATA,
712 : : ACTION_SET_TAG_INDEX,
713 : : ACTION_SET_TAG_MASK,
714 : : ACTION_SET_META,
715 : : ACTION_SET_META_DATA,
716 : : ACTION_SET_META_MASK,
717 : : ACTION_SET_IPV4_DSCP,
718 : : ACTION_SET_IPV4_DSCP_VALUE,
719 : : ACTION_SET_IPV6_DSCP,
720 : : ACTION_SET_IPV6_DSCP_VALUE,
721 : : ACTION_AGE,
722 : : ACTION_AGE_TIMEOUT,
723 : : ACTION_AGE_UPDATE,
724 : : ACTION_AGE_UPDATE_TIMEOUT,
725 : : ACTION_AGE_UPDATE_TOUCH,
726 : : ACTION_SAMPLE,
727 : : ACTION_SAMPLE_RATIO,
728 : : ACTION_SAMPLE_INDEX,
729 : : ACTION_SAMPLE_INDEX_VALUE,
730 : : ACTION_INDIRECT,
731 : : ACTION_INDIRECT_LIST,
732 : : ACTION_INDIRECT_LIST_HANDLE,
733 : : ACTION_INDIRECT_LIST_CONF,
734 : : INDIRECT_LIST_ACTION_ID2PTR_HANDLE,
735 : : INDIRECT_LIST_ACTION_ID2PTR_CONF,
736 : : ACTION_SHARED_INDIRECT,
737 : : INDIRECT_ACTION_PORT,
738 : : INDIRECT_ACTION_ID2PTR,
739 : : ACTION_MODIFY_FIELD,
740 : : ACTION_MODIFY_FIELD_OP,
741 : : ACTION_MODIFY_FIELD_OP_VALUE,
742 : : ACTION_MODIFY_FIELD_DST_TYPE,
743 : : ACTION_MODIFY_FIELD_DST_TYPE_VALUE,
744 : : ACTION_MODIFY_FIELD_DST_LEVEL,
745 : : ACTION_MODIFY_FIELD_DST_LEVEL_VALUE,
746 : : ACTION_MODIFY_FIELD_DST_TAG_INDEX,
747 : : ACTION_MODIFY_FIELD_DST_TYPE_ID,
748 : : ACTION_MODIFY_FIELD_DST_CLASS_ID,
749 : : ACTION_MODIFY_FIELD_DST_OFFSET,
750 : : ACTION_MODIFY_FIELD_SRC_TYPE,
751 : : ACTION_MODIFY_FIELD_SRC_TYPE_VALUE,
752 : : ACTION_MODIFY_FIELD_SRC_LEVEL,
753 : : ACTION_MODIFY_FIELD_SRC_LEVEL_VALUE,
754 : : ACTION_MODIFY_FIELD_SRC_TAG_INDEX,
755 : : ACTION_MODIFY_FIELD_SRC_TYPE_ID,
756 : : ACTION_MODIFY_FIELD_SRC_CLASS_ID,
757 : : ACTION_MODIFY_FIELD_SRC_OFFSET,
758 : : ACTION_MODIFY_FIELD_SRC_VALUE,
759 : : ACTION_MODIFY_FIELD_SRC_POINTER,
760 : : ACTION_MODIFY_FIELD_WIDTH,
761 : : ACTION_CONNTRACK,
762 : : ACTION_CONNTRACK_UPDATE,
763 : : ACTION_CONNTRACK_UPDATE_DIR,
764 : : ACTION_CONNTRACK_UPDATE_CTX,
765 : : ACTION_POL_G,
766 : : ACTION_POL_Y,
767 : : ACTION_POL_R,
768 : : ACTION_PORT_REPRESENTOR,
769 : : ACTION_PORT_REPRESENTOR_PORT_ID,
770 : : ACTION_REPRESENTED_PORT,
771 : : ACTION_REPRESENTED_PORT_ETHDEV_PORT_ID,
772 : : ACTION_SEND_TO_KERNEL,
773 : : ACTION_QUOTA_CREATE,
774 : : ACTION_QUOTA_CREATE_LIMIT,
775 : : ACTION_QUOTA_CREATE_MODE,
776 : : ACTION_QUOTA_CREATE_MODE_NAME,
777 : : ACTION_QUOTA_QU,
778 : : ACTION_QUOTA_QU_LIMIT,
779 : : ACTION_QUOTA_QU_UPDATE_OP,
780 : : ACTION_QUOTA_QU_UPDATE_OP_NAME,
781 : : ACTION_IPV6_EXT_REMOVE,
782 : : ACTION_IPV6_EXT_REMOVE_INDEX,
783 : : ACTION_IPV6_EXT_REMOVE_INDEX_VALUE,
784 : : ACTION_IPV6_EXT_PUSH,
785 : : ACTION_IPV6_EXT_PUSH_INDEX,
786 : : ACTION_IPV6_EXT_PUSH_INDEX_VALUE,
787 : : ACTION_NAT64,
788 : : ACTION_NAT64_MODE,
789 : : ACTION_JUMP_TO_TABLE_INDEX,
790 : : ACTION_JUMP_TO_TABLE_INDEX_TABLE,
791 : : ACTION_JUMP_TO_TABLE_INDEX_INDEX,
792 : : };
793 : :
794 : : /** Maximum size for pattern in struct rte_flow_item_raw. */
795 : : #define ITEM_RAW_PATTERN_SIZE 512
796 : :
797 : : /** Maximum size for GENEVE option data pattern in bytes. */
798 : : #define ITEM_GENEVE_OPT_DATA_SIZE 124
799 : :
800 : : /** Storage size for struct rte_flow_item_raw including pattern. */
801 : : #define ITEM_RAW_SIZE \
802 : : (sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE)
803 : :
804 : : static const char *const compare_ops[] = {
805 : : "eq", "ne", "lt", "le", "gt", "ge", NULL
806 : : };
807 : :
808 : : /** Maximum size for external pattern in struct rte_flow_field_data. */
809 : : #define FLOW_FIELD_PATTERN_SIZE 32
810 : :
811 : : /** Storage size for struct rte_flow_action_modify_field including pattern. */
812 : : #define ACTION_MODIFY_SIZE \
813 : : (sizeof(struct rte_flow_action_modify_field) + \
814 : : FLOW_FIELD_PATTERN_SIZE)
815 : :
816 : : /** Maximum number of queue indices in struct rte_flow_action_rss. */
817 : : #define ACTION_RSS_QUEUE_NUM 128
818 : :
819 : : /** Storage for struct rte_flow_action_rss including external data. */
820 : : struct action_rss_data {
821 : : struct rte_flow_action_rss conf;
822 : : uint8_t key[RSS_HASH_KEY_LENGTH];
823 : : uint16_t queue[ACTION_RSS_QUEUE_NUM];
824 : : };
825 : :
826 : : /** Maximum data size in struct rte_flow_action_raw_encap. */
827 : : #define ACTION_RAW_ENCAP_MAX_DATA 512
828 : : #define RAW_ENCAP_CONFS_MAX_NUM 8
829 : :
830 : : /** Storage for struct rte_flow_action_raw_encap. */
831 : : struct raw_encap_conf {
832 : : uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
833 : : uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
834 : : size_t size;
835 : : };
836 : :
837 : : struct raw_encap_conf raw_encap_confs[RAW_ENCAP_CONFS_MAX_NUM];
838 : :
839 : : /** Storage for struct rte_flow_action_raw_encap including external data. */
840 : : struct action_raw_encap_data {
841 : : struct rte_flow_action_raw_encap conf;
842 : : uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
843 : : uint8_t preserve[ACTION_RAW_ENCAP_MAX_DATA];
844 : : uint16_t idx;
845 : : };
846 : :
847 : : /** Storage for struct rte_flow_action_raw_decap. */
848 : : struct raw_decap_conf {
849 : : uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
850 : : size_t size;
851 : : };
852 : :
853 : : struct raw_decap_conf raw_decap_confs[RAW_ENCAP_CONFS_MAX_NUM];
854 : :
855 : : /** Storage for struct rte_flow_action_raw_decap including external data. */
856 : : struct action_raw_decap_data {
857 : : struct rte_flow_action_raw_decap conf;
858 : : uint8_t data[ACTION_RAW_ENCAP_MAX_DATA];
859 : : uint16_t idx;
860 : : };
861 : :
862 : : /** Maximum data size in struct rte_flow_action_ipv6_ext_push. */
863 : : #define ACTION_IPV6_EXT_PUSH_MAX_DATA 512
864 : : #define IPV6_EXT_PUSH_CONFS_MAX_NUM 8
865 : :
866 : : /** Storage for struct rte_flow_action_ipv6_ext_push. */
867 : : struct ipv6_ext_push_conf {
868 : : uint8_t data[ACTION_IPV6_EXT_PUSH_MAX_DATA];
869 : : size_t size;
870 : : uint8_t type;
871 : : };
872 : :
873 : : struct ipv6_ext_push_conf ipv6_ext_push_confs[IPV6_EXT_PUSH_CONFS_MAX_NUM];
874 : :
875 : : /** Storage for struct rte_flow_action_ipv6_ext_push including external data. */
876 : : struct action_ipv6_ext_push_data {
877 : : struct rte_flow_action_ipv6_ext_push conf;
878 : : uint8_t data[ACTION_IPV6_EXT_PUSH_MAX_DATA];
879 : : uint8_t type;
880 : : uint16_t idx;
881 : : };
882 : :
883 : : /** Storage for struct rte_flow_action_ipv6_ext_remove. */
884 : : struct ipv6_ext_remove_conf {
885 : : struct rte_flow_action_ipv6_ext_remove conf;
886 : : uint8_t type;
887 : : };
888 : :
889 : : struct ipv6_ext_remove_conf ipv6_ext_remove_confs[IPV6_EXT_PUSH_CONFS_MAX_NUM];
890 : :
891 : : /** Storage for struct rte_flow_action_ipv6_ext_remove including external data. */
892 : : struct action_ipv6_ext_remove_data {
893 : : struct rte_flow_action_ipv6_ext_remove conf;
894 : : uint8_t type;
895 : : uint16_t idx;
896 : : };
897 : :
898 : : struct vxlan_encap_conf vxlan_encap_conf = {
899 : : .select_ipv4 = 1,
900 : : .select_vlan = 0,
901 : : .select_tos_ttl = 0,
902 : : .vni = { 0x00, 0x00, 0x00 },
903 : : .udp_src = 0,
904 : : .udp_dst = RTE_BE16(RTE_VXLAN_DEFAULT_PORT),
905 : : .ipv4_src = RTE_IPV4(127, 0, 0, 1),
906 : : .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
907 : : .ipv6_src = RTE_IPV6_ADDR_LOOPBACK,
908 : : .ipv6_dst = RTE_IPV6(0, 0, 0, 0, 0, 0, 0, 0x1111),
909 : : .vlan_tci = 0,
910 : : .ip_tos = 0,
911 : : .ip_ttl = 255,
912 : : .eth_src = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
913 : : .eth_dst = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
914 : : };
915 : :
916 : : /** Maximum number of items in struct rte_flow_action_vxlan_encap. */
917 : : #define ACTION_VXLAN_ENCAP_ITEMS_NUM 6
918 : :
919 : : /** Storage for struct rte_flow_action_vxlan_encap including external data. */
920 : : struct action_vxlan_encap_data {
921 : : struct rte_flow_action_vxlan_encap conf;
922 : : struct rte_flow_item items[ACTION_VXLAN_ENCAP_ITEMS_NUM];
923 : : struct rte_flow_item_eth item_eth;
924 : : struct rte_flow_item_vlan item_vlan;
925 : : union {
926 : : struct rte_flow_item_ipv4 item_ipv4;
927 : : struct rte_flow_item_ipv6 item_ipv6;
928 : : };
929 : : struct rte_flow_item_udp item_udp;
930 : : struct rte_flow_item_vxlan item_vxlan;
931 : : };
932 : :
933 : : struct nvgre_encap_conf nvgre_encap_conf = {
934 : : .select_ipv4 = 1,
935 : : .select_vlan = 0,
936 : : .tni = { 0x00, 0x00, 0x00 },
937 : : .ipv4_src = RTE_IPV4(127, 0, 0, 1),
938 : : .ipv4_dst = RTE_IPV4(255, 255, 255, 255),
939 : : .ipv6_src = RTE_IPV6_ADDR_LOOPBACK,
940 : : .ipv6_dst = RTE_IPV6(0, 0, 0, 0, 0, 0, 0, 0x1111),
941 : : .vlan_tci = 0,
942 : : .eth_src = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
943 : : .eth_dst = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
944 : : };
945 : :
946 : : /** Maximum number of items in struct rte_flow_action_nvgre_encap. */
947 : : #define ACTION_NVGRE_ENCAP_ITEMS_NUM 5
948 : :
949 : : /** Storage for struct rte_flow_action_nvgre_encap including external data. */
950 : : struct action_nvgre_encap_data {
951 : : struct rte_flow_action_nvgre_encap conf;
952 : : struct rte_flow_item items[ACTION_NVGRE_ENCAP_ITEMS_NUM];
953 : : struct rte_flow_item_eth item_eth;
954 : : struct rte_flow_item_vlan item_vlan;
955 : : union {
956 : : struct rte_flow_item_ipv4 item_ipv4;
957 : : struct rte_flow_item_ipv6 item_ipv6;
958 : : };
959 : : struct rte_flow_item_nvgre item_nvgre;
960 : : };
961 : :
962 : : struct l2_encap_conf l2_encap_conf;
963 : :
964 : : struct l2_decap_conf l2_decap_conf;
965 : :
966 : : struct mplsogre_encap_conf mplsogre_encap_conf;
967 : :
968 : : struct mplsogre_decap_conf mplsogre_decap_conf;
969 : :
970 : : struct mplsoudp_encap_conf mplsoudp_encap_conf;
971 : :
972 : : struct mplsoudp_decap_conf mplsoudp_decap_conf;
973 : :
974 : : struct rte_flow_action_conntrack conntrack_context;
975 : :
976 : : #define ACTION_SAMPLE_ACTIONS_NUM 10
977 : : #define RAW_SAMPLE_CONFS_MAX_NUM 8
978 : : /** Storage for struct rte_flow_action_sample including external data. */
979 : : struct action_sample_data {
980 : : struct rte_flow_action_sample conf;
981 : : uint32_t idx;
982 : : };
983 : : /** Storage for struct rte_flow_action_sample. */
984 : : struct raw_sample_conf {
985 : : struct rte_flow_action data[ACTION_SAMPLE_ACTIONS_NUM];
986 : : };
987 : : struct raw_sample_conf raw_sample_confs[RAW_SAMPLE_CONFS_MAX_NUM];
988 : : struct rte_flow_action_mark sample_mark[RAW_SAMPLE_CONFS_MAX_NUM];
989 : : struct rte_flow_action_queue sample_queue[RAW_SAMPLE_CONFS_MAX_NUM];
990 : : struct rte_flow_action_count sample_count[RAW_SAMPLE_CONFS_MAX_NUM];
991 : : struct rte_flow_action_port_id sample_port_id[RAW_SAMPLE_CONFS_MAX_NUM];
992 : : struct rte_flow_action_raw_encap sample_encap[RAW_SAMPLE_CONFS_MAX_NUM];
993 : : struct action_vxlan_encap_data sample_vxlan_encap[RAW_SAMPLE_CONFS_MAX_NUM];
994 : : struct action_nvgre_encap_data sample_nvgre_encap[RAW_SAMPLE_CONFS_MAX_NUM];
995 : : struct action_rss_data sample_rss_data[RAW_SAMPLE_CONFS_MAX_NUM];
996 : : struct rte_flow_action_vf sample_vf[RAW_SAMPLE_CONFS_MAX_NUM];
997 : : struct rte_flow_action_ethdev sample_port_representor[RAW_SAMPLE_CONFS_MAX_NUM];
998 : : struct rte_flow_action_ethdev sample_represented_port[RAW_SAMPLE_CONFS_MAX_NUM];
999 : :
1000 : : static const char *const modify_field_ops[] = {
1001 : : "set", "add", "sub", NULL
1002 : : };
1003 : :
1004 : : static const char *const flow_field_ids[] = {
1005 : : "start", "mac_dst", "mac_src",
1006 : : "vlan_type", "vlan_id", "mac_type",
1007 : : "ipv4_dscp", "ipv4_ttl", "ipv4_src", "ipv4_dst",
1008 : : "ipv6_dscp", "ipv6_hoplimit", "ipv6_src", "ipv6_dst",
1009 : : "tcp_port_src", "tcp_port_dst",
1010 : : "tcp_seq_num", "tcp_ack_num", "tcp_flags",
1011 : : "udp_port_src", "udp_port_dst",
1012 : : "vxlan_vni", "geneve_vni", "gtp_teid",
1013 : : "tag", "mark", "meta", "pointer", "value",
1014 : : "ipv4_ecn", "ipv6_ecn", "gtp_psc_qfi", "meter_color",
1015 : : "ipv6_proto",
1016 : : "flex_item",
1017 : : "hash_result",
1018 : : "geneve_opt_type", "geneve_opt_class", "geneve_opt_data", "mpls",
1019 : : "tcp_data_off", "ipv4_ihl", "ipv4_total_len", "ipv6_payload_len",
1020 : : "ipv4_proto",
1021 : : "ipv6_flow_label", "ipv6_traffic_class",
1022 : : "esp_spi", "esp_seq_num", "esp_proto",
1023 : : "random",
1024 : : "vxlan_last_rsvd",
1025 : : NULL
1026 : : };
1027 : :
1028 : : static const char *const meter_colors[] = {
1029 : : "green", "yellow", "red", "all", NULL
1030 : : };
1031 : :
1032 : : static const char *const table_insertion_types[] = {
1033 : : "pattern", "index", "index_with_pattern", NULL
1034 : : };
1035 : :
1036 : : static const char *const table_hash_funcs[] = {
1037 : : "default", "linear", "crc32", "crc16", NULL
1038 : : };
1039 : :
1040 : : #define RAW_IPSEC_CONFS_MAX_NUM 8
1041 : :
1042 : : /** Maximum number of subsequent tokens and arguments on the stack. */
1043 : : #define CTX_STACK_SIZE 16
1044 : :
1045 : : /** Parser context. */
1046 : : struct context {
1047 : : /** Stack of subsequent token lists to process. */
1048 : : const enum index *next[CTX_STACK_SIZE];
1049 : : /** Arguments for stacked tokens. */
1050 : : const void *args[CTX_STACK_SIZE];
1051 : : enum index curr; /**< Current token index. */
1052 : : enum index prev; /**< Index of the last token seen. */
1053 : : int next_num; /**< Number of entries in next[]. */
1054 : : int args_num; /**< Number of entries in args[]. */
1055 : : uint32_t eol:1; /**< EOL has been detected. */
1056 : : uint32_t last:1; /**< No more arguments. */
1057 : : portid_t port; /**< Current port ID (for completions). */
1058 : : uint32_t objdata; /**< Object-specific data. */
1059 : : void *object; /**< Address of current object for relative offsets. */
1060 : : void *objmask; /**< Object a full mask must be written to. */
1061 : : };
1062 : :
1063 : : /** Token argument. */
1064 : : struct arg {
1065 : : uint32_t hton:1; /**< Use network byte ordering. */
1066 : : uint32_t sign:1; /**< Value is signed. */
1067 : : uint32_t bounded:1; /**< Value is bounded. */
1068 : : uintmax_t min; /**< Minimum value if bounded. */
1069 : : uintmax_t max; /**< Maximum value if bounded. */
1070 : : uint32_t offset; /**< Relative offset from ctx->object. */
1071 : : uint32_t size; /**< Field size. */
1072 : : const uint8_t *mask; /**< Bit-mask to use instead of offset/size. */
1073 : : };
1074 : :
1075 : : /** Parser token definition. */
1076 : : struct token {
1077 : : /** Type displayed during completion (defaults to "TOKEN"). */
1078 : : const char *type;
1079 : : /** Help displayed during completion (defaults to token name). */
1080 : : const char *help;
1081 : : /** Private data used by parser functions. */
1082 : : const void *priv;
1083 : : /**
1084 : : * Lists of subsequent tokens to push on the stack. Each call to the
1085 : : * parser consumes the last entry of that stack.
1086 : : */
1087 : : const enum index *const *next;
1088 : : /** Arguments stack for subsequent tokens that need them. */
1089 : : const struct arg *const *args;
1090 : : /**
1091 : : * Token-processing callback, returns -1 in case of error, the
1092 : : * length of the matched string otherwise. If NULL, attempts to
1093 : : * match the token name.
1094 : : *
1095 : : * If buf is not NULL, the result should be stored in it according
1096 : : * to context. An error is returned if not large enough.
1097 : : */
1098 : : int (*call)(struct context *ctx, const struct token *token,
1099 : : const char *str, unsigned int len,
1100 : : void *buf, unsigned int size);
1101 : : /**
1102 : : * Callback that provides possible values for this token, used for
1103 : : * completion. Returns -1 in case of error, the number of possible
1104 : : * values otherwise. If NULL, the token name is used.
1105 : : *
1106 : : * If buf is not NULL, entry index ent is written to buf and the
1107 : : * full length of the entry is returned (same behavior as
1108 : : * snprintf()).
1109 : : */
1110 : : int (*comp)(struct context *ctx, const struct token *token,
1111 : : unsigned int ent, char *buf, unsigned int size);
1112 : : /** Mandatory token name, no default value. */
1113 : : const char *name;
1114 : : };
1115 : :
1116 : : /** Static initializer for the next field. */
1117 : : #define NEXT(...) (const enum index *const []){ __VA_ARGS__, NULL, }
1118 : :
1119 : : /** Static initializer for a NEXT() entry. */
1120 : : #define NEXT_ENTRY(...) (const enum index []){ __VA_ARGS__, ZERO, }
1121 : :
1122 : : /** Static initializer for the args field. */
1123 : : #define ARGS(...) (const struct arg *const []){ __VA_ARGS__, NULL, }
1124 : :
1125 : : /** Static initializer for ARGS() to target a field. */
1126 : : #define ARGS_ENTRY(s, f) \
1127 : : (&(const struct arg){ \
1128 : : .offset = offsetof(s, f), \
1129 : : .size = sizeof(((s *)0)->f), \
1130 : : })
1131 : :
1132 : : /** Static initializer for ARGS() to target a bit-field. */
1133 : : #define ARGS_ENTRY_BF(s, f, b) \
1134 : : (&(const struct arg){ \
1135 : : .size = sizeof(s), \
1136 : : .mask = (const void *)&(const s){ .f = (1 << (b)) - 1 }, \
1137 : : })
1138 : :
1139 : : /** Static initializer for ARGS() to target a field with limits. */
1140 : : #define ARGS_ENTRY_BOUNDED(s, f, i, a) \
1141 : : (&(const struct arg){ \
1142 : : .bounded = 1, \
1143 : : .min = (i), \
1144 : : .max = (a), \
1145 : : .offset = offsetof(s, f), \
1146 : : .size = sizeof(((s *)0)->f), \
1147 : : })
1148 : :
1149 : : /** Static initializer for ARGS() to target an arbitrary bit-mask. */
1150 : : #define ARGS_ENTRY_MASK(s, f, m) \
1151 : : (&(const struct arg){ \
1152 : : .offset = offsetof(s, f), \
1153 : : .size = sizeof(((s *)0)->f), \
1154 : : .mask = (const void *)(m), \
1155 : : })
1156 : :
1157 : : /** Same as ARGS_ENTRY_MASK() using network byte ordering for the value. */
1158 : : #define ARGS_ENTRY_MASK_HTON(s, f, m) \
1159 : : (&(const struct arg){ \
1160 : : .hton = 1, \
1161 : : .offset = offsetof(s, f), \
1162 : : .size = sizeof(((s *)0)->f), \
1163 : : .mask = (const void *)(m), \
1164 : : })
1165 : :
1166 : : /** Static initializer for ARGS() to target a pointer. */
1167 : : #define ARGS_ENTRY_PTR(s, f) \
1168 : : (&(const struct arg){ \
1169 : : .size = sizeof(*((s *)0)->f), \
1170 : : })
1171 : :
1172 : : /** Static initializer for ARGS() with arbitrary offset and size. */
1173 : : #define ARGS_ENTRY_ARB(o, s) \
1174 : : (&(const struct arg){ \
1175 : : .offset = (o), \
1176 : : .size = (s), \
1177 : : })
1178 : :
1179 : : /** Same as ARGS_ENTRY_ARB() with bounded values. */
1180 : : #define ARGS_ENTRY_ARB_BOUNDED(o, s, i, a) \
1181 : : (&(const struct arg){ \
1182 : : .bounded = 1, \
1183 : : .min = (i), \
1184 : : .max = (a), \
1185 : : .offset = (o), \
1186 : : .size = (s), \
1187 : : })
1188 : :
1189 : : /** Same as ARGS_ENTRY() using network byte ordering. */
1190 : : #define ARGS_ENTRY_HTON(s, f) \
1191 : : (&(const struct arg){ \
1192 : : .hton = 1, \
1193 : : .offset = offsetof(s, f), \
1194 : : .size = sizeof(((s *)0)->f), \
1195 : : })
1196 : :
1197 : : /** Same as ARGS_ENTRY_HTON() for a single argument, without structure. */
1198 : : #define ARG_ENTRY_HTON(s) \
1199 : : (&(const struct arg){ \
1200 : : .hton = 1, \
1201 : : .offset = 0, \
1202 : : .size = sizeof(s), \
1203 : : })
1204 : :
1205 : : /** Parser output buffer layout expected by cmd_flow_parsed(). */
1206 : : struct buffer {
1207 : : enum index command; /**< Flow command. */
1208 : : portid_t port; /**< Affected port ID. */
1209 : : queueid_t queue; /** Async queue ID. */
1210 : : bool postpone; /** Postpone async operation */
1211 : : union {
1212 : : struct {
1213 : : struct rte_flow_port_attr port_attr;
1214 : : uint32_t nb_queue;
1215 : : struct rte_flow_queue_attr queue_attr;
1216 : : } configure; /**< Configuration arguments. */
1217 : : struct {
1218 : : uint32_t *template_id;
1219 : : uint32_t template_id_n;
1220 : : } templ_destroy; /**< Template destroy arguments. */
1221 : : struct {
1222 : : uint32_t id;
1223 : : struct rte_flow_template_table_attr attr;
1224 : : uint32_t *pat_templ_id;
1225 : : uint32_t pat_templ_id_n;
1226 : : uint32_t *act_templ_id;
1227 : : uint32_t act_templ_id_n;
1228 : : } table; /**< Table arguments. */
1229 : : struct {
1230 : : uint32_t *table_id;
1231 : : uint32_t table_id_n;
1232 : : } table_destroy; /**< Template destroy arguments. */
1233 : : struct {
1234 : : uint32_t *action_id;
1235 : : uint32_t action_id_n;
1236 : : } ia_destroy; /**< Indirect action destroy arguments. */
1237 : : struct {
1238 : : uint32_t action_id;
1239 : : enum rte_flow_query_update_mode qu_mode;
1240 : : } ia; /* Indirect action query arguments */
1241 : : struct {
1242 : : uint32_t table_id;
1243 : : uint32_t pat_templ_id;
1244 : : uint32_t rule_id;
1245 : : uint32_t act_templ_id;
1246 : : struct rte_flow_attr attr;
1247 : : struct tunnel_ops tunnel_ops;
1248 : : uintptr_t user_id;
1249 : : struct rte_flow_item *pattern;
1250 : : struct rte_flow_action *actions;
1251 : : struct rte_flow_action *masks;
1252 : : uint32_t pattern_n;
1253 : : uint32_t actions_n;
1254 : : uint8_t *data;
1255 : : enum rte_flow_encap_hash_field field;
1256 : : uint8_t encap_hash;
1257 : : } vc; /**< Validate/create arguments. */
1258 : : struct {
1259 : : uint64_t *rule;
1260 : : uint64_t rule_n;
1261 : : bool is_user_id;
1262 : : } destroy; /**< Destroy arguments. */
1263 : : struct {
1264 : : char file[128];
1265 : : bool mode;
1266 : : uint64_t rule;
1267 : : bool is_user_id;
1268 : : } dump; /**< Dump arguments. */
1269 : : struct {
1270 : : uint64_t rule;
1271 : : struct rte_flow_action action;
1272 : : bool is_user_id;
1273 : : } query; /**< Query arguments. */
1274 : : struct {
1275 : : uint32_t *group;
1276 : : uint32_t group_n;
1277 : : } list; /**< List arguments. */
1278 : : struct {
1279 : : int set;
1280 : : } isolate; /**< Isolated mode arguments. */
1281 : : struct {
1282 : : int destroy;
1283 : : } aged; /**< Aged arguments. */
1284 : : struct {
1285 : : uint32_t policy_id;
1286 : : } policy;/**< Policy arguments. */
1287 : : struct {
1288 : : uint16_t token;
1289 : : uintptr_t uintptr;
1290 : : char filename[128];
1291 : : } flex; /**< Flex arguments*/
1292 : : } args; /**< Command arguments. */
1293 : : };
1294 : :
1295 : : /** Private data for pattern items. */
1296 : : struct parse_item_priv {
1297 : : enum rte_flow_item_type type; /**< Item type. */
1298 : : uint32_t size; /**< Size of item specification structure. */
1299 : : };
1300 : :
1301 : : #define PRIV_ITEM(t, s) \
1302 : : (&(const struct parse_item_priv){ \
1303 : : .type = RTE_FLOW_ITEM_TYPE_ ## t, \
1304 : : .size = s, \
1305 : : })
1306 : :
1307 : : /** Private data for actions. */
1308 : : struct parse_action_priv {
1309 : : enum rte_flow_action_type type; /**< Action type. */
1310 : : uint32_t size; /**< Size of action configuration structure. */
1311 : : };
1312 : :
1313 : : #define PRIV_ACTION(t, s) \
1314 : : (&(const struct parse_action_priv){ \
1315 : : .type = RTE_FLOW_ACTION_TYPE_ ## t, \
1316 : : .size = s, \
1317 : : })
1318 : :
1319 : : static const enum index next_flex_item[] = {
1320 : : FLEX_ITEM_CREATE,
1321 : : FLEX_ITEM_DESTROY,
1322 : : ZERO,
1323 : : };
1324 : :
1325 : : static const enum index next_config_attr[] = {
1326 : : CONFIG_QUEUES_NUMBER,
1327 : : CONFIG_QUEUES_SIZE,
1328 : : CONFIG_COUNTERS_NUMBER,
1329 : : CONFIG_AGING_OBJECTS_NUMBER,
1330 : : CONFIG_METERS_NUMBER,
1331 : : CONFIG_CONN_TRACK_NUMBER,
1332 : : CONFIG_QUOTAS_NUMBER,
1333 : : CONFIG_FLAGS,
1334 : : CONFIG_HOST_PORT,
1335 : : END,
1336 : : ZERO,
1337 : : };
1338 : :
1339 : : static const enum index next_pt_subcmd[] = {
1340 : : PATTERN_TEMPLATE_CREATE,
1341 : : PATTERN_TEMPLATE_DESTROY,
1342 : : ZERO,
1343 : : };
1344 : :
1345 : : static const enum index next_pt_attr[] = {
1346 : : PATTERN_TEMPLATE_CREATE_ID,
1347 : : PATTERN_TEMPLATE_RELAXED_MATCHING,
1348 : : PATTERN_TEMPLATE_INGRESS,
1349 : : PATTERN_TEMPLATE_EGRESS,
1350 : : PATTERN_TEMPLATE_TRANSFER,
1351 : : PATTERN_TEMPLATE_SPEC,
1352 : : ZERO,
1353 : : };
1354 : :
1355 : : static const enum index next_pt_destroy_attr[] = {
1356 : : PATTERN_TEMPLATE_DESTROY_ID,
1357 : : END,
1358 : : ZERO,
1359 : : };
1360 : :
1361 : : static const enum index next_at_subcmd[] = {
1362 : : ACTIONS_TEMPLATE_CREATE,
1363 : : ACTIONS_TEMPLATE_DESTROY,
1364 : : ZERO,
1365 : : };
1366 : :
1367 : : static const enum index next_at_attr[] = {
1368 : : ACTIONS_TEMPLATE_CREATE_ID,
1369 : : ACTIONS_TEMPLATE_INGRESS,
1370 : : ACTIONS_TEMPLATE_EGRESS,
1371 : : ACTIONS_TEMPLATE_TRANSFER,
1372 : : ACTIONS_TEMPLATE_SPEC,
1373 : : ZERO,
1374 : : };
1375 : :
1376 : : static const enum index next_at_destroy_attr[] = {
1377 : : ACTIONS_TEMPLATE_DESTROY_ID,
1378 : : END,
1379 : : ZERO,
1380 : : };
1381 : :
1382 : : static const enum index next_group_attr[] = {
1383 : : GROUP_INGRESS,
1384 : : GROUP_EGRESS,
1385 : : GROUP_TRANSFER,
1386 : : GROUP_SET_MISS_ACTIONS,
1387 : : ZERO,
1388 : : };
1389 : :
1390 : : static const enum index next_table_subcmd[] = {
1391 : : TABLE_CREATE,
1392 : : TABLE_DESTROY,
1393 : : TABLE_RESIZE,
1394 : : TABLE_RESIZE_COMPLETE,
1395 : : ZERO,
1396 : : };
1397 : :
1398 : : static const enum index next_table_attr[] = {
1399 : : TABLE_CREATE_ID,
1400 : : TABLE_GROUP,
1401 : : TABLE_INSERTION_TYPE,
1402 : : TABLE_HASH_FUNC,
1403 : : TABLE_PRIORITY,
1404 : : TABLE_INGRESS,
1405 : : TABLE_EGRESS,
1406 : : TABLE_TRANSFER,
1407 : : TABLE_TRANSFER_WIRE_ORIG,
1408 : : TABLE_TRANSFER_VPORT_ORIG,
1409 : : TABLE_RESIZABLE,
1410 : : TABLE_RULES_NUMBER,
1411 : : TABLE_PATTERN_TEMPLATE,
1412 : : TABLE_ACTIONS_TEMPLATE,
1413 : : END,
1414 : : ZERO,
1415 : : };
1416 : :
1417 : : static const enum index next_table_destroy_attr[] = {
1418 : : TABLE_DESTROY_ID,
1419 : : END,
1420 : : ZERO,
1421 : : };
1422 : :
1423 : : static const enum index next_queue_subcmd[] = {
1424 : : QUEUE_CREATE,
1425 : : QUEUE_DESTROY,
1426 : : QUEUE_FLOW_UPDATE_RESIZED,
1427 : : QUEUE_UPDATE,
1428 : : QUEUE_AGED,
1429 : : QUEUE_INDIRECT_ACTION,
1430 : : ZERO,
1431 : : };
1432 : :
1433 : : static const enum index next_queue_destroy_attr[] = {
1434 : : QUEUE_DESTROY_ID,
1435 : : END,
1436 : : ZERO,
1437 : : };
1438 : :
1439 : : static const enum index next_qia_subcmd[] = {
1440 : : QUEUE_INDIRECT_ACTION_CREATE,
1441 : : QUEUE_INDIRECT_ACTION_UPDATE,
1442 : : QUEUE_INDIRECT_ACTION_DESTROY,
1443 : : QUEUE_INDIRECT_ACTION_QUERY,
1444 : : QUEUE_INDIRECT_ACTION_QUERY_UPDATE,
1445 : : ZERO,
1446 : : };
1447 : :
1448 : : static const enum index next_qia_create_attr[] = {
1449 : : QUEUE_INDIRECT_ACTION_CREATE_ID,
1450 : : QUEUE_INDIRECT_ACTION_INGRESS,
1451 : : QUEUE_INDIRECT_ACTION_EGRESS,
1452 : : QUEUE_INDIRECT_ACTION_TRANSFER,
1453 : : QUEUE_INDIRECT_ACTION_CREATE_POSTPONE,
1454 : : QUEUE_INDIRECT_ACTION_SPEC,
1455 : : QUEUE_INDIRECT_ACTION_LIST,
1456 : : ZERO,
1457 : : };
1458 : :
1459 : : static const enum index next_qia_update_attr[] = {
1460 : : QUEUE_INDIRECT_ACTION_UPDATE_POSTPONE,
1461 : : QUEUE_INDIRECT_ACTION_SPEC,
1462 : : ZERO,
1463 : : };
1464 : :
1465 : : static const enum index next_qia_destroy_attr[] = {
1466 : : QUEUE_INDIRECT_ACTION_DESTROY_POSTPONE,
1467 : : QUEUE_INDIRECT_ACTION_DESTROY_ID,
1468 : : END,
1469 : : ZERO,
1470 : : };
1471 : :
1472 : : static const enum index next_qia_query_attr[] = {
1473 : : QUEUE_INDIRECT_ACTION_QUERY_POSTPONE,
1474 : : END,
1475 : : ZERO,
1476 : : };
1477 : :
1478 : : static const enum index next_ia_create_attr[] = {
1479 : : INDIRECT_ACTION_CREATE_ID,
1480 : : INDIRECT_ACTION_INGRESS,
1481 : : INDIRECT_ACTION_EGRESS,
1482 : : INDIRECT_ACTION_TRANSFER,
1483 : : INDIRECT_ACTION_SPEC,
1484 : : INDIRECT_ACTION_LIST,
1485 : : INDIRECT_ACTION_FLOW_CONF,
1486 : : ZERO,
1487 : : };
1488 : :
1489 : : static const enum index next_ia[] = {
1490 : : INDIRECT_ACTION_ID2PTR,
1491 : : ACTION_NEXT,
1492 : : ZERO
1493 : : };
1494 : :
1495 : : static const enum index next_ial[] = {
1496 : : ACTION_INDIRECT_LIST_HANDLE,
1497 : : ACTION_INDIRECT_LIST_CONF,
1498 : : ACTION_NEXT,
1499 : : ZERO
1500 : : };
1501 : :
1502 : : static const enum index next_qia_qu_attr[] = {
1503 : : QUEUE_INDIRECT_ACTION_QU_MODE,
1504 : : QUEUE_INDIRECT_ACTION_UPDATE_POSTPONE,
1505 : : INDIRECT_ACTION_SPEC,
1506 : : ZERO
1507 : : };
1508 : :
1509 : : static const enum index next_ia_qu_attr[] = {
1510 : : INDIRECT_ACTION_QU_MODE,
1511 : : INDIRECT_ACTION_SPEC,
1512 : : ZERO
1513 : : };
1514 : :
1515 : : static const enum index next_dump_subcmd[] = {
1516 : : DUMP_ALL,
1517 : : DUMP_ONE,
1518 : : DUMP_IS_USER_ID,
1519 : : ZERO,
1520 : : };
1521 : :
1522 : : static const enum index next_ia_subcmd[] = {
1523 : : INDIRECT_ACTION_CREATE,
1524 : : INDIRECT_ACTION_UPDATE,
1525 : : INDIRECT_ACTION_DESTROY,
1526 : : INDIRECT_ACTION_QUERY,
1527 : : INDIRECT_ACTION_QUERY_UPDATE,
1528 : : ZERO,
1529 : : };
1530 : :
1531 : : static const enum index next_vc_attr[] = {
1532 : : VC_GROUP,
1533 : : VC_PRIORITY,
1534 : : VC_INGRESS,
1535 : : VC_EGRESS,
1536 : : VC_TRANSFER,
1537 : : VC_TUNNEL_SET,
1538 : : VC_TUNNEL_MATCH,
1539 : : VC_USER_ID,
1540 : : ITEM_PATTERN,
1541 : : ZERO,
1542 : : };
1543 : :
1544 : : static const enum index next_destroy_attr[] = {
1545 : : DESTROY_RULE,
1546 : : DESTROY_IS_USER_ID,
1547 : : END,
1548 : : ZERO,
1549 : : };
1550 : :
1551 : : static const enum index next_dump_attr[] = {
1552 : : COMMON_FILE_PATH,
1553 : : END,
1554 : : ZERO,
1555 : : };
1556 : :
1557 : : static const enum index next_query_attr[] = {
1558 : : QUERY_IS_USER_ID,
1559 : : END,
1560 : : ZERO,
1561 : : };
1562 : :
1563 : : static const enum index next_list_attr[] = {
1564 : : LIST_GROUP,
1565 : : END,
1566 : : ZERO,
1567 : : };
1568 : :
1569 : : static const enum index next_aged_attr[] = {
1570 : : AGED_DESTROY,
1571 : : END,
1572 : : ZERO,
1573 : : };
1574 : :
1575 : : static const enum index next_ia_destroy_attr[] = {
1576 : : INDIRECT_ACTION_DESTROY_ID,
1577 : : END,
1578 : : ZERO,
1579 : : };
1580 : :
1581 : : static const enum index next_async_insert_subcmd[] = {
1582 : : QUEUE_PATTERN_TEMPLATE,
1583 : : QUEUE_RULE_ID,
1584 : : ZERO,
1585 : : };
1586 : :
1587 : : static const enum index next_async_pattern_subcmd[] = {
1588 : : QUEUE_PATTERN_TEMPLATE,
1589 : : QUEUE_ACTIONS_TEMPLATE,
1590 : : ZERO,
1591 : : };
1592 : :
1593 : : static const enum index item_param[] = {
1594 : : ITEM_PARAM_IS,
1595 : : ITEM_PARAM_SPEC,
1596 : : ITEM_PARAM_LAST,
1597 : : ITEM_PARAM_MASK,
1598 : : ITEM_PARAM_PREFIX,
1599 : : ZERO,
1600 : : };
1601 : :
1602 : : static const enum index next_item[] = {
1603 : : ITEM_END,
1604 : : ITEM_VOID,
1605 : : ITEM_INVERT,
1606 : : ITEM_ANY,
1607 : : ITEM_PORT_ID,
1608 : : ITEM_MARK,
1609 : : ITEM_RAW,
1610 : : ITEM_ETH,
1611 : : ITEM_VLAN,
1612 : : ITEM_IPV4,
1613 : : ITEM_IPV6,
1614 : : ITEM_ICMP,
1615 : : ITEM_UDP,
1616 : : ITEM_TCP,
1617 : : ITEM_SCTP,
1618 : : ITEM_VXLAN,
1619 : : ITEM_E_TAG,
1620 : : ITEM_NVGRE,
1621 : : ITEM_MPLS,
1622 : : ITEM_GRE,
1623 : : ITEM_FUZZY,
1624 : : ITEM_GTP,
1625 : : ITEM_GTPC,
1626 : : ITEM_GTPU,
1627 : : ITEM_GENEVE,
1628 : : ITEM_VXLAN_GPE,
1629 : : ITEM_ARP_ETH_IPV4,
1630 : : ITEM_IPV6_EXT,
1631 : : ITEM_IPV6_FRAG_EXT,
1632 : : ITEM_IPV6_ROUTING_EXT,
1633 : : ITEM_ICMP6,
1634 : : ITEM_ICMP6_ECHO_REQUEST,
1635 : : ITEM_ICMP6_ECHO_REPLY,
1636 : : ITEM_ICMP6_ND_NS,
1637 : : ITEM_ICMP6_ND_NA,
1638 : : ITEM_ICMP6_ND_OPT,
1639 : : ITEM_ICMP6_ND_OPT_SLA_ETH,
1640 : : ITEM_ICMP6_ND_OPT_TLA_ETH,
1641 : : ITEM_META,
1642 : : ITEM_RANDOM,
1643 : : ITEM_GRE_KEY,
1644 : : ITEM_GRE_OPTION,
1645 : : ITEM_GTP_PSC,
1646 : : ITEM_PPPOES,
1647 : : ITEM_PPPOED,
1648 : : ITEM_PPPOE_PROTO_ID,
1649 : : ITEM_HIGIG2,
1650 : : ITEM_TAG,
1651 : : ITEM_L2TPV3OIP,
1652 : : ITEM_ESP,
1653 : : ITEM_AH,
1654 : : ITEM_PFCP,
1655 : : ITEM_ECPRI,
1656 : : ITEM_GENEVE_OPT,
1657 : : ITEM_INTEGRITY,
1658 : : ITEM_CONNTRACK,
1659 : : ITEM_PORT_REPRESENTOR,
1660 : : ITEM_REPRESENTED_PORT,
1661 : : ITEM_FLEX,
1662 : : ITEM_L2TPV2,
1663 : : ITEM_PPP,
1664 : : ITEM_METER,
1665 : : ITEM_QUOTA,
1666 : : ITEM_AGGR_AFFINITY,
1667 : : ITEM_TX_QUEUE,
1668 : : ITEM_IB_BTH,
1669 : : ITEM_PTYPE,
1670 : : ITEM_NSH,
1671 : : ITEM_COMPARE,
1672 : : END_SET,
1673 : : ZERO,
1674 : : };
1675 : :
1676 : : static const enum index item_fuzzy[] = {
1677 : : ITEM_FUZZY_THRESH,
1678 : : ITEM_NEXT,
1679 : : ZERO,
1680 : : };
1681 : :
1682 : : static const enum index item_any[] = {
1683 : : ITEM_ANY_NUM,
1684 : : ITEM_NEXT,
1685 : : ZERO,
1686 : : };
1687 : :
1688 : : static const enum index item_port_id[] = {
1689 : : ITEM_PORT_ID_ID,
1690 : : ITEM_NEXT,
1691 : : ZERO,
1692 : : };
1693 : :
1694 : : static const enum index item_mark[] = {
1695 : : ITEM_MARK_ID,
1696 : : ITEM_NEXT,
1697 : : ZERO,
1698 : : };
1699 : :
1700 : : static const enum index item_raw[] = {
1701 : : ITEM_RAW_RELATIVE,
1702 : : ITEM_RAW_SEARCH,
1703 : : ITEM_RAW_OFFSET,
1704 : : ITEM_RAW_LIMIT,
1705 : : ITEM_RAW_PATTERN,
1706 : : ITEM_RAW_PATTERN_HEX,
1707 : : ITEM_NEXT,
1708 : : ZERO,
1709 : : };
1710 : :
1711 : : static const enum index item_eth[] = {
1712 : : ITEM_ETH_DST,
1713 : : ITEM_ETH_SRC,
1714 : : ITEM_ETH_TYPE,
1715 : : ITEM_ETH_HAS_VLAN,
1716 : : ITEM_NEXT,
1717 : : ZERO,
1718 : : };
1719 : :
1720 : : static const enum index item_vlan[] = {
1721 : : ITEM_VLAN_TCI,
1722 : : ITEM_VLAN_PCP,
1723 : : ITEM_VLAN_DEI,
1724 : : ITEM_VLAN_VID,
1725 : : ITEM_VLAN_INNER_TYPE,
1726 : : ITEM_VLAN_HAS_MORE_VLAN,
1727 : : ITEM_NEXT,
1728 : : ZERO,
1729 : : };
1730 : :
1731 : : static const enum index item_ipv4[] = {
1732 : : ITEM_IPV4_VER_IHL,
1733 : : ITEM_IPV4_TOS,
1734 : : ITEM_IPV4_LENGTH,
1735 : : ITEM_IPV4_ID,
1736 : : ITEM_IPV4_FRAGMENT_OFFSET,
1737 : : ITEM_IPV4_TTL,
1738 : : ITEM_IPV4_PROTO,
1739 : : ITEM_IPV4_SRC,
1740 : : ITEM_IPV4_DST,
1741 : : ITEM_NEXT,
1742 : : ZERO,
1743 : : };
1744 : :
1745 : : static const enum index item_ipv6[] = {
1746 : : ITEM_IPV6_TC,
1747 : : ITEM_IPV6_FLOW,
1748 : : ITEM_IPV6_LEN,
1749 : : ITEM_IPV6_PROTO,
1750 : : ITEM_IPV6_HOP,
1751 : : ITEM_IPV6_SRC,
1752 : : ITEM_IPV6_DST,
1753 : : ITEM_IPV6_HAS_FRAG_EXT,
1754 : : ITEM_IPV6_ROUTING_EXT,
1755 : : ITEM_NEXT,
1756 : : ZERO,
1757 : : };
1758 : :
1759 : : static const enum index item_ipv6_routing_ext[] = {
1760 : : ITEM_IPV6_ROUTING_EXT_TYPE,
1761 : : ITEM_IPV6_ROUTING_EXT_NEXT_HDR,
1762 : : ITEM_IPV6_ROUTING_EXT_SEG_LEFT,
1763 : : ITEM_NEXT,
1764 : : ZERO,
1765 : : };
1766 : :
1767 : : static const enum index item_icmp[] = {
1768 : : ITEM_ICMP_TYPE,
1769 : : ITEM_ICMP_CODE,
1770 : : ITEM_ICMP_IDENT,
1771 : : ITEM_ICMP_SEQ,
1772 : : ITEM_NEXT,
1773 : : ZERO,
1774 : : };
1775 : :
1776 : : static const enum index item_udp[] = {
1777 : : ITEM_UDP_SRC,
1778 : : ITEM_UDP_DST,
1779 : : ITEM_NEXT,
1780 : : ZERO,
1781 : : };
1782 : :
1783 : : static const enum index item_tcp[] = {
1784 : : ITEM_TCP_SRC,
1785 : : ITEM_TCP_DST,
1786 : : ITEM_TCP_FLAGS,
1787 : : ITEM_NEXT,
1788 : : ZERO,
1789 : : };
1790 : :
1791 : : static const enum index item_sctp[] = {
1792 : : ITEM_SCTP_SRC,
1793 : : ITEM_SCTP_DST,
1794 : : ITEM_SCTP_TAG,
1795 : : ITEM_SCTP_CKSUM,
1796 : : ITEM_NEXT,
1797 : : ZERO,
1798 : : };
1799 : :
1800 : : static const enum index item_vxlan[] = {
1801 : : ITEM_VXLAN_VNI,
1802 : : ITEM_VXLAN_FLAG_G,
1803 : : ITEM_VXLAN_FLAG_VER,
1804 : : ITEM_VXLAN_FLAG_I,
1805 : : ITEM_VXLAN_FLAG_P,
1806 : : ITEM_VXLAN_FLAG_B,
1807 : : ITEM_VXLAN_FLAG_O,
1808 : : ITEM_VXLAN_FLAG_D,
1809 : : ITEM_VXLAN_FLAG_A,
1810 : : ITEM_VXLAN_GBP_ID,
1811 : : ITEM_VXLAN_GPE_PROTO,
1812 : : ITEM_VXLAN_FIRST_RSVD,
1813 : : ITEM_VXLAN_SECND_RSVD,
1814 : : ITEM_VXLAN_THIRD_RSVD,
1815 : : ITEM_VXLAN_LAST_RSVD,
1816 : : ITEM_NEXT,
1817 : : ZERO,
1818 : : };
1819 : :
1820 : : static const enum index item_e_tag[] = {
1821 : : ITEM_E_TAG_GRP_ECID_B,
1822 : : ITEM_NEXT,
1823 : : ZERO,
1824 : : };
1825 : :
1826 : : static const enum index item_nvgre[] = {
1827 : : ITEM_NVGRE_TNI,
1828 : : ITEM_NEXT,
1829 : : ZERO,
1830 : : };
1831 : :
1832 : : static const enum index item_mpls[] = {
1833 : : ITEM_MPLS_LABEL,
1834 : : ITEM_MPLS_TC,
1835 : : ITEM_MPLS_S,
1836 : : ITEM_MPLS_TTL,
1837 : : ITEM_NEXT,
1838 : : ZERO,
1839 : : };
1840 : :
1841 : : static const enum index item_gre[] = {
1842 : : ITEM_GRE_PROTO,
1843 : : ITEM_GRE_C_RSVD0_VER,
1844 : : ITEM_GRE_C_BIT,
1845 : : ITEM_GRE_K_BIT,
1846 : : ITEM_GRE_S_BIT,
1847 : : ITEM_NEXT,
1848 : : ZERO,
1849 : : };
1850 : :
1851 : : static const enum index item_gre_key[] = {
1852 : : ITEM_GRE_KEY_VALUE,
1853 : : ITEM_NEXT,
1854 : : ZERO,
1855 : : };
1856 : :
1857 : : static const enum index item_gre_option[] = {
1858 : : ITEM_GRE_OPTION_CHECKSUM,
1859 : : ITEM_GRE_OPTION_KEY,
1860 : : ITEM_GRE_OPTION_SEQUENCE,
1861 : : ITEM_NEXT,
1862 : : ZERO,
1863 : : };
1864 : :
1865 : : static const enum index item_gtp[] = {
1866 : : ITEM_GTP_FLAGS,
1867 : : ITEM_GTP_MSG_TYPE,
1868 : : ITEM_GTP_TEID,
1869 : : ITEM_NEXT,
1870 : : ZERO,
1871 : : };
1872 : :
1873 : : static const enum index item_geneve[] = {
1874 : : ITEM_GENEVE_VNI,
1875 : : ITEM_GENEVE_PROTO,
1876 : : ITEM_GENEVE_OPTLEN,
1877 : : ITEM_NEXT,
1878 : : ZERO,
1879 : : };
1880 : :
1881 : : static const enum index item_vxlan_gpe[] = {
1882 : : ITEM_VXLAN_GPE_VNI,
1883 : : ITEM_VXLAN_GPE_PROTO_IN_DEPRECATED_VXLAN_GPE_HDR,
1884 : : ITEM_VXLAN_GPE_FLAGS,
1885 : : ITEM_VXLAN_GPE_RSVD0,
1886 : : ITEM_VXLAN_GPE_RSVD1,
1887 : : ITEM_NEXT,
1888 : : ZERO,
1889 : : };
1890 : :
1891 : : static const enum index item_arp_eth_ipv4[] = {
1892 : : ITEM_ARP_ETH_IPV4_SHA,
1893 : : ITEM_ARP_ETH_IPV4_SPA,
1894 : : ITEM_ARP_ETH_IPV4_THA,
1895 : : ITEM_ARP_ETH_IPV4_TPA,
1896 : : ITEM_NEXT,
1897 : : ZERO,
1898 : : };
1899 : :
1900 : : static const enum index item_ipv6_ext[] = {
1901 : : ITEM_IPV6_EXT_NEXT_HDR,
1902 : : ITEM_NEXT,
1903 : : ZERO,
1904 : : };
1905 : :
1906 : : static const enum index item_ipv6_frag_ext[] = {
1907 : : ITEM_IPV6_FRAG_EXT_NEXT_HDR,
1908 : : ITEM_IPV6_FRAG_EXT_FRAG_DATA,
1909 : : ITEM_IPV6_FRAG_EXT_ID,
1910 : : ITEM_NEXT,
1911 : : ZERO,
1912 : : };
1913 : :
1914 : : static const enum index item_icmp6[] = {
1915 : : ITEM_ICMP6_TYPE,
1916 : : ITEM_ICMP6_CODE,
1917 : : ITEM_NEXT,
1918 : : ZERO,
1919 : : };
1920 : :
1921 : : static const enum index item_icmp6_echo_request[] = {
1922 : : ITEM_ICMP6_ECHO_REQUEST_ID,
1923 : : ITEM_ICMP6_ECHO_REQUEST_SEQ,
1924 : : ITEM_NEXT,
1925 : : ZERO,
1926 : : };
1927 : :
1928 : : static const enum index item_icmp6_echo_reply[] = {
1929 : : ITEM_ICMP6_ECHO_REPLY_ID,
1930 : : ITEM_ICMP6_ECHO_REPLY_SEQ,
1931 : : ITEM_NEXT,
1932 : : ZERO,
1933 : : };
1934 : :
1935 : : static const enum index item_icmp6_nd_ns[] = {
1936 : : ITEM_ICMP6_ND_NS_TARGET_ADDR,
1937 : : ITEM_NEXT,
1938 : : ZERO,
1939 : : };
1940 : :
1941 : : static const enum index item_icmp6_nd_na[] = {
1942 : : ITEM_ICMP6_ND_NA_TARGET_ADDR,
1943 : : ITEM_NEXT,
1944 : : ZERO,
1945 : : };
1946 : :
1947 : : static const enum index item_icmp6_nd_opt[] = {
1948 : : ITEM_ICMP6_ND_OPT_TYPE,
1949 : : ITEM_NEXT,
1950 : : ZERO,
1951 : : };
1952 : :
1953 : : static const enum index item_icmp6_nd_opt_sla_eth[] = {
1954 : : ITEM_ICMP6_ND_OPT_SLA_ETH_SLA,
1955 : : ITEM_NEXT,
1956 : : ZERO,
1957 : : };
1958 : :
1959 : : static const enum index item_icmp6_nd_opt_tla_eth[] = {
1960 : : ITEM_ICMP6_ND_OPT_TLA_ETH_TLA,
1961 : : ITEM_NEXT,
1962 : : ZERO,
1963 : : };
1964 : :
1965 : : static const enum index item_meta[] = {
1966 : : ITEM_META_DATA,
1967 : : ITEM_NEXT,
1968 : : ZERO,
1969 : : };
1970 : :
1971 : : static const enum index item_random[] = {
1972 : : ITEM_RANDOM_VALUE,
1973 : : ITEM_NEXT,
1974 : : ZERO,
1975 : : };
1976 : :
1977 : : static const enum index item_gtp_psc[] = {
1978 : : ITEM_GTP_PSC_QFI,
1979 : : ITEM_GTP_PSC_PDU_T,
1980 : : ITEM_NEXT,
1981 : : ZERO,
1982 : : };
1983 : :
1984 : : static const enum index item_pppoed[] = {
1985 : : ITEM_PPPOE_SEID,
1986 : : ITEM_NEXT,
1987 : : ZERO,
1988 : : };
1989 : :
1990 : : static const enum index item_pppoes[] = {
1991 : : ITEM_PPPOE_SEID,
1992 : : ITEM_NEXT,
1993 : : ZERO,
1994 : : };
1995 : :
1996 : : static const enum index item_pppoe_proto_id[] = {
1997 : : ITEM_NEXT,
1998 : : ZERO,
1999 : : };
2000 : :
2001 : : static const enum index item_higig2[] = {
2002 : : ITEM_HIGIG2_CLASSIFICATION,
2003 : : ITEM_HIGIG2_VID,
2004 : : ITEM_NEXT,
2005 : : ZERO,
2006 : : };
2007 : :
2008 : : static const enum index item_esp[] = {
2009 : : ITEM_ESP_SPI,
2010 : : ITEM_NEXT,
2011 : : ZERO,
2012 : : };
2013 : :
2014 : : static const enum index item_ah[] = {
2015 : : ITEM_AH_SPI,
2016 : : ITEM_NEXT,
2017 : : ZERO,
2018 : : };
2019 : :
2020 : : static const enum index item_pfcp[] = {
2021 : : ITEM_PFCP_S_FIELD,
2022 : : ITEM_PFCP_SEID,
2023 : : ITEM_NEXT,
2024 : : ZERO,
2025 : : };
2026 : :
2027 : : static const enum index next_set_raw[] = {
2028 : : SET_RAW_INDEX,
2029 : : ITEM_ETH,
2030 : : ZERO,
2031 : : };
2032 : :
2033 : : static const enum index item_tag[] = {
2034 : : ITEM_TAG_DATA,
2035 : : ITEM_TAG_INDEX,
2036 : : ITEM_NEXT,
2037 : : ZERO,
2038 : : };
2039 : :
2040 : : static const enum index item_l2tpv3oip[] = {
2041 : : ITEM_L2TPV3OIP_SESSION_ID,
2042 : : ITEM_NEXT,
2043 : : ZERO,
2044 : : };
2045 : :
2046 : : static const enum index item_ecpri[] = {
2047 : : ITEM_ECPRI_COMMON,
2048 : : ITEM_NEXT,
2049 : : ZERO,
2050 : : };
2051 : :
2052 : : static const enum index item_ecpri_common[] = {
2053 : : ITEM_ECPRI_COMMON_TYPE,
2054 : : ZERO,
2055 : : };
2056 : :
2057 : : static const enum index item_ecpri_common_type[] = {
2058 : : ITEM_ECPRI_COMMON_TYPE_IQ_DATA,
2059 : : ITEM_ECPRI_COMMON_TYPE_RTC_CTRL,
2060 : : ITEM_ECPRI_COMMON_TYPE_DLY_MSR,
2061 : : ZERO,
2062 : : };
2063 : :
2064 : : static const enum index item_geneve_opt[] = {
2065 : : ITEM_GENEVE_OPT_CLASS,
2066 : : ITEM_GENEVE_OPT_TYPE,
2067 : : ITEM_GENEVE_OPT_LENGTH,
2068 : : ITEM_GENEVE_OPT_DATA,
2069 : : ITEM_NEXT,
2070 : : ZERO,
2071 : : };
2072 : :
2073 : : static const enum index item_integrity[] = {
2074 : : ITEM_INTEGRITY_LEVEL,
2075 : : ITEM_INTEGRITY_VALUE,
2076 : : ZERO,
2077 : : };
2078 : :
2079 : : static const enum index item_integrity_lv[] = {
2080 : : ITEM_INTEGRITY_LEVEL,
2081 : : ITEM_INTEGRITY_VALUE,
2082 : : ITEM_NEXT,
2083 : : ZERO,
2084 : : };
2085 : :
2086 : : static const enum index item_port_representor[] = {
2087 : : ITEM_PORT_REPRESENTOR_PORT_ID,
2088 : : ITEM_NEXT,
2089 : : ZERO,
2090 : : };
2091 : :
2092 : : static const enum index item_represented_port[] = {
2093 : : ITEM_REPRESENTED_PORT_ETHDEV_PORT_ID,
2094 : : ITEM_NEXT,
2095 : : ZERO,
2096 : : };
2097 : :
2098 : : static const enum index item_flex[] = {
2099 : : ITEM_FLEX_PATTERN_HANDLE,
2100 : : ITEM_FLEX_ITEM_HANDLE,
2101 : : ITEM_NEXT,
2102 : : ZERO,
2103 : : };
2104 : :
2105 : : static const enum index item_l2tpv2[] = {
2106 : : ITEM_L2TPV2_TYPE,
2107 : : ITEM_NEXT,
2108 : : ZERO,
2109 : : };
2110 : :
2111 : : static const enum index item_l2tpv2_type[] = {
2112 : : ITEM_L2TPV2_TYPE_DATA,
2113 : : ITEM_L2TPV2_TYPE_DATA_L,
2114 : : ITEM_L2TPV2_TYPE_DATA_S,
2115 : : ITEM_L2TPV2_TYPE_DATA_O,
2116 : : ITEM_L2TPV2_TYPE_DATA_L_S,
2117 : : ITEM_L2TPV2_TYPE_CTRL,
2118 : : ZERO,
2119 : : };
2120 : :
2121 : : static const enum index item_l2tpv2_type_data[] = {
2122 : : ITEM_L2TPV2_MSG_DATA_TUNNEL_ID,
2123 : : ITEM_L2TPV2_MSG_DATA_SESSION_ID,
2124 : : ITEM_NEXT,
2125 : : ZERO,
2126 : : };
2127 : :
2128 : : static const enum index item_l2tpv2_type_data_l[] = {
2129 : : ITEM_L2TPV2_MSG_DATA_L_LENGTH,
2130 : : ITEM_L2TPV2_MSG_DATA_L_TUNNEL_ID,
2131 : : ITEM_L2TPV2_MSG_DATA_L_SESSION_ID,
2132 : : ITEM_NEXT,
2133 : : ZERO,
2134 : : };
2135 : :
2136 : : static const enum index item_l2tpv2_type_data_s[] = {
2137 : : ITEM_L2TPV2_MSG_DATA_S_TUNNEL_ID,
2138 : : ITEM_L2TPV2_MSG_DATA_S_SESSION_ID,
2139 : : ITEM_L2TPV2_MSG_DATA_S_NS,
2140 : : ITEM_L2TPV2_MSG_DATA_S_NR,
2141 : : ITEM_NEXT,
2142 : : ZERO,
2143 : : };
2144 : :
2145 : : static const enum index item_l2tpv2_type_data_o[] = {
2146 : : ITEM_L2TPV2_MSG_DATA_O_TUNNEL_ID,
2147 : : ITEM_L2TPV2_MSG_DATA_O_SESSION_ID,
2148 : : ITEM_L2TPV2_MSG_DATA_O_OFFSET,
2149 : : ITEM_NEXT,
2150 : : ZERO,
2151 : : };
2152 : :
2153 : : static const enum index item_l2tpv2_type_data_l_s[] = {
2154 : : ITEM_L2TPV2_MSG_DATA_L_S_LENGTH,
2155 : : ITEM_L2TPV2_MSG_DATA_L_S_TUNNEL_ID,
2156 : : ITEM_L2TPV2_MSG_DATA_L_S_SESSION_ID,
2157 : : ITEM_L2TPV2_MSG_DATA_L_S_NS,
2158 : : ITEM_L2TPV2_MSG_DATA_L_S_NR,
2159 : : ITEM_NEXT,
2160 : : ZERO,
2161 : : };
2162 : :
2163 : : static const enum index item_l2tpv2_type_ctrl[] = {
2164 : : ITEM_L2TPV2_MSG_CTRL_LENGTH,
2165 : : ITEM_L2TPV2_MSG_CTRL_TUNNEL_ID,
2166 : : ITEM_L2TPV2_MSG_CTRL_SESSION_ID,
2167 : : ITEM_L2TPV2_MSG_CTRL_NS,
2168 : : ITEM_L2TPV2_MSG_CTRL_NR,
2169 : : ITEM_NEXT,
2170 : : ZERO,
2171 : : };
2172 : :
2173 : : static const enum index item_ppp[] = {
2174 : : ITEM_PPP_ADDR,
2175 : : ITEM_PPP_CTRL,
2176 : : ITEM_PPP_PROTO_ID,
2177 : : ITEM_NEXT,
2178 : : ZERO,
2179 : : };
2180 : :
2181 : : static const enum index item_meter[] = {
2182 : : ITEM_METER_COLOR,
2183 : : ITEM_NEXT,
2184 : : ZERO,
2185 : : };
2186 : :
2187 : : static const enum index item_quota[] = {
2188 : : ITEM_QUOTA_STATE,
2189 : : ITEM_NEXT,
2190 : : ZERO,
2191 : : };
2192 : :
2193 : : static const enum index item_aggr_affinity[] = {
2194 : : ITEM_AGGR_AFFINITY_VALUE,
2195 : : ITEM_NEXT,
2196 : : ZERO,
2197 : : };
2198 : :
2199 : : static const enum index item_tx_queue[] = {
2200 : : ITEM_TX_QUEUE_VALUE,
2201 : : ITEM_NEXT,
2202 : : ZERO,
2203 : : };
2204 : :
2205 : : static const enum index item_ib_bth[] = {
2206 : : ITEM_IB_BTH_OPCODE,
2207 : : ITEM_IB_BTH_PKEY,
2208 : : ITEM_IB_BTH_DST_QPN,
2209 : : ITEM_IB_BTH_PSN,
2210 : : ITEM_NEXT,
2211 : : ZERO,
2212 : : };
2213 : :
2214 : : static const enum index item_ptype[] = {
2215 : : ITEM_PTYPE_VALUE,
2216 : : ITEM_NEXT,
2217 : : ZERO,
2218 : : };
2219 : :
2220 : : static const enum index item_nsh[] = {
2221 : : ITEM_NEXT,
2222 : : ZERO,
2223 : : };
2224 : :
2225 : : static const enum index item_compare_field[] = {
2226 : : ITEM_COMPARE_OP,
2227 : : ITEM_COMPARE_FIELD_A_TYPE,
2228 : : ITEM_COMPARE_FIELD_B_TYPE,
2229 : : ITEM_NEXT,
2230 : : ZERO,
2231 : : };
2232 : :
2233 : : static const enum index compare_field_a[] = {
2234 : : ITEM_COMPARE_FIELD_A_TYPE,
2235 : : ITEM_COMPARE_FIELD_A_LEVEL,
2236 : : ITEM_COMPARE_FIELD_A_TAG_INDEX,
2237 : : ITEM_COMPARE_FIELD_A_TYPE_ID,
2238 : : ITEM_COMPARE_FIELD_A_CLASS_ID,
2239 : : ITEM_COMPARE_FIELD_A_OFFSET,
2240 : : ITEM_COMPARE_FIELD_B_TYPE,
2241 : : ZERO,
2242 : : };
2243 : :
2244 : : static const enum index compare_field_b[] = {
2245 : : ITEM_COMPARE_FIELD_B_TYPE,
2246 : : ITEM_COMPARE_FIELD_B_LEVEL,
2247 : : ITEM_COMPARE_FIELD_B_TAG_INDEX,
2248 : : ITEM_COMPARE_FIELD_B_TYPE_ID,
2249 : : ITEM_COMPARE_FIELD_B_CLASS_ID,
2250 : : ITEM_COMPARE_FIELD_B_OFFSET,
2251 : : ITEM_COMPARE_FIELD_B_VALUE,
2252 : : ITEM_COMPARE_FIELD_B_POINTER,
2253 : : ITEM_COMPARE_FIELD_WIDTH,
2254 : : ZERO,
2255 : : };
2256 : :
2257 : : static const enum index next_action[] = {
2258 : : ACTION_END,
2259 : : ACTION_VOID,
2260 : : ACTION_PASSTHRU,
2261 : : ACTION_SKIP_CMAN,
2262 : : ACTION_JUMP,
2263 : : ACTION_MARK,
2264 : : ACTION_FLAG,
2265 : : ACTION_QUEUE,
2266 : : ACTION_DROP,
2267 : : ACTION_COUNT,
2268 : : ACTION_RSS,
2269 : : ACTION_PF,
2270 : : ACTION_VF,
2271 : : ACTION_PORT_ID,
2272 : : ACTION_METER,
2273 : : ACTION_METER_COLOR,
2274 : : ACTION_METER_MARK,
2275 : : ACTION_METER_MARK_CONF,
2276 : : ACTION_OF_DEC_NW_TTL,
2277 : : ACTION_OF_POP_VLAN,
2278 : : ACTION_OF_PUSH_VLAN,
2279 : : ACTION_OF_SET_VLAN_VID,
2280 : : ACTION_OF_SET_VLAN_PCP,
2281 : : ACTION_OF_POP_MPLS,
2282 : : ACTION_OF_PUSH_MPLS,
2283 : : ACTION_VXLAN_ENCAP,
2284 : : ACTION_VXLAN_DECAP,
2285 : : ACTION_NVGRE_ENCAP,
2286 : : ACTION_NVGRE_DECAP,
2287 : : ACTION_L2_ENCAP,
2288 : : ACTION_L2_DECAP,
2289 : : ACTION_MPLSOGRE_ENCAP,
2290 : : ACTION_MPLSOGRE_DECAP,
2291 : : ACTION_MPLSOUDP_ENCAP,
2292 : : ACTION_MPLSOUDP_DECAP,
2293 : : ACTION_SET_IPV4_SRC,
2294 : : ACTION_SET_IPV4_DST,
2295 : : ACTION_SET_IPV6_SRC,
2296 : : ACTION_SET_IPV6_DST,
2297 : : ACTION_SET_TP_SRC,
2298 : : ACTION_SET_TP_DST,
2299 : : ACTION_MAC_SWAP,
2300 : : ACTION_DEC_TTL,
2301 : : ACTION_SET_TTL,
2302 : : ACTION_SET_MAC_SRC,
2303 : : ACTION_SET_MAC_DST,
2304 : : ACTION_INC_TCP_SEQ,
2305 : : ACTION_DEC_TCP_SEQ,
2306 : : ACTION_INC_TCP_ACK,
2307 : : ACTION_DEC_TCP_ACK,
2308 : : ACTION_RAW_ENCAP,
2309 : : ACTION_RAW_DECAP,
2310 : : ACTION_SET_TAG,
2311 : : ACTION_SET_META,
2312 : : ACTION_SET_IPV4_DSCP,
2313 : : ACTION_SET_IPV6_DSCP,
2314 : : ACTION_AGE,
2315 : : ACTION_AGE_UPDATE,
2316 : : ACTION_SAMPLE,
2317 : : ACTION_INDIRECT,
2318 : : ACTION_INDIRECT_LIST,
2319 : : ACTION_SHARED_INDIRECT,
2320 : : ACTION_MODIFY_FIELD,
2321 : : ACTION_CONNTRACK,
2322 : : ACTION_CONNTRACK_UPDATE,
2323 : : ACTION_PORT_REPRESENTOR,
2324 : : ACTION_REPRESENTED_PORT,
2325 : : ACTION_SEND_TO_KERNEL,
2326 : : ACTION_QUOTA_CREATE,
2327 : : ACTION_QUOTA_QU,
2328 : : ACTION_IPV6_EXT_REMOVE,
2329 : : ACTION_IPV6_EXT_PUSH,
2330 : : ACTION_NAT64,
2331 : : ACTION_JUMP_TO_TABLE_INDEX,
2332 : : ZERO,
2333 : : };
2334 : :
2335 : : static const enum index action_quota_create[] = {
2336 : : ACTION_QUOTA_CREATE_LIMIT,
2337 : : ACTION_QUOTA_CREATE_MODE,
2338 : : ACTION_NEXT,
2339 : : ZERO
2340 : : };
2341 : :
2342 : : static const enum index action_quota_update[] = {
2343 : : ACTION_QUOTA_QU_LIMIT,
2344 : : ACTION_QUOTA_QU_UPDATE_OP,
2345 : : ACTION_NEXT,
2346 : : ZERO
2347 : : };
2348 : :
2349 : : static const enum index action_mark[] = {
2350 : : ACTION_MARK_ID,
2351 : : ACTION_NEXT,
2352 : : ZERO,
2353 : : };
2354 : :
2355 : : static const enum index action_queue[] = {
2356 : : ACTION_QUEUE_INDEX,
2357 : : ACTION_NEXT,
2358 : : ZERO,
2359 : : };
2360 : :
2361 : : static const enum index action_count[] = {
2362 : : ACTION_COUNT_ID,
2363 : : ACTION_NEXT,
2364 : : ZERO,
2365 : : };
2366 : :
2367 : : static const enum index action_rss[] = {
2368 : : ACTION_RSS_FUNC,
2369 : : ACTION_RSS_LEVEL,
2370 : : ACTION_RSS_TYPES,
2371 : : ACTION_RSS_KEY,
2372 : : ACTION_RSS_KEY_LEN,
2373 : : ACTION_RSS_QUEUES,
2374 : : ACTION_NEXT,
2375 : : ZERO,
2376 : : };
2377 : :
2378 : : static const enum index action_vf[] = {
2379 : : ACTION_VF_ORIGINAL,
2380 : : ACTION_VF_ID,
2381 : : ACTION_NEXT,
2382 : : ZERO,
2383 : : };
2384 : :
2385 : : static const enum index action_port_id[] = {
2386 : : ACTION_PORT_ID_ORIGINAL,
2387 : : ACTION_PORT_ID_ID,
2388 : : ACTION_NEXT,
2389 : : ZERO,
2390 : : };
2391 : :
2392 : : static const enum index action_meter[] = {
2393 : : ACTION_METER_ID,
2394 : : ACTION_NEXT,
2395 : : ZERO,
2396 : : };
2397 : :
2398 : : static const enum index action_meter_color[] = {
2399 : : ACTION_METER_COLOR_TYPE,
2400 : : ACTION_NEXT,
2401 : : ZERO,
2402 : : };
2403 : :
2404 : : static const enum index action_meter_mark[] = {
2405 : : ACTION_METER_PROFILE,
2406 : : ACTION_METER_POLICY,
2407 : : ACTION_METER_COLOR_MODE,
2408 : : ACTION_METER_STATE,
2409 : : ACTION_NEXT,
2410 : : ZERO,
2411 : : };
2412 : :
2413 : : static const enum index action_of_push_vlan[] = {
2414 : : ACTION_OF_PUSH_VLAN_ETHERTYPE,
2415 : : ACTION_NEXT,
2416 : : ZERO,
2417 : : };
2418 : :
2419 : : static const enum index action_of_set_vlan_vid[] = {
2420 : : ACTION_OF_SET_VLAN_VID_VLAN_VID,
2421 : : ACTION_NEXT,
2422 : : ZERO,
2423 : : };
2424 : :
2425 : : static const enum index action_of_set_vlan_pcp[] = {
2426 : : ACTION_OF_SET_VLAN_PCP_VLAN_PCP,
2427 : : ACTION_NEXT,
2428 : : ZERO,
2429 : : };
2430 : :
2431 : : static const enum index action_of_pop_mpls[] = {
2432 : : ACTION_OF_POP_MPLS_ETHERTYPE,
2433 : : ACTION_NEXT,
2434 : : ZERO,
2435 : : };
2436 : :
2437 : : static const enum index action_of_push_mpls[] = {
2438 : : ACTION_OF_PUSH_MPLS_ETHERTYPE,
2439 : : ACTION_NEXT,
2440 : : ZERO,
2441 : : };
2442 : :
2443 : : static const enum index action_set_ipv4_src[] = {
2444 : : ACTION_SET_IPV4_SRC_IPV4_SRC,
2445 : : ACTION_NEXT,
2446 : : ZERO,
2447 : : };
2448 : :
2449 : : static const enum index action_set_mac_src[] = {
2450 : : ACTION_SET_MAC_SRC_MAC_SRC,
2451 : : ACTION_NEXT,
2452 : : ZERO,
2453 : : };
2454 : :
2455 : : static const enum index action_set_ipv4_dst[] = {
2456 : : ACTION_SET_IPV4_DST_IPV4_DST,
2457 : : ACTION_NEXT,
2458 : : ZERO,
2459 : : };
2460 : :
2461 : : static const enum index action_set_ipv6_src[] = {
2462 : : ACTION_SET_IPV6_SRC_IPV6_SRC,
2463 : : ACTION_NEXT,
2464 : : ZERO,
2465 : : };
2466 : :
2467 : : static const enum index action_set_ipv6_dst[] = {
2468 : : ACTION_SET_IPV6_DST_IPV6_DST,
2469 : : ACTION_NEXT,
2470 : : ZERO,
2471 : : };
2472 : :
2473 : : static const enum index action_set_tp_src[] = {
2474 : : ACTION_SET_TP_SRC_TP_SRC,
2475 : : ACTION_NEXT,
2476 : : ZERO,
2477 : : };
2478 : :
2479 : : static const enum index action_set_tp_dst[] = {
2480 : : ACTION_SET_TP_DST_TP_DST,
2481 : : ACTION_NEXT,
2482 : : ZERO,
2483 : : };
2484 : :
2485 : : static const enum index action_set_ttl[] = {
2486 : : ACTION_SET_TTL_TTL,
2487 : : ACTION_NEXT,
2488 : : ZERO,
2489 : : };
2490 : :
2491 : : static const enum index action_jump[] = {
2492 : : ACTION_JUMP_GROUP,
2493 : : ACTION_NEXT,
2494 : : ZERO,
2495 : : };
2496 : :
2497 : : static const enum index action_set_mac_dst[] = {
2498 : : ACTION_SET_MAC_DST_MAC_DST,
2499 : : ACTION_NEXT,
2500 : : ZERO,
2501 : : };
2502 : :
2503 : : static const enum index action_inc_tcp_seq[] = {
2504 : : ACTION_INC_TCP_SEQ_VALUE,
2505 : : ACTION_NEXT,
2506 : : ZERO,
2507 : : };
2508 : :
2509 : : static const enum index action_dec_tcp_seq[] = {
2510 : : ACTION_DEC_TCP_SEQ_VALUE,
2511 : : ACTION_NEXT,
2512 : : ZERO,
2513 : : };
2514 : :
2515 : : static const enum index action_inc_tcp_ack[] = {
2516 : : ACTION_INC_TCP_ACK_VALUE,
2517 : : ACTION_NEXT,
2518 : : ZERO,
2519 : : };
2520 : :
2521 : : static const enum index action_dec_tcp_ack[] = {
2522 : : ACTION_DEC_TCP_ACK_VALUE,
2523 : : ACTION_NEXT,
2524 : : ZERO,
2525 : : };
2526 : :
2527 : : static const enum index action_raw_encap[] = {
2528 : : ACTION_RAW_ENCAP_SIZE,
2529 : : ACTION_RAW_ENCAP_INDEX,
2530 : : ACTION_NEXT,
2531 : : ZERO,
2532 : : };
2533 : :
2534 : : static const enum index action_raw_decap[] = {
2535 : : ACTION_RAW_DECAP_INDEX,
2536 : : ACTION_NEXT,
2537 : : ZERO,
2538 : : };
2539 : :
2540 : : static const enum index action_ipv6_ext_remove[] = {
2541 : : ACTION_IPV6_EXT_REMOVE_INDEX,
2542 : : ACTION_NEXT,
2543 : : ZERO,
2544 : : };
2545 : :
2546 : : static const enum index action_ipv6_ext_push[] = {
2547 : : ACTION_IPV6_EXT_PUSH_INDEX,
2548 : : ACTION_NEXT,
2549 : : ZERO,
2550 : : };
2551 : :
2552 : : static const enum index action_set_tag[] = {
2553 : : ACTION_SET_TAG_DATA,
2554 : : ACTION_SET_TAG_INDEX,
2555 : : ACTION_SET_TAG_MASK,
2556 : : ACTION_NEXT,
2557 : : ZERO,
2558 : : };
2559 : :
2560 : : static const enum index action_set_meta[] = {
2561 : : ACTION_SET_META_DATA,
2562 : : ACTION_SET_META_MASK,
2563 : : ACTION_NEXT,
2564 : : ZERO,
2565 : : };
2566 : :
2567 : : static const enum index action_set_ipv4_dscp[] = {
2568 : : ACTION_SET_IPV4_DSCP_VALUE,
2569 : : ACTION_NEXT,
2570 : : ZERO,
2571 : : };
2572 : :
2573 : : static const enum index action_set_ipv6_dscp[] = {
2574 : : ACTION_SET_IPV6_DSCP_VALUE,
2575 : : ACTION_NEXT,
2576 : : ZERO,
2577 : : };
2578 : :
2579 : : static const enum index action_age[] = {
2580 : : ACTION_AGE,
2581 : : ACTION_AGE_TIMEOUT,
2582 : : ACTION_NEXT,
2583 : : ZERO,
2584 : : };
2585 : :
2586 : : static const enum index action_age_update[] = {
2587 : : ACTION_AGE_UPDATE,
2588 : : ACTION_AGE_UPDATE_TIMEOUT,
2589 : : ACTION_AGE_UPDATE_TOUCH,
2590 : : ACTION_NEXT,
2591 : : ZERO,
2592 : : };
2593 : :
2594 : : static const enum index action_sample[] = {
2595 : : ACTION_SAMPLE,
2596 : : ACTION_SAMPLE_RATIO,
2597 : : ACTION_SAMPLE_INDEX,
2598 : : ACTION_NEXT,
2599 : : ZERO,
2600 : : };
2601 : :
2602 : : static const enum index next_action_sample[] = {
2603 : : ACTION_QUEUE,
2604 : : ACTION_RSS,
2605 : : ACTION_MARK,
2606 : : ACTION_COUNT,
2607 : : ACTION_PORT_ID,
2608 : : ACTION_RAW_ENCAP,
2609 : : ACTION_VXLAN_ENCAP,
2610 : : ACTION_NVGRE_ENCAP,
2611 : : ACTION_REPRESENTED_PORT,
2612 : : ACTION_PORT_REPRESENTOR,
2613 : : ACTION_NEXT,
2614 : : ZERO,
2615 : : };
2616 : :
2617 : : static const enum index item_ipv6_push_ext[] = {
2618 : : ITEM_IPV6_PUSH_REMOVE_EXT,
2619 : : ZERO,
2620 : : };
2621 : :
2622 : : static const enum index item_ipv6_push_ext_type[] = {
2623 : : ITEM_IPV6_PUSH_REMOVE_EXT_TYPE,
2624 : : ZERO,
2625 : : };
2626 : :
2627 : : static const enum index item_ipv6_push_ext_header[] = {
2628 : : ITEM_IPV6_ROUTING_EXT,
2629 : : ITEM_NEXT,
2630 : : ZERO,
2631 : : };
2632 : :
2633 : : static const enum index action_modify_field_dst[] = {
2634 : : ACTION_MODIFY_FIELD_DST_LEVEL,
2635 : : ACTION_MODIFY_FIELD_DST_TAG_INDEX,
2636 : : ACTION_MODIFY_FIELD_DST_TYPE_ID,
2637 : : ACTION_MODIFY_FIELD_DST_CLASS_ID,
2638 : : ACTION_MODIFY_FIELD_DST_OFFSET,
2639 : : ACTION_MODIFY_FIELD_SRC_TYPE,
2640 : : ZERO,
2641 : : };
2642 : :
2643 : : static const enum index action_modify_field_src[] = {
2644 : : ACTION_MODIFY_FIELD_SRC_LEVEL,
2645 : : ACTION_MODIFY_FIELD_SRC_TAG_INDEX,
2646 : : ACTION_MODIFY_FIELD_SRC_TYPE_ID,
2647 : : ACTION_MODIFY_FIELD_SRC_CLASS_ID,
2648 : : ACTION_MODIFY_FIELD_SRC_OFFSET,
2649 : : ACTION_MODIFY_FIELD_SRC_VALUE,
2650 : : ACTION_MODIFY_FIELD_SRC_POINTER,
2651 : : ACTION_MODIFY_FIELD_WIDTH,
2652 : : ZERO,
2653 : : };
2654 : :
2655 : : static const enum index action_update_conntrack[] = {
2656 : : ACTION_CONNTRACK_UPDATE_DIR,
2657 : : ACTION_CONNTRACK_UPDATE_CTX,
2658 : : ACTION_NEXT,
2659 : : ZERO,
2660 : : };
2661 : :
2662 : : static const enum index action_port_representor[] = {
2663 : : ACTION_PORT_REPRESENTOR_PORT_ID,
2664 : : ACTION_NEXT,
2665 : : ZERO,
2666 : : };
2667 : :
2668 : : static const enum index action_represented_port[] = {
2669 : : ACTION_REPRESENTED_PORT_ETHDEV_PORT_ID,
2670 : : ACTION_NEXT,
2671 : : ZERO,
2672 : : };
2673 : :
2674 : : static const enum index action_nat64[] = {
2675 : : ACTION_NAT64_MODE,
2676 : : ACTION_NEXT,
2677 : : ZERO,
2678 : : };
2679 : :
2680 : : static const enum index next_hash_subcmd[] = {
2681 : : HASH_CALC_TABLE,
2682 : : HASH_CALC_ENCAP,
2683 : : ZERO,
2684 : : };
2685 : :
2686 : : static const enum index next_hash_encap_dest_subcmd[] = {
2687 : : ENCAP_HASH_FIELD_SRC_PORT,
2688 : : ENCAP_HASH_FIELD_GRE_FLOW_ID,
2689 : : ZERO,
2690 : : };
2691 : :
2692 : : static const enum index action_jump_to_table_index[] = {
2693 : : ACTION_JUMP_TO_TABLE_INDEX_TABLE,
2694 : : ACTION_JUMP_TO_TABLE_INDEX_INDEX,
2695 : : ACTION_NEXT,
2696 : : ZERO,
2697 : : };
2698 : :
2699 : : static int parse_set_raw_encap_decap(struct context *, const struct token *,
2700 : : const char *, unsigned int,
2701 : : void *, unsigned int);
2702 : : static int parse_set_sample_action(struct context *, const struct token *,
2703 : : const char *, unsigned int,
2704 : : void *, unsigned int);
2705 : : static int parse_set_ipv6_ext_action(struct context *, const struct token *,
2706 : : const char *, unsigned int,
2707 : : void *, unsigned int);
2708 : : static int parse_set_init(struct context *, const struct token *,
2709 : : const char *, unsigned int,
2710 : : void *, unsigned int);
2711 : : static int
2712 : : parse_flex_handle(struct context *, const struct token *,
2713 : : const char *, unsigned int, void *, unsigned int);
2714 : : static int parse_init(struct context *, const struct token *,
2715 : : const char *, unsigned int,
2716 : : void *, unsigned int);
2717 : : static int parse_vc(struct context *, const struct token *,
2718 : : const char *, unsigned int,
2719 : : void *, unsigned int);
2720 : : static int parse_vc_spec(struct context *, const struct token *,
2721 : : const char *, unsigned int, void *, unsigned int);
2722 : : static int parse_vc_conf(struct context *, const struct token *,
2723 : : const char *, unsigned int, void *, unsigned int);
2724 : : static int parse_vc_conf_timeout(struct context *, const struct token *,
2725 : : const char *, unsigned int, void *,
2726 : : unsigned int);
2727 : : static int parse_vc_item_ecpri_type(struct context *, const struct token *,
2728 : : const char *, unsigned int,
2729 : : void *, unsigned int);
2730 : : static int parse_vc_item_l2tpv2_type(struct context *, const struct token *,
2731 : : const char *, unsigned int,
2732 : : void *, unsigned int);
2733 : : static int parse_vc_action_meter_color_type(struct context *,
2734 : : const struct token *,
2735 : : const char *, unsigned int, void *,
2736 : : unsigned int);
2737 : : static int parse_vc_action_rss(struct context *, const struct token *,
2738 : : const char *, unsigned int, void *,
2739 : : unsigned int);
2740 : : static int parse_vc_action_rss_func(struct context *, const struct token *,
2741 : : const char *, unsigned int, void *,
2742 : : unsigned int);
2743 : : static int parse_vc_action_rss_type(struct context *, const struct token *,
2744 : : const char *, unsigned int, void *,
2745 : : unsigned int);
2746 : : static int parse_vc_action_rss_queue(struct context *, const struct token *,
2747 : : const char *, unsigned int, void *,
2748 : : unsigned int);
2749 : : static int parse_vc_action_vxlan_encap(struct context *, const struct token *,
2750 : : const char *, unsigned int, void *,
2751 : : unsigned int);
2752 : : static int parse_vc_action_nvgre_encap(struct context *, const struct token *,
2753 : : const char *, unsigned int, void *,
2754 : : unsigned int);
2755 : : static int parse_vc_action_l2_encap(struct context *, const struct token *,
2756 : : const char *, unsigned int, void *,
2757 : : unsigned int);
2758 : : static int parse_vc_action_l2_decap(struct context *, const struct token *,
2759 : : const char *, unsigned int, void *,
2760 : : unsigned int);
2761 : : static int parse_vc_action_mplsogre_encap(struct context *,
2762 : : const struct token *, const char *,
2763 : : unsigned int, void *, unsigned int);
2764 : : static int parse_vc_action_mplsogre_decap(struct context *,
2765 : : const struct token *, const char *,
2766 : : unsigned int, void *, unsigned int);
2767 : : static int parse_vc_action_mplsoudp_encap(struct context *,
2768 : : const struct token *, const char *,
2769 : : unsigned int, void *, unsigned int);
2770 : : static int parse_vc_action_mplsoudp_decap(struct context *,
2771 : : const struct token *, const char *,
2772 : : unsigned int, void *, unsigned int);
2773 : : static int parse_vc_action_raw_encap(struct context *,
2774 : : const struct token *, const char *,
2775 : : unsigned int, void *, unsigned int);
2776 : : static int parse_vc_action_raw_decap(struct context *,
2777 : : const struct token *, const char *,
2778 : : unsigned int, void *, unsigned int);
2779 : : static int parse_vc_action_raw_encap_index(struct context *,
2780 : : const struct token *, const char *,
2781 : : unsigned int, void *, unsigned int);
2782 : : static int parse_vc_action_raw_decap_index(struct context *,
2783 : : const struct token *, const char *,
2784 : : unsigned int, void *, unsigned int);
2785 : : static int parse_vc_action_ipv6_ext_remove(struct context *ctx, const struct token *token,
2786 : : const char *str, unsigned int len, void *buf,
2787 : : unsigned int size);
2788 : : static int parse_vc_action_ipv6_ext_remove_index(struct context *ctx,
2789 : : const struct token *token,
2790 : : const char *str, unsigned int len,
2791 : : void *buf,
2792 : : unsigned int size);
2793 : : static int parse_vc_action_ipv6_ext_push(struct context *ctx, const struct token *token,
2794 : : const char *str, unsigned int len, void *buf,
2795 : : unsigned int size);
2796 : : static int parse_vc_action_ipv6_ext_push_index(struct context *ctx,
2797 : : const struct token *token,
2798 : : const char *str, unsigned int len,
2799 : : void *buf,
2800 : : unsigned int size);
2801 : : static int parse_vc_action_set_meta(struct context *ctx,
2802 : : const struct token *token, const char *str,
2803 : : unsigned int len, void *buf,
2804 : : unsigned int size);
2805 : : static int parse_vc_action_sample(struct context *ctx,
2806 : : const struct token *token, const char *str,
2807 : : unsigned int len, void *buf,
2808 : : unsigned int size);
2809 : : static int
2810 : : parse_vc_action_sample_index(struct context *ctx, const struct token *token,
2811 : : const char *str, unsigned int len, void *buf,
2812 : : unsigned int size);
2813 : : static int
2814 : : parse_vc_modify_field_op(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_id(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_level(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_action_conntrack_update(struct context *ctx, const struct token *token,
2827 : : const char *str, unsigned int len, void *buf,
2828 : : unsigned int size);
2829 : : static int parse_destroy(struct context *, const struct token *,
2830 : : const char *, unsigned int,
2831 : : void *, unsigned int);
2832 : : static int parse_flush(struct context *, const struct token *,
2833 : : const char *, unsigned int,
2834 : : void *, unsigned int);
2835 : : static int parse_dump(struct context *, const struct token *,
2836 : : const char *, unsigned int,
2837 : : void *, unsigned int);
2838 : : static int parse_query(struct context *, const struct token *,
2839 : : const char *, unsigned int,
2840 : : void *, unsigned int);
2841 : : static int parse_action(struct context *, const struct token *,
2842 : : const char *, unsigned int,
2843 : : void *, unsigned int);
2844 : : static int parse_list(struct context *, const struct token *,
2845 : : const char *, unsigned int,
2846 : : void *, unsigned int);
2847 : : static int parse_aged(struct context *, const struct token *,
2848 : : const char *, unsigned int,
2849 : : void *, unsigned int);
2850 : : static int parse_isolate(struct context *, const struct token *,
2851 : : const char *, unsigned int,
2852 : : void *, unsigned int);
2853 : : static int parse_configure(struct context *, const struct token *,
2854 : : const char *, unsigned int,
2855 : : void *, unsigned int);
2856 : : static int parse_template(struct context *, const struct token *,
2857 : : const char *, unsigned int,
2858 : : void *, unsigned int);
2859 : : static int parse_template_destroy(struct context *, const struct token *,
2860 : : const char *, unsigned int,
2861 : : void *, unsigned int);
2862 : : static int parse_table(struct context *, const struct token *,
2863 : : const char *, unsigned int, void *, unsigned int);
2864 : : static int parse_table_destroy(struct context *, const struct token *,
2865 : : const char *, unsigned int,
2866 : : void *, unsigned int);
2867 : : static int parse_qo(struct context *, const struct token *,
2868 : : const char *, unsigned int,
2869 : : void *, unsigned int);
2870 : : static int parse_qo_destroy(struct context *, const struct token *,
2871 : : const char *, unsigned int,
2872 : : void *, unsigned int);
2873 : : static int parse_qia(struct context *, const struct token *,
2874 : : const char *, unsigned int,
2875 : : void *, unsigned int);
2876 : : static int parse_qia_destroy(struct context *, const struct token *,
2877 : : const char *, unsigned int,
2878 : : void *, unsigned int);
2879 : : static int parse_push(struct context *, const struct token *,
2880 : : const char *, unsigned int,
2881 : : void *, unsigned int);
2882 : : static int parse_pull(struct context *, const struct token *,
2883 : : const char *, unsigned int,
2884 : : void *, unsigned int);
2885 : : static int parse_group(struct context *, const struct token *,
2886 : : const char *, unsigned int,
2887 : : void *, unsigned int);
2888 : : static int parse_hash(struct context *, const struct token *,
2889 : : const char *, unsigned int,
2890 : : void *, unsigned int);
2891 : : static int parse_tunnel(struct context *, const struct token *,
2892 : : const char *, unsigned int,
2893 : : void *, unsigned int);
2894 : : static int parse_flex(struct context *, const struct token *,
2895 : : const char *, unsigned int, void *, unsigned int);
2896 : : static int parse_int(struct context *, const struct token *,
2897 : : const char *, unsigned int,
2898 : : void *, unsigned int);
2899 : : static int parse_prefix(struct context *, const struct token *,
2900 : : const char *, unsigned int,
2901 : : void *, unsigned int);
2902 : : static int parse_boolean(struct context *, const struct token *,
2903 : : const char *, unsigned int,
2904 : : void *, unsigned int);
2905 : : static int parse_string(struct context *, const struct token *,
2906 : : const char *, unsigned int,
2907 : : void *, unsigned int);
2908 : : static int parse_hex(struct context *ctx, const struct token *token,
2909 : : const char *str, unsigned int len,
2910 : : void *buf, unsigned int size);
2911 : : static int parse_string0(struct context *, const struct token *,
2912 : : const char *, unsigned int,
2913 : : void *, unsigned int);
2914 : : static int parse_mac_addr(struct context *, const struct token *,
2915 : : const char *, unsigned int,
2916 : : void *, unsigned int);
2917 : : static int parse_ipv4_addr(struct context *, const struct token *,
2918 : : const char *, unsigned int,
2919 : : void *, unsigned int);
2920 : : static int parse_ipv6_addr(struct context *, const struct token *,
2921 : : const char *, unsigned int,
2922 : : void *, unsigned int);
2923 : : static int parse_port(struct context *, const struct token *,
2924 : : const char *, unsigned int,
2925 : : void *, unsigned int);
2926 : : static int parse_ia(struct context *, const struct token *,
2927 : : const char *, unsigned int,
2928 : : void *, unsigned int);
2929 : : static int parse_ia_destroy(struct context *ctx, const struct token *token,
2930 : : const char *str, unsigned int len,
2931 : : void *buf, unsigned int size);
2932 : : static int parse_ia_id2ptr(struct context *ctx, const struct token *token,
2933 : : const char *str, unsigned int len, void *buf,
2934 : : unsigned int size);
2935 : :
2936 : : static int parse_indlst_id2ptr(struct context *ctx, const struct token *token,
2937 : : const char *str, unsigned int len, void *buf,
2938 : : unsigned int size);
2939 : : static int parse_ia_port(struct context *ctx, const struct token *token,
2940 : : const char *str, unsigned int len, void *buf,
2941 : : unsigned int size);
2942 : : static int parse_mp(struct context *, const struct token *,
2943 : : const char *, unsigned int,
2944 : : void *, unsigned int);
2945 : : static int parse_meter_profile_id2ptr(struct context *ctx,
2946 : : const struct token *token,
2947 : : const char *str, unsigned int len,
2948 : : void *buf, unsigned int size);
2949 : : static int parse_meter_policy_id2ptr(struct context *ctx,
2950 : : const struct token *token,
2951 : : const char *str, unsigned int len,
2952 : : void *buf, unsigned int size);
2953 : : static int parse_meter_color(struct context *ctx, const struct token *token,
2954 : : const char *str, unsigned int len, void *buf,
2955 : : unsigned int size);
2956 : : static int parse_insertion_table_type(struct context *ctx, const struct token *token,
2957 : : const char *str, unsigned int len, void *buf,
2958 : : unsigned int size);
2959 : : static int parse_hash_table_type(struct context *ctx, const struct token *token,
2960 : : const char *str, unsigned int len, void *buf,
2961 : : unsigned int size);
2962 : : static int
2963 : : parse_quota_state_name(struct context *ctx, const struct token *token,
2964 : : const char *str, unsigned int len, void *buf,
2965 : : unsigned int size);
2966 : : static int
2967 : : parse_quota_mode_name(struct context *ctx, const struct token *token,
2968 : : const char *str, unsigned int len, void *buf,
2969 : : unsigned int size);
2970 : : static int
2971 : : parse_quota_update_name(struct context *ctx, const struct token *token,
2972 : : const char *str, unsigned int len, void *buf,
2973 : : unsigned int size);
2974 : : static int
2975 : : parse_qu_mode_name(struct context *ctx, const struct token *token,
2976 : : const char *str, unsigned int len, void *buf,
2977 : : unsigned int size);
2978 : : static int comp_none(struct context *, const struct token *,
2979 : : unsigned int, char *, unsigned int);
2980 : : static int comp_boolean(struct context *, const struct token *,
2981 : : unsigned int, char *, unsigned int);
2982 : : static int comp_action(struct context *, const struct token *,
2983 : : unsigned int, char *, unsigned int);
2984 : : static int comp_port(struct context *, const struct token *,
2985 : : unsigned int, char *, unsigned int);
2986 : : static int comp_rule_id(struct context *, const struct token *,
2987 : : unsigned int, char *, unsigned int);
2988 : : static int comp_vc_action_rss_type(struct context *, const struct token *,
2989 : : unsigned int, char *, unsigned int);
2990 : : static int comp_vc_action_rss_queue(struct context *, const struct token *,
2991 : : unsigned int, char *, unsigned int);
2992 : : static int comp_set_raw_index(struct context *, const struct token *,
2993 : : unsigned int, char *, unsigned int);
2994 : : static int comp_set_sample_index(struct context *, const struct token *,
2995 : : unsigned int, char *, unsigned int);
2996 : : static int comp_set_ipv6_ext_index(struct context *ctx, const struct token *token,
2997 : : unsigned int ent, char *buf, unsigned int size);
2998 : : static int comp_set_modify_field_op(struct context *, const struct token *,
2999 : : unsigned int, char *, unsigned int);
3000 : : static int comp_set_modify_field_id(struct context *, const struct token *,
3001 : : unsigned int, char *, unsigned int);
3002 : : static int comp_pattern_template_id(struct context *, const struct token *,
3003 : : unsigned int, char *, unsigned int);
3004 : : static int comp_actions_template_id(struct context *, const struct token *,
3005 : : unsigned int, char *, unsigned int);
3006 : : static int comp_table_id(struct context *, const struct token *,
3007 : : unsigned int, char *, unsigned int);
3008 : : static int comp_queue_id(struct context *, const struct token *,
3009 : : unsigned int, char *, unsigned int);
3010 : : static int comp_meter_color(struct context *, const struct token *,
3011 : : unsigned int, char *, unsigned int);
3012 : : static int comp_insertion_table_type(struct context *, const struct token *,
3013 : : unsigned int, char *, unsigned int);
3014 : : static int comp_hash_table_type(struct context *, const struct token *,
3015 : : unsigned int, char *, unsigned int);
3016 : : static int
3017 : : comp_quota_state_name(struct context *ctx, const struct token *token,
3018 : : unsigned int ent, char *buf, unsigned int size);
3019 : : static int
3020 : : comp_quota_mode_name(struct context *ctx, const struct token *token,
3021 : : unsigned int ent, char *buf, unsigned int size);
3022 : : static int
3023 : : comp_quota_update_name(struct context *ctx, const struct token *token,
3024 : : unsigned int ent, char *buf, unsigned int size);
3025 : : static int
3026 : : comp_qu_mode_name(struct context *ctx, const struct token *token,
3027 : : unsigned int ent, char *buf, unsigned int size);
3028 : : static int
3029 : : comp_set_compare_field_id(struct context *ctx, const struct token *token,
3030 : : unsigned int ent, char *buf, unsigned int size);
3031 : : static int
3032 : : comp_set_compare_op(struct context *ctx, const struct token *token,
3033 : : unsigned int ent, char *buf, unsigned int size);
3034 : : static int
3035 : : parse_vc_compare_op(struct context *ctx, const struct token *token,
3036 : : const char *str, unsigned int len, void *buf,
3037 : : unsigned int size);
3038 : : static int
3039 : : parse_vc_compare_field_id(struct context *ctx, const struct token *token,
3040 : : const char *str, unsigned int len, void *buf,
3041 : : unsigned int size);
3042 : : static int
3043 : : parse_vc_compare_field_level(struct context *ctx, const struct token *token,
3044 : : const char *str, unsigned int len, void *buf,
3045 : : unsigned int size);
3046 : :
3047 : : struct indlst_conf {
3048 : : uint32_t id;
3049 : : uint32_t conf_num;
3050 : : struct rte_flow_action *actions;
3051 : : const void **conf;
3052 : : SLIST_ENTRY(indlst_conf) next;
3053 : : };
3054 : :
3055 : : static const struct indlst_conf *indirect_action_list_conf_get(uint32_t conf_id);
3056 : :
3057 : : /** Token definitions. */
3058 : : static const struct token token_list[] = {
3059 : : /* Special tokens. */
3060 : : [ZERO] = {
3061 : : .name = "ZERO",
3062 : : .help = "null entry, abused as the entry point",
3063 : : .next = NEXT(NEXT_ENTRY(FLOW, ADD)),
3064 : : },
3065 : : [END] = {
3066 : : .name = "",
3067 : : .type = "RETURN",
3068 : : .help = "command may end here",
3069 : : },
3070 : : [START_SET] = {
3071 : : .name = "START_SET",
3072 : : .help = "null entry, abused as the entry point for set",
3073 : : .next = NEXT(NEXT_ENTRY(SET)),
3074 : : },
3075 : : [END_SET] = {
3076 : : .name = "end_set",
3077 : : .type = "RETURN",
3078 : : .help = "set command may end here",
3079 : : },
3080 : : /* Common tokens. */
3081 : : [COMMON_INTEGER] = {
3082 : : .name = "{int}",
3083 : : .type = "INTEGER",
3084 : : .help = "integer value",
3085 : : .call = parse_int,
3086 : : .comp = comp_none,
3087 : : },
3088 : : [COMMON_UNSIGNED] = {
3089 : : .name = "{unsigned}",
3090 : : .type = "UNSIGNED",
3091 : : .help = "unsigned integer value",
3092 : : .call = parse_int,
3093 : : .comp = comp_none,
3094 : : },
3095 : : [COMMON_PREFIX] = {
3096 : : .name = "{prefix}",
3097 : : .type = "PREFIX",
3098 : : .help = "prefix length for bit-mask",
3099 : : .call = parse_prefix,
3100 : : .comp = comp_none,
3101 : : },
3102 : : [COMMON_BOOLEAN] = {
3103 : : .name = "{boolean}",
3104 : : .type = "BOOLEAN",
3105 : : .help = "any boolean value",
3106 : : .call = parse_boolean,
3107 : : .comp = comp_boolean,
3108 : : },
3109 : : [COMMON_STRING] = {
3110 : : .name = "{string}",
3111 : : .type = "STRING",
3112 : : .help = "fixed string",
3113 : : .call = parse_string,
3114 : : .comp = comp_none,
3115 : : },
3116 : : [COMMON_HEX] = {
3117 : : .name = "{hex}",
3118 : : .type = "HEX",
3119 : : .help = "fixed string",
3120 : : .call = parse_hex,
3121 : : },
3122 : : [COMMON_FILE_PATH] = {
3123 : : .name = "{file path}",
3124 : : .type = "STRING",
3125 : : .help = "file path",
3126 : : .call = parse_string0,
3127 : : .comp = comp_none,
3128 : : },
3129 : : [COMMON_MAC_ADDR] = {
3130 : : .name = "{MAC address}",
3131 : : .type = "MAC-48",
3132 : : .help = "standard MAC address notation",
3133 : : .call = parse_mac_addr,
3134 : : .comp = comp_none,
3135 : : },
3136 : : [COMMON_IPV4_ADDR] = {
3137 : : .name = "{IPv4 address}",
3138 : : .type = "IPV4 ADDRESS",
3139 : : .help = "standard IPv4 address notation",
3140 : : .call = parse_ipv4_addr,
3141 : : .comp = comp_none,
3142 : : },
3143 : : [COMMON_IPV6_ADDR] = {
3144 : : .name = "{IPv6 address}",
3145 : : .type = "IPV6 ADDRESS",
3146 : : .help = "standard IPv6 address notation",
3147 : : .call = parse_ipv6_addr,
3148 : : .comp = comp_none,
3149 : : },
3150 : : [COMMON_RULE_ID] = {
3151 : : .name = "{rule id}",
3152 : : .type = "RULE ID",
3153 : : .help = "rule identifier",
3154 : : .call = parse_int,
3155 : : .comp = comp_rule_id,
3156 : : },
3157 : : [COMMON_PORT_ID] = {
3158 : : .name = "{port_id}",
3159 : : .type = "PORT ID",
3160 : : .help = "port identifier",
3161 : : .call = parse_port,
3162 : : .comp = comp_port,
3163 : : },
3164 : : [COMMON_GROUP_ID] = {
3165 : : .name = "{group_id}",
3166 : : .type = "GROUP ID",
3167 : : .help = "group identifier",
3168 : : .call = parse_int,
3169 : : .comp = comp_none,
3170 : : },
3171 : : [COMMON_PRIORITY_LEVEL] = {
3172 : : .name = "{level}",
3173 : : .type = "PRIORITY",
3174 : : .help = "priority level",
3175 : : .call = parse_int,
3176 : : .comp = comp_none,
3177 : : },
3178 : : [COMMON_INDIRECT_ACTION_ID] = {
3179 : : .name = "{indirect_action_id}",
3180 : : .type = "INDIRECT_ACTION_ID",
3181 : : .help = "indirect action id",
3182 : : .call = parse_int,
3183 : : .comp = comp_none,
3184 : : },
3185 : : [COMMON_PROFILE_ID] = {
3186 : : .name = "{profile_id}",
3187 : : .type = "PROFILE_ID",
3188 : : .help = "profile id",
3189 : : .call = parse_int,
3190 : : .comp = comp_none,
3191 : : },
3192 : : [COMMON_POLICY_ID] = {
3193 : : .name = "{policy_id}",
3194 : : .type = "POLICY_ID",
3195 : : .help = "policy id",
3196 : : .call = parse_int,
3197 : : .comp = comp_none,
3198 : : },
3199 : : [COMMON_FLEX_TOKEN] = {
3200 : : .name = "{flex token}",
3201 : : .type = "flex token",
3202 : : .help = "flex token",
3203 : : .call = parse_int,
3204 : : .comp = comp_none,
3205 : : },
3206 : : [COMMON_FLEX_HANDLE] = {
3207 : : .name = "{flex handle}",
3208 : : .type = "FLEX HANDLE",
3209 : : .help = "fill flex item data",
3210 : : .call = parse_flex_handle,
3211 : : .comp = comp_none,
3212 : : },
3213 : : [COMMON_PATTERN_TEMPLATE_ID] = {
3214 : : .name = "{pattern_template_id}",
3215 : : .type = "PATTERN_TEMPLATE_ID",
3216 : : .help = "pattern template id",
3217 : : .call = parse_int,
3218 : : .comp = comp_pattern_template_id,
3219 : : },
3220 : : [COMMON_ACTIONS_TEMPLATE_ID] = {
3221 : : .name = "{actions_template_id}",
3222 : : .type = "ACTIONS_TEMPLATE_ID",
3223 : : .help = "actions template id",
3224 : : .call = parse_int,
3225 : : .comp = comp_actions_template_id,
3226 : : },
3227 : : [COMMON_TABLE_ID] = {
3228 : : .name = "{table_id}",
3229 : : .type = "TABLE_ID",
3230 : : .help = "table id",
3231 : : .call = parse_int,
3232 : : .comp = comp_table_id,
3233 : : },
3234 : : [COMMON_QUEUE_ID] = {
3235 : : .name = "{queue_id}",
3236 : : .type = "QUEUE_ID",
3237 : : .help = "queue id",
3238 : : .call = parse_int,
3239 : : .comp = comp_queue_id,
3240 : : },
3241 : : [COMMON_METER_COLOR_NAME] = {
3242 : : .name = "color_name",
3243 : : .help = "meter color name",
3244 : : .call = parse_meter_color,
3245 : : .comp = comp_meter_color,
3246 : : },
3247 : : /* Top-level command. */
3248 : : [FLOW] = {
3249 : : .name = "flow",
3250 : : .type = "{command} {port_id} [{arg} [...]]",
3251 : : .help = "manage ingress/egress flow rules",
3252 : : .next = NEXT(NEXT_ENTRY
3253 : : (INFO,
3254 : : CONFIGURE,
3255 : : PATTERN_TEMPLATE,
3256 : : ACTIONS_TEMPLATE,
3257 : : TABLE,
3258 : : FLOW_GROUP,
3259 : : INDIRECT_ACTION,
3260 : : VALIDATE,
3261 : : CREATE,
3262 : : DESTROY,
3263 : : UPDATE,
3264 : : FLUSH,
3265 : : DUMP,
3266 : : LIST,
3267 : : AGED,
3268 : : QUERY,
3269 : : ISOLATE,
3270 : : TUNNEL,
3271 : : FLEX,
3272 : : QUEUE,
3273 : : PUSH,
3274 : : PULL,
3275 : : HASH)),
3276 : : .call = parse_init,
3277 : : },
3278 : : /* Top-level command. */
3279 : : [INFO] = {
3280 : : .name = "info",
3281 : : .help = "get information about flow engine",
3282 : : .next = NEXT(NEXT_ENTRY(END),
3283 : : NEXT_ENTRY(COMMON_PORT_ID)),
3284 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3285 : : .call = parse_configure,
3286 : : },
3287 : : /* Top-level command. */
3288 : : [CONFIGURE] = {
3289 : : .name = "configure",
3290 : : .help = "configure flow engine",
3291 : : .next = NEXT(next_config_attr,
3292 : : NEXT_ENTRY(COMMON_PORT_ID)),
3293 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3294 : : .call = parse_configure,
3295 : : },
3296 : : /* Configure arguments. */
3297 : : [CONFIG_QUEUES_NUMBER] = {
3298 : : .name = "queues_number",
3299 : : .help = "number of queues",
3300 : : .next = NEXT(next_config_attr,
3301 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3302 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3303 : : args.configure.nb_queue)),
3304 : : },
3305 : : [CONFIG_QUEUES_SIZE] = {
3306 : : .name = "queues_size",
3307 : : .help = "number of elements in queues",
3308 : : .next = NEXT(next_config_attr,
3309 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3310 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3311 : : args.configure.queue_attr.size)),
3312 : : },
3313 : : [CONFIG_COUNTERS_NUMBER] = {
3314 : : .name = "counters_number",
3315 : : .help = "number of counters",
3316 : : .next = NEXT(next_config_attr,
3317 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3318 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3319 : : args.configure.port_attr.nb_counters)),
3320 : : },
3321 : : [CONFIG_AGING_OBJECTS_NUMBER] = {
3322 : : .name = "aging_counters_number",
3323 : : .help = "number of aging objects",
3324 : : .next = NEXT(next_config_attr,
3325 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3326 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3327 : : args.configure.port_attr.nb_aging_objects)),
3328 : : },
3329 : : [CONFIG_QUOTAS_NUMBER] = {
3330 : : .name = "quotas_number",
3331 : : .help = "number of quotas",
3332 : : .next = NEXT(next_config_attr,
3333 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3334 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3335 : : args.configure.port_attr.nb_quotas)),
3336 : : },
3337 : : [CONFIG_METERS_NUMBER] = {
3338 : : .name = "meters_number",
3339 : : .help = "number of meters",
3340 : : .next = NEXT(next_config_attr,
3341 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3342 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3343 : : args.configure.port_attr.nb_meters)),
3344 : : },
3345 : : [CONFIG_CONN_TRACK_NUMBER] = {
3346 : : .name = "conn_tracks_number",
3347 : : .help = "number of connection trackings",
3348 : : .next = NEXT(next_config_attr,
3349 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3350 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3351 : : args.configure.port_attr.nb_conn_tracks)),
3352 : : },
3353 : : [CONFIG_FLAGS] = {
3354 : : .name = "flags",
3355 : : .help = "configuration flags",
3356 : : .next = NEXT(next_config_attr,
3357 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3358 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3359 : : args.configure.port_attr.flags)),
3360 : : },
3361 : : [CONFIG_HOST_PORT] = {
3362 : : .name = "host_port",
3363 : : .help = "host port for shared objects",
3364 : : .next = NEXT(next_config_attr,
3365 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3366 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3367 : : args.configure.port_attr.host_port_id)),
3368 : : },
3369 : : /* Top-level command. */
3370 : : [PATTERN_TEMPLATE] = {
3371 : : .name = "pattern_template",
3372 : : .type = "{command} {port_id} [{arg} [...]]",
3373 : : .help = "manage pattern templates",
3374 : : .next = NEXT(next_pt_subcmd, NEXT_ENTRY(COMMON_PORT_ID)),
3375 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3376 : : .call = parse_template,
3377 : : },
3378 : : /* Sub-level commands. */
3379 : : [PATTERN_TEMPLATE_CREATE] = {
3380 : : .name = "create",
3381 : : .help = "create pattern template",
3382 : : .next = NEXT(next_pt_attr),
3383 : : .call = parse_template,
3384 : : },
3385 : : [PATTERN_TEMPLATE_DESTROY] = {
3386 : : .name = "destroy",
3387 : : .help = "destroy pattern template",
3388 : : .next = NEXT(NEXT_ENTRY(PATTERN_TEMPLATE_DESTROY_ID)),
3389 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3390 : : .call = parse_template_destroy,
3391 : : },
3392 : : /* Pattern template arguments. */
3393 : : [PATTERN_TEMPLATE_CREATE_ID] = {
3394 : : .name = "pattern_template_id",
3395 : : .help = "specify a pattern template id to create",
3396 : : .next = NEXT(next_pt_attr,
3397 : : NEXT_ENTRY(COMMON_PATTERN_TEMPLATE_ID)),
3398 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.pat_templ_id)),
3399 : : },
3400 : : [PATTERN_TEMPLATE_DESTROY_ID] = {
3401 : : .name = "pattern_template",
3402 : : .help = "specify a pattern template id to destroy",
3403 : : .next = NEXT(next_pt_destroy_attr,
3404 : : NEXT_ENTRY(COMMON_PATTERN_TEMPLATE_ID)),
3405 : : .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
3406 : : args.templ_destroy.template_id)),
3407 : : .call = parse_template_destroy,
3408 : : },
3409 : : [PATTERN_TEMPLATE_RELAXED_MATCHING] = {
3410 : : .name = "relaxed",
3411 : : .help = "is matching relaxed",
3412 : : .next = NEXT(next_pt_attr,
3413 : : NEXT_ENTRY(COMMON_BOOLEAN)),
3414 : : .args = ARGS(ARGS_ENTRY_BF(struct buffer,
3415 : : args.vc.attr.reserved, 1)),
3416 : : },
3417 : : [PATTERN_TEMPLATE_INGRESS] = {
3418 : : .name = "ingress",
3419 : : .help = "attribute pattern to ingress",
3420 : : .next = NEXT(next_pt_attr),
3421 : : .call = parse_template,
3422 : : },
3423 : : [PATTERN_TEMPLATE_EGRESS] = {
3424 : : .name = "egress",
3425 : : .help = "attribute pattern to egress",
3426 : : .next = NEXT(next_pt_attr),
3427 : : .call = parse_template,
3428 : : },
3429 : : [PATTERN_TEMPLATE_TRANSFER] = {
3430 : : .name = "transfer",
3431 : : .help = "attribute pattern to transfer",
3432 : : .next = NEXT(next_pt_attr),
3433 : : .call = parse_template,
3434 : : },
3435 : : [PATTERN_TEMPLATE_SPEC] = {
3436 : : .name = "template",
3437 : : .help = "specify item to create pattern template",
3438 : : .next = NEXT(next_item),
3439 : : },
3440 : : /* Top-level command. */
3441 : : [ACTIONS_TEMPLATE] = {
3442 : : .name = "actions_template",
3443 : : .type = "{command} {port_id} [{arg} [...]]",
3444 : : .help = "manage actions templates",
3445 : : .next = NEXT(next_at_subcmd, NEXT_ENTRY(COMMON_PORT_ID)),
3446 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3447 : : .call = parse_template,
3448 : : },
3449 : : /* Sub-level commands. */
3450 : : [ACTIONS_TEMPLATE_CREATE] = {
3451 : : .name = "create",
3452 : : .help = "create actions template",
3453 : : .next = NEXT(next_at_attr),
3454 : : .call = parse_template,
3455 : : },
3456 : : [ACTIONS_TEMPLATE_DESTROY] = {
3457 : : .name = "destroy",
3458 : : .help = "destroy actions template",
3459 : : .next = NEXT(NEXT_ENTRY(ACTIONS_TEMPLATE_DESTROY_ID)),
3460 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3461 : : .call = parse_template_destroy,
3462 : : },
3463 : : /* Actions template arguments. */
3464 : : [ACTIONS_TEMPLATE_CREATE_ID] = {
3465 : : .name = "actions_template_id",
3466 : : .help = "specify an actions template id to create",
3467 : : .next = NEXT(NEXT_ENTRY(ACTIONS_TEMPLATE_MASK),
3468 : : NEXT_ENTRY(ACTIONS_TEMPLATE_SPEC),
3469 : : NEXT_ENTRY(COMMON_ACTIONS_TEMPLATE_ID)),
3470 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.act_templ_id)),
3471 : : },
3472 : : [ACTIONS_TEMPLATE_DESTROY_ID] = {
3473 : : .name = "actions_template",
3474 : : .help = "specify an actions template id to destroy",
3475 : : .next = NEXT(next_at_destroy_attr,
3476 : : NEXT_ENTRY(COMMON_ACTIONS_TEMPLATE_ID)),
3477 : : .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
3478 : : args.templ_destroy.template_id)),
3479 : : .call = parse_template_destroy,
3480 : : },
3481 : : [ACTIONS_TEMPLATE_INGRESS] = {
3482 : : .name = "ingress",
3483 : : .help = "attribute actions to ingress",
3484 : : .next = NEXT(next_at_attr),
3485 : : .call = parse_template,
3486 : : },
3487 : : [ACTIONS_TEMPLATE_EGRESS] = {
3488 : : .name = "egress",
3489 : : .help = "attribute actions to egress",
3490 : : .next = NEXT(next_at_attr),
3491 : : .call = parse_template,
3492 : : },
3493 : : [ACTIONS_TEMPLATE_TRANSFER] = {
3494 : : .name = "transfer",
3495 : : .help = "attribute actions to transfer",
3496 : : .next = NEXT(next_at_attr),
3497 : : .call = parse_template,
3498 : : },
3499 : : [ACTIONS_TEMPLATE_SPEC] = {
3500 : : .name = "template",
3501 : : .help = "specify action to create actions template",
3502 : : .next = NEXT(next_action),
3503 : : .call = parse_template,
3504 : : },
3505 : : [ACTIONS_TEMPLATE_MASK] = {
3506 : : .name = "mask",
3507 : : .help = "specify action mask to create actions template",
3508 : : .next = NEXT(next_action),
3509 : : .call = parse_template,
3510 : : },
3511 : : /* Top-level command. */
3512 : : [TABLE] = {
3513 : : .name = "template_table",
3514 : : .type = "{command} {port_id} [{arg} [...]]",
3515 : : .help = "manage template tables",
3516 : : .next = NEXT(next_table_subcmd, NEXT_ENTRY(COMMON_PORT_ID)),
3517 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3518 : : .call = parse_table,
3519 : : },
3520 : : /* Sub-level commands. */
3521 : : [TABLE_CREATE] = {
3522 : : .name = "create",
3523 : : .help = "create template table",
3524 : : .next = NEXT(next_table_attr),
3525 : : .call = parse_table,
3526 : : },
3527 : : [TABLE_DESTROY] = {
3528 : : .name = "destroy",
3529 : : .help = "destroy template table",
3530 : : .next = NEXT(NEXT_ENTRY(TABLE_DESTROY_ID)),
3531 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3532 : : .call = parse_table_destroy,
3533 : : },
3534 : : [TABLE_RESIZE] = {
3535 : : .name = "resize",
3536 : : .help = "resize template table",
3537 : : .next = NEXT(NEXT_ENTRY(TABLE_RESIZE_ID)),
3538 : : .call = parse_table
3539 : : },
3540 : : [TABLE_RESIZE_COMPLETE] = {
3541 : : .name = "resize_complete",
3542 : : .help = "complete table resize",
3543 : : .next = NEXT(NEXT_ENTRY(TABLE_DESTROY_ID)),
3544 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3545 : : .call = parse_table_destroy,
3546 : : },
3547 : : /* Table arguments. */
3548 : : [TABLE_CREATE_ID] = {
3549 : : .name = "table_id",
3550 : : .help = "specify table id to create",
3551 : : .next = NEXT(next_table_attr,
3552 : : NEXT_ENTRY(COMMON_TABLE_ID)),
3553 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.table.id)),
3554 : : },
3555 : : [TABLE_DESTROY_ID] = {
3556 : : .name = "table",
3557 : : .help = "table id",
3558 : : .next = NEXT(next_table_destroy_attr,
3559 : : NEXT_ENTRY(COMMON_TABLE_ID)),
3560 : : .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
3561 : : args.table_destroy.table_id)),
3562 : : .call = parse_table_destroy,
3563 : : },
3564 : : [TABLE_RESIZE_ID] = {
3565 : : .name = "table_resize_id",
3566 : : .help = "table resize id",
3567 : : .next = NEXT(NEXT_ENTRY(TABLE_RESIZE_RULES_NUMBER),
3568 : : NEXT_ENTRY(COMMON_TABLE_ID)),
3569 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.table.id)),
3570 : : .call = parse_table
3571 : : },
3572 : : [TABLE_RESIZE_RULES_NUMBER] = {
3573 : : .name = "table_resize_rules_num",
3574 : : .help = "table resize rules number",
3575 : : .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(COMMON_UNSIGNED)),
3576 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3577 : : args.table.attr.nb_flows)),
3578 : : .call = parse_table
3579 : : },
3580 : : [TABLE_INSERTION_TYPE] = {
3581 : : .name = "insertion_type",
3582 : : .help = "specify insertion type",
3583 : : .next = NEXT(next_table_attr,
3584 : : NEXT_ENTRY(TABLE_INSERTION_TYPE_NAME)),
3585 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3586 : : args.table.attr.insertion_type)),
3587 : : },
3588 : : [TABLE_INSERTION_TYPE_NAME] = {
3589 : : .name = "insertion_type_name",
3590 : : .help = "insertion type name",
3591 : : .call = parse_insertion_table_type,
3592 : : .comp = comp_insertion_table_type,
3593 : : },
3594 : : [TABLE_HASH_FUNC] = {
3595 : : .name = "hash_func",
3596 : : .help = "specify hash calculation function",
3597 : : .next = NEXT(next_table_attr,
3598 : : NEXT_ENTRY(TABLE_HASH_FUNC_NAME)),
3599 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3600 : : args.table.attr.hash_func)),
3601 : : },
3602 : : [TABLE_HASH_FUNC_NAME] = {
3603 : : .name = "hash_func_name",
3604 : : .help = "hash calculation function name",
3605 : : .call = parse_hash_table_type,
3606 : : .comp = comp_hash_table_type,
3607 : : },
3608 : : [TABLE_GROUP] = {
3609 : : .name = "group",
3610 : : .help = "specify a group",
3611 : : .next = NEXT(next_table_attr, NEXT_ENTRY(COMMON_GROUP_ID)),
3612 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3613 : : args.table.attr.flow_attr.group)),
3614 : : },
3615 : : [TABLE_PRIORITY] = {
3616 : : .name = "priority",
3617 : : .help = "specify a priority level",
3618 : : .next = NEXT(next_table_attr, NEXT_ENTRY(COMMON_PRIORITY_LEVEL)),
3619 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3620 : : args.table.attr.flow_attr.priority)),
3621 : : },
3622 : : [TABLE_EGRESS] = {
3623 : : .name = "egress",
3624 : : .help = "affect rule to egress",
3625 : : .next = NEXT(next_table_attr),
3626 : : .call = parse_table,
3627 : : },
3628 : : [TABLE_INGRESS] = {
3629 : : .name = "ingress",
3630 : : .help = "affect rule to ingress",
3631 : : .next = NEXT(next_table_attr),
3632 : : .call = parse_table,
3633 : : },
3634 : : [TABLE_TRANSFER] = {
3635 : : .name = "transfer",
3636 : : .help = "affect rule to transfer",
3637 : : .next = NEXT(next_table_attr),
3638 : : .call = parse_table,
3639 : : },
3640 : : [TABLE_TRANSFER_WIRE_ORIG] = {
3641 : : .name = "wire_orig",
3642 : : .help = "affect rule direction to transfer",
3643 : : .next = NEXT(next_table_attr),
3644 : : .call = parse_table,
3645 : : },
3646 : : [TABLE_TRANSFER_VPORT_ORIG] = {
3647 : : .name = "vport_orig",
3648 : : .help = "affect rule direction to transfer",
3649 : : .next = NEXT(next_table_attr),
3650 : : .call = parse_table,
3651 : : },
3652 : : [TABLE_RESIZABLE] = {
3653 : : .name = "resizable",
3654 : : .help = "set resizable attribute",
3655 : : .next = NEXT(next_table_attr),
3656 : : .call = parse_table,
3657 : : },
3658 : : [TABLE_RULES_NUMBER] = {
3659 : : .name = "rules_number",
3660 : : .help = "number of rules in table",
3661 : : .next = NEXT(next_table_attr,
3662 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3663 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3664 : : args.table.attr.nb_flows)),
3665 : : .call = parse_table,
3666 : : },
3667 : : [TABLE_PATTERN_TEMPLATE] = {
3668 : : .name = "pattern_template",
3669 : : .help = "specify pattern template id",
3670 : : .next = NEXT(next_table_attr,
3671 : : NEXT_ENTRY(COMMON_PATTERN_TEMPLATE_ID)),
3672 : : .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
3673 : : args.table.pat_templ_id)),
3674 : : .call = parse_table,
3675 : : },
3676 : : [TABLE_ACTIONS_TEMPLATE] = {
3677 : : .name = "actions_template",
3678 : : .help = "specify actions template id",
3679 : : .next = NEXT(next_table_attr,
3680 : : NEXT_ENTRY(COMMON_ACTIONS_TEMPLATE_ID)),
3681 : : .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
3682 : : args.table.act_templ_id)),
3683 : : .call = parse_table,
3684 : : },
3685 : : /* Top-level command. */
3686 : : [FLOW_GROUP] = {
3687 : : .name = "group",
3688 : : .help = "manage flow groups",
3689 : : .next = NEXT(NEXT_ENTRY(GROUP_ID), NEXT_ENTRY(COMMON_PORT_ID)),
3690 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3691 : : .call = parse_group,
3692 : : },
3693 : : /* Sub-level commands. */
3694 : : [GROUP_SET_MISS_ACTIONS] = {
3695 : : .name = "set_miss_actions",
3696 : : .help = "set group miss actions",
3697 : : .next = NEXT(next_action),
3698 : : .call = parse_group,
3699 : : },
3700 : : /* Group arguments */
3701 : : [GROUP_ID] = {
3702 : : .name = "group_id",
3703 : : .help = "group id",
3704 : : .next = NEXT(next_group_attr, NEXT_ENTRY(COMMON_GROUP_ID)),
3705 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
3706 : : },
3707 : : [GROUP_INGRESS] = {
3708 : : .name = "ingress",
3709 : : .help = "group ingress attr",
3710 : : .next = NEXT(next_group_attr),
3711 : : .call = parse_group,
3712 : : },
3713 : : [GROUP_EGRESS] = {
3714 : : .name = "egress",
3715 : : .help = "group egress attr",
3716 : : .next = NEXT(next_group_attr),
3717 : : .call = parse_group,
3718 : : },
3719 : : [GROUP_TRANSFER] = {
3720 : : .name = "transfer",
3721 : : .help = "group transfer attr",
3722 : : .next = NEXT(next_group_attr),
3723 : : .call = parse_group,
3724 : : },
3725 : : /* Top-level command. */
3726 : : [QUEUE] = {
3727 : : .name = "queue",
3728 : : .help = "queue a flow rule operation",
3729 : : .next = NEXT(next_queue_subcmd, NEXT_ENTRY(COMMON_PORT_ID)),
3730 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3731 : : .call = parse_qo,
3732 : : },
3733 : : /* Sub-level commands. */
3734 : : [QUEUE_CREATE] = {
3735 : : .name = "create",
3736 : : .help = "create a flow rule",
3737 : : .next = NEXT(NEXT_ENTRY(QUEUE_TEMPLATE_TABLE),
3738 : : NEXT_ENTRY(COMMON_QUEUE_ID)),
3739 : : .args = ARGS(ARGS_ENTRY(struct buffer, queue)),
3740 : : .call = parse_qo,
3741 : : },
3742 : : [QUEUE_DESTROY] = {
3743 : : .name = "destroy",
3744 : : .help = "destroy a flow rule",
3745 : : .next = NEXT(NEXT_ENTRY(QUEUE_DESTROY_POSTPONE),
3746 : : NEXT_ENTRY(COMMON_QUEUE_ID)),
3747 : : .args = ARGS(ARGS_ENTRY(struct buffer, queue)),
3748 : : .call = parse_qo_destroy,
3749 : : },
3750 : : [QUEUE_FLOW_UPDATE_RESIZED] = {
3751 : : .name = "update_resized",
3752 : : .help = "update a flow after table resize",
3753 : : .next = NEXT(NEXT_ENTRY(QUEUE_DESTROY_ID),
3754 : : NEXT_ENTRY(COMMON_QUEUE_ID)),
3755 : : .args = ARGS(ARGS_ENTRY(struct buffer, queue)),
3756 : : .call = parse_qo_destroy,
3757 : : },
3758 : : [QUEUE_UPDATE] = {
3759 : : .name = "update",
3760 : : .help = "update a flow rule",
3761 : : .next = NEXT(NEXT_ENTRY(QUEUE_UPDATE_ID),
3762 : : NEXT_ENTRY(COMMON_QUEUE_ID)),
3763 : : .args = ARGS(ARGS_ENTRY(struct buffer, queue)),
3764 : : .call = parse_qo,
3765 : : },
3766 : : [QUEUE_AGED] = {
3767 : : .name = "aged",
3768 : : .help = "list and destroy aged flows",
3769 : : .next = NEXT(next_aged_attr, NEXT_ENTRY(COMMON_QUEUE_ID)),
3770 : : .args = ARGS(ARGS_ENTRY(struct buffer, queue)),
3771 : : .call = parse_aged,
3772 : : },
3773 : : [QUEUE_INDIRECT_ACTION] = {
3774 : : .name = "indirect_action",
3775 : : .help = "queue indirect actions",
3776 : : .next = NEXT(next_qia_subcmd, NEXT_ENTRY(COMMON_QUEUE_ID)),
3777 : : .args = ARGS(ARGS_ENTRY(struct buffer, queue)),
3778 : : .call = parse_qia,
3779 : : },
3780 : : /* Queue arguments. */
3781 : : [QUEUE_TEMPLATE_TABLE] = {
3782 : : .name = "template_table",
3783 : : .help = "specify table id",
3784 : : .next = NEXT(next_async_insert_subcmd,
3785 : : NEXT_ENTRY(COMMON_TABLE_ID)),
3786 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3787 : : args.vc.table_id)),
3788 : : .call = parse_qo,
3789 : : },
3790 : : [QUEUE_PATTERN_TEMPLATE] = {
3791 : : .name = "pattern_template",
3792 : : .help = "specify pattern template index",
3793 : : .next = NEXT(NEXT_ENTRY(QUEUE_ACTIONS_TEMPLATE),
3794 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3795 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3796 : : args.vc.pat_templ_id)),
3797 : : .call = parse_qo,
3798 : : },
3799 : : [QUEUE_ACTIONS_TEMPLATE] = {
3800 : : .name = "actions_template",
3801 : : .help = "specify actions template index",
3802 : : .next = NEXT(NEXT_ENTRY(QUEUE_CREATE_POSTPONE),
3803 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3804 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3805 : : args.vc.act_templ_id)),
3806 : : .call = parse_qo,
3807 : : },
3808 : : [QUEUE_RULE_ID] = {
3809 : : .name = "rule_index",
3810 : : .help = "specify flow rule index",
3811 : : .next = NEXT(next_async_pattern_subcmd,
3812 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3813 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3814 : : args.vc.rule_id)),
3815 : : .call = parse_qo,
3816 : : },
3817 : : [QUEUE_CREATE_POSTPONE] = {
3818 : : .name = "postpone",
3819 : : .help = "postpone create operation",
3820 : : .next = NEXT(NEXT_ENTRY(ITEM_PATTERN),
3821 : : NEXT_ENTRY(COMMON_BOOLEAN)),
3822 : : .args = ARGS(ARGS_ENTRY(struct buffer, postpone)),
3823 : : .call = parse_qo,
3824 : : },
3825 : : [QUEUE_DESTROY_POSTPONE] = {
3826 : : .name = "postpone",
3827 : : .help = "postpone destroy operation",
3828 : : .next = NEXT(NEXT_ENTRY(QUEUE_DESTROY_ID),
3829 : : NEXT_ENTRY(COMMON_BOOLEAN)),
3830 : : .args = ARGS(ARGS_ENTRY(struct buffer, postpone)),
3831 : : .call = parse_qo_destroy,
3832 : : },
3833 : : [QUEUE_DESTROY_ID] = {
3834 : : .name = "rule",
3835 : : .help = "specify rule id to destroy",
3836 : : .next = NEXT(next_queue_destroy_attr,
3837 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3838 : : .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
3839 : : args.destroy.rule)),
3840 : : .call = parse_qo_destroy,
3841 : : },
3842 : : [QUEUE_UPDATE_ID] = {
3843 : : .name = "rule",
3844 : : .help = "specify rule id to update",
3845 : : .next = NEXT(NEXT_ENTRY(QUEUE_ACTIONS_TEMPLATE),
3846 : : NEXT_ENTRY(COMMON_UNSIGNED)),
3847 : : .args = ARGS(ARGS_ENTRY(struct buffer,
3848 : : args.vc.rule_id)),
3849 : : .call = parse_qo,
3850 : : },
3851 : : /* Queue indirect action arguments */
3852 : : [QUEUE_INDIRECT_ACTION_CREATE] = {
3853 : : .name = "create",
3854 : : .help = "create indirect action",
3855 : : .next = NEXT(next_qia_create_attr),
3856 : : .call = parse_qia,
3857 : : },
3858 : : [QUEUE_INDIRECT_ACTION_UPDATE] = {
3859 : : .name = "update",
3860 : : .help = "update indirect action",
3861 : : .next = NEXT(next_qia_update_attr,
3862 : : NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
3863 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
3864 : : .call = parse_qia,
3865 : : },
3866 : : [QUEUE_INDIRECT_ACTION_DESTROY] = {
3867 : : .name = "destroy",
3868 : : .help = "destroy indirect action",
3869 : : .next = NEXT(next_qia_destroy_attr),
3870 : : .call = parse_qia_destroy,
3871 : : },
3872 : : [QUEUE_INDIRECT_ACTION_QUERY] = {
3873 : : .name = "query",
3874 : : .help = "query indirect action",
3875 : : .next = NEXT(next_qia_query_attr,
3876 : : NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
3877 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.ia.action_id)),
3878 : : .call = parse_qia,
3879 : : },
3880 : : /* Indirect action destroy arguments. */
3881 : : [QUEUE_INDIRECT_ACTION_DESTROY_POSTPONE] = {
3882 : : .name = "postpone",
3883 : : .help = "postpone destroy operation",
3884 : : .next = NEXT(next_qia_destroy_attr,
3885 : : NEXT_ENTRY(COMMON_BOOLEAN)),
3886 : : .args = ARGS(ARGS_ENTRY(struct buffer, postpone)),
3887 : : },
3888 : : [QUEUE_INDIRECT_ACTION_DESTROY_ID] = {
3889 : : .name = "action_id",
3890 : : .help = "specify a indirect action id to destroy",
3891 : : .next = NEXT(next_qia_destroy_attr,
3892 : : NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
3893 : : .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
3894 : : args.ia_destroy.action_id)),
3895 : : .call = parse_qia_destroy,
3896 : : },
3897 : : [QUEUE_INDIRECT_ACTION_QUERY_UPDATE] = {
3898 : : .name = "query_update",
3899 : : .help = "indirect query [and|or] update action",
3900 : : .next = NEXT(next_qia_qu_attr, NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
3901 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.ia.action_id)),
3902 : : .call = parse_qia
3903 : : },
3904 : : [QUEUE_INDIRECT_ACTION_QU_MODE] = {
3905 : : .name = "mode",
3906 : : .help = "indirect query [and|or] update action",
3907 : : .next = NEXT(next_qia_qu_attr,
3908 : : NEXT_ENTRY(INDIRECT_ACTION_QU_MODE_NAME)),
3909 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.ia.qu_mode)),
3910 : : .call = parse_qia
3911 : : },
3912 : : /* Indirect action update arguments. */
3913 : : [QUEUE_INDIRECT_ACTION_UPDATE_POSTPONE] = {
3914 : : .name = "postpone",
3915 : : .help = "postpone update operation",
3916 : : .next = NEXT(next_qia_update_attr,
3917 : : NEXT_ENTRY(COMMON_BOOLEAN)),
3918 : : .args = ARGS(ARGS_ENTRY(struct buffer, postpone)),
3919 : : },
3920 : : /* Indirect action update arguments. */
3921 : : [QUEUE_INDIRECT_ACTION_QUERY_POSTPONE] = {
3922 : : .name = "postpone",
3923 : : .help = "postpone query operation",
3924 : : .next = NEXT(next_qia_query_attr,
3925 : : NEXT_ENTRY(COMMON_BOOLEAN)),
3926 : : .args = ARGS(ARGS_ENTRY(struct buffer, postpone)),
3927 : : },
3928 : : /* Indirect action create arguments. */
3929 : : [QUEUE_INDIRECT_ACTION_CREATE_ID] = {
3930 : : .name = "action_id",
3931 : : .help = "specify a indirect action id to create",
3932 : : .next = NEXT(next_qia_create_attr,
3933 : : NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
3934 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
3935 : : },
3936 : : [QUEUE_INDIRECT_ACTION_INGRESS] = {
3937 : : .name = "ingress",
3938 : : .help = "affect rule to ingress",
3939 : : .next = NEXT(next_qia_create_attr),
3940 : : .call = parse_qia,
3941 : : },
3942 : : [QUEUE_INDIRECT_ACTION_EGRESS] = {
3943 : : .name = "egress",
3944 : : .help = "affect rule to egress",
3945 : : .next = NEXT(next_qia_create_attr),
3946 : : .call = parse_qia,
3947 : : },
3948 : : [QUEUE_INDIRECT_ACTION_TRANSFER] = {
3949 : : .name = "transfer",
3950 : : .help = "affect rule to transfer",
3951 : : .next = NEXT(next_qia_create_attr),
3952 : : .call = parse_qia,
3953 : : },
3954 : : [QUEUE_INDIRECT_ACTION_CREATE_POSTPONE] = {
3955 : : .name = "postpone",
3956 : : .help = "postpone create operation",
3957 : : .next = NEXT(next_qia_create_attr,
3958 : : NEXT_ENTRY(COMMON_BOOLEAN)),
3959 : : .args = ARGS(ARGS_ENTRY(struct buffer, postpone)),
3960 : : },
3961 : : [QUEUE_INDIRECT_ACTION_SPEC] = {
3962 : : .name = "action",
3963 : : .help = "specify action to create indirect handle",
3964 : : .next = NEXT(next_action),
3965 : : },
3966 : : [QUEUE_INDIRECT_ACTION_LIST] = {
3967 : : .name = "list",
3968 : : .help = "specify actions for indirect handle list",
3969 : : .next = NEXT(NEXT_ENTRY(ACTIONS, END)),
3970 : : .call = parse_qia,
3971 : : },
3972 : : /* Top-level command. */
3973 : : [PUSH] = {
3974 : : .name = "push",
3975 : : .help = "push enqueued operations",
3976 : : .next = NEXT(NEXT_ENTRY(PUSH_QUEUE), NEXT_ENTRY(COMMON_PORT_ID)),
3977 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3978 : : .call = parse_push,
3979 : : },
3980 : : /* Sub-level commands. */
3981 : : [PUSH_QUEUE] = {
3982 : : .name = "queue",
3983 : : .help = "specify queue id",
3984 : : .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(COMMON_QUEUE_ID)),
3985 : : .args = ARGS(ARGS_ENTRY(struct buffer, queue)),
3986 : : },
3987 : : /* Top-level command. */
3988 : : [PULL] = {
3989 : : .name = "pull",
3990 : : .help = "pull flow operations results",
3991 : : .next = NEXT(NEXT_ENTRY(PULL_QUEUE), NEXT_ENTRY(COMMON_PORT_ID)),
3992 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
3993 : : .call = parse_pull,
3994 : : },
3995 : : /* Sub-level commands. */
3996 : : [PULL_QUEUE] = {
3997 : : .name = "queue",
3998 : : .help = "specify queue id",
3999 : : .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(COMMON_QUEUE_ID)),
4000 : : .args = ARGS(ARGS_ENTRY(struct buffer, queue)),
4001 : : },
4002 : : /* Top-level command. */
4003 : : [HASH] = {
4004 : : .name = "hash",
4005 : : .help = "calculate hash for a given pattern in a given template table",
4006 : : .next = NEXT(next_hash_subcmd, NEXT_ENTRY(COMMON_PORT_ID)),
4007 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
4008 : : .call = parse_hash,
4009 : : },
4010 : : /* Sub-level commands. */
4011 : : [HASH_CALC_TABLE] = {
4012 : : .name = "template_table",
4013 : : .help = "specify table id",
4014 : : .next = NEXT(NEXT_ENTRY(HASH_CALC_PATTERN_INDEX),
4015 : : NEXT_ENTRY(COMMON_TABLE_ID)),
4016 : : .args = ARGS(ARGS_ENTRY(struct buffer,
4017 : : args.vc.table_id)),
4018 : : .call = parse_hash,
4019 : : },
4020 : : [HASH_CALC_ENCAP] = {
4021 : : .name = "encap",
4022 : : .help = "calculates encap hash",
4023 : : .next = NEXT(next_hash_encap_dest_subcmd),
4024 : : .call = parse_hash,
4025 : : },
4026 : : [HASH_CALC_PATTERN_INDEX] = {
4027 : : .name = "pattern_template",
4028 : : .help = "specify pattern template id",
4029 : : .next = NEXT(NEXT_ENTRY(ITEM_PATTERN),
4030 : : NEXT_ENTRY(COMMON_UNSIGNED)),
4031 : : .args = ARGS(ARGS_ENTRY(struct buffer,
4032 : : args.vc.pat_templ_id)),
4033 : : .call = parse_hash,
4034 : : },
4035 : : [ENCAP_HASH_FIELD_SRC_PORT] = {
4036 : : .name = "hash_field_sport",
4037 : : .help = "the encap hash field is src port",
4038 : : .next = NEXT(NEXT_ENTRY(ITEM_PATTERN)),
4039 : : .call = parse_hash,
4040 : : },
4041 : : [ENCAP_HASH_FIELD_GRE_FLOW_ID] = {
4042 : : .name = "hash_field_flow_id",
4043 : : .help = "the encap hash field is NVGRE flow id",
4044 : : .next = NEXT(NEXT_ENTRY(ITEM_PATTERN)),
4045 : : .call = parse_hash,
4046 : : },
4047 : : /* Top-level command. */
4048 : : [INDIRECT_ACTION] = {
4049 : : .name = "indirect_action",
4050 : : .type = "{command} {port_id} [{arg} [...]]",
4051 : : .help = "manage indirect actions",
4052 : : .next = NEXT(next_ia_subcmd, NEXT_ENTRY(COMMON_PORT_ID)),
4053 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
4054 : : .call = parse_ia,
4055 : : },
4056 : : /* Sub-level commands. */
4057 : : [INDIRECT_ACTION_CREATE] = {
4058 : : .name = "create",
4059 : : .help = "create indirect action",
4060 : : .next = NEXT(next_ia_create_attr),
4061 : : .call = parse_ia,
4062 : : },
4063 : : [INDIRECT_ACTION_UPDATE] = {
4064 : : .name = "update",
4065 : : .help = "update indirect action",
4066 : : .next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_SPEC),
4067 : : NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
4068 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
4069 : : .call = parse_ia,
4070 : : },
4071 : : [INDIRECT_ACTION_DESTROY] = {
4072 : : .name = "destroy",
4073 : : .help = "destroy indirect action",
4074 : : .next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_DESTROY_ID)),
4075 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
4076 : : .call = parse_ia_destroy,
4077 : : },
4078 : : [INDIRECT_ACTION_QUERY] = {
4079 : : .name = "query",
4080 : : .help = "query indirect action",
4081 : : .next = NEXT(NEXT_ENTRY(END),
4082 : : NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
4083 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.ia.action_id)),
4084 : : .call = parse_ia,
4085 : : },
4086 : : [INDIRECT_ACTION_QUERY_UPDATE] = {
4087 : : .name = "query_update",
4088 : : .help = "query [and|or] update",
4089 : : .next = NEXT(next_ia_qu_attr, 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_QU_MODE] = {
4094 : : .name = "mode",
4095 : : .help = "query_update mode",
4096 : : .next = NEXT(next_ia_qu_attr,
4097 : : NEXT_ENTRY(INDIRECT_ACTION_QU_MODE_NAME)),
4098 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.ia.qu_mode)),
4099 : : .call = parse_ia,
4100 : : },
4101 : : [INDIRECT_ACTION_QU_MODE_NAME] = {
4102 : : .name = "mode_name",
4103 : : .help = "query-update mode name",
4104 : : .call = parse_qu_mode_name,
4105 : : .comp = comp_qu_mode_name,
4106 : : },
4107 : : [VALIDATE] = {
4108 : : .name = "validate",
4109 : : .help = "check whether a flow rule can be created",
4110 : : .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_PORT_ID)),
4111 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
4112 : : .call = parse_vc,
4113 : : },
4114 : : [CREATE] = {
4115 : : .name = "create",
4116 : : .help = "create a flow rule",
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 : : [DESTROY] = {
4122 : : .name = "destroy",
4123 : : .help = "destroy specific flow rules",
4124 : : .next = NEXT(next_destroy_attr,
4125 : : NEXT_ENTRY(COMMON_PORT_ID)),
4126 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
4127 : : .call = parse_destroy,
4128 : : },
4129 : : [UPDATE] = {
4130 : : .name = "update",
4131 : : .help = "update a flow rule with new actions",
4132 : : .next = NEXT(NEXT_ENTRY(VC_IS_USER_ID, END),
4133 : : NEXT_ENTRY(ACTIONS),
4134 : : NEXT_ENTRY(COMMON_RULE_ID),
4135 : : NEXT_ENTRY(COMMON_PORT_ID)),
4136 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.rule_id),
4137 : : ARGS_ENTRY(struct buffer, port)),
4138 : : .call = parse_vc,
4139 : : },
4140 : : [FLUSH] = {
4141 : : .name = "flush",
4142 : : .help = "destroy all flow rules",
4143 : : .next = NEXT(NEXT_ENTRY(COMMON_PORT_ID)),
4144 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
4145 : : .call = parse_flush,
4146 : : },
4147 : : [DUMP] = {
4148 : : .name = "dump",
4149 : : .help = "dump single/all flow rules to file",
4150 : : .next = NEXT(next_dump_subcmd, NEXT_ENTRY(COMMON_PORT_ID)),
4151 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
4152 : : .call = parse_dump,
4153 : : },
4154 : : [QUERY] = {
4155 : : .name = "query",
4156 : : .help = "query an existing flow rule",
4157 : : .next = NEXT(next_query_attr, NEXT_ENTRY(QUERY_ACTION),
4158 : : NEXT_ENTRY(COMMON_RULE_ID),
4159 : : NEXT_ENTRY(COMMON_PORT_ID)),
4160 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.query.action.type),
4161 : : ARGS_ENTRY(struct buffer, args.query.rule),
4162 : : ARGS_ENTRY(struct buffer, port)),
4163 : : .call = parse_query,
4164 : : },
4165 : : [LIST] = {
4166 : : .name = "list",
4167 : : .help = "list existing flow rules",
4168 : : .next = NEXT(next_list_attr, NEXT_ENTRY(COMMON_PORT_ID)),
4169 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
4170 : : .call = parse_list,
4171 : : },
4172 : : [AGED] = {
4173 : : .name = "aged",
4174 : : .help = "list and destroy aged flows",
4175 : : .next = NEXT(next_aged_attr, NEXT_ENTRY(COMMON_PORT_ID)),
4176 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
4177 : : .call = parse_aged,
4178 : : },
4179 : : [ISOLATE] = {
4180 : : .name = "isolate",
4181 : : .help = "restrict ingress traffic to the defined flow rules",
4182 : : .next = NEXT(NEXT_ENTRY(COMMON_BOOLEAN),
4183 : : NEXT_ENTRY(COMMON_PORT_ID)),
4184 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.isolate.set),
4185 : : ARGS_ENTRY(struct buffer, port)),
4186 : : .call = parse_isolate,
4187 : : },
4188 : : [FLEX] = {
4189 : : .name = "flex_item",
4190 : : .help = "flex item API",
4191 : : .next = NEXT(next_flex_item),
4192 : : .call = parse_flex,
4193 : : },
4194 : : [FLEX_ITEM_CREATE] = {
4195 : : .name = "create",
4196 : : .help = "flex item create",
4197 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.flex.filename),
4198 : : ARGS_ENTRY(struct buffer, args.flex.token),
4199 : : ARGS_ENTRY(struct buffer, port)),
4200 : : .next = NEXT(NEXT_ENTRY(COMMON_FILE_PATH),
4201 : : NEXT_ENTRY(COMMON_FLEX_TOKEN),
4202 : : NEXT_ENTRY(COMMON_PORT_ID)),
4203 : : .call = parse_flex
4204 : : },
4205 : : [FLEX_ITEM_DESTROY] = {
4206 : : .name = "destroy",
4207 : : .help = "flex item destroy",
4208 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.flex.token),
4209 : : ARGS_ENTRY(struct buffer, port)),
4210 : : .next = NEXT(NEXT_ENTRY(COMMON_FLEX_TOKEN),
4211 : : NEXT_ENTRY(COMMON_PORT_ID)),
4212 : : .call = parse_flex
4213 : : },
4214 : : [TUNNEL] = {
4215 : : .name = "tunnel",
4216 : : .help = "new tunnel API",
4217 : : .next = NEXT(NEXT_ENTRY
4218 : : (TUNNEL_CREATE, TUNNEL_LIST, TUNNEL_DESTROY)),
4219 : : .call = parse_tunnel,
4220 : : },
4221 : : /* Tunnel arguments. */
4222 : : [TUNNEL_CREATE] = {
4223 : : .name = "create",
4224 : : .help = "create new tunnel object",
4225 : : .next = NEXT(NEXT_ENTRY(TUNNEL_CREATE_TYPE),
4226 : : NEXT_ENTRY(COMMON_PORT_ID)),
4227 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
4228 : : .call = parse_tunnel,
4229 : : },
4230 : : [TUNNEL_CREATE_TYPE] = {
4231 : : .name = "type",
4232 : : .help = "create new tunnel",
4233 : : .next = NEXT(NEXT_ENTRY(COMMON_FILE_PATH)),
4234 : : .args = ARGS(ARGS_ENTRY(struct tunnel_ops, type)),
4235 : : .call = parse_tunnel,
4236 : : },
4237 : : [TUNNEL_DESTROY] = {
4238 : : .name = "destroy",
4239 : : .help = "destroy tunnel",
4240 : : .next = NEXT(NEXT_ENTRY(TUNNEL_DESTROY_ID),
4241 : : NEXT_ENTRY(COMMON_PORT_ID)),
4242 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
4243 : : .call = parse_tunnel,
4244 : : },
4245 : : [TUNNEL_DESTROY_ID] = {
4246 : : .name = "id",
4247 : : .help = "tunnel identifier to destroy",
4248 : : .next = NEXT(NEXT_ENTRY(COMMON_UNSIGNED)),
4249 : : .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
4250 : : .call = parse_tunnel,
4251 : : },
4252 : : [TUNNEL_LIST] = {
4253 : : .name = "list",
4254 : : .help = "list existing tunnels",
4255 : : .next = NEXT(NEXT_ENTRY(COMMON_PORT_ID)),
4256 : : .args = ARGS(ARGS_ENTRY(struct buffer, port)),
4257 : : .call = parse_tunnel,
4258 : : },
4259 : : /* Destroy arguments. */
4260 : : [DESTROY_RULE] = {
4261 : : .name = "rule",
4262 : : .help = "specify a rule identifier",
4263 : : .next = NEXT(next_destroy_attr, NEXT_ENTRY(COMMON_RULE_ID)),
4264 : : .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.destroy.rule)),
4265 : : .call = parse_destroy,
4266 : : },
4267 : : [DESTROY_IS_USER_ID] = {
4268 : : .name = "user_id",
4269 : : .help = "rule identifier is user-id",
4270 : : .next = NEXT(next_destroy_attr),
4271 : : .call = parse_destroy,
4272 : : },
4273 : : /* Dump arguments. */
4274 : : [DUMP_ALL] = {
4275 : : .name = "all",
4276 : : .help = "dump all",
4277 : : .next = NEXT(next_dump_attr),
4278 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file)),
4279 : : .call = parse_dump,
4280 : : },
4281 : : [DUMP_ONE] = {
4282 : : .name = "rule",
4283 : : .help = "dump one rule",
4284 : : .next = NEXT(next_dump_attr, NEXT_ENTRY(COMMON_RULE_ID)),
4285 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.dump.file),
4286 : : ARGS_ENTRY(struct buffer, args.dump.rule)),
4287 : : .call = parse_dump,
4288 : : },
4289 : : [DUMP_IS_USER_ID] = {
4290 : : .name = "user_id",
4291 : : .help = "rule identifier is user-id",
4292 : : .next = NEXT(next_dump_subcmd),
4293 : : .call = parse_dump,
4294 : : },
4295 : : /* Query arguments. */
4296 : : [QUERY_ACTION] = {
4297 : : .name = "{action}",
4298 : : .type = "ACTION",
4299 : : .help = "action to query, must be part of the rule",
4300 : : .call = parse_action,
4301 : : .comp = comp_action,
4302 : : },
4303 : : [QUERY_IS_USER_ID] = {
4304 : : .name = "user_id",
4305 : : .help = "rule identifier is user-id",
4306 : : .next = NEXT(next_query_attr),
4307 : : .call = parse_query,
4308 : : },
4309 : : /* List arguments. */
4310 : : [LIST_GROUP] = {
4311 : : .name = "group",
4312 : : .help = "specify a group",
4313 : : .next = NEXT(next_list_attr, NEXT_ENTRY(COMMON_GROUP_ID)),
4314 : : .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.list.group)),
4315 : : .call = parse_list,
4316 : : },
4317 : : [AGED_DESTROY] = {
4318 : : .name = "destroy",
4319 : : .help = "specify aged flows need be destroyed",
4320 : : .call = parse_aged,
4321 : : .comp = comp_none,
4322 : : },
4323 : : /* Validate/create attributes. */
4324 : : [VC_GROUP] = {
4325 : : .name = "group",
4326 : : .help = "specify a group",
4327 : : .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_GROUP_ID)),
4328 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, group)),
4329 : : .call = parse_vc,
4330 : : },
4331 : : [VC_PRIORITY] = {
4332 : : .name = "priority",
4333 : : .help = "specify a priority level",
4334 : : .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_PRIORITY_LEVEL)),
4335 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_attr, priority)),
4336 : : .call = parse_vc,
4337 : : },
4338 : : [VC_INGRESS] = {
4339 : : .name = "ingress",
4340 : : .help = "affect rule to ingress",
4341 : : .next = NEXT(next_vc_attr),
4342 : : .call = parse_vc,
4343 : : },
4344 : : [VC_EGRESS] = {
4345 : : .name = "egress",
4346 : : .help = "affect rule to egress",
4347 : : .next = NEXT(next_vc_attr),
4348 : : .call = parse_vc,
4349 : : },
4350 : : [VC_TRANSFER] = {
4351 : : .name = "transfer",
4352 : : .help = "apply rule directly to endpoints found in pattern",
4353 : : .next = NEXT(next_vc_attr),
4354 : : .call = parse_vc,
4355 : : },
4356 : : [VC_TUNNEL_SET] = {
4357 : : .name = "tunnel_set",
4358 : : .help = "tunnel steer rule",
4359 : : .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_UNSIGNED)),
4360 : : .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
4361 : : .call = parse_vc,
4362 : : },
4363 : : [VC_TUNNEL_MATCH] = {
4364 : : .name = "tunnel_match",
4365 : : .help = "tunnel match rule",
4366 : : .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_UNSIGNED)),
4367 : : .args = ARGS(ARGS_ENTRY(struct tunnel_ops, id)),
4368 : : .call = parse_vc,
4369 : : },
4370 : : [VC_USER_ID] = {
4371 : : .name = "user_id",
4372 : : .help = "specify a user id to create",
4373 : : .next = NEXT(next_vc_attr, NEXT_ENTRY(COMMON_UNSIGNED)),
4374 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.user_id)),
4375 : : .call = parse_vc,
4376 : : },
4377 : : [VC_IS_USER_ID] = {
4378 : : .name = "user_id",
4379 : : .help = "rule identifier is user-id",
4380 : : .call = parse_vc,
4381 : : },
4382 : : /* Validate/create pattern. */
4383 : : [ITEM_PATTERN] = {
4384 : : .name = "pattern",
4385 : : .help = "submit a list of pattern items",
4386 : : .next = NEXT(next_item),
4387 : : .call = parse_vc,
4388 : : },
4389 : : [ITEM_PARAM_IS] = {
4390 : : .name = "is",
4391 : : .help = "match value perfectly (with full bit-mask)",
4392 : : .call = parse_vc_spec,
4393 : : },
4394 : : [ITEM_PARAM_SPEC] = {
4395 : : .name = "spec",
4396 : : .help = "match value according to configured bit-mask",
4397 : : .call = parse_vc_spec,
4398 : : },
4399 : : [ITEM_PARAM_LAST] = {
4400 : : .name = "last",
4401 : : .help = "specify upper bound to establish a range",
4402 : : .call = parse_vc_spec,
4403 : : },
4404 : : [ITEM_PARAM_MASK] = {
4405 : : .name = "mask",
4406 : : .help = "specify bit-mask with relevant bits set to one",
4407 : : .call = parse_vc_spec,
4408 : : },
4409 : : [ITEM_PARAM_PREFIX] = {
4410 : : .name = "prefix",
4411 : : .help = "generate bit-mask from a prefix length",
4412 : : .call = parse_vc_spec,
4413 : : },
4414 : : [ITEM_NEXT] = {
4415 : : .name = "/",
4416 : : .help = "specify next pattern item",
4417 : : .next = NEXT(next_item),
4418 : : },
4419 : : [ITEM_END] = {
4420 : : .name = "end",
4421 : : .help = "end list of pattern items",
4422 : : .priv = PRIV_ITEM(END, 0),
4423 : : .next = NEXT(NEXT_ENTRY(ACTIONS, END)),
4424 : : .call = parse_vc,
4425 : : },
4426 : : [ITEM_VOID] = {
4427 : : .name = "void",
4428 : : .help = "no-op pattern item",
4429 : : .priv = PRIV_ITEM(VOID, 0),
4430 : : .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
4431 : : .call = parse_vc,
4432 : : },
4433 : : [ITEM_INVERT] = {
4434 : : .name = "invert",
4435 : : .help = "perform actions when pattern does not match",
4436 : : .priv = PRIV_ITEM(INVERT, 0),
4437 : : .next = NEXT(NEXT_ENTRY(ITEM_NEXT)),
4438 : : .call = parse_vc,
4439 : : },
4440 : : [ITEM_ANY] = {
4441 : : .name = "any",
4442 : : .help = "match any protocol for the current layer",
4443 : : .priv = PRIV_ITEM(ANY, sizeof(struct rte_flow_item_any)),
4444 : : .next = NEXT(item_any),
4445 : : .call = parse_vc,
4446 : : },
4447 : : [ITEM_ANY_NUM] = {
4448 : : .name = "num",
4449 : : .help = "number of layers covered",
4450 : : .next = NEXT(item_any, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
4451 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_any, num)),
4452 : : },
4453 : : [ITEM_PORT_ID] = {
4454 : : .name = "port_id",
4455 : : .help = "match traffic from/to a given DPDK port ID",
4456 : : .priv = PRIV_ITEM(PORT_ID,
4457 : : sizeof(struct rte_flow_item_port_id)),
4458 : : .next = NEXT(item_port_id),
4459 : : .call = parse_vc,
4460 : : },
4461 : : [ITEM_PORT_ID_ID] = {
4462 : : .name = "id",
4463 : : .help = "DPDK port ID",
4464 : : .next = NEXT(item_port_id, NEXT_ENTRY(COMMON_UNSIGNED),
4465 : : item_param),
4466 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port_id, id)),
4467 : : },
4468 : : [ITEM_MARK] = {
4469 : : .name = "mark",
4470 : : .help = "match traffic against value set in previously matched rule",
4471 : : .priv = PRIV_ITEM(MARK, sizeof(struct rte_flow_item_mark)),
4472 : : .next = NEXT(item_mark),
4473 : : .call = parse_vc,
4474 : : },
4475 : : [ITEM_MARK_ID] = {
4476 : : .name = "id",
4477 : : .help = "Integer value to match against",
4478 : : .next = NEXT(item_mark, NEXT_ENTRY(COMMON_UNSIGNED),
4479 : : item_param),
4480 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_mark, id)),
4481 : : },
4482 : : [ITEM_RAW] = {
4483 : : .name = "raw",
4484 : : .help = "match an arbitrary byte string",
4485 : : .priv = PRIV_ITEM(RAW, ITEM_RAW_SIZE),
4486 : : .next = NEXT(item_raw),
4487 : : .call = parse_vc,
4488 : : },
4489 : : [ITEM_RAW_RELATIVE] = {
4490 : : .name = "relative",
4491 : : .help = "look for pattern after the previous item",
4492 : : .next = NEXT(item_raw, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
4493 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
4494 : : relative, 1)),
4495 : : },
4496 : : [ITEM_RAW_SEARCH] = {
4497 : : .name = "search",
4498 : : .help = "search pattern from offset (see also limit)",
4499 : : .next = NEXT(item_raw, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
4500 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_raw,
4501 : : search, 1)),
4502 : : },
4503 : : [ITEM_RAW_OFFSET] = {
4504 : : .name = "offset",
4505 : : .help = "absolute or relative offset for pattern",
4506 : : .next = NEXT(item_raw, NEXT_ENTRY(COMMON_INTEGER), item_param),
4507 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, offset)),
4508 : : },
4509 : : [ITEM_RAW_LIMIT] = {
4510 : : .name = "limit",
4511 : : .help = "search area limit for start of pattern",
4512 : : .next = NEXT(item_raw, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
4513 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, limit)),
4514 : : },
4515 : : [ITEM_RAW_PATTERN] = {
4516 : : .name = "pattern",
4517 : : .help = "byte string to look for",
4518 : : .next = NEXT(item_raw,
4519 : : NEXT_ENTRY(COMMON_STRING),
4520 : : NEXT_ENTRY(ITEM_PARAM_IS,
4521 : : ITEM_PARAM_SPEC,
4522 : : ITEM_PARAM_MASK)),
4523 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern),
4524 : : ARGS_ENTRY(struct rte_flow_item_raw, length),
4525 : : ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw),
4526 : : ITEM_RAW_PATTERN_SIZE)),
4527 : : },
4528 : : [ITEM_RAW_PATTERN_HEX] = {
4529 : : .name = "pattern_hex",
4530 : : .help = "hex string to look for",
4531 : : .next = NEXT(item_raw,
4532 : : NEXT_ENTRY(COMMON_HEX),
4533 : : NEXT_ENTRY(ITEM_PARAM_IS,
4534 : : ITEM_PARAM_SPEC,
4535 : : ITEM_PARAM_MASK)),
4536 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_raw, pattern),
4537 : : ARGS_ENTRY(struct rte_flow_item_raw, length),
4538 : : ARGS_ENTRY_ARB(sizeof(struct rte_flow_item_raw),
4539 : : ITEM_RAW_PATTERN_SIZE)),
4540 : : },
4541 : : [ITEM_ETH] = {
4542 : : .name = "eth",
4543 : : .help = "match Ethernet header",
4544 : : .priv = PRIV_ITEM(ETH, sizeof(struct rte_flow_item_eth)),
4545 : : .next = NEXT(item_eth),
4546 : : .call = parse_vc,
4547 : : },
4548 : : [ITEM_ETH_DST] = {
4549 : : .name = "dst",
4550 : : .help = "destination MAC",
4551 : : .next = NEXT(item_eth, NEXT_ENTRY(COMMON_MAC_ADDR), item_param),
4552 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, hdr.dst_addr)),
4553 : : },
4554 : : [ITEM_ETH_SRC] = {
4555 : : .name = "src",
4556 : : .help = "source MAC",
4557 : : .next = NEXT(item_eth, NEXT_ENTRY(COMMON_MAC_ADDR), item_param),
4558 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, hdr.src_addr)),
4559 : : },
4560 : : [ITEM_ETH_TYPE] = {
4561 : : .name = "type",
4562 : : .help = "EtherType",
4563 : : .next = NEXT(item_eth, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
4564 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_eth, hdr.ether_type)),
4565 : : },
4566 : : [ITEM_ETH_HAS_VLAN] = {
4567 : : .name = "has_vlan",
4568 : : .help = "packet header contains VLAN",
4569 : : .next = NEXT(item_eth, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
4570 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_eth,
4571 : : has_vlan, 1)),
4572 : : },
4573 : : [ITEM_VLAN] = {
4574 : : .name = "vlan",
4575 : : .help = "match 802.1Q/ad VLAN tag",
4576 : : .priv = PRIV_ITEM(VLAN, sizeof(struct rte_flow_item_vlan)),
4577 : : .next = NEXT(item_vlan),
4578 : : .call = parse_vc,
4579 : : },
4580 : : [ITEM_VLAN_TCI] = {
4581 : : .name = "tci",
4582 : : .help = "tag control information",
4583 : : .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
4584 : : item_param),
4585 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan, hdr.vlan_tci)),
4586 : : },
4587 : : [ITEM_VLAN_PCP] = {
4588 : : .name = "pcp",
4589 : : .help = "priority code point",
4590 : : .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
4591 : : item_param),
4592 : : .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
4593 : : hdr.vlan_tci, "\xe0\x00")),
4594 : : },
4595 : : [ITEM_VLAN_DEI] = {
4596 : : .name = "dei",
4597 : : .help = "drop eligible indicator",
4598 : : .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
4599 : : item_param),
4600 : : .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
4601 : : hdr.vlan_tci, "\x10\x00")),
4602 : : },
4603 : : [ITEM_VLAN_VID] = {
4604 : : .name = "vid",
4605 : : .help = "VLAN identifier",
4606 : : .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
4607 : : item_param),
4608 : : .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_vlan,
4609 : : hdr.vlan_tci, "\x0f\xff")),
4610 : : },
4611 : : [ITEM_VLAN_INNER_TYPE] = {
4612 : : .name = "inner_type",
4613 : : .help = "inner EtherType",
4614 : : .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
4615 : : item_param),
4616 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vlan,
4617 : : hdr.eth_proto)),
4618 : : },
4619 : : [ITEM_VLAN_HAS_MORE_VLAN] = {
4620 : : .name = "has_more_vlan",
4621 : : .help = "packet header contains another VLAN",
4622 : : .next = NEXT(item_vlan, NEXT_ENTRY(COMMON_UNSIGNED),
4623 : : item_param),
4624 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vlan,
4625 : : has_more_vlan, 1)),
4626 : : },
4627 : : [ITEM_IPV4] = {
4628 : : .name = "ipv4",
4629 : : .help = "match IPv4 header",
4630 : : .priv = PRIV_ITEM(IPV4, sizeof(struct rte_flow_item_ipv4)),
4631 : : .next = NEXT(item_ipv4),
4632 : : .call = parse_vc,
4633 : : },
4634 : : [ITEM_IPV4_VER_IHL] = {
4635 : : .name = "version_ihl",
4636 : : .help = "match header length",
4637 : : .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
4638 : : item_param),
4639 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ipv4,
4640 : : hdr.version_ihl)),
4641 : : },
4642 : : [ITEM_IPV4_TOS] = {
4643 : : .name = "tos",
4644 : : .help = "type of service",
4645 : : .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
4646 : : item_param),
4647 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
4648 : : hdr.type_of_service)),
4649 : : },
4650 : : [ITEM_IPV4_LENGTH] = {
4651 : : .name = "length",
4652 : : .help = "total length",
4653 : : .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
4654 : : item_param),
4655 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
4656 : : hdr.total_length)),
4657 : : },
4658 : : [ITEM_IPV4_ID] = {
4659 : : .name = "packet_id",
4660 : : .help = "fragment packet id",
4661 : : .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
4662 : : item_param),
4663 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
4664 : : hdr.packet_id)),
4665 : : },
4666 : : [ITEM_IPV4_FRAGMENT_OFFSET] = {
4667 : : .name = "fragment_offset",
4668 : : .help = "fragmentation flags and fragment offset",
4669 : : .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
4670 : : item_param),
4671 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
4672 : : hdr.fragment_offset)),
4673 : : },
4674 : : [ITEM_IPV4_TTL] = {
4675 : : .name = "ttl",
4676 : : .help = "time to live",
4677 : : .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
4678 : : item_param),
4679 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
4680 : : hdr.time_to_live)),
4681 : : },
4682 : : [ITEM_IPV4_PROTO] = {
4683 : : .name = "proto",
4684 : : .help = "next protocol ID",
4685 : : .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
4686 : : item_param),
4687 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
4688 : : hdr.next_proto_id)),
4689 : : },
4690 : : [ITEM_IPV4_SRC] = {
4691 : : .name = "src",
4692 : : .help = "source address",
4693 : : .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
4694 : : item_param),
4695 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
4696 : : hdr.src_addr)),
4697 : : },
4698 : : [ITEM_IPV4_DST] = {
4699 : : .name = "dst",
4700 : : .help = "destination address",
4701 : : .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
4702 : : item_param),
4703 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
4704 : : hdr.dst_addr)),
4705 : : },
4706 : : [ITEM_IPV6] = {
4707 : : .name = "ipv6",
4708 : : .help = "match IPv6 header",
4709 : : .priv = PRIV_ITEM(IPV6, sizeof(struct rte_flow_item_ipv6)),
4710 : : .next = NEXT(item_ipv6),
4711 : : .call = parse_vc,
4712 : : },
4713 : : [ITEM_IPV6_TC] = {
4714 : : .name = "tc",
4715 : : .help = "traffic class",
4716 : : .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
4717 : : item_param),
4718 : : .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
4719 : : hdr.vtc_flow,
4720 : : "\x0f\xf0\x00\x00")),
4721 : : },
4722 : : [ITEM_IPV6_FLOW] = {
4723 : : .name = "flow",
4724 : : .help = "flow label",
4725 : : .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
4726 : : item_param),
4727 : : .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_ipv6,
4728 : : hdr.vtc_flow,
4729 : : "\x00\x0f\xff\xff")),
4730 : : },
4731 : : [ITEM_IPV6_LEN] = {
4732 : : .name = "length",
4733 : : .help = "payload length",
4734 : : .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
4735 : : item_param),
4736 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
4737 : : hdr.payload_len)),
4738 : : },
4739 : : [ITEM_IPV6_PROTO] = {
4740 : : .name = "proto",
4741 : : .help = "protocol (next header)",
4742 : : .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
4743 : : item_param),
4744 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
4745 : : hdr.proto)),
4746 : : },
4747 : : [ITEM_IPV6_HOP] = {
4748 : : .name = "hop",
4749 : : .help = "hop limit",
4750 : : .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
4751 : : item_param),
4752 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
4753 : : hdr.hop_limits)),
4754 : : },
4755 : : [ITEM_IPV6_SRC] = {
4756 : : .name = "src",
4757 : : .help = "source address",
4758 : : .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_IPV6_ADDR),
4759 : : item_param),
4760 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
4761 : : hdr.src_addr)),
4762 : : },
4763 : : [ITEM_IPV6_DST] = {
4764 : : .name = "dst",
4765 : : .help = "destination address",
4766 : : .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_IPV6_ADDR),
4767 : : item_param),
4768 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6,
4769 : : hdr.dst_addr)),
4770 : : },
4771 : : [ITEM_IPV6_HAS_FRAG_EXT] = {
4772 : : .name = "has_frag_ext",
4773 : : .help = "fragment packet attribute",
4774 : : .next = NEXT(item_ipv6, NEXT_ENTRY(COMMON_UNSIGNED),
4775 : : item_param),
4776 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_ipv6,
4777 : : has_frag_ext, 1)),
4778 : : },
4779 : : [ITEM_IPV6_ROUTING_EXT] = {
4780 : : .name = "ipv6_routing_ext",
4781 : : .help = "match IPv6 routing extension header",
4782 : : .priv = PRIV_ITEM(IPV6_ROUTING_EXT,
4783 : : sizeof(struct rte_flow_item_ipv6_routing_ext)),
4784 : : .next = NEXT(item_ipv6_routing_ext),
4785 : : .call = parse_vc,
4786 : : },
4787 : : [ITEM_IPV6_ROUTING_EXT_TYPE] = {
4788 : : .name = "ext_type",
4789 : : .help = "match IPv6 routing extension header type",
4790 : : .next = NEXT(item_ipv6_routing_ext, NEXT_ENTRY(COMMON_UNSIGNED),
4791 : : item_param),
4792 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_routing_ext,
4793 : : hdr.type)),
4794 : : },
4795 : : [ITEM_IPV6_ROUTING_EXT_NEXT_HDR] = {
4796 : : .name = "ext_next_hdr",
4797 : : .help = "match IPv6 routing extension header next header type",
4798 : : .next = NEXT(item_ipv6_routing_ext, NEXT_ENTRY(COMMON_UNSIGNED),
4799 : : item_param),
4800 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_routing_ext,
4801 : : hdr.next_hdr)),
4802 : : },
4803 : : [ITEM_IPV6_ROUTING_EXT_SEG_LEFT] = {
4804 : : .name = "ext_seg_left",
4805 : : .help = "match IPv6 routing extension header segment left",
4806 : : .next = NEXT(item_ipv6_routing_ext, NEXT_ENTRY(COMMON_UNSIGNED),
4807 : : item_param),
4808 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_routing_ext,
4809 : : hdr.segments_left)),
4810 : : },
4811 : : [ITEM_ICMP] = {
4812 : : .name = "icmp",
4813 : : .help = "match ICMP header",
4814 : : .priv = PRIV_ITEM(ICMP, sizeof(struct rte_flow_item_icmp)),
4815 : : .next = NEXT(item_icmp),
4816 : : .call = parse_vc,
4817 : : },
4818 : : [ITEM_ICMP_TYPE] = {
4819 : : .name = "type",
4820 : : .help = "ICMP packet type",
4821 : : .next = NEXT(item_icmp, NEXT_ENTRY(COMMON_UNSIGNED),
4822 : : item_param),
4823 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
4824 : : hdr.icmp_type)),
4825 : : },
4826 : : [ITEM_ICMP_CODE] = {
4827 : : .name = "code",
4828 : : .help = "ICMP packet code",
4829 : : .next = NEXT(item_icmp, NEXT_ENTRY(COMMON_UNSIGNED),
4830 : : item_param),
4831 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
4832 : : hdr.icmp_code)),
4833 : : },
4834 : : [ITEM_ICMP_IDENT] = {
4835 : : .name = "ident",
4836 : : .help = "ICMP packet identifier",
4837 : : .next = NEXT(item_icmp, NEXT_ENTRY(COMMON_UNSIGNED),
4838 : : item_param),
4839 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
4840 : : hdr.icmp_ident)),
4841 : : },
4842 : : [ITEM_ICMP_SEQ] = {
4843 : : .name = "seq",
4844 : : .help = "ICMP packet sequence number",
4845 : : .next = NEXT(item_icmp, NEXT_ENTRY(COMMON_UNSIGNED),
4846 : : item_param),
4847 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp,
4848 : : hdr.icmp_seq_nb)),
4849 : : },
4850 : : [ITEM_UDP] = {
4851 : : .name = "udp",
4852 : : .help = "match UDP header",
4853 : : .priv = PRIV_ITEM(UDP, sizeof(struct rte_flow_item_udp)),
4854 : : .next = NEXT(item_udp),
4855 : : .call = parse_vc,
4856 : : },
4857 : : [ITEM_UDP_SRC] = {
4858 : : .name = "src",
4859 : : .help = "UDP source port",
4860 : : .next = NEXT(item_udp, NEXT_ENTRY(COMMON_UNSIGNED),
4861 : : item_param),
4862 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
4863 : : hdr.src_port)),
4864 : : },
4865 : : [ITEM_UDP_DST] = {
4866 : : .name = "dst",
4867 : : .help = "UDP destination port",
4868 : : .next = NEXT(item_udp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
4869 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_udp,
4870 : : hdr.dst_port)),
4871 : : },
4872 : : [ITEM_TCP] = {
4873 : : .name = "tcp",
4874 : : .help = "match TCP header",
4875 : : .priv = PRIV_ITEM(TCP, sizeof(struct rte_flow_item_tcp)),
4876 : : .next = NEXT(item_tcp),
4877 : : .call = parse_vc,
4878 : : },
4879 : : [ITEM_TCP_SRC] = {
4880 : : .name = "src",
4881 : : .help = "TCP source port",
4882 : : .next = NEXT(item_tcp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
4883 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
4884 : : hdr.src_port)),
4885 : : },
4886 : : [ITEM_TCP_DST] = {
4887 : : .name = "dst",
4888 : : .help = "TCP destination port",
4889 : : .next = NEXT(item_tcp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
4890 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
4891 : : hdr.dst_port)),
4892 : : },
4893 : : [ITEM_TCP_FLAGS] = {
4894 : : .name = "flags",
4895 : : .help = "TCP flags",
4896 : : .next = NEXT(item_tcp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
4897 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_tcp,
4898 : : hdr.tcp_flags)),
4899 : : },
4900 : : [ITEM_SCTP] = {
4901 : : .name = "sctp",
4902 : : .help = "match SCTP header",
4903 : : .priv = PRIV_ITEM(SCTP, sizeof(struct rte_flow_item_sctp)),
4904 : : .next = NEXT(item_sctp),
4905 : : .call = parse_vc,
4906 : : },
4907 : : [ITEM_SCTP_SRC] = {
4908 : : .name = "src",
4909 : : .help = "SCTP source port",
4910 : : .next = NEXT(item_sctp, NEXT_ENTRY(COMMON_UNSIGNED),
4911 : : item_param),
4912 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
4913 : : hdr.src_port)),
4914 : : },
4915 : : [ITEM_SCTP_DST] = {
4916 : : .name = "dst",
4917 : : .help = "SCTP destination port",
4918 : : .next = NEXT(item_sctp, NEXT_ENTRY(COMMON_UNSIGNED),
4919 : : item_param),
4920 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
4921 : : hdr.dst_port)),
4922 : : },
4923 : : [ITEM_SCTP_TAG] = {
4924 : : .name = "tag",
4925 : : .help = "validation tag",
4926 : : .next = NEXT(item_sctp, NEXT_ENTRY(COMMON_UNSIGNED),
4927 : : item_param),
4928 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
4929 : : hdr.tag)),
4930 : : },
4931 : : [ITEM_SCTP_CKSUM] = {
4932 : : .name = "cksum",
4933 : : .help = "checksum",
4934 : : .next = NEXT(item_sctp, NEXT_ENTRY(COMMON_UNSIGNED),
4935 : : item_param),
4936 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_sctp,
4937 : : hdr.cksum)),
4938 : : },
4939 : : [ITEM_VXLAN] = {
4940 : : .name = "vxlan",
4941 : : .help = "match VXLAN header",
4942 : : .priv = PRIV_ITEM(VXLAN, sizeof(struct rte_flow_item_vxlan)),
4943 : : .next = NEXT(item_vxlan),
4944 : : .call = parse_vc,
4945 : : },
4946 : : [ITEM_VXLAN_VNI] = {
4947 : : .name = "vni",
4948 : : .help = "VXLAN identifier",
4949 : : .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
4950 : : item_param),
4951 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan, hdr.vni)),
4952 : : },
4953 : : [ITEM_VXLAN_FLAG_G] = {
4954 : : .name = "flag_g",
4955 : : .help = "VXLAN GBP bit",
4956 : : .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
4957 : : item_param),
4958 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vxlan,
4959 : : hdr.flag_g, 1)),
4960 : : },
4961 : : [ITEM_VXLAN_FLAG_VER] = {
4962 : : .name = "flag_ver",
4963 : : .help = "VXLAN GPE version",
4964 : : .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
4965 : : item_param),
4966 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vxlan,
4967 : : hdr.flag_ver, 2)),
4968 : : },
4969 : : [ITEM_VXLAN_FLAG_I] = {
4970 : : .name = "flag_i",
4971 : : .help = "VXLAN Instance bit",
4972 : : .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
4973 : : item_param),
4974 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vxlan,
4975 : : hdr.flag_i, 1)),
4976 : : },
4977 : : [ITEM_VXLAN_FLAG_P] = {
4978 : : .name = "flag_p",
4979 : : .help = "VXLAN GPE Next Protocol bit",
4980 : : .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
4981 : : item_param),
4982 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vxlan,
4983 : : hdr.flag_p, 1)),
4984 : : },
4985 : : [ITEM_VXLAN_FLAG_B] = {
4986 : : .name = "flag_b",
4987 : : .help = "VXLAN GPE Ingress-Replicated BUM",
4988 : : .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
4989 : : item_param),
4990 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vxlan,
4991 : : hdr.flag_b, 1)),
4992 : : },
4993 : : [ITEM_VXLAN_FLAG_O] = {
4994 : : .name = "flag_o",
4995 : : .help = "VXLAN GPE OAM Packet bit",
4996 : : .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
4997 : : item_param),
4998 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vxlan,
4999 : : hdr.flag_o, 1)),
5000 : : },
5001 : : [ITEM_VXLAN_FLAG_D] = {
5002 : : .name = "flag_d",
5003 : : .help = "VXLAN GBP Don't Learn bit",
5004 : : .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
5005 : : item_param),
5006 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vxlan,
5007 : : hdr.flag_d, 1)),
5008 : : },
5009 : : [ITEM_VXLAN_FLAG_A] = {
5010 : : .name = "flag_a",
5011 : : .help = "VXLAN GBP Applied bit",
5012 : : .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
5013 : : item_param),
5014 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_vxlan,
5015 : : hdr.flag_a, 1)),
5016 : : },
5017 : : [ITEM_VXLAN_GBP_ID] = {
5018 : : .name = "group_policy_id",
5019 : : .help = "VXLAN GBP ID",
5020 : : .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
5021 : : item_param),
5022 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan,
5023 : : hdr.policy_id)),
5024 : : },
5025 : : [ITEM_VXLAN_GPE_PROTO] = {
5026 : : .name = "protocol",
5027 : : .help = "VXLAN GPE next protocol",
5028 : : .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
5029 : : item_param),
5030 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan,
5031 : : hdr.proto)),
5032 : : },
5033 : : [ITEM_VXLAN_FIRST_RSVD] = {
5034 : : .name = "first_rsvd",
5035 : : .help = "VXLAN rsvd0 first byte",
5036 : : .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
5037 : : item_param),
5038 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan,
5039 : : hdr.rsvd0[0])),
5040 : : },
5041 : : [ITEM_VXLAN_SECND_RSVD] = {
5042 : : .name = "second_rsvd",
5043 : : .help = "VXLAN rsvd0 second byte",
5044 : : .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
5045 : : item_param),
5046 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan,
5047 : : hdr.rsvd0[1])),
5048 : : },
5049 : : [ITEM_VXLAN_THIRD_RSVD] = {
5050 : : .name = "third_rsvd",
5051 : : .help = "VXLAN rsvd0 third byte",
5052 : : .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
5053 : : item_param),
5054 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan,
5055 : : hdr.rsvd0[2])),
5056 : : },
5057 : : [ITEM_VXLAN_LAST_RSVD] = {
5058 : : .name = "last_rsvd",
5059 : : .help = "VXLAN last reserved byte",
5060 : : .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
5061 : : item_param),
5062 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan,
5063 : : hdr.last_rsvd)),
5064 : : },
5065 : : [ITEM_E_TAG] = {
5066 : : .name = "e_tag",
5067 : : .help = "match E-Tag header",
5068 : : .priv = PRIV_ITEM(E_TAG, sizeof(struct rte_flow_item_e_tag)),
5069 : : .next = NEXT(item_e_tag),
5070 : : .call = parse_vc,
5071 : : },
5072 : : [ITEM_E_TAG_GRP_ECID_B] = {
5073 : : .name = "grp_ecid_b",
5074 : : .help = "GRP and E-CID base",
5075 : : .next = NEXT(item_e_tag, NEXT_ENTRY(COMMON_UNSIGNED),
5076 : : item_param),
5077 : : .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_e_tag,
5078 : : rsvd_grp_ecid_b,
5079 : : "\x3f\xff")),
5080 : : },
5081 : : [ITEM_NVGRE] = {
5082 : : .name = "nvgre",
5083 : : .help = "match NVGRE header",
5084 : : .priv = PRIV_ITEM(NVGRE, sizeof(struct rte_flow_item_nvgre)),
5085 : : .next = NEXT(item_nvgre),
5086 : : .call = parse_vc,
5087 : : },
5088 : : [ITEM_NVGRE_TNI] = {
5089 : : .name = "tni",
5090 : : .help = "virtual subnet ID",
5091 : : .next = NEXT(item_nvgre, NEXT_ENTRY(COMMON_UNSIGNED),
5092 : : item_param),
5093 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_nvgre, tni)),
5094 : : },
5095 : : [ITEM_MPLS] = {
5096 : : .name = "mpls",
5097 : : .help = "match MPLS header",
5098 : : .priv = PRIV_ITEM(MPLS, sizeof(struct rte_flow_item_mpls)),
5099 : : .next = NEXT(item_mpls),
5100 : : .call = parse_vc,
5101 : : },
5102 : : [ITEM_MPLS_LABEL] = {
5103 : : .name = "label",
5104 : : .help = "MPLS label",
5105 : : .next = NEXT(item_mpls, NEXT_ENTRY(COMMON_UNSIGNED),
5106 : : item_param),
5107 : : .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
5108 : : label_tc_s,
5109 : : "\xff\xff\xf0")),
5110 : : },
5111 : : [ITEM_MPLS_TC] = {
5112 : : .name = "tc",
5113 : : .help = "MPLS Traffic Class",
5114 : : .next = NEXT(item_mpls, NEXT_ENTRY(COMMON_UNSIGNED),
5115 : : item_param),
5116 : : .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
5117 : : label_tc_s,
5118 : : "\x00\x00\x0e")),
5119 : : },
5120 : : [ITEM_MPLS_S] = {
5121 : : .name = "s",
5122 : : .help = "MPLS Bottom-of-Stack",
5123 : : .next = NEXT(item_mpls, NEXT_ENTRY(COMMON_UNSIGNED),
5124 : : item_param),
5125 : : .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
5126 : : label_tc_s,
5127 : : "\x00\x00\x01")),
5128 : : },
5129 : : [ITEM_MPLS_TTL] = {
5130 : : .name = "ttl",
5131 : : .help = "MPLS Time-to-Live",
5132 : : .next = NEXT(item_mpls, NEXT_ENTRY(COMMON_UNSIGNED),
5133 : : item_param),
5134 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_mpls, ttl)),
5135 : : },
5136 : : [ITEM_GRE] = {
5137 : : .name = "gre",
5138 : : .help = "match GRE header",
5139 : : .priv = PRIV_ITEM(GRE, sizeof(struct rte_flow_item_gre)),
5140 : : .next = NEXT(item_gre),
5141 : : .call = parse_vc,
5142 : : },
5143 : : [ITEM_GRE_PROTO] = {
5144 : : .name = "protocol",
5145 : : .help = "GRE protocol type",
5146 : : .next = NEXT(item_gre, NEXT_ENTRY(COMMON_UNSIGNED),
5147 : : item_param),
5148 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
5149 : : protocol)),
5150 : : },
5151 : : [ITEM_GRE_C_RSVD0_VER] = {
5152 : : .name = "c_rsvd0_ver",
5153 : : .help =
5154 : : "checksum (1b), undefined (1b), key bit (1b),"
5155 : : " sequence number (1b), reserved 0 (9b),"
5156 : : " version (3b)",
5157 : : .next = NEXT(item_gre, NEXT_ENTRY(COMMON_UNSIGNED),
5158 : : item_param),
5159 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
5160 : : c_rsvd0_ver)),
5161 : : },
5162 : : [ITEM_GRE_C_BIT] = {
5163 : : .name = "c_bit",
5164 : : .help = "checksum bit (C)",
5165 : : .next = NEXT(item_gre, NEXT_ENTRY(COMMON_BOOLEAN),
5166 : : item_param),
5167 : : .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
5168 : : c_rsvd0_ver,
5169 : : "\x80\x00\x00\x00")),
5170 : : },
5171 : : [ITEM_GRE_S_BIT] = {
5172 : : .name = "s_bit",
5173 : : .help = "sequence number bit (S)",
5174 : : .next = NEXT(item_gre, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
5175 : : .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
5176 : : c_rsvd0_ver,
5177 : : "\x10\x00\x00\x00")),
5178 : : },
5179 : : [ITEM_GRE_K_BIT] = {
5180 : : .name = "k_bit",
5181 : : .help = "key bit (K)",
5182 : : .next = NEXT(item_gre, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
5183 : : .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
5184 : : c_rsvd0_ver,
5185 : : "\x20\x00\x00\x00")),
5186 : : },
5187 : : [ITEM_FUZZY] = {
5188 : : .name = "fuzzy",
5189 : : .help = "fuzzy pattern match, expect faster than default",
5190 : : .priv = PRIV_ITEM(FUZZY,
5191 : : sizeof(struct rte_flow_item_fuzzy)),
5192 : : .next = NEXT(item_fuzzy),
5193 : : .call = parse_vc,
5194 : : },
5195 : : [ITEM_FUZZY_THRESH] = {
5196 : : .name = "thresh",
5197 : : .help = "match accuracy threshold",
5198 : : .next = NEXT(item_fuzzy, NEXT_ENTRY(COMMON_UNSIGNED),
5199 : : item_param),
5200 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_fuzzy,
5201 : : thresh)),
5202 : : },
5203 : : [ITEM_GTP] = {
5204 : : .name = "gtp",
5205 : : .help = "match GTP header",
5206 : : .priv = PRIV_ITEM(GTP, sizeof(struct rte_flow_item_gtp)),
5207 : : .next = NEXT(item_gtp),
5208 : : .call = parse_vc,
5209 : : },
5210 : : [ITEM_GTP_FLAGS] = {
5211 : : .name = "v_pt_rsv_flags",
5212 : : .help = "GTP flags",
5213 : : .next = NEXT(item_gtp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
5214 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp,
5215 : : hdr.gtp_hdr_info)),
5216 : : },
5217 : : [ITEM_GTP_MSG_TYPE] = {
5218 : : .name = "msg_type",
5219 : : .help = "GTP message type",
5220 : : .next = NEXT(item_gtp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
5221 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_gtp, hdr.msg_type)),
5222 : : },
5223 : : [ITEM_GTP_TEID] = {
5224 : : .name = "teid",
5225 : : .help = "tunnel endpoint identifier",
5226 : : .next = NEXT(item_gtp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
5227 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp, hdr.teid)),
5228 : : },
5229 : : [ITEM_GTPC] = {
5230 : : .name = "gtpc",
5231 : : .help = "match GTP header",
5232 : : .priv = PRIV_ITEM(GTPC, sizeof(struct rte_flow_item_gtp)),
5233 : : .next = NEXT(item_gtp),
5234 : : .call = parse_vc,
5235 : : },
5236 : : [ITEM_GTPU] = {
5237 : : .name = "gtpu",
5238 : : .help = "match GTP header",
5239 : : .priv = PRIV_ITEM(GTPU, sizeof(struct rte_flow_item_gtp)),
5240 : : .next = NEXT(item_gtp),
5241 : : .call = parse_vc,
5242 : : },
5243 : : [ITEM_GENEVE] = {
5244 : : .name = "geneve",
5245 : : .help = "match GENEVE header",
5246 : : .priv = PRIV_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)),
5247 : : .next = NEXT(item_geneve),
5248 : : .call = parse_vc,
5249 : : },
5250 : : [ITEM_GENEVE_VNI] = {
5251 : : .name = "vni",
5252 : : .help = "virtual network identifier",
5253 : : .next = NEXT(item_geneve, NEXT_ENTRY(COMMON_UNSIGNED),
5254 : : item_param),
5255 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve, vni)),
5256 : : },
5257 : : [ITEM_GENEVE_PROTO] = {
5258 : : .name = "protocol",
5259 : : .help = "GENEVE protocol type",
5260 : : .next = NEXT(item_geneve, NEXT_ENTRY(COMMON_UNSIGNED),
5261 : : item_param),
5262 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve,
5263 : : protocol)),
5264 : : },
5265 : : [ITEM_GENEVE_OPTLEN] = {
5266 : : .name = "optlen",
5267 : : .help = "GENEVE options length in dwords",
5268 : : .next = NEXT(item_geneve, NEXT_ENTRY(COMMON_UNSIGNED),
5269 : : item_param),
5270 : : .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_geneve,
5271 : : ver_opt_len_o_c_rsvd0,
5272 : : "\x3f\x00")),
5273 : : },
5274 : : [ITEM_VXLAN_GPE] = {
5275 : : .name = "vxlan-gpe",
5276 : : .help = "match VXLAN-GPE header",
5277 : : .priv = PRIV_ITEM(VXLAN_GPE,
5278 : : sizeof(struct rte_flow_item_vxlan_gpe)),
5279 : : .next = NEXT(item_vxlan_gpe),
5280 : : .call = parse_vc,
5281 : : },
5282 : : [ITEM_VXLAN_GPE_VNI] = {
5283 : : .name = "vni",
5284 : : .help = "VXLAN-GPE identifier",
5285 : : .next = NEXT(item_vxlan_gpe, NEXT_ENTRY(COMMON_UNSIGNED),
5286 : : item_param),
5287 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
5288 : : hdr.vni)),
5289 : : },
5290 : : [ITEM_VXLAN_GPE_PROTO_IN_DEPRECATED_VXLAN_GPE_HDR] = {
5291 : : .name = "protocol",
5292 : : .help = "VXLAN-GPE next protocol",
5293 : : .next = NEXT(item_vxlan_gpe, NEXT_ENTRY(COMMON_UNSIGNED),
5294 : : item_param),
5295 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
5296 : : protocol)),
5297 : : },
5298 : : [ITEM_VXLAN_GPE_FLAGS] = {
5299 : : .name = "flags",
5300 : : .help = "VXLAN-GPE flags",
5301 : : .next = NEXT(item_vxlan_gpe, NEXT_ENTRY(COMMON_UNSIGNED),
5302 : : item_param),
5303 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
5304 : : flags)),
5305 : : },
5306 : : [ITEM_VXLAN_GPE_RSVD0] = {
5307 : : .name = "rsvd0",
5308 : : .help = "VXLAN-GPE rsvd0",
5309 : : .next = NEXT(item_vxlan_gpe, NEXT_ENTRY(COMMON_UNSIGNED),
5310 : : item_param),
5311 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
5312 : : rsvd0)),
5313 : : },
5314 : : [ITEM_VXLAN_GPE_RSVD1] = {
5315 : : .name = "rsvd1",
5316 : : .help = "VXLAN-GPE rsvd1",
5317 : : .next = NEXT(item_vxlan_gpe, NEXT_ENTRY(COMMON_UNSIGNED),
5318 : : item_param),
5319 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan_gpe,
5320 : : rsvd1)),
5321 : : },
5322 : : [ITEM_ARP_ETH_IPV4] = {
5323 : : .name = "arp_eth_ipv4",
5324 : : .help = "match ARP header for Ethernet/IPv4",
5325 : : .priv = PRIV_ITEM(ARP_ETH_IPV4,
5326 : : sizeof(struct rte_flow_item_arp_eth_ipv4)),
5327 : : .next = NEXT(item_arp_eth_ipv4),
5328 : : .call = parse_vc,
5329 : : },
5330 : : [ITEM_ARP_ETH_IPV4_SHA] = {
5331 : : .name = "sha",
5332 : : .help = "sender hardware address",
5333 : : .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_MAC_ADDR),
5334 : : item_param),
5335 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
5336 : : hdr.arp_data.arp_sha)),
5337 : : },
5338 : : [ITEM_ARP_ETH_IPV4_SPA] = {
5339 : : .name = "spa",
5340 : : .help = "sender IPv4 address",
5341 : : .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
5342 : : item_param),
5343 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
5344 : : hdr.arp_data.arp_sip)),
5345 : : },
5346 : : [ITEM_ARP_ETH_IPV4_THA] = {
5347 : : .name = "tha",
5348 : : .help = "target hardware address",
5349 : : .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_MAC_ADDR),
5350 : : item_param),
5351 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
5352 : : hdr.arp_data.arp_tha)),
5353 : : },
5354 : : [ITEM_ARP_ETH_IPV4_TPA] = {
5355 : : .name = "tpa",
5356 : : .help = "target IPv4 address",
5357 : : .next = NEXT(item_arp_eth_ipv4, NEXT_ENTRY(COMMON_IPV4_ADDR),
5358 : : item_param),
5359 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_arp_eth_ipv4,
5360 : : hdr.arp_data.arp_tip)),
5361 : : },
5362 : : [ITEM_IPV6_EXT] = {
5363 : : .name = "ipv6_ext",
5364 : : .help = "match presence of any IPv6 extension header",
5365 : : .priv = PRIV_ITEM(IPV6_EXT,
5366 : : sizeof(struct rte_flow_item_ipv6_ext)),
5367 : : .next = NEXT(item_ipv6_ext),
5368 : : .call = parse_vc,
5369 : : },
5370 : : [ITEM_IPV6_EXT_NEXT_HDR] = {
5371 : : .name = "next_hdr",
5372 : : .help = "next header",
5373 : : .next = NEXT(item_ipv6_ext, NEXT_ENTRY(COMMON_UNSIGNED),
5374 : : item_param),
5375 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_ext,
5376 : : next_hdr)),
5377 : : },
5378 : : [ITEM_IPV6_FRAG_EXT] = {
5379 : : .name = "ipv6_frag_ext",
5380 : : .help = "match presence of IPv6 fragment extension header",
5381 : : .priv = PRIV_ITEM(IPV6_FRAG_EXT,
5382 : : sizeof(struct rte_flow_item_ipv6_frag_ext)),
5383 : : .next = NEXT(item_ipv6_frag_ext),
5384 : : .call = parse_vc,
5385 : : },
5386 : : [ITEM_IPV6_FRAG_EXT_NEXT_HDR] = {
5387 : : .name = "next_hdr",
5388 : : .help = "next header",
5389 : : .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(COMMON_UNSIGNED),
5390 : : item_param),
5391 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ipv6_frag_ext,
5392 : : hdr.next_header)),
5393 : : },
5394 : : [ITEM_IPV6_FRAG_EXT_FRAG_DATA] = {
5395 : : .name = "frag_data",
5396 : : .help = "fragment flags and offset",
5397 : : .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(COMMON_UNSIGNED),
5398 : : item_param),
5399 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_frag_ext,
5400 : : hdr.frag_data)),
5401 : : },
5402 : : [ITEM_IPV6_FRAG_EXT_ID] = {
5403 : : .name = "packet_id",
5404 : : .help = "fragment packet id",
5405 : : .next = NEXT(item_ipv6_frag_ext, NEXT_ENTRY(COMMON_UNSIGNED),
5406 : : item_param),
5407 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_frag_ext,
5408 : : hdr.id)),
5409 : : },
5410 : : [ITEM_ICMP6] = {
5411 : : .name = "icmp6",
5412 : : .help = "match any ICMPv6 header",
5413 : : .priv = PRIV_ITEM(ICMP6, sizeof(struct rte_flow_item_icmp6)),
5414 : : .next = NEXT(item_icmp6),
5415 : : .call = parse_vc,
5416 : : },
5417 : : [ITEM_ICMP6_TYPE] = {
5418 : : .name = "type",
5419 : : .help = "ICMPv6 type",
5420 : : .next = NEXT(item_icmp6, NEXT_ENTRY(COMMON_UNSIGNED),
5421 : : item_param),
5422 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
5423 : : type)),
5424 : : },
5425 : : [ITEM_ICMP6_CODE] = {
5426 : : .name = "code",
5427 : : .help = "ICMPv6 code",
5428 : : .next = NEXT(item_icmp6, NEXT_ENTRY(COMMON_UNSIGNED),
5429 : : item_param),
5430 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6,
5431 : : code)),
5432 : : },
5433 : : [ITEM_ICMP6_ECHO_REQUEST] = {
5434 : : .name = "icmp6_echo_request",
5435 : : .help = "match ICMPv6 echo request",
5436 : : .priv = PRIV_ITEM(ICMP6_ECHO_REQUEST,
5437 : : sizeof(struct rte_flow_item_icmp6_echo)),
5438 : : .next = NEXT(item_icmp6_echo_request),
5439 : : .call = parse_vc,
5440 : : },
5441 : : [ITEM_ICMP6_ECHO_REQUEST_ID] = {
5442 : : .name = "ident",
5443 : : .help = "ICMPv6 echo request identifier",
5444 : : .next = NEXT(item_icmp6_echo_request, NEXT_ENTRY(COMMON_UNSIGNED),
5445 : : item_param),
5446 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_echo,
5447 : : hdr.identifier)),
5448 : : },
5449 : : [ITEM_ICMP6_ECHO_REQUEST_SEQ] = {
5450 : : .name = "seq",
5451 : : .help = "ICMPv6 echo request sequence",
5452 : : .next = NEXT(item_icmp6_echo_request, NEXT_ENTRY(COMMON_UNSIGNED),
5453 : : item_param),
5454 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_echo,
5455 : : hdr.sequence)),
5456 : : },
5457 : : [ITEM_ICMP6_ECHO_REPLY] = {
5458 : : .name = "icmp6_echo_reply",
5459 : : .help = "match ICMPv6 echo reply",
5460 : : .priv = PRIV_ITEM(ICMP6_ECHO_REPLY,
5461 : : sizeof(struct rte_flow_item_icmp6_echo)),
5462 : : .next = NEXT(item_icmp6_echo_reply),
5463 : : .call = parse_vc,
5464 : : },
5465 : : [ITEM_ICMP6_ECHO_REPLY_ID] = {
5466 : : .name = "ident",
5467 : : .help = "ICMPv6 echo reply identifier",
5468 : : .next = NEXT(item_icmp6_echo_reply, NEXT_ENTRY(COMMON_UNSIGNED),
5469 : : item_param),
5470 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_echo,
5471 : : hdr.identifier)),
5472 : : },
5473 : : [ITEM_ICMP6_ECHO_REPLY_SEQ] = {
5474 : : .name = "seq",
5475 : : .help = "ICMPv6 echo reply sequence",
5476 : : .next = NEXT(item_icmp6_echo_reply, NEXT_ENTRY(COMMON_UNSIGNED),
5477 : : item_param),
5478 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_echo,
5479 : : hdr.sequence)),
5480 : : },
5481 : : [ITEM_ICMP6_ND_NS] = {
5482 : : .name = "icmp6_nd_ns",
5483 : : .help = "match ICMPv6 neighbor discovery solicitation",
5484 : : .priv = PRIV_ITEM(ICMP6_ND_NS,
5485 : : sizeof(struct rte_flow_item_icmp6_nd_ns)),
5486 : : .next = NEXT(item_icmp6_nd_ns),
5487 : : .call = parse_vc,
5488 : : },
5489 : : [ITEM_ICMP6_ND_NS_TARGET_ADDR] = {
5490 : : .name = "target_addr",
5491 : : .help = "target address",
5492 : : .next = NEXT(item_icmp6_nd_ns, NEXT_ENTRY(COMMON_IPV6_ADDR),
5493 : : item_param),
5494 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_ns,
5495 : : target_addr)),
5496 : : },
5497 : : [ITEM_ICMP6_ND_NA] = {
5498 : : .name = "icmp6_nd_na",
5499 : : .help = "match ICMPv6 neighbor discovery advertisement",
5500 : : .priv = PRIV_ITEM(ICMP6_ND_NA,
5501 : : sizeof(struct rte_flow_item_icmp6_nd_na)),
5502 : : .next = NEXT(item_icmp6_nd_na),
5503 : : .call = parse_vc,
5504 : : },
5505 : : [ITEM_ICMP6_ND_NA_TARGET_ADDR] = {
5506 : : .name = "target_addr",
5507 : : .help = "target address",
5508 : : .next = NEXT(item_icmp6_nd_na, NEXT_ENTRY(COMMON_IPV6_ADDR),
5509 : : item_param),
5510 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_na,
5511 : : target_addr)),
5512 : : },
5513 : : [ITEM_ICMP6_ND_OPT] = {
5514 : : .name = "icmp6_nd_opt",
5515 : : .help = "match presence of any ICMPv6 neighbor discovery"
5516 : : " option",
5517 : : .priv = PRIV_ITEM(ICMP6_ND_OPT,
5518 : : sizeof(struct rte_flow_item_icmp6_nd_opt)),
5519 : : .next = NEXT(item_icmp6_nd_opt),
5520 : : .call = parse_vc,
5521 : : },
5522 : : [ITEM_ICMP6_ND_OPT_TYPE] = {
5523 : : .name = "type",
5524 : : .help = "ND option type",
5525 : : .next = NEXT(item_icmp6_nd_opt, NEXT_ENTRY(COMMON_UNSIGNED),
5526 : : item_param),
5527 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_icmp6_nd_opt,
5528 : : type)),
5529 : : },
5530 : : [ITEM_ICMP6_ND_OPT_SLA_ETH] = {
5531 : : .name = "icmp6_nd_opt_sla_eth",
5532 : : .help = "match ICMPv6 neighbor discovery source Ethernet"
5533 : : " link-layer address option",
5534 : : .priv = PRIV_ITEM
5535 : : (ICMP6_ND_OPT_SLA_ETH,
5536 : : sizeof(struct rte_flow_item_icmp6_nd_opt_sla_eth)),
5537 : : .next = NEXT(item_icmp6_nd_opt_sla_eth),
5538 : : .call = parse_vc,
5539 : : },
5540 : : [ITEM_ICMP6_ND_OPT_SLA_ETH_SLA] = {
5541 : : .name = "sla",
5542 : : .help = "source Ethernet LLA",
5543 : : .next = NEXT(item_icmp6_nd_opt_sla_eth,
5544 : : NEXT_ENTRY(COMMON_MAC_ADDR), item_param),
5545 : : .args = ARGS(ARGS_ENTRY_HTON
5546 : : (struct rte_flow_item_icmp6_nd_opt_sla_eth, sla)),
5547 : : },
5548 : : [ITEM_ICMP6_ND_OPT_TLA_ETH] = {
5549 : : .name = "icmp6_nd_opt_tla_eth",
5550 : : .help = "match ICMPv6 neighbor discovery target Ethernet"
5551 : : " link-layer address option",
5552 : : .priv = PRIV_ITEM
5553 : : (ICMP6_ND_OPT_TLA_ETH,
5554 : : sizeof(struct rte_flow_item_icmp6_nd_opt_tla_eth)),
5555 : : .next = NEXT(item_icmp6_nd_opt_tla_eth),
5556 : : .call = parse_vc,
5557 : : },
5558 : : [ITEM_ICMP6_ND_OPT_TLA_ETH_TLA] = {
5559 : : .name = "tla",
5560 : : .help = "target Ethernet LLA",
5561 : : .next = NEXT(item_icmp6_nd_opt_tla_eth,
5562 : : NEXT_ENTRY(COMMON_MAC_ADDR), item_param),
5563 : : .args = ARGS(ARGS_ENTRY_HTON
5564 : : (struct rte_flow_item_icmp6_nd_opt_tla_eth, tla)),
5565 : : },
5566 : : [ITEM_META] = {
5567 : : .name = "meta",
5568 : : .help = "match metadata header",
5569 : : .priv = PRIV_ITEM(META, sizeof(struct rte_flow_item_meta)),
5570 : : .next = NEXT(item_meta),
5571 : : .call = parse_vc,
5572 : : },
5573 : : [ITEM_META_DATA] = {
5574 : : .name = "data",
5575 : : .help = "metadata value",
5576 : : .next = NEXT(item_meta, NEXT_ENTRY(COMMON_UNSIGNED),
5577 : : item_param),
5578 : : .args = ARGS(ARGS_ENTRY_MASK(struct rte_flow_item_meta,
5579 : : data, "\xff\xff\xff\xff")),
5580 : : },
5581 : : [ITEM_RANDOM] = {
5582 : : .name = "random",
5583 : : .help = "match random value",
5584 : : .priv = PRIV_ITEM(RANDOM, sizeof(struct rte_flow_item_random)),
5585 : : .next = NEXT(item_random),
5586 : : .call = parse_vc,
5587 : : },
5588 : : [ITEM_RANDOM_VALUE] = {
5589 : : .name = "value",
5590 : : .help = "random value",
5591 : : .next = NEXT(item_random, NEXT_ENTRY(COMMON_UNSIGNED),
5592 : : item_param),
5593 : : .args = ARGS(ARGS_ENTRY_MASK(struct rte_flow_item_random,
5594 : : value, "\xff\xff")),
5595 : : },
5596 : : [ITEM_GRE_KEY] = {
5597 : : .name = "gre_key",
5598 : : .help = "match GRE key",
5599 : : .priv = PRIV_ITEM(GRE_KEY, sizeof(rte_be32_t)),
5600 : : .next = NEXT(item_gre_key),
5601 : : .call = parse_vc,
5602 : : },
5603 : : [ITEM_GRE_KEY_VALUE] = {
5604 : : .name = "value",
5605 : : .help = "key value",
5606 : : .next = NEXT(item_gre_key, NEXT_ENTRY(COMMON_UNSIGNED),
5607 : : item_param),
5608 : : .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
5609 : : },
5610 : : [ITEM_GRE_OPTION] = {
5611 : : .name = "gre_option",
5612 : : .help = "match GRE optional fields",
5613 : : .priv = PRIV_ITEM(GRE_OPTION,
5614 : : sizeof(struct rte_flow_item_gre_opt)),
5615 : : .next = NEXT(item_gre_option),
5616 : : .call = parse_vc,
5617 : : },
5618 : : [ITEM_GRE_OPTION_CHECKSUM] = {
5619 : : .name = "checksum",
5620 : : .help = "match GRE checksum",
5621 : : .next = NEXT(item_gre_option, NEXT_ENTRY(COMMON_UNSIGNED),
5622 : : item_param),
5623 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre_opt,
5624 : : checksum_rsvd.checksum)),
5625 : : },
5626 : : [ITEM_GRE_OPTION_KEY] = {
5627 : : .name = "key",
5628 : : .help = "match GRE key",
5629 : : .next = NEXT(item_gre_option, NEXT_ENTRY(COMMON_UNSIGNED),
5630 : : item_param),
5631 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre_opt,
5632 : : key.key)),
5633 : : },
5634 : : [ITEM_GRE_OPTION_SEQUENCE] = {
5635 : : .name = "sequence",
5636 : : .help = "match GRE sequence",
5637 : : .next = NEXT(item_gre_option, NEXT_ENTRY(COMMON_UNSIGNED),
5638 : : item_param),
5639 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre_opt,
5640 : : sequence.sequence)),
5641 : : },
5642 : : [ITEM_GTP_PSC] = {
5643 : : .name = "gtp_psc",
5644 : : .help = "match GTP extension header with type 0x85",
5645 : : .priv = PRIV_ITEM(GTP_PSC,
5646 : : sizeof(struct rte_flow_item_gtp_psc)),
5647 : : .next = NEXT(item_gtp_psc),
5648 : : .call = parse_vc,
5649 : : },
5650 : : [ITEM_GTP_PSC_QFI] = {
5651 : : .name = "qfi",
5652 : : .help = "QoS flow identifier",
5653 : : .next = NEXT(item_gtp_psc, NEXT_ENTRY(COMMON_UNSIGNED),
5654 : : item_param),
5655 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_gtp_psc,
5656 : : hdr.qfi, 6)),
5657 : : },
5658 : : [ITEM_GTP_PSC_PDU_T] = {
5659 : : .name = "pdu_t",
5660 : : .help = "PDU type",
5661 : : .next = NEXT(item_gtp_psc, NEXT_ENTRY(COMMON_UNSIGNED),
5662 : : item_param),
5663 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_gtp_psc,
5664 : : hdr.type, 4)),
5665 : : },
5666 : : [ITEM_PPPOES] = {
5667 : : .name = "pppoes",
5668 : : .help = "match PPPoE session header",
5669 : : .priv = PRIV_ITEM(PPPOES, sizeof(struct rte_flow_item_pppoe)),
5670 : : .next = NEXT(item_pppoes),
5671 : : .call = parse_vc,
5672 : : },
5673 : : [ITEM_PPPOED] = {
5674 : : .name = "pppoed",
5675 : : .help = "match PPPoE discovery header",
5676 : : .priv = PRIV_ITEM(PPPOED, sizeof(struct rte_flow_item_pppoe)),
5677 : : .next = NEXT(item_pppoed),
5678 : : .call = parse_vc,
5679 : : },
5680 : : [ITEM_PPPOE_SEID] = {
5681 : : .name = "seid",
5682 : : .help = "session identifier",
5683 : : .next = NEXT(item_pppoes, NEXT_ENTRY(COMMON_UNSIGNED),
5684 : : item_param),
5685 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pppoe,
5686 : : session_id)),
5687 : : },
5688 : : [ITEM_PPPOE_PROTO_ID] = {
5689 : : .name = "pppoe_proto_id",
5690 : : .help = "match PPPoE session protocol identifier",
5691 : : .priv = PRIV_ITEM(PPPOE_PROTO_ID,
5692 : : sizeof(struct rte_flow_item_pppoe_proto_id)),
5693 : : .next = NEXT(item_pppoe_proto_id, NEXT_ENTRY(COMMON_UNSIGNED),
5694 : : item_param),
5695 : : .args = ARGS(ARGS_ENTRY_HTON
5696 : : (struct rte_flow_item_pppoe_proto_id, proto_id)),
5697 : : .call = parse_vc,
5698 : : },
5699 : : [ITEM_HIGIG2] = {
5700 : : .name = "higig2",
5701 : : .help = "matches higig2 header",
5702 : : .priv = PRIV_ITEM(HIGIG2,
5703 : : sizeof(struct rte_flow_item_higig2_hdr)),
5704 : : .next = NEXT(item_higig2),
5705 : : .call = parse_vc,
5706 : : },
5707 : : [ITEM_HIGIG2_CLASSIFICATION] = {
5708 : : .name = "classification",
5709 : : .help = "matches classification of higig2 header",
5710 : : .next = NEXT(item_higig2, NEXT_ENTRY(COMMON_UNSIGNED),
5711 : : item_param),
5712 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
5713 : : hdr.ppt1.classification)),
5714 : : },
5715 : : [ITEM_HIGIG2_VID] = {
5716 : : .name = "vid",
5717 : : .help = "matches vid of higig2 header",
5718 : : .next = NEXT(item_higig2, NEXT_ENTRY(COMMON_UNSIGNED),
5719 : : item_param),
5720 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_higig2_hdr,
5721 : : hdr.ppt1.vid)),
5722 : : },
5723 : : [ITEM_TAG] = {
5724 : : .name = "tag",
5725 : : .help = "match tag value",
5726 : : .priv = PRIV_ITEM(TAG, sizeof(struct rte_flow_item_tag)),
5727 : : .next = NEXT(item_tag),
5728 : : .call = parse_vc,
5729 : : },
5730 : : [ITEM_TAG_DATA] = {
5731 : : .name = "data",
5732 : : .help = "tag value to match",
5733 : : .next = NEXT(item_tag, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
5734 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, data)),
5735 : : },
5736 : : [ITEM_TAG_INDEX] = {
5737 : : .name = "index",
5738 : : .help = "index of tag array to match",
5739 : : .next = NEXT(item_tag, NEXT_ENTRY(COMMON_UNSIGNED),
5740 : : NEXT_ENTRY(ITEM_PARAM_IS)),
5741 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tag, index)),
5742 : : },
5743 : : [ITEM_L2TPV3OIP] = {
5744 : : .name = "l2tpv3oip",
5745 : : .help = "match L2TPv3 over IP header",
5746 : : .priv = PRIV_ITEM(L2TPV3OIP,
5747 : : sizeof(struct rte_flow_item_l2tpv3oip)),
5748 : : .next = NEXT(item_l2tpv3oip),
5749 : : .call = parse_vc,
5750 : : },
5751 : : [ITEM_L2TPV3OIP_SESSION_ID] = {
5752 : : .name = "session_id",
5753 : : .help = "session identifier",
5754 : : .next = NEXT(item_l2tpv3oip, NEXT_ENTRY(COMMON_UNSIGNED),
5755 : : item_param),
5756 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv3oip,
5757 : : session_id)),
5758 : : },
5759 : : [ITEM_ESP] = {
5760 : : .name = "esp",
5761 : : .help = "match ESP header",
5762 : : .priv = PRIV_ITEM(ESP, sizeof(struct rte_flow_item_esp)),
5763 : : .next = NEXT(item_esp),
5764 : : .call = parse_vc,
5765 : : },
5766 : : [ITEM_ESP_SPI] = {
5767 : : .name = "spi",
5768 : : .help = "security policy index",
5769 : : .next = NEXT(item_esp, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
5770 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_esp,
5771 : : hdr.spi)),
5772 : : },
5773 : : [ITEM_AH] = {
5774 : : .name = "ah",
5775 : : .help = "match AH header",
5776 : : .priv = PRIV_ITEM(AH, sizeof(struct rte_flow_item_ah)),
5777 : : .next = NEXT(item_ah),
5778 : : .call = parse_vc,
5779 : : },
5780 : : [ITEM_AH_SPI] = {
5781 : : .name = "spi",
5782 : : .help = "security parameters index",
5783 : : .next = NEXT(item_ah, NEXT_ENTRY(COMMON_UNSIGNED), item_param),
5784 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ah, spi)),
5785 : : },
5786 : : [ITEM_PFCP] = {
5787 : : .name = "pfcp",
5788 : : .help = "match pfcp header",
5789 : : .priv = PRIV_ITEM(PFCP, sizeof(struct rte_flow_item_pfcp)),
5790 : : .next = NEXT(item_pfcp),
5791 : : .call = parse_vc,
5792 : : },
5793 : : [ITEM_PFCP_S_FIELD] = {
5794 : : .name = "s_field",
5795 : : .help = "S field",
5796 : : .next = NEXT(item_pfcp, NEXT_ENTRY(COMMON_UNSIGNED),
5797 : : item_param),
5798 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp,
5799 : : s_field)),
5800 : : },
5801 : : [ITEM_PFCP_SEID] = {
5802 : : .name = "seid",
5803 : : .help = "session endpoint identifier",
5804 : : .next = NEXT(item_pfcp, NEXT_ENTRY(COMMON_UNSIGNED),
5805 : : item_param),
5806 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_pfcp, seid)),
5807 : : },
5808 : : [ITEM_ECPRI] = {
5809 : : .name = "ecpri",
5810 : : .help = "match eCPRI header",
5811 : : .priv = PRIV_ITEM(ECPRI, sizeof(struct rte_flow_item_ecpri)),
5812 : : .next = NEXT(item_ecpri),
5813 : : .call = parse_vc,
5814 : : },
5815 : : [ITEM_ECPRI_COMMON] = {
5816 : : .name = "common",
5817 : : .help = "eCPRI common header",
5818 : : .next = NEXT(item_ecpri_common),
5819 : : },
5820 : : [ITEM_ECPRI_COMMON_TYPE] = {
5821 : : .name = "type",
5822 : : .help = "type of common header",
5823 : : .next = NEXT(item_ecpri_common_type),
5824 : : .args = ARGS(ARG_ENTRY_HTON(struct rte_flow_item_ecpri)),
5825 : : },
5826 : : [ITEM_ECPRI_COMMON_TYPE_IQ_DATA] = {
5827 : : .name = "iq_data",
5828 : : .help = "Type #0: IQ Data",
5829 : : .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
5830 : : ITEM_NEXT)),
5831 : : .call = parse_vc_item_ecpri_type,
5832 : : },
5833 : : [ITEM_ECPRI_MSG_IQ_DATA_PCID] = {
5834 : : .name = "pc_id",
5835 : : .help = "Physical Channel ID",
5836 : : .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_IQ_DATA_PCID,
5837 : : ITEM_ECPRI_COMMON, ITEM_NEXT),
5838 : : NEXT_ENTRY(COMMON_UNSIGNED), item_param),
5839 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
5840 : : hdr.type0.pc_id)),
5841 : : },
5842 : : [ITEM_ECPRI_COMMON_TYPE_RTC_CTRL] = {
5843 : : .name = "rtc_ctrl",
5844 : : .help = "Type #2: Real-Time Control Data",
5845 : : .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
5846 : : ITEM_NEXT)),
5847 : : .call = parse_vc_item_ecpri_type,
5848 : : },
5849 : : [ITEM_ECPRI_MSG_RTC_CTRL_RTCID] = {
5850 : : .name = "rtc_id",
5851 : : .help = "Real-Time Control Data ID",
5852 : : .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_RTC_CTRL_RTCID,
5853 : : ITEM_ECPRI_COMMON, ITEM_NEXT),
5854 : : NEXT_ENTRY(COMMON_UNSIGNED), item_param),
5855 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
5856 : : hdr.type2.rtc_id)),
5857 : : },
5858 : : [ITEM_ECPRI_COMMON_TYPE_DLY_MSR] = {
5859 : : .name = "delay_measure",
5860 : : .help = "Type #5: One-Way Delay Measurement",
5861 : : .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
5862 : : ITEM_NEXT)),
5863 : : .call = parse_vc_item_ecpri_type,
5864 : : },
5865 : : [ITEM_ECPRI_MSG_DLY_MSR_MSRID] = {
5866 : : .name = "msr_id",
5867 : : .help = "Measurement ID",
5868 : : .next = NEXT(NEXT_ENTRY(ITEM_ECPRI_MSG_DLY_MSR_MSRID,
5869 : : ITEM_ECPRI_COMMON, ITEM_NEXT),
5870 : : NEXT_ENTRY(COMMON_UNSIGNED), item_param),
5871 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ecpri,
5872 : : hdr.type5.msr_id)),
5873 : : },
5874 : : [ITEM_GENEVE_OPT] = {
5875 : : .name = "geneve-opt",
5876 : : .help = "GENEVE header option",
5877 : : .priv = PRIV_ITEM(GENEVE_OPT,
5878 : : sizeof(struct rte_flow_item_geneve_opt) +
5879 : : ITEM_GENEVE_OPT_DATA_SIZE),
5880 : : .next = NEXT(item_geneve_opt),
5881 : : .call = parse_vc,
5882 : : },
5883 : : [ITEM_GENEVE_OPT_CLASS] = {
5884 : : .name = "class",
5885 : : .help = "GENEVE option class",
5886 : : .next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_UNSIGNED),
5887 : : item_param),
5888 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_geneve_opt,
5889 : : option_class)),
5890 : : },
5891 : : [ITEM_GENEVE_OPT_TYPE] = {
5892 : : .name = "type",
5893 : : .help = "GENEVE option type",
5894 : : .next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_UNSIGNED),
5895 : : item_param),
5896 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt,
5897 : : option_type)),
5898 : : },
5899 : : [ITEM_GENEVE_OPT_LENGTH] = {
5900 : : .name = "length",
5901 : : .help = "GENEVE option data length (in 32b words)",
5902 : : .next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_UNSIGNED),
5903 : : item_param),
5904 : : .args = ARGS(ARGS_ENTRY_BOUNDED(
5905 : : struct rte_flow_item_geneve_opt, option_len,
5906 : : 0, 31)),
5907 : : },
5908 : : [ITEM_GENEVE_OPT_DATA] = {
5909 : : .name = "data",
5910 : : .help = "GENEVE option data pattern",
5911 : : .next = NEXT(item_geneve_opt, NEXT_ENTRY(COMMON_HEX),
5912 : : item_param),
5913 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_geneve_opt, data),
5914 : : ARGS_ENTRY_ARB(0, 0),
5915 : : ARGS_ENTRY_ARB
5916 : : (sizeof(struct rte_flow_item_geneve_opt),
5917 : : ITEM_GENEVE_OPT_DATA_SIZE)),
5918 : : },
5919 : : [ITEM_INTEGRITY] = {
5920 : : .name = "integrity",
5921 : : .help = "match packet integrity",
5922 : : .priv = PRIV_ITEM(INTEGRITY,
5923 : : sizeof(struct rte_flow_item_integrity)),
5924 : : .next = NEXT(item_integrity),
5925 : : .call = parse_vc,
5926 : : },
5927 : : [ITEM_INTEGRITY_LEVEL] = {
5928 : : .name = "level",
5929 : : .help = "integrity level",
5930 : : .next = NEXT(item_integrity_lv, NEXT_ENTRY(COMMON_UNSIGNED),
5931 : : item_param),
5932 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_integrity, level)),
5933 : : },
5934 : : [ITEM_INTEGRITY_VALUE] = {
5935 : : .name = "value",
5936 : : .help = "integrity value",
5937 : : .next = NEXT(item_integrity_lv, NEXT_ENTRY(COMMON_UNSIGNED),
5938 : : item_param),
5939 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_integrity, value)),
5940 : : },
5941 : : [ITEM_CONNTRACK] = {
5942 : : .name = "conntrack",
5943 : : .help = "conntrack state",
5944 : : .priv = PRIV_ITEM(CONNTRACK,
5945 : : sizeof(struct rte_flow_item_conntrack)),
5946 : : .next = NEXT(NEXT_ENTRY(ITEM_NEXT), NEXT_ENTRY(COMMON_UNSIGNED),
5947 : : item_param),
5948 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_conntrack, flags)),
5949 : : .call = parse_vc,
5950 : : },
5951 : : [ITEM_PORT_REPRESENTOR] = {
5952 : : .name = "port_representor",
5953 : : .help = "match traffic entering the embedded switch from the given ethdev",
5954 : : .priv = PRIV_ITEM(PORT_REPRESENTOR,
5955 : : sizeof(struct rte_flow_item_ethdev)),
5956 : : .next = NEXT(item_port_representor),
5957 : : .call = parse_vc,
5958 : : },
5959 : : [ITEM_PORT_REPRESENTOR_PORT_ID] = {
5960 : : .name = "port_id",
5961 : : .help = "ethdev port ID",
5962 : : .next = NEXT(item_port_representor, NEXT_ENTRY(COMMON_UNSIGNED),
5963 : : item_param),
5964 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ethdev, port_id)),
5965 : : },
5966 : : [ITEM_REPRESENTED_PORT] = {
5967 : : .name = "represented_port",
5968 : : .help = "match traffic entering the embedded switch from the entity represented by the given ethdev",
5969 : : .priv = PRIV_ITEM(REPRESENTED_PORT,
5970 : : sizeof(struct rte_flow_item_ethdev)),
5971 : : .next = NEXT(item_represented_port),
5972 : : .call = parse_vc,
5973 : : },
5974 : : [ITEM_REPRESENTED_PORT_ETHDEV_PORT_ID] = {
5975 : : .name = "ethdev_port_id",
5976 : : .help = "ethdev port ID",
5977 : : .next = NEXT(item_represented_port, NEXT_ENTRY(COMMON_UNSIGNED),
5978 : : item_param),
5979 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ethdev, port_id)),
5980 : : },
5981 : : [ITEM_FLEX] = {
5982 : : .name = "flex",
5983 : : .help = "match flex header",
5984 : : .priv = PRIV_ITEM(FLEX, sizeof(struct rte_flow_item_flex)),
5985 : : .next = NEXT(item_flex),
5986 : : .call = parse_vc,
5987 : : },
5988 : : [ITEM_FLEX_ITEM_HANDLE] = {
5989 : : .name = "item",
5990 : : .help = "flex item handle",
5991 : : .next = NEXT(item_flex, NEXT_ENTRY(COMMON_FLEX_HANDLE),
5992 : : NEXT_ENTRY(ITEM_PARAM_IS)),
5993 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_flex, handle)),
5994 : : },
5995 : : [ITEM_FLEX_PATTERN_HANDLE] = {
5996 : : .name = "pattern",
5997 : : .help = "flex pattern handle",
5998 : : .next = NEXT(item_flex, NEXT_ENTRY(COMMON_FLEX_HANDLE),
5999 : : NEXT_ENTRY(ITEM_PARAM_IS)),
6000 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_flex, pattern)),
6001 : : },
6002 : : [ITEM_L2TPV2] = {
6003 : : .name = "l2tpv2",
6004 : : .help = "match L2TPv2 header",
6005 : : .priv = PRIV_ITEM(L2TPV2, sizeof(struct rte_flow_item_l2tpv2)),
6006 : : .next = NEXT(item_l2tpv2),
6007 : : .call = parse_vc,
6008 : : },
6009 : : [ITEM_L2TPV2_TYPE] = {
6010 : : .name = "type",
6011 : : .help = "type of l2tpv2",
6012 : : .next = NEXT(item_l2tpv2_type),
6013 : : .args = ARGS(ARG_ENTRY_HTON(struct rte_flow_item_l2tpv2)),
6014 : : },
6015 : : [ITEM_L2TPV2_TYPE_DATA] = {
6016 : : .name = "data",
6017 : : .help = "Type #7: data message without any options",
6018 : : .next = NEXT(item_l2tpv2_type_data),
6019 : : .call = parse_vc_item_l2tpv2_type,
6020 : : },
6021 : : [ITEM_L2TPV2_MSG_DATA_TUNNEL_ID] = {
6022 : : .name = "tunnel_id",
6023 : : .help = "tunnel identifier",
6024 : : .next = NEXT(item_l2tpv2_type_data,
6025 : : NEXT_ENTRY(COMMON_UNSIGNED),
6026 : : item_param),
6027 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6028 : : hdr.type7.tunnel_id)),
6029 : : },
6030 : : [ITEM_L2TPV2_MSG_DATA_SESSION_ID] = {
6031 : : .name = "session_id",
6032 : : .help = "session identifier",
6033 : : .next = NEXT(item_l2tpv2_type_data,
6034 : : NEXT_ENTRY(COMMON_UNSIGNED),
6035 : : item_param),
6036 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6037 : : hdr.type7.session_id)),
6038 : : },
6039 : : [ITEM_L2TPV2_TYPE_DATA_L] = {
6040 : : .name = "data_l",
6041 : : .help = "Type #6: data message with length option",
6042 : : .next = NEXT(item_l2tpv2_type_data_l),
6043 : : .call = parse_vc_item_l2tpv2_type,
6044 : : },
6045 : : [ITEM_L2TPV2_MSG_DATA_L_LENGTH] = {
6046 : : .name = "length",
6047 : : .help = "message length",
6048 : : .next = NEXT(item_l2tpv2_type_data_l,
6049 : : NEXT_ENTRY(COMMON_UNSIGNED),
6050 : : item_param),
6051 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6052 : : hdr.type6.length)),
6053 : : },
6054 : : [ITEM_L2TPV2_MSG_DATA_L_TUNNEL_ID] = {
6055 : : .name = "tunnel_id",
6056 : : .help = "tunnel identifier",
6057 : : .next = NEXT(item_l2tpv2_type_data_l,
6058 : : NEXT_ENTRY(COMMON_UNSIGNED),
6059 : : item_param),
6060 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6061 : : hdr.type6.tunnel_id)),
6062 : : },
6063 : : [ITEM_L2TPV2_MSG_DATA_L_SESSION_ID] = {
6064 : : .name = "session_id",
6065 : : .help = "session identifier",
6066 : : .next = NEXT(item_l2tpv2_type_data_l,
6067 : : NEXT_ENTRY(COMMON_UNSIGNED),
6068 : : item_param),
6069 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6070 : : hdr.type6.session_id)),
6071 : : },
6072 : : [ITEM_L2TPV2_TYPE_DATA_S] = {
6073 : : .name = "data_s",
6074 : : .help = "Type #5: data message with ns, nr option",
6075 : : .next = NEXT(item_l2tpv2_type_data_s),
6076 : : .call = parse_vc_item_l2tpv2_type,
6077 : : },
6078 : : [ITEM_L2TPV2_MSG_DATA_S_TUNNEL_ID] = {
6079 : : .name = "tunnel_id",
6080 : : .help = "tunnel identifier",
6081 : : .next = NEXT(item_l2tpv2_type_data_s,
6082 : : NEXT_ENTRY(COMMON_UNSIGNED),
6083 : : item_param),
6084 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6085 : : hdr.type5.tunnel_id)),
6086 : : },
6087 : : [ITEM_L2TPV2_MSG_DATA_S_SESSION_ID] = {
6088 : : .name = "session_id",
6089 : : .help = "session identifier",
6090 : : .next = NEXT(item_l2tpv2_type_data_s,
6091 : : NEXT_ENTRY(COMMON_UNSIGNED),
6092 : : item_param),
6093 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6094 : : hdr.type5.session_id)),
6095 : : },
6096 : : [ITEM_L2TPV2_MSG_DATA_S_NS] = {
6097 : : .name = "ns",
6098 : : .help = "sequence number for message",
6099 : : .next = NEXT(item_l2tpv2_type_data_s,
6100 : : NEXT_ENTRY(COMMON_UNSIGNED),
6101 : : item_param),
6102 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6103 : : hdr.type5.ns)),
6104 : : },
6105 : : [ITEM_L2TPV2_MSG_DATA_S_NR] = {
6106 : : .name = "nr",
6107 : : .help = "sequence number for next receive message",
6108 : : .next = NEXT(item_l2tpv2_type_data_s,
6109 : : NEXT_ENTRY(COMMON_UNSIGNED),
6110 : : item_param),
6111 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6112 : : hdr.type5.nr)),
6113 : : },
6114 : : [ITEM_L2TPV2_TYPE_DATA_O] = {
6115 : : .name = "data_o",
6116 : : .help = "Type #4: data message with offset option",
6117 : : .next = NEXT(item_l2tpv2_type_data_o),
6118 : : .call = parse_vc_item_l2tpv2_type,
6119 : : },
6120 : : [ITEM_L2TPV2_MSG_DATA_O_TUNNEL_ID] = {
6121 : : .name = "tunnel_id",
6122 : : .help = "tunnel identifier",
6123 : : .next = NEXT(item_l2tpv2_type_data_o,
6124 : : NEXT_ENTRY(COMMON_UNSIGNED),
6125 : : item_param),
6126 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6127 : : hdr.type4.tunnel_id)),
6128 : : },
6129 : : [ITEM_L2TPV2_MSG_DATA_O_SESSION_ID] = {
6130 : : .name = "session_id",
6131 : : .help = "session identifier",
6132 : : .next = NEXT(item_l2tpv2_type_data_o,
6133 : : NEXT_ENTRY(COMMON_UNSIGNED),
6134 : : item_param),
6135 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6136 : : hdr.type5.session_id)),
6137 : : },
6138 : : [ITEM_L2TPV2_MSG_DATA_O_OFFSET] = {
6139 : : .name = "offset_size",
6140 : : .help = "the size of offset padding",
6141 : : .next = NEXT(item_l2tpv2_type_data_o,
6142 : : NEXT_ENTRY(COMMON_UNSIGNED),
6143 : : item_param),
6144 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6145 : : hdr.type4.offset_size)),
6146 : : },
6147 : : [ITEM_L2TPV2_TYPE_DATA_L_S] = {
6148 : : .name = "data_l_s",
6149 : : .help = "Type #3: data message contains length, ns, nr "
6150 : : "options",
6151 : : .next = NEXT(item_l2tpv2_type_data_l_s),
6152 : : .call = parse_vc_item_l2tpv2_type,
6153 : : },
6154 : : [ITEM_L2TPV2_MSG_DATA_L_S_LENGTH] = {
6155 : : .name = "length",
6156 : : .help = "message length",
6157 : : .next = NEXT(item_l2tpv2_type_data_l_s,
6158 : : NEXT_ENTRY(COMMON_UNSIGNED),
6159 : : item_param),
6160 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6161 : : hdr.type3.length)),
6162 : : },
6163 : : [ITEM_L2TPV2_MSG_DATA_L_S_TUNNEL_ID] = {
6164 : : .name = "tunnel_id",
6165 : : .help = "tunnel identifier",
6166 : : .next = NEXT(item_l2tpv2_type_data_l_s,
6167 : : NEXT_ENTRY(COMMON_UNSIGNED),
6168 : : item_param),
6169 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6170 : : hdr.type3.tunnel_id)),
6171 : : },
6172 : : [ITEM_L2TPV2_MSG_DATA_L_S_SESSION_ID] = {
6173 : : .name = "session_id",
6174 : : .help = "session identifier",
6175 : : .next = NEXT(item_l2tpv2_type_data_l_s,
6176 : : NEXT_ENTRY(COMMON_UNSIGNED),
6177 : : item_param),
6178 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6179 : : hdr.type3.session_id)),
6180 : : },
6181 : : [ITEM_L2TPV2_MSG_DATA_L_S_NS] = {
6182 : : .name = "ns",
6183 : : .help = "sequence number for message",
6184 : : .next = NEXT(item_l2tpv2_type_data_l_s,
6185 : : NEXT_ENTRY(COMMON_UNSIGNED),
6186 : : item_param),
6187 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6188 : : hdr.type3.ns)),
6189 : : },
6190 : : [ITEM_L2TPV2_MSG_DATA_L_S_NR] = {
6191 : : .name = "nr",
6192 : : .help = "sequence number for next receive message",
6193 : : .next = NEXT(item_l2tpv2_type_data_l_s,
6194 : : NEXT_ENTRY(COMMON_UNSIGNED),
6195 : : item_param),
6196 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6197 : : hdr.type3.nr)),
6198 : : },
6199 : : [ITEM_L2TPV2_TYPE_CTRL] = {
6200 : : .name = "control",
6201 : : .help = "Type #3: conrtol message contains length, ns, nr "
6202 : : "options",
6203 : : .next = NEXT(item_l2tpv2_type_ctrl),
6204 : : .call = parse_vc_item_l2tpv2_type,
6205 : : },
6206 : : [ITEM_L2TPV2_MSG_CTRL_LENGTH] = {
6207 : : .name = "length",
6208 : : .help = "message length",
6209 : : .next = NEXT(item_l2tpv2_type_ctrl,
6210 : : NEXT_ENTRY(COMMON_UNSIGNED),
6211 : : item_param),
6212 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6213 : : hdr.type3.length)),
6214 : : },
6215 : : [ITEM_L2TPV2_MSG_CTRL_TUNNEL_ID] = {
6216 : : .name = "tunnel_id",
6217 : : .help = "tunnel identifier",
6218 : : .next = NEXT(item_l2tpv2_type_ctrl,
6219 : : NEXT_ENTRY(COMMON_UNSIGNED),
6220 : : item_param),
6221 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6222 : : hdr.type3.tunnel_id)),
6223 : : },
6224 : : [ITEM_L2TPV2_MSG_CTRL_SESSION_ID] = {
6225 : : .name = "session_id",
6226 : : .help = "session identifier",
6227 : : .next = NEXT(item_l2tpv2_type_ctrl,
6228 : : NEXT_ENTRY(COMMON_UNSIGNED),
6229 : : item_param),
6230 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6231 : : hdr.type3.session_id)),
6232 : : },
6233 : : [ITEM_L2TPV2_MSG_CTRL_NS] = {
6234 : : .name = "ns",
6235 : : .help = "sequence number for message",
6236 : : .next = NEXT(item_l2tpv2_type_ctrl,
6237 : : NEXT_ENTRY(COMMON_UNSIGNED),
6238 : : item_param),
6239 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6240 : : hdr.type3.ns)),
6241 : : },
6242 : : [ITEM_L2TPV2_MSG_CTRL_NR] = {
6243 : : .name = "nr",
6244 : : .help = "sequence number for next receive message",
6245 : : .next = NEXT(item_l2tpv2_type_ctrl,
6246 : : NEXT_ENTRY(COMMON_UNSIGNED),
6247 : : item_param),
6248 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
6249 : : hdr.type3.nr)),
6250 : : },
6251 : : [ITEM_PPP] = {
6252 : : .name = "ppp",
6253 : : .help = "match PPP header",
6254 : : .priv = PRIV_ITEM(PPP, sizeof(struct rte_flow_item_ppp)),
6255 : : .next = NEXT(item_ppp),
6256 : : .call = parse_vc,
6257 : : },
6258 : : [ITEM_PPP_ADDR] = {
6259 : : .name = "addr",
6260 : : .help = "PPP address",
6261 : : .next = NEXT(item_ppp, NEXT_ENTRY(COMMON_UNSIGNED),
6262 : : item_param),
6263 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ppp, hdr.addr)),
6264 : : },
6265 : : [ITEM_PPP_CTRL] = {
6266 : : .name = "ctrl",
6267 : : .help = "PPP control",
6268 : : .next = NEXT(item_ppp, NEXT_ENTRY(COMMON_UNSIGNED),
6269 : : item_param),
6270 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ppp, hdr.ctrl)),
6271 : : },
6272 : : [ITEM_PPP_PROTO_ID] = {
6273 : : .name = "proto_id",
6274 : : .help = "PPP protocol identifier",
6275 : : .next = NEXT(item_ppp, NEXT_ENTRY(COMMON_UNSIGNED),
6276 : : item_param),
6277 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ppp,
6278 : : hdr.proto_id)),
6279 : : },
6280 : : [ITEM_METER] = {
6281 : : .name = "meter",
6282 : : .help = "match meter color",
6283 : : .priv = PRIV_ITEM(METER_COLOR,
6284 : : sizeof(struct rte_flow_item_meter_color)),
6285 : : .next = NEXT(item_meter),
6286 : : .call = parse_vc,
6287 : : },
6288 : : [ITEM_METER_COLOR] = {
6289 : : .name = "color",
6290 : : .help = "meter color",
6291 : : .next = NEXT(item_meter,
6292 : : NEXT_ENTRY(COMMON_METER_COLOR_NAME),
6293 : : item_param),
6294 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_meter_color,
6295 : : color)),
6296 : : },
6297 : : [ITEM_QUOTA] = {
6298 : : .name = "quota",
6299 : : .help = "match quota",
6300 : : .priv = PRIV_ITEM(QUOTA, sizeof(struct rte_flow_item_quota)),
6301 : : .next = NEXT(item_quota),
6302 : : .call = parse_vc
6303 : : },
6304 : : [ITEM_QUOTA_STATE] = {
6305 : : .name = "quota_state",
6306 : : .help = "quota state",
6307 : : .next = NEXT(item_quota, NEXT_ENTRY(ITEM_QUOTA_STATE_NAME),
6308 : : NEXT_ENTRY(ITEM_PARAM_SPEC, ITEM_PARAM_MASK)),
6309 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_quota, state))
6310 : : },
6311 : : [ITEM_QUOTA_STATE_NAME] = {
6312 : : .name = "state_name",
6313 : : .help = "quota state name",
6314 : : .call = parse_quota_state_name,
6315 : : .comp = comp_quota_state_name
6316 : : },
6317 : : [ITEM_IB_BTH] = {
6318 : : .name = "ib_bth",
6319 : : .help = "match ib bth fields",
6320 : : .priv = PRIV_ITEM(IB_BTH,
6321 : : sizeof(struct rte_flow_item_ib_bth)),
6322 : : .next = NEXT(item_ib_bth),
6323 : : .call = parse_vc,
6324 : : },
6325 : : [ITEM_IB_BTH_OPCODE] = {
6326 : : .name = "opcode",
6327 : : .help = "match ib bth opcode",
6328 : : .next = NEXT(item_ib_bth, NEXT_ENTRY(COMMON_UNSIGNED),
6329 : : item_param),
6330 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ib_bth,
6331 : : hdr.opcode)),
6332 : : },
6333 : : [ITEM_IB_BTH_PKEY] = {
6334 : : .name = "pkey",
6335 : : .help = "partition key",
6336 : : .next = NEXT(item_ib_bth, NEXT_ENTRY(COMMON_UNSIGNED),
6337 : : item_param),
6338 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ib_bth,
6339 : : hdr.pkey)),
6340 : : },
6341 : : [ITEM_IB_BTH_DST_QPN] = {
6342 : : .name = "dst_qp",
6343 : : .help = "destination qp",
6344 : : .next = NEXT(item_ib_bth, NEXT_ENTRY(COMMON_UNSIGNED),
6345 : : item_param),
6346 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ib_bth,
6347 : : hdr.dst_qp)),
6348 : : },
6349 : : [ITEM_IB_BTH_PSN] = {
6350 : : .name = "psn",
6351 : : .help = "packet sequence number",
6352 : : .next = NEXT(item_ib_bth, NEXT_ENTRY(COMMON_UNSIGNED),
6353 : : item_param),
6354 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ib_bth,
6355 : : hdr.psn)),
6356 : : },
6357 : : [ITEM_PTYPE] = {
6358 : : .name = "ptype",
6359 : : .help = "match L2/L3/L4 and tunnel information",
6360 : : .priv = PRIV_ITEM(PTYPE,
6361 : : sizeof(struct rte_flow_item_ptype)),
6362 : : .next = NEXT(item_ptype),
6363 : : .call = parse_vc,
6364 : : },
6365 : : [ITEM_PTYPE_VALUE] = {
6366 : : .name = "packet_type",
6367 : : .help = "packet type as defined in rte_mbuf_ptype",
6368 : : .next = NEXT(item_ptype, NEXT_ENTRY(COMMON_UNSIGNED),
6369 : : item_param),
6370 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ptype, packet_type)),
6371 : : },
6372 : : [ITEM_NSH] = {
6373 : : .name = "nsh",
6374 : : .help = "match NSH header",
6375 : : .priv = PRIV_ITEM(NSH,
6376 : : sizeof(struct rte_flow_item_nsh)),
6377 : : .next = NEXT(item_nsh),
6378 : : .call = parse_vc,
6379 : : },
6380 : : [ITEM_COMPARE] = {
6381 : : .name = "compare",
6382 : : .help = "match with the comparison result",
6383 : : .priv = PRIV_ITEM(COMPARE, sizeof(struct rte_flow_item_compare)),
6384 : : .next = NEXT(NEXT_ENTRY(ITEM_COMPARE_OP)),
6385 : : .call = parse_vc,
6386 : : },
6387 : : [ITEM_COMPARE_OP] = {
6388 : : .name = "op",
6389 : : .help = "operation type",
6390 : : .next = NEXT(item_compare_field,
6391 : : NEXT_ENTRY(ITEM_COMPARE_OP_VALUE), item_param),
6392 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, operation)),
6393 : : },
6394 : : [ITEM_COMPARE_OP_VALUE] = {
6395 : : .name = "{operation}",
6396 : : .help = "operation type value",
6397 : : .call = parse_vc_compare_op,
6398 : : .comp = comp_set_compare_op,
6399 : : },
6400 : : [ITEM_COMPARE_FIELD_A_TYPE] = {
6401 : : .name = "a_type",
6402 : : .help = "compared field type",
6403 : : .next = NEXT(compare_field_a,
6404 : : NEXT_ENTRY(ITEM_COMPARE_FIELD_A_TYPE_VALUE), item_param),
6405 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, a.field)),
6406 : : },
6407 : : [ITEM_COMPARE_FIELD_A_TYPE_VALUE] = {
6408 : : .name = "{a_type}",
6409 : : .help = "compared field type value",
6410 : : .call = parse_vc_compare_field_id,
6411 : : .comp = comp_set_compare_field_id,
6412 : : },
6413 : : [ITEM_COMPARE_FIELD_A_LEVEL] = {
6414 : : .name = "a_level",
6415 : : .help = "compared field level",
6416 : : .next = NEXT(compare_field_a,
6417 : : NEXT_ENTRY(ITEM_COMPARE_FIELD_A_LEVEL_VALUE), item_param),
6418 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare, a.level)),
6419 : : },
6420 : : [ITEM_COMPARE_FIELD_A_LEVEL_VALUE] = {
6421 : : .name = "{a_level}",
6422 : : .help = "compared field level value",
6423 : : .call = parse_vc_compare_field_level,
6424 : : .comp = comp_none,
6425 : : },
6426 : : [ITEM_COMPARE_FIELD_A_TAG_INDEX] = {
6427 : : .name = "a_tag_index",
6428 : : .help = "compared field tag array",
6429 : : .next = NEXT(compare_field_a,
6430 : : NEXT_ENTRY(COMMON_UNSIGNED), item_param),
6431 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare,
6432 : : a.tag_index)),
6433 : : },
6434 : : [ITEM_COMPARE_FIELD_A_TYPE_ID] = {
6435 : : .name = "a_type_id",
6436 : : .help = "compared field type ID",
6437 : : .next = NEXT(compare_field_a,
6438 : : NEXT_ENTRY(COMMON_UNSIGNED), item_param),
6439 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare,
6440 : : a.type)),
6441 : : },
6442 : : [ITEM_COMPARE_FIELD_A_CLASS_ID] = {
6443 : : .name = "a_class",
6444 : : .help = "compared field class ID",
6445 : : .next = NEXT(compare_field_a,
6446 : : NEXT_ENTRY(COMMON_UNSIGNED), item_param),
6447 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_compare,
6448 : : a.class_id)),
6449 : : },
6450 : : [ITEM_COMPARE_FIELD_A_OFFSET] = {
6451 : : .name = "a_offset",
6452 : : .help = "compared field bit offset",
6453 : : .next = NEXT(compare_field_a,
6454 : : NEXT_ENTRY(COMMON_UNSIGNED), item_param),
6455 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare,
6456 : : a.offset)),
6457 : : },
6458 : : [ITEM_COMPARE_FIELD_B_TYPE] = {
6459 : : .name = "b_type",
6460 : : .help = "comparator field type",
6461 : : .next = NEXT(compare_field_b,
6462 : : NEXT_ENTRY(ITEM_COMPARE_FIELD_B_TYPE_VALUE), item_param),
6463 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare,
6464 : : b.field)),
6465 : : },
6466 : : [ITEM_COMPARE_FIELD_B_TYPE_VALUE] = {
6467 : : .name = "{b_type}",
6468 : : .help = "comparator field type value",
6469 : : .call = parse_vc_compare_field_id,
6470 : : .comp = comp_set_compare_field_id,
6471 : : },
6472 : : [ITEM_COMPARE_FIELD_B_LEVEL] = {
6473 : : .name = "b_level",
6474 : : .help = "comparator field level",
6475 : : .next = NEXT(compare_field_b,
6476 : : NEXT_ENTRY(ITEM_COMPARE_FIELD_B_LEVEL_VALUE), item_param),
6477 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare,
6478 : : b.level)),
6479 : : },
6480 : : [ITEM_COMPARE_FIELD_B_LEVEL_VALUE] = {
6481 : : .name = "{b_level}",
6482 : : .help = "comparator field level value",
6483 : : .call = parse_vc_compare_field_level,
6484 : : .comp = comp_none,
6485 : : },
6486 : : [ITEM_COMPARE_FIELD_B_TAG_INDEX] = {
6487 : : .name = "b_tag_index",
6488 : : .help = "comparator field tag array",
6489 : : .next = NEXT(compare_field_b,
6490 : : NEXT_ENTRY(COMMON_UNSIGNED), item_param),
6491 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare,
6492 : : b.tag_index)),
6493 : : },
6494 : : [ITEM_COMPARE_FIELD_B_TYPE_ID] = {
6495 : : .name = "b_type_id",
6496 : : .help = "comparator field type ID",
6497 : : .next = NEXT(compare_field_b,
6498 : : NEXT_ENTRY(COMMON_UNSIGNED), item_param),
6499 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare,
6500 : : b.type)),
6501 : : },
6502 : : [ITEM_COMPARE_FIELD_B_CLASS_ID] = {
6503 : : .name = "b_class",
6504 : : .help = "comparator field class ID",
6505 : : .next = NEXT(compare_field_b,
6506 : : NEXT_ENTRY(COMMON_UNSIGNED), item_param),
6507 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_compare,
6508 : : b.class_id)),
6509 : : },
6510 : : [ITEM_COMPARE_FIELD_B_OFFSET] = {
6511 : : .name = "b_offset",
6512 : : .help = "comparator field bit offset",
6513 : : .next = NEXT(compare_field_b,
6514 : : NEXT_ENTRY(COMMON_UNSIGNED), item_param),
6515 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare,
6516 : : b.offset)),
6517 : : },
6518 : : [ITEM_COMPARE_FIELD_B_VALUE] = {
6519 : : .name = "b_value",
6520 : : .help = "comparator immediate value",
6521 : : .next = NEXT(compare_field_b,
6522 : : NEXT_ENTRY(COMMON_HEX), item_param),
6523 : : .args = ARGS(ARGS_ENTRY_ARB(0, 0),
6524 : : ARGS_ENTRY_ARB(0, 0),
6525 : : ARGS_ENTRY(struct rte_flow_item_compare,
6526 : : b.value)),
6527 : : },
6528 : : [ITEM_COMPARE_FIELD_B_POINTER] = {
6529 : : .name = "b_ptr",
6530 : : .help = "pointer to comparator immediate value",
6531 : : .next = NEXT(compare_field_b,
6532 : : NEXT_ENTRY(COMMON_HEX), item_param),
6533 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare,
6534 : : b.pvalue),
6535 : : ARGS_ENTRY_ARB(0, 0),
6536 : : ARGS_ENTRY_ARB
6537 : : (sizeof(struct rte_flow_item_compare),
6538 : : FLOW_FIELD_PATTERN_SIZE)),
6539 : : },
6540 : : [ITEM_COMPARE_FIELD_WIDTH] = {
6541 : : .name = "width",
6542 : : .help = "number of bits to compare",
6543 : : .next = NEXT(item_compare_field,
6544 : : NEXT_ENTRY(COMMON_UNSIGNED), item_param),
6545 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_compare,
6546 : : width)),
6547 : : },
6548 : :
6549 : : /* Validate/create actions. */
6550 : : [ACTIONS] = {
6551 : : .name = "actions",
6552 : : .help = "submit a list of associated actions",
6553 : : .next = NEXT(next_action),
6554 : : .call = parse_vc,
6555 : : },
6556 : : [ACTION_NEXT] = {
6557 : : .name = "/",
6558 : : .help = "specify next action",
6559 : : .next = NEXT(next_action),
6560 : : },
6561 : : [ACTION_END] = {
6562 : : .name = "end",
6563 : : .help = "end list of actions",
6564 : : .priv = PRIV_ACTION(END, 0),
6565 : : .call = parse_vc,
6566 : : },
6567 : : [ACTION_VOID] = {
6568 : : .name = "void",
6569 : : .help = "no-op action",
6570 : : .priv = PRIV_ACTION(VOID, 0),
6571 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
6572 : : .call = parse_vc,
6573 : : },
6574 : : [ACTION_PASSTHRU] = {
6575 : : .name = "passthru",
6576 : : .help = "let subsequent rule process matched packets",
6577 : : .priv = PRIV_ACTION(PASSTHRU, 0),
6578 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
6579 : : .call = parse_vc,
6580 : : },
6581 : : [ACTION_SKIP_CMAN] = {
6582 : : .name = "skip_cman",
6583 : : .help = "bypass cman on received packets",
6584 : : .priv = PRIV_ACTION(SKIP_CMAN, 0),
6585 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
6586 : : .call = parse_vc,
6587 : : },
6588 : : [ACTION_JUMP] = {
6589 : : .name = "jump",
6590 : : .help = "redirect traffic to a given group",
6591 : : .priv = PRIV_ACTION(JUMP, sizeof(struct rte_flow_action_jump)),
6592 : : .next = NEXT(action_jump),
6593 : : .call = parse_vc,
6594 : : },
6595 : : [ACTION_JUMP_GROUP] = {
6596 : : .name = "group",
6597 : : .help = "group to redirect traffic to",
6598 : : .next = NEXT(action_jump, NEXT_ENTRY(COMMON_UNSIGNED)),
6599 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump, group)),
6600 : : .call = parse_vc_conf,
6601 : : },
6602 : : [ACTION_MARK] = {
6603 : : .name = "mark",
6604 : : .help = "attach 32 bit value to packets",
6605 : : .priv = PRIV_ACTION(MARK, sizeof(struct rte_flow_action_mark)),
6606 : : .next = NEXT(action_mark),
6607 : : .call = parse_vc,
6608 : : },
6609 : : [ACTION_MARK_ID] = {
6610 : : .name = "id",
6611 : : .help = "32 bit value to return with packets",
6612 : : .next = NEXT(action_mark, NEXT_ENTRY(COMMON_UNSIGNED)),
6613 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_mark, id)),
6614 : : .call = parse_vc_conf,
6615 : : },
6616 : : [ACTION_FLAG] = {
6617 : : .name = "flag",
6618 : : .help = "flag packets",
6619 : : .priv = PRIV_ACTION(FLAG, 0),
6620 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
6621 : : .call = parse_vc,
6622 : : },
6623 : : [ACTION_QUEUE] = {
6624 : : .name = "queue",
6625 : : .help = "assign packets to a given queue index",
6626 : : .priv = PRIV_ACTION(QUEUE,
6627 : : sizeof(struct rte_flow_action_queue)),
6628 : : .next = NEXT(action_queue),
6629 : : .call = parse_vc,
6630 : : },
6631 : : [ACTION_QUEUE_INDEX] = {
6632 : : .name = "index",
6633 : : .help = "queue index to use",
6634 : : .next = NEXT(action_queue, NEXT_ENTRY(COMMON_UNSIGNED)),
6635 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_queue, index)),
6636 : : .call = parse_vc_conf,
6637 : : },
6638 : : [ACTION_DROP] = {
6639 : : .name = "drop",
6640 : : .help = "drop packets (note: passthru has priority)",
6641 : : .priv = PRIV_ACTION(DROP, 0),
6642 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
6643 : : .call = parse_vc,
6644 : : },
6645 : : [ACTION_COUNT] = {
6646 : : .name = "count",
6647 : : .help = "enable counters for this rule",
6648 : : .priv = PRIV_ACTION(COUNT,
6649 : : sizeof(struct rte_flow_action_count)),
6650 : : .next = NEXT(action_count),
6651 : : .call = parse_vc,
6652 : : },
6653 : : [ACTION_COUNT_ID] = {
6654 : : .name = "identifier",
6655 : : .help = "counter identifier to use",
6656 : : .next = NEXT(action_count, NEXT_ENTRY(COMMON_UNSIGNED)),
6657 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_count, id)),
6658 : : .call = parse_vc_conf,
6659 : : },
6660 : : [ACTION_RSS] = {
6661 : : .name = "rss",
6662 : : .help = "spread packets among several queues",
6663 : : .priv = PRIV_ACTION(RSS, sizeof(struct action_rss_data)),
6664 : : .next = NEXT(action_rss),
6665 : : .call = parse_vc_action_rss,
6666 : : },
6667 : : [ACTION_RSS_FUNC] = {
6668 : : .name = "func",
6669 : : .help = "RSS hash function to apply",
6670 : : .next = NEXT(action_rss,
6671 : : NEXT_ENTRY(ACTION_RSS_FUNC_DEFAULT,
6672 : : ACTION_RSS_FUNC_TOEPLITZ,
6673 : : ACTION_RSS_FUNC_SIMPLE_XOR,
6674 : : ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ)),
6675 : : },
6676 : : [ACTION_RSS_FUNC_DEFAULT] = {
6677 : : .name = "default",
6678 : : .help = "default hash function",
6679 : : .call = parse_vc_action_rss_func,
6680 : : },
6681 : : [ACTION_RSS_FUNC_TOEPLITZ] = {
6682 : : .name = "toeplitz",
6683 : : .help = "Toeplitz hash function",
6684 : : .call = parse_vc_action_rss_func,
6685 : : },
6686 : : [ACTION_RSS_FUNC_SIMPLE_XOR] = {
6687 : : .name = "simple_xor",
6688 : : .help = "simple XOR hash function",
6689 : : .call = parse_vc_action_rss_func,
6690 : : },
6691 : : [ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ] = {
6692 : : .name = "symmetric_toeplitz",
6693 : : .help = "Symmetric Toeplitz hash function",
6694 : : .call = parse_vc_action_rss_func,
6695 : : },
6696 : : [ACTION_RSS_LEVEL] = {
6697 : : .name = "level",
6698 : : .help = "encapsulation level for \"types\"",
6699 : : .next = NEXT(action_rss, NEXT_ENTRY(COMMON_UNSIGNED)),
6700 : : .args = ARGS(ARGS_ENTRY_ARB
6701 : : (offsetof(struct action_rss_data, conf) +
6702 : : offsetof(struct rte_flow_action_rss, level),
6703 : : sizeof(((struct rte_flow_action_rss *)0)->
6704 : : level))),
6705 : : },
6706 : : [ACTION_RSS_TYPES] = {
6707 : : .name = "types",
6708 : : .help = "specific RSS hash types",
6709 : : .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_TYPE)),
6710 : : },
6711 : : [ACTION_RSS_TYPE] = {
6712 : : .name = "{type}",
6713 : : .help = "RSS hash type",
6714 : : .call = parse_vc_action_rss_type,
6715 : : .comp = comp_vc_action_rss_type,
6716 : : },
6717 : : [ACTION_RSS_KEY] = {
6718 : : .name = "key",
6719 : : .help = "RSS hash key",
6720 : : .next = NEXT(action_rss, NEXT_ENTRY(COMMON_HEX)),
6721 : : .args = ARGS(ARGS_ENTRY_ARB
6722 : : (offsetof(struct action_rss_data, conf) +
6723 : : offsetof(struct rte_flow_action_rss, key),
6724 : : sizeof(((struct rte_flow_action_rss *)0)->key)),
6725 : : ARGS_ENTRY_ARB
6726 : : (offsetof(struct action_rss_data, conf) +
6727 : : offsetof(struct rte_flow_action_rss, key_len),
6728 : : sizeof(((struct rte_flow_action_rss *)0)->
6729 : : key_len)),
6730 : : ARGS_ENTRY(struct action_rss_data, key)),
6731 : : },
6732 : : [ACTION_RSS_KEY_LEN] = {
6733 : : .name = "key_len",
6734 : : .help = "RSS hash key length in bytes",
6735 : : .next = NEXT(action_rss, NEXT_ENTRY(COMMON_UNSIGNED)),
6736 : : .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
6737 : : (offsetof(struct action_rss_data, conf) +
6738 : : offsetof(struct rte_flow_action_rss, key_len),
6739 : : sizeof(((struct rte_flow_action_rss *)0)->
6740 : : key_len),
6741 : : 0,
6742 : : RSS_HASH_KEY_LENGTH)),
6743 : : },
6744 : : [ACTION_RSS_QUEUES] = {
6745 : : .name = "queues",
6746 : : .help = "queue indices to use",
6747 : : .next = NEXT(action_rss, NEXT_ENTRY(ACTION_RSS_QUEUE)),
6748 : : .call = parse_vc_conf,
6749 : : },
6750 : : [ACTION_RSS_QUEUE] = {
6751 : : .name = "{queue}",
6752 : : .help = "queue index",
6753 : : .call = parse_vc_action_rss_queue,
6754 : : .comp = comp_vc_action_rss_queue,
6755 : : },
6756 : : [ACTION_PF] = {
6757 : : .name = "pf",
6758 : : .help = "direct traffic to physical function",
6759 : : .priv = PRIV_ACTION(PF, 0),
6760 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
6761 : : .call = parse_vc,
6762 : : },
6763 : : [ACTION_VF] = {
6764 : : .name = "vf",
6765 : : .help = "direct traffic to a virtual function ID",
6766 : : .priv = PRIV_ACTION(VF, sizeof(struct rte_flow_action_vf)),
6767 : : .next = NEXT(action_vf),
6768 : : .call = parse_vc,
6769 : : },
6770 : : [ACTION_VF_ORIGINAL] = {
6771 : : .name = "original",
6772 : : .help = "use original VF ID if possible",
6773 : : .next = NEXT(action_vf, NEXT_ENTRY(COMMON_BOOLEAN)),
6774 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_vf,
6775 : : original, 1)),
6776 : : .call = parse_vc_conf,
6777 : : },
6778 : : [ACTION_VF_ID] = {
6779 : : .name = "id",
6780 : : .help = "VF ID",
6781 : : .next = NEXT(action_vf, NEXT_ENTRY(COMMON_UNSIGNED)),
6782 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vf, id)),
6783 : : .call = parse_vc_conf,
6784 : : },
6785 : : [ACTION_PORT_ID] = {
6786 : : .name = "port_id",
6787 : : .help = "direct matching traffic to a given DPDK port ID",
6788 : : .priv = PRIV_ACTION(PORT_ID,
6789 : : sizeof(struct rte_flow_action_port_id)),
6790 : : .next = NEXT(action_port_id),
6791 : : .call = parse_vc,
6792 : : },
6793 : : [ACTION_PORT_ID_ORIGINAL] = {
6794 : : .name = "original",
6795 : : .help = "use original DPDK port ID if possible",
6796 : : .next = NEXT(action_port_id, NEXT_ENTRY(COMMON_BOOLEAN)),
6797 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_port_id,
6798 : : original, 1)),
6799 : : .call = parse_vc_conf,
6800 : : },
6801 : : [ACTION_PORT_ID_ID] = {
6802 : : .name = "id",
6803 : : .help = "DPDK port ID",
6804 : : .next = NEXT(action_port_id, NEXT_ENTRY(COMMON_UNSIGNED)),
6805 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_port_id, id)),
6806 : : .call = parse_vc_conf,
6807 : : },
6808 : : [ACTION_METER] = {
6809 : : .name = "meter",
6810 : : .help = "meter the directed packets at given id",
6811 : : .priv = PRIV_ACTION(METER,
6812 : : sizeof(struct rte_flow_action_meter)),
6813 : : .next = NEXT(action_meter),
6814 : : .call = parse_vc,
6815 : : },
6816 : : [ACTION_METER_COLOR] = {
6817 : : .name = "color",
6818 : : .help = "meter color for the packets",
6819 : : .priv = PRIV_ACTION(METER_COLOR,
6820 : : sizeof(struct rte_flow_action_meter_color)),
6821 : : .next = NEXT(action_meter_color),
6822 : : .call = parse_vc,
6823 : : },
6824 : : [ACTION_METER_COLOR_TYPE] = {
6825 : : .name = "type",
6826 : : .help = "specific meter color",
6827 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT),
6828 : : NEXT_ENTRY(ACTION_METER_COLOR_GREEN,
6829 : : ACTION_METER_COLOR_YELLOW,
6830 : : ACTION_METER_COLOR_RED)),
6831 : : },
6832 : : [ACTION_METER_COLOR_GREEN] = {
6833 : : .name = "green",
6834 : : .help = "meter color green",
6835 : : .call = parse_vc_action_meter_color_type,
6836 : : },
6837 : : [ACTION_METER_COLOR_YELLOW] = {
6838 : : .name = "yellow",
6839 : : .help = "meter color yellow",
6840 : : .call = parse_vc_action_meter_color_type,
6841 : : },
6842 : : [ACTION_METER_COLOR_RED] = {
6843 : : .name = "red",
6844 : : .help = "meter color red",
6845 : : .call = parse_vc_action_meter_color_type,
6846 : : },
6847 : : [ACTION_METER_ID] = {
6848 : : .name = "mtr_id",
6849 : : .help = "meter id to use",
6850 : : .next = NEXT(action_meter, NEXT_ENTRY(COMMON_UNSIGNED)),
6851 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter, mtr_id)),
6852 : : .call = parse_vc_conf,
6853 : : },
6854 : : [ACTION_METER_MARK] = {
6855 : : .name = "meter_mark",
6856 : : .help = "meter the directed packets using profile and policy",
6857 : : .priv = PRIV_ACTION(METER_MARK,
6858 : : sizeof(struct rte_flow_action_meter_mark)),
6859 : : .next = NEXT(action_meter_mark),
6860 : : .call = parse_vc,
6861 : : },
6862 : : [ACTION_METER_MARK_CONF] = {
6863 : : .name = "meter_mark_conf",
6864 : : .help = "meter mark configuration",
6865 : : .priv = PRIV_ACTION(METER_MARK,
6866 : : sizeof(struct rte_flow_action_meter_mark)),
6867 : : .next = NEXT(NEXT_ENTRY(ACTION_METER_MARK_CONF_COLOR)),
6868 : : .call = parse_vc,
6869 : : },
6870 : : [ACTION_METER_MARK_CONF_COLOR] = {
6871 : : .name = "mtr_update_init_color",
6872 : : .help = "meter update init color",
6873 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT),
6874 : : NEXT_ENTRY(COMMON_METER_COLOR_NAME)),
6875 : : .args = ARGS(ARGS_ENTRY
6876 : : (struct rte_flow_indirect_update_flow_meter_mark,
6877 : : init_color)),
6878 : : },
6879 : : [ACTION_METER_PROFILE] = {
6880 : : .name = "mtr_profile",
6881 : : .help = "meter profile id to use",
6882 : : .next = NEXT(NEXT_ENTRY(ACTION_METER_PROFILE_ID2PTR)),
6883 : : .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
6884 : : },
6885 : : [ACTION_METER_PROFILE_ID2PTR] = {
6886 : : .name = "{mtr_profile_id}",
6887 : : .type = "PROFILE_ID",
6888 : : .help = "meter profile id",
6889 : : .next = NEXT(action_meter_mark),
6890 : : .call = parse_meter_profile_id2ptr,
6891 : : .comp = comp_none,
6892 : : },
6893 : : [ACTION_METER_POLICY] = {
6894 : : .name = "mtr_policy",
6895 : : .help = "meter policy id to use",
6896 : : .next = NEXT(NEXT_ENTRY(ACTION_METER_POLICY_ID2PTR)),
6897 : : ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
6898 : : },
6899 : : [ACTION_METER_POLICY_ID2PTR] = {
6900 : : .name = "{mtr_policy_id}",
6901 : : .type = "POLICY_ID",
6902 : : .help = "meter policy id",
6903 : : .next = NEXT(action_meter_mark),
6904 : : .call = parse_meter_policy_id2ptr,
6905 : : .comp = comp_none,
6906 : : },
6907 : : [ACTION_METER_COLOR_MODE] = {
6908 : : .name = "mtr_color_mode",
6909 : : .help = "meter color awareness mode",
6910 : : .next = NEXT(action_meter_mark, NEXT_ENTRY(COMMON_UNSIGNED)),
6911 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter_mark, color_mode)),
6912 : : .call = parse_vc_conf,
6913 : : },
6914 : : [ACTION_METER_STATE] = {
6915 : : .name = "mtr_state",
6916 : : .help = "meter state",
6917 : : .next = NEXT(action_meter_mark, NEXT_ENTRY(COMMON_UNSIGNED)),
6918 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter_mark, state)),
6919 : : .call = parse_vc_conf,
6920 : : },
6921 : : [ACTION_OF_DEC_NW_TTL] = {
6922 : : .name = "of_dec_nw_ttl",
6923 : : .help = "OpenFlow's OFPAT_DEC_NW_TTL",
6924 : : .priv = PRIV_ACTION(OF_DEC_NW_TTL, 0),
6925 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
6926 : : .call = parse_vc,
6927 : : },
6928 : : [ACTION_OF_POP_VLAN] = {
6929 : : .name = "of_pop_vlan",
6930 : : .help = "OpenFlow's OFPAT_POP_VLAN",
6931 : : .priv = PRIV_ACTION(OF_POP_VLAN, 0),
6932 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
6933 : : .call = parse_vc,
6934 : : },
6935 : : [ACTION_OF_PUSH_VLAN] = {
6936 : : .name = "of_push_vlan",
6937 : : .help = "OpenFlow's OFPAT_PUSH_VLAN",
6938 : : .priv = PRIV_ACTION
6939 : : (OF_PUSH_VLAN,
6940 : : sizeof(struct rte_flow_action_of_push_vlan)),
6941 : : .next = NEXT(action_of_push_vlan),
6942 : : .call = parse_vc,
6943 : : },
6944 : : [ACTION_OF_PUSH_VLAN_ETHERTYPE] = {
6945 : : .name = "ethertype",
6946 : : .help = "EtherType",
6947 : : .next = NEXT(action_of_push_vlan, NEXT_ENTRY(COMMON_UNSIGNED)),
6948 : : .args = ARGS(ARGS_ENTRY_HTON
6949 : : (struct rte_flow_action_of_push_vlan,
6950 : : ethertype)),
6951 : : .call = parse_vc_conf,
6952 : : },
6953 : : [ACTION_OF_SET_VLAN_VID] = {
6954 : : .name = "of_set_vlan_vid",
6955 : : .help = "OpenFlow's OFPAT_SET_VLAN_VID",
6956 : : .priv = PRIV_ACTION
6957 : : (OF_SET_VLAN_VID,
6958 : : sizeof(struct rte_flow_action_of_set_vlan_vid)),
6959 : : .next = NEXT(action_of_set_vlan_vid),
6960 : : .call = parse_vc,
6961 : : },
6962 : : [ACTION_OF_SET_VLAN_VID_VLAN_VID] = {
6963 : : .name = "vlan_vid",
6964 : : .help = "VLAN id",
6965 : : .next = NEXT(action_of_set_vlan_vid,
6966 : : NEXT_ENTRY(COMMON_UNSIGNED)),
6967 : : .args = ARGS(ARGS_ENTRY_HTON
6968 : : (struct rte_flow_action_of_set_vlan_vid,
6969 : : vlan_vid)),
6970 : : .call = parse_vc_conf,
6971 : : },
6972 : : [ACTION_OF_SET_VLAN_PCP] = {
6973 : : .name = "of_set_vlan_pcp",
6974 : : .help = "OpenFlow's OFPAT_SET_VLAN_PCP",
6975 : : .priv = PRIV_ACTION
6976 : : (OF_SET_VLAN_PCP,
6977 : : sizeof(struct rte_flow_action_of_set_vlan_pcp)),
6978 : : .next = NEXT(action_of_set_vlan_pcp),
6979 : : .call = parse_vc,
6980 : : },
6981 : : [ACTION_OF_SET_VLAN_PCP_VLAN_PCP] = {
6982 : : .name = "vlan_pcp",
6983 : : .help = "VLAN priority",
6984 : : .next = NEXT(action_of_set_vlan_pcp,
6985 : : NEXT_ENTRY(COMMON_UNSIGNED)),
6986 : : .args = ARGS(ARGS_ENTRY_HTON
6987 : : (struct rte_flow_action_of_set_vlan_pcp,
6988 : : vlan_pcp)),
6989 : : .call = parse_vc_conf,
6990 : : },
6991 : : [ACTION_OF_POP_MPLS] = {
6992 : : .name = "of_pop_mpls",
6993 : : .help = "OpenFlow's OFPAT_POP_MPLS",
6994 : : .priv = PRIV_ACTION(OF_POP_MPLS,
6995 : : sizeof(struct rte_flow_action_of_pop_mpls)),
6996 : : .next = NEXT(action_of_pop_mpls),
6997 : : .call = parse_vc,
6998 : : },
6999 : : [ACTION_OF_POP_MPLS_ETHERTYPE] = {
7000 : : .name = "ethertype",
7001 : : .help = "EtherType",
7002 : : .next = NEXT(action_of_pop_mpls, NEXT_ENTRY(COMMON_UNSIGNED)),
7003 : : .args = ARGS(ARGS_ENTRY_HTON
7004 : : (struct rte_flow_action_of_pop_mpls,
7005 : : ethertype)),
7006 : : .call = parse_vc_conf,
7007 : : },
7008 : : [ACTION_OF_PUSH_MPLS] = {
7009 : : .name = "of_push_mpls",
7010 : : .help = "OpenFlow's OFPAT_PUSH_MPLS",
7011 : : .priv = PRIV_ACTION
7012 : : (OF_PUSH_MPLS,
7013 : : sizeof(struct rte_flow_action_of_push_mpls)),
7014 : : .next = NEXT(action_of_push_mpls),
7015 : : .call = parse_vc,
7016 : : },
7017 : : [ACTION_OF_PUSH_MPLS_ETHERTYPE] = {
7018 : : .name = "ethertype",
7019 : : .help = "EtherType",
7020 : : .next = NEXT(action_of_push_mpls, NEXT_ENTRY(COMMON_UNSIGNED)),
7021 : : .args = ARGS(ARGS_ENTRY_HTON
7022 : : (struct rte_flow_action_of_push_mpls,
7023 : : ethertype)),
7024 : : .call = parse_vc_conf,
7025 : : },
7026 : : [ACTION_VXLAN_ENCAP] = {
7027 : : .name = "vxlan_encap",
7028 : : .help = "VXLAN encapsulation, uses configuration set by \"set"
7029 : : " vxlan\"",
7030 : : .priv = PRIV_ACTION(VXLAN_ENCAP,
7031 : : sizeof(struct action_vxlan_encap_data)),
7032 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7033 : : .call = parse_vc_action_vxlan_encap,
7034 : : },
7035 : : [ACTION_VXLAN_DECAP] = {
7036 : : .name = "vxlan_decap",
7037 : : .help = "Performs a decapsulation action by stripping all"
7038 : : " headers of the VXLAN tunnel network overlay from the"
7039 : : " matched flow.",
7040 : : .priv = PRIV_ACTION(VXLAN_DECAP, 0),
7041 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7042 : : .call = parse_vc,
7043 : : },
7044 : : [ACTION_NVGRE_ENCAP] = {
7045 : : .name = "nvgre_encap",
7046 : : .help = "NVGRE encapsulation, uses configuration set by \"set"
7047 : : " nvgre\"",
7048 : : .priv = PRIV_ACTION(NVGRE_ENCAP,
7049 : : sizeof(struct action_nvgre_encap_data)),
7050 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7051 : : .call = parse_vc_action_nvgre_encap,
7052 : : },
7053 : : [ACTION_NVGRE_DECAP] = {
7054 : : .name = "nvgre_decap",
7055 : : .help = "Performs a decapsulation action by stripping all"
7056 : : " headers of the NVGRE tunnel network overlay from the"
7057 : : " matched flow.",
7058 : : .priv = PRIV_ACTION(NVGRE_DECAP, 0),
7059 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7060 : : .call = parse_vc,
7061 : : },
7062 : : [ACTION_L2_ENCAP] = {
7063 : : .name = "l2_encap",
7064 : : .help = "l2 encap, uses configuration set by"
7065 : : " \"set l2_encap\"",
7066 : : .priv = PRIV_ACTION(RAW_ENCAP,
7067 : : sizeof(struct action_raw_encap_data)),
7068 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7069 : : .call = parse_vc_action_l2_encap,
7070 : : },
7071 : : [ACTION_L2_DECAP] = {
7072 : : .name = "l2_decap",
7073 : : .help = "l2 decap, uses configuration set by"
7074 : : " \"set l2_decap\"",
7075 : : .priv = PRIV_ACTION(RAW_DECAP,
7076 : : sizeof(struct action_raw_decap_data)),
7077 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7078 : : .call = parse_vc_action_l2_decap,
7079 : : },
7080 : : [ACTION_MPLSOGRE_ENCAP] = {
7081 : : .name = "mplsogre_encap",
7082 : : .help = "mplsogre encapsulation, uses configuration set by"
7083 : : " \"set mplsogre_encap\"",
7084 : : .priv = PRIV_ACTION(RAW_ENCAP,
7085 : : sizeof(struct action_raw_encap_data)),
7086 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7087 : : .call = parse_vc_action_mplsogre_encap,
7088 : : },
7089 : : [ACTION_MPLSOGRE_DECAP] = {
7090 : : .name = "mplsogre_decap",
7091 : : .help = "mplsogre decapsulation, uses configuration set by"
7092 : : " \"set mplsogre_decap\"",
7093 : : .priv = PRIV_ACTION(RAW_DECAP,
7094 : : sizeof(struct action_raw_decap_data)),
7095 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7096 : : .call = parse_vc_action_mplsogre_decap,
7097 : : },
7098 : : [ACTION_MPLSOUDP_ENCAP] = {
7099 : : .name = "mplsoudp_encap",
7100 : : .help = "mplsoudp encapsulation, uses configuration set by"
7101 : : " \"set mplsoudp_encap\"",
7102 : : .priv = PRIV_ACTION(RAW_ENCAP,
7103 : : sizeof(struct action_raw_encap_data)),
7104 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7105 : : .call = parse_vc_action_mplsoudp_encap,
7106 : : },
7107 : : [ACTION_MPLSOUDP_DECAP] = {
7108 : : .name = "mplsoudp_decap",
7109 : : .help = "mplsoudp decapsulation, uses configuration set by"
7110 : : " \"set mplsoudp_decap\"",
7111 : : .priv = PRIV_ACTION(RAW_DECAP,
7112 : : sizeof(struct action_raw_decap_data)),
7113 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7114 : : .call = parse_vc_action_mplsoudp_decap,
7115 : : },
7116 : : [ACTION_SET_IPV4_SRC] = {
7117 : : .name = "set_ipv4_src",
7118 : : .help = "Set a new IPv4 source address in the outermost"
7119 : : " IPv4 header",
7120 : : .priv = PRIV_ACTION(SET_IPV4_SRC,
7121 : : sizeof(struct rte_flow_action_set_ipv4)),
7122 : : .next = NEXT(action_set_ipv4_src),
7123 : : .call = parse_vc,
7124 : : },
7125 : : [ACTION_SET_IPV4_SRC_IPV4_SRC] = {
7126 : : .name = "ipv4_addr",
7127 : : .help = "new IPv4 source address to set",
7128 : : .next = NEXT(action_set_ipv4_src, NEXT_ENTRY(COMMON_IPV4_ADDR)),
7129 : : .args = ARGS(ARGS_ENTRY_HTON
7130 : : (struct rte_flow_action_set_ipv4, ipv4_addr)),
7131 : : .call = parse_vc_conf,
7132 : : },
7133 : : [ACTION_SET_IPV4_DST] = {
7134 : : .name = "set_ipv4_dst",
7135 : : .help = "Set a new IPv4 destination address in the outermost"
7136 : : " IPv4 header",
7137 : : .priv = PRIV_ACTION(SET_IPV4_DST,
7138 : : sizeof(struct rte_flow_action_set_ipv4)),
7139 : : .next = NEXT(action_set_ipv4_dst),
7140 : : .call = parse_vc,
7141 : : },
7142 : : [ACTION_SET_IPV4_DST_IPV4_DST] = {
7143 : : .name = "ipv4_addr",
7144 : : .help = "new IPv4 destination address to set",
7145 : : .next = NEXT(action_set_ipv4_dst, NEXT_ENTRY(COMMON_IPV4_ADDR)),
7146 : : .args = ARGS(ARGS_ENTRY_HTON
7147 : : (struct rte_flow_action_set_ipv4, ipv4_addr)),
7148 : : .call = parse_vc_conf,
7149 : : },
7150 : : [ACTION_SET_IPV6_SRC] = {
7151 : : .name = "set_ipv6_src",
7152 : : .help = "Set a new IPv6 source address in the outermost"
7153 : : " IPv6 header",
7154 : : .priv = PRIV_ACTION(SET_IPV6_SRC,
7155 : : sizeof(struct rte_flow_action_set_ipv6)),
7156 : : .next = NEXT(action_set_ipv6_src),
7157 : : .call = parse_vc,
7158 : : },
7159 : : [ACTION_SET_IPV6_SRC_IPV6_SRC] = {
7160 : : .name = "ipv6_addr",
7161 : : .help = "new IPv6 source address to set",
7162 : : .next = NEXT(action_set_ipv6_src, NEXT_ENTRY(COMMON_IPV6_ADDR)),
7163 : : .args = ARGS(ARGS_ENTRY_HTON
7164 : : (struct rte_flow_action_set_ipv6, ipv6_addr)),
7165 : : .call = parse_vc_conf,
7166 : : },
7167 : : [ACTION_SET_IPV6_DST] = {
7168 : : .name = "set_ipv6_dst",
7169 : : .help = "Set a new IPv6 destination address in the outermost"
7170 : : " IPv6 header",
7171 : : .priv = PRIV_ACTION(SET_IPV6_DST,
7172 : : sizeof(struct rte_flow_action_set_ipv6)),
7173 : : .next = NEXT(action_set_ipv6_dst),
7174 : : .call = parse_vc,
7175 : : },
7176 : : [ACTION_SET_IPV6_DST_IPV6_DST] = {
7177 : : .name = "ipv6_addr",
7178 : : .help = "new IPv6 destination address to set",
7179 : : .next = NEXT(action_set_ipv6_dst, NEXT_ENTRY(COMMON_IPV6_ADDR)),
7180 : : .args = ARGS(ARGS_ENTRY_HTON
7181 : : (struct rte_flow_action_set_ipv6, ipv6_addr)),
7182 : : .call = parse_vc_conf,
7183 : : },
7184 : : [ACTION_SET_TP_SRC] = {
7185 : : .name = "set_tp_src",
7186 : : .help = "set a new source port number in the outermost"
7187 : : " TCP/UDP header",
7188 : : .priv = PRIV_ACTION(SET_TP_SRC,
7189 : : sizeof(struct rte_flow_action_set_tp)),
7190 : : .next = NEXT(action_set_tp_src),
7191 : : .call = parse_vc,
7192 : : },
7193 : : [ACTION_SET_TP_SRC_TP_SRC] = {
7194 : : .name = "port",
7195 : : .help = "new source port number to set",
7196 : : .next = NEXT(action_set_tp_src, NEXT_ENTRY(COMMON_UNSIGNED)),
7197 : : .args = ARGS(ARGS_ENTRY_HTON
7198 : : (struct rte_flow_action_set_tp, port)),
7199 : : .call = parse_vc_conf,
7200 : : },
7201 : : [ACTION_SET_TP_DST] = {
7202 : : .name = "set_tp_dst",
7203 : : .help = "set a new destination port number in the outermost"
7204 : : " TCP/UDP header",
7205 : : .priv = PRIV_ACTION(SET_TP_DST,
7206 : : sizeof(struct rte_flow_action_set_tp)),
7207 : : .next = NEXT(action_set_tp_dst),
7208 : : .call = parse_vc,
7209 : : },
7210 : : [ACTION_SET_TP_DST_TP_DST] = {
7211 : : .name = "port",
7212 : : .help = "new destination port number to set",
7213 : : .next = NEXT(action_set_tp_dst, NEXT_ENTRY(COMMON_UNSIGNED)),
7214 : : .args = ARGS(ARGS_ENTRY_HTON
7215 : : (struct rte_flow_action_set_tp, port)),
7216 : : .call = parse_vc_conf,
7217 : : },
7218 : : [ACTION_MAC_SWAP] = {
7219 : : .name = "mac_swap",
7220 : : .help = "Swap the source and destination MAC addresses"
7221 : : " in the outermost Ethernet header",
7222 : : .priv = PRIV_ACTION(MAC_SWAP, 0),
7223 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7224 : : .call = parse_vc,
7225 : : },
7226 : : [ACTION_DEC_TTL] = {
7227 : : .name = "dec_ttl",
7228 : : .help = "decrease network TTL if available",
7229 : : .priv = PRIV_ACTION(DEC_TTL, 0),
7230 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7231 : : .call = parse_vc,
7232 : : },
7233 : : [ACTION_SET_TTL] = {
7234 : : .name = "set_ttl",
7235 : : .help = "set ttl value",
7236 : : .priv = PRIV_ACTION(SET_TTL,
7237 : : sizeof(struct rte_flow_action_set_ttl)),
7238 : : .next = NEXT(action_set_ttl),
7239 : : .call = parse_vc,
7240 : : },
7241 : : [ACTION_SET_TTL_TTL] = {
7242 : : .name = "ttl_value",
7243 : : .help = "new ttl value to set",
7244 : : .next = NEXT(action_set_ttl, NEXT_ENTRY(COMMON_UNSIGNED)),
7245 : : .args = ARGS(ARGS_ENTRY_HTON
7246 : : (struct rte_flow_action_set_ttl, ttl_value)),
7247 : : .call = parse_vc_conf,
7248 : : },
7249 : : [ACTION_SET_MAC_SRC] = {
7250 : : .name = "set_mac_src",
7251 : : .help = "set source mac address",
7252 : : .priv = PRIV_ACTION(SET_MAC_SRC,
7253 : : sizeof(struct rte_flow_action_set_mac)),
7254 : : .next = NEXT(action_set_mac_src),
7255 : : .call = parse_vc,
7256 : : },
7257 : : [ACTION_SET_MAC_SRC_MAC_SRC] = {
7258 : : .name = "mac_addr",
7259 : : .help = "new source mac address",
7260 : : .next = NEXT(action_set_mac_src, NEXT_ENTRY(COMMON_MAC_ADDR)),
7261 : : .args = ARGS(ARGS_ENTRY_HTON
7262 : : (struct rte_flow_action_set_mac, mac_addr)),
7263 : : .call = parse_vc_conf,
7264 : : },
7265 : : [ACTION_SET_MAC_DST] = {
7266 : : .name = "set_mac_dst",
7267 : : .help = "set destination mac address",
7268 : : .priv = PRIV_ACTION(SET_MAC_DST,
7269 : : sizeof(struct rte_flow_action_set_mac)),
7270 : : .next = NEXT(action_set_mac_dst),
7271 : : .call = parse_vc,
7272 : : },
7273 : : [ACTION_SET_MAC_DST_MAC_DST] = {
7274 : : .name = "mac_addr",
7275 : : .help = "new destination mac address to set",
7276 : : .next = NEXT(action_set_mac_dst, NEXT_ENTRY(COMMON_MAC_ADDR)),
7277 : : .args = ARGS(ARGS_ENTRY_HTON
7278 : : (struct rte_flow_action_set_mac, mac_addr)),
7279 : : .call = parse_vc_conf,
7280 : : },
7281 : : [ACTION_INC_TCP_SEQ] = {
7282 : : .name = "inc_tcp_seq",
7283 : : .help = "increase TCP sequence number",
7284 : : .priv = PRIV_ACTION(INC_TCP_SEQ, sizeof(rte_be32_t)),
7285 : : .next = NEXT(action_inc_tcp_seq),
7286 : : .call = parse_vc,
7287 : : },
7288 : : [ACTION_INC_TCP_SEQ_VALUE] = {
7289 : : .name = "value",
7290 : : .help = "the value to increase TCP sequence number by",
7291 : : .next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(COMMON_UNSIGNED)),
7292 : : .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
7293 : : .call = parse_vc_conf,
7294 : : },
7295 : : [ACTION_DEC_TCP_SEQ] = {
7296 : : .name = "dec_tcp_seq",
7297 : : .help = "decrease TCP sequence number",
7298 : : .priv = PRIV_ACTION(DEC_TCP_SEQ, sizeof(rte_be32_t)),
7299 : : .next = NEXT(action_dec_tcp_seq),
7300 : : .call = parse_vc,
7301 : : },
7302 : : [ACTION_DEC_TCP_SEQ_VALUE] = {
7303 : : .name = "value",
7304 : : .help = "the value to decrease TCP sequence number by",
7305 : : .next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(COMMON_UNSIGNED)),
7306 : : .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
7307 : : .call = parse_vc_conf,
7308 : : },
7309 : : [ACTION_INC_TCP_ACK] = {
7310 : : .name = "inc_tcp_ack",
7311 : : .help = "increase TCP acknowledgment number",
7312 : : .priv = PRIV_ACTION(INC_TCP_ACK, sizeof(rte_be32_t)),
7313 : : .next = NEXT(action_inc_tcp_ack),
7314 : : .call = parse_vc,
7315 : : },
7316 : : [ACTION_INC_TCP_ACK_VALUE] = {
7317 : : .name = "value",
7318 : : .help = "the value to increase TCP acknowledgment number by",
7319 : : .next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(COMMON_UNSIGNED)),
7320 : : .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
7321 : : .call = parse_vc_conf,
7322 : : },
7323 : : [ACTION_DEC_TCP_ACK] = {
7324 : : .name = "dec_tcp_ack",
7325 : : .help = "decrease TCP acknowledgment number",
7326 : : .priv = PRIV_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)),
7327 : : .next = NEXT(action_dec_tcp_ack),
7328 : : .call = parse_vc,
7329 : : },
7330 : : [ACTION_DEC_TCP_ACK_VALUE] = {
7331 : : .name = "value",
7332 : : .help = "the value to decrease TCP acknowledgment number by",
7333 : : .next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(COMMON_UNSIGNED)),
7334 : : .args = ARGS(ARG_ENTRY_HTON(rte_be32_t)),
7335 : : .call = parse_vc_conf,
7336 : : },
7337 : : [ACTION_RAW_ENCAP] = {
7338 : : .name = "raw_encap",
7339 : : .help = "encapsulation data, defined by set raw_encap",
7340 : : .priv = PRIV_ACTION(RAW_ENCAP,
7341 : : sizeof(struct action_raw_encap_data)),
7342 : : .next = NEXT(action_raw_encap),
7343 : : .call = parse_vc_action_raw_encap,
7344 : : },
7345 : : [ACTION_RAW_ENCAP_SIZE] = {
7346 : : .name = "size",
7347 : : .help = "raw encap size",
7348 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT),
7349 : : NEXT_ENTRY(COMMON_UNSIGNED)),
7350 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_raw_encap, size)),
7351 : : .call = parse_vc_conf,
7352 : : },
7353 : : [ACTION_RAW_ENCAP_INDEX] = {
7354 : : .name = "index",
7355 : : .help = "the index of raw_encap_confs",
7356 : : .next = NEXT(NEXT_ENTRY(ACTION_RAW_ENCAP_INDEX_VALUE)),
7357 : : },
7358 : : [ACTION_RAW_ENCAP_INDEX_VALUE] = {
7359 : : .name = "{index}",
7360 : : .type = "UNSIGNED",
7361 : : .help = "unsigned integer value",
7362 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7363 : : .call = parse_vc_action_raw_encap_index,
7364 : : .comp = comp_set_raw_index,
7365 : : },
7366 : : [ACTION_RAW_DECAP] = {
7367 : : .name = "raw_decap",
7368 : : .help = "decapsulation data, defined by set raw_encap",
7369 : : .priv = PRIV_ACTION(RAW_DECAP,
7370 : : sizeof(struct action_raw_decap_data)),
7371 : : .next = NEXT(action_raw_decap),
7372 : : .call = parse_vc_action_raw_decap,
7373 : : },
7374 : : [ACTION_RAW_DECAP_INDEX] = {
7375 : : .name = "index",
7376 : : .help = "the index of raw_encap_confs",
7377 : : .next = NEXT(NEXT_ENTRY(ACTION_RAW_DECAP_INDEX_VALUE)),
7378 : : },
7379 : : [ACTION_RAW_DECAP_INDEX_VALUE] = {
7380 : : .name = "{index}",
7381 : : .type = "UNSIGNED",
7382 : : .help = "unsigned integer value",
7383 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7384 : : .call = parse_vc_action_raw_decap_index,
7385 : : .comp = comp_set_raw_index,
7386 : : },
7387 : : [ACTION_MODIFY_FIELD] = {
7388 : : .name = "modify_field",
7389 : : .help = "modify destination field with data from source field",
7390 : : .priv = PRIV_ACTION(MODIFY_FIELD, ACTION_MODIFY_SIZE),
7391 : : .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_OP)),
7392 : : .call = parse_vc,
7393 : : },
7394 : : [ACTION_MODIFY_FIELD_OP] = {
7395 : : .name = "op",
7396 : : .help = "operation type",
7397 : : .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_TYPE),
7398 : : NEXT_ENTRY(ACTION_MODIFY_FIELD_OP_VALUE)),
7399 : : .call = parse_vc_conf,
7400 : : },
7401 : : [ACTION_MODIFY_FIELD_OP_VALUE] = {
7402 : : .name = "{operation}",
7403 : : .help = "operation type value",
7404 : : .call = parse_vc_modify_field_op,
7405 : : .comp = comp_set_modify_field_op,
7406 : : },
7407 : : [ACTION_MODIFY_FIELD_DST_TYPE] = {
7408 : : .name = "dst_type",
7409 : : .help = "destination field type",
7410 : : .next = NEXT(action_modify_field_dst,
7411 : : NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_TYPE_VALUE)),
7412 : : .call = parse_vc_conf,
7413 : : },
7414 : : [ACTION_MODIFY_FIELD_DST_TYPE_VALUE] = {
7415 : : .name = "{dst_type}",
7416 : : .help = "destination field type value",
7417 : : .call = parse_vc_modify_field_id,
7418 : : .comp = comp_set_modify_field_id,
7419 : : },
7420 : : [ACTION_MODIFY_FIELD_DST_LEVEL] = {
7421 : : .name = "dst_level",
7422 : : .help = "destination field level",
7423 : : .next = NEXT(action_modify_field_dst,
7424 : : NEXT_ENTRY(ACTION_MODIFY_FIELD_DST_LEVEL_VALUE)),
7425 : : .call = parse_vc_conf,
7426 : : },
7427 : : [ACTION_MODIFY_FIELD_DST_LEVEL_VALUE] = {
7428 : : .name = "{dst_level}",
7429 : : .help = "destination field level value",
7430 : : .call = parse_vc_modify_field_level,
7431 : : .comp = comp_none,
7432 : : },
7433 : : [ACTION_MODIFY_FIELD_DST_TAG_INDEX] = {
7434 : : .name = "dst_tag_index",
7435 : : .help = "destination field tag array",
7436 : : .next = NEXT(action_modify_field_dst,
7437 : : NEXT_ENTRY(COMMON_UNSIGNED)),
7438 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
7439 : : dst.tag_index)),
7440 : : .call = parse_vc_conf,
7441 : : },
7442 : : [ACTION_MODIFY_FIELD_DST_TYPE_ID] = {
7443 : : .name = "dst_type_id",
7444 : : .help = "destination field type ID",
7445 : : .next = NEXT(action_modify_field_dst,
7446 : : NEXT_ENTRY(COMMON_UNSIGNED)),
7447 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
7448 : : dst.type)),
7449 : : .call = parse_vc_conf,
7450 : : },
7451 : : [ACTION_MODIFY_FIELD_DST_CLASS_ID] = {
7452 : : .name = "dst_class",
7453 : : .help = "destination field class ID",
7454 : : .next = NEXT(action_modify_field_dst,
7455 : : NEXT_ENTRY(COMMON_UNSIGNED)),
7456 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_action_modify_field,
7457 : : dst.class_id)),
7458 : : .call = parse_vc_conf,
7459 : : },
7460 : : [ACTION_MODIFY_FIELD_DST_OFFSET] = {
7461 : : .name = "dst_offset",
7462 : : .help = "destination field bit offset",
7463 : : .next = NEXT(action_modify_field_dst,
7464 : : NEXT_ENTRY(COMMON_UNSIGNED)),
7465 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
7466 : : dst.offset)),
7467 : : .call = parse_vc_conf,
7468 : : },
7469 : : [ACTION_MODIFY_FIELD_SRC_TYPE] = {
7470 : : .name = "src_type",
7471 : : .help = "source field type",
7472 : : .next = NEXT(action_modify_field_src,
7473 : : NEXT_ENTRY(ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)),
7474 : : .call = parse_vc_conf,
7475 : : },
7476 : : [ACTION_MODIFY_FIELD_SRC_TYPE_VALUE] = {
7477 : : .name = "{src_type}",
7478 : : .help = "source field type value",
7479 : : .call = parse_vc_modify_field_id,
7480 : : .comp = comp_set_modify_field_id,
7481 : : },
7482 : : [ACTION_MODIFY_FIELD_SRC_LEVEL] = {
7483 : : .name = "src_level",
7484 : : .help = "source field level",
7485 : : .next = NEXT(action_modify_field_src,
7486 : : NEXT_ENTRY(ACTION_MODIFY_FIELD_SRC_LEVEL_VALUE)),
7487 : : .call = parse_vc_conf,
7488 : : },
7489 : : [ACTION_MODIFY_FIELD_SRC_LEVEL_VALUE] = {
7490 : : .name = "{src_level}",
7491 : : .help = "source field level value",
7492 : : .call = parse_vc_modify_field_level,
7493 : : .comp = comp_none,
7494 : : },
7495 : : [ACTION_MODIFY_FIELD_SRC_TAG_INDEX] = {
7496 : : .name = "src_tag_index",
7497 : : .help = "source field tag array",
7498 : : .next = NEXT(action_modify_field_src,
7499 : : NEXT_ENTRY(COMMON_UNSIGNED)),
7500 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
7501 : : src.tag_index)),
7502 : : .call = parse_vc_conf,
7503 : : },
7504 : : [ACTION_MODIFY_FIELD_SRC_TYPE_ID] = {
7505 : : .name = "src_type_id",
7506 : : .help = "source field type ID",
7507 : : .next = NEXT(action_modify_field_src,
7508 : : NEXT_ENTRY(COMMON_UNSIGNED)),
7509 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
7510 : : src.type)),
7511 : : .call = parse_vc_conf,
7512 : : },
7513 : : [ACTION_MODIFY_FIELD_SRC_CLASS_ID] = {
7514 : : .name = "src_class",
7515 : : .help = "source field class ID",
7516 : : .next = NEXT(action_modify_field_src,
7517 : : NEXT_ENTRY(COMMON_UNSIGNED)),
7518 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_action_modify_field,
7519 : : src.class_id)),
7520 : : .call = parse_vc_conf,
7521 : : },
7522 : : [ACTION_MODIFY_FIELD_SRC_OFFSET] = {
7523 : : .name = "src_offset",
7524 : : .help = "source field bit offset",
7525 : : .next = NEXT(action_modify_field_src,
7526 : : NEXT_ENTRY(COMMON_UNSIGNED)),
7527 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
7528 : : src.offset)),
7529 : : .call = parse_vc_conf,
7530 : : },
7531 : : [ACTION_MODIFY_FIELD_SRC_VALUE] = {
7532 : : .name = "src_value",
7533 : : .help = "source immediate value",
7534 : : .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_WIDTH),
7535 : : NEXT_ENTRY(COMMON_HEX)),
7536 : : .args = ARGS(ARGS_ENTRY_ARB(0, 0),
7537 : : ARGS_ENTRY_ARB(0, 0),
7538 : : ARGS_ENTRY(struct rte_flow_action_modify_field,
7539 : : src.value)),
7540 : : .call = parse_vc_conf,
7541 : : },
7542 : : [ACTION_MODIFY_FIELD_SRC_POINTER] = {
7543 : : .name = "src_ptr",
7544 : : .help = "pointer to source immediate value",
7545 : : .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_WIDTH),
7546 : : NEXT_ENTRY(COMMON_HEX)),
7547 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
7548 : : src.pvalue),
7549 : : ARGS_ENTRY_ARB(0, 0),
7550 : : ARGS_ENTRY_ARB
7551 : : (sizeof(struct rte_flow_action_modify_field),
7552 : : FLOW_FIELD_PATTERN_SIZE)),
7553 : : .call = parse_vc_conf,
7554 : : },
7555 : : [ACTION_MODIFY_FIELD_WIDTH] = {
7556 : : .name = "width",
7557 : : .help = "number of bits to copy",
7558 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT),
7559 : : NEXT_ENTRY(COMMON_UNSIGNED)),
7560 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
7561 : : width)),
7562 : : .call = parse_vc_conf,
7563 : : },
7564 : : [ACTION_SEND_TO_KERNEL] = {
7565 : : .name = "send_to_kernel",
7566 : : .help = "send packets to kernel",
7567 : : .priv = PRIV_ACTION(SEND_TO_KERNEL, 0),
7568 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7569 : : .call = parse_vc,
7570 : : },
7571 : : [ACTION_IPV6_EXT_REMOVE] = {
7572 : : .name = "ipv6_ext_remove",
7573 : : .help = "IPv6 extension type, defined by set ipv6_ext_remove",
7574 : : .priv = PRIV_ACTION(IPV6_EXT_REMOVE,
7575 : : sizeof(struct action_ipv6_ext_remove_data)),
7576 : : .next = NEXT(action_ipv6_ext_remove),
7577 : : .call = parse_vc_action_ipv6_ext_remove,
7578 : : },
7579 : : [ACTION_IPV6_EXT_REMOVE_INDEX] = {
7580 : : .name = "index",
7581 : : .help = "the index of ipv6_ext_remove",
7582 : : .next = NEXT(NEXT_ENTRY(ACTION_IPV6_EXT_REMOVE_INDEX_VALUE)),
7583 : : },
7584 : : [ACTION_IPV6_EXT_REMOVE_INDEX_VALUE] = {
7585 : : .name = "{index}",
7586 : : .type = "UNSIGNED",
7587 : : .help = "unsigned integer value",
7588 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7589 : : .call = parse_vc_action_ipv6_ext_remove_index,
7590 : : .comp = comp_set_ipv6_ext_index,
7591 : : },
7592 : : [ACTION_IPV6_EXT_PUSH] = {
7593 : : .name = "ipv6_ext_push",
7594 : : .help = "IPv6 extension data, defined by set ipv6_ext_push",
7595 : : .priv = PRIV_ACTION(IPV6_EXT_PUSH,
7596 : : sizeof(struct action_ipv6_ext_push_data)),
7597 : : .next = NEXT(action_ipv6_ext_push),
7598 : : .call = parse_vc_action_ipv6_ext_push,
7599 : : },
7600 : : [ACTION_IPV6_EXT_PUSH_INDEX] = {
7601 : : .name = "index",
7602 : : .help = "the index of ipv6_ext_push",
7603 : : .next = NEXT(NEXT_ENTRY(ACTION_IPV6_EXT_PUSH_INDEX_VALUE)),
7604 : : },
7605 : : [ACTION_IPV6_EXT_PUSH_INDEX_VALUE] = {
7606 : : .name = "{index}",
7607 : : .type = "UNSIGNED",
7608 : : .help = "unsigned integer value",
7609 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7610 : : .call = parse_vc_action_ipv6_ext_push_index,
7611 : : .comp = comp_set_ipv6_ext_index,
7612 : : },
7613 : : [ACTION_NAT64] = {
7614 : : .name = "nat64",
7615 : : .help = "NAT64 IP headers translation",
7616 : : .priv = PRIV_ACTION(NAT64, sizeof(struct rte_flow_action_nat64)),
7617 : : .next = NEXT(action_nat64),
7618 : : .call = parse_vc,
7619 : : },
7620 : : [ACTION_NAT64_MODE] = {
7621 : : .name = "type",
7622 : : .help = "NAT64 translation type",
7623 : : .next = NEXT(action_nat64, NEXT_ENTRY(COMMON_UNSIGNED)),
7624 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_nat64, type)),
7625 : : .call = parse_vc_conf,
7626 : : },
7627 : : [ACTION_JUMP_TO_TABLE_INDEX] = {
7628 : : .name = "jump_to_table_index",
7629 : : .help = "Jump to table index",
7630 : : .priv = PRIV_ACTION(JUMP_TO_TABLE_INDEX,
7631 : : sizeof(struct rte_flow_action_jump_to_table_index)),
7632 : : .next = NEXT(action_jump_to_table_index),
7633 : : .call = parse_vc,
7634 : : },
7635 : : [ACTION_JUMP_TO_TABLE_INDEX_TABLE] = {
7636 : : .name = "table",
7637 : : .help = "table to redirect traffic to",
7638 : : .next = NEXT(action_jump_to_table_index, NEXT_ENTRY(COMMON_UNSIGNED)),
7639 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump_to_table_index, table)),
7640 : : .call = parse_vc_conf,
7641 : : },
7642 : : [ACTION_JUMP_TO_TABLE_INDEX_INDEX] = {
7643 : : .name = "index",
7644 : : .help = "rule index to redirect traffic to",
7645 : : .next = NEXT(action_jump_to_table_index, NEXT_ENTRY(COMMON_UNSIGNED)),
7646 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump_to_table_index, index)),
7647 : : .call = parse_vc_conf,
7648 : : },
7649 : :
7650 : : /* Top level command. */
7651 : : [SET] = {
7652 : : .name = "set",
7653 : : .help = "set raw encap/decap/sample data",
7654 : : .type = "set raw_encap|raw_decap <index> <pattern>"
7655 : : " or set sample_actions <index> <action>",
7656 : : .next = NEXT(NEXT_ENTRY
7657 : : (SET_RAW_ENCAP,
7658 : : SET_RAW_DECAP,
7659 : : SET_SAMPLE_ACTIONS,
7660 : : SET_IPV6_EXT_REMOVE,
7661 : : SET_IPV6_EXT_PUSH)),
7662 : : .call = parse_set_init,
7663 : : },
7664 : : /* Sub-level commands. */
7665 : : [SET_RAW_ENCAP] = {
7666 : : .name = "raw_encap",
7667 : : .help = "set raw encap data",
7668 : : .next = NEXT(next_set_raw),
7669 : : .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
7670 : : (offsetof(struct buffer, port),
7671 : : sizeof(((struct buffer *)0)->port),
7672 : : 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
7673 : : .call = parse_set_raw_encap_decap,
7674 : : },
7675 : : [SET_RAW_DECAP] = {
7676 : : .name = "raw_decap",
7677 : : .help = "set raw decap data",
7678 : : .next = NEXT(next_set_raw),
7679 : : .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
7680 : : (offsetof(struct buffer, port),
7681 : : sizeof(((struct buffer *)0)->port),
7682 : : 0, RAW_ENCAP_CONFS_MAX_NUM - 1)),
7683 : : .call = parse_set_raw_encap_decap,
7684 : : },
7685 : : [SET_RAW_INDEX] = {
7686 : : .name = "{index}",
7687 : : .type = "COMMON_UNSIGNED",
7688 : : .help = "index of raw_encap/raw_decap data",
7689 : : .next = NEXT(next_item),
7690 : : .call = parse_port,
7691 : : },
7692 : : [SET_SAMPLE_INDEX] = {
7693 : : .name = "{index}",
7694 : : .type = "UNSIGNED",
7695 : : .help = "index of sample actions",
7696 : : .next = NEXT(next_action_sample),
7697 : : .call = parse_port,
7698 : : },
7699 : : [SET_SAMPLE_ACTIONS] = {
7700 : : .name = "sample_actions",
7701 : : .help = "set sample actions list",
7702 : : .next = NEXT(NEXT_ENTRY(SET_SAMPLE_INDEX)),
7703 : : .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
7704 : : (offsetof(struct buffer, port),
7705 : : sizeof(((struct buffer *)0)->port),
7706 : : 0, RAW_SAMPLE_CONFS_MAX_NUM - 1)),
7707 : : .call = parse_set_sample_action,
7708 : : },
7709 : : [SET_IPV6_EXT_PUSH] = {
7710 : : .name = "ipv6_ext_push",
7711 : : .help = "set IPv6 extension header",
7712 : : .next = NEXT(NEXT_ENTRY(SET_IPV6_EXT_INDEX)),
7713 : : .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
7714 : : (offsetof(struct buffer, port),
7715 : : sizeof(((struct buffer *)0)->port),
7716 : : 0, IPV6_EXT_PUSH_CONFS_MAX_NUM - 1)),
7717 : : .call = parse_set_ipv6_ext_action,
7718 : : },
7719 : : [SET_IPV6_EXT_REMOVE] = {
7720 : : .name = "ipv6_ext_remove",
7721 : : .help = "set IPv6 extension header",
7722 : : .next = NEXT(NEXT_ENTRY(SET_IPV6_EXT_INDEX)),
7723 : : .args = ARGS(ARGS_ENTRY_ARB_BOUNDED
7724 : : (offsetof(struct buffer, port),
7725 : : sizeof(((struct buffer *)0)->port),
7726 : : 0, IPV6_EXT_PUSH_CONFS_MAX_NUM - 1)),
7727 : : .call = parse_set_ipv6_ext_action,
7728 : : },
7729 : : [SET_IPV6_EXT_INDEX] = {
7730 : : .name = "{index}",
7731 : : .type = "UNSIGNED",
7732 : : .help = "index of ipv6 extension push/remove actions",
7733 : : .next = NEXT(item_ipv6_push_ext),
7734 : : .call = parse_port,
7735 : : },
7736 : : [ITEM_IPV6_PUSH_REMOVE_EXT] = {
7737 : : .name = "ipv6_ext",
7738 : : .help = "set IPv6 extension header",
7739 : : .priv = PRIV_ITEM(IPV6_EXT,
7740 : : sizeof(struct rte_flow_item_ipv6_ext)),
7741 : : .next = NEXT(item_ipv6_push_ext_type),
7742 : : .call = parse_vc,
7743 : : },
7744 : : [ITEM_IPV6_PUSH_REMOVE_EXT_TYPE] = {
7745 : : .name = "type",
7746 : : .help = "set IPv6 extension type",
7747 : : .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv6_ext,
7748 : : next_hdr)),
7749 : : .next = NEXT(item_ipv6_push_ext_header, NEXT_ENTRY(COMMON_UNSIGNED),
7750 : : item_param),
7751 : : },
7752 : : [ACTION_SET_TAG] = {
7753 : : .name = "set_tag",
7754 : : .help = "set tag",
7755 : : .priv = PRIV_ACTION(SET_TAG,
7756 : : sizeof(struct rte_flow_action_set_tag)),
7757 : : .next = NEXT(action_set_tag),
7758 : : .call = parse_vc,
7759 : : },
7760 : : [ACTION_SET_TAG_INDEX] = {
7761 : : .name = "index",
7762 : : .help = "index of tag array",
7763 : : .next = NEXT(action_set_tag, NEXT_ENTRY(COMMON_UNSIGNED)),
7764 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_set_tag, index)),
7765 : : .call = parse_vc_conf,
7766 : : },
7767 : : [ACTION_SET_TAG_DATA] = {
7768 : : .name = "data",
7769 : : .help = "tag value",
7770 : : .next = NEXT(action_set_tag, NEXT_ENTRY(COMMON_UNSIGNED)),
7771 : : .args = ARGS(ARGS_ENTRY
7772 : : (struct rte_flow_action_set_tag, data)),
7773 : : .call = parse_vc_conf,
7774 : : },
7775 : : [ACTION_SET_TAG_MASK] = {
7776 : : .name = "mask",
7777 : : .help = "mask for tag value",
7778 : : .next = NEXT(action_set_tag, NEXT_ENTRY(COMMON_UNSIGNED)),
7779 : : .args = ARGS(ARGS_ENTRY
7780 : : (struct rte_flow_action_set_tag, mask)),
7781 : : .call = parse_vc_conf,
7782 : : },
7783 : : [ACTION_SET_META] = {
7784 : : .name = "set_meta",
7785 : : .help = "set metadata",
7786 : : .priv = PRIV_ACTION(SET_META,
7787 : : sizeof(struct rte_flow_action_set_meta)),
7788 : : .next = NEXT(action_set_meta),
7789 : : .call = parse_vc_action_set_meta,
7790 : : },
7791 : : [ACTION_SET_META_DATA] = {
7792 : : .name = "data",
7793 : : .help = "metadata value",
7794 : : .next = NEXT(action_set_meta, NEXT_ENTRY(COMMON_UNSIGNED)),
7795 : : .args = ARGS(ARGS_ENTRY
7796 : : (struct rte_flow_action_set_meta, data)),
7797 : : .call = parse_vc_conf,
7798 : : },
7799 : : [ACTION_SET_META_MASK] = {
7800 : : .name = "mask",
7801 : : .help = "mask for metadata value",
7802 : : .next = NEXT(action_set_meta, NEXT_ENTRY(COMMON_UNSIGNED)),
7803 : : .args = ARGS(ARGS_ENTRY
7804 : : (struct rte_flow_action_set_meta, mask)),
7805 : : .call = parse_vc_conf,
7806 : : },
7807 : : [ACTION_SET_IPV4_DSCP] = {
7808 : : .name = "set_ipv4_dscp",
7809 : : .help = "set DSCP value",
7810 : : .priv = PRIV_ACTION(SET_IPV4_DSCP,
7811 : : sizeof(struct rte_flow_action_set_dscp)),
7812 : : .next = NEXT(action_set_ipv4_dscp),
7813 : : .call = parse_vc,
7814 : : },
7815 : : [ACTION_SET_IPV4_DSCP_VALUE] = {
7816 : : .name = "dscp_value",
7817 : : .help = "new IPv4 DSCP value to set",
7818 : : .next = NEXT(action_set_ipv4_dscp, NEXT_ENTRY(COMMON_UNSIGNED)),
7819 : : .args = ARGS(ARGS_ENTRY
7820 : : (struct rte_flow_action_set_dscp, dscp)),
7821 : : .call = parse_vc_conf,
7822 : : },
7823 : : [ACTION_SET_IPV6_DSCP] = {
7824 : : .name = "set_ipv6_dscp",
7825 : : .help = "set DSCP value",
7826 : : .priv = PRIV_ACTION(SET_IPV6_DSCP,
7827 : : sizeof(struct rte_flow_action_set_dscp)),
7828 : : .next = NEXT(action_set_ipv6_dscp),
7829 : : .call = parse_vc,
7830 : : },
7831 : : [ACTION_SET_IPV6_DSCP_VALUE] = {
7832 : : .name = "dscp_value",
7833 : : .help = "new IPv6 DSCP value to set",
7834 : : .next = NEXT(action_set_ipv6_dscp, NEXT_ENTRY(COMMON_UNSIGNED)),
7835 : : .args = ARGS(ARGS_ENTRY
7836 : : (struct rte_flow_action_set_dscp, dscp)),
7837 : : .call = parse_vc_conf,
7838 : : },
7839 : : [ACTION_AGE] = {
7840 : : .name = "age",
7841 : : .help = "set a specific metadata header",
7842 : : .next = NEXT(action_age),
7843 : : .priv = PRIV_ACTION(AGE,
7844 : : sizeof(struct rte_flow_action_age)),
7845 : : .call = parse_vc,
7846 : : },
7847 : : [ACTION_AGE_TIMEOUT] = {
7848 : : .name = "timeout",
7849 : : .help = "flow age timeout value",
7850 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_age,
7851 : : timeout, 24)),
7852 : : .next = NEXT(action_age, NEXT_ENTRY(COMMON_UNSIGNED)),
7853 : : .call = parse_vc_conf,
7854 : : },
7855 : : [ACTION_AGE_UPDATE] = {
7856 : : .name = "age_update",
7857 : : .help = "update aging parameter",
7858 : : .next = NEXT(action_age_update),
7859 : : .priv = PRIV_ACTION(AGE,
7860 : : sizeof(struct rte_flow_update_age)),
7861 : : .call = parse_vc,
7862 : : },
7863 : : [ACTION_AGE_UPDATE_TIMEOUT] = {
7864 : : .name = "timeout",
7865 : : .help = "age timeout update value",
7866 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_update_age,
7867 : : timeout, 24)),
7868 : : .next = NEXT(action_age_update, NEXT_ENTRY(COMMON_UNSIGNED)),
7869 : : .call = parse_vc_conf_timeout,
7870 : : },
7871 : : [ACTION_AGE_UPDATE_TOUCH] = {
7872 : : .name = "touch",
7873 : : .help = "this flow is touched",
7874 : : .next = NEXT(action_age_update, NEXT_ENTRY(COMMON_BOOLEAN)),
7875 : : .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_update_age,
7876 : : touch, 1)),
7877 : : .call = parse_vc_conf,
7878 : : },
7879 : : [ACTION_SAMPLE] = {
7880 : : .name = "sample",
7881 : : .help = "set a sample action",
7882 : : .next = NEXT(action_sample),
7883 : : .priv = PRIV_ACTION(SAMPLE,
7884 : : sizeof(struct action_sample_data)),
7885 : : .call = parse_vc_action_sample,
7886 : : },
7887 : : [ACTION_SAMPLE_RATIO] = {
7888 : : .name = "ratio",
7889 : : .help = "flow sample ratio value",
7890 : : .next = NEXT(action_sample, NEXT_ENTRY(COMMON_UNSIGNED)),
7891 : : .args = ARGS(ARGS_ENTRY_ARB
7892 : : (offsetof(struct action_sample_data, conf) +
7893 : : offsetof(struct rte_flow_action_sample, ratio),
7894 : : sizeof(((struct rte_flow_action_sample *)0)->
7895 : : ratio))),
7896 : : },
7897 : : [ACTION_SAMPLE_INDEX] = {
7898 : : .name = "index",
7899 : : .help = "the index of sample actions list",
7900 : : .next = NEXT(NEXT_ENTRY(ACTION_SAMPLE_INDEX_VALUE)),
7901 : : },
7902 : : [ACTION_SAMPLE_INDEX_VALUE] = {
7903 : : .name = "{index}",
7904 : : .type = "COMMON_UNSIGNED",
7905 : : .help = "unsigned integer value",
7906 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7907 : : .call = parse_vc_action_sample_index,
7908 : : .comp = comp_set_sample_index,
7909 : : },
7910 : : [ACTION_CONNTRACK] = {
7911 : : .name = "conntrack",
7912 : : .help = "create a conntrack object",
7913 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
7914 : : .priv = PRIV_ACTION(CONNTRACK,
7915 : : sizeof(struct rte_flow_action_conntrack)),
7916 : : .call = parse_vc,
7917 : : },
7918 : : [ACTION_CONNTRACK_UPDATE] = {
7919 : : .name = "conntrack_update",
7920 : : .help = "update a conntrack object",
7921 : : .next = NEXT(action_update_conntrack),
7922 : : .priv = PRIV_ACTION(CONNTRACK,
7923 : : sizeof(struct rte_flow_modify_conntrack)),
7924 : : .call = parse_vc,
7925 : : },
7926 : : [ACTION_CONNTRACK_UPDATE_DIR] = {
7927 : : .name = "dir",
7928 : : .help = "update a conntrack object direction",
7929 : : .next = NEXT(action_update_conntrack),
7930 : : .call = parse_vc_action_conntrack_update,
7931 : : },
7932 : : [ACTION_CONNTRACK_UPDATE_CTX] = {
7933 : : .name = "ctx",
7934 : : .help = "update a conntrack object context",
7935 : : .next = NEXT(action_update_conntrack),
7936 : : .call = parse_vc_action_conntrack_update,
7937 : : },
7938 : : [ACTION_PORT_REPRESENTOR] = {
7939 : : .name = "port_representor",
7940 : : .help = "at embedded switch level, send matching traffic to the given ethdev",
7941 : : .priv = PRIV_ACTION(PORT_REPRESENTOR,
7942 : : sizeof(struct rte_flow_action_ethdev)),
7943 : : .next = NEXT(action_port_representor),
7944 : : .call = parse_vc,
7945 : : },
7946 : : [ACTION_PORT_REPRESENTOR_PORT_ID] = {
7947 : : .name = "port_id",
7948 : : .help = "ethdev port ID",
7949 : : .next = NEXT(action_port_representor,
7950 : : NEXT_ENTRY(COMMON_UNSIGNED)),
7951 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_ethdev,
7952 : : port_id)),
7953 : : .call = parse_vc_conf,
7954 : : },
7955 : : [ACTION_REPRESENTED_PORT] = {
7956 : : .name = "represented_port",
7957 : : .help = "at embedded switch level, send matching traffic to the entity represented by the given ethdev",
7958 : : .priv = PRIV_ACTION(REPRESENTED_PORT,
7959 : : sizeof(struct rte_flow_action_ethdev)),
7960 : : .next = NEXT(action_represented_port),
7961 : : .call = parse_vc,
7962 : : },
7963 : : [ACTION_REPRESENTED_PORT_ETHDEV_PORT_ID] = {
7964 : : .name = "ethdev_port_id",
7965 : : .help = "ethdev port ID",
7966 : : .next = NEXT(action_represented_port,
7967 : : NEXT_ENTRY(COMMON_UNSIGNED)),
7968 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_ethdev,
7969 : : port_id)),
7970 : : .call = parse_vc_conf,
7971 : : },
7972 : : /* Indirect action destroy arguments. */
7973 : : [INDIRECT_ACTION_DESTROY_ID] = {
7974 : : .name = "action_id",
7975 : : .help = "specify a indirect action id to destroy",
7976 : : .next = NEXT(next_ia_destroy_attr,
7977 : : NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
7978 : : .args = ARGS(ARGS_ENTRY_PTR(struct buffer,
7979 : : args.ia_destroy.action_id)),
7980 : : .call = parse_ia_destroy,
7981 : : },
7982 : : /* Indirect action create arguments. */
7983 : : [INDIRECT_ACTION_CREATE_ID] = {
7984 : : .name = "action_id",
7985 : : .help = "specify a indirect action id to create",
7986 : : .next = NEXT(next_ia_create_attr,
7987 : : NEXT_ENTRY(COMMON_INDIRECT_ACTION_ID)),
7988 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.attr.group)),
7989 : : },
7990 : : [ACTION_INDIRECT] = {
7991 : : .name = "indirect",
7992 : : .help = "apply indirect action by id",
7993 : : .priv = PRIV_ACTION(INDIRECT, 0),
7994 : : .next = NEXT(next_ia),
7995 : : .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
7996 : : .call = parse_vc,
7997 : : },
7998 : : [ACTION_INDIRECT_LIST] = {
7999 : : .name = "indirect_list",
8000 : : .help = "apply indirect list action by id",
8001 : : .priv = PRIV_ACTION(INDIRECT_LIST,
8002 : : sizeof(struct
8003 : : rte_flow_action_indirect_list)),
8004 : : .next = NEXT(next_ial),
8005 : : .call = parse_vc,
8006 : : },
8007 : : [ACTION_INDIRECT_LIST_HANDLE] = {
8008 : : .name = "handle",
8009 : : .help = "indirect list handle",
8010 : : .next = NEXT(next_ial, NEXT_ENTRY(INDIRECT_LIST_ACTION_ID2PTR_HANDLE)),
8011 : : .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
8012 : : },
8013 : : [ACTION_INDIRECT_LIST_CONF] = {
8014 : : .name = "conf",
8015 : : .help = "indirect list configuration",
8016 : : .next = NEXT(next_ial, NEXT_ENTRY(INDIRECT_LIST_ACTION_ID2PTR_CONF)),
8017 : : .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
8018 : : },
8019 : : [INDIRECT_LIST_ACTION_ID2PTR_HANDLE] = {
8020 : : .type = "UNSIGNED",
8021 : : .help = "unsigned integer value",
8022 : : .call = parse_indlst_id2ptr,
8023 : : .comp = comp_none,
8024 : : },
8025 : : [INDIRECT_LIST_ACTION_ID2PTR_CONF] = {
8026 : : .type = "UNSIGNED",
8027 : : .help = "unsigned integer value",
8028 : : .call = parse_indlst_id2ptr,
8029 : : .comp = comp_none,
8030 : : },
8031 : : [ACTION_SHARED_INDIRECT] = {
8032 : : .name = "shared_indirect",
8033 : : .help = "apply indirect action by id and port",
8034 : : .priv = PRIV_ACTION(INDIRECT, 0),
8035 : : .next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_PORT)),
8036 : : .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t)),
8037 : : ARGS_ENTRY_ARB(0, sizeof(uint32_t))),
8038 : : .call = parse_vc,
8039 : : },
8040 : : [INDIRECT_ACTION_PORT] = {
8041 : : .name = "{indirect_action_port}",
8042 : : .type = "INDIRECT_ACTION_PORT",
8043 : : .help = "indirect action port",
8044 : : .next = NEXT(NEXT_ENTRY(INDIRECT_ACTION_ID2PTR)),
8045 : : .call = parse_ia_port,
8046 : : .comp = comp_none,
8047 : : },
8048 : : [INDIRECT_ACTION_ID2PTR] = {
8049 : : .name = "{action_id}",
8050 : : .type = "INDIRECT_ACTION_ID",
8051 : : .help = "indirect action id",
8052 : : .next = NEXT(NEXT_ENTRY(ACTION_NEXT)),
8053 : : .call = parse_ia_id2ptr,
8054 : : .comp = comp_none,
8055 : : },
8056 : : [INDIRECT_ACTION_INGRESS] = {
8057 : : .name = "ingress",
8058 : : .help = "affect rule to ingress",
8059 : : .next = NEXT(next_ia_create_attr),
8060 : : .call = parse_ia,
8061 : : },
8062 : : [INDIRECT_ACTION_EGRESS] = {
8063 : : .name = "egress",
8064 : : .help = "affect rule to egress",
8065 : : .next = NEXT(next_ia_create_attr),
8066 : : .call = parse_ia,
8067 : : },
8068 : : [INDIRECT_ACTION_TRANSFER] = {
8069 : : .name = "transfer",
8070 : : .help = "affect rule to transfer",
8071 : : .next = NEXT(next_ia_create_attr),
8072 : : .call = parse_ia,
8073 : : },
8074 : : [INDIRECT_ACTION_SPEC] = {
8075 : : .name = "action",
8076 : : .help = "specify action to create indirect handle",
8077 : : .next = NEXT(next_action),
8078 : : },
8079 : : [INDIRECT_ACTION_LIST] = {
8080 : : .name = "list",
8081 : : .help = "specify actions for indirect handle list",
8082 : : .next = NEXT(NEXT_ENTRY(ACTIONS, END)),
8083 : : .call = parse_ia,
8084 : : },
8085 : : [INDIRECT_ACTION_FLOW_CONF] = {
8086 : : .name = "flow_conf",
8087 : : .help = "specify actions configuration for indirect handle list",
8088 : : .next = NEXT(NEXT_ENTRY(ACTIONS, END)),
8089 : : .call = parse_ia,
8090 : : },
8091 : : [ACTION_POL_G] = {
8092 : : .name = "g_actions",
8093 : : .help = "submit a list of associated actions for green",
8094 : : .next = NEXT(next_action),
8095 : : .call = parse_mp,
8096 : : },
8097 : : [ACTION_POL_Y] = {
8098 : : .name = "y_actions",
8099 : : .help = "submit a list of associated actions for yellow",
8100 : : .next = NEXT(next_action),
8101 : : },
8102 : : [ACTION_POL_R] = {
8103 : : .name = "r_actions",
8104 : : .help = "submit a list of associated actions for red",
8105 : : .next = NEXT(next_action),
8106 : : },
8107 : : [ACTION_QUOTA_CREATE] = {
8108 : : .name = "quota_create",
8109 : : .help = "create quota action",
8110 : : .priv = PRIV_ACTION(QUOTA,
8111 : : sizeof(struct rte_flow_action_quota)),
8112 : : .next = NEXT(action_quota_create),
8113 : : .call = parse_vc
8114 : : },
8115 : : [ACTION_QUOTA_CREATE_LIMIT] = {
8116 : : .name = "limit",
8117 : : .help = "quota limit",
8118 : : .next = NEXT(action_quota_create, NEXT_ENTRY(COMMON_UNSIGNED)),
8119 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_quota, quota)),
8120 : : .call = parse_vc_conf
8121 : : },
8122 : : [ACTION_QUOTA_CREATE_MODE] = {
8123 : : .name = "mode",
8124 : : .help = "quota mode",
8125 : : .next = NEXT(action_quota_create,
8126 : : NEXT_ENTRY(ACTION_QUOTA_CREATE_MODE_NAME)),
8127 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_action_quota, mode)),
8128 : : .call = parse_vc_conf
8129 : : },
8130 : : [ACTION_QUOTA_CREATE_MODE_NAME] = {
8131 : : .name = "mode_name",
8132 : : .help = "quota mode name",
8133 : : .call = parse_quota_mode_name,
8134 : : .comp = comp_quota_mode_name
8135 : : },
8136 : : [ACTION_QUOTA_QU] = {
8137 : : .name = "quota_update",
8138 : : .help = "update quota action",
8139 : : .priv = PRIV_ACTION(QUOTA,
8140 : : sizeof(struct rte_flow_update_quota)),
8141 : : .next = NEXT(action_quota_update),
8142 : : .call = parse_vc
8143 : : },
8144 : : [ACTION_QUOTA_QU_LIMIT] = {
8145 : : .name = "limit",
8146 : : .help = "quota limit",
8147 : : .next = NEXT(action_quota_update, NEXT_ENTRY(COMMON_UNSIGNED)),
8148 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_update_quota, quota)),
8149 : : .call = parse_vc_conf
8150 : : },
8151 : : [ACTION_QUOTA_QU_UPDATE_OP] = {
8152 : : .name = "update_op",
8153 : : .help = "query update op SET|ADD",
8154 : : .next = NEXT(action_quota_update,
8155 : : NEXT_ENTRY(ACTION_QUOTA_QU_UPDATE_OP_NAME)),
8156 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_update_quota, op)),
8157 : : .call = parse_vc_conf
8158 : : },
8159 : : [ACTION_QUOTA_QU_UPDATE_OP_NAME] = {
8160 : : .name = "update_op_name",
8161 : : .help = "quota update op name",
8162 : : .call = parse_quota_update_name,
8163 : : .comp = comp_quota_update_name
8164 : : },
8165 : :
8166 : : /* Top-level command. */
8167 : : [ADD] = {
8168 : : .name = "add",
8169 : : .type = "port meter policy {port_id} {arg}",
8170 : : .help = "add port meter policy",
8171 : : .next = NEXT(NEXT_ENTRY(ITEM_POL_PORT)),
8172 : : .call = parse_init,
8173 : : },
8174 : : /* Sub-level commands. */
8175 : : [ITEM_POL_PORT] = {
8176 : : .name = "port",
8177 : : .help = "add port meter policy",
8178 : : .next = NEXT(NEXT_ENTRY(ITEM_POL_METER)),
8179 : : },
8180 : : [ITEM_POL_METER] = {
8181 : : .name = "meter",
8182 : : .help = "add port meter policy",
8183 : : .next = NEXT(NEXT_ENTRY(ITEM_POL_POLICY)),
8184 : : },
8185 : : [ITEM_POL_POLICY] = {
8186 : : .name = "policy",
8187 : : .help = "add port meter policy",
8188 : : .next = NEXT(NEXT_ENTRY(ACTION_POL_R),
8189 : : NEXT_ENTRY(ACTION_POL_Y),
8190 : : NEXT_ENTRY(ACTION_POL_G),
8191 : : NEXT_ENTRY(COMMON_POLICY_ID),
8192 : : NEXT_ENTRY(COMMON_PORT_ID)),
8193 : : .args = ARGS(ARGS_ENTRY(struct buffer, args.policy.policy_id),
8194 : : ARGS_ENTRY(struct buffer, port)),
8195 : : .call = parse_mp,
8196 : : },
8197 : : [ITEM_AGGR_AFFINITY] = {
8198 : : .name = "aggr_affinity",
8199 : : .help = "match on the aggregated port receiving the packets",
8200 : : .priv = PRIV_ITEM(AGGR_AFFINITY,
8201 : : sizeof(struct rte_flow_item_aggr_affinity)),
8202 : : .next = NEXT(item_aggr_affinity),
8203 : : .call = parse_vc,
8204 : : },
8205 : : [ITEM_AGGR_AFFINITY_VALUE] = {
8206 : : .name = "affinity",
8207 : : .help = "aggregated affinity value",
8208 : : .next = NEXT(item_aggr_affinity, NEXT_ENTRY(COMMON_UNSIGNED),
8209 : : item_param),
8210 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_aggr_affinity,
8211 : : affinity)),
8212 : : },
8213 : : [ITEM_TX_QUEUE] = {
8214 : : .name = "tx_queue",
8215 : : .help = "match on the tx queue of send packet",
8216 : : .priv = PRIV_ITEM(TX_QUEUE,
8217 : : sizeof(struct rte_flow_item_tx_queue)),
8218 : : .next = NEXT(item_tx_queue),
8219 : : .call = parse_vc,
8220 : : },
8221 : : [ITEM_TX_QUEUE_VALUE] = {
8222 : : .name = "tx_queue_value",
8223 : : .help = "tx queue value",
8224 : : .next = NEXT(item_tx_queue, NEXT_ENTRY(COMMON_UNSIGNED),
8225 : : item_param),
8226 : : .args = ARGS(ARGS_ENTRY(struct rte_flow_item_tx_queue,
8227 : : tx_queue)),
8228 : : },
8229 : : };
8230 : :
8231 : : /** Remove and return last entry from argument stack. */
8232 : : static const struct arg *
8233 : : pop_args(struct context *ctx)
8234 : : {
8235 : 0 : return ctx->args_num ? ctx->args[--ctx->args_num] : NULL;
8236 : : }
8237 : :
8238 : : /** Add entry on top of the argument stack. */
8239 : : static int
8240 : : push_args(struct context *ctx, const struct arg *arg)
8241 : : {
8242 : 0 : if (ctx->args_num == CTX_STACK_SIZE)
8243 : : return -1;
8244 : 0 : ctx->args[ctx->args_num++] = arg;
8245 : 0 : return 0;
8246 : : }
8247 : :
8248 : : /** Spread value into buffer according to bit-mask. */
8249 : : static size_t
8250 : 0 : arg_entry_bf_fill(void *dst, uintmax_t val, const struct arg *arg)
8251 : : {
8252 : 0 : uint32_t i = arg->size;
8253 : : uint32_t end = 0;
8254 : : int sub = 1;
8255 : : int add = 0;
8256 : : size_t len = 0;
8257 : :
8258 : 0 : if (!arg->mask)
8259 : : return 0;
8260 : : #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
8261 : 0 : if (!arg->hton) {
8262 : : i = 0;
8263 : : end = arg->size;
8264 : : sub = 0;
8265 : : add = 1;
8266 : : }
8267 : : #endif
8268 : 0 : while (i != end) {
8269 : : unsigned int shift = 0;
8270 : 0 : uint8_t *buf = (uint8_t *)dst + arg->offset + (i -= sub);
8271 : :
8272 : 0 : for (shift = 0; arg->mask[i] >> shift; ++shift) {
8273 : 0 : if (!(arg->mask[i] & (1 << shift)))
8274 : 0 : continue;
8275 : 0 : ++len;
8276 : 0 : if (!dst)
8277 : 0 : continue;
8278 : 0 : *buf &= ~(1 << shift);
8279 : 0 : *buf |= (val & 1) << shift;
8280 : 0 : val >>= 1;
8281 : : }
8282 : 0 : i += add;
8283 : : }
8284 : : return len;
8285 : : }
8286 : :
8287 : : /** Compare a string with a partial one of a given length. */
8288 : : static int
8289 : 0 : strcmp_partial(const char *full, const char *partial, size_t partial_len)
8290 : : {
8291 : 0 : int r = strncmp(full, partial, partial_len);
8292 : :
8293 : 0 : if (r)
8294 : : return r;
8295 : 0 : if (strlen(full) <= partial_len)
8296 : : return 0;
8297 : 0 : return full[partial_len];
8298 : : }
8299 : :
8300 : : /**
8301 : : * Parse a prefix length and generate a bit-mask.
8302 : : *
8303 : : * Last argument (ctx->args) is retrieved to determine mask size, storage
8304 : : * location and whether the result must use network byte ordering.
8305 : : */
8306 : : static int
8307 : 0 : parse_prefix(struct context *ctx, const struct token *token,
8308 : : const char *str, unsigned int len,
8309 : : void *buf, unsigned int size)
8310 : : {
8311 : : const struct arg *arg = pop_args(ctx);
8312 : : static const uint8_t conv[] = { 0x00, 0x80, 0xc0, 0xe0, 0xf0,
8313 : : 0xf8, 0xfc, 0xfe, 0xff };
8314 : : char *end;
8315 : : uintmax_t u;
8316 : : unsigned int bytes;
8317 : : unsigned int extra;
8318 : :
8319 : : (void)token;
8320 : : /* Argument is expected. */
8321 : 0 : if (!arg)
8322 : 0 : return -1;
8323 : 0 : errno = 0;
8324 : 0 : u = strtoumax(str, &end, 0);
8325 : 0 : if (errno || (size_t)(end - str) != len)
8326 : 0 : goto error;
8327 : 0 : if (arg->mask) {
8328 : : uintmax_t v = 0;
8329 : :
8330 : 0 : extra = arg_entry_bf_fill(NULL, 0, arg);
8331 : 0 : if (u > extra)
8332 : 0 : goto error;
8333 : 0 : if (!ctx->object)
8334 : 0 : return len;
8335 : 0 : extra -= u;
8336 : 0 : while (u--)
8337 : 0 : (v <<= 1, v |= 1);
8338 : 0 : v <<= extra;
8339 : 0 : if (!arg_entry_bf_fill(ctx->object, v, arg) ||
8340 : 0 : !arg_entry_bf_fill(ctx->objmask, -1, arg))
8341 : 0 : goto error;
8342 : 0 : return len;
8343 : : }
8344 : 0 : bytes = u / 8;
8345 : 0 : extra = u % 8;
8346 : 0 : size = arg->size;
8347 : 0 : if (bytes > size || bytes + !!extra > size)
8348 : 0 : goto error;
8349 : 0 : if (!ctx->object)
8350 : 0 : return len;
8351 : 0 : buf = (uint8_t *)ctx->object + arg->offset;
8352 : : #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
8353 : 0 : if (!arg->hton) {
8354 : 0 : memset((uint8_t *)buf + size - bytes, 0xff, bytes);
8355 : 0 : memset(buf, 0x00, size - bytes);
8356 : 0 : if (extra)
8357 : 0 : ((uint8_t *)buf)[size - bytes - 1] = conv[extra];
8358 : : } else
8359 : : #endif
8360 : : {
8361 : : memset(buf, 0xff, bytes);
8362 : 0 : memset((uint8_t *)buf + bytes, 0x00, size - bytes);
8363 : 0 : if (extra)
8364 : 0 : ((uint8_t *)buf)[bytes] = conv[extra];
8365 : : }
8366 : 0 : if (ctx->objmask)
8367 : 0 : memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
8368 : 0 : return len;
8369 : 0 : error:
8370 : : push_args(ctx, arg);
8371 : : return -1;
8372 : : }
8373 : :
8374 : : /** Default parsing function for token name matching. */
8375 : : static int
8376 : : parse_default(struct context *ctx, const struct token *token,
8377 : : const char *str, unsigned int len,
8378 : : void *buf, unsigned int size)
8379 : : {
8380 : : (void)ctx;
8381 : : (void)buf;
8382 : : (void)size;
8383 : 0 : if (strcmp_partial(token->name, str, len))
8384 : : return -1;
8385 : 0 : return len;
8386 : : }
8387 : :
8388 : : /** Parse flow command, initialize output buffer for subsequent tokens. */
8389 : : static int
8390 : 0 : parse_init(struct context *ctx, const struct token *token,
8391 : : const char *str, unsigned int len,
8392 : : void *buf, unsigned int size)
8393 : : {
8394 : : struct buffer *out = buf;
8395 : :
8396 : : /* Token name must match. */
8397 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8398 : : return -1;
8399 : : /* Nothing else to do if there is no buffer. */
8400 : 0 : if (!out)
8401 : : return len;
8402 : : /* Make sure buffer is large enough. */
8403 : 0 : if (size < sizeof(*out))
8404 : : return -1;
8405 : : /* Initialize buffer. */
8406 : : memset(out, 0x00, sizeof(*out));
8407 : 0 : memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
8408 : 0 : ctx->objdata = 0;
8409 : 0 : ctx->object = out;
8410 : 0 : ctx->objmask = NULL;
8411 : 0 : return len;
8412 : : }
8413 : :
8414 : : /** Parse tokens for indirect action commands. */
8415 : : static int
8416 : 0 : parse_ia(struct context *ctx, const struct token *token,
8417 : : const char *str, unsigned int len,
8418 : : void *buf, unsigned int size)
8419 : : {
8420 : : struct buffer *out = buf;
8421 : :
8422 : : /* Token name must match. */
8423 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8424 : : return -1;
8425 : : /* Nothing else to do if there is no buffer. */
8426 : 0 : if (!out)
8427 : : return len;
8428 : 0 : if (!out->command) {
8429 : 0 : if (ctx->curr != INDIRECT_ACTION)
8430 : : return -1;
8431 : 0 : if (sizeof(*out) > size)
8432 : : return -1;
8433 : 0 : out->command = ctx->curr;
8434 : 0 : ctx->objdata = 0;
8435 : 0 : ctx->object = out;
8436 : 0 : ctx->objmask = NULL;
8437 : 0 : out->args.vc.data = (uint8_t *)out + size;
8438 : 0 : return len;
8439 : : }
8440 : 0 : switch (ctx->curr) {
8441 : 0 : case INDIRECT_ACTION_CREATE:
8442 : : case INDIRECT_ACTION_UPDATE:
8443 : : case INDIRECT_ACTION_QUERY_UPDATE:
8444 : 0 : out->args.vc.actions =
8445 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8446 : : sizeof(double));
8447 : 0 : out->args.vc.attr.group = UINT32_MAX;
8448 : : /* fallthrough */
8449 : 0 : case INDIRECT_ACTION_QUERY:
8450 : 0 : out->command = ctx->curr;
8451 : 0 : ctx->objdata = 0;
8452 : 0 : ctx->object = out;
8453 : 0 : ctx->objmask = NULL;
8454 : 0 : return len;
8455 : 0 : case INDIRECT_ACTION_EGRESS:
8456 : 0 : out->args.vc.attr.egress = 1;
8457 : 0 : return len;
8458 : 0 : case INDIRECT_ACTION_INGRESS:
8459 : 0 : out->args.vc.attr.ingress = 1;
8460 : 0 : return len;
8461 : 0 : case INDIRECT_ACTION_TRANSFER:
8462 : 0 : out->args.vc.attr.transfer = 1;
8463 : 0 : return len;
8464 : 0 : case INDIRECT_ACTION_QU_MODE:
8465 : 0 : return len;
8466 : 0 : case INDIRECT_ACTION_LIST:
8467 : 0 : out->command = INDIRECT_ACTION_LIST_CREATE;
8468 : 0 : return len;
8469 : 0 : case INDIRECT_ACTION_FLOW_CONF:
8470 : 0 : out->command = INDIRECT_ACTION_FLOW_CONF_CREATE;
8471 : 0 : return len;
8472 : : default:
8473 : : return -1;
8474 : : }
8475 : : }
8476 : :
8477 : :
8478 : : /** Parse tokens for indirect action destroy command. */
8479 : : static int
8480 : 0 : parse_ia_destroy(struct context *ctx, const struct token *token,
8481 : : const char *str, unsigned int len,
8482 : : void *buf, unsigned int size)
8483 : : {
8484 : : struct buffer *out = buf;
8485 : : uint32_t *action_id;
8486 : :
8487 : : /* Token name must match. */
8488 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8489 : : return -1;
8490 : : /* Nothing else to do if there is no buffer. */
8491 : 0 : if (!out)
8492 : : return len;
8493 : 0 : if (!out->command || out->command == INDIRECT_ACTION) {
8494 : 0 : if (ctx->curr != INDIRECT_ACTION_DESTROY)
8495 : : return -1;
8496 : 0 : if (sizeof(*out) > size)
8497 : : return -1;
8498 : 0 : out->command = ctx->curr;
8499 : 0 : ctx->objdata = 0;
8500 : 0 : ctx->object = out;
8501 : 0 : ctx->objmask = NULL;
8502 : 0 : out->args.ia_destroy.action_id =
8503 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8504 : : sizeof(double));
8505 : 0 : return len;
8506 : : }
8507 : 0 : action_id = out->args.ia_destroy.action_id
8508 : 0 : + out->args.ia_destroy.action_id_n++;
8509 : 0 : if ((uint8_t *)action_id > (uint8_t *)out + size)
8510 : : return -1;
8511 : 0 : ctx->objdata = 0;
8512 : 0 : ctx->object = action_id;
8513 : 0 : ctx->objmask = NULL;
8514 : 0 : return len;
8515 : : }
8516 : :
8517 : : /** Parse tokens for indirect action commands. */
8518 : : static int
8519 : 0 : parse_qia(struct context *ctx, const struct token *token,
8520 : : const char *str, unsigned int len,
8521 : : void *buf, unsigned int size)
8522 : : {
8523 : : struct buffer *out = buf;
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) {
8532 : 0 : if (ctx->curr != QUEUE)
8533 : : return -1;
8534 : 0 : if (sizeof(*out) > size)
8535 : : return -1;
8536 : 0 : out->args.vc.data = (uint8_t *)out + size;
8537 : 0 : return len;
8538 : : }
8539 : 0 : switch (ctx->curr) {
8540 : 0 : case QUEUE_INDIRECT_ACTION:
8541 : 0 : return len;
8542 : 0 : case QUEUE_INDIRECT_ACTION_CREATE:
8543 : : case QUEUE_INDIRECT_ACTION_UPDATE:
8544 : : case QUEUE_INDIRECT_ACTION_QUERY_UPDATE:
8545 : 0 : out->args.vc.actions =
8546 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8547 : : sizeof(double));
8548 : 0 : out->args.vc.attr.group = UINT32_MAX;
8549 : : /* fallthrough */
8550 : 0 : case QUEUE_INDIRECT_ACTION_QUERY:
8551 : 0 : out->command = ctx->curr;
8552 : 0 : ctx->objdata = 0;
8553 : 0 : ctx->object = out;
8554 : 0 : ctx->objmask = NULL;
8555 : 0 : return len;
8556 : 0 : case QUEUE_INDIRECT_ACTION_EGRESS:
8557 : 0 : out->args.vc.attr.egress = 1;
8558 : 0 : return len;
8559 : 0 : case QUEUE_INDIRECT_ACTION_INGRESS:
8560 : 0 : out->args.vc.attr.ingress = 1;
8561 : 0 : return len;
8562 : 0 : case QUEUE_INDIRECT_ACTION_TRANSFER:
8563 : 0 : out->args.vc.attr.transfer = 1;
8564 : 0 : return len;
8565 : 0 : case QUEUE_INDIRECT_ACTION_CREATE_POSTPONE:
8566 : 0 : return len;
8567 : 0 : case QUEUE_INDIRECT_ACTION_QU_MODE:
8568 : 0 : return len;
8569 : 0 : case QUEUE_INDIRECT_ACTION_LIST:
8570 : 0 : out->command = QUEUE_INDIRECT_ACTION_LIST_CREATE;
8571 : 0 : return len;
8572 : : default:
8573 : : return -1;
8574 : : }
8575 : : }
8576 : :
8577 : : /** Parse tokens for indirect action destroy command. */
8578 : : static int
8579 : 0 : parse_qia_destroy(struct context *ctx, const struct token *token,
8580 : : const char *str, unsigned int len,
8581 : : void *buf, unsigned int size)
8582 : : {
8583 : : struct buffer *out = buf;
8584 : : uint32_t *action_id;
8585 : :
8586 : : /* Token name must match. */
8587 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8588 : : return -1;
8589 : : /* Nothing else to do if there is no buffer. */
8590 : 0 : if (!out)
8591 : : return len;
8592 : 0 : if (!out->command || out->command == QUEUE) {
8593 : 0 : if (ctx->curr != QUEUE_INDIRECT_ACTION_DESTROY)
8594 : : return -1;
8595 : 0 : if (sizeof(*out) > size)
8596 : : return -1;
8597 : 0 : out->command = ctx->curr;
8598 : 0 : ctx->objdata = 0;
8599 : 0 : ctx->object = out;
8600 : 0 : ctx->objmask = NULL;
8601 : 0 : out->args.ia_destroy.action_id =
8602 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8603 : : sizeof(double));
8604 : 0 : return len;
8605 : : }
8606 : 0 : switch (ctx->curr) {
8607 : 0 : case QUEUE_INDIRECT_ACTION:
8608 : 0 : out->command = ctx->curr;
8609 : 0 : ctx->objdata = 0;
8610 : 0 : ctx->object = out;
8611 : 0 : ctx->objmask = NULL;
8612 : 0 : return len;
8613 : 0 : case QUEUE_INDIRECT_ACTION_DESTROY_ID:
8614 : 0 : action_id = out->args.ia_destroy.action_id
8615 : 0 : + out->args.ia_destroy.action_id_n++;
8616 : 0 : if ((uint8_t *)action_id > (uint8_t *)out + size)
8617 : : return -1;
8618 : 0 : ctx->objdata = 0;
8619 : 0 : ctx->object = action_id;
8620 : 0 : ctx->objmask = NULL;
8621 : 0 : return len;
8622 : 0 : case QUEUE_INDIRECT_ACTION_DESTROY_POSTPONE:
8623 : 0 : return len;
8624 : : default:
8625 : : return -1;
8626 : : }
8627 : : }
8628 : :
8629 : : /** Parse tokens for meter policy action commands. */
8630 : : static int
8631 : 0 : parse_mp(struct context *ctx, const struct token *token,
8632 : : const char *str, unsigned int len,
8633 : : void *buf, unsigned int size)
8634 : : {
8635 : : struct buffer *out = buf;
8636 : :
8637 : : /* Token name must match. */
8638 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8639 : : return -1;
8640 : : /* Nothing else to do if there is no buffer. */
8641 : 0 : if (!out)
8642 : : return len;
8643 : 0 : if (!out->command) {
8644 : 0 : if (ctx->curr != ITEM_POL_POLICY)
8645 : : return -1;
8646 : 0 : if (sizeof(*out) > size)
8647 : : return -1;
8648 : 0 : out->command = ctx->curr;
8649 : 0 : ctx->objdata = 0;
8650 : 0 : ctx->object = out;
8651 : 0 : ctx->objmask = NULL;
8652 : 0 : out->args.vc.data = (uint8_t *)out + size;
8653 : 0 : return len;
8654 : : }
8655 : 0 : switch (ctx->curr) {
8656 : 0 : case ACTION_POL_G:
8657 : 0 : out->args.vc.actions =
8658 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8659 : : sizeof(double));
8660 : 0 : out->command = ctx->curr;
8661 : 0 : ctx->objdata = 0;
8662 : 0 : ctx->object = out;
8663 : 0 : ctx->objmask = NULL;
8664 : 0 : return len;
8665 : : default:
8666 : : return -1;
8667 : : }
8668 : : }
8669 : :
8670 : : /** Parse tokens for validate/create commands. */
8671 : : static int
8672 : 0 : parse_vc(struct context *ctx, const struct token *token,
8673 : : const char *str, unsigned int len,
8674 : : void *buf, unsigned int size)
8675 : : {
8676 : : struct buffer *out = buf;
8677 : : uint8_t *data;
8678 : : uint32_t data_size;
8679 : :
8680 : : /* Token name must match. */
8681 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8682 : : return -1;
8683 : : /* Nothing else to do if there is no buffer. */
8684 : 0 : if (!out)
8685 : : return len;
8686 : 0 : if (!out->command) {
8687 : 0 : if (ctx->curr != VALIDATE && ctx->curr != CREATE &&
8688 : 0 : ctx->curr != PATTERN_TEMPLATE_CREATE &&
8689 : 0 : ctx->curr != ACTIONS_TEMPLATE_CREATE &&
8690 : : ctx->curr != UPDATE)
8691 : : return -1;
8692 : 0 : if (ctx->curr == UPDATE)
8693 : 0 : out->args.vc.pattern =
8694 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8695 : : sizeof(double));
8696 : 0 : if (sizeof(*out) > size)
8697 : : return -1;
8698 : 0 : out->command = ctx->curr;
8699 : 0 : ctx->objdata = 0;
8700 : 0 : ctx->object = out;
8701 : 0 : ctx->objmask = NULL;
8702 : 0 : out->args.vc.data = (uint8_t *)out + size;
8703 : 0 : return len;
8704 : : }
8705 : 0 : ctx->objdata = 0;
8706 : 0 : switch (ctx->curr) {
8707 : 0 : default:
8708 : 0 : ctx->object = &out->args.vc.attr;
8709 : 0 : break;
8710 : 0 : case VC_TUNNEL_SET:
8711 : : case VC_TUNNEL_MATCH:
8712 : 0 : ctx->object = &out->args.vc.tunnel_ops;
8713 : 0 : break;
8714 : 0 : case VC_USER_ID:
8715 : 0 : ctx->object = out;
8716 : 0 : break;
8717 : : }
8718 : 0 : ctx->objmask = NULL;
8719 : 0 : switch (ctx->curr) {
8720 : : case VC_GROUP:
8721 : : case VC_PRIORITY:
8722 : : case VC_USER_ID:
8723 : : return len;
8724 : 0 : case VC_TUNNEL_SET:
8725 : 0 : out->args.vc.tunnel_ops.enabled = 1;
8726 : 0 : out->args.vc.tunnel_ops.actions = 1;
8727 : 0 : return len;
8728 : 0 : case VC_TUNNEL_MATCH:
8729 : 0 : out->args.vc.tunnel_ops.enabled = 1;
8730 : 0 : out->args.vc.tunnel_ops.items = 1;
8731 : 0 : return len;
8732 : 0 : case VC_INGRESS:
8733 : 0 : out->args.vc.attr.ingress = 1;
8734 : 0 : return len;
8735 : 0 : case VC_EGRESS:
8736 : 0 : out->args.vc.attr.egress = 1;
8737 : 0 : return len;
8738 : 0 : case VC_TRANSFER:
8739 : 0 : out->args.vc.attr.transfer = 1;
8740 : 0 : return len;
8741 : 0 : case ITEM_PATTERN:
8742 : 0 : out->args.vc.pattern =
8743 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8744 : : sizeof(double));
8745 : 0 : ctx->object = out->args.vc.pattern;
8746 : 0 : ctx->objmask = NULL;
8747 : 0 : return len;
8748 : 0 : case ITEM_END:
8749 : 0 : if ((out->command == VALIDATE || out->command == CREATE) &&
8750 : : ctx->last)
8751 : : return -1;
8752 : 0 : if (out->command == PATTERN_TEMPLATE_CREATE &&
8753 : 0 : !ctx->last)
8754 : : return -1;
8755 : : break;
8756 : 0 : case ACTIONS:
8757 : 0 : out->args.vc.actions = out->args.vc.pattern ?
8758 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)
8759 : : (out->args.vc.pattern +
8760 : : out->args.vc.pattern_n),
8761 : 0 : sizeof(double)) :
8762 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
8763 : : sizeof(double));
8764 : 0 : ctx->object = out->args.vc.actions;
8765 : 0 : ctx->objmask = NULL;
8766 : 0 : return len;
8767 : 0 : case VC_IS_USER_ID:
8768 : 0 : out->args.vc.user_id = true;
8769 : 0 : return len;
8770 : 0 : default:
8771 : 0 : if (!token->priv)
8772 : : return -1;
8773 : : break;
8774 : : }
8775 : 0 : if (!out->args.vc.actions) {
8776 : 0 : const struct parse_item_priv *priv = token->priv;
8777 : 0 : struct rte_flow_item *item =
8778 : 0 : out->args.vc.pattern + out->args.vc.pattern_n;
8779 : :
8780 : 0 : data_size = priv->size * 3; /* spec, last, mask */
8781 : 0 : data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
8782 : : (out->args.vc.data - data_size),
8783 : : sizeof(double));
8784 : 0 : if ((uint8_t *)item + sizeof(*item) > data)
8785 : : return -1;
8786 : 0 : *item = (struct rte_flow_item){
8787 : 0 : .type = priv->type,
8788 : : };
8789 : 0 : ++out->args.vc.pattern_n;
8790 : 0 : ctx->object = item;
8791 : 0 : ctx->objmask = NULL;
8792 : : } else {
8793 : 0 : const struct parse_action_priv *priv = token->priv;
8794 : 0 : struct rte_flow_action *action =
8795 : 0 : out->args.vc.actions + out->args.vc.actions_n;
8796 : :
8797 : 0 : data_size = priv->size; /* configuration */
8798 : 0 : data = (void *)RTE_ALIGN_FLOOR((uintptr_t)
8799 : : (out->args.vc.data - data_size),
8800 : : sizeof(double));
8801 : 0 : if ((uint8_t *)action + sizeof(*action) > data)
8802 : : return -1;
8803 : 0 : *action = (struct rte_flow_action){
8804 : 0 : .type = priv->type,
8805 : 0 : .conf = data_size ? data : NULL,
8806 : : };
8807 : 0 : ++out->args.vc.actions_n;
8808 : 0 : ctx->object = action;
8809 : 0 : ctx->objmask = NULL;
8810 : : }
8811 : 0 : memset(data, 0, data_size);
8812 : 0 : out->args.vc.data = data;
8813 : 0 : ctx->objdata = data_size;
8814 : 0 : return len;
8815 : : }
8816 : :
8817 : : /** Parse pattern item parameter type. */
8818 : : static int
8819 : 0 : parse_vc_spec(struct context *ctx, const struct token *token,
8820 : : const char *str, unsigned int len,
8821 : : void *buf, unsigned int size)
8822 : : {
8823 : : struct buffer *out = buf;
8824 : : struct rte_flow_item *item;
8825 : : uint32_t data_size;
8826 : : int index;
8827 : : int objmask = 0;
8828 : :
8829 : : (void)size;
8830 : : /* Token name must match. */
8831 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8832 : : return -1;
8833 : : /* Parse parameter types. */
8834 : 0 : switch (ctx->curr) {
8835 : : static const enum index prefix[] = NEXT_ENTRY(COMMON_PREFIX);
8836 : :
8837 : : case ITEM_PARAM_IS:
8838 : : index = 0;
8839 : : objmask = 1;
8840 : : break;
8841 : 0 : case ITEM_PARAM_SPEC:
8842 : : index = 0;
8843 : 0 : break;
8844 : 0 : case ITEM_PARAM_LAST:
8845 : : index = 1;
8846 : 0 : break;
8847 : 0 : case ITEM_PARAM_PREFIX:
8848 : : /* Modify next token to expect a prefix. */
8849 : 0 : if (ctx->next_num < 2)
8850 : : return -1;
8851 : 0 : ctx->next[ctx->next_num - 2] = prefix;
8852 : : /* Fall through. */
8853 : : case ITEM_PARAM_MASK:
8854 : : index = 2;
8855 : : break;
8856 : : default:
8857 : : return -1;
8858 : : }
8859 : : /* Nothing else to do if there is no buffer. */
8860 : 0 : if (!out)
8861 : : return len;
8862 : 0 : if (!out->args.vc.pattern_n)
8863 : : return -1;
8864 : 0 : item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
8865 : 0 : data_size = ctx->objdata / 3; /* spec, last, mask */
8866 : : /* Point to selected object. */
8867 : 0 : ctx->object = out->args.vc.data + (data_size * index);
8868 : 0 : if (objmask) {
8869 : 0 : ctx->objmask = out->args.vc.data + (data_size * 2); /* mask */
8870 : 0 : item->mask = ctx->objmask;
8871 : : } else
8872 : 0 : ctx->objmask = NULL;
8873 : : /* Update relevant item pointer. */
8874 : 0 : *((const void **[]){ &item->spec, &item->last, &item->mask })[index] =
8875 : : ctx->object;
8876 : 0 : return len;
8877 : : }
8878 : :
8879 : : /** Parse action configuration field. */
8880 : : static int
8881 : 0 : parse_vc_conf(struct context *ctx, const struct token *token,
8882 : : const char *str, unsigned int len,
8883 : : void *buf, unsigned int size)
8884 : : {
8885 : : struct buffer *out = buf;
8886 : :
8887 : : (void)size;
8888 : : /* Token name must match. */
8889 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8890 : : return -1;
8891 : : /* Nothing else to do if there is no buffer. */
8892 : 0 : if (!out)
8893 : : return len;
8894 : : /* Point to selected object. */
8895 : 0 : ctx->object = out->args.vc.data;
8896 : 0 : ctx->objmask = NULL;
8897 : 0 : return len;
8898 : : }
8899 : :
8900 : : /** Parse action configuration field. */
8901 : : static int
8902 : 0 : parse_vc_conf_timeout(struct context *ctx, const struct token *token,
8903 : : const char *str, unsigned int len,
8904 : : void *buf, unsigned int size)
8905 : : {
8906 : : struct buffer *out = buf;
8907 : : struct rte_flow_update_age *update;
8908 : :
8909 : : (void)size;
8910 : 0 : if (ctx->curr != ACTION_AGE_UPDATE_TIMEOUT)
8911 : : return -1;
8912 : : /* Token name must match. */
8913 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8914 : : return -1;
8915 : : /* Nothing else to do if there is no buffer. */
8916 : 0 : if (!out)
8917 : : return len;
8918 : : /* Point to selected object. */
8919 : 0 : ctx->object = out->args.vc.data;
8920 : 0 : ctx->objmask = NULL;
8921 : : /* Update the timeout is valid. */
8922 : : update = (struct rte_flow_update_age *)out->args.vc.data;
8923 : 0 : update->timeout_valid = 1;
8924 : 0 : return len;
8925 : : }
8926 : :
8927 : : /** Parse eCPRI common header type field. */
8928 : : static int
8929 : 0 : parse_vc_item_ecpri_type(struct context *ctx, const struct token *token,
8930 : : const char *str, unsigned int len,
8931 : : void *buf, unsigned int size)
8932 : : {
8933 : : struct rte_flow_item_ecpri *ecpri;
8934 : : struct rte_flow_item_ecpri *ecpri_mask;
8935 : : struct rte_flow_item *item;
8936 : : uint32_t data_size;
8937 : : uint8_t msg_type;
8938 : : struct buffer *out = buf;
8939 : : const struct arg *arg;
8940 : :
8941 : : (void)size;
8942 : : /* Token name must match. */
8943 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8944 : : return -1;
8945 : 0 : switch (ctx->curr) {
8946 : : case ITEM_ECPRI_COMMON_TYPE_IQ_DATA:
8947 : : msg_type = RTE_ECPRI_MSG_TYPE_IQ_DATA;
8948 : : break;
8949 : : case ITEM_ECPRI_COMMON_TYPE_RTC_CTRL:
8950 : : msg_type = RTE_ECPRI_MSG_TYPE_RTC_CTRL;
8951 : : break;
8952 : : case ITEM_ECPRI_COMMON_TYPE_DLY_MSR:
8953 : : msg_type = RTE_ECPRI_MSG_TYPE_DLY_MSR;
8954 : : break;
8955 : : default:
8956 : : return -1;
8957 : : }
8958 : 0 : if (!ctx->object)
8959 : : return len;
8960 : : arg = pop_args(ctx);
8961 : 0 : if (!arg)
8962 : 0 : return -1;
8963 : 0 : ecpri = (struct rte_flow_item_ecpri *)out->args.vc.data;
8964 : 0 : ecpri->hdr.common.type = msg_type;
8965 : 0 : data_size = ctx->objdata / 3; /* spec, last, mask */
8966 : 0 : ecpri_mask = (struct rte_flow_item_ecpri *)(out->args.vc.data +
8967 : 0 : (data_size * 2));
8968 : 0 : ecpri_mask->hdr.common.type = 0xFF;
8969 : 0 : if (arg->hton) {
8970 : 0 : ecpri->hdr.common.u32 = rte_cpu_to_be_32(ecpri->hdr.common.u32);
8971 : 0 : ecpri_mask->hdr.common.u32 =
8972 : 0 : rte_cpu_to_be_32(ecpri_mask->hdr.common.u32);
8973 : : }
8974 : 0 : item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
8975 : 0 : item->spec = ecpri;
8976 : 0 : item->mask = ecpri_mask;
8977 : 0 : return len;
8978 : : }
8979 : :
8980 : : /** Parse L2TPv2 common header type field. */
8981 : : static int
8982 : 0 : parse_vc_item_l2tpv2_type(struct context *ctx, const struct token *token,
8983 : : const char *str, unsigned int len,
8984 : : void *buf, unsigned int size)
8985 : : {
8986 : : struct rte_flow_item_l2tpv2 *l2tpv2;
8987 : : struct rte_flow_item_l2tpv2 *l2tpv2_mask;
8988 : : struct rte_flow_item *item;
8989 : : uint32_t data_size;
8990 : : uint16_t msg_type = 0;
8991 : : struct buffer *out = buf;
8992 : : const struct arg *arg;
8993 : :
8994 : : (void)size;
8995 : : /* Token name must match. */
8996 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
8997 : : return -1;
8998 : 0 : switch (ctx->curr) {
8999 : : case ITEM_L2TPV2_TYPE_DATA:
9000 : : msg_type |= RTE_L2TPV2_MSG_TYPE_DATA;
9001 : : break;
9002 : : case ITEM_L2TPV2_TYPE_DATA_L:
9003 : : msg_type |= RTE_L2TPV2_MSG_TYPE_DATA_L;
9004 : : break;
9005 : : case ITEM_L2TPV2_TYPE_DATA_S:
9006 : : msg_type |= RTE_L2TPV2_MSG_TYPE_DATA_S;
9007 : : break;
9008 : : case ITEM_L2TPV2_TYPE_DATA_O:
9009 : : msg_type |= RTE_L2TPV2_MSG_TYPE_DATA_O;
9010 : : break;
9011 : : case ITEM_L2TPV2_TYPE_DATA_L_S:
9012 : : msg_type |= RTE_L2TPV2_MSG_TYPE_DATA_L_S;
9013 : : break;
9014 : : case ITEM_L2TPV2_TYPE_CTRL:
9015 : : msg_type |= RTE_L2TPV2_MSG_TYPE_CONTROL;
9016 : : break;
9017 : : default:
9018 : : return -1;
9019 : : }
9020 : 0 : if (!ctx->object)
9021 : : return len;
9022 : : arg = pop_args(ctx);
9023 : 0 : if (!arg)
9024 : 0 : return -1;
9025 : 0 : l2tpv2 = (struct rte_flow_item_l2tpv2 *)out->args.vc.data;
9026 : 0 : l2tpv2->hdr.common.flags_version |= msg_type;
9027 : 0 : data_size = ctx->objdata / 3; /* spec, last, mask */
9028 : 0 : l2tpv2_mask = (struct rte_flow_item_l2tpv2 *)(out->args.vc.data +
9029 : 0 : (data_size * 2));
9030 : 0 : l2tpv2_mask->hdr.common.flags_version = 0xFFFF;
9031 : 0 : if (arg->hton) {
9032 : 0 : l2tpv2->hdr.common.flags_version =
9033 : 0 : rte_cpu_to_be_16(l2tpv2->hdr.common.flags_version);
9034 : 0 : l2tpv2_mask->hdr.common.flags_version =
9035 : 0 : rte_cpu_to_be_16(l2tpv2_mask->hdr.common.flags_version);
9036 : : }
9037 : 0 : item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
9038 : 0 : item->spec = l2tpv2;
9039 : 0 : item->mask = l2tpv2_mask;
9040 : 0 : return len;
9041 : : }
9042 : :
9043 : : /** Parse operation for compare match item. */
9044 : : static int
9045 : 0 : parse_vc_compare_op(struct context *ctx, const struct token *token,
9046 : : const char *str, unsigned int len, void *buf,
9047 : : unsigned int size)
9048 : : {
9049 : : struct rte_flow_item_compare *compare_item;
9050 : : unsigned int i;
9051 : :
9052 : : (void)token;
9053 : : (void)buf;
9054 : : (void)size;
9055 : 0 : if (ctx->curr != ITEM_COMPARE_OP_VALUE)
9056 : : return -1;
9057 : 0 : for (i = 0; compare_ops[i]; ++i)
9058 : 0 : if (!strcmp_partial(compare_ops[i], str, len))
9059 : : break;
9060 : 0 : if (!compare_ops[i])
9061 : : return -1;
9062 : 0 : if (!ctx->object)
9063 : 0 : return len;
9064 : : compare_item = ctx->object;
9065 : 0 : compare_item->operation = (enum rte_flow_item_compare_op)i;
9066 : 0 : return len;
9067 : : }
9068 : :
9069 : : /** Parse id for compare match item. */
9070 : : static int
9071 : 0 : parse_vc_compare_field_id(struct context *ctx, const struct token *token,
9072 : : const char *str, unsigned int len, void *buf,
9073 : : unsigned int size)
9074 : : {
9075 : : struct rte_flow_item_compare *compare_item;
9076 : : unsigned int i;
9077 : :
9078 : : (void)token;
9079 : : (void)buf;
9080 : : (void)size;
9081 : 0 : if (ctx->curr != ITEM_COMPARE_FIELD_A_TYPE_VALUE &&
9082 : : ctx->curr != ITEM_COMPARE_FIELD_B_TYPE_VALUE)
9083 : : return -1;
9084 : 0 : for (i = 0; flow_field_ids[i]; ++i)
9085 : 0 : if (!strcmp_partial(flow_field_ids[i], str, len))
9086 : : break;
9087 : 0 : if (!flow_field_ids[i])
9088 : : return -1;
9089 : 0 : if (!ctx->object)
9090 : 0 : return len;
9091 : : compare_item = ctx->object;
9092 : 0 : if (ctx->curr == ITEM_COMPARE_FIELD_A_TYPE_VALUE)
9093 : 0 : compare_item->a.field = (enum rte_flow_field_id)i;
9094 : : else
9095 : 0 : compare_item->b.field = (enum rte_flow_field_id)i;
9096 : 0 : return len;
9097 : : }
9098 : :
9099 : : /** Parse level for compare match item. */
9100 : : static int
9101 : 0 : parse_vc_compare_field_level(struct context *ctx, const struct token *token,
9102 : : const char *str, unsigned int len, void *buf,
9103 : : unsigned int size)
9104 : : {
9105 : : struct rte_flow_item_compare *compare_item;
9106 : : struct flex_item *fp = NULL;
9107 : : uint32_t val;
9108 : : struct buffer *out = buf;
9109 : : char *end;
9110 : :
9111 : : (void)token;
9112 : : (void)size;
9113 : 0 : if (ctx->curr != ITEM_COMPARE_FIELD_A_LEVEL_VALUE &&
9114 : : ctx->curr != ITEM_COMPARE_FIELD_B_LEVEL_VALUE)
9115 : : return -1;
9116 : 0 : if (!ctx->object)
9117 : 0 : return len;
9118 : : compare_item = ctx->object;
9119 : 0 : errno = 0;
9120 : 0 : val = strtoumax(str, &end, 0);
9121 : 0 : if (errno || (size_t)(end - str) != len)
9122 : : return -1;
9123 : : /* No need to validate action template mask value */
9124 : 0 : if (out->args.vc.masks) {
9125 : 0 : if (ctx->curr == ITEM_COMPARE_FIELD_A_LEVEL_VALUE)
9126 : 0 : compare_item->a.level = val;
9127 : : else
9128 : 0 : compare_item->b.level = val;
9129 : 0 : return len;
9130 : : }
9131 : 0 : if ((ctx->curr == ITEM_COMPARE_FIELD_A_LEVEL_VALUE &&
9132 : 0 : compare_item->a.field == RTE_FLOW_FIELD_FLEX_ITEM) ||
9133 : 0 : (ctx->curr == ITEM_COMPARE_FIELD_B_LEVEL_VALUE &&
9134 : 0 : compare_item->b.field == RTE_FLOW_FIELD_FLEX_ITEM)) {
9135 : 0 : if (val >= FLEX_MAX_PARSERS_NUM) {
9136 : : printf("Bad flex item handle\n");
9137 : 0 : return -1;
9138 : : }
9139 : 0 : fp = flex_items[ctx->port][val];
9140 : 0 : if (!fp) {
9141 : : printf("Bad flex item handle\n");
9142 : 0 : return -1;
9143 : : }
9144 : : }
9145 : 0 : if (ctx->curr == ITEM_COMPARE_FIELD_A_LEVEL_VALUE) {
9146 : 0 : if (compare_item->a.field != RTE_FLOW_FIELD_FLEX_ITEM)
9147 : 0 : compare_item->a.level = val;
9148 : : else
9149 : 0 : compare_item->a.flex_handle = fp->flex_handle;
9150 : 0 : } else if (ctx->curr == ITEM_COMPARE_FIELD_B_LEVEL_VALUE) {
9151 : 0 : if (compare_item->b.field != RTE_FLOW_FIELD_FLEX_ITEM)
9152 : 0 : compare_item->b.level = val;
9153 : : else
9154 : 0 : compare_item->b.flex_handle = fp->flex_handle;
9155 : : }
9156 : 0 : return len;
9157 : : }
9158 : :
9159 : : /** Parse meter color action type. */
9160 : : static int
9161 : 0 : parse_vc_action_meter_color_type(struct context *ctx, const struct token *token,
9162 : : const char *str, unsigned int len,
9163 : : void *buf, unsigned int size)
9164 : : {
9165 : : struct rte_flow_action *action_data;
9166 : : struct rte_flow_action_meter_color *conf;
9167 : : enum rte_color color;
9168 : :
9169 : : (void)buf;
9170 : : (void)size;
9171 : : /* Token name must match. */
9172 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
9173 : : return -1;
9174 : 0 : switch (ctx->curr) {
9175 : : case ACTION_METER_COLOR_GREEN:
9176 : : color = RTE_COLOR_GREEN;
9177 : : break;
9178 : : case ACTION_METER_COLOR_YELLOW:
9179 : : color = RTE_COLOR_YELLOW;
9180 : : break;
9181 : : case ACTION_METER_COLOR_RED:
9182 : : color = RTE_COLOR_RED;
9183 : : break;
9184 : : default:
9185 : : return -1;
9186 : : }
9187 : :
9188 : 0 : if (!ctx->object)
9189 : : return len;
9190 : : action_data = ctx->object;
9191 : 0 : conf = (struct rte_flow_action_meter_color *)
9192 : : (uintptr_t)(action_data->conf);
9193 : 0 : conf->color = color;
9194 : 0 : return len;
9195 : : }
9196 : :
9197 : : /** Parse RSS action. */
9198 : : static int
9199 : 0 : parse_vc_action_rss(struct context *ctx, const struct token *token,
9200 : : const char *str, unsigned int len,
9201 : : void *buf, unsigned int size)
9202 : : {
9203 : : struct buffer *out = buf;
9204 : : struct rte_flow_action *action;
9205 : : struct action_rss_data *action_rss_data;
9206 : : unsigned int i;
9207 : : int ret;
9208 : :
9209 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
9210 : 0 : if (ret < 0)
9211 : : return ret;
9212 : : /* Nothing else to do if there is no buffer. */
9213 : 0 : if (!out)
9214 : : return ret;
9215 : 0 : if (!out->args.vc.actions_n)
9216 : : return -1;
9217 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
9218 : : /* Point to selected object. */
9219 : 0 : ctx->object = out->args.vc.data;
9220 : 0 : ctx->objmask = NULL;
9221 : : /* Set up default configuration. */
9222 : : action_rss_data = ctx->object;
9223 : 0 : *action_rss_data = (struct action_rss_data){
9224 : : .conf = (struct rte_flow_action_rss){
9225 : : .func = RTE_ETH_HASH_FUNCTION_DEFAULT,
9226 : : .level = 0,
9227 : : .types = rss_hf,
9228 : : .key_len = 0,
9229 : 0 : .queue_num = RTE_MIN(nb_rxq, ACTION_RSS_QUEUE_NUM),
9230 : : .key = NULL,
9231 : 0 : .queue = action_rss_data->queue,
9232 : : },
9233 : : .queue = { 0 },
9234 : : };
9235 : 0 : for (i = 0; i < action_rss_data->conf.queue_num; ++i)
9236 : 0 : action_rss_data->queue[i] = i;
9237 : 0 : action->conf = &action_rss_data->conf;
9238 : 0 : return ret;
9239 : : }
9240 : :
9241 : : /**
9242 : : * Parse func field for RSS action.
9243 : : *
9244 : : * The RTE_ETH_HASH_FUNCTION_* value to assign is derived from the
9245 : : * ACTION_RSS_FUNC_* index that called this function.
9246 : : */
9247 : : static int
9248 : 0 : parse_vc_action_rss_func(struct context *ctx, const struct token *token,
9249 : : const char *str, unsigned int len,
9250 : : void *buf, unsigned int size)
9251 : : {
9252 : : struct action_rss_data *action_rss_data;
9253 : : enum rte_eth_hash_function func;
9254 : :
9255 : : (void)buf;
9256 : : (void)size;
9257 : : /* Token name must match. */
9258 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
9259 : : return -1;
9260 : 0 : switch (ctx->curr) {
9261 : : case ACTION_RSS_FUNC_DEFAULT:
9262 : : func = RTE_ETH_HASH_FUNCTION_DEFAULT;
9263 : : break;
9264 : : case ACTION_RSS_FUNC_TOEPLITZ:
9265 : : func = RTE_ETH_HASH_FUNCTION_TOEPLITZ;
9266 : : break;
9267 : : case ACTION_RSS_FUNC_SIMPLE_XOR:
9268 : : func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
9269 : : break;
9270 : : case ACTION_RSS_FUNC_SYMMETRIC_TOEPLITZ:
9271 : : func = RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ;
9272 : : break;
9273 : : default:
9274 : : return -1;
9275 : : }
9276 : 0 : if (!ctx->object)
9277 : : return len;
9278 : : action_rss_data = ctx->object;
9279 : 0 : action_rss_data->conf.func = func;
9280 : 0 : return len;
9281 : : }
9282 : :
9283 : : /**
9284 : : * Parse type field for RSS action.
9285 : : *
9286 : : * Valid tokens are type field names and the "end" token.
9287 : : */
9288 : : static int
9289 : 0 : parse_vc_action_rss_type(struct context *ctx, const struct token *token,
9290 : : const char *str, unsigned int len,
9291 : : void *buf, unsigned int size)
9292 : : {
9293 : : static const enum index next[] = NEXT_ENTRY(ACTION_RSS_TYPE);
9294 : : struct action_rss_data *action_rss_data;
9295 : : unsigned int i;
9296 : :
9297 : : (void)token;
9298 : : (void)buf;
9299 : : (void)size;
9300 : 0 : if (ctx->curr != ACTION_RSS_TYPE)
9301 : : return -1;
9302 : 0 : if (!(ctx->objdata >> 16) && ctx->object) {
9303 : : action_rss_data = ctx->object;
9304 : 0 : action_rss_data->conf.types = 0;
9305 : : }
9306 : 0 : if (!strcmp_partial("end", str, len)) {
9307 : 0 : ctx->objdata &= 0xffff;
9308 : 0 : return len;
9309 : : }
9310 : 0 : for (i = 0; rss_type_table[i].str; ++i)
9311 : 0 : if (!strcmp_partial(rss_type_table[i].str, str, len))
9312 : : break;
9313 : 0 : if (!rss_type_table[i].str)
9314 : : return -1;
9315 : 0 : ctx->objdata = 1 << 16 | (ctx->objdata & 0xffff);
9316 : : /* Repeat token. */
9317 : 0 : if (ctx->next_num == RTE_DIM(ctx->next))
9318 : : return -1;
9319 : 0 : ctx->next[ctx->next_num++] = next;
9320 : 0 : if (!ctx->object)
9321 : 0 : return len;
9322 : : action_rss_data = ctx->object;
9323 : 0 : action_rss_data->conf.types |= rss_type_table[i].rss_type;
9324 : 0 : return len;
9325 : : }
9326 : :
9327 : : /**
9328 : : * Parse queue field for RSS action.
9329 : : *
9330 : : * Valid tokens are queue indices and the "end" token.
9331 : : */
9332 : : static int
9333 : 0 : parse_vc_action_rss_queue(struct context *ctx, const struct token *token,
9334 : : const char *str, unsigned int len,
9335 : : void *buf, unsigned int size)
9336 : : {
9337 : : static const enum index next[] = NEXT_ENTRY(ACTION_RSS_QUEUE);
9338 : : struct action_rss_data *action_rss_data;
9339 : : const struct arg *arg;
9340 : : int ret;
9341 : : int i;
9342 : :
9343 : : (void)token;
9344 : : (void)buf;
9345 : : (void)size;
9346 : 0 : if (ctx->curr != ACTION_RSS_QUEUE)
9347 : : return -1;
9348 : 0 : i = ctx->objdata >> 16;
9349 : 0 : if (!strcmp_partial("end", str, len)) {
9350 : 0 : ctx->objdata &= 0xffff;
9351 : 0 : goto end;
9352 : : }
9353 : 0 : if (i >= ACTION_RSS_QUEUE_NUM)
9354 : : return -1;
9355 : 0 : arg = ARGS_ENTRY_ARB(offsetof(struct action_rss_data, queue) +
9356 : : i * sizeof(action_rss_data->queue[i]),
9357 : : sizeof(action_rss_data->queue[i]));
9358 : : if (push_args(ctx, arg))
9359 : : return -1;
9360 : 0 : ret = parse_int(ctx, token, str, len, NULL, 0);
9361 : 0 : if (ret < 0) {
9362 : : pop_args(ctx);
9363 : 0 : return -1;
9364 : : }
9365 : 0 : ++i;
9366 : 0 : ctx->objdata = i << 16 | (ctx->objdata & 0xffff);
9367 : : /* Repeat token. */
9368 : 0 : if (ctx->next_num == RTE_DIM(ctx->next))
9369 : : return -1;
9370 : 0 : ctx->next[ctx->next_num++] = next;
9371 : 0 : end:
9372 : 0 : if (!ctx->object)
9373 : 0 : return len;
9374 : : action_rss_data = ctx->object;
9375 : 0 : action_rss_data->conf.queue_num = i;
9376 : 0 : action_rss_data->conf.queue = i ? action_rss_data->queue : NULL;
9377 : 0 : return len;
9378 : : }
9379 : :
9380 : : /** Setup VXLAN encap configuration. */
9381 : : static int
9382 : 0 : parse_setup_vxlan_encap_data(struct action_vxlan_encap_data *action_vxlan_encap_data)
9383 : : {
9384 : : /* Set up default configuration. */
9385 : 0 : *action_vxlan_encap_data = (struct action_vxlan_encap_data){
9386 : : .conf = (struct rte_flow_action_vxlan_encap){
9387 : 0 : .definition = action_vxlan_encap_data->items,
9388 : : },
9389 : : .items = {
9390 : : {
9391 : : .type = RTE_FLOW_ITEM_TYPE_ETH,
9392 : 0 : .spec = &action_vxlan_encap_data->item_eth,
9393 : : .mask = &rte_flow_item_eth_mask,
9394 : : },
9395 : : {
9396 : : .type = RTE_FLOW_ITEM_TYPE_VLAN,
9397 : 0 : .spec = &action_vxlan_encap_data->item_vlan,
9398 : : .mask = &rte_flow_item_vlan_mask,
9399 : : },
9400 : : {
9401 : : .type = RTE_FLOW_ITEM_TYPE_IPV4,
9402 : 0 : .spec = &action_vxlan_encap_data->item_ipv4,
9403 : : .mask = &rte_flow_item_ipv4_mask,
9404 : : },
9405 : : {
9406 : : .type = RTE_FLOW_ITEM_TYPE_UDP,
9407 : 0 : .spec = &action_vxlan_encap_data->item_udp,
9408 : : .mask = &rte_flow_item_udp_mask,
9409 : : },
9410 : : {
9411 : : .type = RTE_FLOW_ITEM_TYPE_VXLAN,
9412 : 0 : .spec = &action_vxlan_encap_data->item_vxlan,
9413 : : .mask = &rte_flow_item_vxlan_mask,
9414 : : },
9415 : : {
9416 : : .type = RTE_FLOW_ITEM_TYPE_END,
9417 : : },
9418 : : },
9419 : : .item_eth.hdr.ether_type = 0,
9420 : : .item_vlan = {
9421 : 0 : .hdr.vlan_tci = vxlan_encap_conf.vlan_tci,
9422 : : .hdr.eth_proto = 0,
9423 : : },
9424 : : .item_ipv4.hdr = {
9425 : 0 : .src_addr = vxlan_encap_conf.ipv4_src,
9426 : 0 : .dst_addr = vxlan_encap_conf.ipv4_dst,
9427 : : },
9428 : : .item_udp.hdr = {
9429 : 0 : .src_port = vxlan_encap_conf.udp_src,
9430 : 0 : .dst_port = vxlan_encap_conf.udp_dst,
9431 : : },
9432 : : .item_vxlan.hdr.flags = 0,
9433 : : };
9434 : 0 : memcpy(action_vxlan_encap_data->item_eth.hdr.dst_addr.addr_bytes,
9435 : : vxlan_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
9436 : 0 : memcpy(action_vxlan_encap_data->item_eth.hdr.src_addr.addr_bytes,
9437 : : vxlan_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
9438 : 0 : if (!vxlan_encap_conf.select_ipv4) {
9439 : 0 : memcpy(&action_vxlan_encap_data->item_ipv6.hdr.src_addr,
9440 : : &vxlan_encap_conf.ipv6_src,
9441 : : sizeof(vxlan_encap_conf.ipv6_src));
9442 : 0 : memcpy(&action_vxlan_encap_data->item_ipv6.hdr.dst_addr,
9443 : : &vxlan_encap_conf.ipv6_dst,
9444 : : sizeof(vxlan_encap_conf.ipv6_dst));
9445 : 0 : action_vxlan_encap_data->items[2] = (struct rte_flow_item){
9446 : : .type = RTE_FLOW_ITEM_TYPE_IPV6,
9447 : 0 : .spec = &action_vxlan_encap_data->item_ipv6,
9448 : : .mask = &rte_flow_item_ipv6_mask,
9449 : : };
9450 : : }
9451 : 0 : if (!vxlan_encap_conf.select_vlan)
9452 : 0 : action_vxlan_encap_data->items[1].type =
9453 : : RTE_FLOW_ITEM_TYPE_VOID;
9454 : 0 : if (vxlan_encap_conf.select_tos_ttl) {
9455 : 0 : if (vxlan_encap_conf.select_ipv4) {
9456 : : static struct rte_flow_item_ipv4 ipv4_mask_tos;
9457 : :
9458 : : memcpy(&ipv4_mask_tos, &rte_flow_item_ipv4_mask,
9459 : : sizeof(ipv4_mask_tos));
9460 : 0 : ipv4_mask_tos.hdr.type_of_service = 0xff;
9461 : 0 : ipv4_mask_tos.hdr.time_to_live = 0xff;
9462 : 0 : action_vxlan_encap_data->item_ipv4.hdr.type_of_service =
9463 : 0 : vxlan_encap_conf.ip_tos;
9464 : 0 : action_vxlan_encap_data->item_ipv4.hdr.time_to_live =
9465 : 0 : vxlan_encap_conf.ip_ttl;
9466 : 0 : action_vxlan_encap_data->items[2].mask =
9467 : : &ipv4_mask_tos;
9468 : : } else {
9469 : : static struct rte_flow_item_ipv6 ipv6_mask_tos;
9470 : :
9471 : : memcpy(&ipv6_mask_tos, &rte_flow_item_ipv6_mask,
9472 : : sizeof(ipv6_mask_tos));
9473 : 0 : ipv6_mask_tos.hdr.vtc_flow |=
9474 : : RTE_BE32(0xfful << RTE_IPV6_HDR_TC_SHIFT);
9475 : 0 : ipv6_mask_tos.hdr.hop_limits = 0xff;
9476 : 0 : action_vxlan_encap_data->item_ipv6.hdr.vtc_flow |=
9477 : 0 : rte_cpu_to_be_32
9478 : : ((uint32_t)vxlan_encap_conf.ip_tos <<
9479 : : RTE_IPV6_HDR_TC_SHIFT);
9480 : 0 : action_vxlan_encap_data->item_ipv6.hdr.hop_limits =
9481 : 0 : vxlan_encap_conf.ip_ttl;
9482 : 0 : action_vxlan_encap_data->items[2].mask =
9483 : : &ipv6_mask_tos;
9484 : : }
9485 : : }
9486 : 0 : memcpy(action_vxlan_encap_data->item_vxlan.hdr.vni, vxlan_encap_conf.vni,
9487 : : RTE_DIM(vxlan_encap_conf.vni));
9488 : 0 : return 0;
9489 : : }
9490 : :
9491 : : /** Parse VXLAN encap action. */
9492 : : static int
9493 : 0 : parse_vc_action_vxlan_encap(struct context *ctx, const struct token *token,
9494 : : const char *str, unsigned int len,
9495 : : void *buf, unsigned int size)
9496 : : {
9497 : : struct buffer *out = buf;
9498 : : struct rte_flow_action *action;
9499 : : struct action_vxlan_encap_data *action_vxlan_encap_data;
9500 : : int ret;
9501 : :
9502 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
9503 : 0 : if (ret < 0)
9504 : : return ret;
9505 : : /* Nothing else to do if there is no buffer. */
9506 : 0 : if (!out)
9507 : : return ret;
9508 : 0 : if (!out->args.vc.actions_n)
9509 : : return -1;
9510 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
9511 : : /* Point to selected object. */
9512 : 0 : ctx->object = out->args.vc.data;
9513 : 0 : ctx->objmask = NULL;
9514 : : action_vxlan_encap_data = ctx->object;
9515 : 0 : parse_setup_vxlan_encap_data(action_vxlan_encap_data);
9516 : 0 : action->conf = &action_vxlan_encap_data->conf;
9517 : 0 : return ret;
9518 : : }
9519 : :
9520 : : /** Setup NVGRE encap configuration. */
9521 : : static int
9522 : 0 : parse_setup_nvgre_encap_data(struct action_nvgre_encap_data *action_nvgre_encap_data)
9523 : : {
9524 : : /* Set up default configuration. */
9525 : 0 : *action_nvgre_encap_data = (struct action_nvgre_encap_data){
9526 : : .conf = (struct rte_flow_action_nvgre_encap){
9527 : 0 : .definition = action_nvgre_encap_data->items,
9528 : : },
9529 : : .items = {
9530 : : {
9531 : : .type = RTE_FLOW_ITEM_TYPE_ETH,
9532 : 0 : .spec = &action_nvgre_encap_data->item_eth,
9533 : : .mask = &rte_flow_item_eth_mask,
9534 : : },
9535 : : {
9536 : : .type = RTE_FLOW_ITEM_TYPE_VLAN,
9537 : 0 : .spec = &action_nvgre_encap_data->item_vlan,
9538 : : .mask = &rte_flow_item_vlan_mask,
9539 : : },
9540 : : {
9541 : : .type = RTE_FLOW_ITEM_TYPE_IPV4,
9542 : 0 : .spec = &action_nvgre_encap_data->item_ipv4,
9543 : : .mask = &rte_flow_item_ipv4_mask,
9544 : : },
9545 : : {
9546 : : .type = RTE_FLOW_ITEM_TYPE_NVGRE,
9547 : 0 : .spec = &action_nvgre_encap_data->item_nvgre,
9548 : : .mask = &rte_flow_item_nvgre_mask,
9549 : : },
9550 : : {
9551 : : .type = RTE_FLOW_ITEM_TYPE_END,
9552 : : },
9553 : : },
9554 : : .item_eth.hdr.ether_type = 0,
9555 : : .item_vlan = {
9556 : 0 : .hdr.vlan_tci = nvgre_encap_conf.vlan_tci,
9557 : : .hdr.eth_proto = 0,
9558 : : },
9559 : : .item_ipv4.hdr = {
9560 : 0 : .src_addr = nvgre_encap_conf.ipv4_src,
9561 : 0 : .dst_addr = nvgre_encap_conf.ipv4_dst,
9562 : : },
9563 : : .item_nvgre.c_k_s_rsvd0_ver = RTE_BE16(0x2000),
9564 : : .item_nvgre.protocol = RTE_BE16(RTE_ETHER_TYPE_TEB),
9565 : : .item_nvgre.flow_id = 0,
9566 : : };
9567 : 0 : memcpy(action_nvgre_encap_data->item_eth.hdr.dst_addr.addr_bytes,
9568 : : nvgre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
9569 : 0 : memcpy(action_nvgre_encap_data->item_eth.hdr.src_addr.addr_bytes,
9570 : : nvgre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
9571 : 0 : if (!nvgre_encap_conf.select_ipv4) {
9572 : 0 : memcpy(&action_nvgre_encap_data->item_ipv6.hdr.src_addr,
9573 : : &nvgre_encap_conf.ipv6_src,
9574 : : sizeof(nvgre_encap_conf.ipv6_src));
9575 : 0 : memcpy(&action_nvgre_encap_data->item_ipv6.hdr.dst_addr,
9576 : : &nvgre_encap_conf.ipv6_dst,
9577 : : sizeof(nvgre_encap_conf.ipv6_dst));
9578 : 0 : action_nvgre_encap_data->items[2] = (struct rte_flow_item){
9579 : : .type = RTE_FLOW_ITEM_TYPE_IPV6,
9580 : 0 : .spec = &action_nvgre_encap_data->item_ipv6,
9581 : : .mask = &rte_flow_item_ipv6_mask,
9582 : : };
9583 : : }
9584 : 0 : if (!nvgre_encap_conf.select_vlan)
9585 : 0 : action_nvgre_encap_data->items[1].type =
9586 : : RTE_FLOW_ITEM_TYPE_VOID;
9587 : 0 : memcpy(action_nvgre_encap_data->item_nvgre.tni, nvgre_encap_conf.tni,
9588 : : RTE_DIM(nvgre_encap_conf.tni));
9589 : 0 : return 0;
9590 : : }
9591 : :
9592 : : /** Parse NVGRE encap action. */
9593 : : static int
9594 : 0 : parse_vc_action_nvgre_encap(struct context *ctx, const struct token *token,
9595 : : const char *str, unsigned int len,
9596 : : void *buf, unsigned int size)
9597 : : {
9598 : : struct buffer *out = buf;
9599 : : struct rte_flow_action *action;
9600 : : struct action_nvgre_encap_data *action_nvgre_encap_data;
9601 : : int ret;
9602 : :
9603 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
9604 : 0 : if (ret < 0)
9605 : : return ret;
9606 : : /* Nothing else to do if there is no buffer. */
9607 : 0 : if (!out)
9608 : : return ret;
9609 : 0 : if (!out->args.vc.actions_n)
9610 : : return -1;
9611 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
9612 : : /* Point to selected object. */
9613 : 0 : ctx->object = out->args.vc.data;
9614 : 0 : ctx->objmask = NULL;
9615 : : action_nvgre_encap_data = ctx->object;
9616 : 0 : parse_setup_nvgre_encap_data(action_nvgre_encap_data);
9617 : 0 : action->conf = &action_nvgre_encap_data->conf;
9618 : 0 : return ret;
9619 : : }
9620 : :
9621 : : /** Parse l2 encap action. */
9622 : : static int
9623 : 0 : parse_vc_action_l2_encap(struct context *ctx, const struct token *token,
9624 : : const char *str, unsigned int len,
9625 : : void *buf, unsigned int size)
9626 : : {
9627 : : struct buffer *out = buf;
9628 : : struct rte_flow_action *action;
9629 : : struct action_raw_encap_data *action_encap_data;
9630 : 0 : struct rte_flow_item_eth eth = { .hdr.ether_type = 0, };
9631 : 0 : struct rte_flow_item_vlan vlan = {
9632 : 0 : .hdr.vlan_tci = mplsoudp_encap_conf.vlan_tci,
9633 : : .hdr.eth_proto = 0,
9634 : : };
9635 : : uint8_t *header;
9636 : : int ret;
9637 : :
9638 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
9639 : 0 : if (ret < 0)
9640 : : return ret;
9641 : : /* Nothing else to do if there is no buffer. */
9642 : 0 : if (!out)
9643 : : return ret;
9644 : 0 : if (!out->args.vc.actions_n)
9645 : : return -1;
9646 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
9647 : : /* Point to selected object. */
9648 : 0 : ctx->object = out->args.vc.data;
9649 : 0 : ctx->objmask = NULL;
9650 : : /* Copy the headers to the buffer. */
9651 : : action_encap_data = ctx->object;
9652 : 0 : *action_encap_data = (struct action_raw_encap_data) {
9653 : : .conf = (struct rte_flow_action_raw_encap){
9654 : 0 : .data = action_encap_data->data,
9655 : : },
9656 : : .data = {},
9657 : : };
9658 : : header = action_encap_data->data;
9659 : 0 : if (l2_encap_conf.select_vlan)
9660 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
9661 : 0 : else if (l2_encap_conf.select_ipv4)
9662 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
9663 : : else
9664 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
9665 : : memcpy(eth.hdr.dst_addr.addr_bytes,
9666 : : l2_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
9667 : : memcpy(eth.hdr.src_addr.addr_bytes,
9668 : : l2_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
9669 : : memcpy(header, ð.hdr, sizeof(struct rte_ether_hdr));
9670 : 0 : header += sizeof(struct rte_ether_hdr);
9671 : 0 : if (l2_encap_conf.select_vlan) {
9672 : 0 : if (l2_encap_conf.select_ipv4)
9673 : 0 : vlan.hdr.eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
9674 : : else
9675 : 0 : vlan.hdr.eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
9676 : : memcpy(header, &vlan.hdr, sizeof(struct rte_vlan_hdr));
9677 : 0 : header += sizeof(struct rte_vlan_hdr);
9678 : : }
9679 : 0 : action_encap_data->conf.size = header -
9680 : : action_encap_data->data;
9681 : 0 : action->conf = &action_encap_data->conf;
9682 : 0 : return ret;
9683 : : }
9684 : :
9685 : : /** Parse l2 decap action. */
9686 : : static int
9687 : 0 : parse_vc_action_l2_decap(struct context *ctx, const struct token *token,
9688 : : const char *str, unsigned int len,
9689 : : void *buf, unsigned int size)
9690 : : {
9691 : : struct buffer *out = buf;
9692 : : struct rte_flow_action *action;
9693 : : struct action_raw_decap_data *action_decap_data;
9694 : 0 : struct rte_flow_item_eth eth = { .hdr.ether_type = 0, };
9695 : 0 : struct rte_flow_item_vlan vlan = {
9696 : 0 : .hdr.vlan_tci = mplsoudp_encap_conf.vlan_tci,
9697 : : .hdr.eth_proto = 0,
9698 : : };
9699 : : uint8_t *header;
9700 : : int ret;
9701 : :
9702 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
9703 : 0 : if (ret < 0)
9704 : : return ret;
9705 : : /* Nothing else to do if there is no buffer. */
9706 : 0 : if (!out)
9707 : : return ret;
9708 : 0 : if (!out->args.vc.actions_n)
9709 : : return -1;
9710 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
9711 : : /* Point to selected object. */
9712 : 0 : ctx->object = out->args.vc.data;
9713 : 0 : ctx->objmask = NULL;
9714 : : /* Copy the headers to the buffer. */
9715 : : action_decap_data = ctx->object;
9716 : 0 : *action_decap_data = (struct action_raw_decap_data) {
9717 : : .conf = (struct rte_flow_action_raw_decap){
9718 : 0 : .data = action_decap_data->data,
9719 : : },
9720 : : .data = {},
9721 : : };
9722 : : header = action_decap_data->data;
9723 : 0 : if (l2_decap_conf.select_vlan)
9724 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
9725 : : memcpy(header, ð.hdr, sizeof(struct rte_ether_hdr));
9726 : 0 : header += sizeof(struct rte_ether_hdr);
9727 : 0 : if (l2_decap_conf.select_vlan) {
9728 : : memcpy(header, &vlan.hdr, sizeof(struct rte_vlan_hdr));
9729 : 0 : header += sizeof(struct rte_vlan_hdr);
9730 : : }
9731 : 0 : action_decap_data->conf.size = header -
9732 : : action_decap_data->data;
9733 : 0 : action->conf = &action_decap_data->conf;
9734 : 0 : return ret;
9735 : : }
9736 : :
9737 : : #define ETHER_TYPE_MPLS_UNICAST 0x8847
9738 : :
9739 : : /** Parse MPLSOGRE encap action. */
9740 : : static int
9741 : 0 : parse_vc_action_mplsogre_encap(struct context *ctx, const struct token *token,
9742 : : const char *str, unsigned int len,
9743 : : void *buf, unsigned int size)
9744 : : {
9745 : : struct buffer *out = buf;
9746 : : struct rte_flow_action *action;
9747 : : struct action_raw_encap_data *action_encap_data;
9748 : 0 : struct rte_flow_item_eth eth = { .hdr.ether_type = 0, };
9749 : 0 : struct rte_flow_item_vlan vlan = {
9750 : 0 : .hdr.vlan_tci = mplsogre_encap_conf.vlan_tci,
9751 : : .hdr.eth_proto = 0,
9752 : : };
9753 : 0 : struct rte_flow_item_ipv4 ipv4 = {
9754 : : .hdr = {
9755 : 0 : .src_addr = mplsogre_encap_conf.ipv4_src,
9756 : 0 : .dst_addr = mplsogre_encap_conf.ipv4_dst,
9757 : : .next_proto_id = IPPROTO_GRE,
9758 : : .version_ihl = RTE_IPV4_VHL_DEF,
9759 : : .time_to_live = IPDEFTTL,
9760 : : },
9761 : : };
9762 : 0 : struct rte_flow_item_ipv6 ipv6 = {
9763 : : .hdr = {
9764 : : .proto = IPPROTO_GRE,
9765 : : .hop_limits = IPDEFTTL,
9766 : : },
9767 : : };
9768 : 0 : struct rte_flow_item_gre gre = {
9769 : : .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
9770 : : };
9771 : 0 : struct rte_flow_item_mpls mpls = {
9772 : : .ttl = 0,
9773 : : };
9774 : : uint8_t *header;
9775 : : int ret;
9776 : :
9777 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
9778 : 0 : if (ret < 0)
9779 : : return ret;
9780 : : /* Nothing else to do if there is no buffer. */
9781 : 0 : if (!out)
9782 : : return ret;
9783 : 0 : if (!out->args.vc.actions_n)
9784 : : return -1;
9785 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
9786 : : /* Point to selected object. */
9787 : 0 : ctx->object = out->args.vc.data;
9788 : 0 : ctx->objmask = NULL;
9789 : : /* Copy the headers to the buffer. */
9790 : : action_encap_data = ctx->object;
9791 : 0 : *action_encap_data = (struct action_raw_encap_data) {
9792 : : .conf = (struct rte_flow_action_raw_encap){
9793 : 0 : .data = action_encap_data->data,
9794 : : },
9795 : : .data = {},
9796 : : .preserve = {},
9797 : : };
9798 : : header = action_encap_data->data;
9799 : 0 : if (mplsogre_encap_conf.select_vlan)
9800 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
9801 : 0 : else if (mplsogre_encap_conf.select_ipv4)
9802 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
9803 : : else
9804 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
9805 : : memcpy(eth.hdr.dst_addr.addr_bytes,
9806 : : mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
9807 : : memcpy(eth.hdr.src_addr.addr_bytes,
9808 : : mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
9809 : : memcpy(header, ð.hdr, sizeof(struct rte_ether_hdr));
9810 : 0 : header += sizeof(struct rte_ether_hdr);
9811 : 0 : if (mplsogre_encap_conf.select_vlan) {
9812 : 0 : if (mplsogre_encap_conf.select_ipv4)
9813 : 0 : vlan.hdr.eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
9814 : : else
9815 : 0 : vlan.hdr.eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
9816 : : memcpy(header, &vlan.hdr, sizeof(struct rte_vlan_hdr));
9817 : 0 : header += sizeof(struct rte_vlan_hdr);
9818 : : }
9819 : 0 : if (mplsogre_encap_conf.select_ipv4) {
9820 : : memcpy(header, &ipv4, sizeof(ipv4));
9821 : 0 : header += sizeof(ipv4);
9822 : : } else {
9823 : : memcpy(&ipv6.hdr.src_addr,
9824 : : &mplsogre_encap_conf.ipv6_src,
9825 : : sizeof(mplsogre_encap_conf.ipv6_src));
9826 : : memcpy(&ipv6.hdr.dst_addr,
9827 : : &mplsogre_encap_conf.ipv6_dst,
9828 : : sizeof(mplsogre_encap_conf.ipv6_dst));
9829 : : memcpy(header, &ipv6, sizeof(ipv6));
9830 : 0 : header += sizeof(ipv6);
9831 : : }
9832 : : memcpy(header, &gre, sizeof(gre));
9833 : 0 : header += sizeof(gre);
9834 : : memcpy(mpls.label_tc_s, mplsogre_encap_conf.label,
9835 : : RTE_DIM(mplsogre_encap_conf.label));
9836 : 0 : mpls.label_tc_s[2] |= 0x1;
9837 : : memcpy(header, &mpls, sizeof(mpls));
9838 : 0 : header += sizeof(mpls);
9839 : 0 : action_encap_data->conf.size = header -
9840 : : action_encap_data->data;
9841 : 0 : action->conf = &action_encap_data->conf;
9842 : 0 : return ret;
9843 : : }
9844 : :
9845 : : /** Parse MPLSOGRE decap action. */
9846 : : static int
9847 : 0 : parse_vc_action_mplsogre_decap(struct context *ctx, const struct token *token,
9848 : : const char *str, unsigned int len,
9849 : : void *buf, unsigned int size)
9850 : : {
9851 : : struct buffer *out = buf;
9852 : : struct rte_flow_action *action;
9853 : : struct action_raw_decap_data *action_decap_data;
9854 : 0 : struct rte_flow_item_eth eth = { .hdr.ether_type = 0, };
9855 : 0 : struct rte_flow_item_vlan vlan = {.hdr.vlan_tci = 0};
9856 : 0 : struct rte_flow_item_ipv4 ipv4 = {
9857 : : .hdr = {
9858 : : .next_proto_id = IPPROTO_GRE,
9859 : : },
9860 : : };
9861 : 0 : struct rte_flow_item_ipv6 ipv6 = {
9862 : : .hdr = {
9863 : : .proto = IPPROTO_GRE,
9864 : : },
9865 : : };
9866 : 0 : struct rte_flow_item_gre gre = {
9867 : : .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
9868 : : };
9869 : : struct rte_flow_item_mpls mpls;
9870 : : uint8_t *header;
9871 : : int ret;
9872 : :
9873 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
9874 : 0 : if (ret < 0)
9875 : : return ret;
9876 : : /* Nothing else to do if there is no buffer. */
9877 : 0 : if (!out)
9878 : : return ret;
9879 : 0 : if (!out->args.vc.actions_n)
9880 : : return -1;
9881 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
9882 : : /* Point to selected object. */
9883 : 0 : ctx->object = out->args.vc.data;
9884 : 0 : ctx->objmask = NULL;
9885 : : /* Copy the headers to the buffer. */
9886 : : action_decap_data = ctx->object;
9887 : 0 : *action_decap_data = (struct action_raw_decap_data) {
9888 : : .conf = (struct rte_flow_action_raw_decap){
9889 : 0 : .data = action_decap_data->data,
9890 : : },
9891 : : .data = {},
9892 : : };
9893 : : header = action_decap_data->data;
9894 : 0 : if (mplsogre_decap_conf.select_vlan)
9895 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
9896 : 0 : else if (mplsogre_encap_conf.select_ipv4)
9897 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
9898 : : else
9899 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
9900 : : memcpy(eth.hdr.dst_addr.addr_bytes,
9901 : : mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
9902 : : memcpy(eth.hdr.src_addr.addr_bytes,
9903 : : mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
9904 : : memcpy(header, ð.hdr, sizeof(struct rte_ether_hdr));
9905 : 0 : header += sizeof(struct rte_ether_hdr);
9906 : 0 : if (mplsogre_encap_conf.select_vlan) {
9907 : 0 : if (mplsogre_encap_conf.select_ipv4)
9908 : 0 : vlan.hdr.eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
9909 : : else
9910 : 0 : vlan.hdr.eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
9911 : : memcpy(header, &vlan.hdr, sizeof(struct rte_vlan_hdr));
9912 : 0 : header += sizeof(struct rte_vlan_hdr);
9913 : : }
9914 : 0 : if (mplsogre_encap_conf.select_ipv4) {
9915 : : memcpy(header, &ipv4, sizeof(ipv4));
9916 : 0 : header += sizeof(ipv4);
9917 : : } else {
9918 : : memcpy(header, &ipv6, sizeof(ipv6));
9919 : 0 : header += sizeof(ipv6);
9920 : : }
9921 : : memcpy(header, &gre, sizeof(gre));
9922 : 0 : header += sizeof(gre);
9923 : : memset(&mpls, 0, sizeof(mpls));
9924 : : memcpy(header, &mpls, sizeof(mpls));
9925 : 0 : header += sizeof(mpls);
9926 : 0 : action_decap_data->conf.size = header -
9927 : : action_decap_data->data;
9928 : 0 : action->conf = &action_decap_data->conf;
9929 : 0 : return ret;
9930 : : }
9931 : :
9932 : : /** Parse MPLSOUDP encap action. */
9933 : : static int
9934 : 0 : parse_vc_action_mplsoudp_encap(struct context *ctx, const struct token *token,
9935 : : const char *str, unsigned int len,
9936 : : void *buf, unsigned int size)
9937 : : {
9938 : : struct buffer *out = buf;
9939 : : struct rte_flow_action *action;
9940 : : struct action_raw_encap_data *action_encap_data;
9941 : 0 : struct rte_flow_item_eth eth = { .hdr.ether_type = 0, };
9942 : 0 : struct rte_flow_item_vlan vlan = {
9943 : 0 : .hdr.vlan_tci = mplsoudp_encap_conf.vlan_tci,
9944 : : .hdr.eth_proto = 0,
9945 : : };
9946 : 0 : struct rte_flow_item_ipv4 ipv4 = {
9947 : : .hdr = {
9948 : 0 : .src_addr = mplsoudp_encap_conf.ipv4_src,
9949 : 0 : .dst_addr = mplsoudp_encap_conf.ipv4_dst,
9950 : : .next_proto_id = IPPROTO_UDP,
9951 : : .version_ihl = RTE_IPV4_VHL_DEF,
9952 : : .time_to_live = IPDEFTTL,
9953 : : },
9954 : : };
9955 : 0 : struct rte_flow_item_ipv6 ipv6 = {
9956 : : .hdr = {
9957 : : .proto = IPPROTO_UDP,
9958 : : .hop_limits = IPDEFTTL,
9959 : : },
9960 : : };
9961 : 0 : struct rte_flow_item_udp udp = {
9962 : : .hdr = {
9963 : 0 : .src_port = mplsoudp_encap_conf.udp_src,
9964 : 0 : .dst_port = mplsoudp_encap_conf.udp_dst,
9965 : : },
9966 : : };
9967 : : struct rte_flow_item_mpls mpls;
9968 : : uint8_t *header;
9969 : : int ret;
9970 : :
9971 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
9972 : 0 : if (ret < 0)
9973 : : return ret;
9974 : : /* Nothing else to do if there is no buffer. */
9975 : 0 : if (!out)
9976 : : return ret;
9977 : 0 : if (!out->args.vc.actions_n)
9978 : : return -1;
9979 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
9980 : : /* Point to selected object. */
9981 : 0 : ctx->object = out->args.vc.data;
9982 : 0 : ctx->objmask = NULL;
9983 : : /* Copy the headers to the buffer. */
9984 : : action_encap_data = ctx->object;
9985 : 0 : *action_encap_data = (struct action_raw_encap_data) {
9986 : : .conf = (struct rte_flow_action_raw_encap){
9987 : 0 : .data = action_encap_data->data,
9988 : : },
9989 : : .data = {},
9990 : : .preserve = {},
9991 : : };
9992 : : header = action_encap_data->data;
9993 : 0 : if (mplsoudp_encap_conf.select_vlan)
9994 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
9995 : 0 : else if (mplsoudp_encap_conf.select_ipv4)
9996 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
9997 : : else
9998 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
9999 : : memcpy(eth.hdr.dst_addr.addr_bytes,
10000 : : mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
10001 : : memcpy(eth.hdr.src_addr.addr_bytes,
10002 : : mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
10003 : : memcpy(header, ð.hdr, sizeof(struct rte_ether_hdr));
10004 : 0 : header += sizeof(struct rte_ether_hdr);
10005 : 0 : if (mplsoudp_encap_conf.select_vlan) {
10006 : 0 : if (mplsoudp_encap_conf.select_ipv4)
10007 : 0 : vlan.hdr.eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
10008 : : else
10009 : 0 : vlan.hdr.eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
10010 : : memcpy(header, &vlan.hdr, sizeof(struct rte_vlan_hdr));
10011 : 0 : header += sizeof(struct rte_vlan_hdr);
10012 : : }
10013 : 0 : if (mplsoudp_encap_conf.select_ipv4) {
10014 : : memcpy(header, &ipv4, sizeof(ipv4));
10015 : 0 : header += sizeof(ipv4);
10016 : : } else {
10017 : : memcpy(&ipv6.hdr.src_addr,
10018 : : &mplsoudp_encap_conf.ipv6_src,
10019 : : sizeof(mplsoudp_encap_conf.ipv6_src));
10020 : : memcpy(&ipv6.hdr.dst_addr,
10021 : : &mplsoudp_encap_conf.ipv6_dst,
10022 : : sizeof(mplsoudp_encap_conf.ipv6_dst));
10023 : : memcpy(header, &ipv6, sizeof(ipv6));
10024 : 0 : header += sizeof(ipv6);
10025 : : }
10026 : : memcpy(header, &udp, sizeof(udp));
10027 : 0 : header += sizeof(udp);
10028 : : memcpy(mpls.label_tc_s, mplsoudp_encap_conf.label,
10029 : : RTE_DIM(mplsoudp_encap_conf.label));
10030 : 0 : mpls.label_tc_s[2] |= 0x1;
10031 : : memcpy(header, &mpls, sizeof(mpls));
10032 : 0 : header += sizeof(mpls);
10033 : 0 : action_encap_data->conf.size = header -
10034 : : action_encap_data->data;
10035 : 0 : action->conf = &action_encap_data->conf;
10036 : 0 : return ret;
10037 : : }
10038 : :
10039 : : /** Parse MPLSOUDP decap action. */
10040 : : static int
10041 : 0 : parse_vc_action_mplsoudp_decap(struct context *ctx, const struct token *token,
10042 : : const char *str, unsigned int len,
10043 : : void *buf, unsigned int size)
10044 : : {
10045 : : struct buffer *out = buf;
10046 : : struct rte_flow_action *action;
10047 : : struct action_raw_decap_data *action_decap_data;
10048 : 0 : struct rte_flow_item_eth eth = { .hdr.ether_type = 0, };
10049 : 0 : struct rte_flow_item_vlan vlan = {.hdr.vlan_tci = 0};
10050 : 0 : struct rte_flow_item_ipv4 ipv4 = {
10051 : : .hdr = {
10052 : : .next_proto_id = IPPROTO_UDP,
10053 : : },
10054 : : };
10055 : 0 : struct rte_flow_item_ipv6 ipv6 = {
10056 : : .hdr = {
10057 : : .proto = IPPROTO_UDP,
10058 : : },
10059 : : };
10060 : 0 : struct rte_flow_item_udp udp = {
10061 : : .hdr = {
10062 : : .dst_port = rte_cpu_to_be_16(6635),
10063 : : },
10064 : : };
10065 : : struct rte_flow_item_mpls mpls;
10066 : : uint8_t *header;
10067 : : int ret;
10068 : :
10069 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
10070 : 0 : if (ret < 0)
10071 : : return ret;
10072 : : /* Nothing else to do if there is no buffer. */
10073 : 0 : if (!out)
10074 : : return ret;
10075 : 0 : if (!out->args.vc.actions_n)
10076 : : return -1;
10077 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
10078 : : /* Point to selected object. */
10079 : 0 : ctx->object = out->args.vc.data;
10080 : 0 : ctx->objmask = NULL;
10081 : : /* Copy the headers to the buffer. */
10082 : : action_decap_data = ctx->object;
10083 : 0 : *action_decap_data = (struct action_raw_decap_data) {
10084 : : .conf = (struct rte_flow_action_raw_decap){
10085 : 0 : .data = action_decap_data->data,
10086 : : },
10087 : : .data = {},
10088 : : };
10089 : : header = action_decap_data->data;
10090 : 0 : if (mplsoudp_decap_conf.select_vlan)
10091 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
10092 : 0 : else if (mplsoudp_encap_conf.select_ipv4)
10093 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
10094 : : else
10095 : 0 : eth.hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
10096 : : memcpy(eth.hdr.dst_addr.addr_bytes,
10097 : : mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
10098 : : memcpy(eth.hdr.src_addr.addr_bytes,
10099 : : mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
10100 : : memcpy(header, ð.hdr, sizeof(struct rte_ether_hdr));
10101 : 0 : header += sizeof(struct rte_ether_hdr);
10102 : 0 : if (mplsoudp_encap_conf.select_vlan) {
10103 : 0 : if (mplsoudp_encap_conf.select_ipv4)
10104 : 0 : vlan.hdr.eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
10105 : : else
10106 : 0 : vlan.hdr.eth_proto = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
10107 : : memcpy(header, &vlan.hdr, sizeof(struct rte_vlan_hdr));
10108 : 0 : header += sizeof(struct rte_vlan_hdr);
10109 : : }
10110 : 0 : if (mplsoudp_encap_conf.select_ipv4) {
10111 : : memcpy(header, &ipv4, sizeof(ipv4));
10112 : 0 : header += sizeof(ipv4);
10113 : : } else {
10114 : : memcpy(header, &ipv6, sizeof(ipv6));
10115 : 0 : header += sizeof(ipv6);
10116 : : }
10117 : : memcpy(header, &udp, sizeof(udp));
10118 : 0 : header += sizeof(udp);
10119 : : memset(&mpls, 0, sizeof(mpls));
10120 : : memcpy(header, &mpls, sizeof(mpls));
10121 : 0 : header += sizeof(mpls);
10122 : 0 : action_decap_data->conf.size = header -
10123 : : action_decap_data->data;
10124 : 0 : action->conf = &action_decap_data->conf;
10125 : 0 : return ret;
10126 : : }
10127 : :
10128 : : static int
10129 : 0 : parse_vc_action_raw_decap_index(struct context *ctx, const struct token *token,
10130 : : const char *str, unsigned int len, void *buf,
10131 : : unsigned int size)
10132 : : {
10133 : : struct action_raw_decap_data *action_raw_decap_data;
10134 : : struct rte_flow_action *action;
10135 : : const struct arg *arg;
10136 : : struct buffer *out = buf;
10137 : : int ret;
10138 : : uint16_t idx;
10139 : :
10140 : : RTE_SET_USED(token);
10141 : : RTE_SET_USED(buf);
10142 : : RTE_SET_USED(size);
10143 : 0 : arg = ARGS_ENTRY_ARB_BOUNDED
10144 : : (offsetof(struct action_raw_decap_data, idx),
10145 : : sizeof(((struct action_raw_decap_data *)0)->idx),
10146 : : 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
10147 : : if (push_args(ctx, arg))
10148 : : return -1;
10149 : 0 : ret = parse_int(ctx, token, str, len, NULL, 0);
10150 : 0 : if (ret < 0) {
10151 : : pop_args(ctx);
10152 : 0 : return -1;
10153 : : }
10154 : 0 : if (!ctx->object)
10155 : 0 : return len;
10156 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
10157 : : action_raw_decap_data = ctx->object;
10158 : 0 : idx = action_raw_decap_data->idx;
10159 : 0 : action_raw_decap_data->conf.data = raw_decap_confs[idx].data;
10160 : 0 : action_raw_decap_data->conf.size = raw_decap_confs[idx].size;
10161 : 0 : action->conf = &action_raw_decap_data->conf;
10162 : 0 : return len;
10163 : : }
10164 : :
10165 : :
10166 : : static int
10167 : 0 : parse_vc_action_raw_encap_index(struct context *ctx, const struct token *token,
10168 : : const char *str, unsigned int len, void *buf,
10169 : : unsigned int size)
10170 : : {
10171 : : struct action_raw_encap_data *action_raw_encap_data;
10172 : : struct rte_flow_action *action;
10173 : : const struct arg *arg;
10174 : : struct buffer *out = buf;
10175 : : int ret;
10176 : : uint16_t idx;
10177 : :
10178 : : RTE_SET_USED(token);
10179 : : RTE_SET_USED(buf);
10180 : : RTE_SET_USED(size);
10181 : 0 : if (ctx->curr != ACTION_RAW_ENCAP_INDEX_VALUE)
10182 : : return -1;
10183 : 0 : arg = ARGS_ENTRY_ARB_BOUNDED
10184 : : (offsetof(struct action_raw_encap_data, idx),
10185 : : sizeof(((struct action_raw_encap_data *)0)->idx),
10186 : : 0, RAW_ENCAP_CONFS_MAX_NUM - 1);
10187 : : if (push_args(ctx, arg))
10188 : : return -1;
10189 : 0 : ret = parse_int(ctx, token, str, len, NULL, 0);
10190 : 0 : if (ret < 0) {
10191 : : pop_args(ctx);
10192 : 0 : return -1;
10193 : : }
10194 : 0 : if (!ctx->object)
10195 : 0 : return len;
10196 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
10197 : : action_raw_encap_data = ctx->object;
10198 : 0 : idx = action_raw_encap_data->idx;
10199 : 0 : action_raw_encap_data->conf.data = raw_encap_confs[idx].data;
10200 : 0 : action_raw_encap_data->conf.size = raw_encap_confs[idx].size;
10201 : 0 : action_raw_encap_data->conf.preserve = NULL;
10202 : 0 : action->conf = &action_raw_encap_data->conf;
10203 : 0 : return len;
10204 : : }
10205 : :
10206 : : static int
10207 : 0 : parse_vc_action_raw_encap(struct context *ctx, const struct token *token,
10208 : : const char *str, unsigned int len, void *buf,
10209 : : unsigned int size)
10210 : : {
10211 : : struct buffer *out = buf;
10212 : : int ret;
10213 : :
10214 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
10215 : 0 : if (ret < 0)
10216 : : return ret;
10217 : : /* Nothing else to do if there is no buffer. */
10218 : 0 : if (!out)
10219 : : return ret;
10220 : 0 : if (!out->args.vc.actions_n)
10221 : : return -1;
10222 : : /* Point to selected object. */
10223 : 0 : ctx->object = out->args.vc.data;
10224 : 0 : ctx->objmask = NULL;
10225 : 0 : return ret;
10226 : : }
10227 : :
10228 : : static int
10229 : 0 : parse_vc_action_raw_decap(struct context *ctx, const struct token *token,
10230 : : const char *str, unsigned int len, void *buf,
10231 : : unsigned int size)
10232 : : {
10233 : : struct buffer *out = buf;
10234 : : struct rte_flow_action *action;
10235 : : struct action_raw_decap_data *action_raw_decap_data = NULL;
10236 : : int ret;
10237 : :
10238 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
10239 : 0 : if (ret < 0)
10240 : : return ret;
10241 : : /* Nothing else to do if there is no buffer. */
10242 : 0 : if (!out)
10243 : : return ret;
10244 : 0 : if (!out->args.vc.actions_n)
10245 : : return -1;
10246 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
10247 : : /* Point to selected object. */
10248 : 0 : ctx->object = out->args.vc.data;
10249 : 0 : ctx->objmask = NULL;
10250 : : /* Copy the headers to the buffer. */
10251 : : action_raw_decap_data = ctx->object;
10252 : 0 : action_raw_decap_data->conf.data = raw_decap_confs[0].data;
10253 : 0 : action_raw_decap_data->conf.size = raw_decap_confs[0].size;
10254 : 0 : action->conf = &action_raw_decap_data->conf;
10255 : 0 : return ret;
10256 : : }
10257 : :
10258 : : static int
10259 : 0 : parse_vc_action_ipv6_ext_remove(struct context *ctx, const struct token *token,
10260 : : const char *str, unsigned int len, void *buf,
10261 : : unsigned int size)
10262 : : {
10263 : : struct buffer *out = buf;
10264 : : struct rte_flow_action *action;
10265 : : struct action_ipv6_ext_remove_data *ipv6_ext_remove_data = NULL;
10266 : : int ret;
10267 : :
10268 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
10269 : 0 : if (ret < 0)
10270 : : return ret;
10271 : : /* Nothing else to do if there is no buffer. */
10272 : 0 : if (!out)
10273 : : return ret;
10274 : 0 : if (!out->args.vc.actions_n)
10275 : : return -1;
10276 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
10277 : : /* Point to selected object. */
10278 : 0 : ctx->object = out->args.vc.data;
10279 : 0 : ctx->objmask = NULL;
10280 : : /* Copy the headers to the buffer. */
10281 : : ipv6_ext_remove_data = ctx->object;
10282 : 0 : ipv6_ext_remove_data->conf.type = ipv6_ext_remove_confs[0].type;
10283 : 0 : action->conf = &ipv6_ext_remove_data->conf;
10284 : 0 : return ret;
10285 : : }
10286 : :
10287 : : static int
10288 : 0 : parse_vc_action_ipv6_ext_remove_index(struct context *ctx, const struct token *token,
10289 : : const char *str, unsigned int len, void *buf,
10290 : : unsigned int size)
10291 : : {
10292 : : struct action_ipv6_ext_remove_data *action_ipv6_ext_remove_data;
10293 : : struct rte_flow_action *action;
10294 : : const struct arg *arg;
10295 : : struct buffer *out = buf;
10296 : : int ret;
10297 : : uint16_t idx;
10298 : :
10299 : : RTE_SET_USED(token);
10300 : : RTE_SET_USED(buf);
10301 : : RTE_SET_USED(size);
10302 : 0 : arg = ARGS_ENTRY_ARB_BOUNDED
10303 : : (offsetof(struct action_ipv6_ext_remove_data, idx),
10304 : : sizeof(((struct action_ipv6_ext_remove_data *)0)->idx),
10305 : : 0, IPV6_EXT_PUSH_CONFS_MAX_NUM - 1);
10306 : : if (push_args(ctx, arg))
10307 : : return -1;
10308 : 0 : ret = parse_int(ctx, token, str, len, NULL, 0);
10309 : 0 : if (ret < 0) {
10310 : : pop_args(ctx);
10311 : 0 : return -1;
10312 : : }
10313 : 0 : if (!ctx->object)
10314 : 0 : return len;
10315 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
10316 : : action_ipv6_ext_remove_data = ctx->object;
10317 : 0 : idx = action_ipv6_ext_remove_data->idx;
10318 : 0 : action_ipv6_ext_remove_data->conf.type = ipv6_ext_remove_confs[idx].type;
10319 : 0 : action->conf = &action_ipv6_ext_remove_data->conf;
10320 : 0 : return len;
10321 : : }
10322 : :
10323 : : static int
10324 : 0 : parse_vc_action_ipv6_ext_push(struct context *ctx, const struct token *token,
10325 : : const char *str, unsigned int len, void *buf,
10326 : : unsigned int size)
10327 : : {
10328 : : struct buffer *out = buf;
10329 : : struct rte_flow_action *action;
10330 : : struct action_ipv6_ext_push_data *ipv6_ext_push_data = NULL;
10331 : : int ret;
10332 : :
10333 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
10334 : 0 : if (ret < 0)
10335 : : return ret;
10336 : : /* Nothing else to do if there is no buffer. */
10337 : 0 : if (!out)
10338 : : return ret;
10339 : 0 : if (!out->args.vc.actions_n)
10340 : : return -1;
10341 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
10342 : : /* Point to selected object. */
10343 : 0 : ctx->object = out->args.vc.data;
10344 : 0 : ctx->objmask = NULL;
10345 : : /* Copy the headers to the buffer. */
10346 : : ipv6_ext_push_data = ctx->object;
10347 : 0 : ipv6_ext_push_data->conf.type = ipv6_ext_push_confs[0].type;
10348 : 0 : ipv6_ext_push_data->conf.data = ipv6_ext_push_confs[0].data;
10349 : 0 : ipv6_ext_push_data->conf.size = ipv6_ext_push_confs[0].size;
10350 : 0 : action->conf = &ipv6_ext_push_data->conf;
10351 : 0 : return ret;
10352 : : }
10353 : :
10354 : : static int
10355 : 0 : parse_vc_action_ipv6_ext_push_index(struct context *ctx, const struct token *token,
10356 : : const char *str, unsigned int len, void *buf,
10357 : : unsigned int size)
10358 : : {
10359 : : struct action_ipv6_ext_push_data *action_ipv6_ext_push_data;
10360 : : struct rte_flow_action *action;
10361 : : const struct arg *arg;
10362 : : struct buffer *out = buf;
10363 : : int ret;
10364 : : uint16_t idx;
10365 : :
10366 : : RTE_SET_USED(token);
10367 : : RTE_SET_USED(buf);
10368 : : RTE_SET_USED(size);
10369 : 0 : arg = ARGS_ENTRY_ARB_BOUNDED
10370 : : (offsetof(struct action_ipv6_ext_push_data, idx),
10371 : : sizeof(((struct action_ipv6_ext_push_data *)0)->idx),
10372 : : 0, IPV6_EXT_PUSH_CONFS_MAX_NUM - 1);
10373 : : if (push_args(ctx, arg))
10374 : : return -1;
10375 : 0 : ret = parse_int(ctx, token, str, len, NULL, 0);
10376 : 0 : if (ret < 0) {
10377 : : pop_args(ctx);
10378 : 0 : return -1;
10379 : : }
10380 : 0 : if (!ctx->object)
10381 : 0 : return len;
10382 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
10383 : : action_ipv6_ext_push_data = ctx->object;
10384 : 0 : idx = action_ipv6_ext_push_data->idx;
10385 : 0 : action_ipv6_ext_push_data->conf.type = ipv6_ext_push_confs[idx].type;
10386 : 0 : action_ipv6_ext_push_data->conf.size = ipv6_ext_push_confs[idx].size;
10387 : 0 : action_ipv6_ext_push_data->conf.data = ipv6_ext_push_confs[idx].data;
10388 : 0 : action->conf = &action_ipv6_ext_push_data->conf;
10389 : 0 : return len;
10390 : : }
10391 : :
10392 : : static int
10393 : 0 : parse_vc_action_set_meta(struct context *ctx, const struct token *token,
10394 : : const char *str, unsigned int len, void *buf,
10395 : : unsigned int size)
10396 : : {
10397 : : int ret;
10398 : :
10399 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
10400 : 0 : if (ret < 0)
10401 : : return ret;
10402 : 0 : ret = rte_flow_dynf_metadata_register();
10403 : 0 : if (ret < 0)
10404 : : return -1;
10405 : 0 : return len;
10406 : : }
10407 : :
10408 : : static int
10409 : 0 : parse_vc_action_sample(struct context *ctx, const struct token *token,
10410 : : const char *str, unsigned int len, void *buf,
10411 : : unsigned int size)
10412 : : {
10413 : : struct buffer *out = buf;
10414 : : struct rte_flow_action *action;
10415 : : struct action_sample_data *action_sample_data = NULL;
10416 : : static struct rte_flow_action end_action = {
10417 : : RTE_FLOW_ACTION_TYPE_END, 0
10418 : : };
10419 : : int ret;
10420 : :
10421 : 0 : ret = parse_vc(ctx, token, str, len, buf, size);
10422 : 0 : if (ret < 0)
10423 : : return ret;
10424 : : /* Nothing else to do if there is no buffer. */
10425 : 0 : if (!out)
10426 : : return ret;
10427 : 0 : if (!out->args.vc.actions_n)
10428 : : return -1;
10429 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
10430 : : /* Point to selected object. */
10431 : 0 : ctx->object = out->args.vc.data;
10432 : 0 : ctx->objmask = NULL;
10433 : : /* Copy the headers to the buffer. */
10434 : : action_sample_data = ctx->object;
10435 : 0 : action_sample_data->conf.actions = &end_action;
10436 : 0 : action->conf = &action_sample_data->conf;
10437 : 0 : return ret;
10438 : : }
10439 : :
10440 : : static int
10441 : 0 : parse_vc_action_sample_index(struct context *ctx, const struct token *token,
10442 : : const char *str, unsigned int len, void *buf,
10443 : : unsigned int size)
10444 : : {
10445 : : struct action_sample_data *action_sample_data;
10446 : : struct rte_flow_action *action;
10447 : : const struct arg *arg;
10448 : : struct buffer *out = buf;
10449 : : int ret;
10450 : : uint16_t idx;
10451 : :
10452 : : RTE_SET_USED(token);
10453 : : RTE_SET_USED(buf);
10454 : : RTE_SET_USED(size);
10455 : 0 : if (ctx->curr != ACTION_SAMPLE_INDEX_VALUE)
10456 : : return -1;
10457 : 0 : arg = ARGS_ENTRY_ARB_BOUNDED
10458 : : (offsetof(struct action_sample_data, idx),
10459 : : sizeof(((struct action_sample_data *)0)->idx),
10460 : : 0, RAW_SAMPLE_CONFS_MAX_NUM - 1);
10461 : : if (push_args(ctx, arg))
10462 : : return -1;
10463 : 0 : ret = parse_int(ctx, token, str, len, NULL, 0);
10464 : 0 : if (ret < 0) {
10465 : : pop_args(ctx);
10466 : 0 : return -1;
10467 : : }
10468 : 0 : if (!ctx->object)
10469 : 0 : return len;
10470 : 0 : action = &out->args.vc.actions[out->args.vc.actions_n - 1];
10471 : : action_sample_data = ctx->object;
10472 : 0 : idx = action_sample_data->idx;
10473 : 0 : action_sample_data->conf.actions = raw_sample_confs[idx].data;
10474 : 0 : action->conf = &action_sample_data->conf;
10475 : 0 : return len;
10476 : : }
10477 : :
10478 : : /** Parse operation for modify_field command. */
10479 : : static int
10480 : 0 : parse_vc_modify_field_op(struct context *ctx, const struct token *token,
10481 : : const char *str, unsigned int len, void *buf,
10482 : : unsigned int size)
10483 : : {
10484 : : struct rte_flow_action_modify_field *action_modify_field;
10485 : : unsigned int i;
10486 : :
10487 : : (void)token;
10488 : : (void)buf;
10489 : : (void)size;
10490 : 0 : if (ctx->curr != ACTION_MODIFY_FIELD_OP_VALUE)
10491 : : return -1;
10492 : 0 : for (i = 0; modify_field_ops[i]; ++i)
10493 : 0 : if (!strcmp_partial(modify_field_ops[i], str, len))
10494 : : break;
10495 : 0 : if (!modify_field_ops[i])
10496 : : return -1;
10497 : 0 : if (!ctx->object)
10498 : 0 : return len;
10499 : : action_modify_field = ctx->object;
10500 : 0 : action_modify_field->operation = (enum rte_flow_modify_op)i;
10501 : 0 : return len;
10502 : : }
10503 : :
10504 : : /** Parse id for modify_field command. */
10505 : : static int
10506 : 0 : parse_vc_modify_field_id(struct context *ctx, const struct token *token,
10507 : : const char *str, unsigned int len, void *buf,
10508 : : unsigned int size)
10509 : : {
10510 : : struct rte_flow_action_modify_field *action_modify_field;
10511 : : unsigned int i;
10512 : :
10513 : : (void)token;
10514 : : (void)buf;
10515 : : (void)size;
10516 : 0 : if (ctx->curr != ACTION_MODIFY_FIELD_DST_TYPE_VALUE &&
10517 : : ctx->curr != ACTION_MODIFY_FIELD_SRC_TYPE_VALUE)
10518 : : return -1;
10519 : 0 : for (i = 0; flow_field_ids[i]; ++i)
10520 : 0 : if (!strcmp_partial(flow_field_ids[i], str, len))
10521 : : break;
10522 : 0 : if (!flow_field_ids[i])
10523 : : return -1;
10524 : 0 : if (!ctx->object)
10525 : 0 : return len;
10526 : : action_modify_field = ctx->object;
10527 : 0 : if (ctx->curr == ACTION_MODIFY_FIELD_DST_TYPE_VALUE)
10528 : 0 : action_modify_field->dst.field = (enum rte_flow_field_id)i;
10529 : : else
10530 : 0 : action_modify_field->src.field = (enum rte_flow_field_id)i;
10531 : 0 : return len;
10532 : : }
10533 : :
10534 : : /** Parse level for modify_field command. */
10535 : : static int
10536 : 0 : parse_vc_modify_field_level(struct context *ctx, const struct token *token,
10537 : : const char *str, unsigned int len, void *buf,
10538 : : unsigned int size)
10539 : : {
10540 : : struct rte_flow_action_modify_field *action;
10541 : : struct flex_item *fp = NULL;
10542 : : uint32_t val;
10543 : : struct buffer *out = buf;
10544 : : char *end;
10545 : :
10546 : : (void)token;
10547 : : (void)size;
10548 : 0 : if (ctx->curr != ACTION_MODIFY_FIELD_DST_LEVEL_VALUE &&
10549 : : ctx->curr != ACTION_MODIFY_FIELD_SRC_LEVEL_VALUE)
10550 : : return -1;
10551 : 0 : if (!ctx->object)
10552 : 0 : return len;
10553 : : action = ctx->object;
10554 : 0 : errno = 0;
10555 : 0 : val = strtoumax(str, &end, 0);
10556 : 0 : if (errno || (size_t)(end - str) != len)
10557 : : return -1;
10558 : : /* No need to validate action template mask value */
10559 : 0 : if (out->args.vc.masks) {
10560 : 0 : if (ctx->curr == ACTION_MODIFY_FIELD_DST_LEVEL_VALUE)
10561 : 0 : action->dst.level = val;
10562 : : else
10563 : 0 : action->src.level = val;
10564 : 0 : return len;
10565 : : }
10566 : 0 : if ((ctx->curr == ACTION_MODIFY_FIELD_DST_LEVEL_VALUE &&
10567 : 0 : action->dst.field == RTE_FLOW_FIELD_FLEX_ITEM) ||
10568 : 0 : (ctx->curr == ACTION_MODIFY_FIELD_SRC_LEVEL_VALUE &&
10569 : 0 : action->src.field == RTE_FLOW_FIELD_FLEX_ITEM)) {
10570 : 0 : if (val >= FLEX_MAX_PARSERS_NUM) {
10571 : : printf("Bad flex item handle\n");
10572 : 0 : return -1;
10573 : : }
10574 : 0 : fp = flex_items[ctx->port][val];
10575 : 0 : if (!fp) {
10576 : : printf("Bad flex item handle\n");
10577 : 0 : return -1;
10578 : : }
10579 : : }
10580 : 0 : if (ctx->curr == ACTION_MODIFY_FIELD_DST_LEVEL_VALUE) {
10581 : 0 : if (action->dst.field != RTE_FLOW_FIELD_FLEX_ITEM)
10582 : 0 : action->dst.level = val;
10583 : : else
10584 : 0 : action->dst.flex_handle = fp->flex_handle;
10585 : 0 : } else if (ctx->curr == ACTION_MODIFY_FIELD_SRC_LEVEL_VALUE) {
10586 : 0 : if (action->src.field != RTE_FLOW_FIELD_FLEX_ITEM)
10587 : 0 : action->src.level = val;
10588 : : else
10589 : 0 : action->src.flex_handle = fp->flex_handle;
10590 : : }
10591 : 0 : return len;
10592 : : }
10593 : :
10594 : : /** Parse the conntrack update, not a rte_flow_action. */
10595 : : static int
10596 : 0 : parse_vc_action_conntrack_update(struct context *ctx, const struct token *token,
10597 : : const char *str, unsigned int len, void *buf,
10598 : : unsigned int size)
10599 : : {
10600 : : struct buffer *out = buf;
10601 : : struct rte_flow_modify_conntrack *ct_modify = NULL;
10602 : :
10603 : : (void)size;
10604 : 0 : if (ctx->curr != ACTION_CONNTRACK_UPDATE_CTX &&
10605 : : ctx->curr != ACTION_CONNTRACK_UPDATE_DIR)
10606 : : return -1;
10607 : : /* Token name must match. */
10608 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
10609 : : return -1;
10610 : : /* Nothing else to do if there is no buffer. */
10611 : 0 : if (!out)
10612 : : return len;
10613 : 0 : ct_modify = (struct rte_flow_modify_conntrack *)out->args.vc.data;
10614 : 0 : if (ctx->curr == ACTION_CONNTRACK_UPDATE_DIR) {
10615 : 0 : ct_modify->new_ct.is_original_dir =
10616 : 0 : conntrack_context.is_original_dir;
10617 : 0 : ct_modify->direction = 1;
10618 : : } else {
10619 : : uint32_t old_dir;
10620 : :
10621 : 0 : old_dir = ct_modify->new_ct.is_original_dir;
10622 : 0 : memcpy(&ct_modify->new_ct, &conntrack_context,
10623 : : sizeof(conntrack_context));
10624 : 0 : ct_modify->new_ct.is_original_dir = old_dir;
10625 : 0 : ct_modify->state = 1;
10626 : : }
10627 : : return len;
10628 : : }
10629 : :
10630 : : /** Parse tokens for destroy command. */
10631 : : static int
10632 : 0 : parse_destroy(struct context *ctx, const struct token *token,
10633 : : const char *str, unsigned int len,
10634 : : void *buf, unsigned int size)
10635 : : {
10636 : : struct buffer *out = buf;
10637 : :
10638 : : /* Token name must match. */
10639 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
10640 : : return -1;
10641 : : /* Nothing else to do if there is no buffer. */
10642 : 0 : if (!out)
10643 : : return len;
10644 : 0 : if (!out->command) {
10645 : 0 : if (ctx->curr != DESTROY)
10646 : : return -1;
10647 : 0 : if (sizeof(*out) > size)
10648 : : return -1;
10649 : 0 : out->command = ctx->curr;
10650 : 0 : ctx->objdata = 0;
10651 : 0 : ctx->object = out;
10652 : 0 : ctx->objmask = NULL;
10653 : 0 : out->args.destroy.rule =
10654 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
10655 : : sizeof(double));
10656 : 0 : return len;
10657 : : }
10658 : 0 : if (ctx->curr == DESTROY_IS_USER_ID) {
10659 : 0 : out->args.destroy.is_user_id = true;
10660 : 0 : return len;
10661 : : }
10662 : 0 : if (((uint8_t *)(out->args.destroy.rule + out->args.destroy.rule_n) +
10663 : 0 : sizeof(*out->args.destroy.rule)) > (uint8_t *)out + size)
10664 : : return -1;
10665 : 0 : ctx->objdata = 0;
10666 : 0 : ctx->object = out->args.destroy.rule + out->args.destroy.rule_n++;
10667 : 0 : ctx->objmask = NULL;
10668 : 0 : return len;
10669 : : }
10670 : :
10671 : : /** Parse tokens for flush command. */
10672 : : static int
10673 : 0 : parse_flush(struct context *ctx, const struct token *token,
10674 : : const char *str, unsigned int len,
10675 : : void *buf, unsigned int size)
10676 : : {
10677 : : struct buffer *out = buf;
10678 : :
10679 : : /* Token name must match. */
10680 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
10681 : : return -1;
10682 : : /* Nothing else to do if there is no buffer. */
10683 : 0 : if (!out)
10684 : : return len;
10685 : 0 : if (!out->command) {
10686 : 0 : if (ctx->curr != FLUSH)
10687 : : return -1;
10688 : 0 : if (sizeof(*out) > size)
10689 : : return -1;
10690 : 0 : out->command = ctx->curr;
10691 : 0 : ctx->objdata = 0;
10692 : 0 : ctx->object = out;
10693 : 0 : ctx->objmask = NULL;
10694 : : }
10695 : : return len;
10696 : : }
10697 : :
10698 : : /** Parse tokens for dump command. */
10699 : : static int
10700 : 0 : parse_dump(struct context *ctx, const struct token *token,
10701 : : const char *str, unsigned int len,
10702 : : void *buf, unsigned int size)
10703 : : {
10704 : : struct buffer *out = buf;
10705 : :
10706 : : /* Token name must match. */
10707 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
10708 : : return -1;
10709 : : /* Nothing else to do if there is no buffer. */
10710 : 0 : if (!out)
10711 : : return len;
10712 : 0 : if (!out->command) {
10713 : 0 : if (ctx->curr != DUMP)
10714 : : return -1;
10715 : 0 : if (sizeof(*out) > size)
10716 : : return -1;
10717 : 0 : out->command = ctx->curr;
10718 : 0 : ctx->objdata = 0;
10719 : 0 : ctx->object = out;
10720 : 0 : ctx->objmask = NULL;
10721 : 0 : return len;
10722 : : }
10723 : 0 : switch (ctx->curr) {
10724 : 0 : case DUMP_ALL:
10725 : : case DUMP_ONE:
10726 : 0 : out->args.dump.mode = (ctx->curr == DUMP_ALL) ? true : false;
10727 : 0 : out->command = ctx->curr;
10728 : 0 : ctx->objdata = 0;
10729 : 0 : ctx->object = out;
10730 : 0 : ctx->objmask = NULL;
10731 : 0 : return len;
10732 : 0 : case DUMP_IS_USER_ID:
10733 : 0 : out->args.dump.is_user_id = true;
10734 : 0 : return len;
10735 : : default:
10736 : : return -1;
10737 : : }
10738 : : }
10739 : :
10740 : : /** Parse tokens for query command. */
10741 : : static int
10742 : 0 : parse_query(struct context *ctx, const struct token *token,
10743 : : const char *str, unsigned int len,
10744 : : void *buf, unsigned int size)
10745 : : {
10746 : : struct buffer *out = buf;
10747 : :
10748 : : /* Token name must match. */
10749 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
10750 : : return -1;
10751 : : /* Nothing else to do if there is no buffer. */
10752 : 0 : if (!out)
10753 : : return len;
10754 : 0 : if (!out->command) {
10755 : 0 : if (ctx->curr != QUERY)
10756 : : return -1;
10757 : 0 : if (sizeof(*out) > size)
10758 : : return -1;
10759 : 0 : out->command = ctx->curr;
10760 : 0 : ctx->objdata = 0;
10761 : 0 : ctx->object = out;
10762 : 0 : ctx->objmask = NULL;
10763 : : }
10764 : 0 : if (ctx->curr == QUERY_IS_USER_ID) {
10765 : 0 : out->args.query.is_user_id = true;
10766 : 0 : return len;
10767 : : }
10768 : : return len;
10769 : : }
10770 : :
10771 : : /** Parse action names. */
10772 : : static int
10773 : 0 : parse_action(struct context *ctx, const struct token *token,
10774 : : const char *str, unsigned int len,
10775 : : void *buf, unsigned int size)
10776 : : {
10777 : : struct buffer *out = buf;
10778 : : const struct arg *arg = pop_args(ctx);
10779 : : unsigned int i;
10780 : :
10781 : : (void)size;
10782 : : /* Argument is expected. */
10783 : 0 : if (!arg)
10784 : 0 : return -1;
10785 : : /* Parse action name. */
10786 : 0 : for (i = 0; next_action[i]; ++i) {
10787 : : const struct parse_action_priv *priv;
10788 : :
10789 : : token = &token_list[next_action[i]];
10790 : 0 : if (strcmp_partial(token->name, str, len))
10791 : : continue;
10792 : 0 : priv = token->priv;
10793 : 0 : if (!priv)
10794 : 0 : goto error;
10795 : 0 : if (out)
10796 : 0 : memcpy((uint8_t *)ctx->object + arg->offset,
10797 : 0 : &priv->type,
10798 : 0 : arg->size);
10799 : 0 : return len;
10800 : : }
10801 : 0 : error:
10802 : : push_args(ctx, arg);
10803 : : return -1;
10804 : : }
10805 : :
10806 : : /** Parse tokens for list command. */
10807 : : static int
10808 : 0 : parse_list(struct context *ctx, const struct token *token,
10809 : : const char *str, unsigned int len,
10810 : : void *buf, unsigned int size)
10811 : : {
10812 : : struct buffer *out = buf;
10813 : :
10814 : : /* Token name must match. */
10815 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
10816 : : return -1;
10817 : : /* Nothing else to do if there is no buffer. */
10818 : 0 : if (!out)
10819 : : return len;
10820 : 0 : if (!out->command) {
10821 : 0 : if (ctx->curr != LIST)
10822 : : return -1;
10823 : 0 : if (sizeof(*out) > size)
10824 : : return -1;
10825 : 0 : out->command = ctx->curr;
10826 : 0 : ctx->objdata = 0;
10827 : 0 : ctx->object = out;
10828 : 0 : ctx->objmask = NULL;
10829 : 0 : out->args.list.group =
10830 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
10831 : : sizeof(double));
10832 : 0 : return len;
10833 : : }
10834 : 0 : if (((uint8_t *)(out->args.list.group + out->args.list.group_n) +
10835 : 0 : sizeof(*out->args.list.group)) > (uint8_t *)out + size)
10836 : : return -1;
10837 : 0 : ctx->objdata = 0;
10838 : 0 : ctx->object = out->args.list.group + out->args.list.group_n++;
10839 : 0 : ctx->objmask = NULL;
10840 : 0 : return len;
10841 : : }
10842 : :
10843 : : /** Parse tokens for list all aged flows command. */
10844 : : static int
10845 : 0 : parse_aged(struct context *ctx, const struct token *token,
10846 : : const char *str, unsigned int len,
10847 : : void *buf, unsigned int size)
10848 : : {
10849 : : struct buffer *out = buf;
10850 : :
10851 : : /* Token name must match. */
10852 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
10853 : : return -1;
10854 : : /* Nothing else to do if there is no buffer. */
10855 : 0 : if (!out)
10856 : : return len;
10857 : 0 : if (!out->command || out->command == QUEUE) {
10858 : 0 : if (ctx->curr != AGED && ctx->curr != QUEUE_AGED)
10859 : : return -1;
10860 : 0 : if (sizeof(*out) > size)
10861 : : return -1;
10862 : 0 : out->command = ctx->curr;
10863 : 0 : ctx->objdata = 0;
10864 : 0 : ctx->object = out;
10865 : 0 : ctx->objmask = NULL;
10866 : : }
10867 : 0 : if (ctx->curr == AGED_DESTROY)
10868 : 0 : out->args.aged.destroy = 1;
10869 : : return len;
10870 : : }
10871 : :
10872 : : /** Parse tokens for isolate command. */
10873 : : static int
10874 : 0 : parse_isolate(struct context *ctx, const struct token *token,
10875 : : const char *str, unsigned int len,
10876 : : void *buf, unsigned int size)
10877 : : {
10878 : : struct buffer *out = buf;
10879 : :
10880 : : /* Token name must match. */
10881 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
10882 : : return -1;
10883 : : /* Nothing else to do if there is no buffer. */
10884 : 0 : if (!out)
10885 : : return len;
10886 : 0 : if (!out->command) {
10887 : 0 : if (ctx->curr != ISOLATE)
10888 : : return -1;
10889 : 0 : if (sizeof(*out) > size)
10890 : : return -1;
10891 : 0 : out->command = ctx->curr;
10892 : 0 : ctx->objdata = 0;
10893 : 0 : ctx->object = out;
10894 : 0 : ctx->objmask = NULL;
10895 : : }
10896 : : return len;
10897 : : }
10898 : :
10899 : : /** Parse tokens for info/configure command. */
10900 : : static int
10901 : 0 : parse_configure(struct context *ctx, const struct token *token,
10902 : : const char *str, unsigned int len,
10903 : : void *buf, unsigned int size)
10904 : : {
10905 : : struct buffer *out = buf;
10906 : :
10907 : : /* Token name must match. */
10908 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
10909 : : return -1;
10910 : : /* Nothing else to do if there is no buffer. */
10911 : 0 : if (!out)
10912 : : return len;
10913 : 0 : if (!out->command) {
10914 : 0 : if (ctx->curr != INFO && ctx->curr != CONFIGURE)
10915 : : return -1;
10916 : 0 : if (sizeof(*out) > size)
10917 : : return -1;
10918 : 0 : out->command = ctx->curr;
10919 : 0 : ctx->objdata = 0;
10920 : 0 : ctx->object = out;
10921 : 0 : ctx->objmask = NULL;
10922 : : }
10923 : : return len;
10924 : : }
10925 : :
10926 : : /** Parse tokens for template create command. */
10927 : : static int
10928 : 0 : parse_template(struct context *ctx, const struct token *token,
10929 : : const char *str, unsigned int len,
10930 : : void *buf, unsigned int size)
10931 : : {
10932 : : struct buffer *out = buf;
10933 : :
10934 : : /* Token name must match. */
10935 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
10936 : : return -1;
10937 : : /* Nothing else to do if there is no buffer. */
10938 : 0 : if (!out)
10939 : : return len;
10940 : 0 : if (!out->command) {
10941 : 0 : if (ctx->curr != PATTERN_TEMPLATE &&
10942 : : ctx->curr != ACTIONS_TEMPLATE)
10943 : : return -1;
10944 : 0 : if (sizeof(*out) > size)
10945 : : return -1;
10946 : 0 : out->command = ctx->curr;
10947 : 0 : ctx->objdata = 0;
10948 : 0 : ctx->object = out;
10949 : 0 : ctx->objmask = NULL;
10950 : 0 : out->args.vc.data = (uint8_t *)out + size;
10951 : 0 : return len;
10952 : : }
10953 : 0 : switch (ctx->curr) {
10954 : 0 : case PATTERN_TEMPLATE_CREATE:
10955 : 0 : out->args.vc.pattern =
10956 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
10957 : : sizeof(double));
10958 : 0 : out->args.vc.pat_templ_id = UINT32_MAX;
10959 : 0 : out->command = ctx->curr;
10960 : 0 : ctx->objdata = 0;
10961 : 0 : ctx->object = out;
10962 : 0 : ctx->objmask = NULL;
10963 : 0 : return len;
10964 : 0 : case PATTERN_TEMPLATE_EGRESS:
10965 : 0 : out->args.vc.attr.egress = 1;
10966 : 0 : return len;
10967 : 0 : case PATTERN_TEMPLATE_INGRESS:
10968 : 0 : out->args.vc.attr.ingress = 1;
10969 : 0 : return len;
10970 : 0 : case PATTERN_TEMPLATE_TRANSFER:
10971 : 0 : out->args.vc.attr.transfer = 1;
10972 : 0 : return len;
10973 : 0 : case ACTIONS_TEMPLATE_CREATE:
10974 : 0 : out->args.vc.act_templ_id = UINT32_MAX;
10975 : 0 : out->command = ctx->curr;
10976 : 0 : ctx->objdata = 0;
10977 : 0 : ctx->object = out;
10978 : 0 : ctx->objmask = NULL;
10979 : 0 : return len;
10980 : 0 : case ACTIONS_TEMPLATE_SPEC:
10981 : 0 : out->args.vc.actions =
10982 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
10983 : : sizeof(double));
10984 : 0 : ctx->object = out->args.vc.actions;
10985 : 0 : ctx->objmask = NULL;
10986 : 0 : return len;
10987 : 0 : case ACTIONS_TEMPLATE_MASK:
10988 : 0 : out->args.vc.masks =
10989 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)
10990 : : (out->args.vc.actions +
10991 : : out->args.vc.actions_n),
10992 : : sizeof(double));
10993 : 0 : ctx->object = out->args.vc.masks;
10994 : 0 : ctx->objmask = NULL;
10995 : 0 : return len;
10996 : 0 : case ACTIONS_TEMPLATE_EGRESS:
10997 : 0 : out->args.vc.attr.egress = 1;
10998 : 0 : return len;
10999 : 0 : case ACTIONS_TEMPLATE_INGRESS:
11000 : 0 : out->args.vc.attr.ingress = 1;
11001 : 0 : return len;
11002 : 0 : case ACTIONS_TEMPLATE_TRANSFER:
11003 : 0 : out->args.vc.attr.transfer = 1;
11004 : 0 : return len;
11005 : : default:
11006 : : return -1;
11007 : : }
11008 : : }
11009 : :
11010 : : /** Parse tokens for template destroy command. */
11011 : : static int
11012 : 0 : parse_template_destroy(struct context *ctx, const struct token *token,
11013 : : const char *str, unsigned int len,
11014 : : void *buf, unsigned int size)
11015 : : {
11016 : : struct buffer *out = buf;
11017 : : uint32_t *template_id;
11018 : :
11019 : : /* Token name must match. */
11020 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
11021 : : return -1;
11022 : : /* Nothing else to do if there is no buffer. */
11023 : 0 : if (!out)
11024 : : return len;
11025 : 0 : if (!out->command ||
11026 : 0 : out->command == PATTERN_TEMPLATE ||
11027 : : out->command == ACTIONS_TEMPLATE) {
11028 : 0 : if (ctx->curr != PATTERN_TEMPLATE_DESTROY &&
11029 : : ctx->curr != ACTIONS_TEMPLATE_DESTROY)
11030 : : return -1;
11031 : 0 : if (sizeof(*out) > size)
11032 : : return -1;
11033 : 0 : out->command = ctx->curr;
11034 : 0 : ctx->objdata = 0;
11035 : 0 : ctx->object = out;
11036 : 0 : ctx->objmask = NULL;
11037 : 0 : out->args.templ_destroy.template_id =
11038 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
11039 : : sizeof(double));
11040 : 0 : return len;
11041 : : }
11042 : 0 : template_id = out->args.templ_destroy.template_id
11043 : 0 : + out->args.templ_destroy.template_id_n++;
11044 : 0 : if ((uint8_t *)template_id > (uint8_t *)out + size)
11045 : : return -1;
11046 : 0 : ctx->objdata = 0;
11047 : 0 : ctx->object = template_id;
11048 : 0 : ctx->objmask = NULL;
11049 : 0 : return len;
11050 : : }
11051 : :
11052 : : /** Parse tokens for table create command. */
11053 : : static int
11054 : 0 : parse_table(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 : if (ctx->curr != TABLE)
11069 : : return -1;
11070 : 0 : if (sizeof(*out) > size)
11071 : : return -1;
11072 : 0 : out->command = ctx->curr;
11073 : 0 : ctx->objdata = 0;
11074 : 0 : ctx->object = out;
11075 : 0 : ctx->objmask = NULL;
11076 : 0 : return len;
11077 : : }
11078 : 0 : switch (ctx->curr) {
11079 : 0 : case TABLE_CREATE:
11080 : : case TABLE_RESIZE:
11081 : 0 : out->command = ctx->curr;
11082 : 0 : ctx->objdata = 0;
11083 : 0 : ctx->object = out;
11084 : 0 : ctx->objmask = NULL;
11085 : 0 : out->args.table.id = UINT32_MAX;
11086 : 0 : return len;
11087 : 0 : case TABLE_PATTERN_TEMPLATE:
11088 : 0 : out->args.table.pat_templ_id =
11089 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
11090 : : sizeof(double));
11091 : 0 : template_id = out->args.table.pat_templ_id
11092 : 0 : + out->args.table.pat_templ_id_n++;
11093 : 0 : if ((uint8_t *)template_id > (uint8_t *)out + size)
11094 : : return -1;
11095 : 0 : ctx->objdata = 0;
11096 : 0 : ctx->object = template_id;
11097 : 0 : ctx->objmask = NULL;
11098 : 0 : return len;
11099 : 0 : case TABLE_ACTIONS_TEMPLATE:
11100 : 0 : out->args.table.act_templ_id =
11101 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)
11102 : : (out->args.table.pat_templ_id +
11103 : : out->args.table.pat_templ_id_n),
11104 : : sizeof(double));
11105 : 0 : template_id = out->args.table.act_templ_id
11106 : 0 : + out->args.table.act_templ_id_n++;
11107 : 0 : if ((uint8_t *)template_id > (uint8_t *)out + size)
11108 : : return -1;
11109 : 0 : ctx->objdata = 0;
11110 : 0 : ctx->object = template_id;
11111 : 0 : ctx->objmask = NULL;
11112 : 0 : return len;
11113 : 0 : case TABLE_INGRESS:
11114 : 0 : out->args.table.attr.flow_attr.ingress = 1;
11115 : 0 : return len;
11116 : 0 : case TABLE_EGRESS:
11117 : 0 : out->args.table.attr.flow_attr.egress = 1;
11118 : 0 : return len;
11119 : 0 : case TABLE_TRANSFER:
11120 : 0 : out->args.table.attr.flow_attr.transfer = 1;
11121 : 0 : return len;
11122 : 0 : case TABLE_TRANSFER_WIRE_ORIG:
11123 : 0 : if (!out->args.table.attr.flow_attr.transfer)
11124 : : return -1;
11125 : 0 : out->args.table.attr.specialize |= RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_WIRE_ORIG;
11126 : 0 : return len;
11127 : 0 : case TABLE_TRANSFER_VPORT_ORIG:
11128 : 0 : if (!out->args.table.attr.flow_attr.transfer)
11129 : : return -1;
11130 : 0 : out->args.table.attr.specialize |= RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_VPORT_ORIG;
11131 : 0 : return len;
11132 : 0 : case TABLE_RESIZABLE:
11133 : 0 : out->args.table.attr.specialize |=
11134 : : RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE;
11135 : 0 : return len;
11136 : 0 : case TABLE_RULES_NUMBER:
11137 : 0 : ctx->objdata = 0;
11138 : 0 : ctx->object = out;
11139 : 0 : ctx->objmask = NULL;
11140 : 0 : return len;
11141 : 0 : case TABLE_RESIZE_ID:
11142 : : case TABLE_RESIZE_RULES_NUMBER:
11143 : 0 : return len;
11144 : : default:
11145 : : return -1;
11146 : : }
11147 : : }
11148 : :
11149 : : /** Parse tokens for table destroy command. */
11150 : : static int
11151 : 0 : parse_table_destroy(struct context *ctx, const struct token *token,
11152 : : const char *str, unsigned int len,
11153 : : void *buf, unsigned int size)
11154 : : {
11155 : : struct buffer *out = buf;
11156 : : uint32_t *table_id;
11157 : :
11158 : : /* Token name must match. */
11159 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
11160 : : return -1;
11161 : : /* Nothing else to do if there is no buffer. */
11162 : 0 : if (!out)
11163 : : return len;
11164 : 0 : if (!out->command || out->command == TABLE) {
11165 : 0 : if (ctx->curr != TABLE_DESTROY &&
11166 : : ctx->curr != TABLE_RESIZE_COMPLETE)
11167 : : return -1;
11168 : 0 : if (sizeof(*out) > size)
11169 : : return -1;
11170 : 0 : out->command = ctx->curr;
11171 : 0 : ctx->objdata = 0;
11172 : 0 : ctx->object = out;
11173 : 0 : ctx->objmask = NULL;
11174 : 0 : out->args.table_destroy.table_id =
11175 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
11176 : : sizeof(double));
11177 : 0 : return len;
11178 : : }
11179 : 0 : table_id = out->args.table_destroy.table_id
11180 : 0 : + out->args.table_destroy.table_id_n++;
11181 : 0 : if ((uint8_t *)table_id > (uint8_t *)out + size)
11182 : : return -1;
11183 : 0 : ctx->objdata = 0;
11184 : 0 : ctx->object = table_id;
11185 : 0 : ctx->objmask = NULL;
11186 : 0 : return len;
11187 : : }
11188 : :
11189 : : /** Parse tokens for queue create commands. */
11190 : : static int
11191 : 0 : parse_qo(struct context *ctx, const struct token *token,
11192 : : const char *str, unsigned int len,
11193 : : void *buf, unsigned int size)
11194 : : {
11195 : : struct buffer *out = buf;
11196 : :
11197 : : /* Token name must match. */
11198 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
11199 : : return -1;
11200 : : /* Nothing else to do if there is no buffer. */
11201 : 0 : if (!out)
11202 : : return len;
11203 : 0 : if (!out->command) {
11204 : 0 : if (ctx->curr != QUEUE)
11205 : : return -1;
11206 : 0 : if (sizeof(*out) > size)
11207 : : return -1;
11208 : 0 : out->command = ctx->curr;
11209 : 0 : ctx->objdata = 0;
11210 : 0 : ctx->object = out;
11211 : 0 : ctx->objmask = NULL;
11212 : 0 : out->args.vc.data = (uint8_t *)out + size;
11213 : 0 : return len;
11214 : : }
11215 : 0 : switch (ctx->curr) {
11216 : 0 : case QUEUE_CREATE:
11217 : : case QUEUE_UPDATE:
11218 : 0 : out->command = ctx->curr;
11219 : 0 : ctx->objdata = 0;
11220 : 0 : ctx->object = out;
11221 : 0 : ctx->objmask = NULL;
11222 : 0 : out->args.vc.rule_id = UINT32_MAX;
11223 : 0 : return len;
11224 : 0 : case QUEUE_TEMPLATE_TABLE:
11225 : : case QUEUE_PATTERN_TEMPLATE:
11226 : : case QUEUE_ACTIONS_TEMPLATE:
11227 : : case QUEUE_CREATE_POSTPONE:
11228 : : case QUEUE_RULE_ID:
11229 : : case QUEUE_UPDATE_ID:
11230 : 0 : return len;
11231 : 0 : case ITEM_PATTERN:
11232 : 0 : out->args.vc.pattern =
11233 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
11234 : : sizeof(double));
11235 : 0 : ctx->object = out->args.vc.pattern;
11236 : 0 : ctx->objmask = NULL;
11237 : 0 : return len;
11238 : 0 : case ACTIONS:
11239 : 0 : out->args.vc.actions =
11240 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)
11241 : : (out->args.vc.pattern +
11242 : : out->args.vc.pattern_n),
11243 : : sizeof(double));
11244 : 0 : ctx->object = out->args.vc.actions;
11245 : 0 : ctx->objmask = NULL;
11246 : 0 : return len;
11247 : : default:
11248 : : return -1;
11249 : : }
11250 : : }
11251 : :
11252 : : /** Parse tokens for queue destroy command. */
11253 : : static int
11254 : 0 : parse_qo_destroy(struct context *ctx, const struct token *token,
11255 : : const char *str, unsigned int len,
11256 : : void *buf, unsigned int size)
11257 : : {
11258 : : struct buffer *out = buf;
11259 : : uint64_t *flow_id;
11260 : :
11261 : : /* Token name must match. */
11262 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
11263 : : return -1;
11264 : : /* Nothing else to do if there is no buffer. */
11265 : 0 : if (!out)
11266 : : return len;
11267 : 0 : if (!out->command || out->command == QUEUE) {
11268 : 0 : if (ctx->curr != QUEUE_DESTROY &&
11269 : : ctx->curr != QUEUE_FLOW_UPDATE_RESIZED)
11270 : : return -1;
11271 : 0 : if (sizeof(*out) > size)
11272 : : return -1;
11273 : 0 : out->command = ctx->curr;
11274 : 0 : ctx->objdata = 0;
11275 : 0 : ctx->object = out;
11276 : 0 : ctx->objmask = NULL;
11277 : 0 : out->args.destroy.rule =
11278 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
11279 : : sizeof(double));
11280 : 0 : return len;
11281 : : }
11282 : 0 : switch (ctx->curr) {
11283 : 0 : case QUEUE_DESTROY_ID:
11284 : 0 : flow_id = out->args.destroy.rule
11285 : 0 : + out->args.destroy.rule_n++;
11286 : 0 : if ((uint8_t *)flow_id > (uint8_t *)out + size)
11287 : : return -1;
11288 : 0 : ctx->objdata = 0;
11289 : 0 : ctx->object = flow_id;
11290 : 0 : ctx->objmask = NULL;
11291 : 0 : return len;
11292 : 0 : case QUEUE_DESTROY_POSTPONE:
11293 : 0 : return len;
11294 : : default:
11295 : : return -1;
11296 : : }
11297 : : }
11298 : :
11299 : : /** Parse tokens for push queue command. */
11300 : : static int
11301 : 0 : parse_push(struct context *ctx, const struct token *token,
11302 : : const char *str, unsigned int len,
11303 : : void *buf, unsigned int size)
11304 : : {
11305 : : struct buffer *out = buf;
11306 : :
11307 : : /* Token name must match. */
11308 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
11309 : : return -1;
11310 : : /* Nothing else to do if there is no buffer. */
11311 : 0 : if (!out)
11312 : : return len;
11313 : 0 : if (!out->command) {
11314 : 0 : if (ctx->curr != PUSH)
11315 : : return -1;
11316 : 0 : if (sizeof(*out) > size)
11317 : : return -1;
11318 : 0 : out->command = ctx->curr;
11319 : 0 : ctx->objdata = 0;
11320 : 0 : ctx->object = out;
11321 : 0 : ctx->objmask = NULL;
11322 : 0 : out->args.vc.data = (uint8_t *)out + size;
11323 : : }
11324 : : return len;
11325 : : }
11326 : :
11327 : : /** Parse tokens for pull command. */
11328 : : static int
11329 : 0 : parse_pull(struct context *ctx, const struct token *token,
11330 : : const char *str, unsigned int len,
11331 : : void *buf, unsigned int size)
11332 : : {
11333 : : struct buffer *out = buf;
11334 : :
11335 : : /* Token name must match. */
11336 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
11337 : : return -1;
11338 : : /* Nothing else to do if there is no buffer. */
11339 : 0 : if (!out)
11340 : : return len;
11341 : 0 : if (!out->command) {
11342 : 0 : if (ctx->curr != PULL)
11343 : : return -1;
11344 : 0 : if (sizeof(*out) > size)
11345 : : return -1;
11346 : 0 : out->command = ctx->curr;
11347 : 0 : ctx->objdata = 0;
11348 : 0 : ctx->object = out;
11349 : 0 : ctx->objmask = NULL;
11350 : 0 : out->args.vc.data = (uint8_t *)out + size;
11351 : : }
11352 : : return len;
11353 : : }
11354 : :
11355 : : /** Parse tokens for hash calculation commands. */
11356 : : static int
11357 : 0 : parse_hash(struct context *ctx, const struct token *token,
11358 : : const char *str, unsigned int len,
11359 : : void *buf, unsigned int size)
11360 : : {
11361 : : struct buffer *out = buf;
11362 : :
11363 : : /* Token name must match. */
11364 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
11365 : : return -1;
11366 : : /* Nothing else to do if there is no buffer. */
11367 : 0 : if (!out)
11368 : : return len;
11369 : 0 : if (!out->command) {
11370 : 0 : if (ctx->curr != HASH)
11371 : : return -1;
11372 : 0 : if (sizeof(*out) > size)
11373 : : return -1;
11374 : 0 : out->command = ctx->curr;
11375 : 0 : ctx->objdata = 0;
11376 : 0 : ctx->object = out;
11377 : 0 : ctx->objmask = NULL;
11378 : 0 : out->args.vc.data = (uint8_t *)out + size;
11379 : 0 : return len;
11380 : : }
11381 : 0 : switch (ctx->curr) {
11382 : 0 : case HASH_CALC_TABLE:
11383 : : case HASH_CALC_PATTERN_INDEX:
11384 : 0 : return len;
11385 : 0 : case ITEM_PATTERN:
11386 : 0 : out->args.vc.pattern =
11387 : 0 : (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
11388 : : sizeof(double));
11389 : 0 : ctx->object = out->args.vc.pattern;
11390 : 0 : ctx->objmask = NULL;
11391 : 0 : return len;
11392 : 0 : case HASH_CALC_ENCAP:
11393 : 0 : out->args.vc.encap_hash = 1;
11394 : 0 : return len;
11395 : 0 : case ENCAP_HASH_FIELD_SRC_PORT:
11396 : 0 : out->args.vc.field = RTE_FLOW_ENCAP_HASH_FIELD_SRC_PORT;
11397 : 0 : return len;
11398 : 0 : case ENCAP_HASH_FIELD_GRE_FLOW_ID:
11399 : 0 : out->args.vc.field = RTE_FLOW_ENCAP_HASH_FIELD_NVGRE_FLOW_ID;
11400 : 0 : return len;
11401 : : default:
11402 : : return -1;
11403 : : }
11404 : : }
11405 : :
11406 : : static int
11407 : 0 : parse_group(struct context *ctx, const struct token *token,
11408 : : const char *str, unsigned int len,
11409 : : void *buf, unsigned int size)
11410 : : {
11411 : : struct buffer *out = buf;
11412 : :
11413 : : /* Token name must match. */
11414 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
11415 : : return -1;
11416 : : /* Nothing else to do if there is no buffer. */
11417 : 0 : if (!out)
11418 : : return len;
11419 : 0 : if (!out->command) {
11420 : 0 : if (ctx->curr != FLOW_GROUP)
11421 : : return -1;
11422 : 0 : if (sizeof(*out) > size)
11423 : : return -1;
11424 : 0 : out->command = ctx->curr;
11425 : 0 : ctx->objdata = 0;
11426 : 0 : ctx->object = out;
11427 : 0 : ctx->objmask = NULL;
11428 : 0 : out->args.vc.data = (uint8_t *)out + size;
11429 : 0 : return len;
11430 : : }
11431 : 0 : switch (ctx->curr) {
11432 : 0 : case GROUP_INGRESS:
11433 : 0 : out->args.vc.attr.ingress = 1;
11434 : 0 : return len;
11435 : 0 : case GROUP_EGRESS:
11436 : 0 : out->args.vc.attr.egress = 1;
11437 : 0 : return len;
11438 : 0 : case GROUP_TRANSFER:
11439 : 0 : out->args.vc.attr.transfer = 1;
11440 : 0 : return len;
11441 : 0 : case GROUP_SET_MISS_ACTIONS:
11442 : 0 : out->command = ctx->curr;
11443 : 0 : ctx->objdata = 0;
11444 : 0 : ctx->object = out;
11445 : 0 : ctx->objmask = NULL;
11446 : 0 : out->args.vc.actions = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
11447 : : sizeof(double));
11448 : 0 : return len;
11449 : : default:
11450 : : return -1;
11451 : : }
11452 : : }
11453 : :
11454 : : static int
11455 : 0 : parse_flex(struct context *ctx, const struct token *token,
11456 : : const char *str, unsigned int len,
11457 : : void *buf, unsigned int size)
11458 : : {
11459 : : struct buffer *out = buf;
11460 : :
11461 : : /* Token name must match. */
11462 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
11463 : : return -1;
11464 : : /* Nothing else to do if there is no buffer. */
11465 : 0 : if (!out)
11466 : : return len;
11467 : 0 : if (out->command == ZERO) {
11468 : 0 : if (ctx->curr != FLEX)
11469 : : return -1;
11470 : 0 : if (sizeof(*out) > size)
11471 : : return -1;
11472 : 0 : out->command = ctx->curr;
11473 : 0 : ctx->objdata = 0;
11474 : 0 : ctx->object = out;
11475 : 0 : ctx->objmask = NULL;
11476 : : } else {
11477 : 0 : switch (ctx->curr) {
11478 : : default:
11479 : : break;
11480 : 0 : case FLEX_ITEM_CREATE:
11481 : : case FLEX_ITEM_DESTROY:
11482 : 0 : out->command = ctx->curr;
11483 : 0 : break;
11484 : : }
11485 : : }
11486 : :
11487 : : return len;
11488 : : }
11489 : :
11490 : : static int
11491 : 0 : parse_tunnel(struct context *ctx, const struct token *token,
11492 : : const char *str, unsigned int len,
11493 : : void *buf, unsigned int size)
11494 : : {
11495 : : struct buffer *out = buf;
11496 : :
11497 : : /* Token name must match. */
11498 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
11499 : : return -1;
11500 : : /* Nothing else to do if there is no buffer. */
11501 : 0 : if (!out)
11502 : : return len;
11503 : 0 : if (!out->command) {
11504 : 0 : if (ctx->curr != TUNNEL)
11505 : : return -1;
11506 : 0 : if (sizeof(*out) > size)
11507 : : return -1;
11508 : 0 : out->command = ctx->curr;
11509 : 0 : ctx->objdata = 0;
11510 : 0 : ctx->object = out;
11511 : 0 : ctx->objmask = NULL;
11512 : : } else {
11513 : 0 : switch (ctx->curr) {
11514 : : default:
11515 : : break;
11516 : 0 : case TUNNEL_CREATE:
11517 : : case TUNNEL_DESTROY:
11518 : : case TUNNEL_LIST:
11519 : 0 : out->command = ctx->curr;
11520 : 0 : break;
11521 : 0 : case TUNNEL_CREATE_TYPE:
11522 : : case TUNNEL_DESTROY_ID:
11523 : 0 : ctx->object = &out->args.vc.tunnel_ops;
11524 : 0 : break;
11525 : : }
11526 : : }
11527 : :
11528 : : return len;
11529 : : }
11530 : :
11531 : : /**
11532 : : * Parse signed/unsigned integers 8 to 64-bit long.
11533 : : *
11534 : : * Last argument (ctx->args) is retrieved to determine integer type and
11535 : : * storage location.
11536 : : */
11537 : : static int
11538 : 0 : parse_int(struct context *ctx, const struct token *token,
11539 : : const char *str, unsigned int len,
11540 : : void *buf, unsigned int size)
11541 : : {
11542 : : const struct arg *arg = pop_args(ctx);
11543 : : uintmax_t u;
11544 : : char *end;
11545 : :
11546 : : (void)token;
11547 : : /* Argument is expected. */
11548 : 0 : if (!arg)
11549 : 0 : return -1;
11550 : 0 : errno = 0;
11551 : 0 : u = arg->sign ?
11552 : 0 : (uintmax_t)strtoimax(str, &end, 0) :
11553 : 0 : strtoumax(str, &end, 0);
11554 : 0 : if (errno || (size_t)(end - str) != len)
11555 : 0 : goto error;
11556 : 0 : if (arg->bounded &&
11557 : 0 : ((arg->sign && ((intmax_t)u < (intmax_t)arg->min ||
11558 : 0 : (intmax_t)u > (intmax_t)arg->max)) ||
11559 : 0 : (!arg->sign && (u < arg->min || u > arg->max))))
11560 : 0 : goto error;
11561 : 0 : if (!ctx->object)
11562 : 0 : return len;
11563 : 0 : if (arg->mask) {
11564 : 0 : if (!arg_entry_bf_fill(ctx->object, u, arg) ||
11565 : 0 : !arg_entry_bf_fill(ctx->objmask, -1, arg))
11566 : 0 : goto error;
11567 : 0 : return len;
11568 : : }
11569 : 0 : buf = (uint8_t *)ctx->object + arg->offset;
11570 : 0 : size = arg->size;
11571 : 0 : if (u > RTE_LEN2MASK(size * CHAR_BIT, uint64_t))
11572 : : return -1;
11573 : 0 : objmask:
11574 : 0 : switch (size) {
11575 : 0 : case sizeof(uint8_t):
11576 : 0 : *(uint8_t *)buf = u;
11577 : 0 : break;
11578 : 0 : case sizeof(uint16_t):
11579 : 0 : *(uint16_t *)buf = arg->hton ? rte_cpu_to_be_16(u) : u;
11580 : 0 : break;
11581 : 0 : case sizeof(uint8_t [3]):
11582 : : #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
11583 : 0 : if (!arg->hton) {
11584 : 0 : ((uint8_t *)buf)[0] = u;
11585 : 0 : ((uint8_t *)buf)[1] = u >> 8;
11586 : 0 : ((uint8_t *)buf)[2] = u >> 16;
11587 : 0 : break;
11588 : : }
11589 : : #endif
11590 : 0 : ((uint8_t *)buf)[0] = u >> 16;
11591 : 0 : ((uint8_t *)buf)[1] = u >> 8;
11592 : 0 : ((uint8_t *)buf)[2] = u;
11593 : 0 : break;
11594 : 0 : case sizeof(uint32_t):
11595 : 0 : *(uint32_t *)buf = arg->hton ? rte_cpu_to_be_32(u) : u;
11596 : 0 : break;
11597 : 0 : case sizeof(uint64_t):
11598 : 0 : *(uint64_t *)buf = arg->hton ? rte_cpu_to_be_64(u) : u;
11599 : 0 : break;
11600 : 0 : default:
11601 : 0 : goto error;
11602 : : }
11603 : 0 : if (ctx->objmask && buf != (uint8_t *)ctx->objmask + arg->offset) {
11604 : : u = -1;
11605 : : buf = (uint8_t *)ctx->objmask + arg->offset;
11606 : 0 : goto objmask;
11607 : : }
11608 : 0 : return len;
11609 : 0 : error:
11610 : : push_args(ctx, arg);
11611 : : return -1;
11612 : : }
11613 : :
11614 : : /**
11615 : : * Parse a string.
11616 : : *
11617 : : * Three arguments (ctx->args) are retrieved from the stack to store data,
11618 : : * its actual length and address (in that order).
11619 : : */
11620 : : static int
11621 : 0 : parse_string(struct context *ctx, const struct token *token,
11622 : : const char *str, unsigned int len,
11623 : : void *buf, unsigned int size)
11624 : : {
11625 : : const struct arg *arg_data = pop_args(ctx);
11626 : : const struct arg *arg_len = pop_args(ctx);
11627 : : const struct arg *arg_addr = pop_args(ctx);
11628 : : char tmp[16]; /* Ought to be enough. */
11629 : : int ret;
11630 : :
11631 : : /* Arguments are expected. */
11632 : 0 : if (!arg_data)
11633 : : return -1;
11634 : 0 : if (!arg_len) {
11635 : : push_args(ctx, arg_data);
11636 : 0 : return -1;
11637 : : }
11638 : 0 : if (!arg_addr) {
11639 : : push_args(ctx, arg_len);
11640 : : push_args(ctx, arg_data);
11641 : 0 : return -1;
11642 : : }
11643 : 0 : size = arg_data->size;
11644 : : /* Bit-mask fill is not supported. */
11645 : 0 : if (arg_data->mask || size < len)
11646 : 0 : goto error;
11647 : 0 : if (!ctx->object)
11648 : 0 : return len;
11649 : : /* Let parse_int() fill length information first. */
11650 : : ret = snprintf(tmp, sizeof(tmp), "%u", len);
11651 : 0 : if (ret < 0)
11652 : 0 : goto error;
11653 : : push_args(ctx, arg_len);
11654 : 0 : ret = parse_int(ctx, token, tmp, ret, NULL, 0);
11655 : 0 : if (ret < 0) {
11656 : : pop_args(ctx);
11657 : 0 : goto error;
11658 : : }
11659 : 0 : buf = (uint8_t *)ctx->object + arg_data->offset;
11660 : : /* Output buffer is not necessarily NUL-terminated. */
11661 : 0 : memcpy(buf, str, len);
11662 : 0 : memset((uint8_t *)buf + len, 0x00, size - len);
11663 : 0 : if (ctx->objmask)
11664 : 0 : memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
11665 : : /* Save address if requested. */
11666 : 0 : if (arg_addr->size) {
11667 : 0 : memcpy((uint8_t *)ctx->object + arg_addr->offset,
11668 : 0 : (void *[]){
11669 : 0 : (uint8_t *)ctx->object + arg_data->offset
11670 : : },
11671 : : arg_addr->size);
11672 : 0 : if (ctx->objmask)
11673 : 0 : memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
11674 : 0 : (void *[]){
11675 : 0 : (uint8_t *)ctx->objmask + arg_data->offset
11676 : : },
11677 : 0 : arg_addr->size);
11678 : : }
11679 : 0 : return len;
11680 : 0 : error:
11681 : : push_args(ctx, arg_addr);
11682 : : push_args(ctx, arg_len);
11683 : : push_args(ctx, arg_data);
11684 : : return -1;
11685 : : }
11686 : :
11687 : : static int
11688 : 0 : parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)
11689 : : {
11690 : : const uint8_t *head = dst;
11691 : : uint32_t left;
11692 : :
11693 : 0 : if (*size == 0)
11694 : : return -1;
11695 : :
11696 : : left = *size;
11697 : :
11698 : : /* Convert chars to bytes */
11699 : 0 : while (left) {
11700 : 0 : char tmp[3], *end = tmp;
11701 : 0 : uint32_t read_lim = left & 1 ? 1 : 2;
11702 : :
11703 : 0 : snprintf(tmp, read_lim + 1, "%s", src);
11704 : 0 : *dst = strtoul(tmp, &end, 16);
11705 : 0 : if (*end) {
11706 : 0 : *dst = 0;
11707 : 0 : *size = (uint32_t)(dst - head);
11708 : 0 : return -1;
11709 : : }
11710 : 0 : left -= read_lim;
11711 : 0 : src += read_lim;
11712 : 0 : dst++;
11713 : : }
11714 : 0 : *dst = 0;
11715 : 0 : *size = (uint32_t)(dst - head);
11716 : 0 : return 0;
11717 : : }
11718 : :
11719 : : static int
11720 : 0 : parse_hex(struct context *ctx, const struct token *token,
11721 : : const char *str, unsigned int len,
11722 : : void *buf, unsigned int size)
11723 : : {
11724 : : const struct arg *arg_data = pop_args(ctx);
11725 : : const struct arg *arg_len = pop_args(ctx);
11726 : : const struct arg *arg_addr = pop_args(ctx);
11727 : : char tmp[16]; /* Ought to be enough. */
11728 : : int ret;
11729 : 0 : unsigned int hexlen = len;
11730 : : uint8_t hex_tmp[256];
11731 : :
11732 : : /* Arguments are expected. */
11733 : 0 : if (!arg_data)
11734 : : return -1;
11735 : 0 : if (!arg_len) {
11736 : : push_args(ctx, arg_data);
11737 : 0 : return -1;
11738 : : }
11739 : 0 : if (!arg_addr) {
11740 : : push_args(ctx, arg_len);
11741 : : push_args(ctx, arg_data);
11742 : 0 : return -1;
11743 : : }
11744 : 0 : size = arg_data->size;
11745 : : /* Bit-mask fill is not supported. */
11746 : 0 : if (arg_data->mask)
11747 : 0 : goto error;
11748 : 0 : if (!ctx->object)
11749 : 0 : return len;
11750 : :
11751 : : /* translate bytes string to array. */
11752 : 0 : if (str[0] == '0' && ((str[1] == 'x') ||
11753 : : (str[1] == 'X'))) {
11754 : 0 : str += 2;
11755 : 0 : hexlen -= 2;
11756 : : }
11757 : 0 : if (hexlen > RTE_DIM(hex_tmp))
11758 : 0 : goto error;
11759 : 0 : ret = parse_hex_string(str, hex_tmp, &hexlen);
11760 : 0 : if (ret < 0)
11761 : 0 : goto error;
11762 : : /* Check the converted binary fits into data buffer. */
11763 : 0 : if (hexlen > size)
11764 : 0 : goto error;
11765 : : /* Let parse_int() fill length information first. */
11766 : : ret = snprintf(tmp, sizeof(tmp), "%u", hexlen);
11767 : 0 : if (ret < 0)
11768 : 0 : goto error;
11769 : : /* Save length if requested. */
11770 : 0 : if (arg_len->size) {
11771 : : push_args(ctx, arg_len);
11772 : 0 : ret = parse_int(ctx, token, tmp, ret, NULL, 0);
11773 : 0 : if (ret < 0) {
11774 : : pop_args(ctx);
11775 : 0 : goto error;
11776 : : }
11777 : : }
11778 : 0 : buf = (uint8_t *)ctx->object + arg_data->offset;
11779 : : /* Output buffer is not necessarily NUL-terminated. */
11780 : 0 : memcpy(buf, hex_tmp, hexlen);
11781 : 0 : memset((uint8_t *)buf + hexlen, 0x00, size - hexlen);
11782 : 0 : if (ctx->objmask)
11783 : 0 : memset((uint8_t *)ctx->objmask + arg_data->offset,
11784 : : 0xff, hexlen);
11785 : : /* Save address if requested. */
11786 : 0 : if (arg_addr->size) {
11787 : 0 : memcpy((uint8_t *)ctx->object + arg_addr->offset,
11788 : 0 : (void *[]){
11789 : 0 : (uint8_t *)ctx->object + arg_data->offset
11790 : : },
11791 : : arg_addr->size);
11792 : 0 : if (ctx->objmask)
11793 : 0 : memcpy((uint8_t *)ctx->objmask + arg_addr->offset,
11794 : 0 : (void *[]){
11795 : 0 : (uint8_t *)ctx->objmask + arg_data->offset
11796 : : },
11797 : 0 : arg_addr->size);
11798 : : }
11799 : 0 : return len;
11800 : 0 : error:
11801 : : push_args(ctx, arg_addr);
11802 : : push_args(ctx, arg_len);
11803 : : push_args(ctx, arg_data);
11804 : : return -1;
11805 : :
11806 : : }
11807 : :
11808 : : /**
11809 : : * Parse a zero-ended string.
11810 : : */
11811 : : static int
11812 : 0 : parse_string0(struct context *ctx, const struct token *token __rte_unused,
11813 : : const char *str, unsigned int len,
11814 : : void *buf, unsigned int size)
11815 : : {
11816 : : const struct arg *arg_data = pop_args(ctx);
11817 : :
11818 : : /* Arguments are expected. */
11819 : 0 : if (!arg_data)
11820 : 0 : return -1;
11821 : 0 : size = arg_data->size;
11822 : : /* Bit-mask fill is not supported. */
11823 : 0 : if (arg_data->mask || size < len + 1)
11824 : 0 : goto error;
11825 : 0 : if (!ctx->object)
11826 : 0 : return len;
11827 : 0 : buf = (uint8_t *)ctx->object + arg_data->offset;
11828 : 0 : strncpy(buf, str, len);
11829 : 0 : if (ctx->objmask)
11830 : 0 : memset((uint8_t *)ctx->objmask + arg_data->offset, 0xff, len);
11831 : 0 : return len;
11832 : : error:
11833 : : push_args(ctx, arg_data);
11834 : : return -1;
11835 : : }
11836 : :
11837 : : /**
11838 : : * Parse a MAC address.
11839 : : *
11840 : : * Last argument (ctx->args) is retrieved to determine storage size and
11841 : : * location.
11842 : : */
11843 : : static int
11844 : 0 : parse_mac_addr(struct context *ctx, const struct token *token,
11845 : : const char *str, unsigned int len,
11846 : : void *buf, unsigned int size)
11847 : : {
11848 : : const struct arg *arg = pop_args(ctx);
11849 : : struct rte_ether_addr tmp;
11850 : : int ret;
11851 : :
11852 : : (void)token;
11853 : : /* Argument is expected. */
11854 : 0 : if (!arg)
11855 : 0 : return -1;
11856 : 0 : size = arg->size;
11857 : : /* Bit-mask fill is not supported. */
11858 : 0 : if (arg->mask || size != sizeof(tmp))
11859 : 0 : goto error;
11860 : : /* Only network endian is supported. */
11861 : 0 : if (!arg->hton)
11862 : 0 : goto error;
11863 : 0 : ret = cmdline_parse_etheraddr(NULL, str, &tmp, size);
11864 : 0 : if (ret < 0 || (unsigned int)ret != len)
11865 : 0 : goto error;
11866 : 0 : if (!ctx->object)
11867 : 0 : return len;
11868 : 0 : buf = (uint8_t *)ctx->object + arg->offset;
11869 : : memcpy(buf, &tmp, size);
11870 : 0 : if (ctx->objmask)
11871 : 0 : memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
11872 : 0 : return len;
11873 : 0 : error:
11874 : : push_args(ctx, arg);
11875 : : return -1;
11876 : : }
11877 : :
11878 : : /**
11879 : : * Parse an IPv4 address.
11880 : : *
11881 : : * Last argument (ctx->args) is retrieved to determine storage size and
11882 : : * location.
11883 : : */
11884 : : static int
11885 : 0 : parse_ipv4_addr(struct context *ctx, const struct token *token,
11886 : : const char *str, unsigned int len,
11887 : : void *buf, unsigned int size)
11888 : : {
11889 : : const struct arg *arg = pop_args(ctx);
11890 : : char str2[INET_ADDRSTRLEN];
11891 : : struct in_addr tmp;
11892 : : int ret;
11893 : :
11894 : : /* Length is longer than the max length an IPv4 address can have. */
11895 : 0 : if (len >= INET_ADDRSTRLEN)
11896 : : return -1;
11897 : : /* Argument is expected. */
11898 : 0 : if (!arg)
11899 : : return -1;
11900 : 0 : size = arg->size;
11901 : : /* Bit-mask fill is not supported. */
11902 : 0 : if (arg->mask || size != sizeof(tmp))
11903 : 0 : goto error;
11904 : : /* Only network endian is supported. */
11905 : 0 : if (!arg->hton)
11906 : 0 : goto error;
11907 : 0 : memcpy(str2, str, len);
11908 : 0 : str2[len] = '\0';
11909 : 0 : ret = inet_pton(AF_INET, str2, &tmp);
11910 : 0 : if (ret != 1) {
11911 : : /* Attempt integer parsing. */
11912 : : push_args(ctx, arg);
11913 : 0 : return parse_int(ctx, token, str, len, buf, size);
11914 : : }
11915 : 0 : if (!ctx->object)
11916 : 0 : return len;
11917 : 0 : buf = (uint8_t *)ctx->object + arg->offset;
11918 : : memcpy(buf, &tmp, size);
11919 : 0 : if (ctx->objmask)
11920 : 0 : memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
11921 : 0 : return len;
11922 : 0 : error:
11923 : : push_args(ctx, arg);
11924 : : return -1;
11925 : : }
11926 : :
11927 : : /**
11928 : : * Parse an IPv6 address.
11929 : : *
11930 : : * Last argument (ctx->args) is retrieved to determine storage size and
11931 : : * location.
11932 : : */
11933 : : static int
11934 : 0 : parse_ipv6_addr(struct context *ctx, const struct token *token,
11935 : : const char *str, unsigned int len,
11936 : : void *buf, unsigned int size)
11937 : : {
11938 : : const struct arg *arg = pop_args(ctx);
11939 : : char str2[INET6_ADDRSTRLEN];
11940 : : struct rte_ipv6_addr tmp;
11941 : : int ret;
11942 : :
11943 : : (void)token;
11944 : : /* Length is longer than the max length an IPv6 address can have. */
11945 : 0 : if (len >= INET6_ADDRSTRLEN)
11946 : : return -1;
11947 : : /* Argument is expected. */
11948 : 0 : if (!arg)
11949 : : return -1;
11950 : 0 : size = arg->size;
11951 : : /* Bit-mask fill is not supported. */
11952 : 0 : if (arg->mask || size != sizeof(tmp))
11953 : 0 : goto error;
11954 : : /* Only network endian is supported. */
11955 : 0 : if (!arg->hton)
11956 : 0 : goto error;
11957 : 0 : memcpy(str2, str, len);
11958 : 0 : str2[len] = '\0';
11959 : 0 : ret = inet_pton(AF_INET6, str2, &tmp);
11960 : 0 : if (ret != 1)
11961 : 0 : goto error;
11962 : 0 : if (!ctx->object)
11963 : 0 : return len;
11964 : 0 : buf = (uint8_t *)ctx->object + arg->offset;
11965 : : memcpy(buf, &tmp, size);
11966 : 0 : if (ctx->objmask)
11967 : 0 : memset((uint8_t *)ctx->objmask + arg->offset, 0xff, size);
11968 : 0 : return len;
11969 : 0 : error:
11970 : : push_args(ctx, arg);
11971 : : return -1;
11972 : : }
11973 : :
11974 : : /** Boolean values (even indices stand for false). */
11975 : : static const char *const boolean_name[] = {
11976 : : "0", "1",
11977 : : "false", "true",
11978 : : "no", "yes",
11979 : : "N", "Y",
11980 : : "off", "on",
11981 : : NULL,
11982 : : };
11983 : :
11984 : : /**
11985 : : * Parse a boolean value.
11986 : : *
11987 : : * Last argument (ctx->args) is retrieved to determine storage size and
11988 : : * location.
11989 : : */
11990 : : static int
11991 : 0 : parse_boolean(struct context *ctx, const struct token *token,
11992 : : const char *str, unsigned int len,
11993 : : void *buf, unsigned int size)
11994 : : {
11995 : : const struct arg *arg = pop_args(ctx);
11996 : : unsigned int i;
11997 : : int ret;
11998 : :
11999 : : /* Argument is expected. */
12000 : 0 : if (!arg)
12001 : 0 : return -1;
12002 : 0 : for (i = 0; boolean_name[i]; ++i)
12003 : 0 : if (!strcmp_partial(boolean_name[i], str, len))
12004 : : break;
12005 : : /* Process token as integer. */
12006 : 0 : if (boolean_name[i])
12007 : 0 : str = i & 1 ? "1" : "0";
12008 : : push_args(ctx, arg);
12009 : 0 : ret = parse_int(ctx, token, str, strlen(str), buf, size);
12010 : 0 : return ret > 0 ? (int)len : ret;
12011 : : }
12012 : :
12013 : : /** Parse port and update context. */
12014 : : static int
12015 : 0 : parse_port(struct context *ctx, const struct token *token,
12016 : : const char *str, unsigned int len,
12017 : : void *buf, unsigned int size)
12018 : : {
12019 : 0 : struct buffer *out = &(struct buffer){ .port = 0 };
12020 : : int ret;
12021 : :
12022 : 0 : if (buf)
12023 : : out = buf;
12024 : : else {
12025 : 0 : ctx->objdata = 0;
12026 : 0 : ctx->object = out;
12027 : 0 : ctx->objmask = NULL;
12028 : : size = sizeof(*out);
12029 : : }
12030 : 0 : ret = parse_int(ctx, token, str, len, out, size);
12031 : 0 : if (ret >= 0)
12032 : 0 : ctx->port = out->port;
12033 : 0 : if (!buf)
12034 : 0 : ctx->object = NULL;
12035 : 0 : return ret;
12036 : : }
12037 : :
12038 : : /** Parse tokens for shared indirect actions. */
12039 : : static int
12040 : 0 : parse_ia_port(struct context *ctx, const struct token *token,
12041 : : const char *str, unsigned int len,
12042 : : void *buf, unsigned int size)
12043 : : {
12044 : 0 : struct rte_flow_action *action = ctx->object;
12045 : : uint32_t id;
12046 : : int ret;
12047 : :
12048 : : (void)buf;
12049 : : (void)size;
12050 : 0 : ctx->objdata = 0;
12051 : 0 : ctx->object = &id;
12052 : 0 : ctx->objmask = NULL;
12053 : 0 : ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
12054 : 0 : ctx->object = action;
12055 : 0 : if (ret != (int)len)
12056 : : return ret;
12057 : : /* set indirect action */
12058 : 0 : if (action)
12059 : 0 : action->conf = (void *)(uintptr_t)id;
12060 : : return ret;
12061 : : }
12062 : :
12063 : : static int
12064 : 0 : parse_ia_id2ptr(struct context *ctx, const struct token *token,
12065 : : const char *str, unsigned int len,
12066 : : void *buf, unsigned int size)
12067 : : {
12068 : 0 : struct rte_flow_action *action = ctx->object;
12069 : : uint32_t id;
12070 : : int ret;
12071 : :
12072 : : (void)buf;
12073 : : (void)size;
12074 : 0 : ctx->objdata = 0;
12075 : 0 : ctx->object = &id;
12076 : 0 : ctx->objmask = NULL;
12077 : 0 : ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
12078 : 0 : ctx->object = action;
12079 : 0 : if (ret != (int)len)
12080 : : return ret;
12081 : : /* set indirect action */
12082 : 0 : if (action) {
12083 : 0 : portid_t port_id = ctx->port;
12084 : 0 : if (ctx->prev == INDIRECT_ACTION_PORT)
12085 : 0 : port_id = (portid_t)(uintptr_t)action->conf;
12086 : 0 : action->conf = port_action_handle_get_by_id(port_id, id);
12087 : 0 : ret = (action->conf) ? ret : -1;
12088 : : }
12089 : : return ret;
12090 : : }
12091 : :
12092 : : static int
12093 : 0 : parse_indlst_id2ptr(struct context *ctx, const struct token *token,
12094 : : const char *str, unsigned int len,
12095 : : __rte_unused void *buf, __rte_unused unsigned int size)
12096 : : {
12097 : 0 : struct rte_flow_action *action = ctx->object;
12098 : : struct rte_flow_action_indirect_list *action_conf;
12099 : : const struct indlst_conf *indlst_conf;
12100 : : uint32_t id;
12101 : : int ret;
12102 : :
12103 : 0 : ctx->objdata = 0;
12104 : 0 : ctx->object = &id;
12105 : 0 : ctx->objmask = NULL;
12106 : 0 : ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
12107 : 0 : ctx->object = action;
12108 : 0 : if (ret != (int)len)
12109 : : return ret;
12110 : :
12111 : : /* set handle and conf */
12112 : 0 : if (action) {
12113 : 0 : action_conf = (void *)(uintptr_t)action->conf;
12114 : 0 : action_conf->conf = NULL;
12115 : 0 : switch (ctx->curr) {
12116 : 0 : case INDIRECT_LIST_ACTION_ID2PTR_HANDLE:
12117 : 0 : action_conf->handle = (typeof(action_conf->handle))
12118 : 0 : port_action_handle_get_by_id(ctx->port, id);
12119 : 0 : if (!action_conf->handle) {
12120 : 0 : printf("no indirect list handle for id %u\n", id);
12121 : 0 : return -1;
12122 : : }
12123 : : break;
12124 : 0 : case INDIRECT_LIST_ACTION_ID2PTR_CONF:
12125 : 0 : indlst_conf = indirect_action_list_conf_get(id);
12126 : 0 : if (!indlst_conf)
12127 : : return -1;
12128 : 0 : action_conf->conf = (const void **)indlst_conf->conf;
12129 : 0 : break;
12130 : : default:
12131 : : break;
12132 : : }
12133 : : }
12134 : : return ret;
12135 : : }
12136 : :
12137 : : static int
12138 : 0 : parse_meter_profile_id2ptr(struct context *ctx, const struct token *token,
12139 : : const char *str, unsigned int len,
12140 : : void *buf, unsigned int size)
12141 : : {
12142 : 0 : struct rte_flow_action *action = ctx->object;
12143 : : struct rte_flow_action_meter_mark *meter;
12144 : : struct rte_flow_meter_profile *profile = NULL;
12145 : 0 : uint32_t id = 0;
12146 : : int ret;
12147 : :
12148 : : (void)buf;
12149 : : (void)size;
12150 : 0 : ctx->objdata = 0;
12151 : 0 : ctx->object = &id;
12152 : 0 : ctx->objmask = NULL;
12153 : 0 : ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
12154 : 0 : ctx->object = action;
12155 : 0 : if (ret != (int)len)
12156 : : return ret;
12157 : : /* set meter profile */
12158 : 0 : if (action) {
12159 : 0 : meter = (struct rte_flow_action_meter_mark *)
12160 : : (uintptr_t)(action->conf);
12161 : 0 : profile = port_meter_profile_get_by_id(ctx->port, id);
12162 : 0 : meter->profile = profile;
12163 : 0 : ret = (profile) ? ret : -1;
12164 : : }
12165 : : return ret;
12166 : : }
12167 : :
12168 : : static int
12169 : 0 : parse_meter_policy_id2ptr(struct context *ctx, const struct token *token,
12170 : : const char *str, unsigned int len,
12171 : : void *buf, unsigned int size)
12172 : : {
12173 : 0 : struct rte_flow_action *action = ctx->object;
12174 : : struct rte_flow_action_meter_mark *meter;
12175 : : struct rte_flow_meter_policy *policy = NULL;
12176 : 0 : uint32_t id = 0;
12177 : : int ret;
12178 : :
12179 : : (void)buf;
12180 : : (void)size;
12181 : 0 : ctx->objdata = 0;
12182 : 0 : ctx->object = &id;
12183 : 0 : ctx->objmask = NULL;
12184 : 0 : ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id));
12185 : 0 : ctx->object = action;
12186 : 0 : if (ret != (int)len)
12187 : : return ret;
12188 : : /* set meter policy */
12189 : 0 : if (action) {
12190 : 0 : meter = (struct rte_flow_action_meter_mark *)
12191 : : (uintptr_t)(action->conf);
12192 : 0 : policy = port_meter_policy_get_by_id(ctx->port, id);
12193 : 0 : meter->policy = policy;
12194 : 0 : ret = (policy) ? ret : -1;
12195 : : }
12196 : : return ret;
12197 : : }
12198 : :
12199 : : /** Parse set command, initialize output buffer for subsequent tokens. */
12200 : : static int
12201 : 0 : parse_set_raw_encap_decap(struct context *ctx, const struct token *token,
12202 : : const char *str, unsigned int len,
12203 : : void *buf, unsigned int size)
12204 : : {
12205 : : struct buffer *out = buf;
12206 : :
12207 : : /* Token name must match. */
12208 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
12209 : : return -1;
12210 : : /* Nothing else to do if there is no buffer. */
12211 : 0 : if (!out)
12212 : : return len;
12213 : : /* Make sure buffer is large enough. */
12214 : 0 : if (size < sizeof(*out))
12215 : : return -1;
12216 : 0 : ctx->objdata = 0;
12217 : 0 : ctx->objmask = NULL;
12218 : 0 : ctx->object = out;
12219 : 0 : if (!out->command)
12220 : : return -1;
12221 : 0 : out->command = ctx->curr;
12222 : : /* For encap/decap we need is pattern */
12223 : 0 : out->args.vc.pattern = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
12224 : : sizeof(double));
12225 : 0 : return len;
12226 : : }
12227 : :
12228 : : /** Parse set command, initialize output buffer for subsequent tokens. */
12229 : : static int
12230 : 0 : parse_set_sample_action(struct context *ctx, const struct token *token,
12231 : : const char *str, unsigned int len,
12232 : : void *buf, unsigned int size)
12233 : : {
12234 : : struct buffer *out = buf;
12235 : :
12236 : : /* Token name must match. */
12237 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
12238 : : return -1;
12239 : : /* Nothing else to do if there is no buffer. */
12240 : 0 : if (!out)
12241 : : return len;
12242 : : /* Make sure buffer is large enough. */
12243 : 0 : if (size < sizeof(*out))
12244 : : return -1;
12245 : 0 : ctx->objdata = 0;
12246 : 0 : ctx->objmask = NULL;
12247 : 0 : ctx->object = out;
12248 : 0 : if (!out->command)
12249 : : return -1;
12250 : 0 : out->command = ctx->curr;
12251 : : /* For sampler we need is actions */
12252 : 0 : out->args.vc.actions = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
12253 : : sizeof(double));
12254 : 0 : return len;
12255 : : }
12256 : :
12257 : : /** Parse set command, initialize output buffer for subsequent tokens. */
12258 : : static int
12259 : 0 : parse_set_ipv6_ext_action(struct context *ctx, const struct token *token,
12260 : : const char *str, unsigned int len,
12261 : : void *buf, unsigned int size)
12262 : : {
12263 : : struct buffer *out = buf;
12264 : :
12265 : : /* Token name must match. */
12266 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
12267 : : return -1;
12268 : : /* Nothing else to do if there is no buffer. */
12269 : 0 : if (!out)
12270 : : return len;
12271 : : /* Make sure buffer is large enough. */
12272 : 0 : if (size < sizeof(*out))
12273 : : return -1;
12274 : 0 : ctx->objdata = 0;
12275 : 0 : ctx->objmask = NULL;
12276 : 0 : ctx->object = out;
12277 : 0 : if (!out->command)
12278 : : return -1;
12279 : 0 : out->command = ctx->curr;
12280 : : /* For ipv6_ext_push/remove we need is pattern */
12281 : 0 : out->args.vc.pattern = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
12282 : : sizeof(double));
12283 : 0 : return len;
12284 : : }
12285 : :
12286 : : /**
12287 : : * Parse set raw_encap/raw_decap command,
12288 : : * initialize output buffer for subsequent tokens.
12289 : : */
12290 : : static int
12291 : 0 : parse_set_init(struct context *ctx, const struct token *token,
12292 : : const char *str, unsigned int len,
12293 : : void *buf, unsigned int size)
12294 : : {
12295 : : struct buffer *out = buf;
12296 : :
12297 : : /* Token name must match. */
12298 : 0 : if (parse_default(ctx, token, str, len, NULL, 0) < 0)
12299 : : return -1;
12300 : : /* Nothing else to do if there is no buffer. */
12301 : 0 : if (!out)
12302 : : return len;
12303 : : /* Make sure buffer is large enough. */
12304 : 0 : if (size < sizeof(*out))
12305 : : return -1;
12306 : : /* Initialize buffer. */
12307 : : memset(out, 0x00, sizeof(*out));
12308 : 0 : memset((uint8_t *)out + sizeof(*out), 0x22, size - sizeof(*out));
12309 : 0 : ctx->objdata = 0;
12310 : 0 : ctx->object = out;
12311 : 0 : ctx->objmask = NULL;
12312 : : if (!out->command) {
12313 : 0 : if (ctx->curr != SET)
12314 : : return -1;
12315 : : if (sizeof(*out) > size)
12316 : : return -1;
12317 : 0 : out->command = ctx->curr;
12318 : 0 : out->args.vc.data = (uint8_t *)out + size;
12319 : 0 : ctx->object = (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
12320 : : sizeof(double));
12321 : : }
12322 : 0 : return len;
12323 : : }
12324 : :
12325 : : /*
12326 : : * Replace testpmd handles in a flex flow item with real values.
12327 : : */
12328 : : static int
12329 : 0 : parse_flex_handle(struct context *ctx, const struct token *token,
12330 : : const char *str, unsigned int len,
12331 : : void *buf, unsigned int size)
12332 : : {
12333 : : struct rte_flow_item_flex *spec, *mask;
12334 : : const struct rte_flow_item_flex *src_spec, *src_mask;
12335 : : const struct arg *arg = pop_args(ctx);
12336 : : uint32_t offset;
12337 : : uint16_t handle;
12338 : : int ret;
12339 : :
12340 : 0 : if (!arg) {
12341 : : printf("Bad environment\n");
12342 : 0 : return -1;
12343 : : }
12344 : 0 : offset = arg->offset;
12345 : : push_args(ctx, arg);
12346 : 0 : ret = parse_int(ctx, token, str, len, buf, size);
12347 : 0 : if (ret <= 0 || !ctx->object)
12348 : : return ret;
12349 : 0 : if (ctx->port >= RTE_MAX_ETHPORTS) {
12350 : : printf("Bad port\n");
12351 : 0 : return -1;
12352 : : }
12353 : 0 : if (offset == offsetof(struct rte_flow_item_flex, handle)) {
12354 : : const struct flex_item *fp;
12355 : : spec = ctx->object;
12356 : 0 : handle = (uint16_t)(uintptr_t)spec->handle;
12357 : 0 : if (handle >= FLEX_MAX_PARSERS_NUM) {
12358 : : printf("Bad flex item handle\n");
12359 : 0 : return -1;
12360 : : }
12361 : 0 : fp = flex_items[ctx->port][handle];
12362 : 0 : if (!fp) {
12363 : : printf("Bad flex item handle\n");
12364 : 0 : return -1;
12365 : : }
12366 : 0 : spec->handle = fp->flex_handle;
12367 : : mask = spec + 2; /* spec, last, mask */
12368 : 0 : mask->handle = fp->flex_handle;
12369 : 0 : } else if (offset == offsetof(struct rte_flow_item_flex, pattern)) {
12370 : 0 : handle = (uint16_t)(uintptr_t)
12371 : 0 : ((struct rte_flow_item_flex *)ctx->object)->pattern;
12372 : 0 : if (handle >= FLEX_MAX_PATTERNS_NUM) {
12373 : : printf("Bad pattern handle\n");
12374 : 0 : return -1;
12375 : : }
12376 : 0 : src_spec = &flex_patterns[handle].spec;
12377 : : src_mask = &flex_patterns[handle].mask;
12378 : : spec = ctx->object;
12379 : : mask = spec + 2; /* spec, last, mask */
12380 : : /* fill flow rule spec and mask parameters */
12381 : 0 : spec->length = src_spec->length;
12382 : 0 : spec->pattern = src_spec->pattern;
12383 : 0 : mask->length = src_mask->length;
12384 : 0 : mask->pattern = src_mask->pattern;
12385 : : } else {
12386 : : printf("Bad arguments - unknown flex item offset\n");
12387 : 0 : return -1;
12388 : : }
12389 : : return ret;
12390 : : }
12391 : :
12392 : : /** Parse Meter color name */
12393 : : static int
12394 : 0 : parse_meter_color(struct context *ctx, const struct token *token,
12395 : : const char *str, unsigned int len, void *buf,
12396 : : unsigned int size)
12397 : : {
12398 : : unsigned int i;
12399 : : struct buffer *out = buf;
12400 : :
12401 : : (void)token;
12402 : : (void)buf;
12403 : : (void)size;
12404 : 0 : for (i = 0; meter_colors[i]; ++i)
12405 : 0 : if (!strcmp_partial(meter_colors[i], str, len))
12406 : : break;
12407 : 0 : if (!meter_colors[i])
12408 : : return -1;
12409 : 0 : if (!ctx->object)
12410 : 0 : return len;
12411 : 0 : if (ctx->prev == ACTION_METER_MARK_CONF_COLOR) {
12412 : 0 : struct rte_flow_action *action =
12413 : 0 : out->args.vc.actions + out->args.vc.actions_n - 1;
12414 : : const struct arg *arg = pop_args(ctx);
12415 : :
12416 : 0 : if (!arg)
12417 : 0 : return -1;
12418 : 0 : *(int *)RTE_PTR_ADD(action->conf, arg->offset) = i;
12419 : : } else {
12420 : : ((struct rte_flow_item_meter_color *)
12421 : 0 : ctx->object)->color = (enum rte_color)i;
12422 : : }
12423 : 0 : return len;
12424 : : }
12425 : :
12426 : : /** Parse Insertion Table Type name */
12427 : : static int
12428 : 0 : parse_insertion_table_type(struct context *ctx, const struct token *token,
12429 : : const char *str, unsigned int len, void *buf,
12430 : : unsigned int size)
12431 : : {
12432 : : const struct arg *arg = pop_args(ctx);
12433 : : unsigned int i;
12434 : : char tmp[2];
12435 : : int ret;
12436 : :
12437 : : (void)size;
12438 : : /* Argument is expected. */
12439 : 0 : if (!arg)
12440 : 0 : return -1;
12441 : 0 : for (i = 0; table_insertion_types[i]; ++i)
12442 : 0 : if (!strcmp_partial(table_insertion_types[i], str, len))
12443 : : break;
12444 : 0 : if (!table_insertion_types[i])
12445 : : return -1;
12446 : : push_args(ctx, arg);
12447 : : snprintf(tmp, sizeof(tmp), "%u", i);
12448 : 0 : ret = parse_int(ctx, token, tmp, strlen(tmp), buf, sizeof(i));
12449 : 0 : return ret > 0 ? (int)len : ret;
12450 : : }
12451 : :
12452 : : /** Parse Hash Calculation Table Type name */
12453 : : static int
12454 : 0 : parse_hash_table_type(struct context *ctx, const struct token *token,
12455 : : const char *str, unsigned int len, void *buf,
12456 : : unsigned int size)
12457 : : {
12458 : : const struct arg *arg = pop_args(ctx);
12459 : : unsigned int i;
12460 : : char tmp[2];
12461 : : int ret;
12462 : :
12463 : : (void)size;
12464 : : /* Argument is expected. */
12465 : 0 : if (!arg)
12466 : 0 : return -1;
12467 : 0 : for (i = 0; table_hash_funcs[i]; ++i)
12468 : 0 : if (!strcmp_partial(table_hash_funcs[i], str, len))
12469 : : break;
12470 : 0 : if (!table_hash_funcs[i])
12471 : : return -1;
12472 : : push_args(ctx, arg);
12473 : : snprintf(tmp, sizeof(tmp), "%u", i);
12474 : 0 : ret = parse_int(ctx, token, tmp, strlen(tmp), buf, sizeof(i));
12475 : 0 : return ret > 0 ? (int)len : ret;
12476 : : }
12477 : :
12478 : : static int
12479 : 0 : parse_name_to_index(struct context *ctx, const struct token *token,
12480 : : const char *str, unsigned int len, void *buf,
12481 : : unsigned int size,
12482 : : const char *const names[], size_t names_size, uint32_t *dst)
12483 : : {
12484 : : int ret;
12485 : : uint32_t i;
12486 : :
12487 : : RTE_SET_USED(token);
12488 : : RTE_SET_USED(buf);
12489 : : RTE_SET_USED(size);
12490 : 0 : if (!ctx->object)
12491 : 0 : return len;
12492 : 0 : for (i = 0; i < names_size; i++) {
12493 : 0 : if (!names[i])
12494 : 0 : continue;
12495 : 0 : ret = strcmp_partial(names[i], str,
12496 : 0 : RTE_MIN(len, strlen(names[i])));
12497 : 0 : if (!ret) {
12498 : 0 : *dst = i;
12499 : 0 : return len;
12500 : : }
12501 : : }
12502 : : return -1;
12503 : : }
12504 : :
12505 : : static const char *const quota_mode_names[] = {
12506 : : NULL,
12507 : : [RTE_FLOW_QUOTA_MODE_PACKET] = "packet",
12508 : : [RTE_FLOW_QUOTA_MODE_L2] = "l2",
12509 : : [RTE_FLOW_QUOTA_MODE_L3] = "l3"
12510 : : };
12511 : :
12512 : : static const char *const quota_state_names[] = {
12513 : : [RTE_FLOW_QUOTA_STATE_PASS] = "pass",
12514 : : [RTE_FLOW_QUOTA_STATE_BLOCK] = "block"
12515 : : };
12516 : :
12517 : : static const char *const quota_update_names[] = {
12518 : : [RTE_FLOW_UPDATE_QUOTA_SET] = "set",
12519 : : [RTE_FLOW_UPDATE_QUOTA_ADD] = "add"
12520 : : };
12521 : :
12522 : : static const char *const query_update_mode_names[] = {
12523 : : [RTE_FLOW_QU_QUERY_FIRST] = "query_first",
12524 : : [RTE_FLOW_QU_UPDATE_FIRST] = "update_first"
12525 : : };
12526 : :
12527 : : static int
12528 : 0 : parse_quota_state_name(struct context *ctx, const struct token *token,
12529 : : const char *str, unsigned int len, void *buf,
12530 : : unsigned int size)
12531 : : {
12532 : 0 : struct rte_flow_item_quota *quota = ctx->object;
12533 : :
12534 : 0 : return parse_name_to_index(ctx, token, str, len, buf, size,
12535 : : quota_state_names,
12536 : : RTE_DIM(quota_state_names),
12537 : 0 : (uint32_t *)"a->state);
12538 : : }
12539 : :
12540 : : static int
12541 : 0 : parse_quota_mode_name(struct context *ctx, const struct token *token,
12542 : : const char *str, unsigned int len, void *buf,
12543 : : unsigned int size)
12544 : : {
12545 : 0 : struct rte_flow_action_quota *quota = ctx->object;
12546 : :
12547 : 0 : return parse_name_to_index(ctx, token, str, len, buf, size,
12548 : : quota_mode_names,
12549 : : RTE_DIM(quota_mode_names),
12550 : 0 : (uint32_t *)"a->mode);
12551 : : }
12552 : :
12553 : : static int
12554 : 0 : parse_quota_update_name(struct context *ctx, const struct token *token,
12555 : : const char *str, unsigned int len, void *buf,
12556 : : unsigned int size)
12557 : : {
12558 : 0 : struct rte_flow_update_quota *update = ctx->object;
12559 : :
12560 : 0 : return parse_name_to_index(ctx, token, str, len, buf, size,
12561 : : quota_update_names,
12562 : : RTE_DIM(quota_update_names),
12563 : 0 : (uint32_t *)&update->op);
12564 : : }
12565 : :
12566 : : static int
12567 : 0 : parse_qu_mode_name(struct context *ctx, const struct token *token,
12568 : : const char *str, unsigned int len, void *buf,
12569 : : unsigned int size)
12570 : : {
12571 : 0 : struct buffer *out = ctx->object;
12572 : :
12573 : 0 : return parse_name_to_index(ctx, token, str, len, buf, size,
12574 : : query_update_mode_names,
12575 : : RTE_DIM(query_update_mode_names),
12576 : 0 : (uint32_t *)&out->args.ia.qu_mode);
12577 : : }
12578 : :
12579 : : /** No completion. */
12580 : : static int
12581 : 0 : comp_none(struct context *ctx, const struct token *token,
12582 : : unsigned int ent, char *buf, unsigned int size)
12583 : : {
12584 : : (void)ctx;
12585 : : (void)token;
12586 : : (void)ent;
12587 : : (void)buf;
12588 : : (void)size;
12589 : 0 : return 0;
12590 : : }
12591 : :
12592 : : /** Complete boolean values. */
12593 : : static int
12594 : 0 : comp_boolean(struct context *ctx, const struct token *token,
12595 : : unsigned int ent, char *buf, unsigned int size)
12596 : : {
12597 : : unsigned int i;
12598 : :
12599 : : (void)ctx;
12600 : : (void)token;
12601 : 0 : for (i = 0; boolean_name[i]; ++i)
12602 : 0 : if (buf && i == ent)
12603 : 0 : return strlcpy(buf, boolean_name[i], size);
12604 : 0 : if (buf)
12605 : : return -1;
12606 : 0 : return i;
12607 : : }
12608 : :
12609 : : /** Complete action names. */
12610 : : static int
12611 : 0 : comp_action(struct context *ctx, const struct token *token,
12612 : : unsigned int ent, char *buf, unsigned int size)
12613 : : {
12614 : : unsigned int i;
12615 : :
12616 : : (void)ctx;
12617 : : (void)token;
12618 : 0 : for (i = 0; next_action[i]; ++i)
12619 : 0 : if (buf && i == ent)
12620 : 0 : return strlcpy(buf, token_list[next_action[i]].name,
12621 : : size);
12622 : 0 : if (buf)
12623 : : return -1;
12624 : 0 : return i;
12625 : : }
12626 : :
12627 : : /** Complete available ports. */
12628 : : static int
12629 : 0 : comp_port(struct context *ctx, const struct token *token,
12630 : : unsigned int ent, char *buf, unsigned int size)
12631 : : {
12632 : : unsigned int i = 0;
12633 : : portid_t p;
12634 : :
12635 : : (void)ctx;
12636 : : (void)token;
12637 : 0 : RTE_ETH_FOREACH_DEV(p) {
12638 : 0 : if (buf && i == ent)
12639 : 0 : return snprintf(buf, size, "%u", p);
12640 : 0 : ++i;
12641 : : }
12642 : 0 : if (buf)
12643 : : return -1;
12644 : 0 : return i;
12645 : : }
12646 : :
12647 : : /** Complete available rule IDs. */
12648 : : static int
12649 : 0 : comp_rule_id(struct context *ctx, const struct token *token,
12650 : : unsigned int ent, char *buf, unsigned int size)
12651 : : {
12652 : : unsigned int i = 0;
12653 : : struct rte_port *port;
12654 : : struct port_flow *pf;
12655 : :
12656 : : (void)token;
12657 : 0 : if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
12658 : 0 : ctx->port == (portid_t)RTE_PORT_ALL)
12659 : : return -1;
12660 : 0 : port = &ports[ctx->port];
12661 : 0 : for (pf = port->flow_list; pf != NULL; pf = pf->next) {
12662 : 0 : if (buf && i == ent)
12663 : 0 : return snprintf(buf, size, "%"PRIu64, pf->id);
12664 : 0 : ++i;
12665 : : }
12666 : 0 : if (buf)
12667 : : return -1;
12668 : 0 : return i;
12669 : : }
12670 : :
12671 : : /** Complete operation for compare match item. */
12672 : : static int
12673 : 0 : comp_set_compare_op(struct context *ctx, const struct token *token,
12674 : : unsigned int ent, char *buf, unsigned int size)
12675 : : {
12676 : : RTE_SET_USED(ctx);
12677 : : RTE_SET_USED(token);
12678 : 0 : if (!buf)
12679 : : return RTE_DIM(compare_ops);
12680 : 0 : if (ent < RTE_DIM(compare_ops) - 1)
12681 : 0 : return strlcpy(buf, compare_ops[ent], size);
12682 : : return -1;
12683 : : }
12684 : :
12685 : : /** Complete field id for compare match item. */
12686 : : static int
12687 : 0 : comp_set_compare_field_id(struct context *ctx, const struct token *token,
12688 : : unsigned int ent, char *buf, unsigned int size)
12689 : : {
12690 : : const char *name;
12691 : :
12692 : : RTE_SET_USED(token);
12693 : 0 : if (!buf)
12694 : : return RTE_DIM(flow_field_ids);
12695 : 0 : if (ent >= RTE_DIM(flow_field_ids) - 1)
12696 : : return -1;
12697 : 0 : name = flow_field_ids[ent];
12698 : 0 : if (ctx->curr == ITEM_COMPARE_FIELD_B_TYPE ||
12699 : 0 : (strcmp(name, "pointer") && strcmp(name, "value")))
12700 : 0 : return strlcpy(buf, name, size);
12701 : : return -1;
12702 : : }
12703 : :
12704 : : /** Complete type field for RSS action. */
12705 : : static int
12706 : 0 : comp_vc_action_rss_type(struct context *ctx, const struct token *token,
12707 : : unsigned int ent, char *buf, unsigned int size)
12708 : : {
12709 : : unsigned int i;
12710 : :
12711 : : (void)ctx;
12712 : : (void)token;
12713 : 0 : for (i = 0; rss_type_table[i].str; ++i)
12714 : : ;
12715 : 0 : if (!buf)
12716 : 0 : return i + 1;
12717 : 0 : if (ent < i)
12718 : 0 : return strlcpy(buf, rss_type_table[ent].str, size);
12719 : 0 : if (ent == i)
12720 : 0 : return snprintf(buf, size, "end");
12721 : : return -1;
12722 : : }
12723 : :
12724 : : /** Complete queue field for RSS action. */
12725 : : static int
12726 : 0 : comp_vc_action_rss_queue(struct context *ctx, const struct token *token,
12727 : : unsigned int ent, char *buf, unsigned int size)
12728 : : {
12729 : : (void)ctx;
12730 : : (void)token;
12731 : 0 : if (!buf)
12732 : 0 : return nb_rxq + 1;
12733 : 0 : if (ent < nb_rxq)
12734 : 0 : return snprintf(buf, size, "%u", ent);
12735 : 0 : if (ent == nb_rxq)
12736 : 0 : return snprintf(buf, size, "end");
12737 : : return -1;
12738 : : }
12739 : :
12740 : : /** Complete index number for set raw_encap/raw_decap commands. */
12741 : : static int
12742 : 0 : comp_set_raw_index(struct context *ctx, const struct token *token,
12743 : : unsigned int ent, char *buf, unsigned int size)
12744 : : {
12745 : : uint16_t idx = 0;
12746 : : uint16_t nb = 0;
12747 : :
12748 : : RTE_SET_USED(ctx);
12749 : : RTE_SET_USED(token);
12750 : 0 : for (idx = 0; idx < RAW_ENCAP_CONFS_MAX_NUM; ++idx) {
12751 : 0 : if (buf && idx == ent)
12752 : 0 : return snprintf(buf, size, "%u", idx);
12753 : 0 : ++nb;
12754 : : }
12755 : : return nb;
12756 : : }
12757 : :
12758 : : /** Complete index number for set raw_ipv6_ext_push/ipv6_ext_remove commands. */
12759 : : static int
12760 : 0 : comp_set_ipv6_ext_index(struct context *ctx, const struct token *token,
12761 : : unsigned int ent, char *buf, unsigned int size)
12762 : : {
12763 : : uint16_t idx = 0;
12764 : : uint16_t nb = 0;
12765 : :
12766 : : RTE_SET_USED(ctx);
12767 : : RTE_SET_USED(token);
12768 : 0 : for (idx = 0; idx < IPV6_EXT_PUSH_CONFS_MAX_NUM; ++idx) {
12769 : 0 : if (buf && idx == ent)
12770 : 0 : return snprintf(buf, size, "%u", idx);
12771 : 0 : ++nb;
12772 : : }
12773 : : return nb;
12774 : : }
12775 : :
12776 : : /** Complete index number for set raw_encap/raw_decap commands. */
12777 : : static int
12778 : 0 : comp_set_sample_index(struct context *ctx, const struct token *token,
12779 : : unsigned int ent, char *buf, unsigned int size)
12780 : : {
12781 : : uint16_t idx = 0;
12782 : : uint16_t nb = 0;
12783 : :
12784 : : RTE_SET_USED(ctx);
12785 : : RTE_SET_USED(token);
12786 : 0 : for (idx = 0; idx < RAW_SAMPLE_CONFS_MAX_NUM; ++idx) {
12787 : 0 : if (buf && idx == ent)
12788 : 0 : return snprintf(buf, size, "%u", idx);
12789 : 0 : ++nb;
12790 : : }
12791 : : return nb;
12792 : : }
12793 : :
12794 : : /** Complete operation for modify_field command. */
12795 : : static int
12796 : 0 : comp_set_modify_field_op(struct context *ctx, const struct token *token,
12797 : : unsigned int ent, char *buf, unsigned int size)
12798 : : {
12799 : : RTE_SET_USED(ctx);
12800 : : RTE_SET_USED(token);
12801 : 0 : if (!buf)
12802 : : return RTE_DIM(modify_field_ops);
12803 : 0 : if (ent < RTE_DIM(modify_field_ops) - 1)
12804 : 0 : return strlcpy(buf, modify_field_ops[ent], size);
12805 : : return -1;
12806 : : }
12807 : :
12808 : : /** Complete field id for modify_field command. */
12809 : : static int
12810 : 0 : comp_set_modify_field_id(struct context *ctx, const struct token *token,
12811 : : unsigned int ent, char *buf, unsigned int size)
12812 : : {
12813 : : const char *name;
12814 : :
12815 : : RTE_SET_USED(token);
12816 : 0 : if (!buf)
12817 : : return RTE_DIM(flow_field_ids);
12818 : 0 : if (ent >= RTE_DIM(flow_field_ids) - 1)
12819 : : return -1;
12820 : 0 : name = flow_field_ids[ent];
12821 : 0 : if (ctx->curr == ACTION_MODIFY_FIELD_SRC_TYPE ||
12822 : 0 : (strcmp(name, "pointer") && strcmp(name, "value")))
12823 : 0 : return strlcpy(buf, name, size);
12824 : : return -1;
12825 : : }
12826 : :
12827 : : /** Complete available pattern template IDs. */
12828 : : static int
12829 : 0 : comp_pattern_template_id(struct context *ctx, const struct token *token,
12830 : : unsigned int ent, char *buf, unsigned int size)
12831 : : {
12832 : : unsigned int i = 0;
12833 : : struct rte_port *port;
12834 : : struct port_template *pt;
12835 : :
12836 : : (void)token;
12837 : 0 : if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
12838 : 0 : ctx->port == (portid_t)RTE_PORT_ALL)
12839 : : return -1;
12840 : 0 : port = &ports[ctx->port];
12841 : 0 : for (pt = port->pattern_templ_list; pt != NULL; pt = pt->next) {
12842 : 0 : if (buf && i == ent)
12843 : 0 : return snprintf(buf, size, "%u", pt->id);
12844 : 0 : ++i;
12845 : : }
12846 : 0 : if (buf)
12847 : : return -1;
12848 : 0 : return i;
12849 : : }
12850 : :
12851 : : /** Complete available actions template IDs. */
12852 : : static int
12853 : 0 : comp_actions_template_id(struct context *ctx, const struct token *token,
12854 : : unsigned int ent, char *buf, unsigned int size)
12855 : : {
12856 : : unsigned int i = 0;
12857 : : struct rte_port *port;
12858 : : struct port_template *pt;
12859 : :
12860 : : (void)token;
12861 : 0 : if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
12862 : 0 : ctx->port == (portid_t)RTE_PORT_ALL)
12863 : : return -1;
12864 : 0 : port = &ports[ctx->port];
12865 : 0 : for (pt = port->actions_templ_list; pt != NULL; pt = pt->next) {
12866 : 0 : if (buf && i == ent)
12867 : 0 : return snprintf(buf, size, "%u", pt->id);
12868 : 0 : ++i;
12869 : : }
12870 : 0 : if (buf)
12871 : : return -1;
12872 : 0 : return i;
12873 : : }
12874 : :
12875 : : /** Complete available table IDs. */
12876 : : static int
12877 : 0 : comp_table_id(struct context *ctx, const struct token *token,
12878 : : unsigned int ent, char *buf, unsigned int size)
12879 : : {
12880 : : unsigned int i = 0;
12881 : : struct rte_port *port;
12882 : : struct port_table *pt;
12883 : :
12884 : : (void)token;
12885 : 0 : if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
12886 : 0 : ctx->port == (portid_t)RTE_PORT_ALL)
12887 : : return -1;
12888 : 0 : port = &ports[ctx->port];
12889 : 0 : for (pt = port->table_list; pt != NULL; pt = pt->next) {
12890 : 0 : if (buf && i == ent)
12891 : 0 : return snprintf(buf, size, "%u", pt->id);
12892 : 0 : ++i;
12893 : : }
12894 : 0 : if (buf)
12895 : : return -1;
12896 : 0 : return i;
12897 : : }
12898 : :
12899 : : /** Complete available queue IDs. */
12900 : : static int
12901 : 0 : comp_queue_id(struct context *ctx, const struct token *token,
12902 : : unsigned int ent, char *buf, unsigned int size)
12903 : : {
12904 : : unsigned int i = 0;
12905 : : struct rte_port *port;
12906 : :
12907 : : (void)token;
12908 : 0 : if (port_id_is_invalid(ctx->port, DISABLED_WARN) ||
12909 : 0 : ctx->port == (portid_t)RTE_PORT_ALL)
12910 : : return -1;
12911 : 0 : port = &ports[ctx->port];
12912 : 0 : for (i = 0; i < port->queue_nb; i++) {
12913 : 0 : if (buf && i == ent)
12914 : 0 : return snprintf(buf, size, "%u", i);
12915 : : }
12916 : 0 : if (buf)
12917 : : return -1;
12918 : 0 : return i;
12919 : : }
12920 : :
12921 : : static int
12922 : : comp_names_to_index(struct context *ctx, const struct token *token,
12923 : : unsigned int ent, char *buf, unsigned int size,
12924 : : const char *const names[], size_t names_size)
12925 : : {
12926 : : RTE_SET_USED(ctx);
12927 : : RTE_SET_USED(token);
12928 : 0 : if (!buf)
12929 : : return names_size;
12930 : 0 : if (ent < names_size && names[ent] != NULL)
12931 : 0 : return rte_strscpy(buf, names[ent], size);
12932 : : return -1;
12933 : :
12934 : : }
12935 : :
12936 : : /** Complete available Meter colors. */
12937 : : static int
12938 : 0 : comp_meter_color(struct context *ctx, const struct token *token,
12939 : : unsigned int ent, char *buf, unsigned int size)
12940 : : {
12941 : : RTE_SET_USED(ctx);
12942 : : RTE_SET_USED(token);
12943 : 0 : if (!buf)
12944 : : return RTE_DIM(meter_colors);
12945 : 0 : if (ent < RTE_DIM(meter_colors) - 1)
12946 : 0 : return strlcpy(buf, meter_colors[ent], size);
12947 : : return -1;
12948 : : }
12949 : :
12950 : : /** Complete available Insertion Table types. */
12951 : : static int
12952 : 0 : comp_insertion_table_type(struct context *ctx, const struct token *token,
12953 : : unsigned int ent, char *buf, unsigned int size)
12954 : : {
12955 : : RTE_SET_USED(ctx);
12956 : : RTE_SET_USED(token);
12957 : 0 : if (!buf)
12958 : : return RTE_DIM(table_insertion_types);
12959 : 0 : if (ent < RTE_DIM(table_insertion_types) - 1)
12960 : 0 : return rte_strscpy(buf, table_insertion_types[ent], size);
12961 : : return -1;
12962 : : }
12963 : :
12964 : : /** Complete available Hash Calculation Table types. */
12965 : : static int
12966 : 0 : comp_hash_table_type(struct context *ctx, const struct token *token,
12967 : : unsigned int ent, char *buf, unsigned int size)
12968 : : {
12969 : : RTE_SET_USED(ctx);
12970 : : RTE_SET_USED(token);
12971 : 0 : if (!buf)
12972 : : return RTE_DIM(table_hash_funcs);
12973 : 0 : if (ent < RTE_DIM(table_hash_funcs) - 1)
12974 : 0 : return rte_strscpy(buf, table_hash_funcs[ent], size);
12975 : : return -1;
12976 : : }
12977 : :
12978 : : static int
12979 : 0 : comp_quota_state_name(struct context *ctx, const struct token *token,
12980 : : unsigned int ent, char *buf, unsigned int size)
12981 : : {
12982 : 0 : return comp_names_to_index(ctx, token, ent, buf, size,
12983 : : quota_state_names,
12984 : : RTE_DIM(quota_state_names));
12985 : : }
12986 : :
12987 : : static int
12988 : 0 : comp_quota_mode_name(struct context *ctx, const struct token *token,
12989 : : unsigned int ent, char *buf, unsigned int size)
12990 : : {
12991 : 0 : return comp_names_to_index(ctx, token, ent, buf, size,
12992 : : quota_mode_names,
12993 : : RTE_DIM(quota_mode_names));
12994 : : }
12995 : :
12996 : : static int
12997 : 0 : comp_quota_update_name(struct context *ctx, const struct token *token,
12998 : : unsigned int ent, char *buf, unsigned int size)
12999 : : {
13000 : 0 : return comp_names_to_index(ctx, token, ent, buf, size,
13001 : : quota_update_names,
13002 : : RTE_DIM(quota_update_names));
13003 : : }
13004 : :
13005 : : static int
13006 : 0 : comp_qu_mode_name(struct context *ctx, const struct token *token,
13007 : : unsigned int ent, char *buf, unsigned int size)
13008 : : {
13009 : 0 : return comp_names_to_index(ctx, token, ent, buf, size,
13010 : : query_update_mode_names,
13011 : : RTE_DIM(query_update_mode_names));
13012 : : }
13013 : :
13014 : : /** Internal context. */
13015 : : static struct context cmd_flow_context;
13016 : :
13017 : : /** Global parser instance (cmdline API). */
13018 : : cmdline_parse_inst_t cmd_flow;
13019 : : cmdline_parse_inst_t cmd_set_raw;
13020 : :
13021 : : /** Initialize context. */
13022 : : static void
13023 : : cmd_flow_context_init(struct context *ctx)
13024 : : {
13025 : : /* A full memset() is not necessary. */
13026 : 0 : ctx->curr = ZERO;
13027 : 0 : ctx->prev = ZERO;
13028 : 0 : ctx->next_num = 0;
13029 : 0 : ctx->args_num = 0;
13030 : 0 : ctx->eol = 0;
13031 : 0 : ctx->last = 0;
13032 : 0 : ctx->port = 0;
13033 : 0 : ctx->objdata = 0;
13034 : 0 : ctx->object = NULL;
13035 : 0 : ctx->objmask = NULL;
13036 : 0 : }
13037 : :
13038 : : /** Parse a token (cmdline API). */
13039 : : static int
13040 : 0 : cmd_flow_parse(cmdline_parse_token_hdr_t *hdr, const char *src, void *result,
13041 : : unsigned int size)
13042 : : {
13043 : : struct context *ctx = &cmd_flow_context;
13044 : : const struct token *token;
13045 : : const enum index *list;
13046 : : int len;
13047 : : int i;
13048 : :
13049 : : (void)hdr;
13050 : 0 : token = &token_list[ctx->curr];
13051 : : /* Check argument length. */
13052 : 0 : ctx->eol = 0;
13053 : 0 : ctx->last = 1;
13054 : 0 : for (len = 0; src[len]; ++len)
13055 : 0 : if (src[len] == '#' || isspace(src[len]))
13056 : : break;
13057 : 0 : if (!len)
13058 : : return -1;
13059 : : /* Last argument and EOL detection. */
13060 : 0 : for (i = len; src[i]; ++i)
13061 : 0 : if (src[i] == '#' || src[i] == '\r' || src[i] == '\n')
13062 : : break;
13063 : 0 : else if (!isspace(src[i])) {
13064 : 0 : ctx->last = 0;
13065 : 0 : break;
13066 : : }
13067 : 0 : for (; src[i]; ++i)
13068 : 0 : if (src[i] == '\r' || src[i] == '\n') {
13069 : 0 : ctx->eol = 1;
13070 : 0 : break;
13071 : : }
13072 : : /* Initialize context if necessary. */
13073 : 0 : if (!ctx->next_num) {
13074 : 0 : if (!token->next)
13075 : : return 0;
13076 : 0 : ctx->next[ctx->next_num++] = token->next[0];
13077 : : }
13078 : : /* Process argument through candidates. */
13079 : 0 : ctx->prev = ctx->curr;
13080 : 0 : list = ctx->next[ctx->next_num - 1];
13081 : 0 : for (i = 0; list[i]; ++i) {
13082 : 0 : const struct token *next = &token_list[list[i]];
13083 : : int tmp;
13084 : :
13085 : 0 : ctx->curr = list[i];
13086 : 0 : if (next->call)
13087 : 0 : tmp = next->call(ctx, next, src, len, result, size);
13088 : : else
13089 : : tmp = parse_default(ctx, next, src, len, result, size);
13090 : 0 : if (tmp == -1 || tmp != len)
13091 : : continue;
13092 : : token = next;
13093 : : break;
13094 : : }
13095 : 0 : if (!list[i])
13096 : : return -1;
13097 : 0 : --ctx->next_num;
13098 : : /* Push subsequent tokens if any. */
13099 : 0 : if (token->next)
13100 : 0 : for (i = 0; token->next[i]; ++i) {
13101 : 0 : if (ctx->next_num == RTE_DIM(ctx->next))
13102 : : return -1;
13103 : 0 : ctx->next[ctx->next_num++] = token->next[i];
13104 : : }
13105 : : /* Push arguments if any. */
13106 : 0 : if (token->args)
13107 : 0 : for (i = 0; token->args[i]; ++i) {
13108 : 0 : if (ctx->args_num == RTE_DIM(ctx->args))
13109 : : return -1;
13110 : 0 : ctx->args[ctx->args_num++] = token->args[i];
13111 : : }
13112 : : return len;
13113 : : }
13114 : :
13115 : : int
13116 : 0 : flow_parse(const char *src, void *result, unsigned int size,
13117 : : struct rte_flow_attr **attr,
13118 : : struct rte_flow_item **pattern, struct rte_flow_action **actions)
13119 : : {
13120 : : int ret;
13121 : 0 : struct context saved_flow_ctx = cmd_flow_context;
13122 : :
13123 : : cmd_flow_context_init(&cmd_flow_context);
13124 : : do {
13125 : 0 : ret = cmd_flow_parse(NULL, src, result, size);
13126 : 0 : if (ret > 0) {
13127 : 0 : src += ret;
13128 : 0 : while (isspace(*src))
13129 : 0 : src++;
13130 : : }
13131 : 0 : } while (ret > 0 && strlen(src));
13132 : 0 : cmd_flow_context = saved_flow_ctx;
13133 : 0 : *attr = &((struct buffer *)result)->args.vc.attr;
13134 : 0 : *pattern = ((struct buffer *)result)->args.vc.pattern;
13135 : 0 : *actions = ((struct buffer *)result)->args.vc.actions;
13136 : 0 : return (ret >= 0 && !strlen(src)) ? 0 : -1;
13137 : : }
13138 : :
13139 : : /** Return number of completion entries (cmdline API). */
13140 : : static int
13141 : 0 : cmd_flow_complete_get_nb(cmdline_parse_token_hdr_t *hdr)
13142 : : {
13143 : : struct context *ctx = &cmd_flow_context;
13144 : 0 : const struct token *token = &token_list[ctx->curr];
13145 : : const enum index *list;
13146 : : int i;
13147 : :
13148 : : (void)hdr;
13149 : : /* Count number of tokens in current list. */
13150 : 0 : if (ctx->next_num)
13151 : 0 : list = ctx->next[ctx->next_num - 1];
13152 : : else
13153 : 0 : list = token->next[0];
13154 : 0 : for (i = 0; list[i]; ++i)
13155 : : ;
13156 : 0 : if (!i)
13157 : : return 0;
13158 : : /*
13159 : : * If there is a single token, use its completion callback, otherwise
13160 : : * return the number of entries.
13161 : : */
13162 : 0 : token = &token_list[list[0]];
13163 : 0 : if (i == 1 && token->comp) {
13164 : : /* Save index for cmd_flow_get_help(). */
13165 : 0 : ctx->prev = list[0];
13166 : 0 : return token->comp(ctx, token, 0, NULL, 0);
13167 : : }
13168 : : return i;
13169 : : }
13170 : :
13171 : : /** Return a completion entry (cmdline API). */
13172 : : static int
13173 : 0 : cmd_flow_complete_get_elt(cmdline_parse_token_hdr_t *hdr, int index,
13174 : : char *dst, unsigned int size)
13175 : : {
13176 : : struct context *ctx = &cmd_flow_context;
13177 : 0 : const struct token *token = &token_list[ctx->curr];
13178 : : const enum index *list;
13179 : : int i;
13180 : :
13181 : : (void)hdr;
13182 : : /* Count number of tokens in current list. */
13183 : 0 : if (ctx->next_num)
13184 : 0 : list = ctx->next[ctx->next_num - 1];
13185 : : else
13186 : 0 : list = token->next[0];
13187 : 0 : for (i = 0; list[i]; ++i)
13188 : : ;
13189 : 0 : if (!i)
13190 : : return -1;
13191 : : /* If there is a single token, use its completion callback. */
13192 : 0 : token = &token_list[list[0]];
13193 : 0 : if (i == 1 && token->comp) {
13194 : : /* Save index for cmd_flow_get_help(). */
13195 : 0 : ctx->prev = list[0];
13196 : 0 : return token->comp(ctx, token, index, dst, size) < 0 ? -1 : 0;
13197 : : }
13198 : : /* Otherwise make sure the index is valid and use defaults. */
13199 : 0 : if (index >= i)
13200 : : return -1;
13201 : 0 : token = &token_list[list[index]];
13202 : 0 : strlcpy(dst, token->name, size);
13203 : : /* Save index for cmd_flow_get_help(). */
13204 : 0 : ctx->prev = list[index];
13205 : 0 : return 0;
13206 : : }
13207 : :
13208 : : /** Populate help strings for current token (cmdline API). */
13209 : : static int
13210 : 0 : cmd_flow_get_help(cmdline_parse_token_hdr_t *hdr, char *dst, unsigned int size)
13211 : : {
13212 : : struct context *ctx = &cmd_flow_context;
13213 : 0 : const struct token *token = &token_list[ctx->prev];
13214 : :
13215 : : (void)hdr;
13216 : 0 : if (!size)
13217 : : return -1;
13218 : : /* Set token type and update global help with details. */
13219 : 0 : strlcpy(dst, (token->type ? token->type : "TOKEN"), size);
13220 : 0 : if (token->help)
13221 : 0 : cmd_flow.help_str = token->help;
13222 : : else
13223 : 0 : cmd_flow.help_str = token->name;
13224 : : return 0;
13225 : : }
13226 : :
13227 : : /** Token definition template (cmdline API). */
13228 : : static struct cmdline_token_hdr cmd_flow_token_hdr = {
13229 : : .ops = &(struct cmdline_token_ops){
13230 : : .parse = cmd_flow_parse,
13231 : : .complete_get_nb = cmd_flow_complete_get_nb,
13232 : : .complete_get_elt = cmd_flow_complete_get_elt,
13233 : : .get_help = cmd_flow_get_help,
13234 : : },
13235 : : .offset = 0,
13236 : : };
13237 : :
13238 : : /** Populate the next dynamic token. */
13239 : : static void
13240 : 0 : cmd_flow_tok(cmdline_parse_token_hdr_t **hdr,
13241 : : cmdline_parse_token_hdr_t **hdr_inst)
13242 : : {
13243 : : struct context *ctx = &cmd_flow_context;
13244 : :
13245 : : /* Always reinitialize context before requesting the first token. */
13246 : 0 : if (!(hdr_inst - cmd_flow.tokens))
13247 : : cmd_flow_context_init(ctx);
13248 : : /* Return NULL when no more tokens are expected. */
13249 : 0 : if (!ctx->next_num && ctx->curr) {
13250 : 0 : *hdr = NULL;
13251 : 0 : return;
13252 : : }
13253 : : /* Determine if command should end here. */
13254 : 0 : if (ctx->eol && ctx->last && ctx->next_num) {
13255 : 0 : const enum index *list = ctx->next[ctx->next_num - 1];
13256 : : int i;
13257 : :
13258 : 0 : for (i = 0; list[i]; ++i) {
13259 : 0 : if (list[i] != END)
13260 : : continue;
13261 : 0 : *hdr = NULL;
13262 : 0 : return;
13263 : : }
13264 : : }
13265 : 0 : *hdr = &cmd_flow_token_hdr;
13266 : : }
13267 : :
13268 : : static SLIST_HEAD(, indlst_conf) indlst_conf_head =
13269 : : SLIST_HEAD_INITIALIZER();
13270 : :
13271 : : static void
13272 : 0 : indirect_action_flow_conf_create(const struct buffer *in)
13273 : : {
13274 : : int len, ret;
13275 : : uint32_t i;
13276 : : struct indlst_conf *indlst_conf = NULL;
13277 : : size_t base = RTE_ALIGN(sizeof(*indlst_conf), 8);
13278 : 0 : struct rte_flow_action *src = in->args.vc.actions;
13279 : :
13280 : 0 : if (!in->args.vc.actions_n)
13281 : 0 : goto end;
13282 : 0 : len = rte_flow_conv(RTE_FLOW_CONV_OP_ACTIONS, NULL, 0, src, NULL);
13283 : 0 : if (len <= 0)
13284 : 0 : goto end;
13285 : 0 : len = RTE_ALIGN(len, 16);
13286 : :
13287 : 0 : indlst_conf = calloc(1, base + len +
13288 : 0 : in->args.vc.actions_n * sizeof(uintptr_t));
13289 : 0 : if (!indlst_conf)
13290 : 0 : goto end;
13291 : 0 : indlst_conf->id = in->args.vc.attr.group;
13292 : 0 : indlst_conf->conf_num = in->args.vc.actions_n - 1;
13293 : 0 : indlst_conf->actions = RTE_PTR_ADD(indlst_conf, base);
13294 : 0 : ret = rte_flow_conv(RTE_FLOW_CONV_OP_ACTIONS, indlst_conf->actions,
13295 : : len, src, NULL);
13296 : 0 : if (ret <= 0) {
13297 : 0 : free(indlst_conf);
13298 : : indlst_conf = NULL;
13299 : 0 : goto end;
13300 : : }
13301 : 0 : indlst_conf->conf = RTE_PTR_ADD(indlst_conf, base + len);
13302 : 0 : for (i = 0; i < indlst_conf->conf_num; i++)
13303 : 0 : indlst_conf->conf[i] = indlst_conf->actions[i].conf;
13304 : 0 : SLIST_INSERT_HEAD(&indlst_conf_head, indlst_conf, next);
13305 : 0 : end:
13306 : 0 : if (indlst_conf)
13307 : : printf("created indirect action list configuration %u\n",
13308 : 0 : in->args.vc.attr.group);
13309 : : else
13310 : : printf("cannot create indirect action list configuration %u\n",
13311 : 0 : in->args.vc.attr.group);
13312 : 0 : }
13313 : :
13314 : : static const struct indlst_conf *
13315 : : indirect_action_list_conf_get(uint32_t conf_id)
13316 : : {
13317 : : const struct indlst_conf *conf;
13318 : :
13319 : 0 : SLIST_FOREACH(conf, &indlst_conf_head, next) {
13320 : 0 : if (conf->id == conf_id)
13321 : : return conf;
13322 : : }
13323 : : return NULL;
13324 : : }
13325 : :
13326 : : /** Dispatch parsed buffer to function calls. */
13327 : : static void
13328 : 0 : cmd_flow_parsed(const struct buffer *in)
13329 : : {
13330 : 0 : switch (in->command) {
13331 : 0 : case INFO:
13332 : 0 : port_flow_get_info(in->port);
13333 : 0 : break;
13334 : 0 : case CONFIGURE:
13335 : 0 : port_flow_configure(in->port,
13336 : : &in->args.configure.port_attr,
13337 : 0 : in->args.configure.nb_queue,
13338 : : &in->args.configure.queue_attr);
13339 : 0 : break;
13340 : 0 : case PATTERN_TEMPLATE_CREATE:
13341 : 0 : port_flow_pattern_template_create(in->port,
13342 : 0 : in->args.vc.pat_templ_id,
13343 : 0 : &((const struct rte_flow_pattern_template_attr) {
13344 : 0 : .relaxed_matching = in->args.vc.attr.reserved,
13345 : 0 : .ingress = in->args.vc.attr.ingress,
13346 : 0 : .egress = in->args.vc.attr.egress,
13347 : 0 : .transfer = in->args.vc.attr.transfer,
13348 : : }),
13349 : 0 : in->args.vc.pattern);
13350 : 0 : break;
13351 : 0 : case PATTERN_TEMPLATE_DESTROY:
13352 : 0 : port_flow_pattern_template_destroy(in->port,
13353 : 0 : in->args.templ_destroy.template_id_n,
13354 : 0 : in->args.templ_destroy.template_id);
13355 : 0 : break;
13356 : 0 : case ACTIONS_TEMPLATE_CREATE:
13357 : 0 : port_flow_actions_template_create(in->port,
13358 : 0 : in->args.vc.act_templ_id,
13359 : 0 : &((const struct rte_flow_actions_template_attr) {
13360 : 0 : .ingress = in->args.vc.attr.ingress,
13361 : 0 : .egress = in->args.vc.attr.egress,
13362 : 0 : .transfer = in->args.vc.attr.transfer,
13363 : : }),
13364 : 0 : in->args.vc.actions,
13365 : 0 : in->args.vc.masks);
13366 : 0 : break;
13367 : 0 : case ACTIONS_TEMPLATE_DESTROY:
13368 : 0 : port_flow_actions_template_destroy(in->port,
13369 : 0 : in->args.templ_destroy.template_id_n,
13370 : 0 : in->args.templ_destroy.template_id);
13371 : 0 : break;
13372 : 0 : case TABLE_CREATE:
13373 : 0 : port_flow_template_table_create(in->port, in->args.table.id,
13374 : 0 : &in->args.table.attr, in->args.table.pat_templ_id_n,
13375 : 0 : in->args.table.pat_templ_id, in->args.table.act_templ_id_n,
13376 : 0 : in->args.table.act_templ_id);
13377 : 0 : break;
13378 : 0 : case TABLE_DESTROY:
13379 : 0 : port_flow_template_table_destroy(in->port,
13380 : 0 : in->args.table_destroy.table_id_n,
13381 : 0 : in->args.table_destroy.table_id);
13382 : 0 : break;
13383 : 0 : case TABLE_RESIZE_COMPLETE:
13384 : 0 : port_flow_template_table_resize_complete
13385 : 0 : (in->port, in->args.table_destroy.table_id[0]);
13386 : 0 : break;
13387 : 0 : case GROUP_SET_MISS_ACTIONS:
13388 : 0 : port_queue_group_set_miss_actions(in->port, &in->args.vc.attr,
13389 : 0 : in->args.vc.actions);
13390 : 0 : break;
13391 : 0 : case TABLE_RESIZE:
13392 : 0 : port_flow_template_table_resize(in->port, in->args.table.id,
13393 : 0 : in->args.table.attr.nb_flows);
13394 : 0 : break;
13395 : 0 : case QUEUE_CREATE:
13396 : 0 : port_queue_flow_create(in->port, in->queue, in->postpone,
13397 : 0 : in->args.vc.table_id, in->args.vc.rule_id,
13398 : 0 : in->args.vc.pat_templ_id, in->args.vc.act_templ_id,
13399 : 0 : in->args.vc.pattern, in->args.vc.actions);
13400 : 0 : break;
13401 : 0 : case QUEUE_DESTROY:
13402 : 0 : port_queue_flow_destroy(in->port, in->queue, in->postpone,
13403 : 0 : in->args.destroy.rule_n,
13404 : 0 : in->args.destroy.rule);
13405 : 0 : break;
13406 : 0 : case QUEUE_FLOW_UPDATE_RESIZED:
13407 : 0 : port_queue_flow_update_resized(in->port, in->queue,
13408 : 0 : in->postpone,
13409 : 0 : in->args.destroy.rule[0]);
13410 : 0 : break;
13411 : 0 : case QUEUE_UPDATE:
13412 : 0 : port_queue_flow_update(in->port, in->queue, in->postpone,
13413 : 0 : in->args.vc.rule_id, in->args.vc.act_templ_id,
13414 : 0 : in->args.vc.actions);
13415 : 0 : break;
13416 : 0 : case PUSH:
13417 : 0 : port_queue_flow_push(in->port, in->queue);
13418 : 0 : break;
13419 : 0 : case PULL:
13420 : 0 : port_queue_flow_pull(in->port, in->queue);
13421 : 0 : break;
13422 : 0 : case HASH:
13423 : 0 : if (!in->args.vc.encap_hash)
13424 : 0 : port_flow_hash_calc(in->port, in->args.vc.table_id,
13425 : 0 : in->args.vc.pat_templ_id,
13426 : 0 : in->args.vc.pattern);
13427 : : else
13428 : 0 : port_flow_hash_calc_encap(in->port, in->args.vc.field,
13429 : 0 : in->args.vc.pattern);
13430 : : break;
13431 : 0 : case QUEUE_AGED:
13432 : 0 : port_queue_flow_aged(in->port, in->queue,
13433 : 0 : in->args.aged.destroy);
13434 : 0 : break;
13435 : 0 : case QUEUE_INDIRECT_ACTION_CREATE:
13436 : : case QUEUE_INDIRECT_ACTION_LIST_CREATE:
13437 : 0 : port_queue_action_handle_create(
13438 : 0 : in->port, in->queue, in->postpone,
13439 : 0 : in->args.vc.attr.group,
13440 : : in->command == QUEUE_INDIRECT_ACTION_LIST_CREATE,
13441 : 0 : &((const struct rte_flow_indir_action_conf) {
13442 : 0 : .ingress = in->args.vc.attr.ingress,
13443 : 0 : .egress = in->args.vc.attr.egress,
13444 : 0 : .transfer = in->args.vc.attr.transfer,
13445 : : }),
13446 : 0 : in->args.vc.actions);
13447 : 0 : break;
13448 : 0 : case QUEUE_INDIRECT_ACTION_DESTROY:
13449 : 0 : port_queue_action_handle_destroy(in->port,
13450 : 0 : in->queue, in->postpone,
13451 : 0 : in->args.ia_destroy.action_id_n,
13452 : 0 : in->args.ia_destroy.action_id);
13453 : 0 : break;
13454 : 0 : case QUEUE_INDIRECT_ACTION_UPDATE:
13455 : 0 : port_queue_action_handle_update(in->port,
13456 : 0 : in->queue, in->postpone,
13457 : 0 : in->args.vc.attr.group,
13458 : 0 : in->args.vc.actions);
13459 : 0 : break;
13460 : 0 : case QUEUE_INDIRECT_ACTION_QUERY:
13461 : 0 : port_queue_action_handle_query(in->port,
13462 : 0 : in->queue, in->postpone,
13463 : 0 : in->args.ia.action_id);
13464 : 0 : break;
13465 : 0 : case QUEUE_INDIRECT_ACTION_QUERY_UPDATE:
13466 : 0 : port_queue_action_handle_query_update(in->port, in->queue,
13467 : 0 : in->postpone,
13468 : 0 : in->args.ia.action_id,
13469 : 0 : in->args.ia.qu_mode,
13470 : 0 : in->args.vc.actions);
13471 : 0 : break;
13472 : 0 : case INDIRECT_ACTION_CREATE:
13473 : : case INDIRECT_ACTION_LIST_CREATE:
13474 : 0 : port_action_handle_create(
13475 : 0 : in->port, in->args.vc.attr.group,
13476 : : in->command == INDIRECT_ACTION_LIST_CREATE,
13477 : 0 : &((const struct rte_flow_indir_action_conf) {
13478 : 0 : .ingress = in->args.vc.attr.ingress,
13479 : 0 : .egress = in->args.vc.attr.egress,
13480 : 0 : .transfer = in->args.vc.attr.transfer,
13481 : : }),
13482 : 0 : in->args.vc.actions);
13483 : 0 : break;
13484 : 0 : case INDIRECT_ACTION_FLOW_CONF_CREATE:
13485 : 0 : indirect_action_flow_conf_create(in);
13486 : 0 : break;
13487 : 0 : case INDIRECT_ACTION_DESTROY:
13488 : 0 : port_action_handle_destroy(in->port,
13489 : 0 : in->args.ia_destroy.action_id_n,
13490 : 0 : in->args.ia_destroy.action_id);
13491 : 0 : break;
13492 : 0 : case INDIRECT_ACTION_UPDATE:
13493 : 0 : port_action_handle_update(in->port, in->args.vc.attr.group,
13494 : 0 : in->args.vc.actions);
13495 : 0 : break;
13496 : 0 : case INDIRECT_ACTION_QUERY:
13497 : 0 : port_action_handle_query(in->port, in->args.ia.action_id);
13498 : 0 : break;
13499 : 0 : case INDIRECT_ACTION_QUERY_UPDATE:
13500 : 0 : port_action_handle_query_update(in->port,
13501 : 0 : in->args.ia.action_id,
13502 : 0 : in->args.ia.qu_mode,
13503 : 0 : in->args.vc.actions);
13504 : 0 : break;
13505 : 0 : case VALIDATE:
13506 : 0 : port_flow_validate(in->port, &in->args.vc.attr,
13507 : 0 : in->args.vc.pattern, in->args.vc.actions,
13508 : : &in->args.vc.tunnel_ops);
13509 : 0 : break;
13510 : 0 : case CREATE:
13511 : 0 : port_flow_create(in->port, &in->args.vc.attr,
13512 : 0 : in->args.vc.pattern, in->args.vc.actions,
13513 : 0 : &in->args.vc.tunnel_ops, in->args.vc.user_id);
13514 : 0 : break;
13515 : 0 : case DESTROY:
13516 : 0 : port_flow_destroy(in->port, in->args.destroy.rule_n,
13517 : 0 : in->args.destroy.rule,
13518 : 0 : in->args.destroy.is_user_id);
13519 : 0 : break;
13520 : 0 : case UPDATE:
13521 : 0 : port_flow_update(in->port, in->args.vc.rule_id,
13522 : 0 : in->args.vc.actions, in->args.vc.user_id);
13523 : 0 : break;
13524 : 0 : case FLUSH:
13525 : 0 : port_flow_flush(in->port);
13526 : 0 : break;
13527 : 0 : case DUMP_ONE:
13528 : : case DUMP_ALL:
13529 : 0 : port_flow_dump(in->port, in->args.dump.mode,
13530 : 0 : in->args.dump.rule, in->args.dump.file,
13531 : 0 : in->args.dump.is_user_id);
13532 : 0 : break;
13533 : 0 : case QUERY:
13534 : 0 : port_flow_query(in->port, in->args.query.rule,
13535 : : &in->args.query.action,
13536 : 0 : in->args.query.is_user_id);
13537 : 0 : break;
13538 : 0 : case LIST:
13539 : 0 : port_flow_list(in->port, in->args.list.group_n,
13540 : 0 : in->args.list.group);
13541 : 0 : break;
13542 : 0 : case ISOLATE:
13543 : 0 : port_flow_isolate(in->port, in->args.isolate.set);
13544 : 0 : break;
13545 : 0 : case AGED:
13546 : 0 : port_flow_aged(in->port, in->args.aged.destroy);
13547 : 0 : break;
13548 : 0 : case TUNNEL_CREATE:
13549 : 0 : port_flow_tunnel_create(in->port, &in->args.vc.tunnel_ops);
13550 : 0 : break;
13551 : 0 : case TUNNEL_DESTROY:
13552 : 0 : port_flow_tunnel_destroy(in->port, in->args.vc.tunnel_ops.id);
13553 : 0 : break;
13554 : 0 : case TUNNEL_LIST:
13555 : 0 : port_flow_tunnel_list(in->port);
13556 : 0 : break;
13557 : 0 : case ACTION_POL_G:
13558 : 0 : port_meter_policy_add(in->port, in->args.policy.policy_id,
13559 : 0 : in->args.vc.actions);
13560 : 0 : break;
13561 : 0 : case FLEX_ITEM_CREATE:
13562 : 0 : flex_item_create(in->port, in->args.flex.token,
13563 : 0 : in->args.flex.filename);
13564 : 0 : break;
13565 : 0 : case FLEX_ITEM_DESTROY:
13566 : 0 : flex_item_destroy(in->port, in->args.flex.token);
13567 : 0 : break;
13568 : : default:
13569 : : break;
13570 : : }
13571 : 0 : fflush(stdout);
13572 : 0 : }
13573 : :
13574 : : /** Token generator and output processing callback (cmdline API). */
13575 : : static void
13576 : 0 : cmd_flow_cb(void *arg0, struct cmdline *cl, void *arg2)
13577 : : {
13578 : 0 : if (cl == NULL)
13579 : 0 : cmd_flow_tok(arg0, arg2);
13580 : : else
13581 : 0 : cmd_flow_parsed(arg0);
13582 : 0 : }
13583 : :
13584 : : /** Global parser instance (cmdline API). */
13585 : : cmdline_parse_inst_t cmd_flow = {
13586 : : .f = cmd_flow_cb,
13587 : : .data = NULL, /**< Unused. */
13588 : : .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
13589 : : .tokens = {
13590 : : NULL,
13591 : : }, /**< Tokens are returned by cmd_flow_tok(). */
13592 : : };
13593 : :
13594 : : /** set cmd facility. Reuse cmd flow's infrastructure as much as possible. */
13595 : :
13596 : : static void
13597 : 0 : update_fields(uint8_t *buf, struct rte_flow_item *item, uint16_t next_proto)
13598 : : {
13599 : : struct rte_ipv4_hdr *ipv4;
13600 : : struct rte_ether_hdr *eth;
13601 : : struct rte_ipv6_hdr *ipv6;
13602 : : struct rte_vxlan_hdr *vxlan;
13603 : : struct rte_vxlan_gpe_hdr *gpe;
13604 : : struct rte_flow_item_nvgre *nvgre;
13605 : : uint32_t ipv6_vtc_flow;
13606 : :
13607 : 0 : switch (item->type) {
13608 : 0 : case RTE_FLOW_ITEM_TYPE_ETH:
13609 : : eth = (struct rte_ether_hdr *)buf;
13610 : 0 : if (next_proto)
13611 : 0 : eth->ether_type = rte_cpu_to_be_16(next_proto);
13612 : : break;
13613 : 0 : case RTE_FLOW_ITEM_TYPE_IPV4:
13614 : : ipv4 = (struct rte_ipv4_hdr *)buf;
13615 : 0 : if (!ipv4->version_ihl)
13616 : 0 : ipv4->version_ihl = RTE_IPV4_VHL_DEF;
13617 : 0 : if (next_proto && ipv4->next_proto_id == 0)
13618 : 0 : ipv4->next_proto_id = (uint8_t)next_proto;
13619 : : break;
13620 : 0 : case RTE_FLOW_ITEM_TYPE_IPV6:
13621 : : ipv6 = (struct rte_ipv6_hdr *)buf;
13622 : 0 : if (next_proto && ipv6->proto == 0)
13623 : 0 : ipv6->proto = (uint8_t)next_proto;
13624 : 0 : ipv6_vtc_flow = rte_be_to_cpu_32(ipv6->vtc_flow);
13625 : 0 : ipv6_vtc_flow &= 0x0FFFFFFF; /*< reset version bits. */
13626 : 0 : ipv6_vtc_flow |= 0x60000000; /*< set ipv6 version. */
13627 : 0 : ipv6->vtc_flow = rte_cpu_to_be_32(ipv6_vtc_flow);
13628 : 0 : break;
13629 : 0 : case RTE_FLOW_ITEM_TYPE_VXLAN:
13630 : : vxlan = (struct rte_vxlan_hdr *)buf;
13631 : 0 : if (!vxlan->flags)
13632 : 0 : vxlan->flags = 0x08;
13633 : : break;
13634 : 0 : case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
13635 : : gpe = (struct rte_vxlan_gpe_hdr *)buf;
13636 : 0 : gpe->vx_flags = 0x0C;
13637 : 0 : break;
13638 : 0 : case RTE_FLOW_ITEM_TYPE_NVGRE:
13639 : : nvgre = (struct rte_flow_item_nvgre *)buf;
13640 : 0 : nvgre->protocol = rte_cpu_to_be_16(0x6558);
13641 : 0 : nvgre->c_k_s_rsvd0_ver = rte_cpu_to_be_16(0x2000);
13642 : 0 : break;
13643 : : default:
13644 : : break;
13645 : : }
13646 : 0 : }
13647 : :
13648 : : /** Helper of get item's default mask. */
13649 : : static const void *
13650 : 0 : flow_item_default_mask(const struct rte_flow_item *item)
13651 : : {
13652 : : const void *mask = NULL;
13653 : : static rte_be32_t gre_key_default_mask = RTE_BE32(UINT32_MAX);
13654 : : static struct rte_flow_item_ipv6_routing_ext ipv6_routing_ext_default_mask = {
13655 : : .hdr = {
13656 : : .next_hdr = 0xff,
13657 : : .type = 0xff,
13658 : : .segments_left = 0xff,
13659 : : },
13660 : : };
13661 : :
13662 : 0 : switch (item->type) {
13663 : 0 : case RTE_FLOW_ITEM_TYPE_ANY:
13664 : : mask = &rte_flow_item_any_mask;
13665 : 0 : break;
13666 : 0 : case RTE_FLOW_ITEM_TYPE_PORT_ID:
13667 : : mask = &rte_flow_item_port_id_mask;
13668 : 0 : break;
13669 : 0 : case RTE_FLOW_ITEM_TYPE_RAW:
13670 : : mask = &rte_flow_item_raw_mask;
13671 : 0 : break;
13672 : 0 : case RTE_FLOW_ITEM_TYPE_ETH:
13673 : : mask = &rte_flow_item_eth_mask;
13674 : 0 : break;
13675 : 0 : case RTE_FLOW_ITEM_TYPE_VLAN:
13676 : : mask = &rte_flow_item_vlan_mask;
13677 : 0 : break;
13678 : 0 : case RTE_FLOW_ITEM_TYPE_IPV4:
13679 : : mask = &rte_flow_item_ipv4_mask;
13680 : 0 : break;
13681 : 0 : case RTE_FLOW_ITEM_TYPE_IPV6:
13682 : : mask = &rte_flow_item_ipv6_mask;
13683 : 0 : break;
13684 : 0 : case RTE_FLOW_ITEM_TYPE_ICMP:
13685 : : mask = &rte_flow_item_icmp_mask;
13686 : 0 : break;
13687 : 0 : case RTE_FLOW_ITEM_TYPE_UDP:
13688 : : mask = &rte_flow_item_udp_mask;
13689 : 0 : break;
13690 : 0 : case RTE_FLOW_ITEM_TYPE_TCP:
13691 : : mask = &rte_flow_item_tcp_mask;
13692 : 0 : break;
13693 : 0 : case RTE_FLOW_ITEM_TYPE_SCTP:
13694 : : mask = &rte_flow_item_sctp_mask;
13695 : 0 : break;
13696 : 0 : case RTE_FLOW_ITEM_TYPE_VXLAN:
13697 : : mask = &rte_flow_item_vxlan_mask;
13698 : 0 : break;
13699 : 0 : case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
13700 : : mask = &rte_flow_item_vxlan_gpe_mask;
13701 : 0 : break;
13702 : 0 : case RTE_FLOW_ITEM_TYPE_E_TAG:
13703 : : mask = &rte_flow_item_e_tag_mask;
13704 : 0 : break;
13705 : 0 : case RTE_FLOW_ITEM_TYPE_NVGRE:
13706 : : mask = &rte_flow_item_nvgre_mask;
13707 : 0 : break;
13708 : 0 : case RTE_FLOW_ITEM_TYPE_MPLS:
13709 : : mask = &rte_flow_item_mpls_mask;
13710 : 0 : break;
13711 : 0 : case RTE_FLOW_ITEM_TYPE_GRE:
13712 : : mask = &rte_flow_item_gre_mask;
13713 : 0 : break;
13714 : 0 : case RTE_FLOW_ITEM_TYPE_GRE_KEY:
13715 : : mask = &gre_key_default_mask;
13716 : 0 : break;
13717 : 0 : case RTE_FLOW_ITEM_TYPE_META:
13718 : : mask = &rte_flow_item_meta_mask;
13719 : 0 : break;
13720 : 0 : case RTE_FLOW_ITEM_TYPE_RANDOM:
13721 : : mask = &rte_flow_item_random_mask;
13722 : 0 : break;
13723 : 0 : case RTE_FLOW_ITEM_TYPE_FUZZY:
13724 : : mask = &rte_flow_item_fuzzy_mask;
13725 : 0 : break;
13726 : 0 : case RTE_FLOW_ITEM_TYPE_GTP:
13727 : : mask = &rte_flow_item_gtp_mask;
13728 : 0 : break;
13729 : 0 : case RTE_FLOW_ITEM_TYPE_GTP_PSC:
13730 : : mask = &rte_flow_item_gtp_psc_mask;
13731 : 0 : break;
13732 : 0 : case RTE_FLOW_ITEM_TYPE_GENEVE:
13733 : : mask = &rte_flow_item_geneve_mask;
13734 : 0 : break;
13735 : 0 : case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
13736 : : mask = &rte_flow_item_geneve_opt_mask;
13737 : 0 : break;
13738 : 0 : case RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID:
13739 : : mask = &rte_flow_item_pppoe_proto_id_mask;
13740 : 0 : break;
13741 : 0 : case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
13742 : : mask = &rte_flow_item_l2tpv3oip_mask;
13743 : 0 : break;
13744 : 0 : case RTE_FLOW_ITEM_TYPE_ESP:
13745 : : mask = &rte_flow_item_esp_mask;
13746 : 0 : break;
13747 : 0 : case RTE_FLOW_ITEM_TYPE_AH:
13748 : : mask = &rte_flow_item_ah_mask;
13749 : 0 : break;
13750 : 0 : case RTE_FLOW_ITEM_TYPE_PFCP:
13751 : : mask = &rte_flow_item_pfcp_mask;
13752 : 0 : break;
13753 : 0 : case RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR:
13754 : : case RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT:
13755 : : mask = &rte_flow_item_ethdev_mask;
13756 : 0 : break;
13757 : 0 : case RTE_FLOW_ITEM_TYPE_L2TPV2:
13758 : : mask = &rte_flow_item_l2tpv2_mask;
13759 : 0 : break;
13760 : 0 : case RTE_FLOW_ITEM_TYPE_PPP:
13761 : : mask = &rte_flow_item_ppp_mask;
13762 : 0 : break;
13763 : 0 : case RTE_FLOW_ITEM_TYPE_METER_COLOR:
13764 : : mask = &rte_flow_item_meter_color_mask;
13765 : 0 : break;
13766 : 0 : case RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT:
13767 : : mask = &ipv6_routing_ext_default_mask;
13768 : 0 : break;
13769 : 0 : case RTE_FLOW_ITEM_TYPE_AGGR_AFFINITY:
13770 : : mask = &rte_flow_item_aggr_affinity_mask;
13771 : 0 : break;
13772 : 0 : case RTE_FLOW_ITEM_TYPE_TX_QUEUE:
13773 : : mask = &rte_flow_item_tx_queue_mask;
13774 : 0 : break;
13775 : 0 : case RTE_FLOW_ITEM_TYPE_IB_BTH:
13776 : : mask = &rte_flow_item_ib_bth_mask;
13777 : 0 : break;
13778 : 0 : case RTE_FLOW_ITEM_TYPE_PTYPE:
13779 : : mask = &rte_flow_item_ptype_mask;
13780 : 0 : break;
13781 : : default:
13782 : : break;
13783 : : }
13784 : 0 : return mask;
13785 : : }
13786 : :
13787 : : /** Dispatch parsed buffer to function calls. */
13788 : : static void
13789 : 0 : cmd_set_ipv6_ext_parsed(const struct buffer *in)
13790 : : {
13791 : 0 : uint32_t n = in->args.vc.pattern_n;
13792 : : int i = 0;
13793 : : struct rte_flow_item *item = NULL;
13794 : : size_t size = 0;
13795 : : uint8_t *data = NULL;
13796 : : uint8_t *type = NULL;
13797 : : size_t *total_size = NULL;
13798 : 0 : uint16_t idx = in->port; /* We borrow port field as index */
13799 : : struct rte_flow_item_ipv6_routing_ext *ext;
13800 : : const struct rte_flow_item_ipv6_ext *ipv6_ext;
13801 : :
13802 : : RTE_ASSERT(in->command == SET_IPV6_EXT_PUSH ||
13803 : : in->command == SET_IPV6_EXT_REMOVE);
13804 : :
13805 : 0 : if (in->command == SET_IPV6_EXT_REMOVE) {
13806 : 0 : if (n != 1 || in->args.vc.pattern->type !=
13807 : : RTE_FLOW_ITEM_TYPE_IPV6_EXT) {
13808 : 0 : fprintf(stderr, "Error - Not supported item\n");
13809 : 0 : return;
13810 : : }
13811 : 0 : type = (uint8_t *)&ipv6_ext_remove_confs[idx].type;
13812 : : item = in->args.vc.pattern;
13813 : 0 : ipv6_ext = item->spec;
13814 : 0 : *type = ipv6_ext->next_hdr;
13815 : 0 : return;
13816 : : }
13817 : :
13818 : 0 : total_size = &ipv6_ext_push_confs[idx].size;
13819 : 0 : data = (uint8_t *)&ipv6_ext_push_confs[idx].data;
13820 : : type = (uint8_t *)&ipv6_ext_push_confs[idx].type;
13821 : :
13822 : 0 : *total_size = 0;
13823 : : memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
13824 : 0 : for (i = n - 1 ; i >= 0; --i) {
13825 : 0 : item = in->args.vc.pattern + i;
13826 : 0 : switch (item->type) {
13827 : 0 : case RTE_FLOW_ITEM_TYPE_IPV6_EXT:
13828 : 0 : ipv6_ext = item->spec;
13829 : 0 : *type = ipv6_ext->next_hdr;
13830 : 0 : break;
13831 : 0 : case RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT:
13832 : 0 : ext = (struct rte_flow_item_ipv6_routing_ext *)(uintptr_t)item->spec;
13833 : 0 : if (!ext->hdr.hdr_len) {
13834 : 0 : size = sizeof(struct rte_ipv6_routing_ext) +
13835 : 0 : (ext->hdr.segments_left << 4);
13836 : 0 : ext->hdr.hdr_len = ext->hdr.segments_left << 1;
13837 : : /* Indicate no TLV once SRH. */
13838 : 0 : if (ext->hdr.type == 4)
13839 : 0 : ext->hdr.last_entry = ext->hdr.segments_left - 1;
13840 : : } else {
13841 : 0 : size = sizeof(struct rte_ipv6_routing_ext) +
13842 : 0 : (ext->hdr.hdr_len << 3);
13843 : : }
13844 : 0 : *total_size += size;
13845 : : memcpy(data, ext, size);
13846 : : break;
13847 : 0 : default:
13848 : 0 : fprintf(stderr, "Error - Not supported item\n");
13849 : 0 : goto error;
13850 : : }
13851 : : }
13852 : : RTE_ASSERT((*total_size) <= ACTION_IPV6_EXT_PUSH_MAX_DATA);
13853 : : return;
13854 : : error:
13855 : 0 : *total_size = 0;
13856 : : memset(data, 0x00, ACTION_IPV6_EXT_PUSH_MAX_DATA);
13857 : : }
13858 : :
13859 : : /** Dispatch parsed buffer to function calls. */
13860 : : static void
13861 : 0 : cmd_set_raw_parsed_sample(const struct buffer *in)
13862 : : {
13863 : 0 : uint32_t n = in->args.vc.actions_n;
13864 : : uint32_t i = 0;
13865 : : struct rte_flow_action *action = NULL;
13866 : : struct rte_flow_action *data = NULL;
13867 : : const struct rte_flow_action_rss *rss = NULL;
13868 : : size_t size = 0;
13869 : 0 : uint16_t idx = in->port; /* We borrow port field as index */
13870 : : uint32_t max_size = sizeof(struct rte_flow_action) *
13871 : : ACTION_SAMPLE_ACTIONS_NUM;
13872 : :
13873 : : RTE_ASSERT(in->command == SET_SAMPLE_ACTIONS);
13874 : 0 : data = (struct rte_flow_action *)&raw_sample_confs[idx].data;
13875 : : memset(data, 0x00, max_size);
13876 : 0 : for (; i <= n - 1; i++) {
13877 : 0 : action = in->args.vc.actions + i;
13878 : 0 : if (action->type == RTE_FLOW_ACTION_TYPE_END)
13879 : : break;
13880 : 0 : switch (action->type) {
13881 : 0 : case RTE_FLOW_ACTION_TYPE_MARK:
13882 : : size = sizeof(struct rte_flow_action_mark);
13883 : 0 : rte_memcpy(&sample_mark[idx],
13884 : : (const void *)action->conf, size);
13885 : 0 : action->conf = &sample_mark[idx];
13886 : 0 : break;
13887 : 0 : case RTE_FLOW_ACTION_TYPE_COUNT:
13888 : : size = sizeof(struct rte_flow_action_count);
13889 : 0 : rte_memcpy(&sample_count[idx],
13890 : : (const void *)action->conf, size);
13891 : 0 : action->conf = &sample_count[idx];
13892 : 0 : break;
13893 : 0 : case RTE_FLOW_ACTION_TYPE_QUEUE:
13894 : : size = sizeof(struct rte_flow_action_queue);
13895 : 0 : rte_memcpy(&sample_queue[idx],
13896 : : (const void *)action->conf, size);
13897 : 0 : action->conf = &sample_queue[idx];
13898 : 0 : break;
13899 : 0 : case RTE_FLOW_ACTION_TYPE_RSS:
13900 : : size = sizeof(struct rte_flow_action_rss);
13901 : 0 : rss = action->conf;
13902 : 0 : rte_memcpy(&sample_rss_data[idx].conf,
13903 : : (const void *)rss, size);
13904 : 0 : if (rss->key_len && rss->key) {
13905 : 0 : sample_rss_data[idx].conf.key =
13906 : 0 : sample_rss_data[idx].key;
13907 : 0 : rte_memcpy((void *)((uintptr_t)
13908 : : sample_rss_data[idx].conf.key),
13909 : 0 : (const void *)rss->key,
13910 : : sizeof(uint8_t) * rss->key_len);
13911 : : }
13912 : 0 : if (rss->queue_num && rss->queue) {
13913 : 0 : sample_rss_data[idx].conf.queue =
13914 : 0 : sample_rss_data[idx].queue;
13915 : 0 : rte_memcpy((void *)((uintptr_t)
13916 : : sample_rss_data[idx].conf.queue),
13917 : 0 : (const void *)rss->queue,
13918 : 0 : sizeof(uint16_t) * rss->queue_num);
13919 : : }
13920 : 0 : action->conf = &sample_rss_data[idx].conf;
13921 : 0 : break;
13922 : 0 : case RTE_FLOW_ACTION_TYPE_RAW_ENCAP:
13923 : : size = sizeof(struct rte_flow_action_raw_encap);
13924 : 0 : rte_memcpy(&sample_encap[idx],
13925 : : (const void *)action->conf, size);
13926 : 0 : action->conf = &sample_encap[idx];
13927 : 0 : break;
13928 : 0 : case RTE_FLOW_ACTION_TYPE_PORT_ID:
13929 : : size = sizeof(struct rte_flow_action_port_id);
13930 : 0 : rte_memcpy(&sample_port_id[idx],
13931 : : (const void *)action->conf, size);
13932 : 0 : action->conf = &sample_port_id[idx];
13933 : 0 : break;
13934 : : case RTE_FLOW_ACTION_TYPE_PF:
13935 : : break;
13936 : 0 : case RTE_FLOW_ACTION_TYPE_VF:
13937 : : size = sizeof(struct rte_flow_action_vf);
13938 : 0 : rte_memcpy(&sample_vf[idx],
13939 : : (const void *)action->conf, size);
13940 : 0 : action->conf = &sample_vf[idx];
13941 : 0 : break;
13942 : 0 : case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP:
13943 : : size = sizeof(struct rte_flow_action_vxlan_encap);
13944 : 0 : parse_setup_vxlan_encap_data(&sample_vxlan_encap[idx]);
13945 : 0 : action->conf = &sample_vxlan_encap[idx].conf;
13946 : 0 : break;
13947 : 0 : case RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP:
13948 : : size = sizeof(struct rte_flow_action_nvgre_encap);
13949 : 0 : parse_setup_nvgre_encap_data(&sample_nvgre_encap[idx]);
13950 : 0 : action->conf = &sample_nvgre_encap[idx];
13951 : 0 : break;
13952 : 0 : case RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR:
13953 : : size = sizeof(struct rte_flow_action_ethdev);
13954 : 0 : rte_memcpy(&sample_port_representor[idx],
13955 : : (const void *)action->conf, size);
13956 : 0 : action->conf = &sample_port_representor[idx];
13957 : 0 : break;
13958 : 0 : case RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT:
13959 : : size = sizeof(struct rte_flow_action_ethdev);
13960 : 0 : rte_memcpy(&sample_represented_port[idx],
13961 : : (const void *)action->conf, size);
13962 : 0 : action->conf = &sample_represented_port[idx];
13963 : 0 : break;
13964 : 0 : default:
13965 : 0 : fprintf(stderr, "Error - Not supported action\n");
13966 : : return;
13967 : : }
13968 : : rte_memcpy(data, action, sizeof(struct rte_flow_action));
13969 : 0 : data++;
13970 : : }
13971 : : }
13972 : :
13973 : : /** Dispatch parsed buffer to function calls. */
13974 : : static void
13975 : 0 : cmd_set_raw_parsed(const struct buffer *in)
13976 : : {
13977 : 0 : uint32_t n = in->args.vc.pattern_n;
13978 : : int i = 0;
13979 : : struct rte_flow_item *item = NULL;
13980 : : size_t size = 0;
13981 : : uint8_t *data = NULL;
13982 : : uint8_t *data_tail = NULL;
13983 : : size_t *total_size = NULL;
13984 : : uint16_t upper_layer = 0;
13985 : : uint16_t proto = 0;
13986 : 0 : uint16_t idx = in->port; /* We borrow port field as index */
13987 : : int gtp_psc = -1; /* GTP PSC option index. */
13988 : : const void *src_spec;
13989 : :
13990 : 0 : if (in->command == SET_SAMPLE_ACTIONS)
13991 : 0 : return cmd_set_raw_parsed_sample(in);
13992 : 0 : else if (in->command == SET_IPV6_EXT_PUSH ||
13993 : : in->command == SET_IPV6_EXT_REMOVE)
13994 : 0 : return cmd_set_ipv6_ext_parsed(in);
13995 : : RTE_ASSERT(in->command == SET_RAW_ENCAP ||
13996 : : in->command == SET_RAW_DECAP);
13997 : 0 : if (in->command == SET_RAW_ENCAP) {
13998 : 0 : total_size = &raw_encap_confs[idx].size;
13999 : 0 : data = (uint8_t *)&raw_encap_confs[idx].data;
14000 : : } else {
14001 : 0 : total_size = &raw_decap_confs[idx].size;
14002 : 0 : data = (uint8_t *)&raw_decap_confs[idx].data;
14003 : : }
14004 : 0 : *total_size = 0;
14005 : : memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
14006 : : /* process hdr from upper layer to low layer (L3/L4 -> L2). */
14007 : 0 : data_tail = data + ACTION_RAW_ENCAP_MAX_DATA;
14008 : 0 : for (i = n - 1 ; i >= 0; --i) {
14009 : : const struct rte_flow_item_gtp *gtp;
14010 : : const struct rte_flow_item_geneve_opt *opt;
14011 : : struct rte_flow_item_ipv6_routing_ext *ext;
14012 : :
14013 : 0 : item = in->args.vc.pattern + i;
14014 : 0 : if (item->spec == NULL)
14015 : 0 : item->spec = flow_item_default_mask(item);
14016 : 0 : src_spec = item->spec;
14017 : 0 : switch (item->type) {
14018 : : case RTE_FLOW_ITEM_TYPE_ETH:
14019 : : size = sizeof(struct rte_ether_hdr);
14020 : : break;
14021 : 0 : case RTE_FLOW_ITEM_TYPE_VLAN:
14022 : : size = sizeof(struct rte_vlan_hdr);
14023 : : proto = RTE_ETHER_TYPE_VLAN;
14024 : 0 : break;
14025 : 0 : case RTE_FLOW_ITEM_TYPE_IPV4:
14026 : : size = sizeof(struct rte_ipv4_hdr);
14027 : : proto = RTE_ETHER_TYPE_IPV4;
14028 : 0 : break;
14029 : 0 : case RTE_FLOW_ITEM_TYPE_IPV6:
14030 : : size = sizeof(struct rte_ipv6_hdr);
14031 : : proto = RTE_ETHER_TYPE_IPV6;
14032 : 0 : break;
14033 : 0 : case RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT:
14034 : : ext = (struct rte_flow_item_ipv6_routing_ext *)(uintptr_t)item->spec;
14035 : 0 : if (!ext->hdr.hdr_len) {
14036 : 0 : size = sizeof(struct rte_ipv6_routing_ext) +
14037 : 0 : (ext->hdr.segments_left << 4);
14038 : 0 : ext->hdr.hdr_len = ext->hdr.segments_left << 1;
14039 : : /* SRv6 without TLV. */
14040 : 0 : if (ext->hdr.type == RTE_IPV6_SRCRT_TYPE_4)
14041 : 0 : ext->hdr.last_entry = ext->hdr.segments_left - 1;
14042 : : } else {
14043 : 0 : size = sizeof(struct rte_ipv6_routing_ext) +
14044 : 0 : (ext->hdr.hdr_len << 3);
14045 : : }
14046 : : proto = IPPROTO_ROUTING;
14047 : : break;
14048 : 0 : case RTE_FLOW_ITEM_TYPE_UDP:
14049 : : size = sizeof(struct rte_udp_hdr);
14050 : : proto = 0x11;
14051 : 0 : break;
14052 : 0 : case RTE_FLOW_ITEM_TYPE_TCP:
14053 : : size = sizeof(struct rte_tcp_hdr);
14054 : : proto = 0x06;
14055 : 0 : break;
14056 : 0 : case RTE_FLOW_ITEM_TYPE_VXLAN:
14057 : : size = sizeof(struct rte_vxlan_hdr);
14058 : 0 : break;
14059 : 0 : case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
14060 : : size = sizeof(struct rte_vxlan_gpe_hdr);
14061 : 0 : break;
14062 : 0 : case RTE_FLOW_ITEM_TYPE_GRE:
14063 : : size = sizeof(struct rte_gre_hdr);
14064 : : proto = 0x2F;
14065 : 0 : break;
14066 : 0 : case RTE_FLOW_ITEM_TYPE_GRE_KEY:
14067 : : size = sizeof(rte_be32_t);
14068 : : proto = 0x0;
14069 : 0 : break;
14070 : 0 : case RTE_FLOW_ITEM_TYPE_MPLS:
14071 : : size = sizeof(struct rte_mpls_hdr);
14072 : : proto = 0x0;
14073 : 0 : break;
14074 : 0 : case RTE_FLOW_ITEM_TYPE_NVGRE:
14075 : : size = sizeof(struct rte_flow_item_nvgre);
14076 : : proto = 0x2F;
14077 : 0 : break;
14078 : 0 : case RTE_FLOW_ITEM_TYPE_GENEVE:
14079 : : size = sizeof(struct rte_geneve_hdr);
14080 : 0 : break;
14081 : 0 : case RTE_FLOW_ITEM_TYPE_GENEVE_OPT:
14082 : : opt = (const struct rte_flow_item_geneve_opt *)
14083 : : item->spec;
14084 : : size = offsetof(struct rte_flow_item_geneve_opt,
14085 : : option_len) + sizeof(uint8_t);
14086 : 0 : if (opt->option_len && opt->data) {
14087 : 0 : *total_size += opt->option_len *
14088 : : sizeof(uint32_t);
14089 : 0 : rte_memcpy(data_tail - (*total_size),
14090 : : opt->data,
14091 : : opt->option_len * sizeof(uint32_t));
14092 : : }
14093 : : break;
14094 : 0 : case RTE_FLOW_ITEM_TYPE_L2TPV3OIP:
14095 : : size = sizeof(rte_be32_t);
14096 : : proto = 0x73;
14097 : 0 : break;
14098 : 0 : case RTE_FLOW_ITEM_TYPE_ESP:
14099 : : size = sizeof(struct rte_esp_hdr);
14100 : : proto = 0x32;
14101 : 0 : break;
14102 : 0 : case RTE_FLOW_ITEM_TYPE_AH:
14103 : : size = sizeof(struct rte_flow_item_ah);
14104 : : proto = 0x33;
14105 : 0 : break;
14106 : 0 : case RTE_FLOW_ITEM_TYPE_GTP:
14107 : 0 : if (gtp_psc < 0) {
14108 : : size = sizeof(struct rte_gtp_hdr);
14109 : : break;
14110 : : }
14111 : 0 : if (gtp_psc != i + 1) {
14112 : 0 : fprintf(stderr,
14113 : : "Error - GTP PSC does not follow GTP\n");
14114 : 0 : goto error;
14115 : : }
14116 : : gtp = item->spec;
14117 : 0 : if (gtp->hdr.s == 1 || gtp->hdr.pn == 1) {
14118 : : /* Only E flag should be set. */
14119 : 0 : fprintf(stderr,
14120 : : "Error - GTP unsupported flags\n");
14121 : 0 : goto error;
14122 : : } else {
14123 : 0 : struct rte_gtp_hdr_ext_word ext_word = {
14124 : : .next_ext = 0x85
14125 : : };
14126 : :
14127 : : /* We have to add GTP header extra word. */
14128 : 0 : *total_size += sizeof(ext_word);
14129 : 0 : rte_memcpy(data_tail - (*total_size),
14130 : : &ext_word, sizeof(ext_word));
14131 : : }
14132 : : size = sizeof(struct rte_gtp_hdr);
14133 : 0 : break;
14134 : 0 : case RTE_FLOW_ITEM_TYPE_GTP_PSC:
14135 : 0 : if (gtp_psc >= 0) {
14136 : 0 : fprintf(stderr,
14137 : : "Error - Multiple GTP PSC items\n");
14138 : 0 : goto error;
14139 : : } else {
14140 : : const struct rte_flow_item_gtp_psc
14141 : : *opt = item->spec;
14142 : : struct rte_gtp_psc_generic_hdr *hdr;
14143 : : size_t hdr_size = RTE_ALIGN(sizeof(*hdr),
14144 : : sizeof(int32_t));
14145 : :
14146 : 0 : *total_size += hdr_size;
14147 : 0 : hdr = (typeof(hdr))(data_tail - (*total_size));
14148 : : memset(hdr, 0, hdr_size);
14149 : 0 : *hdr = opt->hdr;
14150 : 0 : hdr->ext_hdr_len = 1;
14151 : : gtp_psc = i;
14152 : : size = 0;
14153 : : }
14154 : 0 : break;
14155 : 0 : case RTE_FLOW_ITEM_TYPE_PFCP:
14156 : : size = sizeof(struct rte_flow_item_pfcp);
14157 : 0 : break;
14158 : 0 : case RTE_FLOW_ITEM_TYPE_FLEX:
14159 : 0 : if (item->spec != NULL) {
14160 : 0 : size = ((const struct rte_flow_item_flex *)item->spec)->length;
14161 : 0 : src_spec = ((const struct rte_flow_item_flex *)item->spec)->pattern;
14162 : : } else {
14163 : : size = 0;
14164 : : src_spec = NULL;
14165 : : }
14166 : : break;
14167 : 0 : case RTE_FLOW_ITEM_TYPE_GRE_OPTION:
14168 : : size = 0;
14169 : 0 : if (item->spec) {
14170 : : const struct rte_flow_item_gre_opt
14171 : : *opt = item->spec;
14172 : 0 : if (opt->checksum_rsvd.checksum) {
14173 : 0 : *total_size +=
14174 : : sizeof(opt->checksum_rsvd);
14175 : 0 : rte_memcpy(data_tail - (*total_size),
14176 : 0 : &opt->checksum_rsvd,
14177 : : sizeof(opt->checksum_rsvd));
14178 : : }
14179 : 0 : if (opt->key.key) {
14180 : 0 : *total_size += sizeof(opt->key.key);
14181 : 0 : rte_memcpy(data_tail - (*total_size),
14182 : 0 : &opt->key.key,
14183 : : sizeof(opt->key.key));
14184 : : }
14185 : 0 : if (opt->sequence.sequence) {
14186 : 0 : *total_size += sizeof(opt->sequence.sequence);
14187 : 0 : rte_memcpy(data_tail - (*total_size),
14188 : 0 : &opt->sequence.sequence,
14189 : : sizeof(opt->sequence.sequence));
14190 : : }
14191 : : }
14192 : : proto = 0x2F;
14193 : : break;
14194 : 0 : default:
14195 : 0 : fprintf(stderr, "Error - Not supported item\n");
14196 : 0 : goto error;
14197 : : }
14198 : 0 : if (size) {
14199 : 0 : *total_size += size;
14200 : 0 : rte_memcpy(data_tail - (*total_size), src_spec, size);
14201 : : /* update some fields which cannot be set by cmdline */
14202 : 0 : update_fields((data_tail - (*total_size)), item,
14203 : : upper_layer);
14204 : : upper_layer = proto;
14205 : : }
14206 : : }
14207 : 0 : if (verbose_level & 0x1)
14208 : 0 : printf("total data size is %zu\n", (*total_size));
14209 : : RTE_ASSERT((*total_size) <= ACTION_RAW_ENCAP_MAX_DATA);
14210 : 0 : memmove(data, (data_tail - (*total_size)), *total_size);
14211 : : return;
14212 : :
14213 : 0 : error:
14214 : 0 : *total_size = 0;
14215 : : memset(data, 0x00, ACTION_RAW_ENCAP_MAX_DATA);
14216 : : }
14217 : :
14218 : : /** Populate help strings for current token (cmdline API). */
14219 : : static int
14220 : 0 : cmd_set_raw_get_help(cmdline_parse_token_hdr_t *hdr, char *dst,
14221 : : unsigned int size)
14222 : : {
14223 : : struct context *ctx = &cmd_flow_context;
14224 : 0 : const struct token *token = &token_list[ctx->prev];
14225 : :
14226 : : (void)hdr;
14227 : 0 : if (!size)
14228 : : return -1;
14229 : : /* Set token type and update global help with details. */
14230 : 0 : snprintf(dst, size, "%s", (token->type ? token->type : "TOKEN"));
14231 : 0 : if (token->help)
14232 : 0 : cmd_set_raw.help_str = token->help;
14233 : : else
14234 : 0 : cmd_set_raw.help_str = token->name;
14235 : : return 0;
14236 : : }
14237 : :
14238 : : /** Token definition template (cmdline API). */
14239 : : static struct cmdline_token_hdr cmd_set_raw_token_hdr = {
14240 : : .ops = &(struct cmdline_token_ops){
14241 : : .parse = cmd_flow_parse,
14242 : : .complete_get_nb = cmd_flow_complete_get_nb,
14243 : : .complete_get_elt = cmd_flow_complete_get_elt,
14244 : : .get_help = cmd_set_raw_get_help,
14245 : : },
14246 : : .offset = 0,
14247 : : };
14248 : :
14249 : : /** Populate the next dynamic token. */
14250 : : static void
14251 : 0 : cmd_set_raw_tok(cmdline_parse_token_hdr_t **hdr,
14252 : : cmdline_parse_token_hdr_t **hdr_inst)
14253 : : {
14254 : : struct context *ctx = &cmd_flow_context;
14255 : :
14256 : : /* Always reinitialize context before requesting the first token. */
14257 : 0 : if (!(hdr_inst - cmd_set_raw.tokens)) {
14258 : : cmd_flow_context_init(ctx);
14259 : 0 : ctx->curr = START_SET;
14260 : : }
14261 : : /* Return NULL when no more tokens are expected. */
14262 : 0 : if (!ctx->next_num && (ctx->curr != START_SET)) {
14263 : 0 : *hdr = NULL;
14264 : 0 : return;
14265 : : }
14266 : : /* Determine if command should end here. */
14267 : 0 : if (ctx->eol && ctx->last && ctx->next_num) {
14268 : 0 : const enum index *list = ctx->next[ctx->next_num - 1];
14269 : : int i;
14270 : :
14271 : 0 : for (i = 0; list[i]; ++i) {
14272 : 0 : if (list[i] != END)
14273 : : continue;
14274 : 0 : *hdr = NULL;
14275 : 0 : return;
14276 : : }
14277 : : }
14278 : 0 : *hdr = &cmd_set_raw_token_hdr;
14279 : : }
14280 : :
14281 : : /** Token generator and output processing callback (cmdline API). */
14282 : : static void
14283 : 0 : cmd_set_raw_cb(void *arg0, struct cmdline *cl, void *arg2)
14284 : : {
14285 : 0 : if (cl == NULL)
14286 : 0 : cmd_set_raw_tok(arg0, arg2);
14287 : : else
14288 : 0 : cmd_set_raw_parsed(arg0);
14289 : 0 : }
14290 : :
14291 : : /** Global parser instance (cmdline API). */
14292 : : cmdline_parse_inst_t cmd_set_raw = {
14293 : : .f = cmd_set_raw_cb,
14294 : : .data = NULL, /**< Unused. */
14295 : : .help_str = NULL, /**< Updated by cmd_flow_get_help(). */
14296 : : .tokens = {
14297 : : NULL,
14298 : : }, /**< Tokens are returned by cmd_flow_tok(). */
14299 : : };
14300 : :
14301 : : /* *** display raw_encap/raw_decap buf */
14302 : : struct cmd_show_set_raw_result {
14303 : : cmdline_fixed_string_t cmd_show;
14304 : : cmdline_fixed_string_t cmd_what;
14305 : : cmdline_fixed_string_t cmd_all;
14306 : : uint16_t cmd_index;
14307 : : };
14308 : :
14309 : : static void
14310 : 0 : cmd_show_set_raw_parsed(void *parsed_result, struct cmdline *cl, void *data)
14311 : : {
14312 : : struct cmd_show_set_raw_result *res = parsed_result;
14313 : 0 : uint16_t index = res->cmd_index;
14314 : : uint8_t all = 0;
14315 : : uint8_t *raw_data = NULL;
14316 : : size_t raw_size = 0;
14317 : 0 : char title[16] = {0};
14318 : :
14319 : : RTE_SET_USED(cl);
14320 : : RTE_SET_USED(data);
14321 : 0 : if (!strcmp(res->cmd_all, "all")) {
14322 : : all = 1;
14323 : : index = 0;
14324 : 0 : } else if (index >= RAW_ENCAP_CONFS_MAX_NUM) {
14325 : 0 : fprintf(stderr, "index should be 0-%u\n",
14326 : : RAW_ENCAP_CONFS_MAX_NUM - 1);
14327 : 0 : return;
14328 : : }
14329 : : do {
14330 : 0 : if (!strcmp(res->cmd_what, "raw_encap")) {
14331 : 0 : raw_data = (uint8_t *)&raw_encap_confs[index].data;
14332 : 0 : raw_size = raw_encap_confs[index].size;
14333 : : snprintf(title, 16, "\nindex: %u", index);
14334 : 0 : rte_hexdump(stdout, title, raw_data, raw_size);
14335 : : } else {
14336 : 0 : raw_data = (uint8_t *)&raw_decap_confs[index].data;
14337 : 0 : raw_size = raw_decap_confs[index].size;
14338 : : snprintf(title, 16, "\nindex: %u", index);
14339 : 0 : rte_hexdump(stdout, title, raw_data, raw_size);
14340 : : }
14341 : 0 : } while (all && ++index < RAW_ENCAP_CONFS_MAX_NUM);
14342 : : }
14343 : :
14344 : : static cmdline_parse_token_string_t cmd_show_set_raw_cmd_show =
14345 : : TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
14346 : : cmd_show, "show");
14347 : : static cmdline_parse_token_string_t cmd_show_set_raw_cmd_what =
14348 : : TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
14349 : : cmd_what, "raw_encap#raw_decap");
14350 : : static cmdline_parse_token_num_t cmd_show_set_raw_cmd_index =
14351 : : TOKEN_NUM_INITIALIZER(struct cmd_show_set_raw_result,
14352 : : cmd_index, RTE_UINT16);
14353 : : static cmdline_parse_token_string_t cmd_show_set_raw_cmd_all =
14354 : : TOKEN_STRING_INITIALIZER(struct cmd_show_set_raw_result,
14355 : : cmd_all, "all");
14356 : : cmdline_parse_inst_t cmd_show_set_raw = {
14357 : : .f = cmd_show_set_raw_parsed,
14358 : : .data = NULL,
14359 : : .help_str = "show <raw_encap|raw_decap> <index>",
14360 : : .tokens = {
14361 : : (void *)&cmd_show_set_raw_cmd_show,
14362 : : (void *)&cmd_show_set_raw_cmd_what,
14363 : : (void *)&cmd_show_set_raw_cmd_index,
14364 : : NULL,
14365 : : },
14366 : : };
14367 : : cmdline_parse_inst_t cmd_show_set_raw_all = {
14368 : : .f = cmd_show_set_raw_parsed,
14369 : : .data = NULL,
14370 : : .help_str = "show <raw_encap|raw_decap> all",
14371 : : .tokens = {
14372 : : (void *)&cmd_show_set_raw_cmd_show,
14373 : : (void *)&cmd_show_set_raw_cmd_what,
14374 : : (void *)&cmd_show_set_raw_cmd_all,
14375 : : NULL,
14376 : : },
14377 : : };
|