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