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