062e3ac56c10df371a74a73f479e8352092ef103
[dpdk.git] / lib / librte_ether / rte_flow.h
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright 2016 6WIND S.A.
5  *   Copyright 2016 Mellanox.
6  *
7  *   Redistribution and use in source and binary forms, with or without
8  *   modification, are permitted provided that the following conditions
9  *   are met:
10  *
11  *     * Redistributions of source code must retain the above copyright
12  *       notice, this list of conditions and the following disclaimer.
13  *     * Redistributions in binary form must reproduce the above copyright
14  *       notice, this list of conditions and the following disclaimer in
15  *       the documentation and/or other materials provided with the
16  *       distribution.
17  *     * Neither the name of 6WIND S.A. nor the names of its
18  *       contributors may be used to endorse or promote products derived
19  *       from this software without specific prior written permission.
20  *
21  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33
34 #ifndef RTE_FLOW_H_
35 #define RTE_FLOW_H_
36
37 /**
38  * @file
39  * RTE generic flow API
40  *
41  * This interface provides the ability to program packet matching and
42  * associated actions in hardware through flow rules.
43  */
44
45 #include <rte_arp.h>
46 #include <rte_ether.h>
47 #include <rte_icmp.h>
48 #include <rte_ip.h>
49 #include <rte_sctp.h>
50 #include <rte_tcp.h>
51 #include <rte_udp.h>
52 #include <rte_byteorder.h>
53
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57
58 /**
59  * Flow rule attributes.
60  *
61  * Priorities are set on two levels: per group and per rule within groups.
62  *
63  * Lower values denote higher priority, the highest priority for both levels
64  * is 0, so that a rule with priority 0 in group 8 is always matched after a
65  * rule with priority 8 in group 0.
66  *
67  * Although optional, applications are encouraged to group similar rules as
68  * much as possible to fully take advantage of hardware capabilities
69  * (e.g. optimized matching) and work around limitations (e.g. a single
70  * pattern type possibly allowed in a given group).
71  *
72  * Group and priority levels are arbitrary and up to the application, they
73  * do not need to be contiguous nor start from 0, however the maximum number
74  * varies between devices and may be affected by existing flow rules.
75  *
76  * If a packet is matched by several rules of a given group for a given
77  * priority level, the outcome is undefined. It can take any path, may be
78  * duplicated or even cause unrecoverable errors.
79  *
80  * Note that support for more than a single group and priority level is not
81  * guaranteed.
82  *
83  * Flow rules can apply to inbound and/or outbound traffic (ingress/egress).
84  *
85  * Several pattern items and actions are valid and can be used in both
86  * directions. Those valid for only one direction are described as such.
87  *
88  * At least one direction must be specified.
89  *
90  * Specifying both directions at once for a given rule is not recommended
91  * but may be valid in a few cases (e.g. shared counter).
92  */
93 struct rte_flow_attr {
94         uint32_t group; /**< Priority group. */
95         uint32_t priority; /**< Priority level within group. */
96         uint32_t ingress:1; /**< Rule applies to ingress traffic. */
97         uint32_t egress:1; /**< Rule applies to egress traffic. */
98         uint32_t reserved:30; /**< Reserved, must be zero. */
99 };
100
101 /**
102  * Matching pattern item types.
103  *
104  * Pattern items fall in two categories:
105  *
106  * - Matching protocol headers and packet data (ANY, RAW, ETH, VLAN, IPV4,
107  *   IPV6, ICMP, UDP, TCP, SCTP, VXLAN and so on), usually associated with a
108  *   specification structure. These must be stacked in the same order as the
109  *   protocol layers to match, starting from the lowest.
110  *
111  * - Matching meta-data or affecting pattern processing (END, VOID, INVERT,
112  *   PF, VF, PORT and so on), often without a specification structure. Since
113  *   they do not match packet contents, these can be specified anywhere
114  *   within item lists without affecting others.
115  *
116  * See the description of individual types for more information. Those
117  * marked with [META] fall into the second category.
118  */
119 enum rte_flow_item_type {
120         /**
121          * [META]
122          *
123          * End marker for item lists. Prevents further processing of items,
124          * thereby ending the pattern.
125          *
126          * No associated specification structure.
127          */
128         RTE_FLOW_ITEM_TYPE_END,
129
130         /**
131          * [META]
132          *
133          * Used as a placeholder for convenience. It is ignored and simply
134          * discarded by PMDs.
135          *
136          * No associated specification structure.
137          */
138         RTE_FLOW_ITEM_TYPE_VOID,
139
140         /**
141          * [META]
142          *
143          * Inverted matching, i.e. process packets that do not match the
144          * pattern.
145          *
146          * No associated specification structure.
147          */
148         RTE_FLOW_ITEM_TYPE_INVERT,
149
150         /**
151          * Matches any protocol in place of the current layer, a single ANY
152          * may also stand for several protocol layers.
153          *
154          * See struct rte_flow_item_any.
155          */
156         RTE_FLOW_ITEM_TYPE_ANY,
157
158         /**
159          * [META]
160          *
161          * Matches packets addressed to the physical function of the device.
162          *
163          * If the underlying device function differs from the one that would
164          * normally receive the matched traffic, specifying this item
165          * prevents it from reaching that device unless the flow rule
166          * contains a PF action. Packets are not duplicated between device
167          * instances by default.
168          *
169          * No associated specification structure.
170          */
171         RTE_FLOW_ITEM_TYPE_PF,
172
173         /**
174          * [META]
175          *
176          * Matches packets addressed to a virtual function ID of the device.
177          *
178          * If the underlying device function differs from the one that would
179          * normally receive the matched traffic, specifying this item
180          * prevents it from reaching that device unless the flow rule
181          * contains a VF action. Packets are not duplicated between device
182          * instances by default.
183          *
184          * See struct rte_flow_item_vf.
185          */
186         RTE_FLOW_ITEM_TYPE_VF,
187
188         /**
189          * [META]
190          *
191          * Matches packets coming from the specified physical port of the
192          * underlying device.
193          *
194          * The first PORT item overrides the physical port normally
195          * associated with the specified DPDK input port (port_id). This
196          * item can be provided several times to match additional physical
197          * ports.
198          *
199          * See struct rte_flow_item_port.
200          */
201         RTE_FLOW_ITEM_TYPE_PORT,
202
203         /**
204          * Matches a byte string of a given length at a given offset.
205          *
206          * See struct rte_flow_item_raw.
207          */
208         RTE_FLOW_ITEM_TYPE_RAW,
209
210         /**
211          * Matches an Ethernet header.
212          *
213          * See struct rte_flow_item_eth.
214          */
215         RTE_FLOW_ITEM_TYPE_ETH,
216
217         /**
218          * Matches an 802.1Q/ad VLAN tag.
219          *
220          * See struct rte_flow_item_vlan.
221          */
222         RTE_FLOW_ITEM_TYPE_VLAN,
223
224         /**
225          * Matches an IPv4 header.
226          *
227          * See struct rte_flow_item_ipv4.
228          */
229         RTE_FLOW_ITEM_TYPE_IPV4,
230
231         /**
232          * Matches an IPv6 header.
233          *
234          * See struct rte_flow_item_ipv6.
235          */
236         RTE_FLOW_ITEM_TYPE_IPV6,
237
238         /**
239          * Matches an ICMP header.
240          *
241          * See struct rte_flow_item_icmp.
242          */
243         RTE_FLOW_ITEM_TYPE_ICMP,
244
245         /**
246          * Matches a UDP header.
247          *
248          * See struct rte_flow_item_udp.
249          */
250         RTE_FLOW_ITEM_TYPE_UDP,
251
252         /**
253          * Matches a TCP header.
254          *
255          * See struct rte_flow_item_tcp.
256          */
257         RTE_FLOW_ITEM_TYPE_TCP,
258
259         /**
260          * Matches a SCTP header.
261          *
262          * See struct rte_flow_item_sctp.
263          */
264         RTE_FLOW_ITEM_TYPE_SCTP,
265
266         /**
267          * Matches a VXLAN header.
268          *
269          * See struct rte_flow_item_vxlan.
270          */
271         RTE_FLOW_ITEM_TYPE_VXLAN,
272
273         /**
274          * Matches a E_TAG header.
275          *
276          * See struct rte_flow_item_e_tag.
277          */
278         RTE_FLOW_ITEM_TYPE_E_TAG,
279
280         /**
281          * Matches a NVGRE header.
282          *
283          * See struct rte_flow_item_nvgre.
284          */
285         RTE_FLOW_ITEM_TYPE_NVGRE,
286
287         /**
288          * Matches a MPLS header.
289          *
290          * See struct rte_flow_item_mpls.
291          */
292         RTE_FLOW_ITEM_TYPE_MPLS,
293
294         /**
295          * Matches a GRE header.
296          *
297          * See struct rte_flow_item_gre.
298          */
299         RTE_FLOW_ITEM_TYPE_GRE,
300
301         /**
302          * [META]
303          *
304          * Fuzzy pattern match, expect faster than default.
305          *
306          * This is for device that support fuzzy matching option.
307          * Usually a fuzzy matching is fast but the cost is accuracy.
308          *
309          * See struct rte_flow_item_fuzzy.
310          */
311         RTE_FLOW_ITEM_TYPE_FUZZY,
312
313         /**
314          * Matches a GTP header.
315          *
316          * Configure flow for GTP packets.
317          *
318          * See struct rte_flow_item_gtp.
319          */
320         RTE_FLOW_ITEM_TYPE_GTP,
321
322         /**
323          * Matches a GTP header.
324          *
325          * Configure flow for GTP-C packets.
326          *
327          * See struct rte_flow_item_gtp.
328          */
329         RTE_FLOW_ITEM_TYPE_GTPC,
330
331         /**
332          * Matches a GTP header.
333          *
334          * Configure flow for GTP-U packets.
335          *
336          * See struct rte_flow_item_gtp.
337          */
338         RTE_FLOW_ITEM_TYPE_GTPU,
339 };
340
341 /**
342  * RTE_FLOW_ITEM_TYPE_ANY
343  *
344  * Matches any protocol in place of the current layer, a single ANY may also
345  * stand for several protocol layers.
346  *
347  * This is usually specified as the first pattern item when looking for a
348  * protocol anywhere in a packet.
349  *
350  * A zeroed mask stands for any number of layers.
351  */
352 struct rte_flow_item_any {
353         uint32_t num; /**< Number of layers covered. */
354 };
355
356 /** Default mask for RTE_FLOW_ITEM_TYPE_ANY. */
357 #ifndef __cplusplus
358 static const struct rte_flow_item_any rte_flow_item_any_mask = {
359         .num = 0x00000000,
360 };
361 #endif
362
363 /**
364  * RTE_FLOW_ITEM_TYPE_VF
365  *
366  * Matches packets addressed to a virtual function ID of the device.
367  *
368  * If the underlying device function differs from the one that would
369  * normally receive the matched traffic, specifying this item prevents it
370  * from reaching that device unless the flow rule contains a VF
371  * action. Packets are not duplicated between device instances by default.
372  *
373  * - Likely to return an error or never match any traffic if this causes a
374  *   VF device to match traffic addressed to a different VF.
375  * - Can be specified multiple times to match traffic addressed to several
376  *   VF IDs.
377  * - Can be combined with a PF item to match both PF and VF traffic.
378  *
379  * A zeroed mask can be used to match any VF ID.
380  */
381 struct rte_flow_item_vf {
382         uint32_t id; /**< Destination VF ID. */
383 };
384
385 /** Default mask for RTE_FLOW_ITEM_TYPE_VF. */
386 #ifndef __cplusplus
387 static const struct rte_flow_item_vf rte_flow_item_vf_mask = {
388         .id = 0x00000000,
389 };
390 #endif
391
392 /**
393  * RTE_FLOW_ITEM_TYPE_PORT
394  *
395  * Matches packets coming from the specified physical port of the underlying
396  * device.
397  *
398  * The first PORT item overrides the physical port normally associated with
399  * the specified DPDK input port (port_id). This item can be provided
400  * several times to match additional physical ports.
401  *
402  * Note that physical ports are not necessarily tied to DPDK input ports
403  * (port_id) when those are not under DPDK control. Possible values are
404  * specific to each device, they are not necessarily indexed from zero and
405  * may not be contiguous.
406  *
407  * As a device property, the list of allowed values as well as the value
408  * associated with a port_id should be retrieved by other means.
409  *
410  * A zeroed mask can be used to match any port index.
411  */
412 struct rte_flow_item_port {
413         uint32_t index; /**< Physical port index. */
414 };
415
416 /** Default mask for RTE_FLOW_ITEM_TYPE_PORT. */
417 #ifndef __cplusplus
418 static const struct rte_flow_item_port rte_flow_item_port_mask = {
419         .index = 0x00000000,
420 };
421 #endif
422
423 /**
424  * RTE_FLOW_ITEM_TYPE_RAW
425  *
426  * Matches a byte string of a given length at a given offset.
427  *
428  * Offset is either absolute (using the start of the packet) or relative to
429  * the end of the previous matched item in the stack, in which case negative
430  * values are allowed.
431  *
432  * If search is enabled, offset is used as the starting point. The search
433  * area can be delimited by setting limit to a nonzero value, which is the
434  * maximum number of bytes after offset where the pattern may start.
435  *
436  * Matching a zero-length pattern is allowed, doing so resets the relative
437  * offset for subsequent items.
438  *
439  * This type does not support ranges (struct rte_flow_item.last).
440  */
441 struct rte_flow_item_raw {
442         uint32_t relative:1; /**< Look for pattern after the previous item. */
443         uint32_t search:1; /**< Search pattern from offset (see also limit). */
444         uint32_t reserved:30; /**< Reserved, must be set to zero. */
445         int32_t offset; /**< Absolute or relative offset for pattern. */
446         uint16_t limit; /**< Search area limit for start of pattern. */
447         uint16_t length; /**< Pattern length. */
448         uint8_t pattern[]; /**< Byte string to look for. */
449 };
450
451 /** Default mask for RTE_FLOW_ITEM_TYPE_RAW. */
452 #ifndef __cplusplus
453 static const struct rte_flow_item_raw rte_flow_item_raw_mask = {
454         .relative = 1,
455         .search = 1,
456         .reserved = 0x3fffffff,
457         .offset = 0xffffffff,
458         .limit = 0xffff,
459         .length = 0xffff,
460 };
461 #endif
462
463 /**
464  * RTE_FLOW_ITEM_TYPE_ETH
465  *
466  * Matches an Ethernet header.
467  */
468 struct rte_flow_item_eth {
469         struct ether_addr dst; /**< Destination MAC. */
470         struct ether_addr src; /**< Source MAC. */
471         rte_be16_t type; /**< EtherType. */
472 };
473
474 /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */
475 #ifndef __cplusplus
476 static const struct rte_flow_item_eth rte_flow_item_eth_mask = {
477         .dst.addr_bytes = "\xff\xff\xff\xff\xff\xff",
478         .src.addr_bytes = "\xff\xff\xff\xff\xff\xff",
479         .type = RTE_BE16(0x0000),
480 };
481 #endif
482
483 /**
484  * RTE_FLOW_ITEM_TYPE_VLAN
485  *
486  * Matches an 802.1Q/ad VLAN tag.
487  *
488  * This type normally follows either RTE_FLOW_ITEM_TYPE_ETH or
489  * RTE_FLOW_ITEM_TYPE_VLAN.
490  */
491 struct rte_flow_item_vlan {
492         rte_be16_t tpid; /**< Tag protocol identifier. */
493         rte_be16_t tci; /**< Tag control information. */
494 };
495
496 /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */
497 #ifndef __cplusplus
498 static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = {
499         .tpid = RTE_BE16(0x0000),
500         .tci = RTE_BE16(0xffff),
501 };
502 #endif
503
504 /**
505  * RTE_FLOW_ITEM_TYPE_IPV4
506  *
507  * Matches an IPv4 header.
508  *
509  * Note: IPv4 options are handled by dedicated pattern items.
510  */
511 struct rte_flow_item_ipv4 {
512         struct ipv4_hdr hdr; /**< IPv4 header definition. */
513 };
514
515 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV4. */
516 #ifndef __cplusplus
517 static const struct rte_flow_item_ipv4 rte_flow_item_ipv4_mask = {
518         .hdr = {
519                 .src_addr = RTE_BE32(0xffffffff),
520                 .dst_addr = RTE_BE32(0xffffffff),
521         },
522 };
523 #endif
524
525 /**
526  * RTE_FLOW_ITEM_TYPE_IPV6.
527  *
528  * Matches an IPv6 header.
529  *
530  * Note: IPv6 options are handled by dedicated pattern items.
531  */
532 struct rte_flow_item_ipv6 {
533         struct ipv6_hdr hdr; /**< IPv6 header definition. */
534 };
535
536 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
537 #ifndef __cplusplus
538 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
539         .hdr = {
540                 .src_addr =
541                         "\xff\xff\xff\xff\xff\xff\xff\xff"
542                         "\xff\xff\xff\xff\xff\xff\xff\xff",
543                 .dst_addr =
544                         "\xff\xff\xff\xff\xff\xff\xff\xff"
545                         "\xff\xff\xff\xff\xff\xff\xff\xff",
546         },
547 };
548 #endif
549
550 /**
551  * RTE_FLOW_ITEM_TYPE_ICMP.
552  *
553  * Matches an ICMP header.
554  */
555 struct rte_flow_item_icmp {
556         struct icmp_hdr hdr; /**< ICMP header definition. */
557 };
558
559 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP. */
560 #ifndef __cplusplus
561 static const struct rte_flow_item_icmp rte_flow_item_icmp_mask = {
562         .hdr = {
563                 .icmp_type = 0xff,
564                 .icmp_code = 0xff,
565         },
566 };
567 #endif
568
569 /**
570  * RTE_FLOW_ITEM_TYPE_UDP.
571  *
572  * Matches a UDP header.
573  */
574 struct rte_flow_item_udp {
575         struct udp_hdr hdr; /**< UDP header definition. */
576 };
577
578 /** Default mask for RTE_FLOW_ITEM_TYPE_UDP. */
579 #ifndef __cplusplus
580 static const struct rte_flow_item_udp rte_flow_item_udp_mask = {
581         .hdr = {
582                 .src_port = RTE_BE16(0xffff),
583                 .dst_port = RTE_BE16(0xffff),
584         },
585 };
586 #endif
587
588 /**
589  * RTE_FLOW_ITEM_TYPE_TCP.
590  *
591  * Matches a TCP header.
592  */
593 struct rte_flow_item_tcp {
594         struct tcp_hdr hdr; /**< TCP header definition. */
595 };
596
597 /** Default mask for RTE_FLOW_ITEM_TYPE_TCP. */
598 #ifndef __cplusplus
599 static const struct rte_flow_item_tcp rte_flow_item_tcp_mask = {
600         .hdr = {
601                 .src_port = RTE_BE16(0xffff),
602                 .dst_port = RTE_BE16(0xffff),
603         },
604 };
605 #endif
606
607 /**
608  * RTE_FLOW_ITEM_TYPE_SCTP.
609  *
610  * Matches a SCTP header.
611  */
612 struct rte_flow_item_sctp {
613         struct sctp_hdr hdr; /**< SCTP header definition. */
614 };
615
616 /** Default mask for RTE_FLOW_ITEM_TYPE_SCTP. */
617 #ifndef __cplusplus
618 static const struct rte_flow_item_sctp rte_flow_item_sctp_mask = {
619         .hdr = {
620                 .src_port = RTE_BE16(0xffff),
621                 .dst_port = RTE_BE16(0xffff),
622         },
623 };
624 #endif
625
626 /**
627  * RTE_FLOW_ITEM_TYPE_VXLAN.
628  *
629  * Matches a VXLAN header (RFC 7348).
630  */
631 struct rte_flow_item_vxlan {
632         uint8_t flags; /**< Normally 0x08 (I flag). */
633         uint8_t rsvd0[3]; /**< Reserved, normally 0x000000. */
634         uint8_t vni[3]; /**< VXLAN identifier. */
635         uint8_t rsvd1; /**< Reserved, normally 0x00. */
636 };
637
638 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */
639 #ifndef __cplusplus
640 static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = {
641         .vni = "\xff\xff\xff",
642 };
643 #endif
644
645 /**
646  * RTE_FLOW_ITEM_TYPE_E_TAG.
647  *
648  * Matches a E-tag header.
649  */
650 struct rte_flow_item_e_tag {
651         rte_be16_t tpid; /**< Tag protocol identifier (0x893F). */
652         /**
653          * E-Tag control information (E-TCI).
654          * E-PCP (3b), E-DEI (1b), ingress E-CID base (12b).
655          */
656         rte_be16_t epcp_edei_in_ecid_b;
657         /** Reserved (2b), GRP (2b), E-CID base (12b). */
658         rte_be16_t rsvd_grp_ecid_b;
659         uint8_t in_ecid_e; /**< Ingress E-CID ext. */
660         uint8_t ecid_e; /**< E-CID ext. */
661 };
662
663 /** Default mask for RTE_FLOW_ITEM_TYPE_E_TAG. */
664 #ifndef __cplusplus
665 static const struct rte_flow_item_e_tag rte_flow_item_e_tag_mask = {
666         .rsvd_grp_ecid_b = RTE_BE16(0x3fff),
667 };
668 #endif
669
670 /**
671  * RTE_FLOW_ITEM_TYPE_NVGRE.
672  *
673  * Matches a NVGRE header.
674  */
675 struct rte_flow_item_nvgre {
676         /**
677          * Checksum (1b), undefined (1b), key bit (1b), sequence number (1b),
678          * reserved 0 (9b), version (3b).
679          *
680          * c_k_s_rsvd0_ver must have value 0x2000 according to RFC 7637.
681          */
682         rte_be16_t c_k_s_rsvd0_ver;
683         rte_be16_t protocol; /**< Protocol type (0x6558). */
684         uint8_t tni[3]; /**< Virtual subnet ID. */
685         uint8_t flow_id; /**< Flow ID. */
686 };
687
688 /** Default mask for RTE_FLOW_ITEM_TYPE_NVGRE. */
689 #ifndef __cplusplus
690 static const struct rte_flow_item_nvgre rte_flow_item_nvgre_mask = {
691         .tni = "\xff\xff\xff",
692 };
693 #endif
694
695 /**
696  * RTE_FLOW_ITEM_TYPE_MPLS.
697  *
698  * Matches a MPLS header.
699  */
700 struct rte_flow_item_mpls {
701         /**
702          * Label (20b), TC (3b), Bottom of Stack (1b).
703          */
704         uint8_t label_tc_s[3];
705         uint8_t ttl; /** Time-to-Live. */
706 };
707
708 /** Default mask for RTE_FLOW_ITEM_TYPE_MPLS. */
709 #ifndef __cplusplus
710 static const struct rte_flow_item_mpls rte_flow_item_mpls_mask = {
711         .label_tc_s = "\xff\xff\xf0",
712 };
713 #endif
714
715 /**
716  * RTE_FLOW_ITEM_TYPE_GRE.
717  *
718  * Matches a GRE header.
719  */
720 struct rte_flow_item_gre {
721         /**
722          * Checksum (1b), reserved 0 (12b), version (3b).
723          * Refer to RFC 2784.
724          */
725         rte_be16_t c_rsvd0_ver;
726         rte_be16_t protocol; /**< Protocol type. */
727 };
728
729 /** Default mask for RTE_FLOW_ITEM_TYPE_GRE. */
730 #ifndef __cplusplus
731 static const struct rte_flow_item_gre rte_flow_item_gre_mask = {
732         .protocol = RTE_BE16(0xffff),
733 };
734 #endif
735
736 /**
737  * RTE_FLOW_ITEM_TYPE_FUZZY
738  *
739  * Fuzzy pattern match, expect faster than default.
740  *
741  * This is for device that support fuzzy match option.
742  * Usually a fuzzy match is fast but the cost is accuracy.
743  * i.e. Signature Match only match pattern's hash value, but it is
744  * possible two different patterns have the same hash value.
745  *
746  * Matching accuracy level can be configure by threshold.
747  * Driver can divide the range of threshold and map to different
748  * accuracy levels that device support.
749  *
750  * Threshold 0 means perfect match (no fuzziness), while threshold
751  * 0xffffffff means fuzziest match.
752  */
753 struct rte_flow_item_fuzzy {
754         uint32_t thresh; /**< Accuracy threshold. */
755 };
756
757 /** Default mask for RTE_FLOW_ITEM_TYPE_FUZZY. */
758 #ifndef __cplusplus
759 static const struct rte_flow_item_fuzzy rte_flow_item_fuzzy_mask = {
760         .thresh = 0xffffffff,
761 };
762 #endif
763
764 /**
765  * RTE_FLOW_ITEM_TYPE_GTP.
766  *
767  * Matches a GTPv1 header.
768  */
769 struct rte_flow_item_gtp {
770         /**
771          * Version (3b), protocol type (1b), reserved (1b),
772          * Extension header flag (1b),
773          * Sequence number flag (1b),
774          * N-PDU number flag (1b).
775          */
776         uint8_t v_pt_rsv_flags;
777         uint8_t msg_type; /**< Message type. */
778         rte_be16_t msg_len; /**< Message length. */
779         rte_be32_t teid; /**< Tunnel endpoint identifier. */
780 };
781
782 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP. */
783 #ifndef __cplusplus
784 static const struct rte_flow_item_gtp rte_flow_item_gtp_mask = {
785         .teid = RTE_BE32(0xffffffff),
786 };
787 #endif
788
789 /**
790  * Matching pattern item definition.
791  *
792  * A pattern is formed by stacking items starting from the lowest protocol
793  * layer to match. This stacking restriction does not apply to meta items
794  * which can be placed anywhere in the stack without affecting the meaning
795  * of the resulting pattern.
796  *
797  * Patterns are terminated by END items.
798  *
799  * The spec field should be a valid pointer to a structure of the related
800  * item type. It may remain unspecified (NULL) in many cases to request
801  * broad (nonspecific) matching. In such cases, last and mask must also be
802  * set to NULL.
803  *
804  * Optionally, last can point to a structure of the same type to define an
805  * inclusive range. This is mostly supported by integer and address fields,
806  * may cause errors otherwise. Fields that do not support ranges must be set
807  * to 0 or to the same value as the corresponding fields in spec.
808  *
809  * Only the fields defined to nonzero values in the default masks (see
810  * rte_flow_item_{name}_mask constants) are considered relevant by
811  * default. This can be overridden by providing a mask structure of the
812  * same type with applicable bits set to one. It can also be used to
813  * partially filter out specific fields (e.g. as an alternate mean to match
814  * ranges of IP addresses).
815  *
816  * Mask is a simple bit-mask applied before interpreting the contents of
817  * spec and last, which may yield unexpected results if not used
818  * carefully. For example, if for an IPv4 address field, spec provides
819  * 10.1.2.3, last provides 10.3.4.5 and mask provides 255.255.0.0, the
820  * effective range becomes 10.1.0.0 to 10.3.255.255.
821  */
822 struct rte_flow_item {
823         enum rte_flow_item_type type; /**< Item type. */
824         const void *spec; /**< Pointer to item specification structure. */
825         const void *last; /**< Defines an inclusive range (spec to last). */
826         const void *mask; /**< Bit-mask applied to spec and last. */
827 };
828
829 /**
830  * Action types.
831  *
832  * Each possible action is represented by a type. Some have associated
833  * configuration structures. Several actions combined in a list can be
834  * affected to a flow rule. That list is not ordered.
835  *
836  * They fall in three categories:
837  *
838  * - Terminating actions (such as QUEUE, DROP, RSS, PF, VF) that prevent
839  *   processing matched packets by subsequent flow rules, unless overridden
840  *   with PASSTHRU.
841  *
842  * - Non terminating actions (PASSTHRU, DUP) that leave matched packets up
843  *   for additional processing by subsequent flow rules.
844  *
845  * - Other non terminating meta actions that do not affect the fate of
846  *   packets (END, VOID, MARK, FLAG, COUNT).
847  *
848  * When several actions are combined in a flow rule, they should all have
849  * different types (e.g. dropping a packet twice is not possible).
850  *
851  * Only the last action of a given type is taken into account. PMDs still
852  * perform error checking on the entire list.
853  *
854  * Note that PASSTHRU is the only action able to override a terminating
855  * rule.
856  */
857 enum rte_flow_action_type {
858         /**
859          * [META]
860          *
861          * End marker for action lists. Prevents further processing of
862          * actions, thereby ending the list.
863          *
864          * No associated configuration structure.
865          */
866         RTE_FLOW_ACTION_TYPE_END,
867
868         /**
869          * [META]
870          *
871          * Used as a placeholder for convenience. It is ignored and simply
872          * discarded by PMDs.
873          *
874          * No associated configuration structure.
875          */
876         RTE_FLOW_ACTION_TYPE_VOID,
877
878         /**
879          * Leaves packets up for additional processing by subsequent flow
880          * rules. This is the default when a rule does not contain a
881          * terminating action, but can be specified to force a rule to
882          * become non-terminating.
883          *
884          * No associated configuration structure.
885          */
886         RTE_FLOW_ACTION_TYPE_PASSTHRU,
887
888         /**
889          * [META]
890          *
891          * Attaches an integer value to packets and sets PKT_RX_FDIR and
892          * PKT_RX_FDIR_ID mbuf flags.
893          *
894          * See struct rte_flow_action_mark.
895          */
896         RTE_FLOW_ACTION_TYPE_MARK,
897
898         /**
899          * [META]
900          *
901          * Flags packets. Similar to MARK without a specific value; only
902          * sets the PKT_RX_FDIR mbuf flag.
903          *
904          * No associated configuration structure.
905          */
906         RTE_FLOW_ACTION_TYPE_FLAG,
907
908         /**
909          * Assigns packets to a given queue index.
910          *
911          * See struct rte_flow_action_queue.
912          */
913         RTE_FLOW_ACTION_TYPE_QUEUE,
914
915         /**
916          * Drops packets.
917          *
918          * PASSTHRU overrides this action if both are specified.
919          *
920          * No associated configuration structure.
921          */
922         RTE_FLOW_ACTION_TYPE_DROP,
923
924         /**
925          * [META]
926          *
927          * Enables counters for this rule.
928          *
929          * These counters can be retrieved and reset through rte_flow_query(),
930          * see struct rte_flow_query_count.
931          *
932          * No associated configuration structure.
933          */
934         RTE_FLOW_ACTION_TYPE_COUNT,
935
936         /**
937          * Duplicates packets to a given queue index.
938          *
939          * This is normally combined with QUEUE, however when used alone, it
940          * is actually similar to QUEUE + PASSTHRU.
941          *
942          * See struct rte_flow_action_dup.
943          */
944         RTE_FLOW_ACTION_TYPE_DUP,
945
946         /**
947          * Similar to QUEUE, except RSS is additionally performed on packets
948          * to spread them among several queues according to the provided
949          * parameters.
950          *
951          * See struct rte_flow_action_rss.
952          */
953         RTE_FLOW_ACTION_TYPE_RSS,
954
955         /**
956          * Redirects packets to the physical function (PF) of the current
957          * device.
958          *
959          * No associated configuration structure.
960          */
961         RTE_FLOW_ACTION_TYPE_PF,
962
963         /**
964          * Redirects packets to the virtual function (VF) of the current
965          * device with the specified ID.
966          *
967          * See struct rte_flow_action_vf.
968          */
969         RTE_FLOW_ACTION_TYPE_VF,
970
971         /**
972          * Traffic metering and policing (MTR).
973          *
974          * See struct rte_flow_action_meter.
975          * See file rte_mtr.h for MTR object configuration.
976          */
977         RTE_FLOW_ACTION_TYPE_METER,
978 };
979
980 /**
981  * RTE_FLOW_ACTION_TYPE_MARK
982  *
983  * Attaches an integer value to packets and sets PKT_RX_FDIR and
984  * PKT_RX_FDIR_ID mbuf flags.
985  *
986  * This value is arbitrary and application-defined. Maximum allowed value
987  * depends on the underlying implementation. It is returned in the
988  * hash.fdir.hi mbuf field.
989  */
990 struct rte_flow_action_mark {
991         uint32_t id; /**< Integer value to return with packets. */
992 };
993
994 /**
995  * RTE_FLOW_ACTION_TYPE_QUEUE
996  *
997  * Assign packets to a given queue index.
998  *
999  * Terminating by default.
1000  */
1001 struct rte_flow_action_queue {
1002         uint16_t index; /**< Queue index to use. */
1003 };
1004
1005 /**
1006  * RTE_FLOW_ACTION_TYPE_COUNT (query)
1007  *
1008  * Query structure to retrieve and reset flow rule counters.
1009  */
1010 struct rte_flow_query_count {
1011         uint32_t reset:1; /**< Reset counters after query [in]. */
1012         uint32_t hits_set:1; /**< hits field is set [out]. */
1013         uint32_t bytes_set:1; /**< bytes field is set [out]. */
1014         uint32_t reserved:29; /**< Reserved, must be zero [in, out]. */
1015         uint64_t hits; /**< Number of hits for this rule [out]. */
1016         uint64_t bytes; /**< Number of bytes through this rule [out]. */
1017 };
1018
1019 /**
1020  * RTE_FLOW_ACTION_TYPE_DUP
1021  *
1022  * Duplicates packets to a given queue index.
1023  *
1024  * This is normally combined with QUEUE, however when used alone, it is
1025  * actually similar to QUEUE + PASSTHRU.
1026  *
1027  * Non-terminating by default.
1028  */
1029 struct rte_flow_action_dup {
1030         uint16_t index; /**< Queue index to duplicate packets to. */
1031 };
1032
1033 /**
1034  * RTE_FLOW_ACTION_TYPE_RSS
1035  *
1036  * Similar to QUEUE, except RSS is additionally performed on packets to
1037  * spread them among several queues according to the provided parameters.
1038  *
1039  * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps
1040  * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only,
1041  * both can be requested simultaneously.
1042  *
1043  * Terminating by default.
1044  */
1045 struct rte_flow_action_rss {
1046         const struct rte_eth_rss_conf *rss_conf; /**< RSS parameters. */
1047         uint16_t num; /**< Number of entries in queue[]. */
1048         uint16_t queue[]; /**< Queues indices to use. */
1049 };
1050
1051 /**
1052  * RTE_FLOW_ACTION_TYPE_VF
1053  *
1054  * Redirects packets to a virtual function (VF) of the current device.
1055  *
1056  * Packets matched by a VF pattern item can be redirected to their original
1057  * VF ID instead of the specified one. This parameter may not be available
1058  * and is not guaranteed to work properly if the VF part is matched by a
1059  * prior flow rule or if packets are not addressed to a VF in the first
1060  * place.
1061  *
1062  * Terminating by default.
1063  */
1064 struct rte_flow_action_vf {
1065         uint32_t original:1; /**< Use original VF ID if possible. */
1066         uint32_t reserved:31; /**< Reserved, must be zero. */
1067         uint32_t id; /**< VF ID to redirect packets to. */
1068 };
1069
1070 /**
1071  * RTE_FLOW_ACTION_TYPE_METER
1072  *
1073  * Traffic metering and policing (MTR).
1074  *
1075  * Packets matched by items of this type can be either dropped or passed to the
1076  * next item with their color set by the MTR object.
1077  *
1078  * Non-terminating by default.
1079  */
1080 struct rte_flow_action_meter {
1081         uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */
1082 };
1083
1084 /**
1085  * Definition of a single action.
1086  *
1087  * A list of actions is terminated by a END action.
1088  *
1089  * For simple actions without a configuration structure, conf remains NULL.
1090  */
1091 struct rte_flow_action {
1092         enum rte_flow_action_type type; /**< Action type. */
1093         const void *conf; /**< Pointer to action configuration structure. */
1094 };
1095
1096 /**
1097  * Opaque type returned after successfully creating a flow.
1098  *
1099  * This handle can be used to manage and query the related flow (e.g. to
1100  * destroy it or retrieve counters).
1101  */
1102 struct rte_flow;
1103
1104 /**
1105  * Verbose error types.
1106  *
1107  * Most of them provide the type of the object referenced by struct
1108  * rte_flow_error.cause.
1109  */
1110 enum rte_flow_error_type {
1111         RTE_FLOW_ERROR_TYPE_NONE, /**< No error. */
1112         RTE_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
1113         RTE_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */
1114         RTE_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */
1115         RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */
1116         RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */
1117         RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */
1118         RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */
1119         RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */
1120         RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */
1121         RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */
1122         RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */
1123 };
1124
1125 /**
1126  * Verbose error structure definition.
1127  *
1128  * This object is normally allocated by applications and set by PMDs, the
1129  * message points to a constant string which does not need to be freed by
1130  * the application, however its pointer can be considered valid only as long
1131  * as its associated DPDK port remains configured. Closing the underlying
1132  * device or unloading the PMD invalidates it.
1133  *
1134  * Both cause and message may be NULL regardless of the error type.
1135  */
1136 struct rte_flow_error {
1137         enum rte_flow_error_type type; /**< Cause field and error types. */
1138         const void *cause; /**< Object responsible for the error. */
1139         const char *message; /**< Human-readable error message. */
1140 };
1141
1142 /**
1143  * Check whether a flow rule can be created on a given port.
1144  *
1145  * The flow rule is validated for correctness and whether it could be accepted
1146  * by the device given sufficient resources. The rule is checked against the
1147  * current device mode and queue configuration. The flow rule may also
1148  * optionally be validated against existing flow rules and device resources.
1149  * This function has no effect on the target device.
1150  *
1151  * The returned value is guaranteed to remain valid only as long as no
1152  * successful calls to rte_flow_create() or rte_flow_destroy() are made in
1153  * the meantime and no device parameter affecting flow rules in any way are
1154  * modified, due to possible collisions or resource limitations (although in
1155  * such cases EINVAL should not be returned).
1156  *
1157  * @param port_id
1158  *   Port identifier of Ethernet device.
1159  * @param[in] attr
1160  *   Flow rule attributes.
1161  * @param[in] pattern
1162  *   Pattern specification (list terminated by the END pattern item).
1163  * @param[in] actions
1164  *   Associated actions (list terminated by the END action).
1165  * @param[out] error
1166  *   Perform verbose error reporting if not NULL. PMDs initialize this
1167  *   structure in case of error only.
1168  *
1169  * @return
1170  *   0 if flow rule is valid and can be created. A negative errno value
1171  *   otherwise (rte_errno is also set), the following errors are defined:
1172  *
1173  *   -ENOSYS: underlying device does not support this functionality.
1174  *
1175  *   -EINVAL: unknown or invalid rule specification.
1176  *
1177  *   -ENOTSUP: valid but unsupported rule specification (e.g. partial
1178  *   bit-masks are unsupported).
1179  *
1180  *   -EEXIST: collision with an existing rule. Only returned if device
1181  *   supports flow rule collision checking and there was a flow rule
1182  *   collision. Not receiving this return code is no guarantee that creating
1183  *   the rule will not fail due to a collision.
1184  *
1185  *   -ENOMEM: not enough memory to execute the function, or if the device
1186  *   supports resource validation, resource limitation on the device.
1187  *
1188  *   -EBUSY: action cannot be performed due to busy device resources, may
1189  *   succeed if the affected queues or even the entire port are in a stopped
1190  *   state (see rte_eth_dev_rx_queue_stop() and rte_eth_dev_stop()).
1191  */
1192 int
1193 rte_flow_validate(uint16_t port_id,
1194                   const struct rte_flow_attr *attr,
1195                   const struct rte_flow_item pattern[],
1196                   const struct rte_flow_action actions[],
1197                   struct rte_flow_error *error);
1198
1199 /**
1200  * Create a flow rule on a given port.
1201  *
1202  * @param port_id
1203  *   Port identifier of Ethernet device.
1204  * @param[in] attr
1205  *   Flow rule attributes.
1206  * @param[in] pattern
1207  *   Pattern specification (list terminated by the END pattern item).
1208  * @param[in] actions
1209  *   Associated actions (list terminated by the END action).
1210  * @param[out] error
1211  *   Perform verbose error reporting if not NULL. PMDs initialize this
1212  *   structure in case of error only.
1213  *
1214  * @return
1215  *   A valid handle in case of success, NULL otherwise and rte_errno is set
1216  *   to the positive version of one of the error codes defined for
1217  *   rte_flow_validate().
1218  */
1219 struct rte_flow *
1220 rte_flow_create(uint16_t port_id,
1221                 const struct rte_flow_attr *attr,
1222                 const struct rte_flow_item pattern[],
1223                 const struct rte_flow_action actions[],
1224                 struct rte_flow_error *error);
1225
1226 /**
1227  * Destroy a flow rule on a given port.
1228  *
1229  * Failure to destroy a flow rule handle may occur when other flow rules
1230  * depend on it, and destroying it would result in an inconsistent state.
1231  *
1232  * This function is only guaranteed to succeed if handles are destroyed in
1233  * reverse order of their creation.
1234  *
1235  * @param port_id
1236  *   Port identifier of Ethernet device.
1237  * @param flow
1238  *   Flow rule handle to destroy.
1239  * @param[out] error
1240  *   Perform verbose error reporting if not NULL. PMDs initialize this
1241  *   structure in case of error only.
1242  *
1243  * @return
1244  *   0 on success, a negative errno value otherwise and rte_errno is set.
1245  */
1246 int
1247 rte_flow_destroy(uint16_t port_id,
1248                  struct rte_flow *flow,
1249                  struct rte_flow_error *error);
1250
1251 /**
1252  * Destroy all flow rules associated with a port.
1253  *
1254  * In the unlikely event of failure, handles are still considered destroyed
1255  * and no longer valid but the port must be assumed to be in an inconsistent
1256  * state.
1257  *
1258  * @param port_id
1259  *   Port identifier of Ethernet device.
1260  * @param[out] error
1261  *   Perform verbose error reporting if not NULL. PMDs initialize this
1262  *   structure in case of error only.
1263  *
1264  * @return
1265  *   0 on success, a negative errno value otherwise and rte_errno is set.
1266  */
1267 int
1268 rte_flow_flush(uint16_t port_id,
1269                struct rte_flow_error *error);
1270
1271 /**
1272  * Query an existing flow rule.
1273  *
1274  * This function allows retrieving flow-specific data such as counters.
1275  * Data is gathered by special actions which must be present in the flow
1276  * rule definition.
1277  *
1278  * \see RTE_FLOW_ACTION_TYPE_COUNT
1279  *
1280  * @param port_id
1281  *   Port identifier of Ethernet device.
1282  * @param flow
1283  *   Flow rule handle to query.
1284  * @param action
1285  *   Action type to query.
1286  * @param[in, out] data
1287  *   Pointer to storage for the associated query data type.
1288  * @param[out] error
1289  *   Perform verbose error reporting if not NULL. PMDs initialize this
1290  *   structure in case of error only.
1291  *
1292  * @return
1293  *   0 on success, a negative errno value otherwise and rte_errno is set.
1294  */
1295 int
1296 rte_flow_query(uint16_t port_id,
1297                struct rte_flow *flow,
1298                enum rte_flow_action_type action,
1299                void *data,
1300                struct rte_flow_error *error);
1301
1302 /**
1303  * Restrict ingress traffic to the defined flow rules.
1304  *
1305  * Isolated mode guarantees that all ingress traffic comes from defined flow
1306  * rules only (current and future).
1307  *
1308  * Besides making ingress more deterministic, it allows PMDs to safely reuse
1309  * resources otherwise assigned to handle the remaining traffic, such as
1310  * global RSS configuration settings, VLAN filters, MAC address entries,
1311  * legacy filter API rules and so on in order to expand the set of possible
1312  * flow rule types.
1313  *
1314  * Calling this function as soon as possible after device initialization,
1315  * ideally before the first call to rte_eth_dev_configure(), is recommended
1316  * to avoid possible failures due to conflicting settings.
1317  *
1318  * Once effective, leaving isolated mode may not be possible depending on
1319  * PMD implementation.
1320  *
1321  * Additionally, the following functionality has no effect on the underlying
1322  * port and may return errors such as ENOTSUP ("not supported"):
1323  *
1324  * - Toggling promiscuous mode.
1325  * - Toggling allmulticast mode.
1326  * - Configuring MAC addresses.
1327  * - Configuring multicast addresses.
1328  * - Configuring VLAN filters.
1329  * - Configuring Rx filters through the legacy API (e.g. FDIR).
1330  * - Configuring global RSS settings.
1331  *
1332  * @param port_id
1333  *   Port identifier of Ethernet device.
1334  * @param set
1335  *   Nonzero to enter isolated mode, attempt to leave it otherwise.
1336  * @param[out] error
1337  *   Perform verbose error reporting if not NULL. PMDs initialize this
1338  *   structure in case of error only.
1339  *
1340  * @return
1341  *   0 on success, a negative errno value otherwise and rte_errno is set.
1342  */
1343 int
1344 rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error);
1345
1346 /**
1347  * Initialize flow error structure.
1348  *
1349  * @param[out] error
1350  *   Pointer to flow error structure (may be NULL).
1351  * @param code
1352  *   Related error code (rte_errno).
1353  * @param type
1354  *   Cause field and error types.
1355  * @param cause
1356  *   Object responsible for the error.
1357  * @param message
1358  *   Human-readable error message.
1359  *
1360  * @return
1361  *   Negative error code (errno value) and rte_errno is set.
1362  */
1363 int
1364 rte_flow_error_set(struct rte_flow_error *error,
1365                    int code,
1366                    enum rte_flow_error_type type,
1367                    const void *cause,
1368                    const char *message);
1369
1370 /**
1371  * Generic flow representation.
1372  *
1373  * This form is sufficient to describe an rte_flow independently from any
1374  * PMD implementation and allows for replayability and identification.
1375  */
1376 struct rte_flow_desc {
1377         size_t size; /**< Allocated space including data[]. */
1378         struct rte_flow_attr attr; /**< Attributes. */
1379         struct rte_flow_item *items; /**< Items. */
1380         struct rte_flow_action *actions; /**< Actions. */
1381         uint8_t data[]; /**< Storage for items/actions. */
1382 };
1383
1384 /**
1385  * Copy an rte_flow rule description.
1386  *
1387  * @param[in] fd
1388  *   Flow rule description.
1389  * @param[in] len
1390  *   Total size of allocated data for the flow description.
1391  * @param[in] attr
1392  *   Flow rule attributes.
1393  * @param[in] items
1394  *   Pattern specification (list terminated by the END pattern item).
1395  * @param[in] actions
1396  *   Associated actions (list terminated by the END action).
1397  *
1398  * @return
1399  *   If len is greater or equal to the size of the flow, the total size of the
1400  *   flow description and its data.
1401  *   If len is lower than the size of the flow, the number of bytes that would
1402  *   have been written to desc had it been sufficient. Nothing is written.
1403  */
1404 size_t
1405 rte_flow_copy(struct rte_flow_desc *fd, size_t len,
1406               const struct rte_flow_attr *attr,
1407               const struct rte_flow_item *items,
1408               const struct rte_flow_action *actions);
1409
1410 #ifdef __cplusplus
1411 }
1412 #endif
1413
1414 #endif /* RTE_FLOW_H_ */