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