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