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