ethdev: fix VLAN spelling including VLAN ID case
[dpdk.git] / lib / 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_vxlan.h>
29 #include <rte_byteorder.h>
30 #include <rte_esp.h>
31 #include <rte_higig.h>
32 #include <rte_ecpri.h>
33 #include <rte_bitops.h>
34 #include <rte_mbuf.h>
35 #include <rte_mbuf_dyn.h>
36 #include <rte_meter.h>
37 #include <rte_gtp.h>
38
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42
43 /**
44  * Flow rule attributes.
45  *
46  * Priorities are set on a per rule based within groups.
47  *
48  * Lower values denote higher priority, the highest priority for a flow rule
49  * is 0, so that a flow that matches for than one rule, the rule with the
50  * lowest priority value will always be matched.
51  *
52  * Although optional, applications are encouraged to group similar rules as
53  * much as possible to fully take advantage of hardware capabilities
54  * (e.g. optimized matching) and work around limitations (e.g. a single
55  * pattern type possibly allowed in a given group). Applications should be
56  * aware that groups are not linked by default, and that they must be
57  * explicitly linked by the application using the JUMP action.
58  *
59  * Priority levels are arbitrary and up to the application, they
60  * do not need to be contiguous nor start from 0, however the maximum number
61  * varies between devices and may be affected by existing flow rules.
62  *
63  * If a packet is matched by several rules of a given group for a given
64  * priority level, the outcome is undefined. It can take any path, may be
65  * duplicated or even cause unrecoverable errors.
66  *
67  * Note that support for more than a single group and priority level is not
68  * guaranteed.
69  *
70  * At vNIC / ethdev level, flow rules can apply to inbound and / or outbound
71  * traffic (ingress / egress), with respect to the vNIC / ethdev in question.
72  * At embedded switch level, flow rules apply to all traffic seen by it
73  * unless fitting meta items are used to set concrete traffic source(s).
74  *
75  * Several pattern items and actions are valid and can be used in both
76  * directions. Those valid for only one direction are described as such.
77  *
78  * At least one direction must be specified.
79  *
80  * Specifying both directions at once for a given rule is not recommended
81  * but may be valid in a few cases.
82  */
83 struct rte_flow_attr {
84         uint32_t group; /**< Priority group. */
85         uint32_t priority; /**< Rule priority level within group. */
86         /**
87          * The rule in question applies to ingress traffic (non-"transfer").
88          *
89          * @deprecated
90          * It has been possible to combine this attribute with "transfer".
91          * Doing so has been assumed to restrict the scope of matching
92          * to traffic going from within the embedded switch toward the
93          * ethdev the flow rule being created through. This behaviour
94          * is deprecated. During the transition period, one may still
95          * rely on it, but PMDs and applications are encouraged to
96          * gradually move away from this approach.
97          */
98         uint32_t ingress:1;
99         /**
100          * The rule in question applies to egress traffic (non-"transfer").
101          *
102          * @deprecated
103          * It has been possible to combine this attribute with "transfer".
104          * Doing so has been assumed to restrict the scope of matching
105          * to traffic sent by the application by virtue of the ethdev
106          * the flow rule being created through. This behaviour is now
107          * deprecated. During the transition period, one may still
108          * rely on it, but PMDs and applications are encouraged to
109          * gradually move away from this approach.
110          */
111         uint32_t egress:1;
112         /**
113          * Instead of simply matching the properties of traffic as it would
114          * appear on a given DPDK port ID, enabling this attribute transfers
115          * a flow rule to the lowest possible level of any device endpoints
116          * found in the pattern.
117          *
118          * When supported, this effectively enables an application to
119          * re-route traffic not necessarily intended for it (e.g. coming
120          * from or addressed to different physical ports, VFs or
121          * applications) at the device level.
122          *
123          * The application should match traffic originating from precise
124          * locations. See items PORT_REPRESENTOR and REPRESENTED_PORT.
125          *
126          * Managing "transfer" flows requires that the user communicate them
127          * through a suitable port. @see rte_flow_pick_transfer_proxy().
128          */
129         uint32_t transfer:1;
130         uint32_t reserved:29; /**< Reserved, must be zero. */
131 };
132
133 /**
134  * Matching pattern item types.
135  *
136  * Pattern items fall in two categories:
137  *
138  * - Matching protocol headers and packet data, usually associated with a
139  *   specification structure. These must be stacked in the same order as the
140  *   protocol layers to match inside packets, starting from the lowest.
141  *
142  * - Matching meta-data or affecting pattern processing, often without a
143  *   specification structure. Since they do not match packet contents, their
144  *   position in the list is usually not relevant.
145  *
146  * See the description of individual types for more information. Those
147  * marked with [META] fall into the second category.
148  */
149 enum rte_flow_item_type {
150         /**
151          * [META]
152          *
153          * End marker for item lists. Prevents further processing of items,
154          * thereby ending the pattern.
155          *
156          * No associated specification structure.
157          */
158         RTE_FLOW_ITEM_TYPE_END,
159
160         /**
161          * [META]
162          *
163          * Used as a placeholder for convenience. It is ignored and simply
164          * discarded by PMDs.
165          *
166          * No associated specification structure.
167          */
168         RTE_FLOW_ITEM_TYPE_VOID,
169
170         /**
171          * [META]
172          *
173          * Inverted matching, i.e. process packets that do not match the
174          * pattern.
175          *
176          * No associated specification structure.
177          */
178         RTE_FLOW_ITEM_TYPE_INVERT,
179
180         /**
181          * Matches any protocol in place of the current layer, a single ANY
182          * may also stand for several protocol layers.
183          *
184          * See struct rte_flow_item_any.
185          */
186         RTE_FLOW_ITEM_TYPE_ANY,
187
188         /**
189          * @deprecated
190          * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
191          * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
192          *
193          * [META]
194          *
195          * Matches traffic originating from (ingress) or going to (egress)
196          * the physical function of the current device.
197          *
198          * No associated specification structure.
199          */
200         RTE_FLOW_ITEM_TYPE_PF,
201
202         /**
203          * @deprecated
204          * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
205          * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
206          *
207          * [META]
208          *
209          * Matches traffic originating from (ingress) or going to (egress) a
210          * given virtual function of the current device.
211          *
212          * See struct rte_flow_item_vf.
213          */
214         RTE_FLOW_ITEM_TYPE_VF,
215
216         /**
217          * @deprecated
218          * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
219          * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
220          *
221          * [META]
222          *
223          * Matches traffic originating from (ingress) or going to (egress) a
224          * physical port of the underlying device.
225          *
226          * See struct rte_flow_item_phy_port.
227          */
228         RTE_FLOW_ITEM_TYPE_PHY_PORT,
229
230         /**
231          * @deprecated
232          * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
233          * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
234          *
235          * [META]
236          *
237          * Matches traffic originating from (ingress) or going to (egress) a
238          * given DPDK port ID.
239          *
240          * See struct rte_flow_item_port_id.
241          */
242         RTE_FLOW_ITEM_TYPE_PORT_ID,
243
244         /**
245          * Matches a byte string of a given length at a given offset.
246          *
247          * See struct rte_flow_item_raw.
248          */
249         RTE_FLOW_ITEM_TYPE_RAW,
250
251         /**
252          * Matches an Ethernet header.
253          *
254          * See struct rte_flow_item_eth.
255          */
256         RTE_FLOW_ITEM_TYPE_ETH,
257
258         /**
259          * Matches an 802.1Q/ad VLAN tag.
260          *
261          * See struct rte_flow_item_vlan.
262          */
263         RTE_FLOW_ITEM_TYPE_VLAN,
264
265         /**
266          * Matches an IPv4 header.
267          *
268          * See struct rte_flow_item_ipv4.
269          */
270         RTE_FLOW_ITEM_TYPE_IPV4,
271
272         /**
273          * Matches an IPv6 header.
274          *
275          * See struct rte_flow_item_ipv6.
276          */
277         RTE_FLOW_ITEM_TYPE_IPV6,
278
279         /**
280          * Matches an ICMP header.
281          *
282          * See struct rte_flow_item_icmp.
283          */
284         RTE_FLOW_ITEM_TYPE_ICMP,
285
286         /**
287          * Matches a UDP header.
288          *
289          * See struct rte_flow_item_udp.
290          */
291         RTE_FLOW_ITEM_TYPE_UDP,
292
293         /**
294          * Matches a TCP header.
295          *
296          * See struct rte_flow_item_tcp.
297          */
298         RTE_FLOW_ITEM_TYPE_TCP,
299
300         /**
301          * Matches a SCTP header.
302          *
303          * See struct rte_flow_item_sctp.
304          */
305         RTE_FLOW_ITEM_TYPE_SCTP,
306
307         /**
308          * Matches a VXLAN header.
309          *
310          * See struct rte_flow_item_vxlan.
311          */
312         RTE_FLOW_ITEM_TYPE_VXLAN,
313
314         /**
315          * Matches a E_TAG header.
316          *
317          * See struct rte_flow_item_e_tag.
318          */
319         RTE_FLOW_ITEM_TYPE_E_TAG,
320
321         /**
322          * Matches a NVGRE header.
323          *
324          * See struct rte_flow_item_nvgre.
325          */
326         RTE_FLOW_ITEM_TYPE_NVGRE,
327
328         /**
329          * Matches a MPLS header.
330          *
331          * See struct rte_flow_item_mpls.
332          */
333         RTE_FLOW_ITEM_TYPE_MPLS,
334
335         /**
336          * Matches a GRE header.
337          *
338          * See struct rte_flow_item_gre.
339          */
340         RTE_FLOW_ITEM_TYPE_GRE,
341
342         /**
343          * [META]
344          *
345          * Fuzzy pattern match, expect faster than default.
346          *
347          * This is for device that support fuzzy matching option.
348          * Usually a fuzzy matching is fast but the cost is accuracy.
349          *
350          * See struct rte_flow_item_fuzzy.
351          */
352         RTE_FLOW_ITEM_TYPE_FUZZY,
353
354         /**
355          * Matches a GTP header.
356          *
357          * Configure flow for GTP packets.
358          *
359          * See struct rte_flow_item_gtp.
360          */
361         RTE_FLOW_ITEM_TYPE_GTP,
362
363         /**
364          * Matches a GTP header.
365          *
366          * Configure flow for GTP-C packets.
367          *
368          * See struct rte_flow_item_gtp.
369          */
370         RTE_FLOW_ITEM_TYPE_GTPC,
371
372         /**
373          * Matches a GTP header.
374          *
375          * Configure flow for GTP-U packets.
376          *
377          * See struct rte_flow_item_gtp.
378          */
379         RTE_FLOW_ITEM_TYPE_GTPU,
380
381         /**
382          * Matches a ESP header.
383          *
384          * See struct rte_flow_item_esp.
385          */
386         RTE_FLOW_ITEM_TYPE_ESP,
387
388         /**
389          * Matches a GENEVE header.
390          *
391          * See struct rte_flow_item_geneve.
392          */
393         RTE_FLOW_ITEM_TYPE_GENEVE,
394
395         /**
396          * Matches a VXLAN-GPE header.
397          *
398          * See struct rte_flow_item_vxlan_gpe.
399          */
400         RTE_FLOW_ITEM_TYPE_VXLAN_GPE,
401
402         /**
403          * Matches an ARP header for Ethernet/IPv4.
404          *
405          * See struct rte_flow_item_arp_eth_ipv4.
406          */
407         RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4,
408
409         /**
410          * Matches the presence of any IPv6 extension header.
411          *
412          * See struct rte_flow_item_ipv6_ext.
413          */
414         RTE_FLOW_ITEM_TYPE_IPV6_EXT,
415
416         /**
417          * Matches any ICMPv6 header.
418          *
419          * See struct rte_flow_item_icmp6.
420          */
421         RTE_FLOW_ITEM_TYPE_ICMP6,
422
423         /**
424          * Matches an ICMPv6 neighbor discovery solicitation.
425          *
426          * See struct rte_flow_item_icmp6_nd_ns.
427          */
428         RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS,
429
430         /**
431          * Matches an ICMPv6 neighbor discovery advertisement.
432          *
433          * See struct rte_flow_item_icmp6_nd_na.
434          */
435         RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA,
436
437         /**
438          * Matches the presence of any ICMPv6 neighbor discovery option.
439          *
440          * See struct rte_flow_item_icmp6_nd_opt.
441          */
442         RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT,
443
444         /**
445          * Matches an ICMPv6 neighbor discovery source Ethernet link-layer
446          * address option.
447          *
448          * See struct rte_flow_item_icmp6_nd_opt_sla_eth.
449          */
450         RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH,
451
452         /**
453          * Matches an ICMPv6 neighbor discovery target Ethernet link-layer
454          * address option.
455          *
456          * See struct rte_flow_item_icmp6_nd_opt_tla_eth.
457          */
458         RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH,
459
460         /**
461          * Matches specified mark field.
462          *
463          * See struct rte_flow_item_mark.
464          */
465         RTE_FLOW_ITEM_TYPE_MARK,
466
467         /**
468          * [META]
469          *
470          * Matches a metadata value.
471          *
472          * See struct rte_flow_item_meta.
473          */
474         RTE_FLOW_ITEM_TYPE_META,
475
476         /**
477          * Matches a GRE optional key field.
478          *
479          * The value should a big-endian 32bit integer.
480          *
481          * When this item present the K bit is implicitly matched as "1"
482          * in the default mask.
483          *
484          * @p spec/mask type:
485          * @code rte_be32_t * @endcode
486          */
487         RTE_FLOW_ITEM_TYPE_GRE_KEY,
488
489         /**
490          * Matches a GTP extension header: PDU session container.
491          *
492          * Configure flow for GTP packets with extension header type 0x85.
493          *
494          * See struct rte_flow_item_gtp_psc.
495          */
496         RTE_FLOW_ITEM_TYPE_GTP_PSC,
497
498         /**
499          * Matches a PPPoE header.
500          *
501          * Configure flow for PPPoE session packets.
502          *
503          * See struct rte_flow_item_pppoe.
504          */
505         RTE_FLOW_ITEM_TYPE_PPPOES,
506
507         /**
508          * Matches a PPPoE header.
509          *
510          * Configure flow for PPPoE discovery packets.
511          *
512          * See struct rte_flow_item_pppoe.
513          */
514         RTE_FLOW_ITEM_TYPE_PPPOED,
515
516         /**
517          * Matches a PPPoE optional proto_id field.
518          *
519          * It only applies to PPPoE session packets.
520          *
521          * See struct rte_flow_item_pppoe_proto_id.
522          */
523         RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID,
524
525         /**
526          * Matches Network service header (NSH).
527          * See struct rte_flow_item_nsh.
528          *
529          */
530         RTE_FLOW_ITEM_TYPE_NSH,
531
532         /**
533          * Matches Internet Group Management Protocol (IGMP).
534          * See struct rte_flow_item_igmp.
535          *
536          */
537         RTE_FLOW_ITEM_TYPE_IGMP,
538
539         /**
540          * Matches IP Authentication Header (AH).
541          * See struct rte_flow_item_ah.
542          *
543          */
544         RTE_FLOW_ITEM_TYPE_AH,
545
546         /**
547          * Matches a HIGIG header.
548          * see struct rte_flow_item_higig2_hdr.
549          */
550         RTE_FLOW_ITEM_TYPE_HIGIG2,
551
552         /**
553          * [META]
554          *
555          * Matches a tag value.
556          *
557          * See struct rte_flow_item_tag.
558          */
559         RTE_FLOW_ITEM_TYPE_TAG,
560
561         /**
562          * Matches a L2TPv3 over IP header.
563          *
564          * Configure flow for L2TPv3 over IP packets.
565          *
566          * See struct rte_flow_item_l2tpv3oip.
567          */
568         RTE_FLOW_ITEM_TYPE_L2TPV3OIP,
569
570         /**
571          * Matches PFCP Header.
572          * See struct rte_flow_item_pfcp.
573          *
574          */
575         RTE_FLOW_ITEM_TYPE_PFCP,
576
577         /**
578          * Matches eCPRI Header.
579          *
580          * Configure flow for eCPRI over ETH or UDP packets.
581          *
582          * See struct rte_flow_item_ecpri.
583          */
584         RTE_FLOW_ITEM_TYPE_ECPRI,
585
586         /**
587          * Matches the presence of IPv6 fragment extension header.
588          *
589          * See struct rte_flow_item_ipv6_frag_ext.
590          */
591         RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT,
592
593         /**
594          * Matches Geneve Variable Length Option
595          *
596          * See struct rte_flow_item_geneve_opt
597          */
598         RTE_FLOW_ITEM_TYPE_GENEVE_OPT,
599
600         /**
601          * [META]
602          *
603          * Matches on packet integrity.
604          * For some devices application needs to enable integration checks in HW
605          * before using this item.
606          *
607          * @see struct rte_flow_item_integrity.
608          */
609         RTE_FLOW_ITEM_TYPE_INTEGRITY,
610
611         /**
612          * [META]
613          *
614          * Matches conntrack state.
615          *
616          * @see struct rte_flow_item_conntrack.
617          */
618         RTE_FLOW_ITEM_TYPE_CONNTRACK,
619
620         /**
621          * [META]
622          *
623          * Matches traffic entering the embedded switch from the given ethdev.
624          *
625          * @see struct rte_flow_item_ethdev
626          */
627         RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR,
628
629         /**
630          * [META]
631          *
632          * Matches traffic entering the embedded switch from
633          * the entity represented by the given ethdev.
634          *
635          * @see struct rte_flow_item_ethdev
636          */
637         RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT,
638
639         /**
640          * Matches a configured set of fields at runtime calculated offsets
641          * over the generic network header with variable length and
642          * flexible pattern
643          *
644          * @see struct rte_flow_item_flex.
645          */
646         RTE_FLOW_ITEM_TYPE_FLEX,
647 };
648
649 /**
650  *
651  * RTE_FLOW_ITEM_TYPE_HIGIG2
652  * Matches higig2 header
653  */
654 RTE_STD_C11
655 struct rte_flow_item_higig2_hdr {
656         struct rte_higig2_hdr hdr;
657 };
658
659 /** Default mask for RTE_FLOW_ITEM_TYPE_HIGIG2. */
660 #ifndef __cplusplus
661 static const struct rte_flow_item_higig2_hdr rte_flow_item_higig2_hdr_mask = {
662         .hdr = {
663                 .ppt1 = {
664                         .classification = 0xffff,
665                         .vid = 0xfff,
666                 },
667         },
668 };
669 #endif
670
671 /**
672  * RTE_FLOW_ITEM_TYPE_ANY
673  *
674  * Matches any protocol in place of the current layer, a single ANY may also
675  * stand for several protocol layers.
676  *
677  * This is usually specified as the first pattern item when looking for a
678  * protocol anywhere in a packet.
679  *
680  * A zeroed mask stands for any number of layers.
681  */
682 struct rte_flow_item_any {
683         uint32_t num; /**< Number of layers covered. */
684 };
685
686 /** Default mask for RTE_FLOW_ITEM_TYPE_ANY. */
687 #ifndef __cplusplus
688 static const struct rte_flow_item_any rte_flow_item_any_mask = {
689         .num = 0x00000000,
690 };
691 #endif
692
693 /**
694  * @deprecated
695  * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
696  * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
697  *
698  * RTE_FLOW_ITEM_TYPE_VF
699  *
700  * Matches traffic originating from (ingress) or going to (egress) a given
701  * virtual function of the current device.
702  *
703  * If supported, should work even if the virtual function is not managed by
704  * the application and thus not associated with a DPDK port ID.
705  *
706  * Note this pattern item does not match VF representors traffic which, as
707  * separate entities, should be addressed through their own DPDK port IDs.
708  *
709  * - Can be specified multiple times to match traffic addressed to several
710  *   VF IDs.
711  * - Can be combined with a PF item to match both PF and VF traffic.
712  *
713  * A zeroed mask can be used to match any VF ID.
714  */
715 struct rte_flow_item_vf {
716         uint32_t id; /**< VF ID. */
717 };
718
719 /** Default mask for RTE_FLOW_ITEM_TYPE_VF. */
720 #ifndef __cplusplus
721 static const struct rte_flow_item_vf rte_flow_item_vf_mask = {
722         .id = 0x00000000,
723 };
724 #endif
725
726 /**
727  * @deprecated
728  * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
729  * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
730  *
731  * RTE_FLOW_ITEM_TYPE_PHY_PORT
732  *
733  * Matches traffic originating from (ingress) or going to (egress) a
734  * physical port of the underlying device.
735  *
736  * The first PHY_PORT item overrides the physical port normally associated
737  * with the specified DPDK input port (port_id). This item can be provided
738  * several times to match additional physical ports.
739  *
740  * Note that physical ports are not necessarily tied to DPDK input ports
741  * (port_id) when those are not under DPDK control. Possible values are
742  * specific to each device, they are not necessarily indexed from zero and
743  * may not be contiguous.
744  *
745  * As a device property, the list of allowed values as well as the value
746  * associated with a port_id should be retrieved by other means.
747  *
748  * A zeroed mask can be used to match any port index.
749  */
750 struct rte_flow_item_phy_port {
751         uint32_t index; /**< Physical port index. */
752 };
753
754 /** Default mask for RTE_FLOW_ITEM_TYPE_PHY_PORT. */
755 #ifndef __cplusplus
756 static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask = {
757         .index = 0x00000000,
758 };
759 #endif
760
761 /**
762  * @deprecated
763  * @see RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR
764  * @see RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT
765  *
766  * RTE_FLOW_ITEM_TYPE_PORT_ID
767  *
768  * Matches traffic originating from (ingress) or going to (egress) a given
769  * DPDK port ID.
770  *
771  * Normally only supported if the port ID in question is known by the
772  * underlying PMD and related to the device the flow rule is created
773  * against.
774  *
775  * This must not be confused with @p PHY_PORT which refers to the physical
776  * port of a device, whereas @p PORT_ID refers to a struct rte_eth_dev
777  * object on the application side (also known as "port representor"
778  * depending on the kind of underlying device).
779  */
780 struct rte_flow_item_port_id {
781         uint32_t id; /**< DPDK port ID. */
782 };
783
784 /** Default mask for RTE_FLOW_ITEM_TYPE_PORT_ID. */
785 #ifndef __cplusplus
786 static const struct rte_flow_item_port_id rte_flow_item_port_id_mask = {
787         .id = 0xffffffff,
788 };
789 #endif
790
791 /**
792  * RTE_FLOW_ITEM_TYPE_RAW
793  *
794  * Matches a byte string of a given length at a given offset.
795  *
796  * Offset is either absolute (using the start of the packet) or relative to
797  * the end of the previous matched item in the stack, in which case negative
798  * values are allowed.
799  *
800  * If search is enabled, offset is used as the starting point. The search
801  * area can be delimited by setting limit to a nonzero value, which is the
802  * maximum number of bytes after offset where the pattern may start.
803  *
804  * Matching a zero-length pattern is allowed, doing so resets the relative
805  * offset for subsequent items.
806  *
807  * This type does not support ranges (struct rte_flow_item.last).
808  */
809 struct rte_flow_item_raw {
810         uint32_t relative:1; /**< Look for pattern after the previous item. */
811         uint32_t search:1; /**< Search pattern from offset (see also limit). */
812         uint32_t reserved:30; /**< Reserved, must be set to zero. */
813         int32_t offset; /**< Absolute or relative offset for pattern. */
814         uint16_t limit; /**< Search area limit for start of pattern. */
815         uint16_t length; /**< Pattern length. */
816         const uint8_t *pattern; /**< Byte string to look for. */
817 };
818
819 /** Default mask for RTE_FLOW_ITEM_TYPE_RAW. */
820 #ifndef __cplusplus
821 static const struct rte_flow_item_raw rte_flow_item_raw_mask = {
822         .relative = 1,
823         .search = 1,
824         .reserved = 0x3fffffff,
825         .offset = 0xffffffff,
826         .limit = 0xffff,
827         .length = 0xffff,
828         .pattern = NULL,
829 };
830 #endif
831
832 /**
833  * RTE_FLOW_ITEM_TYPE_ETH
834  *
835  * Matches an Ethernet header.
836  *
837  * Inside @p hdr field, the sub-field @p ether_type stands either for EtherType
838  * or TPID, depending on whether the item is followed by a VLAN item or not. If
839  * two VLAN items follow, the sub-field refers to the outer one, which, in turn,
840  * contains the inner TPID in the similar header field. The innermost VLAN item
841  * contains a layer-3 EtherType. All of that follows the order seen on the wire.
842  *
843  * If the field in question contains a TPID value, only tagged packets with the
844  * specified TPID will match the pattern. Alternatively, it's possible to match
845  * any type of tagged packets by means of the field @p has_vlan rather than use
846  * the EtherType/TPID field. Also, it's possible to leave the two fields unused.
847  * If this is the case, both tagged and untagged packets will match the pattern.
848  */
849 RTE_STD_C11
850 struct rte_flow_item_eth {
851         union {
852                 struct {
853                         /*
854                          * These fields are retained for compatibility.
855                          * Please switch to the new header field below.
856                          */
857                         struct rte_ether_addr dst; /**< Destination MAC. */
858                         struct rte_ether_addr src; /**< Source MAC. */
859                         rte_be16_t type; /**< EtherType or TPID. */
860                 };
861                 struct rte_ether_hdr hdr;
862         };
863         uint32_t has_vlan:1; /**< Packet header contains at least one VLAN. */
864         uint32_t reserved:31; /**< Reserved, must be zero. */
865 };
866
867 /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */
868 #ifndef __cplusplus
869 static const struct rte_flow_item_eth rte_flow_item_eth_mask = {
870         .hdr.dst_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
871         .hdr.src_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff",
872         .hdr.ether_type = RTE_BE16(0x0000),
873 };
874 #endif
875
876 /**
877  * RTE_FLOW_ITEM_TYPE_VLAN
878  *
879  * Matches an 802.1Q/ad VLAN tag.
880  *
881  * The corresponding standard outer EtherType (TPID) values are
882  * RTE_ETHER_TYPE_VLAN or RTE_ETHER_TYPE_QINQ. It can be overridden by
883  * the preceding pattern item.
884  * If a @p VLAN item is present in the pattern, then only tagged packets will
885  * match the pattern.
886  * The field @p has_more_vlan can be used to match any type of tagged packets,
887  * instead of using the @p eth_proto field of @p hdr.
888  * If the @p eth_proto of @p hdr and @p has_more_vlan fields are not specified,
889  * then any tagged packets will match the pattern.
890  */
891 RTE_STD_C11
892 struct rte_flow_item_vlan {
893         union {
894                 struct {
895                         /*
896                          * These fields are retained for compatibility.
897                          * Please switch to the new header field below.
898                          */
899                         rte_be16_t tci; /**< Tag control information. */
900                         rte_be16_t inner_type; /**< Inner EtherType or TPID. */
901                 };
902                 struct rte_vlan_hdr hdr;
903         };
904         /** Packet header contains at least one more VLAN, after this VLAN. */
905         uint32_t has_more_vlan:1;
906         uint32_t reserved:31; /**< Reserved, must be zero. */
907 };
908
909 /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */
910 #ifndef __cplusplus
911 static const struct rte_flow_item_vlan rte_flow_item_vlan_mask = {
912         .hdr.vlan_tci = RTE_BE16(0x0fff),
913         .hdr.eth_proto = RTE_BE16(0x0000),
914 };
915 #endif
916
917 /**
918  * RTE_FLOW_ITEM_TYPE_IPV4
919  *
920  * Matches an IPv4 header.
921  *
922  * Note: IPv4 options are handled by dedicated pattern items.
923  */
924 struct rte_flow_item_ipv4 {
925         struct rte_ipv4_hdr hdr; /**< IPv4 header definition. */
926 };
927
928 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV4. */
929 #ifndef __cplusplus
930 static const struct rte_flow_item_ipv4 rte_flow_item_ipv4_mask = {
931         .hdr = {
932                 .src_addr = RTE_BE32(0xffffffff),
933                 .dst_addr = RTE_BE32(0xffffffff),
934         },
935 };
936 #endif
937
938 /**
939  * RTE_FLOW_ITEM_TYPE_IPV6.
940  *
941  * Matches an IPv6 header.
942  *
943  * Dedicated flags indicate if header contains specific extension headers.
944  */
945 struct rte_flow_item_ipv6 {
946         struct rte_ipv6_hdr hdr; /**< IPv6 header definition. */
947         /** Header contains Hop-by-Hop Options extension header. */
948         uint32_t has_hop_ext:1;
949         /** Header contains Routing extension header. */
950         uint32_t has_route_ext:1;
951         /** Header contains Fragment extension header. */
952         uint32_t has_frag_ext:1;
953         /** Header contains Authentication extension header. */
954         uint32_t has_auth_ext:1;
955         /** Header contains Encapsulation Security Payload extension header. */
956         uint32_t has_esp_ext:1;
957         /** Header contains Destination Options extension header. */
958         uint32_t has_dest_ext:1;
959         /** Header contains Mobility extension header. */
960         uint32_t has_mobil_ext:1;
961         /** Header contains Host Identity Protocol extension header. */
962         uint32_t has_hip_ext:1;
963         /** Header contains Shim6 Protocol extension header. */
964         uint32_t has_shim6_ext:1;
965         /** Reserved for future extension headers, must be zero. */
966         uint32_t reserved:23;
967 };
968
969 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
970 #ifndef __cplusplus
971 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
972         .hdr = {
973                 .src_addr =
974                         "\xff\xff\xff\xff\xff\xff\xff\xff"
975                         "\xff\xff\xff\xff\xff\xff\xff\xff",
976                 .dst_addr =
977                         "\xff\xff\xff\xff\xff\xff\xff\xff"
978                         "\xff\xff\xff\xff\xff\xff\xff\xff",
979         },
980 };
981 #endif
982
983 /**
984  * RTE_FLOW_ITEM_TYPE_ICMP.
985  *
986  * Matches an ICMP header.
987  */
988 struct rte_flow_item_icmp {
989         struct rte_icmp_hdr hdr; /**< ICMP header definition. */
990 };
991
992 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP. */
993 #ifndef __cplusplus
994 static const struct rte_flow_item_icmp rte_flow_item_icmp_mask = {
995         .hdr = {
996                 .icmp_type = 0xff,
997                 .icmp_code = 0xff,
998         },
999 };
1000 #endif
1001
1002 /**
1003  * RTE_FLOW_ITEM_TYPE_UDP.
1004  *
1005  * Matches a UDP header.
1006  */
1007 struct rte_flow_item_udp {
1008         struct rte_udp_hdr hdr; /**< UDP header definition. */
1009 };
1010
1011 /** Default mask for RTE_FLOW_ITEM_TYPE_UDP. */
1012 #ifndef __cplusplus
1013 static const struct rte_flow_item_udp rte_flow_item_udp_mask = {
1014         .hdr = {
1015                 .src_port = RTE_BE16(0xffff),
1016                 .dst_port = RTE_BE16(0xffff),
1017         },
1018 };
1019 #endif
1020
1021 /**
1022  * RTE_FLOW_ITEM_TYPE_TCP.
1023  *
1024  * Matches a TCP header.
1025  */
1026 struct rte_flow_item_tcp {
1027         struct rte_tcp_hdr hdr; /**< TCP header definition. */
1028 };
1029
1030 /** Default mask for RTE_FLOW_ITEM_TYPE_TCP. */
1031 #ifndef __cplusplus
1032 static const struct rte_flow_item_tcp rte_flow_item_tcp_mask = {
1033         .hdr = {
1034                 .src_port = RTE_BE16(0xffff),
1035                 .dst_port = RTE_BE16(0xffff),
1036         },
1037 };
1038 #endif
1039
1040 /**
1041  * RTE_FLOW_ITEM_TYPE_SCTP.
1042  *
1043  * Matches a SCTP header.
1044  */
1045 struct rte_flow_item_sctp {
1046         struct rte_sctp_hdr hdr; /**< SCTP header definition. */
1047 };
1048
1049 /** Default mask for RTE_FLOW_ITEM_TYPE_SCTP. */
1050 #ifndef __cplusplus
1051 static const struct rte_flow_item_sctp rte_flow_item_sctp_mask = {
1052         .hdr = {
1053                 .src_port = RTE_BE16(0xffff),
1054                 .dst_port = RTE_BE16(0xffff),
1055         },
1056 };
1057 #endif
1058
1059 /**
1060  * RTE_FLOW_ITEM_TYPE_VXLAN.
1061  *
1062  * Matches a VXLAN header (RFC 7348).
1063  */
1064 RTE_STD_C11
1065 struct rte_flow_item_vxlan {
1066         union {
1067                 struct {
1068                         /*
1069                          * These fields are retained for compatibility.
1070                          * Please switch to the new header field below.
1071                          */
1072                         uint8_t flags; /**< Normally 0x08 (I flag). */
1073                         uint8_t rsvd0[3]; /**< Reserved, normally 0x000000. */
1074                         uint8_t vni[3]; /**< VXLAN identifier. */
1075                         uint8_t rsvd1; /**< Reserved, normally 0x00. */
1076                 };
1077                 struct rte_vxlan_hdr hdr;
1078         };
1079 };
1080
1081 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN. */
1082 #ifndef __cplusplus
1083 static const struct rte_flow_item_vxlan rte_flow_item_vxlan_mask = {
1084         .hdr.vx_vni = RTE_BE32(0xffffff00), /* (0xffffff << 8) */
1085 };
1086 #endif
1087
1088 /**
1089  * RTE_FLOW_ITEM_TYPE_E_TAG.
1090  *
1091  * Matches a E-tag header.
1092  *
1093  * The corresponding standard outer EtherType (TPID) value is
1094  * RTE_ETHER_TYPE_ETAG. It can be overridden by the preceding pattern item.
1095  */
1096 struct rte_flow_item_e_tag {
1097         /**
1098          * E-Tag control information (E-TCI).
1099          * E-PCP (3b), E-DEI (1b), ingress E-CID base (12b).
1100          */
1101         rte_be16_t epcp_edei_in_ecid_b;
1102         /** Reserved (2b), GRP (2b), E-CID base (12b). */
1103         rte_be16_t rsvd_grp_ecid_b;
1104         uint8_t in_ecid_e; /**< Ingress E-CID ext. */
1105         uint8_t ecid_e; /**< E-CID ext. */
1106         rte_be16_t inner_type; /**< Inner EtherType or TPID. */
1107 };
1108
1109 /** Default mask for RTE_FLOW_ITEM_TYPE_E_TAG. */
1110 #ifndef __cplusplus
1111 static const struct rte_flow_item_e_tag rte_flow_item_e_tag_mask = {
1112         .rsvd_grp_ecid_b = RTE_BE16(0x3fff),
1113 };
1114 #endif
1115
1116 /**
1117  * RTE_FLOW_ITEM_TYPE_NVGRE.
1118  *
1119  * Matches a NVGRE header.
1120  */
1121 struct rte_flow_item_nvgre {
1122         /**
1123          * Checksum (1b), undefined (1b), key bit (1b), sequence number (1b),
1124          * reserved 0 (9b), version (3b).
1125          *
1126          * c_k_s_rsvd0_ver must have value 0x2000 according to RFC 7637.
1127          */
1128         rte_be16_t c_k_s_rsvd0_ver;
1129         rte_be16_t protocol; /**< Protocol type (0x6558). */
1130         uint8_t tni[3]; /**< Virtual subnet ID. */
1131         uint8_t flow_id; /**< Flow ID. */
1132 };
1133
1134 /** Default mask for RTE_FLOW_ITEM_TYPE_NVGRE. */
1135 #ifndef __cplusplus
1136 static const struct rte_flow_item_nvgre rte_flow_item_nvgre_mask = {
1137         .tni = "\xff\xff\xff",
1138 };
1139 #endif
1140
1141 /**
1142  * RTE_FLOW_ITEM_TYPE_MPLS.
1143  *
1144  * Matches a MPLS header.
1145  */
1146 struct rte_flow_item_mpls {
1147         /**
1148          * Label (20b), TC (3b), Bottom of Stack (1b).
1149          */
1150         uint8_t label_tc_s[3];
1151         uint8_t ttl; /** Time-to-Live. */
1152 };
1153
1154 /** Default mask for RTE_FLOW_ITEM_TYPE_MPLS. */
1155 #ifndef __cplusplus
1156 static const struct rte_flow_item_mpls rte_flow_item_mpls_mask = {
1157         .label_tc_s = "\xff\xff\xf0",
1158 };
1159 #endif
1160
1161 /**
1162  * RTE_FLOW_ITEM_TYPE_GRE.
1163  *
1164  * Matches a GRE header.
1165  */
1166 struct rte_flow_item_gre {
1167         /**
1168          * Checksum (1b), reserved 0 (12b), version (3b).
1169          * Refer to RFC 2784.
1170          */
1171         rte_be16_t c_rsvd0_ver;
1172         rte_be16_t protocol; /**< Protocol type. */
1173 };
1174
1175 /** Default mask for RTE_FLOW_ITEM_TYPE_GRE. */
1176 #ifndef __cplusplus
1177 static const struct rte_flow_item_gre rte_flow_item_gre_mask = {
1178         .protocol = RTE_BE16(0xffff),
1179 };
1180 #endif
1181
1182 /**
1183  * RTE_FLOW_ITEM_TYPE_FUZZY
1184  *
1185  * Fuzzy pattern match, expect faster than default.
1186  *
1187  * This is for device that support fuzzy match option.
1188  * Usually a fuzzy match is fast but the cost is accuracy.
1189  * i.e. Signature Match only match pattern's hash value, but it is
1190  * possible two different patterns have the same hash value.
1191  *
1192  * Matching accuracy level can be configure by threshold.
1193  * Driver can divide the range of threshold and map to different
1194  * accuracy levels that device support.
1195  *
1196  * Threshold 0 means perfect match (no fuzziness), while threshold
1197  * 0xffffffff means fuzziest match.
1198  */
1199 struct rte_flow_item_fuzzy {
1200         uint32_t thresh; /**< Accuracy threshold. */
1201 };
1202
1203 /** Default mask for RTE_FLOW_ITEM_TYPE_FUZZY. */
1204 #ifndef __cplusplus
1205 static const struct rte_flow_item_fuzzy rte_flow_item_fuzzy_mask = {
1206         .thresh = 0xffffffff,
1207 };
1208 #endif
1209
1210 /**
1211  * RTE_FLOW_ITEM_TYPE_GTP.
1212  *
1213  * Matches a GTPv1 header.
1214  */
1215 struct rte_flow_item_gtp {
1216         /**
1217          * Version (3b), protocol type (1b), reserved (1b),
1218          * Extension header flag (1b),
1219          * Sequence number flag (1b),
1220          * N-PDU number flag (1b).
1221          */
1222         uint8_t v_pt_rsv_flags;
1223         uint8_t msg_type; /**< Message type. */
1224         rte_be16_t msg_len; /**< Message length. */
1225         rte_be32_t teid; /**< Tunnel endpoint identifier. */
1226 };
1227
1228 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP. */
1229 #ifndef __cplusplus
1230 static const struct rte_flow_item_gtp rte_flow_item_gtp_mask = {
1231         .teid = RTE_BE32(0xffffffff),
1232 };
1233 #endif
1234
1235 /**
1236  * RTE_FLOW_ITEM_TYPE_ESP
1237  *
1238  * Matches an ESP header.
1239  */
1240 struct rte_flow_item_esp {
1241         struct rte_esp_hdr hdr; /**< ESP header definition. */
1242 };
1243
1244 /** Default mask for RTE_FLOW_ITEM_TYPE_ESP. */
1245 #ifndef __cplusplus
1246 static const struct rte_flow_item_esp rte_flow_item_esp_mask = {
1247         .hdr = {
1248                 .spi = RTE_BE32(0xffffffff),
1249         },
1250 };
1251 #endif
1252
1253 /**
1254  * RTE_FLOW_ITEM_TYPE_GENEVE.
1255  *
1256  * Matches a GENEVE header.
1257  */
1258 struct rte_flow_item_geneve {
1259         /**
1260          * Version (2b), length of the options fields (6b), OAM packet (1b),
1261          * critical options present (1b), reserved 0 (6b).
1262          */
1263         rte_be16_t ver_opt_len_o_c_rsvd0;
1264         rte_be16_t protocol; /**< Protocol type. */
1265         uint8_t vni[3]; /**< Virtual Network Identifier. */
1266         uint8_t rsvd1; /**< Reserved, normally 0x00. */
1267 };
1268
1269 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE. */
1270 #ifndef __cplusplus
1271 static const struct rte_flow_item_geneve rte_flow_item_geneve_mask = {
1272         .vni = "\xff\xff\xff",
1273 };
1274 #endif
1275
1276 /**
1277  * RTE_FLOW_ITEM_TYPE_VXLAN_GPE (draft-ietf-nvo3-vxlan-gpe-05).
1278  *
1279  * Matches a VXLAN-GPE header.
1280  */
1281 struct rte_flow_item_vxlan_gpe {
1282         uint8_t flags; /**< Normally 0x0c (I and P flags). */
1283         uint8_t rsvd0[2]; /**< Reserved, normally 0x0000. */
1284         uint8_t protocol; /**< Protocol type. */
1285         uint8_t vni[3]; /**< VXLAN identifier. */
1286         uint8_t rsvd1; /**< Reserved, normally 0x00. */
1287 };
1288
1289 /** Default mask for RTE_FLOW_ITEM_TYPE_VXLAN_GPE. */
1290 #ifndef __cplusplus
1291 static const struct rte_flow_item_vxlan_gpe rte_flow_item_vxlan_gpe_mask = {
1292         .vni = "\xff\xff\xff",
1293 };
1294 #endif
1295
1296 /**
1297  * RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4
1298  *
1299  * Matches an ARP header for Ethernet/IPv4.
1300  */
1301 struct rte_flow_item_arp_eth_ipv4 {
1302         rte_be16_t hrd; /**< Hardware type, normally 1. */
1303         rte_be16_t pro; /**< Protocol type, normally 0x0800. */
1304         uint8_t hln; /**< Hardware address length, normally 6. */
1305         uint8_t pln; /**< Protocol address length, normally 4. */
1306         rte_be16_t op; /**< Opcode (1 for request, 2 for reply). */
1307         struct rte_ether_addr sha; /**< Sender hardware address. */
1308         rte_be32_t spa; /**< Sender IPv4 address. */
1309         struct rte_ether_addr tha; /**< Target hardware address. */
1310         rte_be32_t tpa; /**< Target IPv4 address. */
1311 };
1312
1313 /** Default mask for RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4. */
1314 #ifndef __cplusplus
1315 static const struct rte_flow_item_arp_eth_ipv4
1316 rte_flow_item_arp_eth_ipv4_mask = {
1317         .sha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1318         .spa = RTE_BE32(0xffffffff),
1319         .tha.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1320         .tpa = RTE_BE32(0xffffffff),
1321 };
1322 #endif
1323
1324 /**
1325  * RTE_FLOW_ITEM_TYPE_IPV6_EXT
1326  *
1327  * Matches the presence of any IPv6 extension header.
1328  *
1329  * Normally preceded by any of:
1330  *
1331  * - RTE_FLOW_ITEM_TYPE_IPV6
1332  * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1333  */
1334 struct rte_flow_item_ipv6_ext {
1335         uint8_t next_hdr; /**< Next header. */
1336 };
1337
1338 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6_EXT. */
1339 #ifndef __cplusplus
1340 static const
1341 struct rte_flow_item_ipv6_ext rte_flow_item_ipv6_ext_mask = {
1342         .next_hdr = 0xff,
1343 };
1344 #endif
1345
1346 /**
1347  * RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT
1348  *
1349  * Matches the presence of IPv6 fragment extension header.
1350  *
1351  * Preceded by any of:
1352  *
1353  * - RTE_FLOW_ITEM_TYPE_IPV6
1354  * - RTE_FLOW_ITEM_TYPE_IPV6_EXT
1355  */
1356 struct rte_flow_item_ipv6_frag_ext {
1357         struct rte_ipv6_fragment_ext hdr;
1358 };
1359
1360 /**
1361  * RTE_FLOW_ITEM_TYPE_ICMP6
1362  *
1363  * Matches any ICMPv6 header.
1364  */
1365 struct rte_flow_item_icmp6 {
1366         uint8_t type; /**< ICMPv6 type. */
1367         uint8_t code; /**< ICMPv6 code. */
1368         uint16_t checksum; /**< ICMPv6 checksum. */
1369 };
1370
1371 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6. */
1372 #ifndef __cplusplus
1373 static const struct rte_flow_item_icmp6 rte_flow_item_icmp6_mask = {
1374         .type = 0xff,
1375         .code = 0xff,
1376 };
1377 #endif
1378
1379 /**
1380  * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1381  *
1382  * Matches an ICMPv6 neighbor discovery solicitation.
1383  */
1384 struct rte_flow_item_icmp6_nd_ns {
1385         uint8_t type; /**< ICMPv6 type, normally 135. */
1386         uint8_t code; /**< ICMPv6 code, normally 0. */
1387         rte_be16_t checksum; /**< ICMPv6 checksum. */
1388         rte_be32_t reserved; /**< Reserved, normally 0. */
1389         uint8_t target_addr[16]; /**< Target address. */
1390 };
1391
1392 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS. */
1393 #ifndef __cplusplus
1394 static const
1395 struct rte_flow_item_icmp6_nd_ns rte_flow_item_icmp6_nd_ns_mask = {
1396         .target_addr =
1397                 "\xff\xff\xff\xff\xff\xff\xff\xff"
1398                 "\xff\xff\xff\xff\xff\xff\xff\xff",
1399 };
1400 #endif
1401
1402 /**
1403  * RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1404  *
1405  * Matches an ICMPv6 neighbor discovery advertisement.
1406  */
1407 struct rte_flow_item_icmp6_nd_na {
1408         uint8_t type; /**< ICMPv6 type, normally 136. */
1409         uint8_t code; /**< ICMPv6 code, normally 0. */
1410         rte_be16_t checksum; /**< ICMPv6 checksum. */
1411         /**
1412          * Route flag (1b), solicited flag (1b), override flag (1b),
1413          * reserved (29b).
1414          */
1415         rte_be32_t rso_reserved;
1416         uint8_t target_addr[16]; /**< Target address. */
1417 };
1418
1419 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA. */
1420 #ifndef __cplusplus
1421 static const
1422 struct rte_flow_item_icmp6_nd_na rte_flow_item_icmp6_nd_na_mask = {
1423         .target_addr =
1424                 "\xff\xff\xff\xff\xff\xff\xff\xff"
1425                 "\xff\xff\xff\xff\xff\xff\xff\xff",
1426 };
1427 #endif
1428
1429 /**
1430  * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1431  *
1432  * Matches the presence of any ICMPv6 neighbor discovery option.
1433  *
1434  * Normally preceded by any of:
1435  *
1436  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1437  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1438  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1439  */
1440 struct rte_flow_item_icmp6_nd_opt {
1441         uint8_t type; /**< ND option type. */
1442         uint8_t length; /**< ND option length. */
1443 };
1444
1445 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT. */
1446 #ifndef __cplusplus
1447 static const struct rte_flow_item_icmp6_nd_opt
1448 rte_flow_item_icmp6_nd_opt_mask = {
1449         .type = 0xff,
1450 };
1451 #endif
1452
1453 /**
1454  * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH
1455  *
1456  * Matches an ICMPv6 neighbor discovery source Ethernet link-layer address
1457  * option.
1458  *
1459  * Normally preceded by any of:
1460  *
1461  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA
1462  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1463  */
1464 struct rte_flow_item_icmp6_nd_opt_sla_eth {
1465         uint8_t type; /**< ND option type, normally 1. */
1466         uint8_t length; /**< ND option length, normally 1. */
1467         struct rte_ether_addr sla; /**< Source Ethernet LLA. */
1468 };
1469
1470 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH. */
1471 #ifndef __cplusplus
1472 static const struct rte_flow_item_icmp6_nd_opt_sla_eth
1473 rte_flow_item_icmp6_nd_opt_sla_eth_mask = {
1474         .sla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1475 };
1476 #endif
1477
1478 /**
1479  * RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH
1480  *
1481  * Matches an ICMPv6 neighbor discovery target Ethernet link-layer address
1482  * option.
1483  *
1484  * Normally preceded by any of:
1485  *
1486  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS
1487  * - RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT
1488  */
1489 struct rte_flow_item_icmp6_nd_opt_tla_eth {
1490         uint8_t type; /**< ND option type, normally 2. */
1491         uint8_t length; /**< ND option length, normally 1. */
1492         struct rte_ether_addr tla; /**< Target Ethernet LLA. */
1493 };
1494
1495 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH. */
1496 #ifndef __cplusplus
1497 static const struct rte_flow_item_icmp6_nd_opt_tla_eth
1498 rte_flow_item_icmp6_nd_opt_tla_eth_mask = {
1499         .tla.addr_bytes = "\xff\xff\xff\xff\xff\xff",
1500 };
1501 #endif
1502
1503 /**
1504  * RTE_FLOW_ITEM_TYPE_META
1505  *
1506  * Matches a specified metadata value. On egress, metadata can be set
1507  * either by mbuf dynamic metadata field with PKT_TX_DYNF_METADATA flag or
1508  * RTE_FLOW_ACTION_TYPE_SET_META. On ingress, RTE_FLOW_ACTION_TYPE_SET_META
1509  * sets metadata for a packet and the metadata will be reported via mbuf
1510  * metadata dynamic field with PKT_RX_DYNF_METADATA flag. The dynamic mbuf
1511  * field must be registered in advance by rte_flow_dynf_metadata_register().
1512  */
1513 struct rte_flow_item_meta {
1514         uint32_t data;
1515 };
1516
1517 /** Default mask for RTE_FLOW_ITEM_TYPE_META. */
1518 #ifndef __cplusplus
1519 static const struct rte_flow_item_meta rte_flow_item_meta_mask = {
1520         .data = UINT32_MAX,
1521 };
1522 #endif
1523
1524 /**
1525  * RTE_FLOW_ITEM_TYPE_GTP_PSC.
1526  *
1527  * Matches a GTP PDU extension header with type 0x85.
1528  */
1529 struct rte_flow_item_gtp_psc {
1530         struct rte_gtp_psc_generic_hdr hdr; /**< gtp psc generic hdr. */
1531 };
1532
1533 /** Default mask for RTE_FLOW_ITEM_TYPE_GTP_PSC. */
1534 #ifndef __cplusplus
1535 static const struct rte_flow_item_gtp_psc
1536 rte_flow_item_gtp_psc_mask = {
1537         .hdr.qfi = 0x3f,
1538 };
1539 #endif
1540
1541 /**
1542  * RTE_FLOW_ITEM_TYPE_PPPOE.
1543  *
1544  * Matches a PPPoE header.
1545  */
1546 struct rte_flow_item_pppoe {
1547         /**
1548          * Version (4b), type (4b).
1549          */
1550         uint8_t version_type;
1551         uint8_t code; /**< Message type. */
1552         rte_be16_t session_id; /**< Session identifier. */
1553         rte_be16_t length; /**< Payload length. */
1554 };
1555
1556 /**
1557  * RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID.
1558  *
1559  * Matches a PPPoE optional proto_id field.
1560  *
1561  * It only applies to PPPoE session packets.
1562  *
1563  * Normally preceded by any of:
1564  *
1565  * - RTE_FLOW_ITEM_TYPE_PPPOE
1566  * - RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID
1567  */
1568 struct rte_flow_item_pppoe_proto_id {
1569         rte_be16_t proto_id; /**< PPP protocol identifier. */
1570 };
1571
1572 /** Default mask for RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID. */
1573 #ifndef __cplusplus
1574 static const struct rte_flow_item_pppoe_proto_id
1575 rte_flow_item_pppoe_proto_id_mask = {
1576         .proto_id = RTE_BE16(0xffff),
1577 };
1578 #endif
1579
1580 /**
1581  * @warning
1582  * @b EXPERIMENTAL: this structure may change without prior notice
1583  *
1584  * RTE_FLOW_ITEM_TYPE_TAG
1585  *
1586  * Matches a specified tag value at the specified index.
1587  */
1588 struct rte_flow_item_tag {
1589         uint32_t data;
1590         uint8_t index;
1591 };
1592
1593 /** Default mask for RTE_FLOW_ITEM_TYPE_TAG. */
1594 #ifndef __cplusplus
1595 static const struct rte_flow_item_tag rte_flow_item_tag_mask = {
1596         .data = 0xffffffff,
1597         .index = 0xff,
1598 };
1599 #endif
1600
1601 /**
1602  * RTE_FLOW_ITEM_TYPE_L2TPV3OIP.
1603  *
1604  * Matches a L2TPv3 over IP header.
1605  */
1606 struct rte_flow_item_l2tpv3oip {
1607         rte_be32_t session_id; /**< Session ID. */
1608 };
1609
1610 /** Default mask for RTE_FLOW_ITEM_TYPE_L2TPV3OIP. */
1611 #ifndef __cplusplus
1612 static const struct rte_flow_item_l2tpv3oip rte_flow_item_l2tpv3oip_mask = {
1613         .session_id = RTE_BE32(UINT32_MAX),
1614 };
1615 #endif
1616
1617
1618 /**
1619  * @warning
1620  * @b EXPERIMENTAL: this structure may change without prior notice
1621  *
1622  * RTE_FLOW_ITEM_TYPE_MARK
1623  *
1624  * Matches an arbitrary integer value which was set using the ``MARK`` action
1625  * in a previously matched rule.
1626  *
1627  * This item can only be specified once as a match criteria as the ``MARK``
1628  * action can only be specified once in a flow action.
1629  *
1630  * This value is arbitrary and application-defined. Maximum allowed value
1631  * depends on the underlying implementation.
1632  *
1633  * Depending on the underlying implementation the MARK item may be supported on
1634  * the physical device, with virtual groups in the PMD or not at all.
1635  */
1636 struct rte_flow_item_mark {
1637         uint32_t id; /**< Integer value to match against. */
1638 };
1639
1640 /** Default mask for RTE_FLOW_ITEM_TYPE_MARK. */
1641 #ifndef __cplusplus
1642 static const struct rte_flow_item_mark rte_flow_item_mark_mask = {
1643         .id = 0xffffffff,
1644 };
1645 #endif
1646
1647 /**
1648  * @warning
1649  * @b EXPERIMENTAL: this structure may change without prior notice
1650  *
1651  * RTE_FLOW_ITEM_TYPE_NSH
1652  *
1653  * Match network service header (NSH), RFC 8300
1654  *
1655  */
1656 struct rte_flow_item_nsh {
1657         uint32_t version:2;
1658         uint32_t oam_pkt:1;
1659         uint32_t reserved:1;
1660         uint32_t ttl:6;
1661         uint32_t length:6;
1662         uint32_t reserved1:4;
1663         uint32_t mdtype:4;
1664         uint32_t next_proto:8;
1665         uint32_t spi:24;
1666         uint32_t sindex:8;
1667 };
1668
1669 /** Default mask for RTE_FLOW_ITEM_TYPE_NSH. */
1670 #ifndef __cplusplus
1671 static const struct rte_flow_item_nsh rte_flow_item_nsh_mask = {
1672         .mdtype = 0xf,
1673         .next_proto = 0xff,
1674         .spi = 0xffffff,
1675         .sindex = 0xff,
1676 };
1677 #endif
1678
1679 /**
1680  * @warning
1681  * @b EXPERIMENTAL: this structure may change without prior notice
1682  *
1683  * RTE_FLOW_ITEM_TYPE_IGMP
1684  *
1685  * Match Internet Group Management Protocol (IGMP), RFC 2236
1686  *
1687  */
1688 struct rte_flow_item_igmp {
1689         uint32_t type:8;
1690         uint32_t max_resp_time:8;
1691         uint32_t checksum:16;
1692         uint32_t group_addr;
1693 };
1694
1695 /** Default mask for RTE_FLOW_ITEM_TYPE_IGMP. */
1696 #ifndef __cplusplus
1697 static const struct rte_flow_item_igmp rte_flow_item_igmp_mask = {
1698         .group_addr = 0xffffffff,
1699 };
1700 #endif
1701
1702 /**
1703  * @warning
1704  * @b EXPERIMENTAL: this structure may change without prior notice
1705  *
1706  * RTE_FLOW_ITEM_TYPE_AH
1707  *
1708  * Match IP Authentication Header (AH), RFC 4302
1709  *
1710  */
1711 struct rte_flow_item_ah {
1712         uint32_t next_hdr:8;
1713         uint32_t payload_len:8;
1714         uint32_t reserved:16;
1715         uint32_t spi;
1716         uint32_t seq_num;
1717 };
1718
1719 /** Default mask for RTE_FLOW_ITEM_TYPE_AH. */
1720 #ifndef __cplusplus
1721 static const struct rte_flow_item_ah rte_flow_item_ah_mask = {
1722         .spi = 0xffffffff,
1723 };
1724 #endif
1725
1726 /**
1727  * @warning
1728  * @b EXPERIMENTAL: this structure may change without prior notice
1729  *
1730  * RTE_FLOW_ITEM_TYPE_PFCP
1731  *
1732  * Match PFCP Header
1733  */
1734 struct rte_flow_item_pfcp {
1735         uint8_t s_field;
1736         uint8_t msg_type;
1737         rte_be16_t msg_len;
1738         rte_be64_t seid;
1739 };
1740
1741 /** Default mask for RTE_FLOW_ITEM_TYPE_PFCP. */
1742 #ifndef __cplusplus
1743 static const struct rte_flow_item_pfcp rte_flow_item_pfcp_mask = {
1744         .s_field = 0x01,
1745         .seid = RTE_BE64(UINT64_C(0xffffffffffffffff)),
1746 };
1747 #endif
1748
1749 /**
1750  * @warning
1751  * @b EXPERIMENTAL: this structure may change without prior notice
1752  *
1753  * RTE_FLOW_ITEM_TYPE_ECPRI
1754  *
1755  * Match eCPRI Header
1756  */
1757 struct rte_flow_item_ecpri {
1758         struct rte_ecpri_combined_msg_hdr hdr;
1759 };
1760
1761 /** Default mask for RTE_FLOW_ITEM_TYPE_ECPRI. */
1762 #ifndef __cplusplus
1763 static const struct rte_flow_item_ecpri rte_flow_item_ecpri_mask = {
1764         .hdr = {
1765                 .common = {
1766                         .u32 = 0x0,
1767                 },
1768         },
1769 };
1770 #endif
1771
1772 /**
1773  * RTE_FLOW_ITEM_TYPE_GENEVE_OPT
1774  *
1775  * Matches a GENEVE Variable Length Option
1776  */
1777 struct rte_flow_item_geneve_opt {
1778         rte_be16_t option_class;
1779         uint8_t option_type;
1780         uint8_t option_len;
1781         uint32_t *data;
1782 };
1783
1784 /** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE_OPT. */
1785 #ifndef __cplusplus
1786 static const struct rte_flow_item_geneve_opt
1787 rte_flow_item_geneve_opt_mask = {
1788         .option_type = 0xff,
1789 };
1790 #endif
1791
1792 /**
1793  * @warning
1794  * @b EXPERIMENTAL: this structure may change without prior notice
1795  *
1796  * RTE_FLOW_ITEM_TYPE_INTEGRITY
1797  *
1798  * Match on packet integrity check result.
1799  */
1800 struct rte_flow_item_integrity {
1801         /** Tunnel encapsulation level the item should apply to.
1802          * @see rte_flow_action_rss
1803          */
1804         uint32_t level;
1805         RTE_STD_C11
1806         union {
1807                 __extension__
1808                 struct {
1809                         /** The packet is valid after passing all HW checks. */
1810                         uint64_t packet_ok:1;
1811                         /** L2 layer is valid after passing all HW checks. */
1812                         uint64_t l2_ok:1;
1813                         /** L3 layer is valid after passing all HW checks. */
1814                         uint64_t l3_ok:1;
1815                         /** L4 layer is valid after passing all HW checks. */
1816                         uint64_t l4_ok:1;
1817                         /** L2 layer CRC is valid. */
1818                         uint64_t l2_crc_ok:1;
1819                         /** IPv4 layer checksum is valid. */
1820                         uint64_t ipv4_csum_ok:1;
1821                         /** L4 layer checksum is valid. */
1822                         uint64_t l4_csum_ok:1;
1823                         /** L3 length is smaller than frame length. */
1824                         uint64_t l3_len_ok:1;
1825                         uint64_t reserved:56;
1826                 };
1827                 uint64_t value;
1828         };
1829 };
1830
1831 #ifndef __cplusplus
1832 static const struct rte_flow_item_integrity
1833 rte_flow_item_integrity_mask = {
1834         .level = 0,
1835         .value = 0,
1836 };
1837 #endif
1838
1839 /**
1840  * The packet is valid after conntrack checking.
1841  */
1842 #define RTE_FLOW_CONNTRACK_PKT_STATE_VALID RTE_BIT32(0)
1843 /**
1844  * The state of the connection is changed.
1845  */
1846 #define RTE_FLOW_CONNTRACK_PKT_STATE_CHANGED RTE_BIT32(1)
1847 /**
1848  * Error is detected on this packet for this connection and
1849  * an invalid state is set.
1850  */
1851 #define RTE_FLOW_CONNTRACK_PKT_STATE_INVALID RTE_BIT32(2)
1852 /**
1853  * The HW connection tracking module is disabled.
1854  * It can be due to application command or an invalid state.
1855  */
1856 #define RTE_FLOW_CONNTRACK_PKT_STATE_DISABLED RTE_BIT32(3)
1857 /**
1858  * The packet contains some bad field(s) and cannot continue
1859  * with the conntrack module checking.
1860  */
1861 #define RTE_FLOW_CONNTRACK_PKT_STATE_BAD RTE_BIT32(4)
1862
1863 /**
1864  * @warning
1865  * @b EXPERIMENTAL: this structure may change without prior notice
1866  *
1867  * RTE_FLOW_ITEM_TYPE_CONNTRACK
1868  *
1869  * Matches the state of a packet after it passed the connection tracking
1870  * examination. The state is a bitmap of one RTE_FLOW_CONNTRACK_PKT_STATE*
1871  * or a reasonable combination of these bits.
1872  */
1873 struct rte_flow_item_conntrack {
1874         uint32_t flags;
1875 };
1876
1877 /** Default mask for RTE_FLOW_ITEM_TYPE_CONNTRACK. */
1878 #ifndef __cplusplus
1879 static const struct rte_flow_item_conntrack rte_flow_item_conntrack_mask = {
1880         .flags = 0xffffffff,
1881 };
1882 #endif
1883
1884 /**
1885  * @warning
1886  * @b EXPERIMENTAL: this structure may change without prior notice
1887  *
1888  * Provides an ethdev port ID for use with the following items:
1889  * RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR,
1890  * RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT.
1891  */
1892 struct rte_flow_item_ethdev {
1893         uint16_t port_id; /**< ethdev port ID */
1894 };
1895
1896 /** Default mask for items based on struct rte_flow_item_ethdev */
1897 #ifndef __cplusplus
1898 static const struct rte_flow_item_ethdev rte_flow_item_ethdev_mask = {
1899         .port_id = 0xffff,
1900 };
1901 #endif
1902
1903 /**
1904  * Matching pattern item definition.
1905  *
1906  * A pattern is formed by stacking items starting from the lowest protocol
1907  * layer to match. This stacking restriction does not apply to meta items
1908  * which can be placed anywhere in the stack without affecting the meaning
1909  * of the resulting pattern.
1910  *
1911  * Patterns are terminated by END items.
1912  *
1913  * The spec field should be a valid pointer to a structure of the related
1914  * item type. It may remain unspecified (NULL) in many cases to request
1915  * broad (nonspecific) matching. In such cases, last and mask must also be
1916  * set to NULL.
1917  *
1918  * Optionally, last can point to a structure of the same type to define an
1919  * inclusive range. This is mostly supported by integer and address fields,
1920  * may cause errors otherwise. Fields that do not support ranges must be set
1921  * to 0 or to the same value as the corresponding fields in spec.
1922  *
1923  * Only the fields defined to nonzero values in the default masks (see
1924  * rte_flow_item_{name}_mask constants) are considered relevant by
1925  * default. This can be overridden by providing a mask structure of the
1926  * same type with applicable bits set to one. It can also be used to
1927  * partially filter out specific fields (e.g. as an alternate mean to match
1928  * ranges of IP addresses).
1929  *
1930  * Mask is a simple bit-mask applied before interpreting the contents of
1931  * spec and last, which may yield unexpected results if not used
1932  * carefully. For example, if for an IPv4 address field, spec provides
1933  * 10.1.2.3, last provides 10.3.4.5 and mask provides 255.255.0.0, the
1934  * effective range becomes 10.1.0.0 to 10.3.255.255.
1935  */
1936 struct rte_flow_item {
1937         enum rte_flow_item_type type; /**< Item type. */
1938         const void *spec; /**< Pointer to item specification structure. */
1939         const void *last; /**< Defines an inclusive range (spec to last). */
1940         const void *mask; /**< Bit-mask applied to spec and last. */
1941 };
1942
1943 /**
1944  * @warning
1945  * @b EXPERIMENTAL: this structure may change without prior notice
1946  *
1947  * RTE_FLOW_ITEM_TYPE_FLEX
1948  *
1949  * Matches a specified set of fields within the network protocol
1950  * header. Each field is presented as set of bits with specified width, and
1951  * bit offset from the header beginning.
1952  *
1953  * The pattern is concatenation of bit fields configured at item creation
1954  * by rte_flow_flex_item_create(). At configuration the fields are presented
1955  * by sample_data array.
1956  *
1957  * This type does not support ranges (struct rte_flow_item.last).
1958  */
1959 struct rte_flow_item_flex {
1960         struct rte_flow_item_flex_handle *handle; /**< Opaque item handle. */
1961         uint32_t length; /**< Pattern length in bytes. */
1962         const uint8_t *pattern; /**< Combined bitfields pattern to match. */
1963 };
1964 /**
1965  * Field bit offset calculation mode.
1966  */
1967 enum rte_flow_item_flex_field_mode {
1968         /**
1969          * Dummy field, used for byte boundary alignment in pattern.
1970          * Pattern mask and data are ignored in the match. All configuration
1971          * parameters besides field size are ignored.
1972          */
1973         FIELD_MODE_DUMMY = 0,
1974         /**
1975          * Fixed offset field. The bit offset from header beginning
1976          * is permanent and defined by field_base parameter.
1977          */
1978         FIELD_MODE_FIXED,
1979         /**
1980          * The field bit offset is extracted from other header field (indirect
1981          * offset field). The resulting field offset to match is calculated as:
1982          *
1983          *    field_base + (*offset_base & offset_mask) << offset_shift
1984          */
1985         FIELD_MODE_OFFSET,
1986         /**
1987          * The field bit offset is extracted from other header field (indirect
1988          * offset field), the latter is considered as bitmask containing some
1989          * number of one bits, the resulting field offset to match is
1990          * calculated as:
1991          *
1992          *    field_base + bitcount(*offset_base & offset_mask) << offset_shift
1993          */
1994         FIELD_MODE_BITMASK,
1995 };
1996
1997 /**
1998  * Flex item field tunnel mode
1999  */
2000 enum rte_flow_item_flex_tunnel_mode {
2001         /**
2002          * The protocol header can be present in the packet only once.
2003          * No multiple flex item flow inclusions (for inner/outer) are allowed.
2004          * No any relations with tunnel protocols are imposed. The drivers
2005          * can optimize hardware resource usage to handle match on single flex
2006          * item of specific type.
2007          */
2008         FLEX_TUNNEL_MODE_SINGLE = 0,
2009         /**
2010          * Flex item presents outer header only.
2011          */
2012         FLEX_TUNNEL_MODE_OUTER,
2013         /**
2014          * Flex item presents inner header only.
2015          */
2016         FLEX_TUNNEL_MODE_INNER,
2017         /**
2018          * Flex item presents either inner or outer header. The driver
2019          * handles as many multiple inners as hardware supports.
2020          */
2021         FLEX_TUNNEL_MODE_MULTI,
2022         /**
2023          * Flex item presents tunnel protocol header.
2024          */
2025         FLEX_TUNNEL_MODE_TUNNEL,
2026 };
2027
2028 /**
2029  *
2030  * @warning
2031  * @b EXPERIMENTAL: this structure may change without prior notice
2032  */
2033 __extension__
2034 struct rte_flow_item_flex_field {
2035         /** Defines how match field offset is calculated over the packet. */
2036         enum rte_flow_item_flex_field_mode field_mode;
2037         uint32_t field_size; /**< Field size in bits. */
2038         int32_t field_base; /**< Field offset in bits. */
2039         uint32_t offset_base; /**< Indirect offset field offset in bits. */
2040         uint32_t offset_mask; /**< Indirect offset field bit mask. */
2041         int32_t offset_shift; /**< Indirect offset multiply factor. */
2042         uint32_t field_id:16; /**< Device hint, for multiple items in flow. */
2043         uint32_t reserved:16; /**< Reserved field. */
2044 };
2045
2046 /**
2047  * @warning
2048  * @b EXPERIMENTAL: this structure may change without prior notice
2049  */
2050 struct rte_flow_item_flex_link {
2051         /**
2052          * Preceding/following header. The item type must be always provided.
2053          * For preceding one item must specify the header value/mask to match
2054          * for the link be taken and start the flex item header parsing.
2055          */
2056         struct rte_flow_item item;
2057         /**
2058          * Next field value to match to continue with one of the configured
2059          * next protocols.
2060          */
2061         uint32_t next;
2062 };
2063
2064 /**
2065  * @warning
2066  * @b EXPERIMENTAL: this structure may change without prior notice
2067  */
2068 struct rte_flow_item_flex_conf {
2069         /**
2070          * Specifies the flex item and tunnel relations and tells the PMD
2071          * whether flex item can be used for inner, outer or both headers,
2072          * or whether flex item presents the tunnel protocol itself.
2073          */
2074         enum rte_flow_item_flex_tunnel_mode tunnel;
2075         /**
2076          * The next header offset, it presents the network header size covered
2077          * by the flex item and can be obtained with all supported offset
2078          * calculating methods (fixed, dedicated field, bitmask, etc).
2079          */
2080         struct rte_flow_item_flex_field next_header;
2081         /**
2082          * Specifies the next protocol field to match with link next protocol
2083          * values and continue packet parsing with matching link.
2084          */
2085         struct rte_flow_item_flex_field next_protocol;
2086         /**
2087          * The fields will be sampled and presented for explicit match
2088          * with pattern in the rte_flow_flex_item. There can be multiple
2089          * fields descriptors, the number should be specified by nb_samples.
2090          */
2091         struct rte_flow_item_flex_field *sample_data;
2092         /** Number of field descriptors in the sample_data array. */
2093         uint32_t nb_samples;
2094         /**
2095          * Input link defines the flex item relation with preceding
2096          * header. It specified the preceding item type and provides pattern
2097          * to match. The flex item will continue parsing and will provide the
2098          * data to flow match in case if there is the match with one of input
2099          * links.
2100          */
2101         struct rte_flow_item_flex_link *input_link;
2102         /** Number of link descriptors in the input link array. */
2103         uint32_t nb_inputs;
2104         /**
2105          * Output link defines the next protocol field value to match and
2106          * the following protocol header to continue packet parsing. Also
2107          * defines the tunnel-related behaviour.
2108          */
2109         struct rte_flow_item_flex_link *output_link;
2110         /** Number of link descriptors in the output link array. */
2111         uint32_t nb_outputs;
2112 };
2113
2114 /**
2115  * Action types.
2116  *
2117  * Each possible action is represented by a type.
2118  * An action can have an associated configuration object.
2119  * Several actions combined in a list can be assigned
2120  * to a flow rule and are performed in order.
2121  *
2122  * They fall in three categories:
2123  *
2124  * - Actions that modify the fate of matching traffic, for instance by
2125  *   dropping or assigning it a specific destination.
2126  *
2127  * - Actions that modify matching traffic contents or its properties. This
2128  *   includes adding/removing encapsulation, encryption, compression and
2129  *   marks.
2130  *
2131  * - Actions related to the flow rule itself, such as updating counters or
2132  *   making it non-terminating.
2133  *
2134  * Flow rules being terminating by default, not specifying any action of the
2135  * fate kind results in undefined behavior. This applies to both ingress and
2136  * egress.
2137  *
2138  * PASSTHRU, when supported, makes a flow rule non-terminating.
2139  */
2140 enum rte_flow_action_type {
2141         /**
2142          * End marker for action lists. Prevents further processing of
2143          * actions, thereby ending the list.
2144          *
2145          * No associated configuration structure.
2146          */
2147         RTE_FLOW_ACTION_TYPE_END,
2148
2149         /**
2150          * Used as a placeholder for convenience. It is ignored and simply
2151          * discarded by PMDs.
2152          *
2153          * No associated configuration structure.
2154          */
2155         RTE_FLOW_ACTION_TYPE_VOID,
2156
2157         /**
2158          * Leaves traffic up for additional processing by subsequent flow
2159          * rules; makes a flow rule non-terminating.
2160          *
2161          * No associated configuration structure.
2162          */
2163         RTE_FLOW_ACTION_TYPE_PASSTHRU,
2164
2165         /**
2166          * RTE_FLOW_ACTION_TYPE_JUMP
2167          *
2168          * Redirects packets to a group on the current device.
2169          *
2170          * See struct rte_flow_action_jump.
2171          */
2172         RTE_FLOW_ACTION_TYPE_JUMP,
2173
2174         /**
2175          * Attaches an integer value to packets and sets PKT_RX_FDIR and
2176          * PKT_RX_FDIR_ID mbuf flags.
2177          *
2178          * See struct rte_flow_action_mark.
2179          *
2180          * One should negotiate mark delivery from the NIC to the PMD.
2181          * @see rte_eth_rx_metadata_negotiate()
2182          * @see RTE_ETH_RX_METADATA_USER_MARK
2183          */
2184         RTE_FLOW_ACTION_TYPE_MARK,
2185
2186         /**
2187          * Flags packets. Similar to MARK without a specific value; only
2188          * sets the PKT_RX_FDIR mbuf flag.
2189          *
2190          * No associated configuration structure.
2191          *
2192          * One should negotiate flag delivery from the NIC to the PMD.
2193          * @see rte_eth_rx_metadata_negotiate()
2194          * @see RTE_ETH_RX_METADATA_USER_FLAG
2195          */
2196         RTE_FLOW_ACTION_TYPE_FLAG,
2197
2198         /**
2199          * Assigns packets to a given queue index.
2200          *
2201          * See struct rte_flow_action_queue.
2202          */
2203         RTE_FLOW_ACTION_TYPE_QUEUE,
2204
2205         /**
2206          * Drops packets.
2207          *
2208          * PASSTHRU overrides this action if both are specified.
2209          *
2210          * No associated configuration structure.
2211          */
2212         RTE_FLOW_ACTION_TYPE_DROP,
2213
2214         /**
2215          * Enables counters for this flow rule.
2216          *
2217          * These counters can be retrieved and reset through rte_flow_query() or
2218          * rte_flow_action_handle_query() if the action provided via handle,
2219          * see struct rte_flow_query_count.
2220          *
2221          * See struct rte_flow_action_count.
2222          */
2223         RTE_FLOW_ACTION_TYPE_COUNT,
2224
2225         /**
2226          * Similar to QUEUE, except RSS is additionally performed on packets
2227          * to spread them among several queues according to the provided
2228          * parameters.
2229          *
2230          * See struct rte_flow_action_rss.
2231          */
2232         RTE_FLOW_ACTION_TYPE_RSS,
2233
2234         /**
2235          * @deprecated
2236          * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2237          * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2238          *
2239          * Directs matching traffic to the physical function (PF) of the
2240          * current device.
2241          *
2242          * No associated configuration structure.
2243          */
2244         RTE_FLOW_ACTION_TYPE_PF,
2245
2246         /**
2247          * @deprecated
2248          * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2249          * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2250          *
2251          * Directs matching traffic to a given virtual function of the
2252          * current device.
2253          *
2254          * See struct rte_flow_action_vf.
2255          */
2256         RTE_FLOW_ACTION_TYPE_VF,
2257
2258         /**
2259          * @deprecated
2260          * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2261          * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2262          *
2263          * Directs packets to a given physical port index of the underlying
2264          * device.
2265          *
2266          * See struct rte_flow_action_phy_port.
2267          */
2268         RTE_FLOW_ACTION_TYPE_PHY_PORT,
2269
2270         /**
2271          * @deprecated
2272          * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2273          * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2274          *
2275          * Directs matching traffic to a given DPDK port ID.
2276          *
2277          * See struct rte_flow_action_port_id.
2278          */
2279         RTE_FLOW_ACTION_TYPE_PORT_ID,
2280
2281         /**
2282          * Traffic metering and policing (MTR).
2283          *
2284          * See struct rte_flow_action_meter.
2285          * See file rte_mtr.h for MTR object configuration.
2286          */
2287         RTE_FLOW_ACTION_TYPE_METER,
2288
2289         /**
2290          * Redirects packets to security engine of current device for security
2291          * processing as specified by security session.
2292          *
2293          * See struct rte_flow_action_security.
2294          */
2295         RTE_FLOW_ACTION_TYPE_SECURITY,
2296
2297         /**
2298          * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the
2299          * OpenFlow Switch Specification.
2300          *
2301          * See struct rte_flow_action_of_set_mpls_ttl.
2302          */
2303         RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL,
2304
2305         /**
2306          * Implements OFPAT_DEC_MPLS_TTL ("decrement MPLS TTL") as defined
2307          * by the OpenFlow Switch Specification.
2308          *
2309          * No associated configuration structure.
2310          */
2311         RTE_FLOW_ACTION_TYPE_OF_DEC_MPLS_TTL,
2312
2313         /**
2314          * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow
2315          * Switch Specification.
2316          *
2317          * See struct rte_flow_action_of_set_nw_ttl.
2318          */
2319         RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL,
2320
2321         /**
2322          * Implements OFPAT_DEC_NW_TTL ("decrement IP TTL") as defined by
2323          * the OpenFlow Switch Specification.
2324          *
2325          * No associated configuration structure.
2326          */
2327         RTE_FLOW_ACTION_TYPE_OF_DEC_NW_TTL,
2328
2329         /**
2330          * Implements OFPAT_COPY_TTL_OUT ("copy TTL "outwards" -- from
2331          * next-to-outermost to outermost") as defined by the OpenFlow
2332          * Switch Specification.
2333          *
2334          * No associated configuration structure.
2335          */
2336         RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_OUT,
2337
2338         /**
2339          * Implements OFPAT_COPY_TTL_IN ("copy TTL "inwards" -- from
2340          * outermost to next-to-outermost") as defined by the OpenFlow
2341          * Switch Specification.
2342          *
2343          * No associated configuration structure.
2344          */
2345         RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_IN,
2346
2347         /**
2348          * Implements OFPAT_POP_VLAN ("pop the outer VLAN tag") as defined
2349          * by the OpenFlow Switch Specification.
2350          *
2351          * No associated configuration structure.
2352          */
2353         RTE_FLOW_ACTION_TYPE_OF_POP_VLAN,
2354
2355         /**
2356          * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by
2357          * the OpenFlow Switch Specification.
2358          *
2359          * See struct rte_flow_action_of_push_vlan.
2360          */
2361         RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
2362
2363         /**
2364          * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN ID") as
2365          * defined by the OpenFlow Switch Specification.
2366          *
2367          * See struct rte_flow_action_of_set_vlan_vid.
2368          */
2369         RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
2370
2371         /**
2372          * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as
2373          * defined by the OpenFlow Switch Specification.
2374          *
2375          * See struct rte_flow_action_of_set_vlan_pcp.
2376          */
2377         RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
2378
2379         /**
2380          * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined
2381          * by the OpenFlow Switch Specification.
2382          *
2383          * See struct rte_flow_action_of_pop_mpls.
2384          */
2385         RTE_FLOW_ACTION_TYPE_OF_POP_MPLS,
2386
2387         /**
2388          * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by
2389          * the OpenFlow Switch Specification.
2390          *
2391          * See struct rte_flow_action_of_push_mpls.
2392          */
2393         RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS,
2394
2395         /**
2396          * Encapsulate flow in VXLAN tunnel as defined in
2397          * rte_flow_action_vxlan_encap action structure.
2398          *
2399          * See struct rte_flow_action_vxlan_encap.
2400          */
2401         RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP,
2402
2403         /**
2404          * Decapsulate outer most VXLAN tunnel from matched flow.
2405          *
2406          * If flow pattern does not define a valid VXLAN tunnel (as specified by
2407          * RFC7348) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
2408          * error.
2409          */
2410         RTE_FLOW_ACTION_TYPE_VXLAN_DECAP,
2411
2412         /**
2413          * Encapsulate flow in NVGRE tunnel defined in the
2414          * rte_flow_action_nvgre_encap action structure.
2415          *
2416          * See struct rte_flow_action_nvgre_encap.
2417          */
2418         RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP,
2419
2420         /**
2421          * Decapsulate outer most NVGRE tunnel from matched flow.
2422          *
2423          * If flow pattern does not define a valid NVGRE tunnel (as specified by
2424          * RFC7637) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION
2425          * error.
2426          */
2427         RTE_FLOW_ACTION_TYPE_NVGRE_DECAP,
2428
2429         /**
2430          * Add outer header whose template is provided in its data buffer
2431          *
2432          * See struct rte_flow_action_raw_encap.
2433          */
2434         RTE_FLOW_ACTION_TYPE_RAW_ENCAP,
2435
2436         /**
2437          * Remove outer header whose template is provided in its data buffer.
2438          *
2439          * See struct rte_flow_action_raw_decap
2440          */
2441         RTE_FLOW_ACTION_TYPE_RAW_DECAP,
2442
2443         /**
2444          * Modify IPv4 source address in the outermost IPv4 header.
2445          *
2446          * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2447          * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2448          *
2449          * See struct rte_flow_action_set_ipv4.
2450          */
2451         RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC,
2452
2453         /**
2454          * Modify IPv4 destination address in the outermost IPv4 header.
2455          *
2456          * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2457          * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2458          *
2459          * See struct rte_flow_action_set_ipv4.
2460          */
2461         RTE_FLOW_ACTION_TYPE_SET_IPV4_DST,
2462
2463         /**
2464          * Modify IPv6 source address in the outermost IPv6 header.
2465          *
2466          * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2467          * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2468          *
2469          * See struct rte_flow_action_set_ipv6.
2470          */
2471         RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC,
2472
2473         /**
2474          * Modify IPv6 destination address in the outermost IPv6 header.
2475          *
2476          * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2477          * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2478          *
2479          * See struct rte_flow_action_set_ipv6.
2480          */
2481         RTE_FLOW_ACTION_TYPE_SET_IPV6_DST,
2482
2483         /**
2484          * Modify source port number in the outermost TCP/UDP header.
2485          *
2486          * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
2487          * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
2488          * RTE_FLOW_ERROR_TYPE_ACTION error.
2489          *
2490          * See struct rte_flow_action_set_tp.
2491          */
2492         RTE_FLOW_ACTION_TYPE_SET_TP_SRC,
2493
2494         /**
2495          * Modify destination port number in the outermost TCP/UDP header.
2496          *
2497          * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP
2498          * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a
2499          * RTE_FLOW_ERROR_TYPE_ACTION error.
2500          *
2501          * See struct rte_flow_action_set_tp.
2502          */
2503         RTE_FLOW_ACTION_TYPE_SET_TP_DST,
2504
2505         /**
2506          * Swap the source and destination MAC addresses in the outermost
2507          * Ethernet header.
2508          *
2509          * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2510          * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2511          *
2512          * No associated configuration structure.
2513          */
2514         RTE_FLOW_ACTION_TYPE_MAC_SWAP,
2515
2516         /**
2517          * Decrease TTL value directly
2518          *
2519          * No associated configuration structure.
2520          */
2521         RTE_FLOW_ACTION_TYPE_DEC_TTL,
2522
2523         /**
2524          * Set TTL value
2525          *
2526          * See struct rte_flow_action_set_ttl
2527          */
2528         RTE_FLOW_ACTION_TYPE_SET_TTL,
2529
2530         /**
2531          * Set source MAC address from matched flow.
2532          *
2533          * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2534          * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2535          *
2536          * See struct rte_flow_action_set_mac.
2537          */
2538         RTE_FLOW_ACTION_TYPE_SET_MAC_SRC,
2539
2540         /**
2541          * Set destination MAC address from matched flow.
2542          *
2543          * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH,
2544          * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2545          *
2546          * See struct rte_flow_action_set_mac.
2547          */
2548         RTE_FLOW_ACTION_TYPE_SET_MAC_DST,
2549
2550         /**
2551          * Increase sequence number in the outermost TCP header.
2552          *
2553          * Action configuration specifies the value to increase
2554          * TCP sequence number as a big-endian 32 bit integer.
2555          *
2556          * @p conf type:
2557          * @code rte_be32_t * @endcode
2558          *
2559          * Using this action on non-matching traffic will result in
2560          * undefined behavior.
2561          */
2562         RTE_FLOW_ACTION_TYPE_INC_TCP_SEQ,
2563
2564         /**
2565          * Decrease sequence number in the outermost TCP header.
2566          *
2567          * Action configuration specifies the value to decrease
2568          * TCP sequence number as a big-endian 32 bit integer.
2569          *
2570          * @p conf type:
2571          * @code rte_be32_t * @endcode
2572          *
2573          * Using this action on non-matching traffic will result in
2574          * undefined behavior.
2575          */
2576         RTE_FLOW_ACTION_TYPE_DEC_TCP_SEQ,
2577
2578         /**
2579          * Increase acknowledgment number in the outermost TCP header.
2580          *
2581          * Action configuration specifies the value to increase
2582          * TCP acknowledgment number as a big-endian 32 bit integer.
2583          *
2584          * @p conf type:
2585          * @code rte_be32_t * @endcode
2586
2587          * Using this action on non-matching traffic will result in
2588          * undefined behavior.
2589          */
2590         RTE_FLOW_ACTION_TYPE_INC_TCP_ACK,
2591
2592         /**
2593          * Decrease acknowledgment number in the outermost TCP header.
2594          *
2595          * Action configuration specifies the value to decrease
2596          * TCP acknowledgment number as a big-endian 32 bit integer.
2597          *
2598          * @p conf type:
2599          * @code rte_be32_t * @endcode
2600          *
2601          * Using this action on non-matching traffic will result in
2602          * undefined behavior.
2603          */
2604         RTE_FLOW_ACTION_TYPE_DEC_TCP_ACK,
2605
2606         /**
2607          * Set Tag.
2608          *
2609          * Tag is for internal flow usage only and
2610          * is not delivered to the application.
2611          *
2612          * See struct rte_flow_action_set_tag.
2613          */
2614         RTE_FLOW_ACTION_TYPE_SET_TAG,
2615
2616         /**
2617          * Set metadata on ingress or egress path.
2618          *
2619          * See struct rte_flow_action_set_meta.
2620          */
2621         RTE_FLOW_ACTION_TYPE_SET_META,
2622
2623         /**
2624          * Modify IPv4 DSCP in the outermost IP header.
2625          *
2626          * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4,
2627          * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2628          *
2629          * See struct rte_flow_action_set_dscp.
2630          */
2631         RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP,
2632
2633         /**
2634          * Modify IPv6 DSCP in the outermost IP header.
2635          *
2636          * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6,
2637          * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error.
2638          *
2639          * See struct rte_flow_action_set_dscp.
2640          */
2641         RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP,
2642
2643         /**
2644          * Report as aged flow if timeout passed without any matching on the
2645          * flow.
2646          *
2647          * See struct rte_flow_action_age.
2648          * See function rte_flow_get_aged_flows
2649          * see enum RTE_ETH_EVENT_FLOW_AGED
2650          * See struct rte_flow_query_age
2651          */
2652         RTE_FLOW_ACTION_TYPE_AGE,
2653
2654         /**
2655          * The matching packets will be duplicated with specified ratio and
2656          * applied with own set of actions with a fate action.
2657          *
2658          * See struct rte_flow_action_sample.
2659          */
2660         RTE_FLOW_ACTION_TYPE_SAMPLE,
2661
2662         /**
2663          * @deprecated
2664          * @see RTE_FLOW_ACTION_TYPE_INDIRECT
2665          *
2666          * Describe action shared across multiple flow rules.
2667          *
2668          * Allow multiple rules reference the same action by handle (see
2669          * struct rte_flow_shared_action).
2670          */
2671         RTE_FLOW_ACTION_TYPE_SHARED,
2672
2673         /**
2674          * Modify a packet header field, tag, mark or metadata.
2675          *
2676          * Allow the modification of an arbitrary header field via
2677          * set, add and sub operations or copying its content into
2678          * tag, meta or mark for future processing.
2679          *
2680          * See struct rte_flow_action_modify_field.
2681          */
2682         RTE_FLOW_ACTION_TYPE_MODIFY_FIELD,
2683
2684         /**
2685          * An action handle is referenced in a rule through an indirect action.
2686          *
2687          * The same action handle may be used in multiple rules for the same
2688          * or different ethdev ports.
2689          */
2690         RTE_FLOW_ACTION_TYPE_INDIRECT,
2691
2692         /**
2693          * [META]
2694          *
2695          * Enable tracking a TCP connection state.
2696          *
2697          * @see struct rte_flow_action_conntrack.
2698          */
2699         RTE_FLOW_ACTION_TYPE_CONNTRACK,
2700
2701         /**
2702          * Color the packet to reflect the meter color result.
2703          * Set the meter color in the mbuf to the selected color.
2704          *
2705          * See struct rte_flow_action_meter_color.
2706          */
2707         RTE_FLOW_ACTION_TYPE_METER_COLOR,
2708
2709         /**
2710          * At embedded switch level, sends matching traffic to the given ethdev.
2711          *
2712          * @see struct rte_flow_action_ethdev
2713          */
2714         RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR,
2715
2716         /**
2717          * At embedded switch level, send matching traffic to
2718          * the entity represented by the given ethdev.
2719          *
2720          * @see struct rte_flow_action_ethdev
2721          */
2722         RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT,
2723 };
2724
2725 /**
2726  * RTE_FLOW_ACTION_TYPE_MARK
2727  *
2728  * Attaches an integer value to packets and sets PKT_RX_FDIR and
2729  * PKT_RX_FDIR_ID mbuf flags.
2730  *
2731  * This value is arbitrary and application-defined. Maximum allowed value
2732  * depends on the underlying implementation. It is returned in the
2733  * hash.fdir.hi mbuf field.
2734  */
2735 struct rte_flow_action_mark {
2736         uint32_t id; /**< Integer value to return with packets. */
2737 };
2738
2739 /**
2740  * @warning
2741  * @b EXPERIMENTAL: this structure may change without prior notice
2742  *
2743  * RTE_FLOW_ACTION_TYPE_JUMP
2744  *
2745  * Redirects packets to a group on the current device.
2746  *
2747  * In a hierarchy of groups, which can be used to represent physical or logical
2748  * flow tables on the device, this action allows the action to be a redirect to
2749  * a group on that device.
2750  */
2751 struct rte_flow_action_jump {
2752         uint32_t group;
2753 };
2754
2755 /**
2756  * RTE_FLOW_ACTION_TYPE_QUEUE
2757  *
2758  * Assign packets to a given queue index.
2759  */
2760 struct rte_flow_action_queue {
2761         uint16_t index; /**< Queue index to use. */
2762 };
2763
2764 /**
2765  * @warning
2766  * @b EXPERIMENTAL: this structure may change without prior notice
2767  *
2768  * RTE_FLOW_ACTION_TYPE_AGE
2769  *
2770  * Report flow as aged-out if timeout passed without any matching
2771  * on the flow. RTE_ETH_EVENT_FLOW_AGED event is triggered when a
2772  * port detects new aged-out flows.
2773  *
2774  * The flow context and the flow handle will be reported by the
2775  * rte_flow_get_aged_flows API.
2776  */
2777 struct rte_flow_action_age {
2778         uint32_t timeout:24; /**< Time in seconds. */
2779         uint32_t reserved:8; /**< Reserved, must be zero. */
2780         /** The user flow context, NULL means the rte_flow pointer. */
2781         void *context;
2782 };
2783
2784 /**
2785  * RTE_FLOW_ACTION_TYPE_AGE (query)
2786  *
2787  * Query structure to retrieve the aging status information of a
2788  * shared AGE action, or a flow rule using the AGE action.
2789  */
2790 struct rte_flow_query_age {
2791         uint32_t reserved:6; /**< Reserved, must be zero. */
2792         uint32_t aged:1; /**< 1 if aging timeout expired, 0 otherwise. */
2793         /** sec_since_last_hit value is valid. */
2794         uint32_t sec_since_last_hit_valid:1;
2795         uint32_t sec_since_last_hit:24; /**< Seconds since last traffic hit. */
2796 };
2797
2798 /**
2799  * @warning
2800  * @b EXPERIMENTAL: this structure may change without prior notice
2801  *
2802  * RTE_FLOW_ACTION_TYPE_COUNT
2803  *
2804  * Adds a counter action to a matched flow.
2805  *
2806  * If more than one count action is specified in a single flow rule, then each
2807  * action must specify a unique id.
2808  *
2809  * Counters can be retrieved and reset through ``rte_flow_query()``, see
2810  * ``struct rte_flow_query_count``.
2811  *
2812  * For ports within the same switch domain then the counter id namespace extends
2813  * to all ports within that switch domain.
2814  */
2815 struct rte_flow_action_count {
2816         uint32_t id; /**< Counter ID. */
2817 };
2818
2819 /**
2820  * RTE_FLOW_ACTION_TYPE_COUNT (query)
2821  *
2822  * Query structure to retrieve and reset flow rule counters.
2823  */
2824 struct rte_flow_query_count {
2825         uint32_t reset:1; /**< Reset counters after query [in]. */
2826         uint32_t hits_set:1; /**< hits field is set [out]. */
2827         uint32_t bytes_set:1; /**< bytes field is set [out]. */
2828         uint32_t reserved:29; /**< Reserved, must be zero [in, out]. */
2829         uint64_t hits; /**< Number of hits for this rule [out]. */
2830         uint64_t bytes; /**< Number of bytes through this rule [out]. */
2831 };
2832
2833 /**
2834  * Hash function types.
2835  */
2836 enum rte_eth_hash_function {
2837         RTE_ETH_HASH_FUNCTION_DEFAULT = 0,
2838         RTE_ETH_HASH_FUNCTION_TOEPLITZ, /**< Toeplitz */
2839         RTE_ETH_HASH_FUNCTION_SIMPLE_XOR, /**< Simple XOR */
2840         /**
2841          * Symmetric Toeplitz: src, dst will be replaced by
2842          * xor(src, dst). For the case with src/dst only,
2843          * src or dst address will xor with zero pair.
2844          */
2845         RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ,
2846         RTE_ETH_HASH_FUNCTION_MAX,
2847 };
2848
2849 /**
2850  * RTE_FLOW_ACTION_TYPE_RSS
2851  *
2852  * Similar to QUEUE, except RSS is additionally performed on packets to
2853  * spread them among several queues according to the provided parameters.
2854  *
2855  * Unlike global RSS settings used by other DPDK APIs, unsetting the
2856  * @p types field does not disable RSS in a flow rule. Doing so instead
2857  * requests safe unspecified "best-effort" settings from the underlying PMD,
2858  * which depending on the flow rule, may result in anything ranging from
2859  * empty (single queue) to all-inclusive RSS.
2860  *
2861  * Note: RSS hash result is stored in the hash.rss mbuf field which overlaps
2862  * hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only,
2863  * both can be requested simultaneously.
2864  */
2865 struct rte_flow_action_rss {
2866         enum rte_eth_hash_function func; /**< RSS hash function to apply. */
2867         /**
2868          * Packet encapsulation level RSS hash @p types apply to.
2869          *
2870          * - @p 0 requests the default behavior. Depending on the packet
2871          *   type, it can mean outermost, innermost, anything in between or
2872          *   even no RSS.
2873          *
2874          *   It basically stands for the innermost encapsulation level RSS
2875          *   can be performed on according to PMD and device capabilities.
2876          *
2877          * - @p 1 requests RSS to be performed on the outermost packet
2878          *   encapsulation level.
2879          *
2880          * - @p 2 and subsequent values request RSS to be performed on the
2881          *   specified inner packet encapsulation level, from outermost to
2882          *   innermost (lower to higher values).
2883          *
2884          * Values other than @p 0 are not necessarily supported.
2885          *
2886          * Requesting a specific RSS level on unrecognized traffic results
2887          * in undefined behavior. For predictable results, it is recommended
2888          * to make the flow rule pattern match packet headers up to the
2889          * requested encapsulation level so that only matching traffic goes
2890          * through.
2891          */
2892         uint32_t level;
2893         uint64_t types; /**< Specific RSS hash types (see ETH_RSS_*). */
2894         uint32_t key_len; /**< Hash key length in bytes. */
2895         uint32_t queue_num; /**< Number of entries in @p queue. */
2896         const uint8_t *key; /**< Hash key. */
2897         const uint16_t *queue; /**< Queue indices to use. */
2898 };
2899
2900 /**
2901  * @deprecated
2902  * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2903  * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2904  *
2905  * RTE_FLOW_ACTION_TYPE_VF
2906  *
2907  * Directs matching traffic to a given virtual function of the current
2908  * device.
2909  *
2910  * Packets matched by a VF pattern item can be redirected to their original
2911  * VF ID instead of the specified one. This parameter may not be available
2912  * and is not guaranteed to work properly if the VF part is matched by a
2913  * prior flow rule or if packets are not addressed to a VF in the first
2914  * place.
2915  */
2916 struct rte_flow_action_vf {
2917         uint32_t original:1; /**< Use original VF ID if possible. */
2918         uint32_t reserved:31; /**< Reserved, must be zero. */
2919         uint32_t id; /**< VF ID. */
2920 };
2921
2922 /**
2923  * @deprecated
2924  * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2925  * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2926  *
2927  * RTE_FLOW_ACTION_TYPE_PHY_PORT
2928  *
2929  * Directs packets to a given physical port index of the underlying
2930  * device.
2931  *
2932  * @see RTE_FLOW_ITEM_TYPE_PHY_PORT
2933  */
2934 struct rte_flow_action_phy_port {
2935         uint32_t original:1; /**< Use original port index if possible. */
2936         uint32_t reserved:31; /**< Reserved, must be zero. */
2937         uint32_t index; /**< Physical port index. */
2938 };
2939
2940 /**
2941  * @deprecated
2942  * @see RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR
2943  * @see RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT
2944  *
2945  * RTE_FLOW_ACTION_TYPE_PORT_ID
2946  *
2947  * Directs matching traffic to a given DPDK port ID.
2948  *
2949  * @see RTE_FLOW_ITEM_TYPE_PORT_ID
2950  */
2951 struct rte_flow_action_port_id {
2952         uint32_t original:1; /**< Use original DPDK port ID if possible. */
2953         uint32_t reserved:31; /**< Reserved, must be zero. */
2954         uint32_t id; /**< DPDK port ID. */
2955 };
2956
2957 /**
2958  * RTE_FLOW_ACTION_TYPE_METER
2959  *
2960  * Traffic metering and policing (MTR).
2961  *
2962  * Packets matched by items of this type can be either dropped or passed to the
2963  * next item with their color set by the MTR object.
2964  */
2965 struct rte_flow_action_meter {
2966         uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */
2967 };
2968
2969 /**
2970  * RTE_FLOW_ACTION_TYPE_SECURITY
2971  *
2972  * Perform the security action on flows matched by the pattern items
2973  * according to the configuration of the security session.
2974  *
2975  * This action modifies the payload of matched flows. For INLINE_CRYPTO, the
2976  * security protocol headers and IV are fully provided by the application as
2977  * specified in the flow pattern. The payload of matching packets is
2978  * encrypted on egress, and decrypted and authenticated on ingress.
2979  * For INLINE_PROTOCOL, the security protocol is fully offloaded to HW,
2980  * providing full encapsulation and decapsulation of packets in security
2981  * protocols. The flow pattern specifies both the outer security header fields
2982  * and the inner packet fields. The security session specified in the action
2983  * must match the pattern parameters.
2984  *
2985  * The security session specified in the action must be created on the same
2986  * port as the flow action that is being specified.
2987  *
2988  * The ingress/egress flow attribute should match that specified in the
2989  * security session if the security session supports the definition of the
2990  * direction.
2991  *
2992  * Multiple flows can be configured to use the same security session.
2993  *
2994  * The NULL value is allowed for security session. If security session is NULL,
2995  * then SPI field in ESP flow item and IP addresses in flow items 'IPv4' and
2996  * 'IPv6' will be allowed to be a range. The rule thus created can enable
2997  * security processing on multiple flows.
2998  */
2999 struct rte_flow_action_security {
3000         void *security_session; /**< Pointer to security session structure. */
3001 };
3002
3003 /**
3004  * RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL
3005  *
3006  * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the OpenFlow
3007  * Switch Specification.
3008  */
3009 struct rte_flow_action_of_set_mpls_ttl {
3010         uint8_t mpls_ttl; /**< MPLS TTL. */
3011 };
3012
3013 /**
3014  * RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL
3015  *
3016  * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow Switch
3017  * Specification.
3018  */
3019 struct rte_flow_action_of_set_nw_ttl {
3020         uint8_t nw_ttl; /**< IP TTL. */
3021 };
3022
3023 /**
3024  * RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN
3025  *
3026  * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by the
3027  * OpenFlow Switch Specification.
3028  */
3029 struct rte_flow_action_of_push_vlan {
3030         rte_be16_t ethertype; /**< EtherType. */
3031 };
3032
3033 /**
3034  * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID
3035  *
3036  * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN ID") as defined by
3037  * the OpenFlow Switch Specification.
3038  */
3039 struct rte_flow_action_of_set_vlan_vid {
3040         rte_be16_t vlan_vid; /**< VLAN ID. */
3041 };
3042
3043 /**
3044  * RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP
3045  *
3046  * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as defined by
3047  * the OpenFlow Switch Specification.
3048  */
3049 struct rte_flow_action_of_set_vlan_pcp {
3050         uint8_t vlan_pcp; /**< VLAN priority. */
3051 };
3052
3053 /**
3054  * RTE_FLOW_ACTION_TYPE_OF_POP_MPLS
3055  *
3056  * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined by the
3057  * OpenFlow Switch Specification.
3058  */
3059 struct rte_flow_action_of_pop_mpls {
3060         rte_be16_t ethertype; /**< EtherType. */
3061 };
3062
3063 /**
3064  * RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS
3065  *
3066  * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by the
3067  * OpenFlow Switch Specification.
3068  */
3069 struct rte_flow_action_of_push_mpls {
3070         rte_be16_t ethertype; /**< EtherType. */
3071 };
3072
3073 /**
3074  * @warning
3075  * @b EXPERIMENTAL: this structure may change without prior notice
3076  *
3077  * RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP
3078  *
3079  * VXLAN tunnel end-point encapsulation data definition
3080  *
3081  * The tunnel definition is provided through the flow item pattern, the
3082  * provided pattern must conform to RFC7348 for the tunnel specified. The flow
3083  * definition must be provided in order from the RTE_FLOW_ITEM_TYPE_ETH
3084  * definition up the end item which is specified by RTE_FLOW_ITEM_TYPE_END.
3085  *
3086  * The mask field allows user to specify which fields in the flow item
3087  * definitions can be ignored and which have valid data and can be used
3088  * verbatim.
3089  *
3090  * Note: the last field is not used in the definition of a tunnel and can be
3091  * ignored.
3092  *
3093  * Valid flow definition for RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP include:
3094  *
3095  * - ETH / IPV4 / UDP / VXLAN / END
3096  * - ETH / IPV6 / UDP / VXLAN / END
3097  * - ETH / VLAN / IPV4 / UDP / VXLAN / END
3098  *
3099  */
3100 struct rte_flow_action_vxlan_encap {
3101         /**
3102          * Encapsulating vxlan tunnel definition
3103          * (terminated by the END pattern item).
3104          */
3105         struct rte_flow_item *definition;
3106 };
3107
3108 /**
3109  * @warning
3110  * @b EXPERIMENTAL: this structure may change without prior notice
3111  *
3112  * RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP
3113  *
3114  * NVGRE tunnel end-point encapsulation data definition
3115  *
3116  * The tunnel definition is provided through the flow item pattern  the
3117  * provided pattern must conform with RFC7637. The flow definition must be
3118  * provided in order from the RTE_FLOW_ITEM_TYPE_ETH definition up the end item
3119  * which is specified by RTE_FLOW_ITEM_TYPE_END.
3120  *
3121  * The mask field allows user to specify which fields in the flow item
3122  * definitions can be ignored and which have valid data and can be used
3123  * verbatim.
3124  *
3125  * Note: the last field is not used in the definition of a tunnel and can be
3126  * ignored.
3127  *
3128  * Valid flow definition for RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP include:
3129  *
3130  * - ETH / IPV4 / NVGRE / END
3131  * - ETH / VLAN / IPV6 / NVGRE / END
3132  *
3133  */
3134 struct rte_flow_action_nvgre_encap {
3135         /**
3136          * Encapsulating vxlan tunnel definition
3137          * (terminated by the END pattern item).
3138          */
3139         struct rte_flow_item *definition;
3140 };
3141
3142 /**
3143  * @warning
3144  * @b EXPERIMENTAL: this structure may change without prior notice
3145  *
3146  * RTE_FLOW_ACTION_TYPE_RAW_ENCAP
3147  *
3148  * Raw tunnel end-point encapsulation data definition.
3149  *
3150  * The data holds the headers definitions to be applied on the packet.
3151  * The data must start with ETH header up to the tunnel item header itself.
3152  * When used right after RAW_DECAP (for decapsulating L3 tunnel type for
3153  * example MPLSoGRE) the data will just hold layer 2 header.
3154  *
3155  * The preserve parameter holds which bits in the packet the PMD is not allowed
3156  * to change, this parameter can also be NULL and then the PMD is allowed
3157  * to update any field.
3158  *
3159  * size holds the number of bytes in @p data and @p preserve.
3160  */
3161 struct rte_flow_action_raw_encap {
3162         uint8_t *data; /**< Encapsulation data. */
3163         uint8_t *preserve; /**< Bit-mask of @p data to preserve on output. */
3164         size_t size; /**< Size of @p data and @p preserve. */
3165 };
3166
3167 /**
3168  * @warning
3169  * @b EXPERIMENTAL: this structure may change without prior notice
3170  *
3171  * RTE_FLOW_ACTION_TYPE_RAW_DECAP
3172  *
3173  * Raw tunnel end-point decapsulation data definition.
3174  *
3175  * The data holds the headers definitions to be removed from the packet.
3176  * The data must start with ETH header up to the tunnel item header itself.
3177  * When used right before RAW_DECAP (for encapsulating L3 tunnel type for
3178  * example MPLSoGRE) the data will just hold layer 2 header.
3179  *
3180  * size holds the number of bytes in @p data.
3181  */
3182 struct rte_flow_action_raw_decap {
3183         uint8_t *data; /**< Encapsulation data. */
3184         size_t size; /**< Size of @p data and @p preserve. */
3185 };
3186
3187 /**
3188  * @warning
3189  * @b EXPERIMENTAL: this structure may change without prior notice
3190  *
3191  * RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC
3192  * RTE_FLOW_ACTION_TYPE_SET_IPV4_DST
3193  *
3194  * Allows modification of IPv4 source (RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC)
3195  * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV4_DST) in the
3196  * specified outermost IPv4 header.
3197  */
3198 struct rte_flow_action_set_ipv4 {
3199         rte_be32_t ipv4_addr;
3200 };
3201
3202 /**
3203  * @warning
3204  * @b EXPERIMENTAL: this structure may change without prior notice
3205  *
3206  * RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC
3207  * RTE_FLOW_ACTION_TYPE_SET_IPV6_DST
3208  *
3209  * Allows modification of IPv6 source (RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC)
3210  * and destination address (RTE_FLOW_ACTION_TYPE_SET_IPV6_DST) in the
3211  * specified outermost IPv6 header.
3212  */
3213 struct rte_flow_action_set_ipv6 {
3214         uint8_t ipv6_addr[16];
3215 };
3216
3217 /**
3218  * @warning
3219  * @b EXPERIMENTAL: this structure may change without prior notice
3220  *
3221  * RTE_FLOW_ACTION_TYPE_SET_TP_SRC
3222  * RTE_FLOW_ACTION_TYPE_SET_TP_DST
3223  *
3224  * Allows modification of source (RTE_FLOW_ACTION_TYPE_SET_TP_SRC)
3225  * and destination (RTE_FLOW_ACTION_TYPE_SET_TP_DST) port numbers
3226  * in the specified outermost TCP/UDP header.
3227  */
3228 struct rte_flow_action_set_tp {
3229         rte_be16_t port;
3230 };
3231
3232 /**
3233  * RTE_FLOW_ACTION_TYPE_SET_TTL
3234  *
3235  * Set the TTL value directly for IPv4 or IPv6
3236  */
3237 struct rte_flow_action_set_ttl {
3238         uint8_t ttl_value;
3239 };
3240
3241 /**
3242  * RTE_FLOW_ACTION_TYPE_SET_MAC
3243  *
3244  * Set MAC address from the matched flow
3245  */
3246 struct rte_flow_action_set_mac {
3247         uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
3248 };
3249
3250 /**
3251  * @warning
3252  * @b EXPERIMENTAL: this structure may change without prior notice
3253  *
3254  * RTE_FLOW_ACTION_TYPE_SET_TAG
3255  *
3256  * Set a tag which is a transient data used during flow matching. This is not
3257  * delivered to application. Multiple tags are supported by specifying index.
3258  */
3259 struct rte_flow_action_set_tag {
3260         uint32_t data;
3261         uint32_t mask;
3262         uint8_t index;
3263 };
3264
3265 /**
3266  * @warning
3267  * @b EXPERIMENTAL: this structure may change without prior notice
3268  *
3269  * RTE_FLOW_ACTION_TYPE_SET_META
3270  *
3271  * Set metadata. Metadata set by mbuf metadata dynamic field with
3272  * PKT_TX_DYNF_DATA flag on egress will be overridden by this action. On
3273  * ingress, the metadata will be carried by mbuf metadata dynamic field
3274  * with PKT_RX_DYNF_METADATA flag if set.  The dynamic mbuf field must be
3275  * registered in advance by rte_flow_dynf_metadata_register().
3276  *
3277  * Altering partial bits is supported with mask. For bits which have never
3278  * been set, unpredictable value will be seen depending on driver
3279  * implementation. For loopback/hairpin packet, metadata set on Rx/Tx may
3280  * or may not be propagated to the other path depending on HW capability.
3281  *
3282  * RTE_FLOW_ITEM_TYPE_META matches metadata.
3283  */
3284 struct rte_flow_action_set_meta {
3285         uint32_t data;
3286         uint32_t mask;
3287 };
3288
3289 /**
3290  * RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP
3291  * RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP
3292  *
3293  * Set the DSCP value for IPv4/IPv6 header.
3294  * DSCP in low 6 bits, rest ignored.
3295  */
3296 struct rte_flow_action_set_dscp {
3297         uint8_t dscp;
3298 };
3299
3300 /**
3301  * @warning
3302  * @b EXPERIMENTAL: this structure may change without prior notice
3303  *
3304  * RTE_FLOW_ACTION_TYPE_INDIRECT
3305  *
3306  * Opaque type returned after successfully creating an indirect action object.
3307  * The definition of the object handle is different per driver or
3308  * per direct action type.
3309  *
3310  * This handle can be used to manage and query the related direct action:
3311  * - referenced in single flow rule or across multiple flow rules
3312  *   over multiple ports
3313  * - update action object configuration
3314  * - query action object data
3315  * - destroy action object
3316  */
3317 struct rte_flow_action_handle;
3318
3319 /**
3320  * The state of a TCP connection.
3321  */
3322 enum rte_flow_conntrack_state {
3323         /** SYN-ACK packet was seen. */
3324         RTE_FLOW_CONNTRACK_STATE_SYN_RECV,
3325         /** 3-way handshake was done. */
3326         RTE_FLOW_CONNTRACK_STATE_ESTABLISHED,
3327         /** First FIN packet was received to close the connection. */
3328         RTE_FLOW_CONNTRACK_STATE_FIN_WAIT,
3329         /** First FIN was ACKed. */
3330         RTE_FLOW_CONNTRACK_STATE_CLOSE_WAIT,
3331         /** Second FIN was received, waiting for the last ACK. */
3332         RTE_FLOW_CONNTRACK_STATE_LAST_ACK,
3333         /** Second FIN was ACKed, connection was closed. */
3334         RTE_FLOW_CONNTRACK_STATE_TIME_WAIT,
3335 };
3336
3337 /**
3338  * The last passed TCP packet flags of a connection.
3339  */
3340 enum rte_flow_conntrack_tcp_last_index {
3341         RTE_FLOW_CONNTRACK_FLAG_NONE = 0, /**< No Flag. */
3342         RTE_FLOW_CONNTRACK_FLAG_SYN = RTE_BIT32(0), /**< With SYN flag. */
3343         RTE_FLOW_CONNTRACK_FLAG_SYNACK = RTE_BIT32(1), /**< With SYNACK flag. */
3344         RTE_FLOW_CONNTRACK_FLAG_FIN = RTE_BIT32(2), /**< With FIN flag. */
3345         RTE_FLOW_CONNTRACK_FLAG_ACK = RTE_BIT32(3), /**< With ACK flag. */
3346         RTE_FLOW_CONNTRACK_FLAG_RST = RTE_BIT32(4), /**< With RST flag. */
3347 };
3348
3349 /**
3350  * @warning
3351  * @b EXPERIMENTAL: this structure may change without prior notice
3352  *
3353  * Configuration parameters for each direction of a TCP connection.
3354  * All fields should be in host byte order.
3355  * If needed, driver should convert all fields to network byte order
3356  * if HW needs them in that way.
3357  */
3358 struct rte_flow_tcp_dir_param {
3359         /** TCP window scaling factor, 0xF to disable. */
3360         uint32_t scale:4;
3361         /** The FIN was sent by this direction. */
3362         uint32_t close_initiated:1;
3363         /** An ACK packet has been received by this side. */
3364         uint32_t last_ack_seen:1;
3365         /**
3366          * If set, it indicates that there is unacknowledged data for the
3367          * packets sent from this direction.
3368          */
3369         uint32_t data_unacked:1;
3370         /**
3371          * Maximal value of sequence + payload length in sent
3372          * packets (next ACK from the opposite direction).
3373          */
3374         uint32_t sent_end;
3375         /**
3376          * Maximal value of (ACK + window size) in received packet + length
3377          * over sent packet (maximal sequence could be sent).
3378          */
3379         uint32_t reply_end;
3380         /** Maximal value of actual window size in sent packets. */
3381         uint32_t max_win;
3382         /** Maximal value of ACK in sent packets. */
3383         uint32_t max_ack;
3384 };
3385
3386 /**
3387  * @warning
3388  * @b EXPERIMENTAL: this structure may change without prior notice
3389  *
3390  * RTE_FLOW_ACTION_TYPE_CONNTRACK
3391  *
3392  * Configuration and initial state for the connection tracking module.
3393  * This structure could be used for both setting and query.
3394  * All fields should be in host byte order.
3395  */
3396 struct rte_flow_action_conntrack {
3397         /** The peer port number, can be the same port. */
3398         uint16_t peer_port;
3399         /**
3400          * Direction of this connection when creating a flow rule, the
3401          * value only affects the creation of subsequent flow rules.
3402          */
3403         uint32_t is_original_dir:1;
3404         /**
3405          * Enable / disable the conntrack HW module. When disabled, the
3406          * result will always be RTE_FLOW_CONNTRACK_FLAG_DISABLED.
3407          * In this state the HW will act as passthrough.
3408          * It only affects this conntrack object in the HW without any effect
3409          * to the other objects.
3410          */
3411         uint32_t enable:1;
3412         /** At least one ack was seen after the connection was established. */
3413         uint32_t live_connection:1;
3414         /** Enable selective ACK on this connection. */
3415         uint32_t selective_ack:1;
3416         /** A challenge ack has passed. */
3417         uint32_t challenge_ack_passed:1;
3418         /**
3419          * 1: The last packet is seen from the original direction.
3420          * 0: The last packet is seen from the reply direction.
3421          */
3422         uint32_t last_direction:1;
3423         /** No TCP check will be done except the state change. */
3424         uint32_t liberal_mode:1;
3425         /** The current state of this connection. */
3426         enum rte_flow_conntrack_state state;
3427         /** Scaling factor for maximal allowed ACK window. */
3428         uint8_t max_ack_window;
3429         /** Maximal allowed number of retransmission times. */
3430         uint8_t retransmission_limit;
3431         /** TCP parameters of the original direction. */
3432         struct rte_flow_tcp_dir_param original_dir;
3433         /** TCP parameters of the reply direction. */
3434         struct rte_flow_tcp_dir_param reply_dir;
3435         /** The window value of the last packet passed this conntrack. */
3436         uint16_t last_window;
3437         enum rte_flow_conntrack_tcp_last_index last_index;
3438         /** The sequence of the last packet passed this conntrack. */
3439         uint32_t last_seq;
3440         /** The acknowledgment of the last packet passed this conntrack. */
3441         uint32_t last_ack;
3442         /**
3443          * The total value ACK + payload length of the last packet
3444          * passed this conntrack.
3445          */
3446         uint32_t last_end;
3447 };
3448
3449 /**
3450  * RTE_FLOW_ACTION_TYPE_CONNTRACK
3451  *
3452  * Wrapper structure for the context update interface.
3453  * Ports cannot support updating, and the only valid solution is to
3454  * destroy the old context and create a new one instead.
3455  */
3456 struct rte_flow_modify_conntrack {
3457         /** New connection tracking parameters to be updated. */
3458         struct rte_flow_action_conntrack new_ct;
3459         /** The direction field will be updated. */
3460         uint32_t direction:1;
3461         /** All the other fields except direction will be updated. */
3462         uint32_t state:1;
3463         /** Reserved bits for the future usage. */
3464         uint32_t reserved:30;
3465 };
3466
3467 /**
3468  * @warning
3469  * @b EXPERIMENTAL: this structure may change without prior notice
3470  *
3471  * RTE_FLOW_ACTION_TYPE_METER_COLOR
3472  *
3473  * The meter color should be set in the packet meta-data
3474  * (i.e. struct rte_mbuf::sched::color).
3475  */
3476 struct rte_flow_action_meter_color {
3477         enum rte_color color; /**< Packet color. */
3478 };
3479
3480 /**
3481  * @warning
3482  * @b EXPERIMENTAL: this structure may change without prior notice
3483  *
3484  * Provides an ethdev port ID for use with the following actions:
3485  * RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR,
3486  * RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT.
3487  */
3488 struct rte_flow_action_ethdev {
3489         uint16_t port_id; /**< ethdev port ID */
3490 };
3491
3492 /**
3493  * Field IDs for MODIFY_FIELD action.
3494  */
3495 enum rte_flow_field_id {
3496         RTE_FLOW_FIELD_START = 0,       /**< Start of a packet. */
3497         RTE_FLOW_FIELD_MAC_DST,         /**< Destination MAC Address. */
3498         RTE_FLOW_FIELD_MAC_SRC,         /**< Source MAC Address. */
3499         RTE_FLOW_FIELD_VLAN_TYPE,       /**< 802.1Q Tag Identifier. */
3500         RTE_FLOW_FIELD_VLAN_ID,         /**< 802.1Q VLAN Identifier. */
3501         RTE_FLOW_FIELD_MAC_TYPE,        /**< EtherType. */
3502         RTE_FLOW_FIELD_IPV4_DSCP,       /**< IPv4 DSCP. */
3503         RTE_FLOW_FIELD_IPV4_TTL,        /**< IPv4 Time To Live. */
3504         RTE_FLOW_FIELD_IPV4_SRC,        /**< IPv4 Source Address. */
3505         RTE_FLOW_FIELD_IPV4_DST,        /**< IPv4 Destination Address. */
3506         RTE_FLOW_FIELD_IPV6_DSCP,       /**< IPv6 DSCP. */
3507         RTE_FLOW_FIELD_IPV6_HOPLIMIT,   /**< IPv6 Hop Limit. */
3508         RTE_FLOW_FIELD_IPV6_SRC,        /**< IPv6 Source Address. */
3509         RTE_FLOW_FIELD_IPV6_DST,        /**< IPv6 Destination Address. */
3510         RTE_FLOW_FIELD_TCP_PORT_SRC,    /**< TCP Source Port Number. */
3511         RTE_FLOW_FIELD_TCP_PORT_DST,    /**< TCP Destination Port Number. */
3512         RTE_FLOW_FIELD_TCP_SEQ_NUM,     /**< TCP Sequence Number. */
3513         RTE_FLOW_FIELD_TCP_ACK_NUM,     /**< TCP Acknowledgment Number. */
3514         RTE_FLOW_FIELD_TCP_FLAGS,       /**< TCP Flags. */
3515         RTE_FLOW_FIELD_UDP_PORT_SRC,    /**< UDP Source Port Number. */
3516         RTE_FLOW_FIELD_UDP_PORT_DST,    /**< UDP Destination Port Number. */
3517         RTE_FLOW_FIELD_VXLAN_VNI,       /**< VXLAN Network Identifier. */
3518         RTE_FLOW_FIELD_GENEVE_VNI,      /**< GENEVE Network Identifier. */
3519         RTE_FLOW_FIELD_GTP_TEID,        /**< GTP Tunnel Endpoint Identifier. */
3520         RTE_FLOW_FIELD_TAG,             /**< Tag value. */
3521         RTE_FLOW_FIELD_MARK,            /**< Mark value. */
3522         RTE_FLOW_FIELD_META,            /**< Metadata value. */
3523         RTE_FLOW_FIELD_POINTER,         /**< Memory pointer. */
3524         RTE_FLOW_FIELD_VALUE,           /**< Immediate value. */
3525 };
3526
3527 /**
3528  * @warning
3529  * @b EXPERIMENTAL: this structure may change without prior notice
3530  *
3531  * Field description for MODIFY_FIELD action.
3532  */
3533 struct rte_flow_action_modify_data {
3534         enum rte_flow_field_id field; /**< Field or memory type ID. */
3535         RTE_STD_C11
3536         union {
3537                 struct {
3538                         /** Encapsulation level or tag index. */
3539                         uint32_t level;
3540                         /** Number of bits to skip from a field. */
3541                         uint32_t offset;
3542                 };
3543                 /**
3544                  * Immediate value for RTE_FLOW_FIELD_VALUE, presented in the
3545                  * same byte order and length as in relevant rte_flow_item_xxx.
3546                  * The immediate source bitfield offset is inherited from
3547                  * the destination's one.
3548                  */
3549                 uint8_t value[16];
3550                 /**
3551                  * Memory address for RTE_FLOW_FIELD_POINTER, memory layout
3552                  * should be the same as for relevant field in the
3553                  * rte_flow_item_xxx structure.
3554                  */
3555                 void *pvalue;
3556         };
3557 };
3558
3559 /**
3560  * Operation types for MODIFY_FIELD action.
3561  */
3562 enum rte_flow_modify_op {
3563         RTE_FLOW_MODIFY_SET = 0, /**< Set a new value. */
3564         RTE_FLOW_MODIFY_ADD,     /**< Add a value to a field.  */
3565         RTE_FLOW_MODIFY_SUB,     /**< Subtract a value from a field. */
3566 };
3567
3568 /**
3569  * @warning
3570  * @b EXPERIMENTAL: this structure may change without prior notice
3571  *
3572  * RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
3573  *
3574  * Modify a destination header field according to the specified
3575  * operation. Another field of the packet can be used as a source as well
3576  * as tag, mark, metadata, immediate value or a pointer to it.
3577  */
3578 struct rte_flow_action_modify_field {
3579         enum rte_flow_modify_op operation; /**< Operation to perform. */
3580         struct rte_flow_action_modify_data dst; /**< Destination field. */
3581         struct rte_flow_action_modify_data src; /**< Source field. */
3582         uint32_t width; /**< Number of bits to use from a source field. */
3583 };
3584
3585 /* Mbuf dynamic field offset for metadata. */
3586 extern int32_t rte_flow_dynf_metadata_offs;
3587
3588 /* Mbuf dynamic field flag mask for metadata. */
3589 extern uint64_t rte_flow_dynf_metadata_mask;
3590
3591 /* Mbuf dynamic field pointer for metadata. */
3592 #define RTE_FLOW_DYNF_METADATA(m) \
3593         RTE_MBUF_DYNFIELD((m), rte_flow_dynf_metadata_offs, uint32_t *)
3594
3595 /* Mbuf dynamic flags for metadata. */
3596 #define PKT_RX_DYNF_METADATA (rte_flow_dynf_metadata_mask)
3597 #define PKT_TX_DYNF_METADATA (rte_flow_dynf_metadata_mask)
3598
3599 __rte_experimental
3600 static inline uint32_t
3601 rte_flow_dynf_metadata_get(struct rte_mbuf *m)
3602 {
3603         return *RTE_FLOW_DYNF_METADATA(m);
3604 }
3605
3606 __rte_experimental
3607 static inline void
3608 rte_flow_dynf_metadata_set(struct rte_mbuf *m, uint32_t v)
3609 {
3610         *RTE_FLOW_DYNF_METADATA(m) = v;
3611 }
3612
3613 /**
3614  * Definition of a single action.
3615  *
3616  * A list of actions is terminated by a END action.
3617  *
3618  * For simple actions without a configuration object, conf remains NULL.
3619  */
3620 struct rte_flow_action {
3621         enum rte_flow_action_type type; /**< Action type. */
3622         const void *conf; /**< Pointer to action configuration object. */
3623 };
3624
3625 /**
3626  * Opaque type returned after successfully creating a flow.
3627  *
3628  * This handle can be used to manage and query the related flow (e.g. to
3629  * destroy it or retrieve counters).
3630  */
3631 struct rte_flow;
3632
3633 /**
3634  * @warning
3635  * @b EXPERIMENTAL: this structure may change without prior notice
3636  *
3637  * RTE_FLOW_ACTION_TYPE_SAMPLE
3638  *
3639  * Adds a sample action to a matched flow.
3640  *
3641  * The matching packets will be duplicated with specified ratio and applied
3642  * with own set of actions with a fate action, the sampled packet could be
3643  * redirected to queue or port. All the packets continue processing on the
3644  * default flow path.
3645  *
3646  * When the sample ratio is set to 1 then the packets will be 100% mirrored.
3647  * Additional action list be supported to add for sampled or mirrored packets.
3648  */
3649 struct rte_flow_action_sample {
3650         uint32_t ratio; /**< packets sampled equals to '1/ratio'. */
3651         /** sub-action list specific for the sampling hit cases. */
3652         const struct rte_flow_action *actions;
3653 };
3654
3655 /**
3656  * Verbose error types.
3657  *
3658  * Most of them provide the type of the object referenced by struct
3659  * rte_flow_error.cause.
3660  */
3661 enum rte_flow_error_type {
3662         RTE_FLOW_ERROR_TYPE_NONE, /**< No error. */
3663         RTE_FLOW_ERROR_TYPE_UNSPECIFIED, /**< Cause unspecified. */
3664         RTE_FLOW_ERROR_TYPE_HANDLE, /**< Flow rule (handle). */
3665         RTE_FLOW_ERROR_TYPE_ATTR_GROUP, /**< Group field. */
3666         RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, /**< Priority field. */
3667         RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, /**< Ingress field. */
3668         RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, /**< Egress field. */
3669         RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, /**< Transfer field. */
3670         RTE_FLOW_ERROR_TYPE_ATTR, /**< Attributes structure. */
3671         RTE_FLOW_ERROR_TYPE_ITEM_NUM, /**< Pattern length. */
3672         RTE_FLOW_ERROR_TYPE_ITEM_SPEC, /**< Item specification. */
3673         RTE_FLOW_ERROR_TYPE_ITEM_LAST, /**< Item specification range. */
3674         RTE_FLOW_ERROR_TYPE_ITEM_MASK, /**< Item specification mask. */
3675         RTE_FLOW_ERROR_TYPE_ITEM, /**< Specific pattern item. */
3676         RTE_FLOW_ERROR_TYPE_ACTION_NUM, /**< Number of actions. */
3677         RTE_FLOW_ERROR_TYPE_ACTION_CONF, /**< Action configuration. */
3678         RTE_FLOW_ERROR_TYPE_ACTION, /**< Specific action. */
3679 };
3680
3681 /**
3682  * Verbose error structure definition.
3683  *
3684  * This object is normally allocated by applications and set by PMDs, the
3685  * message points to a constant string which does not need to be freed by
3686  * the application, however its pointer can be considered valid only as long
3687  * as its associated DPDK port remains configured. Closing the underlying
3688  * device or unloading the PMD invalidates it.
3689  *
3690  * Both cause and message may be NULL regardless of the error type.
3691  */
3692 struct rte_flow_error {
3693         enum rte_flow_error_type type; /**< Cause field and error types. */
3694         const void *cause; /**< Object responsible for the error. */
3695         const char *message; /**< Human-readable error message. */
3696 };
3697
3698 /**
3699  * Complete flow rule description.
3700  *
3701  * This object type is used when converting a flow rule description.
3702  *
3703  * @see RTE_FLOW_CONV_OP_RULE
3704  * @see rte_flow_conv()
3705  */
3706 RTE_STD_C11
3707 struct rte_flow_conv_rule {
3708         union {
3709                 const struct rte_flow_attr *attr_ro; /**< RO attributes. */
3710                 struct rte_flow_attr *attr; /**< Attributes. */
3711         };
3712         union {
3713                 const struct rte_flow_item *pattern_ro; /**< RO pattern. */
3714                 struct rte_flow_item *pattern; /**< Pattern items. */
3715         };
3716         union {
3717                 const struct rte_flow_action *actions_ro; /**< RO actions. */
3718                 struct rte_flow_action *actions; /**< List of actions. */
3719         };
3720 };
3721
3722 /**
3723  * Conversion operations for flow API objects.
3724  *
3725  * @see rte_flow_conv()
3726  */
3727 enum rte_flow_conv_op {
3728         /**
3729          * No operation to perform.
3730          *
3731          * rte_flow_conv() simply returns 0.
3732          */
3733         RTE_FLOW_CONV_OP_NONE,
3734
3735         /**
3736          * Convert attributes structure.
3737          *
3738          * This is a basic copy of an attributes structure.
3739          *
3740          * - @p src type:
3741          *   @code const struct rte_flow_attr * @endcode
3742          * - @p dst type:
3743          *   @code struct rte_flow_attr * @endcode
3744          */
3745         RTE_FLOW_CONV_OP_ATTR,
3746
3747         /**
3748          * Convert a single item.
3749          *
3750          * Duplicates @p spec, @p last and @p mask but not outside objects.
3751          *
3752          * - @p src type:
3753          *   @code const struct rte_flow_item * @endcode
3754          * - @p dst type:
3755          *   @code struct rte_flow_item * @endcode
3756          */
3757         RTE_FLOW_CONV_OP_ITEM,
3758
3759         /**
3760          * Convert a single action.
3761          *
3762          * Duplicates @p conf but not outside objects.
3763          *
3764          * - @p src type:
3765          *   @code const struct rte_flow_action * @endcode
3766          * - @p dst type:
3767          *   @code struct rte_flow_action * @endcode
3768          */
3769         RTE_FLOW_CONV_OP_ACTION,
3770
3771         /**
3772          * Convert an entire pattern.
3773          *
3774          * Duplicates all pattern items at once with the same constraints as
3775          * RTE_FLOW_CONV_OP_ITEM.
3776          *
3777          * - @p src type:
3778          *   @code const struct rte_flow_item * @endcode
3779          * - @p dst type:
3780          *   @code struct rte_flow_item * @endcode
3781          */
3782         RTE_FLOW_CONV_OP_PATTERN,
3783
3784         /**
3785          * Convert a list of actions.
3786          *
3787          * Duplicates the entire list of actions at once with the same
3788          * constraints as RTE_FLOW_CONV_OP_ACTION.
3789          *
3790          * - @p src type:
3791          *   @code const struct rte_flow_action * @endcode
3792          * - @p dst type:
3793          *   @code struct rte_flow_action * @endcode
3794          */
3795         RTE_FLOW_CONV_OP_ACTIONS,
3796
3797         /**
3798          * Convert a complete flow rule description.
3799          *
3800          * Comprises attributes, pattern and actions together at once with
3801          * the usual constraints.
3802          *
3803          * - @p src type:
3804          *   @code const struct rte_flow_conv_rule * @endcode
3805          * - @p dst type:
3806          *   @code struct rte_flow_conv_rule * @endcode
3807          */
3808         RTE_FLOW_CONV_OP_RULE,
3809
3810         /**
3811          * Convert item type to its name string.
3812          *
3813          * Writes a NUL-terminated string to @p dst. Like snprintf(), the
3814          * returned value excludes the terminator which is always written
3815          * nonetheless.
3816          *
3817          * - @p src type:
3818          *   @code (const void *)enum rte_flow_item_type @endcode
3819          * - @p dst type:
3820          *   @code char * @endcode
3821          **/
3822         RTE_FLOW_CONV_OP_ITEM_NAME,
3823
3824         /**
3825          * Convert action type to its name string.
3826          *
3827          * Writes a NUL-terminated string to @p dst. Like snprintf(), the
3828          * returned value excludes the terminator which is always written
3829          * nonetheless.
3830          *
3831          * - @p src type:
3832          *   @code (const void *)enum rte_flow_action_type @endcode
3833          * - @p dst type:
3834          *   @code char * @endcode
3835          **/
3836         RTE_FLOW_CONV_OP_ACTION_NAME,
3837
3838         /**
3839          * Convert item type to pointer to item name.
3840          *
3841          * Retrieves item name pointer from its type. The string itself is
3842          * not copied; instead, a unique pointer to an internal static
3843          * constant storage is written to @p dst.
3844          *
3845          * - @p src type:
3846          *   @code (const void *)enum rte_flow_item_type @endcode
3847          * - @p dst type:
3848          *   @code const char ** @endcode
3849          */
3850         RTE_FLOW_CONV_OP_ITEM_NAME_PTR,
3851
3852         /**
3853          * Convert action type to pointer to action name.
3854          *
3855          * Retrieves action name pointer from its type. The string itself is
3856          * not copied; instead, a unique pointer to an internal static
3857          * constant storage is written to @p dst.
3858          *
3859          * - @p src type:
3860          *   @code (const void *)enum rte_flow_action_type @endcode
3861          * - @p dst type:
3862          *   @code const char ** @endcode
3863          */
3864         RTE_FLOW_CONV_OP_ACTION_NAME_PTR,
3865 };
3866
3867 /**
3868  * @warning
3869  * @b EXPERIMENTAL: this API may change without prior notice.
3870  *
3871  * Dump hardware internal representation information of
3872  * rte flow to file.
3873  *
3874  * @param[in] port_id
3875  *    The port identifier of the Ethernet device.
3876  * @param[in] flow
3877  *   The pointer of flow rule to dump. Dump all rules if NULL.
3878  * @param[in] file
3879  *   A pointer to a file for output.
3880  * @param[out] error
3881  *   Perform verbose error reporting if not NULL. PMDs initialize this
3882  *   structure in case of error only.
3883  * @return
3884  *   0 on success, a nagative value otherwise.
3885  */
3886 __rte_experimental
3887 int
3888 rte_flow_dev_dump(uint16_t port_id, struct rte_flow *flow,
3889                 FILE *file, struct rte_flow_error *error);
3890
3891 /**
3892  * Check if mbuf dynamic field for metadata is registered.
3893  *
3894  * @return
3895  *   True if registered, false otherwise.
3896  */
3897 __rte_experimental
3898 static inline int
3899 rte_flow_dynf_metadata_avail(void)
3900 {
3901         return !!rte_flow_dynf_metadata_mask;
3902 }
3903
3904 /**
3905  * Register mbuf dynamic field and flag for metadata.
3906  *
3907  * This function must be called prior to use SET_META action in order to
3908  * register the dynamic mbuf field. Otherwise, the data cannot be delivered to
3909  * application.
3910  *
3911  * @return
3912  *   0 on success, a negative errno value otherwise and rte_errno is set.
3913  */
3914 __rte_experimental
3915 int
3916 rte_flow_dynf_metadata_register(void);
3917
3918 /**
3919  * Check whether a flow rule can be created on a given port.
3920  *
3921  * The flow rule is validated for correctness and whether it could be accepted
3922  * by the device given sufficient resources. The rule is checked against the
3923  * current device mode and queue configuration. The flow rule may also
3924  * optionally be validated against existing flow rules and device resources.
3925  * This function has no effect on the target device.
3926  *
3927  * The returned value is guaranteed to remain valid only as long as no
3928  * successful calls to rte_flow_create() or rte_flow_destroy() are made in
3929  * the meantime and no device parameter affecting flow rules in any way are
3930  * modified, due to possible collisions or resource limitations (although in
3931  * such cases EINVAL should not be returned).
3932  *
3933  * @param port_id
3934  *   Port identifier of Ethernet device.
3935  * @param[in] attr
3936  *   Flow rule attributes.
3937  * @param[in] pattern
3938  *   Pattern specification (list terminated by the END pattern item).
3939  * @param[in] actions
3940  *   Associated actions (list terminated by the END action).
3941  * @param[out] error
3942  *   Perform verbose error reporting if not NULL. PMDs initialize this
3943  *   structure in case of error only.
3944  *
3945  * @return
3946  *   0 if flow rule is valid and can be created. A negative errno value
3947  *   otherwise (rte_errno is also set), the following errors are defined:
3948  *
3949  *   -ENOSYS: underlying device does not support this functionality.
3950  *
3951  *   -EIO: underlying device is removed.
3952  *
3953  *   -EINVAL: unknown or invalid rule specification.
3954  *
3955  *   -ENOTSUP: valid but unsupported rule specification (e.g. partial
3956  *   bit-masks are unsupported).
3957  *
3958  *   -EEXIST: collision with an existing rule. Only returned if device
3959  *   supports flow rule collision checking and there was a flow rule
3960  *   collision. Not receiving this return code is no guarantee that creating
3961  *   the rule will not fail due to a collision.
3962  *
3963  *   -ENOMEM: not enough memory to execute the function, or if the device
3964  *   supports resource validation, resource limitation on the device.
3965  *
3966  *   -EBUSY: action cannot be performed due to busy device resources, may
3967  *   succeed if the affected queues or even the entire port are in a stopped
3968  *   state (see rte_eth_dev_rx_queue_stop() and rte_eth_dev_stop()).
3969  */
3970 int
3971 rte_flow_validate(uint16_t port_id,
3972                   const struct rte_flow_attr *attr,
3973                   const struct rte_flow_item pattern[],
3974                   const struct rte_flow_action actions[],
3975                   struct rte_flow_error *error);
3976
3977 /**
3978  * Create a flow rule on a given port.
3979  *
3980  * @param port_id
3981  *   Port identifier of Ethernet device.
3982  * @param[in] attr
3983  *   Flow rule attributes.
3984  * @param[in] pattern
3985  *   Pattern specification (list terminated by the END pattern item).
3986  * @param[in] actions
3987  *   Associated actions (list terminated by the END action).
3988  * @param[out] error
3989  *   Perform verbose error reporting if not NULL. PMDs initialize this
3990  *   structure in case of error only.
3991  *
3992  * @return
3993  *   A valid handle in case of success, NULL otherwise and rte_errno is set
3994  *   to the positive version of one of the error codes defined for
3995  *   rte_flow_validate().
3996  */
3997 struct rte_flow *
3998 rte_flow_create(uint16_t port_id,
3999                 const struct rte_flow_attr *attr,
4000                 const struct rte_flow_item pattern[],
4001                 const struct rte_flow_action actions[],
4002                 struct rte_flow_error *error);
4003
4004 /**
4005  * Destroy a flow rule on a given port.
4006  *
4007  * Failure to destroy a flow rule handle may occur when other flow rules
4008  * depend on it, and destroying it would result in an inconsistent state.
4009  *
4010  * This function is only guaranteed to succeed if handles are destroyed in
4011  * reverse order of their creation.
4012  *
4013  * @param port_id
4014  *   Port identifier of Ethernet device.
4015  * @param flow
4016  *   Flow rule handle to destroy.
4017  * @param[out] error
4018  *   Perform verbose error reporting if not NULL. PMDs initialize this
4019  *   structure in case of error only.
4020  *
4021  * @return
4022  *   0 on success, a negative errno value otherwise and rte_errno is set.
4023  */
4024 int
4025 rte_flow_destroy(uint16_t port_id,
4026                  struct rte_flow *flow,
4027                  struct rte_flow_error *error);
4028
4029 /**
4030  * Destroy all flow rules associated with a port.
4031  *
4032  * In the unlikely event of failure, handles are still considered destroyed
4033  * and no longer valid but the port must be assumed to be in an inconsistent
4034  * state.
4035  *
4036  * @param port_id
4037  *   Port identifier of Ethernet device.
4038  * @param[out] error
4039  *   Perform verbose error reporting if not NULL. PMDs initialize this
4040  *   structure in case of error only.
4041  *
4042  * @return
4043  *   0 on success, a negative errno value otherwise and rte_errno is set.
4044  */
4045 int
4046 rte_flow_flush(uint16_t port_id,
4047                struct rte_flow_error *error);
4048
4049 /**
4050  * Query an existing flow rule.
4051  *
4052  * This function allows retrieving flow-specific data such as counters.
4053  * Data is gathered by special actions which must be present in the flow
4054  * rule definition.
4055  *
4056  * \see RTE_FLOW_ACTION_TYPE_COUNT
4057  *
4058  * @param port_id
4059  *   Port identifier of Ethernet device.
4060  * @param flow
4061  *   Flow rule handle to query.
4062  * @param action
4063  *   Action definition as defined in original flow rule.
4064  * @param[in, out] data
4065  *   Pointer to storage for the associated query data type.
4066  * @param[out] error
4067  *   Perform verbose error reporting if not NULL. PMDs initialize this
4068  *   structure in case of error only.
4069  *
4070  * @return
4071  *   0 on success, a negative errno value otherwise and rte_errno is set.
4072  */
4073 int
4074 rte_flow_query(uint16_t port_id,
4075                struct rte_flow *flow,
4076                const struct rte_flow_action *action,
4077                void *data,
4078                struct rte_flow_error *error);
4079
4080 /**
4081  * Restrict ingress traffic to the defined flow rules.
4082  *
4083  * Isolated mode guarantees that all ingress traffic comes from defined flow
4084  * rules only (current and future).
4085  *
4086  * Besides making ingress more deterministic, it allows PMDs to safely reuse
4087  * resources otherwise assigned to handle the remaining traffic, such as
4088  * global RSS configuration settings, VLAN filters, MAC address entries,
4089  * legacy filter API rules and so on in order to expand the set of possible
4090  * flow rule types.
4091  *
4092  * Calling this function as soon as possible after device initialization,
4093  * ideally before the first call to rte_eth_dev_configure(), is recommended
4094  * to avoid possible failures due to conflicting settings.
4095  *
4096  * Once effective, leaving isolated mode may not be possible depending on
4097  * PMD implementation.
4098  *
4099  * Additionally, the following functionality has no effect on the underlying
4100  * port and may return errors such as ENOTSUP ("not supported"):
4101  *
4102  * - Toggling promiscuous mode.
4103  * - Toggling allmulticast mode.
4104  * - Configuring MAC addresses.
4105  * - Configuring multicast addresses.
4106  * - Configuring VLAN filters.
4107  * - Configuring Rx filters through the legacy API (e.g. FDIR).
4108  * - Configuring global RSS settings.
4109  *
4110  * @param port_id
4111  *   Port identifier of Ethernet device.
4112  * @param set
4113  *   Nonzero to enter isolated mode, attempt to leave it otherwise.
4114  * @param[out] error
4115  *   Perform verbose error reporting if not NULL. PMDs initialize this
4116  *   structure in case of error only.
4117  *
4118  * @return
4119  *   0 on success, a negative errno value otherwise and rte_errno is set.
4120  */
4121 int
4122 rte_flow_isolate(uint16_t port_id, int set, struct rte_flow_error *error);
4123
4124 /**
4125  * Initialize flow error structure.
4126  *
4127  * @param[out] error
4128  *   Pointer to flow error structure (may be NULL).
4129  * @param code
4130  *   Related error code (rte_errno).
4131  * @param type
4132  *   Cause field and error types.
4133  * @param cause
4134  *   Object responsible for the error.
4135  * @param message
4136  *   Human-readable error message.
4137  *
4138  * @return
4139  *   Negative error code (errno value) and rte_errno is set.
4140  */
4141 int
4142 rte_flow_error_set(struct rte_flow_error *error,
4143                    int code,
4144                    enum rte_flow_error_type type,
4145                    const void *cause,
4146                    const char *message);
4147
4148 /**
4149  * @deprecated
4150  * @see rte_flow_copy()
4151  */
4152 struct rte_flow_desc {
4153         size_t size; /**< Allocated space including data[]. */
4154         struct rte_flow_attr attr; /**< Attributes. */
4155         struct rte_flow_item *items; /**< Items. */
4156         struct rte_flow_action *actions; /**< Actions. */
4157         uint8_t data[]; /**< Storage for items/actions. */
4158 };
4159
4160 /**
4161  * @deprecated
4162  * Copy an rte_flow rule description.
4163  *
4164  * This interface is kept for compatibility with older applications but is
4165  * implemented as a wrapper to rte_flow_conv(). It is deprecated due to its
4166  * lack of flexibility and reliance on a type unusable with C++ programs
4167  * (struct rte_flow_desc).
4168  *
4169  * @param[in] fd
4170  *   Flow rule description.
4171  * @param[in] len
4172  *   Total size of allocated data for the flow description.
4173  * @param[in] attr
4174  *   Flow rule attributes.
4175  * @param[in] items
4176  *   Pattern specification (list terminated by the END pattern item).
4177  * @param[in] actions
4178  *   Associated actions (list terminated by the END action).
4179  *
4180  * @return
4181  *   If len is greater or equal to the size of the flow, the total size of the
4182  *   flow description and its data.
4183  *   If len is lower than the size of the flow, the number of bytes that would
4184  *   have been written to desc had it been sufficient. Nothing is written.
4185  */
4186 __rte_deprecated
4187 size_t
4188 rte_flow_copy(struct rte_flow_desc *fd, size_t len,
4189               const struct rte_flow_attr *attr,
4190               const struct rte_flow_item *items,
4191               const struct rte_flow_action *actions);
4192
4193 /**
4194  * Flow object conversion helper.
4195  *
4196  * This function performs conversion of various flow API objects to a
4197  * pre-allocated destination buffer. See enum rte_flow_conv_op for possible
4198  * operations and details about each of them.
4199  *
4200  * Since destination buffer must be large enough, it works in a manner
4201  * reminiscent of snprintf():
4202  *
4203  * - If @p size is 0, @p dst may be a NULL pointer, otherwise @p dst must be
4204  *   non-NULL.
4205  * - If positive, the returned value represents the number of bytes needed
4206  *   to store the conversion of @p src to @p dst according to @p op
4207  *   regardless of the @p size parameter.
4208  * - Since no more than @p size bytes can be written to @p dst, output is
4209  *   truncated and may be inconsistent when the returned value is larger
4210  *   than that.
4211  * - In case of conversion error, a negative error code is returned and
4212  *   @p dst contents are unspecified.
4213  *
4214  * @param op
4215  *   Operation to perform, related to the object type of @p dst.
4216  * @param[out] dst
4217  *   Destination buffer address. Must be suitably aligned by the caller.
4218  * @param size
4219  *   Destination buffer size in bytes.
4220  * @param[in] src
4221  *   Source object to copy. Depending on @p op, its type may differ from
4222  *   that of @p dst.
4223  * @param[out] error
4224  *   Perform verbose error reporting if not NULL. Initialized in case of
4225  *   error only.
4226  *
4227  * @return
4228  *   The number of bytes required to convert @p src to @p dst on success, a
4229  *   negative errno value otherwise and rte_errno is set.
4230  *
4231  * @see rte_flow_conv_op
4232  */
4233 __rte_experimental
4234 int
4235 rte_flow_conv(enum rte_flow_conv_op op,
4236               void *dst,
4237               size_t size,
4238               const void *src,
4239               struct rte_flow_error *error);
4240
4241 /**
4242  * Get aged-out flows of a given port.
4243  *
4244  * RTE_ETH_EVENT_FLOW_AGED event will be triggered when at least one new aged
4245  * out flow was detected after the last call to rte_flow_get_aged_flows.
4246  * This function can be called to get the aged flows usynchronously from the
4247  * event callback or synchronously regardless the event.
4248  * This is not safe to call rte_flow_get_aged_flows function with other flow
4249  * functions from multiple threads simultaneously.
4250  *
4251  * @param port_id
4252  *   Port identifier of Ethernet device.
4253  * @param[in, out] contexts
4254  *   The address of an array of pointers to the aged-out flows contexts.
4255  * @param[in] nb_contexts
4256  *   The length of context array pointers.
4257  * @param[out] error
4258  *   Perform verbose error reporting if not NULL. Initialized in case of
4259  *   error only.
4260  *
4261  * @return
4262  *   if nb_contexts is 0, return the amount of all aged contexts.
4263  *   if nb_contexts is not 0 , return the amount of aged flows reported
4264  *   in the context array, otherwise negative errno value.
4265  *
4266  * @see rte_flow_action_age
4267  * @see RTE_ETH_EVENT_FLOW_AGED
4268  */
4269 __rte_experimental
4270 int
4271 rte_flow_get_aged_flows(uint16_t port_id, void **contexts,
4272                         uint32_t nb_contexts, struct rte_flow_error *error);
4273
4274 /**
4275  * Specify indirect action object configuration
4276  */
4277 struct rte_flow_indir_action_conf {
4278         /**
4279          * Flow direction for the indirect action configuration.
4280          *
4281          * Action should be valid at least for one flow direction,
4282          * otherwise it is invalid for both ingress and egress rules.
4283          */
4284         /** Action valid for rules applied to ingress traffic. */
4285         uint32_t ingress:1;
4286         /** Action valid for rules applied to egress traffic. */
4287         uint32_t egress:1;
4288         /**
4289          * When set to 1, indicates that the action is valid for
4290          * transfer traffic; otherwise, for non-transfer traffic.
4291          */
4292         uint32_t transfer:1;
4293 };
4294
4295 /**
4296  * @warning
4297  * @b EXPERIMENTAL: this API may change without prior notice.
4298  *
4299  * Create an indirect action object that can be used in flow rules
4300  * via its handle.
4301  * The created object handle has single state and configuration
4302  * across all the flow rules using it.
4303  *
4304  * @param[in] port_id
4305  *    The port identifier of the Ethernet device.
4306  * @param[in] conf
4307  *   Action configuration for the indirect action object creation.
4308  * @param[in] action
4309  *   Specific configuration of the indirect action object.
4310  * @param[out] error
4311  *   Perform verbose error reporting if not NULL. PMDs initialize this
4312  *   structure in case of error only.
4313  * @return
4314  *   A valid handle in case of success, NULL otherwise and rte_errno is set
4315  *   to one of the error codes defined:
4316  *   - (ENODEV) if *port_id* invalid.
4317  *   - (ENOSYS) if underlying device does not support this functionality.
4318  *   - (EIO) if underlying device is removed.
4319  *   - (EINVAL) if *action* invalid.
4320  *   - (ENOTSUP) if *action* valid but unsupported.
4321  */
4322 __rte_experimental
4323 struct rte_flow_action_handle *
4324 rte_flow_action_handle_create(uint16_t port_id,
4325                               const struct rte_flow_indir_action_conf *conf,
4326                               const struct rte_flow_action *action,
4327                               struct rte_flow_error *error);
4328
4329 /**
4330  * @warning
4331  * @b EXPERIMENTAL: this API may change without prior notice.
4332  *
4333  * Destroy indirect action by handle.
4334  *
4335  * @param[in] port_id
4336  *    The port identifier of the Ethernet device.
4337  * @param[in] handle
4338  *   Handle for the indirect action object to be destroyed.
4339  * @param[out] error
4340  *   Perform verbose error reporting if not NULL. PMDs initialize this
4341  *   structure in case of error only.
4342  * @return
4343  *   - (0) if success.
4344  *   - (-ENODEV) if *port_id* invalid.
4345  *   - (-ENOSYS) if underlying device does not support this functionality.
4346  *   - (-EIO) if underlying device is removed.
4347  *   - (-ENOENT) if action pointed by *action* handle was not found.
4348  *   - (-EBUSY) if action pointed by *action* handle still used by some rules
4349  *   rte_errno is also set.
4350  */
4351 __rte_experimental
4352 int
4353 rte_flow_action_handle_destroy(uint16_t port_id,
4354                                struct rte_flow_action_handle *handle,
4355                                struct rte_flow_error *error);
4356
4357 /**
4358  * @warning
4359  * @b EXPERIMENTAL: this API may change without prior notice.
4360  *
4361  * Update in-place the action configuration and / or state pointed
4362  * by action *handle* with the configuration provided as *update* argument.
4363  * The update of the action configuration effects all flow rules reusing
4364  * the action via *handle*.
4365  * The update general pointer provides the ability of partial updating.
4366  *
4367  * @param[in] port_id
4368  *    The port identifier of the Ethernet device.
4369  * @param[in] handle
4370  *   Handle for the indirect action object to be updated.
4371  * @param[in] update
4372  *   Update profile specification used to modify the action pointed by handle.
4373  *   *update* could be with the same type of the immediate action corresponding
4374  *   to the *handle* argument when creating, or a wrapper structure includes
4375  *   action configuration to be updated and bit fields to indicate the member
4376  *   of fields inside the action to update.
4377  * @param[out] error
4378  *   Perform verbose error reporting if not NULL. PMDs initialize this
4379  *   structure in case of error only.
4380  * @return
4381  *   - (0) if success.
4382  *   - (-ENODEV) if *port_id* invalid.
4383  *   - (-ENOSYS) if underlying device does not support this functionality.
4384  *   - (-EIO) if underlying device is removed.
4385  *   - (-EINVAL) if *update* invalid.
4386  *   - (-ENOTSUP) if *update* valid but unsupported.
4387  *   - (-ENOENT) if indirect action object pointed by *handle* was not found.
4388  *   rte_errno is also set.
4389  */
4390 __rte_experimental
4391 int
4392 rte_flow_action_handle_update(uint16_t port_id,
4393                               struct rte_flow_action_handle *handle,
4394                               const void *update,
4395                               struct rte_flow_error *error);
4396
4397 /**
4398  * @warning
4399  * @b EXPERIMENTAL: this API may change without prior notice.
4400  *
4401  * Query the direct action by corresponding indirect action object handle.
4402  *
4403  * Retrieve action-specific data such as counters.
4404  * Data is gathered by special action which may be present/referenced in
4405  * more than one flow rule definition.
4406  *
4407  * @see RTE_FLOW_ACTION_TYPE_COUNT
4408  *
4409  * @param port_id
4410  *   Port identifier of Ethernet device.
4411  * @param[in] handle
4412  *   Handle for the action object to query.
4413  * @param[in, out] data
4414  *   Pointer to storage for the associated query data type.
4415  * @param[out] error
4416  *   Perform verbose error reporting if not NULL. PMDs initialize this
4417  *   structure in case of error only.
4418  *
4419  * @return
4420  *   0 on success, a negative errno value otherwise and rte_errno is set.
4421  */
4422 __rte_experimental
4423 int
4424 rte_flow_action_handle_query(uint16_t port_id,
4425                              const struct rte_flow_action_handle *handle,
4426                              void *data, struct rte_flow_error *error);
4427
4428 /* Tunnel has a type and the key information. */
4429 struct rte_flow_tunnel {
4430         /**
4431          * Tunnel type, for example RTE_FLOW_ITEM_TYPE_VXLAN,
4432          * RTE_FLOW_ITEM_TYPE_NVGRE etc.
4433          */
4434         enum rte_flow_item_type type;
4435         uint64_t tun_id; /**< Tunnel identification. */
4436
4437         RTE_STD_C11
4438         union {
4439                 struct {
4440                         rte_be32_t src_addr; /**< IPv4 source address. */
4441                         rte_be32_t dst_addr; /**< IPv4 destination address. */
4442                 } ipv4;
4443                 struct {
4444                         uint8_t src_addr[16]; /**< IPv6 source address. */
4445                         uint8_t dst_addr[16]; /**< IPv6 destination address. */
4446                 } ipv6;
4447         };
4448         rte_be16_t tp_src; /**< Tunnel port source. */
4449         rte_be16_t tp_dst; /**< Tunnel port destination. */
4450         uint16_t   tun_flags; /**< Tunnel flags. */
4451
4452         bool       is_ipv6; /**< True for valid IPv6 fields. Otherwise IPv4. */
4453
4454         /**
4455          * the following members are required to restore packet
4456          * after miss
4457          */
4458         uint8_t    tos; /**< TOS for IPv4, TC for IPv6. */
4459         uint8_t    ttl; /**< TTL for IPv4, HL for IPv6. */
4460         uint32_t label; /**< Flow Label for IPv6. */
4461 };
4462
4463 /**
4464  * Indicate that the packet has a tunnel.
4465  */
4466 #define RTE_FLOW_RESTORE_INFO_TUNNEL RTE_BIT64(0)
4467
4468 /**
4469  * Indicate that the packet has a non decapsulated tunnel header.
4470  */
4471 #define RTE_FLOW_RESTORE_INFO_ENCAPSULATED RTE_BIT64(1)
4472
4473 /**
4474  * Indicate that the packet has a group_id.
4475  */
4476 #define RTE_FLOW_RESTORE_INFO_GROUP_ID RTE_BIT64(2)
4477
4478 /**
4479  * Restore information structure to communicate the current packet processing
4480  * state when some of the processing pipeline is done in hardware and should
4481  * continue in software.
4482  */
4483 struct rte_flow_restore_info {
4484         /**
4485          * Bitwise flags (RTE_FLOW_RESTORE_INFO_*) to indicate validation of
4486          * other fields in struct rte_flow_restore_info.
4487          */
4488         uint64_t flags;
4489         uint32_t group_id; /**< Group ID where packed missed */
4490         struct rte_flow_tunnel tunnel; /**< Tunnel information. */
4491 };
4492
4493 /**
4494  * Allocate an array of actions to be used in rte_flow_create, to implement
4495  * tunnel-decap-set for the given tunnel.
4496  * Sample usage:
4497  *   actions vxlan_decap / tunnel-decap-set(tunnel properties) /
4498  *            jump group 0 / end
4499  *
4500  * @param port_id
4501  *   Port identifier of Ethernet device.
4502  * @param[in] tunnel
4503  *   Tunnel properties.
4504  * @param[out] actions
4505  *   Array of actions to be allocated by the PMD. This array should be
4506  *   concatenated with the actions array provided to rte_flow_create.
4507  * @param[out] num_of_actions
4508  *   Number of actions allocated.
4509  * @param[out] error
4510  *   Perform verbose error reporting if not NULL. PMDs initialize this
4511  *   structure in case of error only.
4512  *
4513  * @return
4514  *   0 on success, a negative errno value otherwise and rte_errno is set.
4515  */
4516 __rte_experimental
4517 int
4518 rte_flow_tunnel_decap_set(uint16_t port_id,
4519                           struct rte_flow_tunnel *tunnel,
4520                           struct rte_flow_action **actions,
4521                           uint32_t *num_of_actions,
4522                           struct rte_flow_error *error);
4523
4524 /**
4525  * Allocate an array of items to be used in rte_flow_create, to implement
4526  * tunnel-match for the given tunnel.
4527  * Sample usage:
4528  *   pattern tunnel-match(tunnel properties) / outer-header-matches /
4529  *           inner-header-matches / end
4530  *
4531  * @param port_id
4532  *   Port identifier of Ethernet device.
4533  * @param[in] tunnel
4534  *   Tunnel properties.
4535  * @param[out] items
4536  *   Array of items to be allocated by the PMD. This array should be
4537  *   concatenated with the items array provided to rte_flow_create.
4538  * @param[out] num_of_items
4539  *   Number of items allocated.
4540  * @param[out] error
4541  *   Perform verbose error reporting if not NULL. PMDs initialize this
4542  *   structure in case of error only.
4543  *
4544  * @return
4545  *   0 on success, a negative errno value otherwise and rte_errno is set.
4546  */
4547 __rte_experimental
4548 int
4549 rte_flow_tunnel_match(uint16_t port_id,
4550                       struct rte_flow_tunnel *tunnel,
4551                       struct rte_flow_item **items,
4552                       uint32_t *num_of_items,
4553                       struct rte_flow_error *error);
4554
4555 /**
4556  * Populate the current packet processing state, if exists, for the given mbuf.
4557  *
4558  * One should negotiate tunnel metadata delivery from the NIC to the HW.
4559  * @see rte_eth_rx_metadata_negotiate()
4560  * @see RTE_ETH_RX_METADATA_TUNNEL_ID
4561  *
4562  * @param port_id
4563  *   Port identifier of Ethernet device.
4564  * @param[in] m
4565  *   Mbuf struct.
4566  * @param[out] info
4567  *   Restore information. Upon success contains the HW state.
4568  * @param[out] error
4569  *   Perform verbose error reporting if not NULL. PMDs initialize this
4570  *   structure in case of error only.
4571  *
4572  * @return
4573  *   0 on success, a negative errno value otherwise and rte_errno is set.
4574  */
4575 __rte_experimental
4576 int
4577 rte_flow_get_restore_info(uint16_t port_id,
4578                           struct rte_mbuf *m,
4579                           struct rte_flow_restore_info *info,
4580                           struct rte_flow_error *error);
4581
4582 /**
4583  * Release the action array as allocated by rte_flow_tunnel_decap_set.
4584  *
4585  * @param port_id
4586  *   Port identifier of Ethernet device.
4587  * @param[in] actions
4588  *   Array of actions to be released.
4589  * @param[in] num_of_actions
4590  *   Number of elements in actions array.
4591  * @param[out] error
4592  *   Perform verbose error reporting if not NULL. PMDs initialize this
4593  *   structure in case of error only.
4594  *
4595  * @return
4596  *   0 on success, a negative errno value otherwise and rte_errno is set.
4597  */
4598 __rte_experimental
4599 int
4600 rte_flow_tunnel_action_decap_release(uint16_t port_id,
4601                                      struct rte_flow_action *actions,
4602                                      uint32_t num_of_actions,
4603                                      struct rte_flow_error *error);
4604
4605 /**
4606  * Release the item array as allocated by rte_flow_tunnel_match.
4607  *
4608  * @param port_id
4609  *   Port identifier of Ethernet device.
4610  * @param[in] items
4611  *   Array of items to be released.
4612  * @param[in] num_of_items
4613  *   Number of elements in item array.
4614  * @param[out] error
4615  *   Perform verbose error reporting if not NULL. PMDs initialize this
4616  *   structure in case of error only.
4617  *
4618  * @return
4619  *   0 on success, a negative errno value otherwise and rte_errno is set.
4620  */
4621 __rte_experimental
4622 int
4623 rte_flow_tunnel_item_release(uint16_t port_id,
4624                              struct rte_flow_item *items,
4625                              uint32_t num_of_items,
4626                              struct rte_flow_error *error);
4627
4628 /**
4629  * @warning
4630  * @b EXPERIMENTAL: this API may change without prior notice.
4631  *
4632  * Get a proxy port to manage "transfer" flows.
4633  *
4634  * Managing "transfer" flows requires that the user communicate them
4635  * via a port which has the privilege to control the embedded switch.
4636  * For some vendors, all ports in a given switching domain have
4637  * this privilege. For other vendors, it's only one port.
4638  *
4639  * This API indicates such a privileged port (a "proxy")
4640  * for a given port in the same switching domain.
4641  *
4642  * @note
4643  *   If the PMD serving @p port_id doesn't have the corresponding method
4644  *   implemented, the API will return @p port_id via @p proxy_port_id.
4645  *
4646  * @param port_id
4647  *   Indicates the port to get a "proxy" for
4648  * @param[out] proxy_port_id
4649  *   Indicates the "proxy" port
4650  * @param[out] error
4651  *   If not NULL, allows the PMD to provide verbose report in case of error
4652  *
4653  * @return
4654  *   0 on success, a negative error code otherwise
4655  */
4656 __rte_experimental
4657 int
4658 rte_flow_pick_transfer_proxy(uint16_t port_id, uint16_t *proxy_port_id,
4659                              struct rte_flow_error *error);
4660
4661 /**
4662  * @warning
4663  * @b EXPERIMENTAL: this API may change without prior notice.
4664  *
4665  * Create the flex item with specified configuration over
4666  * the Ethernet device.
4667  *
4668  * @param port_id
4669  *   Port identifier of Ethernet device.
4670  * @param[in] conf
4671  *   Item configuration.
4672  * @param[out] error
4673  *   Perform verbose error reporting if not NULL. PMDs initialize this
4674  *   structure in case of error only.
4675  *
4676  * @return
4677  *   Non-NULL opaque pointer on success, NULL otherwise and rte_errno is set.
4678  */
4679 __rte_experimental
4680 struct rte_flow_item_flex_handle *
4681 rte_flow_flex_item_create(uint16_t port_id,
4682                           const struct rte_flow_item_flex_conf *conf,
4683                           struct rte_flow_error *error);
4684
4685 /**
4686  * Release the flex item on the specified Ethernet device.
4687  *
4688  * @param port_id
4689  *   Port identifier of Ethernet device.
4690  * @param[in] handle
4691  *   Handle of the item existing on the specified device.
4692  * @param[out] error
4693  *   Perform verbose error reporting if not NULL. PMDs initialize this
4694  *   structure in case of error only.
4695  *
4696  * @return
4697  *   0 on success, a negative errno value otherwise and rte_errno is set.
4698  */
4699 __rte_experimental
4700 int
4701 rte_flow_flex_item_release(uint16_t port_id,
4702                            const struct rte_flow_item_flex_handle *handle,
4703                            struct rte_flow_error *error);
4704
4705 #ifdef __cplusplus
4706 }
4707 #endif
4708
4709 #endif /* RTE_FLOW_H_ */