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