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