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