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