ethdev: add shared actions to flow API
[dpdk.git] / lib / librte_ethdev / rte_flow.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright 2016 6WIND S.A.
3  * Copyright 2016 Mellanox Technologies, Ltd
4  */
5
6 #ifndef RTE_FLOW_H_
7 #define RTE_FLOW_H_
8
9 /**
10  * @file
11  * RTE generic flow API
12  *
13  * This interface provides the ability to program packet matching and
14  * associated actions in hardware through flow rules.
15  */
16
17 #include <stddef.h>
18 #include <stdint.h>
19
20 #include <rte_arp.h>
21 #include <rte_common.h>
22 #include <rte_ether.h>
23 #include <rte_icmp.h>
24 #include <rte_ip.h>
25 #include <rte_sctp.h>
26 #include <rte_tcp.h>
27 #include <rte_udp.h>
28 #include <rte_byteorder.h>
29 #include <rte_esp.h>
30 #include <rte_higig.h>
31 #include <rte_ecpri.h>
32 #include <rte_mbuf.h>
33 #include <rte_mbuf_dyn.h>
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 /**
40  * Flow rule attributes.
41  *
42  * Priorities are set on a per rule based within groups.
43  *
44  * Lower values denote higher priority, the highest priority for a flow rule
45  * is 0, so that a flow that matches for than one rule, the rule with the
46  * lowest priority value will always be matched.
47  *
48  * Although optional, applications are encouraged to group similar rules as
49  * much as possible to fully take advantage of hardware capabilities
50  * (e.g. optimized matching) and work around limitations (e.g. a single
51  * pattern type possibly allowed in a given group). Applications should be
52  * aware that groups are not linked by default, and that they must be
53  * explicitly linked by the application using the JUMP action.
54  *
55  * Priority levels are arbitrary and up to the application, they
56  * do not need to be contiguous nor start from 0, however the maximum number
57  * varies between devices and may be affected by existing flow rules.
58  *
59  * If a packet is matched by several rules of a given group for a given
60  * priority level, the outcome is undefined. It can take any path, may be
61  * duplicated or even cause unrecoverable errors.
62  *
63  * Note that support for more than a single group and priority level is not
64  * guaranteed.
65  *
66  * Flow rules can apply to inbound and/or outbound traffic (ingress/egress).
67  *
68  * Several pattern items and actions are valid and can be used in both
69  * directions. Those valid for only one direction are described as such.
70  *
71  * At least one direction must be specified.
72  *
73  * Specifying both directions at once for a given rule is not recommended
74  * but may be valid in a few cases (e.g. shared counter).
75  */
76 struct rte_flow_attr {
77         uint32_t group; /**< Priority group. */
78         uint32_t priority; /**< Rule priority level within group. */
79         uint32_t ingress:1; /**< Rule applies to ingress traffic. */
80         uint32_t egress:1; /**< Rule applies to egress traffic. */
81         /**
82          * Instead of simply matching the properties of traffic as it would
83          * appear on a given DPDK port ID, enabling this attribute transfers
84          * a flow rule to the lowest possible level of any device endpoints
85          * found in the pattern.
86          *
87          * When supported, this effectively enables an application to
88          * re-route traffic not necessarily intended for it (e.g. coming
89          * from or addressed to different physical ports, VFs or
90          * applications) at the device level.
91          *
92          * It complements the behavior of some pattern items such as
93          * RTE_FLOW_ITEM_TYPE_PHY_PORT and is meaningless without them.
94          *
95          * When transferring flow rules, ingress and egress attributes keep
96          * their original meaning, as if processing traffic emitted or
97          * received by the application.
98          */
99         uint32_t transfer:1;
100         uint32_t reserved:29; /**< Reserved, must be zero. */
101 };
102
103 /**
104  * Matching pattern item types.
105  *
106  * Pattern items fall in two categories:
107  *
108  * - Matching protocol headers and packet data, usually associated with a
109  *   specification structure. These must be stacked in the same order as the
110  *   protocol layers to match inside packets, starting from the lowest.
111  *
112  * - Matching meta-data or affecting pattern processing, often without a
113  *   specification structure. Since they do not match packet contents, their
114  *   position in the list is usually not relevant.
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 traffic originating from (ingress) or going to (egress)
162          * the physical function of the current device.
163          *
164          * No associated specification structure.
165          */
166         RTE_FLOW_ITEM_TYPE_PF,
167
168         /**
169          * [META]
170          *
171          * Matches traffic originating from (ingress) or going to (egress) a
172          * given virtual function of the current device.
173          *
174          * See struct rte_flow_item_vf.
175          */
176         RTE_FLOW_ITEM_TYPE_VF,
177
178         /**
179          * [META]
180          *
181          * Matches traffic originating from (ingress) or going to (egress) a
182          * physical port of the underlying device.
183          *
184          * See struct rte_flow_item_phy_port.
185          */
186         RTE_FLOW_ITEM_TYPE_PHY_PORT,
187
188         /**
189          * [META]
190          *
191          * Matches traffic originating from (ingress) or going to (egress) a
192          * given DPDK port ID.
193          *
194          * See struct rte_flow_item_port_id.
195          */
196         RTE_FLOW_ITEM_TYPE_PORT_ID,
197
198         /**
199          * Matches a byte string of a given length at a given offset.
200          *
201          * See struct rte_flow_item_raw.
202          */
203         RTE_FLOW_ITEM_TYPE_RAW,
204
205         /**
206          * Matches an Ethernet header.
207          *
208          * See struct rte_flow_item_eth.
209          */
210         RTE_FLOW_ITEM_TYPE_ETH,
211
212         /**
213          * Matches an 802.1Q/ad VLAN tag.
214          *
215          * See struct rte_flow_item_vlan.
216          */
217         RTE_FLOW_ITEM_TYPE_VLAN,
218
219         /**
220          * Matches an IPv4 header.
221          *
222          * See struct rte_flow_item_ipv4.
223          */
224         RTE_FLOW_ITEM_TYPE_IPV4,
225
226         /**
227          * Matches an IPv6 header.
228          *
229          * See struct rte_flow_item_ipv6.
230          */
231         RTE_FLOW_ITEM_TYPE_IPV6,
232
233         /**
234          * Matches an ICMP header.
235          *
236          * See struct rte_flow_item_icmp.
237          */
238         RTE_FLOW_ITEM_TYPE_ICMP,
239
240         /**
241          * Matches a UDP header.
242          *
243          * See struct rte_flow_item_udp.
244          */
245         RTE_FLOW_ITEM_TYPE_UDP,
246
247         /**
248          * Matches a TCP header.
249          *
250          * See struct rte_flow_item_tcp.
251          */
252         RTE_FLOW_ITEM_TYPE_TCP,
253
254         /**
255          * Matches a SCTP header.
256          *
257          * See struct rte_flow_item_sctp.
258          */
259         RTE_FLOW_ITEM_TYPE_SCTP,
260
261         /**
262          * Matches a VXLAN header.
263          *
264          * See struct rte_flow_item_vxlan.
265          */
266         RTE_FLOW_ITEM_TYPE_VXLAN,
267
268         /**
269          * Matches a E_TAG header.
270          *
271          * See struct rte_flow_item_e_tag.
272          */
273         RTE_FLOW_ITEM_TYPE_E_TAG,
274
275         /**
276          * Matches a NVGRE header.
277          *
278          * See struct rte_flow_item_nvgre.
279          */
280         RTE_FLOW_ITEM_TYPE_NVGRE,
281
282         /**
283          * Matches a MPLS header.
284          *
285          * See struct rte_flow_item_mpls.
286          */
287         RTE_FLOW_ITEM_TYPE_MPLS,
288
289         /**
290          * Matches a GRE header.
291          *
292          * See struct rte_flow_item_gre.
293          */
294         RTE_FLOW_ITEM_TYPE_GRE,
295
296         /**
297          * [META]
298          *
299          * Fuzzy pattern match, expect faster than default.
300          *
301          * This is for device that support fuzzy matching option.
302          * Usually a fuzzy matching is fast but the cost is accuracy.
303          *
304          * See struct rte_flow_item_fuzzy.
305          */
306         RTE_FLOW_ITEM_TYPE_FUZZY,
307
308         /**
309          * Matches a GTP header.
310          *
311          * Configure flow for GTP packets.
312          *
313          * See struct rte_flow_item_gtp.
314          */
315         RTE_FLOW_ITEM_TYPE_GTP,
316
317         /**
318          * Matches a GTP header.
319          *
320          * Configure flow for GTP-C packets.
321          *
322          * See struct rte_flow_item_gtp.
323          */
324         RTE_FLOW_ITEM_TYPE_GTPC,
325
326         /**
327          * Matches a GTP header.
328          *
329          * Configure flow for GTP-U packets.
330          *
331          * See struct rte_flow_item_gtp.
332          */
333         RTE_FLOW_ITEM_TYPE_GTPU,
334
335         /**
336          * Matches a ESP header.
337          *
338          * See struct rte_flow_item_esp.
339          */
340         RTE_FLOW_ITEM_TYPE_ESP,
341
342         /**
343          * Matches a GENEVE header.
344          *
345          * See struct rte_flow_item_geneve.
346          */
347         RTE_FLOW_ITEM_TYPE_GENEVE,
348
349         /**
350          * Matches a VXLAN-GPE header.
351          *
352          * See struct rte_flow_item_vxlan_gpe.
353          */
354         RTE_FLOW_ITEM_TYPE_VXLAN_GPE,
355
356         /**
357          * Matches an ARP header for Ethernet/IPv4.
358          *
359          * See struct rte_flow_item_arp_eth_ipv4.
360          */
361         RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4,
362
363         /**
364          * Matches the presence of any IPv6 extension header.
365          *
366          * See struct rte_flow_item_ipv6_ext.
367          */
368         RTE_FLOW_ITEM_TYPE_IPV6_EXT,
369
370         /**
371          * Matches any ICMPv6 header.
372          *
373          * See struct rte_flow_item_icmp6.
374          */
375         RTE_FLOW_ITEM_TYPE_ICMP6,
376
377         /**
378          * Matches an ICMPv6 neighbor discovery solicitation.
379          *
380          * See struct rte_flow_item_icmp6_nd_ns.
381          */
382         RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS,
383
384         /**
385          * Matches an ICMPv6 neighbor discovery advertisement.
386          *
387          * See struct rte_flow_item_icmp6_nd_na.
388          */
389         RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA,
390
391         /**
392          * Matches the presence of any ICMPv6 neighbor discovery option.
393          *
394          * See struct rte_flow_item_icmp6_nd_opt.
395          */
396         RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT,
397
398         /**
399          * Matches an ICMPv6 neighbor discovery source Ethernet link-layer
400          * address option.
401          *
402          * See struct rte_flow_item_icmp6_nd_opt_sla_eth.
403          */
404         RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH,
405
406         /**
407          * Matches an ICMPv6 neighbor discovery target Ethernet link-layer
408          * address option.
409          *
410          * See struct rte_flow_item_icmp6_nd_opt_tla_eth.
411          */
412         RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH,
413
414         /**
415          * Matches specified mark field.
416          *
417          * See struct rte_flow_item_mark.
418          */
419         RTE_FLOW_ITEM_TYPE_MARK,
420
421         /**
422          * [META]
423          *
424          * Matches a metadata value.
425          *
426          * See struct rte_flow_item_meta.
427          */
428         RTE_FLOW_ITEM_TYPE_META,
429
430         /**
431          * Matches a GRE optional key field.
432          *
433          * The value should a big-endian 32bit integer.
434          *
435          * When this item present the K bit is implicitly matched as "1"
436          * in the default mask.
437          *
438          * @p spec/mask type:
439          * @code rte_be32_t * @endcode
440          */
441         RTE_FLOW_ITEM_TYPE_GRE_KEY,
442
443         /**
444          * Matches a GTP extension header: PDU session container.
445          *
446          * Configure flow for GTP packets with extension header type 0x85.
447          *
448          * See struct rte_flow_item_gtp_psc.
449          */
450         RTE_FLOW_ITEM_TYPE_GTP_PSC,
451
452         /**
453          * Matches a PPPoE header.
454          *
455          * Configure flow for PPPoE session packets.
456          *
457          * See struct rte_flow_item_pppoe.
458          */
459         RTE_FLOW_ITEM_TYPE_PPPOES,
460
461         /**
462          * Matches a PPPoE header.
463          *
464          * Configure flow for PPPoE discovery packets.
465          *
466          * See struct rte_flow_item_pppoe.
467          */
468         RTE_FLOW_ITEM_TYPE_PPPOED,
469
470         /**
471          * Matches a PPPoE optional proto_id field.
472          *
473          * It only applies to PPPoE session packets.
474          *
475          * See struct rte_flow_item_pppoe_proto_id.
476          */
477         RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID,
478
479         /**
480          * Matches Network service header (NSH).
481          * See struct rte_flow_item_nsh.
482          *
483          */
484         RTE_FLOW_ITEM_TYPE_NSH,
485
486         /**
487          * Matches Internet Group Management Protocol (IGMP).
488          * See struct rte_flow_item_igmp.
489          *
490          */
491         RTE_FLOW_ITEM_TYPE_IGMP,
492
493         /**
494          * Matches IP Authentication Header (AH).
495          * See struct rte_flow_item_ah.
496          *
497          */
498         RTE_FLOW_ITEM_TYPE_AH,
499
500         /**
501          * Matches a HIGIG header.
502          * see struct rte_flow_item_higig2_hdr.
503          */
504         RTE_FLOW_ITEM_TYPE_HIGIG2,
505
506         /**
507          * [META]
508          *
509          * Matches a tag value.
510          *
511          * See struct rte_flow_item_tag.
512          */
513         RTE_FLOW_ITEM_TYPE_TAG,
514
515         /**
516          * Matches a L2TPv3 over IP header.
517          *
518          * Configure flow for L2TPv3 over IP packets.
519          *
520          * See struct rte_flow_item_l2tpv3oip.
521          */
522         RTE_FLOW_ITEM_TYPE_L2TPV3OIP,
523
524         /**
525          * Matches PFCP Header.
526          * See struct rte_flow_item_pfcp.
527          *
528          */
529         RTE_FLOW_ITEM_TYPE_PFCP,
530
531         /**
532          * Matches eCPRI Header.
533          *
534          * Configure flow for eCPRI over ETH or UDP packets.
535          *
536          * See struct rte_flow_item_ecpri.
537          */
538         RTE_FLOW_ITEM_TYPE_ECPRI,
539
540 };
541
542 /**
543  *
544  * RTE_FLOW_ITEM_TYPE_HIGIG2
545  * Matches higig2 header
546  */
547 RTE_STD_C11
548 struct rte_flow_item_higig2_hdr {
549         struct rte_higig2_hdr hdr;
550 };
551
552 /** Default mask for RTE_FLOW_ITEM_TYPE_HIGIG2. */
553 #ifndef __cplusplus
554 static const struct rte_flow_item_higig2_hdr rte_flow_item_higig2_hdr_mask = {
555         .hdr = {
556                 .ppt1 = {
557                         .classification = 0xffff,
558                         .vid = 0xfff,
559                 },
560         },
561 };
562 #endif
563
564 /**
565  * RTE_FLOW_ITEM_TYPE_ANY
566  *
567  * Matches any protocol in place of the current layer, a single ANY may also
568  * stand for several protocol layers.
569  *
570  * This is usually specified as the first pattern item when looking for a
571  * protocol anywhere in a packet.
572  *
573  * A zeroed mask stands for any number of layers.
574  */
575 struct rte_flow_item_any {
576         uint32_t num; /**< Number of layers covered. */
577 };
578
579 /** Default mask for RTE_FLOW_ITEM_TYPE_ANY. */
580 #ifndef __cplusplus
581 static const struct rte_flow_item_any rte_flow_item_any_mask = {
582         .num = 0x00000000,
583 };
584 #endif
585
586 /**
587  * RTE_FLOW_ITEM_TYPE_VF
588  *
589  * Matches traffic originating from (ingress) or going to (egress) a given
590  * virtual function of the current device.
591  *
592  * If supported, should work even if the virtual function is not managed by
593  * the application and thus not associated with a DPDK port ID.
594  *
595  * Note this pattern item does not match VF representors traffic which, as
596  * separate entities, should be addressed through their own DPDK port IDs.
597  *
598  * - Can be specified multiple times to match traffic addressed to several
599  *   VF IDs.
600  * - Can be combined with a PF item to match both PF and VF traffic.
601  *
602  * A zeroed mask can be used to match any VF ID.
603  */
604 struct rte_flow_item_vf {
605         uint32_t id; /**< VF ID. */
606 };
607
608 /** Default mask for RTE_FLOW_ITEM_TYPE_VF. */
609 #ifndef __cplusplus
610 static const struct rte_flow_item_vf rte_flow_item_vf_mask = {
611         .id = 0x00000000,
612 };
613 #endif
614
615 /**
616  * RTE_FLOW_ITEM_TYPE_PHY_PORT
617  *
618  * Matches traffic originating from (ingress) or going to (egress) a
619  * physical port of the underlying device.
620  *
621  * The first PHY_PORT item overrides the physical port normally associated
622  * with the specified DPDK input port (port_id). This item can be provided
623  * several times to match additional physical ports.
624  *
625  * Note that physical ports are not necessarily tied to DPDK input ports
626  * (port_id) when those are not under DPDK control. Possible values are
627  * specific to each device, they are not necessarily indexed from zero and
628  * may not be contiguous.
629  *
630  * As a device property, the list of allowed values as well as the value
631  * associated with a port_id should be retrieved by other means.
632  *
633  * A zeroed mask can be used to match any port index.
634  */
635 struct rte_flow_item_phy_port {
636         uint32_t index; /**< Physical port index. */
637 };
638
639 /** Default mask for RTE_FLOW_ITEM_TYPE_PHY_PORT. */
640 #ifndef __cplusplus
641 static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask = {
642         .index = 0x00000000,
643 };
644 #endif
645
646 /**
647  * RTE_FLOW_ITEM_TYPE_PORT_ID
648  *
649  * Matches traffic originating from (ingress) or going to (egress) a given
650  * DPDK port ID.
651  *
652  * Normally only supported if the port ID in question is known by the
653  * underlying PMD and related to the device the flow rule is created
654  * against.
655  *
656  * This must not be confused with @p PHY_PORT which refers to the physical
657  * port of a device, whereas @p PORT_ID refers to a struct rte_eth_dev
658  * object on the application side (also known as "port representor"
659  * depending on the kind of underlying device).
660  */
661 struct rte_flow_item_port_id {
662         uint32_t id; /**< DPDK port ID. */
663 };
664
665 /** Default mask for RTE_FLOW_ITEM_TYPE_PORT_ID. */
666 #ifndef __cplusplus
667 static const struct rte_flow_item_port_id rte_flow_item_port_id_mask = {
668         .id = 0xffffffff,
669 };
670 #endif
671
672 /**
673  * RTE_FLOW_ITEM_TYPE_RAW
674  *
675  * Matches a byte string of a given length at a given offset.
676  *
677  * Offset is either absolute (using the start of the packet) or relative to
678  * the end of the previous matched item in the stack, in which case negative
679  * values are allowed.
680  *
681  * If search is enabled, offset is used as the starting point. The search
682  * area can be delimited by setting limit to a nonzero value, which is the
683  * maximum number of bytes after offset where the pattern may start.
684  *
685  * Matching a zero-length pattern is allowed, doing so resets the relative
686  * offset for subsequent items.
687  *
688  * This type does not support ranges (struct rte_flow_item.last).
689  */
690 struct rte_flow_item_raw {
691         uint32_t relative:1; /**< Look for pattern after the previous item. */
692         uint32_t search:1; /**< Search pattern from offset (see also limit). */
693         uint32_t reserved:30; /**< Reserved, must be set to zero. */
694         int32_t offset; /**< Absolute or relative offset for pattern. */
695         uint16_t limit; /**< Search area limit for start of pattern. */
696         uint16_t length; /**< Pattern length. */
697         const uint8_t *pattern; /**< Byte string to look for. */
698 };
699
700 /** Default mask for RTE_FLOW_ITEM_TYPE_RAW. */
701 #ifndef __cplusplus
702 static const struct rte_flow_item_raw rte_flow_item_raw_mask = {
703         .relative = 1,
704         .search = 1,
705         .reserved = 0x3fffffff,
706         .offset = 0xffffffff,
707         .limit = 0xffff,
708         .length = 0xffff,
709         .pattern = NULL,
710 };
711 #endif
712
713 /**
714  * RTE_FLOW_ITEM_TYPE_ETH
715  *
716  * Matches an Ethernet header.
717  *
718  * The @p type field either stands for "EtherType" or "TPID" when followed
719  * by so-called layer 2.5 pattern items such as RTE_FLOW_ITEM_TYPE_VLAN. In
720  * the latter case, @p type refers to that of the outer header, with the
721  * inner EtherType/TPID provided by the subsequent pattern item. This is the
722  * same order as on the wire.
723  * If the @p type field contains a TPID value, then only tagged packets with the
724  * specified TPID will match the pattern.
725  * Otherwise, only untagged packets will match the pattern.
726  * If the @p ETH item is the only item in the pattern, and the @p type field
727  * is not specified, then both tagged and untagged packets will match the
728  * pattern.
729  */
730 struct rte_flow_item_eth {
731         struct rte_ether_addr dst; /**< Destination MAC. */
732         struct rte_ether_addr src; /**< Source MAC. */
733         rte_be16_t type; /**< EtherType or TPID. */
734 };
735
736 /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */
737 #ifndef __cplusplus
738 static const struct rte_flow_item_eth rte_flow_item_eth_mask = {
739         .dst.addr_bytes = "\xff\xff\xff\xff\xff\xff",
740         .src.addr_bytes = "\xff\xff\xff\xff\xff\xff",
741         .type = RTE_BE16(0x0000),
742 };
743 #endif
744
745 /**
746  * RTE_FLOW_ITEM_TYPE_VLAN
747  *
748  * Matches an 802.1Q/ad VLAN tag.
749  *
750  * The corresponding standard outer EtherType (TPID) values are
751  * RTE_ETHER_TYPE_VLAN or RTE_ETHER_TYPE_QINQ. It can be overridden by
752  * the preceding pattern item.
753  * If a @p VLAN item is present in the pattern, then only tagged packets will
754  * match the pattern.
755  */
756 struct rte_flow_item_vlan {
757         rte_be16_t tci; /**< Tag control information. */
758         rte_be16_t inner_type; /**< Inner EtherType or TPID. */
759 };
760
761 /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */
762 #ifndef __cplusplus
763 static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = {
764         .tci = RTE_BE16(0x0fff),
765         .inner_type = RTE_BE16(0x0000),
766 };
767 #endif
768
769 /**
770  * RTE_FLOW_ITEM_TYPE_IPV4
771  *
772  * Matches an IPv4 header.
773  *
774  * Note: IPv4 options are handled by dedicated pattern items.
775  */
776 struct rte_flow_item_ipv4 {
777         struct rte_ipv4_hdr hdr; /**< IPv4 header definition. */
778 };
779
780 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV4. */
781 #ifndef __cplusplus
782 static const struct rte_flow_item_ipv4 rte_flow_item_ipv4_mask = {
783         .hdr = {
784                 .src_addr = RTE_BE32(0xffffffff),
785                 .dst_addr = RTE_BE32(0xffffffff),
786         },
787 };
788 #endif
789
790 /**
791  * RTE_FLOW_ITEM_TYPE_IPV6.
792  *
793  * Matches an IPv6 header.
794  *
795  * Note: IPv6 options are handled by dedicated pattern items, see
796  * RTE_FLOW_ITEM_TYPE_IPV6_EXT.
797  */
798 struct rte_flow_item_ipv6 {
799         struct rte_ipv6_hdr hdr; /**< IPv6 header definition. */
800 };
801
802 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
803 #ifndef __cplusplus
804 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
805         .hdr = {
806                 .src_addr =
807                         "\xff\xff\xff\xff\xff\xff\xff\xff"
808                         "\xff\xff\xff\xff\xff\xff\xff\xff",
809                 .dst_addr =
810                         "\xff\xff\xff\xff\xff\xff\xff\xff"
811                         "\xff\xff\xff\xff\xff\xff\xff\xff",
812         },
813 };
814 #endif
815
816 /**
817  * RTE_FLOW_ITEM_TYPE_ICMP.
818  *
819  * Matches an ICMP header.
820  */
821 struct rte_flow_item_icmp {
822         struct rte_icmp_hdr hdr; /**< ICMP header definition. */
823 };
824
825 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP. */
826 #ifndef __cplusplus
827 static const struct rte_flow_item_icmp rte_flow_item_icmp_mask = {
828         .hdr = {
829                 .icmp_type = 0xff,
830                 .icmp_code = 0xff,
831         },
832 };
833 #endif
834
835 /**
836  * RTE_FLOW_ITEM_TYPE_UDP.
837  *
838  * Matches a UDP header.
839  */
840 struct rte_flow_item_udp {
841         struct rte_udp_hdr hdr; /**< UDP header definition. */
842 };
843
844 /** Default mask for RTE_FLOW_ITEM_TYPE_UDP. */
845 #ifndef __cplusplus
846 static const struct rte_flow_item_udp rte_flow_item_udp_mask = {
847         .hdr = {
848                 .src_port = RTE_BE16(0xffff),
849                 .dst_port = RTE_BE16(0xffff),
850         },
851 };
852 #endif
853
854 /**
855  * RTE_FLOW_ITEM_TYPE_TCP.
856  *
857  * Matches a TCP header.
858  */
859 struct rte_flow_item_tcp {
860         struct rte_tcp_hdr hdr; /**< TCP header definition. */
861 };
862
863 /** Default mask for RTE_FLOW_ITEM_TYPE_TCP. */
864 #ifndef __cplusplus
865 static const struct rte_flow_item_tcp rte_flow_item_tcp_mask = {
866         .hdr = {
867                 .src_port = RTE_BE16(0xffff),
868                 .dst_port = RTE_BE16(0xffff),
869         },
870 };
871 #endif
872
873 /**
874  * RTE_FLOW_ITEM_TYPE_SCTP.
875  *
876  * Matches a SCTP header.
877  */
878 struct rte_flow_item_sctp {
879         struct rte_sctp_hdr hdr; /**< SCTP header definition. */
880 };
881
882 /** Default mask for RTE_FLOW_ITEM_TYPE_SCTP. */
883 #ifndef __cplusplus
884 static const struct rte_flow_item_sctp rte_flow_item_sctp_mask = {
885         .hdr = {
886                 .src_port = RTE_BE16(0xffff),
887                 .dst_port = RTE_BE16(0xffff),
888         },
889 };
890 #endif
891
892 /**
893  * RTE_FLOW_ITEM_TYPE_VXLAN.
894  *
895  * Matches a VXLAN header (RFC 7348).
896  */
897 struct rte_flow_item_vxlan {
898         uint8_t flags; /**< Normally 0x08 (I flag). */
899         uint8_t rsvd0[3]; /**< Reserved, normally 0x000000. */
900         uint8_t vni[3]; /**< VXLAN identifier. */
901         uint8_t rsvd1; /**< Reserved, normally 0x00. */
902 };
903
904 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */
905 #ifndef __cplusplus
906 static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = {
907         .vni = "\xff\xff\xff",
908 };
909 #endif
910
911 /**
912  * RTE_FLOW_ITEM_TYPE_E_TAG.
913  *
914  * Matches a E-tag header.
915  *
916  * The corresponding standard outer EtherType (TPID) value is
917  * RTE_ETHER_TYPE_ETAG. It can be overridden by the preceding pattern item.
918  */
919 struct rte_flow_item_e_tag {
920         /**
921          * E-Tag control information (E-TCI).
922          * E-PCP (3b), E-DEI (1b), ingress E-CID base (12b).
923          */
924         rte_be16_t epcp_edei_in_ecid_b;
925         /** Reserved (2b), GRP (2b), E-CID base (12b). */
926         rte_be16_t rsvd_grp_ecid_b;
927         uint8_t in_ecid_e; /**< Ingress E-CID ext. */
928         uint8_t ecid_e; /**< E-CID ext. */
929         rte_be16_t inner_type; /**< Inner EtherType or TPID. */
930 };
931
932 /** Default mask for RTE_FLOW_ITEM_TYPE_E_TAG. */
933 #ifndef __cplusplus
934 static const struct rte_flow_item_e_tag rte_flow_item_e_tag_mask = {
935         .rsvd_grp_ecid_b = RTE_BE16(0x3fff),
936 };
937 #endif
938
939 /**
940  * RTE_FLOW_ITEM_TYPE_NVGRE.
941  *
942  * Matches a NVGRE header.
943  */
944 struct rte_flow_item_nvgre {
945         /**
946          * Checksum (1b), undefined (1b), key bit (1b), sequence number (1b),
947          * reserved 0 (9b), version (3b).
948          *
949          * c_k_s_rsvd0_ver must have value 0x2000 according to RFC 7637.
950          */
951         rte_be16_t c_k_s_rsvd0_ver;
952         rte_be16_t protocol; /**< Protocol type (0x6558). */
953         uint8_t tni[3]; /**< Virtual subnet ID. */
954         uint8_t flow_id; /**< Flow ID. */
955 };
956
957 /** Default mask for RTE_FLOW_ITEM_TYPE_NVGRE. */
958 #ifndef __cplusplus
959 static const struct rte_flow_item_nvgre rte_flow_item_nvgre_mask = {
960         .tni = "\xff\xff\xff",
961 };
962 #endif
963
964 /**
965  * RTE_FLOW_ITEM_TYPE_MPLS.
966  *
967  * Matches a MPLS header.
968  */
969 struct rte_flow_item_mpls {
970         /**
971          * Label (20b), TC (3b), Bottom of Stack (1b).
972          */
973         uint8_t label_tc_s[3];
974         uint8_t ttl; /** Time-to-Live. */
975 };
976
977 /** Default mask for RTE_FLOW_ITEM_TYPE_MPLS. */
978 #ifndef __cplusplus
979 static const struct rte_flow_item_mpls rte_flow_item_mpls_mask = {
980         .label_tc_s = "\xff\xff\xf0",
981 };
982 #endif
983
984 /**
985  * RTE_FLOW_ITEM_TYPE_GRE.
986  *
987  * Matches a GRE header.
988  */
989 struct rte_flow_item_gre {
990         /**
991          * Checksum (1b), reserved 0 (12b), version (3b).
992          * Refer to RFC 2784.
993          */
994         rte_be16_t c_rsvd0_ver;
995         rte_be16_t protocol; /**< Protocol type. */
996 };
997
998 /** Default mask for RTE_FLOW_ITEM_TYPE_GRE. */
999 #ifndef __cplusplus
1000 static const struct rte_flow_item_gre rte_flow_item_gre_mask = {
1001         .protocol = RTE_BE16(0xffff),
1002 };
1003 #endif
1004
1005 /**
1006  * RTE_FLOW_ITEM_TYPE_FUZZY
1007  *
1008  * Fuzzy pattern match, expect faster than default.
1009  *
1010  * This is for device that support fuzzy match option.
1011  * Usually a fuzzy match is fast but the cost is accuracy.
1012  * i.e. Signature Match only match pattern's hash value, but it is
1013  * possible two different patterns have the same hash value.
1014  *
1015  * Matching accuracy level can be configure by threshold.
1016  * Driver can divide the range of threshold and map to different
1017  * accuracy levels that device support.
1018  *
1019  * Threshold 0 means perfect match (no fuzziness), while threshold
1020  * 0xffffffff means fuzziest match.
1021  */
1022 struct rte_flow_item_fuzzy {
1023         uint32_t thresh; /**< Accuracy threshold. */
1024 };
1025
1026 /** Default mask for RTE_FLOW_ITEM_TYPE_FUZZY. */
1027 #ifndef __cplusplus
1028 static const struct rte_flow_item_fuzzy rte_flow_item_fuzzy_mask = {
1029         .thresh = 0xffffffff,
1030 };
1031 #endif
1032
1033 /**
1034  * RTE_FLOW_ITEM_TYPE_GTP.
1035  *
1036  * Matches a GTPv1 header.
1037  */
1038 struct rte_flow_item_gtp {
1039         /**
1040          * Version (3b), protocol type (1b), reserved (1b),
1041          * Extension header flag (1b),
1042          * Sequence number flag (1b),
1043          * N-PDU number flag (1b).
1044          */
1045         uint8_t v_pt_rsv_flags;
1046         uint8_t msg_type; /**< Message type. */
1047         rte_be16_t msg_len; /**< Message length. */
1048         rte_be32_t teid; /**< Tunnel endpoint identifier. */
1049 };
1050
1051 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP. */
1052 #ifndef __cplusplus
1053 static const struct rte_flow_item_gtp rte_flow_item_gtp_mask = {
1054         .teid = RTE_BE32(0xffffffff),
1055 };
1056 #endif
1057
1058 /**
1059  * RTE_FLOW_ITEM_TYPE_ESP
1060  *
1061  * Matches an ESP header.
1062  */
1063 struct rte_flow_item_esp {
1064         struct rte_esp_hdr hdr; /**< ESP header definition. */
1065 };
1066
1067 /** Default mask for RTE_FLOW_ITEM_TYPE_ESP. */
1068 #ifndef __cplusplus
1069 static const struct rte_flow_item_esp rte_flow_item_esp_mask = {
1070         .hdr = {
1071                 .spi = RTE_BE32(0xffffffff),
1072         },
1073 };
1074 #endif
1075
1076 /**
1077  * RTE_FLOW_ITEM_TYPE_GENEVE.
1078  *
1079  * Matches a GENEVE header.
1080  */
1081 struct rte_flow_item_geneve {
1082         /**
1083          * Version (2b), length of the options fields (6b), OAM packet (1b),
1084          * critical options present (1b), reserved 0 (6b).
1085          */
1086         rte_be16_t ver_opt_len_o_c_rsvd0;
1087         rte_be16_t protocol; /**< Protocol type. */
1088         uint8_t vni[3]; /**< Virtual Network Identifier. */
1089         uint8_t rsvd1; /**< Reserved, normally 0x00. */
1090 };
1091
1092 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE. */
1093 #ifndef __cplusplus
1094 static const struct rte_flow_item_geneve rte_flow_item_geneve_mask = {
1095         .vni = "\xff\xff\xff",
1096 };
1097 #endif
1098
1099 /**
1100  * RTE_FLOW_ITEM_TYPE_VXLAN_GPE (draft-ietf-nvo3-vxlan-gpe-05).
1101  *
1102  * Matches a VXLAN-GPE header.
1103  */
1104 struct rte_flow_item_vxlan_gpe {
1105         uint8_t flags; /**< Normally 0x0c (I and P flags). */
1106         uint8_t rsvd0[2]; /**< Reserved, normally 0x0000. */
1107         uint8_t protocol; /**< Protocol type. */
1108         uint8_t vni[3]; /**< VXLAN identifier. */
1109         uint8_t rsvd1; /**< Reserved, normally 0x00. */
1110 };
1111
1112 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN_GPE. */
1113 #ifndef __cplusplus
1114 static const struct rte_flow_item_vxlan_gpe rte_flow_item_vxlan_gpe_mask = {
1115         .vni = "\xff\xff\xff",
1116 };
1117 #endif
1118
1119 /**
1120  * RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4
1121  *
1122  * Matches an ARP header for Ethernet/IPv4.
1123  */
1124 struct rte_flow_item_arp_eth_ipv4 {
1125         rte_be16_t hrd; /**< Hardware type, normally 1. */
1126         rte_be16_t pro; /**< Protocol type, normally 0x0800. */
1127         uint8_t hln; /**< Hardware address length, normally 6. */
1128         uint8_t pln; /**< Protocol address length, normally 4. */
1129         rte_be16_t op; /**< Opcode (1 for request, 2 for reply). */
1130         struct rte_ether_addr sha; /**< Sender hardware address. */
1131         rte_be32_t spa; /**< Sender IPv4 address. */
1132         struct rte_ether_addr tha; /**< Target hardware address. */
1133         rte_be32_t tpa; /**< Target IPv4 address. */
1134 };
1135
1136 /** Default mask for RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4. */
1137 #ifndef __cplusplus
1138 static const struct rte_flow_item_arp_eth_ipv4
1139 rte_flow_item_arp_eth_ipv4_mask = {
1140         .sha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1141         .spa = RTE_BE32(0xffffffff),
1142         .tha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1143         .tpa = RTE_BE32(0xffffffff),
1144 };
1145 #endif
1146
1147 /**
1148  * RTE_FLOW_ITEM_TYPE_IPV6_EXT
1149  *
1150  * Matches the presence of any IPv6 extension header.
1151  *
1152  * Normally preceded by any of:
1153  *
1154  * - RTE_FLOW_ITEM_TYPE_IPV6
1155  * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1156  */
1157 struct rte_flow_item_ipv6_ext {
1158         uint8_t next_hdr; /**< Next header. */
1159 };
1160
1161 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6_EXT. */
1162 #ifndef __cplusplus
1163 static const
1164 struct rte_flow_item_ipv6_ext rte_flow_item_ipv6_ext_mask = {
1165         .next_hdr = 0xff,
1166 };
1167 #endif
1168
1169 /**
1170  * RTE_FLOW_ITEM_TYPE_ICMP6
1171  *
1172  * Matches any ICMPv6 header.
1173  */
1174 struct rte_flow_item_icmp6 {
1175         uint8_t type; /**< ICMPv6 type. */
1176         uint8_t code; /**< ICMPv6 code. */
1177         uint16_t checksum; /**< ICMPv6 checksum. */
1178 };
1179
1180 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6. */
1181 #ifndef __cplusplus
1182 static const struct rte_flow_item_icmp6 rte_flow_item_icmp6_mask = {
1183         .type = 0xff,
1184         .code = 0xff,
1185 };
1186 #endif
1187
1188 /**
1189  * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1190  *
1191  * Matches an ICMPv6 neighbor discovery solicitation.
1192  */
1193 struct rte_flow_item_icmp6_nd_ns {
1194         uint8_t type; /**< ICMPv6 type, normally 135. */
1195         uint8_t code; /**< ICMPv6 code, normally 0. */
1196         rte_be16_t checksum; /**< ICMPv6 checksum. */
1197         rte_be32_t reserved; /**< Reserved, normally 0. */
1198         uint8_t target_addr[16]; /**< Target address. */
1199 };
1200
1201 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS. */
1202 #ifndef __cplusplus
1203 static const
1204 struct rte_flow_item_icmp6_nd_ns rte_flow_item_icmp6_nd_ns_mask = {
1205         .target_addr =
1206                 "\xff\xff\xff\xff\xff\xff\xff\xff"
1207                 "\xff\xff\xff\xff\xff\xff\xff\xff",
1208 };
1209 #endif
1210
1211 /**
1212  * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1213  *
1214  * Matches an ICMPv6 neighbor discovery advertisement.
1215  */
1216 struct rte_flow_item_icmp6_nd_na {
1217         uint8_t type; /**< ICMPv6 type, normally 136. */
1218         uint8_t code; /**< ICMPv6 code, normally 0. */
1219         rte_be16_t checksum; /**< ICMPv6 checksum. */
1220         /**
1221          * Route flag (1b), solicited flag (1b), override flag (1b),
1222          * reserved (29b).
1223          */
1224         rte_be32_t rso_reserved;
1225         uint8_t target_addr[16]; /**< Target address. */
1226 };
1227
1228 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA. */
1229 #ifndef __cplusplus
1230 static const
1231 struct rte_flow_item_icmp6_nd_na rte_flow_item_icmp6_nd_na_mask = {
1232         .target_addr =
1233                 "\xff\xff\xff\xff\xff\xff\xff\xff"
1234                 "\xff\xff\xff\xff\xff\xff\xff\xff",
1235 };
1236 #endif
1237
1238 /**
1239  * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1240  *
1241  * Matches the presence of any ICMPv6 neighbor discovery option.
1242  *
1243  * Normally preceded by any of:
1244  *
1245  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1246  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1247  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1248  */
1249 struct rte_flow_item_icmp6_nd_opt {
1250         uint8_t type; /**< ND option type. */
1251         uint8_t length; /**< ND option length. */
1252 };
1253
1254 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT. */
1255 #ifndef __cplusplus
1256 static const struct rte_flow_item_icmp6_nd_opt
1257 rte_flow_item_icmp6_nd_opt_mask = {
1258         .type = 0xff,
1259 };
1260 #endif
1261
1262 /**
1263  * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH
1264  *
1265  * Matches an ICMPv6 neighbor discovery source Ethernet link-layer address
1266  * option.
1267  *
1268  * Normally preceded by any of:
1269  *
1270  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1271  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1272  */
1273 struct rte_flow_item_icmp6_nd_opt_sla_eth {
1274         uint8_t type; /**< ND option type, normally 1. */
1275         uint8_t length; /**< ND option length, normally 1. */
1276         struct rte_ether_addr sla; /**< Source Ethernet LLA. */
1277 };
1278
1279 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH. */
1280 #ifndef __cplusplus
1281 static const struct rte_flow_item_icmp6_nd_opt_sla_eth
1282 rte_flow_item_icmp6_nd_opt_sla_eth_mask = {
1283         .sla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1284 };
1285 #endif
1286
1287 /**
1288  * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH
1289  *
1290  * Matches an ICMPv6 neighbor discovery target Ethernet link-layer address
1291  * option.
1292  *
1293  * Normally preceded by any of:
1294  *
1295  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1296  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1297  */
1298 struct rte_flow_item_icmp6_nd_opt_tla_eth {
1299         uint8_t type; /**< ND option type, normally 2. */
1300         uint8_t length; /**< ND option length, normally 1. */
1301         struct rte_ether_addr tla; /**< Target Ethernet LLA. */
1302 };
1303
1304 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH. */
1305 #ifndef __cplusplus
1306 static const struct rte_flow_item_icmp6_nd_opt_tla_eth
1307 rte_flow_item_icmp6_nd_opt_tla_eth_mask = {
1308         .tla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1309 };
1310 #endif
1311
1312 /**
1313  * RTE_FLOW_ITEM_TYPE_META
1314  *
1315  * Matches a specified metadata value. On egress, metadata can be set
1316  * either by mbuf dynamic metadata field with PKT_TX_DYNF_METADATA flag or
1317  * RTE_FLOW_ACTION_TYPE_SET_META. On ingress, RTE_FLOW_ACTION_TYPE_SET_META
1318  * sets metadata for a packet and the metadata will be reported via mbuf
1319  * metadata dynamic field with PKT_RX_DYNF_METADATA flag. The dynamic mbuf
1320  * field must be registered in advance by rte_flow_dynf_metadata_register().
1321  */
1322 struct rte_flow_item_meta {
1323         uint32_t data;
1324 };
1325
1326 /** Default mask for RTE_FLOW_ITEM_TYPE_META. */
1327 #ifndef __cplusplus
1328 static const struct rte_flow_item_meta rte_flow_item_meta_mask = {
1329         .data = UINT32_MAX,
1330 };
1331 #endif
1332
1333 /**
1334  * RTE_FLOW_ITEM_TYPE_GTP_PSC.
1335  *
1336  * Matches a GTP PDU extension header with type 0x85.
1337  */
1338 struct rte_flow_item_gtp_psc {
1339         uint8_t pdu_type; /**< PDU type. */
1340         uint8_t qfi; /**< QoS flow identifier. */
1341 };
1342
1343 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP_PSC. */
1344 #ifndef __cplusplus
1345 static const struct rte_flow_item_gtp_psc
1346 rte_flow_item_gtp_psc_mask = {
1347         .qfi = 0x3f,
1348 };
1349 #endif
1350
1351 /**
1352  * RTE_FLOW_ITEM_TYPE_PPPOE.
1353  *
1354  * Matches a PPPoE header.
1355  */
1356 struct rte_flow_item_pppoe {
1357         /**
1358          * Version (4b), type (4b).
1359          */
1360         uint8_t version_type;
1361         uint8_t code; /**< Message type. */
1362         rte_be16_t session_id; /**< Session identifier. */
1363         rte_be16_t length; /**< Payload length. */
1364 };
1365
1366 /**
1367  * RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID.
1368  *
1369  * Matches a PPPoE optional proto_id field.
1370  *
1371  * It only applies to PPPoE session packets.
1372  *
1373  * Normally preceded by any of:
1374  *
1375  * - RTE_FLOW_ITEM_TYPE_PPPOE
1376  * - RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID
1377  */
1378 struct rte_flow_item_pppoe_proto_id {
1379         rte_be16_t proto_id; /**< PPP protocol identifier. */
1380 };
1381
1382 /** Default mask for RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID. */
1383 #ifndef __cplusplus
1384 static const struct rte_flow_item_pppoe_proto_id
1385 rte_flow_item_pppoe_proto_id_mask = {
1386         .proto_id = RTE_BE16(0xffff),
1387 };
1388 #endif
1389
1390 /**
1391  * @warning
1392  * @b EXPERIMENTAL: this structure may change without prior notice
1393  *
1394  * RTE_FLOW_ITEM_TYPE_TAG
1395  *
1396  * Matches a specified tag value at the specified index.
1397  */
1398 struct rte_flow_item_tag {
1399         uint32_t data;
1400         uint8_t index;
1401 };
1402
1403 /** Default mask for RTE_FLOW_ITEM_TYPE_TAG. */
1404 #ifndef __cplusplus
1405 static const struct rte_flow_item_tag rte_flow_item_tag_mask = {
1406         .data = 0xffffffff,
1407         .index = 0xff,
1408 };
1409 #endif
1410
1411 /**
1412  * RTE_FLOW_ITEM_TYPE_L2TPV3OIP.
1413  *
1414  * Matches a L2TPv3 over IP header.
1415  */
1416 struct rte_flow_item_l2tpv3oip {
1417         rte_be32_t session_id; /**< Session ID. */
1418 };
1419
1420 /** Default mask for RTE_FLOW_ITEM_TYPE_L2TPV3OIP. */
1421 #ifndef __cplusplus
1422 static const struct rte_flow_item_l2tpv3oip rte_flow_item_l2tpv3oip_mask = {
1423         .session_id = RTE_BE32(UINT32_MAX),
1424 };
1425 #endif
1426
1427
1428 /**
1429  * @warning
1430  * @b EXPERIMENTAL: this structure may change without prior notice
1431  *
1432  * RTE_FLOW_ITEM_TYPE_MARK
1433  *
1434  * Matches an arbitrary integer value which was set using the ``MARK`` action
1435  * in a previously matched rule.
1436  *
1437  * This item can only be specified once as a match criteria as the ``MARK``
1438  * action can only be specified once in a flow action.
1439  *
1440  * This value is arbitrary and application-defined. Maximum allowed value
1441  * depends on the underlying implementation.
1442  *
1443  * Depending on the underlying implementation the MARK item may be supported on
1444  * the physical device, with virtual groups in the PMD or not at all.
1445  */
1446 struct rte_flow_item_mark {
1447         uint32_t id; /**< Integer value to match against. */
1448 };
1449
1450 /** Default mask for RTE_FLOW_ITEM_TYPE_MARK. */
1451 #ifndef __cplusplus
1452 static const struct rte_flow_item_mark rte_flow_item_mark_mask = {
1453         .id = 0xffffffff,
1454 };
1455 #endif
1456
1457 /**
1458  * @warning
1459  * @b EXPERIMENTAL: this structure may change without prior notice
1460  *
1461  * RTE_FLOW_ITEM_TYPE_NSH
1462  *
1463  * Match network service header (NSH), RFC 8300
1464  *
1465  */
1466 struct rte_flow_item_nsh {
1467         uint32_t version:2;
1468         uint32_t oam_pkt:1;
1469         uint32_t reserved:1;
1470         uint32_t ttl:6;
1471         uint32_t length:6;
1472         uint32_t reserved1:4;
1473         uint32_t mdtype:4;
1474         uint32_t next_proto:8;
1475         uint32_t spi:24;
1476         uint32_t sindex:8;
1477 };
1478
1479 /** Default mask for RTE_FLOW_ITEM_TYPE_NSH. */
1480 #ifndef __cplusplus
1481 static const struct rte_flow_item_nsh rte_flow_item_nsh_mask = {
1482         .mdtype = 0xf,
1483         .next_proto = 0xff,
1484         .spi = 0xffffff,
1485         .sindex = 0xff,
1486 };
1487 #endif
1488
1489 /**
1490  * @warning
1491  * @b EXPERIMENTAL: this structure may change without prior notice
1492  *
1493  * RTE_FLOW_ITEM_TYPE_IGMP
1494  *
1495  * Match Internet Group Management Protocol (IGMP), RFC 2236
1496  *
1497  */
1498 struct rte_flow_item_igmp {
1499         uint32_t type:8;
1500         uint32_t max_resp_time:8;
1501         uint32_t checksum:16;
1502         uint32_t group_addr;
1503 };
1504
1505 /** Default mask for RTE_FLOW_ITEM_TYPE_IGMP. */
1506 #ifndef __cplusplus
1507 static const struct rte_flow_item_igmp rte_flow_item_igmp_mask = {
1508         .group_addr = 0xffffffff,
1509 };
1510 #endif
1511
1512 /**
1513  * @warning
1514  * @b EXPERIMENTAL: this structure may change without prior notice
1515  *
1516  * RTE_FLOW_ITEM_TYPE_AH
1517  *
1518  * Match IP Authentication Header (AH), RFC 4302
1519  *
1520  */
1521 struct rte_flow_item_ah {
1522         uint32_t next_hdr:8;
1523         uint32_t payload_len:8;
1524         uint32_t reserved:16;
1525         uint32_t spi;
1526         uint32_t seq_num;
1527 };
1528
1529 /** Default mask for RTE_FLOW_ITEM_TYPE_AH. */
1530 #ifndef __cplusplus
1531 static const struct rte_flow_item_ah rte_flow_item_ah_mask = {
1532         .spi = 0xffffffff,
1533 };
1534 #endif
1535
1536 /**
1537  * @warning
1538  * @b EXPERIMENTAL: this structure may change without prior notice
1539  *
1540  * RTE_FLOW_ITEM_TYPE_PFCP
1541  *
1542  * Match PFCP Header
1543  */
1544 struct rte_flow_item_pfcp {
1545         uint8_t s_field;
1546         uint8_t msg_type;
1547         rte_be16_t msg_len;
1548         rte_be64_t seid;
1549 };
1550
1551 /** Default mask for RTE_FLOW_ITEM_TYPE_PFCP. */
1552 #ifndef __cplusplus
1553 static const struct rte_flow_item_pfcp rte_flow_item_pfcp_mask = {
1554         .s_field = 0x01,
1555         .seid = RTE_BE64(UINT64_C(0xffffffffffffffff)),
1556 };
1557 #endif
1558
1559 /**
1560  * @warning
1561  * @b EXPERIMENTAL: this structure may change without prior notice
1562  *
1563  * RTE_FLOW_ITEM_TYPE_ECPRI
1564  *
1565  * Match eCPRI Header
1566  */
1567 struct rte_flow_item_ecpri {
1568         struct rte_ecpri_combined_msg_hdr hdr;
1569 };
1570
1571 /** Default mask for RTE_FLOW_ITEM_TYPE_ECPRI. */
1572 #ifndef __cplusplus
1573 static const struct rte_flow_item_ecpri rte_flow_item_ecpri_mask = {
1574         .hdr = {
1575                 .common = {
1576                         .u32 = 0x0,
1577                 },
1578         },
1579 };
1580 #endif
1581
1582 /**
1583  * Matching pattern item definition.
1584  *
1585  * A pattern is formed by stacking items starting from the lowest protocol
1586  * layer to match. This stacking restriction does not apply to meta items
1587  * which can be placed anywhere in the stack without affecting the meaning
1588  * of the resulting pattern.
1589  *
1590  * Patterns are terminated by END items.
1591  *
1592  * The spec field should be a valid pointer to a structure of the related
1593  * item type. It may remain unspecified (NULL) in many cases to request
1594  * broad (nonspecific) matching. In such cases, last and mask must also be
1595  * set to NULL.
1596  *
1597  * Optionally, last can point to a structure of the same type to define an
1598  * inclusive range. This is mostly supported by integer and address fields,
1599  * may cause errors otherwise. Fields that do not support ranges must be set
1600  * to 0 or to the same value as the corresponding fields in spec.
1601  *
1602  * Only the fields defined to nonzero values in the default masks (see
1603  * rte_flow_item_{name}_mask constants) are considered relevant by
1604  * default. This can be overridden by providing a mask structure of the
1605  * same type with applicable bits set to one. It can also be used to
1606  * partially filter out specific fields (e.g. as an alternate mean to match
1607  * ranges of IP addresses).
1608  *
1609  * Mask is a simple bit-mask applied before interpreting the contents of
1610  * spec and last, which may yield unexpected results if not used
1611  * carefully. For example, if for an IPv4 address field, spec provides
1612  * 10.1.2.3, last provides 10.3.4.5 and mask provides 255.255.0.0, the
1613  * effective range becomes 10.1.0.0 to 10.3.255.255.
1614  */
1615 struct rte_flow_item {
1616         enum rte_flow_item_type type; /**< Item type. */
1617         const void *spec; /**< Pointer to item specification structure. */
1618         const void *last; /**< Defines an inclusive range (spec to last). */
1619         const void *mask; /**< Bit-mask applied to spec and last. */
1620 };
1621
1622 /**
1623  * Action types.
1624  *
1625  * Each possible action is represented by a type.
1626  * An action can have an associated configuration object.
1627  * Several actions combined in a list can be assigned
1628  * to a flow rule and are performed in order.
1629  *
1630  * They fall in three categories:
1631  *
1632  * - Actions that modify the fate of matching traffic, for instance by
1633  *   dropping or assigning it a specific destination.
1634  *
1635  * - Actions that modify matching traffic contents or its properties. This
1636  *   includes adding/removing encapsulation, encryption, compression and
1637  *   marks.
1638  *
1639  * - Actions related to the flow rule itself, such as updating counters or
1640  *   making it non-terminating.
1641  *
1642  * Flow rules being terminating by default, not specifying any action of the
1643  * fate kind results in undefined behavior. This applies to both ingress and
1644  * egress.
1645  *
1646  * PASSTHRU, when supported, makes a flow rule non-terminating.
1647  */
1648 enum rte_flow_action_type {
1649         /**
1650          * End marker for action lists. Prevents further processing of
1651          * actions, thereby ending the list.
1652          *
1653          * No associated configuration structure.
1654          */
1655         RTE_FLOW_ACTION_TYPE_END,
1656
1657         /**
1658          * Used as a placeholder for convenience. It is ignored and simply
1659          * discarded by PMDs.
1660          *
1661          * No associated configuration structure.
1662          */
1663         RTE_FLOW_ACTION_TYPE_VOID,
1664
1665         /**
1666          * Leaves traffic up for additional processing by subsequent flow
1667          * rules; makes a flow rule non-terminating.
1668          *
1669          * No associated configuration structure.
1670          */
1671         RTE_FLOW_ACTION_TYPE_PASSTHRU,
1672
1673         /**
1674          * RTE_FLOW_ACTION_TYPE_JUMP
1675          *
1676          * Redirects packets to a group on the current device.
1677          *
1678          * See struct rte_flow_action_jump.
1679          */
1680         RTE_FLOW_ACTION_TYPE_JUMP,
1681
1682         /**
1683          * Attaches an integer value to packets and sets PKT_RX_FDIR and
1684          * PKT_RX_FDIR_ID mbuf flags.
1685          *
1686          * See struct rte_flow_action_mark.
1687          */
1688         RTE_FLOW_ACTION_TYPE_MARK,
1689
1690         /**
1691          * Flags packets. Similar to MARK without a specific value; only
1692          * sets the PKT_RX_FDIR mbuf flag.
1693          *
1694          * No associated configuration structure.
1695          */
1696         RTE_FLOW_ACTION_TYPE_FLAG,
1697
1698         /**
1699          * Assigns packets to a given queue index.
1700          *
1701          * See struct rte_flow_action_queue.
1702          */
1703         RTE_FLOW_ACTION_TYPE_QUEUE,
1704
1705         /**
1706          * Drops packets.
1707          *
1708          * PASSTHRU overrides this action if both are specified.
1709          *
1710          * No associated configuration structure.
1711          */
1712         RTE_FLOW_ACTION_TYPE_DROP,
1713
1714         /**
1715          * Enables counters for this flow rule.
1716          *
1717          * These counters can be retrieved and reset through rte_flow_query() or
1718          * rte_flow_shared_action_query() if the action provided via handle,
1719          * see struct rte_flow_query_count.
1720          *
1721          * See struct rte_flow_action_count.
1722          */
1723         RTE_FLOW_ACTION_TYPE_COUNT,
1724
1725         /**
1726          * Similar to QUEUE, except RSS is additionally performed on packets
1727          * to spread them among several queues according to the provided
1728          * parameters.
1729          *
1730          * See struct rte_flow_action_rss.
1731          */
1732         RTE_FLOW_ACTION_TYPE_RSS,
1733
1734         /**
1735          * Directs matching traffic to the physical function (PF) of the
1736          * current device.
1737          *
1738          * No associated configuration structure.
1739          */
1740         RTE_FLOW_ACTION_TYPE_PF,
1741
1742         /**
1743          * Directs matching traffic to a given virtual function of the
1744          * current device.
1745          *
1746          * See struct rte_flow_action_vf.
1747          */
1748         RTE_FLOW_ACTION_TYPE_VF,
1749
1750         /**
1751          * Directs packets to a given physical port index of the underlying
1752          * device.
1753          *
1754          * See struct rte_flow_action_phy_port.
1755          */
1756         RTE_FLOW_ACTION_TYPE_PHY_PORT,
1757
1758         /**
1759          * Directs matching traffic to a given DPDK port ID.
1760          *
1761          * See struct rte_flow_action_port_id.
1762          */
1763         RTE_FLOW_ACTION_TYPE_PORT_ID,
1764
1765         /**
1766          * Traffic metering and policing (MTR).
1767          *
1768          * See struct rte_flow_action_meter.
1769          * See file rte_mtr.h for MTR object configuration.
1770          */
1771         RTE_FLOW_ACTION_TYPE_METER,
1772
1773         /**
1774          * Redirects packets to security engine of current device for security
1775          * processing as specified by security session.
1776          *
1777          * See struct rte_flow_action_security.
1778          */
1779         RTE_FLOW_ACTION_TYPE_SECURITY,
1780
1781         /**
1782          * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the
1783          * OpenFlow Switch Specification.
1784          *
1785          * See struct rte_flow_action_of_set_mpls_ttl.
1786          */
1787         RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL,
1788
1789         /**
1790          * Implements OFPAT_DEC_MPLS_TTL ("decrement MPLS TTL") as defined
1791          * by the OpenFlow Switch Specification.
1792          *
1793          * No associated configuration structure.
1794          */
1795         RTE_FLOW_ACTION_TYPE_OF_DEC_MPLS_TTL,
1796
1797         /**
1798          * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow
1799          * Switch Specification.
1800          *
1801          * See struct rte_flow_action_of_set_nw_ttl.
1802          */
1803         RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL,
1804
1805         /**
1806          * Implements OFPAT_DEC_NW_TTL ("decrement IP TTL") as defined by
1807          * the OpenFlow Switch Specification.
1808          *
1809          * No associated configuration structure.
1810          */
1811         RTE_FLOW_ACTION_TYPE_OF_DEC_NW_TTL,
1812
1813         /**
1814          * Implements OFPAT_COPY_TTL_OUT ("copy TTL "outwards" -- from
1815          * next-to-outermost to outermost") as defined by the OpenFlow
1816          * Switch Specification.
1817          *
1818          * No associated configuration structure.
1819          */
1820         RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_OUT,
1821
1822         /**
1823          * Implements OFPAT_COPY_TTL_IN ("copy TTL "inwards" -- from
1824          * outermost to next-to-outermost") as defined by the OpenFlow
1825          * Switch Specification.
1826          *
1827          * No associated configuration structure.
1828          */
1829         RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_IN,
1830
1831         /**
1832          * Implements OFPAT_POP_VLAN ("pop the outer VLAN tag") as defined
1833          * by the OpenFlow Switch Specification.
1834          *
1835          * No associated configuration structure.
1836          */
1837         RTE_FLOW_ACTION_TYPE_OF_POP_VLAN,
1838
1839         /**
1840          * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by
1841          * the OpenFlow Switch Specification.
1842          *
1843          * See struct rte_flow_action_of_push_vlan.
1844          */
1845         RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
1846
1847         /**
1848          * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as
1849          * defined by the OpenFlow Switch Specification.
1850          *
1851          * See struct rte_flow_action_of_set_vlan_vid.
1852          */
1853         RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
1854
1855         /**
1856          * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as
1857          * defined by the OpenFlow Switch Specification.
1858          *
1859          * See struct rte_flow_action_of_set_vlan_pcp.
1860          */
1861         RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
1862
1863         /**
1864          * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined
1865          * by the OpenFlow Switch Specification.
1866          *
1867          * See struct rte_flow_action_of_pop_mpls.
1868          */
1869         RTE_FLOW_ACTION_TYPE_OF_POP_MPLS,
1870
1871         /**
1872          * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by
1873          * the OpenFlow Switch Specification.
1874          *
1875          * See struct rte_flow_action_of_push_mpls.
1876          */
1877         RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS,
1878
1879         /**
1880          * Encapsulate flow in VXLAN tunnel as defined in
1881          * rte_flow_action_vxlan_encap action structure.
1882          *
1883          * See struct rte_flow_action_vxlan_encap.
1884          */
1885         RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP,
1886
1887         /**
1888          * Decapsulate outer most VXLAN tunnel from matched flow.
1889          *
1890          * If flow pattern does not define a valid VXLAN tunnel (as specified by
1891          * RFC7348) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
1892          * error.
1893          */
1894         RTE_FLOW_ACTION_TYPE_VXLAN_DECAP,
1895
1896         /**
1897          * Encapsulate flow in NVGRE tunnel defined in the
1898          * rte_flow_action_nvgre_encap action structure.
1899          *
1900          * See struct rte_flow_action_nvgre_encap.
1901          */
1902         RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP,
1903
1904         /**
1905          * Decapsulate outer most NVGRE tunnel from matched flow.
1906          *
1907          * If flow pattern does not define a valid NVGRE tunnel (as specified by
1908          * RFC7637) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
1909          * error.
1910          */
1911         RTE_FLOW_ACTION_TYPE_NVGRE_DECAP,
1912
1913         /**
1914          * Add outer header whose template is provided in its data buffer
1915          *
1916          * See struct rte_flow_action_raw_encap.
1917          */
1918         RTE_FLOW_ACTION_TYPE_RAW_ENCAP,
1919
1920         /**
1921          * Remove outer header whose template is provided in its data buffer.
1922          *
1923          * See struct rte_flow_action_raw_decap
1924          */
1925         RTE_FLOW_ACTION_TYPE_RAW_DECAP,
1926
1927         /**
1928          * Modify IPv4 source address in the outermost IPv4 header.
1929          *
1930          * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
1931          * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1932          *
1933          * See struct rte_flow_action_set_ipv4.
1934          */
1935         RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC,
1936
1937         /**
1938          * Modify IPv4 destination address in the outermost IPv4 header.
1939          *
1940          * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
1941          * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1942          *
1943          * See struct rte_flow_action_set_ipv4.
1944          */
1945         RTE_FLOW_ACTION_TYPE_SET_IPV4_DST,
1946
1947         /**
1948          * Modify IPv6 source address in the outermost IPv6 header.
1949          *
1950          * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
1951          * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1952          *
1953          * See struct rte_flow_action_set_ipv6.
1954          */
1955         RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC,
1956
1957         /**
1958          * Modify IPv6 destination address in the outermost IPv6 header.
1959          *
1960          * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
1961          * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1962          *
1963          * See struct rte_flow_action_set_ipv6.
1964          */
1965         RTE_FLOW_ACTION_TYPE_SET_IPV6_DST,
1966
1967         /**
1968          * Modify source port number in the outermost TCP/UDP header.
1969          *
1970          * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
1971          * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
1972          * RTE_FLOW_ERROR_TYPE_ACTION error.
1973          *
1974          * See struct rte_flow_action_set_tp.
1975          */
1976         RTE_FLOW_ACTION_TYPE_SET_TP_SRC,
1977
1978         /**
1979          * Modify destination port number in the outermost TCP/UDP header.
1980          *
1981          * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
1982          * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
1983          * RTE_FLOW_ERROR_TYPE_ACTION error.
1984          *
1985          * See struct rte_flow_action_set_tp.
1986          */
1987         RTE_FLOW_ACTION_TYPE_SET_TP_DST,
1988
1989         /**
1990          * Swap the source and destination MAC addresses in the outermost
1991          * Ethernet header.
1992          *
1993          * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
1994          * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
1995          *
1996          * No associated configuration structure.
1997          */
1998         RTE_FLOW_ACTION_TYPE_MAC_SWAP,
1999
2000         /**
2001          * Decrease TTL value directly
2002          *
2003          * No associated configuration structure.
2004          */
2005         RTE_FLOW_ACTION_TYPE_DEC_TTL,
2006
2007         /**
2008          * Set TTL value
2009          *
2010          * See struct rte_flow_action_set_ttl
2011          */
2012         RTE_FLOW_ACTION_TYPE_SET_TTL,
2013
2014         /**
2015          * Set source MAC address from matched flow.
2016          *
2017          * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2018          * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2019          *
2020          * See struct rte_flow_action_set_mac.
2021          */
2022         RTE_FLOW_ACTION_TYPE_SET_MAC_SRC,
2023
2024         /**
2025          * Set destination MAC address from matched flow.
2026          *
2027          * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2028          * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2029          *
2030          * See struct rte_flow_action_set_mac.
2031          */
2032         RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
2033
2034         /**
2035          * Increase sequence number in the outermost TCP header.
2036          *
2037          * Action configuration specifies the value to increase
2038          * TCP sequence number as a big-endian 32 bit integer.
2039          *
2040          * @p conf type:
2041          * @code rte_be32_t * @endcode
2042          *
2043          * Using this action on non-matching traffic will result in
2044          * undefined behavior.
2045          */
2046         RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
2047
2048         /**
2049          * Decrease sequence number in the outermost TCP header.
2050          *
2051          * Action configuration specifies the value to decrease
2052          * TCP sequence number as a big-endian 32 bit integer.
2053          *
2054          * @p conf type:
2055          * @code rte_be32_t * @endcode
2056          *
2057          * Using this action on non-matching traffic will result in
2058          * undefined behavior.
2059          */
2060         RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
2061
2062         /**
2063          * Increase acknowledgment number in the outermost TCP header.
2064          *
2065          * Action configuration specifies the value to increase
2066          * TCP acknowledgment number as a big-endian 32 bit integer.
2067          *
2068          * @p conf type:
2069          * @code rte_be32_t * @endcode
2070
2071          * Using this action on non-matching traffic will result in
2072          * undefined behavior.
2073          */
2074         RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
2075
2076         /**
2077          * Decrease acknowledgment number in the outermost TCP header.
2078          *
2079          * Action configuration specifies the value to decrease
2080          * TCP acknowledgment number as a big-endian 32 bit integer.
2081          *
2082          * @p conf type:
2083          * @code rte_be32_t * @endcode
2084          *
2085          * Using this action on non-matching traffic will result in
2086          * undefined behavior.
2087          */
2088         RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
2089
2090         /**
2091          * Set Tag.
2092          *
2093          * Tag is for internal flow usage only and
2094          * is not delivered to the application.
2095          *
2096          * See struct rte_flow_action_set_tag.
2097          */
2098         RTE_FLOW_ACTION_TYPE_SET_TAG,
2099
2100         /**
2101          * Set metadata on ingress or egress path.
2102          *
2103          * See struct rte_flow_action_set_meta.
2104          */
2105         RTE_FLOW_ACTION_TYPE_SET_META,
2106
2107         /**
2108          * Modify IPv4 DSCP in the outermost IP header.
2109          *
2110          * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2111          * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2112          *
2113          * See struct rte_flow_action_set_dscp.
2114          */
2115         RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP,
2116
2117         /**
2118          * Modify IPv6 DSCP in the outermost IP header.
2119          *
2120          * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2121          * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2122          *
2123          * See struct rte_flow_action_set_dscp.
2124          */
2125         RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP,
2126
2127         /**
2128          * Report as aged flow if timeout passed without any matching on the
2129          * flow.
2130          *
2131          * See struct rte_flow_action_age.
2132          * See function rte_flow_get_aged_flows
2133          * see enum RTE_ETH_EVENT_FLOW_AGED
2134          * See struct rte_flow_query_age
2135          */
2136         RTE_FLOW_ACTION_TYPE_AGE,
2137
2138         /**
2139          * The matching packets will be duplicated with specified ratio and
2140          * applied with own set of actions with a fate action.
2141          *
2142          * See struct rte_flow_action_sample.
2143          */
2144         RTE_FLOW_ACTION_TYPE_SAMPLE,
2145
2146         /**
2147          * Describe action shared across multiple flow rules.
2148          *
2149          * Allow multiple rules reference the same action by handle (see
2150          * struct rte_flow_shared_action).
2151          */
2152         RTE_FLOW_ACTION_TYPE_SHARED,
2153 };
2154
2155 /**
2156  * RTE_FLOW_ACTION_TYPE_MARK
2157  *
2158  * Attaches an integer value to packets and sets PKT_RX_FDIR and
2159  * PKT_RX_FDIR_ID mbuf flags.
2160  *
2161  * This value is arbitrary and application-defined. Maximum allowed value
2162  * depends on the underlying implementation. It is returned in the
2163  * hash.fdir.hi mbuf field.
2164  */
2165 struct rte_flow_action_mark {
2166         uint32_t id; /**< Integer value to return with packets. */
2167 };
2168
2169 /**
2170  * @warning
2171  * @b EXPERIMENTAL: this structure may change without prior notice
2172  *
2173  * RTE_FLOW_ACTION_TYPE_JUMP
2174  *
2175  * Redirects packets to a group on the current device.
2176  *
2177  * In a hierarchy of groups, which can be used to represent physical or logical
2178  * flow tables on the device, this action allows the action to be a redirect to
2179  * a group on that device.
2180  */
2181 struct rte_flow_action_jump {
2182         uint32_t group;
2183 };
2184
2185 /**
2186  * RTE_FLOW_ACTION_TYPE_QUEUE
2187  *
2188  * Assign packets to a given queue index.
2189  */
2190 struct rte_flow_action_queue {
2191         uint16_t index; /**< Queue index to use. */
2192 };
2193
2194 /**
2195  * @warning
2196  * @b EXPERIMENTAL: this structure may change without prior notice
2197  *
2198  * RTE_FLOW_ACTION_TYPE_AGE
2199  *
2200  * Report flow as aged-out if timeout passed without any matching
2201  * on the flow. RTE_ETH_EVENT_FLOW_AGED event is triggered when a
2202  * port detects new aged-out flows.
2203  *
2204  * The flow context and the flow handle will be reported by the
2205  * rte_flow_get_aged_flows API.
2206  */
2207 struct rte_flow_action_age {
2208         uint32_t timeout:24; /**< Time in seconds. */
2209         uint32_t reserved:8; /**< Reserved, must be zero. */
2210         void *context;
2211                 /**< The user flow context, NULL means the rte_flow pointer. */
2212 };
2213
2214 /**
2215  * RTE_FLOW_ACTION_TYPE_AGE (query)
2216  *
2217  * Query structure to retrieve the aging status information of a
2218  * shared AGE action, or a flow rule using the AGE action.
2219  */
2220 struct rte_flow_query_age {
2221         uint32_t reserved:6; /**< Reserved, must be zero. */
2222         uint32_t aged:1; /**< 1 if aging timeout expired, 0 otherwise. */
2223         uint32_t sec_since_last_hit_valid:1;
2224         /**< sec_since_last_hit value is valid. */
2225         uint32_t sec_since_last_hit:24; /**< Seconds since last traffic hit. */
2226 };
2227
2228 /**
2229  * @warning
2230  * @b EXPERIMENTAL: this structure may change without prior notice
2231  *
2232  * RTE_FLOW_ACTION_TYPE_COUNT
2233  *
2234  * Adds a counter action to a matched flow.
2235  *
2236  * If more than one count action is specified in a single flow rule, then each
2237  * action must specify a unique id.
2238  *
2239  * Counters can be retrieved and reset through ``rte_flow_query()``, see
2240  * ``struct rte_flow_query_count``.
2241  *
2242  * The shared flag indicates whether the counter is unique to the flow rule the
2243  * action is specified with, or whether it is a shared counter.
2244  *
2245  * For a count action with the shared flag set, then then a global device
2246  * namespace is assumed for the counter id, so that any matched flow rules using
2247  * a count action with the same counter id on the same port will contribute to
2248  * that counter.
2249  *
2250  * For ports within the same switch domain then the counter id namespace extends
2251  * to all ports within that switch domain.
2252  */
2253 struct rte_flow_action_count {
2254         uint32_t shared:1; /**< Share counter ID with other flow rules. */
2255         uint32_t reserved:31; /**< Reserved, must be zero. */
2256         uint32_t id; /**< Counter ID. */
2257 };
2258
2259 /**
2260  * RTE_FLOW_ACTION_TYPE_COUNT (query)
2261  *
2262  * Query structure to retrieve and reset flow rule counters.
2263  */
2264 struct rte_flow_query_count {
2265         uint32_t reset:1; /**< Reset counters after query [in]. */
2266         uint32_t hits_set:1; /**< hits field is set [out]. */
2267         uint32_t bytes_set:1; /**< bytes field is set [out]. */
2268         uint32_t reserved:29; /**< Reserved, must be zero [in, out]. */
2269         uint64_t hits; /**< Number of hits for this rule [out]. */
2270         uint64_t bytes; /**< Number of bytes through this rule [out]. */
2271 };
2272
2273 /**
2274  * Hash function types.
2275  */
2276 enum rte_eth_hash_function {
2277         RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
2278         RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
2279         RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
2280         /**
2281          * Symmetric Toeplitz: src, dst will be replaced by
2282          * xor(src, dst). For the case with src/dst only,
2283          * src or dst address will xor with zero pair.
2284          */
2285         RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
2286         RTE_ETH_HASH_FUNCTION_MAX,
2287 };
2288
2289 /**
2290  * RTE_FLOW_ACTION_TYPE_RSS
2291  *
2292  * Similar to QUEUE, except RSS is additionally performed on packets to
2293  * spread them among several queues according to the provided parameters.
2294  *
2295  * Unlike global RSS settings used by other DPDK APIs, unsetting the
2296  * @p types field does not disable RSS in a flow rule. Doing so instead
2297  * requests safe unspecified "best-effort" settings from the underlying PMD,
2298  * which depending on the flow rule, may result in anything ranging from
2299  * empty (single queue) to all-inclusive RSS.
2300  *
2301  * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps
2302  * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only,
2303  * both can be requested simultaneously.
2304  */
2305 struct rte_flow_action_rss {
2306         enum rte_eth_hash_function func; /**< RSS hash function to apply. */
2307         /**
2308          * Packet encapsulation level RSS hash @p types apply to.
2309          *
2310          * - @p 0 requests the default behavior. Depending on the packet
2311          *   type, it can mean outermost, innermost, anything in between or
2312          *   even no RSS.
2313          *
2314          *   It basically stands for the innermost encapsulation level RSS
2315          *   can be performed on according to PMD and device capabilities.
2316          *
2317          * - @p 1 requests RSS to be performed on the outermost packet
2318          *   encapsulation level.
2319          *
2320          * - @p 2 and subsequent values request RSS to be performed on the
2321          *   specified inner packet encapsulation level, from outermost to
2322          *   innermost (lower to higher values).
2323          *
2324          * Values other than @p 0 are not necessarily supported.
2325          *
2326          * Requesting a specific RSS level on unrecognized traffic results
2327          * in undefined behavior. For predictable results, it is recommended
2328          * to make the flow rule pattern match packet headers up to the
2329          * requested encapsulation level so that only matching traffic goes
2330          * through.
2331          */
2332         uint32_t level;
2333         uint64_t types; /**< Specific RSS hash types (see ETH_RSS_*). */
2334         uint32_t key_len; /**< Hash key length in bytes. */
2335         uint32_t queue_num; /**< Number of entries in @p queue. */
2336         const uint8_t *key; /**< Hash key. */
2337         const uint16_t *queue; /**< Queue indices to use. */
2338 };
2339
2340 /**
2341  * RTE_FLOW_ACTION_TYPE_VF
2342  *
2343  * Directs matching traffic to a given virtual function of the current
2344  * device.
2345  *
2346  * Packets matched by a VF pattern item can be redirected to their original
2347  * VF ID instead of the specified one. This parameter may not be available
2348  * and is not guaranteed to work properly if the VF part is matched by a
2349  * prior flow rule or if packets are not addressed to a VF in the first
2350  * place.
2351  */
2352 struct rte_flow_action_vf {
2353         uint32_t original:1; /**< Use original VF ID if possible. */
2354         uint32_t reserved:31; /**< Reserved, must be zero. */
2355         uint32_t id; /**< VF ID. */
2356 };
2357
2358 /**
2359  * RTE_FLOW_ACTION_TYPE_PHY_PORT
2360  *
2361  * Directs packets to a given physical port index of the underlying
2362  * device.
2363  *
2364  * @see RTE_FLOW_ITEM_TYPE_PHY_PORT
2365  */
2366 struct rte_flow_action_phy_port {
2367         uint32_t original:1; /**< Use original port index if possible. */
2368         uint32_t reserved:31; /**< Reserved, must be zero. */
2369         uint32_t index; /**< Physical port index. */
2370 };
2371
2372 /**
2373  * RTE_FLOW_ACTION_TYPE_PORT_ID
2374  *
2375  * Directs matching traffic to a given DPDK port ID.
2376  *
2377  * @see RTE_FLOW_ITEM_TYPE_PORT_ID
2378  */
2379 struct rte_flow_action_port_id {
2380         uint32_t original:1; /**< Use original DPDK port ID if possible. */
2381         uint32_t reserved:31; /**< Reserved, must be zero. */
2382         uint32_t id; /**< DPDK port ID. */
2383 };
2384
2385 /**
2386  * RTE_FLOW_ACTION_TYPE_METER
2387  *
2388  * Traffic metering and policing (MTR).
2389  *
2390  * Packets matched by items of this type can be either dropped or passed to the
2391  * next item with their color set by the MTR object.
2392  */
2393 struct rte_flow_action_meter {
2394         uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */
2395 };
2396
2397 /**
2398  * RTE_FLOW_ACTION_TYPE_SECURITY
2399  *
2400  * Perform the security action on flows matched by the pattern items
2401  * according to the configuration of the security session.
2402  *
2403  * This action modifies the payload of matched flows. For INLINE_CRYPTO, the
2404  * security protocol headers and IV are fully provided by the application as
2405  * specified in the flow pattern. The payload of matching packets is
2406  * encrypted on egress, and decrypted and authenticated on ingress.
2407  * For INLINE_PROTOCOL, the security protocol is fully offloaded to HW,
2408  * providing full encapsulation and decapsulation of packets in security
2409  * protocols. The flow pattern specifies both the outer security header fields
2410  * and the inner packet fields. The security session specified in the action
2411  * must match the pattern parameters.
2412  *
2413  * The security session specified in the action must be created on the same
2414  * port as the flow action that is being specified.
2415  *
2416  * The ingress/egress flow attribute should match that specified in the
2417  * security session if the security session supports the definition of the
2418  * direction.
2419  *
2420  * Multiple flows can be configured to use the same security session.
2421  *
2422  * The NULL value is allowed for security session. If security session is NULL,
2423  * then SPI field in ESP flow item and IP addresses in flow items 'IPv4' and
2424  * 'IPv6' will be allowed to be a range. The rule thus created can enable
2425  * security processing on multiple flows.
2426  */
2427 struct rte_flow_action_security {
2428         void *security_session; /**< Pointer to security session structure. */
2429 };
2430
2431 /**
2432  * RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL
2433  *
2434  * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the OpenFlow
2435  * Switch Specification.
2436  */
2437 struct rte_flow_action_of_set_mpls_ttl {
2438         uint8_t mpls_ttl; /**< MPLS TTL. */
2439 };
2440
2441 /**
2442  * RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL
2443  *
2444  * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow Switch
2445  * Specification.
2446  */
2447 struct rte_flow_action_of_set_nw_ttl {
2448         uint8_t nw_ttl; /**< IP TTL. */
2449 };
2450
2451 /**
2452  * RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN
2453  *
2454  * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by the
2455  * OpenFlow Switch Specification.
2456  */
2457 struct rte_flow_action_of_push_vlan {
2458         rte_be16_t ethertype; /**< EtherType. */
2459 };
2460
2461 /**
2462  * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID
2463  *
2464  * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as defined by
2465  * the OpenFlow Switch Specification.
2466  */
2467 struct rte_flow_action_of_set_vlan_vid {
2468         rte_be16_t vlan_vid; /**< VLAN id. */
2469 };
2470
2471 /**
2472  * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP
2473  *
2474  * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as defined by
2475  * the OpenFlow Switch Specification.
2476  */
2477 struct rte_flow_action_of_set_vlan_pcp {
2478         uint8_t vlan_pcp; /**< VLAN priority. */
2479 };
2480
2481 /**
2482  * RTE_FLOW_ACTION_TYPE_OF_POP_MPLS
2483  *
2484  * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined by the
2485  * OpenFlow Switch Specification.
2486  */
2487 struct rte_flow_action_of_pop_mpls {
2488         rte_be16_t ethertype; /**< EtherType. */
2489 };
2490
2491 /**
2492  * RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS
2493  *
2494  * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by the
2495  * OpenFlow Switch Specification.
2496  */
2497 struct rte_flow_action_of_push_mpls {
2498         rte_be16_t ethertype; /**< EtherType. */
2499 };
2500
2501 /**
2502  * @warning
2503  * @b EXPERIMENTAL: this structure may change without prior notice
2504  *
2505  * RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP
2506  *
2507  * VXLAN tunnel end-point encapsulation data definition
2508  *
2509  * The tunnel definition is provided through the flow item pattern, the
2510  * provided pattern must conform to RFC7348 for the tunnel specified. The flow
2511  * definition must be provided in order from the RTE_FLOW_ITEM_TYPE_ETH
2512  * definition up the end item which is specified by RTE_FLOW_ITEM_TYPE_END.
2513  *
2514  * The mask field allows user to specify which fields in the flow item
2515  * definitions can be ignored and which have valid data and can be used
2516  * verbatim.
2517  *
2518  * Note: the last field is not used in the definition of a tunnel and can be
2519  * ignored.
2520  *
2521  * Valid flow definition for RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP include:
2522  *
2523  * - ETH / IPV4 / UDP / VXLAN / END
2524  * - ETH / IPV6 / UDP / VXLAN / END
2525  * - ETH / VLAN / IPV4 / UDP / VXLAN / END
2526  *
2527  */
2528 struct rte_flow_action_vxlan_encap {
2529         /**
2530          * Encapsulating vxlan tunnel definition
2531          * (terminated by the END pattern item).
2532          */
2533         struct rte_flow_item *definition;
2534 };
2535
2536 /**
2537  * @warning
2538  * @b EXPERIMENTAL: this structure may change without prior notice
2539  *
2540  * RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP
2541  *
2542  * NVGRE tunnel end-point encapsulation data definition
2543  *
2544  * The tunnel definition is provided through the flow item pattern  the
2545  * provided pattern must conform with RFC7637. The flow definition must be
2546  * provided in order from the RTE_FLOW_ITEM_TYPE_ETH definition up the end item
2547  * which is specified by RTE_FLOW_ITEM_TYPE_END.
2548  *
2549  * The mask field allows user to specify which fields in the flow item
2550  * definitions can be ignored and which have valid data and can be used
2551  * verbatim.
2552  *
2553  * Note: the last field is not used in the definition of a tunnel and can be
2554  * ignored.
2555  *
2556  * Valid flow definition for RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP include:
2557  *
2558  * - ETH / IPV4 / NVGRE / END
2559  * - ETH / VLAN / IPV6 / NVGRE / END
2560  *
2561  */
2562 struct rte_flow_action_nvgre_encap {
2563         /**
2564          * Encapsulating vxlan tunnel definition
2565          * (terminated by the END pattern item).
2566          */
2567         struct rte_flow_item *definition;
2568 };
2569
2570 /**
2571  * @warning
2572  * @b EXPERIMENTAL: this structure may change without prior notice
2573  *
2574  * RTE_FLOW_ACTION_TYPE_RAW_ENCAP
2575  *
2576  * Raw tunnel end-point encapsulation data definition.
2577  *
2578  * The data holds the headers definitions to be applied on the packet.
2579  * The data must start with ETH header up to the tunnel item header itself.
2580  * When used right after RAW_DECAP (for decapsulating L3 tunnel type for
2581  * example MPLSoGRE) the data will just hold layer 2 header.
2582  *
2583  * The preserve parameter holds which bits in the packet the PMD is not allowed
2584  * to change, this parameter can also be NULL and then the PMD is allowed
2585  * to update any field.
2586  *
2587  * size holds the number of bytes in @p data and @p preserve.
2588  */
2589 struct rte_flow_action_raw_encap {
2590         uint8_t *data; /**< Encapsulation data. */
2591         uint8_t *preserve; /**< Bit-mask of @p data to preserve on output. */
2592         size_t size; /**< Size of @p data and @p preserve. */
2593 };
2594
2595 /**
2596  * @warning
2597  * @b EXPERIMENTAL: this structure may change without prior notice
2598  *
2599  * RTE_FLOW_ACTION_TYPE_RAW_DECAP
2600  *
2601  * Raw tunnel end-point decapsulation data definition.
2602  *
2603  * The data holds the headers definitions to be removed from the packet.
2604  * The data must start with ETH header up to the tunnel item header itself.
2605  * When used right before RAW_DECAP (for encapsulating L3 tunnel type for
2606  * example MPLSoGRE) the data will just hold layer 2 header.
2607  *
2608  * size holds the number of bytes in @p data.
2609  */
2610 struct rte_flow_action_raw_decap {
2611         uint8_t *data; /**< Encapsulation data. */
2612         size_t size; /**< Size of @p data and @p preserve. */
2613 };
2614
2615 /**
2616  * @warning
2617  * @b EXPERIMENTAL: this structure may change without prior notice
2618  *
2619  * RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC
2620  * RTE_FLOW_ACTION_TYPE_SET_IPV4_DST
2621  *
2622  * Allows modification of IPv4 source (RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC)
2623  * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV4_DST) in the
2624  * specified outermost IPv4 header.
2625  */
2626 struct rte_flow_action_set_ipv4 {
2627         rte_be32_t ipv4_addr;
2628 };
2629
2630 /**
2631  * @warning
2632  * @b EXPERIMENTAL: this structure may change without prior notice
2633  *
2634  * RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC
2635  * RTE_FLOW_ACTION_TYPE_SET_IPV6_DST
2636  *
2637  * Allows modification of IPv6 source (RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC)
2638  * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV6_DST) in the
2639  * specified outermost IPv6 header.
2640  */
2641 struct rte_flow_action_set_ipv6 {
2642         uint8_t ipv6_addr[16];
2643 };
2644
2645 /**
2646  * @warning
2647  * @b EXPERIMENTAL: this structure may change without prior notice
2648  *
2649  * RTE_FLOW_ACTION_TYPE_SET_TP_SRC
2650  * RTE_FLOW_ACTION_TYPE_SET_TP_DST
2651  *
2652  * Allows modification of source (RTE_FLOW_ACTION_TYPE_SET_TP_SRC)
2653  * and destination (RTE_FLOW_ACTION_TYPE_SET_TP_DST) port numbers
2654  * in the specified outermost TCP/UDP header.
2655  */
2656 struct rte_flow_action_set_tp {
2657         rte_be16_t port;
2658 };
2659
2660 /**
2661  * RTE_FLOW_ACTION_TYPE_SET_TTL
2662  *
2663  * Set the TTL value directly for IPv4 or IPv6
2664  */
2665 struct rte_flow_action_set_ttl {
2666         uint8_t ttl_value;
2667 };
2668
2669 /**
2670  * RTE_FLOW_ACTION_TYPE_SET_MAC
2671  *
2672  * Set MAC address from the matched flow
2673  */
2674 struct rte_flow_action_set_mac {
2675         uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
2676 };
2677
2678 /**
2679  * @warning
2680  * @b EXPERIMENTAL: this structure may change without prior notice
2681  *
2682  * RTE_FLOW_ACTION_TYPE_SET_TAG
2683  *
2684  * Set a tag which is a transient data used during flow matching. This is not
2685  * delivered to application. Multiple tags are supported by specifying index.
2686  */
2687 struct rte_flow_action_set_tag {
2688         uint32_t data;
2689         uint32_t mask;
2690         uint8_t index;
2691 };
2692
2693 /**
2694  * @warning
2695  * @b EXPERIMENTAL: this structure may change without prior notice
2696  *
2697  * RTE_FLOW_ACTION_TYPE_SET_META
2698  *
2699  * Set metadata. Metadata set by mbuf metadata dynamic field with
2700  * PKT_TX_DYNF_DATA flag on egress will be overridden by this action. On
2701  * ingress, the metadata will be carried by mbuf metadata dynamic field
2702  * with PKT_RX_DYNF_METADATA flag if set.  The dynamic mbuf field must be
2703  * registered in advance by rte_flow_dynf_metadata_register().
2704  *
2705  * Altering partial bits is supported with mask. For bits which have never
2706  * been set, unpredictable value will be seen depending on driver
2707  * implementation. For loopback/hairpin packet, metadata set on Rx/Tx may
2708  * or may not be propagated to the other path depending on HW capability.
2709  *
2710  * RTE_FLOW_ITEM_TYPE_META matches metadata.
2711  */
2712 struct rte_flow_action_set_meta {
2713         uint32_t data;
2714         uint32_t mask;
2715 };
2716
2717 /**
2718  * RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP
2719  * RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP
2720  *
2721  * Set the DSCP value for IPv4/IPv6 header.
2722  * DSCP in low 6 bits, rest ignored.
2723  */
2724 struct rte_flow_action_set_dscp {
2725         uint8_t dscp;
2726 };
2727
2728
2729 /**
2730  * RTE_FLOW_ACTION_TYPE_SHARED
2731  *
2732  * Opaque type returned after successfully creating a shared action.
2733  *
2734  * This handle can be used to manage and query the related action:
2735  * - share it across multiple flow rules
2736  * - update action configuration
2737  * - query action data
2738  * - destroy action
2739  */
2740 struct rte_flow_shared_action;
2741
2742 /* Mbuf dynamic field offset for metadata. */
2743 extern int32_t rte_flow_dynf_metadata_offs;
2744
2745 /* Mbuf dynamic field flag mask for metadata. */
2746 extern uint64_t rte_flow_dynf_metadata_mask;
2747
2748 /* Mbuf dynamic field pointer for metadata. */
2749 #define RTE_FLOW_DYNF_METADATA(m) \
2750         RTE_MBUF_DYNFIELD((m), rte_flow_dynf_metadata_offs, uint32_t *)
2751
2752 /* Mbuf dynamic flags for metadata. */
2753 #define PKT_RX_DYNF_METADATA (rte_flow_dynf_metadata_mask)
2754 #define PKT_TX_DYNF_METADATA (rte_flow_dynf_metadata_mask)
2755
2756 __rte_experimental
2757 static inline uint32_t
2758 rte_flow_dynf_metadata_get(struct rte_mbuf *m)
2759 {
2760         return *RTE_FLOW_DYNF_METADATA(m);
2761 }
2762
2763 __rte_experimental
2764 static inline void
2765 rte_flow_dynf_metadata_set(struct rte_mbuf *m, uint32_t v)
2766 {
2767         *RTE_FLOW_DYNF_METADATA(m) = v;
2768 }
2769
2770 /*
2771  * Definition of a single action.
2772  *
2773  * A list of actions is terminated by a END action.
2774  *
2775  * For simple actions without a configuration object, conf remains NULL.
2776  */
2777 struct rte_flow_action {
2778         enum rte_flow_action_type type; /**< Action type. */
2779         const void *conf; /**< Pointer to action configuration object. */
2780 };
2781
2782 /**
2783  * Opaque type returned after successfully creating a flow.
2784  *
2785  * This handle can be used to manage and query the related flow (e.g. to
2786  * destroy it or retrieve counters).
2787  */
2788 struct rte_flow;
2789
2790 /**
2791  * @warning
2792  * @b EXPERIMENTAL: this structure may change without prior notice
2793  *
2794  * RTE_FLOW_ACTION_TYPE_SAMPLE
2795  *
2796  * Adds a sample action to a matched flow.
2797  *
2798  * The matching packets will be duplicated with specified ratio and applied
2799  * with own set of actions with a fate action, the sampled packet could be
2800  * redirected to queue or port. All the packets continue processing on the
2801  * default flow path.
2802  *
2803  * When the sample ratio is set to 1 then the packets will be 100% mirrored.
2804  * Additional action list be supported to add for sampled or mirrored packets.
2805  */
2806 struct rte_flow_action_sample {
2807         uint32_t ratio; /**< packets sampled equals to '1/ratio'. */
2808         const struct rte_flow_action *actions;
2809                 /**< sub-action list specific for the sampling hit cases. */
2810 };
2811
2812 /**
2813  * Verbose error types.
2814  *
2815  * Most of them provide the type of the object referenced by struct
2816  * rte_flow_error.cause.
2817  */
2818 enum rte_flow_error_type {
2819         RTE_FLOW_ERROR_TYPE_NONE, /**< No error. */
2820         RTE_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
2821         RTE_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */
2822         RTE_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */
2823         RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */
2824         RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */
2825         RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */
2826         RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */
2827         RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */
2828         RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */
2829         RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */
2830         RTE_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */
2831         RTE_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */
2832         RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */
2833         RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */
2834         RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */
2835         RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */
2836 };
2837
2838 /**
2839  * Verbose error structure definition.
2840  *
2841  * This object is normally allocated by applications and set by PMDs, the
2842  * message points to a constant string which does not need to be freed by
2843  * the application, however its pointer can be considered valid only as long
2844  * as its associated DPDK port remains configured. Closing the underlying
2845  * device or unloading the PMD invalidates it.
2846  *
2847  * Both cause and message may be NULL regardless of the error type.
2848  */
2849 struct rte_flow_error {
2850         enum rte_flow_error_type type; /**< Cause field and error types. */
2851         const void *cause; /**< Object responsible for the error. */
2852         const char *message; /**< Human-readable error message. */
2853 };
2854
2855 /**
2856  * Complete flow rule description.
2857  *
2858  * This object type is used when converting a flow rule description.
2859  *
2860  * @see RTE_FLOW_CONV_OP_RULE
2861  * @see rte_flow_conv()
2862  */
2863 RTE_STD_C11
2864 struct rte_flow_conv_rule {
2865         union {
2866                 const struct rte_flow_attr *attr_ro; /**< RO attributes. */
2867                 struct rte_flow_attr *attr; /**< Attributes. */
2868         };
2869         union {
2870                 const struct rte_flow_item *pattern_ro; /**< RO pattern. */
2871                 struct rte_flow_item *pattern; /**< Pattern items. */
2872         };
2873         union {
2874                 const struct rte_flow_action *actions_ro; /**< RO actions. */
2875                 struct rte_flow_action *actions; /**< List of actions. */
2876         };
2877 };
2878
2879 /**
2880  * Conversion operations for flow API objects.
2881  *
2882  * @see rte_flow_conv()
2883  */
2884 enum rte_flow_conv_op {
2885         /**
2886          * No operation to perform.
2887          *
2888          * rte_flow_conv() simply returns 0.
2889          */
2890         RTE_FLOW_CONV_OP_NONE,
2891
2892         /**
2893          * Convert attributes structure.
2894          *
2895          * This is a basic copy of an attributes structure.
2896          *
2897          * - @p src type:
2898          *   @code const struct rte_flow_attr * @endcode
2899          * - @p dst type:
2900          *   @code struct rte_flow_attr * @endcode
2901          */
2902         RTE_FLOW_CONV_OP_ATTR,
2903
2904         /**
2905          * Convert a single item.
2906          *
2907          * Duplicates @p spec, @p last and @p mask but not outside objects.
2908          *
2909          * - @p src type:
2910          *   @code const struct rte_flow_item * @endcode
2911          * - @p dst type:
2912          *   @code struct rte_flow_item * @endcode
2913          */
2914         RTE_FLOW_CONV_OP_ITEM,
2915
2916         /**
2917          * Convert a single action.
2918          *
2919          * Duplicates @p conf but not outside objects.
2920          *
2921          * - @p src type:
2922          *   @code const struct rte_flow_action * @endcode
2923          * - @p dst type:
2924          *   @code struct rte_flow_action * @endcode
2925          */
2926         RTE_FLOW_CONV_OP_ACTION,
2927
2928         /**
2929          * Convert an entire pattern.
2930          *
2931          * Duplicates all pattern items at once with the same constraints as
2932          * RTE_FLOW_CONV_OP_ITEM.
2933          *
2934          * - @p src type:
2935          *   @code const struct rte_flow_item * @endcode
2936          * - @p dst type:
2937          *   @code struct rte_flow_item * @endcode
2938          */
2939         RTE_FLOW_CONV_OP_PATTERN,
2940
2941         /**
2942          * Convert a list of actions.
2943          *
2944          * Duplicates the entire list of actions at once with the same
2945          * constraints as RTE_FLOW_CONV_OP_ACTION.
2946          *
2947          * - @p src type:
2948          *   @code const struct rte_flow_action * @endcode
2949          * - @p dst type:
2950          *   @code struct rte_flow_action * @endcode
2951          */
2952         RTE_FLOW_CONV_OP_ACTIONS,
2953
2954         /**
2955          * Convert a complete flow rule description.
2956          *
2957          * Comprises attributes, pattern and actions together at once with
2958          * the usual constraints.
2959          *
2960          * - @p src type:
2961          *   @code const struct rte_flow_conv_rule * @endcode
2962          * - @p dst type:
2963          *   @code struct rte_flow_conv_rule * @endcode
2964          */
2965         RTE_FLOW_CONV_OP_RULE,
2966
2967         /**
2968          * Convert item type to its name string.
2969          *
2970          * Writes a NUL-terminated string to @p dst. Like snprintf(), the
2971          * returned value excludes the terminator which is always written
2972          * nonetheless.
2973          *
2974          * - @p src type:
2975          *   @code (const void *)enum rte_flow_item_type @endcode
2976          * - @p dst type:
2977          *   @code char * @endcode
2978          **/
2979         RTE_FLOW_CONV_OP_ITEM_NAME,
2980
2981         /**
2982          * Convert action type to its name string.
2983          *
2984          * Writes a NUL-terminated string to @p dst. Like snprintf(), the
2985          * returned value excludes the terminator which is always written
2986          * nonetheless.
2987          *
2988          * - @p src type:
2989          *   @code (const void *)enum rte_flow_action_type @endcode
2990          * - @p dst type:
2991          *   @code char * @endcode
2992          **/
2993         RTE_FLOW_CONV_OP_ACTION_NAME,
2994
2995         /**
2996          * Convert item type to pointer to item name.
2997          *
2998          * Retrieves item name pointer from its type. The string itself is
2999          * not copied; instead, a unique pointer to an internal static
3000          * constant storage is written to @p dst.
3001          *
3002          * - @p src type:
3003          *   @code (const void *)enum rte_flow_item_type @endcode
3004          * - @p dst type:
3005          *   @code const char ** @endcode
3006          */
3007         RTE_FLOW_CONV_OP_ITEM_NAME_PTR,
3008
3009         /**
3010          * Convert action type to pointer to action name.
3011          *
3012          * Retrieves action name pointer from its type. The string itself is
3013          * not copied; instead, a unique pointer to an internal static
3014          * constant storage is written to @p dst.
3015          *
3016          * - @p src type:
3017          *   @code (const void *)enum rte_flow_action_type @endcode
3018          * - @p dst type:
3019          *   @code const char ** @endcode
3020          */
3021         RTE_FLOW_CONV_OP_ACTION_NAME_PTR,
3022 };
3023
3024 /**
3025  * @warning
3026  * @b EXPERIMENTAL: this API may change without prior notice.
3027  *
3028  * Dump hardware internal representation information of
3029  * rte flow to file.
3030  *
3031  * @param[in] port_id
3032  *    The port identifier of the Ethernet device.
3033  * @param[in] file
3034  *   A pointer to a file for output.
3035  * @param[out] error
3036  *   Perform verbose error reporting if not NULL. PMDs initialize this
3037  *   structure in case of error only.
3038  * @return
3039  *   0 on success, a nagative value otherwise.
3040  */
3041 __rte_experimental
3042 int
3043 rte_flow_dev_dump(uint16_t port_id, FILE *file, struct rte_flow_error *error);
3044
3045 /**
3046  * Check if mbuf dynamic field for metadata is registered.
3047  *
3048  * @return
3049  *   True if registered, false otherwise.
3050  */
3051 __rte_experimental
3052 static inline int
3053 rte_flow_dynf_metadata_avail(void)
3054 {
3055         return !!rte_flow_dynf_metadata_mask;
3056 }
3057
3058 /**
3059  * Register mbuf dynamic field and flag for metadata.
3060  *
3061  * This function must be called prior to use SET_META action in order to
3062  * register the dynamic mbuf field. Otherwise, the data cannot be delivered to
3063  * application.
3064  *
3065  * @return
3066  *   0 on success, a negative errno value otherwise and rte_errno is set.
3067  */
3068 __rte_experimental
3069 int
3070 rte_flow_dynf_metadata_register(void);
3071
3072 /**
3073  * Check whether a flow rule can be created on a given port.
3074  *
3075  * The flow rule is validated for correctness and whether it could be accepted
3076  * by the device given sufficient resources. The rule is checked against the
3077  * current device mode and queue configuration. The flow rule may also
3078  * optionally be validated against existing flow rules and device resources.
3079  * This function has no effect on the target device.
3080  *
3081  * The returned value is guaranteed to remain valid only as long as no
3082  * successful calls to rte_flow_create() or rte_flow_destroy() are made in
3083  * the meantime and no device parameter affecting flow rules in any way are
3084  * modified, due to possible collisions or resource limitations (although in
3085  * such cases EINVAL should not be returned).
3086  *
3087  * @param port_id
3088  *   Port identifier of Ethernet device.
3089  * @param[in] attr
3090  *   Flow rule attributes.
3091  * @param[in] pattern
3092  *   Pattern specification (list terminated by the END pattern item).
3093  * @param[in] actions
3094  *   Associated actions (list terminated by the END action).
3095  * @param[out] error
3096  *   Perform verbose error reporting if not NULL. PMDs initialize this
3097  *   structure in case of error only.
3098  *
3099  * @return
3100  *   0 if flow rule is valid and can be created. A negative errno value
3101  *   otherwise (rte_errno is also set), the following errors are defined:
3102  *
3103  *   -ENOSYS: underlying device does not support this functionality.
3104  *
3105  *   -EIO: underlying device is removed.
3106  *
3107  *   -EINVAL: unknown or invalid rule specification.
3108  *
3109  *   -ENOTSUP: valid but unsupported rule specification (e.g. partial
3110  *   bit-masks are unsupported).
3111  *
3112  *   -EEXIST: collision with an existing rule. Only returned if device
3113  *   supports flow rule collision checking and there was a flow rule
3114  *   collision. Not receiving this return code is no guarantee that creating
3115  *   the rule will not fail due to a collision.
3116  *
3117  *   -ENOMEM: not enough memory to execute the function, or if the device
3118  *   supports resource validation, resource limitation on the device.
3119  *
3120  *   -EBUSY: action cannot be performed due to busy device resources, may
3121  *   succeed if the affected queues or even the entire port are in a stopped
3122  *   state (see rte_eth_dev_rx_queue_stop() and rte_eth_dev_stop()).
3123  */
3124 int
3125 rte_flow_validate(uint16_t port_id,
3126                   const struct rte_flow_attr *attr,
3127                   const struct rte_flow_item pattern[],
3128                   const struct rte_flow_action actions[],
3129                   struct rte_flow_error *error);
3130
3131 /**
3132  * Create a flow rule on a given port.
3133  *
3134  * @param port_id
3135  *   Port identifier of Ethernet device.
3136  * @param[in] attr
3137  *   Flow rule attributes.
3138  * @param[in] pattern
3139  *   Pattern specification (list terminated by the END pattern item).
3140  * @param[in] actions
3141  *   Associated actions (list terminated by the END action).
3142  * @param[out] error
3143  *   Perform verbose error reporting if not NULL. PMDs initialize this
3144  *   structure in case of error only.
3145  *
3146  * @return
3147  *   A valid handle in case of success, NULL otherwise and rte_errno is set
3148  *   to the positive version of one of the error codes defined for
3149  *   rte_flow_validate().
3150  */
3151 struct rte_flow *
3152 rte_flow_create(uint16_t port_id,
3153                 const struct rte_flow_attr *attr,
3154                 const struct rte_flow_item pattern[],
3155                 const struct rte_flow_action actions[],
3156                 struct rte_flow_error *error);
3157
3158 /**
3159  * Destroy a flow rule on a given port.
3160  *
3161  * Failure to destroy a flow rule handle may occur when other flow rules
3162  * depend on it, and destroying it would result in an inconsistent state.
3163  *
3164  * This function is only guaranteed to succeed if handles are destroyed in
3165  * reverse order of their creation.
3166  *
3167  * @param port_id
3168  *   Port identifier of Ethernet device.
3169  * @param flow
3170  *   Flow rule handle to destroy.
3171  * @param[out] error
3172  *   Perform verbose error reporting if not NULL. PMDs initialize this
3173  *   structure in case of error only.
3174  *
3175  * @return
3176  *   0 on success, a negative errno value otherwise and rte_errno is set.
3177  */
3178 int
3179 rte_flow_destroy(uint16_t port_id,
3180                  struct rte_flow *flow,
3181                  struct rte_flow_error *error);
3182
3183 /**
3184  * Destroy all flow rules associated with a port.
3185  *
3186  * In the unlikely event of failure, handles are still considered destroyed
3187  * and no longer valid but the port must be assumed to be in an inconsistent
3188  * state.
3189  *
3190  * @param port_id
3191  *   Port identifier of Ethernet device.
3192  * @param[out] error
3193  *   Perform verbose error reporting if not NULL. PMDs initialize this
3194  *   structure in case of error only.
3195  *
3196  * @return
3197  *   0 on success, a negative errno value otherwise and rte_errno is set.
3198  */
3199 int
3200 rte_flow_flush(uint16_t port_id,
3201                struct rte_flow_error *error);
3202
3203 /**
3204  * Query an existing flow rule.
3205  *
3206  * This function allows retrieving flow-specific data such as counters.
3207  * Data is gathered by special actions which must be present in the flow
3208  * rule definition.
3209  *
3210  * \see RTE_FLOW_ACTION_TYPE_COUNT
3211  *
3212  * @param port_id
3213  *   Port identifier of Ethernet device.
3214  * @param flow
3215  *   Flow rule handle to query.
3216  * @param action
3217  *   Action definition as defined in original flow rule.
3218  * @param[in, out] data
3219  *   Pointer to storage for the associated query data type.
3220  * @param[out] error
3221  *   Perform verbose error reporting if not NULL. PMDs initialize this
3222  *   structure in case of error only.
3223  *
3224  * @return
3225  *   0 on success, a negative errno value otherwise and rte_errno is set.
3226  */
3227 int
3228 rte_flow_query(uint16_t port_id,
3229                struct rte_flow *flow,
3230                const struct rte_flow_action *action,
3231                void *data,
3232                struct rte_flow_error *error);
3233
3234 /**
3235  * Restrict ingress traffic to the defined flow rules.
3236  *
3237  * Isolated mode guarantees that all ingress traffic comes from defined flow
3238  * rules only (current and future).
3239  *
3240  * Besides making ingress more deterministic, it allows PMDs to safely reuse
3241  * resources otherwise assigned to handle the remaining traffic, such as
3242  * global RSS configuration settings, VLAN filters, MAC address entries,
3243  * legacy filter API rules and so on in order to expand the set of possible
3244  * flow rule types.
3245  *
3246  * Calling this function as soon as possible after device initialization,
3247  * ideally before the first call to rte_eth_dev_configure(), is recommended
3248  * to avoid possible failures due to conflicting settings.
3249  *
3250  * Once effective, leaving isolated mode may not be possible depending on
3251  * PMD implementation.
3252  *
3253  * Additionally, the following functionality has no effect on the underlying
3254  * port and may return errors such as ENOTSUP ("not supported"):
3255  *
3256  * - Toggling promiscuous mode.
3257  * - Toggling allmulticast mode.
3258  * - Configuring MAC addresses.
3259  * - Configuring multicast addresses.
3260  * - Configuring VLAN filters.
3261  * - Configuring Rx filters through the legacy API (e.g. FDIR).
3262  * - Configuring global RSS settings.
3263  *
3264  * @param port_id
3265  *   Port identifier of Ethernet device.
3266  * @param set
3267  *   Nonzero to enter isolated mode, attempt to leave it otherwise.
3268  * @param[out] error
3269  *   Perform verbose error reporting if not NULL. PMDs initialize this
3270  *   structure in case of error only.
3271  *
3272  * @return
3273  *   0 on success, a negative errno value otherwise and rte_errno is set.
3274  */
3275 int
3276 rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error);
3277
3278 /**
3279  * Initialize flow error structure.
3280  *
3281  * @param[out] error
3282  *   Pointer to flow error structure (may be NULL).
3283  * @param code
3284  *   Related error code (rte_errno).
3285  * @param type
3286  *   Cause field and error types.
3287  * @param cause
3288  *   Object responsible for the error.
3289  * @param message
3290  *   Human-readable error message.
3291  *
3292  * @return
3293  *   Negative error code (errno value) and rte_errno is set.
3294  */
3295 int
3296 rte_flow_error_set(struct rte_flow_error *error,
3297                    int code,
3298                    enum rte_flow_error_type type,
3299                    const void *cause,
3300                    const char *message);
3301
3302 /**
3303  * @deprecated
3304  * @see rte_flow_copy()
3305  */
3306 struct rte_flow_desc {
3307         size_t size; /**< Allocated space including data[]. */
3308         struct rte_flow_attr attr; /**< Attributes. */
3309         struct rte_flow_item *items; /**< Items. */
3310         struct rte_flow_action *actions; /**< Actions. */
3311         uint8_t data[]; /**< Storage for items/actions. */
3312 };
3313
3314 /**
3315  * @deprecated
3316  * Copy an rte_flow rule description.
3317  *
3318  * This interface is kept for compatibility with older applications but is
3319  * implemented as a wrapper to rte_flow_conv(). It is deprecated due to its
3320  * lack of flexibility and reliance on a type unusable with C++ programs
3321  * (struct rte_flow_desc).
3322  *
3323  * @param[in] fd
3324  *   Flow rule description.
3325  * @param[in] len
3326  *   Total size of allocated data for the flow description.
3327  * @param[in] attr
3328  *   Flow rule attributes.
3329  * @param[in] items
3330  *   Pattern specification (list terminated by the END pattern item).
3331  * @param[in] actions
3332  *   Associated actions (list terminated by the END action).
3333  *
3334  * @return
3335  *   If len is greater or equal to the size of the flow, the total size of the
3336  *   flow description and its data.
3337  *   If len is lower than the size of the flow, the number of bytes that would
3338  *   have been written to desc had it been sufficient. Nothing is written.
3339  */
3340 __rte_deprecated
3341 size_t
3342 rte_flow_copy(struct rte_flow_desc *fd, size_t len,
3343               const struct rte_flow_attr *attr,
3344               const struct rte_flow_item *items,
3345               const struct rte_flow_action *actions);
3346
3347 /**
3348  * Flow object conversion helper.
3349  *
3350  * This function performs conversion of various flow API objects to a
3351  * pre-allocated destination buffer. See enum rte_flow_conv_op for possible
3352  * operations and details about each of them.
3353  *
3354  * Since destination buffer must be large enough, it works in a manner
3355  * reminiscent of snprintf():
3356  *
3357  * - If @p size is 0, @p dst may be a NULL pointer, otherwise @p dst must be
3358  *   non-NULL.
3359  * - If positive, the returned value represents the number of bytes needed
3360  *   to store the conversion of @p src to @p dst according to @p op
3361  *   regardless of the @p size parameter.
3362  * - Since no more than @p size bytes can be written to @p dst, output is
3363  *   truncated and may be inconsistent when the returned value is larger
3364  *   than that.
3365  * - In case of conversion error, a negative error code is returned and
3366  *   @p dst contents are unspecified.
3367  *
3368  * @param op
3369  *   Operation to perform, related to the object type of @p dst.
3370  * @param[out] dst
3371  *   Destination buffer address. Must be suitably aligned by the caller.
3372  * @param size
3373  *   Destination buffer size in bytes.
3374  * @param[in] src
3375  *   Source object to copy. Depending on @p op, its type may differ from
3376  *   that of @p dst.
3377  * @param[out] error
3378  *   Perform verbose error reporting if not NULL. Initialized in case of
3379  *   error only.
3380  *
3381  * @return
3382  *   The number of bytes required to convert @p src to @p dst on success, a
3383  *   negative errno value otherwise and rte_errno is set.
3384  *
3385  * @see rte_flow_conv_op
3386  */
3387 __rte_experimental
3388 int
3389 rte_flow_conv(enum rte_flow_conv_op op,
3390               void *dst,
3391               size_t size,
3392               const void *src,
3393               struct rte_flow_error *error);
3394
3395 /**
3396  * Get aged-out flows of a given port.
3397  *
3398  * RTE_ETH_EVENT_FLOW_AGED event will be triggered when at least one new aged
3399  * out flow was detected after the last call to rte_flow_get_aged_flows.
3400  * This function can be called to get the aged flows usynchronously from the
3401  * event callback or synchronously regardless the event.
3402  * This is not safe to call rte_flow_get_aged_flows function with other flow
3403  * functions from multiple threads simultaneously.
3404  *
3405  * @param port_id
3406  *   Port identifier of Ethernet device.
3407  * @param[in, out] contexts
3408  *   The address of an array of pointers to the aged-out flows contexts.
3409  * @param[in] nb_contexts
3410  *   The length of context array pointers.
3411  * @param[out] error
3412  *   Perform verbose error reporting if not NULL. Initialized in case of
3413  *   error only.
3414  *
3415  * @return
3416  *   if nb_contexts is 0, return the amount of all aged contexts.
3417  *   if nb_contexts is not 0 , return the amount of aged flows reported
3418  *   in the context array, otherwise negative errno value.
3419  *
3420  * @see rte_flow_action_age
3421  * @see RTE_ETH_EVENT_FLOW_AGED
3422  */
3423 __rte_experimental
3424 int
3425 rte_flow_get_aged_flows(uint16_t port_id, void **contexts,
3426                         uint32_t nb_contexts, struct rte_flow_error *error);
3427
3428 /**
3429  * Specify shared action configuration
3430  */
3431 struct rte_flow_shared_action_conf {
3432         /**
3433          * Flow direction for shared action configuration.
3434          *
3435          * Shared action should be valid at least for one flow direction,
3436          * otherwise it is invalid for both ingress and egress rules.
3437          */
3438         uint32_t ingress:1;
3439         /**< Action valid for rules applied to ingress traffic. */
3440         uint32_t egress:1;
3441         /**< Action valid for rules applied to egress traffic. */
3442 };
3443
3444 /**
3445  * @warning
3446  * @b EXPERIMENTAL: this API may change without prior notice.
3447  *
3448  * Create shared action for reuse in multiple flow rules.
3449  * The created shared action has single state and configuration
3450  * across all flow rules using it.
3451  *
3452  * @param[in] port_id
3453  *    The port identifier of the Ethernet device.
3454  * @param[in] conf
3455  *   Shared action configuration.
3456  * @param[in] action
3457  *   Action configuration for shared action creation.
3458  * @param[out] error
3459  *   Perform verbose error reporting if not NULL. PMDs initialize this
3460  *   structure in case of error only.
3461  * @return
3462  *   A valid handle in case of success, NULL otherwise and rte_errno is set
3463  *   to one of the error codes defined:
3464  *   - (ENODEV) if *port_id* invalid.
3465  *   - (ENOSYS) if underlying device does not support this functionality.
3466  *   - (EIO) if underlying device is removed.
3467  *   - (EINVAL) if *action* invalid.
3468  *   - (ENOTSUP) if *action* valid but unsupported.
3469  */
3470 __rte_experimental
3471 struct rte_flow_shared_action *
3472 rte_flow_shared_action_create(uint16_t port_id,
3473                               const struct rte_flow_shared_action_conf *conf,
3474                               const struct rte_flow_action *action,
3475                               struct rte_flow_error *error);
3476
3477 /**
3478  * @warning
3479  * @b EXPERIMENTAL: this API may change without prior notice.
3480  *
3481  * Destroy the shared action by handle.
3482  *
3483  * @param[in] port_id
3484  *    The port identifier of the Ethernet device.
3485  * @param[in] action
3486  *   Handle for the shared action to be destroyed.
3487  * @param[out] error
3488  *   Perform verbose error reporting if not NULL. PMDs initialize this
3489  *   structure in case of error only.
3490  * @return
3491  *   - (0) if success.
3492  *   - (-ENODEV) if *port_id* invalid.
3493  *   - (-ENOSYS) if underlying device does not support this functionality.
3494  *   - (-EIO) if underlying device is removed.
3495  *   - (-ENOENT) if action pointed by *action* handle was not found.
3496  *   - (-ETOOMANYREFS) if action pointed by *action* handle still used by one or
3497  *     more rules
3498  *   rte_errno is also set.
3499  */
3500 __rte_experimental
3501 int
3502 rte_flow_shared_action_destroy(uint16_t port_id,
3503                                struct rte_flow_shared_action *action,
3504                                struct rte_flow_error *error);
3505
3506 /**
3507  * @warning
3508  * @b EXPERIMENTAL: this API may change without prior notice.
3509  *
3510  * Update in-place the shared action configuration pointed by *action* handle
3511  * with the configuration provided as *update* argument.
3512  * The update of the shared action configuration effects all flow rules reusing
3513  * the action via handle.
3514  *
3515  * @param[in] port_id
3516  *    The port identifier of the Ethernet device.
3517  * @param[in] action
3518  *   Handle for the shared action to be updated.
3519  * @param[in] update
3520  *   Action specification used to modify the action pointed by handle.
3521  *   *update* should be of same type with the action pointed by the *action*
3522  *   handle argument, otherwise considered as invalid.
3523  * @param[out] error
3524  *   Perform verbose error reporting if not NULL. PMDs initialize this
3525  *   structure in case of error only.
3526  * @return
3527  *   - (0) if success.
3528  *   - (-ENODEV) if *port_id* invalid.
3529  *   - (-ENOSYS) if underlying device does not support this functionality.
3530  *   - (-EIO) if underlying device is removed.
3531  *   - (-EINVAL) if *update* invalid.
3532  *   - (-ENOTSUP) if *update* valid but unsupported.
3533  *   - (-ENOENT) if action pointed by *ctx* was not found.
3534  *   rte_errno is also set.
3535  */
3536 __rte_experimental
3537 int
3538 rte_flow_shared_action_update(uint16_t port_id,
3539                               struct rte_flow_shared_action *action,
3540                               const struct rte_flow_action *update,
3541                               struct rte_flow_error *error);
3542
3543 /**
3544  * @warning
3545  * @b EXPERIMENTAL: this API may change without prior notice.
3546  *
3547  * Query the shared action by handle.
3548  *
3549  * Retrieve action-specific data such as counters.
3550  * Data is gathered by special action which may be present/referenced in
3551  * more than one flow rule definition.
3552  *
3553  * \see RTE_FLOW_ACTION_TYPE_COUNT
3554  *
3555  * @param port_id
3556  *   Port identifier of Ethernet device.
3557  * @param[in] action
3558  *   Handle for the shared action to query.
3559  * @param[in, out] data
3560  *   Pointer to storage for the associated query data type.
3561  * @param[out] error
3562  *   Perform verbose error reporting if not NULL. PMDs initialize this
3563  *   structure in case of error only.
3564  *
3565  * @return
3566  *   0 on success, a negative errno value otherwise and rte_errno is set.
3567  */
3568 __rte_experimental
3569 int
3570 rte_flow_shared_action_query(uint16_t port_id,
3571                              const struct rte_flow_shared_action *action,
3572                              void *data,
3573                              struct rte_flow_error *error);
3574
3575 #ifdef __cplusplus
3576 }
3577 #endif
3578
3579 #endif /* RTE_FLOW_H_ */