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