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