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