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