xref: /dpdk/lib/ethdev/rte_flow.h (revision 0dff3f26d6faad4e51f75e5245f0387ee9bb0c6d)
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_arp.h>
21 #include <rte_common.h>
22 #include <rte_ether.h>
23 #include <rte_icmp.h>
24 #include <rte_ip.h>
25 #include <rte_sctp.h>
26 #include <rte_tcp.h>
27 #include <rte_udp.h>
28 #include <rte_vxlan.h>
29 #include <rte_byteorder.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.h>
35 #include <rte_mbuf_dyn.h>
36 #include <rte_meter.h>
37 #include <rte_gtp.h>
38 #include <rte_l2tpv2.h>
39 #include <rte_ppp.h>
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 /**
46  * Flow rule attributes.
47  *
48  * Priorities are set on a per rule based within groups.
49  *
50  * Lower values denote higher priority, the highest priority for a flow rule
51  * is 0, so that a flow that matches for than one rule, the rule with the
52  * lowest priority value will always be matched.
53  *
54  * Although optional, applications are encouraged to group similar rules as
55  * much as possible to fully take advantage of hardware capabilities
56  * (e.g. optimized matching) and work around limitations (e.g. a single
57  * pattern type possibly allowed in a given group). Applications should be
58  * aware that groups are not linked by default, and that they must be
59  * explicitly linked by the application using the JUMP action.
60  *
61  * Priority levels are arbitrary and up to the application, they
62  * do not need to be contiguous nor start from 0, however the maximum number
63  * varies between devices and may be affected by existing flow rules.
64  *
65  * If a packet is matched by several rules of a given group for a given
66  * priority level, the outcome is undefined. It can take any path, may be
67  * duplicated or even cause unrecoverable errors.
68  *
69  * Note that support for more than a single group and priority level is not
70  * guaranteed.
71  *
72  * At vNIC / ethdev level, flow rules can apply to inbound and / or outbound
73  * traffic (ingress / egress), with respect to the vNIC / ethdev in question.
74  * At embedded switch level, flow rules apply to all traffic seen by it
75  * unless fitting meta items are used to set concrete traffic source(s).
76  *
77  * Several pattern items and actions are valid and can be used in both
78  * directions. Those valid for only one direction are described as such.
79  *
80  * At least one direction must be specified.
81  *
82  * Specifying both directions at once for a given rule is not recommended
83  * but may be valid in a few cases.
84  */
85 struct rte_flow_attr {
86 	uint32_t group; /**< Priority group. */
87 	uint32_t priority; /**< Rule priority level within group. */
88 	/**
89 	 * The rule in question applies to ingress traffic (non-"transfer").
90 	 *
91 	 * @deprecated
92 	 * It has been possible to combine this attribute with "transfer".
93 	 * Doing so has been assumed to restrict the scope of matching
94 	 * to traffic going from within the embedded switch toward the
95 	 * ethdev the flow rule being created through. This behaviour
96 	 * is deprecated. During the transition period, one may still
97 	 * rely on it, but PMDs and applications are encouraged to
98 	 * gradually move away from this approach.
99 	 */
100 	uint32_t ingress:1;
101 	/**
102 	 * The rule in question applies to egress traffic (non-"transfer").
103 	 *
104 	 * @deprecated
105 	 * It has been possible to combine this attribute with "transfer".
106 	 * Doing so has been assumed to restrict the scope of matching
107 	 * to traffic sent by the application by virtue of the ethdev
108 	 * the flow rule being created through. This behaviour is now
109 	 * deprecated. During the transition period, one may still
110 	 * rely on it, but PMDs and applications are encouraged to
111 	 * gradually move away from this approach.
112 	 */
113 	uint32_t egress:1;
114 	/**
115 	 * Instead of simply matching the properties of traffic as it would
116 	 * appear on a given DPDK port ID, enabling this attribute transfers
117 	 * a flow rule to the lowest possible level of any device endpoints
118 	 * found in the pattern.
119 	 *
120 	 * When supported, this effectively enables an application to
121 	 * re-route traffic not necessarily intended for it (e.g. coming
122 	 * from or addressed to different physical ports, VFs or
123 	 * applications) at the device level.
124 	 *
125 	 * The application should match traffic originating from precise
126 	 * locations. See items PORT_REPRESENTOR and REPRESENTED_PORT.
127 	 *
128 	 * Managing "transfer" flows requires that the user communicate them
129 	 * through a suitable port. @see rte_flow_pick_transfer_proxy().
130 	 */
131 	uint32_t transfer:1;
132 	uint32_t reserved:29; /**< Reserved, must be zero. */
133 };
134 
135 /**
136  * Matching pattern item types.
137  *
138  * Pattern items fall in two categories:
139  *
140  * - Matching protocol headers and packet data, usually associated with a
141  *   specification structure. These must be stacked in the same order as the
142  *   protocol layers to match inside packets, starting from the lowest.
143  *
144  * - Matching meta-data or affecting pattern processing, often without a
145  *   specification structure. Since they do not match packet contents, their
146  *   position in the list is usually not relevant.
147  *
148  * See the description of individual types for more information. Those
149  * marked with [META] fall into the second category.
150  */
151 enum rte_flow_item_type {
152 	/**
153 	 * [META]
154 	 *
155 	 * End marker for item lists. Prevents further processing of items,
156 	 * thereby ending the pattern.
157 	 *
158 	 * No associated specification structure.
159 	 */
160 	RTE_FLOW_ITEM_TYPE_END,
161 
162 	/**
163 	 * [META]
164 	 *
165 	 * Used as a placeholder for convenience. It is ignored and simply
166 	 * discarded by PMDs.
167 	 *
168 	 * No associated specification structure.
169 	 */
170 	RTE_FLOW_ITEM_TYPE_VOID,
171 
172 	/**
173 	 * [META]
174 	 *
175 	 * Inverted matching, i.e. process packets that do not match the
176 	 * pattern.
177 	 *
178 	 * No associated specification structure.
179 	 */
180 	RTE_FLOW_ITEM_TYPE_INVERT,
181 
182 	/**
183 	 * Matches any protocol in place of the current layer, a single ANY
184 	 * may also stand for several protocol layers.
185 	 *
186 	 * See struct rte_flow_item_any.
187 	 */
188 	RTE_FLOW_ITEM_TYPE_ANY,
189 
190 	/**
191 	 * @deprecated
192 	 * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
193 	 * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
194 	 *
195 	 * [META]
196 	 *
197 	 * Matches traffic originating from (ingress) or going to (egress)
198 	 * the physical function of the current device.
199 	 *
200 	 * No associated specification structure.
201 	 */
202 	RTE_FLOW_ITEM_TYPE_PF,
203 
204 	/**
205 	 * @deprecated
206 	 * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
207 	 * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
208 	 *
209 	 * [META]
210 	 *
211 	 * Matches traffic originating from (ingress) or going to (egress) a
212 	 * given virtual function of the current device.
213 	 *
214 	 * See struct rte_flow_item_vf.
215 	 */
216 	RTE_FLOW_ITEM_TYPE_VF,
217 
218 	/**
219 	 * @deprecated
220 	 * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
221 	 * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
222 	 *
223 	 * [META]
224 	 *
225 	 * Matches traffic originating from (ingress) or going to (egress) a
226 	 * physical port of the underlying device.
227 	 *
228 	 * See struct rte_flow_item_phy_port.
229 	 */
230 	RTE_FLOW_ITEM_TYPE_PHY_PORT,
231 
232 	/**
233 	 * @deprecated
234 	 * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
235 	 * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
236 	 *
237 	 * [META]
238 	 *
239 	 * Matches traffic originating from (ingress) or going to (egress) a
240 	 * given DPDK port ID.
241 	 *
242 	 * See struct rte_flow_item_port_id.
243 	 */
244 	RTE_FLOW_ITEM_TYPE_PORT_ID,
245 
246 	/**
247 	 * Matches a byte string of a given length at a given offset.
248 	 *
249 	 * See struct rte_flow_item_raw.
250 	 */
251 	RTE_FLOW_ITEM_TYPE_RAW,
252 
253 	/**
254 	 * Matches an Ethernet header.
255 	 *
256 	 * See struct rte_flow_item_eth.
257 	 */
258 	RTE_FLOW_ITEM_TYPE_ETH,
259 
260 	/**
261 	 * Matches an 802.1Q/ad VLAN tag.
262 	 *
263 	 * See struct rte_flow_item_vlan.
264 	 */
265 	RTE_FLOW_ITEM_TYPE_VLAN,
266 
267 	/**
268 	 * Matches an IPv4 header.
269 	 *
270 	 * See struct rte_flow_item_ipv4.
271 	 */
272 	RTE_FLOW_ITEM_TYPE_IPV4,
273 
274 	/**
275 	 * Matches an IPv6 header.
276 	 *
277 	 * See struct rte_flow_item_ipv6.
278 	 */
279 	RTE_FLOW_ITEM_TYPE_IPV6,
280 
281 	/**
282 	 * Matches an ICMP header.
283 	 *
284 	 * See struct rte_flow_item_icmp.
285 	 */
286 	RTE_FLOW_ITEM_TYPE_ICMP,
287 
288 	/**
289 	 * Matches a UDP header.
290 	 *
291 	 * See struct rte_flow_item_udp.
292 	 */
293 	RTE_FLOW_ITEM_TYPE_UDP,
294 
295 	/**
296 	 * Matches a TCP header.
297 	 *
298 	 * See struct rte_flow_item_tcp.
299 	 */
300 	RTE_FLOW_ITEM_TYPE_TCP,
301 
302 	/**
303 	 * Matches a SCTP header.
304 	 *
305 	 * See struct rte_flow_item_sctp.
306 	 */
307 	RTE_FLOW_ITEM_TYPE_SCTP,
308 
309 	/**
310 	 * Matches a VXLAN header.
311 	 *
312 	 * See struct rte_flow_item_vxlan.
313 	 */
314 	RTE_FLOW_ITEM_TYPE_VXLAN,
315 
316 	/**
317 	 * Matches a E_TAG header.
318 	 *
319 	 * See struct rte_flow_item_e_tag.
320 	 */
321 	RTE_FLOW_ITEM_TYPE_E_TAG,
322 
323 	/**
324 	 * Matches a NVGRE header.
325 	 *
326 	 * See struct rte_flow_item_nvgre.
327 	 */
328 	RTE_FLOW_ITEM_TYPE_NVGRE,
329 
330 	/**
331 	 * Matches a MPLS header.
332 	 *
333 	 * See struct rte_flow_item_mpls.
334 	 */
335 	RTE_FLOW_ITEM_TYPE_MPLS,
336 
337 	/**
338 	 * Matches a GRE header.
339 	 *
340 	 * See struct rte_flow_item_gre.
341 	 */
342 	RTE_FLOW_ITEM_TYPE_GRE,
343 
344 	/**
345 	 * [META]
346 	 *
347 	 * Fuzzy pattern match, expect faster than default.
348 	 *
349 	 * This is for device that support fuzzy matching option.
350 	 * Usually a fuzzy matching is fast but the cost is accuracy.
351 	 *
352 	 * See struct rte_flow_item_fuzzy.
353 	 */
354 	RTE_FLOW_ITEM_TYPE_FUZZY,
355 
356 	/**
357 	 * Matches a GTP header.
358 	 *
359 	 * Configure flow for GTP packets.
360 	 *
361 	 * See struct rte_flow_item_gtp.
362 	 */
363 	RTE_FLOW_ITEM_TYPE_GTP,
364 
365 	/**
366 	 * Matches a GTP header.
367 	 *
368 	 * Configure flow for GTP-C packets.
369 	 *
370 	 * See struct rte_flow_item_gtp.
371 	 */
372 	RTE_FLOW_ITEM_TYPE_GTPC,
373 
374 	/**
375 	 * Matches a GTP header.
376 	 *
377 	 * Configure flow for GTP-U packets.
378 	 *
379 	 * See struct rte_flow_item_gtp.
380 	 */
381 	RTE_FLOW_ITEM_TYPE_GTPU,
382 
383 	/**
384 	 * Matches a ESP header.
385 	 *
386 	 * See struct rte_flow_item_esp.
387 	 */
388 	RTE_FLOW_ITEM_TYPE_ESP,
389 
390 	/**
391 	 * Matches a GENEVE header.
392 	 *
393 	 * See struct rte_flow_item_geneve.
394 	 */
395 	RTE_FLOW_ITEM_TYPE_GENEVE,
396 
397 	/**
398 	 * Matches a VXLAN-GPE header.
399 	 *
400 	 * See struct rte_flow_item_vxlan_gpe.
401 	 */
402 	RTE_FLOW_ITEM_TYPE_VXLAN_GPE,
403 
404 	/**
405 	 * Matches an ARP header for Ethernet/IPv4.
406 	 *
407 	 * See struct rte_flow_item_arp_eth_ipv4.
408 	 */
409 	RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4,
410 
411 	/**
412 	 * Matches the presence of any IPv6 extension header.
413 	 *
414 	 * See struct rte_flow_item_ipv6_ext.
415 	 */
416 	RTE_FLOW_ITEM_TYPE_IPV6_EXT,
417 
418 	/**
419 	 * Matches any ICMPv6 header.
420 	 *
421 	 * See struct rte_flow_item_icmp6.
422 	 */
423 	RTE_FLOW_ITEM_TYPE_ICMP6,
424 
425 	/**
426 	 * Matches an ICMPv6 neighbor discovery solicitation.
427 	 *
428 	 * See struct rte_flow_item_icmp6_nd_ns.
429 	 */
430 	RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS,
431 
432 	/**
433 	 * Matches an ICMPv6 neighbor discovery advertisement.
434 	 *
435 	 * See struct rte_flow_item_icmp6_nd_na.
436 	 */
437 	RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA,
438 
439 	/**
440 	 * Matches the presence of any ICMPv6 neighbor discovery option.
441 	 *
442 	 * See struct rte_flow_item_icmp6_nd_opt.
443 	 */
444 	RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT,
445 
446 	/**
447 	 * Matches an ICMPv6 neighbor discovery source Ethernet link-layer
448 	 * address option.
449 	 *
450 	 * See struct rte_flow_item_icmp6_nd_opt_sla_eth.
451 	 */
452 	RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH,
453 
454 	/**
455 	 * Matches an ICMPv6 neighbor discovery target Ethernet link-layer
456 	 * address option.
457 	 *
458 	 * See struct rte_flow_item_icmp6_nd_opt_tla_eth.
459 	 */
460 	RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH,
461 
462 	/**
463 	 * Matches specified mark field.
464 	 *
465 	 * See struct rte_flow_item_mark.
466 	 */
467 	RTE_FLOW_ITEM_TYPE_MARK,
468 
469 	/**
470 	 * [META]
471 	 *
472 	 * Matches a metadata value.
473 	 *
474 	 * See struct rte_flow_item_meta.
475 	 */
476 	RTE_FLOW_ITEM_TYPE_META,
477 
478 	/**
479 	 * Matches a GRE optional key field.
480 	 *
481 	 * The value should a big-endian 32bit integer.
482 	 *
483 	 * When this item present the K bit is implicitly matched as "1"
484 	 * in the default mask.
485 	 *
486 	 * @p spec/mask type:
487 	 * @code rte_be32_t * @endcode
488 	 */
489 	RTE_FLOW_ITEM_TYPE_GRE_KEY,
490 
491 	/**
492 	 * Matches a GTP extension header: PDU session container.
493 	 *
494 	 * Configure flow for GTP packets with extension header type 0x85.
495 	 *
496 	 * See struct rte_flow_item_gtp_psc.
497 	 */
498 	RTE_FLOW_ITEM_TYPE_GTP_PSC,
499 
500 	/**
501 	 * Matches a PPPoE header.
502 	 *
503 	 * Configure flow for PPPoE session packets.
504 	 *
505 	 * See struct rte_flow_item_pppoe.
506 	 */
507 	RTE_FLOW_ITEM_TYPE_PPPOES,
508 
509 	/**
510 	 * Matches a PPPoE header.
511 	 *
512 	 * Configure flow for PPPoE discovery packets.
513 	 *
514 	 * See struct rte_flow_item_pppoe.
515 	 */
516 	RTE_FLOW_ITEM_TYPE_PPPOED,
517 
518 	/**
519 	 * Matches a PPPoE optional proto_id field.
520 	 *
521 	 * It only applies to PPPoE session packets.
522 	 *
523 	 * See struct rte_flow_item_pppoe_proto_id.
524 	 */
525 	RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID,
526 
527 	/**
528 	 * Matches Network service header (NSH).
529 	 * See struct rte_flow_item_nsh.
530 	 *
531 	 */
532 	RTE_FLOW_ITEM_TYPE_NSH,
533 
534 	/**
535 	 * Matches Internet Group Management Protocol (IGMP).
536 	 * See struct rte_flow_item_igmp.
537 	 *
538 	 */
539 	RTE_FLOW_ITEM_TYPE_IGMP,
540 
541 	/**
542 	 * Matches IP Authentication Header (AH).
543 	 * See struct rte_flow_item_ah.
544 	 *
545 	 */
546 	RTE_FLOW_ITEM_TYPE_AH,
547 
548 	/**
549 	 * Matches a HIGIG header.
550 	 * see struct rte_flow_item_higig2_hdr.
551 	 */
552 	RTE_FLOW_ITEM_TYPE_HIGIG2,
553 
554 	/**
555 	 * [META]
556 	 *
557 	 * Matches a tag value.
558 	 *
559 	 * See struct rte_flow_item_tag.
560 	 */
561 	RTE_FLOW_ITEM_TYPE_TAG,
562 
563 	/**
564 	 * Matches a L2TPv3 over IP header.
565 	 *
566 	 * Configure flow for L2TPv3 over IP packets.
567 	 *
568 	 * See struct rte_flow_item_l2tpv3oip.
569 	 */
570 	RTE_FLOW_ITEM_TYPE_L2TPV3OIP,
571 
572 	/**
573 	 * Matches PFCP Header.
574 	 * See struct rte_flow_item_pfcp.
575 	 *
576 	 */
577 	RTE_FLOW_ITEM_TYPE_PFCP,
578 
579 	/**
580 	 * Matches eCPRI Header.
581 	 *
582 	 * Configure flow for eCPRI over ETH or UDP packets.
583 	 *
584 	 * See struct rte_flow_item_ecpri.
585 	 */
586 	RTE_FLOW_ITEM_TYPE_ECPRI,
587 
588 	/**
589 	 * Matches the presence of IPv6 fragment extension header.
590 	 *
591 	 * See struct rte_flow_item_ipv6_frag_ext.
592 	 */
593 	RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
594 
595 	/**
596 	 * Matches Geneve Variable Length Option
597 	 *
598 	 * See struct rte_flow_item_geneve_opt
599 	 */
600 	RTE_FLOW_ITEM_TYPE_GENEVE_OPT,
601 
602 	/**
603 	 * [META]
604 	 *
605 	 * Matches on packet integrity.
606 	 * For some devices application needs to enable integration checks in HW
607 	 * before using this item.
608 	 *
609 	 * @see struct rte_flow_item_integrity.
610 	 */
611 	RTE_FLOW_ITEM_TYPE_INTEGRITY,
612 
613 	/**
614 	 * [META]
615 	 *
616 	 * Matches conntrack state.
617 	 *
618 	 * @see struct rte_flow_item_conntrack.
619 	 */
620 	RTE_FLOW_ITEM_TYPE_CONNTRACK,
621 
622 	/**
623 	 * [META]
624 	 *
625 	 * Matches traffic entering the embedded switch from the given ethdev.
626 	 *
627 	 * @see struct rte_flow_item_ethdev
628 	 */
629 	RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR,
630 
631 	/**
632 	 * [META]
633 	 *
634 	 * Matches traffic entering the embedded switch from
635 	 * the entity represented by the given ethdev.
636 	 *
637 	 * @see struct rte_flow_item_ethdev
638 	 */
639 	RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT,
640 
641 	/**
642 	 * Matches a configured set of fields at runtime calculated offsets
643 	 * over the generic network header with variable length and
644 	 * flexible pattern
645 	 *
646 	 * @see struct rte_flow_item_flex.
647 	 */
648 	RTE_FLOW_ITEM_TYPE_FLEX,
649 
650 	/**
651 	 * Matches L2TPv2 Header.
652 	 *
653 	 * See struct rte_flow_item_l2tpv2.
654 	 */
655 	RTE_FLOW_ITEM_TYPE_L2TPV2,
656 
657 	/**
658 	 * Matches PPP Header.
659 	 *
660 	 * See struct rte_flow_item_ppp.
661 	 */
662 	RTE_FLOW_ITEM_TYPE_PPP,
663 };
664 
665 /**
666  *
667  * RTE_FLOW_ITEM_TYPE_HIGIG2
668  * Matches higig2 header
669  */
670 RTE_STD_C11
671 struct rte_flow_item_higig2_hdr {
672 	struct rte_higig2_hdr hdr;
673 };
674 
675 /** Default mask for RTE_FLOW_ITEM_TYPE_HIGIG2. */
676 #ifndef __cplusplus
677 static const struct rte_flow_item_higig2_hdr rte_flow_item_higig2_hdr_mask = {
678 	.hdr = {
679 		.ppt1 = {
680 			.classification = 0xffff,
681 			.vid = 0xfff,
682 		},
683 	},
684 };
685 #endif
686 
687 /**
688  * RTE_FLOW_ITEM_TYPE_ANY
689  *
690  * Matches any protocol in place of the current layer, a single ANY may also
691  * stand for several protocol layers.
692  *
693  * This is usually specified as the first pattern item when looking for a
694  * protocol anywhere in a packet.
695  *
696  * A zeroed mask stands for any number of layers.
697  */
698 struct rte_flow_item_any {
699 	uint32_t num; /**< Number of layers covered. */
700 };
701 
702 /** Default mask for RTE_FLOW_ITEM_TYPE_ANY. */
703 #ifndef __cplusplus
704 static const struct rte_flow_item_any rte_flow_item_any_mask = {
705 	.num = 0x00000000,
706 };
707 #endif
708 
709 /**
710  * @deprecated
711  * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
712  * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
713  *
714  * RTE_FLOW_ITEM_TYPE_VF
715  *
716  * Matches traffic originating from (ingress) or going to (egress) a given
717  * virtual function of the current device.
718  *
719  * If supported, should work even if the virtual function is not managed by
720  * the application and thus not associated with a DPDK port ID.
721  *
722  * Note this pattern item does not match VF representors traffic which, as
723  * separate entities, should be addressed through their own DPDK port IDs.
724  *
725  * - Can be specified multiple times to match traffic addressed to several
726  *   VF IDs.
727  * - Can be combined with a PF item to match both PF and VF traffic.
728  *
729  * A zeroed mask can be used to match any VF ID.
730  */
731 struct rte_flow_item_vf {
732 	uint32_t id; /**< VF ID. */
733 };
734 
735 /** Default mask for RTE_FLOW_ITEM_TYPE_VF. */
736 #ifndef __cplusplus
737 static const struct rte_flow_item_vf rte_flow_item_vf_mask = {
738 	.id = 0x00000000,
739 };
740 #endif
741 
742 /**
743  * @deprecated
744  * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
745  * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
746  *
747  * RTE_FLOW_ITEM_TYPE_PHY_PORT
748  *
749  * Matches traffic originating from (ingress) or going to (egress) a
750  * physical port of the underlying device.
751  *
752  * The first PHY_PORT item overrides the physical port normally associated
753  * with the specified DPDK input port (port_id). This item can be provided
754  * several times to match additional physical ports.
755  *
756  * Note that physical ports are not necessarily tied to DPDK input ports
757  * (port_id) when those are not under DPDK control. Possible values are
758  * specific to each device, they are not necessarily indexed from zero and
759  * may not be contiguous.
760  *
761  * As a device property, the list of allowed values as well as the value
762  * associated with a port_id should be retrieved by other means.
763  *
764  * A zeroed mask can be used to match any port index.
765  */
766 struct rte_flow_item_phy_port {
767 	uint32_t index; /**< Physical port index. */
768 };
769 
770 /** Default mask for RTE_FLOW_ITEM_TYPE_PHY_PORT. */
771 #ifndef __cplusplus
772 static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask = {
773 	.index = 0x00000000,
774 };
775 #endif
776 
777 /**
778  * @deprecated
779  * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
780  * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
781  *
782  * RTE_FLOW_ITEM_TYPE_PORT_ID
783  *
784  * Matches traffic originating from (ingress) or going to (egress) a given
785  * DPDK port ID.
786  *
787  * Normally only supported if the port ID in question is known by the
788  * underlying PMD and related to the device the flow rule is created
789  * against.
790  *
791  * This must not be confused with @p PHY_PORT which refers to the physical
792  * port of a device, whereas @p PORT_ID refers to a struct rte_eth_dev
793  * object on the application side (also known as "port representor"
794  * depending on the kind of underlying device).
795  */
796 struct rte_flow_item_port_id {
797 	uint32_t id; /**< DPDK port ID. */
798 };
799 
800 /** Default mask for RTE_FLOW_ITEM_TYPE_PORT_ID. */
801 #ifndef __cplusplus
802 static const struct rte_flow_item_port_id rte_flow_item_port_id_mask = {
803 	.id = 0xffffffff,
804 };
805 #endif
806 
807 /**
808  * RTE_FLOW_ITEM_TYPE_RAW
809  *
810  * Matches a byte string of a given length at a given offset.
811  *
812  * Offset is either absolute (using the start of the packet) or relative to
813  * the end of the previous matched item in the stack, in which case negative
814  * values are allowed.
815  *
816  * If search is enabled, offset is used as the starting point. The search
817  * area can be delimited by setting limit to a nonzero value, which is the
818  * maximum number of bytes after offset where the pattern may start.
819  *
820  * Matching a zero-length pattern is allowed, doing so resets the relative
821  * offset for subsequent items.
822  *
823  * This type does not support ranges (struct rte_flow_item.last).
824  */
825 struct rte_flow_item_raw {
826 	uint32_t relative:1; /**< Look for pattern after the previous item. */
827 	uint32_t search:1; /**< Search pattern from offset (see also limit). */
828 	uint32_t reserved:30; /**< Reserved, must be set to zero. */
829 	int32_t offset; /**< Absolute or relative offset for pattern. */
830 	uint16_t limit; /**< Search area limit for start of pattern. */
831 	uint16_t length; /**< Pattern length. */
832 	const uint8_t *pattern; /**< Byte string to look for. */
833 };
834 
835 /** Default mask for RTE_FLOW_ITEM_TYPE_RAW. */
836 #ifndef __cplusplus
837 static const struct rte_flow_item_raw rte_flow_item_raw_mask = {
838 	.relative = 1,
839 	.search = 1,
840 	.reserved = 0x3fffffff,
841 	.offset = 0xffffffff,
842 	.limit = 0xffff,
843 	.length = 0xffff,
844 	.pattern = NULL,
845 };
846 #endif
847 
848 /**
849  * RTE_FLOW_ITEM_TYPE_ETH
850  *
851  * Matches an Ethernet header.
852  *
853  * Inside @p hdr field, the sub-field @p ether_type stands either for EtherType
854  * or TPID, depending on whether the item is followed by a VLAN item or not. If
855  * two VLAN items follow, the sub-field refers to the outer one, which, in turn,
856  * contains the inner TPID in the similar header field. The innermost VLAN item
857  * contains a layer-3 EtherType. All of that follows the order seen on the wire.
858  *
859  * If the field in question contains a TPID value, only tagged packets with the
860  * specified TPID will match the pattern. Alternatively, it's possible to match
861  * any type of tagged packets by means of the field @p has_vlan rather than use
862  * the EtherType/TPID field. Also, it's possible to leave the two fields unused.
863  * If this is the case, both tagged and untagged packets will match the pattern.
864  */
865 RTE_STD_C11
866 struct rte_flow_item_eth {
867 	union {
868 		struct {
869 			/*
870 			 * These fields are retained for compatibility.
871 			 * Please switch to the new header field below.
872 			 */
873 			struct rte_ether_addr dst; /**< Destination MAC. */
874 			struct rte_ether_addr src; /**< Source MAC. */
875 			rte_be16_t type; /**< EtherType or TPID. */
876 		};
877 		struct rte_ether_hdr hdr;
878 	};
879 	uint32_t has_vlan:1; /**< Packet header contains at least one VLAN. */
880 	uint32_t reserved:31; /**< Reserved, must be zero. */
881 };
882 
883 /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */
884 #ifndef __cplusplus
885 static const struct rte_flow_item_eth rte_flow_item_eth_mask = {
886 	.hdr.dst_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
887 	.hdr.src_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
888 	.hdr.ether_type = RTE_BE16(0x0000),
889 };
890 #endif
891 
892 /**
893  * RTE_FLOW_ITEM_TYPE_VLAN
894  *
895  * Matches an 802.1Q/ad VLAN tag.
896  *
897  * The corresponding standard outer EtherType (TPID) values are
898  * RTE_ETHER_TYPE_VLAN or RTE_ETHER_TYPE_QINQ. It can be overridden by
899  * the preceding pattern item.
900  * If a @p VLAN item is present in the pattern, then only tagged packets will
901  * match the pattern.
902  * The field @p has_more_vlan can be used to match any type of tagged packets,
903  * instead of using the @p eth_proto field of @p hdr.
904  * If the @p eth_proto of @p hdr and @p has_more_vlan fields are not specified,
905  * then any tagged packets will match the pattern.
906  */
907 RTE_STD_C11
908 struct rte_flow_item_vlan {
909 	union {
910 		struct {
911 			/*
912 			 * These fields are retained for compatibility.
913 			 * Please switch to the new header field below.
914 			 */
915 			rte_be16_t tci; /**< Tag control information. */
916 			rte_be16_t inner_type; /**< Inner EtherType or TPID. */
917 		};
918 		struct rte_vlan_hdr hdr;
919 	};
920 	/** Packet header contains at least one more VLAN, after this VLAN. */
921 	uint32_t has_more_vlan:1;
922 	uint32_t reserved:31; /**< Reserved, must be zero. */
923 };
924 
925 /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */
926 #ifndef __cplusplus
927 static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = {
928 	.hdr.vlan_tci = RTE_BE16(0x0fff),
929 	.hdr.eth_proto = RTE_BE16(0x0000),
930 };
931 #endif
932 
933 /**
934  * RTE_FLOW_ITEM_TYPE_IPV4
935  *
936  * Matches an IPv4 header.
937  *
938  * Note: IPv4 options are handled by dedicated pattern items.
939  */
940 struct rte_flow_item_ipv4 {
941 	struct rte_ipv4_hdr hdr; /**< IPv4 header definition. */
942 };
943 
944 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV4. */
945 #ifndef __cplusplus
946 static const struct rte_flow_item_ipv4 rte_flow_item_ipv4_mask = {
947 	.hdr = {
948 		.src_addr = RTE_BE32(0xffffffff),
949 		.dst_addr = RTE_BE32(0xffffffff),
950 	},
951 };
952 #endif
953 
954 /**
955  * RTE_FLOW_ITEM_TYPE_IPV6.
956  *
957  * Matches an IPv6 header.
958  *
959  * Dedicated flags indicate if header contains specific extension headers.
960  */
961 struct rte_flow_item_ipv6 {
962 	struct rte_ipv6_hdr hdr; /**< IPv6 header definition. */
963 	/** Header contains Hop-by-Hop Options extension header. */
964 	uint32_t has_hop_ext:1;
965 	/** Header contains Routing extension header. */
966 	uint32_t has_route_ext:1;
967 	/** Header contains Fragment extension header. */
968 	uint32_t has_frag_ext:1;
969 	/** Header contains Authentication extension header. */
970 	uint32_t has_auth_ext:1;
971 	/** Header contains Encapsulation Security Payload extension header. */
972 	uint32_t has_esp_ext:1;
973 	/** Header contains Destination Options extension header. */
974 	uint32_t has_dest_ext:1;
975 	/** Header contains Mobility extension header. */
976 	uint32_t has_mobil_ext:1;
977 	/** Header contains Host Identity Protocol extension header. */
978 	uint32_t has_hip_ext:1;
979 	/** Header contains Shim6 Protocol extension header. */
980 	uint32_t has_shim6_ext:1;
981 	/** Reserved for future extension headers, must be zero. */
982 	uint32_t reserved:23;
983 };
984 
985 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
986 #ifndef __cplusplus
987 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
988 	.hdr = {
989 		.src_addr =
990 			"\xff\xff\xff\xff\xff\xff\xff\xff"
991 			"\xff\xff\xff\xff\xff\xff\xff\xff",
992 		.dst_addr =
993 			"\xff\xff\xff\xff\xff\xff\xff\xff"
994 			"\xff\xff\xff\xff\xff\xff\xff\xff",
995 	},
996 };
997 #endif
998 
999 /**
1000  * RTE_FLOW_ITEM_TYPE_ICMP.
1001  *
1002  * Matches an ICMP header.
1003  */
1004 struct rte_flow_item_icmp {
1005 	struct rte_icmp_hdr hdr; /**< ICMP header definition. */
1006 };
1007 
1008 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP. */
1009 #ifndef __cplusplus
1010 static const struct rte_flow_item_icmp rte_flow_item_icmp_mask = {
1011 	.hdr = {
1012 		.icmp_type = 0xff,
1013 		.icmp_code = 0xff,
1014 	},
1015 };
1016 #endif
1017 
1018 /**
1019  * RTE_FLOW_ITEM_TYPE_UDP.
1020  *
1021  * Matches a UDP header.
1022  */
1023 struct rte_flow_item_udp {
1024 	struct rte_udp_hdr hdr; /**< UDP header definition. */
1025 };
1026 
1027 /** Default mask for RTE_FLOW_ITEM_TYPE_UDP. */
1028 #ifndef __cplusplus
1029 static const struct rte_flow_item_udp rte_flow_item_udp_mask = {
1030 	.hdr = {
1031 		.src_port = RTE_BE16(0xffff),
1032 		.dst_port = RTE_BE16(0xffff),
1033 	},
1034 };
1035 #endif
1036 
1037 /**
1038  * RTE_FLOW_ITEM_TYPE_TCP.
1039  *
1040  * Matches a TCP header.
1041  */
1042 struct rte_flow_item_tcp {
1043 	struct rte_tcp_hdr hdr; /**< TCP header definition. */
1044 };
1045 
1046 /** Default mask for RTE_FLOW_ITEM_TYPE_TCP. */
1047 #ifndef __cplusplus
1048 static const struct rte_flow_item_tcp rte_flow_item_tcp_mask = {
1049 	.hdr = {
1050 		.src_port = RTE_BE16(0xffff),
1051 		.dst_port = RTE_BE16(0xffff),
1052 	},
1053 };
1054 #endif
1055 
1056 /**
1057  * RTE_FLOW_ITEM_TYPE_SCTP.
1058  *
1059  * Matches a SCTP header.
1060  */
1061 struct rte_flow_item_sctp {
1062 	struct rte_sctp_hdr hdr; /**< SCTP header definition. */
1063 };
1064 
1065 /** Default mask for RTE_FLOW_ITEM_TYPE_SCTP. */
1066 #ifndef __cplusplus
1067 static const struct rte_flow_item_sctp rte_flow_item_sctp_mask = {
1068 	.hdr = {
1069 		.src_port = RTE_BE16(0xffff),
1070 		.dst_port = RTE_BE16(0xffff),
1071 	},
1072 };
1073 #endif
1074 
1075 /**
1076  * RTE_FLOW_ITEM_TYPE_VXLAN.
1077  *
1078  * Matches a VXLAN header (RFC 7348).
1079  */
1080 RTE_STD_C11
1081 struct rte_flow_item_vxlan {
1082 	union {
1083 		struct {
1084 			/*
1085 			 * These fields are retained for compatibility.
1086 			 * Please switch to the new header field below.
1087 			 */
1088 			uint8_t flags; /**< Normally 0x08 (I flag). */
1089 			uint8_t rsvd0[3]; /**< Reserved, normally 0x000000. */
1090 			uint8_t vni[3]; /**< VXLAN identifier. */
1091 			uint8_t rsvd1; /**< Reserved, normally 0x00. */
1092 		};
1093 		struct rte_vxlan_hdr hdr;
1094 	};
1095 };
1096 
1097 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */
1098 #ifndef __cplusplus
1099 static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = {
1100 	.hdr.vx_vni = RTE_BE32(0xffffff00), /* (0xffffff << 8) */
1101 };
1102 #endif
1103 
1104 /**
1105  * RTE_FLOW_ITEM_TYPE_E_TAG.
1106  *
1107  * Matches a E-tag header.
1108  *
1109  * The corresponding standard outer EtherType (TPID) value is
1110  * RTE_ETHER_TYPE_ETAG. It can be overridden by the preceding pattern item.
1111  */
1112 struct rte_flow_item_e_tag {
1113 	/**
1114 	 * E-Tag control information (E-TCI).
1115 	 * E-PCP (3b), E-DEI (1b), ingress E-CID base (12b).
1116 	 */
1117 	rte_be16_t epcp_edei_in_ecid_b;
1118 	/** Reserved (2b), GRP (2b), E-CID base (12b). */
1119 	rte_be16_t rsvd_grp_ecid_b;
1120 	uint8_t in_ecid_e; /**< Ingress E-CID ext. */
1121 	uint8_t ecid_e; /**< E-CID ext. */
1122 	rte_be16_t inner_type; /**< Inner EtherType or TPID. */
1123 };
1124 
1125 /** Default mask for RTE_FLOW_ITEM_TYPE_E_TAG. */
1126 #ifndef __cplusplus
1127 static const struct rte_flow_item_e_tag rte_flow_item_e_tag_mask = {
1128 	.rsvd_grp_ecid_b = RTE_BE16(0x3fff),
1129 };
1130 #endif
1131 
1132 /**
1133  * RTE_FLOW_ITEM_TYPE_NVGRE.
1134  *
1135  * Matches a NVGRE header.
1136  */
1137 struct rte_flow_item_nvgre {
1138 	/**
1139 	 * Checksum (1b), undefined (1b), key bit (1b), sequence number (1b),
1140 	 * reserved 0 (9b), version (3b).
1141 	 *
1142 	 * c_k_s_rsvd0_ver must have value 0x2000 according to RFC 7637.
1143 	 */
1144 	rte_be16_t c_k_s_rsvd0_ver;
1145 	rte_be16_t protocol; /**< Protocol type (0x6558). */
1146 	uint8_t tni[3]; /**< Virtual subnet ID. */
1147 	uint8_t flow_id; /**< Flow ID. */
1148 };
1149 
1150 /** Default mask for RTE_FLOW_ITEM_TYPE_NVGRE. */
1151 #ifndef __cplusplus
1152 static const struct rte_flow_item_nvgre rte_flow_item_nvgre_mask = {
1153 	.tni = "\xff\xff\xff",
1154 };
1155 #endif
1156 
1157 /**
1158  * RTE_FLOW_ITEM_TYPE_MPLS.
1159  *
1160  * Matches a MPLS header.
1161  */
1162 struct rte_flow_item_mpls {
1163 	/**
1164 	 * Label (20b), TC (3b), Bottom of Stack (1b).
1165 	 */
1166 	uint8_t label_tc_s[3];
1167 	uint8_t ttl; /** Time-to-Live. */
1168 };
1169 
1170 /** Default mask for RTE_FLOW_ITEM_TYPE_MPLS. */
1171 #ifndef __cplusplus
1172 static const struct rte_flow_item_mpls rte_flow_item_mpls_mask = {
1173 	.label_tc_s = "\xff\xff\xf0",
1174 };
1175 #endif
1176 
1177 /**
1178  * RTE_FLOW_ITEM_TYPE_GRE.
1179  *
1180  * Matches a GRE header.
1181  */
1182 struct rte_flow_item_gre {
1183 	/**
1184 	 * Checksum (1b), reserved 0 (12b), version (3b).
1185 	 * Refer to RFC 2784.
1186 	 */
1187 	rte_be16_t c_rsvd0_ver;
1188 	rte_be16_t protocol; /**< Protocol type. */
1189 };
1190 
1191 /** Default mask for RTE_FLOW_ITEM_TYPE_GRE. */
1192 #ifndef __cplusplus
1193 static const struct rte_flow_item_gre rte_flow_item_gre_mask = {
1194 	.protocol = RTE_BE16(0xffff),
1195 };
1196 #endif
1197 
1198 /**
1199  * RTE_FLOW_ITEM_TYPE_FUZZY
1200  *
1201  * Fuzzy pattern match, expect faster than default.
1202  *
1203  * This is for device that support fuzzy match option.
1204  * Usually a fuzzy match is fast but the cost is accuracy.
1205  * i.e. Signature Match only match pattern's hash value, but it is
1206  * possible two different patterns have the same hash value.
1207  *
1208  * Matching accuracy level can be configure by threshold.
1209  * Driver can divide the range of threshold and map to different
1210  * accuracy levels that device support.
1211  *
1212  * Threshold 0 means perfect match (no fuzziness), while threshold
1213  * 0xffffffff means fuzziest match.
1214  */
1215 struct rte_flow_item_fuzzy {
1216 	uint32_t thresh; /**< Accuracy threshold. */
1217 };
1218 
1219 /** Default mask for RTE_FLOW_ITEM_TYPE_FUZZY. */
1220 #ifndef __cplusplus
1221 static const struct rte_flow_item_fuzzy rte_flow_item_fuzzy_mask = {
1222 	.thresh = 0xffffffff,
1223 };
1224 #endif
1225 
1226 /**
1227  * RTE_FLOW_ITEM_TYPE_GTP.
1228  *
1229  * Matches a GTPv1 header.
1230  */
1231 struct rte_flow_item_gtp {
1232 	/**
1233 	 * Version (3b), protocol type (1b), reserved (1b),
1234 	 * Extension header flag (1b),
1235 	 * Sequence number flag (1b),
1236 	 * N-PDU number flag (1b).
1237 	 */
1238 	uint8_t v_pt_rsv_flags;
1239 	uint8_t msg_type; /**< Message type. */
1240 	rte_be16_t msg_len; /**< Message length. */
1241 	rte_be32_t teid; /**< Tunnel endpoint identifier. */
1242 };
1243 
1244 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP. */
1245 #ifndef __cplusplus
1246 static const struct rte_flow_item_gtp rte_flow_item_gtp_mask = {
1247 	.teid = RTE_BE32(0xffffffff),
1248 };
1249 #endif
1250 
1251 /**
1252  * RTE_FLOW_ITEM_TYPE_ESP
1253  *
1254  * Matches an ESP header.
1255  */
1256 struct rte_flow_item_esp {
1257 	struct rte_esp_hdr hdr; /**< ESP header definition. */
1258 };
1259 
1260 /** Default mask for RTE_FLOW_ITEM_TYPE_ESP. */
1261 #ifndef __cplusplus
1262 static const struct rte_flow_item_esp rte_flow_item_esp_mask = {
1263 	.hdr = {
1264 		.spi = RTE_BE32(0xffffffff),
1265 	},
1266 };
1267 #endif
1268 
1269 /**
1270  * RTE_FLOW_ITEM_TYPE_GENEVE.
1271  *
1272  * Matches a GENEVE header.
1273  */
1274 struct rte_flow_item_geneve {
1275 	/**
1276 	 * Version (2b), length of the options fields (6b), OAM packet (1b),
1277 	 * critical options present (1b), reserved 0 (6b).
1278 	 */
1279 	rte_be16_t ver_opt_len_o_c_rsvd0;
1280 	rte_be16_t protocol; /**< Protocol type. */
1281 	uint8_t vni[3]; /**< Virtual Network Identifier. */
1282 	uint8_t rsvd1; /**< Reserved, normally 0x00. */
1283 };
1284 
1285 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE. */
1286 #ifndef __cplusplus
1287 static const struct rte_flow_item_geneve rte_flow_item_geneve_mask = {
1288 	.vni = "\xff\xff\xff",
1289 };
1290 #endif
1291 
1292 /**
1293  * RTE_FLOW_ITEM_TYPE_VXLAN_GPE (draft-ietf-nvo3-vxlan-gpe-05).
1294  *
1295  * Matches a VXLAN-GPE header.
1296  */
1297 struct rte_flow_item_vxlan_gpe {
1298 	uint8_t flags; /**< Normally 0x0c (I and P flags). */
1299 	uint8_t rsvd0[2]; /**< Reserved, normally 0x0000. */
1300 	uint8_t protocol; /**< Protocol type. */
1301 	uint8_t vni[3]; /**< VXLAN identifier. */
1302 	uint8_t rsvd1; /**< Reserved, normally 0x00. */
1303 };
1304 
1305 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN_GPE. */
1306 #ifndef __cplusplus
1307 static const struct rte_flow_item_vxlan_gpe rte_flow_item_vxlan_gpe_mask = {
1308 	.vni = "\xff\xff\xff",
1309 };
1310 #endif
1311 
1312 /**
1313  * RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4
1314  *
1315  * Matches an ARP header for Ethernet/IPv4.
1316  */
1317 struct rte_flow_item_arp_eth_ipv4 {
1318 	rte_be16_t hrd; /**< Hardware type, normally 1. */
1319 	rte_be16_t pro; /**< Protocol type, normally 0x0800. */
1320 	uint8_t hln; /**< Hardware address length, normally 6. */
1321 	uint8_t pln; /**< Protocol address length, normally 4. */
1322 	rte_be16_t op; /**< Opcode (1 for request, 2 for reply). */
1323 	struct rte_ether_addr sha; /**< Sender hardware address. */
1324 	rte_be32_t spa; /**< Sender IPv4 address. */
1325 	struct rte_ether_addr tha; /**< Target hardware address. */
1326 	rte_be32_t tpa; /**< Target IPv4 address. */
1327 };
1328 
1329 /** Default mask for RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4. */
1330 #ifndef __cplusplus
1331 static const struct rte_flow_item_arp_eth_ipv4
1332 rte_flow_item_arp_eth_ipv4_mask = {
1333 	.sha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1334 	.spa = RTE_BE32(0xffffffff),
1335 	.tha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1336 	.tpa = RTE_BE32(0xffffffff),
1337 };
1338 #endif
1339 
1340 /**
1341  * RTE_FLOW_ITEM_TYPE_IPV6_EXT
1342  *
1343  * Matches the presence of any IPv6 extension header.
1344  *
1345  * Normally preceded by any of:
1346  *
1347  * - RTE_FLOW_ITEM_TYPE_IPV6
1348  * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1349  */
1350 struct rte_flow_item_ipv6_ext {
1351 	uint8_t next_hdr; /**< Next header. */
1352 };
1353 
1354 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6_EXT. */
1355 #ifndef __cplusplus
1356 static const
1357 struct rte_flow_item_ipv6_ext rte_flow_item_ipv6_ext_mask = {
1358 	.next_hdr = 0xff,
1359 };
1360 #endif
1361 
1362 /**
1363  * RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT
1364  *
1365  * Matches the presence of IPv6 fragment extension header.
1366  *
1367  * Preceded by any of:
1368  *
1369  * - RTE_FLOW_ITEM_TYPE_IPV6
1370  * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1371  */
1372 struct rte_flow_item_ipv6_frag_ext {
1373 	struct rte_ipv6_fragment_ext hdr;
1374 };
1375 
1376 /**
1377  * RTE_FLOW_ITEM_TYPE_ICMP6
1378  *
1379  * Matches any ICMPv6 header.
1380  */
1381 struct rte_flow_item_icmp6 {
1382 	uint8_t type; /**< ICMPv6 type. */
1383 	uint8_t code; /**< ICMPv6 code. */
1384 	uint16_t checksum; /**< ICMPv6 checksum. */
1385 };
1386 
1387 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6. */
1388 #ifndef __cplusplus
1389 static const struct rte_flow_item_icmp6 rte_flow_item_icmp6_mask = {
1390 	.type = 0xff,
1391 	.code = 0xff,
1392 };
1393 #endif
1394 
1395 /**
1396  * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1397  *
1398  * Matches an ICMPv6 neighbor discovery solicitation.
1399  */
1400 struct rte_flow_item_icmp6_nd_ns {
1401 	uint8_t type; /**< ICMPv6 type, normally 135. */
1402 	uint8_t code; /**< ICMPv6 code, normally 0. */
1403 	rte_be16_t checksum; /**< ICMPv6 checksum. */
1404 	rte_be32_t reserved; /**< Reserved, normally 0. */
1405 	uint8_t target_addr[16]; /**< Target address. */
1406 };
1407 
1408 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS. */
1409 #ifndef __cplusplus
1410 static const
1411 struct rte_flow_item_icmp6_nd_ns rte_flow_item_icmp6_nd_ns_mask = {
1412 	.target_addr =
1413 		"\xff\xff\xff\xff\xff\xff\xff\xff"
1414 		"\xff\xff\xff\xff\xff\xff\xff\xff",
1415 };
1416 #endif
1417 
1418 /**
1419  * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1420  *
1421  * Matches an ICMPv6 neighbor discovery advertisement.
1422  */
1423 struct rte_flow_item_icmp6_nd_na {
1424 	uint8_t type; /**< ICMPv6 type, normally 136. */
1425 	uint8_t code; /**< ICMPv6 code, normally 0. */
1426 	rte_be16_t checksum; /**< ICMPv6 checksum. */
1427 	/**
1428 	 * Route flag (1b), solicited flag (1b), override flag (1b),
1429 	 * reserved (29b).
1430 	 */
1431 	rte_be32_t rso_reserved;
1432 	uint8_t target_addr[16]; /**< Target address. */
1433 };
1434 
1435 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA. */
1436 #ifndef __cplusplus
1437 static const
1438 struct rte_flow_item_icmp6_nd_na rte_flow_item_icmp6_nd_na_mask = {
1439 	.target_addr =
1440 		"\xff\xff\xff\xff\xff\xff\xff\xff"
1441 		"\xff\xff\xff\xff\xff\xff\xff\xff",
1442 };
1443 #endif
1444 
1445 /**
1446  * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1447  *
1448  * Matches the presence of any ICMPv6 neighbor discovery option.
1449  *
1450  * Normally preceded by any of:
1451  *
1452  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1453  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1454  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1455  */
1456 struct rte_flow_item_icmp6_nd_opt {
1457 	uint8_t type; /**< ND option type. */
1458 	uint8_t length; /**< ND option length. */
1459 };
1460 
1461 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT. */
1462 #ifndef __cplusplus
1463 static const struct rte_flow_item_icmp6_nd_opt
1464 rte_flow_item_icmp6_nd_opt_mask = {
1465 	.type = 0xff,
1466 };
1467 #endif
1468 
1469 /**
1470  * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH
1471  *
1472  * Matches an ICMPv6 neighbor discovery source Ethernet link-layer address
1473  * option.
1474  *
1475  * Normally preceded by any of:
1476  *
1477  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1478  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1479  */
1480 struct rte_flow_item_icmp6_nd_opt_sla_eth {
1481 	uint8_t type; /**< ND option type, normally 1. */
1482 	uint8_t length; /**< ND option length, normally 1. */
1483 	struct rte_ether_addr sla; /**< Source Ethernet LLA. */
1484 };
1485 
1486 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH. */
1487 #ifndef __cplusplus
1488 static const struct rte_flow_item_icmp6_nd_opt_sla_eth
1489 rte_flow_item_icmp6_nd_opt_sla_eth_mask = {
1490 	.sla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1491 };
1492 #endif
1493 
1494 /**
1495  * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH
1496  *
1497  * Matches an ICMPv6 neighbor discovery target Ethernet link-layer address
1498  * option.
1499  *
1500  * Normally preceded by any of:
1501  *
1502  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1503  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1504  */
1505 struct rte_flow_item_icmp6_nd_opt_tla_eth {
1506 	uint8_t type; /**< ND option type, normally 2. */
1507 	uint8_t length; /**< ND option length, normally 1. */
1508 	struct rte_ether_addr tla; /**< Target Ethernet LLA. */
1509 };
1510 
1511 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH. */
1512 #ifndef __cplusplus
1513 static const struct rte_flow_item_icmp6_nd_opt_tla_eth
1514 rte_flow_item_icmp6_nd_opt_tla_eth_mask = {
1515 	.tla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1516 };
1517 #endif
1518 
1519 /**
1520  * RTE_FLOW_ITEM_TYPE_META
1521  *
1522  * Matches a specified metadata value. On egress, metadata can be set
1523  * either by mbuf dynamic metadata field with RTE_MBUF_DYNFLAG_TX_METADATA flag
1524  * or RTE_FLOW_ACTION_TYPE_SET_META. On ingress, RTE_FLOW_ACTION_TYPE_SET_META
1525  * sets metadata for a packet and the metadata will be reported via mbuf
1526  * metadata dynamic field with RTE_MBUF_DYNFLAG_RX_METADATA flag. The dynamic
1527  * mbuf field must be registered in advance by
1528  * rte_flow_dynf_metadata_register().
1529  */
1530 struct rte_flow_item_meta {
1531 	uint32_t data;
1532 };
1533 
1534 /** Default mask for RTE_FLOW_ITEM_TYPE_META. */
1535 #ifndef __cplusplus
1536 static const struct rte_flow_item_meta rte_flow_item_meta_mask = {
1537 	.data = UINT32_MAX,
1538 };
1539 #endif
1540 
1541 /**
1542  * RTE_FLOW_ITEM_TYPE_GTP_PSC.
1543  *
1544  * Matches a GTP PDU extension header with type 0x85.
1545  */
1546 struct rte_flow_item_gtp_psc {
1547 	struct rte_gtp_psc_generic_hdr hdr; /**< gtp psc generic hdr. */
1548 };
1549 
1550 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP_PSC. */
1551 #ifndef __cplusplus
1552 static const struct rte_flow_item_gtp_psc
1553 rte_flow_item_gtp_psc_mask = {
1554 	.hdr.qfi = 0x3f,
1555 };
1556 #endif
1557 
1558 /**
1559  * RTE_FLOW_ITEM_TYPE_PPPOE.
1560  *
1561  * Matches a PPPoE header.
1562  */
1563 struct rte_flow_item_pppoe {
1564 	/**
1565 	 * Version (4b), type (4b).
1566 	 */
1567 	uint8_t version_type;
1568 	uint8_t code; /**< Message type. */
1569 	rte_be16_t session_id; /**< Session identifier. */
1570 	rte_be16_t length; /**< Payload length. */
1571 };
1572 
1573 /**
1574  * RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID.
1575  *
1576  * Matches a PPPoE optional proto_id field.
1577  *
1578  * It only applies to PPPoE session packets.
1579  *
1580  * Normally preceded by any of:
1581  *
1582  * - RTE_FLOW_ITEM_TYPE_PPPOE
1583  * - RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID
1584  */
1585 struct rte_flow_item_pppoe_proto_id {
1586 	rte_be16_t proto_id; /**< PPP protocol identifier. */
1587 };
1588 
1589 /** Default mask for RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID. */
1590 #ifndef __cplusplus
1591 static const struct rte_flow_item_pppoe_proto_id
1592 rte_flow_item_pppoe_proto_id_mask = {
1593 	.proto_id = RTE_BE16(0xffff),
1594 };
1595 #endif
1596 
1597 /**
1598  * @warning
1599  * @b EXPERIMENTAL: this structure may change without prior notice
1600  *
1601  * RTE_FLOW_ITEM_TYPE_TAG
1602  *
1603  * Matches a specified tag value at the specified index.
1604  */
1605 struct rte_flow_item_tag {
1606 	uint32_t data;
1607 	uint8_t index;
1608 };
1609 
1610 /** Default mask for RTE_FLOW_ITEM_TYPE_TAG. */
1611 #ifndef __cplusplus
1612 static const struct rte_flow_item_tag rte_flow_item_tag_mask = {
1613 	.data = 0xffffffff,
1614 	.index = 0xff,
1615 };
1616 #endif
1617 
1618 /**
1619  * RTE_FLOW_ITEM_TYPE_L2TPV3OIP.
1620  *
1621  * Matches a L2TPv3 over IP header.
1622  */
1623 struct rte_flow_item_l2tpv3oip {
1624 	rte_be32_t session_id; /**< Session ID. */
1625 };
1626 
1627 /** Default mask for RTE_FLOW_ITEM_TYPE_L2TPV3OIP. */
1628 #ifndef __cplusplus
1629 static const struct rte_flow_item_l2tpv3oip rte_flow_item_l2tpv3oip_mask = {
1630 	.session_id = RTE_BE32(UINT32_MAX),
1631 };
1632 #endif
1633 
1634 
1635 /**
1636  * @warning
1637  * @b EXPERIMENTAL: this structure may change without prior notice
1638  *
1639  * RTE_FLOW_ITEM_TYPE_MARK
1640  *
1641  * Matches an arbitrary integer value which was set using the ``MARK`` action
1642  * in a previously matched rule.
1643  *
1644  * This item can only be specified once as a match criteria as the ``MARK``
1645  * action can only be specified once in a flow action.
1646  *
1647  * This value is arbitrary and application-defined. Maximum allowed value
1648  * depends on the underlying implementation.
1649  *
1650  * Depending on the underlying implementation the MARK item may be supported on
1651  * the physical device, with virtual groups in the PMD or not at all.
1652  */
1653 struct rte_flow_item_mark {
1654 	uint32_t id; /**< Integer value to match against. */
1655 };
1656 
1657 /** Default mask for RTE_FLOW_ITEM_TYPE_MARK. */
1658 #ifndef __cplusplus
1659 static const struct rte_flow_item_mark rte_flow_item_mark_mask = {
1660 	.id = 0xffffffff,
1661 };
1662 #endif
1663 
1664 /**
1665  * @warning
1666  * @b EXPERIMENTAL: this structure may change without prior notice
1667  *
1668  * RTE_FLOW_ITEM_TYPE_NSH
1669  *
1670  * Match network service header (NSH), RFC 8300
1671  *
1672  */
1673 struct rte_flow_item_nsh {
1674 	uint32_t version:2;
1675 	uint32_t oam_pkt:1;
1676 	uint32_t reserved:1;
1677 	uint32_t ttl:6;
1678 	uint32_t length:6;
1679 	uint32_t reserved1:4;
1680 	uint32_t mdtype:4;
1681 	uint32_t next_proto:8;
1682 	uint32_t spi:24;
1683 	uint32_t sindex:8;
1684 };
1685 
1686 /** Default mask for RTE_FLOW_ITEM_TYPE_NSH. */
1687 #ifndef __cplusplus
1688 static const struct rte_flow_item_nsh rte_flow_item_nsh_mask = {
1689 	.mdtype = 0xf,
1690 	.next_proto = 0xff,
1691 	.spi = 0xffffff,
1692 	.sindex = 0xff,
1693 };
1694 #endif
1695 
1696 /**
1697  * @warning
1698  * @b EXPERIMENTAL: this structure may change without prior notice
1699  *
1700  * RTE_FLOW_ITEM_TYPE_IGMP
1701  *
1702  * Match Internet Group Management Protocol (IGMP), RFC 2236
1703  *
1704  */
1705 struct rte_flow_item_igmp {
1706 	uint32_t type:8;
1707 	uint32_t max_resp_time:8;
1708 	uint32_t checksum:16;
1709 	uint32_t group_addr;
1710 };
1711 
1712 /** Default mask for RTE_FLOW_ITEM_TYPE_IGMP. */
1713 #ifndef __cplusplus
1714 static const struct rte_flow_item_igmp rte_flow_item_igmp_mask = {
1715 	.group_addr = 0xffffffff,
1716 };
1717 #endif
1718 
1719 /**
1720  * @warning
1721  * @b EXPERIMENTAL: this structure may change without prior notice
1722  *
1723  * RTE_FLOW_ITEM_TYPE_AH
1724  *
1725  * Match IP Authentication Header (AH), RFC 4302
1726  *
1727  */
1728 struct rte_flow_item_ah {
1729 	uint32_t next_hdr:8;
1730 	uint32_t payload_len:8;
1731 	uint32_t reserved:16;
1732 	uint32_t spi;
1733 	uint32_t seq_num;
1734 };
1735 
1736 /** Default mask for RTE_FLOW_ITEM_TYPE_AH. */
1737 #ifndef __cplusplus
1738 static const struct rte_flow_item_ah rte_flow_item_ah_mask = {
1739 	.spi = 0xffffffff,
1740 };
1741 #endif
1742 
1743 /**
1744  * @warning
1745  * @b EXPERIMENTAL: this structure may change without prior notice
1746  *
1747  * RTE_FLOW_ITEM_TYPE_PFCP
1748  *
1749  * Match PFCP Header
1750  */
1751 struct rte_flow_item_pfcp {
1752 	uint8_t s_field;
1753 	uint8_t msg_type;
1754 	rte_be16_t msg_len;
1755 	rte_be64_t seid;
1756 };
1757 
1758 /** Default mask for RTE_FLOW_ITEM_TYPE_PFCP. */
1759 #ifndef __cplusplus
1760 static const struct rte_flow_item_pfcp rte_flow_item_pfcp_mask = {
1761 	.s_field = 0x01,
1762 	.seid = RTE_BE64(UINT64_C(0xffffffffffffffff)),
1763 };
1764 #endif
1765 
1766 /**
1767  * @warning
1768  * @b EXPERIMENTAL: this structure may change without prior notice
1769  *
1770  * RTE_FLOW_ITEM_TYPE_ECPRI
1771  *
1772  * Match eCPRI Header
1773  */
1774 struct rte_flow_item_ecpri {
1775 	struct rte_ecpri_combined_msg_hdr hdr;
1776 };
1777 
1778 /** Default mask for RTE_FLOW_ITEM_TYPE_ECPRI. */
1779 #ifndef __cplusplus
1780 static const struct rte_flow_item_ecpri rte_flow_item_ecpri_mask = {
1781 	.hdr = {
1782 		.common = {
1783 			.u32 = 0x0,
1784 		},
1785 	},
1786 };
1787 #endif
1788 
1789 /**
1790  * RTE_FLOW_ITEM_TYPE_GENEVE_OPT
1791  *
1792  * Matches a GENEVE Variable Length Option
1793  */
1794 struct rte_flow_item_geneve_opt {
1795 	rte_be16_t option_class;
1796 	uint8_t option_type;
1797 	uint8_t option_len;
1798 	uint32_t *data;
1799 };
1800 
1801 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE_OPT. */
1802 #ifndef __cplusplus
1803 static const struct rte_flow_item_geneve_opt
1804 rte_flow_item_geneve_opt_mask = {
1805 	.option_type = 0xff,
1806 };
1807 #endif
1808 
1809 /**
1810  * @warning
1811  * @b EXPERIMENTAL: this structure may change without prior notice
1812  *
1813  * RTE_FLOW_ITEM_TYPE_INTEGRITY
1814  *
1815  * Match on packet integrity check result.
1816  */
1817 struct rte_flow_item_integrity {
1818 	/** Tunnel encapsulation level the item should apply to.
1819 	 * @see rte_flow_action_rss
1820 	 */
1821 	uint32_t level;
1822 	RTE_STD_C11
1823 	union {
1824 		__extension__
1825 		struct {
1826 			/** The packet is valid after passing all HW checks. */
1827 			uint64_t packet_ok:1;
1828 			/** L2 layer is valid after passing all HW checks. */
1829 			uint64_t l2_ok:1;
1830 			/** L3 layer is valid after passing all HW checks. */
1831 			uint64_t l3_ok:1;
1832 			/** L4 layer is valid after passing all HW checks. */
1833 			uint64_t l4_ok:1;
1834 			/** L2 layer CRC is valid. */
1835 			uint64_t l2_crc_ok:1;
1836 			/** IPv4 layer checksum is valid. */
1837 			uint64_t ipv4_csum_ok:1;
1838 			/** L4 layer checksum is valid. */
1839 			uint64_t l4_csum_ok:1;
1840 			/** L3 length is smaller than frame length. */
1841 			uint64_t l3_len_ok:1;
1842 			uint64_t reserved:56;
1843 		};
1844 		uint64_t value;
1845 	};
1846 };
1847 
1848 #ifndef __cplusplus
1849 static const struct rte_flow_item_integrity
1850 rte_flow_item_integrity_mask = {
1851 	.level = 0,
1852 	.value = 0,
1853 };
1854 #endif
1855 
1856 /**
1857  * The packet is valid after conntrack checking.
1858  */
1859 #define RTE_FLOW_CONNTRACK_PKT_STATE_VALID RTE_BIT32(0)
1860 /**
1861  * The state of the connection is changed.
1862  */
1863 #define RTE_FLOW_CONNTRACK_PKT_STATE_CHANGED RTE_BIT32(1)
1864 /**
1865  * Error is detected on this packet for this connection and
1866  * an invalid state is set.
1867  */
1868 #define RTE_FLOW_CONNTRACK_PKT_STATE_INVALID RTE_BIT32(2)
1869 /**
1870  * The HW connection tracking module is disabled.
1871  * It can be due to application command or an invalid state.
1872  */
1873 #define RTE_FLOW_CONNTRACK_PKT_STATE_DISABLED RTE_BIT32(3)
1874 /**
1875  * The packet contains some bad field(s) and cannot continue
1876  * with the conntrack module checking.
1877  */
1878 #define RTE_FLOW_CONNTRACK_PKT_STATE_BAD RTE_BIT32(4)
1879 
1880 /**
1881  * @warning
1882  * @b EXPERIMENTAL: this structure may change without prior notice
1883  *
1884  * RTE_FLOW_ITEM_TYPE_CONNTRACK
1885  *
1886  * Matches the state of a packet after it passed the connection tracking
1887  * examination. The state is a bitmap of one RTE_FLOW_CONNTRACK_PKT_STATE*
1888  * or a reasonable combination of these bits.
1889  */
1890 struct rte_flow_item_conntrack {
1891 	uint32_t flags;
1892 };
1893 
1894 /** Default mask for RTE_FLOW_ITEM_TYPE_CONNTRACK. */
1895 #ifndef __cplusplus
1896 static const struct rte_flow_item_conntrack rte_flow_item_conntrack_mask = {
1897 	.flags = 0xffffffff,
1898 };
1899 #endif
1900 
1901 /**
1902  * @warning
1903  * @b EXPERIMENTAL: this structure may change without prior notice
1904  *
1905  * Provides an ethdev port ID for use with the following items:
1906  * RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR,
1907  * RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT.
1908  */
1909 struct rte_flow_item_ethdev {
1910 	uint16_t port_id; /**< ethdev port ID */
1911 };
1912 
1913 /** Default mask for items based on struct rte_flow_item_ethdev */
1914 #ifndef __cplusplus
1915 static const struct rte_flow_item_ethdev rte_flow_item_ethdev_mask = {
1916 	.port_id = 0xffff,
1917 };
1918 #endif
1919 
1920 /**
1921  * @warning
1922  * @b EXPERIMENTAL: this structure may change without prior notice
1923  *
1924  * RTE_FLOW_ITEM_TYPE_L2TPV2
1925  *
1926  * Matches L2TPv2 Header
1927  */
1928 struct rte_flow_item_l2tpv2 {
1929 	struct rte_l2tpv2_combined_msg_hdr hdr;
1930 };
1931 
1932 /** Default mask for RTE_FLOW_ITEM_TYPE_L2TPV2. */
1933 #ifndef __cplusplus
1934 static const struct rte_flow_item_l2tpv2 rte_flow_item_l2tpv2_mask = {
1935 	/*
1936 	 * flags and version bit mask
1937 	 * 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
1938 	 * T L x x S x O P x x x x V V V V
1939 	 */
1940 	.hdr = {
1941 		.common = {
1942 			.flags_version = RTE_BE16(0xcb0f),
1943 		},
1944 	},
1945 };
1946 #endif
1947 
1948 /**
1949  * @warning
1950  * @b EXPERIMENTAL: this structure may change without prior notice
1951  *
1952  * RTE_FLOW_ITEM_TYPE_PPP
1953  *
1954  * Matches PPP Header
1955  */
1956 struct rte_flow_item_ppp {
1957 	struct rte_ppp_hdr hdr;
1958 };
1959 
1960 /** Default mask for RTE_FLOW_ITEM_TYPE_PPP. */
1961 #ifndef __cplusplus
1962 static const struct rte_flow_item_ppp rte_flow_item_ppp_mask = {
1963 	.hdr = {
1964 		.addr = 0xff,
1965 		.ctrl = 0xff,
1966 		.proto_id = RTE_BE16(0xffff),
1967 	}
1968 };
1969 #endif
1970 
1971 /**
1972  * Matching pattern item definition.
1973  *
1974  * A pattern is formed by stacking items starting from the lowest protocol
1975  * layer to match. This stacking restriction does not apply to meta items
1976  * which can be placed anywhere in the stack without affecting the meaning
1977  * of the resulting pattern.
1978  *
1979  * Patterns are terminated by END items.
1980  *
1981  * The spec field should be a valid pointer to a structure of the related
1982  * item type. It may remain unspecified (NULL) in many cases to request
1983  * broad (nonspecific) matching. In such cases, last and mask must also be
1984  * set to NULL.
1985  *
1986  * Optionally, last can point to a structure of the same type to define an
1987  * inclusive range. This is mostly supported by integer and address fields,
1988  * may cause errors otherwise. Fields that do not support ranges must be set
1989  * to 0 or to the same value as the corresponding fields in spec.
1990  *
1991  * Only the fields defined to nonzero values in the default masks (see
1992  * rte_flow_item_{name}_mask constants) are considered relevant by
1993  * default. This can be overridden by providing a mask structure of the
1994  * same type with applicable bits set to one. It can also be used to
1995  * partially filter out specific fields (e.g. as an alternate mean to match
1996  * ranges of IP addresses).
1997  *
1998  * Mask is a simple bit-mask applied before interpreting the contents of
1999  * spec and last, which may yield unexpected results if not used
2000  * carefully. For example, if for an IPv4 address field, spec provides
2001  * 10.1.2.3, last provides 10.3.4.5 and mask provides 255.255.0.0, the
2002  * effective range becomes 10.1.0.0 to 10.3.255.255.
2003  */
2004 struct rte_flow_item {
2005 	enum rte_flow_item_type type; /**< Item type. */
2006 	const void *spec; /**< Pointer to item specification structure. */
2007 	const void *last; /**< Defines an inclusive range (spec to last). */
2008 	const void *mask; /**< Bit-mask applied to spec and last. */
2009 };
2010 
2011 /**
2012  * @warning
2013  * @b EXPERIMENTAL: this structure may change without prior notice
2014  *
2015  * RTE_FLOW_ITEM_TYPE_FLEX
2016  *
2017  * Matches a specified set of fields within the network protocol
2018  * header. Each field is presented as set of bits with specified width, and
2019  * bit offset from the header beginning.
2020  *
2021  * The pattern is concatenation of bit fields configured at item creation
2022  * by rte_flow_flex_item_create(). At configuration the fields are presented
2023  * by sample_data array.
2024  *
2025  * This type does not support ranges (struct rte_flow_item.last).
2026  */
2027 struct rte_flow_item_flex {
2028 	struct rte_flow_item_flex_handle *handle; /**< Opaque item handle. */
2029 	uint32_t length; /**< Pattern length in bytes. */
2030 	const uint8_t *pattern; /**< Combined bitfields pattern to match. */
2031 };
2032 /**
2033  * Field bit offset calculation mode.
2034  */
2035 enum rte_flow_item_flex_field_mode {
2036 	/**
2037 	 * Dummy field, used for byte boundary alignment in pattern.
2038 	 * Pattern mask and data are ignored in the match. All configuration
2039 	 * parameters besides field size are ignored.
2040 	 */
2041 	FIELD_MODE_DUMMY = 0,
2042 	/**
2043 	 * Fixed offset field. The bit offset from header beginning
2044 	 * is permanent and defined by field_base parameter.
2045 	 */
2046 	FIELD_MODE_FIXED,
2047 	/**
2048 	 * The field bit offset is extracted from other header field (indirect
2049 	 * offset field). The resulting field offset to match is calculated as:
2050 	 *
2051 	 *    field_base + (*offset_base & offset_mask) << offset_shift
2052 	 */
2053 	FIELD_MODE_OFFSET,
2054 	/**
2055 	 * The field bit offset is extracted from other header field (indirect
2056 	 * offset field), the latter is considered as bitmask containing some
2057 	 * number of one bits, the resulting field offset to match is
2058 	 * calculated as:
2059 	 *
2060 	 *    field_base + bitcount(*offset_base & offset_mask) << offset_shift
2061 	 */
2062 	FIELD_MODE_BITMASK,
2063 };
2064 
2065 /**
2066  * Flex item field tunnel mode
2067  */
2068 enum rte_flow_item_flex_tunnel_mode {
2069 	/**
2070 	 * The protocol header can be present in the packet only once.
2071 	 * No multiple flex item flow inclusions (for inner/outer) are allowed.
2072 	 * No any relations with tunnel protocols are imposed. The drivers
2073 	 * can optimize hardware resource usage to handle match on single flex
2074 	 * item of specific type.
2075 	 */
2076 	FLEX_TUNNEL_MODE_SINGLE = 0,
2077 	/**
2078 	 * Flex item presents outer header only.
2079 	 */
2080 	FLEX_TUNNEL_MODE_OUTER,
2081 	/**
2082 	 * Flex item presents inner header only.
2083 	 */
2084 	FLEX_TUNNEL_MODE_INNER,
2085 	/**
2086 	 * Flex item presents either inner or outer header. The driver
2087 	 * handles as many multiple inners as hardware supports.
2088 	 */
2089 	FLEX_TUNNEL_MODE_MULTI,
2090 	/**
2091 	 * Flex item presents tunnel protocol header.
2092 	 */
2093 	FLEX_TUNNEL_MODE_TUNNEL,
2094 };
2095 
2096 /**
2097  *
2098  * @warning
2099  * @b EXPERIMENTAL: this structure may change without prior notice
2100  */
2101 __extension__
2102 struct rte_flow_item_flex_field {
2103 	/** Defines how match field offset is calculated over the packet. */
2104 	enum rte_flow_item_flex_field_mode field_mode;
2105 	uint32_t field_size; /**< Field size in bits. */
2106 	int32_t field_base; /**< Field offset in bits. */
2107 	uint32_t offset_base; /**< Indirect offset field offset in bits. */
2108 	uint32_t offset_mask; /**< Indirect offset field bit mask. */
2109 	int32_t offset_shift; /**< Indirect offset multiply factor. */
2110 	uint32_t field_id:16; /**< Device hint, for multiple items in flow. */
2111 	uint32_t reserved:16; /**< Reserved field. */
2112 };
2113 
2114 /**
2115  * @warning
2116  * @b EXPERIMENTAL: this structure may change without prior notice
2117  */
2118 struct rte_flow_item_flex_link {
2119 	/**
2120 	 * Preceding/following header. The item type must be always provided.
2121 	 * For preceding one item must specify the header value/mask to match
2122 	 * for the link be taken and start the flex item header parsing.
2123 	 */
2124 	struct rte_flow_item item;
2125 	/**
2126 	 * Next field value to match to continue with one of the configured
2127 	 * next protocols.
2128 	 */
2129 	uint32_t next;
2130 };
2131 
2132 /**
2133  * @warning
2134  * @b EXPERIMENTAL: this structure may change without prior notice
2135  */
2136 struct rte_flow_item_flex_conf {
2137 	/**
2138 	 * Specifies the flex item and tunnel relations and tells the PMD
2139 	 * whether flex item can be used for inner, outer or both headers,
2140 	 * or whether flex item presents the tunnel protocol itself.
2141 	 */
2142 	enum rte_flow_item_flex_tunnel_mode tunnel;
2143 	/**
2144 	 * The next header offset, it presents the network header size covered
2145 	 * by the flex item and can be obtained with all supported offset
2146 	 * calculating methods (fixed, dedicated field, bitmask, etc).
2147 	 */
2148 	struct rte_flow_item_flex_field next_header;
2149 	/**
2150 	 * Specifies the next protocol field to match with link next protocol
2151 	 * values and continue packet parsing with matching link.
2152 	 */
2153 	struct rte_flow_item_flex_field next_protocol;
2154 	/**
2155 	 * The fields will be sampled and presented for explicit match
2156 	 * with pattern in the rte_flow_flex_item. There can be multiple
2157 	 * fields descriptors, the number should be specified by nb_samples.
2158 	 */
2159 	struct rte_flow_item_flex_field *sample_data;
2160 	/** Number of field descriptors in the sample_data array. */
2161 	uint32_t nb_samples;
2162 	/**
2163 	 * Input link defines the flex item relation with preceding
2164 	 * header. It specified the preceding item type and provides pattern
2165 	 * to match. The flex item will continue parsing and will provide the
2166 	 * data to flow match in case if there is the match with one of input
2167 	 * links.
2168 	 */
2169 	struct rte_flow_item_flex_link *input_link;
2170 	/** Number of link descriptors in the input link array. */
2171 	uint32_t nb_inputs;
2172 	/**
2173 	 * Output link defines the next protocol field value to match and
2174 	 * the following protocol header to continue packet parsing. Also
2175 	 * defines the tunnel-related behaviour.
2176 	 */
2177 	struct rte_flow_item_flex_link *output_link;
2178 	/** Number of link descriptors in the output link array. */
2179 	uint32_t nb_outputs;
2180 };
2181 
2182 /**
2183  * Action types.
2184  *
2185  * Each possible action is represented by a type.
2186  * An action can have an associated configuration object.
2187  * Several actions combined in a list can be assigned
2188  * to a flow rule and are performed in order.
2189  *
2190  * They fall in three categories:
2191  *
2192  * - Actions that modify the fate of matching traffic, for instance by
2193  *   dropping or assigning it a specific destination.
2194  *
2195  * - Actions that modify matching traffic contents or its properties. This
2196  *   includes adding/removing encapsulation, encryption, compression and
2197  *   marks.
2198  *
2199  * - Actions related to the flow rule itself, such as updating counters or
2200  *   making it non-terminating.
2201  *
2202  * Flow rules being terminating by default, not specifying any action of the
2203  * fate kind results in undefined behavior. This applies to both ingress and
2204  * egress.
2205  *
2206  * PASSTHRU, when supported, makes a flow rule non-terminating.
2207  */
2208 enum rte_flow_action_type {
2209 	/**
2210 	 * End marker for action lists. Prevents further processing of
2211 	 * actions, thereby ending the list.
2212 	 *
2213 	 * No associated configuration structure.
2214 	 */
2215 	RTE_FLOW_ACTION_TYPE_END,
2216 
2217 	/**
2218 	 * Used as a placeholder for convenience. It is ignored and simply
2219 	 * discarded by PMDs.
2220 	 *
2221 	 * No associated configuration structure.
2222 	 */
2223 	RTE_FLOW_ACTION_TYPE_VOID,
2224 
2225 	/**
2226 	 * Leaves traffic up for additional processing by subsequent flow
2227 	 * rules; makes a flow rule non-terminating.
2228 	 *
2229 	 * No associated configuration structure.
2230 	 */
2231 	RTE_FLOW_ACTION_TYPE_PASSTHRU,
2232 
2233 	/**
2234 	 * RTE_FLOW_ACTION_TYPE_JUMP
2235 	 *
2236 	 * Redirects packets to a group on the current device.
2237 	 *
2238 	 * See struct rte_flow_action_jump.
2239 	 */
2240 	RTE_FLOW_ACTION_TYPE_JUMP,
2241 
2242 	/**
2243 	 * Attaches an integer value to packets and sets RTE_MBUF_F_RX_FDIR and
2244 	 * RTE_MBUF_F_RX_FDIR_ID mbuf flags.
2245 	 *
2246 	 * See struct rte_flow_action_mark.
2247 	 *
2248 	 * One should negotiate mark delivery from the NIC to the PMD.
2249 	 * @see rte_eth_rx_metadata_negotiate()
2250 	 * @see RTE_ETH_RX_METADATA_USER_MARK
2251 	 */
2252 	RTE_FLOW_ACTION_TYPE_MARK,
2253 
2254 	/**
2255 	 * Flags packets. Similar to MARK without a specific value; only
2256 	 * sets the RTE_MBUF_F_RX_FDIR mbuf flag.
2257 	 *
2258 	 * No associated configuration structure.
2259 	 *
2260 	 * One should negotiate flag delivery from the NIC to the PMD.
2261 	 * @see rte_eth_rx_metadata_negotiate()
2262 	 * @see RTE_ETH_RX_METADATA_USER_FLAG
2263 	 */
2264 	RTE_FLOW_ACTION_TYPE_FLAG,
2265 
2266 	/**
2267 	 * Assigns packets to a given queue index.
2268 	 *
2269 	 * See struct rte_flow_action_queue.
2270 	 */
2271 	RTE_FLOW_ACTION_TYPE_QUEUE,
2272 
2273 	/**
2274 	 * Drops packets.
2275 	 *
2276 	 * PASSTHRU overrides this action if both are specified.
2277 	 *
2278 	 * No associated configuration structure.
2279 	 */
2280 	RTE_FLOW_ACTION_TYPE_DROP,
2281 
2282 	/**
2283 	 * Enables counters for this flow rule.
2284 	 *
2285 	 * These counters can be retrieved and reset through rte_flow_query() or
2286 	 * rte_flow_action_handle_query() if the action provided via handle,
2287 	 * see struct rte_flow_query_count.
2288 	 *
2289 	 * See struct rte_flow_action_count.
2290 	 */
2291 	RTE_FLOW_ACTION_TYPE_COUNT,
2292 
2293 	/**
2294 	 * Similar to QUEUE, except RSS is additionally performed on packets
2295 	 * to spread them among several queues according to the provided
2296 	 * parameters.
2297 	 *
2298 	 * See struct rte_flow_action_rss.
2299 	 */
2300 	RTE_FLOW_ACTION_TYPE_RSS,
2301 
2302 	/**
2303 	 * @deprecated
2304 	 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2305 	 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2306 	 *
2307 	 * Directs matching traffic to the physical function (PF) of the
2308 	 * current device.
2309 	 *
2310 	 * No associated configuration structure.
2311 	 */
2312 	RTE_FLOW_ACTION_TYPE_PF,
2313 
2314 	/**
2315 	 * @deprecated
2316 	 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2317 	 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2318 	 *
2319 	 * Directs matching traffic to a given virtual function of the
2320 	 * current device.
2321 	 *
2322 	 * See struct rte_flow_action_vf.
2323 	 */
2324 	RTE_FLOW_ACTION_TYPE_VF,
2325 
2326 	/**
2327 	 * @deprecated
2328 	 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2329 	 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2330 	 *
2331 	 * Directs packets to a given physical port index of the underlying
2332 	 * device.
2333 	 *
2334 	 * See struct rte_flow_action_phy_port.
2335 	 */
2336 	RTE_FLOW_ACTION_TYPE_PHY_PORT,
2337 
2338 	/**
2339 	 * @deprecated
2340 	 * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2341 	 * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2342 	 *
2343 	 * Directs matching traffic to a given DPDK port ID.
2344 	 *
2345 	 * See struct rte_flow_action_port_id.
2346 	 */
2347 	RTE_FLOW_ACTION_TYPE_PORT_ID,
2348 
2349 	/**
2350 	 * Traffic metering and policing (MTR).
2351 	 *
2352 	 * See struct rte_flow_action_meter.
2353 	 * See file rte_mtr.h for MTR object configuration.
2354 	 */
2355 	RTE_FLOW_ACTION_TYPE_METER,
2356 
2357 	/**
2358 	 * Redirects packets to security engine of current device for security
2359 	 * processing as specified by security session.
2360 	 *
2361 	 * See struct rte_flow_action_security.
2362 	 */
2363 	RTE_FLOW_ACTION_TYPE_SECURITY,
2364 
2365 	/**
2366 	 * @deprecated
2367 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2368 	 *
2369 	 * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the
2370 	 * OpenFlow Switch Specification.
2371 	 *
2372 	 * See struct rte_flow_action_of_set_mpls_ttl.
2373 	 */
2374 	RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL,
2375 
2376 	/**
2377 	 * @deprecated
2378 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2379 	 *
2380 	 * Implements OFPAT_DEC_MPLS_TTL ("decrement MPLS TTL") as defined
2381 	 * by the OpenFlow Switch Specification.
2382 	 *
2383 	 * No associated configuration structure.
2384 	 */
2385 	RTE_FLOW_ACTION_TYPE_OF_DEC_MPLS_TTL,
2386 
2387 	/**
2388 	 * @deprecated
2389 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2390 	 *
2391 	 * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow
2392 	 * Switch Specification.
2393 	 *
2394 	 * See struct rte_flow_action_of_set_nw_ttl.
2395 	 */
2396 	RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL,
2397 
2398 	/**
2399 	 * @warning This is a legacy action.
2400 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2401 	 *
2402 	 * Implements OFPAT_DEC_NW_TTL ("decrement IP TTL") as defined by
2403 	 * the OpenFlow Switch Specification.
2404 	 *
2405 	 * No associated configuration structure.
2406 	 */
2407 	RTE_FLOW_ACTION_TYPE_OF_DEC_NW_TTL,
2408 
2409 	/**
2410 	 * @deprecated
2411 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2412 	 *
2413 	 * Implements OFPAT_COPY_TTL_OUT ("copy TTL "outwards" -- from
2414 	 * next-to-outermost to outermost") as defined by the OpenFlow
2415 	 * Switch Specification.
2416 	 *
2417 	 * No associated configuration structure.
2418 	 */
2419 	RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_OUT,
2420 
2421 	/**
2422 	 * @deprecated
2423 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2424 	 *
2425 	 * Implements OFPAT_COPY_TTL_IN ("copy TTL "inwards" -- from
2426 	 * outermost to next-to-outermost") as defined by the OpenFlow
2427 	 * Switch Specification.
2428 	 *
2429 	 * No associated configuration structure.
2430 	 */
2431 	RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_IN,
2432 
2433 	/**
2434 	 * Implements OFPAT_POP_VLAN ("pop the outer VLAN tag") as defined
2435 	 * by the OpenFlow Switch Specification.
2436 	 *
2437 	 * No associated configuration structure.
2438 	 */
2439 	RTE_FLOW_ACTION_TYPE_OF_POP_VLAN,
2440 
2441 	/**
2442 	 * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by
2443 	 * the OpenFlow Switch Specification.
2444 	 *
2445 	 * See struct rte_flow_action_of_push_vlan.
2446 	 */
2447 	RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
2448 
2449 	/**
2450 	 * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN ID") as
2451 	 * defined by the OpenFlow Switch Specification.
2452 	 *
2453 	 * See struct rte_flow_action_of_set_vlan_vid.
2454 	 */
2455 	RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
2456 
2457 	/**
2458 	 * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as
2459 	 * defined by the OpenFlow Switch Specification.
2460 	 *
2461 	 * See struct rte_flow_action_of_set_vlan_pcp.
2462 	 */
2463 	RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
2464 
2465 	/**
2466 	 * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined
2467 	 * by the OpenFlow Switch Specification.
2468 	 *
2469 	 * See struct rte_flow_action_of_pop_mpls.
2470 	 */
2471 	RTE_FLOW_ACTION_TYPE_OF_POP_MPLS,
2472 
2473 	/**
2474 	 * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by
2475 	 * the OpenFlow Switch Specification.
2476 	 *
2477 	 * See struct rte_flow_action_of_push_mpls.
2478 	 */
2479 	RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS,
2480 
2481 	/**
2482 	 * Encapsulate flow in VXLAN tunnel as defined in
2483 	 * rte_flow_action_vxlan_encap action structure.
2484 	 *
2485 	 * See struct rte_flow_action_vxlan_encap.
2486 	 */
2487 	RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP,
2488 
2489 	/**
2490 	 * Decapsulate outer most VXLAN tunnel from matched flow.
2491 	 *
2492 	 * If flow pattern does not define a valid VXLAN tunnel (as specified by
2493 	 * RFC7348) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
2494 	 * error.
2495 	 */
2496 	RTE_FLOW_ACTION_TYPE_VXLAN_DECAP,
2497 
2498 	/**
2499 	 * Encapsulate flow in NVGRE tunnel defined in the
2500 	 * rte_flow_action_nvgre_encap action structure.
2501 	 *
2502 	 * See struct rte_flow_action_nvgre_encap.
2503 	 */
2504 	RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP,
2505 
2506 	/**
2507 	 * Decapsulate outer most NVGRE tunnel from matched flow.
2508 	 *
2509 	 * If flow pattern does not define a valid NVGRE tunnel (as specified by
2510 	 * RFC7637) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
2511 	 * error.
2512 	 */
2513 	RTE_FLOW_ACTION_TYPE_NVGRE_DECAP,
2514 
2515 	/**
2516 	 * Add outer header whose template is provided in its data buffer
2517 	 *
2518 	 * See struct rte_flow_action_raw_encap.
2519 	 */
2520 	RTE_FLOW_ACTION_TYPE_RAW_ENCAP,
2521 
2522 	/**
2523 	 * Remove outer header whose template is provided in its data buffer.
2524 	 *
2525 	 * See struct rte_flow_action_raw_decap
2526 	 */
2527 	RTE_FLOW_ACTION_TYPE_RAW_DECAP,
2528 
2529 	/**
2530 	 * @warning This is a legacy action.
2531 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2532 	 *
2533 	 * Modify IPv4 source address in the outermost IPv4 header.
2534 	 *
2535 	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2536 	 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2537 	 *
2538 	 * See struct rte_flow_action_set_ipv4.
2539 	 */
2540 	RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC,
2541 
2542 	/**
2543 	 * @warning This is a legacy action.
2544 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2545 	 *
2546 	 * Modify IPv4 destination address in the outermost IPv4 header.
2547 	 *
2548 	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2549 	 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2550 	 *
2551 	 * See struct rte_flow_action_set_ipv4.
2552 	 */
2553 	RTE_FLOW_ACTION_TYPE_SET_IPV4_DST,
2554 
2555 	/**
2556 	 * @warning This is a legacy action.
2557 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2558 	 *
2559 	 * Modify IPv6 source address in the outermost IPv6 header.
2560 	 *
2561 	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2562 	 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2563 	 *
2564 	 * See struct rte_flow_action_set_ipv6.
2565 	 */
2566 	RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC,
2567 
2568 	/**
2569 	 * @warning This is a legacy action.
2570 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2571 	 *
2572 	 * Modify IPv6 destination address in the outermost IPv6 header.
2573 	 *
2574 	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2575 	 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2576 	 *
2577 	 * See struct rte_flow_action_set_ipv6.
2578 	 */
2579 	RTE_FLOW_ACTION_TYPE_SET_IPV6_DST,
2580 
2581 	/**
2582 	 * @warning This is a legacy action.
2583 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2584 	 *
2585 	 * Modify source port number in the outermost TCP/UDP header.
2586 	 *
2587 	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
2588 	 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
2589 	 * RTE_FLOW_ERROR_TYPE_ACTION error.
2590 	 *
2591 	 * See struct rte_flow_action_set_tp.
2592 	 */
2593 	RTE_FLOW_ACTION_TYPE_SET_TP_SRC,
2594 
2595 	/**
2596 	 * @warning This is a legacy action.
2597 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2598 	 *
2599 	 * Modify destination port number in the outermost TCP/UDP header.
2600 	 *
2601 	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
2602 	 * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
2603 	 * RTE_FLOW_ERROR_TYPE_ACTION error.
2604 	 *
2605 	 * See struct rte_flow_action_set_tp.
2606 	 */
2607 	RTE_FLOW_ACTION_TYPE_SET_TP_DST,
2608 
2609 	/**
2610 	 * Swap the source and destination MAC addresses in the outermost
2611 	 * Ethernet header.
2612 	 *
2613 	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2614 	 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2615 	 *
2616 	 * No associated configuration structure.
2617 	 */
2618 	RTE_FLOW_ACTION_TYPE_MAC_SWAP,
2619 
2620 	/**
2621 	 * @warning This is a legacy action.
2622 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2623 	 *
2624 	 * Decrease TTL value directly
2625 	 *
2626 	 * No associated configuration structure.
2627 	 */
2628 	RTE_FLOW_ACTION_TYPE_DEC_TTL,
2629 
2630 	/**
2631 	 * @warning This is a legacy action.
2632 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2633 	 *
2634 	 * Set TTL value
2635 	 *
2636 	 * See struct rte_flow_action_set_ttl
2637 	 */
2638 	RTE_FLOW_ACTION_TYPE_SET_TTL,
2639 
2640 	/**
2641 	 * @warning This is a legacy action.
2642 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2643 	 *
2644 	 * Set source MAC address from matched flow.
2645 	 *
2646 	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2647 	 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2648 	 *
2649 	 * See struct rte_flow_action_set_mac.
2650 	 */
2651 	RTE_FLOW_ACTION_TYPE_SET_MAC_SRC,
2652 
2653 	/**
2654 	 * @warning This is a legacy action.
2655 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2656 	 *
2657 	 * Set destination MAC address from matched flow.
2658 	 *
2659 	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2660 	 * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2661 	 *
2662 	 * See struct rte_flow_action_set_mac.
2663 	 */
2664 	RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
2665 
2666 	/**
2667 	 * @warning This is a legacy action.
2668 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2669 	 *
2670 	 * Increase sequence number in the outermost TCP header.
2671 	 *
2672 	 * Action configuration specifies the value to increase
2673 	 * TCP sequence number as a big-endian 32 bit integer.
2674 	 *
2675 	 * @p conf type:
2676 	 * @code rte_be32_t * @endcode
2677 	 *
2678 	 * Using this action on non-matching traffic will result in
2679 	 * undefined behavior.
2680 	 */
2681 	RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
2682 
2683 	/**
2684 	 * @warning This is a legacy action.
2685 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2686 	 *
2687 	 * Decrease sequence number in the outermost TCP header.
2688 	 *
2689 	 * Action configuration specifies the value to decrease
2690 	 * TCP sequence number as a big-endian 32 bit integer.
2691 	 *
2692 	 * @p conf type:
2693 	 * @code rte_be32_t * @endcode
2694 	 *
2695 	 * Using this action on non-matching traffic will result in
2696 	 * undefined behavior.
2697 	 */
2698 	RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
2699 
2700 	/**
2701 	 * @warning This is a legacy action.
2702 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2703 	 *
2704 	 * Increase acknowledgment number in the outermost TCP header.
2705 	 *
2706 	 * Action configuration specifies the value to increase
2707 	 * TCP acknowledgment number as a big-endian 32 bit integer.
2708 	 *
2709 	 * @p conf type:
2710 	 * @code rte_be32_t * @endcode
2711 
2712 	 * Using this action on non-matching traffic will result in
2713 	 * undefined behavior.
2714 	 */
2715 	RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
2716 
2717 	/**
2718 	 * @warning This is a legacy action.
2719 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2720 	 *
2721 	 * Decrease acknowledgment number in the outermost TCP header.
2722 	 *
2723 	 * Action configuration specifies the value to decrease
2724 	 * TCP acknowledgment number as a big-endian 32 bit integer.
2725 	 *
2726 	 * @p conf type:
2727 	 * @code rte_be32_t * @endcode
2728 	 *
2729 	 * Using this action on non-matching traffic will result in
2730 	 * undefined behavior.
2731 	 */
2732 	RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
2733 
2734 	/**
2735 	 * @warning This is a legacy action.
2736 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2737 	 *
2738 	 * Set Tag.
2739 	 *
2740 	 * Tag is for internal flow usage only and
2741 	 * is not delivered to the application.
2742 	 *
2743 	 * See struct rte_flow_action_set_tag.
2744 	 */
2745 	RTE_FLOW_ACTION_TYPE_SET_TAG,
2746 
2747 	/**
2748 	 * @warning This is a legacy action.
2749 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2750 	 *
2751 	 * Set metadata on ingress or egress path.
2752 	 *
2753 	 * See struct rte_flow_action_set_meta.
2754 	 */
2755 	RTE_FLOW_ACTION_TYPE_SET_META,
2756 
2757 	/**
2758 	 * @warning This is a legacy action.
2759 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2760 	 *
2761 	 * Modify IPv4 DSCP in the outermost IP header.
2762 	 *
2763 	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2764 	 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2765 	 *
2766 	 * See struct rte_flow_action_set_dscp.
2767 	 */
2768 	RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP,
2769 
2770 	/**
2771 	 * @warning This is a legacy action.
2772 	 * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
2773 	 *
2774 	 * Modify IPv6 DSCP in the outermost IP header.
2775 	 *
2776 	 * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2777 	 * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2778 	 *
2779 	 * See struct rte_flow_action_set_dscp.
2780 	 */
2781 	RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP,
2782 
2783 	/**
2784 	 * Report as aged flow if timeout passed without any matching on the
2785 	 * flow.
2786 	 *
2787 	 * See struct rte_flow_action_age.
2788 	 * See function rte_flow_get_aged_flows
2789 	 * see enum RTE_ETH_EVENT_FLOW_AGED
2790 	 * See struct rte_flow_query_age
2791 	 */
2792 	RTE_FLOW_ACTION_TYPE_AGE,
2793 
2794 	/**
2795 	 * The matching packets will be duplicated with specified ratio and
2796 	 * applied with own set of actions with a fate action.
2797 	 *
2798 	 * See struct rte_flow_action_sample.
2799 	 */
2800 	RTE_FLOW_ACTION_TYPE_SAMPLE,
2801 
2802 	/**
2803 	 * @deprecated
2804 	 * @see RTE_FLOW_ACTION_TYPE_INDIRECT
2805 	 *
2806 	 * Describe action shared across multiple flow rules.
2807 	 *
2808 	 * Allow multiple rules reference the same action by handle (see
2809 	 * struct rte_flow_shared_action).
2810 	 */
2811 	RTE_FLOW_ACTION_TYPE_SHARED,
2812 
2813 	/**
2814 	 * Modify a packet header field, tag, mark or metadata.
2815 	 *
2816 	 * Allow the modification of an arbitrary header field via
2817 	 * set, add and sub operations or copying its content into
2818 	 * tag, meta or mark for future processing.
2819 	 *
2820 	 * See struct rte_flow_action_modify_field.
2821 	 */
2822 	RTE_FLOW_ACTION_TYPE_MODIFY_FIELD,
2823 
2824 	/**
2825 	 * An action handle is referenced in a rule through an indirect action.
2826 	 *
2827 	 * The same action handle may be used in multiple rules for the same
2828 	 * or different ethdev ports.
2829 	 */
2830 	RTE_FLOW_ACTION_TYPE_INDIRECT,
2831 
2832 	/**
2833 	 * [META]
2834 	 *
2835 	 * Enable tracking a TCP connection state.
2836 	 *
2837 	 * @see struct rte_flow_action_conntrack.
2838 	 */
2839 	RTE_FLOW_ACTION_TYPE_CONNTRACK,
2840 
2841 	/**
2842 	 * Color the packet to reflect the meter color result.
2843 	 * Set the meter color in the mbuf to the selected color.
2844 	 *
2845 	 * See struct rte_flow_action_meter_color.
2846 	 */
2847 	RTE_FLOW_ACTION_TYPE_METER_COLOR,
2848 
2849 	/**
2850 	 * At embedded switch level, sends matching traffic to the given ethdev.
2851 	 *
2852 	 * @see struct rte_flow_action_ethdev
2853 	 */
2854 	RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR,
2855 
2856 	/**
2857 	 * At embedded switch level, send matching traffic to
2858 	 * the entity represented by the given ethdev.
2859 	 *
2860 	 * @see struct rte_flow_action_ethdev
2861 	 */
2862 	RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT,
2863 };
2864 
2865 /**
2866  * RTE_FLOW_ACTION_TYPE_MARK
2867  *
2868  * Attaches an integer value to packets and sets RTE_MBUF_F_RX_FDIR and
2869  * RTE_MBUF_F_RX_FDIR_ID mbuf flags.
2870  *
2871  * This value is arbitrary and application-defined. Maximum allowed value
2872  * depends on the underlying implementation. It is returned in the
2873  * hash.fdir.hi mbuf field.
2874  */
2875 struct rte_flow_action_mark {
2876 	uint32_t id; /**< Integer value to return with packets. */
2877 };
2878 
2879 /**
2880  * @warning
2881  * @b EXPERIMENTAL: this structure may change without prior notice
2882  *
2883  * RTE_FLOW_ACTION_TYPE_JUMP
2884  *
2885  * Redirects packets to a group on the current device.
2886  *
2887  * In a hierarchy of groups, which can be used to represent physical or logical
2888  * flow tables on the device, this action allows the action to be a redirect to
2889  * a group on that device.
2890  */
2891 struct rte_flow_action_jump {
2892 	uint32_t group;
2893 };
2894 
2895 /**
2896  * RTE_FLOW_ACTION_TYPE_QUEUE
2897  *
2898  * Assign packets to a given queue index.
2899  */
2900 struct rte_flow_action_queue {
2901 	uint16_t index; /**< Queue index to use. */
2902 };
2903 
2904 /**
2905  * @warning
2906  * @b EXPERIMENTAL: this structure may change without prior notice
2907  *
2908  * RTE_FLOW_ACTION_TYPE_AGE
2909  *
2910  * Report flow as aged-out if timeout passed without any matching
2911  * on the flow. RTE_ETH_EVENT_FLOW_AGED event is triggered when a
2912  * port detects new aged-out flows.
2913  *
2914  * The flow context and the flow handle will be reported by the
2915  * rte_flow_get_aged_flows API.
2916  */
2917 struct rte_flow_action_age {
2918 	uint32_t timeout:24; /**< Time in seconds. */
2919 	uint32_t reserved:8; /**< Reserved, must be zero. */
2920 	/** The user flow context, NULL means the rte_flow pointer. */
2921 	void *context;
2922 };
2923 
2924 /**
2925  * RTE_FLOW_ACTION_TYPE_AGE (query)
2926  *
2927  * Query structure to retrieve the aging status information of a
2928  * shared AGE action, or a flow rule using the AGE action.
2929  */
2930 struct rte_flow_query_age {
2931 	uint32_t reserved:6; /**< Reserved, must be zero. */
2932 	uint32_t aged:1; /**< 1 if aging timeout expired, 0 otherwise. */
2933 	/** sec_since_last_hit value is valid. */
2934 	uint32_t sec_since_last_hit_valid:1;
2935 	uint32_t sec_since_last_hit:24; /**< Seconds since last traffic hit. */
2936 };
2937 
2938 /**
2939  * @warning
2940  * @b EXPERIMENTAL: this structure may change without prior notice
2941  *
2942  * RTE_FLOW_ACTION_TYPE_COUNT
2943  *
2944  * Adds a counter action to a matched flow.
2945  *
2946  * If more than one count action is specified in a single flow rule, then each
2947  * action must specify a unique ID.
2948  *
2949  * Counters can be retrieved and reset through ``rte_flow_query()``, see
2950  * ``struct rte_flow_query_count``.
2951  *
2952  * For ports within the same switch domain then the counter ID namespace extends
2953  * to all ports within that switch domain.
2954  */
2955 struct rte_flow_action_count {
2956 	uint32_t id; /**< Counter ID. */
2957 };
2958 
2959 /**
2960  * RTE_FLOW_ACTION_TYPE_COUNT (query)
2961  *
2962  * Query structure to retrieve and reset flow rule counters.
2963  */
2964 struct rte_flow_query_count {
2965 	uint32_t reset:1; /**< Reset counters after query [in]. */
2966 	uint32_t hits_set:1; /**< hits field is set [out]. */
2967 	uint32_t bytes_set:1; /**< bytes field is set [out]. */
2968 	uint32_t reserved:29; /**< Reserved, must be zero [in, out]. */
2969 	uint64_t hits; /**< Number of hits for this rule [out]. */
2970 	uint64_t bytes; /**< Number of bytes through this rule [out]. */
2971 };
2972 
2973 /**
2974  * Hash function types.
2975  */
2976 enum rte_eth_hash_function {
2977 	RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
2978 	RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
2979 	RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
2980 	/**
2981 	 * Symmetric Toeplitz: src, dst will be replaced by
2982 	 * xor(src, dst). For the case with src/dst only,
2983 	 * src or dst address will xor with zero pair.
2984 	 */
2985 	RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
2986 	RTE_ETH_HASH_FUNCTION_MAX,
2987 };
2988 
2989 /**
2990  * RTE_FLOW_ACTION_TYPE_RSS
2991  *
2992  * Similar to QUEUE, except RSS is additionally performed on packets to
2993  * spread them among several queues according to the provided parameters.
2994  *
2995  * Unlike global RSS settings used by other DPDK APIs, unsetting the
2996  * @p types field does not disable RSS in a flow rule. Doing so instead
2997  * requests safe unspecified "best-effort" settings from the underlying PMD,
2998  * which depending on the flow rule, may result in anything ranging from
2999  * empty (single queue) to all-inclusive RSS.
3000  *
3001  * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps
3002  * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only,
3003  * both can be requested simultaneously.
3004  */
3005 struct rte_flow_action_rss {
3006 	enum rte_eth_hash_function func; /**< RSS hash function to apply. */
3007 	/**
3008 	 * Packet encapsulation level RSS hash @p types apply to.
3009 	 *
3010 	 * - @p 0 requests the default behavior. Depending on the packet
3011 	 *   type, it can mean outermost, innermost, anything in between or
3012 	 *   even no RSS.
3013 	 *
3014 	 *   It basically stands for the innermost encapsulation level RSS
3015 	 *   can be performed on according to PMD and device capabilities.
3016 	 *
3017 	 * - @p 1 requests RSS to be performed on the outermost packet
3018 	 *   encapsulation level.
3019 	 *
3020 	 * - @p 2 and subsequent values request RSS to be performed on the
3021 	 *   specified inner packet encapsulation level, from outermost to
3022 	 *   innermost (lower to higher values).
3023 	 *
3024 	 * Values other than @p 0 are not necessarily supported.
3025 	 *
3026 	 * Requesting a specific RSS level on unrecognized traffic results
3027 	 * in undefined behavior. For predictable results, it is recommended
3028 	 * to make the flow rule pattern match packet headers up to the
3029 	 * requested encapsulation level so that only matching traffic goes
3030 	 * through.
3031 	 */
3032 	uint32_t level;
3033 	uint64_t types; /**< Specific RSS hash types (see RTE_ETH_RSS_*). */
3034 	uint32_t key_len; /**< Hash key length in bytes. */
3035 	uint32_t queue_num; /**< Number of entries in @p queue. */
3036 	const uint8_t *key; /**< Hash key. */
3037 	const uint16_t *queue; /**< Queue indices to use. */
3038 };
3039 
3040 /**
3041  * @deprecated
3042  * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
3043  * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
3044  *
3045  * RTE_FLOW_ACTION_TYPE_VF
3046  *
3047  * Directs matching traffic to a given virtual function of the current
3048  * device.
3049  *
3050  * Packets matched by a VF pattern item can be redirected to their original
3051  * VF ID instead of the specified one. This parameter may not be available
3052  * and is not guaranteed to work properly if the VF part is matched by a
3053  * prior flow rule or if packets are not addressed to a VF in the first
3054  * place.
3055  */
3056 struct rte_flow_action_vf {
3057 	uint32_t original:1; /**< Use original VF ID if possible. */
3058 	uint32_t reserved:31; /**< Reserved, must be zero. */
3059 	uint32_t id; /**< VF ID. */
3060 };
3061 
3062 /**
3063  * @deprecated
3064  * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
3065  * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
3066  *
3067  * RTE_FLOW_ACTION_TYPE_PHY_PORT
3068  *
3069  * Directs packets to a given physical port index of the underlying
3070  * device.
3071  *
3072  * @see RTE_FLOW_ITEM_TYPE_PHY_PORT
3073  */
3074 struct rte_flow_action_phy_port {
3075 	uint32_t original:1; /**< Use original port index if possible. */
3076 	uint32_t reserved:31; /**< Reserved, must be zero. */
3077 	uint32_t index; /**< Physical port index. */
3078 };
3079 
3080 /**
3081  * @deprecated
3082  * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
3083  * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
3084  *
3085  * RTE_FLOW_ACTION_TYPE_PORT_ID
3086  *
3087  * Directs matching traffic to a given DPDK port ID.
3088  *
3089  * @see RTE_FLOW_ITEM_TYPE_PORT_ID
3090  */
3091 struct rte_flow_action_port_id {
3092 	uint32_t original:1; /**< Use original DPDK port ID if possible. */
3093 	uint32_t reserved:31; /**< Reserved, must be zero. */
3094 	uint32_t id; /**< DPDK port ID. */
3095 };
3096 
3097 /**
3098  * RTE_FLOW_ACTION_TYPE_METER
3099  *
3100  * Traffic metering and policing (MTR).
3101  *
3102  * Packets matched by items of this type can be either dropped or passed to the
3103  * next item with their color set by the MTR object.
3104  */
3105 struct rte_flow_action_meter {
3106 	uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */
3107 };
3108 
3109 /**
3110  * RTE_FLOW_ACTION_TYPE_SECURITY
3111  *
3112  * Perform the security action on flows matched by the pattern items
3113  * according to the configuration of the security session.
3114  *
3115  * This action modifies the payload of matched flows. For INLINE_CRYPTO, the
3116  * security protocol headers and IV are fully provided by the application as
3117  * specified in the flow pattern. The payload of matching packets is
3118  * encrypted on egress, and decrypted and authenticated on ingress.
3119  * For INLINE_PROTOCOL, the security protocol is fully offloaded to HW,
3120  * providing full encapsulation and decapsulation of packets in security
3121  * protocols. The flow pattern specifies both the outer security header fields
3122  * and the inner packet fields. The security session specified in the action
3123  * must match the pattern parameters.
3124  *
3125  * The security session specified in the action must be created on the same
3126  * port as the flow action that is being specified.
3127  *
3128  * The ingress/egress flow attribute should match that specified in the
3129  * security session if the security session supports the definition of the
3130  * direction.
3131  *
3132  * Multiple flows can be configured to use the same security session.
3133  *
3134  * The NULL value is allowed for security session. If security session is NULL,
3135  * then SPI field in ESP flow item and IP addresses in flow items 'IPv4' and
3136  * 'IPv6' will be allowed to be a range. The rule thus created can enable
3137  * security processing on multiple flows.
3138  */
3139 struct rte_flow_action_security {
3140 	void *security_session; /**< Pointer to security session structure. */
3141 };
3142 
3143 /**
3144  * @deprecated
3145  * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
3146  *
3147  * RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL
3148  *
3149  * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the OpenFlow
3150  * Switch Specification.
3151  */
3152 struct rte_flow_action_of_set_mpls_ttl {
3153 	uint8_t mpls_ttl; /**< MPLS TTL. */
3154 };
3155 
3156 /**
3157  * @deprecated
3158  * @see RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
3159  *
3160  * RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL
3161  *
3162  * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow Switch
3163  * Specification.
3164  */
3165 struct rte_flow_action_of_set_nw_ttl {
3166 	uint8_t nw_ttl; /**< IP TTL. */
3167 };
3168 
3169 /**
3170  * RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN
3171  *
3172  * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by the
3173  * OpenFlow Switch Specification.
3174  */
3175 struct rte_flow_action_of_push_vlan {
3176 	rte_be16_t ethertype; /**< EtherType. */
3177 };
3178 
3179 /**
3180  * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID
3181  *
3182  * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN ID") as defined by
3183  * the OpenFlow Switch Specification.
3184  */
3185 struct rte_flow_action_of_set_vlan_vid {
3186 	rte_be16_t vlan_vid; /**< VLAN ID. */
3187 };
3188 
3189 /**
3190  * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP
3191  *
3192  * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as defined by
3193  * the OpenFlow Switch Specification.
3194  */
3195 struct rte_flow_action_of_set_vlan_pcp {
3196 	uint8_t vlan_pcp; /**< VLAN priority. */
3197 };
3198 
3199 /**
3200  * RTE_FLOW_ACTION_TYPE_OF_POP_MPLS
3201  *
3202  * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined by the
3203  * OpenFlow Switch Specification.
3204  */
3205 struct rte_flow_action_of_pop_mpls {
3206 	rte_be16_t ethertype; /**< EtherType. */
3207 };
3208 
3209 /**
3210  * RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS
3211  *
3212  * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by the
3213  * OpenFlow Switch Specification.
3214  */
3215 struct rte_flow_action_of_push_mpls {
3216 	rte_be16_t ethertype; /**< EtherType. */
3217 };
3218 
3219 /**
3220  * @warning
3221  * @b EXPERIMENTAL: this structure may change without prior notice
3222  *
3223  * RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP
3224  *
3225  * VXLAN tunnel end-point encapsulation data definition
3226  *
3227  * The tunnel definition is provided through the flow item pattern, the
3228  * provided pattern must conform to RFC7348 for the tunnel specified. The flow
3229  * definition must be provided in order from the RTE_FLOW_ITEM_TYPE_ETH
3230  * definition up the end item which is specified by RTE_FLOW_ITEM_TYPE_END.
3231  *
3232  * The mask field allows user to specify which fields in the flow item
3233  * definitions can be ignored and which have valid data and can be used
3234  * verbatim.
3235  *
3236  * Note: the last field is not used in the definition of a tunnel and can be
3237  * ignored.
3238  *
3239  * Valid flow definition for RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP include:
3240  *
3241  * - ETH / IPV4 / UDP / VXLAN / END
3242  * - ETH / IPV6 / UDP / VXLAN / END
3243  * - ETH / VLAN / IPV4 / UDP / VXLAN / END
3244  *
3245  */
3246 struct rte_flow_action_vxlan_encap {
3247 	/**
3248 	 * Encapsulating vxlan tunnel definition
3249 	 * (terminated by the END pattern item).
3250 	 */
3251 	struct rte_flow_item *definition;
3252 };
3253 
3254 /**
3255  * @warning
3256  * @b EXPERIMENTAL: this structure may change without prior notice
3257  *
3258  * RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP
3259  *
3260  * NVGRE tunnel end-point encapsulation data definition
3261  *
3262  * The tunnel definition is provided through the flow item pattern  the
3263  * provided pattern must conform with RFC7637. The flow definition must be
3264  * provided in order from the RTE_FLOW_ITEM_TYPE_ETH definition up the end item
3265  * which is specified by RTE_FLOW_ITEM_TYPE_END.
3266  *
3267  * The mask field allows user to specify which fields in the flow item
3268  * definitions can be ignored and which have valid data and can be used
3269  * verbatim.
3270  *
3271  * Note: the last field is not used in the definition of a tunnel and can be
3272  * ignored.
3273  *
3274  * Valid flow definition for RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP include:
3275  *
3276  * - ETH / IPV4 / NVGRE / END
3277  * - ETH / VLAN / IPV6 / NVGRE / END
3278  *
3279  */
3280 struct rte_flow_action_nvgre_encap {
3281 	/**
3282 	 * Encapsulating vxlan tunnel definition
3283 	 * (terminated by the END pattern item).
3284 	 */
3285 	struct rte_flow_item *definition;
3286 };
3287 
3288 /**
3289  * @warning
3290  * @b EXPERIMENTAL: this structure may change without prior notice
3291  *
3292  * RTE_FLOW_ACTION_TYPE_RAW_ENCAP
3293  *
3294  * Raw tunnel end-point encapsulation data definition.
3295  *
3296  * The data holds the headers definitions to be applied on the packet.
3297  * The data must start with ETH header up to the tunnel item header itself.
3298  * When used right after RAW_DECAP (for decapsulating L3 tunnel type for
3299  * example MPLSoGRE) the data will just hold layer 2 header.
3300  *
3301  * The preserve parameter holds which bits in the packet the PMD is not allowed
3302  * to change, this parameter can also be NULL and then the PMD is allowed
3303  * to update any field.
3304  *
3305  * size holds the number of bytes in @p data and @p preserve.
3306  */
3307 struct rte_flow_action_raw_encap {
3308 	uint8_t *data; /**< Encapsulation data. */
3309 	uint8_t *preserve; /**< Bit-mask of @p data to preserve on output. */
3310 	size_t size; /**< Size of @p data and @p preserve. */
3311 };
3312 
3313 /**
3314  * @warning
3315  * @b EXPERIMENTAL: this structure may change without prior notice
3316  *
3317  * RTE_FLOW_ACTION_TYPE_RAW_DECAP
3318  *
3319  * Raw tunnel end-point decapsulation data definition.
3320  *
3321  * The data holds the headers definitions to be removed from the packet.
3322  * The data must start with ETH header up to the tunnel item header itself.
3323  * When used right before RAW_DECAP (for encapsulating L3 tunnel type for
3324  * example MPLSoGRE) the data will just hold layer 2 header.
3325  *
3326  * size holds the number of bytes in @p data.
3327  */
3328 struct rte_flow_action_raw_decap {
3329 	uint8_t *data; /**< Encapsulation data. */
3330 	size_t size; /**< Size of @p data and @p preserve. */
3331 };
3332 
3333 /**
3334  * @warning
3335  * @b EXPERIMENTAL: this structure may change without prior notice
3336  *
3337  * RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC
3338  * RTE_FLOW_ACTION_TYPE_SET_IPV4_DST
3339  *
3340  * Allows modification of IPv4 source (RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC)
3341  * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV4_DST) in the
3342  * specified outermost IPv4 header.
3343  */
3344 struct rte_flow_action_set_ipv4 {
3345 	rte_be32_t ipv4_addr;
3346 };
3347 
3348 /**
3349  * @warning
3350  * @b EXPERIMENTAL: this structure may change without prior notice
3351  *
3352  * RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC
3353  * RTE_FLOW_ACTION_TYPE_SET_IPV6_DST
3354  *
3355  * Allows modification of IPv6 source (RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC)
3356  * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV6_DST) in the
3357  * specified outermost IPv6 header.
3358  */
3359 struct rte_flow_action_set_ipv6 {
3360 	uint8_t ipv6_addr[16];
3361 };
3362 
3363 /**
3364  * @warning
3365  * @b EXPERIMENTAL: this structure may change without prior notice
3366  *
3367  * RTE_FLOW_ACTION_TYPE_SET_TP_SRC
3368  * RTE_FLOW_ACTION_TYPE_SET_TP_DST
3369  *
3370  * Allows modification of source (RTE_FLOW_ACTION_TYPE_SET_TP_SRC)
3371  * and destination (RTE_FLOW_ACTION_TYPE_SET_TP_DST) port numbers
3372  * in the specified outermost TCP/UDP header.
3373  */
3374 struct rte_flow_action_set_tp {
3375 	rte_be16_t port;
3376 };
3377 
3378 /**
3379  * RTE_FLOW_ACTION_TYPE_SET_TTL
3380  *
3381  * Set the TTL value directly for IPv4 or IPv6
3382  */
3383 struct rte_flow_action_set_ttl {
3384 	uint8_t ttl_value;
3385 };
3386 
3387 /**
3388  * RTE_FLOW_ACTION_TYPE_SET_MAC
3389  *
3390  * Set MAC address from the matched flow
3391  */
3392 struct rte_flow_action_set_mac {
3393 	uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
3394 };
3395 
3396 /**
3397  * @warning
3398  * @b EXPERIMENTAL: this structure may change without prior notice
3399  *
3400  * RTE_FLOW_ACTION_TYPE_SET_TAG
3401  *
3402  * Set a tag which is a transient data used during flow matching. This is not
3403  * delivered to application. Multiple tags are supported by specifying index.
3404  */
3405 struct rte_flow_action_set_tag {
3406 	uint32_t data;
3407 	uint32_t mask;
3408 	uint8_t index;
3409 };
3410 
3411 /**
3412  * @warning
3413  * @b EXPERIMENTAL: this structure may change without prior notice
3414  *
3415  * RTE_FLOW_ACTION_TYPE_SET_META
3416  *
3417  * Set metadata. Metadata set by mbuf metadata dynamic field with
3418  * RTE_MBUF_DYNFLAG_TX_METADATA flag on egress will be overridden by this
3419  * action. On ingress, the metadata will be carried by mbuf metadata dynamic
3420  * field with RTE_MBUF_DYNFLAG_RX_METADATA flag if set.  The dynamic mbuf field
3421  * must be registered in advance by rte_flow_dynf_metadata_register().
3422  *
3423  * Altering partial bits is supported with mask. For bits which have never
3424  * been set, unpredictable value will be seen depending on driver
3425  * implementation. For loopback/hairpin packet, metadata set on Rx/Tx may
3426  * or may not be propagated to the other path depending on HW capability.
3427  *
3428  * RTE_FLOW_ITEM_TYPE_META matches metadata.
3429  */
3430 struct rte_flow_action_set_meta {
3431 	uint32_t data;
3432 	uint32_t mask;
3433 };
3434 
3435 /**
3436  * RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP
3437  * RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP
3438  *
3439  * Set the DSCP value for IPv4/IPv6 header.
3440  * DSCP in low 6 bits, rest ignored.
3441  */
3442 struct rte_flow_action_set_dscp {
3443 	uint8_t dscp;
3444 };
3445 
3446 /**
3447  * @warning
3448  * @b EXPERIMENTAL: this structure may change without prior notice
3449  *
3450  * RTE_FLOW_ACTION_TYPE_INDIRECT
3451  *
3452  * Opaque type returned after successfully creating an indirect action object.
3453  * The definition of the object handle is different per driver or
3454  * per direct action type.
3455  *
3456  * This handle can be used to manage and query the related direct action:
3457  * - referenced in single flow rule or across multiple flow rules
3458  *   over multiple ports
3459  * - update action object configuration
3460  * - query action object data
3461  * - destroy action object
3462  */
3463 struct rte_flow_action_handle;
3464 
3465 /**
3466  * The state of a TCP connection.
3467  */
3468 enum rte_flow_conntrack_state {
3469 	/** SYN-ACK packet was seen. */
3470 	RTE_FLOW_CONNTRACK_STATE_SYN_RECV,
3471 	/** 3-way handshake was done. */
3472 	RTE_FLOW_CONNTRACK_STATE_ESTABLISHED,
3473 	/** First FIN packet was received to close the connection. */
3474 	RTE_FLOW_CONNTRACK_STATE_FIN_WAIT,
3475 	/** First FIN was ACKed. */
3476 	RTE_FLOW_CONNTRACK_STATE_CLOSE_WAIT,
3477 	/** Second FIN was received, waiting for the last ACK. */
3478 	RTE_FLOW_CONNTRACK_STATE_LAST_ACK,
3479 	/** Second FIN was ACKed, connection was closed. */
3480 	RTE_FLOW_CONNTRACK_STATE_TIME_WAIT,
3481 };
3482 
3483 /**
3484  * The last passed TCP packet flags of a connection.
3485  */
3486 enum rte_flow_conntrack_tcp_last_index {
3487 	RTE_FLOW_CONNTRACK_FLAG_NONE = 0, /**< No Flag. */
3488 	RTE_FLOW_CONNTRACK_FLAG_SYN = RTE_BIT32(0), /**< With SYN flag. */
3489 	RTE_FLOW_CONNTRACK_FLAG_SYNACK = RTE_BIT32(1), /**< With SYNACK flag. */
3490 	RTE_FLOW_CONNTRACK_FLAG_FIN = RTE_BIT32(2), /**< With FIN flag. */
3491 	RTE_FLOW_CONNTRACK_FLAG_ACK = RTE_BIT32(3), /**< With ACK flag. */
3492 	RTE_FLOW_CONNTRACK_FLAG_RST = RTE_BIT32(4), /**< With RST flag. */
3493 };
3494 
3495 /**
3496  * @warning
3497  * @b EXPERIMENTAL: this structure may change without prior notice
3498  *
3499  * Configuration parameters for each direction of a TCP connection.
3500  * All fields should be in host byte order.
3501  * If needed, driver should convert all fields to network byte order
3502  * if HW needs them in that way.
3503  */
3504 struct rte_flow_tcp_dir_param {
3505 	/** TCP window scaling factor, 0xF to disable. */
3506 	uint32_t scale:4;
3507 	/** The FIN was sent by this direction. */
3508 	uint32_t close_initiated:1;
3509 	/** An ACK packet has been received by this side. */
3510 	uint32_t last_ack_seen:1;
3511 	/**
3512 	 * If set, it indicates that there is unacknowledged data for the
3513 	 * packets sent from this direction.
3514 	 */
3515 	uint32_t data_unacked:1;
3516 	/**
3517 	 * Maximal value of sequence + payload length in sent
3518 	 * packets (next ACK from the opposite direction).
3519 	 */
3520 	uint32_t sent_end;
3521 	/**
3522 	 * Maximal value of (ACK + window size) in received packet + length
3523 	 * over sent packet (maximal sequence could be sent).
3524 	 */
3525 	uint32_t reply_end;
3526 	/** Maximal value of actual window size in sent packets. */
3527 	uint32_t max_win;
3528 	/** Maximal value of ACK in sent packets. */
3529 	uint32_t max_ack;
3530 };
3531 
3532 /**
3533  * @warning
3534  * @b EXPERIMENTAL: this structure may change without prior notice
3535  *
3536  * RTE_FLOW_ACTION_TYPE_CONNTRACK
3537  *
3538  * Configuration and initial state for the connection tracking module.
3539  * This structure could be used for both setting and query.
3540  * All fields should be in host byte order.
3541  */
3542 struct rte_flow_action_conntrack {
3543 	/** The peer port number, can be the same port. */
3544 	uint16_t peer_port;
3545 	/**
3546 	 * Direction of this connection when creating a flow rule, the
3547 	 * value only affects the creation of subsequent flow rules.
3548 	 */
3549 	uint32_t is_original_dir:1;
3550 	/**
3551 	 * Enable / disable the conntrack HW module. When disabled, the
3552 	 * result will always be RTE_FLOW_CONNTRACK_FLAG_DISABLED.
3553 	 * In this state the HW will act as passthrough.
3554 	 * It only affects this conntrack object in the HW without any effect
3555 	 * to the other objects.
3556 	 */
3557 	uint32_t enable:1;
3558 	/** At least one ack was seen after the connection was established. */
3559 	uint32_t live_connection:1;
3560 	/** Enable selective ACK on this connection. */
3561 	uint32_t selective_ack:1;
3562 	/** A challenge ack has passed. */
3563 	uint32_t challenge_ack_passed:1;
3564 	/**
3565 	 * 1: The last packet is seen from the original direction.
3566 	 * 0: The last packet is seen from the reply direction.
3567 	 */
3568 	uint32_t last_direction:1;
3569 	/** No TCP check will be done except the state change. */
3570 	uint32_t liberal_mode:1;
3571 	/** The current state of this connection. */
3572 	enum rte_flow_conntrack_state state;
3573 	/** Scaling factor for maximal allowed ACK window. */
3574 	uint8_t max_ack_window;
3575 	/** Maximal allowed number of retransmission times. */
3576 	uint8_t retransmission_limit;
3577 	/** TCP parameters of the original direction. */
3578 	struct rte_flow_tcp_dir_param original_dir;
3579 	/** TCP parameters of the reply direction. */
3580 	struct rte_flow_tcp_dir_param reply_dir;
3581 	/** The window value of the last packet passed this conntrack. */
3582 	uint16_t last_window;
3583 	enum rte_flow_conntrack_tcp_last_index last_index;
3584 	/** The sequence of the last packet passed this conntrack. */
3585 	uint32_t last_seq;
3586 	/** The acknowledgment of the last packet passed this conntrack. */
3587 	uint32_t last_ack;
3588 	/**
3589 	 * The total value ACK + payload length of the last packet
3590 	 * passed this conntrack.
3591 	 */
3592 	uint32_t last_end;
3593 };
3594 
3595 /**
3596  * RTE_FLOW_ACTION_TYPE_CONNTRACK
3597  *
3598  * Wrapper structure for the context update interface.
3599  * Ports cannot support updating, and the only valid solution is to
3600  * destroy the old context and create a new one instead.
3601  */
3602 struct rte_flow_modify_conntrack {
3603 	/** New connection tracking parameters to be updated. */
3604 	struct rte_flow_action_conntrack new_ct;
3605 	/** The direction field will be updated. */
3606 	uint32_t direction:1;
3607 	/** All the other fields except direction will be updated. */
3608 	uint32_t state:1;
3609 	/** Reserved bits for the future usage. */
3610 	uint32_t reserved:30;
3611 };
3612 
3613 /**
3614  * @warning
3615  * @b EXPERIMENTAL: this structure may change without prior notice
3616  *
3617  * RTE_FLOW_ACTION_TYPE_METER_COLOR
3618  *
3619  * The meter color should be set in the packet meta-data
3620  * (i.e. struct rte_mbuf::sched::color).
3621  */
3622 struct rte_flow_action_meter_color {
3623 	enum rte_color color; /**< Packet color. */
3624 };
3625 
3626 /**
3627  * @warning
3628  * @b EXPERIMENTAL: this structure may change without prior notice
3629  *
3630  * Provides an ethdev port ID for use with the following actions:
3631  * RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR,
3632  * RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT.
3633  */
3634 struct rte_flow_action_ethdev {
3635 	uint16_t port_id; /**< ethdev port ID */
3636 };
3637 
3638 /**
3639  * Field IDs for MODIFY_FIELD action.
3640  */
3641 enum rte_flow_field_id {
3642 	RTE_FLOW_FIELD_START = 0,	/**< Start of a packet. */
3643 	RTE_FLOW_FIELD_MAC_DST,		/**< Destination MAC Address. */
3644 	RTE_FLOW_FIELD_MAC_SRC,		/**< Source MAC Address. */
3645 	RTE_FLOW_FIELD_VLAN_TYPE,	/**< 802.1Q Tag Identifier. */
3646 	RTE_FLOW_FIELD_VLAN_ID,		/**< 802.1Q VLAN Identifier. */
3647 	RTE_FLOW_FIELD_MAC_TYPE,	/**< EtherType. */
3648 	RTE_FLOW_FIELD_IPV4_DSCP,	/**< IPv4 DSCP. */
3649 	RTE_FLOW_FIELD_IPV4_TTL,	/**< IPv4 Time To Live. */
3650 	RTE_FLOW_FIELD_IPV4_SRC,	/**< IPv4 Source Address. */
3651 	RTE_FLOW_FIELD_IPV4_DST,	/**< IPv4 Destination Address. */
3652 	RTE_FLOW_FIELD_IPV6_DSCP,	/**< IPv6 DSCP. */
3653 	RTE_FLOW_FIELD_IPV6_HOPLIMIT,	/**< IPv6 Hop Limit. */
3654 	RTE_FLOW_FIELD_IPV6_SRC,	/**< IPv6 Source Address. */
3655 	RTE_FLOW_FIELD_IPV6_DST,	/**< IPv6 Destination Address. */
3656 	RTE_FLOW_FIELD_TCP_PORT_SRC,	/**< TCP Source Port Number. */
3657 	RTE_FLOW_FIELD_TCP_PORT_DST,	/**< TCP Destination Port Number. */
3658 	RTE_FLOW_FIELD_TCP_SEQ_NUM,	/**< TCP Sequence Number. */
3659 	RTE_FLOW_FIELD_TCP_ACK_NUM,	/**< TCP Acknowledgment Number. */
3660 	RTE_FLOW_FIELD_TCP_FLAGS,	/**< TCP Flags. */
3661 	RTE_FLOW_FIELD_UDP_PORT_SRC,	/**< UDP Source Port Number. */
3662 	RTE_FLOW_FIELD_UDP_PORT_DST,	/**< UDP Destination Port Number. */
3663 	RTE_FLOW_FIELD_VXLAN_VNI,	/**< VXLAN Network Identifier. */
3664 	RTE_FLOW_FIELD_GENEVE_VNI,	/**< GENEVE Network Identifier. */
3665 	RTE_FLOW_FIELD_GTP_TEID,	/**< GTP Tunnel Endpoint Identifier. */
3666 	RTE_FLOW_FIELD_TAG,		/**< Tag value. */
3667 	RTE_FLOW_FIELD_MARK,		/**< Mark value. */
3668 	RTE_FLOW_FIELD_META,		/**< Metadata value. */
3669 	RTE_FLOW_FIELD_POINTER,		/**< Memory pointer. */
3670 	RTE_FLOW_FIELD_VALUE,		/**< Immediate value. */
3671 };
3672 
3673 /**
3674  * @warning
3675  * @b EXPERIMENTAL: this structure may change without prior notice
3676  *
3677  * Field description for MODIFY_FIELD action.
3678  */
3679 struct rte_flow_action_modify_data {
3680 	enum rte_flow_field_id field; /**< Field or memory type ID. */
3681 	RTE_STD_C11
3682 	union {
3683 		struct {
3684 			/** Encapsulation level or tag index. */
3685 			uint32_t level;
3686 			/** Number of bits to skip from a field. */
3687 			uint32_t offset;
3688 		};
3689 		/**
3690 		 * Immediate value for RTE_FLOW_FIELD_VALUE, presented in the
3691 		 * same byte order and length as in relevant rte_flow_item_xxx.
3692 		 * The immediate source bitfield offset is inherited from
3693 		 * the destination's one.
3694 		 */
3695 		uint8_t value[16];
3696 		/**
3697 		 * Memory address for RTE_FLOW_FIELD_POINTER, memory layout
3698 		 * should be the same as for relevant field in the
3699 		 * rte_flow_item_xxx structure.
3700 		 */
3701 		void *pvalue;
3702 	};
3703 };
3704 
3705 /**
3706  * Operation types for MODIFY_FIELD action.
3707  */
3708 enum rte_flow_modify_op {
3709 	RTE_FLOW_MODIFY_SET = 0, /**< Set a new value. */
3710 	RTE_FLOW_MODIFY_ADD,     /**< Add a value to a field.  */
3711 	RTE_FLOW_MODIFY_SUB,     /**< Subtract a value from a field. */
3712 };
3713 
3714 /**
3715  * @warning
3716  * @b EXPERIMENTAL: this structure may change without prior notice
3717  *
3718  * RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
3719  *
3720  * Modify a destination header field according to the specified
3721  * operation. Another field of the packet can be used as a source as well
3722  * as tag, mark, metadata, immediate value or a pointer to it.
3723  */
3724 struct rte_flow_action_modify_field {
3725 	enum rte_flow_modify_op operation; /**< Operation to perform. */
3726 	struct rte_flow_action_modify_data dst; /**< Destination field. */
3727 	struct rte_flow_action_modify_data src; /**< Source field. */
3728 	uint32_t width; /**< Number of bits to use from a source field. */
3729 };
3730 
3731 /* Mbuf dynamic field offset for metadata. */
3732 extern int32_t rte_flow_dynf_metadata_offs;
3733 
3734 /* Mbuf dynamic field flag mask for metadata. */
3735 extern uint64_t rte_flow_dynf_metadata_mask;
3736 
3737 /* Mbuf dynamic field pointer for metadata. */
3738 #define RTE_FLOW_DYNF_METADATA(m) \
3739 	RTE_MBUF_DYNFIELD((m), rte_flow_dynf_metadata_offs, uint32_t *)
3740 
3741 /* Mbuf dynamic flags for metadata. */
3742 #define RTE_MBUF_DYNFLAG_RX_METADATA (rte_flow_dynf_metadata_mask)
3743 #define PKT_RX_DYNF_METADATA RTE_DEPRECATED(PKT_RX_DYNF_METADATA) \
3744 		RTE_MBUF_DYNFLAG_RX_METADATA
3745 #define RTE_MBUF_DYNFLAG_TX_METADATA (rte_flow_dynf_metadata_mask)
3746 #define PKT_TX_DYNF_METADATA RTE_DEPRECATED(PKT_TX_DYNF_METADATA) \
3747 		RTE_MBUF_DYNFLAG_TX_METADATA
3748 
3749 __rte_experimental
3750 static inline uint32_t
3751 rte_flow_dynf_metadata_get(struct rte_mbuf *m)
3752 {
3753 	return *RTE_FLOW_DYNF_METADATA(m);
3754 }
3755 
3756 __rte_experimental
3757 static inline void
3758 rte_flow_dynf_metadata_set(struct rte_mbuf *m, uint32_t v)
3759 {
3760 	*RTE_FLOW_DYNF_METADATA(m) = v;
3761 }
3762 
3763 /**
3764  * Definition of a single action.
3765  *
3766  * A list of actions is terminated by a END action.
3767  *
3768  * For simple actions without a configuration object, conf remains NULL.
3769  */
3770 struct rte_flow_action {
3771 	enum rte_flow_action_type type; /**< Action type. */
3772 	const void *conf; /**< Pointer to action configuration object. */
3773 };
3774 
3775 /**
3776  * Opaque type returned after successfully creating a flow.
3777  *
3778  * This handle can be used to manage and query the related flow (e.g. to
3779  * destroy it or retrieve counters).
3780  */
3781 struct rte_flow;
3782 
3783 /**
3784  * @warning
3785  * @b EXPERIMENTAL: this structure may change without prior notice
3786  *
3787  * RTE_FLOW_ACTION_TYPE_SAMPLE
3788  *
3789  * Adds a sample action to a matched flow.
3790  *
3791  * The matching packets will be duplicated with specified ratio and applied
3792  * with own set of actions with a fate action, the sampled packet could be
3793  * redirected to queue or port. All the packets continue processing on the
3794  * default flow path.
3795  *
3796  * When the sample ratio is set to 1 then the packets will be 100% mirrored.
3797  * Additional action list be supported to add for sampled or mirrored packets.
3798  */
3799 struct rte_flow_action_sample {
3800 	uint32_t ratio; /**< packets sampled equals to '1/ratio'. */
3801 	/** sub-action list specific for the sampling hit cases. */
3802 	const struct rte_flow_action *actions;
3803 };
3804 
3805 /**
3806  * Verbose error types.
3807  *
3808  * Most of them provide the type of the object referenced by struct
3809  * rte_flow_error.cause.
3810  */
3811 enum rte_flow_error_type {
3812 	RTE_FLOW_ERROR_TYPE_NONE, /**< No error. */
3813 	RTE_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
3814 	RTE_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */
3815 	RTE_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */
3816 	RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */
3817 	RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */
3818 	RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */
3819 	RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */
3820 	RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */
3821 	RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */
3822 	RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */
3823 	RTE_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */
3824 	RTE_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */
3825 	RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */
3826 	RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */
3827 	RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */
3828 	RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */
3829 	RTE_FLOW_ERROR_TYPE_STATE, /**< Current device state. */
3830 };
3831 
3832 /**
3833  * Verbose error structure definition.
3834  *
3835  * This object is normally allocated by applications and set by PMDs, the
3836  * message points to a constant string which does not need to be freed by
3837  * the application, however its pointer can be considered valid only as long
3838  * as its associated DPDK port remains configured. Closing the underlying
3839  * device or unloading the PMD invalidates it.
3840  *
3841  * Both cause and message may be NULL regardless of the error type.
3842  */
3843 struct rte_flow_error {
3844 	enum rte_flow_error_type type; /**< Cause field and error types. */
3845 	const void *cause; /**< Object responsible for the error. */
3846 	const char *message; /**< Human-readable error message. */
3847 };
3848 
3849 /**
3850  * Complete flow rule description.
3851  *
3852  * This object type is used when converting a flow rule description.
3853  *
3854  * @see RTE_FLOW_CONV_OP_RULE
3855  * @see rte_flow_conv()
3856  */
3857 RTE_STD_C11
3858 struct rte_flow_conv_rule {
3859 	union {
3860 		const struct rte_flow_attr *attr_ro; /**< RO attributes. */
3861 		struct rte_flow_attr *attr; /**< Attributes. */
3862 	};
3863 	union {
3864 		const struct rte_flow_item *pattern_ro; /**< RO pattern. */
3865 		struct rte_flow_item *pattern; /**< Pattern items. */
3866 	};
3867 	union {
3868 		const struct rte_flow_action *actions_ro; /**< RO actions. */
3869 		struct rte_flow_action *actions; /**< List of actions. */
3870 	};
3871 };
3872 
3873 /**
3874  * Conversion operations for flow API objects.
3875  *
3876  * @see rte_flow_conv()
3877  */
3878 enum rte_flow_conv_op {
3879 	/**
3880 	 * No operation to perform.
3881 	 *
3882 	 * rte_flow_conv() simply returns 0.
3883 	 */
3884 	RTE_FLOW_CONV_OP_NONE,
3885 
3886 	/**
3887 	 * Convert attributes structure.
3888 	 *
3889 	 * This is a basic copy of an attributes structure.
3890 	 *
3891 	 * - @p src type:
3892 	 *   @code const struct rte_flow_attr * @endcode
3893 	 * - @p dst type:
3894 	 *   @code struct rte_flow_attr * @endcode
3895 	 */
3896 	RTE_FLOW_CONV_OP_ATTR,
3897 
3898 	/**
3899 	 * Convert a single item.
3900 	 *
3901 	 * Duplicates @p spec, @p last and @p mask but not outside objects.
3902 	 *
3903 	 * - @p src type:
3904 	 *   @code const struct rte_flow_item * @endcode
3905 	 * - @p dst type:
3906 	 *   @code struct rte_flow_item * @endcode
3907 	 */
3908 	RTE_FLOW_CONV_OP_ITEM,
3909 
3910 	/**
3911 	 * Convert a single action.
3912 	 *
3913 	 * Duplicates @p conf but not outside objects.
3914 	 *
3915 	 * - @p src type:
3916 	 *   @code const struct rte_flow_action * @endcode
3917 	 * - @p dst type:
3918 	 *   @code struct rte_flow_action * @endcode
3919 	 */
3920 	RTE_FLOW_CONV_OP_ACTION,
3921 
3922 	/**
3923 	 * Convert an entire pattern.
3924 	 *
3925 	 * Duplicates all pattern items at once with the same constraints as
3926 	 * RTE_FLOW_CONV_OP_ITEM.
3927 	 *
3928 	 * - @p src type:
3929 	 *   @code const struct rte_flow_item * @endcode
3930 	 * - @p dst type:
3931 	 *   @code struct rte_flow_item * @endcode
3932 	 */
3933 	RTE_FLOW_CONV_OP_PATTERN,
3934 
3935 	/**
3936 	 * Convert a list of actions.
3937 	 *
3938 	 * Duplicates the entire list of actions at once with the same
3939 	 * constraints as RTE_FLOW_CONV_OP_ACTION.
3940 	 *
3941 	 * - @p src type:
3942 	 *   @code const struct rte_flow_action * @endcode
3943 	 * - @p dst type:
3944 	 *   @code struct rte_flow_action * @endcode
3945 	 */
3946 	RTE_FLOW_CONV_OP_ACTIONS,
3947 
3948 	/**
3949 	 * Convert a complete flow rule description.
3950 	 *
3951 	 * Comprises attributes, pattern and actions together at once with
3952 	 * the usual constraints.
3953 	 *
3954 	 * - @p src type:
3955 	 *   @code const struct rte_flow_conv_rule * @endcode
3956 	 * - @p dst type:
3957 	 *   @code struct rte_flow_conv_rule * @endcode
3958 	 */
3959 	RTE_FLOW_CONV_OP_RULE,
3960 
3961 	/**
3962 	 * Convert item type to its name string.
3963 	 *
3964 	 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
3965 	 * returned value excludes the terminator which is always written
3966 	 * nonetheless.
3967 	 *
3968 	 * - @p src type:
3969 	 *   @code (const void *)enum rte_flow_item_type @endcode
3970 	 * - @p dst type:
3971 	 *   @code char * @endcode
3972 	 **/
3973 	RTE_FLOW_CONV_OP_ITEM_NAME,
3974 
3975 	/**
3976 	 * Convert action type to its name string.
3977 	 *
3978 	 * Writes a NUL-terminated string to @p dst. Like snprintf(), the
3979 	 * returned value excludes the terminator which is always written
3980 	 * nonetheless.
3981 	 *
3982 	 * - @p src type:
3983 	 *   @code (const void *)enum rte_flow_action_type @endcode
3984 	 * - @p dst type:
3985 	 *   @code char * @endcode
3986 	 **/
3987 	RTE_FLOW_CONV_OP_ACTION_NAME,
3988 
3989 	/**
3990 	 * Convert item type to pointer to item name.
3991 	 *
3992 	 * Retrieves item name pointer from its type. The string itself is
3993 	 * not copied; instead, a unique pointer to an internal static
3994 	 * constant storage is written to @p dst.
3995 	 *
3996 	 * - @p src type:
3997 	 *   @code (const void *)enum rte_flow_item_type @endcode
3998 	 * - @p dst type:
3999 	 *   @code const char ** @endcode
4000 	 */
4001 	RTE_FLOW_CONV_OP_ITEM_NAME_PTR,
4002 
4003 	/**
4004 	 * Convert action type to pointer to action name.
4005 	 *
4006 	 * Retrieves action name pointer from its type. The string itself is
4007 	 * not copied; instead, a unique pointer to an internal static
4008 	 * constant storage is written to @p dst.
4009 	 *
4010 	 * - @p src type:
4011 	 *   @code (const void *)enum rte_flow_action_type @endcode
4012 	 * - @p dst type:
4013 	 *   @code const char ** @endcode
4014 	 */
4015 	RTE_FLOW_CONV_OP_ACTION_NAME_PTR,
4016 };
4017 
4018 /**
4019  * @warning
4020  * @b EXPERIMENTAL: this API may change without prior notice.
4021  *
4022  * Dump hardware internal representation information of
4023  * rte flow to file.
4024  *
4025  * @param[in] port_id
4026  *    The port identifier of the Ethernet device.
4027  * @param[in] flow
4028  *   The pointer of flow rule to dump. Dump all rules if NULL.
4029  * @param[in] file
4030  *   A pointer to a file for output.
4031  * @param[out] error
4032  *   Perform verbose error reporting if not NULL. PMDs initialize this
4033  *   structure in case of error only.
4034  * @return
4035  *   0 on success, a negative value otherwise.
4036  */
4037 __rte_experimental
4038 int
4039 rte_flow_dev_dump(uint16_t port_id, struct rte_flow *flow,
4040 		FILE *file, struct rte_flow_error *error);
4041 
4042 /**
4043  * Check if mbuf dynamic field for metadata is registered.
4044  *
4045  * @return
4046  *   True if registered, false otherwise.
4047  */
4048 __rte_experimental
4049 static inline int
4050 rte_flow_dynf_metadata_avail(void)
4051 {
4052 	return !!rte_flow_dynf_metadata_mask;
4053 }
4054 
4055 /**
4056  * Register mbuf dynamic field and flag for metadata.
4057  *
4058  * This function must be called prior to use SET_META action in order to
4059  * register the dynamic mbuf field. Otherwise, the data cannot be delivered to
4060  * application.
4061  *
4062  * @return
4063  *   0 on success, a negative errno value otherwise and rte_errno is set.
4064  */
4065 __rte_experimental
4066 int
4067 rte_flow_dynf_metadata_register(void);
4068 
4069 /**
4070  * Check whether a flow rule can be created on a given port.
4071  *
4072  * The flow rule is validated for correctness and whether it could be accepted
4073  * by the device given sufficient resources. The rule is checked against the
4074  * current device mode and queue configuration. The flow rule may also
4075  * optionally be validated against existing flow rules and device resources.
4076  * This function has no effect on the target device.
4077  *
4078  * The returned value is guaranteed to remain valid only as long as no
4079  * successful calls to rte_flow_create() or rte_flow_destroy() are made in
4080  * the meantime and no device parameter affecting flow rules in any way are
4081  * modified, due to possible collisions or resource limitations (although in
4082  * such cases EINVAL should not be returned).
4083  *
4084  * @param port_id
4085  *   Port identifier of Ethernet device.
4086  * @param[in] attr
4087  *   Flow rule attributes.
4088  * @param[in] pattern
4089  *   Pattern specification (list terminated by the END pattern item).
4090  * @param[in] actions
4091  *   Associated actions (list terminated by the END action).
4092  * @param[out] error
4093  *   Perform verbose error reporting if not NULL. PMDs initialize this
4094  *   structure in case of error only.
4095  *
4096  * @return
4097  *   0 if flow rule is valid and can be created. A negative errno value
4098  *   otherwise (rte_errno is also set), the following errors are defined:
4099  *
4100  *   -ENOSYS: underlying device does not support this functionality.
4101  *
4102  *   -EIO: underlying device is removed.
4103  *
4104  *   -EINVAL: unknown or invalid rule specification.
4105  *
4106  *   -ENOTSUP: valid but unsupported rule specification (e.g. partial
4107  *   bit-masks are unsupported).
4108  *
4109  *   -EEXIST: collision with an existing rule. Only returned if device
4110  *   supports flow rule collision checking and there was a flow rule
4111  *   collision. Not receiving this return code is no guarantee that creating
4112  *   the rule will not fail due to a collision.
4113  *
4114  *   -ENOMEM: not enough memory to execute the function, or if the device
4115  *   supports resource validation, resource limitation on the device.
4116  *
4117  *   -EBUSY: action cannot be performed due to busy device resources, may
4118  *   succeed if the affected queues or even the entire port are in a stopped
4119  *   state (see rte_eth_dev_rx_queue_stop() and rte_eth_dev_stop()).
4120  */
4121 int
4122 rte_flow_validate(uint16_t port_id,
4123 		  const struct rte_flow_attr *attr,
4124 		  const struct rte_flow_item pattern[],
4125 		  const struct rte_flow_action actions[],
4126 		  struct rte_flow_error *error);
4127 
4128 /**
4129  * Create a flow rule on a given port.
4130  *
4131  * @param port_id
4132  *   Port identifier of Ethernet device.
4133  * @param[in] attr
4134  *   Flow rule attributes.
4135  * @param[in] pattern
4136  *   Pattern specification (list terminated by the END pattern item).
4137  * @param[in] actions
4138  *   Associated actions (list terminated by the END action).
4139  * @param[out] error
4140  *   Perform verbose error reporting if not NULL. PMDs initialize this
4141  *   structure in case of error only.
4142  *
4143  * @return
4144  *   A valid handle in case of success, NULL otherwise and rte_errno is set
4145  *   to the positive version of one of the error codes defined for
4146  *   rte_flow_validate().
4147  */
4148 struct rte_flow *
4149 rte_flow_create(uint16_t port_id,
4150 		const struct rte_flow_attr *attr,
4151 		const struct rte_flow_item pattern[],
4152 		const struct rte_flow_action actions[],
4153 		struct rte_flow_error *error);
4154 
4155 /**
4156  * Destroy a flow rule on a given port.
4157  *
4158  * Failure to destroy a flow rule handle may occur when other flow rules
4159  * depend on it, and destroying it would result in an inconsistent state.
4160  *
4161  * This function is only guaranteed to succeed if handles are destroyed in
4162  * reverse order of their creation.
4163  *
4164  * @param port_id
4165  *   Port identifier of Ethernet device.
4166  * @param flow
4167  *   Flow rule handle to destroy.
4168  * @param[out] error
4169  *   Perform verbose error reporting if not NULL. PMDs initialize this
4170  *   structure in case of error only.
4171  *
4172  * @return
4173  *   0 on success, a negative errno value otherwise and rte_errno is set.
4174  */
4175 int
4176 rte_flow_destroy(uint16_t port_id,
4177 		 struct rte_flow *flow,
4178 		 struct rte_flow_error *error);
4179 
4180 /**
4181  * Destroy all flow rules associated with a port.
4182  *
4183  * In the unlikely event of failure, handles are still considered destroyed
4184  * and no longer valid but the port must be assumed to be in an inconsistent
4185  * state.
4186  *
4187  * @param port_id
4188  *   Port identifier of Ethernet device.
4189  * @param[out] error
4190  *   Perform verbose error reporting if not NULL. PMDs initialize this
4191  *   structure in case of error only.
4192  *
4193  * @return
4194  *   0 on success, a negative errno value otherwise and rte_errno is set.
4195  */
4196 int
4197 rte_flow_flush(uint16_t port_id,
4198 	       struct rte_flow_error *error);
4199 
4200 /**
4201  * Query an existing flow rule.
4202  *
4203  * This function allows retrieving flow-specific data such as counters.
4204  * Data is gathered by special actions which must be present in the flow
4205  * rule definition.
4206  *
4207  * \see RTE_FLOW_ACTION_TYPE_COUNT
4208  *
4209  * @param port_id
4210  *   Port identifier of Ethernet device.
4211  * @param flow
4212  *   Flow rule handle to query.
4213  * @param action
4214  *   Action definition as defined in original flow rule.
4215  * @param[in, out] data
4216  *   Pointer to storage for the associated query data type.
4217  * @param[out] error
4218  *   Perform verbose error reporting if not NULL. PMDs initialize this
4219  *   structure in case of error only.
4220  *
4221  * @return
4222  *   0 on success, a negative errno value otherwise and rte_errno is set.
4223  */
4224 int
4225 rte_flow_query(uint16_t port_id,
4226 	       struct rte_flow *flow,
4227 	       const struct rte_flow_action *action,
4228 	       void *data,
4229 	       struct rte_flow_error *error);
4230 
4231 /**
4232  * Restrict ingress traffic to the defined flow rules.
4233  *
4234  * Isolated mode guarantees that all ingress traffic comes from defined flow
4235  * rules only (current and future).
4236  *
4237  * Besides making ingress more deterministic, it allows PMDs to safely reuse
4238  * resources otherwise assigned to handle the remaining traffic, such as
4239  * global RSS configuration settings, VLAN filters, MAC address entries,
4240  * legacy filter API rules and so on in order to expand the set of possible
4241  * flow rule types.
4242  *
4243  * Calling this function as soon as possible after device initialization,
4244  * ideally before the first call to rte_eth_dev_configure(), is recommended
4245  * to avoid possible failures due to conflicting settings.
4246  *
4247  * Once effective, leaving isolated mode may not be possible depending on
4248  * PMD implementation.
4249  *
4250  * Additionally, the following functionality has no effect on the underlying
4251  * port and may return errors such as ENOTSUP ("not supported"):
4252  *
4253  * - Toggling promiscuous mode.
4254  * - Toggling allmulticast mode.
4255  * - Configuring MAC addresses.
4256  * - Configuring multicast addresses.
4257  * - Configuring VLAN filters.
4258  * - Configuring Rx filters through the legacy API (e.g. FDIR).
4259  * - Configuring global RSS settings.
4260  *
4261  * @param port_id
4262  *   Port identifier of Ethernet device.
4263  * @param set
4264  *   Nonzero to enter isolated mode, attempt to leave it otherwise.
4265  * @param[out] error
4266  *   Perform verbose error reporting if not NULL. PMDs initialize this
4267  *   structure in case of error only.
4268  *
4269  * @return
4270  *   0 on success, a negative errno value otherwise and rte_errno is set.
4271  */
4272 int
4273 rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error);
4274 
4275 /**
4276  * Initialize flow error structure.
4277  *
4278  * @param[out] error
4279  *   Pointer to flow error structure (may be NULL).
4280  * @param code
4281  *   Related error code (rte_errno).
4282  * @param type
4283  *   Cause field and error types.
4284  * @param cause
4285  *   Object responsible for the error.
4286  * @param message
4287  *   Human-readable error message.
4288  *
4289  * @return
4290  *   Negative error code (errno value) and rte_errno is set.
4291  */
4292 int
4293 rte_flow_error_set(struct rte_flow_error *error,
4294 		   int code,
4295 		   enum rte_flow_error_type type,
4296 		   const void *cause,
4297 		   const char *message);
4298 
4299 /**
4300  * @deprecated
4301  * @see rte_flow_copy()
4302  */
4303 struct rte_flow_desc {
4304 	size_t size; /**< Allocated space including data[]. */
4305 	struct rte_flow_attr attr; /**< Attributes. */
4306 	struct rte_flow_item *items; /**< Items. */
4307 	struct rte_flow_action *actions; /**< Actions. */
4308 	uint8_t data[]; /**< Storage for items/actions. */
4309 };
4310 
4311 /**
4312  * @deprecated
4313  * Copy an rte_flow rule description.
4314  *
4315  * This interface is kept for compatibility with older applications but is
4316  * implemented as a wrapper to rte_flow_conv(). It is deprecated due to its
4317  * lack of flexibility and reliance on a type unusable with C++ programs
4318  * (struct rte_flow_desc).
4319  *
4320  * @param[in] fd
4321  *   Flow rule description.
4322  * @param[in] len
4323  *   Total size of allocated data for the flow description.
4324  * @param[in] attr
4325  *   Flow rule attributes.
4326  * @param[in] items
4327  *   Pattern specification (list terminated by the END pattern item).
4328  * @param[in] actions
4329  *   Associated actions (list terminated by the END action).
4330  *
4331  * @return
4332  *   If len is greater or equal to the size of the flow, the total size of the
4333  *   flow description and its data.
4334  *   If len is lower than the size of the flow, the number of bytes that would
4335  *   have been written to desc had it been sufficient. Nothing is written.
4336  */
4337 __rte_deprecated
4338 size_t
4339 rte_flow_copy(struct rte_flow_desc *fd, size_t len,
4340 	      const struct rte_flow_attr *attr,
4341 	      const struct rte_flow_item *items,
4342 	      const struct rte_flow_action *actions);
4343 
4344 /**
4345  * Flow object conversion helper.
4346  *
4347  * This function performs conversion of various flow API objects to a
4348  * pre-allocated destination buffer. See enum rte_flow_conv_op for possible
4349  * operations and details about each of them.
4350  *
4351  * Since destination buffer must be large enough, it works in a manner
4352  * reminiscent of snprintf():
4353  *
4354  * - If @p size is 0, @p dst may be a NULL pointer, otherwise @p dst must be
4355  *   non-NULL.
4356  * - If positive, the returned value represents the number of bytes needed
4357  *   to store the conversion of @p src to @p dst according to @p op
4358  *   regardless of the @p size parameter.
4359  * - Since no more than @p size bytes can be written to @p dst, output is
4360  *   truncated and may be inconsistent when the returned value is larger
4361  *   than that.
4362  * - In case of conversion error, a negative error code is returned and
4363  *   @p dst contents are unspecified.
4364  *
4365  * @param op
4366  *   Operation to perform, related to the object type of @p dst.
4367  * @param[out] dst
4368  *   Destination buffer address. Must be suitably aligned by the caller.
4369  * @param size
4370  *   Destination buffer size in bytes.
4371  * @param[in] src
4372  *   Source object to copy. Depending on @p op, its type may differ from
4373  *   that of @p dst.
4374  * @param[out] error
4375  *   Perform verbose error reporting if not NULL. Initialized in case of
4376  *   error only.
4377  *
4378  * @return
4379  *   The number of bytes required to convert @p src to @p dst on success, a
4380  *   negative errno value otherwise and rte_errno is set.
4381  *
4382  * @see rte_flow_conv_op
4383  */
4384 __rte_experimental
4385 int
4386 rte_flow_conv(enum rte_flow_conv_op op,
4387 	      void *dst,
4388 	      size_t size,
4389 	      const void *src,
4390 	      struct rte_flow_error *error);
4391 
4392 /**
4393  * Get aged-out flows of a given port.
4394  *
4395  * RTE_ETH_EVENT_FLOW_AGED event will be triggered when at least one new aged
4396  * out flow was detected after the last call to rte_flow_get_aged_flows.
4397  * This function can be called to get the aged flows asynchronously from the
4398  * event callback or synchronously regardless the event.
4399  * This is not safe to call rte_flow_get_aged_flows function with other flow
4400  * functions from multiple threads simultaneously.
4401  *
4402  * @param port_id
4403  *   Port identifier of Ethernet device.
4404  * @param[in, out] contexts
4405  *   The address of an array of pointers to the aged-out flows contexts.
4406  * @param[in] nb_contexts
4407  *   The length of context array pointers.
4408  * @param[out] error
4409  *   Perform verbose error reporting if not NULL. Initialized in case of
4410  *   error only.
4411  *
4412  * @return
4413  *   if nb_contexts is 0, return the amount of all aged contexts.
4414  *   if nb_contexts is not 0 , return the amount of aged flows reported
4415  *   in the context array, otherwise negative errno value.
4416  *
4417  * @see rte_flow_action_age
4418  * @see RTE_ETH_EVENT_FLOW_AGED
4419  */
4420 __rte_experimental
4421 int
4422 rte_flow_get_aged_flows(uint16_t port_id, void **contexts,
4423 			uint32_t nb_contexts, struct rte_flow_error *error);
4424 
4425 /**
4426  * Specify indirect action object configuration
4427  */
4428 struct rte_flow_indir_action_conf {
4429 	/**
4430 	 * Flow direction for the indirect action configuration.
4431 	 *
4432 	 * Action should be valid at least for one flow direction,
4433 	 * otherwise it is invalid for both ingress and egress rules.
4434 	 */
4435 	/** Action valid for rules applied to ingress traffic. */
4436 	uint32_t ingress:1;
4437 	/** Action valid for rules applied to egress traffic. */
4438 	uint32_t egress:1;
4439 	/**
4440 	 * When set to 1, indicates that the action is valid for
4441 	 * transfer traffic; otherwise, for non-transfer traffic.
4442 	 */
4443 	uint32_t transfer:1;
4444 };
4445 
4446 /**
4447  * @warning
4448  * @b EXPERIMENTAL: this API may change without prior notice.
4449  *
4450  * Create an indirect action object that can be used in flow rules
4451  * via its handle.
4452  * The created object handle has single state and configuration
4453  * across all the flow rules using it.
4454  *
4455  * @param[in] port_id
4456  *    The port identifier of the Ethernet device.
4457  * @param[in] conf
4458  *   Action configuration for the indirect action object creation.
4459  * @param[in] action
4460  *   Specific configuration of the indirect action object.
4461  * @param[out] error
4462  *   Perform verbose error reporting if not NULL. PMDs initialize this
4463  *   structure in case of error only.
4464  * @return
4465  *   A valid handle in case of success, NULL otherwise and rte_errno is set
4466  *   to one of the error codes defined:
4467  *   - (ENODEV) if *port_id* invalid.
4468  *   - (ENOSYS) if underlying device does not support this functionality.
4469  *   - (EIO) if underlying device is removed.
4470  *   - (EINVAL) if *action* invalid.
4471  *   - (ENOTSUP) if *action* valid but unsupported.
4472  */
4473 __rte_experimental
4474 struct rte_flow_action_handle *
4475 rte_flow_action_handle_create(uint16_t port_id,
4476 			      const struct rte_flow_indir_action_conf *conf,
4477 			      const struct rte_flow_action *action,
4478 			      struct rte_flow_error *error);
4479 
4480 /**
4481  * @warning
4482  * @b EXPERIMENTAL: this API may change without prior notice.
4483  *
4484  * Destroy indirect action by handle.
4485  *
4486  * @param[in] port_id
4487  *    The port identifier of the Ethernet device.
4488  * @param[in] handle
4489  *   Handle for the indirect action object to be destroyed.
4490  * @param[out] error
4491  *   Perform verbose error reporting if not NULL. PMDs initialize this
4492  *   structure in case of error only.
4493  * @return
4494  *   - (0) if success.
4495  *   - (-ENODEV) if *port_id* invalid.
4496  *   - (-ENOSYS) if underlying device does not support this functionality.
4497  *   - (-EIO) if underlying device is removed.
4498  *   - (-ENOENT) if action pointed by *action* handle was not found.
4499  *   - (-EBUSY) if action pointed by *action* handle still used by some rules
4500  *   rte_errno is also set.
4501  */
4502 __rte_experimental
4503 int
4504 rte_flow_action_handle_destroy(uint16_t port_id,
4505 			       struct rte_flow_action_handle *handle,
4506 			       struct rte_flow_error *error);
4507 
4508 /**
4509  * @warning
4510  * @b EXPERIMENTAL: this API may change without prior notice.
4511  *
4512  * Update in-place the action configuration and / or state pointed
4513  * by action *handle* with the configuration provided as *update* argument.
4514  * The update of the action configuration effects all flow rules reusing
4515  * the action via *handle*.
4516  * The update general pointer provides the ability of partial updating.
4517  *
4518  * @param[in] port_id
4519  *    The port identifier of the Ethernet device.
4520  * @param[in] handle
4521  *   Handle for the indirect action object to be updated.
4522  * @param[in] update
4523  *   Update profile specification used to modify the action pointed by handle.
4524  *   *update* could be with the same type of the immediate action corresponding
4525  *   to the *handle* argument when creating, or a wrapper structure includes
4526  *   action configuration to be updated and bit fields to indicate the member
4527  *   of fields inside the action to update.
4528  * @param[out] error
4529  *   Perform verbose error reporting if not NULL. PMDs initialize this
4530  *   structure in case of error only.
4531  * @return
4532  *   - (0) if success.
4533  *   - (-ENODEV) if *port_id* invalid.
4534  *   - (-ENOSYS) if underlying device does not support this functionality.
4535  *   - (-EIO) if underlying device is removed.
4536  *   - (-EINVAL) if *update* invalid.
4537  *   - (-ENOTSUP) if *update* valid but unsupported.
4538  *   - (-ENOENT) if indirect action object pointed by *handle* was not found.
4539  *   rte_errno is also set.
4540  */
4541 __rte_experimental
4542 int
4543 rte_flow_action_handle_update(uint16_t port_id,
4544 			      struct rte_flow_action_handle *handle,
4545 			      const void *update,
4546 			      struct rte_flow_error *error);
4547 
4548 /**
4549  * @warning
4550  * @b EXPERIMENTAL: this API may change without prior notice.
4551  *
4552  * Query the direct action by corresponding indirect action object handle.
4553  *
4554  * Retrieve action-specific data such as counters.
4555  * Data is gathered by special action which may be present/referenced in
4556  * more than one flow rule definition.
4557  *
4558  * @see RTE_FLOW_ACTION_TYPE_COUNT
4559  *
4560  * @param port_id
4561  *   Port identifier of Ethernet device.
4562  * @param[in] handle
4563  *   Handle for the action object to query.
4564  * @param[in, out] data
4565  *   Pointer to storage for the associated query data type.
4566  * @param[out] error
4567  *   Perform verbose error reporting if not NULL. PMDs initialize this
4568  *   structure in case of error only.
4569  *
4570  * @return
4571  *   0 on success, a negative errno value otherwise and rte_errno is set.
4572  */
4573 __rte_experimental
4574 int
4575 rte_flow_action_handle_query(uint16_t port_id,
4576 			     const struct rte_flow_action_handle *handle,
4577 			     void *data, struct rte_flow_error *error);
4578 
4579 /* Tunnel has a type and the key information. */
4580 struct rte_flow_tunnel {
4581 	/**
4582 	 * Tunnel type, for example RTE_FLOW_ITEM_TYPE_VXLAN,
4583 	 * RTE_FLOW_ITEM_TYPE_NVGRE etc.
4584 	 */
4585 	enum rte_flow_item_type	type;
4586 	uint64_t tun_id; /**< Tunnel identification. */
4587 
4588 	RTE_STD_C11
4589 	union {
4590 		struct {
4591 			rte_be32_t src_addr; /**< IPv4 source address. */
4592 			rte_be32_t dst_addr; /**< IPv4 destination address. */
4593 		} ipv4;
4594 		struct {
4595 			uint8_t src_addr[16]; /**< IPv6 source address. */
4596 			uint8_t dst_addr[16]; /**< IPv6 destination address. */
4597 		} ipv6;
4598 	};
4599 	rte_be16_t tp_src; /**< Tunnel port source. */
4600 	rte_be16_t tp_dst; /**< Tunnel port destination. */
4601 	uint16_t   tun_flags; /**< Tunnel flags. */
4602 
4603 	bool       is_ipv6; /**< True for valid IPv6 fields. Otherwise IPv4. */
4604 
4605 	/**
4606 	 * the following members are required to restore packet
4607 	 * after miss
4608 	 */
4609 	uint8_t    tos; /**< TOS for IPv4, TC for IPv6. */
4610 	uint8_t    ttl; /**< TTL for IPv4, HL for IPv6. */
4611 	uint32_t label; /**< Flow Label for IPv6. */
4612 };
4613 
4614 /**
4615  * Indicate that the packet has a tunnel.
4616  */
4617 #define RTE_FLOW_RESTORE_INFO_TUNNEL RTE_BIT64(0)
4618 
4619 /**
4620  * Indicate that the packet has a non decapsulated tunnel header.
4621  */
4622 #define RTE_FLOW_RESTORE_INFO_ENCAPSULATED RTE_BIT64(1)
4623 
4624 /**
4625  * Indicate that the packet has a group_id.
4626  */
4627 #define RTE_FLOW_RESTORE_INFO_GROUP_ID RTE_BIT64(2)
4628 
4629 /**
4630  * Restore information structure to communicate the current packet processing
4631  * state when some of the processing pipeline is done in hardware and should
4632  * continue in software.
4633  */
4634 struct rte_flow_restore_info {
4635 	/**
4636 	 * Bitwise flags (RTE_FLOW_RESTORE_INFO_*) to indicate validation of
4637 	 * other fields in struct rte_flow_restore_info.
4638 	 */
4639 	uint64_t flags;
4640 	uint32_t group_id; /**< Group ID where packed missed */
4641 	struct rte_flow_tunnel tunnel; /**< Tunnel information. */
4642 };
4643 
4644 /**
4645  * Allocate an array of actions to be used in rte_flow_create, to implement
4646  * tunnel-decap-set for the given tunnel.
4647  * Sample usage:
4648  *   actions vxlan_decap / tunnel-decap-set(tunnel properties) /
4649  *            jump group 0 / end
4650  *
4651  * @param port_id
4652  *   Port identifier of Ethernet device.
4653  * @param[in] tunnel
4654  *   Tunnel properties.
4655  * @param[out] actions
4656  *   Array of actions to be allocated by the PMD. This array should be
4657  *   concatenated with the actions array provided to rte_flow_create.
4658  * @param[out] num_of_actions
4659  *   Number of actions allocated.
4660  * @param[out] error
4661  *   Perform verbose error reporting if not NULL. PMDs initialize this
4662  *   structure in case of error only.
4663  *
4664  * @return
4665  *   0 on success, a negative errno value otherwise and rte_errno is set.
4666  */
4667 __rte_experimental
4668 int
4669 rte_flow_tunnel_decap_set(uint16_t port_id,
4670 			  struct rte_flow_tunnel *tunnel,
4671 			  struct rte_flow_action **actions,
4672 			  uint32_t *num_of_actions,
4673 			  struct rte_flow_error *error);
4674 
4675 /**
4676  * Allocate an array of items to be used in rte_flow_create, to implement
4677  * tunnel-match for the given tunnel.
4678  * Sample usage:
4679  *   pattern tunnel-match(tunnel properties) / outer-header-matches /
4680  *           inner-header-matches / end
4681  *
4682  * @param port_id
4683  *   Port identifier of Ethernet device.
4684  * @param[in] tunnel
4685  *   Tunnel properties.
4686  * @param[out] items
4687  *   Array of items to be allocated by the PMD. This array should be
4688  *   concatenated with the items array provided to rte_flow_create.
4689  * @param[out] num_of_items
4690  *   Number of items allocated.
4691  * @param[out] error
4692  *   Perform verbose error reporting if not NULL. PMDs initialize this
4693  *   structure in case of error only.
4694  *
4695  * @return
4696  *   0 on success, a negative errno value otherwise and rte_errno is set.
4697  */
4698 __rte_experimental
4699 int
4700 rte_flow_tunnel_match(uint16_t port_id,
4701 		      struct rte_flow_tunnel *tunnel,
4702 		      struct rte_flow_item **items,
4703 		      uint32_t *num_of_items,
4704 		      struct rte_flow_error *error);
4705 
4706 /**
4707  * Populate the current packet processing state, if exists, for the given mbuf.
4708  *
4709  * One should negotiate tunnel metadata delivery from the NIC to the HW.
4710  * @see rte_eth_rx_metadata_negotiate()
4711  * @see RTE_ETH_RX_METADATA_TUNNEL_ID
4712  *
4713  * @param port_id
4714  *   Port identifier of Ethernet device.
4715  * @param[in] m
4716  *   Mbuf struct.
4717  * @param[out] info
4718  *   Restore information. Upon success contains the HW state.
4719  * @param[out] error
4720  *   Perform verbose error reporting if not NULL. PMDs initialize this
4721  *   structure in case of error only.
4722  *
4723  * @return
4724  *   0 on success, a negative errno value otherwise and rte_errno is set.
4725  */
4726 __rte_experimental
4727 int
4728 rte_flow_get_restore_info(uint16_t port_id,
4729 			  struct rte_mbuf *m,
4730 			  struct rte_flow_restore_info *info,
4731 			  struct rte_flow_error *error);
4732 
4733 /**
4734  * Release the action array as allocated by rte_flow_tunnel_decap_set.
4735  *
4736  * @param port_id
4737  *   Port identifier of Ethernet device.
4738  * @param[in] actions
4739  *   Array of actions to be released.
4740  * @param[in] num_of_actions
4741  *   Number of elements in actions array.
4742  * @param[out] error
4743  *   Perform verbose error reporting if not NULL. PMDs initialize this
4744  *   structure in case of error only.
4745  *
4746  * @return
4747  *   0 on success, a negative errno value otherwise and rte_errno is set.
4748  */
4749 __rte_experimental
4750 int
4751 rte_flow_tunnel_action_decap_release(uint16_t port_id,
4752 				     struct rte_flow_action *actions,
4753 				     uint32_t num_of_actions,
4754 				     struct rte_flow_error *error);
4755 
4756 /**
4757  * Release the item array as allocated by rte_flow_tunnel_match.
4758  *
4759  * @param port_id
4760  *   Port identifier of Ethernet device.
4761  * @param[in] items
4762  *   Array of items to be released.
4763  * @param[in] num_of_items
4764  *   Number of elements in item array.
4765  * @param[out] error
4766  *   Perform verbose error reporting if not NULL. PMDs initialize this
4767  *   structure in case of error only.
4768  *
4769  * @return
4770  *   0 on success, a negative errno value otherwise and rte_errno is set.
4771  */
4772 __rte_experimental
4773 int
4774 rte_flow_tunnel_item_release(uint16_t port_id,
4775 			     struct rte_flow_item *items,
4776 			     uint32_t num_of_items,
4777 			     struct rte_flow_error *error);
4778 
4779 /**
4780  * @warning
4781  * @b EXPERIMENTAL: this API may change without prior notice.
4782  *
4783  * Get a proxy port to manage "transfer" flows.
4784  *
4785  * Managing "transfer" flows requires that the user communicate them
4786  * via a port which has the privilege to control the embedded switch.
4787  * For some vendors, all ports in a given switching domain have
4788  * this privilege. For other vendors, it's only one port.
4789  *
4790  * This API indicates such a privileged port (a "proxy")
4791  * for a given port in the same switching domain.
4792  *
4793  * @note
4794  *   If the PMD serving @p port_id doesn't have the corresponding method
4795  *   implemented, the API will return @p port_id via @p proxy_port_id.
4796  *
4797  * @param port_id
4798  *   Indicates the port to get a "proxy" for
4799  * @param[out] proxy_port_id
4800  *   Indicates the "proxy" port
4801  * @param[out] error
4802  *   If not NULL, allows the PMD to provide verbose report in case of error
4803  *
4804  * @return
4805  *   0 on success, a negative error code otherwise
4806  */
4807 __rte_experimental
4808 int
4809 rte_flow_pick_transfer_proxy(uint16_t port_id, uint16_t *proxy_port_id,
4810 			     struct rte_flow_error *error);
4811 
4812 /**
4813  * @warning
4814  * @b EXPERIMENTAL: this API may change without prior notice.
4815  *
4816  * Create the flex item with specified configuration over
4817  * the Ethernet device.
4818  *
4819  * @param port_id
4820  *   Port identifier of Ethernet device.
4821  * @param[in] conf
4822  *   Item configuration.
4823  * @param[out] error
4824  *   Perform verbose error reporting if not NULL. PMDs initialize this
4825  *   structure in case of error only.
4826  *
4827  * @return
4828  *   Non-NULL opaque pointer on success, NULL otherwise and rte_errno is set.
4829  */
4830 __rte_experimental
4831 struct rte_flow_item_flex_handle *
4832 rte_flow_flex_item_create(uint16_t port_id,
4833 			  const struct rte_flow_item_flex_conf *conf,
4834 			  struct rte_flow_error *error);
4835 
4836 /**
4837  * Release the flex item on the specified Ethernet device.
4838  *
4839  * @param port_id
4840  *   Port identifier of Ethernet device.
4841  * @param[in] handle
4842  *   Handle of the item existing on the specified device.
4843  * @param[out] error
4844  *   Perform verbose error reporting if not NULL. PMDs initialize this
4845  *   structure in case of error only.
4846  *
4847  * @return
4848  *   0 on success, a negative errno value otherwise and rte_errno is set.
4849  */
4850 __rte_experimental
4851 int
4852 rte_flow_flex_item_release(uint16_t port_id,
4853 			   const struct rte_flow_item_flex_handle *handle,
4854 			   struct rte_flow_error *error);
4855 
4856 #ifdef __cplusplus
4857 }
4858 #endif
4859 
4860 #endif /* RTE_FLOW_H_ */
4861