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