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