xref: /dpdk/lib/ethdev/rte_flow.h (revision 4aa10e5dc1b0fd6cc5b1b18770ac603e2c33a66c)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright 2016 6WIND S.A.
3  * Copyright 2016 Mellanox Technologies, Ltd
4  */
5 
6 #ifndef RTE_FLOW_H_
7 #define RTE_FLOW_H_
8 
9 /**
10  * @file
11  * RTE generic flow API
12  *
13  * This interface provides the ability to program packet matching and
14  * associated actions in hardware through flow rules.
15  */
16 
17 #include <stddef.h>
18 #include <stdint.h>
19 
20 #include <rte_compat.h>
21 #include <rte_common.h>
22 #include <rte_ether.h>
23 #include <rte_arp.h>
24 #include <rte_icmp.h>
25 #include <rte_ip.h>
26 #include <rte_sctp.h>
27 #include <rte_tcp.h>
28 #include <rte_udp.h>
29 #include <rte_vxlan.h>
30 #include <rte_esp.h>
31 #include <rte_higig.h>
32 #include <rte_ecpri.h>
33 #include <rte_bitops.h>
34 #include <rte_mbuf_dyn.h>
35 #include <rte_meter.h>
36 #include <rte_gtp.h>
37 #include <rte_l2tpv2.h>
38 #include <rte_ppp.h>
39 #include <rte_gre.h>
40 #include <rte_macsec.h>
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 #define RTE_FLOW_LOG(level, ...) \
47 	rte_log(RTE_LOG_ ## level, rte_eth_dev_logtype, "" __VA_ARGS__)
48 
49 /**
50  * Flow rule attributes.
51  *
52  * Priorities are set on a per rule based within groups.
53  *
54  * Lower values denote higher priority, the highest priority for a flow rule
55  * is 0, so that a flow that matches for than one rule, the rule with the
56  * lowest priority value will always be matched.
57  *
58  * Although optional, applications are encouraged to group similar rules as
59  * much as possible to fully take advantage of hardware capabilities
60  * (e.g. optimized matching) and work around limitations (e.g. a single
61  * pattern type possibly allowed in a given group). Applications should be
62  * aware that groups are not linked by default, and that they must be
63  * explicitly linked by the application using the JUMP action.
64  *
65  * Priority levels are arbitrary and up to the application, they
66  * do not need to be contiguous nor start from 0, however the maximum number
67  * varies between devices and may be affected by existing flow rules.
68  *
69  * If a packet is matched by several rules of a given group for a given
70  * priority level, the outcome is undefined. It can take any path, may be
71  * duplicated or even cause unrecoverable errors.
72  *
73  * Note that support for more than a single group and priority level is not
74  * guaranteed.
75  *
76  * At vNIC / ethdev level, flow rules can apply to inbound and / or outbound
77  * traffic (ingress / egress), with respect to the vNIC / ethdev in question.
78  * At embedded switch level, flow rules apply to all traffic seen by it
79  * unless fitting meta items are used to set concrete traffic source(s).
80  *
81  * Several pattern items and actions are valid and can be used in both
82  * directions. Those valid for only one direction are described as such.
83  *
84  * At least one direction must be specified.
85  *
86  * Specifying both directions at once for a given rule is not recommended
87  * but may be valid in a few cases.
88  */
89 struct rte_flow_attr {
90 	uint32_t group; /**< Priority group. */
91 	uint32_t priority; /**< Rule priority level within group. */
92 	/**
93 	 * The rule in question applies to ingress traffic (non-"transfer").
94 	 */
95 	uint32_t ingress:1;
96 	/**
97 	 * The rule in question applies to egress traffic (non-"transfer").
98 	 */
99 	uint32_t egress:1;
100 	/**
101 	 * Instead of simply matching the properties of traffic as it would
102 	 * appear on a given DPDK port ID, enabling this attribute transfers
103 	 * a flow rule to the lowest possible level of any device endpoints
104 	 * found in the pattern.
105 	 *
106 	 * When supported, this effectively enables an application to
107 	 * re-route traffic not necessarily intended for it (e.g. coming
108 	 * from or addressed to different physical ports, VFs or
109 	 * applications) at the device level.
110 	 *
111 	 * The application should match traffic originating from precise
112 	 * locations. See items PORT_REPRESENTOR and REPRESENTED_PORT.
113 	 *
114 	 * Managing "transfer" flows requires that the user communicate them
115 	 * through a suitable port. @see rte_flow_pick_transfer_proxy().
116 	 */
117 	uint32_t transfer:1;
118 	uint32_t reserved:29; /**< Reserved, must be zero. */
119 };
120 
121 /**
122  * Matching pattern item types.
123  *
124  * Pattern items fall in two categories:
125  *
126  * - Matching protocol headers and packet data, usually associated with a
127  *   specification structure. These must be stacked in the same order as the
128  *   protocol layers to match inside packets, starting from the lowest.
129  *
130  * - Matching meta-data or affecting pattern processing, often without a
131  *   specification structure. Since they do not match packet contents, their
132  *   position in the list is usually not relevant.
133  *
134  * See the description of individual types for more information. Those
135  * marked with [META] fall into the second category.
136  */
137 enum rte_flow_item_type {
138 	/**
139 	 * [META]
140 	 *
141 	 * End marker for item lists. Prevents further processing of items,
142 	 * thereby ending the pattern.
143 	 *
144 	 * No associated specification structure.
145 	 */
146 	RTE_FLOW_ITEM_TYPE_END,
147 
148 	/**
149 	 * [META]
150 	 *
151 	 * Used as a placeholder for convenience. It is ignored and simply
152 	 * discarded by PMDs.
153 	 *
154 	 * No associated specification structure.
155 	 */
156 	RTE_FLOW_ITEM_TYPE_VOID,
157 
158 	/**
159 	 * [META]
160 	 *
161 	 * Inverted matching, i.e. process packets that do not match the
162 	 * pattern.
163 	 *
164 	 * No associated specification structure.
165 	 */
166 	RTE_FLOW_ITEM_TYPE_INVERT,
167 
168 	/**
169 	 * Matches any protocol in place of the current layer, a single ANY
170 	 * may also stand for several protocol layers.
171 	 *
172 	 * See struct rte_flow_item_any.
173 	 */
174 	RTE_FLOW_ITEM_TYPE_ANY,
175 
176 	/**
177 	 * @deprecated
178 	 * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
179 	 * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
180 	 *
181 	 * [META]
182 	 *
183 	 * Matches traffic originating from (ingress) or going to (egress) a
184 	 * given DPDK port ID.
185 	 *
186 	 * See struct rte_flow_item_port_id.
187 	 */
188 	RTE_FLOW_ITEM_TYPE_PORT_ID,
189 
190 	/**
191 	 * Matches a byte string of a given length at a given offset.
192 	 *
193 	 * See struct rte_flow_item_raw.
194 	 */
195 	RTE_FLOW_ITEM_TYPE_RAW,
196 
197 	/**
198 	 * Matches an Ethernet header.
199 	 *
200 	 * See struct rte_flow_item_eth.
201 	 */
202 	RTE_FLOW_ITEM_TYPE_ETH,
203 
204 	/**
205 	 * Matches an 802.1Q/ad VLAN tag.
206 	 *
207 	 * See struct rte_flow_item_vlan.
208 	 */
209 	RTE_FLOW_ITEM_TYPE_VLAN,
210 
211 	/**
212 	 * Matches an IPv4 header.
213 	 *
214 	 * See struct rte_flow_item_ipv4.
215 	 */
216 	RTE_FLOW_ITEM_TYPE_IPV4,
217 
218 	/**
219 	 * Matches an IPv6 header.
220 	 *
221 	 * See struct rte_flow_item_ipv6.
222 	 */
223 	RTE_FLOW_ITEM_TYPE_IPV6,
224 
225 	/**
226 	 * Matches an ICMP header.
227 	 *
228 	 * See struct rte_flow_item_icmp.
229 	 */
230 	RTE_FLOW_ITEM_TYPE_ICMP,
231 
232 	/**
233 	 * Matches a UDP header.
234 	 *
235 	 * See struct rte_flow_item_udp.
236 	 */
237 	RTE_FLOW_ITEM_TYPE_UDP,
238 
239 	/**
240 	 * Matches a TCP header.
241 	 *
242 	 * See struct rte_flow_item_tcp.
243 	 */
244 	RTE_FLOW_ITEM_TYPE_TCP,
245 
246 	/**
247 	 * Matches a SCTP header.
248 	 *
249 	 * See struct rte_flow_item_sctp.
250 	 */
251 	RTE_FLOW_ITEM_TYPE_SCTP,
252 
253 	/**
254 	 * Matches a VXLAN header.
255 	 *
256 	 * See struct rte_flow_item_vxlan.
257 	 */
258 	RTE_FLOW_ITEM_TYPE_VXLAN,
259 
260 	/**
261 	 * Matches a E_TAG header.
262 	 *
263 	 * See struct rte_flow_item_e_tag.
264 	 */
265 	RTE_FLOW_ITEM_TYPE_E_TAG,
266 
267 	/**
268 	 * Matches a NVGRE header.
269 	 *
270 	 * See struct rte_flow_item_nvgre.
271 	 */
272 	RTE_FLOW_ITEM_TYPE_NVGRE,
273 
274 	/**
275 	 * Matches a MPLS header.
276 	 *
277 	 * See struct rte_flow_item_mpls.
278 	 */
279 	RTE_FLOW_ITEM_TYPE_MPLS,
280 
281 	/**
282 	 * Matches a GRE header.
283 	 *
284 	 * See struct rte_flow_item_gre.
285 	 */
286 	RTE_FLOW_ITEM_TYPE_GRE,
287 
288 	/**
289 	 * [META]
290 	 *
291 	 * Fuzzy pattern match, expect faster than default.
292 	 *
293 	 * This is for device that support fuzzy matching option.
294 	 * Usually a fuzzy matching is fast but the cost is accuracy.
295 	 *
296 	 * See struct rte_flow_item_fuzzy.
297 	 */
298 	RTE_FLOW_ITEM_TYPE_FUZZY,
299 
300 	/**
301 	 * Matches a GTP header.
302 	 *
303 	 * Configure flow for GTP packets.
304 	 *
305 	 * See struct rte_flow_item_gtp.
306 	 */
307 	RTE_FLOW_ITEM_TYPE_GTP,
308 
309 	/**
310 	 * Matches a GTP header.
311 	 *
312 	 * Configure flow for GTP-C packets.
313 	 *
314 	 * See struct rte_flow_item_gtp.
315 	 */
316 	RTE_FLOW_ITEM_TYPE_GTPC,
317 
318 	/**
319 	 * Matches a GTP header.
320 	 *
321 	 * Configure flow for GTP-U packets.
322 	 *
323 	 * See struct rte_flow_item_gtp.
324 	 */
325 	RTE_FLOW_ITEM_TYPE_GTPU,
326 
327 	/**
328 	 * Matches a ESP header.
329 	 *
330 	 * See struct rte_flow_item_esp.
331 	 */
332 	RTE_FLOW_ITEM_TYPE_ESP,
333 
334 	/**
335 	 * Matches a GENEVE header.
336 	 *
337 	 * See struct rte_flow_item_geneve.
338 	 */
339 	RTE_FLOW_ITEM_TYPE_GENEVE,
340 
341 	/**
342 	 * Matches a VXLAN-GPE header.
343 	 *
344 	 * See struct rte_flow_item_vxlan_gpe.
345 	 */
346 	RTE_FLOW_ITEM_TYPE_VXLAN_GPE,
347 
348 	/**
349 	 * Matches an ARP header for Ethernet/IPv4.
350 	 *
351 	 * See struct rte_flow_item_arp_eth_ipv4.
352 	 */
353 	RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4,
354 
355 	/**
356 	 * Matches the presence of any IPv6 extension header.
357 	 *
358 	 * See struct rte_flow_item_ipv6_ext.
359 	 */
360 	RTE_FLOW_ITEM_TYPE_IPV6_EXT,
361 
362 	/**
363 	 * Matches any ICMPv6 header.
364 	 *
365 	 * See struct rte_flow_item_icmp6.
366 	 */
367 	RTE_FLOW_ITEM_TYPE_ICMP6,
368 
369 	/**
370 	 * Matches an ICMPv6 neighbor discovery solicitation.
371 	 *
372 	 * See struct rte_flow_item_icmp6_nd_ns.
373 	 */
374 	RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS,
375 
376 	/**
377 	 * Matches an ICMPv6 neighbor discovery advertisement.
378 	 *
379 	 * See struct rte_flow_item_icmp6_nd_na.
380 	 */
381 	RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA,
382 
383 	/**
384 	 * Matches the presence of any ICMPv6 neighbor discovery option.
385 	 *
386 	 * See struct rte_flow_item_icmp6_nd_opt.
387 	 */
388 	RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT,
389 
390 	/**
391 	 * Matches an ICMPv6 neighbor discovery source Ethernet link-layer
392 	 * address option.
393 	 *
394 	 * See struct rte_flow_item_icmp6_nd_opt_sla_eth.
395 	 */
396 	RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH,
397 
398 	/**
399 	 * Matches an ICMPv6 neighbor discovery target Ethernet link-layer
400 	 * address option.
401 	 *
402 	 * See struct rte_flow_item_icmp6_nd_opt_tla_eth.
403 	 */
404 	RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH,
405 
406 	/**
407 	 * Matches specified mark field.
408 	 *
409 	 * See struct rte_flow_item_mark.
410 	 */
411 	RTE_FLOW_ITEM_TYPE_MARK,
412 
413 	/**
414 	 * [META]
415 	 *
416 	 * Matches a metadata value.
417 	 *
418 	 * See struct rte_flow_item_meta.
419 	 */
420 	RTE_FLOW_ITEM_TYPE_META,
421 
422 	/**
423 	 * Matches a GRE optional key field.
424 	 *
425 	 * The value should a big-endian 32bit integer.
426 	 *
427 	 * When this item present the K bit is implicitly matched as "1"
428 	 * in the default mask.
429 	 *
430 	 * @p spec/mask type:
431 	 * @code rte_be32_t * @endcode
432 	 */
433 	RTE_FLOW_ITEM_TYPE_GRE_KEY,
434 
435 	/**
436 	 * Matches a GTP extension header: PDU session container.
437 	 *
438 	 * Configure flow for GTP packets with extension header type 0x85.
439 	 *
440 	 * See struct rte_flow_item_gtp_psc.
441 	 */
442 	RTE_FLOW_ITEM_TYPE_GTP_PSC,
443 
444 	/**
445 	 * Matches a PPPoE header.
446 	 *
447 	 * Configure flow for PPPoE session packets.
448 	 *
449 	 * See struct rte_flow_item_pppoe.
450 	 */
451 	RTE_FLOW_ITEM_TYPE_PPPOES,
452 
453 	/**
454 	 * Matches a PPPoE header.
455 	 *
456 	 * Configure flow for PPPoE discovery packets.
457 	 *
458 	 * See struct rte_flow_item_pppoe.
459 	 */
460 	RTE_FLOW_ITEM_TYPE_PPPOED,
461 
462 	/**
463 	 * Matches a PPPoE optional proto_id field.
464 	 *
465 	 * It only applies to PPPoE session packets.
466 	 *
467 	 * See struct rte_flow_item_pppoe_proto_id.
468 	 */
469 	RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID,
470 
471 	/**
472 	 * Matches Network service header (NSH).
473 	 * See struct rte_flow_item_nsh.
474 	 *
475 	 */
476 	RTE_FLOW_ITEM_TYPE_NSH,
477 
478 	/**
479 	 * Matches Internet Group Management Protocol (IGMP).
480 	 * See struct rte_flow_item_igmp.
481 	 *
482 	 */
483 	RTE_FLOW_ITEM_TYPE_IGMP,
484 
485 	/**
486 	 * Matches IP Authentication Header (AH).
487 	 * See struct rte_flow_item_ah.
488 	 *
489 	 */
490 	RTE_FLOW_ITEM_TYPE_AH,
491 
492 	/**
493 	 * Matches a HIGIG header.
494 	 * see struct rte_flow_item_higig2_hdr.
495 	 */
496 	RTE_FLOW_ITEM_TYPE_HIGIG2,
497 
498 	/**
499 	 * [META]
500 	 *
501 	 * Matches a tag value.
502 	 *
503 	 * See struct rte_flow_item_tag.
504 	 */
505 	RTE_FLOW_ITEM_TYPE_TAG,
506 
507 	/**
508 	 * Matches a L2TPv3 over IP header.
509 	 *
510 	 * Configure flow for L2TPv3 over IP packets.
511 	 *
512 	 * See struct rte_flow_item_l2tpv3oip.
513 	 */
514 	RTE_FLOW_ITEM_TYPE_L2TPV3OIP,
515 
516 	/**
517 	 * Matches PFCP Header.
518 	 * See struct rte_flow_item_pfcp.
519 	 *
520 	 */
521 	RTE_FLOW_ITEM_TYPE_PFCP,
522 
523 	/**
524 	 * Matches eCPRI Header.
525 	 *
526 	 * Configure flow for eCPRI over ETH or UDP packets.
527 	 *
528 	 * See struct rte_flow_item_ecpri.
529 	 */
530 	RTE_FLOW_ITEM_TYPE_ECPRI,
531 
532 	/**
533 	 * Matches the presence of IPv6 fragment extension header.
534 	 *
535 	 * See struct rte_flow_item_ipv6_frag_ext.
536 	 */
537 	RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
538 
539 	/**
540 	 * Matches Geneve Variable Length Option
541 	 *
542 	 * See struct rte_flow_item_geneve_opt
543 	 */
544 	RTE_FLOW_ITEM_TYPE_GENEVE_OPT,
545 
546 	/**
547 	 * [META]
548 	 *
549 	 * Matches on packet integrity.
550 	 * For some devices application needs to enable integration checks in HW
551 	 * before using this item.
552 	 *
553 	 * @see struct rte_flow_item_integrity.
554 	 */
555 	RTE_FLOW_ITEM_TYPE_INTEGRITY,
556 
557 	/**
558 	 * [META]
559 	 *
560 	 * Matches conntrack state.
561 	 *
562 	 * @see struct rte_flow_item_conntrack.
563 	 */
564 	RTE_FLOW_ITEM_TYPE_CONNTRACK,
565 
566 	/**
567 	 * [META]
568 	 *
569 	 * Matches traffic entering the embedded switch from the given ethdev.
570 	 *
571 	 * @see struct rte_flow_item_ethdev
572 	 */
573 	RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR,
574 
575 	/**
576 	 * [META]
577 	 *
578 	 * Matches traffic entering the embedded switch from
579 	 * the entity represented by the given ethdev.
580 	 *
581 	 * @see struct rte_flow_item_ethdev
582 	 */
583 	RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT,
584 
585 	/**
586 	 * Matches a configured set of fields at runtime calculated offsets
587 	 * over the generic network header with variable length and
588 	 * flexible pattern
589 	 *
590 	 * @see struct rte_flow_item_flex.
591 	 */
592 	RTE_FLOW_ITEM_TYPE_FLEX,
593 
594 	/**
595 	 * Matches L2TPv2 Header.
596 	 *
597 	 * See struct rte_flow_item_l2tpv2.
598 	 */
599 	RTE_FLOW_ITEM_TYPE_L2TPV2,
600 
601 	/**
602 	 * Matches PPP Header.
603 	 *
604 	 * See struct rte_flow_item_ppp.
605 	 */
606 	RTE_FLOW_ITEM_TYPE_PPP,
607 
608 	/**
609 	 * Matches GRE optional fields.
610 	 *
611 	 * See struct rte_flow_item_gre_opt.
612 	 */
613 	RTE_FLOW_ITEM_TYPE_GRE_OPTION,
614 
615 	/**
616 	 * Matches MACsec Ethernet Header.
617 	 *
618 	 * See struct rte_flow_item_macsec.
619 	 */
620 	RTE_FLOW_ITEM_TYPE_MACSEC,
621 
622 	/**
623 	 * Matches Meter Color Marker.
624 	 *
625 	 * See struct rte_flow_item_meter_color.
626 	 */
627 	RTE_FLOW_ITEM_TYPE_METER_COLOR,
628 
629 	/**
630 	 * Matches the presence of IPv6 routing extension header.
631 	 *
632 	 * @see struct rte_flow_item_ipv6_routing_ext.
633 	 */
634 	RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT,
635 };
636 
637 /**
638  *
639  * RTE_FLOW_ITEM_TYPE_HIGIG2
640  * Matches higig2 header
641  */
642 RTE_STD_C11
643 struct rte_flow_item_higig2_hdr {
644 	struct rte_higig2_hdr hdr;
645 };
646 
647 /** Default mask for RTE_FLOW_ITEM_TYPE_HIGIG2. */
648 #ifndef __cplusplus
649 static const struct rte_flow_item_higig2_hdr rte_flow_item_higig2_hdr_mask = {
650 	.hdr = {
651 		.ppt1 = {
652 			.classification = RTE_BE16(UINT16_MAX),
653 			.vid = RTE_BE16(0xfff),
654 		},
655 	},
656 };
657 #endif
658 
659 /**
660  * RTE_FLOW_ITEM_TYPE_ANY
661  *
662  * Matches any protocol in place of the current layer, a single ANY may also
663  * stand for several protocol layers.
664  *
665  * This is usually specified as the first pattern item when looking for a
666  * protocol anywhere in a packet.
667  *
668  * A zeroed mask stands for any number of layers.
669  */
670 struct rte_flow_item_any {
671 	uint32_t num; /**< Number of layers covered. */
672 };
673 
674 /** Default mask for RTE_FLOW_ITEM_TYPE_ANY. */
675 #ifndef __cplusplus
676 static const struct rte_flow_item_any rte_flow_item_any_mask = {
677 	.num = 0x00000000,
678 };
679 #endif
680 
681 /**
682  * @deprecated
683  * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
684  * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
685  *
686  * RTE_FLOW_ITEM_TYPE_PORT_ID
687  *
688  * Matches traffic originating from (ingress) or going to (egress) a given
689  * DPDK port ID.
690  *
691  * Normally only supported if the port ID in question is known by the
692  * underlying PMD and related to the device the flow rule is created
693  * against.
694  */
695 struct rte_flow_item_port_id {
696 	uint32_t id; /**< DPDK port ID. */
697 };
698 
699 /** Default mask for RTE_FLOW_ITEM_TYPE_PORT_ID. */
700 #ifndef __cplusplus
701 static const struct rte_flow_item_port_id rte_flow_item_port_id_mask = {
702 	.id = 0xffffffff,
703 };
704 #endif
705 
706 /**
707  * RTE_FLOW_ITEM_TYPE_RAW
708  *
709  * Matches a byte string of a given length at a given offset.
710  *
711  * Offset is either absolute (using the start of the packet) or relative to
712  * the end of the previous matched item in the stack, in which case negative
713  * values are allowed.
714  *
715  * If search is enabled, offset is used as the starting point. The search
716  * area can be delimited by setting limit to a nonzero value, which is the
717  * maximum number of bytes after offset where the pattern may start.
718  *
719  * Matching a zero-length pattern is allowed, doing so resets the relative
720  * offset for subsequent items.
721  *
722  * This type does not support ranges (struct rte_flow_item.last).
723  */
724 struct rte_flow_item_raw {
725 	uint32_t relative:1; /**< Look for pattern after the previous item. */
726 	uint32_t search:1; /**< Search pattern from offset (see also limit). */
727 	uint32_t reserved:30; /**< Reserved, must be set to zero. */
728 	int32_t offset; /**< Absolute or relative offset for pattern. */
729 	uint16_t limit; /**< Search area limit for start of pattern. */
730 	uint16_t length; /**< Pattern length. */
731 	const uint8_t *pattern; /**< Byte string to look for. */
732 };
733 
734 /** Default mask for RTE_FLOW_ITEM_TYPE_RAW. */
735 #ifndef __cplusplus
736 static const struct rte_flow_item_raw rte_flow_item_raw_mask = {
737 	.relative = 1,
738 	.search = 1,
739 	.reserved = 0x3fffffff,
740 	.offset = 0xffffffff,
741 	.limit = 0xffff,
742 	.length = 0xffff,
743 	.pattern = NULL,
744 };
745 #endif
746 
747 /**
748  * RTE_FLOW_ITEM_TYPE_ETH
749  *
750  * Matches an Ethernet header.
751  *
752  * Inside @p hdr field, the sub-field @p ether_type stands either for EtherType
753  * or TPID, depending on whether the item is followed by a VLAN item or not. If
754  * two VLAN items follow, the sub-field refers to the outer one, which, in turn,
755  * contains the inner TPID in the similar header field. The innermost VLAN item
756  * contains a layer-3 EtherType. All of that follows the order seen on the wire.
757  *
758  * If the field in question contains a TPID value, only tagged packets with the
759  * specified TPID will match the pattern. Alternatively, it's possible to match
760  * any type of tagged packets by means of the field @p has_vlan rather than use
761  * the EtherType/TPID field. Also, it's possible to leave the two fields unused.
762  * If this is the case, both tagged and untagged packets will match the pattern.
763  */
764 RTE_STD_C11
765 struct rte_flow_item_eth {
766 	union {
767 		struct {
768 			/*
769 			 * These fields are retained for compatibility.
770 			 * Please switch to the new header field below.
771 			 */
772 			struct rte_ether_addr dst; /**< Destination MAC. */
773 			struct rte_ether_addr src; /**< Source MAC. */
774 			rte_be16_t type; /**< EtherType or TPID. */
775 		};
776 		struct rte_ether_hdr hdr;
777 	};
778 	uint32_t has_vlan:1; /**< Packet header contains at least one VLAN. */
779 	uint32_t reserved:31; /**< Reserved, must be zero. */
780 };
781 
782 /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */
783 #ifndef __cplusplus
784 static const struct rte_flow_item_eth rte_flow_item_eth_mask = {
785 	.hdr.dst_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
786 	.hdr.src_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
787 	.hdr.ether_type = RTE_BE16(0x0000),
788 };
789 #endif
790 
791 /**
792  * RTE_FLOW_ITEM_TYPE_VLAN
793  *
794  * Matches an 802.1Q/ad VLAN tag.
795  *
796  * The corresponding standard outer EtherType (TPID) values are
797  * RTE_ETHER_TYPE_VLAN or RTE_ETHER_TYPE_QINQ. It can be overridden by
798  * the preceding pattern item.
799  * If a @p VLAN item is present in the pattern, then only tagged packets will
800  * match the pattern.
801  * The field @p has_more_vlan can be used to match any type of tagged packets,
802  * instead of using the @p eth_proto field of @p hdr.
803  * If the @p eth_proto of @p hdr and @p has_more_vlan fields are not specified,
804  * then any tagged packets will match the pattern.
805  */
806 RTE_STD_C11
807 struct rte_flow_item_vlan {
808 	union {
809 		struct {
810 			/*
811 			 * These fields are retained for compatibility.
812 			 * Please switch to the new header field below.
813 			 */
814 			rte_be16_t tci; /**< Tag control information. */
815 			rte_be16_t inner_type; /**< Inner EtherType or TPID. */
816 		};
817 		struct rte_vlan_hdr hdr;
818 	};
819 	/** Packet header contains at least one more VLAN, after this VLAN. */
820 	uint32_t has_more_vlan:1;
821 	uint32_t reserved:31; /**< Reserved, must be zero. */
822 };
823 
824 /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */
825 #ifndef __cplusplus
826 static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = {
827 	.hdr.vlan_tci = RTE_BE16(0x0fff),
828 	.hdr.eth_proto = RTE_BE16(0x0000),
829 };
830 #endif
831 
832 /**
833  * RTE_FLOW_ITEM_TYPE_IPV4
834  *
835  * Matches an IPv4 header.
836  *
837  * Note: IPv4 options are handled by dedicated pattern items.
838  */
839 struct rte_flow_item_ipv4 {
840 	struct rte_ipv4_hdr hdr; /**< IPv4 header definition. */
841 };
842 
843 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV4. */
844 #ifndef __cplusplus
845 static const struct rte_flow_item_ipv4 rte_flow_item_ipv4_mask = {
846 	.hdr = {
847 		.src_addr = RTE_BE32(0xffffffff),
848 		.dst_addr = RTE_BE32(0xffffffff),
849 	},
850 };
851 #endif
852 
853 /**
854  * RTE_FLOW_ITEM_TYPE_IPV6.
855  *
856  * Matches an IPv6 header.
857  *
858  * Dedicated flags indicate if header contains specific extension headers.
859  */
860 struct rte_flow_item_ipv6 {
861 	struct rte_ipv6_hdr hdr; /**< IPv6 header definition. */
862 	/** Header contains Hop-by-Hop Options extension header. */
863 	uint32_t has_hop_ext:1;
864 	/** Header contains Routing extension header. */
865 	uint32_t has_route_ext:1;
866 	/** Header contains Fragment extension header. */
867 	uint32_t has_frag_ext:1;
868 	/** Header contains Authentication extension header. */
869 	uint32_t has_auth_ext:1;
870 	/** Header contains Encapsulation Security Payload extension header. */
871 	uint32_t has_esp_ext:1;
872 	/** Header contains Destination Options extension header. */
873 	uint32_t has_dest_ext:1;
874 	/** Header contains Mobility extension header. */
875 	uint32_t has_mobil_ext:1;
876 	/** Header contains Host Identity Protocol extension header. */
877 	uint32_t has_hip_ext:1;
878 	/** Header contains Shim6 Protocol extension header. */
879 	uint32_t has_shim6_ext:1;
880 	/** Reserved for future extension headers, must be zero. */
881 	uint32_t reserved:23;
882 };
883 
884 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
885 #ifndef __cplusplus
886 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
887 	.hdr = {
888 		.src_addr =
889 			"\xff\xff\xff\xff\xff\xff\xff\xff"
890 			"\xff\xff\xff\xff\xff\xff\xff\xff",
891 		.dst_addr =
892 			"\xff\xff\xff\xff\xff\xff\xff\xff"
893 			"\xff\xff\xff\xff\xff\xff\xff\xff",
894 	},
895 };
896 #endif
897 
898 /**
899  * @warning
900  * @b EXPERIMENTAL: this structure may change without prior notice.
901  *
902  * RTE_FLOW_ITEM_TYPE_IPV6_ROUTING_EXT.
903  *
904  * Matches an IPv6 routing extension header.
905  */
906 struct rte_flow_item_ipv6_routing_ext {
907 	struct rte_ipv6_routing_ext hdr;
908 };
909 
910 /**
911  * RTE_FLOW_ITEM_TYPE_ICMP.
912  *
913  * Matches an ICMP header.
914  */
915 struct rte_flow_item_icmp {
916 	struct rte_icmp_hdr hdr; /**< ICMP header definition. */
917 };
918 
919 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP. */
920 #ifndef __cplusplus
921 static const struct rte_flow_item_icmp rte_flow_item_icmp_mask = {
922 	.hdr = {
923 		.icmp_type = 0xff,
924 		.icmp_code = 0xff,
925 	},
926 };
927 #endif
928 
929 /**
930  * RTE_FLOW_ITEM_TYPE_UDP.
931  *
932  * Matches a UDP header.
933  */
934 struct rte_flow_item_udp {
935 	struct rte_udp_hdr hdr; /**< UDP header definition. */
936 };
937 
938 /** Default mask for RTE_FLOW_ITEM_TYPE_UDP. */
939 #ifndef __cplusplus
940 static const struct rte_flow_item_udp rte_flow_item_udp_mask = {
941 	.hdr = {
942 		.src_port = RTE_BE16(0xffff),
943 		.dst_port = RTE_BE16(0xffff),
944 	},
945 };
946 #endif
947 
948 /**
949  * RTE_FLOW_ITEM_TYPE_TCP.
950  *
951  * Matches a TCP header.
952  */
953 struct rte_flow_item_tcp {
954 	struct rte_tcp_hdr hdr; /**< TCP header definition. */
955 };
956 
957 /** Default mask for RTE_FLOW_ITEM_TYPE_TCP. */
958 #ifndef __cplusplus
959 static const struct rte_flow_item_tcp rte_flow_item_tcp_mask = {
960 	.hdr = {
961 		.src_port = RTE_BE16(0xffff),
962 		.dst_port = RTE_BE16(0xffff),
963 	},
964 };
965 #endif
966 
967 /**
968  * RTE_FLOW_ITEM_TYPE_SCTP.
969  *
970  * Matches a SCTP header.
971  */
972 struct rte_flow_item_sctp {
973 	struct rte_sctp_hdr hdr; /**< SCTP header definition. */
974 };
975 
976 /** Default mask for RTE_FLOW_ITEM_TYPE_SCTP. */
977 #ifndef __cplusplus
978 static const struct rte_flow_item_sctp rte_flow_item_sctp_mask = {
979 	.hdr = {
980 		.src_port = RTE_BE16(0xffff),
981 		.dst_port = RTE_BE16(0xffff),
982 	},
983 };
984 #endif
985 
986 /**
987  * RTE_FLOW_ITEM_TYPE_VXLAN.
988  *
989  * Matches a VXLAN header (RFC 7348).
990  */
991 RTE_STD_C11
992 struct rte_flow_item_vxlan {
993 	union {
994 		struct {
995 			/*
996 			 * These fields are retained for compatibility.
997 			 * Please switch to the new header field below.
998 			 */
999 			uint8_t flags; /**< Normally 0x08 (I flag). */
1000 			uint8_t rsvd0[3]; /**< Reserved, normally 0x000000. */
1001 			uint8_t vni[3]; /**< VXLAN identifier. */
1002 			uint8_t rsvd1; /**< Reserved, normally 0x00. */
1003 		};
1004 		struct rte_vxlan_hdr hdr;
1005 	};
1006 };
1007 
1008 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */
1009 #ifndef __cplusplus
1010 static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = {
1011 	.hdr.vni = "\xff\xff\xff",
1012 };
1013 #endif
1014 
1015 /**
1016  * RTE_FLOW_ITEM_TYPE_E_TAG.
1017  *
1018  * Matches a E-tag header.
1019  *
1020  * The corresponding standard outer EtherType (TPID) value is
1021  * RTE_ETHER_TYPE_ETAG. It can be overridden by the preceding pattern item.
1022  */
1023 struct rte_flow_item_e_tag {
1024 	/**
1025 	 * E-Tag control information (E-TCI).
1026 	 * E-PCP (3b), E-DEI (1b), ingress E-CID base (12b).
1027 	 */
1028 	rte_be16_t epcp_edei_in_ecid_b;
1029 	/** Reserved (2b), GRP (2b), E-CID base (12b). */
1030 	rte_be16_t rsvd_grp_ecid_b;
1031 	uint8_t in_ecid_e; /**< Ingress E-CID ext. */
1032 	uint8_t ecid_e; /**< E-CID ext. */
1033 	rte_be16_t inner_type; /**< Inner EtherType or TPID. */
1034 };
1035 
1036 /** Default mask for RTE_FLOW_ITEM_TYPE_E_TAG. */
1037 #ifndef __cplusplus
1038 static const struct rte_flow_item_e_tag rte_flow_item_e_tag_mask = {
1039 	.rsvd_grp_ecid_b = RTE_BE16(0x3fff),
1040 };
1041 #endif
1042 
1043 /**
1044  * RTE_FLOW_ITEM_TYPE_NVGRE.
1045  *
1046  * Matches a NVGRE header.
1047  */
1048 struct rte_flow_item_nvgre {
1049 	/**
1050 	 * Checksum (1b), undefined (1b), key bit (1b), sequence number (1b),
1051 	 * reserved 0 (9b), version (3b).
1052 	 *
1053 	 * c_k_s_rsvd0_ver must have value 0x2000 according to RFC 7637.
1054 	 */
1055 	rte_be16_t c_k_s_rsvd0_ver;
1056 	rte_be16_t protocol; /**< Protocol type (0x6558). */
1057 	uint8_t tni[3]; /**< Virtual subnet ID. */
1058 	uint8_t flow_id; /**< Flow ID. */
1059 };
1060 
1061 /** Default mask for RTE_FLOW_ITEM_TYPE_NVGRE. */
1062 #ifndef __cplusplus
1063 static const struct rte_flow_item_nvgre rte_flow_item_nvgre_mask = {
1064 	.tni = "\xff\xff\xff",
1065 };
1066 #endif
1067 
1068 /**
1069  * RTE_FLOW_ITEM_TYPE_MPLS.
1070  *
1071  * Matches a MPLS header.
1072  */
1073 struct rte_flow_item_mpls {
1074 	/**
1075 	 * Label (20b), TC (3b), Bottom of Stack (1b).
1076 	 */
1077 	uint8_t label_tc_s[3];
1078 	uint8_t ttl; /** Time-to-Live. */
1079 };
1080 
1081 /** Default mask for RTE_FLOW_ITEM_TYPE_MPLS. */
1082 #ifndef __cplusplus
1083 static const struct rte_flow_item_mpls rte_flow_item_mpls_mask = {
1084 	.label_tc_s = "\xff\xff\xf0",
1085 };
1086 #endif
1087 
1088 /**
1089  * RTE_FLOW_ITEM_TYPE_GRE.
1090  *
1091  * Matches a GRE header.
1092  */
1093 struct rte_flow_item_gre {
1094 	/**
1095 	 * Checksum (1b), reserved 0 (12b), version (3b).
1096 	 * Refer to RFC 2784.
1097 	 */
1098 	rte_be16_t c_rsvd0_ver;
1099 	rte_be16_t protocol; /**< Protocol type. */
1100 };
1101 
1102 /** Default mask for RTE_FLOW_ITEM_TYPE_GRE. */
1103 #ifndef __cplusplus
1104 static const struct rte_flow_item_gre rte_flow_item_gre_mask = {
1105 	.protocol = RTE_BE16(0xffff),
1106 };
1107 #endif
1108 
1109 /**
1110  * RTE_FLOW_ITEM_TYPE_GRE_OPTION.
1111  *
1112  * Matches GRE optional fields in header.
1113  */
1114 struct rte_flow_item_gre_opt {
1115 	struct rte_gre_hdr_opt_checksum_rsvd checksum_rsvd;
1116 	struct rte_gre_hdr_opt_key key;
1117 	struct rte_gre_hdr_opt_sequence sequence;
1118 };
1119 
1120 /**
1121  * RTE_FLOW_ITEM_TYPE_MACSEC.
1122  *
1123  * Matches MACsec header.
1124  */
1125 struct rte_flow_item_macsec {
1126 	struct rte_macsec_hdr macsec_hdr;
1127 };
1128 
1129 /**
1130  * RTE_FLOW_ITEM_TYPE_FUZZY
1131  *
1132  * Fuzzy pattern match, expect faster than default.
1133  *
1134  * This is for device that support fuzzy match option.
1135  * Usually a fuzzy match is fast but the cost is accuracy.
1136  * i.e. Signature Match only match pattern's hash value, but it is
1137  * possible two different patterns have the same hash value.
1138  *
1139  * Matching accuracy level can be configure by threshold.
1140  * Driver can divide the range of threshold and map to different
1141  * accuracy levels that device support.
1142  *
1143  * Threshold 0 means perfect match (no fuzziness), while threshold
1144  * 0xffffffff means fuzziest match.
1145  */
1146 struct rte_flow_item_fuzzy {
1147 	uint32_t thresh; /**< Accuracy threshold. */
1148 };
1149 
1150 /** Default mask for RTE_FLOW_ITEM_TYPE_FUZZY. */
1151 #ifndef __cplusplus
1152 static const struct rte_flow_item_fuzzy rte_flow_item_fuzzy_mask = {
1153 	.thresh = 0xffffffff,
1154 };
1155 #endif
1156 
1157 /**
1158  * RTE_FLOW_ITEM_TYPE_GTP.
1159  *
1160  * Matches a GTPv1 header.
1161  */
1162 RTE_STD_C11
1163 struct rte_flow_item_gtp {
1164 	union {
1165 		struct {
1166 			/*
1167 			 * These are old fields kept for compatibility.
1168 			 * Please prefer hdr field below.
1169 			 */
1170 			/**
1171 			 * Version (3b), protocol type (1b), reserved (1b),
1172 			 * Extension header flag (1b),
1173 			 * Sequence number flag (1b),
1174 			 * N-PDU number flag (1b).
1175 			 */
1176 			uint8_t v_pt_rsv_flags;
1177 			uint8_t msg_type; /**< Message type. */
1178 			rte_be16_t msg_len; /**< Message length. */
1179 			rte_be32_t teid; /**< Tunnel endpoint identifier. */
1180 		};
1181 		struct rte_gtp_hdr hdr; /**< GTP header definition. */
1182 	};
1183 };
1184 
1185 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP. */
1186 #ifndef __cplusplus
1187 static const struct rte_flow_item_gtp rte_flow_item_gtp_mask = {
1188 	.hdr.teid = RTE_BE32(UINT32_MAX),
1189 };
1190 #endif
1191 
1192 /**
1193  * RTE_FLOW_ITEM_TYPE_ESP
1194  *
1195  * Matches an ESP header.
1196  */
1197 struct rte_flow_item_esp {
1198 	struct rte_esp_hdr hdr; /**< ESP header definition. */
1199 };
1200 
1201 /** Default mask for RTE_FLOW_ITEM_TYPE_ESP. */
1202 #ifndef __cplusplus
1203 static const struct rte_flow_item_esp rte_flow_item_esp_mask = {
1204 	.hdr = {
1205 		.spi = RTE_BE32(0xffffffff),
1206 	},
1207 };
1208 #endif
1209 
1210 /**
1211  * RTE_FLOW_ITEM_TYPE_GENEVE.
1212  *
1213  * Matches a GENEVE header.
1214  */
1215 struct rte_flow_item_geneve {
1216 	/**
1217 	 * Version (2b), length of the options fields (6b), OAM packet (1b),
1218 	 * critical options present (1b), reserved 0 (6b).
1219 	 */
1220 	rte_be16_t ver_opt_len_o_c_rsvd0;
1221 	rte_be16_t protocol; /**< Protocol type. */
1222 	uint8_t vni[3]; /**< Virtual Network Identifier. */
1223 	uint8_t rsvd1; /**< Reserved, normally 0x00. */
1224 };
1225 
1226 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE. */
1227 #ifndef __cplusplus
1228 static const struct rte_flow_item_geneve rte_flow_item_geneve_mask = {
1229 	.vni = "\xff\xff\xff",
1230 };
1231 #endif
1232 
1233 /**
1234  * RTE_FLOW_ITEM_TYPE_VXLAN_GPE (draft-ietf-nvo3-vxlan-gpe-05).
1235  *
1236  * Matches a VXLAN-GPE header.
1237  */
1238 RTE_STD_C11
1239 struct rte_flow_item_vxlan_gpe {
1240 	union {
1241 		struct {
1242 			/*
1243 			 * These are old fields kept for compatibility.
1244 			 * Please prefer hdr field below.
1245 			 */
1246 			uint8_t flags; /**< Normally 0x0c (I and P flags). */
1247 			uint8_t rsvd0[2]; /**< Reserved, normally 0x0000. */
1248 			uint8_t protocol; /**< Protocol type. */
1249 			uint8_t vni[3]; /**< VXLAN identifier. */
1250 			uint8_t rsvd1; /**< Reserved, normally 0x00. */
1251 		};
1252 		struct rte_vxlan_gpe_hdr hdr;
1253 	};
1254 };
1255 
1256 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN_GPE. */
1257 #ifndef __cplusplus
1258 static const struct rte_flow_item_vxlan_gpe rte_flow_item_vxlan_gpe_mask = {
1259 	.hdr.vni = "\xff\xff\xff",
1260 };
1261 #endif
1262 
1263 /**
1264  * RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4
1265  *
1266  * Matches an ARP header for Ethernet/IPv4.
1267  */
1268 RTE_STD_C11
1269 struct rte_flow_item_arp_eth_ipv4 {
1270 	union {
1271 		struct {
1272 			/*
1273 			 * These are old fields kept for compatibility.
1274 			 * Please prefer hdr field below.
1275 			 */
1276 			rte_be16_t hrd; /**< Hardware type, normally 1. */
1277 			rte_be16_t pro; /**< Protocol type, normally 0x0800. */
1278 			uint8_t hln; /**< Hardware address length, normally 6. */
1279 			uint8_t pln; /**< Protocol address length, normally 4. */
1280 			rte_be16_t op; /**< Opcode (1 for request, 2 for reply). */
1281 			struct rte_ether_addr sha; /**< Sender hardware address. */
1282 			rte_be32_t spa; /**< Sender IPv4 address. */
1283 			struct rte_ether_addr tha; /**< Target hardware address. */
1284 			rte_be32_t tpa; /**< Target IPv4 address. */
1285 		};
1286 		struct rte_arp_hdr hdr; /**< ARP header definition. */
1287 	};
1288 };
1289 
1290 /** Default mask for RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4. */
1291 #ifndef __cplusplus
1292 static const struct rte_flow_item_arp_eth_ipv4
1293 rte_flow_item_arp_eth_ipv4_mask = {
1294 	.hdr.arp_data.arp_sha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1295 	.hdr.arp_data.arp_sip = RTE_BE32(UINT32_MAX),
1296 	.hdr.arp_data.arp_tha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1297 	.hdr.arp_data.arp_tip = RTE_BE32(UINT32_MAX),
1298 };
1299 #endif
1300 
1301 /**
1302  * RTE_FLOW_ITEM_TYPE_IPV6_EXT
1303  *
1304  * Matches the presence of any IPv6 extension header.
1305  *
1306  * Normally preceded by any of:
1307  *
1308  * - RTE_FLOW_ITEM_TYPE_IPV6
1309  * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1310  */
1311 struct rte_flow_item_ipv6_ext {
1312 	uint8_t next_hdr; /**< Next header. */
1313 };
1314 
1315 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6_EXT. */
1316 #ifndef __cplusplus
1317 static const
1318 struct rte_flow_item_ipv6_ext rte_flow_item_ipv6_ext_mask = {
1319 	.next_hdr = 0xff,
1320 };
1321 #endif
1322 
1323 /**
1324  * RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT
1325  *
1326  * Matches the presence of IPv6 fragment extension header.
1327  *
1328  * Preceded by any of:
1329  *
1330  * - RTE_FLOW_ITEM_TYPE_IPV6
1331  * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1332  */
1333 struct rte_flow_item_ipv6_frag_ext {
1334 	struct rte_ipv6_fragment_ext hdr;
1335 };
1336 
1337 /**
1338  * RTE_FLOW_ITEM_TYPE_ICMP6
1339  *
1340  * Matches any ICMPv6 header.
1341  */
1342 struct rte_flow_item_icmp6 {
1343 	uint8_t type; /**< ICMPv6 type. */
1344 	uint8_t code; /**< ICMPv6 code. */
1345 	uint16_t checksum; /**< ICMPv6 checksum. */
1346 };
1347 
1348 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6. */
1349 #ifndef __cplusplus
1350 static const struct rte_flow_item_icmp6 rte_flow_item_icmp6_mask = {
1351 	.type = 0xff,
1352 	.code = 0xff,
1353 };
1354 #endif
1355 
1356 /**
1357  * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1358  *
1359  * Matches an ICMPv6 neighbor discovery solicitation.
1360  */
1361 struct rte_flow_item_icmp6_nd_ns {
1362 	uint8_t type; /**< ICMPv6 type, normally 135. */
1363 	uint8_t code; /**< ICMPv6 code, normally 0. */
1364 	rte_be16_t checksum; /**< ICMPv6 checksum. */
1365 	rte_be32_t reserved; /**< Reserved, normally 0. */
1366 	uint8_t target_addr[16]; /**< Target address. */
1367 };
1368 
1369 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS. */
1370 #ifndef __cplusplus
1371 static const
1372 struct rte_flow_item_icmp6_nd_ns rte_flow_item_icmp6_nd_ns_mask = {
1373 	.target_addr =
1374 		"\xff\xff\xff\xff\xff\xff\xff\xff"
1375 		"\xff\xff\xff\xff\xff\xff\xff\xff",
1376 };
1377 #endif
1378 
1379 /**
1380  * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1381  *
1382  * Matches an ICMPv6 neighbor discovery advertisement.
1383  */
1384 struct rte_flow_item_icmp6_nd_na {
1385 	uint8_t type; /**< ICMPv6 type, normally 136. */
1386 	uint8_t code; /**< ICMPv6 code, normally 0. */
1387 	rte_be16_t checksum; /**< ICMPv6 checksum. */
1388 	/**
1389 	 * Route flag (1b), solicited flag (1b), override flag (1b),
1390 	 * reserved (29b).
1391 	 */
1392 	rte_be32_t rso_reserved;
1393 	uint8_t target_addr[16]; /**< Target address. */
1394 };
1395 
1396 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA. */
1397 #ifndef __cplusplus
1398 static const
1399 struct rte_flow_item_icmp6_nd_na rte_flow_item_icmp6_nd_na_mask = {
1400 	.target_addr =
1401 		"\xff\xff\xff\xff\xff\xff\xff\xff"
1402 		"\xff\xff\xff\xff\xff\xff\xff\xff",
1403 };
1404 #endif
1405 
1406 /**
1407  * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1408  *
1409  * Matches the presence of any ICMPv6 neighbor discovery option.
1410  *
1411  * Normally preceded by any of:
1412  *
1413  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1414  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1415  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1416  */
1417 struct rte_flow_item_icmp6_nd_opt {
1418 	uint8_t type; /**< ND option type. */
1419 	uint8_t length; /**< ND option length. */
1420 };
1421 
1422 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT. */
1423 #ifndef __cplusplus
1424 static const struct rte_flow_item_icmp6_nd_opt
1425 rte_flow_item_icmp6_nd_opt_mask = {
1426 	.type = 0xff,
1427 };
1428 #endif
1429 
1430 /**
1431  * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH
1432  *
1433  * Matches an ICMPv6 neighbor discovery source Ethernet link-layer address
1434  * option.
1435  *
1436  * Normally preceded by any of:
1437  *
1438  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1439  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1440  */
1441 struct rte_flow_item_icmp6_nd_opt_sla_eth {
1442 	uint8_t type; /**< ND option type, normally 1. */
1443 	uint8_t length; /**< ND option length, normally 1. */
1444 	struct rte_ether_addr sla; /**< Source Ethernet LLA. */
1445 };
1446 
1447 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH. */
1448 #ifndef __cplusplus
1449 static const struct rte_flow_item_icmp6_nd_opt_sla_eth
1450 rte_flow_item_icmp6_nd_opt_sla_eth_mask = {
1451 	.sla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1452 };
1453 #endif
1454 
1455 /**
1456  * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH
1457  *
1458  * Matches an ICMPv6 neighbor discovery target Ethernet link-layer address
1459  * option.
1460  *
1461  * Normally preceded by any of:
1462  *
1463  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1464  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1465  */
1466 struct rte_flow_item_icmp6_nd_opt_tla_eth {
1467 	uint8_t type; /**< ND option type, normally 2. */
1468 	uint8_t length; /**< ND option length, normally 1. */
1469 	struct rte_ether_addr tla; /**< Target Ethernet LLA. */
1470 };
1471 
1472 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH. */
1473 #ifndef __cplusplus
1474 static const struct rte_flow_item_icmp6_nd_opt_tla_eth
1475 rte_flow_item_icmp6_nd_opt_tla_eth_mask = {
1476 	.tla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1477 };
1478 #endif
1479 
1480 /**
1481  * RTE_FLOW_ITEM_TYPE_META
1482  *
1483  * Matches a specified metadata value. On egress, metadata can be set
1484  * either by mbuf dynamic metadata field with RTE_MBUF_DYNFLAG_TX_METADATA flag
1485  * or RTE_FLOW_ACTION_TYPE_SET_META. On ingress, RTE_FLOW_ACTION_TYPE_SET_META
1486  * sets metadata for a packet and the metadata will be reported via mbuf
1487  * metadata dynamic field with RTE_MBUF_DYNFLAG_RX_METADATA flag. The dynamic
1488  * mbuf field must be registered in advance by
1489  * rte_flow_dynf_metadata_register().
1490  */
1491 struct rte_flow_item_meta {
1492 	uint32_t data;
1493 };
1494 
1495 /** Default mask for RTE_FLOW_ITEM_TYPE_META. */
1496 #ifndef __cplusplus
1497 static const struct rte_flow_item_meta rte_flow_item_meta_mask = {
1498 	.data = UINT32_MAX,
1499 };
1500 #endif
1501 
1502 /**
1503  * RTE_FLOW_ITEM_TYPE_GTP_PSC.
1504  *
1505  * Matches a GTP PDU extension header with type 0x85.
1506  */
1507 struct rte_flow_item_gtp_psc {
1508 	struct rte_gtp_psc_generic_hdr hdr; /**< gtp psc generic hdr. */
1509 };
1510 
1511 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP_PSC. */
1512 #ifndef __cplusplus
1513 static const struct rte_flow_item_gtp_psc
1514 rte_flow_item_gtp_psc_mask = {
1515 	.hdr.qfi = 0x3f,
1516 };
1517 #endif
1518 
1519 /**
1520  * RTE_FLOW_ITEM_TYPE_PPPOE.
1521  *
1522  * Matches a PPPoE header.
1523  */
1524 struct rte_flow_item_pppoe {
1525 	/**
1526 	 * Version (4b), type (4b).
1527 	 */
1528 	uint8_t version_type;
1529 	uint8_t code; /**< Message type. */
1530 	rte_be16_t session_id; /**< Session identifier. */
1531 	rte_be16_t length; /**< Payload length. */
1532 };
1533 
1534 /**
1535  * RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID.
1536  *
1537  * Matches a PPPoE optional proto_id field.
1538  *
1539  * It only applies to PPPoE session packets.
1540  *
1541  * Normally preceded by any of:
1542  *
1543  * - RTE_FLOW_ITEM_TYPE_PPPOE
1544  * - RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID
1545  */
1546 struct rte_flow_item_pppoe_proto_id {
1547 	rte_be16_t proto_id; /**< PPP protocol identifier. */
1548 };
1549 
1550 /** Default mask for RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID. */
1551 #ifndef __cplusplus
1552 static const struct rte_flow_item_pppoe_proto_id
1553 rte_flow_item_pppoe_proto_id_mask = {
1554 	.proto_id = RTE_BE16(0xffff),
1555 };
1556 #endif
1557 
1558 /**
1559  * @warning
1560  * @b EXPERIMENTAL: this structure may change without prior notice
1561  *
1562  * RTE_FLOW_ITEM_TYPE_TAG
1563  *
1564  * Matches a specified tag value at the specified index.
1565  */
1566 struct rte_flow_item_tag {
1567 	uint32_t data;
1568 	uint8_t index;
1569 };
1570 
1571 /** Default mask for RTE_FLOW_ITEM_TYPE_TAG. */
1572 #ifndef __cplusplus
1573 static const struct rte_flow_item_tag rte_flow_item_tag_mask = {
1574 	.data = 0xffffffff,
1575 	.index = 0xff,
1576 };
1577 #endif
1578 
1579 /**
1580  * RTE_FLOW_ITEM_TYPE_L2TPV3OIP.
1581  *
1582  * Matches a L2TPv3 over IP header.
1583  */
1584 struct rte_flow_item_l2tpv3oip {
1585 	rte_be32_t session_id; /**< Session ID. */
1586 };
1587 
1588 /** Default mask for RTE_FLOW_ITEM_TYPE_L2TPV3OIP. */
1589 #ifndef __cplusplus
1590 static const struct rte_flow_item_l2tpv3oip rte_flow_item_l2tpv3oip_mask = {
1591 	.session_id = RTE_BE32(UINT32_MAX),
1592 };
1593 #endif
1594 
1595 
1596 /**
1597  * @warning
1598  * @b EXPERIMENTAL: this structure may change without prior notice
1599  *
1600  * RTE_FLOW_ITEM_TYPE_MARK
1601  *
1602  * Matches an arbitrary integer value which was set using the ``MARK`` action
1603  * in a previously matched rule.
1604  *
1605  * This item can only be specified once as a match criteria as the ``MARK``
1606  * action can only be specified once in a flow action.
1607  *
1608  * This value is arbitrary and application-defined. Maximum allowed value
1609  * depends on the underlying implementation.
1610  *
1611  * Depending on the underlying implementation the MARK item may be supported on
1612  * the physical device, with virtual groups in the PMD or not at all.
1613  */
1614 struct rte_flow_item_mark {
1615 	uint32_t id; /**< Integer value to match against. */
1616 };
1617 
1618 /** Default mask for RTE_FLOW_ITEM_TYPE_MARK. */
1619 #ifndef __cplusplus
1620 static const struct rte_flow_item_mark rte_flow_item_mark_mask = {
1621 	.id = 0xffffffff,
1622 };
1623 #endif
1624 
1625 /**
1626  * @warning
1627  * @b EXPERIMENTAL: this structure may change without prior notice
1628  *
1629  * RTE_FLOW_ITEM_TYPE_NSH
1630  *
1631  * Match network service header (NSH), RFC 8300
1632  *
1633  */
1634 struct rte_flow_item_nsh {
1635 	uint32_t version:2;
1636 	uint32_t oam_pkt:1;
1637 	uint32_t reserved:1;
1638 	uint32_t ttl:6;
1639 	uint32_t length:6;
1640 	uint32_t reserved1:4;
1641 	uint32_t mdtype:4;
1642 	uint32_t next_proto:8;
1643 	uint32_t spi:24;
1644 	uint32_t sindex:8;
1645 };
1646 
1647 /** Default mask for RTE_FLOW_ITEM_TYPE_NSH. */
1648 #ifndef __cplusplus
1649 static const struct rte_flow_item_nsh rte_flow_item_nsh_mask = {
1650 	.mdtype = 0xf,
1651 	.next_proto = 0xff,
1652 	.spi = 0xffffff,
1653 	.sindex = 0xff,
1654 };
1655 #endif
1656 
1657 /**
1658  * @warning
1659  * @b EXPERIMENTAL: this structure may change without prior notice
1660  *
1661  * RTE_FLOW_ITEM_TYPE_IGMP
1662  *
1663  * Match Internet Group Management Protocol (IGMP), RFC 2236
1664  *
1665  */
1666 struct rte_flow_item_igmp {
1667 	uint32_t type:8;
1668 	uint32_t max_resp_time:8;
1669 	uint32_t checksum:16;
1670 	uint32_t group_addr;
1671 };
1672 
1673 /** Default mask for RTE_FLOW_ITEM_TYPE_IGMP. */
1674 #ifndef __cplusplus
1675 static const struct rte_flow_item_igmp rte_flow_item_igmp_mask = {
1676 	.group_addr = 0xffffffff,
1677 };
1678 #endif
1679 
1680 /**
1681  * @warning
1682  * @b EXPERIMENTAL: this structure may change without prior notice
1683  *
1684  * RTE_FLOW_ITEM_TYPE_AH
1685  *
1686  * Match IP Authentication Header (AH), RFC 4302
1687  *
1688  */
1689 struct rte_flow_item_ah {
1690 	uint32_t next_hdr:8;
1691 	uint32_t payload_len:8;
1692 	uint32_t reserved:16;
1693 	uint32_t spi;
1694 	uint32_t seq_num;
1695 };
1696 
1697 /** Default mask for RTE_FLOW_ITEM_TYPE_AH. */
1698 #ifndef __cplusplus
1699 static const struct rte_flow_item_ah rte_flow_item_ah_mask = {
1700 	.spi = 0xffffffff,
1701 };
1702 #endif
1703 
1704 /**
1705  * @warning
1706  * @b EXPERIMENTAL: this structure may change without prior notice
1707  *
1708  * RTE_FLOW_ITEM_TYPE_PFCP
1709  *
1710  * Match PFCP Header
1711  */
1712 struct rte_flow_item_pfcp {
1713 	uint8_t s_field;
1714 	uint8_t msg_type;
1715 	rte_be16_t msg_len;
1716 	rte_be64_t seid;
1717 };
1718 
1719 /** Default mask for RTE_FLOW_ITEM_TYPE_PFCP. */
1720 #ifndef __cplusplus
1721 static const struct rte_flow_item_pfcp rte_flow_item_pfcp_mask = {
1722 	.s_field = 0x01,
1723 	.seid = RTE_BE64(UINT64_C(0xffffffffffffffff)),
1724 };
1725 #endif
1726 
1727 /**
1728  * @warning
1729  * @b EXPERIMENTAL: this structure may change without prior notice
1730  *
1731  * RTE_FLOW_ITEM_TYPE_ECPRI
1732  *
1733  * Match eCPRI Header
1734  */
1735 struct rte_flow_item_ecpri {
1736 	struct rte_ecpri_combined_msg_hdr hdr;
1737 };
1738 
1739 /** Default mask for RTE_FLOW_ITEM_TYPE_ECPRI. */
1740 #ifndef __cplusplus
1741 static const struct rte_flow_item_ecpri rte_flow_item_ecpri_mask = {
1742 	.hdr = {
1743 		.common = {
1744 			.u32 = 0x0,
1745 		},
1746 	},
1747 };
1748 #endif
1749 
1750 /**
1751  * RTE_FLOW_ITEM_TYPE_GENEVE_OPT
1752  *
1753  * Matches a GENEVE Variable Length Option
1754  */
1755 struct rte_flow_item_geneve_opt {
1756 	rte_be16_t option_class;
1757 	uint8_t option_type;
1758 	uint8_t option_len;
1759 	uint32_t *data;
1760 };
1761 
1762 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE_OPT. */
1763 #ifndef __cplusplus
1764 static const struct rte_flow_item_geneve_opt
1765 rte_flow_item_geneve_opt_mask = {
1766 	.option_type = 0xff,
1767 };
1768 #endif
1769 
1770 /**
1771  * @warning
1772  * @b EXPERIMENTAL: this structure may change without prior notice
1773  *
1774  * RTE_FLOW_ITEM_TYPE_INTEGRITY
1775  *
1776  * Match on packet integrity check result.
1777  */
1778 struct rte_flow_item_integrity {
1779 	/** Tunnel encapsulation level the item should apply to.
1780 	 * @see rte_flow_action_rss
1781 	 */
1782 	uint32_t level;
1783 	RTE_STD_C11
1784 	union {
1785 		__extension__
1786 		struct {
1787 			/** The packet is valid after passing all HW checks. */
1788 			uint64_t packet_ok:1;
1789 			/** L2 layer is valid after passing all HW checks. */
1790 			uint64_t l2_ok:1;
1791 			/** L3 layer is valid after passing all HW checks. */
1792 			uint64_t l3_ok:1;
1793 			/** L4 layer is valid after passing all HW checks. */
1794 			uint64_t l4_ok:1;
1795 			/** L2 layer CRC is valid. */
1796 			uint64_t l2_crc_ok:1;
1797 			/** IPv4 layer checksum is valid. */
1798 			uint64_t ipv4_csum_ok:1;
1799 			/** L4 layer checksum is valid. */
1800 			uint64_t l4_csum_ok:1;
1801 			/** L3 length is smaller than frame length. */
1802 			uint64_t l3_len_ok:1;
1803 			uint64_t reserved:56;
1804 		};
1805 		uint64_t value;
1806 	};
1807 };
1808 
1809 #ifndef __cplusplus
1810 static const struct rte_flow_item_integrity
1811 rte_flow_item_integrity_mask = {
1812 	.level = 0,
1813 	.value = 0,
1814 };
1815 #endif
1816 
1817 /**
1818  * The packet is valid after conntrack checking.
1819  */
1820 #define RTE_FLOW_CONNTRACK_PKT_STATE_VALID RTE_BIT32(0)
1821 /**
1822  * The state of the connection is changed.
1823  */
1824 #define RTE_FLOW_CONNTRACK_PKT_STATE_CHANGED RTE_BIT32(1)
1825 /**
1826  * Error is detected on this packet for this connection and
1827  * an invalid state is set.
1828  */
1829 #define RTE_FLOW_CONNTRACK_PKT_STATE_INVALID RTE_BIT32(2)
1830 /**
1831  * The HW connection tracking module is disabled.
1832  * It can be due to application command or an invalid state.
1833  */
1834 #define RTE_FLOW_CONNTRACK_PKT_STATE_DISABLED RTE_BIT32(3)
1835 /**
1836  * The packet contains some bad field(s) and cannot continue
1837  * with the conntrack module checking.
1838  */
1839 #define RTE_FLOW_CONNTRACK_PKT_STATE_BAD RTE_BIT32(4)
1840 
1841 /**
1842  * @warning
1843  * @b EXPERIMENTAL: this structure may change without prior notice
1844  *
1845  * RTE_FLOW_ITEM_TYPE_CONNTRACK
1846  *
1847  * Matches the state of a packet after it passed the connection tracking
1848  * examination. The state is a bitmap of one RTE_FLOW_CONNTRACK_PKT_STATE*
1849  * or a reasonable combination of these bits.
1850  */
1851 struct rte_flow_item_conntrack {
1852 	uint32_t flags;
1853 };
1854 
1855 /** Default mask for RTE_FLOW_ITEM_TYPE_CONNTRACK. */
1856 #ifndef __cplusplus
1857 static const struct rte_flow_item_conntrack rte_flow_item_conntrack_mask = {
1858 	.flags = 0xffffffff,
1859 };
1860 #endif
1861 
1862 /**
1863  * Provides an ethdev port ID for use with the following items:
1864  * RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR,
1865  * RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT.
1866  */
1867 struct rte_flow_item_ethdev {
1868 	uint16_t port_id; /**< ethdev port ID */
1869 };
1870 
1871 /** Default mask for items based on struct rte_flow_item_ethdev */
1872 #ifndef __cplusplus
1873 static const struct rte_flow_item_ethdev rte_flow_item_ethdev_mask = {
1874 	.port_id = 0xffff,
1875 };
1876 #endif
1877 
1878 /**
1879  * @warning
1880  * @b EXPERIMENTAL: this structure may change without prior notice
1881  *
1882  * RTE_FLOW_ITEM_TYPE_L2TPV2
1883  *
1884  * Matches L2TPv2 Header
1885  */
1886 struct rte_flow_item_l2tpv2 {
1887 	struct rte_l2tpv2_combined_msg_hdr hdr;
1888 };
1889 
1890 /** Default mask for RTE_FLOW_ITEM_TYPE_L2TPV2. */
1891 #ifndef __cplusplus
1892 static const struct rte_flow_item_l2tpv2 rte_flow_item_l2tpv2_mask = {
1893 	/*
1894 	 * flags and version bit mask
1895 	 * 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
1896 	 * T L x x S x O P x x x x V V V V
1897 	 */
1898 	.hdr = {
1899 		.common = {
1900 			.flags_version = RTE_BE16(0xcb0f),
1901 		},
1902 	},
1903 };
1904 #endif
1905 
1906 /**
1907  * @warning
1908  * @b EXPERIMENTAL: this structure may change without prior notice
1909  *
1910  * RTE_FLOW_ITEM_TYPE_PPP
1911  *
1912  * Matches PPP Header
1913  */
1914 struct rte_flow_item_ppp {
1915 	struct rte_ppp_hdr hdr;
1916 };
1917 
1918 /** Default mask for RTE_FLOW_ITEM_TYPE_PPP. */
1919 #ifndef __cplusplus
1920 static const struct rte_flow_item_ppp rte_flow_item_ppp_mask = {
1921 	.hdr = {
1922 		.addr = 0xff,
1923 		.ctrl = 0xff,
1924 		.proto_id = RTE_BE16(0xffff),
1925 	}
1926 };
1927 #endif
1928 
1929 /**
1930  * Matching pattern item definition.
1931  *
1932  * A pattern is formed by stacking items starting from the lowest protocol
1933  * layer to match. This stacking restriction does not apply to meta items
1934  * which can be placed anywhere in the stack without affecting the meaning
1935  * of the resulting pattern.
1936  *
1937  * Patterns are terminated by END items.
1938  *
1939  * The spec field should be a valid pointer to a structure of the related
1940  * item type. It may remain unspecified (NULL) in many cases to request
1941  * broad (nonspecific) matching. In such cases, last and mask must also be
1942  * set to NULL.
1943  *
1944  * Optionally, last can point to a structure of the same type to define an
1945  * inclusive range. This is mostly supported by integer and address fields,
1946  * may cause errors otherwise. Fields that do not support ranges must be set
1947  * to 0 or to the same value as the corresponding fields in spec.
1948  *
1949  * Only the fields defined to nonzero values in the default masks (see
1950  * rte_flow_item_{name}_mask constants) are considered relevant by
1951  * default. This can be overridden by providing a mask structure of the
1952  * same type with applicable bits set to one. It can also be used to
1953  * partially filter out specific fields (e.g. as an alternate mean to match
1954  * ranges of IP addresses).
1955  *
1956  * Mask is a simple bit-mask applied before interpreting the contents of
1957  * spec and last, which may yield unexpected results if not used
1958  * carefully. For example, if for an IPv4 address field, spec provides
1959  * 10.1.2.3, last provides 10.3.4.5 and mask provides 255.255.0.0, the
1960  * effective range becomes 10.1.0.0 to 10.3.255.255.
1961  */
1962 struct rte_flow_item {
1963 	enum rte_flow_item_type type; /**< Item type. */
1964 	const void *spec; /**< Pointer to item specification structure. */
1965 	const void *last; /**< Defines an inclusive range (spec to last). */
1966 	const void *mask; /**< Bit-mask applied to spec and last. */
1967 };
1968 
1969 /**
1970  * @warning
1971  * @b EXPERIMENTAL: this structure may change without prior notice
1972  *
1973  * RTE_FLOW_ITEM_TYPE_FLEX
1974  *
1975  * Matches a specified set of fields within the network protocol
1976  * header. Each field is presented as set of bits with specified width, and
1977  * bit offset from the header beginning.
1978  *
1979  * The pattern is concatenation of bit fields configured at item creation
1980  * by rte_flow_flex_item_create(). At configuration the fields are presented
1981  * by sample_data array.
1982  *
1983  * This type does not support ranges (struct rte_flow_item.last).
1984  */
1985 struct rte_flow_item_flex {
1986 	struct rte_flow_item_flex_handle *handle; /**< Opaque item handle. */
1987 	uint32_t length; /**< Pattern length in bytes. */
1988 	const uint8_t *pattern; /**< Combined bitfields pattern to match. */
1989 };
1990 /**
1991  * Field bit offset calculation mode.
1992  */
1993 enum rte_flow_item_flex_field_mode {
1994 	/**
1995 	 * Dummy field, used for byte boundary alignment in pattern.
1996 	 * Pattern mask and data are ignored in the match. All configuration
1997 	 * parameters besides field size are ignored.
1998 	 */
1999 	FIELD_MODE_DUMMY = 0,
2000 	/**
2001 	 * Fixed offset field. The bit offset from header beginning
2002 	 * is permanent and defined by field_base parameter.
2003 	 */
2004 	FIELD_MODE_FIXED,
2005 	/**
2006 	 * The field bit offset is extracted from other header field (indirect
2007 	 * offset field). The resulting field offset to match is calculated as:
2008 	 *
2009 	 *    field_base + (*offset_base & offset_mask) << offset_shift
2010 	 */
2011 	FIELD_MODE_OFFSET,
2012 	/**
2013 	 * The field bit offset is extracted from other header field (indirect
2014 	 * offset field), the latter is considered as bitmask containing some
2015 	 * number of one bits, the resulting field offset to match is
2016 	 * calculated as:
2017 	 *
2018 	 *    field_base + bitcount(*offset_base & offset_mask) << offset_shift
2019 	 */
2020 	FIELD_MODE_BITMASK,
2021 };
2022 
2023 /**
2024  * Flex item field tunnel mode
2025  */
2026 enum rte_flow_item_flex_tunnel_mode {
2027 	/**
2028 	 * The protocol header can be present in the packet only once.
2029 	 * No multiple flex item flow inclusions (for inner/outer) are allowed.
2030 	 * No any relations with tunnel protocols are imposed. The drivers
2031 	 * can optimize hardware resource usage to handle match on single flex
2032 	 * item of specific type.
2033 	 */
2034 	FLEX_TUNNEL_MODE_SINGLE = 0,
2035 	/**
2036 	 * Flex item presents outer header only.
2037 	 */
2038 	FLEX_TUNNEL_MODE_OUTER,
2039 	/**
2040 	 * Flex item presents inner header only.
2041 	 */
2042 	FLEX_TUNNEL_MODE_INNER,
2043 	/**
2044 	 * Flex item presents either inner or outer header. The driver
2045 	 * handles as many multiple inners as hardware supports.
2046 	 */
2047 	FLEX_TUNNEL_MODE_MULTI,
2048 	/**
2049 	 * Flex item presents tunnel protocol header.
2050 	 */
2051 	FLEX_TUNNEL_MODE_TUNNEL,
2052 };
2053 
2054 /**
2055  *
2056  * @warning
2057  * @b EXPERIMENTAL: this structure may change without prior notice
2058  */
2059 __extension__
2060 struct rte_flow_item_flex_field {
2061 	/** Defines how match field offset is calculated over the packet. */
2062 	enum rte_flow_item_flex_field_mode field_mode;
2063 	uint32_t field_size; /**< Field size in bits. */
2064 	int32_t field_base; /**< Field offset in bits. */
2065 	uint32_t offset_base; /**< Indirect offset field offset in bits. */
2066 	uint32_t offset_mask; /**< Indirect offset field bit mask. */
2067 	int32_t offset_shift; /**< Indirect offset multiply factor. */
2068 	uint32_t field_id:16; /**< Device hint, for multiple items in flow. */
2069 	uint32_t reserved:16; /**< Reserved field. */
2070 };
2071 
2072 /**
2073  * @warning
2074  * @b EXPERIMENTAL: this structure may change without prior notice
2075  */
2076 struct rte_flow_item_flex_link {
2077 	/**
2078 	 * Preceding/following header. The item type must be always provided.
2079 	 * For preceding one item must specify the header value/mask to match
2080 	 * for the link be taken and start the flex item header parsing.
2081 	 */
2082 	struct rte_flow_item item;
2083 	/**
2084 	 * Next field value to match to continue with one of the configured
2085 	 * next protocols.
2086 	 */
2087 	uint32_t next;
2088 };
2089 
2090 /**
2091  * @warning
2092  * @b EXPERIMENTAL: this structure may change without prior notice
2093  */
2094 struct rte_flow_item_flex_conf {
2095 	/**
2096 	 * Specifies the flex item and tunnel relations and tells the PMD
2097 	 * whether flex item can be used for inner, outer or both headers,
2098 	 * or whether flex item presents the tunnel protocol itself.
2099 	 */
2100 	enum rte_flow_item_flex_tunnel_mode tunnel;
2101 	/**
2102 	 * The next header offset, it presents the network header size covered
2103 	 * by the flex item and can be obtained with all supported offset
2104 	 * calculating methods (fixed, dedicated field, bitmask, etc).
2105 	 */
2106 	struct rte_flow_item_flex_field next_header;
2107 	/**
2108 	 * Specifies the next protocol field to match with link next protocol
2109 	 * values and continue packet parsing with matching link.
2110 	 */
2111 	struct rte_flow_item_flex_field next_protocol;
2112 	/**
2113 	 * The fields will be sampled and presented for explicit match
2114 	 * with pattern in the rte_flow_flex_item. There can be multiple
2115 	 * fields descriptors, the number should be specified by nb_samples.
2116 	 */
2117 	struct rte_flow_item_flex_field *sample_data;
2118 	/** Number of field descriptors in the sample_data array. */
2119 	uint32_t nb_samples;
2120 	/**
2121 	 * Input link defines the flex item relation with preceding
2122 	 * header. It specified the preceding item type and provides pattern
2123 	 * to match. The flex item will continue parsing and will provide the
2124 	 * data to flow match in case if there is the match with one of input
2125 	 * links.
2126 	 */
2127 	struct rte_flow_item_flex_link *input_link;
2128 	/** Number of link descriptors in the input link array. */
2129 	uint32_t nb_inputs;
2130 	/**
2131 	 * Output link defines the next protocol field value to match and
2132 	 * the following protocol header to continue packet parsing. Also
2133 	 * defines the tunnel-related behaviour.
2134 	 */
2135 	struct rte_flow_item_flex_link *output_link;
2136 	/** Number of link descriptors in the output link array. */
2137 	uint32_t nb_outputs;
2138 };
2139 
2140 /**
2141  * RTE_FLOW_ITEM_TYPE_METER_COLOR.
2142  *
2143  * Matches Color Marker set by a Meter.
2144  */
2145 struct rte_flow_item_meter_color {
2146 	enum rte_color color; /**< Meter color marker. */
2147 };
2148 
2149 /** Default mask for RTE_FLOW_ITEM_TYPE_METER_COLOR. */
2150 #ifndef __cplusplus
2151 static const struct rte_flow_item_meter_color rte_flow_item_meter_color_mask = {
2152 	.color = RTE_COLORS,
2153 };
2154 #endif
2155 
2156 /**
2157  * Action types.
2158  *
2159  * Each possible action is represented by a type.
2160  * An action can have an associated configuration object.
2161  * Several actions combined in a list can be assigned
2162  * to a flow rule and are performed in order.
2163  *
2164  * They fall in three categories:
2165  *
2166  * - Actions that modify the fate of matching traffic, for instance by
2167  *   dropping or assigning it a specific destination.
2168  *
2169  * - Actions that modify matching traffic contents or its properties. This
2170  *   includes adding/removing encapsulation, encryption, compression and
2171  *   marks.
2172  *
2173  * - Actions related to the flow rule itself, such as updating counters or
2174  *   making it non-terminating.
2175  *
2176  * Flow rules being terminating by default, not specifying any action of the
2177  * fate kind results in undefined behavior. This applies to both ingress and
2178  * egress.
2179  *
2180  * PASSTHRU, when supported, makes a flow rule non-terminating.
2181  */
2182 enum rte_flow_action_type {
2183 	/**
2184 	 * End marker for action lists. Prevents further processing of
2185 	 * actions, thereby ending the list.
2186 	 *
2187 	 * No associated configuration structure.
2188 	 */
2189 	RTE_FLOW_ACTION_TYPE_END,
2190 
2191 	/**
2192 	 * Used as a placeholder for convenience. It is ignored and simply
2193 	 * discarded by PMDs.
2194 	 *
2195 	 * No associated configuration structure.
2196 	 */
2197 	RTE_FLOW_ACTION_TYPE_VOID,
2198 
2199 	/**
2200 	 * Leaves traffic up for additional processing by subsequent flow
2201 	 * rules; makes a flow rule non-terminating.
2202 	 *
2203 	 * No associated configuration structure.
2204 	 */
2205 	RTE_FLOW_ACTION_TYPE_PASSTHRU,
2206 
2207 	/**
2208 	 * RTE_FLOW_ACTION_TYPE_JUMP
2209 	 *
2210 	 * Redirects packets to a group on the current device.
2211 	 *
2212 	 * See struct rte_flow_action_jump.
2213 	 */
2214 	RTE_FLOW_ACTION_TYPE_JUMP,
2215 
2216 	/**
2217 	 * Attaches an integer value to packets and sets RTE_MBUF_F_RX_FDIR and
2218 	 * RTE_MBUF_F_RX_FDIR_ID mbuf flags.
2219 	 *
2220 	 * See struct rte_flow_action_mark.
2221 	 *
2222 	 * One should negotiate mark delivery from the NIC to the PMD.
2223 	 * @see rte_eth_rx_metadata_negotiate()
2224 	 * @see RTE_ETH_RX_METADATA_USER_MARK
2225 	 */
2226 	RTE_FLOW_ACTION_TYPE_MARK,
2227 
2228 	/**
2229 	 * Flags packets. Similar to MARK without a specific value; only
2230 	 * sets the RTE_MBUF_F_RX_FDIR mbuf flag.
2231 	 *
2232 	 * No associated configuration structure.
2233 	 *
2234 	 * One should negotiate flag delivery from the NIC to the PMD.
2235 	 * @see rte_eth_rx_metadata_negotiate()
2236 	 * @see RTE_ETH_RX_METADATA_USER_FLAG
2237 	 */
2238 	RTE_FLOW_ACTION_TYPE_FLAG,
2239 
2240 	/**
2241 	 * Assigns packets to a given queue index.
2242 	 *
2243 	 * See struct rte_flow_action_queue.
2244 	 */
2245 	RTE_FLOW_ACTION_TYPE_QUEUE,
2246 
2247 	/**
2248 	 * Drops packets.
2249 	 *
2250 	 * PASSTHRU overrides this action if both are specified.
2251 	 *
2252 	 * No associated configuration structure.
2253 	 */
2254 	RTE_FLOW_ACTION_TYPE_DROP,
2255 
2256 	/**
2257 	 * Enables counters for this flow rule.
2258 	 *
2259 	 * These counters can be retrieved and reset through rte_flow_query() or
2260 	 * rte_flow_action_handle_query() if the action provided via handle,
2261 	 * see struct rte_flow_query_count.
2262 	 *
2263 	 * See struct rte_flow_action_count.
2264 	 */
2265 	RTE_FLOW_ACTION_TYPE_COUNT,
2266 
2267 	/**
2268 	 * Similar to QUEUE, except RSS is additionally performed on packets
2269 	 * to spread them among several queues according to the provided
2270 	 * parameters.
2271 	 *
2272 	 * See struct rte_flow_action_rss.
2273 	 */
2274 	RTE_FLOW_ACTION_TYPE_RSS,
2275 
2276 	/**
2277 	 * @deprecated
2278 	 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2279 	 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2280 	 *
2281 	 * Directs matching traffic to the physical function (PF) of the
2282 	 * current device.
2283 	 *
2284 	 * No associated configuration structure.
2285 	 */
2286 	RTE_FLOW_ACTION_TYPE_PF,
2287 
2288 	/**
2289 	 * @deprecated
2290 	 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2291 	 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2292 	 *
2293 	 * Directs matching traffic to a given virtual function of the
2294 	 * current device.
2295 	 *
2296 	 * See struct rte_flow_action_vf.
2297 	 */
2298 	RTE_FLOW_ACTION_TYPE_VF,
2299 
2300 	/**
2301 	 * @deprecated
2302 	 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2303 	 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2304 	 *
2305 	 * Directs matching traffic to a given DPDK port ID.
2306 	 *
2307 	 * See struct rte_flow_action_port_id.
2308 	 */
2309 	RTE_FLOW_ACTION_TYPE_PORT_ID,
2310 
2311 	/**
2312 	 * Traffic metering and policing (MTR).
2313 	 *
2314 	 * See struct rte_flow_action_meter.
2315 	 * See file rte_mtr.h for MTR object configuration.
2316 	 */
2317 	RTE_FLOW_ACTION_TYPE_METER,
2318 
2319 	/**
2320 	 * Redirects packets to security engine of current device for security
2321 	 * processing as specified by security session.
2322 	 *
2323 	 * See struct rte_flow_action_security.
2324 	 */
2325 	RTE_FLOW_ACTION_TYPE_SECURITY,
2326 
2327 	/**
2328 	 * @warning This is a legacy action.
2329 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2330 	 *
2331 	 * Implements OFPAT_DEC_NW_TTL ("decrement IP TTL") as defined by
2332 	 * the OpenFlow Switch Specification.
2333 	 *
2334 	 * No associated configuration structure.
2335 	 */
2336 	RTE_FLOW_ACTION_TYPE_OF_DEC_NW_TTL,
2337 
2338 	/**
2339 	 * Implements OFPAT_POP_VLAN ("pop the outer VLAN tag") as defined
2340 	 * by the OpenFlow Switch Specification.
2341 	 *
2342 	 * No associated configuration structure.
2343 	 */
2344 	RTE_FLOW_ACTION_TYPE_OF_POP_VLAN,
2345 
2346 	/**
2347 	 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by
2348 	 * the OpenFlow Switch Specification.
2349 	 *
2350 	 * See struct rte_flow_action_of_push_vlan.
2351 	 */
2352 	RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
2353 
2354 	/**
2355 	 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN ID") as
2356 	 * defined by the OpenFlow Switch Specification.
2357 	 *
2358 	 * See struct rte_flow_action_of_set_vlan_vid.
2359 	 */
2360 	RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
2361 
2362 	/**
2363 	 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as
2364 	 * defined by the OpenFlow Switch Specification.
2365 	 *
2366 	 * See struct rte_flow_action_of_set_vlan_pcp.
2367 	 */
2368 	RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
2369 
2370 	/**
2371 	 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined
2372 	 * by the OpenFlow Switch Specification.
2373 	 *
2374 	 * See struct rte_flow_action_of_pop_mpls.
2375 	 */
2376 	RTE_FLOW_ACTION_TYPE_OF_POP_MPLS,
2377 
2378 	/**
2379 	 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by
2380 	 * the OpenFlow Switch Specification.
2381 	 *
2382 	 * See struct rte_flow_action_of_push_mpls.
2383 	 */
2384 	RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS,
2385 
2386 	/**
2387 	 * Encapsulate flow in VXLAN tunnel as defined in
2388 	 * rte_flow_action_vxlan_encap action structure.
2389 	 *
2390 	 * See struct rte_flow_action_vxlan_encap.
2391 	 */
2392 	RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP,
2393 
2394 	/**
2395 	 * Decapsulate outer most VXLAN tunnel from matched flow.
2396 	 *
2397 	 * If flow pattern does not define a valid VXLAN tunnel (as specified by
2398 	 * RFC7348) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
2399 	 * error.
2400 	 */
2401 	RTE_FLOW_ACTION_TYPE_VXLAN_DECAP,
2402 
2403 	/**
2404 	 * Encapsulate flow in NVGRE tunnel defined in the
2405 	 * rte_flow_action_nvgre_encap action structure.
2406 	 *
2407 	 * See struct rte_flow_action_nvgre_encap.
2408 	 */
2409 	RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP,
2410 
2411 	/**
2412 	 * Decapsulate outer most NVGRE tunnel from matched flow.
2413 	 *
2414 	 * If flow pattern does not define a valid NVGRE tunnel (as specified by
2415 	 * RFC7637) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
2416 	 * error.
2417 	 */
2418 	RTE_FLOW_ACTION_TYPE_NVGRE_DECAP,
2419 
2420 	/**
2421 	 * Add outer header whose template is provided in its data buffer
2422 	 *
2423 	 * See struct rte_flow_action_raw_encap.
2424 	 */
2425 	RTE_FLOW_ACTION_TYPE_RAW_ENCAP,
2426 
2427 	/**
2428 	 * Remove outer header whose template is provided in its data buffer.
2429 	 *
2430 	 * See struct rte_flow_action_raw_decap
2431 	 */
2432 	RTE_FLOW_ACTION_TYPE_RAW_DECAP,
2433 
2434 	/**
2435 	 * @warning This is a legacy action.
2436 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2437 	 *
2438 	 * Modify IPv4 source address in the outermost IPv4 header.
2439 	 *
2440 	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2441 	 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2442 	 *
2443 	 * See struct rte_flow_action_set_ipv4.
2444 	 */
2445 	RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC,
2446 
2447 	/**
2448 	 * @warning This is a legacy action.
2449 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2450 	 *
2451 	 * Modify IPv4 destination address in the outermost IPv4 header.
2452 	 *
2453 	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2454 	 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2455 	 *
2456 	 * See struct rte_flow_action_set_ipv4.
2457 	 */
2458 	RTE_FLOW_ACTION_TYPE_SET_IPV4_DST,
2459 
2460 	/**
2461 	 * @warning This is a legacy action.
2462 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2463 	 *
2464 	 * Modify IPv6 source address in the outermost IPv6 header.
2465 	 *
2466 	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2467 	 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2468 	 *
2469 	 * See struct rte_flow_action_set_ipv6.
2470 	 */
2471 	RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC,
2472 
2473 	/**
2474 	 * @warning This is a legacy action.
2475 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2476 	 *
2477 	 * Modify IPv6 destination address in the outermost IPv6 header.
2478 	 *
2479 	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2480 	 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2481 	 *
2482 	 * See struct rte_flow_action_set_ipv6.
2483 	 */
2484 	RTE_FLOW_ACTION_TYPE_SET_IPV6_DST,
2485 
2486 	/**
2487 	 * @warning This is a legacy action.
2488 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2489 	 *
2490 	 * Modify source port number in the outermost TCP/UDP header.
2491 	 *
2492 	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
2493 	 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
2494 	 * RTE_FLOW_ERROR_TYPE_ACTION error.
2495 	 *
2496 	 * See struct rte_flow_action_set_tp.
2497 	 */
2498 	RTE_FLOW_ACTION_TYPE_SET_TP_SRC,
2499 
2500 	/**
2501 	 * @warning This is a legacy action.
2502 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2503 	 *
2504 	 * Modify destination port number in the outermost TCP/UDP header.
2505 	 *
2506 	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
2507 	 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
2508 	 * RTE_FLOW_ERROR_TYPE_ACTION error.
2509 	 *
2510 	 * See struct rte_flow_action_set_tp.
2511 	 */
2512 	RTE_FLOW_ACTION_TYPE_SET_TP_DST,
2513 
2514 	/**
2515 	 * Swap the source and destination MAC addresses in the outermost
2516 	 * Ethernet header.
2517 	 *
2518 	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2519 	 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2520 	 *
2521 	 * No associated configuration structure.
2522 	 */
2523 	RTE_FLOW_ACTION_TYPE_MAC_SWAP,
2524 
2525 	/**
2526 	 * @warning This is a legacy action.
2527 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2528 	 *
2529 	 * Decrease TTL value directly
2530 	 *
2531 	 * No associated configuration structure.
2532 	 */
2533 	RTE_FLOW_ACTION_TYPE_DEC_TTL,
2534 
2535 	/**
2536 	 * @warning This is a legacy action.
2537 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2538 	 *
2539 	 * Set TTL value
2540 	 *
2541 	 * See struct rte_flow_action_set_ttl
2542 	 */
2543 	RTE_FLOW_ACTION_TYPE_SET_TTL,
2544 
2545 	/**
2546 	 * @warning This is a legacy action.
2547 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2548 	 *
2549 	 * Set source MAC address from matched flow.
2550 	 *
2551 	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2552 	 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2553 	 *
2554 	 * See struct rte_flow_action_set_mac.
2555 	 */
2556 	RTE_FLOW_ACTION_TYPE_SET_MAC_SRC,
2557 
2558 	/**
2559 	 * @warning This is a legacy action.
2560 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2561 	 *
2562 	 * Set destination MAC address from matched flow.
2563 	 *
2564 	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2565 	 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2566 	 *
2567 	 * See struct rte_flow_action_set_mac.
2568 	 */
2569 	RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
2570 
2571 	/**
2572 	 * @warning This is a legacy action.
2573 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2574 	 *
2575 	 * Increase sequence number in the outermost TCP header.
2576 	 *
2577 	 * Action configuration specifies the value to increase
2578 	 * TCP sequence number as a big-endian 32 bit integer.
2579 	 *
2580 	 * @p conf type:
2581 	 * @code rte_be32_t * @endcode
2582 	 *
2583 	 * Using this action on non-matching traffic will result in
2584 	 * undefined behavior.
2585 	 */
2586 	RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
2587 
2588 	/**
2589 	 * @warning This is a legacy action.
2590 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2591 	 *
2592 	 * Decrease sequence number in the outermost TCP header.
2593 	 *
2594 	 * Action configuration specifies the value to decrease
2595 	 * TCP sequence number as a big-endian 32 bit integer.
2596 	 *
2597 	 * @p conf type:
2598 	 * @code rte_be32_t * @endcode
2599 	 *
2600 	 * Using this action on non-matching traffic will result in
2601 	 * undefined behavior.
2602 	 */
2603 	RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
2604 
2605 	/**
2606 	 * @warning This is a legacy action.
2607 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2608 	 *
2609 	 * Increase acknowledgment number in the outermost TCP header.
2610 	 *
2611 	 * Action configuration specifies the value to increase
2612 	 * TCP acknowledgment number as a big-endian 32 bit integer.
2613 	 *
2614 	 * @p conf type:
2615 	 * @code rte_be32_t * @endcode
2616 
2617 	 * Using this action on non-matching traffic will result in
2618 	 * undefined behavior.
2619 	 */
2620 	RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
2621 
2622 	/**
2623 	 * @warning This is a legacy action.
2624 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2625 	 *
2626 	 * Decrease acknowledgment number in the outermost TCP header.
2627 	 *
2628 	 * Action configuration specifies the value to decrease
2629 	 * TCP acknowledgment number as a big-endian 32 bit integer.
2630 	 *
2631 	 * @p conf type:
2632 	 * @code rte_be32_t * @endcode
2633 	 *
2634 	 * Using this action on non-matching traffic will result in
2635 	 * undefined behavior.
2636 	 */
2637 	RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
2638 
2639 	/**
2640 	 * @warning This is a legacy action.
2641 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2642 	 *
2643 	 * Set Tag.
2644 	 *
2645 	 * Tag is for internal flow usage only and
2646 	 * is not delivered to the application.
2647 	 *
2648 	 * See struct rte_flow_action_set_tag.
2649 	 */
2650 	RTE_FLOW_ACTION_TYPE_SET_TAG,
2651 
2652 	/**
2653 	 * @warning This is a legacy action.
2654 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2655 	 *
2656 	 * Set metadata on ingress or egress path.
2657 	 *
2658 	 * See struct rte_flow_action_set_meta.
2659 	 */
2660 	RTE_FLOW_ACTION_TYPE_SET_META,
2661 
2662 	/**
2663 	 * @warning This is a legacy action.
2664 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2665 	 *
2666 	 * Modify IPv4 DSCP in the outermost IP header.
2667 	 *
2668 	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2669 	 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2670 	 *
2671 	 * See struct rte_flow_action_set_dscp.
2672 	 */
2673 	RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP,
2674 
2675 	/**
2676 	 * @warning This is a legacy action.
2677 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2678 	 *
2679 	 * Modify IPv6 DSCP in the outermost IP header.
2680 	 *
2681 	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2682 	 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2683 	 *
2684 	 * See struct rte_flow_action_set_dscp.
2685 	 */
2686 	RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP,
2687 
2688 	/**
2689 	 * Report as aged flow if timeout passed without any matching on the
2690 	 * flow.
2691 	 *
2692 	 * See struct rte_flow_action_age.
2693 	 * See function rte_flow_get_q_aged_flows
2694 	 * See function rte_flow_get_aged_flows
2695 	 * see enum RTE_ETH_EVENT_FLOW_AGED
2696 	 * See struct rte_flow_query_age
2697 	 * See struct rte_flow_update_age
2698 	 */
2699 	RTE_FLOW_ACTION_TYPE_AGE,
2700 
2701 	/**
2702 	 * The matching packets will be duplicated with specified ratio and
2703 	 * applied with own set of actions with a fate action.
2704 	 *
2705 	 * See struct rte_flow_action_sample.
2706 	 */
2707 	RTE_FLOW_ACTION_TYPE_SAMPLE,
2708 
2709 	/**
2710 	 * @deprecated
2711 	 * @see RTE_FLOW_ACTION_TYPE_INDIRECT
2712 	 *
2713 	 * Describe action shared across multiple flow rules.
2714 	 *
2715 	 * Allow multiple rules reference the same action by handle (see
2716 	 * struct rte_flow_shared_action).
2717 	 */
2718 	RTE_FLOW_ACTION_TYPE_SHARED,
2719 
2720 	/**
2721 	 * Modify a packet header field, tag, mark or metadata.
2722 	 *
2723 	 * Allow the modification of an arbitrary header field via
2724 	 * set, add and sub operations or copying its content into
2725 	 * tag, meta or mark for future processing.
2726 	 *
2727 	 * See struct rte_flow_action_modify_field.
2728 	 */
2729 	RTE_FLOW_ACTION_TYPE_MODIFY_FIELD,
2730 
2731 	/**
2732 	 * An action handle is referenced in a rule through an indirect action.
2733 	 *
2734 	 * The same action handle may be used in multiple rules for the same
2735 	 * or different ethdev ports.
2736 	 */
2737 	RTE_FLOW_ACTION_TYPE_INDIRECT,
2738 
2739 	/**
2740 	 * [META]
2741 	 *
2742 	 * Enable tracking a TCP connection state.
2743 	 *
2744 	 * @see struct rte_flow_action_conntrack.
2745 	 */
2746 	RTE_FLOW_ACTION_TYPE_CONNTRACK,
2747 
2748 	/**
2749 	 * Color the packet to reflect the meter color result.
2750 	 * Set the meter color in the mbuf to the selected color.
2751 	 *
2752 	 * See struct rte_flow_action_meter_color.
2753 	 */
2754 	RTE_FLOW_ACTION_TYPE_METER_COLOR,
2755 
2756 	/**
2757 	 * At embedded switch level, sends matching traffic to the given ethdev.
2758 	 *
2759 	 * @see struct rte_flow_action_ethdev
2760 	 */
2761 	RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR,
2762 
2763 	/**
2764 	 * At embedded switch level, send matching traffic to
2765 	 * the entity represented by the given ethdev.
2766 	 *
2767 	 * @see struct rte_flow_action_ethdev
2768 	 */
2769 	RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT,
2770 
2771 	/**
2772 	 * Traffic metering and marking (MTR).
2773 	 *
2774 	 * @see struct rte_flow_action_meter_mark
2775 	 * See file rte_mtr.h for MTR profile object configuration.
2776 	 */
2777 	RTE_FLOW_ACTION_TYPE_METER_MARK,
2778 
2779 	/**
2780 	 * Send packets to the kernel, without going to userspace at all.
2781 	 * The packets will be received by the kernel driver sharing
2782 	 * the same device as the DPDK port on which this action is configured.
2783 	 * This action mostly suits bifurcated driver model.
2784 	 * This is an ingress non-transfer action only.
2785 	 *
2786 	 * No associated configuration structure.
2787 	 */
2788 	RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL,
2789 };
2790 
2791 /**
2792  * RTE_FLOW_ACTION_TYPE_MARK
2793  *
2794  * Attaches an integer value to packets and sets RTE_MBUF_F_RX_FDIR and
2795  * RTE_MBUF_F_RX_FDIR_ID mbuf flags.
2796  *
2797  * This value is arbitrary and application-defined. Maximum allowed value
2798  * depends on the underlying implementation. It is returned in the
2799  * hash.fdir.hi mbuf field.
2800  */
2801 struct rte_flow_action_mark {
2802 	uint32_t id; /**< Integer value to return with packets. */
2803 };
2804 
2805 /**
2806  * @warning
2807  * @b EXPERIMENTAL: this structure may change without prior notice
2808  *
2809  * RTE_FLOW_ACTION_TYPE_JUMP
2810  *
2811  * Redirects packets to a group on the current device.
2812  *
2813  * In a hierarchy of groups, which can be used to represent physical or logical
2814  * flow tables on the device, this action allows the action to be a redirect to
2815  * a group on that device.
2816  */
2817 struct rte_flow_action_jump {
2818 	uint32_t group;
2819 };
2820 
2821 /**
2822  * RTE_FLOW_ACTION_TYPE_QUEUE
2823  *
2824  * Assign packets to a given queue index.
2825  */
2826 struct rte_flow_action_queue {
2827 	uint16_t index; /**< Queue index to use. */
2828 };
2829 
2830 /**
2831  * @warning
2832  * @b EXPERIMENTAL: this structure may change without prior notice
2833  *
2834  * RTE_FLOW_ACTION_TYPE_AGE
2835  *
2836  * Report flow as aged-out if timeout passed without any matching
2837  * on the flow. RTE_ETH_EVENT_FLOW_AGED event is triggered when a
2838  * port detects new aged-out flows.
2839  *
2840  * The flow context and the flow handle will be reported by the either
2841  * rte_flow_get_aged_flows or rte_flow_get_q_aged_flows APIs.
2842  */
2843 struct rte_flow_action_age {
2844 	uint32_t timeout:24; /**< Time in seconds. */
2845 	uint32_t reserved:8; /**< Reserved, must be zero. */
2846 	/** The user flow context, NULL means the rte_flow pointer. */
2847 	void *context;
2848 };
2849 
2850 /**
2851  * RTE_FLOW_ACTION_TYPE_AGE (query)
2852  *
2853  * Query structure to retrieve the aging status information of a
2854  * shared AGE action, or a flow rule using the AGE action.
2855  */
2856 struct rte_flow_query_age {
2857 	uint32_t reserved:6; /**< Reserved, must be zero. */
2858 	uint32_t aged:1; /**< 1 if aging timeout expired, 0 otherwise. */
2859 	/** sec_since_last_hit value is valid. */
2860 	uint32_t sec_since_last_hit_valid:1;
2861 	uint32_t sec_since_last_hit:24; /**< Seconds since last traffic hit. */
2862 };
2863 
2864 /**
2865  * @warning
2866  * @b EXPERIMENTAL: this structure may change without prior notice
2867  *
2868  * RTE_FLOW_ACTION_TYPE_AGE
2869  *
2870  * Update indirect AGE action attributes:
2871  *  - Timeout can be updated including stop/start action:
2872  *     +-------------+-------------+------------------------------+
2873  *     | Old Timeout | New Timeout | Updating                     |
2874  *     +=============+=============+==============================+
2875  *     | 0           | positive    | Start aging with new value   |
2876  *     +-------------+-------------+------------------------------+
2877  *     | positive    | 0           | Stop aging			  |
2878  *     +-------------+-------------+------------------------------+
2879  *     | positive    | positive    | Change timeout to new value  |
2880  *     +-------------+-------------+------------------------------+
2881  *  - sec_since_last_hit can be reset.
2882  */
2883 struct rte_flow_update_age {
2884 	uint32_t reserved:6; /**< Reserved, must be zero. */
2885 	uint32_t timeout_valid:1; /**< The timeout is valid for update. */
2886 	uint32_t timeout:24; /**< Time in seconds. */
2887 	/** Means that aging should assume packet passed the aging. */
2888 	uint32_t touch:1;
2889 };
2890 
2891 /**
2892  * @warning
2893  * @b EXPERIMENTAL: this structure may change without prior notice
2894  *
2895  * RTE_FLOW_ACTION_TYPE_COUNT
2896  *
2897  * Adds a counter action to a matched flow.
2898  *
2899  * If more than one count action is specified in a single flow rule, then each
2900  * action must specify a unique ID.
2901  *
2902  * Counters can be retrieved and reset through ``rte_flow_query()``, see
2903  * ``struct rte_flow_query_count``.
2904  *
2905  * For ports within the same switch domain then the counter ID namespace extends
2906  * to all ports within that switch domain.
2907  */
2908 struct rte_flow_action_count {
2909 	uint32_t id; /**< Counter ID. */
2910 };
2911 
2912 /**
2913  * RTE_FLOW_ACTION_TYPE_COUNT (query)
2914  *
2915  * Query structure to retrieve and reset flow rule counters.
2916  */
2917 struct rte_flow_query_count {
2918 	uint32_t reset:1; /**< Reset counters after query [in]. */
2919 	uint32_t hits_set:1; /**< hits field is set [out]. */
2920 	uint32_t bytes_set:1; /**< bytes field is set [out]. */
2921 	uint32_t reserved:29; /**< Reserved, must be zero [in, out]. */
2922 	uint64_t hits; /**< Number of hits for this rule [out]. */
2923 	uint64_t bytes; /**< Number of bytes through this rule [out]. */
2924 };
2925 
2926 /**
2927  * Hash function types.
2928  */
2929 enum rte_eth_hash_function {
2930 	RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
2931 	RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
2932 	RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
2933 	/**
2934 	 * Symmetric Toeplitz: src, dst will be replaced by
2935 	 * xor(src, dst). For the case with src/dst only,
2936 	 * src or dst address will xor with zero pair.
2937 	 */
2938 	RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
2939 	RTE_ETH_HASH_FUNCTION_MAX,
2940 };
2941 
2942 /**
2943  * RTE_FLOW_ACTION_TYPE_RSS
2944  *
2945  * Similar to QUEUE, except RSS is additionally performed on packets to
2946  * spread them among several queues according to the provided parameters.
2947  *
2948  * Unlike global RSS settings used by other DPDK APIs, unsetting the
2949  * @p types field does not disable RSS in a flow rule. Doing so instead
2950  * requests safe unspecified "best-effort" settings from the underlying PMD,
2951  * which depending on the flow rule, may result in anything ranging from
2952  * empty (single queue) to all-inclusive RSS.
2953  *
2954  * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps
2955  * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only,
2956  * both can be requested simultaneously.
2957  */
2958 struct rte_flow_action_rss {
2959 	enum rte_eth_hash_function func; /**< RSS hash function to apply. */
2960 	/**
2961 	 * Packet encapsulation level RSS hash @p types apply to.
2962 	 *
2963 	 * - @p 0 requests the default behavior. Depending on the packet
2964 	 *   type, it can mean outermost, innermost, anything in between or
2965 	 *   even no RSS.
2966 	 *
2967 	 *   It basically stands for the innermost encapsulation level RSS
2968 	 *   can be performed on according to PMD and device capabilities.
2969 	 *
2970 	 * - @p 1 requests RSS to be performed on the outermost packet
2971 	 *   encapsulation level.
2972 	 *
2973 	 * - @p 2 and subsequent values request RSS to be performed on the
2974 	 *   specified inner packet encapsulation level, from outermost to
2975 	 *   innermost (lower to higher values).
2976 	 *
2977 	 * Values other than @p 0 are not necessarily supported.
2978 	 *
2979 	 * Requesting a specific RSS level on unrecognized traffic results
2980 	 * in undefined behavior. For predictable results, it is recommended
2981 	 * to make the flow rule pattern match packet headers up to the
2982 	 * requested encapsulation level so that only matching traffic goes
2983 	 * through.
2984 	 */
2985 	uint32_t level;
2986 	uint64_t types; /**< Specific RSS hash types (see RTE_ETH_RSS_*). */
2987 	uint32_t key_len; /**< Hash key length in bytes. */
2988 	uint32_t queue_num; /**< Number of entries in @p queue. */
2989 	const uint8_t *key; /**< Hash key. */
2990 	const uint16_t *queue; /**< Queue indices to use. */
2991 };
2992 
2993 /**
2994  * @deprecated
2995  * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2996  * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2997  *
2998  * RTE_FLOW_ACTION_TYPE_VF
2999  *
3000  * Directs matching traffic to a given virtual function of the current
3001  * device.
3002  *
3003  * Packets matched by a VF pattern item can be redirected to their original
3004  * VF ID instead of the specified one. This parameter may not be available
3005  * and is not guaranteed to work properly if the VF part is matched by a
3006  * prior flow rule or if packets are not addressed to a VF in the first
3007  * place.
3008  */
3009 struct rte_flow_action_vf {
3010 	uint32_t original:1; /**< Use original VF ID if possible. */
3011 	uint32_t reserved:31; /**< Reserved, must be zero. */
3012 	uint32_t id; /**< VF ID. */
3013 };
3014 
3015 /**
3016  * @deprecated
3017  * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
3018  * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
3019  *
3020  * RTE_FLOW_ACTION_TYPE_PORT_ID
3021  *
3022  * Directs matching traffic to a given DPDK port ID.
3023  *
3024  * @see RTE_FLOW_ITEM_TYPE_PORT_ID
3025  */
3026 struct rte_flow_action_port_id {
3027 	uint32_t original:1; /**< Use original DPDK port ID if possible. */
3028 	uint32_t reserved:31; /**< Reserved, must be zero. */
3029 	uint32_t id; /**< DPDK port ID. */
3030 };
3031 
3032 /**
3033  * RTE_FLOW_ACTION_TYPE_METER
3034  *
3035  * Traffic metering and policing (MTR).
3036  *
3037  * Packets matched by items of this type can be either dropped or passed to the
3038  * next item with their color set by the MTR object.
3039  */
3040 struct rte_flow_action_meter {
3041 	uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */
3042 };
3043 
3044 /**
3045  * RTE_FLOW_ACTION_TYPE_SECURITY
3046  *
3047  * Perform the security action on flows matched by the pattern items
3048  * according to the configuration of the security session.
3049  *
3050  * This action modifies the payload of matched flows. For INLINE_CRYPTO, the
3051  * security protocol headers and IV are fully provided by the application as
3052  * specified in the flow pattern. The payload of matching packets is
3053  * encrypted on egress, and decrypted and authenticated on ingress.
3054  * For INLINE_PROTOCOL, the security protocol is fully offloaded to HW,
3055  * providing full encapsulation and decapsulation of packets in security
3056  * protocols. The flow pattern specifies both the outer security header fields
3057  * and the inner packet fields. The security session specified in the action
3058  * must match the pattern parameters.
3059  *
3060  * The security session specified in the action must be created on the same
3061  * port as the flow action that is being specified.
3062  *
3063  * The ingress/egress flow attribute should match that specified in the
3064  * security session if the security session supports the definition of the
3065  * direction.
3066  *
3067  * Multiple flows can be configured to use the same security session.
3068  *
3069  * The NULL value is allowed for security session. If security session is NULL,
3070  * then SPI field in ESP flow item and IP addresses in flow items 'IPv4' and
3071  * 'IPv6' will be allowed to be a range. The rule thus created can enable
3072  * security processing on multiple flows.
3073  */
3074 struct rte_flow_action_security {
3075 	void *security_session; /**< Pointer to security session structure. */
3076 };
3077 
3078 /**
3079  * RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN
3080  *
3081  * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by the
3082  * OpenFlow Switch Specification.
3083  */
3084 struct rte_flow_action_of_push_vlan {
3085 	rte_be16_t ethertype; /**< EtherType. */
3086 };
3087 
3088 /**
3089  * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID
3090  *
3091  * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN ID") as defined by
3092  * the OpenFlow Switch Specification.
3093  */
3094 struct rte_flow_action_of_set_vlan_vid {
3095 	rte_be16_t vlan_vid; /**< VLAN ID. */
3096 };
3097 
3098 /**
3099  * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP
3100  *
3101  * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as defined by
3102  * the OpenFlow Switch Specification.
3103  */
3104 struct rte_flow_action_of_set_vlan_pcp {
3105 	uint8_t vlan_pcp; /**< VLAN priority. */
3106 };
3107 
3108 /**
3109  * RTE_FLOW_ACTION_TYPE_OF_POP_MPLS
3110  *
3111  * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined by the
3112  * OpenFlow Switch Specification.
3113  */
3114 struct rte_flow_action_of_pop_mpls {
3115 	rte_be16_t ethertype; /**< EtherType. */
3116 };
3117 
3118 /**
3119  * RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS
3120  *
3121  * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by the
3122  * OpenFlow Switch Specification.
3123  */
3124 struct rte_flow_action_of_push_mpls {
3125 	rte_be16_t ethertype; /**< EtherType. */
3126 };
3127 
3128 /**
3129  * @warning
3130  * @b EXPERIMENTAL: this structure may change without prior notice
3131  *
3132  * RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP
3133  *
3134  * VXLAN tunnel end-point encapsulation data definition
3135  *
3136  * The tunnel definition is provided through the flow item pattern, the
3137  * provided pattern must conform to RFC7348 for the tunnel specified. The flow
3138  * definition must be provided in order from the RTE_FLOW_ITEM_TYPE_ETH
3139  * definition up the end item which is specified by RTE_FLOW_ITEM_TYPE_END.
3140  *
3141  * The mask field allows user to specify which fields in the flow item
3142  * definitions can be ignored and which have valid data and can be used
3143  * verbatim.
3144  *
3145  * Note: the last field is not used in the definition of a tunnel and can be
3146  * ignored.
3147  *
3148  * Valid flow definition for RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP include:
3149  *
3150  * - ETH / IPV4 / UDP / VXLAN / END
3151  * - ETH / IPV6 / UDP / VXLAN / END
3152  * - ETH / VLAN / IPV4 / UDP / VXLAN / END
3153  *
3154  */
3155 struct rte_flow_action_vxlan_encap {
3156 	/**
3157 	 * Encapsulating vxlan tunnel definition
3158 	 * (terminated by the END pattern item).
3159 	 */
3160 	struct rte_flow_item *definition;
3161 };
3162 
3163 /**
3164  * @warning
3165  * @b EXPERIMENTAL: this structure may change without prior notice
3166  *
3167  * RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP
3168  *
3169  * NVGRE tunnel end-point encapsulation data definition
3170  *
3171  * The tunnel definition is provided through the flow item pattern  the
3172  * provided pattern must conform with RFC7637. The flow definition must be
3173  * provided in order from the RTE_FLOW_ITEM_TYPE_ETH definition up the end item
3174  * which is specified by RTE_FLOW_ITEM_TYPE_END.
3175  *
3176  * The mask field allows user to specify which fields in the flow item
3177  * definitions can be ignored and which have valid data and can be used
3178  * verbatim.
3179  *
3180  * Note: the last field is not used in the definition of a tunnel and can be
3181  * ignored.
3182  *
3183  * Valid flow definition for RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP include:
3184  *
3185  * - ETH / IPV4 / NVGRE / END
3186  * - ETH / VLAN / IPV6 / NVGRE / END
3187  *
3188  */
3189 struct rte_flow_action_nvgre_encap {
3190 	/**
3191 	 * Encapsulating vxlan tunnel definition
3192 	 * (terminated by the END pattern item).
3193 	 */
3194 	struct rte_flow_item *definition;
3195 };
3196 
3197 /**
3198  * @warning
3199  * @b EXPERIMENTAL: this structure may change without prior notice
3200  *
3201  * RTE_FLOW_ACTION_TYPE_RAW_ENCAP
3202  *
3203  * Raw tunnel end-point encapsulation data definition.
3204  *
3205  * The data holds the headers definitions to be applied on the packet.
3206  * The data must start with ETH header up to the tunnel item header itself.
3207  * When used right after RAW_DECAP (for decapsulating L3 tunnel type for
3208  * example MPLSoGRE) the data will just hold layer 2 header.
3209  *
3210  * The preserve parameter holds which bits in the packet the PMD is not allowed
3211  * to change, this parameter can also be NULL and then the PMD is allowed
3212  * to update any field.
3213  *
3214  * size holds the number of bytes in @p data and @p preserve.
3215  */
3216 struct rte_flow_action_raw_encap {
3217 	uint8_t *data; /**< Encapsulation data. */
3218 	uint8_t *preserve; /**< Bit-mask of @p data to preserve on output. */
3219 	size_t size; /**< Size of @p data and @p preserve. */
3220 };
3221 
3222 /**
3223  * @warning
3224  * @b EXPERIMENTAL: this structure may change without prior notice
3225  *
3226  * RTE_FLOW_ACTION_TYPE_RAW_DECAP
3227  *
3228  * Raw tunnel end-point decapsulation data definition.
3229  *
3230  * The data holds the headers definitions to be removed from the packet.
3231  * The data must start with ETH header up to the tunnel item header itself.
3232  * When used right before RAW_DECAP (for encapsulating L3 tunnel type for
3233  * example MPLSoGRE) the data will just hold layer 2 header.
3234  *
3235  * size holds the number of bytes in @p data.
3236  */
3237 struct rte_flow_action_raw_decap {
3238 	uint8_t *data; /**< Encapsulation data. */
3239 	size_t size; /**< Size of @p data and @p preserve. */
3240 };
3241 
3242 /**
3243  * @warning
3244  * @b EXPERIMENTAL: this structure may change without prior notice
3245  *
3246  * RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC
3247  * RTE_FLOW_ACTION_TYPE_SET_IPV4_DST
3248  *
3249  * Allows modification of IPv4 source (RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC)
3250  * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV4_DST) in the
3251  * specified outermost IPv4 header.
3252  */
3253 struct rte_flow_action_set_ipv4 {
3254 	rte_be32_t ipv4_addr;
3255 };
3256 
3257 /**
3258  * @warning
3259  * @b EXPERIMENTAL: this structure may change without prior notice
3260  *
3261  * RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC
3262  * RTE_FLOW_ACTION_TYPE_SET_IPV6_DST
3263  *
3264  * Allows modification of IPv6 source (RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC)
3265  * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV6_DST) in the
3266  * specified outermost IPv6 header.
3267  */
3268 struct rte_flow_action_set_ipv6 {
3269 	uint8_t ipv6_addr[16];
3270 };
3271 
3272 /**
3273  * @warning
3274  * @b EXPERIMENTAL: this structure may change without prior notice
3275  *
3276  * RTE_FLOW_ACTION_TYPE_SET_TP_SRC
3277  * RTE_FLOW_ACTION_TYPE_SET_TP_DST
3278  *
3279  * Allows modification of source (RTE_FLOW_ACTION_TYPE_SET_TP_SRC)
3280  * and destination (RTE_FLOW_ACTION_TYPE_SET_TP_DST) port numbers
3281  * in the specified outermost TCP/UDP header.
3282  */
3283 struct rte_flow_action_set_tp {
3284 	rte_be16_t port;
3285 };
3286 
3287 /**
3288  * RTE_FLOW_ACTION_TYPE_SET_TTL
3289  *
3290  * Set the TTL value directly for IPv4 or IPv6
3291  */
3292 struct rte_flow_action_set_ttl {
3293 	uint8_t ttl_value;
3294 };
3295 
3296 /**
3297  * RTE_FLOW_ACTION_TYPE_SET_MAC
3298  *
3299  * Set MAC address from the matched flow
3300  */
3301 struct rte_flow_action_set_mac {
3302 	uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
3303 };
3304 
3305 /**
3306  * @warning
3307  * @b EXPERIMENTAL: this structure may change without prior notice
3308  *
3309  * RTE_FLOW_ACTION_TYPE_SET_TAG
3310  *
3311  * Set a tag which is a transient data used during flow matching. This is not
3312  * delivered to application. Multiple tags are supported by specifying index.
3313  */
3314 struct rte_flow_action_set_tag {
3315 	uint32_t data;
3316 	uint32_t mask;
3317 	uint8_t index;
3318 };
3319 
3320 /**
3321  * @warning
3322  * @b EXPERIMENTAL: this structure may change without prior notice
3323  *
3324  * RTE_FLOW_ACTION_TYPE_SET_META
3325  *
3326  * Set metadata. Metadata set by mbuf metadata dynamic field with
3327  * RTE_MBUF_DYNFLAG_TX_METADATA flag on egress will be overridden by this
3328  * action. On ingress, the metadata will be carried by mbuf metadata dynamic
3329  * field with RTE_MBUF_DYNFLAG_RX_METADATA flag if set.  The dynamic mbuf field
3330  * must be registered in advance by rte_flow_dynf_metadata_register().
3331  *
3332  * Altering partial bits is supported with mask. For bits which have never
3333  * been set, unpredictable value will be seen depending on driver
3334  * implementation. For loopback/hairpin packet, metadata set on Rx/Tx may
3335  * or may not be propagated to the other path depending on HW capability.
3336  *
3337  * RTE_FLOW_ITEM_TYPE_META matches metadata.
3338  */
3339 struct rte_flow_action_set_meta {
3340 	uint32_t data;
3341 	uint32_t mask;
3342 };
3343 
3344 /**
3345  * RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP
3346  * RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP
3347  *
3348  * Set the DSCP value for IPv4/IPv6 header.
3349  * DSCP in low 6 bits, rest ignored.
3350  */
3351 struct rte_flow_action_set_dscp {
3352 	uint8_t dscp;
3353 };
3354 
3355 /**
3356  * @warning
3357  * @b EXPERIMENTAL: this structure may change without prior notice
3358  *
3359  * RTE_FLOW_ACTION_TYPE_INDIRECT
3360  *
3361  * Opaque type returned after successfully creating an indirect action object.
3362  * The definition of the object handle is different per driver or
3363  * per direct action type.
3364  *
3365  * This handle can be used to manage and query the related direct action:
3366  * - referenced in single flow rule or across multiple flow rules
3367  *   over multiple ports
3368  * - update action object configuration
3369  * - query action object data
3370  * - destroy action object
3371  */
3372 struct rte_flow_action_handle;
3373 
3374 /**
3375  * The state of a TCP connection.
3376  */
3377 enum rte_flow_conntrack_state {
3378 	/** SYN-ACK packet was seen. */
3379 	RTE_FLOW_CONNTRACK_STATE_SYN_RECV,
3380 	/** 3-way handshake was done. */
3381 	RTE_FLOW_CONNTRACK_STATE_ESTABLISHED,
3382 	/** First FIN packet was received to close the connection. */
3383 	RTE_FLOW_CONNTRACK_STATE_FIN_WAIT,
3384 	/** First FIN was ACKed. */
3385 	RTE_FLOW_CONNTRACK_STATE_CLOSE_WAIT,
3386 	/** Second FIN was received, waiting for the last ACK. */
3387 	RTE_FLOW_CONNTRACK_STATE_LAST_ACK,
3388 	/** Second FIN was ACKed, connection was closed. */
3389 	RTE_FLOW_CONNTRACK_STATE_TIME_WAIT,
3390 };
3391 
3392 /**
3393  * The last passed TCP packet flags of a connection.
3394  */
3395 enum rte_flow_conntrack_tcp_last_index {
3396 	RTE_FLOW_CONNTRACK_FLAG_NONE = 0, /**< No Flag. */
3397 	RTE_FLOW_CONNTRACK_FLAG_SYN = RTE_BIT32(0), /**< With SYN flag. */
3398 	RTE_FLOW_CONNTRACK_FLAG_SYNACK = RTE_BIT32(1), /**< With SYNACK flag. */
3399 	RTE_FLOW_CONNTRACK_FLAG_FIN = RTE_BIT32(2), /**< With FIN flag. */
3400 	RTE_FLOW_CONNTRACK_FLAG_ACK = RTE_BIT32(3), /**< With ACK flag. */
3401 	RTE_FLOW_CONNTRACK_FLAG_RST = RTE_BIT32(4), /**< With RST flag. */
3402 };
3403 
3404 /**
3405  * @warning
3406  * @b EXPERIMENTAL: this structure may change without prior notice
3407  *
3408  * Configuration parameters for each direction of a TCP connection.
3409  * All fields should be in host byte order.
3410  * If needed, driver should convert all fields to network byte order
3411  * if HW needs them in that way.
3412  */
3413 struct rte_flow_tcp_dir_param {
3414 	/** TCP window scaling factor, 0xF to disable. */
3415 	uint32_t scale:4;
3416 	/** The FIN was sent by this direction. */
3417 	uint32_t close_initiated:1;
3418 	/** An ACK packet has been received by this side. */
3419 	uint32_t last_ack_seen:1;
3420 	/**
3421 	 * If set, it indicates that there is unacknowledged data for the
3422 	 * packets sent from this direction.
3423 	 */
3424 	uint32_t data_unacked:1;
3425 	/**
3426 	 * Maximal value of sequence + payload length in sent
3427 	 * packets (next ACK from the opposite direction).
3428 	 */
3429 	uint32_t sent_end;
3430 	/**
3431 	 * Maximal value of (ACK + window size) in received packet + length
3432 	 * over sent packet (maximal sequence could be sent).
3433 	 */
3434 	uint32_t reply_end;
3435 	/** Maximal value of actual window size in sent packets. */
3436 	uint32_t max_win;
3437 	/** Maximal value of ACK in sent packets. */
3438 	uint32_t max_ack;
3439 };
3440 
3441 /**
3442  * @warning
3443  * @b EXPERIMENTAL: this structure may change without prior notice
3444  *
3445  * RTE_FLOW_ACTION_TYPE_CONNTRACK
3446  *
3447  * Configuration and initial state for the connection tracking module.
3448  * This structure could be used for both setting and query.
3449  * All fields should be in host byte order.
3450  */
3451 struct rte_flow_action_conntrack {
3452 	/** The peer port number, can be the same port. */
3453 	uint16_t peer_port;
3454 	/**
3455 	 * Direction of this connection when creating a flow rule, the
3456 	 * value only affects the creation of subsequent flow rules.
3457 	 */
3458 	uint32_t is_original_dir:1;
3459 	/**
3460 	 * Enable / disable the conntrack HW module. When disabled, the
3461 	 * result will always be RTE_FLOW_CONNTRACK_FLAG_DISABLED.
3462 	 * In this state the HW will act as passthrough.
3463 	 * It only affects this conntrack object in the HW without any effect
3464 	 * to the other objects.
3465 	 */
3466 	uint32_t enable:1;
3467 	/** At least one ack was seen after the connection was established. */
3468 	uint32_t live_connection:1;
3469 	/** Enable selective ACK on this connection. */
3470 	uint32_t selective_ack:1;
3471 	/** A challenge ack has passed. */
3472 	uint32_t challenge_ack_passed:1;
3473 	/**
3474 	 * 1: The last packet is seen from the original direction.
3475 	 * 0: The last packet is seen from the reply direction.
3476 	 */
3477 	uint32_t last_direction:1;
3478 	/** No TCP check will be done except the state change. */
3479 	uint32_t liberal_mode:1;
3480 	/** The current state of this connection. */
3481 	enum rte_flow_conntrack_state state;
3482 	/** Scaling factor for maximal allowed ACK window. */
3483 	uint8_t max_ack_window;
3484 	/** Maximal allowed number of retransmission times. */
3485 	uint8_t retransmission_limit;
3486 	/** TCP parameters of the original direction. */
3487 	struct rte_flow_tcp_dir_param original_dir;
3488 	/** TCP parameters of the reply direction. */
3489 	struct rte_flow_tcp_dir_param reply_dir;
3490 	/** The window value of the last packet passed this conntrack. */
3491 	uint16_t last_window;
3492 	enum rte_flow_conntrack_tcp_last_index last_index;
3493 	/** The sequence of the last packet passed this conntrack. */
3494 	uint32_t last_seq;
3495 	/** The acknowledgment of the last packet passed this conntrack. */
3496 	uint32_t last_ack;
3497 	/**
3498 	 * The total value ACK + payload length of the last packet
3499 	 * passed this conntrack.
3500 	 */
3501 	uint32_t last_end;
3502 };
3503 
3504 /**
3505  * RTE_FLOW_ACTION_TYPE_CONNTRACK
3506  *
3507  * Wrapper structure for the context update interface.
3508  * Ports cannot support updating, and the only valid solution is to
3509  * destroy the old context and create a new one instead.
3510  */
3511 struct rte_flow_modify_conntrack {
3512 	/** New connection tracking parameters to be updated. */
3513 	struct rte_flow_action_conntrack new_ct;
3514 	/** The direction field will be updated. */
3515 	uint32_t direction:1;
3516 	/** All the other fields except direction will be updated. */
3517 	uint32_t state:1;
3518 	/** Reserved bits for the future usage. */
3519 	uint32_t reserved:30;
3520 };
3521 
3522 /**
3523  * @warning
3524  * @b EXPERIMENTAL: this structure may change without prior notice
3525  *
3526  * RTE_FLOW_ACTION_TYPE_METER_COLOR
3527  *
3528  * The meter color should be set in the packet meta-data
3529  * (i.e. struct rte_mbuf::sched::color).
3530  */
3531 struct rte_flow_action_meter_color {
3532 	enum rte_color color; /**< Packet color. */
3533 };
3534 
3535 /**
3536  * Provides an ethdev port ID for use with the following actions:
3537  * RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR,
3538  * RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT.
3539  */
3540 struct rte_flow_action_ethdev {
3541 	uint16_t port_id; /**< ethdev port ID */
3542 };
3543 
3544 /**
3545  * Field IDs for MODIFY_FIELD action.
3546  */
3547 enum rte_flow_field_id {
3548 	RTE_FLOW_FIELD_START = 0,	/**< Start of a packet. */
3549 	RTE_FLOW_FIELD_MAC_DST,		/**< Destination MAC Address. */
3550 	RTE_FLOW_FIELD_MAC_SRC,		/**< Source MAC Address. */
3551 	RTE_FLOW_FIELD_VLAN_TYPE,	/**< 802.1Q Tag Identifier. */
3552 	RTE_FLOW_FIELD_VLAN_ID,		/**< 802.1Q VLAN Identifier. */
3553 	RTE_FLOW_FIELD_MAC_TYPE,	/**< EtherType. */
3554 	RTE_FLOW_FIELD_IPV4_DSCP,	/**< IPv4 DSCP. */
3555 	RTE_FLOW_FIELD_IPV4_TTL,	/**< IPv4 Time To Live. */
3556 	RTE_FLOW_FIELD_IPV4_SRC,	/**< IPv4 Source Address. */
3557 	RTE_FLOW_FIELD_IPV4_DST,	/**< IPv4 Destination Address. */
3558 	RTE_FLOW_FIELD_IPV6_DSCP,	/**< IPv6 DSCP. */
3559 	RTE_FLOW_FIELD_IPV6_HOPLIMIT,	/**< IPv6 Hop Limit. */
3560 	RTE_FLOW_FIELD_IPV6_SRC,	/**< IPv6 Source Address. */
3561 	RTE_FLOW_FIELD_IPV6_DST,	/**< IPv6 Destination Address. */
3562 	RTE_FLOW_FIELD_TCP_PORT_SRC,	/**< TCP Source Port Number. */
3563 	RTE_FLOW_FIELD_TCP_PORT_DST,	/**< TCP Destination Port Number. */
3564 	RTE_FLOW_FIELD_TCP_SEQ_NUM,	/**< TCP Sequence Number. */
3565 	RTE_FLOW_FIELD_TCP_ACK_NUM,	/**< TCP Acknowledgment Number. */
3566 	RTE_FLOW_FIELD_TCP_FLAGS,	/**< TCP Flags. */
3567 	RTE_FLOW_FIELD_UDP_PORT_SRC,	/**< UDP Source Port Number. */
3568 	RTE_FLOW_FIELD_UDP_PORT_DST,	/**< UDP Destination Port Number. */
3569 	RTE_FLOW_FIELD_VXLAN_VNI,	/**< VXLAN Network Identifier. */
3570 	RTE_FLOW_FIELD_GENEVE_VNI,	/**< GENEVE Network Identifier. */
3571 	RTE_FLOW_FIELD_GTP_TEID,	/**< GTP Tunnel Endpoint Identifier. */
3572 	RTE_FLOW_FIELD_TAG,		/**< Tag value. */
3573 	RTE_FLOW_FIELD_MARK,		/**< Mark value. */
3574 	RTE_FLOW_FIELD_META,		/**< Metadata value. */
3575 	RTE_FLOW_FIELD_POINTER,		/**< Memory pointer. */
3576 	RTE_FLOW_FIELD_VALUE,		/**< Immediate value. */
3577 	RTE_FLOW_FIELD_IPV4_ECN,	/**< IPv4 ECN. */
3578 	RTE_FLOW_FIELD_IPV6_ECN,	/**< IPv6 ECN. */
3579 	RTE_FLOW_FIELD_GTP_PSC_QFI,	/**< GTP QFI. */
3580 	RTE_FLOW_FIELD_METER_COLOR,	/**< Meter color marker. */
3581 	RTE_FLOW_FIELD_IPV6_PROTO,	/**< IPv6 next header. */
3582 };
3583 
3584 /**
3585  * @warning
3586  * @b EXPERIMENTAL: this structure may change without prior notice
3587  *
3588  * Field description for MODIFY_FIELD action.
3589  */
3590 struct rte_flow_action_modify_data {
3591 	enum rte_flow_field_id field; /**< Field or memory type ID. */
3592 	RTE_STD_C11
3593 	union {
3594 		struct {
3595 			/** Encapsulation level or tag index. */
3596 			uint32_t level;
3597 			/** Number of bits to skip from a field. */
3598 			uint32_t offset;
3599 		};
3600 		/**
3601 		 * Immediate value for RTE_FLOW_FIELD_VALUE, presented in the
3602 		 * same byte order and length as in relevant rte_flow_item_xxx.
3603 		 * The immediate source bitfield offset is inherited from
3604 		 * the destination's one.
3605 		 */
3606 		uint8_t value[16];
3607 		/**
3608 		 * Memory address for RTE_FLOW_FIELD_POINTER, memory layout
3609 		 * should be the same as for relevant field in the
3610 		 * rte_flow_item_xxx structure.
3611 		 */
3612 		void *pvalue;
3613 	};
3614 };
3615 
3616 /**
3617  * Operation types for MODIFY_FIELD action.
3618  */
3619 enum rte_flow_modify_op {
3620 	RTE_FLOW_MODIFY_SET = 0, /**< Set a new value. */
3621 	RTE_FLOW_MODIFY_ADD,     /**< Add a value to a field.  */
3622 	RTE_FLOW_MODIFY_SUB,     /**< Subtract a value from a field. */
3623 };
3624 
3625 /**
3626  * @warning
3627  * @b EXPERIMENTAL: this structure may change without prior notice
3628  *
3629  * RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
3630  *
3631  * Modify a destination header field according to the specified
3632  * operation. Another field of the packet can be used as a source as well
3633  * as tag, mark, metadata, immediate value or a pointer to it.
3634  */
3635 struct rte_flow_action_modify_field {
3636 	enum rte_flow_modify_op operation; /**< Operation to perform. */
3637 	struct rte_flow_action_modify_data dst; /**< Destination field. */
3638 	struct rte_flow_action_modify_data src; /**< Source field. */
3639 	uint32_t width; /**< Number of bits to use from a source field. */
3640 };
3641 
3642 /**
3643  * RTE_FLOW_ACTION_TYPE_METER_MARK
3644  *
3645  * Traffic metering and marking (MTR).
3646  *
3647  * Meters a packet stream and marks its packets either
3648  * green, yellow, or red according to the specified profile.
3649  * The policy is optional and may be specified for defining
3650  * subsequent actions based on a color assigned by MTR.
3651  * Alternatively, the METER_COLOR item may be used for this.
3652  */
3653 struct rte_flow_action_meter_mark {
3654 
3655 	/**< Profile config retrieved with rte_mtr_profile_get(). */
3656 	struct rte_flow_meter_profile *profile;
3657 	/**< Policy config retrieved with rte_mtr_policy_get(). */
3658 	struct rte_flow_meter_policy *policy;
3659 	/** Metering mode: 0 - Color-Blind, 1 - Color-Aware. */
3660 	int color_mode;
3661 	/** Initial Color applied to packets in Color-Aware mode. */
3662 	enum rte_color init_color;
3663 	/** Metering state: 0 - Disabled, 1 - Enabled. */
3664 	int state;
3665 };
3666 
3667 /**
3668  * RTE_FLOW_ACTION_TYPE_METER_MARK
3669  *
3670  * Wrapper structure for the context update interface.
3671  *
3672  */
3673 struct rte_flow_update_meter_mark {
3674 	/** New meter_mark parameters to be updated. */
3675 	struct rte_flow_action_meter_mark meter_mark;
3676 	/** The profile will be updated. */
3677 	uint32_t profile_valid:1;
3678 	/** The policy will be updated. */
3679 	uint32_t policy_valid:1;
3680 	/** The color mode will be updated. */
3681 	uint32_t color_mode_valid:1;
3682 	/** The initial color will be updated. */
3683 	uint32_t init_color_valid:1;
3684 	/** The meter state will be updated. */
3685 	uint32_t state_valid:1;
3686 	/** Reserved bits for the future usage. */
3687 	uint32_t reserved:27;
3688 };
3689 
3690 /* Mbuf dynamic field offset for metadata. */
3691 extern int32_t rte_flow_dynf_metadata_offs;
3692 
3693 /* Mbuf dynamic field flag mask for metadata. */
3694 extern uint64_t rte_flow_dynf_metadata_mask;
3695 
3696 /* Mbuf dynamic field pointer for metadata. */
3697 #define RTE_FLOW_DYNF_METADATA(m) \
3698 	RTE_MBUF_DYNFIELD((m), rte_flow_dynf_metadata_offs, uint32_t *)
3699 
3700 /* Mbuf dynamic flags for metadata. */
3701 #define RTE_MBUF_DYNFLAG_RX_METADATA (rte_flow_dynf_metadata_mask)
3702 #define RTE_MBUF_DYNFLAG_TX_METADATA (rte_flow_dynf_metadata_mask)
3703 
3704 __rte_experimental
3705 static inline uint32_t
3706 rte_flow_dynf_metadata_get(struct rte_mbuf *m)
3707 {
3708 	return *RTE_FLOW_DYNF_METADATA(m);
3709 }
3710 
3711 __rte_experimental
3712 static inline void
3713 rte_flow_dynf_metadata_set(struct rte_mbuf *m, uint32_t v)
3714 {
3715 	*RTE_FLOW_DYNF_METADATA(m) = v;
3716 }
3717 
3718 /**
3719  * Definition of a single action.
3720  *
3721  * A list of actions is terminated by a END action.
3722  *
3723  * For simple actions without a configuration object, conf remains NULL.
3724  */
3725 struct rte_flow_action {
3726 	enum rte_flow_action_type type; /**< Action type. */
3727 	const void *conf; /**< Pointer to action configuration object. */
3728 };
3729 
3730 /**
3731  * Opaque type returned after successfully creating a flow.
3732  *
3733  * This handle can be used to manage and query the related flow (e.g. to
3734  * destroy it or retrieve counters).
3735  */
3736 struct rte_flow;
3737 
3738 /**
3739  * Opaque type for Meter profile object returned by MTR API.
3740  *
3741  * This handle can be used to create Meter actions instead of profile ID.
3742  */
3743 struct rte_flow_meter_profile;
3744 
3745 /**
3746  * Opaque type for Meter policy object returned by MTR API.
3747  *
3748  * This handle can be used to create Meter actions instead of policy ID.
3749  */
3750 struct rte_flow_meter_policy;
3751 
3752 /**
3753  * @warning
3754  * @b EXPERIMENTAL: this structure may change without prior notice
3755  *
3756  * RTE_FLOW_ACTION_TYPE_SAMPLE
3757  *
3758  * Adds a sample action to a matched flow.
3759  *
3760  * The matching packets will be duplicated with specified ratio and applied
3761  * with own set of actions with a fate action, the sampled packet could be
3762  * redirected to queue or port. All the packets continue processing on the
3763  * default flow path.
3764  *
3765  * When the sample ratio is set to 1 then the packets will be 100% mirrored.
3766  * Additional action list be supported to add for sampled or mirrored packets.
3767  */
3768 struct rte_flow_action_sample {
3769 	uint32_t ratio; /**< packets sampled equals to '1/ratio'. */
3770 	/** sub-action list specific for the sampling hit cases. */
3771 	const struct rte_flow_action *actions;
3772 };
3773 
3774 /**
3775  * Verbose error types.
3776  *
3777  * Most of them provide the type of the object referenced by struct
3778  * rte_flow_error.cause.
3779  */
3780 enum rte_flow_error_type {
3781 	RTE_FLOW_ERROR_TYPE_NONE, /**< No error. */
3782 	RTE_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
3783 	RTE_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */
3784 	RTE_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */
3785 	RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */
3786 	RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */
3787 	RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */
3788 	RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */
3789 	RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */
3790 	RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */
3791 	RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */
3792 	RTE_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */
3793 	RTE_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */
3794 	RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */
3795 	RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */
3796 	RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */
3797 	RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */
3798 	RTE_FLOW_ERROR_TYPE_STATE, /**< Current device state. */
3799 };
3800 
3801 /**
3802  * Verbose error structure definition.
3803  *
3804  * This object is normally allocated by applications and set by PMDs, the
3805  * message points to a constant string which does not need to be freed by
3806  * the application, however its pointer can be considered valid only as long
3807  * as its associated DPDK port remains configured. Closing the underlying
3808  * device or unloading the PMD invalidates it.
3809  *
3810  * Both cause and message may be NULL regardless of the error type.
3811  */
3812 struct rte_flow_error {
3813 	enum rte_flow_error_type type; /**< Cause field and error types. */
3814 	const void *cause; /**< Object responsible for the error. */
3815 	const char *message; /**< Human-readable error message. */
3816 };
3817 
3818 /**
3819  * Complete flow rule description.
3820  *
3821  * This object type is used when converting a flow rule description.
3822  *
3823  * @see RTE_FLOW_CONV_OP_RULE
3824  * @see rte_flow_conv()
3825  */
3826 RTE_STD_C11
3827 struct rte_flow_conv_rule {
3828 	union {
3829 		const struct rte_flow_attr *attr_ro; /**< RO attributes. */
3830 		struct rte_flow_attr *attr; /**< Attributes. */
3831 	};
3832 	union {
3833 		const struct rte_flow_item *pattern_ro; /**< RO pattern. */
3834 		struct rte_flow_item *pattern; /**< Pattern items. */
3835 	};
3836 	union {
3837 		const struct rte_flow_action *actions_ro; /**< RO actions. */
3838 		struct rte_flow_action *actions; /**< List of actions. */
3839 	};
3840 };
3841 
3842 /**
3843  * Conversion operations for flow API objects.
3844  *
3845  * @see rte_flow_conv()
3846  */
3847 enum rte_flow_conv_op {
3848 	/**
3849 	 * No operation to perform.
3850 	 *
3851 	 * rte_flow_conv() simply returns 0.
3852 	 */
3853 	RTE_FLOW_CONV_OP_NONE,
3854 
3855 	/**
3856 	 * Convert attributes structure.
3857 	 *
3858 	 * This is a basic copy of an attributes structure.
3859 	 *
3860 	 * - @p src type:
3861 	 *   @code const struct rte_flow_attr * @endcode
3862 	 * - @p dst type:
3863 	 *   @code struct rte_flow_attr * @endcode
3864 	 */
3865 	RTE_FLOW_CONV_OP_ATTR,
3866 
3867 	/**
3868 	 * Convert a single item.
3869 	 *
3870 	 * Duplicates @p spec, @p last and @p mask but not outside objects.
3871 	 *
3872 	 * - @p src type:
3873 	 *   @code const struct rte_flow_item * @endcode
3874 	 * - @p dst type:
3875 	 *   @code struct rte_flow_item * @endcode
3876 	 */
3877 	RTE_FLOW_CONV_OP_ITEM,
3878 
3879 	/**
3880 	 * Convert a single action.
3881 	 *
3882 	 * Duplicates @p conf but not outside objects.
3883 	 *
3884 	 * - @p src type:
3885 	 *   @code const struct rte_flow_action * @endcode
3886 	 * - @p dst type:
3887 	 *   @code struct rte_flow_action * @endcode
3888 	 */
3889 	RTE_FLOW_CONV_OP_ACTION,
3890 
3891 	/**
3892 	 * Convert an entire pattern.
3893 	 *
3894 	 * Duplicates all pattern items at once with the same constraints as
3895 	 * RTE_FLOW_CONV_OP_ITEM.
3896 	 *
3897 	 * - @p src type:
3898 	 *   @code const struct rte_flow_item * @endcode
3899 	 * - @p dst type:
3900 	 *   @code struct rte_flow_item * @endcode
3901 	 */
3902 	RTE_FLOW_CONV_OP_PATTERN,
3903 
3904 	/**
3905 	 * Convert a list of actions.
3906 	 *
3907 	 * Duplicates the entire list of actions at once with the same
3908 	 * constraints as RTE_FLOW_CONV_OP_ACTION.
3909 	 *
3910 	 * - @p src type:
3911 	 *   @code const struct rte_flow_action * @endcode
3912 	 * - @p dst type:
3913 	 *   @code struct rte_flow_action * @endcode
3914 	 */
3915 	RTE_FLOW_CONV_OP_ACTIONS,
3916 
3917 	/**
3918 	 * Convert a complete flow rule description.
3919 	 *
3920 	 * Comprises attributes, pattern and actions together at once with
3921 	 * the usual constraints.
3922 	 *
3923 	 * - @p src type:
3924 	 *   @code const struct rte_flow_conv_rule * @endcode
3925 	 * - @p dst type:
3926 	 *   @code struct rte_flow_conv_rule * @endcode
3927 	 */
3928 	RTE_FLOW_CONV_OP_RULE,
3929 
3930 	/**
3931 	 * Convert item type to its name string.
3932 	 *
3933 	 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
3934 	 * returned value excludes the terminator which is always written
3935 	 * nonetheless.
3936 	 *
3937 	 * - @p src type:
3938 	 *   @code (const void *)enum rte_flow_item_type @endcode
3939 	 * - @p dst type:
3940 	 *   @code char * @endcode
3941 	 **/
3942 	RTE_FLOW_CONV_OP_ITEM_NAME,
3943 
3944 	/**
3945 	 * Convert action type to its name string.
3946 	 *
3947 	 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
3948 	 * returned value excludes the terminator which is always written
3949 	 * nonetheless.
3950 	 *
3951 	 * - @p src type:
3952 	 *   @code (const void *)enum rte_flow_action_type @endcode
3953 	 * - @p dst type:
3954 	 *   @code char * @endcode
3955 	 **/
3956 	RTE_FLOW_CONV_OP_ACTION_NAME,
3957 
3958 	/**
3959 	 * Convert item type to pointer to item name.
3960 	 *
3961 	 * Retrieves item name pointer from its type. The string itself is
3962 	 * not copied; instead, a unique pointer to an internal static
3963 	 * constant storage is written to @p dst.
3964 	 *
3965 	 * - @p src type:
3966 	 *   @code (const void *)enum rte_flow_item_type @endcode
3967 	 * - @p dst type:
3968 	 *   @code const char ** @endcode
3969 	 */
3970 	RTE_FLOW_CONV_OP_ITEM_NAME_PTR,
3971 
3972 	/**
3973 	 * Convert action type to pointer to action name.
3974 	 *
3975 	 * Retrieves action name pointer from its type. The string itself is
3976 	 * not copied; instead, a unique pointer to an internal static
3977 	 * constant storage is written to @p dst.
3978 	 *
3979 	 * - @p src type:
3980 	 *   @code (const void *)enum rte_flow_action_type @endcode
3981 	 * - @p dst type:
3982 	 *   @code const char ** @endcode
3983 	 */
3984 	RTE_FLOW_CONV_OP_ACTION_NAME_PTR,
3985 };
3986 
3987 /**
3988  * @warning
3989  * @b EXPERIMENTAL: this API may change without prior notice.
3990  *
3991  * Dump hardware internal representation information of
3992  * rte flow to file.
3993  *
3994  * @param[in] port_id
3995  *    The port identifier of the Ethernet device.
3996  * @param[in] flow
3997  *   The pointer of flow rule to dump. Dump all rules if NULL.
3998  * @param[in] file
3999  *   A pointer to a file for output.
4000  * @param[out] error
4001  *   Perform verbose error reporting if not NULL. PMDs initialize this
4002  *   structure in case of error only.
4003  * @return
4004  *   0 on success, a negative value otherwise.
4005  */
4006 __rte_experimental
4007 int
4008 rte_flow_dev_dump(uint16_t port_id, struct rte_flow *flow,
4009 		FILE *file, struct rte_flow_error *error);
4010 
4011 /**
4012  * Check if mbuf dynamic field for metadata is registered.
4013  *
4014  * @return
4015  *   True if registered, false otherwise.
4016  */
4017 __rte_experimental
4018 static inline int
4019 rte_flow_dynf_metadata_avail(void)
4020 {
4021 	return !!rte_flow_dynf_metadata_mask;
4022 }
4023 
4024 /**
4025  * Register mbuf dynamic field and flag for metadata.
4026  *
4027  * This function must be called prior to use SET_META action in order to
4028  * register the dynamic mbuf field. Otherwise, the data cannot be delivered to
4029  * application.
4030  *
4031  * @return
4032  *   0 on success, a negative errno value otherwise and rte_errno is set.
4033  */
4034 __rte_experimental
4035 int
4036 rte_flow_dynf_metadata_register(void);
4037 
4038 /**
4039  * Check whether a flow rule can be created on a given port.
4040  *
4041  * The flow rule is validated for correctness and whether it could be accepted
4042  * by the device given sufficient resources. The rule is checked against the
4043  * current device mode and queue configuration. The flow rule may also
4044  * optionally be validated against existing flow rules and device resources.
4045  * This function has no effect on the target device.
4046  *
4047  * The returned value is guaranteed to remain valid only as long as no
4048  * successful calls to rte_flow_create() or rte_flow_destroy() are made in
4049  * the meantime and no device parameter affecting flow rules in any way are
4050  * modified, due to possible collisions or resource limitations (although in
4051  * such cases EINVAL should not be returned).
4052  *
4053  * @param port_id
4054  *   Port identifier of Ethernet device.
4055  * @param[in] attr
4056  *   Flow rule attributes.
4057  * @param[in] pattern
4058  *   Pattern specification (list terminated by the END pattern item).
4059  * @param[in] actions
4060  *   Associated actions (list terminated by the END action).
4061  * @param[out] error
4062  *   Perform verbose error reporting if not NULL. PMDs initialize this
4063  *   structure in case of error only.
4064  *
4065  * @return
4066  *   0 if flow rule is valid and can be created. A negative errno value
4067  *   otherwise (rte_errno is also set), the following errors are defined:
4068  *
4069  *   -ENOSYS: underlying device does not support this functionality.
4070  *
4071  *   -EIO: underlying device is removed.
4072  *
4073  *   -EINVAL: unknown or invalid rule specification.
4074  *
4075  *   -ENOTSUP: valid but unsupported rule specification (e.g. partial
4076  *   bit-masks are unsupported).
4077  *
4078  *   -EEXIST: collision with an existing rule. Only returned if device
4079  *   supports flow rule collision checking and there was a flow rule
4080  *   collision. Not receiving this return code is no guarantee that creating
4081  *   the rule will not fail due to a collision.
4082  *
4083  *   -ENOMEM: not enough memory to execute the function, or if the device
4084  *   supports resource validation, resource limitation on the device.
4085  *
4086  *   -EBUSY: action cannot be performed due to busy device resources, may
4087  *   succeed if the affected queues or even the entire port are in a stopped
4088  *   state (see rte_eth_dev_rx_queue_stop() and rte_eth_dev_stop()).
4089  */
4090 int
4091 rte_flow_validate(uint16_t port_id,
4092 		  const struct rte_flow_attr *attr,
4093 		  const struct rte_flow_item pattern[],
4094 		  const struct rte_flow_action actions[],
4095 		  struct rte_flow_error *error);
4096 
4097 /**
4098  * Create a flow rule on a given port.
4099  *
4100  * @param port_id
4101  *   Port identifier of Ethernet device.
4102  * @param[in] attr
4103  *   Flow rule attributes.
4104  * @param[in] pattern
4105  *   Pattern specification (list terminated by the END pattern item).
4106  * @param[in] actions
4107  *   Associated actions (list terminated by the END action).
4108  * @param[out] error
4109  *   Perform verbose error reporting if not NULL. PMDs initialize this
4110  *   structure in case of error only.
4111  *
4112  * @return
4113  *   A valid handle in case of success, NULL otherwise and rte_errno is set
4114  *   to the positive version of one of the error codes defined for
4115  *   rte_flow_validate().
4116  */
4117 struct rte_flow *
4118 rte_flow_create(uint16_t port_id,
4119 		const struct rte_flow_attr *attr,
4120 		const struct rte_flow_item pattern[],
4121 		const struct rte_flow_action actions[],
4122 		struct rte_flow_error *error);
4123 
4124 /**
4125  * Destroy a flow rule on a given port.
4126  *
4127  * Failure to destroy a flow rule handle may occur when other flow rules
4128  * depend on it, and destroying it would result in an inconsistent state.
4129  *
4130  * This function is only guaranteed to succeed if handles are destroyed in
4131  * reverse order of their creation.
4132  *
4133  * @param port_id
4134  *   Port identifier of Ethernet device.
4135  * @param flow
4136  *   Flow rule handle to destroy.
4137  * @param[out] error
4138  *   Perform verbose error reporting if not NULL. PMDs initialize this
4139  *   structure in case of error only.
4140  *
4141  * @return
4142  *   0 on success, a negative errno value otherwise and rte_errno is set.
4143  */
4144 int
4145 rte_flow_destroy(uint16_t port_id,
4146 		 struct rte_flow *flow,
4147 		 struct rte_flow_error *error);
4148 
4149 /**
4150  * Destroy all flow rules associated with a port.
4151  *
4152  * In the unlikely event of failure, handles are still considered destroyed
4153  * and no longer valid but the port must be assumed to be in an inconsistent
4154  * state.
4155  *
4156  * @param port_id
4157  *   Port identifier of Ethernet device.
4158  * @param[out] error
4159  *   Perform verbose error reporting if not NULL. PMDs initialize this
4160  *   structure in case of error only.
4161  *
4162  * @return
4163  *   0 on success, a negative errno value otherwise and rte_errno is set.
4164  */
4165 int
4166 rte_flow_flush(uint16_t port_id,
4167 	       struct rte_flow_error *error);
4168 
4169 /**
4170  * Query an existing flow rule.
4171  *
4172  * This function allows retrieving flow-specific data such as counters.
4173  * Data is gathered by special actions which must be present in the flow
4174  * rule definition.
4175  *
4176  * \see RTE_FLOW_ACTION_TYPE_COUNT
4177  *
4178  * @param port_id
4179  *   Port identifier of Ethernet device.
4180  * @param flow
4181  *   Flow rule handle to query.
4182  * @param action
4183  *   Action definition as defined in original flow rule.
4184  * @param[in, out] data
4185  *   Pointer to storage for the associated query data type.
4186  * @param[out] error
4187  *   Perform verbose error reporting if not NULL. PMDs initialize this
4188  *   structure in case of error only.
4189  *
4190  * @return
4191  *   0 on success, a negative errno value otherwise and rte_errno is set.
4192  */
4193 int
4194 rte_flow_query(uint16_t port_id,
4195 	       struct rte_flow *flow,
4196 	       const struct rte_flow_action *action,
4197 	       void *data,
4198 	       struct rte_flow_error *error);
4199 
4200 /**
4201  * Restrict ingress traffic to the defined flow rules.
4202  *
4203  * Isolated mode guarantees that all ingress traffic comes from defined flow
4204  * rules only (current and future).
4205  * When enabled with a bifurcated driver,
4206  * non-matched packets are routed to the kernel driver interface.
4207  * When disabled (the default),
4208  * there may be some default rules routing traffic to the DPDK port.
4209  *
4210  * Besides making ingress more deterministic, it allows PMDs to safely reuse
4211  * resources otherwise assigned to handle the remaining traffic, such as
4212  * global RSS configuration settings, VLAN filters, MAC address entries,
4213  * legacy filter API rules and so on in order to expand the set of possible
4214  * flow rule types.
4215  *
4216  * Calling this function as soon as possible after device initialization,
4217  * ideally before the first call to rte_eth_dev_configure(), is recommended
4218  * to avoid possible failures due to conflicting settings.
4219  *
4220  * Once effective, leaving isolated mode may not be possible depending on
4221  * PMD implementation.
4222  *
4223  * Additionally, the following functionality has no effect on the underlying
4224  * port and may return errors such as ENOTSUP ("not supported"):
4225  *
4226  * - Toggling promiscuous mode.
4227  * - Toggling allmulticast mode.
4228  * - Configuring MAC addresses.
4229  * - Configuring multicast addresses.
4230  * - Configuring VLAN filters.
4231  * - Configuring Rx filters through the legacy API (e.g. FDIR).
4232  * - Configuring global RSS settings.
4233  *
4234  * @param port_id
4235  *   Port identifier of Ethernet device.
4236  * @param set
4237  *   Nonzero to enter isolated mode, attempt to leave it otherwise.
4238  * @param[out] error
4239  *   Perform verbose error reporting if not NULL. PMDs initialize this
4240  *   structure in case of error only.
4241  *
4242  * @return
4243  *   0 on success, a negative errno value otherwise and rte_errno is set.
4244  */
4245 int
4246 rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error);
4247 
4248 /**
4249  * Initialize flow error structure.
4250  *
4251  * @param[out] error
4252  *   Pointer to flow error structure (may be NULL).
4253  * @param code
4254  *   Related error code (rte_errno).
4255  * @param type
4256  *   Cause field and error types.
4257  * @param cause
4258  *   Object responsible for the error.
4259  * @param message
4260  *   Human-readable error message.
4261  *
4262  * @return
4263  *   Negative error code (errno value) and rte_errno is set.
4264  */
4265 int
4266 rte_flow_error_set(struct rte_flow_error *error,
4267 		   int code,
4268 		   enum rte_flow_error_type type,
4269 		   const void *cause,
4270 		   const char *message);
4271 
4272 /**
4273  * @deprecated
4274  * @see rte_flow_copy()
4275  */
4276 struct rte_flow_desc {
4277 	size_t size; /**< Allocated space including data[]. */
4278 	struct rte_flow_attr attr; /**< Attributes. */
4279 	struct rte_flow_item *items; /**< Items. */
4280 	struct rte_flow_action *actions; /**< Actions. */
4281 	uint8_t data[]; /**< Storage for items/actions. */
4282 };
4283 
4284 /**
4285  * @deprecated
4286  * Copy an rte_flow rule description.
4287  *
4288  * This interface is kept for compatibility with older applications but is
4289  * implemented as a wrapper to rte_flow_conv(). It is deprecated due to its
4290  * lack of flexibility and reliance on a type unusable with C++ programs
4291  * (struct rte_flow_desc).
4292  *
4293  * @param[in] fd
4294  *   Flow rule description.
4295  * @param[in] len
4296  *   Total size of allocated data for the flow description.
4297  * @param[in] attr
4298  *   Flow rule attributes.
4299  * @param[in] items
4300  *   Pattern specification (list terminated by the END pattern item).
4301  * @param[in] actions
4302  *   Associated actions (list terminated by the END action).
4303  *
4304  * @return
4305  *   If len is greater or equal to the size of the flow, the total size of the
4306  *   flow description and its data.
4307  *   If len is lower than the size of the flow, the number of bytes that would
4308  *   have been written to desc had it been sufficient. Nothing is written.
4309  */
4310 __rte_deprecated
4311 size_t
4312 rte_flow_copy(struct rte_flow_desc *fd, size_t len,
4313 	      const struct rte_flow_attr *attr,
4314 	      const struct rte_flow_item *items,
4315 	      const struct rte_flow_action *actions);
4316 
4317 /**
4318  * Flow object conversion helper.
4319  *
4320  * This function performs conversion of various flow API objects to a
4321  * pre-allocated destination buffer. See enum rte_flow_conv_op for possible
4322  * operations and details about each of them.
4323  *
4324  * Since destination buffer must be large enough, it works in a manner
4325  * reminiscent of snprintf():
4326  *
4327  * - If @p size is 0, @p dst may be a NULL pointer, otherwise @p dst must be
4328  *   non-NULL.
4329  * - If positive, the returned value represents the number of bytes needed
4330  *   to store the conversion of @p src to @p dst according to @p op
4331  *   regardless of the @p size parameter.
4332  * - Since no more than @p size bytes can be written to @p dst, output is
4333  *   truncated and may be inconsistent when the returned value is larger
4334  *   than that.
4335  * - In case of conversion error, a negative error code is returned and
4336  *   @p dst contents are unspecified.
4337  *
4338  * @param op
4339  *   Operation to perform, related to the object type of @p dst.
4340  * @param[out] dst
4341  *   Destination buffer address. Must be suitably aligned by the caller.
4342  * @param size
4343  *   Destination buffer size in bytes.
4344  * @param[in] src
4345  *   Source object to copy. Depending on @p op, its type may differ from
4346  *   that of @p dst.
4347  * @param[out] error
4348  *   Perform verbose error reporting if not NULL. Initialized in case of
4349  *   error only.
4350  *
4351  * @return
4352  *   The number of bytes required to convert @p src to @p dst on success, a
4353  *   negative errno value otherwise and rte_errno is set.
4354  *
4355  * @see rte_flow_conv_op
4356  */
4357 __rte_experimental
4358 int
4359 rte_flow_conv(enum rte_flow_conv_op op,
4360 	      void *dst,
4361 	      size_t size,
4362 	      const void *src,
4363 	      struct rte_flow_error *error);
4364 
4365 /**
4366  * Get aged-out flows of a given port.
4367  *
4368  * RTE_ETH_EVENT_FLOW_AGED event will be triggered when at least one new aged
4369  * out flow was detected after the last call to rte_flow_get_aged_flows.
4370  * This function can be called to get the aged flows asynchronously from the
4371  * event callback or synchronously regardless the event.
4372  * This is not safe to call rte_flow_get_aged_flows function with other flow
4373  * functions from multiple threads simultaneously.
4374  *
4375  * @param port_id
4376  *   Port identifier of Ethernet device.
4377  * @param[in, out] contexts
4378  *   The address of an array of pointers to the aged-out flows contexts.
4379  * @param[in] nb_contexts
4380  *   The length of context array pointers.
4381  * @param[out] error
4382  *   Perform verbose error reporting if not NULL. Initialized in case of
4383  *   error only.
4384  *
4385  * @return
4386  *   if nb_contexts is 0, return the amount of all aged contexts.
4387  *   if nb_contexts is not 0 , return the amount of aged flows reported
4388  *   in the context array, otherwise negative errno value.
4389  *
4390  * @see rte_flow_action_age
4391  * @see RTE_ETH_EVENT_FLOW_AGED
4392  */
4393 __rte_experimental
4394 int
4395 rte_flow_get_aged_flows(uint16_t port_id, void **contexts,
4396 			uint32_t nb_contexts, struct rte_flow_error *error);
4397 
4398 /**
4399  * @warning
4400  * @b EXPERIMENTAL: this API may change without prior notice.
4401  *
4402  * Get aged-out flows of a given port on the given flow queue.
4403  *
4404  * If application configure port attribute with RTE_FLOW_PORT_FLAG_STRICT_QUEUE,
4405  * there is no RTE_ETH_EVENT_FLOW_AGED event and this function must be called to
4406  * get the aged flows synchronously.
4407  *
4408  * If application configure port attribute without
4409  * RTE_FLOW_PORT_FLAG_STRICT_QUEUE, RTE_ETH_EVENT_FLOW_AGED event will be
4410  * triggered at least one new aged out flow was detected on any flow queue after
4411  * the last call to rte_flow_get_q_aged_flows.
4412  * In addition, the @p queue_id will be ignored.
4413  * This function can be called to get the aged flows asynchronously from the
4414  * event callback or synchronously regardless the event.
4415  *
4416  * @param[in] port_id
4417  *   Port identifier of Ethernet device.
4418  * @param[in] queue_id
4419  *   Flow queue to query. Ignored when RTE_FLOW_PORT_FLAG_STRICT_QUEUE not set.
4420  * @param[in, out] contexts
4421  *   The address of an array of pointers to the aged-out flows contexts.
4422  * @param[in] nb_contexts
4423  *   The length of context array pointers.
4424  * @param[out] error
4425  *   Perform verbose error reporting if not NULL. Initialized in case of
4426  *   error only.
4427  *
4428  * @return
4429  *   if nb_contexts is 0, return the amount of all aged contexts.
4430  *   if nb_contexts is not 0 , return the amount of aged flows reported
4431  *   in the context array, otherwise negative errno value.
4432  *
4433  * @see rte_flow_action_age
4434  * @see RTE_ETH_EVENT_FLOW_AGED
4435  * @see rte_flow_port_flag
4436  */
4437 __rte_experimental
4438 int
4439 rte_flow_get_q_aged_flows(uint16_t port_id, uint32_t queue_id, void **contexts,
4440 			  uint32_t nb_contexts, struct rte_flow_error *error);
4441 
4442 /**
4443  * Specify indirect action object configuration
4444  */
4445 struct rte_flow_indir_action_conf {
4446 	/**
4447 	 * Flow direction for the indirect action configuration.
4448 	 *
4449 	 * Action should be valid at least for one flow direction,
4450 	 * otherwise it is invalid for both ingress and egress rules.
4451 	 */
4452 	/** Action valid for rules applied to ingress traffic. */
4453 	uint32_t ingress:1;
4454 	/** Action valid for rules applied to egress traffic. */
4455 	uint32_t egress:1;
4456 	/**
4457 	 * When set to 1, indicates that the action is valid for
4458 	 * transfer traffic; otherwise, for non-transfer traffic.
4459 	 */
4460 	uint32_t transfer:1;
4461 };
4462 
4463 /**
4464  * @warning
4465  * @b EXPERIMENTAL: this API may change without prior notice.
4466  *
4467  * Create an indirect action object that can be used in flow rules
4468  * via its handle.
4469  * The created object handle has single state and configuration
4470  * across all the flow rules using it.
4471  *
4472  * @param[in] port_id
4473  *    The port identifier of the Ethernet device.
4474  * @param[in] conf
4475  *   Action configuration for the indirect action object creation.
4476  * @param[in] action
4477  *   Specific configuration of the indirect action object.
4478  * @param[out] error
4479  *   Perform verbose error reporting if not NULL. PMDs initialize this
4480  *   structure in case of error only.
4481  * @return
4482  *   A valid handle in case of success, NULL otherwise and rte_errno is set
4483  *   to one of the error codes defined:
4484  *   - (ENODEV) if *port_id* invalid.
4485  *   - (ENOSYS) if underlying device does not support this functionality.
4486  *   - (EIO) if underlying device is removed.
4487  *   - (EINVAL) if *action* invalid.
4488  *   - (ENOTSUP) if *action* valid but unsupported.
4489  */
4490 __rte_experimental
4491 struct rte_flow_action_handle *
4492 rte_flow_action_handle_create(uint16_t port_id,
4493 			      const struct rte_flow_indir_action_conf *conf,
4494 			      const struct rte_flow_action *action,
4495 			      struct rte_flow_error *error);
4496 
4497 /**
4498  * @warning
4499  * @b EXPERIMENTAL: this API may change without prior notice.
4500  *
4501  * Destroy indirect action by handle.
4502  *
4503  * @param[in] port_id
4504  *    The port identifier of the Ethernet device.
4505  * @param[in] handle
4506  *   Handle for the indirect action object to be destroyed.
4507  * @param[out] error
4508  *   Perform verbose error reporting if not NULL. PMDs initialize this
4509  *   structure in case of error only.
4510  * @return
4511  *   - (0) if success.
4512  *   - (-ENODEV) if *port_id* invalid.
4513  *   - (-ENOSYS) if underlying device does not support this functionality.
4514  *   - (-EIO) if underlying device is removed.
4515  *   - (-ENOENT) if action pointed by *action* handle was not found.
4516  *   - (-EBUSY) if action pointed by *action* handle still used by some rules
4517  *   rte_errno is also set.
4518  */
4519 __rte_experimental
4520 int
4521 rte_flow_action_handle_destroy(uint16_t port_id,
4522 			       struct rte_flow_action_handle *handle,
4523 			       struct rte_flow_error *error);
4524 
4525 /**
4526  * @warning
4527  * @b EXPERIMENTAL: this API may change without prior notice.
4528  *
4529  * Update in-place the action configuration and / or state pointed
4530  * by action *handle* with the configuration provided as *update* argument.
4531  * The update of the action configuration effects all flow rules reusing
4532  * the action via *handle*.
4533  * The update general pointer provides the ability of partial updating.
4534  *
4535  * @param[in] port_id
4536  *    The port identifier of the Ethernet device.
4537  * @param[in] handle
4538  *   Handle for the indirect action object to be updated.
4539  * @param[in] update
4540  *   Update profile specification used to modify the action pointed by handle.
4541  *   *update* could be with the same type of the immediate action corresponding
4542  *   to the *handle* argument when creating, or a wrapper structure includes
4543  *   action configuration to be updated and bit fields to indicate the member
4544  *   of fields inside the action to update.
4545  * @param[out] error
4546  *   Perform verbose error reporting if not NULL. PMDs initialize this
4547  *   structure in case of error only.
4548  * @return
4549  *   - (0) if success.
4550  *   - (-ENODEV) if *port_id* invalid.
4551  *   - (-ENOSYS) if underlying device does not support this functionality.
4552  *   - (-EIO) if underlying device is removed.
4553  *   - (-EINVAL) if *update* invalid.
4554  *   - (-ENOTSUP) if *update* valid but unsupported.
4555  *   - (-ENOENT) if indirect action object pointed by *handle* was not found.
4556  *   rte_errno is also set.
4557  */
4558 __rte_experimental
4559 int
4560 rte_flow_action_handle_update(uint16_t port_id,
4561 			      struct rte_flow_action_handle *handle,
4562 			      const void *update,
4563 			      struct rte_flow_error *error);
4564 
4565 /**
4566  * @warning
4567  * @b EXPERIMENTAL: this API may change without prior notice.
4568  *
4569  * Query the direct action by corresponding indirect action object handle.
4570  *
4571  * Retrieve action-specific data such as counters.
4572  * Data is gathered by special action which may be present/referenced in
4573  * more than one flow rule definition.
4574  *
4575  * @see RTE_FLOW_ACTION_TYPE_COUNT
4576  *
4577  * @param port_id
4578  *   Port identifier of Ethernet device.
4579  * @param[in] handle
4580  *   Handle for the action object to query.
4581  * @param[in, out] data
4582  *   Pointer to storage for the associated query data type.
4583  * @param[out] error
4584  *   Perform verbose error reporting if not NULL. PMDs initialize this
4585  *   structure in case of error only.
4586  *
4587  * @return
4588  *   0 on success, a negative errno value otherwise and rte_errno is set.
4589  */
4590 __rte_experimental
4591 int
4592 rte_flow_action_handle_query(uint16_t port_id,
4593 			     const struct rte_flow_action_handle *handle,
4594 			     void *data, struct rte_flow_error *error);
4595 
4596 /* Tunnel has a type and the key information. */
4597 struct rte_flow_tunnel {
4598 	/**
4599 	 * Tunnel type, for example RTE_FLOW_ITEM_TYPE_VXLAN,
4600 	 * RTE_FLOW_ITEM_TYPE_NVGRE etc.
4601 	 */
4602 	enum rte_flow_item_type	type;
4603 	uint64_t tun_id; /**< Tunnel identification. */
4604 
4605 	RTE_STD_C11
4606 	union {
4607 		struct {
4608 			rte_be32_t src_addr; /**< IPv4 source address. */
4609 			rte_be32_t dst_addr; /**< IPv4 destination address. */
4610 		} ipv4;
4611 		struct {
4612 			uint8_t src_addr[16]; /**< IPv6 source address. */
4613 			uint8_t dst_addr[16]; /**< IPv6 destination address. */
4614 		} ipv6;
4615 	};
4616 	rte_be16_t tp_src; /**< Tunnel port source. */
4617 	rte_be16_t tp_dst; /**< Tunnel port destination. */
4618 	uint16_t   tun_flags; /**< Tunnel flags. */
4619 
4620 	bool       is_ipv6; /**< True for valid IPv6 fields. Otherwise IPv4. */
4621 
4622 	/**
4623 	 * the following members are required to restore packet
4624 	 * after miss
4625 	 */
4626 	uint8_t    tos; /**< TOS for IPv4, TC for IPv6. */
4627 	uint8_t    ttl; /**< TTL for IPv4, HL for IPv6. */
4628 	uint32_t label; /**< Flow Label for IPv6. */
4629 };
4630 
4631 /**
4632  * Indicate that the packet has a tunnel.
4633  */
4634 #define RTE_FLOW_RESTORE_INFO_TUNNEL RTE_BIT64(0)
4635 
4636 /**
4637  * Indicate that the packet has a non decapsulated tunnel header.
4638  */
4639 #define RTE_FLOW_RESTORE_INFO_ENCAPSULATED RTE_BIT64(1)
4640 
4641 /**
4642  * Indicate that the packet has a group_id.
4643  */
4644 #define RTE_FLOW_RESTORE_INFO_GROUP_ID RTE_BIT64(2)
4645 
4646 /**
4647  * Restore information structure to communicate the current packet processing
4648  * state when some of the processing pipeline is done in hardware and should
4649  * continue in software.
4650  */
4651 struct rte_flow_restore_info {
4652 	/**
4653 	 * Bitwise flags (RTE_FLOW_RESTORE_INFO_*) to indicate validation of
4654 	 * other fields in struct rte_flow_restore_info.
4655 	 */
4656 	uint64_t flags;
4657 	uint32_t group_id; /**< Group ID where packed missed */
4658 	struct rte_flow_tunnel tunnel; /**< Tunnel information. */
4659 };
4660 
4661 /**
4662  * Allocate an array of actions to be used in rte_flow_create, to implement
4663  * tunnel-decap-set for the given tunnel.
4664  * Sample usage:
4665  *   actions vxlan_decap / tunnel-decap-set(tunnel properties) /
4666  *            jump group 0 / end
4667  *
4668  * @param port_id
4669  *   Port identifier of Ethernet device.
4670  * @param[in] tunnel
4671  *   Tunnel properties.
4672  * @param[out] actions
4673  *   Array of actions to be allocated by the PMD. This array should be
4674  *   concatenated with the actions array provided to rte_flow_create.
4675  * @param[out] num_of_actions
4676  *   Number of actions allocated.
4677  * @param[out] error
4678  *   Perform verbose error reporting if not NULL. PMDs initialize this
4679  *   structure in case of error only.
4680  *
4681  * @return
4682  *   0 on success, a negative errno value otherwise and rte_errno is set.
4683  */
4684 __rte_experimental
4685 int
4686 rte_flow_tunnel_decap_set(uint16_t port_id,
4687 			  struct rte_flow_tunnel *tunnel,
4688 			  struct rte_flow_action **actions,
4689 			  uint32_t *num_of_actions,
4690 			  struct rte_flow_error *error);
4691 
4692 /**
4693  * Allocate an array of items to be used in rte_flow_create, to implement
4694  * tunnel-match for the given tunnel.
4695  * Sample usage:
4696  *   pattern tunnel-match(tunnel properties) / outer-header-matches /
4697  *           inner-header-matches / end
4698  *
4699  * @param port_id
4700  *   Port identifier of Ethernet device.
4701  * @param[in] tunnel
4702  *   Tunnel properties.
4703  * @param[out] items
4704  *   Array of items to be allocated by the PMD. This array should be
4705  *   concatenated with the items array provided to rte_flow_create.
4706  * @param[out] num_of_items
4707  *   Number of items allocated.
4708  * @param[out] error
4709  *   Perform verbose error reporting if not NULL. PMDs initialize this
4710  *   structure in case of error only.
4711  *
4712  * @return
4713  *   0 on success, a negative errno value otherwise and rte_errno is set.
4714  */
4715 __rte_experimental
4716 int
4717 rte_flow_tunnel_match(uint16_t port_id,
4718 		      struct rte_flow_tunnel *tunnel,
4719 		      struct rte_flow_item **items,
4720 		      uint32_t *num_of_items,
4721 		      struct rte_flow_error *error);
4722 
4723 /**
4724  * Populate the current packet processing state, if exists, for the given mbuf.
4725  *
4726  * One should negotiate tunnel metadata delivery from the NIC to the HW.
4727  * @see rte_eth_rx_metadata_negotiate()
4728  * @see RTE_ETH_RX_METADATA_TUNNEL_ID
4729  *
4730  * @param port_id
4731  *   Port identifier of Ethernet device.
4732  * @param[in] m
4733  *   Mbuf struct.
4734  * @param[out] info
4735  *   Restore information. Upon success contains the HW state.
4736  * @param[out] error
4737  *   Perform verbose error reporting if not NULL. PMDs initialize this
4738  *   structure in case of error only.
4739  *
4740  * @return
4741  *   0 on success, a negative errno value otherwise and rte_errno is set.
4742  */
4743 __rte_experimental
4744 int
4745 rte_flow_get_restore_info(uint16_t port_id,
4746 			  struct rte_mbuf *m,
4747 			  struct rte_flow_restore_info *info,
4748 			  struct rte_flow_error *error);
4749 
4750 /**
4751  * Release the action array as allocated by rte_flow_tunnel_decap_set.
4752  *
4753  * @param port_id
4754  *   Port identifier of Ethernet device.
4755  * @param[in] actions
4756  *   Array of actions to be released.
4757  * @param[in] num_of_actions
4758  *   Number of elements in actions array.
4759  * @param[out] error
4760  *   Perform verbose error reporting if not NULL. PMDs initialize this
4761  *   structure in case of error only.
4762  *
4763  * @return
4764  *   0 on success, a negative errno value otherwise and rte_errno is set.
4765  */
4766 __rte_experimental
4767 int
4768 rte_flow_tunnel_action_decap_release(uint16_t port_id,
4769 				     struct rte_flow_action *actions,
4770 				     uint32_t num_of_actions,
4771 				     struct rte_flow_error *error);
4772 
4773 /**
4774  * Release the item array as allocated by rte_flow_tunnel_match.
4775  *
4776  * @param port_id
4777  *   Port identifier of Ethernet device.
4778  * @param[in] items
4779  *   Array of items to be released.
4780  * @param[in] num_of_items
4781  *   Number of elements in item array.
4782  * @param[out] error
4783  *   Perform verbose error reporting if not NULL. PMDs initialize this
4784  *   structure in case of error only.
4785  *
4786  * @return
4787  *   0 on success, a negative errno value otherwise and rte_errno is set.
4788  */
4789 __rte_experimental
4790 int
4791 rte_flow_tunnel_item_release(uint16_t port_id,
4792 			     struct rte_flow_item *items,
4793 			     uint32_t num_of_items,
4794 			     struct rte_flow_error *error);
4795 
4796 /**
4797  * Get a proxy port to manage "transfer" flows.
4798  *
4799  * Managing "transfer" flows requires that the user communicate them
4800  * via a port which has the privilege to control the embedded switch.
4801  * For some vendors, all ports in a given switching domain have
4802  * this privilege. For other vendors, it's only one port.
4803  *
4804  * This API indicates such a privileged port (a "proxy")
4805  * for a given port in the same switching domain.
4806  *
4807  * @note
4808  *   If the PMD serving @p port_id doesn't have the corresponding method
4809  *   implemented, the API will return @p port_id via @p proxy_port_id.
4810  *
4811  * @param port_id
4812  *   Indicates the port to get a "proxy" for
4813  * @param[out] proxy_port_id
4814  *   Indicates the "proxy" port
4815  * @param[out] error
4816  *   If not NULL, allows the PMD to provide verbose report in case of error
4817  *
4818  * @return
4819  *   0 on success, a negative error code otherwise
4820  */
4821 int
4822 rte_flow_pick_transfer_proxy(uint16_t port_id, uint16_t *proxy_port_id,
4823 			     struct rte_flow_error *error);
4824 
4825 /**
4826  * @warning
4827  * @b EXPERIMENTAL: this API may change without prior notice.
4828  *
4829  * Create the flex item with specified configuration over
4830  * the Ethernet device.
4831  *
4832  * @param port_id
4833  *   Port identifier of Ethernet device.
4834  * @param[in] conf
4835  *   Item configuration.
4836  * @param[out] error
4837  *   Perform verbose error reporting if not NULL. PMDs initialize this
4838  *   structure in case of error only.
4839  *
4840  * @return
4841  *   Non-NULL opaque pointer on success, NULL otherwise and rte_errno is set.
4842  */
4843 __rte_experimental
4844 struct rte_flow_item_flex_handle *
4845 rte_flow_flex_item_create(uint16_t port_id,
4846 			  const struct rte_flow_item_flex_conf *conf,
4847 			  struct rte_flow_error *error);
4848 
4849 /**
4850  * Release the flex item on the specified Ethernet device.
4851  *
4852  * @param port_id
4853  *   Port identifier of Ethernet device.
4854  * @param[in] handle
4855  *   Handle of the item existing on the specified device.
4856  * @param[out] error
4857  *   Perform verbose error reporting if not NULL. PMDs initialize this
4858  *   structure in case of error only.
4859  *
4860  * @return
4861  *   0 on success, a negative errno value otherwise and rte_errno is set.
4862  */
4863 __rte_experimental
4864 int
4865 rte_flow_flex_item_release(uint16_t port_id,
4866 			   const struct rte_flow_item_flex_handle *handle,
4867 			   struct rte_flow_error *error);
4868 
4869 /**
4870  * Indicate all operations for a given flow rule will _strictly_
4871  * happen on the same queue (create/destroy/query/update).
4872  */
4873 #define RTE_FLOW_PORT_FLAG_STRICT_QUEUE RTE_BIT32(0)
4874 
4875 /**
4876  * @warning
4877  * @b EXPERIMENTAL: this API may change without prior notice.
4878  *
4879  * Information about flow engine resources.
4880  * The zero value means a resource is not supported.
4881  *
4882  */
4883 struct rte_flow_port_info {
4884 	/**
4885 	 * Maximum number of queues for asynchronous operations.
4886 	 */
4887 	uint32_t max_nb_queues;
4888 	/**
4889 	 * Maximum number of counters.
4890 	 * @see RTE_FLOW_ACTION_TYPE_COUNT
4891 	 */
4892 	uint32_t max_nb_counters;
4893 	/**
4894 	 * Maximum number of aging objects.
4895 	 * @see RTE_FLOW_ACTION_TYPE_AGE
4896 	 */
4897 	uint32_t max_nb_aging_objects;
4898 	/**
4899 	 * Maximum number traffic meters.
4900 	 * @see RTE_FLOW_ACTION_TYPE_METER
4901 	 */
4902 	uint32_t max_nb_meters;
4903 	/**
4904 	 * Maximum number connection trackings.
4905 	 * @see RTE_FLOW_ACTION_TYPE_CONNTRACK
4906 	 */
4907 	uint32_t max_nb_conn_tracks;
4908 	/**
4909 	 * Port supported flags (RTE_FLOW_PORT_FLAG_*).
4910 	 */
4911 	uint32_t supported_flags;
4912 };
4913 
4914 /**
4915  * @warning
4916  * @b EXPERIMENTAL: this API may change without prior notice.
4917  *
4918  * Information about flow engine asynchronous queues.
4919  * The value only valid if @p port_attr.max_nb_queues is not zero.
4920  *
4921  */
4922 struct rte_flow_queue_info {
4923 	/**
4924 	 * Maximum number of operations a queue can hold.
4925 	 */
4926 	uint32_t max_size;
4927 };
4928 
4929 /**
4930  * @warning
4931  * @b EXPERIMENTAL: this API may change without prior notice.
4932  *
4933  * Get information about flow engine resources.
4934  *
4935  * @param port_id
4936  *   Port identifier of Ethernet device.
4937  * @param[out] port_info
4938  *   A pointer to a structure of type *rte_flow_port_info*
4939  *   to be filled with the resources information of the port.
4940  * @param[out] queue_info
4941  *   A pointer to a structure of type *rte_flow_queue_info*
4942  *   to be filled with the asynchronous queues information.
4943  * @param[out] error
4944  *   Perform verbose error reporting if not NULL.
4945  *   PMDs initialize this structure in case of error only.
4946  *
4947  * @return
4948  *   0 on success, a negative errno value otherwise and rte_errno is set.
4949  */
4950 __rte_experimental
4951 int
4952 rte_flow_info_get(uint16_t port_id,
4953 		  struct rte_flow_port_info *port_info,
4954 		  struct rte_flow_queue_info *queue_info,
4955 		  struct rte_flow_error *error);
4956 
4957 /**
4958  * @warning
4959  * @b EXPERIMENTAL: this API may change without prior notice.
4960  *
4961  * Flow engine resources settings.
4962  * The zero value means on demand resource allocations only.
4963  *
4964  */
4965 struct rte_flow_port_attr {
4966 	/**
4967 	 * Number of counters to configure.
4968 	 * @see RTE_FLOW_ACTION_TYPE_COUNT
4969 	 */
4970 	uint32_t nb_counters;
4971 	/**
4972 	 * Number of aging objects to configure.
4973 	 * @see RTE_FLOW_ACTION_TYPE_AGE
4974 	 */
4975 	uint32_t nb_aging_objects;
4976 	/**
4977 	 * Number of traffic meters to configure.
4978 	 * @see RTE_FLOW_ACTION_TYPE_METER
4979 	 */
4980 	uint32_t nb_meters;
4981 	/**
4982 	 * Number of connection trackings to configure.
4983 	 * @see RTE_FLOW_ACTION_TYPE_CONNTRACK
4984 	 */
4985 	uint32_t nb_conn_tracks;
4986 	/**
4987 	 * Port flags (RTE_FLOW_PORT_FLAG_*).
4988 	 */
4989 	uint32_t flags;
4990 };
4991 
4992 /**
4993  * @warning
4994  * @b EXPERIMENTAL: this API may change without prior notice.
4995  *
4996  * Flow engine asynchronous queues settings.
4997  * The value means default value picked by PMD.
4998  *
4999  */
5000 struct rte_flow_queue_attr {
5001 	/**
5002 	 * Number of flow rule operations a queue can hold.
5003 	 */
5004 	uint32_t size;
5005 };
5006 
5007 /**
5008  * @warning
5009  * @b EXPERIMENTAL: this API may change without prior notice.
5010  *
5011  * Configure the port's flow API engine.
5012  *
5013  * This API can only be invoked before the application
5014  * starts using the rest of the flow library functions.
5015  *
5016  * The API can be invoked multiple times to change the settings.
5017  * The port, however, may reject changes and keep the old config.
5018  *
5019  * Parameters in configuration attributes must not exceed
5020  * numbers of resources returned by the rte_flow_info_get API.
5021  *
5022  * @param port_id
5023  *   Port identifier of Ethernet device.
5024  * @param[in] port_attr
5025  *   Port configuration attributes.
5026  * @param[in] nb_queue
5027  *   Number of flow queues to be configured.
5028  * @param[in] queue_attr
5029  *   Array that holds attributes for each flow queue.
5030  *   Number of elements is set in @p port_attr.nb_queues.
5031  * @param[out] error
5032  *   Perform verbose error reporting if not NULL.
5033  *   PMDs initialize this structure in case of error only.
5034  *
5035  * @return
5036  *   0 on success, a negative errno value otherwise and rte_errno is set.
5037  */
5038 __rte_experimental
5039 int
5040 rte_flow_configure(uint16_t port_id,
5041 		   const struct rte_flow_port_attr *port_attr,
5042 		   uint16_t nb_queue,
5043 		   const struct rte_flow_queue_attr *queue_attr[],
5044 		   struct rte_flow_error *error);
5045 
5046 /**
5047  * Opaque type returned after successful creation of pattern template.
5048  * This handle can be used to manage the created pattern template.
5049  */
5050 struct rte_flow_pattern_template;
5051 
5052 /**
5053  * @warning
5054  * @b EXPERIMENTAL: this API may change without prior notice.
5055  *
5056  * Flow pattern template attributes.
5057  */
5058 __extension__
5059 struct rte_flow_pattern_template_attr {
5060 	/**
5061 	 * Relaxed matching policy.
5062 	 * - If 1, matching is performed only on items with the mask member set
5063 	 * and matching on protocol layers specified without any masks is skipped.
5064 	 * - If 0, matching on protocol layers specified without any masks is done
5065 	 * as well. This is the standard behaviour of Flow API now.
5066 	 */
5067 	uint32_t relaxed_matching:1;
5068 	/**
5069 	 * Flow direction for the pattern template.
5070 	 * At least one direction must be specified.
5071 	 */
5072 	/** Pattern valid for rules applied to ingress traffic. */
5073 	uint32_t ingress:1;
5074 	/** Pattern valid for rules applied to egress traffic. */
5075 	uint32_t egress:1;
5076 	/** Pattern valid for rules applied to transfer traffic. */
5077 	uint32_t transfer:1;
5078 };
5079 
5080 /**
5081  * @warning
5082  * @b EXPERIMENTAL: this API may change without prior notice.
5083  *
5084  * Create flow pattern template.
5085  *
5086  * The pattern template defines common matching fields without values.
5087  * For example, matching on 5 tuple TCP flow, the template will be
5088  * eth(null) + IPv4(source + dest) + TCP(s_port + d_port),
5089  * while values for each rule will be set during the flow rule creation.
5090  * The number and order of items in the template must be the same
5091  * at the rule creation.
5092  *
5093  * @param port_id
5094  *   Port identifier of Ethernet device.
5095  * @param[in] template_attr
5096  *   Pattern template attributes.
5097  * @param[in] pattern
5098  *   Pattern specification (list terminated by the END pattern item).
5099  *   The spec member of an item is not used unless the end member is used.
5100  * @param[out] error
5101  *   Perform verbose error reporting if not NULL.
5102  *   PMDs initialize this structure in case of error only.
5103  *
5104  * @return
5105  *   Handle on success, NULL otherwise and rte_errno is set.
5106  */
5107 __rte_experimental
5108 struct rte_flow_pattern_template *
5109 rte_flow_pattern_template_create(uint16_t port_id,
5110 		const struct rte_flow_pattern_template_attr *template_attr,
5111 		const struct rte_flow_item pattern[],
5112 		struct rte_flow_error *error);
5113 
5114 /**
5115  * @warning
5116  * @b EXPERIMENTAL: this API may change without prior notice.
5117  *
5118  * Destroy flow pattern template.
5119  *
5120  * This function may be called only when
5121  * there are no more tables referencing this template.
5122  *
5123  * @param port_id
5124  *   Port identifier of Ethernet device.
5125  * @param[in] pattern_template
5126  *   Handle of the template to be destroyed.
5127  * @param[out] error
5128  *   Perform verbose error reporting if not NULL.
5129  *   PMDs initialize this structure in case of error only.
5130  *
5131  * @return
5132  *   0 on success, a negative errno value otherwise and rte_errno is set.
5133  */
5134 __rte_experimental
5135 int
5136 rte_flow_pattern_template_destroy(uint16_t port_id,
5137 		struct rte_flow_pattern_template *pattern_template,
5138 		struct rte_flow_error *error);
5139 
5140 /**
5141  * Opaque type returned after successful creation of actions template.
5142  * This handle can be used to manage the created actions template.
5143  */
5144 struct rte_flow_actions_template;
5145 
5146 /**
5147  * @warning
5148  * @b EXPERIMENTAL: this API may change without prior notice.
5149  *
5150  * Flow actions template attributes.
5151  */
5152 __extension__
5153 struct rte_flow_actions_template_attr {
5154 	/**
5155 	 * Flow direction for the actions template.
5156 	 * At least one direction must be specified.
5157 	 */
5158 	/** Action valid for rules applied to ingress traffic. */
5159 	uint32_t ingress:1;
5160 	/** Action valid for rules applied to egress traffic. */
5161 	uint32_t egress:1;
5162 	/** Action valid for rules applied to transfer traffic. */
5163 	uint32_t transfer:1;
5164 };
5165 
5166 /**
5167  * @warning
5168  * @b EXPERIMENTAL: this API may change without prior notice.
5169  *
5170  * Create flow actions template.
5171  *
5172  * The actions template holds a list of action types without values.
5173  * For example, the template to change TCP ports is TCP(s_port + d_port),
5174  * while values for each rule will be set during the flow rule creation.
5175  * The number and order of actions in the template must be the same
5176  * at the rule creation.
5177  *
5178  * @param port_id
5179  *   Port identifier of Ethernet device.
5180  * @param[in] template_attr
5181  *   Template attributes.
5182  * @param[in] actions
5183  *   Associated actions (list terminated by the END action).
5184  *   The spec member is only used if @p masks spec is non-zero.
5185  * @param[in] masks
5186  *   List of actions that marks which of the action's member is constant.
5187  *   A mask has the same format as the corresponding action.
5188  *   If the action field in @p masks is not 0,
5189  *   the corresponding value in an action from @p actions will be the part
5190  *   of the template and used in all flow rules.
5191  *   The order of actions in @p masks is the same as in @p actions.
5192  *   In case of indirect actions present in @p actions,
5193  *   the actual action type should be present in @p mask.
5194  * @param[out] error
5195  *   Perform verbose error reporting if not NULL.
5196  *   PMDs initialize this structure in case of error only.
5197  *
5198  * @return
5199  *   Handle on success, NULL otherwise and rte_errno is set.
5200  */
5201 __rte_experimental
5202 struct rte_flow_actions_template *
5203 rte_flow_actions_template_create(uint16_t port_id,
5204 		const struct rte_flow_actions_template_attr *template_attr,
5205 		const struct rte_flow_action actions[],
5206 		const struct rte_flow_action masks[],
5207 		struct rte_flow_error *error);
5208 
5209 /**
5210  * @warning
5211  * @b EXPERIMENTAL: this API may change without prior notice.
5212  *
5213  * Destroy flow actions template.
5214  *
5215  * This function may be called only when
5216  * there are no more tables referencing this template.
5217  *
5218  * @param port_id
5219  *   Port identifier of Ethernet device.
5220  * @param[in] actions_template
5221  *   Handle to the template to be destroyed.
5222  * @param[out] error
5223  *   Perform verbose error reporting if not NULL.
5224  *   PMDs initialize this structure in case of error only.
5225  *
5226  * @return
5227  *   0 on success, a negative errno value otherwise and rte_errno is set.
5228  */
5229 __rte_experimental
5230 int
5231 rte_flow_actions_template_destroy(uint16_t port_id,
5232 		struct rte_flow_actions_template *actions_template,
5233 		struct rte_flow_error *error);
5234 
5235 /**
5236  * Opaque type returned after successful creation of a template table.
5237  * This handle can be used to manage the created template table.
5238  */
5239 struct rte_flow_template_table;
5240 
5241 /**@{@name Flags for template table attribute.
5242  * Each bit is an optional hint for table specialization,
5243  * offering a potential optimization at driver layer.
5244  * The driver can ignore the hints silently.
5245  * The hints do not replace any matching criteria.
5246  */
5247 /**
5248  * Specialize table for transfer flows which come only from wire.
5249  * It allows PMD not to allocate resources for non-wire originated traffic.
5250  * This bit is not a matching criteria, just an optimization hint.
5251  * Flow rules which match non-wire originated traffic will be missed
5252  * if the hint is supported.
5253  */
5254 #define RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_WIRE_ORIG RTE_BIT32(0)
5255 /**
5256  * Specialize table for transfer flows which come only from vport (e.g. VF, SF).
5257  * It allows PMD not to allocate resources for non-vport originated traffic.
5258  * This bit is not a matching criteria, just an optimization hint.
5259  * Flow rules which match non-vport originated traffic will be missed
5260  * if the hint is supported.
5261  */
5262 #define RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_VPORT_ORIG RTE_BIT32(1)
5263 /**@}*/
5264 
5265 /**
5266  * @warning
5267  * @b EXPERIMENTAL: this API may change without prior notice.
5268  *
5269  * Table attributes.
5270  */
5271 struct rte_flow_template_table_attr {
5272 	/**
5273 	 * Flow attributes to be used in each rule generated from this table.
5274 	 */
5275 	struct rte_flow_attr flow_attr;
5276 	/**
5277 	 * Maximum number of flow rules that this table holds.
5278 	 */
5279 	uint32_t nb_flows;
5280 	/**
5281 	 * Optional hint flags for driver optimization.
5282 	 * The effect may vary in the different drivers.
5283 	 * The functionality must not rely on the hints.
5284 	 * Value is composed with RTE_FLOW_TABLE_SPECIALIZE_* based on application
5285 	 * design choices.
5286 	 * Misused hints may mislead the driver, it may result in an undefined behavior.
5287 	 */
5288 	uint32_t specialize;
5289 };
5290 
5291 /**
5292  * @warning
5293  * @b EXPERIMENTAL: this API may change without prior notice.
5294  *
5295  * Create flow template table.
5296  *
5297  * A template table consists of multiple pattern templates and actions
5298  * templates associated with a single set of rule attributes (group ID,
5299  * priority and traffic direction).
5300  *
5301  * Each rule is free to use any combination of pattern and actions templates
5302  * and specify particular values for items and actions it would like to change.
5303  *
5304  * @param port_id
5305  *   Port identifier of Ethernet device.
5306  * @param[in] table_attr
5307  *   Template table attributes.
5308  * @param[in] pattern_templates
5309  *   Array of pattern templates to be used in this table.
5310  * @param[in] nb_pattern_templates
5311  *   The number of pattern templates in the pattern_templates array.
5312  * @param[in] actions_templates
5313  *   Array of actions templates to be used in this table.
5314  * @param[in] nb_actions_templates
5315  *   The number of actions templates in the actions_templates array.
5316  * @param[out] error
5317  *   Perform verbose error reporting if not NULL.
5318  *   PMDs initialize this structure in case of error only.
5319  *
5320  * @return
5321  *   Handle on success, NULL otherwise and rte_errno is set.
5322  */
5323 __rte_experimental
5324 struct rte_flow_template_table *
5325 rte_flow_template_table_create(uint16_t port_id,
5326 		const struct rte_flow_template_table_attr *table_attr,
5327 		struct rte_flow_pattern_template *pattern_templates[],
5328 		uint8_t nb_pattern_templates,
5329 		struct rte_flow_actions_template *actions_templates[],
5330 		uint8_t nb_actions_templates,
5331 		struct rte_flow_error *error);
5332 
5333 /**
5334  * @warning
5335  * @b EXPERIMENTAL: this API may change without prior notice.
5336  *
5337  * Destroy flow template table.
5338  *
5339  * This function may be called only when
5340  * there are no more flow rules referencing this table.
5341  *
5342  * @param port_id
5343  *   Port identifier of Ethernet device.
5344  * @param[in] template_table
5345  *   Handle to the table to be destroyed.
5346  * @param[out] error
5347  *   Perform verbose error reporting if not NULL.
5348  *   PMDs initialize this structure in case of error only.
5349  *
5350  * @return
5351  *   0 on success, a negative errno value otherwise and rte_errno is set.
5352  */
5353 __rte_experimental
5354 int
5355 rte_flow_template_table_destroy(uint16_t port_id,
5356 		struct rte_flow_template_table *template_table,
5357 		struct rte_flow_error *error);
5358 
5359 /**
5360  * @warning
5361  * @b EXPERIMENTAL: this API may change without prior notice.
5362  *
5363  * Asynchronous operation attributes.
5364  */
5365 __extension__
5366 struct rte_flow_op_attr {
5367 	 /**
5368 	  * When set, the requested action will not be sent to the HW immediately.
5369 	  * The application must call the rte_flow_queue_push to actually send it.
5370 	  */
5371 	uint32_t postpone:1;
5372 };
5373 
5374 /**
5375  * @warning
5376  * @b EXPERIMENTAL: this API may change without prior notice.
5377  *
5378  * Enqueue rule creation operation.
5379  *
5380  * @param port_id
5381  *   Port identifier of Ethernet device.
5382  * @param queue_id
5383  *   Flow queue used to insert the rule.
5384  * @param[in] op_attr
5385  *   Rule creation operation attributes.
5386  * @param[in] template_table
5387  *   Template table to select templates from.
5388  * @param[in] pattern
5389  *   List of pattern items to be used.
5390  *   The list order should match the order in the pattern template.
5391  *   The spec is the only relevant member of the item that is being used.
5392  * @param[in] pattern_template_index
5393  *   Pattern template index in the table.
5394  * @param[in] actions
5395  *   List of actions to be used.
5396  *   The list order should match the order in the actions template.
5397  * @param[in] actions_template_index
5398  *   Actions template index in the table.
5399  * @param[in] user_data
5400  *   The user data that will be returned on the completion events.
5401  * @param[out] error
5402  *   Perform verbose error reporting if not NULL.
5403  *   PMDs initialize this structure in case of error only.
5404  *
5405  * @return
5406  *   Handle on success, NULL otherwise and rte_errno is set.
5407  *   The rule handle doesn't mean that the rule has been populated.
5408  *   Only completion result indicates that if there was success or failure.
5409  */
5410 __rte_experimental
5411 struct rte_flow *
5412 rte_flow_async_create(uint16_t port_id,
5413 		      uint32_t queue_id,
5414 		      const struct rte_flow_op_attr *op_attr,
5415 		      struct rte_flow_template_table *template_table,
5416 		      const struct rte_flow_item pattern[],
5417 		      uint8_t pattern_template_index,
5418 		      const struct rte_flow_action actions[],
5419 		      uint8_t actions_template_index,
5420 		      void *user_data,
5421 		      struct rte_flow_error *error);
5422 
5423 /**
5424  * @warning
5425  * @b EXPERIMENTAL: this API may change without prior notice.
5426  *
5427  * Enqueue rule destruction operation.
5428  *
5429  * This function enqueues a destruction operation on the queue.
5430  * Application should assume that after calling this function
5431  * the rule handle is not valid anymore.
5432  * Completion indicates the full removal of the rule from the HW.
5433  *
5434  * @param port_id
5435  *   Port identifier of Ethernet device.
5436  * @param queue_id
5437  *   Flow queue which is used to destroy the rule.
5438  *   This must match the queue on which the rule was created.
5439  * @param[in] op_attr
5440  *   Rule destruction operation attributes.
5441  * @param[in] flow
5442  *   Flow handle to be destroyed.
5443  * @param[in] user_data
5444  *   The user data that will be returned on the completion events.
5445  * @param[out] error
5446  *   Perform verbose error reporting if not NULL.
5447  *   PMDs initialize this structure in case of error only.
5448  *
5449  * @return
5450  *   0 on success, a negative errno value otherwise and rte_errno is set.
5451  */
5452 __rte_experimental
5453 int
5454 rte_flow_async_destroy(uint16_t port_id,
5455 		       uint32_t queue_id,
5456 		       const struct rte_flow_op_attr *op_attr,
5457 		       struct rte_flow *flow,
5458 		       void *user_data,
5459 		       struct rte_flow_error *error);
5460 
5461 /**
5462  * @warning
5463  * @b EXPERIMENTAL: this API may change without prior notice.
5464  *
5465  * Push all internally stored rules to the HW.
5466  * Postponed rules are rules that were inserted with the postpone flag set.
5467  * Can be used to notify the HW about batch of rules prepared by the SW to
5468  * reduce the number of communications between the HW and SW.
5469  *
5470  * @param port_id
5471  *   Port identifier of Ethernet device.
5472  * @param queue_id
5473  *   Flow queue to be pushed.
5474  * @param[out] error
5475  *   Perform verbose error reporting if not NULL.
5476  *   PMDs initialize this structure in case of error only.
5477  *
5478  * @return
5479  *   0 on success, a negative errno value otherwise and rte_errno is set.
5480  */
5481 __rte_experimental
5482 int
5483 rte_flow_push(uint16_t port_id,
5484 	      uint32_t queue_id,
5485 	      struct rte_flow_error *error);
5486 
5487 /**
5488  * @warning
5489  * @b EXPERIMENTAL: this API may change without prior notice.
5490  *
5491  * Asynchronous operation status.
5492  */
5493 enum rte_flow_op_status {
5494 	/**
5495 	 * The operation was completed successfully.
5496 	 */
5497 	RTE_FLOW_OP_SUCCESS,
5498 	/**
5499 	 * The operation was not completed successfully.
5500 	 */
5501 	RTE_FLOW_OP_ERROR,
5502 };
5503 
5504 /**
5505  * @warning
5506  * @b EXPERIMENTAL: this API may change without prior notice.
5507  *
5508  * Asynchronous operation result.
5509  */
5510 __extension__
5511 struct rte_flow_op_result {
5512 	/**
5513 	 * Returns the status of the operation that this completion signals.
5514 	 */
5515 	enum rte_flow_op_status status;
5516 	/**
5517 	 * The user data that will be returned on the completion events.
5518 	 */
5519 	void *user_data;
5520 };
5521 
5522 /**
5523  * @warning
5524  * @b EXPERIMENTAL: this API may change without prior notice.
5525  *
5526  * Pull a rte flow operation.
5527  * The application must invoke this function in order to complete
5528  * the flow rule offloading and to retrieve the flow rule operation status.
5529  *
5530  * @param port_id
5531  *   Port identifier of Ethernet device.
5532  * @param queue_id
5533  *   Flow queue which is used to pull the operation.
5534  * @param[out] res
5535  *   Array of results that will be set.
5536  * @param[in] n_res
5537  *   Maximum number of results that can be returned.
5538  *   This value is equal to the size of the res array.
5539  * @param[out] error
5540  *   Perform verbose error reporting if not NULL.
5541  *   PMDs initialize this structure in case of error only.
5542  *
5543  * @return
5544  *   Number of results that were pulled,
5545  *   a negative errno value otherwise and rte_errno is set.
5546  */
5547 __rte_experimental
5548 int
5549 rte_flow_pull(uint16_t port_id,
5550 	      uint32_t queue_id,
5551 	      struct rte_flow_op_result res[],
5552 	      uint16_t n_res,
5553 	      struct rte_flow_error *error);
5554 
5555 /**
5556  * @warning
5557  * @b EXPERIMENTAL: this API may change without prior notice.
5558  *
5559  * Enqueue indirect action creation operation.
5560  * @see rte_flow_action_handle_create
5561  *
5562  * @param[in] port_id
5563  *   Port identifier of Ethernet device.
5564  * @param[in] queue_id
5565  *   Flow queue which is used to create the rule.
5566  * @param[in] op_attr
5567  *   Indirect action creation operation attributes.
5568  * @param[in] indir_action_conf
5569  *   Action configuration for the indirect action object creation.
5570  * @param[in] action
5571  *   Specific configuration of the indirect action object.
5572  * @param[in] user_data
5573  *   The user data that will be returned on the completion events.
5574  * @param[out] error
5575  *   Perform verbose error reporting if not NULL.
5576  *   PMDs initialize this structure in case of error only.
5577  *
5578  * @return
5579  *   A valid handle in case of success, NULL otherwise and rte_errno is set.
5580  */
5581 __rte_experimental
5582 struct rte_flow_action_handle *
5583 rte_flow_async_action_handle_create(uint16_t port_id,
5584 		uint32_t queue_id,
5585 		const struct rte_flow_op_attr *op_attr,
5586 		const struct rte_flow_indir_action_conf *indir_action_conf,
5587 		const struct rte_flow_action *action,
5588 		void *user_data,
5589 		struct rte_flow_error *error);
5590 
5591 /**
5592  * @warning
5593  * @b EXPERIMENTAL: this API may change without prior notice.
5594  *
5595  * Enqueue indirect action destruction operation.
5596  * The destroy queue must be the same
5597  * as the queue on which the action was created.
5598  *
5599  * @param[in] port_id
5600  *   Port identifier of Ethernet device.
5601  * @param[in] queue_id
5602  *   Flow queue which is used to destroy the rule.
5603  * @param[in] op_attr
5604  *   Indirect action destruction operation attributes.
5605  * @param[in] action_handle
5606  *   Handle for the indirect action object to be destroyed.
5607  * @param[in] user_data
5608  *   The user data that will be returned on the completion events.
5609  * @param[out] error
5610  *   Perform verbose error reporting if not NULL.
5611  *   PMDs initialize this structure in case of error only.
5612  *
5613  * @return
5614  *   0 on success, a negative errno value otherwise and rte_errno is set.
5615  */
5616 __rte_experimental
5617 int
5618 rte_flow_async_action_handle_destroy(uint16_t port_id,
5619 		uint32_t queue_id,
5620 		const struct rte_flow_op_attr *op_attr,
5621 		struct rte_flow_action_handle *action_handle,
5622 		void *user_data,
5623 		struct rte_flow_error *error);
5624 
5625 /**
5626  * @warning
5627  * @b EXPERIMENTAL: this API may change without prior notice.
5628  *
5629  * Enqueue indirect action update operation.
5630  * @see rte_flow_action_handle_create
5631  *
5632  * @param[in] port_id
5633  *   Port identifier of Ethernet device.
5634  * @param[in] queue_id
5635  *   Flow queue which is used to update the rule.
5636  * @param[in] op_attr
5637  *   Indirect action update operation attributes.
5638  * @param[in] action_handle
5639  *   Handle for the indirect action object to be updated.
5640  * @param[in] update
5641  *   Update profile specification used to modify the action pointed by handle.
5642  *   *update* could be with the same type of the immediate action corresponding
5643  *   to the *handle* argument when creating, or a wrapper structure includes
5644  *   action configuration to be updated and bit fields to indicate the member
5645  *   of fields inside the action to update.
5646  * @param[in] user_data
5647  *   The user data that will be returned on the completion events.
5648  * @param[out] error
5649  *   Perform verbose error reporting if not NULL.
5650  *   PMDs initialize this structure in case of error only.
5651  *
5652  * @return
5653  *   0 on success, a negative errno value otherwise and rte_errno is set.
5654  */
5655 __rte_experimental
5656 int
5657 rte_flow_async_action_handle_update(uint16_t port_id,
5658 		uint32_t queue_id,
5659 		const struct rte_flow_op_attr *op_attr,
5660 		struct rte_flow_action_handle *action_handle,
5661 		const void *update,
5662 		void *user_data,
5663 		struct rte_flow_error *error);
5664 
5665 /**
5666  * @warning
5667  * @b EXPERIMENTAL: this API may change without prior notice.
5668  *
5669  * Enqueue indirect action query operation.
5670  *
5671  * Retrieve action-specific data such as counters.
5672  * Data is gathered by special action which may be present/referenced in
5673  * more than one flow rule definition.
5674  * Data will be available only when completion event returns.
5675  *
5676  * @see rte_flow_async_action_handle_query
5677  *
5678  * @param port_id
5679  *   Port identifier of Ethernet device.
5680  * @param[in] queue_id
5681  *   Flow queue which is used to query the action.
5682  * @param[in] op_attr
5683  *   Indirect action update operation attributes.
5684  * @param[in] action_handle
5685  *   Handle for the action object to query.
5686  * @param[in, out] data
5687  *   Pointer to storage for the associated query data type.
5688  *   The out data will be available only when completion event returns
5689  *   from rte_flow_pull.
5690  * @param[in] user_data
5691  *   The user data that will be returned on the completion events.
5692  * @param[out] error
5693  *   Perform verbose error reporting if not NULL. PMDs initialize this
5694  *   structure in case of error only.
5695  *
5696  * @return
5697  *   0 on success, a negative errno value otherwise and rte_errno is set.
5698  */
5699 __rte_experimental
5700 int
5701 rte_flow_async_action_handle_query(uint16_t port_id,
5702 		uint32_t queue_id,
5703 		const struct rte_flow_op_attr *op_attr,
5704 		const struct rte_flow_action_handle *action_handle,
5705 		void *data,
5706 		void *user_data,
5707 		struct rte_flow_error *error);
5708 
5709 #ifdef __cplusplus
5710 }
5711 #endif
5712 
5713 #endif /* RTE_FLOW_H_ */
5714