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