xref: /dpdk/lib/ethdev/rte_flow.h (revision 966eb55e9a009d7575a75a9e7db8ea9f90a21f13)
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 	 */
2647 	RTE_FLOW_ACTION_TYPE_AGE,
2648 
2649 	/**
2650 	 * The matching packets will be duplicated with specified ratio and
2651 	 * applied with own set of actions with a fate action.
2652 	 *
2653 	 * See struct rte_flow_action_sample.
2654 	 */
2655 	RTE_FLOW_ACTION_TYPE_SAMPLE,
2656 
2657 	/**
2658 	 * @deprecated
2659 	 * @see RTE_FLOW_ACTION_TYPE_INDIRECT
2660 	 *
2661 	 * Describe action shared across multiple flow rules.
2662 	 *
2663 	 * Allow multiple rules reference the same action by handle (see
2664 	 * struct rte_flow_shared_action).
2665 	 */
2666 	RTE_FLOW_ACTION_TYPE_SHARED,
2667 
2668 	/**
2669 	 * Modify a packet header field, tag, mark or metadata.
2670 	 *
2671 	 * Allow the modification of an arbitrary header field via
2672 	 * set, add and sub operations or copying its content into
2673 	 * tag, meta or mark for future processing.
2674 	 *
2675 	 * See struct rte_flow_action_modify_field.
2676 	 */
2677 	RTE_FLOW_ACTION_TYPE_MODIFY_FIELD,
2678 
2679 	/**
2680 	 * An action handle is referenced in a rule through an indirect action.
2681 	 *
2682 	 * The same action handle may be used in multiple rules for the same
2683 	 * or different ethdev ports.
2684 	 */
2685 	RTE_FLOW_ACTION_TYPE_INDIRECT,
2686 
2687 	/**
2688 	 * [META]
2689 	 *
2690 	 * Enable tracking a TCP connection state.
2691 	 *
2692 	 * @see struct rte_flow_action_conntrack.
2693 	 */
2694 	RTE_FLOW_ACTION_TYPE_CONNTRACK,
2695 
2696 	/**
2697 	 * Color the packet to reflect the meter color result.
2698 	 * Set the meter color in the mbuf to the selected color.
2699 	 *
2700 	 * See struct rte_flow_action_meter_color.
2701 	 */
2702 	RTE_FLOW_ACTION_TYPE_METER_COLOR,
2703 
2704 	/**
2705 	 * At embedded switch level, sends matching traffic to the given ethdev.
2706 	 *
2707 	 * @see struct rte_flow_action_ethdev
2708 	 */
2709 	RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR,
2710 
2711 	/**
2712 	 * At embedded switch level, send matching traffic to
2713 	 * the entity represented by the given ethdev.
2714 	 *
2715 	 * @see struct rte_flow_action_ethdev
2716 	 */
2717 	RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT,
2718 
2719 	/**
2720 	 * Traffic metering and marking (MTR).
2721 	 *
2722 	 * @see struct rte_flow_action_meter_mark
2723 	 * See file rte_mtr.h for MTR profile object configuration.
2724 	 */
2725 	RTE_FLOW_ACTION_TYPE_METER_MARK,
2726 
2727 	/**
2728 	 * Send packets to the kernel, without going to userspace at all.
2729 	 * The packets will be received by the kernel driver sharing
2730 	 * the same device as the DPDK port on which this action is configured.
2731 	 * This action mostly suits bifurcated driver model.
2732 	 * This is an ingress non-transfer action only.
2733 	 *
2734 	 * No associated configuration structure.
2735 	 */
2736 	RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL,
2737 };
2738 
2739 /**
2740  * RTE_FLOW_ACTION_TYPE_MARK
2741  *
2742  * Attaches an integer value to packets and sets RTE_MBUF_F_RX_FDIR and
2743  * RTE_MBUF_F_RX_FDIR_ID mbuf flags.
2744  *
2745  * This value is arbitrary and application-defined. Maximum allowed value
2746  * depends on the underlying implementation. It is returned in the
2747  * hash.fdir.hi mbuf field.
2748  */
2749 struct rte_flow_action_mark {
2750 	uint32_t id; /**< Integer value to return with packets. */
2751 };
2752 
2753 /**
2754  * @warning
2755  * @b EXPERIMENTAL: this structure may change without prior notice
2756  *
2757  * RTE_FLOW_ACTION_TYPE_JUMP
2758  *
2759  * Redirects packets to a group on the current device.
2760  *
2761  * In a hierarchy of groups, which can be used to represent physical or logical
2762  * flow tables on the device, this action allows the action to be a redirect to
2763  * a group on that device.
2764  */
2765 struct rte_flow_action_jump {
2766 	uint32_t group;
2767 };
2768 
2769 /**
2770  * RTE_FLOW_ACTION_TYPE_QUEUE
2771  *
2772  * Assign packets to a given queue index.
2773  */
2774 struct rte_flow_action_queue {
2775 	uint16_t index; /**< Queue index to use. */
2776 };
2777 
2778 /**
2779  * @warning
2780  * @b EXPERIMENTAL: this structure may change without prior notice
2781  *
2782  * RTE_FLOW_ACTION_TYPE_AGE
2783  *
2784  * Report flow as aged-out if timeout passed without any matching
2785  * on the flow. RTE_ETH_EVENT_FLOW_AGED event is triggered when a
2786  * port detects new aged-out flows.
2787  *
2788  * The flow context and the flow handle will be reported by the either
2789  * rte_flow_get_aged_flows or rte_flow_get_q_aged_flows APIs.
2790  */
2791 struct rte_flow_action_age {
2792 	uint32_t timeout:24; /**< Time in seconds. */
2793 	uint32_t reserved:8; /**< Reserved, must be zero. */
2794 	/** The user flow context, NULL means the rte_flow pointer. */
2795 	void *context;
2796 };
2797 
2798 /**
2799  * RTE_FLOW_ACTION_TYPE_AGE (query)
2800  *
2801  * Query structure to retrieve the aging status information of a
2802  * shared AGE action, or a flow rule using the AGE action.
2803  */
2804 struct rte_flow_query_age {
2805 	uint32_t reserved:6; /**< Reserved, must be zero. */
2806 	uint32_t aged:1; /**< 1 if aging timeout expired, 0 otherwise. */
2807 	/** sec_since_last_hit value is valid. */
2808 	uint32_t sec_since_last_hit_valid:1;
2809 	uint32_t sec_since_last_hit:24; /**< Seconds since last traffic hit. */
2810 };
2811 
2812 /**
2813  * @warning
2814  * @b EXPERIMENTAL: this structure may change without prior notice
2815  *
2816  * RTE_FLOW_ACTION_TYPE_COUNT
2817  *
2818  * Adds a counter action to a matched flow.
2819  *
2820  * If more than one count action is specified in a single flow rule, then each
2821  * action must specify a unique ID.
2822  *
2823  * Counters can be retrieved and reset through ``rte_flow_query()``, see
2824  * ``struct rte_flow_query_count``.
2825  *
2826  * For ports within the same switch domain then the counter ID namespace extends
2827  * to all ports within that switch domain.
2828  */
2829 struct rte_flow_action_count {
2830 	uint32_t id; /**< Counter ID. */
2831 };
2832 
2833 /**
2834  * RTE_FLOW_ACTION_TYPE_COUNT (query)
2835  *
2836  * Query structure to retrieve and reset flow rule counters.
2837  */
2838 struct rte_flow_query_count {
2839 	uint32_t reset:1; /**< Reset counters after query [in]. */
2840 	uint32_t hits_set:1; /**< hits field is set [out]. */
2841 	uint32_t bytes_set:1; /**< bytes field is set [out]. */
2842 	uint32_t reserved:29; /**< Reserved, must be zero [in, out]. */
2843 	uint64_t hits; /**< Number of hits for this rule [out]. */
2844 	uint64_t bytes; /**< Number of bytes through this rule [out]. */
2845 };
2846 
2847 /**
2848  * Hash function types.
2849  */
2850 enum rte_eth_hash_function {
2851 	RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
2852 	RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
2853 	RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
2854 	/**
2855 	 * Symmetric Toeplitz: src, dst will be replaced by
2856 	 * xor(src, dst). For the case with src/dst only,
2857 	 * src or dst address will xor with zero pair.
2858 	 */
2859 	RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
2860 	RTE_ETH_HASH_FUNCTION_MAX,
2861 };
2862 
2863 /**
2864  * RTE_FLOW_ACTION_TYPE_RSS
2865  *
2866  * Similar to QUEUE, except RSS is additionally performed on packets to
2867  * spread them among several queues according to the provided parameters.
2868  *
2869  * Unlike global RSS settings used by other DPDK APIs, unsetting the
2870  * @p types field does not disable RSS in a flow rule. Doing so instead
2871  * requests safe unspecified "best-effort" settings from the underlying PMD,
2872  * which depending on the flow rule, may result in anything ranging from
2873  * empty (single queue) to all-inclusive RSS.
2874  *
2875  * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps
2876  * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only,
2877  * both can be requested simultaneously.
2878  */
2879 struct rte_flow_action_rss {
2880 	enum rte_eth_hash_function func; /**< RSS hash function to apply. */
2881 	/**
2882 	 * Packet encapsulation level RSS hash @p types apply to.
2883 	 *
2884 	 * - @p 0 requests the default behavior. Depending on the packet
2885 	 *   type, it can mean outermost, innermost, anything in between or
2886 	 *   even no RSS.
2887 	 *
2888 	 *   It basically stands for the innermost encapsulation level RSS
2889 	 *   can be performed on according to PMD and device capabilities.
2890 	 *
2891 	 * - @p 1 requests RSS to be performed on the outermost packet
2892 	 *   encapsulation level.
2893 	 *
2894 	 * - @p 2 and subsequent values request RSS to be performed on the
2895 	 *   specified inner packet encapsulation level, from outermost to
2896 	 *   innermost (lower to higher values).
2897 	 *
2898 	 * Values other than @p 0 are not necessarily supported.
2899 	 *
2900 	 * Requesting a specific RSS level on unrecognized traffic results
2901 	 * in undefined behavior. For predictable results, it is recommended
2902 	 * to make the flow rule pattern match packet headers up to the
2903 	 * requested encapsulation level so that only matching traffic goes
2904 	 * through.
2905 	 */
2906 	uint32_t level;
2907 	uint64_t types; /**< Specific RSS hash types (see RTE_ETH_RSS_*). */
2908 	uint32_t key_len; /**< Hash key length in bytes. */
2909 	uint32_t queue_num; /**< Number of entries in @p queue. */
2910 	const uint8_t *key; /**< Hash key. */
2911 	const uint16_t *queue; /**< Queue indices to use. */
2912 };
2913 
2914 /**
2915  * @deprecated
2916  * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2917  * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2918  *
2919  * RTE_FLOW_ACTION_TYPE_VF
2920  *
2921  * Directs matching traffic to a given virtual function of the current
2922  * device.
2923  *
2924  * Packets matched by a VF pattern item can be redirected to their original
2925  * VF ID instead of the specified one. This parameter may not be available
2926  * and is not guaranteed to work properly if the VF part is matched by a
2927  * prior flow rule or if packets are not addressed to a VF in the first
2928  * place.
2929  */
2930 struct rte_flow_action_vf {
2931 	uint32_t original:1; /**< Use original VF ID if possible. */
2932 	uint32_t reserved:31; /**< Reserved, must be zero. */
2933 	uint32_t id; /**< VF ID. */
2934 };
2935 
2936 /**
2937  * @deprecated
2938  * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2939  * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2940  *
2941  * RTE_FLOW_ACTION_TYPE_PORT_ID
2942  *
2943  * Directs matching traffic to a given DPDK port ID.
2944  *
2945  * @see RTE_FLOW_ITEM_TYPE_PORT_ID
2946  */
2947 struct rte_flow_action_port_id {
2948 	uint32_t original:1; /**< Use original DPDK port ID if possible. */
2949 	uint32_t reserved:31; /**< Reserved, must be zero. */
2950 	uint32_t id; /**< DPDK port ID. */
2951 };
2952 
2953 /**
2954  * RTE_FLOW_ACTION_TYPE_METER
2955  *
2956  * Traffic metering and policing (MTR).
2957  *
2958  * Packets matched by items of this type can be either dropped or passed to the
2959  * next item with their color set by the MTR object.
2960  */
2961 struct rte_flow_action_meter {
2962 	uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */
2963 };
2964 
2965 /**
2966  * RTE_FLOW_ACTION_TYPE_SECURITY
2967  *
2968  * Perform the security action on flows matched by the pattern items
2969  * according to the configuration of the security session.
2970  *
2971  * This action modifies the payload of matched flows. For INLINE_CRYPTO, the
2972  * security protocol headers and IV are fully provided by the application as
2973  * specified in the flow pattern. The payload of matching packets is
2974  * encrypted on egress, and decrypted and authenticated on ingress.
2975  * For INLINE_PROTOCOL, the security protocol is fully offloaded to HW,
2976  * providing full encapsulation and decapsulation of packets in security
2977  * protocols. The flow pattern specifies both the outer security header fields
2978  * and the inner packet fields. The security session specified in the action
2979  * must match the pattern parameters.
2980  *
2981  * The security session specified in the action must be created on the same
2982  * port as the flow action that is being specified.
2983  *
2984  * The ingress/egress flow attribute should match that specified in the
2985  * security session if the security session supports the definition of the
2986  * direction.
2987  *
2988  * Multiple flows can be configured to use the same security session.
2989  *
2990  * The NULL value is allowed for security session. If security session is NULL,
2991  * then SPI field in ESP flow item and IP addresses in flow items 'IPv4' and
2992  * 'IPv6' will be allowed to be a range. The rule thus created can enable
2993  * security processing on multiple flows.
2994  */
2995 struct rte_flow_action_security {
2996 	void *security_session; /**< Pointer to security session structure. */
2997 };
2998 
2999 /**
3000  * RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN
3001  *
3002  * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by the
3003  * OpenFlow Switch Specification.
3004  */
3005 struct rte_flow_action_of_push_vlan {
3006 	rte_be16_t ethertype; /**< EtherType. */
3007 };
3008 
3009 /**
3010  * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID
3011  *
3012  * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN ID") as defined by
3013  * the OpenFlow Switch Specification.
3014  */
3015 struct rte_flow_action_of_set_vlan_vid {
3016 	rte_be16_t vlan_vid; /**< VLAN ID. */
3017 };
3018 
3019 /**
3020  * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP
3021  *
3022  * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as defined by
3023  * the OpenFlow Switch Specification.
3024  */
3025 struct rte_flow_action_of_set_vlan_pcp {
3026 	uint8_t vlan_pcp; /**< VLAN priority. */
3027 };
3028 
3029 /**
3030  * RTE_FLOW_ACTION_TYPE_OF_POP_MPLS
3031  *
3032  * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined by the
3033  * OpenFlow Switch Specification.
3034  */
3035 struct rte_flow_action_of_pop_mpls {
3036 	rte_be16_t ethertype; /**< EtherType. */
3037 };
3038 
3039 /**
3040  * RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS
3041  *
3042  * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by the
3043  * OpenFlow Switch Specification.
3044  */
3045 struct rte_flow_action_of_push_mpls {
3046 	rte_be16_t ethertype; /**< EtherType. */
3047 };
3048 
3049 /**
3050  * @warning
3051  * @b EXPERIMENTAL: this structure may change without prior notice
3052  *
3053  * RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP
3054  *
3055  * VXLAN tunnel end-point encapsulation data definition
3056  *
3057  * The tunnel definition is provided through the flow item pattern, the
3058  * provided pattern must conform to RFC7348 for the tunnel specified. The flow
3059  * definition must be provided in order from the RTE_FLOW_ITEM_TYPE_ETH
3060  * definition up the end item which is specified by RTE_FLOW_ITEM_TYPE_END.
3061  *
3062  * The mask field allows user to specify which fields in the flow item
3063  * definitions can be ignored and which have valid data and can be used
3064  * verbatim.
3065  *
3066  * Note: the last field is not used in the definition of a tunnel and can be
3067  * ignored.
3068  *
3069  * Valid flow definition for RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP include:
3070  *
3071  * - ETH / IPV4 / UDP / VXLAN / END
3072  * - ETH / IPV6 / UDP / VXLAN / END
3073  * - ETH / VLAN / IPV4 / UDP / VXLAN / END
3074  *
3075  */
3076 struct rte_flow_action_vxlan_encap {
3077 	/**
3078 	 * Encapsulating vxlan tunnel definition
3079 	 * (terminated by the END pattern item).
3080 	 */
3081 	struct rte_flow_item *definition;
3082 };
3083 
3084 /**
3085  * @warning
3086  * @b EXPERIMENTAL: this structure may change without prior notice
3087  *
3088  * RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP
3089  *
3090  * NVGRE tunnel end-point encapsulation data definition
3091  *
3092  * The tunnel definition is provided through the flow item pattern  the
3093  * provided pattern must conform with RFC7637. The flow definition must be
3094  * provided in order from the RTE_FLOW_ITEM_TYPE_ETH definition up the end item
3095  * which is specified by RTE_FLOW_ITEM_TYPE_END.
3096  *
3097  * The mask field allows user to specify which fields in the flow item
3098  * definitions can be ignored and which have valid data and can be used
3099  * verbatim.
3100  *
3101  * Note: the last field is not used in the definition of a tunnel and can be
3102  * ignored.
3103  *
3104  * Valid flow definition for RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP include:
3105  *
3106  * - ETH / IPV4 / NVGRE / END
3107  * - ETH / VLAN / IPV6 / NVGRE / END
3108  *
3109  */
3110 struct rte_flow_action_nvgre_encap {
3111 	/**
3112 	 * Encapsulating vxlan tunnel definition
3113 	 * (terminated by the END pattern item).
3114 	 */
3115 	struct rte_flow_item *definition;
3116 };
3117 
3118 /**
3119  * @warning
3120  * @b EXPERIMENTAL: this structure may change without prior notice
3121  *
3122  * RTE_FLOW_ACTION_TYPE_RAW_ENCAP
3123  *
3124  * Raw tunnel end-point encapsulation data definition.
3125  *
3126  * The data holds the headers definitions to be applied on the packet.
3127  * The data must start with ETH header up to the tunnel item header itself.
3128  * When used right after RAW_DECAP (for decapsulating L3 tunnel type for
3129  * example MPLSoGRE) the data will just hold layer 2 header.
3130  *
3131  * The preserve parameter holds which bits in the packet the PMD is not allowed
3132  * to change, this parameter can also be NULL and then the PMD is allowed
3133  * to update any field.
3134  *
3135  * size holds the number of bytes in @p data and @p preserve.
3136  */
3137 struct rte_flow_action_raw_encap {
3138 	uint8_t *data; /**< Encapsulation data. */
3139 	uint8_t *preserve; /**< Bit-mask of @p data to preserve on output. */
3140 	size_t size; /**< Size of @p data and @p preserve. */
3141 };
3142 
3143 /**
3144  * @warning
3145  * @b EXPERIMENTAL: this structure may change without prior notice
3146  *
3147  * RTE_FLOW_ACTION_TYPE_RAW_DECAP
3148  *
3149  * Raw tunnel end-point decapsulation data definition.
3150  *
3151  * The data holds the headers definitions to be removed from the packet.
3152  * The data must start with ETH header up to the tunnel item header itself.
3153  * When used right before RAW_DECAP (for encapsulating L3 tunnel type for
3154  * example MPLSoGRE) the data will just hold layer 2 header.
3155  *
3156  * size holds the number of bytes in @p data.
3157  */
3158 struct rte_flow_action_raw_decap {
3159 	uint8_t *data; /**< Encapsulation data. */
3160 	size_t size; /**< Size of @p data and @p preserve. */
3161 };
3162 
3163 /**
3164  * @warning
3165  * @b EXPERIMENTAL: this structure may change without prior notice
3166  *
3167  * RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC
3168  * RTE_FLOW_ACTION_TYPE_SET_IPV4_DST
3169  *
3170  * Allows modification of IPv4 source (RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC)
3171  * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV4_DST) in the
3172  * specified outermost IPv4 header.
3173  */
3174 struct rte_flow_action_set_ipv4 {
3175 	rte_be32_t ipv4_addr;
3176 };
3177 
3178 /**
3179  * @warning
3180  * @b EXPERIMENTAL: this structure may change without prior notice
3181  *
3182  * RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC
3183  * RTE_FLOW_ACTION_TYPE_SET_IPV6_DST
3184  *
3185  * Allows modification of IPv6 source (RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC)
3186  * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV6_DST) in the
3187  * specified outermost IPv6 header.
3188  */
3189 struct rte_flow_action_set_ipv6 {
3190 	uint8_t ipv6_addr[16];
3191 };
3192 
3193 /**
3194  * @warning
3195  * @b EXPERIMENTAL: this structure may change without prior notice
3196  *
3197  * RTE_FLOW_ACTION_TYPE_SET_TP_SRC
3198  * RTE_FLOW_ACTION_TYPE_SET_TP_DST
3199  *
3200  * Allows modification of source (RTE_FLOW_ACTION_TYPE_SET_TP_SRC)
3201  * and destination (RTE_FLOW_ACTION_TYPE_SET_TP_DST) port numbers
3202  * in the specified outermost TCP/UDP header.
3203  */
3204 struct rte_flow_action_set_tp {
3205 	rte_be16_t port;
3206 };
3207 
3208 /**
3209  * RTE_FLOW_ACTION_TYPE_SET_TTL
3210  *
3211  * Set the TTL value directly for IPv4 or IPv6
3212  */
3213 struct rte_flow_action_set_ttl {
3214 	uint8_t ttl_value;
3215 };
3216 
3217 /**
3218  * RTE_FLOW_ACTION_TYPE_SET_MAC
3219  *
3220  * Set MAC address from the matched flow
3221  */
3222 struct rte_flow_action_set_mac {
3223 	uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
3224 };
3225 
3226 /**
3227  * @warning
3228  * @b EXPERIMENTAL: this structure may change without prior notice
3229  *
3230  * RTE_FLOW_ACTION_TYPE_SET_TAG
3231  *
3232  * Set a tag which is a transient data used during flow matching. This is not
3233  * delivered to application. Multiple tags are supported by specifying index.
3234  */
3235 struct rte_flow_action_set_tag {
3236 	uint32_t data;
3237 	uint32_t mask;
3238 	uint8_t index;
3239 };
3240 
3241 /**
3242  * @warning
3243  * @b EXPERIMENTAL: this structure may change without prior notice
3244  *
3245  * RTE_FLOW_ACTION_TYPE_SET_META
3246  *
3247  * Set metadata. Metadata set by mbuf metadata dynamic field with
3248  * RTE_MBUF_DYNFLAG_TX_METADATA flag on egress will be overridden by this
3249  * action. On ingress, the metadata will be carried by mbuf metadata dynamic
3250  * field with RTE_MBUF_DYNFLAG_RX_METADATA flag if set.  The dynamic mbuf field
3251  * must be registered in advance by rte_flow_dynf_metadata_register().
3252  *
3253  * Altering partial bits is supported with mask. For bits which have never
3254  * been set, unpredictable value will be seen depending on driver
3255  * implementation. For loopback/hairpin packet, metadata set on Rx/Tx may
3256  * or may not be propagated to the other path depending on HW capability.
3257  *
3258  * RTE_FLOW_ITEM_TYPE_META matches metadata.
3259  */
3260 struct rte_flow_action_set_meta {
3261 	uint32_t data;
3262 	uint32_t mask;
3263 };
3264 
3265 /**
3266  * RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP
3267  * RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP
3268  *
3269  * Set the DSCP value for IPv4/IPv6 header.
3270  * DSCP in low 6 bits, rest ignored.
3271  */
3272 struct rte_flow_action_set_dscp {
3273 	uint8_t dscp;
3274 };
3275 
3276 /**
3277  * @warning
3278  * @b EXPERIMENTAL: this structure may change without prior notice
3279  *
3280  * RTE_FLOW_ACTION_TYPE_INDIRECT
3281  *
3282  * Opaque type returned after successfully creating an indirect action object.
3283  * The definition of the object handle is different per driver or
3284  * per direct action type.
3285  *
3286  * This handle can be used to manage and query the related direct action:
3287  * - referenced in single flow rule or across multiple flow rules
3288  *   over multiple ports
3289  * - update action object configuration
3290  * - query action object data
3291  * - destroy action object
3292  */
3293 struct rte_flow_action_handle;
3294 
3295 /**
3296  * The state of a TCP connection.
3297  */
3298 enum rte_flow_conntrack_state {
3299 	/** SYN-ACK packet was seen. */
3300 	RTE_FLOW_CONNTRACK_STATE_SYN_RECV,
3301 	/** 3-way handshake was done. */
3302 	RTE_FLOW_CONNTRACK_STATE_ESTABLISHED,
3303 	/** First FIN packet was received to close the connection. */
3304 	RTE_FLOW_CONNTRACK_STATE_FIN_WAIT,
3305 	/** First FIN was ACKed. */
3306 	RTE_FLOW_CONNTRACK_STATE_CLOSE_WAIT,
3307 	/** Second FIN was received, waiting for the last ACK. */
3308 	RTE_FLOW_CONNTRACK_STATE_LAST_ACK,
3309 	/** Second FIN was ACKed, connection was closed. */
3310 	RTE_FLOW_CONNTRACK_STATE_TIME_WAIT,
3311 };
3312 
3313 /**
3314  * The last passed TCP packet flags of a connection.
3315  */
3316 enum rte_flow_conntrack_tcp_last_index {
3317 	RTE_FLOW_CONNTRACK_FLAG_NONE = 0, /**< No Flag. */
3318 	RTE_FLOW_CONNTRACK_FLAG_SYN = RTE_BIT32(0), /**< With SYN flag. */
3319 	RTE_FLOW_CONNTRACK_FLAG_SYNACK = RTE_BIT32(1), /**< With SYNACK flag. */
3320 	RTE_FLOW_CONNTRACK_FLAG_FIN = RTE_BIT32(2), /**< With FIN flag. */
3321 	RTE_FLOW_CONNTRACK_FLAG_ACK = RTE_BIT32(3), /**< With ACK flag. */
3322 	RTE_FLOW_CONNTRACK_FLAG_RST = RTE_BIT32(4), /**< With RST flag. */
3323 };
3324 
3325 /**
3326  * @warning
3327  * @b EXPERIMENTAL: this structure may change without prior notice
3328  *
3329  * Configuration parameters for each direction of a TCP connection.
3330  * All fields should be in host byte order.
3331  * If needed, driver should convert all fields to network byte order
3332  * if HW needs them in that way.
3333  */
3334 struct rte_flow_tcp_dir_param {
3335 	/** TCP window scaling factor, 0xF to disable. */
3336 	uint32_t scale:4;
3337 	/** The FIN was sent by this direction. */
3338 	uint32_t close_initiated:1;
3339 	/** An ACK packet has been received by this side. */
3340 	uint32_t last_ack_seen:1;
3341 	/**
3342 	 * If set, it indicates that there is unacknowledged data for the
3343 	 * packets sent from this direction.
3344 	 */
3345 	uint32_t data_unacked:1;
3346 	/**
3347 	 * Maximal value of sequence + payload length in sent
3348 	 * packets (next ACK from the opposite direction).
3349 	 */
3350 	uint32_t sent_end;
3351 	/**
3352 	 * Maximal value of (ACK + window size) in received packet + length
3353 	 * over sent packet (maximal sequence could be sent).
3354 	 */
3355 	uint32_t reply_end;
3356 	/** Maximal value of actual window size in sent packets. */
3357 	uint32_t max_win;
3358 	/** Maximal value of ACK in sent packets. */
3359 	uint32_t max_ack;
3360 };
3361 
3362 /**
3363  * @warning
3364  * @b EXPERIMENTAL: this structure may change without prior notice
3365  *
3366  * RTE_FLOW_ACTION_TYPE_CONNTRACK
3367  *
3368  * Configuration and initial state for the connection tracking module.
3369  * This structure could be used for both setting and query.
3370  * All fields should be in host byte order.
3371  */
3372 struct rte_flow_action_conntrack {
3373 	/** The peer port number, can be the same port. */
3374 	uint16_t peer_port;
3375 	/**
3376 	 * Direction of this connection when creating a flow rule, the
3377 	 * value only affects the creation of subsequent flow rules.
3378 	 */
3379 	uint32_t is_original_dir:1;
3380 	/**
3381 	 * Enable / disable the conntrack HW module. When disabled, the
3382 	 * result will always be RTE_FLOW_CONNTRACK_FLAG_DISABLED.
3383 	 * In this state the HW will act as passthrough.
3384 	 * It only affects this conntrack object in the HW without any effect
3385 	 * to the other objects.
3386 	 */
3387 	uint32_t enable:1;
3388 	/** At least one ack was seen after the connection was established. */
3389 	uint32_t live_connection:1;
3390 	/** Enable selective ACK on this connection. */
3391 	uint32_t selective_ack:1;
3392 	/** A challenge ack has passed. */
3393 	uint32_t challenge_ack_passed:1;
3394 	/**
3395 	 * 1: The last packet is seen from the original direction.
3396 	 * 0: The last packet is seen from the reply direction.
3397 	 */
3398 	uint32_t last_direction:1;
3399 	/** No TCP check will be done except the state change. */
3400 	uint32_t liberal_mode:1;
3401 	/** The current state of this connection. */
3402 	enum rte_flow_conntrack_state state;
3403 	/** Scaling factor for maximal allowed ACK window. */
3404 	uint8_t max_ack_window;
3405 	/** Maximal allowed number of retransmission times. */
3406 	uint8_t retransmission_limit;
3407 	/** TCP parameters of the original direction. */
3408 	struct rte_flow_tcp_dir_param original_dir;
3409 	/** TCP parameters of the reply direction. */
3410 	struct rte_flow_tcp_dir_param reply_dir;
3411 	/** The window value of the last packet passed this conntrack. */
3412 	uint16_t last_window;
3413 	enum rte_flow_conntrack_tcp_last_index last_index;
3414 	/** The sequence of the last packet passed this conntrack. */
3415 	uint32_t last_seq;
3416 	/** The acknowledgment of the last packet passed this conntrack. */
3417 	uint32_t last_ack;
3418 	/**
3419 	 * The total value ACK + payload length of the last packet
3420 	 * passed this conntrack.
3421 	 */
3422 	uint32_t last_end;
3423 };
3424 
3425 /**
3426  * RTE_FLOW_ACTION_TYPE_CONNTRACK
3427  *
3428  * Wrapper structure for the context update interface.
3429  * Ports cannot support updating, and the only valid solution is to
3430  * destroy the old context and create a new one instead.
3431  */
3432 struct rte_flow_modify_conntrack {
3433 	/** New connection tracking parameters to be updated. */
3434 	struct rte_flow_action_conntrack new_ct;
3435 	/** The direction field will be updated. */
3436 	uint32_t direction:1;
3437 	/** All the other fields except direction will be updated. */
3438 	uint32_t state:1;
3439 	/** Reserved bits for the future usage. */
3440 	uint32_t reserved:30;
3441 };
3442 
3443 /**
3444  * @warning
3445  * @b EXPERIMENTAL: this structure may change without prior notice
3446  *
3447  * RTE_FLOW_ACTION_TYPE_METER_COLOR
3448  *
3449  * The meter color should be set in the packet meta-data
3450  * (i.e. struct rte_mbuf::sched::color).
3451  */
3452 struct rte_flow_action_meter_color {
3453 	enum rte_color color; /**< Packet color. */
3454 };
3455 
3456 /**
3457  * Provides an ethdev port ID for use with the following actions:
3458  * RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR,
3459  * RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT.
3460  */
3461 struct rte_flow_action_ethdev {
3462 	uint16_t port_id; /**< ethdev port ID */
3463 };
3464 
3465 /**
3466  * Field IDs for MODIFY_FIELD action.
3467  */
3468 enum rte_flow_field_id {
3469 	RTE_FLOW_FIELD_START = 0,	/**< Start of a packet. */
3470 	RTE_FLOW_FIELD_MAC_DST,		/**< Destination MAC Address. */
3471 	RTE_FLOW_FIELD_MAC_SRC,		/**< Source MAC Address. */
3472 	RTE_FLOW_FIELD_VLAN_TYPE,	/**< 802.1Q Tag Identifier. */
3473 	RTE_FLOW_FIELD_VLAN_ID,		/**< 802.1Q VLAN Identifier. */
3474 	RTE_FLOW_FIELD_MAC_TYPE,	/**< EtherType. */
3475 	RTE_FLOW_FIELD_IPV4_DSCP,	/**< IPv4 DSCP. */
3476 	RTE_FLOW_FIELD_IPV4_TTL,	/**< IPv4 Time To Live. */
3477 	RTE_FLOW_FIELD_IPV4_SRC,	/**< IPv4 Source Address. */
3478 	RTE_FLOW_FIELD_IPV4_DST,	/**< IPv4 Destination Address. */
3479 	RTE_FLOW_FIELD_IPV6_DSCP,	/**< IPv6 DSCP. */
3480 	RTE_FLOW_FIELD_IPV6_HOPLIMIT,	/**< IPv6 Hop Limit. */
3481 	RTE_FLOW_FIELD_IPV6_SRC,	/**< IPv6 Source Address. */
3482 	RTE_FLOW_FIELD_IPV6_DST,	/**< IPv6 Destination Address. */
3483 	RTE_FLOW_FIELD_TCP_PORT_SRC,	/**< TCP Source Port Number. */
3484 	RTE_FLOW_FIELD_TCP_PORT_DST,	/**< TCP Destination Port Number. */
3485 	RTE_FLOW_FIELD_TCP_SEQ_NUM,	/**< TCP Sequence Number. */
3486 	RTE_FLOW_FIELD_TCP_ACK_NUM,	/**< TCP Acknowledgment Number. */
3487 	RTE_FLOW_FIELD_TCP_FLAGS,	/**< TCP Flags. */
3488 	RTE_FLOW_FIELD_UDP_PORT_SRC,	/**< UDP Source Port Number. */
3489 	RTE_FLOW_FIELD_UDP_PORT_DST,	/**< UDP Destination Port Number. */
3490 	RTE_FLOW_FIELD_VXLAN_VNI,	/**< VXLAN Network Identifier. */
3491 	RTE_FLOW_FIELD_GENEVE_VNI,	/**< GENEVE Network Identifier. */
3492 	RTE_FLOW_FIELD_GTP_TEID,	/**< GTP Tunnel Endpoint Identifier. */
3493 	RTE_FLOW_FIELD_TAG,		/**< Tag value. */
3494 	RTE_FLOW_FIELD_MARK,		/**< Mark value. */
3495 	RTE_FLOW_FIELD_META,		/**< Metadata value. */
3496 	RTE_FLOW_FIELD_POINTER,		/**< Memory pointer. */
3497 	RTE_FLOW_FIELD_VALUE,		/**< Immediate value. */
3498 	RTE_FLOW_FIELD_IPV4_ECN,	/**< IPv4 ECN. */
3499 	RTE_FLOW_FIELD_IPV6_ECN,	/**< IPv6 ECN. */
3500 	RTE_FLOW_FIELD_GTP_PSC_QFI,	/**< GTP QFI. */
3501 	RTE_FLOW_FIELD_METER_COLOR,	/**< Meter color marker. */
3502 };
3503 
3504 /**
3505  * @warning
3506  * @b EXPERIMENTAL: this structure may change without prior notice
3507  *
3508  * Field description for MODIFY_FIELD action.
3509  */
3510 struct rte_flow_action_modify_data {
3511 	enum rte_flow_field_id field; /**< Field or memory type ID. */
3512 	RTE_STD_C11
3513 	union {
3514 		struct {
3515 			/** Encapsulation level or tag index. */
3516 			uint32_t level;
3517 			/** Number of bits to skip from a field. */
3518 			uint32_t offset;
3519 		};
3520 		/**
3521 		 * Immediate value for RTE_FLOW_FIELD_VALUE, presented in the
3522 		 * same byte order and length as in relevant rte_flow_item_xxx.
3523 		 * The immediate source bitfield offset is inherited from
3524 		 * the destination's one.
3525 		 */
3526 		uint8_t value[16];
3527 		/**
3528 		 * Memory address for RTE_FLOW_FIELD_POINTER, memory layout
3529 		 * should be the same as for relevant field in the
3530 		 * rte_flow_item_xxx structure.
3531 		 */
3532 		void *pvalue;
3533 	};
3534 };
3535 
3536 /**
3537  * Operation types for MODIFY_FIELD action.
3538  */
3539 enum rte_flow_modify_op {
3540 	RTE_FLOW_MODIFY_SET = 0, /**< Set a new value. */
3541 	RTE_FLOW_MODIFY_ADD,     /**< Add a value to a field.  */
3542 	RTE_FLOW_MODIFY_SUB,     /**< Subtract a value from a field. */
3543 };
3544 
3545 /**
3546  * @warning
3547  * @b EXPERIMENTAL: this structure may change without prior notice
3548  *
3549  * RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
3550  *
3551  * Modify a destination header field according to the specified
3552  * operation. Another field of the packet can be used as a source as well
3553  * as tag, mark, metadata, immediate value or a pointer to it.
3554  */
3555 struct rte_flow_action_modify_field {
3556 	enum rte_flow_modify_op operation; /**< Operation to perform. */
3557 	struct rte_flow_action_modify_data dst; /**< Destination field. */
3558 	struct rte_flow_action_modify_data src; /**< Source field. */
3559 	uint32_t width; /**< Number of bits to use from a source field. */
3560 };
3561 
3562 /**
3563  * RTE_FLOW_ACTION_TYPE_METER_MARK
3564  *
3565  * Traffic metering and marking (MTR).
3566  *
3567  * Meters a packet stream and marks its packets either
3568  * green, yellow, or red according to the specified profile.
3569  * The policy is optional and may be specified for defining
3570  * subsequent actions based on a color assigned by MTR.
3571  * Alternatively, the METER_COLOR item may be used for this.
3572  */
3573 struct rte_flow_action_meter_mark {
3574 
3575 	/**< Profile config retrieved with rte_mtr_profile_get(). */
3576 	struct rte_flow_meter_profile *profile;
3577 	/**< Policy config retrieved with rte_mtr_policy_get(). */
3578 	struct rte_flow_meter_policy *policy;
3579 	/** Metering mode: 0 - Color-Blind, 1 - Color-Aware. */
3580 	int color_mode;
3581 	/** Initial Color applied to packets in Color-Aware mode. */
3582 	enum rte_color init_color;
3583 	/** Metering state: 0 - Disabled, 1 - Enabled. */
3584 	int state;
3585 };
3586 
3587 /**
3588  * RTE_FLOW_ACTION_TYPE_METER_MARK
3589  *
3590  * Wrapper structure for the context update interface.
3591  *
3592  */
3593 struct rte_flow_update_meter_mark {
3594 	/** New meter_mark parameters to be updated. */
3595 	struct rte_flow_action_meter_mark meter_mark;
3596 	/** The profile will be updated. */
3597 	uint32_t profile_valid:1;
3598 	/** The policy will be updated. */
3599 	uint32_t policy_valid:1;
3600 	/** The color mode will be updated. */
3601 	uint32_t color_mode_valid:1;
3602 	/** The initial color will be updated. */
3603 	uint32_t init_color_valid:1;
3604 	/** The meter state will be updated. */
3605 	uint32_t state_valid:1;
3606 	/** Reserved bits for the future usage. */
3607 	uint32_t reserved:27;
3608 };
3609 
3610 /* Mbuf dynamic field offset for metadata. */
3611 extern int32_t rte_flow_dynf_metadata_offs;
3612 
3613 /* Mbuf dynamic field flag mask for metadata. */
3614 extern uint64_t rte_flow_dynf_metadata_mask;
3615 
3616 /* Mbuf dynamic field pointer for metadata. */
3617 #define RTE_FLOW_DYNF_METADATA(m) \
3618 	RTE_MBUF_DYNFIELD((m), rte_flow_dynf_metadata_offs, uint32_t *)
3619 
3620 /* Mbuf dynamic flags for metadata. */
3621 #define RTE_MBUF_DYNFLAG_RX_METADATA (rte_flow_dynf_metadata_mask)
3622 #define RTE_MBUF_DYNFLAG_TX_METADATA (rte_flow_dynf_metadata_mask)
3623 
3624 __rte_experimental
3625 static inline uint32_t
3626 rte_flow_dynf_metadata_get(struct rte_mbuf *m)
3627 {
3628 	return *RTE_FLOW_DYNF_METADATA(m);
3629 }
3630 
3631 __rte_experimental
3632 static inline void
3633 rte_flow_dynf_metadata_set(struct rte_mbuf *m, uint32_t v)
3634 {
3635 	*RTE_FLOW_DYNF_METADATA(m) = v;
3636 }
3637 
3638 /**
3639  * Definition of a single action.
3640  *
3641  * A list of actions is terminated by a END action.
3642  *
3643  * For simple actions without a configuration object, conf remains NULL.
3644  */
3645 struct rte_flow_action {
3646 	enum rte_flow_action_type type; /**< Action type. */
3647 	const void *conf; /**< Pointer to action configuration object. */
3648 };
3649 
3650 /**
3651  * Opaque type returned after successfully creating a flow.
3652  *
3653  * This handle can be used to manage and query the related flow (e.g. to
3654  * destroy it or retrieve counters).
3655  */
3656 struct rte_flow;
3657 
3658 /**
3659  * Opaque type for Meter profile object returned by MTR API.
3660  *
3661  * This handle can be used to create Meter actions instead of profile ID.
3662  */
3663 struct rte_flow_meter_profile;
3664 
3665 /**
3666  * Opaque type for Meter policy object returned by MTR API.
3667  *
3668  * This handle can be used to create Meter actions instead of policy ID.
3669  */
3670 struct rte_flow_meter_policy;
3671 
3672 /**
3673  * @warning
3674  * @b EXPERIMENTAL: this structure may change without prior notice
3675  *
3676  * RTE_FLOW_ACTION_TYPE_SAMPLE
3677  *
3678  * Adds a sample action to a matched flow.
3679  *
3680  * The matching packets will be duplicated with specified ratio and applied
3681  * with own set of actions with a fate action, the sampled packet could be
3682  * redirected to queue or port. All the packets continue processing on the
3683  * default flow path.
3684  *
3685  * When the sample ratio is set to 1 then the packets will be 100% mirrored.
3686  * Additional action list be supported to add for sampled or mirrored packets.
3687  */
3688 struct rte_flow_action_sample {
3689 	uint32_t ratio; /**< packets sampled equals to '1/ratio'. */
3690 	/** sub-action list specific for the sampling hit cases. */
3691 	const struct rte_flow_action *actions;
3692 };
3693 
3694 /**
3695  * Verbose error types.
3696  *
3697  * Most of them provide the type of the object referenced by struct
3698  * rte_flow_error.cause.
3699  */
3700 enum rte_flow_error_type {
3701 	RTE_FLOW_ERROR_TYPE_NONE, /**< No error. */
3702 	RTE_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
3703 	RTE_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */
3704 	RTE_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */
3705 	RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */
3706 	RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */
3707 	RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */
3708 	RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */
3709 	RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */
3710 	RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */
3711 	RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */
3712 	RTE_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */
3713 	RTE_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */
3714 	RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */
3715 	RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */
3716 	RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */
3717 	RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */
3718 	RTE_FLOW_ERROR_TYPE_STATE, /**< Current device state. */
3719 };
3720 
3721 /**
3722  * Verbose error structure definition.
3723  *
3724  * This object is normally allocated by applications and set by PMDs, the
3725  * message points to a constant string which does not need to be freed by
3726  * the application, however its pointer can be considered valid only as long
3727  * as its associated DPDK port remains configured. Closing the underlying
3728  * device or unloading the PMD invalidates it.
3729  *
3730  * Both cause and message may be NULL regardless of the error type.
3731  */
3732 struct rte_flow_error {
3733 	enum rte_flow_error_type type; /**< Cause field and error types. */
3734 	const void *cause; /**< Object responsible for the error. */
3735 	const char *message; /**< Human-readable error message. */
3736 };
3737 
3738 /**
3739  * Complete flow rule description.
3740  *
3741  * This object type is used when converting a flow rule description.
3742  *
3743  * @see RTE_FLOW_CONV_OP_RULE
3744  * @see rte_flow_conv()
3745  */
3746 RTE_STD_C11
3747 struct rte_flow_conv_rule {
3748 	union {
3749 		const struct rte_flow_attr *attr_ro; /**< RO attributes. */
3750 		struct rte_flow_attr *attr; /**< Attributes. */
3751 	};
3752 	union {
3753 		const struct rte_flow_item *pattern_ro; /**< RO pattern. */
3754 		struct rte_flow_item *pattern; /**< Pattern items. */
3755 	};
3756 	union {
3757 		const struct rte_flow_action *actions_ro; /**< RO actions. */
3758 		struct rte_flow_action *actions; /**< List of actions. */
3759 	};
3760 };
3761 
3762 /**
3763  * Conversion operations for flow API objects.
3764  *
3765  * @see rte_flow_conv()
3766  */
3767 enum rte_flow_conv_op {
3768 	/**
3769 	 * No operation to perform.
3770 	 *
3771 	 * rte_flow_conv() simply returns 0.
3772 	 */
3773 	RTE_FLOW_CONV_OP_NONE,
3774 
3775 	/**
3776 	 * Convert attributes structure.
3777 	 *
3778 	 * This is a basic copy of an attributes structure.
3779 	 *
3780 	 * - @p src type:
3781 	 *   @code const struct rte_flow_attr * @endcode
3782 	 * - @p dst type:
3783 	 *   @code struct rte_flow_attr * @endcode
3784 	 */
3785 	RTE_FLOW_CONV_OP_ATTR,
3786 
3787 	/**
3788 	 * Convert a single item.
3789 	 *
3790 	 * Duplicates @p spec, @p last and @p mask but not outside objects.
3791 	 *
3792 	 * - @p src type:
3793 	 *   @code const struct rte_flow_item * @endcode
3794 	 * - @p dst type:
3795 	 *   @code struct rte_flow_item * @endcode
3796 	 */
3797 	RTE_FLOW_CONV_OP_ITEM,
3798 
3799 	/**
3800 	 * Convert a single action.
3801 	 *
3802 	 * Duplicates @p conf but not outside objects.
3803 	 *
3804 	 * - @p src type:
3805 	 *   @code const struct rte_flow_action * @endcode
3806 	 * - @p dst type:
3807 	 *   @code struct rte_flow_action * @endcode
3808 	 */
3809 	RTE_FLOW_CONV_OP_ACTION,
3810 
3811 	/**
3812 	 * Convert an entire pattern.
3813 	 *
3814 	 * Duplicates all pattern items at once with the same constraints as
3815 	 * RTE_FLOW_CONV_OP_ITEM.
3816 	 *
3817 	 * - @p src type:
3818 	 *   @code const struct rte_flow_item * @endcode
3819 	 * - @p dst type:
3820 	 *   @code struct rte_flow_item * @endcode
3821 	 */
3822 	RTE_FLOW_CONV_OP_PATTERN,
3823 
3824 	/**
3825 	 * Convert a list of actions.
3826 	 *
3827 	 * Duplicates the entire list of actions at once with the same
3828 	 * constraints as RTE_FLOW_CONV_OP_ACTION.
3829 	 *
3830 	 * - @p src type:
3831 	 *   @code const struct rte_flow_action * @endcode
3832 	 * - @p dst type:
3833 	 *   @code struct rte_flow_action * @endcode
3834 	 */
3835 	RTE_FLOW_CONV_OP_ACTIONS,
3836 
3837 	/**
3838 	 * Convert a complete flow rule description.
3839 	 *
3840 	 * Comprises attributes, pattern and actions together at once with
3841 	 * the usual constraints.
3842 	 *
3843 	 * - @p src type:
3844 	 *   @code const struct rte_flow_conv_rule * @endcode
3845 	 * - @p dst type:
3846 	 *   @code struct rte_flow_conv_rule * @endcode
3847 	 */
3848 	RTE_FLOW_CONV_OP_RULE,
3849 
3850 	/**
3851 	 * Convert item type to its name string.
3852 	 *
3853 	 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
3854 	 * returned value excludes the terminator which is always written
3855 	 * nonetheless.
3856 	 *
3857 	 * - @p src type:
3858 	 *   @code (const void *)enum rte_flow_item_type @endcode
3859 	 * - @p dst type:
3860 	 *   @code char * @endcode
3861 	 **/
3862 	RTE_FLOW_CONV_OP_ITEM_NAME,
3863 
3864 	/**
3865 	 * Convert action type to its name string.
3866 	 *
3867 	 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
3868 	 * returned value excludes the terminator which is always written
3869 	 * nonetheless.
3870 	 *
3871 	 * - @p src type:
3872 	 *   @code (const void *)enum rte_flow_action_type @endcode
3873 	 * - @p dst type:
3874 	 *   @code char * @endcode
3875 	 **/
3876 	RTE_FLOW_CONV_OP_ACTION_NAME,
3877 
3878 	/**
3879 	 * Convert item type to pointer to item name.
3880 	 *
3881 	 * Retrieves item name pointer from its type. The string itself is
3882 	 * not copied; instead, a unique pointer to an internal static
3883 	 * constant storage is written to @p dst.
3884 	 *
3885 	 * - @p src type:
3886 	 *   @code (const void *)enum rte_flow_item_type @endcode
3887 	 * - @p dst type:
3888 	 *   @code const char ** @endcode
3889 	 */
3890 	RTE_FLOW_CONV_OP_ITEM_NAME_PTR,
3891 
3892 	/**
3893 	 * Convert action type to pointer to action name.
3894 	 *
3895 	 * Retrieves action name pointer from its type. The string itself is
3896 	 * not copied; instead, a unique pointer to an internal static
3897 	 * constant storage is written to @p dst.
3898 	 *
3899 	 * - @p src type:
3900 	 *   @code (const void *)enum rte_flow_action_type @endcode
3901 	 * - @p dst type:
3902 	 *   @code const char ** @endcode
3903 	 */
3904 	RTE_FLOW_CONV_OP_ACTION_NAME_PTR,
3905 };
3906 
3907 /**
3908  * @warning
3909  * @b EXPERIMENTAL: this API may change without prior notice.
3910  *
3911  * Dump hardware internal representation information of
3912  * rte flow to file.
3913  *
3914  * @param[in] port_id
3915  *    The port identifier of the Ethernet device.
3916  * @param[in] flow
3917  *   The pointer of flow rule to dump. Dump all rules if NULL.
3918  * @param[in] file
3919  *   A pointer to a file for output.
3920  * @param[out] error
3921  *   Perform verbose error reporting if not NULL. PMDs initialize this
3922  *   structure in case of error only.
3923  * @return
3924  *   0 on success, a negative value otherwise.
3925  */
3926 __rte_experimental
3927 int
3928 rte_flow_dev_dump(uint16_t port_id, struct rte_flow *flow,
3929 		FILE *file, struct rte_flow_error *error);
3930 
3931 /**
3932  * Check if mbuf dynamic field for metadata is registered.
3933  *
3934  * @return
3935  *   True if registered, false otherwise.
3936  */
3937 __rte_experimental
3938 static inline int
3939 rte_flow_dynf_metadata_avail(void)
3940 {
3941 	return !!rte_flow_dynf_metadata_mask;
3942 }
3943 
3944 /**
3945  * Register mbuf dynamic field and flag for metadata.
3946  *
3947  * This function must be called prior to use SET_META action in order to
3948  * register the dynamic mbuf field. Otherwise, the data cannot be delivered to
3949  * application.
3950  *
3951  * @return
3952  *   0 on success, a negative errno value otherwise and rte_errno is set.
3953  */
3954 __rte_experimental
3955 int
3956 rte_flow_dynf_metadata_register(void);
3957 
3958 /**
3959  * Check whether a flow rule can be created on a given port.
3960  *
3961  * The flow rule is validated for correctness and whether it could be accepted
3962  * by the device given sufficient resources. The rule is checked against the
3963  * current device mode and queue configuration. The flow rule may also
3964  * optionally be validated against existing flow rules and device resources.
3965  * This function has no effect on the target device.
3966  *
3967  * The returned value is guaranteed to remain valid only as long as no
3968  * successful calls to rte_flow_create() or rte_flow_destroy() are made in
3969  * the meantime and no device parameter affecting flow rules in any way are
3970  * modified, due to possible collisions or resource limitations (although in
3971  * such cases EINVAL should not be returned).
3972  *
3973  * @param port_id
3974  *   Port identifier of Ethernet device.
3975  * @param[in] attr
3976  *   Flow rule attributes.
3977  * @param[in] pattern
3978  *   Pattern specification (list terminated by the END pattern item).
3979  * @param[in] actions
3980  *   Associated actions (list terminated by the END action).
3981  * @param[out] error
3982  *   Perform verbose error reporting if not NULL. PMDs initialize this
3983  *   structure in case of error only.
3984  *
3985  * @return
3986  *   0 if flow rule is valid and can be created. A negative errno value
3987  *   otherwise (rte_errno is also set), the following errors are defined:
3988  *
3989  *   -ENOSYS: underlying device does not support this functionality.
3990  *
3991  *   -EIO: underlying device is removed.
3992  *
3993  *   -EINVAL: unknown or invalid rule specification.
3994  *
3995  *   -ENOTSUP: valid but unsupported rule specification (e.g. partial
3996  *   bit-masks are unsupported).
3997  *
3998  *   -EEXIST: collision with an existing rule. Only returned if device
3999  *   supports flow rule collision checking and there was a flow rule
4000  *   collision. Not receiving this return code is no guarantee that creating
4001  *   the rule will not fail due to a collision.
4002  *
4003  *   -ENOMEM: not enough memory to execute the function, or if the device
4004  *   supports resource validation, resource limitation on the device.
4005  *
4006  *   -EBUSY: action cannot be performed due to busy device resources, may
4007  *   succeed if the affected queues or even the entire port are in a stopped
4008  *   state (see rte_eth_dev_rx_queue_stop() and rte_eth_dev_stop()).
4009  */
4010 int
4011 rte_flow_validate(uint16_t port_id,
4012 		  const struct rte_flow_attr *attr,
4013 		  const struct rte_flow_item pattern[],
4014 		  const struct rte_flow_action actions[],
4015 		  struct rte_flow_error *error);
4016 
4017 /**
4018  * Create a flow rule on a given port.
4019  *
4020  * @param port_id
4021  *   Port identifier of Ethernet device.
4022  * @param[in] attr
4023  *   Flow rule attributes.
4024  * @param[in] pattern
4025  *   Pattern specification (list terminated by the END pattern item).
4026  * @param[in] actions
4027  *   Associated actions (list terminated by the END action).
4028  * @param[out] error
4029  *   Perform verbose error reporting if not NULL. PMDs initialize this
4030  *   structure in case of error only.
4031  *
4032  * @return
4033  *   A valid handle in case of success, NULL otherwise and rte_errno is set
4034  *   to the positive version of one of the error codes defined for
4035  *   rte_flow_validate().
4036  */
4037 struct rte_flow *
4038 rte_flow_create(uint16_t port_id,
4039 		const struct rte_flow_attr *attr,
4040 		const struct rte_flow_item pattern[],
4041 		const struct rte_flow_action actions[],
4042 		struct rte_flow_error *error);
4043 
4044 /**
4045  * Destroy a flow rule on a given port.
4046  *
4047  * Failure to destroy a flow rule handle may occur when other flow rules
4048  * depend on it, and destroying it would result in an inconsistent state.
4049  *
4050  * This function is only guaranteed to succeed if handles are destroyed in
4051  * reverse order of their creation.
4052  *
4053  * @param port_id
4054  *   Port identifier of Ethernet device.
4055  * @param flow
4056  *   Flow rule handle to destroy.
4057  * @param[out] error
4058  *   Perform verbose error reporting if not NULL. PMDs initialize this
4059  *   structure in case of error only.
4060  *
4061  * @return
4062  *   0 on success, a negative errno value otherwise and rte_errno is set.
4063  */
4064 int
4065 rte_flow_destroy(uint16_t port_id,
4066 		 struct rte_flow *flow,
4067 		 struct rte_flow_error *error);
4068 
4069 /**
4070  * Destroy all flow rules associated with a port.
4071  *
4072  * In the unlikely event of failure, handles are still considered destroyed
4073  * and no longer valid but the port must be assumed to be in an inconsistent
4074  * state.
4075  *
4076  * @param port_id
4077  *   Port identifier of Ethernet device.
4078  * @param[out] error
4079  *   Perform verbose error reporting if not NULL. PMDs initialize this
4080  *   structure in case of error only.
4081  *
4082  * @return
4083  *   0 on success, a negative errno value otherwise and rte_errno is set.
4084  */
4085 int
4086 rte_flow_flush(uint16_t port_id,
4087 	       struct rte_flow_error *error);
4088 
4089 /**
4090  * Query an existing flow rule.
4091  *
4092  * This function allows retrieving flow-specific data such as counters.
4093  * Data is gathered by special actions which must be present in the flow
4094  * rule definition.
4095  *
4096  * \see RTE_FLOW_ACTION_TYPE_COUNT
4097  *
4098  * @param port_id
4099  *   Port identifier of Ethernet device.
4100  * @param flow
4101  *   Flow rule handle to query.
4102  * @param action
4103  *   Action definition as defined in original flow rule.
4104  * @param[in, out] data
4105  *   Pointer to storage for the associated query data type.
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_query(uint16_t port_id,
4115 	       struct rte_flow *flow,
4116 	       const struct rte_flow_action *action,
4117 	       void *data,
4118 	       struct rte_flow_error *error);
4119 
4120 /**
4121  * Restrict ingress traffic to the defined flow rules.
4122  *
4123  * Isolated mode guarantees that all ingress traffic comes from defined flow
4124  * rules only (current and future).
4125  * When enabled with a bifurcated driver,
4126  * non-matched packets are routed to the kernel driver interface.
4127  * When disabled (the default),
4128  * there may be some default rules routing traffic to the DPDK port.
4129  *
4130  * Besides making ingress more deterministic, it allows PMDs to safely reuse
4131  * resources otherwise assigned to handle the remaining traffic, such as
4132  * global RSS configuration settings, VLAN filters, MAC address entries,
4133  * legacy filter API rules and so on in order to expand the set of possible
4134  * flow rule types.
4135  *
4136  * Calling this function as soon as possible after device initialization,
4137  * ideally before the first call to rte_eth_dev_configure(), is recommended
4138  * to avoid possible failures due to conflicting settings.
4139  *
4140  * Once effective, leaving isolated mode may not be possible depending on
4141  * PMD implementation.
4142  *
4143  * Additionally, the following functionality has no effect on the underlying
4144  * port and may return errors such as ENOTSUP ("not supported"):
4145  *
4146  * - Toggling promiscuous mode.
4147  * - Toggling allmulticast mode.
4148  * - Configuring MAC addresses.
4149  * - Configuring multicast addresses.
4150  * - Configuring VLAN filters.
4151  * - Configuring Rx filters through the legacy API (e.g. FDIR).
4152  * - Configuring global RSS settings.
4153  *
4154  * @param port_id
4155  *   Port identifier of Ethernet device.
4156  * @param set
4157  *   Nonzero to enter isolated mode, attempt to leave it otherwise.
4158  * @param[out] error
4159  *   Perform verbose error reporting if not NULL. PMDs initialize this
4160  *   structure in case of error only.
4161  *
4162  * @return
4163  *   0 on success, a negative errno value otherwise and rte_errno is set.
4164  */
4165 int
4166 rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error);
4167 
4168 /**
4169  * Initialize flow error structure.
4170  *
4171  * @param[out] error
4172  *   Pointer to flow error structure (may be NULL).
4173  * @param code
4174  *   Related error code (rte_errno).
4175  * @param type
4176  *   Cause field and error types.
4177  * @param cause
4178  *   Object responsible for the error.
4179  * @param message
4180  *   Human-readable error message.
4181  *
4182  * @return
4183  *   Negative error code (errno value) and rte_errno is set.
4184  */
4185 int
4186 rte_flow_error_set(struct rte_flow_error *error,
4187 		   int code,
4188 		   enum rte_flow_error_type type,
4189 		   const void *cause,
4190 		   const char *message);
4191 
4192 /**
4193  * @deprecated
4194  * @see rte_flow_copy()
4195  */
4196 struct rte_flow_desc {
4197 	size_t size; /**< Allocated space including data[]. */
4198 	struct rte_flow_attr attr; /**< Attributes. */
4199 	struct rte_flow_item *items; /**< Items. */
4200 	struct rte_flow_action *actions; /**< Actions. */
4201 	uint8_t data[]; /**< Storage for items/actions. */
4202 };
4203 
4204 /**
4205  * @deprecated
4206  * Copy an rte_flow rule description.
4207  *
4208  * This interface is kept for compatibility with older applications but is
4209  * implemented as a wrapper to rte_flow_conv(). It is deprecated due to its
4210  * lack of flexibility and reliance on a type unusable with C++ programs
4211  * (struct rte_flow_desc).
4212  *
4213  * @param[in] fd
4214  *   Flow rule description.
4215  * @param[in] len
4216  *   Total size of allocated data for the flow description.
4217  * @param[in] attr
4218  *   Flow rule attributes.
4219  * @param[in] items
4220  *   Pattern specification (list terminated by the END pattern item).
4221  * @param[in] actions
4222  *   Associated actions (list terminated by the END action).
4223  *
4224  * @return
4225  *   If len is greater or equal to the size of the flow, the total size of the
4226  *   flow description and its data.
4227  *   If len is lower than the size of the flow, the number of bytes that would
4228  *   have been written to desc had it been sufficient. Nothing is written.
4229  */
4230 __rte_deprecated
4231 size_t
4232 rte_flow_copy(struct rte_flow_desc *fd, size_t len,
4233 	      const struct rte_flow_attr *attr,
4234 	      const struct rte_flow_item *items,
4235 	      const struct rte_flow_action *actions);
4236 
4237 /**
4238  * Flow object conversion helper.
4239  *
4240  * This function performs conversion of various flow API objects to a
4241  * pre-allocated destination buffer. See enum rte_flow_conv_op for possible
4242  * operations and details about each of them.
4243  *
4244  * Since destination buffer must be large enough, it works in a manner
4245  * reminiscent of snprintf():
4246  *
4247  * - If @p size is 0, @p dst may be a NULL pointer, otherwise @p dst must be
4248  *   non-NULL.
4249  * - If positive, the returned value represents the number of bytes needed
4250  *   to store the conversion of @p src to @p dst according to @p op
4251  *   regardless of the @p size parameter.
4252  * - Since no more than @p size bytes can be written to @p dst, output is
4253  *   truncated and may be inconsistent when the returned value is larger
4254  *   than that.
4255  * - In case of conversion error, a negative error code is returned and
4256  *   @p dst contents are unspecified.
4257  *
4258  * @param op
4259  *   Operation to perform, related to the object type of @p dst.
4260  * @param[out] dst
4261  *   Destination buffer address. Must be suitably aligned by the caller.
4262  * @param size
4263  *   Destination buffer size in bytes.
4264  * @param[in] src
4265  *   Source object to copy. Depending on @p op, its type may differ from
4266  *   that of @p dst.
4267  * @param[out] error
4268  *   Perform verbose error reporting if not NULL. Initialized in case of
4269  *   error only.
4270  *
4271  * @return
4272  *   The number of bytes required to convert @p src to @p dst on success, a
4273  *   negative errno value otherwise and rte_errno is set.
4274  *
4275  * @see rte_flow_conv_op
4276  */
4277 __rte_experimental
4278 int
4279 rte_flow_conv(enum rte_flow_conv_op op,
4280 	      void *dst,
4281 	      size_t size,
4282 	      const void *src,
4283 	      struct rte_flow_error *error);
4284 
4285 /**
4286  * Get aged-out flows of a given port.
4287  *
4288  * RTE_ETH_EVENT_FLOW_AGED event will be triggered when at least one new aged
4289  * out flow was detected after the last call to rte_flow_get_aged_flows.
4290  * This function can be called to get the aged flows asynchronously from the
4291  * event callback or synchronously regardless the event.
4292  * This is not safe to call rte_flow_get_aged_flows function with other flow
4293  * functions from multiple threads simultaneously.
4294  *
4295  * @param port_id
4296  *   Port identifier of Ethernet device.
4297  * @param[in, out] contexts
4298  *   The address of an array of pointers to the aged-out flows contexts.
4299  * @param[in] nb_contexts
4300  *   The length of context array pointers.
4301  * @param[out] error
4302  *   Perform verbose error reporting if not NULL. Initialized in case of
4303  *   error only.
4304  *
4305  * @return
4306  *   if nb_contexts is 0, return the amount of all aged contexts.
4307  *   if nb_contexts is not 0 , return the amount of aged flows reported
4308  *   in the context array, otherwise negative errno value.
4309  *
4310  * @see rte_flow_action_age
4311  * @see RTE_ETH_EVENT_FLOW_AGED
4312  */
4313 __rte_experimental
4314 int
4315 rte_flow_get_aged_flows(uint16_t port_id, void **contexts,
4316 			uint32_t nb_contexts, struct rte_flow_error *error);
4317 
4318 /**
4319  * @warning
4320  * @b EXPERIMENTAL: this API may change without prior notice.
4321  *
4322  * Get aged-out flows of a given port on the given flow queue.
4323  *
4324  * If application configure port attribute with RTE_FLOW_PORT_FLAG_STRICT_QUEUE,
4325  * there is no RTE_ETH_EVENT_FLOW_AGED event and this function must be called to
4326  * get the aged flows synchronously.
4327  *
4328  * If application configure port attribute without
4329  * RTE_FLOW_PORT_FLAG_STRICT_QUEUE, RTE_ETH_EVENT_FLOW_AGED event will be
4330  * triggered at least one new aged out flow was detected on any flow queue after
4331  * the last call to rte_flow_get_q_aged_flows.
4332  * In addition, the @p queue_id will be ignored.
4333  * This function can be called to get the aged flows asynchronously from the
4334  * event callback or synchronously regardless the event.
4335  *
4336  * @param[in] port_id
4337  *   Port identifier of Ethernet device.
4338  * @param[in] queue_id
4339  *   Flow queue to query. Ignored when RTE_FLOW_PORT_FLAG_STRICT_QUEUE not set.
4340  * @param[in, out] contexts
4341  *   The address of an array of pointers to the aged-out flows contexts.
4342  * @param[in] nb_contexts
4343  *   The length of context array pointers.
4344  * @param[out] error
4345  *   Perform verbose error reporting if not NULL. Initialized in case of
4346  *   error only.
4347  *
4348  * @return
4349  *   if nb_contexts is 0, return the amount of all aged contexts.
4350  *   if nb_contexts is not 0 , return the amount of aged flows reported
4351  *   in the context array, otherwise negative errno value.
4352  *
4353  * @see rte_flow_action_age
4354  * @see RTE_ETH_EVENT_FLOW_AGED
4355  * @see rte_flow_port_flag
4356  */
4357 __rte_experimental
4358 int
4359 rte_flow_get_q_aged_flows(uint16_t port_id, uint32_t queue_id, void **contexts,
4360 			  uint32_t nb_contexts, struct rte_flow_error *error);
4361 
4362 /**
4363  * Specify indirect action object configuration
4364  */
4365 struct rte_flow_indir_action_conf {
4366 	/**
4367 	 * Flow direction for the indirect action configuration.
4368 	 *
4369 	 * Action should be valid at least for one flow direction,
4370 	 * otherwise it is invalid for both ingress and egress rules.
4371 	 */
4372 	/** Action valid for rules applied to ingress traffic. */
4373 	uint32_t ingress:1;
4374 	/** Action valid for rules applied to egress traffic. */
4375 	uint32_t egress:1;
4376 	/**
4377 	 * When set to 1, indicates that the action is valid for
4378 	 * transfer traffic; otherwise, for non-transfer traffic.
4379 	 */
4380 	uint32_t transfer:1;
4381 };
4382 
4383 /**
4384  * @warning
4385  * @b EXPERIMENTAL: this API may change without prior notice.
4386  *
4387  * Create an indirect action object that can be used in flow rules
4388  * via its handle.
4389  * The created object handle has single state and configuration
4390  * across all the flow rules using it.
4391  *
4392  * @param[in] port_id
4393  *    The port identifier of the Ethernet device.
4394  * @param[in] conf
4395  *   Action configuration for the indirect action object creation.
4396  * @param[in] action
4397  *   Specific configuration of the indirect action object.
4398  * @param[out] error
4399  *   Perform verbose error reporting if not NULL. PMDs initialize this
4400  *   structure in case of error only.
4401  * @return
4402  *   A valid handle in case of success, NULL otherwise and rte_errno is set
4403  *   to one of the error codes defined:
4404  *   - (ENODEV) if *port_id* invalid.
4405  *   - (ENOSYS) if underlying device does not support this functionality.
4406  *   - (EIO) if underlying device is removed.
4407  *   - (EINVAL) if *action* invalid.
4408  *   - (ENOTSUP) if *action* valid but unsupported.
4409  */
4410 __rte_experimental
4411 struct rte_flow_action_handle *
4412 rte_flow_action_handle_create(uint16_t port_id,
4413 			      const struct rte_flow_indir_action_conf *conf,
4414 			      const struct rte_flow_action *action,
4415 			      struct rte_flow_error *error);
4416 
4417 /**
4418  * @warning
4419  * @b EXPERIMENTAL: this API may change without prior notice.
4420  *
4421  * Destroy indirect action by handle.
4422  *
4423  * @param[in] port_id
4424  *    The port identifier of the Ethernet device.
4425  * @param[in] handle
4426  *   Handle for the indirect action object to be destroyed.
4427  * @param[out] error
4428  *   Perform verbose error reporting if not NULL. PMDs initialize this
4429  *   structure in case of error only.
4430  * @return
4431  *   - (0) if success.
4432  *   - (-ENODEV) if *port_id* invalid.
4433  *   - (-ENOSYS) if underlying device does not support this functionality.
4434  *   - (-EIO) if underlying device is removed.
4435  *   - (-ENOENT) if action pointed by *action* handle was not found.
4436  *   - (-EBUSY) if action pointed by *action* handle still used by some rules
4437  *   rte_errno is also set.
4438  */
4439 __rte_experimental
4440 int
4441 rte_flow_action_handle_destroy(uint16_t port_id,
4442 			       struct rte_flow_action_handle *handle,
4443 			       struct rte_flow_error *error);
4444 
4445 /**
4446  * @warning
4447  * @b EXPERIMENTAL: this API may change without prior notice.
4448  *
4449  * Update in-place the action configuration and / or state pointed
4450  * by action *handle* with the configuration provided as *update* argument.
4451  * The update of the action configuration effects all flow rules reusing
4452  * the action via *handle*.
4453  * The update general pointer provides the ability of partial updating.
4454  *
4455  * @param[in] port_id
4456  *    The port identifier of the Ethernet device.
4457  * @param[in] handle
4458  *   Handle for the indirect action object to be updated.
4459  * @param[in] update
4460  *   Update profile specification used to modify the action pointed by handle.
4461  *   *update* could be with the same type of the immediate action corresponding
4462  *   to the *handle* argument when creating, or a wrapper structure includes
4463  *   action configuration to be updated and bit fields to indicate the member
4464  *   of fields inside the action to update.
4465  * @param[out] error
4466  *   Perform verbose error reporting if not NULL. PMDs initialize this
4467  *   structure in case of error only.
4468  * @return
4469  *   - (0) if success.
4470  *   - (-ENODEV) if *port_id* invalid.
4471  *   - (-ENOSYS) if underlying device does not support this functionality.
4472  *   - (-EIO) if underlying device is removed.
4473  *   - (-EINVAL) if *update* invalid.
4474  *   - (-ENOTSUP) if *update* valid but unsupported.
4475  *   - (-ENOENT) if indirect action object pointed by *handle* was not found.
4476  *   rte_errno is also set.
4477  */
4478 __rte_experimental
4479 int
4480 rte_flow_action_handle_update(uint16_t port_id,
4481 			      struct rte_flow_action_handle *handle,
4482 			      const void *update,
4483 			      struct rte_flow_error *error);
4484 
4485 /**
4486  * @warning
4487  * @b EXPERIMENTAL: this API may change without prior notice.
4488  *
4489  * Query the direct action by corresponding indirect action object handle.
4490  *
4491  * Retrieve action-specific data such as counters.
4492  * Data is gathered by special action which may be present/referenced in
4493  * more than one flow rule definition.
4494  *
4495  * @see RTE_FLOW_ACTION_TYPE_COUNT
4496  *
4497  * @param port_id
4498  *   Port identifier of Ethernet device.
4499  * @param[in] handle
4500  *   Handle for the action object to query.
4501  * @param[in, out] data
4502  *   Pointer to storage for the associated query data type.
4503  * @param[out] error
4504  *   Perform verbose error reporting if not NULL. PMDs initialize this
4505  *   structure in case of error only.
4506  *
4507  * @return
4508  *   0 on success, a negative errno value otherwise and rte_errno is set.
4509  */
4510 __rte_experimental
4511 int
4512 rte_flow_action_handle_query(uint16_t port_id,
4513 			     const struct rte_flow_action_handle *handle,
4514 			     void *data, struct rte_flow_error *error);
4515 
4516 /* Tunnel has a type and the key information. */
4517 struct rte_flow_tunnel {
4518 	/**
4519 	 * Tunnel type, for example RTE_FLOW_ITEM_TYPE_VXLAN,
4520 	 * RTE_FLOW_ITEM_TYPE_NVGRE etc.
4521 	 */
4522 	enum rte_flow_item_type	type;
4523 	uint64_t tun_id; /**< Tunnel identification. */
4524 
4525 	RTE_STD_C11
4526 	union {
4527 		struct {
4528 			rte_be32_t src_addr; /**< IPv4 source address. */
4529 			rte_be32_t dst_addr; /**< IPv4 destination address. */
4530 		} ipv4;
4531 		struct {
4532 			uint8_t src_addr[16]; /**< IPv6 source address. */
4533 			uint8_t dst_addr[16]; /**< IPv6 destination address. */
4534 		} ipv6;
4535 	};
4536 	rte_be16_t tp_src; /**< Tunnel port source. */
4537 	rte_be16_t tp_dst; /**< Tunnel port destination. */
4538 	uint16_t   tun_flags; /**< Tunnel flags. */
4539 
4540 	bool       is_ipv6; /**< True for valid IPv6 fields. Otherwise IPv4. */
4541 
4542 	/**
4543 	 * the following members are required to restore packet
4544 	 * after miss
4545 	 */
4546 	uint8_t    tos; /**< TOS for IPv4, TC for IPv6. */
4547 	uint8_t    ttl; /**< TTL for IPv4, HL for IPv6. */
4548 	uint32_t label; /**< Flow Label for IPv6. */
4549 };
4550 
4551 /**
4552  * Indicate that the packet has a tunnel.
4553  */
4554 #define RTE_FLOW_RESTORE_INFO_TUNNEL RTE_BIT64(0)
4555 
4556 /**
4557  * Indicate that the packet has a non decapsulated tunnel header.
4558  */
4559 #define RTE_FLOW_RESTORE_INFO_ENCAPSULATED RTE_BIT64(1)
4560 
4561 /**
4562  * Indicate that the packet has a group_id.
4563  */
4564 #define RTE_FLOW_RESTORE_INFO_GROUP_ID RTE_BIT64(2)
4565 
4566 /**
4567  * Restore information structure to communicate the current packet processing
4568  * state when some of the processing pipeline is done in hardware and should
4569  * continue in software.
4570  */
4571 struct rte_flow_restore_info {
4572 	/**
4573 	 * Bitwise flags (RTE_FLOW_RESTORE_INFO_*) to indicate validation of
4574 	 * other fields in struct rte_flow_restore_info.
4575 	 */
4576 	uint64_t flags;
4577 	uint32_t group_id; /**< Group ID where packed missed */
4578 	struct rte_flow_tunnel tunnel; /**< Tunnel information. */
4579 };
4580 
4581 /**
4582  * Allocate an array of actions to be used in rte_flow_create, to implement
4583  * tunnel-decap-set for the given tunnel.
4584  * Sample usage:
4585  *   actions vxlan_decap / tunnel-decap-set(tunnel properties) /
4586  *            jump group 0 / end
4587  *
4588  * @param port_id
4589  *   Port identifier of Ethernet device.
4590  * @param[in] tunnel
4591  *   Tunnel properties.
4592  * @param[out] actions
4593  *   Array of actions to be allocated by the PMD. This array should be
4594  *   concatenated with the actions array provided to rte_flow_create.
4595  * @param[out] num_of_actions
4596  *   Number of actions allocated.
4597  * @param[out] error
4598  *   Perform verbose error reporting if not NULL. PMDs initialize this
4599  *   structure in case of error only.
4600  *
4601  * @return
4602  *   0 on success, a negative errno value otherwise and rte_errno is set.
4603  */
4604 __rte_experimental
4605 int
4606 rte_flow_tunnel_decap_set(uint16_t port_id,
4607 			  struct rte_flow_tunnel *tunnel,
4608 			  struct rte_flow_action **actions,
4609 			  uint32_t *num_of_actions,
4610 			  struct rte_flow_error *error);
4611 
4612 /**
4613  * Allocate an array of items to be used in rte_flow_create, to implement
4614  * tunnel-match for the given tunnel.
4615  * Sample usage:
4616  *   pattern tunnel-match(tunnel properties) / outer-header-matches /
4617  *           inner-header-matches / end
4618  *
4619  * @param port_id
4620  *   Port identifier of Ethernet device.
4621  * @param[in] tunnel
4622  *   Tunnel properties.
4623  * @param[out] items
4624  *   Array of items to be allocated by the PMD. This array should be
4625  *   concatenated with the items array provided to rte_flow_create.
4626  * @param[out] num_of_items
4627  *   Number of items allocated.
4628  * @param[out] error
4629  *   Perform verbose error reporting if not NULL. PMDs initialize this
4630  *   structure in case of error only.
4631  *
4632  * @return
4633  *   0 on success, a negative errno value otherwise and rte_errno is set.
4634  */
4635 __rte_experimental
4636 int
4637 rte_flow_tunnel_match(uint16_t port_id,
4638 		      struct rte_flow_tunnel *tunnel,
4639 		      struct rte_flow_item **items,
4640 		      uint32_t *num_of_items,
4641 		      struct rte_flow_error *error);
4642 
4643 /**
4644  * Populate the current packet processing state, if exists, for the given mbuf.
4645  *
4646  * One should negotiate tunnel metadata delivery from the NIC to the HW.
4647  * @see rte_eth_rx_metadata_negotiate()
4648  * @see RTE_ETH_RX_METADATA_TUNNEL_ID
4649  *
4650  * @param port_id
4651  *   Port identifier of Ethernet device.
4652  * @param[in] m
4653  *   Mbuf struct.
4654  * @param[out] info
4655  *   Restore information. Upon success contains the HW state.
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_get_restore_info(uint16_t port_id,
4666 			  struct rte_mbuf *m,
4667 			  struct rte_flow_restore_info *info,
4668 			  struct rte_flow_error *error);
4669 
4670 /**
4671  * Release the action array as allocated by rte_flow_tunnel_decap_set.
4672  *
4673  * @param port_id
4674  *   Port identifier of Ethernet device.
4675  * @param[in] actions
4676  *   Array of actions to be released.
4677  * @param[in] num_of_actions
4678  *   Number of elements in actions array.
4679  * @param[out] error
4680  *   Perform verbose error reporting if not NULL. PMDs initialize this
4681  *   structure in case of error only.
4682  *
4683  * @return
4684  *   0 on success, a negative errno value otherwise and rte_errno is set.
4685  */
4686 __rte_experimental
4687 int
4688 rte_flow_tunnel_action_decap_release(uint16_t port_id,
4689 				     struct rte_flow_action *actions,
4690 				     uint32_t num_of_actions,
4691 				     struct rte_flow_error *error);
4692 
4693 /**
4694  * Release the item array as allocated by rte_flow_tunnel_match.
4695  *
4696  * @param port_id
4697  *   Port identifier of Ethernet device.
4698  * @param[in] items
4699  *   Array of items to be released.
4700  * @param[in] num_of_items
4701  *   Number of elements in item array.
4702  * @param[out] error
4703  *   Perform verbose error reporting if not NULL. PMDs initialize this
4704  *   structure in case of error only.
4705  *
4706  * @return
4707  *   0 on success, a negative errno value otherwise and rte_errno is set.
4708  */
4709 __rte_experimental
4710 int
4711 rte_flow_tunnel_item_release(uint16_t port_id,
4712 			     struct rte_flow_item *items,
4713 			     uint32_t num_of_items,
4714 			     struct rte_flow_error *error);
4715 
4716 /**
4717  * Get a proxy port to manage "transfer" flows.
4718  *
4719  * Managing "transfer" flows requires that the user communicate them
4720  * via a port which has the privilege to control the embedded switch.
4721  * For some vendors, all ports in a given switching domain have
4722  * this privilege. For other vendors, it's only one port.
4723  *
4724  * This API indicates such a privileged port (a "proxy")
4725  * for a given port in the same switching domain.
4726  *
4727  * @note
4728  *   If the PMD serving @p port_id doesn't have the corresponding method
4729  *   implemented, the API will return @p port_id via @p proxy_port_id.
4730  *
4731  * @param port_id
4732  *   Indicates the port to get a "proxy" for
4733  * @param[out] proxy_port_id
4734  *   Indicates the "proxy" port
4735  * @param[out] error
4736  *   If not NULL, allows the PMD to provide verbose report in case of error
4737  *
4738  * @return
4739  *   0 on success, a negative error code otherwise
4740  */
4741 int
4742 rte_flow_pick_transfer_proxy(uint16_t port_id, uint16_t *proxy_port_id,
4743 			     struct rte_flow_error *error);
4744 
4745 /**
4746  * @warning
4747  * @b EXPERIMENTAL: this API may change without prior notice.
4748  *
4749  * Create the flex item with specified configuration over
4750  * the Ethernet device.
4751  *
4752  * @param port_id
4753  *   Port identifier of Ethernet device.
4754  * @param[in] conf
4755  *   Item configuration.
4756  * @param[out] error
4757  *   Perform verbose error reporting if not NULL. PMDs initialize this
4758  *   structure in case of error only.
4759  *
4760  * @return
4761  *   Non-NULL opaque pointer on success, NULL otherwise and rte_errno is set.
4762  */
4763 __rte_experimental
4764 struct rte_flow_item_flex_handle *
4765 rte_flow_flex_item_create(uint16_t port_id,
4766 			  const struct rte_flow_item_flex_conf *conf,
4767 			  struct rte_flow_error *error);
4768 
4769 /**
4770  * Release the flex item on the specified Ethernet device.
4771  *
4772  * @param port_id
4773  *   Port identifier of Ethernet device.
4774  * @param[in] handle
4775  *   Handle of the item existing on the specified device.
4776  * @param[out] error
4777  *   Perform verbose error reporting if not NULL. PMDs initialize this
4778  *   structure in case of error only.
4779  *
4780  * @return
4781  *   0 on success, a negative errno value otherwise and rte_errno is set.
4782  */
4783 __rte_experimental
4784 int
4785 rte_flow_flex_item_release(uint16_t port_id,
4786 			   const struct rte_flow_item_flex_handle *handle,
4787 			   struct rte_flow_error *error);
4788 
4789 /**
4790  * Indicate all operations for a given flow rule will _strictly_
4791  * happen on the same queue (create/destroy/query/update).
4792  */
4793 #define RTE_FLOW_PORT_FLAG_STRICT_QUEUE RTE_BIT32(0)
4794 
4795 /**
4796  * @warning
4797  * @b EXPERIMENTAL: this API may change without prior notice.
4798  *
4799  * Information about flow engine resources.
4800  * The zero value means a resource is not supported.
4801  *
4802  */
4803 struct rte_flow_port_info {
4804 	/**
4805 	 * Maximum number of queues for asynchronous operations.
4806 	 */
4807 	uint32_t max_nb_queues;
4808 	/**
4809 	 * Maximum number of counters.
4810 	 * @see RTE_FLOW_ACTION_TYPE_COUNT
4811 	 */
4812 	uint32_t max_nb_counters;
4813 	/**
4814 	 * Maximum number of aging objects.
4815 	 * @see RTE_FLOW_ACTION_TYPE_AGE
4816 	 */
4817 	uint32_t max_nb_aging_objects;
4818 	/**
4819 	 * Maximum number traffic meters.
4820 	 * @see RTE_FLOW_ACTION_TYPE_METER
4821 	 */
4822 	uint32_t max_nb_meters;
4823 	/**
4824 	 * Maximum number connection trackings.
4825 	 * @see RTE_FLOW_ACTION_TYPE_CONNTRACK
4826 	 */
4827 	uint32_t max_nb_conn_tracks;
4828 	/**
4829 	 * Port supported flags (RTE_FLOW_PORT_FLAG_*).
4830 	 */
4831 	uint32_t supported_flags;
4832 };
4833 
4834 /**
4835  * @warning
4836  * @b EXPERIMENTAL: this API may change without prior notice.
4837  *
4838  * Information about flow engine asynchronous queues.
4839  * The value only valid if @p port_attr.max_nb_queues is not zero.
4840  *
4841  */
4842 struct rte_flow_queue_info {
4843 	/**
4844 	 * Maximum number of operations a queue can hold.
4845 	 */
4846 	uint32_t max_size;
4847 };
4848 
4849 /**
4850  * @warning
4851  * @b EXPERIMENTAL: this API may change without prior notice.
4852  *
4853  * Get information about flow engine resources.
4854  *
4855  * @param port_id
4856  *   Port identifier of Ethernet device.
4857  * @param[out] port_info
4858  *   A pointer to a structure of type *rte_flow_port_info*
4859  *   to be filled with the resources information of the port.
4860  * @param[out] queue_info
4861  *   A pointer to a structure of type *rte_flow_queue_info*
4862  *   to be filled with the asynchronous queues information.
4863  * @param[out] error
4864  *   Perform verbose error reporting if not NULL.
4865  *   PMDs initialize this structure in case of error only.
4866  *
4867  * @return
4868  *   0 on success, a negative errno value otherwise and rte_errno is set.
4869  */
4870 __rte_experimental
4871 int
4872 rte_flow_info_get(uint16_t port_id,
4873 		  struct rte_flow_port_info *port_info,
4874 		  struct rte_flow_queue_info *queue_info,
4875 		  struct rte_flow_error *error);
4876 
4877 /**
4878  * @warning
4879  * @b EXPERIMENTAL: this API may change without prior notice.
4880  *
4881  * Flow engine resources settings.
4882  * The zero value means on demand resource allocations only.
4883  *
4884  */
4885 struct rte_flow_port_attr {
4886 	/**
4887 	 * Number of counters to configure.
4888 	 * @see RTE_FLOW_ACTION_TYPE_COUNT
4889 	 */
4890 	uint32_t nb_counters;
4891 	/**
4892 	 * Number of aging objects to configure.
4893 	 * @see RTE_FLOW_ACTION_TYPE_AGE
4894 	 */
4895 	uint32_t nb_aging_objects;
4896 	/**
4897 	 * Number of traffic meters to configure.
4898 	 * @see RTE_FLOW_ACTION_TYPE_METER
4899 	 */
4900 	uint32_t nb_meters;
4901 	/**
4902 	 * Number of connection trackings to configure.
4903 	 * @see RTE_FLOW_ACTION_TYPE_CONNTRACK
4904 	 */
4905 	uint32_t nb_conn_tracks;
4906 	/**
4907 	 * Port flags (RTE_FLOW_PORT_FLAG_*).
4908 	 */
4909 	uint32_t flags;
4910 };
4911 
4912 /**
4913  * @warning
4914  * @b EXPERIMENTAL: this API may change without prior notice.
4915  *
4916  * Flow engine asynchronous queues settings.
4917  * The value means default value picked by PMD.
4918  *
4919  */
4920 struct rte_flow_queue_attr {
4921 	/**
4922 	 * Number of flow rule operations a queue can hold.
4923 	 */
4924 	uint32_t size;
4925 };
4926 
4927 /**
4928  * @warning
4929  * @b EXPERIMENTAL: this API may change without prior notice.
4930  *
4931  * Configure the port's flow API engine.
4932  *
4933  * This API can only be invoked before the application
4934  * starts using the rest of the flow library functions.
4935  *
4936  * The API can be invoked multiple times to change the settings.
4937  * The port, however, may reject changes and keep the old config.
4938  *
4939  * Parameters in configuration attributes must not exceed
4940  * numbers of resources returned by the rte_flow_info_get API.
4941  *
4942  * @param port_id
4943  *   Port identifier of Ethernet device.
4944  * @param[in] port_attr
4945  *   Port configuration attributes.
4946  * @param[in] nb_queue
4947  *   Number of flow queues to be configured.
4948  * @param[in] queue_attr
4949  *   Array that holds attributes for each flow queue.
4950  *   Number of elements is set in @p port_attr.nb_queues.
4951  * @param[out] error
4952  *   Perform verbose error reporting if not NULL.
4953  *   PMDs initialize this structure in case of error only.
4954  *
4955  * @return
4956  *   0 on success, a negative errno value otherwise and rte_errno is set.
4957  */
4958 __rte_experimental
4959 int
4960 rte_flow_configure(uint16_t port_id,
4961 		   const struct rte_flow_port_attr *port_attr,
4962 		   uint16_t nb_queue,
4963 		   const struct rte_flow_queue_attr *queue_attr[],
4964 		   struct rte_flow_error *error);
4965 
4966 /**
4967  * Opaque type returned after successful creation of pattern template.
4968  * This handle can be used to manage the created pattern template.
4969  */
4970 struct rte_flow_pattern_template;
4971 
4972 /**
4973  * @warning
4974  * @b EXPERIMENTAL: this API may change without prior notice.
4975  *
4976  * Flow pattern template attributes.
4977  */
4978 __extension__
4979 struct rte_flow_pattern_template_attr {
4980 	/**
4981 	 * Relaxed matching policy.
4982 	 * - If 1, matching is performed only on items with the mask member set
4983 	 * and matching on protocol layers specified without any masks is skipped.
4984 	 * - If 0, matching on protocol layers specified without any masks is done
4985 	 * as well. This is the standard behaviour of Flow API now.
4986 	 */
4987 	uint32_t relaxed_matching:1;
4988 	/**
4989 	 * Flow direction for the pattern template.
4990 	 * At least one direction must be specified.
4991 	 */
4992 	/** Pattern valid for rules applied to ingress traffic. */
4993 	uint32_t ingress:1;
4994 	/** Pattern valid for rules applied to egress traffic. */
4995 	uint32_t egress:1;
4996 	/** Pattern valid for rules applied to transfer traffic. */
4997 	uint32_t transfer:1;
4998 };
4999 
5000 /**
5001  * @warning
5002  * @b EXPERIMENTAL: this API may change without prior notice.
5003  *
5004  * Create flow pattern template.
5005  *
5006  * The pattern template defines common matching fields without values.
5007  * For example, matching on 5 tuple TCP flow, the template will be
5008  * eth(null) + IPv4(source + dest) + TCP(s_port + d_port),
5009  * while values for each rule will be set during the flow rule creation.
5010  * The number and order of items in the template must be the same
5011  * at the rule creation.
5012  *
5013  * @param port_id
5014  *   Port identifier of Ethernet device.
5015  * @param[in] template_attr
5016  *   Pattern template attributes.
5017  * @param[in] pattern
5018  *   Pattern specification (list terminated by the END pattern item).
5019  *   The spec member of an item is not used unless the end member is used.
5020  * @param[out] error
5021  *   Perform verbose error reporting if not NULL.
5022  *   PMDs initialize this structure in case of error only.
5023  *
5024  * @return
5025  *   Handle on success, NULL otherwise and rte_errno is set.
5026  */
5027 __rte_experimental
5028 struct rte_flow_pattern_template *
5029 rte_flow_pattern_template_create(uint16_t port_id,
5030 		const struct rte_flow_pattern_template_attr *template_attr,
5031 		const struct rte_flow_item pattern[],
5032 		struct rte_flow_error *error);
5033 
5034 /**
5035  * @warning
5036  * @b EXPERIMENTAL: this API may change without prior notice.
5037  *
5038  * Destroy flow pattern template.
5039  *
5040  * This function may be called only when
5041  * there are no more tables referencing this template.
5042  *
5043  * @param port_id
5044  *   Port identifier of Ethernet device.
5045  * @param[in] pattern_template
5046  *   Handle of the template to be destroyed.
5047  * @param[out] error
5048  *   Perform verbose error reporting if not NULL.
5049  *   PMDs initialize this structure in case of error only.
5050  *
5051  * @return
5052  *   0 on success, a negative errno value otherwise and rte_errno is set.
5053  */
5054 __rte_experimental
5055 int
5056 rte_flow_pattern_template_destroy(uint16_t port_id,
5057 		struct rte_flow_pattern_template *pattern_template,
5058 		struct rte_flow_error *error);
5059 
5060 /**
5061  * Opaque type returned after successful creation of actions template.
5062  * This handle can be used to manage the created actions template.
5063  */
5064 struct rte_flow_actions_template;
5065 
5066 /**
5067  * @warning
5068  * @b EXPERIMENTAL: this API may change without prior notice.
5069  *
5070  * Flow actions template attributes.
5071  */
5072 __extension__
5073 struct rte_flow_actions_template_attr {
5074 	/**
5075 	 * Flow direction for the actions template.
5076 	 * At least one direction must be specified.
5077 	 */
5078 	/** Action valid for rules applied to ingress traffic. */
5079 	uint32_t ingress:1;
5080 	/** Action valid for rules applied to egress traffic. */
5081 	uint32_t egress:1;
5082 	/** Action valid for rules applied to transfer traffic. */
5083 	uint32_t transfer:1;
5084 };
5085 
5086 /**
5087  * @warning
5088  * @b EXPERIMENTAL: this API may change without prior notice.
5089  *
5090  * Create flow actions template.
5091  *
5092  * The actions template holds a list of action types without values.
5093  * For example, the template to change TCP ports is TCP(s_port + d_port),
5094  * while values for each rule will be set during the flow rule creation.
5095  * The number and order of actions in the template must be the same
5096  * at the rule creation.
5097  *
5098  * @param port_id
5099  *   Port identifier of Ethernet device.
5100  * @param[in] template_attr
5101  *   Template attributes.
5102  * @param[in] actions
5103  *   Associated actions (list terminated by the END action).
5104  *   The spec member is only used if @p masks spec is non-zero.
5105  * @param[in] masks
5106  *   List of actions that marks which of the action's member is constant.
5107  *   A mask has the same format as the corresponding action.
5108  *   If the action field in @p masks is not 0,
5109  *   the corresponding value in an action from @p actions will be the part
5110  *   of the template and used in all flow rules.
5111  *   The order of actions in @p masks is the same as in @p actions.
5112  *   In case of indirect actions present in @p actions,
5113  *   the actual action type should be present in @p mask.
5114  * @param[out] error
5115  *   Perform verbose error reporting if not NULL.
5116  *   PMDs initialize this structure in case of error only.
5117  *
5118  * @return
5119  *   Handle on success, NULL otherwise and rte_errno is set.
5120  */
5121 __rte_experimental
5122 struct rte_flow_actions_template *
5123 rte_flow_actions_template_create(uint16_t port_id,
5124 		const struct rte_flow_actions_template_attr *template_attr,
5125 		const struct rte_flow_action actions[],
5126 		const struct rte_flow_action masks[],
5127 		struct rte_flow_error *error);
5128 
5129 /**
5130  * @warning
5131  * @b EXPERIMENTAL: this API may change without prior notice.
5132  *
5133  * Destroy flow actions template.
5134  *
5135  * This function may be called only when
5136  * there are no more tables referencing this template.
5137  *
5138  * @param port_id
5139  *   Port identifier of Ethernet device.
5140  * @param[in] actions_template
5141  *   Handle to the template to be destroyed.
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  *   0 on success, a negative errno value otherwise and rte_errno is set.
5148  */
5149 __rte_experimental
5150 int
5151 rte_flow_actions_template_destroy(uint16_t port_id,
5152 		struct rte_flow_actions_template *actions_template,
5153 		struct rte_flow_error *error);
5154 
5155 /**
5156  * Opaque type returned after successful creation of a template table.
5157  * This handle can be used to manage the created template table.
5158  */
5159 struct rte_flow_template_table;
5160 
5161 /**
5162  * @warning
5163  * @b EXPERIMENTAL: this API may change without prior notice.
5164  *
5165  * Table attributes.
5166  */
5167 struct rte_flow_template_table_attr {
5168 	/**
5169 	 * Flow attributes to be used in each rule generated from this table.
5170 	 */
5171 	struct rte_flow_attr flow_attr;
5172 	/**
5173 	 * Maximum number of flow rules that this table holds.
5174 	 */
5175 	uint32_t nb_flows;
5176 };
5177 
5178 /**
5179  * @warning
5180  * @b EXPERIMENTAL: this API may change without prior notice.
5181  *
5182  * Create flow template table.
5183  *
5184  * A template table consists of multiple pattern templates and actions
5185  * templates associated with a single set of rule attributes (group ID,
5186  * priority and traffic direction).
5187  *
5188  * Each rule is free to use any combination of pattern and actions templates
5189  * and specify particular values for items and actions it would like to change.
5190  *
5191  * @param port_id
5192  *   Port identifier of Ethernet device.
5193  * @param[in] table_attr
5194  *   Template table attributes.
5195  * @param[in] pattern_templates
5196  *   Array of pattern templates to be used in this table.
5197  * @param[in] nb_pattern_templates
5198  *   The number of pattern templates in the pattern_templates array.
5199  * @param[in] actions_templates
5200  *   Array of actions templates to be used in this table.
5201  * @param[in] nb_actions_templates
5202  *   The number of actions templates in the actions_templates array.
5203  * @param[out] error
5204  *   Perform verbose error reporting if not NULL.
5205  *   PMDs initialize this structure in case of error only.
5206  *
5207  * @return
5208  *   Handle on success, NULL otherwise and rte_errno is set.
5209  */
5210 __rte_experimental
5211 struct rte_flow_template_table *
5212 rte_flow_template_table_create(uint16_t port_id,
5213 		const struct rte_flow_template_table_attr *table_attr,
5214 		struct rte_flow_pattern_template *pattern_templates[],
5215 		uint8_t nb_pattern_templates,
5216 		struct rte_flow_actions_template *actions_templates[],
5217 		uint8_t nb_actions_templates,
5218 		struct rte_flow_error *error);
5219 
5220 /**
5221  * @warning
5222  * @b EXPERIMENTAL: this API may change without prior notice.
5223  *
5224  * Destroy flow template table.
5225  *
5226  * This function may be called only when
5227  * there are no more flow rules referencing this table.
5228  *
5229  * @param port_id
5230  *   Port identifier of Ethernet device.
5231  * @param[in] template_table
5232  *   Handle to the table to be destroyed.
5233  * @param[out] error
5234  *   Perform verbose error reporting if not NULL.
5235  *   PMDs initialize this structure in case of error only.
5236  *
5237  * @return
5238  *   0 on success, a negative errno value otherwise and rte_errno is set.
5239  */
5240 __rte_experimental
5241 int
5242 rte_flow_template_table_destroy(uint16_t port_id,
5243 		struct rte_flow_template_table *template_table,
5244 		struct rte_flow_error *error);
5245 
5246 /**
5247  * @warning
5248  * @b EXPERIMENTAL: this API may change without prior notice.
5249  *
5250  * Asynchronous operation attributes.
5251  */
5252 __extension__
5253 struct rte_flow_op_attr {
5254 	 /**
5255 	  * When set, the requested action will not be sent to the HW immediately.
5256 	  * The application must call the rte_flow_queue_push to actually send it.
5257 	  */
5258 	uint32_t postpone:1;
5259 };
5260 
5261 /**
5262  * @warning
5263  * @b EXPERIMENTAL: this API may change without prior notice.
5264  *
5265  * Enqueue rule creation operation.
5266  *
5267  * @param port_id
5268  *   Port identifier of Ethernet device.
5269  * @param queue_id
5270  *   Flow queue used to insert the rule.
5271  * @param[in] op_attr
5272  *   Rule creation operation attributes.
5273  * @param[in] template_table
5274  *   Template table to select templates from.
5275  * @param[in] pattern
5276  *   List of pattern items to be used.
5277  *   The list order should match the order in the pattern template.
5278  *   The spec is the only relevant member of the item that is being used.
5279  * @param[in] pattern_template_index
5280  *   Pattern template index in the table.
5281  * @param[in] actions
5282  *   List of actions to be used.
5283  *   The list order should match the order in the actions template.
5284  * @param[in] actions_template_index
5285  *   Actions template index in the table.
5286  * @param[in] user_data
5287  *   The user data that will be returned on the completion events.
5288  * @param[out] error
5289  *   Perform verbose error reporting if not NULL.
5290  *   PMDs initialize this structure in case of error only.
5291  *
5292  * @return
5293  *   Handle on success, NULL otherwise and rte_errno is set.
5294  *   The rule handle doesn't mean that the rule has been populated.
5295  *   Only completion result indicates that if there was success or failure.
5296  */
5297 __rte_experimental
5298 struct rte_flow *
5299 rte_flow_async_create(uint16_t port_id,
5300 		      uint32_t queue_id,
5301 		      const struct rte_flow_op_attr *op_attr,
5302 		      struct rte_flow_template_table *template_table,
5303 		      const struct rte_flow_item pattern[],
5304 		      uint8_t pattern_template_index,
5305 		      const struct rte_flow_action actions[],
5306 		      uint8_t actions_template_index,
5307 		      void *user_data,
5308 		      struct rte_flow_error *error);
5309 
5310 /**
5311  * @warning
5312  * @b EXPERIMENTAL: this API may change without prior notice.
5313  *
5314  * Enqueue rule destruction operation.
5315  *
5316  * This function enqueues a destruction operation on the queue.
5317  * Application should assume that after calling this function
5318  * the rule handle is not valid anymore.
5319  * Completion indicates the full removal of the rule from the HW.
5320  *
5321  * @param port_id
5322  *   Port identifier of Ethernet device.
5323  * @param queue_id
5324  *   Flow queue which is used to destroy the rule.
5325  *   This must match the queue on which the rule was created.
5326  * @param[in] op_attr
5327  *   Rule destruction operation attributes.
5328  * @param[in] flow
5329  *   Flow handle to be destroyed.
5330  * @param[in] user_data
5331  *   The user data that will be returned on the completion events.
5332  * @param[out] error
5333  *   Perform verbose error reporting if not NULL.
5334  *   PMDs initialize this structure in case of error only.
5335  *
5336  * @return
5337  *   0 on success, a negative errno value otherwise and rte_errno is set.
5338  */
5339 __rte_experimental
5340 int
5341 rte_flow_async_destroy(uint16_t port_id,
5342 		       uint32_t queue_id,
5343 		       const struct rte_flow_op_attr *op_attr,
5344 		       struct rte_flow *flow,
5345 		       void *user_data,
5346 		       struct rte_flow_error *error);
5347 
5348 /**
5349  * @warning
5350  * @b EXPERIMENTAL: this API may change without prior notice.
5351  *
5352  * Push all internally stored rules to the HW.
5353  * Postponed rules are rules that were inserted with the postpone flag set.
5354  * Can be used to notify the HW about batch of rules prepared by the SW to
5355  * reduce the number of communications between the HW and SW.
5356  *
5357  * @param port_id
5358  *   Port identifier of Ethernet device.
5359  * @param queue_id
5360  *   Flow queue to be pushed.
5361  * @param[out] error
5362  *   Perform verbose error reporting if not NULL.
5363  *   PMDs initialize this structure in case of error only.
5364  *
5365  * @return
5366  *   0 on success, a negative errno value otherwise and rte_errno is set.
5367  */
5368 __rte_experimental
5369 int
5370 rte_flow_push(uint16_t port_id,
5371 	      uint32_t queue_id,
5372 	      struct rte_flow_error *error);
5373 
5374 /**
5375  * @warning
5376  * @b EXPERIMENTAL: this API may change without prior notice.
5377  *
5378  * Asynchronous operation status.
5379  */
5380 enum rte_flow_op_status {
5381 	/**
5382 	 * The operation was completed successfully.
5383 	 */
5384 	RTE_FLOW_OP_SUCCESS,
5385 	/**
5386 	 * The operation was not completed successfully.
5387 	 */
5388 	RTE_FLOW_OP_ERROR,
5389 };
5390 
5391 /**
5392  * @warning
5393  * @b EXPERIMENTAL: this API may change without prior notice.
5394  *
5395  * Asynchronous operation result.
5396  */
5397 __extension__
5398 struct rte_flow_op_result {
5399 	/**
5400 	 * Returns the status of the operation that this completion signals.
5401 	 */
5402 	enum rte_flow_op_status status;
5403 	/**
5404 	 * The user data that will be returned on the completion events.
5405 	 */
5406 	void *user_data;
5407 };
5408 
5409 /**
5410  * @warning
5411  * @b EXPERIMENTAL: this API may change without prior notice.
5412  *
5413  * Pull a rte flow operation.
5414  * The application must invoke this function in order to complete
5415  * the flow rule offloading and to retrieve the flow rule operation status.
5416  *
5417  * @param port_id
5418  *   Port identifier of Ethernet device.
5419  * @param queue_id
5420  *   Flow queue which is used to pull the operation.
5421  * @param[out] res
5422  *   Array of results that will be set.
5423  * @param[in] n_res
5424  *   Maximum number of results that can be returned.
5425  *   This value is equal to the size of the res array.
5426  * @param[out] error
5427  *   Perform verbose error reporting if not NULL.
5428  *   PMDs initialize this structure in case of error only.
5429  *
5430  * @return
5431  *   Number of results that were pulled,
5432  *   a negative errno value otherwise and rte_errno is set.
5433  */
5434 __rte_experimental
5435 int
5436 rte_flow_pull(uint16_t port_id,
5437 	      uint32_t queue_id,
5438 	      struct rte_flow_op_result res[],
5439 	      uint16_t n_res,
5440 	      struct rte_flow_error *error);
5441 
5442 /**
5443  * @warning
5444  * @b EXPERIMENTAL: this API may change without prior notice.
5445  *
5446  * Enqueue indirect action creation operation.
5447  * @see rte_flow_action_handle_create
5448  *
5449  * @param[in] port_id
5450  *   Port identifier of Ethernet device.
5451  * @param[in] queue_id
5452  *   Flow queue which is used to create the rule.
5453  * @param[in] op_attr
5454  *   Indirect action creation operation attributes.
5455  * @param[in] indir_action_conf
5456  *   Action configuration for the indirect action object creation.
5457  * @param[in] action
5458  *   Specific configuration of the indirect action object.
5459  * @param[in] user_data
5460  *   The user data that will be returned on the completion events.
5461  * @param[out] error
5462  *   Perform verbose error reporting if not NULL.
5463  *   PMDs initialize this structure in case of error only.
5464  *
5465  * @return
5466  *   A valid handle in case of success, NULL otherwise and rte_errno is set.
5467  */
5468 __rte_experimental
5469 struct rte_flow_action_handle *
5470 rte_flow_async_action_handle_create(uint16_t port_id,
5471 		uint32_t queue_id,
5472 		const struct rte_flow_op_attr *op_attr,
5473 		const struct rte_flow_indir_action_conf *indir_action_conf,
5474 		const struct rte_flow_action *action,
5475 		void *user_data,
5476 		struct rte_flow_error *error);
5477 
5478 /**
5479  * @warning
5480  * @b EXPERIMENTAL: this API may change without prior notice.
5481  *
5482  * Enqueue indirect action destruction operation.
5483  * The destroy queue must be the same
5484  * as the queue on which the action was created.
5485  *
5486  * @param[in] port_id
5487  *   Port identifier of Ethernet device.
5488  * @param[in] queue_id
5489  *   Flow queue which is used to destroy the rule.
5490  * @param[in] op_attr
5491  *   Indirect action destruction operation attributes.
5492  * @param[in] action_handle
5493  *   Handle for the indirect action object to be destroyed.
5494  * @param[in] user_data
5495  *   The user data that will be returned on the completion events.
5496  * @param[out] error
5497  *   Perform verbose error reporting if not NULL.
5498  *   PMDs initialize this structure in case of error only.
5499  *
5500  * @return
5501  *   0 on success, a negative errno value otherwise and rte_errno is set.
5502  */
5503 __rte_experimental
5504 int
5505 rte_flow_async_action_handle_destroy(uint16_t port_id,
5506 		uint32_t queue_id,
5507 		const struct rte_flow_op_attr *op_attr,
5508 		struct rte_flow_action_handle *action_handle,
5509 		void *user_data,
5510 		struct rte_flow_error *error);
5511 
5512 /**
5513  * @warning
5514  * @b EXPERIMENTAL: this API may change without prior notice.
5515  *
5516  * Enqueue indirect action update operation.
5517  * @see rte_flow_action_handle_create
5518  *
5519  * @param[in] port_id
5520  *   Port identifier of Ethernet device.
5521  * @param[in] queue_id
5522  *   Flow queue which is used to update the rule.
5523  * @param[in] op_attr
5524  *   Indirect action update operation attributes.
5525  * @param[in] action_handle
5526  *   Handle for the indirect action object to be updated.
5527  * @param[in] update
5528  *   Update profile specification used to modify the action pointed by handle.
5529  *   *update* could be with the same type of the immediate action corresponding
5530  *   to the *handle* argument when creating, or a wrapper structure includes
5531  *   action configuration to be updated and bit fields to indicate the member
5532  *   of fields inside the action to update.
5533  * @param[in] user_data
5534  *   The user data that will be returned on the completion events.
5535  * @param[out] error
5536  *   Perform verbose error reporting if not NULL.
5537  *   PMDs initialize this structure in case of error only.
5538  *
5539  * @return
5540  *   0 on success, a negative errno value otherwise and rte_errno is set.
5541  */
5542 __rte_experimental
5543 int
5544 rte_flow_async_action_handle_update(uint16_t port_id,
5545 		uint32_t queue_id,
5546 		const struct rte_flow_op_attr *op_attr,
5547 		struct rte_flow_action_handle *action_handle,
5548 		const void *update,
5549 		void *user_data,
5550 		struct rte_flow_error *error);
5551 
5552 /**
5553  * @warning
5554  * @b EXPERIMENTAL: this API may change without prior notice.
5555  *
5556  * Enqueue indirect action query operation.
5557  *
5558  * Retrieve action-specific data such as counters.
5559  * Data is gathered by special action which may be present/referenced in
5560  * more than one flow rule definition.
5561  * Data will be available only when completion event returns.
5562  *
5563  * @see rte_flow_async_action_handle_query
5564  *
5565  * @param port_id
5566  *   Port identifier of Ethernet device.
5567  * @param[in] queue_id
5568  *   Flow queue which is used to query the action.
5569  * @param[in] op_attr
5570  *   Indirect action update operation attributes.
5571  * @param[in] action_handle
5572  *   Handle for the action object to query.
5573  * @param[in, out] data
5574  *   Pointer to storage for the associated query data type.
5575  *   The out data will be available only when completion event returns
5576  *   from rte_flow_pull.
5577  * @param[in] user_data
5578  *   The user data that will be returned on the completion events.
5579  * @param[out] error
5580  *   Perform verbose error reporting if not NULL. PMDs initialize this
5581  *   structure in case of error only.
5582  *
5583  * @return
5584  *   0 on success, a negative errno value otherwise and rte_errno is set.
5585  */
5586 __rte_experimental
5587 int
5588 rte_flow_async_action_handle_query(uint16_t port_id,
5589 		uint32_t queue_id,
5590 		const struct rte_flow_op_attr *op_attr,
5591 		const struct rte_flow_action_handle *action_handle,
5592 		void *data,
5593 		void *user_data,
5594 		struct rte_flow_error *error);
5595 
5596 #ifdef __cplusplus
5597 }
5598 #endif
5599 
5600 #endif /* RTE_FLOW_H_ */
5601