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