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