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