ethdev: add generic create/destroy ethdev APIs
[dpdk.git] / lib / librte_ether / 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_ether.h>
22 #include <rte_eth_ctrl.h>
23 #include <rte_icmp.h>
24 #include <rte_ip.h>
25 #include <rte_sctp.h>
26 #include <rte_tcp.h>
27 #include <rte_udp.h>
28 #include <rte_byteorder.h>
29 #include <rte_esp.h>
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 /**
36  * Flow rule attributes.
37  *
38  * Priorities are set on two levels: per group and per rule within groups.
39  *
40  * Lower values denote higher priority, the highest priority for both levels
41  * is 0, so that a rule with priority 0 in group 8 is always matched after a
42  * rule with priority 8 in group 0.
43  *
44  * Although optional, applications are encouraged to group similar rules as
45  * much as possible to fully take advantage of hardware capabilities
46  * (e.g. optimized matching) and work around limitations (e.g. a single
47  * pattern type possibly allowed in a given group).
48  *
49  * Group and priority levels are arbitrary and up to the application, they
50  * do not need to be contiguous nor start from 0, however the maximum number
51  * varies between devices and may be affected by existing flow rules.
52  *
53  * If a packet is matched by several rules of a given group for a given
54  * priority level, the outcome is undefined. It can take any path, may be
55  * duplicated or even cause unrecoverable errors.
56  *
57  * Note that support for more than a single group and priority level is not
58  * guaranteed.
59  *
60  * Flow rules can apply to inbound and/or outbound traffic (ingress/egress).
61  *
62  * Several pattern items and actions are valid and can be used in both
63  * directions. Those valid for only one direction are described as such.
64  *
65  * At least one direction must be specified.
66  *
67  * Specifying both directions at once for a given rule is not recommended
68  * but may be valid in a few cases (e.g. shared counter).
69  */
70 struct rte_flow_attr {
71         uint32_t group; /**< Priority group. */
72         uint32_t priority; /**< Priority level within group. */
73         uint32_t ingress:1; /**< Rule applies to ingress traffic. */
74         uint32_t egress:1; /**< Rule applies to egress traffic. */
75         /**
76          * Instead of simply matching the properties of traffic as it would
77          * appear on a given DPDK port ID, enabling this attribute transfers
78          * a flow rule to the lowest possible level of any device endpoints
79          * found in the pattern.
80          *
81          * When supported, this effectively enables an application to
82          * re-route traffic not necessarily intended for it (e.g. coming
83          * from or addressed to different physical ports, VFs or
84          * applications) at the device level.
85          *
86          * It complements the behavior of some pattern items such as
87          * RTE_FLOW_ITEM_TYPE_PHY_PORT and is meaningless without them.
88          *
89          * When transferring flow rules, ingress and egress attributes keep
90          * their original meaning, as if processing traffic emitted or
91          * received by the application.
92          */
93         uint32_t transfer:1;
94         uint32_t reserved:29; /**< Reserved, must be zero. */
95 };
96
97 /**
98  * Matching pattern item types.
99  *
100  * Pattern items fall in two categories:
101  *
102  * - Matching protocol headers and packet data, usually associated with a
103  *   specification structure. These must be stacked in the same order as the
104  *   protocol layers to match inside packets, starting from the lowest.
105  *
106  * - Matching meta-data or affecting pattern processing, often without a
107  *   specification structure. Since they do not match packet contents, their
108  *   position in the list is usually not relevant.
109  *
110  * See the description of individual types for more information. Those
111  * marked with [META] fall into the second category.
112  */
113 enum rte_flow_item_type {
114         /**
115          * [META]
116          *
117          * End marker for item lists. Prevents further processing of items,
118          * thereby ending the pattern.
119          *
120          * No associated specification structure.
121          */
122         RTE_FLOW_ITEM_TYPE_END,
123
124         /**
125          * [META]
126          *
127          * Used as a placeholder for convenience. It is ignored and simply
128          * discarded by PMDs.
129          *
130          * No associated specification structure.
131          */
132         RTE_FLOW_ITEM_TYPE_VOID,
133
134         /**
135          * [META]
136          *
137          * Inverted matching, i.e. process packets that do not match the
138          * pattern.
139          *
140          * No associated specification structure.
141          */
142         RTE_FLOW_ITEM_TYPE_INVERT,
143
144         /**
145          * Matches any protocol in place of the current layer, a single ANY
146          * may also stand for several protocol layers.
147          *
148          * See struct rte_flow_item_any.
149          */
150         RTE_FLOW_ITEM_TYPE_ANY,
151
152         /**
153          * [META]
154          *
155          * Matches traffic originating from (ingress) or going to (egress)
156          * the physical function of the current device.
157          *
158          * No associated specification structure.
159          */
160         RTE_FLOW_ITEM_TYPE_PF,
161
162         /**
163          * [META]
164          *
165          * Matches traffic originating from (ingress) or going to (egress) a
166          * given virtual function of the current device.
167          *
168          * See struct rte_flow_item_vf.
169          */
170         RTE_FLOW_ITEM_TYPE_VF,
171
172         /**
173          * [META]
174          *
175          * Matches traffic originating from (ingress) or going to (egress) a
176          * physical port of the underlying device.
177          *
178          * See struct rte_flow_item_phy_port.
179          */
180         RTE_FLOW_ITEM_TYPE_PHY_PORT,
181
182         /**
183          * [META]
184          *
185          * Matches traffic originating from (ingress) or going to (egress) a
186          * given DPDK port ID.
187          *
188          * See struct rte_flow_item_port_id.
189          */
190         RTE_FLOW_ITEM_TYPE_PORT_ID,
191
192         /**
193          * Matches a byte string of a given length at a given offset.
194          *
195          * See struct rte_flow_item_raw.
196          */
197         RTE_FLOW_ITEM_TYPE_RAW,
198
199         /**
200          * Matches an Ethernet header.
201          *
202          * See struct rte_flow_item_eth.
203          */
204         RTE_FLOW_ITEM_TYPE_ETH,
205
206         /**
207          * Matches an 802.1Q/ad VLAN tag.
208          *
209          * See struct rte_flow_item_vlan.
210          */
211         RTE_FLOW_ITEM_TYPE_VLAN,
212
213         /**
214          * Matches an IPv4 header.
215          *
216          * See struct rte_flow_item_ipv4.
217          */
218         RTE_FLOW_ITEM_TYPE_IPV4,
219
220         /**
221          * Matches an IPv6 header.
222          *
223          * See struct rte_flow_item_ipv6.
224          */
225         RTE_FLOW_ITEM_TYPE_IPV6,
226
227         /**
228          * Matches an ICMP header.
229          *
230          * See struct rte_flow_item_icmp.
231          */
232         RTE_FLOW_ITEM_TYPE_ICMP,
233
234         /**
235          * Matches a UDP header.
236          *
237          * See struct rte_flow_item_udp.
238          */
239         RTE_FLOW_ITEM_TYPE_UDP,
240
241         /**
242          * Matches a TCP header.
243          *
244          * See struct rte_flow_item_tcp.
245          */
246         RTE_FLOW_ITEM_TYPE_TCP,
247
248         /**
249          * Matches a SCTP header.
250          *
251          * See struct rte_flow_item_sctp.
252          */
253         RTE_FLOW_ITEM_TYPE_SCTP,
254
255         /**
256          * Matches a VXLAN header.
257          *
258          * See struct rte_flow_item_vxlan.
259          */
260         RTE_FLOW_ITEM_TYPE_VXLAN,
261
262         /**
263          * Matches a E_TAG header.
264          *
265          * See struct rte_flow_item_e_tag.
266          */
267         RTE_FLOW_ITEM_TYPE_E_TAG,
268
269         /**
270          * Matches a NVGRE header.
271          *
272          * See struct rte_flow_item_nvgre.
273          */
274         RTE_FLOW_ITEM_TYPE_NVGRE,
275
276         /**
277          * Matches a MPLS header.
278          *
279          * See struct rte_flow_item_mpls.
280          */
281         RTE_FLOW_ITEM_TYPE_MPLS,
282
283         /**
284          * Matches a GRE header.
285          *
286          * See struct rte_flow_item_gre.
287          */
288         RTE_FLOW_ITEM_TYPE_GRE,
289
290         /**
291          * [META]
292          *
293          * Fuzzy pattern match, expect faster than default.
294          *
295          * This is for device that support fuzzy matching option.
296          * Usually a fuzzy matching is fast but the cost is accuracy.
297          *
298          * See struct rte_flow_item_fuzzy.
299          */
300         RTE_FLOW_ITEM_TYPE_FUZZY,
301
302         /**
303          * Matches a GTP header.
304          *
305          * Configure flow for GTP packets.
306          *
307          * See struct rte_flow_item_gtp.
308          */
309         RTE_FLOW_ITEM_TYPE_GTP,
310
311         /**
312          * Matches a GTP header.
313          *
314          * Configure flow for GTP-C packets.
315          *
316          * See struct rte_flow_item_gtp.
317          */
318         RTE_FLOW_ITEM_TYPE_GTPC,
319
320         /**
321          * Matches a GTP header.
322          *
323          * Configure flow for GTP-U packets.
324          *
325          * See struct rte_flow_item_gtp.
326          */
327         RTE_FLOW_ITEM_TYPE_GTPU,
328
329         /**
330          * Matches a ESP header.
331          *
332          * See struct rte_flow_item_esp.
333          */
334         RTE_FLOW_ITEM_TYPE_ESP,
335
336         /**
337          * Matches a GENEVE header.
338          *
339          * See struct rte_flow_item_geneve.
340          */
341         RTE_FLOW_ITEM_TYPE_GENEVE,
342
343         /**
344          * Matches a VXLAN-GPE header.
345          *
346          * See struct rte_flow_item_vxlan_gpe.
347          */
348         RTE_FLOW_ITEM_TYPE_VXLAN_GPE,
349
350         /**
351          * Matches an ARP header for Ethernet/IPv4.
352          *
353          * See struct rte_flow_item_arp_eth_ipv4.
354          */
355         RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4,
356
357         /**
358          * Matches the presence of any IPv6 extension header.
359          *
360          * See struct rte_flow_item_ipv6_ext.
361          */
362         RTE_FLOW_ITEM_TYPE_IPV6_EXT,
363
364         /**
365          * Matches any ICMPv6 header.
366          *
367          * See struct rte_flow_item_icmp6.
368          */
369         RTE_FLOW_ITEM_TYPE_ICMP6,
370
371         /**
372          * Matches an ICMPv6 neighbor discovery solicitation.
373          *
374          * See struct rte_flow_item_icmp6_nd_ns.
375          */
376         RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS,
377
378         /**
379          * Matches an ICMPv6 neighbor discovery advertisement.
380          *
381          * See struct rte_flow_item_icmp6_nd_na.
382          */
383         RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA,
384
385         /**
386          * Matches the presence of any ICMPv6 neighbor discovery option.
387          *
388          * See struct rte_flow_item_icmp6_nd_opt.
389          */
390         RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT,
391
392         /**
393          * Matches an ICMPv6 neighbor discovery source Ethernet link-layer
394          * address option.
395          *
396          * See struct rte_flow_item_icmp6_nd_opt_sla_eth.
397          */
398         RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH,
399
400         /**
401          * Matches an ICMPv6 neighbor discovery target Ethernet link-layer
402          * address option.
403          *
404          * See struct rte_flow_item_icmp6_nd_opt_tla_eth.
405          */
406         RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH,
407 };
408
409 /**
410  * RTE_FLOW_ITEM_TYPE_ANY
411  *
412  * Matches any protocol in place of the current layer, a single ANY may also
413  * stand for several protocol layers.
414  *
415  * This is usually specified as the first pattern item when looking for a
416  * protocol anywhere in a packet.
417  *
418  * A zeroed mask stands for any number of layers.
419  */
420 struct rte_flow_item_any {
421         uint32_t num; /**< Number of layers covered. */
422 };
423
424 /** Default mask for RTE_FLOW_ITEM_TYPE_ANY. */
425 #ifndef __cplusplus
426 static const struct rte_flow_item_any rte_flow_item_any_mask = {
427         .num = 0x00000000,
428 };
429 #endif
430
431 /**
432  * RTE_FLOW_ITEM_TYPE_VF
433  *
434  * Matches traffic originating from (ingress) or going to (egress) a given
435  * virtual function of the current device.
436  *
437  * If supported, should work even if the virtual function is not managed by
438  * the application and thus not associated with a DPDK port ID.
439  *
440  * Note this pattern item does not match VF representors traffic which, as
441  * separate entities, should be addressed through their own DPDK port IDs.
442  *
443  * - Can be specified multiple times to match traffic addressed to several
444  *   VF IDs.
445  * - Can be combined with a PF item to match both PF and VF traffic.
446  *
447  * A zeroed mask can be used to match any VF ID.
448  */
449 struct rte_flow_item_vf {
450         uint32_t id; /**< VF ID. */
451 };
452
453 /** Default mask for RTE_FLOW_ITEM_TYPE_VF. */
454 #ifndef __cplusplus
455 static const struct rte_flow_item_vf rte_flow_item_vf_mask = {
456         .id = 0x00000000,
457 };
458 #endif
459
460 /**
461  * RTE_FLOW_ITEM_TYPE_PHY_PORT
462  *
463  * Matches traffic originating from (ingress) or going to (egress) a
464  * physical port of the underlying device.
465  *
466  * The first PHY_PORT item overrides the physical port normally associated
467  * with the specified DPDK input port (port_id). This item can be provided
468  * several times to match additional physical ports.
469  *
470  * Note that physical ports are not necessarily tied to DPDK input ports
471  * (port_id) when those are not under DPDK control. Possible values are
472  * specific to each device, they are not necessarily indexed from zero and
473  * may not be contiguous.
474  *
475  * As a device property, the list of allowed values as well as the value
476  * associated with a port_id should be retrieved by other means.
477  *
478  * A zeroed mask can be used to match any port index.
479  */
480 struct rte_flow_item_phy_port {
481         uint32_t index; /**< Physical port index. */
482 };
483
484 /** Default mask for RTE_FLOW_ITEM_TYPE_PHY_PORT. */
485 #ifndef __cplusplus
486 static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask = {
487         .index = 0x00000000,
488 };
489 #endif
490
491 /**
492  * RTE_FLOW_ITEM_TYPE_PORT_ID
493  *
494  * Matches traffic originating from (ingress) or going to (egress) a given
495  * DPDK port ID.
496  *
497  * Normally only supported if the port ID in question is known by the
498  * underlying PMD and related to the device the flow rule is created
499  * against.
500  *
501  * This must not be confused with @p PHY_PORT which refers to the physical
502  * port of a device, whereas @p PORT_ID refers to a struct rte_eth_dev
503  * object on the application side (also known as "port representor"
504  * depending on the kind of underlying device).
505  */
506 struct rte_flow_item_port_id {
507         uint32_t id; /**< DPDK port ID. */
508 };
509
510 /** Default mask for RTE_FLOW_ITEM_TYPE_PORT_ID. */
511 #ifndef __cplusplus
512 static const struct rte_flow_item_port_id rte_flow_item_port_id_mask = {
513         .id = 0xffffffff,
514 };
515 #endif
516
517 /**
518  * RTE_FLOW_ITEM_TYPE_RAW
519  *
520  * Matches a byte string of a given length at a given offset.
521  *
522  * Offset is either absolute (using the start of the packet) or relative to
523  * the end of the previous matched item in the stack, in which case negative
524  * values are allowed.
525  *
526  * If search is enabled, offset is used as the starting point. The search
527  * area can be delimited by setting limit to a nonzero value, which is the
528  * maximum number of bytes after offset where the pattern may start.
529  *
530  * Matching a zero-length pattern is allowed, doing so resets the relative
531  * offset for subsequent items.
532  *
533  * This type does not support ranges (struct rte_flow_item.last).
534  */
535 struct rte_flow_item_raw {
536         uint32_t relative:1; /**< Look for pattern after the previous item. */
537         uint32_t search:1; /**< Search pattern from offset (see also limit). */
538         uint32_t reserved:30; /**< Reserved, must be set to zero. */
539         int32_t offset; /**< Absolute or relative offset for pattern. */
540         uint16_t limit; /**< Search area limit for start of pattern. */
541         uint16_t length; /**< Pattern length. */
542         const uint8_t *pattern; /**< Byte string to look for. */
543 };
544
545 /** Default mask for RTE_FLOW_ITEM_TYPE_RAW. */
546 #ifndef __cplusplus
547 static const struct rte_flow_item_raw rte_flow_item_raw_mask = {
548         .relative = 1,
549         .search = 1,
550         .reserved = 0x3fffffff,
551         .offset = 0xffffffff,
552         .limit = 0xffff,
553         .length = 0xffff,
554         .pattern = NULL,
555 };
556 #endif
557
558 /**
559  * RTE_FLOW_ITEM_TYPE_ETH
560  *
561  * Matches an Ethernet header.
562  *
563  * The @p type field either stands for "EtherType" or "TPID" when followed
564  * by so-called layer 2.5 pattern items such as RTE_FLOW_ITEM_TYPE_VLAN. In
565  * the latter case, @p type refers to that of the outer header, with the
566  * inner EtherType/TPID provided by the subsequent pattern item. This is the
567  * same order as on the wire.
568  */
569 struct rte_flow_item_eth {
570         struct ether_addr dst; /**< Destination MAC. */
571         struct ether_addr src; /**< Source MAC. */
572         rte_be16_t type; /**< EtherType or TPID. */
573 };
574
575 /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */
576 #ifndef __cplusplus
577 static const struct rte_flow_item_eth rte_flow_item_eth_mask = {
578         .dst.addr_bytes = "\xff\xff\xff\xff\xff\xff",
579         .src.addr_bytes = "\xff\xff\xff\xff\xff\xff",
580         .type = RTE_BE16(0x0000),
581 };
582 #endif
583
584 /**
585  * RTE_FLOW_ITEM_TYPE_VLAN
586  *
587  * Matches an 802.1Q/ad VLAN tag.
588  *
589  * The corresponding standard outer EtherType (TPID) values are
590  * ETHER_TYPE_VLAN or ETHER_TYPE_QINQ. It can be overridden by the preceding
591  * pattern item.
592  */
593 struct rte_flow_item_vlan {
594         rte_be16_t tci; /**< Tag control information. */
595         rte_be16_t inner_type; /**< Inner EtherType or TPID. */
596 };
597
598 /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */
599 #ifndef __cplusplus
600 static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = {
601         .tci = RTE_BE16(0x0fff),
602         .inner_type = RTE_BE16(0x0000),
603 };
604 #endif
605
606 /**
607  * RTE_FLOW_ITEM_TYPE_IPV4
608  *
609  * Matches an IPv4 header.
610  *
611  * Note: IPv4 options are handled by dedicated pattern items.
612  */
613 struct rte_flow_item_ipv4 {
614         struct ipv4_hdr hdr; /**< IPv4 header definition. */
615 };
616
617 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV4. */
618 #ifndef __cplusplus
619 static const struct rte_flow_item_ipv4 rte_flow_item_ipv4_mask = {
620         .hdr = {
621                 .src_addr = RTE_BE32(0xffffffff),
622                 .dst_addr = RTE_BE32(0xffffffff),
623         },
624 };
625 #endif
626
627 /**
628  * RTE_FLOW_ITEM_TYPE_IPV6.
629  *
630  * Matches an IPv6 header.
631  *
632  * Note: IPv6 options are handled by dedicated pattern items, see
633  * RTE_FLOW_ITEM_TYPE_IPV6_EXT.
634  */
635 struct rte_flow_item_ipv6 {
636         struct ipv6_hdr hdr; /**< IPv6 header definition. */
637 };
638
639 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
640 #ifndef __cplusplus
641 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
642         .hdr = {
643                 .src_addr =
644                         "\xff\xff\xff\xff\xff\xff\xff\xff"
645                         "\xff\xff\xff\xff\xff\xff\xff\xff",
646                 .dst_addr =
647                         "\xff\xff\xff\xff\xff\xff\xff\xff"
648                         "\xff\xff\xff\xff\xff\xff\xff\xff",
649         },
650 };
651 #endif
652
653 /**
654  * RTE_FLOW_ITEM_TYPE_ICMP.
655  *
656  * Matches an ICMP header.
657  */
658 struct rte_flow_item_icmp {
659         struct icmp_hdr hdr; /**< ICMP header definition. */
660 };
661
662 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP. */
663 #ifndef __cplusplus
664 static const struct rte_flow_item_icmp rte_flow_item_icmp_mask = {
665         .hdr = {
666                 .icmp_type = 0xff,
667                 .icmp_code = 0xff,
668         },
669 };
670 #endif
671
672 /**
673  * RTE_FLOW_ITEM_TYPE_UDP.
674  *
675  * Matches a UDP header.
676  */
677 struct rte_flow_item_udp {
678         struct udp_hdr hdr; /**< UDP header definition. */
679 };
680
681 /** Default mask for RTE_FLOW_ITEM_TYPE_UDP. */
682 #ifndef __cplusplus
683 static const struct rte_flow_item_udp rte_flow_item_udp_mask = {
684         .hdr = {
685                 .src_port = RTE_BE16(0xffff),
686                 .dst_port = RTE_BE16(0xffff),
687         },
688 };
689 #endif
690
691 /**
692  * RTE_FLOW_ITEM_TYPE_TCP.
693  *
694  * Matches a TCP header.
695  */
696 struct rte_flow_item_tcp {
697         struct tcp_hdr hdr; /**< TCP header definition. */
698 };
699
700 /** Default mask for RTE_FLOW_ITEM_TYPE_TCP. */
701 #ifndef __cplusplus
702 static const struct rte_flow_item_tcp rte_flow_item_tcp_mask = {
703         .hdr = {
704                 .src_port = RTE_BE16(0xffff),
705                 .dst_port = RTE_BE16(0xffff),
706         },
707 };
708 #endif
709
710 /**
711  * RTE_FLOW_ITEM_TYPE_SCTP.
712  *
713  * Matches a SCTP header.
714  */
715 struct rte_flow_item_sctp {
716         struct sctp_hdr hdr; /**< SCTP header definition. */
717 };
718
719 /** Default mask for RTE_FLOW_ITEM_TYPE_SCTP. */
720 #ifndef __cplusplus
721 static const struct rte_flow_item_sctp rte_flow_item_sctp_mask = {
722         .hdr = {
723                 .src_port = RTE_BE16(0xffff),
724                 .dst_port = RTE_BE16(0xffff),
725         },
726 };
727 #endif
728
729 /**
730  * RTE_FLOW_ITEM_TYPE_VXLAN.
731  *
732  * Matches a VXLAN header (RFC 7348).
733  */
734 struct rte_flow_item_vxlan {
735         uint8_t flags; /**< Normally 0x08 (I flag). */
736         uint8_t rsvd0[3]; /**< Reserved, normally 0x000000. */
737         uint8_t vni[3]; /**< VXLAN identifier. */
738         uint8_t rsvd1; /**< Reserved, normally 0x00. */
739 };
740
741 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */
742 #ifndef __cplusplus
743 static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = {
744         .vni = "\xff\xff\xff",
745 };
746 #endif
747
748 /**
749  * RTE_FLOW_ITEM_TYPE_E_TAG.
750  *
751  * Matches a E-tag header.
752  *
753  * The corresponding standard outer EtherType (TPID) value is
754  * ETHER_TYPE_ETAG. It can be overridden by the preceding pattern item.
755  */
756 struct rte_flow_item_e_tag {
757         /**
758          * E-Tag control information (E-TCI).
759          * E-PCP (3b), E-DEI (1b), ingress E-CID base (12b).
760          */
761         rte_be16_t epcp_edei_in_ecid_b;
762         /** Reserved (2b), GRP (2b), E-CID base (12b). */
763         rte_be16_t rsvd_grp_ecid_b;
764         uint8_t in_ecid_e; /**< Ingress E-CID ext. */
765         uint8_t ecid_e; /**< E-CID ext. */
766         rte_be16_t inner_type; /**< Inner EtherType or TPID. */
767 };
768
769 /** Default mask for RTE_FLOW_ITEM_TYPE_E_TAG. */
770 #ifndef __cplusplus
771 static const struct rte_flow_item_e_tag rte_flow_item_e_tag_mask = {
772         .rsvd_grp_ecid_b = RTE_BE16(0x3fff),
773 };
774 #endif
775
776 /**
777  * RTE_FLOW_ITEM_TYPE_NVGRE.
778  *
779  * Matches a NVGRE header.
780  */
781 struct rte_flow_item_nvgre {
782         /**
783          * Checksum (1b), undefined (1b), key bit (1b), sequence number (1b),
784          * reserved 0 (9b), version (3b).
785          *
786          * c_k_s_rsvd0_ver must have value 0x2000 according to RFC 7637.
787          */
788         rte_be16_t c_k_s_rsvd0_ver;
789         rte_be16_t protocol; /**< Protocol type (0x6558). */
790         uint8_t tni[3]; /**< Virtual subnet ID. */
791         uint8_t flow_id; /**< Flow ID. */
792 };
793
794 /** Default mask for RTE_FLOW_ITEM_TYPE_NVGRE. */
795 #ifndef __cplusplus
796 static const struct rte_flow_item_nvgre rte_flow_item_nvgre_mask = {
797         .tni = "\xff\xff\xff",
798 };
799 #endif
800
801 /**
802  * RTE_FLOW_ITEM_TYPE_MPLS.
803  *
804  * Matches a MPLS header.
805  */
806 struct rte_flow_item_mpls {
807         /**
808          * Label (20b), TC (3b), Bottom of Stack (1b).
809          */
810         uint8_t label_tc_s[3];
811         uint8_t ttl; /** Time-to-Live. */
812 };
813
814 /** Default mask for RTE_FLOW_ITEM_TYPE_MPLS. */
815 #ifndef __cplusplus
816 static const struct rte_flow_item_mpls rte_flow_item_mpls_mask = {
817         .label_tc_s = "\xff\xff\xf0",
818 };
819 #endif
820
821 /**
822  * RTE_FLOW_ITEM_TYPE_GRE.
823  *
824  * Matches a GRE header.
825  */
826 struct rte_flow_item_gre {
827         /**
828          * Checksum (1b), reserved 0 (12b), version (3b).
829          * Refer to RFC 2784.
830          */
831         rte_be16_t c_rsvd0_ver;
832         rte_be16_t protocol; /**< Protocol type. */
833 };
834
835 /** Default mask for RTE_FLOW_ITEM_TYPE_GRE. */
836 #ifndef __cplusplus
837 static const struct rte_flow_item_gre rte_flow_item_gre_mask = {
838         .protocol = RTE_BE16(0xffff),
839 };
840 #endif
841
842 /**
843  * RTE_FLOW_ITEM_TYPE_FUZZY
844  *
845  * Fuzzy pattern match, expect faster than default.
846  *
847  * This is for device that support fuzzy match option.
848  * Usually a fuzzy match is fast but the cost is accuracy.
849  * i.e. Signature Match only match pattern's hash value, but it is
850  * possible two different patterns have the same hash value.
851  *
852  * Matching accuracy level can be configure by threshold.
853  * Driver can divide the range of threshold and map to different
854  * accuracy levels that device support.
855  *
856  * Threshold 0 means perfect match (no fuzziness), while threshold
857  * 0xffffffff means fuzziest match.
858  */
859 struct rte_flow_item_fuzzy {
860         uint32_t thresh; /**< Accuracy threshold. */
861 };
862
863 /** Default mask for RTE_FLOW_ITEM_TYPE_FUZZY. */
864 #ifndef __cplusplus
865 static const struct rte_flow_item_fuzzy rte_flow_item_fuzzy_mask = {
866         .thresh = 0xffffffff,
867 };
868 #endif
869
870 /**
871  * RTE_FLOW_ITEM_TYPE_GTP.
872  *
873  * Matches a GTPv1 header.
874  */
875 struct rte_flow_item_gtp {
876         /**
877          * Version (3b), protocol type (1b), reserved (1b),
878          * Extension header flag (1b),
879          * Sequence number flag (1b),
880          * N-PDU number flag (1b).
881          */
882         uint8_t v_pt_rsv_flags;
883         uint8_t msg_type; /**< Message type. */
884         rte_be16_t msg_len; /**< Message length. */
885         rte_be32_t teid; /**< Tunnel endpoint identifier. */
886 };
887
888 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP. */
889 #ifndef __cplusplus
890 static const struct rte_flow_item_gtp rte_flow_item_gtp_mask = {
891         .teid = RTE_BE32(0xffffffff),
892 };
893 #endif
894
895 /**
896  * RTE_FLOW_ITEM_TYPE_ESP
897  *
898  * Matches an ESP header.
899  */
900 struct rte_flow_item_esp {
901         struct esp_hdr hdr; /**< ESP header definition. */
902 };
903
904 /** Default mask for RTE_FLOW_ITEM_TYPE_ESP. */
905 #ifndef __cplusplus
906 static const struct rte_flow_item_esp rte_flow_item_esp_mask = {
907         .hdr = {
908                 .spi = 0xffffffff,
909         },
910 };
911 #endif
912
913 /**
914  * RTE_FLOW_ITEM_TYPE_GENEVE.
915  *
916  * Matches a GENEVE header.
917  */
918 struct rte_flow_item_geneve {
919         /**
920          * Version (2b), length of the options fields (6b), OAM packet (1b),
921          * critical options present (1b), reserved 0 (6b).
922          */
923         rte_be16_t ver_opt_len_o_c_rsvd0;
924         rte_be16_t protocol; /**< Protocol type. */
925         uint8_t vni[3]; /**< Virtual Network Identifier. */
926         uint8_t rsvd1; /**< Reserved, normally 0x00. */
927 };
928
929 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE. */
930 #ifndef __cplusplus
931 static const struct rte_flow_item_geneve rte_flow_item_geneve_mask = {
932         .vni = "\xff\xff\xff",
933 };
934 #endif
935
936 /**
937  * RTE_FLOW_ITEM_TYPE_VXLAN_GPE (draft-ietf-nvo3-vxlan-gpe-05).
938  *
939  * Matches a VXLAN-GPE header.
940  */
941 struct rte_flow_item_vxlan_gpe {
942         uint8_t flags; /**< Normally 0x0c (I and P flags). */
943         uint8_t rsvd0[2]; /**< Reserved, normally 0x0000. */
944         uint8_t protocol; /**< Protocol type. */
945         uint8_t vni[3]; /**< VXLAN identifier. */
946         uint8_t rsvd1; /**< Reserved, normally 0x00. */
947 };
948
949 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN_GPE. */
950 #ifndef __cplusplus
951 static const struct rte_flow_item_vxlan_gpe rte_flow_item_vxlan_gpe_mask = {
952         .vni = "\xff\xff\xff",
953 };
954 #endif
955
956 /**
957  * RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4
958  *
959  * Matches an ARP header for Ethernet/IPv4.
960  */
961 struct rte_flow_item_arp_eth_ipv4 {
962         rte_be16_t hrd; /**< Hardware type, normally 1. */
963         rte_be16_t pro; /**< Protocol type, normally 0x0800. */
964         uint8_t hln; /**< Hardware address length, normally 6. */
965         uint8_t pln; /**< Protocol address length, normally 4. */
966         rte_be16_t op; /**< Opcode (1 for request, 2 for reply). */
967         struct ether_addr sha; /**< Sender hardware address. */
968         rte_be32_t spa; /**< Sender IPv4 address. */
969         struct ether_addr tha; /**< Target hardware address. */
970         rte_be32_t tpa; /**< Target IPv4 address. */
971 };
972
973 /** Default mask for RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4. */
974 #ifndef __cplusplus
975 static const struct rte_flow_item_arp_eth_ipv4
976 rte_flow_item_arp_eth_ipv4_mask = {
977         .sha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
978         .spa = RTE_BE32(0xffffffff),
979         .tha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
980         .tpa = RTE_BE32(0xffffffff),
981 };
982 #endif
983
984 /**
985  * RTE_FLOW_ITEM_TYPE_IPV6_EXT
986  *
987  * Matches the presence of any IPv6 extension header.
988  *
989  * Normally preceded by any of:
990  *
991  * - RTE_FLOW_ITEM_TYPE_IPV6
992  * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
993  */
994 struct rte_flow_item_ipv6_ext {
995         uint8_t next_hdr; /**< Next header. */
996 };
997
998 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6_EXT. */
999 #ifndef __cplusplus
1000 static const
1001 struct rte_flow_item_ipv6_ext rte_flow_item_ipv6_ext_mask = {
1002         .next_hdr = 0xff,
1003 };
1004 #endif
1005
1006 /**
1007  * RTE_FLOW_ITEM_TYPE_ICMP6
1008  *
1009  * Matches any ICMPv6 header.
1010  */
1011 struct rte_flow_item_icmp6 {
1012         uint8_t type; /**< ICMPv6 type. */
1013         uint8_t code; /**< ICMPv6 code. */
1014         uint16_t checksum; /**< ICMPv6 checksum. */
1015 };
1016
1017 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6. */
1018 #ifndef __cplusplus
1019 static const struct rte_flow_item_icmp6 rte_flow_item_icmp6_mask = {
1020         .type = 0xff,
1021         .code = 0xff,
1022 };
1023 #endif
1024
1025 /**
1026  * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1027  *
1028  * Matches an ICMPv6 neighbor discovery solicitation.
1029  */
1030 struct rte_flow_item_icmp6_nd_ns {
1031         uint8_t type; /**< ICMPv6 type, normally 135. */
1032         uint8_t code; /**< ICMPv6 code, normally 0. */
1033         rte_be16_t checksum; /**< ICMPv6 checksum. */
1034         rte_be32_t reserved; /**< Reserved, normally 0. */
1035         uint8_t target_addr[16]; /**< Target address. */
1036 };
1037
1038 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS. */
1039 #ifndef __cplusplus
1040 static const
1041 struct rte_flow_item_icmp6_nd_ns rte_flow_item_icmp6_nd_ns_mask = {
1042         .target_addr =
1043                 "\xff\xff\xff\xff\xff\xff\xff\xff"
1044                 "\xff\xff\xff\xff\xff\xff\xff\xff",
1045 };
1046 #endif
1047
1048 /**
1049  * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1050  *
1051  * Matches an ICMPv6 neighbor discovery advertisement.
1052  */
1053 struct rte_flow_item_icmp6_nd_na {
1054         uint8_t type; /**< ICMPv6 type, normally 136. */
1055         uint8_t code; /**< ICMPv6 code, normally 0. */
1056         rte_be16_t checksum; /**< ICMPv6 checksum. */
1057         /**
1058          * Route flag (1b), solicited flag (1b), override flag (1b),
1059          * reserved (29b).
1060          */
1061         rte_be32_t rso_reserved;
1062         uint8_t target_addr[16]; /**< Target address. */
1063 };
1064
1065 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA. */
1066 #ifndef __cplusplus
1067 static const
1068 struct rte_flow_item_icmp6_nd_na rte_flow_item_icmp6_nd_na_mask = {
1069         .target_addr =
1070                 "\xff\xff\xff\xff\xff\xff\xff\xff"
1071                 "\xff\xff\xff\xff\xff\xff\xff\xff",
1072 };
1073 #endif
1074
1075 /**
1076  * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1077  *
1078  * Matches the presence of any ICMPv6 neighbor discovery option.
1079  *
1080  * Normally preceded by any of:
1081  *
1082  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1083  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1084  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1085  */
1086 struct rte_flow_item_icmp6_nd_opt {
1087         uint8_t type; /**< ND option type. */
1088         uint8_t length; /**< ND option length. */
1089 };
1090
1091 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT. */
1092 #ifndef __cplusplus
1093 static const struct rte_flow_item_icmp6_nd_opt
1094 rte_flow_item_icmp6_nd_opt_mask = {
1095         .type = 0xff,
1096 };
1097 #endif
1098
1099 /**
1100  * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH
1101  *
1102  * Matches an ICMPv6 neighbor discovery source Ethernet link-layer address
1103  * option.
1104  *
1105  * Normally preceded by any of:
1106  *
1107  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1108  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1109  */
1110 struct rte_flow_item_icmp6_nd_opt_sla_eth {
1111         uint8_t type; /**< ND option type, normally 1. */
1112         uint8_t length; /**< ND option length, normally 1. */
1113         struct ether_addr sla; /**< Source Ethernet LLA. */
1114 };
1115
1116 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH. */
1117 #ifndef __cplusplus
1118 static const struct rte_flow_item_icmp6_nd_opt_sla_eth
1119 rte_flow_item_icmp6_nd_opt_sla_eth_mask = {
1120         .sla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1121 };
1122 #endif
1123
1124 /**
1125  * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH
1126  *
1127  * Matches an ICMPv6 neighbor discovery target Ethernet link-layer address
1128  * option.
1129  *
1130  * Normally preceded by any of:
1131  *
1132  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1133  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1134  */
1135 struct rte_flow_item_icmp6_nd_opt_tla_eth {
1136         uint8_t type; /**< ND option type, normally 2. */
1137         uint8_t length; /**< ND option length, normally 1. */
1138         struct ether_addr tla; /**< Target Ethernet LLA. */
1139 };
1140
1141 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH. */
1142 #ifndef __cplusplus
1143 static const struct rte_flow_item_icmp6_nd_opt_tla_eth
1144 rte_flow_item_icmp6_nd_opt_tla_eth_mask = {
1145         .tla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1146 };
1147 #endif
1148
1149 /**
1150  * Matching pattern item definition.
1151  *
1152  * A pattern is formed by stacking items starting from the lowest protocol
1153  * layer to match. This stacking restriction does not apply to meta items
1154  * which can be placed anywhere in the stack without affecting the meaning
1155  * of the resulting pattern.
1156  *
1157  * Patterns are terminated by END items.
1158  *
1159  * The spec field should be a valid pointer to a structure of the related
1160  * item type. It may remain unspecified (NULL) in many cases to request
1161  * broad (nonspecific) matching. In such cases, last and mask must also be
1162  * set to NULL.
1163  *
1164  * Optionally, last can point to a structure of the same type to define an
1165  * inclusive range. This is mostly supported by integer and address fields,
1166  * may cause errors otherwise. Fields that do not support ranges must be set
1167  * to 0 or to the same value as the corresponding fields in spec.
1168  *
1169  * Only the fields defined to nonzero values in the default masks (see
1170  * rte_flow_item_{name}_mask constants) are considered relevant by
1171  * default. This can be overridden by providing a mask structure of the
1172  * same type with applicable bits set to one. It can also be used to
1173  * partially filter out specific fields (e.g. as an alternate mean to match
1174  * ranges of IP addresses).
1175  *
1176  * Mask is a simple bit-mask applied before interpreting the contents of
1177  * spec and last, which may yield unexpected results if not used
1178  * carefully. For example, if for an IPv4 address field, spec provides
1179  * 10.1.2.3, last provides 10.3.4.5 and mask provides 255.255.0.0, the
1180  * effective range becomes 10.1.0.0 to 10.3.255.255.
1181  */
1182 struct rte_flow_item {
1183         enum rte_flow_item_type type; /**< Item type. */
1184         const void *spec; /**< Pointer to item specification structure. */
1185         const void *last; /**< Defines an inclusive range (spec to last). */
1186         const void *mask; /**< Bit-mask applied to spec and last. */
1187 };
1188
1189 /**
1190  * Action types.
1191  *
1192  * Each possible action is represented by a type. Some have associated
1193  * configuration structures. Several actions combined in a list can be
1194  * assigned to a flow rule and are performed in order.
1195  *
1196  * They fall in three categories:
1197  *
1198  * - Actions that modify the fate of matching traffic, for instance by
1199  *   dropping or assigning it a specific destination.
1200  *
1201  * - Actions that modify matching traffic contents or its properties. This
1202  *   includes adding/removing encapsulation, encryption, compression and
1203  *   marks.
1204  *
1205  * - Actions related to the flow rule itself, such as updating counters or
1206  *   making it non-terminating.
1207  *
1208  * Flow rules being terminating by default, not specifying any action of the
1209  * fate kind results in undefined behavior. This applies to both ingress and
1210  * egress.
1211  *
1212  * PASSTHRU, when supported, makes a flow rule non-terminating.
1213  */
1214 enum rte_flow_action_type {
1215         /**
1216          * End marker for action lists. Prevents further processing of
1217          * actions, thereby ending the list.
1218          *
1219          * No associated configuration structure.
1220          */
1221         RTE_FLOW_ACTION_TYPE_END,
1222
1223         /**
1224          * Used as a placeholder for convenience. It is ignored and simply
1225          * discarded by PMDs.
1226          *
1227          * No associated configuration structure.
1228          */
1229         RTE_FLOW_ACTION_TYPE_VOID,
1230
1231         /**
1232          * Leaves traffic up for additional processing by subsequent flow
1233          * rules; makes a flow rule non-terminating.
1234          *
1235          * No associated configuration structure.
1236          */
1237         RTE_FLOW_ACTION_TYPE_PASSTHRU,
1238
1239         /**
1240          * Attaches an integer value to packets and sets PKT_RX_FDIR and
1241          * PKT_RX_FDIR_ID mbuf flags.
1242          *
1243          * See struct rte_flow_action_mark.
1244          */
1245         RTE_FLOW_ACTION_TYPE_MARK,
1246
1247         /**
1248          * Flags packets. Similar to MARK without a specific value; only
1249          * sets the PKT_RX_FDIR mbuf flag.
1250          *
1251          * No associated configuration structure.
1252          */
1253         RTE_FLOW_ACTION_TYPE_FLAG,
1254
1255         /**
1256          * Assigns packets to a given queue index.
1257          *
1258          * See struct rte_flow_action_queue.
1259          */
1260         RTE_FLOW_ACTION_TYPE_QUEUE,
1261
1262         /**
1263          * Drops packets.
1264          *
1265          * PASSTHRU overrides this action if both are specified.
1266          *
1267          * No associated configuration structure.
1268          */
1269         RTE_FLOW_ACTION_TYPE_DROP,
1270
1271         /**
1272          * Enables counters for this flow rule.
1273          *
1274          * These counters can be retrieved and reset through rte_flow_query(),
1275          * see struct rte_flow_query_count.
1276          *
1277          * No associated configuration structure.
1278          */
1279         RTE_FLOW_ACTION_TYPE_COUNT,
1280
1281         /**
1282          * Similar to QUEUE, except RSS is additionally performed on packets
1283          * to spread them among several queues according to the provided
1284          * parameters.
1285          *
1286          * See struct rte_flow_action_rss.
1287          */
1288         RTE_FLOW_ACTION_TYPE_RSS,
1289
1290         /**
1291          * Directs matching traffic to the physical function (PF) of the
1292          * current device.
1293          *
1294          * No associated configuration structure.
1295          */
1296         RTE_FLOW_ACTION_TYPE_PF,
1297
1298         /**
1299          * Directs matching traffic to a given virtual function of the
1300          * current device.
1301          *
1302          * See struct rte_flow_action_vf.
1303          */
1304         RTE_FLOW_ACTION_TYPE_VF,
1305
1306         /**
1307          * Directs packets to a given physical port index of the underlying
1308          * device.
1309          *
1310          * See struct rte_flow_action_phy_port.
1311          */
1312         RTE_FLOW_ACTION_TYPE_PHY_PORT,
1313
1314         /**
1315          * Directs matching traffic to a given DPDK port ID.
1316          *
1317          * See struct rte_flow_action_port_id.
1318          */
1319         RTE_FLOW_ACTION_TYPE_PORT_ID,
1320
1321         /**
1322          * Traffic metering and policing (MTR).
1323          *
1324          * See struct rte_flow_action_meter.
1325          * See file rte_mtr.h for MTR object configuration.
1326          */
1327         RTE_FLOW_ACTION_TYPE_METER,
1328
1329         /**
1330          * Redirects packets to security engine of current device for security
1331          * processing as specified by security session.
1332          *
1333          * See struct rte_flow_action_security.
1334          */
1335         RTE_FLOW_ACTION_TYPE_SECURITY,
1336
1337         /**
1338          * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the
1339          * OpenFlow Switch Specification.
1340          *
1341          * See struct rte_flow_action_of_set_mpls_ttl.
1342          */
1343         RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL,
1344
1345         /**
1346          * Implements OFPAT_DEC_MPLS_TTL ("decrement MPLS TTL") as defined
1347          * by the OpenFlow Switch Specification.
1348          *
1349          * No associated configuration structure.
1350          */
1351         RTE_FLOW_ACTION_TYPE_OF_DEC_MPLS_TTL,
1352
1353         /**
1354          * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow
1355          * Switch Specification.
1356          *
1357          * See struct rte_flow_action_of_set_nw_ttl.
1358          */
1359         RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL,
1360
1361         /**
1362          * Implements OFPAT_DEC_NW_TTL ("decrement IP TTL") as defined by
1363          * the OpenFlow Switch Specification.
1364          *
1365          * No associated configuration structure.
1366          */
1367         RTE_FLOW_ACTION_TYPE_OF_DEC_NW_TTL,
1368
1369         /**
1370          * Implements OFPAT_COPY_TTL_OUT ("copy TTL "outwards" -- from
1371          * next-to-outermost to outermost") as defined by the OpenFlow
1372          * Switch Specification.
1373          *
1374          * No associated configuration structure.
1375          */
1376         RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_OUT,
1377
1378         /**
1379          * Implements OFPAT_COPY_TTL_IN ("copy TTL "inwards" -- from
1380          * outermost to next-to-outermost") as defined by the OpenFlow
1381          * Switch Specification.
1382          *
1383          * No associated configuration structure.
1384          */
1385         RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_IN,
1386
1387         /**
1388          * Implements OFPAT_POP_VLAN ("pop the outer VLAN tag") as defined
1389          * by the OpenFlow Switch Specification.
1390          *
1391          * No associated configuration structure.
1392          */
1393         RTE_FLOW_ACTION_TYPE_OF_POP_VLAN,
1394
1395         /**
1396          * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by
1397          * the OpenFlow Switch Specification.
1398          *
1399          * See struct rte_flow_action_of_push_vlan.
1400          */
1401         RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
1402
1403         /**
1404          * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as
1405          * defined by the OpenFlow Switch Specification.
1406          *
1407          * See struct rte_flow_action_of_set_vlan_vid.
1408          */
1409         RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
1410
1411         /**
1412          * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as
1413          * defined by the OpenFlow Switch Specification.
1414          *
1415          * See struct rte_flow_action_of_set_vlan_pcp.
1416          */
1417         RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
1418
1419         /**
1420          * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined
1421          * by the OpenFlow Switch Specification.
1422          *
1423          * See struct rte_flow_action_of_pop_mpls.
1424          */
1425         RTE_FLOW_ACTION_TYPE_OF_POP_MPLS,
1426
1427         /**
1428          * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by
1429          * the OpenFlow Switch Specification.
1430          *
1431          * See struct rte_flow_action_of_push_mpls.
1432          */
1433         RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS,
1434 };
1435
1436 /**
1437  * RTE_FLOW_ACTION_TYPE_MARK
1438  *
1439  * Attaches an integer value to packets and sets PKT_RX_FDIR and
1440  * PKT_RX_FDIR_ID mbuf flags.
1441  *
1442  * This value is arbitrary and application-defined. Maximum allowed value
1443  * depends on the underlying implementation. It is returned in the
1444  * hash.fdir.hi mbuf field.
1445  */
1446 struct rte_flow_action_mark {
1447         uint32_t id; /**< Integer value to return with packets. */
1448 };
1449
1450 /**
1451  * RTE_FLOW_ACTION_TYPE_QUEUE
1452  *
1453  * Assign packets to a given queue index.
1454  */
1455 struct rte_flow_action_queue {
1456         uint16_t index; /**< Queue index to use. */
1457 };
1458
1459 /**
1460  * RTE_FLOW_ACTION_TYPE_COUNT (query)
1461  *
1462  * Query structure to retrieve and reset flow rule counters.
1463  */
1464 struct rte_flow_query_count {
1465         uint32_t reset:1; /**< Reset counters after query [in]. */
1466         uint32_t hits_set:1; /**< hits field is set [out]. */
1467         uint32_t bytes_set:1; /**< bytes field is set [out]. */
1468         uint32_t reserved:29; /**< Reserved, must be zero [in, out]. */
1469         uint64_t hits; /**< Number of hits for this rule [out]. */
1470         uint64_t bytes; /**< Number of bytes through this rule [out]. */
1471 };
1472
1473 /**
1474  * RTE_FLOW_ACTION_TYPE_RSS
1475  *
1476  * Similar to QUEUE, except RSS is additionally performed on packets to
1477  * spread them among several queues according to the provided parameters.
1478  *
1479  * Unlike global RSS settings used by other DPDK APIs, unsetting the
1480  * @p types field does not disable RSS in a flow rule. Doing so instead
1481  * requests safe unspecified "best-effort" settings from the underlying PMD,
1482  * which depending on the flow rule, may result in anything ranging from
1483  * empty (single queue) to all-inclusive RSS.
1484  *
1485  * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps
1486  * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only,
1487  * both can be requested simultaneously.
1488  */
1489 struct rte_flow_action_rss {
1490         enum rte_eth_hash_function func; /**< RSS hash function to apply. */
1491         /**
1492          * Packet encapsulation level RSS hash @p types apply to.
1493          *
1494          * - @p 0 requests the default behavior. Depending on the packet
1495          *   type, it can mean outermost, innermost, anything in between or
1496          *   even no RSS.
1497          *
1498          *   It basically stands for the innermost encapsulation level RSS
1499          *   can be performed on according to PMD and device capabilities.
1500          *
1501          * - @p 1 requests RSS to be performed on the outermost packet
1502          *   encapsulation level.
1503          *
1504          * - @p 2 and subsequent values request RSS to be performed on the
1505          *   specified inner packet encapsulation level, from outermost to
1506          *   innermost (lower to higher values).
1507          *
1508          * Values other than @p 0 are not necessarily supported.
1509          *
1510          * Requesting a specific RSS level on unrecognized traffic results
1511          * in undefined behavior. For predictable results, it is recommended
1512          * to make the flow rule pattern match packet headers up to the
1513          * requested encapsulation level so that only matching traffic goes
1514          * through.
1515          */
1516         uint32_t level;
1517         uint64_t types; /**< Specific RSS hash types (see ETH_RSS_*). */
1518         uint32_t key_len; /**< Hash key length in bytes. */
1519         uint32_t queue_num; /**< Number of entries in @p queue. */
1520         const uint8_t *key; /**< Hash key. */
1521         const uint16_t *queue; /**< Queue indices to use. */
1522 };
1523
1524 /**
1525  * RTE_FLOW_ACTION_TYPE_VF
1526  *
1527  * Directs matching traffic to a given virtual function of the current
1528  * device.
1529  *
1530  * Packets matched by a VF pattern item can be redirected to their original
1531  * VF ID instead of the specified one. This parameter may not be available
1532  * and is not guaranteed to work properly if the VF part is matched by a
1533  * prior flow rule or if packets are not addressed to a VF in the first
1534  * place.
1535  */
1536 struct rte_flow_action_vf {
1537         uint32_t original:1; /**< Use original VF ID if possible. */
1538         uint32_t reserved:31; /**< Reserved, must be zero. */
1539         uint32_t id; /**< VF ID. */
1540 };
1541
1542 /**
1543  * RTE_FLOW_ACTION_TYPE_PHY_PORT
1544  *
1545  * Directs packets to a given physical port index of the underlying
1546  * device.
1547  *
1548  * @see RTE_FLOW_ITEM_TYPE_PHY_PORT
1549  */
1550 struct rte_flow_action_phy_port {
1551         uint32_t original:1; /**< Use original port index if possible. */
1552         uint32_t reserved:31; /**< Reserved, must be zero. */
1553         uint32_t index; /**< Physical port index. */
1554 };
1555
1556 /**
1557  * RTE_FLOW_ACTION_TYPE_PORT_ID
1558  *
1559  * Directs matching traffic to a given DPDK port ID.
1560  *
1561  * @see RTE_FLOW_ITEM_TYPE_PORT_ID
1562  */
1563 struct rte_flow_action_port_id {
1564         uint32_t original:1; /**< Use original DPDK port ID if possible. */
1565         uint32_t reserved:31; /**< Reserved, must be zero. */
1566         uint32_t id; /**< DPDK port ID. */
1567 };
1568
1569 /**
1570  * RTE_FLOW_ACTION_TYPE_METER
1571  *
1572  * Traffic metering and policing (MTR).
1573  *
1574  * Packets matched by items of this type can be either dropped or passed to the
1575  * next item with their color set by the MTR object.
1576  */
1577 struct rte_flow_action_meter {
1578         uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */
1579 };
1580
1581 /**
1582  * RTE_FLOW_ACTION_TYPE_SECURITY
1583  *
1584  * Perform the security action on flows matched by the pattern items
1585  * according to the configuration of the security session.
1586  *
1587  * This action modifies the payload of matched flows. For INLINE_CRYPTO, the
1588  * security protocol headers and IV are fully provided by the application as
1589  * specified in the flow pattern. The payload of matching packets is
1590  * encrypted on egress, and decrypted and authenticated on ingress.
1591  * For INLINE_PROTOCOL, the security protocol is fully offloaded to HW,
1592  * providing full encapsulation and decapsulation of packets in security
1593  * protocols. The flow pattern specifies both the outer security header fields
1594  * and the inner packet fields. The security session specified in the action
1595  * must match the pattern parameters.
1596  *
1597  * The security session specified in the action must be created on the same
1598  * port as the flow action that is being specified.
1599  *
1600  * The ingress/egress flow attribute should match that specified in the
1601  * security session if the security session supports the definition of the
1602  * direction.
1603  *
1604  * Multiple flows can be configured to use the same security session.
1605  */
1606 struct rte_flow_action_security {
1607         void *security_session; /**< Pointer to security session structure. */
1608 };
1609
1610 /**
1611  * RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL
1612  *
1613  * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the OpenFlow
1614  * Switch Specification.
1615  */
1616 struct rte_flow_action_of_set_mpls_ttl {
1617         uint8_t mpls_ttl; /**< MPLS TTL. */
1618 };
1619
1620 /**
1621  * RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL
1622  *
1623  * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow Switch
1624  * Specification.
1625  */
1626 struct rte_flow_action_of_set_nw_ttl {
1627         uint8_t nw_ttl; /**< IP TTL. */
1628 };
1629
1630 /**
1631  * RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN
1632  *
1633  * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by the
1634  * OpenFlow Switch Specification.
1635  */
1636 struct rte_flow_action_of_push_vlan {
1637         rte_be16_t ethertype; /**< EtherType. */
1638 };
1639
1640 /**
1641  * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID
1642  *
1643  * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as defined by
1644  * the OpenFlow Switch Specification.
1645  */
1646 struct rte_flow_action_of_set_vlan_vid {
1647         rte_be16_t vlan_vid; /**< VLAN id. */
1648 };
1649
1650 /**
1651  * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP
1652  *
1653  * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as defined by
1654  * the OpenFlow Switch Specification.
1655  */
1656 struct rte_flow_action_of_set_vlan_pcp {
1657         uint8_t vlan_pcp; /**< VLAN priority. */
1658 };
1659
1660 /**
1661  * RTE_FLOW_ACTION_TYPE_OF_POP_MPLS
1662  *
1663  * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined by the
1664  * OpenFlow Switch Specification.
1665  */
1666 struct rte_flow_action_of_pop_mpls {
1667         rte_be16_t ethertype; /**< EtherType. */
1668 };
1669
1670 /**
1671  * RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS
1672  *
1673  * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by the
1674  * OpenFlow Switch Specification.
1675  */
1676 struct rte_flow_action_of_push_mpls {
1677         rte_be16_t ethertype; /**< EtherType. */
1678 };
1679
1680 /**
1681  * Definition of a single action.
1682  *
1683  * A list of actions is terminated by a END action.
1684  *
1685  * For simple actions without a configuration structure, conf remains NULL.
1686  */
1687 struct rte_flow_action {
1688         enum rte_flow_action_type type; /**< Action type. */
1689         const void *conf; /**< Pointer to action configuration structure. */
1690 };
1691
1692 /**
1693  * Opaque type returned after successfully creating a flow.
1694  *
1695  * This handle can be used to manage and query the related flow (e.g. to
1696  * destroy it or retrieve counters).
1697  */
1698 struct rte_flow;
1699
1700 /**
1701  * Verbose error types.
1702  *
1703  * Most of them provide the type of the object referenced by struct
1704  * rte_flow_error.cause.
1705  */
1706 enum rte_flow_error_type {
1707         RTE_FLOW_ERROR_TYPE_NONE, /**< No error. */
1708         RTE_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
1709         RTE_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */
1710         RTE_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */
1711         RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */
1712         RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */
1713         RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */
1714         RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */
1715         RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */
1716         RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */
1717         RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */
1718         RTE_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */
1719         RTE_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */
1720         RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */
1721         RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */
1722         RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */
1723         RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */
1724 };
1725
1726 /**
1727  * Verbose error structure definition.
1728  *
1729  * This object is normally allocated by applications and set by PMDs, the
1730  * message points to a constant string which does not need to be freed by
1731  * the application, however its pointer can be considered valid only as long
1732  * as its associated DPDK port remains configured. Closing the underlying
1733  * device or unloading the PMD invalidates it.
1734  *
1735  * Both cause and message may be NULL regardless of the error type.
1736  */
1737 struct rte_flow_error {
1738         enum rte_flow_error_type type; /**< Cause field and error types. */
1739         const void *cause; /**< Object responsible for the error. */
1740         const char *message; /**< Human-readable error message. */
1741 };
1742
1743 /**
1744  * Check whether a flow rule can be created on a given port.
1745  *
1746  * The flow rule is validated for correctness and whether it could be accepted
1747  * by the device given sufficient resources. The rule is checked against the
1748  * current device mode and queue configuration. The flow rule may also
1749  * optionally be validated against existing flow rules and device resources.
1750  * This function has no effect on the target device.
1751  *
1752  * The returned value is guaranteed to remain valid only as long as no
1753  * successful calls to rte_flow_create() or rte_flow_destroy() are made in
1754  * the meantime and no device parameter affecting flow rules in any way are
1755  * modified, due to possible collisions or resource limitations (although in
1756  * such cases EINVAL should not be returned).
1757  *
1758  * @param port_id
1759  *   Port identifier of Ethernet device.
1760  * @param[in] attr
1761  *   Flow rule attributes.
1762  * @param[in] pattern
1763  *   Pattern specification (list terminated by the END pattern item).
1764  * @param[in] actions
1765  *   Associated actions (list terminated by the END action).
1766  * @param[out] error
1767  *   Perform verbose error reporting if not NULL. PMDs initialize this
1768  *   structure in case of error only.
1769  *
1770  * @return
1771  *   0 if flow rule is valid and can be created. A negative errno value
1772  *   otherwise (rte_errno is also set), the following errors are defined:
1773  *
1774  *   -ENOSYS: underlying device does not support this functionality.
1775  *
1776  *   -EIO: underlying device is removed.
1777  *
1778  *   -EINVAL: unknown or invalid rule specification.
1779  *
1780  *   -ENOTSUP: valid but unsupported rule specification (e.g. partial
1781  *   bit-masks are unsupported).
1782  *
1783  *   -EEXIST: collision with an existing rule. Only returned if device
1784  *   supports flow rule collision checking and there was a flow rule
1785  *   collision. Not receiving this return code is no guarantee that creating
1786  *   the rule will not fail due to a collision.
1787  *
1788  *   -ENOMEM: not enough memory to execute the function, or if the device
1789  *   supports resource validation, resource limitation on the device.
1790  *
1791  *   -EBUSY: action cannot be performed due to busy device resources, may
1792  *   succeed if the affected queues or even the entire port are in a stopped
1793  *   state (see rte_eth_dev_rx_queue_stop() and rte_eth_dev_stop()).
1794  */
1795 int
1796 rte_flow_validate(uint16_t port_id,
1797                   const struct rte_flow_attr *attr,
1798                   const struct rte_flow_item pattern[],
1799                   const struct rte_flow_action actions[],
1800                   struct rte_flow_error *error);
1801
1802 /**
1803  * Create a flow rule on a given port.
1804  *
1805  * @param port_id
1806  *   Port identifier of Ethernet device.
1807  * @param[in] attr
1808  *   Flow rule attributes.
1809  * @param[in] pattern
1810  *   Pattern specification (list terminated by the END pattern item).
1811  * @param[in] actions
1812  *   Associated actions (list terminated by the END action).
1813  * @param[out] error
1814  *   Perform verbose error reporting if not NULL. PMDs initialize this
1815  *   structure in case of error only.
1816  *
1817  * @return
1818  *   A valid handle in case of success, NULL otherwise and rte_errno is set
1819  *   to the positive version of one of the error codes defined for
1820  *   rte_flow_validate().
1821  */
1822 struct rte_flow *
1823 rte_flow_create(uint16_t port_id,
1824                 const struct rte_flow_attr *attr,
1825                 const struct rte_flow_item pattern[],
1826                 const struct rte_flow_action actions[],
1827                 struct rte_flow_error *error);
1828
1829 /**
1830  * Destroy a flow rule on a given port.
1831  *
1832  * Failure to destroy a flow rule handle may occur when other flow rules
1833  * depend on it, and destroying it would result in an inconsistent state.
1834  *
1835  * This function is only guaranteed to succeed if handles are destroyed in
1836  * reverse order of their creation.
1837  *
1838  * @param port_id
1839  *   Port identifier of Ethernet device.
1840  * @param flow
1841  *   Flow rule handle to destroy.
1842  * @param[out] error
1843  *   Perform verbose error reporting if not NULL. PMDs initialize this
1844  *   structure in case of error only.
1845  *
1846  * @return
1847  *   0 on success, a negative errno value otherwise and rte_errno is set.
1848  */
1849 int
1850 rte_flow_destroy(uint16_t port_id,
1851                  struct rte_flow *flow,
1852                  struct rte_flow_error *error);
1853
1854 /**
1855  * Destroy all flow rules associated with a port.
1856  *
1857  * In the unlikely event of failure, handles are still considered destroyed
1858  * and no longer valid but the port must be assumed to be in an inconsistent
1859  * state.
1860  *
1861  * @param port_id
1862  *   Port identifier of Ethernet device.
1863  * @param[out] error
1864  *   Perform verbose error reporting if not NULL. PMDs initialize this
1865  *   structure in case of error only.
1866  *
1867  * @return
1868  *   0 on success, a negative errno value otherwise and rte_errno is set.
1869  */
1870 int
1871 rte_flow_flush(uint16_t port_id,
1872                struct rte_flow_error *error);
1873
1874 /**
1875  * Query an existing flow rule.
1876  *
1877  * This function allows retrieving flow-specific data such as counters.
1878  * Data is gathered by special actions which must be present in the flow
1879  * rule definition.
1880  *
1881  * \see RTE_FLOW_ACTION_TYPE_COUNT
1882  *
1883  * @param port_id
1884  *   Port identifier of Ethernet device.
1885  * @param flow
1886  *   Flow rule handle to query.
1887  * @param action
1888  *   Action type to query.
1889  * @param[in, out] data
1890  *   Pointer to storage for the associated query data type.
1891  * @param[out] error
1892  *   Perform verbose error reporting if not NULL. PMDs initialize this
1893  *   structure in case of error only.
1894  *
1895  * @return
1896  *   0 on success, a negative errno value otherwise and rte_errno is set.
1897  */
1898 int
1899 rte_flow_query(uint16_t port_id,
1900                struct rte_flow *flow,
1901                enum rte_flow_action_type action,
1902                void *data,
1903                struct rte_flow_error *error);
1904
1905 /**
1906  * Restrict ingress traffic to the defined flow rules.
1907  *
1908  * Isolated mode guarantees that all ingress traffic comes from defined flow
1909  * rules only (current and future).
1910  *
1911  * Besides making ingress more deterministic, it allows PMDs to safely reuse
1912  * resources otherwise assigned to handle the remaining traffic, such as
1913  * global RSS configuration settings, VLAN filters, MAC address entries,
1914  * legacy filter API rules and so on in order to expand the set of possible
1915  * flow rule types.
1916  *
1917  * Calling this function as soon as possible after device initialization,
1918  * ideally before the first call to rte_eth_dev_configure(), is recommended
1919  * to avoid possible failures due to conflicting settings.
1920  *
1921  * Once effective, leaving isolated mode may not be possible depending on
1922  * PMD implementation.
1923  *
1924  * Additionally, the following functionality has no effect on the underlying
1925  * port and may return errors such as ENOTSUP ("not supported"):
1926  *
1927  * - Toggling promiscuous mode.
1928  * - Toggling allmulticast mode.
1929  * - Configuring MAC addresses.
1930  * - Configuring multicast addresses.
1931  * - Configuring VLAN filters.
1932  * - Configuring Rx filters through the legacy API (e.g. FDIR).
1933  * - Configuring global RSS settings.
1934  *
1935  * @param port_id
1936  *   Port identifier of Ethernet device.
1937  * @param set
1938  *   Nonzero to enter isolated mode, attempt to leave it otherwise.
1939  * @param[out] error
1940  *   Perform verbose error reporting if not NULL. PMDs initialize this
1941  *   structure in case of error only.
1942  *
1943  * @return
1944  *   0 on success, a negative errno value otherwise and rte_errno is set.
1945  */
1946 int
1947 rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error);
1948
1949 /**
1950  * Initialize flow error structure.
1951  *
1952  * @param[out] error
1953  *   Pointer to flow error structure (may be NULL).
1954  * @param code
1955  *   Related error code (rte_errno).
1956  * @param type
1957  *   Cause field and error types.
1958  * @param cause
1959  *   Object responsible for the error.
1960  * @param message
1961  *   Human-readable error message.
1962  *
1963  * @return
1964  *   Negative error code (errno value) and rte_errno is set.
1965  */
1966 int
1967 rte_flow_error_set(struct rte_flow_error *error,
1968                    int code,
1969                    enum rte_flow_error_type type,
1970                    const void *cause,
1971                    const char *message);
1972
1973 /**
1974  * Generic flow representation.
1975  *
1976  * This form is sufficient to describe an rte_flow independently from any
1977  * PMD implementation and allows for replayability and identification.
1978  */
1979 struct rte_flow_desc {
1980         size_t size; /**< Allocated space including data[]. */
1981         struct rte_flow_attr attr; /**< Attributes. */
1982         struct rte_flow_item *items; /**< Items. */
1983         struct rte_flow_action *actions; /**< Actions. */
1984         uint8_t data[]; /**< Storage for items/actions. */
1985 };
1986
1987 /**
1988  * Copy an rte_flow rule description.
1989  *
1990  * @param[in] fd
1991  *   Flow rule description.
1992  * @param[in] len
1993  *   Total size of allocated data for the flow description.
1994  * @param[in] attr
1995  *   Flow rule attributes.
1996  * @param[in] items
1997  *   Pattern specification (list terminated by the END pattern item).
1998  * @param[in] actions
1999  *   Associated actions (list terminated by the END action).
2000  *
2001  * @return
2002  *   If len is greater or equal to the size of the flow, the total size of the
2003  *   flow description and its data.
2004  *   If len is lower than the size of the flow, the number of bytes that would
2005  *   have been written to desc had it been sufficient. Nothing is written.
2006  */
2007 size_t
2008 rte_flow_copy(struct rte_flow_desc *fd, size_t len,
2009               const struct rte_flow_attr *attr,
2010               const struct rte_flow_item *items,
2011               const struct rte_flow_action *actions);
2012
2013 #ifdef __cplusplus
2014 }
2015 #endif
2016
2017 #endif /* RTE_FLOW_H_ */