ethdev: add GTP extension header to flow API
[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
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 /**
36  * Flow rule attributes.
37  *
38  * Priorities are set on a per rule based within groups.
39  *
40  * Lower values denote higher priority, the highest priority for a flow rule
41  * is 0, so that a flow that matches for than one rule, the rule with the
42  * lowest priority value will always be matched.
43  *
44  * Although optional, applications are encouraged to group similar rules as
45  * much as possible to fully take advantage of hardware capabilities
46  * (e.g. optimized matching) and work around limitations (e.g. a single
47  * pattern type possibly allowed in a given group). Applications should be
48  * aware that groups are not linked by default, and that they must be
49  * explicitly linked by the application using the JUMP action.
50  *
51  * Priority levels are arbitrary and up to the application, they
52  * do not need to be contiguous nor start from 0, however the maximum number
53  * varies between devices and may be affected by existing flow rules.
54  *
55  * If a packet is matched by several rules of a given group for a given
56  * priority level, the outcome is undefined. It can take any path, may be
57  * duplicated or even cause unrecoverable errors.
58  *
59  * Note that support for more than a single group and priority level is not
60  * guaranteed.
61  *
62  * Flow rules can apply to inbound and/or outbound traffic (ingress/egress).
63  *
64  * Several pattern items and actions are valid and can be used in both
65  * directions. Those valid for only one direction are described as such.
66  *
67  * At least one direction must be specified.
68  *
69  * Specifying both directions at once for a given rule is not recommended
70  * but may be valid in a few cases (e.g. shared counter).
71  */
72 struct rte_flow_attr {
73         uint32_t group; /**< Priority group. */
74         uint32_t priority; /**< Rule priority level within group. */
75         uint32_t ingress:1; /**< Rule applies to ingress traffic. */
76         uint32_t egress:1; /**< Rule applies to egress traffic. */
77         /**
78          * Instead of simply matching the properties of traffic as it would
79          * appear on a given DPDK port ID, enabling this attribute transfers
80          * a flow rule to the lowest possible level of any device endpoints
81          * found in the pattern.
82          *
83          * When supported, this effectively enables an application to
84          * re-route traffic not necessarily intended for it (e.g. coming
85          * from or addressed to different physical ports, VFs or
86          * applications) at the device level.
87          *
88          * It complements the behavior of some pattern items such as
89          * RTE_FLOW_ITEM_TYPE_PHY_PORT and is meaningless without them.
90          *
91          * When transferring flow rules, ingress and egress attributes keep
92          * their original meaning, as if processing traffic emitted or
93          * received by the application.
94          */
95         uint32_t transfer:1;
96         uint32_t reserved:29; /**< Reserved, must be zero. */
97 };
98
99 /**
100  * Matching pattern item types.
101  *
102  * Pattern items fall in two categories:
103  *
104  * - Matching protocol headers and packet data, usually associated with a
105  *   specification structure. These must be stacked in the same order as the
106  *   protocol layers to match inside packets, starting from the lowest.
107  *
108  * - Matching meta-data or affecting pattern processing, often without a
109  *   specification structure. Since they do not match packet contents, their
110  *   position in the list is usually not relevant.
111  *
112  * See the description of individual types for more information. Those
113  * marked with [META] fall into the second category.
114  */
115 enum rte_flow_item_type {
116         /**
117          * [META]
118          *
119          * End marker for item lists. Prevents further processing of items,
120          * thereby ending the pattern.
121          *
122          * No associated specification structure.
123          */
124         RTE_FLOW_ITEM_TYPE_END,
125
126         /**
127          * [META]
128          *
129          * Used as a placeholder for convenience. It is ignored and simply
130          * discarded by PMDs.
131          *
132          * No associated specification structure.
133          */
134         RTE_FLOW_ITEM_TYPE_VOID,
135
136         /**
137          * [META]
138          *
139          * Inverted matching, i.e. process packets that do not match the
140          * pattern.
141          *
142          * No associated specification structure.
143          */
144         RTE_FLOW_ITEM_TYPE_INVERT,
145
146         /**
147          * Matches any protocol in place of the current layer, a single ANY
148          * may also stand for several protocol layers.
149          *
150          * See struct rte_flow_item_any.
151          */
152         RTE_FLOW_ITEM_TYPE_ANY,
153
154         /**
155          * [META]
156          *
157          * Matches traffic originating from (ingress) or going to (egress)
158          * the physical function of the current device.
159          *
160          * No associated specification structure.
161          */
162         RTE_FLOW_ITEM_TYPE_PF,
163
164         /**
165          * [META]
166          *
167          * Matches traffic originating from (ingress) or going to (egress) a
168          * given virtual function of the current device.
169          *
170          * See struct rte_flow_item_vf.
171          */
172         RTE_FLOW_ITEM_TYPE_VF,
173
174         /**
175          * [META]
176          *
177          * Matches traffic originating from (ingress) or going to (egress) a
178          * physical port of the underlying device.
179          *
180          * See struct rte_flow_item_phy_port.
181          */
182         RTE_FLOW_ITEM_TYPE_PHY_PORT,
183
184         /**
185          * [META]
186          *
187          * Matches traffic originating from (ingress) or going to (egress) a
188          * given DPDK port ID.
189          *
190          * See struct rte_flow_item_port_id.
191          */
192         RTE_FLOW_ITEM_TYPE_PORT_ID,
193
194         /**
195          * Matches a byte string of a given length at a given offset.
196          *
197          * See struct rte_flow_item_raw.
198          */
199         RTE_FLOW_ITEM_TYPE_RAW,
200
201         /**
202          * Matches an Ethernet header.
203          *
204          * See struct rte_flow_item_eth.
205          */
206         RTE_FLOW_ITEM_TYPE_ETH,
207
208         /**
209          * Matches an 802.1Q/ad VLAN tag.
210          *
211          * See struct rte_flow_item_vlan.
212          */
213         RTE_FLOW_ITEM_TYPE_VLAN,
214
215         /**
216          * Matches an IPv4 header.
217          *
218          * See struct rte_flow_item_ipv4.
219          */
220         RTE_FLOW_ITEM_TYPE_IPV4,
221
222         /**
223          * Matches an IPv6 header.
224          *
225          * See struct rte_flow_item_ipv6.
226          */
227         RTE_FLOW_ITEM_TYPE_IPV6,
228
229         /**
230          * Matches an ICMP header.
231          *
232          * See struct rte_flow_item_icmp.
233          */
234         RTE_FLOW_ITEM_TYPE_ICMP,
235
236         /**
237          * Matches a UDP header.
238          *
239          * See struct rte_flow_item_udp.
240          */
241         RTE_FLOW_ITEM_TYPE_UDP,
242
243         /**
244          * Matches a TCP header.
245          *
246          * See struct rte_flow_item_tcp.
247          */
248         RTE_FLOW_ITEM_TYPE_TCP,
249
250         /**
251          * Matches a SCTP header.
252          *
253          * See struct rte_flow_item_sctp.
254          */
255         RTE_FLOW_ITEM_TYPE_SCTP,
256
257         /**
258          * Matches a VXLAN header.
259          *
260          * See struct rte_flow_item_vxlan.
261          */
262         RTE_FLOW_ITEM_TYPE_VXLAN,
263
264         /**
265          * Matches a E_TAG header.
266          *
267          * See struct rte_flow_item_e_tag.
268          */
269         RTE_FLOW_ITEM_TYPE_E_TAG,
270
271         /**
272          * Matches a NVGRE header.
273          *
274          * See struct rte_flow_item_nvgre.
275          */
276         RTE_FLOW_ITEM_TYPE_NVGRE,
277
278         /**
279          * Matches a MPLS header.
280          *
281          * See struct rte_flow_item_mpls.
282          */
283         RTE_FLOW_ITEM_TYPE_MPLS,
284
285         /**
286          * Matches a GRE header.
287          *
288          * See struct rte_flow_item_gre.
289          */
290         RTE_FLOW_ITEM_TYPE_GRE,
291
292         /**
293          * [META]
294          *
295          * Fuzzy pattern match, expect faster than default.
296          *
297          * This is for device that support fuzzy matching option.
298          * Usually a fuzzy matching is fast but the cost is accuracy.
299          *
300          * See struct rte_flow_item_fuzzy.
301          */
302         RTE_FLOW_ITEM_TYPE_FUZZY,
303
304         /**
305          * Matches a GTP header.
306          *
307          * Configure flow for GTP packets.
308          *
309          * See struct rte_flow_item_gtp.
310          */
311         RTE_FLOW_ITEM_TYPE_GTP,
312
313         /**
314          * Matches a GTP header.
315          *
316          * Configure flow for GTP-C packets.
317          *
318          * See struct rte_flow_item_gtp.
319          */
320         RTE_FLOW_ITEM_TYPE_GTPC,
321
322         /**
323          * Matches a GTP header.
324          *
325          * Configure flow for GTP-U packets.
326          *
327          * See struct rte_flow_item_gtp.
328          */
329         RTE_FLOW_ITEM_TYPE_GTPU,
330
331         /**
332          * Matches a ESP header.
333          *
334          * See struct rte_flow_item_esp.
335          */
336         RTE_FLOW_ITEM_TYPE_ESP,
337
338         /**
339          * Matches a GENEVE header.
340          *
341          * See struct rte_flow_item_geneve.
342          */
343         RTE_FLOW_ITEM_TYPE_GENEVE,
344
345         /**
346          * Matches a VXLAN-GPE header.
347          *
348          * See struct rte_flow_item_vxlan_gpe.
349          */
350         RTE_FLOW_ITEM_TYPE_VXLAN_GPE,
351
352         /**
353          * Matches an ARP header for Ethernet/IPv4.
354          *
355          * See struct rte_flow_item_arp_eth_ipv4.
356          */
357         RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4,
358
359         /**
360          * Matches the presence of any IPv6 extension header.
361          *
362          * See struct rte_flow_item_ipv6_ext.
363          */
364         RTE_FLOW_ITEM_TYPE_IPV6_EXT,
365
366         /**
367          * Matches any ICMPv6 header.
368          *
369          * See struct rte_flow_item_icmp6.
370          */
371         RTE_FLOW_ITEM_TYPE_ICMP6,
372
373         /**
374          * Matches an ICMPv6 neighbor discovery solicitation.
375          *
376          * See struct rte_flow_item_icmp6_nd_ns.
377          */
378         RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS,
379
380         /**
381          * Matches an ICMPv6 neighbor discovery advertisement.
382          *
383          * See struct rte_flow_item_icmp6_nd_na.
384          */
385         RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA,
386
387         /**
388          * Matches the presence of any ICMPv6 neighbor discovery option.
389          *
390          * See struct rte_flow_item_icmp6_nd_opt.
391          */
392         RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT,
393
394         /**
395          * Matches an ICMPv6 neighbor discovery source Ethernet link-layer
396          * address option.
397          *
398          * See struct rte_flow_item_icmp6_nd_opt_sla_eth.
399          */
400         RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH,
401
402         /**
403          * Matches an ICMPv6 neighbor discovery target Ethernet link-layer
404          * address option.
405          *
406          * See struct rte_flow_item_icmp6_nd_opt_tla_eth.
407          */
408         RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH,
409
410         /**
411          * Matches specified mark field.
412          *
413          * See struct rte_flow_item_mark.
414          */
415         RTE_FLOW_ITEM_TYPE_MARK,
416
417         /**
418          * [META]
419          *
420          * Matches a metadata value specified in mbuf metadata field.
421          * See struct rte_flow_item_meta.
422          */
423         RTE_FLOW_ITEM_TYPE_META,
424
425         /**
426          * Matches a GRE optional key field.
427          *
428          * The value should a big-endian 32bit integer.
429          *
430          * When this item present the K bit is implicitly matched as "1"
431          * in the default mask.
432          *
433          * @p spec/mask type:
434          * @code rte_be32_t * @endcode
435          */
436         RTE_FLOW_ITEM_TYPE_GRE_KEY,
437
438         /**
439          * Matches a GTP extension header: PDU session container.
440          *
441          * Configure flow for GTP packets with extension header type 0x85.
442          *
443          * See struct rte_flow_item_gtp_psc.
444          */
445         RTE_FLOW_ITEM_TYPE_GTP_PSC,
446 };
447
448 /**
449  * RTE_FLOW_ITEM_TYPE_ANY
450  *
451  * Matches any protocol in place of the current layer, a single ANY may also
452  * stand for several protocol layers.
453  *
454  * This is usually specified as the first pattern item when looking for a
455  * protocol anywhere in a packet.
456  *
457  * A zeroed mask stands for any number of layers.
458  */
459 struct rte_flow_item_any {
460         uint32_t num; /**< Number of layers covered. */
461 };
462
463 /** Default mask for RTE_FLOW_ITEM_TYPE_ANY. */
464 #ifndef __cplusplus
465 static const struct rte_flow_item_any rte_flow_item_any_mask = {
466         .num = 0x00000000,
467 };
468 #endif
469
470 /**
471  * RTE_FLOW_ITEM_TYPE_VF
472  *
473  * Matches traffic originating from (ingress) or going to (egress) a given
474  * virtual function of the current device.
475  *
476  * If supported, should work even if the virtual function is not managed by
477  * the application and thus not associated with a DPDK port ID.
478  *
479  * Note this pattern item does not match VF representors traffic which, as
480  * separate entities, should be addressed through their own DPDK port IDs.
481  *
482  * - Can be specified multiple times to match traffic addressed to several
483  *   VF IDs.
484  * - Can be combined with a PF item to match both PF and VF traffic.
485  *
486  * A zeroed mask can be used to match any VF ID.
487  */
488 struct rte_flow_item_vf {
489         uint32_t id; /**< VF ID. */
490 };
491
492 /** Default mask for RTE_FLOW_ITEM_TYPE_VF. */
493 #ifndef __cplusplus
494 static const struct rte_flow_item_vf rte_flow_item_vf_mask = {
495         .id = 0x00000000,
496 };
497 #endif
498
499 /**
500  * RTE_FLOW_ITEM_TYPE_PHY_PORT
501  *
502  * Matches traffic originating from (ingress) or going to (egress) a
503  * physical port of the underlying device.
504  *
505  * The first PHY_PORT item overrides the physical port normally associated
506  * with the specified DPDK input port (port_id). This item can be provided
507  * several times to match additional physical ports.
508  *
509  * Note that physical ports are not necessarily tied to DPDK input ports
510  * (port_id) when those are not under DPDK control. Possible values are
511  * specific to each device, they are not necessarily indexed from zero and
512  * may not be contiguous.
513  *
514  * As a device property, the list of allowed values as well as the value
515  * associated with a port_id should be retrieved by other means.
516  *
517  * A zeroed mask can be used to match any port index.
518  */
519 struct rte_flow_item_phy_port {
520         uint32_t index; /**< Physical port index. */
521 };
522
523 /** Default mask for RTE_FLOW_ITEM_TYPE_PHY_PORT. */
524 #ifndef __cplusplus
525 static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask = {
526         .index = 0x00000000,
527 };
528 #endif
529
530 /**
531  * RTE_FLOW_ITEM_TYPE_PORT_ID
532  *
533  * Matches traffic originating from (ingress) or going to (egress) a given
534  * DPDK port ID.
535  *
536  * Normally only supported if the port ID in question is known by the
537  * underlying PMD and related to the device the flow rule is created
538  * against.
539  *
540  * This must not be confused with @p PHY_PORT which refers to the physical
541  * port of a device, whereas @p PORT_ID refers to a struct rte_eth_dev
542  * object on the application side (also known as "port representor"
543  * depending on the kind of underlying device).
544  */
545 struct rte_flow_item_port_id {
546         uint32_t id; /**< DPDK port ID. */
547 };
548
549 /** Default mask for RTE_FLOW_ITEM_TYPE_PORT_ID. */
550 #ifndef __cplusplus
551 static const struct rte_flow_item_port_id rte_flow_item_port_id_mask = {
552         .id = 0xffffffff,
553 };
554 #endif
555
556 /**
557  * RTE_FLOW_ITEM_TYPE_RAW
558  *
559  * Matches a byte string of a given length at a given offset.
560  *
561  * Offset is either absolute (using the start of the packet) or relative to
562  * the end of the previous matched item in the stack, in which case negative
563  * values are allowed.
564  *
565  * If search is enabled, offset is used as the starting point. The search
566  * area can be delimited by setting limit to a nonzero value, which is the
567  * maximum number of bytes after offset where the pattern may start.
568  *
569  * Matching a zero-length pattern is allowed, doing so resets the relative
570  * offset for subsequent items.
571  *
572  * This type does not support ranges (struct rte_flow_item.last).
573  */
574 struct rte_flow_item_raw {
575         uint32_t relative:1; /**< Look for pattern after the previous item. */
576         uint32_t search:1; /**< Search pattern from offset (see also limit). */
577         uint32_t reserved:30; /**< Reserved, must be set to zero. */
578         int32_t offset; /**< Absolute or relative offset for pattern. */
579         uint16_t limit; /**< Search area limit for start of pattern. */
580         uint16_t length; /**< Pattern length. */
581         const uint8_t *pattern; /**< Byte string to look for. */
582 };
583
584 /** Default mask for RTE_FLOW_ITEM_TYPE_RAW. */
585 #ifndef __cplusplus
586 static const struct rte_flow_item_raw rte_flow_item_raw_mask = {
587         .relative = 1,
588         .search = 1,
589         .reserved = 0x3fffffff,
590         .offset = 0xffffffff,
591         .limit = 0xffff,
592         .length = 0xffff,
593         .pattern = NULL,
594 };
595 #endif
596
597 /**
598  * RTE_FLOW_ITEM_TYPE_ETH
599  *
600  * Matches an Ethernet header.
601  *
602  * The @p type field either stands for "EtherType" or "TPID" when followed
603  * by so-called layer 2.5 pattern items such as RTE_FLOW_ITEM_TYPE_VLAN. In
604  * the latter case, @p type refers to that of the outer header, with the
605  * inner EtherType/TPID provided by the subsequent pattern item. This is the
606  * same order as on the wire.
607  */
608 struct rte_flow_item_eth {
609         struct rte_ether_addr dst; /**< Destination MAC. */
610         struct rte_ether_addr src; /**< Source MAC. */
611         rte_be16_t type; /**< EtherType or TPID. */
612 };
613
614 /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */
615 #ifndef __cplusplus
616 static const struct rte_flow_item_eth rte_flow_item_eth_mask = {
617         .dst.addr_bytes = "\xff\xff\xff\xff\xff\xff",
618         .src.addr_bytes = "\xff\xff\xff\xff\xff\xff",
619         .type = RTE_BE16(0x0000),
620 };
621 #endif
622
623 /**
624  * RTE_FLOW_ITEM_TYPE_VLAN
625  *
626  * Matches an 802.1Q/ad VLAN tag.
627  *
628  * The corresponding standard outer EtherType (TPID) values are
629  * RTE_ETHER_TYPE_VLAN or RTE_ETHER_TYPE_QINQ. It can be overridden by
630  * the preceding pattern item.
631  */
632 struct rte_flow_item_vlan {
633         rte_be16_t tci; /**< Tag control information. */
634         rte_be16_t inner_type; /**< Inner EtherType or TPID. */
635 };
636
637 /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */
638 #ifndef __cplusplus
639 static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = {
640         .tci = RTE_BE16(0x0fff),
641         .inner_type = RTE_BE16(0x0000),
642 };
643 #endif
644
645 /**
646  * RTE_FLOW_ITEM_TYPE_IPV4
647  *
648  * Matches an IPv4 header.
649  *
650  * Note: IPv4 options are handled by dedicated pattern items.
651  */
652 struct rte_flow_item_ipv4 {
653         struct rte_ipv4_hdr hdr; /**< IPv4 header definition. */
654 };
655
656 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV4. */
657 #ifndef __cplusplus
658 static const struct rte_flow_item_ipv4 rte_flow_item_ipv4_mask = {
659         .hdr = {
660                 .src_addr = RTE_BE32(0xffffffff),
661                 .dst_addr = RTE_BE32(0xffffffff),
662         },
663 };
664 #endif
665
666 /**
667  * RTE_FLOW_ITEM_TYPE_IPV6.
668  *
669  * Matches an IPv6 header.
670  *
671  * Note: IPv6 options are handled by dedicated pattern items, see
672  * RTE_FLOW_ITEM_TYPE_IPV6_EXT.
673  */
674 struct rte_flow_item_ipv6 {
675         struct rte_ipv6_hdr hdr; /**< IPv6 header definition. */
676 };
677
678 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
679 #ifndef __cplusplus
680 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
681         .hdr = {
682                 .src_addr =
683                         "\xff\xff\xff\xff\xff\xff\xff\xff"
684                         "\xff\xff\xff\xff\xff\xff\xff\xff",
685                 .dst_addr =
686                         "\xff\xff\xff\xff\xff\xff\xff\xff"
687                         "\xff\xff\xff\xff\xff\xff\xff\xff",
688         },
689 };
690 #endif
691
692 /**
693  * RTE_FLOW_ITEM_TYPE_ICMP.
694  *
695  * Matches an ICMP header.
696  */
697 struct rte_flow_item_icmp {
698         struct rte_icmp_hdr hdr; /**< ICMP header definition. */
699 };
700
701 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP. */
702 #ifndef __cplusplus
703 static const struct rte_flow_item_icmp rte_flow_item_icmp_mask = {
704         .hdr = {
705                 .icmp_type = 0xff,
706                 .icmp_code = 0xff,
707         },
708 };
709 #endif
710
711 /**
712  * RTE_FLOW_ITEM_TYPE_UDP.
713  *
714  * Matches a UDP header.
715  */
716 struct rte_flow_item_udp {
717         struct rte_udp_hdr hdr; /**< UDP header definition. */
718 };
719
720 /** Default mask for RTE_FLOW_ITEM_TYPE_UDP. */
721 #ifndef __cplusplus
722 static const struct rte_flow_item_udp rte_flow_item_udp_mask = {
723         .hdr = {
724                 .src_port = RTE_BE16(0xffff),
725                 .dst_port = RTE_BE16(0xffff),
726         },
727 };
728 #endif
729
730 /**
731  * RTE_FLOW_ITEM_TYPE_TCP.
732  *
733  * Matches a TCP header.
734  */
735 struct rte_flow_item_tcp {
736         struct rte_tcp_hdr hdr; /**< TCP header definition. */
737 };
738
739 /** Default mask for RTE_FLOW_ITEM_TYPE_TCP. */
740 #ifndef __cplusplus
741 static const struct rte_flow_item_tcp rte_flow_item_tcp_mask = {
742         .hdr = {
743                 .src_port = RTE_BE16(0xffff),
744                 .dst_port = RTE_BE16(0xffff),
745         },
746 };
747 #endif
748
749 /**
750  * RTE_FLOW_ITEM_TYPE_SCTP.
751  *
752  * Matches a SCTP header.
753  */
754 struct rte_flow_item_sctp {
755         struct rte_sctp_hdr hdr; /**< SCTP header definition. */
756 };
757
758 /** Default mask for RTE_FLOW_ITEM_TYPE_SCTP. */
759 #ifndef __cplusplus
760 static const struct rte_flow_item_sctp rte_flow_item_sctp_mask = {
761         .hdr = {
762                 .src_port = RTE_BE16(0xffff),
763                 .dst_port = RTE_BE16(0xffff),
764         },
765 };
766 #endif
767
768 /**
769  * RTE_FLOW_ITEM_TYPE_VXLAN.
770  *
771  * Matches a VXLAN header (RFC 7348).
772  */
773 struct rte_flow_item_vxlan {
774         uint8_t flags; /**< Normally 0x08 (I flag). */
775         uint8_t rsvd0[3]; /**< Reserved, normally 0x000000. */
776         uint8_t vni[3]; /**< VXLAN identifier. */
777         uint8_t rsvd1; /**< Reserved, normally 0x00. */
778 };
779
780 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */
781 #ifndef __cplusplus
782 static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = {
783         .vni = "\xff\xff\xff",
784 };
785 #endif
786
787 /**
788  * RTE_FLOW_ITEM_TYPE_E_TAG.
789  *
790  * Matches a E-tag header.
791  *
792  * The corresponding standard outer EtherType (TPID) value is
793  * RTE_ETHER_TYPE_ETAG. It can be overridden by the preceding pattern item.
794  */
795 struct rte_flow_item_e_tag {
796         /**
797          * E-Tag control information (E-TCI).
798          * E-PCP (3b), E-DEI (1b), ingress E-CID base (12b).
799          */
800         rte_be16_t epcp_edei_in_ecid_b;
801         /** Reserved (2b), GRP (2b), E-CID base (12b). */
802         rte_be16_t rsvd_grp_ecid_b;
803         uint8_t in_ecid_e; /**< Ingress E-CID ext. */
804         uint8_t ecid_e; /**< E-CID ext. */
805         rte_be16_t inner_type; /**< Inner EtherType or TPID. */
806 };
807
808 /** Default mask for RTE_FLOW_ITEM_TYPE_E_TAG. */
809 #ifndef __cplusplus
810 static const struct rte_flow_item_e_tag rte_flow_item_e_tag_mask = {
811         .rsvd_grp_ecid_b = RTE_BE16(0x3fff),
812 };
813 #endif
814
815 /**
816  * RTE_FLOW_ITEM_TYPE_NVGRE.
817  *
818  * Matches a NVGRE header.
819  */
820 struct rte_flow_item_nvgre {
821         /**
822          * Checksum (1b), undefined (1b), key bit (1b), sequence number (1b),
823          * reserved 0 (9b), version (3b).
824          *
825          * c_k_s_rsvd0_ver must have value 0x2000 according to RFC 7637.
826          */
827         rte_be16_t c_k_s_rsvd0_ver;
828         rte_be16_t protocol; /**< Protocol type (0x6558). */
829         uint8_t tni[3]; /**< Virtual subnet ID. */
830         uint8_t flow_id; /**< Flow ID. */
831 };
832
833 /** Default mask for RTE_FLOW_ITEM_TYPE_NVGRE. */
834 #ifndef __cplusplus
835 static const struct rte_flow_item_nvgre rte_flow_item_nvgre_mask = {
836         .tni = "\xff\xff\xff",
837 };
838 #endif
839
840 /**
841  * RTE_FLOW_ITEM_TYPE_MPLS.
842  *
843  * Matches a MPLS header.
844  */
845 struct rte_flow_item_mpls {
846         /**
847          * Label (20b), TC (3b), Bottom of Stack (1b).
848          */
849         uint8_t label_tc_s[3];
850         uint8_t ttl; /** Time-to-Live. */
851 };
852
853 /** Default mask for RTE_FLOW_ITEM_TYPE_MPLS. */
854 #ifndef __cplusplus
855 static const struct rte_flow_item_mpls rte_flow_item_mpls_mask = {
856         .label_tc_s = "\xff\xff\xf0",
857 };
858 #endif
859
860 /**
861  * RTE_FLOW_ITEM_TYPE_GRE.
862  *
863  * Matches a GRE header.
864  */
865 struct rte_flow_item_gre {
866         /**
867          * Checksum (1b), reserved 0 (12b), version (3b).
868          * Refer to RFC 2784.
869          */
870         rte_be16_t c_rsvd0_ver;
871         rte_be16_t protocol; /**< Protocol type. */
872 };
873
874 /** Default mask for RTE_FLOW_ITEM_TYPE_GRE. */
875 #ifndef __cplusplus
876 static const struct rte_flow_item_gre rte_flow_item_gre_mask = {
877         .protocol = RTE_BE16(0xffff),
878 };
879 #endif
880
881 /**
882  * RTE_FLOW_ITEM_TYPE_FUZZY
883  *
884  * Fuzzy pattern match, expect faster than default.
885  *
886  * This is for device that support fuzzy match option.
887  * Usually a fuzzy match is fast but the cost is accuracy.
888  * i.e. Signature Match only match pattern's hash value, but it is
889  * possible two different patterns have the same hash value.
890  *
891  * Matching accuracy level can be configure by threshold.
892  * Driver can divide the range of threshold and map to different
893  * accuracy levels that device support.
894  *
895  * Threshold 0 means perfect match (no fuzziness), while threshold
896  * 0xffffffff means fuzziest match.
897  */
898 struct rte_flow_item_fuzzy {
899         uint32_t thresh; /**< Accuracy threshold. */
900 };
901
902 /** Default mask for RTE_FLOW_ITEM_TYPE_FUZZY. */
903 #ifndef __cplusplus
904 static const struct rte_flow_item_fuzzy rte_flow_item_fuzzy_mask = {
905         .thresh = 0xffffffff,
906 };
907 #endif
908
909 /**
910  * RTE_FLOW_ITEM_TYPE_GTP.
911  *
912  * Matches a GTPv1 header.
913  */
914 struct rte_flow_item_gtp {
915         /**
916          * Version (3b), protocol type (1b), reserved (1b),
917          * Extension header flag (1b),
918          * Sequence number flag (1b),
919          * N-PDU number flag (1b).
920          */
921         uint8_t v_pt_rsv_flags;
922         uint8_t msg_type; /**< Message type. */
923         rte_be16_t msg_len; /**< Message length. */
924         rte_be32_t teid; /**< Tunnel endpoint identifier. */
925 };
926
927 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP. */
928 #ifndef __cplusplus
929 static const struct rte_flow_item_gtp rte_flow_item_gtp_mask = {
930         .teid = RTE_BE32(0xffffffff),
931 };
932 #endif
933
934 /**
935  * RTE_FLOW_ITEM_TYPE_ESP
936  *
937  * Matches an ESP header.
938  */
939 struct rte_flow_item_esp {
940         struct rte_esp_hdr hdr; /**< ESP header definition. */
941 };
942
943 /** Default mask for RTE_FLOW_ITEM_TYPE_ESP. */
944 #ifndef __cplusplus
945 static const struct rte_flow_item_esp rte_flow_item_esp_mask = {
946         .hdr = {
947                 .spi = RTE_BE32(0xffffffff),
948         },
949 };
950 #endif
951
952 /**
953  * RTE_FLOW_ITEM_TYPE_GENEVE.
954  *
955  * Matches a GENEVE header.
956  */
957 struct rte_flow_item_geneve {
958         /**
959          * Version (2b), length of the options fields (6b), OAM packet (1b),
960          * critical options present (1b), reserved 0 (6b).
961          */
962         rte_be16_t ver_opt_len_o_c_rsvd0;
963         rte_be16_t protocol; /**< Protocol type. */
964         uint8_t vni[3]; /**< Virtual Network Identifier. */
965         uint8_t rsvd1; /**< Reserved, normally 0x00. */
966 };
967
968 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE. */
969 #ifndef __cplusplus
970 static const struct rte_flow_item_geneve rte_flow_item_geneve_mask = {
971         .vni = "\xff\xff\xff",
972 };
973 #endif
974
975 /**
976  * RTE_FLOW_ITEM_TYPE_VXLAN_GPE (draft-ietf-nvo3-vxlan-gpe-05).
977  *
978  * Matches a VXLAN-GPE header.
979  */
980 struct rte_flow_item_vxlan_gpe {
981         uint8_t flags; /**< Normally 0x0c (I and P flags). */
982         uint8_t rsvd0[2]; /**< Reserved, normally 0x0000. */
983         uint8_t protocol; /**< Protocol type. */
984         uint8_t vni[3]; /**< VXLAN identifier. */
985         uint8_t rsvd1; /**< Reserved, normally 0x00. */
986 };
987
988 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN_GPE. */
989 #ifndef __cplusplus
990 static const struct rte_flow_item_vxlan_gpe rte_flow_item_vxlan_gpe_mask = {
991         .vni = "\xff\xff\xff",
992 };
993 #endif
994
995 /**
996  * RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4
997  *
998  * Matches an ARP header for Ethernet/IPv4.
999  */
1000 struct rte_flow_item_arp_eth_ipv4 {
1001         rte_be16_t hrd; /**< Hardware type, normally 1. */
1002         rte_be16_t pro; /**< Protocol type, normally 0x0800. */
1003         uint8_t hln; /**< Hardware address length, normally 6. */
1004         uint8_t pln; /**< Protocol address length, normally 4. */
1005         rte_be16_t op; /**< Opcode (1 for request, 2 for reply). */
1006         struct rte_ether_addr sha; /**< Sender hardware address. */
1007         rte_be32_t spa; /**< Sender IPv4 address. */
1008         struct rte_ether_addr tha; /**< Target hardware address. */
1009         rte_be32_t tpa; /**< Target IPv4 address. */
1010 };
1011
1012 /** Default mask for RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4. */
1013 #ifndef __cplusplus
1014 static const struct rte_flow_item_arp_eth_ipv4
1015 rte_flow_item_arp_eth_ipv4_mask = {
1016         .sha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1017         .spa = RTE_BE32(0xffffffff),
1018         .tha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1019         .tpa = RTE_BE32(0xffffffff),
1020 };
1021 #endif
1022
1023 /**
1024  * RTE_FLOW_ITEM_TYPE_IPV6_EXT
1025  *
1026  * Matches the presence of any IPv6 extension header.
1027  *
1028  * Normally preceded by any of:
1029  *
1030  * - RTE_FLOW_ITEM_TYPE_IPV6
1031  * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1032  */
1033 struct rte_flow_item_ipv6_ext {
1034         uint8_t next_hdr; /**< Next header. */
1035 };
1036
1037 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6_EXT. */
1038 #ifndef __cplusplus
1039 static const
1040 struct rte_flow_item_ipv6_ext rte_flow_item_ipv6_ext_mask = {
1041         .next_hdr = 0xff,
1042 };
1043 #endif
1044
1045 /**
1046  * RTE_FLOW_ITEM_TYPE_ICMP6
1047  *
1048  * Matches any ICMPv6 header.
1049  */
1050 struct rte_flow_item_icmp6 {
1051         uint8_t type; /**< ICMPv6 type. */
1052         uint8_t code; /**< ICMPv6 code. */
1053         uint16_t checksum; /**< ICMPv6 checksum. */
1054 };
1055
1056 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6. */
1057 #ifndef __cplusplus
1058 static const struct rte_flow_item_icmp6 rte_flow_item_icmp6_mask = {
1059         .type = 0xff,
1060         .code = 0xff,
1061 };
1062 #endif
1063
1064 /**
1065  * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1066  *
1067  * Matches an ICMPv6 neighbor discovery solicitation.
1068  */
1069 struct rte_flow_item_icmp6_nd_ns {
1070         uint8_t type; /**< ICMPv6 type, normally 135. */
1071         uint8_t code; /**< ICMPv6 code, normally 0. */
1072         rte_be16_t checksum; /**< ICMPv6 checksum. */
1073         rte_be32_t reserved; /**< Reserved, normally 0. */
1074         uint8_t target_addr[16]; /**< Target address. */
1075 };
1076
1077 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS. */
1078 #ifndef __cplusplus
1079 static const
1080 struct rte_flow_item_icmp6_nd_ns rte_flow_item_icmp6_nd_ns_mask = {
1081         .target_addr =
1082                 "\xff\xff\xff\xff\xff\xff\xff\xff"
1083                 "\xff\xff\xff\xff\xff\xff\xff\xff",
1084 };
1085 #endif
1086
1087 /**
1088  * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1089  *
1090  * Matches an ICMPv6 neighbor discovery advertisement.
1091  */
1092 struct rte_flow_item_icmp6_nd_na {
1093         uint8_t type; /**< ICMPv6 type, normally 136. */
1094         uint8_t code; /**< ICMPv6 code, normally 0. */
1095         rte_be16_t checksum; /**< ICMPv6 checksum. */
1096         /**
1097          * Route flag (1b), solicited flag (1b), override flag (1b),
1098          * reserved (29b).
1099          */
1100         rte_be32_t rso_reserved;
1101         uint8_t target_addr[16]; /**< Target address. */
1102 };
1103
1104 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA. */
1105 #ifndef __cplusplus
1106 static const
1107 struct rte_flow_item_icmp6_nd_na rte_flow_item_icmp6_nd_na_mask = {
1108         .target_addr =
1109                 "\xff\xff\xff\xff\xff\xff\xff\xff"
1110                 "\xff\xff\xff\xff\xff\xff\xff\xff",
1111 };
1112 #endif
1113
1114 /**
1115  * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1116  *
1117  * Matches the presence of any ICMPv6 neighbor discovery option.
1118  *
1119  * Normally preceded by any of:
1120  *
1121  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1122  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1123  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1124  */
1125 struct rte_flow_item_icmp6_nd_opt {
1126         uint8_t type; /**< ND option type. */
1127         uint8_t length; /**< ND option length. */
1128 };
1129
1130 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT. */
1131 #ifndef __cplusplus
1132 static const struct rte_flow_item_icmp6_nd_opt
1133 rte_flow_item_icmp6_nd_opt_mask = {
1134         .type = 0xff,
1135 };
1136 #endif
1137
1138 /**
1139  * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH
1140  *
1141  * Matches an ICMPv6 neighbor discovery source Ethernet link-layer address
1142  * option.
1143  *
1144  * Normally preceded by any of:
1145  *
1146  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1147  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1148  */
1149 struct rte_flow_item_icmp6_nd_opt_sla_eth {
1150         uint8_t type; /**< ND option type, normally 1. */
1151         uint8_t length; /**< ND option length, normally 1. */
1152         struct rte_ether_addr sla; /**< Source Ethernet LLA. */
1153 };
1154
1155 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH. */
1156 #ifndef __cplusplus
1157 static const struct rte_flow_item_icmp6_nd_opt_sla_eth
1158 rte_flow_item_icmp6_nd_opt_sla_eth_mask = {
1159         .sla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1160 };
1161 #endif
1162
1163 /**
1164  * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH
1165  *
1166  * Matches an ICMPv6 neighbor discovery target Ethernet link-layer address
1167  * option.
1168  *
1169  * Normally preceded by any of:
1170  *
1171  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1172  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1173  */
1174 struct rte_flow_item_icmp6_nd_opt_tla_eth {
1175         uint8_t type; /**< ND option type, normally 2. */
1176         uint8_t length; /**< ND option length, normally 1. */
1177         struct rte_ether_addr tla; /**< Target Ethernet LLA. */
1178 };
1179
1180 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH. */
1181 #ifndef __cplusplus
1182 static const struct rte_flow_item_icmp6_nd_opt_tla_eth
1183 rte_flow_item_icmp6_nd_opt_tla_eth_mask = {
1184         .tla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1185 };
1186 #endif
1187
1188 /**
1189  * RTE_FLOW_ITEM_TYPE_META.
1190  *
1191  * Matches a specified metadata value.
1192  */
1193 struct rte_flow_item_meta {
1194         rte_be32_t data;
1195 };
1196
1197 /** Default mask for RTE_FLOW_ITEM_TYPE_META. */
1198 #ifndef __cplusplus
1199 static const struct rte_flow_item_meta rte_flow_item_meta_mask = {
1200         .data = RTE_BE32(UINT32_MAX),
1201 };
1202 #endif
1203
1204 /**
1205  * RTE_FLOW_ITEM_TYPE_GTP_PSC.
1206  *
1207  * Matches a GTP PDU extension header with type 0x85.
1208  */
1209 struct rte_flow_item_gtp_psc {
1210         uint8_t pdu_type; /**< PDU type. */
1211         uint8_t qfi; /**< QoS flow identifier. */
1212 };
1213
1214 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP_PSC. */
1215 #ifndef __cplusplus
1216 static const struct rte_flow_item_gtp_psc
1217 rte_flow_item_gtp_psc_mask = {
1218         .qfi = 0x3f,
1219 };
1220 #endif
1221
1222 /**
1223  * @warning
1224  * @b EXPERIMENTAL: this structure may change without prior notice
1225  *
1226  * RTE_FLOW_ITEM_TYPE_MARK
1227  *
1228  * Matches an arbitrary integer value which was set using the ``MARK`` action
1229  * in a previously matched rule.
1230  *
1231  * This item can only be specified once as a match criteria as the ``MARK``
1232  * action can only be specified once in a flow action.
1233  *
1234  * This value is arbitrary and application-defined. Maximum allowed value
1235  * depends on the underlying implementation.
1236  *
1237  * Depending on the underlying implementation the MARK item may be supported on
1238  * the physical device, with virtual groups in the PMD or not at all.
1239  */
1240 struct rte_flow_item_mark {
1241         uint32_t id; /**< Integer value to match against. */
1242 };
1243
1244 /**
1245  * Matching pattern item definition.
1246  *
1247  * A pattern is formed by stacking items starting from the lowest protocol
1248  * layer to match. This stacking restriction does not apply to meta items
1249  * which can be placed anywhere in the stack without affecting the meaning
1250  * of the resulting pattern.
1251  *
1252  * Patterns are terminated by END items.
1253  *
1254  * The spec field should be a valid pointer to a structure of the related
1255  * item type. It may remain unspecified (NULL) in many cases to request
1256  * broad (nonspecific) matching. In such cases, last and mask must also be
1257  * set to NULL.
1258  *
1259  * Optionally, last can point to a structure of the same type to define an
1260  * inclusive range. This is mostly supported by integer and address fields,
1261  * may cause errors otherwise. Fields that do not support ranges must be set
1262  * to 0 or to the same value as the corresponding fields in spec.
1263  *
1264  * Only the fields defined to nonzero values in the default masks (see
1265  * rte_flow_item_{name}_mask constants) are considered relevant by
1266  * default. This can be overridden by providing a mask structure of the
1267  * same type with applicable bits set to one. It can also be used to
1268  * partially filter out specific fields (e.g. as an alternate mean to match
1269  * ranges of IP addresses).
1270  *
1271  * Mask is a simple bit-mask applied before interpreting the contents of
1272  * spec and last, which may yield unexpected results if not used
1273  * carefully. For example, if for an IPv4 address field, spec provides
1274  * 10.1.2.3, last provides 10.3.4.5 and mask provides 255.255.0.0, the
1275  * effective range becomes 10.1.0.0 to 10.3.255.255.
1276  */
1277 struct rte_flow_item {
1278         enum rte_flow_item_type type; /**< Item type. */
1279         const void *spec; /**< Pointer to item specification structure. */
1280         const void *last; /**< Defines an inclusive range (spec to last). */
1281         const void *mask; /**< Bit-mask applied to spec and last. */
1282 };
1283
1284 /**
1285  * Action types.
1286  *
1287  * Each possible action is represented by a type.
1288  * An action can have an associated configuration object.
1289  * Several actions combined in a list can be assigned
1290  * to a flow rule and are performed in order.
1291  *
1292  * They fall in three categories:
1293  *
1294  * - Actions that modify the fate of matching traffic, for instance by
1295  *   dropping or assigning it a specific destination.
1296  *
1297  * - Actions that modify matching traffic contents or its properties. This
1298  *   includes adding/removing encapsulation, encryption, compression and
1299  *   marks.
1300  *
1301  * - Actions related to the flow rule itself, such as updating counters or
1302  *   making it non-terminating.
1303  *
1304  * Flow rules being terminating by default, not specifying any action of the
1305  * fate kind results in undefined behavior. This applies to both ingress and
1306  * egress.
1307  *
1308  * PASSTHRU, when supported, makes a flow rule non-terminating.
1309  */
1310 enum rte_flow_action_type {
1311         /**
1312          * End marker for action lists. Prevents further processing of
1313          * actions, thereby ending the list.
1314          *
1315          * No associated configuration structure.
1316          */
1317         RTE_FLOW_ACTION_TYPE_END,
1318
1319         /**
1320          * Used as a placeholder for convenience. It is ignored and simply
1321          * discarded by PMDs.
1322          *
1323          * No associated configuration structure.
1324          */
1325         RTE_FLOW_ACTION_TYPE_VOID,
1326
1327         /**
1328          * Leaves traffic up for additional processing by subsequent flow
1329          * rules; makes a flow rule non-terminating.
1330          *
1331          * No associated configuration structure.
1332          */
1333         RTE_FLOW_ACTION_TYPE_PASSTHRU,
1334
1335         /**
1336          * RTE_FLOW_ACTION_TYPE_JUMP
1337          *
1338          * Redirects packets to a group on the current device.
1339          *
1340          * See struct rte_flow_action_jump.
1341          */
1342         RTE_FLOW_ACTION_TYPE_JUMP,
1343
1344         /**
1345          * Attaches an integer value to packets and sets PKT_RX_FDIR and
1346          * PKT_RX_FDIR_ID mbuf flags.
1347          *
1348          * See struct rte_flow_action_mark.
1349          */
1350         RTE_FLOW_ACTION_TYPE_MARK,
1351
1352         /**
1353          * Flags packets. Similar to MARK without a specific value; only
1354          * sets the PKT_RX_FDIR mbuf flag.
1355          *
1356          * No associated configuration structure.
1357          */
1358         RTE_FLOW_ACTION_TYPE_FLAG,
1359
1360         /**
1361          * Assigns packets to a given queue index.
1362          *
1363          * See struct rte_flow_action_queue.
1364          */
1365         RTE_FLOW_ACTION_TYPE_QUEUE,
1366
1367         /**
1368          * Drops packets.
1369          *
1370          * PASSTHRU overrides this action if both are specified.
1371          *
1372          * No associated configuration structure.
1373          */
1374         RTE_FLOW_ACTION_TYPE_DROP,
1375
1376         /**
1377          * Enables counters for this flow rule.
1378          *
1379          * These counters can be retrieved and reset through rte_flow_query(),
1380          * see struct rte_flow_query_count.
1381          *
1382          * See struct rte_flow_action_count.
1383          */
1384         RTE_FLOW_ACTION_TYPE_COUNT,
1385
1386         /**
1387          * Similar to QUEUE, except RSS is additionally performed on packets
1388          * to spread them among several queues according to the provided
1389          * parameters.
1390          *
1391          * See struct rte_flow_action_rss.
1392          */
1393         RTE_FLOW_ACTION_TYPE_RSS,
1394
1395         /**
1396          * Directs matching traffic to the physical function (PF) of the
1397          * current device.
1398          *
1399          * No associated configuration structure.
1400          */
1401         RTE_FLOW_ACTION_TYPE_PF,
1402
1403         /**
1404          * Directs matching traffic to a given virtual function of the
1405          * current device.
1406          *
1407          * See struct rte_flow_action_vf.
1408          */
1409         RTE_FLOW_ACTION_TYPE_VF,
1410
1411         /**
1412          * Directs packets to a given physical port index of the underlying
1413          * device.
1414          *
1415          * See struct rte_flow_action_phy_port.
1416          */
1417         RTE_FLOW_ACTION_TYPE_PHY_PORT,
1418
1419         /**
1420          * Directs matching traffic to a given DPDK port ID.
1421          *
1422          * See struct rte_flow_action_port_id.
1423          */
1424         RTE_FLOW_ACTION_TYPE_PORT_ID,
1425
1426         /**
1427          * Traffic metering and policing (MTR).
1428          *
1429          * See struct rte_flow_action_meter.
1430          * See file rte_mtr.h for MTR object configuration.
1431          */
1432         RTE_FLOW_ACTION_TYPE_METER,
1433
1434         /**
1435          * Redirects packets to security engine of current device for security
1436          * processing as specified by security session.
1437          *
1438          * See struct rte_flow_action_security.
1439          */
1440         RTE_FLOW_ACTION_TYPE_SECURITY,
1441
1442         /**
1443          * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the
1444          * OpenFlow Switch Specification.
1445          *
1446          * See struct rte_flow_action_of_set_mpls_ttl.
1447          */
1448         RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL,
1449
1450         /**
1451          * Implements OFPAT_DEC_MPLS_TTL ("decrement MPLS TTL") as defined
1452          * by the OpenFlow Switch Specification.
1453          *
1454          * No associated configuration structure.
1455          */
1456         RTE_FLOW_ACTION_TYPE_OF_DEC_MPLS_TTL,
1457
1458         /**
1459          * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow
1460          * Switch Specification.
1461          *
1462          * See struct rte_flow_action_of_set_nw_ttl.
1463          */
1464         RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL,
1465
1466         /**
1467          * Implements OFPAT_DEC_NW_TTL ("decrement IP TTL") as defined by
1468          * the OpenFlow Switch Specification.
1469          *
1470          * No associated configuration structure.
1471          */
1472         RTE_FLOW_ACTION_TYPE_OF_DEC_NW_TTL,
1473
1474         /**
1475          * Implements OFPAT_COPY_TTL_OUT ("copy TTL "outwards" -- from
1476          * next-to-outermost to outermost") as defined by the OpenFlow
1477          * Switch Specification.
1478          *
1479          * No associated configuration structure.
1480          */
1481         RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_OUT,
1482
1483         /**
1484          * Implements OFPAT_COPY_TTL_IN ("copy TTL "inwards" -- from
1485          * outermost to next-to-outermost") as defined by the OpenFlow
1486          * Switch Specification.
1487          *
1488          * No associated configuration structure.
1489          */
1490         RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_IN,
1491
1492         /**
1493          * Implements OFPAT_POP_VLAN ("pop the outer VLAN tag") as defined
1494          * by the OpenFlow Switch Specification.
1495          *
1496          * No associated configuration structure.
1497          */
1498         RTE_FLOW_ACTION_TYPE_OF_POP_VLAN,
1499
1500         /**
1501          * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by
1502          * the OpenFlow Switch Specification.
1503          *
1504          * See struct rte_flow_action_of_push_vlan.
1505          */
1506         RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
1507
1508         /**
1509          * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as
1510          * defined by the OpenFlow Switch Specification.
1511          *
1512          * See struct rte_flow_action_of_set_vlan_vid.
1513          */
1514         RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
1515
1516         /**
1517          * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as
1518          * defined by the OpenFlow Switch Specification.
1519          *
1520          * See struct rte_flow_action_of_set_vlan_pcp.
1521          */
1522         RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
1523
1524         /**
1525          * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined
1526          * by the OpenFlow Switch Specification.
1527          *
1528          * See struct rte_flow_action_of_pop_mpls.
1529          */
1530         RTE_FLOW_ACTION_TYPE_OF_POP_MPLS,
1531
1532         /**
1533          * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by
1534          * the OpenFlow Switch Specification.
1535          *
1536          * See struct rte_flow_action_of_push_mpls.
1537          */
1538         RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS,
1539
1540         /**
1541          * Encapsulate flow in VXLAN tunnel as defined in
1542          * rte_flow_action_vxlan_encap action structure.
1543          *
1544          * See struct rte_flow_action_vxlan_encap.
1545          */
1546         RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP,
1547
1548         /**
1549          * Decapsulate outer most VXLAN tunnel from matched flow.
1550          *
1551          * If flow pattern does not define a valid VXLAN tunnel (as specified by
1552          * RFC7348) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
1553          * error.
1554          */
1555         RTE_FLOW_ACTION_TYPE_VXLAN_DECAP,
1556
1557         /**
1558          * Encapsulate flow in NVGRE tunnel defined in the
1559          * rte_flow_action_nvgre_encap action structure.
1560          *
1561          * See struct rte_flow_action_nvgre_encap.
1562          */
1563         RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP,
1564
1565         /**
1566          * Decapsulate outer most NVGRE tunnel from matched flow.
1567          *
1568          * If flow pattern does not define a valid NVGRE tunnel (as specified by
1569          * RFC7637) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
1570          * error.
1571          */
1572         RTE_FLOW_ACTION_TYPE_NVGRE_DECAP,
1573
1574         /**
1575          * Add outer header whose template is provided in its data buffer
1576          *
1577          * See struct rte_flow_action_raw_encap.
1578          */
1579         RTE_FLOW_ACTION_TYPE_RAW_ENCAP,
1580
1581         /**
1582          * Remove outer header whose template is provided in its data buffer.
1583          *
1584          * See struct rte_flow_action_raw_decap
1585          */
1586         RTE_FLOW_ACTION_TYPE_RAW_DECAP,
1587
1588         /**
1589          * Modify IPv4 source address in the outermost IPv4 header.
1590          *
1591          * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
1592          * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1593          *
1594          * See struct rte_flow_action_set_ipv4.
1595          */
1596         RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC,
1597
1598         /**
1599          * Modify IPv4 destination address in the outermost IPv4 header.
1600          *
1601          * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
1602          * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1603          *
1604          * See struct rte_flow_action_set_ipv4.
1605          */
1606         RTE_FLOW_ACTION_TYPE_SET_IPV4_DST,
1607
1608         /**
1609          * Modify IPv6 source address in the outermost IPv6 header.
1610          *
1611          * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
1612          * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1613          *
1614          * See struct rte_flow_action_set_ipv6.
1615          */
1616         RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC,
1617
1618         /**
1619          * Modify IPv6 destination address in the outermost IPv6 header.
1620          *
1621          * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
1622          * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1623          *
1624          * See struct rte_flow_action_set_ipv6.
1625          */
1626         RTE_FLOW_ACTION_TYPE_SET_IPV6_DST,
1627
1628         /**
1629          * Modify source port number in the outermost TCP/UDP header.
1630          *
1631          * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
1632          * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
1633          * RTE_FLOW_ERROR_TYPE_ACTION error.
1634          *
1635          * See struct rte_flow_action_set_tp.
1636          */
1637         RTE_FLOW_ACTION_TYPE_SET_TP_SRC,
1638
1639         /**
1640          * Modify destination port number in the outermost TCP/UDP header.
1641          *
1642          * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
1643          * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
1644          * RTE_FLOW_ERROR_TYPE_ACTION error.
1645          *
1646          * See struct rte_flow_action_set_tp.
1647          */
1648         RTE_FLOW_ACTION_TYPE_SET_TP_DST,
1649
1650         /**
1651          * Swap the source and destination MAC addresses in the outermost
1652          * Ethernet header.
1653          *
1654          * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
1655          * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1656          *
1657          * No associated configuration structure.
1658          */
1659         RTE_FLOW_ACTION_TYPE_MAC_SWAP,
1660
1661         /**
1662          * Decrease TTL value directly
1663          *
1664          * No associated configuration structure.
1665          */
1666         RTE_FLOW_ACTION_TYPE_DEC_TTL,
1667
1668         /**
1669          * Set TTL value
1670          *
1671          * See struct rte_flow_action_set_ttl
1672          */
1673         RTE_FLOW_ACTION_TYPE_SET_TTL,
1674
1675         /**
1676          * Set source MAC address from matched flow.
1677          *
1678          * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
1679          * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1680          *
1681          * See struct rte_flow_action_set_mac.
1682          */
1683         RTE_FLOW_ACTION_TYPE_SET_MAC_SRC,
1684
1685         /**
1686          * Set destination MAC address from matched flow.
1687          *
1688          * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
1689          * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1690          *
1691          * See struct rte_flow_action_set_mac.
1692          */
1693         RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
1694
1695         /**
1696          * Increase sequence number in the outermost TCP header.
1697          *
1698          * Action configuration specifies the value to increase
1699          * TCP sequence number as a big-endian 32 bit integer.
1700          *
1701          * @p conf type:
1702          * @code rte_be32_t * @endcode
1703          *
1704          * Using this action on non-matching traffic will result in
1705          * undefined behavior.
1706          */
1707         RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
1708
1709         /**
1710          * Decrease sequence number in the outermost TCP header.
1711          *
1712          * Action configuration specifies the value to decrease
1713          * TCP sequence number as a big-endian 32 bit integer.
1714          *
1715          * @p conf type:
1716          * @code rte_be32_t * @endcode
1717          *
1718          * Using this action on non-matching traffic will result in
1719          * undefined behavior.
1720          */
1721         RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
1722
1723         /**
1724          * Increase acknowledgment number in the outermost TCP header.
1725          *
1726          * Action configuration specifies the value to increase
1727          * TCP acknowledgment number as a big-endian 32 bit integer.
1728          *
1729          * @p conf type:
1730          * @code rte_be32_t * @endcode
1731
1732          * Using this action on non-matching traffic will result in
1733          * undefined behavior.
1734          */
1735         RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
1736
1737         /**
1738          * Decrease acknowledgment number in the outermost TCP header.
1739          *
1740          * Action configuration specifies the value to decrease
1741          * TCP acknowledgment number as a big-endian 32 bit integer.
1742          *
1743          * @p conf type:
1744          * @code rte_be32_t * @endcode
1745          *
1746          * Using this action on non-matching traffic will result in
1747          * undefined behavior.
1748          */
1749         RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
1750 };
1751
1752 /**
1753  * RTE_FLOW_ACTION_TYPE_MARK
1754  *
1755  * Attaches an integer value to packets and sets PKT_RX_FDIR and
1756  * PKT_RX_FDIR_ID mbuf flags.
1757  *
1758  * This value is arbitrary and application-defined. Maximum allowed value
1759  * depends on the underlying implementation. It is returned in the
1760  * hash.fdir.hi mbuf field.
1761  */
1762 struct rte_flow_action_mark {
1763         uint32_t id; /**< Integer value to return with packets. */
1764 };
1765
1766 /**
1767  * @warning
1768  * @b EXPERIMENTAL: this structure may change without prior notice
1769  *
1770  * RTE_FLOW_ACTION_TYPE_JUMP
1771  *
1772  * Redirects packets to a group on the current device.
1773  *
1774  * In a hierarchy of groups, which can be used to represent physical or logical
1775  * flow tables on the device, this action allows the action to be a redirect to
1776  * a group on that device.
1777  */
1778 struct rte_flow_action_jump {
1779         uint32_t group;
1780 };
1781
1782 /**
1783  * RTE_FLOW_ACTION_TYPE_QUEUE
1784  *
1785  * Assign packets to a given queue index.
1786  */
1787 struct rte_flow_action_queue {
1788         uint16_t index; /**< Queue index to use. */
1789 };
1790
1791
1792 /**
1793  * @warning
1794  * @b EXPERIMENTAL: this structure may change without prior notice
1795  *
1796  * RTE_FLOW_ACTION_TYPE_COUNT
1797  *
1798  * Adds a counter action to a matched flow.
1799  *
1800  * If more than one count action is specified in a single flow rule, then each
1801  * action must specify a unique id.
1802  *
1803  * Counters can be retrieved and reset through ``rte_flow_query()``, see
1804  * ``struct rte_flow_query_count``.
1805  *
1806  * The shared flag indicates whether the counter is unique to the flow rule the
1807  * action is specified with, or whether it is a shared counter.
1808  *
1809  * For a count action with the shared flag set, then then a global device
1810  * namespace is assumed for the counter id, so that any matched flow rules using
1811  * a count action with the same counter id on the same port will contribute to
1812  * that counter.
1813  *
1814  * For ports within the same switch domain then the counter id namespace extends
1815  * to all ports within that switch domain.
1816  */
1817 struct rte_flow_action_count {
1818         uint32_t shared:1; /**< Share counter ID with other flow rules. */
1819         uint32_t reserved:31; /**< Reserved, must be zero. */
1820         uint32_t id; /**< Counter ID. */
1821 };
1822
1823 /**
1824  * RTE_FLOW_ACTION_TYPE_COUNT (query)
1825  *
1826  * Query structure to retrieve and reset flow rule counters.
1827  */
1828 struct rte_flow_query_count {
1829         uint32_t reset:1; /**< Reset counters after query [in]. */
1830         uint32_t hits_set:1; /**< hits field is set [out]. */
1831         uint32_t bytes_set:1; /**< bytes field is set [out]. */
1832         uint32_t reserved:29; /**< Reserved, must be zero [in, out]. */
1833         uint64_t hits; /**< Number of hits for this rule [out]. */
1834         uint64_t bytes; /**< Number of bytes through this rule [out]. */
1835 };
1836
1837 /**
1838  * Hash function types.
1839  */
1840 enum rte_eth_hash_function {
1841         RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
1842         RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
1843         RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
1844         RTE_ETH_HASH_FUNCTION_MAX,
1845 };
1846
1847 /**
1848  * RTE_FLOW_ACTION_TYPE_RSS
1849  *
1850  * Similar to QUEUE, except RSS is additionally performed on packets to
1851  * spread them among several queues according to the provided parameters.
1852  *
1853  * Unlike global RSS settings used by other DPDK APIs, unsetting the
1854  * @p types field does not disable RSS in a flow rule. Doing so instead
1855  * requests safe unspecified "best-effort" settings from the underlying PMD,
1856  * which depending on the flow rule, may result in anything ranging from
1857  * empty (single queue) to all-inclusive RSS.
1858  *
1859  * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps
1860  * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only,
1861  * both can be requested simultaneously.
1862  */
1863 struct rte_flow_action_rss {
1864         enum rte_eth_hash_function func; /**< RSS hash function to apply. */
1865         /**
1866          * Packet encapsulation level RSS hash @p types apply to.
1867          *
1868          * - @p 0 requests the default behavior. Depending on the packet
1869          *   type, it can mean outermost, innermost, anything in between or
1870          *   even no RSS.
1871          *
1872          *   It basically stands for the innermost encapsulation level RSS
1873          *   can be performed on according to PMD and device capabilities.
1874          *
1875          * - @p 1 requests RSS to be performed on the outermost packet
1876          *   encapsulation level.
1877          *
1878          * - @p 2 and subsequent values request RSS to be performed on the
1879          *   specified inner packet encapsulation level, from outermost to
1880          *   innermost (lower to higher values).
1881          *
1882          * Values other than @p 0 are not necessarily supported.
1883          *
1884          * Requesting a specific RSS level on unrecognized traffic results
1885          * in undefined behavior. For predictable results, it is recommended
1886          * to make the flow rule pattern match packet headers up to the
1887          * requested encapsulation level so that only matching traffic goes
1888          * through.
1889          */
1890         uint32_t level;
1891         uint64_t types; /**< Specific RSS hash types (see ETH_RSS_*). */
1892         uint32_t key_len; /**< Hash key length in bytes. */
1893         uint32_t queue_num; /**< Number of entries in @p queue. */
1894         const uint8_t *key; /**< Hash key. */
1895         const uint16_t *queue; /**< Queue indices to use. */
1896 };
1897
1898 /**
1899  * RTE_FLOW_ACTION_TYPE_VF
1900  *
1901  * Directs matching traffic to a given virtual function of the current
1902  * device.
1903  *
1904  * Packets matched by a VF pattern item can be redirected to their original
1905  * VF ID instead of the specified one. This parameter may not be available
1906  * and is not guaranteed to work properly if the VF part is matched by a
1907  * prior flow rule or if packets are not addressed to a VF in the first
1908  * place.
1909  */
1910 struct rte_flow_action_vf {
1911         uint32_t original:1; /**< Use original VF ID if possible. */
1912         uint32_t reserved:31; /**< Reserved, must be zero. */
1913         uint32_t id; /**< VF ID. */
1914 };
1915
1916 /**
1917  * RTE_FLOW_ACTION_TYPE_PHY_PORT
1918  *
1919  * Directs packets to a given physical port index of the underlying
1920  * device.
1921  *
1922  * @see RTE_FLOW_ITEM_TYPE_PHY_PORT
1923  */
1924 struct rte_flow_action_phy_port {
1925         uint32_t original:1; /**< Use original port index if possible. */
1926         uint32_t reserved:31; /**< Reserved, must be zero. */
1927         uint32_t index; /**< Physical port index. */
1928 };
1929
1930 /**
1931  * RTE_FLOW_ACTION_TYPE_PORT_ID
1932  *
1933  * Directs matching traffic to a given DPDK port ID.
1934  *
1935  * @see RTE_FLOW_ITEM_TYPE_PORT_ID
1936  */
1937 struct rte_flow_action_port_id {
1938         uint32_t original:1; /**< Use original DPDK port ID if possible. */
1939         uint32_t reserved:31; /**< Reserved, must be zero. */
1940         uint32_t id; /**< DPDK port ID. */
1941 };
1942
1943 /**
1944  * RTE_FLOW_ACTION_TYPE_METER
1945  *
1946  * Traffic metering and policing (MTR).
1947  *
1948  * Packets matched by items of this type can be either dropped or passed to the
1949  * next item with their color set by the MTR object.
1950  */
1951 struct rte_flow_action_meter {
1952         uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */
1953 };
1954
1955 /**
1956  * RTE_FLOW_ACTION_TYPE_SECURITY
1957  *
1958  * Perform the security action on flows matched by the pattern items
1959  * according to the configuration of the security session.
1960  *
1961  * This action modifies the payload of matched flows. For INLINE_CRYPTO, the
1962  * security protocol headers and IV are fully provided by the application as
1963  * specified in the flow pattern. The payload of matching packets is
1964  * encrypted on egress, and decrypted and authenticated on ingress.
1965  * For INLINE_PROTOCOL, the security protocol is fully offloaded to HW,
1966  * providing full encapsulation and decapsulation of packets in security
1967  * protocols. The flow pattern specifies both the outer security header fields
1968  * and the inner packet fields. The security session specified in the action
1969  * must match the pattern parameters.
1970  *
1971  * The security session specified in the action must be created on the same
1972  * port as the flow action that is being specified.
1973  *
1974  * The ingress/egress flow attribute should match that specified in the
1975  * security session if the security session supports the definition of the
1976  * direction.
1977  *
1978  * Multiple flows can be configured to use the same security session.
1979  */
1980 struct rte_flow_action_security {
1981         void *security_session; /**< Pointer to security session structure. */
1982 };
1983
1984 /**
1985  * RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL
1986  *
1987  * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the OpenFlow
1988  * Switch Specification.
1989  */
1990 struct rte_flow_action_of_set_mpls_ttl {
1991         uint8_t mpls_ttl; /**< MPLS TTL. */
1992 };
1993
1994 /**
1995  * RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL
1996  *
1997  * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow Switch
1998  * Specification.
1999  */
2000 struct rte_flow_action_of_set_nw_ttl {
2001         uint8_t nw_ttl; /**< IP TTL. */
2002 };
2003
2004 /**
2005  * RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN
2006  *
2007  * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by the
2008  * OpenFlow Switch Specification.
2009  */
2010 struct rte_flow_action_of_push_vlan {
2011         rte_be16_t ethertype; /**< EtherType. */
2012 };
2013
2014 /**
2015  * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID
2016  *
2017  * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as defined by
2018  * the OpenFlow Switch Specification.
2019  */
2020 struct rte_flow_action_of_set_vlan_vid {
2021         rte_be16_t vlan_vid; /**< VLAN id. */
2022 };
2023
2024 /**
2025  * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP
2026  *
2027  * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as defined by
2028  * the OpenFlow Switch Specification.
2029  */
2030 struct rte_flow_action_of_set_vlan_pcp {
2031         uint8_t vlan_pcp; /**< VLAN priority. */
2032 };
2033
2034 /**
2035  * RTE_FLOW_ACTION_TYPE_OF_POP_MPLS
2036  *
2037  * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined by the
2038  * OpenFlow Switch Specification.
2039  */
2040 struct rte_flow_action_of_pop_mpls {
2041         rte_be16_t ethertype; /**< EtherType. */
2042 };
2043
2044 /**
2045  * RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS
2046  *
2047  * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by the
2048  * OpenFlow Switch Specification.
2049  */
2050 struct rte_flow_action_of_push_mpls {
2051         rte_be16_t ethertype; /**< EtherType. */
2052 };
2053
2054 /**
2055  * @warning
2056  * @b EXPERIMENTAL: this structure may change without prior notice
2057  *
2058  * RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP
2059  *
2060  * VXLAN tunnel end-point encapsulation data definition
2061  *
2062  * The tunnel definition is provided through the flow item pattern, the
2063  * provided pattern must conform to RFC7348 for the tunnel specified. The flow
2064  * definition must be provided in order from the RTE_FLOW_ITEM_TYPE_ETH
2065  * definition up the end item which is specified by RTE_FLOW_ITEM_TYPE_END.
2066  *
2067  * The mask field allows user to specify which fields in the flow item
2068  * definitions can be ignored and which have valid data and can be used
2069  * verbatim.
2070  *
2071  * Note: the last field is not used in the definition of a tunnel and can be
2072  * ignored.
2073  *
2074  * Valid flow definition for RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP include:
2075  *
2076  * - ETH / IPV4 / UDP / VXLAN / END
2077  * - ETH / IPV6 / UDP / VXLAN / END
2078  * - ETH / VLAN / IPV4 / UDP / VXLAN / END
2079  *
2080  */
2081 struct rte_flow_action_vxlan_encap {
2082         /**
2083          * Encapsulating vxlan tunnel definition
2084          * (terminated by the END pattern item).
2085          */
2086         struct rte_flow_item *definition;
2087 };
2088
2089 /**
2090  * @warning
2091  * @b EXPERIMENTAL: this structure may change without prior notice
2092  *
2093  * RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP
2094  *
2095  * NVGRE tunnel end-point encapsulation data definition
2096  *
2097  * The tunnel definition is provided through the flow item pattern  the
2098  * provided pattern must conform with RFC7637. The flow definition must be
2099  * provided in order from the RTE_FLOW_ITEM_TYPE_ETH definition up the end item
2100  * which is specified by RTE_FLOW_ITEM_TYPE_END.
2101  *
2102  * The mask field allows user to specify which fields in the flow item
2103  * definitions can be ignored and which have valid data and can be used
2104  * verbatim.
2105  *
2106  * Note: the last field is not used in the definition of a tunnel and can be
2107  * ignored.
2108  *
2109  * Valid flow definition for RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP include:
2110  *
2111  * - ETH / IPV4 / NVGRE / END
2112  * - ETH / VLAN / IPV6 / NVGRE / END
2113  *
2114  */
2115 struct rte_flow_action_nvgre_encap {
2116         /**
2117          * Encapsulating vxlan tunnel definition
2118          * (terminated by the END pattern item).
2119          */
2120         struct rte_flow_item *definition;
2121 };
2122
2123 /**
2124  * @warning
2125  * @b EXPERIMENTAL: this structure may change without prior notice
2126  *
2127  * RTE_FLOW_ACTION_TYPE_RAW_ENCAP
2128  *
2129  * Raw tunnel end-point encapsulation data definition.
2130  *
2131  * The data holds the headers definitions to be applied on the packet.
2132  * The data must start with ETH header up to the tunnel item header itself.
2133  * When used right after RAW_DECAP (for decapsulating L3 tunnel type for
2134  * example MPLSoGRE) the data will just hold layer 2 header.
2135  *
2136  * The preserve parameter holds which bits in the packet the PMD is not allowed
2137  * to change, this parameter can also be NULL and then the PMD is allowed
2138  * to update any field.
2139  *
2140  * size holds the number of bytes in @p data and @p preserve.
2141  */
2142 struct rte_flow_action_raw_encap {
2143         uint8_t *data; /**< Encapsulation data. */
2144         uint8_t *preserve; /**< Bit-mask of @p data to preserve on output. */
2145         size_t size; /**< Size of @p data and @p preserve. */
2146 };
2147
2148 /**
2149  * @warning
2150  * @b EXPERIMENTAL: this structure may change without prior notice
2151  *
2152  * RTE_FLOW_ACTION_TYPE_RAW_DECAP
2153  *
2154  * Raw tunnel end-point decapsulation data definition.
2155  *
2156  * The data holds the headers definitions to be removed from the packet.
2157  * The data must start with ETH header up to the tunnel item header itself.
2158  * When used right before RAW_DECAP (for encapsulating L3 tunnel type for
2159  * example MPLSoGRE) the data will just hold layer 2 header.
2160  *
2161  * size holds the number of bytes in @p data.
2162  */
2163 struct rte_flow_action_raw_decap {
2164         uint8_t *data; /**< Encapsulation data. */
2165         size_t size; /**< Size of @p data and @p preserve. */
2166 };
2167
2168 /**
2169  * @warning
2170  * @b EXPERIMENTAL: this structure may change without prior notice
2171  *
2172  * RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC
2173  * RTE_FLOW_ACTION_TYPE_SET_IPV4_DST
2174  *
2175  * Allows modification of IPv4 source (RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC)
2176  * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV4_DST) in the
2177  * specified outermost IPv4 header.
2178  */
2179 struct rte_flow_action_set_ipv4 {
2180         rte_be32_t ipv4_addr;
2181 };
2182
2183 /**
2184  * @warning
2185  * @b EXPERIMENTAL: this structure may change without prior notice
2186  *
2187  * RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC
2188  * RTE_FLOW_ACTION_TYPE_SET_IPV6_DST
2189  *
2190  * Allows modification of IPv6 source (RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC)
2191  * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV6_DST) in the
2192  * specified outermost IPv6 header.
2193  */
2194 struct rte_flow_action_set_ipv6 {
2195         uint8_t ipv6_addr[16];
2196 };
2197
2198 /**
2199  * @warning
2200  * @b EXPERIMENTAL: this structure may change without prior notice
2201  *
2202  * RTE_FLOW_ACTION_TYPE_SET_TP_SRC
2203  * RTE_FLOW_ACTION_TYPE_SET_TP_DST
2204  *
2205  * Allows modification of source (RTE_FLOW_ACTION_TYPE_SET_TP_SRC)
2206  * and destination (RTE_FLOW_ACTION_TYPE_SET_TP_DST) port numbers
2207  * in the specified outermost TCP/UDP header.
2208  */
2209 struct rte_flow_action_set_tp {
2210         rte_be16_t port;
2211 };
2212
2213 /**
2214  * RTE_FLOW_ACTION_TYPE_SET_TTL
2215  *
2216  * Set the TTL value directly for IPv4 or IPv6
2217  */
2218 struct rte_flow_action_set_ttl {
2219         uint8_t ttl_value;
2220 };
2221
2222 /**
2223  * RTE_FLOW_ACTION_TYPE_SET_MAC
2224  *
2225  * Set MAC address from the matched flow
2226  */
2227 struct rte_flow_action_set_mac {
2228         uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
2229 };
2230
2231 /*
2232  * Definition of a single action.
2233  *
2234  * A list of actions is terminated by a END action.
2235  *
2236  * For simple actions without a configuration object, conf remains NULL.
2237  */
2238 struct rte_flow_action {
2239         enum rte_flow_action_type type; /**< Action type. */
2240         const void *conf; /**< Pointer to action configuration object. */
2241 };
2242
2243 /**
2244  * Opaque type returned after successfully creating a flow.
2245  *
2246  * This handle can be used to manage and query the related flow (e.g. to
2247  * destroy it or retrieve counters).
2248  */
2249 struct rte_flow;
2250
2251 /**
2252  * Verbose error types.
2253  *
2254  * Most of them provide the type of the object referenced by struct
2255  * rte_flow_error.cause.
2256  */
2257 enum rte_flow_error_type {
2258         RTE_FLOW_ERROR_TYPE_NONE, /**< No error. */
2259         RTE_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
2260         RTE_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */
2261         RTE_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */
2262         RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */
2263         RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */
2264         RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */
2265         RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */
2266         RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */
2267         RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */
2268         RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */
2269         RTE_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */
2270         RTE_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */
2271         RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */
2272         RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */
2273         RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */
2274         RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */
2275 };
2276
2277 /**
2278  * Verbose error structure definition.
2279  *
2280  * This object is normally allocated by applications and set by PMDs, the
2281  * message points to a constant string which does not need to be freed by
2282  * the application, however its pointer can be considered valid only as long
2283  * as its associated DPDK port remains configured. Closing the underlying
2284  * device or unloading the PMD invalidates it.
2285  *
2286  * Both cause and message may be NULL regardless of the error type.
2287  */
2288 struct rte_flow_error {
2289         enum rte_flow_error_type type; /**< Cause field and error types. */
2290         const void *cause; /**< Object responsible for the error. */
2291         const char *message; /**< Human-readable error message. */
2292 };
2293
2294 /**
2295  * Complete flow rule description.
2296  *
2297  * This object type is used when converting a flow rule description.
2298  *
2299  * @see RTE_FLOW_CONV_OP_RULE
2300  * @see rte_flow_conv()
2301  */
2302 RTE_STD_C11
2303 struct rte_flow_conv_rule {
2304         union {
2305                 const struct rte_flow_attr *attr_ro; /**< RO attributes. */
2306                 struct rte_flow_attr *attr; /**< Attributes. */
2307         };
2308         union {
2309                 const struct rte_flow_item *pattern_ro; /**< RO pattern. */
2310                 struct rte_flow_item *pattern; /**< Pattern items. */
2311         };
2312         union {
2313                 const struct rte_flow_action *actions_ro; /**< RO actions. */
2314                 struct rte_flow_action *actions; /**< List of actions. */
2315         };
2316 };
2317
2318 /**
2319  * Conversion operations for flow API objects.
2320  *
2321  * @see rte_flow_conv()
2322  */
2323 enum rte_flow_conv_op {
2324         /**
2325          * No operation to perform.
2326          *
2327          * rte_flow_conv() simply returns 0.
2328          */
2329         RTE_FLOW_CONV_OP_NONE,
2330
2331         /**
2332          * Convert attributes structure.
2333          *
2334          * This is a basic copy of an attributes structure.
2335          *
2336          * - @p src type:
2337          *   @code const struct rte_flow_attr * @endcode
2338          * - @p dst type:
2339          *   @code struct rte_flow_attr * @endcode
2340          */
2341         RTE_FLOW_CONV_OP_ATTR,
2342
2343         /**
2344          * Convert a single item.
2345          *
2346          * Duplicates @p spec, @p last and @p mask but not outside objects.
2347          *
2348          * - @p src type:
2349          *   @code const struct rte_flow_item * @endcode
2350          * - @p dst type:
2351          *   @code struct rte_flow_item * @endcode
2352          */
2353         RTE_FLOW_CONV_OP_ITEM,
2354
2355         /**
2356          * Convert a single action.
2357          *
2358          * Duplicates @p conf but not outside objects.
2359          *
2360          * - @p src type:
2361          *   @code const struct rte_flow_action * @endcode
2362          * - @p dst type:
2363          *   @code struct rte_flow_action * @endcode
2364          */
2365         RTE_FLOW_CONV_OP_ACTION,
2366
2367         /**
2368          * Convert an entire pattern.
2369          *
2370          * Duplicates all pattern items at once with the same constraints as
2371          * RTE_FLOW_CONV_OP_ITEM.
2372          *
2373          * - @p src type:
2374          *   @code const struct rte_flow_item * @endcode
2375          * - @p dst type:
2376          *   @code struct rte_flow_item * @endcode
2377          */
2378         RTE_FLOW_CONV_OP_PATTERN,
2379
2380         /**
2381          * Convert a list of actions.
2382          *
2383          * Duplicates the entire list of actions at once with the same
2384          * constraints as RTE_FLOW_CONV_OP_ACTION.
2385          *
2386          * - @p src type:
2387          *   @code const struct rte_flow_action * @endcode
2388          * - @p dst type:
2389          *   @code struct rte_flow_action * @endcode
2390          */
2391         RTE_FLOW_CONV_OP_ACTIONS,
2392
2393         /**
2394          * Convert a complete flow rule description.
2395          *
2396          * Comprises attributes, pattern and actions together at once with
2397          * the usual constraints.
2398          *
2399          * - @p src type:
2400          *   @code const struct rte_flow_conv_rule * @endcode
2401          * - @p dst type:
2402          *   @code struct rte_flow_conv_rule * @endcode
2403          */
2404         RTE_FLOW_CONV_OP_RULE,
2405
2406         /**
2407          * Convert item type to its name string.
2408          *
2409          * Writes a NUL-terminated string to @p dst. Like snprintf(), the
2410          * returned value excludes the terminator which is always written
2411          * nonetheless.
2412          *
2413          * - @p src type:
2414          *   @code (const void *)enum rte_flow_item_type @endcode
2415          * - @p dst type:
2416          *   @code char * @endcode
2417          **/
2418         RTE_FLOW_CONV_OP_ITEM_NAME,
2419
2420         /**
2421          * Convert action type to its name string.
2422          *
2423          * Writes a NUL-terminated string to @p dst. Like snprintf(), the
2424          * returned value excludes the terminator which is always written
2425          * nonetheless.
2426          *
2427          * - @p src type:
2428          *   @code (const void *)enum rte_flow_action_type @endcode
2429          * - @p dst type:
2430          *   @code char * @endcode
2431          **/
2432         RTE_FLOW_CONV_OP_ACTION_NAME,
2433
2434         /**
2435          * Convert item type to pointer to item name.
2436          *
2437          * Retrieves item name pointer from its type. The string itself is
2438          * not copied; instead, a unique pointer to an internal static
2439          * constant storage is written to @p dst.
2440          *
2441          * - @p src type:
2442          *   @code (const void *)enum rte_flow_item_type @endcode
2443          * - @p dst type:
2444          *   @code const char ** @endcode
2445          */
2446         RTE_FLOW_CONV_OP_ITEM_NAME_PTR,
2447
2448         /**
2449          * Convert action type to pointer to action name.
2450          *
2451          * Retrieves action name pointer from its type. The string itself is
2452          * not copied; instead, a unique pointer to an internal static
2453          * constant storage is written to @p dst.
2454          *
2455          * - @p src type:
2456          *   @code (const void *)enum rte_flow_action_type @endcode
2457          * - @p dst type:
2458          *   @code const char ** @endcode
2459          */
2460         RTE_FLOW_CONV_OP_ACTION_NAME_PTR,
2461 };
2462
2463 /**
2464  * Check whether a flow rule can be created on a given port.
2465  *
2466  * The flow rule is validated for correctness and whether it could be accepted
2467  * by the device given sufficient resources. The rule is checked against the
2468  * current device mode and queue configuration. The flow rule may also
2469  * optionally be validated against existing flow rules and device resources.
2470  * This function has no effect on the target device.
2471  *
2472  * The returned value is guaranteed to remain valid only as long as no
2473  * successful calls to rte_flow_create() or rte_flow_destroy() are made in
2474  * the meantime and no device parameter affecting flow rules in any way are
2475  * modified, due to possible collisions or resource limitations (although in
2476  * such cases EINVAL should not be returned).
2477  *
2478  * @param port_id
2479  *   Port identifier of Ethernet device.
2480  * @param[in] attr
2481  *   Flow rule attributes.
2482  * @param[in] pattern
2483  *   Pattern specification (list terminated by the END pattern item).
2484  * @param[in] actions
2485  *   Associated actions (list terminated by the END action).
2486  * @param[out] error
2487  *   Perform verbose error reporting if not NULL. PMDs initialize this
2488  *   structure in case of error only.
2489  *
2490  * @return
2491  *   0 if flow rule is valid and can be created. A negative errno value
2492  *   otherwise (rte_errno is also set), the following errors are defined:
2493  *
2494  *   -ENOSYS: underlying device does not support this functionality.
2495  *
2496  *   -EIO: underlying device is removed.
2497  *
2498  *   -EINVAL: unknown or invalid rule specification.
2499  *
2500  *   -ENOTSUP: valid but unsupported rule specification (e.g. partial
2501  *   bit-masks are unsupported).
2502  *
2503  *   -EEXIST: collision with an existing rule. Only returned if device
2504  *   supports flow rule collision checking and there was a flow rule
2505  *   collision. Not receiving this return code is no guarantee that creating
2506  *   the rule will not fail due to a collision.
2507  *
2508  *   -ENOMEM: not enough memory to execute the function, or if the device
2509  *   supports resource validation, resource limitation on the device.
2510  *
2511  *   -EBUSY: action cannot be performed due to busy device resources, may
2512  *   succeed if the affected queues or even the entire port are in a stopped
2513  *   state (see rte_eth_dev_rx_queue_stop() and rte_eth_dev_stop()).
2514  */
2515 int
2516 rte_flow_validate(uint16_t port_id,
2517                   const struct rte_flow_attr *attr,
2518                   const struct rte_flow_item pattern[],
2519                   const struct rte_flow_action actions[],
2520                   struct rte_flow_error *error);
2521
2522 /**
2523  * Create a flow rule on a given port.
2524  *
2525  * @param port_id
2526  *   Port identifier of Ethernet device.
2527  * @param[in] attr
2528  *   Flow rule attributes.
2529  * @param[in] pattern
2530  *   Pattern specification (list terminated by the END pattern item).
2531  * @param[in] actions
2532  *   Associated actions (list terminated by the END action).
2533  * @param[out] error
2534  *   Perform verbose error reporting if not NULL. PMDs initialize this
2535  *   structure in case of error only.
2536  *
2537  * @return
2538  *   A valid handle in case of success, NULL otherwise and rte_errno is set
2539  *   to the positive version of one of the error codes defined for
2540  *   rte_flow_validate().
2541  */
2542 struct rte_flow *
2543 rte_flow_create(uint16_t port_id,
2544                 const struct rte_flow_attr *attr,
2545                 const struct rte_flow_item pattern[],
2546                 const struct rte_flow_action actions[],
2547                 struct rte_flow_error *error);
2548
2549 /**
2550  * Destroy a flow rule on a given port.
2551  *
2552  * Failure to destroy a flow rule handle may occur when other flow rules
2553  * depend on it, and destroying it would result in an inconsistent state.
2554  *
2555  * This function is only guaranteed to succeed if handles are destroyed in
2556  * reverse order of their creation.
2557  *
2558  * @param port_id
2559  *   Port identifier of Ethernet device.
2560  * @param flow
2561  *   Flow rule handle to destroy.
2562  * @param[out] error
2563  *   Perform verbose error reporting if not NULL. PMDs initialize this
2564  *   structure in case of error only.
2565  *
2566  * @return
2567  *   0 on success, a negative errno value otherwise and rte_errno is set.
2568  */
2569 int
2570 rte_flow_destroy(uint16_t port_id,
2571                  struct rte_flow *flow,
2572                  struct rte_flow_error *error);
2573
2574 /**
2575  * Destroy all flow rules associated with a port.
2576  *
2577  * In the unlikely event of failure, handles are still considered destroyed
2578  * and no longer valid but the port must be assumed to be in an inconsistent
2579  * state.
2580  *
2581  * @param port_id
2582  *   Port identifier of Ethernet device.
2583  * @param[out] error
2584  *   Perform verbose error reporting if not NULL. PMDs initialize this
2585  *   structure in case of error only.
2586  *
2587  * @return
2588  *   0 on success, a negative errno value otherwise and rte_errno is set.
2589  */
2590 int
2591 rte_flow_flush(uint16_t port_id,
2592                struct rte_flow_error *error);
2593
2594 /**
2595  * Query an existing flow rule.
2596  *
2597  * This function allows retrieving flow-specific data such as counters.
2598  * Data is gathered by special actions which must be present in the flow
2599  * rule definition.
2600  *
2601  * \see RTE_FLOW_ACTION_TYPE_COUNT
2602  *
2603  * @param port_id
2604  *   Port identifier of Ethernet device.
2605  * @param flow
2606  *   Flow rule handle to query.
2607  * @param action
2608  *   Action definition as defined in original flow rule.
2609  * @param[in, out] data
2610  *   Pointer to storage for the associated query data type.
2611  * @param[out] error
2612  *   Perform verbose error reporting if not NULL. PMDs initialize this
2613  *   structure in case of error only.
2614  *
2615  * @return
2616  *   0 on success, a negative errno value otherwise and rte_errno is set.
2617  */
2618 int
2619 rte_flow_query(uint16_t port_id,
2620                struct rte_flow *flow,
2621                const struct rte_flow_action *action,
2622                void *data,
2623                struct rte_flow_error *error);
2624
2625 /**
2626  * Restrict ingress traffic to the defined flow rules.
2627  *
2628  * Isolated mode guarantees that all ingress traffic comes from defined flow
2629  * rules only (current and future).
2630  *
2631  * Besides making ingress more deterministic, it allows PMDs to safely reuse
2632  * resources otherwise assigned to handle the remaining traffic, such as
2633  * global RSS configuration settings, VLAN filters, MAC address entries,
2634  * legacy filter API rules and so on in order to expand the set of possible
2635  * flow rule types.
2636  *
2637  * Calling this function as soon as possible after device initialization,
2638  * ideally before the first call to rte_eth_dev_configure(), is recommended
2639  * to avoid possible failures due to conflicting settings.
2640  *
2641  * Once effective, leaving isolated mode may not be possible depending on
2642  * PMD implementation.
2643  *
2644  * Additionally, the following functionality has no effect on the underlying
2645  * port and may return errors such as ENOTSUP ("not supported"):
2646  *
2647  * - Toggling promiscuous mode.
2648  * - Toggling allmulticast mode.
2649  * - Configuring MAC addresses.
2650  * - Configuring multicast addresses.
2651  * - Configuring VLAN filters.
2652  * - Configuring Rx filters through the legacy API (e.g. FDIR).
2653  * - Configuring global RSS settings.
2654  *
2655  * @param port_id
2656  *   Port identifier of Ethernet device.
2657  * @param set
2658  *   Nonzero to enter isolated mode, attempt to leave it otherwise.
2659  * @param[out] error
2660  *   Perform verbose error reporting if not NULL. PMDs initialize this
2661  *   structure in case of error only.
2662  *
2663  * @return
2664  *   0 on success, a negative errno value otherwise and rte_errno is set.
2665  */
2666 int
2667 rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error);
2668
2669 /**
2670  * Initialize flow error structure.
2671  *
2672  * @param[out] error
2673  *   Pointer to flow error structure (may be NULL).
2674  * @param code
2675  *   Related error code (rte_errno).
2676  * @param type
2677  *   Cause field and error types.
2678  * @param cause
2679  *   Object responsible for the error.
2680  * @param message
2681  *   Human-readable error message.
2682  *
2683  * @return
2684  *   Negative error code (errno value) and rte_errno is set.
2685  */
2686 int
2687 rte_flow_error_set(struct rte_flow_error *error,
2688                    int code,
2689                    enum rte_flow_error_type type,
2690                    const void *cause,
2691                    const char *message);
2692
2693 /**
2694  * @deprecated
2695  * @see rte_flow_copy()
2696  */
2697 struct rte_flow_desc {
2698         size_t size; /**< Allocated space including data[]. */
2699         struct rte_flow_attr attr; /**< Attributes. */
2700         struct rte_flow_item *items; /**< Items. */
2701         struct rte_flow_action *actions; /**< Actions. */
2702         uint8_t data[]; /**< Storage for items/actions. */
2703 };
2704
2705 /**
2706  * @deprecated
2707  * Copy an rte_flow rule description.
2708  *
2709  * This interface is kept for compatibility with older applications but is
2710  * implemented as a wrapper to rte_flow_conv(). It is deprecated due to its
2711  * lack of flexibility and reliance on a type unusable with C++ programs
2712  * (struct rte_flow_desc).
2713  *
2714  * @param[in] fd
2715  *   Flow rule description.
2716  * @param[in] len
2717  *   Total size of allocated data for the flow description.
2718  * @param[in] attr
2719  *   Flow rule attributes.
2720  * @param[in] items
2721  *   Pattern specification (list terminated by the END pattern item).
2722  * @param[in] actions
2723  *   Associated actions (list terminated by the END action).
2724  *
2725  * @return
2726  *   If len is greater or equal to the size of the flow, the total size of the
2727  *   flow description and its data.
2728  *   If len is lower than the size of the flow, the number of bytes that would
2729  *   have been written to desc had it been sufficient. Nothing is written.
2730  */
2731 __rte_deprecated
2732 size_t
2733 rte_flow_copy(struct rte_flow_desc *fd, size_t len,
2734               const struct rte_flow_attr *attr,
2735               const struct rte_flow_item *items,
2736               const struct rte_flow_action *actions);
2737
2738 /**
2739  * Flow object conversion helper.
2740  *
2741  * This function performs conversion of various flow API objects to a
2742  * pre-allocated destination buffer. See enum rte_flow_conv_op for possible
2743  * operations and details about each of them.
2744  *
2745  * Since destination buffer must be large enough, it works in a manner
2746  * reminiscent of snprintf():
2747  *
2748  * - If @p size is 0, @p dst may be a NULL pointer, otherwise @p dst must be
2749  *   non-NULL.
2750  * - If positive, the returned value represents the number of bytes needed
2751  *   to store the conversion of @p src to @p dst according to @p op
2752  *   regardless of the @p size parameter.
2753  * - Since no more than @p size bytes can be written to @p dst, output is
2754  *   truncated and may be inconsistent when the returned value is larger
2755  *   than that.
2756  * - In case of conversion error, a negative error code is returned and
2757  *   @p dst contents are unspecified.
2758  *
2759  * @param op
2760  *   Operation to perform, related to the object type of @p dst.
2761  * @param[out] dst
2762  *   Destination buffer address. Must be suitably aligned by the caller.
2763  * @param size
2764  *   Destination buffer size in bytes.
2765  * @param[in] src
2766  *   Source object to copy. Depending on @p op, its type may differ from
2767  *   that of @p dst.
2768  * @param[out] error
2769  *   Perform verbose error reporting if not NULL. Initialized in case of
2770  *   error only.
2771  *
2772  * @return
2773  *   The number of bytes required to convert @p src to @p dst on success, a
2774  *   negative errno value otherwise and rte_errno is set.
2775  *
2776  * @see rte_flow_conv_op
2777  */
2778 __rte_experimental
2779 int
2780 rte_flow_conv(enum rte_flow_conv_op op,
2781               void *dst,
2782               size_t size,
2783               const void *src,
2784               struct rte_flow_error *error);
2785
2786 #ifdef __cplusplus
2787 }
2788 #endif
2789
2790 #endif /* RTE_FLOW_H_ */