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