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